diff --git a/lib/cancellationToken.js b/lib/cancellationToken.js index 76a6a60e72976..0d4569c601b91 100644 --- a/lib/cancellationToken.js +++ b/lib/cancellationToken.js @@ -49,7 +49,7 @@ function createCancellationToken(args) { }, resetRequest: function (requestId) { if (currentRequestId_1 !== requestId) { - throw new Error("Mismatched request id, expected " + currentRequestId_1 + ", actual " + requestId); + throw new Error("Mismatched request id, expected ".concat(currentRequestId_1, ", actual ").concat(requestId)); } perRequestPipeName_1 = undefined; } diff --git a/lib/cs/diagnosticMessages.generated.json b/lib/cs/diagnosticMessages.generated.json index 46a209f6cb3b1..fe4fc2822215a 100644 --- a/lib/cs/diagnosticMessages.generated.json +++ b/lib/cs/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "Typ this je k dispozici jenom v nestatických členech třídy nebo rozhraní.", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "Soubor tsconfig.json je už v {0} definovaný.", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "Člen řazené kolekce členů nemůže být volitelný a zbytek.", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "Typ řazené kolekce členů není možné indexovat zápornou hodnotou.", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "Výraz potvrzení typu se na levé straně výrazu umocnění nepovoluje. Zvažte možnost uzavření výrazu do závorek.", "A_type_literal_property_cannot_have_an_initializer_1247": "Vlastnost literálu typu nemůže mít inicializátor.", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "Import, při kterém se importují jen typy, může určovat výchozí import nebo pojmenované vazby, ale ne obojí.", @@ -132,8 +133,8 @@ "Add_definite_assignment_assertion_to_property_0_95020": "Přidat kontrolní výraz jednoznačného přiřazení k vlastnosti {0}", "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": "Přidat kontrolní výrazy jednoznačného přiřazení do všech neinicializovaných vlastností", "Add_export_to_make_this_file_into_a_module_95097": "Přidat export {}, aby se tento soubor převedl na modul", - "Add_extends_constraint_2211": "Add `extends` constraint.", - "Add_extends_constraint_to_all_type_parameters_2212": "Add `extends` constraint to all type parameters", + "Add_extends_constraint_2211": "Přidejte omezení extends.", + "Add_extends_constraint_to_all_type_parameters_2212": "Přidat omezení extends ke všem parametrům typu", "Add_import_from_0_90057": "Přidat import z {0}", "Add_index_signature_for_property_0_90017": "Přidat signaturu indexu pro vlastnost {0}", "Add_initializer_to_property_0_95019": "Přidat inicializační výraz k vlastnosti {0}", @@ -226,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "V parametru signatury indexu nemůže být anotace typu.", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "Typ parametru signatury indexu nemůže být typ literálu nebo obecný typ. Místo toho zvažte použití namapovaného typu objektu.", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "Typ parametru signatury indexu musí být řetězec, číslo, symbol nebo typ literálu šablony.", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "Po výrazu vytvoření instance nemůže následovat přístup k vlastnosti.", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "Rozhraní může rozšířit jenom identifikátor nebo kvalifikovaný název s volitelnými argumenty typu.", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "Rozhraní může rozšiřovat jen typ objektu nebo průsečík typů objektů se staticky známými členy.", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "Rozhraní nemůže rozšířit primitivní typ, jako je {0}; rozhraní může rozšířit jenom pojmenované typy a třídy.", @@ -700,6 +702,10 @@ "File_0_not_found_6053": "Soubor {0} se nenašel.", "File_Management_6245": "Správa souborů", "File_change_detected_Starting_incremental_compilation_6032": "Zjistila se změna souboru. Spouští se přírůstková kompilace...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "Soubor je modul CommonJS, protože {0} nemá pole type", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "Soubor je modul CommonJS, protože {0} má pole type, jehož hodnota není module", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "Soubor je modul CommonJS, protože se nenašel package.json", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "Soubor je modul ECMAScript, protože {0} má pole type s hodnotou module", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "Soubor je modul CommonJS; může být převeden na modul ES.", "File_is_default_library_for_target_specified_here_1426": "Soubor je výchozí knihovna pro cíl, který se zadal na tomto místě.", "File_is_entry_point_of_type_library_specified_here_1419": "Soubor je vstupní bod knihovny typů, která se zadala na tomto místě.", @@ -774,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "Očekává se identifikátor. {0} je rezervované slovo, které se tady nedá použít.", "Identifier_expected_1003": "Očekával se identifikátor.", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "Očekává se identifikátor. __esModule je při transformaci modulů ECMAScript rezervované jako označení exportu.", + "Identifier_or_string_literal_expected_1478": "Očekává se identifikátor nebo řetězcový literál.", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "Pokud balíček ‚{0}‘ ve skutečnosti zveřejňuje tento modul, zvažte možnost poslat žádost o přijetí změn, aby se připojila adresa ‚https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}‘", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "Pokud balíček {0} skutečně zpřístupňuje tento modul, zkuste přidat nový soubor deklarace (.d.ts), který obsahuje declare module {1};", "Ignore_this_error_message_90019": "Ignorovat tuto chybovou zprávu", @@ -1495,7 +1502,7 @@ "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354": "Tato syntaxe vyžaduje importovanou podpůrnou aplikaci, ale modul {0} se nenašel.", "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Tato syntaxe vyžaduje importovanou pomocnou rutinu s názvem {1}, která v {0} neexistuje. Zvažte možnost upgradovat verzi {0}.", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Tato syntaxe vyžaduje importovanou pomocnou rutinu s názvem {1} a parametry {2}, která není kompatibilní s tou v {0}. Zvažte upgrade verze {0}.", - "This_type_parameter_might_need_an_extends_0_constraint_2208": "This type parameter might need an `extends {0}` constraint.", + "This_type_parameter_might_need_an_extends_0_constraint_2208": "Tento parametr typu může potřebovat omezení extends {0}.", "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "Toto použití importu není platné. Volání import() se dají zapsat, ale musí mít závorky a nemůžou mít typové argumenty.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378": "Výrazy await nejvyšší úrovně se povolují jen v případě, že možnost module je nastavená na es2022, esnext, system, node16 nebo nodenext a možnost target je nastavená na es2017 nebo vyšší.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "Deklarace nejvyšší úrovně v souborech .d.ts musí začínat modifikátorem declare, nebo export.", @@ -1561,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "Knihovna typů, na kterou se odkazuje přes {0} ze souboru {1} s packageId {2}", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "Typ operandu await musí být buď platný příslib, nebo nesmí obsahovat člen then, který se dá volat.", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "Typ hodnoty počítané vlastnosti je {0} a nedá se přiřadit do typu {1}.", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "Typ instance členské proměnné {0} nemůže odkazovat na identifikátor {1} deklarovaný v konstruktoru.", "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.", @@ -1588,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== Direktiva odkazu na typ {0} se nepřeložila. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== Direktiva odkazu na typ {0} se úspěšně přeložila na {1}, primární: {2}. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== Direktiva odkazu na typ {0} se úspěšně přeložila na {1} s ID balíčku {2}, primární: {3}. ========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "Typy se v deklaracích exportu v souborech JavaScriptu nemůžou vyskytovat.", "Types_have_separate_declarations_of_a_private_property_0_2442": "Typy mají samostatné deklarace privátní vlastnosti {0}.", "Types_of_construct_signatures_are_incompatible_2419": "Typy signatur konstruktorů nejsou kompatibilní.", "Types_of_parameters_0_and_1_are_incompatible_2328": "Typy parametrů {0} a {1} jsou nekompatibilní.", @@ -1665,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "Uzavřít následující kód, který by měl být literál objektu, do závorek", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "Informace o všech možnostech kompilátoru najdete na {0}", "You_cannot_rename_a_module_via_a_global_import_8031": "Přes globální import se modul nedá přejmenovat.", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "Nelze přejmenovat elementy definované ve složce node_modules.", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "Nelze přejmenovat elementy definované v jiné složce node_modules.", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "Nejde přejmenovat elementy definované ve standardní knihovně TypeScriptu.", "You_cannot_rename_this_element_8000": "Tento element nejde přejmenovat.", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "Objekt {0} přijímá málo argumentů k tomu, aby se dal použít jako dekoratér. Nechtěli jste ho nejprve volat a napsat @{0}()?", @@ -1692,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "Signatury indexu {0} jsou nekompatibilní.", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "{0} Typ indexu {1} se nedá přiřadit k {2} typu indexu {3}.", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "{0} je primitivum, ale {1} je obálkový objekt. Pokud je to možné, použijte raději {0}.", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "{0} je typ a nedá se importovat do javascriptových souborů. V poznámce typu JSDoc použijte {1}.", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "Hodnota {0} je typ a musí být importována pomocí importu, který se bude zadávat jenom v případě, že jsou povolené parametry preserveValueImports a isolatedModules.", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "{0} je nepoužívané přejmenování {1}. Chtěli jste ji použít jako poznámku typu?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "{0} se dá přiřadit k omezení typu {1}, ale pro {1} se dala vytvořit instance s jiným podtypem omezení {2}.", + "_0_is_automatically_exported_here_18044": "{0} se sem automaticky exportuje.", "_0_is_declared_but_its_value_is_never_read_6133": "Deklaruje se {0}, ale jeho hodnota se vůbec nečte.", "_0_is_declared_but_never_used_6196": "{0} se nadeklarovalo, ale nepoužilo.", "_0_is_declared_here_2728": "{0} je deklarované tady.", diff --git a/lib/de/diagnosticMessages.generated.json b/lib/de/diagnosticMessages.generated.json index b7e22809ce950..5e4c01914273c 100644 --- a/lib/de/diagnosticMessages.generated.json +++ b/lib/de/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "Ein this-Typ ist nur in einem nicht statischen Member einer Klasse oder Schnittstelle verfügbar.", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "Eine Datei \"tsconfig.json\" ist bereits definiert unter: \"{0}\".", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "Ein Tupelelement kann nicht gleichzeitig als \"optional\" und als \"rest\" festgelegt werden.", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "Ein Tupeltyp kann nicht mit einem negativen Wert indiziert werden.", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "Typassertionsausdrücke sind in der linken Seite von Potenzierungsausdrücken nicht zulässig. Erwägen Sie, den Ausdruck in Klammern zu setzen.", "A_type_literal_property_cannot_have_an_initializer_1247": "Typliteraleigenschaften können keinen Initialisierer aufweisen.", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "Ein reiner Typenimport kann einen Standardimport oder benannte Bindungen angeben, aber nicht beides.", @@ -132,6 +133,8 @@ "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 in ein Modul umzuwandeln", + "Add_extends_constraint_2211": "\"extends\"-Einschränkung hinzufügen", + "Add_extends_constraint_to_all_type_parameters_2212": "\"extends\"-Einschränkung zu allen Typparametern hinzufügen", "Add_import_from_0_90057": "Import aus \"{0}\" hinzufügen", "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", @@ -224,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "Ein Indexsignaturparameter muss eine Typanmerkung besitzen.", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "Ein Indexsignaturparametertyp darf kein Literaltyp oder generischer Typ sein. Erwägen Sie stattdessen die Verwendung eines zugeordneten Objekttyps.", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "Ein Parametertyp für die Indexsignatur muss \"string\", \"number\", \"symbol\" oder ein Vorlagenliteraltyp sein.", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "Auf einen Instanziierungsausdruck kann kein Eigenschaftenzugriff folgen.", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "Eine Schnittstelle kann nur einen Bezeichner/\"qualified-name\" mit optionalen Typargumenten erweitern.", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "Eine Schnittstelle kann nur einen Objekttyp oder eine Schnittmenge von Objekttypen mit statisch bekannten Membern erweitern.", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "Eine Schnittstelle kann einen primitiven Typ wie „{0}“ nicht erweitern; eine Schnittstelle kann nur benannte Typen und Klassen erweitern", @@ -698,6 +702,10 @@ "File_0_not_found_6053": "Die Datei \"{0}\" wurde nicht gefunden.", "File_Management_6245": "Dateiverwaltung", "File_change_detected_Starting_incremental_compilation_6032": "Es wurde eine Dateiänderung erkannt. Die inkrementelle Kompilierung wird gestartet...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "Die Datei ist ein CommonJS-Modul, da '{0}' nicht das Feld „Typ“ aufweist", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "Die Datei ist ein CommonJS-Modul, da '{0}' das Feld „Typ“ aufweist, dessen Wert nicht „Modul“ ist", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "Die Datei ist ein CommonJS-Modul, da „package.json“ nicht gefunden wurde", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "Die Datei ist ein ECMAScript-Modul, da '{0}' das Feld „Typ“ mit dem Wert „Modul“ aufweist.", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "Die Datei ist ein CommonJS-Modul und kann möglicherweise in ein ES-Modul konvertiert werden.", "File_is_default_library_for_target_specified_here_1426": "Die Datei ist die Standardbibliothek für das hier angegebene Ziel.", "File_is_entry_point_of_type_library_specified_here_1419": "Die Datei ist ein Einstiegspunkt der hier angegebenen Typbibliothek.", @@ -772,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "Bezeichner erwartet. \"{0}\" ist ein reserviertes Wort, das hier nicht verwendet werden kann.", "Identifier_expected_1003": "Es wurde ein Bezeichner erwartet.", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "Bezeichner erwartet. \"__esModule\" ist als exportierter Marker für die Umwandlung von ECMAScript-Modulen reserviert.", + "Identifier_or_string_literal_expected_1478": "Bezeichner oder Zeichenfolgenliteral erwartet.", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "Wenn das Paket \"{0}\" dieses Modul tatsächlich verfügbar macht, erwägen Sie, einen Pull Request zum Ändern von https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1} zu senden.", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "Wenn das Paket \"{0}\" dieses Modul tatsächlich verfügbar macht, versuchen Sie, eine neue Deklarationsdatei (.d.ts) hinzuzufügen, die Declare-Modul \"{1}\" enthält.", "Ignore_this_error_message_90019": "Diese Fehlermeldung ignorieren", @@ -1493,7 +1502,7 @@ "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354": "Diese Syntax erfordert ein importiertes Hilfsprogramm, aber das Modul \"{0}\" wurde nicht gefunden.", "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Diese Syntax erfordert ein importiertes Hilfsprogramm namens \"{1}\", das in \"{0}\" nicht vorhanden ist. Erwägen Sie ein Upgrade Ihrer Version von \"{0}\".", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Diese Syntax erfordert ein importiertes Hilfsprogramm mit dem Namen \"{1}\" mit {2} Parametern, die nicht mit der in \"{0}\" kompatibel ist. Erwägen Sie ein Upgrade Ihrer Version von \"{0}\".", - "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Dieser Typparameter benötigt wahrscheinlich eine „extends object“-Einschränkung.", + "This_type_parameter_might_need_an_extends_0_constraint_2208": "Für diesen Typparameter ist möglicherweise die Einschränkung \"extends {0}\" erforderlich.", "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "Diese Verwendung von „import“ ist ungültig. „import()“-Aufrufe können geschrieben werden, müssen jedoch Klammern aufweisen und dürfen keine Typargumente aufweisen.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378": "'await'-Ausdrücke der obersten Ebene sind nur zulässig, wenn die 'module'-Option auf 'es2022', 'esnext', 'system', 'node16' oder 'nodenext' und die 'target'-Option auf ' es2017' oder höher.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "Deklarationen der obersten Ebene in .d.ts-Dateien müssen entweder mit einem declare- oder einem export-Modifizierer beginnen.", @@ -1559,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "Typbibliothek, die über \"{0}\" aus der Datei \"{1}\" mit packageId \"{2}\" referenziert wird", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "Der Typ des \"await\"-Operanden muss entweder eine gültige Zusage sein oder darf keinen aufrufbaren \"then\"-Member enthalten.", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "Der Typ des Werts der berechneten Eigenschaft lautet \"{0}\" und kann dem Typ \"{1}\" nicht zugewiesen werden.", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "Der Typ der Instanzmembervariablen „{0}“ darf nicht auf den im Konstruktor deklarierten Bezeichner „{1}“ verweisen.", "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.", @@ -1586,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== Die Typverweisdirektive \"{0}\" wurde nicht aufgelöst. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== Die Typverweisdirektive \"{0}\" wurde erfolgreich in \"{1}\" aufgelöst. Primär: {2}. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== Die Typverweisdirektive \"{0}\" wurde erfolgreich in \"{1}\" mit Paket-ID \"{2}\" aufgelöst. Primär: {3}. ========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "Typen können in Exportdeklarationen in JavaScript-Dateien nicht angezeigt werden.", "Types_have_separate_declarations_of_a_private_property_0_2442": "Typen weisen separate Deklarationen einer privaten Eigenschaft \"{0}\" auf.", "Types_of_construct_signatures_are_incompatible_2419": "Die Typen der Konstruktsignaturen sind nicht kompatibel.", "Types_of_parameters_0_and_1_are_incompatible_2328": "Die Typen der Parameter \"{0}\" und \"{1}\" sind nicht kompatibel.", @@ -1663,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "Schließen Sie den folgenden Text, der ein Objektliteral darstellt, in Klammern ein.", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "Informationen zu allen Compileroptionen finden Sie unter {0}", "You_cannot_rename_a_module_via_a_global_import_8031": "Ein Modul kann nicht über einen globalen Import umbenannt werden.", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "Elemente, die in einem Ordner \"node_modules\" definiert sind, können nicht umbenannt werden.", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "Elemente, die in einem anderen Ordner \"node_modules\" definiert sind, können nicht umbenannt werden.", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "Sie können keine Elemente umbenennen, die in der TypeScript-Standardbibliothek definiert sind.", "You_cannot_rename_this_element_8000": "Sie können dieses Element nicht umbenennen.", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "\"{0}\" akzeptiert zu wenige Argumente, um hier als Decorator verwendet zu werden. Wollten Sie es zuerst aufrufen und \"@{0}()\" schreiben?", @@ -1690,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "\"{0}\" Indexsignaturen sind inkompatibel.", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "\"{0}\" Indextyp \"{1}\" kann nicht \"{2}\" Indextyp \"{3}\" zugewiesen werden.", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "\"{0}\" ist ein primitiver Typ, aber \"{1}\" ist ein Wrapperobjekt. Verwenden Sie vorzugsweise \"{0}\", wenn möglich.", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "\"{0}\" ist ein Typ und kann nicht in JavaScript-Dateien importiert werden. Verwenden Sie \"{1}\" in einer JSDoc-Typanmerkung.", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "„{0}“ ist ein Typ und muss mithilfe eines reinen Typimports importiert werden, wenn „preserveValueImports“ und isolatedModules“ beide aktiviert sind.", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "„{0}“ ist eine nicht verwendete Umbenennung von „{1}“. Wollten Sie sie als Typanmerkung verwenden?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "\"{0}\" kann der Einschränkung vom Typ \"{1}\" zugewiesen werden, aber \"{1}\" könnte mit einem anderen Untertyp der Einschränkung \"{2}\" instanziiert werden.", + "_0_is_automatically_exported_here_18044": "\"{0}\" wird hier automatisch exportiert.", "_0_is_declared_but_its_value_is_never_read_6133": "\"{0}\" ist deklariert, aber der zugehörige Wert wird nie gelesen.", "_0_is_declared_but_never_used_6196": "\"{0}\" ist deklariert, wird aber nie verwendet.", "_0_is_declared_here_2728": "\"{0}\" wird hier deklariert.", diff --git a/lib/es/diagnosticMessages.generated.json b/lib/es/diagnosticMessages.generated.json index bc3214620ad82..06fd2b618cc6d 100644 --- a/lib/es/diagnosticMessages.generated.json +++ b/lib/es/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "El tipo \"this\" solo está disponible en un miembro no estático de una clase o interfaz.", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "Ya hay un archivo \"tsconfig.json\" definido en: '{0}'.", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "Un miembro de tupla no puede ser tanto opcional como REST.", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "Un tipo de tupla no se puede indizar con un valor negativo.", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "No se admite una expresión de aserción de tipo en el lado izquierdo de una expresión de exponenciación. Considere la posibilidad de incluir la expresión entre paréntesis.", "A_type_literal_property_cannot_have_an_initializer_1247": "Una propiedad de literal de tipo no puede tener un inicializador.", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "Una importación solo de tipo puede especificar una importación predeterminada o enlaces con nombre, pero no ambos.", @@ -226,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "Un parámetro de signatura de índice debe tener una anotación de tipo.", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "Un tipo de parámetro de signatura de índice no puede ser un tipo literal o un tipo genérico. Considere la posibilidad de usar, en su lugar, uno de los tipos de objeto asignados.", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "El tipo de parámetro de la signatura de índice debe ser \"string\", \"number\", \"symbol\" o un tipo literal de plantilla.", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "Una expresión de creación de una instancia no puede ir seguida de un acceso a una propiedad.", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "Una interfaz solo puede extender un identificador o nombre completo con argumentos de tipo opcional.", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "Una interfaz solo puede extender un tipo de objeto o una intersección de tipos de objeto con miembros conocidos estáticamente.", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "Una interfaz no puede extender un tipo primitivo como \"{0}\"; una interfaz solo puede extender tipos y clases con nombre", @@ -700,6 +702,10 @@ "File_0_not_found_6053": "Archivo '{0}' no encontrado.", "File_Management_6245": "Administración de archivos", "File_change_detected_Starting_incremental_compilation_6032": "Se detectó un cambio de archivo. Iniciando la compilación incremental...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "El archivo es un módulo CommonJS porque “{0}” no tiene el campo “type”", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "El archivo es el módulo CommonJS porque “{0}” tiene el campo “type” cuyo valor no es “module”.", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "El archivo es un módulo CommonJS porque no se encontró “package.json”", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "El archivo es un módulo ECMAScript porque “{0}” tiene el campo “type” con el valor “module”", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "El archivo es un módulo CommonJS; se puede convertir en un módulo ES.", "File_is_default_library_for_target_specified_here_1426": "El archivo es la biblioteca predeterminada para el destino que se especifica aquí.", "File_is_entry_point_of_type_library_specified_here_1419": "El archivo es el punto de entrada de la biblioteca de tipos que se especifica aquí.", @@ -774,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "Se esperaba un identificador. \"{0}\" es una palabra reservada que no se puede usar aquí.", "Identifier_expected_1003": "Se esperaba un identificador.", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "Identificador esperado. \"__esModule\" está reservado como marcador exportado al transformar módulos ECMAScript.", + "Identifier_or_string_literal_expected_1478": "Se esperaba un literal de cadena o identificador", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "Si el paquete \"{0}\" expone realmente este módulo, considere la posibilidad de enviar una solicitud de incorporación de cambios para corregir \"https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}\".", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "Si el paquete '{0}' realmente expone este módulo, intente agregar un nuevo archivo de declaración (.d.ts) que contenga 'declarar módulo '{1}';`", "Ignore_this_error_message_90019": "Ignorar este mensaje de error", @@ -1561,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "Biblioteca de tipos a la que se hace referencia mediante \"{0}\" desde el archivo \"{1}\" con el valor packageId \"{2}\"", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "El tipo de operando \"await\" debe ser una promesa válida o no debe contener un miembro \"then\" invocable.", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "El tipo de valor de la propiedad calculada es \"{0}\", que no se puede asignar al tipo \"{1}\".", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "El tipo de variable miembro de instancia \"{0}\" no puede hacer referencia al identificador \"{1}\" declarado en el constructor.", "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "El tipo de elementos iterados de un operando \"yield*\" debe ser una promesa válida o no debe contener un miembro \"then\" invocable.", "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "El tipo de propiedad \"{0}\" hace referencia circular a sí misma en el tipo asignado \"{1}\".", "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "El tipo de operando \"yield\" en un generador asincrónico debe ser una promesa válida o no debe contener un miembro \"then\" invocable.", @@ -1588,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== No se resolvió la directiva de referencia de tipo '{0}'. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== La directiva de referencia de tipo '{0}' se resolvió correctamente como '{1}', principal: {2}. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== La directiva de referencia de tipo \"{0}\" se resolvió correctamente como \"{1}\" con el identificador de paquete \"{2}\", principal: {3}. ========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "Los tipos no pueden aparecer en declaraciones de exportación en archivos JavaScript.", "Types_have_separate_declarations_of_a_private_property_0_2442": "Los tipos tienen declaraciones independientes de una propiedad '{0}' privada.", "Types_of_construct_signatures_are_incompatible_2419": "Los tipos de signaturas de construcción son incompatibles.", "Types_of_parameters_0_and_1_are_incompatible_2328": "Los tipos de parámetros '{0}' y '{1}' no son compatibles.", @@ -1665,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "Encapsular el cuerpo siguiente entre paréntesis, lo cual debe ser un literal de objeto", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "Puede obtener información sobre todas las opciones del compilador en {0}", "You_cannot_rename_a_module_via_a_global_import_8031": "No se puede cambiar el nombre de un módulo mediante una importación global.", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "No se puede cambiar el nombre de los elementos definidos en una carpeta 'node_modules'.", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "No se puede cambiar el nombre de los elementos definidos en otra carpeta 'node_modules'.", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "No se puede cambiar el nombre de elementos definidos en la biblioteca TypeScript estándar.", "You_cannot_rename_this_element_8000": "No se puede cambiar el nombre a este elemento.", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "\"{0}\" no acepta suficientes argumentos para utilizarse como decorador aquí. ¿Pretendía llamar primero y escribir \"@{0}()\"?", @@ -1692,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "Las signaturas de índice \"{0}\" no son compatibles.", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "El tipo de índice \"{0}\"' \"{1}\" no se puede asignar al tipo de índice \"{2}\" \"{3}\".", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "'{0}' es un elemento primitivo, pero '{1}' es un objeto contenedor. Use '{0}' preferentemente cuando sea posible.", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "'{0}' es un tipo y no se puede importar en archivos JavaScript. Use '{1}' en una anotación de tipo JSDoc.", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "\"{0}\" es un tipo y debe importarse mediante una importación de solo tipo cuando \"preserveValueImports\" y \"isolatedModules\" estén habilitados.", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "'{0}' es un cambio de nombre de '{1}' sin usar. ¿Quería usarlo como una anotación de tipo?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "\"{0}\" puede asignarse a la restricción de tipo \"{1}\", pero no se pudo crear una instancia de \"{1}\" con un subtipo distinto de la restricción \"{2}\".", + "_0_is_automatically_exported_here_18044": "'{0}' se exporta automáticamente aquí.", "_0_is_declared_but_its_value_is_never_read_6133": "Se declara \"{0}\", pero su valor no se lee nunca.", "_0_is_declared_but_never_used_6196": "\"{0}\" se declara pero nunca se utiliza.", "_0_is_declared_here_2728": "\"{0}\" se declara aquí.", diff --git a/lib/fr/diagnosticMessages.generated.json b/lib/fr/diagnosticMessages.generated.json index a8a84336de004..632cac15426f9 100644 --- a/lib/fr/diagnosticMessages.generated.json +++ b/lib/fr/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "Un type 'this' est disponible uniquement dans un membre non statique d'une classe ou d'une interface.", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "Un fichier 'tsconfig.json' est déjà défini à l'emplacement '{0}'.", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "Un membre de tuple ne peut pas être à la fois facultatif et rest.", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "Un type tuple ne peut pas être indexé avec une valeur négative.", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "Une expression d'assertion de type n'est pas autorisée dans la partie gauche d'une expression d'élévation à une puissance. Mettez l'expression entre parenthèses.", "A_type_literal_property_cannot_have_an_initializer_1247": "Une propriété de littéral de type ne peut pas avoir d'initialiseur.", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "Une importation de type uniquement peut spécifier une importation par défaut ou des liaisons nommées, mais pas les deux.", @@ -226,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "Un paramètre de signature d'index doit avoir une annotation de type.", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "Un type de paramètre de signature d’index ne peut pas être un type littéral ni générique. Envisagez plutôt d’utiliser un type d’objet mappé.", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "Un type de paramètre de signature d’index doit être « string », « number », « symbol » ou un type littéral de modèle.", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "Une expression d’instanciation ne peut pas être suivie d’un accès à la propriété.", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "Une interface peut uniquement étendre un identificateur/nom qualifié avec des arguments de type facultatifs.", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "Une interface peut étendre uniquement un type d'objet ou une intersection de types d'objet avec des membres connus de manière statique.", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "Une interface ne peut pas étendre un type primitif comme « {0} » ; une interface peut uniquement étendre des types nommés et des classes.", @@ -700,6 +702,10 @@ "File_0_not_found_6053": "Fichier '{0}' introuvable.", "File_Management_6245": "Gestion de fichiers", "File_change_detected_Starting_incremental_compilation_6032": "Modification de fichier détectée. Démarrage de la compilation incrémentielle...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "Le fichier est un module CommonJS, car « {0} » n’a pas de champ « type »", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "Le fichier est un module CommonJS, car « {0} » a un champ « type » dont la valeur n’est pas « module »", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "Le fichier est un module CommonJS, car « package.json » est introuvable", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "Le fichier est un module ECMAScript, car « {0} » a un champ « type » avec la valeur « module »", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "Le fichier est un module CommonJS ; il peut être converti en module ES.", "File_is_default_library_for_target_specified_here_1426": "Le fichier représente la bibliothèque par défaut de la cible spécifiée ici.", "File_is_entry_point_of_type_library_specified_here_1419": "Le fichier représente le point d'entrée de la bibliothèque de types spécifiée ici.", @@ -774,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "Identificateur attendu. '{0}' est un mot réservé qui ne peut pas être utilisé ici.", "Identifier_expected_1003": "Identificateur attendu.", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "Identificateur attendu. '__esModule' est réservé en tant que marqueur exporté durant la transformation des modules ECMAScript.", + "Identifier_or_string_literal_expected_1478": "Identificateur ou littéral de chaîne attendu", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "Si le package '{0}' expose réellement ce module, envoyez une demande de tirage (pull request) pour modifier 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}'", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "Si le package' {0} 'expose effectivement ce module, essayez d’ajouter un nouveau fichier de déclaration (. d. TS) contenant’declare module' {1} '; '", "Ignore_this_error_message_90019": "Ignorer ce message d'erreur", @@ -1561,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "Bibliothèque de types référencée via '{0}' à partir du fichier '{1}' ayant le packageId '{2}'", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "Le type d'un opérande 'await' doit être une promesse valide ou ne doit contenir aucun membre 'then' pouvant être appelé.", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "Le type de la valeur de la propriété calculée est '{0}'. Il ne peut pas être assigné au type '{1}'.", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "Le type de variable membre d’instance '{0}' ne peut pas référencer l’identificateur '{1}' déclaré dans le constructeur.", "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "Le type des éléments itérés d'un opérande 'yield*' doit être une promesse valide ou ne doit contenir aucun membre 'then' pouvant être appelé.", "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "Le type de la propriété '{0}' se référence de façon circulaire dans le type mappé '{1}'.", "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "Le type d'un opérande 'yield' dans un générateur asynchrone doit être une promesse valide ou ne doit contenir aucun membre 'then' pouvant être appelé.", @@ -1588,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== La directive de référence de type '{0}' n'a pas été résolue. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== La directive de référence de type '{0}' a été correctement résolue en '{1}', primaire : {2}. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== La directive de référence de type '{0}' a été correctement résolue en '{1}' avec l'ID de package '{2}', primaire : {3}. ========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "Les types ne peuvent pas apparaître dans les déclarations d’exportation dans les fichiers JavaScript.", "Types_have_separate_declarations_of_a_private_property_0_2442": "Les types ont des déclarations distinctes d'une propriété privée '{0}'.", "Types_of_construct_signatures_are_incompatible_2419": "Les types de signature de construction sont incompatibles.", "Types_of_parameters_0_and_1_are_incompatible_2328": "Les types des paramètres '{0}' et '{1}' sont incompatibles.", @@ -1665,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "Placer le corps suivant entre parenthèses pour indiquer qu'il s'agit d'un littéral d'objet", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "Vous pouvez en savoir plus sur toutes les options du compilateur sur {0}", "You_cannot_rename_a_module_via_a_global_import_8031": "Vous ne pouvez pas renommer un module via une importation globale.", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "Vous ne pouvez pas renommer les éléments définis dans un dossier « node_modules ».", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "Vous ne pouvez pas renommer les éléments définis dans un autre dossier « node_modules ».", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "Vous ne pouvez pas renommer des éléments définis dans la bibliothèque TypeScript standard.", "You_cannot_rename_this_element_8000": "Vous ne pouvez pas renommer cet élément.", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "'{0}' accepte trop peu d'arguments pour pouvoir être utilisé ici en tant qu'élément décoratif. Voulez-vous vraiment l'appeler d'abord et écrire '@{0}()' ?", @@ -1692,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "Les signatures d'index « {0} » sont incompatibles.", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "Le type d’index « {0} », « {1} », ne peut pas être attribué au type d’index « {2} », « {3} ».", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "'{0}' est une primitive, mais '{1}' est un objet wrapper. Si possible, utilisez '{0}' de préférence.", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "'{0}' est un type qui ne peut pas être importé dans des fichiers JavaScript. Utilisez '{1}' dans une annotation de type JSDoc.", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "« {0} » est un type seul et doit être importé à l'aide d'une importation de type seul lorsque « preserveValueImports » et « isolatedModules » sont tous deux activés.", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "« {0} » est un changement de nom inutilisé de « {1} ». Souhaitiez-vous l’utiliser comme annotation de type?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "'{0}' peut être assigné à la contrainte de type '{1}', mais '{1}' a pu être instancié avec un autre sous-type de contrainte '{2}'.", + "_0_is_automatically_exported_here_18044": "'{0}' est automatiquement exporté ici.", "_0_is_declared_but_its_value_is_never_read_6133": "'{0}' est déclaré mais sa valeur n'est jamais lue.", "_0_is_declared_but_never_used_6196": "'{0}' est déclaré mais n'est jamais utilisé.", "_0_is_declared_here_2728": "'{0}' est déclaré ici.", diff --git a/lib/it/diagnosticMessages.generated.json b/lib/it/diagnosticMessages.generated.json index 559666a0badd9..dff3926256724 100644 --- a/lib/it/diagnosticMessages.generated.json +++ b/lib/it/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "Un tipo 'this' è disponibile solo in un membro non statico di una classe o di interfaccia.", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "Un file 'tsconfig.json' è già definito in: '{0}'.", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "Un membro di tupla non può essere sia facoltativo che inattivo.", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "Un tipo di tupla non può essere indicizzato con un valore negativo.", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "Nella parte sinistra di un'espressione di elevamento a potenza non è consentita un'espressione di asserzione tipi. Provare a racchiudere l'espressione tra parentesi.", "A_type_literal_property_cannot_have_an_initializer_1247": "Una proprietà di valore letterale di tipo non può contenere un inizializzatore.", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "Un'importazione solo di tipi può specificare un'importazione predefinita o binding denominati, ma non entrambi.", @@ -132,6 +133,8 @@ "Add_definite_assignment_assertion_to_property_0_95020": "Aggiungere l'asserzione di assegnazione definita alla proprietà '{0}'", "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": "Aggiungere le asserzioni di assegnazione definite a tutte le proprietà non inizializzate", "Add_export_to_make_this_file_into_a_module_95097": "Aggiungere 'export {}' per trasformare questo file in un modulo", + "Add_extends_constraint_2211": "Aggiungere il vincolo 'extends'.", + "Add_extends_constraint_to_all_type_parameters_2212": "Aggiungere il vincolo `extends` a tutti i parametri di tipo", "Add_import_from_0_90057": "Aggiungere l'importazione da \"{0}\"", "Add_index_signature_for_property_0_90017": "Aggiungere la firma dell'indice per la proprietà '{0}'", "Add_initializer_to_property_0_95019": "Aggiungere l'inizializzatore alla proprietà '{0}'", @@ -224,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "Un parametro della firma dell'indice deve contenere un'annotazione di tipo.", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "Un tipo di parametro della firma dell'indice non può essere un tipo di valore letterale o un tipo generico. Considerare l'utilizzo di un tipo di oggetto con mapping.", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "Un tipo di parametro della firma dell'indice deve essere 'stringa', 'numero', 'simbolo' o un tipo di valore letterale del modello.", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "Un'espressione di creazione di un'istanza non può essere seguita da un accesso a proprietà.", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "Un'interfaccia può estendere solo un identificatore/nome qualificato con argomenti tipo facoltativi.", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "Un'interfaccia può estendere solo un tipo di oggetto o un'intersezione di tipi di oggetto con membri noti in modo statico.", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "Un'interfaccia non può estendere un tipo primitivo come '{0}'; un'interfaccia può estendere solo tipi e classi denominati", @@ -698,6 +702,10 @@ "File_0_not_found_6053": "Il file '{0}' non è stato trovato.", "File_Management_6245": "Gestione dei file", "File_change_detected_Starting_incremental_compilation_6032": "È stata rilevata una modifica ai file. Verrà avviata la compilazione incrementale...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "Il file è un modulo CommonJS perché '{0}' non contiene il campo \"type\"", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "Il file è un modulo CommonJS perché '{0}' contiene il campo \"type\" il cui valore non è \"module\"", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "Il file è un modulo CommonJS perché 'package.json' non è stato trovato", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "Il file è un modulo ECMAScript perché '{0}' contiene il campo \"type\" con valore \"module\"", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "Il file è un modulo CommonJS e può essere convertito in un modulo ES6.", "File_is_default_library_for_target_specified_here_1426": "Il file è la libreria predefinita per la destinazione specificata in questo punto.", "File_is_entry_point_of_type_library_specified_here_1419": "Il file è il punto di ingresso della libreria dei tipi specificata in questo punto.", @@ -772,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "È previsto un identificatore. '{0}' è una parola riservata che non può essere usata in questo punto.", "Identifier_expected_1003": "È previsto l'identificatore.", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "È previsto un identificatore. '__esModule' è riservato come marcatore esportato durante la trasformazione di moduli ECMAScript.", + "Identifier_or_string_literal_expected_1478": "Previsto identificatore o valore letterale stringa.", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "Se il pacchetto '{0}' espone effettivamente questo modulo, provare a inviare una richiesta pull per modificare 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}'", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "Se il pacchetto ' {0}' espone effettivamente il modulo, provare ad aggiungere un nuovo file di dichiarazione (.d.ts) contenente ' Dichiara modulo' {1}';'", "Ignore_this_error_message_90019": "Ignorare questo messaggio di errore", @@ -1493,7 +1502,7 @@ "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354": "Con questa sintassi è richiesto un helper importato, ma il modulo '{0}' non è stato trovato.", "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Con questa sintassi è richiesto un helper importato denominato '{1}', che non esiste in '{0}'. Provare ad aggiornare la versione di '{0}'.", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Con questa sintassi è richiesto un helper importato denominato '{1}' con {2} parametri, che non è compatibile con quello presente in '{0}'. Provare ad aggiornare la versione di '{0}'.", - "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Questo parametro di tipo richiede probabilmente un vincolo 'extends object'.", + "This_type_parameter_might_need_an_extends_0_constraint_2208": "Questo parametro di tipo potrebbe richiedere un vincolo `extends {0}`.", "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "Questo uso di 'import' non è valido. le chiamate 'import()' possono essere scritte, ma devono avere parentesi e non possono avere argomenti di tipo.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378": "Le espressioni 'await' di primo livello sono consentite solo quando l'opzione 'module' è impostata su 'es2022', 'esnext', 'system', 'node16', or 'nodenext', e l'opzione 'target' è impostata su 'es2017' o versione successiva.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "Le dichiarazioni di primo livello nei file con estensione d.ts devono iniziare con un modificatore 'declare' o 'export'.", @@ -1559,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "Libreria dei tipi a cui viene fatto riferimento tramite '{0}' dal file '{1}' con packageId '{2}'", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "Il tipo dell'operando 'await' deve essere una promessa valida oppure non deve contenere un membro 'then' chiamabile.", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "Il tipo del valore della proprietà calcolata è '{0}', che non è assegnabile al tipo '{1}'.", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "Il tipo di variabile del membro di istanza '{0}' non può fare riferimento all'identificatore '{1}' dichiarato nel costruttore.", "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "Il tipo di elementi iterati di un operando 'yield*' deve essere una promessa valida oppure non deve contenere un membro 'then' chiamabile.", "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "Il tipo di proprietà '{0}' contiene un riferimento circolare a se stesso nel tipo con mapping '{1}'.", "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "Il tipo dell'operando 'yield' in un generatore asincrono deve essere una promessa valida oppure non deve contenere un membro 'then' chiamabile.", @@ -1586,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== La direttiva '{0}' del riferimento al tipo non è stata risolta. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== La direttiva '{0}' del riferimento al tipo è stata risolta in '{1}'. Primaria: {2}. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== La direttiva '{0}' del riferimento al tipo è stata risolta in '{1}' con ID pacchetto ID '{2}'. Primaria: {3}. ========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "I tipi non possono essere visualizzati nelle dichiarazioni di esportazione nei file JavaScript.", "Types_have_separate_declarations_of_a_private_property_0_2442": "I tipi contengono dichiarazioni separate di una proprietà privata '{0}'.", "Types_of_construct_signatures_are_incompatible_2419": "I tipi delle firme del costrutto sono incompatibili.", "Types_of_parameters_0_and_1_are_incompatible_2328": "I tipi dei parametri '{0}' e '{1}' sono incompatibili.", @@ -1663,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "Racchiudere tra parentesi il corpo seguente che deve essere un valore letterale di oggetto", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "Per informazioni su tutte le opzioni del compilatore, vedere {0}", "You_cannot_rename_a_module_via_a_global_import_8031": "Non è possibile rinominare un modulo tramite un'importazione globale.", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "Non è possibile rinominare gli elementi definiti in una cartella 'node_modules'.", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "Non è possibile rinominare gli elementi definiti in un'altra cartella 'node_modules'.", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "Non è possibile rinominare elementi definiti nella libreria TypeScript standard.", "You_cannot_rename_this_element_8000": "Non è possibile rinominare questo elemento.", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "'{0}' accetta un numero troppo ridotto di argomenti da usare come espressione Decorator in questo punto. Si intendeva chiamarlo prima e scrivere '@{0}()'?", @@ -1690,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "Le firme dell'indice '{0}' non sono compatibili.", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "Il tipo di indice '{0}' '{1}' non è assegnabile al tipo di indice '{2}' '{3}'.", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "'{0}' è una primitiva, ma '{1}' è un oggetto wrapper. Quando possibile, preferire '{0}'.", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "'{0}' è un tipo e non può essere importato nei file JavaScript. Usare '{1}' in un'annotazione di tipo JSDoc.", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "'{0}' è un tipo e deve essere importato usando un'importazione solo di tipi quando 'preserveValueImports' e 'isolatedModules' sono entrambi abilitati.", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "'{0}' è una ridenominazione inutilizzata di '{1}'. Si intendeva utilizzarla come annotazione di tipo?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "'{0}' è assegnabile al vincolo di tipo '{1}', ma è possibile creare un'istanza di '{1}' con un sottotipo diverso del vincolo '{2}'.", + "_0_is_automatically_exported_here_18044": "'{0}' viene esportato automaticamente qui.", "_0_is_declared_but_its_value_is_never_read_6133": "L'elemento '{0}' è dichiarato, ma il suo valore non viene mai letto.", "_0_is_declared_but_never_used_6196": "La variabile '{0}' è dichiarata, ma non viene mai usata.", "_0_is_declared_here_2728": "In questo punto viene dichiarato '{0}'.", diff --git a/lib/ja/diagnosticMessages.generated.json b/lib/ja/diagnosticMessages.generated.json index 35505e947a8cd..9841773a6a037 100644 --- a/lib/ja/diagnosticMessages.generated.json +++ b/lib/ja/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "'this' 型はクラスまたはインターフェイスの静的でないメンバーでのみ使用できます。", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "'tsconfig.json' ファイルは既に '{0}' で定義されています。", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "タプル メンバーを optional と rest の両方に指定することはできません。", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "タプル型に負の値のインデックスを指定することはできません。", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "累乗式の左辺で型アサーション式を使用することはできません。式を括弧で囲むことを検討してください。", "A_type_literal_property_cannot_have_an_initializer_1247": "型リテラル プロパティに初期化子を使用することはできません。", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "型のみのインポートでは既定のインポートまたは名前付きバインドを指定できますが、両方を指定することはできません。", @@ -132,6 +133,8 @@ "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_extends_constraint_2211": "'extends' 制約を追加します。", + "Add_extends_constraint_to_all_type_parameters_2212": "すべての型パラメーターに 'extends' 制約を追加する", "Add_import_from_0_90057": "\"{0}\" からのインポートの追加", "Add_index_signature_for_property_0_90017": "プロパティ '{0}' のインデックス シグネチャを追加する", "Add_initializer_to_property_0_95019": "プロパティ '{0}' に初期化子を追加します", @@ -224,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "インデックス シグネチャのパラメーターには型の注釈が必要です。", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "インデックス シグネチャ パラメーターの型をリテラル型またはジェネリック型にすることはできません。代わりに、マップされたオブジェクト型の使用を検討してください。", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "インデックス シグネチャ パラメーター型は、'string'、'number'、'symbol'、またはテンプレート リテラルの型である必要があります。", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "インスタンス化式の後にプロパティ アクセスを続けることはできません。", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "インターフェイスが拡張するのは、オプションの型引数が指定された識別子/完全修飾名のみです。", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "インターフェイスが拡張できるのは、オブジェクト型または静的な既知のメンバーを持つオブジェクト型の積集合のみです。", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "インターフェイスは、'{0}' のようなプリミティブ型を拡張できません。インターフェイスは名前付きの型とクラスのみを拡張できます", @@ -698,6 +702,10 @@ "File_0_not_found_6053": "ファイル '{0}' が見つかりません。", "File_Management_6245": "ファイルの管理", "File_change_detected_Starting_incremental_compilation_6032": "ファイルの変更が検出されました。インクリメンタル コンパイルを開始しています...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "'{0}' にはフィールド \"type\" がないため、ファイルは CommonJS モジュールです", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "'{0}' にフィールド \"type\" があり、値が \"module\" ではないため、ファイルは CommonJS モジュールです。", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "\"package.json\" が見つからなかったため、ファイルは CommonJS モジュールです", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "'{0}' には値 \"module\" のフィールド \"type\" があるため、ファイルは ECMAScript モジュールです。", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "ファイルは CommonJS モジュールです。ES モジュールに変換される可能性があります。", "File_is_default_library_for_target_specified_here_1426": "ファイルはこちらで指定されたターゲットの既定のライブラリです。", "File_is_entry_point_of_type_library_specified_here_1419": "ファイルはこちらで指定されたタイプ ライブラリのエントリ ポイントです。", @@ -772,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "識別子が予期されていました。'{0}' は、ここでは使用できない予約語です。", "Identifier_expected_1003": "識別子が必要です。", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "識別子が必要です。'__esModule' は、ECMAScript モジュールを変換するときのエクスポート済みマーカーとして予約されています。", + "Identifier_or_string_literal_expected_1478": "識別子または文字列リテラルが必要です。", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "'{0}' パッケージが実際にこのモジュールを公開する場合は、pull request を送信して 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}' を修正することを検討してください", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "'{0}' パッケージが実際にこのモジュールを公開する場合は、'declare module '{1}';' を含む新しい宣言 (d.ts) ファイルを追加してみてください。", "Ignore_this_error_message_90019": "このエラー メッセージを無視する", @@ -1493,7 +1502,7 @@ "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354": "この構文にはインポートされたヘルパーが必要ですが、モジュール '{0}' が見つかりません。", "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "この構文には、'{1}' という名前のインポートされたヘルパーが必要ですが、'{0}' には存在しません。'{0}' のバージョンのアップグレードを検討してください。", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "この構文には、{2} パラメーターを持つ '{1}' という名前のインポートされたヘルパーが必要ですが、'{0}' にあるものと互換性がありません。'{0}' のバージョンをアップグレードすることをご検討ください。", - "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "この型パラメーターには、`extends object` 制約が必要な可能性があります。", + "This_type_parameter_might_need_an_extends_0_constraint_2208": "この型パラメーターには 'extends {0}' 制約が必要な場合があります。", "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "この 'import' の使用は無効です。'import()' 呼び出しは書き込むことができますが、かっこが必要であり、型引数を指定することはできません。", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378": "トップレベルの 'await' 式は、'module' オプションが 'es2022'、'esnext'、'system'、'node16' または 'nodenext' に設定されていて、'target' オプションが 'es2017' 以上に設定されている場合にのみ使用できます。", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": ".d.ts ファイルのトップレベルの宣言は、'declare' または 'export' 修飾子で始める必要があります。", @@ -1559,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "packageId が '{2}' のファイル '{1}' から '{0}' を介して参照されたタイプ ライブラリ", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "'await' オペランドの型は、有効な Promise であるか、呼び出し可能な 'then' メンバーを含んでいないかのどちらかであることが必要です。", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "計算されたプロパティの値の型は '{0}' です。これは、型 '{1}' に代入することはできません。", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "インスタンス メンバー変数 '{0}' の型は、コンストラクターで宣言された識別子 '{1}' を参照できません。", "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "'yield*' オペランドの反復要素の型は、有効な Promise であるか、呼び出し可能な 'then' メンバーを含んでいないかのどちらかであることが必要です。", "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "マップされた型 '{1}' で、プロパティ '{0}' の型によってそれ自体が循環参照されています。", "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "非同期ジェネレーター内の 'yield' オペランドの型は、有効な Promise であるか、呼び出し可能な 'then' メンバーを含んでいないかのどちらかであることが必要です。", @@ -1586,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== 型参照ディレクティブ '{0}' が解決されませんでした。========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== 型参照ディレクティブ '{0}' が正常に '{1}' に解決されました。プライマリ: {2}。========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== 型参照ディレクティブ '{0}' が正常に '{1}' に解決されました (パッケージ ID '{2}'、プライマリ: {3})。========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "JavaScript ファイルのエクスポート宣言に型を含めることはできません。", "Types_have_separate_declarations_of_a_private_property_0_2442": "複数の型に、プライベート プロパティ '{0}' の異なる宣言が含まれています。", "Types_of_construct_signatures_are_incompatible_2419": "コンストラクト シグネチャの型に互換性がありません。", "Types_of_parameters_0_and_1_are_incompatible_2328": "パラメーター '{0}' および '{1}' は型に互換性がありません。", @@ -1663,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "次の本体をかっこで囲みます。これはオブジェクト リテラルです", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "コンパイラ オプションの詳細については、{0} をご覧ください。", "You_cannot_rename_a_module_via_a_global_import_8031": "グローバル インポートを使用してモジュールの名前を変更することはできません。", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "'node_modules' フォルダーで定義されている要素の名前を変更することはできません。", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "別の 'node_modules' フォルダーで定義されている要素の名前を変更することはできません。", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "標準の TypeScript ライブラリで定義された要素の名前を変更することはできません。", "You_cannot_rename_this_element_8000": "この要素の名前を変更することはできません。", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "'{0}' は受け入れる引数が少なすぎるので、ここでデコレーターとして使用することができません。最初にこれを呼び出してから、'@{0}()' を書き込むつもりでしたか?", @@ -1690,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "'{0}' インデックス シグネチャに互換性がありません。", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "'{0}'インデックス型'{1}' を '{2}'インデックス型'{3}' に割り当てることはできません。", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "'{0}' はプリミティブですが、'{1}' はラッパー オブジェクトです。できれば '{0}' をご使用ください。", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "'{0}' は型であるため、JavaScript ファイルにインポートできません。JSDoc 型の注釈で '{1}' を使用します。", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "\"{0}\" は型であり、\"preserveValueImports\" と \"isolatedModules\" の両方が有効な場合、型に限定したインポートを使用してインポートされる必要があります。", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "'{0}' は、'{1}' の未使用の名前変更です。型の注釈として使用するつもりでしたか?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "'{0}' は型 '{1}' の制約に代入できますが、'{1}' は制約 '{2}' の別のサブタイプでインスタンス化できることがあります。", + "_0_is_automatically_exported_here_18044": "`{0}` は自動的にここにエクスポートされます。", "_0_is_declared_but_its_value_is_never_read_6133": "'{0}' が宣言されていますが、その値が読み取られることはありません。", "_0_is_declared_but_never_used_6196": "'{0}' は宣言されましたが使用されませんでした。", "_0_is_declared_here_2728": "'{0}' はここで宣言されています。", diff --git a/lib/ko/diagnosticMessages.generated.json b/lib/ko/diagnosticMessages.generated.json index a21f6ce8c7d12..e60bffb9ec362 100644 --- a/lib/ko/diagnosticMessages.generated.json +++ b/lib/ko/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "'this' 형식은 클래스 또는 인터페이스의 비정적 멤버에서만 사용할 수 있습니다.", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "'tsconfig.json' 파일이 이미 '{0}'에 정의되어 있습니다.", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "튜플 멤버는 optional이면서 rest일 수 없습니다.", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "튜플 형식은 음수 값으로 인덱싱할 수 없습니다.", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "지수 식의 왼쪽에는 type assertion expression을 사용할 수 없습니다. 식을 괄호로 묶는 것이 좋습니다.", "A_type_literal_property_cannot_have_an_initializer_1247": "형식 리터럴 속성에는 이니셜라이저를 사용할 수 없습니다.", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "형식 전용 가져오기는 기본 가져오기 또는 명명된 바인딩을 지정할 수 있지만, 둘 다 지정할 수는 없습니다.", @@ -226,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "인덱스 시그니처 매개 변수에는 형식 주석을 사용할 수 없습니다.", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "인덱스 시그니처 매개 변수 형식은 리터럴 유형이나 제네릭 형식일 수 없습니다. 대신 매핑된 개체 형식을 사용하세요.", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "인덱스 시그니처 매개 변수 형식은 'string', 'number', 'symbol' 또는 템플릿 리터럴 형식이어야 합니다.", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "인스턴스화 식 뒤에 속성 액세스가 있을 수 없습니다.", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "인터페이스는 선택적 형식 인수가 포함된 식별자/정규화된 이름만 확장할 수 있습니다.", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "인터페이스는 개체 형식 또는 정적으로 알려진 멤버가 포함된 개체 형식의 교집합만 확장할 수 있습니다.", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "인터페이스는 '{0}' 같은 기본 형식을 확장할 수 없습니다. 인터페이스는 명명된 형식 및 클래스만 확장할 수 있습니다.", @@ -700,6 +702,10 @@ "File_0_not_found_6053": "파일 '{0}'을(를) 찾을 수 없습니다.", "File_Management_6245": "파일 관리", "File_change_detected_Starting_incremental_compilation_6032": "파일 변경이 검색되었습니다. 증분 컴파일을 시작하는 중...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "'{0}'에 \"type\" 필드가 없으므로 파일이 CommonJS 모듈입니다.", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "'{0}'에 값이 \"module\"이 아닌 \"type\" 필드가 있으므로 파일이 CommonJS 모듈입니다.", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "'package.json'을 찾을 수 없으므로 파일이 CommonJS 모듈입니다.", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "'{0}'에 값이 \"module\"인 \"type\" 필드가 있으므로 파일이 ECMAScript 모듈입니다.", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "파일이 CommonJS 모듈입니다. ES 모듈로 변환될 수 있습니다.", "File_is_default_library_for_target_specified_here_1426": "파일은 여기에 지정된 대상의 기본 라이브러리입니다.", "File_is_entry_point_of_type_library_specified_here_1419": "파일은 여기에 지정된 형식 라이브러리의 진입점입니다.", @@ -774,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "식별자가 필요합니다. '{0}'은(는) 여기에서 사용할 수 없는 예약어입니다.", "Identifier_expected_1003": "식별자가 필요합니다.", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "식별자가 필요합니다. '__esModule'은 ECMAScript 모듈을 변환할 때 내보낸 표식으로 예약되어 있습니다.", + "Identifier_or_string_literal_expected_1478": "식별자 또는 문자열 리터럴이 필요합니다.", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "'{0}' 패키지가 이 모듈을 실제로 공개하는 경우 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}' 수정을 위한 끌어오기 요청을 보내는 것이 좋습니다.", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "'{0}' 패키지가 실제로 이 모듈을 노출하는 경우 'declare module {1}';'이(가) 포함된 새 선언(.d.ts) 파일을 추가해 보세요.", "Ignore_this_error_message_90019": "이 오류 메시지 무시", @@ -1561,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "packageId가 '{2}'인 '{1}' 파일에서 '{0}'을(를) 통해 형식 라이브러리가 참조되었습니다.", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "'await' 형식의 피연산자는 유효한 프라미스여야 하거나 호출 가능 'then' 멤버를 포함하지 않아야 합니다.", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "계산된 속성 값의 형식은 '{1}' 형식에 할당할 수 없는 '{0}'입니다.", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "인스턴스 멤버 변수 '{0}'의 형식은 생성자에 선언된 식별자 '{1}'을(를) 참조할 수 없습니다.", "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' 멤버를 포함하지 않아야 합니다.", @@ -1588,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== 형식 참조 지시문 '{0}'이(가) 확인되지 않았습니다. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== 형식 참조 지시문 '{0}'이(가) '{1}'(으)로 확인되었습니다. 주: {2}. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== 형식 참조 지시문 '{0}'이(가) 패키지 ID가 '{2}'인 '{1}'(으)로 확인되었습니다. 주: {3}. ========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "유형은 JavaScript 파일의 내보내기 선언에 나타날 수 없습니다.", "Types_have_separate_declarations_of_a_private_property_0_2442": "형식에 별도의 프라이빗 속성 '{0}' 선언이 있습니다.", "Types_of_construct_signatures_are_incompatible_2419": "구문 시그니처 형식이 호환되지 않습니다.", "Types_of_parameters_0_and_1_are_incompatible_2328": "'{0}' 및 '{1}' 매개 변수의 형식이 호환되지 않습니다.", @@ -1665,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "괄호를 사용하여 개체 리터럴이어야 하는 다음 본문 래핑", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "{0}에서 모든 컴파일러 옵션에 대해 알아볼 수 있습니다.", "You_cannot_rename_a_module_via_a_global_import_8031": "전역 가져오기를 통해 모듈 이름을 바꿀 수 없습니다.", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "'node_modules' 폴더에 정의된 요소의 이름은 변경할 수 없습니다.", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "다른 'node_modules' 폴더에 정의된 요소의 이름은 변경할 수 없습니다.", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "표준 TypeScript 라이브러리에 정의된 요소의 이름을 바꿀 수 없습니다.", "You_cannot_rename_this_element_8000": "이 요소의 이름을 바꿀 수 없습니다.", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "'{0}'이(가) 여기에서 decorator로 사용할 인수를 너무 적게 허용합니다. 먼저 이를 호출하고 '@{0}()'을(를) 작성하시겠습니까?", @@ -1692,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "'{0}' 인덱스 시그니처가 호환되지 않습니다.", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "'{0}' 인덱스 유형 '{1}'을(를) '{2}' 인텍스 유형 '{3}'에 할당할 수 없습니다.", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "{0}'은(는) 기본 개체이지만 '{1}'은(는) 래퍼 개체입니다. 가능한 경우 '{0}'을(를) 사용하세요.", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "'{0}'은(는) 유형이며 JavaScript 파일로 가져올 수 없습니다. JSDoc 유형 주석에서 '{1}'을(를) 사용하세요.", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "'{0}'은(는) 형식이며, 'preserveValueImports'와 'isolatedModules'를 모두 사용하도록 설정한 경우 형식 전용 가져오기를 사용하여 가져와야 합니다.", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "'{0}'은(는) '{1}'의 사용되지 않는 이름 변경입니다. 형식 주석으로 사용하려고 했습니까?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "'{0}'은(는) '{1}' 형식의 제약 조건에 할당할 수 있지만, '{1}'은(는) '{2}' 제약 조건의 다른 하위 형식으로 인스턴스화할 수 있습니다.", + "_0_is_automatically_exported_here_18044": "'{0}'은(는) 여기에서 자동으로 내보내집니다.", "_0_is_declared_but_its_value_is_never_read_6133": "'{0}'이(가) 선언은 되었지만 해당 값이 읽히지는 않았습니다.", "_0_is_declared_but_never_used_6196": "'{0}'이(가) 선언되었지만 사용되지 않았습니다.", "_0_is_declared_here_2728": "여기서는 '{0}'이(가) 선언됩니다.", diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index a12871754c841..d1223acc6fff6 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -13848,11 +13848,11 @@ declare var SubmitEvent: { * Available only in secure contexts. */ interface SubtleCrypto { - decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; + decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise; deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise; digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise; - encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; + encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; exportKey(format: "jwk", key: CryptoKey): Promise; exportKey(format: Exclude, key: CryptoKey): Promise; generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray): Promise; diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index dc154ca17e78b..c2e7733ae54b4 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -19,18 +19,38 @@ and limitations under the License. interface Map { + clear(): void; + /** + * @returns true if an element in the Map existed and has been removed, or false if the element does not exist. + */ delete(key: K): boolean; + /** + * Executes a provided function once per each key/value pair in the Map, in insertion order. + */ forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; + /** + * Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map. + * @returns Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned. + */ get(key: K): V | undefined; + /** + * @returns boolean indicating whether an element with the specified key exists or not. + */ has(key: K): boolean; + /** + * Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated. + */ set(key: K, value: V): this; + /** + * @returns the number of elements in the Map. + */ readonly size: number; } interface MapConstructor { new(): Map; - new(entries?: readonly (readonly [K, V])[] | null): Map; + new (entries?: readonly (readonly [K, V])[] | null): Map; readonly prototype: Map; } declare var Map: MapConstructor; @@ -43,9 +63,23 @@ interface ReadonlyMap { } interface WeakMap { + /** + * Removes the specified element from the WeakMap. + * @returns true if the element was successfully removed, or false if it was not present. + */ delete(key: K): boolean; + /** + * @returns a specified element. + */ get(key: K): V | undefined; + /** + * @returns a boolean indicating whether an element with the specified key exists or not. + */ has(key: K): boolean; + /** + * Adds a new element with a specified key and value. + * @param key Must be an object. + */ set(key: K, value: V): this; } @@ -56,11 +90,28 @@ interface WeakMapConstructor { declare var WeakMap: WeakMapConstructor; interface Set { + /** + * Appends a new element with a specified value to the end of the Set. + */ add(value: T): this; + clear(): void; + /** + * Removes a specified value from the Set. + * @returns Returns true if an element in the Set existed and has been removed, or false if the element does not exist. + */ delete(value: T): boolean; + /** + * Executes a provided function once per each value in the Set object, in insertion order. + */ forEach(callbackfn: (value: T, value2: T, set: Set) => void, thisArg?: any): void; + /** + * @returns a boolean indicating whether an element with the specified value exists in the Set or not. + */ has(value: T): boolean; + /** + * @returns the number of (unique) elements in Set. + */ readonly size: number; } @@ -77,8 +128,18 @@ interface ReadonlySet { } interface WeakSet { + /** + * Appends a new object to the end of the WeakSet. + */ add(value: T): this; + /** + * Removes the specified element from the WeakSet. + * @returns Returns true if the element existed and has been removed, or false if the element does not exist. + */ delete(value: T): boolean; + /** + * @returns a boolean indicating whether an object exists in the WeakSet or not. + */ has(value: T): boolean; } diff --git a/lib/lib.es2015.promise.d.ts b/lib/lib.es2015.promise.d.ts index 57eea0f6bbc31..685f7164f5d61 100644 --- a/lib/lib.es2015.promise.d.ts +++ b/lib/lib.es2015.promise.d.ts @@ -41,7 +41,7 @@ interface PromiseConstructor { all(values: T): Promise<{ -readonly [P in keyof T]: Awaited }>; // see: lib.es2015.iterable.d.ts - // all(values: Iterable>): Promise; + // all(values: Iterable>): Promise[]>; /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved @@ -52,7 +52,7 @@ interface PromiseConstructor { race(values: T): Promise>; // see: lib.es2015.iterable.d.ts - // race(values: Iterable): Promise ? U : T>; + // race(values: Iterable>): Promise>; /** * Creates a new rejected promise for the provided reason. @@ -66,13 +66,18 @@ interface PromiseConstructor { * @returns A resolved promise. */ resolve(): Promise; - /** * Creates a new resolved promise for the provided value. * @param value A promise. * @returns A promise whose internal state matches the provided promise. */ - resolve(value: T | PromiseLike): Promise; + resolve(value: T): Promise>; + /** + * Creates a new resolved promise for the provided value. + * @param value A promise. + * @returns A promise whose internal state matches the provided promise. + */ + resolve(value: T | PromiseLike): Promise>; } declare var Promise: PromiseConstructor; diff --git a/lib/lib.es2015.proxy.d.ts b/lib/lib.es2015.proxy.d.ts index 9e8b8757a4af1..c241866150ba8 100644 --- a/lib/lib.es2015.proxy.d.ts +++ b/lib/lib.es2015.proxy.d.ts @@ -19,23 +19,112 @@ and limitations under the License. interface ProxyHandler { + /** + * A trap method for a function call. + * @param target The original callable object which is being proxied. + */ apply?(target: T, thisArg: any, argArray: any[]): any; + + /** + * A trap for the `new` operator. + * @param target The original object which is being proxied. + * @param newTarget The constructor that was originally called. + */ construct?(target: T, argArray: any[], newTarget: Function): object; - defineProperty?(target: T, p: string | symbol, attributes: PropertyDescriptor): boolean; + + /** + * A trap for `Object.defineProperty()`. + * @param target The original object which is being proxied. + * @returns A `Boolean` indicating whether or not the property has been defined. + */ + defineProperty?(target: T, property: string | symbol, attributes: PropertyDescriptor): boolean; + + /** + * A trap for the `delete` operator. + * @param target The original object which is being proxied. + * @param p The name or `Symbol` of the property to delete. + * @returns A `Boolean` indicating whether or not the property was deleted. + */ deleteProperty?(target: T, p: string | symbol): boolean; + + /** + * A trap for getting a property value. + * @param target The original object which is being proxied. + * @param p The name or `Symbol` of the property to get. + * @param receiver The proxy or an object that inherits from the proxy. + */ get?(target: T, p: string | symbol, receiver: any): any; + + /** + * A trap for `Object.getOwnPropertyDescriptor()`. + * @param target The original object which is being proxied. + * @param p The name of the property whose description should be retrieved. + */ getOwnPropertyDescriptor?(target: T, p: string | symbol): PropertyDescriptor | undefined; + + /** + * A trap for the `[[GetPrototypeOf]]` internal method. + * @param target The original object which is being proxied. + */ getPrototypeOf?(target: T): object | null; + + /** + * A trap for the `in` operator. + * @param target The original object which is being proxied. + * @param p The name or `Symbol` of the property to check for existence. + */ has?(target: T, p: string | symbol): boolean; + + /** + * A trap for `Object.isExtensible()`. + * @param target The original object which is being proxied. + */ isExtensible?(target: T): boolean; + + /** + * A trap for `Reflect.ownKeys()`. + * @param target The original object which is being proxied. + */ ownKeys?(target: T): ArrayLike; + + /** + * A trap for `Object.preventExtensions()`. + * @param target The original object which is being proxied. + */ preventExtensions?(target: T): boolean; - set?(target: T, p: string | symbol, value: any, receiver: any): boolean; + + /** + * A trap for setting a property value. + * @param target The original object which is being proxied. + * @param p The name or `Symbol` of the property to set. + * @param receiver The object to which the assignment was originally directed. + * @returns `A `Boolean` indicating whether or not the property was set. + */ + set?(target: T, p: string | symbol, newValue: any, receiver: any): boolean; + + /** + * A trap for `Object.setPrototypeOf()`. + * @param target The original object which is being proxied. + * @param newPrototype The object's new prototype or `null`. + */ setPrototypeOf?(target: T, v: object | null): boolean; } interface ProxyConstructor { + /** + * Creates a revocable Proxy object. + * @param target A target object to wrap with Proxy. + * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it. + */ revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + + /** + * Creates a Proxy object. The Proxy object allows you to create an object that can be used in place of the + * original object, but which may redefine fundamental Object operations like getting, setting, and defining + * properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs. + * @param target A target object to wrap with Proxy. + * @param handler An object whose properties define the behavior of Proxy when an operation is attempted on it. + */ new (target: T, handler: ProxyHandler): T; } declare var Proxy: ProxyConstructor; diff --git a/lib/lib.es2017.intl.d.ts b/lib/lib.es2017.intl.d.ts index f20c149f2824d..c2ab43e8fc304 100644 --- a/lib/lib.es2017.intl.d.ts +++ b/lib/lib.es2017.intl.d.ts @@ -19,7 +19,22 @@ and limitations under the License. declare namespace Intl { - type DateTimeFormatPartTypes = "day" | "dayPeriod" | "era" | "hour" | "literal" | "minute" | "month" | "second" | "timeZoneName" | "weekday" | "year"; + + interface DateTimeFormatPartTypesRegistry { + day: any + dayPeriod: any + era: any + hour: any + literal: any + minute: any + month: any + second: any + timeZoneName: any + weekday: any + year: any + } + + type DateTimeFormatPartTypes = keyof DateTimeFormatPartTypesRegistry; interface DateTimeFormatPart { type: DateTimeFormatPartTypes; diff --git a/lib/lib.es2021.intl.d.ts b/lib/lib.es2021.intl.d.ts index f1ec84e8a1748..e66ebb1af5d38 100644 --- a/lib/lib.es2021.intl.d.ts +++ b/lib/lib.es2021.intl.d.ts @@ -20,6 +20,10 @@ and limitations under the License. declare namespace Intl { + interface DateTimeFormatPartTypesRegistry { + fractionalSecond: any + } + interface DateTimeFormatOptions { formatMatcher?: "basic" | "best fit" | "best fit" | undefined; dateStyle?: "full" | "long" | "medium" | "short" | undefined; diff --git a/lib/lib.es2022.error.d.ts b/lib/lib.es2022.error.d.ts index d97525dcca469..4b16e09121d45 100644 --- a/lib/lib.es2022.error.d.ts +++ b/lib/lib.es2022.error.d.ts @@ -19,11 +19,11 @@ and limitations under the License. interface ErrorOptions { - cause?: Error; + cause?: unknown; } interface Error { - cause?: Error; + cause?: unknown; } interface ErrorConstructor { diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index c2d7f6d1ddc3a..cd91033d5f0b5 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -933,12 +933,24 @@ interface DateConstructor { declare var Date: DateConstructor; interface RegExpMatchArray extends Array { + /** + * The index of the search at which the result was found. + */ index?: number; + /** + * A copy of the search string. + */ input?: string; } interface RegExpExecArray extends Array { + /** + * The index of the search at which the result was found. + */ index: number; + /** + * A copy of the search string. + */ input: string; } @@ -1520,8 +1532,8 @@ interface Promise { */ type Awaited = T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode - T extends object & { then(onfulfilled: infer F): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped - F extends ((value: infer V, ...args: any) => any) ? // if the argument to `then` is callable, extracts the first argument + T extends object & { then(onfulfilled: infer F, ...args: infer _): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped + F extends ((value: infer V, ...args: infer _) => any) ? // if the argument to `then` is callable, extracts the first argument Awaited : // recursively unwrap the value never : // the argument to `then` was not callable T; // non-object or non-thenable diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 56ee915ac3a2d..30f83bc8462e2 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -3008,11 +3008,11 @@ declare var StorageManager: { * Available only in secure contexts. */ interface SubtleCrypto { - decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; + decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise; deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise; digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise; - encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; + encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; exportKey(format: "jwk", key: CryptoKey): Promise; exportKey(format: Exclude, key: CryptoKey): Promise; generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray): Promise; diff --git a/lib/pl/diagnosticMessages.generated.json b/lib/pl/diagnosticMessages.generated.json index d7516e671f8b1..8523a81e5bcb8 100644 --- a/lib/pl/diagnosticMessages.generated.json +++ b/lib/pl/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "Typ „this” jest dostępny tylko w niestatycznej składowej klasy lub interfejsu.", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "Plik „tsconfig.json” jest już zdefiniowany w: „{0}”.", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "Składowa krotki nie może być jednocześnie opcjonalna i typu rest.", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "Nie można indeksować typu krotki z wartością ujemną.", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "Wyrażenie asercji typu jest niedozwolone po lewej stronie wyrażenia potęgowania. Zastanów się nad zamknięciem wyrażenia w nawiasach.", "A_type_literal_property_cannot_have_an_initializer_1247": "Właściwość literału typu nie może mieć inicjatora.", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "Import dotyczący tylko typu może określać import domyślny lub powiązania nazwane, ale nie jedno i drugie jednocześnie.", @@ -132,8 +133,8 @@ "Add_definite_assignment_assertion_to_property_0_95020": "Dodaj asercję określonego przypisania do właściwości „{0}”", "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": "Dodaj asercję określonego przypisania do wszystkich niezainicjowanych właściwości", "Add_export_to_make_this_file_into_a_module_95097": "Dodaj element „export {}”, aby przekształcić ten plik w moduł", - "Add_extends_constraint_2211": "Add `extends` constraint.", - "Add_extends_constraint_to_all_type_parameters_2212": "Add `extends` constraint to all type parameters", + "Add_extends_constraint_2211": "Dodaj ograniczenie „rozszerzeń”.", + "Add_extends_constraint_to_all_type_parameters_2212": "Dodaj ograniczenie „rozszerzeń” do wszystkich parametrów typu", "Add_import_from_0_90057": "Dodaj import z „{0}”", "Add_index_signature_for_property_0_90017": "Dodaj sygnaturę indeksu dla właściwości „{0}”", "Add_initializer_to_property_0_95019": "Dodaj inicjator do właściwości „{0}”", @@ -226,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "Parametr sygnatury indeksu musi mieć adnotację typu.", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "Typ parametru sygnatury indeksu nie może być typem literału ani typem ogólnym. Rozważ użycie zamiast tego mapowanego typu obiektu.", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "Parametr sygnatury indeksu musi mieć typ „string”, „number” lub „symbol” albo typ literału szablonu.", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "Po wyrażeniu tworzenia wystąpienia nie może następować dostęp do właściwości.", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "Interfejs może rozszerzać tylko identyfikator/nazwę kwalifikowaną z opcjonalnymi argumentami typu.", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "Interfejs może rozszerzać tylko typ obiektu lub część wspólną typów obiektów ze statycznie znanymi elementami członkowskimi.", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "Interfejs nie może rozszerzyć typu pierwotnego, takiego jak „{0}”; interfejs może rozszerzać tylko nazwane typy i klasy", @@ -700,6 +702,10 @@ "File_0_not_found_6053": "Nie można odnaleźć pliku '{0}'.", "File_Management_6245": "Zarządzanie plikami", "File_change_detected_Starting_incremental_compilation_6032": "Wykryto zmianę pliku. Trwa rozpoczynanie kompilacji przyrostowej...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "Plik jest modułem CommonJS, ponieważ element „{0}” nie ma pola „type”", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "Plik jest modułem CommonJS, ponieważ element „{0}” ma pole „type”, którego wartość nie jest „module”", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "Plik jest modułem CommonJS, ponieważ nie znaleziono pliku „package.json”", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "Plik jest modułem ECMAScript, ponieważ element „{0}” ma pole „type” z wartością „module”", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "Plik jest modułem CommonJS; może zostać przekonwertowany na moduł ES.", "File_is_default_library_for_target_specified_here_1426": "Plik to domyślna biblioteka dla elementu docelowego określonego w tym miejscu.", "File_is_entry_point_of_type_library_specified_here_1419": "Plik to punkt wejścia biblioteki typów określonej w tym miejscu.", @@ -774,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "Oczekiwano identyfikatora. „{0}” jest słowem zastrzeżonym, którego nie można użyć w tym miejscu.", "Identifier_expected_1003": "Oczekiwano identyfikatora.", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "Oczekiwano identyfikatora. Ciąg „__esModule” jest zastrzeżony jako eksportowany znacznik podczas transformowania modułów ECMAScript.", + "Identifier_or_string_literal_expected_1478": "Oczekiwano identyfikatora lub literału ciągu.", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "Jeśli pakiet \"{0}\" faktycznie udostępnia ten moduł, rozważ wysłanie żądania ściągnięcia w celu zmiany elementu \"https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}\"", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "Jeśli pakiet „{0}” rzeczywiście uwidacznia ten moduł, spróbuj dodać nowy plik deklaracji (.d.ts) zawierający „declare module”{1}';`", "Ignore_this_error_message_90019": "Ignoruj ten komunikat o błędzie", @@ -1495,7 +1502,7 @@ "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354": "Ta składnia wymaga zaimportowanego pomocnika, ale nie można znaleźć modułu „{0}”.", "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Ta składnia wymaga zaimportowanego pomocnika o nazwie „{1}”, który nie istnieje w elemencie „{0}”. Rozważ uaktualnienie wersji „{0}”.", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Ta składnia wymaga zaimportowanego pomocnika o nazwie „{1}” z parametrami {2}, który nie jest zgodny z tym w elemencie „{0}”. Rozważ uaktualnienie wersji elementu „{0}”.", - "This_type_parameter_might_need_an_extends_0_constraint_2208": "This type parameter might need an `extends {0}` constraint.", + "This_type_parameter_might_need_an_extends_0_constraint_2208": "Ten parametr typu może wymagać ograniczenia „rozszerzeń{0}”.", "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "To użycie elementu „import” jest nieprawidłowe. Wywołania „import()” mogą być zapisywane, ale muszą mieć nawiasy i nie mogą mieć argumentów typu.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378": "Wyrażenia „await” najwyższego poziomu są dozwolone tylko wtedy, gdy opcja „module” jest ustawiona na wartość „es2022”, „esnext”, „system”, „node16” lub „nodenext”, a opcja „target” jest ustawiona na wartość „es2017” lub wyższą.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": "Deklaracje najwyższego poziomu w plikach .d.ts muszą rozpoczynać się od modyfikatora „declare” lub „export”.", @@ -1561,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "Biblioteka typów jest przywoływana za pośrednictwem elementu „{0}” z pliku „{1}” o identyfikatorze packageId „{2}”", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "Typ operandu „await” musi być prawidłową obietnicą lub nie może zawierać wywoływalnej składowej „then”.", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "Typ wartości właściwości obliczanej to „{0}”, którego nie można przypisać do typu „{1}”.", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "Typ zmiennej składowej wystąpienia „{0}” nie może odwoływać się do identyfikatora „{1}” zadeklarowanego w konstruktorze.", "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "Typ iterowanych elementów operandu „yield*” musi być prawidłową obietnicą lub nie może zawierać wywoływalnej składowej „then”.", "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "Typ właściwości „{0}” cyklicznie odwołuje się do siebie w zamapowanym typie „{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” w generatorze asynchronicznym musi być prawidłową obietnicą lub nie może zawierać wywoływalnej składowej „then”.", @@ -1588,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== Dyrektywa odwołania do typu „{0}” nie została rozpoznana. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== Dyrektywa odwołania do typu „{0}” została pomyślnie rozpoznana jako „{1}”, podstawowe: {2}. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== Dyrektywa odwołania do typu „{0}” została pomyślnie rozpoznana jako „{1}” z identyfikatorem pakietu „{2}”, podstawowe: {3}. ========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "Typy nie mogą występować w deklaracjach eksportu w plikach JavaScript.", "Types_have_separate_declarations_of_a_private_property_0_2442": "Typy mają osobne deklaracje właściwości prywatnej „{0}”.", "Types_of_construct_signatures_are_incompatible_2419": "Typy sygnatur konstrukcji są niezgodne.", "Types_of_parameters_0_and_1_are_incompatible_2328": "Typy parametrów „{0}” i „{1}” są niezgodne.", @@ -1665,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "Zawijaj następującą treść z nawiasami, która powinna być literałem obiektu", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "O wszystkich opcjach kompilatora przeczytasz na stronie {0}", "You_cannot_rename_a_module_via_a_global_import_8031": "Nie można zmienić nazwy modułu za pomocą importu globalnego.", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "Nie można zmieniać nazw elementów zdefiniowanych w folderze „node_modules”.", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "Nie można zmieniać nazw elementów zdefiniowanych w innym folderze „node_modules”.", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "Nie można zmienić nazw elementów zdefiniowanych w standardowej bibliotece TypeScript.", "You_cannot_rename_this_element_8000": "Nie można zmienić nazwy tego elementu.", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "Element „{0}” akceptuje za mało argumentów, aby można go było użyć w tym miejscu jako dekorator. Czy chcesz najpierw go wywołać i zapisać tag „@{0}()”?", @@ -1692,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "Sygnatury indeksów „{0}” są niezgodne.", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "Typu indeksu „{0}” „{1}” nie można przypisać do typu indeksu „{2}” „{3}”.", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "Element „{0}” jest elementem podstawowym, ale element „{1}” jest obiektem otoki. Preferuje się użycie elementu „{0}”, jeśli jest to możliwe.", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "„{0}” jest typem i nie można go zaimportować w plikach JavaScript. Użyj elementu „{1}” w adnotacji typu JSDoc.", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "Element \"{0}\" jest typem i musi być importowany przy użyciu importu tylko typu, gdy są włączone opcje \"preserveValueImports\" i \"isolatedModules\".", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "„{0}” to nieużywana zmiana nazwy elementu „{1}”. Czy zamierzano używać go jako adnotacji typu?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "Element „{0}” można przypisać do ograniczenia typu „{1}”, ale wystąpienie typu „{1}” można utworzyć z innym podtypem ograniczenia „{2}”.", + "_0_is_automatically_exported_here_18044": "W tym miejscu jest automatycznie eksportowany element „{0}”.", "_0_is_declared_but_its_value_is_never_read_6133": "Element „{0}” jest zadeklarowany, ale jego wartość nie jest nigdy odczytywana.", "_0_is_declared_but_never_used_6196": "Element „{0}” jest zadeklarowany, ale nie jest nigdy używany.", "_0_is_declared_here_2728": "Element „{0}” jest zadeklarowany tutaj.", diff --git a/lib/pt-br/diagnosticMessages.generated.json b/lib/pt-br/diagnosticMessages.generated.json index c7244246ad8a1..269fbc9d6b6a1 100644 --- a/lib/pt-br/diagnosticMessages.generated.json +++ b/lib/pt-br/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "Um tipo 'this' está disponível somente em um membro não estático de uma classe ou interface.", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "Um arquivo 'tsconfig.json' já está definido em: '{0}'.", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "Um membro de tupla não pode ser opcional e rest.", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "Um tipo de tupla não pode ser indexado com um valor negativo.", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "Uma expressão de asserção de tipo não é permitida no lado esquerdo de uma expressão de exponenciação. Considere delimitar a expressão em parênteses.", "A_type_literal_property_cannot_have_an_initializer_1247": "Uma propriedade literal de tipo não pode ter um inicializador.", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "Uma importação somente de tipo pode especificar uma importação padrão ou associações nomeadas, mas não ambos.", @@ -226,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "Um parâmetro de assinatura de índice deve ter uma anotação de tipo.", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "Um tipo de parâmetro de assinatura de índice não pode ser um tipo literal ou genérico. Considere usar um tipo de objeto mapeado.", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "Um tipo de parâmetro de assinatura de índice deve ser 'cadeia de caracteres', 'número', 'símbolo' ou um tipo literal de modelo.", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "Uma expressão de instanciação não pode ser seguida por um acesso de propriedade.", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "Uma interface só pode estender um identificador/nome qualificado com argumentos de tipo opcionais.", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "Uma interface só pode estender um tipo de objeto ou interseção de tipos de objeto com membros estaticamente conhecidos.", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "Uma interface não pode estender um tipo primitivo como '{0}'; uma interface só pode estender tipos e classes nomeados", @@ -700,6 +702,10 @@ "File_0_not_found_6053": "Arquivo '{0}' não encontrado.", "File_Management_6245": "Gerenciamento de Arquivos", "File_change_detected_Starting_incremental_compilation_6032": "Alteração do arquivo detectada. Iniciando compilação incremental...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "O arquivo é um módulo CommonJS porque '{0}' não tem o campo \"type\"", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "O arquivo é o módulo CommonJS porque '{0}' tem o campo \"type\" cujo valor não é \"module\"", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "O arquivo é um módulo CommonJS porque 'package.json' não foi encontrado", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "O arquivo é o módulo ECMAScript porque '{0}' tem o campo \"type\" com o valor \"module\"", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "O arquivo é um módulo CommonJS; ele pode ser convertido em um módulo ES.", "File_is_default_library_for_target_specified_here_1426": "O arquivo é a biblioteca padrão para o destino especificado aqui.", "File_is_entry_point_of_type_library_specified_here_1419": "O arquivo é o ponto de entrada da biblioteca de tipos especificada aqui.", @@ -774,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "Identificador esperado. '{0}' é uma palavra reservada que não pode ser usada aqui.", "Identifier_expected_1003": "Identificador esperado.", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "Identificador esperado. '__esModule' é reservado como um marcador exportado ao transformar os módulos ECMAScript.", + "Identifier_or_string_literal_expected_1478": "Identificador ou literal de cadeia de caracteres esperado.", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "Se o pacote '{0}' realmente expõe este módulo, considere enviar uma solicitação de pull para corrigir 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}'", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "Se o pacote '{0}' realmente expõe este módulo, tente adicionar um novo arquivo de declaração (.d.ts) contendo o módulo `declare '{1}';`", "Ignore_this_error_message_90019": "Ignorar essa mensagem de erro", @@ -1561,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "Biblioteca de tipos referenciada via '{0}' do arquivo '{1}' com packageId '{2}'", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "O tipo de operando \"await\" deve ser uma promessa válida ou não deve conter um membro \"then\" que pode ser chamado.", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "O tipo de valor da propriedade computada é '{0}', que não pode ser atribuído ao tipo '{1}'.", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "O tipo de variável '{0}' de membro de instância não pode referenciar o identificador '{1}' declarado no construtor.", "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.", @@ -1588,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== A diretiva de referência de tipo '{0}' não foi resolvida. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== A diretiva de referência de tipo '{0}' foi resolvida com sucesso para '{1}', primário: {2}. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== A diretiva de referência de tipo '{0}' foi resolvida com sucesso para '{1}' com a ID do Pacote '{2}', primário: {3}. ========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "Os tipos não podem aparecer em declarações de exportação em arquivos JavaScript.", "Types_have_separate_declarations_of_a_private_property_0_2442": "Tipos têm declarações separadas de uma propriedade privada '{0}'.", "Types_of_construct_signatures_are_incompatible_2419": "Os tipos de assinaturas de constructo são incompatíveis.", "Types_of_parameters_0_and_1_are_incompatible_2328": "Os tipos de parâmetros '{0}' e '{1}' são incompatíveis.", @@ -1665,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "Colocar entre parênteses o corpo a seguir, que deve ser um literal de objeto", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "Você pode aprender sobre todas as opções do compilador em {0}", "You_cannot_rename_a_module_via_a_global_import_8031": "Não é possível renomear um módulo por meio de uma importação global.", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "Não é possível renomear elementos definidos em uma pasta 'node_modules'.", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "Não é possível renomear elementos definidos em outra pasta 'node_modules'.", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "Não é possível renomear elementos que são definidos na biblioteca TypeScript padrão.", "You_cannot_rename_this_element_8000": "Você não pode renomear este elemento.", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "'{0}' aceita muito poucos argumentos para serem usados como um decorador aqui. Você quis dizer para chamá-lo primeiro e gravar '@{0}()'?", @@ -1692,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "'{0}' assinaturas de índice são incompatíveis.", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "'{0}' tipo de índice '{1}' não pode ser atribuído a '{2}' tipo de índice '{3}'.", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "'{0}' é um primitivo, mas '{1}' é um objeto de wrapper. Prefira usar '{0}' quando possível.", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "'{0}' é um tipo e não pode ser importado em arquivos JavaScript. Use '{1}' em uma anotação de tipo JSDoc.", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "'{0}' é um tipo e deve ser importado usando uma importação somente de tipo quando 'preserveValueImports' e 'isolatedModules' estiverem habilitados.", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "'{0}' é uma renomeação não usada de '{1}'. Você pretendia usá-lo como uma anotação de tipo?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "'{0}' é atribuível à restrição do tipo '{1}', mas é possível criar uma instância de '{1}' com um subtipo diferente de restrição '{2}'.", + "_0_is_automatically_exported_here_18044": "'{0}' é exportado automaticamente aqui.", "_0_is_declared_but_its_value_is_never_read_6133": "'{0}' é declarado, mas seu valor nunca é lido.", "_0_is_declared_but_never_used_6196": "'{0}' está declarado, mas nunca foi usado.", "_0_is_declared_here_2728": "'{0}' é declarado aqui.", diff --git a/lib/ru/diagnosticMessages.generated.json b/lib/ru/diagnosticMessages.generated.json index ac24d359dc276..e3d29e3966b1f 100644 --- a/lib/ru/diagnosticMessages.generated.json +++ b/lib/ru/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "Тип this доступен только в нестатическом элементе класса или интерфейса.", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "Файл tsconfig.json уже определен в \"{0}\".", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "Элемент кортежа не может быть одновременно элементом rest и необязательным элементом.", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "Тип кортежа нельзя индексировать с отрицательным значением.", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "Выражение утверждения типа не допускается в левой части выражения, возводимого в степень. Попробуйте заключить выражение в скобки.", "A_type_literal_property_cannot_have_an_initializer_1247": "Свойство литерала типа не может иметь инициализатор.", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "Импорт, затрагивающий только тип, может указывать либо только импорт по умолчанию, либо только именованные привязки.", @@ -226,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "У параметра сигнатуры индекса должна быть аннотация типа.", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "Тип параметра сигнатуры индекса не может быть типом литерала или универсальным типом. Рекомендуется использовать тип сопоставляемого объекта.", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "Тип параметра сигнатуры индекса должен быть строкой, числом, символом или типом литерала шаблона.", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "За выражением создания экземпляра не может следовать доступ к свойству.", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "Интерфейс может расширить только идентификатор или полное имя с дополнительными аргументами типа.", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "Интерфейс может расширять только тип объекта или пересечение типов объектов со статическими известными членами.", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "Интерфейс не может расширять примитивный тип, например \"{0}\". Интерфейс может расширять только именованные типы и классы", @@ -700,6 +702,10 @@ "File_0_not_found_6053": "Файл \"{0}\" не найден.", "File_Management_6245": "Управление файлами", "File_change_detected_Starting_incremental_compilation_6032": "Обнаружено изменение в файле. Запускается инкрементная компиляция...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "Файл является модулем CommonJS, так как \"{0}\" не содержит поле \"type\"", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "Файл является модулем CommonJS, так как \"{0}\" содержит поле \"type\", значение которого отличается от \"module\"", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "Файл является модулем CommonJS, так как \"package.json\" не найден", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "Файл является модулем ECMAScript, так как \"{0}\" содержит поле \"type\" со значением \"module\"", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "Файл является модулем CommonJS. Его можно преобразовать в модуль ES.", "File_is_default_library_for_target_specified_here_1426": "Файл является библиотекой по умолчанию для указанного здесь целевого объекта.", "File_is_entry_point_of_type_library_specified_here_1419": "Файл является точкой входа для указанной здесь библиотеки типов.", @@ -774,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "Ожидается идентификатор. \"{0}\" — это зарезервированное слово, которое не может быть использовано здесь.", "Identifier_expected_1003": "Ожидался идентификатор.", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "Ожидался идентификатор. Значение \"__esModule\" зарезервировано как экспортируемый маркер при преобразовании модулей ECMAScript.", + "Identifier_or_string_literal_expected_1478": "Ожидался идентификатор или строковый литерал.", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "Если пакет \"{0}\" фактически предоставляет этот модуль, рекомендуется отправить запрос на вытягивание, чтобы изменить \"https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}\"", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "Если пакет \"{0}\" действительно предоставляет этот модуль, попробуйте добавить новый файл объявления (. d. TS), содержащий \"declare module\" \"{1}\";`", "Ignore_this_error_message_90019": "Пропустите это сообщение об ошибке", @@ -1561,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "Библиотека типов, на которую осуществляется ссылка с помощью \"{0}\" из файла \"{1}\" с идентификатором пакета \"{2}\"", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "Тип операнда \"await\" должен быть допустимым обещанием либо не должен содержать вызываемый элемент \"then\".", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "Типом значения вычисляемого свойства является \"{0}\", который не может быть назначен типу \"{1}\".", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "Инициализатор переменной-элемента экземпляра \"{0}\" не может ссылаться на идентификатор \"{1}\", объявленный в конструкторе.", "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\".", @@ -1588,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== Директива ссылки на тип \"{0}\" не разрешена. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== Директива ссылки на тип \"{0}\" успешно разрешена в \"{1}\", первичный объект: {2}. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== Директива ссылки на тип \"{0}\" успешно разрешена в \"{1}\" с идентификатором пакета \"{2}\", первичный объект: {3}. ========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "Типы не могут отображаться в объявлениях экспорта в файлах JavaScript.", "Types_have_separate_declarations_of_a_private_property_0_2442": "Типы имеют раздельные объявления закрытого свойства \"{0}\".", "Types_of_construct_signatures_are_incompatible_2419": "Типы сигнатур конструкций несовместимы.", "Types_of_parameters_0_and_1_are_incompatible_2328": "Типы параметров \"{0}\" и \"{1}\" несовместимы.", @@ -1665,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "Заключить следующий текст в круглые скобки, которые должны быть литералом объекта", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "Вы можете узнать обо всех параметрах компилятора на {0}", "You_cannot_rename_a_module_via_a_global_import_8031": "Вы не можете переименовать модуль с помощью глобального импорта.", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "Невозможно переименовать элементы, определенные в папке \"node_modules\".", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "Невозможно переименовать элементы, определенные в другой папке \"node_modules\".", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "Невозможно переименовать элементы, определенные в стандартной библиотеке TypeScript.", "You_cannot_rename_this_element_8000": "Этот элемент переименовать нельзя.", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "\"{0}\" принимает слишком мало аргументов для использования в качестве декоратора. Вы хотели сначала вызвать его и записать \"@{0}()\"?", @@ -1692,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "Сигнатуры индекса \"{0}\" несовместимы.", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "Тип индекса \"{0}\" \"{1}\" не может быть назначен типу индекса \"{2}\" \"{3}\".", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "\"{0}\" является примитивом, но \"{1}\" — объект оболочки. Предпочтительно использовать \"{0}\" по мере возможности.", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "\"{0}\" является типом и не может импортироваться в файлы JavaScript. Используйте \"{1}\" в заметке типа JSDoc.", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "\"{0}\" является типом. Чтобы импортировать его, необходимо использовать импорт, распространяющийся только на тип, если включены параметры \"preserveValueImports\" и \"isolatedModules\".", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "\"{0}\" является неиспользуемым переименованием \"{1}\". Возможно, это должна была быть заметка для типа?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "\"{0}\" может быть назначен ограничению типа \"{1}\", но можно создать экземпляр \"{1}\" с другим подтипом ограничения \"{2}\".", + "_0_is_automatically_exported_here_18044": "\"{0}\" экспортирован автоматически.", "_0_is_declared_but_its_value_is_never_read_6133": "Свойство \"{0}\" объявлено, но его значение не было прочитано.", "_0_is_declared_but_never_used_6196": "\"{0}\" объявлен, но никогда не использовался.", "_0_is_declared_here_2728": "Здесь объявлен \"{0}\".", diff --git a/lib/tr/diagnosticMessages.generated.json b/lib/tr/diagnosticMessages.generated.json index a568001a0cd2e..5297519a46f86 100644 --- a/lib/tr/diagnosticMessages.generated.json +++ b/lib/tr/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "'this' türü, yalnızca bir sınıfın veya arabirimin statik olmayan bir üyesinde kullanılabilir.", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "'tsconfig.json' dosyası şu konumda zaten tanımlanmış: '{0}'.", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "Demet üyesi hem isteğe bağlı hem de diğerleri olamaz.", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "Bir demet türünün negatif bir değerle dizini oluşturulamaz.", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "Üs ifadesinin sol tarafında tür onaylama ifadesine izin verilmez. İfadeyi parantez içine yazmayı düşünün.", "A_type_literal_property_cannot_have_an_initializer_1247": "Tür sabit değeri özelliği bir başlatıcıya sahip olamaz.", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "Yalnızca tür içeri aktarma işlemleri varsayılan bir içeri aktarmayı veya adlandırılan bağlamaları belirtebilir ancak ikisini birden belirtemez.", @@ -132,6 +133,8 @@ "Add_definite_assignment_assertion_to_property_0_95020": "'{0}' özelliğine belirli atama onayı ekle", "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": "Tüm başlatılmamış özelliklere kesin atama onayları ekle", "Add_export_to_make_this_file_into_a_module_95097": "Bu dosyayı bir modüle dönüştürmek için 'export {}' ekleyin", + "Add_extends_constraint_2211": "`extends` kısıtlaması ekleyin.", + "Add_extends_constraint_to_all_type_parameters_2212": "Tüm tür parametrelerine `extends` kısıtlaması ekleyin", "Add_import_from_0_90057": "\"{0}\" kaynağından içeri aktarma ekle", "Add_index_signature_for_property_0_90017": "'{0}' özelliği için dizin imzası ekle", "Add_initializer_to_property_0_95019": "'{0}' özelliğine başlatıcı ekle", @@ -224,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "Dizin imzası parametresi, bir tür ek açıklamasına sahip olmalıdır.", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "Dizin imzası parametre türü sabit değer veya genel tür olamaz. Bunun yerine eşlenen nesne türü kullanabilirsiniz.", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "Dizin imzası parametre türü 'dize', 'sayı', 'sembol' veya şablon sabit değeri olmalıdır.", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "Bir örnek oluşturma ifadesinin ardından özellik erişimi gelemez.", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "Bir arabirim, isteğe bağlı tür bağımsız değişkenleri ile yalnızca bir tanımlayıcıyı/tam adı genişletebilir.", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "Arabirim, yalnızca statik olarak bilinen üyelere sahip bir nesne türünü veya nesne türlerinin bir kesişimini genişletebilir.", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "Arabirim, '{0}' gibi temel bir türü genişletemez; arabirim yalnızca adlandırılmış türleri ve sınıfları genişletilebilir", @@ -698,6 +702,10 @@ "File_0_not_found_6053": "'{0}' dosyası bulunamadı.", "File_Management_6245": "Dosya Yönetimi", "File_change_detected_Starting_incremental_compilation_6032": "Dosya değişikliği algılandı. Artımlı derleme başlatılıyor...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "'{0}', \"type\" alanına sahip olmadığından dosya CommonJS modülüdür", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "'{0}', değeri \"module\" olmayan \"type\" alanına sahip olduğundan dosya CommonJS modülüdür", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "'package.json' bulunamadığından dosya CommonJS modülüdür", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "'{0}', değeri \"module\" olan \"type\" alanına sahip olduğundan dosya ECMAScript modülüdür", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "Bir CommonJS modülü olan dosya bir ES modülüne dönüştürülebilir.", "File_is_default_library_for_target_specified_here_1426": "Burada dosya, belirtilen hedef için varsayılan kitaplıktır.", "File_is_entry_point_of_type_library_specified_here_1419": "Burada dosya, belirtilen tür kitaplığının giriş noktasıdır.", @@ -772,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "Tanımlayıcı bekleniyor. '{0}', burada kullanılamayan ayrılmış bir sözcüktür.", "Identifier_expected_1003": "Tanımlayıcı bekleniyor.", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "Tanımlayıcı bekleniyor. '__esModule', ECMAScript modülleri dönüştürülürken, dışarı aktarılan bir işaretçi olarak ayrılmış.", + "Identifier_or_string_literal_expected_1478": "Tanımlayıcı veya sabit değerli dize bekleniyor.", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "'{0}' paketi bu modülü gerçekten kullanıma sunarsa, 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}' öğesini düzeltmek için bir çekme isteği göndermeyi deneyin", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "‘{0}’ paketi bu modülü fiili olarak kullanıma sunuyorsa `'{1}' modülünü bildir;` ifadesini içeren yeni bir bildirim (.d.ts) dosyası eklemeyi deneyin", "Ignore_this_error_message_90019": "Bu hata iletisini yoksay", @@ -1493,7 +1502,7 @@ "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354": "Bu söz dizimi, içeri aktarılan bir yardımcı gerektiriyor ancak '{0}' modülü bulunamıyor.", "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343": "Bu söz dizimi, '{0}' içinde bulunmayan '{1}' adlı içeri aktarılmış bir yardımcı gerektirir. '{0}' sürümünüzü yükseltmeyi deneyin.", "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807": "Bu söz dizimi, '{0}' içindeki yardımcı ile uyumlu olmayan, {2} parametreye sahip '{1}' adlı içeri aktarılan yardımcıyı gerektiriyor. '{0}' sürümünüzü yükseltmeyi düşünün.", - "This_type_parameter_probably_needs_an_extends_object_constraint_2208": "Bu tür parametresi için bir `nesneyi genişletir` kısıtlaması gerekiyor olabilir.", + "This_type_parameter_might_need_an_extends_0_constraint_2208": "Bu tür parametresinin bir `extends {0}` kısıtlamasına ihtiyacı olabilir.", "This_use_of_import_is_invalid_import_calls_can_be_written_but_they_must_have_parentheses_and_cannot__1326": "'import' çağrısının bu kullanımı geçersiz. 'import()' çağrıları yazılabilir ancak ayraç içermeleri gerekir ve tür bağımsız değişkenleri içeremezler.", "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_n_1378": "Üst düzey 'await' ifadelerine yalnızca 'module' seçeneği 'es2022', 'esnext', 'system', 'node16' veya 'nodenext' olarak ayarlandığında ve 'target' seçeneği 'es2017' veya üzeri olarak ayarlandığında izin verilir.", "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046": ".d.ts dosyalarındaki üst düzey bildirimler bir 'declare' veya 'export' değiştiricisi ile başlamalıdır.", @@ -1559,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "'{2}' paket kimliğine sahip '{1}' dosyasından '{0}' aracılığıyla başvurulan tür kitaplığı", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "'await' işleneninin türü, geçerli bir promise olmalı veya çağrılabilir 'then' üyesi içermemelidir.", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "Hesaplanan özellik değerinin '{0}' türü, '{1}' türüne atanamıyor.", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "'{0}' örnek üyesi değişkeninin türü, oluşturucuda bildirilen '{1}' tanımlayıcısına başvuramaz.", "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.", @@ -1586,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== '{0}' tür başvuru yönergesi çözümlenmedi. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== '{0}' tür başvuru yönergesi '{1}' olarak başarıyla çözümlendi, birincil: {2}. ========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== '{0}' tür başvuru yönergesi '{2}' Paket Kimliğine sahip '{1}' olarak başarıyla çözümlendi, birincil: {3}. ========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "Türler, JavaScript dosyalarında dışarı aktarma bildirimlerinde görünemez.", "Types_have_separate_declarations_of_a_private_property_0_2442": "Türler, '{0}' özel özelliğinin ayrı bildirimlerine sahip.", "Types_of_construct_signatures_are_incompatible_2419": "Yapı imzalarının türleri uyumsuz.", "Types_of_parameters_0_and_1_are_incompatible_2328": "'{0}' ve '{1}' parametre türleri uyumsuz.", @@ -1663,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "Nesne sabit değeri olması gereken aşağıdaki gövdeyi parantez içine alın", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "Tüm derleyici seçenekleri hakkında bilgi edinmek için bkz. {0}", "You_cannot_rename_a_module_via_a_global_import_8031": "Genel içeri aktarma aracılığıyla bir modülü yeniden adlandıramazsınız.", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "Bir 'node_modules' klasöründe tanımlanan öğeler yeniden adlandırılamaz.", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "Başka bir 'node_modules' klasöründe tanımlanan öğeler yeniden adlandırılamaz.", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "Standart TypeScript kitaplığında tanımlanmış öğeleri yeniden adlandıramazsınız.", "You_cannot_rename_this_element_8000": "Bu öğeyi yeniden adlandıramazsınız.", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "'{0}' burada dekoratör olarak kullanılmak için çok az bağımsız değişken kabul ediyor. Önce çağırıp '@{0}()' yazmak mı istediniz?", @@ -1690,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "'{0}' dizin imzaları uyumsuz.", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "'{0}' dizin türü '{1}' ' {2}' dizin türüne '{3}' atanamaz.", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "'{0}' temel elemandır ancak '{1}' sarmalayıcı nesnedir. Mümkün olduğunda '{0}' kullanmayı tercih edin.", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "'{0}' bir tür ve JavaScript dosyalarında içeri aktarılamaz. Bir JSDoc türü ek açıklamasında '{1}' kullanın.", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "'{0}' bir türdür ve 'preserveValueImports' ve 'isolatedModules' seçeneklerinin her ikisi de etkin olduğunda yalnızca türü içeri aktarma kullanılarak içeri aktarılmalıdır.", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "'{0}', '{1}' türünün kullanılmayan bir yeniden adlandırması. Tür ek açıklaması olarak mı kullanmak istediniz?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "'{0}', '{1}' türündeki kısıtlamaya atanabilir ancak '{1}' örneği, '{2}' kısıtlamasının farklı bir alt türüyle oluşturulabilir.", + "_0_is_automatically_exported_here_18044": "'{0}' burada otomatik olarak dışarı aktarılır.", "_0_is_declared_but_its_value_is_never_read_6133": "'{0}' bildirildi ancak değeri hiç okunmadı.", "_0_is_declared_but_never_used_6196": "'{0}' bildirildi ancak hiç kullanılmadı.", "_0_is_declared_here_2728": "'{0}' burada bildirilir.", diff --git a/lib/tsc.js b/lib/tsc.js index 8f88471446307..ae1a92412f2c7 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -22,7 +22,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var ts; (function (ts) { ts.versionMajorMinor = "4.8"; - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "4.8.1-rc"; var NativeCollections; (function (NativeCollections) { var globals = typeof globalThis !== "undefined" ? globalThis : @@ -94,7 +94,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); var ts; @@ -1278,6 +1278,41 @@ var ts; return createMultiMap(); } ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap; + function createQueue(items) { + var elements = (items === null || items === void 0 ? void 0 : items.slice()) || []; + var headIndex = 0; + function isEmpty() { + return headIndex === elements.length; + } + function enqueue() { + var items = []; + for (var _i = 0; _i < arguments.length; _i++) { + items[_i] = arguments[_i]; + } + elements.push.apply(elements, items); + } + function dequeue() { + if (isEmpty()) { + throw new Error("Queue is empty"); + } + var result = elements[headIndex]; + elements[headIndex] = undefined; + headIndex++; + if (headIndex > 100 && headIndex > (elements.length >> 1)) { + var newLength = elements.length - headIndex; + elements.copyWithin(0, headIndex); + elements.length = newLength; + headIndex = 0; + } + return result; + } + return { + enqueue: enqueue, + dequeue: dequeue, + isEmpty: isEmpty, + }; + } + ts.createQueue = createQueue; function createSet(getHashCode, equals) { var multiMap = new ts.Map(); var size = 0; @@ -1444,11 +1479,15 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; function noop(_) { } ts.noop = noop; + ts.noopPush = { + push: noop, + length: 0 + }; function returnFalse() { return false; } @@ -1494,7 +1533,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -1672,7 +1711,7 @@ var ts; } ts.compareBooleans = compareBooleans; function getSpellingSuggestion(name, candidates, getName) { - var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34)); + var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34)); var bestDistance = Math.floor(name.length * 0.4) + 1; var bestCandidate; for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { @@ -1829,7 +1868,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; function matchedText(pattern, candidate) { @@ -2101,7 +2140,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2109,12 +2148,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2124,26 +2163,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2173,42 +2212,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { if (shouldAssertFunction(1, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2229,7 +2268,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; function formatEnum(value, enumObject, isFlags) { @@ -2327,6 +2366,22 @@ var ts; return formatEnum(flags, ts.FlowFlags, true); } Debug.formatFlowFlags = formatFlowFlags; + function formatRelationComparisonResult(result) { + return formatEnum(result, ts.RelationComparisonResult, true); + } + Debug.formatRelationComparisonResult = formatRelationComparisonResult; + function formatCheckMode(mode) { + return formatEnum(mode, ts.CheckMode, true); + } + Debug.formatCheckMode = formatCheckMode; + function formatSignatureCheckMode(mode) { + return formatEnum(mode, ts.SignatureCheckMode, true); + } + Debug.formatSignatureCheckMode = formatSignatureCheckMode; + function formatTypeFacts(facts) { + return formatEnum(facts, ts.TypeFacts, true); + } + Debug.formatTypeFacts = formatTypeFacts; var isDebugInfoEnabled = false; var extendedDebugModule; function extendedDebug() { @@ -2363,7 +2418,7 @@ var ts; this.flags & 1 ? "FlowUnreachable" : "UnknownFlow"; var remainingFlags = this.flags & ~(2048 - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, true); } }, @@ -2393,7 +2448,7 @@ var ts; __tsDebuggerDisplay: { value: function (defaultValue) { defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -2439,7 +2494,7 @@ var ts; var symbolHeader = this.flags & 33554432 ? "TransientSymbol" : "Symbol"; var remainingSymbolFlags = this.flags & ~33554432; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -2448,11 +2503,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var typeHeader = this.flags & 98304 ? "NullableType" : - this.flags & 384 ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : + this.flags & 384 ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : this.flags & 8192 ? "UniqueESSymbolType" : this.flags & 32 ? "EnumType" : - this.flags & 67359327 ? "IntrinsicType " + this.intrinsicName : + this.flags & 67359327 ? "IntrinsicType ".concat(this.intrinsicName) : this.flags & 1048576 ? "UnionType" : this.flags & 2097152 ? "IntersectionType" : this.flags & 4194304 ? "IndexType" : @@ -2471,7 +2526,7 @@ var ts; "ObjectType" : "Type"; var remainingObjectFlags = this.flags & 524288 ? this.objectFlags & ~1343 : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, @@ -2505,11 +2560,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -2541,7 +2596,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -2585,10 +2640,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -2632,6 +2687,48 @@ var ts; return wrapFunction(deprecation, func); } Debug.deprecate = deprecate; + function formatVariance(varianceFlags) { + var variance = varianceFlags & 7; + var result = variance === 0 ? "in out" : + variance === 3 ? "[bivariant]" : + variance === 2 ? "in" : + variance === 1 ? "out" : + variance === 4 ? "[independent]" : ""; + if (varianceFlags & 8) { + result += " (unmeasurable)"; + } + else if (varianceFlags & 16) { + result += " (unreliable)"; + } + return result; + } + Debug.formatVariance = formatVariance; + var DebugTypeMapper = (function () { + function DebugTypeMapper() { + } + DebugTypeMapper.prototype.__debugToString = function () { + var _a; + type(this); + switch (this.kind) { + case 3: return ((_a = this.debugInfo) === null || _a === void 0 ? void 0 : _a.call(this)) || "(function mapper)"; + case 0: return "".concat(this.source.__debugTypeToString(), " -> ").concat(this.target.__debugTypeToString()); + case 1: return ts.zipWith(this.sources, this.targets || ts.map(this.sources, function () { return "any"; }), function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(typeof t === "string" ? t : t.__debugTypeToString()); }).join(", "); + case 2: return ts.zipWith(this.sources, this.targets, function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(t().__debugTypeToString()); }).join(", "); + case 5: + case 4: return "m1: ".concat(this.mapper1.__debugToString().split("\n").join("\n "), "\nm2: ").concat(this.mapper2.__debugToString().split("\n").join("\n ")); + default: return assertNever(this); + } + }; + return DebugTypeMapper; + }()); + Debug.DebugTypeMapper = DebugTypeMapper; + function attachDebugPrototypeIfDebug(mapper) { + if (Debug.isDebugging) { + return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype); + } + return mapper; + } + Debug.attachDebugPrototypeIfDebug = attachDebugPrototypeIfDebug; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); var ts; @@ -2687,11 +2784,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -2913,7 +3010,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); var ts; @@ -3142,7 +3239,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3153,11 +3250,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -3204,9 +3301,9 @@ var ts; eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } tracingEnabled.push = push; - function pop() { + function pop(results) { ts.Debug.assert(eventStack.length > 0); - writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); + writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results); eventStack.length--; } tracingEnabled.pop = pop; @@ -3219,13 +3316,14 @@ var ts; } tracingEnabled.popAll = popAll; var sampleInterval = 1000 * 10; - function writeStackEvent(index, endTime) { + function writeStackEvent(index, endTime, results) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { + ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`"); writeEvent("E", phase, name, args, undefined, endTime); } else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { @@ -3233,11 +3331,11 @@ var ts; if (mode === "server" && phase === "checkTypes") return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -3564,7 +3662,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -3988,7 +4086,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -3999,7 +4097,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -4015,7 +4113,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -4223,20 +4321,22 @@ var ts; watchPresentFileSystemEntry(); return { close: function () { - watcher.close(); - watcher = undefined; + if (watcher) { + watcher.close(); + watcher = undefined; + } } }; function updateWatcher(createWatcher) { if (watcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); watcher.close(); watcher = createWatcher(); } } function watchPresentFileSystemEntry() { if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -4251,7 +4351,7 @@ var ts; } catch (e) { hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -4495,7 +4595,7 @@ var ts; var externalFileCounter = 0; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -4504,7 +4604,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -4520,7 +4620,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -5627,13 +5727,24 @@ var ts; resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."), Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"), + File_is_ECMAScript_module_because_0_has_field_type_with_value_module: diag(1458, ts.DiagnosticCategory.Message, "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458", "File is ECMAScript module because '{0}' has field \"type\" with value \"module\""), + File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module: diag(1459, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459", "File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\""), + File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""), + File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"), The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."), - Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."), + Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead."), catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."), An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), + An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."), + Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."), + The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead: diag(1479, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_reference_1479", "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"{0}\")' call instead."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module: diag(1480, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_packag_1480", "To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1: diag(1481, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Co_1481", "To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'."), + To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0: diag(1482, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0_1482", "To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'."), + To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module: diag(1483, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module_1483", "To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true), @@ -5847,6 +5958,7 @@ var ts; Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."), Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."), Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."), + A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, ts.DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."), Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."), All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."), Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."), @@ -6134,6 +6246,7 @@ var ts; The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), + Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), 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}'."), @@ -7303,7 +7416,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -9830,7 +9943,7 @@ var ts; : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } function getEffectiveTypeParameterDeclarations(node) { if (ts.isJSDocSignature(node)) { @@ -10957,11 +11070,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -11038,7 +11151,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -11139,7 +11252,7 @@ var ts; ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -11156,10 +11269,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -11359,7 +11472,7 @@ var ts; } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { @@ -13718,11 +13831,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -15328,7 +15441,8 @@ var ts; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration)) + || (s.flags & 32768 && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); return s.parent && s.parent.flags & 32 ? flags : flags & ~28; } @@ -15950,7 +16064,7 @@ var ts; return !file.isDeclarationFile ? walkTreeForJSXTags(file) : undefined; } function isFileForcedToBeModuleByFormat(file) { - return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs", ".cts"]))) && !file.isDeclarationFile ? true : undefined; + return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs", ".cts", ".mjs", ".mts"]))) && !file.isDeclarationFile ? true : undefined; } function getSetExternalModuleIndicator(options) { switch (getEmitModuleDetectionKind(options)) { @@ -15967,10 +16081,7 @@ var ts; if (options.jsx === 4 || options.jsx === 5) { checks.push(isFileModuleFromUsingJSXTag); } - var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { - checks.push(isFileForcedToBeModuleByFormat); - } + checks.push(isFileForcedToBeModuleByFormat); var combined_1 = ts.or.apply(void 0, checks); var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); }; return callback; @@ -16121,7 +16232,7 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { @@ -16219,15 +16330,15 @@ var ts; } var wildcardCharCodes = [42, 63]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*", - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { singleAsteriskRegexFragment: "[^/]*", - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -16245,9 +16356,9 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -16265,7 +16376,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -16331,7 +16442,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -16577,7 +16688,7 @@ var ts; ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -17277,10 +17388,11 @@ var ts; } return parenthesizeLeftSideOfAccess(expression); } - function parenthesizeLeftSideOfAccess(expression) { + function parenthesizeLeftSideOfAccess(expression, optionalChain) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 || emittedExpression.arguments) + && (optionalChain || !ts.isOptionalChain(emittedExpression))) { return expression; } return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); @@ -18490,7 +18602,7 @@ var ts; } function createDecorator(expression) { var node = createBaseNode(165); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.transformFlags |= propagateChildFlags(node.expression) | 1 | @@ -19164,13 +19276,13 @@ var ts; } function createPropertyAccessExpression(expression, name) { var node = createBaseExpression(206); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.name = asName(name); node.transformFlags = propagateChildFlags(node.expression) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912); if (ts.isSuperKeyword(expression)) { node.transformFlags |= 256 | @@ -19190,7 +19302,7 @@ var ts; function createPropertyAccessChain(expression, questionDotToken, name) { var node = createBaseExpression(206); node.flags |= 32; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, true); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= @@ -19199,7 +19311,7 @@ var ts; propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912); return node; } function updatePropertyAccessChain(node, expression, questionDotToken, name) { @@ -19212,7 +19324,7 @@ var ts; } function createElementAccessExpression(expression, index) { var node = createBaseExpression(207); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | @@ -19236,7 +19348,7 @@ var ts; function createElementAccessChain(expression, questionDotToken, index) { var node = createBaseExpression(207); node.flags |= 32; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, true); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); node.transformFlags |= @@ -19256,7 +19368,7 @@ var ts; } function createCallExpression(expression, typeArguments, argumentsArray) { var node = createBaseExpression(208); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); node.transformFlags |= @@ -19287,7 +19399,7 @@ var ts; function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { var node = createBaseExpression(208); node.flags |= 32; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, true); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -19338,7 +19450,7 @@ var ts; } function createTaggedTemplateExpression(tag, typeArguments, template) { var node = createBaseExpression(210); - node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); + node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, false); node.typeArguments = asNodeArray(typeArguments); node.template = template; node.transformFlags |= @@ -19558,6 +19670,9 @@ var ts; else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { node.transformFlags |= 16; } + if (operatorKind === 101 && ts.isPrivateIdentifier(node.left)) { + node.transformFlags |= 536870912; + } return node; } function propagateAssignmentPatternFlags(node) { @@ -19724,7 +19839,7 @@ var ts; } function createExpressionWithTypeArguments(expression, typeArguments) { var node = createBaseNode(228); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | @@ -19756,7 +19871,7 @@ var ts; } function createNonNullExpression(expression) { var node = createBaseExpression(230); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); node.transformFlags |= propagateChildFlags(node.expression) | 1; @@ -19773,7 +19888,7 @@ var ts; function createNonNullChain(expression) { var node = createBaseExpression(230); node.flags |= 32; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, true); node.transformFlags |= propagateChildFlags(node.expression) | 1; @@ -21616,7 +21731,7 @@ var ts; } else if (ts.getEmitFlags(callee) & 4096) { thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, false); } else if (ts.isPropertyAccessExpression(callee)) { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { @@ -21642,7 +21757,7 @@ var ts; } else { thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, false); } return { target: target, thisArg: thisArg }; } @@ -21906,7 +22021,7 @@ var ts; case 328: return "augments"; case 329: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; @@ -21984,29 +22099,29 @@ var ts; case 208: case 209: case 204: - return 536903680; + return -2147450880; case 261: - return 742678528; + return -1941676032; case 164: - return 536870912; + return -2147483648; case 214: - return 612179968; + return -2072174592; case 213: case 256: - return 746414080; + return -1937940480; case 255: - return 537460736; + return -2146893824; case 257: case 226: - return 537010176; + return -2147344384; case 171: - return 746405888; + return -1937948672; case 167: - return 671105024; + return -2013249536; case 169: case 172: case 173: - return 679297024; + return -2005057536; case 130: case 147: case 158: @@ -22026,23 +22141,23 @@ var ts; case 259: return -2; case 205: - return 537075712; + return -2147278848; case 292: - return 536936448; + return -2147418112; case 201: case 202: - return 536903680; + return -2147450880; case 211: case 229: case 350: case 212: case 106: - return 536870912; + return -2147483648; case 206: case 207: - return 536870912; + return -2147483648; default: - return 536870912; + return -2147483648; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; @@ -22233,7 +22348,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -26089,7 +26204,7 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; @@ -26582,11 +26697,11 @@ var ts; } return parseElement(); } - function currentNode(parsingContext) { + function currentNode(parsingContext, pos) { if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) { return undefined; } - var node = syntaxCursor.currentNode(scanner.getStartPos()); + var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos()); if (ts.nodeIsMissing(node) || node.intersectsChange || ts.containsParseError(node)) { return undefined; } @@ -26784,7 +26899,9 @@ var ts; case 23: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); case 13: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); case 14: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - default: return [undefined]; + case 24: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); + case 25: return ts.Debug.fail("ParsingContext.Count used as a context"); + default: ts.Debug.assertNever(context); } } function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { @@ -27130,7 +27247,7 @@ var ts; if (allowAmbiguity === void 0) { allowAmbiguity = true; } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); + var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators); if (token() === 108) { var node_1 = factory.createParameterDeclaration(decorators, undefined, createIdentifier(true), undefined, parseTypeAnnotation(), undefined); if (decorators) { @@ -27306,10 +27423,10 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); if (parseContextualModifier(136)) { - return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 172); + return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 172, 4); } if (parseContextualModifier(149)) { - return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 173); + return parseAccessorDeclaration(pos, hasJSDoc, undefined, modifiers, 173, 4); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, undefined, modifiers); @@ -28392,6 +28509,9 @@ var ts; var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); + if (!isTemplateStartOfTaggedTemplate()) { + expression = factory.createExpressionWithTypeArguments(expression, typeArguments); + } } } if (token() === 20 || token() === 24 || token() === 22) { @@ -28671,6 +28791,11 @@ var ts; if (isOptionalChain && ts.isPrivateIdentifier(propertyAccess.name)) { parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers); } + if (ts.isExpressionWithTypeArguments(expression) && expression.typeArguments) { + var pos_2 = expression.typeArguments.pos - 1; + var end = ts.skipTrivia(sourceText, expression.typeArguments.end) + 1; + parseErrorAt(pos_2, end, ts.Diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access); + } return finishNode(propertyAccess, pos); } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { @@ -28895,10 +29020,10 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); if (parseContextualModifier(136)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172, 0); } if (parseContextualModifier(149)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173, 0); } var asteriskToken = parseOptionalToken(41); var tokenIsIdentifier = isIdentifier(); @@ -29439,18 +29564,16 @@ var ts; return modifier.kind === 135; } function parseDeclaration() { - var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier); - if (isAmbient) { - var node = tryReuseAmbientDeclaration(); - if (node) { - return node; - } - } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(); + var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { + var node = tryReuseAmbientDeclaration(pos); + if (node) { + return node; + } for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; m.flags |= 16777216; @@ -29461,9 +29584,9 @@ var ts; return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } - function tryReuseAmbientDeclaration() { + function tryReuseAmbientDeclaration(pos) { return doInsideOfContext(16777216, function () { - var node = currentNode(parsingContext); + var node = currentNode(parsingContext, pos); if (node) { return consumeNode(node); } @@ -29518,9 +29641,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 && canParseSemicolon()) { - parseSemicolon(); - return; + if (token() !== 18) { + if (flags & 4) { + parseTypeMemberSemicolon(); + return; + } + if (canParseSemicolon()) { + parseSemicolon(); + return; + } } return parseFunctionBlock(flags, diagnosticMessage); } @@ -29708,12 +29837,12 @@ var ts; } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); } - function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { + function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(0); var type = parseReturnType(58, false); - var body = parseFunctionBlockOrSemicolon(0); + var body = parseFunctionBlockOrSemicolon(flags); var node = kind === 172 ? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body) : factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body); @@ -29869,10 +29998,10 @@ var ts; return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } if (parseContextualModifier(136)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172, 0); } if (parseContextualModifier(149)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173); + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173, 0); } if (token() === 134 || token() === 10) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -31367,10 +31496,10 @@ var ts; } function checkNodePositions(node, aggressiveChecks) { if (aggressiveChecks) { - var pos_2 = node.pos; + var pos_3 = node.pos; var visitNode_1 = function (child) { - ts.Debug.assert(child.pos >= pos_2); - pos_2 = child.end; + ts.Debug.assert(child.pos >= pos_3); + pos_3 = child.end; }; if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -31379,7 +31508,7 @@ var ts; } } forEachChild(node, visitNode_1); - ts.Debug.assert(pos_2 <= node.end); + ts.Debug.assert(pos_3 <= node.end); } } function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { @@ -31683,7 +31812,7 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } @@ -33202,8 +33331,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } function parseCustomTypeOption(opt, value, errors) { return convertJsonOptionOfCustomType(opt, ts.trimString(value || ""), errors); @@ -33921,10 +34050,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -33962,19 +34091,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -33982,24 +34111,24 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -34356,7 +34485,7 @@ var ts; if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = extendedConfigPath + ".json"; + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -34552,7 +34681,7 @@ var ts; if (ts.fileExtensionIs(file, ".json")) { if (!jsonOnlyIncludeRegexes) { var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json"); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -34780,7 +34909,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -34929,7 +35058,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -35135,18 +35264,7 @@ var ts; NodeResolutionFeatures.None; } function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) { - var moduleResolutionState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ts.emptyArray, - features: NodeResolutionFeatures.None, - requestContainingDirectory: containingDirectory, - reportDiagnostic: ts.noop - }; + var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules"); @@ -35226,7 +35344,7 @@ var ts; ts.createCacheWithRedirects = createCacheWithRedirects; function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { var cache; - return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries }; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap }; function getPackageJsonInfo(packageJsonPath) { return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); } @@ -35240,6 +35358,9 @@ var ts; var iter = cache === null || cache === void 0 ? void 0 : cache.entries(); return iter ? ts.arrayFrom(iter) : []; } + function getInternalMap() { + return cache; + } } function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); @@ -35319,7 +35440,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -35338,21 +35459,24 @@ var ts; } ts.zipToModeAwareCache = zipToModeAwareCache; function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options)); var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); - moduleNameToDirectoryMap.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + } function update(options) { updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -35403,13 +35527,16 @@ var ts; } ts.createModuleResolutionCache = createModuleResolutionCache; function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + } } ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) { @@ -35480,10 +35607,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -35613,7 +35740,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -35746,7 +35873,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -35946,18 +36073,9 @@ var ts; var entrypoints; var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript; var features = getDefaultNodeResolutionFeatures(options); - var requireState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ["node", "require", "types"], - features: features, - requestContainingDirectory: packageJsonInfo.packageDirectory, - reportDiagnostic: ts.noop - }; + var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); + requireState.conditions = ["node", "require", "types"]; + requireState.requestContainingDirectory = packageJsonInfo.packageDirectory; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path); if (features & NodeResolutionFeatures.Exports && packageJsonInfo.packageJsonContent.exports) { @@ -36027,19 +36145,22 @@ var ts; } } } - function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) { - var state = { + function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) { + return { host: host, compilerOptions: options, traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], + failedLookupLocations: ts.noopPush, + affectingLocations: ts.noopPush, packageJsonInfoCache: packageJsonInfoCache, - features: 0, - conditions: [], + features: NodeResolutionFeatures.None, + conditions: ts.emptyArray, requestContainingDirectory: undefined, reportDiagnostic: ts.noop }; + } + ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState; + function getPackageScopeForPath(fileName, state) { var parts = ts.getPathComponents(fileName); parts.pop(); while (parts.length > 0) { @@ -36196,7 +36317,7 @@ var ts; var _a, _b; var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope || !scope.packageJsonContent.exports) { return undefined; } @@ -36209,7 +36330,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -36255,7 +36376,7 @@ var ts; } var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath); @@ -36296,6 +36417,7 @@ var ts; return 1; return 0; } + ts.comparePatternKeys = comparePatternKeys; function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) { var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports); if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) { @@ -36635,7 +36757,7 @@ var ts; return mangled; } function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; function mangleScopedPackageName(packageName) { @@ -36987,7 +37109,7 @@ var ts; if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } if (name.kind === 162) { var nameExpression = name.expression; @@ -37036,7 +37158,7 @@ var ts; case 317: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); case 164: - ts.Debug.assert(node.parent.kind === 317, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317, "Impossible parameter parent kind", function () { return "parent is: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind), ", expected JSDocFunctionType"); }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -37102,7 +37224,7 @@ var ts; } var relatedInformation_1 = []; if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1) && symbol.flags & (2097152 | 788968 | 1920)) { - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -38353,24 +38475,6 @@ var ts; typeLiteralSymbol.members.set(symbol.escapedName, symbol); } function bindObjectLiteralExpression(node) { - if (inStrictMode && !ts.isAssignmentTarget(node)) { - var seen = new ts.Map(); - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - if (prop.kind === 298 || prop.name.kind !== 79) { - continue; - } - var identifier = prop.name; - var currentKind = prop.kind === 296 || prop.kind === 297 || prop.kind === 169 - ? 1 - : 2; - var existingKind = seen.get(identifier.escapedText); - if (!existingKind) { - seen.set(identifier.escapedText, currentKind); - continue; - } - } - } return bindAnonymousDeclaration(node, 4096, "__object"); } function bindJsxAttributes(node) { @@ -38924,7 +39028,7 @@ var ts; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { @@ -39498,10 +39602,11 @@ var ts; } function isExportsOrModuleExportsOrAlias(sourceFile, node) { var i = 0; - var q = [node]; - while (q.length && i < 100) { + var q = ts.createQueue(); + q.enqueue(node); + while (!q.isEmpty() && i < 100) { i++; - node = q.shift(); + node = q.dequeue(); if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } @@ -39509,10 +39614,10 @@ var ts; var symbol = lookupSymbolForName(sourceFile, node.escapedText); if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) { var init = symbol.valueDeclaration.initializer; - q.push(init); + q.enqueue(init); if (ts.isAssignmentExpression(init, true)) { - q.push(init.left); - q.push(init.right); + q.enqueue(init.left); + q.enqueue(init.right); } } } @@ -39956,7 +40061,7 @@ var ts; }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); - return node ? getContextualTypeForObjectLiteralElement(node) : undefined; + return node ? getContextualTypeForObjectLiteralElement(node, undefined) : undefined; }, getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); @@ -39964,7 +40069,7 @@ var ts; }, getContextualTypeForJsxAttribute: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); - return node && getContextualTypeForJsxAttribute(node); + return node && getContextualTypeForJsxAttribute(node, undefined); }, isContextSensitive: isContextSensitive, getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, @@ -40164,6 +40269,7 @@ var ts; var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); var subtypeReductionCache = new ts.Map(); + var cachedTypes = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); @@ -40172,11 +40278,10 @@ var ts; var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); var anyType = createIntrinsicType(1, "any"); - var autoType = createIntrinsicType(1, "any"); + var autoType = createIntrinsicType(1, "any", 262144); var wildcardType = createIntrinsicType(1, "any"); var errorType = createIntrinsicType(1, "error"); var unresolvedType = createIntrinsicType(1, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1, "any", 65536); var intrinsicMarkerType = createIntrinsicType(1, "intrinsic"); var unknownType = createIntrinsicType(2, "unknown"); var nonNullUnknownType = createIntrinsicType(2, "unknown"); @@ -40205,8 +40310,7 @@ var ts; var esSymbolType = createIntrinsicType(4096, "symbol"); var voidType = createIntrinsicType(16384, "void"); var neverType = createIntrinsicType(131072, "never"); - var silentNeverType = createIntrinsicType(131072, "never"); - var nonInferrableType = createIntrinsicType(131072, "never", 262144); + var silentNeverType = createIntrinsicType(131072, "never", 262144); var implicitNeverType = createIntrinsicType(131072, "never"); var unreachableNeverType = createIntrinsicType(131072, "never"); var nonPrimitiveType = createIntrinsicType(67108864, "object"); @@ -40216,10 +40320,23 @@ var ts; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); var numericStringType = getTemplateLiteralType(["", ""], [numberType]); - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; }); + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; }, function () { return "(restrictive mapper)"; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; }, function () { return "(permissive mapper)"; }); var uniqueLiteralType = createIntrinsicType(131072, "never"); - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? uniqueLiteralType : t; }); + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? uniqueLiteralType : t; }, function () { return "(unique literal mapper)"; }); + var outofbandVarianceMarkerHandler; + var reportUnreliableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(true); + } + return t; + }, function () { return "(unmeasurable reporter)"; }); + var reportUnmeasurableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(false); + } + return t; + }, function () { return "(unreliable reporter)"; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); emptyJsxObjectType.objectFlags |= 2048; @@ -40238,6 +40355,9 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); + var markerSuperTypeForCheck = createTypeParameter(); + var markerSubTypeForCheck = createTypeParameter(); + markerSubTypeForCheck.constraint = markerSuperTypeForCheck; var noTypePredicate = createTypePredicate(1, "<>", 0, anyType); var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0); var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, 0); @@ -40365,7 +40485,6 @@ var ts; var typeofType = createTypeofType(); var _jsxNamespace; var _jsxFactoryEntity; - var outofbandVarianceMarkerHandler; var subtypeRelation = new ts.Map(); var strictSubtypeRelation = new ts.Map(); var assignableRelation = new ts.Map(); @@ -40387,6 +40506,14 @@ var ts; ]; initializeTypeChecker(); return checker; + function getCachedType(key) { + return key ? cachedTypes.get(key) : undefined; + } + function setCachedType(key, type) { + if (key) + cachedTypes.set(key, type); + return type; + } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -40653,7 +40780,7 @@ var ts; if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -41126,6 +41253,7 @@ var ts; var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { if (lookup(ctor.locals, name, meaning & 111551)) { + ts.Debug.assertNode(location, ts.isPropertyDeclaration); propertyWithInvalidInitializer = location; } } @@ -41271,11 +41399,21 @@ var ts; } } } + function checkAndReportErrorForInvalidInitializer() { + if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9)) { + error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos) + ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor + : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg)); + return true; + } + return false; + } if (!result) { if (nameNotFoundMessage) { addLazyDiagnostic(function () { if (!errorLocation || !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && + !checkAndReportErrorForInvalidInitializer() && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) && @@ -41283,7 +41421,14 @@ var ts; !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { var suggestion = void 0; - if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { + var suggestedLib = void 0; + if (nameArg) { + suggestedLib = getSuggestedLibForNonExistentName(nameArg); + if (suggestedLib) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib); + } + } + if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); if (isGlobalScopeAugmentationDeclaration) { @@ -41302,16 +41447,8 @@ var ts; } } } - if (!suggestion) { - if (nameArg) { - var lib = getSuggestedLibForNonExistentName(nameArg); - if (lib) { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib); - } - else { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); - } - } + if (!suggestion && !suggestedLib && nameArg) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); } suggestionCount++; } @@ -41319,9 +41456,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 && useDefineForClassFields)) { - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg)); + else if (checkAndReportErrorForInvalidInitializer()) { return undefined; } if (nameNotFoundMessage) { @@ -41989,10 +42124,6 @@ var ts; checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } - function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { - var expression = node.initializer; - return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); - } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63)) { return undefined; @@ -42024,7 +42155,7 @@ var ts; case 297: return resolveEntityName(node.name, 111551 | 788968 | 1920, true, dontRecursivelyResolve); case 296: - return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve); case 207: case 206: return getTargetOfAccessExpression(node, dontRecursivelyResolve); @@ -42362,7 +42493,34 @@ var ts; var overrideClauseHost = ts.findAncestor(location, function (l) { return ts.isImportTypeNode(l) || ts.isExportDeclaration(l) || ts.isImportDeclaration(l); }); var overrideClause = overrideClauseHost && ts.isImportTypeNode(overrideClauseHost) ? (_g = overrideClauseHost.assertions) === null || _g === void 0 ? void 0 : _g.assertClause : overrideClauseHost === null || overrideClauseHost === void 0 ? void 0 : overrideClauseHost.assertClause; if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { - error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); + if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) { + error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference); + } + else { + var diagnosticDetails = void 0; + var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName); + if (ext === ".ts" || ext === ".js" || ext === ".tsx" || ext === ".jsx") { + var scope = currentSourceFile.packageJsonScope; + var targetExt = ext === ".ts" ? ".mts" : ext === ".js" ? ".mjs" : undefined; + if (scope && !scope.packageJsonContent.type) { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, targetExt, ts.combinePaths(scope.packageDirectory, "package.json")); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0, ts.combinePaths(scope.packageDirectory, "package.json")); + } + } + else { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, targetExt); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module); + } + } + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, ts.chainDiagnosticMessages(diagnosticDetails, ts.Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference))); + } } } return getMergedSymbol(sourceFile.symbol); @@ -42972,7 +43130,7 @@ var ts; var links = getSymbolLinks(symbol); var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -43195,13 +43353,25 @@ var ts; && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) - && ts.isVariableDeclaration(declaration.parent.parent) - && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1) - && declaration.parent.parent.parent.parent.parent - && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { - return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + else if (ts.isBindingElement(declaration)) { + if (symbol.flags & 2097152 && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) + && ts.isVariableDeclaration(declaration.parent.parent) + && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1) + && declaration.parent.parent.parent.parent.parent + && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + } + else if (symbol.flags & 2) { + var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement); + if (ts.hasSyntacticModifier(variableStatement, 1)) { + return true; + } + if (!isDeclarationVisible(variableStatement.parent)) { + return false; + } + return addVisibleAlias(declaration, variableStatement); + } } return false; } @@ -43321,7 +43491,7 @@ var ts; } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0; } - return flags & 814775659; + return flags & 848330091; } function isClassInstanceSide(type) { return !!type.symbol && !!(type.symbol.flags & 32) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288) && !!(ts.getObjectFlags(type) & 16777216))); @@ -43422,6 +43592,12 @@ var ts; return context.truncating = context.approximateLength > ((context.flags & 1) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { + var savedFlags = context.flags; + var typeNode = typeToTypeNodeWorker(type, context); + context.flags = savedFlags; + return typeNode; + } + function typeToTypeNodeWorker(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } @@ -43595,8 +43771,8 @@ var ts; if (type.symbol) { return symbolToTypeNode(type.symbol, context, 788968); } - var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? - (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; + var name = (type === markerSuperTypeForCheck || type === markerSubTypeForCheck) && varianceTypeParameter && varianceTypeParameter.symbol ? + (type === markerSubTypeForCheck ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), undefined); } if (type.flags & 1048576 && type.origin) { @@ -43661,7 +43837,7 @@ var ts; var name = typeParameterToName(newParam, context); var newTypeVariable = ts.factory.createTypeReferenceNode(name); context.approximateLength += 37; - var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.mapper); var saveInferTypeParameters_1 = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); @@ -43692,6 +43868,10 @@ var ts; } return typeToTypeNodeHelper(type, context); } + function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) { + return isMappedTypeWithKeyofConstraintDeclaration(type) + && !(getModifiersTypeFromMappedType(type).flags & 262144); + } function createMappedTypeNodeFromType(type) { ts.Debug.assert(!!(type.flags & 524288)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; @@ -43699,7 +43879,7 @@ var ts; var appropriateConstraintTypeNode; var newTypeVariable; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { - if (!(getModifiersTypeFromMappedType(type).flags & 262144) && context.flags & 4) { + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4) { var newParam = createTypeParameter(createSymbol(262144, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); @@ -43715,8 +43895,9 @@ var ts; var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, undefined); context.approximateLength += 10; var result = ts.setEmitFlags(mappedTypeNode, 1); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144) && context.flags & 4) { - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143)); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4) { + var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(undefined, ts.factory.cloneNode(newTypeVariable.typeName), originalConstraint.flags & 2 ? undefined : typeToTypeNodeHelper(originalConstraint, context))), result, ts.factory.createKeywordTypeNode(143)); } return result; } @@ -43782,7 +43963,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -44043,7 +44224,7 @@ var ts; } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(undefined, "... " + (properties.length - i) + " more ...", undefined, undefined)); + typeElements.push(ts.factory.createPropertySignature(undefined, "... ".concat(properties.length - i, " more ..."), undefined, undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -44151,7 +44332,7 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } @@ -44164,7 +44345,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -44234,7 +44415,7 @@ var ts; } var expandedParams = getExpandedParameters(signature, true)[0]; var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); - var thisParameter = tryGetThisParameterDeclaration(signature, context); + var thisParameter = context.flags & 33554432 ? undefined : tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); } @@ -44526,7 +44707,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -44693,7 +44874,7 @@ var ts; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -44985,7 +45166,7 @@ var ts; function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -45187,12 +45368,11 @@ var ts; if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { var oldContext = context; context = cloneNodeBuilderContext(context); - var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); if (context.reportedDiagnostic) { oldcontext.reportedDiagnostic = context.reportedDiagnostic; } context = oldContext; - return result; } } function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { @@ -45798,7 +45978,7 @@ var ts; } return results_1; } - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -45868,7 +46048,7 @@ var ts; if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, undefined, typeToTypeNodeHelper(staticType, context)) ], 2)); @@ -45913,7 +46093,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -46019,15 +46199,15 @@ var ts; if (nameType.flags & 384) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34) + "\""; + return "\"".concat(ts.escapeString(name, 34), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } if (nameType.flags & 8192) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -46813,7 +46993,7 @@ var ts; (resolvedSymbol || symbol).exports.forEach(function (s, name) { var _a; var exportedMember = members_4.get(name); - if (exportedMember && exportedMember !== s) { + if (exportedMember && exportedMember !== s && !(s.flags & 2097152)) { if (s.flags & 111551 && exportedMember.flags & 111551) { if (s.valueDeclaration && exportedMember.valueDeclaration && ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName); @@ -46890,7 +47070,7 @@ var ts; if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAny(element, anyType); } - return includePatternInType ? nonInferrableAnyType : anyType; + return anyType; } function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); @@ -47777,7 +47957,7 @@ var ts; error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } } links.declaredType = type; @@ -48455,7 +48635,7 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } @@ -48901,6 +49081,9 @@ var ts; else if (type.objectFlags & 32) { resolveMappedTypeMembers(type); } + else { + ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags)); + } } else if (type.flags & 1048576) { resolveUnionTypeMembers(type); @@ -48908,6 +49091,9 @@ var ts; else if (type.flags & 2097152) { resolveIntersectionTypeMembers(type); } + else { + ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags)); + } } return type; } @@ -49082,7 +49268,7 @@ var ts; } } } - return getIntersectionType(constraints); + return getNormalizedType(getIntersectionType(constraints), false); } return undefined; } @@ -49577,12 +49763,15 @@ var ts; return getApplicableIndexInfo(type, isLateBoundName(name) ? esSymbolType : getStringLiteralType(ts.unescapeLeadingUnderscores(name))); } function getTypeParametersFromDeclaration(declaration) { + var _a; var result; - for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) { - var node = _a[_i]; + for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) { + var node = _b[_i]; result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol)); } - return result; + return (result === null || result === void 0 ? void 0 : result.length) ? result + : ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters + : undefined; } function symbolsToArray(symbols) { var result = []; @@ -50085,19 +50274,20 @@ var ts; var _a; var inferences; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { - for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { - var declaration = _b[_i]; + var _loop_15 = function (declaration) { if (declaration.parent.kind === 190) { var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; if (grandParent.kind === 178 && !omitTypeReferences) { - var typeReference = grandParent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(childTypeParameter); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + var typeReference_1 = grandParent; + var typeParameters_1 = getTypeParametersForTypeReference(typeReference_1); + if (typeParameters_1) { + var index = typeReference_1.typeArguments.indexOf(childTypeParameter); + if (index < typeParameters_1.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters_1[index]); if (declaredConstraint) { - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var mapper = makeDeferredTypeMapper(typeParameters_1, typeParameters_1.map(function (_, index) { return function () { + return getEffectiveTypeArgumentAtIndex(typeReference_1, typeParameters_1, index); + }; })); var constraint = instantiateType(declaredConstraint, mapper); if (constraint !== typeParameter) { inferences = ts.append(inferences, constraint); @@ -50126,6 +50316,10 @@ var ts; inferences = ts.append(inferences, instantiateType(nodeType, makeUnaryTypeMapper(getDeclaredTypeOfTypeParameter(getSymbolOfNode(checkMappedType_1.typeParameter)), checkMappedType_1.typeParameter.constraint ? getTypeFromTypeNode(checkMappedType_1.typeParameter.constraint) : keyofConstraintType))); } } + }; + for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + _loop_15(declaration); } } return inferences && getIntersectionType(inferences); @@ -50181,13 +50375,13 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - if (!(type.flags & excludeKinds)) { + if (excludeKinds === undefined || !(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } } @@ -50199,7 +50393,7 @@ var ts; if (!type) { type = createObjectType(4, target.symbol); target.instantiations.set(id, type); - type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; + type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0; type.target = target; type.resolvedTypeArguments = typeArguments; } @@ -50344,7 +50538,7 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { var identifier = name.kind === 161 ? name.right : @@ -50355,7 +50549,7 @@ var ts; var parentSymbol = name.kind === 161 ? getUnresolvedSymbolForEntityName(name.left) : name.kind === 206 ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { unresolvedSymbols.set(path, result = createSymbol(524288, text, 1048576)); @@ -50421,7 +50615,7 @@ var ts; if (substitute.flags & 3 || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; @@ -50933,7 +51127,7 @@ var ts; var lastRequiredIndex = -1; var firstRestIndex = -1; var lastOptionalOrRestIndex = -1; - var _loop_15 = function (i) { + var _loop_16 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; if (flags & 8) { @@ -50959,7 +51153,7 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - var state_4 = _loop_15(i); + var state_4 = _loop_16(i); if (typeof state_4 === "object") return state_4.value; } @@ -51136,7 +51330,7 @@ var ts; var templates = ts.filter(types, isPatternLiteralType); if (templates.length) { var i = types.length; - var _loop_16 = function () { + var _loop_17 = function () { i--; var t = types[i]; if (t.flags & 128 && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { @@ -51144,7 +51338,7 @@ var ts; } }; while (i > 0) { - _loop_16(); + _loop_17(); } } } @@ -51214,14 +51408,14 @@ var ts; var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; - var _loop_17 = function (t) { + var _loop_18 = function (t) { if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) { reducedTypes.push(t); } }; for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) { var t = typeSet_1[_i]; - _loop_17(t); + _loop_18(t); } if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) { return namedUnions[0]; @@ -51280,9 +51474,9 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); + origin.flags & 1048576 ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { @@ -51671,19 +51865,22 @@ var ts; return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1, undefined, undefined, origin); } function isPossiblyReducibleByInstantiation(type) { - return ts.some(type.types, function (t) { - var uniqueFilled = getUniqueLiteralFilledInstantiation(t); - return getReducedType(uniqueFilled) !== uniqueFilled; - }); + var uniqueFilled = getUniqueLiteralFilledInstantiation(type); + return getReducedType(uniqueFilled) !== uniqueFilled; + } + function shouldDeferIndexType(type) { + return !!(type.flags & 58982400 || + isGenericTupleType(type) || + isGenericMappedType(type) && !hasDistributiveNameType(type) || + type.flags & 1048576 && ts.some(type.types, isPossiblyReducibleByInstantiation) || + type.flags & 2097152 && maybeTypeOfKind(type, 465829888) && ts.some(type.types, isEmptyAnonymousObjectType)); } function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 ? isPossiblyReducibleByInstantiation(type) - ? getIndexTypeForGenericType(type, stringsOnly) - : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 1048576 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : ts.getObjectFlags(type) & 32 ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : type.flags & 2 ? neverType : @@ -51752,7 +51949,7 @@ var ts; if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -51834,7 +52031,7 @@ var ts; return [texts, types]; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -51924,21 +52121,28 @@ var ts; getFlowTypeOfReference(accessExpression, propType) : propType; } - if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { + if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) { + var index = +propName; if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { + if (index < 0) { + error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value); + return undefinedType; + } error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); } else { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } } - errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); - return mapType(objectType, function (t) { - var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 ? getUnionType([restType, undefinedType]) : restType; - }); + if (index >= 0) { + errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); + return mapType(objectType, function (t) { + var restType = getRestTypeOfTupleType(t) || undefinedType; + return accessFlags & 1 ? getUnionType([restType, undefinedType]) : restType; + }); + } } } if (!(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 402653316 | 296 | 12288)) { @@ -52297,7 +52501,7 @@ var ts; var result; var extraTypes; var tailCount = 0; - var _loop_18 = function () { + var _loop_19 = function () { if (tailCount === 1000) { error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); result = errorType; @@ -52371,7 +52575,7 @@ var ts; return "break"; }; while (true) { - var state_5 = _loop_18(); + var state_5 = _loop_19(); if (typeof state_5 === "object") return state_5.value; if (state_5 === "break") @@ -52468,6 +52672,7 @@ var ts; } } function getTypeFromImportTypeNode(node) { + var _a; var links = getNodeLinks(node); if (!links.resolvedType) { if (node.isTypeOf && node.typeArguments) { @@ -52486,6 +52691,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } + var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=")); var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, false); if (!ts.nodeIsMissing(node.qualifier)) { var nameStack = getIdentifierChain(node.qualifier); @@ -52494,9 +52700,11 @@ var ts; while (current = nameStack.shift()) { var meaning = nameStack.length ? 1920 : targetMeaning; var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace)); - var next = node.isTypeOf + var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, false, true) - : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + : undefined; + var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable; if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); return links.resolvedType = errorType; @@ -52772,7 +52980,7 @@ var ts; function createUniqueESSymbolType(symbol) { var type = createType(8192); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -52972,7 +53180,7 @@ var ts; switch (mapper.kind) { case 0: return type === mapper.source ? mapper.target : type; - case 1: + case 1: { var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -52981,43 +53189,58 @@ var ts; } } return type; - case 2: - return mapper.func(type); + } + case 2: { + var sources = mapper.sources; + var targets = mapper.targets; + for (var i = 0; i < sources.length; i++) { + if (type === sources[i]) { + return targets[i](); + } + } + return type; + } case 3: + return mapper.func(type); case 4: + case 5: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 4 ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0, source: source, target: target }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 0, source: source, target: target }); } function makeArrayTypeMapper(sources, targets) { - return { kind: 1, sources: sources, targets: targets }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 1, sources: sources, targets: targets }); + } + function makeFunctionTypeMapper(func, debugInfo) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 3, func: func, debugInfo: ts.Debug.isDebugging ? debugInfo : undefined }); } - function makeFunctionTypeMapper(func) { - return { kind: 2, func: func }; + function makeDeferredTypeMapper(sources, targets) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 2, sources: sources, targets: targets }); } function makeCompositeTypeMapper(kind, mapper1, mapper2) { - return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: kind, mapper1: mapper1, mapper2: mapper2 }); } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } function createBackreferenceMapper(context, index) { - return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); + var forwardInferences = context.inferences.slice(index); + return createTypeMapper(ts.map(forwardInferences, function (i) { return i.typeParameter; }), ts.map(forwardInferences, function () { return unknownType; })); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(5, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -53241,6 +53464,7 @@ var ts; result.mapper = mapper; result.aliasSymbol = aliasSymbol || type.aliasSymbol; result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0; return result; } function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { @@ -53828,7 +54052,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068) + if (target.flags & (131068 | 131072)) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -53893,7 +54117,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068) + if (target.flags & (131068 | 131072)) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -54328,20 +54552,20 @@ var ts; switch (msg.code) { case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; if (path.length === 0) { - path = "" + str; + path = "".concat(str); } else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -54368,7 +54592,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -54381,7 +54605,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -54431,7 +54655,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 && target !== markerSuperTypeForCheck && target !== markerSubTypeForCheck) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -54697,7 +54921,7 @@ var ts; reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); checkTypes = reducedTarget.flags & 1048576 ? reducedTarget.types : [reducedTarget]; } - var _loop_19 = function (prop) { + var _loop_20 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { @@ -54750,7 +54974,7 @@ var ts; }; for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { var prop = _b[_i]; - var state_6 = _loop_19(prop); + var state_6 = _loop_20(prop); if (typeof state_6 === "object") return state_6.value; } @@ -54938,10 +55162,10 @@ var ts; if (outofbandVarianceMarkerHandler) { var saved = entry & 24; if (saved & 8) { - instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); + instantiateType(source, reportUnmeasurableMapper); } if (saved & 16) { - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + instantiateType(source, reportUnreliableMapper); } } return entry & 1 ? -1 : 0; @@ -55033,13 +55257,26 @@ var ts; return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { + var saveErrorInfo = captureErrorCalculationState(); + var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo); + if (!result && (source.flags & 2097152 || source.flags & 262144 && target.flags & 1048576)) { + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576)); + if (constraint && everyType(constraint, function (c) { return c !== source; })) { + result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState); + } + } + if (result) { + resetErrorInfo(saveErrorInfo); + } + return result; + } + function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) { if (intersectionState & 4) { return propertiesRelatedTo(source, target, reportErrors, undefined, 0); } var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = captureErrorCalculationState(); var sourceFlags = source.flags; var targetFlags = target.flags; if (relation === identityRelation) { @@ -55084,15 +55321,6 @@ var ts; if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 || source.flags & 262144 && target.flags & 1048576) { - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576)); - if (constraint && everyType(constraint, function (c) { return c !== source; })) { - if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); - return result; - } - } - } if (!(sourceFlags & 465829888 || sourceFlags & 524288 && targetFlags & 1048576 || sourceFlags & 2097152 && targetFlags & (524288 | 1048576 | 465829888))) { @@ -55181,7 +55409,6 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, 3, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } if (reportErrors) { @@ -55257,7 +55484,6 @@ var ts; } else if (targetFlags & 16777216) { if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { - resetErrorInfo(saveErrorInfo); return 3; } var c = target; @@ -55267,7 +55493,6 @@ var ts; if (result = skipTrue ? -1 : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2, false)) { result &= skipFalse ? -1 : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2, false); if (result) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -55278,7 +55503,7 @@ var ts; if (relation === comparableRelation) { return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 : -1; } - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + instantiateType(source, reportUnreliableMapper); } if (isTypeMatchedByTemplateLiteralType(source, target)) { return -1; @@ -55295,18 +55520,15 @@ var ts; if (!(sourceFlags & 8388608 && targetFlags & 8388608)) { var constraint = getConstraintOfType(source) || unknownType; if (result = isRelatedTo(constraint, target, 1, false, undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); return result; } else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144), undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); return result; } if (isMappedTypeGenericIndexedAccess(source)) { var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -55315,7 +55537,6 @@ var ts; } else if (sourceFlags & 4194304) { if (result = isRelatedTo(keyofConstraintType, target, 1, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -55323,7 +55544,6 @@ var ts; if (!(targetFlags & 134217728)) { var constraint = getBaseConstraintOfType(source); if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1, reportErrors))) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -55334,21 +55554,18 @@ var ts; return 0; } if (result = isRelatedTo(source.type, target.type, 3, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } else { var constraint = getBaseConstraintOfType(source); if (constraint && (result = isRelatedTo(constraint, target, 1, reportErrors))) { - resetErrorInfo(saveErrorInfo); return result; } } } else if (sourceFlags & 16777216) { if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { - resetErrorInfo(saveErrorInfo); return 3; } if (targetFlags & 16777216) { @@ -55367,7 +55584,6 @@ var ts; result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -55376,7 +55592,6 @@ var ts; var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, 1, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -55384,7 +55599,6 @@ var ts; var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, 1, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -55396,7 +55610,6 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -55490,25 +55703,13 @@ var ts; } } } - function reportUnmeasurableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(false); - } - return p; - } - function reportUnreliableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(true); - } - return p; - } function mappedTypeRelatedTo(source, target, reportErrors) { var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); - var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); + var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMapper : reportUnreliableMapper); if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { @@ -55544,11 +55745,11 @@ var ts; } var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_20 = function (combination) { + var _loop_21 = function (combination) { var hasMatch = false; outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) { var type = _d[_c]; - var _loop_21 = function (i) { + var _loop_22 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfType(type, sourceProperty.escapedName); if (!targetProperty) @@ -55561,7 +55762,7 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_8 = _loop_21(i); + var state_8 = _loop_22(i); switch (state_8) { case "continue-outer": continue outer; } @@ -55575,7 +55776,7 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_7 = _loop_20(combination); + var state_7 = _loop_21(combination); if (typeof state_7 === "object") return state_7.value; } @@ -55981,7 +56182,7 @@ var ts; return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; } function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, reportUnreliableMapper); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -56219,7 +56420,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; - var _loop_22 = function (tp) { + var _loop_23 = function (tp) { var modifiers = getVarianceModifiers(tp); var variance = modifiers & 65536 ? modifiers & 32768 ? 0 : 1 : @@ -56248,12 +56449,12 @@ var ts; } variances.push(variance); }; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - _loop_22(tp); + for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { + var tp = typeParameters_2[_i]; + _loop_23(tp); } links.variances = variances; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) }); } return links.variances; } @@ -56299,7 +56500,7 @@ var ts; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); function getTypeReferenceId(type, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; @@ -56335,7 +56536,7 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } function forEachProperty(prop, callback) { if (ts.getCheckFlags(prop) & 6) { @@ -56529,34 +56730,28 @@ var ts; var commonBaseType; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - var baseType = getBaseTypeOfLiteralType(t); - if (!commonBaseType) { - commonBaseType = baseType; - } - if (baseType === t || baseType !== commonBaseType) { - return false; + if (!(t.flags & 131072)) { + var baseType = getBaseTypeOfLiteralType(t); + commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType); + if (baseType === t || baseType !== commonBaseType) { + return false; + } } } return true; } - function getSupertypeOrUnion(types) { - if (types.length === 1) { - return types[0]; - } - return literalTypesWithSameBaseType(types) ? - getUnionType(types) : - ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + function getCombinedTypeFlags(types) { + return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 ? getCombinedTypeFlags(t.types) : t.flags); }, 0); } function getCommonSupertype(types) { - if (!strictNullChecks) { - return getSupertypeOrUnion(types); - } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304); }); - if (primaryTypes.length) { - var supertypeOrUnion = getSupertypeOrUnion(primaryTypes); - return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304); }), true)); + if (types.length === 1) { + return types[0]; } - return getUnionType(types, 2); + var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304); }); }) : types; + var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? + getUnionType(primaryTypes) : + ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304); } function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); @@ -56655,9 +56850,14 @@ var ts; type.flags & 256 ? numberType : type.flags & 2048 ? bigintType : type.flags & 512 ? booleanType : - type.flags & 1048576 ? mapType(type, getBaseTypeOfLiteralType) : + type.flags & 1048576 ? getBaseTypeOfLiteralTypeUnion(type) : type; } + function getBaseTypeOfLiteralTypeUnion(type) { + var _a; + var key = "B".concat(getTypeId(type)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType)); + } function getWidenedLiteralType(type) { return type.flags & 1024 && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : type.flags & 128 && isFreshLiteralType(type) ? stringType : @@ -57118,25 +57318,27 @@ var ts; signature: signature, flags: flags, compareTypes: compareTypes, - mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, true); }), - nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, false); }), + mapper: reportUnmeasurableMapper, + nonFixingMapper: reportUnmeasurableMapper, }; + context.mapper = makeFixingMapperForContext(context); + context.nonFixingMapper = makeNonFixingMapperForContext(context); return context; } - function mapToInferredType(context, t, fix) { - var inferences = context.inferences; - for (var i = 0; i < inferences.length; i++) { - var inference = inferences[i]; - if (t === inference.typeParameter) { - if (fix && !inference.isFixed) { - inferFromIntraExpressionSites(context); - clearCachedInferences(inferences); - inference.isFixed = true; - } - return getInferredType(context, i); + function makeFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (inference, i) { return function () { + if (!inference.isFixed) { + inferFromIntraExpressionSites(context); + clearCachedInferences(context.inferences); + inference.isFixed = true; } - } - return t; + return getInferredType(context, i); + }; })); + } + function makeNonFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (_, i) { return function () { + return getInferredType(context, i); + }; })); } function clearCachedInferences(inferences) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { @@ -57376,7 +57578,7 @@ var ts; } function parseBigIntLiteralType(text) { var negative = text.startsWith("-"); - var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n"); + var base10Value = ts.parsePseudoBigInt("".concat(negative ? text.slice(1) : text, "n")); return getBigIntLiteralType({ negative: negative, base10Value: base10Value }); } function isValidBigIntString(s, roundTripOnly) { @@ -57523,8 +57725,10 @@ var ts; propagationType = savePropagationType; return; } - if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) { + if (source.aliasTypeArguments) { + inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + } return; } if (source === target && source.flags & 3145728) { @@ -57561,7 +57765,7 @@ var ts; target = getActualTypeVariable(target); } if (target.flags & 8650752) { - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); @@ -57616,15 +57820,11 @@ var ts; inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 && target.flags & 4194304) { - contravariant = !contravariant; - inferFromTypes(source.type, target.type); - contravariant = !contravariant; + inferFromContravariantTypes(source.type, target.type); } else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) { var empty = createEmptyObjectTypeFromStringLiteral(source); - contravariant = !contravariant; - inferWithPriority(empty, target.type, 256); - contravariant = !contravariant; + inferFromContravariantTypesWithPriority(empty, target.type, 256); } else if (source.flags & 8388608 && target.flags & 8388608) { inferFromTypes(source.objectType, target.objectType); @@ -57637,10 +57837,7 @@ var ts; } else if (source.flags & 33554432) { inferFromTypes(source.baseType, target); - var oldPriority = priority; - priority |= 4; - inferFromTypes(source.substitute, target); - priority = oldPriority; + inferWithPriority(source.substitute, target, 4); } else if (target.flags & 16777216) { invokeOnce(source, target, inferToConditionalType); @@ -57679,6 +57876,18 @@ var ts; inferFromTypes(source, target); priority = savePriority; } + function inferFromContravariantTypesWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromContravariantTypes(source, target); + priority = savePriority; + } + function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferToMultipleTypes(source, targets, targetFlags); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -57741,10 +57950,13 @@ var ts; } } function inferFromContravariantTypes(source, target) { + contravariant = !contravariant; + inferFromTypes(source, target); + contravariant = !contravariant; + } + function inferFromContravariantTypesIfStrictFunctionTypes(source, target) { if (strictFunctionTypes || priority & 1024) { - contravariant = !contravariant; - inferFromTypes(source, target); - contravariant = !contravariant; + inferFromContravariantTypes(source, target); } else { inferFromTypes(source, target); @@ -57875,18 +58087,15 @@ var ts; inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } else { - var savePriority = priority; - priority |= contravariant ? 64 : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; - inferToMultipleTypes(source, targetTypes, target.flags); - priority = savePriority; + inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 : 0); } } function inferToTemplateLiteralType(source, target) { var matches = inferTypesFromTemplateLiteralType(source, target); var types = target.types; if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) { - var _loop_23 = function (i) { + var _loop_24 = function (i) { var source_1 = matches ? matches[i] : neverType; var target_3 = types[i]; if (source_1.flags & 128 && target_3.flags & 8650752) { @@ -57930,7 +58139,7 @@ var ts; inferFromTypes(source_1, target_3); }; for (var i = 0; i < types.length; i++) { - _loop_23(i); + _loop_24(i); } } } @@ -58030,19 +58239,16 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144); for (var i = 0; i < len; i++) { - inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); + inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); } } - function inferFromSignature(source, target, skipParameters) { - if (!skipParameters) { - var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0; - bivariant = bivariant || kind === 169 || kind === 168 || kind === 171; - applyToParameterTypes(source, target, inferFromContravariantTypes); - bivariant = saveBivariant; - } + function inferFromSignature(source, target) { + var saveBivariant = bivariant; + var kind = target.declaration ? target.declaration.kind : 0; + bivariant = bivariant || kind === 169 || kind === 168 || kind === 171; + applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes); + bivariant = saveBivariant; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { @@ -58243,10 +58449,10 @@ var ts; case 79: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } case 108: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); case 230: case 212: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -58260,6 +58466,14 @@ var ts; var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); return key && key + "." + propName; } + break; + case 201: + case 202: + case 256: + case 213: + case 214: + case 169: + return "".concat(getNodeId(node), "#").concat(getTypeId(declaredType)); } return undefined; } @@ -58400,7 +58614,7 @@ var ts; function mapTypesByKeyProperty(types, name) { var map = new ts.Map(); var count = 0; - var _loop_24 = function (type) { + var _loop_25 = function (type) { if (type.flags & (524288 | 2097152 | 58982400)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { @@ -58426,7 +58640,7 @@ var ts; }; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var type = types_15[_i]; - var state_9 = _loop_24(type); + var state_9 = _loop_25(type); if (typeof state_9 === "object") return state_9.value; } @@ -58505,19 +58719,20 @@ var ts; return false; } function getAssignmentReducedType(declaredType, assignedType) { - if (declaredType !== assignedType) { - if (assignedType.flags & 131072) { - return assignedType; - } - var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 && isFreshLiteralType(assignedType)) { - reducedType = mapType(reducedType, getFreshTypeOfLiteralType); - } - if (isTypeAssignableTo(assignedType, reducedType)) { - return reducedType; - } + var _a; + if (declaredType === assignedType) { + return declaredType; } - return declaredType; + if (assignedType.flags & 131072) { + return assignedType; + } + var key = "A".concat(getTypeId(declaredType), ",").concat(getTypeId(assignedType)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType)); + } + function getAssignmentReducedTypeWorker(declaredType, assignedType) { + var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); + var reducedType = assignedType.flags & 512 && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType; + return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType; } function isFunctionObjectType(type) { var resolved = resolveStructuredTypeMembers(type); @@ -59359,7 +59574,7 @@ var ts; return declaredType; } if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 && isMatchingReference(reference, node.parent.parent.expression)) { - return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)))); } return undefined; } @@ -59786,7 +60001,7 @@ var ts; var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, true); } function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { var equalsOperator = operator === 34 || operator === 36; @@ -59995,22 +60210,37 @@ var ts; if (!nonConstructorTypeInUnion) return type; } - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, true); + } + function getNarrowedType(type, candidate, assumeTrue, checkDerived) { + var _a; + var key = type.flags & 1048576 ? "N".concat(getTypeId(type), ",").concat(getTypeId(candidate), ",").concat((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined; + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived)); } - function getNarrowedType(type, candidate, assumeTrue, isRelated) { + function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) { + var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf; if (!assumeTrue) { return filterType(type, function (t) { return !isRelated(t, candidate); }); } - if (type.flags & 1048576) { - var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072)) { - return assignableType; - } + if (type.flags & 3) { + return candidate; } - return isTypeSubtypeOf(candidate, type) ? candidate : - isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, type) ? candidate : - getIntersectionType([type, candidate]); + var keyPropertyName = type.flags & 1048576 ? getKeyPropertyName(type) : undefined; + var narrowedType = mapType(candidate, function (c) { + var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName); + var matching = discriminant && getConstituentTypeForKeyType(type, discriminant); + var directlyRelated = mapType(matching || type, checkDerived ? + function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } : + function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; }); + return directlyRelated.flags & 131072 ? + mapType(type, function (t) { return maybeTypeOfKind(t, 465829888) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType; }) : + directlyRelated; + }); + return !(narrowedType.flags & 131072) ? narrowedType : + isTypeSubtypeOf(candidate, type) ? candidate : + isTypeAssignableTo(type, candidate) ? type : + isTypeAssignableTo(candidate, type) ? candidate : + getIntersectionType([type, candidate]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { @@ -60037,7 +60267,7 @@ var ts; var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + return getNarrowedType(type, predicate.type, assumeTrue, false); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(getTypeFacts(predicate.type) & 65536)) { @@ -60045,7 +60275,7 @@ var ts; } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, false); }); } } } @@ -60198,7 +60428,7 @@ var ts; !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && (checkMode && checkMode & 64 ? getContextualType(node, 8) - : getContextualType(node)); + : getContextualType(node, undefined)); return contextualType && !isGenericType(contextualType); } function getNarrowableTypeForReference(type, reference, checkMode) { @@ -60301,7 +60531,7 @@ var ts; getNodeLinks(container).flags |= 8192; return getTypeOfSymbol(symbol); } - if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) { + if (shouldMarkIdentifierAliasReferenced(node)) { markAliasReferenced(symbol, node); } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); @@ -60414,6 +60644,23 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function shouldMarkIdentifierAliasReferenced(node) { + var _a; + var parent = node.parent; + if (parent) { + if (ts.isPropertyAccessExpression(parent) && parent.expression === node) { + return false; + } + if (ts.isExportSpecifier(parent) && parent.isTypeOnly) { + return false; + } + var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent; + if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) { + return false; + } + } + return true; + } function isInsideFunctionOrInstancePropertyInitializer(node, threshold) { return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); }); } @@ -60838,7 +61085,7 @@ var ts; if (noImplicitThis || inJs) { var containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { - var contextualType = getApparentTypeOfContextualType(containingLiteral); + var contextualType = getApparentTypeOfContextualType(containingLiteral, undefined); var literal = containingLiteral; var type = contextualType; while (type) { @@ -60850,7 +61097,7 @@ var ts; break; } literal = literal.parent.parent; - type = getApparentTypeOfContextualType(literal); + type = getApparentTypeOfContextualType(literal, undefined); } return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral)); } @@ -60900,7 +61147,7 @@ var ts; tryGetTypeAtPosition(contextualSignature, index); } } - function getContextualTypeForVariableLikeDeclaration(declaration) { + function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) { var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); if (typeNode) { return getTypeFromTypeNode(typeNode); @@ -60909,17 +61156,17 @@ var ts; case 164: return getContextuallyTypedParameterType(declaration); case 203: - return getContextualTypeForBindingElement(declaration); + return getContextualTypeForBindingElement(declaration, contextFlags); case 167: if (ts.isStatic(declaration)) { - return getContextualTypeForStaticPropertyDeclaration(declaration); + return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags); } } } - function getContextualTypeForBindingElement(declaration) { + function getContextualTypeForBindingElement(declaration, contextFlags) { var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - var parentType = getContextualTypeForVariableLikeDeclaration(parent) || + var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || parent.kind !== 203 && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 : 0); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; @@ -60935,8 +61182,8 @@ var ts; return getTypeOfPropertyOfType(parentType, text); } } - function getContextualTypeForStaticPropertyDeclaration(declaration) { - var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent); + function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) { + var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags); if (!parentType) return undefined; return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName); @@ -60944,7 +61191,7 @@ var ts; function getContextualTypeForInitializerExpression(node, contextFlags) { var declaration = node.parent; if (ts.hasInitializer(declaration) && node === declaration.initializer) { - var result = getContextualTypeForVariableLikeDeclaration(declaration); + var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags); if (result) { return result; } @@ -60954,19 +61201,22 @@ var ts; } return undefined; } - function getContextualTypeForReturnExpression(node) { + function getContextualTypeForReturnExpression(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); if (functionFlags & 1) { - var use = functionFlags & 2 ? 2 : 1; - var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, undefined); - if (!iterationTypes) { + var isAsyncGenerator_1 = (functionFlags & 2) !== 0; + if (contextualReturnType.flags & 1048576) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1, type, isAsyncGenerator_1); }); + } + var iterationReturnType = getIterationTypeOfGeneratorFunctionReturnType(1, contextualReturnType, (functionFlags & 2) !== 0); + if (!iterationReturnType) { return undefined; } - contextualReturnType = iterationTypes.returnType; + contextualReturnType = iterationReturnType; } if (functionFlags & 2) { var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); @@ -60985,15 +61235,19 @@ var ts; } return undefined; } - function getContextualTypeForYieldOperand(node) { + function getContextualTypeForYieldOperand(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { var functionFlags = ts.getFunctionFlags(func); - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { + var isAsyncGenerator_2 = (functionFlags & 2) !== 0; + if (!node.asteriskToken && contextualReturnType.flags & 1048576) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1, type, isAsyncGenerator_2); }); + } return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0, contextualReturnType, (functionFlags & 2) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0, contextualReturnType, isAsyncGenerator_2); } } return undefined; @@ -61013,14 +61267,14 @@ var ts; } function getContextualIterationType(kind, functionDecl) { var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2); - var contextualReturnType = getContextualReturnType(functionDecl); + var contextualReturnType = getContextualReturnType(functionDecl, undefined); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) || undefined; } return undefined; } - function getContextualReturnType(functionDecl) { + function getContextualReturnType(functionDecl, contextFlags) { var returnType = getReturnTypeFromAnnotation(functionDecl); if (returnType) { return returnType; @@ -61031,7 +61285,7 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl); if (iife) { - return getContextualType(iife); + return getContextualType(iife, contextFlags); } return undefined; } @@ -61093,6 +61347,14 @@ var ts; var lhsType = getTypeOfExpression(e.expression); return ts.isPrivateIdentifier(e.name) ? tryGetPrivateIdentifierPropertyOfType(lhsType, e.name) : getPropertyOfType(lhsType, e.name.escapedText); } + if (ts.isElementAccessExpression(e)) { + var propType = checkExpressionCached(e.argumentExpression); + if (!isTypeUsableAsPropertyName(propType)) { + return undefined; + } + var lhsType = getTypeOfExpression(e.expression); + return getPropertyOfType(lhsType, getPropertyNameFromType(propType)); + } return undefined; function tryGetPrivateIdentifierPropertyOfType(type, id) { var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(id.escapedText, id); @@ -61261,7 +61523,7 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; - var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags); if (propertyAssignmentType) { return propertyAssignmentType; } @@ -61286,8 +61548,8 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined; } - function getContextualTypeForChildJsxExpression(node, child) { - var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName); + function getContextualTypeForChildJsxExpression(node, child, contextFlags) { + var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags); var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) { return undefined; @@ -61304,24 +61566,24 @@ var ts; } }, true)); } - function getContextualTypeForJsxExpression(node) { + function getContextualTypeForJsxExpression(node, contextFlags) { var exprParent = node.parent; return ts.isJsxAttributeLike(exprParent) - ? getContextualType(node) + ? getContextualType(node, contextFlags) : ts.isJsxElement(exprParent) - ? getContextualTypeForChildJsxExpression(exprParent, node) + ? getContextualTypeForChildJsxExpression(exprParent, node, contextFlags) : undefined; } - function getContextualTypeForJsxAttribute(attribute) { + function getContextualTypeForJsxAttribute(attribute, contextFlags) { if (ts.isJsxAttribute(attribute)) { - var attributesType = getApparentTypeOfContextualType(attribute.parent); + var attributesType = getApparentTypeOfContextualType(attribute.parent, contextFlags); if (!attributesType || isTypeAny(attributesType)) { return undefined; } return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { - return getContextualType(attribute.parent); + return getContextualType(attribute.parent, contextFlags); } } function isPossiblyDiscriminantValue(node) { @@ -61406,9 +61668,9 @@ var ts; return getContextualTypeForInitializerExpression(node, contextFlags); case 214: case 247: - return getContextualTypeForReturnExpression(node); + return getContextualTypeForReturnExpression(node, contextFlags); case 224: - return getContextualTypeForYieldOperand(parent); + return getContextualTypeForYieldOperand(parent, contextFlags); case 218: return getContextualTypeForAwaitOperand(parent, contextFlags); case 208: @@ -61445,17 +61707,17 @@ var ts; case 271: return tryGetTypeFromEffectiveTypeNode(parent); case 288: - return getContextualTypeForJsxExpression(parent); + return getContextualTypeForJsxExpression(parent, contextFlags); case 285: case 287: - return getContextualTypeForJsxAttribute(parent); + return getContextualTypeForJsxAttribute(parent, contextFlags); case 280: case 279: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; function tryFindWhenConstTypeReference(node) { - return getContextualType(node); + return getContextualType(node, contextFlags); } } function getInferenceContext(node) { @@ -61616,7 +61878,7 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } @@ -61724,7 +61986,7 @@ var ts; var elementCount = elements.length; var elementTypes = []; var elementFlags = []; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, undefined); var inDestructuringPattern = ts.isAssignmentTarget(node); var inConstContext = isConstContext(node); var hasOmittedExpression = false; @@ -61873,7 +62135,7 @@ var ts; var propertiesTable = ts.createSymbolTable(); var propertiesArray = []; var spread = emptyObjectType; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, undefined); var contextualTypeHasPattern = contextualType && contextualType.pattern && (contextualType.pattern.kind === 201 || contextualType.pattern.kind === 205); var inConstContext = isConstContext(node); @@ -62171,7 +62433,7 @@ var ts; if (explicitlySpecifyChildrenAttribute) { error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName)); } - var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); + var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, undefined); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); var childrenPropSymbol = createSymbol(4, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : @@ -63835,7 +64097,7 @@ var ts; var spreadIndex = getSpreadArgumentIndex(args); if (spreadIndex >= 0) { var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_25 = function (i) { + var _loop_26 = function (i) { var arg = args[i]; var spreadType = arg.kind === 225 && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { @@ -63851,7 +64113,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_25(i); + _loop_26(i); } return effectiveArgs_1; } @@ -64037,7 +64299,7 @@ var ts; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; - if (!isDecorator) { + if (!isDecorator && !ts.isSuperCall(node)) { typeArguments = node.typeArguments; if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106) { ts.forEach(typeArguments, checkSourceElement); @@ -64069,6 +64331,8 @@ var ts; if (result) { return result; } + result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + getNodeLinks(node).resolvedSignature = result; if (reportErrors) { if (candidatesForArgumentError) { if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) { @@ -64099,7 +64363,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_26 = function (c) { + var _loop_27 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2); if (diags_2) { @@ -64117,7 +64381,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_26(c); + _loop_27(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -64154,7 +64418,7 @@ var ts; } } } - return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + return result; function addImplementationSuccessElaboration(failed, diagnostic) { var _a, _b; var oldCandidatesForArgumentError = candidatesForArgumentError; @@ -64228,7 +64492,7 @@ var ts; argCheckMode = checkMode & 32; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); - checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); + checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters); if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) { candidateForArgumentArityError = checkCandidate; continue; @@ -64260,7 +64524,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_27 = function (i) { + var _loop_28 = function (i) { var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : i < s.parameters.length ? s.parameters[i] : undefined; }); @@ -64268,7 +64532,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_27(i); + _loop_28(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0; @@ -64867,7 +65131,7 @@ var ts; checkGrammarTypeArguments(node, node.typeArguments); var signature = getResolvedSignature(node, undefined, checkMode); if (signature === resolvingSignature) { - return nonInferrableType; + return silentNeverType; } checkDeprecatedSignature(signature, node); if (node.expression.kind === 106) { @@ -65457,13 +65721,6 @@ var ts; } } } - var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144) { - var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); - assignContextualParameterTypes(signature, instantiatedContext); - var restPos = getParameterCount(context) - 1; - inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType); - } } function assignContextualParameterTypes(signature, context) { if (context.typeParameters) { @@ -65636,7 +65893,7 @@ var ts; var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); var contextualType = !contextualSignature ? undefined : contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : - instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); + instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, undefined); if (isGenerator) { yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0, isAsync); returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1, isAsync); @@ -65699,7 +65956,7 @@ var ts; nextType = iterationTypes && iterationTypes.nextType; } else { - nextType = getContextualType(yieldExpression); + nextType = getContextualType(yieldExpression, undefined); } if (nextType) ts.pushIfUnique(nextTypes, nextType); @@ -65872,11 +66129,16 @@ var ts; if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); + var instantiatedContextualSignature = void 0; if (checkMode && checkMode & 2) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); + var restType = getEffectiveRestType(contextualSignature); + if (restType && restType.flags & 262144) { + instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper); + } } - var instantiatedContextualSignature = inferenceContext ? - instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature; + instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ? + instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature); assignContextualParameterTypes(signature, instantiatedContextualSignature); } else { @@ -66145,7 +66407,7 @@ var ts; error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } if (node.operator === 39) { - if (maybeTypeOfKind(operandType, 2112)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; @@ -66535,7 +66797,11 @@ var ts; var operator = operatorToken.kind; if (operator === 55 || operator === 56 || operator === 60) { if (operator === 55) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); + var parent = node.parent; + while (parent.kind === 212 + || ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 || parent.operatorToken.kind === 56)) { + parent = parent.parent; + } checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } checkTruthinessOfType(leftType, node.left); @@ -66991,7 +67257,7 @@ var ts; type = anyType; addLazyDiagnostic(function () { if (noImplicitAny && !ts.expressionResultIsUnused(node)) { - var contextualType = getContextualType(node); + var contextualType = getContextualType(node, undefined); if (!contextualType || isTypeAny(contextualType)) { error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation); } @@ -67032,7 +67298,7 @@ var ts; texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; + return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { return !!(type.flags & (128 | 134217728) || @@ -67055,7 +67321,7 @@ var ts; if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { inferenceContext.intraExpressionInferenceSites = undefined; } - var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, undefined)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -67159,7 +67425,7 @@ var ts; var type = checkExpression(node, checkMode, forceTuple); return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) : isTypeAssertion(node) ? type : - getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node)); + getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, undefined) : contextualType, node, undefined)); } function checkPropertyAssignment(node, checkMode) { if (node.name.kind === 162) { @@ -67245,8 +67511,8 @@ var ts; var result = []; var oldTypeParameters; var newTypeParameters; - for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { - var tp = typeParameters_2[_i]; + for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { + var tp = typeParameters_3[_i]; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); @@ -67539,12 +67805,14 @@ var ts; error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); } else if (modifiers === 32768 || modifiers === 65536) { - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSuperType : markerSubType); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) }); + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSubTypeForCheck : markerSuperTypeForCheck); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 ? markerSuperTypeForCheck : markerSubTypeForCheck); var saveVarianceTypeParameter = typeParameter; varianceTypeParameter = typeParameter; checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); varianceTypeParameter = saveVarianceTypeParameter; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } } } @@ -67561,7 +67829,7 @@ var ts; error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } - if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { + if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) { error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); } if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) { @@ -67854,7 +68122,7 @@ var ts; var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var indexSignatureMap_1 = new ts.Map(); - var _loop_28 = function (declaration) { + var _loop_29 = function (declaration) { if (declaration.parameters.length === 1 && declaration.parameters[0].type) { forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) { var entry = indexSignatureMap_1.get(getTypeId(type)); @@ -67869,7 +68137,7 @@ var ts; }; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - _loop_28(declaration); + _loop_29(declaration); } indexSignatureMap_1.forEach(function (entry) { if (entry.declarations.length > 1) { @@ -68061,6 +68329,12 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function getEffectiveTypeArgumentAtIndex(node, typeParameters, index) { + if (index < typeParameters.length) { + return getTypeFromTypeNode(node.typeArguments[index]); + } + return getEffectiveTypeArguments(node, typeParameters)[index]; + } function getEffectiveTypeArguments(node, typeParameters) { return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node)); } @@ -68718,20 +68992,32 @@ var ts; isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } - function createAwaitedTypeIfNeeded(type) { - if (isTypeAny(type)) { - return type; - } - if (isAwaitedTypeInstantiation(type)) { - return type; + function isAwaitedTypeNeeded(type) { + if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) { + return false; } if (isGenericObjectType(type)) { var baseConstraint = getBaseConstraintOfType(type); - if (!baseConstraint || (baseConstraint.flags & 3) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { - var awaitedSymbol = getGlobalAwaitedSymbol(true); - if (awaitedSymbol) { - return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); - } + if (baseConstraint ? + baseConstraint.flags & 3 || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) : + maybeTypeOfKind(type, 8650752)) { + return true; + } + } + return false; + } + function tryCreateAwaitedType(type) { + var awaitedSymbol = getGlobalAwaitedSymbol(true); + if (awaitedSymbol) { + return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); + } + return undefined; + } + function createAwaitedTypeIfNeeded(type) { + if (isAwaitedTypeNeeded(type)) { + var awaitedType = tryCreateAwaitedType(type); + if (awaitedType) { + return awaitedType; } } ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like."); @@ -68753,8 +69039,20 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } if (type.flags & 1048576) { + if (awaitedTypeStack.lastIndexOf(type.id) >= 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; - return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); + awaitedTypeStack.push(type.id); + var mapped = mapType(type, mapper); + awaitedTypeStack.pop(); + return typeAsAwaitable.awaitedTypeOfType = mapped; + } + if (isAwaitedTypeNeeded(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; } var thisTypeForErrorOut = { value: undefined }; var promisedType = getPromisedTypeOfPromise(type, undefined, thisTypeForErrorOut); @@ -69259,8 +69557,8 @@ var ts; return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); - for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { - var typeParameter = typeParameters_3[_i]; + for (var _i = 0, typeParameters_4 = typeParameters; _i < typeParameters_4.length; _i++) { + var typeParameter = typeParameters_4[_i]; if (!isTypeParameterUnused(typeParameter)) continue; var name = ts.idText(typeParameter.name); @@ -70213,17 +70511,28 @@ var ts; return type[cacheKey] = cachedTypes; } function getIterationTypesOfIterable(type, use, errorNode) { + var _a, _b; if (isTypeAny(type)) { return anyIterationTypes; } if (!(type.flags & 1048576)) { - var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } return undefined; } + else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) { + for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) { + var diag = _c[_i]; + diagnostics.add(diag); + } + } return iterationTypes_1; } var cacheKey = use & 2 ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; @@ -70231,19 +70540,27 @@ var ts; if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; var allIterationTypes; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituent = _a[_i]; - var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); + for (var _d = 0, _e = type.types; _d < _e.length; _d++) { + var constituent = _e[_d]; + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; } - else { - allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); + else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) { + for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) { + var diag = _g[_f]; + diagnostics.add(diag); + } } + allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); } var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes; setCachedIterationTypes(type, cacheKey, iterationTypes); @@ -70260,46 +70577,57 @@ var ts; } return createIterationTypes(getAwaitedType(yieldType, errorNode) || anyType, getAwaitedType(returnType, errorNode) || anyType, nextType); } - function getIterationTypesOfIterableWorker(type, use, errorNode) { + function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) { if (isTypeAny(type)) { return anyIterationTypes; } + var noCache = false; if (use & 2) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 ? - getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : - iterationTypes; + if (iterationTypes === noIterationTypes && errorNode) { + noCache = true; + } + else { + return use & 8 ? + getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : + iterationTypes; + } } } if (use & 1) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2) { - if (iterationTypes !== noIterationTypes) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); - } + if (iterationTypes === noIterationTypes && errorNode) { + noCache = true; } else { - return iterationTypes; + if (use & 2) { + if (iterationTypes !== noIterationTypes) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); + } + } + else { + return iterationTypes; + } } } } if (use & 2) { - var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); + var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } if (use & 1) { - var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); + var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { if (use & 2) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes - ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) - : noIterationTypes); + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); } else { return iterationTypes; @@ -70313,7 +70641,7 @@ var ts; } function getIterationTypesOfGlobalIterableType(globalType, resolver) { var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) || - getIterationTypesOfIterableSlow(globalType, resolver, undefined); + getIterationTypesOfIterableSlow(globalType, resolver, undefined, undefined, false); return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes; } function getIterationTypesOfIterableFast(type, resolver) { @@ -70332,36 +70660,43 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } - function getIterationTypesOfIterableSlow(type, resolver, errorNode) { + function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); var methodType = method && !(method.flags & 16777216) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); + return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } var signatures = methodType ? getSignaturesOfType(methodType, 0) : undefined; if (!ts.some(signatures)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); + return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature)); - var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes; - return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); + var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes; + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); } function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) { var message = allowAsyncIterables ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator; - errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); + return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); + } + function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) { + return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, false); } - function getIterationTypesOfIterator(type, resolver, errorNode) { + function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) { if (isTypeAny(type)) { return anyIterationTypes; } var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) || - getIterationTypesOfIteratorFast(type, resolver) || - getIterationTypesOfIteratorSlow(type, resolver, errorNode); + getIterationTypesOfIteratorFast(type, resolver); + if (iterationTypes === noIterationTypes && errorNode) { + iterationTypes = undefined; + noCache = true; + } + iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache)); return iterationTypes === noIterationTypes ? undefined : iterationTypes; } function getIterationTypesOfIteratorCached(type, resolver) { @@ -70372,7 +70707,7 @@ var ts; if (isReferenceToType(type, globalType)) { var yieldType = getTypeArguments(type)[0]; var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || - getIterationTypesOfIteratorSlow(globalType, resolver, undefined); + getIterationTypesOfIteratorSlow(globalType, resolver, undefined, undefined, false); var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType; return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType)); } @@ -70417,8 +70752,8 @@ var ts; } return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType, returnType || voidType, undefined)); } - function getIterationTypesOfMethod(type, resolver, methodName, errorNode) { - var _a, _b, _c, _d; + function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) { + var _a, _b, _c, _d, _e, _f; var method = getPropertyOfType(type, methodName); if (!method && methodName !== "next") { return undefined; @@ -70435,15 +70770,21 @@ var ts; var diagnostic = methodName === "next" ? resolver.mustHaveANextMethodDiagnostic : resolver.mustBeAMethodDiagnostic; - error(errorNode, diagnostic, methodName); + if (errorOutputContainer) { + (_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName)); + } + else { + error(errorNode, diagnostic, methodName); + } } - return methodName === "next" ? anyIterationTypes : undefined; + return methodName === "next" ? noIterationTypes : undefined; } if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) { var globalGeneratorType = resolver.getGlobalGeneratorType(false); var globalIteratorType = resolver.getGlobalIteratorType(false); - var isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get(methodName)) === methodType.symbol; - var isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) === null || _c === void 0 ? void 0 : _c.members) === null || _d === void 0 ? void 0 : _d.get(methodName)) === methodType.symbol; + var isGeneratorMethod = ((_c = (_b = globalGeneratorType.symbol) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.get(methodName)) === methodType.symbol; + var isIteratorMethod = !isGeneratorMethod && ((_e = (_d = globalIteratorType.symbol) === null || _d === void 0 ? void 0 : _d.members) === null || _e === void 0 ? void 0 : _e.get(methodName)) === methodType.symbol; if (isGeneratorMethod || isIteratorMethod) { var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType; var mapper = methodType.mapper; @@ -70477,7 +70818,13 @@ var ts; var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType); if (iterationTypes === noIterationTypes) { if (errorNode) { - error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + if (errorOutputContainer) { + (_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName)); + } + else { + error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + } } yieldType = anyType; returnTypes = ts.append(returnTypes, anyType); @@ -70488,13 +70835,13 @@ var ts; } return createIterationTypes(yieldType, getUnionType(returnTypes), nextType); } - function getIterationTypesOfIteratorSlow(type, resolver, errorNode) { + function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var iterationTypes = combineIterationTypes([ - getIterationTypesOfMethod(type, resolver, "next", errorNode), - getIterationTypesOfMethod(type, resolver, "return", errorNode), - getIterationTypesOfMethod(type, resolver, "throw", errorNode), + getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer), ]); - return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); } function getIterationTypeOfGeneratorFunctionReturnType(kind, returnType, isAsyncGenerator) { if (isTypeAny(returnType)) { @@ -70510,7 +70857,7 @@ var ts; var use = isAsyncGenerator ? 2 : 1; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, undefined) || - getIterationTypesOfIterator(type, resolver, undefined); + getIterationTypesOfIterator(type, resolver, undefined, undefined); } function checkBreakOrContinueStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) @@ -70519,9 +70866,14 @@ var ts; function unwrapReturnType(returnType, functionFlags) { var isGenerator = !!(functionFlags & 1); var isAsync = !!(functionFlags & 2); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1, returnType, isAsync) || errorType : - isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : - returnType; + if (isGenerator) { + var returnIterationType = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, isAsync); + if (!returnIterationType) { + return errorType; + } + return isAsync ? getAwaitedTypeNoAlias(unwrapAwaitedType(returnIterationType)) : returnIterationType; + } + return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); @@ -70722,19 +71074,24 @@ var ts; } var indexInfos = getApplicableIndexInfos(type, propNameType); var interfaceDeclaration = ts.getObjectFlags(type) & 2 ? ts.getDeclarationOfKind(type.symbol, 258) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 || - name && name.kind === 162 || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; - var _loop_29 = function (info) { + var propDeclaration = declaration && declaration.kind === 221 || + name && name.kind === 162 ? declaration : undefined; + var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var _loop_30 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; var errorNode = localPropDeclaration || localIndexDeclaration || (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined); if (errorNode && !isTypeAssignableTo(propType, info.type)) { - error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + if (propDeclaration && errorNode !== propDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop))); + } + diagnostics.add(diagnostic); } }; for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) { var info = indexInfos_9[_i]; - _loop_29(info); + _loop_30(info); } } function checkIndexConstraintForIndexSignature(type, checkInfo) { @@ -70742,7 +71099,7 @@ var ts; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); var interfaceDeclaration = ts.getObjectFlags(type) & 2 ? ts.getDeclarationOfKind(type.symbol, 258) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; - var _loop_30 = function (info) { + var _loop_31 = function (info) { if (info === checkInfo) return "continue"; var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; @@ -70754,7 +71111,7 @@ var ts; }; for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) { var info = indexInfos_10[_i]; - _loop_30(info); + _loop_31(info); } } function checkTypeNameIsReserved(name, message) { @@ -71049,7 +71406,7 @@ var ts; var baseTypes = baseTypeNode && getBaseTypes(type); var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined; var baseStaticType = getBaseConstructorTypeOfClass(type); - var _loop_31 = function (member) { + var _loop_32 = function (member) { if (ts.hasAmbientModifier(member)) { return "continue"; } @@ -71064,7 +71421,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_31(member); + _loop_32(member); } } function checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, memberIsParameterProperty, reportErrors) { @@ -71139,7 +71496,7 @@ var ts; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { var issuedMemberError = false; - var _loop_32 = function (member) { + var _loop_33 = function (member) { if (ts.isStatic(member)) { return "continue"; } @@ -71157,7 +71514,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_32(member); + _loop_33(member); } if (!issuedMemberError) { checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag); @@ -71204,7 +71561,7 @@ var ts; function checkKindsOfPropertyMemberOverrides(type, baseType) { var _a, _b, _c, _d; var baseProperties = getPropertiesOfType(baseType); - var _loop_33 = function (baseProperty) { + var _loop_34 = function (baseProperty) { var base = getTargetSymbol(baseProperty); if (base.flags & 4194304) { return "continue"; @@ -71302,7 +71659,7 @@ var ts; }; basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; - var state_10 = _loop_33(baseProperty); + var state_10 = _loop_34(baseProperty); switch (state_10) { case "continue-basePropertyCheck": continue basePropertyCheck; } @@ -71914,7 +72271,7 @@ var ts; var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)); var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "..."; var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName); - error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"" + moduleSpecifier + "\")." + importedIdentifier); + error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"".concat(moduleSpecifier, "\").").concat(importedIdentifier)); } return; } @@ -72214,7 +72571,9 @@ var ts; error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { - markExportAsReferenced(node); + if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) { + markExportAsReferenced(node); + } var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol); if (!target || target === unknownSymbol || target.flags & 111551) { checkExpressionCached(node.propertyName || node.name); @@ -73946,10 +74305,16 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = 788968 | 1920; - if ((node.kind === 79 && isInTypeQuery(node)) || (node.kind === 206 && !isInHeritageClause(node))) { + var meaning; + if (node.parent.kind === 162) { meaning = 111551 | 1048576; } + else { + meaning = 788968 | 1920; + if ((node.kind === 79 && isInTypeQuery(node)) || (node.kind === 206 && !isInHeritageClause(node))) { + meaning = 111551 | 1048576; + } + } var symbol = resolveEntityName(node, meaning, true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; } @@ -75265,9 +75630,6 @@ var ts; else { return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } - if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } } } function checkGrammarVariableDeclaration(node) { @@ -76058,13 +76420,13 @@ var ts; return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); case 200: ts.Debug.type(node); - return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); case 295: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); case 197: ts.Debug.type(node); - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); + return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); case 191: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); @@ -76127,7 +76489,7 @@ var ts; return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 210: ts.Debug.type(node); - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); + return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); case 211: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); @@ -76846,7 +77208,7 @@ var ts; value >= 52 && value < 62 ? 48 + value - 52 : value === 62 ? 43 : value === 63 ? 47 : - ts.Debug.fail(value + ": not a base64 value"); + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { return ch >= 65 && ch <= 90 ? ch - 65 : @@ -76919,7 +77281,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -78398,7 +78760,8 @@ var ts; else { statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); + var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start)); statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), true); ts.setTextRange(block, body); @@ -79005,7 +79368,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -79325,10 +79688,11 @@ var ts; } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { if (node.operator === 45 || node.operator === 46) { - if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + var operand = ts.skipParentheses(node.operand); + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) { var info = void 0; - if (info = accessPrivateIdentifier(node.operand.name)) { - var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); + if (info = accessPrivateIdentifier(operand.name)) { + var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); @@ -79344,36 +79708,36 @@ var ts; } } else if (shouldTransformSuperInStaticInitializers && - ts.isSuperProperty(node.operand) && + ts.isSuperProperty(operand) && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; if (facts & 1) { - var operand = visitInvalidSuperProperty(node.operand); + var expression = visitInvalidSuperProperty(operand); return ts.isPrefixUnaryExpression(node) ? - factory.updatePrefixUnaryExpression(node, operand) : - factory.updatePostfixUnaryExpression(node, operand); + factory.updatePrefixUnaryExpression(node, expression) : + factory.updatePostfixUnaryExpression(node, expression); } if (classConstructor && superClassReference) { var setterName = void 0; var getterName = void 0; - if (ts.isPropertyAccessExpression(node.operand)) { - if (ts.isIdentifier(node.operand.name)) { - getterName = setterName = factory.createStringLiteralFromNode(node.operand.name); + if (ts.isPropertyAccessExpression(operand)) { + if (ts.isIdentifier(operand.name)) { + getterName = setterName = factory.createStringLiteralFromNode(operand.name); } } else { - if (ts.isSimpleInlineableExpression(node.operand.argumentExpression)) { - getterName = setterName = node.operand.argumentExpression; + if (ts.isSimpleInlineableExpression(operand.argumentExpression)) { + getterName = setterName = operand.argumentExpression; } else { getterName = factory.createTempVariable(hoistVariableDeclaration); - setterName = factory.createAssignment(getterName, ts.visitNode(node.operand.argumentExpression, visitor, ts.isExpression)); + setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression)); } } if (setterName && getterName) { var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor); - ts.setTextRange(expression, node.operand); + ts.setTextRange(expression, operand); var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor); @@ -80256,8 +80620,8 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16); + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16); if (resolver.getNodeCheckFlags(node) & 524288) { addBlockScopedVariable(identifier); } @@ -80783,23 +81147,58 @@ var ts; function visitClassDeclaration(node) { if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node))) return ts.visitEachChild(node, visitor, context); - var classStatement = ts.hasDecorators(node) ? - createClassDeclarationHeadWithDecorators(node, node.name) : - createClassDeclarationHeadWithoutDecorators(node, node.name); - var statements = [classStatement]; - addClassElementDecorationStatements(statements, node, false); - addClassElementDecorationStatements(statements, node, true); - addConstructorDecorationStatement(statements, node); + var statements = ts.hasDecorators(node) ? + transformClassDeclarationWithClassDecorators(node, node.name) : + transformClassDeclarationWithoutClassDecorators(node, node.name); if (statements.length > 1) { statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304); + ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304); } return ts.singleOrMany(statements); } - function createClassDeclarationHeadWithoutDecorators(node, name) { - return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement)); + function decoratorContainsPrivateIdentifierInExpression(decorator) { + return !!(decorator.transformFlags & 536870912); + } + function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) { + return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression); } - function createClassDeclarationHeadWithDecorators(node, name) { + function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (!ts.canHaveDecorators(member)) + continue; + var allDecorators = ts.getAllDecoratorsOfClassElement(member, node); + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression)) + return true; + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression)) + return true; + } + return false; + } + function transformDecoratorsOfClassElements(node, members) { + var decorationStatements = []; + addClassElementDecorationStatements(decorationStatements, node, false); + addClassElementDecorationStatements(decorationStatements, node, true); + if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) { + members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [ + factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, true)) + ], false)), members); + decorationStatements = undefined; + } + return { decorationStatements: decorationStatements, members: members }; + } + function transformClassDeclarationWithoutClassDecorators(node, name) { + var _a; + var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = ts.visitNodes(node.members, visitor, ts.isClassElement); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var updated = factory.updateClassDeclaration(node, modifiers, name, undefined, heritageClauses, members); + return ts.addRange([updated], decorationStatements); + } + function transformClassDeclarationWithClassDecorators(node, name) { + var _a; var location = ts.moveRangePastModifiers(node); var classAlias = getClassAliasIfNeeded(node); var declName = languageVersion <= 2 ? @@ -80807,6 +81206,8 @@ var ts; factory.getLocalName(node, false, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = ts.visitNodes(node.members, visitor, ts.isClassElement); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); var classExpression = factory.createClassExpression(undefined, name, undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); ts.setTextRange(classExpression, location); @@ -80816,7 +81217,10 @@ var ts; ts.setOriginalNode(statement, node); ts.setTextRange(statement, location); ts.setCommentRange(statement, node); - return statement; + var statements = [statement]; + ts.addRange(statements, decorationStatements); + addConstructorDecorationStatement(statements, node); + return statements; } function visitClassExpression(node) { return factory.updateClassExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement)); @@ -82528,7 +82932,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 | 32 | 64); + var generatedName = factory.createUniqueName("_".concat(name), 16 | 32 | 64); var specifier = factory.createImportSpecifier(false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -83476,11 +83880,11 @@ var ts; } else { if (node.kind === 246) { - labelMarker = "break-" + label.escapedText; + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, false, ts.idText(label), labelMarker); } } @@ -89135,7 +89539,7 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind)); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(node.kind))); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (node.kind === 254 || node.kind === 203) { @@ -89332,7 +89736,7 @@ var ts; ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind)); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind))); } } function getTypeParameterConstraintVisibilityError() { @@ -90039,7 +90443,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.Debug.formatSyntaxKind(i.kind))); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -90204,7 +90608,7 @@ var ts; return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind)); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(input.kind))); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { @@ -90454,7 +90858,7 @@ var ts; var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104) { var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, @@ -90491,7 +90895,7 @@ var ts; })))); } } - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind)); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.Debug.formatSyntaxKind(input.kind))); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -91261,13 +91665,13 @@ var ts; if (ts.fileExtensionIs(inputFileName, ".json")) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -91327,7 +91731,7 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { @@ -91346,7 +91750,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { @@ -91360,7 +91764,6 @@ var ts; var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit; var bundleBuildInfo; var emitSkipped = false; - var exportedModulesFromDeclarationEmit; enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); @@ -91369,7 +91772,6 @@ var ts; diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList, - exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; @@ -91429,7 +91831,7 @@ var ts; if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) { return; } - if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) { + if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) { emitSkipped = true; return; } @@ -91454,7 +91856,7 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions); transform.dispose(); if (bundleBuildInfo) bundleBuildInfo.js = printer.bundleFileInfo; @@ -91486,7 +91888,7 @@ var ts; noEmitHelpers: true, module: compilerOptions.module, target: compilerOptions.target, - sourceMap: compilerOptions.sourceMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, @@ -91504,16 +91906,12 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { - sourceMap: !forceDtsEmit && compilerOptions.declarationMap, + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, { + sourceMap: printerOptions.sourceMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305) { - var sourceFile = declarationTransform.transformed[0]; - exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; - } } declarationTransform.dispose(); if (bundleBuildInfo) @@ -91532,7 +91930,8 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) { + var sourceFileOrBundle = transform.transformed[0]; var bundle = sourceFileOrBundle.kind === 306 ? sourceFileOrBundle : undefined; var sourceFile = sourceFileOrBundle.kind === 305 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; @@ -91559,22 +91958,22 @@ var ts; if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); sourceMapUrlPos = writer.getTextPos(); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); } if (sourceMapFilePath) { var sourceMap = sourceMapGenerator.toString(); ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles); if (printer.bundleFileInfo) - printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); } } else { writer.writeLine(); } var text = writer.getText(); - ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); + ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics }); if (printer.bundleFileInfo) - printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash)); writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { @@ -91604,7 +92003,7 @@ var ts; if (mapOptions.inlineSourceMap) { var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -91719,22 +92118,22 @@ var ts; var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath)); if (!jsFileText) return jsFilePath; - if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) + if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) return jsFilePath; var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) return sourceMapFilePath || "inline sourcemap decoding"; - if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) + if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) return sourceMapFilePath; var declarationText = declarationFilePath && host.readFile(declarationFilePath); if (declarationFilePath && !declarationText) return declarationFilePath; - if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) + if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) return declarationFilePath; var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) return declarationMapPath || "inline sourcemap decoding"; - if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) + if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) return declarationMapPath; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true); @@ -91772,8 +92171,7 @@ var ts; var newBuildInfo = data.buildInfo; newBuildInfo.program = buildInfo.program; if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) { - newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash); - newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime(); + newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData); } var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; newBuildInfo.bundle.js.sources = js.sources; @@ -91794,7 +92192,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -92608,7 +93006,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -92748,14 +93146,14 @@ var ts; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); + nonEscapingWrite("${".concat(snippet.order, ":")); pipelineEmitWithHintWorker(hint, node, false); nonEscapingWrite("}"); } function emitTabStop(hint, node, snippet) { - ts.Debug.assert(node.kind === 236, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.assert(node.kind === 236, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); ts.Debug.assert(hint !== 5, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + nonEscapingWrite("$".concat(snippet.order)); } function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; @@ -94414,17 +94812,17 @@ var ts; writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -94432,7 +94830,7 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName }); writeLine(); @@ -94441,9 +94839,9 @@ var ts; var directive = types_23[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" : "type-require", data: directive.fileName }); writeLine(); @@ -94451,7 +94849,7 @@ var ts; for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib", data: directive.fileName }); writeLine(); @@ -95178,9 +95576,9 @@ var ts; var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); @@ -95583,8 +95981,8 @@ var ts; } function formatSynthesizedComment(comment) { return comment.kind === 3 - ? "/*" + comment.text + "*/" - : "//" + comment.text; + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); @@ -96218,18 +96616,18 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; if (fileOrDirectoryPath === watchedDirPath) return false; if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) @@ -96248,7 +96646,7 @@ var ts; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; if (hasSourceFile((filePathWithoutExtension + ".ts")) || hasSourceFile((filePathWithoutExtension + ".tsx"))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -96316,36 +96714,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -96355,16 +96753,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -96631,12 +97029,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -96714,9 +97112,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -96730,7 +97128,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -96791,7 +97189,7 @@ var ts; var result = void 0; var mode = getModeForFileReference(name, containingFileMode); var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -96886,7 +97284,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -97028,6 +97426,11 @@ var ts; } ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics; function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { + var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options); + return typeof result === "object" ? result.impliedNodeFormat : result; + } + ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: @@ -97039,11 +97442,16 @@ var ts; return undefined; } function lookupFromPackageJson() { - var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options); - return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options); + var packageJsonLocations = []; + state.failedLookupLocations = packageJsonLocations; + state.affectingLocations = packageJsonLocations; + var packageJsonScope = ts.getPackageScopeForPath(fileName, state); + var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope }; } } - ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker; ts.plainJSErrors = new ts.Set([ ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0.code, ts.Diagnostics.A_module_cannot_have_multiple_default_exports.code, @@ -97321,7 +97729,7 @@ var ts; for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { var oldSourceFile = oldSourceFiles_1[_i]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); - if (shouldCreateNewSourceFile || !newFile || + if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); } @@ -97651,7 +98059,7 @@ var ts; }); } function tryReuseStructureFromOldProgram() { - var _a; + var _a, _b; if (!oldProgram) { return 0; } @@ -97679,12 +98087,15 @@ var ts; var seenPackageNames = new ts.Map(); for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { var oldSourceFile = oldSourceFiles_2[_i]; + var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options); var newSourceFile = host.getSourceFileByPath - ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), undefined, shouldCreateNewSourceFile); + ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat) + : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); if (!newSourceFile) { return 0; } + newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope; ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; if (oldSourceFile.redirectInfo) { @@ -97717,27 +98128,32 @@ var ts; seenPackageNames.set(packageName, newKind); } if (fileChanged) { - if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { - structureIsReused = 1; - } - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) { structureIsReused = 1; } - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { structureIsReused = 1; } - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { structureIsReused = 1; } - if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { structureIsReused = 1; } - if ((oldSourceFile.flags & 6291456) !== (newSourceFile.flags & 6291456)) { - structureIsReused = 1; - } - if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { - structureIsReused = 1; + else { + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + structureIsReused = 1; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + structureIsReused = 1; + } + else if ((oldSourceFile.flags & 6291456) !== (newSourceFile.flags & 6291456)) { + structureIsReused = 1; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { + structureIsReused = 1; + } } modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } @@ -97751,17 +98167,17 @@ var ts; return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); - for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) { - var oldFile = oldSourceFiles_3[_b]; + for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) { + var oldFile = oldSourceFiles_3[_c]; if (!ts.contains(modifiedFiles, oldFile)) { - for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) { - var moduleName = _d[_c]; + for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) { + var moduleName = _e[_d]; ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); } } } - for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) { - var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile; + for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) { + var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile; var moduleNames = getModuleNames(newSourceFile); var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile); var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); @@ -97786,13 +98202,13 @@ var ts; if (structureIsReused !== 2) { return structureIsReused; } - if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) { return 1; } missingFilePaths = oldProgram.getMissingFilePaths(); ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length); - for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) { - var newSourceFile = newSourceFiles_1[_g]; + for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) { + var newSourceFile = newSourceFiles_1[_h]; filesByName.set(newSourceFile.path, newSourceFile); } var oldFilesByNameMap = oldProgram.getFilesByNameMap(); @@ -98492,13 +98908,16 @@ var ts; addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]); } } - function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) { + var _a; var redirect = Object.create(redirectTarget); redirect.fileName = fileName; redirect.path = path; redirect.resolvedPath = resolvedPath; redirect.originalFileName = originalFileName; redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + redirect.packageJsonScope = sourceFileOptions.packageJsonScope; sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); Object.defineProperties(redirect, { id: { @@ -98523,14 +98942,14 @@ var ts; return result; } function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) { - var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); - return { - languageVersion: ts.getEmitScriptTarget(options), - impliedNodeFormat: impliedNodeFormat, - setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options) - }; + var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); + var languageVersion = ts.getEmitScriptTarget(options); + var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options); + return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) : + { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator }; } function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { + var _a, _b; var path = toPath(fileName); if (useSourceOfProjectReferenceRedirect) { var source = getSourceOfProjectReferenceRedirect(path); @@ -98600,12 +99019,13 @@ var ts; redirectedPath = toPath(redirect); } } - var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile); + var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options); + var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat)); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { - var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions); redirectTargetsMap.add(fileFromPackageId.path, fileName); addFileToFilesByName(dupFile, path, redirectedPath); addFileIncludeReason(dupFile, reason); @@ -98625,6 +99045,8 @@ var ts; file.path = path; file.resolvedPath = toPath(fileName); file.originalFileName = originalFileName; + file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined; + file.packageJsonScope = sourceFileOptions.packageJsonScope; addFileIncludeReason(file, reason); if (host.useCaseSensitiveFileNames()) { var pathLowerCase = ts.toFileNameLowerCase(path); @@ -98757,7 +99179,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -98806,7 +99228,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -99201,7 +99623,7 @@ var ts; fileIncludeReasons = undefined; var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason); var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon); - var redirectInfo = file && ts.explainIfFileIsRedirect(file); + var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file); var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false)); return location && isReferenceFileLocation(location) ? ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : @@ -99560,10 +99982,10 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -99611,7 +100033,7 @@ var ts; var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath)); if (isFile && result) { var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -99746,8 +100168,8 @@ var ts; (function (ts) { function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit; - return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; + var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics; + return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); } @@ -99938,23 +100360,23 @@ var ts; state.allFileNames = undefined; } BuilderState.releaseCache = releaseCache; - function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var _a, _b; - var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash); + var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName); (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear(); (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); return result; } BuilderState.getFilesAffectedBy = getFilesAffectedBy; - function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var sourceFile = programOfThisState.getSourceFileByPath(path); if (!sourceFile) { return ts.emptyArray; } - if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) { + if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) { return [sourceFile]; } - return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash); + return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName); } BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState; function updateSignatureOfFile(state, signature, path) { @@ -99962,7 +100384,7 @@ var ts; (state.hasCalledUpdateShapeSignature || (state.hasCalledUpdateShapeSignature = new ts.Set())).add(path); } BuilderState.updateSignatureOfFile = updateSignatureOfFile; - function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) { + function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) { var _a; if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; } if ((_a = state.hasCalledUpdateShapeSignature) === null || _a === void 0 ? void 0 : _a.has(sourceFile.resolvedPath)) @@ -99971,15 +100393,13 @@ var ts; var prevSignature = info.signature; var latestSignature; if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) { - var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true); - var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); - if (firstDts_1) { - ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); - latestSignature = computeSignature(firstDts_1.text, computeHash); + programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) { + ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: ".concat(fileName)); + latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data); if (latestSignature !== prevSignature) { - updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit); + updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit); } - } + }, cancellationToken, true, undefined, true); } if (latestSignature === undefined) { latestSignature = sourceFile.version; @@ -100000,10 +100420,6 @@ var ts; return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; - function computeSignature(text, computeHash) { - return (computeHash || ts.generateDjb2Hash)(text); - } - BuilderState.computeSignature = computeSignature; function updateExportedModules(state, sourceFile, exportedModulesFromDeclarationEmit) { if (!state.exportedModulesMap) return; @@ -100113,7 +100529,7 @@ var ts; } return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } - function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) { + function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) { if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } @@ -100129,7 +100545,7 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath); seenFileNamesMap.set(currentPath, currentSourceFile); - if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) { + if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) { queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath)); } } @@ -100157,7 +100573,7 @@ var ts; state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature; } state.changedFilesSet = new ts.Set(); - state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined; + state.latestChangedDtsFile = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.latestChangedDtsFile : undefined; var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && @@ -100264,7 +100680,7 @@ var ts; programEmitComplete: state.programEmitComplete, emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: state.latestChangedDtsFile, hasChangedEmitSignature: state.hasChangedEmitSignature, changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined, }; @@ -100277,7 +100693,7 @@ var ts; state.programEmitComplete = savedEmitState.programEmitComplete; state.emitSignatures = savedEmitState.emitSignatures; state.outSignature = savedEmitState.outSignature; - state.dtsChangeTime = savedEmitState.dtsChangeTime; + state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile; state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature; if (savedEmitState.changedFilesSet) state.changedFilesSet = savedEmitState.changedFilesSet; @@ -100285,7 +100701,7 @@ var ts; function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) { ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath)); } - function getNextAffectedFile(state, cancellationToken, computeHash, host) { + function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; while (true) { var affectedFiles = state.affectedFiles; @@ -100296,7 +100712,7 @@ var ts; var affectedFile = affectedFiles[affectedFilesIndex]; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); return affectedFile; } affectedFilesIndex++; @@ -100317,7 +100733,7 @@ var ts; ts.Debug.assert(!state.semanticDiagnosticsPerFile); return program; } - state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash); + state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName); state.currentChangedFilePath = nextKey.value; state.affectedFilesIndex = 0; if (!state.seenAffectedFiles) @@ -100360,24 +100776,24 @@ var ts; }); } } - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { removeDiagnosticsOfLibraryFiles(state); - ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash); + ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName); return; } if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) return; - handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); } - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); var sourceFile = program.getSourceFileByPath(path); if (sourceFile) { - ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature); if (ts.getEmitDeclarations(state.compilerOptions)) { addToAffectedFilesPendingEmit(state, path, 0); } @@ -100397,16 +100813,16 @@ var ts; var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } - function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) return false; ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined) - .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); }); removeDiagnosticsOfLibraryFiles(state); return true; } - function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return; @@ -100420,9 +100836,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host)) return; - handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -100432,27 +100848,27 @@ var ts; } var seenFileAndExportsOfFile = new ts.Set(); (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; var references = state.referencedMap.getKeys(exportedFromPath); return references && ts.forEachKey(references, function (filePath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); }); } - function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) return undefined; - if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; - handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host); (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && - handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host); }); return undefined; } @@ -100507,13 +100923,13 @@ var ts; return !!ts.outFile(info.options || {}); } ts.isProgramBundleEmitBuildInfo = isProgramBundleEmitBuildInfo; - function getProgramBuildInfo(state, getCanonicalFileName, host) { + function getProgramBuildInfo(state, getCanonicalFileName) { var outFilePath = ts.outFile(state.compilerOptions); if (outFilePath && !state.compilerOptions.composite) return; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime; + var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined; if (outFilePath) { var fileNames_1 = []; var fileInfos_1 = []; @@ -100529,7 +100945,7 @@ var ts; fileInfos: fileInfos_1, options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result_15; } @@ -100624,7 +101040,7 @@ var ts; affectedFilesPendingEmit: affectedFilesPendingEmit, changeFileSet: changeFileSet, emitSignatures: emitSignatures, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result; function relativeToBuildInfoEnsuringAbsolutePath(path) { @@ -100736,8 +101152,39 @@ var ts; return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray }; } ts.getBuilderCreationParameters = getBuilderCreationParameters; - function computeSignature(text, data, computeHash) { - return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash); + function getTextHandlingSourceMapForSignature(text, data) { + return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text; + } + function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) { + var _a; + text = getTextHandlingSourceMapForSignature(text, data); + var sourceFileDirectory; + if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) { + text += data.diagnostics.map(function (diagnostic) { + return "".concat(locationInfo(diagnostic)).concat(ts.DiagnosticCategory[diagnostic.category]).concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText)); + }).join("\n"); + } + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text); + function flattenDiagnosticMessageText(diagnostic) { + return ts.isString(diagnostic) ? + diagnostic : + diagnostic === undefined ? + "" : + !diagnostic.next ? + diagnostic.messageText : + diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n"); + } + function locationInfo(diagnostic) { + if (diagnostic.file.resolvedPath === sourceFile.resolvedPath) + return "(".concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + if (sourceFileDirectory === undefined) + sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath); + return "".concat(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)), "(").concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + } + } + ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics; + function computeSignature(text, computeHash, data) { + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data)); } ts.computeSignature = computeSignature; function createBuilderProgram(kind, _a) { @@ -100751,7 +101198,7 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); var computeHash = ts.maybeBind(host, host.createHash); var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); - newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); }; + newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); }; newProgram = undefined; oldProgram = undefined; oldState = undefined; @@ -100760,6 +101207,7 @@ var ts; builderProgram.getState = getState; builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); }; builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); }; + builderProgram.hasChangedEmitSignature = function () { return !!state.hasChangedEmitSignature; }; builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); }; builderProgram.getSemanticDiagnostics = getSemanticDiagnostics; builderProgram.emit = emit; @@ -100785,7 +101233,7 @@ var ts; return ts.emitSkippedWithNoDiagnostics; } function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); var emitKind = 1; var isPendingEmitFile = false; if (!affected) { @@ -100814,50 +101262,54 @@ var ts; } function getWriteFileCallback(writeFile, customTransformers) { return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f, _g; if (ts.isDeclarationFileName(fileName)) { if (!ts.outFile(state.compilerOptions)) { ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); - var newSignature = void 0; + var emitSignature = void 0; if (!customTransformers) { var file = sourceFiles[0]; var info = state.fileInfos.get(file.resolvedPath); if (info.signature === file.version) { - newSignature = computeSignature(text, data, computeHash); - if (newSignature !== file.version) { + var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data); + if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length)) + emitSignature = signature; + if (signature !== file.version) { if (host.storeFilesChangingSignatureDuringEmit) - (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); if (state.exportedModulesMap) ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit); if (state.affectedFiles) { - var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath); + var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath); if (existing === undefined) - (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); - info.signature = newSignature; + ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); + info.signature = signature; } else { - info.signature = newSignature; - (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); + info.signature = signature; + (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear(); } } } } if (state.compilerOptions.composite) { var filePath = sourceFiles[0].resolvedPath; - var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath); - newSignature || (newSignature = computeSignature(text, data, computeHash)); - if (newSignature !== oldSignature) { - (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature); - state.hasChangedEmitSignature = true; - } + var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath); + emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data)); + if (emitSignature === oldSignature) + return; + ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature); + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } else if (state.compilerOptions.composite) { - var newSignature = computeSignature(text, data, computeHash); - if (newSignature !== state.outSignature) { - state.outSignature = newSignature; - state.hasChangedEmitSignature = true; - } + var newSignature = computeSignature(text, computeHash, data); + if (newSignature === state.outSignature) + return; + state.outSignature = newSignature; + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } if (writeFile) @@ -100913,7 +101365,7 @@ var ts; } function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); if (!affected) { return undefined; } @@ -100978,11 +101430,12 @@ var ts; var state; var filePaths; var filePathsSetList; + var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined; if (isProgramBundleEmitBuildInfo(program)) { state = { fileInfos: new ts.Map(), compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, outSignature: program.outSignature, }; } @@ -101015,7 +101468,7 @@ var ts; affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)), - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined, }; } @@ -101042,6 +101495,7 @@ var ts; getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, emitBuildInfo: ts.notImplemented, close: ts.noop, + hasChangedEmitSignature: ts.returnFalse, }; function toPath(path) { return ts.toPath(path, buildInfoDirectory, getCanonicalFileName); @@ -101136,7 +101590,7 @@ var ts; path; } ts.removeIgnoredPath = removeIgnoredPath; - function canWatchDirectory(dirPath) { + function canWatchDirectoryOrFile(dirPath) { var rootLength = ts.getRootLength(dirPath); if (dirPath.length === rootLength) { return false; @@ -101168,7 +101622,7 @@ var ts; } return true; } - ts.canWatchDirectory = canWatchDirectory; + ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; var filesWithInvalidatedResolutions; @@ -101177,7 +101631,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolutionsWithOnlyAffectingLocations = []; var resolvedFileToResolution = ts.createMultiMap(); + var impliedFormatPackageJsons = new ts.Map(); var hasChangedAutomaticTypeDirectiveNames = false; + var affectingPathChecksForFile; var affectingPathChecks; var failedLookupChecks; var startsWithPathChecks; @@ -101203,7 +101659,7 @@ var ts; getModuleResolutionCache: function () { return moduleResolutionCache; }, startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions, finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions, - startCachingPerDirectoryResolution: clearPerDirectoryResolutions, + startCachingPerDirectoryResolution: startCachingPerDirectoryResolution, finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution, resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, @@ -101247,7 +101703,10 @@ var ts; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; affectingPathChecks = undefined; - clearPerDirectoryResolutions(); + affectingPathChecksForFile = undefined; + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); + impliedFormatPackageJsons.clear(); hasChangedAutomaticTypeDirectiveNames = false; } function startRecordingFilesWithChangedResolutions() { @@ -101276,15 +101735,41 @@ var ts; return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } - function clearPerDirectoryResolutions() { - moduleResolutionCache.clear(); - typeReferenceDirectiveResolutionCache.clear(); + function startCachingPerDirectoryResolution() { + moduleResolutionCache.clearAllExceptPackageJsonInfoCache(); + typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache(); nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } - function finishCachingPerDirectoryResolution() { + function finishCachingPerDirectoryResolution(newProgram, oldProgram) { filesWithInvalidatedNonRelativeUnresolvedImports = undefined; - clearPerDirectoryResolutions(); + nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); + nonRelativeExternalModuleResolutions.clear(); + if (newProgram !== oldProgram) { + newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) { + var _a, _b, _c; + var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0; + var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray; + for (var i = existing.length; i < expected; i++) { + createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], false); + } + if (existing.length > expected) { + for (var i = expected; i < existing.length; i++) { + fileWatchesOfAffectingLocations.get(existing[i]).files--; + } + } + if (expected) + impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations); + else + impliedFormatPackageJsons.delete(newFile.path); + }); + impliedFormatPackageJsons.forEach(function (existing, path) { + if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) { + existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; }); + impliedFormatPackageJsons.delete(path); + } + }); + } directoryWatchesOfFailedLookups.forEach(function (watcher, path) { if (watcher.refCount === 0) { directoryWatchesOfFailedLookups.delete(path); @@ -101292,10 +101777,9 @@ var ts; } }); fileWatchesOfAffectingLocations.forEach(function (watcher, path) { - if (watcher.refCount === 0) { + if (watcher.files === 0 && watcher.resolutions === 0) { fileWatchesOfAffectingLocations.delete(path); watcher.watcher.close(); - watcher.watcher = ts.noopFileWatcher; } }); hasChangedAutomaticTypeDirectiveNames = false; @@ -101478,7 +101962,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { return { dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator), @@ -101501,7 +101985,7 @@ var ts; dirPath = ts.getDirectoryPath(dirPath); } if (ts.isNodeModulesDirectory(dirPath)) { - return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; + return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; var subDirectoryPath, subDirectory; @@ -101518,7 +102002,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; + return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -101585,46 +102069,64 @@ var ts; resolutionsWithOnlyAffectingLocations.push(resolution); for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) { var affectingLocation = affectingLocations_1[_i]; - createFileWatcherOfAffectingLocation(affectingLocation); + createFileWatcherOfAffectingLocation(affectingLocation, true); } } - function createFileWatcherOfAffectingLocation(affectingLocation) { - var path = resolutionHost.toPath(affectingLocation); - var fileWatcher = fileWatchesOfAffectingLocations.get(path); + function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) { + var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation); if (fileWatcher) { - fileWatcher.refCount++; + if (forResolution) + fileWatcher.resolutions++; + else + fileWatcher.files++; return; } var locationToWatch = affectingLocation; - var locationToWatchPath = path; if (resolutionHost.realpath) { locationToWatch = resolutionHost.realpath(affectingLocation); - locationToWatchPath = resolutionHost.toPath(locationToWatch); - if (path !== locationToWatchPath) { - var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath); + if (affectingLocation !== locationToWatch) { + var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch); if (fileWatcher_1) { - fileWatcher_1.refCount++; - fileWatcher_1.paths.add(path); - fileWatchesOfAffectingLocations.set(path, fileWatcher_1); + if (forResolution) + fileWatcher_1.resolutions++; + else + fileWatcher_1.files++; + fileWatcher_1.paths.add(affectingLocation); + fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1); return; } } } var paths = new ts.Set(); - paths.add(locationToWatchPath); - var watcher = { - watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { - cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind); - paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); }); + paths.add(locationToWatch); + var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ? + resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { + cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind); + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + paths.forEach(function (path) { + if (watcher.resolutions) + (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path); + if (watcher.files) + (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path); + packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path)); + }); resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); - }), - refCount: 1, + }) : ts.noopFileWatcher; + var watcher = { + watcher: actualWatcher !== ts.noopFileWatcher ? { + close: function () { + actualWatcher.close(); + actualWatcher = ts.noopFileWatcher; + } + } : actualWatcher, + resolutions: forResolution ? 1 : 0, + files: forResolution ? 0 : 1, paths: paths, }; - fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher); - if (path !== locationToWatchPath) { - fileWatchesOfAffectingLocations.set(path, watcher); - paths.add(path); + fileWatchesOfAffectingLocations.set(locationToWatch, watcher); + if (affectingLocation !== locationToWatch) { + fileWatchesOfAffectingLocations.set(affectingLocation, watcher); + paths.add(affectingLocation); } } function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) { @@ -101692,8 +102194,8 @@ var ts; } for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) { var affectingLocation = affectingLocations_2[_a]; - var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation)); - watcher.refCount--; + var watcher = fileWatchesOfAffectingLocations.get(affectingLocation); + watcher.resolutions--; } } function removeDirectoryWatcher(dirPath) { @@ -101742,7 +102244,7 @@ var ts; resolution.isInvalidated = invalidated = true; for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) { var containingFilePath = _b[_a]; - (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile); } } @@ -101795,10 +102297,25 @@ var ts; resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { + var _a; + var invalidated = false; + if (affectingPathChecksForFile) { + (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) { + if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) { + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path); + invalidated = true; + } + }); + affectingPathChecksForFile = undefined; + } if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) { - return false; + return invalidated; + } + invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated; + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) { + packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; }); } - var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); failedLookupChecks = undefined; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; @@ -101811,17 +102328,15 @@ var ts; return true; if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) return false; - return resolution.failedLookupLocations.some(function (location) { - var locationPath = resolutionHost.toPath(location); - return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || - ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || - ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); - }); + return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); }); + } + function isInvalidatedFailedLookup(locationPath) { + return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); } function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) { - return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { - return affectingPathChecks.has(resolutionHost.toPath(location)); - }); + return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); }); } function closeTypeRootsWatch() { ts.clearMap(typeRootsWatches, ts.closeFileWatcher); @@ -101867,7 +102382,7 @@ var ts; function directoryExistsForTypeRootWatch(nodeTypesDirectory) { var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory)); var dirPath = resolutionHost.toPath(dir); - return dirPath === rootPath || canWatchDirectory(dirPath); + return dirPath === rootPath || canWatchDirectoryOrFile(dirPath); } } ts.createResolutionCache = createResolutionCache; @@ -101952,7 +102467,7 @@ var ts; var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, undefined, options.overrideImportMode); }) || - getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); + getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { if (options === void 0) { options = {}; } @@ -102023,7 +102538,7 @@ var ts; return nodeModulesSpecifiers; } if (!specifier && !modulePath.isRedirect) { - var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences); + var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); if (ts.pathIsBareSpecifier(local)) { pathsSpecifiers = ts.append(pathsSpecifiers, local); } @@ -102041,7 +102556,7 @@ var ts; var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory }; } - function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) { + function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) { var ending = _a.ending, relativePreference = _a.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; @@ -102055,9 +102570,8 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; + var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions); + var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths; if (!nonRelative) { return relativePath; } @@ -102182,7 +102696,7 @@ var ts; importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules; }); var sortedPaths = []; - var _loop_34 = function (directory) { + var _loop_35 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -102206,7 +102720,7 @@ var ts; }; var out_directory_1; for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { - var state_11 = _loop_34(directory); + var state_11 = _loop_35(directory); directory = out_directory_1; if (state_11 === "break") break; @@ -102254,28 +102768,59 @@ var ts; return ambientModuleDeclare.name.text; } } - function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) { + function getAllowedEndings(preferredEnding, compilerOptions, importMode) { + if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) { + return [2]; + } + switch (preferredEnding) { + case 2: return [2, 0, 1]; + case 1: return [1, 0, 2]; + case 0: return [0, 1, 2]; + default: ts.Debug.assertNever(preferredEnding); + } + } + function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) { for (var key in paths) { - for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { - var patternText_1 = _a[_i]; - var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1)); + var _loop_36 = function (patternText_1) { + var pattern = ts.normalizePath(patternText_1); var indexOfStar = pattern.indexOf("*"); + var candidates = allowedEndings.map(function (ending) { return ({ + ending: ending, + value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) + }); }); + if (ts.tryGetExtensionFromPath(pattern)) { + candidates.push({ ending: undefined, value: relativeToBaseUrl }); + } if (indexOfStar !== -1) { - var prefix = pattern.substr(0, indexOfStar); - var suffix = pattern.substr(indexOfStar + 1); - if (relativeToBaseUrl.length >= prefix.length + suffix.length && - ts.startsWith(relativeToBaseUrl, prefix) && - ts.endsWith(relativeToBaseUrl, suffix) || - !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); - return key.replace("*", matchedStar); + var prefix = pattern.substring(0, indexOfStar); + var suffix = pattern.substring(indexOfStar + 1); + for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) { + var _c = candidates_3[_b], ending = _c.ending, value = _c.value; + if (value.length >= prefix.length + suffix.length && + ts.startsWith(value, prefix) && + ts.endsWith(value, suffix) && + validateEnding({ ending: ending, value: value })) { + var matchedStar = value.substring(prefix.length, value.length - suffix.length); + return { value: key.replace("*", matchedStar) }; + } } } - else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) { - return key; + else if (ts.some(candidates, function (c) { return c.ending !== 0 && pattern === c.value; }) || + ts.some(candidates, function (c) { return c.ending === 0 && pattern === c.value && validateEnding(c); })) { + return { value: key }; } + }; + for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { + var patternText_1 = _a[_i]; + var state_12 = _loop_36(patternText_1); + if (typeof state_12 === "object") + return state_12.value; } } + function validateEnding(_a) { + var ending = _a.ending, value = _a.value; + return ending !== 0 || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host); + } } function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { if (mode === void 0) { mode = 0; } @@ -102358,10 +102903,10 @@ var ts; if (!parts) { return undefined; } + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { - var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; var moduleFileName = void 0; while (true) { @@ -102404,11 +102949,13 @@ var ts; var packageRootPath = path.substring(0, packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); var moduleFileToTry = path; + var maybeBlockedByTypesVersions = false; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); + var importMode = overrideMode || importingSourceFile.impliedNodeFormat; if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { - var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"]; + var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"]; var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions) : undefined; @@ -102427,13 +102974,16 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths); - if (fromPaths !== undefined) { + var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options); + if (fromPaths === undefined) { + maybeBlockedByTypesVersions = true; + } + else { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; - if (ts.isString(mainFileRelative)) { + if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) { var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry }; @@ -102492,7 +103042,7 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); @@ -102582,8 +103132,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -102591,8 +103141,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -102614,7 +103164,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -102647,7 +103197,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -102660,7 +103210,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -102683,7 +103233,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -102710,23 +103260,43 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; - function explainIfFileIsRedirect(file, fileNameConvertor) { + function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) { + var _a; var result; if (file.path !== file.resolvedPath) { - (result || (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor))); + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor))); } if (file.redirectInfo) { - (result || (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor))); + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor))); + } + if (ts.isExternalOrCommonJsModule(file)) { + switch (file.impliedNodeFormat) { + case ts.ModuleKind.ESNext: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + break; + case ts.ModuleKind.CommonJS: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, file.packageJsonScope.packageJsonContent.type ? + ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module : + ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found)); + } + break; + } } return result; } - ts.explainIfFileIsRedirect = explainIfFileIsRedirect; + ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat; function getMatchedFileSpec(program, fileName) { var _a; var configFile = program.getCompilerOptions().configFile; @@ -102752,7 +103322,7 @@ var ts; if (isJsonFile && !ts.endsWith(includeSpec, ".json")) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -102761,7 +103331,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -102874,7 +103444,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -102919,6 +103489,7 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", + AffectingFileLocation: "File location affecting resolution", TypeRoots: "Type roots", ConfigFileOfReferencedProject: "Config file of referened project", ExtendedConfigOfReferencedProject: "Extended config file of referenced project", @@ -102979,7 +103550,6 @@ var ts; readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, - now: ts.maybeBind(host, host.now), }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -103118,7 +103688,6 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - host.now = ts.maybeBind(system, system.now); ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -103169,7 +103738,6 @@ var ts; var parsedConfigs; var sharedExtendedConfigFileWatchers; var extendedConfigCache = host.extendedConfigCache; - var changesAffectResolution = false; var reportFileChangeDetectedOnCreateProgram = false; var sourceFilesCache = new ts.Map(); var missingFilePathsRequestedForRelease; @@ -103199,7 +103767,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -103223,7 +103791,7 @@ var ts; compilerHost.getCompilationSettings = function () { return compilerOptions; }; compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect); compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); }; - compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); }; + compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); }; compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); }; compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; }; compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations; @@ -103254,6 +103822,9 @@ var ts; return host.resolveTypeReferenceDirectives.apply(host, args); }) : (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); }); + compilerHost.getModuleResolutionCache = host.resolveModuleNames ? + ts.maybeBind(host, host.getModuleResolutionCache) : + (function () { return resolutionCache.getModuleResolutionCache(); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); synchronizeProgram(); @@ -103314,11 +103885,11 @@ var ts; var program = getCurrentBuilderProgram(); if (hasChangedCompilerOptions) { newLine = updateNewLine(); - if (program && (changesAffectResolution || ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) { + if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) { resolutionCache.clear(); } } - var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution); + var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { @@ -103334,7 +103905,6 @@ var ts; } createNewProgram(hasInvalidatedResolution); } - changesAffectResolution = false; reportFileChangeDetectedOnCreateProgram = false; if (host.afterProgramCreate && program !== builderProgram) { host.afterProgramCreate(builderProgram); @@ -103343,18 +103913,19 @@ var ts; } function createNewProgram(hasInvalidatedResolution) { writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; resolutionCache.startCachingPerDirectoryResolution(); compilerHost.hasInvalidatedResolution = hasInvalidatedResolution; compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames; + var oldProgram = getCurrentProgram(); builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); - resolutionCache.finishCachingPerDirectoryResolution(); + resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram); ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath); if (needsUpdateInTypeRootWatch) { resolutionCache.updateTypeRootsWatch(); @@ -103424,9 +103995,6 @@ var ts; sourceFilesCache.set(path, false); } } - if (sourceFile) { - sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings()); - } return sourceFile; } return hostSourceFile.sourceFile; @@ -103483,7 +104051,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -103540,7 +104108,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -103578,7 +104146,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -103821,8 +104389,8 @@ var ts; ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -103879,6 +104447,7 @@ var ts; compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); + compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache); var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined; if (!compilerHost.resolveModuleNames) { @@ -104342,8 +104911,7 @@ var ts; }; } var host = state.host, compilerHost = state.compilerHost; - var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; - var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined; + var resultFlags = ((_d = program.hasChangedEmitSignature) === null || _d === void 0 ? void 0 : _d.call(program)) ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged; var emitterDiagnostics = ts.createDiagnosticCollection(); var emittedOutputs = new ts.Map(); var options = program.getCompilerOptions(); @@ -104351,16 +104919,11 @@ var ts; var outputTimeStampMap; var now; outputFiles.forEach(function (_a) { - var _b, _c; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; var path = toPath(state, name); emittedOutputs.set(toPath(state, name), name); - if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, options); - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo === null || existingBuildInfo === void 0 ? void 0 : existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { - resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; - } - } + if (buildInfo) + setBuildInfo(state, buildInfo, projectPath, options, resultFlags); ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); if (!isIncremental && state.watch) { (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host))); @@ -104374,7 +104937,7 @@ var ts; ts.Debug.assert(step === BuildStep.EmitBuildInfo); var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) { if (data === null || data === void 0 ? void 0 : data.buildInfo) - setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions()); + setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions(), BuildResultFlags.DeclarationOutputUnchanged); if (writeFileCallback) writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data); else @@ -104406,7 +104969,6 @@ var ts; state.diagnostics.delete(projectPath); state.projectStatus.set(projectPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath), oldestOutputFileName: oldestOutputFileName }); afterProgramDone(state, program, config); @@ -104446,10 +105008,10 @@ var ts; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; emittedOutputs.set(toPath(state, name), name); if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, config.options); - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { + if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) { resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; } + setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags); } ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); }); @@ -104605,7 +105167,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -104619,7 +105181,7 @@ var ts; } function afterProgramDone(state, program, config) { if (program) { - if (program && state.write) + if (state.write) ts.listFiles(program, state.write); if (state.host.afterProgramEmitAndDiagnostics) { state.host.afterProgramEmitAndDiagnostics(program); @@ -104634,7 +105196,7 @@ var ts; function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) { var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -104698,15 +105260,23 @@ var ts; state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map()); return result; } - function setBuildInfo(state, buildInfo, resolvedConfigPath, options) { + function setBuildInfo(state, buildInfo, resolvedConfigPath, options, resultFlags) { var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath); + var modifiedTime = getCurrentTime(state.host); if (existing) { existing.buildInfo = buildInfo; - existing.modifiedTime = getCurrentTime(state.host); + existing.modifiedTime = modifiedTime; + if (!(resultFlags & BuildResultFlags.DeclarationOutputUnchanged)) + existing.latestChangedDtsTime = modifiedTime; } else { - state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) }); + state.buildInfoCache.set(resolvedConfigPath, { + path: toPath(state, buildInfoPath), + buildInfo: buildInfo, + modifiedTime: modifiedTime, + latestChangedDtsTime: resultFlags & BuildResultFlags.DeclarationOutputUnchanged ? undefined : modifiedTime, + }); } } function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) { @@ -104737,7 +105307,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { - var _a, _b, _c; + var _a, _b; if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) { return { type: ts.UpToDateStatusType.ContainerOnly @@ -104747,8 +105317,8 @@ var ts; var force = !!state.options.force; if (project.projectReferences) { state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream }); - for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) { - var ref = _d[_i]; + for (var _i = 0, _c = project.projectReferences; _i < _c.length; _i++) { + var ref = _c[_i]; var resolvedRef = ts.resolveProjectReferencePath(ref); var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef); var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath); @@ -104784,7 +105354,6 @@ var ts; var buildInfoTime; var buildInfoProgram; var buildInfoVersionMap; - var newestDeclarationFileContentChangedTime; if (buildInfoPath) { var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath); buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath); @@ -104820,18 +105389,17 @@ var ts; } oldestOutputFileTime = buildInfoTime; oldestOutputFileName = buildInfoPath; - newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; } var newestInputFileName = undefined; var newestInputFileTime = minimumDate; var pseudoInputUpToDate = false; - for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) { - var inputFile = _f[_e]; + for (var _d = 0, _e = project.fileNames; _d < _e.length; _d++) { + var inputFile = _e[_d]; var inputTime = getModifiedTime(state, inputFile); if (inputTime === ts.missingFileModifiedTime) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } if (buildInfoTime && buildInfoTime < inputTime) { @@ -104862,8 +105430,8 @@ var ts; if (!buildInfoPath) { var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath); - for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) { - var output = outputs_1[_g]; + for (var _f = 0, outputs_1 = outputs; _f < outputs_1.length; _f++) { + var output = outputs_1[_f]; var path = toPath(state, output); var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path); if (!outputTime) { @@ -104896,8 +105464,8 @@ var ts; var usesPrepend = false; var upstreamChangedProject; if (referenceStatuses) { - for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) { - var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath; + for (var _g = 0, referenceStatuses_1 = referenceStatuses; _g < referenceStatuses_1.length; _g++) { + var _h = referenceStatuses_1[_g], ref = _h.ref, refStatus = _h.refStatus, resolvedConfig = _h.resolvedConfig, resolvedRefPath = _h.resolvedRefPath; usesPrepend = usesPrepend || !!(ref.prepend); if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) { continue; @@ -104909,7 +105477,8 @@ var ts; newerProjectName: ref.path }; } - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + var newestDeclarationFileContentChangedTime = getLatestChangedDtsTime(state, resolvedConfig.options, resolvedRefPath); + if (newestDeclarationFileContentChangedTime && newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -104947,7 +105516,6 @@ var ts; pseudoInputUpToDate ? ts.UpToDateStatusType.UpToDateWithInputFileText : ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, newestInputFileTime: newestInputFileTime, newestInputFileName: newestInputFileName, oldestOutputFileName: oldestOutputFileName @@ -105026,13 +105594,17 @@ var ts; outputTimeStampMap.delete(key); }); } - function getDtsChangeTime(state, options, resolvedConfigPath) { - var _a; + function getLatestChangedDtsTime(state, options, resolvedConfigPath) { if (!options.composite) return undefined; - var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); - var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, undefined); - return ((_a = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.program) === null || _a === void 0 ? void 0 : _a.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; + var entry = ts.Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath)); + if (entry.latestChangedDtsTime !== undefined) + return entry.latestChangedDtsTime || undefined; + var latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ? + state.host.getModifiedTime(ts.getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, ts.getDirectoryPath(entry.path))) : + undefined; + entry.latestChangedDtsTime = latestChangedDtsTime || false; + return latestChangedDtsTime; } function updateOutputTimestamps(state, proj, resolvedPath) { if (state.options.dry) { @@ -105041,7 +105613,6 @@ var ts; updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0); state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath), oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames()) }); } @@ -105168,7 +105739,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -105528,7 +106099,7 @@ var ts; }; } function bold(str) { - return "\u001B[1m" + str + "\u001B[22m"; + return "\u001B[1m".concat(str, "\u001B[22m"); } var isWindows = sys.getEnvironmentVariable("OS") && ts.stringContains(sys.getEnvironmentVariable("OS").toLowerCase(), "windows"); var isWindowsTerminal = sys.getEnvironmentVariable("WT_SESSION"); @@ -105537,19 +106108,19 @@ var ts; if (isWindows && !isWindowsTerminal && !isVSCode) { return brightWhite(str); } - return "\u001B[94m" + str + "\u001B[39m"; + return "\u001B[94m".concat(str, "\u001B[39m"); } var supportsRicherColors = sys.getEnvironmentVariable("COLORTERM") === "truecolor" || sys.getEnvironmentVariable("TERM") === "xterm-256color"; function blueBackground(str) { if (supportsRicherColors) { - return "\u001B[48;5;68m" + str + "\u001B[39;49m"; + return "\u001B[48;5;68m".concat(str, "\u001B[39;49m"); } else { - return "\u001B[44m" + str + "\u001B[39;49m"; + return "\u001B[44m".concat(str, "\u001B[39;49m"); } } function brightWhite(str) { - return "\u001B[97m" + str + "\u001B[39m"; + return "\u001B[97m".concat(str, "\u001B[39m"); } return { bold: bold, @@ -105559,7 +106130,7 @@ var ts; }; } function getDisplayNameTextOfOption(option) { - return "--" + option.name + (option.shortName ? ", -" + option.shortName : ""); + return "--".concat(option.name).concat(option.shortName ? ", -".concat(option.shortName) : ""); } function generateOptionOutput(sys, option, rightAlignOfLeft, leftAlignOfRight) { var _a, _b; @@ -105596,13 +106167,13 @@ var ts; text.push(sys.newLine); if (showAdditionalInfoOutput(valueCandidates, option)) { if (valueCandidates) { - text.push(valueCandidates.valueType + " " + valueCandidates.possibleValues); + text.push("".concat(valueCandidates.valueType, " ").concat(valueCandidates.possibleValues)); } if (defaultValueDescription) { if (valueCandidates) text.push(sys.newLine); var diagType = ts.getDiagnosticText(ts.Diagnostics.default_Colon); - text.push(diagType + " " + defaultValueDescription); + text.push("".concat(diagType, " ").concat(defaultValueDescription)); } text.push(sys.newLine); } @@ -105651,7 +106222,7 @@ var ts; } var curRight = remainRight.substr(0, rightCharacterNumber); remainRight = remainRight.slice(rightCharacterNumber); - res.push("" + curLeft + curRight); + res.push("".concat(curLeft).concat(curRight)); isFirstLine = false; } return res; @@ -105752,7 +106323,7 @@ var ts; categoryMap.set(curCategory, optionsOfCurCategory); } categoryMap.forEach(function (value, key) { - res.push("### " + key + sys.newLine + sys.newLine); + res.push("### ".concat(key).concat(sys.newLine).concat(sys.newLine)); res = __spreadArray(__spreadArray([], res, true), generateGroupOptionOutput(sys, value), true); }); if (afterOptionsDescription) { @@ -105762,7 +106333,7 @@ var ts; } function printEasyHelp(sys, simpleOptions) { var colors = createColors(sys); - var output = __spreadArray([], getHeader(sys, ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler) + " - " + ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version)), true); + var output = __spreadArray([], getHeader(sys, "".concat(ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler), " - ").concat(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version))), true); output.push(colors.bold(ts.getDiagnosticText(ts.Diagnostics.COMMON_COMMANDS)) + sys.newLine + sys.newLine); example("tsc", ts.Diagnostics.Compiles_the_current_project_tsconfig_json_in_the_working_directory); example("tsc app.ts util.ts", ts.Diagnostics.Ignoring_tsconfig_json_compiles_the_specified_files_with_default_compiler_options); @@ -105788,7 +106359,7 @@ var ts; } } function printAllHelp(sys, compilerOptions, buildOptions, watchOptions) { - var output = __spreadArray([], getHeader(sys, ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler) + " - " + ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version)), true); + var output = __spreadArray([], getHeader(sys, "".concat(ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler), " - ").concat(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version))), true); output = __spreadArray(__spreadArray([], output, true), generateSectionOptionsOutput(sys, ts.getDiagnosticText(ts.Diagnostics.ALL_COMPILER_OPTIONS), compilerOptions, true, undefined, ts.formatMessage(undefined, ts.Diagnostics.You_can_learn_about_all_of_the_compiler_options_at_0, "https://aka.ms/tsc")), true); output = __spreadArray(__spreadArray([], output, true), generateSectionOptionsOutput(sys, ts.getDiagnosticText(ts.Diagnostics.WATCH_OPTIONS), watchOptions, false, ts.getDiagnosticText(ts.Diagnostics.Including_watch_w_will_start_watching_the_current_project_for_the_file_changes_Once_set_you_can_config_watch_mode_with_Colon)), true); output = __spreadArray(__spreadArray([], output, true), generateSectionOptionsOutput(sys, ts.getDiagnosticText(ts.Diagnostics.BUILD_OPTIONS), buildOptions, false, ts.formatMessage(undefined, ts.Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds")), true); @@ -105798,7 +106369,7 @@ var ts; } } function printBuildHelp(sys, buildOptions) { - var output = __spreadArray([], getHeader(sys, ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler) + " - " + ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version)), true); + var output = __spreadArray([], getHeader(sys, "".concat(ts.getDiagnosticText(ts.Diagnostics.tsc_Colon_The_TypeScript_Compiler), " - ").concat(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version))), true); output = __spreadArray(__spreadArray([], output, true), generateSectionOptionsOutput(sys, ts.getDiagnosticText(ts.Diagnostics.BUILD_OPTIONS), buildOptions, false, ts.formatMessage(undefined, ts.Diagnostics.Using_build_b_will_make_tsc_behave_more_like_a_build_orchestrator_than_a_compiler_This_is_used_to_trigger_building_composite_projects_which_you_can_learn_more_about_at_0, "https://aka.ms/tsc-composite-builds")), true); for (var _i = 0, output_3 = output; _i < output_3.length; _i++) { var line = output_3[_i]; @@ -106179,7 +106750,7 @@ var ts; reportCountStatistic("Subtype cache size", caches.subtype); reportCountStatistic("Strict subtype cache size", caches.strictSubtype); if (isPerformanceEnabled) { - ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic(name + " time", duration); }); + ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic("".concat(name, " time"), duration); }); } } else if (isPerformanceEnabled) { @@ -106251,7 +106822,7 @@ var ts; // enable deprecation logging ts.Debug.loggingHost = { log: function (_level, s) { - ts.sys.write("" + (s || "") + ts.sys.newLine); + ts.sys.write("".concat(s || "").concat(ts.sys.newLine)); } }; if (ts.Debug.isDebugging) { diff --git a/lib/tsserver.js b/lib/tsserver.js index 4da75523ad795..21accd494a376 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -22,7 +22,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -109,7 +109,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "4.8.1-rc"; /* @internal */ var Comparison; (function (Comparison) { @@ -156,7 +156,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); /* @internal */ @@ -856,9 +856,9 @@ var ts; case true: // relational comparison // falls through - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: continue; - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If `array` is sorted, `next` should **never** be less than `last`. return ts.Debug.fail("Array is unsorted."); } @@ -894,7 +894,7 @@ var ts; var prevElement = array[0]; for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) { var element = _a[_i]; - if (comparer(prevElement, element) === 1 /* GreaterThan */) { + if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) { return false; } prevElement = element; @@ -948,27 +948,27 @@ var ts; loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) { if (offsetB > 0) { // Ensure `arrayB` is properly sorted. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */); } loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) { if (offsetA > startA) { // Ensure `arrayA` is properly sorted. We only need to perform this check if // `offsetA` has changed since we entered the loop. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */); } switch (comparer(arrayB[offsetB], arrayA[offsetA])) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If B is less than A, B does not exist in arrayA. Add B to the result and // move to the next element in arrayB without changing the current position // in arrayA. result.push(arrayB[offsetB]); continue loopB; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: // If B is equal to A, B exists in arrayA. Move to the next element in // arrayB without adding B to the result or changing the current position // in arrayA. continue loopB; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: // If B is greater than A, we need to keep looking for B in arrayA. Move to // the next element in arrayA and recheck. continue loopA; @@ -1208,12 +1208,12 @@ var ts; var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle], middle); switch (keyComparer(midKey, key)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: low = middle + 1; break; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: return middle; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: high = middle - 1; break; } @@ -1485,6 +1485,43 @@ var ts; return createMultiMap(); } ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap; + function createQueue(items) { + var elements = (items === null || items === void 0 ? void 0 : items.slice()) || []; + var headIndex = 0; + function isEmpty() { + return headIndex === elements.length; + } + function enqueue() { + var items = []; + for (var _i = 0; _i < arguments.length; _i++) { + items[_i] = arguments[_i]; + } + elements.push.apply(elements, items); + } + function dequeue() { + if (isEmpty()) { + throw new Error("Queue is empty"); + } + var result = elements[headIndex]; + elements[headIndex] = undefined; // Don't keep referencing dequeued item + headIndex++; + // If more than half of the queue is empty, copy the remaining elements to the + // front and shrink the array (unless we'd be saving fewer than 100 slots) + if (headIndex > 100 && headIndex > (elements.length >> 1)) { + var newLength = elements.length - headIndex; + elements.copyWithin(/*target*/ 0, /*start*/ headIndex); + elements.length = newLength; + headIndex = 0; + } + return result; + } + return { + enqueue: enqueue, + dequeue: dequeue, + isEmpty: isEmpty, + }; + } + ts.createQueue = createQueue; /** * Creates a Set with custom equality and hash code functionality. This is useful when you * want to use something looser than object identity - e.g. "has the same span". @@ -1667,12 +1704,16 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; /** Does nothing. */ function noop(_) { } ts.noop = noop; + ts.noopPush = { + push: noop, + length: 0 + }; /** Do nothing and return false */ function returnFalse() { return false; @@ -1758,7 +1799,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -1830,11 +1871,11 @@ var ts; } ts.equateStringsCaseSensitive = equateStringsCaseSensitive; function compareComparableValues(a, b) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + a < b ? -1 /* Comparison.LessThan */ : + 1 /* Comparison.GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -1852,7 +1893,7 @@ var ts; } ts.compareTextSpans = compareTextSpans; function min(a, b, compare) { - return compare(a, b) === -1 /* LessThan */ ? a : b; + return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b; } ts.min = min; /** @@ -1869,14 +1910,14 @@ var ts; */ function compareStringsCaseInsensitive(a, b) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; a = a.toUpperCase(); b = b.toUpperCase(); - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive; /** @@ -1907,13 +1948,13 @@ var ts; return createStringComparer; function compareWithCallback(a, b, comparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; var value = comparer(a, b); - return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } function createIntlCollatorStringComparer(locale) { // Intl.Collator.prototype.compare is bound to the collator. See NOTE in @@ -1943,7 +1984,7 @@ var ts; return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b); } function compareStrings(a, b) { - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } } function getStringComparerFactory() { @@ -2004,9 +2045,9 @@ var ts; } ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI; function compareProperties(a, b, key, comparer) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : comparer(a[key], b[key]); } ts.compareProperties = compareProperties; @@ -2028,7 +2069,7 @@ var ts; * and 1 insertion/deletion at 3 characters) */ function getSpellingSuggestion(name, candidates, getName) { - var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34)); + var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34)); var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother. var bestCandidate; for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { @@ -2125,24 +2166,24 @@ var ts; var end = fileName.length; for (var pos = end - 1; pos > 0; pos--) { var ch = fileName.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) { // Match a \d+ segment do { --pos; ch = fileName.charCodeAt(pos); - } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */); } - else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) { // Looking for "min" or "min" // Already matched the 'n' --pos; ch = fileName.charCodeAt(pos); - if (ch !== 105 /* i */ && ch !== 73 /* I */) { + if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) { break; } --pos; ch = fileName.charCodeAt(pos); - if (ch !== 109 /* m */ && ch !== 77 /* M */) { + if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) { break; } --pos; @@ -2152,7 +2193,7 @@ var ts; // This character is not part of either suffix pattern break; } - if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) { break; } end = pos; @@ -2208,7 +2249,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; /** @@ -2309,12 +2350,12 @@ var ts; var newItem = newItems[newIndex]; var oldItem = oldItems[oldIndex]; var compareResult = comparer(newItem, oldItem); - if (compareResult === -1 /* LessThan */) { + if (compareResult === -1 /* Comparison.LessThan */) { inserted(newItem); newIndex++; hasChanges = true; } - else if (compareResult === 1 /* GreaterThan */) { + else if (compareResult === 1 /* Comparison.GreaterThan */) { deleted(oldItem); oldIndex++; hasChanges = true; @@ -2445,7 +2486,7 @@ var ts; (function (Debug) { var typeScriptVersion; /* eslint-disable prefer-const */ - var currentAssertionLevel = 0 /* None */; + var currentAssertionLevel = 0 /* AssertionLevel.None */; Debug.currentLogLevel = LogLevel.Warning; Debug.isDebugging = false; function getTypeScriptVersion() { @@ -2524,7 +2565,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2532,12 +2573,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2547,26 +2588,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2597,42 +2638,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2653,7 +2694,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; /** @@ -2757,6 +2798,22 @@ var ts; return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true); } Debug.formatFlowFlags = formatFlowFlags; + function formatRelationComparisonResult(result) { + return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true); + } + Debug.formatRelationComparisonResult = formatRelationComparisonResult; + function formatCheckMode(mode) { + return formatEnum(mode, ts.CheckMode, /*isFlags*/ true); + } + Debug.formatCheckMode = formatCheckMode; + function formatSignatureCheckMode(mode) { + return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true); + } + Debug.formatSignatureCheckMode = formatSignatureCheckMode; + function formatTypeFacts(facts) { + return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true); + } + Debug.formatTypeFacts = formatTypeFacts; var isDebugInfoEnabled = false; var extendedDebugModule; function extendedDebug() { @@ -2781,20 +2838,20 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" : - this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" : - this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" : - this.flags & 16 /* Assignment */ ? "FlowAssignment" : - this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" : - this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" : - this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" : - this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" : - this.flags & 512 /* Call */ ? "FlowCall" : - this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" : - this.flags & 1 /* Unreachable */ ? "FlowUnreachable" : + var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" : + this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" : + this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" : + this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" : "UnknownFlow"; - var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, @@ -2833,7 +2890,7 @@ var ts; // We don't care, this is debug code that's only enabled with a debugger attached - // we're just taking note of it for anyone checking regex performance in the future. defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -2885,10 +2942,10 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" : + var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" : "Symbol"; - var remainingSymbolFlags = this.flags & ~33554432 /* Transient */; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */; + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -2897,35 +2954,35 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" : - this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 /* BigIntLiteral */ ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : - this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : - this.flags & 32 /* Enum */ ? "EnumType" : - this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType " + this.intrinsicName : - this.flags & 1048576 /* Union */ ? "UnionType" : - this.flags & 2097152 /* Intersection */ ? "IntersectionType" : - this.flags & 4194304 /* Index */ ? "IndexType" : - this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : - this.flags & 16777216 /* Conditional */ ? "ConditionalType" : - this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : - this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : - this.flags & 524288 /* Object */ ? - this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : - this.objectFlags & 4 /* Reference */ ? "TypeReference" : - this.objectFlags & 8 /* Tuple */ ? "TupleType" : - this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : - this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : - this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : + var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" : + this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : + this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" : + this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) : + this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" : + this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" : + this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* TypeFlags.Object */ ? + this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" : + this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" : + this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" : + this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0; + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { // avoid recomputing @@ -2957,11 +3014,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -2993,7 +3050,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -3040,10 +3097,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -3087,6 +3144,48 @@ var ts; return wrapFunction(deprecation, func); } Debug.deprecate = deprecate; + function formatVariance(varianceFlags) { + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; + var result = variance === 0 /* VarianceFlags.Invariant */ ? "in out" : + variance === 3 /* VarianceFlags.Bivariant */ ? "[bivariant]" : + variance === 2 /* VarianceFlags.Contravariant */ ? "in" : + variance === 1 /* VarianceFlags.Covariant */ ? "out" : + variance === 4 /* VarianceFlags.Independent */ ? "[independent]" : ""; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { + result += " (unmeasurable)"; + } + else if (varianceFlags & 16 /* VarianceFlags.Unreliable */) { + result += " (unreliable)"; + } + return result; + } + Debug.formatVariance = formatVariance; + var DebugTypeMapper = /** @class */ (function () { + function DebugTypeMapper() { + } + DebugTypeMapper.prototype.__debugToString = function () { + var _a; + type(this); + switch (this.kind) { + case 3 /* TypeMapKind.Function */: return ((_a = this.debugInfo) === null || _a === void 0 ? void 0 : _a.call(this)) || "(function mapper)"; + case 0 /* TypeMapKind.Simple */: return "".concat(this.source.__debugTypeToString(), " -> ").concat(this.target.__debugTypeToString()); + case 1 /* TypeMapKind.Array */: return ts.zipWith(this.sources, this.targets || ts.map(this.sources, function () { return "any"; }), function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(typeof t === "string" ? t : t.__debugTypeToString()); }).join(", "); + case 2 /* TypeMapKind.Deferred */: return ts.zipWith(this.sources, this.targets, function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(t().__debugTypeToString()); }).join(", "); + case 5 /* TypeMapKind.Merged */: + case 4 /* TypeMapKind.Composite */: return "m1: ".concat(this.mapper1.__debugToString().split("\n").join("\n "), "\nm2: ").concat(this.mapper2.__debugToString().split("\n").join("\n ")); + default: return assertNever(this); + } + }; + return DebugTypeMapper; + }()); + Debug.DebugTypeMapper = DebugTypeMapper; + function attachDebugPrototypeIfDebug(mapper) { + if (Debug.isDebugging) { + return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype); + } + return mapper; + } + Debug.attachDebugPrototypeIfDebug = attachDebugPrototypeIfDebug; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); /* @internal */ @@ -3159,9 +3258,9 @@ var ts; // https://semver.org/#spec-item-11 // > Build metadata does not figure into precedence if (this === other) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (other === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; return ts.compareValues(this.major, other.major) || ts.compareValues(this.minor, other.minor) || ts.compareValues(this.patch, other.patch) @@ -3176,11 +3275,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -3209,11 +3308,11 @@ var ts; // > When major, minor, and patch are equal, a pre-release version has lower precedence // > than a normal version. if (left === right) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (left.length === 0) - return right.length === 0 ? 0 /* EqualTo */ : 1 /* GreaterThan */; + return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */; if (right.length === 0) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; // https://semver.org/#spec-item-11 // > Precedence for two pre-release versions with the same major, minor, and patch version // > MUST be determined by comparing each dot separated identifier from left to right until @@ -3230,7 +3329,7 @@ var ts; // https://semver.org/#spec-item-11 // > Numeric identifiers always have lower precedence than non-numeric identifiers. if (leftIsNumeric !== rightIsNumeric) - return leftIsNumeric ? -1 /* LessThan */ : 1 /* GreaterThan */; + return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; // https://semver.org/#spec-item-11 // > identifiers consisting of only digits are compared numerically var result = ts.compareValues(+leftIdentifier, +rightIdentifier); @@ -3447,7 +3546,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); /*@internal*/ @@ -3745,7 +3844,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3757,11 +3856,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -3828,9 +3927,9 @@ var ts; eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } tracingEnabled.push = push; - function pop() { + function pop(results) { ts.Debug.assert(eventStack.length > 0); - writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); + writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results); eventStack.length--; } tracingEnabled.pop = pop; @@ -3844,27 +3943,28 @@ var ts; tracingEnabled.popAll = popAll; // sample every 10ms var sampleInterval = 1000 * 10; - function writeStackEvent(index, endTime) { + function writeStackEvent(index, endTime, results) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { + ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`"); writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); } // test if [time,endTime) straddles a sampling point else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === "server" && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */) return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -3900,7 +4000,7 @@ var ts; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) var display = void 0; - if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { + if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) { try { display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } @@ -3909,7 +4009,7 @@ var ts; } } var indexedAccessProperties = {}; - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, @@ -3917,7 +4017,7 @@ var ts; }; } var referenceProperties = {}; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { var referenceType = type; referenceProperties = { instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, @@ -3926,7 +4026,7 @@ var ts; }; } var conditionalProperties = {}; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var conditionalType = type; conditionalProperties = { conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, @@ -3936,7 +4036,7 @@ var ts; }; } var substitutionProperties = {}; - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { var substitutionType = type; substitutionProperties = { substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, @@ -3944,7 +4044,7 @@ var ts; }; } var reverseMappedProperties = {}; - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { var reverseMappedType = type; reverseMappedProperties = { reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, @@ -3953,7 +4053,7 @@ var ts; }; } var evolvingArrayProperties = {}; - if (objectFlags & 256 /* EvolvingArray */) { + if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) { var evolvingArrayType = type; evolvingArrayProperties = { evolvingArrayElementType: evolvingArrayType.elementType.id, @@ -3971,7 +4071,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -4692,6 +4792,7 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; @@ -4732,6 +4833,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter"; // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -4743,7 +4845,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; /** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 814775659] = "NodeBuilderFlagsMask"; + TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -5222,9 +5324,10 @@ var ts; (function (TypeMapKind) { TypeMapKind[TypeMapKind["Simple"] = 0] = "Simple"; TypeMapKind[TypeMapKind["Array"] = 1] = "Array"; - TypeMapKind[TypeMapKind["Function"] = 2] = "Function"; - TypeMapKind[TypeMapKind["Composite"] = 3] = "Composite"; - TypeMapKind[TypeMapKind["Merged"] = 4] = "Merged"; + TypeMapKind[TypeMapKind["Deferred"] = 2] = "Deferred"; + TypeMapKind[TypeMapKind["Function"] = 3] = "Function"; + TypeMapKind[TypeMapKind["Composite"] = 4] = "Composite"; + TypeMapKind[TypeMapKind["Merged"] = 5] = "Merged"; })(TypeMapKind = ts.TypeMapKind || (ts.TypeMapKind = {})); var InferencePriority; (function (InferencePriority) { @@ -5619,10 +5722,8 @@ var ts; TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait"; TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper"; TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier"; - // Please leave this as 1 << 29. - // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. - // It is a good reminder of how much room we have left - TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["ContainsPrivateIdentifierInExpression"] = 536870912] = "ContainsPrivateIdentifierInExpression"; + TransformFlags[TransformFlags["HasComputedFlags"] = -2147483648] = "HasComputedFlags"; // Assertions // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript"; @@ -5641,23 +5742,23 @@ var ts; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes"; - TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes"; - TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes"; + TransformFlags[TransformFlags["OuterExpressionExcludes"] = -2147483648] = "OuterExpressionExcludes"; + TransformFlags[TransformFlags["PropertyAccessExcludes"] = -2147483648] = "PropertyAccessExcludes"; + TransformFlags[TransformFlags["NodeExcludes"] = -2147483648] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = -2072174592] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = -1937940480] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = -1937948672] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = -2005057536] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = -2013249536] = "PropertyExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = -2147344384] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = -1941676032] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes"; - TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; - TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes"; - TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = -2147278848] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = -2147450880] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = -2146893824] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = -2147483648] = "ParameterExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = -2147418112] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = -2147450880] = "BindingPatternExcludes"; TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper"; // Propagating flags // - Bitmasks for flags that should propagate from a child @@ -5910,37 +6011,37 @@ var ts; { name: "no-default-lib", optional: true }, { name: "resolution-mode", optional: true } ], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-dependency": { args: [{ name: "path" }, { name: "name", optional: true }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-module": { args: [{ name: "name" }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "ts-check": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "ts-nocheck": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "jsx": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxfrag": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsximportsource": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxruntime": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, }; })(ts || (ts = {})); @@ -6012,7 +6113,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -6229,7 +6330,7 @@ var ts; }; } function createDirectoryWatcher(dirName, dirPath, fallbackOptions) { - var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) { + var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName, modifiedTime) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" if (!ts.isString(relativeFileName)) return; @@ -6457,7 +6558,7 @@ var ts; function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) { // Iterate through existing children and update the watches if needed var parentWatcher = cache.get(dirPath); - if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) { + if (parentWatcher && fileSystemEntryExists(dirName, 1 /* FileSystemEntryKind.Directory */)) { // Schedule the update and postpone invoke for callbacks scheduleUpdateChildWatches(dirName, dirPath, fileName, options); return; @@ -6482,7 +6583,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -6495,7 +6596,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -6511,7 +6612,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -6530,11 +6631,11 @@ var ts; if (!parentWatcher) return false; var newChildWatches; - var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) { + var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* FileSystemEntryKind.Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) { var childFullName = ts.getNormalizedAbsolutePath(child, parentDir); // Filter our the symbolic link directories since those arent included in recursive watch // which is same behaviour when recursive: true is passed to fs.watch - return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : undefined; + return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* Comparison.EqualTo */ ? childFullName : undefined; }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher); parentWatcher.childWatches = newChildWatches || ts.emptyArray; return hasChanges; @@ -6632,7 +6733,7 @@ var ts; case ts.WatchFileKind.FixedChunkSizePolling: return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: - return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime), + return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); case ts.WatchFileKind.UseFsEventsOnParentDirectory: if (!nonPollingWatchFile) { @@ -6687,7 +6788,7 @@ var ts; } function watchDirectory(directoryName, callback, recursive, options) { if (fsSupportsRecursiveFsWatch) { - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); } if (!hostRecursiveDirectoryWatcher) { hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({ @@ -6719,7 +6820,7 @@ var ts; /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchDirectoryKind.UseFsEvents: - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: ts.Debug.assertNever(watchDirectoryKind); } @@ -6758,14 +6859,16 @@ var ts; return { close: function () { // Close the watcher (either existing file system entry watcher or missing file system entry watcher) - watcher.close(); - watcher = undefined; + if (watcher) { + watcher.close(); + watcher = undefined; + } } }; function updateWatcher(createWatcher) { // If watcher is not closed, update it if (watcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); watcher.close(); watcher = createWatcher(); } @@ -6776,7 +6879,7 @@ var ts; */ function watchPresentFileSystemEntry() { if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -6795,7 +6898,7 @@ var ts; // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -7090,7 +7193,7 @@ var ts; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -7099,7 +7202,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -7115,7 +7218,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -7313,8 +7416,8 @@ var ts; return false; } switch (entryKind) { - case 0 /* File */: return stat.isFile(); - case 1 /* Directory */: return stat.isDirectory(); + case 0 /* FileSystemEntryKind.File */: return stat.isFile(); + case 1 /* FileSystemEntryKind.Directory */: return stat.isDirectory(); default: return false; } } @@ -7326,10 +7429,10 @@ var ts; } } function fileExists(path) { - return fileSystemEntryExists(path, 0 /* File */); + return fileSystemEntryExists(path, 0 /* FileSystemEntryKind.File */); } function directoryExists(path) { - return fileSystemEntryExists(path, 1 /* Directory */); + return fileSystemEntryExists(path, 1 /* FileSystemEntryKind.Directory */); } function getDirectories(path) { return getAccessibleFileSystemEntries(path).directories.slice(); @@ -7400,8 +7503,8 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* AssertionLevel.Normal */ + : 0 /* AssertionLevel.None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7424,7 +7527,7 @@ var ts; * Determines whether a charCode corresponds to `/` or `\`. */ function isAnyDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */; } ts.isAnyDirectorySeparator = isAnyDirectorySeparator; /** @@ -7511,16 +7614,16 @@ var ts; ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; //// Path Parsing function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) || + (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */); } function getFileUrlVolumeSeparatorEnd(url, start) { var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) + if (ch0 === 58 /* CharacterCodes.colon */) return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) { var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */) return start + 3; } return -1; @@ -7534,18 +7637,18 @@ var ts; return 0; var ch0 = path.charCodeAt(0); // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) { if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); + var p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); if (p1 < 0) return path.length; // UNC: "//server" or "\\server" return p1 + 1; // UNC: "//server/" or "\\server\" } // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) { var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */) return 3; // DOS: "c:/" or "c:\" if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") @@ -7565,7 +7668,7 @@ var ts; isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) { // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" return ~(volumeSeparatorEnd + 1); } @@ -7642,7 +7745,7 @@ var ts; function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { if (!ts.startsWith(extension, ".")) extension = "." + extension; - if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) { var pathExtension = path.slice(path.length - extension.length); if (stringEqualityComparer(pathExtension, extension)) { return pathExtension; @@ -7926,17 +8029,17 @@ var ts; var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; // NOTE: Performance optimization - shortcut if the root segments differ as there would be no // need to perform path reduction. var aRoot = a.substring(0, getRootLength(a)); var bRoot = b.substring(0, getRootLength(b)); var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { + if (result !== 0 /* Comparison.EqualTo */) { return result; } // NOTE: Performance optimization - shortcut if there are no relative path segments in @@ -7953,7 +8056,7 @@ var ts; var sharedLength = Math.min(aComponents.length, bComponents.length); for (var i = 1; i < sharedLength; i++) { var result_2 = componentComparer(aComponents[i], bComponents[i]); - if (result_2 !== 0 /* EqualTo */) { + if (result_2 !== 0 /* Comparison.EqualTo */) { return result_2; } } @@ -8468,13 +8571,24 @@ var ts; resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."), Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"), + File_is_ECMAScript_module_because_0_has_field_type_with_value_module: diag(1458, ts.DiagnosticCategory.Message, "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458", "File is ECMAScript module because '{0}' has field \"type\" with value \"module\""), + File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module: diag(1459, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459", "File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\""), + File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""), + File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"), The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."), - Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."), + Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead."), catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."), An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), + An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."), + Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."), + The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead: diag(1479, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_reference_1479", "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"{0}\")' call instead."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module: diag(1480, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_packag_1480", "To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1: diag(1481, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Co_1481", "To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'."), + To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0: diag(1482, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0_1482", "To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'."), + To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module: diag(1483, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module_1483", "To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -8688,6 +8802,7 @@ var ts; Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."), Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."), Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."), + A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, ts.DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."), Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."), All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."), Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."), @@ -8975,6 +9090,7 @@ var ts; The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), + Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), 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}'."), @@ -9954,100 +10070,100 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 79 /* Identifier */; + return token >= 79 /* SyntaxKind.Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* SyntaxKind.GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; /** @internal */ ts.textToKeywordObj = (_a = { - abstract: 126 /* AbstractKeyword */, - any: 130 /* AnyKeyword */, - as: 127 /* AsKeyword */, - asserts: 128 /* AssertsKeyword */, - assert: 129 /* AssertKeyword */, - bigint: 158 /* BigIntKeyword */, - boolean: 133 /* BooleanKeyword */, - break: 81 /* BreakKeyword */, - case: 82 /* CaseKeyword */, - catch: 83 /* CatchKeyword */, - class: 84 /* ClassKeyword */, - continue: 86 /* ContinueKeyword */, - const: 85 /* ConstKeyword */ + abstract: 126 /* SyntaxKind.AbstractKeyword */, + any: 130 /* SyntaxKind.AnyKeyword */, + as: 127 /* SyntaxKind.AsKeyword */, + asserts: 128 /* SyntaxKind.AssertsKeyword */, + assert: 129 /* SyntaxKind.AssertKeyword */, + bigint: 158 /* SyntaxKind.BigIntKeyword */, + boolean: 133 /* SyntaxKind.BooleanKeyword */, + break: 81 /* SyntaxKind.BreakKeyword */, + case: 82 /* SyntaxKind.CaseKeyword */, + catch: 83 /* SyntaxKind.CatchKeyword */, + class: 84 /* SyntaxKind.ClassKeyword */, + continue: 86 /* SyntaxKind.ContinueKeyword */, + const: 85 /* SyntaxKind.ConstKeyword */ }, - _a["" + "constructor"] = 134 /* ConstructorKeyword */, - _a.debugger = 87 /* DebuggerKeyword */, - _a.declare = 135 /* DeclareKeyword */, - _a.default = 88 /* DefaultKeyword */, - _a.delete = 89 /* DeleteKeyword */, - _a.do = 90 /* DoKeyword */, - _a.else = 91 /* ElseKeyword */, - _a.enum = 92 /* EnumKeyword */, - _a.export = 93 /* ExportKeyword */, - _a.extends = 94 /* ExtendsKeyword */, - _a.false = 95 /* FalseKeyword */, - _a.finally = 96 /* FinallyKeyword */, - _a.for = 97 /* ForKeyword */, - _a.from = 156 /* FromKeyword */, - _a.function = 98 /* FunctionKeyword */, - _a.get = 136 /* GetKeyword */, - _a.if = 99 /* IfKeyword */, - _a.implements = 117 /* ImplementsKeyword */, - _a.import = 100 /* ImportKeyword */, - _a.in = 101 /* InKeyword */, - _a.infer = 137 /* InferKeyword */, - _a.instanceof = 102 /* InstanceOfKeyword */, - _a.interface = 118 /* InterfaceKeyword */, - _a.intrinsic = 138 /* IntrinsicKeyword */, - _a.is = 139 /* IsKeyword */, - _a.keyof = 140 /* KeyOfKeyword */, - _a.let = 119 /* LetKeyword */, - _a.module = 141 /* ModuleKeyword */, - _a.namespace = 142 /* NamespaceKeyword */, - _a.never = 143 /* NeverKeyword */, - _a.new = 103 /* NewKeyword */, - _a.null = 104 /* NullKeyword */, - _a.number = 147 /* NumberKeyword */, - _a.object = 148 /* ObjectKeyword */, - _a.package = 120 /* PackageKeyword */, - _a.private = 121 /* PrivateKeyword */, - _a.protected = 122 /* ProtectedKeyword */, - _a.public = 123 /* PublicKeyword */, - _a.override = 159 /* OverrideKeyword */, - _a.out = 144 /* OutKeyword */, - _a.readonly = 145 /* ReadonlyKeyword */, - _a.require = 146 /* RequireKeyword */, - _a.global = 157 /* GlobalKeyword */, - _a.return = 105 /* ReturnKeyword */, - _a.set = 149 /* SetKeyword */, - _a.static = 124 /* StaticKeyword */, - _a.string = 150 /* StringKeyword */, - _a.super = 106 /* SuperKeyword */, - _a.switch = 107 /* SwitchKeyword */, - _a.symbol = 151 /* SymbolKeyword */, - _a.this = 108 /* ThisKeyword */, - _a.throw = 109 /* ThrowKeyword */, - _a.true = 110 /* TrueKeyword */, - _a.try = 111 /* TryKeyword */, - _a.type = 152 /* TypeKeyword */, - _a.typeof = 112 /* TypeOfKeyword */, - _a.undefined = 153 /* UndefinedKeyword */, - _a.unique = 154 /* UniqueKeyword */, - _a.unknown = 155 /* UnknownKeyword */, - _a.var = 113 /* VarKeyword */, - _a.void = 114 /* VoidKeyword */, - _a.while = 115 /* WhileKeyword */, - _a.with = 116 /* WithKeyword */, - _a.yield = 125 /* YieldKeyword */, - _a.async = 131 /* AsyncKeyword */, - _a.await = 132 /* AwaitKeyword */, - _a.of = 160 /* OfKeyword */, + _a["" + "constructor"] = 134 /* SyntaxKind.ConstructorKeyword */, + _a.debugger = 87 /* SyntaxKind.DebuggerKeyword */, + _a.declare = 135 /* SyntaxKind.DeclareKeyword */, + _a.default = 88 /* SyntaxKind.DefaultKeyword */, + _a.delete = 89 /* SyntaxKind.DeleteKeyword */, + _a.do = 90 /* SyntaxKind.DoKeyword */, + _a.else = 91 /* SyntaxKind.ElseKeyword */, + _a.enum = 92 /* SyntaxKind.EnumKeyword */, + _a.export = 93 /* SyntaxKind.ExportKeyword */, + _a.extends = 94 /* SyntaxKind.ExtendsKeyword */, + _a.false = 95 /* SyntaxKind.FalseKeyword */, + _a.finally = 96 /* SyntaxKind.FinallyKeyword */, + _a.for = 97 /* SyntaxKind.ForKeyword */, + _a.from = 156 /* SyntaxKind.FromKeyword */, + _a.function = 98 /* SyntaxKind.FunctionKeyword */, + _a.get = 136 /* SyntaxKind.GetKeyword */, + _a.if = 99 /* SyntaxKind.IfKeyword */, + _a.implements = 117 /* SyntaxKind.ImplementsKeyword */, + _a.import = 100 /* SyntaxKind.ImportKeyword */, + _a.in = 101 /* SyntaxKind.InKeyword */, + _a.infer = 137 /* SyntaxKind.InferKeyword */, + _a.instanceof = 102 /* SyntaxKind.InstanceOfKeyword */, + _a.interface = 118 /* SyntaxKind.InterfaceKeyword */, + _a.intrinsic = 138 /* SyntaxKind.IntrinsicKeyword */, + _a.is = 139 /* SyntaxKind.IsKeyword */, + _a.keyof = 140 /* SyntaxKind.KeyOfKeyword */, + _a.let = 119 /* SyntaxKind.LetKeyword */, + _a.module = 141 /* SyntaxKind.ModuleKeyword */, + _a.namespace = 142 /* SyntaxKind.NamespaceKeyword */, + _a.never = 143 /* SyntaxKind.NeverKeyword */, + _a.new = 103 /* SyntaxKind.NewKeyword */, + _a.null = 104 /* SyntaxKind.NullKeyword */, + _a.number = 147 /* SyntaxKind.NumberKeyword */, + _a.object = 148 /* SyntaxKind.ObjectKeyword */, + _a.package = 120 /* SyntaxKind.PackageKeyword */, + _a.private = 121 /* SyntaxKind.PrivateKeyword */, + _a.protected = 122 /* SyntaxKind.ProtectedKeyword */, + _a.public = 123 /* SyntaxKind.PublicKeyword */, + _a.override = 159 /* SyntaxKind.OverrideKeyword */, + _a.out = 144 /* SyntaxKind.OutKeyword */, + _a.readonly = 145 /* SyntaxKind.ReadonlyKeyword */, + _a.require = 146 /* SyntaxKind.RequireKeyword */, + _a.global = 157 /* SyntaxKind.GlobalKeyword */, + _a.return = 105 /* SyntaxKind.ReturnKeyword */, + _a.set = 149 /* SyntaxKind.SetKeyword */, + _a.static = 124 /* SyntaxKind.StaticKeyword */, + _a.string = 150 /* SyntaxKind.StringKeyword */, + _a.super = 106 /* SyntaxKind.SuperKeyword */, + _a.switch = 107 /* SyntaxKind.SwitchKeyword */, + _a.symbol = 151 /* SyntaxKind.SymbolKeyword */, + _a.this = 108 /* SyntaxKind.ThisKeyword */, + _a.throw = 109 /* SyntaxKind.ThrowKeyword */, + _a.true = 110 /* SyntaxKind.TrueKeyword */, + _a.try = 111 /* SyntaxKind.TryKeyword */, + _a.type = 152 /* SyntaxKind.TypeKeyword */, + _a.typeof = 112 /* SyntaxKind.TypeOfKeyword */, + _a.undefined = 153 /* SyntaxKind.UndefinedKeyword */, + _a.unique = 154 /* SyntaxKind.UniqueKeyword */, + _a.unknown = 155 /* SyntaxKind.UnknownKeyword */, + _a.var = 113 /* SyntaxKind.VarKeyword */, + _a.void = 114 /* SyntaxKind.VoidKeyword */, + _a.while = 115 /* SyntaxKind.WhileKeyword */, + _a.with = 116 /* SyntaxKind.WithKeyword */, + _a.yield = 125 /* SyntaxKind.YieldKeyword */, + _a.async = 131 /* SyntaxKind.AsyncKeyword */, + _a.await = 132 /* SyntaxKind.AwaitKeyword */, + _a.of = 160 /* SyntaxKind.OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* SyntaxKind.OpenBraceToken */, "}": 19 /* SyntaxKind.CloseBraceToken */, "(": 20 /* SyntaxKind.OpenParenToken */, ")": 21 /* SyntaxKind.CloseParenToken */, "[": 22 /* SyntaxKind.OpenBracketToken */, "]": 23 /* SyntaxKind.CloseBracketToken */, ".": 24 /* SyntaxKind.DotToken */, "...": 25 /* SyntaxKind.DotDotDotToken */, ";": 26 /* SyntaxKind.SemicolonToken */, ",": 27 /* SyntaxKind.CommaToken */, "<": 29 /* SyntaxKind.LessThanToken */, ">": 31 /* SyntaxKind.GreaterThanToken */, "<=": 32 /* SyntaxKind.LessThanEqualsToken */, ">=": 33 /* SyntaxKind.GreaterThanEqualsToken */, "==": 34 /* SyntaxKind.EqualsEqualsToken */, "!=": 35 /* SyntaxKind.ExclamationEqualsToken */, "===": 36 /* SyntaxKind.EqualsEqualsEqualsToken */, "!==": 37 /* SyntaxKind.ExclamationEqualsEqualsToken */, "=>": 38 /* SyntaxKind.EqualsGreaterThanToken */, "+": 39 /* SyntaxKind.PlusToken */, "-": 40 /* SyntaxKind.MinusToken */, "**": 42 /* SyntaxKind.AsteriskAsteriskToken */, "*": 41 /* SyntaxKind.AsteriskToken */, "/": 43 /* SyntaxKind.SlashToken */, "%": 44 /* SyntaxKind.PercentToken */, "++": 45 /* SyntaxKind.PlusPlusToken */, "--": 46 /* SyntaxKind.MinusMinusToken */, "<<": 47 /* SyntaxKind.LessThanLessThanToken */, ">": 48 /* SyntaxKind.GreaterThanGreaterThanToken */, ">>>": 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* SyntaxKind.AmpersandToken */, "|": 51 /* SyntaxKind.BarToken */, "^": 52 /* SyntaxKind.CaretToken */, "!": 53 /* SyntaxKind.ExclamationToken */, "~": 54 /* SyntaxKind.TildeToken */, "&&": 55 /* SyntaxKind.AmpersandAmpersandToken */, "||": 56 /* SyntaxKind.BarBarToken */, "?": 57 /* SyntaxKind.QuestionToken */, "??": 60 /* SyntaxKind.QuestionQuestionToken */, "?.": 28 /* SyntaxKind.QuestionDotToken */, ":": 58 /* SyntaxKind.ColonToken */, "=": 63 /* SyntaxKind.EqualsToken */, "+=": 64 /* SyntaxKind.PlusEqualsToken */, "-=": 65 /* SyntaxKind.MinusEqualsToken */, "*=": 66 /* SyntaxKind.AsteriskEqualsToken */, "**=": 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */, "/=": 68 /* SyntaxKind.SlashEqualsToken */, "%=": 69 /* SyntaxKind.PercentEqualsToken */, "<<=": 70 /* SyntaxKind.LessThanLessThanEqualsToken */, ">>=": 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* SyntaxKind.AmpersandEqualsToken */, "|=": 74 /* SyntaxKind.BarEqualsToken */, "^=": 78 /* SyntaxKind.CaretEqualsToken */, "||=": 75 /* SyntaxKind.BarBarEqualsToken */, "&&=": 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */, "??=": 77 /* SyntaxKind.QuestionQuestionEqualsToken */, "@": 59 /* SyntaxKind.AtToken */, "#": 62 /* SyntaxKind.HashToken */, "`": 61 /* SyntaxKind.BacktickToken */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -10136,16 +10252,16 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { @@ -10174,17 +10290,17 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: result.push(lineStart); lineStart = pos; break; default: - if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) { result.push(lineStart); lineStart = pos; } @@ -10209,7 +10325,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -10287,18 +10403,18 @@ var ts; function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; + return ch === 32 /* CharacterCodes.space */ || + ch === 9 /* CharacterCodes.tab */ || + ch === 11 /* CharacterCodes.verticalTab */ || + ch === 12 /* CharacterCodes.formFeed */ || + ch === 160 /* CharacterCodes.nonBreakingSpace */ || + ch === 133 /* CharacterCodes.nextLine */ || + ch === 5760 /* CharacterCodes.ogham */ || + ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ || + ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ || + ch === 8287 /* CharacterCodes.mathematicalSpace */ || + ch === 12288 /* CharacterCodes.ideographicSpace */ || + ch === 65279 /* CharacterCodes.byteOrderMark */; } ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; function isLineBreak(ch) { @@ -10312,50 +10428,50 @@ var ts; // \u2029 Paragraph separator // Only the characters in Table 3 are treated as line terminators. Other new line or line // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; + return ch === 10 /* CharacterCodes.lineFeed */ || + ch === 13 /* CharacterCodes.carriageReturn */ || + ch === 8232 /* CharacterCodes.lineSeparator */ || + ch === 8233 /* CharacterCodes.paragraphSeparator */; } ts.isLineBreak = isLineBreak; function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isHexDigit(ch) { - return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */; + return isDigit(ch) || ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */ || ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */; } function isCodePoint(code) { return code <= 0x10FFFF; } /* @internal */ function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 55 /* CharacterCodes._7 */; } ts.isOctalDigit = isOctalDigit; function couldStartTrivia(text, pos) { // Keep in sync with skipTrivia var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: + case 13 /* CharacterCodes.carriageReturn */: + case 10 /* CharacterCodes.lineFeed */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 47 /* CharacterCodes.slash */: // starts of normal trivia // falls through - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: // Starts of conflict marker trivia return true; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: // Only if its the beginning can we have #! trivia return pos === 0; default: - return ch > 127 /* maxAsciiCharacter */; + return ch > 127 /* CharacterCodes.maxAsciiCharacter */; } } ts.couldStartTrivia = couldStartTrivia; @@ -10369,29 +10485,29 @@ var ts; while (true) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (stopAfterLineBreak) { return pos; } canConsumeStar = !!inJSDoc; continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: if (stopAtComments) { break; } - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { @@ -10402,10 +10518,10 @@ var ts; canConsumeStar = false; continue; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10415,24 +10531,24 @@ var ts; continue; } break; - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); canConsumeStar = false; continue; } break; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); canConsumeStar = false; continue; } break; - case 42 /* asterisk */: + case 42 /* CharacterCodes.asterisk */: if (canConsumeStar) { pos++; canConsumeStar = false; @@ -10440,7 +10556,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -10464,8 +10580,8 @@ var ts; return false; } } - return ch === 61 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + return ch === 61 /* CharacterCodes.equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* CharacterCodes.space */; } } return false; @@ -10476,18 +10592,18 @@ var ts; } var ch = text.charCodeAt(pos); var len = text.length; - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { while (pos < len && !isLineBreak(text.charCodeAt(pos))) { pos++; } } else { - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); // Consume everything from the start of a ||||||| or ======= marker to the start // of the next ======= or >>>>>>> marker. while (pos < len) { var currentChar = text.charCodeAt(pos); - if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { + if ((currentChar === 61 /* CharacterCodes.equals */ || currentChar === 62 /* CharacterCodes.greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -10548,12 +10664,12 @@ var ts; scan: while (pos >= 0 && pos < text.length) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (trailing) { break scan; @@ -10563,20 +10679,20 @@ var ts; pendingHasTrailingNewLine = true; } continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: var nextChar = text.charCodeAt(pos + 1); var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + if (nextChar === 47 /* CharacterCodes.slash */ || nextChar === 42 /* CharacterCodes.asterisk */) { + var kind = nextChar === 47 /* CharacterCodes.slash */ ? 2 /* SyntaxKind.SingleLineCommentTrivia */ : 3 /* SyntaxKind.MultiLineCommentTrivia */; var startPos = pos; pos += 2; - if (nextChar === 47 /* slash */) { + if (nextChar === 47 /* CharacterCodes.slash */) { while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { hasTrailingNewLine = true; @@ -10587,7 +10703,7 @@ var ts; } else { while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10612,7 +10728,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -10667,17 +10783,17 @@ var ts; } ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } ts.isIdentifierStart = isIdentifierStart; function isIdentifierPart(ch, languageVersion, identifierVariant) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ || ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || // "-" and ":" are valid in JSX Identifiers - (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + (identifierVariant === 1 /* LanguageVariant.JSX */ ? (ch === 45 /* CharacterCodes.minus */ || ch === 58 /* CharacterCodes.colon */) : false) || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; /* @internal */ @@ -10696,7 +10812,7 @@ var ts; ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + if (languageVariant === void 0) { languageVariant = 0 /* LanguageVariant.Standard */; } var text = textInitial; // Current position (end position of text of current token) var pos; @@ -10719,15 +10835,15 @@ var ts; getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, - hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, - hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, - hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; }, - isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; }, - isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* TokenFlags.UnicodeEscape */) !== 0; }, + hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* TokenFlags.ExtendedUnicodeEscape */) !== 0; }, + hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */) !== 0; }, + hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* TokenFlags.PrecedingJSDocComment */) !== 0; }, + isIdentifier: function () { return token === 79 /* SyntaxKind.Identifier */ || token > 116 /* SyntaxKind.LastReservedWord */; }, + isReservedWord: function () { return token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */; }, + isUnterminated: function () { return (tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, - getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, + getNumericLiteralFlags: function () { return tokenFlags & 1008 /* TokenFlags.NumericLiteralFlags */; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, reScanAsteriskEqualsToken: reScanAsteriskEqualsToken, @@ -10782,8 +10898,8 @@ var ts; var result = ""; while (true) { var ch = text.charCodeAt(pos); - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10807,7 +10923,7 @@ var ts; } break; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return result + text.substring(start, pos); @@ -10817,15 +10933,15 @@ var ts; var mainFragment = scanNumberFragment(); var decimalFragment; var scientificFragment; - if (text.charCodeAt(pos) === 46 /* dot */) { + if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) { pos++; decimalFragment = scanNumberFragment(); } var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) { pos++; - tokenFlags |= 16 /* Scientific */; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + tokenFlags |= 16 /* TokenFlags.Scientific */; + if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos++; var preNumericPart = pos; var finalFragment = scanNumberFragment(); @@ -10838,7 +10954,7 @@ var ts; } } var result; - if (tokenFlags & 512 /* ContainsSeparator */) { + if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) { result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; @@ -10850,10 +10966,10 @@ var ts; else { result = text.substring(start, end); // No need to use all the fragments; no _ removal needed } - if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { - checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* Scientific */)); + if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) { + checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */)); return { - type: 8 /* NumericLiteral */, + type: 8 /* SyntaxKind.NumericLiteral */, value: "" + +result // if value is not an integer, it can be safely coerced to a number }; } @@ -10911,8 +11027,8 @@ var ts; var isPreviousTokenSeparator = false; while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); - if (canHaveSeparators && ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (canHaveSeparators && ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10927,11 +11043,11 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 65 /* A */ && ch <= 70 /* F */) { - ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase + if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) { + ch += 97 /* CharacterCodes.a */ - 65 /* CharacterCodes.A */; // standardize hex literals to lowercase } - else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || - (ch >= 97 /* a */ && ch <= 102 /* f */))) { + else if (!((ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) || + (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */))) { break; } valueChars.push(ch); @@ -10941,7 +11057,7 @@ var ts; if (valueChars.length < minCount) { valueChars = []; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return String.fromCharCode.apply(String, valueChars); @@ -10955,7 +11071,7 @@ var ts; while (true) { if (pos >= end) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -10965,7 +11081,7 @@ var ts; pos++; break; } - if (ch === 92 /* backslash */ && !jsxAttributeString) { + if (ch === 92 /* CharacterCodes.backslash */ && !jsxAttributeString) { result += text.substring(start, pos); result += scanEscapeSequence(); start = pos; @@ -10973,7 +11089,7 @@ var ts; } if (isLineBreak(ch) && !jsxAttributeString) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -10986,7 +11102,7 @@ var ts; * a literal component of a TemplateExpression. */ function scanTemplateAndSetTokenValue(isTaggedTemplate) { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + var startedWithBacktick = text.charCodeAt(pos) === 96 /* CharacterCodes.backtick */; pos++; var start = pos; var contents = ""; @@ -10994,28 +11110,28 @@ var ts; while (true) { if (pos >= end) { contents += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } var currChar = text.charCodeAt(pos); // '`' - if (currChar === 96 /* backtick */) { + if (currChar === 96 /* CharacterCodes.backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } // '${' - if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + if (currChar === 36 /* CharacterCodes.$ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* CharacterCodes.openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* SyntaxKind.TemplateHead */ : 16 /* SyntaxKind.TemplateMiddle */; break; } // Escape character - if (currChar === 92 /* backslash */) { + if (currChar === 92 /* CharacterCodes.backslash */) { contents += text.substring(start, pos); contents += scanEscapeSequence(isTaggedTemplate); start = pos; @@ -11023,10 +11139,10 @@ var ts; } // Speculated ECMAScript 6 Spec 11.8.6.1: // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { + if (currChar === 13 /* CharacterCodes.carriageReturn */) { contents += text.substring(start, pos); pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } contents += "\n"; @@ -11049,47 +11165,47 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 48 /* _0 */: + case 48 /* CharacterCodes._0 */: // '\01' if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } return "\0"; - case 98 /* b */: + case 98 /* CharacterCodes.b */: return "\b"; - case 116 /* t */: + case 116 /* CharacterCodes.t */: return "\t"; - case 110 /* n */: + case 110 /* CharacterCodes.n */: return "\n"; - case 118 /* v */: + case 118 /* CharacterCodes.v */: return "\v"; - case 102 /* f */: + case 102 /* CharacterCodes.f */: return "\f"; - case 114 /* r */: + case 114 /* CharacterCodes.r */: return "\r"; - case 39 /* singleQuote */: + case 39 /* CharacterCodes.singleQuote */: return "\'"; - case 34 /* doubleQuote */: + case 34 /* CharacterCodes.doubleQuote */: return "\""; - case 117 /* u */: + case 117 /* CharacterCodes.u */: if (isTaggedTemplate) { // '\u' or '\u0' or '\u00' or '\u000' for (var escapePos = pos; escapePos < pos + 4; escapePos++) { - if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) { + if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* CharacterCodes.openBrace */) { pos = escapePos; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } } // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + if (pos < end && text.charCodeAt(pos) === 123 /* CharacterCodes.openBrace */) { pos++; // '\u{' if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } if (isTaggedTemplate) { @@ -11097,29 +11213,29 @@ var ts; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; // '\u{Not Code Point' or '\u{CodePoint' - if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* CharacterCodes.closeBrace */) { + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else { pos = savePos; } } - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; return scanExtendedUnicodeEscape(); } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: + case 120 /* CharacterCodes.x */: if (isTaggedTemplate) { if (!isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else if (!isHexDigit(text.charCodeAt(pos + 1))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } @@ -11127,14 +11243,14 @@ var ts; return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: + case 10 /* CharacterCodes.lineFeed */: + case 8232 /* CharacterCodes.lineSeparator */: + case 8233 /* CharacterCodes.paragraphSeparator */: return ""; default: return String.fromCharCode(ch); @@ -11167,7 +11283,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) === 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -11183,7 +11299,7 @@ var ts; // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* CharacterCodes.u */) { var start_1 = pos; pos += 2; var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false); @@ -11193,7 +11309,7 @@ var ts; return -1; } function peekExtendedUnicodeEscape() { - if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) { var start_2 = pos; pos += 3; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); @@ -11211,11 +11327,11 @@ var ts; if (isIdentifierPart(ch, languageVersion)) { pos += charSize(ch); } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { ch = peekExtendedUnicodeEscape(); if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; result += scanExtendedUnicodeEscape(); start = pos; continue; @@ -11224,7 +11340,7 @@ var ts; if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; result += text.substring(start, pos); result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters @@ -11243,14 +11359,14 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 12) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { var keyword = textToKeyword.get(tokenValue); if (keyword !== undefined) { return token = keyword; } } } - return token = 79 /* Identifier */; + return token = 79 /* SyntaxKind.Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -11261,8 +11377,8 @@ var ts; while (true) { var ch = text.charCodeAt(pos); // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (separatorAllowed) { separatorAllowed = false; isPreviousTokenSeparator = true; @@ -11277,101 +11393,101 @@ var ts; continue; } separatorAllowed = true; - if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { + if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) { break; } value += text[pos]; pos++; isPreviousTokenSeparator = false; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return value; } function checkBigIntSuffix() { - if (text.charCodeAt(pos) === 110 /* n */) { + if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) { tokenValue += "n"; // Use base 10 instead of base 2 or base 8 for shorter literals - if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + if (tokenFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; } pos++; - return 9 /* BigIntLiteral */; + return 9 /* SyntaxKind.BigIntLiteral */; } else { // not a bigint, so can convert to number in simplified form // Number() may not support 0b or 0o, so use parseInt() instead - var numericValue = tokenFlags & 128 /* BinarySpecifier */ + var numericValue = tokenFlags & 128 /* TokenFlags.BinarySpecifier */ ? parseInt(tokenValue.slice(2), 2) // skip "0b" - : tokenFlags & 256 /* OctalSpecifier */ + : tokenFlags & 256 /* TokenFlags.OctalSpecifier */ ? parseInt(tokenValue.slice(2), 8) // skip "0o" : +tokenValue; tokenValue = "" + numericValue; - return 8 /* NumericLiteral */; + return 8 /* SyntaxKind.NumericLiteral */; } } function scan() { var _a; startPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + if (ch === 35 /* CharacterCodes.hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { continue; } else { - return token = 6 /* ShebangTrivia */; + return token = 6 /* SyntaxKind.ShebangTrivia */; } } switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - tokenFlags |= 1 /* PrecedingLineBreak */; + case 10 /* CharacterCodes.lineFeed */: + case 13 /* CharacterCodes.carriageReturn */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; if (skipTrivia) { pos++; continue; } else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + if (ch === 13 /* CharacterCodes.carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { // consume both CR and LF pos += 2; } else { pos++; } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 5760 /* ogham */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 8287 /* mathematicalSpace */: - case 12288 /* ideographicSpace */: - case 65279 /* byteOrderMark */: + return token = 4 /* SyntaxKind.NewLineTrivia */; + } + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 160 /* CharacterCodes.nonBreakingSpace */: + case 5760 /* CharacterCodes.ogham */: + case 8192 /* CharacterCodes.enQuad */: + case 8193 /* CharacterCodes.emQuad */: + case 8194 /* CharacterCodes.enSpace */: + case 8195 /* CharacterCodes.emSpace */: + case 8196 /* CharacterCodes.threePerEmSpace */: + case 8197 /* CharacterCodes.fourPerEmSpace */: + case 8198 /* CharacterCodes.sixPerEmSpace */: + case 8199 /* CharacterCodes.figureSpace */: + case 8200 /* CharacterCodes.punctuationSpace */: + case 8201 /* CharacterCodes.thinSpace */: + case 8202 /* CharacterCodes.hairSpace */: + case 8203 /* CharacterCodes.zeroWidthSpace */: + case 8239 /* CharacterCodes.narrowNoBreakSpace */: + case 8287 /* CharacterCodes.mathematicalSpace */: + case 12288 /* CharacterCodes.ideographicSpace */: + case 65279 /* CharacterCodes.byteOrderMark */: if (skipTrivia) { pos++; continue; @@ -11380,98 +11496,98 @@ var ts; while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; + return token = 5 /* SyntaxKind.WhitespaceTrivia */; } - case 33 /* exclamation */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; + case 33 /* CharacterCodes.exclamation */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } - return pos += 2, token = 35 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* SyntaxKind.ExclamationEqualsToken */; } pos++; - return token = 53 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + return token = 53 /* SyntaxKind.ExclamationToken */; + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(); - return token = 10 /* StringLiteral */; - case 96 /* backtick */: + return token = 10 /* SyntaxKind.StringLiteral */; + case 96 /* CharacterCodes.backtick */: return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* PercentEqualsToken */; + case 37 /* CharacterCodes.percent */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 69 /* SyntaxKind.PercentEqualsToken */; } pos++; - return token = 44 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; + return token = 44 /* SyntaxKind.PercentToken */; + case 38 /* CharacterCodes.ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* CharacterCodes.ampersand */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */; } - return pos += 2, token = 55 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* SyntaxKind.AmpersandAmpersandToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* AmpersandEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 73 /* SyntaxKind.AmpersandEqualsToken */; } pos++; - return token = 50 /* AmpersandToken */; - case 40 /* openParen */: + return token = 50 /* SyntaxKind.AmpersandToken */; + case 40 /* CharacterCodes.openParen */: pos++; - return token = 20 /* OpenParenToken */; - case 41 /* closeParen */: + return token = 20 /* SyntaxKind.OpenParenToken */; + case 41 /* CharacterCodes.closeParen */: pos++; - return token = 21 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AsteriskEqualsToken */; + return token = 21 /* SyntaxKind.CloseParenToken */; + case 42 /* CharacterCodes.asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 66 /* SyntaxKind.AsteriskEqualsToken */; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 42 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* SyntaxKind.AsteriskAsteriskToken */; } pos++; - if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { + if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */)) { // decoration at the start of a JSDoc comment line asteriskSeen = true; continue; } - return token = 41 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 45 /* PlusPlusToken */; + return token = 41 /* SyntaxKind.AsteriskToken */; + case 43 /* CharacterCodes.plus */: + if (text.charCodeAt(pos + 1) === 43 /* CharacterCodes.plus */) { + return pos += 2, token = 45 /* SyntaxKind.PlusPlusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PlusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 64 /* SyntaxKind.PlusEqualsToken */; } pos++; - return token = 39 /* PlusToken */; - case 44 /* comma */: + return token = 39 /* SyntaxKind.PlusToken */; + case 44 /* CharacterCodes.comma */: pos++; - return token = 27 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 46 /* MinusMinusToken */; + return token = 27 /* SyntaxKind.CommaToken */; + case 45 /* CharacterCodes.minus */: + if (text.charCodeAt(pos + 1) === 45 /* CharacterCodes.minus */) { + return pos += 2, token = 46 /* SyntaxKind.MinusMinusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* MinusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 65 /* SyntaxKind.MinusEqualsToken */; } pos++; - return token = 40 /* MinusToken */; - case 46 /* dot */: + return token = 40 /* SyntaxKind.MinusToken */; + case 46 /* CharacterCodes.dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; - return token = 8 /* NumericLiteral */; + return token = 8 /* SyntaxKind.NumericLiteral */; } - if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 25 /* DotDotDotToken */; + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && text.charCodeAt(pos + 2) === 46 /* CharacterCodes.dot */) { + return pos += 3, token = 25 /* SyntaxKind.DotDotDotToken */; } pos++; - return token = 24 /* DotToken */; - case 47 /* slash */: + return token = 24 /* SyntaxKind.DotToken */; + case 47 /* CharacterCodes.slash */: // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < end) { if (isLineBreak(text.charCodeAt(pos))) { @@ -11484,20 +11600,20 @@ var ts; continue; } else { - return token = 2 /* SingleLineCommentTrivia */; + return token = 2 /* SyntaxKind.SingleLineCommentTrivia */; } } // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) { - tokenFlags |= 2 /* PrecedingJSDocComment */; + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) !== 47 /* CharacterCodes.slash */) { + tokenFlags |= 2 /* TokenFlags.PrecedingJSDocComment */; } var commentClosed = false; var lastLineStart = tokenPos; while (pos < end) { var ch_1 = text.charCodeAt(pos); - if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (ch_1 === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; commentClosed = true; break; @@ -11505,7 +11621,7 @@ var ts; pos++; if (isLineBreak(ch_1)) { lastLineStart = pos; - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; } } commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart); @@ -11517,18 +11633,18 @@ var ts; } else { if (!commentClosed) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; } - return token = 3 /* MultiLineCommentTrivia */; + return token = 3 /* SyntaxKind.MultiLineCommentTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* SlashEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 68 /* SyntaxKind.SlashEqualsToken */; } pos++; - return token = 43 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + return token = 43 /* SyntaxKind.SlashToken */; + case 48 /* CharacterCodes._0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* CharacterCodes.X */ || text.charCodeAt(pos + 1) === 120 /* CharacterCodes.x */)) { pos += 2; tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); if (!tokenValue) { @@ -11536,10 +11652,10 @@ var ts; tokenValue = "0"; } tokenValue = "0x" + tokenValue; - tokenFlags |= 64 /* HexSpecifier */; + tokenFlags |= 64 /* TokenFlags.HexSpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* CharacterCodes.B */ || text.charCodeAt(pos + 1) === 98 /* CharacterCodes.b */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 2); if (!tokenValue) { @@ -11547,10 +11663,10 @@ var ts; tokenValue = "0"; } tokenValue = "0b" + tokenValue; - tokenFlags |= 128 /* BinarySpecifier */; + tokenFlags |= 128 /* TokenFlags.BinarySpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* CharacterCodes.O */ || text.charCodeAt(pos + 1) === 111 /* CharacterCodes.o */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 8); if (!tokenValue) { @@ -11558,175 +11674,175 @@ var ts; tokenValue = "0"; } tokenValue = "0o" + tokenValue; - tokenFlags |= 256 /* OctalSpecifier */; + tokenFlags |= 256 /* TokenFlags.OctalSpecifier */; return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - tokenFlags |= 32 /* Octal */; - return token = 8 /* NumericLiteral */; + tokenFlags |= 32 /* TokenFlags.Octal */; + return token = 8 /* SyntaxKind.NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). // falls through - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: + case 49 /* CharacterCodes._1 */: + case 50 /* CharacterCodes._2 */: + case 51 /* CharacterCodes._3 */: + case 52 /* CharacterCodes._4 */: + case 53 /* CharacterCodes._5 */: + case 54 /* CharacterCodes._6 */: + case 55 /* CharacterCodes._7 */: + case 56 /* CharacterCodes._8 */: + case 57 /* CharacterCodes._9 */: (_a = scanNumber(), token = _a.type, tokenValue = _a.value); return token; - case 58 /* colon */: + case 58 /* CharacterCodes.colon */: pos++; - return token = 58 /* ColonToken */; - case 59 /* semicolon */: + return token = 58 /* SyntaxKind.ColonToken */; + case 59 /* CharacterCodes.semicolon */: pos++; - return token = 26 /* SemicolonToken */; - case 60 /* lessThan */: + return token = 26 /* SyntaxKind.SemicolonToken */; + case 60 /* CharacterCodes.lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 70 /* SyntaxKind.LessThanLessThanEqualsToken */; } - return pos += 2, token = 47 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* SyntaxKind.LessThanLessThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 32 /* LessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 32 /* SyntaxKind.LessThanEqualsToken */; } - if (languageVariant === 1 /* JSX */ && - text.charCodeAt(pos + 1) === 47 /* slash */ && - text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 30 /* LessThanSlashToken */; + if (languageVariant === 1 /* LanguageVariant.JSX */ && + text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */ && + text.charCodeAt(pos + 2) !== 42 /* CharacterCodes.asterisk */) { + return pos += 2, token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; - case 61 /* equals */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 61 /* CharacterCodes.equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 36 /* SyntaxKind.EqualsEqualsEqualsToken */; } - return pos += 2, token = 34 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* SyntaxKind.EqualsEqualsToken */; } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 38 /* EqualsGreaterThanToken */; + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + return pos += 2, token = 38 /* SyntaxKind.EqualsGreaterThanToken */; } pos++; - return token = 63 /* EqualsToken */; - case 62 /* greaterThan */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } pos++; - return token = 31 /* GreaterThanToken */; - case 63 /* question */: - if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) { - return pos += 2, token = 28 /* QuestionDotToken */; + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 63 /* CharacterCodes.question */: + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && !isDigit(text.charCodeAt(pos + 2))) { + return pos += 2, token = 28 /* SyntaxKind.QuestionDotToken */; } - if (text.charCodeAt(pos + 1) === 63 /* question */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; + if (text.charCodeAt(pos + 1) === 63 /* CharacterCodes.question */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } - return pos += 2, token = 60 /* QuestionQuestionToken */; + return pos += 2, token = 60 /* SyntaxKind.QuestionQuestionToken */; } pos++; - return token = 57 /* QuestionToken */; - case 91 /* openBracket */: + return token = 57 /* SyntaxKind.QuestionToken */; + case 91 /* CharacterCodes.openBracket */: pos++; - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: pos++; - return token = 23 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 78 /* CaretEqualsToken */; + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 94 /* CharacterCodes.caret */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 78 /* SyntaxKind.CaretEqualsToken */; } pos++; - return token = 52 /* CaretToken */; - case 123 /* openBrace */: + return token = 52 /* SyntaxKind.CaretToken */; + case 123 /* CharacterCodes.openBrace */: pos++; - return token = 18 /* OpenBraceToken */; - case 124 /* bar */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 124 /* CharacterCodes.bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 75 /* BarBarEqualsToken */; + if (text.charCodeAt(pos + 1) === 124 /* CharacterCodes.bar */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 75 /* SyntaxKind.BarBarEqualsToken */; } - return pos += 2, token = 56 /* BarBarToken */; + return pos += 2, token = 56 /* SyntaxKind.BarBarToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 74 /* BarEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 74 /* SyntaxKind.BarEqualsToken */; } pos++; - return token = 51 /* BarToken */; - case 125 /* closeBrace */: + return token = 51 /* SyntaxKind.BarToken */; + case 125 /* CharacterCodes.closeBrace */: pos++; - return token = 19 /* CloseBraceToken */; - case 126 /* tilde */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 126 /* CharacterCodes.tilde */: pos++; - return token = 54 /* TildeToken */; - case 64 /* at */: + return token = 54 /* SyntaxKind.TildeToken */; + case 64 /* CharacterCodes.at */: pos++; - return token = 59 /* AtToken */; - case 92 /* backslash */: + return token = 59 /* SyntaxKind.AtToken */; + case 92 /* CharacterCodes.backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } error(ts.Diagnostics.Invalid_character); pos++; - return token = 0 /* Unknown */; - case 35 /* hash */: + return token = 0 /* SyntaxKind.Unknown */; + case 35 /* CharacterCodes.hash */: if (pos !== 0 && text[pos + 1] === "!") { error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file); pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; @@ -11736,7 +11852,7 @@ var ts; tokenValue = String.fromCharCode(codePointAt(text, pos)); error(ts.Diagnostics.Invalid_character, pos++, charSize(ch)); } - return token = 80 /* PrivateIdentifier */; + return token = 80 /* SyntaxKind.PrivateIdentifier */; default: var identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { @@ -11747,23 +11863,23 @@ var ts; continue; } else if (isLineBreak(ch)) { - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; pos += charSize(ch); continue; } var size = charSize(ch); error(ts.Diagnostics.Invalid_character, pos, size); pos += size; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } } function reScanInvalidIdentifier() { - ts.Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); + ts.Debug.assert(token === 0 /* SyntaxKind.Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); pos = tokenPos = startPos; tokenFlags = 0; var ch = codePointAt(text, pos); - var identifierKind = scanIdentifier(ch, 99 /* ESNext */); + var identifierKind = scanIdentifier(ch, 99 /* ScriptTarget.ESNext */); if (identifierKind) { return token = identifierKind; } @@ -11777,41 +11893,41 @@ var ts; while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { + if (ch === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return getIdentifierToken(); } } function reScanGreaterToken() { - if (token === 31 /* GreaterThanToken */) { - if (text.charCodeAt(pos) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + if (text.charCodeAt(pos) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 48 /* GreaterThanGreaterThanToken */; + return token = 48 /* SyntaxKind.GreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos) === 61 /* equals */) { + if (text.charCodeAt(pos) === 61 /* CharacterCodes.equals */) { pos++; - return token = 33 /* GreaterThanEqualsToken */; + return token = 33 /* SyntaxKind.GreaterThanEqualsToken */; } } return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* SyntaxKind.AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 63 /* EqualsToken */; + return token = 63 /* SyntaxKind.EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { + if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11819,13 +11935,13 @@ var ts; // If we reach the end of a file, or hit a newline, then this is an unterminated // regex. Report error and return what we have so far. if (p >= end) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -11834,19 +11950,19 @@ var ts; // reset the flag and just advance to the next char. inEscape = false; } - else if (ch === 47 /* slash */ && !inCharacterClass) { + else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) { // A slash within a character class is permissible, // but in general it signals the end of the regexp literal. p++; break; } - else if (ch === 91 /* openBracket */) { + else if (ch === 91 /* CharacterCodes.openBracket */) { inCharacterClass = true; } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { inEscape = true; } - else if (ch === 93 /* closeBracket */) { + else if (ch === 93 /* CharacterCodes.closeBracket */) { inCharacterClass = false; } p++; @@ -11856,7 +11972,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 13 /* RegularExpressionLiteral */; + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } return token; } @@ -11877,9 +11993,9 @@ var ts; } switch (match[1]) { case "ts-expect-error": - return 0 /* ExpectError */; + return 0 /* CommentDirectiveType.ExpectError */; case "ts-ignore": - return 1 /* Ignore */; + return 1 /* CommentDirectiveType.Ignore */; } return undefined; } @@ -11887,7 +12003,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken(isTaggedTemplate) { - ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* SyntaxKind.CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(isTaggedTemplate); } @@ -11901,42 +12017,42 @@ var ts; return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { - if (token === 47 /* LessThanLessThanToken */) { + if (token === 47 /* SyntaxKind.LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } return token; } function reScanHashToken() { - if (token === 80 /* PrivateIdentifier */) { + if (token === 80 /* SyntaxKind.PrivateIdentifier */) { pos = tokenPos + 1; - return token = 62 /* HashToken */; + return token = 62 /* SyntaxKind.HashToken */; } return token; } function reScanQuestionToken() { - ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + ts.Debug.assert(token === 60 /* SyntaxKind.QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; - return token = 57 /* QuestionToken */; + return token = 57 /* SyntaxKind.QuestionToken */; } function scanJsxToken(allowMultilineJsxText) { if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (char === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; - return token = 30 /* LessThanSlashToken */; + return token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { pos++; - return token = 18 /* OpenBraceToken */; + return token = 18 /* SyntaxKind.OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -11944,20 +12060,20 @@ var ts; // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { break; } - if (char === 60 /* lessThan */) { + if (char === 60 /* CharacterCodes.lessThan */) { if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } break; } - if (char === 62 /* greaterThan */) { + if (char === 62 /* CharacterCodes.greaterThan */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1); } - if (char === 125 /* closeBrace */) { + if (char === 125 /* CharacterCodes.closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. @@ -11980,7 +12096,7 @@ var ts; pos++; } tokenValue = text.substring(startPos, pos); - return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* SyntaxKind.JsxTextAllWhiteSpaces */ : 11 /* SyntaxKind.JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -11993,16 +12109,16 @@ var ts; var namespaceSeparator = false; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */) { + if (ch === 45 /* CharacterCodes.minus */) { tokenValue += "-"; pos++; continue; } - else if (ch === 58 /* colon */ && !namespaceSeparator) { + else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) { tokenValue += ":"; pos++; namespaceSeparator = true; - token = 79 /* Identifier */; // swap from keyword kind to identifier kind + token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -12023,10 +12139,10 @@ var ts; function scanJsxAttributeValue() { startPos = pos; switch (text.charCodeAt(pos)) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 10 /* StringLiteral */; + return token = 10 /* SyntaxKind.StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -12038,86 +12154,86 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); pos += charSize(ch); switch (ch) { - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; - case 64 /* at */: - return token = 59 /* AtToken */; - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + return token = 5 /* SyntaxKind.WhitespaceTrivia */; + case 64 /* CharacterCodes.at */: + return token = 59 /* SyntaxKind.AtToken */; + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - tokenFlags |= 1 /* PrecedingLineBreak */; - return token = 4 /* NewLineTrivia */; - case 42 /* asterisk */: - return token = 41 /* AsteriskToken */; - case 123 /* openBrace */: - return token = 18 /* OpenBraceToken */; - case 125 /* closeBrace */: - return token = 19 /* CloseBraceToken */; - case 91 /* openBracket */: - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: - return token = 23 /* CloseBracketToken */; - case 60 /* lessThan */: - return token = 29 /* LessThanToken */; - case 62 /* greaterThan */: - return token = 31 /* GreaterThanToken */; - case 61 /* equals */: - return token = 63 /* EqualsToken */; - case 44 /* comma */: - return token = 27 /* CommaToken */; - case 46 /* dot */: - return token = 24 /* DotToken */; - case 96 /* backtick */: - return token = 61 /* BacktickToken */; - case 35 /* hash */: - return token = 62 /* HashToken */; - case 92 /* backslash */: + case 10 /* CharacterCodes.lineFeed */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; + return token = 4 /* SyntaxKind.NewLineTrivia */; + case 42 /* CharacterCodes.asterisk */: + return token = 41 /* SyntaxKind.AsteriskToken */; + case 123 /* CharacterCodes.openBrace */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 125 /* CharacterCodes.closeBrace */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 91 /* CharacterCodes.openBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 60 /* CharacterCodes.lessThan */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 62 /* CharacterCodes.greaterThan */: + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 61 /* CharacterCodes.equals */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 44 /* CharacterCodes.comma */: + return token = 27 /* SyntaxKind.CommaToken */; + case 46 /* CharacterCodes.dot */: + return token = 24 /* SyntaxKind.DotToken */; + case 96 /* CharacterCodes.backtick */: + return token = 61 /* SyntaxKind.BacktickToken */; + case 35 /* CharacterCodes.hash */: + return token = 62 /* SyntaxKind.HashToken */; + case 92 /* CharacterCodes.backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); - if (char === 92 /* backslash */) { + if (char === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return token = getIdentifierToken(); } else { - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } function speculationHelper(callback, isLookahead) { @@ -12192,9 +12308,9 @@ var ts; pos = textPos; startPos = textPos; tokenPos = textPos; - token = 0 /* Unknown */; + token = 0 /* SyntaxKind.Unknown */; tokenValue = undefined; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -12260,23 +12376,23 @@ var ts; ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; function getDefaultLibFileName(options) { switch (ts.getEmitScriptTarget(options)) { - case 99 /* ESNext */: + case 99 /* ScriptTarget.ESNext */: return "lib.esnext.full.d.ts"; - case 9 /* ES2022 */: + case 9 /* ScriptTarget.ES2022 */: return "lib.es2022.full.d.ts"; - case 8 /* ES2021 */: + case 8 /* ScriptTarget.ES2021 */: return "lib.es2021.full.d.ts"; - case 7 /* ES2020 */: + case 7 /* ScriptTarget.ES2020 */: return "lib.es2020.full.d.ts"; - case 6 /* ES2019 */: + case 6 /* ScriptTarget.ES2019 */: return "lib.es2019.full.d.ts"; - case 5 /* ES2018 */: + case 5 /* ScriptTarget.ES2018 */: return "lib.es2018.full.d.ts"; - case 4 /* ES2017 */: + case 4 /* ScriptTarget.ES2017 */: return "lib.es2017.full.d.ts"; - case 3 /* ES2016 */: + case 3 /* ScriptTarget.ES2016 */: return "lib.es2016.full.d.ts"; - case 2 /* ES2015 */: + case 2 /* ScriptTarget.ES2015 */: return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; @@ -12484,9 +12600,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 163 /* TypeParameter */) { + if (d && d.kind === 163 /* SyntaxKind.TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return current; } } @@ -12494,7 +12610,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 171 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) && parent.kind === 171 /* SyntaxKind.Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12524,14 +12640,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 254 /* VariableDeclaration */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 255 /* VariableDeclarationList */) { + if (node && node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 237 /* VariableStatement */) { + if (node && node.kind === 237 /* SyntaxKind.VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12645,7 +12761,7 @@ var ts; * @param node The node to test. */ function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + return (node.flags & 8 /* NodeFlags.Synthesized */) === 0; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { @@ -12663,7 +12779,7 @@ var ts; ts.getParseTreeNode = getParseTreeNode; /** Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' */ function escapeLeadingUnderscores(identifier) { - return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); + return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* CharacterCodes._ */ && identifier.charCodeAt(1) === 95 /* CharacterCodes._ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; /** @@ -12674,7 +12790,7 @@ var ts; */ function unescapeLeadingUnderscores(identifier) { var id = identifier; - return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id; + return id.length >= 3 && id.charCodeAt(0) === 95 /* CharacterCodes._ */ && id.charCodeAt(1) === 95 /* CharacterCodes._ */ && id.charCodeAt(2) === 95 /* CharacterCodes._ */ ? id.substr(1) : id; } ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores; function idText(identifierOrPrivateName) { @@ -12704,30 +12820,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 221 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { + if (expr.kind === 221 /* SyntaxKind.BinaryExpression */ && expr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return expr.name; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12762,42 +12878,42 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return declaration; - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: { + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 161 /* QualifiedName */) { + if (name.kind === 161 /* SyntaxKind.QualifiedName */) { return name.right; } break; } - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { - case 1 /* ExportsProperty */: - case 4 /* ThisProperty */: - case 5 /* Property */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return expr_1.arguments[1]; default: return undefined; } } - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 339 /* JSDocEnumTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -12841,7 +12957,7 @@ var ts; } ts.getDecorators = getDecorators; function getModifiers(node) { - if (ts.hasSyntacticModifier(node, 125951 /* Modifier */)) { + if (ts.hasSyntacticModifier(node, 125951 /* ModifierFlags.Modifier */)) { return ts.filter(node.modifiers, isModifier); } } @@ -13102,27 +13218,33 @@ var ts; /** Gets the text of a jsdoc comment, flattening links to their text. */ function getTextOfJSDocComment(comment) { return typeof comment === "string" ? comment - : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* SyntaxKind.JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; function formatJSDocLink(link) { - var kind = link.kind === 324 /* JSDocLink */ ? "link" - : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" + var kind = link.kind === 324 /* SyntaxKind.JSDocLink */ ? "link" + : link.kind === 325 /* SyntaxKind.JSDocLinkCode */ ? "linkcode" : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. + * + * This does *not* return type parameters from a jsdoc reference to a generic type, eg + * + * type Id = (x: T) => T + * /** @type {Id} / + * function id(x) { return x } */ function getEffectiveTypeParameterDeclarations(node) { if (ts.isJSDocSignature(node)) { return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 320 /* JSDoc */); + ts.Debug.assert(node.parent.kind === 320 /* SyntaxKind.JSDoc */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13152,33 +13274,33 @@ var ts; ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region function isMemberName(node) { - return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; + return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */ || node.kind === 172 /* GetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */ || node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { - return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessChain(node) { - return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isElementAccessChain = isElementAccessChain; function isCallChain(node) { - return ts.isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isCallExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isCallChain = isCallChain; function isOptionalChain(node) { var kind = node.kind; - return !!(node.flags & 32 /* OptionalChain */) && - (kind === 206 /* PropertyAccessExpression */ - || kind === 207 /* ElementAccessExpression */ - || kind === 208 /* CallExpression */ - || kind === 230 /* NonNullExpression */); + return !!(node.flags & 32 /* NodeFlags.OptionalChain */) && + (kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 207 /* SyntaxKind.ElementAccessExpression */ + || kind === 208 /* SyntaxKind.CallExpression */ + || kind === 230 /* SyntaxKind.NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -13213,7 +13335,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -13222,25 +13344,25 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function skipPartiallyEmittedExpressions(node) { - return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */); + return ts.skipOuterExpressions(node, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isNonNullChain(node) { - return ts.isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isNonNullExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 246 /* BreakStatement */ || node.kind === 245 /* ContinueStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */ || node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 274 /* NamespaceExport */ || node.kind === 273 /* NamedExports */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return true; default: return false; @@ -13249,12 +13371,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 300 /* UnparsedPrologue */ || - node.kind === 304 /* UnparsedSyntheticReference */; + node.kind === 300 /* SyntaxKind.UnparsedPrologue */ || + node.kind === 304 /* SyntaxKind.UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 347 /* JSDocPropertyTag */ || node.kind === 340 /* JSDocParameterTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */ || node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -13270,7 +13392,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 161 /* FirstNode */; + return kind >= 161 /* SyntaxKind.FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13279,7 +13401,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 160 /* LastToken */; + return kind >= 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -13300,7 +13422,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; + return 8 /* SyntaxKind.FirstLiteralToken */ <= kind && kind <= 14 /* SyntaxKind.LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13310,11 +13432,11 @@ var ts; /** @internal */ function isLiteralExpressionOfObject(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 13 /* RegularExpressionLiteral */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; } return false; @@ -13323,7 +13445,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; + return 14 /* SyntaxKind.FirstTemplateToken */ <= kind && kind <= 17 /* SyntaxKind.LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13332,8 +13454,8 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 16 /* TemplateMiddle */ - || kind === 17 /* TemplateTail */; + return kind === 16 /* SyntaxKind.TemplateMiddle */ + || kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isImportOrExportSpecifier(node) { @@ -13342,13 +13464,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.isTypeOnly || node.parent.parent.isTypeOnly; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.isTypeOnly; - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -13360,13 +13482,13 @@ var ts; } ts.isAssertionKey = isAssertionKey; function isStringTextContainingNode(node) { - return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* SyntaxKind.StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; + return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) > 0 /* GeneratedIdentifierFlags.None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers @@ -13384,20 +13506,20 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 88 /* DefaultKeyword */: - case 93 /* ExportKeyword */: - case 101 /* InKeyword */: - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 124 /* StaticKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; } return false; @@ -13405,12 +13527,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ModifierFlags.ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 159 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* SyntaxKind.StaticKeyword */ || idToken === 159 /* SyntaxKind.OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13419,24 +13541,24 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 80 /* PrivateIdentifier */ - || kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 162 /* ComputedPropertyName */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 80 /* SyntaxKind.PrivateIdentifier */ + || kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */ + || kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 201 /* ObjectBindingPattern */ - || kind === 202 /* ArrayBindingPattern */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */ + || kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13456,18 +13578,18 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; /* @internal */ function isBooleanLiteral(node) { - return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */; + return node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */; } ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -13476,14 +13598,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 180 /* ConstructorType */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13498,30 +13620,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 234 /* SemicolonClassElement */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */); + return node && (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */); + return node && (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -13535,13 +13657,13 @@ var ts; ts.isModifierLike = isModifierLike; function isTypeElement(node) { var kind = node.kind; - return kind === 175 /* ConstructSignature */ - || kind === 174 /* CallSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */ - || kind === 176 /* IndexSignature */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 174 /* SyntaxKind.CallSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13550,12 +13672,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 298 /* SpreadAssignment */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 298 /* SyntaxKind.SpreadAssignment */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13570,8 +13692,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; } return false; @@ -13582,8 +13704,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 202 /* ArrayBindingPattern */ - || kind === 201 /* ObjectBindingPattern */; + return kind === 202 /* SyntaxKind.ArrayBindingPattern */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */; } return false; } @@ -13591,15 +13713,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 204 /* ArrayLiteralExpression */ - || kind === 205 /* ObjectLiteralExpression */; + return kind === 204 /* SyntaxKind.ArrayLiteralExpression */ + || kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 203 /* BindingElement */ - || kind === 227 /* OmittedExpression */; + return kind === 203 /* SyntaxKind.BindingElement */ + || kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13608,9 +13730,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: return true; } return false; @@ -13631,8 +13753,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return true; } return false; @@ -13641,10 +13763,10 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentElement(node) { switch (node.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: // AssignmentProperty - case 297 /* ShorthandPropertyAssignment */: // AssignmentProperty - case 298 /* SpreadAssignment */: // AssignmentRestProperty + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: // AssignmentProperty + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // AssignmentProperty + case 298 /* SyntaxKind.SpreadAssignment */: // AssignmentRestProperty return true; } return false; @@ -13656,8 +13778,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; } return false; @@ -13666,26 +13788,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */ - || kind === 200 /* ImportType */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 200 /* SyntaxKind.ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: return true; default: return false; @@ -13693,13 +13815,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 208 /* CallExpression */ || node.kind === 209 /* NewExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */ || node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 223 /* TemplateExpression */ - || kind === 14 /* NoSubstitutionTemplateLiteral */; + return kind === 223 /* SyntaxKind.TemplateExpression */ + || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13709,36 +13831,36 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 209 /* NewExpression */: - case 208 /* CallExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 210 /* TaggedTemplateExpression */: - case 204 /* ArrayLiteralExpression */: - case 212 /* ParenthesizedExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression - case 13 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 110 /* TrueKeyword */: - case 106 /* SuperKeyword */: - case 230 /* NonNullExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 231 /* MetaProperty */: - case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 230 /* SyntaxKind.NonNullExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 231 /* SyntaxKind.MetaProperty */: + case 100 /* SyntaxKind.ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13751,13 +13873,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 218 /* AwaitExpression */: - case 211 /* TypeAssertionExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13766,11 +13888,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 45 /* PlusPlusToken */ || - expr.operator === 46 /* MinusMinusToken */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || + expr.operator === 46 /* SyntaxKind.MinusMinusToken */; default: return false; } @@ -13787,15 +13909,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - case 214 /* ArrowFunction */: - case 221 /* BinaryExpression */: - case 225 /* SpreadElement */: - case 229 /* AsExpression */: - case 227 /* OmittedExpression */: - case 351 /* CommaListExpression */: - case 350 /* PartiallyEmittedExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 221 /* SyntaxKind.BinaryExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 229 /* SyntaxKind.AsExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13803,8 +13925,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 211 /* TypeAssertionExpression */ - || kind === 229 /* AsExpression */; + return kind === 211 /* SyntaxKind.TypeAssertionExpression */ + || kind === 229 /* SyntaxKind.AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13815,13 +13937,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13839,18 +13961,18 @@ var ts; ts.hasScopeMarker = hasScopeMarker; /* @internal */ function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */) && !ts.isAmbientModule(result); } ts.needsScopeMarker = needsScopeMarker; /* @internal */ function isExternalModuleIndicator(result) { // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* Export */); + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */); } ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 243 /* ForInStatement */ || node.kind === 244 /* ForOfStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */ || node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13874,115 +13996,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */ - || kind === 79 /* Identifier */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 261 /* ModuleDeclaration */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 269 /* NamedImports */ - || kind === 268 /* NamespaceImport */; + return kind === 269 /* SyntaxKind.NamedImports */ + || kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ || node.kind === 260 /* EnumDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 214 /* ArrowFunction */ - || kind === 203 /* BindingElement */ - || kind === 257 /* ClassDeclaration */ - || kind === 226 /* ClassExpression */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 171 /* Constructor */ - || kind === 260 /* EnumDeclaration */ - || kind === 299 /* EnumMember */ - || kind === 275 /* ExportSpecifier */ - || kind === 256 /* FunctionDeclaration */ - || kind === 213 /* FunctionExpression */ - || kind === 172 /* GetAccessor */ - || kind === 267 /* ImportClause */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 270 /* ImportSpecifier */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 285 /* JsxAttribute */ - || kind === 169 /* MethodDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 261 /* ModuleDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 268 /* NamespaceImport */ - || kind === 274 /* NamespaceExport */ - || kind === 164 /* Parameter */ - || kind === 296 /* PropertyAssignment */ - || kind === 167 /* PropertyDeclaration */ - || kind === 166 /* PropertySignature */ - || kind === 173 /* SetAccessor */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 163 /* TypeParameter */ - || kind === 254 /* VariableDeclaration */ - || kind === 345 /* JSDocTypedefTag */ - || kind === 338 /* JSDocCallbackTag */ - || kind === 347 /* JSDocPropertyTag */; + return kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 203 /* SyntaxKind.BindingElement */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 299 /* SyntaxKind.EnumMember */ + || kind === 275 /* SyntaxKind.ExportSpecifier */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 267 /* SyntaxKind.ImportClause */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 270 /* SyntaxKind.ImportSpecifier */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 268 /* SyntaxKind.NamespaceImport */ + || kind === 274 /* SyntaxKind.NamespaceExport */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 254 /* SyntaxKind.VariableDeclaration */ + || kind === 345 /* SyntaxKind.JSDocTypedefTag */ + || kind === 338 /* SyntaxKind.JSDocCallbackTag */ + || kind === 347 /* SyntaxKind.JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 246 /* BreakStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 240 /* DoStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 236 /* EmptyStatement */ - || kind === 243 /* ForInStatement */ - || kind === 244 /* ForOfStatement */ - || kind === 242 /* ForStatement */ - || kind === 239 /* IfStatement */ - || kind === 250 /* LabeledStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 249 /* SwitchStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 252 /* TryStatement */ - || kind === 237 /* VariableStatement */ - || kind === 241 /* WhileStatement */ - || kind === 248 /* WithStatement */ - || kind === 349 /* NotEmittedStatement */ - || kind === 353 /* EndOfDeclarationMarker */ - || kind === 352 /* MergeDeclarationMarker */; + return kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 236 /* SyntaxKind.EmptyStatement */ + || kind === 243 /* SyntaxKind.ForInStatement */ + || kind === 244 /* SyntaxKind.ForOfStatement */ + || kind === 242 /* SyntaxKind.ForStatement */ + || kind === 239 /* SyntaxKind.IfStatement */ + || kind === 250 /* SyntaxKind.LabeledStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 249 /* SyntaxKind.SwitchStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 252 /* SyntaxKind.TryStatement */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 241 /* SyntaxKind.WhileStatement */ + || kind === 248 /* SyntaxKind.WithStatement */ + || kind === 349 /* SyntaxKind.NotEmittedStatement */ + || kind === 353 /* SyntaxKind.EndOfDeclarationMarker */ + || kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 163 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 344 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { + return (node.parent && node.parent.kind !== 344 /* SyntaxKind.JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14009,10 +14131,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 235 /* Block */) + if (node.kind !== 235 /* SyntaxKind.Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 252 /* TryStatement */ || node.parent.kind === 292 /* CatchClause */) { + if (node.parent.kind === 252 /* SyntaxKind.TryStatement */ || node.parent.kind === 292 /* SyntaxKind.CatchClause */) { return false; } } @@ -14026,76 +14148,76 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 235 /* Block */; + || kind === 235 /* SyntaxKind.Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 277 /* ExternalModuleReference */ - || kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 277 /* SyntaxKind.ExternalModuleReference */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 108 /* ThisKeyword */ - || kind === 79 /* Identifier */ - || kind === 206 /* PropertyAccessExpression */; + return kind === 108 /* SyntaxKind.ThisKeyword */ + || kind === 79 /* SyntaxKind.Identifier */ + || kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 278 /* JsxElement */ - || kind === 288 /* JsxExpression */ - || kind === 279 /* JsxSelfClosingElement */ - || kind === 11 /* JsxText */ - || kind === 282 /* JsxFragment */; + return kind === 278 /* SyntaxKind.JsxElement */ + || kind === 288 /* SyntaxKind.JsxExpression */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */ + || kind === 11 /* SyntaxKind.JsxText */ + || kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 285 /* JsxAttribute */ - || kind === 287 /* JsxSpreadAttribute */; + return kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 288 /* JsxExpression */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 288 /* SyntaxKind.JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 280 /* JsxOpeningElement */ - || kind === 279 /* JsxSelfClosingElement */; + return kind === 280 /* SyntaxKind.JsxOpeningElement */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 289 /* CaseClause */ - || kind === 290 /* DefaultClause */; + return kind === 289 /* SyntaxKind.CaseClause */ + || kind === 290 /* SyntaxKind.DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 309 /* FirstJSDocNode */ && node.kind <= 347 /* LastJSDocNode */; + return node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 320 /* JSDoc */ - || node.kind === 319 /* JSDocNamepathType */ - || node.kind === 321 /* JSDocText */ + return node.kind === 320 /* SyntaxKind.JSDoc */ + || node.kind === 319 /* SyntaxKind.JSDocNamepathType */ + || node.kind === 321 /* SyntaxKind.JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) @@ -14105,15 +14227,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 327 /* FirstJSDocTagNode */ && node.kind <= 347 /* LastJSDocTagNode */; + return node.kind >= 327 /* SyntaxKind.FirstJSDocTagNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14139,12 +14261,12 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: return true; default: return false; @@ -14152,12 +14274,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 285 /* JsxAttribute */ || node.kind === 287 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 285 /* SyntaxKind.JsxAttribute */ || node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 178 /* TypeReference */ || node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14186,11 +14308,11 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */ || node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; function isJSDocLinkLike(node) { - return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 324 /* SyntaxKind.JSDocLink */ || node.kind === 325 /* SyntaxKind.JSDocLinkCode */ || node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkLike = isJSDocLinkLike; function hasRestParameter(s) { @@ -14200,7 +14322,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isRestParameter = isRestParameter; // #endregion @@ -14241,7 +14363,7 @@ var ts; } ts.createSymbolTable = createSymbolTable; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } ts.isTransientSymbol = isTransientSymbol; var stringWriter = createSingleLineStringWriter(); @@ -14402,11 +14524,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -14437,28 +14559,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 1048576 /* HasAggregatedChildData */)) { + if (!(node.flags & 1048576 /* NodeFlags.HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* NodeFlags.ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 1048576 /* HasAggregatedChildData */; + node.flags |= 1048576 /* NodeFlags.HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 305 /* SourceFile */) { + while (node && node.kind !== 305 /* SyntaxKind.SourceFile */) { node = node.parent; } return node; @@ -14469,16 +14591,16 @@ var ts; } ts.getSourceFileOfModule = getSourceFileOfModule; function isPlainJsFile(file, checkJs) { - return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined; + return !!file && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */) && !file.checkJsDirective && checkJs === undefined; } ts.isPlainJsFile = isPlainJsFile; function isStatementWithLocals(node) { switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return true; } return false; @@ -14493,7 +14615,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -14546,7 +14668,7 @@ var ts; if (node === undefined) { return true; } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -14580,7 +14702,7 @@ var ts; return to; } function isAnyPrologueDirective(node) { - return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } /** * Prepends statements to an array while taking care of prologue directives. @@ -14612,9 +14734,9 @@ var ts; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments - if (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + if (text.charCodeAt(commentPos + 1) === 47 /* CharacterCodes.slash */ && commentPos + 2 < commentEnd && - text.charCodeAt(commentPos + 2) === 47 /* slash */) { + text.charCodeAt(commentPos + 2) === 47 /* CharacterCodes.slash */) { var textSubStr = text.substring(commentPos, commentEnd); return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || @@ -14626,13 +14748,13 @@ var ts; } ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; function isPinnedComment(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 33 /* exclamation */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 33 /* CharacterCodes.exclamation */; } ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -14641,7 +14763,7 @@ var ts; return ts.arrayFrom(directivesByLine.entries()) .filter(function (_a) { var line = _a[0], directive = _a[1]; - return directive.type === 0 /* ExpectError */ && !usedLines.get(line); + return directive.type === 0 /* CommentDirectiveType.ExpectError */ && !usedLines.get(line); }) .map(function (_a) { var _ = _a[0], directive = _a[1]; @@ -14649,10 +14771,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -14663,7 +14785,7 @@ var ts; if (nodeIsMissing(node)) { return node.pos; } - if (ts.isJSDocNode(node) || node.kind === 11 /* JsxText */) { + if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) { // JsxText cannot actually contain comments, even though the scanner will think it sees comments return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } @@ -14674,7 +14796,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 348 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -14842,56 +14964,56 @@ var ts; // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { - case 10 /* StringLiteral */: { - var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : - flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + case 10 /* SyntaxKind.StringLiteral */: { + var escapeText = flags & 2 /* GetLiteralTextFlags.JsxAttributeEscape */ ? escapeJsxAttributeString : + flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; if (node.singleQuote) { - return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + return "'" + escapeText(node.text, 39 /* CharacterCodes.singleQuote */) + "'"; } else { - return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + return '"' + escapeText(node.text, 34 /* CharacterCodes.doubleQuote */) + '"'; } } - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: { // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. - var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; - var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* CharacterCodes.backtick */)); switch (node.kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return "`" + rawText + "${"; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: return "}" + rawText + "${"; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: return "}" + rawText + "`"; } break; } - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return node.text; - case 13 /* RegularExpressionLiteral */: - if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) { - return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/"); + case 13 /* SyntaxKind.RegularExpressionLiteral */: + if (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) { + return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* CharacterCodes.backslash */ ? " /" : "/"); } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { - if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated)) { + if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) { return false; } - if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) { - return !!(flags & 8 /* AllowNumericSeparator */); + if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) { + return !!(flags & 8 /* GetLiteralTextFlags.AllowNumericSeparator */); } return !ts.isBigIntLiteral(node); } @@ -14906,21 +15028,21 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || + return (ts.getCombinedNodeFlags(declaration) & 3 /* NodeFlags.BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* SyntaxKind.StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -14944,16 +15066,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return !!node && node.kind === 261 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 305 /* SourceFile */ || - node.kind === 261 /* ModuleDeclaration */ || + return node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 1024 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* NodeFlags.GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -14965,9 +15087,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return ts.isExternalModule(node.parent); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -14991,10 +15113,10 @@ var ts; function isEffectiveStrictModeSourceFile(node, compilerOptions) { // We can only verify strict mode for JS/TS files switch (node.scriptKind) { - case 1 /* JS */: - case 3 /* TS */: - case 2 /* JSX */: - case 4 /* TSX */: + case 1 /* ScriptKind.JS */: + case 3 /* ScriptKind.TS */: + case 2 /* ScriptKind.JSX */: + case 4 /* ScriptKind.TSX */: break; default: return false; @@ -15024,24 +15146,24 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 292 /* CatchClause */: - case 261 /* ModuleDeclaration */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 167 /* PropertyDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 292 /* SyntaxKind.CatchClause */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); @@ -15051,9 +15173,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 323 /* JSDocSignature */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 323 /* SyntaxKind.JSDocSignature */: return true; default: ts.assertType(node); @@ -15063,25 +15185,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: ts.assertType(node); @@ -15091,8 +15213,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -15105,15 +15227,15 @@ var ts; ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 237 /* VariableStatement */: - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return true; default: return false; @@ -15154,19 +15276,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 162 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function tryGetTextOfPropertyName(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return undefined; @@ -15181,21 +15303,21 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return "this"; - case 80 /* PrivateIdentifier */: - case 79 /* Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); @@ -15285,7 +15407,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 235 /* Block */) { + if (node.body && node.body.kind === 235 /* SyntaxKind.Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -15299,7 +15421,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -15308,29 +15430,29 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 268 /* NamespaceImport */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 268 /* SyntaxKind.NamespaceImport */: errorNode = node.name; break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -15362,36 +15484,36 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isJsonSourceFile(file) { - return file.scriptKind === 6 /* JSON */; + return file.scriptKind === 6 /* ScriptKind.JSON */; } ts.isJsonSourceFile = isJsonSourceFile; function isEnumConst(node) { - return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(ts.getCombinedModifierFlags(node) & 2048 /* ModifierFlags.Const */); } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* ModifierFlags.Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); + return !!(ts.getCombinedNodeFlags(node) & 2 /* NodeFlags.Const */); } ts.isVarConst = isVarConst; function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); + return !!(ts.getCombinedNodeFlags(node) & 1 /* NodeFlags.Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 100 /* ImportKeyword */ + && n.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -15400,12 +15522,12 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 238 /* ExpressionStatement */ - && node.expression.kind === 10 /* StringLiteral */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */ + && node.expression.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isCustomPrologue(node) { - return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } ts.isCustomPrologue = isCustomPrologue; function isHoistedFunction(node) { @@ -15424,24 +15546,24 @@ var ts; } ts.isHoistedVariableStatement = isHoistedVariableStatement; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* SyntaxKind.JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 164 /* Parameter */ || - node.kind === 163 /* TypeParameter */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 214 /* ArrowFunction */ || - node.kind === 212 /* ParenthesizedExpression */ || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 275 /* ExportSpecifier */) ? + var commentRanges = (node.kind === 164 /* SyntaxKind.Parameter */ || + node.kind === 163 /* SyntaxKind.TypeParameter */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 214 /* SyntaxKind.ArrowFunction */ || + node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + return text.charCodeAt(comment.pos + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; @@ -15450,48 +15572,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (177 /* FirstTypeNode */ <= node.kind && node.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= node.kind && node.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return true; - case 114 /* VoidKeyword */: - return node.parent.kind !== 217 /* VoidExpression */; - case 228 /* ExpressionWithTypeArguments */: + case 114 /* SyntaxKind.VoidKeyword */: + return node.parent.kind !== 217 /* SyntaxKind.VoidExpression */; + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 163 /* TypeParameter */: - return node.parent.kind === 195 /* MappedType */ || node.parent.kind === 190 /* InferType */; + case 163 /* SyntaxKind.TypeParameter */: + return node.parent.kind === 195 /* SyntaxKind.MappedType */ || node.parent.kind === 190 /* SyntaxKind.InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */ || node.kind === 206 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: - case 108 /* ThisKeyword */: { + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: { var parent = node.parent; - if (parent.kind === 181 /* TypeQuery */) { + if (parent.kind === 181 /* SyntaxKind.TypeQuery */) { return false; } - if (parent.kind === 200 /* ImportType */) { + if (parent.kind === 200 /* SyntaxKind.ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -15500,40 +15622,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (177 /* FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (parent.kind) { - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return node === parent.constraint; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return node === parent.constraint; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return node === parent.type; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return node === parent.type; - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return node === parent.type; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return node === parent.type; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.contains(parent.typeArguments, node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -15558,23 +15680,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitor(node); - case 263 /* CaseBlock */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 263 /* SyntaxKind.CaseBlock */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return ts.forEachChild(node, traverse); } } @@ -15584,23 +15706,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -15623,10 +15745,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 183 /* ArrayType */) { + if (node && node.kind === 183 /* SyntaxKind.ArrayType */) { return node.elementType; } - else if (node && node.kind === 178 /* TypeReference */) { + else if (node && node.kind === 178 /* SyntaxKind.TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15636,12 +15758,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 182 /* TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 182 /* SyntaxKind.TypeLiteral */: return node.members; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return node.properties; } } @@ -15649,14 +15771,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 203 /* BindingElement */: - case 299 /* EnumMember */: - case 164 /* Parameter */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 299 /* SyntaxKind.EnumMember */: + case 164 /* SyntaxKind.Parameter */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } } @@ -15668,21 +15790,21 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ - && node.parent.parent.kind === 237 /* VariableStatement */; + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ + && node.parent.parent.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isCommonJsExportedExpression(node) { if (!isInJSFile(node)) return false; - return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) || + return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) || isCommonJsExportPropertyAssignment(node.parent); } ts.isCommonJsExportedExpression = isCommonJsExportedExpression; function isCommonJsExportPropertyAssignment(node) { if (!isInJSFile(node)) return false; - return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */); + return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* AssignmentDeclarationKind.ExportsProperty */); } ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment; function isValidESSymbolDeclaration(node) { @@ -15693,13 +15815,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return true; } return false; @@ -15710,7 +15832,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 250 /* LabeledStatement */) { + if (node.statement.kind !== 250 /* SyntaxKind.LabeledStatement */) { return node.statement; } node = node.statement; @@ -15718,30 +15840,30 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 235 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 169 /* MethodDeclaration */ && node.parent.kind === 205 /* ObjectLiteralExpression */; + return node && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethodOrAccessor(node) { - return (node.kind === 169 /* MethodDeclaration */ || node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) && - (node.parent.kind === 205 /* ObjectLiteralExpression */ || - node.parent.kind === 226 /* ClassExpression */); + return (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) && + (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || + node.parent.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor; function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1 /* Identifier */; + return predicate && predicate.kind === 1 /* TypePredicateKind.Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0 /* This */; + return predicate && predicate.kind === 0 /* TypePredicateKind.This */; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 296 /* PropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */) { var propName = tryGetTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15803,14 +15925,14 @@ var ts; } ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 305 /* SourceFile */); + ts.Debug.assert(node.kind !== 305 /* SyntaxKind.SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -15825,9 +15947,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -15838,27 +15960,27 @@ var ts; node = node.parent; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 261 /* ModuleDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 260 /* EnumDeclaration */: - case 305 /* SourceFile */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 305 /* SyntaxKind.SourceFile */: return node; } } @@ -15871,17 +15993,17 @@ var ts; switch (node.kind) { // Arrow functions use the same scope, but may do so in a "delayed" manner // For example, `const getThis = () => this` may be before a super() call in a derived constructor - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 167 /* PropertyDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Object properties can have computed names; only method-like bodies start a new scope return true; default: @@ -15905,9 +16027,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return container; } } @@ -15929,28 +16051,28 @@ var ts; return node; } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: node = node.parent; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return node; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -15966,21 +16088,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 213 /* FunctionExpression */ || func.kind === 214 /* ArrowFunction */) { + if (func.kind === 213 /* SyntaxKind.FunctionExpression */ || func.kind === 214 /* SyntaxKind.ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 212 /* ParenthesizedExpression */) { + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 208 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 106 /* SuperKeyword */ + return node.kind === 106 /* SyntaxKind.SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -15989,8 +16111,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 106 /* SuperKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -15998,34 +16120,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 108 /* ThisKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function isThisInitializedObjectBindingExpression(node) { return !!node && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) && ts.isBinaryExpression(node.parent.parent) - && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */ - && node.parent.parent.right.kind === 108 /* ThisKeyword */; + && node.parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && node.parent.parent.right.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: return node; } return undefined; @@ -16033,10 +16155,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return node.tag; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -16049,25 +16171,25 @@ var ts; return false; } switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // classes are valid targets return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 257 /* ClassDeclaration */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + return parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 257 /* ClassDeclaration */; - case 164 /* Parameter */: + && parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 164 /* SyntaxKind.Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 171 /* Constructor */ - || parent.kind === 169 /* MethodDeclaration */ - || parent.kind === 173 /* SetAccessor */) - && grandparent.kind === 257 /* ClassDeclaration */; + && (parent.kind === 171 /* SyntaxKind.Constructor */ + || parent.kind === 169 /* SyntaxKind.MethodDeclaration */ + || parent.kind === 173 /* SyntaxKind.SetAccessor */) + && grandparent.kind === 257 /* SyntaxKind.ClassDeclaration */; } return false; } @@ -16083,11 +16205,11 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -16103,9 +16225,9 @@ var ts; ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 280 /* JsxOpeningElement */ || - parent.kind === 279 /* JsxSelfClosingElement */ || - parent.kind === 281 /* JsxClosingElement */) { + if (parent.kind === 280 /* SyntaxKind.JsxOpeningElement */ || + parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || + parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return parent.tagName === node; } return false; @@ -16113,66 +16235,66 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 13 /* RegularExpressionLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 229 /* AsExpression */: - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 221 /* BinaryExpression */: - case 222 /* ConditionalExpression */: - case 225 /* SpreadElement */: - case 223 /* TemplateExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 224 /* YieldExpression */: - case 218 /* AwaitExpression */: - case 231 /* MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 223 /* SyntaxKind.TemplateExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 224 /* SyntaxKind.YieldExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 231 /* SyntaxKind.MetaProperty */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return !ts.isHeritageClause(node.parent); - case 161 /* QualifiedName */: - while (node.parent.kind === 161 /* QualifiedName */) { + case 161 /* SyntaxKind.QualifiedName */: + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 311 /* JSDocMemberName */: + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 311 /* SyntaxKind.JSDocMemberName */: while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 80 /* PrivateIdentifier */: - return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */; - case 79 /* Identifier */: - if (node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 80 /* SyntaxKind.PrivateIdentifier */: + return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; + case 79 /* SyntaxKind.Identifier */: + if (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -16182,49 +16304,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: return parent.initializer === node; - case 238 /* ExpressionStatement */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 247 /* ReturnStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 251 /* ThrowStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 251 /* SyntaxKind.ThrowStatement */: return parent.expression === node; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forInStatement.expression === node; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return node === parent.expression; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node === parent.expression; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return node === parent.expression; - case 165 /* Decorator */: - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: - case 298 /* SpreadAssignment */: + case 165 /* SyntaxKind.Decorator */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 298 /* SyntaxKind.SpreadAssignment */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return parent.expression === node && !isPartOfTypeNode(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -16232,10 +16354,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 161 /* QualifiedName */ || node.kind === 79 /* Identifier */) { + while (node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 79 /* SyntaxKind.Identifier */) { node = node.parent; } - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -16243,7 +16365,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -16256,7 +16378,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -16268,11 +16390,11 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 262144 /* JavaScriptFile */); + return !!node && !!(node.flags & 262144 /* NodeFlags.JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 67108864 /* JsonFile */); + return !!node && !!(node.flags & 67108864 /* NodeFlags.JsonFile */); } ts.isInJsonFile = isInJsonFile; function isSourceFileNotJson(file) { @@ -16280,7 +16402,7 @@ var ts; } ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { - return !!node && !!(node.flags & 8388608 /* JSDoc */); + return !!node && !!(node.flags & 8388608 /* NodeFlags.JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -16288,15 +16410,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 150 /* StringKeyword */ || node.typeArguments[0].kind === 147 /* NumberKeyword */); + (node.typeArguments[0].kind === 150 /* SyntaxKind.StringKeyword */ || node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 208 /* CallExpression */) { + if (callExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* SyntaxKind.Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -16333,11 +16455,11 @@ var ts; } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { - return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */; + return charCode === 39 /* CharacterCodes.singleQuote */ || charCode === 34 /* CharacterCodes.doubleQuote */; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isStringDoubleQuoted(str, sourceFile) { - return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; + return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; function isAssignmentDeclaration(decl) { @@ -16348,7 +16470,7 @@ var ts; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && ts.isBinaryExpression(node.initializer) && - (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && + (node.initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -16375,7 +16497,7 @@ var ts; * 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 === 63 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -16401,11 +16523,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 213 /* FunctionExpression */ || e.kind === 214 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 213 /* FunctionExpression */ || - initializer.kind === 226 /* ClassExpression */ || - initializer.kind === 214 /* ArrowFunction */) { + if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ || + initializer.kind === 226 /* SyntaxKind.ClassExpression */ || + initializer.kind === 214 /* SyntaxKind.ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -16423,7 +16545,7 @@ var ts; */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { var e = ts.isBinaryExpression(initializer) - && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && (initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; @@ -16431,7 +16553,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -16439,8 +16561,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -16463,7 +16585,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 108 /* ThisKeyword */ || + (initializer.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -16502,7 +16624,7 @@ var ts; /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); - return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; + return special === 5 /* AssignmentDeclarationKind.Property */ || isInJSFile(expr) ? special : 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; function isBindableObjectDefinePropertyCall(expr) { @@ -16527,14 +16649,14 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; /** Any series of property and element accesses, ending in a literal element access */ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -16553,23 +16675,23 @@ var ts; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } var entityName = expr.arguments[0]; if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { - return 8 /* ObjectDefinePropertyExports */; + return 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */; } if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { - return 9 /* ObjectDefinePrototypeProperty */; + return 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */; } - return 7 /* ObjectDefinePropertyValue */; + return 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { - return 0 /* None */; + if (expr.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + return 0 /* AssignmentDeclarationKind.None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } - return 6 /* Prototype */; + return 6 /* AssignmentDeclarationKind.Prototype */; } return getAssignmentDeclarationPropertyAccessKind(expr.left); } @@ -16606,17 +16728,17 @@ var ts; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 108 /* ThisKeyword */) { - return 4 /* ThisProperty */; + if (lhs.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { + return 4 /* AssignmentDeclarationKind.ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr - return 2 /* ModuleExports */; + return 2 /* AssignmentDeclarationKind.ModuleExports */; } else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr - return 3 /* PrototypeProperty */; + return 3 /* AssignmentDeclarationKind.PrototypeProperty */; } var nextToLast = lhs; while (!ts.isIdentifier(nextToLast.expression)) { @@ -16628,14 +16750,14 @@ var ts; // ExportsProperty does not support binding with computed names isBindableStaticAccessExpression(lhs)) { // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... - return 1 /* ExportsProperty */; + return 1 /* AssignmentDeclarationKind.ExportsProperty */; } if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) { // F.G...x = expr - return 5 /* Property */; + return 5 /* AssignmentDeclarationKind.Property */; } } - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { @@ -16646,12 +16768,12 @@ var ts; } ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression; function isPrototypePropertyAssignment(node) { - return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */; + return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 238 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -16659,7 +16781,7 @@ var ts; function setValueDeclaration(symbol, node) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) && + !(node.flags & 16777216 /* NodeFlags.Ambient */ && !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { // other kinds of value declarations take precedence over modules and assignment declarations @@ -16672,17 +16794,17 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 256 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 256 /* SyntaxKind.FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { var _a, _b; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0]; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike); default: ts.Debug.assertNever(node); @@ -16695,14 +16817,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.parent; - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return node.parent.parent; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16712,17 +16834,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.moduleSpecifier; - case 265 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 277 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 200 /* ImportType */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 200 /* SyntaxKind.ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return node.arguments[0]; - case 261 /* ModuleDeclaration */: - return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; + case 261 /* SyntaxKind.ModuleDeclaration */: + return node.name.kind === 10 /* SyntaxKind.StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -16730,11 +16852,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16742,7 +16864,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 266 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16763,13 +16885,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 164 /* Parameter */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return node.questionToken !== undefined; } } @@ -16783,7 +16905,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 345 /* JSDocTypedefTag */ || node.kind === 338 /* JSDocCallbackTag */ || node.kind === 339 /* JSDocEnumTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || node.kind === 338 /* SyntaxKind.JSDocCallbackTag */ || node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16793,27 +16915,27 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 63 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && + getAssignmentDeclarationKind(node.expression) !== 0 /* AssignmentDeclarationKind.None */ && ts.isBinaryExpression(node.expression.right) && - (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) + (node.expression.right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return node.initializer; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return node.initializer; } } @@ -16825,7 +16947,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 261 /* ModuleDeclaration */ + node.body.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? node.body : undefined; } @@ -16840,11 +16962,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc))); } - if (node.kind === 164 /* Parameter */) { + if (node.kind === 164 /* SyntaxKind.Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 163 /* TypeParameter */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -16873,13 +16995,13 @@ var ts; } function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 296 /* PropertyAssignment */ || - parent.kind === 271 /* ExportAssignment */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 238 /* ExpressionStatement */ && node.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 247 /* ReturnStatement */ || + if (parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + parent.kind === 271 /* SyntaxKind.ExportAssignment */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 247 /* SyntaxKind.ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -16890,7 +17012,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -16914,7 +17036,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* SyntaxKind.Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -16987,41 +17109,41 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + binaryOperator === 63 /* SyntaxKind.EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* AssignmentKind.Definite */ : 2 /* AssignmentKind.Compound */ : + 0 /* AssignmentKind.None */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 212 /* ParenthesizedExpression */: - case 204 /* ArrayLiteralExpression */: - case 225 /* SpreadElement */: - case 230 /* NonNullExpression */: + return unaryOperator === 45 /* SyntaxKind.PlusPlusToken */ || unaryOperator === 46 /* SyntaxKind.MinusMinusToken */ ? 2 /* AssignmentKind.Compound */ : 0 /* AssignmentKind.None */; + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + return parent.initializer === node ? 1 /* AssignmentKind.Definite */ : 0 /* AssignmentKind.None */; + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 230 /* SyntaxKind.NonNullExpression */: node = parent; break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: node = parent.parent; break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (parent.name !== node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (parent.name === node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; default: - return 0 /* None */; + return 0 /* AssignmentKind.None */; } parent = node.parent; } @@ -17032,7 +17154,7 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0 /* None */; + return getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */; } ts.isAssignmentTarget = isAssignmentTarget; /** @@ -17041,22 +17163,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 235 /* Block */: - case 237 /* VariableStatement */: - case 248 /* WithStatement */: - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 235 /* SyntaxKind.Block */: + case 237 /* SyntaxKind.VariableStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return true; } return false; @@ -17073,11 +17195,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 191 /* ParenthesizedType */); + return walkUp(node, 191 /* SyntaxKind.ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 212 /* ParenthesizedExpression */); + return walkUp(node, 212 /* SyntaxKind.ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -17087,7 +17209,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 191 /* ParenthesizedType */) { + while (node && node.kind === 191 /* SyntaxKind.ParenthesizedType */) { child = node; node = node.parent; } @@ -17102,18 +17224,18 @@ var ts; ts.skipTypeParentheses = skipTypeParentheses; function skipParentheses(node, excludeJSDocTypeAssertions) { var flags = excludeJSDocTypeAssertions ? - 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : - 1 /* Parentheses */; + 1 /* OuterExpressionKinds.Parentheses */ | 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ : + 1 /* OuterExpressionKinds.Parentheses */; return ts.skipOuterExpressions(node, flags); } ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 206 /* PropertyAccessExpression */ && node.kind !== 207 /* ElementAccessExpression */) { + if (node.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 207 /* SyntaxKind.ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 215 /* DeleteExpression */; + return node && node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -17134,13 +17256,13 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -17151,13 +17273,13 @@ var ts; else { var binExp = parent.parent; return ts.isBinaryExpression(binExp) && - getAssignmentDeclarationKind(binExp) !== 0 /* None */ && + getAssignmentDeclarationKind(binExp) !== 0 /* AssignmentDeclarationKind.None */ && (binExp.left.symbol || binExp.symbol) && ts.getNameOfDeclaration(binExp) === name ? binExp : undefined; } - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -17166,7 +17288,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 162 /* ComputedPropertyName */ && + node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -17174,29 +17296,29 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 206 /* PropertyAccessExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 203 /* BindingElement */: - case 270 /* ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 275 /* ExportSpecifier */: - case 285 /* JsxAttribute */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 285 /* SyntaxKind.JsxAttribute */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: // Any name in an export specifier or JSX Attribute or Jsx Element return true; } @@ -17219,38 +17341,38 @@ var ts; // const x = require("...").y // const { x } = require("...").y function isAliasSymbolDeclaration(node) { - if (node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - node.kind === 267 /* ImportClause */ && !!node.name || - node.kind === 268 /* NamespaceImport */ || - node.kind === 274 /* NamespaceExport */ || - node.kind === 270 /* ImportSpecifier */ || - node.kind === 275 /* ExportSpecifier */ || - node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) { + if (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name || + node.kind === 268 /* SyntaxKind.NamespaceImport */ || + node.kind === 274 /* SyntaxKind.NamespaceExport */ || + node.kind === 270 /* SyntaxKind.ImportSpecifier */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ && exportAssignmentIsAlias(node)) { return true; } - return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && exportAssignmentIsAlias(node) || ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableExpression(node.parent.right)); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 268 /* NamespaceImport */: - case 275 /* ExportSpecifier */: - case 271 /* ExportAssignment */: - case 265 /* ImportEqualsDeclaration */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 271 /* SyntaxKind.ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 161 /* QualifiedName */); + } while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -17269,7 +17391,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* PropertyAssignment */ ? node.initializer : + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -17286,7 +17408,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -17295,7 +17417,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* SyntaxKind.ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -17308,7 +17430,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -17335,11 +17457,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 81 /* FirstKeyword */ <= token && token <= 160 /* LastKeyword */; + return 81 /* SyntaxKind.FirstKeyword */ <= token && token <= 160 /* SyntaxKind.LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 126 /* FirstContextualKeyword */ <= token && token <= 160 /* LastContextualKeyword */; + return 126 /* SyntaxKind.FirstContextualKeyword */ <= token && token <= 160 /* SyntaxKind.LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -17347,7 +17469,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; + return 117 /* SyntaxKind.FirstFutureReservedWord */ <= token && token <= 125 /* SyntaxKind.LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -17366,7 +17488,7 @@ var ts; } ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + return 2 /* SyntaxKind.FirstTriviaToken */ <= token && token <= 7 /* SyntaxKind.LastTriviaToken */; } ts.isTrivia = isTrivia; var FunctionFlags; @@ -17379,38 +17501,38 @@ var ts; })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { - return 4 /* Invalid */; + return 4 /* FunctionFlags.Invalid */; } - var flags = 0 /* Normal */; + var flags = 0 /* FunctionFlags.Normal */; switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - flags |= 1 /* Generator */; + flags |= 1 /* FunctionFlags.Generator */; } // falls through - case 214 /* ArrowFunction */: - if (hasSyntacticModifier(node, 256 /* Async */)) { - flags |= 2 /* Async */; + case 214 /* SyntaxKind.ArrowFunction */: + if (hasSyntacticModifier(node, 256 /* ModifierFlags.Async */)) { + flags |= 2 /* FunctionFlags.Async */; } break; } if (!node.body) { - flags |= 4 /* Invalid */; + flags |= 4 /* FunctionFlags.Invalid */; } return flags; } ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined - && hasSyntacticModifier(node, 256 /* Async */); + && hasSyntacticModifier(node, 256 /* ModifierFlags.Async */); } return false; } @@ -17420,7 +17542,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* SyntaxKind.PlusToken */ || node.operator === 40 /* SyntaxKind.MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -17437,7 +17559,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) { + if (!(name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || name.kind === 207 /* SyntaxKind.ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -17447,19 +17569,19 @@ var ts; ts.isDynamicName = isDynamicName; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { - if (nameExpression.operator === 40 /* MinusToken */) { + if (nameExpression.operator === 40 /* SyntaxKind.MinusToken */) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } return nameExpression.operand.text; @@ -17472,10 +17594,10 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return true; default: return false; @@ -17491,11 +17613,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -17510,7 +17632,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -17519,11 +17641,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 164 /* Parameter */; + return root.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 203 /* BindingElement */) { + while (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return node; @@ -17531,15 +17653,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 213 /* FunctionExpression */ - || kind === 256 /* FunctionDeclaration */ - || kind === 214 /* ArrowFunction */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 261 /* ModuleDeclaration */ - || kind === 305 /* SourceFile */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 305 /* SyntaxKind.SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -17558,58 +17680,58 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 209 /* NewExpression */: - return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - return 1 /* Right */; - case 221 /* BinaryExpression */: + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 0 /* Associativity.Left */ : 1 /* Associativity.Right */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + return 1 /* Associativity.Right */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operator) { - case 42 /* AsteriskAsteriskToken */: - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 1 /* Right */; - } - } - return 0 /* Left */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 1 /* Associativity.Right */; + } + } + return 0 /* Associativity.Left */; } ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 221 /* BinaryExpression */) { + if (expression.kind === 221 /* SyntaxKind.BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 219 /* PrefixUnaryExpression */ || expression.kind === 220 /* PostfixUnaryExpression */) { + else if (expression.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || expression.kind === 220 /* SyntaxKind.PostfixUnaryExpression */) { return expression.operator; } else { @@ -17788,129 +17910,129 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 351 /* CommaListExpression */: - return 0 /* Comma */; - case 225 /* SpreadElement */: - return 1 /* Spread */; - case 224 /* YieldExpression */: - return 2 /* Yield */; - case 222 /* ConditionalExpression */: - return 4 /* Conditional */; - case 221 /* BinaryExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + return 0 /* OperatorPrecedence.Comma */; + case 225 /* SyntaxKind.SpreadElement */: + return 1 /* OperatorPrecedence.Spread */; + case 224 /* SyntaxKind.YieldExpression */: + return 2 /* OperatorPrecedence.Yield */; + case 222 /* SyntaxKind.ConditionalExpression */: + return 4 /* OperatorPrecedence.Conditional */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operatorKind) { - case 27 /* CommaToken */: - return 0 /* Comma */; - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 3 /* Assignment */; + case 27 /* SyntaxKind.CommaToken */: + return 0 /* OperatorPrecedence.Comma */; + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 3 /* OperatorPrecedence.Assignment */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - return 16 /* Unary */; - case 220 /* PostfixUnaryExpression */: - return 17 /* Update */; - case 208 /* CallExpression */: - return 18 /* LeftHandSide */; - case 209 /* NewExpression */: - return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 210 /* TaggedTemplateExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 231 /* MetaProperty */: - return 19 /* Member */; - case 229 /* AsExpression */: - return 11 /* Relational */; - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 212 /* ParenthesizedExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - return 20 /* Primary */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + return 16 /* OperatorPrecedence.Unary */; + case 220 /* SyntaxKind.PostfixUnaryExpression */: + return 17 /* OperatorPrecedence.Update */; + case 208 /* SyntaxKind.CallExpression */: + return 18 /* OperatorPrecedence.LeftHandSide */; + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 19 /* OperatorPrecedence.Member */ : 18 /* OperatorPrecedence.LeftHandSide */; + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 231 /* SyntaxKind.MetaProperty */: + return 19 /* OperatorPrecedence.Member */; + case 229 /* SyntaxKind.AsExpression */: + return 11 /* OperatorPrecedence.Relational */; + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + return 20 /* OperatorPrecedence.Primary */; default: - return -1 /* Invalid */; + return -1 /* OperatorPrecedence.Invalid */; } } ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 60 /* QuestionQuestionToken */: - return 4 /* Coalesce */; - case 56 /* BarBarToken */: - return 5 /* LogicalOR */; - case 55 /* AmpersandAmpersandToken */: - return 6 /* LogicalAND */; - case 51 /* BarToken */: - return 7 /* BitwiseOR */; - case 52 /* CaretToken */: - return 8 /* BitwiseXOR */; - case 50 /* AmpersandToken */: - return 9 /* BitwiseAND */; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - return 10 /* Equality */; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - return 11 /* Relational */; - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - return 12 /* Shift */; - case 39 /* PlusToken */: - case 40 /* MinusToken */: - return 13 /* Additive */; - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - return 14 /* Multiplicative */; - case 42 /* AsteriskAsteriskToken */: - return 15 /* Exponentiation */; + case 60 /* SyntaxKind.QuestionQuestionToken */: + return 4 /* OperatorPrecedence.Coalesce */; + case 56 /* SyntaxKind.BarBarToken */: + return 5 /* OperatorPrecedence.LogicalOR */; + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + return 6 /* OperatorPrecedence.LogicalAND */; + case 51 /* SyntaxKind.BarToken */: + return 7 /* OperatorPrecedence.BitwiseOR */; + case 52 /* SyntaxKind.CaretToken */: + return 8 /* OperatorPrecedence.BitwiseXOR */; + case 50 /* SyntaxKind.AmpersandToken */: + return 9 /* OperatorPrecedence.BitwiseAND */; + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + return 10 /* OperatorPrecedence.Equality */; + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + return 11 /* OperatorPrecedence.Relational */; + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + return 12 /* OperatorPrecedence.Shift */; + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + return 13 /* OperatorPrecedence.Additive */; + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + return 14 /* OperatorPrecedence.Multiplicative */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + return 15 /* OperatorPrecedence.Exponentiation */; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. @@ -17920,9 +18042,9 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !!i.expression; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return !i.containsOnlyTriviaWhiteSpaces; default: return true; @@ -18037,9 +18159,9 @@ var ts; return "\\u" + paddedHexCode; } function getReplacement(c, offset, input) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); - if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) { + if (lookAhead >= 48 /* CharacterCodes._0 */ && lookAhead <= 57 /* CharacterCodes._9 */) { // If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode) return "\\x00"; } @@ -18054,8 +18176,8 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : - quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 96 /* CharacterCodes.backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* CharacterCodes.singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } @@ -18085,13 +18207,13 @@ var ts; return "&#x" + hexCharCode + ";"; } function getJsxAttributeStringReplacement(c) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { return "�"; } return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0)); } function escapeJsxAttributeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 39 /* CharacterCodes.singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : jsxDoubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement); } @@ -18110,13 +18232,13 @@ var ts; } ts.stripQuotes = stripQuotes; function isQuoteOrBacktick(charCode) { - return charCode === 39 /* singleQuote */ || - charCode === 34 /* doubleQuote */ || - charCode === 96 /* backtick */; + return charCode === 39 /* CharacterCodes.singleQuote */ || + charCode === 34 /* CharacterCodes.doubleQuote */ || + charCode === 96 /* CharacterCodes.backtick */; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); + return (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; var indentStrings = ["", " "]; @@ -18361,20 +18483,20 @@ var ts; } ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker; function getDeclarationEmitExtensionForPath(path) { - return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : - ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : - ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well - ".d.ts" /* Dts */; + return ts.fileExtensionIsOneOf(path, [".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? ".d.mts" /* Extension.Dmts */ : + ts.fileExtensionIsOneOf(path, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? ".d.cts" /* Extension.Dcts */ : + ts.fileExtensionIsOneOf(path, [".json" /* Extension.Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + ".d.ts" /* Extension.Dts */; } ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; /** * This function is an inverse of `getDeclarationEmitExtensionForPath`. */ function getPossibleOriginalInputExtensionForExtension(path) { - return ts.fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : - ts.fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : - ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Json */] : - [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */]; + return ts.fileExtensionIsOneOf(path, [".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */] : + ts.fileExtensionIsOneOf(path, [".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */] : + ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Extension.Json */] : + [".tsx" /* Extension.Tsx */, ".ts" /* Extension.Ts */, ".jsx" /* Extension.Jsx */, ".js" /* Extension.Js */]; } ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension; function outFile(options) { @@ -18502,7 +18624,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* SyntaxKind.Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function isThisInTypeQuery(node) { @@ -18512,11 +18634,11 @@ var ts; while (ts.isQualifiedName(node.parent) && node.parent.left === node) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */; + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 108 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* SyntaxKind.ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -18527,10 +18649,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 173 /* SetAccessor */) { + else if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { setAccessor = accessor; } else { @@ -18550,10 +18672,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 172 /* GetAccessor */ && !getAccessor) { + if (member.kind === 172 /* SyntaxKind.GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 173 /* SetAccessor */ && !setAccessor) { + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -18602,7 +18724,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* SyntaxKind.JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18719,7 +18841,7 @@ var ts; } ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); var lineCount = lineMap.length; var firstCommentLineIndent = void 0; @@ -18794,7 +18916,7 @@ var ts; function calculateIndent(text, pos, end) { var currentLineIndent = 0; for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9 /* tab */) { + if (text.charCodeAt(pos) === 9 /* CharacterCodes.tab */) { // Tabs = TabSize = indent size and go to next tabStop currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } @@ -18806,11 +18928,11 @@ var ts; return currentLineIndent; } function hasEffectiveModifiers(node) { - return getEffectiveModifierFlags(node) !== 0 /* None */; + return getEffectiveModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasEffectiveModifiers = hasEffectiveModifiers; function hasSyntacticModifiers(node) { - return getSyntacticModifierFlags(node) !== 0 /* None */; + return getSyntacticModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasSyntacticModifiers = hasSyntacticModifiers; function hasEffectiveModifier(node, flags) { @@ -18827,27 +18949,27 @@ var ts; } ts.isStatic = isStatic; function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 32 /* ModifierFlags.Static */); } ts.hasStaticModifier = hasStaticModifier; function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16384 /* ModifierFlags.Override */); } ts.hasOverrideModifier = hasOverrideModifier; function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 128 /* Abstract */); + return hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); } ts.hasAbstractModifier = hasAbstractModifier; function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */); } ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 64 /* ModifierFlags.Readonly */); } ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier; function hasDecorators(node) { - return hasSyntacticModifier(node, 131072 /* Decorator */); + return hasSyntacticModifier(node, 131072 /* ModifierFlags.Decorator */); } ts.hasDecorators = hasDecorators; function getSelectedEffectiveModifierFlags(node, flags) { @@ -18859,16 +18981,16 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 160 /* LastToken */) { - return 0 /* None */; + if (node.kind >= 0 /* SyntaxKind.FirstToken */ && node.kind <= 160 /* SyntaxKind.LastToken */) { + return 0 /* ModifierFlags.None */; } - if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { - node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; + if (!(node.modifierFlagsCache & 536870912 /* ModifierFlags.HasComputedFlags */)) { + node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* ModifierFlags.HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* ModifierFlags.HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { + node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* ModifierFlags.HasComputedJSDocModifiers */; } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return node.modifierFlagsCache & ~(536870912 /* ModifierFlags.HasComputedFlags */ | 4096 /* ModifierFlags.HasComputedJSDocModifiers */); } /** * Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance. @@ -18893,22 +19015,22 @@ var ts; } ts.getSyntacticModifierFlags = getSyntacticModifierFlags; function getJSDocModifierFlagsNoCache(node) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (!!node.parent && !ts.isParameter(node)) { if (isInJSFile(node)) { if (ts.getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 4 /* ModifierFlags.Public */; if (ts.getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 8 /* ModifierFlags.Private */; if (ts.getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 16 /* ModifierFlags.Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; if (ts.getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 8192 /* ModifierFlags.Deprecated */; } return flags; } @@ -18927,15 +19049,15 @@ var ts; * NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc. */ function getSyntacticModifierFlagsNoCache(node) { - var flags = ts.canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* None */; - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { - flags |= 1 /* Export */; + var flags = ts.canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* ModifierFlags.None */; + if (node.flags & 4 /* NodeFlags.NestedNamespace */ || (node.kind === 79 /* SyntaxKind.Identifier */ && node.isInJSDocNamespace)) { + flags |= 1 /* ModifierFlags.Export */; } return flags; } ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache; function modifiersToFlags(modifiers) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (modifiers) { for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; @@ -18947,23 +19069,23 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 124 /* StaticKeyword */: return 32 /* Static */; - case 123 /* PublicKeyword */: return 4 /* Public */; - case 122 /* ProtectedKeyword */: return 16 /* Protected */; - case 121 /* PrivateKeyword */: return 8 /* Private */; - case 126 /* AbstractKeyword */: return 128 /* Abstract */; - case 93 /* ExportKeyword */: return 1 /* Export */; - case 135 /* DeclareKeyword */: return 2 /* Ambient */; - case 85 /* ConstKeyword */: return 2048 /* Const */; - case 88 /* DefaultKeyword */: return 512 /* Default */; - case 131 /* AsyncKeyword */: return 256 /* Async */; - case 145 /* ReadonlyKeyword */: return 64 /* Readonly */; - case 159 /* OverrideKeyword */: return 16384 /* Override */; - case 101 /* InKeyword */: return 32768 /* In */; - case 144 /* OutKeyword */: return 65536 /* Out */; - case 165 /* Decorator */: return 131072 /* Decorator */; - } - return 0 /* None */; + case 124 /* SyntaxKind.StaticKeyword */: return 32 /* ModifierFlags.Static */; + case 123 /* SyntaxKind.PublicKeyword */: return 4 /* ModifierFlags.Public */; + case 122 /* SyntaxKind.ProtectedKeyword */: return 16 /* ModifierFlags.Protected */; + case 121 /* SyntaxKind.PrivateKeyword */: return 8 /* ModifierFlags.Private */; + case 126 /* SyntaxKind.AbstractKeyword */: return 128 /* ModifierFlags.Abstract */; + case 93 /* SyntaxKind.ExportKeyword */: return 1 /* ModifierFlags.Export */; + case 135 /* SyntaxKind.DeclareKeyword */: return 2 /* ModifierFlags.Ambient */; + case 85 /* SyntaxKind.ConstKeyword */: return 2048 /* ModifierFlags.Const */; + case 88 /* SyntaxKind.DefaultKeyword */: return 512 /* ModifierFlags.Default */; + case 131 /* SyntaxKind.AsyncKeyword */: return 256 /* ModifierFlags.Async */; + case 145 /* SyntaxKind.ReadonlyKeyword */: return 64 /* ModifierFlags.Readonly */; + case 159 /* SyntaxKind.OverrideKeyword */: return 16384 /* ModifierFlags.Override */; + case 101 /* SyntaxKind.InKeyword */: return 32768 /* ModifierFlags.In */; + case 144 /* SyntaxKind.OutKeyword */: return 65536 /* ModifierFlags.Out */; + case 165 /* SyntaxKind.Decorator */: return 131072 /* ModifierFlags.Decorator */; + } + return 0 /* ModifierFlags.None */; } ts.modifierToFlag = modifierToFlag; function createModifiers(modifierFlags) { @@ -18971,15 +19093,15 @@ var ts; } ts.createModifiers = createModifiers; function isLogicalOperator(token) { - return token === 56 /* BarBarToken */ - || token === 55 /* AmpersandAmpersandToken */ - || token === 53 /* ExclamationToken */; + return token === 56 /* SyntaxKind.BarBarToken */ + || token === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || token === 53 /* SyntaxKind.ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 75 /* BarBarEqualsToken */ - || token === 76 /* AmpersandAmpersandEqualsToken */ - || token === 77 /* QuestionQuestionEqualsToken */; + return token === 75 /* SyntaxKind.BarBarEqualsToken */ + || token === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */ + || token === 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -18987,7 +19109,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; + return token >= 63 /* SyntaxKind.FirstAssignment */ && token <= 78 /* SyntaxKind.LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -19000,14 +19122,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 63 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -19019,8 +19141,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 205 /* ObjectLiteralExpression */ - || kind === 204 /* ArrayLiteralExpression */; + return kind === 205 /* SyntaxKind.ObjectLiteralExpression */ + || kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } return false; } @@ -19030,33 +19152,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* SyntaxKind.Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 79 /* Identifier */ - || node.kind === 108 /* ThisKeyword */ - || node.kind === 106 /* SuperKeyword */ - || node.kind === 231 /* MetaProperty */ - || node.kind === 206 /* PropertyAccessExpression */ && isDottedName(node.expression) - || node.kind === 212 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 108 /* SyntaxKind.ThisKeyword */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */ + || node.kind === 231 /* SyntaxKind.MetaProperty */ + || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -19087,8 +19209,8 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isRightSideOfAccessExpression(node) { @@ -19103,12 +19225,12 @@ var ts; } ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 205 /* ObjectLiteralExpression */ && + return expression.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 204 /* ArrayLiteralExpression */ && + return expression.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -19124,7 +19246,7 @@ var ts; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isExportDefaultSymbol(symbol) { - return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* Default */); + return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* ModifierFlags.Default */); } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTSExtension(fileName) { @@ -19295,9 +19417,9 @@ var ts; var lineFeed = "\n"; function getNewLineCharacter(options, getNewLine) { switch (options.newLine) { - case 0 /* CarriageReturnLineFeed */: + case 0 /* NewLineKind.CarriageReturnLineFeed */: return carriageReturnLineFeed; - case 1 /* LineFeed */: + case 1 /* NewLineKind.LineFeed */: return lineFeed; } return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed; @@ -19442,8 +19564,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -19467,32 +19589,33 @@ var ts; } ts.closeFileWatcher = closeFileWatcher; function getCheckFlags(symbol) { - return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; + return symbol.flags & 33554432 /* SymbolFlags.Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration)) + || (s.flags & 32768 /* SymbolFlags.GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* SymbolFlags.Class */ ? flags : flags & ~28 /* ModifierFlags.AccessibilityModifier */; } - if (getCheckFlags(s) & 6 /* Synthetic */) { + if (getCheckFlags(s) & 6 /* CheckFlags.Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; - var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + var accessModifier = checkFlags & 1024 /* CheckFlags.ContainsPrivate */ ? 8 /* ModifierFlags.Private */ : + checkFlags & 256 /* CheckFlags.ContainsPublic */ ? 4 /* ModifierFlags.Public */ : + 16 /* ModifierFlags.Protected */; + var staticModifier = checkFlags & 2048 /* CheckFlags.ContainsStatic */ ? 32 /* ModifierFlags.Static */ : 0; return accessModifier | staticModifier; } - if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + if (s.flags & 4194304 /* SymbolFlags.Prototype */) { + return 4 /* ModifierFlags.Public */ | 32 /* ModifierFlags.Static */; } return 0; } ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol; function skipAlias(symbol, checker) { - return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol; + return symbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(symbol) : symbol; } ts.skipAlias = skipAlias; /** See comment on `declareModuleMember` in `binder.ts`. */ @@ -19501,11 +19624,11 @@ var ts; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; function isWriteOnlyAccess(node) { - return accessKind(node) === 1 /* Write */; + return accessKind(node) === 1 /* AccessKind.Write */; } ts.isWriteOnlyAccess = isWriteOnlyAccess; function isWriteAccess(node) { - return accessKind(node) !== 0 /* Read */; + return accessKind(node) !== 0 /* AccessKind.Read */; } ts.isWriteAccess = isWriteAccess; var AccessKind; @@ -19520,47 +19643,47 @@ var ts; function accessKind(node) { var parent = node.parent; if (!parent) - return 0 /* Read */; + return 0 /* AccessKind.Read */; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return accessKind(parent); - case 220 /* PostfixUnaryExpression */: - case 219 /* PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var operator = parent.operator; - return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 221 /* BinaryExpression */: + return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? writeOrReadWrite() : 0 /* AccessKind.Read */; + case 221 /* SyntaxKind.BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() - : 0 /* Read */; - case 206 /* PropertyAccessExpression */: - return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 296 /* PropertyAssignment */: { + operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : writeOrReadWrite() + : 0 /* AccessKind.Read */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent); + case 296 /* SyntaxKind.PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. - return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 204 /* ArrayLiteralExpression */: + return node === parent.objectAssignmentInitializer ? 0 /* AccessKind.Read */ : accessKind(parent.parent); + case 204 /* SyntaxKind.ArrayLiteralExpression */: return accessKind(parent); default: - return 0 /* Read */; + return 0 /* AccessKind.Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* SyntaxKind.ExpressionStatement */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */; } } function reverseAccessKind(a) { switch (a) { - case 0 /* Read */: - return 1 /* Write */; - case 1 /* Write */: - return 0 /* Read */; - case 2 /* ReadWrite */: - return 2 /* ReadWrite */; + case 0 /* AccessKind.Read */: + return 1 /* AccessKind.Write */; + case 1 /* AccessKind.Write */: + return 0 /* AccessKind.Read */; + case 2 /* AccessKind.ReadWrite */: + return 2 /* AccessKind.ReadWrite */; default: return ts.Debug.assertNever(a); } @@ -19630,9 +19753,9 @@ var ts; } ts.mutateMap = mutateMap; function isAbstractConstructorSymbol(symbol) { - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 128 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); } return false; } @@ -19643,11 +19766,11 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0; + return type.flags & 3899393 /* TypeFlags.ObjectFlagsType */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { - return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0; + return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length !== 0; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { @@ -19694,44 +19817,44 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) - || kind === 130 /* AnyKeyword */ - || kind === 155 /* UnknownKeyword */ - || kind === 147 /* NumberKeyword */ - || kind === 158 /* BigIntKeyword */ - || kind === 148 /* ObjectKeyword */ - || kind === 133 /* BooleanKeyword */ - || kind === 150 /* StringKeyword */ - || kind === 151 /* SymbolKeyword */ - || kind === 114 /* VoidKeyword */ - || kind === 153 /* UndefinedKeyword */ - || kind === 143 /* NeverKeyword */ - || kind === 228 /* ExpressionWithTypeArguments */ - || kind === 312 /* JSDocAllType */ - || kind === 313 /* JSDocUnknownType */ - || kind === 314 /* JSDocNullableType */ - || kind === 315 /* JSDocNonNullableType */ - || kind === 316 /* JSDocOptionalType */ - || kind === 317 /* JSDocFunctionType */ - || kind === 318 /* JSDocVariadicType */; + return (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) + || kind === 130 /* SyntaxKind.AnyKeyword */ + || kind === 155 /* SyntaxKind.UnknownKeyword */ + || kind === 147 /* SyntaxKind.NumberKeyword */ + || kind === 158 /* SyntaxKind.BigIntKeyword */ + || kind === 148 /* SyntaxKind.ObjectKeyword */ + || kind === 133 /* SyntaxKind.BooleanKeyword */ + || kind === 150 /* SyntaxKind.StringKeyword */ + || kind === 151 /* SyntaxKind.SymbolKeyword */ + || kind === 114 /* SyntaxKind.VoidKeyword */ + || kind === 153 /* SyntaxKind.UndefinedKeyword */ + || kind === 143 /* SyntaxKind.NeverKeyword */ + || kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ + || kind === 312 /* SyntaxKind.JSDocAllType */ + || kind === 313 /* SyntaxKind.JSDocUnknownType */ + || kind === 314 /* SyntaxKind.JSDocNullableType */ + || kind === 315 /* SyntaxKind.JSDocNonNullableType */ + || kind === 316 /* SyntaxKind.JSDocOptionalType */ + || kind === 317 /* SyntaxKind.JSDocFunctionType */ + || kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */ || node.kind === 207 /* ElementAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 206 /* PropertyAccessExpression */) { + if (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 207 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 207 /* SyntaxKind.ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; function isBundleFileTextLike(section) { switch (section.kind) { - case "text" /* Text */: - case "internal" /* Internal */: + case "text" /* BundleFileSectionKind.Text */: + case "internal" /* BundleFileSectionKind.Internal */: return true; default: return false; @@ -19739,7 +19862,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 269 /* NamedImports */ || node.kind === 273 /* NamedExports */; + return node.kind === 269 /* SyntaxKind.NamedImports */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -19754,13 +19877,13 @@ var ts; return walkAccessExpression(name.parent); } function walkAccessExpression(access) { - if (access.kind === 206 /* PropertyAccessExpression */) { + if (access.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var res = action(access.name); if (res !== undefined) { return res; } } - else if (access.kind === 207 /* ElementAccessExpression */) { + else if (access.kind === 207 /* SyntaxKind.ElementAccessExpression */) { if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) { var res = action(access.argumentExpression); if (res !== undefined) { @@ -19787,28 +19910,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: node = node.operand; continue; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: node = node.left; continue; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: node = node.condition; continue; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: node = node.tag; continue; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 229 /* AsExpression */: - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: - case 230 /* NonNullExpression */: - case 350 /* PartiallyEmittedExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: node = node.expression; continue; } @@ -19842,9 +19965,9 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; } @@ -19853,8 +19976,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } function Identifier(kind, pos, end) { @@ -19862,8 +19985,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; this.flowNode = undefined; @@ -20058,7 +20181,7 @@ var ts; function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -20067,43 +20190,43 @@ var ts; ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (d1.relatedInformation && d2.relatedInformation) { return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { var d2i = d2.relatedInformation[index]; return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; + }) || 0 /* Comparison.EqualTo */; } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + return d1.relatedInformation ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; } function compareMessageText(t1, t2) { if (typeof t1 === "string" && typeof t2 === "string") { return ts.compareStringsCaseSensitive(t1, t2); } else if (typeof t1 === "string") { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (typeof t2 === "string") { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); if (res) { return res; } if (!t1.next && !t2.next) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (!t1.next) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } if (!t2.next) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var len = Math.min(t1.next.length, t2.next.length); for (var i = 0; i < len; i++) { @@ -20113,16 +20236,16 @@ var ts; } } if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* ScriptKind.TSX */ || scriptKind === 2 /* ScriptKind.JSX */ || scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 6 /* ScriptKind.JSON */ ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */; } ts.getLanguageVariant = getLanguageVariant; /** @@ -20131,7 +20254,7 @@ var ts; * Unfortunately, there's no `NodeFlag` space to do the same for JSX. */ function walkTreeForJSXTags(node) { - if (!(node.transformFlags & 2 /* ContainsJsx */)) + if (!(node.transformFlags & 2 /* TransformFlags.ContainsJsx */)) return undefined; return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags); } @@ -20148,7 +20271,7 @@ var ts; // Excludes declaration files - they still require an explicit `export {}` or the like // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files // that aren't esm-mode (meaning not in a `type: module` scope). - return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined; + return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]))) && !file.isDeclarationFile ? true : undefined; } function getSetExternalModuleIndicator(options) { // TODO: Should this callback be cached? @@ -20168,13 +20291,10 @@ var ts; // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness var checks = [ts.isFileProbablyExternalModule]; - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { checks.push(isFileModuleFromUsingJSXTag); } - var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { - checks.push(isFileForcedToBeModuleByFormat); - } + checks.push(isFileForcedToBeModuleByFormat); var combined_1 = ts.or.apply(void 0, checks); var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); }; return callback; @@ -20183,15 +20303,15 @@ var ts; ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator; function getEmitScriptTarget(compilerOptions) { return compilerOptions.target || - (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ES2022 */) || - (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) || - 0 /* ES3 */; + (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ScriptTarget.ES2022 */) || + (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ScriptTarget.ESNext */) || + 0 /* ScriptTarget.ES3 */; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function getEmitModuleResolutionKind(compilerOptions) { @@ -20289,7 +20409,7 @@ var ts; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function getUseDefineForClassFields(compilerOptions) { - return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */ : compilerOptions.useDefineForClassFields; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { @@ -20310,14 +20430,14 @@ var ts; ts.getCompilerOptionValue = getCompilerOptionValue; function getJSXTransformEnabled(options) { var jsx = options.jsx; - return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */; + return jsx === 2 /* JsxEmit.React */ || jsx === 4 /* JsxEmit.ReactJSX */ || jsx === 5 /* JsxEmit.ReactJSXDev */; } ts.getJSXTransformEnabled = getJSXTransformEnabled; function getJSXImplicitImportBase(compilerOptions, file) { var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; - return compilerOptions.jsx === 4 /* ReactJSX */ || - compilerOptions.jsx === 5 /* ReactJSXDev */ || + return compilerOptions.jsx === 4 /* JsxEmit.ReactJSX */ || + compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ || compilerOptions.jsxImportSource || jsxImportSourcePragma ? (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : @@ -20325,13 +20445,13 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { + if (str.charCodeAt(i) === 42 /* CharacterCodes.asterisk */) { if (!seenAsterisk) { seenAsterisk = true; } @@ -20430,9 +20550,9 @@ var ts; function escapeRegExpCharacter(match) { return "\\" + match; } - var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; + var wildcardCharCodes = [42 /* CharacterCodes.asterisk */, 63 /* CharacterCodes.question */]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { /** * Matches any single directory segment unless it is the last segment and a .min.js file @@ -20445,7 +20565,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { @@ -20454,7 +20574,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -20472,10 +20592,10 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); // If excluding, match "foo/bar/baz...", but if including, only allow "foo". var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -20497,7 +20617,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -20534,11 +20654,11 @@ var ts; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { + if (component.charCodeAt(0) === 42 /* CharacterCodes.asterisk */) { componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } - else if (component.charCodeAt(0) === 63 /* question */) { + else if (component.charCodeAt(0) === 63 /* CharacterCodes.question */) { componentPattern += "[^./]"; component = component.substr(1); } @@ -20575,7 +20695,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -20700,44 +20820,44 @@ var ts; // If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt // to get the ScriptKind from the file name. If it cannot be resolved // from the file name then the default 'TS' script kind is returned. - return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */; + return scriptKind || getScriptKindFromFileName(fileName) || 3 /* ScriptKind.TS */; } ts.ensureScriptKind = ensureScriptKind; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: - case ".cjs" /* Cjs */: - case ".mjs" /* Mjs */: - return 1 /* JS */; - case ".jsx" /* Jsx */: - return 2 /* JSX */; - case ".ts" /* Ts */: - case ".cts" /* Cts */: - case ".mts" /* Mts */: - return 3 /* TS */; - case ".tsx" /* Tsx */: - return 4 /* TSX */; - case ".json" /* Json */: - return 6 /* JSON */; + case ".js" /* Extension.Js */: + case ".cjs" /* Extension.Cjs */: + case ".mjs" /* Extension.Mjs */: + return 1 /* ScriptKind.JS */; + case ".jsx" /* Extension.Jsx */: + return 2 /* ScriptKind.JSX */; + case ".ts" /* Extension.Ts */: + case ".cts" /* Extension.Cts */: + case ".mts" /* Extension.Mts */: + return 3 /* ScriptKind.TS */; + case ".tsx" /* Extension.Tsx */: + return 4 /* ScriptKind.TSX */; + case ".json" /* Extension.Json */: + return 6 /* ScriptKind.JSON */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } ts.getScriptKindFromFileName = getScriptKindFromFileName; /** * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ - ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]]; + ts.supportedTSExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */]]; ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions); - var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false); + var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Extension.Json */]], false); /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */]; - ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]]; + var supportedTSExtensionsForExtractExtension = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */]; + ts.supportedJSExtensions = [[".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".mjs" /* Extension.Mjs */], [".cjs" /* Extension.Cjs */]]; ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); - var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]]; - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false); - ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]; + var allSupportedExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */]]; + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Extension.Json */]], false); + ts.supportedDeclarationExtensions = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */]; function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { @@ -20745,7 +20865,7 @@ var ts; } var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; var flatBuiltins = ts.flatten(builtins); - var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); + var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* ScriptKind.Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); return extensions; } ts.getSupportedExtensions = getSupportedExtensions; @@ -20756,11 +20876,11 @@ var ts; return allSupportedExtensionsWithJson; if (supportedExtensions === ts.supportedTSExtensions) return supportedTSExtensionsWithJson; - return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false); + return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Extension.Json */]], false); } ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { - return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; + return scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 2 /* ScriptKind.JSX */; } function hasJSFileExtension(fileName) { return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -20791,7 +20911,7 @@ var ts; return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); } ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; - var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; + var extensionsToRemove = [".d.ts" /* Extension.Dts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".ts" /* Extension.Ts */, ".js" /* Extension.Js */, ".tsx" /* Extension.Tsx */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -20844,11 +20964,11 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTS(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */; + return ext === ".ts" /* Extension.Ts */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".d.ts" /* Extension.Dts */ || ext === ".cts" /* Extension.Cts */ || ext === ".mts" /* Extension.Mts */ || ext === ".d.mts" /* Extension.Dmts */ || ext === ".d.cts" /* Extension.Dcts */; } ts.extensionIsTS = extensionIsTS; function resolutionExtensionIsTSOrJson(ext) { - return extensionIsTS(ext) || ext === ".json" /* Json */; + return extensionIsTS(ext) || ext === ".json" /* Extension.Json */; } ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; /** @@ -20857,7 +20977,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -20966,23 +21086,23 @@ var ts; function parsePseudoBigInt(stringValue) { var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" - case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 98 /* CharacterCodes.b */: + case 66 /* CharacterCodes.B */: // 0b or 0B log2Base = 1; break; - case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 111 /* CharacterCodes.o */: + case 79 /* CharacterCodes.O */: // 0o or 0O log2Base = 3; break; - case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 120 /* CharacterCodes.x */: + case 88 /* CharacterCodes.X */: // 0x or 0X log2Base = 4; break; default: // already in decimal; omit trailing "n" var nIndex = stringValue.length - 1; // Skip leading 0s var nonZeroStart = 0; - while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) { + while (stringValue.charCodeAt(nonZeroStart) === 48 /* CharacterCodes._0 */) { nonZeroStart++; } return stringValue.slice(nonZeroStart, nIndex) || "0"; @@ -20998,10 +21118,10 @@ var ts; var segment = bitOffset >>> 4; var digitChar = stringValue.charCodeAt(i); // Find character range: 0-9 < A-F < a-f - var digit = digitChar <= 57 /* _9 */ - ? digitChar - 48 /* _0 */ + var digit = digitChar <= 57 /* CharacterCodes._9 */ + ? digitChar - 48 /* CharacterCodes._0 */ : 10 + digitChar - - (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + (digitChar <= 70 /* CharacterCodes.F */ ? 65 /* CharacterCodes.A */ : 97 /* CharacterCodes.a */); var shiftedDigit = digit << (bitOffset & 15); segments[segment] |= shiftedDigit; var residual = shiftedDigit >>> 16; @@ -21036,7 +21156,7 @@ var ts; } ts.pseudoBigIntToString = pseudoBigIntToString; function isValidTypeOnlyAliasUseSite(useSite) { - return !!(useSite.flags & 16777216 /* Ambient */) + return !!(useSite.flags & 16777216 /* NodeFlags.Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) @@ -21047,34 +21167,34 @@ var ts; return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite; } function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 79 /* Identifier */ || node.kind === 206 /* PropertyAccessExpression */) { + while (node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 258 /* InterfaceDeclaration */ || containerKind === 182 /* TypeLiteral */; + return containerKind === 258 /* SyntaxKind.InterfaceDeclaration */ || containerKind === 182 /* SyntaxKind.TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 79 /* Identifier */) + if (node.kind !== 79 /* SyntaxKind.Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return true; - case 206 /* PropertyAccessExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* SyntaxKind.ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* SyntaxKind.InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -21215,7 +21335,7 @@ var ts; node = parent; continue; } - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // left side of comma is always unused if (node === parent.left) return true; @@ -21235,22 +21355,22 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 190 /* InferType */ ? undefined : parent_1.typeParameters; - case 164 /* Parameter */: + return parent_1.kind === 190 /* SyntaxKind.InferType */ ? undefined : parent_1.typeParameters; + case 164 /* SyntaxKind.Parameter */: return node.parent.parameters; - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node.parent.templateSpans; - case 165 /* Decorator */: { + case 165 /* SyntaxKind.Decorator */: { var parent_2 = node.parent; return ts.canHaveDecorators(parent_2) ? parent_2.modifiers : ts.canHaveIllegalDecorators(parent_2) ? parent_2.decorators : undefined; } - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -21258,45 +21378,45 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 182 /* TypeLiteral */: - case 258 /* InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return parent.types; - case 184 /* TupleType */: - case 204 /* ArrayLiteralExpression */: - case 351 /* CommaListExpression */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 184 /* SyntaxKind.TupleType */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return parent.elements; - case 205 /* ObjectLiteralExpression */: - case 286 /* JsxAttributes */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 286 /* SyntaxKind.JsxAttributes */: return parent.properties; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 278 /* JsxElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 282 /* SyntaxKind.JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: return parent.statements; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return parent.clauses; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return parent.statements; } } @@ -21308,7 +21428,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 214 /* ArrowFunction */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -21326,7 +21446,7 @@ var ts; } ts.isInfinityOrNaNString = isInfinityOrNaNString; function isCatchClauseVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function isParameterOrCatchClauseVariable(symbol) { @@ -21335,7 +21455,7 @@ var ts; } ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable; function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 213 /* FunctionExpression */ || node.kind === 214 /* ArrowFunction */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */ || node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction; function escapeSnippetText(text) { @@ -21374,7 +21494,7 @@ var ts; } ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral; function isThisTypeParameter(type) { - return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); + return !!(type.flags & 262144 /* TypeFlags.TypeParameter */ && type.isThisType); } ts.isThisTypeParameter = isThisTypeParameter; function getNodeModulePathParts(fullPath) { @@ -21394,45 +21514,45 @@ var ts; })(States || (States = {})); var partStart = 0; var partEnd = 0; - var state = 0 /* BeforeNodeModules */; + var state = 0 /* States.BeforeNodeModules */; while (partEnd >= 0) { partStart = partEnd; partEnd = fullPath.indexOf("/", partStart + 1); switch (state) { - case 0 /* BeforeNodeModules */: + case 0 /* States.BeforeNodeModules */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { topLevelNodeModulesIndex = partStart; topLevelPackageNameIndex = partEnd; - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } break; - case 1 /* NodeModules */: - case 2 /* Scope */: - if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { - state = 2 /* Scope */; + case 1 /* States.NodeModules */: + case 2 /* States.Scope */: + if (state === 1 /* States.NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* States.Scope */; } else { packageRootIndex = partEnd; - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; - case 3 /* PackageContent */: + case 3 /* States.PackageContent */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } else { - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; } } fileNameIndex = partStart; - return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; + return state > 1 /* States.NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; } ts.getNodeModulePathParts = getNodeModulePathParts; function getParameterTypeNode(parameter) { var _a; - return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; + return parameter.kind === 340 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; } ts.getParameterTypeNode = getParameterTypeNode; })(ts || (ts = {})); @@ -21557,28 +21677,28 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* SyntaxKind.BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 214 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 214 /* SyntaxKind.ArrowFunction */ && binaryOperatorPrecedence > 3 /* OperatorPrecedence.Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If the operand is the right side of a right-associative binary operation // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 224 /* YieldExpression */) { + && binaryOperatorAssociativity === 1 /* Associativity.Right */ + && operand.kind === 224 /* SyntaxKind.YieldExpression */) { return false; } return true; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: return false; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: if (isLeftSideOfBinary) { // No need to parenthesize the left operand when the binary operator is // left associative: @@ -21589,7 +21709,7 @@ var ts; // right associative: // (a/b)**x -> (a/b)**x // (a**b)**x -> (a**b)**x - return binaryOperatorAssociativity === 1 /* Right */; + return binaryOperatorAssociativity === 1 /* Associativity.Right */; } else { if (ts.isBinaryExpression(emittedOperand) @@ -21609,8 +21729,8 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 39 /* PlusToken */) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; + if (binaryOperator === 39 /* SyntaxKind.PlusToken */) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* SyntaxKind.Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; } @@ -21626,7 +21746,7 @@ var ts; // x/(a*b) -> x/(a*b) // x**(a/b) -> x**(a/b) var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0 /* Left */; + return operandAssociativity === 0 /* Associativity.Left */; } } } @@ -21644,10 +21764,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 41 /* AsteriskToken */ - || binaryOperator === 51 /* BarToken */ - || binaryOperator === 50 /* AmpersandToken */ - || binaryOperator === 52 /* CaretToken */; + return binaryOperator === 41 /* SyntaxKind.AsteriskToken */ + || binaryOperator === 51 /* SyntaxKind.BarToken */ + || binaryOperator === 50 /* SyntaxKind.AmpersandToken */ + || binaryOperator === 52 /* SyntaxKind.CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -21660,7 +21780,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -21668,11 +21788,11 @@ var ts; var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind - : 0 /* Unknown */; + : 0 /* SyntaxKind.Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended @@ -21686,7 +21806,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 212 /* ParenthesizedExpression */) { + if (skipped.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -21703,10 +21823,10 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(222 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(222 /* SyntaxKind.ConditionalExpression */, 57 /* SyntaxKind.QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* Comparison.GreaterThan */) { return factory.createParenthesizedExpression(condition); } return condition; @@ -21736,8 +21856,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: needsParens = true; } } @@ -21750,9 +21870,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return factory.createParenthesizedExpression(expression); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -21763,7 +21883,7 @@ var ts; * Wraps an expression in parentheses if it is needed in order to use the expression for * property or element access. */ - function parenthesizeLeftSideOfAccess(expression) { + function parenthesizeLeftSideOfAccess(expression, optionalChain) { // isLeftHandSideExpression is almost the correct criterion for when it is not necessary // to parenthesize the expression before a dot. The known exception is: // @@ -21772,7 +21892,8 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 /* SyntaxKind.NewExpression */ || emittedExpression.arguments) + && (optionalChain || !ts.isOptionalChain(emittedExpression))) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -21794,7 +21915,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, 27 /* SyntaxKind.CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -21803,21 +21924,21 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 213 /* FunctionExpression */ || kind === 214 /* ArrowFunction */) { + if (kind === 213 /* SyntaxKind.FunctionExpression */ || kind === 214 /* SyntaxKind.ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); - return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); + return factory.restoreOuterExpressions(expression, updated, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 205 /* ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* FunctionExpression */) { + if (leftmostExpressionKind === 205 /* SyntaxKind.ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* SyntaxKind.FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } @@ -21835,16 +21956,16 @@ var ts; // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type function parenthesizeCheckTypeOfConditionalType(checkType) { switch (checkType.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 189 /* ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(checkType); } return checkType; } function parenthesizeExtendsTypeOfConditionalType(extendsType) { switch (extendsType.kind) { - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(extendsType); } return extendsType; @@ -21856,8 +21977,8 @@ var ts; // - A union type constituent has the same precedence as the check type of a conditional type function parenthesizeConstituentTypeOfUnionType(type) { switch (type.kind) { - case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened - case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 187 /* SyntaxKind.UnionType */: // Not strictly necessary, but a union containing a union should have been flattened + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeCheckTypeOfConditionalType(type); @@ -21872,8 +21993,8 @@ var ts; // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized) function parenthesizeConstituentTypeOfIntersectionType(type) { switch (type.kind) { - case 187 /* UnionType */: - case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfUnionType(type); @@ -21890,14 +22011,14 @@ var ts; // function parenthesizeOperandOfTypeOperator(type) { switch (type.kind) { - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfIntersectionType(type); } function parenthesizeOperandOfReadonlyTypeOperator(type) { switch (type.kind) { - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -21917,9 +22038,9 @@ var ts; // function parenthesizeNonArrayTypeOfPostfixType(type) { switch (type.kind) { - case 190 /* InferType */: - case 193 /* TypeOperator */: - case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 190 /* SyntaxKind.InferType */: + case 193 /* SyntaxKind.TypeOperator */: + case 181 /* SyntaxKind.TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -22113,11 +22234,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -22175,10 +22296,10 @@ var ts; */ /* @internal */ function createNodeFactory(flags, baseFactory) { - var update = flags & 8 /* NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; + var update = flags & 8 /* NodeFactoryFlags.NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; // Lazily load the parenthesizer, node converters, and some factory methods until they are used. - var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); - var converters = ts.memoize(function () { return flags & 2 /* NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); + var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NodeFactoryFlags.NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); + var converters = ts.memoize(function () { return flags & 2 /* NodeFactoryFlags.NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); // lazy initializaton of common operator factories var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; }); var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; }); @@ -22309,12 +22430,12 @@ var ts; updateArrayLiteralExpression: updateArrayLiteralExpression, createObjectLiteralExpression: createObjectLiteralExpression, updateObjectLiteralExpression: updateObjectLiteralExpression, - createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* NoIndentation */); } : + createPropertyAccessExpression: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessExpression, updatePropertyAccessExpression: updatePropertyAccessExpression, - createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* NoIndentation */); } : + createPropertyAccessChain: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessChain, updatePropertyAccessChain: updatePropertyAccessChain, createElementAccessExpression: createElementAccessExpression, @@ -22470,18 +22591,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* SyntaxKind.JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* SyntaxKind.JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -22517,30 +22638,30 @@ var ts; createJSDocLinkPlain: createJSDocLinkPlain, updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* JSDocReadonlyTag */); }, - get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* JSDocOverrideTag */); }, - get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* JSDocOverrideTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -22608,38 +22729,38 @@ var ts; updateSyntheticReferenceExpression: updateSyntheticReferenceExpression, cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities - get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, - get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, - get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, - get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, - get createBitwiseXor() { return getBinaryCreateFunction(52 /* CaretToken */); }, - get createBitwiseAnd() { return getBinaryCreateFunction(50 /* AmpersandToken */); }, - get createStrictEquality() { return getBinaryCreateFunction(36 /* EqualsEqualsEqualsToken */); }, - get createStrictInequality() { return getBinaryCreateFunction(37 /* ExclamationEqualsEqualsToken */); }, - get createEquality() { return getBinaryCreateFunction(34 /* EqualsEqualsToken */); }, - get createInequality() { return getBinaryCreateFunction(35 /* ExclamationEqualsToken */); }, - get createLessThan() { return getBinaryCreateFunction(29 /* LessThanToken */); }, - get createLessThanEquals() { return getBinaryCreateFunction(32 /* LessThanEqualsToken */); }, - get createGreaterThan() { return getBinaryCreateFunction(31 /* GreaterThanToken */); }, - get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* GreaterThanEqualsToken */); }, - get createLeftShift() { return getBinaryCreateFunction(47 /* LessThanLessThanToken */); }, - get createRightShift() { return getBinaryCreateFunction(48 /* GreaterThanGreaterThanToken */); }, - get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* GreaterThanGreaterThanGreaterThanToken */); }, - get createAdd() { return getBinaryCreateFunction(39 /* PlusToken */); }, - get createSubtract() { return getBinaryCreateFunction(40 /* MinusToken */); }, - get createMultiply() { return getBinaryCreateFunction(41 /* AsteriskToken */); }, - get createDivide() { return getBinaryCreateFunction(43 /* SlashToken */); }, - get createModulo() { return getBinaryCreateFunction(44 /* PercentToken */); }, - get createExponent() { return getBinaryCreateFunction(42 /* AsteriskAsteriskToken */); }, - get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* PlusToken */); }, - get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* MinusToken */); }, - get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* MinusMinusToken */); }, - get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* TildeToken */); }, - get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* ExclamationToken */); }, - get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* MinusMinusToken */); }, + get createComma() { return getBinaryCreateFunction(27 /* SyntaxKind.CommaToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* SyntaxKind.EqualsToken */); }, + get createLogicalOr() { return getBinaryCreateFunction(56 /* SyntaxKind.BarBarToken */); }, + get createLogicalAnd() { return getBinaryCreateFunction(55 /* SyntaxKind.AmpersandAmpersandToken */); }, + get createBitwiseOr() { return getBinaryCreateFunction(51 /* SyntaxKind.BarToken */); }, + get createBitwiseXor() { return getBinaryCreateFunction(52 /* SyntaxKind.CaretToken */); }, + get createBitwiseAnd() { return getBinaryCreateFunction(50 /* SyntaxKind.AmpersandToken */); }, + get createStrictEquality() { return getBinaryCreateFunction(36 /* SyntaxKind.EqualsEqualsEqualsToken */); }, + get createStrictInequality() { return getBinaryCreateFunction(37 /* SyntaxKind.ExclamationEqualsEqualsToken */); }, + get createEquality() { return getBinaryCreateFunction(34 /* SyntaxKind.EqualsEqualsToken */); }, + get createInequality() { return getBinaryCreateFunction(35 /* SyntaxKind.ExclamationEqualsToken */); }, + get createLessThan() { return getBinaryCreateFunction(29 /* SyntaxKind.LessThanToken */); }, + get createLessThanEquals() { return getBinaryCreateFunction(32 /* SyntaxKind.LessThanEqualsToken */); }, + get createGreaterThan() { return getBinaryCreateFunction(31 /* SyntaxKind.GreaterThanToken */); }, + get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* SyntaxKind.GreaterThanEqualsToken */); }, + get createLeftShift() { return getBinaryCreateFunction(47 /* SyntaxKind.LessThanLessThanToken */); }, + get createRightShift() { return getBinaryCreateFunction(48 /* SyntaxKind.GreaterThanGreaterThanToken */); }, + get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */); }, + get createAdd() { return getBinaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createSubtract() { return getBinaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createMultiply() { return getBinaryCreateFunction(41 /* SyntaxKind.AsteriskToken */); }, + get createDivide() { return getBinaryCreateFunction(43 /* SyntaxKind.SlashToken */); }, + get createModulo() { return getBinaryCreateFunction(44 /* SyntaxKind.PercentToken */); }, + get createExponent() { return getBinaryCreateFunction(42 /* SyntaxKind.AsteriskAsteriskToken */); }, + get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, + get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* SyntaxKind.TildeToken */); }, + get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* SyntaxKind.ExclamationToken */); }, + get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, // Compound nodes createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression, createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction, @@ -22743,11 +22864,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -22765,7 +22886,7 @@ var ts; node.typeParameters = asNodeArray(typeParameters); node.transformFlags |= propagateChildrenFlags(node.typeParameters); if (typeParameters) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type) { @@ -22776,7 +22897,7 @@ var ts; propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used for quick info node.typeArguments = undefined; return node; @@ -22791,9 +22912,9 @@ var ts; function createBaseFunctionLikeDeclaration(kind, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; if (!body) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseInterfaceOrClassLikeDeclaration(kind, modifiers, name, typeParameters, heritageClauses) { @@ -22819,7 +22940,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } // @@ -22832,21 +22953,21 @@ var ts; } // @api function createNumericLiteral(value, numericLiteralFlags) { - if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* None */; } - var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); + if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* TokenFlags.None */; } + var node = createBaseLiteral(8 /* SyntaxKind.NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; - if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 1024 /* ContainsES2015 */; + if (numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api function createBigIntLiteral(value) { - var node = createBaseLiteral(9 /* BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); - node.transformFlags |= 4 /* ContainsESNext */; + var node = createBaseLiteral(9 /* SyntaxKind.BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } function createBaseStringLiteral(text, isSingleQuote) { - var node = createBaseLiteral(10 /* StringLiteral */, text); + var node = createBaseLiteral(10 /* SyntaxKind.StringLiteral */, text); node.singleQuote = isSingleQuote; return node; } @@ -22855,7 +22976,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -22866,19 +22987,19 @@ var ts; } // @api function createRegularExpressionLiteral(text) { - var node = createBaseLiteral(13 /* RegularExpressionLiteral */, text); + var node = createBaseLiteral(13 /* SyntaxKind.RegularExpressionLiteral */, text); return node; } // @api function createLiteralLikeNode(kind, text) { switch (kind) { - case 8 /* NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); - case 9 /* BigIntLiteral */: return createBigIntLiteral(text); - case 10 /* StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); - case 11 /* JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); - case 12 /* JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); - case 13 /* RegularExpressionLiteral */: return createRegularExpressionLiteral(text); - case 14 /* NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); + case 8 /* SyntaxKind.NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); + case 9 /* SyntaxKind.BigIntLiteral */: return createBigIntLiteral(text); + case 10 /* SyntaxKind.StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); + case 11 /* SyntaxKind.JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); + case 13 /* SyntaxKind.RegularExpressionLiteral */: return createRegularExpressionLiteral(text); + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); } } // @@ -22888,10 +23009,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 79 /* Identifier */) { + if (originalKeywordKind === 79 /* SyntaxKind.Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -22910,8 +23031,8 @@ var ts; // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 132 /* AwaitKeyword */) { - node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { + node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; } return node; } @@ -22923,9 +23044,9 @@ var ts; } // @api function createTempVariable(recordTempVariable, reservedInNestedScopes) { - var flags = 1 /* Auto */; + var flags = 1 /* GeneratedIdentifierFlags.Auto */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; var name = createBaseGeneratedIdentifier("", flags); if (recordTempVariable) { recordTempVariable(name); @@ -22935,25 +23056,25 @@ var ts; /** Create a unique temporary variable for use in a loop. */ // @api function createLoopVariable(reservedInNestedScopes) { - var flags = 2 /* Loop */; + var flags = 2 /* GeneratedIdentifierFlags.Loop */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api function createUniqueName(text, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - ts.Debug.assert((flags & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); - return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags); + if (flags === void 0) { flags = 0 /* GeneratedIdentifierFlags.None */; } + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + ts.Debug.assert((flags & (16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)) !== 32 /* GeneratedIdentifierFlags.FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); + return createBaseGeneratedIdentifier(text, 3 /* GeneratedIdentifierFlags.Unique */ | flags); } /** Create a unique name generated for a node. */ // @api function getGeneratedNameForNode(node, flags) { if (flags === void 0) { flags = 0; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* Node */ | flags); + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* GeneratedIdentifierFlags.Node */ | flags); name.original = node; return name; } @@ -22961,9 +23082,9 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 16777216 /* ContainsClassFields */; + node.transformFlags |= 16777216 /* TransformFlags.ContainsClassFields */; return node; } // @@ -22973,51 +23094,51 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 160 /* LastToken */, "Invalid token"); - ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); - ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token >= 0 /* SyntaxKind.FirstToken */ && token <= 160 /* SyntaxKind.LastToken */, "Invalid token"); + ts.Debug.assert(token <= 14 /* SyntaxKind.FirstTemplateToken */ || token >= 17 /* SyntaxKind.LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); + ts.Debug.assert(token <= 8 /* SyntaxKind.FirstLiteralToken */ || token >= 14 /* SyntaxKind.LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); + ts.Debug.assert(token !== 79 /* SyntaxKind.Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); - var transformFlags = 0 /* None */; + var transformFlags = 0 /* TransformFlags.None */; switch (token) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; break; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 126 /* AbstractKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 155 /* UnknownKeyword */: - case 153 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. - transformFlags = 1 /* ContainsTypeScript */; + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + transformFlags = 1 /* TransformFlags.ContainsTypeScript */; break; - case 106 /* SuperKeyword */: - transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */; + case 106 /* SyntaxKind.SuperKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */ | 134217728 /* TransformFlags.ContainsLexicalSuper */; break; - case 124 /* StaticKeyword */: - transformFlags = 1024 /* ContainsES2015 */; + case 124 /* SyntaxKind.StaticKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */; break; - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 16384 /* ContainsLexicalThis */; + transformFlags = 16384 /* TransformFlags.ContainsLexicalThis */; break; } if (transformFlags) { @@ -23030,23 +23151,23 @@ var ts; // // @api function createSuper() { - return createToken(106 /* SuperKeyword */); + return createToken(106 /* SyntaxKind.SuperKeyword */); } // @api function createThis() { - return createToken(108 /* ThisKeyword */); + return createToken(108 /* SyntaxKind.ThisKeyword */); } // @api function createNull() { - return createToken(104 /* NullKeyword */); + return createToken(104 /* SyntaxKind.NullKeyword */); } // @api function createTrue() { - return createToken(110 /* TrueKeyword */); + return createToken(110 /* SyntaxKind.TrueKeyword */); } // @api function createFalse() { - return createToken(95 /* FalseKeyword */); + return createToken(95 /* SyntaxKind.FalseKeyword */); } // // Modifiers @@ -23058,34 +23179,34 @@ var ts; // @api function createModifiersFromModifierFlags(flags) { var result = []; - if (flags & 1 /* Export */) - result.push(createModifier(93 /* ExportKeyword */)); - if (flags & 2 /* Ambient */) - result.push(createModifier(135 /* DeclareKeyword */)); - if (flags & 512 /* Default */) - result.push(createModifier(88 /* DefaultKeyword */)); - if (flags & 2048 /* Const */) - result.push(createModifier(85 /* ConstKeyword */)); - if (flags & 4 /* Public */) - result.push(createModifier(123 /* PublicKeyword */)); - if (flags & 8 /* Private */) - result.push(createModifier(121 /* PrivateKeyword */)); - if (flags & 16 /* Protected */) - result.push(createModifier(122 /* ProtectedKeyword */)); - if (flags & 128 /* Abstract */) - result.push(createModifier(126 /* AbstractKeyword */)); - if (flags & 32 /* Static */) - result.push(createModifier(124 /* StaticKeyword */)); - if (flags & 16384 /* Override */) - result.push(createModifier(159 /* OverrideKeyword */)); - if (flags & 64 /* Readonly */) - result.push(createModifier(145 /* ReadonlyKeyword */)); - if (flags & 256 /* Async */) - result.push(createModifier(131 /* AsyncKeyword */)); - if (flags & 32768 /* In */) - result.push(createModifier(101 /* InKeyword */)); - if (flags & 65536 /* Out */) - result.push(createModifier(144 /* OutKeyword */)); + if (flags & 1 /* ModifierFlags.Export */) + result.push(createModifier(93 /* SyntaxKind.ExportKeyword */)); + if (flags & 2 /* ModifierFlags.Ambient */) + result.push(createModifier(135 /* SyntaxKind.DeclareKeyword */)); + if (flags & 512 /* ModifierFlags.Default */) + result.push(createModifier(88 /* SyntaxKind.DefaultKeyword */)); + if (flags & 2048 /* ModifierFlags.Const */) + result.push(createModifier(85 /* SyntaxKind.ConstKeyword */)); + if (flags & 4 /* ModifierFlags.Public */) + result.push(createModifier(123 /* SyntaxKind.PublicKeyword */)); + if (flags & 8 /* ModifierFlags.Private */) + result.push(createModifier(121 /* SyntaxKind.PrivateKeyword */)); + if (flags & 16 /* ModifierFlags.Protected */) + result.push(createModifier(122 /* SyntaxKind.ProtectedKeyword */)); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push(createModifier(126 /* SyntaxKind.AbstractKeyword */)); + if (flags & 32 /* ModifierFlags.Static */) + result.push(createModifier(124 /* SyntaxKind.StaticKeyword */)); + if (flags & 16384 /* ModifierFlags.Override */) + result.push(createModifier(159 /* SyntaxKind.OverrideKeyword */)); + if (flags & 64 /* ModifierFlags.Readonly */) + result.push(createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); + if (flags & 256 /* ModifierFlags.Async */) + result.push(createModifier(131 /* SyntaxKind.AsyncKeyword */)); + if (flags & 32768 /* ModifierFlags.In */) + result.push(createModifier(101 /* SyntaxKind.InKeyword */)); + if (flags & 65536 /* ModifierFlags.Out */) + result.push(createModifier(144 /* SyntaxKind.OutKeyword */)); return result.length ? result : undefined; } // @@ -23093,7 +23214,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(161 /* QualifiedName */); + var node = createBaseNode(161 /* SyntaxKind.QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -23110,12 +23231,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(162 /* ComputedPropertyName */); + var node = createBaseNode(162 /* SyntaxKind.ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 131072 /* ContainsComputedPropertyName */; + 1024 /* TransformFlags.ContainsES2015 */ | + 131072 /* TransformFlags.ContainsComputedPropertyName */; return node; } // @api @@ -23129,10 +23250,10 @@ var ts; // // @api function createTypeParameterDeclaration(modifiers, name, constraint, defaultType) { - var node = createBaseNamedDeclaration(163 /* TypeParameter */, modifiers, name); + var node = createBaseNamedDeclaration(163 /* SyntaxKind.TypeParameter */, modifiers, name); node.constraint = constraint; node.default = defaultType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23146,22 +23267,22 @@ var ts; } // @api function createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164 /* Parameter */, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(164 /* SyntaxKind.Parameter */, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.questionToken); if (questionToken) - node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) - node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ModifierFlags.ParameterPropertyModifier */) + node.transformFlags |= 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; } return node; } @@ -23178,13 +23299,13 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(165 /* Decorator */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseNode(165 /* SyntaxKind.Decorator */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 8192 /* ContainsTypeScriptClassSyntax */ | - 33554432 /* ContainsDecorators */; + 1 /* TransformFlags.ContainsTypeScript */ | + 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */ | + 33554432 /* TransformFlags.ContainsDecorators */; return node; } // @api @@ -23198,10 +23319,10 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(166 /* PropertySignature */, modifiers, name); + var node = createBaseNamedDeclaration(166 /* SyntaxKind.PropertySignature */, modifiers, name); node.type = type; node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.initializer = undefined; return node; @@ -23224,18 +23345,18 @@ var ts; } // @api function createPropertyDeclaration(modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(167 /* PropertyDeclaration */, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(167 /* SyntaxKind.PropertyDeclaration */, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 16777216 /* ContainsClassFields */; + 16777216 /* TransformFlags.ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */; } - if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23252,9 +23373,9 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168 /* MethodSignature */, modifiers, name, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(168 /* SyntaxKind.MethodSignature */, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23270,26 +23391,26 @@ var ts; } // @api function createMethodDeclaration(modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(169 /* MethodDeclaration */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(169 /* SyntaxKind.MethodDeclaration */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (questionToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } // The following properties are used only to report grammar errors node.exclamationToken = undefined; @@ -23316,12 +23437,12 @@ var ts; } // @api function createClassStaticBlockDeclaration(body) { - var node = createBaseGenericNamedDeclaration(170 /* ClassStaticBlockDeclaration */, + var node = createBaseGenericNamedDeclaration(170 /* SyntaxKind.ClassStaticBlockDeclaration */, /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined); node.body = body; - node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */; + node.transformFlags = propagateChildFlags(body) | 16777216 /* TransformFlags.ContainsClassFields */; // The following properties are used only to report grammar errors node.decorators = undefined; node.modifiers = undefined; @@ -23342,11 +23463,11 @@ var ts; } // @api function createConstructorDeclaration(modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(171 /* Constructor */, modifiers, + var node = createBaseFunctionLikeDeclaration(171 /* SyntaxKind.Constructor */, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; // The following properties are used only to report grammar errors node.decorators = undefined; node.typeParameters = undefined; @@ -23371,7 +23492,7 @@ var ts; } // @api function createGetAccessorDeclaration(modifiers, name, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(172 /* GetAccessor */, modifiers, name, + var node = createBaseFunctionLikeDeclaration(172 /* SyntaxKind.GetAccessor */, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); // The following properties are used only to report grammar errors node.typeParameters = undefined; @@ -23395,7 +23516,7 @@ var ts; } // @api function createSetAccessorDeclaration(modifiers, name, parameters, body) { - var node = createBaseFunctionLikeDeclaration(173 /* SetAccessor */, modifiers, name, + var node = createBaseFunctionLikeDeclaration(173 /* SyntaxKind.SetAccessor */, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); // The following properties are used only to report grammar errors @@ -23421,10 +23542,10 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* CallSignature */, + var node = createBaseSignatureDeclaration(174 /* SyntaxKind.CallSignature */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23437,10 +23558,10 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(175 /* SyntaxKind.ConstructSignature */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23453,10 +23574,10 @@ var ts; } // @api function createIndexSignature(modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(176 /* IndexSignature */, modifiers, + var node = createBaseSignatureDeclaration(176 /* SyntaxKind.IndexSignature */, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23469,10 +23590,10 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(199 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(199 /* SyntaxKind.TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23491,11 +23612,11 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(177 /* TypePredicate */); + var node = createBaseNode(177 /* SyntaxKind.TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23508,10 +23629,10 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(178 /* TypeReference */); + var node = createBaseNode(178 /* SyntaxKind.TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23523,10 +23644,10 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(179 /* FunctionType */, + var node = createBaseSignatureDeclaration(179 /* SyntaxKind.FunctionType */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.modifiers = undefined; return node; @@ -23556,9 +23677,9 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(180 /* ConstructorType */, modifiers, + var node = createBaseSignatureDeclaration(180 /* SyntaxKind.ConstructorType */, modifiers, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } /** @deprecated */ @@ -23589,10 +23710,10 @@ var ts; } // @api function createTypeQueryNode(exprName, typeArguments) { - var node = createBaseNode(181 /* TypeQuery */); + var node = createBaseNode(181 /* SyntaxKind.TypeQuery */); node.exprName = exprName; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23604,9 +23725,9 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(182 /* TypeLiteral */); + var node = createBaseNode(182 /* SyntaxKind.TypeLiteral */); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23617,9 +23738,9 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(183 /* ArrayType */); + var node = createBaseNode(183 /* SyntaxKind.ArrayType */); node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23630,9 +23751,9 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(184 /* TupleType */); + var node = createBaseNode(184 /* SyntaxKind.TupleType */); node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23643,12 +23764,12 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(197 /* NamedTupleMember */); + var node = createBaseNode(197 /* SyntaxKind.NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23662,9 +23783,9 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(185 /* OptionalType */); + var node = createBaseNode(185 /* SyntaxKind.OptionalType */); node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23675,9 +23796,9 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(186 /* RestType */); + var node = createBaseNode(186 /* SyntaxKind.RestType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23689,7 +23810,7 @@ var ts; function createUnionOrIntersectionTypeNode(kind, types, parenthesize) { var node = createBaseNode(kind); node.types = factory.createNodeArray(parenthesize(types)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateUnionOrIntersectionTypeNode(node, types, parenthesize) { @@ -23699,7 +23820,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); + return createUnionOrIntersectionTypeNode(187 /* SyntaxKind.UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); } // @api function updateUnionTypeNode(node, types) { @@ -23707,7 +23828,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); + return createUnionOrIntersectionTypeNode(188 /* SyntaxKind.IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); } // @api function updateIntersectionTypeNode(node, types) { @@ -23715,12 +23836,12 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(189 /* ConditionalType */); + var node = createBaseNode(189 /* SyntaxKind.ConditionalType */); node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType); node.trueType = trueType; node.falseType = falseType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23734,9 +23855,9 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(190 /* InferType */); + var node = createBaseNode(190 /* SyntaxKind.InferType */); node.typeParameter = typeParameter; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23747,10 +23868,10 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(198 /* TemplateLiteralType */); + var node = createBaseNode(198 /* SyntaxKind.TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23763,13 +23884,13 @@ var ts; // @api function createImportTypeNode(argument, assertions, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(200 /* ImportType */); + var node = createBaseNode(200 /* SyntaxKind.ImportType */); node.argument = argument; node.assertions = assertions; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23785,9 +23906,9 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(191 /* ParenthesizedType */); + var node = createBaseNode(191 /* SyntaxKind.ParenthesizedType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23798,18 +23919,18 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(192 /* ThisType */); - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseNode(192 /* SyntaxKind.ThisType */); + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(193 /* TypeOperator */); + var node = createBaseNode(193 /* SyntaxKind.TypeOperator */); node.operator = operator; - node.type = operator === 145 /* ReadonlyKeyword */ ? + node.type = operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) : parenthesizerRules().parenthesizeOperandOfTypeOperator(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23820,10 +23941,10 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(194 /* IndexedAccessType */); + var node = createBaseNode(194 /* SyntaxKind.IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType); node.indexType = indexType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23835,14 +23956,14 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) { - var node = createBaseNode(195 /* MappedType */); + var node = createBaseNode(195 /* SyntaxKind.MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; node.questionToken = questionToken; node.type = type; node.members = members && createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23858,9 +23979,9 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(196 /* LiteralType */); + var node = createBaseNode(196 /* SyntaxKind.LiteralType */); node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23874,16 +23995,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(201 /* ObjectBindingPattern */); + var node = createBaseNode(201 /* SyntaxKind.ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 524288 /* ContainsBindingPattern */; - if (node.transformFlags & 32768 /* ContainsRestOrSpread */) { + 1024 /* TransformFlags.ContainsES2015 */ | + 524288 /* TransformFlags.ContainsBindingPattern */; + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */) { node.transformFlags |= - 128 /* ContainsES2018 */ | - 65536 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 65536 /* TransformFlags.ContainsObjectRestOrSpread */; } return node; } @@ -23895,12 +24016,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(202 /* ArrayBindingPattern */); + var node = createBaseNode(202 /* SyntaxKind.ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 524288 /* ContainsBindingPattern */; + 1024 /* TransformFlags.ContainsES2015 */ | + 524288 /* TransformFlags.ContainsBindingPattern */; return node; } // @api @@ -23911,20 +24032,20 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(203 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(203 /* SyntaxKind.BindingElement */, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 32768 /* ContainsRestOrSpread */; + node.transformFlags |= 32768 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -23946,7 +24067,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(204 /* ArrayLiteralExpression */); + var node = createBaseExpression(204 /* SyntaxKind.ArrayLiteralExpression */); // Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that // we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like // a trailing comma. @@ -23965,7 +24086,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(205 /* ObjectLiteralExpression */); + var node = createBaseExpression(205 /* SyntaxKind.ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -23979,20 +24100,20 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.name = asName(name); node.transformFlags = propagateChildFlags(node.expression) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); if (ts.isSuperKeyword(expression)) { // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24008,23 +24129,23 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 32 /* ContainsES2020 */ | + 32 /* TransformFlags.ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); return node; } // @api function updatePropertyAccessChain(node, expression, questionDotToken, name) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -24035,8 +24156,8 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | @@ -24045,8 +24166,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24062,21 +24183,21 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; return node; } // @api function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); // Because we are updating an existing ElementAccessChain we want to inherit its emitFlags // instead of using the default from createElementAccess return node.expression !== expression @@ -24087,8 +24208,8 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); node.transformFlags |= @@ -24096,13 +24217,13 @@ var ts; propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments); if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 8388608 /* ContainsDynamicImport */; + node.transformFlags |= 8388608 /* TransformFlags.ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 16384 /* ContainsLexicalThis */; + node.transformFlags |= 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24119,9 +24240,9 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -24130,18 +24251,18 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 16384 /* ContainsLexicalThis */; + node.transformFlags |= 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } // @api function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); return node.expression !== expression || node.questionDotToken !== questionDotToken || node.typeArguments !== typeArguments @@ -24151,7 +24272,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(209 /* NewExpression */); + var node = createBaseExpression(209 /* SyntaxKind.NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -24159,9 +24280,9 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24175,20 +24296,20 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(210 /* TaggedTemplateExpression */); - node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); + var node = createBaseExpression(210 /* SyntaxKind.TaggedTemplateExpression */); + node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false); node.typeArguments = asNodeArray(typeArguments); node.template = template; node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24202,13 +24323,13 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(211 /* TypeAssertionExpression */); + var node = createBaseExpression(211 /* SyntaxKind.TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24220,7 +24341,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(212 /* ParenthesizedExpression */); + var node = createBaseExpression(212 /* SyntaxKind.ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -24233,22 +24354,22 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(213 /* FunctionExpression */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(213 /* SyntaxKind.FunctionExpression */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -24266,14 +24387,14 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(214 /* ArrowFunction */, modifiers, + var node = createBaseFunctionLikeDeclaration(214 /* SyntaxKind.ArrowFunction */, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); - node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* SyntaxKind.EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 1024 /* ContainsES2015 */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */; + 1024 /* TransformFlags.ContainsES2015 */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */ | 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24290,7 +24411,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(215 /* DeleteExpression */); + var node = createBaseExpression(215 /* SyntaxKind.DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24303,7 +24424,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(216 /* TypeOfExpression */); + var node = createBaseExpression(216 /* SyntaxKind.TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24316,7 +24437,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(217 /* VoidExpression */); + var node = createBaseExpression(217 /* SyntaxKind.VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24329,13 +24450,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(218 /* AwaitExpression */); + var node = createBaseExpression(218 /* SyntaxKind.AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */ | - 2097152 /* ContainsAwait */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 2097152 /* TransformFlags.ContainsAwait */; return node; } // @api @@ -24346,17 +24467,17 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(219 /* PrefixUnaryExpression */); + var node = createBaseExpression(219 /* SyntaxKind.PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); // Only set this flag for non-generated identifiers and non-"local" names. See the // comment in `visitPreOrPostfixUnaryExpression` in module.ts - if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) && + if ((operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24368,7 +24489,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(220 /* PostfixUnaryExpression */); + var node = createBaseExpression(220 /* SyntaxKind.PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -24377,7 +24498,7 @@ var ts; if (ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24389,7 +24510,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(221 /* BinaryExpression */); + var node = createBaseExpression(221 /* SyntaxKind.BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -24399,46 +24520,49 @@ var ts; propagateChildFlags(node.left) | propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); - if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 32 /* ContainsES2020 */; + if (operatorKind === 60 /* SyntaxKind.QuestionQuestionToken */) { + node.transformFlags |= 32 /* TransformFlags.ContainsES2020 */; } - else if (operatorKind === 63 /* EqualsToken */) { + else if (operatorKind === 63 /* SyntaxKind.EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 512 /* ContainsES2016 */; + else if (operatorKind === 42 /* SyntaxKind.AsteriskAsteriskToken */ || operatorKind === 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 512 /* TransformFlags.ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 16 /* ContainsES2021 */; + node.transformFlags |= 16 /* TransformFlags.ContainsES2021 */; + } + if (operatorKind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { + node.transformFlags |= 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) - return 65536 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 128 /* ContainsES2018 */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) + return 65536 /* TransformFlags.ContainsObjectRestOrSpread */; + if (node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' // will not be correctly interpreted by the ES2018 transformer for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return 65536 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return 65536 /* TransformFlags.ContainsObjectRestOrSpread */; } - if (target.transformFlags & 128 /* ContainsES2018 */) { + if (target.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -24446,7 +24570,7 @@ var ts; } } } - return 0 /* None */; + return 0 /* TransformFlags.None */; } // @api function updateBinaryExpression(node, left, operator, right) { @@ -24458,11 +24582,11 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(222 /* ConditionalExpression */); + var node = createBaseExpression(222 /* SyntaxKind.ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); - node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); + node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* SyntaxKind.QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); - node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* ColonToken */); + node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* SyntaxKind.ColonToken */); node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse); node.transformFlags |= propagateChildFlags(node.condition) | @@ -24484,13 +24608,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(223 /* TemplateExpression */); + var node = createBaseExpression(223 /* SyntaxKind.TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24501,8 +24625,8 @@ var ts; : node; } function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) { - if (templateFlags === void 0) { templateFlags = 0 /* None */; } - ts.Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags."); + if (templateFlags === void 0) { templateFlags = 0 /* TokenFlags.None */; } + ts.Debug.assert(!(templateFlags & ~2048 /* TokenFlags.TemplateLiteralLikeFlags */), "Unsupported template flags."); // NOTE: without the assignment to `undefined`, we don't narrow the initial type of `cooked`. // eslint-disable-next-line no-undef-init var cooked = undefined; @@ -24528,41 +24652,41 @@ var ts; var node = createBaseToken(kind); node.text = text; node.rawText = rawText; - node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 1024 /* ContainsES2015 */; + node.templateFlags = templateFlags & 2048 /* TokenFlags.TemplateLiteralLikeFlags */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } // @api function createTemplateHead(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(15 /* TemplateHead */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(15 /* SyntaxKind.TemplateHead */, text, rawText, templateFlags); } // @api function createTemplateMiddle(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(16 /* TemplateMiddle */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(16 /* SyntaxKind.TemplateMiddle */, text, rawText, templateFlags); } // @api function createTemplateTail(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(17 /* TemplateTail */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(17 /* SyntaxKind.TemplateTail */, text, rawText, templateFlags); } // @api function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(14 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); } // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(224 /* YieldExpression */); + var node = createBaseExpression(224 /* SyntaxKind.YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 1048576 /* ContainsYield */; + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 1048576 /* TransformFlags.ContainsYield */; return node; } // @api @@ -24574,12 +24698,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(225 /* SpreadElement */); + var node = createBaseExpression(225 /* SyntaxKind.SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 32768 /* ContainsRestOrSpread */; + 1024 /* TransformFlags.ContainsES2015 */ | + 32768 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24590,8 +24714,8 @@ var ts; } // @api function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(226 /* ClassExpression */, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(226 /* SyntaxKind.ClassExpression */, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24606,17 +24730,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(227 /* OmittedExpression */); + return createBaseExpression(227 /* SyntaxKind.OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(228 /* ExpressionWithTypeArguments */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseNode(228 /* SyntaxKind.ExpressionWithTypeArguments */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24628,13 +24752,13 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(229 /* AsExpression */); + var node = createBaseExpression(229 /* SyntaxKind.AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24646,11 +24770,11 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24664,33 +24788,33 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function updateNonNullChain(node, expression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); return node.expression !== expression ? update(createNonNullChain(expression), node) : node; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(231 /* MetaProperty */); + var node = createBaseExpression(231 /* SyntaxKind.MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 103 /* NewKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 103 /* SyntaxKind.NewKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 100 /* ImportKeyword */: - node.transformFlags |= 4 /* ContainsESNext */; + case 100 /* SyntaxKind.ImportKeyword */: + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; break; default: return ts.Debug.assertNever(keywordToken); @@ -24708,13 +24832,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(233 /* TemplateSpan */); + var node = createBaseNode(233 /* SyntaxKind.TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24726,8 +24850,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(234 /* SemicolonClassElement */); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseNode(234 /* SyntaxKind.SemicolonClassElement */); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @@ -24735,7 +24859,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(235 /* Block */); + var node = createBaseNode(235 /* SyntaxKind.Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -24749,14 +24873,14 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(237 /* VariableStatement */); + var node = createBaseDeclaration(237 /* SyntaxKind.VariableStatement */); node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.declarationList); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24769,11 +24893,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(236 /* EmptyStatement */); + return createBaseNode(236 /* SyntaxKind.EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(238 /* ExpressionStatement */); + var node = createBaseNode(238 /* SyntaxKind.ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24786,7 +24910,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(239 /* IfStatement */); + var node = createBaseNode(239 /* SyntaxKind.IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -24806,7 +24930,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(240 /* DoStatement */); + var node = createBaseNode(240 /* SyntaxKind.DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -24823,7 +24947,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(241 /* WhileStatement */); + var node = createBaseNode(241 /* SyntaxKind.WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24840,7 +24964,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(242 /* ForStatement */); + var node = createBaseNode(242 /* SyntaxKind.ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -24863,7 +24987,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(243 /* ForInStatement */); + var node = createBaseNode(243 /* SyntaxKind.ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -24883,7 +25007,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(244 /* ForOfStatement */); + var node = createBaseNode(244 /* SyntaxKind.ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -24893,9 +25017,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; return node; } // @api @@ -24909,11 +25033,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(245 /* ContinueStatement */); + var node = createBaseNode(245 /* SyntaxKind.ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24924,11 +25048,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(246 /* BreakStatement */); + var node = createBaseNode(246 /* SyntaxKind.BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24939,13 +25063,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(247 /* ReturnStatement */); + var node = createBaseNode(247 /* SyntaxKind.ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 128 /* TransformFlags.ContainsES2018 */ | + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24956,7 +25080,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(248 /* WithStatement */); + var node = createBaseNode(248 /* SyntaxKind.WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24973,7 +25097,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(249 /* SwitchStatement */); + var node = createBaseNode(249 /* SyntaxKind.SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -24990,7 +25114,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(250 /* LabeledStatement */); + var node = createBaseNode(250 /* SyntaxKind.LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -25007,7 +25131,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(251 /* ThrowStatement */); + var node = createBaseNode(251 /* SyntaxKind.ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -25020,7 +25144,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(252 /* TryStatement */); + var node = createBaseNode(252 /* SyntaxKind.TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -25040,16 +25164,16 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(253 /* DebuggerStatement */); + return createBaseNode(253 /* SyntaxKind.DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(254 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(254 /* SyntaxKind.VariableDeclaration */, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25064,17 +25188,17 @@ var ts; } // @api function createVariableDeclarationList(declarations, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(255 /* VariableDeclarationList */); - node.flags |= flags & 3 /* BlockScoped */; + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseNode(255 /* SyntaxKind.VariableDeclarationList */); + node.flags |= flags & 3 /* NodeFlags.BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; - if (flags & 3 /* BlockScoped */) { + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (flags & 3 /* NodeFlags.BlockScoped */) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBlockScopedBinding */; + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBlockScopedBinding */; } return node; } @@ -25086,25 +25210,25 @@ var ts; } // @api function createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(256 /* FunctionDeclaration */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(256 /* SyntaxKind.FunctionDeclaration */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; - if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } } // The following properties are used only to report grammar errors @@ -25132,14 +25256,14 @@ var ts; } // @api function createClassDeclaration(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(257 /* ClassDeclaration */, modifiers, name, typeParameters, heritageClauses, members); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseClassLikeDeclaration(257 /* SyntaxKind.ClassDeclaration */, modifiers, name, typeParameters, heritageClauses, members); + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { - node.transformFlags |= 1024 /* ContainsES2015 */; - if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; + if (node.transformFlags & 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } } return node; @@ -25156,9 +25280,9 @@ var ts; } // @api function createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(258 /* InterfaceDeclaration */, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(258 /* SyntaxKind.InterfaceDeclaration */, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25181,9 +25305,9 @@ var ts; } // @api function createTypeAliasDeclaration(modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(259 /* TypeAliasDeclaration */, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(259 /* SyntaxKind.TypeAliasDeclaration */, modifiers, name, typeParameters); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25205,12 +25329,12 @@ var ts; } // @api function createEnumDeclaration(modifiers, name, members) { - var node = createBaseNamedDeclaration(260 /* EnumDeclaration */, modifiers, name); + var node = createBaseNamedDeclaration(260 /* SyntaxKind.EnumDeclaration */, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25231,23 +25355,23 @@ var ts; } // @api function createModuleDeclaration(modifiers, name, body, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(261 /* ModuleDeclaration */); + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseDeclaration(261 /* SyntaxKind.ModuleDeclaration */); node.modifiers = asNodeArray(modifiers); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); + node.flags |= flags & (16 /* NodeFlags.Namespace */ | 4 /* NodeFlags.NestedNamespace */ | 1024 /* NodeFlags.GlobalAugmentation */); node.name = name; node.body = body; - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25268,7 +25392,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(262 /* ModuleBlock */); + var node = createBaseNode(262 /* SyntaxKind.ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -25281,7 +25405,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(263 /* CaseBlock */); + var node = createBaseNode(263 /* SyntaxKind.CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -25294,9 +25418,9 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(264 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(264 /* SyntaxKind.NamespaceExportDeclaration */, /*modifiers*/ undefined, name); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; node.modifiers = undefined; @@ -25317,13 +25441,13 @@ var ts; } // @api function createImportEqualsDeclaration(modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(265 /* ImportEqualsDeclaration */, modifiers, name); + var node = createBaseNamedDeclaration(265 /* SyntaxKind.ImportEqualsDeclaration */, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) - node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25345,7 +25469,7 @@ var ts; } // @api function createImportDeclaration(modifiers, importClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(266 /* ImportDeclaration */); + var node = createBaseDeclaration(266 /* SyntaxKind.ImportDeclaration */); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; @@ -25353,7 +25477,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25375,7 +25499,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(267 /* ImportClause */); + var node = createBaseNode(267 /* SyntaxKind.ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -25383,9 +25507,9 @@ var ts; propagateChildFlags(node.name) | propagateChildFlags(node.namedBindings); if (isTypeOnly) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25398,10 +25522,10 @@ var ts; } // @api function createAssertClause(elements, multiLine) { - var node = createBaseNode(293 /* AssertClause */); + var node = createBaseNode(293 /* SyntaxKind.AssertClause */); node.elements = createNodeArray(elements); node.multiLine = multiLine; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25413,10 +25537,10 @@ var ts; } // @api function createAssertEntry(name, value) { - var node = createBaseNode(294 /* AssertEntry */); + var node = createBaseNode(294 /* SyntaxKind.AssertEntry */); node.name = name; node.value = value; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25428,7 +25552,7 @@ var ts; } // @api function createImportTypeAssertionContainer(clause, multiLine) { - var node = createBaseNode(295 /* ImportTypeAssertionContainer */); + var node = createBaseNode(295 /* SyntaxKind.ImportTypeAssertionContainer */); node.assertClause = clause; node.multiLine = multiLine; return node; @@ -25442,10 +25566,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(268 /* NamespaceImport */); + var node = createBaseNode(268 /* SyntaxKind.NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25456,12 +25580,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(274 /* NamespaceExport */); + var node = createBaseNode(274 /* SyntaxKind.NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | - 4 /* ContainsESNext */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + 4 /* TransformFlags.ContainsESNext */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25472,10 +25596,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(269 /* NamedImports */); + var node = createBaseNode(269 /* SyntaxKind.NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25486,14 +25610,14 @@ var ts; } // @api function createImportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(270 /* ImportSpecifier */); + var node = createBaseNode(270 /* SyntaxKind.ImportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25506,14 +25630,14 @@ var ts; } // @api function createExportAssignment(modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(271 /* ExportAssignment */); + var node = createBaseDeclaration(271 /* SyntaxKind.ExportAssignment */); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* SyntaxKind.EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.expression); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25533,7 +25657,7 @@ var ts; } // @api function createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(272 /* ExportDeclaration */); + var node = createBaseDeclaration(272 /* SyntaxKind.ExportDeclaration */); node.modifiers = asNodeArray(modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; @@ -25543,7 +25667,7 @@ var ts; propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25566,10 +25690,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(273 /* NamedExports */); + var node = createBaseNode(273 /* SyntaxKind.NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25580,14 +25704,14 @@ var ts; } // @api function createExportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(275 /* ExportSpecifier */); + var node = createBaseNode(275 /* SyntaxKind.ExportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25600,7 +25724,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(276 /* MissingDeclaration */); + var node = createBaseDeclaration(276 /* SyntaxKind.MissingDeclaration */); return node; } // @@ -25608,10 +25732,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(277 /* ExternalModuleReference */); + var node = createBaseNode(277 /* SyntaxKind.ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25666,7 +25790,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(317 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(317 /* SyntaxKind.JSDocFunctionType */, /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); @@ -25682,7 +25806,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(322 /* JSDocTypeLiteral */); + var node = createBaseNode(322 /* SyntaxKind.JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -25696,7 +25820,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(309 /* JSDocTypeExpression */); + var node = createBaseNode(309 /* SyntaxKind.JSDocTypeExpression */); node.type = type; return node; } @@ -25708,7 +25832,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(323 /* JSDocSignature */); + var node = createBaseNode(323 /* SyntaxKind.JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -25737,7 +25861,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(344 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(344 /* SyntaxKind.JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -25754,7 +25878,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(345 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(345 /* SyntaxKind.JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25772,7 +25896,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(340 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(340 /* SyntaxKind.JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25793,7 +25917,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(347 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(347 /* SyntaxKind.JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25814,7 +25938,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(338 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(338 /* SyntaxKind.JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25832,7 +25956,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(328 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(328 /* SyntaxKind.JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -25847,13 +25971,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(329 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(329 /* SyntaxKind.JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(346 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(346 /* SyntaxKind.JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -25867,7 +25991,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(310 /* JSDocNameReference */); + var node = createBaseNode(310 /* SyntaxKind.JSDocNameReference */); node.name = name; return node; } @@ -25879,7 +26003,7 @@ var ts; } // @api function createJSDocMemberName(left, right) { - var node = createBaseNode(311 /* JSDocMemberName */); + var node = createBaseNode(311 /* SyntaxKind.JSDocMemberName */); node.left = left; node.right = right; node.transformFlags |= @@ -25896,7 +26020,7 @@ var ts; } // @api function createJSDocLink(name, text) { - var node = createBaseNode(324 /* JSDocLink */); + var node = createBaseNode(324 /* SyntaxKind.JSDocLink */); node.name = name; node.text = text; return node; @@ -25909,7 +26033,7 @@ var ts; } // @api function createJSDocLinkCode(name, text) { - var node = createBaseNode(325 /* JSDocLinkCode */); + var node = createBaseNode(325 /* SyntaxKind.JSDocLinkCode */); node.name = name; node.text = text; return node; @@ -25922,7 +26046,7 @@ var ts; } // @api function createJSDocLinkPlain(name, text) { - var node = createBaseNode(326 /* JSDocLinkPlain */); + var node = createBaseNode(326 /* SyntaxKind.JSDocLinkPlain */); node.name = name; node.text = text; return node; @@ -25994,7 +26118,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(327 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(327 /* SyntaxKind.JSDocTag */, tagName, comment); return node; } // @api @@ -26006,7 +26130,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(321 /* JSDocText */); + var node = createBaseNode(321 /* SyntaxKind.JSDocText */); node.text = text; return node; } @@ -26018,7 +26142,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(320 /* JSDoc */); + var node = createBaseNode(320 /* SyntaxKind.JSDoc */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -26035,7 +26159,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(278 /* JsxElement */); + var node = createBaseNode(278 /* SyntaxKind.JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -26043,7 +26167,7 @@ var ts; propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26056,7 +26180,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(279 /* JsxSelfClosingElement */); + var node = createBaseNode(279 /* SyntaxKind.JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -26064,9 +26188,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -26080,7 +26204,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(280 /* JsxOpeningElement */); + var node = createBaseNode(280 /* SyntaxKind.JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -26088,9 +26212,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -26104,11 +26228,11 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(281 /* JsxClosingElement */); + var node = createBaseNode(281 /* SyntaxKind.JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26119,7 +26243,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(282 /* JsxFragment */); + var node = createBaseNode(282 /* SyntaxKind.JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -26127,7 +26251,7 @@ var ts; propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26140,10 +26264,10 @@ var ts; } // @api function createJsxText(text, containsOnlyTriviaWhiteSpaces) { - var node = createBaseNode(11 /* JsxText */); + var node = createBaseNode(11 /* SyntaxKind.JsxText */); node.text = text; node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces; - node.transformFlags |= 2 /* ContainsJsx */; + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26155,25 +26279,25 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(283 /* JsxOpeningFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(283 /* SyntaxKind.JsxOpeningFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(284 /* JsxClosingFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(284 /* SyntaxKind.JsxClosingFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(285 /* JsxAttribute */); + var node = createBaseNode(285 /* SyntaxKind.JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26185,11 +26309,11 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(286 /* JsxAttributes */); + var node = createBaseNode(286 /* SyntaxKind.JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26200,11 +26324,11 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(287 /* JsxSpreadAttribute */); + var node = createBaseNode(287 /* SyntaxKind.JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26215,13 +26339,13 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(288 /* JsxExpression */); + var node = createBaseNode(288 /* SyntaxKind.JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26235,7 +26359,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(289 /* CaseClause */); + var node = createBaseNode(289 /* SyntaxKind.CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -26252,7 +26376,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(290 /* DefaultClause */); + var node = createBaseNode(290 /* SyntaxKind.DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -26265,16 +26389,16 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(291 /* HeritageClause */); + var node = createBaseNode(291 /* SyntaxKind.HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 94 /* ExtendsKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 94 /* SyntaxKind.ExtendsKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 117 /* ImplementsKeyword */: - node.transformFlags |= 1 /* ContainsTypeScript */; + case 117 /* SyntaxKind.ImplementsKeyword */: + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; break; default: return ts.Debug.assertNever(token); @@ -26289,7 +26413,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(292 /* CatchClause */); + var node = createBaseNode(292 /* SyntaxKind.CatchClause */); if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) { variableDeclaration = createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, @@ -26302,7 +26426,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 64 /* ContainsES2019 */; + node.transformFlags |= 64 /* TransformFlags.ContainsES2019 */; return node; } // @api @@ -26317,7 +26441,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(296 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(296 /* SyntaxKind.PropertyAssignment */, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -26349,12 +26473,12 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(297 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(297 /* SyntaxKind.ShorthandPropertyAssignment */, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; // The following properties are used only to report grammar errors node.equalsToken = undefined; node.decorators = undefined; @@ -26383,12 +26507,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(298 /* SpreadAssignment */); + var node = createBaseNode(298 /* SyntaxKind.SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 65536 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 65536 /* TransformFlags.ContainsObjectRestOrSpread */; return node; } // @api @@ -26402,13 +26526,13 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(299 /* EnumMember */); + var node = createBaseNode(299 /* SyntaxKind.EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -26423,7 +26547,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -26440,7 +26564,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SourceFile */)); + var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */)); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -26479,7 +26603,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(306 /* Bundle */); + var node = createBaseNode(306 /* SyntaxKind.Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -26494,7 +26618,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(307 /* UnparsedSource */); + var node = createBaseNode(307 /* SyntaxKind.UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -26512,28 +26636,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(300 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(300 /* SyntaxKind.UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(301 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(301 /* SyntaxKind.UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 303 /* UnparsedInternalText */ : 302 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 303 /* SyntaxKind.UnparsedInternalText */ : 302 /* SyntaxKind.UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(304 /* UnparsedSyntheticReference */); + var node = createBaseNode(304 /* SyntaxKind.UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(308 /* InputFiles */); + var node = createBaseNode(308 /* SyntaxKind.InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -26544,7 +26668,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(232 /* SyntheticExpression */); + var node = createBaseNode(232 /* SyntaxKind.SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -26552,7 +26676,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(348 /* SyntaxList */); + var node = createBaseNode(348 /* SyntaxKind.SyntaxList */); node._children = children; return node; } @@ -26567,7 +26691,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(349 /* NotEmittedStatement */); + var node = createBaseNode(349 /* SyntaxKind.NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -26581,12 +26705,12 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(350 /* PartiallyEmittedExpression */); + var node = createBaseNode(350 /* SyntaxKind.PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -26609,7 +26733,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(351 /* CommaListExpression */); + var node = createBaseNode(351 /* SyntaxKind.CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -26626,7 +26750,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(353 /* EndOfDeclarationMarker */); + var node = createBaseNode(353 /* SyntaxKind.EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -26637,14 +26761,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(352 /* MergeDeclarationMarker */); + var node = createBaseNode(352 /* SyntaxKind.MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(354 /* SyntheticReferenceExpression */); + var node = createBaseNode(354 /* SyntaxKind.SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -26666,12 +26790,12 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); - clone.flags |= (node.flags & ~8 /* Synthesized */); + clone.flags |= (node.flags & ~8 /* NodeFlags.Synthesized */); clone.transformFlags = node.transformFlags; setOriginalNode(clone, node); for (var key in node) { @@ -26783,11 +26907,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 212 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 211 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 229 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 230 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 350 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 212 /* SyntaxKind.ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 211 /* SyntaxKind.TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 229 /* SyntaxKind.AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 230 /* SyntaxKind.NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -26813,7 +26937,7 @@ var ts; && !ts.some(ts.getSyntheticTrailingComments(node)); } function restoreOuterExpressions(outerExpression, innerExpression, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression)); } @@ -26834,20 +26958,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cacheIdentifiers; - case 108 /* ThisKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return false; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -26855,7 +26979,7 @@ var ts; } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } - var callee = ts.skipOuterExpressions(expression, 15 /* All */); + var callee = ts.skipOuterExpressions(expression, 15 /* OuterExpressionKinds.All */); var thisArg; var target; if (ts.isSuperProperty(callee)) { @@ -26864,13 +26988,13 @@ var ts; } else if (ts.isSuperKeyword(callee)) { thisArg = createThis(); - target = languageVersion !== undefined && languageVersion < 2 /* ES2015 */ + target = languageVersion !== undefined && languageVersion < 2 /* ScriptTarget.ES2015 */ ? ts.setTextRange(createIdentifier("_super"), callee) : callee; } - else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + else if (ts.getEmitFlags(callee) & 4096 /* EmitFlags.HelperName */) { thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false); } else if (ts.isPropertyAccessExpression(callee)) { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { @@ -26899,7 +27023,7 @@ var ts; else { // for `a()` target is `a` and thisArg is `void 0` thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); } return { target: target, thisArg: thisArg }; } @@ -26933,9 +27057,9 @@ var ts; var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent); emitFlags |= ts.getEmitFlags(nodeName); if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(name, emitFlags); return name; @@ -26954,7 +27078,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getInternalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */ | 32768 /* EmitFlags.InternalName */); } /** * Gets the local name of a declaration. This is primarily used for declarations that can be @@ -26967,7 +27091,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */); } /** * Gets the export name of a declaration. This is primarily used for declarations that can be @@ -26980,7 +27104,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192 /* ExportName */); + return getName(node, allowComments, allowSourceMaps, 8192 /* EmitFlags.ExportName */); } /** * Gets the name of a declaration for use in declarations. @@ -27005,9 +27129,9 @@ var ts; ts.setTextRange(qualifiedName, name); var emitFlags = 0; if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; @@ -27024,7 +27148,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -27082,7 +27206,7 @@ var ts; var numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) { + if (ts.getEmitFlags(statement) & 1048576 /* EmitFlags.CustomPrologue */ && filter(statement)) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -27273,52 +27397,52 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 343 /* JSDocTypeTag */: return "type"; - case 341 /* JSDocReturnTag */: return "returns"; - case 342 /* JSDocThisTag */: return "this"; - case 339 /* JSDocEnumTag */: return "enum"; - case 330 /* JSDocAuthorTag */: return "author"; - case 332 /* JSDocClassTag */: return "class"; - case 333 /* JSDocPublicTag */: return "public"; - case 334 /* JSDocPrivateTag */: return "private"; - case 335 /* JSDocProtectedTag */: return "protected"; - case 336 /* JSDocReadonlyTag */: return "readonly"; - case 337 /* JSDocOverrideTag */: return "override"; - case 344 /* JSDocTemplateTag */: return "template"; - case 345 /* JSDocTypedefTag */: return "typedef"; - case 340 /* JSDocParameterTag */: return "param"; - case 347 /* JSDocPropertyTag */: return "prop"; - case 338 /* JSDocCallbackTag */: return "callback"; - case 328 /* JSDocAugmentsTag */: return "augments"; - case 329 /* JSDocImplementsTag */: return "implements"; + case 343 /* SyntaxKind.JSDocTypeTag */: return "type"; + case 341 /* SyntaxKind.JSDocReturnTag */: return "returns"; + case 342 /* SyntaxKind.JSDocThisTag */: return "this"; + case 339 /* SyntaxKind.JSDocEnumTag */: return "enum"; + case 330 /* SyntaxKind.JSDocAuthorTag */: return "author"; + case 332 /* SyntaxKind.JSDocClassTag */: return "class"; + case 333 /* SyntaxKind.JSDocPublicTag */: return "public"; + case 334 /* SyntaxKind.JSDocPrivateTag */: return "private"; + case 335 /* SyntaxKind.JSDocProtectedTag */: return "protected"; + case 336 /* SyntaxKind.JSDocReadonlyTag */: return "readonly"; + case 337 /* SyntaxKind.JSDocOverrideTag */: return "override"; + case 344 /* SyntaxKind.JSDocTemplateTag */: return "template"; + case 345 /* SyntaxKind.JSDocTypedefTag */: return "typedef"; + case 340 /* SyntaxKind.JSDocParameterTag */: return "param"; + case 347 /* SyntaxKind.JSDocPropertyTag */: return "prop"; + case 338 /* SyntaxKind.JSDocCallbackTag */: return "callback"; + case 328 /* SyntaxKind.JSDocAugmentsTag */: return "augments"; + case 329 /* SyntaxKind.JSDocImplementsTag */: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; var invalidValueSentinel = {}; function getCookedText(kind, rawText) { if (!rawTextScanner) { - rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + rawTextScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); } switch (kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: rawTextScanner.setText("`" + rawText + "`"); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: rawTextScanner.setText("}" + rawText + "`"); break; } var token = rawTextScanner.scan(); - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false); } if (rawTextScanner.isUnterminated()) { @@ -27327,14 +27451,14 @@ var ts; } var tokenValue; switch (token) { - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: tokenValue = rawTextScanner.getTokenValue(); break; } - if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* SyntaxKind.EndOfFileToken */) { rawTextScanner.setText(undefined); return invalidValueSentinel; } @@ -27343,22 +27467,22 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 134234112 /* TransformFlags.PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) - return 0 /* None */; + return 0 /* TransformFlags.None */; var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind); return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags; } function propagateChildrenFlags(children) { - return children ? children.transformFlags : 0 /* None */; + return children ? children.transformFlags : 0 /* TransformFlags.None */; } function aggregateChildrenFlags(children) { - var subtreeFlags = 0 /* None */; + var subtreeFlags = 0 /* TransformFlags.None */; for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { var child = children_2[_i]; subtreeFlags |= propagateChildFlags(child); @@ -27370,78 +27494,78 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) { - return -2 /* TypeExcludes */; + if (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) { + return -2 /* TransformFlags.TypeExcludes */; } switch (kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 204 /* ArrayLiteralExpression */: - return 536903680 /* ArrayLiteralOrCallOrNewExcludes */; - case 261 /* ModuleDeclaration */: - return 742678528 /* ModuleExcludes */; - case 164 /* Parameter */: - return 536870912 /* ParameterExcludes */; - case 214 /* ArrowFunction */: - return 612179968 /* ArrowFunctionExcludes */; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - return 746414080 /* FunctionExcludes */; - case 255 /* VariableDeclarationList */: - return 537460736 /* VariableDeclarationListExcludes */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return 537010176 /* ClassExcludes */; - case 171 /* Constructor */: - return 746405888 /* ConstructorExcludes */; - case 167 /* PropertyDeclaration */: - return 671105024 /* PropertyExcludes */; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return 679297024 /* MethodOrAccessorExcludes */; - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 150 /* StringKeyword */: - case 148 /* ObjectKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 163 /* TypeParameter */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return -2 /* TypeExcludes */; - case 205 /* ObjectLiteralExpression */: - return 537075712 /* ObjectLiteralExcludes */; - case 292 /* CatchClause */: - return 536936448 /* CatchClauseExcludes */; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - return 536903680 /* BindingPatternExcludes */; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - case 350 /* PartiallyEmittedExpression */: - case 212 /* ParenthesizedExpression */: - case 106 /* SuperKeyword */: - return 536870912 /* OuterExpressionExcludes */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - return 536870912 /* PropertyAccessExcludes */; + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return -2147450880 /* TransformFlags.ArrayLiteralOrCallOrNewExcludes */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return -1941676032 /* TransformFlags.ModuleExcludes */; + case 164 /* SyntaxKind.Parameter */: + return -2147483648 /* TransformFlags.ParameterExcludes */; + case 214 /* SyntaxKind.ArrowFunction */: + return -2072174592 /* TransformFlags.ArrowFunctionExcludes */; + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return -1937940480 /* TransformFlags.FunctionExcludes */; + case 255 /* SyntaxKind.VariableDeclarationList */: + return -2146893824 /* TransformFlags.VariableDeclarationListExcludes */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return -2147344384 /* TransformFlags.ClassExcludes */; + case 171 /* SyntaxKind.Constructor */: + return -1937948672 /* TransformFlags.ConstructorExcludes */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return -2013249536 /* TransformFlags.PropertyExcludes */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return -2005057536 /* TransformFlags.MethodOrAccessorExcludes */; + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 163 /* SyntaxKind.TypeParameter */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return -2 /* TransformFlags.TypeExcludes */; + case 205 /* SyntaxKind.ObjectLiteralExpression */: + return -2147278848 /* TransformFlags.ObjectLiteralExcludes */; + case 292 /* SyntaxKind.CatchClause */: + return -2147418112 /* TransformFlags.CatchClauseExcludes */; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return -2147450880 /* TransformFlags.BindingPatternExcludes */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 106 /* SyntaxKind.SuperKeyword */: + return -2147483648 /* TransformFlags.OuterExpressionExcludes */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + return -2147483648 /* TransformFlags.PropertyAccessExcludes */; default: - return 536870912 /* NodeExcludes */; + return -2147483648 /* TransformFlags.NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; var baseFactory = ts.createBaseNodeFactory(); function makeSynthetic(node) { - node.flags |= 8 /* Synthesized */; + node.flags |= 8 /* NodeFlags.Synthesized */; return node; } var syntheticFactory = { @@ -27451,7 +27575,7 @@ var ts; createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); }, createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); }, }; - ts.factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory); + ts.factory = createNodeFactory(4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */, syntheticFactory); function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { var stripInternal; var bundleFileInfo; @@ -27514,50 +27638,50 @@ var ts; for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "prologue" /* Prologue */: + case "prologue" /* BundleFileSectionKind.Prologue */: prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section)); break; - case "emitHelpers" /* EmitHelpers */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data)); break; - case "no-default-lib" /* NoDefaultLib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: hasNoDefaultLib = true; break; - case "reference" /* Reference */: + case "reference" /* BundleFileSectionKind.Reference */: referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data }); break; - case "type" /* Type */: + case "type" /* BundleFileSectionKind.Type */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "type-import" /* TypeResolutionModeImport */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext }); break; - case "type-require" /* TypeResolutionModeRequire */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS }); break; - case "lib" /* Lib */: + case "lib" /* BundleFileSectionKind.Lib */: libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "prepend" /* Prepend */: + case "prepend" /* BundleFileSectionKind.Prepend */: var prependTexts = void 0; for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { var text = _c[_b]; - if (!stripInternal || text.kind !== "internal" /* Internal */) { - prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* Internal */), text)); + if (!stripInternal || text.kind !== "internal" /* BundleFileSectionKind.Internal */) { + prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* BundleFileSectionKind.Internal */), text)); } } prependChildren = ts.addRange(prependChildren, prependTexts); texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray)); break; - case "internal" /* Internal */: + case "internal" /* BundleFileSectionKind.Internal */: if (stripInternal) { if (!texts) texts = []; break; } // falls through - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; default: ts.Debug.assertNever(section); @@ -27585,22 +27709,22 @@ var ts; for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "internal" /* Internal */: - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "internal" /* BundleFileSectionKind.Internal */: + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; - case "no-default-lib" /* NoDefaultLib */: - case "reference" /* Reference */: - case "type" /* Type */: - case "type-import" /* TypeResolutionModeImport */: - case "type-require" /* TypeResolutionModeRequire */: - case "lib" /* Lib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: + case "reference" /* BundleFileSectionKind.Reference */: + case "type" /* BundleFileSectionKind.Type */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: + case "lib" /* BundleFileSectionKind.Lib */: syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section)); break; // Ignore - case "prologue" /* Prologue */: - case "emitHelpers" /* EmitHelpers */: - case "prepend" /* Prepend */: + case "prologue" /* BundleFileSectionKind.Prologue */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: + case "prepend" /* BundleFileSectionKind.Prepend */: break; default: ts.Debug.assertNever(section); @@ -27628,7 +27752,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -27697,7 +27821,7 @@ var ts; if (trailingComments) destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) - destEmitNode.flags = flags & ~268435456 /* Immutable */; + destEmitNode.flags = flags & ~268435456 /* EmitFlags.Immutable */; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) @@ -27739,7 +27863,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -27748,7 +27872,7 @@ var ts; node.emitNode = {}; } else { - ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node."); + ts.Debug.assert(!(node.emitNode.flags & 268435456 /* EmitFlags.Immutable */), "Invalid attempt to mutate an immutable node."); } return node.emitNode; } @@ -27780,7 +27904,7 @@ var ts; */ function removeAllComments(node) { var emitNode = getOrCreateEmitNode(node); - emitNode.flags |= 1536 /* NoComments */; + emitNode.flags |= 1536 /* EmitFlags.NoComments */; emitNode.leadingComments = undefined; emitNode.trailingComments = undefined; return node; @@ -28016,7 +28140,7 @@ var ts; ts.setSnippetElement = setSnippetElement; /* @internal */ function ignoreSourceNewlines(node) { - getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; + getOrCreateEmitNode(node).flags |= 134217728 /* EmitFlags.IgnoreSourceNewlines */; return node; } ts.ignoreSourceNewlines = ignoreSourceNewlines; @@ -28039,8 +28163,8 @@ var ts; (function (ts) { function createEmitHelperFactory(context) { var factory = context.factory; - var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); }); - var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); }); + var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* EmitFlags.Immutable */); }); + var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* EmitFlags.Immutable */); }); return { getUnscopedHelperName: getUnscopedHelperName, // TypeScript Helpers @@ -28081,7 +28205,7 @@ var ts; * Gets an identifier for the name of an *unscoped* emit helper. */ function getUnscopedHelperName(name) { - return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* EmitFlags.HelperName */ | 2 /* EmitFlags.AdviseOnEmitNode */); } // TypeScript Helpers function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) { @@ -28116,7 +28240,7 @@ var ts; } // ES2018 Helpers function createAssignHelper(attributesSegments) { - if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } @@ -28132,7 +28256,7 @@ var ts; context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28186,13 +28310,13 @@ var ts; function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28205,7 +28329,7 @@ var ts; function createExtendsHelper(name) { context.requestEmitHelper(ts.extendsHelper); return factory.createCallExpression(getUnscopedHelperName("__extends"), - /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]); + /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)]); } function createTemplateObjectHelper(cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); @@ -28295,13 +28419,13 @@ var ts; /* @internal */ function compareEmitHelpers(x, y) { if (x === y) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === y.priority) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; if (y.priority === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; @@ -28708,7 +28832,7 @@ var ts; function isCallToHelper(firstSegment, helperName) { return ts.isCallExpression(firstSegment) && ts.isIdentifier(firstSegment.expression) - && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0 + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* EmitFlags.HelperName */) !== 0 && firstSegment.expression.escapedText === helperName; } ts.isCallToHelper = isCallToHelper; @@ -28717,750 +28841,750 @@ var ts; (function (ts) { // Literals function isNumericLiteral(node) { - return node.kind === 8 /* NumericLiteral */; + return node.kind === 8 /* SyntaxKind.NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; function isBigIntLiteral(node) { - return node.kind === 9 /* BigIntLiteral */; + return node.kind === 9 /* SyntaxKind.BigIntLiteral */; } ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 10 /* StringLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 11 /* JsxText */; + return node.kind === 11 /* SyntaxKind.JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 13 /* RegularExpressionLiteral */; + return node.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 15 /* TemplateHead */; + return node.kind === 15 /* SyntaxKind.TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 16 /* TemplateMiddle */; + return node.kind === 16 /* SyntaxKind.TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 17 /* TemplateTail */; + return node.kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateTail = isTemplateTail; // Punctuation function isDotDotDotToken(node) { - return node.kind === 25 /* DotDotDotToken */; + return node.kind === 25 /* SyntaxKind.DotDotDotToken */; } ts.isDotDotDotToken = isDotDotDotToken; /*@internal*/ function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; + return node.kind === 27 /* SyntaxKind.CommaToken */; } ts.isCommaToken = isCommaToken; function isPlusToken(node) { - return node.kind === 39 /* PlusToken */; + return node.kind === 39 /* SyntaxKind.PlusToken */; } ts.isPlusToken = isPlusToken; function isMinusToken(node) { - return node.kind === 40 /* MinusToken */; + return node.kind === 40 /* SyntaxKind.MinusToken */; } ts.isMinusToken = isMinusToken; function isAsteriskToken(node) { - return node.kind === 41 /* AsteriskToken */; + return node.kind === 41 /* SyntaxKind.AsteriskToken */; } ts.isAsteriskToken = isAsteriskToken; /*@internal*/ function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + return node.kind === 53 /* SyntaxKind.ExclamationToken */; } ts.isExclamationToken = isExclamationToken; /*@internal*/ function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + return node.kind === 57 /* SyntaxKind.QuestionToken */; } ts.isQuestionToken = isQuestionToken; /*@internal*/ function isColonToken(node) { - return node.kind === 58 /* ColonToken */; + return node.kind === 58 /* SyntaxKind.ColonToken */; } ts.isColonToken = isColonToken; /*@internal*/ function isQuestionDotToken(node) { - return node.kind === 28 /* QuestionDotToken */; + return node.kind === 28 /* SyntaxKind.QuestionDotToken */; } ts.isQuestionDotToken = isQuestionDotToken; /*@internal*/ function isEqualsGreaterThanToken(node) { - return node.kind === 38 /* EqualsGreaterThanToken */; + return node.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */; } ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 79 /* Identifier */; + return node.kind === 79 /* SyntaxKind.Identifier */; } ts.isIdentifier = isIdentifier; function isPrivateIdentifier(node) { - return node.kind === 80 /* PrivateIdentifier */; + return node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; // Reserved Words /* @internal */ function isExportModifier(node) { - return node.kind === 93 /* ExportKeyword */; + return node.kind === 93 /* SyntaxKind.ExportKeyword */; } ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 131 /* AsyncKeyword */; + return node.kind === 131 /* SyntaxKind.AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ function isAssertsKeyword(node) { - return node.kind === 128 /* AssertsKeyword */; + return node.kind === 128 /* SyntaxKind.AssertsKeyword */; } ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 132 /* AwaitKeyword */; + return node.kind === 132 /* SyntaxKind.AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 145 /* ReadonlyKeyword */; + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ function isStaticModifier(node) { - return node.kind === 124 /* StaticKeyword */; + return node.kind === 124 /* SyntaxKind.StaticKeyword */; } ts.isStaticModifier = isStaticModifier; /* @internal */ function isAbstractModifier(node) { - return node.kind === 126 /* AbstractKeyword */; + return node.kind === 126 /* SyntaxKind.AbstractKeyword */; } ts.isAbstractModifier = isAbstractModifier; /* @internal */ function isOverrideModifier(node) { - return node.kind === 159 /* OverrideKeyword */; + return node.kind === 159 /* SyntaxKind.OverrideKeyword */; } ts.isOverrideModifier = isOverrideModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 106 /* SuperKeyword */; + return node.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 100 /* ImportKeyword */; + return node.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 161 /* QualifiedName */; + return node.kind === 161 /* SyntaxKind.QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 162 /* ComputedPropertyName */; + return node.kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 163 /* TypeParameter */; + return node.kind === 163 /* SyntaxKind.TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 164 /* Parameter */; + return node.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 166 /* PropertySignature */; + return node.kind === 166 /* SyntaxKind.PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 167 /* PropertyDeclaration */; + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 168 /* MethodSignature */; + return node.kind === 168 /* SyntaxKind.MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassStaticBlockDeclaration(node) { - return node.kind === 170 /* ClassStaticBlockDeclaration */; + return node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 171 /* Constructor */; + return node.kind === 171 /* SyntaxKind.Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 174 /* CallSignature */; + return node.kind === 174 /* SyntaxKind.CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 175 /* ConstructSignature */; + return node.kind === 175 /* SyntaxKind.ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 176 /* IndexSignature */; + return node.kind === 176 /* SyntaxKind.IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 177 /* TypePredicate */; + return node.kind === 177 /* SyntaxKind.TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 178 /* TypeReference */; + return node.kind === 178 /* SyntaxKind.TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 179 /* FunctionType */; + return node.kind === 179 /* SyntaxKind.FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 180 /* ConstructorType */; + return node.kind === 180 /* SyntaxKind.ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 182 /* TypeLiteral */; + return node.kind === 182 /* SyntaxKind.TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 183 /* ArrayType */; + return node.kind === 183 /* SyntaxKind.ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 184 /* TupleType */; + return node.kind === 184 /* SyntaxKind.TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 197 /* NamedTupleMember */; + return node.kind === 197 /* SyntaxKind.NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 185 /* OptionalType */; + return node.kind === 185 /* SyntaxKind.OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 186 /* RestType */; + return node.kind === 186 /* SyntaxKind.RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 187 /* UnionType */; + return node.kind === 187 /* SyntaxKind.UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 188 /* IntersectionType */; + return node.kind === 188 /* SyntaxKind.IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 189 /* ConditionalType */; + return node.kind === 189 /* SyntaxKind.ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 190 /* InferType */; + return node.kind === 190 /* SyntaxKind.InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 191 /* ParenthesizedType */; + return node.kind === 191 /* SyntaxKind.ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 192 /* ThisType */; + return node.kind === 192 /* SyntaxKind.ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 193 /* TypeOperator */; + return node.kind === 193 /* SyntaxKind.TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 194 /* IndexedAccessType */; + return node.kind === 194 /* SyntaxKind.IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 195 /* MappedType */; + return node.kind === 195 /* SyntaxKind.MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 196 /* LiteralType */; + return node.kind === 196 /* SyntaxKind.LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 200 /* ImportType */; + return node.kind === 200 /* SyntaxKind.ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 199 /* TemplateLiteralTypeSpan */; + return node.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 198 /* TemplateLiteralType */; + return node.kind === 198 /* SyntaxKind.TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 201 /* ObjectBindingPattern */; + return node.kind === 201 /* SyntaxKind.ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 202 /* ArrayBindingPattern */; + return node.kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 203 /* BindingElement */; + return node.kind === 203 /* SyntaxKind.BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 204 /* ArrayLiteralExpression */; + return node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 205 /* ObjectLiteralExpression */; + return node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 207 /* ElementAccessExpression */; + return node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 208 /* CallExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 209 /* NewExpression */; + return node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 210 /* TaggedTemplateExpression */; + return node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 212 /* ParenthesizedExpression */; + return node.kind === 212 /* SyntaxKind.ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 213 /* FunctionExpression */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 214 /* ArrowFunction */; + return node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 215 /* DeleteExpression */; + return node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 216 /* TypeOfExpression */; + return node.kind === 216 /* SyntaxKind.TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 217 /* VoidExpression */; + return node.kind === 217 /* SyntaxKind.VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 218 /* AwaitExpression */; + return node.kind === 218 /* SyntaxKind.AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 219 /* PrefixUnaryExpression */; + return node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 220 /* PostfixUnaryExpression */; + return node.kind === 220 /* SyntaxKind.PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 221 /* BinaryExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 222 /* ConditionalExpression */; + return node.kind === 222 /* SyntaxKind.ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 223 /* TemplateExpression */; + return node.kind === 223 /* SyntaxKind.TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 224 /* YieldExpression */; + return node.kind === 224 /* SyntaxKind.YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 225 /* SpreadElement */; + return node.kind === 225 /* SyntaxKind.SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 226 /* ClassExpression */; + return node.kind === 226 /* SyntaxKind.ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 227 /* OmittedExpression */; + return node.kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 229 /* AsExpression */; + return node.kind === 229 /* SyntaxKind.AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 230 /* NonNullExpression */; + return node.kind === 230 /* SyntaxKind.NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 231 /* MetaProperty */; + return node.kind === 231 /* SyntaxKind.MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 232 /* SyntheticExpression */; + return node.kind === 232 /* SyntaxKind.SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 350 /* PartiallyEmittedExpression */; + return node.kind === 350 /* SyntaxKind.PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 351 /* CommaListExpression */; + return node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 233 /* TemplateSpan */; + return node.kind === 233 /* SyntaxKind.TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 234 /* SemicolonClassElement */; + return node.kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 235 /* Block */; + return node.kind === 235 /* SyntaxKind.Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 237 /* VariableStatement */; + return node.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 236 /* EmptyStatement */; + return node.kind === 236 /* SyntaxKind.EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 238 /* ExpressionStatement */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 239 /* IfStatement */; + return node.kind === 239 /* SyntaxKind.IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 240 /* DoStatement */; + return node.kind === 240 /* SyntaxKind.DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 241 /* WhileStatement */; + return node.kind === 241 /* SyntaxKind.WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 242 /* ForStatement */; + return node.kind === 242 /* SyntaxKind.ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 243 /* ForInStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 244 /* ForOfStatement */; + return node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 245 /* ContinueStatement */; + return node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 246 /* BreakStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 247 /* ReturnStatement */; + return node.kind === 247 /* SyntaxKind.ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 248 /* WithStatement */; + return node.kind === 248 /* SyntaxKind.WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 249 /* SwitchStatement */; + return node.kind === 249 /* SyntaxKind.SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 250 /* LabeledStatement */; + return node.kind === 250 /* SyntaxKind.LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 251 /* ThrowStatement */; + return node.kind === 251 /* SyntaxKind.ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 252 /* TryStatement */; + return node.kind === 252 /* SyntaxKind.TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 253 /* DebuggerStatement */; + return node.kind === 253 /* SyntaxKind.DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 255 /* VariableDeclarationList */; + return node.kind === 255 /* SyntaxKind.VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 256 /* FunctionDeclaration */; + return node.kind === 256 /* SyntaxKind.FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 257 /* ClassDeclaration */; + return node.kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 258 /* InterfaceDeclaration */; + return node.kind === 258 /* SyntaxKind.InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 259 /* TypeAliasDeclaration */; + return node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 260 /* EnumDeclaration */; + return node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 262 /* ModuleBlock */; + return node.kind === 262 /* SyntaxKind.ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 263 /* CaseBlock */; + return node.kind === 263 /* SyntaxKind.CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 264 /* NamespaceExportDeclaration */; + return node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 266 /* ImportDeclaration */; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 267 /* ImportClause */; + return node.kind === 267 /* SyntaxKind.ImportClause */; } ts.isImportClause = isImportClause; function isImportTypeAssertionContainer(node) { - return node.kind === 295 /* ImportTypeAssertionContainer */; + return node.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */; } ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer; function isAssertClause(node) { - return node.kind === 293 /* AssertClause */; + return node.kind === 293 /* SyntaxKind.AssertClause */; } ts.isAssertClause = isAssertClause; function isAssertEntry(node) { - return node.kind === 294 /* AssertEntry */; + return node.kind === 294 /* SyntaxKind.AssertEntry */; } ts.isAssertEntry = isAssertEntry; function isNamespaceImport(node) { - return node.kind === 268 /* NamespaceImport */; + return node.kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 274 /* NamespaceExport */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 269 /* NamedImports */; + return node.kind === 269 /* SyntaxKind.NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 270 /* ImportSpecifier */; + return node.kind === 270 /* SyntaxKind.ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 271 /* ExportAssignment */; + return node.kind === 271 /* SyntaxKind.ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 272 /* ExportDeclaration */; + return node.kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 273 /* NamedExports */; + return node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 275 /* ExportSpecifier */; + return node.kind === 275 /* SyntaxKind.ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 276 /* MissingDeclaration */; + return node.kind === 276 /* SyntaxKind.MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 349 /* NotEmittedStatement */; + return node.kind === 349 /* SyntaxKind.NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 354 /* SyntheticReferenceExpression */; + return node.kind === 354 /* SyntaxKind.SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 352 /* MergeDeclarationMarker */; + return node.kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 353 /* EndOfDeclarationMarker */; + return node.kind === 353 /* SyntaxKind.EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 277 /* ExternalModuleReference */; + return node.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 278 /* JsxElement */; + return node.kind === 278 /* SyntaxKind.JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 279 /* JsxSelfClosingElement */; + return node.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 280 /* JsxOpeningElement */; + return node.kind === 280 /* SyntaxKind.JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 281 /* JsxClosingElement */; + return node.kind === 281 /* SyntaxKind.JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 282 /* JsxFragment */; + return node.kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 283 /* JsxOpeningFragment */; + return node.kind === 283 /* SyntaxKind.JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 284 /* JsxClosingFragment */; + return node.kind === 284 /* SyntaxKind.JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 285 /* JsxAttribute */; + return node.kind === 285 /* SyntaxKind.JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 286 /* JsxAttributes */; + return node.kind === 286 /* SyntaxKind.JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 287 /* JsxSpreadAttribute */; + return node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 288 /* JsxExpression */; + return node.kind === 288 /* SyntaxKind.JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 289 /* CaseClause */; + return node.kind === 289 /* SyntaxKind.CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 290 /* DefaultClause */; + return node.kind === 290 /* SyntaxKind.DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 291 /* HeritageClause */; + return node.kind === 291 /* SyntaxKind.HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 292 /* CatchClause */; + return node.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 296 /* PropertyAssignment */; + return node.kind === 296 /* SyntaxKind.PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */; + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 298 /* SpreadAssignment */; + return node.kind === 298 /* SyntaxKind.SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 301 /* UnparsedPrepend */; + return node.kind === 301 /* SyntaxKind.UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -29468,176 +29592,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 305 /* SourceFile */; + return node.kind === 305 /* SyntaxKind.SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 306 /* Bundle */; + return node.kind === 306 /* SyntaxKind.Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 307 /* UnparsedSource */; + return node.kind === 307 /* SyntaxKind.UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 309 /* JSDocTypeExpression */; + return node.kind === 309 /* SyntaxKind.JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 310 /* JSDocNameReference */; + return node.kind === 310 /* SyntaxKind.JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; function isJSDocMemberName(node) { - return node.kind === 311 /* JSDocMemberName */; + return node.kind === 311 /* SyntaxKind.JSDocMemberName */; } ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 324 /* JSDocLink */; + return node.kind === 324 /* SyntaxKind.JSDocLink */; } ts.isJSDocLink = isJSDocLink; function isJSDocLinkCode(node) { - return node.kind === 325 /* JSDocLinkCode */; + return node.kind === 325 /* SyntaxKind.JSDocLinkCode */; } ts.isJSDocLinkCode = isJSDocLinkCode; function isJSDocLinkPlain(node) { - return node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 312 /* JSDocAllType */; + return node.kind === 312 /* SyntaxKind.JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 313 /* JSDocUnknownType */; + return node.kind === 313 /* SyntaxKind.JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 314 /* JSDocNullableType */; + return node.kind === 314 /* SyntaxKind.JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 315 /* JSDocNonNullableType */; + return node.kind === 315 /* SyntaxKind.JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 316 /* JSDocOptionalType */; + return node.kind === 316 /* SyntaxKind.JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 317 /* JSDocFunctionType */; + return node.kind === 317 /* SyntaxKind.JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 318 /* JSDocVariadicType */; + return node.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 319 /* JSDocNamepathType */; + return node.kind === 319 /* SyntaxKind.JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 320 /* JSDoc */; + return node.kind === 320 /* SyntaxKind.JSDoc */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 322 /* JSDocTypeLiteral */; + return node.kind === 322 /* SyntaxKind.JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 323 /* JSDocSignature */; + return node.kind === 323 /* SyntaxKind.JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 328 /* JSDocAugmentsTag */; + return node.kind === 328 /* SyntaxKind.JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 330 /* JSDocAuthorTag */; + return node.kind === 330 /* SyntaxKind.JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 332 /* JSDocClassTag */; + return node.kind === 332 /* SyntaxKind.JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 338 /* JSDocCallbackTag */; + return node.kind === 338 /* SyntaxKind.JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 333 /* JSDocPublicTag */; + return node.kind === 333 /* SyntaxKind.JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 334 /* JSDocPrivateTag */; + return node.kind === 334 /* SyntaxKind.JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 335 /* JSDocProtectedTag */; + return node.kind === 335 /* SyntaxKind.JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 336 /* JSDocReadonlyTag */; + return node.kind === 336 /* SyntaxKind.JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 337 /* JSDocOverrideTag */; + return node.kind === 337 /* SyntaxKind.JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 331 /* JSDocDeprecatedTag */; + return node.kind === 331 /* SyntaxKind.JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 346 /* JSDocSeeTag */; + return node.kind === 346 /* SyntaxKind.JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 339 /* JSDocEnumTag */; + return node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 340 /* JSDocParameterTag */; + return node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 341 /* JSDocReturnTag */; + return node.kind === 341 /* SyntaxKind.JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 342 /* JSDocThisTag */; + return node.kind === 342 /* SyntaxKind.JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 343 /* JSDocTypeTag */; + return node.kind === 343 /* SyntaxKind.JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 344 /* JSDocTemplateTag */; + return node.kind === 344 /* SyntaxKind.JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 345 /* JSDocTypedefTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 327 /* JSDocTag */; + return node.kind === 327 /* SyntaxKind.JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 347 /* JSDocPropertyTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 329 /* JSDocImplementsTag */; + return node.kind === 329 /* SyntaxKind.JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 348 /* SyntaxList */; + return n.kind === 348 /* SyntaxKind.SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -29657,7 +29781,7 @@ var ts; var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); - ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; + ts.getOrCreateEmitNode(expression).flags |= 64 /* EmitFlags.NoNestedSourceMaps */; return expression; } } @@ -29836,14 +29960,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -29882,7 +30006,7 @@ var ts; */ function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) { var operator = node.operator; - ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); + ts.Debug.assert(operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); var temp = factory.createTempVariable(recordTempVariable); expression = factory.createAssignment(temp, expression); ts.setTextRange(expression, node.operand); @@ -29907,14 +30031,14 @@ var ts; * Gets whether an identifier should only be referred to by its internal name. */ function isInternalName(node) { - return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + return (ts.getEmitFlags(node) & 32768 /* EmitFlags.InternalName */) !== 0; } ts.isInternalName = isInternalName; /** * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* EmitFlags.LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -29922,7 +30046,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* EmitFlags.ExportName */) !== 0; } ts.isExportName = isExportName; function isUseStrictPrologue(node) { @@ -29951,8 +30075,8 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 351 /* CommaListExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || + node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isJSDocTypeAssertion(node) { @@ -29968,26 +30092,26 @@ var ts; } ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType; function isOuterExpression(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } switch (node.kind) { - case 212 /* ParenthesizedExpression */: - if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { + case 212 /* SyntaxKind.ParenthesizedExpression */: + if (kinds & 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { return false; } - return (kinds & 1 /* Parentheses */) !== 0; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - return (kinds & 2 /* TypeAssertions */) !== 0; - case 230 /* NonNullExpression */: - return (kinds & 4 /* NonNullAssertions */) !== 0; - case 350 /* PartiallyEmittedExpression */: - return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; + return (kinds & 1 /* OuterExpressionKinds.Parentheses */) !== 0; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + return (kinds & 2 /* OuterExpressionKinds.TypeAssertions */) !== 0; + case 230 /* SyntaxKind.NonNullExpression */: + return (kinds & 4 /* OuterExpressionKinds.NonNullAssertions */) !== 0; + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + return (kinds & 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */) !== 0; } return false; } ts.isOuterExpression = isOuterExpression; function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } while (isOuterExpression(node, kinds)) { node = node.expression; } @@ -29995,7 +30119,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - return skipOuterExpressions(node, 6 /* Assertions */); + return skipOuterExpressions(node, 6 /* OuterExpressionKinds.Assertions */); } ts.skipAssertions = skipAssertions; function startOnNewLine(node) { @@ -30056,7 +30180,7 @@ var ts; var externalHelpersImportDeclaration = nodeFactory.createImportDeclaration( /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), /*assertClause*/ undefined); - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* EmitFlags.NeverApplyImportHelper */); return externalHelpersImportDeclaration; } } @@ -30101,10 +30225,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 266 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 266 /* SyntaxKind.ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 272 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -30223,7 +30347,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -30235,11 +30359,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -30271,12 +30395,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 225 /* SpreadElement */: - case 298 /* SpreadAssignment */: + case 225 /* SyntaxKind.SpreadElement */: + case 298 /* SyntaxKind.SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -30294,7 +30418,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -30309,7 +30433,7 @@ var ts; : propertyName; } break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -30324,7 +30448,7 @@ var ts; : propertyName; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -30339,21 +30463,21 @@ var ts; ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */; } /** * Gets the elements of a BindingOrAssignmentPattern */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -30374,86 +30498,86 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveIllegalType(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 173 /* SetAccessor */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.canHaveIllegalType = canHaveIllegalType; function canHaveIllegalTypeParameters(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.canHaveIllegalTypeParameters = canHaveIllegalTypeParameters; function canHaveDecorators(node) { var kind = node.kind; - return kind === 164 /* Parameter */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 226 /* ClassExpression */ - || kind === 257 /* ClassDeclaration */; + return kind === 164 /* SyntaxKind.Parameter */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.canHaveDecorators = canHaveDecorators; function canHaveIllegalDecorators(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 237 /* VariableStatement */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.canHaveIllegalDecorators = canHaveIllegalDecorators; function canHaveModifiers(node) { var kind = node.kind; - return kind === 163 /* TypeParameter */ - || kind === 164 /* Parameter */ - || kind === 166 /* PropertySignature */ - || kind === 167 /* PropertyDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 169 /* MethodDeclaration */ - || kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 180 /* ConstructorType */ - || kind === 213 /* FunctionExpression */ - || kind === 214 /* ArrowFunction */ - || kind === 226 /* ClassExpression */ - || kind === 237 /* VariableStatement */ - || kind === 256 /* FunctionDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 272 /* ExportDeclaration */; + return kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 180 /* SyntaxKind.ConstructorType */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; function canHaveIllegalModifiers(node) { var kind = node.kind; - return kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 179 /* FunctionType */ - || kind === 276 /* MissingDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 179 /* SyntaxKind.FunctionType */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.canHaveIllegalModifiers = canHaveIllegalModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -30464,68 +30588,68 @@ var ts; ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); function isLiteralTypeLikeExpression(node) { var kind = node.kind; - return kind === 104 /* NullKeyword */ - || kind === 110 /* TrueKeyword */ - || kind === 95 /* FalseKeyword */ + return kind === 104 /* SyntaxKind.NullKeyword */ + || kind === 110 /* SyntaxKind.TrueKeyword */ + || kind === 95 /* SyntaxKind.FalseKeyword */ || ts.isLiteralExpression(node) || ts.isPrefixUnaryExpression(node); } ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; function isExponentiationOperator(kind) { - return kind === 42 /* AsteriskAsteriskToken */; + return kind === 42 /* SyntaxKind.AsteriskAsteriskToken */; } function isMultiplicativeOperator(kind) { - return kind === 41 /* AsteriskToken */ - || kind === 43 /* SlashToken */ - || kind === 44 /* PercentToken */; + return kind === 41 /* SyntaxKind.AsteriskToken */ + || kind === 43 /* SyntaxKind.SlashToken */ + || kind === 44 /* SyntaxKind.PercentToken */; } function isMultiplicativeOperatorOrHigher(kind) { return isExponentiationOperator(kind) || isMultiplicativeOperator(kind); } function isAdditiveOperator(kind) { - return kind === 39 /* PlusToken */ - || kind === 40 /* MinusToken */; + return kind === 39 /* SyntaxKind.PlusToken */ + || kind === 40 /* SyntaxKind.MinusToken */; } function isAdditiveOperatorOrHigher(kind) { return isAdditiveOperator(kind) || isMultiplicativeOperatorOrHigher(kind); } function isShiftOperator(kind) { - return kind === 47 /* LessThanLessThanToken */ - || kind === 48 /* GreaterThanGreaterThanToken */ - || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */; + return kind === 47 /* SyntaxKind.LessThanLessThanToken */ + || kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ + || kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } function isShiftOperatorOrHigher(kind) { return isShiftOperator(kind) || isAdditiveOperatorOrHigher(kind); } function isRelationalOperator(kind) { - return kind === 29 /* LessThanToken */ - || kind === 32 /* LessThanEqualsToken */ - || kind === 31 /* GreaterThanToken */ - || kind === 33 /* GreaterThanEqualsToken */ - || kind === 102 /* InstanceOfKeyword */ - || kind === 101 /* InKeyword */; + return kind === 29 /* SyntaxKind.LessThanToken */ + || kind === 32 /* SyntaxKind.LessThanEqualsToken */ + || kind === 31 /* SyntaxKind.GreaterThanToken */ + || kind === 33 /* SyntaxKind.GreaterThanEqualsToken */ + || kind === 102 /* SyntaxKind.InstanceOfKeyword */ + || kind === 101 /* SyntaxKind.InKeyword */; } function isRelationalOperatorOrHigher(kind) { return isRelationalOperator(kind) || isShiftOperatorOrHigher(kind); } function isEqualityOperator(kind) { - return kind === 34 /* EqualsEqualsToken */ - || kind === 36 /* EqualsEqualsEqualsToken */ - || kind === 35 /* ExclamationEqualsToken */ - || kind === 37 /* ExclamationEqualsEqualsToken */; + return kind === 34 /* SyntaxKind.EqualsEqualsToken */ + || kind === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ + || kind === 35 /* SyntaxKind.ExclamationEqualsToken */ + || kind === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } function isEqualityOperatorOrHigher(kind) { return isEqualityOperator(kind) || isRelationalOperatorOrHigher(kind); } function isBitwiseOperator(kind) { - return kind === 50 /* AmpersandToken */ - || kind === 51 /* BarToken */ - || kind === 52 /* CaretToken */; + return kind === 50 /* SyntaxKind.AmpersandToken */ + || kind === 51 /* SyntaxKind.BarToken */ + || kind === 52 /* SyntaxKind.CaretToken */; } function isBitwiseOperatorOrHigher(kind) { return isBitwiseOperator(kind) @@ -30533,21 +30657,21 @@ var ts; } // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. function isLogicalOperator(kind) { - return kind === 55 /* AmpersandAmpersandToken */ - || kind === 56 /* BarBarToken */; + return kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || kind === 56 /* SyntaxKind.BarBarToken */; } function isLogicalOperatorOrHigher(kind) { return isLogicalOperator(kind) || isBitwiseOperatorOrHigher(kind); } function isAssignmentOperatorOrHigher(kind) { - return kind === 60 /* QuestionQuestionToken */ + return kind === 60 /* SyntaxKind.QuestionQuestionToken */ || isLogicalOperatorOrHigher(kind) || ts.isAssignmentOperator(kind); } function isBinaryOperator(kind) { return isAssignmentOperatorOrHigher(kind) - || kind === 27 /* CommaToken */; + || kind === 27 /* SyntaxKind.CommaToken */; } function isBinaryOperatorToken(node) { return isBinaryOperator(node.kind); @@ -30680,7 +30804,7 @@ var ts; return stackIndex; } function checkCircularity(stackIndex, nodeStack, node) { - if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + if (ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */)) { while (stackIndex >= 0) { ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); stackIndex--; @@ -30769,7 +30893,7 @@ var ts; createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); }, }; /* @internal */ - ts.parseNodeFactory = ts.createNodeFactory(1 /* NoParenthesizerRules */, ts.parseBaseNodeFactory); + ts.parseNodeFactory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.parseBaseNodeFactory); function visitNode(cbNode, node) { return node && cbNode(node); } @@ -30789,9 +30913,9 @@ var ts; } /*@internal*/ function isJSDocLikeText(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 42 /* asterisk */ && - text.charCodeAt(start + 3) !== 47 /* slash */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 3) !== 47 /* CharacterCodes.slash */; } ts.isJSDocLikeText = isJSDocLikeText; /*@internal*/ @@ -30803,14 +30927,14 @@ var ts; } ts.isFileProbablyExternalModule = isFileProbablyExternalModule; function isAnExternalModuleIndicatorNode(node) { - return ts.canHaveModifiers(node) && hasModifierOfKind(node, 93 /* ExportKeyword */) + return ts.canHaveModifiers(node) && hasModifierOfKind(node, 93 /* SyntaxKind.ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) || ts.isExportDeclaration(node) ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */ ? walkTreeForImportMeta(sourceFile) : undefined; } @@ -30822,7 +30946,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && node.name.escapedText === "meta"; } /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes @@ -30838,20 +30962,20 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 160 /* LastToken */) { + if (!node || node.kind <= 160 /* SyntaxKind.LastToken */) { return; } switch (node.kind) { - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30859,67 +30983,67 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitNode(cbNode, node.expression); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.initializer); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || @@ -30929,14 +31053,14 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30944,21 +31068,21 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -30967,7 +31091,7 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || @@ -30975,357 +31099,357 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return visitNode(cbNode, node.exprName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return visitNode(cbNode, node.elementType); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return visitNode(cbNode, node.typeParameter); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.assertions) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: return visitNode(cbNode, node.assertClause); - case 191 /* ParenthesizedType */: - case 193 /* TypeOperator */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 193 /* SyntaxKind.TypeOperator */: return visitNode(cbNode, node.type); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNodes(cbNode, cbNodes, node.members); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return visitNode(cbNode, node.literal); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitNode(cbNode, node.expression); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return visitNode(cbNode, node.expression); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitNode(cbNode, node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitNode(cbNode, node.expression); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return visitNode(cbNode, node.expression); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitNode(cbNode, node.name); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitNode(cbNode, node.expression); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitNode(cbNode, node.expression); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitNode(cbNode, node.label); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitNode(cbNode, node.expression); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return visitNode(cbNode, node.expression); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return visitNode(cbNode, node.expression); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return visitNodes(cbNode, cbNodes, node.elements); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.value); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNode(cbNode, node.name); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return visitNode(cbNode, node.name); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return visitNode(cbNode, node.name); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 185 /* OptionalType */: - case 186 /* RestType */: - case 309 /* JSDocTypeExpression */: - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 316 /* JSDocOptionalType */: - case 318 /* JSDocVariadicType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return visitNode(cbNode, node.type); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return visitNode(cbNode, node.name); - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || @@ -31334,64 +31458,64 @@ var ts; : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 330 /* JSDocAuthorTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 309 /* JSDocTypeExpression */ + node.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: - case 331 /* JSDocDeprecatedTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -31440,7 +31564,7 @@ var ts; continue; return res; } - if (current.kind >= 161 /* FirstNode */) { + if (current.kind >= 161 /* SyntaxKind.FirstNode */) { // add children in reverse order to the queue, so popping gives the first child for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { var child = _a[_i]; @@ -31465,13 +31589,13 @@ var ts; } function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat; - if (languageVersion === 100 /* JSON */) { - result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop); + if (languageVersion === 100 /* ScriptTarget.JSON */) { + result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* ScriptKind.JSON */, ts.noop); } else { var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) { @@ -31519,7 +31643,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -31547,8 +31671,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks // tslint:disable variable-name var NodeConstructor; @@ -31570,7 +31694,7 @@ var ts; createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)); }, createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); } }; - var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory); + var factory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */ | 2 /* NodeFactoryFlags.NoNodeConverters */ | 8 /* NodeFactoryFlags.NoOriginalNode */, baseNodeFactory); var fileName; var sourceFlags; var sourceText; @@ -31668,7 +31792,7 @@ var ts; var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); - if (scriptKind === 6 /* JSON */) { + if (scriptKind === 6 /* ScriptKind.JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); result_3.referencedFiles = ts.emptyArray; @@ -31687,25 +31811,25 @@ var ts; Parser.parseSourceFile = parseSourceFile; function parseIsolatedEntityName(content, languageVersion) { // Choice of `isDeclarationFile` should be arbitrary - initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* ScriptKind.JS */); // Prime the scanner. nextToken(); var entityName = parseEntityName(/*allowReservedWords*/ true); - var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + var isInvalid = token() === 1 /* SyntaxKind.EndOfFileToken */ && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; } Parser.parseIsolatedEntityName = parseIsolatedEntityName; function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { - if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; } + if (languageVersion === void 0) { languageVersion = 2 /* ScriptTarget.ES2015 */; } if (setParentNodes === void 0) { setParentNodes = false; } - initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* JSON */); + initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* ScriptKind.JSON */); sourceFlags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); var statements, endOfFileToken; - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { statements = createNodeArray([], pos, pos); endOfFileToken = parseTokenNode(); } @@ -31713,28 +31837,28 @@ var ts; // Loop and synthesize an ArrayLiteralExpression if there are more than // one top-level expressions to ensure all input text is consumed. var expressions = void 0; - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var expression_1 = void 0; switch (token()) { - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: expression_1 = parseArrayLiteralExpression(); break; - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: expression_1 = parseTokenNode(); break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + case 40 /* SyntaxKind.MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* SyntaxKind.NumericLiteral */ && nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parsePrefixUnaryExpression(); } else { expression_1 = parseObjectLiteralExpression(); } break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parseLiteralNode(); break; } @@ -31752,7 +31876,7 @@ var ts; } else { expressions = expression_1; - if (token() !== 1 /* EndOfFileToken */) { + if (token() !== 1 /* SyntaxKind.EndOfFileToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } } @@ -31761,10 +31885,10 @@ var ts; var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); - endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token); + endOfFileToken = parseExpectedToken(1 /* SyntaxKind.EndOfFileToken */, ts.Diagnostics.Unexpected_token); } // Set source file so that errors will be reported with this file name - var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); + var sourceFile = createSourceFile(fileName, 2 /* ScriptTarget.ES2015 */, 6 /* ScriptKind.JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); if (setParentNodes) { fixupParentReferences(sourceFile); } @@ -31801,15 +31925,15 @@ var ts; sourceFlags = 0; topLevel = true; switch (scriptKind) { - case 1 /* JS */: - case 2 /* JSX */: - contextFlags = 262144 /* JavaScriptFile */; + case 1 /* ScriptKind.JS */: + case 2 /* ScriptKind.JSX */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */; break; - case 6 /* JSON */: - contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */; + case 6 /* ScriptKind.JSON */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */ | 67108864 /* NodeFlags.JsonFile */; break; default: - contextFlags = 0 /* None */; + contextFlags = 0 /* NodeFlags.None */; break; } parseErrorBeforeNextFinishedNode = false; @@ -31841,13 +31965,13 @@ var ts; function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 16777216 /* Ambient */; + contextFlags |= 16777216 /* NodeFlags.Ambient */; } sourceFlags = contextFlags; // Prime the scanner. nextToken(); - var statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token() === 1 /* EndOfFileToken */); + var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement); + ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */); var endOfFileToken = addJSDocComment(parseTokenNode()); var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator); // A member of ReadonlyArray isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future @@ -31880,7 +32004,7 @@ var ts; node.jsDoc = jsDoc; if (hasDeprecatedTag) { hasDeprecatedTag = false; - node.flags |= 268435456 /* Deprecated */; + node.flags |= 268435456 /* NodeFlags.Deprecated */; } return node; } @@ -31908,12 +32032,12 @@ var ts; // reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones. speculationHelper(function () { var savedContextFlags = contextFlags; - contextFlags |= 32768 /* AwaitContext */; + contextFlags |= 32768 /* NodeFlags.AwaitContext */; scanner.setTextPos(nextStatement.pos); nextToken(); - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var startPos = scanner.getStartPos(); - var statement = parseListElement(0 /* SourceElements */, parseStatement); + var statement = parseListElement(0 /* ParsingContext.SourceElements */, parseStatement); statements.push(statement); if (startPos === scanner.getStartPos()) { nextToken(); @@ -31931,7 +32055,7 @@ var ts; } } contextFlags = savedContextFlags; - }, 2 /* Reparse */); + }, 2 /* SpeculationKind.Reparse */); // find the next statement containing an `await` start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1; }; @@ -31951,8 +32075,8 @@ var ts; syntaxCursor = savedSyntaxCursor; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { - return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */); + return !(node.flags & 32768 /* NodeFlags.AwaitContext */) + && !!(node.transformFlags & 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -31993,7 +32117,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setFields(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); setFields(sourceFile); } @@ -32020,16 +32144,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 4096 /* DisallowInContext */); + setContextFlag(val, 4096 /* NodeFlags.DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 8192 /* YieldContext */); + setContextFlag(val, 8192 /* NodeFlags.YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 16384 /* DecoratorContext */); + setContextFlag(val, 16384 /* NodeFlags.DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 32768 /* AwaitContext */); + setContextFlag(val, 32768 /* NodeFlags.AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -32070,52 +32194,52 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(4096 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(4096 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function allowConditionalTypesAnd(func) { - return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doOutsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function disallowConditionalTypesAnd(func) { - return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doInsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(8192 /* YieldContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(16384 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* NodeFlags.DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(32768 /* AwaitContext */, func); + return doInsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(32768 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(8192 /* YieldContext */); + return inContext(8192 /* NodeFlags.YieldContext */); } function inDisallowInContext() { - return inContext(4096 /* DisallowInContext */); + return inContext(4096 /* NodeFlags.DisallowInContext */); } function inDisallowConditionalTypesContext() { - return inContext(65536 /* DisallowConditionalTypesContext */); + return inContext(65536 /* NodeFlags.DisallowConditionalTypesContext */); } function inDecoratorContext() { - return inContext(16384 /* DecoratorContext */); + return inContext(16384 /* NodeFlags.DecoratorContext */); } function inAwaitContext() { - return inContext(32768 /* AwaitContext */); + return inContext(32768 /* NodeFlags.AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -32216,15 +32340,15 @@ var ts; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the // same. - var result = speculationKind !== 0 /* TryParse */ + var result = speculationKind !== 0 /* SpeculationKind.TryParse */ ? scanner.lookAhead(callback) : scanner.tryScan(callback); ts.Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. - if (!result || speculationKind !== 0 /* TryParse */) { + if (!result || speculationKind !== 0 /* SpeculationKind.TryParse */) { currentToken = saveToken; - if (speculationKind !== 2 /* Reparse */) { + if (speculationKind !== 2 /* SpeculationKind.Reparse */) { parseDiagnostics.length = saveParseDiagnosticsLength; } parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -32236,7 +32360,7 @@ var ts; * is returned from this function. */ function lookAhead(callback) { - return speculationHelper(callback, 1 /* Lookahead */); + return speculationHelper(callback, 1 /* SpeculationKind.Lookahead */); } /** Invokes the provided callback. If the callback returns something falsy, then it restores * the parser to the state it was in immediately prior to invoking the callback. If the @@ -32244,31 +32368,31 @@ var ts; * of invoking the callback is returned from this function. */ function tryParse(callback) { - return speculationHelper(callback, 0 /* TryParse */); + return speculationHelper(callback, 0 /* SpeculationKind.TryParse */); } function isBindingIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder. - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 125 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* SyntaxKind.YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -32306,7 +32430,7 @@ var ts; // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined; if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } var pos = ts.skipTrivia(sourceText, node.pos); @@ -32321,17 +32445,17 @@ var ts; // If a declared node failed to parse, it would have emitted a diagnostic already. return; case "interface": - parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "is": parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; case "module": case "namespace": - parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "type": - parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */); + parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* SyntaxKind.EqualsToken */); return; } // The user alternatively might have misspelled or forgotten to add a space after a common keyword. @@ -32341,7 +32465,7 @@ var ts; return; } // Unknown tokens are handled with their own errors in the scanner - if (token() === 0 /* Unknown */) { + if (token() === 0 /* SyntaxKind.Unknown */) { return; } // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. @@ -32366,24 +32490,24 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; } function parseSemicolonAfterPropertyName(name, type, initializer) { - if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 59 /* SyntaxKind.AtToken */ && !scanner.hasPrecedingLineBreak()) { parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); return; } - if (token() === 20 /* OpenParenToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); nextToken(); return; } if (type && !canParseSemicolon()) { if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); } else { parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer); @@ -32394,7 +32518,7 @@ var ts; return; } if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } parseErrorForMissingSemicolonAfter(name); @@ -32461,24 +32585,24 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 1 /* SyntaxKind.EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function tryParseSemicolon() { if (!canParseSemicolon()) { return false; } - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } function parseSemicolon() { - return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */); + return tryParseSemicolon() || parseExpected(26 /* SyntaxKind.SemicolonToken */); } function createNodeArray(elements, pos, end, hasTrailingComma) { var array = factory.createNodeArray(elements, hasTrailingComma); @@ -32495,7 +32619,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 131072 /* ThisNodeHasError */; + node.flags |= 131072 /* NodeFlags.ThisNodeHasError */; } return node; } @@ -32507,11 +32631,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* SyntaxKind.Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 276 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : + kind === 276 /* SyntaxKind.MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -32535,23 +32659,23 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(/*isIdentifier*/ true); } - if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) { + if (token() === 0 /* SyntaxKind.Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* SyntaxKind.Identifier */; })) { // Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser. return createIdentifier(/*isIdentifier*/ true); } identifierCount++; // Only for end of file because the error gets reported incorrectly on embedded script tags. - var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + var reportAtCurrentPosition = token() === 1 /* SyntaxKind.EndOfFileToken */; var isReservedWord = scanner.isReservedWord(); var msgArg = scanner.getTokenText(); var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* SyntaxKind.Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -32564,23 +32688,23 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */; } function isAssertionKey() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ || token() === 8 /* SyntaxKind.NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -32593,12 +32717,12 @@ var ts; // LiteralPropertyName // ComputedPropertyName[?Yield] var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. var expression = allowInAnd(parseExpression); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createComputedPropertyName(expression), pos); } function internPrivateIdentifier(text) { @@ -32626,23 +32750,23 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 92 /* EnumKeyword */; - case 93 /* ExportKeyword */: + return nextToken() === 92 /* SyntaxKind.EnumKeyword */; + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); - if (token() === 88 /* DefaultKeyword */) { + if (token() === 88 /* SyntaxKind.DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 152 /* TypeKeyword */) { + if (token() === 152 /* SyntaxKind.TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 124 /* StaticKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -32650,9 +32774,9 @@ var ts; } } function canFollowExportModifier() { - return token() !== 41 /* AsteriskToken */ - && token() !== 127 /* AsKeyword */ - && token() !== 18 /* OpenBraceToken */ + return token() !== 41 /* SyntaxKind.AsteriskToken */ + && token() !== 127 /* SyntaxKind.AsKeyword */ + && token() !== 18 /* SyntaxKind.OpenBraceToken */ && canFollowModifier(); } function nextTokenCanFollowExportModifier() { @@ -32663,18 +32787,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 22 /* OpenBracketToken */ - || token() === 18 /* OpenBraceToken */ - || token() === 41 /* AsteriskToken */ - || token() === 25 /* DotDotDotToken */ + return token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 41 /* SyntaxKind.AsteriskToken */ + || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || - token() === 118 /* InterfaceKeyword */ || - (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* SyntaxKind.ClassKeyword */ || token() === 98 /* SyntaxKind.FunctionKeyword */ || + token() === 118 /* SyntaxKind.InterfaceKeyword */ || + (token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -32683,50 +32807,50 @@ var ts; return true; } switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 2 /* SwitchClauses */: - return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 4 /* TypeMembers */: + return !(token() === 26 /* SyntaxKind.SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + case 2 /* ParsingContext.SwitchClauses */: + return token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 4 /* ParsingContext.TypeMembers */: return lookAhead(isTypeMemberStart); - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); - case 6 /* EnumMembers */: + return lookAhead(isClassMemberStart) || (token() === 26 /* SyntaxKind.SemicolonToken */ && !inErrorRecovery); + case 6 /* ParsingContext.EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); - case 12 /* ObjectLiteralMembers */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || isLiteralPropertyName(); + case 12 /* ParsingContext.ObjectLiteralMembers */: switch (token()) { - case 22 /* OpenBracketToken */: - case 41 /* AsteriskToken */: - case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* SyntaxKind.OpenBracketToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 24 /* SyntaxKind.DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; default: return isLiteralPropertyName(); } - case 18 /* RestProperties */: + case 18 /* ParsingContext.RestProperties */: return isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); - case 24 /* AssertEntries */: + case 9 /* ParsingContext.ObjectBindingElements */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); + case 24 /* ParsingContext.AssertEntries */: return isAssertionKey(); - case 7 /* HeritageClauseElement */: + case 7 /* ParsingContext.HeritageClauseElement */: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -32738,42 +32862,42 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 19 /* TypeParameters */: - return token() === 101 /* InKeyword */ || isIdentifier(); - case 15 /* ArrayLiteralMembers */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); + case 19 /* ParsingContext.TypeParameters */: + return token() === 101 /* SyntaxKind.InKeyword */ || isIdentifier(); + case 15 /* ParsingContext.ArrayLiteralMembers */: switch (token()) { - case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 27 /* SyntaxKind.CommaToken */: + case 24 /* SyntaxKind.DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) return true; } // falls through - case 11 /* ArgumentExpressions */: - return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: + case 11 /* ParsingContext.ArgumentExpressions */: + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isStartOfExpression(); + case 16 /* ParsingContext.Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); - case 17 /* JSDocParameters */: + case 17 /* ParsingContext.JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); - case 20 /* TypeArguments */: - case 21 /* TupleElementTypes */: - return token() === 27 /* CommaToken */ || isStartOfType(); - case 22 /* HeritageClauses */: + case 20 /* ParsingContext.TypeArguments */: + case 21 /* ParsingContext.TupleElementTypes */: + return token() === 27 /* SyntaxKind.CommaToken */ || isStartOfType(); + case 22 /* ParsingContext.HeritageClauses */: return isHeritageClause(); - case 23 /* ImportOrExportSpecifiers */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; - case 14 /* JsxChildren */: + case 13 /* ParsingContext.JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* SyntaxKind.OpenBraceToken */; + case 14 /* ParsingContext.JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 18 /* OpenBraceToken */); - if (nextToken() === 19 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* SyntaxKind.OpenBraceToken */); + if (nextToken() === 19 /* SyntaxKind.CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -32782,7 +32906,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; + return next === 27 /* SyntaxKind.CommaToken */ || next === 18 /* SyntaxKind.OpenBraceToken */ || next === 94 /* SyntaxKind.ExtendsKeyword */ || next === 117 /* SyntaxKind.ImplementsKeyword */; } return true; } @@ -32799,8 +32923,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 117 /* ImplementsKeyword */ || - token() === 94 /* ExtendsKeyword */) { + if (token() === 117 /* SyntaxKind.ImplementsKeyword */ || + token() === 94 /* SyntaxKind.ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -32815,51 +32939,51 @@ var ts; } // True if positioned at a list terminator function isListTerminator(kind) { - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { // Being at the end of the file ends all lists. return true; } switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 23 /* ImportOrExportSpecifiers */: - case 24 /* AssertEntries */: - return token() === 19 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: + case 2 /* ParsingContext.SwitchClauses */: + case 4 /* ParsingContext.TypeMembers */: + case 5 /* ParsingContext.ClassMembers */: + case 6 /* ParsingContext.EnumMembers */: + case 12 /* ParsingContext.ObjectLiteralMembers */: + case 9 /* ParsingContext.ObjectBindingElements */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: + case 24 /* ParsingContext.AssertEntries */: + return token() === 19 /* SyntaxKind.CloseBraceToken */; + case 3 /* ParsingContext.SwitchClauseStatements */: + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 7 /* ParsingContext.HeritageClauseElement */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 8 /* ParsingContext.VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 19 /* TypeParameters */: + case 19 /* ParsingContext.TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 11 /* ParsingContext.ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 21 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token() === 23 /* CloseBracketToken */; - case 17 /* JSDocParameters */: - case 16 /* Parameters */: - case 18 /* RestProperties */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 26 /* SyntaxKind.SemicolonToken */; + case 15 /* ParsingContext.ArrayLiteralMembers */: + case 21 /* ParsingContext.TupleElementTypes */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 23 /* SyntaxKind.CloseBracketToken */; + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: + case 18 /* ParsingContext.RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 20 /* TypeArguments */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + case 20 /* ParsingContext.TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 27 /* CommaToken */; - case 22 /* HeritageClauses */: - return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; - case 14 /* JsxChildren */: - return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() !== 27 /* SyntaxKind.CommaToken */; + case 22 /* ParsingContext.HeritageClauses */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 19 /* SyntaxKind.CloseBraceToken */; + case 13 /* ParsingContext.JsxAttributes */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 43 /* SyntaxKind.SlashToken */; + case 14 /* ParsingContext.JsxChildren */: + return token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -32879,7 +33003,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -32887,7 +33011,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 25 /* ParsingContext.Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -32921,7 +33045,7 @@ var ts; } return parseElement(); } - function currentNode(parsingContext) { + function currentNode(parsingContext, pos) { // If we don't have a cursor or the parsing context isn't reusable, there's nothing to reuse. // // If there is an outstanding parse error that we've encountered, but not attached to @@ -32934,7 +33058,7 @@ var ts; if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) { return undefined; } - var node = syntaxCursor.currentNode(scanner.getStartPos()); + var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos()); // Can't reuse a missing node. // Can't reuse a node that intersected the change range. // Can't reuse a node that contains a parse error. This is necessary so that we @@ -32953,7 +33077,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 50720768 /* ContextFlags */; + var nodeContextFlags = node.flags & 50720768 /* NodeFlags.ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -32976,38 +33100,38 @@ var ts; } function isReusableParsingContext(parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: - case 2 /* SwitchClauses */: - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - case 6 /* EnumMembers */: - case 4 /* TypeMembers */: - case 8 /* VariableDeclarations */: - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 5 /* ParsingContext.ClassMembers */: + case 2 /* ParsingContext.SwitchClauses */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: + case 6 /* ParsingContext.EnumMembers */: + case 4 /* ParsingContext.TypeMembers */: + case 8 /* ParsingContext.VariableDeclarations */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return true; } return false; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: return isReusableClassMember(node); - case 2 /* SwitchClauses */: + case 2 /* ParsingContext.SwitchClauses */: return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: return isReusableStatement(node); - case 6 /* EnumMembers */: + case 6 /* ParsingContext.EnumMembers */: return isReusableEnumMember(node); - case 4 /* TypeMembers */: + case 4 /* ParsingContext.TypeMembers */: return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isReusableVariableDeclaration(node); - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative @@ -33054,20 +33178,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 171 /* Constructor */: - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 234 /* SemicolonClassElement */: + case 171 /* SyntaxKind.Constructor */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 234 /* SyntaxKind.SemicolonClassElement */: return true; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ && + methodDeclaration.name.originalKeywordKind === 134 /* SyntaxKind.ConstructorKeyword */; return !nameIsConstructor; } } @@ -33076,8 +33200,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return true; } } @@ -33086,58 +33210,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 237 /* VariableStatement */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 238 /* ExpressionStatement */: - case 251 /* ThrowStatement */: - case 247 /* ReturnStatement */: - case 249 /* SwitchStatement */: - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 236 /* EmptyStatement */: - case 252 /* TryStatement */: - case 250 /* LabeledStatement */: - case 240 /* DoStatement */: - case 253 /* DebuggerStatement */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 166 /* PropertySignature */: - case 174 /* CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 174 /* SyntaxKind.CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 254 /* VariableDeclaration */) { + if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -33158,7 +33282,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 164 /* Parameter */) { + if (node.kind !== 164 /* SyntaxKind.Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -33176,40 +33300,42 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return token() === 88 /* DefaultKeyword */ - ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */)) + case 0 /* ParsingContext.SourceElements */: + return token() === 88 /* SyntaxKind.DefaultKeyword */ + ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* SyntaxKind.ExportKeyword */)) : parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); - case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); - case 18 /* RestProperties */: // fallthrough - case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); - case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); - case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); - case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 2 /* ParsingContext.SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); + case 3 /* ParsingContext.SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); + case 18 /* ParsingContext.RestProperties */: // fallthrough + case 4 /* ParsingContext.TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); + case 5 /* ParsingContext.ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case 6 /* ParsingContext.EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); + case 7 /* ParsingContext.HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); + case 8 /* ParsingContext.VariableDeclarations */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected); - case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); - case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); - case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); - case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); - case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); - case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 16 /* Parameters */: + case 9 /* ParsingContext.ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); + case 10 /* ParsingContext.ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); + case 11 /* ParsingContext.ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); + case 12 /* ParsingContext.ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); + case 15 /* ParsingContext.ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); + case 17 /* ParsingContext.JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* ParsingContext.Parameters */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); - case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); - case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); - case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); - case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);` + case 19 /* ParsingContext.TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); + case 20 /* ParsingContext.TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); + case 21 /* ParsingContext.TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); + case 22 /* ParsingContext.HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 13 /* ParsingContext.JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 14 /* ParsingContext.JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 24 /* ParsingContext.AssertEntries */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); // AssertionKey. + case 25 /* ParsingContext.Count */: return ts.Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker. + default: ts.Debug.assertNever(context); } } function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { @@ -33228,7 +33354,7 @@ var ts; } list.push(result); commaStart = scanner.getTokenPos(); - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -33238,13 +33364,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); + parseExpected(27 /* SyntaxKind.CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SyntaxKind.SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -33273,7 +33399,7 @@ var ts; return createNodeArray(list, listPos, /*end*/ undefined, commaStart >= 0); } function getExpectedCommaDiagnostic(kind) { - return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + return kind === 6 /* ParsingContext.EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; } function createMissingList() { var list = createNodeArray([], getNodePos()); @@ -33295,8 +33421,8 @@ var ts; var pos = getNodePos(); var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = getNodePos(); - while (parseOptional(24 /* DotToken */)) { - if (token() === 29 /* LessThanToken */) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -33335,12 +33461,12 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -33351,7 +33477,7 @@ var ts; do { node = parseTemplateSpan(isTaggedTemplate); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateExpression(isTaggedTemplate) { @@ -33369,7 +33495,7 @@ var ts; do { node = parseTemplateTypeSpan(); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateTypeSpan() { @@ -33377,13 +33503,13 @@ var ts; return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos); } function parseLiteralOfTemplateSpan(isTaggedTemplate) { - if (token() === 19 /* CloseBraceToken */) { + if (token() === 19 /* SyntaxKind.CloseBraceToken */) { reScanTemplateToken(isTaggedTemplate); return parseTemplateMiddleOrTemplateTail(); } else { // TODO(rbuckton): Do we need to call `parseExpectedToken` or can we just call `createMissingNode` directly? - return parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); + return parseExpectedToken(17 /* SyntaxKind.TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* SyntaxKind.CloseBraceToken */)); } } function parseTemplateSpan(isTaggedTemplate) { @@ -33398,30 +33524,30 @@ var ts; reScanTemplateHeadOrNoSubstitutionTemplate(); } var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* SyntaxKind.TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* SyntaxKind.TemplateMiddle */ || fragment.kind === 17 /* SyntaxKind.TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function getTemplateLiteralRawText(kind) { - var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var isLast = kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || kind === 17 /* SyntaxKind.TemplateTail */; var tokenText = scanner.getTokenText(); return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); } function parseLiteralLikeNode(kind) { var pos = getNodePos(); - var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : + var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TokenFlags.TemplateLiteralLikeFlags */) : // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal. But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) : ts.Debug.fail(); if (scanner.hasExtendedUnicodeEscape()) { @@ -33438,8 +33564,8 @@ var ts; return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { - return parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function parseTypeReference() { @@ -33449,14 +33575,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return ts.nodeIsMissing(node.typeName); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: { + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -33494,12 +33620,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 27 /* CommaToken */ || - token() === 19 /* CloseBraceToken */ || - token() === 21 /* CloseParenToken */ || - token() === 31 /* GreaterThanToken */ || - token() === 63 /* EqualsToken */ || - token() === 51 /* BarToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */ || + token() === 19 /* SyntaxKind.CloseBraceToken */ || + token() === 21 /* SyntaxKind.CloseParenToken */ || + token() === 31 /* SyntaxKind.GreaterThanToken */ || + token() === 63 /* SyntaxKind.EqualsToken */ || + token() === 51 /* SyntaxKind.BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } else { @@ -33511,8 +33637,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); if (lookAhead(nextTokenIsOpenParen)) { nextToken(); - var parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */ | 32 /* SignatureFlags.JSDoc */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc); } return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), /*typeArguments*/ undefined), pos); @@ -33520,9 +33646,9 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */ || token() === 103 /* SyntaxKind.NewKeyword */) { name = parseIdentifierName(); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); } return finishNode(factory.createParameterDeclaration( /*modifiers*/ undefined, @@ -33535,15 +33661,15 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(141 /* ModuleKeyword */)) { + if (parseOptional(141 /* SyntaxKind.ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { switch (token()) { - case 19 /* CloseBraceToken */: - case 1 /* EndOfFileToken */: - case 27 /* CommaToken */: - case 5 /* WhitespaceTrivia */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 1 /* SyntaxKind.EndOfFileToken */: + case 27 /* SyntaxKind.CommaToken */: + case 5 /* SyntaxKind.WhitespaceTrivia */: break terminate; default: nextTokenJSDoc(); @@ -33552,13 +33678,13 @@ var ts; scanner.setInJSDocType(false); return finishNode(moduleTag, pos); } - var hasDotDotDot = parseOptional(25 /* DotDotDotToken */); + var hasDotDotDot = parseOptional(25 /* SyntaxKind.DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -33566,7 +33692,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(112 /* TypeOfKeyword */); + parseExpected(112 /* SyntaxKind.TypeOfKeyword */); var entityName = parseEntityName(/*allowReservedWords*/ true); // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression. var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; @@ -33578,7 +33704,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -33597,21 +33723,21 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); } function parseTypeParameters() { - if (token() === 29 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (token() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function isStartOfParameter(isJSDocParameter) { - return token() === 25 /* DotDotDotToken */ || + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 59 /* AtToken */ || + token() === 59 /* SyntaxKind.AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseNameOfParameter(modifiers) { @@ -33635,7 +33761,7 @@ var ts; // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later // complaining about the use of the keywords. - return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */; + return isBindingIdentifier() || token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function parseParameter(inOuterAwaitContext) { return parseParameterWorker(inOuterAwaitContext); @@ -33650,8 +33776,8 @@ var ts; // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. - var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); - if (token() === 108 /* ThisKeyword */) { + var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators); + if (token() === 108 /* SyntaxKind.ThisKeyword */) { var node_1 = factory.createParameterDeclaration(decorators, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, parseTypeAnnotation(), @@ -33664,11 +33790,11 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var modifiers = combineDecoratorsAndModifiers(decorators, parseModifiers()); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); if (!allowAmbiguity && !isParameterNameStart()) { return undefined; } - var node = withJSDoc(finishNode(factory.createParameterDeclaration(modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createParameterDeclaration(modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* SyntaxKind.QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); topLevel = savedTopLevel; return node; } @@ -33678,16 +33804,16 @@ var ts; } } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 38 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* SyntaxKind.EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(58 /* ColonToken */)) { + else if (parseOptional(58 /* SyntaxKind.ColonToken */)) { return true; } - else if (isType && token() === 38 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */)); nextToken(); return true; } @@ -33709,11 +33835,11 @@ var ts; // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); - setYieldContext(!!(flags & 1 /* Yield */)); - setAwaitContext(!!(flags & 2 /* Await */)); - var parameters = flags & 32 /* JSDoc */ ? - parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) : - parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); + var parameters = flags & 32 /* SignatureFlags.JSDoc */ ? + parseDelimitedList(17 /* ParsingContext.JSDocParameters */, parseJSDocParameter) : + parseDelimitedList(16 /* ParsingContext.Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); return parameters; @@ -33732,17 +33858,17 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { return createMissingList(); } var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return parameters; } function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -33751,20 +33877,20 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 175 /* ConstructSignature */) { - parseExpected(103 /* NewKeyword */); + if (kind === 175 /* SyntaxKind.ConstructSignature */) { + parseExpected(103 /* SyntaxKind.NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 174 /* CallSignature */ + var node = kind === 174 /* SyntaxKind.CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); } function isIndexSignature() { - return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* SyntaxKind.OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -33784,7 +33910,7 @@ var ts; // [] // nextToken(); - if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -33803,21 +33929,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 57 /* QuestionToken */) { + if (token() !== 57 /* SyntaxKind.QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */; } function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) { - var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); + var parameters = parseBracketedList(16 /* ParsingContext.Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */); var type = parseTypeAnnotation(); parseTypeMemberSemicolon(); var node = factory.createIndexSignature(modifiers, parameters, type); @@ -33826,14 +33952,14 @@ var ts; } function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); var node; - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type); } else { @@ -33842,7 +33968,7 @@ var ts; // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === 63 /* EqualsToken */) + if (token() === 63 /* SyntaxKind.EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -33850,10 +33976,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 136 /* GetKeyword */ || - token() === 149 /* SetKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 136 /* SyntaxKind.GetKeyword */ || + token() === 149 /* SyntaxKind.SetKeyword */) { return true; } var idToken = false; @@ -33863,7 +33989,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -33874,30 +34000,30 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 57 /* QuestionToken */ || - token() === 58 /* ColonToken */ || - token() === 27 /* CommaToken */ || + return token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || + token() === 58 /* SyntaxKind.ColonToken */ || + token() === 27 /* SyntaxKind.CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(174 /* CallSignature */); + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { + return parseSignatureMember(174 /* SyntaxKind.CallSignature */); } - if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(175 /* ConstructSignature */); + if (token() === 103 /* SyntaxKind.NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(175 /* SyntaxKind.ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SyntaxKind.GetAccessor */, 4 /* SignatureFlags.Type */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SyntaxKind.SetAccessor */, 4 /* SignatureFlags.Type */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -33906,16 +34032,16 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; + return token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 24 /* DotToken */; + return nextToken() === 24 /* SyntaxKind.DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 20 /* OpenParenToken */: - case 29 /* LessThanToken */: - case 24 /* DotToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 24 /* SyntaxKind.DotToken */: return true; } return false; @@ -33926,9 +34052,9 @@ var ts; } function parseObjectTypeMembers() { var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -33937,51 +34063,51 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 145 /* ReadonlyKeyword */; + if (token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { + return nextToken() === 145 /* SyntaxKind.ReadonlyKeyword */; } - if (token() === 145 /* ReadonlyKeyword */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; + return token() === 22 /* SyntaxKind.OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* SyntaxKind.InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(101 /* InKeyword */); + parseExpected(101 /* SyntaxKind.InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos); } function parseMappedType() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var readonlyToken; - if (token() === 145 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 145 /* ReadonlyKeyword */) { - parseExpected(145 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + parseExpected(145 /* SyntaxKind.ReadonlyKeyword */); } } - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; - parseExpected(23 /* CloseBracketToken */); + var nameType = parseOptional(127 /* SyntaxKind.AsKeyword */) ? parseType() : undefined; + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var questionToken; - if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 57 /* SyntaxKind.QuestionToken */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { questionToken = parseTokenNode(); - if (questionToken.kind !== 57 /* QuestionToken */) { - parseExpected(57 /* QuestionToken */); + if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { + parseExpected(57 /* SyntaxKind.QuestionToken */); } } var type = parseTypeAnnotation(); parseSemicolon(); - var members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + var members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(25 /* DotDotDotToken */)) { + if (parseOptional(25 /* SyntaxKind.DotDotDotToken */)) { return finishNode(factory.createRestTypeNode(parseType()), pos); } var type = parseType(); @@ -33994,10 +34120,10 @@ var ts; return type; } function isNextTokenColonOrQuestionColon() { - return nextToken() === 58 /* ColonToken */ || (token() === 57 /* QuestionToken */ && nextToken() === 58 /* ColonToken */); + return nextToken() === 58 /* SyntaxKind.ColonToken */ || (token() === 57 /* SyntaxKind.QuestionToken */ && nextToken() === 58 /* SyntaxKind.ColonToken */); } function isTupleElementName() { - if (token() === 25 /* DotDotDotToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */) { return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon(); } return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon(); @@ -34006,10 +34132,10 @@ var ts; if (lookAhead(isTupleElementName)) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); - parseExpected(58 /* ColonToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var type = parseTupleElementType(); var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -34018,21 +34144,21 @@ var ts; } function parseTupleType() { var pos = getNodePos(); - return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */)), pos); + return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* ParsingContext.TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */)), pos); } function parseParenthesizedType() { var pos = getNodePos(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createParenthesizedType(type), pos); } function parseModifiersForConstructorType() { var modifiers; - if (token() === 126 /* AbstractKeyword */) { + if (token() === 126 /* SyntaxKind.AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* SyntaxKind.AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -34041,10 +34167,10 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(103 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* SyntaxKind.NewKeyword */); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(38 /* SyntaxKind.EqualsGreaterThanToken */, /*isType*/ false); var node = isConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory.createFunctionTypeNode(typeParameters, parameters, type); @@ -34054,34 +34180,34 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 24 /* DotToken */ ? undefined : node; + return token() === 24 /* SyntaxKind.DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { var pos = getNodePos(); if (negative) { nextToken(); } - var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? + var expression = token() === 110 /* SyntaxKind.TrueKeyword */ || token() === 95 /* SyntaxKind.FalseKeyword */ || token() === 104 /* SyntaxKind.NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { - expression = finishNode(factory.createPrefixUnaryExpression(40 /* MinusToken */, expression), pos); + expression = finishNode(factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, expression), pos); } return finishNode(factory.createLiteralTypeNode(expression), pos); } function isStartOfTypeOfImportType() { nextToken(); - return token() === 100 /* ImportKeyword */; + return token() === 100 /* SyntaxKind.ImportKeyword */; } function parseImportTypeAssertions() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - parseExpected(129 /* AssertKeyword */); - parseExpected(58 /* ColonToken */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); var clause = parseAssertClause(/*skipAssertKeyword*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -34090,89 +34216,89 @@ var ts; return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos); } function parseImportType() { - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(112 /* TypeOfKeyword */); - parseExpected(100 /* ImportKeyword */); - parseExpected(20 /* OpenParenToken */); + var isTypeOf = parseOptional(112 /* SyntaxKind.TypeOfKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); var assertions; - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { assertions = parseImportTypeAssertions(); } - parseExpected(21 /* CloseParenToken */); - var qualifier = parseOptional(24 /* DotToken */) ? parseEntityNameOfTypeReference() : undefined; + parseExpected(21 /* SyntaxKind.CloseParenToken */); + var qualifier = parseOptional(24 /* SyntaxKind.DotToken */) ? parseEntityNameOfTypeReference() : undefined; var typeArguments = parseTypeArgumentsOfTypeReference(); return finishNode(factory.createImportTypeNode(type, assertions, qualifier, typeArguments, isTypeOf), pos); } function nextTokenIsNumericOrBigIntLiteral() { nextToken(); - return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; + return token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 151 /* SymbolKeyword */: - case 133 /* BooleanKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 66 /* AsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return parseJSDocAllType(); - case 60 /* QuestionQuestionToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // If there is '??', treat it as prefix-'?' in JSDoc type. scanner.reScanQuestionToken(); // falls through - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseJSDocFunctionType(); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return parseLiteralTypeNode(); - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseTokenNode(); - case 108 /* ThisKeyword */: { + case 108 /* SyntaxKind.ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseTupleType(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedType(); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportType(); - case 128 /* AssertsKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateType(); default: return parseTypeReference(); @@ -34180,48 +34306,48 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 145 /* ReadonlyKeyword */: - case 151 /* SymbolKeyword */: - case 154 /* UniqueKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 112 /* TypeOfKeyword */: - case 143 /* NeverKeyword */: - case 18 /* OpenBraceToken */: - case 22 /* OpenBracketToken */: - case 29 /* LessThanToken */: - case 51 /* BarToken */: - case 50 /* AmpersandToken */: - case 103 /* NewKeyword */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 148 /* ObjectKeyword */: - case 41 /* AsteriskToken */: - case 57 /* QuestionToken */: - case 53 /* ExclamationToken */: - case 25 /* DotDotDotToken */: - case 137 /* InferKeyword */: - case 100 /* ImportKeyword */: - case 128 /* AssertsKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 51 /* SyntaxKind.BarToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 103 /* SyntaxKind.NewKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 41 /* SyntaxKind.AsteriskToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 137 /* SyntaxKind.InferKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: return true; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return !inStartOfParameter; - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -34231,18 +34357,18 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* SyntaxKind.CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var pos = getNodePos(); var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: nextToken(); type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos); break; - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: // If next token is start of a type we have a conditional type if (lookAhead(nextTokenIsStartOfType)) { return type; @@ -34250,15 +34376,15 @@ var ts; nextToken(); type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos); break; - case 22 /* OpenBracketToken */: - parseExpected(22 /* OpenBracketToken */); + case 22 /* SyntaxKind.OpenBracketToken */: + parseExpected(22 /* SyntaxKind.OpenBracketToken */); if (isStartOfType()) { var indexType = parseType(); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos); } else { - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createArrayTypeNode(type), pos); } break; @@ -34274,9 +34400,9 @@ var ts; return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos); } function tryParseConstraintOfInferType() { - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { var constraint = disallowConditionalTypesAnd(parseType); - if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) { + if (inDisallowConditionalTypesContext() || token() !== 57 /* SyntaxKind.QuestionToken */) { return constraint; } } @@ -34290,17 +34416,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(137 /* InferKeyword */); + parseExpected(137 /* SyntaxKind.InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 140 /* KeyOfKeyword */: - case 154 /* UniqueKeyword */: - case 145 /* ReadonlyKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: return parseTypeOperator(operator); - case 137 /* InferKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return parseInferType(); } return allowConditionalTypesAnd(parsePostfixTypeOrHigher); @@ -34329,7 +34455,7 @@ var ts; } function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) { var pos = getNodePos(); - var isUnionType = operator === 51 /* BarToken */; + var isUnionType = operator === 51 /* SyntaxKind.BarToken */; var hasLeadingOperator = parseOptional(operator); var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType(); @@ -34343,35 +34469,35 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(50 /* AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); + return parseUnionOrIntersectionType(50 /* SyntaxKind.AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(51 /* BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); + return parseUnionOrIntersectionType(51 /* SyntaxKind.BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); } function nextTokenIsNewKeyword() { nextToken(); - return token() === 103 /* NewKeyword */; + return token() === 103 /* SyntaxKind.NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return true; } - if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 103 /* NewKeyword */ || - token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* SyntaxKind.NewKeyword */ || + token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 108 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* SyntaxKind.ThisKeyword */) { nextToken(); return true; } - if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -34381,7 +34507,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */) { // ( ) // ( ... return true; @@ -34389,17 +34515,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || token() === 63 /* SyntaxKind.EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 21 /* CloseParenToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */) { nextToken(); - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -34420,65 +34546,65 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); - var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* SyntaxKind.AssertsKeyword */); + var parameterName = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(139 /* SyntaxKind.IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { - if (contextFlags & 40960 /* TypeExcludesFlags */) { - return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType); + if (contextFlags & 40960 /* NodeFlags.TypeExcludesFlags */) { + return doOutsideOfContext(40960 /* NodeFlags.TypeExcludesFlags */, parseType); } if (isStartOfFunctionTypeOrConstructorType()) { return parseFunctionOrConstructorType(); } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { + if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = disallowConditionalTypesAnd(parseType); - parseExpected(57 /* QuestionToken */); + parseExpected(57 /* SyntaxKind.QuestionToken */); var trueType = allowConditionalTypesAnd(parseType); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var falseType = allowConditionalTypesAnd(parseType); return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos); } return type; } function parseTypeAnnotation() { - return parseOptional(58 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* SyntaxKind.ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 20 /* OpenParenToken */: - case 22 /* OpenBracketToken */: - case 18 /* OpenBraceToken */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 103 /* NewKeyword */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 79 /* Identifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 20 /* SyntaxKind.OpenParenToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 103 /* SyntaxKind.NewKeyword */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 79 /* SyntaxKind.Identifier */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -34489,19 +34615,19 @@ var ts; return true; } switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 29 /* LessThanToken */: - case 132 /* AwaitKeyword */: - case 125 /* YieldKeyword */: - case 80 /* PrivateIdentifier */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 132 /* SyntaxKind.AwaitKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: + case 80 /* SyntaxKind.PrivateIdentifier */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -34519,10 +34645,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 18 /* OpenBraceToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && - token() !== 59 /* AtToken */ && + return token() !== 18 /* SyntaxKind.OpenBraceToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && + token() !== 59 /* SyntaxKind.AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -34537,7 +34663,7 @@ var ts; var pos = getNodePos(); var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); var operatorToken; - while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(27 /* SyntaxKind.CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos); } if (saveDecoratorContext) { @@ -34546,7 +34672,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined; + return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined; } function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) { // AssignmentExpression[in,yield]: @@ -34588,11 +34714,11 @@ var ts; // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. var pos = getNodePos(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -34608,7 +34734,7 @@ var ts; return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction); } function isYieldExpression() { - if (token() === 125 /* YieldKeyword */) { + if (token() === 125 /* SyntaxKind.YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -34644,8 +34770,8 @@ var ts; // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos); + (token() === 41 /* SyntaxKind.AsteriskToken */ || isStartOfExpression())) { + return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* SyntaxKind.AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos); } else { // if the next token is not on the same line as yield. or we don't have an '*' or @@ -34654,7 +34780,7 @@ var ts; } } function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) { - ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* SyntaxKind.EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var parameter = factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, identifier, @@ -34663,14 +34789,14 @@ var ts; /*initializer*/ undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction); var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { + if (triState === 0 /* Tristate.False */) { // It's definitely not a parenthesized arrow function expression. return undefined; } @@ -34678,7 +34804,7 @@ var ts; // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. - return triState === 1 /* True */ ? + return triState === 1 /* Tristate.True */ ? parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) : tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); }); } @@ -34687,44 +34813,44 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */ || token() === 131 /* SyntaxKind.AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. - return 1 /* True */; + return 1 /* Tristate.True */; } // Definitely not a parenthesized arrow function. - return 0 /* False */; + return 0 /* Tristate.False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; + return 0 /* Tristate.False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { - return 0 /* False */; + if (token() !== 20 /* SyntaxKind.OpenParenToken */ && token() !== 29 /* SyntaxKind.LessThanToken */) { + return 0 /* Tristate.False */; } } var first = token(); var second = nextToken(); - if (first === 20 /* OpenParenToken */) { - if (second === 21 /* CloseParenToken */) { + if (first === 20 /* SyntaxKind.OpenParenToken */) { + if (second === 21 /* SyntaxKind.CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 38 /* EqualsGreaterThanToken */: - case 58 /* ColonToken */: - case 18 /* OpenBraceToken */: - return 1 /* True */; + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 58 /* SyntaxKind.ColonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + return 1 /* Tristate.True */; default: - return 0 /* False */; + return 0 /* Tristate.False */; } } // If encounter "([" or "({", this could be the start of a binding pattern. @@ -34733,85 +34859,85 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { - return 2 /* Unknown */; + if (second === 22 /* SyntaxKind.OpenBracketToken */ || second === 18 /* SyntaxKind.OpenBraceToken */) { + return 2 /* Tristate.Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 25 /* DotDotDotToken */) { - return 1 /* True */; + if (second === 25 /* SyntaxKind.DotDotDotToken */) { + return 1 /* Tristate.True */; } // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { - if (nextToken() === 127 /* AsKeyword */) { + if (ts.isModifierKind(second) && second !== 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (nextToken() === 127 /* SyntaxKind.AsKeyword */) { // https://github.com/microsoft/TypeScript/issues/44466 - return 0 /* False */; + return 0 /* Tristate.False */; } - return 1 /* True */; + return 1 /* Tristate.True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 108 /* ThisKeyword */) { - return 0 /* False */; + if (!isIdentifier() && second !== 108 /* SyntaxKind.ThisKeyword */) { + return 0 /* Tristate.False */; } switch (nextToken()) { - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - return 1 /* True */; - case 57 /* QuestionToken */: + return 1 /* Tristate.True */; + case 57 /* SyntaxKind.QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { - return 1 /* True */; + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 63 /* SyntaxKind.EqualsToken */ || token() === 21 /* SyntaxKind.CloseParenToken */) { + return 1 /* Tristate.True */; } // Otherwise it is definitely not a lambda. - return 0 /* False */; - case 27 /* CommaToken */: - case 63 /* EqualsToken */: - case 21 /* CloseParenToken */: + return 0 /* Tristate.False */; + case 27 /* SyntaxKind.CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 21 /* SyntaxKind.CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } // It is definitely not an arrow function - return 0 /* False */; + return 0 /* Tristate.False */; } else { - ts.Debug.assert(first === 29 /* LessThanToken */); + ts.Debug.assert(first === 29 /* SyntaxKind.LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { - return 0 /* False */; + return 0 /* Tristate.False */; } // JSX overrides - if (languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* LanguageVariant.JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 94 /* ExtendsKeyword */) { + if (third === 94 /* SyntaxKind.ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 63 /* EqualsToken */: - case 31 /* GreaterThanToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: return false; default: return true; } } - else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) { + else if (third === 27 /* SyntaxKind.CommaToken */ || third === 63 /* SyntaxKind.EqualsToken */) { return true; } return false; }); if (isArrowFunctionInJsx) { - return 1 /* True */; + return 1 /* Tristate.True */; } - return 0 /* False */; + return 0 /* Tristate.False */; } // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } } function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { @@ -34827,11 +34953,11 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 131 /* AsyncKeyword */) { - if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* Tristate.True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier); } } @@ -34841,26 +34967,26 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { - return 0 /* False */; + if (scanner.hasPrecedingLineBreak() || token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 0 /* Tristate.False */; } // Check for un-parenthesized AsyncArrowFunction - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return 1 /* True */; + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 1 /* Tristate.True */; } } - return 0 /* False */; + return 0 /* Tristate.False */; } function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -34870,7 +34996,7 @@ var ts; // close paren. var typeParameters = parseTypeParameters(); var parameters; - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { if (!allowAmbiguity) { return undefined; } @@ -34887,12 +35013,12 @@ var ts; else { parameters = parseParametersWorker(isAsync, allowAmbiguity); } - if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) { + if (!parseExpected(21 /* SyntaxKind.CloseParenToken */) && !allowAmbiguity) { return undefined; } } - var hasReturnColon = token() === 58 /* ColonToken */; - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var hasReturnColon = token() === 58 /* SyntaxKind.ColonToken */; + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; } @@ -34907,19 +35033,19 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var unwrappedType = type; - while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* ParenthesizedType */) { + while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* SyntaxKind.ParenthesizedType */) { unwrappedType = unwrappedType.type; // Skip parens if need be } var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType); - if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* SyntaxKind.EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* SyntaxKind.OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = (lastToken === 38 /* SyntaxKind.EqualsGreaterThanToken */ || lastToken === 18 /* SyntaxKind.OpenBraceToken */) ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction) : parseIdentifier(); // Given: @@ -34943,7 +35069,7 @@ var ts; // Then allow the arrow function, and treat the second colon as terminating // the conditional expression. It's okay to do this because this code would // be a syntax error in JavaScript (as the second colon shouldn't be there). - if (token() !== 58 /* ColonToken */) { + if (token() !== 58 /* SyntaxKind.ColonToken */) { return undefined; } } @@ -34951,12 +35077,12 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) { - if (token() === 18 /* OpenBraceToken */) { - return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { + return parseFunctionBlock(isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */); } - if (token() !== 26 /* SemicolonToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && + if (token() !== 26 /* SyntaxKind.SemicolonToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -34973,7 +35099,7 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error. - return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */)); + return parseFunctionBlock(16 /* SignatureFlags.IgnoreMissingOpenBrace */ | (isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */)); } var savedTopLevel = topLevel; topLevel = false; @@ -34985,16 +35111,16 @@ var ts; } function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* SyntaxKind.ColonToken */), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) - : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -35002,7 +35128,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 101 /* InKeyword */ || t === 160 /* OfKeyword */; + return t === 101 /* SyntaxKind.InKeyword */ || t === 160 /* SyntaxKind.OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -35031,16 +35157,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 101 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* SyntaxKind.InKeyword */ && inDisallowInContext()) { break; } - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -35061,7 +35187,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 101 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* SyntaxKind.InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -35089,7 +35215,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 132 /* AwaitKeyword */) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -35122,7 +35248,7 @@ var ts; if (isUpdateExpression()) { var pos = getNodePos(); var updateExpression = parseUpdateExpression(); - return token() === 42 /* AsteriskAsteriskToken */ ? + return token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) : updateExpression; } @@ -35139,10 +35265,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 42 /* AsteriskAsteriskToken */) { + if (token() === 42 /* SyntaxKind.AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 211 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -35167,23 +35293,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parsePrefixUnaryExpression(); - case 89 /* DeleteKeyword */: + case 89 /* SyntaxKind.DeleteKeyword */: return parseDeleteExpression(); - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return parseTypeOfExpression(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseVoidExpression(); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 132 /* AwaitKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -35206,18 +35332,18 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 132 /* AwaitKeyword */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: return false; - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (languageVariant !== 1 /* JSX */) { + if (languageVariant !== 1 /* LanguageVariant.JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. @@ -35238,17 +35364,17 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + if (token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) { var pos = getNodePos(); return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos); } - else if (languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (languageVariant === 1 /* LanguageVariant.JSX */ && token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { var operator = token(); nextToken(); return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos); @@ -35289,29 +35415,29 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 100 /* ImportKeyword */) { + if (token() === 100 /* SyntaxKind.ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); - sourceFlags |= 4194304 /* PossiblyContainsImportMeta */; + expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos); + sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression or OptionalExpression. As such, we need to consume the rest @@ -35373,19 +35499,22 @@ var ts; function parseSuperExpression() { var pos = getNodePos(); var expression = parseTokenNode(); - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); + if (!isTemplateStartOfTaggedTemplate()) { + expression = factory.createExpressionWithTypeArguments(expression, typeArguments); + } } } - if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 24 /* SyntaxKind.DotToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* SyntaxKind.DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); // private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } @@ -35393,11 +35522,11 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 280 /* JsxOpeningElement */) { + if (opening.kind === 280 /* SyntaxKind.JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = void 0; var lastChild = children[children.length - 1]; - if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* JsxElement */ + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, @@ -35423,11 +35552,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 283 /* JsxOpeningFragment */) { + else if (opening.kind === 283 /* SyntaxKind.JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 279 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 279 /* SyntaxKind.JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -35438,11 +35567,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 29 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* SyntaxKind.LessThanToken */) { var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos_1); }); if (invalidElement) { - var operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false); + var operatorToken = createMissingNode(27 /* SyntaxKind.CommaToken */, /*reportAtCurrentPosition*/ false); ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0); parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element); return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos); @@ -35452,13 +35581,13 @@ var ts; } function parseJsxText() { var pos = getNodePos(); - var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* JsxTextAllWhiteSpaces */); + var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* SyntaxKind.JsxTextAllWhiteSpaces */); currentToken = scanner.scanJsxToken(); return finishNode(node, pos); } function parseJsxChild(openingTag, token) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // If we hit EOF, issue the error at the tag that lacks the closing element // rather than at the end of the file (which is useless) if (ts.isJsxOpeningFragment(openingTag)) { @@ -35472,15 +35601,15 @@ var ts; parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 30 /* LessThanSlashToken */: - case 7 /* ConflictMarkerTrivia */: + case 30 /* SyntaxKind.LessThanSlashToken */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: return undefined; - case 11 /* JsxText */: - case 12 /* JsxTextAllWhiteSpaces */: + case 11 /* SyntaxKind.JsxText */: + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return parseJsxText(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); @@ -35490,14 +35619,14 @@ var ts; var list = []; var listPos = getNodePos(); var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; + parsingContext |= 1 << 14 /* ParsingContext.JsxChildren */; while (true) { var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken()); if (!child) break; list.push(child); if (ts.isJsxOpeningElement(openingTag) - && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* JsxElement */ + && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { // stop after parsing a mismatched child like
...(
) in order to reattach the higher @@ -35509,21 +35638,21 @@ var ts; } function parseJsxAttributes() { var pos = getNodePos(); - return finishNode(factory.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos); + return finishNode(factory.createJsxAttributes(parseList(13 /* ParsingContext.JsxAttributes */, parseJsxAttribute)), pos); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); - if (token() === 31 /* GreaterThanToken */) { + parseExpected(29 /* SyntaxKind.LessThanToken */); + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // See below for explanation of scanJsxText scanJsxText(); return finishNode(factory.createJsxOpeningFragment(), pos); } var tagName = parseJsxElementName(); - var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; + var typeArguments = (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; var attributes = parseJsxAttributes(); var node; - if (token() === 31 /* GreaterThanToken */) { + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors @@ -35531,8 +35660,8 @@ var ts; node = factory.createJsxOpeningElement(tagName, typeArguments, attributes); } else { - parseExpected(43 /* SlashToken */); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + parseExpected(43 /* SyntaxKind.SlashToken */); + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35553,39 +35682,39 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 108 /* ThisKeyword */ ? + var expression = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); } return expression; } function parseJsxExpression(inExpressionContext) { var pos = getNodePos(); - if (!parseExpected(18 /* OpenBraceToken */)) { + if (!parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { return undefined; } var dotDotDotToken; var expression; - if (token() !== 19 /* CloseBraceToken */) { - dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + if (token() !== 19 /* SyntaxKind.CloseBraceToken */) { + dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); // Only an AssignmentExpression is valid here per the JSX spec, // but we can unambiguously parse a comma sequence and provide // a better error message in grammar checking. expression = parseExpression(); } if (inExpressionContext) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { - if (parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(19 /* SyntaxKind.CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { scanJsxText(); } } return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos); } function parseJsxAttribute() { - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); @@ -35593,14 +35722,14 @@ var ts; return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos); } function parseJsxAttributeValue() { - if (token() === 63 /* EqualsToken */) { - if (scanJsxAttributeValue() === 10 /* StringLiteral */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { + if (scanJsxAttributeValue() === 10 /* SyntaxKind.StringLiteral */) { return parseLiteralNode(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxExpression(/*inExpressionContext*/ true); } - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } parseErrorAtCurrentToken(ts.Diagnostics.or_JSX_element_expected); @@ -35609,17 +35738,17 @@ var ts; } function parseJsxSpreadAttribute() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - parseExpected(25 /* DotDotDotToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseExpression(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); var tagName = parseJsxElementName(); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { nextToken(); @@ -35632,11 +35761,11 @@ var ts; } function parseJsxClosingFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35649,36 +35778,36 @@ var ts; } function parseTypeAssertion() { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); + parseExpected(29 /* SyntaxKind.LessThanToken */); var type = parseType(); - parseExpected(31 /* GreaterThanToken */); + parseExpected(31 /* SyntaxKind.GreaterThanToken */); var expression = parseSimpleUnaryExpression(); return finishNode(factory.createTypeAssertion(type, expression), pos); } function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) - || token() === 22 /* OpenBracketToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ || isTemplateStartOfTaggedTemplate(); } function isStartOfOptionalPropertyOrElementAccessChain() { - return token() === 28 /* QuestionDotToken */ + return token() === 28 /* SyntaxKind.QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); } function tryReparseOptionalChain(node) { - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { return true; } // check for an optional chain in a non-null expression if (ts.isNonNullExpression(node)) { var expr = node.expression; - while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) { + while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* NodeFlags.OptionalChain */)) { expr = expr.expression; } - if (expr.flags & 32 /* OptionalChain */) { + if (expr.flags & 32 /* NodeFlags.OptionalChain */) { // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. while (ts.isNonNullExpression(node)) { - node.flags |= 32 /* OptionalChain */; + node.flags |= 32 /* NodeFlags.OptionalChain */; node = node.expression; } return true; @@ -35695,12 +35824,17 @@ var ts; if (isOptionalChain && ts.isPrivateIdentifier(propertyAccess.name)) { parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers); } + if (ts.isExpressionWithTypeArguments(expression) && expression.typeArguments) { + var pos_2 = expression.typeArguments.pos - 1; + var end = ts.skipTrivia(sourceText, expression.typeArguments.end) + 1; + parseErrorAt(pos_2, end, ts.Diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access); + } return finishNode(propertyAccess, pos); } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; - if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* SyntaxKind.CloseBracketToken */) { + argumentExpression = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -35709,7 +35843,7 @@ var ts; } argumentExpression = argument; } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ? factory.createElementAccessChain(expression, questionDotToken, argumentExpression) : factory.createElementAccessExpression(expression, argumentExpression); @@ -35720,30 +35854,30 @@ var ts; var questionDotToken = void 0; var isPropertyAccess = false; if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { - questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + questionDotToken = parseExpectedToken(28 /* SyntaxKind.QuestionDotToken */); isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); } else { - isPropertyAccess = parseOptional(24 /* DotToken */); + isPropertyAccess = parseOptional(24 /* SyntaxKind.DotToken */); } if (isPropertyAccess) { expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { expression = parseElementAccessExpressionRest(pos, expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments - expression = !questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */ ? + expression = !questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) : parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined); continue; } if (!questionDotToken) { - if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); expression = finishNode(factory.createNonNullExpression(expression), pos); continue; @@ -35758,14 +35892,14 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; + return token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || token() === 15 /* SyntaxKind.TemplateHead */; } function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) { - var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* NoSubstitutionTemplateLiteral */ ? + var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(/*isTaggedTemplate*/ true)); - if (questionDotToken || tag.flags & 32 /* OptionalChain */) { - tagExpression.flags |= 32 /* OptionalChain */; + if (questionDotToken || tag.flags & 32 /* NodeFlags.OptionalChain */) { + tagExpression.flags |= 32 /* NodeFlags.OptionalChain */; } tagExpression.questionDotToken = questionDotToken; return finishNode(tagExpression, pos); @@ -35774,7 +35908,7 @@ var ts; while (true) { expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true); var typeArguments = void 0; - var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); + var questionDotToken = parseOptionalToken(28 /* SyntaxKind.QuestionDotToken */); if (questionDotToken) { typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { @@ -35782,9 +35916,9 @@ var ts; continue; } } - if (typeArguments || token() === 20 /* OpenParenToken */) { + if (typeArguments || token() === 20 /* SyntaxKind.OpenParenToken */) { // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments - if (!questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (!questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } @@ -35797,7 +35931,7 @@ var ts; } if (questionDotToken) { // We parsed `?.` but then failed to parse anything, so report a missing identifier here. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -35805,22 +35939,22 @@ var ts; return expression; } function parseArgumentList() { - parseExpected(20 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); + var result = parseDelimitedList(11 /* ParsingContext.ArgumentExpressions */, parseArgumentExpression); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) { + if ((contextFlags & 262144 /* NodeFlags.JavaScriptFile */) !== 0) { // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators. return undefined; } - if (reScanLessThanToken() !== 29 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* SyntaxKind.LessThanToken */) { return undefined; } nextToken(); - var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (reScanGreaterToken() !== 31 /* GreaterThanToken */) { + var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType); + if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -35834,17 +35968,17 @@ var ts; function canFollowTypeArgumentsInExpression() { switch (token()) { // These tokens can follow a type argument list in a call expression. - case 20 /* OpenParenToken */: // foo( - case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 15 /* TemplateHead */: // foo `...${100}...` + case 20 /* SyntaxKind.OpenParenToken */: // foo( + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* SyntaxKind.TemplateHead */: // foo `...${100}...` return true; // A type argument list followed by `<` never makes sense, and a type argument list followed // by `>` is ambiguous with a (re-scanned) `>>` operator, so we disqualify both. Also, in // this context, `+` and `-` are unary operators, not binary operators. - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: return false; } // We favor the type argument list interpretation when it is immediately followed by @@ -35853,24 +35987,24 @@ var ts; } function parsePrimaryExpression() { switch (token()) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return parseTokenNode(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedExpression(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseArrayLiteralExpression(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseObjectLiteralExpression(); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -35878,21 +36012,21 @@ var ts; break; } return parseFunctionExpression(); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassExpression(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionExpression(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateExpression(/* isTaggedTemplate */ false); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return parsePrivateIdentifier(); } return parseIdentifier(ts.Diagnostics.Expression_expected); @@ -35900,20 +36034,20 @@ var ts; function parseParenthesizedExpression() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc); } function parseSpreadElement() { var pos = getNodePos(); - parseExpected(25 /* DotDotDotToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { - return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : + return token() === 25 /* SyntaxKind.DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* SyntaxKind.CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); } function parseArgumentExpression() { @@ -35922,34 +36056,34 @@ var ts; function parseArrayLiteralExpression() { var pos = getNodePos(); var openBracketPosition = scanner.getTokenPos(); - var openBracketParsed = parseExpected(22 /* OpenBracketToken */); + var openBracketParsed = parseExpected(22 /* SyntaxKind.OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition); + var elements = parseDelimitedList(15 /* ParsingContext.ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpectedMatchingBrackets(22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, openBracketParsed, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (parseOptionalToken(25 /* DotDotDotToken */)) { + if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) { var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */, 0 /* SignatureFlags.None */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */, 0 /* SignatureFlags.None */); } - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - var exclamationToken = parseOptionalToken(53 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken); } // check if it is short-hand property assignment or normal property assignment @@ -35958,9 +36092,9 @@ var ts; // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var node; - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(63 /* EqualsToken */); + var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */); var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. @@ -35968,7 +36102,7 @@ var ts; node.equalsToken = equalsToken; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }); node = factory.createPropertyAssignment(name, initializer); } @@ -35982,10 +36116,10 @@ var ts; function parseObjectLiteralExpression() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var properties = parseDelimitedList(12 /* ParsingContext.ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -35999,17 +36133,17 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : parseOptionalBindingIdentifier(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlock(isGenerator | isAsync); setDecoratorContext(savedDecoratorContext); var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -36020,23 +36154,23 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(103 /* NewKeyword */); - if (parseOptional(24 /* DotToken */)) { + parseExpected(103 /* SyntaxKind.NewKeyword */); + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* SyntaxKind.NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false); var typeArguments; // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } - if (token() === 28 /* QuestionDotToken */) { + if (token() === 28 /* SyntaxKind.QuestionDotToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, ts.getTextOfNodeFromSourceText(sourceText, expression)); } - var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined; + var argumentList = token() === 20 /* SyntaxKind.OpenParenToken */ ? parseArgumentList() : undefined; return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos); } // STATEMENTS @@ -36044,13 +36178,13 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */, diagnosticMessage); if (openBraceParsed || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); - var statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); nextToken(); } @@ -36063,9 +36197,9 @@ var ts; } function parseFunctionBlock(flags, diagnosticMessage) { var savedYieldContext = inYieldContext(); - setYieldContext(!!(flags & 1 /* Yield */)); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); var savedAwaitContext = inAwaitContext(); - setAwaitContext(!!(flags & 2 /* Await */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); var savedTopLevel = topLevel; topLevel = false; // We may be in a [Decorator] context when parsing a function expression or @@ -36074,7 +36208,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage); + var block = parseBlock(!!(flags & 16 /* SignatureFlags.IgnoreMissingOpenBrace */), diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -36086,58 +36220,58 @@ var ts; function parseEmptyStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(26 /* SemicolonToken */); + parseExpected(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(99 /* IfKeyword */); + parseExpected(99 /* SyntaxKind.IfKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var thenStatement = parseStatement(); - var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + var elseStatement = parseOptional(91 /* SyntaxKind.ElseKeyword */) ? parseStatement() : undefined; return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(90 /* DoKeyword */); + parseExpected(90 /* SyntaxKind.DoKeyword */); var statement = parseStatement(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(26 /* SemicolonToken */); + parseOptional(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var statement = parseStatement(); return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(97 /* ForKeyword */); - var awaitToken = parseOptionalToken(132 /* AwaitKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(97 /* SyntaxKind.ForKeyword */); + var awaitToken = parseOptionalToken(132 /* SyntaxKind.AwaitKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var initializer; - if (token() !== 26 /* SemicolonToken */) { - if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { + if (token() !== 26 /* SyntaxKind.SemicolonToken */) { + if (token() === 113 /* SyntaxKind.VarKeyword */ || token() === 119 /* SyntaxKind.LetKeyword */ || token() === 85 /* SyntaxKind.ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -36145,26 +36279,26 @@ var ts; } } var node; - if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) { + if (awaitToken ? parseExpected(160 /* SyntaxKind.OfKeyword */) : parseOptional(160 /* SyntaxKind.OfKeyword */)) { var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(101 /* InKeyword */)) { + else if (parseOptional(101 /* SyntaxKind.InKeyword */)) { var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); } else { - parseExpected(26 /* SemicolonToken */); - var condition = token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var condition = token() !== 26 /* SyntaxKind.SemicolonToken */ && token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(26 /* SemicolonToken */); - var incrementor = token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var incrementor = token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36172,10 +36306,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 246 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); + parseExpected(kind === 246 /* SyntaxKind.BreakStatement */ ? 81 /* SyntaxKind.BreakKeyword */ : 86 /* SyntaxKind.ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 246 /* BreakStatement */ + var node = kind === 246 /* SyntaxKind.BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36183,7 +36317,7 @@ var ts; function parseReturnStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(105 /* ReturnKeyword */); + parseExpected(105 /* SyntaxKind.ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); @@ -36191,47 +36325,47 @@ var ts; function parseWithStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(116 /* WithKeyword */); + parseExpected(116 /* SyntaxKind.WithKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); - var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); + var statement = doInsideOfContext(33554432 /* NodeFlags.InWithStatement */, parseStatement); return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(82 /* CaseKeyword */); + parseExpected(82 /* SyntaxKind.CaseKeyword */); var expression = allowInAnd(parseExpression); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc); } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(88 /* DefaultKeyword */); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* SyntaxKind.CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var clauses = parseList(2 /* ParsingContext.SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createCaseBlock(clauses), pos); } function parseSwitchStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(107 /* SwitchKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(107 /* SyntaxKind.SwitchKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); var caseBlock = parseCaseBlock(); return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } @@ -36240,7 +36374,7 @@ var ts; // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(109 /* ThrowKeyword */); + parseExpected(109 /* SyntaxKind.ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' // directly as that might consume an expression on the following line. @@ -36260,25 +36394,25 @@ var ts; function parseTryStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(111 /* TryKeyword */); + parseExpected(111 /* SyntaxKind.TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 83 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* SyntaxKind.CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. var finallyBlock; - if (!catchClause || token() === 96 /* FinallyKeyword */) { - parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); + if (!catchClause || token() === 96 /* SyntaxKind.FinallyKeyword */) { + parseExpected(96 /* SyntaxKind.FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(83 /* CatchKeyword */); + parseExpected(83 /* SyntaxKind.CatchKeyword */); var variableDeclaration; - if (parseOptional(20 /* OpenParenToken */)) { + if (parseOptional(20 /* SyntaxKind.OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -36290,7 +36424,7 @@ var ts; function parseDebuggerStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(87 /* DebuggerKeyword */); + parseExpected(87 /* SyntaxKind.DebuggerKeyword */); parseSemicolon(); return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } @@ -36301,9 +36435,9 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var node; - var hasParen = token() === 20 /* OpenParenToken */; + var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */; var expression = allowInAnd(parseExpression); - if (ts.isIdentifier(expression) && parseOptional(58 /* ColonToken */)) { + if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) { node = factory.createLabeledStatement(expression, parseStatement()); } else { @@ -36324,25 +36458,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* SyntaxKind.ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* SyntaxKind.FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */ || token() === 10 /* SyntaxKind.StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -36365,44 +36499,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 157 /* GlobalKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; - case 100 /* ImportKeyword */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 79 /* SyntaxKind.Identifier */ || token() === 93 /* SyntaxKind.ExportKeyword */; + case 100 /* SyntaxKind.ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 93 /* ExportKeyword */: + return token() === 10 /* SyntaxKind.StringLiteral */ || token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 18 /* SyntaxKind.OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 93 /* SyntaxKind.ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 152 /* TypeKeyword */) { + if (currentToken_1 === 152 /* SyntaxKind.TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || - currentToken_1 === 127 /* AsKeyword */) { + if (currentToken_1 === 63 /* SyntaxKind.EqualsToken */ || currentToken_1 === 41 /* SyntaxKind.AsteriskToken */ || + currentToken_1 === 18 /* SyntaxKind.OpenBraceToken */ || currentToken_1 === 88 /* SyntaxKind.DefaultKeyword */ || + currentToken_1 === 127 /* SyntaxKind.AsKeyword */) { return true; } continue; - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: nextToken(); continue; default: @@ -36415,51 +36549,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 59 /* AtToken */: - case 26 /* SemicolonToken */: - case 18 /* OpenBraceToken */: - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 99 /* IfKeyword */: - case 90 /* DoKeyword */: - case 115 /* WhileKeyword */: - case 97 /* ForKeyword */: - case 86 /* ContinueKeyword */: - case 81 /* BreakKeyword */: - case 105 /* ReturnKeyword */: - case 116 /* WithKeyword */: - case 107 /* SwitchKeyword */: - case 109 /* ThrowKeyword */: - case 111 /* TryKeyword */: - case 87 /* DebuggerKeyword */: + case 59 /* SyntaxKind.AtToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 90 /* SyntaxKind.DoKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: + case 116 /* SyntaxKind.WithKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: + case 111 /* SyntaxKind.TryKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 85 /* ConstKeyword */: - case 93 /* ExportKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return isStartOfDeclaration(); - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 118 /* InterfaceKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 152 /* TypeKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -36469,7 +36603,7 @@ var ts; } function nextTokenIsBindingIdentifierOrStartOfDestructuring() { nextToken(); - return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; + return isBindingIdentifier() || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -36478,68 +36612,68 @@ var ts; } function parseStatement() { switch (token()) { - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: return parseEmptyStatement(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 119 /* LetKeyword */: + case 119 /* SyntaxKind.LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 99 /* IfKeyword */: + case 99 /* SyntaxKind.IfKeyword */: return parseIfStatement(); - case 90 /* DoKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return parseDoStatement(); - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return parseWhileStatement(); - case 97 /* ForKeyword */: + case 97 /* SyntaxKind.ForKeyword */: return parseForOrForInOrForOfStatement(); - case 86 /* ContinueKeyword */: - return parseBreakOrContinueStatement(245 /* ContinueStatement */); - case 81 /* BreakKeyword */: - return parseBreakOrContinueStatement(246 /* BreakStatement */); - case 105 /* ReturnKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + return parseBreakOrContinueStatement(245 /* SyntaxKind.ContinueStatement */); + case 81 /* SyntaxKind.BreakKeyword */: + return parseBreakOrContinueStatement(246 /* SyntaxKind.BreakStatement */); + case 105 /* SyntaxKind.ReturnKeyword */: return parseReturnStatement(); - case 116 /* WithKeyword */: + case 116 /* SyntaxKind.WithKeyword */: return parseWithStatement(); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return parseSwitchStatement(); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return parseThrowStatement(); - case 111 /* TryKeyword */: + case 111 /* SyntaxKind.TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return parseTryStatement(); - case 87 /* DebuggerKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: return parseDebuggerStatement(); - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: return parseDeclaration(); - case 131 /* AsyncKeyword */: - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 92 /* EnumKeyword */: - case 93 /* ExportKeyword */: - case 100 /* ImportKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 126 /* AbstractKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -36548,40 +36682,35 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 135 /* DeclareKeyword */; + return modifier.kind === 135 /* SyntaxKind.DeclareKeyword */; } function parseDeclaration() { - // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner - // if we can't reuse the declaration, so that we don't do this work twice? - // // `parseListElement` attempted to get the reused node at this position, // but the ambient context flag was not yet set, so the node appeared // not reusable in that context. - var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier); - if (isAmbient) { - var node = tryReuseAmbientDeclaration(); - if (node) { - return node; - } - } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(); + var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { + var node = tryReuseAmbientDeclaration(pos); + if (node) { + return node; + } for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); } else { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } - function tryReuseAmbientDeclaration() { - return doInsideOfContext(16777216 /* Ambient */, function () { - var node = currentNode(parsingContext); + function tryReuseAmbientDeclaration(pos) { + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { + var node = currentNode(parsingContext, pos); if (node) { return consumeNode(node); } @@ -36589,33 +36718,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 118 /* InterfaceKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* EnumKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 157 /* GlobalKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); switch (token()) { - case 88 /* DefaultKeyword */: - case 63 /* EqualsToken */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 63 /* SyntaxKind.EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 127 /* AsKeyword */: + case 127 /* SyntaxKind.AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36624,7 +36753,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(276 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -36635,38 +36764,44 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { - parseSemicolon(); - return; + if (token() !== 18 /* SyntaxKind.OpenBraceToken */) { + if (flags & 4 /* SignatureFlags.Type */) { + parseTypeMemberSemicolon(); + return; + } + if (canParseSemicolon()) { + parseSemicolon(); + return; + } } return parseFunctionBlock(flags, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { var pos = getNodePos(); - if (token() === 27 /* CommaToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */) { return finishNode(factory.createOmittedExpression(), pos); } - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierOrPattern(); var initializer = parseInitializer(); return finishNode(factory.createBindingElement(dotDotDotToken, /*propertyName*/ undefined, name, initializer), pos); } function parseObjectBindingElement() { var pos = getNodePos(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var tokenIsIdentifier = isBindingIdentifier(); var propertyName = parsePropertyName(); var name; - if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* SyntaxKind.ColonToken */) { name = propertyName; propertyName = undefined; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); name = parseIdentifierOrPattern(); } var initializer = parseInitializer(); @@ -36674,29 +36809,29 @@ var ts; } function parseObjectBindingPattern() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var elements = parseDelimitedList(9 /* ParsingContext.ObjectBindingElements */, parseObjectBindingElement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createObjectBindingPattern(elements), pos); } function parseArrayBindingPattern() { var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); - var elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(23 /* CloseBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); + var elements = parseDelimitedList(10 /* ParsingContext.ArrayBindingElements */, parseArrayBindingElement); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createArrayBindingPattern(elements), pos); } function isBindingIdentifierOrPrivateIdentifierOrPattern() { - return token() === 18 /* OpenBraceToken */ - || token() === 22 /* OpenBracketToken */ - || token() === 80 /* PrivateIdentifier */ + return token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 80 /* SyntaxKind.PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseObjectBindingPattern(); } return parseBindingIdentifier(privateIdentifierDiagnosticMessage); @@ -36709,8 +36844,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 79 /* Identifier */ && - token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && name.kind === 79 /* SyntaxKind.Identifier */ && + token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); @@ -36722,13 +36857,13 @@ var ts; var pos = getNodePos(); var flags = 0; switch (token()) { - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: break; - case 119 /* LetKeyword */: - flags |= 1 /* Let */; + case 119 /* SyntaxKind.LetKeyword */: + flags |= 1 /* NodeFlags.Let */; break; - case 85 /* ConstKeyword */: - flags |= 2 /* Const */; + case 85 /* SyntaxKind.ConstKeyword */: + flags |= 2 /* NodeFlags.Const */; break; default: ts.Debug.fail(); @@ -36744,19 +36879,19 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 160 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 160 /* SyntaxKind.OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); + declarations = parseDelimitedList(8 /* ParsingContext.VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); setDisallowInContext(savedDisallowIn); } return finishNode(factory.createVariableDeclarationList(declarations, flags), pos); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* SyntaxKind.CloseParenToken */; } function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) { var declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -36769,17 +36904,17 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. - var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */; + var name = modifierFlags & 512 /* ModifierFlags.Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = modifierFlags & 256 /* ModifierFlags.Async */ ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 1 /* ModifierFlags.Export */) setAwaitContext(/*value*/ true); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); setAwaitContext(savedAwaitContext); var node = factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -36787,10 +36922,10 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 134 /* ConstructorKeyword */) { - return parseExpected(134 /* ConstructorKeyword */); + if (token() === 134 /* SyntaxKind.ConstructorKeyword */) { + return parseExpected(134 /* SyntaxKind.ConstructorKeyword */); } - if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ && lookAhead(nextToken) === 20 /* SyntaxKind.OpenParenToken */) { return tryParse(function () { var literalNode = parseLiteralNode(); return literalNode.text === "constructor" ? literalNode : undefined; @@ -36801,9 +36936,9 @@ var ts; return tryParse(function () { if (parseConstructorName()) { var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */, ts.Diagnostics.or_expected); var node = factory.createConstructorDeclaration(modifiers, parameters, body); // Attach invalid nodes if they exist so that we can report them in the grammar checker. node.decorators = decorators; @@ -36814,11 +36949,11 @@ var ts; }); } function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) { - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); var node = factory.createMethodDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body); // An exclamation token on a method is invalid syntax and will be handled by the grammar checker @@ -36826,31 +36961,31 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) { - var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined; + var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* SyntaxKind.ExclamationToken */) : undefined; var type = parseTypeAnnotation(); - var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer); + var initializer = doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */ | 4096 /* NodeFlags.DisallowInContext */, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); var node = factory.createPropertyDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) { - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, /*exclamationToken*/ undefined, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); } - function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { + function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 172 /* GetAccessor */ + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(flags); + var node = kind === 172 /* SyntaxKind.GetAccessor */ ? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body) : factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors @@ -36861,7 +36996,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 59 /* AtToken */) { + if (token() === 59 /* SyntaxKind.AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -36878,7 +37013,7 @@ var ts; } nextToken(); } - if (token() === 41 /* AsteriskToken */) { + if (token() === 41 /* SyntaxKind.AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -36888,24 +37023,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 149 /* SetKeyword */ || idToken === 136 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 149 /* SyntaxKind.SetKeyword */ || idToken === 136 /* SyntaxKind.GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 20 /* OpenParenToken */: // Method declaration - case 29 /* LessThanToken */: // Generic Method declaration - case 53 /* ExclamationToken */: // Non-null assertion on property name - case 58 /* ColonToken */: // Type Annotation for declaration - case 63 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* SyntaxKind.OpenParenToken */: // Method declaration + case 29 /* SyntaxKind.LessThanToken */: // Generic Method declaration + case 53 /* SyntaxKind.ExclamationToken */: // Non-null assertion on property name + case 58 /* SyntaxKind.ColonToken */: // Type Annotation for declaration + case 63 /* SyntaxKind.EqualsToken */: // Initializer for declaration + case 57 /* SyntaxKind.QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -36919,7 +37054,7 @@ var ts; return false; } function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpectedToken(124 /* StaticKeyword */); + parseExpectedToken(124 /* SyntaxKind.StaticKeyword */); var body = parseClassStaticBlockBody(); var node = withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(body), pos), hasJSDoc); node.decorators = decorators; @@ -36937,7 +37072,7 @@ var ts; return body; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 132 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 132 /* SyntaxKind.AwaitKeyword */) { // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails // This simply parses the missing identifier and moves on. var pos = getNodePos(); @@ -36950,7 +37085,7 @@ var ts; } function tryParseDecorator() { var pos = getNodePos(); - if (!parseOptional(59 /* AtToken */)) { + if (!parseOptional(59 /* SyntaxKind.AtToken */)) { return undefined; } var expression = doInDecoratorContext(parseDecoratorExpression); @@ -36967,17 +37102,17 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } } - else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return undefined; } - else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) { + else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) { return undefined; } else { @@ -37007,7 +37142,7 @@ var ts; var pos = getNodePos(); var list, modifier, hasSeenStatic = false; while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) { - if (modifier.kind === 124 /* StaticKeyword */) + if (modifier.kind === 124 /* SyntaxKind.StaticKeyword */) hasSeenStatic = true; list = ts.append(list, modifier); } @@ -37015,33 +37150,33 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(131 /* SyntaxKind.AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; } function parseClassElement() { var pos = getNodePos(); - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { nextToken(); return finishNode(factory.createSemicolonClassElement(), pos); } var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true); - if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */, 0 /* SignatureFlags.None */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */, 0 /* SignatureFlags.None */); } - if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -37053,17 +37188,17 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */ || - token() === 41 /* AsteriskToken */ || - token() === 22 /* OpenBracketToken */) { + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */ || + token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 22 /* SyntaxKind.OpenBracketToken */) { var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); } else { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -37071,21 +37206,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* SyntaxKind.ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(84 /* ClassKeyword */); + parseExpected(84 /* SyntaxKind.ClassKeyword */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); @@ -37093,17 +37228,17 @@ var ts; setAwaitContext(/*value*/ true); var heritageClauses = parseHeritageClauses(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } members = parseClassMembers(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 257 /* ClassDeclaration */ + var node = kind === 257 /* SyntaxKind.ClassDeclaration */ ? factory.createClassDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members) : factory.createClassExpression(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -37119,45 +37254,45 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* SyntaxKind.ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(22 /* HeritageClauses */, parseHeritageClause); + return parseList(22 /* ParsingContext.HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* SyntaxKind.ExtendsKeyword */ || tok === 117 /* SyntaxKind.ImplementsKeyword */); // isListElement() should ensure this. nextToken(); - var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + var types = parseDelimitedList(7 /* ParsingContext.HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); } function parseExpressionWithTypeArguments() { var pos = getNodePos(); var expression = parseLeftHandSideExpressionOrHigher(); - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { return expression; } var typeArguments = tryParseTypeArguments(); return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos); } function tryParseTypeArguments() { - return token() === 29 /* LessThanToken */ ? - parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; + return token() === 29 /* SyntaxKind.LessThanToken */ ? + parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; + return token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; } function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); + return parseList(5 /* ParsingContext.ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(118 /* InterfaceKeyword */); + parseExpected(118 /* SyntaxKind.InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -37167,11 +37302,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(152 /* TypeKeyword */); + parseExpected(152 /* SyntaxKind.TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(63 /* EqualsToken */); - var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* SyntaxKind.EqualsToken */); + var type = token() === 138 /* SyntaxKind.IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(modifiers, name, typeParameters, type); node.decorators = decorators; @@ -37189,12 +37324,12 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(92 /* EnumKeyword */); + parseExpected(92 /* SyntaxKind.EnumKeyword */); var name = parseIdentifier(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* EnumMembers */, parseEnumMember); }); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* ParsingContext.EnumMembers */, parseEnumMember); }); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -37206,9 +37341,9 @@ var ts; function parseModuleBlock() { var pos = getNodePos(); var statements; - if (parseExpected(18 /* OpenBraceToken */)) { - statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { statements = createMissingList(); @@ -37218,10 +37353,10 @@ var ts; function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) { // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 16 /* Namespace */; + var namespaceFlag = flags & 16 /* NodeFlags.Namespace */; var name = parseIdentifier(); - var body = parseOptional(24 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) + var body = parseOptional(24 /* SyntaxKind.DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NodeFlags.NestedNamespace */ | namespaceFlag) : parseModuleBlock(); var node = factory.createModuleDeclaration(modifiers, name, body, flags); node.decorators = decorators; @@ -37230,17 +37365,17 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); - flags |= 1024 /* GlobalAugmentation */; + flags |= 1024 /* NodeFlags.GlobalAugmentation */; } else { name = parseLiteralNode(); name.text = internIdentifier(name.text); } var body; - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { body = parseModuleBlock(); } else { @@ -37252,37 +37387,37 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(142 /* NamespaceKeyword */)) { - flags |= 16 /* Namespace */; + else if (parseOptional(142 /* SyntaxKind.NamespaceKeyword */)) { + flags |= 16 /* NodeFlags.Namespace */; } else { - parseExpected(141 /* ModuleKeyword */); - if (token() === 10 /* StringLiteral */) { + parseExpected(141 /* SyntaxKind.ModuleKeyword */); + if (token() === 10 /* SyntaxKind.StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 146 /* RequireKeyword */ && + return token() === 146 /* SyntaxKind.RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 20 /* OpenParenToken */; + return nextToken() === 20 /* SyntaxKind.OpenParenToken */; } function nextTokenIsOpenBrace() { - return nextToken() === 18 /* OpenBraceToken */; + return nextToken() === 18 /* SyntaxKind.OpenBraceToken */; } function nextTokenIsSlash() { - return nextToken() === 43 /* SlashToken */; + return nextToken() === 43 /* SyntaxKind.SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(127 /* AsKeyword */); - parseExpected(142 /* NamespaceKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); + parseExpected(142 /* SyntaxKind.NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -37292,7 +37427,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(100 /* ImportKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); var afterImportPos = scanner.getStartPos(); // We don't parse the identifier here in await context, instead we will report a grammar error in the checker. var identifier; @@ -37300,7 +37435,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 156 /* FromKeyword */ && + if (token() !== 156 /* SyntaxKind.FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -37314,15 +37449,15 @@ var ts; // import ModuleSpecifier; var importClause; if (identifier || // import id - token() === 41 /* AsteriskToken */ || // import * - token() === 18 /* OpenBraceToken */ // import { + token() === 41 /* SyntaxKind.AsteriskToken */ || // import * + token() === 18 /* SyntaxKind.OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); var assertClause; - if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37332,21 +37467,21 @@ var ts; } function parseAssertEntry() { var pos = getNodePos(); - var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */); - parseExpected(58 /* ColonToken */); + var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* SyntaxKind.StringLiteral */); + parseExpected(58 /* SyntaxKind.ColonToken */); var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { var pos = getNodePos(); if (!skipAssertKeyword) { - parseExpected(129 /* AssertKeyword */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); } var openBracePosition = scanner.getTokenPos(); - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + var elements = parseDelimitedList(24 /* ParsingContext.AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -37360,15 +37495,15 @@ var ts; } } function tokenAfterImportDefinitelyProducesImportDeclaration() { - return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */; + return token() === 41 /* SyntaxKind.AsteriskToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 156 /* FromKeyword */; + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 156 /* SyntaxKind.FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(63 /* EqualsToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(modifiers, isTypeOnly, identifier, moduleReference); @@ -37387,8 +37522,8 @@ var ts; // parse namespace or named imports var namedBindings; if (!identifier || - parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* NamedImports */); + parseOptional(27 /* SyntaxKind.CommaToken */)) { + namedBindings = token() === 41 /* SyntaxKind.AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* SyntaxKind.NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -37399,14 +37534,14 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(146 /* RequireKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(146 /* SyntaxKind.RequireKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = parseModuleSpecifier(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createExternalModuleReference(expression), pos); } function parseModuleSpecifier() { - if (token() === 10 /* StringLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -37422,8 +37557,8 @@ var ts; // NameSpaceImport: // * as ImportedBinding var pos = getNodePos(); - parseExpected(41 /* AsteriskToken */); - parseExpected(127 /* AsKeyword */); + parseExpected(41 /* SyntaxKind.AsteriskToken */); + parseExpected(127 /* SyntaxKind.AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -37436,17 +37571,17 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 269 /* NamedImports */ - ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) - : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); + var node = kind === 269 /* SyntaxKind.NamedImports */ + ? factory.createNamedImports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)) + : factory.createNamedExports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { var hasJSDoc = hasPrecedingJSDocComment(); - return withJSDoc(parseImportOrExportSpecifier(275 /* ExportSpecifier */), hasJSDoc); + return withJSDoc(parseImportOrExportSpecifier(275 /* SyntaxKind.ExportSpecifier */), hasJSDoc); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(270 /* ImportSpecifier */); + return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -37471,10 +37606,10 @@ var ts; // import { type as } from "mod"; - isTypeOnly: true, name: as // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as ...? } var firstAs = parseIdentifierName(); - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as as ...? } var secondAs = parseIdentifierName(); if (ts.tokenIsIdentifierOrKeyword(token())) { @@ -37509,15 +37644,15 @@ var ts; name = parseNameWithKeywordCheck(); } } - if (canParseAsKeyword && token() === 127 /* AsKeyword */) { + if (canParseAsKeyword && token() === 127 /* SyntaxKind.AsKeyword */) { propertyName = name; - parseExpected(127 /* AsKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); name = parseNameWithKeywordCheck(); } - if (kind === 270 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 270 /* SyntaxKind.ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 270 /* ImportSpecifier */ + var node = kind === 270 /* SyntaxKind.ImportSpecifier */ ? factory.createImportSpecifier(isTypeOnly, propertyName, name) : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); @@ -37537,26 +37672,26 @@ var ts; var exportClause; var moduleSpecifier; var assertClause; - var isTypeOnly = parseOptional(152 /* TypeKeyword */); + var isTypeOnly = parseOptional(152 /* SyntaxKind.TypeKeyword */); var namespaceExportPos = getNodePos(); - if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(127 /* AsKeyword */)) { + if (parseOptional(41 /* SyntaxKind.AsteriskToken */)) { + if (parseOptional(127 /* SyntaxKind.AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(273 /* NamedExports */); + exportClause = parseNamedImportsOrExports(273 /* SyntaxKind.NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 156 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(156 /* FromKeyword */); + if (token() === 156 /* SyntaxKind.FromKeyword */ || (token() === 10 /* SyntaxKind.StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } - if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (moduleSpecifier && token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37569,11 +37704,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(63 /* EqualsToken */)) { + if (parseOptional(63 /* SyntaxKind.EqualsToken */)) { isExportEquals = true; } else { - parseExpected(88 /* DefaultKeyword */); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); } var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); parseSemicolon(); @@ -37620,11 +37755,11 @@ var ts; var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState("file.js", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); - var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop); + var sourceFile = createSourceFile("file.js", 99 /* ScriptTarget.Latest */, 1 /* ScriptKind.JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* SyntaxKind.EndOfFileToken */), 0 /* NodeFlags.None */, ts.noop); var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); if (jsDocDiagnostics) { sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile); @@ -37636,10 +37771,10 @@ var ts; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { var pos = getNodePos(); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* SyntaxKind.OpenBraceToken */); + var type = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocTypeExpression(type); fixupParentReferences(result); @@ -37648,16 +37783,16 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocNameReference() { var pos = getNodePos(); - var hasBrace = parseOptional(18 /* OpenBraceToken */); + var hasBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var p2 = getNodePos(); var entityName = parseEntityName(/* allowReservedWords*/ false); - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); } if (hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocNameReference(entityName); fixupParentReferences(result); @@ -37665,9 +37800,9 @@ var ts; } JSDocParser.parseJSDocNameReference = parseJSDocNameReference; function parseIsolatedJSDocComment(content, start, length) { - initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); - var sourceFile = { languageVariant: 0 /* Standard */, text: content }; + initializeState("", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); + var jsDoc = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var sourceFile = { languageVariant: 0 /* LanguageVariant.Standard */, text: content }; var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -37677,9 +37812,9 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); ts.setParent(comment, parent); - if (contextFlags & 262144 /* JavaScriptFile */) { + if (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) { if (!jsDocDiagnostics) { jsDocDiagnostics = []; } @@ -37727,7 +37862,7 @@ var ts; return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. - var state = 1 /* SawAsterisk */; + var state = 1 /* JSDocState.SawAsterisk */; var margin; // + 4 for leading '/** ' // + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character @@ -37740,16 +37875,16 @@ var ts; indent += text.length; } nextTokenJSDoc(); - while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + while (parseOptionalJsdoc(5 /* SyntaxKind.WhitespaceTrivia */)) ; - if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { - state = 0 /* BeginningOfLine */; + if (parseOptionalJsdoc(4 /* SyntaxKind.NewLineTrivia */)) { + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; } loop: while (true) { switch (token()) { - case 59 /* AtToken */: - if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { + case 59 /* SyntaxKind.AtToken */: + if (state === 0 /* JSDocState.BeginningOfLine */ || state === 1 /* JSDocState.SawAsterisk */) { removeTrailingWhitespace(comments); if (!commentsPos) commentsPos = getNodePos(); @@ -37757,35 +37892,35 @@ var ts; // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning // for malformed examples like `/** @param {string} x @returns {number} the length */` - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; margin = undefined; } else { pushComment(scanner.getTokenText()); } break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: comments.push(scanner.getTokenText()); - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: var asterisk = scanner.getTokenText(); - if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { + if (state === 1 /* JSDocState.SawAsterisk */ || state === 2 /* JSDocState.SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(asterisk); } else { // Ignore the first asterisk on a line - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += asterisk.length; } break; - case 5 /* WhitespaceTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // only collect whitespace if we're already saving comments or have just crossed the comment indent margin var whitespace = scanner.getTokenText(); - if (state === 2 /* SavingComments */) { + if (state === 2 /* JSDocState.SavingComments */) { comments.push(whitespace); } else if (margin !== undefined && indent + whitespace.length > margin) { @@ -37793,10 +37928,10 @@ var ts; } indent += whitespace.length; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37815,7 +37950,7 @@ var ts; // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(scanner.getTokenText()); break; } @@ -37844,26 +37979,26 @@ var ts; // We must use infinite lookahead, as there could be any number of newlines :( while (true) { nextTokenJSDoc(); - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { return true; } - if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) { + if (!(token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */)) { return false; } } } function skipWhitespace() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } } - while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { nextTokenJSDoc(); } } function skipWhitespaceOrAsterisk() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return ""; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } @@ -37871,14 +38006,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* SyntaxKind.AsteriskToken */) || token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { indentText += scanner.getTokenText(); - if (token() === 4 /* NewLineTrivia */) { + if (token() === 4 /* SyntaxKind.NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 41 /* AsteriskToken */) { + else if (token() === 41 /* SyntaxKind.AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -37886,7 +38021,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -37935,7 +38070,7 @@ var ts; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, margin); + return parseParameterOrPropertyTag(start, tagName, 2 /* PropertyLikeParse.Parameter */, margin); case "return": case "returns": tag = parseReturnTag(start, tagName, margin, indentText); @@ -37973,7 +38108,7 @@ var ts; var comments = []; var parts = []; var linkEnd; - var state = 0 /* BeginningOfLine */; + var state = 0 /* JSDocState.BeginningOfLine */; var previousWhitespace = true; var margin; function pushComment(text) { @@ -37988,31 +38123,31 @@ var ts; if (initialMargin !== "") { pushComment(initialMargin); } - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; } var tok = token(); loop: while (true) { switch (tok) { - case 4 /* NewLineTrivia */: - state = 0 /* BeginningOfLine */; + case 4 /* SyntaxKind.NewLineTrivia */: + state = 0 /* JSDocState.BeginningOfLine */; // don't use pushComment here because we want to keep the margin unchanged comments.push(scanner.getTokenText()); indent = 0; break; - case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */ - || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { + case 59 /* SyntaxKind.AtToken */: + if (state === 3 /* JSDocState.SavingBackticks */ + || state === 2 /* JSDocState.SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace comments.push(scanner.getTokenText()); break; } scanner.setTextPos(scanner.getTextPos() - 1); // falls through - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // Done break loop; - case 5 /* WhitespaceTrivia */: - if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) { + case 5 /* SyntaxKind.WhitespaceTrivia */: + if (state === 2 /* JSDocState.SavingComments */ || state === 3 /* JSDocState.SavingBackticks */) { pushComment(scanner.getTokenText()); } else { @@ -38024,8 +38159,8 @@ var ts; indent += whitespace.length; } break; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -38039,32 +38174,32 @@ var ts; pushComment(scanner.getTokenText()); } break; - case 61 /* BacktickToken */: - if (state === 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; + case 61 /* SyntaxKind.BacktickToken */: + if (state === 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; } else { - state = 3 /* SavingBackticks */; + state = 3 /* JSDocState.SavingBackticks */; } pushComment(scanner.getTokenText()); break; - case 41 /* AsteriskToken */: - if (state === 0 /* BeginningOfLine */) { + case 41 /* SyntaxKind.AsteriskToken */: + if (state === 0 /* JSDocState.BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += 1; break; } // record the * as a comment // falls through default: - if (state !== 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; // leading identifiers start recording as well + if (state !== 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; // leading identifiers start recording as well } pushComment(scanner.getTokenText()); break; } - previousWhitespace = token() === 5 /* WhitespaceTrivia */; + previousWhitespace = token() === 5 /* SyntaxKind.WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); @@ -38081,7 +38216,7 @@ var ts; } function isNextJSDocTokenWhitespace() { var next = nextTokenJSDoc(); - return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + return next === 5 /* SyntaxKind.WhitespaceTrivia */ || next === 4 /* SyntaxKind.NewLineTrivia */; } function parseJSDocLink(start) { var linkType = tryParse(parseJSDocLinkPrefix); @@ -38096,14 +38231,14 @@ var ts; ? parseEntityName(/*allowReservedWords*/ true) : undefined; if (name) { - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); } } var text = []; - while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 19 /* SyntaxKind.CloseBraceToken */ && token() !== 4 /* SyntaxKind.NewLineTrivia */ && token() !== 1 /* SyntaxKind.EndOfFileToken */) { text.push(scanner.getTokenText()); nextTokenJSDoc(); } @@ -38114,8 +38249,8 @@ var ts; } function parseJSDocLinkPrefix() { skipWhitespaceOrAsterisk(); - if (token() === 18 /* OpenBraceToken */ - && nextTokenJSDoc() === 59 /* AtToken */ + if (token() === 18 /* SyntaxKind.OpenBraceToken */ + && nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { var kind = scanner.getTokenValue(); if (isJSDocLinkTag(kind)) @@ -38143,35 +38278,35 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* SyntaxKind.BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(61 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* SyntaxKind.BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(63 /* EqualsToken */)) { + if (parseOptionalToken(63 /* SyntaxKind.EqualsToken */)) { parseExpression(); } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -38187,12 +38322,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); - var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); + var nestedTypeLiteral = target !== 4 /* PropertyLikeParse.CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - var result = target === 1 /* Property */ + var result = target === 1 /* PropertyLikeParse.Property */ ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment); return finishNode(result, start); @@ -38203,12 +38338,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) { + if (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -38229,8 +38364,8 @@ var ts; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */ - || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); + var isMarkdownOrJSDocLink = token() === 22 /* SyntaxKind.OpenBracketToken */ + || lookAhead(function () { return nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference(); var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); @@ -38252,14 +38387,14 @@ var ts; var comments = []; var inEmail = false; var token = scanner.getToken(); - while (token !== 1 /* EndOfFileToken */ && token !== 4 /* NewLineTrivia */) { - if (token === 29 /* LessThanToken */) { + while (token !== 1 /* SyntaxKind.EndOfFileToken */ && token !== 4 /* SyntaxKind.NewLineTrivia */) { + if (token === 29 /* SyntaxKind.LessThanToken */) { inEmail = true; } - else if (token === 59 /* AtToken */ && !inEmail) { + else if (token === 59 /* SyntaxKind.AtToken */ && !inEmail) { break; } - else if (token === 31 /* GreaterThanToken */ && inEmail) { + else if (token === 31 /* SyntaxKind.GreaterThanToken */ && inEmail) { comments.push(scanner.getTokenText()); scanner.setTextPos(scanner.getTokenPos() + 1); break; @@ -38278,21 +38413,21 @@ var ts; return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(18 /* OpenBraceToken */); + var usedBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var pos = getNodePos(); var expression = parsePropertyAccessEntityNameExpression(); var typeArguments = tryParseTypeArguments(); var node = factory.createExpressionWithTypeArguments(expression, typeArguments); var res = finishNode(node, pos); if (usedBrace) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var pos = getNodePos(); var node = parseJSDocIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); node = finishNode(factory.createPropertyAccessExpression(node, name), pos); } @@ -38326,7 +38461,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 343 /* JSDocTypeTag */) { + if (child.kind === 343 /* SyntaxKind.JSDocTypeTag */) { if (childTypeTag) { var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { @@ -38343,7 +38478,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 183 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -38367,10 +38502,10 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(24 /* DotToken */)) { + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var body = parseJSDocTypeNameWithNamespace(/*nested*/ true); var jsDocNamespaceNode = factory.createModuleDeclaration( - /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NestedNamespace */ : undefined); + /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NodeFlags.NestedNamespace */ : undefined); return finishNode(jsDocNamespaceNode, pos); } if (nested) { @@ -38382,7 +38517,7 @@ var ts; var pos = getNodePos(); var child; var parameters; - while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { + while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* PropertyLikeParse.CallbackParameter */, indent); })) { parameters = ts.append(parameters, child); } return createNodeArray(parameters || [], pos); @@ -38393,9 +38528,9 @@ var ts; var comment = parseTagComments(indent); var parameters = parseCallbackTagParameters(indent); var returnTag = tryParse(function () { - if (parseOptionalJsdoc(59 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 341 /* JSDocReturnTag */) { + if (tag && tag.kind === 341 /* SyntaxKind.JSDocReturnTag */) { return tag; } } @@ -38420,18 +38555,18 @@ var ts; return a.escapedText === b.escapedText; } function parseChildPropertyTag(indent) { - return parseChildParameterOrPropertyTag(1 /* Property */, indent); + return parseChildParameterOrPropertyTag(1 /* PropertyLikeParse.Property */, indent); } function parseChildParameterOrPropertyTag(target, indent, name) { var canParseTag = true; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) && - target !== 4 /* CallbackParameter */ && + if (child && (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) && + target !== 4 /* PropertyLikeParse.CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -38439,26 +38574,26 @@ var ts; } seenAsterisk = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: canParseTag = true; seenAsterisk = false; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: canParseTag = false; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return false; } } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -38466,15 +38601,15 @@ var ts; var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(start, tagName); + return target === 1 /* PropertyLikeParse.Property */ && parseTypeTag(start, tagName); case "prop": case "property": - t = 1 /* Property */; + t = 1 /* PropertyLikeParse.Property */; break; case "arg": case "argument": case "param": - t = 2 /* Parameter */ | 4 /* CallbackParameter */; + t = 2 /* PropertyLikeParse.Parameter */ | 4 /* PropertyLikeParse.CallbackParameter */; break; default: return false; @@ -38486,7 +38621,7 @@ var ts; } function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } @@ -38494,9 +38629,9 @@ var ts; var defaultType; if (isBracketed) { skipWhitespace(); - parseExpected(63 /* EqualsToken */); - defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); - parseExpected(23 /* CloseBracketToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); + defaultType = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } if (ts.nodeIsMissing(name)) { return undefined; @@ -38513,7 +38648,7 @@ var ts; typeParameters.push(node); } skipWhitespaceOrAsterisk(); - } while (parseOptionalJsdoc(27 /* CommaToken */)); + } while (parseOptionalJsdoc(27 /* SyntaxKind.CommaToken */)); return createNodeArray(typeParameters, pos); } function parseTemplateTag(start, tagName, indent, indentText) { @@ -38528,7 +38663,7 @@ var ts; // TODO: Determine whether we should enforce this in the checker. // TODO: Consider moving the `constraint` to the first type parameter as we could then remove `getEffectiveConstraintOfTypeParameter`. // TODO: Consider only parsing a single type parameter if there is a constraint. - var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + var constraint = token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } @@ -38541,16 +38676,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); // Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking. // Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}> // but it's not worth it to enforce that restriction. } - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -38558,7 +38693,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -38575,7 +38710,7 @@ var ts; var IncrementalParser; (function (IncrementalParser) { function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */); checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); if (ts.textChangeRangeIsUnchanged(textChangeRange)) { // if the text didn't change, then we can just return our current source file as-is. @@ -38730,9 +38865,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 79 /* Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: return true; } return false; @@ -38806,10 +38941,10 @@ var ts; } function checkNodePositions(node, aggressiveChecks) { if (aggressiveChecks) { - var pos_2 = node.pos; + var pos_3 = node.pos; var visitNode_1 = function (child) { - ts.Debug.assert(child.pos >= pos_2); - pos_2 = child.end; + ts.Debug.assert(child.pos >= pos_3); + pos_3 = child.end; }; if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -38818,7 +38953,7 @@ var ts; } } forEachChild(node, visitNode_1); - ts.Debug.assert(pos_2 <= node.end); + ts.Debug.assert(pos_3 <= node.end); } } function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { @@ -38987,7 +39122,7 @@ var ts; var oldText = sourceFile.text; if (textChangeRange) { ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* AssertionLevel.VeryAggressive */)) { var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); var newTextPrefix = newText.substr(0, textChangeRange.span.start); ts.Debug.assert(oldTextPrefix === newTextPrefix); @@ -39002,7 +39137,7 @@ var ts; var currentArrayIndex = 0; ts.Debug.assert(currentArrayIndex < currentArray.length); var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; + var lastQueriedPosition = -1 /* InvalidPosition.Value */; return { currentNode: function (position) { // Only compute the current node if the position is different than the last time @@ -39040,7 +39175,7 @@ var ts; function findHighestListElementThatStartsAtPosition(position) { // Clear out any cached state about the last node we found. currentArray = undefined; - currentArrayIndex = -1 /* Value */; + currentArrayIndex = -1 /* InvalidPosition.Value */; current = undefined; // Recurse into the source file to find the highest node at this position. forEachChild(sourceFile, visitNode, visitArray); @@ -39220,18 +39355,18 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im; var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im; function extractPragmas(pragmas, range, text) { - var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); + var tripleSlash = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); if (tripleSlash) { var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks var pragma = ts.commentPragmas[name]; - if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) { + if (!pragma || !(pragma.kind & 1 /* PragmaKindFlags.TripleSlashXML */)) { return; } if (pragma.args) { @@ -39265,15 +39400,15 @@ var ts; } return; } - var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); + var singleLine = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); if (singleLine) { - return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); + return addPragmaForMatch(pragmas, range, 2 /* PragmaKindFlags.SingleLine */, singleLine); } - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { - addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch); + addPragmaForMatch(pragmas, range, 4 /* PragmaKindFlags.MultiLine */, multiLineMatch); } } } @@ -39316,10 +39451,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 79 /* Identifier */) { + if (lhs.kind === 79 /* SyntaxKind.Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 108 /* ThisKeyword */) { + if (lhs.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -39339,11 +39474,11 @@ var ts; defaultValueDescription: false, }; var jsxOptionMap = new ts.Map(ts.getEntries({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */, - "react-jsx": 4 /* ReactJSX */, - "react-jsxdev": 5 /* ReactJSXDev */, + "preserve": 1 /* JsxEmit.Preserve */, + "react-native": 3 /* JsxEmit.ReactNative */, + "react": 2 /* JsxEmit.React */, + "react-jsx": 4 /* JsxEmit.ReactJSX */, + "react-jsxdev": 5 /* JsxEmit.ReactJSXDev */, })); /* @internal */ ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) { @@ -39649,18 +39784,18 @@ var ts; name: "target", shortName: "t", type: new ts.Map(ts.getEntries({ - es3: 0 /* ES3 */, - es5: 1 /* ES5 */, - es6: 2 /* ES2015 */, - es2015: 2 /* ES2015 */, - es2016: 3 /* ES2016 */, - es2017: 4 /* ES2017 */, - es2018: 5 /* ES2018 */, - es2019: 6 /* ES2019 */, - es2020: 7 /* ES2020 */, - es2021: 8 /* ES2021 */, - es2022: 9 /* ES2022 */, - esnext: 99 /* ESNext */, + es3: 0 /* ScriptTarget.ES3 */, + es5: 1 /* ScriptTarget.ES5 */, + es6: 2 /* ScriptTarget.ES2015 */, + es2015: 2 /* ScriptTarget.ES2015 */, + es2016: 3 /* ScriptTarget.ES2016 */, + es2017: 4 /* ScriptTarget.ES2017 */, + es2018: 5 /* ScriptTarget.ES2018 */, + es2019: 6 /* ScriptTarget.ES2019 */, + es2020: 7 /* ScriptTarget.ES2020 */, + es2021: 8 /* ScriptTarget.ES2021 */, + es2022: 9 /* ScriptTarget.ES2022 */, + esnext: 99 /* ScriptTarget.ESNext */, })), affectsSourceFile: true, affectsModuleResolution: true, @@ -39670,7 +39805,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, - defaultValueDescription: 0 /* ES3 */, + defaultValueDescription: 0 /* ScriptTarget.ES3 */, }; /*@internal*/ ts.moduleOptionDeclaration = { @@ -39950,16 +40085,16 @@ var ts; { name: "importsNotUsedAsValues", type: new ts.Map(ts.getEntries({ - remove: 0 /* Remove */, - preserve: 1 /* Preserve */, - error: 2 /* Error */, + remove: 0 /* ImportsNotUsedAsValues.Remove */, + preserve: 1 /* ImportsNotUsedAsValues.Preserve */, + error: 2 /* ImportsNotUsedAsValues.Error */, })), affectsEmit: true, affectsSemanticDiagnostics: true, affectsMultiFileEmitBuildInfo: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, - defaultValueDescription: 0 /* Remove */, + defaultValueDescription: 0 /* ImportsNotUsedAsValues.Remove */, }, { name: "downlevelIteration", @@ -40414,8 +40549,8 @@ var ts; { name: "newLine", type: new ts.Map(ts.getEntries({ - crlf: 0 /* CarriageReturnLineFeed */, - lf: 1 /* LineFeed */ + crlf: 0 /* NewLineKind.CarriageReturnLineFeed */, + lf: 1 /* NewLineKind.LineFeed */ })), affectsEmit: true, affectsMultiFileEmitBuildInfo: true, @@ -40788,7 +40923,7 @@ var ts; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, - target: 3 /* ES2016 */, + target: 3 /* ScriptTarget.ES2016 */, strict: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, @@ -40813,8 +40948,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } /* @internal */ function parseCustomTypeOption(opt, value, errors) { @@ -40873,11 +41008,11 @@ var ts; while (i < args.length) { var s = args[i]; i++; - if (s.charCodeAt(0) === 64 /* at */) { + if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) { parseResponseFile(s.slice(1)); } - else if (s.charCodeAt(0) === 45 /* minus */) { - var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1); + else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) { + var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1); var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true); if (opt) { i = parseOptionValue(args, i, diagnostics, opt, options, errors); @@ -40906,14 +41041,14 @@ var ts; var args = []; var pos = 0; while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) + while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */) pos++; if (pos >= text.length) break; var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { + if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) { pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */) pos++; if (pos < text.length) { args.push(text.substring(start + 1, pos)); @@ -40924,7 +41059,7 @@ var ts; } } else { - while (text.charCodeAt(pos) > 32 /* space */) + while (text.charCodeAt(pos) > 32 /* CharacterCodes.space */) pos++; args.push(text.substring(start, pos)); } @@ -41259,7 +41394,7 @@ var ts; var _a; var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; - if (rootExpression && rootExpression.kind !== 205 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json")); // Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that @@ -41299,7 +41434,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 296 /* PropertyAssignment */) { + if (element.kind !== 296 /* SyntaxKind.PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -41366,16 +41501,16 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -41390,16 +41525,16 @@ var ts; } } return validateValue(text); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 219 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* SyntaxKind.MinusToken */ || valueExpression.operand.kind !== 8 /* SyntaxKind.NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -41416,7 +41551,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -41610,10 +41745,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -41664,19 +41799,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -41685,25 +41820,25 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); // Print out each row, aligning all the descriptions on the same column. for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -41758,7 +41893,7 @@ var ts; * file to. e.g. outDir */ function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -42108,8 +42243,8 @@ var ts; extendedConfig = ts.normalizeSlashes(extendedConfig); if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Extension.Json */)) { + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -42350,11 +42485,11 @@ var ts; var jsonOnlyIncludeRegexes; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { var _loop_6 = function (file) { - if (ts.fileExtensionIs(file, ".json" /* Json */)) { + if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { - var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Json */); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -42498,7 +42633,7 @@ var ts; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; - if (flags === 1 /* Recursive */) { + if (flags === 1 /* WatchDirectoryFlags.Recursive */) { recursiveKeys.push(key); } } @@ -42532,13 +42667,13 @@ var ts; key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) - ? 1 /* Recursive */ : 0 /* None */ + ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */ }; } if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) { return { key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)), - flags: 1 /* Recursive */ + flags: 1 /* WatchDirectoryFlags.Recursive */ }; } return undefined; @@ -42561,7 +42696,7 @@ var ts; } var higherPriorityPath = keyMapper(ts.changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { - if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) { + if (ext === ".d.ts" /* Extension.Dts */ && (ts.fileExtensionIs(file, ".js" /* Extension.Js */) || ts.fileExtensionIs(file, ".jsx" /* Extension.Jsx */))) { // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to // prevent breakage. @@ -42639,7 +42774,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -42795,7 +42930,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -42858,7 +42993,7 @@ var ts; var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); function arePathsEqual(path1, path2, host) { var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames; - return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */; + return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* Comparison.EqualTo */; } /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -43026,18 +43161,7 @@ var ts; * Does not try `@types/${packageName}` - use a second pass if needed. */ function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) { - var moduleResolutionState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ts.emptyArray, - features: NodeResolutionFeatures.None, - requestContainingDirectory: containingDirectory, - reportDiagnostic: ts.noop - }; + var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules"); @@ -43079,7 +43203,7 @@ var ts; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); // At this stage, skip results with leading dot. - if (baseFileName.charCodeAt(0) !== 46 /* dot */) { + if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) { // Return just the type directive names result.push(baseFileName); } @@ -43134,7 +43258,7 @@ var ts; ts.createCacheWithRedirects = createCacheWithRedirects; function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { var cache; - return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries }; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap }; function getPackageJsonInfo(packageJsonPath) { return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); } @@ -43148,6 +43272,9 @@ var ts; var iter = cache === null || cache === void 0 ? void 0 : cache.entries(); return iter ? ts.arrayFrom(iter) : []; } + function getInternalMap() { + return cache; + } } function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); @@ -43230,7 +43357,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -43251,21 +43378,24 @@ var ts; } ts.zipToModeAwareCache = zipToModeAwareCache; function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options)); var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); - moduleNameToDirectoryMap.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + } function update(options) { updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -43335,13 +43465,16 @@ var ts; } ts.createModuleResolutionCache = createModuleResolutionCache; function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + } } ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) { @@ -43412,10 +43545,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -43618,7 +43751,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -43767,7 +43900,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -43834,7 +43967,7 @@ var ts; } var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length; var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules); - if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) { + if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) { indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName); } return path.slice(0, indexAfterPackageName); @@ -43853,7 +43986,7 @@ var ts; */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { - var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); + var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Extension.Json */); var extension = extensionLess ? candidate.substring(extensionLess.length) : ""; return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } @@ -43870,7 +44003,7 @@ var ts; function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) { + if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Extension.Json */) && state.compilerOptions.resolveJsonModule)) { var extensionless = ts.removeFileExtension(candidate); var extension = candidate.substring(extensionless.length); if (state.traceEnabled) { @@ -43898,55 +44031,55 @@ var ts; switch (extensions) { case Extensions.DtsOnly: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); - default: return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".d.mts" /* Extension.Dmts */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".d.cts" /* Extension.Dcts */); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return tryExtension(".d.ts" /* Extension.Dts */); + default: return tryExtension(".d.ts" /* Extension.Dts */); } case Extensions.TypeScript: case Extensions.TsOnly: var useDts = extensions === Extensions.TypeScript; switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return useDts ? tryExtension(".d.ts" /* Dts */) : undefined; + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mts" /* Extension.Mts */) || (useDts ? tryExtension(".d.mts" /* Extension.Dmts */) : undefined); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cts" /* Extension.Cts */) || (useDts ? tryExtension(".d.cts" /* Extension.Dcts */) : undefined); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined; default: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined); + return tryExtension(".ts" /* Extension.Ts */) || tryExtension(".tsx" /* Extension.Tsx */) || (useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined); } case Extensions.JavaScript: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mjs" /* Mjs */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cjs" /* Cjs */); - case ".json" /* Json */: - return tryExtension(".json" /* Json */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mjs" /* Extension.Mjs */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cjs" /* Extension.Cjs */); + case ".json" /* Extension.Json */: + return tryExtension(".json" /* Extension.Json */); default: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js" /* Extension.Js */) || tryExtension(".jsx" /* Extension.Jsx */); } case Extensions.TSConfig: case Extensions.Json: - return tryExtension(".json" /* Json */); + return tryExtension(".json" /* Extension.Json */); } function tryExtension(ext) { var path = tryFile(candidate + ext, onlyRecordFailures, state); @@ -43997,18 +44130,9 @@ var ts; var entrypoints; var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript; var features = getDefaultNodeResolutionFeatures(options); - var requireState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ["node", "require", "types"], - features: features, - requestContainingDirectory: packageJsonInfo.packageDirectory, - reportDiagnostic: ts.noop - }; + var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); + requireState.conditions = ["node", "require", "types"]; + requireState.requestContainingDirectory = packageJsonInfo.packageDirectory; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path); @@ -44081,23 +44205,27 @@ var ts; } } } - /** - * A function for locating the package.json scope for a given path - */ /*@internal*/ - function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) { - var state = { + function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) { + return { host: host, compilerOptions: options, traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], + failedLookupLocations: ts.noopPush, + affectingLocations: ts.noopPush, packageJsonInfoCache: packageJsonInfoCache, - features: 0, - conditions: [], + features: NodeResolutionFeatures.None, + conditions: ts.emptyArray, requestContainingDirectory: undefined, reportDiagnostic: ts.noop }; + } + ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState; + /** + * A function for locating the package.json scope for a given path + */ + /*@internal*/ + function getPackageScopeForPath(fileName, state) { var parts = ts.getPathComponents(fileName); parts.pop(); while (parts.length > 0) { @@ -44235,16 +44363,16 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */; + return extension === ".js" /* Extension.Js */ || extension === ".jsx" /* Extension.Jsx */ || extension === ".mjs" /* Extension.Mjs */ || extension === ".cjs" /* Extension.Cjs */; case Extensions.TSConfig: case Extensions.Json: - return extension === ".json" /* Json */; + return extension === ".json" /* Extension.Json */; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */ || extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */ || extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; case Extensions.TsOnly: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */; + return extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; } } /* @internal */ @@ -44268,7 +44396,7 @@ var ts; var _a, _b; var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope || !scope.packageJsonContent.exports) { return undefined; } @@ -44281,7 +44409,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -44327,7 +44455,7 @@ var ts; } var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath); @@ -44350,6 +44478,7 @@ var ts; return toSearchResult(/*value*/ undefined); } /** + * @internal * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 - * "longest" has some nuance as to what "longest" means in the presence of pattern trailers */ @@ -44372,6 +44501,7 @@ var ts; return 1; return 0; } + ts.comparePatternKeys = comparePatternKeys; function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) { var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports); if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) { @@ -44579,7 +44709,7 @@ var ts; // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment); - var jsAndDtsExtensions = [".mjs" /* Mjs */, ".cjs" /* Cjs */, ".js" /* Js */, ".json" /* Json */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".d.ts" /* Dts */]; + var jsAndDtsExtensions = [".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */, ".js" /* Extension.Js */, ".json" /* Extension.Json */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".d.ts" /* Extension.Dts */]; for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) { var ext = jsAndDtsExtensions_1[_f]; if (ts.fileExtensionIs(possibleInputBase, ext)) { @@ -44764,7 +44894,7 @@ var ts; } /* @internal */ function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; /* @internal */ @@ -44910,14 +45040,14 @@ var ts; ts.setParent(node.body, node); ts.setParentRecursive(node.body, /*incremental*/ false); } - return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* ModuleInstanceState.Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateCached(node, visited) { if (visited === void 0) { visited = new ts.Map(); } var nodeId = ts.getNodeId(node); if (visited.has(nodeId)) { - return visited.get(nodeId) || 0 /* NonInstantiated */; + return visited.get(nodeId) || 0 /* ModuleInstanceState.NonInstantiated */; } visited.set(nodeId, undefined); var result = getModuleInstanceStateWorker(node, visited); @@ -44928,34 +45058,34 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return 0 /* NonInstantiated */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return 0 /* ModuleInstanceState.NonInstantiated */; // 2. const enum declarations - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (ts.isEnumConst(node)) { - return 2 /* ConstEnumOnly */; + return 2 /* ModuleInstanceState.ConstEnumOnly */; } break; // 3. non-exported import declarations - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { - return 0 /* NonInstantiated */; + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (!(ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { + return 0 /* ModuleInstanceState.NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* NamedExports */) { - var state = 0 /* NonInstantiated */; + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* SyntaxKind.NamedExports */) { + var state = 0 /* ModuleInstanceState.NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); if (specifierState > state) { state = specifierState; } - if (state === 1 /* Instantiated */) { + if (state === 1 /* ModuleInstanceState.Instantiated */) { return state; } } @@ -44963,21 +45093,21 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 262 /* ModuleBlock */: { - var state_1 = 0 /* NonInstantiated */; + case 262 /* SyntaxKind.ModuleBlock */: { + var state_1 = 0 /* ModuleInstanceState.NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); switch (childState) { - case 0 /* NonInstantiated */: + case 0 /* ModuleInstanceState.NonInstantiated */: // child is non-instantiated - continue searching return; - case 2 /* ConstEnumOnly */: + case 2 /* ModuleInstanceState.ConstEnumOnly */: // child is const enum only - record state and continue searching - state_1 = 2 /* ConstEnumOnly */; + state_1 = 2 /* ModuleInstanceState.ConstEnumOnly */; return; - case 1 /* Instantiated */: + case 1 /* ModuleInstanceState.Instantiated */: // child is instantiated - record state and stop - state_1 = 1 /* Instantiated */; + state_1 = 1 /* ModuleInstanceState.Instantiated */; return true; default: ts.Debug.assertNever(childState); @@ -44985,16 +45115,16 @@ var ts; }); return state_1; } - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { - return 0 /* NonInstantiated */; + return 0 /* ModuleInstanceState.NonInstantiated */; } } - return 1 /* Instantiated */; + return 1 /* ModuleInstanceState.Instantiated */; } function getModuleInstanceStateForAliasTarget(specifier, visited) { var name = specifier.propertyName || specifier.name; @@ -45014,7 +45144,7 @@ var ts; if (found === undefined || state > found) { found = state; } - if (found === 1 /* Instantiated */) { + if (found === 1 /* ModuleInstanceState.Instantiated */) { return found; } } @@ -45025,7 +45155,7 @@ var ts; } p = p.parent; } - return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + return 1 /* ModuleInstanceState.Instantiated */; // Couldn't locate, assume could refer to a value } var ContainerFlags; (function (ContainerFlags) { @@ -45099,8 +45229,8 @@ var ts; var symbolCount = 0; var Symbol; var classifiableNames; - var unreachableFlow = { flags: 1 /* Unreachable */ }; - var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; + var unreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; + var reportedUnreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); /** * Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file) @@ -45122,7 +45252,7 @@ var ts; ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* tracing.Phase.Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); bind(file); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); file.symbolCount = symbolCount; @@ -45149,7 +45279,7 @@ var ts; activeLabelList = undefined; hasExplicitReturn = false; inAssignmentPattern = false; - emitFlags = 0 /* None */; + emitFlags = 0 /* NodeFlags.None */; } return bindSourceFile; function bindInStrictMode(file, opts) { @@ -45169,33 +45299,33 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; symbol.declarations = ts.appendIfUnique(symbol.declarations, node); - if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } - if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && !symbol.members) { symbol.members = ts.createSymbolTable(); } // On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate) - if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { + if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { ts.setValueDeclaration(symbol, node); } } // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 271 /* ExportAssignment */) { - return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) { + return node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; } var name = ts.getNameOfDeclaration(node); if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -45221,36 +45351,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 171 /* Constructor */: - return "__constructor" /* Constructor */; - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - return "__call" /* Call */; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: - return "__new" /* New */; - case 176 /* IndexSignature */: - return "__index" /* Index */; - case 272 /* ExportDeclaration */: - return "__export" /* ExportStar */; - case 305 /* SourceFile */: + case 171 /* SyntaxKind.Constructor */: + return "__constructor" /* InternalSymbolName.Constructor */; + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + return "__call" /* InternalSymbolName.Call */; + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + return "__new" /* InternalSymbolName.New */; + case 176 /* SyntaxKind.IndexSignature */: + return "__index" /* InternalSymbolName.Index */; + case 272 /* SyntaxKind.ExportDeclaration */: + return "__export" /* InternalSymbolName.ExportStar */; + case 305 /* SyntaxKind.SourceFile */: // json file should behave as // module.exports = ... - return "export=" /* ExportEquals */; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { + return "export=" /* InternalSymbolName.ExportEquals */; + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */) { // module.exports = ... - return "export=" /* ExportEquals */; + return "export=" /* InternalSymbolName.ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 317 /* JSDocFunctionType */: - return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 164 /* Parameter */: + case 317 /* SyntaxKind.JSDocFunctionType */: + return (ts.isJSDocConstructSignature(node) ? "__new" /* InternalSymbolName.New */ : "__call" /* InternalSymbolName.Call */); + case 164 /* SyntaxKind.Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind), ", expected JSDocFunctionType"); }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -45269,14 +45399,14 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) { ts.Debug.assert(isComputedName || !ts.hasDynamicName(node)); - var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; + var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" - var name = isComputedName ? "__computed" /* Computed */ - : isDefaultExport && parent ? "default" /* Default */ + var name = isComputedName ? "__computed" /* InternalSymbolName.Computed */ + : isDefaultExport && parent ? "default" /* InternalSymbolName.Default */ : getDeclarationName(node); var symbol; if (name === undefined) { - symbol = createSymbol(0 /* None */, "__missing" /* Missing */); + symbol = createSymbol(0 /* SymbolFlags.None */, "__missing" /* InternalSymbolName.Missing */); } else { // Check and see if the symbol table already has a symbol with this name. If not, @@ -45303,11 +45433,11 @@ var ts; // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. symbol = symbolTable.get(name); - if (includes & 2885600 /* Classifiable */) { + if (includes & 2885600 /* SymbolFlags.Classifiable */) { classifiableNames.add(name); } if (!symbol) { - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); if (isReplaceableByMethod) symbol.isReplaceableByMethod = true; } @@ -45319,20 +45449,20 @@ var ts; if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); } - else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) { + else if (!(includes & 3 /* SymbolFlags.Variable */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { // Assignment declarations are allowed to merge with variables, no matter what other flags they have. if (ts.isNamedDeclaration(node)) { ts.setParent(node.name, node); } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message_1 = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; var messageNeedsName_1 = true; - if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ || includes & 384 /* SymbolFlags.Enum */) { message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; messageNeedsName_1 = false; } @@ -45352,7 +45482,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 271 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 271 /* SyntaxKind.ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -45360,9 +45490,9 @@ var ts; } } var relatedInformation_1 = []; - if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) && symbol.flags & (2097152 /* SymbolFlags.Alias */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { // export type T; - may have meant export type { T }? - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -45375,7 +45505,7 @@ var ts; }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false))); - symbol = createSymbol(0 /* None */, name); + symbol = createSymbol(0 /* SymbolFlags.None */, name); } } } @@ -45389,9 +45519,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); - if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 275 /* ExportSpecifier */ || (node.kind === 265 /* ImportEqualsDeclaration */ && hasExportModifier)) { + var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node); + if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -45415,11 +45545,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) { - if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) { + if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -45446,7 +45576,7 @@ var ts; return false; if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* ModifierFlags.Export */) return true; // This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should // already have calculated and branched on most of this. @@ -45479,21 +45609,21 @@ var ts; // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. - if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 214 /* ArrowFunction */) { + if (containerFlags & 1 /* ContainerFlags.IsContainer */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; - if (containerFlags & 32 /* HasLocals */) { + if (containerFlags & 32 /* ContainerFlags.HasLocals */) { container.locals = ts.createSymbolTable(); } addToContainerChain(container); } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { + else if (containerFlags & 2 /* ContainerFlags.IsBlockScopedContainer */) { blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (containerFlags & 4 /* IsControlFlowContainer */) { + if (containerFlags & 4 /* ContainerFlags.IsControlFlowContainer */) { var saveCurrentFlow = currentFlow; var saveBreakTarget = currentBreakTarget; var saveContinueTarget = currentContinueTarget; @@ -45501,22 +45631,22 @@ var ts; var saveExceptionTarget = currentExceptionTarget; var saveActiveLabelList = activeLabelList; var saveHasExplicitReturn = hasExplicitReturn; - var isImmediatelyInvoked = (containerFlags & 16 /* IsFunctionExpression */ && - !ts.hasSyntacticModifier(node, 256 /* Async */) && + var isImmediatelyInvoked = (containerFlags & 16 /* ContainerFlags.IsFunctionExpression */ && + !ts.hasSyntacticModifier(node, 256 /* ModifierFlags.Async */) && !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node)) || - node.kind === 170 /* ClassStaticBlockDeclaration */; + node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isImmediatelyInvoked) { - currentFlow = initFlowNode({ flags: 2 /* Start */ }); - if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); + if (containerFlags & (16 /* ContainerFlags.IsFunctionExpression */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { currentFlow.node = node; } } // 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 = isImmediatelyInvoked || node.kind === 171 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* SyntaxKind.Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -45524,21 +45654,21 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~2816 /* ReachabilityAndEmitFlags */; - if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 256 /* HasImplicitReturn */; + node.flags &= ~2816 /* NodeFlags.ReachabilityAndEmitFlags */; + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && containerFlags & 8 /* ContainerFlags.IsFunctionLike */ && ts.nodeIsPresent(node.body)) { + node.flags |= 256 /* NodeFlags.HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 512 /* HasExplicitReturn */; + node.flags |= 512 /* NodeFlags.HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 171 /* Constructor */ || node.kind === 170 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */))) { + if (node.kind === 171 /* SyntaxKind.Constructor */ || node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -45552,10 +45682,10 @@ var ts; activeLabelList = saveActiveLabelList; hasExplicitReturn = saveHasExplicitReturn; } - else if (containerFlags & 64 /* IsInterface */) { + else if (containerFlags & 64 /* ContainerFlags.IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* NodeFlags.ContainsThis */ : node.flags & ~128 /* NodeFlags.ContainsThis */; } else { bindChildren(node); @@ -45565,8 +45695,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -45589,59 +45719,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 237 /* FirstStatement */ && node.kind <= 253 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 237 /* SyntaxKind.FirstStatement */ && node.kind <= 253 /* SyntaxKind.LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: bindWhileStatement(node); break; - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: bindDoStatement(node); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: bindForStatement(node); break; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: bindForInOrForOfStatement(node); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: bindIfStatement(node); break; - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: bindReturnOrThrow(node); break; - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: bindTryStatement(node); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: bindSwitchStatement(node); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: bindCaseBlock(node); break; - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: bindCaseClause(node); break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: bindExpressionStatement(node); break; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: bindLabeledStatement(node); break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -45651,47 +45781,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bindCallExpressionFlow(node); break; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 305 /* SourceFile */: { + case 305 /* SyntaxKind.SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: bindBindingElementFlow(node); break; - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 296 /* PropertyAssignment */: - case 225 /* SpreadElement */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 225 /* SyntaxKind.SpreadElement */: // Carry over whether we are in an assignment pattern of Object and Array literals // as well as their children that are valid assignment targets. inAssignmentPattern = saveInAssignmentPattern; @@ -45705,22 +45835,22 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 108 /* ThisKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return containsNarrowableReference(expr); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return hasNarrowableArgument(expr); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isNarrowingExpression(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 219 /* PrefixUnaryExpression */: - return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 216 /* TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand); + case 216 /* SyntaxKind.TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -45728,7 +45858,7 @@ var ts; function isNarrowableReference(expr) { return ts.isDottedName(expr) || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) - || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(expr.right) || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } @@ -45744,7 +45874,7 @@ var ts; } } } - if (expr.expression.kind === 206 /* PropertyAccessExpression */ && + if (expr.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -45755,68 +45885,68 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return isNarrowingExpression(expr.right); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: return isNarrowableOperand(expr.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowableOperand(expr.right); } } return containsNarrowableReference(expr); } function createBranchLabel() { - return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); + return initFlowNode({ flags: 4 /* FlowFlags.BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); + return initFlowNode({ flags: 8 /* FlowFlags.LoopLabel */, antecedents: undefined }); } function createReduceLabel(target, antecedents, antecedent) { - return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); + return initFlowNode({ flags: 1024 /* FlowFlags.ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */; + flow.flags |= flow.flags & 2048 /* FlowFlags.Referenced */ ? 4096 /* FlowFlags.Shared */ : 2048 /* FlowFlags.Referenced */; } function addAntecedent(label, antecedent) { - if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { + if (!(antecedent.flags & 1 /* FlowFlags.Unreachable */) && !ts.contains(label.antecedents, antecedent)) { (label.antecedents || (label.antecedents = [])).push(antecedent); setFlowNodeReferenced(antecedent); } } function createFlowCondition(flags, antecedent, expression) { - if (antecedent.flags & 1 /* Unreachable */) { + if (antecedent.flags & 1 /* FlowFlags.Unreachable */) { return antecedent; } if (!expression) { - return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; + return flags & 32 /* FlowFlags.TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* SyntaxKind.TrueKeyword */ && flags & 64 /* FlowFlags.FalseCondition */ || + expression.kind === 95 /* SyntaxKind.FalseKeyword */ && flags & 32 /* FlowFlags.TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -45828,7 +45958,7 @@ var ts; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); + return initFlowNode({ flags: 128 /* FlowFlags.SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowMutation(flags, antecedent, node) { setFlowNodeReferenced(antecedent); @@ -45840,7 +45970,7 @@ var ts; } function createFlowCall(antecedent, node) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + return initFlowNode({ flags: 512 /* FlowFlags.Call */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -45855,28 +45985,28 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return parent.expression === node; - case 242 /* ForStatement */: - case 222 /* ConditionalExpression */: + case 242 /* SyntaxKind.ForStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 212 /* ParenthesizedExpression */) { + if (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 219 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && node.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.operand; } else { - return node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 56 /* BarBarToken */ || - node.operatorToken.kind === 60 /* QuestionQuestionToken */); + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || + node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */); } } } @@ -45886,7 +46016,7 @@ var ts; } function isTopLevelLogicalExpression(node) { while (ts.isParenthesizedExpression(node.parent) || - ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && @@ -45905,8 +46035,8 @@ var ts; function bindCondition(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindIterativeStatement(node, breakTarget, continueTarget) { @@ -45920,7 +46050,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 250 /* LabeledStatement */) { + while (label && node.parent.kind === 250 /* SyntaxKind.LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -45971,12 +46101,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 244 /* ForOfStatement */) { + if (node.kind === 244 /* SyntaxKind.ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 255 /* VariableDeclarationList */) { + if (node.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -45998,7 +46128,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 247 /* ReturnStatement */) { + if (node.kind === 247 /* SyntaxKind.ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -46015,7 +46145,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 246 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 246 /* SyntaxKind.BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -46086,7 +46216,7 @@ var ts; finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents); currentFlow = finallyLabel; bind(node.finallyBlock); - if (currentFlow.flags & 1 /* Unreachable */) { + if (currentFlow.flags & 1 /* FlowFlags.Unreachable */) { // If the end of the finally block is unreachable, the end of the entire try statement is unreachable. currentFlow = unreachableFlow; } @@ -46120,7 +46250,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* SyntaxKind.DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -46149,7 +46279,7 @@ var ts; var clause = clauses[i]; bind(clause); fallthroughFlow = currentFlow; - if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { clause.fallthroughFlowNode = currentFlow; } } @@ -46168,9 +46298,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { var call = node; - if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { + if (call.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -46194,7 +46324,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -46203,12 +46333,12 @@ var ts; } function bindAssignmentTargetFlow(node) { if (isNarrowableReference(node)) { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } - else if (node.kind === 204 /* ArrayLiteralExpression */) { + else if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 225 /* SpreadElement */) { + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -46216,16 +46346,16 @@ var ts; } } } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 296 /* PropertyAssignment */) { + if (p.kind === 296 /* SyntaxKind.PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 297 /* ShorthandPropertyAssignment */) { + else if (p.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 298 /* SpreadAssignment */) { + else if (p.kind === 298 /* SyntaxKind.SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -46233,7 +46363,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -46244,15 +46374,15 @@ var ts; if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) { doWithConditionalBranches(bind, node.right, trueTarget, falseTarget); bindAssignmentTargetFlow(node.left); - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } else { bindCondition(node.right, trueTarget, falseTarget); } } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 53 /* ExclamationToken */) { + if (node.operator === 53 /* SyntaxKind.ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -46262,14 +46392,14 @@ var ts; } else { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -46318,9 +46448,9 @@ var ts; // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too // For now, though, since the common cases are chained `+`, leaving it recursive is fine var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || - operator === 56 /* BarBarToken */ || - operator === 60 /* QuestionQuestionToken */ || + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + operator === 56 /* SyntaxKind.BarBarToken */ || + operator === 60 /* SyntaxKind.QuestionQuestionToken */ || ts.isLogicalOrCoalescingAssignmentOperator(operator)) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); @@ -46337,7 +46467,7 @@ var ts; function onLeft(left, state, node) { if (!state.skip) { var maybeBound = maybeBind(left); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(left); } return maybeBound; @@ -46351,7 +46481,7 @@ var ts; function onRight(right, state, node) { if (!state.skip) { var maybeBound = maybeBind(right); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(right); } return maybeBound; @@ -46362,10 +46492,10 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 63 /* EqualsToken */ && node.left.kind === 207 /* ElementAccessExpression */) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && node.left.kind === 207 /* SyntaxKind.ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } @@ -46390,7 +46520,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -46418,7 +46548,7 @@ var ts; } } else { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } } function bindVariableDeclarationFlow(node) { @@ -46445,7 +46575,7 @@ var ts; } function bindJSDocTypeAlias(node) { bind(node.tagName); - if (node.kind !== 339 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 339 /* SyntaxKind.JSDocEnumTag */ && node.fullName) { // don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); @@ -46457,28 +46587,28 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 169 /* MethodDeclaration */) { - addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + if (host && host.kind !== 169 /* SyntaxKind.MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* SymbolFlags.Class */); } } function bindOptionalExpression(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainRest(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -46504,8 +46634,8 @@ var ts; } doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); if (ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainFlow(node) { @@ -46543,76 +46673,76 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 213 /* FunctionExpression */ || expr.kind === 214 /* ArrowFunction */) { + if (expr.kind === 213 /* SyntaxKind.FunctionExpression */ || expr.kind === 214 /* SyntaxKind.ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } function getContainerFlags(node) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 286 /* JsxAttributes */: - return 1 /* IsContainer */; - case 258 /* InterfaceDeclaration */: - return 1 /* IsContainer */ | 64 /* IsInterface */; - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: - case 176 /* IndexSignature */: - return 1 /* IsContainer */ | 32 /* HasLocals */; - case 305 /* SourceFile */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 286 /* SyntaxKind.JsxAttributes */: + return 1 /* ContainerFlags.IsContainer */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */; + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: + case 176 /* SyntaxKind.IndexSignature */: + return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */; + case 305 /* SyntaxKind.SourceFile */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */; + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */; } // falls through - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 317 /* JSDocFunctionType */: - case 179 /* FunctionType */: - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: - case 170 /* ClassStaticBlockDeclaration */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 262 /* ModuleBlock */: - return 4 /* IsControlFlowContainer */; - case 167 /* PropertyDeclaration */: - return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 292 /* CatchClause */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 263 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 235 /* Block */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 179 /* SyntaxKind.FunctionType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */; + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 16 /* ContainerFlags.IsFunctionExpression */; + case 262 /* SyntaxKind.ModuleBlock */: + return 4 /* ContainerFlags.IsControlFlowContainer */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return node.initializer ? 4 /* ContainerFlags.IsControlFlowContainer */ : 0; + case 292 /* SyntaxKind.CatchClause */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 263 /* SyntaxKind.CaseBlock */: + return 2 /* ContainerFlags.IsBlockScopedContainer */; + case 235 /* SyntaxKind.Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -46629,9 +46759,9 @@ var ts; // By not creating a new block-scoped-container here, we ensure that both 'var x' // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. - return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* ContainerFlags.None */ : 2 /* ContainerFlags.IsBlockScopedContainer */; } - return 0 /* None */; + return 0 /* ContainerFlags.None */; } function addToContainerChain(next) { if (lastContainer) { @@ -46645,46 +46775,46 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 205 /* ObjectLiteralExpression */: - case 258 /* InterfaceDeclaration */: - case 286 /* JsxAttributes */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 286 /* SyntaxKind.JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 323 /* JSDocSignature */: - case 176 /* IndexSignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 317 /* JSDocFunctionType */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 170 /* ClassStaticBlockDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -46711,17 +46841,17 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 64 /* ExportContext */; + if (node.flags & 16777216 /* NodeFlags.Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* NodeFlags.ExportContext */; } else { - node.flags &= ~64 /* ExportContext */; + node.flags &= ~64 /* NodeFlags.ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isModuleAugmentationExternal(node)) { @@ -46729,25 +46859,25 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 10 /* StringLiteral */) { + if (node.name.kind === 10 /* SyntaxKind.StringLiteral */) { var text = node.name.text; pattern = ts.tryParsePattern(text); if (pattern === undefined) { errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); } } - var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */); + var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* SymbolFlags.ValueModule */, 110735 /* SymbolFlags.ValueModuleExcludes */); file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { var state = declareModuleSymbol(node); - if (state !== 0 /* NonInstantiated */) { + if (state !== 0 /* ModuleInstanceState.NonInstantiated */) { var symbol = node.symbol; // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only - symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) + symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) // Current must be `const enum` only - && state === 2 /* ConstEnumOnly */ + && state === 2 /* ModuleInstanceState.ConstEnumOnly */ // Can't have been set to 'false' in a previous merged symbol. ('undefined' OK) && symbol.constEnumOnlyModule !== false; } @@ -46755,8 +46885,8 @@ var ts; } function declareModuleSymbol(node) { var state = getModuleInstanceState(node); - var instantiated = state !== 0 /* NonInstantiated */; - declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + var instantiated = state !== 0 /* ModuleInstanceState.NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* SymbolFlags.ValueModule */ : 1024 /* SymbolFlags.NamespaceModule */, instantiated ? 110735 /* SymbolFlags.ValueModuleExcludes */ : 0 /* SymbolFlags.NamespaceModuleExcludes */); return state; } function bindFunctionOrConstructorType(node) { @@ -46766,56 +46896,25 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + var symbol = createSymbol(131072 /* SymbolFlags.Signature */, getDeclarationName(node)); // TODO: GH#18217 + addDeclarationToSymbol(symbol, node, 131072 /* SymbolFlags.Signature */); + var typeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* SymbolFlags.TypeLiteral */); typeLiteralSymbol.members = ts.createSymbolTable(); typeLiteralSymbol.members.set(symbol.escapedName, symbol); } function bindObjectLiteralExpression(node) { - var ElementKind; - (function (ElementKind) { - ElementKind[ElementKind["Property"] = 1] = "Property"; - ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; - })(ElementKind || (ElementKind = {})); - if (inStrictMode && !ts.isAssignmentTarget(node)) { - var seen = new ts.Map(); - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { - continue; - } - var identifier = prop.name; - // ECMA-262 11.1.5 Object Initializer - // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true - // a.This production is contained in strict code and IsDataDescriptor(previous) is true and - // IsDataDescriptor(propId.descriptor) is true. - // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. - // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. - // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true - // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; - var existingKind = seen.get(identifier.escapedText); - if (!existingKind) { - seen.set(identifier.escapedText, currentKind); - continue; - } - } - } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__object" /* InternalSymbolName.Object */); } function bindJsxAttributes(node) { - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__jsxAttributes" /* InternalSymbolName.JSXAttributes */); } function bindJsxAttribute(node, symbolFlags, symbolExcludes) { return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); - if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) { + if (symbolFlags & (8 /* SymbolFlags.EnumMember */ | 106500 /* SymbolFlags.ClassMember */)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); @@ -46823,10 +46922,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -46852,9 +46951,9 @@ var ts; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; var host = typeAlias.parent.parent; - container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* ContainerFlags.IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = initFlowNode({ flags: 2 /* Start */ }); + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -46865,8 +46964,8 @@ var ts; bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: if (!ts.isExternalOrCommonJsModule(file)) { container = undefined; } @@ -46874,29 +46973,29 @@ var ts; container = file; } break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: container = declName.parent.expression; break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: container = declName.parent.expression.name; break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } if (container) { - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + declareModuleMember(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* SyntaxKind.Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -46914,24 +47013,24 @@ var ts; function checkContextualIdentifier(node) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length && - !(node.flags & 16777216 /* Ambient */) && - !(node.flags & 8388608 /* JSDoc */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && + !(node.flags & 8388608 /* NodeFlags.JSDoc */) && !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 132 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); } - else if (node.flags & 32768 /* AwaitContext */) { + else if (node.flags & 32768 /* NodeFlags.AwaitContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } - else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -46973,7 +47072,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 79 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* SyntaxKind.Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -46984,7 +47083,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 79 /* Identifier */) { + if (name && name.kind === 79 /* SyntaxKind.Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -47023,10 +47122,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 305 /* SourceFile */ && - blockScopeContainer.kind !== 261 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ && + blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -47036,7 +47135,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -47052,7 +47151,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -47065,7 +47164,7 @@ var ts; } function checkStrictModeLabeledStatement(node) { // Grammar checking for labeledStatement - if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) { + if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ScriptTarget.ES2015 */) { if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) { errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here); } @@ -47123,11 +47222,11 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 160 /* LastToken */) { + if (node.kind > 160 /* SyntaxKind.LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); - if (containerFlags === 0 /* None */) { + if (containerFlags === 0 /* ContainerFlags.None */) { bindChildren(node); } else { @@ -47137,7 +47236,7 @@ var ts; } else { var saveParent = parent; - if (node.kind === 1 /* EndOfFileToken */) + if (node.kind === 1 /* SyntaxKind.EndOfFileToken */) parent = node; bindJSDoc(node); parent = saveParent; @@ -47185,7 +47284,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -47194,28 +47293,28 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); break; } // falls through - case 108 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* ShorthandPropertyAssignment */)) { + case 108 /* SyntaxKind.ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 231 /* MetaProperty */: - case 106 /* SuperKeyword */: + case 231 /* SyntaxKind.MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: node.flowNode = currentFlow; break; - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifier(node); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -47227,28 +47326,28 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForName(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* SymbolFlags.FunctionScopedVariable */ | 134217728 /* SymbolFlags.ModuleExports */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { - case 1 /* ExportsProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: bindExportsPropertyAssignment(node); break; - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: bindModuleExportsAssignment(node); break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: bindPrototypePropertyAssignment(node.left, node); break; - case 6 /* Prototype */: + case 6 /* AssignmentDeclarationKind.Prototype */: bindPrototypeAssignment(node); break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: bindThisPropertyAssignment(node); break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: var expression = node.left.expression; if (ts.isInJSFile(node) && ts.isIdentifier(expression)) { var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText); @@ -47259,94 +47358,94 @@ var ts; } bindSpecialPropertyAssignment(node); break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: // Nothing to do break; default: ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return checkStrictModeCatchClause(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkStrictModeWithStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: seenThisKeyword = true; return; - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: break; // Binding the children will handle everything - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return bindTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return bindParameter(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return bindPropertyWorker(node); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 299 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); + case 299 /* SyntaxKind.EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */); + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */); + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 256 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), ts.isObjectLiteralMethod(node) ? 0 /* SymbolFlags.PropertyExcludes */ : 103359 /* SymbolFlags.MethodExcludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: return bindFunctionDeclaration(node); - case 171 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 172 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 173 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: - case 180 /* ConstructorType */: + case 171 /* SyntaxKind.Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, /*symbolExcludes:*/ 0 /* SymbolFlags.None */); + case 172 /* SyntaxKind.GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46015 /* SymbolFlags.GetAccessorExcludes */); + case 173 /* SyntaxKind.SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78783 /* SymbolFlags.SetAccessorExcludes */); + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: + case 180 /* SyntaxKind.ConstructorType */: return bindFunctionOrConstructorType(node); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 195 /* MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 195 /* SyntaxKind.MappedType */: return bindAnonymousTypeWorker(node); - case 332 /* JSDocClassTag */: + case 332 /* SyntaxKind.JSDocClassTag */: return bindJSDocClassTag(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return bindFunctionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { - case 7 /* ObjectDefinePropertyValue */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: return bindObjectDefinePropertyAssignment(node); - case 8 /* ObjectDefinePropertyExports */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: return bindObjectDefinePropertyExport(node); - case 9 /* ObjectDefinePrototypeProperty */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return bindObjectDefinePrototypeProperty(node); - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: break; // Nothing to do default: return ts.Debug.fail("Unknown call expression assignment declaration kind"); @@ -47356,73 +47455,73 @@ var ts; } break; // Members of classes, interfaces, and modules - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 258 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 259 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 260 /* EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */); + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); + case 260 /* SyntaxKind.EnumDeclaration */: return bindEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return bindJsxAttributes(node); - case 285 /* JsxAttribute */: - return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); + case 285 /* SyntaxKind.JsxAttribute */: + return bindJsxAttribute(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); // Imports and exports - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 264 /* NamespaceExportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return bindImportClause(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return bindExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return bindExportAssignment(node); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 340 /* JSDocParameterTag */: - if (node.parent.kind === 323 /* JSDocSignature */) { + case 340 /* SyntaxKind.JSDocParameterTag */: + if (node.parent.kind === 323 /* SyntaxKind.JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 322 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 322 /* SyntaxKind.JSDocTypeLiteral */) { break; } // falls through - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; - return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ ? + 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */ : + 4 /* SymbolFlags.Property */; + return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* SymbolFlags.PropertyExcludes */); + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } function bindPropertyWorker(node) { - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } function bindAnonymousTypeWorker(node) { - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */); + return bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); } function bindSourceFileIfExternalModule() { setExportContextFlag(file); @@ -47433,27 +47532,27 @@ var ts; bindSourceFileAsExternalModule(); // Create symbol equivalent for the module.exports = {} var originalSymbol = file.symbol; - declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */); + declareSymbol(file.symbol.exports, file.symbol, file, 4 /* SymbolFlags.Property */, 67108863 /* SymbolFlags.All */); file.symbol = originalSymbol; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512 /* SymbolFlags.ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { // Incorrect export assignment in some sort of block construct - bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 111551 /* SymbolFlags.Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ + ? 2097152 /* SymbolFlags.Alias */ // An export default clause with any other expression exports a value - : 4 /* Property */; + : 4 /* SymbolFlags.Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) - var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); + var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* SymbolFlags.All */); if (node.isExportEquals) { // Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set. ts.setValueDeclaration(symbol, node); @@ -47473,28 +47572,28 @@ var ts; } else { file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable(); - declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 8388608 /* SymbolFlags.ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */); } else if (ts.isNamespaceExport(node.exportClause)) { // declareSymbol walks up parents to find name text, parent _must_ be set // but won't be set by the normal binder walk until `bindChildren` later on. ts.setParent(node.exportClause, node); - declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindImportClause(node) { if (node.name) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function setCommonJsModuleIndicator(node) { @@ -47515,13 +47614,13 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { - var flags = 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + var flags = 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* SymbolFlags.None */); } } function bindExportsPropertyAssignment(node) { @@ -47532,15 +47631,15 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression)); - var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */; + var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; ts.setParent(node.left, node); - declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */); } } function bindModuleExportsAssignment(node) { @@ -47561,13 +47660,13 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + ? 2097152 /* SymbolFlags.Alias */ + : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */ | 512 /* SymbolFlags.ValueModule */; + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); ts.setValueDeclaration(symbol, node); } function bindExportAssignedObjectMemberAlias(node) { - declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); @@ -47579,11 +47678,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -47597,17 +47696,17 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); } else { - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */); } - addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } break; - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -47616,19 +47715,19 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); } else { - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true); } break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; } else if (thisContainer.commonJsModuleIndicator) { - declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); + declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; default: @@ -47636,7 +47735,7 @@ var ts; } } function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) { - declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); + declareSymbol(symbolTable, symbol, node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); addLateBoundAssignmentDeclarationToSymbol(node, symbol); } function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { @@ -47645,10 +47744,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 108 /* ThisKeyword */) { + if (node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -47667,7 +47766,7 @@ var ts; var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); if (namespaceSymbol && namespaceSymbol.valueDeclaration) { // Ensure the namespace symbol becomes class-like - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } @@ -47688,7 +47787,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 305 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -47700,7 +47799,7 @@ var ts; return; } var rootExpr = ts.getLeftmostAccessExpression(node.left); - if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) { + if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* SymbolFlags.Alias */) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them @@ -47713,7 +47812,7 @@ var ts; bindExportsPropertyAssignment(node); } else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + bindAnonymousDeclaration(node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, "__computed" /* InternalSymbolName.Computed */); var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); addLateBoundAssignmentDeclarationToSymbol(node, sym); } @@ -47731,13 +47830,13 @@ var ts; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { - if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) { + if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* SymbolFlags.Alias */) { return namespaceSymbol; } if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers - var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */; - var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; + var flags_2 = 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */; + var excludeFlags_1 = 110735 /* SymbolFlags.ValueModuleExcludes */ & ~67108864 /* SymbolFlags.Assignment */; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_2); @@ -47751,7 +47850,7 @@ var ts; }); } if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } return namespaceSymbol; } @@ -47763,12 +47862,12 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var includes = 0 /* None */; - var excludes = 0 /* None */; + var includes = 0 /* SymbolFlags.None */; + var excludes = 0 /* SymbolFlags.None */; // Method-like if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { - includes = 8192 /* Method */; - excludes = 103359 /* MethodExcludes */; + includes = 8192 /* SymbolFlags.Method */; + excludes = 103359 /* SymbolFlags.MethodExcludes */; } // Maybe accessor-like else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { @@ -47778,27 +47877,27 @@ var ts; })) { // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) - includes |= 65536 /* SetAccessor */ | 4 /* Property */; - excludes |= 78783 /* SetAccessorExcludes */; + includes |= 65536 /* SymbolFlags.SetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 78783 /* SymbolFlags.SetAccessorExcludes */; } if (ts.some(declaration.arguments[2].properties, function (p) { var id = ts.getNameOfDeclaration(p); return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; })) { - includes |= 32768 /* GetAccessor */ | 4 /* Property */; - excludes |= 46015 /* GetAccessorExcludes */; + includes |= 32768 /* SymbolFlags.GetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 46015 /* SymbolFlags.GetAccessorExcludes */; } } - if (includes === 0 /* None */) { - includes = 4 /* Property */; - excludes = 0 /* PropertyExcludes */; + if (includes === 0 /* SymbolFlags.None */) { + includes = 4 /* SymbolFlags.Property */; + excludes = 0 /* SymbolFlags.PropertyExcludes */; } - declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* SymbolFlags.Assignment */, excludes & ~67108864 /* SymbolFlags.Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SourceFile */ - : propertyAccess.parent.parent.kind === 305 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SyntaxKind.SourceFile */ + : propertyAccess.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -47817,7 +47916,7 @@ var ts; * - with non-empty object literals if assigned to the prototype property */ function isExpandoSymbol(symbol) { - if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 1024 /* SymbolFlags.NamespaceModule */)) { return true; } var node = symbol.valueDeclaration; @@ -47832,7 +47931,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || init.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -47877,12 +47976,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 257 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); + if (node.kind === 257 /* SyntaxKind.ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */); } else { - var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__class" /* InternalSymbolName.Class */; + bindAnonymousDeclaration(node, 32 /* SymbolFlags.Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { classifiableNames.add(node.name.escapedText); @@ -47898,7 +47997,7 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype"); + var prototypeSymbol = createSymbol(4 /* SymbolFlags.Property */ | 4194304 /* SymbolFlags.Prototype */, "prototype"); var symbolExport = symbol.exports.get(prototypeSymbol.escapedName); if (symbolExport) { if (node.name) { @@ -47911,23 +48010,23 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent; + var possibleVariableDecl = node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node : node.parent.parent; if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !ts.getJSDocTypeTag(node) && - !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) { + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); + bindBlockScopedDeclaration(node, 2 /* SymbolFlags.BlockScopedVariable */, 111551 /* SymbolFlags.BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -47939,72 +48038,72 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) { + if (node.kind === 340 /* SyntaxKind.JSDocParameterTag */ && container.kind !== 323 /* SyntaxKind.JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) { + if (inStrictMode && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); + bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } if (currentFlow) { node.flowNode = currentFlow; } checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.escapedText : "__function" /* Function */; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__function" /* InternalSymbolName.Function */; + return bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { node.flowNode = currentFlow; } return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* InternalSymbolName.Computed */) : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function getInferTypeContainer(node) { @@ -48018,45 +48117,45 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } - else if (node.parent.kind === 190 /* InferType */) { + else if (node.parent.kind === 190 /* SyntaxKind.InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 + bindAnonymousDeclaration(node, 262144 /* SymbolFlags.TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); + return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { - if (!(currentFlow.flags & 1 /* Unreachable */)) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) { return false; } if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) || // report error on class declarations - node.kind === 257 /* ClassDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 261 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -48070,9 +48169,9 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 16777216 /* Ambient */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && (!ts.isVariableStatement(node) || - !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); }); } @@ -48096,27 +48195,28 @@ var ts; // Don't remove statements that can validly be used before they appear. return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) && // `var x;` may declare a variable used above - !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); + !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* NodeFlags.Let */ | 2 /* NodeFlags.Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 261 /* ModuleDeclaration */: - return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 260 /* EnumDeclaration */: - return ts.hasSyntacticModifier(s, 2048 /* Const */); + case 261 /* SyntaxKind.ModuleDeclaration */: + return getModuleInstanceState(s) !== 1 /* ModuleInstanceState.Instantiated */; + case 260 /* SyntaxKind.EnumDeclaration */: + return ts.hasSyntacticModifier(s, 2048 /* ModifierFlags.Const */); default: return false; } } function isExportsOrModuleExportsOrAlias(sourceFile, node) { var i = 0; - var q = [node]; - while (q.length && i < 100) { + var q = ts.createQueue(); + q.enqueue(node); + while (!q.isEmpty() && i < 100) { i++; - node = q.shift(); + node = q.dequeue(); if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } @@ -48124,10 +48224,10 @@ var ts; var symbol = lookupSymbolForName(sourceFile, node.escapedText); if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) { var init = symbol.valueDeclaration.initializer; - q.push(init); + q.enqueue(init); if (ts.isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) { - q.push(init.left); - q.push(init.right); + q.enqueue(init.left); + q.enqueue(init.right); } } } @@ -48191,32 +48291,32 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var objectType = type; var objectFlags = objectType.objectFlags; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { visitTypeReference(type); } - if (objectFlags & 32 /* Mapped */) { + if (objectFlags & 32 /* ObjectFlags.Mapped */) { visitMappedType(type); } - if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + if (objectFlags & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { visitInterfaceType(type); } - if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + if (objectFlags & (8 /* ObjectFlags.Tuple */ | 16 /* ObjectFlags.Anonymous */)) { visitObjectType(objectType); } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { visitIndexType(type); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { visitIndexedAccessType(type); } } @@ -48305,7 +48405,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 181 /* TypeQuery */) { + if (d.type && d.type.kind === 181 /* SyntaxKind.TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -48442,16 +48542,16 @@ var ts; // Masks TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask"; TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask"; - })(TypeFacts || (TypeFacts = {})); + })(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {})); var typeofNEFacts = new ts.Map(ts.getEntries({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ + string: 256 /* TypeFacts.TypeofNEString */, + number: 512 /* TypeFacts.TypeofNENumber */, + bigint: 1024 /* TypeFacts.TypeofNEBigInt */, + boolean: 2048 /* TypeFacts.TypeofNEBoolean */, + symbol: 4096 /* TypeFacts.TypeofNESymbol */, + undefined: 524288 /* TypeFacts.NEUndefined */, + object: 8192 /* TypeFacts.TypeofNEObject */, + function: 16384 /* TypeFacts.TypeofNEFunction */ })); var TypeSystemPropertyName; (function (TypeSystemPropertyName) { @@ -48477,7 +48577,7 @@ var ts; CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement"; // e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`, // we need to preserve generic types instead of substituting them for constraints - })(CheckMode || (CheckMode = {})); + })(CheckMode = ts.CheckMode || (ts.CheckMode = {})); var SignatureCheckMode; (function (SignatureCheckMode) { SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback"; @@ -48485,7 +48585,7 @@ var ts; SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes"; SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity"; SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback"; - })(SignatureCheckMode || (SignatureCheckMode = {})); + })(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {})); var IntersectionState; (function (IntersectionState) { IntersectionState[IntersectionState["None"] = 0] = "None"; @@ -48557,10 +48657,10 @@ var ts; IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize"; })(IntrinsicTypeKind || (IntrinsicTypeKind = {})); var intrinsicTypeKinds = new ts.Map(ts.getEntries({ - Uppercase: 0 /* Uppercase */, - Lowercase: 1 /* Lowercase */, - Capitalize: 2 /* Capitalize */, - Uncapitalize: 3 /* Uncapitalize */ + Uppercase: 0 /* IntrinsicTypeKind.Uppercase */, + Lowercase: 1 /* IntrinsicTypeKind.Lowercase */, + Capitalize: 2 /* IntrinsicTypeKind.Capitalize */, + Uncapitalize: 3 /* IntrinsicTypeKind.Uncapitalize */ })); function SymbolLinks() { } @@ -48585,8 +48685,8 @@ var ts; ts.getSymbolId = getSymbolId; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + return moduleState === 1 /* ModuleInstanceState.Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ModuleInstanceState.ConstEnumOnly */); } ts.isInstantiatedModule = isInstantiatedModule; function createTypeChecker(host) { @@ -48601,7 +48701,7 @@ var ts; return; sf.resolvedModules.forEach(function (r) { if (r && r.packageId) - map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name)); + map.set(r.packageId.name, r.extension === ".d.ts" /* Extension.Dts */ || !!map.get(r.packageId.name)); }); }); return map; @@ -48635,7 +48735,7 @@ var ts; var currentNode; var varianceTypeParameter; var emptySymbols = ts.createSymbolTable(); - var arrayVariances = [1 /* Covariant */]; + var arrayVariances = [1 /* VarianceFlags.Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -48649,20 +48749,20 @@ var ts; var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* ObjectFlags.FreshLiteral */; var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); - var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); + var undefinedSymbol = createSymbol(4 /* SymbolFlags.Property */, "undefined"); undefinedSymbol.declarations = []; - var globalThisSymbol = createSymbol(1536 /* Module */, "globalThis", 8 /* Readonly */); + var globalThisSymbol = createSymbol(1536 /* SymbolFlags.Module */, "globalThis", 8 /* CheckFlags.Readonly */); globalThisSymbol.exports = globals; globalThisSymbol.declarations = []; globals.set(globalThisSymbol.escapedName, globalThisSymbol); - var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); - var requireSymbol = createSymbol(4 /* Property */, "require"); + var argumentsSymbol = createSymbol(4 /* SymbolFlags.Property */, "arguments"); + var requireSymbol = createSymbol(4 /* SymbolFlags.Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; // for public members that accept a Node or one of its subtypes, we must guard against @@ -48714,10 +48814,10 @@ var ts; return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined; }, getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, - getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexInfosOfType: getIndexInfosOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexType: function (type) { return getIndexType(type); }, getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, @@ -48812,14 +48912,14 @@ var ts; if (!node) { return undefined; } - if (contextFlags & 4 /* Completions */) { + if (contextFlags & 4 /* ContextFlags.Completions */) { return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); }); } return getContextualType(node, contextFlags); }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); - return node ? getContextualTypeForObjectLiteralElement(node) : undefined; + return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined; }, getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); @@ -48827,19 +48927,19 @@ var ts; }, getContextualTypeForJsxAttribute: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); - return node && getContextualTypeForJsxAttribute(node); + return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined); }, isContextSensitive: isContextSensitive, getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* CheckMode.Normal */); }, getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) { - return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument); + return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* CheckMode.IsForStringLiteralArgumentCompletions */, editingArgument); }, getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* CheckMode.IsForSignatureHelp */); }, getExpandedParameters: getExpandedParameters, hasEffectiveRestParameter: hasEffectiveRestParameter, @@ -48925,7 +49025,7 @@ var ts; getSuggestionForNonexistentExport: getSuggestionForNonexistentExport, getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeFlags.TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -48962,10 +49062,10 @@ var ts; cancellationToken = ct; // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused checkSourceFileWithEagerDiagnostics(file); - ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* NodeCheckFlags.TypeChecked */)); diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); @@ -49033,35 +49133,35 @@ var ts; var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); var subtypeReductionCache = new ts.Map(); + var cachedTypes = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); - var unknownSymbol = createSymbol(4 /* Property */, "unknown"); - var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */); + var unknownSymbol = createSymbol(4 /* SymbolFlags.Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__" /* InternalSymbolName.Resolving */); var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var autoType = createIntrinsicType(1 /* Any */, "any"); - var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var errorType = createIntrinsicType(1 /* Any */, "error"); - var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */); - var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); - var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */); - var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; - var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */); - var stringType = createIntrinsicType(4 /* String */, "string"); - var numberType = createIntrinsicType(8 /* Number */, "number"); - var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); - var falseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); + var anyType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var autoType = createIntrinsicType(1 /* TypeFlags.Any */, "any", 262144 /* ObjectFlags.NonInferrableType */); + var wildcardType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var errorType = createIntrinsicType(1 /* TypeFlags.Any */, "error"); + var unresolvedType = createIntrinsicType(1 /* TypeFlags.Any */, "unresolved"); + var intrinsicMarkerType = createIntrinsicType(1 /* TypeFlags.Any */, "intrinsic"); + var unknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var nonNullUnknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var undefinedType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined", 65536 /* ObjectFlags.ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined") : undefinedType; + var nullType = createIntrinsicType(65536 /* TypeFlags.Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* TypeFlags.Null */, "null", 65536 /* ObjectFlags.ContainsWideningType */); + var stringType = createIntrinsicType(4 /* TypeFlags.String */, "string"); + var numberType = createIntrinsicType(8 /* TypeFlags.Number */, "number"); + var bigintType = createIntrinsicType(64 /* TypeFlags.BigInt */, "bigint"); + var falseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var regularFalseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var trueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); + var regularTrueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); trueType.regularType = regularTrueType; trueType.freshType = trueType; regularTrueType.regularType = regularTrueType; @@ -49071,28 +49171,40 @@ var ts; regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = getUnionType([regularFalseType, regularTrueType]); - var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16384 /* Void */, "void"); - var neverType = createIntrinsicType(131072 /* Never */, "never"); - var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */); - var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); - var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(4096 /* TypeFlags.ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16384 /* TypeFlags.Void */, "void"); + var neverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var silentNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never", 262144 /* ObjectFlags.NonInferrableType */); + var implicitNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* TypeFlags.NonPrimitive */, "object"); var stringOrNumberType = getUnionType([stringType, numberType]); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); - var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }, function () { return "(restrictive mapper)"; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? wildcardType : t; }, function () { return "(permissive mapper)"; }); + var uniqueLiteralType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? uniqueLiteralType : t; }, function () { return "(unique literal mapper)"; }); // replace all type parameters with the unique literal type (disregarding constraints) + var outofbandVarianceMarkerHandler; + var reportUnreliableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true); + } + return t; + }, function () { return "(unmeasurable reporter)"; }); + var reportUnmeasurableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false); + } + return t; + }, function () { return "(unreliable reporter)"; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); - emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + emptyJsxObjectType.objectFlags |= 2048 /* ObjectFlags.JsxAttributes */; + var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType; @@ -49101,7 +49213,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 262144 /* NonInferrableType */; + anyFunctionType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -49109,11 +49221,14 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var markerSuperTypeForCheck = createTypeParameter(); + var markerSubTypeForCheck = createTypeParameter(); + markerSubTypeForCheck.constraint = markerSuperTypeForCheck; + var noTypePredicate = createTypePredicate(1 /* TypePredicateKind.Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true); var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances var noIterationTypes = { @@ -49245,7 +49360,6 @@ var ts; var typeofType = createTypeofType(); var _jsxNamespace; var _jsxFactoryEntity; - var outofbandVarianceMarkerHandler; var subtypeRelation = new ts.Map(); var strictSubtypeRelation = new ts.Map(); var assignableRelation = new ts.Map(); @@ -49265,12 +49379,20 @@ var ts; [".mjs", ".mjs"], [".js", ".js"], [".cjs", ".cjs"], - [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"], + [".tsx", compilerOptions.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" : ".js"], [".jsx", ".jsx"], [".json", ".json"], ]; initializeTypeChecker(); return checker; + function getCachedType(key) { + return key ? cachedTypes.get(key) : undefined; + } + function setCachedType(key, type) { + if (key) + cachedTypes.set(key, type); + return type; + } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -49411,7 +49533,7 @@ var ts; return diagnostic; } function isDeprecatedSymbol(symbol) { - return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */); + return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* NodeFlags.Deprecated */); } function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); @@ -49425,44 +49547,44 @@ var ts; } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = new Symbol(flags | 33554432 /* Transient */, name); + var symbol = new Symbol(flags | 33554432 /* SymbolFlags.Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 111551 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 111550 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 0 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 900095 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 110991 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899503 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 788872 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 110735 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 103359 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 46015 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 78783 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 526824 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 788968 /* TypeAliasExcludes */; - if (flags & 2097152 /* Alias */) - result |= 2097152 /* AliasExcludes */; + if (flags & 2 /* SymbolFlags.BlockScopedVariable */) + result |= 111551 /* SymbolFlags.BlockScopedVariableExcludes */; + if (flags & 1 /* SymbolFlags.FunctionScopedVariable */) + result |= 111550 /* SymbolFlags.FunctionScopedVariableExcludes */; + if (flags & 4 /* SymbolFlags.Property */) + result |= 0 /* SymbolFlags.PropertyExcludes */; + if (flags & 8 /* SymbolFlags.EnumMember */) + result |= 900095 /* SymbolFlags.EnumMemberExcludes */; + if (flags & 16 /* SymbolFlags.Function */) + result |= 110991 /* SymbolFlags.FunctionExcludes */; + if (flags & 32 /* SymbolFlags.Class */) + result |= 899503 /* SymbolFlags.ClassExcludes */; + if (flags & 64 /* SymbolFlags.Interface */) + result |= 788872 /* SymbolFlags.InterfaceExcludes */; + if (flags & 256 /* SymbolFlags.RegularEnum */) + result |= 899327 /* SymbolFlags.RegularEnumExcludes */; + if (flags & 128 /* SymbolFlags.ConstEnum */) + result |= 899967 /* SymbolFlags.ConstEnumExcludes */; + if (flags & 512 /* SymbolFlags.ValueModule */) + result |= 110735 /* SymbolFlags.ValueModuleExcludes */; + if (flags & 8192 /* SymbolFlags.Method */) + result |= 103359 /* SymbolFlags.MethodExcludes */; + if (flags & 32768 /* SymbolFlags.GetAccessor */) + result |= 46015 /* SymbolFlags.GetAccessorExcludes */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + result |= 78783 /* SymbolFlags.SetAccessorExcludes */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + result |= 526824 /* SymbolFlags.TypeParameterExcludes */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + result |= 788968 /* SymbolFlags.TypeAliasExcludes */; + if (flags & 2097152 /* SymbolFlags.Alias */) + result |= 2097152 /* SymbolFlags.AliasExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -49494,13 +49616,13 @@ var ts; function mergeSymbol(target, source, unidirectional) { if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || - (source.flags | target.flags) & 67108864 /* Assignment */) { + (source.flags | target.flags) & 67108864 /* SymbolFlags.Assignment */) { if (source === target) { // This can happen when an export assigned namespace exports something also erroneously exported at the top level // See `declarationFileNoCrashOnExtraExportModifier` for an example return target; } - if (!(target.flags & 33554432 /* Transient */)) { + if (!(target.flags & 33554432 /* SymbolFlags.Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { return source; @@ -49508,7 +49630,7 @@ var ts; target = cloneSymbol(resolvedTarget); } // Javascript static-property-assignment declarations always merge, even though they are also values - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + if (source.flags & 512 /* SymbolFlags.ValueModule */ && target.flags & 512 /* SymbolFlags.ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums target.constEnumOnlyModule = false; } @@ -49531,7 +49653,7 @@ var ts; recordMergedSymbol(target, source); } } - else if (target.flags & 1024 /* NamespaceModule */) { + else if (target.flags & 1024 /* SymbolFlags.NamespaceModule */) { // Do not report an error when merging `var globalThis` with the built-in `globalThis`, // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. @@ -49540,8 +49662,8 @@ var ts; } } else { // error - var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); - var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var isEitherEnum = !!(target.flags & 384 /* SymbolFlags.Enum */ || source.flags & 384 /* SymbolFlags.Enum */); + var isEitherBlockScoped_1 = !!(target.flags & 2 /* SymbolFlags.BlockScopedVariable */ || source.flags & 2 /* SymbolFlags.BlockScopedVariable */); var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -49552,9 +49674,9 @@ var ts; var symbolName_1 = symbolToString(source); // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { - var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile; + var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* Comparison.LessThan */ ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -49597,7 +49719,7 @@ var ts; err.relatedInformation = err.relatedInformation || []; var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName); var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here); - if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; })) + if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* Comparison.EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* Comparison.EqualTo */; })) return "continue"; ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage); }; @@ -49639,7 +49761,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -49648,7 +49770,7 @@ var ts; } // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); - if (mainModule_1.flags & 1920 /* Namespace */) { + if (mainModule_1.flags & 1920 /* SymbolFlags.Namespace */) { // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you @@ -49663,9 +49785,9 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { // We may need to merge the module augmentation's exports into the target symbols of the resolved exports - var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); + var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */); for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) { var _e = _d[_i], key = _e[0], value = _e[1]; if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { @@ -49698,7 +49820,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks()); @@ -49708,17 +49830,17 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { var symbol = getMergedSymbol(symbols.get(name)); if (symbol) { - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors if (target === unknownSymbol || target.flags & meaning) { @@ -49738,8 +49860,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* SymbolFlags.Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* SymbolFlags.Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -49753,7 +49875,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!ts.outFile(compilerOptions)) || isInTypeQuery(usage) || - declaration.flags & 16777216 /* Ambient */) { + declaration.flags & 16777216 /* NodeFlags.Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -49767,17 +49889,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 203 /* BindingElement */) { + if (declaration.kind === 203 /* SyntaxKind.BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 203 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 203 /* SyntaxKind.BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* SyntaxKind.VariableDeclaration */), usage); } - else if (declaration.kind === 254 /* VariableDeclaration */) { + else if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -49791,7 +49913,7 @@ var ts; } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -49807,19 +49929,19 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 275 /* ExportSpecifier */ || (usage.parent.kind === 271 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 275 /* SyntaxKind.ExportSpecifier */ || (usage.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.isExportEquals) { return true; } - if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { + if (!!(usage.flags & 8388608 /* NodeFlags.JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -49834,9 +49956,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 237 /* VariableStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 237 /* SyntaxKind.VariableStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -49864,7 +49986,7 @@ var ts; var initializerOfProperty = propertyDeclaration.initializer === current; if (initializerOfProperty) { if (ts.isStatic(current.parent)) { - if (declaration.kind === 169 /* MethodDeclaration */) { + if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) { return true; } if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { @@ -49879,7 +50001,7 @@ var ts; } } else { - var isDeclarationInstanceProperty = declaration.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(declaration); + var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -49902,19 +50024,19 @@ var ts; return "quit"; } switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 172 /* GetAccessor */: - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -49939,7 +50061,7 @@ var ts; // - optional chaining pre-es2020 // - nullish coalesce pre-es2020 // - spread assignment in binding pattern pre-es2017 - if (target >= 2 /* ES2015 */) { + if (target >= 2 /* ScriptTarget.ES2015 */) { var links = getNodeLinks(functionLocation); if (links.declarationRequiresScopeChange === undefined) { links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false; @@ -49954,30 +50076,30 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: // do not descend into these return false; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !useDefineForClassFields; + return target < 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: // null coalesce and optional chain pre-es2020 produce temporary variables if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) { - return target < 7 /* ES2020 */; + return target < 7 /* ScriptTarget.ES2020 */; } if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) { - return target < 4 /* ES2017 */; + return target < 4 /* ScriptTarget.ES2017 */; } if (ts.isTypeNode(node)) return false; @@ -50030,35 +50152,35 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) { - useResult = result.flags & 262144 /* TypeParameter */ + if (meaning & result.flags & 788968 /* SymbolFlags.Type */ && lastLocation.kind !== 320 /* SyntaxKind.JSDoc */) { + useResult = result.flags & 262144 /* SymbolFlags.TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 164 /* Parameter */ || - lastLocation.kind === 340 /* JSDocParameterTag */ || - lastLocation.kind === 341 /* JSDocReturnTag */ || - lastLocation.kind === 163 /* TypeParameter */ + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || + lastLocation.kind === 340 /* SyntaxKind.JSDocParameterTag */ || + lastLocation.kind === 341 /* SyntaxKind.JSDocReturnTag */ || + lastLocation.kind === 163 /* SyntaxKind.TypeParameter */ // local types not visible outside the function body : false; } - if (meaning & result.flags & 3 /* Variable */) { + if (meaning & result.flags & 3 /* SymbolFlags.Variable */) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } - else if (result.flags & 1 /* FunctionScopedVariable */) { + else if (result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { // parameters are visible only inside function body, parameter list and return type // technically for parameter list case here we might mix parameters and variables declared in function, // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 164 /* Parameter */ || + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 189 /* ConditionalType */) { + else if (location.kind === 189 /* SyntaxKind.ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -50073,17 +50195,17 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols; - if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 305 /* SyntaxKind.SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports.get("default" /* Default */)) { + if (result = moduleExports.get("default" /* InternalSymbolName.Default */)) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { break loop; @@ -50103,13 +50225,13 @@ var ts; // which is not the desired behavior. var moduleExport = moduleExports.get(name); if (moduleExport && - moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 275 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* NamespaceExport */))) { + moduleExport.flags === 2097152 /* SymbolFlags.Alias */ && + (ts.getDeclarationOfKind(moduleExport, 275 /* SyntaxKind.ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* SyntaxKind.NamespaceExport */))) { break; } } // ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs) - if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) { + if (name !== "default" /* InternalSymbolName.Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */))) { if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) { result = undefined; } @@ -50118,12 +50240,12 @@ var ts; } } break; - case 260 /* EnumDeclaration */: - if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) { + case 260 /* SyntaxKind.EnumDeclaration */: + if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* SymbolFlags.EnumMember */)) { break loop; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -50133,20 +50255,21 @@ var ts; if (!ts.isStatic(location)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* SymbolFlags.Value */)) { // Remember the property node, it will be used later to report appropriate error + ts.Debug.assertNode(location, ts.isPropertyDeclaration); propertyWithInvalidInitializer = location; } } } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* SymbolFlags.Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -50161,7 +50284,7 @@ var ts; } break loop; } - if (location.kind === 226 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 226 /* SyntaxKind.ClassExpression */ && meaning & 32 /* SymbolFlags.Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -50169,11 +50292,11 @@ var ts; } } break; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* SyntaxKind.ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* SymbolFlags.Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -50189,39 +50312,39 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error - if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */) { break; } // falls through - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 213 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 213 /* SyntaxKind.FunctionExpression */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } - if (meaning & 16 /* Function */) { + if (meaning & 16 /* SymbolFlags.Function */) { var functionName = location.name; if (functionName && name === functionName.escapedText) { result = location.symbol; @@ -50229,7 +50352,7 @@ var ts; } } break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -50238,7 +50361,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 164 /* Parameter */) { + if (location.parent && location.parent.kind === 164 /* SyntaxKind.Parameter */) { location = location.parent; } // @@ -50253,20 +50376,20 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* SyntaxKind.ClassDeclaration */)) { location = location.parent; } break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -50274,7 +50397,7 @@ var ts; } } break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -50282,8 +50405,8 @@ var ts; } } break; - case 190 /* InferType */: - if (meaning & 262144 /* TypeParameter */) { + case 190 /* SyntaxKind.InferType */: + if (meaning & 262144 /* SymbolFlags.TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { result = location.typeParameter.symbol; @@ -50308,7 +50431,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 305 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 305 /* SyntaxKind.SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -50324,11 +50447,27 @@ var ts; } } } + // The invalid initializer error is needed in two situation: + // 1. When result is undefined, after checking for a missing "this." + // 2. When result is defined + function checkAndReportErrorForInvalidInitializer() { + if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */)) { + // We have a match, but the reference occurred within a property initializer and the identifier also binds + // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed + // with ESNext+useDefineForClassFields because the scope semantics are different. + error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos) + ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor + : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg)); + return true; + } + return false; + } if (!result) { if (nameNotFoundMessage) { addLazyDiagnostic(function () { if (!errorLocation || !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217 + !checkAndReportErrorForInvalidInitializer() && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) && @@ -50336,7 +50475,16 @@ var ts; !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { var suggestion = void 0; - if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { + var suggestedLib = void 0; + // Report missing lib first + if (nameArg) { + suggestedLib = getSuggestedLibForNonExistentName(nameArg); + if (suggestedLib) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib); + } + } + // then spelling suggestions + if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); if (isGlobalScopeAugmentationDeclaration) { @@ -50345,7 +50493,7 @@ var ts; if (suggestion) { var suggestionName = symbolToString(suggestion); var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false); - var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 + var message = meaning === 1920 /* SymbolFlags.Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1; var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName); @@ -50355,16 +50503,9 @@ var ts; } } } - if (!suggestion) { - if (nameArg) { - var lib = getSuggestedLibForNonExistentName(nameArg); - if (lib) { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib); - } - else { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); - } - } + // And then fall back to unspecified "not found" + if (!suggestion && !suggestedLib && nameArg) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); } suggestionCount++; } @@ -50372,12 +50513,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) { - // We have a match, but the reference occurred within a property initializer and the identifier also binds - // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed - // with ESNext+useDefineForClassFields because the scope semantics are different. - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg)); + else if (checkAndReportErrorForInvalidInitializer()) { return undefined; } // Perform extra checks only if error reporting was requested @@ -50395,22 +50531,22 @@ var ts; // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped if (errorLocation && - (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { + (meaning & 2 /* SymbolFlags.BlockScopedVariable */ || + ((meaning & 32 /* SymbolFlags.Class */ || meaning & 384 /* SymbolFlags.Enum */) && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { + if (exportOrLocalSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* SymbolFlags.Class */ || exportOrLocalSymbol.flags & 384 /* SymbolFlags.Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */ && !(originalLocation.flags & 8388608 /* NodeFlags.JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -50422,10 +50558,10 @@ var ts; error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation)); } } - if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { + if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ + var message = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -50439,31 +50575,31 @@ var ts; function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) { if (!typeOnlyDeclaration) return diagnostic; - return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); + return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 214 /* ArrowFunction */ && location.kind !== 213 /* FunctionExpression */) { + if (location.kind !== 214 /* SyntaxKind.ArrowFunction */ && location.kind !== 213 /* SyntaxKind.FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; } // generator functions and async functions are not inlined in control flow when immediately invoked - if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* Async */)) { + if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* ModifierFlags.Async */)) { return true; } return !ts.getImmediatelyInvokedFunctionExpression(location); } function isSelfReferenceLocation(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: // For `namespace N { N; }` + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -50476,7 +50612,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 163 /* TypeParameter */) { + if (decl.kind === 163 /* SyntaxKind.TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); @@ -50520,7 +50656,7 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { + if (expression && resolveEntityName(expression, 64 /* SymbolFlags.Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); return true; } @@ -50532,10 +50668,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -50545,9 +50681,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* SymbolFlags.Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -50566,9 +50702,9 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1920 /* Namespace */)) { + if (meaning & (788968 /* SymbolFlags.Type */ & ~1920 /* SymbolFlags.Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1920 /* SymbolFlags.Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name)); return true; } @@ -50579,14 +50715,14 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) { if (isPrimitiveTypeName(name)) { if (isExtendedByInterface(errorLocation)) { error(errorLocation, ts.Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, ts.unescapeLeadingUnderscores(name)); @@ -50596,8 +50732,8 @@ var ts; } return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) { var rawName = ts.unescapeLeadingUnderscores(name); if (isES2015OrLaterConstructorName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); @@ -50617,7 +50753,7 @@ var ts; var grandparent = node.parent.parent; var parentOfGrandparent = grandparent.parent; if (grandparent && parentOfGrandparent) { - var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* ExtendsKeyword */; + var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* SyntaxKind.ExtendsKeyword */; var isInterface = ts.isInterfaceDeclaration(parentOfGrandparent); return isExtending && isInterface; } @@ -50629,7 +50765,7 @@ var ts; }); if (container && container.members.length === 1) { var type = getDeclaredTypeOfSymbol(symbol); - return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true); + return !!(type.flags & 1048576 /* TypeFlags.Union */) && allTypesAssignableToKind(type, 384 /* TypeFlags.StringOrNumberLiteral */, /*strict*/ true); } return false; } @@ -50646,15 +50782,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -50664,29 +50800,29 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { var _a; - ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); - if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */)); + if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); - if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); - if (result.flags & 2 /* BlockScopedVariable */) { + if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } - else if (result.flags & 32 /* Class */) { + else if (result.flags & 32 /* SymbolFlags.Class */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } - else if (result.flags & 256 /* RegularEnum */) { + else if (result.flags & 256 /* SymbolFlags.RegularEnum */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } else { - ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */)); if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } @@ -50707,13 +50843,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.parent; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -50738,24 +50874,24 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ - || node.kind === 264 /* NamespaceExportDeclaration */ - || node.kind === 267 /* ImportClause */ && !!node.name - || node.kind === 268 /* NamespaceImport */ - || node.kind === 274 /* NamespaceExport */ - || node.kind === 270 /* ImportSpecifier */ - || node.kind === 275 /* ExportSpecifier */ - || node.kind === 271 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) - || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name + || node.kind === 268 /* SyntaxKind.NamespaceImport */ + || node.kind === 274 /* SyntaxKind.NamespaceExport */ + || node.kind === 270 /* SyntaxKind.ImportSpecifier */ + || node.kind === 275 /* SyntaxKind.ExportSpecifier */ + || node.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.exportAssignmentIsAlias(node) + || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 297 /* ShorthandPropertyAssignment */ - || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) - || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent); + || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) + || node.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -50768,7 +50904,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -50781,7 +50917,7 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var isExport = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */; + var isExport = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */; var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; @@ -50793,14 +50929,14 @@ var ts; } } function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) { - var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportValue = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node)); } function getUsageModeForExpression(usage) { return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined; @@ -50810,7 +50946,7 @@ var ts; } function isOnlyImportedAsDefault(usage) { var usageMode = getUsageModeForExpression(usage); - return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */); + return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Extension.Json */); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) { var usageMode = file && getUsageModeForExpression(usage); @@ -50827,7 +50963,7 @@ var ts; // Declaration files (and ambient modules) if (!file || file.isDeclarationFile) { // Definitely cannot have a synthetic default if they have a syntactic default member specified - var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration + var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) { return false; } @@ -50859,7 +50995,7 @@ var ts; exportDefaultSymbol = moduleSymbol; } else { - exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); + exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias); } var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier); @@ -50867,7 +51003,7 @@ var ts; if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) { if (hasExportAssignmentSymbol(moduleSymbol)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; - var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportAssignment = exportEqualsSymbol.valueDeclaration; var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName); if (exportAssignment) { @@ -50895,12 +51031,12 @@ var ts; } else { var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); + var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */); if (exportStar) { var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) { var _a, _b; return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && - ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); + ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */))); }); if (defaultExport) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default)); @@ -50944,7 +51080,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -50959,7 +51095,7 @@ var ts; return result; } function getExportOfModule(symbol, name, specifier, dontResolveAlias) { - if (symbol.flags & 1536 /* Module */) { + if (symbol.flags & 1536 /* SymbolFlags.Module */) { var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); @@ -50967,7 +51103,7 @@ var ts; } } function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); @@ -50983,7 +51119,7 @@ var ts; if (!ts.isIdentifier(name)) { return undefined; } - var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); + var suppressInteropError = name.escapedText === "default" /* InternalSymbolName.Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -50992,7 +51128,7 @@ var ts; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true); } else { @@ -51001,7 +51137,7 @@ var ts; // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); - if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { + if (symbolFromModule === undefined && name.escapedText === "default" /* InternalSymbolName.Default */) { var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -51022,7 +51158,7 @@ var ts; } } else { - if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)) { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { @@ -51039,7 +51175,7 @@ var ts; var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { - var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); + var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportedEqualsSymbol) { getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); @@ -51119,19 +51255,15 @@ var ts; if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { return undefined; } - var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } - function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { - var expression = node.initializer; - return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); - } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -51139,31 +51271,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: - case 254 /* VariableDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 270 /* ImportSpecifier */: - case 203 /* BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 275 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, dontRecursivelyResolve); + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 297 /* ShorthandPropertyAssignment */: - return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 296 /* PropertyAssignment */: - return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 296 /* SyntaxKind.PropertyAssignment */: + return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve); + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -51174,16 +51306,16 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); + return (symbol.flags & (2097152 /* SymbolFlags.Alias */ | excludes)) === 2097152 /* SymbolFlags.Alias */ || !!(symbol.flags & 2097152 /* SymbolFlags.Alias */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */); } function resolveSymbol(symbol, dontResolveAlias) { return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.aliasTarget) { links.aliasTarget = resolvingSymbol; @@ -51248,7 +51380,7 @@ var ts; function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) { var _a, _b, _c; if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) { - var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */)) !== null && _b !== void 0 ? _b : target; + var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)) !== null && _b !== void 0 ? _b : target; var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false; } @@ -51256,7 +51388,7 @@ var ts; } /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */ function getTypeOnlyAliasDeclaration(symbol) { - if (!(symbol.flags & 2097152 /* Alias */)) { + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) { return undefined; } var links = getSymbolLinks(symbol); @@ -51267,7 +51399,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); + ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -51288,7 +51420,7 @@ var ts; // position. if (ts.isInternalModuleImportEqualsDeclaration(node)) { var target = resolveSymbol(symbol); - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // import foo = checkExpressionCached(node.moduleReference); } @@ -51311,22 +51443,22 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* SyntaxKind.Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 161 /* QualifiedName */) { - return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + if (entityName.kind === 79 /* SyntaxKind.Identifier */ || entityName.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + return resolveEntityName(entityName, 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 265 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { - return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */); + return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); } function getContainingQualifiedNameNode(node) { while (ts.isQualifiedName(node.parent)) { @@ -51336,7 +51468,7 @@ var ts; } function tryGetQualifiedNameAsValue(node) { var left = ts.getFirstIdentifier(node); - var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true); + var symbol = resolveName(left, left.escapedText, 111551 /* SymbolFlags.Value */, undefined, left, /*isUse*/ true); if (!symbol) { return undefined; } @@ -51357,9 +51489,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* SymbolFlags.Value */ : 0); var symbol; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false)); @@ -51367,9 +51499,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 161 /* QualifiedName */ || name.kind === 206 /* PropertyAccessExpression */) { - var left = name.kind === 161 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 161 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 161 /* SyntaxKind.QualifiedName */ || name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var left = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.left : name.expression; + var right = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -51403,7 +51535,7 @@ var ts; } var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name); var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet - && (meaning & 788968 /* Type */) + && (meaning & 788968 /* SymbolFlags.Type */) && containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName); @@ -51411,8 +51543,8 @@ var ts; error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName)); return undefined; } - if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) { - var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */)); + if (meaning & 1920 /* SymbolFlags.Namespace */ && ts.isQualifiedName(name.parent)) { + var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* SymbolFlags.Type */)); if (exportedTypeSymbol) { error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText)); return undefined; @@ -51426,8 +51558,8 @@ var ts; else { throw ts.Debug.assertNever(name, "Unknown entity name kind."); } - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 271 /* ExportAssignment */)) { + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* SymbolFlags.Alias */ || name.parent.kind === 271 /* SyntaxKind.ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -51447,7 +51579,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* NodeFlags.JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -51468,7 +51600,7 @@ var ts; } if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) && ts.isBinaryExpression(host.parent.parent) && - ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { // X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration var symbol = getSymbolOfNode(host.parent.parent.left); if (symbol) { @@ -51499,7 +51631,7 @@ var ts; */ function getExpandoSymbol(symbol) { var decl = symbol.valueDeclaration; - if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* SymbolFlags.TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { return undefined; } var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); @@ -51566,7 +51698,40 @@ var ts; // An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of // normal mode restrictions if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { - error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); + if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) { + // ImportEquals in a ESM file resolving to another ESM file + error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference); + } + else { + // CJS file resolving to an ESM file + var diagnosticDetails = void 0; + var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName); + if (ext === ".ts" /* Extension.Ts */ || ext === ".js" /* Extension.Js */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".jsx" /* Extension.Jsx */) { + var scope = currentSourceFile.packageJsonScope; + var targetExt = ext === ".ts" /* Extension.Ts */ ? ".mts" /* Extension.Mts */ : ext === ".js" /* Extension.Js */ ? ".mjs" /* Extension.Mjs */ : undefined; + if (scope && !scope.packageJsonContent.type) { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, targetExt, ts.combinePaths(scope.packageDirectory, "package.json")); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0, ts.combinePaths(scope.packageDirectory, "package.json")); + } + } + else { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, targetExt); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module); + } + } + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, ts.chainDiagnosticMessages(diagnosticDetails, ts.Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference))); + } } } // merged symbol is module declaration symbol combined with all augmentations @@ -51631,12 +51796,12 @@ var ts; * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (moduleKind >= ts.ModuleKind.ES2015) { - replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js"; + replacedImportSource += tsExtension === ".mts" /* Extension.Mts */ ? ".mjs" : tsExtension === ".cts" /* Extension.Cts */ ? ".cjs" : ".js"; } error(errorNode, diag, tsExtension, replacedImportSource); } else if (!compilerOptions.resolveJsonModule && - ts.fileExtensionIs(moduleReference, ".json" /* Json */) && + ts.fileExtensionIs(moduleReference, ".json" /* Extension.Json */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); @@ -51683,27 +51848,27 @@ var ts; } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { - var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */), dontResolveAlias); var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* SymbolFlags.Alias */) { return exported; } var links = getSymbolLinks(exported); if (links.cjsExportMerged) { return links.cjsExportMerged; } - var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); - merged.flags = merged.flags | 512 /* ValueModule */; + var merged = exported.flags & 33554432 /* SymbolFlags.Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* SymbolFlags.ValueModule */; if (merged.exports === undefined) { merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { - if (name === "export=" /* ExportEquals */) + if (name === "export=" /* InternalSymbolName.ExportEquals */) return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); @@ -51717,7 +51882,7 @@ var ts; var _a; var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -51736,12 +51901,12 @@ var ts; var targetFile = (_a = moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat); if (ts.getESModuleInterop(compilerOptions) || isEsmCjsRef) { - var sigs = getSignaturesOfStructuredType(type, 0 /* Call */); + var sigs = getSignaturesOfStructuredType(type, 0 /* SignatureKind.Call */); if (!sigs || !sigs.length) { - sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); + sigs = getSignaturesOfStructuredType(type, 1 /* SignatureKind.Construct */); } if ((sigs && sigs.length) || - getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true) || + getPropertyOfType(type, "default" /* InternalSymbolName.Default */, /*skipObjectFunctionPropertyAugment*/ true) || isEsmCjsRef) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); @@ -51773,7 +51938,7 @@ var ts; return result; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; + return moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -51825,15 +51990,15 @@ var ts; return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; } function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { - return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || - ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ || + return !(resolvedExternalModuleType.flags & 131068 /* TypeFlags.Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* ObjectFlags.Class */ || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path isArrayType(resolvedExternalModuleType) || isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : - symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { @@ -51848,7 +52013,7 @@ var ts; if (!source) return; source.forEach(function (sourceSymbol, id) { - if (id === "default" /* Default */) + if (id === "default" /* InternalSymbolName.Default */) return; var targetSymbol = target.get(id); if (!targetSymbol) { @@ -51883,7 +52048,7 @@ var ts; } var symbols = new ts.Map(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports.get("__export" /* ExportStar */); + var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */); if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); @@ -51972,21 +52137,21 @@ var ts; function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) { var container = getParentOfSymbol(symbol); // Type parameters end up in the `members` lists but are not externally visible - if (container && !(symbol.flags & 262144 /* TypeParameter */)) { + if (container && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && - getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */, /*externalOnly*/ false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope } // we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type // which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`) var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) - && container.flags & 788968 /* Type */ - && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ - && meaning === 111551 /* Value */ + && container.flags & 788968 /* SymbolFlags.Type */ + && getDeclaredTypeOfSymbol(container).flags & 524288 /* TypeFlags.Object */ + && meaning === 111551 /* SymbolFlags.Value */ ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { return ts.forEachEntry(t, function (s) { if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { @@ -52010,7 +52175,7 @@ var ts; return getSymbolOfNode(d.parent.parent); } } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { return getSymbolOfNode(ts.getSourceFileOfNode(d)); } @@ -52031,7 +52196,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations); - if (meaning & 111551 /* Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { + if (meaning & 111551 /* SymbolFlags.Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) { return getSymbolOfNode(firstDecl.parent); } @@ -52039,7 +52204,7 @@ var ts; } function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) { var fileSymbol = getExternalModuleContainer(d); - var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); + var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } function getAliasForSymbolInContainer(container, symbol) { @@ -52049,7 +52214,7 @@ var ts; } // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return // the container itself as the alias for the symbol - var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + var exportEquals = container.exports && container.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { return container; } @@ -52073,17 +52238,17 @@ var ts; } } function getExportSymbolOfValueSymbolIfExported(symbol) { - return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 && symbol.exportSymbol || symbol); + return getMergedSymbol(symbol && (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol, includeTypeOnlyMembers) { - return !!(symbol.flags & 111551 /* Value */ || - symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); + return !!(symbol.flags & 111551 /* SymbolFlags.Value */ || + symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 171 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -52106,7 +52271,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(524288 /* Object */); + var type = createType(524288 /* TypeFlags.Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -52120,7 +52285,7 @@ var ts; return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { - var type = createType(262144 /* TypeParameter */); + var type = createType(262144 /* TypeFlags.TypeParameter */); if (symbol) type.symbol = symbol; return type; @@ -52130,11 +52295,11 @@ var ts; // with at least two underscores. The @ character indicates that the name is denoted by a well known ES // Symbol instance and the # character indicates that the name is a PrivateIdentifier. function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */ && - name.charCodeAt(2) !== 35 /* hash */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 64 /* CharacterCodes.at */ && + name.charCodeAt(2) !== 35 /* CharacterCodes.hash */; } function getNamedMembers(members) { var result; @@ -52166,14 +52331,14 @@ var ts; return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) { - return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); + return setStructuredTypeMembers(createObjectType(16 /* ObjectFlags.Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); } function getResolvedTypeWithoutAbstractConstructSignatures(type) { if (type.constructSignatures.length === 0) return type; if (type.objectTypeWithoutAbstractConstructSignatures) return type.objectTypeWithoutAbstractConstructSignatures; - var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); }); + var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (type.constructSignatures === constructSignatures) return type; var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos); @@ -52191,12 +52356,12 @@ var ts; } } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred @@ -52205,9 +52370,9 @@ var ts; return { value: result }; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -52218,7 +52383,7 @@ var ts; var table_1; // TODO: Should this filtered table be cached in some way? (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { - if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) { (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); @@ -52237,7 +52402,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); } @@ -52248,7 +52413,7 @@ var ts; var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -52292,9 +52457,9 @@ var ts; } // Check if symbol is any of the aliases in scope var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" /* ExportEquals */ - && symbolFromSymbolTable.escapedName !== "default" /* Default */ + if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ + && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */ && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) @@ -52302,7 +52467,7 @@ var ts; && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -52346,7 +52511,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -52361,10 +52526,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: continue; default: return false; @@ -52375,16 +52540,16 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* SymbolFlags.Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* SymbolFlags.Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) { var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ false); - return access.accessibility === 0 /* Accessible */; + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) { if (!ts.length(symbols)) @@ -52414,7 +52579,7 @@ var ts; } // Any meaning of a module symbol is always accessible via an `import` type return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } } @@ -52438,14 +52603,14 @@ var ts; } if (earlyModuleBail) { return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } if (hadAccessibleChain) { return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined, + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */) : undefined, }; } } @@ -52474,7 +52639,7 @@ var ts; if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { - accessibility: 2 /* CannotBeNamed */, + accessibility: 2 /* SymbolAccessibility.CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule), errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, @@ -52483,28 +52648,28 @@ var ts; } // Just a local name that is not accessible return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } - return { accessibility: 0 /* Accessible */ }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } function getExternalModuleContainer(declaration) { var node = ts.findAncestor(declaration, hasExternalModuleSymbol); return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* SyntaxKind.Identifier */; }), getIsDeclarationVisible)) { return undefined; } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { var _a, _b; if (!isDeclarationVisible(declaration)) { @@ -52512,27 +52677,39 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !ts.hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + !ts.hasSyntacticModifier(anyImportSyntax, 1 /* ModifierFlags.Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); } else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) && - !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* ModifierFlags.Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); } else if (ts.isLateVisibilityPaintedStatement(declaration) // unexported top-level statement - && !ts.hasSyntacticModifier(declaration, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration, 1 /* ModifierFlags.Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement - && ts.isVariableDeclaration(declaration.parent.parent) - && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) - && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) - && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { - return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + else if (ts.isBindingElement(declaration)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement + && ts.isVariableDeclaration(declaration.parent.parent) + && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* ModifierFlags.Export */) + && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) + && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + } + else if (symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement); + if (ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */)) { + return true; + } + if (!isDeclarationVisible(variableStatement.parent)) { + return false; + } + return addVisibleAlias(declaration, variableStatement); + } } // Declaration is not visible return false; @@ -52553,86 +52730,86 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 181 /* TypeQuery */ || - entityName.parent.kind === 228 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || - entityName.parent.kind === 162 /* ComputedPropertyName */) { + if (entityName.parent.kind === 181 /* SyntaxKind.TypeQuery */ || + entityName.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || + entityName.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Typeof value - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } - else if (entityName.kind === 161 /* QualifiedName */ || entityName.kind === 206 /* PropertyAccessExpression */ || - entityName.parent.kind === 265 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 161 /* SyntaxKind.QualifiedName */ || entityName.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 788968 /* Type */; + meaning = 788968 /* SymbolFlags.Type */; } var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); - if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) { - return { accessibility: 0 /* Accessible */ }; + if (symbol && symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && meaning & 788968 /* SymbolFlags.Type */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } - if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) { - return { accessibility: 0 /* Accessible */ }; + if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) { - if (flags === void 0) { flags = 4 /* AllowAnyNodeKind */; } - var nodeFlags = 70221824 /* IgnoreErrors */; - if (flags & 2 /* UseOnlyExternalAliasing */) { - nodeFlags |= 128 /* UseOnlyExternalAliasing */; + if (flags === void 0) { flags = 4 /* SymbolFormatFlags.AllowAnyNodeKind */; } + var nodeFlags = 70221824 /* NodeBuilderFlags.IgnoreErrors */; + if (flags & 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */) { + nodeFlags |= 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */; } - if (flags & 1 /* WriteTypeParametersOrArguments */) { - nodeFlags |= 512 /* WriteTypeParametersInQualifiedName */; + if (flags & 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */) { + nodeFlags |= 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; } - if (flags & 8 /* UseAliasDefinedOutsideCurrentScope */) { - nodeFlags |= 16384 /* UseAliasDefinedOutsideCurrentScope */; + if (flags & 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */) { + nodeFlags |= 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; } - if (flags & 16 /* DoNotIncludeSymbolChain */) { - nodeFlags |= 134217728 /* DoNotIncludeSymbolChain */; + if (flags & 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */) { + nodeFlags |= 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */; } - var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; + var builder = flags & 4 /* SymbolFormatFlags.AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SyntaxKind.SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; - if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructorType */ : 179 /* FunctionType */; + if (flags & 262144 /* TypeFormatFlags.WriteArrowStyleSignature */) { + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 180 /* SyntaxKind.ConstructorType */ : 179 /* SyntaxKind.FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructSignature */ : 174 /* CallSignature */; + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 175 /* SyntaxKind.ConstructSignature */ : 174 /* SyntaxKind.CallSignature */; } - var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); + var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* EmitHint.Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } - var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */; - var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer); + var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* TypeFormatFlags.NoTruncation */; + var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | (noTruncation ? 1 /* NodeBuilderFlags.NoTruncation */ : 0), writer); if (typeNode === undefined) return ts.Debug.fail("should always get typenode"); // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. @@ -52640,7 +52817,7 @@ var ts; var options = { removeComments: type !== unresolvedType }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { @@ -52658,17 +52835,17 @@ var ts; return [leftStr, rightStr]; } function getTypeNameForErrorDisplay(type) { - return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); + return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { - if (flags === void 0) { flags = 0 /* None */; } - return flags & 814775659 /* NodeBuilderFlagsMask */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + return flags & 848330091 /* TypeFormatFlags.NodeBuilderFlagsMask */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); + return !!type.symbol && !!(type.symbol.flags & 32 /* SymbolFlags.Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* TypeFlags.Object */) && !!(ts.getObjectFlags(type) & 16777216 /* ObjectFlags.IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -52702,12 +52879,12 @@ var ts; }; function withContext(enclosingDeclaration, flags, tracker, cb) { var _a, _b; - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0); var context = { enclosingDeclaration: enclosingDeclaration, - flags: flags || 0 /* None */, + flags: flags || 0 /* NodeBuilderFlags.None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache), @@ -52729,7 +52906,7 @@ var ts; }; context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); - if (context.truncating && context.flags & 1 /* NoTruncation */) { + if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) { (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); } return context.encounteredError ? undefined : resultingNode; @@ -52764,62 +52941,68 @@ var ts; function checkTruncationLength(context) { if (context.truncating) return context.truncating; - return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); + return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { + var savedFlags = context.flags; + var typeNode = typeToTypeNodeWorker(type, context); + context.flags = savedFlags; + return typeNode; + } + function typeToTypeNodeWorker(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } - var inTypeAlias = context.flags & 8388608 /* InTypeAlias */; - context.flags &= ~8388608 /* InTypeAlias */; + var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */; + context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */; if (!type) { - if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (!(context.flags & 536870912 /* NoTypeReduction */)) { + if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) { type = getReducedType(type); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { if (type.aliasSymbol) { return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); } if (type === unresolvedType) { - return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved"); + return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved"); } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */); } - if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + if (type.flags & 2 /* TypeFlags.Unknown */) { + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } - if (type.flags & 4 /* String */) { + if (type.flags & 4 /* TypeFlags.String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(158 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */); } - if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { + if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */); } - if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { + if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */); if (getDeclaredTypeOfSymbol(parentSymbol) === type) { return parentName; } var memberName = ts.symbolName(type.symbol); - if (ts.isIdentifierText(memberName, 0 /* ES3 */)) { + if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) { return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); } if (ts.isImportTypeNode(parentName)) { @@ -52833,66 +53016,66 @@ var ts; return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + if (type.flags & 1056 /* TypeFlags.EnumLike */) { + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - if (type.flags & 128 /* StringLiteral */) { + if (type.flags & 128 /* TypeFlags.StringLiteral */) { context.approximateLength += (type.value.length + 2); - return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */)); + return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */)), 16777216 /* EmitFlags.NoAsciiEscaping */)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); + return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value))); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse()); } - if (type.flags & 8192 /* UniqueESSymbol */) { - if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + if (!(context.flags & 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 111551 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* SymbolFlags.Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(154 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(154 /* SyntaxKind.UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */)); } - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */); } - if (type.flags & 32768 /* Undefined */) { + if (type.flags & 32768 /* TypeFlags.Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { context.approximateLength += 4; return ts.factory.createLiteralTypeNode(ts.factory.createNull()); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */); } - if (type.flags & 4096 /* ESSymbol */) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */); } - if (type.flags & 67108864 /* NonPrimitive */) { + if (type.flags & 67108864 /* TypeFlags.NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(148 /* SyntaxKind.ObjectKeyword */); } if (ts.isThisTypeParameter(type)) { - if (context.flags & 4194304 /* InObjectTypeLiteral */) { - if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { + if (context.flags & 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */) { + if (!context.encounteredError && !(context.flags & 32768 /* NodeBuilderFlags.AllowThisInObjectLiteral */)) { context.encounteredError = true; } if (context.tracker.reportInaccessibleThisError) { @@ -52902,22 +53085,22 @@ var ts; context.approximateLength += 4; return ts.factory.createThisTypeNode(); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* SymbolFlags.Class */)) return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes); if (ts.length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) { return ts.factory.createArrayTypeNode(typeArgumentNodes[0]); } - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); } var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & 4 /* ObjectFlags.Reference */) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } - if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ || objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); var constraintNode = void 0; var constraint = getConstraintOfTypeParameter(type); @@ -52934,8 +53117,8 @@ var ts; } return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode)); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 262144 /* TypeParameter */ && + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name_2 = typeParameterToName(type, context); context.approximateLength += ts.idText(name_2).length; @@ -52943,43 +53126,43 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? - (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; + var name = (type === markerSuperTypeForCheck || type === markerSubTypeForCheck) && varianceTypeParameter && varianceTypeParameter.symbol ? + (type === markerSubTypeForCheck ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined); } - if (type.flags & 1048576 /* Union */ && type.origin) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.origin) { type = type.origin; } - if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { - var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + var types = type.flags & 1048576 /* TypeFlags.Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - return type.flags & 1048576 /* Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); } else { - if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!context.encounteredError && !(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } return undefined; // TODO: GH#18217 } } - if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, indexTypeNode); } - if (type.flags & 134217728 /* TemplateLiteral */) { + if (type.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts_1 = type.texts; var types_1 = type.types; var templateHead = ts.factory.createTemplateHead(texts_1[0]); @@ -52987,32 +53170,32 @@ var ts; context.approximateLength += 2; return ts.factory.createTemplateLiteralType(templateHead, templateSpans); } - if (type.flags & 268435456 /* StringMapping */) { + if (type.flags & 268435456 /* TypeFlags.StringMapping */) { var typeNode = typeToTypeNodeHelper(type.type, context); - return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, [typeNode]); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); }); } - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return typeToTypeNodeHelper(type.baseType, context); } return ts.Debug.fail("Should be unreachable."); function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); context.approximateLength += 15; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeFlags.TypeParameter */)) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); var newTypeVariable = ts.factory.createTypeReferenceNode(name); context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type - var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.mapper); var saveInferTypeParameters_1 = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); @@ -53029,7 +53212,7 @@ var ts; // On the other hand, // checkType extends infer T extends checkType ? T extends extendsType ? trueType : falseType : never; // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS. - return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -53041,9 +53224,9 @@ var ts; } function typeToTypeNodeOrCircularityElision(type) { var _a, _b, _c; - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) { - if (!(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + if (!(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b); } @@ -53053,8 +53236,12 @@ var ts; } return typeToTypeNodeHelper(type, context); } + function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) { + return isMappedTypeWithKeyofConstraintDeclaration(type) + && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */); + } function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -53062,27 +53249,28 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); } - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; - var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined); context.approximateLength += 10; - var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + var result = ts.setEmitFlags(mappedTypeNode, 1 /* EmitFlags.SingleLine */); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { // homomorphic mapped type with a non-homomorphic naive inlining // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting // type stays homomorphic - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName), originalConstraint.flags & 2 /* TypeFlags.Unknown */ ? undefined : typeToTypeNodeHelper(originalConstraint, context))), result, ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } return result; } @@ -53091,16 +53279,16 @@ var ts; var typeId = type.id; var symbol = type.symbol; if (symbol) { - var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = isClassInstanceSide(type) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */; if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ + else if (symbol.flags & 32 /* SymbolFlags.Class */ && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* Accessible */)) || - symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */)) || + symbol.flags & (384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); } @@ -53109,7 +53297,7 @@ var ts; var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 788968 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* SymbolFlags.Type */); } else { return createElidedInformationPlaceholder(context); @@ -53125,26 +53313,26 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var _a; - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* SymbolFlags.Method */) && // typeof static method ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); }); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* SymbolFlags.Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 305 /* SourceFile */ || declaration.parent.kind === 262 /* ModuleBlock */; + return declaration.parent.kind === 305 /* SyntaxKind.SourceFile */ || declaration.parent.kind === 262 /* SyntaxKind.ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + return (!!(context.flags & 4096 /* NodeBuilderFlags.UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively + (!(context.flags & 8 /* NodeBuilderFlags.UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } function visitAndTransformType(type, transform) { var _a, _b; var typeId = type.id; - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : - type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) : + var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */; + var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) : type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : undefined; // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead @@ -53156,7 +53344,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -53215,20 +53403,20 @@ var ts; if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { context.approximateLength += 2; - return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* EmitFlags.SingleLine */); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* SyntaxKind.FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* SyntaxKind.ConstructorType */, context); return signatureNode; } } - var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); }); + var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (ts.some(abstractSignatures)) { var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature); // count the number of type elements excluding abstract constructors @@ -53237,8 +53425,8 @@ var ts; resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per // the logic in `createTypeNodesFromResolvedType`. - (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? - ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* Prototype */); }) : + (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ ? + ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */); }) : ts.length(resolved.properties)); // don't include an empty object literal if there were no other static-side // properties to write, i.e. `abstract class C { }` becomes `abstract new () => {}` @@ -53250,27 +53438,27 @@ var ts; return typeToTypeNodeHelper(getIntersectionType(types), context); } var savedFlags = context.flags; - context.flags |= 4194304 /* InObjectTypeLiteral */; + context.flags |= 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */; var members = createTypeNodesFromResolvedType(resolved); context.flags = savedFlags; var typeLiteralNode = ts.factory.createTypeLiteralNode(members); context.approximateLength += 2; - ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); + ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* NodeBuilderFlags.MultilineObjectLiterals */) ? 0 : 1 /* EmitFlags.SingleLine */); return typeLiteralNode; } function typeReferenceToTypeNode(type) { var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { - if (context.flags & 2 /* WriteArrayAsGenericType */) { + if (context.flags & 2 /* NodeBuilderFlags.WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]); } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, arrayType); } - else if (type.target.objectFlags & 8 /* Tuple */) { - typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); }); + else if (type.target.objectFlags & 8 /* ObjectFlags.Tuple */) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* ElementFlags.Optional */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -53278,7 +53466,7 @@ var ts; if (type.target.labeledElementDeclarations) { for (var i = 0; i < tupleConstituentNodes.length; i++) { var flags = type.target.elementFlags[i]; - tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* Variable */ ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : + tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* ElementFlags.Variable */ ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* ElementFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]); } } @@ -53286,23 +53474,23 @@ var ts; for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) { var flags = type.target.elementFlags[i]; tupleConstituentNodes[i] = - flags & 12 /* Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : - flags & 2 /* Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : + flags & 12 /* ElementFlags.Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : + flags & 2 /* ElementFlags.Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]; } } - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } - if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + if (context.encounteredError || (context.flags & 524288 /* NodeBuilderFlags.AllowEmptyTuple */)) { + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 } - else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && + else if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { @@ -53326,8 +53514,8 @@ var ts; if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_3 = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var ref = symbolToTypeNode(parent, context, 788968 /* SymbolFlags.Type */, typeArgumentSlice); context.flags = flags_3; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -53339,8 +53527,8 @@ var ts; typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); } var flags = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -53404,17 +53592,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* SyntaxKind.CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - if (signature.flags & 4 /* Abstract */) + if (signature.flags & 4 /* SignatureFlags.Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* SyntaxKind.ConstructSignature */, context)); } for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { var info = _e[_d]; - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); } var properties = resolvedType.properties; if (!properties) { @@ -53424,16 +53612,16 @@ var ts; for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) { var propertySymbol = properties_1[_f]; i++; - if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) { - if (propertySymbol.flags & 4194304 /* Prototype */) { + if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) { + if (propertySymbol.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } - if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName)); } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... " + (properties.length - i) + " more ...", /*questionToken*/ undefined, /*type*/ undefined)); + typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... ".concat(properties.length - i, " more ..."), /*questionToken*/ undefined, /*type*/ undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -53444,10 +53632,10 @@ var ts; } function createElidedInformationPlaceholder(context) { context.approximateLength += 3; - if (!(context.flags & 1 /* NoTruncation */)) { + if (!(context.flags & 1 /* NodeBuilderFlags.NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -53457,14 +53645,14 @@ var ts; // Since anonymous types usually come from expressions, this allows us to preserve the output // for deep mappings which likely come from expressions, while truncating those parts which // come from mappings over library functions. - return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) + return !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */) && (ts.contains(context.reverseMappedStack, propertySymbol) || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) - && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* ObjectFlags.Anonymous */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { var _a, _b; - var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); + var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */); var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; @@ -53492,12 +53680,12 @@ var ts; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined; - if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { - var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); + var optionalToken = propertySymbol.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { + var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* TypeFlags.Undefined */); }), 0 /* SignatureKind.Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* SyntaxKind.MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -53511,12 +53699,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -53525,11 +53713,11 @@ var ts; } function preserveCommentsOn(node) { var _a; - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* JSDocPropertyTag */; })) { - var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; }); var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { - ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } } else if (propertySymbol.valueDeclaration) { @@ -53548,12 +53736,12 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", /*typeArguments*/ undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), /*typeArguments*/ undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } } - var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); + var mayHaveNameCollisions = !(context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */); /** Map from type reference identifier text to [type, index in `result` where the type node is] */ var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; var result_5 = []; @@ -53562,7 +53750,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -53587,7 +53775,7 @@ var ts; // type node for each entry by that name with the // `UseFullyQualifiedType` flag enabled. var saveContextFlags = context.flags; - context.flags |= 64 /* UseFullyQualifiedType */; + context.flags |= 64 /* NodeBuilderFlags.UseFullyQualifiedType */; seenNames.forEach(function (types) { if (!ts.arrayIsHomogeneous(types, function (_a, _b) { var a = _a[0]; @@ -53621,21 +53809,21 @@ var ts; if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); } - if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { + if (!indexInfo.type && !(context.flags & 2097152 /* NodeBuilderFlags.AllowEmptyIndexInfoType */)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); - return ts.factory.createIndexSignature(indexInfo.isReadonly ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + return ts.factory.createIndexSignature(indexInfo.isReadonly ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; - var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; + var suppressAny = context.flags & 256 /* NodeBuilderFlags.SuppressAnyReturnType */; if (suppressAny) - context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s + context.flags &= ~256 /* NodeBuilderFlags.SuppressAnyReturnType */; // suppress only toplevel `any`s context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum var typeParameters; var typeArguments; - if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { + if (context.flags & 32 /* NodeBuilderFlags.WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); }); } else { @@ -53643,19 +53831,19 @@ var ts; } var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; // If the expanded parameter list had a variadic in a non-trailing position, don't expand it - var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); - var thisParameter = tryGetThisParameterDeclaration(signature, context); + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* CheckFlags.RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* SyntaxKind.Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var thisParameter = context.flags & 33554432 /* NodeBuilderFlags.OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); } var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(128 /* AssertsKeyword */) : + var assertsModifier = typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined; - var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : + var parameterName = typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* EmitFlags.NoAsciiEscaping */) : ts.factory.createThisTypeNode(); var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode); @@ -53666,28 +53854,28 @@ var ts; returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); } else if (!suppressAny) { - returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 180 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 180 /* SyntaxKind.ConstructorType */) && signature.flags & 4 /* SignatureFlags.Abstract */) { var flags = ts.modifiersToFlags(modifiers); - modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); - } - var node = kind === 174 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 175 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 168 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 169 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 171 /* Constructor */ ? ts.factory.createConstructorDeclaration(modifiers, parameters, /*body*/ undefined) : - kind === 172 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 173 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 176 /* IndexSignature */ ? ts.factory.createIndexSignature(modifiers, parameters, returnTypeNode) : - kind === 317 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 179 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 180 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 256 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 213 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 214 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* ModifierFlags.Abstract */); + } + var node = kind === 174 /* SyntaxKind.CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 175 /* SyntaxKind.ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 168 /* SyntaxKind.MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 169 /* SyntaxKind.MethodDeclaration */ ? ts.factory.createMethodDeclaration(modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 171 /* SyntaxKind.Constructor */ ? ts.factory.createConstructorDeclaration(modifiers, parameters, /*body*/ undefined) : + kind === 172 /* SyntaxKind.GetAccessor */ ? ts.factory.createGetAccessorDeclaration(modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 173 /* SyntaxKind.SetAccessor */ ? ts.factory.createSetAccessorDeclaration(modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 176 /* SyntaxKind.IndexSignature */ ? ts.factory.createIndexSignature(modifiers, parameters, returnTypeNode) : + kind === 317 /* SyntaxKind.JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 179 /* SyntaxKind.FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 180 /* SyntaxKind.ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 213 /* SyntaxKind.FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 214 /* SyntaxKind.ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -53710,7 +53898,7 @@ var ts; } function typeParameterToDeclarationWithConstraint(type, context, constraintNode) { var savedContextFlags = context.flags; - context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic + context.flags &= ~512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic var modifiers = ts.factory.createModifiersFromModifierFlags(getVarianceModifiers(type)); var name = typeParameterToName(type, context); var defaultParameter = getDefaultFromTypeParameter(type); @@ -53724,26 +53912,26 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* SyntaxKind.Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* SyntaxKind.JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && ts.canHaveModifiers(parameterDeclaration) ? ts.map(ts.getModifiers(parameterDeclaration), ts.factory.cloneNode) : undefined; - var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; - var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; + var modifiers = !(context.flags & 8192 /* NodeBuilderFlags.OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && ts.canHaveModifiers(parameterDeclaration) ? ts.map(ts.getModifiers(parameterDeclaration), ts.factory.cloneNode) : undefined; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* CheckFlags.RestParameter */; + var dotDotDotToken = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 161 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* EmitFlags.NoAsciiEscaping */) : + parameterDeclaration.name.kind === 161 /* SyntaxKind.QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* EmitFlags.NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* CheckFlags.OptionalParameter */; + var questionToken = isOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var parameterNode = ts.factory.createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); context.approximateLength += ts.symbolName(parameterSymbol).length + 3; @@ -53769,7 +53957,7 @@ var ts; if (!ts.nodeIsSynthesized(visited)) { visited = ts.factory.cloneNode(visited); } - return ts.setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); + return ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */ | 16777216 /* EmitFlags.NoAsciiEscaping */); } } } @@ -53778,9 +53966,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = ts.getFirstIdentifier(accessExpression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* SymbolFlags.Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -53790,8 +53978,8 @@ var ts; function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) { + var isTypeParameter = symbol.flags & 262144 /* SymbolFlags.TypeParameter */; + if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */) && !(context.flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */)) { chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } @@ -53801,7 +53989,7 @@ var ts; return chain; /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol, meaning, endOfChain) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */)); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */)); var parentSpecifiers; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -53820,8 +54008,8 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { - if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && - getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + if (parent.exports && parent.exports.get("export=" /* InternalSymbolName.ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* InternalSymbolName.ExportEquals */), symbol)) { // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent // No need to lookup an alias for the symbol in itself accessibleSymbolChain = parentChain; @@ -53840,7 +54028,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */))) { // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return; @@ -53870,7 +54058,7 @@ var ts; function typeParametersToTypeParameterDeclarations(symbol, context) { var typeParameterNodes; var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + if (targetSymbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 524288 /* SymbolFlags.TypeAlias */)) { typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); })); } return typeParameterNodes; @@ -53885,11 +54073,11 @@ var ts; } (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId); var typeParameterNodes; - if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { + if (context.flags & 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { var parentSymbol = symbol; var nextSymbol_1 = chain[index + 1]; - if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) { - var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol); + if (ts.getCheckFlags(nextSymbol_1) & 1 /* CheckFlags.Instantiated */) { + var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(parentSymbol) : parentSymbol); typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context); } else { @@ -53909,11 +54097,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context, overrideImportMode) { var _a; - var file = ts.getDeclarationOfKind(symbol, 305 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SyntaxKind.SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -53965,7 +54153,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -53974,8 +54162,8 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var _a, _b, _c, _d; - var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 111551 /* Value */; + var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module + var isTypeOf = meaning === 111551 /* SymbolFlags.Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -53997,7 +54185,7 @@ var ts; if (!specifier) { specifier = getSpecifierForModuleSymbol(chain[0], context); } - if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & 67108864 /* NodeBuilderFlags.AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { var oldSpecifier = specifier; if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set @@ -54059,16 +54247,16 @@ var ts; var parent = chain[index - 1]; var symbolName; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; symbolName = getNameOfSymbolAsWritten(symbol, context); context.approximateLength += (symbolName ? symbolName.length : 0) + 1; - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } else { if (parent && getExportsOfSymbol(parent)) { var exports_2 = getExportsOfSymbol(parent); ts.forEachEntry(exports_2, function (ex, name) { - if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* InternalSymbolName.ExportEquals */) { symbolName = ts.unescapeLeadingUnderscores(name); return true; } @@ -54087,7 +54275,7 @@ var ts; symbolName = getNameOfSymbolAsWritten(symbol, context); } context.approximateLength += symbolName.length + 1; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + if (!(context.flags & 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access @@ -54099,7 +54287,7 @@ var ts; return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName))); } } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; if (index > stopper) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); @@ -54112,9 +54300,9 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context, type) { - var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* SymbolFlags.Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); if (result) { - if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) { + if (result.flags & 262144 /* SymbolFlags.TypeParameter */ && result === type.symbol) { return false; } return true; @@ -54123,23 +54311,23 @@ var ts; } function typeParameterToName(type, context) { var _a, _b; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { return cached; } } - var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 79 /* Identifier */)) { + var result = symbolToName(type.symbol, context, 788968 /* SymbolFlags.Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 79 /* SyntaxKind.Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -54156,7 +54344,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* NodeBuilderFlags.AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -54164,13 +54352,13 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -54182,38 +54370,38 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); } - var canUsePropertyAccess = firstChar === 35 /* hash */ ? + var canUsePropertyAccess = firstChar === 35 /* CharacterCodes.hash */ ? symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) : ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier; } else { - if (firstChar === 91 /* openBracket */) { + if (firstChar === 91 /* CharacterCodes.openBracket */) { symbolName = symbolName.substring(1, symbolName.length - 1); firstChar = symbolName.charCodeAt(0); } var expression = void 0; - if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) { - expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */); + if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* SymbolFlags.EnumMember */)) { + expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* CharacterCodes.singleQuote */); } else if (("" + +symbolName) === symbolName) { expression = ts.factory.createNumericLiteral(+symbolName); } if (!expression) { - expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); expression.symbol = symbol; } return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression); @@ -54242,7 +54430,7 @@ var ts; function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { return ts.factory.createStringLiteral(name, !!singleQuote); @@ -54252,8 +54440,8 @@ var ts; } return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions)); } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* SymbolFlags.Value */)); } } } @@ -54287,7 +54475,7 @@ var ts; 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); + return !(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag @@ -54308,9 +54496,9 @@ var ts; } } var oldFlags = context.flags; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { - context.flags |= 1048576 /* AllowUniqueESSymbolType */; + context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } var result = typeToTypeNodeHelper(type, context); context.flags = oldFlags; @@ -54322,7 +54510,7 @@ var ts; return true; } if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { - return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode; + return getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */) === typeFromTypeNode; } return false; } @@ -54331,7 +54519,7 @@ var ts; var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { var annotated = getTypeFromTypeNode(annotation); - var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + var thisInstantiated = annotated.flags & 262144 /* TypeFlags.TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { @@ -54350,20 +54538,20 @@ var ts; introducesError = true; return { introducesError: introducesError, node: node }; } - var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + var sym = resolveEntityName(leftmost, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); if (sym) { - if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) { + if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */) { introducesError = true; } else { - (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */); + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */); includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym); } if (ts.isIdentifier(node)) { var type = getDeclaredTypeOfSymbol(sym); - var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); + var name = sym.flags & 262144 /* SymbolFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); name.symbol = sym; // for quickinfo, which uses identifier symbol information - return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) }; + return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* EmitFlags.NoAsciiEscaping */) }; } } return { introducesError: introducesError, node: node }; @@ -54381,17 +54569,17 @@ var ts; return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 319 /* SyntaxKind.JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -54405,11 +54593,11 @@ var ts; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; return ts.factory.createPropertySignature( - /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -54424,15 +54612,15 @@ var ts; return ts.factory.createConstructorTypeNode( /*modifiers*/ undefined, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration( /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) { + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } if (ts.isLiteralImportTypeNode(node)) { @@ -54441,7 +54629,7 @@ var ts; nodeSymbol && ( // The import type resolved using jsdoc fallback logic - (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */)) || + (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* SymbolFlags.Type */)) || // The import type had type arguments autofilled by js fallback logic !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); @@ -54456,17 +54644,17 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); function getEffectiveDotDotDotForParameter(p) { - return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined); + return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined); } /** Note that `new:T` parameters are not handled, but should be before calling this function. */ function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -54497,8 +54685,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* SyntaxKind.MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* SyntaxKind.MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -54511,10 +54699,10 @@ var ts; var oldcontext = context; context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); - if (accessibleResult.accessibility === 0 /* Accessible */) { + if (accessibleResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Lookup the root symbol of the chain of refs we'll use to access it and serialize it var chain = lookupSymbolChainWorker(sym, context, meaning); - if (!(sym.flags & 4 /* Property */)) { + if (!(sym.flags & 4 /* SymbolFlags.Property */)) { includePrivateSymbol(chain[0]); } } @@ -54529,16 +54717,16 @@ var ts; void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` }); var addingDeclare = !bundled; - var exportEquals = symbolTable.get("export=" /* ExportEquals */); - if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + var exportEquals = symbolTable.get("export=" /* InternalSymbolName.ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* SymbolFlags.Alias */) { symbolTable = ts.createSymbolTable(); // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) - symbolTable.set("export=" /* ExportEquals */, exportEquals); + symbolTable.set("export=" /* InternalSymbolName.ExportEquals */, exportEquals); } visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 79 /* Identifier */; + return !!node && node.kind === 79 /* SyntaxKind.Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -54555,7 +54743,7 @@ var ts; ns.body && ts.isModuleBlock(ns.body)) { // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments - var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* Export */); }); + var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* ModifierFlags.Export */); }); var name_3 = ns.name; var body = ns.body; if (ts.length(excessExports)) { @@ -54570,9 +54758,9 @@ var ts; results = []; // If the namespace contains no export assignments or declarations, and no declarations flagged with `export`, then _everything_ is exported - // to respect this as the top level, we need to add an `export` modifier to everything - var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); + var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* ModifierFlags.Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); ts.forEach(body.statements, function (s) { - addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + addResult(s, mixinExportFlag_1 ? 1 /* ModifierFlags.Export */ : 0 /* ModifierFlags.None */); // Recalculates the ambient (and export, if applicable from above) flag }); statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true); } @@ -54666,11 +54854,11 @@ var ts; isTypeDeclaration(node); } function addExportModifier(node) { - var flags = (ts.getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; + var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */; return ts.factory.updateModifiers(node, flags); } function removeExportModifier(node) { - var flags = ts.getEffectiveModifierFlags(node) & ~1 /* Export */; + var flags = ts.getEffectiveModifierFlags(node) & ~1 /* ModifierFlags.Export */; return ts.factory.updateModifiers(node, flags); } function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { @@ -54703,12 +54891,11 @@ var ts; if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { var oldContext = context; context = cloneNodeBuilderContext(context); - var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); if (context.reportedDiagnostic) { oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context } context = oldContext; - return result; } } // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias @@ -54723,37 +54910,37 @@ var ts; function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { var _a, _b, _c, _d; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isDefault = symbol.escapedName === "default" /* Default */; - if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */; + if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( context.encounteredError = true; // TODO: Issue error via symbol tracker? return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name } - var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ - || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault; // `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); - var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && - symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && - symbol.escapedName !== "export=" /* ExportEquals */; + var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ && + symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) && + symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); - if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { serializeTypeAlias(symbol, symbolName, modifierFlags); } // Need to skip over export= symbols below - json source files get a single `Property` flagged // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. - if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) - && symbol.escapedName !== "export=" /* ExportEquals */ - && !(symbol.flags & 4194304 /* Prototype */) - && !(symbol.flags & 32 /* Class */) + if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) + && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */) + && !(symbol.flags & 32 /* SymbolFlags.Class */) && !isConstMergedWithNSPrintableAsSignatureMerge) { if (propertyAsAlias) { var createdExport = serializeMaybeAliasAssignment(symbol); @@ -54765,21 +54952,21 @@ var ts; else { var type = getTypeOfSymbol(symbol); var localName = getInternalSymbolName(symbol, symbolName); - if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); } else { // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` - var flags = !(symbol.flags & 2 /* BlockScopedVariable */) + var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) - ? 2 /* Const */ + ? 2 /* NodeFlags.Const */ : undefined : isConstVariable(symbol) - ? 2 /* Const */ - : 1 /* Let */; - var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + ? 2 /* NodeFlags.Const */ + : 1 /* NodeFlags.Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* SymbolFlags.Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; @@ -54790,14 +54977,14 @@ var ts; var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */); - context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* ModifierFlags.None */); + context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* SymbolFlags.Value */); } else { var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~1 /* ModifierFlags.Export */ : modifierFlags); if (name !== localName && !isPrivate) { // We rename the variable declaration we generate for Property symbols since they may have a name which // conflicts with a local declaration. For example, given input: @@ -54822,7 +55009,7 @@ var ts; // To create an export named `g` that does _not_ shadow the local `g` addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* ModifierFlags.None */); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -54830,11 +55017,11 @@ var ts; } } } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { serializeEnum(symbol, symbolName, modifierFlags); } - if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ + if (symbol.flags & 32 /* SymbolFlags.Class */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { @@ -54847,20 +55034,20 @@ var ts; serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } } - if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + if ((symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeModule(symbol, symbolName, modifierFlags); } // The class meaning serialization should handle serializing all interface members - if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) { + if (symbol.flags & 64 /* SymbolFlags.Interface */ && !(symbol.flags & 32 /* SymbolFlags.Class */)) { serializeInterface(symbol, symbolName, modifierFlags); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } - if (symbol.flags & 8388608 /* ExportStar */) { + if (symbol.flags & 8388608 /* SymbolFlags.ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration if (symbol.declarations) { @@ -54869,17 +55056,17 @@ var ts; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); if (!resolvedModule) continue; - addResult(ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + addResult(ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* ModifierFlags.None */); } } } if (needsPostExportDefault) { - addResult(ts.factory.createExportAssignment(/*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + addResult(ts.factory.createExportAssignment(/*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* ModifierFlags.None */); } else if (needsExportDeclaration) { addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* ModifierFlags.None */); } } function includePrivateSymbol(symbol) { @@ -54892,7 +55079,7 @@ var ts; // will throw a wrench in this, since those may have been nested, but we'll need to synthesize them in the outer scope // anyway, as that's the only place the import they translate to is valid. In such a case, we might need to use a unique name // for the moved import; which hopefully the above `getUnusedName` call should produce. - var isExternalImportAlias = !!(symbol.flags & 2097152 /* Alias */) && !ts.some(symbol.declarations, function (d) { + var isExternalImportAlias = !!(symbol.flags & 2097152 /* SymbolFlags.Alias */) && !ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, ts.isExportDeclaration) || ts.isNamespaceExport(d) || (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference)); @@ -54906,23 +55093,23 @@ var ts; // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { - var newModifierFlags = 0 /* None */; + var newModifierFlags = 0 /* ModifierFlags.None */; var enclosingDeclaration_1 = context.enclosingDeclaration && (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && + if (additionalModifierFlags & 1 /* ModifierFlags.Export */ && enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) && canHaveExportModifier(node)) { // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private - newModifierFlags |= 1 /* Export */; + newModifierFlags |= 1 /* ModifierFlags.Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) && + if (addingDeclare && !(newModifierFlags & 1 /* ModifierFlags.Export */) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* NodeFlags.Ambient */)) && (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope - newModifierFlags |= 2 /* Ambient */; + newModifierFlags |= 2 /* ModifierFlags.Ambient */; } - if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { - newModifierFlags |= 512 /* Default */; + if ((additionalModifierFlags & 512 /* ModifierFlags.Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* ModifierFlags.Default */; } if (newModifierFlags) { node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node)); @@ -54938,14 +55125,14 @@ var ts; var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias); var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined); var oldFlags = context.flags; - context.flags |= 8388608 /* InTypeAlias */; + context.flags |= 8388608 /* NodeBuilderFlags.InTypeAlias */; var oldEnclosingDecl = context.enclosingDeclaration; context.enclosingDeclaration = jsdocAliasDecl; var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); - addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; context.enclosingDeclaration = oldEnclosingDecl; } @@ -54956,10 +55143,10 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 174 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 175 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* SignatureKind.Call */, interfaceType, baseType, 174 /* SyntaxKind.CallSignature */); + var constructSignatures = serializeSignatures(1 /* SignatureKind.Construct */, interfaceType, baseType, 175 /* SyntaxKind.ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* SymbolFlags.Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); } @@ -54967,7 +55154,7 @@ var ts; return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); } function isTypeOnlyNamespace(symbol) { - return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); }); } function serializeModule(symbol, symbolName, modifierFlags) { var members = getNamespaceMembersForSerialization(symbol); @@ -54980,14 +55167,14 @@ var ts; // so we don't even have placeholders to fill in. if (ts.length(realMembers)) { var localName = getInternalSymbolName(symbol, symbolName); - serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* SymbolFlags.Function */ | 67108864 /* SymbolFlags.Assignment */))); } if (ts.length(mergedMembers)) { var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); var localName = getInternalSymbolName(symbol, symbolName); var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; }), function (s) { var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); @@ -55002,11 +55189,11 @@ var ts; return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name === targetName ? undefined : targetName, name); })))]); addResult(ts.factory.createModuleDeclaration( - /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* NodeFlags.Namespace */), 0 /* ModifierFlags.None */); } } function serializeEnum(symbol, symbolName, modifierFlags) { - addResult(ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + addResult(ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* ModifierFlags.Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* SymbolFlags.EnumMember */); }), function (p) { // TODO: Handle computed names // I hate that to get the initialized value we need to walk back to the declarations here; but there's no // other way to get the possible const value of an enum member that I'm aware of, as the value is cached @@ -55018,22 +55205,22 @@ var ts; })), modifierFlags); } function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 256 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 256 /* SyntaxKind.FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports - if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + if (!(symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } function getSignatureTextRangeLocation(signature) { if (signature.declaration && signature.declaration.parent) { - if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* AssignmentDeclarationKind.Property */) { return signature.declaration.parent; } // for expressions assigned to `var`s, use the `var` as the text range @@ -55067,7 +55254,7 @@ var ts; // emit akin to the above would be needed. // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace, enclosingDeclaration); fakespace.locals = ts.createSymbolTable(props); fakespace.symbol = props[0].parent; @@ -55087,15 +55274,15 @@ var ts; // replace namespace with synthetic version var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); - var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* InternalSymbolName.Default */))])) : d; }); + var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* ModifierFlags.Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); // namespaces can never be default exported } } function isNamespaceMember(p) { - return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); + return !!(p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */)) || + !(p.flags & 4194304 /* SymbolFlags.Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); } function sanitizeJSDocImplements(clauses) { var result = ts.mapDefined(clauses, function (e) { @@ -55144,7 +55331,7 @@ var ts; var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* SyntaxKind.ImplementsKeyword */, implementsExpressions)], true); var symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from @@ -55170,17 +55357,17 @@ var ts; ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); // When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether // the value is ever initialized with a class or function-like value. For cases where `X` could never be // created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable. var isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && ts.isInJSFile(symbol.valueDeclaration) && - !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); + !ts.some(getSignaturesOfType(staticType, 1 /* SignatureKind.Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? - [ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 171 /* Constructor */); + [ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(8 /* ModifierFlags.Private */), [], /*body*/ undefined)] : + serializeSignatures(1 /* SignatureKind.Construct */, staticType, staticBaseType, 171 /* SyntaxKind.Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -55222,34 +55409,34 @@ var ts; // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === "export=" /* InternalSymbolName.ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match - verbatimTargetName = "default" /* Default */; + verbatimTargetName = "default" /* InternalSymbolName.Default */; } var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 203 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* VariableDeclaration */) { + case 203 /* SyntaxKind.BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* SyntaxKind.VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier( /*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), - /*importClause*/ undefined), 0 /* None */); + /*importClause*/ undefined), 0 /* ModifierFlags.None */); break; } // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 297 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* BinaryExpression */) { + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* SyntaxKind.BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -55259,7 +55446,7 @@ var ts; // import _x = require('y'); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */); + /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* ModifierFlags.None */); // import x = _x.z addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, @@ -55267,48 +55454,48 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // This _specifically_ only exists to handle json declarations - where we make aliases, but since // we emit no declarations for the json document, must not refer to it in the declarations - if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { + if (target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { serializeMaybeAliasAssignment(symbol); break; } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node); + var isLocalImport = !(target.flags & 512 /* SymbolFlags.ValueModule */) && !ts.isVariableDeclaration(node); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createIdentifier(localName), isLocalImport - ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) - : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); + ? symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false) + : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* ModifierFlags.None */); break; - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse - addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* ModifierFlags.None */); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* ModifierFlags.None */); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause( /*isTypeOnly*/ false, @@ -55316,9 +55503,9 @@ var ts; ts.factory.createImportSpecifier( /*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -55326,16 +55513,16 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 221 /* BinaryExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier - if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */ || symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } else { @@ -55349,18 +55536,18 @@ var ts; function serializeExportSpecifier(localName, targetName, specifier) { addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* ModifierFlags.None */); } /** * Returns `true` if an export assignment or declaration was produced for the symbol */ function serializeMaybeAliasAssignment(symbol) { - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return false; } var name = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isExportEquals = name === "export=" /* ExportEquals */; - var isDefault = name === "default" /* Default */; + var isExportEquals = name === "export=" /* InternalSymbolName.ExportEquals */; + var isDefault = name === "default" /* InternalSymbolName.Default */; var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault; // synthesize export = ref // ref should refer to either be a locally scoped symbol which we need to emit, or @@ -55375,7 +55562,7 @@ var ts; // Technically, this is all that's required in the case where the assignment is an entity name expression var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl)); var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; - var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); if (referenced || target) { includePrivateSymbol(referenced || target); } @@ -55388,7 +55575,7 @@ var ts; context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( - /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* SymbolFlags.All */))); } else { if (first_1 === expr && first_1) { @@ -55403,7 +55590,7 @@ var ts; var varName = getUnusedName(name, symbol); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)), 0 /* ModifierFlags.None */); serializeExportSpecifier(name, varName); } } @@ -55418,17 +55605,17 @@ var ts; var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* ModifierFlags.None */ : 1 /* ModifierFlags.Export */); } else { var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* SymbolFlags.Property */ && target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ModifierFlags.Ambient */ + : name === varName ? 1 /* ModifierFlags.Export */ + : 0 /* ModifierFlags.None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -55447,11 +55634,11 @@ var ts; // context source file, and whose property names are all valid identifiers and not late-bound, _and_ // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); - return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + return ts.getObjectFlags(typeToSerialize) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */) && !ts.length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class - !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && - !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* SignatureKind.Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* SignatureKind.Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && @@ -55462,33 +55649,33 @@ var ts; return function serializePropertySymbol(p, isStatic, baseType) { var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); - var isPrivate = !!(modifierFlags & 8 /* Private */); - if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + var isPrivate = !!(modifierFlags & 8 /* ModifierFlags.Private */); + if (isStatic && (p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members return []; } - if (p.flags & 4194304 /* Prototype */ || + if (p.flags & 4194304 /* SymbolFlags.Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) - && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && (p.flags & 16777216 /* SymbolFlags.Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* SymbolFlags.Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* ModifierFlags.Async */) | (isStatic ? 32 /* ModifierFlags.Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); - if (p.flags & 98304 /* Accessor */ && useAccessors) { + if (p.flags & 98304 /* SymbolFlags.Accessor */ && useAccessors) { var result = []; - if (p.flags & 65536 /* SetAccessor */) { + if (p.flags & 65536 /* SymbolFlags.SetAccessor */) { result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], /*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } - if (p.flags & 32768 /* GetAccessor */) { - var isPrivate_1 = modifierFlags & 8 /* Private */; + if (p.flags & 32768 /* SymbolFlags.GetAccessor */) { + var isPrivate_1 = modifierFlags & 8 /* ModifierFlags.Private */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } @@ -55496,17 +55683,17 @@ var ts; } // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints - else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { - return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), + else if (p.flags & (4 /* SymbolFlags.Property */ | 3 /* SymbolFlags.Variable */ | 98304 /* SymbolFlags.Accessor */)) { + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } - if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + if (p.flags & (8192 /* SymbolFlags.Method */ | 16 /* SymbolFlags.Function */)) { var type = getTypeOfSymbol(p); - var signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { - return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); + if (flag & 8 /* ModifierFlags.Private */) { + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, /*type*/ undefined, /*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } @@ -55516,7 +55703,7 @@ var ts; // Each overload becomes a separate method declaration, in order var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, { name: name, - questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + questionToken: p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; @@ -55525,7 +55712,7 @@ var ts; return results_1; } // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -55533,13 +55720,13 @@ var ts; } function serializeSignatures(kind, input, baseType, outputKind) { var signatures = getSignaturesOfType(input, kind); - if (kind === 1 /* Construct */) { + if (kind === 1 /* SignatureKind.Construct */) { if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // No base type, every constructor is empty - elide the extraneous `constructor()` } if (baseType) { // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations - var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + var baseSigs = getSignaturesOfType(baseType, 1 /* SignatureKind.Construct */); if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list } @@ -55560,7 +55747,7 @@ var ts; for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { var s = signatures_4[_i]; if (s.declaration) { - privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */); } } if (privateProtected) { @@ -55595,15 +55782,15 @@ var ts; return results; } function serializeBaseType(t, staticType, rootName) { - var ref = trySerializeAsTypeReference(t, 111551 /* Value */); + var ref = trySerializeAsTypeReference(t, 111551 /* SymbolFlags.Value */); if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context)) - ], 2 /* Const */)); - addResult(statement, 0 /* None */); + ], 2 /* NodeFlags.Const */)); + addResult(statement, 0 /* ModifierFlags.None */); return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), /*typeArgs*/ undefined); } function trySerializeAsTypeReference(t, flags) { @@ -55613,22 +55800,22 @@ var ts; // which we can't write out in a syntactically valid way as an expression if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) { typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); - reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.target.symbol, context, 788968 /* SymbolFlags.Type */); } else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) { - reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */); } if (reference) { return ts.factory.createExpressionWithTypeArguments(reference, typeArgs); } } function serializeImplementedType(t) { - var ref = trySerializeAsTypeReference(t, 788968 /* Type */); + var ref = trySerializeAsTypeReference(t, 788968 /* SymbolFlags.Type */); if (ref) { return ref; } if (t.symbol) { - return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* Type */), /*typeArgs*/ undefined); + return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */), /*typeArgs*/ undefined); } } function getUnusedName(input, symbol) { @@ -55646,7 +55833,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -55655,17 +55842,17 @@ var ts; return input; } function getNameCandidateWorker(symbol, localName) { - if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + if (localName === "default" /* InternalSymbolName.Default */ || localName === "__class" /* InternalSymbolName.Class */ || localName === "__function" /* InternalSymbolName.Function */) { var flags = context.flags; - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; var nameCandidate = getNameOfSymbolAsWritten(symbol, context); context.flags = flags; localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; } - if (localName === "default" /* Default */) { + if (localName === "default" /* InternalSymbolName.Default */) { localName = "_default"; } - else if (localName === "export=" /* ExportEquals */) { + else if (localName === "export=" /* InternalSymbolName.ExportEquals */) { localName = "_exports"; } localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); @@ -55684,14 +55871,14 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined, typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */) // TODO: GH#18217 ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); return writer; } } @@ -55701,10 +55888,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 98304 /* Nullable */)) { - if (t.flags & (512 /* BooleanLiteral */ | 1024 /* EnumLiteral */)) { - var baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 1048576 /* Union */) { + if (!(t.flags & 98304 /* TypeFlags.Nullable */)) { + if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) { + var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 1048576 /* TypeFlags.Union */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -55716,25 +55903,25 @@ var ts; result.push(t); } } - if (flags & 65536 /* Null */) + if (flags & 65536 /* TypeFlags.Null */) result.push(nullType); - if (flags & 32768 /* Undefined */) + if (flags & 32768 /* TypeFlags.Undefined */) result.push(undefinedType); return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 8 /* ModifierFlags.Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 16 /* ModifierFlags.Protected */) { return "protected"; } return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { + if (type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 259 /* TypeAliasDeclaration */) { + if (node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -55742,27 +55929,27 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 262 /* ModuleBlock */ && + node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 305 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 305 /* SyntaxKind.SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\""; + return "\"".concat(ts.escapeString(name, 34 /* CharacterCodes.doubleQuote */), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -55774,9 +55961,9 @@ var ts; * It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`. */ function getNameOfSymbolAsWritten(symbol, context) { - if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && + if (context && symbol.escapedName === "default" /* InternalSymbolName.Default */ && !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default` - (!(context.flags & 16777216 /* InInitialEntityName */) || + (!(context.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default` !symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default` @@ -55790,9 +55977,9 @@ var ts; if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } - if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* Late */)) { + if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */)) { var nameType = getSymbolLinks(symbol).nameType; - if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType && nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { // Computed property name isn't late bound, but has a well-known name type - use name type to generate a symbol name var result = getNameOfSymbolFromNameType(symbol, context); if (result !== undefined) { @@ -55805,17 +55992,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 254 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 226 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 226 /* SyntaxKind.ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -55832,84 +56019,84 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return isDeclarationVisible(node.parent.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 256 /* FunctionDeclaration */: - case 260 /* EnumDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) { + if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) && + !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 164 /* Parameter */: - case 262 /* ModuleBlock */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 178 /* TypeReference */: - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 164 /* SyntaxKind.Parameter */: + case 262 /* SyntaxKind.ModuleBlock */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 178 /* SyntaxKind.TypeReference */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: return false; // Type parameters are always visible - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: // Source file and namespace export are always visible // falls through - case 305 /* SourceFile */: - case 264 /* NamespaceExportDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return false; default: return false; @@ -55918,11 +56105,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 271 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 275 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } var result; var visited; @@ -55946,7 +56133,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol && visited) { if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) { buildVisibleNodeList(importSymbol.declarations); @@ -55995,23 +56182,23 @@ var ts; } function hasType(target, propertyName) { switch (propertyName) { - case 0 /* Type */: + case 0 /* TypeSystemPropertyName.Type */: return !!getSymbolLinks(target).type; - case 5 /* EnumTagType */: + case 5 /* TypeSystemPropertyName.EnumTagType */: return !!(getNodeLinks(target).resolvedEnumType); - case 2 /* DeclaredType */: + case 2 /* TypeSystemPropertyName.DeclaredType */: return !!getSymbolLinks(target).declaredType; - case 1 /* ResolvedBaseConstructorType */: + case 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */: return !!target.resolvedBaseConstructorType; - case 3 /* ResolvedReturnType */: + case 3 /* TypeSystemPropertyName.ResolvedReturnType */: return !!target.resolvedReturnType; - case 4 /* ImmediateBaseConstraint */: + case 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */: return !!target.immediateBaseConstraint; - case 6 /* ResolvedTypeArguments */: + case 6 /* TypeSystemPropertyName.ResolvedTypeArguments */: return !!target.resolvedTypeArguments; - case 7 /* ResolvedBaseTypes */: + case 7 /* TypeSystemPropertyName.ResolvedBaseTypes */: return !!target.baseTypesResolved; - case 8 /* WriteType */: + case 8 /* TypeSystemPropertyName.WriteType */: return !!getSymbolLinks(target).writeType; } return ts.Debug.assertNever(propertyName); @@ -56028,12 +56215,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 255 /* VariableDeclarationList */: - case 270 /* ImportSpecifier */: - case 269 /* NamedImports */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 255 /* SyntaxKind.VariableDeclarationList */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 269 /* SyntaxKind.NamedImports */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: return false; default: return true; @@ -56058,28 +56245,28 @@ var ts; return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType; } function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; + return type && (type.flags & 1 /* TypeFlags.Any */) !== 0; } function isErrorType(type) { // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for // a reference to an unresolved symbol. We want those to behave like the errorType. - return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol); + return type === errorType || !!(type.flags & 1 /* TypeFlags.Any */ && type.aliasSymbol); } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node, checkMode) { - if (checkMode !== 0 /* Normal */) { + if (checkMode !== 0 /* CheckMode.Normal */) { return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (source.flags & 131072 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); + if (source.flags & 131072 /* TypeFlags.Never */) { return emptyObjectType; } - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); @@ -56087,9 +56274,9 @@ var ts; var unspreadableToRestKeys = []; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); + var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) - && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) + && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } @@ -56104,7 +56291,7 @@ var ts; // they are explicitly omitted, as they would in the non-generic case. omitKeyType = getUnionType(__spreadArray([omitKeyType], unspreadableToRestKeys, true)); } - if (omitKeyType.flags & 131072 /* Never */) { + if (omitKeyType.flags & 131072 /* TypeFlags.Never */) { return source; } var omitTypeAlias = getGlobalOmitSymbol(); @@ -56119,15 +56306,15 @@ var ts; members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false)); } var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source)); - result.objectFlags |= 4194304 /* ObjectRestType */; + result.objectFlags |= 4194304 /* ObjectFlags.ObjectRestType */; return result; } function isGenericTypeWithUndefinedConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* TypeFlags.Undefined */); } function getNonUndefinedType(type) { - var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; - return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */); + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288 /* TypeFacts.NEUndefined */); } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: @@ -56163,34 +56350,34 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ancestor.initializer; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 203 /* BindingElement */ && parent.kind === 201 /* ObjectBindingPattern */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */ && parent.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 296 /* PropertyAssignment */ || node.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.kind === 296 /* SyntaxKind.PropertyAssignment */ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); } function getLiteralPropertyNameText(name) { var type = getLiteralTypeFromPropertyName(name); - return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : undefined; + return type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */) ? "" + type.value : undefined; } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { - var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var checkMode = declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode); return parentType && getBindingElementTypeFromParentType(declaration, parentType); } @@ -56201,18 +56388,18 @@ var ts; } var pattern = declaration.parent; // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 16777216 /* NodeFlags.Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` - else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) { - parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* TypeFacts.EQUndefined */)) { + parentType = getTypeWithFacts(parentType, 524288 /* TypeFacts.NEUndefined */); } var type; - if (pattern.kind === 201 /* ObjectBindingPattern */) { + if (pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); - if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* TypeFlags.Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return errorType; } @@ -56229,7 +56416,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* AccessFlags.ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -56237,7 +56424,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern); + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* IterationUse.PossiblyOutOfBounds */), parentType, undefinedType, pattern); var index_2 = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { // If the parent is a tuple type, the rest element has a tuple type of the @@ -56249,7 +56436,7 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getNumberLiteralType(index_2); - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } @@ -56263,9 +56450,9 @@ var ts; if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type; + return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)) & 16777216 /* TypeFacts.IsUndefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)], 2 /* UnionReduction.Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -56276,11 +56463,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* SyntaxKind.NullKeyword */ || expr.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 204 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, isProperty, isOptional) { if (isProperty === void 0) { isProperty = false; } @@ -56291,11 +56478,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode))); - return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -56317,11 +56504,11 @@ var ts; } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) { + !(ts.getCombinedModifierFlags(declaration) & 1 /* ModifierFlags.Export */) && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. - if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array @@ -56333,8 +56520,8 @@ var ts; if (ts.isParameter(declaration)) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 173 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* GetAccessor */); + if (func.kind === 173 /* SyntaxKind.SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* SyntaxKind.GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -56352,7 +56539,7 @@ var ts; return type_1; } // Use contextual parameter type if one is available - var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); + var type = declaration.symbol.escapedName === "this" /* InternalSymbolName.This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { return addOptionality(type, /*isProperty*/ false, isOptional); } @@ -56375,14 +56562,14 @@ var ts; if (!ts.hasStaticModifier(declaration)) { var constructor = findConstructorDeclaration(declaration.parent); var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } else { var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } @@ -56411,7 +56598,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 207 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 207 /* SyntaxKind.ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -56433,7 +56620,7 @@ var ts; 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 === 171 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(container))) { return container; } } @@ -56493,7 +56680,7 @@ var ts; } function getFlowTypeOfProperty(reference, prop) { var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) - && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* ModifierFlags.Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); @@ -56532,7 +56719,7 @@ var ts; var kind = ts.isAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } @@ -56562,12 +56749,12 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes); } } var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); - if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -56591,7 +56778,7 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - type.objectFlags |= 4096 /* JSLiteral */; + type.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { @@ -56647,13 +56834,13 @@ var ts; if (containsSameNamedThisProperty(expression.left, expression.right)) { return anyType; } - var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); + var isDirectExport = kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right)) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 524288 /* Object */ && - kind === 2 /* ModuleExports */ && - symbol.escapedName === "export=" /* ExportEquals */) { + if (type.flags & 524288 /* TypeFlags.Object */ && + kind === 2 /* AssignmentDeclarationKind.ModuleExports */ && + symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); ts.copyEntries(exportedType.members, members_4); @@ -56664,8 +56851,8 @@ var ts; (resolvedSymbol || symbol).exports.forEach(function (s, name) { var _a; var exportedMember = members_4.get(name); - if (exportedMember && exportedMember !== s) { - if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) { + if (exportedMember && exportedMember !== s && !(s.flags & 2097152 /* SymbolFlags.Alias */)) { + if (s.flags & 111551 /* SymbolFlags.Value */ && exportedMember.flags & 111551 /* SymbolFlags.Value */) { // If the member has an additional value-like declaration, union the types from the two declarations, // but issue an error if they occurred in two different files. The purpose is to support a JS file with // a pattern like: @@ -56703,15 +56890,15 @@ var ts; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = type.aliasTypeArguments; } - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { result.aliasSymbol = type.symbol; var args = getTypeArguments(type); result.aliasTypeArguments = ts.length(args) ? args : undefined; } } - result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag - if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */); // Propagate JSLiteral flag + if (result.symbol && result.symbol.flags & 32 /* SymbolFlags.Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { + result.objectFlags |= 16777216 /* ObjectFlags.IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -56723,16 +56910,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 108 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 171 /* Constructor */ || - thisContainer.kind === 256 /* FunctionDeclaration */ || - (thisContainer.kind === 213 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 171 /* SyntaxKind.Constructor */ || + thisContainer.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (thisContainer.kind === 213 /* SyntaxKind.FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -56752,7 +56939,7 @@ var ts; // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType))); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -56760,17 +56947,13 @@ var ts; if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAny(element, anyType); } - // When we're including the pattern in the type (an indication we're obtaining a contextual type), we - // use the non-inferrable any type. Inference will never directly infer this type, but it is possible - // to infer a type that contains it, e.g. for a binding pattern like [foo] or { foo }. In such cases, - // widening of the binding pattern type substitutes a regular any for the non-inferrable any. - return includePatternInType ? nonInferrableAnyType : anyType; + return anyType; } // Return the type implied by an object binding pattern function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -56780,11 +56963,11 @@ var ts; var exprType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(exprType)) { // do not include computed properties in the implied type - objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; return; } var text = getPropertyNameFromType(exprType); - var flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0); + var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; @@ -56794,7 +56977,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56802,18 +56985,18 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 203 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { - return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1; - var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* Rest */ : i >= minLength ? 2 /* Optional */ : 1 /* Required */; }); + var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; }); var result = createTupleType(elementTypes, elementFlags); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56827,7 +57010,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 201 /* ObjectBindingPattern */ + return pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -56841,7 +57024,7 @@ var ts; // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors); + return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* CheckMode.Normal */), declaration, reportErrors); } function isGlobalSymbolConstructor(node) { var symbol = getSymbolOfNode(node); @@ -56851,14 +57034,14 @@ var ts; function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol` - if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { type = getESSymbolLikeTypeForNode(declaration); } if (reportErrors) { reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -56875,7 +57058,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 164 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(node) { @@ -56899,14 +57082,14 @@ var ts; } function getTypeOfVariableOrParameterOrPropertyWorker(symbol) { // Handle prototype property - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return getTypeOfPrototypeProperty(symbol); } // CommonsJS require and module both have type any. if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { + if (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); var result = createSymbol(fileSymbol.flags, "exports"); result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; @@ -56947,15 +57130,15 @@ var ts; return getTypeOfAccessors(symbol); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 271 /* ExportAssignment */) { + if (declaration.kind === 271 /* SyntaxKind.ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -56974,7 +57157,7 @@ var ts; || ts.isMethodSignature(declaration) || ts.isSourceFile(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } type = ts.isBinaryExpression(declaration.parent) ? @@ -56988,10 +57171,10 @@ var ts; type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration); } else if (ts.isShorthandPropertyAssignment(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* CheckMode.Normal */); } else if (ts.isObjectLiteralMethod(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* CheckMode.Normal */); } else if (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration) @@ -57014,7 +57197,7 @@ var ts; } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -57023,7 +57206,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -57048,11 +57231,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); // We try to resolve a getter type annotation, a setter type annotation, or a getter function // body return type inference, in that order. var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || @@ -57087,10 +57270,10 @@ var ts; function getWriteTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.writeType) { - if (!pushTypeResolution(symbol, 8 /* WriteType */)) { + if (!pushTypeResolution(symbol, 8 /* TypeSystemPropertyName.WriteType */)) { return errorType; } - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); var writeType = getAnnotatedAccessorType(setter); if (!popTypeResolution()) { if (getAnnotatedAccessorTypeNode(setter)) { @@ -57105,8 +57288,8 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : - baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + return baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeFlags.TypeVariable */); }) : undefined; } function getTypeOfFuncClassEnumModule(symbol) { @@ -57127,21 +57310,21 @@ var ts; } function getTypeOfFuncClassEnumModuleWorker(symbol) { var declaration = symbol.valueDeclaration; - if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 221 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 221 /* BinaryExpression */)) { + declaration.parent.kind === 221 /* SyntaxKind.BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } - else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { + else if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { var resolvedModule = resolveExternalModuleSymbol(symbol); if (resolvedModule !== symbol) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */)); + var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)); var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule); if (!popTypeResolution()) { return reportCircularityError(symbol); @@ -57149,13 +57332,13 @@ var ts; return type_3; } } - var type = createObjectType(16 /* Anonymous */, symbol); - if (symbol.flags & 32 /* Class */) { + var type = createObjectType(16 /* ObjectFlags.Anonymous */, symbol); + if (symbol.flags & 32 /* SymbolFlags.Class */) { var baseTypeVariable = getBaseTypeVariableOfClass(symbol); return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type; + return strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ ? getOptionalType(type) : type; } } function getTypeOfEnumMember(symbol) { @@ -57176,7 +57359,7 @@ var ts; links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType - : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } return links.type; @@ -57197,7 +57380,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 164 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 164 /* SyntaxKind.Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -57210,7 +57393,7 @@ var ts; if (!links.type) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); } return links.type; } @@ -57219,7 +57402,7 @@ var ts; if (!links.writeType && links.deferralWriteConstituents) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); + links.writeType = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); } return links.writeType; } @@ -57230,15 +57413,15 @@ var ts; */ function getWriteTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (symbol.flags & 4 /* Property */) { - return checkFlags & 2 /* SyntheticProperty */ ? - checkFlags & 65536 /* DeferredType */ ? + if (symbol.flags & 4 /* SymbolFlags.Property */) { + return checkFlags & 2 /* CheckFlags.SyntheticProperty */ ? + checkFlags & 65536 /* CheckFlags.DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : symbol.writeType || symbol.type : getTypeOfSymbol(symbol); } - if (symbol.flags & 98304 /* Accessor */) { - return checkFlags & 1 /* Instantiated */ ? + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { + return checkFlags & 1 /* CheckFlags.Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol); } @@ -57246,56 +57429,56 @@ var ts; } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (checkFlags & 65536 /* DeferredType */) { + if (checkFlags & 65536 /* CheckFlags.DeferredType */) { return getTypeOfSymbolWithDeferredType(symbol); } - if (checkFlags & 1 /* Instantiated */) { + if (checkFlags & 1 /* CheckFlags.Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (checkFlags & 262144 /* Mapped */) { + if (checkFlags & 262144 /* CheckFlags.Mapped */) { return getTypeOfMappedSymbol(symbol); } - if (checkFlags & 8192 /* ReverseMapped */) { + if (checkFlags & 8192 /* CheckFlags.ReverseMapped */) { return getTypeOfReverseMappedSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & 98304 /* Accessor */) { + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getTypeOfAlias(symbol); } return errorType; } function getNonMissingTypeOfSymbol(symbol) { - return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* SymbolFlags.Optional */)); } function isReferenceToType(type, target) { return type !== undefined && target !== undefined - && (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + && (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getTargetType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target : type; } // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { - if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, check); } return false; @@ -57318,7 +57501,7 @@ var ts; if (node && ts.isBinaryExpression(node)) { // prototype assignments get the outer type parameters of their constructor function var assignmentKind = ts.getAssignmentDeclarationKind(node); - if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { var symbol = getSymbolOfNode(node.left); if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { node = symbol.parent.valueDeclaration; @@ -57329,46 +57512,46 @@ var ts; return undefined; } switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: - case 338 /* JSDocCallbackTag */: - case 195 /* MappedType */: - case 189 /* ConditionalType */: { + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 195 /* SyntaxKind.MappedType */: + case 189 /* SyntaxKind.ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 195 /* MappedType */) { + if (node.kind === 195 /* SyntaxKind.MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 189 /* ConditionalType */) { + else if (node.kind === 189 /* SyntaxKind.ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */ || node.kind === 258 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 320 /* JSDoc */: { + case 320 /* SyntaxKind.JSDoc */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -57379,7 +57562,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* SymbolFlags.Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -57392,9 +57575,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 257 /* ClassDeclaration */ || - node.kind === 226 /* ClassExpression */ || + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || + node.kind === 226 /* SyntaxKind.ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -57411,7 +57594,7 @@ var ts; // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single // rest parameter of type any[]. function isMixinConstructorType(type) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length === 1) { var s = signatures[0]; if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) { @@ -57422,10 +57605,10 @@ var ts; return false; } function isConstructorType(type) { - if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length > 0) { return true; } - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isMixinConstructorType(constraint); } @@ -57438,7 +57621,7 @@ var ts; function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); var isJavascript = ts.isInJSFile(location); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); + return ts.filter(getSignaturesOfType(type, 1 /* SignatureKind.Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); @@ -57461,7 +57644,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + if (!pushTypeResolution(type, 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */)) { return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -57469,7 +57652,7 @@ var ts; ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -57478,13 +57661,13 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = errorType; } - if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* TypeFlags.Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - if (baseConstructorType.flags & 262144 /* TypeParameter */) { + if (baseConstructorType.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(baseConstructorType); var ctorReturn = unknownType; if (constraint) { - var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + var ctorSig = getSignaturesOfType(constraint, 1 /* SignatureKind.Construct */); if (ctorSig[0]) { ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } @@ -57524,19 +57707,19 @@ var ts; return resolvedImplementsTypes; } function reportCircularBaseType(node, type) { - error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); } function getBaseTypes(type) { if (!type.baseTypesResolved) { - if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) { - if (type.objectFlags & 8 /* Tuple */) { + if (pushTypeResolution(type, 7 /* TypeSystemPropertyName.ResolvedBaseTypes */)) { + if (type.objectFlags & 8 /* ObjectFlags.Tuple */) { type.resolvedBaseTypes = [getTupleBaseType(type)]; } - else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (type.symbol.flags & 32 /* Class */) { + else if (type.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { + if (type.symbol.flags & 32 /* SymbolFlags.Class */) { resolveBaseTypesOfClass(type); } - if (type.symbol.flags & 64 /* Interface */) { + if (type.symbol.flags & 64 /* SymbolFlags.Interface */) { resolveBaseTypesOfInterface(type); } } @@ -57546,7 +57729,7 @@ var ts; if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 257 /* ClassDeclaration */ || declaration.kind === 258 /* InterfaceDeclaration */) { + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -57557,26 +57740,26 @@ var ts; return type.resolvedBaseTypes; } function getTupleBaseType(type) { - var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; }); + var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; }); return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly); } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); var baseType; var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; - if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && + if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } - else if (baseConstructorType.flags & 1 /* Any */) { + else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) { baseType = baseConstructorType; } else { @@ -57601,7 +57784,7 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); return type.resolvedBaseTypes = ts.emptyArray; } if (type.resolvedBaseTypes === ts.resolvingEmptyArray) { @@ -57626,7 +57809,7 @@ var ts; } // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getBaseConstraintOfType(type); if (constraint) { return isValidBaseType(constraint); @@ -57634,15 +57817,15 @@ var ts; } // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? // There's no reason a `T` should be allowed while a `Readonly` should not. - return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType)); + return !!(type.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 1 /* TypeFlags.Any */) && !isGenericMappedType(type) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isValidBaseType)); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; if (type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -57682,8 +57865,8 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */) { - if (declaration.flags & 128 /* ContainsThis */) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { + if (declaration.flags & 128 /* NodeFlags.ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -57691,8 +57874,8 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + var baseSymbol = resolveEntityName(node.expression, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* SymbolFlags.Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } } @@ -57706,7 +57889,7 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; + var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */; var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol @@ -57720,8 +57903,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isThislessInterface(symbol)) { - type.objectFlags |= 4 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) { + type.objectFlags |= 4 /* ObjectFlags.Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -57742,7 +57925,7 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + if (!pushTypeResolution(symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { return errorType; } var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found"); @@ -57761,11 +57944,11 @@ var ts; } else { type = errorType; - if (declaration.kind === 339 /* JSDocEnumTag */) { + if (declaration.kind === 339 /* SyntaxKind.JSDocEnumTag */) { error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } } links.declaredType = type; @@ -57776,7 +57959,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 221 /* BinaryExpression */) { + else if (expr.kind === 221 /* SyntaxKind.BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -57784,19 +57967,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 16777216 /* Ambient */); + return !(member.flags & 16777216 /* NodeFlags.Ambient */); } switch (expr.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; - case 79 /* Identifier */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; + case 79 /* SyntaxKind.Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -57811,11 +57994,11 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { - return links.enumKind = 1 /* Literal */; + return links.enumKind = 1 /* EnumKind.Literal */; } if (!isLiteralEnumMember(member)) { hasNonLiteralMember = true; @@ -57824,23 +58007,23 @@ var ts; } } } - return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; + return links.enumKind = hasNonLiteralMember ? 0 /* EnumKind.Numeric */ : 1 /* EnumKind.Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (links.declaredType) { return links.declaredType; } - if (getEnumKind(symbol) === 1 /* Literal */) { + if (getEnumKind(symbol) === 1 /* EnumKind.Literal */) { enumCount++; var memberTypeList = []; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -57852,15 +58035,15 @@ var ts; } } if (memberTypeList.length) { - var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 1048576 /* Union */) { - enumType_1.flags |= 1024 /* EnumLiteral */; + var enumType_1 = getUnionType(memberTypeList, 1 /* UnionReduction.Literal */, symbol, /*aliasTypeArguments*/ undefined); + if (enumType_1.flags & 1048576 /* TypeFlags.Union */) { + enumType_1.flags |= 1024 /* TypeFlags.EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(32 /* Enum */); + var enumType = createType(32 /* TypeFlags.Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -57886,22 +58069,22 @@ var ts; return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getDeclaredTypeOfEnumMember(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getDeclaredTypeOfAlias(symbol); } return undefined; @@ -57913,22 +58096,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 196 /* LiteralType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 196 /* SyntaxKind.LiteralType */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isThislessType(node.elementType); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -57954,7 +58137,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 171 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 171 /* SyntaxKind.Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -57970,14 +58153,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -58014,8 +58197,8 @@ var ts; type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; type.declaredIndexInfos = ts.emptyArray; - type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); - type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); + type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* InternalSymbolName.Call */)); + type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* InternalSymbolName.New */)); type.declaredIndexInfos = getIndexInfosOfSymbol(symbol); } return type; @@ -58024,7 +58207,7 @@ var ts; * Indicates whether a type can be used as a property name. */ function isTypeUsableAsPropertyName(type) { - return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -58043,9 +58226,9 @@ var ts; && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) === 64 /* at */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) === 64 /* CharacterCodes.at */; } /** * Indicates whether a declaration has a late-bindable dynamic name. @@ -58070,10 +58253,10 @@ var ts; * Gets the symbolic name for a member from its type. */ function getPropertyNameFromType(type) { - if (type.flags & 8192 /* UniqueESSymbol */) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { return type.escapedName; } - if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -58084,7 +58267,7 @@ var ts; * members. */ function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { - ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol."); + ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { @@ -58093,7 +58276,7 @@ var ts; else if (!member.symbol.isReplaceableByMethod) { symbol.declarations.push(member); } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -58142,7 +58325,7 @@ var ts; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. var lateSymbol = lateSymbols.get(memberName); if (!lateSymbol) - lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */)); + lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. @@ -58151,10 +58334,10 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_5 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); + var name_5 = !(type.flags & 8192 /* TypeFlags.UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_5); }); error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_5); - lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); + lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */); } lateSymbol.nameType = type; addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); @@ -58172,9 +58355,9 @@ var ts; function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) { var links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */; + var isStatic_1 = resolutionKind === "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */; var earlySymbols = !isStatic_1 ? symbol.members : - symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModuleWorker(symbol) : symbol.exports; // In the event we recursively resolve the members/exports of the symbol, we // set the initial value of resolvedMembers/resolvedExports to the early-bound @@ -58200,10 +58383,10 @@ var ts; for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { var member = decls_1[_c]; var assignmentKind = ts.getAssignmentDeclarationKind(member); - var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + var isInstanceMember = assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */ || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) - || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ - || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + || assignmentKind === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */; // A straight `Prototype` assignment probably can never have a computed name if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } @@ -58219,8 +58402,8 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ - ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ + ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* MembersOrExportsResolutionKind.resolvedMembers */) : symbol.members || emptySymbols; } /** @@ -58230,7 +58413,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol) { - if (symbol.flags & 106500 /* ClassMember */ && symbol.escapedName === "__computed" /* Computed */) { + if (symbol.flags & 106500 /* SymbolFlags.ClassMember */ && symbol.escapedName === "__computed" /* InternalSymbolName.Computed */) { var links = getSymbolLinks(symbol); if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol @@ -58247,7 +58430,7 @@ var ts; return symbol; } function getTypeWithThisArgument(type, thisArgument, needApparentType) { - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { var target = type.target; var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { @@ -58255,7 +58438,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }); return types !== type.types ? getIntersectionType(types) : type; } @@ -58291,8 +58474,8 @@ var ts; var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* SignatureKind.Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* SignatureKind.Construct */)); var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)]; indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); })); } @@ -58327,7 +58510,7 @@ var ts; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; result.compositeSignatures = sig.compositeSignatures; @@ -58337,24 +58520,24 @@ var ts; function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); result.compositeSignatures = unionSignatures; - result.compositeKind = 1048576 /* Union */; + result.compositeKind = 1048576 /* TypeFlags.Union */; result.target = undefined; result.mapper = undefined; return result; } function getOptionalCallSignature(signature, callChainFlags) { - if ((signature.flags & 24 /* CallChainFlags */) === callChainFlags) { + if ((signature.flags & 24 /* SignatureFlags.CallChainFlags */) === callChainFlags) { return signature; } if (!signature.optionalCallSignatureCache) { signature.optionalCallSignatureCache = {}; } - var key = callChainFlags === 8 /* IsInnerCallChain */ ? "inner" : "outer"; + var key = callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ ? "inner" : "outer"; return signature.optionalCallSignatureCache[key] || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags)); } function createOptionalCallSignature(signature, callChainFlags) { - ts.Debug.assert(callChainFlags === 8 /* IsInnerCallChain */ || callChainFlags === 16 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); + ts.Debug.assert(callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ || callChainFlags === 16 /* SignatureFlags.IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); var result = cloneSignature(signature); result.flags |= callChainFlags; return result; @@ -58366,7 +58549,7 @@ var ts; if (isTupleType(restType)) { return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)]; } - else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && ts.every(restType.types, isTupleType)) { + else if (!skipUnionExpanding && restType.flags & 1048576 /* TypeFlags.Union */ && ts.every(restType.types, isTupleType)) { return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); }); } } @@ -58379,10 +58562,10 @@ var ts; var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]); var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType); var flags = restType.target.elementFlags[i]; - var checkFlags = flags & 12 /* Variable */ ? 32768 /* RestParameter */ : - flags & 2 /* Optional */ ? 16384 /* OptionalParameter */ : 0; - var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); - symbol.type = flags & 4 /* Rest */ ? createArrayType(t) : t; + var checkFlags = flags & 12 /* ElementFlags.Variable */ ? 32768 /* CheckFlags.RestParameter */ : + flags & 2 /* ElementFlags.Optional */ ? 16384 /* CheckFlags.OptionalParameter */ : 0; + var symbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, name, checkFlags); + symbol.type = flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t; return symbol; }); return ts.concatenate(sig.parameters.slice(0, restIndex), restParams); @@ -58390,11 +58573,11 @@ var ts; } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol); - var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* Abstract */); + var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* Abstract */ : 0 /* None */)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* SignatureFlags.Abstract */ : 0 /* SignatureFlags.None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -58409,7 +58592,7 @@ var ts; var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; - sig.flags = isAbstract ? sig.flags | 4 /* Abstract */ : sig.flags & ~4 /* Abstract */; + sig.flags = isAbstract ? sig.flags | 4 /* SignatureFlags.Abstract */ : sig.flags & ~4 /* SignatureFlags.Abstract */; result.push(sig); } } @@ -58572,12 +58755,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -58599,11 +58782,11 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 1048576 /* Union */; - result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 1048576 /* TypeFlags.Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -58628,8 +58811,8 @@ var ts; function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); })); - var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* SignatureKind.Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */); })); var indexInfos = getUnionIndexInfos(type.types); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos); } @@ -58637,7 +58820,7 @@ var ts; return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } function findMixins(types) { - var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; }); + var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */).length > 0; }); var mixinFlags = ts.map(types, isMixinConstructorType); if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) { var firstMixinIndex = mixinFlags.indexOf(/*searchElement*/ true); @@ -58652,7 +58835,7 @@ var ts; mixedTypes.push(type); } else if (mixinFlags[i]) { - mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* SignatureKind.Construct */)[0])); } } return getIntersectionType(mixedTypes); @@ -58674,7 +58857,7 @@ var ts; // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature // 'new(s: string) => A & B'. if (!mixinFlags[i]) { - var signatures = getSignaturesOfType(t, 1 /* Construct */); + var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */); if (signatures.length && mixinCount > 0) { signatures = ts.map(signatures, function (s) { var clone = cloneSignature(s); @@ -58684,7 +58867,7 @@ var ts; } constructSignatures = appendSignatures(constructSignatures, signatures); } - callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */)); indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos); }; for (var i = 0; i < types.length; i++) { @@ -58723,18 +58906,18 @@ var ts; if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); - var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* SignatureKind.Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* SignatureKind.Construct */), type.mapper); var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper); setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1); return; } var symbol = getMergedSymbol(type.symbol); - if (symbol.flags & 2048 /* TypeLiteral */) { + if (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_7 = getMembersOfSymbol(symbol); - var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */)); - var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */)); + var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* InternalSymbolName.Call */)); + var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* InternalSymbolName.New */)); var indexInfos_2 = getIndexInfosOfSymbol(symbol); setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2); return; @@ -58748,7 +58931,7 @@ var ts; var varsOnly_1 = new ts.Map(); members.forEach(function (p) { var _a; - if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { + if (!(p.flags & 418 /* SymbolFlags.BlockScoped */) && !(p.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { varsOnly_1.set(p.escapedName, p); } }); @@ -58757,10 +58940,10 @@ var ts; } var baseConstructorIndexInfo; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 8650752 /* TypeFlags.TypeVariable */)) { members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -58776,8 +58959,8 @@ var ts; if (baseConstructorIndexInfo) { indexInfos = ts.append(indexInfos, baseConstructorIndexInfo); } - if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* TypeFlags.Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* TypeFlags.NumberLike */); }))) { indexInfos = ts.append(indexInfos, enumNumberIndexInfo); } } @@ -58786,16 +58969,16 @@ var ts; // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list // will never be observed because a qualified name can't reference signatures. - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } // And likewise for construct signatures for classes - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; - if (symbol.flags & 16 /* Function */) { + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* InternalSymbolName.Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* SymbolFlags.Function */) { constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? - createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) : + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */) : undefined; })); } if (!constructSignatures.length) { @@ -58813,20 +58996,20 @@ var ts; function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, stringType); var modifiers = getMappedTypeModifiers(type.mappedType); - var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; - var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; + var readonlyMask = modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? false : true; + var optionalMask = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 0 : 16777216 /* SymbolFlags.Optional */; var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; - var checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0); - var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); + var checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* CheckFlags.Readonly */ : 0); + var inferredProp = createSymbol(4 /* SymbolFlags.Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ - && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ - && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) { + if (type.constraintType.type.flags & 8388608 /* TypeFlags.IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeFlags.TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* TypeFlags.TypeParameter */) { // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of // type identities produced, we simplify such indexed access occurences @@ -58847,11 +59030,11 @@ var ts; // bound includes those keys that are known to always be present, for example because // because of constraints on type parameters (e.g. 'keyof T' for a constrained T). function getLowerBoundOfKeyType(type) { - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var t = getApparentType(type.type); return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { if (type.root.isDistributive) { var checkType = type.checkType; var constraint = getLowerBoundOfKeyType(checkType); @@ -58861,29 +59044,29 @@ var ts; } return type; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getLowerBoundOfKeyType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType)); } return type; } function getIsLateCheckFlag(s) { - return ts.getCheckFlags(s) & 4096 /* Late */; + return ts.getCheckFlags(s) & 4096 /* CheckFlags.Late */; } function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; cb(getLiteralTypeFromProperty(prop, include)); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { cb(stringType); } else { for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) { var info = _c[_b]; - if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + if (!stringsOnly || info.keyType.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { cb(info.keyType); } } @@ -58903,7 +59086,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* TypeFlags.StringLiteral */ : 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType); @@ -58931,13 +59114,13 @@ var ts; } else { var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined; - var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || - !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); - var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || - !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); - var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; + var isOptional = !!(templateModifiers & 4 /* MappedTypeModifiers.IncludeOptional */ || + !(templateModifiers & 8 /* MappedTypeModifiers.ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */); + var isReadonly = !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ || + !(templateModifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); + var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */; var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0; - var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, lateFlag | 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); + var prop = createSymbol(4 /* SymbolFlags.Property */ | (isOptional ? 16777216 /* SymbolFlags.Optional */ : 0), propName, lateFlag | 262144 /* CheckFlags.Mapped */ | (isReadonly ? 8 /* CheckFlags.Readonly */ : 0) | (stripOptional ? 524288 /* CheckFlags.StripOptional */ : 0)); prop.mappedType = type; prop.nameType = propNameType; prop.keyType = keyType; @@ -58950,12 +59133,12 @@ var ts; members.set(propName, prop); } } - else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) { - var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : - propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : + else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* TypeFlags.Any */ | 32 /* TypeFlags.Enum */)) { + var indexKeyType = propNameType.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */) ? stringType : + propNameType.flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */) ? numberType : propNameType; var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); - var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */)); indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true); } } @@ -58963,7 +59146,7 @@ var ts; function getTypeOfMappedSymbol(symbol) { if (!symbol.type) { var mappedType = symbol.mappedType; - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { mappedType.containsError = true; return errorType; } @@ -58973,8 +59156,8 @@ var ts; // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. - var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : + var type = strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + symbol.checkFlags & 524288 /* CheckFlags.StripOptional */ ? removeMissingOrUndefinedType(propType) : propType; if (!popTypeResolution()) { error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); @@ -59000,7 +59183,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -59008,8 +59191,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 193 /* TypeOperator */ && - constraintDeclaration.operator === 140 /* KeyOfKeyword */; + return constraintDeclaration.kind === 193 /* SyntaxKind.TypeOperator */ && + constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -59025,20 +59208,20 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* SyntaxKind.MinusToken */ ? 8 /* MappedTypeModifiers.ExcludeOptional */ : 4 /* MappedTypeModifiers.IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); - return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0; + return modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? -1 : modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 1 : 0; } function getCombinedMappedTypeOptionality(type) { var optionality = getMappedTypeOptionality(type); @@ -59046,42 +59229,48 @@ var ts; return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0); } function isPartialMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */); } function isGenericMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 524288 /* Object */) { - if (type.objectFlags & 4 /* Reference */) { + if (type.flags & 524288 /* TypeFlags.Object */) { + if (type.objectFlags & 4 /* ObjectFlags.Reference */) { resolveTypeReferenceMembers(type); } - else if (type.objectFlags & 3 /* ClassOrInterface */) { + else if (type.objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 1024 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { resolveReverseMappedTypeMembers(type); } - else if (type.objectFlags & 16 /* Anonymous */) { + else if (type.objectFlags & 16 /* ObjectFlags.Anonymous */) { resolveAnonymousTypeMembers(type); } - else if (type.objectFlags & 32 /* Mapped */) { + else if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { resolveMappedTypeMembers(type); } + else { + ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags)); + } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { resolveIntersectionTypeMembers(type); } + else { + ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags)); + } } return type; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -59090,7 +59279,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -59114,7 +59303,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type without index signature - if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) { + if (type.flags & 1048576 /* TypeFlags.Union */ && getIndexInfosOfType(current).length === 0) { break; } } @@ -59124,13 +59313,13 @@ var ts; } function getPropertiesOfType(type) { type = getReducedApparentType(type); - return type.flags & 3145728 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function forEachPropertyOfType(type, action) { type = getReducedApparentType(type); - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) { if (isNamedMember(symbol, escapedName)) { action(symbol, escapedName); @@ -59149,7 +59338,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 1048576 /* Union */)) { + if (!(unionType.flags & 1048576 /* TypeFlags.Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -59168,9 +59357,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -59231,7 +59420,7 @@ var ts; var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint && constraint !== type.checkType) { var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); - if (!(instantiated.flags & 131072 /* Never */)) { + if (!(instantiated.flags & 131072 /* TypeFlags.Never */)) { return instantiated; } } @@ -59249,11 +59438,11 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { var t = types_5[_i]; - if (t.flags & 465829888 /* Instantiable */) { + if (t.flags & 465829888 /* TypeFlags.Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { @@ -59263,7 +59452,7 @@ var ts; } } } - else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) { + else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */ || isEmptyAnonymousObjectType(t)) { hasDisjointDomainType = true; } } @@ -59275,21 +59464,22 @@ var ts; // intersection operation to reduce the union constraints. for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { var t = types_6[_a]; - if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) { + if (t.flags & 469892092 /* TypeFlags.DisjointDomains */ || isEmptyAnonymousObjectType(t)) { constraints = ts.append(constraints, t); } } } - return getIntersectionType(constraints); + // The source types were normalized; ensure the result is normalized too. + return getNormalizedType(getIntersectionType(constraints), /*writing*/ false); } return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { + if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -59314,7 +59504,7 @@ var ts; return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t) { if (!t.immediateBaseConstraint) { - if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) { + if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) { return circularConstraintType; } var result = void 0; @@ -59331,7 +59521,7 @@ var ts; stack.pop(); } if (!popTypeResolution()) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var errorNode = getConstraintDeclaration(t); if (errorNode) { var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t)); @@ -59351,13 +59541,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 3145728 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = t.types; var baseTypes = []; var different = false; @@ -59377,23 +59567,23 @@ var ts; if (!different) { return t; } - return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* TypeFlags.Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* TypeFlags.Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 4194304 /* Index */) { + if (t.flags & 4194304 /* TypeFlags.Index */) { return keyofConstraintType; } - if (t.flags & 134217728 /* TemplateLiteral */) { + if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var types = t.types; var constraints = ts.mapDefined(types, getBaseConstraint); return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType; } - if (t.flags & 268435456 /* StringMapping */) { + if (t.flags & 268435456 /* TypeFlags.StringMapping */) { var constraint = getBaseConstraint(t.type); return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType; } - if (t.flags & 8388608 /* IndexedAccess */) { + if (t.flags & 8388608 /* TypeFlags.IndexedAccess */) { if (isMappedTypeGenericIndexedAccess(t)) { // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic, // we substitute an instantiation of E where P is replaced with X. @@ -59404,11 +59594,11 @@ var ts; var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } - if (t.flags & 16777216 /* Conditional */) { + if (t.flags & 16777216 /* TypeFlags.Conditional */) { var constraint = getConstraintFromConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 33554432 /* Substitution */) { + if (t.flags & 33554432 /* TypeFlags.Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -59475,9 +59665,9 @@ var ts; } function isMappedTypeGenericIndexedAccess(type) { var objectType; - return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && + return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && - !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType); + !(getMappedTypeModifiers(objectType) & 8 /* MappedTypeModifiers.ExcludeOptional */) && !objectType.declaration.nameType); } /** * For a type parameter, return the base constraint of the type parameter. For the string, number, @@ -59485,17 +59675,17 @@ var ts; * type itself. */ function getApparentType(type) { - var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; - return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 402653316 /* StringLike */ ? globalStringType : - t.flags & 296 /* NumberLike */ ? globalNumberType : - t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : - t.flags & 528 /* BooleanLike */ ? globalBooleanType : - t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : - t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : - t.flags & 4194304 /* Index */ ? keyofConstraintType : - t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : + var t = !(type.flags & 465829888 /* TypeFlags.Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; + return ts.getObjectFlags(t) & 32 /* ObjectFlags.Mapped */ ? getApparentTypeOfMappedType(t) : + t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType : + t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType : + t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType() : + t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType : + t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType() : + t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType : + t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : + t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType : t; } function getReducedApparentType(type) { @@ -59510,21 +59700,21 @@ var ts; var singleProp; var propSet; var indexTypes; - var isUnion = containingType.flags & 1048576 /* Union */; + var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */; // Flags we want to propagate to the result if they exist in all source symbols - var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; - var syntheticFlag = 4 /* SyntheticMethod */; - var checkFlags = isUnion ? 0 : 8 /* Readonly */; + var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */; + var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */; + var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */; var mergedInstantiations = false; for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { var current = _c[_i]; var type = getApparentType(current); - if (!(isErrorType(type) || type.flags & 131072 /* Never */)) { + if (!(isErrorType(type) || type.flags & 131072 /* TypeFlags.Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop) { if (isUnion) { - optionalFlag |= (prop.flags & 16777216 /* Optional */); + optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */); } else { optionalFlag &= prop.flags; @@ -59537,7 +59727,7 @@ var ts; // If the symbols are instances of one another with identical types - consider the symbols // equivalent and just use the first one, which thus allows us to avoid eliding private // members when intersecting a (this-)instantiations of a class with it's raw base or another instance - if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) { + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) { // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` @@ -59555,41 +59745,41 @@ var ts; } } if (isUnion && isReadonlySymbol(prop)) { - checkFlags |= 8 /* Readonly */; + checkFlags |= 8 /* CheckFlags.Readonly */; } else if (!isUnion && !isReadonlySymbol(prop)) { - checkFlags &= ~8 /* Readonly */; + checkFlags &= ~8 /* CheckFlags.Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) ? 256 /* CheckFlags.ContainsPublic */ : 0) | + (modifiers & 16 /* ModifierFlags.Protected */ ? 512 /* CheckFlags.ContainsProtected */ : 0) | + (modifiers & 8 /* ModifierFlags.Private */ ? 1024 /* CheckFlags.ContainsPrivate */ : 0) | + (modifiers & 32 /* ModifierFlags.Static */ ? 2048 /* CheckFlags.ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { - syntheticFlag = 2 /* SyntheticProperty */; + syntheticFlag = 2 /* CheckFlags.SyntheticProperty */; } } else if (isUnion) { var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name); if (indexInfo) { - checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); + checkFlags |= 32 /* CheckFlags.WritePartial */ | (indexInfo.isReadonly ? 8 /* CheckFlags.Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ContainsSpread */)) { - checkFlags |= 32 /* WritePartial */; + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ObjectFlags.ContainsSpread */)) { + checkFlags |= 32 /* CheckFlags.WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } else { - checkFlags |= 16 /* ReadPartial */; + checkFlags |= 16 /* CheckFlags.ReadPartial */; } } } } - if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) { + if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) { // No property was found, or, in a union, a property has a private or protected declaration in one // constituent, but is missing or has a different declaration in another constituent. return undefined; } - if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { + if (!propSet && !(checkFlags & 16 /* CheckFlags.ReadPartial */) && !indexTypes) { if (mergedInstantiations) { // No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents) // Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!) @@ -59631,18 +59821,18 @@ var ts; writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType); } else if (type !== firstType) { - checkFlags |= 64 /* HasNonUniformType */; + checkFlags |= 64 /* CheckFlags.HasNonUniformType */; } if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) { - checkFlags |= 128 /* HasLiteralType */; + checkFlags |= 128 /* CheckFlags.HasLiteralType */; } - if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) { - checkFlags |= 131072 /* HasNeverType */; + if (type.flags & 131072 /* TypeFlags.Never */ && type !== uniqueLiteralType) { + checkFlags |= 131072 /* CheckFlags.HasNeverType */; } propTypes.push(type); } ts.addRange(propTypes, indexTypes); - var result = createSymbol(4 /* Property */ | optionalFlag, name, syntheticFlag | checkFlags); + var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags); result.containingType = containingType; if (!hasNonUniformValueDeclaration && firstValueDeclaration) { result.valueDeclaration = firstValueDeclaration; @@ -59655,7 +59845,7 @@ var ts; result.nameType = nameType; if (propTypes.length > 2) { // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed - result.checkFlags |= 65536 /* DeferredType */; + result.checkFlags |= 65536 /* CheckFlags.DeferredType */; result.deferralParent = containingType; result.deferralConstituents = propTypes; result.deferralWriteConstituents = writeTypes; @@ -59689,7 +59879,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) { var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment); // We need to filter out partial properties in union types - return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined; + return property && !(ts.getCheckFlags(property) & 16 /* CheckFlags.ReadPartial */) ? property : undefined; } /** * Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. @@ -59698,15 +59888,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 16777216 /* ContainsIntersections */) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } - else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 16777216 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 16777216 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* IsNeverIntersection */ : 0); + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { + if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) { + type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0); } - return type.objectFlags & 33554432 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type; } return type; } @@ -59716,7 +59906,7 @@ var ts; return unionType; } var reduced = getUnionType(reducedTypes); - if (reduced.flags & 1048576 /* Union */) { + if (reduced.flags & 1048576 /* TypeFlags.Union */) { reduced.resolvedReducedType = reduced; } return reduced; @@ -59727,23 +59917,23 @@ var ts; function isDiscriminantWithNeverType(prop) { // Return true for a synthetic non-optional property with non-uniform types, where at least one is // a literal type and none is never, that reduces to never. - return !(prop.flags & 16777216 /* Optional */) && - (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ && - !!(getTypeOfSymbol(prop).flags & 131072 /* Never */); + return !(prop.flags & 16777216 /* SymbolFlags.Optional */) && + (ts.getCheckFlags(prop) & (192 /* CheckFlags.Discriminant */ | 131072 /* CheckFlags.HasNeverType */)) === 192 /* CheckFlags.Discriminant */ && + !!(getTypeOfSymbol(prop).flags & 131072 /* TypeFlags.Never */); } function isConflictingPrivateProperty(prop) { // Return true for a synthetic property with multiple declarations, at least one of which is private. - return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); + return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* CheckFlags.ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 33554432 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(neverProp)); } var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty); if (privateProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(privateProp)); } } return errorInfo; @@ -59758,7 +59948,7 @@ var ts; */ function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment, includeTypeOnlyMembers) { type = getReducedApparentType(type); - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol, includeTypeOnlyMembers)) { @@ -59778,15 +59968,15 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + return kind === 0 /* SignatureKind.Call */ ? resolved.callSignatures : resolved.constructSignatures; } return ts.emptyArray; } @@ -59832,10 +60022,10 @@ var ts; // signature applies to types assignable to 'number', `${number}` and numeric string literal types. return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value)); + target === numberType && (source === numericStringType || !!(source.flags & 128 /* TypeFlags.StringLiteral */) && ts.isNumericLiteralName(source.value)); } function getIndexInfosOfStructuredType(type) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return resolved.indexInfos; } @@ -59867,12 +60057,15 @@ var ts; // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(declaration) { + var _a; var result; - for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) { - var node = _a[_i]; + for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) { + var node = _b[_i]; result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol)); } - return result; + return (result === null || result === void 0 ? void 0 : result.length) ? result + : ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters + : undefined; } function symbolsToArray(symbols) { var result = []; @@ -59886,17 +60079,17 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 316 /* JSDocOptionalType */ + node.type && node.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* SymbolFlags.ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -59911,7 +60104,7 @@ var ts; // Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used // in grammar checks and checking for `void` too early results in parameter types widening too early // and causes some noImplicitAny errors to be lost. - return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */); + return parameterIndex >= getMinArgumentCount(signature, 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */ | 2 /* MinArgumentCountFlags.VoidIsNonOptional */); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -59929,7 +60122,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -59978,7 +60171,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -59990,7 +60183,7 @@ var ts; !ts.hasJSDocParameterTags(declaration) && !ts.getJSDocType(declaration); if (isUntypedSignatureInJSFile) { - flags |= 32 /* IsUntypedSignatureInJSFile */; + flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */; } // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -60000,19 +60193,19 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature - if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); + if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) { + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } - if (i === 0 && paramSymbol.escapedName === "this" /* This */) { + if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) { hasThisParameter = true; thisParameter = param.symbol; } else { parameters.push(paramSymbol); } - if (type && type.kind === 196 /* LiteralType */) { - flags |= 2 /* HasLiteralTypes */; + if (type && type.kind === 196 /* SyntaxKind.LiteralType */) { + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || @@ -60024,25 +60217,25 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) && + if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 171 /* Constructor */ ? + var classType = declaration.kind === 171 /* SyntaxKind.Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } - if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* Abstract */) || - ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* Abstract */)) { - flags |= 4 /* Abstract */; + if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */) || + ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* ModifierFlags.Abstract */)) { + flags |= 4 /* SignatureFlags.Abstract */; } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); @@ -60064,7 +60257,7 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */); + var syntheticArgsSymbol = createSymbol(3 /* SymbolFlags.Variable */, "args", 32768 /* CheckFlags.RestParameter */); if (lastParamVariadicType) { // Parameter has effective annotation, lock in type syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)); @@ -60073,7 +60266,7 @@ var ts; // Parameter has no annotation // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been // cached by `getTypeOfSymbol` yet. - syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */; + syntheticArgsSymbol.checkFlags |= 65536 /* CheckFlags.DeferredType */; syntheticArgsSymbol.deferralParent = neverType; syntheticArgsSymbol.deferralConstituents = [anyArrayType]; syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType]; @@ -60106,7 +60299,7 @@ var ts; function containsArgumentsReference(declaration) { var links = getNodeLinks(declaration); if (links.containsArgumentsReference === undefined) { - if (links.flags & 8192 /* CaptureArguments */) { + if (links.flags & 8192 /* NodeCheckFlags.CaptureArguments */) { links.containsArgumentsReference = true; } else { @@ -60118,18 +60311,18 @@ var ts; if (!node) return false; switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return node.name.kind === 162 /* ComputedPropertyName */ + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && traverse(node.name); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return traverse(node.expression); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return traverse(node.initializer); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -60201,26 +60394,26 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 192 /* ThisType */ ? - createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : - createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); + return parameterName.kind === 192 /* SyntaxKind.ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* TypePredicateKind.AssertsThis */ : 0 /* TypePredicateKind.This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* TypePredicateKind.AssertsIdentifier */ : 1 /* TypePredicateKind.Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getUnionOrIntersectionType(types, kind, unionReduction) { - return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + return kind !== 2097152 /* TypeFlags.Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + if (!pushTypeResolution(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* UnionReduction.Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); - if (signature.flags & 8 /* IsInnerCallChain */) { + if (signature.flags & 8 /* SignatureFlags.IsInnerCallChain */) { type = addOptionalTypeMarker(type); } - else if (signature.flags & 16 /* IsOuterCallChain */) { + else if (signature.flags & 16 /* SignatureFlags.IsOuterCallChain */) { type = getOptionalType(type); } if (!popTypeResolution()) { @@ -60247,7 +60440,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 171 /* Constructor */) { + if (declaration.kind === 171 /* SyntaxKind.Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -60257,12 +60450,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 172 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SyntaxKind.SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -60271,7 +60464,7 @@ var ts; return getReturnTypeOfTypeTag(declaration); } function isResolvingReturnTypeOfSignature(signature) { - return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { return tryGetRestTypeOfSignature(signature) || anyType; @@ -60365,8 +60558,8 @@ var ts; if (!signature.isolatedSignatureType) { var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind; // If declaration is undefined, it is likely to be the signature of the default constructor. - var isConstructor = kind === undefined || kind === 171 /* Constructor */ || kind === 175 /* ConstructSignature */ || kind === 180 /* ConstructorType */; - var type = createObjectType(16 /* Anonymous */); + var isConstructor = kind === undefined || kind === 171 /* SyntaxKind.Constructor */ || kind === 175 /* SyntaxKind.ConstructSignature */ || kind === 180 /* SyntaxKind.ConstructorType */; + var type = createObjectType(16 /* ObjectFlags.Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; type.callSignatures = !isConstructor ? [signature] : ts.emptyArray; @@ -60380,7 +60573,7 @@ var ts; return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; } function getIndexSymbolFromSymbolTable(symbolTable) { - return symbolTable.get("__index" /* Index */); + return symbolTable.get("__index" /* InternalSymbolName.Index */); } function createIndexInfo(keyType, type, isReadonly, declaration) { return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration }; @@ -60398,7 +60591,7 @@ var ts; if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), function (keyType) { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) { - indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* ModifierFlags.Readonly */), declaration)); } }); } @@ -60413,8 +60606,8 @@ var ts; return ts.emptyArray; } function isValidIndexKeyType(type) { - return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || - !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); + return !!(type.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 4096 /* TypeFlags.ESSymbol */)) || isPatternLiteralType(type) || + !!(type.flags & 2097152 /* TypeFlags.Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -60423,21 +60616,20 @@ var ts; var _a; var inferences; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { - for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { - var declaration = _b[_i]; - if (declaration.parent.kind === 190 /* InferType */) { + var _loop_15 = function (declaration) { + if (declaration.parent.kind === 190 /* SyntaxKind.InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; - if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) { - var typeReference = grandParent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(childTypeParameter); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (grandParent.kind === 178 /* SyntaxKind.TypeReference */ && !omitTypeReferences) { + var typeReference_1 = grandParent; + var typeParameters_1 = getTypeParametersForTypeReference(typeReference_1); + if (typeParameters_1) { + var index = typeReference_1.typeArguments.indexOf(childTypeParameter); + if (index < typeParameters_1.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters_1[index]); if (declaredConstraint) { // Type parameter constraints can reference other type parameters so // constraints need to be instantiated. If instantiation produces the @@ -60445,7 +60637,9 @@ var ts; // type Foo = [T, U]; // type Bar = T extends Foo ? Foo : T; // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var mapper = makeDeferredTypeMapper(typeParameters_1, typeParameters_1.map(function (_, index) { return function () { + return getEffectiveTypeArgumentAtIndex(typeReference_1, typeParameters_1, index); + }; })); var constraint = instantiateType(declaredConstraint, mapper); if (constraint !== typeParameter) { inferences = ts.append(inferences, constraint); @@ -60456,33 +60650,37 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 164 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 186 /* RestType */ || - grandParent.kind === 197 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 164 /* SyntaxKind.Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 186 /* SyntaxKind.RestType */ || + grandParent.kind === 197 /* SyntaxKind.NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' // constraint. - else if (grandParent.kind === 199 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */) { inferences = ts.append(inferences, stringType); } // When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any' // constraint. - else if (grandParent.kind === 163 /* TypeParameter */ && grandParent.parent.kind === 195 /* MappedType */) { + else if (grandParent.kind === 163 /* SyntaxKind.TypeParameter */ && grandParent.parent.kind === 195 /* SyntaxKind.MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template // of the check type's mapped type - else if (grandParent.kind === 195 /* MappedType */ && grandParent.type && - ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* ConditionalType */ && - grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* MappedType */ && + else if (grandParent.kind === 195 /* SyntaxKind.MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* SyntaxKind.ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* SyntaxKind.MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); inferences = ts.append(inferences, instantiateType(nodeType, makeUnaryTypeMapper(getDeclaredTypeOfTypeParameter(getSymbolOfNode(checkMappedType_1.typeParameter)), checkMappedType_1.typeParameter.constraint ? getTypeFromTypeNode(checkMappedType_1.typeParameter.constraint) : keyofConstraintType))); } } + }; + for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + _loop_15(declaration); } } return inferences && getIntersectionType(inferences); @@ -60501,10 +60699,10 @@ var ts; } else { var type = getTypeFromTypeNode(constraintDeclaration); - if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed + if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 195 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -60513,7 +60711,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -60541,29 +60739,29 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type - // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // of an object literal or a non-inferrable type. This is because there are operations in the type checker // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - if (!(type.flags & excludeKinds)) { + if (excludeKinds === undefined || !(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } } - return result & 458752 /* PropagatingFlags */; + return result & 458752 /* ObjectFlags.PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations.get(id); if (!type) { - type = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); target.instantiations.set(id, type); - type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; + type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0; type.target = target; type.resolvedTypeArguments = typeArguments; } @@ -60583,7 +60781,7 @@ var ts; var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; } - var type = createObjectType(4 /* Reference */, target.symbol); + var type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; @@ -60594,13 +60792,13 @@ var ts; function getTypeArguments(type) { var _a, _b; if (!type.resolvedTypeArguments) { - if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) { + if (!pushTypeResolution(type, 6 /* TypeSystemPropertyName.ResolvedTypeArguments */)) { return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 178 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 178 /* SyntaxKind.TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -60635,14 +60833,14 @@ var ts; missingAugmentsTag ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; - var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); + var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) return errorType; } } - if (node.kind === 178 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -60673,12 +60871,12 @@ var ts; * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ function getTypeFromTypeAliasReference(node, symbol) { - if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) { + if (ts.getCheckFlags(symbol) & 1048576 /* CheckFlags.Unresolved */) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); var id = getAliasId(symbol, typeArguments); var errorType_1 = errorTypes.get(id); if (!errorType_1) { - errorType_1 = createIntrinsicType(1 /* Any */, "error"); + errorType_1 = createIntrinsicType(1 /* TypeFlags.Any */, "error"); errorType_1.aliasSymbol = symbol; errorType_1.aliasTypeArguments = typeArguments; errorTypes.set(id, errorType_1); @@ -60713,9 +60911,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -60727,21 +60925,21 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { - var identifier = name.kind === 161 /* QualifiedName */ ? name.right : - name.kind === 206 /* PropertyAccessExpression */ ? name.name : + var identifier = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? name.name : name; var text = identifier.escapedText; if (text) { - var parentSymbol = name.kind === 161 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : - name.kind === 206 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : + var parentSymbol = name.kind === 161 /* SyntaxKind.QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { - unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */)); + unresolvedSymbols.set(path, result = createSymbol(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */)); result.parent = parentSymbol; result.declaredType = unresolvedType; } @@ -60763,10 +60961,10 @@ var ts; return errorType; } symbol = getExpandoSymbol(symbol) || symbol; - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getTypeFromClassOrInterfaceReference(node, symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) @@ -60774,14 +60972,14 @@ var ts; if (res) { return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType; } - if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + if (symbol.flags & 111551 /* SymbolFlags.Value */ && isJSDocTypeReference(node)) { var jsdocType = getTypeFromJSDocValueReference(node, symbol); if (jsdocType) { return jsdocType; } else { // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(node, 788968 /* Type */); + resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */); return getTypeOfSymbol(symbol); } } @@ -60797,7 +60995,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 200 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 200 /* SyntaxKind.ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); @@ -60808,22 +61006,22 @@ var ts; return links.resolvedJSDocType; } function getSubstitutionType(baseType, substitute) { - if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) { + if (substitute.flags & 3 /* TypeFlags.AnyOrUnknown */ || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; } - var result = createType(33554432 /* Substitution */); + var result = createType(33554432 /* TypeFlags.Substitution */); result.baseType = baseType; result.substitute = substitute; substitutionTypes.set(id, result); return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 184 /* TupleType */ && node.elements.length === 1; + return node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -60833,16 +61031,16 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 320 /* JSDoc */) { + while (node && !ts.isStatement(node) && node.kind !== 320 /* SyntaxKind.JSDoc */) { var parent = node.parent; // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax - if (parent.kind === 164 /* Parameter */) { + if (parent.kind === 164 /* SyntaxKind.Parameter */) { covariant = !covariant; } // Always substitute on type parameters, regardless of variance, since even // in contravariant positions, they may rely on substituted constraints to be valid - if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 189 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeFlags.TypeVariable */) && parent.kind === 189 /* SyntaxKind.ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -60850,7 +61048,7 @@ var ts; } // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the // template type XXX, K has an added constraint of number | `${number}`. - else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 195 /* MappedType */ && node === parent.type) { + else if (type.flags & 262144 /* TypeFlags.TypeParameter */ && parent.kind === 195 /* SyntaxKind.MappedType */ && node === parent.type) { var mappedType = getTypeFromTypeNode(parent); if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { var typeParameter = getHomomorphicTypeVariable(mappedType); @@ -60867,7 +61065,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */); + return !!(node.flags & 8388608 /* NodeFlags.JSDoc */) && (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 200 /* SyntaxKind.ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -60923,7 +61121,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -60935,13 +61133,13 @@ var ts; } var symbol = void 0; var type = void 0; - var meaning = 788968 /* Type */; + var meaning = 788968 /* SymbolFlags.Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); if (!type) { symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true); if (symbol === unknownSymbol) { - symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */); + symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */); } else { resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any @@ -60982,9 +61180,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declaration; } } @@ -60994,7 +61192,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 524288 /* Object */)) { + if (!(type.flags & 524288 /* TypeFlags.Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -61005,13 +61203,13 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* SymbolFlags.Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalTypeAliasSymbol(name, arity, reportErrors) { - var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); if (symbol) { // Resolve the declared type of the symbol. This resolves type parameters for the type // alias so that we can check arity. @@ -61047,9 +61245,9 @@ var ts; function getGlobalImportMetaExpressionType() { if (!deferredGlobalImportMetaExpressionType) { // Create a synthetic type `ImportMetaExpression { meta: MetaProperty }` - var symbol = createSymbol(0 /* None */, "ImportMetaExpression"); + var symbol = createSymbol(0 /* SymbolFlags.None */, "ImportMetaExpression"); var importMetaType = getGlobalImportMetaType(); - var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */); + var metaPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "meta", 8 /* CheckFlags.Readonly */); metaPropertySymbol.parent = symbol; metaPropertySymbol.type = importMetaType; var members = ts.createSymbolTable([metaPropertySymbol]); @@ -61114,7 +61312,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -61152,20 +61350,20 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 185 /* OptionalType */: - return 2 /* Optional */; - case 186 /* RestType */: + case 185 /* SyntaxKind.OptionalType */: + return 2 /* ElementFlags.Optional */; + case 186 /* SyntaxKind.RestType */: return getRestTypeElementFlags(node); - case 197 /* NamedTupleMember */: - return node.questionToken ? 2 /* Optional */ : + case 197 /* SyntaxKind.NamedTupleMember */: + return node.questionToken ? 2 /* ElementFlags.Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + 1 /* ElementFlags.Required */; default: - return 1 /* Required */; + return 1 /* ElementFlags.Required */; } } function getRestTypeElementFlags(node) { - return getArrayElementTypeNode(node.type) ? 4 /* Rest */ : 8 /* Variadic */; + return getArrayElementTypeNode(node.type) ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */; } function getArrayOrTupleTargetType(node) { var readonly = isReadonlyTypeOperator(node.parent); @@ -61174,14 +61372,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* SyntaxKind.NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 184 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* SyntaxKind.ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 184 /* SyntaxKind.TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -61190,18 +61388,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 194 /* IndexedAccessType */: - case 189 /* ConditionalType */: - case 193 /* TypeOperator */: - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 189 /* SyntaxKind.ConditionalType */: + case 193 /* SyntaxKind.TypeOperator */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return isResolvedByTypeAlias(parent); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } return false; @@ -61210,28 +61408,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 178 /* TypeReference */: - return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 181 /* TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */).flags & 524288 /* SymbolFlags.TypeAlias */); + case 181 /* SyntaxKind.TypeQuery */: return true; - case 193 /* TypeOperator */: - return node.operator !== 154 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 197 /* NamedTupleMember */: - case 316 /* JSDocOptionalType */: - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 193 /* SyntaxKind.TypeOperator */: + return node.operator !== 154 /* SyntaxKind.UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 186 /* RestType */: - return node.type.kind !== 183 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 186 /* SyntaxKind.RestType */: + return node.type.kind !== 183 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -61244,33 +61442,33 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 184 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 184 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 184 /* SyntaxKind.TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* ElementFlags.Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 145 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } - var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* Required */; }), readonly, namedMemberDeclarations); + var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* ElementFlags.Required */; }), readonly, namedMemberDeclarations); return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget; } function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { - if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) { + if (elementFlags.length === 1 && elementFlags[0] & 4 /* ElementFlags.Rest */) { // [...X[]] is equivalent to just X[] return readonly ? globalReadonlyArrayType : globalArrayType; } - var key = ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*"; }).join() + + var key = ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? "#" : f & 2 /* ElementFlags.Optional */ ? "?" : f & 4 /* ElementFlags.Rest */ ? "." : "*"; }).join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : ""); var type = tupleTypes.get(key); @@ -61288,7 +61486,7 @@ var ts; // is true for each of the synthesized type parameters. function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { var arity = elementFlags.length; - var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* Required */ | 8 /* Variadic */)); }); + var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* ElementFlags.Required */ | 8 /* ElementFlags.Variadic */)); }); var typeParameters; var properties = []; var combinedFlags = 0; @@ -61298,8 +61496,8 @@ var ts; var typeParameter = typeParameters[i] = createTypeParameter(); var flags = elementFlags[i]; combinedFlags |= flags; - if (!(combinedFlags & 12 /* Variable */)) { - var property = createSymbol(4 /* Property */ | (flags & 2 /* Optional */ ? 16777216 /* Optional */ : 0), "" + i, readonly ? 8 /* Readonly */ : 0); + if (!(combinedFlags & 12 /* ElementFlags.Variable */)) { + var property = createSymbol(4 /* SymbolFlags.Property */ | (flags & 2 /* ElementFlags.Optional */ ? 16777216 /* SymbolFlags.Optional */ : 0), "" + i, readonly ? 8 /* CheckFlags.Readonly */ : 0); property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i]; property.type = typeParameter; properties.push(property); @@ -61307,8 +61505,8 @@ var ts; } } var fixedLength = properties.length; - var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0); - if (combinedFlags & 12 /* Variable */) { + var lengthSymbol = createSymbol(4 /* SymbolFlags.Property */, "length", readonly ? 8 /* CheckFlags.Readonly */ : 0); + if (combinedFlags & 12 /* ElementFlags.Variable */) { lengthSymbol.type = numberType; } else { @@ -61318,7 +61516,7 @@ var ts; lengthSymbol.type = getUnionType(literalTypes); } properties.push(lengthSymbol); - var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); + var type = createObjectType(8 /* ObjectFlags.Tuple */ | 4 /* ObjectFlags.Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -61336,26 +61534,26 @@ var ts; type.elementFlags = elementFlags; type.minLength = minLength; type.fixedLength = fixedLength; - type.hasRestElement = !!(combinedFlags & 12 /* Variable */); + type.hasRestElement = !!(combinedFlags & 12 /* ElementFlags.Variable */); type.combinedFlags = combinedFlags; type.readonly = readonly; type.labeledElementDeclarations = namedMemberDeclarations; return type; } function createNormalizedTypeReference(target, typeArguments) { - return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); + return target.objectFlags & 8 /* ObjectFlags.Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); } function createNormalizedTupleType(target, elementTypes) { var _a, _b, _c; - if (!(target.combinedFlags & 14 /* NonRequired */)) { + if (!(target.combinedFlags & 14 /* ElementFlags.NonRequired */)) { // No need to normalize when we only have regular required elements return createTypeReference(target, elementTypes); } - if (target.combinedFlags & 8 /* Variadic */) { + if (target.combinedFlags & 8 /* ElementFlags.Variadic */) { // Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z] - var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* ElementFlags.Variadic */ && t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex_1 >= 0) { - return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ? + return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : unknownType; })) ? mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) : errorType; } @@ -61371,13 +61569,13 @@ var ts; var lastRequiredIndex = -1; var firstRestIndex = -1; var lastOptionalOrRestIndex = -1; - var _loop_15 = function (i) { + var _loop_16 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; - if (flags & 8 /* Variadic */) { - if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) { + if (flags & 8 /* ElementFlags.Variadic */) { + if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type)) { // Generic variadic elements stay as they are. - addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + addElement(type, 8 /* ElementFlags.Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { var elements = getTypeArguments(type); @@ -61392,7 +61590,7 @@ var ts; } else { // Treat everything else as an array type and create a rest element. - addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); + addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* ElementFlags.Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); } } else { @@ -61401,18 +61599,18 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - var state_4 = _loop_15(i); + var state_4 = _loop_16(i); if (typeof state_4 === "object") return state_4.value; } // Turn optional elements preceding the last required element into required elements for (var i = 0; i < lastRequiredIndex; i++) { - if (expandedFlags[i] & 2 /* Optional */) - expandedFlags[i] = 1 /* Required */; + if (expandedFlags[i] & 2 /* ElementFlags.Optional */) + expandedFlags[i] = 1 /* ElementFlags.Required */; } if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) { // Turn elements between first rest and last optional/rest into a single rest element - expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; })); + expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; })); expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); @@ -61422,13 +61620,13 @@ var ts; expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget; function addElement(type, flags, declaration) { - if (flags & 1 /* Required */) { + if (flags & 1 /* ElementFlags.Required */) { lastRequiredIndex = expandedFlags.length; } - if (flags & 4 /* Rest */ && firstRestIndex < 0) { + if (flags & 4 /* ElementFlags.Rest */ && firstRestIndex < 0) { firstRestIndex = expandedFlags.length; } - if (flags & (2 /* Optional */ | 4 /* Rest */)) { + if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) { lastOptionalOrRestIndex = expandedFlags.length; } expandedTypes.push(type); @@ -61480,19 +61678,19 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 1048576 /* Union */) { - return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* Union */ : 0), type.types); + if (flags & 1048576 /* TypeFlags.Union */) { + return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* TypeFlags.Union */ : 0), type.types); } // We ignore 'never' types in unions - if (!(flags & 131072 /* Never */)) { - includes |= flags & 205258751 /* IncludesMask */; - if (flags & 465829888 /* Instantiable */) - includes |= 33554432 /* IncludesInstantiable */; + if (!(flags & 131072 /* TypeFlags.Never */)) { + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; + if (flags & 465829888 /* TypeFlags.Instantiable */) + includes |= 33554432 /* TypeFlags.IncludesInstantiable */; if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; - if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 65536 /* ContainsWideningType */)) - includes |= 4194304 /* IncludesNonWideningType */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; + if (!strictNullChecks && flags & 98304 /* TypeFlags.Nullable */) { + if (!(ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */)) + includes |= 4194304 /* TypeFlags.IncludesNonWideningType */; } else { var len = typeSet.length; @@ -61526,18 +61724,18 @@ var ts; // We assume that redundant primitive types have already been removed from the types array and that there // are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty // object types, and if none of those are present we can exclude primitive types from the subtype check. - var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); + var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); var len = types.length; var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (hasEmptyObject || source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { // Find the first property with a unit type, if any. When constituents have a property by the same name // but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype // reduction of large discriminated union types. - var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? + var keyProperty = source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : undefined; var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); @@ -61551,20 +61749,20 @@ var ts; // caps union types at 1000 unique object types. var estimatedCount = (count / (len - i)) * len; if (estimatedCount > 1000000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return undefined; } } count++; - if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (keyProperty && target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { continue; } } - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || + if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* ObjectFlags.Class */) || + !(ts.getObjectFlags(getTargetType(target)) & 1 /* ObjectFlags.Class */) || isTypeDerivedFrom(source, target))) { ts.orderedRemoveItemAt(types, i); break; @@ -61582,11 +61780,11 @@ var ts; i--; var t = types[i]; var flags = t.flags; - var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || - flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ || + flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ || + flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ || + flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ || + reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -61597,30 +61795,30 @@ var ts; var templates = ts.filter(types, isPatternLiteralType); if (templates.length) { var i = types.length; - var _loop_16 = function () { + var _loop_17 = function () { i--; var t = types[i]; - if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { + if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { ts.orderedRemoveItemAt(types, i); } }; while (i > 0) { - _loop_16(); + _loop_17(); } } } function isNamedUnionType(type) { - return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin)); + return !!(type.flags & 1048576 /* TypeFlags.Union */ && (type.aliasSymbol || type.origin)); } function addNamedUnions(namedUnions, types) { for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { var t = types_11[_i]; - if (t.flags & 1048576 /* Union */) { + if (t.flags & 1048576 /* TypeFlags.Union */) { var origin = t.origin; - if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { + if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* TypeFlags.Union */)) { ts.pushIfUnique(namedUnions, t); } - else if (origin && origin.flags & 1048576 /* Union */) { + else if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { addNamedUnions(namedUnions, origin.types); } } @@ -61639,7 +61837,7 @@ var ts; // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) { - if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } + if (unionReduction === void 0) { unionReduction = 1 /* UnionReduction.Literal */; } if (types.length === 0) { return neverType; } @@ -61648,48 +61846,48 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (unionReduction !== 0 /* None */) { - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? - includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : - includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; + if (unionReduction !== 0 /* UnionReduction.None */) { + if (includes & 3 /* TypeFlags.AnyOrUnknown */) { + return includes & 1 /* TypeFlags.Any */ ? + includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType : + includes & 65536 /* TypeFlags.Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; } - if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { + if (exactOptionalPropertyTypes && includes & 32768 /* TypeFlags.Undefined */) { var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { ts.orderedRemoveItemAt(typeSet, missingIndex); } } - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + if (includes & (2944 /* TypeFlags.Literal */ | 8192 /* TypeFlags.UniqueESSymbol */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* UnionReduction.Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* TypeFlags.StringLiteral */ && includes & 134217728 /* TypeFlags.TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (unionReduction === 2 /* Subtype */) { - typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (unionReduction === 2 /* UnionReduction.Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* TypeFlags.Object */)); if (!typeSet) { return errorType; } } if (typeSet.length === 0) { - return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : - includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 65536 /* TypeFlags.Null */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* TypeFlags.Undefined */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType; } } - if (!origin && includes & 1048576 /* Union */) { + if (!origin && includes & 1048576 /* TypeFlags.Union */) { var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; - var _loop_17 = function (t) { + var _loop_18 = function (t) { if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) { reducedTypes.push(t); } }; for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) { var t = typeSet_1[_i]; - _loop_17(t); + _loop_18(t); } if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) { return namedUnions[0]; @@ -61702,11 +61900,11 @@ var ts; var t = namedUnions_1[_a]; insertType(reducedTypes, t); } - origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); + origin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, reducedTypes); } } - var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 36323363 /* TypeFlags.NotPrimitiveUnion */ ? 0 : 32768 /* ObjectFlags.PrimitiveUnion */) | + (includes & 2097152 /* TypeFlags.Intersection */ ? 16777216 /* ObjectFlags.ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } function getUnionOrIntersectionTypePredicate(signatures, kind) { @@ -61715,8 +61913,8 @@ var ts; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { - if (kind !== 2097152 /* Intersection */) { + if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { + if (kind !== 2097152 /* TypeFlags.Intersection */) { continue; } else { @@ -61753,20 +61951,20 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving + origin.flags & 1048576 /* TypeFlags.Union */ ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 /* TypeFlags.Intersection */ ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { - type = createType(1048576 /* Union */); - type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* TypeFlags.Union */); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); type.types = types; type.origin = origin; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) { - type.flags |= 16 /* Boolean */; + if (types.length === 2 && types[0].flags & 512 /* TypeFlags.BooleanLiteral */ && types[1].flags & 512 /* TypeFlags.BooleanLiteral */) { + type.flags |= 16 /* TypeFlags.Boolean */; type.intrinsicName = "boolean"; } unionTypes.set(id, type); @@ -61777,41 +61975,41 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* UnionReduction.Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & 16777216 /* IncludesEmptyObject */)) { - includes |= 16777216 /* IncludesEmptyObject */; + if (!(includes & 16777216 /* TypeFlags.IncludesEmptyObject */)) { + includes |= 16777216 /* TypeFlags.IncludesEmptyObject */; typeSet.set(type.id.toString(), type); } } else { - if (flags & 3 /* AnyOrUnknown */) { + if (flags & 3 /* TypeFlags.AnyOrUnknown */) { if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; } - else if (strictNullChecks || !(flags & 98304 /* Nullable */)) { + else if (strictNullChecks || !(flags & 98304 /* TypeFlags.Nullable */)) { if (exactOptionalPropertyTypes && type === missingType) { - includes |= 262144 /* IncludesMissingType */; + includes |= 262144 /* TypeFlags.IncludesMissingType */; type = undefinedType; } if (!typeSet.has(type.id.toString())) { - if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { + if (type.flags & 109440 /* TypeFlags.Unit */ && includes & 109440 /* TypeFlags.Unit */) { // We have seen two distinct unit types which means we should reduce to an // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. - includes |= 67108864 /* NonPrimitive */; + includes |= 67108864 /* TypeFlags.NonPrimitive */; } typeSet.set(type.id.toString(), type); } } - includes |= flags & 205258751 /* IncludesMask */; + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; } return includes; } @@ -61829,12 +62027,12 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || - t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || - t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ || - isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */; + var remove = t.flags & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + t.flags & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + t.flags & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + t.flags & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */ || + t.flags & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */ || + isEmptyAnonymousObjectType(t) && includes & 470302716 /* TypeFlags.DefinitelyNonNullable */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -61847,10 +62045,10 @@ var ts; for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) { var u = unionTypes_1[_i]; if (!containsType(u.types, type)) { - var primitive = type.flags & 128 /* StringLiteral */ ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + var primitive = type.flags & 128 /* TypeFlags.StringLiteral */ ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : undefined; if (!primitive || !containsType(u.types, primitive)) { return false; @@ -61864,11 +62062,11 @@ var ts; */ function extractRedundantTemplateLiterals(types) { var i = types.length; - var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); }); + var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); }); while (i > 0) { i--; var t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */)) continue; for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) { var t2 = literals_1[_i]; @@ -61885,7 +62083,7 @@ var ts; return false; } function eachIsUnionContaining(types, flag) { - return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); + return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); } function removeFromEach(types, flag) { for (var i = 0; i < types.length; i++) { @@ -61897,7 +62095,7 @@ var ts; // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); }); if (index < 0) { return false; } @@ -61906,7 +62104,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -61935,12 +62133,12 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { - var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + var result = createType(2097152 /* TypeFlags.Intersection */); + result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -61969,37 +62167,37 @@ var ts; // a symbol-like type and a type known to be non-symbol-like, or // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. - if (includes & 131072 /* Never */) { + if (includes & 131072 /* TypeFlags.Never */) { return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; } - if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || - includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || - includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || - includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || - includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || - includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || - includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) || + includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) || + includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) || + includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) || + includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) || + includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) || + includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } - if (includes & 1 /* Any */) { - return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType; + if (includes & 1 /* TypeFlags.Any */) { + return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 98304 /* Nullable */) { - return includes & 32768 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) { + return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || - includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || - includes & 16384 /* Void */ && includes & 32768 /* Undefined */ || - includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) { + if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */ || + includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */ || + includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 470302716 /* TypeFlags.DefinitelyNonNullable */) { if (!noSupertypeReduction) removeRedundantSupertypes(typeSet, includes); } - if (includes & 262144 /* IncludesMissingType */) { + if (includes & 262144 /* TypeFlags.IncludesMissingType */) { typeSet[typeSet.indexOf(undefinedType)] = missingType; } if (typeSet.length === 0) { @@ -62011,21 +62209,21 @@ var ts; var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { - if (includes & 1048576 /* Union */) { + if (includes & 1048576 /* TypeFlags.Union */) { if (intersectUnionsOfPrimitiveTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) { + else if (eachIsUnionContaining(typeSet, 32768 /* TypeFlags.Undefined */)) { var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType; - removeFromEach(typeSet, 32768 /* Undefined */); - result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + removeFromEach(typeSet, 32768 /* TypeFlags.Undefined */); + result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) { - removeFromEach(typeSet, 65536 /* Null */); - result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + else if (eachIsUnionContaining(typeSet, 65536 /* TypeFlags.Null */)) { + removeFromEach(typeSet, 65536 /* TypeFlags.Null */); + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } else { // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of @@ -62038,8 +62236,8 @@ var ts; // We attach a denormalized origin type when at least one constituent of the cross-product union is an // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and // the denormalized origin has fewer constituents than the union itself. - var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined; - result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin); + var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* TypeFlags.Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* TypeFlags.Intersection */, typeSet) : undefined; + result = getUnionType(constituents, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments, origin); } } else { @@ -62050,12 +62248,12 @@ var ts; return result; } function getCrossProductUnionSize(types) { - return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* Union */ ? n * t.types.length : t.flags & 131072 /* Never */ ? 0 : n; }, 1); + return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* TypeFlags.Union */ ? n * t.types.length : t.flags & 131072 /* TypeFlags.Never */ ? 0 : n; }, 1); } function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return false; } @@ -62068,7 +62266,7 @@ var ts; var constituents = types.slice(); var n = i; for (var j = types.length - 1; j >= 0; j--) { - if (types[j].flags & 1048576 /* Union */) { + if (types[j].flags & 1048576 /* TypeFlags.Union */) { var sourceTypes = types[j].types; var length_5 = sourceTypes.length; constituents[j] = sourceTypes[n % length_5]; @@ -62076,14 +62274,14 @@ var ts; } } var t = getIntersectionType(constituents); - if (!(t.flags & 131072 /* Never */)) + if (!(t.flags & 131072 /* TypeFlags.Never */)) intersections.push(t); } return intersections; } function getConstituentCount(type) { - return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 : - type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) : + return !(type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) || type.aliasSymbol ? 1 : + type.flags & 1048576 /* TypeFlags.Union */ && type.origin ? getConstituentCount(type.origin) : getConstituentCountOfTypes(type.types); } function getConstituentCountOfTypes(types) { @@ -62094,19 +62292,19 @@ var ts; if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); var types = ts.map(node.types, getTypeFromTypeNode); - var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType; + var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) && types[1] === emptyTypeLiteralType; links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction); } return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(4194304 /* Index */); + var result = createType(4194304 /* TypeFlags.Index */); result.type = type; result.stringsOnly = stringsOnly; return result; } function createOriginIndexType(type) { - var result = createOriginType(4194304 /* Index */); + var result = createOriginType(4194304 /* TypeFlags.Index */); result.type = type; return result; } @@ -62138,7 +62336,7 @@ var ts; // so we only eagerly manifest the keys if the constraint is nongeneric if (!isGenericIndexType(constraintType)) { var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); } else { // we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later @@ -62154,8 +62352,8 @@ var ts; } // we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType, // so we can return the union that preserves aliases/origin data if possible - var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes); - if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { + var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)); }) : getUnionType(keyTypes); + if (result.flags & 1048576 /* TypeFlags.Union */ && constraintType.flags & 1048576 /* TypeFlags.Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { return constraintType; } return result; @@ -62175,12 +62373,12 @@ var ts; var typeVariable = getTypeParameterFromMappedType(mappedType); return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); function isDistributive(type) { - return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true : - type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) : - type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : - type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) : - type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) : + return type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */ | 262144 /* TypeFlags.TypeParameter */ | 524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */) ? true : + type.flags & 16777216 /* TypeFlags.Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? isDistributive(type.substitute) : + type.flags & 268435456 /* TypeFlags.StringMapping */ ? isDistributive(type.type) : false; } } @@ -62192,11 +62390,11 @@ var ts; getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); - type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") : + type = prop.escapedName === "default" /* InternalSymbolName.Default */ ? getStringLiteralType("default") : name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined); } if (type && type.flags & include) { @@ -62206,14 +62404,14 @@ var ts; return neverType; } function isKeyTypeIncluded(keyType, include) { - return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); + return !!(keyType.flags & include || keyType.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); } function getLiteralTypeFromProperties(type, include, includeOrigin) { - var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; + var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); }); var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? - info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); - return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, + info.keyType === stringType && include & 8 /* TypeFlags.Number */ ? stringOrNumberType : info.keyType : neverType; }); + return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* UnionReduction.Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); } /** @@ -62223,24 +62421,27 @@ var ts; * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible). */ function isPossiblyReducibleByInstantiation(type) { - return ts.some(type.types, function (t) { - var uniqueFilled = getUniqueLiteralFilledInstantiation(t); - return getReducedType(uniqueFilled) !== uniqueFilled; - }); + var uniqueFilled = getUniqueLiteralFilledInstantiation(type); + return getReducedType(uniqueFilled) !== uniqueFilled; + } + function shouldDeferIndexType(type) { + return !!(type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || + isGenericTupleType(type) || + isGenericMappedType(type) && !hasDistributiveNameType(type) || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) || + type.flags & 2097152 /* TypeFlags.Intersection */ && maybeTypeOfKind(type, 465829888 /* TypeFlags.Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType)); } function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type) - ? getIndexTypeForGenericType(type, stringsOnly) - : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : + return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 1048576 /* TypeFlags.Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : - type.flags & 2 /* Unknown */ ? neverType : - type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : - getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); + type.flags & 2 /* TypeFlags.Unknown */ ? neverType : + type.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */) ? keyofConstraintType : + getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* TypeFlags.StringLiteral */ : 402653316 /* TypeFlags.StringLike */) | (stringsOnly ? 0 : 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -62251,21 +62452,21 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 131072 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* TypeFlags.Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 140 /* KeyOfKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 154 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 151 /* SymbolKeyword */ + case 154 /* SyntaxKind.UniqueKeyword */: + links.resolvedType = node.type.kind === 151 /* SyntaxKind.SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 145 /* ReadonlyKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -62282,7 +62483,7 @@ var ts; return links.resolvedType; } function getTemplateLiteralType(texts, types) { - var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex >= 0) { return checkCrossProductUnion(types) ? mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : @@ -62301,10 +62502,10 @@ var ts; return getStringLiteralType(text); } newTexts.push(text); - if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) { + if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -62315,13 +62516,13 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; var addText = isTextsArray ? texts[i + 1] : texts; - if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) { + if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) { text += getTemplateStringForType(t) || ""; text += addText; if (!isTextsArray) return true; } - else if (t.flags & 134217728 /* TemplateLiteral */) { + else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { text += t.texts[0]; if (!addSpans(t.texts, t.types)) return false; @@ -62334,7 +62535,7 @@ var ts; newTexts.push(text); text = addText; } - else if (t.flags & 2097152 /* Intersection */) { + else if (t.flags & 2097152 /* TypeFlags.Intersection */) { var added = addSpans(texts[i + 1], t.types); if (!added) return false; @@ -62347,47 +62548,47 @@ var ts; } } function getTemplateStringForType(type) { - return type.flags & 128 /* StringLiteral */ ? type.value : - type.flags & 256 /* NumberLiteral */ ? "" + type.value : - type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : - type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? "" + type.value : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : + type.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) ? type.intrinsicName : undefined; } function createTemplateLiteralType(texts, types) { - var type = createType(134217728 /* TemplateLiteral */); + var type = createType(134217728 /* TypeFlags.TemplateLiteral */); type.texts = texts; type.types = types; return type; } function getStringMappingType(symbol, type) { - return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : + return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : // Mapping> === Mapping - type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : - isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) : - type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : - type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) : + type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type : + isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* TypeFlags.StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) : type; } function applyStringMapping(symbol, str) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return str.toUpperCase(); - case 1 /* Lowercase */: return str.toLowerCase(); - case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); - case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); + case 0 /* IntrinsicTypeKind.Uppercase */: return str.toUpperCase(); + case 1 /* IntrinsicTypeKind.Lowercase */: return str.toLowerCase(); + case 2 /* IntrinsicTypeKind.Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); + case 3 /* IntrinsicTypeKind.Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); } return str; } function applyTemplateStringMapping(symbol, texts, types) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; - case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; - case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; - case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + case 0 /* IntrinsicTypeKind.Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 1 /* IntrinsicTypeKind.Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 2 /* IntrinsicTypeKind.Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + case 3 /* IntrinsicTypeKind.Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; } return [texts, types]; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -62395,13 +62596,13 @@ var ts; return result; } function createStringMappingType(symbol, type) { - var result = createType(268435456 /* StringMapping */); + var result = createType(268435456 /* TypeFlags.StringMapping */); result.symbol = symbol; result.type = type; return result; } function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { - var type = createType(8388608 /* IndexedAccess */); + var type = createType(8388608 /* TypeFlags.IndexedAccess */); type.objectType = objectType; type.indexType = indexType; type.accessFlags = accessFlags; @@ -62422,16 +62623,16 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 4096 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) { return true; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getResolvedBaseConstraint(type); return constraint !== type && isJSLiteralType(constraint); } @@ -62446,26 +62647,26 @@ var ts; undefined; } function isUncalledFunctionReference(node, symbol) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent; if (ts.isCallLikeExpression(parent)) { return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node); } - return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } return true; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { - if (accessFlags & 256 /* Contextual */) { + if (accessFlags & 256 /* AccessFlags.Contextual */) { return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* AccessFlags.ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } @@ -62475,7 +62676,7 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 8 /* CacheSymbol */) { + if (accessFlags & 8 /* AccessFlags.CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -62483,50 +62684,57 @@ var ts; } } var propType = getTypeOfSymbol(prop); - return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? + return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* AssignmentKind.Definite */ ? getFlowTypeOfReference(accessExpression, propType) : propType; } - if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { + if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) { + var index = +propName; + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* AccessFlags.NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { + if (index < 0) { + error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value); + return undefinedType; + } error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); } else { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } } - errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); - return mapType(objectType, function (t) { - var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; - }); + if (index >= 0) { + errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); + return mapType(objectType, function (t) { + var restType = getRestTypeOfTupleType(t) || undefinedType; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; + }); + } } } - if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { + if (!(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */)) { + if (objectType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) { return objectType; } // If no index signature is applicable, we default to the string index signature. In effect, this means the string // index signature applies even when accessing with a symbol-like type. var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType); if (indexInfo) { - if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { + if (accessFlags & 2 /* AccessFlags.NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } return undefined; } - if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } - if (indexType.flags & 131072 /* Never */) { + if (indexType.flags & 131072 /* TypeFlags.Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -62534,21 +62742,21 @@ var ts; } if (accessExpression && !isConstEnumObjectType(objectType)) { if (isObjectLiteralType(objectType)) { - if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (noImplicitAny && indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType))); return undefinedType; } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { var types = ts.map(objectType.properties, function (property) { return getTypeOfSymbol(property); }); return getUnionType(ts.append(types, undefinedType)); } } - if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* SymbolFlags.BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* AccessFlags.SuppressNoImplicitAnyError */)) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { var typeName = typeToString(objectType); error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]"); @@ -62570,20 +62778,20 @@ var ts; } else { var errorInfo = void 0; - if (indexType.flags & 1024 /* EnumLiteral */) { + if (indexType.flags & 1024 /* TypeFlags.EnumLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType)); } - else if (indexType.flags & 8192 /* UniqueESSymbol */) { + else if (indexType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression); errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType)); } - else if (indexType.flags & 128 /* StringLiteral */) { + else if (indexType.flags & 128 /* TypeFlags.StringLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & 256 /* NumberLiteral */) { + else if (indexType.flags & 256 /* TypeFlags.NumberLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType)); } errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType)); @@ -62600,10 +62808,10 @@ var ts; } if (accessNode) { var indexNode = getIndexNodeForAccessExpression(accessNode); - if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { + else if (indexType.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { @@ -62621,62 +62829,62 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 194 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 162 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 194 /* SyntaxKind.IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type)); + return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */ && isPatternLiteralPlaceholderType(type.type)); } function isPatternLiteralType(type) { - return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); + return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); } function isGenericType(type) { return !!getGenericObjectFlags(type); } function isGenericObjectType(type) { - return !!(getGenericObjectFlags(type) & 4194304 /* IsGenericObjectType */); + return !!(getGenericObjectFlags(type) & 4194304 /* ObjectFlags.IsGenericObjectType */); } function isGenericIndexType(type) { - return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */); + return !!(getGenericObjectFlags(type) & 8388608 /* ObjectFlags.IsGenericIndexType */); } function getGenericObjectFlags(type) { - if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 33554432 /* TypeFlags.Substitution */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | - (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0); + return (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* ObjectFlags.IsGenericObjectType */ : 0) | + (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* ObjectFlags.IsGenericIndexType */ : 0); } function getSimplifiedType(type, writing) { - return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : - type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : + return type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getSimplifiedConditionalType(type, writing) : type; } function distributeIndexOverObjectType(objectType, indexType, writing) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 3145728 /* UnionOrIntersection */) { + if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); }); - return objectType.flags & 2097152 /* Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); + return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); } } function distributeObjectOverIndexType(objectType, indexType, writing) { // T[A | B] -> T[A] | T[B] (reading) // T[A | B] -> T[A] & T[B] (writing) - if (indexType.flags & 1048576 /* Union */) { + if (indexType.flags & 1048576 /* TypeFlags.Union */) { var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); }); return writing ? getIntersectionType(types) : getUnionType(types); } @@ -62701,7 +62909,7 @@ var ts; return type[cache] = distributedOverIndex; } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 465829888 /* Instantiable */)) { + if (!(indexType.flags & 465829888 /* TypeFlags.Instantiable */)) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] @@ -62715,8 +62923,8 @@ var ts; // A generic tuple type indexed by a number exists only when the index type doesn't select a // fixed element. We simplify to either the combined type of all elements (when the index type // the actual number type) or to the combined type of all non-fixed elements. - if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) { - var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); + if (isGenericTupleType(objectType) && indexType.flags & 296 /* TypeFlags.NumberLike */) { + var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* TypeFlags.Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); if (elementType) { return type[cache] = elementType; } @@ -62738,19 +62946,19 @@ var ts; var trueType = getTrueTypeFromConditionalType(type); var falseType = getFalseTypeFromConditionalType(type); // Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`. - if (falseType.flags & 131072 /* Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { - if (checkType.flags & 1 /* Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + if (falseType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { + if (checkType.flags & 1 /* TypeFlags.Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return getSimplifiedType(trueType, writing); } else if (isIntersectionEmpty(checkType, extendsType)) { // Always false return neverType; } } - else if (trueType.flags & 131072 /* Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { - if (!(checkType.flags & 1 /* Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + else if (trueType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { + if (!(checkType.flags & 1 /* TypeFlags.Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return neverType; } - else if (checkType.flags & 1 /* Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false + else if (checkType.flags & 1 /* TypeFlags.Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false return getSimplifiedType(falseType, writing); } } @@ -62760,7 +62968,7 @@ var ts; * Invokes union simplification logic to determine if an intersection is considered empty as a union constituent */ function isIntersectionEmpty(type1, type2) { - return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* Never */); + return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* TypeFlags.Never */); } function substituteIndexedMappedType(objectType, index) { var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); @@ -62768,12 +62976,12 @@ var ts; return instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper); } function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { - if (t.flags & 384 /* StringOrNumberLiteral */) { + if (t.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var propName = getPropertyNameFromType(t); if (ts.isNumericLiteralName(propName)) { var index = +propName; @@ -62784,33 +62992,33 @@ var ts; }); } function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. - if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { indexType = stringType; } // In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to // an index signature have 'undefined' included in their type. - if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) - accessFlags |= 1 /* IncludeUndefined */; + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* AccessFlags.ExpressionPosition */) + accessFlags |= 1 /* AccessFlags.IncludeUndefined */; // If the index type is generic, or if the object type is generic and doesn't originate in an expression and // the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing // a higher-order index access where we cannot meaningfully access the properties of the object type. Note that // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* SyntaxKind.IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { - if (objectType.flags & 3 /* AnyOrUnknown */) { + if (objectType.flags & 3 /* TypeFlags.AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var persistentAccessFlags = accessFlags & 1 /* AccessFlags.Persistent */; var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { @@ -62822,12 +63030,12 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getReducedApparentType(objectType); - if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* TypeFlags.Union */ && !(indexType.flags & 16 /* TypeFlags.Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* AccessFlags.SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -62843,11 +63051,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 4 /* Writing */ + return accessFlags & 4 /* AccessFlags.Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) - : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); + : getUnionType(propTypes, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* AccessFlags.CacheSymbol */ | 64 /* AccessFlags.ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -62855,8 +63063,8 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); - links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && + var resolved = getIndexedAccessType(objectType, indexType, 0 /* AccessFlags.None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + links.resolvedType = resolved.flags & 8388608 /* TypeFlags.IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConditionalFlowTypeOfType(resolved, node) : resolved; @@ -62866,7 +63074,7 @@ var ts; function getTypeFromMappedTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(32 /* Mapped */, node.symbol); + var type = createObjectType(32 /* ObjectFlags.Mapped */, node.symbol); type.declaration = node; type.aliasSymbol = getAliasSymbolForTypeNode(node); type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol); @@ -62878,11 +63086,11 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return type.baseType; } - if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ || - type.indexType.flags & 33554432 /* Substitution */)) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */ && (type.objectType.flags & 33554432 /* TypeFlags.Substitution */ || + type.indexType.flags & 33554432 /* TypeFlags.Substitution */)) { return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType)); } return type; @@ -62913,7 +63121,7 @@ var ts; var result; var extraTypes; var tailCount = 0; - var _loop_18 = function () { + var _loop_19 = function () { if (tailCount === 1000) { error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); result = errorType; @@ -62947,7 +63155,7 @@ var ts; // * The mapper that maps the clone to its inference result (`context.mapper`) var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter); var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined; - var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */); + var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */); if (freshMapper) { var freshCombinedMapper = combineTypeMappers(mapper, freshMapper); for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) { @@ -62965,7 +63173,7 @@ var ts; // We don't want inferences from constraints as they may cause us to eagerly resolve the // conditional type instead of deferring resolution. Also, we always want strict function // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); } var innerMapper = combineTypeMappers(freshMapper, context.mapper); // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the @@ -62981,15 +63189,15 @@ var ts; // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, // then no instantiations will be and we can just return the false branch type. - if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */ && !isUnwrapped) { + if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) { (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } // If falseType is an immediately nested conditional type that isn't distributive or has an // identical checkType, switch to that type and loop. var falseType_1 = getTypeFromTypeNode(root.node.falseType); - if (falseType_1.flags & 16777216 /* Conditional */) { + if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) { var newRoot = falseType_1.root; if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { root = newRoot; @@ -63007,7 +63215,7 @@ var ts; // that has no constraint. This ensures that, for example, the type // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. - if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { + if (inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { var trueType_1 = getTypeFromTypeNode(root.node.trueType); var trueMapper = combinedMapper || mapper; if (canTailRecurse(trueType_1, trueMapper)) { @@ -63018,7 +63226,7 @@ var ts; } } // Return a deferred type for a check that is neither definitely true nor definitely false - result = createType(16777216 /* Conditional */); + result = createType(16777216 /* TypeFlags.Conditional */); result.root = root; result.checkType = instantiateType(root.checkType, mapper); result.extendsType = instantiateType(root.extendsType, mapper); @@ -63034,7 +63242,7 @@ var ts; // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive // cases we increment the tail recursion counter and stop after 1000 iterations. while (true) { - var state_5 = _loop_18(); + var state_5 = _loop_19(); if (typeof state_5 === "object") return state_5.value; if (state_5 === "break") @@ -63046,14 +63254,14 @@ var ts; // type. Note that recursion is possible only through aliased conditional types, so we only increment the tail // recursion counter for those. function canTailRecurse(newType, newMapper) { - if (newType.flags & 16777216 /* Conditional */ && newMapper) { + if (newType.flags & 16777216 /* TypeFlags.Conditional */ && newMapper) { var newRoot = newType.root; if (newRoot.outerTypeParameters) { var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper); var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); }); var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments); var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined; - if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) { + if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */))) { root = newRoot; mapper = newRootMapper; aliasSymbol = undefined; @@ -63081,7 +63289,7 @@ var ts; var result; if (node.locals) { node.locals.forEach(function (symbol) { - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { result = ts.append(result, getDeclaredTypeOfSymbol(symbol)); } }); @@ -63104,7 +63312,7 @@ var ts; node: node, checkType: checkType, extendsType: getTypeFromTypeNode(node.extendsType), - isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeFlags.TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -63135,6 +63343,7 @@ var ts; } } function getTypeFromImportTypeNode(node) { + var _a; var links = getNodeLinks(node); if (!links.resolvedType) { if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments @@ -63147,27 +63356,30 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* SymbolFlags.Value */ : node.flags & 8388608 /* NodeFlags.JSDoc */ ? 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ : 788968 /* SymbolFlags.Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } + var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)); var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); if (!ts.nodeIsMissing(node.qualifier)) { var nameStack = getIdentifierChain(node.qualifier); var currentNamespace = moduleSymbol; var current = void 0; while (current = nameStack.shift()) { - var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning; + var meaning = nameStack.length ? 1920 /* SymbolFlags.Namespace */ : targetMeaning; // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from // the `exports` lookup process that only looks up namespace members which is used for most type references var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace)); - var next = node.isTypeOf + var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true) - : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + : undefined; + var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable; if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); return links.resolvedType = errorType; @@ -63183,7 +63395,7 @@ var ts; links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 111551 /* Value */ + var errorMessage = targetMeaning === 111551 /* SymbolFlags.Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -63197,7 +63409,7 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 111551 /* Value */) { + if (meaning === 111551 /* SymbolFlags.Value */) { return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { @@ -63213,7 +63425,7 @@ var ts; links.resolvedType = emptyTypeLiteralType; } else { - var type = createObjectType(16 /* Anonymous */, node.symbol); + var type = createObjectType(16 /* ObjectFlags.Anonymous */, node.symbol); type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); if (ts.isJSDocTypeLiteral(node) && node.isArrayType) { @@ -63226,7 +63438,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -63235,13 +63447,13 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function isNonGenericObjectType(type) { - return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + return !!(type.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(type); } function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) { - return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); + return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return type; } if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { @@ -63261,13 +63473,13 @@ var ts; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // do nothing, skip privates } else if (isSpreadableProperty(prop)) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - var flags = 4 /* Property */ | 16777216 /* Optional */; - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */; + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -63276,7 +63488,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return spread; } } @@ -63286,31 +63498,31 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, symbol, objectFlags, readonly) { - if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + if (left.flags & 1 /* TypeFlags.Any */ || right.flags & 1 /* TypeFlags.Any */) { return anyType; } - if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + if (left.flags & 2 /* TypeFlags.Unknown */ || right.flags & 2 /* TypeFlags.Unknown */) { return unknownType; } - if (left.flags & 131072 /* Never */) { + if (left.flags & 131072 /* TypeFlags.Never */) { return right; } - if (right.flags & 131072 /* Never */) { + if (right.flags & 131072 /* TypeFlags.Never */) { return left; } left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); - if (left.flags & 1048576 /* Union */) { + if (left.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) : errorType; } right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); - if (right.flags & 1048576 /* Union */) { + if (right.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) : errorType; } - if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { + if (right.flags & (528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)) { return left; } if (isGenericObjectType(left) || isGenericObjectType(right)) { @@ -63320,7 +63532,7 @@ var ts; // When the left type is an intersection, we may need to merge the last constituent of the // intersection with the right type. For example when the left type is 'T & { a: string }' // and the right type is '{ b: string }' we produce 'T & { a: string, b: string }'. - if (left.flags & 2097152 /* Intersection */) { + if (left.flags & 2097152 /* TypeFlags.Intersection */) { var types = left.types; var lastLeft = types[types.length - 1]; if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { @@ -63334,7 +63546,7 @@ var ts; var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { @@ -63349,11 +63561,11 @@ var ts; if (members.has(leftProp.escapedName)) { var rightProp = members.get(leftProp.escapedName); var rightType = getTypeOfSymbol(rightProp); - if (rightProp.flags & 16777216 /* Optional */) { + if (rightProp.flags & 16777216 /* SymbolFlags.Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); + var flags = 4 /* SymbolFlags.Property */ | (leftProp.flags & 16777216 /* SymbolFlags.Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */); + result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* UnionReduction.Subtype */); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -63366,23 +63578,23 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); })); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */ | 2097152 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 2097152 /* ObjectFlags.ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { var _a; return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && - (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + (!(prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) || !((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); }))); } function getSpreadSymbol(prop, readonly) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) { return prop; } - var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var flags = 4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */); + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -63400,7 +63612,7 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 2944 /* Literal */) { + if (type.flags & 2944 /* TypeFlags.Literal */) { if (!type.freshType) { var freshType = createLiteralType(type.flags, type.value, type.symbol, type); freshType.freshType = freshType; @@ -63411,39 +63623,39 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 2944 /* Literal */ ? type.regularType : - type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : + return type.flags & 2944 /* TypeFlags.Literal */ ? type.regularType : + type.flags & 1048576 /* TypeFlags.Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + return !!(type.flags & 2944 /* TypeFlags.Literal */) && type.freshType === type; } function getStringLiteralType(value) { var type; return stringLiteralTypes.get(value) || - (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type); + (stringLiteralTypes.set(value, type = createLiteralType(128 /* TypeFlags.StringLiteral */, value)), type); } function getNumberLiteralType(value) { var type; return numberLiteralTypes.get(value) || - (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type); + (numberLiteralTypes.set(value, type = createLiteralType(256 /* TypeFlags.NumberLiteral */, value)), type); } function getBigIntLiteralType(value) { var type; var key = ts.pseudoBigIntToString(value); return bigIntLiteralTypes.get(key) || - (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type); + (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* TypeFlags.BigIntLiteral */, value)), type); } function getEnumLiteralType(value, enumId, symbol) { var type; var qualifier = typeof value === "string" ? "@" : "#"; var key = enumId + qualifier + value; - var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */); + var flags = 1024 /* TypeFlags.EnumLiteral */ | (typeof value === "string" ? 128 /* TypeFlags.StringLiteral */ : 256 /* TypeFlags.NumberLiteral */); return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type); } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 104 /* NullKeyword */) { + if (node.literal.kind === 104 /* SyntaxKind.NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -63453,9 +63665,9 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(8192 /* UniqueESSymbol */); + var type = createType(8192 /* TypeFlags.UniqueESSymbol */); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -63471,20 +63683,20 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) { if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } // inside x.prototype = { ... } - if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; } // /** @return {this} */ // x.prototype.m = function() { ... } - var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; - if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; } // inside constructor function C() { ... } @@ -63506,17 +63718,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 186 /* RestType */ || node.kind === 197 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 186 /* SyntaxKind.RestType */ || node.kind === 197 /* SyntaxKind.NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return node.elementType; } return undefined; @@ -63532,99 +63744,99 @@ var ts; } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return anyType; - case 155 /* UnknownKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return unknownType; - case 150 /* StringKeyword */: + case 150 /* SyntaxKind.StringKeyword */: return stringType; - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return numberType; - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return bigintType; - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return booleanType; - case 151 /* SymbolKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: return esSymbolType; - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return voidType; - case 153 /* UndefinedKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: return undefinedType; - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 143 /* NeverKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return neverType; - case 148 /* ObjectKeyword */: - return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 138 /* IntrinsicKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + return node.flags & 262144 /* NodeFlags.JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; + case 138 /* SyntaxKind.IntrinsicKeyword */: return intrinsicMarkerType; - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return getTypeFromLiteralTypeNode(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getTypeFromTypeReference(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return getTypeFromTypeQueryNode(node); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return getTypeFromOptionalTypeNode(node); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return getTypeFromUnionTypeNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 191 /* ParenthesizedType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: return getTypeFromRestTypeNode(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return getTypeFromMappedTypeNode(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return getTypeFromInferTypeNode(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -63662,9 +63874,9 @@ var ts; } function getMappedType(type, mapper) { switch (mapper.kind) { - case 0 /* Simple */: + case 0 /* TypeMapKind.Simple */: return type === mapper.source ? mapper.target : type; - case 1 /* Array */: + case 1 /* TypeMapKind.Array */: { var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -63673,25 +63885,39 @@ var ts; } } return type; - case 2 /* Function */: + } + case 2 /* TypeMapKind.Deferred */: { + var sources = mapper.sources; + var targets = mapper.targets; + for (var i = 0; i < sources.length; i++) { + if (type === sources[i]) { + return targets[i](); + } + } + return type; + } + case 3 /* TypeMapKind.Function */: return mapper.func(type); - case 3 /* Composite */: - case 4 /* Merged */: + case 4 /* TypeMapKind.Composite */: + case 5 /* TypeMapKind.Merged */: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 4 /* TypeMapKind.Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0 /* Simple */, source: source, target: target }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 0 /* TypeMapKind.Simple */, source: source, target: target }); } function makeArrayTypeMapper(sources, targets) { - return { kind: 1 /* Array */, sources: sources, targets: targets }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 1 /* TypeMapKind.Array */, sources: sources, targets: targets }); + } + function makeFunctionTypeMapper(func, debugInfo) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 3 /* TypeMapKind.Function */, func: func, debugInfo: ts.Debug.isDebugging ? debugInfo : undefined }); } - function makeFunctionTypeMapper(func) { - return { kind: 2 /* Function */, func: func }; + function makeDeferredTypeMapper(sources, targets) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 2 /* TypeMapKind.Deferred */, sources: sources, targets: targets }); } function makeCompositeTypeMapper(kind, mapper1, mapper2) { - return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: kind, mapper1: mapper1, mapper2: mapper2 }); } function createTypeEraser(sources) { return createTypeMapper(sources, /*targets*/ undefined); @@ -63701,19 +63927,20 @@ var ts; * This is used during inference when instantiating type parameter defaults. */ function createBackreferenceMapper(context, index) { - return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); + var forwardInferences = context.inferences.slice(index); + return createTypeMapper(ts.map(forwardInferences, function (i) { return i.typeParameter; }), ts.map(forwardInferences, function () { return unknownType; })); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4 /* TypeMapKind.Composite */, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -63746,7 +63973,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -63758,7 +63985,7 @@ var ts; // be affected by instantiation, simply return the symbol itself. return symbol; } - if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + if (ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) { // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -63767,7 +63994,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (8 /* Readonly */ | 4096 /* Late */ | 16384 /* OptionalParameter */ | 32768 /* RestParameter */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* CheckFlags.Instantiated */ | ts.getCheckFlags(symbol) & (8 /* CheckFlags.Readonly */ | 4096 /* CheckFlags.Late */ | 16384 /* CheckFlags.OptionalParameter */ | 32768 /* CheckFlags.RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -63781,12 +64008,12 @@ var ts; return result; } function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { - var declaration = type.objectFlags & 4 /* Reference */ ? type.node : - type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : + var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node : + type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); - var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : - type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType : + type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type; var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type @@ -63799,8 +64026,8 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; - typeParameters = (target.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -63821,8 +64048,8 @@ var ts; var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } @@ -63831,8 +64058,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.parent.kind === 178 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 200 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -63841,7 +64068,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 235 /* Block */ || n.kind === 189 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -63850,15 +64077,15 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return !!tp.isThisType; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return true; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return !node.type && !!node.body || ts.some(node.typeParameters, containsReference) || ts.some(node.parameters, containsReference) || @@ -63869,9 +64096,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { var typeVariable = getActualTypeVariable(constraintType.type); - if (typeVariable.flags & 262144 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeFlags.TypeParameter */) { return typeVariable; } } @@ -63893,10 +64120,10 @@ var ts; var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) { + if (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && t !== wildcardType && !isErrorType(t)) { if (!type.declaration.nameType) { var constraint = void 0; - if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && + if (isArrayType(t) || t.flags & 1 /* TypeFlags.Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } @@ -63917,7 +64144,7 @@ var ts; return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments); } function getModifiedReadonlyState(state, modifiers) { - return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state; + return modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? true : modifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */ ? false : state; } function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) { // When a tuple type is generic (i.e. when it contains variadic elements), we want to eagerly map the @@ -63926,14 +64153,14 @@ var ts; // normalization to resolve the non-generic parts of the resulting tuple. var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) { - var singleton = elementFlags[i] & 8 /* Variadic */ ? t : - elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : + var singleton = elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : + elementFlags[i] & 4 /* ElementFlags.Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]); // The singleton is never a generic tuple type, so it is safe to recurse here. return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper)); }); var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType)); - return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* Variadic */; }), newReadonly); + return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* ElementFlags.Variadic */; }), newReadonly); } function instantiateMappedArrayType(arrayType, mappedType, mapper) { var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper); @@ -63943,11 +64170,11 @@ var ts; function instantiateMappedTupleType(tupleType, mappedType, mapper) { var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { - return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); + return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* ElementFlags.Optional */), mapper); }); var modifiers = getMappedTypeModifiers(mappedType); - var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) : - modifiers & 8 /* ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var newTupleModifiers = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? 2 /* ElementFlags.Optional */ : f; }) : + modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : elementFlags; var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers); return ts.contains(elementTypes, errorType) ? errorType : @@ -63957,13 +64184,13 @@ var ts; var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + return strictNullChecks && modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + strictNullChecks && modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { - var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); - if (type.objectFlags & 32 /* Mapped */) { + var result = createObjectType(type.objectFlags | 64 /* ObjectFlags.Instantiated */, type.symbol); + if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { result.declaration = type.declaration; // C.f. instantiateSignature var origTypeParameter = getTypeParameterFromMappedType(type); @@ -63972,13 +64199,14 @@ var ts; mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper); freshTypeParameter.mapper = mapper; } - if (type.objectFlags & 8388608 /* InstantiationExpressionType */) { + if (type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */) { result.node = type.node; } result.target = type; result.mapper = mapper; result.aliasSymbol = aliasSymbol || type.aliasSymbol; result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0; return result; } function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { @@ -63997,7 +64225,7 @@ var ts; // Distributive conditional types are distributed over union types. For example, when the // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the // result is (A extends U ? X : Y) | (B extends U ? X : Y). - result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? + result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); @@ -64017,7 +64245,7 @@ var ts; // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } @@ -64030,62 +64258,62 @@ var ts; } function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; - if (flags & 262144 /* TypeParameter */) { + if (flags & 262144 /* TypeFlags.TypeParameter */) { return getMappedType(type, mapper); } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { var objectFlags = type.objectFlags; - if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !type.node) { + if (objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + if (objectFlags & 4 /* ObjectFlags.Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { return instantiateReverseMappedType(type, mapper); } return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } - if (flags & 3145728 /* UnionOrIntersection */) { - var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; - var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; + if (flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + var origin = type.flags & 1048576 /* TypeFlags.Union */ ? type.origin : undefined; + var types = origin && origin.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); if (newTypes === types && aliasSymbol === type.aliasSymbol) { return type; } var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); - return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? + return flags & 2097152 /* TypeFlags.Intersection */ || origin && origin.flags & 2097152 /* TypeFlags.Intersection */ ? getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : - getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); + getUnionType(newTypes, 1 /* UnionReduction.Literal */, newAliasSymbol, newAliasTypeArguments); } - if (flags & 4194304 /* Index */) { + if (flags & 4194304 /* TypeFlags.Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 134217728 /* TemplateLiteral */) { + if (flags & 134217728 /* TypeFlags.TemplateLiteral */) { return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper)); } - if (flags & 268435456 /* StringMapping */) { + if (flags & 268435456 /* TypeFlags.StringMapping */) { return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } - if (flags & 8388608 /* IndexedAccess */) { + if (flags & 8388608 /* TypeFlags.IndexedAccess */) { var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); } - if (flags & 16777216 /* Conditional */) { + if (flags & 16777216 /* TypeFlags.Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } - if (flags & 33554432 /* Substitution */) { + if (flags & 33554432 /* TypeFlags.Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); - if (maybeVariable.flags & 8650752 /* TypeVariable */) { + if (maybeVariable.flags & 8650752 /* TypeFlags.TypeVariable */) { return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper)); } else { var sub = instantiateType(type.substitute, mapper); - if (sub.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { + if (sub.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { return maybeVariable; } return sub; @@ -64095,11 +64323,11 @@ var ts; } function instantiateReverseMappedType(type, mapper) { var innerMappedType = instantiateType(type.mappedType, mapper); - if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + if (!(ts.getObjectFlags(innerMappedType) & 32 /* ObjectFlags.Mapped */)) { return type; } var innerIndexType = instantiateType(type.constraintType, mapper); - if (!(innerIndexType.flags & 4194304 /* Index */)) { + if (!(innerIndexType.flags & 4194304 /* TypeFlags.Index */)) { return type; } var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); @@ -64109,15 +64337,15 @@ var ts; return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable } function getUniqueLiteralFilledInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper)); } function getPermissiveInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); } function getRestrictiveInstantiation(type) { - if (type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */)) { + if (type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) { return type; } if (type.restrictiveInstantiation) { @@ -64138,35 +64366,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 221 /* BinaryExpression */: - return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && + case 221 /* SyntaxKind.BinaryExpression */: + return (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return isContextSensitive(node.initializer); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isContextSensitive(node.expression); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 285 /* JsxAttribute */: { + case 285 /* SyntaxKind.JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 288 /* JsxExpression */: { + case 288 /* SyntaxKind.JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -64180,17 +64408,17 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* SyntaxKind.Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { - var result = createObjectType(16 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* ObjectFlags.Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = ts.emptyArray; @@ -64199,7 +64427,7 @@ var ts; return result; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -64209,13 +64437,13 @@ var ts; return isTypeRelatedTo(source, target, identityRelation); } function compareTypesIdentical(source, target) { - return isTypeRelatedTo(source, target, identityRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, identityRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesAssignable(source, target) { - return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesSubtypeOf(source, target) { - return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); @@ -64232,11 +64460,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 1048576 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : - target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 1048576 /* TypeFlags.Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* TypeFlags.Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType)); } /** @@ -64274,7 +64502,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* TypeFlags.Conditional */ || (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { if (!node || isOrHasGenericConditional(target)) @@ -64284,35 +64512,35 @@ var ts; return true; } switch (node.kind) { - case 288 /* JsxExpression */: - case 212 /* ParenthesizedExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 27 /* CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; } function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { - var callSignatures = getSignaturesOfType(source, 0 /* Call */); - var constructSignatures = getSignaturesOfType(source, 1 /* Construct */); + var callSignatures = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructSignatures = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) { var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = errorOutputContainer || {}; checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj); @@ -64336,7 +64564,7 @@ var ts; if (!sourceSig) { return false; } - var targetSignatures = getSignaturesOfType(target, 0 /* Call */); + var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */); if (!ts.length(targetSignatures)) { return false; } @@ -64354,7 +64582,7 @@ var ts; if (target.symbol && ts.length(target.symbol.declarations)) { ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); } - if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0 + if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 // exclude cases where source itself is promisy - this way we don't make a suggestion when relating // an IPromise and a Promise that are slightly different && !getTypeOfPropertyOfType(sourceReturn, "then") @@ -64371,7 +64599,7 @@ var ts; if (idx) { return idx; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { var best = getBestMatchingType(source, target); if (best) { return getIndexedAccessTypeOrUndefined(best, nameType); @@ -64381,7 +64609,7 @@ var ts; function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) { next.contextualType = sourcePropType; try { - return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType); + return checkExpressionForMutableLocation(next, 1 /* CheckMode.Contextual */, sourcePropType); } finally { next.contextualType = undefined; @@ -64398,7 +64626,7 @@ var ts; for (var status = iterator.next(); !status.done; status = iterator.next()) { var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType); - if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) + if (!targetPropType || targetPropType.flags & 8388608 /* TypeFlags.IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); if (!sourcePropType) @@ -64418,8 +64646,8 @@ var ts; resultObj.errors = [diag]; } else { - var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); - var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); targetPropType = removeMissingType(targetPropType, targetIsOptional); sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); @@ -64443,7 +64671,7 @@ var ts; if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) { var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0]; if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) { - ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); } } } @@ -64509,18 +64737,18 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: if (child.containsOnlyTriviaWhiteSpaces) { break; // Whitespace only jsx text isn't real jsx text } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -64545,7 +64773,7 @@ var ts; var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); }); if (moreThanOneRealChildren) { if (arrayLikeTargetParts !== neverType) { - var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */)); + var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */)); var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic); result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result; } @@ -64627,7 +64855,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & (131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -64637,7 +64865,7 @@ var ts; var oldContext = node.contextualType; node.contextualType = target; try { - var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); + var tupleizedType = checkArrayLiteral(node, 1 /* CheckMode.Contextual */, /*forceTuple*/ true); node.contextualType = oldContext; if (isTupleLikeType(tupleizedType)) { return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); @@ -64662,17 +64890,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 131072 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* TypeFlags.Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 173 /* SetAccessor */: return [3 /*break*/, 2]; - case 172 /* GetAccessor */: return [3 /*break*/, 2]; - case 169 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 297 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 296 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 173 /* SyntaxKind.SetAccessor */: return [3 /*break*/, 2]; + case 172 /* SyntaxKind.GetAccessor */: return [3 /*break*/, 2]; + case 169 /* SyntaxKind.MethodDeclaration */: return [3 /*break*/, 2]; + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 296 /* SyntaxKind.PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -64694,7 +64922,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & (131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -64706,8 +64934,8 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* IgnoreReturnTypes */ : 0, /*reportErrors*/ false, - /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* False */; + return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* SignatureCheckMode.IgnoreReturnTypes */ : 0, /*reportErrors*/ false, + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* Ternary.False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -64723,16 +64951,16 @@ var ts; function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isAnySignature(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var targetCount = getParameterCount(target); var sourceHasMoreParameters = !hasEffectiveRestParameter(target) && - (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); + (checkMode & 8 /* SignatureCheckMode.StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); if (sourceHasMoreParameters) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); @@ -64744,10 +64972,10 @@ var ts; if (sourceRestType || targetRestType) { void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers); } - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 169 /* MethodDeclaration */ && - kind !== 168 /* MethodSignature */ && kind !== 171 /* Constructor */; - var result = -1 /* True */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + var strictVariance = !(checkMode & 3 /* SignatureCheckMode.Callback */) && strictFunctionTypes && kind !== 169 /* SyntaxKind.MethodDeclaration */ && + kind !== 168 /* SyntaxKind.MethodSignature */ && kind !== 171 /* SyntaxKind.Constructor */; + var result = -1 /* Ternary.True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { var targetThisType = getThisTypeOfSignature(target); @@ -64759,7 +64987,7 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64778,27 +65006,27 @@ var ts; // similar to return values, callback parameters are output positions. This means that a Promise, // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) // with respect to T. - var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); - var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); + var sourceSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getTypeFacts(sourceType) & 50331648 /* IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* IsUndefinedOrNull */); + (getTypeFacts(sourceType) & 50331648 /* TypeFacts.IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* TypeFacts.IsUndefinedOrNull */); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : - !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* SignatureCheckMode.StrictArity */) | (strictVariance ? 2 /* SignatureCheckMode.StrictCallback */ : 1 /* SignatureCheckMode.BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : + !(checkMode & 3 /* SignatureCheckMode.Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { - related = 0 /* False */; + if (related && checkMode & 8 /* SignatureCheckMode.StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + related = 0 /* Ternary.False */; } if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } } - if (!(checkMode & 4 /* IgnoreReturnTypes */)) { + if (!(checkMode & 4 /* SignatureCheckMode.IgnoreReturnTypes */)) { // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType @@ -64821,14 +65049,14 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } else { // When relating callback signatures, we still need to relate return types bi-variantly as otherwise // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } // wouldn't be co-variant for T without this rule. - result &= checkMode & 1 /* BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + result &= checkMode & 1 /* SignatureCheckMode.BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); if (!result && reportErrors && incompatibleErrorReporter) { incompatibleErrorReporter(sourceReturnType, targetReturnType); @@ -64843,21 +65071,21 @@ var ts; errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { + if (source.kind === 1 /* TypePredicateKind.Identifier */ || source.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var related = source.type === target.type ? -1 /* True */ : + var related = source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; - if (related === 0 /* False */ && reportErrors) { + 0 /* Ternary.False */; + if (related === 0 /* Ternary.False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return related; @@ -64883,33 +65111,33 @@ var ts; t.indexInfos.length === 0; } function isEmptyObjectType(type) { - return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 67108864 /* NonPrimitive */ ? true : - type.flags & 1048576 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* TypeFlags.Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 67108864 /* TypeFlags.NonPrimitive */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isEmptyObjectType) : false; } function isEmptyAnonymousObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) || - type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && (type.members && isEmptyResolvedType(type) || + type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); } function isUnknownLikeUnionType(type) { - if (strictNullChecks && type.flags & 1048576 /* Union */) { - if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) { + if (strictNullChecks && type.flags & 1048576 /* TypeFlags.Union */) { + if (!(type.objectFlags & 33554432 /* ObjectFlags.IsUnknownLikeUnionComputed */)) { var types = type.types; - type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ && - types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0); + type.objectFlags |= 33554432 /* ObjectFlags.IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* TypeFlags.Undefined */ && + types[1].flags & 65536 /* TypeFlags.Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* ObjectFlags.IsUnknownLikeUnion */ : 0); } - return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */); + return !!(type.objectFlags & 67108864 /* ObjectFlags.IsUnknownLikeUnion */); } return false; } function containsUndefinedType(type) { - return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */); + return !!((type.flags & 1048576 /* TypeFlags.Union */ ? type.types[0] : type).flags & 32768 /* TypeFlags.Undefined */); } function isStringIndexSignatureOnlyType(type) { - return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || - type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || + return type.flags & 524288 /* TypeFlags.Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -64918,83 +65146,83 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var entry = enumRelation.get(id); - if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { - return !!(entry & 1 /* Succeeded */); + if (entry !== undefined && !(!(entry & 4 /* RelationComparisonResult.Reported */) && entry & 2 /* RelationComparisonResult.Failed */ && errorReporter)) { + return !!(entry & 1 /* RelationComparisonResult.Succeeded */); } - if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* SymbolFlags.RegularEnum */) || !(targetSymbol.flags & 256 /* SymbolFlags.RegularEnum */)) { + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) { var property = _a[_i]; - if (property.flags & 8 /* EnumMember */) { + if (property.flags & 8 /* SymbolFlags.EnumMember */) { var targetProperty = getPropertyOfType(targetEnumType, property.escapedName); - if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { + if (!targetProperty || !(targetProperty.flags & 8 /* SymbolFlags.EnumMember */)) { if (errorReporter) { - errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */)); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); } else { - enumRelation.set(id, 2 /* Failed */); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */); } return false; } } } - enumRelation.set(id, 1 /* Succeeded */); + enumRelation.set(id, 1 /* RelationComparisonResult.Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) + if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType) return true; - if (t & 131072 /* Never */) + if (t & 131072 /* TypeFlags.Never */) return false; - if (s & 402653316 /* StringLike */ && t & 4 /* String */) + if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */) return true; - if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && - t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 296 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */) return true; - if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && - t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) + if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */) return true; - if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */) return true; - if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) + if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */) return true; - if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { - if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) { + if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && + if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`. // Since unions and intersections may reduce to `never`, we exclude them here. - if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) + if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */))) return true; - if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) + if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */)) return true; - if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */))) + if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */))) return true; if (relation === assignableRelation || relation === comparableRelation) { - if (s & 1 /* Any */) + if (s & 1 /* TypeFlags.Any */) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any // numeric enum literal type. This rule exists for backwards compatibility reasons because // bit-flag enum types sometimes look like literal enum types with numeric literal values. - if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */)) return true; // Anything is assignable to a union containing undefined, null, and {} if (isUnknownLikeUnionType(target)) @@ -65013,38 +65241,38 @@ var ts; return true; } if (relation !== identityRelation) { - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { return true; } } - else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) { + else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) { // We have excluded types that may simplify to other forms, so types must have identical flags if (source.flags !== target.flags) return false; - if (source.flags & 67358815 /* Singleton */) + if (source.flags & 67358815 /* TypeFlags.Singleton */) return true; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false)); + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { + var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false)); if (related !== undefined) { - return !!(related & 1 /* Succeeded */); + return !!(related & 1 /* RelationComparisonResult.Succeeded */); } } - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { var t = isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type : - type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) : - type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : - type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : + ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type : + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? writing ? type.baseType : type.substitute : + type.flags & 25165824 /* TypeFlags.Simplifiable */ ? getSimplifiedType(type, writing) : type; if (t === type) return t; @@ -65056,7 +65284,7 @@ var ts; if (reduced !== type) { return reduced; } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); }); if (normalizedTypes !== type.types) { return getIntersectionType(normalizedTypes); @@ -65084,19 +65312,19 @@ var ts; var maybeCount = 0; var sourceDepth = 0; var targetDepth = 0; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; var overflow = false; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid var lastSkippedInfo; var incompatibleStack; var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage); + var result = isRelatedTo(source, target, 3 /* RecursionFlags.Both */, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack) { reportIncompatibleStack(); } if (overflow) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -65134,10 +65362,10 @@ var ts; diagnostics.add(diag); } } - if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) { + if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* Ternary.False */) { ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } - return result !== 0 /* False */; + return result !== 0 /* Ternary.False */; function resetErrorInfo(saved) { errorInfo = saved.errorInfo; lastSkippedInfo = saved.lastSkippedInfo; @@ -65182,24 +65410,24 @@ var ts; case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { // Parenthesize a `new` if there is one if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; // If leading, just print back the arg (irrespective of if it's a valid identifier) if (path.length === 0) { - path = "" + str; + path = "".concat(str); } // Otherwise write a dotted name if possible else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } // Failing that, check if the name is already a computed name else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } // And finally write out a computed name as a last resort else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -65228,7 +65456,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -65241,7 +65469,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -65293,7 +65521,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 /* TypeFlags.TypeParameter */ && target !== markerSuperTypeForCheck && target !== markerSubTypeForCheck) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -65315,7 +65543,7 @@ var ts; message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; } else { - if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */ && target.flags & 1048576 /* TypeFlags.Union */) { var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target); if (suggestedType) { reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType)); @@ -65377,7 +65605,7 @@ var ts; return true; } function isRelatedToWorker(source, target, reportErrors) { - return isRelatedTo(source, target, 3 /* Both */, reportErrors); + return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors); } /** * Compare two types and return @@ -65386,19 +65614,19 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) { - if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; } + if (recursionFlags === void 0) { recursionFlags = 3 /* RecursionFlags.Both */; } if (reportErrors === void 0) { reportErrors = false; } - if (intersectionState === void 0) { intersectionState = 0 /* None */; } + if (intersectionState === void 0) { intersectionState = 0 /* IntersectionState.None */; } // Before normalization: if `source` is type an object type, and `target` is primitive, // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result - if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) { + if (originalSource.flags & 524288 /* TypeFlags.Object */ && originalTarget.flags & 131068 /* TypeFlags.Primitive */) { if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (reportErrors) { reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and @@ -65407,73 +65635,73 @@ var ts; var source = getNormalizedType(originalSource, /*writing*/ false); var target = getNormalizedType(originalTarget, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; if (relation === identityRelation) { if (source.flags !== target.flags) - return 0 /* False */; - if (source.flags & 67358815 /* Singleton */) - return -1 /* True */; + return 0 /* Ternary.False */; + if (source.flags & 67358815 /* TypeFlags.Singleton */) + return -1 /* Ternary.True */; traceUnionsOrIntersectionsTooLarge(source, target); - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* IntersectionState.None */, recursionFlags); } // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, // as we break down the _target_ union first, _then_ get the source constraint - so for every // member of the target, we attempt to find a match in the source. This avoids that in cases where // the target is exactly the constraint. - if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) { - return -1 /* True */; + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && getConstraintOfType(source) === target) { + return -1 /* Ternary.True */; } // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined // plus a single non-nullable type. If so, remove null and/or undefined from the target type. - if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) { + if (source.flags & 470302716 /* TypeFlags.DefinitelyNonNullable */ && target.flags & 1048576 /* TypeFlags.Union */) { var types = target.types; - var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : - types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : + var candidate = types.length === 2 && types[0].flags & 98304 /* TypeFlags.Nullable */ ? types[1] : + types.length === 3 && types[0].flags & 98304 /* TypeFlags.Nullable */ && types[1].flags & 98304 /* TypeFlags.Nullable */ ? types[2] : undefined; - if (candidate && !(candidate.flags & 98304 /* Nullable */)) { + if (candidate && !(candidate.flags & 98304 /* TypeFlags.Nullable */)) { target = getNormalizedType(candidate, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) - return -1 /* True */; - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* FreshLiteral */); + return -1 /* Ternary.True */; + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* IntersectionState.Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) && - source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && - target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* IntersectionState.Target */) && + source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType && + target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source); var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target); - var calls = getSignaturesOfType(source, 0 /* Call */); - var constructs = getSignaturesOfType(source, 1 /* Construct */); - if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) || - constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) { + var calls = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructs = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString); } else { reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString); } } - return 0 /* False */; + return 0 /* Ternary.False */; } traceUnionsOrIntersectionsTooLarge(source, target); - var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) || - target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */); + var skipCaching = source.flags & 1048576 /* TypeFlags.Union */ && source.types.length < 4 && !(target.flags & 1048576 /* TypeFlags.Union */) || + target.flags & 1048576 /* TypeFlags.Union */ && target.types.length < 4 && !(source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */); var result_7 = skipCaching ? unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) : recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags); @@ -65492,10 +65720,10 @@ 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_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) { + if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) { inPropertyCheck = true; - result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags); + result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags); inPropertyCheck = false; } if (result_7) { @@ -65505,7 +65733,7 @@ var ts; if (reportErrors) { reportErrorResults(originalSource, originalTarget, source, target, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { var _a, _b; @@ -65517,20 +65745,20 @@ var ts; if (maybeSuppress) { overrideNextErrorInfo--; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true); if (errorInfo !== currentError) { maybeSuppress = !!errorInfo; } } - if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 131068 /* TypeFlags.Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* TypeFlags.Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } - else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) { + else if (ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && target.flags & 2097152 /* TypeFlags.Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -65549,7 +65777,7 @@ var ts; return; } reportRelationError(headMessage, source, target); - if (source.flags & 262144 /* TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) { + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) { var syntheticParam = cloneTypeParameter(source); syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam)); if (hasNonCircularBaseConstraint(syntheticParam)) { @@ -65562,17 +65790,17 @@ var ts; if (!ts.tracing) { return; } - if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { + if ((source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) && (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* ObjectFlags.PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } var sourceSize = sourceUnionOrIntersection.types.length; var targetSize = targetUnionOrIntersection.types.length; if (sourceSize * targetSize > 1E6) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { + ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { sourceId: source.id, sourceSize: sourceSize, targetId: target.id, @@ -65587,7 +65815,7 @@ var ts; var appendPropType = function (propTypes, type) { var _a; type = getApparentType(type); - var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); + var prop = type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType; return ts.append(propTypes, propType); }; @@ -65595,21 +65823,21 @@ var ts; } function hasExcessProperties(source, target, reportErrors) { var _a; - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* JSLiteral */) { + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* ObjectFlags.JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; } var reducedTarget = target; var checkTypes; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); - checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; + checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget]; } - var _loop_19 = function (prop) { + var _loop_20 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { @@ -65662,7 +65890,7 @@ var ts; } return { value: true }; } - if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) { + if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* RecursionFlags.Both */, reportErrors)) { if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop)); } @@ -65672,7 +65900,7 @@ var ts; }; for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { var prop = _b[_i]; - var state_6 = _loop_19(prop); + var state_6 = _loop_20(prop); if (typeof state_6 === "object") return state_6.value; } @@ -65685,28 +65913,28 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState); } - if (target.flags & 1048576 /* Union */) { - return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); + if (target.flags & 1048576 /* TypeFlags.Union */) { + return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */) && !(target.flags & 131068 /* TypeFlags.Primitive */)); } - if (target.flags & 2097152 /* Intersection */) { - return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */); + if (target.flags & 2097152 /* TypeFlags.Intersection */) { + return typeRelatedToEachType(source, target, reportErrors, 2 /* IntersectionState.Target */); } // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the // constraints of all non-primitive types in the source into a new intersection. We do this because the // intersection may further constrain the constraints of the non-primitive types. For example, given a type // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't // appear to be comparable to '2'. - if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { + if (relation === comparableRelation && target.flags & 131068 /* TypeFlags.Primitive */) { var constraints = ts.sameMap(source.types, getBaseConstraintOrType); if (constraints !== source.types) { source = getIntersectionType(constraints); - if (!(source.flags & 2097152 /* Intersection */)) { - return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false); + if (!(source.flags & 2097152 /* TypeFlags.Intersection */)) { + return isRelatedTo(source, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false); } } } @@ -65714,16 +65942,16 @@ var ts; // Don't report errors though. Elaborating on whether a source constituent is related to the target is // not actually useful and leads to some confusing error messages. Instead, we rely on the caller // checking whether the full intersection viewed as an object is related to the target. - return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */); + return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* IntersectionState.Source */); } function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65731,13 +65959,13 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { if (containsType(targetTypes, source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var match = getMatchingUnionConstituentForType(target, source); if (match) { - var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65745,7 +65973,7 @@ var ts; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; - var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65754,19 +65982,19 @@ var ts; // Elaborate only if we can find a best matching type in the target union var bestMatchingType = getBestMatchingType(source, target, isRelatedTo); if (bestMatchingType) { - isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true); + isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true); } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToEachType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var targetTypes = target.types; for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { var targetType = targetTypes_2[_i]; - var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(source, targetType, 2 /* RecursionFlags.Target */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65774,50 +66002,50 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors, intersectionState) { var sourceTypes = source.types; - if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { - return -1 /* True */; + if (source.flags & 1048576 /* TypeFlags.Union */ && containsType(sourceTypes, target)) { + return -1 /* Ternary.True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceTypes[i], target, 1 /* RecursionFlags.Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); if (related) { return related; } } - return 0 /* False */; + return 0 /* Ternary.False */; } function getUndefinedStrippedTargetIfNeeded(source, target) { // As a builtin type, `undefined` is a very low type ID - making it almsot always first, making this a very fast check to see // if we need to strip `undefined` from the target - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && - !(source.types[0].flags & 32768 /* Undefined */) && target.types[0].flags & 32768 /* Undefined */) { - return extractTypesOfKind(target, ~32768 /* Undefined */); + if (source.flags & 1048576 /* TypeFlags.Union */ && target.flags & 1048576 /* TypeFlags.Union */ && + !(source.types[0].flags & 32768 /* TypeFlags.Undefined */) && target.types[0].flags & 32768 /* TypeFlags.Undefined */) { + return extractTypesOfKind(target, ~32768 /* TypeFlags.Undefined */); } return target; } function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; // We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath // since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target); for (var i = 0; i < sourceTypes.length; i++) { var sourceType = sourceTypes[i]; - if (undefinedStrippedTarget.flags & 1048576 /* Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { + if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison // such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union - var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); if (related_1) { result &= related_1; continue; } } - var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65828,54 +66056,54 @@ var ts; if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; + return 0 /* Ternary.False */; } var length = sources.length <= targets.length ? sources.length : targets.length; - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < length; i++) { // When variance information isn't available we default to covariance. This happens // in the process of computing variance information for recursive types and when // comparing 'this' type arguments. - var varianceFlags = i < variances.length ? variances[i] : 1 /* Covariant */; - var variance = varianceFlags & 7 /* VarianceMask */; + var varianceFlags = i < variances.length ? variances[i] : 1 /* VarianceFlags.Covariant */; + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; // We ignore arguments for independent type parameters (because they're never witnessed). - if (variance !== 4 /* Independent */) { + if (variance !== 4 /* VarianceFlags.Independent */) { var s = sources[i]; var t = targets[i]; - var related = -1 /* True */; - if (varianceFlags & 8 /* Unmeasurable */) { + var related = -1 /* Ternary.True */; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_. // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be) - related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); + related = relation === identityRelation ? isRelatedTo(s, t, 3 /* RecursionFlags.Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); } - else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 1 /* VarianceFlags.Covariant */) { + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 2 /* VarianceFlags.Contravariant */) { + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 3 /* Bivariant */) { + else if (variance === 3 /* VarianceFlags.Bivariant */) { // In the bivariant case we first compare contravariantly without reporting // errors. Then, if that doesn't succeed, we compare covariantly with error // reporting. Thus, error elaboration will be based on the the covariant check, // which is generally easier to reason about. - related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false); + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (related) { - related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related &= isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65889,28 +66117,28 @@ var ts; // and issue an error. Otherwise, actually compare the structure of the two types. function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) { if (overflow) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0); + var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0); var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false); var entry = relation.get(id); if (entry !== undefined) { - if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { + if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - var saved = entry & 24 /* ReportsMask */; - if (saved & 8 /* ReportsUnmeasurable */) { - instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); + var saved = entry & 24 /* RelationComparisonResult.ReportsMask */; + if (saved & 8 /* RelationComparisonResult.ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMapper); } - if (saved & 16 /* ReportsUnreliable */) { - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + if (saved & 16 /* RelationComparisonResult.ReportsUnreliable */) { + instantiateType(source, reportUnreliableMapper); } } - return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* RelationComparisonResult.Succeeded */ ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } } if (!maybeKeys) { @@ -65926,42 +66154,42 @@ var ts; for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) { - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } } if (sourceDepth === 100 || targetDepth === 100) { overflow = true; - return 0 /* False */; + return 0 /* Ternary.False */; } } var maybeStart = maybeCount; maybeKeys[maybeCount] = id; maybeCount++; var saveExpandingFlags = expandingFlags; - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceStack[sourceDepth] = source; sourceDepth++; - if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) - expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 1 /* ExpandingFlags.Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) + expandingFlags |= 1 /* ExpandingFlags.Source */; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetStack[targetDepth] = target; targetDepth++; - if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) - expandingFlags |= 2 /* Target */; + if (!(expandingFlags & 2 /* ExpandingFlags.Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) + expandingFlags |= 2 /* ExpandingFlags.Target */; } var originalHandler; var propagatingVarianceFlags = 0; if (outofbandVarianceMarkerHandler) { originalHandler = outofbandVarianceMarkerHandler; outofbandVarianceMarkerHandler = function (onlyUnreliable) { - propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + propagatingVarianceFlags |= onlyUnreliable ? 16 /* RelationComparisonResult.ReportsUnreliable */ : 8 /* RelationComparisonResult.ReportsUnmeasurable */; return originalHandler(onlyUnreliable); }; } var result; - if (expandingFlags === 3 /* Both */) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + if (expandingFlags === 3 /* ExpandingFlags.Both */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -65969,30 +66197,30 @@ var ts; depth: sourceDepth, targetDepth: targetDepth }); - result = 3 /* Maybe */; + result = 3 /* Ternary.Maybe */; } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceDepth--; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetDepth--; } expandingFlags = saveExpandingFlags; if (result) { - if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) { - if (result === -1 /* True */ || result === 3 /* Maybe */) { + if (result === -1 /* Ternary.True */ || (sourceDepth === 0 && targetDepth === 0)) { + if (result === -1 /* Ternary.True */ || result === 3 /* Ternary.Maybe */) { // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + relation.set(maybeKeys[i], 1 /* RelationComparisonResult.Succeeded */ | propagatingVarianceFlags); } } maybeCount = maybeStart; @@ -66001,46 +66229,73 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); + relation.set(id, (reportErrors ? 4 /* RelationComparisonResult.Reported */ : 0) | 2 /* RelationComparisonResult.Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - if (intersectionState & 4 /* PropertyCheck */) { - return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); + var saveErrorInfo = captureErrorCalculationState(); + var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo); + if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) { + // The combined constraint of an intersection type is the intersection of the constraints of + // the constituents. When an intersection type contains instantiable types with union type + // constraints, there are situations where we need to examine the combined constraint. One is + // when the target is a union type. Another is when the intersection contains types belonging + // to one of the disjoint domains. For example, given type variables T and U, each with the + // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and + // we need to check this constraint against a union on the target side. Also, given a type + // variable V constrained to 'string | number', 'V & number' has a combined constraint of + // 'string & number | number & number' which reduces to just 'number'. + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */)); + if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + } + } + if (result) { + resetErrorInfo(saveErrorInfo); + } + return result; + } + function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) { + if (intersectionState & 4 /* IntersectionState.PropertyCheck */) { + return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */); } var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = captureErrorCalculationState(); var sourceFlags = source.flags; var targetFlags = target.flags; if (relation === identityRelation) { // We've already checked that source.flags and target.flags are identical - if (sourceFlags & 3145728 /* UnionOrIntersection */) { + if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { var result_8 = eachTypeRelatedToSomeType(source, target); if (result_8) { result_8 &= eachTypeRelatedToSomeType(target, source); } return result_8; } - if (sourceFlags & 4194304 /* Index */) { - return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (sourceFlags & 8388608 /* IndexedAccess */) { - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } } - if (sourceFlags & 16777216 /* Conditional */) { + if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { + if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } @@ -66048,60 +66303,37 @@ var ts; } } } - if (sourceFlags & 33554432 /* Substitution */) { - return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 33554432 /* TypeFlags.Substitution */) { + return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (!(sourceFlags & 524288 /* Object */)) { - return 0 /* False */; + if (!(sourceFlags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } } - else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) { + else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) { - // The combined constraint of an intersection type is the intersection of the constraints of - // the constituents. When an intersection type contains instantiable types with union type - // constraints, there are situations where we need to examine the combined constraint. One is - // when the target is a union type. Another is when the intersection contains types belonging - // to one of the disjoint domains. For example, given type variables T and U, each with the - // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and - // we need to check this constraint against a union on the target side. Also, given a type - // variable V constrained to 'string | number', 'V & number' has a combined constraint of - // 'string & number | number & number' which reduces to just 'number'. - // This also handles type parameters, as a type parameter with a union constraint compared against a union - // needs to have its constraint hoisted into an intersection with said type parameter, this way - // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) - // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); - if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself - // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); - return result; - } - } - } // The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle: // Source is instantiable (e.g. source has union or intersection constraint). // Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }). // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }). - if (!(sourceFlags & 465829888 /* Instantiable */ || - sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ || - sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) { - return 0 /* False */; + if (!(sourceFlags & 465829888 /* TypeFlags.Instantiable */ || + sourceFlags & 524288 /* TypeFlags.Object */ && targetFlags & 1048576 /* TypeFlags.Union */ || + sourceFlags & 2097152 /* TypeFlags.Intersection */ && targetFlags & (524288 /* TypeFlags.Object */ | 1048576 /* TypeFlags.Union */ | 465829888 /* TypeFlags.Instantiable */))) { + return 0 /* Ternary.False */; } } // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. - if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && source.aliasTypeArguments && + if (sourceFlags & (524288 /* TypeFlags.Object */ | 16777216 /* TypeFlags.Conditional */) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) { var variances = getAliasVariances(source.aliasSymbol); if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState); if (varianceResult !== undefined) { @@ -66110,48 +66342,48 @@ var ts; } // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T], // and U is assignable to [...T] when U is constrained to a mutable array or tuple type. - if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) || - isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) { + if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* RecursionFlags.Source */)) || + isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* RecursionFlags.Target */))) { return result; } - if (targetFlags & 262144 /* TypeParameter */) { + if (targetFlags & 262144 /* TypeFlags.TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) { - if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { + if (ts.getObjectFlags(source) & 32 /* ObjectFlags.Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* RecursionFlags.Both */)) { + if (!(getMappedTypeModifiers(source) & 4 /* MappedTypeModifiers.IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(templateType, indexedAccessType, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } } - if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) { + if (relation === comparableRelation && sourceFlags & 262144 /* TypeFlags.TypeParameter */) { // This is a carve-out in comparability to essentially forbid comparing a type parameter // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!) var constraint = getConstraintOfTypeParameter(source); if (constraint && hasNonCircularBaseConstraint(source)) { - while (constraint && constraint.flags & 262144 /* TypeParameter */) { - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) { + while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) { + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { return result; } constraint = getConstraintOfTypeParameter(constraint); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetFlags & 4194304 /* Index */) { + else if (targetFlags & 4194304 /* TypeFlags.Index */) { var targetType_1 = target.type; // A keyof S is related to a keyof T if T is related to S. - if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(targetType_1, source.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } if (isTupleType(targetType_1)) { // An index type can have a tuple type target when the tuple type contains variadic elements. // Check if the source is related to the known keys of the tuple type. - if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -66164,8 +66396,8 @@ var ts; // false positives. For example, given 'T extends { [K in keyof T]: string }', // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when // related to other types. - if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } else if (isGenericMappedType(targetType_1)) { @@ -66180,7 +66412,7 @@ var ts; // missing from the `constraintType` which will otherwise be mapped in the object var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1)); var mappedKeys_1 = []; - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); }); // We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side) targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false)); @@ -66188,21 +66420,20 @@ var ts; else { targetKeys = nameType_1 || constraintType; } - if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, targetKeys, 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } } } - else if (targetFlags & 8388608 /* IndexedAccess */) { - if (sourceFlags & 8388608 /* IndexedAccess */) { + else if (targetFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { // Relate components directly before falling back to constraint relationships // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors); + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } if (reportErrors) { @@ -66217,14 +66448,14 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0); + var accessFlags = 4 /* AccessFlags.Writing */ | (baseObjectType !== objectType ? 2 /* AccessFlags.NoIndexSignatures */ : 0); var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); if (constraint) { if (reportErrors && originalErrorInfo) { // create a new chain for the constraint error resetErrorInfo(saveErrorInfo); } - if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, constraint, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain @@ -66243,12 +66474,12 @@ var ts; var keysRemapped = !!target.declaration.nameType; var templateType = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); - if (!(modifiers & 8 /* ExcludeOptional */)) { + if (!(modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */)) { // If the mapped type has shape `{ [P in Q]: T[P] }`, // source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`. - if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source && + if (!keysRemapped && templateType.flags & 8388608 /* TypeFlags.IndexedAccess */ && templateType.objectType === source && templateType.indexType === getTypeParameterFromMappedType(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!isGenericMappedType(source)) { // If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`. @@ -66256,22 +66487,22 @@ var ts; var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target); // Type of the keys of source type `S`, i.e. `keyof S`. var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true); - var includeOptional = modifiers & 4 /* IncludeOptional */; + var includeOptional = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */; var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined; // A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T. // A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`. if (includeOptional - ? !(filteredByApplicability.flags & 131072 /* Never */) - : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) { + ? !(filteredByApplicability.flags & 131072 /* TypeFlags.Never */) + : isRelatedTo(targetKeys, sourceKeys, 3 /* RecursionFlags.Both */)) { var templateType_1 = getTemplateTypeFromMappedType(target); var typeParameter = getTypeParameterFromMappedType(target); // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj` // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`. - var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */); - if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { - if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) { + var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* TypeFlags.Nullable */); + if (!keysRemapped && nonNullComponent.flags & 8388608 /* TypeFlags.IndexedAccess */ && nonNullComponent.indexType === typeParameter) { + if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -66291,7 +66522,7 @@ var ts; : typeParameter; var indexedAccessType = getIndexedAccessType(source, indexingType); // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type. - if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } @@ -66301,12 +66532,11 @@ var ts; } } } - else if (targetFlags & 16777216 /* Conditional */) { + else if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { - resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } var c = target; // We check for a relationship to a conditional type target only when the conditional type has no @@ -66317,47 +66547,44 @@ var ts; var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType)); // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) - if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) { - result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false); + if (result = skipTrue ? -1 /* Ternary.True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false)) { + result &= skipFalse ? -1 /* Ternary.True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (result) { - resetErrorInfo(saveErrorInfo); return result; } } } } - else if (targetFlags & 134217728 /* TemplateLiteral */) { - if (sourceFlags & 134217728 /* TemplateLiteral */) { + else if (targetFlags & 134217728 /* TypeFlags.TemplateLiteral */) { + if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */) { if (relation === comparableRelation) { - return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */; + return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* Ternary.False */ : -1 /* Ternary.True */; } // Report unreliable variance for type variables referenced in template literal type placeholders. // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + instantiateType(source, reportUnreliableMapper); } if (isTypeMatchedByTemplateLiteralType(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } - else if (target.flags & 268435456 /* StringMapping */) { - if (!(source.flags & 268435456 /* StringMapping */)) { + else if (target.flags & 268435456 /* TypeFlags.StringMapping */) { + if (!(source.flags & 268435456 /* TypeFlags.StringMapping */)) { if (isMemberOfStringMapping(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } } - if (sourceFlags & 8650752 /* TypeVariable */) { + if (sourceFlags & 8650752 /* TypeFlags.TypeVariable */) { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch - if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) { + if (!(sourceFlags & 8388608 /* TypeFlags.IndexedAccess */ && targetFlags & 8388608 /* TypeFlags.IndexedAccess */)) { var constraint = getConstraintOfType(source) || unknownType; // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* RecursionFlags.Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeFlags.TypeParameter */), /*headMessage*/ undefined, intersectionState)) { return result; } if (isMappedTypeGenericIndexedAccess(source)) { @@ -66365,55 +66592,49 @@ var ts; // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X. var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { - if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } } } } - else if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + else if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(keyofConstraintType, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } - else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) { - if (!(targetFlags & 134217728 /* TemplateLiteral */)) { + else if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */ && !(targetFlags & 524288 /* TypeFlags.Object */)) { + if (!(targetFlags & 134217728 /* TypeFlags.TemplateLiteral */)) { var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { - resetErrorInfo(saveErrorInfo); + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { return result; } } } - else if (sourceFlags & 268435456 /* StringMapping */) { - if (targetFlags & 268435456 /* StringMapping */) { + else if (sourceFlags & 268435456 /* TypeFlags.StringMapping */) { + if (targetFlags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol !== target.symbol) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } else { var constraint = getBaseConstraintOfType(source); - if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { - resetErrorInfo(saveErrorInfo); + if (constraint && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { return result; } } } - else if (sourceFlags & 16777216 /* Conditional */) { + else if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { - resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } - if (targetFlags & 16777216 /* Conditional */) { + if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -66422,18 +66643,17 @@ var ts; var mapper = void 0; if (sourceParams) { // If the source has infer type parameters, we instantiate them in the context of the target - var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* InferenceFlags.None */, isRelatedToWorker); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } if (isTypeIdenticalTo(sourceExtends, target.extendsType) && - (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) { - if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors); + (isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* RecursionFlags.Both */))) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -66443,8 +66663,7 @@ var ts; // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { - if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(distributiveConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } @@ -66453,8 +66672,7 @@ var ts; // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!). var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(defaultConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } @@ -66462,31 +66680,30 @@ var ts; else { // An empty object type is related to any mapped type that includes a '?' modifier. if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } - return 0 /* False */; + return 0 /* Ternary.False */; } - var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */); + var sourceIsPrimitive = !!(sourceFlags & 131068 /* TypeFlags.Primitive */); if (relation !== identityRelation) { source = getApparentType(source); sourceFlags = source.flags; } else if (isGenericMappedType(source)) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && source.target === target.target && !isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) { // When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType, // and an empty array literal wouldn't be assignable to a `never[]` without this check. if (isEmptyArrayLiteralType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance @@ -66496,7 +66713,7 @@ var ts; // effectively means we measure variance only from type parameter occurrences that aren't nested in // recursive instantiations of the generic type. if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState); if (varianceResult !== undefined) { @@ -66505,32 +66722,32 @@ var ts; } else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { - return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* RecursionFlags.Both */, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple // or `target` is an array and source is a tuple - in both cases the types cannot be identical, by construction - return 0 /* False */; + return 0 /* Ternary.False */; } } // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` // and not `{} <- fresh({}) <- {[idx: string]: any}` - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source)) { - return 0 /* False */; + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* ObjectFlags.FreshLiteral */ && !isEmptyObjectType(source)) { + return 0 /* Ternary.False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 524288 /* TypeFlags.Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState); if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 0 /* SignatureKind.Call */, reportStructuralErrors); if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 1 /* SignatureKind.Construct */, reportStructuralErrors); if (result) { result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState); } @@ -66547,9 +66764,9 @@ var ts; // there exists a constituent of T for every combination of the discriminants of S // with respect to T. We do not report errors here, as we will use the existing // error result from checking each constituent of the union. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) { - var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); - if (objectOnlyTarget.flags & 1048576 /* Union */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 1048576 /* TypeFlags.Union */) { + var objectOnlyTarget = extractTypesOfKind(target, 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 33554432 /* TypeFlags.Substitution */); + if (objectOnlyTarget.flags & 1048576 /* TypeFlags.Union */) { var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); if (result_9) { return result_9; @@ -66557,7 +66774,7 @@ var ts; } } } - return 0 /* False */; + return 0 /* Ternary.False */; function countMessageChainBreadth(info) { if (!info) return 0; @@ -66567,7 +66784,7 @@ var ts; if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; } - if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { + if (ts.some(variances, function (v) { return !!(v & 24 /* VarianceFlags.AllowsStructuralFallback */); })) { // If some type parameter was `Unmeasurable` or `Unreliable`, and we couldn't pass by assuming it was identical, then we // have to allow a structural fallback check // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially @@ -66594,8 +66811,8 @@ var ts; // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceMask */) === 0 /* Invariant */; }))) { - return 0 /* False */; + if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceFlags.VarianceMask */) === 0 /* VarianceFlags.Invariant */; }))) { + return 0 /* Ternary.False */; } // We remember the original error information so we can restore it in case the structural // comparison unexpectedly succeeds. This can happen when the structural comparison result @@ -66605,18 +66822,6 @@ var ts; } } } - function reportUnmeasurableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false); - } - return p; - } - function reportUnreliableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true); - } - return p; - } // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice // that S and T are contra-variant whereas X and Y are co-variant. @@ -66626,15 +66831,15 @@ var ts; if (modifiersRelated) { var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); - var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) { + var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMapper : reportUnreliableMapper); + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors); + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors); } } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToDiscriminatedType(source, target) { // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. @@ -66649,7 +66854,7 @@ var ts; var sourceProperties = getPropertiesOfType(source); var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); if (!sourcePropertiesFiltered) - return 0 /* False */; + return 0 /* Ternary.False */; // Though we could compute the number of combinations as we generate // the matrix, this would incur additional memory overhead due to // array allocations. To reduce this overhead, we first compute @@ -66661,8 +66866,8 @@ var ts; numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); - return 0 /* False */; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + return 0 /* Ternary.False */; } } // Compute the set of types for each discriminant property. @@ -66671,7 +66876,7 @@ var ts; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); - sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ + sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* TypeFlags.Union */ ? sourcePropertyType.types : [sourcePropertyType]; excludedProperties.add(sourceProperty.escapedName); @@ -66680,11 +66885,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_20 = function (combination) { + var _loop_21 = function (combination) { var hasMatch = false; outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) { var type = _d[_c]; - var _loop_21 = function (i) { + var _loop_22 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfType(type, sourceProperty.escapedName); if (!targetProperty) @@ -66692,7 +66897,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* IntersectionState.None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -66700,7 +66905,7 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_8 = _loop_21(i); + var state_8 = _loop_22(i); switch (state_8) { case "continue-outer": continue outer; } @@ -66709,30 +66914,30 @@ var ts; hasMatch = true; } if (!hasMatch) { - return { value: 0 /* False */ }; + return { value: 0 /* Ternary.False */ }; } }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_7 = _loop_20(combination); + var state_7 = _loop_21(combination); if (typeof state_7 === "object") return state_7.value; } // Compare the remaining non-discriminant properties of each match. - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* None */); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* IntersectionState.None */); if (result) { - result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 0 /* SignatureKind.Call */, /*reportStructuralErrors*/ false); if (result) { - result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 1 /* SignatureKind.Construct */, /*reportStructuralErrors*/ false); if (result && !(isTupleType(source) && isTupleType(type))) { // Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the // element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems // with index type assignability as the types for the excluded discriminants are still included // in the index type. - result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); + result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* IntersectionState.None */); } } } @@ -66759,40 +66964,40 @@ var ts; return result || properties; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { - var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */); var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); var effectiveSource = getTypeOfSourceProperty(sourceProp); - return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source)); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetPropFlags & 16 /* Protected */) { + else if (targetPropFlags & 16 /* ModifierFlags.Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (sourcePropFlags & 16 /* Protected */) { + else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Ensure {readonly a: whatever} is not a subtype of {a: whatever}, // while {a: whatever} is a subtype of {readonly a: whatever}. @@ -66802,7 +67007,7 @@ var ts; // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction if (relation === strictSubtypeRelation && isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // If the target comes from a partial union prop, allow `undefined` in the target type var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState); @@ -66810,10 +67015,10 @@ var ts; if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // When checking for comparability, be more lenient with optional properties. - if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { + if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -66824,7 +67029,7 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } return related; } @@ -66835,7 +67040,7 @@ var ts; && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) && source.symbol - && source.symbol.flags & 32 /* Class */) { + && source.symbol.flags & 32 /* SymbolFlags.Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) { @@ -66877,29 +67082,29 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (isTupleType(target)) { if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); - var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* Rest */ : 4 /* Rest */; - var targetRestFlag = target.target.combinedFlags & 4 /* Rest */; + var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */; + var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */; var sourceMinLength = isTupleType(source) ? source.target.minLength : 0; var targetMinLength = target.target.minLength; if (!sourceRestFlag && sourceArity < targetMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && targetArity < sourceMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { @@ -66910,38 +67115,38 @@ var ts; reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity); } } - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceTypeArguments = getTypeArguments(source); var targetTypeArguments = getTypeArguments(target); - var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* NonRest */) : 0, getStartElementCount(target.target, 11 /* NonRest */)); - var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* NonRest */) : 0); + var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */)); + var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0); var canExcludeDiscriminants = !!excludedProperties; for (var i = 0; i < targetArity; i++) { var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity; - var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* Rest */; + var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */; var targetFlags = target.target.elementFlags[i]; - if (targetFlags & 8 /* Variadic */ && !(sourceFlags & 8 /* Variadic */)) { + if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (sourceFlags & 8 /* Variadic */ && !(targetFlags & 12 /* Variable */)) { + if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) { if (reportErrors) { reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (targetFlags & 1 /* Required */ && !(sourceFlags & 1 /* Required */)) { + if (targetFlags & 1 /* ElementFlags.Required */ && !(sourceFlags & 1 /* ElementFlags.Required */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } // We can only exclude discriminant properties if we have not yet encountered a variable-length element. if (canExcludeDiscriminants) { - if (sourceFlags & 12 /* Variable */ || targetFlags & 12 /* Variable */) { + if (sourceFlags & 12 /* ElementFlags.Variable */ || targetFlags & 12 /* ElementFlags.Variable */) { canExcludeDiscriminants = false; } if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) { @@ -66949,12 +67154,12 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* ElementFlags.Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : - removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); - var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + var targetCheckType = sourceFlags & 8 /* ElementFlags.Variadic */ && targetFlags & 4 /* ElementFlags.Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* ElementFlags.Optional */)); + var related = isRelatedTo(sourceType, targetCheckType, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { @@ -66964,14 +67169,14 @@ var ts; reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i); } } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } - if (target.target.combinedFlags & 12 /* Variable */) { - return 0 /* False */; + if (target.target.combinedFlags & 12 /* ElementFlags.Variable */) { + return 0 /* Ternary.False */; } } var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); @@ -66980,18 +67185,18 @@ var ts; if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) { reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (isObjectLiteralType(target)) { for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) { var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType.flags & 32768 /* Undefined */)) { + if (!(sourceType.flags & 32768 /* TypeFlags.Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } } @@ -67003,12 +67208,12 @@ var ts; for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; var name = targetProp.escapedName; - if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { + if (!(targetProp.flags & 4194304 /* SymbolFlags.Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67017,24 +67222,24 @@ var ts; return result; } function propertiesIdenticalTo(source, target, excludedProperties) { - if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { - return 0 /* False */; + if (!(source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName); if (!targetProp) { - return 0 /* False */; + return 0 /* Ternary.False */; } var related = compareProperties(sourceProp, targetProp, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67046,17 +67251,17 @@ var ts; return signaturesIdenticalTo(source, target, kind); } if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; + return -1 /* Ternary.True */; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { - var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); - var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) { + var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */); + var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */); if (sourceIsAbstract && !targetIsAbstract) { // An abstract constructor type is not assignable to a non-abstract constructor type // as it would otherwise be possible to new an abstract class. Note that the assignability @@ -67065,18 +67270,18 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } - var result = -1 /* True */; - var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; + var result = -1 /* Ternary.True */; + var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; var sourceObjectFlags = ts.getObjectFlags(source); var targetObjectFlags = ts.getObjectFlags(target); - if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol || - sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) { + if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol || + sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters @@ -67084,7 +67289,7 @@ var ts; for (var i = 0; i < targetSignatures.length; i++) { var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67099,10 +67304,10 @@ var ts; var sourceSignature = ts.first(sourceSignatures); var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); - if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* Constructor */)) { + if (!result && reportErrors && kind === 1 /* SignatureKind.Construct */ && (sourceObjectFlags & targetObjectFlags) && + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* SyntaxKind.Constructor */)) { var constructSignatureToString = function (signature) { - return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); + return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */, kind); }; reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature)); reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible); @@ -67128,18 +67333,18 @@ var ts; if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } return result; } function shouldReportUnmatchedPropertyError(source, target) { - var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* Call */); - var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* Construct */); + var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* SignatureKind.Call */); + var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* SignatureKind.Construct */); var typeProperties = getPropertiesOfObjectType(source); if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) { - if ((getSignaturesOfType(target, 0 /* Call */).length && typeCallSignatures.length) || - (getSignaturesOfType(target, 1 /* Construct */).length && typeConstructSignatures.length)) { + if ((getSignaturesOfType(target, 0 /* SignatureKind.Call */).length && typeCallSignatures.length) || + (getSignaturesOfType(target, 1 /* SignatureKind.Construct */).length && typeConstructSignatures.length)) { return true; // target has similar signature kinds to source, still focus on the unmatched property } return false; @@ -67162,45 +67367,45 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* SignatureCheckMode.StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, reportUnreliableMapper); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } function membersRelatedToIndexInfo(source, targetInfo, reportErrors) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var keyType = targetInfo.keyType; - var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); + var props = source.flags & 2097152 /* TypeFlags.Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { var prop = props_2[_i]; // Skip over ignored JSX and symbol-named members if (isIgnoredJsxProperty(source, prop)) { continue; } - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), keyType)) { var propType = getNonMissingTypeOfSymbol(prop); - var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) + var type = exactOptionalPropertyTypes || propType.flags & 32768 /* TypeFlags.Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* SymbolFlags.Optional */) ? propType - : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors); + : getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */); + var related = isRelatedTo(type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67210,7 +67415,7 @@ var ts; if (isApplicableIndexType(info.keyType, keyType)) { var related = indexInfoRelatedTo(info, targetInfo, reportErrors); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67218,7 +67423,7 @@ var ts; return result; } function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { - var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors); + var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related && reportErrors) { if (sourceInfo.keyType === targetInfo.keyType) { reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); @@ -67235,14 +67440,14 @@ var ts; } var indexInfos = getIndexInfosOfType(target); var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; }); - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) { var targetInfo = indexInfos_5[_i]; - var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : - isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) : + var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* TypeFlags.Any */ ? -1 /* Ternary.True */ : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors) : typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67253,46 +67458,46 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } - if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) { + if (!(intersectionState & 1 /* IntersectionState.Source */) && isObjectTypeWithInferableIndex(source)) { // Intersection constituents are never considered to have an inferred index signature return membersRelatedToIndexInfo(source, targetInfo, reportErrors); } if (reportErrors) { reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } function indexSignaturesIdenticalTo(source, target) { var sourceInfos = getIndexInfosOfType(source); var targetInfos = getIndexInfosOfType(target); if (sourceInfos.length !== targetInfos.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) { var targetInfo = targetInfos_1[_i]; var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType); - if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { - return 0 /* False */; + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { + return 0 /* Ternary.False */; } } - return -1 /* True */; + return -1 /* Ternary.True */; } function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. - if (targetAccessibility === 8 /* Private */) { + if (targetAccessibility === 8 /* ModifierFlags.Private */) { return true; } // A public and protected signature is assignable to a protected signature. - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 16 /* ModifierFlags.Protected */ && sourceAccessibility !== 8 /* ModifierFlags.Private */) { return true; } // Only a public signature is assignable to public signature. - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 16 /* ModifierFlags.Protected */ && !sourceAccessibility) { return true; } if (reportErrors) { @@ -67305,19 +67510,19 @@ var ts; // Okay, yes, 'boolean' is a union of 'true | false', but that's not useful // in error reporting scenarios. If you need to use this function but that detail matters, // feel free to add a flag. - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return false; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getConstraintOfType(type); if (constraint && constraint !== type) { return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */); + return isUnitType(type) || !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */); } function getExactOptionalUnassignableProperties(source, target) { if (isTupleType(source) && isTupleType(target)) @@ -67326,7 +67531,7 @@ var ts; .filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); }); } function isExactOptionalPropertyMismatch(source, target) { - return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target); + return !!source && !!target && maybeTypeOfKind(source, 32768 /* TypeFlags.Undefined */) && !!containsMissingType(target); } function getExactOptionalProperties(type) { return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); }); @@ -67346,7 +67551,7 @@ var ts; for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; var targetProp = getUnionOrIntersectionProperty(target, propertyName); - if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) { + if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* CheckFlags.ReadPartial */) { continue; } var i = 0; @@ -67381,12 +67586,12 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && - resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); + resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* SymbolFlags.Optional */); }); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -67402,7 +67607,7 @@ var ts; } function getVariances(type) { // Arrays and tuples are known to be covariant, no need to spend time computing this. - return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */ ? + return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* ObjectFlags.Tuple */ ? arrayVariances : getVariancesWorker(type.symbol, type.typeParameters); } @@ -67418,14 +67623,14 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var links = getSymbolLinks(symbol); if (!links.variances) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; - var _loop_22 = function (tp) { + var _loop_23 = function (tp) { var modifiers = getVarianceModifiers(tp); - var variance = modifiers & 65536 /* Out */ ? - modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : - modifiers & 32768 /* In */ ? 2 /* Contravariant */ : undefined; + var variance = modifiers & 65536 /* ModifierFlags.Out */ ? + modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ : + modifiers & 32768 /* ModifierFlags.In */ ? 2 /* VarianceFlags.Contravariant */ : undefined; if (variance === undefined) { var unmeasurable_1 = false; var unreliable_1 = false; @@ -67436,33 +67641,33 @@ var ts; // invariance, covariance, contravariance or bivariance. var typeWithSuper = createMarkerType(symbol, tp, markerSuperType); var typeWithSub = createMarkerType(symbol, tp, markerSubType); - variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* Covariant */ : 0) | - (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* Contravariant */ : 0); + variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* VarianceFlags.Covariant */ : 0) | + (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* VarianceFlags.Contravariant */ : 0); // If the instantiations appear to be related bivariantly it may be because the // type parameter is independent (i.e. it isn't witnessed anywhere in the generic // type). To determine this we compare instantiations where the type parameter is // replaced with marker types that are known to be unrelated. - if (variance === 3 /* Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; + if (variance === 3 /* VarianceFlags.Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { + variance = 4 /* VarianceFlags.Independent */; } outofbandVarianceMarkerHandler = oldHandler; if (unmeasurable_1 || unreliable_1) { if (unmeasurable_1) { - variance |= 8 /* Unmeasurable */; + variance |= 8 /* VarianceFlags.Unmeasurable */; } if (unreliable_1) { - variance |= 16 /* Unreliable */; + variance |= 16 /* VarianceFlags.Unreliable */; } } } variances.push(variance); }; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - _loop_22(tp); + for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { + var tp = typeParameters_2[_i]; + _loop_23(tp); } links.variances = variances; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) }); } return links.variances; } @@ -67472,7 +67677,7 @@ var ts; if (isErrorType(type)) { return type; } - var result = symbol.flags & 524288 /* TypeAlias */ ? + var result = symbol.flags & 524288 /* SymbolFlags.TypeAlias */ ? getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) : createTypeReference(type, instantiateTypes(type.typeParameters, mapper)); markerTypes.add(getTypeId(result)); @@ -67483,34 +67688,34 @@ var ts; } function getVarianceModifiers(tp) { var _a, _b; - return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* In */); }) ? 32768 /* In */ : 0) | - (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* Out */); }) ? 65536 /* Out */ : 0); + return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* ModifierFlags.In */); }) ? 32768 /* ModifierFlags.In */ : 0) | + (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* ModifierFlags.Out */); }) ? 65536 /* ModifierFlags.Out */ : 0); } // Return true if the given type reference has a 'void' type argument for a covariant type parameter. // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(typeArguments, variances) { for (var i = 0; i < variances.length; i++) { - if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) { + if ((variances[i] & 7 /* VarianceFlags.VarianceMask */) === 1 /* VarianceFlags.Covariant */ && typeArguments[i].flags & 16384 /* TypeFlags.Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeFlags.TypeParameter */ && !getConstraintOfTypeParameter(type); } function isNonDeferredTypeReference(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeFlags.TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) { var typeParameters = []; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); // getTypeReferenceId(A) returns "111=0-12=1" // where A.id=111 and number.id=12 function getTypeReferenceId(type, depth) { @@ -67518,7 +67723,7 @@ var ts; var result = "" + type.target.id; for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { if (ignoreConstraints || isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); if (index < 0) { @@ -67554,12 +67759,12 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (ts.getCheckFlags(prop) & 6 /* Synthetic */) { + if (ts.getCheckFlags(prop) & 6 /* CheckFlags.Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.escapedName); @@ -67574,7 +67779,7 @@ var ts; } // Return the declaring class type of a property or undefined if property not declared in class function getDeclaringClass(prop) { - return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + return prop.parent && prop.parent.flags & 32 /* SymbolFlags.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) { @@ -67592,13 +67797,13 @@ var ts; } // Return true if source property is a valid override of protected parts of target property. function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* ModifierFlags.Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); } // Return true if the given class derives from each of the declaring classes of the protected // constituents of the given property. function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* ModifierFlags.Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons @@ -67644,14 +67849,14 @@ var ts; // reference the type have a recursion identity that differs from the object identity. function getRecursionIdentity(type) { // Object and array literals are known not to contain recursive references and don't need a recursion identity. - if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { - if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { + if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) { + if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) { // Deferred type references are tracked through their associated AST node. This gives us finer // granularity than using their associated target because each manifest type reference has a // unique AST node. return type.node; } - if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) { // We track all object types that have an associated symbol (representing the origin of the type), but // exclude the static side of classes from this check since it shares its symbol with the instance side. return type.symbol; @@ -67661,49 +67866,49 @@ var ts; return type.target; } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { return type.symbol; } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { type = type.objectType; - } while (type.flags & 8388608 /* IndexedAccess */); + } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */); return type; } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { // The root object represents the origin of the conditional type return type.root; } return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; + return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */; } function compareProperties(sourceProp, targetProp, compareTypes) { // Two members are considered identical when // - they are public properties with identical names, optionality, and types, // - they are private or protected properties originating in the same declaration and having identical types if (sourceProp === targetProp) { - return -1 /* True */; + return -1 /* Ternary.True */; } - var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; + var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (sourcePropAccessibility) { if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } else { - if ((sourceProp.flags & 16777216 /* Optional */) !== (targetProp.flags & 16777216 /* Optional */)) { - return 0 /* False */; + if ((sourceProp.flags & 16777216 /* SymbolFlags.Optional */) !== (targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { + return 0 /* Ternary.False */; } } if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -67734,14 +67939,14 @@ var ts; function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!(isMatchingSignature(source, target, partialMatch))) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that the two signatures have the same number of type parameters. if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that type parameter constraints and defaults match. If they do, instantiate the source // signature with the type parameters of the target signature and continue the comparison. @@ -67752,12 +67957,12 @@ var ts; var t = target.typeParameters[i]; if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) { - return 0 /* False */; + return 0 /* Ternary.False */; } } source = instantiateSignature(source, mapper, /*eraseTypeParameters*/ true); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (!ignoreThisTypes) { var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType) { @@ -67765,7 +67970,7 @@ var ts; if (targetThisType) { var related = compareTypes(sourceThisType, targetThisType); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67777,7 +67982,7 @@ var ts; var t = getTypeAtPosition(target, i); var related = compareTypes(t, s); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67791,56 +67996,52 @@ var ts; return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : - source.type === target.type ? -1 /* True */ : + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* Ternary.False */ : + source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + 0 /* Ternary.False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - var baseType = getBaseTypeOfLiteralType(t); - if (!commonBaseType) { - commonBaseType = baseType; - } - if (baseType === t || baseType !== commonBaseType) { - return false; + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + var baseType = getBaseTypeOfLiteralType(t); + commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType); + if (baseType === t || baseType !== commonBaseType) { + return false; + } } } return true; } - // When the candidate types are all literal types with the same base type, return a union - // of those literal types. Otherwise, return the leftmost type for which no type to the - // right is a supertype. - function getSupertypeOrUnion(types) { - if (types.length === 1) { - return types[0]; - } - return literalTypesWithSameBaseType(types) ? - getUnionType(types) : - ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + function getCombinedTypeFlags(types) { + return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 /* TypeFlags.Union */ ? getCombinedTypeFlags(t.types) : t.flags); }, 0); } function getCommonSupertype(types) { - if (!strictNullChecks) { - return getSupertypeOrUnion(types); - } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (primaryTypes.length) { - var supertypeOrUnion = getSupertypeOrUnion(primaryTypes); - return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true)); + if (types.length === 1) { + return types[0]; } - return getUnionType(types, 2 /* Subtype */); + // Remove nullable types from each of the candidates. + var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304 /* TypeFlags.Nullable */); }); }) : types; + // When the candidate types are all literal types with the same base type, return a union + // of those literal types. Otherwise, return the leftmost type for which no type to the + // right is a supertype. + var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? + getUnionType(primaryTypes) : + ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + // Add any nullable types that occurred in the candidates back to the result. + return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* TypeFlags.Nullable */); } // Return the leftmost type for which no type to the right is a subtype. function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); } function isReadonlyArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && type.target === globalReadonlyArrayType; } function isArrayOrTupleType(type) { return isArrayType(type) || isTupleType(type); @@ -67854,22 +68055,22 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || !(type.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function getSingleBaseForNonAugmentingSubtype(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ObjectFlags.ClassOrInterface */)) { return undefined; } - if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { - return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + if (ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* ObjectFlags.IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; } - type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + type.objectFlags |= 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */; var target = type.target; - if (ts.getObjectFlags(target) & 1 /* Class */) { + if (ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { var baseTypeNode = getBaseTypeNodeOfClass(target); // A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only // check for base types specified as simple qualified names. - if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 206 /* PropertyAccessExpression */) { + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* SyntaxKind.Identifier */ && baseTypeNode.expression.kind !== 206 /* SyntaxKind.PropertyAccessExpression */) { return undefined; } } @@ -67884,7 +68085,7 @@ var ts; if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); } - type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + type.objectFlags |= 67108864 /* ObjectFlags.IdenticalBaseTypeExists */; return type.cachedEquivalentBaseType = instantiatedBase; } function isEmptyLiteralType(type) { @@ -67911,44 +68112,49 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); + return !(type.flags & (109440 /* TypeFlags.Unit */ | 131072 /* TypeFlags.Never */)); } function isUnitType(type) { - return !!(type.flags & 109440 /* Unit */); + return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : - !!(type.flags & 109440 /* Unit */); + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* TypeFlags.Unit */); } function extractUnitType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type; + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; } function isLiteralType(type) { - return type.flags & 16 /* Boolean */ ? true : - type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + return type.flags & 16 /* TypeFlags.Boolean */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? type.flags & 1024 /* TypeFlags.EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 512 /* BooleanLiteral */ ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? getBaseTypeOfLiteralTypeUnion(type) : type; } + function getBaseTypeOfLiteralTypeUnion(type) { + var _a; + var key = "B".concat(getTypeId(type)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType)); + } function getWidenedLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : - type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : - type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : - type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* TypeFlags.StringLiteral */ && isFreshLiteralType(type) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ && isFreshLiteralType(type) ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedLiteralType) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -67979,10 +68185,10 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required. */ function isTupleType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target.objectFlags & 8 /* ObjectFlags.Tuple */); } function isGenericTupleType(type) { - return isTupleType(type) && !!(type.target.combinedFlags & 8 /* Variadic */); + return isTupleType(type) && !!(type.target.combinedFlags & 8 /* ElementFlags.Variadic */); } function isSingleElementGenericTupleType(type) { return isGenericTupleType(type) && type.target.elementFlags.length === 1; @@ -68003,7 +68209,7 @@ var ts; var elementTypes = []; for (var i = index; i < length; i++) { var t = typeArguments[i]; - elementTypes.push(type.target.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t); + elementTypes.push(type.target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t); } return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes); } @@ -68011,28 +68217,28 @@ var ts; } function isTupleTypeStructureMatching(t1, t2) { return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && - ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */); }); + ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* ElementFlags.Variable */) === (t2.target.elementFlags[i] & 12 /* ElementFlags.Variable */); }); } function isZeroBigInt(_a) { var value = _a.value; return value.base10Value === "0"; } function removeDefinitelyFalsyTypes(type) { - return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* Truthy */); }); + return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* TypeFacts.Truthy */); }); } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 4 /* String */ ? emptyStringType : - type.flags & 8 /* Number */ ? zeroType : - type.flags & 64 /* BigInt */ ? zeroBigIntType : + return type.flags & 4 /* TypeFlags.String */ ? emptyStringType : + type.flags & 8 /* TypeFlags.Number */ ? zeroType : + type.flags & 64 /* TypeFlags.BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || - type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || - type.flags & 128 /* StringLiteral */ && type.value === "" || - type.flags & 256 /* NumberLiteral */ && type.value === 0 || - type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + type.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */ | 3 /* TypeFlags.AnyOrUnknown */) || + type.flags & 128 /* TypeFlags.StringLiteral */ && type.value === "" || + type.flags & 256 /* TypeFlags.NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isZeroBigInt(type) ? type : neverType; } /** @@ -68041,27 +68247,27 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */); return missing === 0 ? type : - missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 65536 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* TypeFlags.Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* TypeFlags.Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type, isProperty) { if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); + return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { - deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; + deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* SymbolFlags.TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) : getIntersectionType([type, emptyObjectType]); } function getNonNullableType(type) { - return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function addOptionalTypeMarker(type) { return strictNullChecks ? getUnionType([type, optionalType]) : type; @@ -68081,10 +68287,10 @@ var ts; return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type; } function containsMissingType(type) { - return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, missingType)); } function removeMissingOrUndefinedType(type) { - return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */); + return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */); } /** * Is source potentially coercible to target type under `==`. @@ -68107,8 +68313,8 @@ var ts; * @param target */ function isCoercibleUnderDoubleEquals(source, target) { - return ((source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0) - && ((target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0); + return ((source.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 512 /* TypeFlags.BooleanLiteral */)) !== 0) + && ((target.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 16 /* TypeFlags.Boolean */)) !== 0); } /** * Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module @@ -68116,15 +68322,15 @@ var ts; */ function isObjectTypeWithInferableIndex(type) { var objectFlags = ts.getObjectFlags(type); - return type.flags & 2097152 /* Intersection */ + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol - && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 - && !(type.symbol.flags & 32 /* Class */) - && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + && (type.symbol.flags & (4096 /* SymbolFlags.ObjectLiteral */ | 2048 /* SymbolFlags.TypeLiteral */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !== 0 + && !(type.symbol.flags & 32 /* SymbolFlags.Class */) + && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectFlags.ObjectRestType */) || !!(objectFlags & 1024 /* ObjectFlags.ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { - var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); + var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* CheckFlags.Readonly */); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -68154,7 +68360,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* ObjectFlags.FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -68165,7 +68371,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~8192 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~8192 /* ObjectFlags.FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -68195,7 +68401,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) { var t = _a[_i]; - if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ObjectFlags.ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -68207,7 +68413,7 @@ var ts; return context.resolvedProperties; } function getWidenedProperty(prop, context) { - if (!(prop.flags & 4 /* Property */)) { + if (!(prop.flags & 4 /* SymbolFlags.Property */)) { // Since get accessors already widen their return value there is no need to // widen accessor based properties here. return prop; @@ -68223,7 +68429,7 @@ var ts; return cached; } var result = createSymbolWithType(prop, missingType); - result.flags |= 16777216 /* Optional */; + result.flags |= 16777216 /* SymbolFlags.Optional */; undefinedProperties.set(prop.escapedName, result); return result; } @@ -68242,33 +68448,33 @@ var ts; } } var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); })); - result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* JSLiteral */ | 262144 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */)); // Retain js literal flag through widening return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 196608 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } var result = void 0; - if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) { + if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) { result = anyType; } else if (isObjectLiteralType(type)) { result = getWidenedTypeOfObjectLiteral(type, context); } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayOrTupleType(type)) { @@ -68294,8 +68500,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 65536 /* ContainsWideningType */) { - if (type.flags & 1048576 /* Union */) { + if (ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -68320,7 +68526,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (ts.getObjectFlags(t) & 65536 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 65536 /* ObjectFlags.ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -68339,17 +68545,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 221 /* BinaryExpression */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 221 /* SyntaxKind.BinaryExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* SymbolFlags.Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : ""); @@ -68360,25 +68566,25 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (noImplicitAny && !declaration.name) { - if (wideningKind === 3 /* GeneratorYield */) { + if (wideningKind === 3 /* WideningKind.GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); } else { @@ -68387,10 +68593,10 @@ var ts; return; } diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage : - wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : + wideningKind === 3 /* WideningKind.GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -68402,7 +68608,7 @@ var ts; } function reportErrorsFromWidening(declaration, type, wideningKind) { addLazyDiagnostic(function () { - if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -68454,27 +68660,29 @@ var ts; signature: signature, flags: flags, compareTypes: compareTypes, - mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ true); }), - nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ false); }), + mapper: reportUnmeasurableMapper, + nonFixingMapper: reportUnmeasurableMapper, }; + context.mapper = makeFixingMapperForContext(context); + context.nonFixingMapper = makeNonFixingMapperForContext(context); return context; } - function mapToInferredType(context, t, fix) { - var inferences = context.inferences; - for (var i = 0; i < inferences.length; i++) { - var inference = inferences[i]; - if (t === inference.typeParameter) { - if (fix && !inference.isFixed) { - // Before we commit to a particular inference (and thus lock out any further inferences), - // we infer from any intra-expression inference sites we have collected. - inferFromIntraExpressionSites(context); - clearCachedInferences(inferences); - inference.isFixed = true; - } - return getInferredType(context, i); + function makeFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (inference, i) { return function () { + if (!inference.isFixed) { + // Before we commit to a particular inference (and thus lock out any further inferences), + // we infer from any intra-expression inference sites we have collected. + inferFromIntraExpressionSites(context); + clearCachedInferences(context.inferences); + inference.isFixed = true; } - } - return t; + return getInferredType(context, i); + }; })); + } + function makeNonFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (_, i) { return function () { + return getInferredType(context, i); + }; })); } function clearCachedInferences(inferences) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { @@ -68505,9 +68713,9 @@ var ts; if (context.intraExpressionInferenceSites) { for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) { var _b = _a[_i], node = _b.node, type = _b.type; - var contextualType = node.kind === 169 /* MethodDeclaration */ ? - getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : - getContextualType(node, 2 /* NoConstraints */); + var contextualType = node.kind === 169 /* SyntaxKind.MethodDeclaration */ ? + getContextualTypeForObjectLiteralMethod(node, 2 /* ContextFlags.NoConstraints */) : + getContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { inferTypes(context.inferences, type, contextualType); } @@ -68553,40 +68761,40 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 1048576 /* CouldContainTypeVariables */); + if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */); } - var result = !!(type.flags & 465829888 /* Instantiable */ || - 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 */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); - if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0); + var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ || + type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); + if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) { + type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SourceFile */ ? true : n.kind === 261 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SyntaxKind.SourceFile */ ? true : n.kind === 261 /* SyntaxKind.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); }) || - type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || + type.flags & 16777216 /* TypeFlags.Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 128 /* StringLiteral */)) { + if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); - var literalProp = createSymbol(4 /* Property */, name); + var literalProp = createSymbol(4 /* SymbolFlags.Property */, name); literalProp.type = anyType; if (t.symbol) { literalProp.declarations = t.symbol.declarations; @@ -68594,7 +68802,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; + var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos); } /** @@ -68622,7 +68830,7 @@ var ts; // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 262144 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 262144 /* ObjectFlags.NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -68639,14 +68847,14 @@ var ts; } if (isTupleType(source)) { var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); - var elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? - ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var elementFlags = getMappedTypeModifiers(target) & 4 /* MappedTypeModifiers.IncludeOptional */ ? + ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : source.target.elementFlags; return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations); } // For all other object types we infer a new object type where the reverse mapping has been // applied to the type of each property. - var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ObjectFlags.ReverseMapped */ | 16 /* ObjectFlags.Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; @@ -68681,7 +68889,7 @@ var ts; if (isStaticPrivateIdentifierProperty(targetProp)) { return [3 /*break*/, 5]; } - if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */))) return [3 /*break*/, 5]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */))) return [3 /*break*/, 5]; sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!!sourceProp) return [3 /*break*/, 3]; return [4 /*yield*/, targetProp]; @@ -68691,9 +68899,9 @@ var ts; case 3: if (!matchDiscriminantProperties) return [3 /*break*/, 5]; targetType = getTypeOfSymbol(targetProp); - if (!(targetType.flags & 109440 /* Unit */)) return [3 /*break*/, 5]; + if (!(targetType.flags & 109440 /* TypeFlags.Unit */)) return [3 /*break*/, 5]; sourceType = getTypeOfSymbol(sourceProp); - if (!!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; + if (!!(sourceType.flags & 1 /* TypeFlags.Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; return [4 /*yield*/, targetProp]; case 4: _a.sent(); @@ -68711,7 +68919,7 @@ var ts; return result.value; } function tupleTypesDefinitelyUnrelated(source, target) { - return !(target.target.combinedFlags & 8 /* Variadic */) && target.target.minLength > source.target.minLength || + return !(target.target.combinedFlags & 8 /* ElementFlags.Variadic */) && target.target.minLength > source.target.minLength || !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength); } function typesDefinitelyUnrelated(source, target) { @@ -68722,7 +68930,7 @@ var ts; !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false); } function getTypeFromInference(inference) { - return inference.candidates ? getUnionType(inference.candidates, 2 /* Subtype */) : + return inference.candidates ? getUnionType(inference.candidates, 2 /* UnionReduction.Subtype */) : inference.contraCandidates ? getIntersectionType(inference.contraCandidates) : undefined; } @@ -68759,7 +68967,7 @@ var ts; */ function parseBigIntLiteralType(text) { var negative = text.startsWith("-"); - var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n"); + var base10Value = ts.parsePseudoBigInt("".concat(negative ? text.slice(1) : text, "n")); return getBigIntLiteralType({ negative: negative, base10Value: base10Value }); } /** @@ -68770,12 +68978,12 @@ var ts; function isValidBigIntString(s, roundTripOnly) { if (s === "") return false; - var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.ESNext */, /*skipTrivia*/ false); var success = true; scanner.setOnError(function () { return success = false; }); scanner.setText(s + "n"); var result = scanner.scan(); - var negative = result === 40 /* MinusToken */; + var negative = result === 40 /* SyntaxKind.MinusToken */; if (negative) { result = scanner.scan(); } @@ -68785,17 +68993,17 @@ var ts; // * a bigint can be scanned, and that when it is scanned, it is // * the full length of the input string (so the scanner is one character beyond the augmented input length) // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) - return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */) + return success && result === 9 /* SyntaxKind.BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* TokenFlags.ContainsSeparator */) && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) })); } function isMemberOfStringMapping(source, target) { - if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) { + if (target.flags & (4 /* TypeFlags.String */ | 3 /* TypeFlags.AnyOrUnknown */)) { return true; } - if (target.flags & 134217728 /* TemplateLiteral */) { + if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { return isTypeAssignableTo(source, target); } - if (target.flags & 268435456 /* StringMapping */) { + if (target.flags & 268435456 /* TypeFlags.StringMapping */) { // We need to see whether applying the same mappings of the target // onto the source would produce an identical type *and* that // it's compatible with the inner-most non-string-mapped type. @@ -68804,7 +69012,7 @@ var ts; // and the source is compatible with the unmapped target, then they must // still reside in the same domain. var mappingStack = []; - while (target.flags & 268435456 /* StringMapping */) { + while (target.flags & 268435456 /* TypeFlags.StringMapping */) { mappingStack.unshift(target.symbol); target = target.type; } @@ -68814,25 +69022,25 @@ var ts; return false; } function isValidTypeForTemplateLiteralPlaceholder(source, target) { - if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + if (source === target || target.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)) { return true; } - if (source.flags & 128 /* StringLiteral */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */) { var value = source.value; - return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) || - target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) || - target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName || - target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target)); + return !!(target.flags & 8 /* TypeFlags.Number */ && isValidNumberString(value, /*roundTripOnly*/ false) || + target.flags & 64 /* TypeFlags.BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) || + target.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) && value === target.intrinsicName || + target.flags & 268435456 /* TypeFlags.StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target)); } - if (source.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts = source.texts; return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target); } return isTypeAssignableTo(source, target); } function inferTypesFromTemplateLiteralType(source, target) { - return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : - source.flags & 134217728 /* TemplateLiteral */ ? + return source.flags & 128 /* TypeFlags.StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : undefined; @@ -68842,7 +69050,7 @@ var ts; return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); }); } function getStringLikeTypeForType(type) { - return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); + return type.flags & (1 /* TypeFlags.Any */ | 402653316 /* TypeFlags.StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); } // This function infers from the text parts and type parts of a source literal to a target template literal. The number // of text parts is always one more than the number of type parts, and a source string literal is treated as a source @@ -68924,12 +69132,12 @@ var ts; if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 2048 /* MaxValue */; + var inferencePriority = 2048 /* InferencePriority.MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; var targetStack; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { if (!couldContainTypeVariables(target)) { @@ -68945,13 +69153,16 @@ var ts; propagationType = savePropagationType; return; } - if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - // Source and target are types originating in the same generic type alias declaration. - // Simply infer from source type arguments to target type arguments. - inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) { + if (source.aliasTypeArguments) { + // Source and target are types originating in the same generic type alias declaration. + // Simply infer from source type arguments to target type arguments. + inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + } + // And if there weren't any type arguments, there's no reason to run inference as the types must be the same. return; } - if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + if (source === target && source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { // When source and target are the same union or intersection type, just relate each constituent // type to itself. for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -68960,10 +69171,10 @@ var ts; } return; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { // First, infer between identically matching source and target constituents and remove the // matching types. - var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _b = inferFromMatchingTypes(source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; // Next, infer between closely matching source and target constituents and remove // the matching types. Types closely match when they are instantiations of the same // object type or instantiations of the same type alias. @@ -68978,21 +69189,21 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - inferWithPriority(source, target, 1 /* NakedTypeVariable */); + inferWithPriority(source, target, 1 /* InferencePriority.NakedTypeVariable */); return; } source = getUnionType(sources); } - else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + else if (target.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { // We reduce intersection types only when they contain naked type parameters. For example, when // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the // string[] on the source side and infer string for T. // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" // in such scenarios. - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { // Infer between identically matching source and target constituents and remove the matching types. - var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + var _d = inferFromMatchingTypes(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; if (sources.length === 0 || targets.length === 0) { return; } @@ -69000,23 +69211,31 @@ var ts; target = getIntersectionType(targets); } } - else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { + else if (target.flags & (8388608 /* TypeFlags.IndexedAccess */ | 33554432 /* TypeFlags.Substitution */)) { target = getActualTypeVariable(target); } - if (target.flags & 8650752 /* TypeVariable */) { - // If target is a type parameter, make an inference, unless the source type contains - // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). - // Because the anyFunctionType is internal, it should not be exposed to the user by adding - // it as an inference candidate. Hopefully, a better candidate will come along that does - // not contain anyFunctionType when we come back to this argument for its second round - // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard - // when constructing types from type parameters that had no inference candidates). - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (target.flags & 8650752 /* TypeFlags.TypeVariable */) { + // Skip inference if the source is "blocked", which is used by the language service to + // prevent inference on nodes currently being edited. + if (isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); if (inference) { - if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) { + // If target is a type parameter, make an inference, unless the source type contains + // a "non-inferrable" type. Types with this flag set are markers used to prevent inference. + // + // For example: + // - anyFunctionType is a wildcard type that's used to avoid contextually typing functions; + // it's internal, so should not be exposed to the user by adding it as a candidate. + // - autoType (and autoArrayType) is a special "any" used in control flow; like anyFunctionType, + // it's internal and should not be observable. + // - silentNeverType is returned by getInferredType when instantiating a generic function for + // inference (and a type variable has no mapping). + // + // This flag is infectious; if we produce Box (where never is silentNeverType), Box is + // also non-inferrable. + if (ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */) { return; } if (!inference.isFixed) { @@ -69041,7 +69260,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* InferencePriority.ReturnType */) && target.flags & 262144 /* TypeFlags.TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -69054,11 +69273,11 @@ var ts; if (simplified !== target) { inferFromTypes(source, simplified); } - else if (target.flags & 8388608 /* IndexedAccess */) { + else if (target.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexType = getSimplifiedType(target.indexType, /*writing*/ false); // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can. - if (indexType.flags & 465829888 /* Instantiable */) { + if (indexType.flags & 465829888 /* TypeFlags.Instantiable */) { var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false); if (simplified_1 && simplified_1 !== target) { inferFromTypes(source, simplified_1); @@ -69066,45 +69285,38 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } - else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { - contravariant = !contravariant; - inferFromTypes(source.type, target.type); - contravariant = !contravariant; + else if (source.flags & 4194304 /* TypeFlags.Index */ && target.flags & 4194304 /* TypeFlags.Index */) { + inferFromContravariantTypes(source.type, target.type); } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* TypeFlags.String */) && target.flags & 4194304 /* TypeFlags.Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); - contravariant = !contravariant; - inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); - contravariant = !contravariant; + inferFromContravariantTypesWithPriority(empty, target.type, 256 /* InferencePriority.LiteralKeyof */); } - else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { + else if (source.flags & 8388608 /* TypeFlags.IndexedAccess */ && target.flags & 8388608 /* TypeFlags.IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) { + else if (source.flags & 268435456 /* TypeFlags.StringMapping */ && target.flags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol === target.symbol) { inferFromTypes(source.type, target.type); } } - else if (source.flags & 33554432 /* Substitution */) { + else if (source.flags & 33554432 /* TypeFlags.Substitution */) { inferFromTypes(source.baseType, target); - var oldPriority = priority; - priority |= 4 /* SubstituteSource */; - inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority - priority = oldPriority; + inferWithPriority(source.substitute, target, 4 /* InferencePriority.SubstituteSource */); // Make substitute inference at a lower priority } - else if (target.flags & 16777216 /* Conditional */) { + else if (target.flags & 16777216 /* TypeFlags.Conditional */) { invokeOnce(source, target, inferToConditionalType); } - else if (target.flags & 3145728 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } - else if (source.flags & 1048576 /* Union */) { + else if (source.flags & 1048576 /* TypeFlags.Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) { @@ -69112,17 +69324,17 @@ var ts; inferFromTypes(sourceType, target); } } - else if (target.flags & 134217728 /* TemplateLiteral */) { + else if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { inferToTemplateLiteralType(source, target); } else { source = getReducedType(source); - if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* InferencePriority.NoConstraints */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` // with the simplified source. - if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */))) { // TODO: The `allowComplexConstraintInference` flag is a hack! This forbids inference from complex constraints within constraints! // This isn't required algorithmically, but rather is used to lower the memory burden caused by performing inference // that is _too good_ in projects with complicated constraints (eg, fp-ts). In such cases, if we did not limit ourselves @@ -69135,7 +69347,7 @@ var ts; } source = apparentSource; } - if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { invokeOnce(source, target, inferFromObjectTypes); } } @@ -69146,6 +69358,18 @@ var ts; inferFromTypes(source, target); priority = savePriority; } + function inferFromContravariantTypesWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromContravariantTypes(source, target); + priority = savePriority; + } + function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferToMultipleTypes(source, targets, targetFlags); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -69153,19 +69377,19 @@ var ts; inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); + (visited || (visited = new ts.Map())).set(key, -1 /* InferencePriority.Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. var saveExpandingFlags = expandingFlags; var sourceIdentity = getRecursionIdentity(source); var targetIdentity = getRecursionIdentity(target); if (ts.contains(sourceStack, sourceIdentity)) - expandingFlags |= 1 /* Source */; + expandingFlags |= 1 /* ExpandingFlags.Source */; if (ts.contains(targetStack, targetIdentity)) - expandingFlags |= 2 /* Target */; - if (expandingFlags !== 3 /* Both */) { + expandingFlags |= 2 /* ExpandingFlags.Target */; + if (expandingFlags !== 3 /* ExpandingFlags.Both */) { (sourceStack || (sourceStack = [])).push(sourceIdentity); (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); @@ -69173,7 +69397,7 @@ var ts; sourceStack.pop(); } else { - inferencePriority = -1 /* Circularity */; + inferencePriority = -1 /* InferencePriority.Circularity */; } expandingFlags = saveExpandingFlags; visited.set(key, inferencePriority); @@ -69201,7 +69425,7 @@ var ts; function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; for (var i = 0; i < count; i++) { - if (i < variances.length && (variances[i] & 7 /* VarianceMask */) === 2 /* Contravariant */) { + if (i < variances.length && (variances[i] & 7 /* VarianceFlags.VarianceMask */) === 2 /* VarianceFlags.Contravariant */) { inferFromContravariantTypes(sourceTypes[i], targetTypes[i]); } else { @@ -69210,17 +69434,20 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { - contravariant = !contravariant; - inferFromTypes(source, target); - contravariant = !contravariant; + contravariant = !contravariant; + inferFromTypes(source, target); + contravariant = !contravariant; + } + function inferFromContravariantTypesIfStrictFunctionTypes(source, target) { + if (strictFunctionTypes || priority & 1024 /* InferencePriority.AlwaysStrict */) { + inferFromContravariantTypes(source, target); } else { inferFromTypes(source, target); } } function getInferenceInfoForType(type) { - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) { var inference = inferences_2[_i]; if (type === inference.typeParameter) { @@ -69234,7 +69461,7 @@ var ts; var typeVariable; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var type = types_14[_i]; - var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + var t = type.flags & 2097152 /* TypeFlags.Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; } @@ -69244,9 +69471,9 @@ var ts; } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; - if (targetFlags & 1048576 /* Union */) { + if (targetFlags & 1048576 /* TypeFlags.Union */) { var nakedTypeVariable = void 0; - var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; + var sources = source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we @@ -69262,11 +69489,11 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; - inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* InferencePriority.Circularity */; inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } @@ -69277,7 +69504,7 @@ var ts; // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); if (intersectionTypeVariable) { - inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + inferWithPriority(source, intersectionTypeVariable, 1 /* InferencePriority.NakedTypeVariable */); } return; } @@ -69311,17 +69538,17 @@ var ts; // less specific. For example, when inferring from Promise to T | Promise, // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. - if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { + if (targetFlags & 2097152 /* TypeFlags.Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferWithPriority(source, t, 1 /* NakedTypeVariable */); + inferWithPriority(source, t, 1 /* InferencePriority.NakedTypeVariable */); } } } } function inferToMappedType(source, target, constraintType) { - if (constraintType.flags & 1048576 /* Union */) { + if (constraintType.flags & 1048576 /* TypeFlags.Union */) { var result = false; for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { var type = _a[_i]; @@ -69329,7 +69556,7 @@ var ts; } return result; } - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -69341,17 +69568,17 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* NonInferrableType */ ? - 16 /* PartialHomomorphicMappedType */ : - 8 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */ ? + 16 /* InferencePriority.PartialHomomorphicMappedType */ : + 8 /* InferencePriority.HomomorphicMappedType */); } } return true; } - if (constraintType.flags & 262144 /* TypeParameter */) { + if (constraintType.flags & 262144 /* TypeFlags.TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* InferencePriority.MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -69370,18 +69597,15 @@ var ts; return false; } function inferToConditionalType(source, target) { - if (source.flags & 16777216 /* Conditional */) { + if (source.flags & 16777216 /* TypeFlags.Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } else { - var savePriority = priority; - priority |= contravariant ? 64 /* ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; - inferToMultipleTypes(source, targetTypes, target.flags); - priority = savePriority; + inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 /* InferencePriority.ContravariantConditional */ : 0); } } function inferToTemplateLiteralType(source, target) { @@ -69394,47 +69618,47 @@ var ts; // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might // succeed. That would be a pointless and confusing outcome. if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) { - var _loop_23 = function (i) { + var _loop_24 = function (i) { var source_1 = matches ? matches[i] : neverType; var target_3 = types[i]; // If we are inferring from a string literal type to a type variable whose constraint includes one of the // allowed template literal placeholder types, infer from a literal type corresponding to the constraint. - if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) { + if (source_1.flags & 128 /* TypeFlags.StringLiteral */ && target_3.flags & 8650752 /* TypeFlags.TypeVariable */) { var inferenceContext = getInferenceInfoForType(target_3); var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined; if (constraint && !isTypeAny(constraint)) { - var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint]; + var constraintTypes = constraint.flags & 1048576 /* TypeFlags.Union */ ? constraint.types : [constraint]; var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0); // If the constraint contains `string`, we don't need to look for a more preferred type - if (!(allTypeFlags_1 & 4 /* String */)) { + if (!(allTypeFlags_1 & 4 /* TypeFlags.String */)) { var str_1 = source_1.value; // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers - if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) { - allTypeFlags_1 &= ~296 /* NumberLike */; + if (allTypeFlags_1 & 296 /* TypeFlags.NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) { + allTypeFlags_1 &= ~296 /* TypeFlags.NumberLike */; } // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints - if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) { - allTypeFlags_1 &= ~2112 /* BigIntLike */; + if (allTypeFlags_1 & 2112 /* TypeFlags.BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) { + allTypeFlags_1 &= ~2112 /* TypeFlags.BigIntLike */; } // for each type in the constraint, find the highest priority matching type var matchingType = ts.reduceLeft(constraintTypes, function (left, right) { return !(right.flags & allTypeFlags_1) ? left : - left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 : - left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 : - left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 : - left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right : - left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) : - left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) : - left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right : - left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) : - left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right : - left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType : - left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right : - left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right : - left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right : + left.flags & 4 /* TypeFlags.String */ ? left : right.flags & 4 /* TypeFlags.String */ ? source_1 : + left.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? left : right.flags & 134217728 /* TypeFlags.TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 : + left.flags & 268435456 /* TypeFlags.StringMapping */ ? left : right.flags & 268435456 /* TypeFlags.StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 : + left.flags & 128 /* TypeFlags.StringLiteral */ ? left : right.flags & 128 /* TypeFlags.StringLiteral */ && right.value === str_1 ? right : + left.flags & 8 /* TypeFlags.Number */ ? left : right.flags & 8 /* TypeFlags.Number */ ? getNumberLiteralType(+str_1) : + left.flags & 32 /* TypeFlags.Enum */ ? left : right.flags & 32 /* TypeFlags.Enum */ ? getNumberLiteralType(+str_1) : + left.flags & 256 /* TypeFlags.NumberLiteral */ ? left : right.flags & 256 /* TypeFlags.NumberLiteral */ && right.value === +str_1 ? right : + left.flags & 64 /* TypeFlags.BigInt */ ? left : right.flags & 64 /* TypeFlags.BigInt */ ? parseBigIntLiteralType(str_1) : + left.flags & 2048 /* TypeFlags.BigIntLiteral */ ? left : right.flags & 2048 /* TypeFlags.BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right : + left.flags & 16 /* TypeFlags.Boolean */ ? left : right.flags & 16 /* TypeFlags.Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType : + left.flags & 512 /* TypeFlags.BooleanLiteral */ ? left : right.flags & 512 /* TypeFlags.BooleanLiteral */ && right.intrinsicName === str_1 ? right : + left.flags & 32768 /* TypeFlags.Undefined */ ? left : right.flags & 32768 /* TypeFlags.Undefined */ && right.intrinsicName === str_1 ? right : + left.flags & 65536 /* TypeFlags.Null */ ? left : right.flags & 65536 /* TypeFlags.Null */ && right.intrinsicName === str_1 ? right : left; }, neverType); - if (!(matchingType.flags & 131072 /* Never */)) { + if (!(matchingType.flags & 131072 /* TypeFlags.Never */)) { inferFromTypes(matchingType, target_3); return "continue"; } @@ -69444,12 +69668,12 @@ var ts; inferFromTypes(source_1, target_3); }; for (var i = 0; i < types.length; i++) { - _loop_23(i); + _loop_24(i); } } } function inferFromObjectTypes(source, target) { - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); return; @@ -69464,7 +69688,7 @@ var ts; if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType); } - if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) { + if (ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */ && !target.declaration.nameType) { var constraintType = getConstraintTypeFromMappedType(target); if (inferToMappedType(source, target, constraintType)) { return; @@ -69487,21 +69711,21 @@ var ts; return; } var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0; - var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* Fixed */) : 0); + var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* ElementFlags.Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* ElementFlags.Fixed */) : 0); // Infer between starting fixed elements. for (var i = 0; i < startLength; i++) { inferFromTypes(getTypeArguments(source)[i], elementTypes[i]); } - if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* Rest */) { + if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Single rest element remains in source, infer from that to every element in target var restType = getTypeArguments(source)[startLength]; for (var i = startLength; i < targetArity - endLength; i++) { - inferFromTypes(elementFlags[i] & 8 /* Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); + inferFromTypes(elementFlags[i] & 8 /* ElementFlags.Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); } } else { var middleLength = targetArity - startLength - endLength; - if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* Variadic */ && isTupleType(source)) { + if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* ElementFlags.Variadic */ && isTupleType(source)) { // Middle of target is [...T, ...U] and source is tuple type var targetInfo = getInferenceInfoForType(elementTypes[startLength]); if (targetInfo && targetInfo.impliedArity !== undefined) { @@ -69510,14 +69734,14 @@ var ts; inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]); } } - else if (middleLength === 1 && elementFlags[startLength] & 8 /* Variadic */) { + else if (middleLength === 1 && elementFlags[startLength] & 8 /* ElementFlags.Variadic */) { // Middle of target is exactly one variadic element. Infer the slice between the fixed parts in the source. // If target ends in optional element(s), make a lower priority a speculative inference. - var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* Optional */; + var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* ElementFlags.Optional */; var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]); - inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* SpeculativeTuple */ : 0); + inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* InferencePriority.SpeculativeTuple */ : 0); } - else if (middleLength === 1 && elementFlags[startLength] & 4 /* Rest */) { + else if (middleLength === 1 && elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Middle of target is exactly one rest element. If middle of source is not empty, infer union of middle element types. var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0]; if (restType) { @@ -69537,8 +69761,8 @@ var ts; } } inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); + inferFromSignatures(source, target, 0 /* SignatureKind.Call */); + inferFromSignatures(source, target, 1 /* SignatureKind.Construct */); inferFromIndexTypes(source, target); } } @@ -69558,25 +69782,22 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */); for (var i = 0; i < len; i++) { - inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); + inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); } } - function inferFromSignature(source, target, skipParameters) { - if (!skipParameters) { - var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */; - applyToParameterTypes(source, target, inferFromContravariantTypes); - bivariant = saveBivariant; - } + function inferFromSignature(source, target) { + var saveBivariant = bivariant; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + // Once we descend into a bivariant signature we remain bivariant for all nested inferences + bivariant = bivariant || kind === 169 /* SyntaxKind.MethodDeclaration */ || kind === 168 /* SyntaxKind.MethodSignature */ || kind === 171 /* SyntaxKind.Constructor */; + applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes); + bivariant = saveBivariant; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables - var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */) ? 8 /* InferencePriority.HomomorphicMappedType */ : 0; var indexInfos = getIndexInfosOfType(target); if (isObjectTypeWithInferableIndex(source)) { for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) { @@ -69584,9 +69805,9 @@ var ts; var propTypes = []; for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { var propType = getTypeOfSymbol(prop); - propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType); + propTypes.push(prop.flags & 16777216 /* SymbolFlags.Optional */ ? removeMissingOrUndefinedType(propType) : propType); } } for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) { @@ -69611,34 +69832,34 @@ var ts; } function isTypeOrBaseIdenticalTo(s, t) { return exactOptionalPropertyTypes && t === missingType ? s === t : - (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */)); + (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* TypeFlags.String */ && s.flags & 128 /* TypeFlags.StringLiteral */ || t.flags & 8 /* TypeFlags.Number */ && s.flags & 256 /* TypeFlags.NumberLiteral */)); } function isTypeCloselyMatchedBy(s, t) { - return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + return !!(s.flags & 524288 /* TypeFlags.Object */ && t.flags & 524288 /* TypeFlags.Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* TypeFlags.Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); } function isObjectLiteralType(type) { - return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); + return !!(ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 16384 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectFlags.ObjectLiteral */ | 16384 /* ObjectFlags.ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType); if (objectLiterals.length) { - var literalsType = getUnionType(objectLiterals, 2 /* Subtype */); + var literalsType = getUnionType(objectLiterals, 2 /* UnionReduction.Subtype */); return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]); } } return candidates; } function getContravariantInference(inference) { - return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { // Extract all object and array literal types and replace them with a single widened and normalized type. @@ -69655,8 +69876,8 @@ var ts; candidates; // If all inferences were made from a position that implies a combined result, infer a union type. // Otherwise, infer a common supertype. - var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? - getUnionType(baseCandidates, 2 /* Subtype */) : + var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? + getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); } @@ -69670,14 +69891,14 @@ var ts; if (inference.contraCandidates) { // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'. - inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) && + inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* TypeFlags.Never */) && ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ? inferredCovariantType_1 : getContravariantInference(inference); } else if (inferredCovariantType_1) { inferredType = inferredCovariantType_1; } - else if (context.flags & 1 /* NoDefault */) { + else if (context.flags & 1 /* InferenceFlags.NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. inferredType = silentNeverType; } @@ -69698,7 +69919,7 @@ var ts; else { inferredType = getTypeFromInference(inference); } - inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* AnyDefault */)); + inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* InferenceFlags.AnyDefault */)); var constraint = getConstraintOfTypeParameter(inference.typeParameter); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper); @@ -69768,7 +69989,7 @@ var ts; } // falls through default: - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -69780,7 +70001,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false) || unknownSymbol; } return links.resolvedSymbol; @@ -69789,7 +70010,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 161 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* SyntaxKind.TypeQuery */ ? true : n.kind === 79 /* SyntaxKind.Identifier */ || n.kind === 161 /* SyntaxKind.QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -69797,70 +70018,79 @@ var ts; // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } // falls through - case 108 /* ThisKeyword */: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); return left && left + "." + node.right.escapedText; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); return key && key + "." + propName; } + break; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + // Handle pseudo-references originating in getNarrowedTypeOfSymbol. + return "".concat(getNodeId(node), "#").concat(getTypeId(declaredType)); } return undefined; } function isMatchingReference(source, target) { switch (target.kind) { - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isMatchingReference(source, target.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || - (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); + (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 231 /* MetaProperty */: - return target.kind === 231 /* MetaProperty */ + case 231 /* SyntaxKind.MetaProperty */: + return target.kind === 231 /* SyntaxKind.MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isThisInTypeQuery(source) ? - target.kind === 108 /* ThisKeyword */ : - target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 254 /* VariableDeclaration */ || target.kind === 203 /* BindingElement */) && + target.kind === 108 /* SyntaxKind.ThisKeyword */ : + target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 108 /* ThisKeyword */: - return target.kind === 108 /* ThisKeyword */; - case 106 /* SuperKeyword */: - return target.kind === 106 /* SuperKeyword */; - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return target.kind === 108 /* SyntaxKind.ThisKeyword */; + case 106 /* SyntaxKind.SuperKeyword */: + return target.kind === 106 /* SyntaxKind.SuperKeyword */; + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var sourcePropertyName = getAccessedPropertyName(source); var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined; return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName && isMatchingReference(source.expression, target.expression); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 221 /* BinaryExpression */: - return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); + case 221 /* SyntaxKind.BinaryExpression */: + return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target)); } return false; } @@ -69881,15 +70111,15 @@ var ts; return undefined; } function tryGetNameFromType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : - type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? type.escapedName : + type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; } function tryGetElementAccessExpressionName(node) { if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) { return ts.escapeLeadingUnderscores(node.argumentExpression.text); } if (ts.isEntityNameExpression(node.argumentExpression)) { - var symbol = resolveEntityName(node.argumentExpression, 111551 /* Value */, /*ignoreErrors*/ true); + var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); if (!symbol || !isConstVariable(symbol)) return undefined; var declaration = symbol.valueDeclaration; @@ -69928,12 +70158,12 @@ var ts; return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 1048576 /* Union */) { + if (type && type.flags & 1048576 /* TypeFlags.Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (prop && ts.getCheckFlags(prop) & 2 /* CheckFlags.SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = - (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && + (prop.checkFlags & 192 /* CheckFlags.Discriminant */) === 192 /* CheckFlags.Discriminant */ && !isGenericType(getTypeOfSymbol(prop)); } return !!prop.isDiscriminantProperty; @@ -69962,8 +70192,8 @@ var ts; function mapTypesByKeyProperty(types, name) { var map = new ts.Map(); var count = 0; - var _loop_24 = function (type) { - if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var _loop_25 = function (type) { + if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { if (!isLiteralType(discriminant)) { @@ -69988,7 +70218,7 @@ var ts; }; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var type = types_15[_i]; - var state_9 = _loop_24(type); + var state_9 = _loop_25(type); if (typeof state_9 === "object") return state_9.value; } @@ -69999,15 +70229,15 @@ var ts; function getKeyPropertyName(unionType) { var types = unionType.types; // We only construct maps for unions with many non-primitive constituents. - if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* PrimitiveUnion */ || - ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) { + if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* ObjectFlags.PrimitiveUnion */ || + ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)); }) < 10) { return undefined; } if (unionType.keyPropertyName === undefined) { // The candidate key property name is the name of the first property with a unit type in one of the // constituent types. var keyPropertyName = ts.forEach(types, function (t) { - return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ? + return t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : undefined; }); @@ -70031,7 +70261,7 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); @@ -70048,7 +70278,7 @@ var ts; } } } - if (expression.expression.kind === 206 /* PropertyAccessExpression */ && + if (expression.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -70062,7 +70292,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -70077,23 +70307,25 @@ var ts; // For example, when a variable of type number | string | boolean is assigned a value of type number | boolean, // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { - if (declaredType !== assignedType) { - if (assignedType.flags & 131072 /* Never */) { - return assignedType; - } - var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) { - reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types - } - // Our crude heuristic produces an invalid result in some cases: see GH#26130. - // For now, when that happens, we give up and don't narrow at all. (This also - // means we'll never narrow for erroneous assignments where the assigned type - // is not assignable to the declared type.) - if (isTypeAssignableTo(assignedType, reducedType)) { - return reducedType; - } + var _a; + if (declaredType === assignedType) { + return declaredType; } - return declaredType; + if (assignedType.flags & 131072 /* TypeFlags.Never */) { + return assignedType; + } + var key = "A".concat(getTypeId(declaredType), ",").concat(getTypeId(assignedType)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType)); + } + function getAssignmentReducedTypeWorker(declaredType, assignedType) { + var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); + // Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type. + var reducedType = assignedType.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType; + // Our crude heuristic produces an invalid result in some cases: see GH#26130. + // For now, when that happens, we give up and don't narrow at all. (This also + // means we'll never narrow for erroneous assignments where the assigned type + // is not assignable to the declared type.) + return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType; } function isFunctionObjectType(type) { // We do a quick check for a "bind" property before performing the more expensive subtype @@ -70103,95 +70335,95 @@ var ts; resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { - if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) { + if (type.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */)) { type = getBaseConstraintOfType(type) || unknownType; } var flags = type.flags; - if (flags & (4 /* String */ | 268435456 /* StringMapping */)) { - return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; + if (flags & (4 /* TypeFlags.String */ | 268435456 /* TypeFlags.StringMapping */)) { + return strictNullChecks ? 16317953 /* TypeFacts.StringStrictFacts */ : 16776705 /* TypeFacts.StringFacts */; } - if (flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) { - var isEmpty = flags & 128 /* StringLiteral */ && type.value === ""; + if (flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + var isEmpty = flags & 128 /* TypeFlags.StringLiteral */ && type.value === ""; return strictNullChecks ? - isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : - isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* TypeFacts.EmptyStringStrictFacts */ : 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* TypeFacts.EmptyStringFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; + if (flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */)) { + return strictNullChecks ? 16317698 /* TypeFacts.NumberStrictFacts */ : 16776450 /* TypeFacts.NumberFacts */; } - if (flags & 256 /* NumberLiteral */) { + if (flags & 256 /* TypeFlags.NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : - isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + isZero ? 12123394 /* TypeFacts.ZeroNumberStrictFacts */ : 7929090 /* TypeFacts.NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* TypeFacts.ZeroNumberFacts */ : 16776450 /* TypeFacts.NonZeroNumberFacts */; } - if (flags & 64 /* BigInt */) { - return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + if (flags & 64 /* TypeFlags.BigInt */) { + return strictNullChecks ? 16317188 /* TypeFacts.BigIntStrictFacts */ : 16775940 /* TypeFacts.BigIntFacts */; } - if (flags & 2048 /* BigIntLiteral */) { + if (flags & 2048 /* TypeFlags.BigIntLiteral */) { var isZero = isZeroBigInt(type); return strictNullChecks ? - isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : - isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; + isZero ? 12122884 /* TypeFacts.ZeroBigIntStrictFacts */ : 7928580 /* TypeFacts.NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* TypeFacts.ZeroBigIntFacts */ : 16775940 /* TypeFacts.NonZeroBigIntFacts */; } - if (flags & 16 /* Boolean */) { - return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; + if (flags & 16 /* TypeFlags.Boolean */) { + return strictNullChecks ? 16316168 /* TypeFacts.BooleanStrictFacts */ : 16774920 /* TypeFacts.BooleanFacts */; } - if (flags & 528 /* BooleanLike */) { + if (flags & 528 /* TypeFlags.BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* TypeFacts.FalseStrictFacts */ : 7927560 /* TypeFacts.TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* TypeFacts.FalseFacts */ : 16774920 /* TypeFacts.TrueFacts */; } - if (flags & 524288 /* Object */) { - return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : + if (flags & 524288 /* TypeFlags.Object */) { + return ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && isEmptyObjectType(type) ? + strictNullChecks ? 83427327 /* TypeFacts.EmptyObjectStrictFacts */ : 83886079 /* TypeFacts.EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : - strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + strictNullChecks ? 7880640 /* TypeFacts.FunctionStrictFacts */ : 16728000 /* TypeFacts.FunctionFacts */ : + strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 16384 /* Void */) { - return 9830144 /* VoidFacts */; + if (flags & 16384 /* TypeFlags.Void */) { + return 9830144 /* TypeFacts.VoidFacts */; } - if (flags & 32768 /* Undefined */) { - return 26607360 /* UndefinedFacts */; + if (flags & 32768 /* TypeFlags.Undefined */) { + return 26607360 /* TypeFacts.UndefinedFacts */; } - if (flags & 65536 /* Null */) { - return 42917664 /* NullFacts */; + if (flags & 65536 /* TypeFlags.Null */) { + return 42917664 /* TypeFacts.NullFacts */; } - if (flags & 12288 /* ESSymbolLike */) { - return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; + if (flags & 12288 /* TypeFlags.ESSymbolLike */) { + return strictNullChecks ? 7925520 /* TypeFacts.SymbolStrictFacts */ : 16772880 /* TypeFacts.SymbolFacts */; } - if (flags & 67108864 /* NonPrimitive */) { - return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + if (flags & 67108864 /* TypeFlags.NonPrimitive */) { + return strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 131072 /* Never */) { - return 0 /* None */; + if (flags & 131072 /* TypeFlags.Never */) { + return 0 /* TypeFacts.None */; } - if (flags & 1048576 /* Union */) { - return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* None */); + if (flags & 1048576 /* TypeFlags.Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* TypeFacts.None */); } - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionTypeFacts(type); } - return 83886079 /* UnknownFacts */; + return 83886079 /* TypeFacts.UnknownFacts */; } function getIntersectionTypeFacts(type) { // When an intersection contains a primitive type we ignore object type constituents as they are // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type. - var ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */); + var ignoreObjects = maybeTypeOfKind(type, 131068 /* TypeFlags.Primitive */); // When computing the type facts of an intersection type, certain type facts are computed as `and` // and others are computed as `or`. - var oredFacts = 0 /* None */; - var andedFacts = 134217727 /* All */; + var oredFacts = 0 /* TypeFacts.None */; + var andedFacts = 134217727 /* TypeFacts.All */; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (!(ignoreObjects && t.flags & 524288 /* Object */)) { + if (!(ignoreObjects && t.flags & 524288 /* TypeFlags.Object */)) { var f = getTypeFacts(t); oredFacts |= f; andedFacts &= f; } } - return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */; + return oredFacts & 8256 /* TypeFacts.OrFactsMask */ | andedFacts & 134209471 /* TypeFacts.AndFactsMask */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -70200,16 +70432,16 @@ var ts; // unknown with the union {} | null | undefined (and reduces that accordingly), and it intersects remaining // instantiable types with {}, {} | null, or {} | undefined in order to remove null and/or undefined. function getAdjustedTypeWithFacts(type, facts) { - var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts)); + var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */ ? unknownUnionType : type, facts)); if (strictNullChecks) { switch (facts) { - case 524288 /* NEUndefined */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; }); - case 1048576 /* NENull */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; }); - case 2097152 /* NEUndefinedOrNull */: - case 4194304 /* Truthy */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; }); + case 524288 /* TypeFacts.NEUndefined */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* TypeFacts.EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* TypeFacts.EQNull */ && !maybeTypeOfKind(reduced, 65536 /* TypeFlags.Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; }); + case 1048576 /* TypeFacts.NENull */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* TypeFacts.EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* TypeFacts.EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* TypeFlags.Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; }); + case 2097152 /* TypeFacts.NEUndefinedOrNull */: + case 4194304 /* TypeFacts.Truthy */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; }); } } return reduced; @@ -70232,7 +70464,7 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || - includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || + includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || errorType; } function includeUndefinedInIndexSignature(type) { @@ -70243,18 +70475,18 @@ var ts; type; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); + return createArrayType(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 204 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 221 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 244 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -70271,21 +70503,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return stringType; - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return undefinedType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -70293,7 +70525,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 201 /* ObjectBindingPattern */ ? + var type = pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -70311,37 +70543,37 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 243 /* ForInStatement */) { + if (node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 254 /* VariableDeclaration */ ? + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 254 /* VariableDeclaration */ && node.initializer && + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 203 /* BindingElement */ && node.parent.kind === 221 /* BinaryExpression */ && + node.kind !== 203 /* SyntaxKind.BindingElement */ && node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return getReferenceCandidate(node.right); } } @@ -70349,13 +70581,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 212 /* ParenthesizedExpression */ || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.left === node || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -70374,25 +70606,25 @@ var ts; // Get the type names from all cases in a switch on `typeof`. The default clause and/or duplicate type names are // represented as undefined. Return undefined if one or more case clause expressions are not string literals. function getSwitchClauseTypeOfWitnesses(switchStatement) { - if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) { + if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* SyntaxKind.CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) { return undefined; } var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - var text = clause.kind === 289 /* CaseClause */ ? clause.expression.text : undefined; + var text = clause.kind === 289 /* SyntaxKind.CaseClause */ ? clause.expression.text : undefined; witnesses.push(text && !ts.contains(witnesses, text) ? text : undefined); } return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 1048576 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* TypeFlags.Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* TypeFlags.Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -70401,25 +70633,25 @@ var ts; } return true; } - if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* TypeFlags.EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.forEach(type.types, f) : f(type); } function someType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.every(type.types, f) : f(type); } function everyContainedType(type, f) { - return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var types = type.types; var filtered = ts.filter(types, f); if (filtered === types) { @@ -70427,45 +70659,45 @@ var ts; } var origin = type.origin; var newOrigin = void 0; - if (origin && origin.flags & 1048576 /* Union */) { + if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { // If the origin type is a (denormalized) union type, filter its non-union constituents. If that ends // up removing a smaller number of types than in the normalized constituent set (meaning some of the // filtered types are within nested unions in the origin), then we can't construct a new origin type. // Otherwise, if we have exactly one type left in the origin set, return that as the filtered type. // Otherwise, construct a new filtered origin type. var originTypes = origin.types; - var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* Union */) || f(t); }); + var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) || f(t); }); if (originTypes.length - originFiltered.length === types.length - filtered.length) { if (originFiltered.length === 1) { return originFiltered[0]; } - newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + newOrigin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, originFiltered); } } return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } - return type.flags & 131072 /* Never */ || f(type) ? type : neverType; + return type.flags & 131072 /* TypeFlags.Never */ || f(type) ? type : neverType; } function removeType(type, targetType) { return filterType(type, function (t) { return t !== targetType; }); } function countTypes(type) { - return type.flags & 1048576 /* Union */ ? type.types.length : 1; + return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1; } function mapType(type, mapper, noReductions) { - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return type; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return mapper(type); } var origin = type.origin; - var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types; + var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? origin.types : type.types; var mappedTypes; var changed = false; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; - var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t); + var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { if (!mappedTypes) { @@ -70476,11 +70708,11 @@ var ts; } } } - return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; + return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type; } function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { - return type.flags & 1048576 /* Union */ && aliasSymbol ? - getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper); } function extractTypesOfKind(type, kind) { @@ -70492,13 +70724,13 @@ var ts; // true intersection because it is more costly and, when applied to union types, generates a large number of // types we don't actually care about. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && - maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) { + if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) && + maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : - isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; + return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) : + isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) : + t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) : + t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -70510,14 +70742,14 @@ var ts; return flowType.flags === 0 ? flowType.type : flowType; } function createFlowType(type, incomplete) { - return incomplete ? { flags: 0, type: type.flags & 131072 /* Never */ ? silentNeverType : type } : type; + return incomplete ? { flags: 0, type: type.flags & 131072 /* TypeFlags.Never */ ? silentNeverType : type } : type; } // An evolving array type tracks the element types that have so far been seen in an // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(256 /* EvolvingArray */); + var result = createObjectType(256 /* ObjectFlags.EvolvingArray */); result.elementType = elementType; return result; } @@ -70532,10 +70764,10 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 131072 /* Never */ ? + return elementType.flags & 131072 /* TypeFlags.Never */ ? autoArrayType : - createArrayType(elementType.flags & 1048576 /* Union */ ? - getUnionType(elementType.types, 2 /* Subtype */) : + createArrayType(elementType.flags & 1048576 /* TypeFlags.Union */ ? + getUnionType(elementType.types, 2 /* UnionReduction.Subtype */) : elementType); } // We perform subtype reduction upon obtaining the final array type from an evolving array type. @@ -70543,17 +70775,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { var t = types_17[_i]; - if (!(t.flags & 131072 /* Never */)) { - if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + if (!(ts.getObjectFlags(t) & 256 /* ObjectFlags.EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -70567,16 +70799,16 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 208 /* CallExpression */ + parent.parent.kind === 208 /* SyntaxKind.CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 207 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 221 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 63 /* EqualsToken */ && + parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* TypeFlags.NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(node) { @@ -70585,11 +70817,11 @@ var ts; ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer)); } function getExplicitTypeOfSymbol(symbol, diagnostic) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { + if (ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */) { var origin = symbol.syntheticOrigin; if (origin && getExplicitTypeOfSymbol(origin)) { return getTypeOfSymbol(symbol); @@ -70600,11 +70832,11 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); } } @@ -70619,16 +70851,16 @@ var ts; // parameter symbols with declarations that have explicit type annotations. Such references are // resolvable with no possibility of triggering circularities in control flow analysis. function getTypeOfDottedName(node, diagnostic) { - if (!(node.flags & 33554432 /* InWithStatement */)) { + if (!(node.flags & 33554432 /* NodeFlags.InWithStatement */)) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); - return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 108 /* ThisKeyword */: + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 108 /* SyntaxKind.ThisKeyword */: return getExplicitThisType(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 206 /* PropertyAccessExpression */: { + case 206 /* SyntaxKind.PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -70646,7 +70878,7 @@ var ts; } return undefined; } - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -70660,10 +70892,10 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 106 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -70671,7 +70903,7 @@ var ts; funcType = checkNonNullExpression(node.expression); } } - var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* SignatureKind.Call */); var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : undefined; @@ -70681,10 +70913,10 @@ var ts; } function hasTypePredicateOrNeverReturnType(signature) { return !!(getTypePredicateOfSignature(signature) || - signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* TypeFlags.Never */); } function getTypePredicateArgument(predicate, callExpression) { - if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + if (predicate.kind === 1 /* TypePredicateKind.Identifier */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { return callExpression.arguments[predicate.parameterIndex]; } var invokedExpression = ts.skipParentheses(callExpression.expression); @@ -70704,8 +70936,8 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 95 /* FalseKeyword */ || node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || - node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + return node.kind === 95 /* SyntaxKind.FalseKeyword */ || node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { while (true) { @@ -70713,7 +70945,7 @@ var ts; return lastFlowNodeReachable; } var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var reachable = flowNodeReachable[id]; @@ -70721,30 +70953,30 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && predicate.kind === 3 /* AssertsIdentifier */ && !predicate.type) { + if (predicate && predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && !predicate.type) { var predicateArgument = flow.node.arguments[predicate.parameterIndex]; if (predicateArgument && isFalseExpression(predicateArgument)) { return false; } } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return false; } } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is reachable if any branch is reachable. return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { var antecedents = flow.antecedents; if (antecedents === undefined || antecedents.length === 0) { return false; @@ -70752,7 +70984,7 @@ var ts; // A loop is reachable if the control flow path that leads to the top is reachable. flow = antecedents[0]; } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { // The control flow path representing an unmatched value in a switch statement with // no default clause is unreachable if the switch statement is exhaustive. if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { @@ -70760,7 +70992,7 @@ var ts; } flow = flow.antecedent; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { // Cache is unreliable once we start adjusting labels lastFlowNode = undefined; var target = flow.target; @@ -70771,7 +71003,7 @@ var ts; return result; } else { - return !(flags & 1 /* Unreachable */); + return !(flags & 1 /* FlowFlags.Unreachable */); } } } @@ -70780,7 +71012,7 @@ var ts; function isPostSuperFlowNode(flow, noCacheCheck) { while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var postSuper = flowNodePostSuper[id]; @@ -70788,24 +71020,24 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 128 /* SwitchClause */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */ | 128 /* FlowFlags.SwitchClause */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 106 /* SuperKeyword */) { + else if (flags & 512 /* FlowFlags.Call */) { + if (flow.node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return true; } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is post-super if every branch is post-super. return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { // A loop is post-super if the control flow path that leads to the top is post-super. flow = flow.antecedents[0]; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; @@ -70815,18 +71047,18 @@ var ts; } else { // Unreachable nodes are considered post-super to silence errors - return !!(flags & 1 /* Unreachable */); + return !!(flags & 1 /* FlowFlags.Unreachable */); } } } function isConstantReference(node) { switch (node.kind) { - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var symbol = getResolvedSymbol(node); return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); } @@ -70852,8 +71084,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* ObjectFlags.EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* SyntaxKind.NonNullExpression */ && !(resultType.flags & 131072 /* TypeFlags.Never */) && getTypeWithFacts(resultType, 2097152 /* TypeFacts.NEUndefinedOrNull */).flags & 131072 /* TypeFlags.Never */) { return declaredType; } // The non-null unknown type should never escape control flow analysis. @@ -70869,7 +71101,7 @@ var ts; if (flowDepth === 2000) { // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error // and disable further control flow analysis in the containing function or module body. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -70878,7 +71110,7 @@ var ts; var sharedFlow; while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -70891,56 +71123,56 @@ var ts; sharedFlow = flow; } var type = void 0; - if (flags & 16 /* Assignment */) { + if (flags & 16 /* FlowFlags.Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { type = getTypeAtFlowCall(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 96 /* Condition */) { + else if (flags & 96 /* FlowFlags.Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flags & 12 /* Label */) { + else if (flags & 12 /* FlowFlags.Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flags & 4 /* BranchLabel */ ? + type = flags & 4 /* FlowFlags.BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* FlowFlags.ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; type = getTypeAtFlowNode(flow.antecedent); target.antecedents = saveAntecedents; } - else if (flags & 2 /* Start */) { + else if (flags & 2 /* FlowFlags.Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 206 /* PropertyAccessExpression */ && - reference.kind !== 207 /* ElementAccessExpression */ && - reference.kind !== 108 /* ThisKeyword */) { + reference.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && + reference.kind !== 207 /* SyntaxKind.ElementAccessExpression */ && + reference.kind !== 108 /* SyntaxKind.ThisKeyword */) { flow = container.flowNode; continue; } @@ -70964,7 +71196,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -70976,7 +71208,7 @@ var ts; if (!isReachableFlowNode(flow)) { return unreachableNeverType; } - if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { + if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -70987,7 +71219,7 @@ var ts; var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* TypeFlags.Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; @@ -71004,29 +71236,29 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 213 /* FunctionExpression */ || init.kind === 214 /* ArrowFunction */)) { + if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { - return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)))); } // Assignment doesn't affect reference return undefined; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - if (node.kind === 95 /* FalseKeyword */) { + if (node.kind === 95 /* SyntaxKind.FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 221 /* BinaryExpression */) { - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } - if (node.operatorToken.kind === 56 /* BarBarToken */) { + if (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); } } @@ -71036,15 +71268,15 @@ var ts; var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + if (predicate && (predicate.kind === 2 /* TypePredicateKind.AssertsThis */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = finalizeEvolvingArrayType(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]) : + predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return unreachableNeverType; } } @@ -71053,15 +71285,15 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 208 /* CallExpression */ ? + var expr = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { + if (ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -71070,7 +71302,7 @@ var ts; else { // We must get the context free expression type so as to not recur in an uncached fashion on the LHS (which causes exponential blowup in compile time) var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -71084,7 +71316,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -71094,7 +71326,7 @@ var ts; // have the complete type. We proceed by switching to the silent never type which // doesn't report errors when operators are applied to it. Note that this is the // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { @@ -71109,16 +71341,16 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 216 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* TypeFlags.Undefined */ | 131072 /* TypeFlags.Never */)); }); } - else if (expr.kind === 216 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* TypeFlags.Never */ || t.flags & 128 /* TypeFlags.StringLiteral */ && t.value === "undefined"); }); } } var access = getDiscriminantPropertyAccess(expr, type); @@ -71135,7 +71367,7 @@ var ts; var bypassFlow; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { + if (!bypassFlow && antecedent.flags & 128 /* FlowFlags.SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { // The antecedent is the bypass branch of a potentially exhaustive switch statement. bypassFlow = antecedent; continue; @@ -71179,7 +71411,7 @@ var ts; } } } - return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -71205,7 +71437,7 @@ var ts; // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { - return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* Literal */), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* UnionReduction.Literal */), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -71258,7 +71490,7 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } @@ -71273,7 +71505,7 @@ var ts; return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))); } var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction)); - if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) { + if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* TypeFlags.Union */ && ts.arraysEqual(result.types, declaredType.types)) { return declaredType; } return result; @@ -71319,8 +71551,8 @@ var ts; return undefined; } function getDiscriminantPropertyAccess(expr, computedType) { - var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + var type = declaredType.flags & 1048576 /* TypeFlags.Union */ ? declaredType : computedType; + if (type.flags & 1048576 /* TypeFlags.Union */) { var access = getCandidateDiscriminantPropertyAccess(expr); if (access) { var name = getAccessedPropertyName(access); @@ -71336,8 +71568,8 @@ var ts; if (propName === undefined) { return type; } - var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); - var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* TypeFlags.Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } @@ -71345,16 +71577,16 @@ var ts; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); - return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType); + return !(narrowedPropType.flags & 131072 /* TypeFlags.Never */) && isTypeComparableTo(narrowedPropType, discriminantType); }); } function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { - if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + if ((operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* TypeFlags.Union */) { var keyPropertyName = getKeyPropertyName(type); if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); if (candidate) { - return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate : + return operator === (assumeTrue ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) ? candidate : isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) : type; } @@ -71363,7 +71595,7 @@ var ts; return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); }); } function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) { - if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { + if (clauseStart < clauseEnd && type.flags & 1048576 /* TypeFlags.Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); if (candidate !== unknownType) { @@ -71374,51 +71606,51 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); + return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { - type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + type = getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); }); } return type; } function isTypePresencePossible(type, propName, assumeTrue) { var prop = getPropertyOfType(type, propName); if (prop) { - return prop.flags & 16777216 /* Optional */ ? true : assumeTrue; + return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue; } return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue; } function narrowByInKeyword(type, name, assumeTrue) { - if (type.flags & 1048576 /* Union */ - || type.flags & 524288 /* Object */ && declaredType !== type + if (type.flags & 1048576 /* TypeFlags.Union */ + || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type || ts.isThisTypeParameter(type) - || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { + || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); }); } return type; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -71450,35 +71682,35 @@ var ts; return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (ts.isPrivateIdentifier(expr.left)) { return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue); } var target = getReferenceCandidate(expr.right); var leftType = getTypeOfNode(expr.left); - if (leftType.flags & 128 /* StringLiteral */) { + if (leftType.flags & 128 /* TypeFlags.StringLiteral */) { var name = ts.escapeLeadingUnderscores(leftType.value); if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && getAccessedPropertyName(reference) === name) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } if (isMatchingReference(reference, target)) { return narrowByInKeyword(type, name, assumeTrue); } } break; - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return narrowType(type, expr.right, assumeTrue); // Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those // expressions down to individual conditional control flows. However, we may encounter them when analyzing // aliased conditional expressions. - case 55 /* AmpersandAmpersandToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: return assumeTrue ? narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) : getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]); - case 56 /* BarBarToken */: + case 56 /* SyntaxKind.BarBarToken */: return assumeTrue ? getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) : narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); @@ -71499,7 +71731,7 @@ var ts; var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true); } function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { // We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows: @@ -71511,45 +71743,45 @@ var ts; // When operator is !== and type of value is undefined, null and undefined is removed from type of obj in true branch. // When operator is == and type of value is null or undefined, null and undefined is removed from type of obj in false branch. // When operator is != and type of value is null or undefined, null and undefined is removed from type of obj in true branch. - var equalsOperator = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; - var nullableFlags = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */; + var equalsOperator = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; + var nullableFlags = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? 98304 /* TypeFlags.Nullable */ : 32768 /* TypeFlags.Undefined */; var valueType = getTypeOfExpression(value); // Note that we include any and unknown in the exclusion test because their domain includes null and undefined. var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) || - equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); }); - return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* TypeFlags.AnyOrUnknown */ | nullableFlags)); }); + return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeByEquality(type, operator, value, assumeTrue) { - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { return type; } - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { - if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && assumeTrue && (operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { + if (valueType.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { return valueType; } - if (valueType.flags & 524288 /* Object */) { + if (valueType.flags & 524288 /* TypeFlags.Object */) { return nonPrimitiveType; } return type; } - if (valueType.flags & 98304 /* Nullable */) { + if (valueType.flags & 98304 /* TypeFlags.Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : - valueType.flags & 65536 /* Null */ ? - assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : - assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; + assumeTrue ? 262144 /* TypeFacts.EQUndefinedOrNull */ : 2097152 /* TypeFacts.NEUndefinedOrNull */ : + valueType.flags & 65536 /* TypeFlags.Null */ ? + assumeTrue ? 131072 /* TypeFacts.EQNull */ : 1048576 /* TypeFacts.NENull */ : + assumeTrue ? 65536 /* TypeFacts.EQUndefined */ : 524288 /* TypeFacts.NEUndefined */; return getAdjustedTypeWithFacts(type, facts); } if (assumeTrue) { - var filterFn = operator === 34 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); @@ -71561,23 +71793,23 @@ var ts; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { - return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } return assumeTrue ? narrowTypeByTypeName(type, literal.text) : - getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */); + getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeFacts.TypeofNEHostObject */); } function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); - return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify @@ -71590,16 +71822,16 @@ var ts; } var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); - if ((type.flags & 2 /* Unknown */) && !hasDefaultClause) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && !hasDefaultClause) { var groundClauseTypes = void 0; for (var i = 0; i < clauseTypes.length; i += 1) { var t = clauseTypes[i]; - if (t.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if (t.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { if (groundClauseTypes !== undefined) { groundClauseTypes.push(t); } } - else if (t.flags & 524288 /* Object */) { + else if (t.flags & 524288 /* TypeFlags.Object */) { if (groundClauseTypes === undefined) { groundClauseTypes = clauseTypes.slice(0, i); } @@ -71612,26 +71844,26 @@ var ts; return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes); } var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* TypeFlags.Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); - return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]); } function narrowTypeByTypeName(type, typeName) { switch (typeName) { - case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeofEQString */); - case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeofEQNumber */); - case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeofEQBigInt */); - case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeofEQBoolean */); - case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeofEQSymbol */); - case "object": return type.flags & 1 /* Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* EQNull */)]); - case "function": return type.flags & 1 /* Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeofEQFunction */); - case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* EQUndefined */); + case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeFacts.TypeofEQString */); + case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeFacts.TypeofEQNumber */); + case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeFacts.TypeofEQBigInt */); + case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeFacts.TypeofEQBoolean */); + case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeFacts.TypeofEQSymbol */); + case "object": return type.flags & 1 /* TypeFlags.Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeFacts.TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* TypeFacts.EQNull */)]); + case "function": return type.flags & 1 /* TypeFlags.Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeFacts.TypeofEQFunction */); + case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* TypeFacts.EQUndefined */); } - return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */); + return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeFacts.TypeofEQHostObject */); } function narrowTypeByTypeFacts(type, impliedType, facts) { return mapType(type, function (t) { @@ -71656,7 +71888,7 @@ var ts; return type; } // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause. - var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* DefaultClause */; }); + var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* SyntaxKind.DefaultClause */; }); var hasDefaultClause = clauseStart === clauseEnd || (defaultIndex >= clauseStart && defaultIndex < clauseEnd); if (hasDefaultClause) { // In the default clause we filter constituents down to those that are not-equal to all handled cases. @@ -71674,7 +71906,7 @@ var ts; } function narrowTypeByConstructor(type, operator, identifier, assumeTrue) { // Do not narrow when checking inequality. - if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) { + if (assumeTrue ? (operator !== 34 /* SyntaxKind.EqualsEqualsToken */ && operator !== 36 /* SyntaxKind.EqualsEqualsEqualsToken */) : (operator !== 35 /* SyntaxKind.ExclamationEqualsToken */ && operator !== 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { return type; } // Get the type of the constructor identifier expression, if it is not a function then do not narrow. @@ -71704,8 +71936,8 @@ var ts; // This is because you may have a class `A` that defines some set of properties, and another class `B` // that defines the same set of properties as class `A`, in that case they are structurally the same // type, but when you do something like `instanceOfA.constructor === B` it will return false. - if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ || - target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) { + if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ || + target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { return source.symbol === target.symbol; } // For all other types just check that the `source` type is a subtype of the `target` type. @@ -71716,7 +71948,7 @@ var ts; var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { - return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } @@ -71739,46 +71971,65 @@ var ts; return type; } if (!targetType) { - var constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(rightType, 1 /* SignatureKind.Construct */); targetType = constructSignatures.length ? getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) : emptyObjectType; } // We can't narrow a union based off instanceof without negated types see #31576 for more info - if (!assumeTrue && rightType.flags & 1048576 /* Union */) { + if (!assumeTrue && rightType.flags & 1048576 /* TypeFlags.Union */) { var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); }); if (!nonConstructorTypeInUnion) return type; } - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true); } - function getNarrowedType(type, candidate, assumeTrue, isRelated) { + function getNarrowedType(type, candidate, assumeTrue, checkDerived) { + var _a; + var key = type.flags & 1048576 /* TypeFlags.Union */ ? "N".concat(getTypeId(type), ",").concat(getTypeId(candidate), ",").concat((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined; + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived)); + } + function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) { + var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf; if (!assumeTrue) { return filterType(type, function (t) { return !isRelated(t, candidate); }); } - // If the current type is a union type, remove all constituents that couldn't be instances of - // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 1048576 /* Union */) { - var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072 /* Never */)) { - return assignableType; - } + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { + return candidate; } - // If the candidate type is a subtype of the target type, narrow to the candidate type. - // Otherwise, if the target type is assignable to the candidate type, keep the target type. - // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate - // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the - // two types. - return isTypeSubtypeOf(candidate, type) ? candidate : - isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, type) ? candidate : - getIntersectionType([type, candidate]); + // We first attempt to filter the current type, narrowing constituents as appropriate and removing + // constituents that are unrelated to the candidate. + var keyPropertyName = type.flags & 1048576 /* TypeFlags.Union */ ? getKeyPropertyName(type) : undefined; + var narrowedType = mapType(candidate, function (c) { + // If a discriminant property is available, use that to reduce the type. + var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName); + var matching = discriminant && getConstituentTypeForKeyType(type, discriminant); + // For each constituent t in the current type, if t and and c are directly related, pick the most + // specific of the two. When t and c are related in both directions, we prefer c for type predicates + // because that is the asserted type, but t for `instanceof` because generics aren't reflected in + // prototype object types. + var directlyRelated = mapType(matching || type, checkDerived ? + function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } : + function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; }); + // If no constituents are directly related, create intersections for any generic constituents that + // are related by constraint. + return directlyRelated.flags & 131072 /* TypeFlags.Never */ ? + mapType(type, function (t) { return maybeTypeOfKind(t, 465829888 /* TypeFlags.Instantiable */) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType; }) : + directlyRelated; + }); + // If filtering produced a non-empty type, return that. Otherwise, pick the most specific of the two + // based on assignability, or as a last resort produce an intersection. + return !(narrowedType.flags & 131072 /* TypeFlags.Never */) ? narrowedType : + isTypeSubtypeOf(candidate, type) ? candidate : + isTypeAssignableTo(type, candidate) ? type : + isTypeAssignableTo(candidate, type) ? candidate : + getIntersectionType([type, candidate]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; var predicate = signature && getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + if (predicate && (predicate.kind === 0 /* TypePredicateKind.This */ || predicate.kind === 1 /* TypePredicateKind.Identifier */)) { return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } @@ -71788,7 +72039,7 @@ var ts; ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) { var argument = callExpression.arguments[0]; if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } } } @@ -71800,15 +72051,15 @@ var ts; var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && - !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { - type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + !(getTypeFacts(predicate.type) & 65536 /* TypeFacts.EQUndefined */)) { + type = getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); }); } } } @@ -71819,11 +72070,11 @@ var ts; function narrowType(type, expr, assumeTrue) { // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` if (ts.isExpressionOfOptionalChainRoot(expr) || - ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */ && expr.parent.left === expr) { return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline // up to five levels of aliased conditional expressions that are themselves declared as const variables. if (!isMatchingReference(reference, expr) && inlineLevel < 5) { @@ -71839,20 +72090,20 @@ var ts; } } // falls through - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 219 /* PrefixUnaryExpression */: - if (expr.operator === 53 /* ExclamationToken */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (expr.operator === 53 /* SyntaxKind.ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -71861,11 +72112,11 @@ var ts; } function narrowTypeByOptionality(type, expr, assumePresent) { if (isMatchingReference(reference, expr)) { - return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); }); } return type; } @@ -71876,7 +72127,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { + if (location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -71900,9 +72151,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 262 /* ModuleBlock */ || - node.kind === 305 /* SourceFile */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 262 /* SyntaxKind.ModuleBlock */ || + node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; }); } // Check if a parameter or catch variable is assigned anywhere @@ -71912,8 +72163,8 @@ var ts; } var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(parent); - if (!(links.flags & 8388608 /* AssignmentsMarked */)) { - links.flags |= 8388608 /* AssignmentsMarked */; + if (!(links.flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */)) { + links.flags |= 8388608 /* NodeCheckFlags.AssignmentsMarked */; if (!hasParentWithAssignmentsMarked(parent)) { markNodeAssignments(parent); } @@ -71922,11 +72173,11 @@ var ts; } function hasParentWithAssignmentsMarked(node) { return !!ts.findAncestor(node.parent, function (node) { - return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); + return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */); }); } function markNodeAssignments(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); if (ts.isParameterOrCatchClauseVariable(symbol)) { @@ -71939,18 +72190,18 @@ var ts; } } function isConstVariable(symbol) { - return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0; + return symbol.flags & 3 /* SymbolFlags.Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */) !== 0; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { - if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { + if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 164 /* Parameter */ && + declaration.kind === 164 /* SyntaxKind.Parameter */ && declaration.initializer && - getTypeFacts(declaredType) & 16777216 /* IsUndefined */ && - !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* IsUndefined */); + getTypeFacts(declaredType) & 16777216 /* TypeFacts.IsUndefined */ && + !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* TypeFacts.IsUndefined */); popTypeResolution(); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType; } else { reportCircularityError(declaration.symbol); @@ -71962,19 +72213,19 @@ var ts; // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of // a generic type without a nullable constraint and x is a generic type. This is because when both obj // and x are of generic types T and K, we want the resulting type to be T[K]. - return parent.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 161 /* QualifiedName */ || - parent.kind === 208 /* CallExpression */ && parent.expression === node || - parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node && + return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 161 /* SyntaxKind.QualifiedName */ || + parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node || + parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { - return type.flags & 2097152 /* Intersection */ ? + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isGenericTypeWithUnionConstraint) : - !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */)); } function isGenericTypeWithoutNullableConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* TypeFlags.Nullable */)); } function hasContextualTypeWithNoGenericTypes(node, checkMode) { // Computing the contextual type for a child of a JSX element involves resolving the type of the @@ -71983,9 +72234,9 @@ var ts; // as we want the type of a rest element to be generic when possible. var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && - (checkMode && checkMode & 64 /* RestBindingElement */ ? - getContextualType(node, 8 /* SkipBindingPatterns */) - : getContextualType(node)); + (checkMode && checkMode & 64 /* CheckMode.RestBindingElement */ ? + getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) + : getContextualType(node, /*contextFlags*/ undefined)); return contextualType && !isGenericType(contextualType); } function getNarrowableTypeForReference(type, reference, checkMode) { @@ -71996,7 +72247,7 @@ var ts; // control flow analysis an opportunity to narrow it further. For example, for a reference of a type // parameter type 'T extends string | undefined' with a contextual type 'string', we substitute // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. - var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && + var substituteConstraints = !(checkMode && checkMode & 2 /* CheckMode.Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode)); return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type; @@ -72017,9 +72268,9 @@ var ts; }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled // (because the const enum value will not be inlined), or if (2) the alias is an export // of a const enum declaration that will be preserved. @@ -72062,16 +72313,16 @@ var ts; // destructuring from the narrowed parent type. if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { var parent = declaration.parent.parent; - if (parent.kind === 254 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 164 /* Parameter */) { + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || parent.kind === 164 /* SyntaxKind.Parameter */) { var links = getNodeLinks(parent); - if (!(links.flags & 268435456 /* InCheckIdentifier */)) { - links.flags |= 268435456 /* InCheckIdentifier */; - var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */); - links.flags &= ~268435456 /* InCheckIdentifier */; - if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 164 /* Parameter */ && isSymbolAssigned(symbol))) { + if (!(links.flags & 268435456 /* NodeCheckFlags.InCheckIdentifier */)) { + links.flags |= 268435456 /* NodeCheckFlags.InCheckIdentifier */; + var parentType = getTypeForBindingElementParent(parent, 0 /* CheckMode.Normal */); + links.flags &= ~268435456 /* NodeCheckFlags.InCheckIdentifier */; + if (parentType && parentType.flags & 1048576 /* TypeFlags.Union */ && !(parent.kind === 164 /* SyntaxKind.Parameter */ && isSymbolAssigned(symbol))) { var pattern = declaration.parent; var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode); - if (narrowedType.flags & 131072 /* Never */) { + if (narrowedType.flags & 131072 /* TypeFlags.Never */) { return neverType; } return getBindingElementTypeFromParentType(declaration, narrowedType); @@ -72105,7 +72356,7 @@ var ts; var contextualSignature = getContextualSignature(func); if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) { var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0])); - if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { + if (restType.flags & 1048576 /* TypeFlags.Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode); var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0); return getIndexedAccessType(narrowedType, getNumberLiteralType(index)); @@ -72136,20 +72387,18 @@ var ts; return errorType; } var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 214 /* ArrowFunction */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } - else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { + else if (ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; + getNodeLinks(container).flags |= 8192 /* NodeCheckFlags.CaptureArguments */; return getTypeOfSymbol(symbol); } - // We should only mark aliases as referenced if there isn't a local value declaration - // for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that - if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) { + if (shouldMarkIdentifierAliasReferenced(node)) { markAliasReferenced(symbol, node); } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); @@ -72158,32 +72407,32 @@ var ts; addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (declaration && localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 257 /* ClassDeclaration */ + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { if (container === declaration && container.name !== node) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; break; } container = ts.getContainingClass(container); } } - else if (declaration.kind === 226 /* ClassExpression */) { + else if (declaration.kind === 226 /* SyntaxKind.ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 305 /* SourceFile */) { + while (container.kind !== 305 /* SyntaxKind.SourceFile */) { if (container.parent === declaration) { if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; } break; } @@ -72195,19 +72444,19 @@ var ts; var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { - if (!(localOrExportSymbol.flags & 3 /* Variable */) && - !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum - : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class - : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace - : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function - : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import + if (!(localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) && + !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* SymbolFlags.ValueModule */)) { + var assignmentError = localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 /* SymbolFlags.Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { - if (localOrExportSymbol.flags & 3 /* Variable */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol)); } else { @@ -72216,11 +72465,11 @@ var ts; return errorType; } } - var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; + var isAlias = localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */; // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (localOrExportSymbol.flags & 3 /* Variable */) { - if (assignmentKind === 1 /* Definite */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { + if (assignmentKind === 1 /* AssignmentKind.Definite */) { return type; } } @@ -72237,17 +72486,17 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* SyntaxKind.Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - var isModuleExports = symbol.flags & 134217728 /* ModuleExports */; + var isModuleExports = symbol.flags & 134217728 /* SymbolFlags.ModuleExports */; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* FunctionExpression */ || - flowContainer.kind === 214 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* SyntaxKind.FunctionExpression */ || + flowContainer.kind === 214 /* SyntaxKind.ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -72255,11 +72504,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) || - node.parent.kind === 230 /* NonNullExpression */ || - declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 16777216 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) || + node.parent.kind === 230 /* SyntaxKind.NonNullExpression */ || + declaration.kind === 254 /* SyntaxKind.VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 16777216 /* NodeFlags.Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -72283,6 +72532,25 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function shouldMarkIdentifierAliasReferenced(node) { + var _a; + var parent = node.parent; + if (parent) { + // A property access expression LHS? checkPropertyAccessExpression will handle that. + if (ts.isPropertyAccessExpression(parent) && parent.expression === node) { + return false; + } + // Next two check for an identifier inside a type only export. + if (ts.isExportSpecifier(parent) && parent.isTypeOnly) { + return false; + } + var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent; + if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) { + return false; + } + } + return true; + } function isInsideFunctionOrInstancePropertyInitializer(node, threshold) { return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); }); } @@ -72293,11 +72561,11 @@ var ts; return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); }); } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES2015 */ || - (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || + (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 32 /* SymbolFlags.Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 292 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 292 /* SyntaxKind.CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -72312,12 +72580,12 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); - links.flags |= 131072 /* ContainsCapturedBlockScopeBinding */; + links.flags |= 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */; var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []); ts.pushIfUnique(capturedBindings, symbol); if (part === container.initializer) { @@ -72327,22 +72595,22 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { - getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; + getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */; } } // set 'declared inside loop' bit on the block-scoped binding - getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } if (isCaptured) { - getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; } } function isBindingCapturedByNode(node, decl) { @@ -72352,7 +72620,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 212 /* ParenthesizedExpression */) { + while (current.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -72360,9 +72628,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 219 /* PrefixUnaryExpression */ || current.parent.kind === 220 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || current.parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || expr.operator === 46 /* SyntaxKind.MinusMinusToken */; } if (!isAssigned) { return false; @@ -72372,13 +72640,13 @@ var ts; return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 167 /* PropertyDeclaration */ || container.kind === 171 /* Constructor */) { + getNodeLinks(node).flags |= 2 /* NodeCheckFlags.LexicalThis */; + if (container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || container.kind === 171 /* SyntaxKind.Constructor */) { var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + getNodeLinks(classNode).flags |= 4 /* NodeCheckFlags.CaptureThis */; } else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; + getNodeLinks(container).flags |= 4 /* NodeCheckFlags.CaptureThis */; } } function findFirstSuperCall(node) { @@ -72420,36 +72688,36 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 171 /* Constructor */) { + if (container.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 214 /* ArrowFunction */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } // When targeting es6, mark that we'll need to capture `this` in its lexically bound scope. - if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { + if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ScriptTarget.ES2015 */) { captureLexicalThis(node, container); } var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); @@ -72484,7 +72752,7 @@ var ts; var className = getClassNameFromPrototypeMethod(container); if (isInJS && className) { var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* SymbolFlags.Function */)) { thisType = getDeclaredTypeOfSymbol(classSymbol).thisType; } } @@ -72532,9 +72800,9 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 213 /* FunctionExpression */ && + if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isBinaryExpression(container.parent) && - ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' return container.parent // x.prototype.y = container .left // x.prototype.y @@ -72542,31 +72810,31 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 169 /* MethodDeclaration */ && - container.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && + container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 213 /* FunctionExpression */ && - container.parent.kind === 296 /* PropertyAssignment */ && - container.parent.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && + container.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && + container.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.parent.left.expression; } // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 213 /* FunctionExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && ts.isObjectLiteralExpression(container.parent.parent) && ts.isCallExpression(container.parent.parent.parent) && container.parent.parent.parent.arguments[2] === container.parent.parent && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.parent.arguments[0].expression; } // Object.defineProperty(x, "method", { value() { } }); @@ -72578,17 +72846,17 @@ var ts; ts.isObjectLiteralExpression(container.parent) && ts.isCallExpression(container.parent.parent) && container.parent.parent.arguments[2] === container.parent && - ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.arguments[0].expression; } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 317 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 317 /* SyntaxKind.JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && - jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) { + jsDocFunctionType.parameters[0].name.escapedText === "this" /* InternalSymbolName.This */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -72598,18 +72866,18 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* SyntaxKind.Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 208 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 208 /* SyntaxKind.CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 214 /* ArrowFunction */) { + while (container && container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; + needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -72620,14 +72888,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* ComputedPropertyName */; }); - if (current && current.kind === 162 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* SyntaxKind.ComputedPropertyName */; }); + if (current && current.kind === 162 /* SyntaxKind.ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -72635,26 +72903,26 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 171 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.isStatic(container) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; + nodeCheckFlag = 512 /* NodeCheckFlags.SuperStatic */; if (!isCallExpression && - languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && + languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && (ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) { // for `super.x` or `super[x]` in a static initializer, mark all enclosing // block scope containers so that we can report potential collisions with // `Reflect`. ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) { if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) { - getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */; + getNodeLinks(current).flags |= 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */; } }); } } else { - nodeCheckFlag = 256 /* SuperInstance */; + nodeCheckFlag = 256 /* NodeCheckFlags.SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. @@ -72716,12 +72984,12 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 169 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { - getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */; } else { - getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */; } } if (needToCaptureLexicalThis) { @@ -72730,8 +72998,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 205 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES2015 */) { + if (container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; } @@ -72751,12 +73019,12 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 171 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 171 /* SyntaxKind.Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } - return nodeCheckFlag === 512 /* SuperStatic */ + return nodeCheckFlag === 512 /* NodeCheckFlags.SuperStatic */ ? getBaseConstructorTypeOfClass(classType) : getTypeWithThisArgument(baseClassType, classType.thisType); function isLegalUsageOfSuperExpression(container) { @@ -72766,7 +73034,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 171 /* Constructor */; + return container.kind === 171 /* SyntaxKind.Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -72774,23 +73042,23 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { if (ts.isStatic(container)) { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 170 /* ClassStaticBlockDeclaration */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } else { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 166 /* PropertySignature */ || - container.kind === 171 /* Constructor */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 166 /* SyntaxKind.PropertySignature */ || + container.kind === 171 /* SyntaxKind.Constructor */; } } } @@ -72798,22 +73066,22 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 169 /* MethodDeclaration */ || - func.kind === 172 /* GetAccessor */ || - func.kind === 173 /* SetAccessor */) && func.parent.kind === 205 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 213 /* FunctionExpression */ && func.parent.kind === 296 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ || + func.kind === 172 /* SyntaxKind.GetAccessor */ || + func.kind === 173 /* SyntaxKind.SetAccessor */) && func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ? func.parent : + func.kind === 213 /* SyntaxKind.FunctionExpression */ && func.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -72832,7 +73100,7 @@ var ts; // We have an object literal method. Check if the containing object literal has a contextual type // that includes a ThisType. If so, T is the contextual type for 'this'. We continue looking in // any directly enclosing object literals. - var contextualType = getApparentTypeOfContextualType(containingLiteral); + var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined); var literal = containingLiteral; var type = contextualType; while (type) { @@ -72840,11 +73108,11 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 296 /* PropertyAssignment */) { + if (literal.parent.kind !== 296 /* SyntaxKind.PropertyAssignment */) { break; } literal = literal.parent.parent; - type = getApparentTypeOfContextualType(literal); + type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined); } // There was no contextual ThisType for the containing object literal, so the contextual type // for 'this' is the non-null form of the contextual type for the containing object literal or @@ -72854,7 +73122,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -72882,7 +73150,7 @@ var ts; var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* Normal */); + return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; @@ -72901,31 +73169,31 @@ var ts; tryGetTypeAtPosition(contextualSignature, index); } } - function getContextualTypeForVariableLikeDeclaration(declaration) { + function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) { var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); if (typeNode) { return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return getContextuallyTypedParameterType(declaration); - case 203 /* BindingElement */: - return getContextualTypeForBindingElement(declaration); - case 167 /* PropertyDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + return getContextualTypeForBindingElement(declaration, contextFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isStatic(declaration)) { - return getContextualTypeForStaticPropertyDeclaration(declaration); + return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags); } // By default, do nothing and return undefined - only the above cases have context implied by a parent } } - function getContextualTypeForBindingElement(declaration) { + function getContextualTypeForBindingElement(declaration, contextFlags) { var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */); + var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || + parent.kind !== 203 /* SyntaxKind.BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 202 /* ArrayBindingPattern */) { + if (parent.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -72937,8 +73205,8 @@ var ts; return getTypeOfPropertyOfType(parentType, text); } } - function getContextualTypeForStaticPropertyDeclaration(declaration) { - var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent); + function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) { + var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags); if (!parentType) return undefined; return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName); @@ -72954,32 +73222,35 @@ var ts; function getContextualTypeForInitializerExpression(node, contextFlags) { var declaration = node.parent; if (ts.hasInitializer(declaration) && node === declaration.initializer) { - var result = getContextualTypeForVariableLikeDeclaration(declaration); + var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags); if (result) { return result; } - if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) { + if (!(contextFlags & 8 /* ContextFlags.SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) { return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } } return undefined; } - function getContextualTypeForReturnExpression(node) { + function getContextualTypeForReturnExpression(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); - if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function - var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; - var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined); - if (!iterationTypes) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { // Generator or AsyncGenerator function + var isAsyncGenerator_1 = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + if (contextualReturnType.flags & 1048576 /* TypeFlags.Union */) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, type, isAsyncGenerator_1); }); + } + var iterationReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, contextualReturnType, (functionFlags & 2 /* FunctionFlags.Async */) !== 0); + if (!iterationReturnType) { return undefined; } - contextualReturnType = iterationTypes.returnType; + contextualReturnType = iterationReturnType; // falls through to unwrap Promise for AsyncGenerators } - if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function + if (functionFlags & 2 /* FunctionFlags.Async */) { // Async function or AsyncGenerator function // Get the awaited type without the `Awaited` alias var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); @@ -72997,15 +73268,19 @@ var ts; } return undefined; } - function getContextualTypeForYieldOperand(node) { + function getContextualTypeForYieldOperand(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { var functionFlags = ts.getFunctionFlags(func); - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { + var isAsyncGenerator_2 = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + if (!node.asteriskToken && contextualReturnType.flags & 1048576 /* TypeFlags.Union */) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, type, isAsyncGenerator_2); }); + } return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, contextualReturnType, isAsyncGenerator_2); } } return undefined; @@ -73024,15 +73299,15 @@ var ts; return false; } function getContextualIterationType(kind, functionDecl) { - var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); - var contextualReturnType = getContextualReturnType(functionDecl); + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* FunctionFlags.Async */); + var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) || undefined; } return undefined; } - function getContextualReturnType(functionDecl) { + function getContextualReturnType(functionDecl, contextFlags) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed var returnType = getReturnTypeFromAnnotation(functionDecl); @@ -73047,7 +73322,7 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl); if (iife) { - return getContextualType(iife); + return getContextualType(iife, contextFlags); } return undefined; } @@ -73071,11 +73346,11 @@ var ts; } var restIndex = signature.parameters.length - 1; return signatureHasRestParameter(signature) && argIndex >= restIndex ? - getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) : getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 210 /* TaggedTemplateExpression */) { + if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -73084,13 +73359,13 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 63 /* EqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -73099,8 +73374,8 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: return undefined; @@ -73121,6 +73396,14 @@ var ts; var lhsType = getTypeOfExpression(e.expression); return ts.isPrivateIdentifier(e.name) ? tryGetPrivateIdentifierPropertyOfType(lhsType, e.name) : getPropertyOfType(lhsType, e.name.escapedText); } + if (ts.isElementAccessExpression(e)) { + var propType = checkExpressionCached(e.argumentExpression); + if (!isTypeUsableAsPropertyName(propType)) { + return undefined; + } + var lhsType = getTypeOfExpression(e.expression); + return getPropertyOfType(lhsType, getPropertyNameFromType(propType)); + } return undefined; function tryGetPrivateIdentifierPropertyOfType(type, id) { var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(id.escapedText, id); @@ -73133,8 +73416,8 @@ var ts; var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { - case 0 /* None */: - case 4 /* ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var lhsSymbol = getSymbolForExpression(binaryExpression.left); var decl = lhsSymbol && lhsSymbol.valueDeclaration; // Unannotated, uninitialized property declarations have a type implied by their usage in the constructor. @@ -73144,11 +73427,11 @@ var ts; return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || (ts.isPropertyDeclaration(decl) ? decl.initializer && getTypeOfExpression(binaryExpression.left) : undefined); } - if (kind === 0 /* None */) { + if (kind === 0 /* AssignmentDeclarationKind.None */) { return getTypeOfExpression(binaryExpression.left); } return getContextualTypeForThisPropertyAssignment(binaryExpression); - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { return getContextualTypeForThisPropertyAssignment(binaryExpression); } @@ -73169,7 +73452,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* SymbolFlags.Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated_1) { @@ -73183,18 +73466,18 @@ var ts; } return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left); } - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; // falls through - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration); var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration); return annotated ? getTypeFromTypeNode(annotated) : undefined; - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); @@ -73202,14 +73485,14 @@ var ts; } function isPossiblyAliasedThisProperty(declaration, kind) { if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); } - if (kind === 4 /* ThisProperty */) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */) { return true; } - if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) { + if (!ts.isInJSFile(declaration) || kind !== 5 /* AssignmentDeclarationKind.Property */ || !ts.isIdentifier(declaration.left.expression)) { return false; } var name = declaration.left.expression.escapedText; - var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); + var symbol = resolveName(declaration.left, name, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } function getContextualTypeForThisPropertyAssignment(binaryExpression) { @@ -73233,11 +73516,11 @@ var ts; return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined; } function isCircularMappedProperty(symbol) { - return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0); + return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0); } function getTypeOfPropertyOfContextualType(type, name, nameType) { return mapType(type, function (t) { - if (t.flags & 2097152 /* Intersection */) { + if (t.flags & 2097152 /* TypeFlags.Intersection */) { var intersection = t; var newTypes = ts.mapDefined(intersection.types, getTypeOfConcretePropertyOfContextualType); if (newTypes.length > 0) { @@ -73265,7 +73548,7 @@ var ts; } return undefined; } - if (t.flags & 3670016 /* StructuredType */) { + if (t.flags & 3670016 /* TypeFlags.StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop); @@ -73281,7 +73564,7 @@ var ts; } function getTypeOfApplicableIndexInfoOfContextualType(t) { var _a; - if (!(t.flags & 3670016 /* StructuredType */)) { + if (!(t.flags & 3670016 /* TypeFlags.StructuredType */)) { return undefined; } return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type; @@ -73292,7 +73575,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -73300,7 +73583,7 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; - var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags); if (propertyAssignmentType) { return propertyAssignmentType; } @@ -73327,7 +73610,7 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, + || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* IterationUse.Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, /*noReductions*/ true)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -73335,8 +73618,8 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined; } - function getContextualTypeForChildJsxExpression(node, child) { - var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName); + function getContextualTypeForChildJsxExpression(node, child, contextFlags) { + var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags); // JSX expression is in children of JSX Element, we will look for an "children" attribute (we get the name from JSX.ElementAttributesProperty) var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) { @@ -73354,27 +73637,27 @@ var ts; } }, /*noReductions*/ true)); } - function getContextualTypeForJsxExpression(node) { + function getContextualTypeForJsxExpression(node, contextFlags) { var exprParent = node.parent; return ts.isJsxAttributeLike(exprParent) - ? getContextualType(node) + ? getContextualType(node, contextFlags) : ts.isJsxElement(exprParent) - ? getContextualTypeForChildJsxExpression(exprParent, node) + ? getContextualTypeForChildJsxExpression(exprParent, node, contextFlags) : undefined; } - function getContextualTypeForJsxAttribute(attribute) { + function getContextualTypeForJsxAttribute(attribute, contextFlags) { // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type // which is a type of the parameter of the signature we are trying out. // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName if (ts.isJsxAttribute(attribute)) { - var attributesType = getApparentTypeOfContextualType(attribute.parent); + var attributesType = getApparentTypeOfContextualType(attribute.parent, contextFlags); if (!attributesType || isTypeAny(attributesType)) { return undefined; } return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { - return getContextualType(attribute.parent); + return getContextualType(attribute.parent, contextFlags); } } // Return true if the given expression is possibly a discriminant value. We limit the kinds of @@ -73382,29 +73665,29 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 79 /* Identifier */: - case 153 /* UndefinedKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 153 /* SyntaxKind.UndefinedKeyword */: return true; - case 206 /* PropertyAccessExpression */: - case 212 /* ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* SyntaxKind.JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -73413,21 +73696,21 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* ContextFlags.NoConstraints */ && instantiatedType.flags & 8650752 /* TypeFlags.TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : - apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + return apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing // return type inferences is available, instantiate those types using that mapper. function instantiateContextualType(contextualType, node, contextFlags) { - if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) { + if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) { var inferenceContext = getInferenceContext(node); // If no inferences have been made, nothing is gained from instantiating as type parameters // would just be replaced with their defaults similar to the apparent type. - if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { + if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { // For contextual signatures we incorporate all inferences made so far, e.g. from return // types as well as arguments to the left in a function call. return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); @@ -73438,7 +73721,7 @@ var ts; // the 'boolean' type from the contextual type such that contextually typed boolean // literals actually end up widening to 'boolean' (see #48363). var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); - return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? + return type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : type; } @@ -73449,13 +73732,13 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { return instantiateType(type, mapper); } - if (type.flags & 1048576 /* Union */) { - return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* None */); + if (type.flags & 1048576 /* TypeFlags.Union */) { + return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* UnionReduction.None */); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); })); } return type; @@ -73478,7 +73761,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -73487,65 +73770,65 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 214 /* ArrowFunction */: - case 247 /* ReturnStatement */: - return getContextualTypeForReturnExpression(node); - case 224 /* YieldExpression */: - return getContextualTypeForYieldOperand(parent); - case 218 /* AwaitExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 247 /* SyntaxKind.ReturnStatement */: + return getContextualTypeForReturnExpression(node, contextFlags); + case 224 /* SyntaxKind.YieldExpression */: + return getContextualTypeForYieldOperand(parent, contextFlags); + case 218 /* SyntaxKind.AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return getContextualTypeForArgument(parent, node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 204 /* ArrayLiteralExpression */: { + case 204 /* SyntaxKind.ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 233 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 223 /* TemplateExpression */); + case 233 /* SyntaxKind.TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 223 /* SyntaxKind.TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return !tag ? getContextualType(parent, contextFlags) : ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(tag.typeExpression.type); } - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return getContextualType(parent, contextFlags); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return tryGetTypeFromEffectiveTypeNode(parent); - case 288 /* JsxExpression */: - return getContextualTypeForJsxExpression(parent); - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - return getContextualTypeForJsxAttribute(parent); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + return getContextualTypeForJsxExpression(parent, contextFlags); + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + return getContextualTypeForJsxAttribute(parent, contextFlags); + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; function tryFindWhenConstTypeReference(node) { - return getContextualType(node); + return getContextualType(node, contextFlags); } } function getInferenceContext(node) { @@ -73553,7 +73836,7 @@ var ts; return ancestor && ancestor.inferenceContext; } function getContextualJsxElementAttributesType(node, contextFlags) { - if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) { + if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* ContextFlags.Completions */) { // Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit // _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type // (as below) instead! @@ -73562,7 +73845,7 @@ var ts; return getContextualTypeForArgumentAtIndex(node, 0); } function getEffectiveFirstArgumentForJsxSignature(signature, node) { - return getJsxReferenceKind(node) !== 0 /* Component */ + return getJsxReferenceKind(node) !== 0 /* JsxReferenceKind.Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } @@ -73607,7 +73890,7 @@ var ts; return getOrCreateTypeFromSignature(fakeSignature); } var tagType = checkExpressionCached(context.tagName); - if (tagType.flags & 128 /* StringLiteral */) { + if (tagType.flags & 128 /* TypeFlags.StringLiteral */) { var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); if (!result) { return errorType; @@ -73622,7 +73905,7 @@ var ts; if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); - if (managedSym.flags & 524288 /* TypeAlias */) { + if (managedSym.flags & 524288 /* SymbolFlags.TypeAlias */) { var params = getSymbolLinks(managedSym).typeParameters; if (ts.length(params) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); @@ -73723,12 +74006,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -73750,18 +74033,18 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 2097152 /* Intersection */; - result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 2097152 /* TypeFlags.Intersection */; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. function getContextualCallSignature(type, node) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } @@ -73791,16 +74074,16 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */); if (!type) { return undefined; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -73829,38 +74112,38 @@ var ts; } } function checkSpreadExpression(node, checkMode) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); + return checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, arrayOrIterableType, undefinedType, node.expression); } function checkSyntheticExpression(node) { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 203 /* BindingElement */ && !!node.initializer) || - (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); + return (node.kind === 203 /* SyntaxKind.BindingElement */ && !!node.initializer) || + (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; var elementCount = elements.length; var elementTypes = []; var elementFlags = []; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined); var inDestructuringPattern = ts.isAssignmentTarget(node); var inConstContext = isConstContext(node); var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 225 /* SpreadElement */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var spreadType = checkExpression(e.expression, checkMode, forceTuple); if (isArrayLikeType(spreadType)) { elementTypes.push(spreadType); - elementFlags.push(8 /* Variadic */); + elementFlags.push(8 /* ElementFlags.Variadic */); } else if (inDestructuringPattern) { // Given the following situation: @@ -73876,27 +74159,27 @@ var ts; // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. var restElementType = getIndexTypeOfType(spreadType, numberType) || - getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || + getIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || unknownType; elementTypes.push(restElementType); - elementFlags.push(4 /* Rest */); + elementFlags.push(4 /* ElementFlags.Rest */); } else { - elementTypes.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, e.expression)); - elementFlags.push(4 /* Rest */); + elementTypes.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, e.expression)); + elementFlags.push(4 /* ElementFlags.Rest */); } } - else if (exactOptionalPropertyTypes && e.kind === 227 /* OmittedExpression */) { + else if (exactOptionalPropertyTypes && e.kind === 227 /* SyntaxKind.OmittedExpression */) { hasOmittedExpression = true; elementTypes.push(missingType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); - elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); - if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) { + elementFlags.push(hasOmittedExpression ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */); + if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && isContextSensitive(e)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context addIntraExpressionInferenceSite(inferenceContext, e, type); @@ -73910,28 +74193,28 @@ var ts; return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? - getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* Subtype */) : + getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* UnionReduction.Subtype */) : strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext)); } function createArrayLiteralType(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */)) { return type; } var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 16384 /* ArrayLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 16384 /* ObjectFlags.ArrayLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return isNumericComputedName(name); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isNumericLiteralName(name.escapedText); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return ts.isNumericLiteralName(name.text); default: return false; @@ -73940,14 +74223,14 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* TypeFlags.NumberLike */); } function checkComputedPropertyName(node) { var links = getNodeLinks(node.expression); if (!links.resolvedType) { if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent)) - && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */ - && node.parent.kind !== 172 /* GetAccessor */ && node.parent.kind !== 173 /* SetAccessor */) { + && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ + && node.parent.kind !== 172 /* SyntaxKind.GetAccessor */ && node.parent.kind !== 173 /* SyntaxKind.SetAccessor */) { return links.resolvedType = errorType; } links.resolvedType = checkExpression(node.expression); @@ -73958,17 +74241,17 @@ var ts; var enclosingIterationStatement = getEnclosingIterationStatement(container); if (enclosingIterationStatement) { // The computed field name will use a block scoped binding which can be unique for each iteration of the loop. - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; // The generated variable which stores the computed field name must be block-scoped. - getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; // The generated variable which stores the class must be block-scoped. - getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node.parent.parent).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } } // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 98304 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* TypeFlags.Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -73984,7 +74267,7 @@ var ts; var _a; var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) && - isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */)); + isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* TypeFlags.ESSymbol */)); } function getObjectLiteralIndexInfo(node, offset, properties, keyType) { var propTypes = []; @@ -73996,11 +74279,11 @@ var ts; propTypes.push(getTypeOfSymbol(properties[i])); } } - var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType; + var unionType = propTypes.length ? getUnionType(propTypes, 2 /* UnionReduction.Subtype */) : undefinedType; return createIndexInfo(keyType, unionType, isConstContext(node)); } function getImmediateAliasedSymbol(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); @@ -74018,11 +74301,11 @@ var ts; var propertiesTable = ts.createSymbolTable(); var propertiesArray = []; var spread = emptyObjectType; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* SyntaxKind.ObjectLiteralExpression */); var inConstContext = isConstContext(node); - var checkFlags = inConstContext ? 8 /* Readonly */ : 0; + var checkFlags = inConstContext ? 8 /* CheckFlags.Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -74044,16 +74327,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 296 /* PropertyAssignment */ || - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 296 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -74065,29 +74348,29 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 458752 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 458752 /* ObjectFlags.PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? - createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : - createSymbol(4 /* Property */ | member.flags, member.escapedName, checkFlags); + createSymbol(4 /* SymbolFlags.Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* CheckFlags.Late */) : + createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName, checkFlags); if (nameType) { prop.nameType = nameType; } if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 296 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 297 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 16777216 /* Optional */; + prop.flags |= 16777216 /* SymbolFlags.Optional */; } } - else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.escapedName); if (impliedProp) { - prop.flags |= impliedProp.flags & 16777216 /* Optional */; + prop.flags |= impliedProp.flags & 16777216 /* SymbolFlags.Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -74102,17 +74385,17 @@ var ts; prop.target = member; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); - if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && - (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) { + if (contextualType && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && + (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || memberDecl.kind === 169 /* SyntaxKind.MethodDeclaration */) && isContextSensitive(memberDecl)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context - var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl; + var inferenceNode = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? memberDecl.initializer : memberDecl; addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type); } } - else if (memberDecl.kind === 298 /* SpreadAssignment */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + else if (memberDecl.kind === 298 /* SyntaxKind.SpreadAssignment */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(memberDecl, 2 /* ExternalEmitHelpers.Assign */); } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -74146,10 +74429,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 172 /* GetAccessor */ || memberDecl.kind === 173 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 172 /* SyntaxKind.GetAccessor */ || memberDecl.kind === 173 /* SyntaxKind.SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -74174,11 +74457,11 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 298 /* SyntaxKind.SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { - if (!(prop.flags & 16777216 /* Optional */)) { + if (!(prop.flags & 16777216 /* SymbolFlags.Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } propertiesTable.set(prop.escapedName, prop); @@ -74210,12 +74493,12 @@ var ts; if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType)); var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 4096 /* JSLiteral */; + result.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; } if (patternWithComputedProperties) { - result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; } if (inDestructuringPattern) { result.pattern = node; @@ -74225,8 +74508,8 @@ var ts; } function isValidSpreadType(type) { var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType)); - return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || - t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); + return !!(t.flags & (1 /* TypeFlags.Any */ | 67108864 /* TypeFlags.NonPrimitive */ | 524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + t.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); @@ -74272,7 +74555,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* SyntaxKind.Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -74296,15 +74579,15 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 2048 /* JsxAttributes */; + var objectFlags = 2048 /* ObjectFlags.JsxAttributes */; var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { var attributeDecl = _a[_i]; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); - objectFlags |= ts.getObjectFlags(exprType) & 458752 /* PropagatingFlags */; - var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); + objectFlags |= ts.getObjectFlags(exprType) & 458752 /* ObjectFlags.PropagatingFlags */; + var attributeSymbol = createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; if (member.valueDeclaration) { @@ -74319,7 +74602,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 287 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 287 /* SyntaxKind.JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -74346,7 +74629,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 278 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 278 /* SyntaxKind.JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -74357,10 +74640,10 @@ var ts; if (explicitlySpecifyChildrenAttribute) { error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName)); } - var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); + var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process - var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); + var childrenPropSymbol = createSymbol(4 /* SymbolFlags.Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); @@ -74388,7 +74671,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return result; } } @@ -74398,12 +74681,12 @@ var ts; var child = _a[_i]; // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that // because then type of children property will have constituent of string type. - if (child.kind === 11 /* JsxText */) { + if (child.kind === 11 /* SyntaxKind.JsxText */) { if (!child.containsOnlyTriviaWhiteSpaces) { childrenTypes.push(stringType); } } - else if (child.kind === 288 /* JsxExpression */ && !child.expression) { + else if (child.kind === 288 /* SyntaxKind.JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -74415,7 +74698,7 @@ var ts; function checkSpreadPropOverrides(type, props, spread) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var right = _a[_i]; - if (!(right.flags & 16777216 /* Optional */)) { + if (!(right.flags & 16777216 /* SymbolFlags.Optional */)) { var left = props.get(right.escapedName); if (left) { var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); @@ -74435,7 +74718,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* SymbolFlags.Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -74454,13 +74737,13 @@ var ts; return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; + links.jsxFlags |= 1 /* JsxFlags.IntrinsicNamedElement */; return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + links.jsxFlags |= 2 /* JsxFlags.IntrinsicIndexedElement */; return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found @@ -74509,10 +74792,10 @@ var ts; var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location); if (!resolvedNamespace || resolvedNamespace === unknownSymbol) { var namespaceName = getJsxNamespace(location); - resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + resolvedNamespace = resolveName(location, namespaceName, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); } if (resolvedNamespace) { - var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */)); + var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* SymbolFlags.Namespace */)); if (candidate && candidate !== unknownSymbol) { if (links) { links.jsxNamespace = candidate; @@ -74525,7 +74808,7 @@ var ts; } } // JSX global fallback - var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined)); + var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined)); if (s === unknownSymbol) { return undefined; // TODO: GH#18217 } @@ -74540,7 +74823,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* SymbolFlags.Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -74564,7 +74847,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* SymbolFlags.Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -74578,10 +74861,10 @@ var ts; return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } function getUninstantiatedJsxSignaturesOfType(elementType, caller) { - if (elementType.flags & 4 /* String */) { + if (elementType.flags & 4 /* TypeFlags.String */) { return [anySignature]; } - else if (elementType.flags & 128 /* StringLiteral */) { + else if (elementType.flags & 128 /* TypeFlags.StringLiteral */) { var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller); if (!intrinsicType) { error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements); @@ -74594,12 +74877,12 @@ var ts; } var apparentElemType = getApparentType(elementType); // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(apparentElemType, 1 /* Construct */); + var signatures = getSignaturesOfType(apparentElemType, 1 /* SignatureKind.Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures - signatures = getSignaturesOfType(apparentElemType, 0 /* Call */); + signatures = getSignaturesOfType(apparentElemType, 0 /* SignatureKind.Call */); } - if (signatures.length === 0 && apparentElemType.flags & 1048576 /* Union */) { + if (signatures.length === 0 && apparentElemType.flags & 1048576 /* TypeFlags.Union */) { // If each member has some combination of new/call signatures; make a union signature list for those signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); })); } @@ -74627,13 +74910,13 @@ var ts; return anyType; } function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { - if (refKind === 1 /* Function */) { + if (refKind === 1 /* JsxReferenceKind.Function */) { var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); if (sfcReturnConstraint) { checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } - else if (refKind === 0 /* Component */) { + else if (refKind === 0 /* JsxReferenceKind.Component */) { var classConstraint = getJsxElementClassTypeAt(openingLikeElement); if (classConstraint) { // Issue an error if this return type isn't assignable to JSX.ElementClass, failing that @@ -74664,10 +74947,10 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + if (links.jsxFlags & 1 /* JsxFlags.IntrinsicNamedElement */) { return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + else if (links.jsxFlags & 2 /* JsxFlags.IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType; } @@ -74701,7 +74984,7 @@ var ts; } function checkJsxPreconditions(errorNode) { // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + if ((compilerOptions.jsx || 0 /* JsxEmit.None */) === 0 /* JsxEmit.None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } if (getJsxElementTypeAt(errorNode) === undefined) { @@ -74719,20 +75002,20 @@ var ts; if (!getJsxNamespaceContainerForImplicitImport(node)) { // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; + var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* JsxEmit.React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var jsxFactoryNamespace = getJsxNamespace(node); var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; // allow null as jsxFragmentFactory var jsxFactorySym = void 0; if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); + jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); } if (jsxFactorySym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not jsxFactory as there wont be error being emitted - jsxFactorySym.isReferenced = 67108863 /* All */; + jsxFactorySym.isReferenced = 67108863 /* SymbolFlags.All */; // If react/jsxFactory symbol is alias, mark it as refereced - if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { + if (jsxFactorySym.flags & 2097152 /* SymbolFlags.Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { markAliasSymbolAsReferenced(jsxFactorySym); } } @@ -74741,7 +75024,7 @@ var ts; var file = ts.getSourceFileOfNode(node); var localJsxNamespace = getLocalJsxNamespace(file); if (localJsxNamespace) { - resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); + resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); } } } @@ -74766,7 +75049,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 524288 /* Object */) { + if (targetType.flags & 524288 /* TypeFlags.Object */) { // For backwards compatibility a symbol-named property is satisfied by a string index signature. This // is incorrect and inconsistent with element access expressions, where it is an error, so eventually // we should remove this exception. @@ -74778,7 +75061,7 @@ var ts; return true; } } - else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { + else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -74789,10 +75072,10 @@ var ts; return false; } function isExcessPropertyCheckTarget(type) { - return !!(type.flags & 524288 /* Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || - type.flags & 67108864 /* NonPrimitive */ || - type.flags & 1048576 /* Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); + return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) || + type.flags & 67108864 /* TypeFlags.NonPrimitive */ || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); } function checkJsxExpression(node, checkMode) { checkGrammarJsxExpression(node); @@ -74815,13 +75098,13 @@ var ts; * Note that this is not tracked well within the compiler, so the answer may be incorrect. */ function isPrototypeProperty(symbol) { - if (symbol.flags & 8192 /* Method */ || ts.getCheckFlags(symbol) & 4 /* SyntheticMethod */) { + if (symbol.flags & 8192 /* SymbolFlags.Method */ || ts.getCheckFlags(symbol) & 4 /* CheckFlags.SyntheticMethod */) { return true; } if (ts.isInJSFile(symbol.valueDeclaration)) { var parent = symbol.valueDeclaration.parent; return parent && ts.isBinaryExpression(parent) && - ts.getAssignmentDeclarationKind(parent) === 3 /* PrototypeProperty */; + ts.getAssignmentDeclarationKind(parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } } /** @@ -74835,9 +75118,9 @@ var ts; function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } var errorNode = !reportError ? undefined : - node.kind === 161 /* QualifiedName */ ? node.right : - node.kind === 200 /* ImportType */ ? node : - node.kind === 203 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + node.kind === 161 /* SyntaxKind.QualifiedName */ ? node.right : + node.kind === 200 /* SyntaxKind.ImportType */ ? node : + node.kind === 203 /* SyntaxKind.BindingElement */ && node.propertyName ? node.propertyName : node.name; return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode); } /** @@ -74860,7 +75143,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { if (errorNode) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -74868,7 +75151,7 @@ var ts; return false; } } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -74880,7 +75163,7 @@ var ts; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + if ((flags & 128 /* ModifierFlags.Abstract */) && symbolHasNonMethodDeclaration(prop) && (ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { @@ -74891,12 +75174,12 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { return true; } // Property is known to be private or protected at this point // Private property is accessible if the property is within the declaring class - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -74923,7 +75206,7 @@ var ts; // static member access is disallowed enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 32 /* ModifierFlags.Static */ || !enclosingClass) { if (errorNode) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } @@ -74931,10 +75214,10 @@ var ts; } } // No further restrictions for static properties - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return true; } - if (containingType.flags & 262144 /* TypeParameter */) { + if (containingType.flags & 262144 /* TypeFlags.TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -74949,10 +75232,10 @@ var ts; function getEnclosingClassFromThisParameter(node) { var thisParameter = getThisParameterFromNodeContext(node); var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type); - if (thisType && thisType.flags & 262144 /* TypeParameter */) { + if (thisType && thisType.flags & 262144 /* TypeFlags.TypeParameter */) { thisType = getConstraintOfTypeParameter(thisType); } - if (thisType && ts.getObjectFlags(thisType) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (thisType && ts.getObjectFlags(thisType) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { return getTargetType(thisType); } return undefined; @@ -74962,39 +75245,39 @@ var ts; return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined; } function symbolHasNonMethodDeclaration(symbol) { - return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); + return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* SymbolFlags.Method */); }); } function checkNonNullExpression(node) { return checkNonNullType(checkExpression(node), node); } function isNullableType(type) { - return !!(getTypeFacts(type) & 50331648 /* IsUndefinedOrNull */); + return !!(getTypeFacts(type) & 50331648 /* TypeFacts.IsUndefinedOrNull */); } function getNonNullableTypeIfNeeded(type) { return isNullableType(type) ? getNonNullableType(type) : type; } function reportObjectPossiblyNullOrUndefinedError(node, facts) { - error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? + error(node, facts & 16777216 /* TypeFacts.IsUndefined */ ? facts & 33554432 /* TypeFacts.IsNull */ ? ts.Diagnostics.Object_is_possibly_null_or_undefined : ts.Diagnostics.Object_is_possibly_undefined : ts.Diagnostics.Object_is_possibly_null); } function reportCannotInvokePossiblyNullOrUndefinedError(node, facts) { - error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? + error(node, facts & 16777216 /* TypeFacts.IsUndefined */ ? facts & 33554432 /* TypeFacts.IsNull */ ? ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); } function checkNonNullTypeWithReporter(type, node, reportError) { - if (strictNullChecks && type.flags & 2 /* Unknown */) { + if (strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } var facts = getTypeFacts(type); - if (facts & 50331648 /* IsUndefinedOrNull */) { + if (facts & 50331648 /* TypeFacts.IsUndefinedOrNull */) { reportError(node, facts); var t = getNonNullableType(type); - return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; + return t.flags & (98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */) ? errorType : t; } return type; } @@ -75003,13 +75286,13 @@ var ts; } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); - if (nonNullType.flags & 16384 /* Void */) { + if (nonNullType.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.Object_is_possibly_undefined); } return nonNullType; } function checkPropertyAccessExpression(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } function checkPropertyAccessChain(node, checkMode) { @@ -75022,7 +75305,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 212 /* ParenthesizedExpression */) { + while (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -75046,7 +75329,7 @@ var ts; if (!ts.isExpressionNode(privId)) { return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression); } - var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* InKeyword */; + var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) { return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId)); } @@ -75118,16 +75401,16 @@ var ts; function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); - var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); + var apparentType = getApparentType(assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { - if (languageVersion < 99 /* ESNext */) { - if (assignmentKind !== 0 /* None */) { - checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + if (assignmentKind !== 0 /* AssignmentKind.None */) { + checkExternalEmitHelpers(node, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } - if (assignmentKind !== 1 /* Definite */) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + if (assignmentKind !== 1 /* AssignmentKind.Definite */) { + checkExternalEmitHelpers(node, 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */); } } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); @@ -75149,8 +75432,8 @@ var ts; return errorType; } else { - var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* AssignmentKind.Definite */) { error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); } } @@ -75162,7 +75445,7 @@ var ts; } return isErrorType(apparentType) ? errorType : apparentType; } - prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === 161 /* QualifiedName */); + prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === 161 /* SyntaxKind.QualifiedName */); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined @@ -75172,13 +75455,13 @@ var ts; // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`. if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || - !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && node.parent.kind === 299 /* EnumMember */)) || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* SymbolFlags.EnumMember */ && node.parent.kind === 299 /* SyntaxKind.EnumMember */)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; if (!prop) { - var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? + var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined; if (!(indexInfo && indexInfo.type)) { var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true); @@ -75186,7 +75469,7 @@ var ts; return anyType; } if (leftType.symbol === globalThisSymbol) { - if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */)) { + if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* SymbolFlags.BlockScoped */)) { error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); } else if (noImplicitAny) { @@ -75206,7 +75489,7 @@ var ts; if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) { error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText)); } - if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) { + if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* NodeFlags.Deprecated */) { addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText); } } @@ -75218,7 +75501,7 @@ var ts; markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; var writing = ts.isWriteAccess(node); - checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 106 /* SyntaxKind.SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; @@ -75237,11 +75520,11 @@ var ts; function isUncheckedJSSuggestion(node, suggestion, excludeClasses) { var file = ts.getSourceFileOfNode(node); if (file) { - if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) { + if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */)) { var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode); return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) - && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */) - && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */); + && !(excludeClasses && suggestion && suggestion.flags & 32 /* SymbolFlags.Class */) + && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */); } } return false; @@ -75251,12 +75534,12 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (assignmentKind === 1 /* Definite */) { - return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + if (assignmentKind === 1 /* AssignmentKind.Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* SymbolFlags.Optional */)); } if (prop && - !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) - && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + !(prop.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */ | 98304 /* SymbolFlags.Accessor */)) + && !(prop.flags & 8192 /* SymbolFlags.Method */ && propType.flags & 1048576 /* TypeFlags.Union */) && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } @@ -75269,12 +75552,12 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isPropertyWithoutInitializer(declaration)) { if (!ts.isStatic(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) { + if (flowContainer.kind === 171 /* SyntaxKind.Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { assumeUninitialized = true; } } @@ -75305,13 +75588,13 @@ var ts; && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* Static */) + && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* ModifierFlags.Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 257 /* ClassDeclaration */ && - node.parent.kind !== 178 /* TypeReference */ && - !(valueDeclaration.flags & 16777216 /* Ambient */) && + else if (valueDeclaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && + node.parent.kind !== 178 /* SyntaxKind.TypeReference */ && + !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -75322,25 +75605,25 @@ var ts; function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 296 /* PropertyAssignment */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 298 /* SpreadAssignment */: - case 162 /* ComputedPropertyName */: - case 233 /* TemplateSpan */: - case 288 /* JsxExpression */: - case 285 /* JsxAttribute */: - case 286 /* JsxAttributes */: - case 287 /* JsxSpreadAttribute */: - case 280 /* JsxOpeningElement */: - case 228 /* ExpressionWithTypeArguments */: - case 291 /* HeritageClause */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 298 /* SyntaxKind.SpreadAssignment */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 233 /* SyntaxKind.TemplateSpan */: + case 288 /* SyntaxKind.JsxExpression */: + case 285 /* SyntaxKind.JsxAttribute */: + case 286 /* SyntaxKind.JsxAttributes */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 291 /* SyntaxKind.HeritageClause */: return false; - case 214 /* ArrowFunction */: - case 238 /* ExpressionStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -75352,7 +75635,7 @@ var ts; * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. */ function isPropertyDeclaredInAncestorClass(prop) { - if (!(prop.parent.flags & 32 /* Class */)) { + if (!(prop.parent.flags & 32 /* SymbolFlags.Class */)) { return false; } var classType = getTypeOfSymbol(prop.parent); @@ -75377,7 +75660,7 @@ var ts; function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { var errorInfo; var relatedInfo; - if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { + if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* TypeFlags.Union */ && !(containingType.flags & 131068 /* TypeFlags.Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) { @@ -75465,7 +75748,7 @@ var ts; } } function getSuggestedSymbolForNonexistentClassMember(name, baseType) { - return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */); + return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* SymbolFlags.ClassMember */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); @@ -75476,7 +75759,7 @@ var ts; } name = ts.idText(name); } - return getSpellingSuggestionForName(name, props, 111551 /* Value */); + return getSpellingSuggestionForName(name, props, 111551 /* SymbolFlags.Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -75484,7 +75767,7 @@ var ts; var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; }) : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; }) : undefined; - return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* Value */); + return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* SymbolFlags.Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -75503,7 +75786,7 @@ var ts; var candidates; if (symbols === globals) { var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1))) - ? createSymbol(524288 /* TypeAlias */, s) + ? createSymbol(524288 /* SymbolFlags.TypeAlias */, s) : undefined; }); candidates = primitives.concat(ts.arrayFrom(symbols.values())); } @@ -75519,7 +75802,7 @@ var ts; return symbolResult && ts.symbolName(symbolResult); } function getSuggestedSymbolForNonexistentModule(name, targetModule) { - return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */); + return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* SymbolFlags.ModuleMember */); } function getSuggestionForNonexistentExport(name, targetModule) { var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule); @@ -75550,7 +75833,7 @@ var ts; return suggestion; } function getSuggestedTypeForNonexistentStringLiteralType(source, target) { - var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); }); + var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); }); return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; }); } /** @@ -75578,7 +75861,7 @@ var ts; if (candidate.flags & meaning) { return candidateName; } - if (candidate.flags & 2097152 /* Alias */) { + if (candidate.flags & 2097152 /* SymbolFlags.Alias */) { var alias = tryResolveAlias(candidate); if (alias && alias.flags & meaning) { return candidateName; @@ -75588,16 +75871,16 @@ var ts; } } function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { - var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; + var valueDeclaration = prop && (prop.flags & 106500 /* SymbolFlags.ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } - var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); + var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* ModifierFlags.Private */); var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } - if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { + if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SymbolFlags.SetAccessor */)) { return; } if (isSelfTypeAccess) { @@ -75607,19 +75890,19 @@ var ts; return; } } - (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; + (ts.getCheckFlags(prop) & 1 /* CheckFlags.Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* SymbolFlags.All */; } function isSelfTypeAccess(name, parent) { - return name.kind === 108 /* ThisKeyword */ + return name.kind === 108 /* SyntaxKind.ThisKeyword */ || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 161 /* SyntaxKind.QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } @@ -75634,7 +75917,7 @@ var ts; * @param property the accessed property's symbol. */ function isValidPropertyAccessForCompletions(node, type, property) { - return isPropertyAccessible(node, node.kind === 206 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, + return isPropertyAccessible(node, node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, /* isWrite */ false, type, property); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } @@ -75674,13 +75957,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 79 /* Identifier */) { + else if (initializer.kind === 79 /* SyntaxKind.Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -75697,13 +75980,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 79 /* Identifier */) { + if (e.kind === 79 /* SyntaxKind.Identifier */) { var symbol = getResolvedSymbol(e); - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 243 /* ForInStatement */ && + if (node.kind === 243 /* SyntaxKind.ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -75717,7 +76000,7 @@ var ts; return false; } function checkIndexedAccess(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkElementAccessChain(node, checkMode) : checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } function checkElementAccessChain(node, checkMode) { @@ -75726,7 +76009,7 @@ var ts; return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } function checkElementAccessExpression(node, exprType, checkMode) { - var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; + var objectType = ts.getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); if (isErrorType(objectType) || objectType === silentNeverType) { @@ -75738,8 +76021,8 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : - 32 /* ExpressionPosition */; + 4 /* AccessFlags.Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* AccessFlags.NoIndexSignatures */ : 0) : + 32 /* AccessFlags.ExpressionPosition */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -75752,13 +76035,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 165 /* Decorator */) { + else if (node.kind !== 165 /* SyntaxKind.Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -75822,16 +76105,16 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 225 /* SpreadElement */ || arg.kind === 232 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } function acceptsVoid(t) { - return !!(t.flags & 16384 /* Void */); + return !!(t.flags & 16384 /* TypeFlags.Void */); } function acceptsVoidUndefinedUnknownOrAny(t) { - return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */)); + return !!(t.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 2 /* TypeFlags.Unknown */ | 1 /* TypeFlags.Any */)); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -75839,9 +76122,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 223 /* TemplateExpression */) { + if (node.template.kind === 223 /* SyntaxKind.TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -75852,11 +76135,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = node.template; - ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 165 /* Decorator */) { + else if (node.kind === 165 /* SyntaxKind.Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -75870,7 +76153,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 209 /* NewExpression */); + ts.Debug.assert(node.kind === 209 /* SyntaxKind.NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -75894,7 +76177,7 @@ var ts; } for (var i = argCount; i < effectiveMinimumArguments; i++) { var type = getTypeAtPosition(signature, i); - if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* TypeFlags.Never */) { return false; } } @@ -75910,20 +76193,20 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false); } function getSingleCallOrConstructSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false) || - getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false) || + getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ false); } function getSingleSignature(type, kind, allowMembers) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) { - if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + if (kind === 0 /* SignatureKind.Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { return resolved.callSignatures[0]; } - if (kind === 1 /* Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + if (kind === 1 /* SignatureKind.Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { return resolved.constructSignatures[0]; } } @@ -75932,12 +76215,12 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) { - var context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes); + var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes); // We clone the inferenceContext to avoid fixing. For example, when the source signature is (x: T) => T[] and // the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any') // for T but leave it possible to later infer '[any]' back to A. var restType = getEffectiveRestType(contextualSignature); - var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); + var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; applyToParameterTypes(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -75945,7 +76228,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 128 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -75973,14 +76256,14 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 165 /* Decorator */) { + if (node.kind !== 165 /* SyntaxKind.Decorator */) { var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }); - var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */); + var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */); if (contextualType) { var inferenceTargetType = getReturnTypeOfSignature(signature); if (couldContainTypeVariables(inferenceTargetType)) { var outerContext = getInferenceContext(node); - var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType; + var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) !== contextualType; // A return type inference from a binding pattern can be used in instantiating the contextual // type of an argument later in inference, but cannot stand on its own as the final return type. // It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`, @@ -75995,7 +76278,7 @@ var ts; // We clone the inference context to avoid disturbing a resolution in progress for an // outer call expression. Effectively we just want a snapshot of whatever has been // inferred for any outer call expression so far. - var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */)); + var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* InferenceFlags.NoDefault */)); var instantiatedType = instantiateType(contextualType, outerMapper); // If the contextual type is a generic function type with a single call signature, we // instantiate the type with its own type parameters and type arguments. This ensures that @@ -76009,7 +76292,7 @@ var ts; getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */); } // Create a type mapper for instantiating generic contextual types using the inferences made // from the return type. We need a separate inference pass here because (a) instantiation of @@ -76024,7 +76307,7 @@ var ts; } var restType = getNonArrayRestType(signature); var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; }); if (info) { info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined; @@ -76037,7 +76320,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */ && !(checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { var paramType = getTypeAtPosition(signature, i); if (couldContainTypeVariables(paramType)) { var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); @@ -76052,10 +76335,10 @@ var ts; return getInferredTypes(context); } function getMutableArrayOrTupleType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : - type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getMutableArrayOrTupleType) : + type.flags & 1 /* TypeFlags.Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, /*readonly*/ false, type.target.labeledElementDeclarations) : - createTupleType([type], [8 /* Variadic */]); + createTupleType([type], [8 /* ElementFlags.Variadic */]); } function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) { if (index >= argCount - 1) { @@ -76063,7 +76346,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 232 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -76073,24 +76356,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 232 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 225 /* SpreadElement */ ? arg.expression : arg)); - flags.push(4 /* Rest */); + types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg)); + flags.push(4 /* ElementFlags.Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */); + var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); - flags.push(1 /* Required */); + flags.push(1 /* ElementFlags.Required */); } - if (arg.kind === 232 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -76120,16 +76403,16 @@ var ts; } function getJsxReferenceKind(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } var tagType = getApparentType(checkExpression(node.tagName)); - if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { - return 0 /* Component */; + if (ts.length(getSignaturesOfType(tagType, 1 /* SignatureKind.Construct */))) { + return 0 /* JsxReferenceKind.Component */; } - if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { - return 1 /* Function */; + if (ts.length(getSignaturesOfType(tagType, 0 /* SignatureKind.Call */))) { + return 1 /* JsxReferenceKind.Function */; } - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. @@ -76154,7 +76437,7 @@ var ts; if (!tagType) { return true; } - var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */); + var tagCallSignatures = getSignaturesOfType(tagType, 0 /* SignatureKind.Call */); if (!ts.length(tagCallSignatures)) { return true; } @@ -76162,12 +76445,12 @@ var ts; if (!factory) { return true; } - var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); + var factorySymbol = resolveEntityName(factory, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); if (!factorySymbol) { return true; } var factoryType = getTypeOfSymbol(factorySymbol); - var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */); + var callSignatures = getSignaturesOfType(factoryType, 0 /* SignatureKind.Call */); if (!ts.length(callSignatures)) { return true; } @@ -76177,7 +76460,7 @@ var ts; for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) { var sig = callSignatures_1[_i]; var firstparam = getTypeAtPosition(sig, 0); - var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */); + var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* SignatureKind.Call */); if (!ts.length(signaturesOfParam)) continue; for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) { @@ -76234,7 +76517,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 209 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -76252,13 +76535,13 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; + var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); @@ -76297,8 +76580,8 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - var expression = node.kind === 208 /* CallExpression */ ? node.expression : - node.kind === 210 /* TaggedTemplateExpression */ ? node.tag : undefined; + var expression = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression : + node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */ ? node.tag : undefined; if (expression) { var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { @@ -76316,17 +76599,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 165 /* Decorator */) { + if (node.kind === 165 /* SyntaxKind.Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -76337,15 +76620,15 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_25 = function (i) { + var _loop_26 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 225 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; var flags = spreadType.target.elementFlags[i]; - var syntheticArg = createSyntheticExpression(arg, flags & 4 /* Rest */ ? createArrayType(t) : t, !!(flags & 12 /* Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + var syntheticArg = createSyntheticExpression(arg, flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t, !!(flags & 12 /* ElementFlags.Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); effectiveArgs_1.push(syntheticArg); }); } @@ -76354,7 +76637,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_25(i); + _loop_26(i); } return effectiveArgs_1; } @@ -76367,30 +76650,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 171 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 171 /* SyntaxKind.Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 167 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && languageVersion !== 0 /* ScriptTarget.ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -76404,17 +76687,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return 1; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return 2; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments - return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 164 /* Parameter */: + return languageVersion === 0 /* ScriptTarget.ES3 */ || signature.parameters.length <= 2 ? 2 : 3; + case 164 /* SyntaxKind.Parameter */: return 3; default: return ts.Debug.fail(); @@ -76448,7 +76731,7 @@ var ts; function isPromiseResolveArityError(node) { if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression)) return false; - var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); + var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, undefined, undefined, false); var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { return false; @@ -76556,15 +76839,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 210 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 165 /* Decorator */; + var isTaggedTemplate = node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; + var isDecorator = node.kind === 165 /* SyntaxKind.Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; - if (!isDecorator) { + if (!isDecorator && !ts.isSuperCall(node)) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -76591,8 +76874,8 @@ var ts; // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; - var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */; - argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */; + var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* CheckMode.SkipContextSensitive */ : 0 /* CheckMode.Normal */; + argCheckMode |= checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; // The following variables are captured and modified by calls to chooseOverload. // If overload resolution or type argument inference fails, we want to report the // best error possible. The best error is one which says that an argument was not @@ -76620,7 +76903,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 208 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* CheckMode.IsForSignatureHelp */) && node.kind === 208 /* SyntaxKind.CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -76640,6 +76923,15 @@ var ts; if (result) { return result; } + result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + // Preemptively cache the result; getResolvedSignature will do this after we return, but + // we need to ensure that the result is present for the error checks below so that if + // this signature is encountered again, we handle the circularity (rather than producing a + // different result which may produce no errors and assert). Callers of getResolvedSignature + // don't hit this issue because they only observe this result after it's had a chance to + // be cached, but the error reporting code below executes before getResolvedSignature sets + // resolvedSignature. + getNodeLinks(node).resolvedSignature = result; // No signatures were applicable. Now report errors based on the last applicable signature with // no arguments excluded from assignability checks. // If candidate is undefined, it means that no candidates had a suitable arity. In that case, @@ -76653,7 +76945,7 @@ var ts; chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error); chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call); } - var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, function () { return chain_1; }); + var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, function () { return chain_1; }); if (diags) { for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) { var d = diags_1[_i]; @@ -76674,9 +76966,9 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_26 = function (c) { + var _loop_27 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { if (diags_2.length <= min_3) { min_3 = diags_2.length; @@ -76692,7 +76984,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_26(c); + _loop_27(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -76731,7 +77023,7 @@ var ts; } } } - return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + return result; function addImplementationSuccessElaboration(failed, diagnostic) { var _a, _b; var oldCandidatesForArgumentError = candidatesForArgumentError; @@ -76761,7 +77053,7 @@ var ts; if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { return undefined; } - if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { + if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { candidatesForArgumentError = [candidate]; return undefined; } @@ -76784,9 +77076,9 @@ var ts; } } else { - inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext); - argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */; + inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); + argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */; } checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a @@ -76808,10 +77100,10 @@ var ts; // If one or more context sensitive arguments were excluded, we start including // them now (and keeping do so for any subsequent candidates) and perform a second // round of type inference and applicability checking for this particular candidate. - argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */; + argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); - checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); + checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a // signature with different arity and we need to perform another arity check. if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) { @@ -76850,7 +77142,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_27 = function (i) { + var _loop_28 = function (i) { var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : i < s.parameters.length ? s.parameters[i] : undefined; }); @@ -76858,17 +77150,17 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_27(i); + _loop_28(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; if (restParameterSymbols.length !== 0) { - var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); + var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* UnionReduction.Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } if (candidates.some(signatureHasLiteralTypes)) { - flags |= 2 /* HasLiteralTypes */; + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. @@ -76881,7 +77173,7 @@ var ts; return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { - return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); + return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* UnionReduction.Subtype */)); } function createCombinedSymbolForOverloadFailure(sources, type) { // This function is currently only used for erroneous overloads, so it's good enough to just use the first source. @@ -76918,8 +77210,8 @@ var ts; return typeArguments; } function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) { - var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext); + var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* CheckMode.SkipContextSensitive */ | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); return createSignatureInstantiation(candidate, typeArgumentTypes); } function getLongestCandidateIndex(candidates, argsCount) { @@ -76939,7 +77231,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -76954,7 +77246,7 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } } return resolveUntypedCall(node); @@ -76963,13 +77255,13 @@ var ts; var funcType = checkExpression(node.expression); if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); - callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + callChainFlags = nonOptionalType === funcType ? 0 /* SignatureFlags.None */ : + ts.isOutermostOptionalChain(node) ? 16 /* SignatureFlags.IsOuterCallChain */ : + 8 /* SignatureFlags.IsInnerCallChain */; funcType = nonOptionalType; } else { - callChainFlags = 0 /* None */; + callChainFlags = 0 /* SignatureFlags.None */; } funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { @@ -76984,8 +77276,8 @@ var ts; // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; // TS 1.0 Spec: 4.12 // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. @@ -77012,7 +77304,7 @@ var ts; relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation); + invocationError(node.expression, apparentType, 0 /* SignatureKind.Call */, relatedInformation); } return resolveErrorCall(node); } @@ -77026,9 +77318,9 @@ var ts; // returns a function type, we choose to defer processing. This narrowly permits function composition // operators to flow inferences through return types, but otherwise processes calls right away. We // use the resolvingSignature singleton to indicate that we deferred processing. This result will be - // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and + // propagated out and eventually turned into silentNeverType (a type that is assignable to anything and // from which we never make inferences). - if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { skippedGenericFunction(node, checkMode); return resolvingSignature; } @@ -77049,11 +77341,11 @@ var ts; */ function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have no common signatures. - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeFlags.TypeParameter */) || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* TypeFlags.Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { - if (node.arguments && languageVersion < 1 /* ES5 */) { + if (node.arguments && languageVersion < 1 /* ScriptTarget.ES5 */) { var spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); @@ -77086,7 +77378,7 @@ var ts; // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(expressionType, 1 /* SignatureKind.Construct */); if (constructSignatures.length) { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); @@ -77095,24 +77387,24 @@ var ts; // then it cannot be instantiated. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); })) { + if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); })) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* Abstract */)) { + if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* ModifierFlags.Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. It is an error to have a Void this type. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + var callSignatures = getSignaturesOfType(expressionType, 0 /* SignatureKind.Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -77123,14 +77415,14 @@ var ts; } return signature; } - invocationError(node.expression, expressionType, 1 /* Construct */); + invocationError(node.expression, expressionType, 1 /* SignatureKind.Construct */); return resolveErrorCall(node); } function someSignature(signatures, f) { if (ts.isArray(signatures)) { return ts.some(signatures, function (signature) { return someSignature(signature, f); }); } - return signatures.compositeKind === 1048576 /* Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); + return signatures.compositeKind === 1048576 /* TypeFlags.Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); } function typeHasProtectedAccessibleBase(target, type) { var baseTypes = getBaseTypes(type); @@ -77138,7 +77430,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 2097152 /* Intersection */) { + if (firstBase.flags & 2097152 /* TypeFlags.Intersection */) { var types = firstBase.types; var mixinFlags = findMixins(types); var i = 0; @@ -77146,7 +77438,7 @@ var ts; var intersectionMember = _a[_i]; // We want to ignore mixin ctors if (!mixinFlags[i]) { - if (ts.getObjectFlags(intersectionMember) & (1 /* Class */ | 2 /* Interface */)) { + if (ts.getObjectFlags(intersectionMember) & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { if (intersectionMember.symbol === target) { return true; } @@ -77169,9 +77461,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 171 /* Constructor */) { + if (!modifiers || declaration.kind !== 171 /* SyntaxKind.Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -77179,16 +77471,16 @@ var ts; // A private or protected constructor can only be instantiated within its own class (or a subclass, for protected) if (!isNodeWithinClass(node, declaringClassDeclaration)) { var containingClass = ts.getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 16 /* ModifierFlags.Protected */) { var containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 8 /* ModifierFlags.Private */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 16 /* ModifierFlags.Protected */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -77197,10 +77489,10 @@ var ts; } function invocationErrorDetails(errorTarget, apparentType, kind) { var errorInfo; - var isCall = kind === 0 /* Call */; + var isCall = kind === 0 /* SignatureKind.Call */; var awaitedType = getAwaitedType(apparentType); var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0; - if (apparentType.flags & 1048576 /* Union */) { + if (apparentType.flags & 1048576 /* TypeFlags.Union */) { var types = apparentType.types; var hasSignatures = false; for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { @@ -77250,7 +77542,7 @@ var ts; // Diagnose get accessors incorrectly called as functions if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol; - if (resolvedSymbol && resolvedSymbol.flags & 32768 /* GetAccessor */) { + if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) { headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } @@ -77294,8 +77586,8 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -77305,26 +77597,26 @@ var ts; diagnostics.add(diagnostic); return resolveErrorCall(node); } - invocationError(node.tag, apparentType, 0 /* Call */); + invocationError(node.tag, apparentType, 0 /* SignatureKind.Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -77339,8 +77631,8 @@ var ts; if (isErrorType(apparentType)) { return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -77351,38 +77643,38 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* Call */); + var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* SignatureKind.Call */); var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage); var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage)); } diagnostics.add(diag); - invocationErrorRecovery(apparentType, 0 /* Call */, diag); + invocationErrorRecovery(apparentType, 0 /* SignatureKind.Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); - var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* SymbolFlags.Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* SymbolFlags.Type */, node); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, 0 /* None */); + /*returnTypePredicate*/ undefined, 1, 0 /* SignatureFlags.None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); var fakeSignature = createSignatureForJSXIntrinsic(node, result); - checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* CheckMode.Normal */), result, node.tagName, node.attributes); if (ts.length(node.typeArguments)) { ts.forEach(node.typeArguments, checkSourceElement); diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments))); @@ -77403,7 +77695,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -77419,16 +77711,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -77451,7 +77743,7 @@ var ts; return cached; } links.resolvedSignature = resolvingSignature; - var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */); + var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* CheckMode.Normal */); // When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call // resolution should be deferred. if (result !== resolvingSignature) { @@ -77492,7 +77784,7 @@ var ts; var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target); inferred.exports = inferred.exports || ts.createSymbolTable(); inferred.members = inferred.members || ts.createSymbolTable(); - inferred.flags |= source.flags & 32 /* Class */; + inferred.flags |= source.flags & 32 /* SymbolFlags.Class */; if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) { mergeSymbolTable(inferred.exports, source.exports); } @@ -77528,16 +77820,16 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } - else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + else if (parentNodeOperator === 56 /* SyntaxKind.BarBarToken */ || parentNodeOperator === 60 /* SyntaxKind.QuestionQuestionToken */) { if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -77560,10 +77852,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 206 /* PropertyAccessExpression */) { + while (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -77579,19 +77871,19 @@ var ts; var signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode); if (signature === resolvingSignature) { // CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that - // returns a function type. We defer checking and return nonInferrableType. - return nonInferrableType; + // returns a function type. We defer checking and return silentNeverType. + return silentNeverType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return voidType; } - if (node.kind === 209 /* NewExpression */) { + if (node.kind === 209 /* SyntaxKind.NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 171 /* Constructor */ && - declaration.kind !== 175 /* ConstructSignature */ && - declaration.kind !== 180 /* ConstructorType */ && + declaration.kind !== 171 /* SyntaxKind.Constructor */ && + declaration.kind !== 175 /* SyntaxKind.ConstructSignature */ && + declaration.kind !== 180 /* SyntaxKind.ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -77608,11 +77900,11 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* TypeFlags.ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 208 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* ExpressionStatement */ && - returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (node.kind === 208 /* SyntaxKind.CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && + returnType.flags & 16384 /* TypeFlags.Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); } @@ -77625,14 +77917,14 @@ var ts; var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - jsAssignmentType.objectFlags |= 4096 /* JSLiteral */; + jsAssignmentType.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } return returnType; } function checkDeprecatedSignature(signature, node) { - if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) { + if (signature.declaration && signature.declaration.flags & 268435456 /* NodeFlags.Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); @@ -77641,20 +77933,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 208 /* CallExpression */: - case 165 /* Decorator */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 165 /* SyntaxKind.Decorator */: + case 209 /* SyntaxKind.NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.argumentExpression; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -77676,7 +77968,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -77691,13 +77983,13 @@ var ts; for (var i = 2; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* TypeFlags.Undefined */ || specifierType.flags & 65536 /* TypeFlags.Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } if (optionsType) { var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true); if (importCallOptionsType !== emptyObjectType) { - checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]); + checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* TypeFlags.Undefined */), node.arguments[1]); } } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -77713,11 +78005,11 @@ var ts; } function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) { var memberTable = ts.createSymbolTable(); - var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + var newSymbol = createSymbol(2097152 /* SymbolFlags.Alias */, "default" /* InternalSymbolName.Default */); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); newSymbol.aliasTarget = resolveSymbol(symbol); - memberTable.set("default" /* Default */, newSymbol); + memberTable.set("default" /* InternalSymbolName.Default */, newSymbol); return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); } function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) { @@ -77740,7 +78032,7 @@ var ts; var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier); if (hasSyntheticDefault) { - var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var anonymousSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; @@ -77760,40 +78052,40 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } // project includes symbol named 'require' - make sure that it is ambient and local non-alias - if (resolvedRequire.flags & 2097152 /* Alias */) { + if (resolvedRequire.flags & 2097152 /* SymbolFlags.Alias */) { return false; } - var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 256 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 254 /* VariableDeclaration */ - : 0 /* Unknown */; - if (targetDeclarationKind !== 0 /* Unknown */) { + var targetDeclarationKind = resolvedRequire.flags & 16 /* SymbolFlags.Function */ + ? 256 /* SyntaxKind.FunctionDeclaration */ + : resolvedRequire.flags & 3 /* SymbolFlags.Variable */ + ? 254 /* SyntaxKind.VariableDeclaration */ + : 0 /* SyntaxKind.Unknown */; + if (targetDeclarationKind !== 0 /* SyntaxKind.Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 16777216 /* Ambient */); + return !!decl && !!(decl.flags & 16777216 /* NodeFlags.Ambient */); } return false; } function checkTaggedTemplateExpression(node) { if (!checkGrammarTaggedTemplateChain(node)) checkGrammarTypeArguments(node, node.typeArguments); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 262144 /* ExternalEmitHelpers.MakeTemplateObject */); } var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); return getReturnTypeOfSignature(signature); } function checkAssertion(node) { - if (node.kind === 211 /* TypeAssertionExpression */) { + if (node.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { var file = ts.getSourceFileOfNode(node); - if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */])) { grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } @@ -77801,31 +78093,31 @@ var ts; } function isValidConstAssertionArgument(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 223 /* TemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) || + op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node.expression; var symbol = getTypeOfNode(expr).symbol; - if (symbol && symbol.flags & 2097152 /* Alias */) { + if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = resolveAlias(symbol); } - return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); + return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */); } return false; } @@ -77856,12 +78148,12 @@ var ts; return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType); } function checkNonNullAssertion(node) { - return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkNonNullChain(node) : getNonNullableType(checkExpression(node.expression)); } function checkExpressionWithTypeArguments(node) { checkGrammarExpressionWithTypeArguments(node); - var exprType = node.kind === 228 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : + var exprType = node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? checkExpression(node.expression) : ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName); var typeArguments = node.typeArguments; @@ -77886,7 +78178,7 @@ var ts; } return result; function getInstantiatedTypePart(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var callSignatures = getInstantiatedSignatures(resolved.callSignatures); var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures); @@ -77894,12 +78186,12 @@ var ts; hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0); if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) { var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos); - result_11.objectFlags |= 8388608 /* InstantiationExpressionType */; + result_11.objectFlags |= 8388608 /* ObjectFlags.InstantiationExpressionType */; result_11.node = node; return result_11; } } - else if (type.flags & 58982400 /* InstantiableNonPrimitive */) { + else if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { var constraint = getBaseConstraintOfType(type); if (constraint) { var instantiated = getInstantiatedTypePart(constraint); @@ -77908,10 +78200,10 @@ var ts; } } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getInstantiatedType); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart)); } return type; @@ -77927,19 +78219,19 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 103 /* NewKeyword */) { + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 100 /* ImportKeyword */) { + if (node.keywordToken === 100 /* SyntaxKind.ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); } function checkMetaPropertyKeyword(node) { switch (node.keywordToken) { - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return getGlobalImportMetaExpressionType(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: var type = checkNewTargetMetaProperty(node); return isErrorType(type) ? errorType : createNewTargetExpressionType(type); default: @@ -77952,7 +78244,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -77971,7 +78263,7 @@ var ts; error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { @@ -78004,7 +78296,7 @@ var ts; } function getParameterIdentifierNameAtPosition(signature, pos) { var _a; - if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* JSDocFunctionType */) { + if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* SyntaxKind.JSDocFunctionType */) { return undefined; } var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -78036,7 +78328,7 @@ var ts; return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); } function isValidDeclarationForTupleLabel(d) { - return d.kind === 197 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 197 /* SyntaxKind.NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -78086,11 +78378,11 @@ var ts; for (var i = pos; i < parameterCount; i++) { if (!restType || i < parameterCount - 1) { types.push(getTypeAtPosition(source, i)); - flags.push(i < minArgumentCount ? 1 /* Required */ : 2 /* Optional */); + flags.push(i < minArgumentCount ? 1 /* ElementFlags.Required */ : 2 /* ElementFlags.Optional */); } else { types.push(restType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } var name = getNameableDeclarationAtPosition(source, i); if (name) { @@ -78114,14 +78406,14 @@ var ts; return length; } function getMinArgumentCount(signature, flags) { - var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */; - var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */; + var strongArityForUntypedJS = flags & 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */; + var voidIsNonOptional = flags & 2 /* MinArgumentCountFlags.VoidIsNonOptional */; if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) { var minArgumentCount = void 0; if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { - var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); + var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* ElementFlags.Required */); }); var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; if (requiredCount > 0) { minArgumentCount = signature.parameters.length - 1 + requiredCount; @@ -78129,7 +78421,7 @@ var ts; } } if (minArgumentCount === undefined) { - if (!strongArityForUntypedJS && signature.flags & 32 /* IsUntypedSignatureInJSFile */) { + if (!strongArityForUntypedJS && signature.flags & 32 /* SignatureFlags.IsUntypedSignatureInJSFile */) { return 0; } minArgumentCount = signature.minArgumentCount; @@ -78139,7 +78431,7 @@ var ts; } for (var i = minArgumentCount - 1; i >= 0; i--) { var type = getTypeAtPosition(signature, i); - if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, acceptsVoid).flags & 131072 /* TypeFlags.Never */) { break; } minArgumentCount = i; @@ -78169,7 +78461,7 @@ var ts; } function getNonArrayRestType(signature) { var restType = getEffectiveRestType(signature); - return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined; + return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* TypeFlags.Never */) === 0 ? restType : undefined; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -78188,17 +78480,6 @@ var ts; } } } - var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144 /* TypeParameter */) { - // The contextual signature has a generic rest parameter. We first instantiate the contextual - // signature (without fixing type parameters) and assign types to contextually typed parameters. - var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); - assignContextualParameterTypes(signature, instantiatedContext); - // We then infer from a tuple type representing the parameters that correspond to the contextual - // rest parameter. - var restPos = getParameterCount(context) - 1; - inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType); - } } function assignContextualParameterTypes(signature, context) { if (context.typeParameters) { @@ -78233,7 +78514,7 @@ var ts; ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration) // a declarationless parameter may still have a `.type` already set by its construction logic // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type - : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) { + : !!(ts.getCheckFlags(parameter) & 65536 /* CheckFlags.DeferredType */)) { var contextualParameterType = getRestTypeAtPosition(context, len); assignParameterType(parameter, contextualParameterType); } @@ -78253,7 +78534,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter)); - if (declaration && declaration.name.kind !== 79 /* Identifier */) { + if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); @@ -78272,7 +78553,7 @@ var ts; var element = _a[_i]; if (!ts.isOmittedExpression(element)) { var type = getBindingElementTypeFromParentType(element, parentType); - if (element.name.kind === 79 /* Identifier */) { + if (element.name.kind === 79 /* SyntaxKind.Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = type; } else { @@ -78320,8 +78601,8 @@ var ts; } function createNewTargetExpressionType(targetType) { // Create a synthetic type `NewTargetExpression { target: TargetType; }` - var symbol = createSymbol(0 /* None */, "NewTargetExpression"); - var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */); + var symbol = createSymbol(0 /* SymbolFlags.None */, "NewTargetExpression"); + var targetPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "target", 8 /* CheckFlags.Readonly */); targetPropertySymbol.parent = symbol; targetPropertySymbol.type = targetType; var members = ts.createSymbolTable([targetPropertySymbol]); @@ -78333,14 +78614,14 @@ var ts; return errorType; } var functionFlags = ts.getFunctionFlags(func); - var isAsync = (functionFlags & 2 /* Async */) !== 0; - var isGenerator = (functionFlags & 1 /* Generator */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + var isGenerator = (functionFlags & 1 /* FunctionFlags.Generator */) !== 0; var returnType; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 235 /* Block */) { // Async or normal arrow function - returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); + if (func.body.kind !== 235 /* SyntaxKind.Block */) { // Async or normal arrow function + returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -78355,47 +78636,47 @@ var ts; fallbackReturnType = neverType; } else if (returnTypes.length > 0) { - returnType = getUnionType(returnTypes, 2 /* Subtype */); + returnType = getUnionType(returnTypes, 2 /* UnionReduction.Subtype */); } var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes; - yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* Subtype */) : undefined; + yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* UnionReduction.Subtype */) : undefined; nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined; } else { // Async or normal function var types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, voidType) // Async function : voidType; // Normal function } // Return a union of the return expression types. - returnType = getUnionType(types, 2 /* Subtype */); + returnType = getUnionType(types, 2 /* UnionReduction.Subtype */); } if (returnType || yieldType || nextType) { if (yieldType) - reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */); + reportErrorsFromWidening(func, yieldType, 3 /* WideningKind.GeneratorYield */); if (returnType) - reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */); + reportErrorsFromWidening(func, returnType, 1 /* WideningKind.FunctionReturn */); if (nextType) - reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */); + reportErrorsFromWidening(func, nextType, 2 /* WideningKind.GeneratorNext */); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); var contextualType = !contextualSignature ? undefined : contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : - instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); + instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined); if (isGenerator) { - yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync); - returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync); - nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* Next */, isAsync); + yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* IterationTypeKind.Yield */, isAsync); + returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* IterationTypeKind.Return */, isAsync); + nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* IterationTypeKind.Next */, isAsync); } else { returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync); @@ -78409,7 +78690,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* IterationTypeKind.Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -78452,17 +78733,17 @@ var ts; function checkAndAggregateYieldOperandTypes(func, checkMode) { var yieldTypes = []; var nextTypes = []; - var isAsync = (ts.getFunctionFlags(func) & 2 /* Async */) !== 0; + var isAsync = (ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) !== 0; ts.forEachYieldExpression(func.body, function (yieldExpression) { var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType; ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync)); var nextType; if (yieldExpression.asteriskToken) { - var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, yieldExpression.expression); + var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, yieldExpression.expression); nextType = iterationTypes && iterationTypes.nextType; } else { - nextType = getContextualType(yieldExpression); + nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined); } if (nextType) ts.pushIfUnique(nextTypes, nextType); @@ -78472,17 +78753,17 @@ var ts; function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) { var errorNode = node.expression || node; // A `yield*` expression effectively yields everything that its operand yields - var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, expressionType, sentType, errorNode) : expressionType; + var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, expressionType, sentType, errorNode) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } // Return the combined not-equal type facts for all cases except those between the start and end indices. function getNotEqualFactsFromTypeofSwitch(start, end, witnesses) { - var facts = 0 /* None */; + var facts = 0 /* TypeFacts.None */; for (var i = 0; i < witnesses.length; i++) { var witness = i < start || i >= end ? witnesses[i] : undefined; - facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeofNEHostObject */ : 0; + facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeFacts.TypeofNEHostObject */ : 0; } return facts; } @@ -78491,7 +78772,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 216 /* TypeOfExpression */) { + if (node.expression.kind === 216 /* SyntaxKind.TypeOfExpression */) { var witnesses = getSwitchClauseTypeOfWitnesses(node); if (!witnesses) { return false; @@ -78499,9 +78780,9 @@ var ts; var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression)); // Get the not-equal flags for all handled cases. var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses); - if (operandConstraint.flags & 3 /* AnyOrUnknown */) { + if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) { // We special case the top types to be exhaustive when all cases are handled. - return (556800 /* AllTypeofNE */ & notEqualFacts_2) === 556800 /* AllTypeofNE */; + return (556800 /* TypeFacts.AllTypeofNE */ & notEqualFacts_2) === 556800 /* TypeFacts.AllTypeofNE */; } // A missing not-equal flag indicates that the type wasn't handled by some case. return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; }); @@ -78528,15 +78809,15 @@ var ts; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */); - if (functionFlags & 2 /* Async */) { + var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); + if (functionFlags & 2 /* FunctionFlags.Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -78557,11 +78838,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 169 /* MethodDeclaration */: - return func.parent.kind === 205 /* ObjectLiteralExpression */; + case 169 /* SyntaxKind.MethodDeclaration */: + return func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; default: return false; } @@ -78582,17 +78863,17 @@ var ts; var functionFlags = ts.getFunctionFlags(func); var type = returnType && unwrapReturnType(returnType, functionFlags); // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) { + if (type && maybeTypeOfKind(type, 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 168 /* SyntaxKind.MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* SyntaxKind.Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* NodeFlags.HasExplicitReturn */; var errorNode = ts.getEffectiveReturnTypeNode(func) || func; - if (type && type.flags & 131072 /* Never */) { + if (type && type.flags & 131072 /* TypeFlags.Never */) { error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { @@ -78621,13 +78902,13 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (ts.isFunctionExpression(node)) { checkCollisionsForDeclarationName(node, node.name); } // The identityMapper object is used to indicate that function expressions are wildcards - if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { + if (checkMode && checkMode & 4 /* CheckMode.SkipContextSensitive */ && isContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type @@ -78638,9 +78919,9 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray); - returnOnlyType.objectFlags |= 262144 /* NonInferrableType */; + returnOnlyType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -78648,7 +78929,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 213 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 213 /* SyntaxKind.FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -78657,25 +78938,30 @@ var ts; function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) { var links = getNodeLinks(node); // Check if function expression is contextually typed and assign parameter types if so. - if (!(links.flags & 1024 /* ContextChecked */)) { + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { - links.flags |= 1024 /* ContextChecked */; - var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* Call */)); + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { + links.flags |= 1024 /* NodeCheckFlags.ContextChecked */; + var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* SignatureKind.Call */)); if (!signature) { return; } if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); - if (checkMode && checkMode & 2 /* Inferential */) { + var instantiatedContextualSignature = void 0; + if (checkMode && checkMode & 2 /* CheckMode.Inferential */) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); + var restType = getEffectiveRestType(contextualSignature); + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { + instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper); + } } - var instantiatedContextualSignature = inferenceContext ? - instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature; + instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ? + instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature); assignContextualParameterTypes(signature, instantiatedContextualSignature); } else { @@ -78694,7 +78980,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -78707,7 +78993,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 235 /* Block */) { + if (node.body.kind === 235 /* SyntaxKind.Block */) { checkSourceElement(node.body); } else { @@ -78719,7 +79005,7 @@ var ts; var exprType = checkExpression(node.body); var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { // Async function var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } @@ -78777,27 +79063,27 @@ var ts; // Enum members // Object.defineProperty assignments with writable false or no setter // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(ts.getCheckFlags(symbol) & 8 /* Readonly */ || - symbol.flags & 4 /* Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || - symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || - symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - symbol.flags & 8 /* EnumMember */ || + return !!(ts.getCheckFlags(symbol) & 8 /* CheckFlags.Readonly */ || + symbol.flags & 4 /* SymbolFlags.Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* ModifierFlags.Readonly */ || + symbol.flags & 3 /* SymbolFlags.Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */ || + symbol.flags & 98304 /* SymbolFlags.Accessor */ && !(symbol.flags & 65536 /* SymbolFlags.SetAccessor */) || + symbol.flags & 8 /* SymbolFlags.EnumMember */ || ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; - if (assignmentKind === 0 /* None */) { + if (assignmentKind === 0 /* AssignmentKind.None */) { // no assigment means it doesn't matter whether the entity is readonly return false; } if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. - if (symbol.flags & 4 /* Property */ && + if (symbol.flags & 4 /* SymbolFlags.Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 108 /* ThisKeyword */) { + expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 171 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -78818,11 +79104,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; - if (symbol_2.flags & 2097152 /* Alias */) { + if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 268 /* NamespaceImport */; + return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */; } } } @@ -78830,12 +79116,12 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { + var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */); + if (node.kind !== 79 /* SyntaxKind.Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { error(expr, invalidOptionalChainMessage); return false; } @@ -78864,8 +79150,8 @@ var ts; function checkDeleteExpressionMustBeOptional(expr, symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks && - !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && - !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) { + !(type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) && + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* SymbolFlags.Optional */ : getTypeFacts(type) & 16777216 /* TypeFacts.IsUndefined */)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -78883,7 +79169,7 @@ var ts; if (container && ts.isClassStaticBlockDeclaration(container)) { error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); } - else if (!(node.flags & 32768 /* AwaitContext */)) { + else if (!(node.flags & 32768 /* NodeFlags.AwaitContext */)) { if (ts.isInTopLevelContext(node)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -78905,7 +79191,7 @@ var ts; case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: case ts.ModuleKind.System: - if (languageVersion >= 4 /* ES2017 */) { + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { break; } // fallthrough @@ -78922,7 +79208,7 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); - if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + if (container && container.kind !== 171 /* SyntaxKind.Constructor */ && (ts.getFunctionFlags(container) & 2 /* FunctionFlags.Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -78938,7 +79224,7 @@ var ts; addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); }); var operandType = checkExpression(node.expression); var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) { + if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* TypeFlags.AnyOrUnknown */)) { addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); } return awaitedType; @@ -78949,16 +79235,16 @@ var ts; return silentNeverType; } switch (node.operand.kind) { - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: switch (node.operator) { - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text)); - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text)); } break; - case 9 /* BigIntLiteral */: - if (node.operator === 40 /* MinusToken */) { + case 9 /* SyntaxKind.BigIntLiteral */: + if (node.operator === 40 /* SyntaxKind.MinusToken */) { return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -78966,28 +79252,28 @@ var ts; } } switch (node.operator) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* TypeFlags.ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 39 /* PlusToken */) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + if (node.operator === 39 /* SyntaxKind.PlusToken */) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* TypeFlags.BigIntLike */)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); - return facts === 4194304 /* Truthy */ ? falseType : - facts === 8388608 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* TypeFacts.Truthy */ | 8388608 /* TypeFacts.Falsy */); + return facts === 4194304 /* TypeFacts.Truthy */ ? falseType : + facts === 8388608 /* TypeFacts.Falsy */ ? trueType : booleanType; - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -79010,8 +79296,8 @@ var ts; return getUnaryResultType(operandType); } function getUnaryResultType(operandType) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* TypeFlags.AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* TypeFlags.NumberLike */) ? numberOrBigIntType : bigintType; } @@ -79031,7 +79317,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { var t = types_20[_i]; @@ -79046,30 +79332,30 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { + if (strict && source.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */)) { return false; } - return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || - !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* TypeFlags.NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 402653316 /* TypeFlags.StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 528 /* TypeFlags.BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 16384 /* TypeFlags.Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 65536 /* TypeFlags.Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 32768 /* TypeFlags.Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 4096 /* TypeFlags.ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 67108864 /* TypeFlags.NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 1048576 /* Union */ ? + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; + return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { if (leftType === silentNeverType || rightType === silentNeverType) { @@ -79081,7 +79367,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 131068 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -79095,8 +79381,8 @@ var ts; return silentNeverType; } if (ts.isPrivateIdentifier(left)) { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(left, 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */); } // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors @@ -79109,8 +79395,8 @@ var ts; leftType = checkNonNullType(leftType, left); // TypeScript 1.0 spec (April 2014): 4.15.5 // Require the left operand to be of type Any, the String primitive type, or the Number primitive type. - if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { + if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol); } } @@ -79135,9 +79421,9 @@ var ts; // // The result is always of the Boolean primitive type. var rightTypeConstraint = getConstraintOfType(rightType); - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - !maybeTypeOfKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */))) { + if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; @@ -79157,7 +79443,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 296 /* PropertyAssignment */ || property.kind === 297 /* ShorthandPropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */ || property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -79168,17 +79454,17 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* AccessFlags.ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 297 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 298 /* SpreadAssignment */) { + else if (property.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(property, 4 /* Rest */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(property, 4 /* ExternalEmitHelpers.Rest */); } var nonRestNames = []; if (allProperties) { @@ -79200,18 +79486,18 @@ var ts; } function checkArrayLiteralAssignment(node, sourceType, checkMode) { var elements = node.elements; - if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; + var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | 128 /* IterationUse.PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 225 /* SpreadElement */) { - type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); + if (node.elements[i].kind === 225 /* SyntaxKind.SpreadElement */) { + type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); } @@ -79220,15 +79506,15 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 227 /* OmittedExpression */) { - if (element.kind !== 225 /* SpreadElement */) { + if (element.kind !== 227 /* SyntaxKind.OmittedExpression */) { + if (element.kind !== 225 /* SyntaxKind.SpreadElement */) { var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; - var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; + var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* TypeFacts.NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); } @@ -79239,7 +79525,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 221 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { + if (restExpression.kind === 221 /* SyntaxKind.BinaryExpression */ && restExpression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -79255,14 +79541,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 297 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* IsUndefined */)) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* TypeFacts.IsUndefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -79271,35 +79557,35 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { + if (target.kind === 221 /* SyntaxKind.BinaryExpression */ && target.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; // A default value is specified, so remove undefined from the final type. if (strictNullChecks) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } } - if (target.kind === 205 /* ObjectLiteralExpression */) { + if (target.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 204 /* ArrayLiteralExpression */) { + if (target.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 298 /* SpreadAssignment */ ? + var error = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 298 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { - checkExternalEmitHelpers(target.parent, 1048576 /* ClassPrivateFieldSet */); + checkExternalEmitHelpers(target.parent, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } return sourceType; } @@ -79314,59 +79600,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 210 /* TaggedTemplateExpression */: - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 153 /* UndefinedKeyword */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 216 /* TypeOfExpression */: - case 230 /* NonNullExpression */: - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: return true; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 53 /* ExclamationToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: return true; } return false; // Some forms listed here for clarity - case 217 /* VoidExpression */: // Explicit opt-out - case 211 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 229 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 217 /* SyntaxKind.VoidExpression */: // Explicit opt-out + case 211 /* SyntaxKind.TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 229 /* SyntaxKind.AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* TypeFlags.Nullable */) !== 0 || isTypeComparableTo(source, target); } function createCheckBinaryExpression() { var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); @@ -79397,9 +79683,9 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (node.left.kind === 205 /* ObjectLiteralExpression */ || node.left.kind === 204 /* ArrayLiteralExpression */)) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && (node.left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { state.skip = true; - setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* SyntaxKind.ThisKeyword */)); return state; } return state; @@ -79416,9 +79702,13 @@ var ts; setLeftType(state, leftType); setLastResult(state, /*type*/ undefined); var operator = operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */) { + var parent = node.parent; + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ + || ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */)) { + parent = parent.parent; + } checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } checkTruthinessOfType(leftType, node.left); @@ -79477,11 +79767,11 @@ var ts; } function checkGrammarNullishCoalesceWithLogicalExpression(node) { var left = node.left, operatorToken = node.operatorToken, right = node.right; - if (operatorToken.kind === 60 /* QuestionQuestionToken */) { - if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || left.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } - if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || right.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } } @@ -79490,11 +79780,11 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (left.kind === 205 /* ObjectLiteralExpression */ || left.kind === 204 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); + if (operator === 63 /* SyntaxKind.EqualsToken */ && (left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* SyntaxKind.ThisKeyword */); } var leftType; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -79506,28 +79796,28 @@ var ts; function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) { var operator = operatorToken.kind; switch (operator) { - case 41 /* AsteriskToken */: - case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 44 /* PercentToken */: - case 69 /* PercentEqualsToken */: - case 40 /* MinusToken */: - case 65 /* MinusEqualsToken */: - case 47 /* LessThanLessThanToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 44 /* SyntaxKind.PercentToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 40 /* SyntaxKind.MinusToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -79536,8 +79826,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 528 /* BooleanLike */) && - (rightType.flags & 528 /* BooleanLike */) && + if ((leftType.flags & 528 /* TypeFlags.BooleanLike */) && + (rightType.flags & 528 /* TypeFlags.BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); return numberType; @@ -79548,21 +79838,21 @@ var ts; var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, /*isAwaitValid*/ true); var resultType_1; // If both are any or unknown, allow operation; assume it will resolve to number - if ((isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */)) || + if ((isTypeAssignableToKind(leftType, 3 /* TypeFlags.AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* TypeFlags.AnyOrUnknown */)) || // Or, if neither could be bigint, implicit coercion results in a number result - !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + !(maybeTypeOfKind(leftType, 2112 /* TypeFlags.BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* TypeFlags.BigIntLike */))) { resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; - case 42 /* AsteriskAsteriskToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - if (languageVersion < 3 /* ES2016 */) { + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } } @@ -79578,26 +79868,26 @@ var ts; } return resultType_1; } - case 39 /* PlusToken */: - case 64 /* PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* TypeFlags.NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* TypeFlags.NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true)) { // If both operands are of the BigInt primitive type, the result is of the BigInt primitive type. resultType = bigintType; } - else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -79615,21 +79905,21 @@ var ts; // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. - var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */; + var closeEnoughKind_1 = 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 3 /* TypeFlags.AnyOrUnknown */; reportOperatorError(function (left, right) { return isTypeAssignableToKind(left, closeEnoughKind_1) && isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 64 /* PlusEqualsToken */) { + if (operator === 64 /* SyntaxKind.PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -79638,60 +79928,60 @@ var ts; }); } return booleanType; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: if (ts.isLiteralExpressionOfObject(left) || ts.isLiteralExpressionOfObject(right)) { - var eqType = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; + var eqType = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true"); } reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 55 /* AmpersandAmpersandToken */: - case 76 /* AmpersandAmpersandEqualsToken */: { - var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: { + var resultType_2 = getTypeFacts(leftType) & 4194304 /* TypeFacts.Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 76 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } - case 56 /* BarBarToken */: - case 75 /* BarBarEqualsToken */: { - var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? - getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : + case 56 /* SyntaxKind.BarBarToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: { + var resultType_3 = getTypeFacts(leftType) & 8388608 /* TypeFacts.Falsy */ ? + getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 75 /* BarBarEqualsToken */) { + if (operator === 75 /* SyntaxKind.BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } - case 60 /* QuestionQuestionToken */: - case 77 /* QuestionQuestionEqualsToken */: { - var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? - getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: { + var resultType_4 = getTypeFacts(leftType) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 77 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* SyntaxKind.QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 63 /* EqualsToken */: - var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; + case 63 /* SyntaxKind.EqualsToken */: + var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* AssignmentDeclarationKind.None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { - if (!(rightType.flags & 524288 /* Object */) || - declKind !== 2 /* ModuleExports */ && - declKind !== 6 /* Prototype */ && + if (!(rightType.flags & 524288 /* TypeFlags.Object */) || + declKind !== 2 /* AssignmentDeclarationKind.ModuleExports */ && + declKind !== 6 /* AssignmentDeclarationKind.Prototype */ && !isEmptyObjectType(rightType) && !isFunctionObjectType(rightType) && - !(ts.getObjectFlags(rightType) & 1 /* Class */)) { + !(ts.getObjectFlags(rightType) & 1 /* ObjectFlags.Class */)) { // don't check assignability of module.exports=, C.prototype=, or expando types because they will necessarily be incomplete checkAssignmentOperator(rightType); } @@ -79701,7 +79991,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { var sf = ts.getSourceFileOfNode(left); var sourceText = sf.text; @@ -79719,16 +80009,16 @@ var ts; return ts.Debug.fail(); } function bothAreBigIntLike(left, right) { - return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + return isTypeAssignableToKind(left, 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableToKind(right, 2112 /* TypeFlags.BigIntLike */); } function checkAssignmentDeclaration(kind, rightType) { - if (kind === 2 /* ModuleExports */) { + if (kind === 2 /* AssignmentDeclarationKind.ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { var prop = _a[_i]; var propType = getTypeOfSymbol(prop); - if (propType.symbol && propType.symbol.flags & 32 /* Class */) { + if (propType.symbol && propType.symbol.flags & 32 /* SymbolFlags.Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* SymbolFlags.Type */, undefined, name, /*isUse*/ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) { addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); @@ -79738,12 +80028,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : - maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* TypeFlags.ESSymbolLike */) ? left : + maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* TypeFlags.ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -79753,15 +80043,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - return 56 /* BarBarToken */; - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - return 37 /* ExclamationEqualsEqualsToken */; - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: - return 55 /* AmpersandAmpersandToken */; + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + return 56 /* SyntaxKind.BarBarToken */; + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + return 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + return 55 /* SyntaxKind.AmpersandAmpersandToken */; default: return undefined; } @@ -79780,7 +80070,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { var headMessage = void 0; - if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) { + if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* TypeFlags.Undefined */)) { var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText); if (isExactOptionalPropertyMismatch(valueType, target)) { headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target; @@ -79794,13 +80084,13 @@ var ts; function isAssignmentDeclaration(kind) { var _a; switch (kind) { - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: return true; - case 1 /* ExportsProperty */: - case 5 /* Property */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: - case 4 /* ThisProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var symbol = getSymbolOfNode(left); var init = ts.getAssignedExpandoInitializer(right); return !!init && ts.isObjectLiteralExpression(init) && @@ -79843,12 +80133,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: typeName = "false"; break; - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -79874,20 +80164,20 @@ var ts; if (!func) return anyType; var functionFlags = ts.getFunctionFlags(func); - if (!(functionFlags & 1 /* Generator */)) { + if (!(functionFlags & 1 /* FunctionFlags.Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; } - var isAsync = (functionFlags & 2 /* Async */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; if (node.asteriskToken) { // Async generator functions prior to ESNext require the __await, __asyncDelegator, // and __asyncValues helpers - if (isAsync && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */); + if (isAsync && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 26624 /* ExternalEmitHelpers.AsyncDelegatorIncludes */); } // Generator functions prior to ES2015 require the __values helper - if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 256 /* Values */); + if (!isAsync && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.Values */); } } // There is no point in doing an assignability check if the function @@ -79904,20 +80194,20 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression); } if (node.asteriskToken) { - var use = isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */; - return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression) + var use = isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */; + return getIterationTypeOfIterable(use, 1 /* IterationTypeKind.Return */, yieldExpressionType, node.expression) || anyType; } else if (returnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) + return getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, isAsync) || anyType; } - var type = getContextualIterationType(2 /* Next */, func); + var type = getContextualIterationType(2 /* IterationTypeKind.Next */, func); if (!type) { type = anyType; addLazyDiagnostic(function () { if (noImplicitAny && !ts.expressionResultIsUnused(node)) { - var contextualType = getContextualType(node); + var contextualType = getContextualType(node, /*contextFlags*/ undefined); if (!contextualType || isTypeAny(contextualType)) { error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation); } @@ -79926,7 +80216,7 @@ var ts; } return type; function checkYieldExpressionGrammar() { - if (!(node.flags & 8192 /* YieldContext */)) { + if (!(node.flags & 8192 /* NodeFlags.YieldContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -79939,7 +80229,7 @@ var ts; checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); - return getUnionType([type1, type2], 2 /* Subtype */); + return getUnionType([type1, type2], 2 /* UnionReduction.Subtype */); } function isTemplateLiteralContext(node) { var parent = node.parent; @@ -79952,20 +80242,20 @@ var ts; for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { var span = _a[_i]; var type = checkExpression(span.expression); - if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) { error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; + return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { - return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || - type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); + return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) || + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */)); } function getContextNode(node) { - if (node.kind === 286 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 286 /* SyntaxKind.JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -79977,7 +80267,7 @@ var ts; try { context.contextualType = contextualType; context.inferenceContext = inferenceContext; - var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0)); + var type = checkExpression(node, checkMode | 1 /* CheckMode.Contextual */ | (inferenceContext ? 2 /* CheckMode.Inferential */ : 0)); // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type // parameters. This information is no longer needed after the call to checkExpression. if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { @@ -79986,7 +80276,7 @@ var ts; // We strip literal freshness when an appropriate contextual type is present such that contextually typed // literals always preserve their literal types (otherwise they might widen during type inference). An alternative // here would be to not mark contextually typed literals as fresh in the first place. - var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* TypeFlags.Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -79999,7 +80289,7 @@ var ts; } } function checkExpressionCached(node, checkMode) { - if (checkMode && checkMode !== 0 /* Normal */) { + if (checkMode && checkMode !== 0 /* CheckMode.Normal */) { return checkExpression(node, checkMode); } var links = getNodeLinks(node); @@ -80019,17 +80309,17 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 211 /* TypeAssertionExpression */ || - node.kind === 229 /* AsExpression */ || + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */ || + node.kind === 229 /* SyntaxKind.AsExpression */ || ts.isJSDocTypeAssertion(node); } function checkDeclarationInitializer(declaration, checkMode, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? - checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */) + checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* CheckMode.Normal */) : checkExpressionCached(initializer, checkMode)); - return ts.isParameter(declaration) && declaration.name.kind === 202 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -80039,9 +80329,9 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 203 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 203 /* SyntaxKind.BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); } @@ -80050,7 +80340,7 @@ var ts; return createTupleType(elementTypes, elementFlags, type.target.readonly); } function widenTypeInferredFromInitializer(declaration, type) { - var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); + var widened = ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); @@ -80065,28 +80355,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 3145728 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || unknownType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* TypeFlags.String */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* TypeFlags.Number */) && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + maybeTypeOfKind(constraint, 64 /* TypeFlags.BigInt */) && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + maybeTypeOfKind(constraint, 4096 /* TypeFlags.ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || - contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* TypeFlags.StringLiteral */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + contextualType.flags & 256 /* TypeFlags.NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + contextualType.flags & 2048 /* TypeFlags.BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + contextualType.flags & 512 /* TypeFlags.BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* TypeFlags.BooleanLiteral */) || + contextualType.flags & 8192 /* TypeFlags.UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */)); } return false; } @@ -80101,13 +80391,13 @@ var ts; var type = checkExpression(node, checkMode, forceTuple); return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) : isTypeAssertion(node) ? type : - getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node)); + getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined)); } function checkPropertyAssignment(node, checkMode) { // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -80118,23 +80408,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { - if (checkMode && checkMode & (2 /* Inferential */ | 8 /* SkipGenericFunctions */)) { - var callSignature = getSingleSignature(type, 0 /* Call */, /*allowMembers*/ true); - var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); + if (checkMode && checkMode & (2 /* CheckMode.Inferential */ | 8 /* CheckMode.SkipGenericFunctions */)) { + var callSignature = getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ true); + var constructSignature = getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + var contextualType = getApparentTypeOfContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { - var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); + var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { - if (checkMode & 8 /* SkipGenericFunctions */) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */) { skippedGenericFunction(node, checkMode); return anyFunctionType; } @@ -80182,11 +80472,11 @@ var ts; return type; } function skippedGenericFunction(node, checkMode) { - if (checkMode & 2 /* Inferential */) { + if (checkMode & 2 /* CheckMode.Inferential */) { // We have skipped a generic function during inferential typing. Obtain the inference context and // indicate this has occurred such that we know a second pass of inference is be needed. var context = getInferenceContext(node); - context.flags |= 4 /* SkippedGenericFunction */; + context.flags |= 4 /* InferenceFlags.SkippedGenericFunction */; } } function hasInferenceCandidates(info) { @@ -80211,12 +80501,12 @@ var ts; var result = []; var oldTypeParameters; var newTypeParameters; - for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { - var tp = typeParameters_2[_i]; + for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { + var tp = typeParameters_3[_i]; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); - var symbol = createSymbol(262144 /* TypeParameter */, newName); + var symbol = createSymbol(262144 /* SymbolFlags.TypeParameter */, newName); var newTypeParameter = createTypeParameter(symbol); newTypeParameter.target = tp; oldTypeParameters = ts.append(oldTypeParameters, tp); @@ -80241,7 +80531,7 @@ var ts; } function getUniqueTypeParameterName(typeParameters, baseName) { var len = baseName.length; - while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* _0 */ && baseName.charCodeAt(len - 1) <= 57 /* _9 */) + while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* CharacterCodes._0 */ && baseName.charCodeAt(len - 1) <= 57 /* CharacterCodes._9 */) len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { @@ -80274,7 +80564,7 @@ var ts; return quickType; } // If a type has been cached for the node, return it. - if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) { + if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) { var cachedType = flowTypeCache[getNodeId(node)]; if (cachedType) { return cachedType; @@ -80286,7 +80576,7 @@ var ts; if (flowInvocationCount !== startInvocationCount) { var cache = flowTypeCache || (flowTypeCache = []); cache[getNodeId(node)] = type; - ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */); + ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */); } return type; } @@ -80301,7 +80591,7 @@ var ts; expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -80311,8 +80601,8 @@ var ts; else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { return getTypeFromTypeNode(expr.type); } - else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { + else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ || + node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) { return checkExpression(node); } return undefined; @@ -80332,7 +80622,7 @@ var ts; var saveContextualType = node.contextualType; node.contextualType = anyType; try { - var type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */); + var type = links.contextFreeType = checkExpression(node, 4 /* CheckMode.SkipContextSensitive */); return type; } finally { @@ -80343,7 +80633,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -80361,18 +80651,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 207 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 181 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 275 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { - ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 16777216 /* Ambient */) { + if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -80390,113 +80680,113 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return checkIdentifier(node, checkMode); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifierExpression(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return checkThisExpression(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return nullWideningType; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getFreshTypeOfLiteralType(getStringLiteralType(node.text)); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text)); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: false, base10Value: ts.parsePseudoBigInt(node.text) })); - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: return trueType; - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return falseType; - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return checkTemplateExpression(node); - case 13 /* RegularExpressionLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: return globalRegExpType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return checkQualifiedName(node, checkMode); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 208 /* CallExpression */: - if (node.expression.kind === 100 /* ImportKeyword */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.expression.kind === 100 /* SyntaxKind.ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checkCallExpression(node, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return checkClassExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return checkTypeOfExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return checkAssertion(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return checkNonNullAssertion(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return checkExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkMetaProperty(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkDeleteExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return checkVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return checkAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return checkSpreadExpression(node, checkMode); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return undefinedWideningType; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return checkYieldExpression(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return checkSyntheticExpression(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return checkJsxExpression(node, checkMode); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return checkJsxElement(node, checkMode); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return checkJsxFragment(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -80530,16 +80820,18 @@ var ts; var modifiers = getVarianceModifiers(typeParameter); if (modifiers) { var symbol = getSymbolOfNode(node.parent); - if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) { + if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */))) { error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); } - else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType); + else if (modifiers === 32768 /* ModifierFlags.In */ || modifiers === 65536 /* ModifierFlags.Out */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) }); + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck); var saveVarianceTypeParameter = typeParameter; varianceTypeParameter = typeParameter; checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); varianceTypeParameter = saveVarianceTypeParameter; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } } } @@ -80552,28 +80844,28 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 171 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { + if (!(func.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 171 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 171 /* SyntaxKind.Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } - if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { + if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) { error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); } if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) { if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 171 /* Constructor */ || func.kind === 175 /* ConstructSignature */ || func.kind === 180 /* ConstructorType */) { + if (func.kind === 171 /* SyntaxKind.Constructor */ || func.kind === 175 /* SyntaxKind.ConstructSignature */ || func.kind === 180 /* SyntaxKind.ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 172 /* GetAccessor */ || func.kind === 173 /* SetAccessor */) { + if (func.kind === 172 /* SyntaxKind.GetAccessor */ || func.kind === 173 /* SyntaxKind.SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -80597,7 +80889,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { + if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -80631,13 +80923,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 179 /* FunctionType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 179 /* SyntaxKind.FunctionType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -80651,11 +80943,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* SyntaxKind.Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 202 /* ArrayBindingPattern */ || name.kind === 201 /* ObjectBindingPattern */) { + else if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -80664,29 +80956,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 176 /* IndexSignature */) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 179 /* FunctionType */ || node.kind === 256 /* FunctionDeclaration */ || node.kind === 180 /* ConstructorType */ || - node.kind === 174 /* CallSignature */ || node.kind === 171 /* Constructor */ || - node.kind === 175 /* ConstructSignature */) { + else if (node.kind === 179 /* SyntaxKind.FunctionType */ || node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 180 /* SyntaxKind.ConstructorType */ || + node.kind === 174 /* SyntaxKind.CallSignature */ || node.kind === 171 /* SyntaxKind.Constructor */ || + node.kind === 175 /* SyntaxKind.ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); - if (!(functionFlags & 4 /* Invalid */)) { + if (!(functionFlags & 4 /* FunctionFlags.Invalid */)) { // Async generators prior to ESNext require the __await and __asyncGenerator helpers - if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 3 /* FunctionFlags.AsyncGenerator */ && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 6144 /* ExternalEmitHelpers.AsyncGeneratorIncludes */); } // Async functions prior to ES2017 require the __awaiter helper - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { - checkExternalEmitHelpers(node, 64 /* Awaiter */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */ && languageVersion < 4 /* ScriptTarget.ES2017 */) { + checkExternalEmitHelpers(node, 64 /* ExternalEmitHelpers.Awaiter */); } // Generator functions, Async functions, and Async Generator functions prior to // ES2015 require the __generator helper - if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 128 /* Generator */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) !== 0 /* FunctionFlags.Normal */ && languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 128 /* ExternalEmitHelpers.Generator */); } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); @@ -80702,17 +80994,17 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (returnTypeNode) { var functionFlags_1 = ts.getFunctionFlags(node); - if ((functionFlags_1 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) { + if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) { var returnType = getTypeFromTypeNode(returnTypeNode); if (returnType === voidType) { error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -80724,18 +81016,18 @@ var ts; // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; - var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || generatorYieldType; - var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || unknownType; - var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* Async */)); + var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType; + var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType; + var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType; + var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */)); checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode); } } - else if ((functionFlags_1 & 3 /* AsyncGenerator */) === 2 /* Async */) { + else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 176 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) { + if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -80747,11 +81039,11 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 171 /* Constructor */) { + if (member.kind === 171 /* SyntaxKind.Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); + addName(instanceNames, param.name, param.name.escapedText, 3 /* DeclarationMeaning.GetOrSetAccessor */); } } } @@ -80762,24 +81054,24 @@ var ts; continue; } var isPrivate = ts.isPrivateIdentifier(name); - var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0; + var privateStaticFlags = isPrivate && isStaticMember ? 16 /* DeclarationMeaning.PrivateStatic */ : 0; var names = isPrivate ? privateIdentifiers : isStaticMember ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 172 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); + case 172 /* SyntaxKind.GetAccessor */: + addName(names, name, memberName, 1 /* DeclarationMeaning.GetAccessor */ | privateStaticFlags); break; - case 173 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); + case 173 /* SyntaxKind.SetAccessor */: + addName(names, name, memberName, 2 /* DeclarationMeaning.SetAccessor */ | privateStaticFlags); break; - case 167 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: + addName(names, name, memberName, 3 /* DeclarationMeaning.GetOrSetAccessor */ | privateStaticFlags); break; - case 169 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); + case 169 /* SyntaxKind.MethodDeclaration */: + addName(names, name, memberName, 8 /* DeclarationMeaning.Method */ | privateStaticFlags); break; } } @@ -80789,19 +81081,19 @@ var ts; var prev = names.get(name); if (prev) { // For private identifiers, do not allow mixing of static and instance members with the same name - if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + if ((prev & 16 /* DeclarationMeaning.PrivateStatic */) !== (meaning & 16 /* DeclarationMeaning.PrivateStatic */)) { error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - var prevIsMethod = !!(prev & 8 /* Method */); - var isMethod = !!(meaning & 8 /* Method */); + var prevIsMethod = !!(prev & 8 /* DeclarationMeaning.Method */); + var isMethod = !!(meaning & 8 /* DeclarationMeaning.Method */); if (prevIsMethod || isMethod) { if (prevIsMethod !== isMethod) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered } - else if (prev & meaning & ~16 /* PrivateStatic */) { + else if (prev & meaning & ~16 /* DeclarationMeaning.PrivateStatic */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { @@ -80850,15 +81142,15 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 166 /* PropertySignature */) { + if (member.kind === 166 /* SyntaxKind.PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: memberName = name.text; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: memberName = ts.idText(name); break; default: @@ -80875,7 +81167,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -80889,7 +81181,7 @@ var ts; var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var indexSignatureMap_1 = new ts.Map(); - var _loop_28 = function (declaration) { + var _loop_29 = function (declaration) { if (declaration.parameters.length === 1 && declaration.parameters[0].type) { forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) { var entry = indexSignatureMap_1.get(getTypeId(type)); @@ -80904,7 +81196,7 @@ var ts; }; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - _loop_28(declaration); + _loop_29(declaration); } indexSignatureMap_1.forEach(function (entry) { if (entry.declarations.length > 1) { @@ -80923,7 +81215,7 @@ var ts; checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); // property signatures already report "initializer not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* PropertyDeclaration */ && node.initializer) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && node.initializer) { error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -80943,7 +81235,7 @@ var ts; // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // method signatures already report "implementation not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 169 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } // Private named methods are only allowed in class declarations @@ -80953,9 +81245,9 @@ var ts; setNodeLinksForPrivateIdentifierScope(node); } function setNodeLinksForPrivateIdentifierScope(node) { - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ScriptTarget.ESNext */) { for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; + getNodeLinks(lexicalScope).flags |= 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */; } // If this is a private element in a class expression inside the body of a loop, // then we must use a block-scoped binding to store the additional variables required @@ -80963,8 +81255,8 @@ var ts; if (ts.isClassExpression(node.parent)) { var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); if (enclosingIterationStatement) { - getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(node.name).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } } @@ -80996,7 +81288,7 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 167 /* PropertyDeclaration */ && + return n.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(n) && !!n.initializer; } @@ -81017,9 +81309,9 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && + var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ModifierFlags.ParameterPropertyModifier */); })); if (superCallShouldBeRootLevel) { // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional // See GH #8277 @@ -81058,7 +81350,7 @@ var ts; return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body; } function nodeImmediatelyReferencesSuperOrThis(node) { - if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || node.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } if (ts.isThisContainerOrFunctionBlock(node)) { @@ -81079,9 +81371,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 172 /* GetAccessor */) { - if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { - if (!(node.flags & 512 /* HasExplicitReturn */)) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* NodeFlags.HasImplicitReturn */)) { + if (!(node.flags & 512 /* NodeFlags.HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -81089,25 +81381,25 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var symbol = getSymbolOfNode(node); - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); - if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { - getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* NodeCheckFlags.TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* NodeCheckFlags.TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); var setterFlags = ts.getEffectiveModifierFlags(setter); - if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) { + if ((getterFlags & 128 /* ModifierFlags.Abstract */) !== (setterFlags & 128 /* ModifierFlags.Abstract */)) { error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) || - ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) { + if (((getterFlags & 16 /* ModifierFlags.Protected */) && !(setterFlags & (16 /* ModifierFlags.Protected */ | 8 /* ModifierFlags.Private */))) || + ((getterFlags & 8 /* ModifierFlags.Private */) && !(setterFlags & 8 /* ModifierFlags.Private */))) { error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -81119,7 +81411,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -81127,6 +81419,12 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function getEffectiveTypeArgumentAtIndex(node, typeParameters, index) { + if (index < typeParameters.length) { + return getTypeFromTypeNode(node.typeArguments[index]); + } + return getEffectiveTypeArguments(node, typeParameters)[index]; + } function getEffectiveTypeArguments(node, typeParameters) { return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node)); } @@ -81151,15 +81449,15 @@ var ts; if (!isErrorType(type)) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || - (ts.getObjectFlags(type) & 4 /* Reference */ ? type.target.localTypeParameters : undefined); + return symbol.flags & 524288 /* SymbolFlags.TypeAlias */ && getSymbolLinks(symbol).typeParameters || + (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target.localTypeParameters : undefined); } } return undefined; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 178 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -81175,10 +81473,10 @@ var ts; } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) { + if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) { addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } - if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -81217,29 +81515,29 @@ var ts; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) { var e = elementTypes_1[_i]; - if (e.kind !== 197 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 197 /* SyntaxKind.NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } var flags = getTupleElementFlags(e); - if (flags & 8 /* Variadic */) { + if (flags & 8 /* ElementFlags.Variadic */) { var type = getTypeFromTypeNode(e.type); if (!isArrayLikeType(type)) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); break; } - if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) { + if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* ElementFlags.Rest */) { seenRestElement = true; } } - else if (flags & 4 /* Rest */) { + else if (flags & 4 /* ElementFlags.Rest */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element); break; } seenRestElement = true; } - else if (flags & 2 /* Optional */) { + else if (flags & 2 /* ElementFlags.Optional */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element); break; @@ -81259,15 +81557,15 @@ var ts; getTypeFromTypeNode(node); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 8388608 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* TypeFlags.IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 207 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && - ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { + if (accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + ts.getObjectFlags(objectType) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; @@ -81275,14 +81573,14 @@ var ts; // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. var apparentObjectType = getApparentType(objectType); - if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { return type; } if (isGenericObjectType(objectType)) { var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode); if (propertyName_1) { var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); }); - if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) { error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1)); return errorType; } @@ -81331,7 +81629,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* SyntaxKind.ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -81341,7 +81639,7 @@ var ts; if (!links.typeParametersChecked) { links.typeParametersChecked = true; var typeParameter = getDeclaredTypeOfTypeParameter(symbol); - var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */); + var declarations = ts.getDeclarationsOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); @@ -81382,31 +81680,31 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 185 /* OptionalType */) { + if (node.type.kind === 185 /* SyntaxKind.OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 186 /* RestType */) { + if (node.type.kind === 186 /* SyntaxKind.RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* NodeFlags.Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 258 /* InterfaceDeclaration */ && - n.parent.kind !== 257 /* ClassDeclaration */ && - n.parent.kind !== 226 /* ClassExpression */ && - n.flags & 16777216 /* Ambient */) { - if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { + if (n.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */ && + n.parent.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + n.parent.kind !== 226 /* SyntaxKind.ClassExpression */ && + n.flags & 16777216 /* NodeFlags.Ambient */) { + if (!(flags & 2 /* ModifierFlags.Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; } return flags & flagsToCheck; } @@ -81431,16 +81729,16 @@ var ts; var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; - if (deviation & 1 /* Export */) { + if (deviation & 1 /* ModifierFlags.Export */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 2 /* ModifierFlags.Ambient */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 128 /* Abstract */) { + else if (deviation & 128 /* ModifierFlags.Abstract */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -81457,8 +81755,8 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; - var someNodeFlags = 0 /* None */; + var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */; + var someNodeFlags = 0 /* ModifierFlags.None */; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; var allHaveQuestionToken = true; @@ -81467,7 +81765,7 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0; function reportImplementationExpectedError(node) { if (node.name && ts.nodeIsMissing(node.name)) { return; @@ -81496,7 +81794,7 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */) && + var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) && ts.isStatic(node) !== ts.isStatic(subsequentNode); // we can get here in two cases // 1. mixed static and instance class members @@ -81521,7 +81819,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -81537,8 +81835,8 @@ var ts; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var current = declarations_5[_i]; var node = current; - var inAmbientContext = node.flags & 16777216 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -81549,10 +81847,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 256 /* FunctionDeclaration */ || node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */ || node.kind === 171 /* Constructor */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */ || node.kind === 171 /* SyntaxKind.Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -81596,13 +81894,13 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { - var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* ClassDeclaration */; }) + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* SymbolFlags.Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* SyntaxKind.ClassDeclaration */; }) .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - var diagnostic = declaration.kind === 257 /* ClassDeclaration */ + var diagnostic = declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 - : declaration.kind === 256 /* FunctionDeclaration */ + : declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : undefined; if (diagnostic) { @@ -81612,7 +81910,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* ModifierFlags.Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -81652,15 +81950,15 @@ var ts; if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; + var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 512 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */); + if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) { + if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -81693,56 +81991,56 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: - return 2 /* ExportType */; - case 261 /* ModuleDeclaration */: - return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4 /* ExportNamespace */ | 1 /* ExportValue */ - : 4 /* ExportNamespace */; - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - return 2 /* ExportType */ | 1 /* ExportValue */; - case 305 /* SourceFile */: - return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + return 2 /* DeclarationSpaces.ExportType */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* ModuleInstanceState.NonInstantiated */ + ? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */ + : 4 /* DeclarationSpaces.ExportNamespace */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */; + case 305 /* SyntaxKind.SourceFile */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */; + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: var node_2 = d; var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(expression)) { - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; } d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: - var result_12 = 0 /* None */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + var result_12 = 0 /* DeclarationSpaces.None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 256 /* FunctionDeclaration */: - case 270 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* SyntaxKind.Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) // or SyntaxKind.PropertyAccessExpression - `thing.aField = 42;` // all of which are pretty much always values, or at least imply a value meaning. // It may be apprpriate to treat these as aliases in the future. - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); } @@ -81778,14 +82076,14 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } // primitives with a `{ then() }` won't be unwrapped/adopted. - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { return undefined; } var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : ts.emptyArray; + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* SignatureKind.Call */) : ts.emptyArray; if (thenSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); @@ -81814,18 +82112,18 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* TypeFacts.NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* SignatureKind.Call */); if (onfulfilledParameterSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); } return undefined; } - return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* Subtype */); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* UnionReduction.Subtype */); } /** * Gets the "awaited type" of a type. @@ -81845,16 +82143,16 @@ var ts; * Determines whether a type is an object with a callable `then` member. */ function isThenableType(type) { - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { // primitive types cannot be considered "thenable" since they are not objects. return false; } var thenFunction = getTypeOfPropertyOfType(type, "then"); - return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; + return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* TypeFacts.NEUndefinedOrNull */), 0 /* SignatureKind.Call */).length > 0; } function isAwaitedTypeInstantiation(type) { var _a; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false); return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1; } @@ -81864,10 +82162,38 @@ var ts; * For a generic `Awaited`, gets `T`. */ function unwrapAwaitedType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, unwrapAwaitedType) : isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } + function isAwaitedTypeNeeded(type) { + // If this is already an `Awaited`, we shouldn't wrap it. This helps to avoid `Awaited>` in higher-order. + if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) { + return false; + } + // We only need `Awaited` if `T` contains possibly non-primitive types. + if (isGenericObjectType(type)) { + var baseConstraint = getBaseConstraintOfType(type); + // We only need `Awaited` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, + // or is promise-like. + if (baseConstraint ? + baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) : + maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) { + return true; + } + } + return false; + } + function tryCreateAwaitedType(type) { + // Nothing to do if `Awaited` doesn't exist + var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); + if (awaitedSymbol) { + // Unwrap unions that may contain `Awaited`, otherwise its possible to manufacture an `Awaited | U>` where + // an `Awaited` would suffice. + return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); + } + return undefined; + } function createAwaitedTypeIfNeeded(type) { // We wrap type `T` in `Awaited` based on the following conditions: // - `T` is not already an `Awaited`, and @@ -81876,26 +82202,10 @@ var ts; // - `T` has no base constraint, or // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or // - The base constraint of `T` is an object type with a callable `then` method. - if (isTypeAny(type)) { - return type; - } - // If this is already an `Awaited`, just return it. This helps to avoid `Awaited>` in higher-order. - if (isAwaitedTypeInstantiation(type)) { - return type; - } - // Only instantiate `Awaited` if `T` contains possibly non-primitive types. - if (isGenericObjectType(type)) { - var baseConstraint = getBaseConstraintOfType(type); - // Only instantiate `Awaited` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, - // or is promise-like. - if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { - // Nothing to do if `Awaited` doesn't exist - var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); - if (awaitedSymbol) { - // Unwrap unions that may contain `Awaited`, otherwise its possible to manufacture an `Awaited | U>` where - // an `Awaited` would suffice. - return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); - } + if (isAwaitedTypeNeeded(type)) { + var awaitedType = tryCreateAwaitedType(type); + if (awaitedType) { + return awaitedType; } } ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like."); @@ -81934,9 +82244,22 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } // For a union, get a union of the awaited types of each constituent. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { + if (awaitedTypeStack.lastIndexOf(type.id) >= 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; - return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); + awaitedTypeStack.push(type.id); + var mapped = mapType(type, mapper); + awaitedTypeStack.pop(); + return typeAsAwaitable.awaitedTypeOfType = mapped; + } + // If `type` is generic and should be wrapped in `Awaited`, return it. + if (isAwaitedTypeNeeded(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; } var thisTypeForErrorOut = { value: undefined }; var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut); @@ -82057,7 +82380,7 @@ var ts; // } // var returnType = getTypeFromTypeNode(returnTypeNode); - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { if (isErrorType(returnType)) { return; } @@ -82080,10 +82403,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (isErrorType(promiseConstructorType)) { - if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* SyntaxKind.Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -82103,7 +82426,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* SymbolFlags.Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -82116,26 +82439,26 @@ var ts; var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { + if (returnType.flags & 1 /* TypeFlags.Any */) { return; } var headMessage; var expectedReturnType; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any; expectedReturnType = voidType; break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); @@ -82157,9 +82480,9 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* SyntaxKind.Identifier */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */) | 2097152 /* SymbolFlags.Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true); - if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) { + if (rootSymbol && rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) { if (symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) { @@ -82194,15 +82517,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; } } @@ -82211,13 +82534,13 @@ var ts; var commonEntityName; for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { var typeNode = types_21[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */ || typeNode.kind === 197 /* SyntaxKind.NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -82262,15 +82585,15 @@ var ts; if (!firstDecorator) { return; } - checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 164 /* Parameter */) { - checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + checkExternalEmitHelpers(firstDecorator, 8 /* ExternalEmitHelpers.Decorate */); + if (node.kind === 164 /* SyntaxKind.Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* ExternalEmitHelpers.Param */); } if (compilerOptions.emitDecoratorMetadata) { - checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); + checkExternalEmitHelpers(firstDecorator, 16 /* ExternalEmitHelpers.Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -82279,23 +82602,23 @@ var ts; } } break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - var otherKind = node.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + var otherKind = node.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -82395,9 +82718,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; default: return undefined; @@ -82411,7 +82734,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -82427,7 +82750,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find( // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* NodeFlags.JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -82437,7 +82760,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 168 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 168 /* SyntaxKind.MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics); @@ -82455,7 +82778,7 @@ var ts; if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { reportImplicitAny(node, anyType); } - if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) { + if (functionFlags & 1 /* FunctionFlags.Generator */ && ts.nodeIsPresent(body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -82483,42 +82806,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 305 /* SourceFile */: - case 261 /* ModuleDeclaration */: - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 305 /* SyntaxKind.SourceFile */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -82529,41 +82852,41 @@ var ts; function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(declaration, 0 /* Local */, ts.createDiagnosticForNode(node, message, name)); + addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name)); } function isIdentifierThatStartsWithUnderscore(node) { - return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; + return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* CharacterCodes._ */; } function checkUnusedClassMembers(node, addDiagnostic) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - if (member.kind === 173 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && member.symbol.flags & 32768 /* SymbolFlags.GetAccessor */) { // Already would have reported an error on the getter. break; } var symbol = getSymbolOfNode(member); if (!symbol.isReferenced - && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) - && !(member.flags & 16777216 /* Ambient */)) { - addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); + && (ts.hasEffectiveModifier(member, 8 /* ModifierFlags.Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) + && !(member.flags & 16777216 /* NodeFlags.Ambient */)) { + addDiagnostic(member, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { - addDiagnostic(parameter, 0 /* Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); + if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* ModifierFlags.Private */)) { + addDiagnostic(parameter, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); } } break; - case 176 /* IndexSignature */: - case 234 /* SemicolonClassElement */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 234 /* SyntaxKind.SemicolonClassElement */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Can't be private break; default: @@ -82574,7 +82897,7 @@ var ts; function checkUnusedInferTypeParameter(node, addDiagnostic) { var typeParameter = node.typeParameter; if (isTypeParameterUnused(typeParameter)) { - addDiagnostic(node, 1 /* Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); + addDiagnostic(node, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); } } function checkUnusedTypeParameters(node, addDiagnostic) { @@ -82585,13 +82908,13 @@ var ts; return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); - for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { - var typeParameter = typeParameters_3[_i]; + for (var _i = 0, typeParameters_4 = typeParameters; _i < typeParameters_4.length; _i++) { + var typeParameter = typeParameters_4[_i]; if (!isTypeParameterUnused(typeParameter)) continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 190 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 190 /* SyntaxKind.InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -82603,17 +82926,17 @@ var ts; //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); } } else { //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); } } } function isTypeParameterUnused(typeParameter) { - return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); + return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* SymbolFlags.TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); } function addToGroup(map, key, value, getKey) { var keyString = String(getKey(key)); @@ -82650,7 +82973,7 @@ var ts; nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. - if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { + if (local.flags & 262144 /* SymbolFlags.TypeParameter */ ? !(local.flags & 3 /* SymbolFlags.Variable */ && !(local.isReferenced & 3 /* SymbolFlags.Variable */)) : local.isReferenced || local.exportSymbol) { return; } if (local.declarations) { @@ -82681,7 +83004,7 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } else { - addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + addDiagnostic(parameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } } @@ -82697,10 +83020,10 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 268 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { - addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 + addDiagnostic(importDecl, 0 /* UnusedKind.Local */, unuseds.length === 1 ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); } @@ -82713,9 +83036,9 @@ var ts; }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; - var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; + var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -82734,14 +83057,14 @@ var ts; unusedVariables.forEach(function (_a) { var declarationList = _a[0], declarations = _a[1]; if (declarationList.declarations.length === declarations.length) { - addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 + addDiagnostic(declarationList, 0 /* UnusedKind.Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { var decl = declarations_6[_i]; - addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); + addDiagnostic(decl, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); } } }); @@ -82764,24 +83087,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.idText(name); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 267 /* ImportClause */ || node.kind === 270 /* ImportSpecifier */ || node.kind === 268 /* NamespaceImport */; + return node.kind === 267 /* SyntaxKind.ImportClause */ || node.kind === 270 /* SyntaxKind.ImportSpecifier */ || node.kind === 268 /* SyntaxKind.NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 267 /* ImportClause */ ? decl : decl.kind === 268 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 267 /* SyntaxKind.ImportClause */ ? decl : decl.kind === 268 /* SyntaxKind.NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 235 /* Block */) { + if (node.kind === 235 /* SyntaxKind.Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -82798,7 +83121,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* NodeFlags.Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -82816,17 +83139,17 @@ var ts; if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - if (node.kind === 167 /* PropertyDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 169 /* MethodDeclaration */ || - node.kind === 168 /* MethodSignature */ || - node.kind === 172 /* GetAccessor */ || - node.kind === 173 /* SetAccessor */ || - node.kind === 296 /* PropertyAssignment */) { + if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */ || + node.kind === 168 /* SyntaxKind.MethodSignature */ || + node.kind === 172 /* SyntaxKind.GetAccessor */ || + node.kind === 173 /* SyntaxKind.SetAccessor */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */) { // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // ambient context - no codegen impact return false; } @@ -82846,8 +83169,8 @@ var ts; // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 4 /* NodeCheckFlags.CaptureThis */) { + var isDeclaration_1 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -82861,8 +83184,8 @@ var ts; } function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 8 /* NodeCheckFlags.CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -82883,46 +83206,46 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { + if (!name || languageVersion >= 4 /* ScriptTarget.ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* NodeFlags.HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) { - if (languageVersion <= 8 /* ES2021 */ + if (languageVersion <= 8 /* ScriptTarget.ES2021 */ && (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) { potentialWeakMapSetCollisions.push(node); } } function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); - if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { + if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */) { ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); } } function recordPotentialCollisionWithReflectInGeneratedCode(node, name) { - if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ + if (name && languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && needCollisionCheckForIdentifier(node, name, "Reflect")) { potentialReflectCollisions.push(node); } @@ -82933,7 +83256,7 @@ var ts; // ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(member) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; break; } @@ -82941,13 +83264,13 @@ var ts; } else if (ts.isFunctionExpression(node)) { // FunctionExpression names don't contribute to their containers, but do matter for their contents - if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(node) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } else { var container = ts.getEnclosingBlockScopeContainer(node); - if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (container && getNodeCheckFlags(container) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } @@ -82965,7 +83288,7 @@ var ts; recordPotentialCollisionWithReflectInGeneratedCode(node, name); if (ts.isClassLike(node)) { checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0); - if (!(node.flags & 16777216 /* Ambient */)) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */)) { checkClassNameCollisionWithObject(name); } } @@ -82997,35 +83320,35 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3 /* NodeFlags.BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 254 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { + if (symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) return ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* SymbolFlags.Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 237 /* VariableStatement */ && varDeclList.parent.parent + localDeclarationSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* NodeFlags.BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); + var container = varDeclList.parent.kind === 237 /* SyntaxKind.VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 235 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 262 /* ModuleBlock */ || - container.kind === 261 /* ModuleDeclaration */ || - container.kind === 305 /* SourceFile */); + (container.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(container.parent) || + container.kind === 262 /* SyntaxKind.ModuleBlock */ || + container.kind === 261 /* SyntaxKind.ModuleDeclaration */ || + container.kind === 305 /* SyntaxKind.SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -83056,7 +83379,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { checkExpressionCached(node.initializer); @@ -83074,16 +83397,16 @@ var ts; potentialUnusedRenamedBindingElementsInTypes.push(node); return; } - if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { - checkExternalEmitHelpers(node, 4 /* Rest */); + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ScriptTarget.ES2018 */) { + checkExternalEmitHelpers(node, 4 /* ExternalEmitHelpers.Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 162 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access var parent = node.parent.parent; - var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var parentCheckMode = node.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(parent, parentCheckMode); var name = node.propertyName || node.name; if (parentType && !ts.isBindingPattern(name)) { @@ -83093,15 +83416,15 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SyntaxKind.SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 202 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (node.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } ts.forEach(node.name.elements, checkSourceElement); } @@ -83112,7 +83435,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = ts.hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */; + var needCheckInitializer = ts.hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */; var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression)); if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -83129,7 +83452,7 @@ var ts; // check the binding pattern with empty elements if (needCheckWidenedType) { if (ts.isArrayBindingPattern(node.name)) { - checkIteratedTypeOrElementType(65 /* Destructuring */, widenedType, undefinedType, node); + checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, widenedType, undefinedType, node); } else if (strictNullChecks) { checkNonNullNonVoidType(widenedType, node); @@ -83140,7 +83463,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* SyntaxKind.BindingElement */ ? node.parent.parent : node)) { checkAliasSymbol(node); return; } @@ -83154,7 +83477,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -83170,7 +83493,7 @@ var ts; var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (!isErrorType(type) && !isErrorType(declarationType) && !isTypeIdenticalTo(type, declarationType) && - !(symbol.flags & 67108864 /* Assignment */)) { + !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { @@ -83180,10 +83503,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */) { + if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionsForDeclarationName(node, node.name); @@ -83191,7 +83514,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 167 /* PropertyDeclaration */ || nextDeclaration.kind === 166 /* PropertySignature */ + var message = nextDeclaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 166 /* SyntaxKind.PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -83201,24 +83524,24 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 164 /* Parameter */ && right.kind === 254 /* VariableDeclaration */) || - (left.kind === 254 /* VariableDeclaration */ && right.kind === 164 /* Parameter */)) { + if ((left.kind === 164 /* SyntaxKind.Parameter */ && right.kind === 254 /* SyntaxKind.VariableDeclaration */) || + (left.kind === 254 /* SyntaxKind.VariableDeclaration */ && right.kind === 164 /* SyntaxKind.Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* ModifierFlags.Private */ | + 16 /* ModifierFlags.Protected */ | + 256 /* ModifierFlags.Async */ | + 128 /* ModifierFlags.Abstract */ | + 64 /* ModifierFlags.Readonly */ | + 32 /* ModifierFlags.Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -83244,7 +83567,7 @@ var ts; checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 236 /* EmptyStatement */) { + if (node.thenStatement.kind === 236 /* SyntaxKind.EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -83253,27 +83576,27 @@ var ts; if (!strictNullChecks) return; helper(condExpr, body); - while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) { + while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { condExpr = condExpr.left; helper(condExpr, body); } function helper(condExpr, body) { var location = ts.isBinaryExpression(condExpr) && - (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */) + (condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || condExpr.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) ? condExpr.right : condExpr; if (ts.isModuleExportsAccessExpression(location)) return; var type = checkTruthinessExpression(location); var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression); - if (!(getTypeFacts(type) & 4194304 /* Truthy */) || isPropertyExpressionCast) + if (!(getTypeFacts(type) & 4194304 /* TypeFacts.Truthy */) || isPropertyExpressionCast) return; // While it technically should be invalid for any known-truthy value // to be tested, we de-scope to functions and Promises unreferenced in // the block as a heuristic to identify the most common bugs. There // are too many false positives for values sourced from type // definitions without strictNullChecks otherwise. - var callSignatures = getSignaturesOfType(type, 0 /* Call */); + var callSignatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var isPromise = !!getAwaitedTypeOfPromise(type); if (callSignatures.length === 0 && !isPromise) { return; @@ -83313,7 +83636,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { + testedExpression.kind === 108 /* SyntaxKind.ThisKeyword */ && childExpression.kind === 108 /* SyntaxKind.ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -83337,7 +83660,7 @@ var ts; }); } function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { - while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { var symbol = getSymbolAtLocation(child); @@ -83367,7 +83690,7 @@ var ts; checkSourceElement(node.statement); } function checkTruthinessOfType(type, node) { - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -83378,12 +83701,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -83408,29 +83731,29 @@ var ts; } else { var functionFlags = ts.getFunctionFlags(container); - if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { + if ((functionFlags & (4 /* FunctionFlags.Invalid */ | 2 /* FunctionFlags.Async */)) === 2 /* FunctionFlags.Async */ && languageVersion < 99 /* ScriptTarget.ESNext */) { // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper - checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + checkExternalEmitHelpers(node, 16384 /* ExternalEmitHelpers.ForAwaitOfIncludes */); } } } - else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) { + else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ScriptTarget.ES2015 */) { // for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled - checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.ForOfIncludes */); } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -83462,7 +83785,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -83476,7 +83799,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -83489,7 +83812,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -83506,7 +83829,7 @@ var ts; } } function checkRightHandSideOfForOf(statement) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) { @@ -83521,14 +83844,14 @@ var ts; * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) { - var allowAsyncIterables = (use & 2 /* AllowsAsyncIterablesFlag */) !== 0; + var allowAsyncIterables = (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) !== 0; if (inputType === neverType) { reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } - var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var uplevelIteration = languageVersion >= 2 /* ScriptTarget.ES2015 */; var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; - var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */); + var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* IterationUse.PossiblyOutOfBounds */); // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. @@ -83537,10 +83860,10 @@ var ts; var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined); if (checkAssignability) { if (iterationTypes) { - var diagnostic = use & 8 /* ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : - use & 32 /* SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : - use & 64 /* DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : - use & 16 /* YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : + var diagnostic = use & 8 /* IterationUse.ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : + use & 32 /* IterationUse.SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : + use & 64 /* IterationUse.DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : + use & 16 /* IterationUse.YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : undefined; if (diagnostic) { checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic); @@ -83557,22 +83880,22 @@ var ts; // If strings are permitted, remove any string-like constituents from the array type. // This allows us to find other non-string element types from an array unioned with // a string. - if (use & 4 /* AllowsStringInputFlag */) { - if (arrayType.flags & 1048576 /* Union */) { + if (use & 4 /* IterationUse.AllowsStringInputFlag */) { + if (arrayType.flags & 1048576 /* TypeFlags.Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* TypeFlags.StringLike */); }); if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, 2 /* Subtype */); + arrayType = getUnionType(filteredTypes, 2 /* UnionReduction.Subtype */); } } - else if (arrayType.flags & 402653316 /* StringLike */) { + else if (arrayType.flags & 402653316 /* TypeFlags.StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { if (errorNode) { error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); reportedError = true; @@ -83580,7 +83903,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 131072 /* Never */) { + if (arrayType.flags & 131072 /* TypeFlags.Never */) { return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType; } } @@ -83592,7 +83915,7 @@ var ts; // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var allowsStrings = !!(use & 4 /* IterationUse.AllowsStringInputFlag */) && !hasStringConstituent; var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } @@ -83601,12 +83924,12 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, numberType); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { + if (arrayElementType.flags & 402653316 /* TypeFlags.StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } - return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); + return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* UnionReduction.Subtype */); } - return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + return (use & 128 /* IterationUse.PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { var _a; if (downlevelIteration) { @@ -83614,7 +83937,7 @@ var ts; ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] : [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]; } - var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); + var yieldType = getIterationTypeOfIterable(use, 0 /* IterationTypeKind.Yield */, inputType, /*errorNode*/ undefined); if (yieldType) { return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } @@ -83663,9 +83986,9 @@ var ts; // more frequently created (i.e. `Iterator`). Iteration types // are also cached on the type they are requested for, so we shouldn't need to maintain // the cache for less-frequently used types. - if (yieldType.flags & 67359327 /* Intrinsic */ && - returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && - nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) { + if (yieldType.flags & 67359327 /* TypeFlags.Intrinsic */ && + returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */) && + nextType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { var id = getTypeListId([yieldType, returnType, nextType]); var iterationTypes = iterationTypesCache.get(id); if (!iterationTypes) { @@ -83732,37 +84055,56 @@ var ts; * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method. */ function getIterationTypesOfIterable(type, use, errorNode) { + var _a, _b; if (isTypeAny(type)) { return anyIterationTypes; } - if (!(type.flags & 1048576 /* Union */)) { - var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } return undefined; } + else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) { + for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) { + var diag = _c[_i]; + diagnostics.add(diag); + } + } return iterationTypes_1; } - var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; + var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; var cachedTypes = getCachedIterationTypes(type, cacheKey); if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; var allIterationTypes; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituent = _a[_i]; - var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); + for (var _d = 0, _e = type.types; _d < _e.length; _d++) { + var constituent = _e[_d]; + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; } - else { - allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); + else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) { + for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) { + var diag = _g[_f]; + diagnostics.add(diag); + } } + allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); } var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes; setCachedIterationTypes(type, cacheKey, iterationTypes); @@ -83790,47 +84132,62 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterable` instead. */ - function getIterationTypesOfIterableWorker(type, use, errorNode) { + function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) { if (isTypeAny(type)) { return anyIterationTypes; } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + // If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached. + // In addition, we should not cache any new results for this call. + var noCache = false; + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 /* ForOfFlag */ ? - getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : - iterationTypes; + if (iterationTypes === noIterationTypes && errorNode) { + // ignore the cached value + noCache = true; + } + else { + return use & 8 /* IterationUse.ForOfFlag */ ? + getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : + iterationTypes; + } } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { - // for a sync iterable in an async context, only use the cached types if they are valid. - if (iterationTypes !== noIterationTypes) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); - } + if (iterationTypes === noIterationTypes && errorNode) { + // ignore the cached value + noCache = true; } else { - return iterationTypes; + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + // for a sync iterable in an async context, only use the cached types if they are valid. + if (iterationTypes !== noIterationTypes) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); + } + } + else { + return iterationTypes; + } } } } - if (use & 2 /* AllowsAsyncIterablesFlag */) { - var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { - var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { + var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes - ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) - : noIterationTypes); + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); } else { return iterationTypes; @@ -83851,7 +84208,7 @@ var ts; } function getIterationTypesOfGlobalIterableType(globalType, resolver) { var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) || - getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined); + getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false); return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes; } /** @@ -83893,7 +84250,7 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like @@ -83905,26 +84262,26 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterable` instead. */ - function getIterationTypesOfIterableSlow(type, resolver, errorNode) { + function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); - var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; + var methodType = method && !(method.flags & 16777216 /* SymbolFlags.Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); + return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } - var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : undefined; if (!ts.some(signatures)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); + return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature)); - var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes; - return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); + var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes; + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); } function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) { var message = allowAsyncIterables ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator; - errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); + return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); } /** * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type. @@ -83932,13 +84289,29 @@ var ts; * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` * record is returned. Otherwise, `undefined` is returned. */ - function getIterationTypesOfIterator(type, resolver, errorNode) { + function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) { + return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false); + } + /** + * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type. + * + * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` + * record is returned. Otherwise, `undefined` is returned. + * + * NOTE: You probably don't want to call this directly and should be calling + * `getIterationTypesOfIterator` instead. + */ + function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) { if (isTypeAny(type)) { return anyIterationTypes; } var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) || - getIterationTypesOfIteratorFast(type, resolver) || - getIterationTypesOfIteratorSlow(type, resolver, errorNode); + getIterationTypesOfIteratorFast(type, resolver); + if (iterationTypes === noIterationTypes && errorNode) { + iterationTypes = undefined; + noCache = true; + } + iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache)); return iterationTypes === noIterationTypes ? undefined : iterationTypes; } /** @@ -83976,7 +84349,7 @@ var ts; // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || - getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined); + getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false); var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType; return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType)); } @@ -83992,13 +84365,13 @@ var ts; // > If the end was not reached `done` is `false` and a value is available. // > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`. var doneType = getTypeOfPropertyOfType(type, "done") || falseType; - return isTypeAssignableTo(kind === 0 /* Yield */ ? falseType : trueType, doneType); + return isTypeAssignableTo(kind === 0 /* IterationTypeKind.Yield */ ? falseType : trueType, doneType); } function isYieldIteratorResult(type) { - return isIteratorResult(type, 0 /* Yield */); + return isIteratorResult(type, 0 /* IterationTypeKind.Yield */); } function isReturnIteratorResult(type) { - return isIteratorResult(type, 1 /* Return */); + return isIteratorResult(type, 1 /* IterationTypeKind.Return */); } /** * Gets the *yield* and *return* types of an `IteratorResult`-like type. @@ -84046,30 +84419,36 @@ var ts; * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` * record is returned. Otherwise, we return `undefined`. */ - function getIterationTypesOfMethod(type, resolver, methodName, errorNode) { - var _a, _b, _c, _d; + function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) { + var _a, _b, _c, _d, _e, _f; var method = getPropertyOfType(type, methodName); // Ignore 'return' or 'throw' if they are missing. if (!method && methodName !== "next") { return undefined; } - var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* Optional */)) - ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */) + var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* SymbolFlags.Optional */)) + ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* TypeFacts.NEUndefinedOrNull */) : undefined; if (isTypeAny(methodType)) { // `return()` and `throw()` don't provide a *next* type. return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext; } // Both async and non-async iterators *must* have a `next` method. - var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : ts.emptyArray; + var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : ts.emptyArray; if (methodSignatures.length === 0) { if (errorNode) { var diagnostic = methodName === "next" ? resolver.mustHaveANextMethodDiagnostic : resolver.mustBeAMethodDiagnostic; - error(errorNode, diagnostic, methodName); + if (errorOutputContainer) { + (_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName)); + } + else { + error(errorNode, diagnostic, methodName); + } } - return methodName === "next" ? anyIterationTypes : undefined; + return methodName === "next" ? noIterationTypes : undefined; } // If the method signature comes exclusively from the global iterator or generator type, // create iteration types from its type arguments like `getIterationTypesOfIteratorFast` @@ -84081,8 +84460,8 @@ var ts; if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) { var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false); var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false); - var isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get(methodName)) === methodType.symbol; - var isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) === null || _c === void 0 ? void 0 : _c.members) === null || _d === void 0 ? void 0 : _d.get(methodName)) === methodType.symbol; + var isGeneratorMethod = ((_c = (_b = globalGeneratorType.symbol) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.get(methodName)) === methodType.symbol; + var isIteratorMethod = !isGeneratorMethod && ((_e = (_d = globalIteratorType.symbol) === null || _d === void 0 ? void 0 : _d.members) === null || _e === void 0 ? void 0 : _e.get(methodName)) === methodType.symbol; if (isGeneratorMethod || isIteratorMethod) { var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType; var mapper = methodType.mapper; @@ -84122,7 +84501,13 @@ var ts; var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType); if (iterationTypes === noIterationTypes) { if (errorNode) { - error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + if (errorOutputContainer) { + (_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName)); + } + else { + error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + } } yieldType = anyType; returnTypes = ts.append(returnTypes, anyType); @@ -84143,13 +84528,13 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterator` instead. */ - function getIterationTypesOfIteratorSlow(type, resolver, errorNode) { + function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var iterationTypes = combineIterationTypes([ - getIterationTypesOfMethod(type, resolver, "next", errorNode), - getIterationTypesOfMethod(type, resolver, "return", errorNode), - getIterationTypesOfMethod(type, resolver, "throw", errorNode), + getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer), ]); - return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); } /** * Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like, @@ -84167,10 +84552,10 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + var use = isAsyncGenerator ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) || - getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined); + getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined); } function checkBreakOrContinueStatement(node) { // Grammar checking @@ -84179,15 +84564,20 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { - var isGenerator = !!(functionFlags & 1 /* Generator */); - var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : - isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : - returnType; + var isGenerator = !!(functionFlags & 1 /* FunctionFlags.Generator */); + var isAsync = !!(functionFlags & 2 /* FunctionFlags.Async */); + if (isGenerator) { + var returnIterationType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, isAsync); + if (!returnIterationType) { + return errorType; + } + return isAsync ? getAwaitedTypeNoAlias(unwrapAwaitedType(returnIterationType)) : returnIterationType; + } + return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* TypeFlags.Void */ | 3 /* TypeFlags.AnyOrUnknown */); } function checkReturnStatement(node) { var _a; @@ -84207,21 +84597,21 @@ var ts; var signature = getSignatureFromDeclaration(container); var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(container); - if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* TypeFlags.Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (container.kind === 173 /* SetAccessor */) { + if (container.kind === 173 /* SyntaxKind.SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (getReturnTypeFromAnnotation(container)) { var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; - var unwrappedExprType = functionFlags & 2 /* Async */ + var unwrappedExprType = functionFlags & 2 /* FunctionFlags.Async */ ? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; if (unwrappedReturnType) { @@ -84232,7 +84622,7 @@ var ts; } } } - else if (container.kind !== 171 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { + else if (container.kind !== 171 /* SyntaxKind.Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -84240,7 +84630,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 32768 /* AwaitContext */) { + if (node.flags & 32768 /* NodeFlags.AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -84261,7 +84651,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 290 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -84270,7 +84660,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause)); } ts.forEach(clause.statements, checkSourceElement); @@ -84307,7 +84697,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 250 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 250 /* SyntaxKind.LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -84339,8 +84729,8 @@ var ts; var declaration = catchClause.variableDeclaration; var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); if (typeNode) { - var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */); - if (type && !(type.flags & 3 /* AnyOrUnknown */)) { + var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */); + if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) { grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } @@ -84352,7 +84742,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -84372,8 +84762,8 @@ var ts; } for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) { - checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); + if (!(isStaticIndex && prop.flags & 4194304 /* SymbolFlags.Prototype */)) { + checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); } } var typeDeclaration = symbol.valueDeclaration; @@ -84402,10 +84792,11 @@ var ts; return; } var indexInfos = getApplicableIndexInfos(type, propNameType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ || - name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; - var _loop_29 = function (info) { + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; + var propDeclaration = declaration && declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || + name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined; + var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var _loop_30 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and @@ -84413,20 +84804,24 @@ var ts; var errorNode = localPropDeclaration || localIndexDeclaration || (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined); if (errorNode && !isTypeAssignableTo(propType, info.type)) { - error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + if (propDeclaration && errorNode !== propDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop))); + } + diagnostics.add(diagnostic); } }; for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) { var info = indexInfos_9[_i]; - _loop_29(info); + _loop_30(info); } } function checkIndexConstraintForIndexSignature(type, checkInfo) { var declaration = checkInfo.declaration; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; - var _loop_30 = function (info) { + var _loop_31 = function (info) { if (info === checkInfo) return "continue"; var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; @@ -84441,7 +84836,7 @@ var ts; }; for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) { var info = indexInfos_10[_i]; - _loop_30(info); + _loop_31(info); } } function checkTypeNameIsReserved(name, message) { @@ -84465,7 +84860,7 @@ var ts; * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name) { - if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" + if (languageVersion >= 1 /* ScriptTarget.ES5 */ && name.escapedText === "Object" && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) { error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } @@ -84544,9 +84939,9 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 178 /* TypeReference */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */) { var type = getTypeFromTypeReference(node); - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { if (type.symbol === getSymbolOfNode(typeParameters[i])) { error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters); @@ -84634,7 +85029,7 @@ var ts; if (firstDecorator && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { grammarErrorOnNode(firstDecorator, ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) { + if (!node.name && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -84655,15 +85050,15 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */); } // check both @extends and extends if both are specified. var extendsNode = ts.getClassExtendsHeritageElement(node); @@ -84695,18 +85090,18 @@ var ts; // Report static side error only when instance type is assignable checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); } - if (baseConstructorType.flags & 8650752 /* TypeVariable */) { + if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) { if (!isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { - var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); + if (constructSignatures.some(function (signature) { return signature.flags & 4 /* SignatureFlags.Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* SymbolFlags.Class */) && !(baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); @@ -84741,7 +85136,7 @@ var ts; var t = getReducedType(getTypeFromTypeNode(typeRefNode)); if (!isErrorType(t)) { if (isValidBaseType(t)) { - var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? + var genericDiag = t.symbol && t.symbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : ts.Diagnostics.Class_0_incorrectly_implements_interface_1; var baseWithThis = getTypeWithThisArgument(t, type.thisType); @@ -84761,7 +85156,7 @@ var ts; var baseTypes = baseTypeNode && getBaseTypes(type); var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined; var baseStaticType = getBaseConstructorTypeOfClass(type); - var _loop_31 = function (member) { + var _loop_32 = function (member) { if (ts.hasAmbientModifier(member)) { return "continue"; } @@ -84778,7 +85173,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_31(member); + _loop_32(member); } } /** @@ -84791,7 +85186,7 @@ var ts; && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); if (!declaredProp) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined); } @@ -84805,7 +85200,7 @@ var ts; */ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) { var isJs = ts.isInJSFile(node); - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { var memberEscapedName = ts.escapeLeadingUnderscores(memberName); var thisType = memberIsStatic ? staticType : typeWithThis; @@ -84824,12 +85219,12 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier); if (memberHasOverrideModifier) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } if (!baseHasAbstract) { if (errorNode) { @@ -84842,13 +85237,13 @@ var ts; ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; error(errorNode, diag, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } else if (memberHasAbstractModifier && baseHasAbstract) { if (errorNode) { error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } } } @@ -84859,14 +85254,14 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_32 = function (member) { + var _loop_33 = function (member) { if (ts.isStatic(member)) { return "continue"; } @@ -84885,7 +85280,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_32(member); + _loop_33(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -84893,10 +85288,10 @@ var ts; } } function checkBaseTypeAccessibility(type, node) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) { var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -84912,7 +85307,7 @@ var ts; */ function getMemberOverrideModifierStatus(node, member) { if (!member.name) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -84924,7 +85319,7 @@ var ts; var baseStaticType = getBaseConstructorTypeOfClass(type); var memberHasOverrideModifier = member.parent ? ts.hasOverrideModifier(member) - : ts.hasSyntacticModifier(member, 16384 /* Override */); + : ts.hasSyntacticModifier(member, 16384 /* ModifierFlags.Override */); var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member), /* memberIsParameterProperty */ false, memberName); @@ -84932,11 +85327,11 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return ts.getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; + return ts.getCheckFlags(s) & 1 /* CheckFlags.Instantiated */ ? s.target : s; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 257 /* ClassDeclaration */ || d.kind === 258 /* InterfaceDeclaration */; + return d.kind === 257 /* SyntaxKind.ClassDeclaration */ || d.kind === 258 /* SyntaxKind.InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -84956,9 +85351,9 @@ var ts; var _a, _b, _c, _d; // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - var _loop_33 = function (baseProperty) { + var _loop_34 = function (baseProperty) { var base = getTargetSymbol(baseProperty); - if (base.flags & 4194304 /* Prototype */) { + if (base.flags & 4194304 /* SymbolFlags.Prototype */) { return "continue"; } var baseSymbol = getPropertyOfObjectType(type, base.escapedName); @@ -84977,7 +85372,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* ModifierFlags.Abstract */))) { // Searches other base types for a declaration that would satisfy the inherited abstract member. // (The class may have more than one base type via declaration merging with an interface with the // same name.) @@ -84991,7 +85386,7 @@ var ts; return "continue-basePropertyCheck"; } } - if (derivedClassDecl.kind === 226 /* ClassExpression */) { + if (derivedClassDecl.kind === 226 /* SyntaxKind.ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -85002,23 +85397,23 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 8 /* ModifierFlags.Private */ || derivedDeclarationFlags & 8 /* ModifierFlags.Private */) { return "continue"; } var errorMessage = void 0; - var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; - var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + var basePropertyFlags = base.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor - if ((ts.getCheckFlags(base) & 6 /* Synthetic */ + if ((ts.getCheckFlags(base) & 6 /* CheckFlags.Synthetic */ ? (_a = base.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); }) : (_b = base.declarations) === null || _b === void 0 ? void 0 : _b.every(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); })) - || ts.getCheckFlags(base) & 262144 /* Mapped */ + || ts.getCheckFlags(base) & 262144 /* CheckFlags.Mapped */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { return "continue"; } - var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */; - var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */; + var overriddenInstanceProperty = basePropertyFlags !== 4 /* SymbolFlags.Property */ && derivedPropertyFlags === 4 /* SymbolFlags.Property */; + var overriddenInstanceAccessor = basePropertyFlags === 4 /* SymbolFlags.Property */ && derivedPropertyFlags !== 4 /* SymbolFlags.Property */; if (overriddenInstanceProperty || overriddenInstanceAccessor) { var errorMessage_1 = overriddenInstanceProperty ? ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property : @@ -85026,12 +85421,12 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !d.initializer; }); if (uninitialized - && !(derived.flags & 33554432 /* Transient */) - && !(baseDeclarationFlags & 128 /* Abstract */) - && !(derivedDeclarationFlags & 128 /* Abstract */) - && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) { + && !(derived.flags & 33554432 /* SymbolFlags.Transient */) + && !(baseDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !(derivedDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* NodeFlags.Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -85047,15 +85442,15 @@ var ts; return "continue"; } else if (isPrototypeProperty(base)) { - if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* SymbolFlags.Property */) { return "continue"; } else { - ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + ts.Debug.assert(!!(derived.flags & 98304 /* SymbolFlags.Accessor */)); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } - else if (base.flags & 98304 /* Accessor */) { + else if (base.flags & 98304 /* SymbolFlags.Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } else { @@ -85066,14 +85461,14 @@ var ts; }; basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; - var state_10 = _loop_33(baseProperty); + var state_10 = _loop_34(baseProperty); switch (state_10) { case "continue-basePropertyCheck": continue basePropertyCheck; } } } function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) { - return baseDeclarationFlags & 128 /* Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer) + return baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer) || ts.isInterfaceDeclaration(declaration.parent); } function getNonInheritedProperties(type, baseTypes, properties) { @@ -85132,20 +85527,20 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) { continue; } if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || containsUndefinedType(type))) { + if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || containsUndefinedType(type))) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -85155,7 +85550,7 @@ var ts; } } function isPropertyWithoutInitializer(node) { - return node.kind === 167 /* PropertyDeclaration */ && + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; @@ -85198,7 +85593,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -85231,7 +85626,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 138 /* IntrinsicKeyword */) { + if (node.type.kind === 138 /* SyntaxKind.IntrinsicKeyword */) { if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); } @@ -85243,8 +85638,8 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { - nodeLinks.flags |= 16384 /* EnumValuesComputed */; + if (!(nodeLinks.flags & 16384 /* NodeCheckFlags.EnumValuesComputed */)) { + nodeLinks.flags |= 16384 /* NodeCheckFlags.EnumValuesComputed */; var autoValue = 0; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -85269,7 +85664,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -85286,7 +85681,7 @@ var ts; var enumKind = getEnumKind(getSymbolOfNode(member.parent)); var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; - var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); + var value = enumKind === 1 /* EnumKind.Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { if (isConstEnum && typeof value === "number" && !isFinite(value)) { error(initializer, isNaN(value) ? @@ -85294,20 +85689,20 @@ var ts; ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); } } - else if (enumKind === 1 /* Literal */) { + else if (enumKind === 1 /* EnumKind.Literal */) { error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members); return 0; } else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 16777216 /* Ambient */) { + else if (member.parent.flags & 16777216 /* NodeFlags.Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { // Only here do we need to check that the initializer is assignable to the enum type. var source = checkExpression(initializer); - if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) { + if (!isTypeAssignableToKind(source, 296 /* TypeFlags.NumberLike */)) { error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); } else { @@ -85317,60 +85712,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 39 /* PlusToken */: return value_2; - case 40 /* MinusToken */: return -value_2; - case 54 /* TildeToken */: return ~value_2; + case 39 /* SyntaxKind.PlusToken */: return value_2; + case 40 /* SyntaxKind.MinusToken */: return -value_2; + case 54 /* SyntaxKind.TildeToken */: return ~value_2; } } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 51 /* BarToken */: return left | right; - case 50 /* AmpersandToken */: return left & right; - case 48 /* GreaterThanGreaterThanToken */: return left >> right; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 47 /* LessThanLessThanToken */: return left << right; - case 52 /* CaretToken */: return left ^ right; - case 41 /* AsteriskToken */: return left * right; - case 43 /* SlashToken */: return left / right; - case 39 /* PlusToken */: return left + right; - case 40 /* MinusToken */: return left - right; - case 44 /* PercentToken */: return left % right; - case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); - } - } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { + case 51 /* SyntaxKind.BarToken */: return left | right; + case 50 /* SyntaxKind.AmpersandToken */: return left & right; + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return left >> right; + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* SyntaxKind.LessThanLessThanToken */: return left << right; + case 52 /* SyntaxKind.CaretToken */: return left ^ right; + case 41 /* SyntaxKind.AsteriskToken */: return left * right; + case 43 /* SyntaxKind.SlashToken */: return left / right; + case 39 /* SyntaxKind.PlusToken */: return left + right; + case 40 /* SyntaxKind.MinusToken */: return left - right; + case 44 /* SyntaxKind.PercentToken */: return left % right; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { return left + right; } break; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return expr.text; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return evaluate(expr.expression); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var identifier = expr; if (ts.isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (isConstantMemberAccess(expr)) { var type = getTypeOfExpression(expr.expression); - if (type.symbol && type.symbol.flags & 384 /* Enum */) { + if (type.symbol && type.symbol.flags & 384 /* SymbolFlags.Enum */) { var name = void 0; - if (expr.kind === 206 /* PropertyAccessExpression */) { + if (expr.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { name = expr.name.escapedText; } else { @@ -85406,9 +85801,9 @@ var ts; if (type === errorType) { return false; } - return node.kind === 79 /* Identifier */ || - node.kind === 206 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 207 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 207 /* SyntaxKind.ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -85442,7 +85837,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 260 /* EnumDeclaration */) { + if (declaration.kind !== 260 /* SyntaxKind.EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -85471,9 +85866,9 @@ var ts; if (declarations) { for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { var declaration = declarations_9[_i]; - if ((declaration.kind === 257 /* ClassDeclaration */ || - (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 16777216 /* Ambient */)) { + if ((declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || + (declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { return declaration; } } @@ -85504,7 +85899,7 @@ var ts; function checkModuleDeclarationDiagnostics() { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 16777216 /* Ambient */; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -85517,7 +85912,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* SyntaxKind.StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -85527,7 +85922,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !inAmbientContext && symbol.declarations && symbol.declarations.length > 1 @@ -85543,10 +85938,10 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* SyntaxKind.ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* NodeCheckFlags.LexicalModuleMergesWithClass */; } } if (isAmbientExternalModule) { @@ -85556,7 +85951,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Transient */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* SymbolFlags.Transient */); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -85588,23 +85983,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -85615,12 +86010,12 @@ var ts; break; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 256 /* FunctionDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -85630,7 +86025,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Transient */); + var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -85641,20 +86036,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } @@ -85668,9 +86063,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 272 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -85713,12 +86108,12 @@ var ts; // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). symbol = getMergedSymbol(symbol.exportSymbol || symbol); // A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within - if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) { + if (ts.isInJSFile(node) && !(target.flags & 111551 /* SymbolFlags.Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) { var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name : ts.isNamedDeclaration(node) ? node.name : node; - ts.Debug.assert(node.kind !== 274 /* NamespaceExport */); - if (node.kind === 275 /* ExportSpecifier */) { + ts.Debug.assert(node.kind !== 274 /* SyntaxKind.NamespaceExport */); + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */) { var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files); var alreadyExportedSymbol = (_b = (_a = ts.getSourceFileOfNode(node).symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.get((node.propertyName || node.name).escapedText); if (alreadyExportedSymbol === target) { @@ -85729,47 +86124,47 @@ var ts; } } else { - ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */); + ts.Debug.assert(node.kind !== 254 /* SyntaxKind.VariableDeclaration */); var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)); var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "..."; var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName); - error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"" + moduleSpecifier + "\")." + importedIdentifier); + error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"".concat(moduleSpecifier, "\").").concat(importedIdentifier)); } return; } - var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | - (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | - (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) | + (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) | + (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 275 /* ExportSpecifier */ ? + var message = node.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } if (compilerOptions.isolatedModules && !ts.isTypeOnlyImportOrExportDeclaration(node) - && !(node.flags & 16777216 /* Ambient */)) { + && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol); - var isType = !(target.flags & 111551 /* Value */); + var isType = !(target.flags & 111551 /* SymbolFlags.Value */); if (isType || typeOnlyAlias) { switch (node.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: { + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { if (compilerOptions.preserveValueImports) { ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name"); var message = isType ? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled; - var name = ts.idText(node.kind === 270 /* ImportSpecifier */ ? node.propertyName || node.name : node.name); + var name = ts.idText(node.kind === 270 /* SyntaxKind.ImportSpecifier */ ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); } - if (isType && node.kind === 265 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* ModifierFlags.Export */)) { error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided); } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // Don't allow re-exporting an export that will be elided when `--isolatedModules` is set. // The exception is that `import type { A } from './a'; export { A }` is allowed // because single-file analysis can determine that the export should be dropped. @@ -85794,15 +86189,15 @@ var ts; } } function isDeprecatedAliasedSymbol(symbol) { - return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } function checkDeprecatedAliasedSymbol(symbol, location) { - if (!(symbol.flags & 2097152 /* Alias */)) + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) return symbol; var targetSymbol = resolveAlias(symbol); if (targetSymbol === unknownSymbol) return targetSymbol; - while (symbol.flags & 2097152 /* Alias */) { + while (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = getImmediateAliasedSymbol(symbol); if (target) { if (target === targetSymbol) @@ -85828,11 +86223,11 @@ var ts; function checkImportBinding(node) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 270 /* ImportSpecifier */ && + if (node.kind === 270 /* SyntaxKind.ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && ts.getESModuleInterop(compilerOptions) && moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } function checkAssertClause(declaration) { @@ -85878,11 +86273,11 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { @@ -85904,20 +86299,20 @@ var ts; checkGrammarDecoratorsAndModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 277 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = ts.getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 788968 /* Type */) { + if (target.flags & 788968 /* SymbolFlags.Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -85926,7 +86321,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -85941,8 +86336,8 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } - if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { - checkExternalEmitHelpers(node, 4194304 /* CreateBinding */); + if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) { + checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */); } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -85950,10 +86345,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 16777216 /* Ambient */; - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && + !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */; + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -85973,12 +86368,12 @@ var ts; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop if (ts.getESModuleInterop(compilerOptions)) { - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { // export * from "foo" - checkExternalEmitHelpers(node, 32768 /* ExportStar */); + checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */); } } } @@ -85988,7 +86383,7 @@ var ts; function checkGrammarExportDeclaration(node) { var _a; if (node.isTypeOnly) { - if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* NamedExports */) { + if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* SyntaxKind.NamedExports */) { return checkGrammarNamedImportsOrExports(node.exportClause); } else { @@ -85998,7 +86393,7 @@ var ts; return false; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 305 /* SourceFile */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 261 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 305 /* SyntaxKind.SourceFile */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -86046,15 +86441,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { - markExportAsReferenced(node); - var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); - if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) { + markExportAsReferenced(node); + } + var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { checkExpressionCached(node.propertyName || node.name); } } @@ -86064,7 +86461,7 @@ var ts; moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.idText(node.propertyName || node.name) === "default") { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } } @@ -86076,8 +86473,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -86094,14 +86491,14 @@ var ts; if (typeAnnotationNode) { checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression); } - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { var id = node.expression; - var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + var sym = resolveEntityName(id, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { markAliasReferenced(sym, id); // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) - var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // However if it is a value, we need to check it's being used correctly checkExpressionCached(node.expression); } @@ -86117,10 +86514,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 16777216 /* NodeFlags.Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -86155,11 +86552,11 @@ var ts; } // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (flags & (1920 /* Namespace */ | 384 /* Enum */)) { + if (flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) { return; } var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration))); - if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + if (flags & 524288 /* SymbolFlags.TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) return; @@ -86209,181 +86606,181 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 237 /* FirstStatement */ && kind <= 253 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 237 /* SyntaxKind.FirstStatement */ && kind <= 253 /* SyntaxKind.LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return checkTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return checkParameter(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return checkPropertyDeclaration(node); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checkPropertySignature(node); - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return checkSignatureDeclaration(node); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return checkMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return checkClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return checkConstructorDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return checkAccessorDeclaration(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return checkTypeReferenceNode(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return checkTypePredicate(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return checkTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return checkTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return checkArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return checkTupleType(node); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return checkUnionOrIntersectionType(node); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 186 /* RestType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: return checkSourceElement(node.type); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return checkThisType(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return checkTypeOperator(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return checkConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return checkInferType(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return checkTemplateLiteralType(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return checkImportType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return checkNamedTupleMember(node); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return checkJSDocTypeTag(node); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return checkJSDocLinkLikeTag(node); - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return checkJSDocParameterTag(node); - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 322 /* JSDocTypeLiteral */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return checkSourceElement(node.type); - case 333 /* JSDocPublicTag */: - case 335 /* JSDocProtectedTag */: - case 334 /* JSDocPrivateTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: return checkJSDocAccessibilityModifiers(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return checkIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return checkMappedType(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return checkFunctionDeclaration(node); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return checkBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return checkVariableStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return checkExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return checkIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return checkDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return checkWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return checkForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return checkForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkForOfStatement(node); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return checkBreakOrContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return checkReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return checkSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return checkThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return checkTryStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checkVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return checkBindingElement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return checkClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return checkEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return checkModuleDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return checkImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return checkExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return checkExportAssignment(node); - case 236 /* EmptyStatement */: - case 253 /* DebuggerStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -86473,7 +86870,7 @@ var ts; function checkNodeDeferred(node) { var enclosingFile = ts.getSourceFileOfNode(node); var links = getNodeLinks(enclosingFile); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { links.deferredNodes || (links.deferredNodes = new ts.Set()); links.deferredNodes.add(node); } @@ -86485,41 +86882,41 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: - case 280 /* JsxOpeningElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: checkAccessorDeclaration(node); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: checkClassExpressionDeferred(node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: checkTypeParameterDeferred(node); break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: checkJsxElementDeferred(node); break; } @@ -86527,7 +86924,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); @@ -86539,9 +86936,9 @@ var ts; return false; } switch (kind) { - case 0 /* Local */: + case 0 /* UnusedKind.Local */: return !!compilerOptions.noUnusedLocals; - case 1 /* Parameter */: + case 1 /* UnusedKind.Parameter */: return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); @@ -86553,7 +86950,7 @@ var ts; // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node) { var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } @@ -86574,7 +86971,7 @@ var ts; // This relies on the results of other lazy diagnostics, so must be computed after them if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { diagnostics.add(diag); } }); @@ -86583,7 +86980,7 @@ var ts; checkPotentialUncheckedRenamedBindingElementsInTypes(); } }); - if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && + if (compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ && !node.isDeclarationFile && ts.isExternalModule(node)) { checkImportsForTypeOnlyConversion(node); @@ -86607,7 +87004,7 @@ var ts; ts.forEach(potentialReflectCollisions, checkReflectCollision); ts.clear(potentialReflectCollisions); } - links.flags |= 1 /* TypeChecked */; + links.flags |= 1 /* NodeCheckFlags.TypeChecked */; } } function getDiagnostics(sourceFile, ct) { @@ -86677,14 +87074,14 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 33554432 /* InWithStatement */) { + if (location.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } var symbols = ts.createSymbolTable(); var isStaticSymbol = false; populateSymbols(); - symbols.delete("this" /* This */); // Not a symbol, a keyword + symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -86692,17 +87089,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 261 /* ModuleDeclaration */: - copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 261 /* SyntaxKind.ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */); break; - case 260 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + case 260 /* SyntaxKind.EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -86710,17 +87107,17 @@ var ts; // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. // falls through - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStaticSymbol) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */); } break; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -86764,7 +87161,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* SyntaxKind.NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -86772,25 +87169,25 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 79 /* Identifier */ && + return name.kind === 79 /* SyntaxKind.Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 163 /* TypeParameter */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 163 /* SyntaxKind.TypeParameter */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return true; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.isTypeOnly; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -86798,16 +87195,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 178 /* TypeReference */; + return node.parent.kind === 178 /* SyntaxKind.TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 206 /* PropertyAccessExpression */) { + while (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 228 /* ExpressionWithTypeArguments */; + return node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -86835,13 +87232,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 161 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 161 /* SyntaxKind.QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 265 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 271 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -86852,12 +87249,12 @@ var ts; function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { - case 1 /* ExportsProperty */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return getSymbolOfNode(entityName.parent); - case 4 /* ThisProperty */: - case 2 /* ModuleExports */: - case 5 /* Property */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: + case 5 /* AssignmentDeclarationKind.Property */: return getSymbolOfNode(entityName.parent.parent); } } @@ -86867,7 +87264,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 200 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 200 /* SyntaxKind.ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -86877,7 +87274,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 206 /* PropertyAccessExpression */ && + name.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { @@ -86887,17 +87284,17 @@ var ts; } } } - if (name.parent.kind === 271 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, - /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 265 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 265 /* SyntaxKind.ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -86913,28 +87310,28 @@ var ts; name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { - var meaning = 0 /* None */; + var meaning = 0 /* SymbolFlags.None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 228 /* ExpressionWithTypeArguments */) { - meaning = 788968 /* Type */; + if (name.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { + meaning = 788968 /* SymbolFlags.Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { - meaning |= 111551 /* Value */; + meaning |= 111551 /* SymbolFlags.Value */; } } else { - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } - meaning |= 2097152 /* Alias */; + meaning |= 2097152 /* SymbolFlags.Alias */; var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined; if (entityNameSymbol) { return entityNameSymbol; } } - if (name.parent.kind === 340 /* JSDocParameterTag */) { + if (name.parent.kind === 340 /* SyntaxKind.JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 163 /* TypeParameter */ && name.parent.parent.kind === 344 /* JSDocTemplateTag */) { + if (name.parent.kind === 163 /* SyntaxKind.TypeParameter */ && name.parent.parent.kind === 344 /* SyntaxKind.JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -86945,8 +87342,8 @@ var ts; return undefined; } var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); - var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */; - if (name.kind === 79 /* Identifier */) { + var meaning = isJSDoc_1 ? 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */ : 111551 /* SymbolFlags.Value */; + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; @@ -86963,16 +87360,16 @@ var ts; else if (ts.isPrivateIdentifier(name)) { return getSymbolForPrivateIdentifierExpression(name); } - else if (name.kind === 206 /* PropertyAccessExpression */ || name.kind === 161 /* QualifiedName */) { + else if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 161 /* SyntaxKind.QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 206 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name, 0 /* Normal */); + if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* CheckMode.Normal */); } else { - checkQualifiedName(name, 0 /* Normal */); + checkQualifiedName(name, 0 /* CheckMode.Normal */); } if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { return resolveJSDocMemberName(name); @@ -86984,12 +87381,12 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 178 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 178 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } - if (name.parent.kind === 177 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + if (name.parent.kind === 177 /* SyntaxKind.TypePredicate */) { + return resolveEntityName(name, /*meaning*/ 1 /* SymbolFlags.FunctionScopedVariable */); } return undefined; } @@ -87004,7 +87401,7 @@ var ts; function resolveJSDocMemberName(name, ignoreErrors, container) { if (ts.isEntityName(name)) { // resolve static values first - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */; var symbol = resolveEntityName(name, meaning, ignoreErrors, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); if (!symbol && ts.isIdentifier(name) && container) { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); @@ -87016,18 +87413,18 @@ var ts; var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left, ignoreErrors, container); var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; if (left) { - var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var proto = left.flags & 111551 /* SymbolFlags.Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); return getPropertyOfType(t, right); } } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -87041,12 +87438,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 203 /* BindingElement */ && - grandParent.kind === 201 /* ObjectBindingPattern */ && + else if (parent.kind === 203 /* SyntaxKind.BindingElement */ && + grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -87055,7 +87452,7 @@ var ts; } } else if (ts.isMetaProperty(parent) && parent.name === node) { - if (parent.keywordToken === 103 /* NewKeyword */ && ts.idText(node) === "target") { + if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") { // `target` in `new.target` return checkNewTargetMetaProperty(parent).symbol; } @@ -87063,7 +87460,7 @@ var ts; // we have a fake expression type made for other reasons already, whose transient `meta` // member should more exactly be the kind of (declarationless) symbol we want. // (See #44364 and #45031 for relevant implementation PRs) - if (parent.keywordToken === 100 /* ImportKeyword */ && ts.idText(node) === "meta") { + if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") { return getGlobalImportMetaExpressionType().members.get("meta"); } // no other meta properties are valid syntax, thus no others should have symbols @@ -87071,15 +87468,15 @@ var ts; } } switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: if (!ts.isThisInTypeQuery(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } // falls through - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -87091,25 +87488,25 @@ var ts; return checkExpression(node).symbol; } // falls through - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkExpression(node).symbol; - case 134 /* ConstructorKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 171 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 171 /* SyntaxKind.Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // 1). import x = require("./mo/*gotToDefinitionHere*/d") // 2). External module name in an import declaration // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 266 /* ImportDeclaration */ || node.parent.kind === 272 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.parent.kind === 272 /* SyntaxKind.ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -87118,7 +87515,7 @@ var ts; return getSymbolOfNode(parent); } // falls through - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: // index access var objectType = ts.isElementAccessExpression(parent) ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined @@ -87126,19 +87523,19 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 88 /* DefaultKeyword */: - case 98 /* FunctionKeyword */: - case 38 /* EqualsGreaterThanToken */: - case 84 /* ClassKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 84 /* SyntaxKind.ClassKeyword */: return getSymbolOfNode(node.parent); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; - case 100 /* ImportKeyword */: - case 103 /* NewKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkExpression(node).symbol; default: return undefined; @@ -87148,14 +87545,14 @@ var ts; if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { var keyType_1 = getLiteralTypeFromPropertyName(node); var objectType = getTypeOfExpression(node.parent.expression); - var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType]; + var objectTypes = objectType.flags & 1048576 /* TypeFlags.Union */ ? objectType.types : [objectType]; return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); }); } return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 297 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */); } return undefined; } @@ -87164,17 +87561,17 @@ var ts; if (ts.isExportSpecifier(node)) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } else { - return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + return resolveEntityName(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } } function getTypeOfNode(node) { if (ts.isSourceFile(node) && !ts.isExternalModule(node)) { return errorType; } - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -87215,7 +87612,7 @@ var ts; return errorType; } if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType; + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType; } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolAtLocation(node); @@ -87236,23 +87633,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 205 /* ObjectLiteralExpression */ || expr.kind === 204 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 244 /* ForOfStatement */) { + if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 221 /* BinaryExpression */) { + if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 296 /* PropertyAssignment */) { + if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) { var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); @@ -87262,7 +87659,7 @@ var ts; var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -87295,14 +87692,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return getStringLiteralType(ts.idText(name)); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getStringLiteralType(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* TypeFlags.ESSymbolLike */) ? nameType : stringType; default: return ts.Debug.fail("Unsupported property name."); } @@ -87312,8 +87709,8 @@ var ts; function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = ts.createSymbolTable(getPropertiesOfType(type)); - var functionType = getSignaturesOfType(type, 0 /* Call */).length ? globalCallableFunctionType : - getSignaturesOfType(type, 1 /* Construct */).length ? globalNewableFunctionType : + var functionType = getSignaturesOfType(type, 0 /* SignatureKind.Call */).length ? globalCallableFunctionType : + getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length ? globalNewableFunctionType : undefined; if (functionType) { ts.forEach(getPropertiesOfType(functionType), function (p) { @@ -87332,10 +87729,10 @@ var ts; return roots ? ts.flatMap(roots, getRootSymbols) : [symbol]; } function getImmediateRootSymbols(symbol) { - if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { + if (ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */) { return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); }); } - else if (symbol.flags & 33554432 /* Transient */) { + else if (symbol.flags & 33554432 /* SymbolFlags.Transient */) { var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin; return leftSpread ? [leftSpread, rightSpread] : syntheticOrigin ? [syntheticOrigin] @@ -87382,13 +87779,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 111551 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* SymbolFlags.Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 111551 /* Value */); + return s && !!(s.flags & 111551 /* SymbolFlags.Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -87406,19 +87803,19 @@ var ts; // declaration if it contains an exported member with the same name. var symbol = getReferencedValueSymbol(node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node)); if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { + if (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) { // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (!prefixLocals && exportSymbol.flags & 944 /* ExportHasLocal */ && !(exportSymbol.flags & 3 /* Variable */)) { + if (!prefixLocals && exportSymbol.flags & 944 /* SymbolFlags.ExportHasLocal */ && !(exportSymbol.flags & 3 /* SymbolFlags.Variable */)) { return undefined; } symbol = exportSymbol; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SyntaxKind.SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -87441,7 +87838,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -87450,20 +87847,20 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* SyntaxKind.CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* SymbolFlags.BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } - else if (nodeLinks_1.flags & 262144 /* CapturedBlockScopedBinding */) { + else if (nodeLinks_1.flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */) { // binding is captured in the function // should be renamed if: // - binding is not top level - top level bindings never collide with anything @@ -87479,9 +87876,9 @@ var ts; // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything - var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; + var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 235 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 235 /* SyntaxKind.Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -87522,20 +87919,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: var symbol = getSymbolOfNode(node); return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 271 /* ExportAssignment */: - return node.expression && node.expression.kind === 79 /* Identifier */ ? + case 271 /* SyntaxKind.ExportAssignment */: + return node.expression && node.expression.kind === 79 /* SyntaxKind.Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } @@ -87543,7 +87940,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 305 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -87560,7 +87957,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 111551 /* Value */) && + return !!(target.flags & 111551 /* SymbolFlags.Value */) && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -87574,8 +87971,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217 - if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && - target.flags & 111551 /* Value */ && + if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ && + target.flags & 111551 /* SymbolFlags.Value */ && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; @@ -87613,13 +88010,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -87627,10 +88024,10 @@ var ts; return false; } var symbol = getSymbolOfNode(declaration); - if (!symbol || !(symbol.flags & 16 /* Function */)) { + if (!symbol || !(symbol.flags & 16 /* SymbolFlags.Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* SymbolFlags.Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -87653,19 +88050,19 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 299 /* EnumMember */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 299 /* SyntaxKind.EnumMember */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 299 /* EnumMember */) { + if (node.kind === 299 /* SyntaxKind.EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { + if (symbol && (symbol.flags & 8 /* SymbolFlags.EnumMember */)) { // inline property\index accesses only for const enums var member = symbol.valueDeclaration; if (ts.isEnumConst(member.parent)) { @@ -87675,7 +88072,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* TypeFlags.Object */) && getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { var _a, _b; @@ -87691,14 +88088,14 @@ var ts; // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var isTypeOnly = false; if (ts.isQualifiedName(typeName)) { - var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)); } - var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); - var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol; + var valueSymbol = resolveEntityName(typeName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(valueSymbol) : valueSymbol; isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration))); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (resolvedSymbol && resolvedSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) { @@ -87717,28 +88114,28 @@ var ts; if (isErrorType(type)) { return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 3 /* AnyOrUnknown */) { + else if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* TypeFlags.Void */ | 98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* TypeFlags.BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* TypeFlags.NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* TypeFlags.BigIntLike */)) { return ts.TypeReferenceSerializationKind.BigIntLikeType; } - else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 402653316 /* TypeFlags.StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* TypeFlags.ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -87754,37 +88151,37 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + var type = symbol && !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 131072 /* SymbolFlags.Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol) { - flags |= 1048576 /* AllowUniqueESSymbolType */; + flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } if (addUndefined) { type = getOptionalType(type); } - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); - return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function hasGlobalName(name) { return globals.has(ts.escapeLeadingUnderscores(name)); @@ -87803,7 +88200,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -87824,7 +88221,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* TypeFlags.EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* SymbolFlags.Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse(); if (enumResult) return enumResult; @@ -87932,18 +88329,18 @@ var ts; isLateBound: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); - return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */); + return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */); }, getJsxFactoryEntity: getJsxFactoryEntity, getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 173 /* SetAccessor */ ? 172 /* GetAccessor */ : 173 /* SetAccessor */; + var otherKind = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? 172 /* SyntaxKind.GetAccessor */ : 173 /* SyntaxKind.SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 173 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 172 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -87959,7 +88356,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 305 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 305 /* SyntaxKind.SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -87996,7 +88393,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 228 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* HeritageClause */; + return node.parent && node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -88004,12 +88401,19 @@ var ts; if (!fileToDirective) { return undefined; } + // computed property name should use node as value // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + var meaning; + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; + } + else { + meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; + if ((node.kind === 79 /* SyntaxKind.Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; + } } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -88056,7 +88460,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -88084,12 +88488,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 261 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 305 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -88160,7 +88564,7 @@ var ts; getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; - getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* Anonymous */, globalThisSymbol); + getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* ObjectFlags.Anonymous */, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -88222,28 +88626,28 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* NodeFlags.Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* ExternalEmitHelpers.FirstEmitHelper */; helper <= 4194304 /* ExternalEmitHelpers.LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* SymbolFlags.Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } - else if (helper & 524288 /* ClassPrivateFieldGet */) { + else if (helper & 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4); } } - else if (helper & 1048576 /* ClassPrivateFieldSet */) { + else if (helper & 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); } } - else if (helper & 1024 /* SpreadArray */) { + else if (helper & 1024 /* ExternalEmitHelpers.SpreadArray */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3); } @@ -88257,29 +88661,29 @@ var ts; } function getHelperName(helper) { switch (helper) { - case 1 /* Extends */: return "__extends"; - case 2 /* Assign */: return "__assign"; - case 4 /* Rest */: return "__rest"; - case 8 /* Decorate */: return "__decorate"; - case 16 /* Metadata */: return "__metadata"; - case 32 /* Param */: return "__param"; - case 64 /* Awaiter */: return "__awaiter"; - case 128 /* Generator */: return "__generator"; - case 256 /* Values */: return "__values"; - case 512 /* Read */: return "__read"; - case 1024 /* SpreadArray */: return "__spreadArray"; - case 2048 /* Await */: return "__await"; - case 4096 /* AsyncGenerator */: return "__asyncGenerator"; - case 8192 /* AsyncDelegator */: return "__asyncDelegator"; - case 16384 /* AsyncValues */: return "__asyncValues"; - case 32768 /* ExportStar */: return "__exportStar"; - case 65536 /* ImportStar */: return "__importStar"; - case 131072 /* ImportDefault */: return "__importDefault"; - case 262144 /* MakeTemplateObject */: return "__makeTemplateObject"; - case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; - case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; - case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn"; - case 4194304 /* CreateBinding */: return "__createBinding"; + case 1 /* ExternalEmitHelpers.Extends */: return "__extends"; + case 2 /* ExternalEmitHelpers.Assign */: return "__assign"; + case 4 /* ExternalEmitHelpers.Rest */: return "__rest"; + case 8 /* ExternalEmitHelpers.Decorate */: return "__decorate"; + case 16 /* ExternalEmitHelpers.Metadata */: return "__metadata"; + case 32 /* ExternalEmitHelpers.Param */: return "__param"; + case 64 /* ExternalEmitHelpers.Awaiter */: return "__awaiter"; + case 128 /* ExternalEmitHelpers.Generator */: return "__generator"; + case 256 /* ExternalEmitHelpers.Values */: return "__values"; + case 512 /* ExternalEmitHelpers.Read */: return "__read"; + case 1024 /* ExternalEmitHelpers.SpreadArray */: return "__spreadArray"; + case 2048 /* ExternalEmitHelpers.Await */: return "__await"; + case 4096 /* ExternalEmitHelpers.AsyncGenerator */: return "__asyncGenerator"; + case 8192 /* ExternalEmitHelpers.AsyncDelegator */: return "__asyncDelegator"; + case 16384 /* ExternalEmitHelpers.AsyncValues */: return "__asyncValues"; + case 32768 /* ExternalEmitHelpers.ExportStar */: return "__exportStar"; + case 65536 /* ExternalEmitHelpers.ImportStar */: return "__importStar"; + case 131072 /* ExternalEmitHelpers.ImportDefault */: return "__importDefault"; + case 262144 /* ExternalEmitHelpers.MakeTemplateObject */: return "__makeTemplateObject"; + case 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */: return "__classPrivateFieldGet"; + case 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */: return "__classPrivateFieldSet"; + case 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */: return "__classPrivateFieldIn"; + case 4194304 /* ExternalEmitHelpers.CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -88301,14 +88705,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 169 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) { + else if (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (ts.hasDecorators(accessors.firstAccessor) && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -88322,71 +88726,71 @@ var ts; return quickResult; } var lastStatic, lastDeclare, lastAsync, lastOverride; - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (ts.isDecorator(modifier)) continue; - if (modifier.kind !== 145 /* ReadonlyKeyword */) { - if (node.kind === 166 /* PropertySignature */ || node.kind === 168 /* MethodSignature */) { + if (modifier.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.kind === 166 /* SyntaxKind.PropertySignature */ || node.kind === 168 /* SyntaxKind.MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 176 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */ && (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } - if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 144 /* OutKeyword */) { - if (node.kind === 163 /* TypeParameter */) { + if (modifier.kind !== 101 /* SyntaxKind.InKeyword */ && modifier.kind !== 144 /* SyntaxKind.OutKeyword */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 85 /* ConstKeyword */: - if (node.kind !== 260 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); + case 85 /* SyntaxKind.ConstKeyword */: + if (node.kind !== 260 /* SyntaxKind.EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* SyntaxKind.ConstKeyword */)); } break; - case 159 /* OverrideKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; lastOverride = modifier; break; - case 123 /* PublicKeyword */: - case 122 /* ProtectedKeyword */: - case 121 /* PrivateKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 28 /* ModifierFlags.AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); } - else if (flags & 32 /* Static */) { + else if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } - else if (flags & 128 /* Abstract */) { - if (modifier.kind === 121 /* PrivateKeyword */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { + if (modifier.kind === 121 /* SyntaxKind.PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -88398,185 +88802,185 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 124 /* StaticKeyword */: - if (flags & 32 /* Static */) { + case 124 /* SyntaxKind.StaticKeyword */: + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 32 /* ModifierFlags.Static */; lastStatic = modifier; break; - case 145 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + case 145 /* SyntaxKind.ReadonlyKeyword */: + if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */ && node.kind !== 176 /* IndexSignature */ && node.kind !== 164 /* Parameter */) { + else if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */ && node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 164 /* SyntaxKind.Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; break; - case 93 /* ExportKeyword */: - if (flags & 1 /* Export */) { + case 93 /* SyntaxKind.ExportKeyword */: + if (flags & 1 /* ModifierFlags.Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; break; - case 88 /* DefaultKeyword */: - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* SyntaxKind.DefaultKeyword */: + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } - else if (!(flags & 1 /* Export */)) { + else if (!(flags & 1 /* ModifierFlags.Export */)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } - flags |= 512 /* Default */; + flags |= 512 /* ModifierFlags.Default */; break; - case 135 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + case 135 /* SyntaxKind.DeclareKeyword */: + if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) { + else if ((node.parent.flags & 16777216 /* NodeFlags.Ambient */) && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; lastDeclare = modifier; break; - case 126 /* AbstractKeyword */: - if (flags & 128 /* Abstract */) { + case 126 /* SyntaxKind.AbstractKeyword */: + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 257 /* ClassDeclaration */ && - node.kind !== 180 /* ConstructorType */) { - if (node.kind !== 169 /* MethodDeclaration */ && - node.kind !== 167 /* PropertyDeclaration */ && - node.kind !== 172 /* GetAccessor */ && - node.kind !== 173 /* SetAccessor */) { + if (node.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + node.kind !== 180 /* SyntaxKind.ConstructorType */) { + if (node.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + node.kind !== 172 /* SyntaxKind.GetAccessor */ && + node.kind !== 173 /* SyntaxKind.SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 257 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 256 /* Async */ && lastAsync) { + if (flags & 256 /* ModifierFlags.Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } } - if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 128 /* Abstract */; + flags |= 128 /* ModifierFlags.Abstract */; break; - case 131 /* AsyncKeyword */: - if (flags & 256 /* Async */) { + case 131 /* SyntaxKind.AsyncKeyword */: + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */ || node.parent.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 256 /* Async */; + flags |= 256 /* ModifierFlags.Async */; lastAsync = modifier; break; - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; - var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out"; - if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + var inOutFlag = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? 32768 /* ModifierFlags.In */ : 65536 /* ModifierFlags.Out */; + var inOutText = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? "in" : "out"; + if (node.kind !== 163 /* SyntaxKind.TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 32768 /* ModifierFlags.In */ && flags & 65536 /* ModifierFlags.Out */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; break; } } - if (node.kind === 171 /* Constructor */) { - if (flags & 32 /* Static */) { + if (node.kind === 171 /* SyntaxKind.Constructor */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; } - else if ((node.kind === 266 /* ImportDeclaration */ || node.kind === 265 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) && flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -88594,48 +88998,48 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 261 /* ModuleDeclaration */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return false; - case 170 /* ClassStaticBlockDeclaration */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 264 /* NamespaceExportDeclaration */: - case 179 /* FunctionType */: - case 276 /* MissingDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 276 /* SyntaxKind.MissingDeclaration */: return true; default: - if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return false; } switch (node.kind) { - case 256 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */); - case 257 /* ClassDeclaration */: - case 180 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 237 /* VariableStatement */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 131 /* SyntaxKind.AsyncKeyword */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 180 /* SyntaxKind.ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* SyntaxKind.AbstractKeyword */); + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 260 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); + case 260 /* SyntaxKind.EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* SyntaxKind.ConstKeyword */); default: ts.Debug.assertNever(node); } @@ -88652,10 +89056,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -88684,7 +89088,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 16777216 /* NodeFlags.Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -88709,7 +89113,7 @@ var ts; return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); }); } function checkGrammarForUseStrictSimpleParameterList(node) { - if (languageVersion >= 3 /* ES2016 */) { + if (languageVersion >= 3 /* ScriptTarget.ES2016 */) { var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements); if (useStrictDirective_1) { var nonSimpleParameters = getNonSimpleParameters(node.parameters); @@ -88744,7 +89148,7 @@ var ts; return false; } if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { - if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */])) { grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } @@ -88780,7 +89184,7 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } var type = getTypeFromTypeNode(parameter.type); - if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { + if (someType(type, function (t) { return !!(t.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead); } if (!everyType(type, isValidIndexKeyType)) { @@ -88809,7 +89213,7 @@ var ts; checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } function checkGrammarTaggedTemplateChain(node) { - if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + if (node.questionDotToken || node.flags & 32 /* NodeFlags.OptionalChain */) { return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); } return false; @@ -88837,7 +89241,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -88850,7 +89254,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -88866,14 +89270,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -88884,21 +89288,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 221 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 221 /* SyntaxKind.BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 169 /* MethodDeclaration */); - if (node.flags & 16777216 /* Ambient */) { + ts.Debug.assert(node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -88916,7 +89320,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -88927,23 +89331,23 @@ var ts; continue; } var name = prop.name; - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 297 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } - if (name.kind === 80 /* PrivateIdentifier */) { + if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (ts.canHaveModifiers(prop) && prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (ts.isModifier(mod) && (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 169 /* MethodDeclaration */)) { + if (ts.isModifier(mod) && (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */)) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -88964,24 +89368,24 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name.kind === 8 /* NumericLiteral */) { + if (name.kind === 8 /* SyntaxKind.NumericLiteral */) { checkGrammarNumericLiteral(name); } - currentKind = 4 /* PropertyAssignment */; + currentKind = 4 /* DeclarationMeaning.PropertyAssignment */; break; - case 169 /* MethodDeclaration */: - currentKind = 8 /* Method */; + case 169 /* SyntaxKind.MethodDeclaration */: + currentKind = 8 /* DeclarationMeaning.Method */; break; - case 172 /* GetAccessor */: - currentKind = 1 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + currentKind = 1 /* DeclarationMeaning.GetAccessor */; break; - case 173 /* SetAccessor */: - currentKind = 2 /* SetAccessor */; + case 173 /* SyntaxKind.SetAccessor */: + currentKind = 2 /* DeclarationMeaning.SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -88996,14 +89400,14 @@ var ts; seen.set(effectiveName, currentKind); } else { - if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) { + if ((currentKind & 8 /* DeclarationMeaning.Method */) && (existingKind & 8 /* DeclarationMeaning.Method */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) { + else if ((currentKind & 4 /* DeclarationMeaning.PropertyAssignment */) && (existingKind & 4 /* DeclarationMeaning.PropertyAssignment */)) { grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name)); } - else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { - if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* DeclarationMeaning.GetOrSetAccessor */) && (existingKind & 3 /* DeclarationMeaning.GetOrSetAccessor */)) { + if (existingKind !== 3 /* DeclarationMeaning.GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -89023,7 +89427,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 287 /* JsxSpreadAttribute */) { + if (attr.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -89033,7 +89437,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 288 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 288 /* SyntaxKind.JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -89068,8 +89472,8 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 244 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { + if (forInOrOfStatement.kind === 244 /* SyntaxKind.ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { if (!hasParseDiagnostics(sourceFile)) { @@ -89087,7 +89491,7 @@ var ts; case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: case ts.ModuleKind.System: - if (languageVersion >= 4 /* ES2017 */) { + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { break; } // fallthrough @@ -89102,8 +89506,8 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 171 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); + if (func && func.kind !== 171 /* SyntaxKind.Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -89114,12 +89518,12 @@ var ts; return false; } } - if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) && + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */) && ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") { grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async); return false; } - if (forInOrOfStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -89134,20 +89538,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -89157,22 +89561,22 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) { - if (languageVersion < 1 /* ES5 */) { + if (!(accessor.flags & 16777216 /* NodeFlags.Ambient */) && (accessor.parent.kind !== 182 /* SyntaxKind.TypeLiteral */) && (accessor.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */)) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - if (accessor.parent.kind === 182 /* TypeLiteral */ || accessor.parent.kind === 258 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 182 /* SyntaxKind.TypeLiteral */ || accessor.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -89180,11 +89584,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 173 /* SetAccessor */) { + if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -89206,17 +89610,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 154 /* UniqueKeyword */) { - if (node.type.kind !== 151 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SymbolKeyword */)); + if (node.operator === 154 /* SyntaxKind.UniqueKeyword */) { + if (node.type.kind !== 151 /* SyntaxKind.SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -89226,26 +89630,26 @@ var ts; } } switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 79 /* Identifier */) { + if (decl.name.kind !== 79 /* SyntaxKind.Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); } - if (!(decl.parent.flags & 2 /* Const */)) { + if (!(decl.parent.flags & 2 /* NodeFlags.Const */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (!ts.isStatic(parent) || !ts.hasEffectiveReadonlyModifier(parent)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 166 /* PropertySignature */: - if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { + case 166 /* SyntaxKind.PropertySignature */: + if (!ts.hasSyntacticModifier(parent, 64 /* ModifierFlags.Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -89253,9 +89657,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 145 /* ReadonlyKeyword */) { - if (node.type.kind !== 183 /* ArrayType */ && node.type.kind !== 184 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SymbolKeyword */)); + else if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.type.kind !== 183 /* SyntaxKind.ArrayType */ && node.type.kind !== 184 /* SyntaxKind.TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } } } @@ -89268,10 +89672,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 169 /* MethodDeclaration */) { - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) { + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -89289,7 +89693,7 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } // Technically, computed properties in ambient contexts is disallowed @@ -89297,17 +89701,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 169 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 182 /* TypeLiteral */) { + else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -89318,11 +89722,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 245 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 245 /* SyntaxKind.ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -89330,8 +89734,8 @@ var ts; return false; } break; - case 249 /* SwitchStatement */: - if (node.kind === 246 /* BreakStatement */ && !node.label) { + case 249 /* SyntaxKind.SwitchStatement */: + if (node.kind === 246 /* SyntaxKind.BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -89346,13 +89750,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -89376,18 +89780,18 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; } function isBigIntLiteralExpression(expr) { - return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 9 /* BigIntLiteral */; + return expr.kind === 9 /* SyntaxKind.BigIntLiteral */ || + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 9 /* SyntaxKind.BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) { - return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* TypeFlags.EnumLiteral */); } } function checkAmbientInitializer(node) { @@ -89395,7 +89799,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || + initializer.kind === 110 /* SyntaxKind.TrueKeyword */ || initializer.kind === 95 /* SyntaxKind.FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -89406,14 +89810,11 @@ var ts; else { return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } - if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) { - if (node.flags & 16777216 /* Ambient */) { + if (node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */ && node.parent.parent.kind !== 244 /* SyntaxKind.ForOfStatement */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -89425,7 +89826,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 237 /* SyntaxKind.VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* NodeFlags.Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -89434,7 +89835,7 @@ var ts; return grammarErrorOnNode(node.exclamationToken, message); } if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System && - !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* ModifierFlags.Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -89447,7 +89848,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -89464,8 +89865,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 79 /* Identifier */) { - if (name.originalKeywordKind === 119 /* LetKeyword */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { + if (name.originalKeywordKind === 119 /* SyntaxKind.LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -89492,15 +89893,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return false; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -89518,12 +89919,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -89581,7 +89982,7 @@ var ts; } } function checkGrammarProperty(node) { - if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) { + if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) { return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); } if (ts.isClassLike(node.parent)) { @@ -89591,11 +89992,11 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { return true; } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -89615,11 +90016,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { + node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -89641,14 +90042,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 259 /* TypeAliasDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 272 /* ExportDeclaration */ || - node.kind === 271 /* ExportAssignment */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */ | 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -89656,7 +90057,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 237 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 237 /* SyntaxKind.VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -89665,10 +90066,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -89679,7 +90080,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 235 /* Block */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 235 /* SyntaxKind.Block */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -89696,19 +90097,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.numericLiteralFlags & 32 /* Octal */) { + if (node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { var diagnosticMessage = void 0; - if (languageVersion >= 1 /* ES5 */) { + if (languageVersion >= 1 /* ScriptTarget.ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 196 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 196 /* SyntaxKind.LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 299 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 299 /* SyntaxKind.EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* SyntaxKind.MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -89721,7 +90122,7 @@ var ts; // We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "." // e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`. var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1; - var isScientific = node.numericLiteralFlags & 16 /* Scientific */; + var isScientific = node.numericLiteralFlags & 16 /* TokenFlags.Scientific */; // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway if (isFractional || isScientific) { @@ -89742,7 +90143,7 @@ var ts; var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); if (!literalType) { - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { return true; } @@ -89776,7 +90177,7 @@ var ts; if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } - if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* NamedImports */) { + if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* SyntaxKind.NamedImports */) { return checkGrammarNamedImportsOrExports(node.namedBindings); } return false; @@ -89784,7 +90185,7 @@ var ts; function checkGrammarNamedImportsOrExports(namedBindings) { return !!ts.forEach(namedBindings.elements, function (specifier) { if (specifier.isTypeOnly) { - return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* ImportSpecifier */ + return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* SyntaxKind.ImportSpecifier */ ? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement : ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); } @@ -89819,14 +90220,14 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { + if (sourceObjectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */) && unionTarget.flags & 1048576 /* TypeFlags.Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 524288 /* Object */) { + if (target.flags & 524288 /* TypeFlags.Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); - if (overlapObjFlags & 4 /* Reference */) { + if (overlapObjFlags & 4 /* ObjectFlags.Reference */) { return source.target === target.target; } - if (overlapObjFlags & 16 /* Anonymous */) { + if (overlapObjFlags & 16 /* ObjectFlags.Anonymous */) { return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; } } @@ -89835,35 +90236,35 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectFlags.ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } function findBestTypeForInvokable(source, unionTarget) { - var signatureKind = 0 /* Call */; + var signatureKind = 0 /* SignatureKind.Call */; var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 || - (signatureKind = 1 /* Construct */, getSignaturesOfType(source, signatureKind).length > 0); + (signatureKind = 1 /* SignatureKind.Construct */, getSignaturesOfType(source, signatureKind).length > 0); if (hasSignatures) { return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; }); } } function findMostOverlappyType(source, unionTarget) { var bestMatch; - if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(source.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var matchingCount = 0; for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) { var target = _a[_i]; - if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(target.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]); - if (overlap.flags & 4194304 /* Index */) { + if (overlap.flags & 4194304 /* TypeFlags.Index */) { // perfect overlap of keys return target; } - else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) { + else if (isUnitType(overlap) || overlap.flags & 1048576 /* TypeFlags.Union */) { // We only want to account for literal types otherwise. // If we have a union of index types, it seems likely that we // needed to elaborate between two generic mapped types anyway. - var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; + var len = overlap.flags & 1048576 /* TypeFlags.Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; if (len >= matchingCount) { bestMatch = target; matchingCount = len; @@ -89875,9 +90276,9 @@ var ts; return bestMatch; } function filterPrimitivesIfContainsNonPrimitive(type) { - if (maybeTypeOfKind(type, 67108864 /* NonPrimitive */)) { - var result = filterType(type, function (t) { return !(t.flags & 131068 /* Primitive */); }); - if (!(result.flags & 131072 /* Never */)) { + if (maybeTypeOfKind(type, 67108864 /* TypeFlags.NonPrimitive */)) { + var result = filterType(type, function (t) { return !(t.flags & 131068 /* TypeFlags.Primitive */); }); + if (!(result.flags & 131072 /* TypeFlags.Never */)) { return result; } } @@ -89885,7 +90286,7 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { - if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { + if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) { var match = getMatchingUnionConstituentForType(target, source); if (match) { return match; @@ -89907,14 +90308,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 256 /* FunctionDeclaration */ && declaration.kind !== 169 /* MethodDeclaration */) || + return (declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */ && declaration.kind !== 169 /* SyntaxKind.MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -89934,17 +90335,17 @@ var ts; })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { - case 0 /* Yield */: return "yieldType"; - case 1 /* Return */: return "returnType"; - case 2 /* Next */: return "nextType"; + case 0 /* IterationTypeKind.Yield */: return "yieldType"; + case 1 /* IterationTypeKind.Return */: return "returnType"; + case 2 /* IterationTypeKind.Next */: return "nextType"; } } function signatureHasRestParameter(s) { - return !!(s.flags & 1 /* HasRestParameter */); + return !!(s.flags & 1 /* SignatureFlags.HasRestParameter */); } ts.signatureHasRestParameter = signatureHasRestParameter; function signatureHasLiteralTypes(s) { - return !!(s.flags & 2 /* HasLiteralTypes */); + return !!(s.flags & 2 /* SignatureFlags.HasLiteralTypes */); } ts.signatureHasLiteralTypes = signatureHasLiteralTypes; })(ts || (ts = {})); @@ -90084,7 +90485,7 @@ var ts; var updated; context.startLexicalEnvironment(); if (nodes) { - context.setLexicalEnvironmentFlags(1 /* InParameters */, true); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, true); updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression @@ -90092,11 +90493,11 @@ var ts; // exists in a different lexical scope. To address this, we move any binding patterns and initializers // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list // when the emit target is greater than ES2015. - if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ && - ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (context.getLexicalEnvironmentFlags() & 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */ && + ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { updated = addDefaultValueAssignmentsIfNeeded(updated, context); } - context.setLexicalEnvironmentFlags(1 /* InParameters */, false); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, false); } context.suspendLexicalEnvironment(); return updated; @@ -90143,8 +90544,8 @@ var ts; function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { var factory = context.factory; context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ - factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */))); + factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */))); return factory.updateParameterDeclaration(parameter, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, /*initializer*/ undefined); } @@ -90190,446 +90591,446 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 160 /* LastToken */) || kind === 192 /* ThisType */) { + if ((kind > 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */) || kind === 192 /* SyntaxKind.ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: ts.Debug.type(node); return factory.updateParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: ts.Debug.type(node); return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: ts.Debug.type(node); return factory.updateMethodDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: ts.Debug.type(node); context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); return factory.updateClassStaticBlockDeclaration(node, visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: ts.Debug.type(node); return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: ts.Debug.type(node); return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: ts.Debug.type(node); return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: ts.Debug.type(node); return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: ts.Debug.type(node); - return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 295 /* ImportTypeAssertionContainer */: + return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: ts.Debug.type(node); - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 191 /* ParenthesizedType */: + return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); + case 191 /* SyntaxKind.ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: ts.Debug.type(node); return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: ts.Debug.type(node); return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 206 /* PropertyAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName)); } ts.Debug.type(node); return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); - case 207 /* ElementAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 208 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: ts.Debug.type(node); return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: ts.Debug.type(node); - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 211 /* TypeAssertionExpression */: + return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: ts.Debug.type(node); return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: ts.Debug.type(node); return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: ts.Debug.type(node); return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: ts.Debug.type(node); return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 230 /* NonNullExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 230 /* SyntaxKind.NonNullExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: ts.Debug.type(node); return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: ts.Debug.type(node); return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: ts.Debug.type(node); return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: ts.Debug.type(node); return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: ts.Debug.type(node); return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: ts.Debug.type(node); return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: ts.Debug.type(node); return factory.updateFunctionDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: ts.Debug.type(node); return factory.updateModuleDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: ts.Debug.type(node); return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: ts.Debug.type(node); return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode)); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: ts.Debug.type(node); return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: ts.Debug.type(node); return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: ts.Debug.type(node); return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: ts.Debug.type(node); return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.type(node); return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: ts.Debug.type(node); return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -90854,7 +91255,7 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - appendMappingCharCode(59 /* semicolon */); + appendMappingCharCode(59 /* CharacterCodes.semicolon */); lastGeneratedLine++; } while (lastGeneratedLine < pendingGeneratedLine); // Only need to set this once @@ -90864,7 +91265,7 @@ var ts; ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - appendMappingCharCode(44 /* comma */); + appendMappingCharCode(44 /* CharacterCodes.comma */); } } // 1. Relative generated character @@ -91007,14 +91408,14 @@ var ts; next: function () { while (!done && pos < mappings.length) { var ch = mappings.charCodeAt(pos); - if (ch === 59 /* semicolon */) { + if (ch === 59 /* CharacterCodes.semicolon */) { // new line generatedLine++; generatedCharacter = 0; pos++; continue; } - if (ch === 44 /* comma */) { + if (ch === 44 /* CharacterCodes.comma */) { // Next entry is on same line - no action needed pos++; continue; @@ -91091,8 +91492,8 @@ var ts; } function isSourceMappingSegmentEnd() { return (pos === mappings.length || - mappings.charCodeAt(pos) === 44 /* comma */ || - mappings.charCodeAt(pos) === 59 /* semicolon */); + mappings.charCodeAt(pos) === 44 /* CharacterCodes.comma */ || + mappings.charCodeAt(pos) === 59 /* CharacterCodes.semicolon */); } function base64VLQFormatDecode() { var moreDigits = true; @@ -91142,19 +91543,19 @@ var ts; } ts.isSourceMapping = isSourceMapping; function base64FormatEncode(value) { - return value >= 0 && value < 26 ? 65 /* A */ + value : - value >= 26 && value < 52 ? 97 /* a */ + value - 26 : - value >= 52 && value < 62 ? 48 /* _0 */ + value - 52 : - value === 62 ? 43 /* plus */ : - value === 63 ? 47 /* slash */ : - ts.Debug.fail(value + ": not a base64 value"); + return value >= 0 && value < 26 ? 65 /* CharacterCodes.A */ + value : + value >= 26 && value < 52 ? 97 /* CharacterCodes.a */ + value - 26 : + value >= 52 && value < 62 ? 48 /* CharacterCodes._0 */ + value - 52 : + value === 62 ? 43 /* CharacterCodes.plus */ : + value === 63 ? 47 /* CharacterCodes.slash */ : + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ ? ch - 65 /* A */ : - ch >= 97 /* a */ && ch <= 122 /* z */ ? ch - 97 /* a */ + 26 : - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ ? ch - 48 /* _0 */ + 52 : - ch === 43 /* plus */ ? 62 : - ch === 47 /* slash */ ? 63 : + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ ? ch - 65 /* CharacterCodes.A */ : + ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ? ch - 97 /* CharacterCodes.a */ + 26 : + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ ? ch - 48 /* CharacterCodes._0 */ + 52 : + ch === 43 /* CharacterCodes.plus */ ? 62 : + ch === 47 /* CharacterCodes.slash */ ? 63 : -1; } function isSourceMappedPosition(value) { @@ -91222,7 +91623,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -91315,12 +91716,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* InternalSymbolName.Default */; } function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -91371,7 +91772,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -91384,13 +91785,13 @@ var ts; hasImportDefault = true; } break; - case 265 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 277 /* ExternalModuleReference */) { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -91421,23 +91822,23 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 237 /* VariableStatement */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + case 237 /* SyntaxKind.VariableStatement */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames); } } break; - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default function() { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -91455,9 +91856,9 @@ var ts; } } break; - case 257 /* ClassDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default class { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -91538,7 +91939,7 @@ var ts; */ function isSimpleCopiableExpression(expression) { return ts.isStringLiteralLike(expression) || - expression.kind === 8 /* NumericLiteral */ || + expression.kind === 8 /* SyntaxKind.NumericLiteral */ || ts.isKeyword(expression.kind) || ts.isIdentifier(expression); } @@ -91553,27 +91954,27 @@ var ts; } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 64 /* FirstCompoundAssignment */ - && kind <= 78 /* LastCompoundAssignment */; + return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */ + && kind <= 78 /* SyntaxKind.LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 64 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 65 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 68 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 69 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 74 /* BarEqualsToken */: return 51 /* BarToken */; - case 78 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + case 64 /* SyntaxKind.PlusEqualsToken */: return 39 /* SyntaxKind.PlusToken */; + case 65 /* SyntaxKind.MinusEqualsToken */: return 40 /* SyntaxKind.MinusToken */; + case 66 /* SyntaxKind.AsteriskEqualsToken */: return 41 /* SyntaxKind.AsteriskToken */; + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return 42 /* SyntaxKind.AsteriskAsteriskToken */; + case 68 /* SyntaxKind.SlashEqualsToken */: return 43 /* SyntaxKind.SlashToken */; + case 69 /* SyntaxKind.PercentEqualsToken */: return 44 /* SyntaxKind.PercentToken */; + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: return 47 /* SyntaxKind.LessThanLessThanToken */; + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: return 48 /* SyntaxKind.GreaterThanGreaterThanToken */; + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; + case 73 /* SyntaxKind.AmpersandEqualsToken */: return 50 /* SyntaxKind.AmpersandToken */; + case 74 /* SyntaxKind.BarEqualsToken */: return 51 /* SyntaxKind.BarToken */; + case 78 /* SyntaxKind.CaretEqualsToken */: return 52 /* SyntaxKind.CaretToken */; + case 75 /* SyntaxKind.BarBarEqualsToken */: return 56 /* SyntaxKind.BarBarToken */; + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: return 55 /* SyntaxKind.AmpersandAmpersandToken */; + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return 60 /* SyntaxKind.QuestionQuestionToken */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -91635,7 +92036,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 167 /* PropertyDeclaration */ + return member.kind === 167 /* SyntaxKind.PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -91699,12 +92100,12 @@ var ts; */ function getAllDecoratorsOfClassElement(member, parent) { switch (member.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return getAllDecoratorsOfAccessors(member, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -92040,9 +92441,9 @@ var ts; var element = elements[i]; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); - if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */)) + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */ + && !(element.transformFlags & (32768 /* TransformFlags.ContainsRestOrSpread */ | 65536 /* TransformFlags.ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* TransformFlags.ContainsRestOrSpread */ | 65536 /* TransformFlags.ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -92083,14 +92484,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + if (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ && flattenContext.downlevelIteration) { // Read the elements of the iterable into an array value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) ? undefined : numElements), location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + else if (numElements !== 1 && (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ || numElements === 0) || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -92105,10 +92506,10 @@ var ts; var restContainingElements; for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (flattenContext.level >= 1 /* ObjectRest */) { + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -92311,7 +92712,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + var isLast = node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || node.kind === 17 /* SyntaxKind.TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); } // Newline normalization: @@ -92365,8 +92766,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -92386,14 +92787,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -92442,16 +92843,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 262 /* ModuleBlock */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 262 /* SyntaxKind.ModuleBlock */: + case 235 /* SyntaxKind.Block */: currentLexicalScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { break; } // Record these declarations provided that they have a name. @@ -92462,7 +92863,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 257 /* SyntaxKind.ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)); } break; } @@ -92481,7 +92882,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { return visitTypeScript(node); } return node; @@ -92501,10 +92902,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -92517,7 +92918,7 @@ var ts; // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes // We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`, // and will trigger debug failures when debug verbosity is turned up - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { // This node contains TypeScript, so we should visit its children. return ts.visitEachChild(node, visitor, context); } @@ -92525,13 +92926,13 @@ var ts; return node; } switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -92551,15 +92952,15 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 272 /* ExportDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 267 /* ImportClause */ || - (node.kind === 265 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 277 /* ExternalModuleReference */)) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ || + (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && + node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } - else if (node.transformFlags & 1 /* ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* Export */)) { + else if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return visitTypeScript(node); } return node; @@ -92579,27 +92980,27 @@ var ts; */ function classElementVisitorWorker(node, parent) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node, parent); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node, parent); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node, parent); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return ts.visitEachChild(node, visitor, context); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Index signatures are elided return; default: @@ -92611,17 +93012,17 @@ var ts; } function objectLiteralElementVisitorWorker(node, parent) { switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitor(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node, parent); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node, parent); @@ -92632,10 +93033,10 @@ var ts; function modifierVisitor(node) { if (ts.isDecorator(node)) return undefined; - if (ts.modifierToFlag(node.kind) & 116958 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 116958 /* ModifierFlags.TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* SyntaxKind.ExportKeyword */) { return undefined; } return node; @@ -92646,72 +93047,72 @@ var ts; * @param node The node to visit. */ function visitTypeScript(node) { - if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { // TypeScript ambient declarations are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 145 /* ReadonlyKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 185 /* OptionalType */: - case 186 /* RestType */: - case 182 /* TypeLiteral */: - case 177 /* TypePredicate */: - case 163 /* TypeParameter */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 133 /* BooleanKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 143 /* NeverKeyword */: - case 114 /* VoidKeyword */: - case 151 /* SymbolKeyword */: - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 181 /* TypeQuery */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 189 /* ConditionalType */: - case 191 /* ParenthesizedType */: - case 192 /* ThisType */: - case 193 /* TypeOperator */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 196 /* LiteralType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 177 /* SyntaxKind.TypePredicate */: + case 163 /* SyntaxKind.TypeParameter */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 181 /* SyntaxKind.TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 189 /* SyntaxKind.ConditionalType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 192 /* SyntaxKind.ThisType */: + case 193 /* SyntaxKind.TypeOperator */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 196 /* SyntaxKind.LiteralType */: // TypeScript type nodes are elided. // falls through - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // TypeScript index signatures are elided. return undefined; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return factory.createNotEmittedStatement(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -92721,7 +93122,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -92731,34 +93132,34 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors"); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -92768,40 +93169,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -92818,28 +93219,28 @@ var ts; return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement)); } function getClassFacts(node, staticProperties) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; if (ts.some(staticProperties)) - facts |= 1 /* HasStaticInitializedProperties */; + facts |= 1 /* ClassFacts.HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) - facts |= 64 /* IsDerivedClass */; + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */) + facts |= 64 /* ClassFacts.IsDerivedClass */; if (ts.classOrConstructorParameterIsDecorated(node)) - facts |= 2 /* HasConstructorDecorators */; + facts |= 2 /* ClassFacts.HasConstructorDecorators */; if (ts.childIsDecorated(node)) - facts |= 4 /* HasMemberDecorators */; + facts |= 4 /* ClassFacts.HasMemberDecorators */; if (isExportOfNamespace(node)) - facts |= 8 /* IsExportOfNamespace */; + facts |= 8 /* ClassFacts.IsExportOfNamespace */; else if (isDefaultExternalModuleExport(node)) - facts |= 32 /* IsDefaultExternalExport */; + facts |= 32 /* ClassFacts.IsDefaultExternalExport */; else if (isNamedExternalModuleExport(node)) - facts |= 16 /* IsNamedExternalExport */; - if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */)) - facts |= 128 /* UseImmediatelyInvokedFunctionExpression */; + facts |= 16 /* ClassFacts.IsNamedExternalExport */; + if (languageVersion <= 1 /* ScriptTarget.ES5 */ && (facts & 7 /* ClassFacts.MayNeedImmediatelyInvokedFunctionExpression */)) + facts |= 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.hasDecorators(node) @@ -92848,20 +93249,20 @@ var ts; || ts.some(node.members, hasTypeScriptClassSyntax); } function visitClassDeclaration(node) { - if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) { + if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement)); } var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); } - var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); + var name = node.name || (facts & 5 /* ClassFacts.NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); var allDecorators = ts.getAllDecoratorsOfClass(node); var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators); // we do not emit modifiers on the declaration if we are emitting an IIFE - var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */) + var modifiers = !(facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) : ts.elideNodes(factory, node.modifiers); // preserve positions, if available // ${modifiers} class ${name} ${heritageClauses} { @@ -92872,12 +93273,12 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. var emitFlags = ts.getEmitFlags(node); - if (facts & 1 /* HasStaticInitializedProperties */) { - emitFlags |= 32 /* NoTrailingSourceMap */; + if (facts & 1 /* ClassFacts.HasStaticInitializedProperties */) { + emitFlags |= 32 /* EmitFlags.NoTrailingSourceMap */; } ts.setEmitFlags(classStatement, emitFlags); var statements = [classStatement]; - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the // 'es2015' transformer can properly nest static initializers and decorators. The result // looks something like: @@ -92889,20 +93290,20 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); var localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(localName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment()); var iife = factory.createImmediatelyInvokedArrowFunction(statements); - ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); + ts.setEmitFlags(iife, 33554432 /* EmitFlags.TypeScriptClassWrapper */); var varStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), @@ -92918,21 +93319,21 @@ var ts; // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. - if (facts & 8 /* IsExportOfNamespace */) { + if (facts & 8 /* ClassFacts.IsExportOfNamespace */) { addExportMemberAssignment(statements, node); } - else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { - if (facts & 32 /* IsDefaultExternalExport */) { + else if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* ClassFacts.HasConstructorDecorators */) { + if (facts & 32 /* ClassFacts.IsDefaultExternalExport */) { statements.push(factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } - else if (facts & 16 /* IsNamedExternalExport */) { + else if (facts & 16 /* ClassFacts.IsNamedExternalExport */) { statements.push(factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -93003,11 +93404,11 @@ var ts; var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression); var helper = emitHelpers().createParamHelper(expression, parameterOffset); ts.setTextRange(helper, parameterDecorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); var decorator = factory.createDecorator(helper); ts.setSourceMapRange(decorator, parameterDecorator.expression); ts.setCommentRange(decorator, parameterDecorator.expression); - ts.setEmitFlags(decorator, 1536 /* NoComments */); + ts.setEmitFlags(decorator, 1536 /* EmitFlags.NoComments */); decorators.push(decorator); } return decorators; @@ -93045,15 +93446,15 @@ var ts; if (typeSerializer) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); properties = ts.append(properties, typeProperty); } if (shouldAddParamTypesMetadata(node)) { - var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container))); + var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container))); properties = ts.append(properties, paramTypeProperty); } if (shouldAddReturnTypeMetadata(node)) { - var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); properties = ts.append(properties, returnTypeProperty); } if (properties) { @@ -93071,10 +93472,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 167 /* PropertyDeclaration */; + return kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -93084,7 +93485,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -93095,12 +93496,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; } return false; @@ -93162,7 +93563,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 117 /* ImplementsKeyword */) { + if (node.token === 117 /* SyntaxKind.ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -93190,7 +93591,7 @@ var ts; return !ts.nodeIsMissing(node.body); } function visitPropertyDeclaration(node, parent) { - var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */); + var isAmbient = node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); if (isAmbient && !ts.hasDecorators(node)) { return undefined; } @@ -93198,7 +93599,7 @@ var ts; var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators); // Preserve a `declare x` property with decorators to be handled by the decorators transform if (isAmbient) { - return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, factory.createModifiersFromModifierFlags(2 /* Ambient */)), ts.visitNode(node.name, visitor, ts.isPropertyName), + return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, factory.createModifiersFromModifierFlags(2 /* ModifierFlags.Ambient */)), ts.visitNode(node.name, visitor, ts.isPropertyName), /*questionOrExclamationToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); @@ -93250,7 +93651,8 @@ var ts; statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); + var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start)); // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); @@ -93270,14 +93672,14 @@ var ts; } // TODO(rbuckton): Does this need to be parented? var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 48 /* EmitFlags.NoSourceMap */); // TODO(rbuckton): Does this need to be parented? var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(localName, 1536 /* NoComments */); + ts.setEmitFlags(localName, 1536 /* EmitFlags.NoComments */); return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1)))); } function visitMethodDeclaration(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitFunctionLikeDeclaration(node)) { @@ -93297,10 +93699,10 @@ var ts; * @param node The declaration node. */ function shouldEmitAccessorDeclaration(node) { - return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */)); + return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)); } function visitGetAccessor(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitAccessorDeclaration(node)) { @@ -93313,7 +93715,7 @@ var ts; /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([])); } function visitSetAccessor(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitAccessorDeclaration(node)) { @@ -93367,7 +93769,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -93387,7 +93789,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createNamespaceExportExpression); } else { @@ -93405,7 +93807,7 @@ var ts; return updated; } function visitParenthesizedExpression(node) { - var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */); + var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* OuterExpressionKinds.Assertions */); if (ts.isAssertionExpression(innerExpression)) { // Make sure we consider all nested cast expressions, e.g.: // (-A).x; @@ -93482,7 +93884,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. @@ -93490,7 +93892,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the enum. @@ -93498,7 +93900,7 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93564,7 +93966,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* SyntaxKind.StringLiteral */ ? innerAssignment : factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -93652,12 +94054,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 305 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 305 /* SyntaxKind.SourceFile */ ? 0 /* NodeFlags.None */ : 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 260 /* EnumDeclaration */) { + if (node.kind === 260 /* SyntaxKind.EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -93682,7 +94084,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.addEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.addEmitFlags(statement, 1024 /* EmitFlags.NoTrailingComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -93692,7 +94094,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = factory.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* EmitFlags.NoComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -93713,7 +94115,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. @@ -93721,7 +94123,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the namespace. @@ -93729,7 +94131,7 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93782,7 +94184,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 262 /* ModuleBlock */) { + if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -93829,13 +94231,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 262 /* ModuleBlock */) { - ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); + if (!node.body || node.body.kind !== 262 /* SyntaxKind.ModuleBlock */) { + ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* EmitFlags.NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -93858,8 +94260,8 @@ var ts; // Elide the declaration if the import clause was elided. var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause || - compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */ + compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ ? factory.updateImportDeclaration(node, /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) : undefined; @@ -93882,14 +94284,14 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 268 /* NamespaceImport */) { + if (node.kind === 268 /* SyntaxKind.NamespaceImport */) { // Elide a namespace import if it is not referenced. return shouldEmitAliasDeclaration(node) ? node : undefined; } else { // Elide named imports if all of its import specifiers are elided and settings allow. - var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; } @@ -93930,8 +94332,8 @@ var ts; return node; } // Elide the export declaration if all of its named exports are elided. - var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause ? factory.updateExportDeclaration(node, @@ -93990,7 +94392,7 @@ var ts; if (ts.isExternalModuleImportEqualsDeclaration(node)) { var isReferenced = shouldEmitAliasDeclaration(node); // If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'. - if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) { + if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */) { return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration( /*modifiers*/ undefined, /*importClause*/ undefined, node.moduleReference.expression, @@ -94002,7 +94404,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference); - ts.setEmitFlags(moduleReference, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -94023,7 +94425,7 @@ var ts; * @param node The node to test. */ function isExportOfNamespace(node) { - return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is exported from an external module. @@ -94031,7 +94433,7 @@ var ts; * @param node The node to test. */ function isExternalModuleExport(node) { - return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is a named export from an external module. @@ -94040,7 +94442,7 @@ var ts; */ function isNamedExternalModuleExport(node) { return isExternalModuleExport(node) - && !ts.hasSyntacticModifier(node, 512 /* Default */); + && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Gets a value indicating whether the node is the default export of an external module. @@ -94049,7 +94451,7 @@ var ts; */ function isDefaultExternalModuleExport(node) { return isExternalModuleExport(node) - && ts.hasSyntacticModifier(node, 512 /* Default */); + && ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } function addExportMemberAssignment(statements, node) { var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node)); @@ -94083,27 +94485,27 @@ var ts; return factory.getGeneratedNameForNode(node); } function enableSubstitutionForNonQualifiedEnumMembers() { - if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { - enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */) === 0) { + enabledSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } function enableSubstitutionForNamespaceExports() { - if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) { - enabledSubstitutions |= 2 /* NamespaceExports */; + if ((enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) === 0) { + enabledSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(79 /* Identifier */); - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(261 /* ModuleDeclaration */); + context.enableEmitNotification(261 /* SyntaxKind.ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 261 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 260 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 260 /* SyntaxKind.EnumDeclaration */; } /** * Hook for node emit. @@ -94118,11 +94520,11 @@ var ts; if (ts.isSourceFile(node)) { currentSourceFile = node; } - if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { - applicableSubstitutions |= 2 /* NamespaceExports */; + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && isTransformedModuleDeclaration(node)) { + applicableSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; } - if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { - applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; + if (enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { + applicableSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; @@ -94136,7 +94538,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -94145,7 +94547,7 @@ var ts; return node; } function substituteShorthandPropertyAssignment(node) { - if (enabledSubstitutions & 2 /* NamespaceExports */) { + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) { var name = node.name; var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { @@ -94162,11 +94564,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -94181,9 +94583,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 305 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 261 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 260 /* EnumDeclaration */); + if (container && container.kind !== 305 /* SyntaxKind.SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && container.kind === 261 /* SyntaxKind.ModuleDeclaration */) || + (applicableSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && container.kind === 260 /* SyntaxKind.EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -94209,7 +94611,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3 /* SyntaxKind.MultiLineCommentTrivia */, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -94272,13 +94674,13 @@ var ts; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); - var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */; + var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ScriptTarget.ES2022 */; // We need to transform `this` in a static initializer into a reference to the class // when targeting < ES2022 since the assignment will be moved outside of the class body. - var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */; + var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ScriptTarget.ES2022 */; // We don't need to transform `super` property access when targeting ES5, ES3 because // the es2015 transformation handles those. - var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */; + var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ScriptTarget.ES2015 */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -94304,7 +94706,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ES2022 */) { + || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ScriptTarget.ES2022 */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -94312,50 +94714,50 @@ var ts; return visited; } function visitorWorker(node, valueIsDiscarded) { - if (node.transformFlags & 16777216 /* ContainsClassFields */) { + if (node.transformFlags & 16777216 /* TransformFlags.ContainsClassFields */) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassLike(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return visitPrivateIdentifier(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitClassStaticBlockDeclaration(node); } } - if (node.transformFlags & 16777216 /* ContainsClassFields */ || - node.transformFlags & 134217728 /* ContainsLexicalSuper */ && + if (node.transformFlags & 16777216 /* TransformFlags.ContainsClassFields */ || + node.transformFlags & 134217728 /* TransformFlags.ContainsLexicalSuper */ && shouldTransformSuperInStaticInitializers && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; currentStaticPropertyDeclarationOrStaticBlock = undefined; var result = ts.visitEachChild(node, visitor, context); @@ -94374,17 +94776,17 @@ var ts; } function heritageClauseVisitor(node) { switch (node.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return ts.visitEachChild(node, heritageClauseVisitor, context); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitExpressionWithTypeArguments(node); } return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -94414,7 +94816,7 @@ var ts; } var privId = node.left; ts.Debug.assertNode(privId, ts.isPrivateIdentifier); - ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */); + ts.Debug.assert(node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */); var info = accessPrivateIdentifier(privId); if (info) { var receiver = ts.visitNode(node.right, visitor, ts.isExpression); @@ -94430,19 +94832,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return visitor(node); @@ -94491,10 +94893,10 @@ var ts; ts.Debug.assert(ts.isPrivateIdentifier(node.name)); var info = accessPrivateIdentifier(node.name); ts.Debug.assert(info, "Undeclared private name for property declaration."); - if (info.kind === "m" /* Method */) { + if (info.kind === "m" /* PrivateIdentifierKind.Method */) { return info.methodName; } - if (info.kind === "a" /* Accessor */) { + if (info.kind === "a" /* PrivateIdentifierKind.Accessor */) { if (ts.isGetAccessor(node)) { return info.getterName; } @@ -94553,11 +94955,11 @@ var ts; function createPrivateIdentifierAccessHelper(info, receiver) { ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94576,7 +94978,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94595,7 +94997,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94609,16 +95011,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { - if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { + var operand = ts.skipParentheses(node.operand); + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) { var info = void 0; - if (info = accessPrivateIdentifier(node.operand.name)) { - var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); + if (info = accessPrivateIdentifier(operand.name)) { + var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); - expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */); + expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* SyntaxKind.EqualsToken */); ts.setOriginalNode(expression, node); ts.setTextRange(expression, node); if (temp) { @@ -94629,7 +95032,7 @@ var ts; } } else if (shouldTransformSuperInStaticInitializers && - ts.isSuperProperty(node.operand) && + ts.isSuperProperty(operand) && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { // converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)` @@ -94641,32 +95044,32 @@ var ts; // converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)` // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)` var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { - var operand = visitInvalidSuperProperty(node.operand); + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { + var expression = visitInvalidSuperProperty(operand); return ts.isPrefixUnaryExpression(node) ? - factory.updatePrefixUnaryExpression(node, operand) : - factory.updatePostfixUnaryExpression(node, operand); + factory.updatePrefixUnaryExpression(node, expression) : + factory.updatePostfixUnaryExpression(node, expression); } if (classConstructor && superClassReference) { var setterName = void 0; var getterName = void 0; - if (ts.isPropertyAccessExpression(node.operand)) { - if (ts.isIdentifier(node.operand.name)) { - getterName = setterName = factory.createStringLiteralFromNode(node.operand.name); + if (ts.isPropertyAccessExpression(operand)) { + if (ts.isIdentifier(operand.name)) { + getterName = setterName = factory.createStringLiteralFromNode(operand.name); } } else { - if (ts.isSimpleInlineableExpression(node.operand.argumentExpression)) { - getterName = setterName = node.operand.argumentExpression; + if (ts.isSimpleInlineableExpression(operand.argumentExpression)) { + getterName = setterName = operand.argumentExpression; } else { getterName = factory.createTempVariable(hoistVariableDeclaration); - setterName = factory.createAssignment(getterName, ts.visitNode(node.operand.argumentExpression, visitor, ts.isExpression)); + setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression)); } } if (setterName && getterName) { var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor); - ts.setTextRange(expression, node.operand); + ts.setTextRange(expression, operand); var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor); @@ -94757,7 +95160,7 @@ var ts; var iife = factory.createImmediatelyInvokedArrowFunction(statements); ts.setOriginalNode(iife, node); ts.setTextRange(iife, node); - ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(iife, 2 /* EmitFlags.AdviseOnEmitNode */); return iife; } } @@ -94784,7 +95187,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); } if (classConstructor && superClassReference) { @@ -94826,7 +95229,7 @@ var ts; } } } - if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) { + if (node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { return visitPrivateIdentifierInInExpression(node); } return ts.visitEachChild(node, visitor, context); @@ -94841,12 +95244,12 @@ var ts; } ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, /* f */ undefined); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94886,28 +95289,28 @@ var ts; return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function getClassFacts(node) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; var original = ts.getOriginalNode(node); if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) { - facts |= 1 /* ClassWasDecorated */; + facts |= 1 /* ClassFacts.ClassWasDecorated */; } for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (!ts.isStatic(member)) continue; if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) { - facts |= 2 /* NeedsClassConstructorReference */; + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { - if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) { - facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */; - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */; + if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */) { + facts |= 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */; + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } } - if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) { - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */; + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* TransformFlags.ContainsLexicalSuper */) { + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */ | 4 /* ClassFacts.NeedsClassSuperReference */; } } } @@ -94915,8 +95318,8 @@ var ts; return facts; } function visitExpressionWithTypeArguments(node) { - var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */; - if (facts & 4 /* NeedsClassSuperReference */) { + var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* ClassFacts.None */; + if (facts & 4 /* ClassFacts.NeedsClassSuperReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true); getClassLexicalEnvironment().superClassReference = temp; return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)), @@ -94929,19 +95332,19 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If a class has private static fields, or a static field has a `this` or `super` reference, // then we need to allocate a temp variable to hold on to that reference. var pendingClassReferenceAssignment; - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node)); } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); var statements = [ factory.updateClassDeclaration(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) @@ -94969,7 +95372,7 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If this class expression is a transformation of a decorated class declaration, @@ -94979,19 +95382,19 @@ var ts; // In this case, we use pendingStatements to produce the same output as the // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. - var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */); + var isDecoratedClassDeclaration = !!(facts & 1 /* ClassFacts.ClassWasDecorated */); var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; var temp; function createClassTempVar() { var classCheckFlags = resolver.getNodeCheckFlags(node); - var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; - var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + var isClassWithConstructorReference = classCheckFlags & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); } - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { temp = createClassTempVar(); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } @@ -95020,12 +95423,12 @@ var ts; // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); var alias = factory.cloneNode(temp); - alias.autoGenerateFlags &= ~8 /* ReservedInNestedScopes */; + alias.autoGenerateFlags &= ~8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; classAliases[ts.getOriginalNodeId(node)] = alias; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* EmitFlags.Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression))); // Add any pending expressions leftover from elided or relocated computed property names ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine)); @@ -95078,13 +95481,13 @@ var ts; /*typeArguments*/ undefined, []))); } function isClassElementThatRequiresConstructorStatement(member) { - if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* ModifierFlags.Abstract */)) { return false; } if (useDefineForClassFields) { // If we are using define semantics and targeting ESNext or higher, // then we don't need to transform any class properties. - return languageVersion < 9 /* ES2022 */; + return languageVersion < 9 /* ScriptTarget.ES2022 */; } return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member); } @@ -95273,7 +95676,7 @@ var ts; if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) { // capture the lexical environment for the member ts.setOriginalNode(transformed, property); - ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(transformed, 2 /* EmitFlags.AdviseOnEmitNode */); classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment); } currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; @@ -95292,7 +95695,7 @@ var ts; if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - if (privateIdentifierInfo.kind === "f" /* Field */) { + if (privateIdentifierInfo.kind === "f" /* PrivateIdentifierKind.Field */) { if (!privateIdentifierInfo.isStatic) { return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); } @@ -95312,7 +95715,7 @@ var ts; return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); - if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* ModifierFlags.Abstract */)) { return undefined; } var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero() @@ -95331,32 +95734,32 @@ var ts; } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* ClassPropertySubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForClassStaticThisOrSuperReference() { - if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) { - enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */; + if ((enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */) === 0) { + enabledSubstitutions |= 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */; // substitute `this` in a static field initializer - context.enableSubstitution(108 /* ThisKeyword */); + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); // these push a new lexical environment that is not the class lexical environment - context.enableEmitNotification(256 /* FunctionDeclaration */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // these push a new lexical environment that is not the class lexical environment, except // when they have a computed property name - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(167 /* PropertyDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(167 /* SyntaxKind.PropertyDeclaration */); // class lexical environments are restored when entering a computed property name - context.enableEmitNotification(162 /* ComputedPropertyName */); + context.enableEmitNotification(162 /* SyntaxKind.ComputedPropertyName */); } } /** @@ -95395,13 +95798,13 @@ var ts; } } switch (node.kind) { - case 213 /* FunctionExpression */: - if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { + case 213 /* SyntaxKind.FunctionExpression */: + if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */) { break; } // falls through - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = undefined; @@ -95411,10 +95814,10 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; @@ -95424,7 +95827,7 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 162 /* ComputedPropertyName */: { + case 162 /* SyntaxKind.ComputedPropertyName */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; @@ -95445,24 +95848,24 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisExpression(node); } return node; } function substituteThisExpression(node) { - if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { + if (enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.createParenthesizedExpression(factory.createVoidZero()); } if (classConstructor) { @@ -95475,8 +95878,8 @@ var ts; return trySubstituteClassAlias(node) || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -95509,7 +95912,7 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(generatedName); } else { @@ -95529,7 +95932,7 @@ var ts; } function getClassLexicalEnvironment() { return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = { - facts: 0 /* None */, + facts: 0 /* ClassFacts.None */, classConstructor: undefined, superClassReference: undefined, privateIdentifierEnvironment: undefined, @@ -95562,7 +95965,7 @@ var ts; if (ts.isPropertyDeclaration(node)) { var variableName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, variableName: variableName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95572,7 +95975,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { var functionName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: functionName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95581,12 +95984,12 @@ var ts; } else if (ts.isGetAccessorDeclaration(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: classConstructor, @@ -95597,12 +96000,12 @@ var ts; } else if (ts.isSetAccessorDeclaration(node)) { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: classConstructor, @@ -95618,7 +96021,7 @@ var ts; else if (ts.isPropertyDeclaration(node)) { var weakMapName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, brandCheckIdentifier: weakMapName, isStatic: false, variableName: undefined, @@ -95630,7 +96033,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: createHoistedVariableForPrivateName(text, node), brandCheckIdentifier: weakSetName, isStatic: false, @@ -95641,12 +96044,12 @@ var ts; ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); if (ts.isGetAccessor(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: weakSetName, @@ -95657,12 +96060,12 @@ var ts; } else { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: weakSetName, @@ -95679,9 +96082,9 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16 /* Optimistic */); - if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) { + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */); + if (resolver.getNodeCheckFlags(node) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(identifier); } else { @@ -95723,9 +96126,9 @@ var ts; // differently inside the function. if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); } - return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */)); + return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* SyntaxKind.EqualsToken */)); } function visitArrayAssignmentTarget(node) { var target = ts.getTargetOfBindingOrAssignmentElement(node); @@ -95739,7 +96142,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95779,7 +96182,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95887,15 +96290,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: return serializeTypeNode(node.type); - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createIdentifier("Function"); default: return ts.factory.createVoidZero(); @@ -95931,7 +96334,7 @@ var ts; return ts.factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 172 /* GetAccessor */) { + if (container && node.kind === 172 /* SyntaxKind.GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -95976,67 +96379,67 @@ var ts; } node = ts.skipTypeParentheses(node); switch (node.kind) { - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return ts.factory.createVoidZero(); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return ts.factory.createIdentifier("Function"); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return ts.factory.createIdentifier("Array"); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? ts.factory.createVoidZero() : ts.factory.createIdentifier("Boolean"); - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return ts.factory.createIdentifier("Boolean"); - case 198 /* TemplateLiteralType */: - case 150 /* StringKeyword */: + case 198 /* SyntaxKind.TemplateLiteralType */: + case 150 /* SyntaxKind.StringKeyword */: return ts.factory.createIdentifier("String"); - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return ts.factory.createIdentifier("Object"); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return serializeLiteralOfLiteralTypeNode(node.literal); - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return ts.factory.createIdentifier("Number"); - case 158 /* BigIntKeyword */: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); - case 151 /* SymbolKeyword */: - return getGlobalConstructor("Symbol", 2 /* ES2015 */); - case 178 /* TypeReference */: + case 158 /* SyntaxKind.BigIntKeyword */: + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); + case 151 /* SyntaxKind.SymbolKeyword */: + return getGlobalConstructor("Symbol", 2 /* ScriptTarget.ES2015 */); + case 178 /* SyntaxKind.TypeReference */: return serializeTypeReferenceNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ true); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ false); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], /*isIntersection*/ false); - case 193 /* TypeOperator */: - if (node.operator === 145 /* ReadonlyKeyword */) { + case 193 /* SyntaxKind.TypeOperator */: + if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 181 /* TypeQuery */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 182 /* TypeLiteral */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 192 /* ThisType */: - case 200 /* ImportType */: + case 181 /* SyntaxKind.TypeQuery */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 200 /* SyntaxKind.ImportType */: break; // handle JSDoc types from an invalid parse - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 317 /* JSDocFunctionType */: - case 318 /* JSDocVariadicType */: - case 319 /* JSDocNamepathType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 318 /* SyntaxKind.JSDocVariadicType */: + case 319 /* SyntaxKind.JSDocNamepathType */: break; - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 316 /* JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -96045,27 +96448,27 @@ var ts; } function serializeLiteralOfLiteralTypeNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.factory.createIdentifier("String"); - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; switch (operand.kind) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return serializeLiteralOfLiteralTypeNode(operand); default: return ts.Debug.failBadSyntaxKind(operand); } } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.factory.createIdentifier("Number"); - case 9 /* BigIntLiteral */: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 9 /* SyntaxKind.BigIntLiteral */: + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return ts.factory.createIdentifier("Boolean"); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return ts.factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node); @@ -96077,20 +96480,20 @@ var ts; for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { var typeNode = types_22[_i]; typeNode = ts.skipTypeParentheses(typeNode); - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { if (isIntersection) return ts.factory.createVoidZero(); // Reduce to `never` in an intersection continue; // Elide `never` in a union } - if (typeNode.kind === 155 /* UnknownKeyword */) { + if (typeNode.kind === 155 /* SyntaxKind.UnknownKeyword */) { if (!isIntersection) return ts.factory.createIdentifier("Object"); // Reduce to `unknown` in a union continue; // Elide `unknown` in an intersection } - if (typeNode.kind === 130 /* AnyKeyword */) { + if (typeNode.kind === 130 /* SyntaxKind.AnyKeyword */) { return ts.factory.createIdentifier("Object"); // Reduce to `any` in a union or intersection } - if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */) || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */) || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedConstituent = serializeTypeNode(typeNode); @@ -96171,7 +96574,7 @@ var ts; case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: return ts.factory.createVoidZero(); case ts.TypeReferenceSerializationKind.BigIntLikeType: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); case ts.TypeReferenceSerializationKind.BooleanType: return ts.factory.createIdentifier("Boolean"); case ts.TypeReferenceSerializationKind.NumberLikeType: @@ -96181,7 +96584,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return ts.factory.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return getGlobalConstructor("Symbol", 2 /* ES2015 */); + return getGlobalConstructor("Symbol", 2 /* ScriptTarget.ES2015 */); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: return ts.factory.createIdentifier("Function"); case ts.TypeReferenceSerializationKind.Promise: @@ -96211,12 +96614,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { // A -> typeof A !== "undefined" && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 79 /* Identifier */) { + if (node.left.kind === 79 /* SyntaxKind.Identifier */) { // A.B -> typeof A !== "undefined" && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -96231,14 +96634,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -96289,28 +96692,28 @@ var ts; return ts.isDecorator(node) ? undefined : node; } function visitor(node) { - if (!(node.transformFlags & 33554432 /* ContainsDecorators */)) { + if (!(node.transformFlags & 33554432 /* TransformFlags.ContainsDecorators */)) { return node; } switch (node.kind) { - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are elided. They will be emitted as part of `visitClassDeclaration`. return undefined; - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructorDeclaration(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitSetAccessorDeclaration(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return visitGetAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameterDeclaration(node); default: return ts.visitEachChild(node, visitor, context); @@ -96319,39 +96722,72 @@ var ts; function visitClassDeclaration(node) { if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node))) return ts.visitEachChild(node, visitor, context); - var classStatement = ts.hasDecorators(node) ? - createClassDeclarationHeadWithDecorators(node, node.name) : - createClassDeclarationHeadWithoutDecorators(node, node.name); - var statements = [classStatement]; - // Write any decorators of the node. - addClassElementDecorationStatements(statements, node, /*isStatic*/ false); - addClassElementDecorationStatements(statements, node, /*isStatic*/ true); - addConstructorDecorationStatement(statements, node); + var statements = ts.hasDecorators(node) ? + transformClassDeclarationWithClassDecorators(node, node.name) : + transformClassDeclarationWithoutClassDecorators(node, node.name); if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } + function decoratorContainsPrivateIdentifierInExpression(decorator) { + return !!(decorator.transformFlags & 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); + } + function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) { + return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression); + } + function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (!ts.canHaveDecorators(member)) + continue; + var allDecorators = ts.getAllDecoratorsOfClassElement(member, node); + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression)) + return true; + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression)) + return true; + } + return false; + } + function transformDecoratorsOfClassElements(node, members) { + var decorationStatements = []; + addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ false); + addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ true); + if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) { + members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [ + factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, /*multiLine*/ true)) + ], false)), members); + decorationStatements = undefined; + } + return { decorationStatements: decorationStatements, members: members }; + } /** * Transforms a non-decorated class declaration. * * @param node A ClassDeclaration node. * @param name The name of the class. */ - function createClassDeclarationHeadWithoutDecorators(node, name) { + function transformClassDeclarationWithoutClassDecorators(node, name) { // ${modifiers} class ${name} ${heritageClauses} { // ${members} // } - return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement)); + var _a; + var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = ts.visitNodes(node.members, visitor, ts.isClassElement); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var updated = factory.updateClassDeclaration(node, modifiers, name, + /*typeParameters*/ undefined, heritageClauses, members); + return ts.addRange([updated], decorationStatements); } /** * Transforms a decorated class declaration and appends the resulting statements. If * the class requires an alias to avoid issues with double-binding, the alias is returned. */ - function createClassDeclarationHeadWithDecorators(node, name) { + function transformClassDeclarationWithClassDecorators(node, name) { // When we emit an ES6 class that has a class decorator, we must tailor the // emit to certain specific cases. // @@ -96437,11 +96873,12 @@ var ts; // | var C_1; // --------------------------------------------------------------------- // + var _a; var location = ts.moveRangePastModifiers(node); var classAlias = getClassAliasIfNeeded(node); // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var declName = languageVersion <= 2 /* ES2015 */ ? + var declName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { @@ -96449,7 +96886,11 @@ var ts; // } var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = ts.visitNodes(node.members, visitor, ts.isClassElement); - var classExpression = factory.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var classExpression = factory.createClassExpression( + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); ts.setTextRange(classExpression, location); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference @@ -96459,11 +96900,14 @@ var ts; factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) - ], 1 /* Let */)); + ], 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); ts.setTextRange(statement, location); ts.setCommentRange(statement, node); - return statement; + var statements = [statement]; + ts.addRange(statements, decorationStatements); + addConstructorDecorationStatement(statements, node); + return statements; } function visitClassExpression(node) { // Legacy decorators were not supported on class expressions @@ -96496,7 +96940,7 @@ var ts; return finishClassElement(factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock)), node); } function visitPropertyDeclaration(node) { - if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { return undefined; } return finishClassElement(factory.updatePropertyDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), @@ -96513,7 +96957,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -96623,9 +97067,9 @@ var ts; // ], C.prototype, "prop"); // var prefix = getClassMemberPrefix(node, member); - var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */)); - var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 167 /* PropertyDeclaration */ + var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* ModifierFlags.Ambient */)); + var descriptor = languageVersion > 0 /* ScriptTarget.ES3 */ + ? member.kind === 167 /* SyntaxKind.PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -96634,7 +97078,7 @@ var ts; : factory.createNull() : undefined; var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member)); return helper; } @@ -96663,12 +97107,12 @@ var ts; var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var localName = languageVersion <= 2 /* ES2015 */ ? + var localName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 1536 /* NoComments */); + ts.setEmitFlags(expression, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node)); return expression; } @@ -96694,7 +97138,7 @@ var ts; var decorator = decorators_1[_i]; var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); ts.setTextRange(helper, decorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); expressions.push(helper); } } @@ -96727,7 +97171,7 @@ var ts; if (!classAliases) { // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } @@ -96738,7 +97182,7 @@ var ts; * double-binding semantics for the class name. */ function getClassAliasIfNeeded(node) { - if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) { + if (resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; @@ -96762,14 +97206,14 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -96780,7 +97224,7 @@ var ts; } function trySubstituteClassAlias(node) { if (classAliases) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -96852,8 +97296,8 @@ var ts; if (node.isDeclarationFile) { return node; } - setContextFlag(1 /* NonTopLevel */, false); - setContextFlag(2 /* HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); + setContextFlag(1 /* ContextFlags.NonTopLevel */, false); + setContextFlag(2 /* ContextFlags.HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -96865,10 +97309,10 @@ var ts; return (contextFlags & flags) !== 0; } function inTopLevelContext() { - return !inContext(1 /* NonTopLevel */); + return !inContext(1 /* ContextFlags.NonTopLevel */); } function inHasLexicalThisContext() { - return inContext(2 /* HasLexicalThis */); + return inContext(2 /* ContextFlags.HasLexicalThis */); } function doWithContext(flags, cb, value) { var contextFlagsToSet = flags & ~contextFlags; @@ -96884,39 +97328,39 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 256 /* TransformFlags.ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 169 /* MethodDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 256 /* FunctionDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 213 /* FunctionExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 214 /* ArrowFunction */: - return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitMethodDeclaration, node); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionDeclaration, node); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionExpression, node); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithContext(1 /* ContextFlags.NonTopLevel */, visitArrowFunction, node); + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -96924,27 +97368,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatementInAsyncBody(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatementInAsyncBody(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClauseInAsyncBody(node); - case 235 /* Block */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 248 /* WithStatement */: - case 250 /* LabeledStatement */: + case 235 /* SyntaxKind.Block */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -97026,7 +97470,7 @@ var ts; return factory.updateMethodDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97041,7 +97485,7 @@ var ts; function visitFunctionDeclaration(node) { return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97056,7 +97500,7 @@ var ts; function visitFunctionExpression(node) { return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97071,7 +97515,7 @@ var ts; function visitArrowFunction(node) { return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97092,7 +97536,7 @@ var ts; function isVariableDeclarationListWithCollidingName(node) { return !!node && ts.isVariableDeclarationList(node) - && !(node.flags & 3 /* BlockScoped */) + && !(node.flags & 3 /* NodeFlags.BlockScoped */) && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { @@ -97146,9 +97590,9 @@ var ts; resumeLexicalEnvironment(); var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 214 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + var promiseConstructor = languageVersion < 2 /* ScriptTarget.ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 214 /* SyntaxKind.ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* NodeCheckFlags.CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -97174,7 +97618,7 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); if (capturedSuperProperties.size) { @@ -97187,10 +97631,10 @@ var ts; ts.setTextRange(block, node.body); if (emitSuperHelpers && hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -97234,21 +97678,21 @@ var ts; return undefined; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -97261,8 +97705,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -97289,30 +97733,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -97332,19 +97776,19 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), location); } } @@ -97354,7 +97798,7 @@ var ts; function createSuperAccessVariableStatement(factory, resolver, node, names) { // Create a variable declaration with a getter/setter (if binding) definition for each name: // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... }); - var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) !== 0; + var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0; var accessors = []; names.forEach(function (_, key) { var name = ts.unescapeLeadingUnderscores(key); @@ -97364,7 +97808,7 @@ var ts; /* typeParameters */ undefined, /* parameters */ [], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */)))); + /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */)))); if (hasBinding) { getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction( /* modifiers */ undefined, @@ -97378,20 +97822,20 @@ var ts; /* initializer */ undefined) ], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */), factory.createIdentifier("v"))))); + /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v"))))); } accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter))); }); return factory.createVariableStatement( /* modifiers */ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), /* typeArguments */ undefined, [ factory.createNull(), factory.createObjectLiteralExpression(accessors, /* multiline */ true) ])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; })(ts || (ts = {})); @@ -97461,7 +97905,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -97493,7 +97937,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 131 /* AsyncKeyword */) { + if (node.kind === 131 /* SyntaxKind.AsyncKeyword */) { return undefined; } return node; @@ -97515,88 +97959,88 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 244 /* ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + return doWithHierarchyFacts(visitDefault, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: - return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 217 /* VoidExpression */: + case 242 /* SyntaxKind.ForStatement */: + return doWithHierarchyFacts(visitForStatement, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); - case 171 /* Constructor */: - return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 169 /* MethodDeclaration */: - return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 172 /* GetAccessor */: - return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 173 /* SetAccessor */: - return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 256 /* FunctionDeclaration */: - return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 213 /* FunctionExpression */: - return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 214 /* ArrowFunction */: - return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 164 /* Parameter */: + case 171 /* SyntaxKind.Constructor */: + return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 172 /* SyntaxKind.GetAccessor */: + return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 173 /* SyntaxKind.SetAccessor */: + return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithHierarchyFacts(visitArrowFunction, node, 2 /* HierarchyFacts.ArrowFunctionExcludes */, 0 /* HierarchyFacts.ArrowFunctionIncludes */); + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithHierarchyFacts(visitDefault, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); } function visitYieldExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { if (node.asteriskToken) { var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression); return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression( @@ -97610,15 +98054,15 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitReturnStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero())); } return ts.visitEachChild(node, visitor, context); } function visitLabeledStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 244 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 244 /* SyntaxKind.ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -97630,7 +98074,7 @@ var ts; var objects = []; for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { var e = elements_5[_i]; - if (e.kind === 298 /* SpreadAssignment */) { + if (e.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -97639,7 +98083,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 296 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 296 /* SyntaxKind.PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -97650,7 +98094,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { // spread elements emit like so: // non-spread elements are chunked together into object literals, and then all are passed to __assign: // { a, ...o, b } => __assign(__assign({a}, o), {b}); @@ -97673,7 +98117,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 205 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -97700,9 +98144,9 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* HierarchyFacts.SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? + 0 /* HierarchyFacts.StrictModeSourceFileIncludes */ : + 1 /* HierarchyFacts.SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -97723,10 +98167,10 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -97754,10 +98198,10 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name); - var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); + var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* FlattenLevel.ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { block = factory.updateBlock(block, __spreadArray([ @@ -97769,7 +98213,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; var visited = ts.visitEachChild(node, visitor, context); @@ -97795,8 +98239,8 @@ var ts; } function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); @@ -97813,8 +98257,8 @@ var ts; * @param node A ForOfStatement. */ function visitForOfStatement(node, outermostLabeledStatement) { - var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + if (node.initializer.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -97842,7 +98286,7 @@ var ts; } return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), + ], 1 /* NodeFlags.Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), /*multiLine*/ true), bodyLocation)); } return node; @@ -97862,10 +98306,10 @@ var ts; statements.push(statement); } return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), - /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function createDownlevelAwait(expression) { - return enclosingFunctionFlags & 1 /* Generator */ + return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(expression)) : factory.createAwaitExpression(expression); } @@ -97884,18 +98328,18 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 2 /* IterationContainer */ ? + var initializer = ancestorFacts & 2 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) : callValues; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), /*incrementor*/ undefined, /*statement*/ convertForOfStatementHead(node, getValue)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setOriginalNode(forStatement, node); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -97903,15 +98347,15 @@ var ts; factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } function parameterVisitor(node) { @@ -97926,7 +98370,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -97943,7 +98387,7 @@ var ts; if (parameters) { parameters.add(parameter); } - else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { parameters = new ts.Set(); } } @@ -97985,13 +98429,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateMethodDeclaration(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateMethodDeclaration(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifierLike) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98003,13 +98447,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionDeclaration(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionDeclaration(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98033,13 +98477,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98056,13 +98500,13 @@ var ts; capturedSuperProperties = new ts.Set(); hasSuperElementAccess = false; var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */))); + /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */))); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties); @@ -98073,10 +98517,10 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.updateBlock(node.body, statements); if (emitSuperHelpers && hasSuperElementAccess) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -98115,11 +98559,11 @@ var ts; // // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts if (parameter.name.elements.length > 0) { - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)); + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98128,7 +98572,7 @@ var ts; var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); var assignment = factory.createAssignment(name, initializer); var statement = factory.createExpressionStatement(assignment); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98144,32 +98588,32 @@ var ts; // } var name = factory.cloneNode(parameter.name); ts.setTextRange(name, parameter.name); - ts.setEmitFlags(name, 48 /* NoSourceMap */); + ts.setEmitFlags(name, 48 /* EmitFlags.NoSourceMap */); var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); - ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */); + ts.addEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | 1536 /* EmitFlags.NoComments */); var assignment = factory.createAssignment(name, initializer); ts.setTextRange(assignment, parameter); - ts.setEmitFlags(assignment, 1536 /* NoComments */); + ts.setEmitFlags(assignment, 1536 /* EmitFlags.NoComments */); var block = factory.createBlock([factory.createExpressionStatement(assignment)]); ts.setTextRange(block, parameter); - ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined"); var statement = factory.createIfStatement(typeCheck, block); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); statements = ts.append(statements, statement); } } - else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { containsPrecedingObjectRestOrSpread = true; - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter), + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* FlattenLevel.ObjectRest */, factory.getGeneratedNameForNode(parameter), /*doNotRecordTempVariablesInLine*/ false, /*skipInitializer*/ true); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98177,21 +98621,21 @@ var ts; return statements; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -98204,8 +98648,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -98232,30 +98676,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -98275,14 +98719,14 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } @@ -98307,11 +98751,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 64 /* TransformFlags.ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -98339,29 +98783,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 32 /* TransformFlags.ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 221 /* BinaryExpression */: - if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98403,7 +98847,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 206 /* PropertyAccessExpression */ + expression = node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -98426,10 +98870,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 208 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 208 /* SyntaxKind.CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -98438,7 +98882,7 @@ var ts; var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false); var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left; - var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */); + var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); if (!ts.isSimpleCopiableExpression(capturedLeft)) { capturedLeft = factory.createTempVariable(hoistVariableDeclaration); leftExpression = factory.createAssignment(capturedLeft, leftExpression); @@ -98448,8 +98892,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -98459,17 +98903,17 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 206 /* PropertyAccessExpression */ + rightExpression = segment.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (i === 0 && leftThisArg) { if (!ts.isGeneratedIdentifier(leftThisArg)) { leftThisArg = factory.cloneNode(leftThisArg); - ts.addEmitFlags(leftThisArg, 1536 /* NoComments */); + ts.addEmitFlags(leftThisArg, 1536 /* EmitFlags.NoComments */); } - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SyntaxKind.SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -98486,7 +98930,7 @@ var ts; return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target; } function createNotNullCondition(left, right, invert) { - return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* BarBarToken */ : 55 /* AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createVoidZero())); + return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* SyntaxKind.BarBarToken */ : 55 /* SyntaxKind.AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createVoidZero())); } function transformNullishCoalescingExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -98520,11 +98964,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) { + if ((node.transformFlags & 16 /* TransformFlags.ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -98574,7 +99018,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 4 /* TransformFlags.ContainsESNext */) === 0) { return node; } switch (node.kind) { @@ -98598,12 +99042,12 @@ var ts; if (currentFileState.filenameDeclaration) { return currentFileState.filenameDeclaration.name; } - var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); + var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); currentFileState.filenameDeclaration = declaration; return currentFileState.filenameDeclaration.name; } function getJsxFactoryCalleePrimitive(isStaticChildren) { - return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; + return compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; } function getJsxFactoryCallee(isStaticChildren) { var type = getJsxFactoryCalleePrimitive(isStaticChildren); @@ -98629,7 +99073,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); + var generatedName = factory.createUniqueName("_".concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */ | 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */); var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -98651,7 +99095,7 @@ var ts; ts.addEmitHelpers(visited, context.readEmitHelpers()); var statements = visited.statements; if (currentFileState.filenameDeclaration) { - statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */))); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* NodeFlags.Const */))); } if (currentFileState.utilizedImplicitRuntimeImports) { for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { @@ -98668,7 +99112,7 @@ var ts; factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); ts.setParentRecursive(requireStatement, /*incremental*/ false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement); } @@ -98684,7 +99128,7 @@ var ts; return visited; } function visitor(node) { - if (node.transformFlags & 2 /* ContainsJsx */) { + if (node.transformFlags & 2 /* TransformFlags.ContainsJsx */) { return visitorWorker(node); } else { @@ -98693,13 +99137,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98707,15 +99151,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return visitJsxText(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -98784,7 +99228,7 @@ var ts; if (keyAttr) { args.push(transformJsxAttributeInitializer(keyAttr.initializer)); } - if (compilerOptions.jsx === 5 /* ReactJSXDev */) { + if (compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */) { var originalFile = ts.getOriginalNode(currentSourceFile); if (originalFile && ts.isSourceFile(originalFile)) { // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature @@ -98849,7 +99293,7 @@ var ts; } function transformJsxAttributesToObjectProps(attrs, children) { var target = ts.getEmitScriptTarget(compilerOptions); - return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : + return target && target >= 5 /* ScriptTarget.ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : transformJsxAttributesToExpression(attrs, children); } function transformJsxAttributesToProps(attrs, children) { @@ -98889,14 +99333,14 @@ var ts; if (node === undefined) { return factory.createTrue(); } - if (node.kind === 10 /* StringLiteral */) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */) { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - if (node.kind === 288 /* JsxExpression */) { + if (node.kind === 288 /* SyntaxKind.JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -98997,7 +99441,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 278 /* JsxElement */) { + if (node.kind === 278 /* SyntaxKind.JsxElement */) { return getTagName(node.openingElement); } else { @@ -99300,11 +99744,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 512 /* TransformFlags.ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -99312,9 +99756,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 67 /* AsteriskAsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -99504,7 +99948,7 @@ var ts; currentSourceFile = undefined; currentText = undefined; taggedTemplateStringDeclarations = undefined; - hierarchyFacts = 0 /* None */; + hierarchyFacts = 0 /* HierarchyFacts.None */; return visited; } /** @@ -99514,7 +99958,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -99525,15 +99969,15 @@ var ts; * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* HierarchyFacts.SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 247 /* ReturnStatement */ + return (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */) !== 0 + && node.kind === 247 /* SyntaxKind.ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -99548,11 +99992,11 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 1024 /* TransformFlags.ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) + || (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) - || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; + || (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) !== 0; } function visitor(node) { return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node; @@ -99564,9 +100008,9 @@ var ts; if (shouldVisitNode(node)) { var original = ts.getOriginalNode(node); if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) { - var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.StaticInitializerExcludes */, 16449 /* HierarchyFacts.StaticInitializerIncludes */); var result = visitorWorker(node, /*expressionResultIsUnused*/ false); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); return result; } return visitorWorker(node, /*expressionResultIsUnused*/ false); @@ -99574,115 +100018,115 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return undefined; // elide static keyword - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitArrowFunction(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return visitIdentifier(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitVariableDeclarationList(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitBreakOrContinueStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return visitTemplateLiteral(node); - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return visitStringLiteral(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return visitNumericLiteral(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitSpreadElement(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return visitThisKeyword(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitMetaProperty(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(8064 /* HierarchyFacts.SourceFileExcludes */, 64 /* HierarchyFacts.SourceFileIncludes */); var prologue = []; var statements = []; startLexicalEnvironment(); @@ -99693,14 +100137,14 @@ var ts; } factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureThisForNodeIfNeeded(prologue, node); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + convertedLoopState.allowedNonLabeledJumps |= 2 /* Jump.Break */; var result = ts.visitEachChild(node, visitor, context); convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; return result; @@ -99708,17 +100152,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCaseBlock(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function returnCapturedThis(node) { - return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)), node); } function visitReturnStatement(node) { if (convertedLoopState) { - convertedLoopState.nonLocalJumps |= 8 /* Return */; + convertedLoopState.nonLocalJumps |= 8 /* Jump.Return */; if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { node = returnCapturedThis(node); } @@ -99734,11 +100178,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } if (convertedLoopState) { - if (hierarchyFacts & 2 /* ArrowFunction */) { + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */) { // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -99765,30 +100209,30 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 246 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 246 /* SyntaxKind.BreakStatement */ ? 2 /* Jump.Break */ : 4 /* Jump.Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 246 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Jump.Break */; labelMarker = "break"; } else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; + convertedLoopState.nonLocalJumps |= 4 /* Jump.Continue */; // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. labelMarker = "continue"; } } else { - if (node.kind === 246 /* BreakStatement */) { - labelMarker = "break-" + label.escapedText; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } @@ -99797,15 +100241,15 @@ var ts; var outParams = convertedLoopState.loopOutParameters; var expr = void 0; for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + var copyExpr = copyOutParameter(outParams[i], 1 /* CopyDirection.ToOutParameter */); if (i === 0) { expr = copyExpr; } else { - expr = factory.createBinaryExpression(expr, 27 /* CommaToken */, copyExpr); + expr = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, copyExpr); } } - returnExpression = factory.createBinaryExpression(expr, 27 /* CommaToken */, returnExpression); + returnExpression = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, returnExpression); } return factory.createReturnStatement(returnExpression); } @@ -99838,18 +100282,18 @@ var ts; ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - var exportStatement = ts.hasSyntacticModifier(node, 512 /* Default */) + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + var exportStatement = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? factory.createExportDefault(factory.getLocalName(node)) : factory.createExternalModuleExport(factory.getLocalName(node)); ts.setOriginalNode(exportStatement, statement); statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -99906,25 +100350,25 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */))] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* Indented */) | 524288 /* ReuseTempVariableScope */); + ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */) | 524288 /* EmitFlags.ReuseTempVariableScope */); // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = factory.createPartiallyEmittedExpression(classFunction); ts.setTextRangeEnd(inner, node.end); - ts.setEmitFlags(inner, 1536 /* NoComments */); + ts.setEmitFlags(inner, 1536 /* EmitFlags.NoComments */); var outer = factory.createPartiallyEmittedExpression(inner); ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos)); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); - ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + ts.addSyntheticLeadingComment(result, 3 /* SyntaxKind.MultiLineCommentTrivia */, "* @class "); return result; } /** @@ -99942,19 +100386,19 @@ var ts; addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(constructorLikeName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -99980,7 +100424,7 @@ var ts; function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); + var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = factory.createFunctionDeclaration( @@ -99990,10 +100434,10 @@ var ts; /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); + ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; } /** @@ -100027,7 +100471,7 @@ var ts; ts.setTextRange(statementsArray, node.members); var block = factory.createBlock(statementsArray, /*multiLine*/ true); ts.setTextRange(block, node); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -100042,7 +100486,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -100086,7 +100530,7 @@ var ts; superCallExpression = visitSuperCallInBody(superCall); } if (superCallExpression) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + hierarchyFacts |= 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */; } // Add parameter defaults at the beginning of the output, with prologue statements addDefaultValueAssignmentsIfNeeded(prologue, constructor); @@ -100096,7 +100540,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) { + if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -100119,7 +100563,7 @@ var ts; var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1)); - ts.setEmitFlags(superCall_1, 1536 /* NoComments */); + ts.setEmitFlags(superCall_1, 1536 /* EmitFlags.NoComments */); statements.push(returnStatement); } else { @@ -100158,7 +100602,7 @@ var ts; } } if (!isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))); } } } @@ -100208,11 +100652,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 247 /* ReturnStatement */) { + if (statement.kind === 247 /* SyntaxKind.ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 239 /* IfStatement */) { + else if (statement.kind === 239 /* SyntaxKind.IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -100220,7 +100664,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 235 /* Block */) { + else if (statement.kind === 235 /* SyntaxKind.Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -100229,10 +100673,10 @@ var ts; return false; } function createActualThis() { - return ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */); + return ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */); } function createDefaultSuperCallOrThis() { - return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); + return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -100319,11 +100763,11 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } else if (initializer) { - ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } return false; @@ -100341,11 +100785,11 @@ var ts; var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment( // TODO(rbuckton): Does this need to be parented? - ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); + ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); ts.insertStatementAfterCustomPrologue(statements, statement); } /** @@ -100376,10 +100820,10 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. // TODO(rbuckton): Does this need to be parented? - var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); - ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); + var declarationName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + ts.setEmitFlags(declarationName, 48 /* EmitFlags.NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -100389,7 +100833,7 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, factory.createArrayLiteralExpression([])) ])), - /*location*/ parameter), 1048576 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* EmitFlags.CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -100401,13 +100845,13 @@ var ts; : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* EmitFlags.CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 79 /* Identifier */) { + if (parameter.name.kind !== 79 /* SyntaxKind.Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, expressionName))), parameter), 1048576 /* EmitFlags.CustomPrologue */)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; @@ -100420,7 +100864,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 214 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* HierarchyFacts.CapturedLexicalThis */ && node.kind !== 214 /* SyntaxKind.ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -100434,7 +100878,7 @@ var ts; */ function insertSuperThisCaptureThisForNode(statements, superExpression) { enableSubstitutionsForCapturedThis(); - var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression)); + var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* SyntaxKind.EqualsToken */, superExpression)); ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression); ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent); } @@ -100442,38 +100886,38 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); ts.setSourceMapRange(captureThisStatement, node); ts.insertStatementAfterCustomPrologue(statements, captureThisStatement); } function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { - if (hierarchyFacts & 32768 /* NewTarget */) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return statements; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. - newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); + newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), - /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"), + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), 102 /* SyntaxKind.InstanceOfKeyword */, factory.getLocalName(node))), + /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"), /*colonToken*/ undefined, factory.createVoidZero()); break; default: @@ -100481,11 +100925,11 @@ var ts; } var captureNewTargetStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, newTarget) ])); - ts.setEmitFlags(captureNewTargetStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureNewTargetStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); if (copyOnWrite) { statements = statements.slice(); } @@ -100504,21 +100948,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -100557,7 +101001,7 @@ var ts; var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, /*location*/ member.name); e = factory.createAssignment(memberName, memberFunction); } - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); + ts.setEmitFlags(memberFunction, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.setTextRange(factory.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); @@ -100565,7 +101009,7 @@ var ts; // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 48 /* NoSourceMap */); + ts.setEmitFlags(statement, 48 /* EmitFlags.NoSourceMap */); return statement; } /** @@ -100579,7 +101023,7 @@ var ts; // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } @@ -100595,20 +101039,20 @@ var ts; // arguments are both mapped contiguously to the accessor name. // TODO(rbuckton): Does this need to be parented? var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(target, 1536 /* EmitFlags.NoComments */ | 32 /* EmitFlags.NoTrailingSourceMap */); ts.setSourceMapRange(target, firstAccessor.name); var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName); if (ts.isPrivateIdentifier(visitedAccessorName)) { return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015."); } var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 16 /* EmitFlags.NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(getterFunction, 512 /* EmitFlags.NoLeadingComments */); var getter = factory.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -100616,7 +101060,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(setterFunction, 512 /* EmitFlags.NoLeadingComments */); var setter = factory.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -100639,12 +101083,12 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (node.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); + var ancestorFacts = enterSubtree(15232 /* HierarchyFacts.ArrowFunctionExcludes */, 66 /* HierarchyFacts.ArrowFunctionIncludes */); var func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -100653,9 +101097,9 @@ var ts; /*type*/ undefined, transformFunctionBody(node)); ts.setTextRange(func, node); ts.setOriginalNode(func, node); - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); // If an arrow function contains - exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.ArrowFunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return func; } @@ -100665,17 +101109,17 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ - ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */ + ? enterSubtree(32662 /* HierarchyFacts.AsyncFunctionBodyExcludes */, 69 /* HierarchyFacts.AsyncFunctionBodyIncludes */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionExpression(node, /*modifiers*/ undefined, node.asteriskToken, name, @@ -100690,13 +101134,13 @@ var ts; function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, /*typeParameters*/ undefined, parameters, @@ -100713,14 +101157,14 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node) - ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + ? enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */ | 8 /* HierarchyFacts.NonStaticClassElement */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ && !name && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, @@ -100763,7 +101207,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 214 /* ArrowFunction */); + ts.Debug.assert(node.kind === 214 /* SyntaxKind.ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -100782,7 +101226,7 @@ var ts; var returnStatement = factory.createReturnStatement(expression); ts.setTextRange(returnStatement, body); ts.moveSyntheticComments(returnStatement, body); - ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1024 /* EmitFlags.NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -100803,10 +101247,10 @@ var ts; var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine); ts.setTextRange(block, node.body); if (!multiLine && singleLine) { - ts.setEmitFlags(block, 1 /* SingleLine */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* SyntaxKind.CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -100816,11 +101260,11 @@ var ts; // A function body is not a block scope. return ts.visitEachChild(node, visitor, context); } - var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ - ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) - : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */); + var ancestorFacts = hierarchyFacts & 256 /* HierarchyFacts.IterationStatement */ + ? enterSubtree(7104 /* HierarchyFacts.IterationStatementBlockExcludes */, 512 /* HierarchyFacts.IterationStatementBlockIncludes */) + : enterSubtree(6976 /* HierarchyFacts.BlockExcludes */, 128 /* HierarchyFacts.BlockIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -100851,9 +101295,9 @@ var ts; function visitBinaryExpression(node, expressionResultIsUnused) { // If we are here it is because this is a destructuring assignment. if (ts.isDestructuringAssignment(node)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -100881,12 +101325,12 @@ var ts; function isVariableStatementOfTypeScriptClassWrapper(node) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer - && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */); + && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* EmitFlags.TypeScriptClassWrapper */); } function visitVariableStatement(node) { - var ancestorFacts = enterSubtree(0 /* None */, ts.hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.None */, ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? 32 /* HierarchyFacts.ExportedVariableStatement */ : 0 /* HierarchyFacts.None */); var updated; - if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { + if (convertedLoopState && (node.declarationList.flags & 3 /* NodeFlags.BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -100895,10 +101339,10 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); + assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* FlattenLevel.All */); } else { - assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -100915,7 +101359,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -100924,11 +101368,11 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) { - if (node.flags & 3 /* BlockScoped */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */ || node.transformFlags & 524288 /* TransformFlags.ContainsBindingPattern */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var declarations = ts.flatMap(node.declarations, node.flags & 1 /* Let */ + var declarations = ts.flatMap(node.declarations, node.flags & 1 /* NodeFlags.Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration); var declarationList = factory.createVariableDeclarationList(declarations); @@ -100937,7 +101381,7 @@ var ts; ts.setCommentRange(declarationList, node); // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. - if (node.transformFlags & 524288 /* ContainsBindingPattern */ + if (node.transformFlags & 524288 /* TransformFlags.ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -101003,18 +101447,18 @@ var ts; // * Why loop initializer is excluded? // - Since we've introduced a fresh name it already will be undefined. var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 262144 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 524288 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 + var isCapturedInFunction = flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + var emittedAsTopLevel = (hierarchyFacts & 64 /* HierarchyFacts.TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); + && (hierarchyFacts & 512 /* HierarchyFacts.IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0 + && (hierarchyFacts & 4096 /* HierarchyFacts.ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0)); + && (hierarchyFacts & (2048 /* HierarchyFacts.ForStatement */ | 4096 /* HierarchyFacts.ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -101041,16 +101485,16 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var ancestorFacts = enterSubtree(32 /* HierarchyFacts.ExportedVariableStatement */, 0 /* HierarchyFacts.None */); var updated; if (ts.isBindingPattern(node.name)) { - updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* FlattenLevel.All */, + /*value*/ undefined, (ancestorFacts & 32 /* HierarchyFacts.ExportedVariableStatement */) !== 0); } else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function recordLabel(node) { @@ -101070,50 +101514,50 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function visitDoOrWhileStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(0 /* HierarchyFacts.DoOrWhileStatementExcludes */, 1280 /* HierarchyFacts.DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } function visitForStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(5056 /* HierarchyFacts.ForStatementExcludes */, 3328 /* HierarchyFacts.ForStatementIncludes */, node, outermostLabeledStatement); } function visitEachChildOfForStatement(node) { return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); } function visitForInStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; var initializer = node.initializer; if (ts.isVariableDeclarationList(initializer)) { - if (node.initializer.flags & 3 /* BlockScoped */) { + if (node.initializer.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* FlattenLevel.All */, boundValue); var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old @@ -101161,7 +101605,7 @@ var ts; } function createSyntheticBlockForConvertedStatements(statements) { return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), - /*multiLine*/ true), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: @@ -101193,18 +101637,18 @@ var ts; var counter = factory.createLoopVariable(); var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); + ts.setEmitFlags(expression, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(expression)); var forStatement = ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(counter, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(factory.createVariableDeclaration(rhsReference, /*exclamationToken*/ undefined, /*type*/ undefined, expression), node.expression) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression), /*incrementor*/ ts.setTextRange(factory.createPostfixIncrement(counter), node.expression), /*statement*/ convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)), /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } @@ -101220,33 +101664,33 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 1024 /* IterationContainer */ + var initializer = ancestorFacts & 1024 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values]) : values; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result, /*exclamationToken*/ undefined, /*type*/ undefined, next) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), /*incrementor*/ factory.createAssignment(result, next), /*statement*/ convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([ factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* EmitFlags.SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } /** @@ -101261,9 +101705,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 1048576 /* ContainsYield */ && - hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) { + if ((property.transformFlags & 1048576 /* TransformFlags.ContainsYield */ && + hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* SyntaxKind.ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -101276,7 +101720,7 @@ var ts; var temp = factory.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* Indented */ : 0)); + var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* EmitFlags.Indented */ : 0)); if (node.multiLine) { ts.startOnNewLine(assignment); } @@ -101288,7 +101732,7 @@ var ts; return factory.inlineExpressions(expressions); } function shouldConvertPartOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 131072 /* ContainsCapturedBlockScopeBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */) !== 0; } function shouldConvertInitializerOfForStatement(node) { return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer); @@ -101304,7 +101748,7 @@ var ts; || shouldConvertInitializerOfForStatement(node); } function shouldConvertBodyOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */) !== 0; } /** * Records constituents of name for the given variable to be hoisted in the outer scope. @@ -101315,7 +101759,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -101335,7 +101779,7 @@ var ts; // we get here if we are trying to emit normal loop loop inside converted loop // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + convertedLoopState.allowedNonLabeledJumps = 2 /* Jump.Break */ | 4 /* Jump.Continue */; } var result = convert ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts) @@ -101379,11 +101823,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 242 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 243 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 244 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 240 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 241 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 242 /* SyntaxKind.ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 243 /* SyntaxKind.ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 244 /* SyntaxKind.ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 240 /* SyntaxKind.DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 241 /* SyntaxKind.WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -101408,11 +101852,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -101421,7 +101865,7 @@ var ts; var loopParameters = []; // variables declared in the loop initializer that will be changed inside the loop var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) { var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) || shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node); @@ -101534,15 +101978,15 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0; - var emitFlags = 0 /* None */; + var containsYield = (node.initializer.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 0 /* EmitFlags.None */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && hierarchyFacts & 4 /* AsyncFunctionBody */) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; var statements = []; statements.push(factory.createVariableStatement(/*modifiers*/ undefined, node.initializer)); - copyOutParameters(currentState.loopOutParameters, 2 /* Initializer */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 2 /* LoopOutParameterFlags.Initializer */, 1 /* CopyDirection.ToOutParameter */, statements); // This transforms the following ES2015 syntax: // // for (let i = (setImmediate(() => console.log(i)), 0); i < 2; i++) { @@ -101568,12 +102012,12 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, ts.visitNode(factory.createBlock(statements, /*multiLine*/ true), visitor, ts.isBlock)), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } @@ -101635,7 +102079,7 @@ var ts; statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue())))); } if (shouldConvertConditionOfForStatement(node)) { - statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); + statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -101644,17 +102088,17 @@ var ts; else { statements.push(statement); } - copyOutParameters(currentState.loopOutParameters, 1 /* Body */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 1 /* CopyDirection.ToOutParameter */, statements); ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment); var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0; - var emitFlags = 524288 /* ReuseTempVariableScope */; + var containsYield = (node.statement.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 524288 /* EmitFlags.ReuseTempVariableScope */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && (hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) !== 0) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; // This transforms the following ES2015 syntax (in addition to other variations): // // for (let i = 0; i < 2; i++) { @@ -101674,18 +102118,18 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); + var source = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.originalName : outParam.outParamName; + return factory.createBinaryExpression(target, 63 /* SyntaxKind.EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -101698,7 +102142,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = factory.createCallExpression(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; return factory.createExpressionStatement(callResult); } @@ -101707,27 +102151,27 @@ var ts; // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop // simple loops are emitted as just 'loop()'; // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Jump.Continue */) && !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = factory.createCallExpression(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; if (isSimpleLoop) { statements.push(factory.createExpressionStatement(callResult)); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); } else { var loopResultName = factory.createUniqueName("state"); var stateVariable = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, /*exclamationToken*/ undefined, /*type*/ undefined, callResult)])); statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Jump.Return */) { var returnStatement = void 0; if (outerState) { - outerState.nonLocalJumps |= 8 /* Return */; + outerState.nonLocalJumps |= 8 /* Jump.Return */; returnStatement = factory.createReturnStatement(loopResultName); } else { @@ -101735,7 +102179,7 @@ var ts; } statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement)); } - if (state.nonLocalJumps & 2 /* Break */) { + if (state.nonLocalJumps & 2 /* Jump.Break */) { statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { @@ -101794,19 +102238,19 @@ var ts; else { loopParameters.push(factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); var checkFlags = resolver.getNodeCheckFlags(decl); - if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { var outParamName = factory.createUniqueName("out_" + ts.idText(name)); var flags = 0; - if (checkFlags & 4194304 /* NeedsLoopOutParameter */) { - flags |= 1 /* Body */; + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */) { + flags |= 1 /* LoopOutParameterFlags.Body */; } if (ts.isForStatement(container)) { if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) { - flags |= 2 /* Initializer */; + flags |= 2 /* LoopOutParameterFlags.Initializer */; } if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) || container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) { - flags |= 1 /* Body */; + flags |= 1 /* LoopOutParameterFlags.Body */; } } loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName }); @@ -101828,20 +102272,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -101896,14 +102340,14 @@ var ts; return expression; } function visitCatchClause(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated; ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = factory.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* FlattenLevel.All */, temp); var list = factory.createVariableDeclarationList(vars); ts.setTextRange(list, node.variableDeclaration); var destructure = factory.createVariableStatement(/*modifiers*/ undefined, list); @@ -101912,7 +102356,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function addStatementToStartOfBlock(block, statement) { @@ -101931,7 +102375,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); - ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 512 /* EmitFlags.NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } @@ -101944,17 +102388,17 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.modifiers, node.name, parameters, node.type, body); } else { updated = factory.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -101997,11 +102441,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { + if (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 106 /* SuperKeyword */ || + if (expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -102074,7 +102518,7 @@ var ts; // }()) // var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); - if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) { + if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression); } // The underlying call (3) is another IIFE that may contain a '_super' argument. @@ -102131,15 +102575,15 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. - if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || - node.expression.kind === 106 /* SuperKeyword */ || + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */ || + node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 106 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + ts.setEmitFlags(thisArg, 4 /* EmitFlags.NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 32768 /* ContainsRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -102153,7 +102597,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -102165,12 +102609,12 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); + resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis - ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) + ? factory.createAssignment(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), initializer) : initializer; } return ts.setOriginalNode(resultingCall, node); @@ -102259,13 +102703,13 @@ var ts; } } var helpers = emitHelpers(); - var startsWithSpread = segments[0].kind !== 0 /* None */; + var startsWithSpread = segments[0].kind !== 0 /* SpreadSegmentKind.None */; var expression = startsWithSpread ? factory.createArrayLiteralExpression() : segments[0].expression; for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) { var segment = segments[i]; // If this is for an argument list, it doesn't matter if the array is packed or sparse - expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList); + expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !isArgumentList); } return expression; } @@ -102281,12 +102725,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); // We don't need to pack already packed array literals, or existing calls to the `__read` helper. var isCallToReadHelper = ts.isCallToHelper(expression, "___read"); - var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */; + var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* SpreadSegmentKind.PackedSpread */ : 1 /* SpreadSegmentKind.UnpackedSpread */; // We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`. - if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { + if (compilerOptions.downlevelIteration && kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { expression = emitHelpers().createReadHelper(expression, /*count*/ undefined); // the `__read` helper returns a packed array, so we don't need to ensure a packed array - kind = 2 /* PackedSpread */; + kind = 2 /* SpreadSegmentKind.PackedSpread */; } return createSpreadSegment(kind, expression); } @@ -102294,7 +102738,7 @@ var ts; var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); // We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to // `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements` - return createSpreadSegment(0 /* None */, expression); + return createSpreadSegment(0 /* SpreadSegmentKind.None */, expression); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -102324,7 +102768,7 @@ var ts; * @param node A string literal. */ function visitNumericLiteral(node) { - if (node.numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) { + if (node.numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { return ts.setTextRange(factory.createNumericLiteral(node.text), node); } return node; @@ -102359,15 +102803,15 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ + return hierarchyFacts & 8 /* HierarchyFacts.NonStaticClassElement */ && !isExpressionOfCall - ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") - : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), "prototype") + : factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { - hierarchyFacts |= 32768 /* NewTarget */; - return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */ && node.name.escapedText === "target") { + hierarchyFacts |= 32768 /* HierarchyFacts.NewTarget */; + return factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } return node; } @@ -102379,13 +102823,13 @@ var ts; * @param emitCallback The callback used to emit the node. */ function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ - ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ - : 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, ts.getEmitFlags(node) & 8 /* EmitFlags.CapturesThis */ + ? 65 /* HierarchyFacts.FunctionIncludes */ | 16 /* HierarchyFacts.CapturesThis */ + : 65 /* HierarchyFacts.FunctionIncludes */); previousOnEmitNode(hint, node, emitCallback); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return; } previousOnEmitNode(hint, node, emitCallback); @@ -102395,9 +102839,9 @@ var ts; * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* ES2015SubstitutionFlags.BlockScopedBindings */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } /** @@ -102405,16 +102849,16 @@ var ts; * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(108 /* ThisKeyword */); - context.enableEmitNotification(171 /* Constructor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(214 /* ArrowFunction */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(256 /* FunctionDeclaration */); + if ((enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* ES2015SubstitutionFlags.CapturedThis */; + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(214 /* SyntaxKind.ArrowFunction */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); } } /** @@ -102425,7 +102869,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -102439,7 +102883,7 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return ts.setTextRange(factory.getGeneratedNameForNode(original), node); @@ -102455,10 +102899,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -102471,9 +102915,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -102484,7 +102928,7 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node); @@ -102521,9 +102965,9 @@ var ts; * @param node The ThisKeyword node. */ function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && hierarchyFacts & 16 /* CapturesThis */) { - return ts.setTextRange(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ + && hierarchyFacts & 16 /* HierarchyFacts.CapturesThis */) { + return ts.setTextRange(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node); } return node; } @@ -102540,19 +102984,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* SyntaxKind.ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SyntaxKind.SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SyntaxKind.SpreadElement */) { return false; } var expression = callArgument.expression; @@ -102575,18 +103019,18 @@ var ts; // enable emit notification only if using --jsx preserve or react-native var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + if (compilerOptions.jsx === 1 /* JsxEmit.Preserve */ || compilerOptions.jsx === 3 /* JsxEmit.ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(280 /* JsxOpeningElement */); - context.enableEmitNotification(281 /* JsxClosingElement */); - context.enableEmitNotification(279 /* JsxSelfClosingElement */); + context.enableEmitNotification(280 /* SyntaxKind.JsxOpeningElement */); + context.enableEmitNotification(281 /* SyntaxKind.JsxClosingElement */); + context.enableEmitNotification(279 /* SyntaxKind.JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(296 /* PropertyAssignment */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(296 /* SyntaxKind.PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -102605,9 +103049,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -102667,7 +103111,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -102847,11 +103291,11 @@ var ts; })(Instruction || (Instruction = {})); function getInstructionName(instruction) { switch (instruction) { - case 2 /* Return */: return "return"; - case 3 /* Break */: return "break"; - case 4 /* Yield */: return "yield"; - case 5 /* YieldStar */: return "yield*"; - case 7 /* Endfinally */: return "endfinally"; + case 2 /* Instruction.Return */: return "return"; + case 3 /* Instruction.Break */: return "break"; + case 4 /* Instruction.Yield */: return "yield"; + case 5 /* Instruction.YieldStar */: return "yield*"; + case 7 /* Instruction.Endfinally */: return "endfinally"; default: return undefined; // TODO: GH#18217 } } @@ -102905,7 +103349,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 2048 /* TransformFlags.ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -102928,7 +103372,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 2048 /* ContainsGenerator */) { + else if (transformFlags & 2048 /* TransformFlags.ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -102942,13 +103386,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -102961,30 +103405,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitBreakStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 1048576 /* ContainsYield */) { + if (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (2048 /* TransformFlags.ContainsGenerator */ | 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -102999,23 +103443,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitConditionalExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -103028,9 +103472,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -103188,13 +103632,13 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 1048576 /* ContainsYield */) { + if (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -103219,9 +103663,9 @@ var ts; function visitBinaryExpression(node) { var assoc = ts.getExpressionAssociativity(node); switch (assoc) { - case 0 /* Left */: + case 0 /* Associativity.Left */: return visitLeftAssociativeBinaryExpression(node); - case 1 /* Right */: + case 1 /* Associativity.Right */: return visitRightAssociativeBinaryExpression(node); default: return ts.Debug.assertNever(assoc); @@ -103237,7 +103681,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // [source] // a.b = yield; // @@ -103249,7 +103693,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // [source] // a[b] = yield; // @@ -103281,7 +103725,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 27 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return visitCommaExpression(node); } // [source] @@ -103315,13 +103759,13 @@ var ts; visit(node.right); return factory.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { visit(node.left); visit(node.right); } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -103338,12 +103782,12 @@ var ts; var pendingExpressions = []; for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var elem = _a[_i]; - if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { pendingExpressions.push(visitCommaExpression(elem)); } else { if (containsYield(elem) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression)); @@ -103388,7 +103832,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -103454,7 +103898,7 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { // NOTE: `expression` must be defined for `yield*`. - var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* EmitFlags.Iterator */) === 0 ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node) : expression; emitYieldStar(iterator, /*location*/ node); @@ -103643,35 +104087,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return transformAndEmitBlock(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return transformAndEmitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return transformAndEmitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return transformAndEmitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return transformAndEmitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return transformAndEmitForInStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return transformAndEmitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return transformAndEmitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return transformAndEmitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return transformAndEmitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return transformAndEmitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -104101,7 +104545,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 290 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -104114,7 +104558,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -104246,7 +104690,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -104259,7 +104703,7 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; @@ -104290,7 +104734,7 @@ var ts; return node; } function cacheExpression(node) { - if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return node; } var temp = factory.createTempVariable(hoistVariableDeclaration); @@ -104336,7 +104780,7 @@ var ts; blockStack = []; } var index = blockActions.length; - blockActions[index] = 0 /* Open */; + blockActions[index] = 0 /* BlockAction.Open */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.push(block); @@ -104350,7 +104794,7 @@ var ts; if (block === undefined) return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; - blockActions[index] = 1 /* Close */; + blockActions[index] = 1 /* BlockAction.Close */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.pop(); @@ -104379,7 +104823,7 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 1 /* With */, + kind: 1 /* CodeBlockKind.With */, expression: expression, startLabel: startLabel, endLabel: endLabel @@ -104389,7 +104833,7 @@ var ts; * Ends a code block for a generated `with` statement. */ function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); + ts.Debug.assert(peekBlockKind() === 1 /* CodeBlockKind.With */); var block = endBlock(); markLabel(block.endLabel); } @@ -104401,8 +104845,8 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, + kind: 0 /* CodeBlockKind.Exception */, + state: 0 /* ExceptionBlockState.Try */, startLabel: startLabel, endLabel: endLabel }); @@ -104415,7 +104859,7 @@ var ts; * @param variable The catch variable. */ function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); // generated identifiers should already be unique within a file var name; if (ts.isGeneratedIdentifier(variable.name)) { @@ -104428,18 +104872,18 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); + ts.Debug.assert(exception.state < 1 /* ExceptionBlockState.Catch */); var endLabel = exception.endLabel; emitBreak(endLabel); var catchLabel = defineLabel(); markLabel(catchLabel); - exception.state = 1 /* Catch */; + exception.state = 1 /* ExceptionBlockState.Catch */; exception.catchVariable = name; exception.catchLabel = catchLabel; emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), /*typeArguments*/ undefined, [])); @@ -104449,24 +104893,24 @@ var ts; * Enters the `finally` block of a generated `try` statement. */ function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); + ts.Debug.assert(exception.state < 2 /* ExceptionBlockState.Finally */); var endLabel = exception.endLabel; emitBreak(endLabel); var finallyLabel = defineLabel(); markLabel(finallyLabel); - exception.state = 2 /* Finally */; + exception.state = 2 /* ExceptionBlockState.Finally */; exception.finallyLabel = finallyLabel; } /** * Ends the code block for a generated `try` statement. */ function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = endBlock(); var state = exception.state; - if (state < 2 /* Finally */) { + if (state < 2 /* ExceptionBlockState.Finally */) { emitBreak(exception.endLabel); } else { @@ -104474,7 +104918,7 @@ var ts; } markLabel(exception.endLabel); emitNop(); - exception.state = 3 /* Done */; + exception.state = 3 /* ExceptionBlockState.Done */; } /** * Begins a code block that supports `break` or `continue` statements that are defined in @@ -104484,7 +104928,7 @@ var ts; */ function beginScriptLoopBlock() { beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: true, breakLabel: -1, continueLabel: -1 @@ -104501,7 +104945,7 @@ var ts; function beginLoopBlock(continueLabel) { var breakLabel = defineLabel(); beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: false, breakLabel: breakLabel, continueLabel: continueLabel, @@ -104513,7 +104957,7 @@ var ts; * generated code or in the source tree. */ function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + ts.Debug.assert(peekBlockKind() === 3 /* CodeBlockKind.Loop */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -104527,7 +104971,7 @@ var ts; */ function beginScriptSwitchBlock() { beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: true, breakLabel: -1 }); @@ -104540,7 +104984,7 @@ var ts; function beginSwitchBlock() { var breakLabel = defineLabel(); beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: false, breakLabel: breakLabel, }); @@ -104550,7 +104994,7 @@ var ts; * Ends a code block that supports `break` statements that are defined in generated code. */ function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + ts.Debug.assert(peekBlockKind() === 2 /* CodeBlockKind.Switch */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -104559,7 +105003,7 @@ var ts; } function beginScriptLabeledBlock(labelText) { beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: true, labelText: labelText, breakLabel: -1 @@ -104568,14 +105012,14 @@ var ts; function beginLabeledBlock(labelText) { var breakLabel = defineLabel(); beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: false, labelText: labelText, breakLabel: breakLabel }); } function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + ts.Debug.assert(peekBlockKind() === 4 /* CodeBlockKind.Labeled */); var block = endBlock(); if (!block.isScript) { markLabel(block.breakLabel); @@ -104587,8 +105031,8 @@ var ts; * @param block A code block. */ function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; + return block.kind === 2 /* CodeBlockKind.Switch */ + || block.kind === 3 /* CodeBlockKind.Loop */; } /** * Indicates whether the provided block supports `break` statements with labels. @@ -104596,7 +105040,7 @@ var ts; * @param block A code block. */ function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; + return block.kind === 4 /* CodeBlockKind.Labeled */; } /** * Indicates whether the provided block supports `continue` statements. @@ -104604,7 +105048,7 @@ var ts; * @param block A code block. */ function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; + return block.kind === 3 /* CodeBlockKind.Loop */; } function hasImmediateContainingLabeledBlock(labelText, start) { for (var j = start; j >= 0; j--) { @@ -104701,7 +105145,7 @@ var ts; */ function createInstruction(instruction) { var literal = factory.createNumericLiteral(instruction); - ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); + ts.addSyntheticTrailingComment(literal, 3 /* SyntaxKind.MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -104713,7 +105157,7 @@ var ts; function createInlineBreak(label, location) { ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) ])), location); } @@ -104725,8 +105169,8 @@ var ts; */ function createInlineReturn(expression, location) { return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), location); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. @@ -104739,7 +105183,7 @@ var ts; * Emits an empty instruction. */ function emitNop() { - emitWorker(0 /* Nop */); + emitWorker(0 /* OpCode.Nop */); } /** * Emits a Statement. @@ -104748,7 +105192,7 @@ var ts; */ function emitStatement(node) { if (node) { - emitWorker(1 /* Statement */, [node]); + emitWorker(1 /* OpCode.Statement */, [node]); } else { emitNop(); @@ -104762,7 +105206,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); + emitWorker(2 /* OpCode.Assign */, [left, right], location); } /** * Emits a Break operation to the specified label. @@ -104771,7 +105215,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); + emitWorker(3 /* OpCode.Break */, [label], location); } /** * Emits a Break operation to the specified label when a condition evaluates to a truthy @@ -104782,7 +105226,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + emitWorker(4 /* OpCode.BreakWhenTrue */, [label, condition], location); } /** * Emits a Break to the specified label when a condition evaluates to a falsey value at @@ -104793,7 +105237,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + emitWorker(5 /* OpCode.BreakWhenFalse */, [label, condition], location); } /** * Emits a YieldStar operation for the provided expression. @@ -104802,7 +105246,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + emitWorker(7 /* OpCode.YieldStar */, [expression], location); } /** * Emits a Yield operation for the provided expression. @@ -104811,7 +105255,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + emitWorker(6 /* OpCode.Yield */, [expression], location); } /** * Emits a Return operation for the provided expression. @@ -104820,7 +105264,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + emitWorker(8 /* OpCode.Return */, [expression], location); } /** * Emits a Throw operation for the provided expression. @@ -104829,13 +105273,13 @@ var ts; * @param location An optional source map location for the assignment. */ function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + emitWorker(9 /* OpCode.Throw */, [expression], location); } /** * Emits an Endfinally operation. This is used to handle `finally` block semantics. */ function emitEndfinally() { - emitWorker(10 /* Endfinally */); + emitWorker(10 /* OpCode.Endfinally */); } /** * Emits an operation. @@ -104879,7 +105323,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, factory.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* EmitFlags.ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -105052,8 +105496,8 @@ var ts; var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; switch (block.kind) { - case 0 /* Exception */: - if (blockAction === 0 /* Open */) { + case 0 /* CodeBlockKind.Exception */: + if (blockAction === 0 /* BlockAction.Open */) { if (!exceptionBlockStack) { exceptionBlockStack = []; } @@ -105063,18 +105507,18 @@ var ts; exceptionBlockStack.push(currentExceptionBlock); currentExceptionBlock = block; } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { currentExceptionBlock = exceptionBlockStack.pop(); } break; - case 1 /* With */: - if (blockAction === 0 /* Open */) { + case 1 /* CodeBlockKind.With */: + if (blockAction === 0 /* BlockAction.Open */) { if (!withBlockStack) { withBlockStack = []; } withBlockStack.push(block); } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { withBlockStack.pop(); } break; @@ -105098,33 +105542,33 @@ var ts; lastOperationWasAbrupt = false; lastOperationWasCompletion = false; var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { + if (opcode === 0 /* OpCode.Nop */) { return; } - else if (opcode === 10 /* Endfinally */) { + else if (opcode === 10 /* OpCode.Endfinally */) { return writeEndfinally(); } var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { + if (opcode === 1 /* OpCode.Statement */) { return writeStatement(args[0]); } var location = operationLocations[operationIndex]; switch (opcode) { - case 2 /* Assign */: + case 2 /* OpCode.Assign */: return writeAssign(args[0], args[1], location); - case 3 /* Break */: + case 3 /* OpCode.Break */: return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: + case 4 /* OpCode.BreakWhenTrue */: return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: + case 5 /* OpCode.BreakWhenFalse */: return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: + case 6 /* OpCode.Yield */: return writeYield(args[0], location); - case 7 /* YieldStar */: + case 7 /* OpCode.YieldStar */: return writeYieldStar(args[0], location); - case 8 /* Return */: + case 8 /* OpCode.Return */: return writeReturn(args[0], location); - case 9 /* Throw */: + case 9 /* OpCode.Throw */: return writeThrow(args[0], location); } } @@ -105174,8 +105618,8 @@ var ts; lastOperationWasAbrupt = true; lastOperationWasCompletion = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -105186,9 +105630,9 @@ var ts; function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -105199,9 +105643,9 @@ var ts; */ function writeBreakWhenTrue(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -105212,9 +105656,9 @@ var ts; */ function writeBreakWhenFalse(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -105225,8 +105669,8 @@ var ts; function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(4 /* Instruction.Yield */), expression] + : [createInstruction(4 /* Instruction.Yield */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -105237,9 +105681,9 @@ var ts; function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(5 /* YieldStar */), + createInstruction(5 /* Instruction.YieldStar */), expression - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -105247,7 +105691,7 @@ var ts; function writeEndfinally() { lastOperationWasAbrupt = true; writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(7 /* Endfinally */) + createInstruction(7 /* Instruction.Endfinally */) ]))); } } @@ -105274,12 +105718,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(208 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(210 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -105295,7 +105739,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 8388608 /* ContainsDynamicImport */ || + node.transformFlags & 8388608 /* TransformFlags.ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -105431,7 +105875,7 @@ var ts; factory.createIdentifier("exports") ])) ]), - ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* EmitFlags.SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ @@ -105516,7 +105960,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } @@ -105585,13 +106029,13 @@ var ts; if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); statements.push(statement); } } @@ -105607,23 +106051,23 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -105632,30 +106076,30 @@ var ts; function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (8388608 /* TransformFlags.ContainsDynamicImport */ | 4096 /* TransformFlags.ContainsDestructuringAssignment */ | 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -105671,24 +106115,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -105714,7 +106158,7 @@ var ts; } function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded, createAllExportExpressions); } return ts.visitEachChild(node, visitor, context); } @@ -105740,7 +106184,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -105783,7 +106227,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -105810,7 +106254,7 @@ var ts; // }); needUMDDynamicImportHelper = true; if (ts.isSimpleCopiableExpression(arg)) { - var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */); + var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* EmitFlags.NoComments */); return factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, @@ -105846,7 +106290,7 @@ var ts; /*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) ]); var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, parameters, @@ -105864,7 +106308,7 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); @@ -105885,7 +106329,7 @@ var ts; requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, @@ -105905,13 +106349,13 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { @@ -105920,7 +106364,7 @@ var ts; return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { @@ -105967,7 +106411,7 @@ var ts; } } statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), /*location*/ node), /*original*/ node)); } @@ -105981,7 +106425,7 @@ var ts; /*type*/ undefined, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) - ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + ], languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */))); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -106015,7 +106459,7 @@ var ts; ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)); } else { @@ -106025,11 +106469,11 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); } } else { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node)); } } @@ -106070,12 +106514,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && - !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && + !(ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); @@ -106126,7 +106570,7 @@ var ts; */ function visitFunctionDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), /*type*/ undefined, ts.visitEachChild(node.body, visitor, context)), @@ -106153,7 +106597,7 @@ var ts; */ function visitClassDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); } @@ -106179,7 +106623,7 @@ var ts; var statements; var variables; var expressions; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var modifiers = void 0; var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. @@ -106237,7 +106681,7 @@ var ts; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. - ts.setEmitFlags(expression, 4 /* NoSubstitution */); + ts.setEmitFlags(expression, 4 /* EmitFlags.NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; @@ -106252,7 +106696,7 @@ var ts; function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), - /*visitor*/ undefined, context, 0 /* All */, + /*visitor*/ undefined, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAllExportExpressions); } else { @@ -106274,7 +106718,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -106286,7 +106730,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -106329,10 +106773,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -106415,8 +106859,8 @@ var ts; if (currentModuleInfo.exportEquals) { return statements; } - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -106461,7 +106905,7 @@ var ts; } function createUnderscoreUnderscoreESModule() { var statement; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())); } else { @@ -106474,7 +106918,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); return statement; } /** @@ -106489,7 +106933,7 @@ var ts; var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -106501,7 +106945,7 @@ var ts; * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { - return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), + return ts.setTextRange(liveBinding && languageVersion !== 0 /* ScriptTarget.ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), @@ -106528,8 +106972,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -106545,7 +106989,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); @@ -106570,7 +107014,7 @@ var ts; if (node.id && noSubstitution[node.id]) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -106605,13 +107049,13 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); } return node; @@ -106620,9 +107064,9 @@ var ts; if (ts.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); noSubstitution[ts.getNodeId(expression)] = true; - if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateCallExpression(node, expression, - /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.arguments), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -106631,9 +107075,9 @@ var ts; if (ts.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); noSubstitution[ts.getNodeId(tag)] = true; - if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, - /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.template), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -106646,16 +107090,16 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } return node; } - else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -106744,11 +107188,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(231 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(231 /* SyntaxKind.MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -106768,7 +107212,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* TransformFlags.ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -106815,7 +107259,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ]), node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* EmitFlags.NoTrailingComments */); if (!ts.outFile(compilerOptions)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -106937,8 +107381,8 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 - var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ? - factory.createModifiersFromModifierFlags(256 /* Async */) : + var modifiers = node.transformFlags & 2097152 /* TransformFlags.ContainsAwait */ ? + factory.createModifiersFromModifierFlags(256 /* ModifierFlags.Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -106972,7 +107416,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 272 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 272 /* SyntaxKind.ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -107037,7 +107481,7 @@ var ts; factory.createForInStatement(factory.createVariableDeclarationList([ factory.createVariableDeclaration(n) ]), m, factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */) ])), factory.createExpressionStatement(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exports])) @@ -107061,19 +107505,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -107132,13 +107576,13 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); default: return topLevelNestedVisitor(node); @@ -107214,7 +107658,7 @@ var ts; * @param node The node to visit. */ function visitFunctionDeclaration(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock))); @@ -107266,7 +107710,7 @@ var ts; return ts.visitNode(node, visitor, ts.isStatement); } var expressions; - var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; @@ -107316,9 +107760,9 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 305 /* SourceFile */ - || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + return (ts.getEmitFlags(node) & 2097152 /* EmitFlags.NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 305 /* SyntaxKind.SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* NodeFlags.BlockScoped */) === 0); } /** * Transform an initialized variable declaration into an expression. @@ -107329,7 +107773,7 @@ var ts; function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAssignment) : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name; } @@ -107381,9 +107825,9 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); - var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* ModifierFlags.Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); } return node; @@ -107394,7 +107838,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -107443,10 +107887,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -107540,8 +107984,8 @@ var ts; return statements; } var excludeName; - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createStringLiteral("default") : decl.name; + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory.getLocalName(decl)); excludeName = ts.getTextOfIdentifierOrLiteral(exportName); } @@ -107601,7 +108045,7 @@ var ts; var statement = factory.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -107613,7 +108057,7 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name; - ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* EmitFlags.NoComments */); return ts.setCommentRange(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // @@ -107626,43 +108070,43 @@ var ts; */ function topLevelNestedVisitor(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ true); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitDefaultClause(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitTryStatement(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -107844,30 +108288,30 @@ var ts; * @param node The node to visit. */ function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4096 /* TransformFlags.ContainsDestructuringAssignment */ | 8388608 /* TransformFlags.ContainsDynamicImport */ | 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node)) { return visitImportCallExpression(node); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -107917,7 +108361,7 @@ var ts; */ function visitDestructuringAssignment(node, valueIsDiscarded) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); } @@ -107947,7 +108391,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 305 /* SourceFile */; + return container !== undefined && container.kind === 305 /* SyntaxKind.SourceFile */; } else { return false; @@ -107963,7 +108407,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -108008,8 +108452,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -108025,7 +108469,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -108060,10 +108504,10 @@ var ts; if (isSubstitutionPrevented(node)) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } - else if (hint === 4 /* Unspecified */) { + else if (hint === 4 /* EmitHint.Unspecified */) { return substituteUnspecified(node); } return node; @@ -108075,7 +108519,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -108110,11 +108554,11 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return substituteMetaProperty(node); } return node; @@ -108126,7 +108570,7 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); @@ -108204,7 +108648,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -108247,8 +108691,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(305 /* SourceFile */); - context.enableSubstitution(79 /* Identifier */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); var helperNameSubstitutions; var currentSourceFile; var importRequireStatements; @@ -108287,14 +108731,14 @@ var ts; } function visitor(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` // is available, just because the output is reasonable for a node-like runtime. return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -108312,23 +108756,23 @@ var ts; args.push(moduleName); } if (!importRequireStatements) { - var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */); + var createRequireName = factory.createUniqueName("_createRequire", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var importStatement = factory.createImportDeclaration( /*modifiers*/ undefined, factory.createImportClause( /*isTypeOnly*/ false, /*name*/ undefined, factory.createNamedImports([ factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName) ])), factory.createStringLiteral("module")); - var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */); + var requireHelperName = factory.createUniqueName("__require", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var requireStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(requireHelperName, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ - factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) + factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) ])) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)); importRequireStatements = [importStatement, requireStatement]; } var name = importRequireStatements[1].declarationList.declarations[0].name; @@ -108349,12 +108793,12 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); statements = appendExportsOfImportEqualsDeclaration(statements, node); return ts.singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, factory.createExportDeclaration( /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))]))); } @@ -108419,7 +108863,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return substituteHelperName(node); } return node; @@ -108428,7 +108872,7 @@ var ts; var name = ts.idText(node); var substitution = helperNameSubstitutions.get(name); if (!substitution) { - helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */)); + helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)); } return substitution; } @@ -108451,8 +108895,8 @@ var ts; var cjsOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(305 /* SourceFile */); - context.enableEmitNotification(305 /* SourceFile */); + context.enableSubstitution(305 /* SyntaxKind.SourceFile */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); var currentSourceFile; return transformSourceFileOrBundle; function onSubstituteNode(hint, node) { @@ -108499,7 +108943,7 @@ var ts; return result; } function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -108554,14 +108998,14 @@ var ts; function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -108583,14 +109027,14 @@ var ts; function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; @@ -108614,7 +109058,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -108632,31 +109076,31 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind)); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(node.kind))); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 167 /* PropertyDeclaration */ || node.kind === 206 /* PropertyAccessExpression */ || node.kind === 166 /* PropertySignature */ || - (node.kind === 164 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 166 /* SyntaxKind.PropertySignature */ || + (node.kind === 164 /* SyntaxKind.Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */ || node.kind === 164 /* Parameter */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 164 /* SyntaxKind.Parameter */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -108679,7 +109123,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.isStatic(node)) { @@ -108696,14 +109140,14 @@ var ts; else { if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1; @@ -108718,36 +109162,36 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; @@ -108759,9 +109203,9 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -108784,40 +109228,40 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; @@ -108828,61 +109272,61 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 256 /* FunctionDeclaration */: - case 179 /* FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind)); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind))); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 179 /* FunctionType */: - case 256 /* FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -108899,7 +109343,7 @@ var ts; // Heritage clause is written by user so it can always be named if (ts.isClassDeclaration(node.parent.parent)) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0; @@ -108948,7 +109392,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 164 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 164 /* SyntaxKind.Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -108967,13 +109411,13 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* NodeBuilderFlags.MultilineObjectLiterals */ | + 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ | + 4096 /* NodeBuilderFlags.UseTypeOfFunction */ | + 8 /* NodeBuilderFlags.UseStructuralFallback */ | + 524288 /* NodeBuilderFlags.AllowEmptyTuple */ | + 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ | + 1 /* NodeBuilderFlags.NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -109033,7 +109477,7 @@ var ts; } function trackReferencedAmbientModule(node, symbol) { // If it is visible via `// `, then we should just use that - var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* SymbolFlags.All */); if (ts.length(directives)) { return recordTypeReferenceDirectivesIfNecessary(directives); } @@ -109042,7 +109486,7 @@ var ts; refs.set(ts.getOriginalNodeId(container), container); } function handleSymbolAccessibilityError(symbolAccessibilityResult) { - if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccessibilityResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { if (!lateMarkedStatements) { @@ -109078,7 +109522,7 @@ var ts; } } function trackSymbol(symbol, enclosingDeclaration, meaning) { - if (symbol.flags & 262144 /* TypeParameter */) + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) return false; var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); @@ -109154,10 +109598,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 305 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 305 /* SyntaxKind.SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -109180,14 +109624,14 @@ var ts; resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([factory.createModifier(135 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -109324,11 +109768,11 @@ var ts; return ret; } function filterBindingPatternInitializersAndRenamings(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return name; } else { - if (name.kind === 202 /* ArrayBindingPattern */) { + if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -109336,7 +109780,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 227 /* OmittedExpression */) { + if (elem.kind === 227 /* SyntaxKind.OmittedExpression */) { return elem; } if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) { @@ -109353,7 +109797,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } - var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* SyntaxKind.QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -109370,7 +109814,7 @@ var ts; return undefined; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { // Private nodes emit no types (except private parameter properties, whose parameter types are actually visible) return; } @@ -109378,19 +109822,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 164 /* Parameter */ && + var shouldUseResolverType = node.kind === 164 /* SyntaxKind.Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return factory.createKeywordTypeNode(130 /* AnyKeyword */); + return factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -109398,12 +109842,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 164 /* Parameter */ - || node.kind === 167 /* PropertyDeclaration */ - || node.kind === 166 /* PropertySignature */) { + if (node.kind === 164 /* SyntaxKind.Parameter */ + || node.kind === 167 /* SyntaxKind.PropertyDeclaration */ + || node.kind === 166 /* SyntaxKind.PropertySignature */) { if (ts.isPropertySignature(node) || !node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -109414,28 +109858,28 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !getBindingNameVisible(node); - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return false; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; } return false; @@ -109462,7 +109906,7 @@ var ts; } } function updateParamsList(node, params, modifierMask) { - if (ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); @@ -109498,7 +109942,7 @@ var ts; return factory.createNodeArray(newParams || ts.emptyArray); } function ensureTypeParams(node, params) { - return ts.hasEffectiveModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); + return ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } function isEnclosingDeclaration(node) { return ts.isSourceFile(node) @@ -109524,7 +109968,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* ModuleDeclaration */ && parent.kind !== 200 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && parent.kind !== 200 /* SyntaxKind.ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -109544,7 +109988,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, decl.modifiers, decl.isTypeOnly, decl.name, factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); @@ -109569,7 +110013,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } - if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; @@ -109614,7 +110058,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.Debug.formatSyntaxKind(i.kind))); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -109672,10 +110116,10 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* TypeLiteral */ || input.kind === 195 /* MappedType */) && input.parent.kind !== 259 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* SyntaxKind.TypeLiteral */ || input.kind === 195 /* SyntaxKind.MappedType */) && input.parent.kind !== 259 /* SyntaxKind.TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { - if (ts.hasEffectiveModifier(input, 8 /* Private */)) { + if (ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload return cleanup(factory.createPropertyDeclaration(ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); @@ -109693,28 +110137,28 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 228 /* ExpressionWithTypeArguments */: { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( - /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* None */), + /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* ModifierFlags.None */), /*body*/ undefined); return cleanup(ctor); } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -109723,44 +110167,44 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 172 /* GetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(factory.updateGetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), + return cleanup(factory.updateGetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 173 /* SetAccessor */: { + case 173 /* SyntaxKind.SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } - return cleanup(factory.updateSetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), + return cleanup(factory.updateSetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), /*body*/ undefined)); } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 176 /* IndexSignature */: { - return cleanup(factory.updateIndexSignature(input, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */))); + case 176 /* SyntaxKind.IndexSignature */: { + return cleanup(factory.updateIndexSignature(input, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */))); } - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -109768,13 +110212,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 163 /* TypeParameter */: { + case 163 /* SyntaxKind.TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 189 /* ConditionalType */: { + case 189 /* SyntaxKind.ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -109786,22 +110230,22 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 179 /* FunctionType */: { + case 179 /* SyntaxKind.FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 180 /* ConstructorType */: { + case 180 /* SyntaxKind.ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 200 /* ImportType */: { + case 200 /* SyntaxKind.ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind)); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(input.kind))); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { - ts.setEmitFlags(input, 1 /* SingleLine */); + ts.setEmitFlags(input, 1 /* EmitFlags.SingleLine */); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { @@ -109824,7 +110268,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 169 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -109834,7 +110278,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 272 /* ExportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -109843,17 +110287,17 @@ var ts; // Rewrite external module names if necessary return factory.updateExportDeclaration(input, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 79 /* Identifier */) { + if (input.expression.kind === 79 /* SyntaxKind.Identifier */) { return input; } else { - var newId = factory.createUniqueName("_default", 16 /* Optimistic */); + var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input @@ -109861,7 +110305,7 @@ var ts; errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); preserveJsDoc(statement, input); ts.removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.modifiers, newId)]; @@ -109874,12 +110318,12 @@ var ts; return input; } function stripExportModifiers(statement) { - if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* Default */) || !ts.canHaveModifiers(statement)) { + if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) { // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (257023 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (257023 /* ModifierFlags.All */ ^ 1 /* ModifierFlags.Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { @@ -109890,10 +110334,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -109914,12 +110358,12 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 258 /* InterfaceDeclaration */: { + case 258 /* SyntaxKind.InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), @@ -109927,7 +110371,7 @@ var ts; if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration - var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace_1, enclosingDeclaration); fakespace_1.locals = ts.createSymbolTable(props); fakespace_1.symbol = props[0].parent; @@ -109946,10 +110390,10 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* SyntaxKind.ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { - declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); + declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* ModifierFlags.None */); }); } else { declarations.push(factory.createExportDeclaration( @@ -109959,11 +110403,11 @@ var ts; return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); })))); } - var namespaceDecl = factory.createModuleDeclaration(ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */); - if (!ts.hasEffectiveModifier(clean, 512 /* Default */)) { + var namespaceDecl = factory.createModuleDeclaration(ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* NodeFlags.Namespace */); + if (!ts.hasEffectiveModifier(clean, 512 /* ModifierFlags.Default */)) { return [clean, namespaceDecl]; } - var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ExportDefault */) | 2 /* Ambient */); + var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ModifierFlags.ExportDefault */) | 2 /* ModifierFlags.Ambient */); var cleanDeclaration = factory.updateFunctionDeclaration(clean, modifiers, /*asteriskToken*/ undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, /*body*/ undefined); @@ -109981,17 +110425,17 @@ var ts; return clean; } } - case 261 /* ModuleDeclaration */: { + case 261 /* SyntaxKind.ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 262 /* ModuleBlock */) { + if (inner && inner.kind === 262 /* SyntaxKind.ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 16777216 /* Ambient */) { + if (input.flags & 16777216 /* NodeFlags.Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -110025,7 +110469,7 @@ var ts; return cleanup(factory.updateModuleDeclaration(input, mods, input.name, body)); } } - case 257 /* ClassDeclaration */: { + case 257 /* SyntaxKind.ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -110035,10 +110479,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ModifierFlags.ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 79 /* Identifier */) { + if (param.name.kind === 79 /* SyntaxKind.Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration(ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } else { @@ -110077,26 +110521,26 @@ var ts; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* SyntaxKind.NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16 /* Optimistic */); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 94 /* ExtendsKeyword */) { + if (clause.token === 94 /* SyntaxKind.ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* SyntaxKind.NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 } @@ -110105,10 +110549,10 @@ var ts; return cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 260 /* EnumDeclaration */: { + case 260 /* SyntaxKind.EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -110119,7 +110563,7 @@ var ts; } } // Anything left unhandled is an error, so this should be unreachable - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind)); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.Debug.formatSyntaxKind(input.kind))); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -110127,7 +110571,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 261 /* ModuleDeclaration */) { + if (input.kind === 261 /* SyntaxKind.ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -110150,7 +110594,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 227 /* OmittedExpression */) { + if (e.kind === 227 /* SyntaxKind.OmittedExpression */) { return; } if (e.name) { @@ -110198,12 +110642,12 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 257023 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files - var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 305 /* SourceFile */; + var mask = 257023 /* ModifierFlags.All */ ^ (4 /* ModifierFlags.Public */ | 256 /* ModifierFlags.Async */ | 16384 /* ModifierFlags.Override */); // No async and override modifiers in declaration files + var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* ModifierFlags.Ambient */ : 0 /* ModifierFlags.None */; + var parentIsFile = node.parent.kind === 305 /* SyntaxKind.SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { - mask ^= 2 /* Ambient */; - additions = 0 /* None */; + mask ^= 2 /* ModifierFlags.Ambient */; + additions = 0 /* ModifierFlags.None */; } return maskModifierFlags(node, mask, additions); } @@ -110223,13 +110667,13 @@ var ts; } function transformHeritageClauses(nodes) { return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* SyntaxKind.ExtendsKeyword */ && t.expression.kind === 104 /* SyntaxKind.NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return true; } return false; @@ -110239,22 +110683,22 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 257023 /* All */ ^ 4 /* Public */; } - if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } + if (modifierMask === void 0) { modifierMask = 257023 /* ModifierFlags.All */ ^ 4 /* ModifierFlags.Public */; } + if (modifierAdditions === void 0) { modifierAdditions = 0 /* ModifierFlags.None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; - if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { + if (flags & 512 /* ModifierFlags.Default */ && !(flags & 1 /* ModifierFlags.Export */)) { // A non-exported default is a nonsequitor - we usually try to remove all export modifiers // from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid - flags ^= 1 /* Export */; + flags ^= 1 /* ModifierFlags.Export */; } - if (flags & 512 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) + if (flags & 512 /* ModifierFlags.Default */ && flags & 2 /* ModifierFlags.Ambient */) { + flags ^= 2 /* ModifierFlags.Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) } return flags; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 172 /* GetAccessor */ + return accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -110263,52 +110707,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return !ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */); + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 237 /* VariableStatement */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 254 /* VariableDeclaration */: - case 163 /* TypeParameter */: - case 228 /* ExpressionWithTypeArguments */: - case 178 /* TypeReference */: - case 189 /* ConditionalType */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 200 /* ImportType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 189 /* SyntaxKind.ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 200 /* SyntaxKind.ImportType */: return true; } return false; @@ -110366,35 +110810,35 @@ var ts; if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); } - if (languageVersion < 99 /* ESNext */) { + if (languageVersion < 99 /* ScriptTarget.ESNext */) { transformers.push(ts.transformESNext); } - if (languageVersion < 8 /* ES2021 */) { + if (languageVersion < 8 /* ScriptTarget.ES2021 */) { transformers.push(ts.transformES2021); } - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { transformers.push(ts.transformES2020); } - if (languageVersion < 6 /* ES2019 */) { + if (languageVersion < 6 /* ScriptTarget.ES2019 */) { transformers.push(ts.transformES2019); } - if (languageVersion < 5 /* ES2018 */) { + if (languageVersion < 5 /* ScriptTarget.ES2018 */) { transformers.push(ts.transformES2018); } - if (languageVersion < 4 /* ES2017 */) { + if (languageVersion < 4 /* ScriptTarget.ES2017 */) { transformers.push(ts.transformES2017); } - if (languageVersion < 3 /* ES2016 */) { + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { transformers.push(ts.transformES2016); } - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { transformers.push(ts.transformES5); } ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory)); @@ -110448,11 +110892,11 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(355 /* Count */); + var enabledSyntaxKindFeatures = new Array(355 /* SyntaxKind.Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; - var lexicalEnvironmentFlags = 0 /* None */; + var lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var lexicalEnvironmentStatementsStack = []; @@ -110465,7 +110909,7 @@ var ts; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; - var state = 0 /* Uninitialized */; + var state = 0 /* TransformationState.Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer // initialization. @@ -110495,13 +110939,13 @@ var ts; isEmitNotificationEnabled: isEmitNotificationEnabled, get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onEmitNode = value; }, @@ -110525,17 +110969,17 @@ var ts; return node; }; // prevent modification of transformation hooks. - state = 1 /* Initialized */; + state = 1 /* TransformationState.Initialized */; // Transform each node. var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 305 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "transformNodes", node.kind === 305 /* SyntaxKind.SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. - state = 2 /* Completed */; + state = 2 /* TransformationState.Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { @@ -110553,15 +110997,15 @@ var ts; * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 1 /* SyntaxKindFeatureFlags.Substitution */; } /** * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 - && (ts.getEmitFlags(node) & 4 /* NoSubstitution */) === 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* SyntaxKindFeatureFlags.Substitution */) !== 0 + && (ts.getEmitFlags(node) & 4 /* EmitFlags.NoSubstitution */) === 0; } /** * Emits a node with possible substitution. @@ -110571,23 +111015,23 @@ var ts; * @param emitCallback The callback used to emit the node or its substitute. */ function substituteNode(hint, node) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot substitute a node after the result is disposed."); return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 2 /* SyntaxKindFeatureFlags.EmitNotifications */; } /** * Determines whether before/after emit notifications should be raised in the pretty * printer when it emits a node. */ function isEmitNotificationEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (ts.getEmitFlags(node) & 2 /* AdviseOnEmitNode */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 2 /* SyntaxKindFeatureFlags.EmitNotifications */) !== 0 + || (ts.getEmitFlags(node) & 2 /* EmitFlags.AdviseOnEmitNode */) !== 0; } /** * Emits a node with possible emit notification. @@ -110597,7 +111041,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { // TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed // (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739) @@ -110613,26 +111057,26 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* NoNestedSourceMaps */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* EmitFlags.NoNestedSourceMaps */); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; } else { lexicalEnvironmentVariableDeclarations.push(decl); } - if (lexicalEnvironmentFlags & 1 /* InParameters */) { - lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */; + if (lexicalEnvironmentFlags & 1 /* LexicalEnvironmentFlags.InParameters */) { + lexicalEnvironmentFlags |= 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */; } } /** * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(func, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(func, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -110644,9 +111088,9 @@ var ts; * Adds an initialization statement to the top of the lexical environment. */ function addInitializationStatement(node) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(node, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(node, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentStatements) { lexicalEnvironmentStatements = [node]; } @@ -110659,8 +111103,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -110674,19 +111118,19 @@ var ts; lexicalEnvironmentVariableDeclarations = undefined; lexicalEnvironmentFunctionDeclarations = undefined; lexicalEnvironmentStatements = undefined; - lexicalEnvironmentFlags = 0 /* None */; + lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -110695,8 +111139,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || @@ -110708,7 +111152,7 @@ var ts; if (lexicalEnvironmentVariableDeclarations) { var statement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); if (!statements) { statements = [statement]; } @@ -110751,8 +111195,8 @@ var ts; * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. */ function startBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot start a block scope after transformation has completed."); blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; blockScopeStackOffset++; blockScopedVariableDeclarations = undefined; @@ -110761,12 +111205,12 @@ var ts; * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. */ function endBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot end a block scope after transformation has completed."); var statements = ts.some(blockScopedVariableDeclarations) ? [ factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* NodeFlags.Let */)) ] : undefined; blockScopeStackOffset--; blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; @@ -110780,8 +111224,8 @@ var ts; (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); } function requestEmitHelper(helper) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); if (helper.dependencies) { for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) { @@ -110792,14 +111236,14 @@ var ts; emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } function dispose() { - if (state < 3 /* Disposed */) { + if (state < 3 /* TransformationState.Disposed */) { // Clean up emit nodes on parse tree for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; @@ -110814,7 +111258,7 @@ var ts; onEmitNode = undefined; emitHelpers = undefined; // Prevent further use of the transformation result. - state = 3 /* Disposed */; + state = 3 /* TransformationState.Disposed */; } } } @@ -110853,7 +111297,7 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ function isBuildInfoFile(file) { - return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + return ts.fileExtensionIs(file, ".tsbuildinfo" /* Extension.TsBuildInfo */); } ts.isBuildInfoFile = isBuildInfoFile; /*@internal*/ @@ -110919,7 +111363,7 @@ var ts; ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : configFileExtensionLess; } - return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + return buildInfoExtensionLess + ".tsbuildinfo" /* Extension.TsBuildInfo */; } ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ @@ -110927,7 +111371,7 @@ var ts; var outPath = ts.outFile(options); var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; @@ -110936,7 +111380,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 306 /* Bundle */) { + if (sourceFile.kind === 306 /* SyntaxKind.Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -110944,7 +111388,7 @@ var ts; var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it var isJsonEmittedToSameLocation = isJsonFile && - ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; @@ -110958,11 +111402,11 @@ var ts; } /* @internal */ function getOutputExtension(fileName, options) { - return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : - options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : - ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : - ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : - ".js" /* Js */; + return ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) ? ".json" /* Extension.Json */ : + options.jsx === 1 /* JsxEmit.Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Extension.Jsx */, ".tsx" /* Extension.Tsx */]) ? ".jsx" /* Extension.Jsx */ : + ts.fileExtensionIsOneOf(fileName, [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ".mjs" /* Extension.Mjs */ : + ts.fileExtensionIsOneOf(fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ".cjs" /* Extension.Cjs */ : + ".js" /* Extension.Js */; } ts.getOutputExtension = getOutputExtension; function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) { @@ -110978,9 +111422,9 @@ var ts; function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { if (configFile.options.emitDeclarationOnly) return undefined; - var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options)); - return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? + return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* Comparison.EqualTo */ ? outputFileName : undefined; } @@ -111009,16 +111453,16 @@ var ts; return; var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -111087,7 +111531,7 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { @@ -111097,7 +111541,7 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) return jsFilePath; - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) continue; if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); @@ -111106,7 +111550,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ @@ -111122,7 +111566,6 @@ var ts; var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit; var bundleBuildInfo; var emitSkipped = false; - var exportedModulesFromDeclarationEmit; // Emit each output file enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile); @@ -111132,7 +111575,6 @@ var ts; diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList, - exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; @@ -111144,13 +111586,13 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { @@ -111195,7 +111637,7 @@ var ts; return; } // Make sure not to write js file and source map file if any of them cannot be written - if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) { + if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) { emitSkipped = true; return; } @@ -111224,7 +111666,7 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); if (bundleBuildInfo) @@ -111260,7 +111702,7 @@ var ts; noEmitHelpers: true, module: compilerOptions.module, target: compilerOptions.target, - sourceMap: compilerOptions.sourceMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, @@ -111280,17 +111722,13 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { - sourceMap: !forceDtsEmit && compilerOptions.declarationMap, + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, { + sourceMap: printerOptions.sourceMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) { - var sourceFile = declarationTransform.transformed[0]; - exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; - } } declarationTransform.dispose(); if (bundleBuildInfo) @@ -111298,7 +111736,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -111309,9 +111747,10 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) { + var sourceFileOrBundle = transform.transformed[0]; + var bundle = sourceFileOrBundle.kind === 306 /* SyntaxKind.Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -111336,14 +111775,14 @@ var ts; if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); sourceMapUrlPos = writer.getTextPos(); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); // Tools can sometimes see this line as a source mapping url comment } // Write the source map if (sourceMapFilePath) { var sourceMap = sourceMapGenerator.toString(); ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles); if (printer.bundleFileInfo) - printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); } } else { @@ -111351,17 +111790,17 @@ var ts; } // Write the output file var text = writer.getText(); - ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); + ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics }); // We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo // This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode if (printer.bundleFileInfo) - printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash)); // Reset state writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 305 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Extension.Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -111392,7 +111831,7 @@ var ts; // Encode the sourceMap into the sourceMap url var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -111485,8 +111924,8 @@ var ts; ts.setParent(literal, statement); return statement; }); - var eofToken = ts.factory.createToken(1 /* EndOfFileToken */); - var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* None */); + var eofToken = ts.factory.createToken(1 /* SyntaxKind.EndOfFileToken */); + var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* NodeFlags.None */); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : ""; ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0); @@ -111520,25 +111959,25 @@ var ts; if (!jsFileText) return jsFilePath; // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it - if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) + if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) return jsFilePath; var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); // error if no source map or for now if inline sourcemap if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) return sourceMapFilePath || "inline sourcemap decoding"; - if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) + if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) return sourceMapFilePath; // read declaration text var declarationText = declarationFilePath && host.readFile(declarationFilePath); if (declarationFilePath && !declarationText) return declarationFilePath; - if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) + if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) return declarationFilePath; var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); // error if no source map or for now if inline sourcemap if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) return declarationMapPath || "inline sourcemap decoding"; - if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) + if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) return declarationMapPath; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, @@ -111578,8 +112017,7 @@ var ts; newBuildInfo.program = buildInfo.program; if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) { // Update the output signature - newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash); - newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime(); + newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData); } // Update sourceFileInfo var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; @@ -111601,7 +112039,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -111654,7 +112092,7 @@ var ts; var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined; var recordInternalSection = printerOptions.recordInternalSection; var sourceFileTextPos = 0; - var sourceFileTextKind = "text" /* Text */; + var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -111694,20 +112132,20 @@ var ts; }; function printNode(hint, node, sourceFile) { switch (hint) { - case 0 /* SourceFile */: + case 0 /* EmitHint.SourceFile */: ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); break; - case 2 /* IdentifierName */: + case 2 /* EmitHint.IdentifierName */: ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); break; - case 1 /* Expression */: + case 1 /* EmitHint.Expression */: ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); break; } switch (node.kind) { - case 305 /* SourceFile */: return printFile(node); - case 306 /* Bundle */: return printBundle(node); - case 307 /* UnparsedSource */: return printUnparsedSource(node); + case 305 /* SyntaxKind.SourceFile */: return printFile(node); + case 306 /* SyntaxKind.Bundle */: return printBundle(node); + case 307 /* SyntaxKind.UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -111763,11 +112201,11 @@ var ts; currentSourceFile && (ts.isDeclaration(node) || ts.isVariableStatement(node)) && ts.isInternalDeclaration(node, currentSourceFile) && - sourceFileTextKind !== "internal" /* Internal */) { + sourceFileTextKind !== "internal" /* BundleFileSectionKind.Internal */) { var prevSourceFileTextKind = sourceFileTextKind; recordBundleFileTextLikeSection(writer.getTextPos()); sourceFileTextPos = getTextPosWithWriteLine(); - sourceFileTextKind = "internal" /* Internal */; + sourceFileTextKind = "internal" /* BundleFileSectionKind.Internal */; return prevSourceFileTextKind; } return undefined; @@ -111802,7 +112240,7 @@ var ts; var savedSections = bundleFileInfo && bundleFileInfo.sections; if (savedSections) bundleFileInfo.sections = []; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, prepend, /*sourceFile*/ undefined); if (bundleFileInfo) { var newSections = bundleFileInfo.sections; bundleFileInfo.sections = savedSections; @@ -111813,7 +112251,7 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), - kind: "prepend" /* Prepend */, + kind: "prepend" /* BundleFileSectionKind.Prepend */, data: relativeToBuildInfo(prepend.fileName), texts: newSections }); @@ -111823,7 +112261,7 @@ var ts; sourceFileTextPos = getTextPosWithWriteLine(); for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { var sourceFile = _e[_d]; - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); } if (bundleFileInfo && bundle.sourceFiles.length) { var end = writer.getTextPos(); @@ -111850,7 +112288,7 @@ var ts; function writeUnparsedSource(unparsed, output) { var previousWriter = writer; setWriter(output, /*_sourceMapGenerator*/ undefined); - print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } @@ -111860,7 +112298,7 @@ var ts; setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; } @@ -111899,7 +112337,7 @@ var ts; autoGeneratedIdToGeneratedName = []; generatedNames = new ts.Set(); tempFlagsStack = []; - tempFlags = 0 /* Auto */; + tempFlags = 0 /* TempFlags.Auto */; reservedNamesStack = []; currentSourceFile = undefined; currentLineMap = undefined; @@ -111913,24 +112351,24 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); + pipelineEmit(4 /* EmitHint.Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) return; - pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); + pipelineEmit(2 /* EmitHint.IdentifierName */, node, /*parenthesizerRule*/ undefined); } function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - pipelineEmit(1 /* Expression */, node, parenthesizerRule); + pipelineEmit(1 /* EmitHint.Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* EmitHint.JsxAttributeValue */ : 4 /* EmitHint.Unspecified */, node); } function beforeEmitNode(node) { - if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* EmitFlags.IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } } @@ -111939,7 +112377,7 @@ var ts; } function pipelineEmit(emitHint, node, parenthesizerRule) { currentParenthesizerRule = parenthesizerRule; - var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, emitHint, node); pipelinePhase(emitHint, node); currentParenthesizerRule = undefined; } @@ -111955,12 +112393,12 @@ var ts; } function getPipelinePhase(phase, emitHint, node) { switch (phase) { - case 0 /* Notification */: + case 0 /* PipelinePhase.Notification */: if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) { return pipelineEmitWithNotification; } // falls through - case 1 /* Substitution */: + case 1 /* PipelinePhase.Substitution */: if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { if (currentParenthesizerRule) { lastSubstitution = currentParenthesizerRule(lastSubstitution); @@ -111968,17 +112406,17 @@ var ts; return pipelineEmitWithSubstitution; } // falls through - case 2 /* Comments */: + case 2 /* PipelinePhase.Comments */: if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through - case 3 /* SourceMaps */: + case 3 /* PipelinePhase.SourceMaps */: if (shouldEmitSourceMaps(node)) { return pipelineEmitWithSourceMaps; } // falls through - case 4 /* Emit */: + case 4 /* PipelinePhase.Emit */: return pipelineEmitWithHint; default: return ts.Debug.assertNever(phase); @@ -111988,7 +112426,7 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); + var pipelinePhase = getNextPipelinePhase(0 /* PipelinePhase.Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { @@ -112014,346 +112452,346 @@ var ts; return emitSnippetNode(hint, node, snippet); } } - if (hint === 0 /* SourceFile */) + if (hint === 0 /* EmitHint.SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); - if (hint === 2 /* IdentifierName */) + if (hint === 2 /* EmitHint.IdentifierName */) return emitIdentifier(ts.cast(node, ts.isIdentifier)); - if (hint === 6 /* JsxAttributeValue */) + if (hint === 6 /* EmitHint.JsxAttributeValue */) return emitLiteral(ts.cast(node, ts.isStringLiteral), /*jsxAttributeEscape*/ true); - if (hint === 3 /* MappedTypeParameter */) + if (hint === 3 /* EmitHint.MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); - if (hint === 5 /* EmbeddedStatement */) { + if (hint === 5 /* EmitHint.EmbeddedStatement */) { ts.Debug.assertNode(node, ts.isEmptyStatement); return emitEmptyStatement(/*isEmbeddedStatement*/ true); } - if (hint === 4 /* Unspecified */) { + if (hint === 4 /* EmitHint.Unspecified */) { switch (node.kind) { // Pseudo-literals - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return emitQualifiedName(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return emitTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return emitParameter(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return emitDecorator(node); // Type members - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return emitPropertySignature(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return emitPropertyDeclaration(node); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return emitMethodSignature(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return emitMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return emitClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return emitConstructor(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return emitAccessorDeclaration(node); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return emitCallSignature(node); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return emitConstructSignature(node); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return emitIndexSignature(node); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return emitTypePredicate(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return emitTypeReference(node); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return emitFunctionType(node); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return emitConstructorType(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return emitTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return emitTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return emitArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return emitTupleType(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return emitUnionType(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return emitIntersectionType(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return emitConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return emitInferType(node); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return emitParenthesizedType(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return emitThisType(); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return emitTypeOperator(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return emitIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return emitMappedType(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return emitLiteralType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return emitNamedTupleMember(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return emitTemplateType(node); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return emitImportTypeNode(node); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return emitBindingElement(node); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return emitTemplateSpan(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return emitBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return emitVariableStatement(node); - case 236 /* EmptyStatement */: + case 236 /* SyntaxKind.EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return emitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return emitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return emitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return emitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return emitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return emitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return emitForOfStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return emitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return emitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return emitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return emitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return emitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return emitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return emitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return emitTryStatement(node); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return emitVariableDeclaration(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return emitVariableDeclarationList(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return emitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return emitClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return emitEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return emitModuleDeclaration(node); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return emitModuleBlock(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return emitCaseBlock(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return emitImportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return emitImportClause(node); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return emitNamespaceImport(node); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return emitNamespaceExport(node); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: return emitNamedImports(node); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return emitImportSpecifier(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return emitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return emitExportDeclaration(node); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: return emitNamedExports(node); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return emitExportSpecifier(node); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return emitAssertClause(node); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return emitAssertEntry(node); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return; // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return emitJsxText(node); - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 281 /* JsxClosingElement */: - case 284 /* JsxClosingFragment */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 284 /* SyntaxKind.JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return emitJsxAttribute(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return emitJsxAttributes(node); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return emitJsxExpression(node); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return emitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return emitDefaultClause(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return emitHeritageClause(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return emitCatchClause(node); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return emitPropertyAssignment(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return emitEnumMember(node); // Unparsed - case 300 /* UnparsedPrologue */: + case 300 /* SyntaxKind.UnparsedPrologue */: return writeUnparsedNode(node); - case 307 /* UnparsedSource */: - case 301 /* UnparsedPrepend */: + case 307 /* SyntaxKind.UnparsedSource */: + case 301 /* SyntaxKind.UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return emitUnparsedTextLike(node); - case 304 /* UnparsedSyntheticReference */: + case 304 /* SyntaxKind.UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return emitSourceFile(node); - case 306 /* Bundle */: + case 306 /* SyntaxKind.Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 308 /* InputFiles */: + case 308 /* SyntaxKind.InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return emitJSDocNameReference(node); - case 312 /* JSDocAllType */: + case 312 /* SyntaxKind.JSDocAllType */: return writePunctuation("*"); - case 313 /* JSDocUnknownType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return writePunctuation("?"); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return emitJSDocNullableType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return emitJSDocOptionalType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return emitJSDocFunctionType(node); - case 186 /* RestType */: - case 318 /* JSDocVariadicType */: + case 186 /* SyntaxKind.RestType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 319 /* JSDocNamepathType */: + case 319 /* SyntaxKind.JSDocNamepathType */: return; - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return emitJSDoc(node); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return emitJSDocSignature(node); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 337 /* JSDocOverrideTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 337 /* SyntaxKind.JSDocOverrideTag */: return emitJSDocSimpleTag(node); - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 330 /* JSDocAuthorTag */: - case 331 /* JSDocDeprecatedTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: return; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 339 /* JSDocEnumTag */: - case 341 /* JSDocReturnTag */: - case 342 /* JSDocThisTag */: - case 343 /* JSDocTypeTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 349 /* NotEmittedStatement */: - case 353 /* EndOfDeclarationMarker */: - case 352 /* MergeDeclarationMarker */: + case 349 /* SyntaxKind.NotEmittedStatement */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { - hint = 1 /* Expression */; + hint = 1 /* EmitHint.Expression */; if (substituteNode !== ts.noEmitSubstitution) { var substitute = substituteNode(hint, node) || node; if (substitute !== node) { @@ -112365,101 +112803,101 @@ var ts; } } } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { switch (node.kind) { // Literals - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return emitNumericOrBigIntLiteral(node); - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Expressions - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return emitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return emitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return emitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return emitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return emitArrowFunction(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return emitDeleteExpression(node); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return emitTypeOfExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return emitVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return emitAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return emitBinaryExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return emitConditionalExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return emitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return emitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return emitSpreadElement(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return emitClassExpression(node); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return emitAsExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return emitNonNullExpression(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return emitMetaProperty(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return emitJsxElement(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 349 /* NotEmittedStatement */: + case 349 /* SyntaxKind.NotEmittedStatement */: return; - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return emitCommaList(node); - case 352 /* MergeDeclarationMarker */: - case 353 /* EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return; - case 354 /* SyntheticReferenceExpression */: + case 354 /* SyntaxKind.SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -112467,7 +112905,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -112477,7 +112915,7 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); + var pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, hint, node); ts.Debug.assertIsDefined(lastSubstitution); node = lastSubstitution; lastSubstitution = undefined; @@ -112507,7 +112945,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 306 /* Bundle */ ? node : undefined; + var bundle = node.kind === 306 /* SyntaxKind.Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -112549,7 +112987,7 @@ var ts; writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* BundleFileSectionKind.EmitHelpers */, data: helper.name }); helpersEmitted = true; } } @@ -112577,7 +113015,7 @@ var ts; function emitLiteral(node, jsxAttributeEscape) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* SyntaxKind.StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -112607,9 +113045,9 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* SyntaxKind.UnparsedText */ ? + "text" /* BundleFileSectionKind.Text */ : + "internal" /* BundleFileSectionKind.Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -112628,25 +113066,25 @@ var ts; // function emitSnippetNode(hint, node, snippet) { switch (snippet.kind) { - case 1 /* Placeholder */: + case 1 /* SnippetKind.Placeholder */: emitPlaceholder(hint, node, snippet); break; - case 0 /* TabStop */: + case 0 /* SnippetKind.TabStop */: emitTabStop(hint, node, snippet); break; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); // `${2:` + nonEscapingWrite("${".concat(snippet.order, ":")); // `${2:` pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` nonEscapingWrite("}"); // `}` // `${2:...}` } function emitTabStop(hint, node, snippet) { // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text. - ts.Debug.assert(node.kind === 236 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); - ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + ts.Debug.assert(node.kind === 236 /* SyntaxKind.EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); + ts.Debug.assert(hint !== 5 /* EmitHint.EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); + nonEscapingWrite("$".concat(snippet.order)); } // // Identifiers @@ -112654,7 +113092,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* ListFormat.TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -112669,7 +113107,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112705,7 +113143,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 317 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -112766,7 +113204,7 @@ var ts; } function emitAccessorDeclaration(node) { emitDecoratorsAndModifiers(node, node.modifiers); - writeKeyword(node.kind === 172 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 172 /* SyntaxKind.GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -112871,8 +113309,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineTypeLiteralMembers */ : 32897 /* ListFormat.MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* ListFormat.NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -112885,16 +113323,16 @@ var ts; emit(node.type); } function emitTupleType(node) { - emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */; - emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); - emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.pos, writePunctuation, node); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 528 /* ListFormat.SingleLineTupleTypeElements */ : 657 /* ListFormat.MultiLineTupleTypeElements */; + emitList(node, node.elements, flags | 524288 /* ListFormat.NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.elements.end, writePunctuation, node); } function emitNamedTupleMember(node) { emit(node.dotDotDotToken); emit(node.name); emit(node.questionToken); - emitTokenWithComment(58 /* ColonToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.name.end, writePunctuation, node); writeSpace(); emit(node.type); } @@ -112903,10 +113341,10 @@ var ts; writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); + emitList(node, node.types, 516 /* ListFormat.UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); + emitList(node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); } function emitConditionalType(node) { emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType); @@ -112939,7 +113377,7 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ? + var parenthesizerRule = node.operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizer.parenthesizeOperandOfReadonlyTypeOperator : parenthesizer.parenthesizeOperandOfTypeOperator; emit(node.type, parenthesizerRule); @@ -112953,7 +113391,7 @@ var ts; function emitMappedType(node) { var emitFlags = ts.getEmitFlags(node); writePunctuation("{"); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { @@ -112962,13 +113400,13 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 145 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* EmitHint.MappedTypeParameter */, node.typeParameter); if (node.nameType) { writeSpace(); writeKeyword("as"); @@ -112978,7 +113416,7 @@ var ts; writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 57 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { writePunctuation("?"); } } @@ -112986,14 +113424,14 @@ var ts; writeSpace(); emit(node.type); writeTrailingSemicolon(); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { writeLine(); decreaseIndent(); } - emitList(node, node.members, 2 /* PreserveLines */); + emitList(node, node.members, 2 /* ListFormat.PreserveLines */); writePunctuation("}"); } function emitLiteralType(node) { @@ -113001,7 +113439,7 @@ var ts; } function emitTemplateType(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitImportTypeNode(node) { if (node.isTypeOf) { @@ -113020,7 +113458,7 @@ var ts; writePunctuation(":"); writeSpace(); var elements = node.assertions.assertClause.elements; - emitList(node.assertions.assertClause, elements, 526226 /* ImportClauseEntries */); + emitList(node.assertions.assertClause, elements, 526226 /* ListFormat.ImportClauseEntries */); writeSpace(); writePunctuation("}"); } @@ -113036,12 +113474,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ListFormat.ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ListFormat.ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -113059,29 +113497,29 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + emitExpressionList(node, elements, 8914 /* ListFormat.ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ScriptTarget.ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* ListFormat.AllowTrailingComma */ : 0 /* ListFormat.None */; + emitList(node, node.properties, 526226 /* ListFormat.ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); } } function emitPropertyAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); - var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos); + var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* SyntaxKind.DotToken */), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + var shouldEmitDotDot = token.kind !== 28 /* SyntaxKind.QuestionDotToken */ && mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); @@ -113107,7 +113545,7 @@ var ts; var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true, /*jsxAttributeEscape*/ false); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* SyntaxKind.DotToken */)); } else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer @@ -113120,12 +113558,12 @@ var ts; function emitElementAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); - emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -113138,17 +113576,17 @@ var ts; } emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* SyntaxKind.NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 18960 /* ListFormat.NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -113170,12 +113608,12 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); - emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -113193,22 +113631,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* SyntaxKind.DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* SyntaxKind.TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* SyntaxKind.VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(132 /* SyntaxKind.AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -113233,9 +113671,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 219 /* PrefixUnaryExpression */ - && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) - || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); + return operand.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ + && ((node.operator === 39 /* SyntaxKind.PlusToken */ && (operand.operator === 39 /* SyntaxKind.PlusToken */ || operand.operator === 45 /* SyntaxKind.PlusPlusToken */)) + || (node.operator === 40 /* SyntaxKind.MinusToken */ && (operand.operator === 40 /* SyntaxKind.MinusToken */ || operand.operator === 46 /* SyntaxKind.MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); @@ -113276,12 +113714,12 @@ var ts; return maybeEmitExpression(next, parent, "left"); } function onOperator(operatorToken, _state, node) { - var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */; + var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken); var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(operatorToken.pos); - writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); } @@ -113312,11 +113750,11 @@ var ts; var parenthesizerRule = side === "left" ? parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, 1 /* EmitHint.Expression */, next); if (pipelinePhase === pipelineEmitWithSubstitution) { ts.Debug.assertIsDefined(lastSubstitution); next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); - pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, 1 /* EmitHint.Expression */, next); lastSubstitution = undefined; } if (pipelinePhase === pipelineEmitWithComments || @@ -113327,7 +113765,7 @@ var ts; } } currentParenthesizerRule = parenthesizerRule; - pipelinePhase(1 /* Expression */, next); + pipelinePhase(1 /* EmitHint.Expression */, next); } } function emitConditionalExpression(node) { @@ -113349,15 +113787,15 @@ var ts; } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* SyntaxKind.YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma); } function emitSpreadElement(node) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { @@ -113400,10 +113838,10 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineBlockStatements */ : 129 /* ListFormat.MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* ListFormat.MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -113429,16 +113867,16 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SyntaxKind.IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 239 /* IfStatement */) { + emitTokenWithComment(91 /* SyntaxKind.ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 239 /* SyntaxKind.IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -113448,14 +113886,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* SyntaxKind.WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* SyntaxKind.DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -113471,45 +113909,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* SyntaxKind.InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(160 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(160 /* SyntaxKind.OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { emit(node); } else { @@ -113518,12 +113956,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* SyntaxKind.ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* SyntaxKind.BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -113546,13 +113984,13 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 288 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function commentWillEmitNewLine(node) { - return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; + return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; } function willEmitLeadingNewLine(node) { if (!currentSourceFile) @@ -113592,40 +114030,40 @@ var ts; return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node)); } function emitReturnStatement(node) { - emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* SyntaxKind.ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* SyntaxKind.WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SyntaxKind.SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* SyntaxKind.ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* SyntaxKind.TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -113634,13 +114072,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* SyntaxKind.FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* SyntaxKind.DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -113656,7 +114094,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 528 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* ListFormat.VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -113673,7 +114111,7 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } @@ -113710,7 +114148,7 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (ts.getEmitFlags(body) & 1 /* SingleLine */) { + if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) { return true; } if (body.multiLine) { @@ -113719,14 +114157,14 @@ var ts; if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (getLeadingLineTerminatorCount(body, ts.firstOrUndefined(body.statements), 2 /* PreserveLines */) - || getClosingLineTerminatorCount(body, ts.lastOrUndefined(body.statements), 2 /* PreserveLines */, body.statements)) { + if (getLeadingLineTerminatorCount(body, ts.firstOrUndefined(body.statements), 2 /* ListFormat.PreserveLines */) + || getClosingLineTerminatorCount(body, ts.lastOrUndefined(body.statements), 2 /* ListFormat.PreserveLines */, body.statements)) { return false; } var previousStatement; for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { var statement = _b[_a]; - if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) { + if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) { return false; } previousStatement = statement; @@ -113743,7 +114181,7 @@ var ts; : emitBlockFunctionBodyWorker; emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); - writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* SyntaxKind.CloseBraceToken */, body.statements.end, writePunctuation, body); onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { @@ -113756,11 +114194,11 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* ListFormat.SingleLineFunctionBodyStatements */); increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); + emitList(body, body.statements, 1 /* ListFormat.MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -113774,15 +114212,15 @@ var ts; writeSpace(); emitIdentifierName(node.name); } - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); + emitList(node, node.heritageClauses, 0 /* ListFormat.ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* ClassMembers */); + emitList(node, node.members, 129 /* ListFormat.ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -113794,10 +114232,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 512 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* ListFormat.HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* InterfaceMembers */); + emitList(node, node.members, 129 /* ListFormat.InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -113819,13 +114257,13 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 145 /* EnumMembers */); + emitList(node, node.members, 145 /* ListFormat.EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 1024 /* GlobalAugmentation */) { - writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); + if (~node.flags & 1024 /* NodeFlags.GlobalAugmentation */) { + writeKeyword(node.flags & 16 /* NodeFlags.Namespace */ ? "namespace" : "module"); writeSpace(); } emit(node.name); @@ -113847,27 +114285,27 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 129 /* CaseBlockClauses */); - emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* ListFormat.CaseBlockClauses */); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -113876,12 +114314,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(156 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -113892,20 +114330,20 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -113916,37 +114354,37 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression, node.isExportEquals ? - parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* SyntaxKind.EqualsToken */) : parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(152 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(156 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -113956,10 +114394,10 @@ var ts; writeTrailingSemicolon(); } function emitAssertClause(node) { - emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(129 /* SyntaxKind.AssertKeyword */, node.pos, writeKeyword, node); writeSpace(); var elements = node.elements; - emitList(node, elements, 526226 /* ImportClauseEntries */); + emitList(node, elements, 526226 /* ListFormat.ImportClauseEntries */); } function emitAssertEntry(node) { emit(node.name); @@ -113967,26 +114405,26 @@ var ts; writeSpace(); var value = node.value; /** @see {emitPropertyAssignment} */ - if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(value) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(value); emitTrailingCommentsOfPosition(commentRange.pos); } emit(value); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(142 /* SyntaxKind.NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); } function emitNamespaceExport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -113998,7 +114436,7 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { @@ -114009,7 +114447,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -114028,7 +114466,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -114041,7 +114479,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -114070,7 +114508,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 262656 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* ListFormat.JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -114101,17 +114539,17 @@ var ts; if (isMultiline) { writer.increaseIndent(); } - var end = emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + var end = emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); emit(node.dotDotDotToken); emitExpression(node.expression); - emitTokenWithComment(19 /* CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); if (isMultiline) { writer.decreaseIndent(); } } } function emitJsxTagName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -114122,13 +114560,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* SyntaxKind.CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -114139,14 +114577,14 @@ var ts; ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 163969 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* ListFormat.CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 128 /* Indented */); + format &= ~(1 /* ListFormat.MultiLine */ | 128 /* ListFormat.Indented */); } else { - emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -114154,15 +114592,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 528 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* ListFormat.HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* SyntaxKind.CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -114182,7 +114620,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(initializer) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -114199,7 +114637,7 @@ var ts; } function emitSpreadAssignment(node) { if (node.expression) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } @@ -114230,12 +114668,12 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 343 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 343 /* SyntaxKind.JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } else { - emitList(node, node.tags, 33 /* JSDocComment */); + emitList(node, node.tags, 33 /* ListFormat.JSDocComment */); } } writeSpace(); @@ -114269,13 +114707,13 @@ var ts; emitJSDocTagName(tag.tagName); emitJSDocTypeExpression(tag.constraint); writeSpace(); - emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitList(tag, tag.typeParameters, 528 /* ListFormat.CommaListElements */); emitJSDocComment(tag.comment); } function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 309 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -114294,7 +114732,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 322 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 322 /* SyntaxKind.JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -114312,14 +114750,14 @@ var ts; emitJSDocComment(tag.comment); } function emitJSDocTypeLiteral(lit) { - emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* ListFormat.JSDocComment */); } function emitJSDocSignature(sig) { if (sig.typeParameters) { - emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* ListFormat.JSDocComment */); } if (sig.parameters) { - emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* ListFormat.JSDocComment */); } if (sig.type) { writeLine(); @@ -114400,21 +114838,21 @@ var ts; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -114422,28 +114860,28 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* BundleFileSectionKind.Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_23 = types; _d < types_23.length; _d++) { var directive = types_23[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* BundleFileSectionKind.Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */ : "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* BundleFileSectionKind.Lib */, data: directive.fileName }); writeLine(); } } @@ -114454,22 +114892,22 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* ListFormat.MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes function emitPartiallyEmittedExpression(node) { var emitFlags = ts.getEmitFlags(node); - if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) { + if (!(emitFlags & 512 /* EmitFlags.NoLeadingComments */) && node.pos !== node.expression.pos) { emitTrailingCommentsOfPosition(node.expression.pos); } emitExpression(node.expression); - if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) { + if (!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */) && node.end !== node.expression.end) { emitLeadingCommentsOfPosition(node.expression.end); } } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); + emitExpressionList(node, node.elements, 528 /* ListFormat.CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -114490,7 +114928,7 @@ var ts; var pos = writer.getTextPos(); emit(statement); if (recordBundleFileSection && bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.add(statement.expression.text); } @@ -114511,7 +114949,7 @@ var ts; var pos = writer.getTextPos(); emit(prologue); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: prologue.data }); if (seenPrologueDirectives) { seenPrologueDirectives.add(prologue.data); } @@ -114635,7 +115073,7 @@ var ts; textRange.pos = modifiers.pos; if (pos === modifiers.length - 1) textRange.end = modifiers.end; - emitNodeListItems(emit, node, modifiers, lastMode === "modifiers" ? 2359808 /* Modifiers */ : 2146305 /* Decorators */, + emitNodeListItems(emit, node, modifiers, lastMode === "modifiers" ? 2359808 /* ListFormat.Modifiers */ : 2146305 /* ListFormat.Decorators */, /*parenthesizerRule*/ undefined, start, pos - start, /*hasTrailingComma*/ false, textRange); start = pos; @@ -114646,7 +115084,7 @@ var ts; } } function emitModifiers(node, modifiers) { - emitList(node, modifiers, 2359808 /* Modifiers */); + emitList(node, modifiers, 2359808 /* ListFormat.Modifiers */); } function emitTypeAnnotation(node) { if (node) { @@ -114658,7 +115096,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node, parenthesizerRule); } @@ -114688,7 +115126,7 @@ var ts; } } function emitEmbeddedStatement(parent, node) { - if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* EmitFlags.SingleLine */) { writeSpace(); emit(node); } @@ -114696,7 +115134,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - pipelineEmit(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmitHint.EmbeddedStatement */, node); } else { emit(node); @@ -114705,19 +115143,19 @@ var ts; } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 2146305 /* Decorators */); + emitList(parentNode, decorators, 2146305 /* ListFormat.Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector); + emitList(parentNode, typeArguments, 53776 /* ListFormat.TypeArguments */, typeArgumentParenthesizerRuleSelector); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures return emitTypeArguments(parentNode, parentNode.typeArguments); } - emitList(parentNode, typeParameters, 53776 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* ListFormat.TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 2576 /* Parameters */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -114736,32 +115174,32 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */ & ~2048 /* ListFormat.Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* ListFormat.IndexSignatureParameters */); } function writeDelimiter(format) { - switch (format & 60 /* DelimitersMask */) { - case 0 /* None */: + switch (format & 60 /* ListFormat.DelimitersMask */) { + case 0 /* ListFormat.None */: break; - case 16 /* CommaDelimited */: + case 16 /* ListFormat.CommaDelimited */: writePunctuation(","); break; - case 4 /* BarDelimited */: + case 4 /* ListFormat.BarDelimited */: writeSpace(); writePunctuation("|"); break; - case 32 /* AsteriskDelimited */: + case 32 /* ListFormat.AsteriskDelimited */: writeSpace(); writePunctuation("*"); writeSpace(); break; - case 8 /* AmpersandDelimited */: + case 8 /* ListFormat.AmpersandDelimited */: writeSpace(); writePunctuation("&"); break; @@ -114777,16 +115215,16 @@ var ts; if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; - if (isUndefined && format & 16384 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* ListFormat.OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 32768 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* ListFormat.OptionalIfEmpty */) { onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); return; } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists @@ -114795,10 +115233,10 @@ var ts; onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { + if (format & 1 /* ListFormat.MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } - else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */ && !(format & 524288 /* ListFormat.NoSpaceIfEmpty */)) { writeSpace(); } } @@ -114806,7 +115244,7 @@ var ts; emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, children.hasTrailingComma, children); } onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } @@ -114820,18 +115258,18 @@ var ts; */ function emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, hasTrailingComma, childrenTextRange) { // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* ListFormat.NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format); if (leadingLineTerminatorCount) { writeLine(leadingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (format & 256 /* SpaceBetweenBraces */) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { increaseIndent(); } var emitListItem = getEmitListItem(emit, parenthesizerRule); @@ -114842,7 +115280,7 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. - if (format & 32 /* AsteriskDelimited */) { + if (format & 32 /* ListFormat.AsteriskDelimited */) { // always write JSDoc in the format "\n *" writeLine(); writeDelimiter(format); @@ -114854,7 +115292,7 @@ var ts; // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + if (format & 60 /* ListFormat.DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -114864,14 +115302,14 @@ var ts; if (separatingLineTerminatorCount > 0) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* ListFormat.LinesMask */ | 128 /* ListFormat.Indented */)) === 0 /* ListFormat.SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(separatingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* ListFormat.SpaceBetweenSiblings */) { writeSpace(); } } @@ -114894,11 +115332,11 @@ var ts; } // Write a trailing comma, if requested. var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; - var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* NoTrailingComments */); - var emitTrailingComma = hasTrailingComma && (format & 64 /* AllowTrailingComma */) && (format & 16 /* CommaDelimited */); + var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */); + var emitTrailingComma = hasTrailingComma && (format & 64 /* ListFormat.AllowTrailingComma */) && (format & 16 /* ListFormat.CommaDelimited */); if (emitTrailingComma) { if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(27 /* CommaToken */, previousSibling.end, writePunctuation, previousSibling); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, previousSibling.end, writePunctuation, previousSibling); } else { writePunctuation(","); @@ -114910,11 +115348,11 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* ListFormat.DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(emitTrailingComma && (childrenTextRange === null || childrenTextRange === void 0 ? void 0 : childrenTextRange.end) ? childrenTextRange.end : previousSibling.end); } // Decrease the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { decreaseIndent(); } recordBundleFileInternalSectionEnd(previousSourceFileTextKind); @@ -114923,7 +115361,7 @@ var ts; if (closingLineTerminatorCount) { writeLine(closingLineTerminatorCount); } - else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) { + else if (format & (2097152 /* ListFormat.SpaceAfterList */ | 256 /* ListFormat.SpaceBetweenBraces */)) { writeSpace(); } } @@ -115005,7 +115443,7 @@ var ts; return pos < 0 ? pos : pos + tokenString.length; } function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) { - if (ts.getEmitFlags(parentNode) & 1 /* SingleLine */) { + if (ts.getEmitFlags(parentNode) & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else if (preserveSourceNewlines) { @@ -115055,8 +115493,8 @@ var ts; } } function getLeadingLineTerminatorCount(parentNode, firstChild, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } if (firstChild === undefined) { @@ -115080,7 +115518,7 @@ var ts; // leading newline to start the modifiers. return 0; } - if (firstChild.kind === 11 /* JsxText */) { + if (firstChild.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } @@ -115097,14 +115535,14 @@ var ts; return 1; } } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { if (previousNode === undefined || nextNode === undefined) { return 0; } - if (nextNode.kind === 11 /* JsxText */) { + if (nextNode.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } @@ -115122,7 +115560,7 @@ var ts; } // If the two nodes are not comparable, add a line terminator based on the format that can indicate // whether new lines are preferred or not. - return format & 65536 /* PreferNewLine */ ? 1 : 0; + return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -115131,11 +115569,11 @@ var ts; else if (ts.getStartsOnNewLine(nextNode)) { return 1; } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getClosingLineTerminatorCount(parentNode, lastChild, format, childrenTextRange) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } if (lastChild === undefined) { @@ -115152,7 +115590,7 @@ var ts; return 1; } } - if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) { + if (format & 1 /* ListFormat.MultiLine */ && !(format & 131072 /* ListFormat.NoTrailingNewLine */)) { return 1; } return 0; @@ -115181,14 +115619,14 @@ var ts; return lines; } function writeLineSeparatorsAndIndentBefore(node, parent) { - var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, 0 /* None */); + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, 0 /* ListFormat.None */); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false); } return !!leadingNewlines; } function writeLineSeparatorsAfter(node, parent) { - var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, 0 /* None */, /*childrenTextRange*/ undefined); + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, 0 /* ListFormat.None */, /*childrenTextRange*/ undefined); if (trailingNewlines) { writeLine(trailingNewlines); } @@ -115197,14 +115635,14 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } function getLinesBetweenNodes(parent, node1, node2) { - if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + if (ts.getEmitFlags(parent) & 131072 /* EmitFlags.NoIndentation */) { return 0; } parent = skipSynthesizedParentheses(parent); @@ -115227,7 +115665,7 @@ var ts; && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node) { - while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -115255,29 +115693,29 @@ var ts; return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) { - if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); } } - var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0) - | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0) - | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0) - | (printerOptions.target && printerOptions.target === 99 /* ESNext */ ? 8 /* AllowNumericSeparator */ : 0); + var flags = (neverAsciiEscape ? 1 /* GetLiteralTextFlags.NeverAsciiEscape */ : 0) + | (jsxAttributeEscape ? 2 /* GetLiteralTextFlags.JsxAttributeEscape */ : 0) + | (printerOptions.terminateUnterminatedLiterals ? 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ : 0) + | (printerOptions.target && printerOptions.target === 99 /* ScriptTarget.ESNext */ ? 8 /* GetLiteralTextFlags.AllowNumericSeparator */ : 0); return ts.getLiteralText(node, currentSourceFile, flags); } /** * Push a new name generation scope. */ function pushNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlagsStack.push(tempFlags); @@ -115288,7 +115726,7 @@ var ts; * Pop the current name generation scope. */ function popNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlags = tempFlagsStack.pop(); @@ -115304,84 +115742,84 @@ var ts; if (!node) return; switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.forEach(node.statements, generateNames); break; - case 250 /* LabeledStatement */: - case 248 /* WithStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: generateNames(node.statement); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: generateNames(node.caseBlock); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: generateNames(node.declarationList); break; - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: generateNameIfNeeded(node.name); - if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: generateNames(node.importClause); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: generateNameIfNeeded(node.name); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: generateNameIfNeeded(node.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.forEach(node.elements, generateNames); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -115390,12 +115828,12 @@ var ts; if (!node) return; switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -115414,7 +115852,7 @@ var ts; * Generate the text for a generated identifier. */ function generateName(name) { - if ((name.autoGenerateFlags & 7 /* KindMask */) === 4 /* Node */) { + if ((name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) === 4 /* GeneratedIdentifierFlags.Node */) { // Node names generate unique names based on their original node // and are cached based on that node's id. return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags); @@ -115453,7 +115891,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */)) { return false; } } @@ -115467,7 +115905,7 @@ var ts; */ function makeTempVariableName(flags, reservedInNestedScopes) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + var name = flags === 268435456 /* TempFlags._i */ ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; if (reservedInNestedScopes) { @@ -115477,12 +115915,12 @@ var ts; } } while (true) { - var count = tempFlags & 268435455 /* CountMask */; + var count = tempFlags & 268435455 /* TempFlags.CountMask */; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { var name = count < 26 - ? "_" + String.fromCharCode(97 /* a */ + count) + ? "_" + String.fromCharCode(97 /* CharacterCodes.a */ + count) : "_" + (count - 26); if (isUniqueName(name)) { if (reservedInNestedScopes) { @@ -115514,7 +115952,7 @@ var ts; } } // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* CharacterCodes._ */) { baseName += "_"; } var i = 1; @@ -115568,48 +116006,48 @@ var ts; if (ts.isIdentifier(node.name)) { return generateNameCached(node.name); } - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } /** * Generates a unique name from a node. */ function generateNameForNode(node, flags) { switch (node.kind) { - case 79 /* Identifier */: - return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: + case 79 /* SyntaxKind.Identifier */: + return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(flags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return generateNameForExportDefault(); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return generateNameForClassExpression(); - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return generateNameForMethodOrAccessor(node); - case 162 /* ComputedPropertyName */: - return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); + case 162 /* SyntaxKind.ComputedPropertyName */: + return makeTempVariableName(0 /* TempFlags.Auto */, /*reserveInNestedScopes*/ true); default: - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } } /** * Generates a unique identifier for a node. */ function makeName(name) { - switch (name.autoGenerateFlags & 7 /* KindMask */) { - case 1 /* Auto */: - return makeTempVariableName(0 /* Auto */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 2 /* Loop */: - return makeTempVariableName(268435456 /* _i */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 3 /* Unique */: - return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); + switch (name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) { + case 1 /* GeneratedIdentifierFlags.Auto */: + return makeTempVariableName(0 /* TempFlags.Auto */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 2 /* GeneratedIdentifierFlags.Loop */: + return makeTempVariableName(268435456 /* TempFlags._i */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 3 /* GeneratedIdentifierFlags.Unique */: + return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* GeneratedIdentifierFlags.FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); } return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -115625,7 +116063,7 @@ var ts; // if "node" is a different generated name (having a different // "autoGenerateId"), use it and stop traversing. if (ts.isIdentifier(node) - && !!(node.autoGenerateFlags & 4 /* Node */) + && !!(node.autoGenerateFlags & 4 /* GeneratedIdentifierFlags.Node */) && node.autoGenerateId !== autoGenerateId) { break; } @@ -115636,7 +116074,7 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var pipelinePhase = getNextPipelinePhase(2 /* PipelinePhase.Comments */, hint, node); var savedContainerPos = containerPos; var savedContainerEnd = containerEnd; var savedDeclarationListContainerEnd = declarationListContainerEnd; @@ -115649,7 +116087,7 @@ var ts; var commentRange = ts.getCommentRange(node); // Emit leading comments emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = true; } } @@ -115657,7 +116095,7 @@ var ts; var emitFlags = ts.getEmitFlags(node); var commentRange = ts.getCommentRange(node); // Emit trailing comments - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = false; } emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); @@ -115671,25 +116109,25 @@ var ts; hasWrittenComment = false; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; // Save current container state on the stack. if ((pos > 0 || end > 0) && pos !== end) { // Emit leading comments if the position is not synthesized and the node // has not opted out from emitting leading comments. if (!skipLeadingComments) { - emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */); } - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. containerPos = pos; } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* NoTrailingComments */) !== 0)) { + if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) { // As above. containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -115699,7 +116137,7 @@ var ts; } function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -115708,18 +116146,18 @@ var ts; declarationListContainerEnd = savedDeclarationListContainerEnd; // Emit trailing comments if the position is not synthesized and the node // has not opted out from emitting leading comments and is an emitted node. - if (!skipTrailingComments && node.kind !== 349 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 349 /* SyntaxKind.NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); } function emitLeadingSynthesizedComment(comment) { - if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasLeadingNewline || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasTrailingNewLine || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } else { @@ -115737,25 +116175,25 @@ var ts; } function writeSynthesizedComment(comment) { var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + var lineMap = comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); } function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; + return comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); var pos = detachedRange.pos, end = detachedRange.end; var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0; + var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0; if (!skipLeadingComments) { emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); } exitComment(); - if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */ && !commentsDisabled) { commentsDisabled = true; emitCallback(node); commentsDisabled = false; @@ -115844,7 +116282,7 @@ var ts; if (hasTrailingNewLine) { writer.writeLine(); } - else if (kind === 3 /* MultiLineCommentTrivia */) { + else if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { writer.writeSpace(" "); } } @@ -115886,7 +116324,7 @@ var ts; emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); - if (kind === 2 /* SingleLineCommentTrivia */) { + if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); // still write a newline for single-line comments, so closing tokens aren't written on the same line } } @@ -115971,7 +116409,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMaps(hint, node) { - var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); + var pipelinePhase = getNextPipelinePhase(3 /* PipelinePhase.SourceMaps */, hint, node); emitSourceMapsBeforeNode(node); pipelinePhase(hint, node); emitSourceMapsAfterNode(node); @@ -115989,12 +116427,12 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 16 /* EmitFlags.NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = true; } } @@ -116004,11 +116442,11 @@ var ts; var sourceMapRange = ts.getSourceMapRange(node); // Emit trailing sourcemap if (!ts.isUnparsedNode(node)) { - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 32 /* EmitFlags.NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } @@ -116061,17 +116499,17 @@ var ts; return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; + var emitFlags = emitNode && emitNode.flags || 0 /* EmitFlags.None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; var source = range && range.source || sourceMapSource; tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 128 /* EmitFlags.NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } tokenPos = emitCallback(token, writer, tokenPos); if (range) tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 256 /* EmitFlags.NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } return tokenPos; @@ -116102,23 +116540,23 @@ var ts; sourceMapSourceIndex = sourceIndex; } function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Extension.Json */); } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[1024 /* Braces */] = ["{", "}"]; - brackets[2048 /* Parenthesis */] = ["(", ")"]; - brackets[4096 /* AngleBrackets */] = ["<", ">"]; - brackets[8192 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* ListFormat.Braces */] = ["{", "}"]; + brackets[2048 /* ListFormat.Parenthesis */] = ["(", ")"]; + brackets[4096 /* ListFormat.AngleBrackets */] = ["<", ">"]; + brackets[8192 /* ListFormat.SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 15360 /* BracketsMask */][0]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 15360 /* BracketsMask */][1]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -116484,7 +116922,7 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; @@ -116493,11 +116931,11 @@ var ts; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) @@ -116519,9 +116957,9 @@ var ts; var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; - if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) || - hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + if (hasSourceFile((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + hasSourceFile((filePathWithoutExtension + ".tsx" /* Extension.Tsx */))) { + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -116554,7 +116992,7 @@ var ts; ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop); var plainInvokeFactory = { watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); }, - watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options); }, + watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* WatchDirectoryFlags.Recursive */) !== 0, options); }, }; var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ? { @@ -116589,36 +117027,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -116628,16 +117066,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -116818,7 +117256,7 @@ var ts; if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output // Cache json or buildInfo - if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { + if (!ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -116829,7 +117267,7 @@ var ts; if (value) return value; var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); - if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */))) { + if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) { sourceFileCache.set(key, sourceFile); } return sourceFile; @@ -116919,12 +117357,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -117012,9 +117450,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -117028,7 +117466,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -117091,7 +117529,7 @@ var ts; var mode = getModeForFileReference(name, containingFileMode); // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -117207,7 +117645,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -117386,22 +117824,33 @@ var ts; * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format */ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { + var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options); + return typeof result === "object" ? result.impliedNodeFormat : result; + } + ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + /*@internal*/ + function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: - return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext : - ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS : - ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : + return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ts.ModuleKind.ESNext : + ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ts.ModuleKind.CommonJS : + ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Extension.Dts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */]) ? lookupFromPackageJson() : undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline default: return undefined; } function lookupFromPackageJson() { - var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options); - return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options); + var packageJsonLocations = []; + state.failedLookupLocations = packageJsonLocations; + state.affectingLocations = packageJsonLocations; + var packageJsonScope = ts.getPackageScopeForPath(fileName, state); + var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope }; } } - ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker; /** @internal */ ts.plainJSErrors = new ts.Set([ // binder errors @@ -117549,7 +117998,7 @@ var ts; var modulesWithElidedImports = new ts.Map(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = new ts.Map(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -117630,16 +118079,16 @@ var ts; forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists; var readFile = host.readFile.bind(host); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structureIsReused; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { @@ -117667,7 +118116,7 @@ var ts; var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); }); for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) { var fileName = _c[_b]; - if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index }); } } @@ -117676,13 +118125,13 @@ var ts; }); } } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferences", { count: typeReferences.length }); // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); @@ -117726,7 +118175,7 @@ var ts; for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { var oldSourceFile = oldSourceFiles_1[_i]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); - if (shouldCreateNewSourceFile || !newFile || + if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || // old file wasn't redirect but new file is (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); @@ -117816,9 +118265,9 @@ var ts; // Add file processingDiagnostics fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) { switch (diagnostic.kind) { - case 1 /* FilePreprocessingFileExplainingDiagnostic */: + case 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */: return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray)); - case 0 /* FilePreprocessingReferencedDiagnostic */: + case 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */: var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end; return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false))); default: @@ -117869,7 +118318,7 @@ var ts; return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); @@ -117884,7 +118333,7 @@ var ts; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode); ts.performance.mark("afterResolveTypeReference"); @@ -117966,7 +118415,7 @@ var ts; return classifiableNames; } function resolveModuleNamesReusingOldState(moduleNames, file) { - if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { + if (structureIsReused === 0 /* StructureIsReused.Not */ && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); @@ -118063,7 +118512,7 @@ var ts; // `result[i]` is either a `ResolvedModuleFull` or a marker. // If it is the former, we can leave it as is. if (result[i] === predictedToResolveToAmbientModuleMarker) { - result[i] = undefined; // TODO: GH#18217 + result[i] = undefined; } } else { @@ -118119,24 +118568,24 @@ var ts; }); } function tryReuseStructureFromOldProgram() { - var _a; + var _a, _b; if (!oldProgram) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); if (ts.changesAffectModuleResolution(oldOptions, options)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // there is an old program, check if we can reuse its structure var oldRootNames = oldProgram.getRootFileNames(); if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); @@ -118144,12 +118593,12 @@ var ts; // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; var modifiedSourceFiles = []; - structureIsReused = 2 /* Completely */; + structureIsReused = 2 /* StructureIsReused.Completely */; // If the missing file paths are now present, it can change the progam structure, // and hence cant reuse the structure. // This is same as how we dont reuse the structure if one of the file from old program is now missing if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } var oldSourceFiles = oldProgram.getSourceFiles(); var SeenPackageName; @@ -118160,12 +118609,15 @@ var ts; var seenPackageNames = new ts.Map(); for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { var oldSourceFile = oldSourceFiles_2[_i]; + var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options); var newSourceFile = host.getSourceFileByPath - ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 + ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat) + : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217 if (!newSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } + newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope; ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; if (oldSourceFile.redirectInfo) { @@ -118173,7 +118625,7 @@ var ts; // This lets us know if the unredirected file has changed. If it has we should break the redirect. if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { // Underlying file has changed. Might not redirect anymore. Must rebuild program. - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; newSourceFile = oldSourceFile; // Use the redirect. @@ -118181,7 +118633,7 @@ var ts; else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) { // If a redirected-to source file changes, the redirect may be broken. if (newSourceFile !== oldSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; } @@ -118198,80 +118650,85 @@ var ts; // If there are 2 different source files for the same package name and at least one of them changes, // they might become redirects. So we must rebuild the program. var prevKind = seenPackageNames.get(packageName); - var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; - if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { - return 0 /* Not */; + var newKind = fileChanged ? 1 /* SeenPackageName.Modified */ : 0 /* SeenPackageName.Exists */; + if ((prevKind !== undefined && newKind === 1 /* SeenPackageName.Modified */) || prevKind === 1 /* SeenPackageName.Modified */) { + return 0 /* StructureIsReused.Not */; } seenPackageNames.set(packageName, newKind); } if (fileChanged) { + if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) { + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } // The `newSourceFile` object was created for the new program. - if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check tripleslash references - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - // check imports and module augmentations - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { - // imports has changed - structureIsReused = 1 /* SafeModules */; - } - if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { - // moduleAugmentations has changed - structureIsReused = 1 /* SafeModules */; - } - if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) { - // dynamicImport has changed - structureIsReused = 1 /* SafeModules */; - } - if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { - // 'types' references has changed - structureIsReused = 1 /* SafeModules */; + else { + // check imports and module augmentations + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + // moduleAugmentations has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if ((oldSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */)) { + // dynamicImport has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { + // 'types' references has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else if (hasInvalidatedResolution(oldSourceFile.path)) { // 'module/types' references could have changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; // add file to the modified list so that we will resolve it later modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); - for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) { - var oldFile = oldSourceFiles_3[_b]; + for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) { + var oldFile = oldSourceFiles_3[_c]; if (!ts.contains(modifiedFiles, oldFile)) { - for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) { - var moduleName = _d[_c]; + for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) { + var moduleName = _e[_d]; ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); } } } // try to verify results of module resolution - for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) { - var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile; + for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) { + var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile; var moduleNames = getModuleNames(newSourceFile); var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile); // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions); } else { @@ -118282,24 +118739,24 @@ var ts; // ensure that types resolutions are still correct var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo); if (typeReferenceResolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } - if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { - return 1 /* SafeModules */; + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) { + return 1 /* StructureIsReused.SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length); - for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) { - var newSourceFile = newSourceFiles_1[_g]; + for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) { + var newSourceFile = newSourceFiles_1[_h]; filesByName.set(newSourceFile.path, newSourceFile); } var oldFilesByNameMap = oldProgram.getFilesByNameMap(); @@ -118324,7 +118781,7 @@ var ts; sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules; - return 2 /* Completely */; + return 2 /* StructureIsReused.Completely */; } function getEmitHost(writeFileCallback) { return { @@ -118369,7 +118826,7 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -118421,7 +118878,7 @@ var ts; return typeChecker || (typeChecker = ts.createTypeChecker(program)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -118541,7 +118998,7 @@ var ts; } var typeChecker = getTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); - var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */; + var isJs = sourceFile.scriptKind === 1 /* ScriptKind.JS */ || sourceFile.scriptKind === 2 /* ScriptKind.JSX */; var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options); var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs); var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; @@ -118549,8 +119006,8 @@ var ts; // - plain JS: .js files with no // ts-check and checkJs: undefined // - check JS: .js files with either // ts-check or checkJs: true // - external: files that are added by plugins - var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ - || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* ScriptKind.TS */ || sourceFile.scriptKind === 4 /* ScriptKind.TSX */ + || sourceFile.scriptKind === 5 /* ScriptKind.External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* ScriptKind.Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; if (isPlainJs) { @@ -118629,22 +119086,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 254 /* VariableDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 254 /* SyntaxKind.VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -118652,65 +119109,65 @@ var ts; } } switch (node.kind) { - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type")); return "skip"; } break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: var heritageClause = node; - if (heritageClause.token === 117 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 258 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* SyntaxKind.InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 261 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */); + case 261 /* SyntaxKind.ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* NodeFlags.Namespace */ ? ts.tokenToString(142 /* SyntaxKind.NamespaceKeyword */) : ts.tokenToString(141 /* SyntaxKind.ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 260 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); + case 260 /* SyntaxKind.EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* SyntaxKind.EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -118719,53 +119176,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 237 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 237 /* SyntaxKind.VariableStatement */); return "skip"; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (ts.isModifier(modifier) && modifier.kind !== 124 /* StaticKeyword */) { + if (ts.isModifier(modifier) && modifier.kind !== 124 /* SyntaxKind.StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers && ts.some(nodes, ts.isModifier)) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 210 /* TaggedTemplateExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -118778,27 +119235,27 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 135 /* DeclareKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 124 /* StaticKeyword */: - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: } } } @@ -118868,20 +119325,20 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 79 /* Identifier */ - ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 10 /* StringLiteral */ && a.text === b.text; + return a.kind === 79 /* SyntaxKind.Identifier */ + ? b.kind === 79 /* SyntaxKind.Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* SyntaxKind.StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); var importDecl = ts.factory.createImportDeclaration(/*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); - ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(importDecl, 67108864 /* EmitFlags.NeverApplyImportHelper */); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); // explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them // (which is required to build the dependency graph for incremental emit) - externalHelpersModuleReference.flags &= ~8 /* Synthesized */; - importDecl.flags &= ~8 /* Synthesized */; + externalHelpersModuleReference.flags &= ~8 /* NodeFlags.Synthesized */; + importDecl.flags &= ~8 /* NodeFlags.Synthesized */; return externalHelpersModuleReference; } function collectExternalModuleReferences(file) { @@ -118912,7 +119369,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -118934,7 +119391,7 @@ var ts; } } else if (ts.isModuleDeclaration(node)) { - if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) { node.name.parent = node; var nameText = ts.getTextOfIdentifierOrLiteral(node.name); // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -118989,7 +119446,7 @@ var ts; function getNodeAtPosition(sourceFile, position) { var current = sourceFile; var getContainingChild = function (child) { - if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* EndOfFileToken */)))) { + if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) { return child; } }; @@ -119082,13 +119539,16 @@ var ts; addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]); } } - function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) { + var _a; var redirect = Object.create(redirectTarget); redirect.fileName = fileName; redirect.path = path; redirect.resolvedPath = resolvedPath; redirect.originalFileName = originalFileName; redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + redirect.packageJsonScope = sourceFileOptions.packageJsonScope; sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); Object.defineProperties(redirect, { id: { @@ -119104,7 +119564,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], @@ -119117,14 +119577,14 @@ var ts; // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront. - var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); - return { - languageVersion: ts.getEmitScriptTarget(options), - impliedNodeFormat: impliedNodeFormat, - setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options) - }; + var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); + var languageVersion = ts.getEmitScriptTarget(options); + var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options); + return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) : + { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator }; } function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { + var _a, _b; var path = toPath(fileName); if (useSourceOfProjectReferenceRedirect) { var source = getSourceOfProjectReferenceRedirect(path); @@ -119211,14 +119671,15 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile); + var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options); + var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat)); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. // Instead of creating a duplicate, just redirect to the existing one. - var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217 + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions); redirectTargetsMap.add(fileFromPackageId.path, fileName); addFileToFilesByName(dupFile, path, redirectedPath); addFileIncludeReason(dupFile, reason); @@ -119239,6 +119700,8 @@ var ts; file.path = path; file.resolvedPath = toPath(fileName); file.originalFileName = originalFileName; + file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined; + file.packageJsonScope = sourceFileOptions.packageJsonScope; addFileIncludeReason(file, reason); if (host.useCaseSensitiveFileNames()) { var pathLowerCase = ts.toFileNameLowerCase(path); @@ -119289,7 +119752,7 @@ var ts; } function getProjectReferenceRedirectProject(fileName) { // Ignore dts or any json files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -119299,7 +119762,7 @@ var ts; function getProjectReferenceOutputName(referencedProject, fileName) { var out = ts.outFile(referencedProject.commandLine.options); return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.changeExtension(out, ".d.ts" /* Extension.Dts */) : ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames()); } /** @@ -119332,13 +119795,13 @@ var ts; var out = ts.outFile(resolvedRef.commandLine.options); if (out) { // Dont know which source file it means so return true? - var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + var outputDts = ts.changeExtension(out, ".d.ts" /* Extension.Dts */); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); } else { var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); }); ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -119384,7 +119847,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -119443,7 +119906,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -119463,7 +119926,7 @@ var ts; var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 0 /* FilePreprocessingReferencedDiagnostic */, + kind: 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */, reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }, diagnostic: diagnostic, args: [libName, suggestion] @@ -119510,7 +119973,7 @@ var ts; && index < file.imports.length && !elideImport && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) - && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */)); + && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* NodeFlags.JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -119571,7 +120034,7 @@ var ts; else { // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); - sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + sourceFile = host.getSourceFile(refPath, 100 /* ScriptTarget.JSON */); addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { projectReferenceRedirects.set(sourceFilePath, false); @@ -119711,19 +120174,19 @@ var ts; var languageVersion = ts.getEmitScriptTarget(options); var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ScriptTarget.ES2015 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } if (options.preserveConstEnums === false) { createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules"); } - var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* ScriptKind.JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName))); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ScriptTarget.ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -119762,7 +120225,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + if (options.useDefineForClassFields && languageVersion === 0 /* ScriptTarget.ES3 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !ts.getAllowJSCompilerOption(options)) { @@ -119784,7 +120247,7 @@ var ts; if (options.reactNamespace) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { @@ -119798,7 +120261,7 @@ var ts; if (!options.jsxFactory) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { @@ -119806,12 +120269,12 @@ var ts; } } if (options.reactNamespace) { - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx)); } } if (options.jsxImportSource) { - if (options.jsx === 2 /* React */) { + if (options.jsx === 2 /* JsxEmit.React */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); } } @@ -119869,7 +120332,7 @@ var ts; fileIncludeReasons = undefined; var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason); var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon); - var redirectInfo = file && ts.explainIfFileIsRedirect(file); + var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file); var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false)); return location && isReferenceFileLocation(location) ? ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : @@ -119890,7 +120353,7 @@ var ts; } function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) { (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 1 /* FilePreprocessingFileExplainingDiagnostic */, + kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */, file: file && file.path, fileProcessingReason: fileProcessingReason, diagnostic: diagnostic, @@ -120129,7 +120592,7 @@ var ts; // If options have --outFile or --out just check that var out = ts.outFile(options); if (out) { - return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); + return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Extension.Dts */); } // If declarationDir is specified, return if its a file in that directory if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { @@ -120142,13 +120605,13 @@ var ts; if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || - !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Extension.Tsx */)); } return false; } function isSameFile(file1, file2) { - return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; } function getSymlinkCache() { if (host.getSymlinkCache) { @@ -120249,12 +120712,12 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || // Any parent directory of declaration dir ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || // Any directory inside declaration dir - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -120307,7 +120770,7 @@ var ts; if (isFile && result) { // Store the real path for the file' var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -120403,17 +120866,17 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ".tsx" /* Extension.Tsx */: return needJsx(); - case ".jsx" /* Jsx */: + case ".jsx" /* Extension.Jsx */: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ".js" /* Extension.Js */: return needAllowJs(); - case ".json" /* Json */: + case ".json" /* Extension.Json */: return needResolveJsonModule(); } function needJsx() { @@ -120432,7 +120895,7 @@ var ts; var res = imports.map(function (i) { return i.text; }); for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { var aug = moduleAugmentations_1[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -120447,7 +120910,7 @@ var ts; var augIndex = imports.length; for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) { var aug = moduleAugmentations_2[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { if (index === augIndex) return aug; augIndex++; @@ -120463,8 +120926,8 @@ var ts; (function (ts) { function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit; - return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; + var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics; + return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); } @@ -120688,23 +121151,23 @@ var ts; /** * Gets the files affected by the path from the program */ - function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var _a, _b; - var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash); + var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName); (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear(); (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); return result; } BuilderState.getFilesAffectedBy = getFilesAffectedBy; - function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var sourceFile = programOfThisState.getSourceFileByPath(path); if (!sourceFile) { return ts.emptyArray; } - if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) { + if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) { return [sourceFile]; } - return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash); + return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName); } BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState; function updateSignatureOfFile(state, signature, path) { @@ -120715,7 +121178,7 @@ var ts; /** * Returns if the shape of the signature has changed since last emit */ - function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) { + function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) { var _a; if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; } // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate @@ -120725,18 +121188,16 @@ var ts; var prevSignature = info.signature; var latestSignature; if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) { - var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, - /*emitOnlyDtsFiles*/ true, cancellationToken, - /*customTransformers*/ undefined, - /*forceDtsEmit*/ true); - var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); - if (firstDts_1) { - ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); - latestSignature = computeSignature(firstDts_1.text, computeHash); + programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) { + ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: ".concat(fileName)); + latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data); if (latestSignature !== prevSignature) { - updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit); + updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit); } - } + }, cancellationToken, + /*emitOnlyDtsFiles*/ true, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); } // Default is to use file version as signature if (latestSignature === undefined) { @@ -120759,10 +121220,6 @@ var ts; return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; - function computeSignature(text, computeHash) { - return (computeHash || ts.generateDjb2Hash)(text); - } - BuilderState.computeSignature = computeSignature; /** * Coverts the declaration emit result into exported modules map */ @@ -120912,7 +121369,7 @@ var ts; /** * When program emits modular code, gets the files affected by the sourceFile whose shape has changed */ - function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) { + function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) { if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } @@ -120932,7 +121389,7 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath); seenFileNamesMap.set(currentPath, currentSourceFile); - if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) { + if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) { queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath)); } } @@ -120972,7 +121429,7 @@ var ts; state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature; } state.changedFilesSet = new ts.Set(); - state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined; + state.latestChangedDtsFile = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.latestChangedDtsFile : undefined; var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && @@ -121043,7 +121500,7 @@ var ts; } else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); }); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* BuilderFileEmit.Full */); }); ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } @@ -121096,7 +121553,7 @@ var ts; programEmitComplete: state.programEmitComplete, emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: state.latestChangedDtsFile, hasChangedEmitSignature: state.hasChangedEmitSignature, changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined, }; @@ -121109,7 +121566,7 @@ var ts; state.programEmitComplete = savedEmitState.programEmitComplete; state.emitSignatures = savedEmitState.emitSignatures; state.outSignature = savedEmitState.outSignature; - state.dtsChangeTime = savedEmitState.dtsChangeTime; + state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile; state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature; if (savedEmitState.changedFilesSet) state.changedFilesSet = savedEmitState.changedFilesSet; @@ -121126,7 +121583,7 @@ var ts; * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained */ - function getNextAffectedFile(state, cancellationToken, computeHash, host) { + function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; while (true) { var affectedFiles = state.affectedFiles; @@ -121138,7 +121595,7 @@ var ts; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { // Set the next affected file as seen and remove the cached semantic diagnostics state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); return affectedFile; } affectedFilesIndex++; @@ -121166,7 +121623,7 @@ var ts; return program; } // Get next batch of affected files - state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash); + state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName); state.currentChangedFilePath = nextKey.value; state.affectedFilesIndex = 0; if (!state.seenAffectedFiles) @@ -121217,7 +121674,7 @@ var ts; * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { @@ -121225,18 +121682,18 @@ var ts; // When a change affects the global scope, all files are considered to be affected without updating their signature // That means when affected file is handled, its signature can be out of date // To avoid this, ensure that we update the signature for any affected file in this scenario. - ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash); + ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName); return; } if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) return; - handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); } /** * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, * Also we need to make sure signature is updated for these files */ - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); @@ -121247,10 +121704,10 @@ var ts; // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. - ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); + addToAffectedFilesPendingEmit(state, path, 0 /* BuilderFileEmit.DtsOnly */); } } } @@ -121272,20 +121729,20 @@ var ts; var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } - function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) return false; // Every file needs to be handled ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined) - .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); }); removeDiagnosticsOfLibraryFiles(state); return true; } /** * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit */ - function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit @@ -121303,9 +121760,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host)) return; - handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -121317,11 +121774,11 @@ var ts; // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; var references = state.referencedMap.getKeys(exportedFromPath); return references && ts.forEachKey(references, function (filePath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); }); } @@ -121329,22 +121786,22 @@ var ts; * handle dts and semantic diagnostics on file and iterate on anything that exports this file * return true when all work is done and we can exit handling dts emit and semantic diagnostics */ - function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) return undefined; - if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; - handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host); // If exported modules has path, all files referencing file exported from are affected (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); // Remove diagnostics of files that import this file (without going to exports of referencing files) (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal - state, referencingFilePath, cancellationToken, computeHash, host); + state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host); }); return undefined; } @@ -121423,14 +121880,14 @@ var ts; /** * Gets the program information to be emitted in buildInfo so that we can use it to create new program */ - function getProgramBuildInfo(state, getCanonicalFileName, host) { + function getProgramBuildInfo(state, getCanonicalFileName) { var outFilePath = ts.outFile(state.compilerOptions); if (outFilePath && !state.compilerOptions.composite) return; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - // Update the dtsChange time in buildInfo - state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime; + // Convert the file name to Path here if we set the fileName instead to optimize multiple d.ts file emits and having to compute Canonical path + var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined; if (outFilePath) { var fileNames_1 = []; var fileInfos_1 = []; @@ -121446,7 +121903,7 @@ var ts; fileInfos: fileInfos_1, options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result_15; } @@ -121548,7 +122005,7 @@ var ts; affectedFilesPendingEmit: affectedFilesPendingEmit, changeFileSet: changeFileSet, emitSignatures: emitSignatures, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result; function relativeToBuildInfoEnsuringAbsolutePath(path) { @@ -121663,8 +122120,39 @@ var ts; return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray }; } ts.getBuilderCreationParameters = getBuilderCreationParameters; - function computeSignature(text, data, computeHash) { - return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash); + function getTextHandlingSourceMapForSignature(text, data) { + return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text; + } + function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) { + var _a; + text = getTextHandlingSourceMapForSignature(text, data); + var sourceFileDirectory; + if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) { + text += data.diagnostics.map(function (diagnostic) { + return "".concat(locationInfo(diagnostic)).concat(ts.DiagnosticCategory[diagnostic.category]).concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText)); + }).join("\n"); + } + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text); + function flattenDiagnosticMessageText(diagnostic) { + return ts.isString(diagnostic) ? + diagnostic : + diagnostic === undefined ? + "" : + !diagnostic.next ? + diagnostic.messageText : + diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n"); + } + function locationInfo(diagnostic) { + if (diagnostic.file.resolvedPath === sourceFile.resolvedPath) + return "(".concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + if (sourceFileDirectory === undefined) + sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath); + return "".concat(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)), "(").concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + } + } + ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics; + function computeSignature(text, computeHash, data) { + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data)); } ts.computeSignature = computeSignature; function createBuilderProgram(kind, _a) { @@ -121685,7 +122173,7 @@ var ts; */ var computeHash = ts.maybeBind(host, host.createHash); var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); - newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); }; + newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); }; // To ensure that we arent storing any references to old program or new program without state newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; @@ -121695,6 +122183,7 @@ var ts; builderProgram.getState = getState; builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); }; builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); }; + builderProgram.hasChangedEmitSignature = function () { return !!state.hasChangedEmitSignature; }; builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); }; builderProgram.getSemanticDiagnostics = getSemanticDiagnostics; builderProgram.emit = emit; @@ -121725,8 +122214,8 @@ var ts; * in that order would be used to write the files */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); - var emitKind = 1 /* Full */; + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); + var emitKind = 1 /* BuilderFileEmit.Full */; var isPendingEmitFile = false; if (!affected) { if (!ts.outFile(state.compilerOptions)) { @@ -121739,7 +122228,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* BuilderFileEmit.Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } @@ -121758,36 +122247,39 @@ var ts; // Otherwise just affected file ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ? getWriteFileCallback(writeFile, customTransformers) : - writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } function getWriteFileCallback(writeFile, customTransformers) { return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f, _g; if (ts.isDeclarationFileName(fileName)) { if (!ts.outFile(state.compilerOptions)) { ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); - var newSignature = void 0; + var emitSignature = void 0; if (!customTransformers) { var file = sourceFiles[0]; var info = state.fileInfos.get(file.resolvedPath); if (info.signature === file.version) { - newSignature = computeSignature(text, data, computeHash); - if (newSignature !== file.version) { // Update it + var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data); + // With d.ts diagnostics they are also part of the signature so emitSignature will be different from it since its just hash of d.ts + if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length)) + emitSignature = signature; + if (signature !== file.version) { // Update it if (host.storeFilesChangingSignatureDuringEmit) - (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); if (state.exportedModulesMap) ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit); if (state.affectedFiles) { // Keep old signature so we know what to undo if cancellation happens - var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath); + var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath); if (existing === undefined) - (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); - info.signature = newSignature; + ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); + info.signature = signature; } else { // These are directly commited - info.signature = newSignature; - (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); + info.signature = signature; + (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear(); } } } @@ -121797,20 +122289,24 @@ var ts; // and would need their d.ts change time in --build mode if (state.compilerOptions.composite) { var filePath = sourceFiles[0].resolvedPath; - var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath); - newSignature || (newSignature = computeSignature(text, data, computeHash)); - if (newSignature !== oldSignature) { - (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature); - state.hasChangedEmitSignature = true; - } + var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath); + emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data)); + // Dont write dts files if they didn't change + if (emitSignature === oldSignature) + return; + ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature); + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } else if (state.compilerOptions.composite) { - var newSignature = computeSignature(text, data, computeHash); - if (newSignature !== state.outSignature) { - state.outSignature = newSignature; - state.hasChangedEmitSignature = true; - } + var newSignature = computeSignature(text, computeHash, data); + // Dont write dts files if they didn't change + if (newSignature === state.outSignature) + return; + state.outSignature = newSignature; + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } if (writeFile) @@ -121870,7 +122366,7 @@ var ts; // If every file pending emit is pending on only dts emit || ts.every(state.affectedFilesPendingEmit, function (path, index) { return index < state.affectedFilesPendingEmitIndex || - state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */; + state.affectedFilesPendingEmitKind.get(path) === 0 /* BuilderFileEmit.DtsOnly */; })) { clearAffectedFilesPendingEmit(state); } @@ -121886,7 +122382,7 @@ var ts; */ function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); if (!affected) { // Done return undefined; @@ -121898,7 +122394,7 @@ var ts; // Add file to affected file pending emit to handle for later emit time // Apart for emit builder do this for tsbuildinfo, do this for non emit builder when noEmit is set as tsbuildinfo is written and reused between emitters if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) { - addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* Full */); + addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* BuilderFileEmit.Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -121973,11 +122469,12 @@ var ts; var state; var filePaths; var filePathsSetList; + var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined; if (isProgramBundleEmitBuildInfo(program)) { state = { fileInfos: new ts.Map(), compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, outSignature: program.outSignature, }; } @@ -122010,7 +122507,7 @@ var ts; affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)), - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined, }; } @@ -122037,6 +122534,7 @@ var ts; getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, emitBuildInfo: ts.notImplemented, close: ts.noop, + hasChangedEmitSignature: ts.returnFalse, }; function toPath(path) { return ts.toPath(path, buildInfoDirectory, getCanonicalFileName); @@ -122139,7 +122637,7 @@ var ts; * "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot" * @param dirPath */ - function canWatchDirectory(dirPath) { + function canWatchDirectoryOrFile(dirPath) { var rootLength = ts.getRootLength(dirPath); if (dirPath.length === rootLength) { // Ignore "/", "c:/" @@ -122151,7 +122649,7 @@ var ts; return false; } var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); - var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */; if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart @@ -122176,7 +122674,7 @@ var ts; } return true; } - ts.canWatchDirectory = canWatchDirectory; + ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; var filesWithInvalidatedResolutions; @@ -122185,7 +122683,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolutionsWithOnlyAffectingLocations = []; var resolvedFileToResolution = ts.createMultiMap(); + var impliedFormatPackageJsons = new ts.Map(); var hasChangedAutomaticTypeDirectiveNames = false; + var affectingPathChecksForFile; var affectingPathChecks; var failedLookupChecks; var startsWithPathChecks; @@ -122210,7 +122710,7 @@ var ts; * This helps in not having to comb through all resolutions when files are added/removed * Note that .d.ts file also has .d.ts extension hence will be part of default extensions */ - var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; + var failedLookupDefaultExtensions = [".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); var fileWatchesOfAffectingLocations = new ts.Map(); @@ -122225,7 +122725,7 @@ var ts; finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions, // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) - startCachingPerDirectoryResolution: clearPerDirectoryResolutions, + startCachingPerDirectoryResolution: startCachingPerDirectoryResolution, finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution, resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, @@ -122269,9 +122769,10 @@ var ts; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; affectingPathChecks = undefined; - // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update - // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) - clearPerDirectoryResolutions(); + affectingPathChecksForFile = undefined; + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); + impliedFormatPackageJsons.clear(); hasChangedAutomaticTypeDirectiveNames = false; } function startRecordingFilesWithChangedResolutions() { @@ -122303,15 +122804,44 @@ var ts; return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } - function clearPerDirectoryResolutions() { - moduleResolutionCache.clear(); - typeReferenceDirectiveResolutionCache.clear(); + function startCachingPerDirectoryResolution() { + moduleResolutionCache.clearAllExceptPackageJsonInfoCache(); + typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache(); + // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update + // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } - function finishCachingPerDirectoryResolution() { + function finishCachingPerDirectoryResolution(newProgram, oldProgram) { filesWithInvalidatedNonRelativeUnresolvedImports = undefined; - clearPerDirectoryResolutions(); + nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); + nonRelativeExternalModuleResolutions.clear(); + // Update file watches + if (newProgram !== oldProgram) { + newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) { + var _a, _b, _c; + var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0; + var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray; + for (var i = existing.length; i < expected; i++) { + createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false); + } + if (existing.length > expected) { + for (var i = expected; i < existing.length; i++) { + fileWatchesOfAffectingLocations.get(existing[i]).files--; + } + } + if (expected) + impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations); + else + impliedFormatPackageJsons.delete(newFile.path); + }); + impliedFormatPackageJsons.forEach(function (existing, path) { + if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) { + existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; }); + impliedFormatPackageJsons.delete(path); + } + }); + } directoryWatchesOfFailedLookups.forEach(function (watcher, path) { if (watcher.refCount === 0) { directoryWatchesOfFailedLookups.delete(path); @@ -122319,11 +122849,9 @@ var ts; } }); fileWatchesOfAffectingLocations.forEach(function (watcher, path) { - if (watcher.refCount === 0) { + if (watcher.files === 0 && watcher.resolutions === 0) { fileWatchesOfAffectingLocations.delete(path); watcher.watcher.close(); - // Ensure when watching symlinked package.json, we can close the actual file watcher only once - watcher.watcher = ts.noopFileWatcher; } }); hasChangedAutomaticTypeDirectiveNames = false; @@ -122523,7 +123051,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution return { @@ -122550,7 +123078,7 @@ var ts; } // If the directory is node_modules use it to watch, always watch it recursively if (ts.isNodeModulesDirectory(dirPath)) { - return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; + return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; // Use some ancestor of the root directory @@ -122568,7 +123096,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; + return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -122639,46 +123167,65 @@ var ts; // Watch package json for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) { var affectingLocation = affectingLocations_1[_i]; - createFileWatcherOfAffectingLocation(affectingLocation); + createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true); } } - function createFileWatcherOfAffectingLocation(affectingLocation) { - var path = resolutionHost.toPath(affectingLocation); - var fileWatcher = fileWatchesOfAffectingLocations.get(path); + function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) { + var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation); if (fileWatcher) { - fileWatcher.refCount++; + if (forResolution) + fileWatcher.resolutions++; + else + fileWatcher.files++; return; } var locationToWatch = affectingLocation; - var locationToWatchPath = path; if (resolutionHost.realpath) { locationToWatch = resolutionHost.realpath(affectingLocation); - locationToWatchPath = resolutionHost.toPath(locationToWatch); - if (path !== locationToWatchPath) { - var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath); + if (affectingLocation !== locationToWatch) { + var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch); if (fileWatcher_1) { - fileWatcher_1.refCount++; - fileWatcher_1.paths.add(path); - fileWatchesOfAffectingLocations.set(path, fileWatcher_1); + if (forResolution) + fileWatcher_1.resolutions++; + else + fileWatcher_1.files++; + fileWatcher_1.paths.add(affectingLocation); + fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1); return; } } } var paths = new ts.Set(); - paths.add(locationToWatchPath); - var watcher = { - watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { - cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind); - paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); }); + paths.add(locationToWatch); + var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ? + resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { + cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind); + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + paths.forEach(function (path) { + if (watcher.resolutions) + (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path); + if (watcher.files) + (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path); + packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path)); + }); resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); - }), - refCount: 1, + }) : ts.noopFileWatcher; + var watcher = { + watcher: actualWatcher !== ts.noopFileWatcher ? { + close: function () { + actualWatcher.close(); + // Ensure when watching symlinked package.json, we can close the actual file watcher only once + actualWatcher = ts.noopFileWatcher; + } + } : actualWatcher, + resolutions: forResolution ? 1 : 0, + files: forResolution ? 0 : 1, paths: paths, }; - fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher); - if (path !== locationToWatchPath) { - fileWatchesOfAffectingLocations.set(path, watcher); - paths.add(path); + fileWatchesOfAffectingLocations.set(locationToWatch, watcher); + if (affectingLocation !== locationToWatch) { + fileWatchesOfAffectingLocations.set(affectingLocation, watcher); + paths.add(affectingLocation); } } function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) { @@ -122746,8 +123293,8 @@ var ts; } for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) { var affectingLocation = affectingLocations_2[_a]; - var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation)); - watcher.refCount--; + var watcher = fileWatchesOfAffectingLocations.get(affectingLocation); + watcher.resolutions--; } } function removeDirectoryWatcher(dirPath) { @@ -122763,7 +123310,7 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); - }, nonRecursive ? 0 /* None */ : 1 /* Recursive */); + }, nonRecursive ? 0 /* WatchDirectoryFlags.None */ : 1 /* WatchDirectoryFlags.Recursive */); } function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) { // Deleted file, stop watching failed lookups for all the resolutions in the file @@ -122774,7 +123321,7 @@ var ts; } } function removeResolutionsFromProjectReferenceRedirects(filePath) { - if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) + if (!ts.fileExtensionIs(filePath, ".json" /* Extension.Json */)) return; var program = resolutionHost.getCurrentProgram(); if (!program) @@ -122801,7 +123348,7 @@ var ts; resolution.isInvalidated = invalidated = true; for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) { var containingFilePath = _b[_a]; - (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); // When its a file with inferred types resolution, invalidate type reference directive resolution hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile); } @@ -122868,10 +123415,25 @@ var ts; resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { + var _a; + var invalidated = false; + if (affectingPathChecksForFile) { + (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) { + if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) { + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path); + invalidated = true; + } + }); + affectingPathChecksForFile = undefined; + } if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) { - return false; + return invalidated; + } + invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated; + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) { + packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; }); } - var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); failedLookupChecks = undefined; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; @@ -122884,17 +123446,15 @@ var ts; return true; if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) return false; - return resolution.failedLookupLocations.some(function (location) { - var locationPath = resolutionHost.toPath(location); - return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || - ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || - ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); - }); + return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); }); + } + function isInvalidatedFailedLookup(locationPath) { + return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); } function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) { - return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { - return affectingPathChecks.has(resolutionHost.toPath(location)); - }); + return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); }); } function closeTypeRootsWatch() { ts.clearMap(typeRootsWatches, ts.closeFileWatcher); @@ -122925,7 +123485,7 @@ var ts; if (dirPath) { scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); } - }, 1 /* Recursive */); + }, 1 /* WatchDirectoryFlags.Recursive */); } /** * Watches the types that would get added as part of getAutomaticTypeDirectiveNames @@ -122960,7 +123520,7 @@ var ts; function directoryExistsForTypeRootWatch(nodeTypesDirectory) { var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory)); var dirPath = resolutionHost.toPath(dir); - return dirPath === rootPath || canWatchDirectory(dirPath); + return dirPath === rootPath || canWatchDirectoryOrFile(dirPath); } } ts.createResolutionCache = createResolutionCache; @@ -122993,28 +123553,28 @@ var ts; function getPreferences(host, _a, compilerOptions, importingSourceFile) { var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding; return { - relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : - importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* RelativePreference.Relative */ : + importModuleSpecifierPreference === "non-relative" ? 1 /* RelativePreference.NonRelative */ : + importModuleSpecifierPreference === "project-relative" ? 3 /* RelativePreference.ExternalNonRelative */ : + 2 /* RelativePreference.Shortest */, ending: getEnding(), }; function getEnding() { switch (importModuleSpecifierEnding) { - case "minimal": return 0 /* Minimal */; - case "index": return 1 /* Index */; - case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + case "minimal": return 0 /* Ending.Minimal */; + case "index": return 1 /* Ending.Index */; + case "js": return 2 /* Ending.JsExtension */; + default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* Ending.JsExtension */ + : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) { return { - relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, + relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* RelativePreference.Relative */ : 1 /* RelativePreference.NonRelative */, ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? - 2 /* JsExtension */ : - ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + 2 /* Ending.JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */, }; } function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { @@ -123071,7 +123631,7 @@ var ts; var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || - getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); + getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { if (options === void 0) { options = {}; } @@ -123127,7 +123687,7 @@ var ts; return undefined; var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text; // If the preference is for non relative and the module specifier is relative, ignore it - return preferences.relativePreference !== 1 /* NonRelative */ || !ts.pathIsRelative(specifier) ? + return preferences.relativePreference !== 1 /* RelativePreference.NonRelative */ || !ts.pathIsRelative(specifier) ? specifier : undefined; }); }); @@ -123154,7 +123714,7 @@ var ts; return nodeModulesSpecifiers; } if (!specifier && !modulePath.isRedirect) { - var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences); + var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); if (ts.pathIsBareSpecifier(local)) { pathsSpecifiers = ts.append(pathsSpecifiers, local); } @@ -123182,13 +123742,13 @@ var ts; var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory }; } - function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) { + function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) { var ending = _a.ending, relativePreference = _a.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); - if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { + if (!baseUrl && !paths || relativePreference === 0 /* RelativePreference.Relative */) { return relativePath; } var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); @@ -123196,16 +123756,15 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; + var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions); + var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths; if (!nonRelative) { return relativePath; } - if (relativePreference === 1 /* NonRelative */) { + if (relativePreference === 1 /* RelativePreference.NonRelative */) { return nonRelative; } - if (relativePreference === 3 /* ExternalNonRelative */) { + if (relativePreference === 3 /* RelativePreference.ExternalNonRelative */) { var projectDirectory = compilerOptions.configFilePath ? ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory()); @@ -123239,7 +123798,7 @@ var ts; } return relativePath; } - if (relativePreference !== 2 /* Shortest */) + if (relativePreference !== 2 /* RelativePreference.Shortest */) ts.Debug.assertNever(relativePreference); // Prefer a relative import over a baseUrl import if it has fewer components. return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; @@ -123247,7 +123806,7 @@ var ts; function countPathComponents(path) { var count = 0; for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) { - if (path.charCodeAt(i) === 47 /* slash */) + if (path.charCodeAt(i) === 47 /* CharacterCodes.slash */) count++; } return count; @@ -123351,7 +123910,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_34 = function (directory) { + var _loop_35 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -123375,7 +123934,7 @@ var ts; }; var out_directory_1; for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { - var state_11 = _loop_34(directory); + var state_11 = _loop_35(directory); directory = out_directory_1; if (state_11 === "break") break; @@ -123418,11 +123977,11 @@ var ts; var exportSymbol = checker.getSymbolAtLocation(exportAssignment); if (!exportSymbol) return; - var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; + var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; if (originalExportSymbol === d.symbol) return topNamespace.parent.parent; function getTopNamespace(namespaceDeclaration) { - while (namespaceDeclaration.flags & 4 /* NestedNamespace */) { + while (namespaceDeclaration.flags & 4 /* NodeFlags.NestedNamespace */) { namespaceDeclaration = namespaceDeclaration.parent; } return namespaceDeclaration; @@ -123433,28 +123992,102 @@ var ts; return ambientModuleDeclare.name.text; } } - function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) { + function getAllowedEndings(preferredEnding, compilerOptions, importMode) { + if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) { + return [2 /* Ending.JsExtension */]; + } + switch (preferredEnding) { + case 2 /* Ending.JsExtension */: return [2 /* Ending.JsExtension */, 0 /* Ending.Minimal */, 1 /* Ending.Index */]; + case 1 /* Ending.Index */: return [1 /* Ending.Index */, 0 /* Ending.Minimal */, 2 /* Ending.JsExtension */]; + case 0 /* Ending.Minimal */: return [0 /* Ending.Minimal */, 1 /* Ending.Index */, 2 /* Ending.JsExtension */]; + default: ts.Debug.assertNever(preferredEnding); + } + } + function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) { for (var key in paths) { - for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { - var patternText_1 = _a[_i]; - var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1)); + var _loop_36 = function (patternText_1) { + var pattern = ts.normalizePath(patternText_1); var indexOfStar = pattern.indexOf("*"); + // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly, + // meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution + // causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file + // and matches the '*'. For example: + // + // Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action + // ---------------------->------------------------------->--------------------->--------------------------------------------------------------- + // import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm] + // import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm] + // + // (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516) + // + // The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in + // the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result. + // (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid + // extension for a module specifier.) + // + // Here, this means we need to be careful about whether we generate a match from the target filename (typically with a + // .ts extension) or the possible relative module specifiers representing that file: + // + // Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results + // --------------------<----------------------------------------------<------------------------------<-------------------||---------------------------- + // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none) + // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js + // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none) + // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*"] <- (none) || @app/foo, @app/foo/index, @app/foo/index.js + // dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js + // + // The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of + // relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes + // into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js' + // exists) and (c) that they are ordered by preference. The last row shows that the filename result and module + // specifier results are not mutually exclusive. Note that the filename result is a higher priority in module + // resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result + // in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be + // sorted among the others for a particular value of `importModuleSpecifierEnding`. + var candidates = allowedEndings.map(function (ending) { return ({ + ending: ending, + value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) + }); }); + if (ts.tryGetExtensionFromPath(pattern)) { + candidates.push({ ending: undefined, value: relativeToBaseUrl }); + } if (indexOfStar !== -1) { - var prefix = pattern.substr(0, indexOfStar); - var suffix = pattern.substr(indexOfStar + 1); - if (relativeToBaseUrl.length >= prefix.length + suffix.length && - ts.startsWith(relativeToBaseUrl, prefix) && - ts.endsWith(relativeToBaseUrl, suffix) || - !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); - return key.replace("*", matchedStar); + var prefix = pattern.substring(0, indexOfStar); + var suffix = pattern.substring(indexOfStar + 1); + for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) { + var _c = candidates_3[_b], ending = _c.ending, value = _c.value; + if (value.length >= prefix.length + suffix.length && + ts.startsWith(value, prefix) && + ts.endsWith(value, suffix) && + validateEnding({ ending: ending, value: value })) { + var matchedStar = value.substring(prefix.length, value.length - suffix.length); + return { value: key.replace("*", matchedStar) }; + } } } - else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) { - return key; + else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Ending.Minimal */ && pattern === c.value; }) || + ts.some(candidates, function (c) { return c.ending === 0 /* Ending.Minimal */ && pattern === c.value && validateEnding(c); })) { + return { value: key }; } + }; + for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { + var patternText_1 = _a[_i]; + var state_12 = _loop_36(patternText_1); + if (typeof state_12 === "object") + return state_12.value; } } + function validateEnding(_a) { + var ending = _a.ending, value = _a.value; + // Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename + // is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only + // here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls), + // do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the + // `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is + // that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally + // everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.) + return ending !== 0 /* Ending.Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host); + } } var MatchingMode; (function (MatchingMode) { @@ -123463,23 +124096,23 @@ var ts; MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern"; })(MatchingMode || (MatchingMode = {})); function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { - if (mode === void 0) { mode = 0 /* Exact */; } + if (mode === void 0) { mode = 0 /* MatchingMode.Exact */; } if (typeof exports === "string") { var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined); var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined; switch (mode) { - case 0 /* Exact */: - if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) { + case 0 /* MatchingMode.Exact */: + if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* Comparison.EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* Comparison.EqualTo */)) { return { moduleFileToTry: packageName }; } break; - case 1 /* Directory */: + case 1 /* MatchingMode.Directory */: if (ts.containsPath(pathOrPattern, targetFilePath)) { var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false); return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) }; } break; - case 2 /* Pattern */: + case 2 /* MatchingMode.Pattern */: var starPos = pathOrPattern.indexOf("*"); var leadingSlice = pathOrPattern.slice(0, starPos); var trailingSlice = pathOrPattern.slice(starPos + 1); @@ -123506,9 +124139,9 @@ var ts; // * exact mappings (no *, does not end with /) return ts.forEach(ts.getOwnKeys(exports), function (k) { var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined); - var mode = ts.endsWith(k, "/") ? 1 /* Directory */ - : ts.stringContains(k, "*") ? 2 /* Pattern */ - : 0 /* Exact */; + var mode = ts.endsWith(k, "/") ? 1 /* MatchingMode.Directory */ + : ts.stringContains(k, "*") ? 2 /* MatchingMode.Pattern */ + : 0 /* MatchingMode.Exact */; return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode); }); } @@ -123550,10 +124183,10 @@ var ts; return undefined; } // Simplify the full file path to something that can be resolved by Node. + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { - var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; var moduleFileName = void 0; while (true) { @@ -123602,15 +124235,13 @@ var ts; var packageRootPath = path.substring(0, packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); var moduleFileToTry = path; + var maybeBlockedByTypesVersions = false; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); + var importMode = overrideMode || importingSourceFile.impliedNodeFormat; if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { - // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate - // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is - // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` - // with, so for now we just stick with the mode of the file. - var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"]; + var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"]; var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions) : undefined; @@ -123629,16 +124260,26 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { + var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options); + if (fromPaths === undefined) { + maybeBlockedByTypesVersions = true; + } + else { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } // If the file is the main module, it can be imported by the package name var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; - if (ts.isString(mainFileRelative)) { + if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) { + // The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path + // explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable. + // (The only way this can happen is if some file in a package that's not resolvable from outside the + // package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It + // happens very easily in fourslash tests though, since every test file listed gets included. See + // importNameCodeFix_typesVersions.ts for an example.) var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { + // ^ An arbitrary removal of file extension for this comparison is almost certainly wrong return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry }; } } @@ -123657,7 +124298,7 @@ var ts; if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }])); + var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }])); for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) { var e = extensions_3[_i]; var fullPath = path + e; @@ -123673,15 +124314,15 @@ var ts; }); } function removeExtensionAndIndexPostFix(fileName, ending, options, host) { - if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) + if (ts.fileExtensionIsOneOf(fileName, [".json" /* Extension.Json */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) return fileName; var noExtension = ts.removeFileExtension(fileName); if (fileName === noExtension) return fileName; - if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) + if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { - case 0 /* Minimal */: + case 0 /* Ending.Minimal */: var withoutIndex = ts.removeSuffix(noExtension, "/index"); if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { // Can't remove index if there's a file by the same name as the directory. @@ -123689,9 +124330,9 @@ var ts; return noExtension; } return withoutIndex; - case 1 /* Index */: + case 1 /* Ending.Index */: return noExtension; - case 2 /* JsExtension */: + case 2 /* Ending.JsExtension */: return noExtension + getJSExtensionForFile(fileName, options); default: return ts.Debug.assertNever(ending); @@ -123699,28 +124340,28 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); switch (ext) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: - return ".js" /* Js */; - case ".tsx" /* Tsx */: - return options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; - case ".js" /* Js */: - case ".jsx" /* Jsx */: - case ".json" /* Json */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: + return ".js" /* Extension.Js */; + case ".tsx" /* Extension.Tsx */: + return options.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" /* Extension.Jsx */ : ".js" /* Extension.Js */; + case ".js" /* Extension.Js */: + case ".jsx" /* Extension.Jsx */: + case ".json" /* Extension.Json */: return ext; - case ".d.mts" /* Dmts */: - case ".mts" /* Mts */: - case ".mjs" /* Mjs */: - return ".mjs" /* Mjs */; - case ".d.cts" /* Dcts */: - case ".cts" /* Cts */: - case ".cjs" /* Cjs */: - return ".cjs" /* Cjs */; + case ".d.mts" /* Extension.Dmts */: + case ".mts" /* Extension.Mts */: + case ".mjs" /* Extension.Mjs */: + return ".mjs" /* Extension.Mjs */; + case ".d.cts" /* Extension.Dcts */: + case ".cts" /* Extension.Cts */: + case ".cjs" /* Extension.Cjs */: + return ".cjs" /* Extension.Cjs */; default: return undefined; } @@ -123802,8 +124443,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -123811,8 +124452,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -123835,7 +124476,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -123868,7 +124509,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -123881,7 +124522,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -123904,7 +124545,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -123931,25 +124572,48 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; - function explainIfFileIsRedirect(file, fileNameConvertor) { + function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) { + var _a; var result; if (file.path !== file.resolvedPath) { - (result || (result = [])).push(ts.chainDiagnosticMessages( + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor))); } if (file.redirectInfo) { - (result || (result = [])).push(ts.chainDiagnosticMessages( + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor))); } + if (ts.isExternalOrCommonJsModule(file)) { + switch (file.impliedNodeFormat) { + case ts.ModuleKind.ESNext: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + break; + case ts.ModuleKind.CommonJS: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, file.packageJsonScope.packageJsonContent.type ? + ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module : + ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found)); + } + break; + } + } return result; } - ts.explainIfFileIsRedirect = explainIfFileIsRedirect; + ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat; function getMatchedFileSpec(program, fileName) { var _a; var configFile = program.getCompilerOptions().configFile; @@ -123969,14 +124633,14 @@ var ts; // Return true if its default include spec if (configFile.configFileSpecs.isDefaultIncludeSpec) return true; - var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Extension.Json */); var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames(); return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) { - if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Json */)) + if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Extension.Json */)) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -123985,7 +124649,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -124111,7 +124775,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -124159,6 +124823,7 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", + AffectingFileLocation: "File location affecting resolution", TypeRoots: "Type roots", ConfigFileOfReferencedProject: "Config file of referened project", ExtendedConfigOfReferencedProject: "Extended config file of referenced project", @@ -124219,7 +124884,6 @@ var ts; readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, - now: ts.maybeBind(host, host.now), }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -124377,7 +125041,6 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - host.now = ts.maybeBind(system, system.now); ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -124428,7 +125091,6 @@ var ts; var parsedConfigs; // Parsed commandline and watching cached for referenced projects var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation - var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files @@ -124459,7 +125121,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -124485,7 +125147,7 @@ var ts; compilerHost.getCompilationSettings = function () { return compilerOptions; }; compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect); compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); }; - compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); }; + compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); }; compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); }; compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; }; compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations; @@ -124519,6 +125181,9 @@ var ts; return host.resolveTypeReferenceDirectives.apply(host, args); }) : (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); }); + compilerHost.getModuleResolutionCache = host.resolveModuleNames ? + ts.maybeBind(host, host.getModuleResolutionCache) : + (function () { return resolutionCache.getModuleResolutionCache(); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); synchronizeProgram(); @@ -124581,12 +125246,12 @@ var ts; var program = getCurrentBuilderProgram(); if (hasChangedCompilerOptions) { newLine = updateNewLine(); - if (program && (changesAffectResolution || ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) { + if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) { resolutionCache.clear(); } } // All resolutions are invalid if user provided resolutions - var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution); + var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { @@ -124602,7 +125267,6 @@ var ts; } createNewProgram(hasInvalidatedResolution); } - changesAffectResolution = false; // reset for next sync reportFileChangeDetectedOnCreateProgram = false; if (host.afterProgramCreate && program !== builderProgram) { host.afterProgramCreate(builderProgram); @@ -124612,18 +125276,19 @@ var ts; function createNewProgram(hasInvalidatedResolution) { // Compile the program writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; resolutionCache.startCachingPerDirectoryResolution(); compilerHost.hasInvalidatedResolution = hasInvalidatedResolution; compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames; + var oldProgram = getCurrentProgram(); builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); - resolutionCache.finishCachingPerDirectoryResolution(); + resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram); // Update watches ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath); if (needsUpdateInTypeRootWatch) { @@ -124705,9 +125370,6 @@ var ts; sourceFilesCache.set(path, false); } } - if (sourceFile) { - sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings()); - } return sourceFile; } return hostSourceFile.sourceFile; @@ -124770,7 +125432,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -124831,7 +125493,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -124872,7 +125534,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -125101,7 +125763,7 @@ var ts; UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function resolveConfigFileProjectName(project) { - if (ts.fileExtensionIs(project, ".json" /* Json */)) { + if (ts.fileExtensionIs(project, ".json" /* Extension.Json */)) { return project; } return ts.combinePaths(project, "tsconfig.json"); @@ -125164,8 +125826,8 @@ var ts; */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -125223,6 +125885,7 @@ var ts; compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); + compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache); var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined; if (!compilerHost.resolveModuleNames) { @@ -125705,8 +126368,7 @@ var ts; } // Actual Emit var host = state.host, compilerHost = state.compilerHost; - var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; - var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined; + var resultFlags = ((_d = program.hasChangedEmitSignature) === null || _d === void 0 ? void 0 : _d.call(program)) ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged; var emitterDiagnostics = ts.createDiagnosticCollection(); var emittedOutputs = new ts.Map(); var options = program.getCompilerOptions(); @@ -125714,17 +126376,11 @@ var ts; var outputTimeStampMap; var now; outputFiles.forEach(function (_a) { - var _b, _c; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; var path = toPath(state, name); emittedOutputs.set(toPath(state, name), name); - if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, options); - // Buildinfo has information on when last dts change time - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo === null || existingBuildInfo === void 0 ? void 0 : existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { - resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; - } - } + if (buildInfo) + setBuildInfo(state, buildInfo, projectPath, options, resultFlags); ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); if (!isIncremental && state.watch) { (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host))); @@ -125738,7 +126394,7 @@ var ts; ts.Debug.assert(step === BuildStep.EmitBuildInfo); var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) { if (data === null || data === void 0 ? void 0 : data.buildInfo) - setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions()); + setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions(), BuildResultFlags.DeclarationOutputUnchanged); if (writeFileCallback) writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data); else @@ -125771,7 +126427,6 @@ var ts; state.diagnostics.delete(projectPath); state.projectStatus.set(projectPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath), oldestOutputFileName: oldestOutputFileName }); afterProgramDone(state, program, config); @@ -125813,10 +126468,10 @@ var ts; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; emittedOutputs.set(toPath(state, name), name); if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, config.options); - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { + if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) { resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; } + setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags); } ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); }); @@ -125977,7 +126632,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -125991,7 +126646,7 @@ var ts; } function afterProgramDone(state, program, config) { if (program) { - if (program && state.write) + if (state.write) ts.listFiles(program, state.write); if (state.host.afterProgramEmitAndDiagnostics) { state.host.afterProgramEmitAndDiagnostics(program); @@ -126007,7 +126662,7 @@ var ts; // Since buildinfo has changeset and diagnostics when doing multi file emit, only --out cannot emit buildinfo if it has errors var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -126075,15 +126730,23 @@ var ts; state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map()); return result; } - function setBuildInfo(state, buildInfo, resolvedConfigPath, options) { + function setBuildInfo(state, buildInfo, resolvedConfigPath, options, resultFlags) { var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath); + var modifiedTime = getCurrentTime(state.host); if (existing) { existing.buildInfo = buildInfo; - existing.modifiedTime = getCurrentTime(state.host); + existing.modifiedTime = modifiedTime; + if (!(resultFlags & BuildResultFlags.DeclarationOutputUnchanged)) + existing.latestChangedDtsTime = modifiedTime; } else { - state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) }); + state.buildInfoCache.set(resolvedConfigPath, { + path: toPath(state, buildInfoPath), + buildInfo: buildInfo, + modifiedTime: modifiedTime, + latestChangedDtsTime: resultFlags & BuildResultFlags.DeclarationOutputUnchanged ? undefined : modifiedTime, + }); } } function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) { @@ -126115,7 +126778,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { - var _a, _b, _c; + var _a, _b; // Container if no files are specified in the project if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) { return { @@ -126127,8 +126790,8 @@ var ts; var force = !!state.options.force; if (project.projectReferences) { state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream }); - for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) { - var ref = _d[_i]; + for (var _i = 0, _c = project.projectReferences; _i < _c.length; _i++) { + var ref = _c[_i]; var resolvedRef = ts.resolveProjectReferencePath(ref); var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef); var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath); @@ -126168,7 +126831,6 @@ var ts; var buildInfoTime; var buildInfoProgram; var buildInfoVersionMap; - var newestDeclarationFileContentChangedTime; if (buildInfoPath) { var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath); buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath); @@ -126205,8 +126867,6 @@ var ts; } oldestOutputFileTime = buildInfoTime; oldestOutputFileName = buildInfoPath; - // Get the last dtsChange time from build info - newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; } // Check input files var newestInputFileName = undefined; @@ -126214,13 +126874,13 @@ var ts; /** True if input file has changed timestamp but text is not changed, we can then do only timestamp updates on output to make it look up-to-date later */ var pseudoInputUpToDate = false; // Get timestamps of input files - for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) { - var inputFile = _f[_e]; + for (var _d = 0, _e = project.fileNames; _d < _e.length; _d++) { + var inputFile = _e[_d]; var inputTime = getModifiedTime(state, inputFile); if (inputTime === ts.missingFileModifiedTime) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } // If an buildInfo is older than the newest input, we can stop checking @@ -126256,8 +126916,8 @@ var ts; // Collect the expected outputs of this project var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath); - for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) { - var output = outputs_1[_g]; + for (var _f = 0, outputs_1 = outputs; _f < outputs_1.length; _f++) { + var output = outputs_1[_f]; var path = toPath(state, output); // Output is missing; can stop checking var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path); @@ -126295,8 +126955,8 @@ var ts; var usesPrepend = false; var upstreamChangedProject; if (referenceStatuses) { - for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) { - var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath; + for (var _g = 0, referenceStatuses_1 = referenceStatuses; _g < referenceStatuses_1.length; _g++) { + var _h = referenceStatuses_1[_g], ref = _h.ref, refStatus = _h.refStatus, resolvedConfig = _h.resolvedConfig, resolvedRefPath = _h.resolvedRefPath; usesPrepend = usesPrepend || !!(ref.prepend); // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it @@ -126313,7 +126973,8 @@ var ts; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + var newestDeclarationFileContentChangedTime = getLatestChangedDtsTime(state, resolvedConfig.options, resolvedRefPath); + if (newestDeclarationFileContentChangedTime && newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -126356,7 +127017,6 @@ var ts; pseudoInputUpToDate ? ts.UpToDateStatusType.UpToDateWithInputFileText : ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, newestInputFileTime: newestInputFileTime, newestInputFileName: newestInputFileName, oldestOutputFileName: oldestOutputFileName @@ -126440,13 +127100,17 @@ var ts; outputTimeStampMap.delete(key); }); } - function getDtsChangeTime(state, options, resolvedConfigPath) { - var _a; + function getLatestChangedDtsTime(state, options, resolvedConfigPath) { if (!options.composite) return undefined; - var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); - var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined); - return ((_a = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.program) === null || _a === void 0 ? void 0 : _a.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; + var entry = ts.Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath)); + if (entry.latestChangedDtsTime !== undefined) + return entry.latestChangedDtsTime || undefined; + var latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ? + state.host.getModifiedTime(ts.getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, ts.getDirectoryPath(entry.path))) : + undefined; + entry.latestChangedDtsTime = latestChangedDtsTime || false; + return latestChangedDtsTime; } function updateOutputTimestamps(state, proj, resolvedPath) { if (state.options.dry) { @@ -126455,7 +127119,6 @@ var ts; updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0); state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath), oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames()) }); } @@ -126591,7 +127254,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -127251,7 +127914,7 @@ var ts; (function (ts) { // These utilities are common to multiple language service features. //#region - ts.scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); var SemanticMeaning; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -127262,66 +127925,66 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 292 /* CatchClause */: - case 285 /* JsxAttribute */: - return 1 /* Value */; - case 163 /* TypeParameter */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 182 /* TypeLiteral */: - return 2 /* Type */; - case 345 /* JSDocTypedefTag */: + case 254 /* SyntaxKind.VariableDeclaration */: + return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* SemanticMeaning.All */ : 1 /* SemanticMeaning.Value */; + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 292 /* SyntaxKind.CatchClause */: + case 285 /* SyntaxKind.JsxAttribute */: + return 1 /* SemanticMeaning.Value */; + case 163 /* SyntaxKind.TypeParameter */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + return 2 /* SemanticMeaning.Type */; + case 345 /* SyntaxKind.JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. - return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 299 /* EnumMember */: - case 257 /* ClassDeclaration */: - return 1 /* Value */ | 2 /* Type */; - case 261 /* ModuleDeclaration */: + return node.name === undefined ? 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */ : 2 /* SemanticMeaning.Type */; + case 299 /* SyntaxKind.EnumMember */: + case 257 /* SyntaxKind.ClassDeclaration */: + return 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */; + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isAmbientModule(node)) { - return 4 /* Namespace */ | 1 /* Value */; + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { - return 4 /* Namespace */ | 1 /* Value */; + else if (ts.getModuleInstanceState(node) === 1 /* ModuleInstanceState.Instantiated */) { + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } else { - return 4 /* Namespace */; - } - case 260 /* EnumDeclaration */: - case 269 /* NamedImports */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: - return 7 /* All */; + return 4 /* SemanticMeaning.Namespace */; + } + case 260 /* SyntaxKind.EnumDeclaration */: + case 269 /* SyntaxKind.NamedImports */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: + return 7 /* SemanticMeaning.All */; // An external module can be a Value - case 305 /* SourceFile */: - return 4 /* Namespace */ | 1 /* Value */; + case 305 /* SyntaxKind.SourceFile */: + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); var parent = node.parent; - if (node.kind === 305 /* SourceFile */) { - return 1 /* Value */; + if (node.kind === 305 /* SyntaxKind.SourceFile */) { + return 1 /* SemanticMeaning.Value */; } else if (ts.isExportAssignment(parent) || ts.isExportSpecifier(parent) @@ -127329,7 +127992,7 @@ var ts; || ts.isImportSpecifier(parent) || ts.isImportClause(parent) || ts.isImportEqualsDeclaration(parent) && node === parent.name) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { return getMeaningFromRightHandSideOfImportEquals(node); @@ -127338,24 +128001,24 @@ var ts; return getMeaningFromDeclaration(parent); } else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isTypeReference(node)) { - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (isNamespaceReference(node)) { - return 4 /* Namespace */; + return 4 /* SemanticMeaning.Namespace */; } else if (ts.isTypeParameterDeclaration(parent)) { ts.Debug.assert(ts.isJSDocTemplateTag(parent.parent)); // Else would be handled by isDeclarationName - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (ts.isLiteralTypeNode(parent)) { // This might be T["name"], which is actually referencing a property and not a type. So allow both meanings. - return 2 /* Type */ | 1 /* Value */; + return 2 /* SemanticMeaning.Type */ | 1 /* SemanticMeaning.Value */; } else { - return 1 /* Value */; + return 1 /* SemanticMeaning.Value */; } } ts.getMeaningFromLocation = getMeaningFromLocation; @@ -127363,11 +128026,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 161 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 265 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 161 /* SyntaxKind.QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? 7 /* SemanticMeaning.All */ : 4 /* SemanticMeaning.Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -127379,27 +128042,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 161 /* QualifiedName */) { - while (root.parent && root.parent.kind === 161 /* QualifiedName */) { + if (root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + while (root.parent && root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 178 /* TypeReference */ && !isLastClause; + return root.parent.kind === 178 /* SyntaxKind.TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 206 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 206 /* PropertyAccessExpression */) { + if (root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 228 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 257 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || - (decl.kind === 258 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); + return (decl.kind === 257 /* SyntaxKind.ClassDeclaration */ && root.parent.parent.token === 117 /* SyntaxKind.ImplementsKeyword */) || + (decl.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && root.parent.parent.token === 94 /* SyntaxKind.ExtendsKeyword */); } return false; } @@ -127408,17 +128071,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return !ts.isExpressionNode(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return true; } switch (node.parent.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return true; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return !node.parent.isTypeOf; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isPartOfTypeNode(node.parent); } return false; @@ -127485,7 +128148,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 250 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 250 /* SyntaxKind.LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -127546,22 +128209,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 261 /* ModuleDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.parent.argumentExpression === node; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return true; - case 196 /* LiteralType */: - return node.parent.parent.kind === 194 /* IndexedAccessType */; + case 196 /* SyntaxKind.LiteralType */: + return node.parent.parent.kind === 194 /* SyntaxKind.IndexedAccessType */; default: return false; } @@ -127585,17 +128248,17 @@ var ts; return undefined; } switch (node.kind) { - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return node; } } @@ -127603,108 +128266,108 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 305 /* SourceFile */: - return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 261 /* ModuleDeclaration */: - return "module" /* moduleElement */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return "class" /* classElement */; - case 258 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 259 /* TypeAliasDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - return "type" /* typeElement */; - case 260 /* EnumDeclaration */: return "enum" /* enumElement */; - case 254 /* VariableDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + return ts.isExternalModule(node) ? "module" /* ScriptElementKind.moduleElement */ : "script" /* ScriptElementKind.scriptElement */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return "module" /* ScriptElementKind.moduleElement */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return "class" /* ScriptElementKind.classElement */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return "interface" /* ScriptElementKind.interfaceElement */; + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + return "type" /* ScriptElementKind.typeElement */; + case 260 /* SyntaxKind.EnumDeclaration */: return "enum" /* ScriptElementKind.enumElement */; + case 254 /* SyntaxKind.VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - return "function" /* functionElement */; - case 172 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 173 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - return "method" /* memberFunctionElement */; - case 296 /* PropertyAssignment */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + return "function" /* ScriptElementKind.functionElement */; + case 172 /* SyntaxKind.GetAccessor */: return "getter" /* ScriptElementKind.memberGetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: return "setter" /* ScriptElementKind.memberSetAccessorElement */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + return "method" /* ScriptElementKind.memberFunctionElement */; + case 296 /* SyntaxKind.PropertyAssignment */: var initializer = node.initializer; - return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: - return "property" /* memberVariableElement */; - case 176 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 175 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 174 /* CallSignature */: return "call" /* callSignatureElement */; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: - return "constructor" /* constructorImplementationElement */; - case 163 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 299 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 164 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - return "alias" /* alias */; - case 221 /* BinaryExpression */: + return ts.isFunctionLike(initializer) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: + return "property" /* ScriptElementKind.memberVariableElement */; + case 176 /* SyntaxKind.IndexSignature */: return "index" /* ScriptElementKind.indexSignatureElement */; + case 175 /* SyntaxKind.ConstructSignature */: return "construct" /* ScriptElementKind.constructSignatureElement */; + case 174 /* SyntaxKind.CallSignature */: return "call" /* ScriptElementKind.callSignatureElement */; + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + case 163 /* SyntaxKind.TypeParameter */: return "type parameter" /* ScriptElementKind.typeParameterElement */; + case 299 /* SyntaxKind.EnumMember */: return "enum member" /* ScriptElementKind.enumMemberElement */; + case 164 /* SyntaxKind.Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) ? "property" /* ScriptElementKind.memberVariableElement */ : "parameter" /* ScriptElementKind.parameterElement */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + return "alias" /* ScriptElementKind.alias */; + case 221 /* SyntaxKind.BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: - case 0 /* None */: - return "" /* unknown */; - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: + case 0 /* AssignmentDeclarationKind.None */: + return "" /* ScriptElementKind.unknown */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: var rightKind = getNodeKind(right); - return rightKind === "" /* unknown */ ? "const" /* constElement */ : rightKind; - case 3 /* PrototypeProperty */: - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 4 /* ThisProperty */: - return "property" /* memberVariableElement */; // property - case 5 /* Property */: + return rightKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : rightKind; + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 4 /* AssignmentDeclarationKind.ThisProperty */: + return "property" /* ScriptElementKind.memberVariableElement */; // property + case 5 /* AssignmentDeclarationKind.Property */: // static method / property - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 6 /* Prototype */: - return "local class" /* localClassElement */; + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 6 /* AssignmentDeclarationKind.Prototype */: + return "local class" /* ScriptElementKind.localClassElement */; default: { ts.assertType(kind); - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } } - case 79 /* Identifier */: - return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 271 /* ExportAssignment */: + case 79 /* SyntaxKind.Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* ScriptElementKind.alias */ : "" /* ScriptElementKind.unknown */; + case 271 /* SyntaxKind.ExportAssignment */: var scriptKind = getNodeKind(node.expression); // If the expression didn't come back with something (like it does for an identifiers) - return scriptKind === "" /* unknown */ ? "const" /* constElement */ : scriptKind; + return scriptKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : scriptKind; default: - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ + ? "const" /* ScriptElementKind.constElement */ : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "let" /* ScriptElementKind.letElement */ + : "var" /* ScriptElementKind.variableElement */; } } ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* SyntaxKind.Parameter */; default: return false; } @@ -127769,42 +128432,42 @@ var ts; return false; } switch (n.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 201 /* ObjectBindingPattern */: - case 182 /* TypeLiteral */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 263 /* CaseBlock */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: - return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 292 /* CatchClause */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 182 /* SyntaxKind.TypeLiteral */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 263 /* SyntaxKind.CaseBlock */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: + return nodeEndsWith(n, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + case 292 /* SyntaxKind.CatchClause */: return isCompletedNode(n.block, sourceFile); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: if (!n.arguments) { return true; } // falls through - case 208 /* CallExpression */: - case 212 /* ParenthesizedExpression */: - case 191 /* ParenthesizedType */: - return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 208 /* SyntaxKind.CallExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + return nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -127813,66 +128476,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 261 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 261 /* SyntaxKind.ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 204 /* ArrayLiteralExpression */: - case 202 /* ArrayBindingPattern */: - case 207 /* ElementAccessExpression */: - case 162 /* ComputedPropertyName */: - case 184 /* TupleType */: - return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 176 /* IndexSignature */: + hasChildOfKind(n, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 184 /* SyntaxKind.TupleType */: + return nodeEndsWith(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 176 /* SyntaxKind.IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + return hasChildOfKind(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 115 /* SyntaxKind.WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 216 /* TypeOfExpression */: - case 215 /* DeleteExpression */: - case 217 /* VoidExpression */: - case 224 /* YieldExpression */: - case 225 /* SpreadElement */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 225 /* SyntaxKind.SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -127889,7 +128552,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SyntaxKind.SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -127932,13 +128595,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 84 /* ClassKeyword */; + return node.kind === 84 /* SyntaxKind.ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 98 /* FunctionKeyword */; + return node.kind === 98 /* SyntaxKind.FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -127997,13 +128660,13 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return getAdjustedLocationForClass(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return getAdjustedLocationForFunction(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return node; } } @@ -128093,30 +128756,30 @@ var ts; // // NOTE: If the node is a modifier, we don't adjust its location if it is the `default` modifier as that is handled // specially by `getSymbolAtLocation`. - if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? ts.canHaveModifiers(parent) && ts.contains(parent.modifiers, node) : - node.kind === 84 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 98 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 118 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 92 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 152 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 142 /* NamespaceKeyword */ || node.kind === 141 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 136 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 149 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* SyntaxKind.DefaultKeyword */) ? ts.canHaveModifiers(parent) && ts.contains(parent.modifiers, node) : + node.kind === 84 /* SyntaxKind.ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : + node.kind === 98 /* SyntaxKind.FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : + node.kind === 118 /* SyntaxKind.InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : + node.kind === 92 /* SyntaxKind.EnumKeyword */ ? ts.isEnumDeclaration(parent) : + node.kind === 152 /* SyntaxKind.TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 142 /* SyntaxKind.NamespaceKeyword */ || node.kind === 141 /* SyntaxKind.ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 136 /* SyntaxKind.GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 149 /* SyntaxKind.SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && + if ((node.kind === 113 /* SyntaxKind.VarKeyword */ || node.kind === 85 /* SyntaxKind.ConstKeyword */ || node.kind === 119 /* SyntaxKind.LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 152 /* TypeKeyword */) { + if (node.kind === 152 /* SyntaxKind.TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -128142,7 +128805,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 127 /* AsKeyword */) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -128158,13 +128821,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* SyntaxKind.ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 93 /* ExportKeyword */) { + if (node.kind === 93 /* SyntaxKind.ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -128183,12 +128846,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 146 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 146 /* SyntaxKind.RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 156 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 156 /* SyntaxKind.FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -128196,13 +128859,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* SyntaxKind.ExtendsKeyword */ || node.kind === 117 /* SyntaxKind.ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 94 /* ExtendsKeyword */) { + if (node.kind === 94 /* SyntaxKind.ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -128213,20 +128876,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 137 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 137 /* SyntaxKind.InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 140 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* KeyOfKeyword */ && + if (node.kind === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 145 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* ReadonlyKeyword */ && + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -128241,29 +128904,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 132 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* SyntaxKind.NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* SyntaxKind.TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 132 /* SyntaxKind.AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* SyntaxKind.YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* SyntaxKind.DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* SyntaxKind.InKeyword */ || node.kind === 102 /* SyntaxKind.InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 160 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isForInStatement(parent) || + node.kind === 160 /* SyntaxKind.OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -128332,25 +128995,31 @@ var ts; // flag causes us to return the first node whose end position matches the position and which produces and acceptable token // kind. Meanwhile, if includePrecedingTokenAtEndPosition is unset, we look for the first node whose start is <= the // position and whose end is greater than the position. + // There are more sophisticated end tests later, but this one is very fast + // and allows us to skip a bunch of work + var end = children[middle].getEnd(); + if (end < position) { + return -1 /* Comparison.LessThan */; + } var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } // first element whose start position is before the input and whose end position is after or equal to the input - if (nodeContainsPosition(children[middle])) { + if (nodeContainsPosition(children[middle], start, end)) { if (children[middle - 1]) { // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position if (nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // this complex condition makes us left-recur around a zero-length node when includePrecedingTokenAtEndPosition is set, rather than right-recur on it if (includePrecedingTokenAtEndPosition && start === position && children[middle - 1] && children[middle - 1].getEnd() === position && nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (foundToken) { return { value: foundToken }; @@ -128369,14 +129038,17 @@ var ts; case "continue-outer": continue outer; } } - function nodeContainsPosition(node) { - var start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true); + function nodeContainsPosition(node, start, end) { + end !== null && end !== void 0 ? end : (end = node.getEnd()); + if (end < position) { + return false; + } + start !== null && start !== void 0 ? start : (start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true)); if (start > position) { // If this child begins after position, then all subsequent children will as well. return false; } - var end = node.getEnd(); - if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) { + if (position < end || (position === end && (node.kind === 1 /* SyntaxKind.EndOfFileToken */ || includeEndPosition))) { return true; } else if (includePrecedingTokenAtEndPosition && end === position) { @@ -128445,7 +129117,7 @@ var ts; ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; function find(n) { - if (isNonWhitespaceToken(n) && n.kind !== 1 /* EndOfFileToken */) { + if (isNonWhitespaceToken(n) && n.kind !== 1 /* SyntaxKind.EndOfFileToken */) { return n; } var children = n.getChildren(sourceFile); @@ -128457,11 +129129,11 @@ var ts; if (position < children[middle].end) { // first element whose end position is greater than the input position if (!children[middle - 1] || position >= children[middle - 1].end) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (i >= 0 && children[i]) { var child = children[i]; @@ -128486,7 +129158,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SyntaxKind.SourceFile */ || n.kind === 1 /* SyntaxKind.EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -128517,7 +129189,7 @@ var ts; for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 279 /* JsxSelfClosingElement */)) { + if (i === 0 && (parentKind === 11 /* SyntaxKind.JsxText */ || parentKind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); } } @@ -128553,25 +129225,25 @@ var ts; if (!token) { return false; } - if (token.kind === 11 /* JsxText */) { + if (token.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
Hello |
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 281 /* JsxClosingElement */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return true; } return false; @@ -128590,10 +129262,10 @@ var ts; if (ts.isJsxText(token)) { return true; } - if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -128602,17 +129274,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 279 /* JsxSelfClosingElement */ && node.kind <= 288 /* JsxExpression */ - || node.kind === 11 /* JsxText */ - || node.kind === 29 /* LessThanToken */ - || node.kind === 31 /* GreaterThanToken */ - || node.kind === 79 /* Identifier */ - || node.kind === 19 /* CloseBraceToken */ - || node.kind === 18 /* OpenBraceToken */ - || node.kind === 43 /* SlashToken */) { + if (node.kind >= 279 /* SyntaxKind.JsxSelfClosingElement */ && node.kind <= 288 /* SyntaxKind.JsxExpression */ + || node.kind === 11 /* SyntaxKind.JsxText */ + || node.kind === 29 /* SyntaxKind.LessThanToken */ + || node.kind === 31 /* SyntaxKind.GreaterThanToken */ + || node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 19 /* SyntaxKind.CloseBraceToken */ + || node.kind === 18 /* SyntaxKind.OpenBraceToken */ + || node.kind === 43 /* SyntaxKind.SlashToken */) { node = node.parent; } - else if (node.kind === 278 /* JsxElement */) { + else if (node.kind === 278 /* SyntaxKind.JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -128702,10 +129374,10 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); - if (token && token.kind === 28 /* QuestionDotToken */) { + if (token && token.kind === 28 /* SyntaxKind.QuestionDotToken */) { token = findPrecedingToken(token.getFullStart(), sourceFile); } if (!token || !ts.isIdentifier(token)) @@ -128715,56 +129387,56 @@ var ts; } remainingLessThanTokens--; break; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 48 /* GreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: remainingLessThanTokens++; break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* SyntaxKind.OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: nTypeArguments++; break; - case 38 /* EqualsGreaterThanToken */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: // falls through - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: // falls through - case 112 /* TypeOfKeyword */: - case 94 /* ExtendsKeyword */: - case 140 /* KeyOfKeyword */: - case 24 /* DotToken */: - case 51 /* BarToken */: - case 57 /* QuestionToken */: - case 58 /* ColonToken */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 94 /* SyntaxKind.ExtendsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 24 /* SyntaxKind.DotToken */: + case 51 /* SyntaxKind.BarToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 58 /* SyntaxKind.ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -128796,52 +129468,52 @@ var ts; function nodeHasTokens(n, sourceFile) { // If we have a token or node that has a non-zero width, it must have tokens. // Note: getWidth() does not take trivia into account. - return n.kind === 1 /* EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; + return n.kind === 1 /* SyntaxKind.EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node, excludeFlags) { - if (excludeFlags === void 0) { excludeFlags = 0 /* None */; } + if (excludeFlags === void 0) { excludeFlags = 0 /* ModifierFlags.None */; } var result = []; var flags = ts.isDeclaration(node) ? ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(node) & ~excludeFlags - : 0 /* None */; - if (flags & 8 /* Private */) - result.push("private" /* privateMemberModifier */); - if (flags & 16 /* Protected */) - result.push("protected" /* protectedMemberModifier */); - if (flags & 4 /* Public */) - result.push("public" /* publicMemberModifier */); - if (flags & 32 /* Static */ || ts.isClassStaticBlockDeclaration(node)) - result.push("static" /* staticModifier */); - if (flags & 128 /* Abstract */) - result.push("abstract" /* abstractModifier */); - if (flags & 1 /* Export */) - result.push("export" /* exportedModifier */); - if (flags & 8192 /* Deprecated */) - result.push("deprecated" /* deprecatedModifier */); - if (node.flags & 16777216 /* Ambient */) - result.push("declare" /* ambientModifier */); - if (node.kind === 271 /* ExportAssignment */) - result.push("export" /* exportedModifier */); - return result.length > 0 ? result.join(",") : "" /* none */; + : 0 /* ModifierFlags.None */; + if (flags & 8 /* ModifierFlags.Private */) + result.push("private" /* ScriptElementKindModifier.privateMemberModifier */); + if (flags & 16 /* ModifierFlags.Protected */) + result.push("protected" /* ScriptElementKindModifier.protectedMemberModifier */); + if (flags & 4 /* ModifierFlags.Public */) + result.push("public" /* ScriptElementKindModifier.publicMemberModifier */); + if (flags & 32 /* ModifierFlags.Static */ || ts.isClassStaticBlockDeclaration(node)) + result.push("static" /* ScriptElementKindModifier.staticModifier */); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push("abstract" /* ScriptElementKindModifier.abstractModifier */); + if (flags & 1 /* ModifierFlags.Export */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + if (flags & 8192 /* ModifierFlags.Deprecated */) + result.push("deprecated" /* ScriptElementKindModifier.deprecatedModifier */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) + result.push("declare" /* ScriptElementKindModifier.ambientModifier */); + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + return result.length > 0 ? result.join(",") : "" /* ScriptElementKindModifier.none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 178 /* TypeReference */ || node.kind === 208 /* CallExpression */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 208 /* SyntaxKind.CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 257 /* ClassDeclaration */ || node.kind === 258 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isComment(kind) { - return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; + return kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || kind === 3 /* SyntaxKind.MultiLineCommentTrivia */; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 10 /* StringLiteral */ - || kind === 13 /* RegularExpressionLiteral */ + if (kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 13 /* SyntaxKind.RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -128849,7 +129521,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; + return 18 /* SyntaxKind.FirstPunctuation */ <= kind && kind <= 78 /* SyntaxKind.LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -128859,9 +129531,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: return true; } return false; @@ -128874,18 +129546,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 204 /* ArrayLiteralExpression */ || - node.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || + node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 221 /* BinaryExpression */ && + if (node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 63 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 244 /* ForOfStatement */ && + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -128893,7 +129565,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -128916,8 +129588,8 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTextSpanFromStringLiteralLikeContent(contextToken); default: return createTextSpanFromNode(contextToken); @@ -128955,32 +129627,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 130 /* AnyKeyword */, - 128 /* AssertsKeyword */, - 158 /* BigIntKeyword */, - 133 /* BooleanKeyword */, - 95 /* FalseKeyword */, - 137 /* InferKeyword */, - 140 /* KeyOfKeyword */, - 143 /* NeverKeyword */, - 104 /* NullKeyword */, - 147 /* NumberKeyword */, - 148 /* ObjectKeyword */, - 145 /* ReadonlyKeyword */, - 150 /* StringKeyword */, - 151 /* SymbolKeyword */, - 110 /* TrueKeyword */, - 114 /* VoidKeyword */, - 153 /* UndefinedKeyword */, - 154 /* UniqueKeyword */, - 155 /* UnknownKeyword */, + 130 /* SyntaxKind.AnyKeyword */, + 128 /* SyntaxKind.AssertsKeyword */, + 158 /* SyntaxKind.BigIntKeyword */, + 133 /* SyntaxKind.BooleanKeyword */, + 95 /* SyntaxKind.FalseKeyword */, + 137 /* SyntaxKind.InferKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 143 /* SyntaxKind.NeverKeyword */, + 104 /* SyntaxKind.NullKeyword */, + 147 /* SyntaxKind.NumberKeyword */, + 148 /* SyntaxKind.ObjectKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 150 /* SyntaxKind.StringKeyword */, + 151 /* SyntaxKind.SymbolKeyword */, + 110 /* SyntaxKind.TrueKeyword */, + 114 /* SyntaxKind.VoidKeyword */, + 153 /* SyntaxKind.UndefinedKeyword */, + 154 /* SyntaxKind.UniqueKeyword */, + 155 /* SyntaxKind.UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 152 /* TypeKeyword */; + return node.kind === 152 /* SyntaxKind.TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; function isTypeKeywordTokenOrIdentifier(node) { @@ -128989,7 +129661,7 @@ var ts; ts.isTypeKeywordTokenOrIdentifier = isTypeKeywordTokenOrIdentifier; /** True if the symbol is for an external module, as opposed to a namespace. */ function isExternalModuleSymbol(moduleSymbol) { - return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */; + return !!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isExternalModuleSymbol = isExternalModuleSymbol; function nodeSeenTracker() { @@ -129017,7 +129689,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 162 /* ComputedPropertyName */ + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name); @@ -129032,7 +129704,7 @@ var ts; } ts.programContainsEsModules = programContainsEsModules; function compilerOptionsIndicateEsModules(compilerOptions) { - return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit; + return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ || !!compilerOptions.noEmit; } ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules; function createModuleSpecifierResolutionHost(program, host) { @@ -129080,7 +129752,7 @@ var ts; } ts.makeImport = makeImport; function makeStringLiteral(text, quotePreference) { - return ts.factory.createStringLiteral(text, quotePreference === 0 /* Single */); + return ts.factory.createStringLiteral(text, quotePreference === 0 /* QuotePreference.Single */); } ts.makeStringLiteral = makeStringLiteral; var QuotePreference; @@ -129089,25 +129761,25 @@ var ts; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); function quotePreferenceFromString(str, sourceFile) { - return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* QuotePreference.Double */ : 0 /* QuotePreference.Single */; } ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference && preferences.quotePreference !== "auto") { - return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; + return preferences.quotePreference === "single" ? 0 /* QuotePreference.Single */ : 1 /* QuotePreference.Double */; } else { // ignore synthetic import added when importHelpers: true var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, function (n) { return ts.isStringLiteral(n) && !ts.nodeIsSynthesized(n.parent); }); - return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* QuotePreference.Double */; } } ts.getQuotePreference = getQuotePreference; function getQuoteFromPreference(qp) { switch (qp) { - case 0 /* Single */: return "'"; - case 1 /* Double */: return '"'; + case 0 /* QuotePreference.Single */: return "'"; + case 1 /* QuotePreference.Double */: return '"'; default: return ts.Debug.assertNever(qp); } } @@ -129118,12 +129790,12 @@ var ts; } ts.symbolNameNoDefault = symbolNameNoDefault; function symbolEscapedNameNoDefault(symbol) { - if (symbol.escapedName !== "default" /* Default */) { + if (symbol.escapedName !== "default" /* InternalSymbolName.Default */) { return symbol.escapedName; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* SyntaxKind.Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -129167,7 +129839,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 237 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 237 /* SyntaxKind.VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate); var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports]; if (!existingImportStatements.length) { @@ -129380,34 +130052,34 @@ var ts; return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } - if (flags & 4 /* Property */) + if (flags & 4 /* SymbolFlags.Property */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 32768 /* GetAccessor */) + if (flags & 32768 /* SymbolFlags.GetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 65536 /* SetAccessor */) + if (flags & 65536 /* SymbolFlags.SetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 8 /* EnumMember */) + if (flags & 8 /* SymbolFlags.EnumMember */) return ts.SymbolDisplayPartKind.enumMemberName; - if (flags & 16 /* Function */) + if (flags & 16 /* SymbolFlags.Function */) return ts.SymbolDisplayPartKind.functionName; - if (flags & 32 /* Class */) + if (flags & 32 /* SymbolFlags.Class */) return ts.SymbolDisplayPartKind.className; - if (flags & 64 /* Interface */) + if (flags & 64 /* SymbolFlags.Interface */) return ts.SymbolDisplayPartKind.interfaceName; - if (flags & 384 /* Enum */) + if (flags & 384 /* SymbolFlags.Enum */) return ts.SymbolDisplayPartKind.enumName; - if (flags & 1536 /* Module */) + if (flags & 1536 /* SymbolFlags.Module */) return ts.SymbolDisplayPartKind.moduleName; - if (flags & 8192 /* Method */) + if (flags & 8192 /* SymbolFlags.Method */) return ts.SymbolDisplayPartKind.methodName; - if (flags & 262144 /* TypeParameter */) + if (flags & 262144 /* SymbolFlags.TypeParameter */) return ts.SymbolDisplayPartKind.typeParameterName; - if (flags & 524288 /* TypeAlias */) + if (flags & 524288 /* SymbolFlags.TypeAlias */) return ts.SymbolDisplayPartKind.aliasName; - if (flags & 2097152 /* Alias */) + if (flags & 2097152 /* SymbolFlags.Alias */) return ts.SymbolDisplayPartKind.aliasName; return ts.SymbolDisplayPartKind.text; } @@ -129484,7 +130156,7 @@ var ts; var prefix = ts.isJSDocLink(link) ? "link" : ts.isJSDocLinkCode(link) ? "linkcode" : "linkplain"; - var parts = [linkPart("{@" + prefix + " ")]; + var parts = [linkPart("{@".concat(prefix, " "))]; if (!link.name) { if (link.text) { parts.push(linkTextPart(link.text)); @@ -129511,8 +130183,8 @@ var ts; ts.buildLinkParts = buildLinkParts; function skipSeparatorFromLinkText(text) { var pos = 0; - if (text.charCodeAt(pos++) === 124 /* bar */) { - while (pos < text.length && text.charCodeAt(pos) === 32 /* space */) + if (text.charCodeAt(pos++) === 124 /* CharacterCodes.bar */) { + while (pos < text.length && text.charCodeAt(pos) === 32 /* CharacterCodes.space */) pos++; return text.slice(pos); } @@ -129562,22 +130234,22 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* SymbolFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer); + typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } - flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + flags |= 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */ | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */ | 8192 /* TypeFormatFlags.OmitParameterModifiers */; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer); }); @@ -129587,7 +130259,7 @@ var ts; var file = enclosingDeclaration.getSourceFile(); return mapToDisplayParts(function (writer) { var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - printer.writeNode(4 /* Unspecified */, node, file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, node, file, writer); }); } ts.nodeToDisplayParts = nodeToDisplayParts; @@ -129615,10 +130287,10 @@ var ts; } ts.getSymbolTarget = getSymbolTarget; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } function isAliasSymbol(symbol) { - return (symbol.flags & 2097152 /* Alias */) !== 0; + return (symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0; } function getUniqueSymbolId(symbol, checker) { return ts.getSymbolId(ts.skipAlias(symbol, checker)); @@ -129707,14 +130379,14 @@ var ts; * Sets EmitFlags to suppress leading trivia on the node. */ function suppressLeadingTrivia(node) { - addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); + addEmitFlagsRecursively(node, 512 /* EmitFlags.NoLeadingComments */, getFirstChild); } ts.suppressLeadingTrivia = suppressLeadingTrivia; /** * Sets EmitFlags to suppress trailing trivia on the node. */ function suppressTrailingTrivia(node) { - addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); + addEmitFlagsRecursively(node, 1024 /* EmitFlags.NoTrailingComments */, ts.getLastChild); } ts.suppressTrailingTrivia = suppressTrailingTrivia; function copyComments(sourceNode, targetNode) { @@ -129733,7 +130405,7 @@ var ts; var start = node.getFullStart(); var end = node.getStart(); for (var i = start; i < end; i++) { - if (text.charCodeAt(i) === 10 /* lineFeed */) + if (text.charCodeAt(i) === 10 /* CharacterCodes.lineFeed */) return true; } return false; @@ -129750,7 +130422,7 @@ var ts; function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { - nameText = baseName + "_" + i; + nameText = "".concat(baseName, "_").concat(i); } return nameText; } @@ -129769,7 +130441,7 @@ var ts; for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { var change = textChanges_1[_b]; var span = change.span, newText = change.newText; - var index = indexInTextChange(newText, name); + var index = indexInTextChange(newText, ts.escapeString(name)); if (index !== -1) { lastPos = span.start + delta + index; // If the reference comes first, return immediately. @@ -129807,7 +130479,7 @@ var ts; ts.copyTrailingAsLeadingComments = copyTrailingAsLeadingComments; function getAddCommentsFunction(targetNode, sourceFile, commentKind, hasTrailingNewLine, cb) { return function (pos, end, kind, htnl) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // Remove leading /* pos += 2; // Remove trailing */ @@ -129833,7 +130505,7 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || ts.isObjectLiteralExpression(expression) || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } @@ -129841,15 +130513,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checker.getContextualType(parent); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -129860,15 +130532,15 @@ var ts; // Editors can pass in undefined or empty string - we want to infer the preference in those cases. var quotePreference = getQuotePreference(sourceFile, preferences); var quoted = JSON.stringify(text); - return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; + return quotePreference === 0 /* QuotePreference.Single */ ? "'".concat(ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"'), "'") : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: return true; default: return false; @@ -129877,10 +130549,10 @@ var ts; ts.isEqualityOperatorKind = isEqualityOperatorKind; function isStringLiteralOrTemplate(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 210 /* TaggedTemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return true; default: return false; @@ -129900,9 +130572,9 @@ var ts; var checker = program.getTypeChecker(); var typeIsAccessible = true; var notAccessible = function () { return typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { + var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NodeBuilderFlags.NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */; return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, @@ -129914,48 +130586,48 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 174 /* CallSignature */ - || kind === 175 /* ConstructSignature */ - || kind === 176 /* IndexSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */; + return kind === 174 /* SyntaxKind.CallSignature */ + || kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */; } function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 261 /* ModuleDeclaration */; + return kind === 261 /* SyntaxKind.ModuleDeclaration */; } function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 237 /* VariableStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 240 /* DoStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 246 /* BreakStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 167 /* PropertyDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); function nodeIsASICandidate(node, sourceFile) { var lastToken = node.getLastToken(sourceFile); - if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + if (lastToken && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */) { return false; } if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { - if (lastToken && lastToken.kind === 27 /* CommaToken */) { + if (lastToken && lastToken.kind === 27 /* SyntaxKind.CommaToken */) { return false; } } @@ -129975,12 +130647,12 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 240 /* DoStatement */) { + if (node.kind === 240 /* SyntaxKind.DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); var nextToken = findNextToken(node, topNode, sourceFile); - if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + if (!nextToken || nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { return true; } var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; @@ -130004,7 +130676,7 @@ var ts; ts.forEachChild(sourceFile, function visit(node) { if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } else { @@ -130013,10 +130685,10 @@ var ts; } else if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } - else if (lastToken && lastToken.kind !== 27 /* CommaToken */) { + else if (lastToken && lastToken.kind !== 27 /* SyntaxKind.CommaToken */) { var lastTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, lastToken.getStart(sourceFile)).line; var nextTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, ts.getSpanOfTokenAtPosition(sourceFile, lastToken.end).start).line; // Avoid counting missing semicolon in single-line objects: @@ -130140,16 +130812,16 @@ var ts; } } var dependencyGroups = [ - [1 /* Dependencies */, info.dependencies], - [2 /* DevDependencies */, info.devDependencies], - [8 /* OptionalDependencies */, info.optionalDependencies], - [4 /* PeerDependencies */, info.peerDependencies], + [1 /* PackageJsonDependencyGroup.Dependencies */, info.dependencies], + [2 /* PackageJsonDependencyGroup.DevDependencies */, info.devDependencies], + [8 /* PackageJsonDependencyGroup.OptionalDependencies */, info.optionalDependencies], + [4 /* PackageJsonDependencyGroup.PeerDependencies */, info.peerDependencies], ]; return __assign(__assign({}, info), { parseable: !!content, fileName: fileName, get: get, has: function (dependencyName, inGroups) { return !!get(dependencyName, inGroups); } }); function get(dependencyName, inGroups) { - if (inGroups === void 0) { inGroups = 15 /* All */; } + if (inGroups === void 0) { inGroups = 15 /* PackageJsonDependencyGroup.All */; } for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; if (deps && (inGroups & group_1)) { @@ -130244,7 +130916,7 @@ var ts; var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); // Scoped packages if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; + return "".concat(components[0], "/").concat(components[1]); } return components[0]; } @@ -130364,20 +131036,20 @@ var ts; } ts.getNameForExportedSymbol = getNameForExportedSymbol; function needsNameFromDeclaration(symbol) { - return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */); + return !(symbol.flags & 33554432 /* SymbolFlags.Transient */) && (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */ || symbol.escapedName === "default" /* InternalSymbolName.Default */); } function getDefaultLikeExportNameFromDeclaration(symbol) { return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; }); } function getSymbolParentOrFail(symbol) { var _a; - return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " + - ("Declarations: " + ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { + return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: ".concat(ts.Debug.formatSymbolFlags(symbol.flags), ". ") + + "Declarations: ".concat((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { var kind = ts.Debug.formatSyntaxKind(d.kind); var inJS = ts.isInJSFile(d); var expression = d.expression; - return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: " + ts.Debug.formatSyntaxKind(expression.kind) + ")" : ""); - }).join(", ")) + ".")); + return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: ".concat(ts.Debug.formatSyntaxKind(expression.kind), ")") : ""); + }).join(", "), ".")); } /** * Useful to check whether a string contains another string at a specific index @@ -130410,7 +131082,7 @@ var ts; } ts.stringContainsAt = stringContainsAt; function startsWithUnderscore(name) { - return name.charCodeAt(0) === 95 /* _ */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */; } ts.startsWithUnderscore = startsWithUnderscore; function isGlobalDeclaration(declaration) { @@ -130428,7 +131100,7 @@ var ts; } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* ModifierFlags.Deprecated */); } ts.isDeprecatedDeclaration = isDeprecatedDeclaration; function shouldUseUriStyleNodeCoreModules(file, program) { @@ -130441,7 +131113,7 @@ var ts; } ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules; function getNewLineKind(newLineCharacter) { - return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + return newLineCharacter === "\n" ? 1 /* NewLineKind.LineFeed */ : 0 /* NewLineKind.CarriageReturnLineFeed */; } ts.getNewLineKind = getNewLineKind; function diagnosticToString(diag) { @@ -130461,7 +131133,7 @@ var ts; } ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting; function jsxModeNeedsExplicitImport(jsx) { - return jsx === 2 /* React */ || jsx === 3 /* ReactNative */; + return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */; } ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport; // #endregion @@ -130533,7 +131205,7 @@ var ts; } } } - var isDefault = exportKind === 1 /* Default */; + var isDefault = exportKind === 1 /* ExportKind.Default */; var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol; // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`. // 2. A re-export merged with an export from a module augmentation can result in `symbol` @@ -130542,7 +131214,7 @@ var ts; // 3. Otherwise, we have a default/namespace import that can be imported by any name, and // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to // get a better name. - var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol) + var names = exportKind === 0 /* ExportKind.Named */ || ts.isExternalModuleSymbol(namedSymbol) ? ts.unescapeLeadingUnderscores(symbolTableKey) : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined); var symbolName = typeof names === "string" ? names : names[0]; @@ -130550,8 +131222,8 @@ var ts; var moduleName = ts.stripQuotes(moduleSymbol.name); var id = exportInfoId++; var target = ts.skipAlias(symbol, checker); - var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol; - var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol; + var storedSymbol = symbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : symbol; + var storedModuleSymbol = moduleSymbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : moduleSymbol; if (!storedSymbol || !storedModuleSymbol) symbols.set(id, [symbol, moduleSymbol]); exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), { @@ -130640,9 +131312,9 @@ var ts; var moduleSymbol = info.moduleSymbol || cachedModuleSymbol || ts.Debug.checkDefined(info.moduleFile ? checker.getMergedSymbol(info.moduleFile.symbol) : checker.tryFindAmbientModule(info.moduleName)); - var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportEquals */ + var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportKind.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) - : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '" + info.symbolName + "' by key '" + info.symbolTableKey + "' in module " + moduleSymbol.name); + : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '".concat(info.symbolName, "' by key '").concat(info.symbolTableKey, "' in module ").concat(moduleSymbol.name)); symbols.set(id, [symbol, moduleSymbol]); return { symbol: symbol, @@ -130655,7 +131327,7 @@ var ts; } function key(importedName, symbol, ambientModuleName, checker) { var moduleKey = ambientModuleName || ""; - return importedName + "|" + ts.getSymbolId(ts.skipAlias(symbol, checker)) + "|" + moduleKey; + return "".concat(importedName, "|").concat(ts.getSymbolId(ts.skipAlias(symbol, checker)), "|").concat(moduleKey); } function parseKey(key) { var symbolName = key.substring(0, key.indexOf("|")); @@ -130751,7 +131423,7 @@ var ts; if (autoImportProvider) { var start = ts.timestamp(); forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: ".concat(ts.timestamp() - start)); } } ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; @@ -130800,11 +131472,11 @@ var ts; // Note: I think we shouldn't actually see resolved module symbols here, but weird merges // can cause it to happen: see 'completionsImport_mergedReExport.ts' if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { - cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); + cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* ExportKind.Default */ ? "default" /* InternalSymbolName.Default */ : "export=" /* InternalSymbolName.ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); } checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { - cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker); + cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* ExportKind.Named */, isFromPackageJson, checker); } }); }); @@ -130814,7 +131486,7 @@ var ts; cache.clear(); throw err; } - (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in ".concat(ts.timestamp() - start, " ms")); return cache; } ts.getExportInfoMap = getExportInfoMap; @@ -130833,10 +131505,10 @@ var ts; function getDefaultLikeExportWorker(moduleSymbol, checker) { var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) - return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ }; - var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); + return { symbol: exportEquals, exportKind: 2 /* ExportKind.ExportEquals */ }; + var defaultExport = checker.tryGetMemberInModuleExports("default" /* InternalSymbolName.Default */, moduleSymbol); if (defaultExport) - return { symbol: defaultExport, exportKind: 1 /* Default */ }; + return { symbol: defaultExport, exportKind: 1 /* ExportKind.Default */ }; } function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -130845,7 +131517,7 @@ var ts; var name = getNameForExportDefault(defaultExport); if (name !== undefined) return { symbolForMeaning: defaultExport, name: name }; - if (defaultExport.flags & 2097152 /* Alias */) { + if (defaultExport.flags & 2097152 /* SymbolFlags.Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); if (aliased && aliased.parent) { // - `aliased` will be undefined if the module is exporting an unresolvable name, @@ -130855,8 +131527,8 @@ var ts; return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } - if (defaultExport.escapedName !== "default" /* Default */ && - defaultExport.escapedName !== "export=" /* ExportEquals */) { + if (defaultExport.escapedName !== "default" /* InternalSymbolName.Default */ && + defaultExport.escapedName !== "export=" /* InternalSymbolName.ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; @@ -130868,7 +131540,7 @@ var ts; return (_a = ts.tryCast(ts.skipOuterExpressions(declaration.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); + ts.Debug.assert(declaration.name.text === "default" /* InternalSymbolName.Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -130878,15 +131550,15 @@ var ts; (function (ts) { /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { return convertClassificationsToResult(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); } // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var token = 0 /* Unknown */; - var lastNonTriviaToken = 0 /* Unknown */; + var token = 0 /* SyntaxKind.Unknown */; + var lastNonTriviaToken = 0 /* SyntaxKind.Unknown */; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -130912,10 +131584,10 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(15 /* TemplateHead */); + templateStack.push(15 /* SyntaxKind.TemplateHead */); } scanner.setText(text); - var endOfLineState = 0 /* None */; + var endOfLineState = 0 /* EndOfLineState.None */; var spans = []; // We can run into an unfortunate interaction between the lexical and syntactic classifier // when the user is typing something generic. Consider the case where the user types: @@ -130951,68 +131623,68 @@ var ts; endOfLineState = end_1; } } - } while (token !== 1 /* EndOfFileToken */); + } while (token !== 1 /* SyntaxKind.EndOfFileToken */); function handleToken() { switch (token) { - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { - token = 13 /* RegularExpressionLiteral */; + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } break; - case 29 /* LessThanToken */: - if (lastNonTriviaToken === 79 /* Identifier */) { + case 29 /* SyntaxKind.LessThanToken */: + if (lastNonTriviaToken === 79 /* SyntaxKind.Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 130 /* AnyKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: templateStack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 15 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* SyntaxKind.TemplateHead */) { token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 17 /* TemplateTail */) { + if (token === 17 /* SyntaxKind.TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* SyntaxKind.TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* SyntaxKind.OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -131021,15 +131693,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 24 /* DotToken */) { - token = 79 /* Identifier */; + if (lastNonTriviaToken === 24 /* SyntaxKind.DotToken */) { + token = 79 /* SyntaxKind.Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } } } @@ -131043,59 +131715,59 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 79 /* Identifier */, - 10 /* StringLiteral */, - 8 /* NumericLiteral */, - 9 /* BigIntLiteral */, - 13 /* RegularExpressionLiteral */, - 108 /* ThisKeyword */, - 45 /* PlusPlusToken */, - 46 /* MinusMinusToken */, - 21 /* CloseParenToken */, - 23 /* CloseBracketToken */, - 19 /* CloseBraceToken */, - 110 /* TrueKeyword */, - 95 /* FalseKeyword */, + 79 /* SyntaxKind.Identifier */, + 10 /* SyntaxKind.StringLiteral */, + 8 /* SyntaxKind.NumericLiteral */, + 9 /* SyntaxKind.BigIntLiteral */, + 13 /* SyntaxKind.RegularExpressionLiteral */, + 108 /* SyntaxKind.ThisKeyword */, + 45 /* SyntaxKind.PlusPlusToken */, + 46 /* SyntaxKind.MinusMinusToken */, + 21 /* SyntaxKind.CloseParenToken */, + 23 /* SyntaxKind.CloseBracketToken */, + 19 /* SyntaxKind.CloseBraceToken */, + 110 /* SyntaxKind.TrueKeyword */, + 95 /* SyntaxKind.FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 10 /* StringLiteral */: { + case 10 /* SyntaxKind.StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; var tokenText = scanner.getTokenText(); var lastCharIndex = tokenText.length - 1; var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* CharacterCodes.backslash */) { numBackslashes++; } // If we have an odd number of backslashes, then the multiline string is unclosed if ((numBackslashes & 1) === 0) return undefined; - return tokenText.charCodeAt(0) === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + return tokenText.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */ ? 3 /* EndOfLineState.InDoubleQuoteStringLiteral */ : 2 /* EndOfLineState.InSingleQuoteStringLiteral */; } - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Check to see if the multiline comment was unclosed. - return scanner.isUnterminated() ? 1 /* InMultiLineCommentTrivia */ : undefined; + return scanner.isUnterminated() ? 1 /* EndOfLineState.InMultiLineCommentTrivia */ : undefined; default: if (ts.isTemplateLiteralKind(token)) { if (!scanner.isUnterminated()) { return undefined; } switch (token) { - case 17 /* TemplateTail */: - return 5 /* InTemplateMiddleOrTail */; - case 14 /* NoSubstitutionTemplateLiteral */: - return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + case 17 /* SyntaxKind.TemplateTail */: + return 5 /* EndOfLineState.InTemplateMiddleOrTail */; + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + return 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* SyntaxKind.TemplateHead */ ? 6 /* EndOfLineState.InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { - if (classification === 8 /* whiteSpace */) { + if (classification === 8 /* ClassificationType.whiteSpace */) { // Don't bother with whitespace classifications. They're not needed. return; } @@ -131137,23 +131809,23 @@ var ts; } function convertClassification(type) { switch (type) { - case 1 /* comment */: return ts.TokenClass.Comment; - case 3 /* keyword */: return ts.TokenClass.Keyword; - case 4 /* numericLiteral */: return ts.TokenClass.NumberLiteral; - case 25 /* bigintLiteral */: return ts.TokenClass.BigIntLiteral; - case 5 /* operator */: return ts.TokenClass.Operator; - case 6 /* stringLiteral */: return ts.TokenClass.StringLiteral; - case 8 /* whiteSpace */: return ts.TokenClass.Whitespace; - case 10 /* punctuation */: return ts.TokenClass.Punctuation; - case 2 /* identifier */: - case 11 /* className */: - case 12 /* enumName */: - case 13 /* interfaceName */: - case 14 /* moduleName */: - case 15 /* typeParameterName */: - case 16 /* typeAliasName */: - case 9 /* text */: - case 17 /* parameterName */: + case 1 /* ClassificationType.comment */: return ts.TokenClass.Comment; + case 3 /* ClassificationType.keyword */: return ts.TokenClass.Keyword; + case 4 /* ClassificationType.numericLiteral */: return ts.TokenClass.NumberLiteral; + case 25 /* ClassificationType.bigintLiteral */: return ts.TokenClass.BigIntLiteral; + case 5 /* ClassificationType.operator */: return ts.TokenClass.Operator; + case 6 /* ClassificationType.stringLiteral */: return ts.TokenClass.StringLiteral; + case 8 /* ClassificationType.whiteSpace */: return ts.TokenClass.Whitespace; + case 10 /* ClassificationType.punctuation */: return ts.TokenClass.Punctuation; + case 2 /* ClassificationType.identifier */: + case 11 /* ClassificationType.className */: + case 12 /* ClassificationType.enumName */: + case 13 /* ClassificationType.interfaceName */: + case 14 /* ClassificationType.moduleName */: + case 15 /* ClassificationType.typeParameterName */: + case 16 /* ClassificationType.typeAliasName */: + case 9 /* ClassificationType.text */: + case 17 /* ClassificationType.parameterName */: return ts.TokenClass.Identifier; default: return undefined; // TODO: GH#18217 Debug.assertNever(type); @@ -131167,10 +131839,10 @@ var ts; return true; } switch (keyword2) { - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 134 /* ConstructorKeyword */: - case 124 /* StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -131183,19 +131855,19 @@ var ts; // If we're in a multiline comment, then prepend: /* // (and a newline). That way when we lex we'll think we're still in a multiline comment. switch (lexState) { - case 3 /* InDoubleQuoteStringLiteral */: + case 3 /* EndOfLineState.InDoubleQuoteStringLiteral */: return { prefix: "\"\\\n" }; - case 2 /* InSingleQuoteStringLiteral */: + case 2 /* EndOfLineState.InSingleQuoteStringLiteral */: return { prefix: "'\\\n" }; - case 1 /* InMultiLineCommentTrivia */: + case 1 /* EndOfLineState.InMultiLineCommentTrivia */: return { prefix: "/*\n" }; - case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: + case 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */: return { prefix: "`\n" }; - case 5 /* InTemplateMiddleOrTail */: + case 5 /* EndOfLineState.InTemplateMiddleOrTail */: return { prefix: "}\n", pushTemplate: true }; - case 6 /* InTemplateSubstitutionPosition */: + case 6 /* EndOfLineState.InTemplateSubstitutionPosition */: return { prefix: "", pushTemplate: true }; - case 0 /* None */: + case 0 /* EndOfLineState.None */: return { prefix: "" }; default: return ts.Debug.assertNever(lexState); @@ -131203,47 +131875,47 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 50 /* AmpersandToken */: - case 52 /* CaretToken */: - case 51 /* BarToken */: - case 55 /* AmpersandAmpersandToken */: - case 56 /* BarBarToken */: - case 74 /* BarEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 63 /* EqualsToken */: - case 27 /* CommaToken */: - case 60 /* QuestionQuestionToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 52 /* SyntaxKind.CaretToken */: + case 51 /* SyntaxKind.BarToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return true; default: return false; @@ -131251,12 +131923,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: return true; default: return false; @@ -131264,36 +131936,36 @@ var ts; } function classFromKind(token) { if (ts.isKeyword(token)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5 /* operator */; + return 5 /* ClassificationType.operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { - return 10 /* punctuation */; + else if (token >= 18 /* SyntaxKind.FirstPunctuation */ && token <= 78 /* SyntaxKind.LastPunctuation */) { + return 10 /* ClassificationType.punctuation */; } switch (token) { - case 8 /* NumericLiteral */: - return 4 /* numericLiteral */; - case 9 /* BigIntLiteral */: - return 25 /* bigintLiteral */; - case 10 /* StringLiteral */: - return 6 /* stringLiteral */; - case 13 /* RegularExpressionLiteral */: - return 7 /* regularExpressionLiteral */; - case 7 /* ConflictMarkerTrivia */: - case 3 /* MultiLineCommentTrivia */: - case 2 /* SingleLineCommentTrivia */: - return 1 /* comment */; - case 5 /* WhitespaceTrivia */: - case 4 /* NewLineTrivia */: - return 8 /* whiteSpace */; - case 79 /* Identifier */: + case 8 /* SyntaxKind.NumericLiteral */: + return 4 /* ClassificationType.numericLiteral */; + case 9 /* SyntaxKind.BigIntLiteral */: + return 25 /* ClassificationType.bigintLiteral */; + case 10 /* SyntaxKind.StringLiteral */: + return 6 /* ClassificationType.stringLiteral */; + case 13 /* SyntaxKind.RegularExpressionLiteral */: + return 7 /* ClassificationType.regularExpressionLiteral */; + case 7 /* SyntaxKind.ConflictMarkerTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + return 1 /* ClassificationType.comment */; + case 5 /* SyntaxKind.WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + return 8 /* ClassificationType.whiteSpace */; + case 79 /* SyntaxKind.Identifier */: default: if (ts.isTemplateLiteralKind(token)) { - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } /* @internal */ @@ -131313,13 +131985,13 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -131344,10 +132016,10 @@ var ts; } node.forEachChild(cb); }); - return { spans: spans, endOfLineState: 0 /* None */ }; + return { spans: spans, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, end, type) { var length = end - start; - ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); + ts.Debug.assert(length > 0, "Classification had non-positive length of ".concat(length)); spans.push(start); spans.push(length); spans.push(type); @@ -131356,29 +132028,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function classifySymbol(symbol, meaningAtPosition, checker) { var flags = symbol.getFlags(); - if ((flags & 2885600 /* Classifiable */) === 0 /* None */) { + if ((flags & 2885600 /* SymbolFlags.Classifiable */) === 0 /* SymbolFlags.None */) { return undefined; } - else if (flags & 32 /* Class */) { - return 11 /* className */; + else if (flags & 32 /* SymbolFlags.Class */) { + return 11 /* ClassificationType.className */; } - else if (flags & 384 /* Enum */) { - return 12 /* enumName */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 12 /* ClassificationType.enumName */; } - else if (flags & 524288 /* TypeAlias */) { - return 16 /* typeAliasName */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 16 /* ClassificationType.typeAliasName */; } - else if (flags & 1536 /* Module */) { + else if (flags & 1536 /* SymbolFlags.Module */) { // Only classify a module as such if // - It appears in a namespace context. // - There exists a module declaration which actually impacts the value side. - return meaningAtPosition & 4 /* Namespace */ || meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol) ? 14 /* moduleName */ : undefined; + return meaningAtPosition & 4 /* SemanticMeaning.Namespace */ || meaningAtPosition & 1 /* SemanticMeaning.Value */ && hasValueSideModule(symbol) ? 14 /* ClassificationType.moduleName */ : undefined; } - else if (flags & 2097152 /* Alias */) { + else if (flags & 2097152 /* SymbolFlags.Alias */) { return classifySymbol(checker.getAliasedSymbol(symbol), meaningAtPosition, checker); } - else if (meaningAtPosition & 2 /* Type */) { - return flags & 64 /* Interface */ ? 13 /* interfaceName */ : flags & 262144 /* TypeParameter */ ? 15 /* typeParameterName */ : undefined; + else if (meaningAtPosition & 2 /* SemanticMeaning.Type */) { + return flags & 64 /* SymbolFlags.Interface */ ? 13 /* ClassificationType.interfaceName */ : flags & 262144 /* SymbolFlags.TypeParameter */ ? 15 /* ClassificationType.typeParameterName */ : undefined; } else { return undefined; @@ -131387,35 +132059,35 @@ var ts; /** Returns true if there exists a module that introduces entities on the value side. */ function hasValueSideModule(symbol) { return ts.some(symbol.declarations, function (declaration) { - return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; + return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* ModuleInstanceState.Instantiated */; }); } function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return "comment" /* comment */; - case 2 /* identifier */: return "identifier" /* identifier */; - case 3 /* keyword */: return "keyword" /* keyword */; - case 4 /* numericLiteral */: return "number" /* numericLiteral */; - case 25 /* bigintLiteral */: return "bigint" /* bigintLiteral */; - case 5 /* operator */: return "operator" /* operator */; - case 6 /* stringLiteral */: return "string" /* stringLiteral */; - case 8 /* whiteSpace */: return "whitespace" /* whiteSpace */; - case 9 /* text */: return "text" /* text */; - case 10 /* punctuation */: return "punctuation" /* punctuation */; - case 11 /* className */: return "class name" /* className */; - case 12 /* enumName */: return "enum name" /* enumName */; - case 13 /* interfaceName */: return "interface name" /* interfaceName */; - case 14 /* moduleName */: return "module name" /* moduleName */; - case 15 /* typeParameterName */: return "type parameter name" /* typeParameterName */; - case 16 /* typeAliasName */: return "type alias name" /* typeAliasName */; - case 17 /* parameterName */: return "parameter name" /* parameterName */; - case 18 /* docCommentTagName */: return "doc comment tag name" /* docCommentTagName */; - case 19 /* jsxOpenTagName */: return "jsx open tag name" /* jsxOpenTagName */; - case 20 /* jsxCloseTagName */: return "jsx close tag name" /* jsxCloseTagName */; - case 21 /* jsxSelfClosingTagName */: return "jsx self closing tag name" /* jsxSelfClosingTagName */; - case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; - case 23 /* jsxText */: return "jsx text" /* jsxText */; - case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + case 1 /* ClassificationType.comment */: return "comment" /* ClassificationTypeNames.comment */; + case 2 /* ClassificationType.identifier */: return "identifier" /* ClassificationTypeNames.identifier */; + case 3 /* ClassificationType.keyword */: return "keyword" /* ClassificationTypeNames.keyword */; + case 4 /* ClassificationType.numericLiteral */: return "number" /* ClassificationTypeNames.numericLiteral */; + case 25 /* ClassificationType.bigintLiteral */: return "bigint" /* ClassificationTypeNames.bigintLiteral */; + case 5 /* ClassificationType.operator */: return "operator" /* ClassificationTypeNames.operator */; + case 6 /* ClassificationType.stringLiteral */: return "string" /* ClassificationTypeNames.stringLiteral */; + case 8 /* ClassificationType.whiteSpace */: return "whitespace" /* ClassificationTypeNames.whiteSpace */; + case 9 /* ClassificationType.text */: return "text" /* ClassificationTypeNames.text */; + case 10 /* ClassificationType.punctuation */: return "punctuation" /* ClassificationTypeNames.punctuation */; + case 11 /* ClassificationType.className */: return "class name" /* ClassificationTypeNames.className */; + case 12 /* ClassificationType.enumName */: return "enum name" /* ClassificationTypeNames.enumName */; + case 13 /* ClassificationType.interfaceName */: return "interface name" /* ClassificationTypeNames.interfaceName */; + case 14 /* ClassificationType.moduleName */: return "module name" /* ClassificationTypeNames.moduleName */; + case 15 /* ClassificationType.typeParameterName */: return "type parameter name" /* ClassificationTypeNames.typeParameterName */; + case 16 /* ClassificationType.typeAliasName */: return "type alias name" /* ClassificationTypeNames.typeAliasName */; + case 17 /* ClassificationType.parameterName */: return "parameter name" /* ClassificationTypeNames.parameterName */; + case 18 /* ClassificationType.docCommentTagName */: return "doc comment tag name" /* ClassificationTypeNames.docCommentTagName */; + case 19 /* ClassificationType.jsxOpenTagName */: return "jsx open tag name" /* ClassificationTypeNames.jsxOpenTagName */; + case 20 /* ClassificationType.jsxCloseTagName */: return "jsx close tag name" /* ClassificationTypeNames.jsxCloseTagName */; + case 21 /* ClassificationType.jsxSelfClosingTagName */: return "jsx self closing tag name" /* ClassificationTypeNames.jsxSelfClosingTagName */; + case 22 /* ClassificationType.jsxAttribute */: return "jsx attribute" /* ClassificationTypeNames.jsxAttribute */; + case 23 /* ClassificationType.jsxText */: return "jsx text" /* ClassificationTypeNames.jsxText */; + case 24 /* ClassificationType.jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* ClassificationTypeNames.jsxAttributeStringLiteralValue */; default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type); } } @@ -131441,11 +132113,11 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; + return { spans: result, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, length, type) { result.push(start); result.push(length); @@ -131467,12 +132139,12 @@ var ts; return start; } switch (kind) { - case 4 /* NewLineTrivia */: - case 5 /* WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // Don't bother with newlines/whitespace. continue; - case 2 /* SingleLineCommentTrivia */: - case 3 /* MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Only bother with the trivia if it at least intersects the span of interest. classifyComment(token, kind, start, width); // Classifying a comment might cause us to reuse the trivia scanner @@ -131480,21 +132152,21 @@ var ts; // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; - case 7 /* ConflictMarkerTrivia */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { + pushClassification(start, width, 1 /* ClassificationType.comment */); continue; } // for the ||||||| and ======== markers, add a comment for the first line, // and then lex all subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); classifyDisabledMergeCode(text, start, end); break; - case 6 /* ShebangTrivia */: + case 6 /* SyntaxKind.ShebangTrivia */: // TODO: Maybe we should classify these. break; default: @@ -131503,7 +132175,7 @@ var ts; } } function classifyComment(token, kind, start, width) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // See if this is a doc comment. If so, we'll classify certain portions of it // specially. var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); @@ -131514,7 +132186,7 @@ var ts; return; } } - else if (kind === 2 /* SingleLineCommentTrivia */) { + else if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { if (tryClassifyTripleSlashComment(start, width)) { return; } @@ -131523,7 +132195,7 @@ var ts; pushCommentRange(start, width); } function pushCommentRange(start, width) { - pushClassification(start, width, 1 /* comment */); + pushClassification(start, width, 1 /* ClassificationType.comment */); } function classifyJSDocComment(docComment) { var _a, _b, _c, _d, _e, _f, _g; @@ -131536,51 +132208,51 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" + pushClassification(tag.pos, 1, 10 /* ClassificationType.punctuation */); // "@" + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* ClassificationType.docCommentTagName */); // e.g. "param" pos = tag.tagName.end; var commentStart = tag.tagName.end; switch (tag.kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var param = tag; processJSDocParameterTag(param); commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end; break; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var prop = tag; commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; commentStart = tag.typeParameters.end; break; - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: var type = tag; - commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; break; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: commentStart = tag.typeExpression.end; break; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = tag.typeExpression.end; break; - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: commentStart = tag.typeExpression.end; break; - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; break; - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: commentStart = tag.class.end; break; } @@ -131599,7 +132271,7 @@ var ts; function processJSDocParameterTag(tag) { if (tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } if (tag.typeExpression) { @@ -131609,7 +132281,7 @@ var ts; } if (!tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } } @@ -131634,9 +132306,9 @@ var ts; var pos = start; pushCommentRange(pos, match[1].length); // /// pos += match[1].length; - pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pushClassification(pos, match[2].length, 10 /* ClassificationType.punctuation */); // < pos += match[2].length; - pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pushClassification(pos, match[3].length, 21 /* ClassificationType.jsxSelfClosingTagName */); // element name pos += match[3].length; var attrText = match[4]; var attrPos = pos; @@ -131650,19 +132322,19 @@ var ts; pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + pushClassification(attrPos, attrMatch[2].length, 22 /* ClassificationType.jsxAttribute */); // attribute name attrPos += attrMatch[2].length; if (attrMatch[3].length) { pushCommentRange(attrPos, attrMatch[3].length); // whitespace attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + pushClassification(attrPos, attrMatch[4].length, 5 /* ClassificationType.operator */); // = attrPos += attrMatch[4].length; if (attrMatch[5].length) { pushCommentRange(attrPos, attrMatch[5].length); // whitespace attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + pushClassification(attrPos, attrMatch[6].length, 24 /* ClassificationType.jsxAttributeStringLiteralValue */); // attribute value attrPos += attrMatch[6].length; } pos += match[4].length; @@ -131670,7 +132342,7 @@ var ts; pushCommentRange(attrPos, pos - attrPos); } if (match[5]) { - pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pushClassification(pos, match[5].length, 10 /* ClassificationType.punctuation */); // /> pos += match[5].length; } var end = start + width; @@ -131694,7 +132366,7 @@ var ts; break; } } - pushClassification(start, i - start, 1 /* comment */); + pushClassification(start, i - start, 1 /* ClassificationType.comment */); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { classifyDisabledCodeToken(); @@ -131721,10 +132393,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* SyntaxKind.JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* SyntaxKind.JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -131737,24 +132409,24 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: if (token.parent.tagName === token) { - return 19 /* jsxOpenTagName */; + return 19 /* ClassificationType.jsxOpenTagName */; } break; - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: if (token.parent.tagName === token) { - return 20 /* jsxCloseTagName */; + return 20 /* ClassificationType.jsxCloseTagName */; } break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: if (token.parent.tagName === token) { - return 21 /* jsxSelfClosingTagName */; + return 21 /* ClassificationType.jsxSelfClosingTagName */; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: if (token.parent.name === token) { - return 22 /* jsxAttribute */; + return 22 /* ClassificationType.jsxAttribute */; } break; } @@ -131765,97 +132437,97 @@ var ts; // classify based on that instead. function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { + if (tokenKind === 29 /* SyntaxKind.LessThanToken */ || tokenKind === 31 /* SyntaxKind.GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } } if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 63 /* EqualsToken */) { + if (tokenKind === 63 /* SyntaxKind.EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 254 /* VariableDeclaration */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 164 /* Parameter */ || - parent.kind === 285 /* JsxAttribute */) { - return 5 /* operator */; + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 164 /* SyntaxKind.Parameter */ || + parent.kind === 285 /* SyntaxKind.JsxAttribute */) { + return 5 /* ClassificationType.operator */; } } - if (parent.kind === 221 /* BinaryExpression */ || - parent.kind === 219 /* PrefixUnaryExpression */ || - parent.kind === 220 /* PostfixUnaryExpression */ || - parent.kind === 222 /* ConditionalExpression */) { - return 5 /* operator */; + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ || + parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || + parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */ || + parent.kind === 222 /* SyntaxKind.ConditionalExpression */) { + return 5 /* ClassificationType.operator */; } } - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } - else if (tokenKind === 8 /* NumericLiteral */) { - return 4 /* numericLiteral */; + else if (tokenKind === 8 /* SyntaxKind.NumericLiteral */) { + return 4 /* ClassificationType.numericLiteral */; } - else if (tokenKind === 9 /* BigIntLiteral */) { - return 25 /* bigintLiteral */; + else if (tokenKind === 9 /* SyntaxKind.BigIntLiteral */) { + return 25 /* ClassificationType.bigintLiteral */; } - else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 285 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 10 /* SyntaxKind.StringLiteral */) { + return token && token.parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? 24 /* ClassificationType.jsxAttributeStringLiteralValue */ : 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 13 /* RegularExpressionLiteral */) { + else if (tokenKind === 13 /* SyntaxKind.RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } else if (ts.isTemplateLiteralKind(tokenKind)) { // TODO (drosen): we should *also* get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 11 /* JsxText */) { - return 23 /* jsxText */; + else if (tokenKind === 11 /* SyntaxKind.JsxText */) { + return 23 /* ClassificationType.jsxText */; } - else if (tokenKind === 79 /* Identifier */) { + else if (tokenKind === 79 /* SyntaxKind.Identifier */) { if (token) { switch (token.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: if (token.parent.name === token) { - return 11 /* className */; + return 11 /* ClassificationType.className */; } return; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: if (token.parent.name === token) { - return 15 /* typeParameterName */; + return 15 /* ClassificationType.typeParameterName */; } return; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: if (token.parent.name === token) { - return 13 /* interfaceName */; + return 13 /* ClassificationType.interfaceName */; } return; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (token.parent.name === token) { - return 12 /* enumName */; + return 12 /* ClassificationType.enumName */; } return; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (token.parent.name === token) { - return 14 /* moduleName */; + return 14 /* ClassificationType.moduleName */; } return; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (token.parent.name === token) { - return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; + return ts.isThisIdentifier(token) ? 3 /* ClassificationType.keyword */ : 17 /* ClassificationType.parameterName */; } return; } if (ts.isConstTypeReference(token.parent)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } function processElement(element) { @@ -131931,14 +132603,14 @@ var ts; function getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span) { return { spans: getSemanticTokens(program, sourceFile, span, cancellationToken), - endOfLineState: 0 /* None */ + endOfLineState: 0 /* EndOfLineState.None */ }; } v2020.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getSemanticTokens(program, sourceFile, span, cancellationToken) { var resultTokens = []; var collector = function (node, typeIdx, modifierSet) { - resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* typeOffset */) + modifierSet); + resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* TokenEncodingConsts.typeOffset */) + modifierSet); }; if (program && sourceFile) { collectTokens(program, sourceFile, span, collector, cancellationToken); @@ -131950,13 +132622,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -131972,7 +132644,7 @@ var ts; if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node) && !ts.isInfinityOrNaNString(node.escapedText)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } var typeIdx = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -131981,38 +132653,38 @@ var ts; if (node.parent) { var parentIsDeclaration = (ts.isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx); if (parentIsDeclaration && node.parent.name === node) { - modifierSet = 1 << 0 /* declaration */; + modifierSet = 1 << 0 /* TokenModifier.declaration */; } } // property declaration in constructor - if (typeIdx === 6 /* parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { - typeIdx = 9 /* property */; + if (typeIdx === 6 /* TokenType.parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { + typeIdx = 9 /* TokenType.property */; } typeIdx = reclassifyByType(typeChecker, node, typeIdx); var decl = symbol.valueDeclaration; if (decl) { var modifiers = ts.getCombinedModifierFlags(decl); var nodeFlags = ts.getCombinedNodeFlags(decl); - if (modifiers & 32 /* Static */) { - modifierSet |= 1 << 1 /* static */; + if (modifiers & 32 /* ModifierFlags.Static */) { + modifierSet |= 1 << 1 /* TokenModifier.static */; } - if (modifiers & 256 /* Async */) { - modifierSet |= 1 << 2 /* async */; + if (modifiers & 256 /* ModifierFlags.Async */) { + modifierSet |= 1 << 2 /* TokenModifier.async */; } - if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) { - if ((modifiers & 64 /* Readonly */) || (nodeFlags & 2 /* Const */) || (symbol.getFlags() & 8 /* EnumMember */)) { - modifierSet |= 1 << 3 /* readonly */; + if (typeIdx !== 0 /* TokenType.class */ && typeIdx !== 2 /* TokenType.interface */) { + if ((modifiers & 64 /* ModifierFlags.Readonly */) || (nodeFlags & 2 /* NodeFlags.Const */) || (symbol.getFlags() & 8 /* SymbolFlags.EnumMember */)) { + modifierSet |= 1 << 3 /* TokenModifier.readonly */; } } - if ((typeIdx === 7 /* variable */ || typeIdx === 10 /* function */) && isLocalDeclaration(decl, sourceFile)) { - modifierSet |= 1 << 5 /* local */; + if ((typeIdx === 7 /* TokenType.variable */ || typeIdx === 10 /* TokenType.function */) && isLocalDeclaration(decl, sourceFile)) { + modifierSet |= 1 << 5 /* TokenModifier.local */; } if (program.isSourceFileDefaultLibrary(decl.getSourceFile())) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } } else if (symbol.declarations && symbol.declarations.some(function (d) { return program.isSourceFileDefaultLibrary(d.getSourceFile()); })) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } collector(node, typeIdx, modifierSet); } @@ -132025,22 +132697,22 @@ var ts; } function classifySymbol(symbol, meaning) { var flags = symbol.getFlags(); - if (flags & 32 /* Class */) { - return 0 /* class */; + if (flags & 32 /* SymbolFlags.Class */) { + return 0 /* TokenType.class */; } - else if (flags & 384 /* Enum */) { - return 1 /* enum */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 1 /* TokenType.enum */; } - else if (flags & 524288 /* TypeAlias */) { - return 5 /* type */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 5 /* TokenType.type */; } - else if (flags & 64 /* Interface */) { - if (meaning & 2 /* Type */) { - return 2 /* interface */; + else if (flags & 64 /* SymbolFlags.Interface */) { + if (meaning & 2 /* SemanticMeaning.Type */) { + return 2 /* TokenType.interface */; } } - else if (flags & 262144 /* TypeParameter */) { - return 4 /* typeParameter */; + else if (flags & 262144 /* SymbolFlags.TypeParameter */) { + return 4 /* TokenType.typeParameter */; } var decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0]; if (decl && ts.isBindingElement(decl)) { @@ -132050,17 +132722,17 @@ var ts; } function reclassifyByType(typeChecker, node, typeIdx) { // type based classifications - if (typeIdx === 7 /* variable */ || typeIdx === 9 /* property */ || typeIdx === 6 /* parameter */) { + if (typeIdx === 7 /* TokenType.variable */ || typeIdx === 9 /* TokenType.property */ || typeIdx === 6 /* TokenType.parameter */) { var type_1 = typeChecker.getTypeAtLocation(node); if (type_1) { var test = function (condition) { return condition(type_1) || type_1.isUnion() && type_1.types.some(condition); }; - if (typeIdx !== 6 /* parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { - return 0 /* class */; + if (typeIdx !== 6 /* TokenType.parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { + return 0 /* TokenType.class */; } if (test(function (t) { return t.getCallSignatures().length > 0; }) && !test(function (t) { return t.getProperties().length > 0; }) || isExpressionInCallExpression(node)) { - return typeIdx === 9 /* property */ ? 11 /* member */ : 10 /* function */; + return typeIdx === 9 /* TokenType.property */ ? 11 /* TokenType.member */ : 10 /* TokenType.function */; } } } @@ -132102,25 +132774,25 @@ var ts; return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node); } var tokenFromDeclarationMapping = new ts.Map([ - [254 /* VariableDeclaration */, 7 /* variable */], - [164 /* Parameter */, 6 /* parameter */], - [167 /* PropertyDeclaration */, 9 /* property */], - [261 /* ModuleDeclaration */, 3 /* namespace */], - [260 /* EnumDeclaration */, 1 /* enum */], - [299 /* EnumMember */, 8 /* enumMember */], - [257 /* ClassDeclaration */, 0 /* class */], - [169 /* MethodDeclaration */, 11 /* member */], - [256 /* FunctionDeclaration */, 10 /* function */], - [213 /* FunctionExpression */, 10 /* function */], - [168 /* MethodSignature */, 11 /* member */], - [172 /* GetAccessor */, 9 /* property */], - [173 /* SetAccessor */, 9 /* property */], - [166 /* PropertySignature */, 9 /* property */], - [258 /* InterfaceDeclaration */, 2 /* interface */], - [259 /* TypeAliasDeclaration */, 5 /* type */], - [163 /* TypeParameter */, 4 /* typeParameter */], - [296 /* PropertyAssignment */, 9 /* property */], - [297 /* ShorthandPropertyAssignment */, 9 /* property */] + [254 /* SyntaxKind.VariableDeclaration */, 7 /* TokenType.variable */], + [164 /* SyntaxKind.Parameter */, 6 /* TokenType.parameter */], + [167 /* SyntaxKind.PropertyDeclaration */, 9 /* TokenType.property */], + [261 /* SyntaxKind.ModuleDeclaration */, 3 /* TokenType.namespace */], + [260 /* SyntaxKind.EnumDeclaration */, 1 /* TokenType.enum */], + [299 /* SyntaxKind.EnumMember */, 8 /* TokenType.enumMember */], + [257 /* SyntaxKind.ClassDeclaration */, 0 /* TokenType.class */], + [169 /* SyntaxKind.MethodDeclaration */, 11 /* TokenType.member */], + [256 /* SyntaxKind.FunctionDeclaration */, 10 /* TokenType.function */], + [213 /* SyntaxKind.FunctionExpression */, 10 /* TokenType.function */], + [168 /* SyntaxKind.MethodSignature */, 11 /* TokenType.member */], + [172 /* SyntaxKind.GetAccessor */, 9 /* TokenType.property */], + [173 /* SyntaxKind.SetAccessor */, 9 /* TokenType.property */], + [166 /* SyntaxKind.PropertySignature */, 9 /* TokenType.property */], + [258 /* SyntaxKind.InterfaceDeclaration */, 2 /* TokenType.interface */], + [259 /* SyntaxKind.TypeAliasDeclaration */, 5 /* TokenType.type */], + [163 /* SyntaxKind.TypeParameter */, 4 /* TokenType.typeParameter */], + [296 /* SyntaxKind.PropertyAssignment */, 9 /* TokenType.property */], + [297 /* SyntaxKind.ShorthandPropertyAssignment */, 9 /* TokenType.property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -132132,6 +132804,26 @@ var ts; (function (Completions) { var StringCompletions; (function (StringCompletions) { + var _a; + var kindPrecedence = (_a = {}, + _a["directory" /* ScriptElementKind.directory */] = 0, + _a["script" /* ScriptElementKind.scriptElement */] = 1, + _a["external module name" /* ScriptElementKind.externalModuleName */] = 2, + _a); + function createNameAndKindSet() { + var map = new ts.Map(); + function add(value) { + var existing = map.get(value.name); + if (!existing || kindPrecedence[existing.kind] < kindPrecedence[value.kind]) { + map.set(value.name, value); + } + } + return { + add: add, + has: map.has.bind(map), + values: map.values.bind(map), + }; + } function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) { if (ts.isInReferenceComment(sourceFile, position)) { var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host); @@ -132151,19 +132843,19 @@ var ts; } var optionalReplacementSpan = ts.createTextSpanFromStringLiteralLikeContent(contextToken); switch (completion.kind) { - case 0 /* Paths */: + case 0 /* StringLiteralCompletionKind.Paths */: return convertPathCompletions(completion.paths); - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var entries = ts.createSortedArray(); - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options, + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ScriptTarget.ESNext */, log, 4 /* CompletionKind.String */, preferences, options, /*formatContext*/ undefined); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } - case 2 /* Types */: { + case 2 /* StringLiteralCompletionKind.Types */: { var entries = completion.types.map(function (type) { return ({ name: type.value, - kindModifiers: "" /* none */, - kind: "string" /* string */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "string" /* ScriptElementKind.string */, sortText: Completions.SortText.LocationPriority, replacementSpan: ts.getReplacementSpanForContextToken(contextToken) }); }); @@ -132182,16 +132874,16 @@ var ts; StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { switch (completion.kind) { - case 0 /* Paths */: { + case 0 /* StringLiteralCompletionKind.Paths */: { var match = ts.find(completion.paths, function (p) { return p.name === name; }); return match && Completions.createCompletionDetails(name, kindModifiersFromExtension(match.extension), match.kind, [ts.textPart(name)]); } - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var match = ts.find(completion.symbols, function (s) { return s.name === name; }); return match && Completions.createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; + case 2 /* StringLiteralCompletionKind.Types */: + return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, "type" /* ScriptElementKind.typeElement */, [ts.textPart(name)]) : undefined; default: return ts.Debug.assertNever(completion); } @@ -132207,20 +132899,20 @@ var ts; } function kindModifiersFromExtension(extension) { switch (extension) { - case ".d.ts" /* Dts */: return ".d.ts" /* dtsModifier */; - case ".js" /* Js */: return ".js" /* jsModifier */; - case ".json" /* Json */: return ".json" /* jsonModifier */; - case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; - case ".ts" /* Ts */: return ".ts" /* tsModifier */; - case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; - case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */; - case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */; - case ".mts" /* Mts */: return ".mts" /* mtsModifier */; - case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */; - case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */; - case ".cts" /* Cts */: return ".cts" /* ctsModifier */; - case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); - case undefined: return "" /* none */; + case ".d.ts" /* Extension.Dts */: return ".d.ts" /* ScriptElementKindModifier.dtsModifier */; + case ".js" /* Extension.Js */: return ".js" /* ScriptElementKindModifier.jsModifier */; + case ".json" /* Extension.Json */: return ".json" /* ScriptElementKindModifier.jsonModifier */; + case ".jsx" /* Extension.Jsx */: return ".jsx" /* ScriptElementKindModifier.jsxModifier */; + case ".ts" /* Extension.Ts */: return ".ts" /* ScriptElementKindModifier.tsModifier */; + case ".tsx" /* Extension.Tsx */: return ".tsx" /* ScriptElementKindModifier.tsxModifier */; + case ".d.mts" /* Extension.Dmts */: return ".d.mts" /* ScriptElementKindModifier.dmtsModifier */; + case ".mjs" /* Extension.Mjs */: return ".mjs" /* ScriptElementKindModifier.mjsModifier */; + case ".mts" /* Extension.Mts */: return ".mts" /* ScriptElementKindModifier.mtsModifier */; + case ".d.cts" /* Extension.Dcts */: return ".d.cts" /* ScriptElementKindModifier.dctsModifier */; + case ".cjs" /* Extension.Cjs */: return ".cjs" /* ScriptElementKindModifier.cjsModifier */; + case ".cts" /* Extension.Cts */: return ".cts" /* ScriptElementKindModifier.ctsModifier */; + case ".tsbuildinfo" /* Extension.TsBuildInfo */: return ts.Debug.fail("Extension ".concat(".tsbuildinfo" /* Extension.TsBuildInfo */, " is unsupported.")); + case undefined: return "" /* ScriptElementKindModifier.none */; default: return ts.Debug.assertNever(extension); } @@ -132234,44 +132926,44 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 196 /* LiteralType */: { - var grandParent = walkUpParentheses(parent.parent); - switch (grandParent.kind) { - case 178 /* TypeReference */: { - var typeReference_1 = grandParent; - var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); + case 196 /* SyntaxKind.LiteralType */: { + var grandParent_1 = walkUpParentheses(parent.parent); + switch (grandParent_1.kind) { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: { + var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === grandParent_1; }); if (typeArgument) { - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; } return undefined; } - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; // bar: string; // } // let x: Foo["/*completion position*/"] - var _a = grandParent, indexType = _a.indexType, objectType = _a.objectType; + var _a = grandParent_1, indexType = _a.indexType, objectType = _a.objectType; if (!ts.rangeContainsPosition(indexType, position)) { return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 200 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; - case 187 /* UnionType */: { - if (!ts.isTypeReferenceNode(grandParent.parent)) { + case 200 /* SyntaxKind.ImportType */: + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 187 /* SyntaxKind.UnionType */: { + if (!ts.isTypeReferenceNode(grandParent_1.parent)) { return undefined; } - var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent); - var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent_1, parent); + var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent_1)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: false }; } default: return undefined; } } - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -132288,7 +132980,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 207 /* ElementAccessExpression */: { + case 207 /* SyntaxKind.ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -132301,41 +132993,41 @@ var ts; } return undefined; } - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 285 /* JsxAttribute */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 285 /* SyntaxKind.JsxAttribute */: if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? parent.parent : node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `require(""` or `import("")`) - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 277 /* ExternalModuleReference */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 277 /* SyntaxKind.ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } function fromContextualType() { // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" - return { kind: 2 /* Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; } } function walkUpParentheses(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -132362,14 +133054,14 @@ var ts; type = propType; } } - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* TypeFlags.String */); return getStringLiteralTypes(type, uniques); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: isNewIdentifier }; } function stringLiteralCompletionsFromProperties(type) { return type && { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; @@ -132378,10 +133070,10 @@ var ts; var contextualType = checker.getContextualType(objectLiteralExpression); if (!contextualType) return undefined; - var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* Completions */); + var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* ContextFlags.Completions */); var symbols = Completions.getPropertiesForObjectExpression(contextualType, completionsType, objectLiteralExpression, checker); return { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: symbols, hasIndexSignature: ts.hasIndexSignature(contextualType) }; @@ -132392,13 +133084,13 @@ var ts; return ts.emptyArray; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : - type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; + type.isStringLiteral() && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; } function directoryResult(name) { - return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); + return nameAndKind(name, "directory" /* ScriptElementKind.directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); @@ -132413,18 +133105,19 @@ var ts; } function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) { var literalValue = ts.normalizeSlashes(node.text); + var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption()) - : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker); function getIncludeExtensionOption() { var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; - return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */; + return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */ : 0 /* IncludeExtensionsOption.Exclude */; } } function getExtensionOptions(compilerOptions, includeExtensionsOption) { - if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; } + if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* IncludeExtensionsOption.Exclude */; } return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption }; } function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, includeExtensions) { @@ -132433,7 +133126,7 @@ var ts; return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } else { - return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath); + return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values()); } } function isEmitResolutionKindUsingNodeModules(compilerOptions) { @@ -132469,7 +133162,7 @@ var ts; var basePath = compilerOptions.project || host.getCurrentDirectory(); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase); - return ts.flatMap(baseDirectories, function (baseDirectory) { return getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude); }); + return ts.flatMap(baseDirectories, function (baseDirectory) { return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values()); }); } var IncludeExtensionsOption; (function (IncludeExtensionsOption) { @@ -132480,10 +133173,9 @@ var ts; /** * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) { - var _b; - var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption; - if (result === void 0) { result = []; } + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensionOptions, host, exclude, result) { + var _a; + if (result === void 0) { result = createNameAndKindSet(); } if (fragment === undefined) { fragment = ""; } @@ -132507,11 +133199,11 @@ var ts; var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; if (typeof typesVersions === "object") { - var versionPaths = (_b = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _b === void 0 ? void 0 : _b.paths; + var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths; if (versionPaths) { var packageDirectory = ts.getDirectoryPath(packageJsonPath); var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length); - if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) { + if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) { // A true result means one of the `versionPaths` was matched, which will block relative resolution // to files and folders from here. All reachable paths given the pattern match are already added. return result; @@ -132523,39 +133215,17 @@ var ts; if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = new ts.Map(); // maps file to its extension for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var filePath = files_1[_i]; filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* Comparison.EqualTo */) { continue; } - var foundFileName = void 0; - var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings()); - if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) { - foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath)); - foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); - } - else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) { - foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension); - foundFiles.set(foundFileName, outputExtension); - } - else { - foundFileName = ts.getBaseFileName(filePath); - foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); - } + var _b = getFilenameWithExtensionOption(ts.getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _b.name, extension = _b.extension; + result.add(nameAndKind(name, "script" /* ScriptElementKind.scriptElement */, extension)); } - foundFiles.forEach(function (ext, foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); - }); } // If possible, get folder completion as well var directories = ts.tryGetDirectories(host, baseDirectory); @@ -132564,27 +133234,52 @@ var ts; var directory = directories_1[_c]; var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); if (directoryName !== "@types") { - result.push(directoryResult(directoryName)); + result.add(directoryResult(directoryName)); } } } return result; } + function getFilenameWithExtensionOption(name, compilerOptions, includeExtensionsOption) { + var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions); + if (includeExtensionsOption === 0 /* IncludeExtensionsOption.Exclude */ && !ts.fileExtensionIsOneOf(name, [".json" /* Extension.Json */, ".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) { + return { name: ts.removeFileExtension(name), extension: ts.tryGetExtensionFromPath(name) }; + } + else if ((ts.fileExtensionIsOneOf(name, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */]) || includeExtensionsOption === 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */) && outputExtension) { + return { name: ts.changeExtension(name, outputExtension), extension: outputExtension }; + } + else { + return { name: name, extension: ts.tryGetExtensionFromPath(name) }; + } + } /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */ - function addCompletionEntriesFromPaths(result, fragment, baseDirectory, fileExtensions, paths, host) { - var _a; + function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) { + var getPatternsForKey = function (key) { return paths[key]; }; + var comparePaths = function (a, b) { + var patternA = ts.tryParsePattern(a); + var patternB = ts.tryParsePattern(b); + var lengthA = typeof patternA === "object" ? patternA.prefix.length : a.length; + var lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length; + return ts.compareValues(lengthB, lengthA); + }; + return addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, ts.getOwnKeys(paths), getPatternsForKey, comparePaths); + } + /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */ + function addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths) { var pathResults = []; - var matchedPathPrefixLength = -1; - for (var path in paths) { - if (!ts.hasProperty(paths, path)) + var matchedPath; + for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { + var key = keys_1[_i]; + if (key === ".") continue; - var patterns = paths[path]; + var keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./" + var patterns = getPatternsForKey(key); if (patterns) { - var pathPattern = ts.tryParsePattern(path); + var pathPattern = ts.tryParsePattern(keyWithoutLeadingDotSlash); if (!pathPattern) continue; var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment); - var isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength); + var isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === -1 /* Comparison.LessThan */); if (isLongestMatch) { // If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g. // for `import {} from "some-package/|"` with a typesVersions: @@ -132597,13 +133292,13 @@ var ts; // added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both // ./dist/foo and ./foo, when only the latter will actually be resolvable. // See pathCompletionsTypesVersionsWildcard6.ts. - matchedPathPrefixLength = pathPattern.prefix.length; + matchedPath = key; pathResults = pathResults.filter(function (r) { return !r.matchedPattern; }); } - if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) { + if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== 1 /* Comparison.GreaterThan */) { pathResults.push({ matchedPattern: isMatch, - results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host) + results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host) .map(function (_a) { var name = _a.name, kind = _a.kind, extension = _a.extension; return nameAndKind(name, kind, extension); @@ -132612,10 +133307,8 @@ var ts; } } } - var equatePaths = ((_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host)) ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive; - var equateResults = function (a, b) { return equatePaths(a.name, b.name); }; - pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); }); - return matchedPathPrefixLength > -1; + pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (r) { return result.add(r); }); }); + return matchedPath !== undefined; } /** * Check all of the declared modules and those in node modules. Possible sources of modules: @@ -132624,22 +133317,22 @@ var ts; * Modules from node_modules (i.e. those listed in package.json) * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions */ - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) { + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, includeExtensionsOption, typeChecker) { var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result = []; - var extensionOptions = getExtensionOptions(compilerOptions); + var result = createNameAndKindSet(); + var extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption); if (baseUrl) { var projectDir = compilerOptions.project || host.getCurrentDirectory(); var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl)); getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result); if (paths) { - addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host); + addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths); } } var fragmentDirectory = getFragmentDirectory(fragment); for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) { var ambientName = _a[_i]; - result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.add(nameAndKind(ambientName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (isEmitResolutionKindUsingNodeModules(compilerOptions)) { @@ -132647,15 +133340,13 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_3 = function (moduleName) { - if (!result.some(function (entry) { return entry.name === moduleName; })) { - foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); - } - }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { var moduleName = _c[_b]; - _loop_3(moduleName); + var moduleResult = nameAndKind(moduleName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined); + if (!result.has(moduleResult.name)) { + foundGlobal = true; + result.add(moduleResult); + } } } if (!foundGlobal) { @@ -132681,39 +133372,19 @@ var ts; } packagePath = ts.combinePaths(packagePath, subName); } - var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json"); + var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath); + var packageFile = ts.combinePaths(packageDirectory, "package.json"); if (ts.tryFileExists(host, packageFile)) { var packageJson = ts.readJson(packageFile, host); - var exports = packageJson.exports; - if (exports) { - if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null + var exports_1 = packageJson.exports; + if (exports_1) { + if (typeof exports_1 !== "object" || exports_1 === null) { // eslint-disable-line no-null/no-null return; // null exports or entrypoint only, no sub-modules available } - var keys = ts.getOwnKeys(exports); - var fragmentSubpath_1 = components.join("/"); - var processedKeys = ts.mapDefined(keys, function (k) { - if (k === ".") - return undefined; - if (!ts.startsWith(k, "./")) - return undefined; - var subpath = k.substring(2); - if (!ts.startsWith(subpath, fragmentSubpath_1)) - return undefined; - // subpath is a valid export (barring conditions, which we don't currently check here) - if (!ts.stringContains(subpath, "*")) { - return subpath; - } - // pattern export - only return everything up to the `*`, so the user can autocomplete, then - // keep filling in the pattern (we could speculatively return a list of options by hitting disk, - // but conditions will make that somewhat awkward, as each condition may have a different set of possible - // options for the `*`. - return subpath.slice(0, subpath.indexOf("*")); - }); - ts.forEach(processedKeys, function (k) { - if (k) { - result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined)); - } - }); + var keys = ts.getOwnKeys(exports_1); + var fragmentSubpath = components.join("/") + (components.length && ts.hasTrailingDirectorySeparator(fragment) ? "/" : ""); + var conditions_1 = mode === ts.ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"]; + addCompletionEntriesFromPathsOrExports(result, fragmentSubpath, packageDirectory, extensionOptions, host, keys, function (key) { return ts.singleElementArray(getPatternFromFirstMatchingCondition(exports_1[key], conditions_1)); }, ts.comparePatternKeys); return; } } @@ -132723,31 +133394,44 @@ var ts; ts.forEachAncestorDirectory(scriptPath, ancestorLookup); } } - return result; + return ts.arrayFrom(result.values()); + } + function getPatternFromFirstMatchingCondition(target, conditions) { + if (typeof target === "string") { + return target; + } + if (target && typeof target === "object" && !ts.isArray(target)) { + for (var condition in target) { + if (condition === "default" || conditions.indexOf(condition) > -1 || ts.isApplicableVersionedTypesKey(conditions, condition)) { + var pattern = target[condition]; + return getPatternFromFirstMatchingCondition(pattern, conditions); + } + } + } } function getFragmentDirectory(fragment) { return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; } - function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { + function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. - return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray; + return !ts.stringContains(path, "*") ? justPathMappingName(path, "script" /* ScriptElementKind.scriptElement */) : ts.emptyArray; } var pathPrefix = path.slice(0, path.length - 1); var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix); if (remainingFragment === undefined) { var starIsFullPathComponent = path[path.length - 2] === "/"; - return starIsFullPathComponent ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", baseUrl, pattern, fileExtensions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) { + return starIsFullPathComponent ? justPathMappingName(pathPrefix, "directory" /* ScriptElementKind.directory */) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) { var name = _a.name, rest = __rest(_a, ["name"]); return (__assign({ name: pathPrefix + name }, rest)); }); }); } - return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); - function justPathMappingName(name) { - return ts.startsWith(name, fragment) ? [directoryResult(ts.removeTrailingDirectorySeparator(name))] : ts.emptyArray; + return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, host); }); + function justPathMappingName(name, kind) { + return ts.startsWith(name, fragment) ? [{ name: ts.removeTrailingDirectorySeparator(name), kind: kind, extension: undefined }] : ts.emptyArray; } } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, host) { if (!host.readDirectory) { return undefined; } @@ -132766,21 +133450,33 @@ var ts; var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory; var normalizedSuffix = ts.normalizePath(parsed.suffix); // Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b". - var baseDirectory = ts.normalizePath(ts.combinePaths(baseUrl, expandedPrefixDirectory)); + var baseDirectory = ts.normalizePath(ts.combinePaths(packageDirectory, expandedPrefixDirectory)); var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { - var extension = ts.tryGetExtensionFromPath(match); - var name = trimPrefixAndSuffix(match); - return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); - }); - var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { - var name = trimPrefixAndSuffix(dir); - return name === undefined ? undefined : directoryResult(name); + // If we have a suffix, then we read the directory all the way down to avoid returning completions for + // directories that don't contain files that would match the suffix. A previous comment here was concerned + // about the case where `normalizedSuffix` includes a `?` character, which should be interpreted literally, + // but will match any single character as part of the `include` pattern in `tryReadDirectory`. This is not + // a problem, because (in the extremely unusual circumstance where the suffix has a `?` in it) a `?` + // interpreted as "any character" can only return *too many* results as compared to the literal + // interpretation, so we can filter those superfluous results out via `trimPrefixAndSuffix` as we've always + // done. + var includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*"; + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var trimmedWithPattern = trimPrefixAndSuffix(match); + if (trimmedWithPattern) { + if (containsSlash(trimmedWithPattern)) { + return directoryResult(ts.getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]); + } + var _a = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _a.name, extension = _a.extension; + return nameAndKind(name, "script" /* ScriptElementKind.scriptElement */, extension); + } }); + // If we had a suffix, we already recursively searched for all possible files that could match + // it and returned the directories leading to those files. Otherwise, assume any directory could + // have something valid to import. + var directories = normalizedSuffix + ? ts.emptyArray + : ts.mapDefined(ts.tryGetDirectories(host, baseDirectory), function (dir) { return dir === "node_modules" ? undefined : directoryResult(dir); }); return __spreadArray(__spreadArray([], matches, true), directories, true); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); @@ -132820,13 +133516,13 @@ var ts; } var prefix = match[1], kind = match[2], toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path) + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* IncludeExtensionsOption.Include */), host, sourceFile.path) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) : ts.Debug.fail(); - return addReplacementSpans(toComplete, range.pos + prefix.length, names); + return addReplacementSpans(toComplete, range.pos + prefix.length, ts.arrayFrom(names.values())); } function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) { - if (result === void 0) { result = []; } + if (result === void 0) { result = createNameAndKindSet(); } // Check for typings specified in compiler options var seen = new ts.Map(); var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; @@ -132851,7 +133547,7 @@ var ts; continue; if (fragmentDirectory === undefined) { if (!seen.has(packageName)) { - result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.add(nameAndKind(packageName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); seen.set(packageName, true); } } @@ -132893,14 +133589,14 @@ var ts; var offset = index !== -1 ? index + 1 : 0; // If the range is an identifier, span is unnecessary. var length = text.length - offset; - return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); + return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ScriptTarget.ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); } // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* CharacterCodes.dot */ ? 2 : 1; var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + return slashCharCode === 47 /* CharacterCodes.slash */ || slashCharCode === 92 /* CharacterCodes.backslash */; } return false; } @@ -132957,7 +133653,7 @@ var ts; return "z" + sortText; }, ObjectLiteralProperty: function (presetSortText, symbolDisplayName) { - return presetSortText + "\0" + symbolDisplayName + "\0"; + return "".concat(presetSortText, "\0").concat(symbolDisplayName, "\0"); }, SortBelow: function (sortText) { return sortText + "1"; @@ -132999,16 +133695,16 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsThisType(origin) { - return !!(origin.kind & 1 /* ThisType */); + return !!(origin.kind & 1 /* SymbolOriginInfoKind.ThisType */); } function originIsSymbolMember(origin) { - return !!(origin.kind & 2 /* SymbolMember */); + return !!(origin.kind & 2 /* SymbolOriginInfoKind.SymbolMember */); } function originIsExport(origin) { - return !!(origin && origin.kind & 4 /* Export */); + return !!(origin && origin.kind & 4 /* SymbolOriginInfoKind.Export */); } function originIsResolvedExport(origin) { - return !!(origin && origin.kind === 32 /* ResolvedExport */); + return !!(origin && origin.kind === 32 /* SymbolOriginInfoKind.ResolvedExport */); } function originIncludesSymbolName(origin) { return originIsExport(origin) || originIsResolvedExport(origin); @@ -133017,16 +133713,16 @@ var ts; return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { - return !!(origin.kind & 8 /* Promise */); + return !!(origin.kind & 8 /* SymbolOriginInfoKind.Promise */); } function originIsNullableMember(origin) { - return !!(origin.kind & 16 /* Nullable */); + return !!(origin.kind & 16 /* SymbolOriginInfoKind.Nullable */); } function originIsTypeOnlyAlias(origin) { - return !!(origin && origin.kind & 64 /* TypeOnlyAlias */); + return !!(origin && origin.kind & 64 /* SymbolOriginInfoKind.TypeOnlyAlias */); } function originIsObjectLiteralMethod(origin) { - return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */); + return !!(origin && origin.kind & 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */); } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { @@ -133067,10 +133763,10 @@ var ts; resolvedAny: function () { return resolvedCount > 0; }, resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; }, }); - var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : ""; - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, logPrefix + ": resolved " + resolvedCount + " module specifiers, plus " + ambientCount + " ambient and " + resolvedFromCacheCount + " from cache" + hitRateMessage); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (skippedAny ? "incomplete" : "complete")); - (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start)); + var hitRateMessage = cacheAttemptCount ? " (".concat((resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1), "% hit rate)") : ""; + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "".concat(logPrefix, ": resolved ").concat(resolvedCount, " module specifiers, plus ").concat(ambientCount, " ambient and ").concat(resolvedFromCacheCount, " from cache").concat(hitRateMessage)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "".concat(logPrefix, ": response is ").concat(skippedAny ? "incomplete" : "complete")); + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "".concat(logPrefix, ": ").concat(ts.timestamp() - start)); return result; function tryResolve(exportInfo, symbolName, isFromAmbientModule) { if (isFromAmbientModule) { @@ -133113,7 +133809,7 @@ var ts; // we can continue it from the cached previous response. var compilerOptions = program.getCompilerOptions(); var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined; - if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { + if (incompleteCompletionsCache && completionKind === 3 /* CompletionTriggerKind.TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { var incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken); if (incompleteContinuation) { return incompleteContinuation; @@ -133127,7 +133823,7 @@ var ts; return stringCompletions; } if (previousToken && ts.isBreakOrContinueStatement(previousToken.parent) - && (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) { + && (previousToken.kind === 81 /* SyntaxKind.BreakKeyword */ || previousToken.kind === 86 /* SyntaxKind.ContinueKeyword */ || previousToken.kind === 79 /* SyntaxKind.Identifier */)) { return getLabelCompletionAtPosition(previousToken.parent); } var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken); @@ -133135,21 +133831,21 @@ var ts; return undefined; } switch (completionData.kind) { - case 0 /* Data */: + case 0 /* CompletionDataKind.Data */: var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position); if (response === null || response === void 0 ? void 0 : response.isIncomplete) { incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response); } return response; - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: // If the current position is a jsDoc tag name, only tag names should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagNameCompletions()); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: // If the current position is a jsDoc tag, only tags should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); - case 4 /* Keywords */: + case 4 /* CompletionDataKind.Keywords */: return specificKeywordCompletionInfo(completionData.keywordCompletions, completionData.isNewIdentifierLocation); default: return ts.Debug.assertNever(completionData); @@ -133166,16 +133862,16 @@ var ts; function compareCompletionEntries(entryInArray, entryToInsert) { var _a, _b; var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText); - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name); } - if (result === 0 /* EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { + if (result === 0 /* Comparison.EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { // Sort same-named auto-imports by module specifier result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier); } - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { // Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first. - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } return result; } @@ -133206,10 +133902,10 @@ var ts; if (result === "skipped") return entry; if (!result || result === "failed") { - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '" + entry.name + "' from '" + entry.source + "'"); + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '".concat(entry.name, "' from '").concat(entry.source, "'")); return undefined; } - var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); + var newOrigin = __assign(__assign({}, origin), { kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); // Mutating for performance... feels sketchy but nobody else uses the cache, // so why bother allocating a bunch of new objects? entry.data = originToCompletionEntryData(newOrigin); @@ -133223,7 +133919,7 @@ var ts; return entries; }); previousResponse.entries = newEntries; - previousResponse.flags = (previousResponse.flags || 0) | 4 /* IsContinuation */; + previousResponse.flags = (previousResponse.flags || 0) | 4 /* CompletionInfoFlags.IsContinuation */; return previousResponse; } function jsdocCompletionInfo(entries) { @@ -133232,8 +133928,8 @@ var ts; function keywordToCompletionEntry(keyword) { return { name: ts.tokenToString(keyword), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }; } @@ -133247,62 +133943,61 @@ var ts; } function keywordCompletionData(keywordFilters, filterOutTsOnlyKeywords, isNewIdentifierLocation) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: getKeywordCompletions(keywordFilters, filterOutTsOnlyKeywords), isNewIdentifierLocation: isNewIdentifierLocation, }; } function keywordFiltersFromSyntaxKind(keywordCompletion) { switch (keywordCompletion) { - case 152 /* TypeKeyword */: return 8 /* TypeKeyword */; + case 152 /* SyntaxKind.TypeKeyword */: return 8 /* KeywordCompletionFilters.TypeKeyword */; default: ts.Debug.fail("Unknown mapping from SyntaxKind to KeywordCompletionFilters"); } } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) { var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant - if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); if (completionInfo) { return completionInfo; } } var entries = ts.createSortedArray(); - if (isUncheckedFile(sourceFile, compilerOptions)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); - getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); - } - else { - if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { - return undefined; - } - getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); + var isChecked = isCheckedFile(sourceFile, compilerOptions); + if (isChecked && !isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* KeywordCompletionFilters.None */) { + return undefined; } - if (keywordFilters !== 0 /* None */) { - var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; })); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); + if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) { for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) { var keywordEntry = _a[_i]; - if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) { + if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) { + uniqueNames.add(keywordEntry.name); ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } } - var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) { var keywordEntry = _c[_b]; - if (!entryNames.has(keywordEntry.name)) { + if (!uniqueNames.has(keywordEntry.name)) { + uniqueNames.add(keywordEntry.name); ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) { var literal = literals_1[_d]; - ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true); + var literalEntry = createCompletionEntryForLiteral(sourceFile, preferences, literal); + uniqueNames.add(literalEntry.name); + ts.insertSorted(entries, literalEntry, compareCompletionEntries, /*allowDuplicates*/ true); + } + if (!isChecked) { + getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); } return { flags: completionData.flags, @@ -133314,14 +134009,14 @@ var ts; entries: entries, }; } - function isUncheckedFile(sourceFile, compilerOptions) { - return ts.isSourceFileJS(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); + function isCheckedFile(sourceFile, compilerOptions) { + return !ts.isSourceFileJS(sourceFile) || !!ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); } function isMemberCompletionKind(kind) { switch (kind) { - case 0 /* ObjectPropertyDeclaration */: - case 3 /* MemberLike */: - case 2 /* PropertyAccess */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: + case 3 /* CompletionKind.MemberLike */: + case 2 /* CompletionKind.PropertyAccess */: return true; default: return false; @@ -133331,12 +134026,12 @@ var ts; // We wanna walk up the tree till we find a JSX closing element var jsxClosingElement = ts.findAncestor(location, function (node) { switch (node.kind) { - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return true; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return false; default: return "quit"; @@ -133355,14 +134050,14 @@ var ts; // var x = // var y = // the completion list at "1" and "2" will contain "MainComponent.Child" with a replacement span of closing tag name - var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* SyntaxKind.GreaterThanToken */, sourceFile); var tagName = jsxClosingElement.parent.openingElement.tagName; var closingTag = tagName.getText(sourceFile); var fullClosingTag = closingTag + (hasClosingAngleBracket ? "" : ">"); var replacementSpan = ts.createTextSpanFromNode(jsxClosingElement.tagName); var entry = { name: fullClosingTag, - kind: "class" /* classElement */, + kind: "class" /* ScriptElementKind.classElement */, kindModifiers: undefined, sortText: Completions.SortText.LocationPriority, }; @@ -133381,7 +134076,7 @@ var ts; uniqueNames.add(realName); ts.insertSorted(entries, { name: realName, - kind: "warning" /* warning */, + kind: "warning" /* ScriptElementKind.warning */, kindModifiers: "", sortText: Completions.SortText.JavascriptIdentifiers, isFromUncheckedFile: true @@ -133394,7 +134089,7 @@ var ts; ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal); } function createCompletionEntryForLiteral(sourceFile, preferences, literal) { - return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority }; + return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority }; } function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; @@ -133411,18 +134106,18 @@ var ts; var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { insertText = needsConvertPropertyAccess - ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(sourceFile, preferences, name) + "]" - : "this" + (insertQuestionDot ? "?." : ".") + name; + ? "this".concat(insertQuestionDot ? "?." : "", "[").concat(quotePropertyName(sourceFile, preferences, name), "]") + : "this".concat(insertQuestionDot ? "?." : ".").concat(name); } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { - insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(sourceFile, preferences, name) + "]" : "[" + name + "]" : name; + insertText = useBraces ? needsConvertPropertyAccess ? "[".concat(quotePropertyName(sourceFile, preferences, name), "]") : "[".concat(name, "]") : name; if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { - insertText = "?." + insertText; + insertText = "?.".concat(insertText); } - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || - ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* SyntaxKind.DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* SyntaxKind.QuestionDotToken */, sourceFile); if (!dot) { return undefined; } @@ -133433,7 +134128,7 @@ var ts; if (isJsxInitializer) { if (insertText === undefined) insertText = name; - insertText = "{" + insertText + "}"; + insertText = "{".concat(insertText, "}"); if (typeof isJsxInitializer !== "boolean") { replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } @@ -133446,8 +134141,8 @@ var ts; if (precedingToken && ts.positionIsASICandidate(precedingToken.end, precedingToken.parent, sourceFile)) { awaitText = ";"; } - awaitText += "(await " + propertyAccessToConvert.expression.getText() + ")"; - insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + awaitText += "(await ".concat(propertyAccessToConvert.expression.getText(), ")"); + insertText = needsConvertPropertyAccess ? "".concat(awaitText).concat(insertText) : "".concat(awaitText).concat(insertQuestionDot ? "?." : ".").concat(insertText); replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } if (originIsResolvedExport(origin)) { @@ -133457,12 +134152,12 @@ var ts; isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; } } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { hasAction = true; } if (preferences.includeCompletionsWithClassMemberSnippets && preferences.includeCompletionsWithInsertText && - completionKind === 3 /* MemberLike */ && + completionKind === 3 /* CompletionKind.MemberLike */ && isClassLikeMemberCompletion(symbol, location)) { var importAdder = void 0; (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan); @@ -133486,11 +134181,11 @@ var ts; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. if (preferences.jsxAttributeCompletionStyle === "auto" - && !(type.flags & 528 /* BooleanLike */) - && !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) { - if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) { + && !(type.flags & 528 /* TypeFlags.BooleanLike */) + && !(type.flags & 1048576 /* TypeFlags.Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* TypeFlags.BooleanLike */); }))) { + if (type.flags & 402653316 /* TypeFlags.StringLike */ || (type.flags & 1048576 /* TypeFlags.Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* TypeFlags.StringLike */ | 32768 /* TypeFlags.Undefined */)); }))) { // If is string like or undefined use quotes - insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1"); + insertText = "".concat(ts.escapeSnippetText(name), "=").concat(ts.quote(sourceFile, preferences, "$1")); isSnippet = true; } else { @@ -133499,7 +134194,7 @@ var ts; } } if (useBraces_1) { - insertText = ts.escapeSnippetText(name) + "={$1}"; + insertText = "".concat(ts.escapeSnippetText(name), "={$1}"); isSnippet = true; } } @@ -133541,8 +134236,8 @@ var ts; return false; } // Completion symbol must be for a class member. - var memberFlags = 106500 /* ClassMember */ - & 900095 /* EnumMemberExcludes */; + var memberFlags = 106500 /* SymbolFlags.ClassMember */ + & 900095 /* SymbolFlags.EnumMemberExcludes */; /* In `class C { | @@ -133601,16 +134296,16 @@ var ts; // Note: this assumes we won't have more than one body in the completion nodes, which should be the case. var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; // Whether the suggested member should be abstract. // e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`. var _a = getPresentModifiers(contextToken), presentModifiers = _a.modifiers, modifiersSpan = _a.span; - var isAbstract = !!(presentModifiers & 128 /* Abstract */); + var isAbstract = !!(presentModifiers & 128 /* ModifierFlags.Abstract */); var completionNodes = []; ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder, // `addNewNodeForMemberSymbol` calls this callback function for each new member node @@ -133621,13 +134316,13 @@ var ts; // - One node; // - More than one node if the member is overloaded (e.g. a method with overload signatures). function (node) { - var requiredModifiers = 0 /* None */; + var requiredModifiers = 0 /* ModifierFlags.None */; if (isAbstract) { - requiredModifiers |= 128 /* Abstract */; + requiredModifiers |= 128 /* ModifierFlags.Abstract */; } if (ts.isClassElement(node) - && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) { - requiredModifiers |= 16384 /* Override */; + && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* MemberOverrideStatus.NeedsOverride */) { + requiredModifiers |= 16384 /* ModifierFlags.Override */; } if (!completionNodes.length) { // Keep track of added missing required modifiers and modifiers already present. @@ -133638,9 +134333,9 @@ var ts; } node = ts.factory.updateModifiers(node, modifiers); completionNodes.push(node); - }, body, 2 /* Property */, isAbstract); + }, body, 2 /* codefix.PreserveOptionalFlags.Property */, isAbstract); if (completionNodes.length) { - var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */; + var format = 1 /* ListFormat.MultiLine */ | 131072 /* ListFormat.NoTrailingNewLine */; replacementSpan = modifiersSpan; // If we have access to formatting settings, we print the nodes using the emitter, // and then format the printed text. @@ -133655,9 +134350,9 @@ var ts; } function getPresentModifiers(contextToken) { if (!contextToken) { - return { modifiers: 0 /* None */ }; + return { modifiers: 0 /* ModifierFlags.None */ }; } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; var span; var contextMod; /* @@ -133684,7 +134379,7 @@ var ts; span = ts.createTextSpanFromNode(contextToken); } if (ts.isPropertyDeclaration(contextToken.parent)) { - modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers) & 125951 /* Modifier */; + modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers) & 125951 /* ModifierFlags.Modifier */; span = ts.createTextSpanFromNode(contextToken.parent); } return { modifiers: modifiers, span: span }; @@ -133714,10 +134409,10 @@ var ts; newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))), }); if (formatContext) { - insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); + insertText = printer.printAndFormatSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); } else { - insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); + insertText = printer.printSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); } var signaturePrinter = ts.createPrinter({ removeComments: true, @@ -133730,7 +134425,7 @@ var ts; var methodSignature = ts.factory.createMethodSignature( /*modifiers*/ undefined, /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type); - var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) }; + var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) }; return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails }; } ; @@ -133744,18 +134439,18 @@ var ts; var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false); var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + var builderFlags = 33554432 /* NodeBuilderFlags.OmitThisParameter */ | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: { - var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10 - ? checker.getUnionType(type.types, 2 /* Subtype */) + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: { + var effectiveType = type.flags & 1048576 /* TypeFlags.Union */ && type.types.length < 10 + ? checker.getUnionType(type.types, 2 /* UnionReduction.Subtype */) : type; - if (effectiveType.flags & 1048576 /* Union */) { + if (effectiveType.flags & 1048576 /* TypeFlags.Union */) { // Only offer the completion if there's a single function type component. - var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; }); + var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; }); if (functionTypes.length === 1) { effectiveType = functionTypes[0]; } @@ -133763,7 +134458,7 @@ var ts; return undefined; } } - var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */); + var signatures = checker.getSignaturesOfType(effectiveType, 0 /* SignatureKind.Call */); if (signatures.length !== 1) { // We don't support overloads in object literals. return undefined; @@ -133776,7 +134471,7 @@ var ts; if (preferences.includeCompletionsWithSnippetText) { var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); @@ -133876,11 +134571,11 @@ var ts; return unresolvedData; } function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) { - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; var isFromPackageJson = !!data.isPackageJsonImport; if (completionEntryDataIsResolved(data)) { var resolvedOrigin = { - kind: 32 /* ResolvedExport */, + kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, exportName: data.exportName, moduleSpecifier: data.moduleSpecifier, symbolName: completionName, @@ -133892,7 +134587,7 @@ var ts; return resolvedOrigin; } var unresolvedOrigin = { - kind: 4 /* Export */, + kind: 4 /* SymbolOriginInfoKind.Export */, exportName: data.exportName, exportMapKey: data.exportMapKey, symbolName: completionName, @@ -133908,21 +134603,21 @@ var ts; var sourceFile = importCompletionNode.getSourceFile(); var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); - var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ : + origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ : + 0 /* ExportKind.Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true); var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly); var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken); - var topLevelTypeOnlyText = isTopLevelTypeOnly ? " " + ts.tokenToString(152 /* TypeKeyword */) + " " : " "; - var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(152 /* TypeKeyword */) + " " : ""; + var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : " "; + var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : ""; var suffix = useSemicolons ? ";" : ""; switch (importKind) { - case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; - case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix }; - case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix }; - case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix }; + case 3 /* ImportKind.CommonJS */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " = require(").concat(quotedModuleSpecifier, ")").concat(suffix) }; + case 1 /* ImportKind.Default */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 2 /* ImportKind.Namespace */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "* as ").concat(ts.escapeSnippetText(name), " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 0 /* ImportKind.Named */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "{ ").concat(importSpecifierTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " } from ").concat(quotedModuleSpecifier).concat(suffix) }; } } function quotePropertyName(sourceFile, preferences, name) { @@ -133933,7 +134628,7 @@ var ts; } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || - !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; + !!(localSymbol.flags & 1048576 /* SymbolFlags.ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; } function getSourceFromOrigin(origin) { if (originIsExport(origin)) { @@ -133942,10 +134637,10 @@ var ts; if (originIsResolvedExport(origin)) { return origin.moduleSpecifier; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* SymbolOriginInfoKind.ThisType */) { return CompletionSource.ThisProperty; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { return CompletionSource.TypeOnlyAlias; } } @@ -133964,7 +134659,7 @@ var ts; var symbol = symbols[i]; var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); - if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { + if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* CompletionKind.Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; @@ -134017,7 +134712,7 @@ var ts; allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin); // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(allFlags & 1920 /* Namespace */); + return !!(allFlags & 1920 /* SymbolFlags.Namespace */); } if (isTypeOnlyLocation) { // It's a type, but you can reach it by namespace.type as well @@ -134025,7 +134720,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(allFlags & 111551 /* Value */); + return !!(allFlags & 111551 /* SymbolFlags.Value */); } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; @@ -134049,8 +134744,8 @@ var ts; uniques.set(name, true); entries.push({ name: name, - kindModifiers: "" /* none */, - kind: "label" /* label */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "label" /* ScriptElementKind.label */, sortText: Completions.SortText.LocationPriority }); } @@ -134081,7 +134776,7 @@ var ts; if (!completionData) { return { type: "none" }; } - if (completionData.kind !== 0 /* Data */) { + if (completionData.kind !== 0 /* CompletionDataKind.Data */) { return { type: "request", request: completionData }; } var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; @@ -134095,8 +134790,8 @@ var ts; return ts.firstDefined(symbols, function (symbol, index) { var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); - return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ - || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */) + return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* SymbolFlags.ClassMember */ + || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */) || getSourceFromOrigin(origin) === entryId.source) ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; @@ -134116,14 +134811,14 @@ var ts; case "request": { var request = symbolCompletion.request; switch (request.kind) { - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: return ts.JsDoc.getJSDocTagNameCompletionDetails(name); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: return ts.JsDoc.getJSDocTagCompletionDetails(name); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); - case 4 /* Keywords */: - return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + case 4 /* CompletionDataKind.Keywords */: + return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } @@ -134135,22 +134830,22 @@ var ts; } case "literal": { var literal = symbolCompletion.literal; - return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); + return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* ScriptElementKind.string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. - return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: ts.Debug.assertNever(symbolCompletion); } } Completions.getCompletionEntryDetails = getCompletionEntryDetails; function createSimpleDetails(name, kind, kind2) { - return createCompletionDetails(name, "" /* none */, kind, [ts.displayPart(name, kind2)]); + return createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, kind, [ts.displayPart(name, kind2)]); } function createCompletionDetailsForSymbol(symbol, checker, sourceFile, location, cancellationToken, codeActions, sourceDisplay) { var _a = checker.runWithCancellationToken(cancellationToken, function (checker) { - return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* All */); + return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* SemanticMeaning.All */); }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(checker, symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } @@ -134190,7 +134885,7 @@ var ts; var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); var moduleSymbol = origin.moduleSymbol; var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); + var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier); return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -134222,7 +134917,7 @@ var ts; return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { var symbol = type && type.symbol; // Don't include make a recommended completion for an abstract class - return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol)) + return symbol && (symbol.flags & (8 /* SymbolFlags.EnumMember */ | 384 /* SymbolFlags.Enum */ | 32 /* SymbolFlags.Class */) && !ts.isAbstractConstructorSymbol(symbol)) ? getFirstSymbolInChain(symbol, previousToken, checker) : undefined; }); @@ -134230,31 +134925,31 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return checker.getContextualType(parent); - case 82 /* CaseKeyword */: + case 82 /* SyntaxKind.CaseKeyword */: var caseClause = ts.tryCast(parent, ts.isCaseClause); return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? // At `,`, treat this as the next argument after the comma. - checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* SyntaxKind.CommaToken */ ? 1 : 0)) : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side checker.getTypeAtLocation(parent.left) : @@ -134262,18 +134957,18 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* SymbolFlags.All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { var _a; - return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; })); + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SyntaxKind.SourceFile */; })); } function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) { var typeChecker = program.getTypeChecker(); - var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions); + var inCheckedFile = isCheckedFile(sourceFile, compilerOptions); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) @@ -134285,10 +134980,10 @@ var ts; var isInSnippetScope = false; if (insideComment) { if (ts.hasDocComment(sourceFile, position)) { - if (sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + if (sourceFile.text.charCodeAt(position - 1) === 64 /* CharacterCodes.at */) { // The current position is next to the '@' sign, when no tag name being provided yet. // Provide a full list of tag names - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } else { // When completion is requested without "@", we will have check to make sure that @@ -134309,7 +135004,7 @@ var ts; // */ var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) { - return { kind: 2 /* JsDocTag */ }; + return { kind: 2 /* CompletionDataKind.JsDocTag */ }; } } } @@ -134319,21 +135014,21 @@ var ts; var tag = getJsDocTagAtPosition(currentToken, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } var typeExpression = tryGetTypeExpressionFromTag(tag); if (typeExpression) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 347 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 347 /* SyntaxKind.JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression); } } if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) { - return { kind: 3 /* JsDocParameterName */, tag: tag }; + return { kind: 3 /* CompletionDataKind.JsDocParameterName */, tag: tag }; } } if (!insideJsDocTagTypeExpression) { @@ -134364,16 +135059,16 @@ var ts; var isJsxIdentifierExpected = false; var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); - var keywordFilters = 0 /* None */; + var keywordFilters = 0 /* KeywordCompletionFilters.None */; var isNewIdentifierLocation = false; - var flags = 0 /* None */; + var flags = 0 /* CompletionInfoFlags.None */; if (contextToken) { var importStatementCompletion = getImportStatementCompletionInfo(contextToken); isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation; if (importStatementCompletion.keywordCompletion) { if (importStatementCompletion.isKeywordOnlyCompletion) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)], isNewIdentifierLocation: isNewIdentifierLocation, }; @@ -134386,7 +135081,7 @@ var ts; // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients // to opt in with the `includeCompletionsForImportStatements` user preference. importCompletionNode = importStatementCompletion.replacementNode; - flags |= 2 /* IsImportStatementCompletion */; + flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */; } // Bail out if this is a known invalid completion location if (!importCompletionNode && isCompletionListBlocker(contextToken)) { @@ -134396,11 +135091,11 @@ var ts; : undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { - isRightOfDot = contextToken.kind === 24 /* DotToken */; - isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; + if (contextToken.kind === 24 /* SyntaxKind.DotToken */ || contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* SyntaxKind.DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert); @@ -134408,7 +135103,7 @@ var ts; ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && node.end === contextToken.pos && node.getChildCount(sourceFile) && - ts.last(node.getChildren(sourceFile)).kind !== 21 /* CloseParenToken */)) { + ts.last(node.getChildren(sourceFile)).kind !== 21 /* SyntaxKind.CloseParenToken */)) { // This is likely dot from incorrectly parsed expression and user is starting to write spread // eg: Math.min(./**/) // const x = function (./**/) {} @@ -134416,18 +135111,18 @@ var ts; return undefined; } break; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: node = parent.left; break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: node = parent.name; break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: node = parent; break; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: node = parent.getFirstToken(sourceFile); - ts.Debug.assert(node.kind === 100 /* ImportKeyword */ || node.kind === 103 /* NewKeyword */); + ts.Debug.assert(node.kind === 100 /* SyntaxKind.ImportKeyword */ || node.kind === 103 /* SyntaxKind.NewKeyword */); break; default: // There is nothing that precedes the dot, so this likely just a stray character @@ -134435,58 +135130,58 @@ var ts; return undefined; } } - else if (!importCompletionNode && sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) { // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 206 /* PropertyAccessExpression */) { + if (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 278 /* JsxElement */ || currentToken.parent.kind === 280 /* JsxOpeningElement */) { + case 31 /* SyntaxKind.GreaterThanToken */: + if (currentToken.parent.kind === 278 /* SyntaxKind.JsxElement */ || currentToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { location = currentToken; } break; - case 43 /* SlashToken */: - if (currentToken.parent.kind === 279 /* JsxSelfClosingElement */) { + case 43 /* SyntaxKind.SlashToken */: + if (currentToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 281 /* JsxClosingElement */: - if (contextToken.kind === 43 /* SlashToken */) { + case 281 /* SyntaxKind.JsxClosingElement */: + if (contextToken.kind === 43 /* SyntaxKind.SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: isJsxIdentifierExpected = true; - if (contextToken.kind === 29 /* LessThanToken */) { + if (contextToken.kind === 29 /* SyntaxKind.LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` - if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { + if (previousToken.kind === 19 /* SyntaxKind.CloseBraceToken */ && currentToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -134494,16 +135189,16 @@ var ts; break; } switch (previousToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: isJsxInitializer = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: isJsxIdentifierExpected = true; // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* SyntaxKind.EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -134512,7 +135207,7 @@ var ts; } } var semanticStart = ts.timestamp(); - var completionKind = 5 /* None */; + var completionKind = 5 /* CompletionKind.None */; var isNonContextualObjectLiteral = false; var hasUnresolvedAutoImports = false; // This also gets mutated in nested-functions after the return @@ -134532,8 +135227,8 @@ var ts; symbols = typeChecker.getJsxIntrinsicTagNamesAt(location); ts.Debug.assertEachIsDefined(symbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else if (isStartingCloseTag) { var tagName = contextToken.parent.parent.openingElement.tagName; @@ -134541,8 +135236,8 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the @@ -134556,10 +135251,10 @@ var ts; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); var contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker); - var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : undefined; }); + var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* TypeFlags.EnumLiteral */) ? t.value : undefined; }); var recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker); return { - kind: 0 /* Data */, + kind: 0 /* CompletionDataKind.Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, @@ -134584,13 +135279,13 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 345 /* JSDocTypedefTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return true; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return !!tag.constraint; default: return false; @@ -134599,13 +135294,13 @@ var ts; function tryGetTypeExpressionFromTag(tag) { if (isTagWithTypeExpression(tag)) { var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression; - return typeExpression && typeExpression.kind === 309 /* JSDocTypeExpression */ ? typeExpression : undefined; + return typeExpression && typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? typeExpression : undefined; } return undefined; } function getTypeScriptMemberSymbols() { // Right of dot member completion list - completionKind = 2 /* PropertyAccess */; + completionKind = 2 /* CompletionKind.PropertyAccess */; // Since this is qualified name check it's a type node location var isImportType = ts.isLiteralImportTypeNode(node); var isTypeLocation = insideJsDocTagTypeExpression @@ -134620,7 +135315,7 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & (1536 /* Module */ | 384 /* Enum */)) { + if (symbol.flags & (1536 /* SymbolFlags.Module */ | 384 /* SymbolFlags.Enum */)) { // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); @@ -134628,7 +135323,7 @@ var ts; var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); }; var isValidAccess = isNamespaceName // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. - ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } + ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* SymbolFlags.Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -134642,7 +135337,7 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 305 /* SourceFile */ && d.kind !== 261 /* ModuleDeclaration */ && d.kind !== 260 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 305 /* SyntaxKind.SourceFile */ && d.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 260 /* SyntaxKind.EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -134656,7 +135351,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } return; } @@ -134680,7 +135375,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } } function addTypeProperties(type, insertAwait, insertQuestionDot) { @@ -134688,16 +135383,8 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent; - if (inUncheckedFile) { - // In javascript files, for union types, we don't just get the members that - // the individual types have in common, we also include all the members that - // each individual type has. This is because we're going to add all identifiers - // anyways. So we might as well elevate the members that were at least part - // of the individual types to a higher status since we know what they are. - symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); })); - } - else { + var propertyAccess = node.kind === 200 /* SyntaxKind.ImportType */ ? node : node.parent; + if (inCheckedFile) { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { @@ -134705,6 +135392,14 @@ var ts; } } } + else { + // In javascript files, for union types, we don't just get the members that + // the individual types have in common, we also include all the members that + // each individual type has. This is because we're going to add all identifiers + // anyways. So we might as well elevate the members that were at least part + // of the individual types to a higher status since we know what they are. + symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); })); + } if (insertAwait && preferences.includeCompletionsWithInsertText) { var promiseType = typeChecker.getPromisedTypeOfPromise(type); if (promiseType) { @@ -134735,12 +135430,12 @@ var ts; if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) || typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) { - symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolOriginInfoKind.SymbolMemberNoExport */) }; } else { var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined; var moduleSpecifier = ((importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences))).getModuleSpecifierForBestExportInfo([{ - exportKind: 0 /* Named */, + exportKind: 0 /* ExportKind.Named */, moduleFileName: fileName, isFromPackageJson: false, moduleSymbol: moduleSymbol, @@ -134749,7 +135444,7 @@ var ts; }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)) || {}).moduleSpecifier; if (moduleSpecifier) { var origin = { - kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false, symbolName: firstAccessibleSymbol.name, @@ -134780,15 +135475,15 @@ var ts; function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { - symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* SymbolOriginInfoKind.Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* SymbolOriginInfoKind.Nullable */ }; } } } function getNullableSymbolOriginInfoKind(kind) { - return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + return insertQuestionDot ? kind | 16 /* SymbolOriginInfoKind.Nullable */ : kind; } } /** Given 'a.b.c', returns 'a'. */ @@ -134804,44 +135499,44 @@ var ts; || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() - || (getGlobalCompletions(), 1 /* Success */); - return result === 1 /* Success */; + || (getGlobalCompletions(), 1 /* GlobalsSearch.Success */); + return result === 1 /* GlobalsSearch.Success */; } function tryGetConstructorCompletion() { if (!tryGetConstructorLikeCompletionContainer(contextToken)) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // no members, only keywords - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; // Declaring new property/method/accessor isNewIdentifierLocation = true; // Has keywords for constructor parameter - keywordFilters = 4 /* ConstructorParameterKeywords */; - return 1 /* Success */; + keywordFilters = 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */; + return 1 /* GlobalsSearch.Success */; } function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) - return 0 /* Continue */; - var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* Completions */); + return 0 /* GlobalsSearch.Continue */; + var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* ContextFlags.Completions */); symbols = ts.concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties)); setSortTextToOptionalMember(); - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function tryGetImportCompletionSymbols() { if (!importCompletionNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; isNewIdentifierLocation = true; collectAutoImports(); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function getGlobalCompletions() { - keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; + keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */ : 1 /* KeywordCompletionFilters.All */; // Get all entities in the current scope. - completionKind = 1 /* Global */; + completionKind = 1 /* CompletionKind.Global */; isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); @@ -134876,7 +135571,7 @@ var ts; position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); - var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnlyLocation ? 0 /* SymbolFlags.None */ : 111551 /* SymbolFlags.Value */) | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */; var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken); symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings)); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); @@ -134886,21 +135581,21 @@ var ts; !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords; } - if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) { + if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* SymbolFlags.Value */)) { var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); if (typeOnlyAliasDeclaration) { - var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; + var origin = { kind: 64 /* SymbolOriginInfoKind.TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; symbolToOriginInfoMap[i] = origin; } } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SyntaxKind.SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; - symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* SymbolOriginInfoKind.ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers; } @@ -134909,8 +135604,8 @@ var ts; collectAutoImports(); if (isTypeOnlyLocation) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* KeywordCompletionFilters.TypeAssertionKeywords */ + : 7 /* KeywordCompletionFilters.TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -134934,10 +135629,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 305 /* SourceFile */: - case 223 /* TemplateExpression */: - case 288 /* JsxExpression */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 223 /* SyntaxKind.TemplateExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 235 /* SyntaxKind.Block */: return true; default: return ts.isStatement(scopeNode); @@ -134953,29 +135648,29 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - ((contextToken.kind === 112 /* TypeOfKeyword */ && - (contextToken.parent.kind === 181 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || - (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 177 /* TypePredicate */)); + ((contextToken.kind === 112 /* SyntaxKind.TypeOfKeyword */ && + (contextToken.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* SyntaxKind.AssertsKeyword */ && contextToken.parent.kind === 177 /* SyntaxKind.TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 58 /* ColonToken */: - return parentKind === 167 /* PropertyDeclaration */ || - parentKind === 166 /* PropertySignature */ || - parentKind === 164 /* Parameter */ || - parentKind === 254 /* VariableDeclaration */ || + case 58 /* SyntaxKind.ColonToken */: + return parentKind === 167 /* SyntaxKind.PropertyDeclaration */ || + parentKind === 166 /* SyntaxKind.PropertySignature */ || + parentKind === 164 /* SyntaxKind.Parameter */ || + parentKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 63 /* EqualsToken */: - return parentKind === 259 /* TypeAliasDeclaration */; - case 127 /* AsKeyword */: - return parentKind === 229 /* AsExpression */; - case 29 /* LessThanToken */: - return parentKind === 178 /* TypeReference */ || - parentKind === 211 /* TypeAssertionExpression */; - case 94 /* ExtendsKeyword */: - return parentKind === 163 /* TypeParameter */; + case 63 /* SyntaxKind.EqualsToken */: + return parentKind === 259 /* SyntaxKind.TypeAliasDeclaration */; + case 127 /* SyntaxKind.AsKeyword */: + return parentKind === 229 /* SyntaxKind.AsExpression */; + case 29 /* SyntaxKind.LessThanToken */: + return parentKind === 178 /* SyntaxKind.TypeReference */ || + parentKind === 211 /* SyntaxKind.TypeAssertionExpression */; + case 94 /* SyntaxKind.ExtendsKeyword */: + return parentKind === 163 /* SyntaxKind.TypeParameter */; } } return false; @@ -134990,7 +135685,7 @@ var ts; // Asking for completion details for an item that is not an auto-import return; } - flags |= 1 /* MayIncludeAutoImports */; + flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */; // import { type | -> token text should be blank var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken && importCompletionNode @@ -135009,13 +135704,13 @@ var ts; return false; if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return false; - if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */)) + if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */)) return false; - if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */))) + if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */))) return false; // Do not try to auto-import something with a lowercase first letter for a JSX tag var firstChar = symbolName.charCodeAt(0); - if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */)) + if (isRightOfOpenTag && (firstChar < 65 /* CharacterCodes.A */ || firstChar > 90 /* CharacterCodes.Z */)) return false; if (detailsEntryId) return true; @@ -135051,14 +135746,14 @@ var ts; if (result !== "skipped") { (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier); } - var isDefaultExport = exportInfo.exportKind === 1 /* Default */; + var isDefaultExport = exportInfo.exportKind === 1 /* ExportKind.Default */; var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol; pushAutoImportSymbol(symbol, { - kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + kind: moduleSpecifier ? 32 /* SymbolOriginInfoKind.ResolvedExport */ : 4 /* SymbolOriginInfoKind.Export */, moduleSpecifier: moduleSpecifier, symbolName: symbolName, exportMapKey: exportMapKey, - exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name, + exportName: exportInfo.exportKind === 2 /* ExportKind.ExportEquals */ ? "export=" /* InternalSymbolName.ExportEquals */ : exportInfo.symbol.name, fileName: exportInfo.moduleFileName, isDefaultExport: isDefaultExport, moduleSymbol: exportInfo.moduleSymbol, @@ -135066,8 +135761,8 @@ var ts; }); }); hasUnresolvedAutoImports = context.skippedAny(); - flags |= context.resolvedAny() ? 8 /* ResolvedModuleSpecifiers */ : 0; - flags |= context.resolvedBeyondLimit() ? 16 /* ResolvedModuleSpecifiersBeyondLimit */ : 0; + flags |= context.resolvedAny() ? 8 /* CompletionInfoFlags.ResolvedModuleSpecifiers */ : 0; + flags |= context.resolvedBeyondLimit() ? 16 /* CompletionInfoFlags.ResolvedModuleSpecifiersBeyondLimit */ : 0; }); function isImportableExportInfo(info) { var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); @@ -135104,7 +135799,7 @@ var ts; return; } var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions), - /*origin*/ undefined, 0 /* ObjectPropertyDeclaration */, + /*origin*/ undefined, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (!displayName) { return; @@ -135114,8 +135809,8 @@ var ts; if (!entryProps) { return; } - var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps); - flags |= 32 /* MayIncludeMethodSnippets */; + var origin = __assign({ kind: 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */ }, entryProps); + flags |= 32 /* CompletionInfoFlags.MayIncludeMethodSnippets */; symbolToOriginInfoMap[symbols.length] = origin; symbols.push(member); }); @@ -135130,7 +135825,7 @@ var ts; `bar` will have symbol flag `Method`, `foo` will have symbol flag `Property`. */ - if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) { + if (!(symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */))) { return false; } return true; @@ -135157,27 +135852,27 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 11 /* JsxText */) { + if (contextToken.kind === 11 /* SyntaxKind.JsxText */) { return true; } - if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */ && contextToken.parent) { // /**/ /> // /**/ > // - contextToken: GreaterThanToken (before cursor) // - location: JsxSelfClosingElement or JsxOpeningElement // - contextToken.parent === location - if (location === contextToken.parent && (location.kind === 280 /* JsxOpeningElement */ || location.kind === 279 /* JsxSelfClosingElement */)) { + if (location === contextToken.parent && (location.kind === 280 /* SyntaxKind.JsxOpeningElement */ || location.kind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { return false; } - if (contextToken.parent.kind === 280 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { //
/**/ // - contextToken: GreaterThanToken (before cursor) // - location: JSXElement // - different parents (JSXOpeningElement, JSXElement) - return location.parent.kind !== 280 /* JsxOpeningElement */; + return location.parent.kind !== 280 /* SyntaxKind.JsxOpeningElement */; } - if (contextToken.parent.kind === 281 /* JsxClosingElement */ || contextToken.parent.kind === 279 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* JsxElement */; + if (contextToken.parent.kind === 281 /* SyntaxKind.JsxClosingElement */ || contextToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* SyntaxKind.JsxElement */; } } return false; @@ -135188,45 +135883,45 @@ var ts; var tokenKind = keywordForNode(contextToken); // Previous token may have been a keyword that was converted to an identifier. switch (tokenKind) { - case 27 /* CommaToken */: - return containingNodeKind === 208 /* CallExpression */ // func( a, | - || containingNodeKind === 171 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 209 /* NewExpression */ // new C(a, | - || containingNodeKind === 204 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 221 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 179 /* FunctionType */ // var x: (s: string, list| - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { x, | - case 20 /* OpenParenToken */: - return containingNodeKind === 208 /* CallExpression */ // func( | - || containingNodeKind === 171 /* Constructor */ // constructor( | - || containingNodeKind === 209 /* NewExpression */ // new C(a| - || containingNodeKind === 212 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 191 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 22 /* OpenBracketToken */: - return containingNodeKind === 204 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 176 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 162 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 141 /* ModuleKeyword */: // module | - case 142 /* NamespaceKeyword */: // namespace | - case 100 /* ImportKeyword */: // import | + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( a, | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a, | + || containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [a, | + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */ // const x = (a, | + || containingNodeKind === 179 /* SyntaxKind.FunctionType */ // var x: (s: string, list| + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { x, | + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( | + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a| + || containingNodeKind === 212 /* SyntaxKind.ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 191 /* SyntaxKind.ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [ | + || containingNodeKind === 176 /* SyntaxKind.IndexSignature */ // [ | : string ] + || containingNodeKind === 162 /* SyntaxKind.ComputedPropertyName */; // [ | /* this can become an index signature */ + case 141 /* SyntaxKind.ModuleKeyword */: // module | + case 142 /* SyntaxKind.NamespaceKeyword */: // namespace | + case 100 /* SyntaxKind.ImportKeyword */: // import | return true; - case 24 /* DotToken */: - return containingNodeKind === 261 /* ModuleDeclaration */; // module A.| - case 18 /* OpenBraceToken */: - return containingNodeKind === 257 /* ClassDeclaration */ // class A { | - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { | - case 63 /* EqualsToken */: - return containingNodeKind === 254 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 221 /* BinaryExpression */; // x = a| - case 15 /* TemplateHead */: - return containingNodeKind === 223 /* TemplateExpression */; // `aa ${| - case 16 /* TemplateMiddle */: - return containingNodeKind === 233 /* TemplateSpan */; // `aa ${10} dd ${| - case 131 /* AsyncKeyword */: - return containingNodeKind === 169 /* MethodDeclaration */ // const obj = { async c|() - || containingNodeKind === 297 /* ShorthandPropertyAssignment */; // const obj = { async c| - case 41 /* AsteriskToken */: - return containingNodeKind === 169 /* MethodDeclaration */; // const obj = { * c| + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 261 /* SyntaxKind.ModuleDeclaration */; // module A.| + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ // class A { | + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { | + case 63 /* SyntaxKind.EqualsToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ // const x = a| + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */; // x = a| + case 15 /* SyntaxKind.TemplateHead */: + return containingNodeKind === 223 /* SyntaxKind.TemplateExpression */; // `aa ${| + case 16 /* SyntaxKind.TemplateMiddle */: + return containingNodeKind === 233 /* SyntaxKind.TemplateSpan */; // `aa ${10} dd ${| + case 131 /* SyntaxKind.AsyncKeyword */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */ // const obj = { async c|() + || containingNodeKind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; // const obj = { async c| + case 41 /* SyntaxKind.AsteriskToken */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */; // const obj = { * c| } if (isClassMemberCompletionKeyword(tokenKind)) { return true; @@ -135245,21 +135940,21 @@ var ts; function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { var typeLiteralNode = tryGetTypeLiteralNode(contextToken); if (!typeLiteralNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; var containerTypeNode = intersectionTypeNode || typeLiteralNode; var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); if (!containerExpectedType) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var containerActualType = typeChecker.getTypeFromTypeNode(containerTypeNode); var members = getPropertiesForCompletion(containerExpectedType, typeChecker); var existingMembers = getPropertiesForCompletion(containerActualType, typeChecker); var existingMemberEscapedNames = new ts.Set(); existingMembers.forEach(function (s) { return existingMemberEscapedNames.add(s.escapedName); }); symbols = ts.concatenate(symbols, ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); })); - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; isNewIdentifierLocation = true; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. @@ -135271,22 +135966,22 @@ var ts; var symbolsStartIndex = symbols.length; var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); if (!objectLikeContainer) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from contextual/inferred/declared type. - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { - if (objectLikeContainer.flags & 33554432 /* InWithStatement */) { - return 2 /* Fail */; + if (objectLikeContainer.flags & 33554432 /* NodeFlags.InWithStatement */) { + return 2 /* GlobalsSearch.Fail */; } isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } - var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* Completions */); + var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* ContextFlags.Completions */); var hasStringIndexType = (completionsType || instantiatedType).getStringIndexType(); var hasNumberIndextype = (completionsType || instantiatedType).getNumberIndexType(); isNewIdentifierLocation = !!hasStringIndexType || !!hasNumberIndextype; @@ -135296,12 +135991,12 @@ var ts; // Edge case: If NumberIndexType exists if (!hasNumberIndextype) { isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } } } else { - ts.Debug.assert(objectLikeContainer.kind === 201 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 201 /* SyntaxKind.ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -135312,19 +136007,19 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 164 /* SyntaxKind.Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 169 /* MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SyntaxKind.SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } if (canGetType) { var typeForObject_1 = typeChecker.getTypeAtLocation(objectLikeContainer); if (!typeForObject_1) - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; typeMembers = typeChecker.getPropertiesOfType(typeForObject_1).filter(function (propertySymbol) { return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*writing*/ false, typeForObject_1, propertySymbol); }); @@ -135336,14 +136031,14 @@ var ts; var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)); symbols = ts.concatenate(symbols, filteredMembers); setSortTextToOptionalMember(); - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */ + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && preferences.includeCompletionsWithObjectLiteralMethodSnippets && preferences.includeCompletionsWithInsertText) { transformObjectLiteralMembersSortText(symbolsStartIndex); collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer); } } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in import clauses and export clauses @@ -135360,38 +136055,38 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { if (!contextToken) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // `import { |` or `import { a as 0, | }` or `import { type | }` - var namedImportsOrExports = contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : + var namedImportsOrExports = contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : ts.isTypeKeywordTokenOrIdentifier(contextToken) ? ts.tryCast(contextToken.parent.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We can at least offer `type` at `import { |` if (!ts.isTypeKeywordTokenOrIdentifier(contextToken)) { - keywordFilters = 8 /* TypeKeyword */; + keywordFilters = 8 /* KeywordCompletionFilters.TypeKeyword */; } // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 269 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) { isNewIdentifierLocation = true; - return namedImportsOrExports.kind === 269 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? 2 /* GlobalsSearch.Fail */ : 0 /* GlobalsSearch.Continue */; } var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) { isNewIdentifierLocation = true; - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; } - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); var existing = new ts.Set(namedImportsOrExports.elements.filter(function (n) { return !isCurrentlyEditingNode(n); }).map(function (n) { return (n.propertyName || n.name).escapedText; })); - var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); }); + var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* InternalSymbolName.Default */ && !existing.has(e.escapedName); }); symbols = ts.concatenate(symbols, uniques); if (!uniques.length) { // If there's nothing else to import, don't offer `type` either - keywordFilters = 0 /* None */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Adds local declarations for completions in named exports: @@ -135404,14 +136099,14 @@ var ts; */ function tryGetLocalNamedExportCompletionSymbols() { var _a; - var namedExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) + var namedExports = contextToken && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedExports) : undefined; if (!namedExports) { - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } var localsContainer = ts.findAncestor(namedExports, ts.or(ts.isSourceFile, ts.isModuleDeclaration)); - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; isNewIdentifierLocation = false; (_a = localsContainer.locals) === null || _a === void 0 ? void 0 : _a.forEach(function (symbol, name) { var _a, _b; @@ -135420,7 +136115,7 @@ var ts; symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember; } }); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in class declaration @@ -135429,48 +136124,48 @@ var ts; function tryGetClassLikeCompletionSymbols() { var decl = tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position); if (!decl) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from parent type. - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : - ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; + keywordFilters = contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ ? 0 /* KeywordCompletionFilters.None */ : + ts.isClassLike(decl) ? 2 /* KeywordCompletionFilters.ClassElementKeywords */ : 3 /* KeywordCompletionFilters.InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) - return 1 /* Success */; - var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; + return 1 /* GlobalsSearch.Success */; + var classElement = contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* ModifierFlags.None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* SyntaxKind.Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": - classElementModifierFlags = classElementModifierFlags | 8 /* Private */; + classElementModifierFlags = classElementModifierFlags | 8 /* ModifierFlags.Private */; break; case "static": - classElementModifierFlags = classElementModifierFlags | 32 /* Static */; + classElementModifierFlags = classElementModifierFlags | 32 /* ModifierFlags.Static */; break; case "override": - classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + classElementModifierFlags = classElementModifierFlags | 16384 /* ModifierFlags.Override */; break; } } if (ts.isClassStaticBlockDeclaration(classElement)) { - classElementModifierFlags |= 32 /* Static */; + classElementModifierFlags |= 32 /* ModifierFlags.Static */; } // No member list for private methods - if (!(classElementModifierFlags & 8 /* Private */)) { + if (!(classElementModifierFlags & 8 /* ModifierFlags.Private */)) { // List of property symbols of base type that are not private and already implemented - var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* ModifierFlags.Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); var baseSymbols = ts.flatMap(baseTypeNodes, function (baseTypeNode) { var type = typeChecker.getTypeAtLocation(baseTypeNode); - return classElementModifierFlags & 32 /* Static */ ? + return classElementModifierFlags & 32 /* ModifierFlags.Static */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); }); symbols = ts.concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags)); } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function isConstructorParameterCompletion(node) { return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent) @@ -135484,8 +136179,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 20 /* OpenParenToken */: - case 27 /* CommaToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 27 /* SyntaxKind.CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -135515,23 +136210,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 31 /* GreaterThanToken */: // End of a type argument list - case 30 /* LessThanSlashToken */: - case 43 /* SlashToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: - case 286 /* JsxAttributes */: - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 279 /* JsxSelfClosingElement */ || parent.kind === 280 /* JsxOpeningElement */)) { - if (contextToken.kind === 31 /* GreaterThanToken */) { + case 31 /* SyntaxKind.GreaterThanToken */: // End of a type argument list + case 30 /* SyntaxKind.LessThanSlashToken */: + case 43 /* SyntaxKind.SlashToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 286 /* SyntaxKind.JsxAttributes */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + if (parent && (parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || parent.kind === 280 /* SyntaxKind.JsxOpeningElement */)) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SyntaxKind.SlashToken */)) break; } return parent; } - else if (parent.kind === 285 /* JsxAttribute */) { + else if (parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -135542,8 +136237,8 @@ var ts; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement - case 10 /* StringLiteral */: - if (parent && ((parent.kind === 285 /* JsxAttribute */) || (parent.kind === 287 /* JsxSpreadAttribute */))) { + case 10 /* SyntaxKind.StringLiteral */: + if (parent && ((parent.kind === 285 /* SyntaxKind.JsxAttribute */) || (parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -135551,10 +136246,10 @@ var ts; return parent.parent.parent; } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (parent && - parent.kind === 288 /* JsxExpression */ && - parent.parent && parent.parent.kind === 285 /* JsxAttribute */) { + parent.kind === 288 /* SyntaxKind.JsxExpression */ && + parent.parent && parent.parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -135562,7 +136257,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 287 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -135581,75 +136276,75 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 27 /* CommaToken */: - return containingNodeKind === 254 /* VariableDeclaration */ || + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 237 /* VariableStatement */ || - containingNodeKind === 260 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 237 /* SyntaxKind.VariableStatement */ || + containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 24 /* DotToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [.| - case 58 /* ColonToken */: - return containingNodeKind === 203 /* BindingElement */; // var {x :html| - case 22 /* OpenBracketToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [x| - case 20 /* OpenParenToken */: - return containingNodeKind === 292 /* CatchClause */ || + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [.| + case 58 /* SyntaxKind.ColonToken */: + return containingNodeKind === 203 /* SyntaxKind.BindingElement */; // var {x :html| + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [x| + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 292 /* SyntaxKind.CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 18 /* OpenBraceToken */: - return containingNodeKind === 260 /* EnumDeclaration */; // enum a { | - case 29 /* LessThanToken */: - return containingNodeKind === 257 /* ClassDeclaration */ || // class A< | - containingNodeKind === 226 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 259 /* TypeAliasDeclaration */ || // type List< | + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */; // enum a { | + case 29 /* SyntaxKind.LessThanToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ || // class A< | + containingNodeKind === 226 /* SyntaxKind.ClassExpression */ || // var C = class D< | + containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A< | + containingNodeKind === 259 /* SyntaxKind.TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 124 /* StaticKeyword */: - return containingNodeKind === 167 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 25 /* DotDotDotToken */: - return containingNodeKind === 164 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 202 /* ArrayBindingPattern */); // var [...z| - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - return containingNodeKind === 164 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 127 /* AsKeyword */: - return containingNodeKind === 270 /* ImportSpecifier */ || - containingNodeKind === 275 /* ExportSpecifier */ || - containingNodeKind === 268 /* NamespaceImport */; - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + return containingNodeKind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* SyntaxKind.DotDotDotToken */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ || + (!!parent.parent && parent.parent.kind === 202 /* SyntaxKind.ArrayBindingPattern */); // var [...z| + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* SyntaxKind.AsKeyword */: + return containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ || + containingNodeKind === 275 /* SyntaxKind.ExportSpecifier */ || + containingNodeKind === 268 /* SyntaxKind.NamespaceImport */; + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 79 /* Identifier */: - if (containingNodeKind === 270 /* ImportSpecifier */ && + case 79 /* SyntaxKind.Identifier */: + if (containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ && contextToken === parent.name && contextToken.text === "type") { // import { type | } return false; } break; - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 118 /* InterfaceKeyword */: - case 98 /* FunctionKeyword */: - case 113 /* VarKeyword */: - case 100 /* ImportKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 137 /* InferKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return true; - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: // import { type foo| } - return containingNodeKind !== 270 /* ImportSpecifier */; - case 41 /* AsteriskToken */: + return containingNodeKind !== 270 /* SyntaxKind.ImportSpecifier */; + case 41 /* SyntaxKind.AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword corresponding to class member completion keyword @@ -135670,21 +136365,21 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 126 /* AbstractKeyword */: - case 84 /* ClassKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 98 /* FunctionKeyword */: - case 118 /* InterfaceKeyword */: - case 119 /* LetKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 124 /* StaticKeyword */: - case 113 /* VarKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return true; - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } // If we are inside a class declaration, and `constructor` is totally not present, @@ -135693,7 +136388,7 @@ var ts; if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { return false; // Don't block completions. } - var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* PropertyDeclaration */); + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* SyntaxKind.PropertyDeclaration */); // If we are inside a class declaration and typing `constructor` after property declaration... if (ancestorPropertyDeclaraion && contextToken !== previousToken @@ -135704,7 +136399,7 @@ var ts; if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { return false; // Don't block completions. } - else if (contextToken.kind !== 63 /* EqualsToken */ + else if (contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ // Should not block: `class C { blah = c/**/ }` // But should block: `class C { blah = somewhat c/**/ }` and `class C { blah: SomeType c/**/ }` && (ts.isInitializedProperty(ancestorPropertyDeclaraion) @@ -135720,22 +136415,22 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isPreviousPropertyDeclarationTerminated(contextToken, position) { - return contextToken.kind !== 63 /* EqualsToken */ && - (contextToken.kind === 26 /* SemicolonToken */ + return contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ && + (contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 171 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 171 /* SyntaxKind.Constructor */; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8 /* NumericLiteral */) { + if (contextToken.kind === 8 /* SyntaxKind.NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -135753,13 +136448,13 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 296 /* PropertyAssignment */ && - m.kind !== 297 /* ShorthandPropertyAssignment */ && - m.kind !== 203 /* BindingElement */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */ && - m.kind !== 298 /* SpreadAssignment */) { + if (m.kind !== 296 /* SyntaxKind.PropertyAssignment */ && + m.kind !== 297 /* SyntaxKind.ShorthandPropertyAssignment */ && + m.kind !== 203 /* SyntaxKind.BindingElement */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */ && + m.kind !== 298 /* SyntaxKind.SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -135772,7 +136467,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 79 /* Identifier */) { + if (m.propertyName.kind === 79 /* SyntaxKind.Identifier */) { existingName = m.propertyName.escapedText; } } @@ -135806,7 +136501,7 @@ var ts; function setSortTextToOptionalMember() { symbols.forEach(function (m) { var _a; - if (m.flags & 16777216 /* Optional */) { + if (m.flags & 16777216 /* SymbolFlags.Optional */) { var symbolId = ts.getSymbolId(m); symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember; } @@ -135831,7 +136526,7 @@ var ts; var symbolId = ts.getSymbolId(symbol); var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var target = ts.getEmitScriptTarget(compilerOptions); - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */, + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (displayName) { var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority; @@ -135850,10 +136545,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 167 /* PropertyDeclaration */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */) { + if (m.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -135861,11 +136556,11 @@ var ts; continue; } // Dont filter member even if the name matches if it is declared private in the list - if (ts.hasEffectiveModifier(m, 8 /* Private */)) { + if (ts.hasEffectiveModifier(m, 8 /* ModifierFlags.Private */)) { continue; } // do not filter it out if the static presence doesnt match - if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { + if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* ModifierFlags.Static */)) { continue; } var existingName = ts.getPropertyNameForPropertyNameNode(m.name); @@ -135876,7 +136571,7 @@ var ts; return baseSymbols.filter(function (propertySymbol) { return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && - !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && + !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* ModifierFlags.Private */) && !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } @@ -135895,7 +136590,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 285 /* JsxAttribute */) { + if (attr.kind === 285 /* SyntaxKind.JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -135918,15 +136613,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 18 /* SyntaxKind.OpenBraceToken */: // const x = { | + case 27 /* SyntaxKind.CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -135949,12 +136644,12 @@ var ts; undefined; if (!moduleSymbol) return undefined; - var symbol = data.exportName === "export=" /* ExportEquals */ + var symbol = data.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); if (!symbol) return undefined; - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) }; } @@ -135963,27 +136658,27 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) + || symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { - case 3 /* MemberLike */: + case 3 /* CompletionKind.MemberLike */: return undefined; - case 0 /* ObjectPropertyDeclaration */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; - case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 2 /* CompletionKind.PropertyAccess */: + case 1 /* CompletionKind.Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 - return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; - case 5 /* None */: - case 4 /* String */: + return name.charCodeAt(0) === 32 /* CharacterCodes.space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; + case 5 /* CompletionKind.None */: + case 4 /* CompletionKind.String */: return validNameResult; default: ts.Debug.assertNever(kind); @@ -135993,11 +136688,11 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 81 /* FirstKeyword */; i <= 160 /* LastKeyword */; i++) { + for (var i = 81 /* SyntaxKind.FirstKeyword */; i <= 160 /* SyntaxKind.LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords }); } @@ -136006,7 +136701,7 @@ var ts; function getKeywordCompletions(keywordFilter, filterOutTsOnlyKeywords) { if (!filterOutTsOnlyKeywords) return getTypescriptKeywordCompletions(keywordFilter); - var index = keywordFilter + 8 /* Last */ + 1; + var index = keywordFilter + 8 /* KeywordCompletionFilters.Last */ + 1; return _keywordCompletions[index] || (_keywordCompletions[index] = getTypescriptKeywordCompletions(keywordFilter) .filter(function (entry) { return !isTypeScriptOnlyKeyword(ts.stringToToken(entry.name)); })); @@ -136015,30 +136710,30 @@ var ts; return _keywordCompletions[keywordFilter] || (_keywordCompletions[keywordFilter] = allKeywordsCompletions().filter(function (entry) { var kind = ts.stringToToken(entry.name); switch (keywordFilter) { - case 0 /* None */: + case 0 /* KeywordCompletionFilters.None */: return false; - case 1 /* All */: + case 1 /* KeywordCompletionFilters.All */: return isFunctionLikeBodyKeyword(kind) - || kind === 135 /* DeclareKeyword */ - || kind === 141 /* ModuleKeyword */ - || kind === 152 /* TypeKeyword */ - || kind === 142 /* NamespaceKeyword */ - || kind === 126 /* AbstractKeyword */ - || ts.isTypeKeyword(kind) && kind !== 153 /* UndefinedKeyword */; - case 5 /* FunctionLikeBodyKeywords */: + || kind === 135 /* SyntaxKind.DeclareKeyword */ + || kind === 141 /* SyntaxKind.ModuleKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ + || kind === 142 /* SyntaxKind.NamespaceKeyword */ + || kind === 126 /* SyntaxKind.AbstractKeyword */ + || ts.isTypeKeyword(kind) && kind !== 153 /* SyntaxKind.UndefinedKeyword */; + case 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); - case 2 /* ClassElementKeywords */: + case 2 /* KeywordCompletionFilters.ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); - case 3 /* InterfaceElementKeywords */: + case 3 /* KeywordCompletionFilters.InterfaceElementKeywords */: return isInterfaceOrTypeLiteralCompletionKeyword(kind); - case 4 /* ConstructorParameterKeywords */: + case 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); - case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; - case 7 /* TypeKeywords */: + case 6 /* KeywordCompletionFilters.TypeAssertionKeywords */: + return ts.isTypeKeyword(kind) || kind === 85 /* SyntaxKind.ConstKeyword */; + case 7 /* KeywordCompletionFilters.TypeKeywords */: return ts.isTypeKeyword(kind); - case 8 /* TypeKeyword */: - return kind === 152 /* TypeKeyword */; + case 8 /* KeywordCompletionFilters.TypeKeyword */: + return kind === 152 /* SyntaxKind.TypeKeyword */; default: return ts.Debug.assertNever(keywordFilter); } @@ -136046,64 +136741,64 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 130 /* AnyKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 157 /* GlobalKeyword */: - case 117 /* ImplementsKeyword */: - case 137 /* InferKeyword */: - case 118 /* InterfaceKeyword */: - case 139 /* IsKeyword */: - case 140 /* KeyOfKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 143 /* NeverKeyword */: - case 147 /* NumberKeyword */: - case 148 /* ObjectKeyword */: - case 159 /* OverrideKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: - case 150 /* StringKeyword */: - case 151 /* SymbolKeyword */: - case 152 /* TypeKeyword */: - case 154 /* UniqueKeyword */: - case 155 /* UnknownKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 117 /* SyntaxKind.ImplementsKeyword */: + case 137 /* SyntaxKind.InferKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 139 /* SyntaxKind.IsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 145 /* ReadonlyKeyword */; + return kind === 145 /* SyntaxKind.ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 134 /* ConstructorKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 131 /* AsyncKeyword */ - || kind === 132 /* AwaitKeyword */ - || kind === 127 /* AsKeyword */ - || kind === 152 /* TypeKeyword */ + return kind === 131 /* SyntaxKind.AsyncKeyword */ + || kind === 132 /* SyntaxKind.AwaitKeyword */ + || kind === 127 /* SyntaxKind.AsKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { - return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; + return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* SyntaxKind.Unknown */ : node.kind; } function getContextualKeywords(contextToken, position) { var entries = []; @@ -136124,9 +136819,9 @@ var ts; && contextToken === parent.moduleSpecifier && tokenLine === currentLine) { entries.push({ - name: ts.tokenToString(129 /* AssertKeyword */), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + name: ts.tokenToString(129 /* SyntaxKind.AssertKeyword */), + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }); } @@ -136142,7 +136837,7 @@ var ts; } function getPropertiesForObjectExpression(contextualType, completionsType, obj, checker) { var hasCompletionsType = completionsType && completionsType !== contextualType; - var type = hasCompletionsType && !(completionsType.flags & 3 /* AnyOrUnknown */) + var type = hasCompletionsType && !(completionsType.flags & 3 /* TypeFlags.AnyOrUnknown */) ? checker.getUnionType([contextualType, completionsType]) : contextualType; var properties = getApparentProperties(type, obj, checker); @@ -136164,7 +136859,7 @@ var ts; if (!type.isUnion()) return type.getApparentProperties(); return checker.getAllPossiblePropertiesOfTypes(ts.filter(type.types, function (memberType) { - return !(memberType.flags & 131068 /* Primitive */ + return !(memberType.flags & 131068 /* TypeFlags.Primitive */ || checker.isArrayLikeType(memberType) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, node) || ts.typeHasCallOrConstructSignatures(memberType, checker) @@ -136172,7 +136867,7 @@ var ts; })); } function containsNonPublicProperties(props) { - return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */); }); + return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */); }); } /** * Gets all properties on a type, but if that type is a union of several types, @@ -136190,15 +136885,19 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile)) { return cls; } break; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { + var originalKeywordKind = location.originalKeywordKind; + if (originalKeywordKind && ts.isKeyword(originalKeywordKind)) { + return undefined; + } // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -136212,22 +136911,22 @@ var ts; if (!contextToken) return undefined; // class C { blah; constructor/**/ } and so on - if (location.kind === 134 /* ConstructorKeyword */ + if (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ // class C { blah \n constructor/**/ } || (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) { return ts.findAncestor(contextToken, ts.isClassLike); } switch (contextToken.kind) { - case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* SyntaxKind.EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; - case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SyntaxKind.SemicolonToken */: // class c {getValue(): number; | } + case 19 /* SyntaxKind.CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* SyntaxKind.OpenBraceToken */: // class c { | + case 27 /* SyntaxKind.CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -136238,7 +136937,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -136247,15 +136946,15 @@ var ts; return undefined; var parent = node.parent; switch (node.kind) { - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.isTypeLiteralNode(parent)) { return parent; } break; - case 26 /* SemicolonToken */: - case 27 /* CommaToken */: - case 79 /* Identifier */: - if (parent.kind === 166 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + case 26 /* SyntaxKind.SemicolonToken */: + case 27 /* SyntaxKind.CommaToken */: + case 79 /* SyntaxKind.Identifier */: + if (parent.kind === 166 /* SyntaxKind.PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { return parent.parent; } break; @@ -136272,11 +136971,11 @@ var ts; if (!t) return undefined; switch (node.kind) { - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); - case 188 /* IntersectionType */: - case 182 /* TypeLiteral */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 187 /* SyntaxKind.UnionType */: return t; } } @@ -136298,13 +136997,13 @@ var ts; return !!contextToken && ts.isPrivateIdentifier(contextToken) && !!ts.getContainingClass(contextToken); case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* SyntaxKind.LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SyntaxKind.SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); case " ": - return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SourceFile */; + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SyntaxKind.SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -136317,22 +137016,22 @@ var ts; function isProbablyGlobalType(type, sourceFile, checker) { // The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in // lib.webworker.d.ts, so checking against `self` is also a check against `window` when it exists. - var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (selfSymbol && checker.getTypeOfSymbolAtLocation(selfSymbol, sourceFile) === type) { return true; } - var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalSymbol && checker.getTypeOfSymbolAtLocation(globalSymbol, sourceFile) === type) { return true; } - var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalThisSymbol && checker.getTypeOfSymbolAtLocation(globalThisSymbol, sourceFile) === type) { return true; } return false; } function isStaticProperty(symbol) { - return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); + return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* ModifierFlags.Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); } function tryGetObjectLiteralContextualType(node, typeChecker) { var type = typeChecker.getContextualType(node); @@ -136340,7 +137039,7 @@ var ts; return type; } var parent = ts.walkUpParenthesizedExpressions(node.parent); - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && node === parent.left) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && node === parent.left) { // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(parent); } @@ -136357,7 +137056,7 @@ var ts; return { isKeywordOnlyCompletion: isKeywordOnlyCompletion, keywordCompletion: keywordCompletion, - isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* TypeKeyword */), + isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* SyntaxKind.TypeKeyword */), replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined @@ -136365,23 +137064,23 @@ var ts; function getCandidate() { var parent = contextToken.parent; if (ts.isImportEqualsDeclaration(parent)) { - keywordCompletion = contextToken.kind === 152 /* TypeKeyword */ ? undefined : 152 /* TypeKeyword */; + keywordCompletion = contextToken.kind === 152 /* SyntaxKind.TypeKeyword */ ? undefined : 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; } if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) { return parent; } if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { - if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* OpenBraceToken */ || - contextToken.kind === 100 /* ImportKeyword */ || - contextToken.kind === 27 /* CommaToken */)) { - keywordCompletion = 152 /* TypeKeyword */; + if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || + contextToken.kind === 100 /* SyntaxKind.ImportKeyword */ || + contextToken.kind === 27 /* SyntaxKind.CommaToken */)) { + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; } if (canCompleteFromNamedBindings(parent)) { // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` - if (contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */) { + if (contextToken.kind === 19 /* SyntaxKind.CloseBraceToken */ || contextToken.kind === 79 /* SyntaxKind.Identifier */) { isKeywordOnlyCompletion = true; - keywordCompletion = 156 /* FromKeyword */; + keywordCompletion = 156 /* SyntaxKind.FromKeyword */; } else { return parent.parent.parent; @@ -136391,12 +137090,12 @@ var ts; } if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { // A lone import keyword with nothing following it does not parse as a statement at all - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return contextToken; } if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { // `import s| from` - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; } return undefined; @@ -136436,8 +137135,8 @@ var ts; // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings. return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker)); function nonAliasCanBeReferencedAtTypeLocation(symbol) { - return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) || - !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && + return !!(symbol.flags & 788968 /* SymbolFlags.Type */) || checker.isUnknownSymbol(symbol) || + !!(symbol.flags & 1536 /* SymbolFlags.Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); } } @@ -136474,8 +137173,8 @@ var ts; var testChar = lowercaseCharacters.charCodeAt(characterIndex); if (strChar === testChar || strChar === toUpperCharCode(testChar)) { matchedFirstCharacter || (matchedFirstCharacter = prevChar === undefined || // Beginning of word - 97 /* a */ <= prevChar && prevChar <= 122 /* z */ && 65 /* A */ <= strChar && strChar <= 90 /* Z */ || // camelCase transition - prevChar === 95 /* _ */ && strChar !== 95 /* _ */); // snake_case transition + 97 /* CharacterCodes.a */ <= prevChar && prevChar <= 122 /* CharacterCodes.z */ && 65 /* CharacterCodes.A */ <= strChar && strChar <= 90 /* CharacterCodes.Z */ || // camelCase transition + prevChar === 95 /* CharacterCodes._ */ && strChar !== 95 /* CharacterCodes._ */); // snake_case transition if (matchedFirstCharacter) { characterIndex++; } @@ -136489,7 +137188,7 @@ var ts; return false; } function toUpperCharCode(charCode) { - if (97 /* a */ <= charCode && charCode <= 122 /* z */) { + if (97 /* CharacterCodes.a */ <= charCode && charCode <= 122 /* CharacterCodes.z */) { return charCode - 32; } return charCode; @@ -136519,7 +137218,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" /* none */ + kind: "none" /* HighlightSpanKind.none */ }; } function getSemanticDocumentHighlights(position, node, program, cancellationToken, sourceFilesToSearch) { @@ -136549,46 +137248,46 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 99 /* IfKeyword */: - case 91 /* ElseKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 105 /* ReturnKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 111 /* TryKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: - var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* SyntaxKind.TryKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: + var tryStatement = node.kind === 83 /* SyntaxKind.CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 82 /* CaseKeyword */: - case 88 /* DefaultKeyword */: { + case 82 /* SyntaxKind.CaseKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 81 /* BreakKeyword */: - case 86 /* ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 97 /* ForKeyword */: - case 115 /* WhileKeyword */: - case 90 /* DoKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 134 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* ConstructorKeyword */]); - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [136 /* GetKeyword */, 149 /* SetKeyword */]); - case 132 /* AwaitKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* SyntaxKind.ConstructorKeyword */]); + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */]); + case 132 /* SyntaxKind.AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 125 /* YieldKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return undefined; default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -136631,7 +137330,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -136663,16 +137362,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 249 /* SwitchStatement */: - if (statement.kind === 245 /* ContinueStatement */) { + case 249 /* SyntaxKind.SwitchStatement */: + if (statement.kind === 245 /* SyntaxKind.ContinueStatement */) { return false; } // falls through - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -136688,41 +137387,41 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { + if (modifierFlag & 128 /* ModifierFlags.Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members, true), [declaration], false); } else { return container.statements; } - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters, true), (ts.isClassLike(container.parent) ? container.parent.members : []), true); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { + if (modifierFlag & (28 /* ModifierFlags.AccessibilityModifier */ | 64 /* ModifierFlags.Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { return __spreadArray(__spreadArray([], nodes, true), constructor.parameters, true); } } - else if (modifierFlag & 128 /* Abstract */) { + else if (modifierFlag & 128 /* ModifierFlags.Abstract */) { return __spreadArray(__spreadArray([], nodes, true), [container], false); } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -136741,12 +137440,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* SyntaxKind.ForKeyword */, 115 /* SyntaxKind.WhileKeyword */, 90 /* SyntaxKind.DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 240 /* DoStatement */) { + if (loopNode.kind === 240 /* SyntaxKind.DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* SyntaxKind.WhileKeyword */)) { break; } } @@ -136754,7 +137453,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */, 86 /* SyntaxKind.ContinueKeyword */); } }); return keywords; @@ -136763,13 +137462,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -136777,13 +137476,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SyntaxKind.SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* SyntaxKind.CaseKeyword */, 88 /* SyntaxKind.DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */); } }); }); @@ -136791,13 +137490,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* SyntaxKind.TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* SyntaxKind.CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* SyntaxKind.FinallyKeyword */); } return keywords; } @@ -136808,13 +137507,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); } return keywords; @@ -136826,11 +137525,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); return keywords; } @@ -136842,13 +137541,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 131 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 131 /* SyntaxKind.AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 132 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 132 /* SyntaxKind.AwaitKeyword */); } }); }); @@ -136863,7 +137562,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* SyntaxKind.YieldKeyword */); } }); }); @@ -136882,7 +137581,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* SyntaxKind.ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -136897,7 +137596,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ }); i++; // skip the next keyword continue; @@ -136917,10 +137616,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 99 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* SyntaxKind.IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* SyntaxKind.ElseKeyword */)) { break; } } @@ -136986,60 +137685,64 @@ var ts; } return settingsOrHost; } - function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings)); - return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); + return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions); } - function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { - return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind); + function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { + return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind, languageVersionOrOptions); } - function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings)); - return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); + return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions); } - function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { - return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); + function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { + return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind, languageVersionOrOptions); } function getDocumentRegistryEntry(bucketEntry, scriptKind) { var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided")); - ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry); + ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:".concat(scriptKind, " and sourceFile.scriptKind: ").concat(entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind, ", !entry: ").concat(!entry)); return entry; } - function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) { + function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind, languageVersionOrOptions) { var _a, _b, _c, _d; scriptKind = ts.ensureScriptKind(fileName, scriptKind); var compilationSettings = getCompilationSettings(compilationSettingsOrHost); var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost; - var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings); - var sourceFileOptions = { - languageVersion: scriptTarget, - impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), - setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings) - }; + var scriptTarget = scriptKind === 6 /* ScriptKind.JSON */ ? 100 /* ScriptTarget.JSON */ : ts.getEmitScriptTarget(compilationSettings); + var sourceFileOptions = typeof languageVersionOrOptions === "object" ? + languageVersionOrOptions : + { + languageVersion: scriptTarget, + impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), + setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings) + }; + sourceFileOptions.languageVersion = scriptTarget; var oldBucketCount = buckets.size; - var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); + var keyWithMode = getDocumentRegistryBucketKeyWithMode(key, sourceFileOptions.impliedNodeFormat); + var bucket = ts.getOrUpdate(buckets, keyWithMode, function () { return new ts.Map(); }); if (ts.tracing) { if (buckets.size > oldBucketCount) { // It is interesting, but not definitively problematic if a build requires multiple document registry buckets - // perhaps they are for two projects that don't have any overlap. // Bonus: these events can help us interpret the more interesting event below. - ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: keyWithMode }); } // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations. // If this occurs unexpectedly, the fix is likely to synchronize the project settings. // Skip .d.ts files to reduce noise (should also cover most of node_modules). var otherBucketKey = !ts.isDeclarationFileName(path) && - ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; }); + ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== keyWithMode && bucket.has(path) && bucketKey; }); if (otherBucketKey) { - ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: keyWithMode }); } } var bucketEntry = bucket.get(path); var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); if (!entry && externalCache) { - var sourceFile = externalCache.getDocument(key, path); + var sourceFile = externalCache.getDocument(keyWithMode, path); if (sourceFile) { ts.Debug.assert(acquiring); entry = { @@ -137053,7 +137756,7 @@ var ts; // Have never seen this file with these settings. Create a new source file for it. var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind); if (externalCache) { - externalCache.setDocument(key, path, sourceFile); + externalCache.setDocument(keyWithMode, path, sourceFile); } entry = { sourceFile: sourceFile, @@ -137068,7 +137771,7 @@ var ts; if (entry.sourceFile.version !== version) { entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217 if (externalCache) { - externalCache.setDocument(key, path, entry.sourceFile); + externalCache.setDocument(keyWithMode, path, entry.sourceFile); } } // If we're acquiring, then this is the first time this LS is asking for this document. @@ -137097,13 +137800,13 @@ var ts; } } } - function releaseDocument(fileName, compilationSettings, scriptKind) { + function releaseDocument(fileName, compilationSettings, scriptKind, impliedNodeFormat) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(compilationSettings); - return releaseDocumentWithKey(path, key, scriptKind); + return releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat); } - function releaseDocumentWithKey(path, key, scriptKind) { - var bucket = ts.Debug.checkDefined(buckets.get(key)); + function releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat) { + var bucket = ts.Debug.checkDefined(buckets.get(getDocumentRegistryBucketKeyWithMode(key, impliedNodeFormat))); var bucketEntry = bucket.get(path); var entry = getDocumentRegistryEntry(bucketEntry, scriptKind); entry.languageServiceRefCount--; @@ -137147,18 +137850,21 @@ var ts; return "" + value; } if (ts.isArray(value)) { - return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]"; + return "[".concat((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(","), "]"); } var str = "{"; for (var key in value) { if (ts.hasProperty(value, key)) { - str += key + ": " + compilerOptionValueToString(value[key]); + str += "".concat(key, ": ").concat(compilerOptionValueToString(value[key])); } } return str + "}"; } function getKeyForCompilationSettings(settings) { - return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined); + return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|".concat(settings.pathsBasePath) : undefined); + } + function getDocumentRegistryBucketKeyWithMode(key, mode) { + return (mode ? "".concat(key, "|").concat(mode) : key); } })(ts || (ts = {})); /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ @@ -137225,43 +137931,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 254 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { var name = parent.name; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { directImports.push(name); break; } } } break; - case 79 /* Identifier */: // for 'const x = require("y"); + case 79 /* SyntaxKind.Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 265 /* ImportEqualsDeclaration */: - handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* ModifierFlags.Export */), /*alreadyAddedDirect*/ false); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); } - else if (direct.exportClause.kind === 274 /* NamespaceExport */) { + else if (direct.exportClause.kind === 274 /* SyntaxKind.NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -137270,7 +137976,7 @@ var ts; directImports.push(direct); } break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -137296,14 +138002,14 @@ var ts; }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { - if (exportKind === 2 /* ExportEquals */) { + if (exportKind === 2 /* ExportKind.ExportEquals */) { // This is a direct import, not import-as-namespace. if (!alreadyAddedDirect) directImports.push(importDeclaration); } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 305 /* SourceFile */ || sourceFileLike.kind === 261 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ || sourceFileLike.kind === 261 /* SyntaxKind.ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -137325,7 +138031,7 @@ var ts; var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); if (!moduleSymbol) return; - ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */)); var directImports = getDirectImports(moduleSymbol); if (directImports) { for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { @@ -137359,33 +138065,33 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 265 /* ImportEqualsDeclaration */) { + if (decl.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 79 /* Identifier */) { + if (decl.kind === 79 /* SyntaxKind.Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 200 /* ImportType */) { + if (decl.kind === 200 /* SyntaxKind.ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(firstIdentifier); } } - else if (exportKind === 2 /* ExportEquals */) { + else if (exportKind === 2 /* ExportKind.ExportEquals */) { singleReferences.push(decl.argument.literal); } return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* SyntaxKind.StringLiteral */) { return; } - if (decl.kind === 272 /* ExportDeclaration */) { + if (decl.kind === 272 /* SyntaxKind.ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -137394,12 +138100,12 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. - if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { + if (exportKind === 0 /* ExportKind.Named */ || exportKind === 1 /* ExportKind.Default */) { searchForNamedImport(namedBindings); } break; @@ -137410,7 +138116,7 @@ var ts; // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals. // If a default import has the same name as the default export, allow to rename it. // Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that. - if (name && (exportKind === 1 /* Default */ || exportKind === 2 /* ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { + if (name && (exportKind === 1 /* ExportKind.Default */ || exportKind === 2 /* ExportKind.ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { var defaultImportAlias = checker.getSymbolAtLocation(name); addSearch(name, defaultImportAlias); } @@ -137422,7 +138128,7 @@ var ts; */ function handleNamespaceImportLike(importName) { // Don't rename an import that already has a different name than the export. - if (exportKind === 2 /* ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } @@ -137447,7 +138153,7 @@ var ts; } } else { - var localSymbol = element.kind === 275 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 275 /* SyntaxKind.ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -137456,7 +138162,7 @@ var ts; } function isNameMatch(name) { // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports - return name === exportSymbol.escapedName || exportKind !== 0 /* Named */ && name === "default" /* Default */; + return name === exportSymbol.escapedName || exportKind !== 0 /* ExportKind.Named */ && name === "default" /* InternalSymbolName.Default */; } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ @@ -137476,7 +138182,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SyntaxKind.SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -137524,7 +138230,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 305 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -137539,15 +138245,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -137572,7 +138278,7 @@ var ts; var parent = node.parent; var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 206 /* PropertyAccessExpression */) { + if (parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) @@ -137585,21 +138291,21 @@ var ts; } else { var exportNode = getExportNode(parent, node); - if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* Export */)) { + if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* ModifierFlags.Export */)) { if (ts.isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) { // We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement. if (comingFromExport) { return undefined; } var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); - return { kind: 0 /* Import */, symbol: lhsSymbol }; + return { kind: 0 /* ImportExport.Import */, symbol: lhsSymbol }; } else { return exportInfo(symbol, getExportKindForDeclaration(exportNode)); } } else if (ts.isNamespaceExport(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } // If we are in `export = a;` or `export default a;`, `parent` is the export assignment. else if (ts.isExportAssignment(parent)) { @@ -137617,24 +138323,24 @@ var ts; return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. if (!ex.symbol.parent) return undefined; - var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; + var exportKind = ex.isExportEquals ? 2 /* ExportKind.ExportEquals */ : 1 /* ExportKind.Default */; + return { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; switch (ts.getAssignmentDeclarationKind(node)) { - case 1 /* ExportsProperty */: - kind = 0 /* Named */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + kind = 0 /* ExportKind.Named */; break; - case 2 /* ModuleExports */: - kind = 2 /* ExportEquals */; + case 2 /* AssignmentDeclarationKind.ModuleExports */: + kind = 2 /* ExportKind.ExportEquals */; break; default: return undefined; @@ -137661,22 +138367,22 @@ var ts; // If `importedName` is undefined, do continue searching as the export is anonymous. // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) var importedName = ts.symbolEscapedNameNoDefault(importedSymbol); - if (importedName === undefined || importedName === "default" /* Default */ || importedName === symbol.escapedName) { - return { kind: 0 /* Import */, symbol: importedSymbol }; + if (importedName === undefined || importedName === "default" /* InternalSymbolName.Default */ || importedName === symbol.escapedName) { + return { kind: 0 /* ImportExport.Import */, symbol: importedSymbol }; } } function exportInfo(symbol, kind) { var exportInfo = getExportInfo(symbol, kind, checker); - return exportInfo && { kind: 1 /* Export */, symbol: symbol, exportInfo: exportInfo }; + return exportInfo && { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: exportInfo }; } // Not meant for use with export specifiers or export assignment. function getExportKindForDeclaration(node) { - return ts.hasSyntacticModifier(node, 512 /* Default */) ? 1 /* Default */ : 0 /* Named */; + return ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; } } FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; function getExportEqualsLocalSymbol(importedSymbol, checker) { - if (importedSymbol.flags & 2097152 /* Alias */) { + if (importedSymbol.flags & 2097152 /* SymbolFlags.Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); @@ -137706,16 +138412,16 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent); default: return false; @@ -137745,7 +138451,7 @@ var ts; } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) - && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) { + && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) { return checker.getExportSpecifierLocalTargetSymbol(declaration.name); } } @@ -137756,21 +138462,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 305 /* SourceFile */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 262 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 262 /* SyntaxKind.ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 277 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* SyntaxKind.StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -137797,7 +138503,7 @@ var ts; EntryKind[EntryKind["SearchedPropertyFoundLocal"] = 4] = "SearchedPropertyFoundLocal"; })(EntryKind = FindAllReferences.EntryKind || (FindAllReferences.EntryKind = {})); function nodeEntry(node, kind) { - if (kind === void 0) { kind = 1 /* Node */; } + if (kind === void 0) { kind = 1 /* EntryKind.Node */; } return { kind: kind, node: node.name || node, @@ -137825,7 +138531,7 @@ var ts; node.parent.parent.left === node.parent ? node.parent.parent : undefined; - if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* None */) { + if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* AssignmentDeclarationKind.None */) { return getContextNode(binaryExpression); } } @@ -137864,7 +138570,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ModifierFlags.ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -137873,7 +138579,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -137881,28 +138587,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextNode(node.parent.parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 267 /* ImportClause */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return { start: node.initializer, end: node.expression }; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -137943,7 +138649,7 @@ var ts; })(FindReferencesUse = FindAllReferences.FindReferencesUse || (FindAllReferences.FindReferencesUse = {})); function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); - var options = { use: 1 /* References */ }; + var options = { use: 1 /* FindReferencesUse.References */ }; var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options); var checker = program.getTypeChecker(); // Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition @@ -137960,33 +138666,33 @@ var ts; } FindAllReferences.findReferencedSymbols = findReferencedSymbols; function isDefinitionForReference(node) { - return node.kind === 88 /* DefaultKeyword */ + return node.kind === 88 /* SyntaxKind.DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 206 /* PropertyAccessExpression */ - || node.parent.kind === 203 /* BindingElement */ - || node.parent.kind === 207 /* ElementAccessExpression */ - || node.kind === 106 /* SuperKeyword */) { + if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || node.parent.kind === 203 /* SyntaxKind.BindingElement */ + || node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries, true); } - else { - var queue = entries && __spreadArray([], entries, true); + else if (entries) { + var queue = ts.createQueue(entries); var seenNodes = new ts.Map(); - while (queue && queue.length) { - var entry = queue.shift(); + while (!queue.isEmpty()) { + var entry = queue.dequeue(); if (!ts.addToSeen(seenNodes, ts.getNodeId(entry.node))) { continue; } referenceEntries = ts.append(referenceEntries, entry); var entries_1 = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, entry.node, entry.node.pos); if (entries_1) { - queue.push.apply(queue, entries_1); + queue.enqueue.apply(queue, entries_1); } } } @@ -137995,18 +138701,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var result_2 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); }); return result_2; } - else if (node.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -138014,7 +138720,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* References */ }); + return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* FindReferencesUse.References */ }); } } function findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, convertEntry) { @@ -138033,7 +138739,7 @@ var ts; function definitionToReferencedSymbolDefinitionInfo(def, checker, originalNode) { var info = (function () { switch (def.type) { - case 0 /* Symbol */: { + case 0 /* DefinitionKind.Symbol */: { var symbol = def.symbol; var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind; var name_1 = displayParts_1.map(function (p) { return p.text; }).join(""); @@ -138041,32 +138747,32 @@ var ts; var node = declaration ? (ts.getNameOfDeclaration(declaration) || declaration) : originalNode; return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_1, kind: kind_1, displayParts: displayParts_1, context: getContextNode(declaration) }); } - case 1 /* Label */: { + case 1 /* DefinitionKind.Label */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* ScriptElementKind.label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); } - case 2 /* Keyword */: { + case 2 /* DefinitionKind.Keyword */: { var node = def.node; var name_2 = ts.tokenToString(node.kind); - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* keyword */, displayParts: [{ text: name_2, kind: "keyword" /* keyword */ }] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* ScriptElementKind.keyword */, displayParts: [{ text: name_2, kind: "keyword" /* ScriptElementKind.keyword */ }] }); } - case 3 /* This */: { + case 3 /* DefinitionKind.This */: { var node = def.node; var symbol = checker.getSymbolAtLocation(node); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node).displayParts || [ts.textPart("this")]; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* variableElement */, displayParts: displayParts_2 }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* ScriptElementKind.variableElement */, displayParts: displayParts_2 }); } - case 4 /* String */: { + case 4 /* DefinitionKind.String */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* ScriptElementKind.variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); } - case 5 /* TripleSlashReference */: { + case 5 /* DefinitionKind.TripleSlashReference */: { return { textSpan: ts.createTextSpanFromRange(def.reference), sourceFile: def.file, name: def.reference.fileName, - kind: "string" /* string */, - displayParts: [ts.displayPart("\"" + def.reference.fileName + "\"", ts.SymbolDisplayPartKind.stringLiteral)] + kind: "string" /* ScriptElementKind.string */, + displayParts: [ts.displayPart("\"".concat(def.reference.fileName, "\""), ts.SymbolDisplayPartKind.stringLiteral)] }; } default: @@ -138074,7 +138780,7 @@ var ts; } })(); var sourceFile = info.sourceFile, textSpan = info.textSpan, name = info.name, kind = info.kind, displayParts = info.displayParts, context = info.context; - return __assign({ containerKind: "" /* unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); + return __assign({ containerKind: "" /* ScriptElementKind.unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); } function getFileAndTextSpanFromNode(node) { var sourceFile = node.getSourceFile(); @@ -138097,19 +138803,19 @@ var ts; var referenceEntry = toReferenceEntry(entry); if (!symbol) return referenceEntry; - return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) }); + return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* EntryKind.Span */ && isDeclarationOfSymbol(entry.node, symbol) }); } function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return __assign(__assign({}, documentSpan), { isWriteAccess: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }); } FindAllReferences.toReferenceEntry = toReferenceEntry; function entryToDocumentSpan(entry) { - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { textSpan: entry.textSpan, fileName: entry.fileName }; } else { @@ -138119,7 +138825,7 @@ var ts; } } function getPrefixAndSuffixText(entry, originalNode, checker) { - if (entry.kind !== 0 /* Span */ && ts.isIdentifier(originalNode)) { + if (entry.kind !== 0 /* EntryKind.Span */ && ts.isIdentifier(originalNode)) { var node = entry.node, kind = entry.kind; var parent = node.parent; var name = originalNode.text; @@ -138127,10 +138833,10 @@ var ts; if (isShorthandAssignment || (ts.isObjectBindingElementWithoutPropertyName(parent) && parent.name === node && parent.dotDotDotToken === undefined)) { var prefixColon = { prefixText: name + ": " }; var suffixColon = { suffixText: ": " + name }; - if (kind === 3 /* SearchedLocalFoundProperty */) { + if (kind === 3 /* EntryKind.SearchedLocalFoundProperty */) { return prefixColon; } - if (kind === 4 /* SearchedPropertyFoundLocal */) { + if (kind === 4 /* EntryKind.SearchedPropertyFoundLocal */) { return suffixColon; } // In `const o = { x }; o.x`, symbolAtLocation at `x` in `{ x }` is the property symbol. @@ -138164,12 +138870,12 @@ var ts; } function toImplementationLocation(entry, checker) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind !== 0 /* Span */) { + if (entry.kind !== 0 /* EntryKind.Span */) { var node = entry.node; return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* ScriptElementKind.unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -138177,16 +138883,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return { - kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "interface" /* ScriptElementKind.interfaceElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } - else if (node.kind === 226 /* ClassExpression */) { + else if (node.kind === 226 /* SyntaxKind.ClassExpression */) { return { - kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "local class" /* ScriptElementKind.localClassElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } else { @@ -138195,17 +138901,17 @@ var ts; } function toHighlightSpan(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { fileName: documentSpan.fileName, span: { textSpan: documentSpan.textSpan, - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ } }; } var writeAccess = isWriteAccessForReference(entry.node); - var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, isInString: entry.kind === 2 /* StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); + var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* HighlightSpanKind.writtenReference */ : "reference" /* HighlightSpanKind.reference */, isInString: entry.kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); return { fileName: documentSpan.fileName, span: span }; } FindAllReferences.toHighlightSpan = toHighlightSpan; @@ -138220,14 +138926,14 @@ var ts; return ts.createTextSpanFromBounds(start, end); } function getTextSpanOfEntry(entry) { - return entry.kind === 0 /* Span */ ? entry.textSpan : + return entry.kind === 0 /* EntryKind.Span */ ? entry.textSpan : getTextSpan(entry.node, entry.node.getSourceFile()); } FindAllReferences.getTextSpanOfEntry = getTextSpanOfEntry; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* SyntaxKind.DefaultKeyword */ || ts.isWriteAccess(node); } /** Whether a reference, `node`, is a definition of the `target` symbol */ function isDeclarationOfSymbol(node, target) { @@ -138235,9 +138941,9 @@ var ts; if (!target) return false; var source = ts.getDeclarationFromName(node) || - (node.kind === 88 /* DefaultKeyword */ ? node.parent + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ ? node.parent : ts.isLiteralComputedPropertyDeclarationName(node) ? node.parent.parent - : node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent + : node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent : undefined); var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined; return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; }))); @@ -138249,50 +138955,50 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 16777216 /* Ambient */)) + if (!!(decl.flags & 16777216 /* NodeFlags.Ambient */)) return true; switch (decl.kind) { - case 221 /* BinaryExpression */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 88 /* DefaultKeyword */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 275 /* ExportSpecifier */: - case 267 /* ImportClause */: // default import - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 258 /* InterfaceDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 285 /* JsxAttribute */: - case 261 /* ModuleDeclaration */: - case 264 /* NamespaceExportDeclaration */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - case 164 /* Parameter */: - case 297 /* ShorthandPropertyAssignment */: - case 259 /* TypeAliasDeclaration */: - case 163 /* TypeParameter */: + case 221 /* SyntaxKind.BinaryExpression */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: // default import + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 285 /* SyntaxKind.JsxAttribute */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + case 164 /* SyntaxKind.Parameter */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return !!decl.body; - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 168 /* MethodSignature */: - case 166 /* PropertySignature */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 168 /* SyntaxKind.MethodSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -138321,7 +139027,7 @@ var ts; return undefined; } return [{ - definition: { type: 5 /* TripleSlashReference */, reference: resolvedRef.reference, file: node }, + definition: { type: 5 /* DefinitionKind.TripleSlashReference */, reference: resolvedRef.reference, file: node }, references: getReferencesForNonModule(resolvedRef.file, fileIncludeReasons, program) || ts.emptyArray }]; } @@ -138343,7 +139049,7 @@ var ts; var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { - return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; + return [{ definition: { type: 4 /* DefinitionKind.String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; } // Fall through to string literal references. This is not very likely to return // anything useful, but I guess it's better than nothing, and there's an existing @@ -138353,11 +139059,11 @@ var ts; } return undefined; } - if (symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); } var moduleReferences = getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet); - if (moduleReferences && !(symbol.flags & 33554432 /* Transient */)) { + if (moduleReferences && !(symbol.flags & 33554432 /* SymbolFlags.Transient */)) { return moduleReferences; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(node, symbol, checker); @@ -138368,10 +139074,10 @@ var ts; } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function getAdjustedNode(node, options) { - if (options.use === 1 /* References */) { + if (options.use === 1 /* FindReferencesUse.References */) { node = ts.getAdjustedReferenceLocation(node); } - else if (options.use === 2 /* Rename */) { + else if (options.use === 2 /* FindReferencesUse.Rename */) { node = ts.getAdjustedRenameLocation(node); } return node; @@ -138399,7 +139105,7 @@ var ts; var location = ts.getReferencedFileLocation(program.getSourceFileByPath, ref); if (ts.isReferenceFileLocation(location)) { entries = ts.append(entries, { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: referencingFile.fileName, textSpan: ts.createTextSpanFromRange(location) }); @@ -138419,10 +139125,10 @@ var ts; return undefined; } function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet) { - var moduleSourceFile = (symbol.flags & 1536 /* Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); + var moduleSourceFile = (symbol.flags & 1536 /* SymbolFlags.Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; - var exportEquals = symbol.exports.get("export=" /* ExportEquals */); + var exportEquals = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. var moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) @@ -138449,14 +139155,14 @@ var ts; result = references; continue; } - var _loop_4 = function (entry) { - if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { + var _loop_3 = function (entry) { + if (!entry.definition || entry.definition.type !== 0 /* DefinitionKind.Symbol */) { result.push(entry); return "continue"; } var symbol = entry.definition.symbol; var refIndex = ts.findIndex(result, function (ref) { return !!ref.definition && - ref.definition.type === 0 /* Symbol */ && + ref.definition.type === 0 /* DefinitionKind.Symbol */ && ref.definition.symbol === symbol; }); if (refIndex === -1) { result.push(entry); @@ -138481,13 +139187,13 @@ var ts; }; for (var _b = 0, references_2 = references; _b < references_2.length; _b++) { var entry = references_2[_b]; - _loop_4(entry); + _loop_3(entry); } } return result; } function getSourceFileIndexOfEntry(program, entry) { - var sourceFile = entry.kind === 0 /* Span */ ? + var sourceFile = entry.kind === 0 /* EntryKind.Span */ ? program.getSourceFile(entry.fileName) : entry.node.getSourceFile(); return program.getSourceFiles().indexOf(sourceFile); @@ -138508,7 +139214,7 @@ var ts; } else { return { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: reference.referencingFile.fileName, textSpan: ts.createTextSpanFromRange(reference.ref), }; @@ -138518,21 +139224,21 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } break; default: // This may be merged with something. - ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); + ts.Debug.assert(!!(symbol.flags & 33554432 /* SymbolFlags.Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } } - var exported = symbol.exports.get("export=" /* ExportEquals */); + var exported = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exported === null || exported === void 0 ? void 0 : exported.declarations) { for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -138540,41 +139246,41 @@ var ts; if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : - ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* SyntaxKind.ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } } } - return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; + return references.length ? [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 145 /* ReadonlyKeyword */ + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 145 /* ReadonlyKeyword */; + && node.parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A void expression (i.e., `void foo()`) is not special, but the `void` type is. - if (node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(node.parent)) { return undefined; } // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 145 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } if (ts.isImportMeta(node.parent) && node.parent.name === node) { return getAllReferencesForImportMeta(sourceFiles, cancellationToken); } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { - return [{ definition: { type: 2 /* Keyword */, node: node }, references: [nodeEntry(node)] }]; + return [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: node }, references: [nodeEntry(node)] }]; } // Labels if (ts.isJumpStatementTarget(node)) { @@ -138590,7 +139296,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -138599,20 +139305,20 @@ var ts; function getReferencedSymbolsForSymbol(originalSymbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options) { var symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, /*useLocalSymbolForExportSpecifier*/ !isForRenameWithPrefixAndSuffixText(options)) || originalSymbol; // Compute the meaning from the location and the symbol it references - var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; + var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* SemanticMeaning.All */; var result = []; - var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); + var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* SpecialSearchKind.None */, checker, cancellationToken, searchMeaning, options, result); var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) || !symbol.declarations ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); if (exportSpecifier) { // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { + else if (node && node.kind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.escapedName === "default" /* InternalSymbolName.Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* ExportKind.Default */ }, state); } else { - var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* FindReferencesUse.Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); getReferencesInContainerOrFiles(symbol, state, search); } return result; @@ -138635,17 +139341,17 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 171 /* Constructor */: - case 134 /* ConstructorKeyword */: - return 1 /* Constructor */; - case 79 /* Identifier */: + case 171 /* SyntaxKind.Constructor */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return 1 /* SpecialSearchKind.Constructor */; + case 79 /* SyntaxKind.Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); - return 2 /* Class */; + return 2 /* SpecialSearchKind.Class */; } // falls through default: - return 0 /* None */; + return 0 /* SpecialSearchKind.None */; } } /** Handle a few special cases relating to export/import specifiers. */ @@ -138658,10 +139364,10 @@ var ts; return ts.firstDefined(symbol.declarations, function (decl) { if (!decl.parent) { // Ignore UMD module and global merge - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return undefined; // Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here. - ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol)); + ts.Debug.fail("Unexpected symbol at ".concat(ts.Debug.formatSyntaxKind(node.kind), ": ").concat(ts.Debug.formatSymbol(symbol))); } return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent) ? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name) @@ -138675,7 +139381,7 @@ var ts; SpecialSearchKind[SpecialSearchKind["Class"] = 2] = "Class"; })(SpecialSearchKind || (SpecialSearchKind = {})); function getNonModuleSymbolOfMergedModuleSymbol(symbol) { - if (!(symbol.flags & (1536 /* Module */ | 33554432 /* Transient */))) + if (!(symbol.flags & (1536 /* SymbolFlags.Module */ | 33554432 /* SymbolFlags.Transient */))) return undefined; var decl = symbol.declarations && ts.find(symbol.declarations, function (d) { return !ts.isSourceFile(d) && !ts.isModuleDeclaration(d); }); return decl && decl.symbol; @@ -138727,7 +139433,7 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* Rename */); + return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* FindReferencesUse.Rename */); }; /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { @@ -138750,7 +139456,7 @@ var ts; var references = this.symbolIdToReferences[symbolId]; if (!references) { references = this.symbolIdToReferences[symbolId] = []; - this.result.push({ definition: { type: 0 /* Symbol */, symbol: searchSymbol }, references: references }); + this.result.push({ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSymbol }, references: references }); } return function (node, kind) { return references.push(nodeEntry(node, kind)); }; }; @@ -138758,7 +139464,7 @@ var ts; State.prototype.addStringOrCommentReference = function (fileName, textSpan) { this.result.push({ definition: undefined, - references: [{ kind: 0 /* Span */, fileName: fileName, textSpan: textSpan }] + references: [{ kind: 0 /* EntryKind.Span */, fileName: fileName, textSpan: textSpan }] }); }; /** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */ @@ -138789,19 +139495,19 @@ var ts; // For each import, find all references to that import in its source file. for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; - getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* Export */), state); + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* ImportExport.Export */), state); } if (indirectUsers.length) { var indirectSearch = void 0; switch (exportInfo.exportKind) { - case 0 /* Named */: - indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* Export */); + case 0 /* ExportKind.Named */: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */); break; - case 1 /* Default */: + case 1 /* ExportKind.Default */: // Search for a property access to '.default'. This can't be renamed. - indirectSearch = state.options.use === 2 /* Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* Export */, { text: "default" }); + indirectSearch = state.options.use === 2 /* FindReferencesUse.Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */, { text: "default" }); break; - case 2 /* ExportEquals */: + case 2 /* ExportKind.ExportEquals */: break; } if (indirectSearch) { @@ -138814,7 +139520,7 @@ var ts; } function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken); - var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { var importLocation = importSearches_2[_i][0]; cb(importLocation); @@ -138842,13 +139548,13 @@ var ts; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; - if (state.options.use !== 2 /* Rename */) + if (state.options.use !== 2 /* FindReferencesUse.Rename */) return true; // Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;` if (!ts.isIdentifier(singleRef)) return false; // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename. - return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* Default */); + return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* InternalSymbolName.Default */); } // Go to the symbol we imported from and find references for it. function searchForImportedSymbol(symbol, state) { @@ -138858,7 +139564,7 @@ var ts; var declaration = _a[_i]; var exportingFile = declaration.getSourceFile(); // Need to search in the file even if it's not in the search-file set, because it might export the symbol. - getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* Import */), state, state.includesSourceFile(exportingFile)); + getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* ImportExport.Import */), state, state.includesSourceFile(exportingFile)); } } /** Search for all occurrences of an identifier in a source file (and filter out the ones that match). */ @@ -138884,17 +139590,17 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 213 /* FunctionExpression */ || valueDeclaration.kind === 226 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 213 /* SyntaxKind.FunctionExpression */ || valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */)) { return valueDeclaration; } if (!declarations) { return undefined; } // If this is private property or method, the scope is the containing class - if (flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); + if (flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)) { + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 257 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 257 /* SyntaxKind.ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -138911,7 +139617,7 @@ var ts; - The parent is an external module: then we should only search in the module (and recurse on the export later). - But if the parent has `export as namespace`, the symbol is globally visible through that namespace. */ - var exposedByParent = parent && !(symbol.flags & 262144 /* TypeParameter */); + var exposedByParent = parent && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */); if (exposedByParent && !(ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { return undefined; } @@ -138923,7 +139629,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -139042,8 +139748,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* ScriptTarget.Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* ScriptTarget.Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -139058,27 +139764,27 @@ var ts; // Only pick labels that are either the target label, or have a target that is the target label return node === targetLabel || (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel) ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 1 /* Label */, node: targetLabel }, references: references }]; + return [{ definition: { type: 1 /* DefinitionKind.Label */, node: targetLabel }, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: if (ts.isJSDocMemberName(node.parent)) { return true; } // falls through I guess - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.text.length === searchSymbolName.length; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && str.text.length === searchSymbolName.length; } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -139094,7 +139800,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { @@ -139105,7 +139811,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getReferencesInSourceFile(sourceFile, search, state, addReferencesHere) { if (addReferencesHere === void 0) { addReferencesHere = true; } @@ -139156,7 +139862,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* SyntaxKind.Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -139166,14 +139872,14 @@ var ts; return; } switch (state.specialSearchKind) { - case 0 /* None */: + case 0 /* SpecialSearchKind.None */: if (addReferencesHere) addReference(referenceLocation, relatedSymbol, state); break; - case 1 /* Constructor */: + case 1 /* SpecialSearchKind.Constructor */: addConstructorReferences(referenceLocation, sourceFile, search, state); break; - case 2 /* Class */: + case 2 /* SpecialSearchKind.Class */: addClassStaticThisReferences(referenceLocation, search, state); break; default: @@ -139181,7 +139887,7 @@ var ts; } // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) - && referenceLocation.parent.kind === 203 /* BindingElement */ + && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In @@ -139201,7 +139907,7 @@ var ts; } if (!propertyName) { // Don't rename at `export { default } from "m";`. (but do continue to search for imports of the re-export) - if (!(state.options.use === 2 /* Rename */ && (name.escapedText === "default" /* Default */))) { + if (!(state.options.use === 2 /* FindReferencesUse.Rename */ && (name.escapedText === "default" /* InternalSymbolName.Default */))) { addRef(); } } @@ -139211,7 +139917,7 @@ var ts; if (!exportDeclaration.moduleSpecifier) { addRef(); } - if (addReferencesHere && state.options.use !== 2 /* Rename */ && state.markSeenReExportRHS(name)) { + if (addReferencesHere && state.options.use !== 2 /* FindReferencesUse.Rename */ && state.markSeenReExportRHS(name)) { addReference(name, ts.Debug.checkDefined(exportSpecifier.symbol), state); } } @@ -139222,9 +139928,9 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; - var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */; + var exportKind = isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); if (exportInfo) { @@ -139232,7 +139938,7 @@ var ts; } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. - if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { + if (search.comingFrom !== 1 /* ImportExport.Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { var imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (imported) searchForImportedSymbol(imported, state); @@ -139259,11 +139965,11 @@ var ts; } } function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { - var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* Export */); + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* ImportExport.Export */); if (!importOrExport) return; var symbol = importOrExport.symbol; - if (importOrExport.kind === 0 /* Import */) { + if (importOrExport.kind === 0 /* ImportExport.Import */) { if (!(isForRenameWithPrefixAndSuffixText(state.options))) { searchForImportedSymbol(symbol, state); } @@ -139283,14 +139989,14 @@ var ts; * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the * position of property accessing, the referenceEntry of such position will be handled in the first case. */ - if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + if (!(flags & 33554432 /* SymbolFlags.Transient */) && name && search.includes(shorthandValueSymbol)) { addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator // if rename symbol from default export anonymous function, for example `export default function() {}`, we do not need to add reference - if (state.options.use === 2 /* Rename */ && referenceLocation.kind === 88 /* DefaultKeyword */) { + if (state.options.use === 2 /* FindReferencesUse.Rename */ && referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */) { return; } var addRef = state.referenceAdder(symbol); @@ -139308,7 +140014,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -139324,7 +140030,7 @@ var ts; function addClassStaticThisReferences(referenceLocation, search, state) { addReference(referenceLocation, search.symbol, state); var classLike = referenceLocation.parent; - if (state.options.use === 2 /* Rename */ || !ts.isClassLike(classLike)) + if (state.options.use === 2 /* FindReferencesUse.Rename */ || !ts.isClassLike(classLike)) return; ts.Debug.assert(classLike.name === referenceLocation); var addRef = state.referenceAdder(search.symbol); @@ -139335,7 +140041,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 108 /* ThisKeyword */) { + if (node.kind === 108 /* SyntaxKind.ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -139354,18 +140060,18 @@ var ts; if (constructorSymbol && constructorSymbol.declarations) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 134 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 171 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 169 /* MethodDeclaration */) { + if (decl && decl.kind === 169 /* SyntaxKind.MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* SyntaxKind.ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -139376,7 +140082,7 @@ var ts; } } function getClassConstructorSymbol(classSymbol) { - return classSymbol.members && classSymbol.members.get("__constructor" /* Constructor */); + return classSymbol.members && classSymbol.members.get("__constructor" /* InternalSymbolName.Constructor */); } /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(classDeclaration, addNode) { @@ -139386,10 +140092,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 171 /* Constructor */); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SyntaxKind.SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -139413,10 +140119,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 79 /* Identifier */) { + if (refNode.kind !== 79 /* SyntaxKind.Identifier */) { return; } - if (refNode.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -139436,7 +140142,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 235 /* Block */) { + if (body.kind === 235 /* SyntaxKind.Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -139464,13 +140170,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 204 /* ArrayLiteralExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; default: return false; @@ -139521,15 +140227,15 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -139538,7 +140244,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 106 /* SuperKeyword */) { + if (node.kind !== 106 /* SyntaxKind.SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -139547,46 +140253,46 @@ var ts; // and has the same static qualifier as the original 'super's owner. return container && ts.isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; + return [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 79 /* Identifier */ && node.parent.kind === 164 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 164 /* SyntaxKind.Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 305 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -139594,26 +140300,26 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 205 /* ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // Make sure the container belongs to the same class/object literals // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag; - case 305 /* SourceFile */: - return container.kind === 305 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 305 /* SyntaxKind.SourceFile */: + return container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); var thisParameter = ts.firstDefined(references, function (r) { return ts.isParameter(r.node.parent) ? r.node : undefined; }); return [{ - definition: { type: 3 /* This */, node: thisParameter || thisOrSuperKeyword }, + definition: { type: 3 /* DefinitionKind.This */, node: thisParameter || thisOrSuperKeyword }, references: references }]; } @@ -139626,18 +140332,18 @@ var ts; if (type) { var refType = ts.getContextualTypeFromParentOrAncestorTypeNode(ref, checker); if (type !== checker.getStringType() && type === refType) { - return nodeEntry(ref, 2 /* StringLiteral */); + return nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } else { return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined : - nodeEntry(ref, 2 /* StringLiteral */); + nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } }); }); return [{ - definition: { type: 4 /* String */, node: node }, + definition: { type: 4 /* DefinitionKind.String */, node: node }, references: references }]; } @@ -139682,30 +140388,30 @@ var ts; var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); // gets the local symbol if (shorthandValueSymbol && isForRenamePopulateSearchSymbolSet) { // When renaming 'x' in `const o = { x }`, just rename the local variable, not the property. - return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); } // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set var contextualType = checker.getContextualType(containingObjectLiteralElement.parent); - var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* SearchedPropertyFoundLocal */); }); + var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* EntryKind.SearchedPropertyFoundLocal */); }); if (res_1) return res_1; // If the location is name of property symbol from object literal destructuring pattern // Search the property symbol // for ( { property: p2 } of elems) { } var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); - var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* SearchedPropertyFoundLocal */); + var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* EntryKind.SearchedPropertyFoundLocal */); if (res1) return res1; - var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); if (res2) return res2; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(location, symbol, checker); if (aliasedSymbol) { // In case of UMD module and global merging, search for global as well - var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_2) return res_2; } @@ -139715,14 +140421,14 @@ var ts; if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); - ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] - return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); + ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* SymbolFlags.FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* SymbolFlags.Property */)); // is [parameter, property] + return fromRoot(symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { - var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_3) return res_3; } @@ -139737,7 +140443,7 @@ var ts; else { bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); } - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } ts.Debug.assert(isForRenamePopulateSearchSymbolSet); // due to the above assert and the arguments at the uses of this function, @@ -139745,7 +140451,7 @@ var ts; var includeOriginalSymbolOfBindingElement = onlyIncludeBindingElementAtReferenceLocation; if (includeOriginalSymbolOfBindingElement) { var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } function fromRoot(sym, kind) { // If this is a union property: @@ -139757,13 +140463,13 @@ var ts; return ts.firstDefined(checker.getRootSymbols(sym), function (rootSymbol) { return cbSymbol(sym, rootSymbol, /*baseSymbol*/ undefined, kind) // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol) + || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) && allowBaseTypes(rootSymbol) ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base, kind); }) : undefined); }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* SyntaxKind.BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -139785,7 +140491,7 @@ var ts; // interface C extends C { // /*findRef*/propName: string; // } - if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + if (!(symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) return; return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { var type = checker.getTypeAtLocation(typeReference); @@ -139799,12 +140505,12 @@ var ts; if (!symbol.valueDeclaration) return false; var modifierFlags = ts.getEffectiveModifierFlags(symbol.valueDeclaration); - return !!(modifierFlags & 32 /* Static */); + return !!(modifierFlags & 32 /* ModifierFlags.Static */); } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, /*isForRenamePopulateSearchSymbolSet*/ false, - /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { + /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* FindReferencesUse.Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { // check whether the symbol used to search itself is just the searched one. if (baseSymbol) { // static method/property and instance method/property might have the same name. Only check static or only check instance. @@ -139814,7 +140520,7 @@ var ts; } return search.includes(baseSymbol || rootSymbol || sym) // For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol. - ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* Synthetic */) ? rootSymbol : sym, kind: kind } + ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* CheckFlags.Synthetic */) ? rootSymbol : sym, kind: kind } : undefined; }, /*allowBaseTypes*/ function (rootSymbol) { @@ -139854,7 +140560,7 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : (ts.isVariableLike(node) ? ts.hasInitializer(node) : ts.isFunctionLikeDeclaration(node) ? !!node.body : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); @@ -139865,7 +140571,7 @@ var ts; if (shorthandSymbol) { for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { + if (ts.getMeaningFromDeclaration(declaration) & 1 /* SemanticMeaning.Value */) { addReference(declaration); } } @@ -139894,12 +140600,12 @@ var ts; var propertyAccessExpression = ts.isRightSideOfPropertyAccess(location) ? location.parent : undefined; var lhsType = propertyAccessExpression && checker.getTypeAtLocation(propertyAccessExpression.expression); var res = ts.mapDefined(lhsType && (lhsType.isUnionOrIntersection() ? lhsType.types : lhsType.symbol === symbol.parent ? undefined : [lhsType]), function (t) { - return t.symbol && t.symbol.flags & (32 /* Class */ | 64 /* Interface */) ? t.symbol : undefined; + return t.symbol && t.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) ? t.symbol : undefined; }); return res.length === 0 ? undefined : res; } function isForRenameWithPrefixAndSuffixText(options) { - return options.use === 2 /* Rename */ && options.providePrefixAndSuffixTextForRename; + return options.use === 2 /* FindReferencesUse.Rename */ && options.providePrefixAndSuffixTextForRename; } })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); @@ -139919,7 +140625,7 @@ var ts; && ts.isVariableDeclaration(node.parent) && node === node.parent.initializer && ts.isIdentifier(node.parent.name) - && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* Const */); + && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* NodeFlags.Const */); } /** * Indicates whether a node could possibly be a call hierarchy declaration. @@ -139968,7 +140674,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -139992,8 +140698,8 @@ var ts; var end = pos + 6; /* "static".length */ var typeChecker = program.getTypeChecker(); var symbol = typeChecker.getSymbolAtLocation(node.parent); - var prefix = symbol ? typeChecker.symbolToString(symbol, node.parent) + " " : ""; - return { text: prefix + "static {}", pos: pos, end: end }; + var prefix = symbol ? "".concat(typeChecker.symbolToString(symbol, node.parent), " ") : ""; + return { text: "".concat(prefix, "static {}"), pos: pos, end: end }; } var declName = isConstNamedExpression(node) ? node.parent.name : ts.Debug.checkDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name"); @@ -140013,7 +140719,7 @@ var ts; if (text === undefined) { // get the text from printing the node on a single line without comments... var printer_1 = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* Unspecified */, node, node.getSourceFile(), writer); }); + text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* EmitHint.Unspecified */, node, node.getSourceFile(), writer); }); } return { text: text, pos: declName.getStart(), end: declName.getEnd() }; } @@ -140026,16 +140732,16 @@ var ts; return; } switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText(); } return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText(); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -140062,8 +140768,8 @@ var ts; var declarations; if (symbol && symbol.declarations) { var indices = ts.indicesOf(symbol.declarations); - var keys_1 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); }); - indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_1[a].file, keys_1[b].file) || keys_1[a].pos - keys_1[b].pos; }); + var keys_2 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); }); + indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_2[a].file, keys_2[b].file) || keys_2[a].pos - keys_2[b].pos; }); var sortedDeclarations = ts.map(indices, function (i) { return symbol.declarations[i]; }); var lastDecl = void 0; for (var _i = 0, sortedDeclarations_1 = sortedDeclarations; _i < sortedDeclarations_1.length; _i++) { @@ -140133,7 +140839,7 @@ var ts; } return undefined; } - if (location.kind === 124 /* StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { + if (location.kind === 124 /* SyntaxKind.StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { location = location.parent; continue; } @@ -140144,7 +140850,7 @@ var ts; if (!followingSymbol) { var symbol = typeChecker.getSymbolAtLocation(location); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } if (symbol.valueDeclaration) { @@ -140174,7 +140880,7 @@ var ts; return x !== undefined; } function convertEntryToCallSite(entry) { - if (entry.kind === 1 /* Node */) { + if (entry.kind === 1 /* FindAllReferences.EntryKind.Node */) { var node = entry.node; if (ts.isCallOrNewExpressionTarget(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) || ts.isTaggedTemplateTag(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) @@ -140204,7 +140910,7 @@ var ts; return []; } var location = getCallHierarchyDeclarationReferenceNode(declaration); - var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* References */ }, convertEntryToCallSite), isDefined); + var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, convertEntryToCallSite), isDefined); return calls ? ts.group(calls, getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToIncomingCall(program, entries); }) : []; } CallHierarchy.getIncomingCalls = getIncomingCalls; @@ -140232,7 +140938,7 @@ var ts; function collect(node) { if (!node) return; - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // do not descend into ambient nodes. return; } @@ -140249,59 +140955,59 @@ var ts; return; } switch (node.kind) { - case 79 /* Identifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 79 /* SyntaxKind.Identifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: recordCallSite(node); return; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: recordCallSite(node); collect(node.expression); return; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -140318,7 +141024,7 @@ var ts; ts.forEach(node.statements, collect); } function collectCallSitesOfModuleDeclaration(node, collect) { - if (!ts.hasSyntacticModifier(node, 2 /* Ambient */) && node.body && ts.isModuleBlock(node.body)) { + if (!ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) && node.body && ts.isModuleBlock(node.body)) { ts.forEach(node.body.statements, collect); } } @@ -140359,25 +141065,25 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: collectCallSitesOfClassStaticBlockDeclaration(node, collect); break; default: @@ -140393,7 +141099,7 @@ var ts; } /** Gets the call sites that call out of the provided call hierarchy declaration. */ function getOutgoingCalls(program, declaration) { - if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) { + if (declaration.flags & 16777216 /* NodeFlags.Ambient */ || ts.isMethodSignature(declaration)) { return []; } return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); }); @@ -140511,7 +141217,7 @@ var ts; } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) { var allFiles = program.getSourceFiles(); - var _loop_5 = function (sourceFile) { + var _loop_4 = function (sourceFile) { var newFromOld = oldToNew(sourceFile.fileName); var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); @@ -140543,7 +141249,7 @@ var ts; }; for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { var sourceFile = allFiles_1[_i]; - _loop_5(sourceFile); + _loop_4(sourceFile); } } function combineNormal(pathA, pathB) { @@ -140648,13 +141354,13 @@ var ts; } var parent = node.parent; var typeChecker = program.getTypeChecker(); - if (node.kind === 159 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { + if (node.kind === 159 /* SyntaxKind.OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray; } // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 + return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { var classDecl = node.parent.parent; @@ -140665,7 +141371,7 @@ var ts; return ts.map(staticBlocks, function (staticBlock) { var pos = ts.moveRangePastModifiers(staticBlock).pos; pos = ts.skipTrivia(sourceFile_1.text, pos); - return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); + return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* ScriptElementKind.constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); }); } var _d = getSymbol(node, typeChecker, stopAtAlias), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution; @@ -140689,7 +141395,7 @@ var ts; fileName: ref.resolvedFileName, containerName: undefined, containerKind: undefined, - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, textSpan: ts.createTextSpan(0, 0), failedAliasResolution: failedAliasResolution, isAmbient: ts.isDeclarationFileName(ref.resolvedFileName), @@ -140716,7 +141422,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); + return node.kind === 106 /* SyntaxKind.SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -140724,7 +141430,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray; return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); @@ -140858,12 +141564,12 @@ var ts; // If a function returns 'void' or some other type with no definition, just return the function definition. var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution); return typeDefinitions.length ? typeDefinitions - : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) + : !(symbol.flags & 111551 /* SymbolFlags.Value */) && symbol.flags & 788968 /* SymbolFlags.Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) : undefined; } GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition; function definitionFromType(type, checker, node, failedAliasResolution) { - return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) { + return ts.flatMap(type.isUnion() && !(type.flags & 32 /* TypeFlags.Enum */) ? type.types : [type], function (t) { return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution); }); } @@ -140907,7 +141613,7 @@ var ts; // import {A, B} from "mod"; // to jump to the implementation directly. var failedAliasResolution = false; - if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* SymbolFlags.Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { return { symbol: aliased }; @@ -140924,13 +141630,13 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 79 /* Identifier */) { + if (node.kind !== 79 /* SyntaxKind.Identifier */) { return false; } if (node.parent === declaration) { return true; } - if (declaration.kind === 268 /* NamespaceImport */) { + if (declaration.kind === 268 /* SyntaxKind.NamespaceImport */) { return false; } return true; @@ -140962,7 +141668,7 @@ var ts; return "quit"; return false; }); - return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */; + return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* AssignmentDeclarationKind.Property */; } function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) { var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; }); @@ -140972,7 +141678,7 @@ var ts; function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* SymbolFlags.Class */ && !(symbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* SyntaxKind.ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -141012,7 +141718,7 @@ var ts; textSpan = ts.createTextSpanFromNode(name, sourceFile); } return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217 - containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* NodeFlags.Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); } function isDefinitionVisible(checker, declaration) { if (checker.isDeclarationVisible(declaration)) @@ -141024,22 +141730,22 @@ var ts; return isDefinitionVisible(checker, declaration.parent); // Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // Private/protected properties/methods are not visible - if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + if (ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) return false; // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: return isDefinitionVisible(checker, declaration.parent); default: return false; @@ -141056,7 +141762,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, name: name, containerName: undefined, containerKind: undefined, @@ -141077,9 +141783,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return true; default: return false; @@ -141185,17 +141891,17 @@ var ts; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var jsdoc = _a[_i]; - var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 327 /* JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); }); + var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 327 /* SyntaxKind.JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); }); // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @typedefs are themselves declarations with associated comments // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation if (jsdoc.comment === undefined && !inheritDoc || ts.isJSDoc(jsdoc) - && declaration.kind !== 345 /* JSDocTypedefTag */ && declaration.kind !== 338 /* JSDocCallbackTag */ + && declaration.kind !== 345 /* SyntaxKind.JSDocTypedefTag */ && declaration.kind !== 338 /* SyntaxKind.JSDocCallbackTag */ && jsdoc.tags - && jsdoc.tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + && jsdoc.tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !jsdoc.tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { continue; } var newparts = jsdoc.comment ? getDisplayPartsFromComment(jsdoc.comment, checker) : []; @@ -141215,11 +141921,11 @@ var ts; } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return [declaration]; - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -141233,8 +141939,8 @@ var ts; // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation - if (tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + if (tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { return; } for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) { @@ -141249,17 +141955,17 @@ var ts; if (typeof comment === "string") { return [ts.textPart(comment)]; } - return ts.flatMap(comment, function (node) { return node.kind === 321 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); + return ts.flatMap(comment, function (node) { return node.kind === 321 /* SyntaxKind.JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); } function getCommentDisplayParts(tag, checker) { var comment = tag.comment, kind = tag.kind; var namePart = getTagNameDisplayPart(kind); switch (kind) { - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return withNode(tag.class); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return withNode(tag.class); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: var templateTag = tag; var displayParts_3 = []; if (templateTag.constraint) { @@ -141273,7 +141979,7 @@ var ts; ts.forEach(templateTag.typeParameters, function (tp) { displayParts_3.push(namePart(tp.getText())); if (lastTypeParameter_1 !== tp) { - displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]); + displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]); } }); } @@ -141281,13 +141987,13 @@ var ts; displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true)); } return displayParts_3; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return withNode(tag.typeExpression); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: - case 346 /* JSDocSeeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: var name = tag.name; return name ? withNode(name) : comment === undefined ? undefined @@ -141314,14 +142020,14 @@ var ts; } function getTagNameDisplayPart(kind) { switch (kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return ts.parameterNamePart; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return ts.propertyNamePart; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return ts.typeParameterNamePart; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return ts.typeAliasNamePart; default: return ts.textPart; @@ -141331,7 +142037,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword" /* keyword */, + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority, }; @@ -141342,8 +142048,8 @@ var ts; function getJSDocTagCompletions() { return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { - name: "@" + tagName, - kind: "keyword" /* keyword */, + name: "@".concat(tagName), + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; @@ -141353,7 +142059,7 @@ var ts; function getJSDocTagCompletionDetails(name) { return { name: name, - kind: "" /* unknown */, + kind: "" /* ScriptElementKind.unknown */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -141379,14 +142085,14 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; + return { name: name, kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; function getJSDocParameterNameCompletionDetails(name) { return { name: name, - kind: "parameter" /* parameterElement */, + kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -141435,8 +142141,12 @@ var ts; return undefined; } var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn; - var commentOwnerJSDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? ts.lastOrUndefined(commentOwner.jsDoc) : undefined; - if (commentOwner.getStart(sourceFile) < position || commentOwnerJSDoc && commentOwnerJSDoc !== existingDocComment) { + var commentOwnerJsDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? commentOwner.jsDoc : undefined; + var lastJsDoc = ts.lastOrUndefined(commentOwnerJsDoc); + if (commentOwner.getStart(sourceFile) < position + || lastJsDoc + && existingDocComment + && lastJsDoc !== existingDocComment) { return undefined; } var indentationStr = getIndentationStringAtPosition(sourceFile, position); @@ -141453,7 +142163,9 @@ var ts; // * if the caret was directly in front of the object, then we add an extra line and indentation. var openComment = "/**"; var closeComment = " */"; - if (tags) { + // If any of the existing jsDoc has tags, ignore adding new ones. + var hasTag = (commentOwnerJsDoc || []).some(function (jsDoc) { return !!jsDoc.tags; }); + if (tags && !hasTag) { var preamble = openComment + newLine + indentationStr + " * "; var endLine = tokenStart === position ? newLine + indentationStr : ""; var result = preamble + newLine + tags + indentationStr + closeComment + endLine; @@ -141473,37 +142185,37 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* SyntaxKind.Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; - return indentationStr + " * @param " + type + paramName + newLine; + return "".concat(indentationStr, " * @param ").concat(type).concat(paramName).concat(newLine); }).join(""); } function returnsDocComment(indentationStr, newLine) { - return indentationStr + " * @returns" + newLine; + return "".concat(indentationStr, " * @returns").concat(newLine); } function getCommentOwnerInfo(tokenAtPos, options) { return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: var host = commentOwner; return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer, options); - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 166 /* PropertySignature */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -141513,25 +142225,25 @@ var ts; ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return "quit"; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 261 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 238 /* ExpressionStatement */: + return commentOwner.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 238 /* SyntaxKind.ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression, options); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var be = commentOwner; - if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { + if (ts.getAssignmentDeclarationKind(be) === 0 /* AssignmentDeclarationKind.None */) { return "quit"; } return ts.isFunctionLike(be.right) ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; @@ -141544,14 +142256,14 @@ var ts; || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 212 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return rightHandSide; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -141567,7 +142279,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_6 = function (sourceFile) { + var _loop_5 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && sourceFile.isDeclarationFile) { return "continue"; @@ -141579,7 +142291,7 @@ var ts; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var sourceFile = sourceFiles_4[_i]; - _loop_6(sourceFile); + _loop_5(sourceFile); } rawItems.sort(compareNavigateToItems); return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); @@ -141610,9 +142322,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -141622,7 +142334,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 162 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -141639,7 +142351,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 162 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -141673,7 +142385,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, + containerKind: containerName ? ts.getNodeKind(container) : "" /* ScriptElementKind.unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -141856,7 +142568,7 @@ var ts; */ function hasNavigationBarName(node) { return !ts.hasDynamicName(node) || - (node.kind !== 221 /* BinaryExpression */ && + (node.kind !== 221 /* SyntaxKind.BinaryExpression */ && ts.isPropertyAccessExpression(node.name.expression) && ts.isIdentifier(node.name.expression.expression) && ts.idText(node.name.expression.expression) === "Symbol"); @@ -141869,7 +142581,7 @@ var ts; return; } switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -141881,25 +142593,25 @@ var ts; } } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 168 /* SyntaxKind.MethodSignature */: if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (hasNavigationBarName(node)) { addNodeWithRecursiveInitializer(node); } break; - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -141911,7 +142623,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -141922,17 +142634,17 @@ var ts; } } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: var expression = node.expression; // Use the expression as the name of the SpreadAssignment, otherwise show as . ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); break; - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: - case 254 /* VariableDeclaration */: { + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: { var child = node; if (ts.isBindingPattern(child.name)) { addChildrenRecursively(child.name); @@ -141942,7 +142654,7 @@ var ts; } break; } - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -141950,11 +142662,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -141964,9 +142676,9 @@ var ts; } endNode(); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -141974,10 +142686,10 @@ var ts; } endNode(); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression_1 = node.expression; var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 : ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined; @@ -141991,27 +142703,27 @@ var ts; } break; } - case 275 /* ExportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 176 /* IndexSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 259 /* TypeAliasDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: addLeafNode(node); break; - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: addNodeWithRecursiveChild(node, node.right); return; - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: { + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; - var prototypeAccess = special === 3 /* PrototypeProperty */ ? + var prototypeAccess = special === 3 /* AssignmentDeclarationKind.PrototypeProperty */ ? assignmentTarget.expression : assignmentTarget; var depth = 0; @@ -142025,7 +142737,7 @@ var ts; else { _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; } - if (special === 6 /* Prototype */) { + if (special === 6 /* AssignmentDeclarationKind.Prototype */) { if (ts.isObjectLiteralExpression(binaryExpression.right)) { if (binaryExpression.right.properties.length > 0) { startNode(binaryExpression, className); @@ -142045,10 +142757,10 @@ var ts; endNestedNodes(depth); return; } - case 7 /* ObjectDefinePropertyValue */: - case 9 /* ObjectDefinePrototypeProperty */: { + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: { var defineCall = node; - var className = special === 7 /* ObjectDefinePropertyValue */ ? + var className = special === 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */ ? defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; @@ -142061,7 +142773,7 @@ var ts; endNestedNodes(depth); return; } - case 5 /* Property */: { + case 5 /* AssignmentDeclarationKind.Property */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; var targetFunction = assignmentTarget.expression; @@ -142079,9 +142791,9 @@ var ts; } break; } - case 4 /* ThisProperty */: - case 0 /* None */: - case 8 /* ObjectDefinePropertyExports */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: break; default: ts.Debug.assertNever(special); @@ -142137,16 +142849,16 @@ var ts; }); } var isEs5ClassMember = (_a = {}, - _a[5 /* Property */] = true, - _a[3 /* PrototypeProperty */] = true, - _a[7 /* ObjectDefinePropertyValue */] = true, - _a[9 /* ObjectDefinePrototypeProperty */] = true, - _a[0 /* None */] = false, - _a[1 /* ExportsProperty */] = false, - _a[2 /* ModuleExports */] = false, - _a[8 /* ObjectDefinePropertyExports */] = false, - _a[6 /* Prototype */] = true, - _a[4 /* ThisProperty */] = false, + _a[5 /* AssignmentDeclarationKind.Property */] = true, + _a[3 /* AssignmentDeclarationKind.PrototypeProperty */] = true, + _a[7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */] = true, + _a[9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */] = true, + _a[0 /* AssignmentDeclarationKind.None */] = false, + _a[1 /* AssignmentDeclarationKind.ExportsProperty */] = false, + _a[2 /* AssignmentDeclarationKind.ModuleExports */] = false, + _a[8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */] = false, + _a[6 /* AssignmentDeclarationKind.Prototype */] = true, + _a[4 /* AssignmentDeclarationKind.ThisProperty */] = false, _a); function tryMergeEs5Class(a, b, bIndex, parent) { function isPossibleConstructor(node) { @@ -142154,10 +142866,10 @@ var ts; } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -142221,7 +142933,7 @@ var ts; } return true; } - return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + return bAssignmentDeclarationKind === 0 /* AssignmentDeclarationKind.None */ ? false : true; } function tryMerge(a, b, bIndex, parent) { // const v = false as boolean; @@ -142240,12 +142952,12 @@ var ts; return false; } switch (a.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.isStatic(a) === ts.isStatic(b); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return areSameModule(a, b) && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: @@ -142253,7 +142965,7 @@ var ts; } } function isSynthesized(node) { - return !!(node.flags & 8 /* Synthesized */); + return !!(node.flags & 8 /* NodeFlags.Synthesized */); } // We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }` // We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };` @@ -142267,7 +142979,7 @@ var ts; if (!a.body || !b.body) { return a.body === b.body; } - return a.body.kind === b.body.kind && (a.body.kind !== 261 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 261 /* SyntaxKind.ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -142297,7 +143009,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -142306,53 +143018,53 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { var text = ts.isIdentifier(name) ? name.text - : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : ts.isElementAccessExpression(name) ? "[".concat(nodeText(name.argumentExpression), "]") : nodeText(name); if (text.length > 0) { return cleanText(text); } } switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" + ? "\"".concat(ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))), "\"") : ""; - case 271 /* ExportAssignment */: - return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + case 271 /* SyntaxKind.ExportAssignment */: + return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } // We may get a string with newlines or other whitespace in the case of an object dereference // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return "new()"; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return "()"; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return "[]"; default: return ""; @@ -142385,19 +143097,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 305 /* SourceFile */: - case 259 /* TypeAliasDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return true; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -142407,10 +143119,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: return true; default: return false; @@ -142472,7 +143184,7 @@ var ts; function getFullyQualifiedModuleName(moduleDeclaration) { // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)]; - while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -142486,13 +143198,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 162 /* ComputedPropertyName */; + return !member.name || member.name.kind === 162 /* SyntaxKind.ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 305 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 254 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -142507,7 +143219,7 @@ var ts; return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -142515,7 +143227,7 @@ var ts; return nodeText(parent.name); } // Default exports are named "default" - else if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + else if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } else if (ts.isClassLike(node)) { @@ -142526,10 +143238,10 @@ var ts; if (name !== undefined) { name = cleanText(name); if (name.length > maxLength) { - return name + " callback"; + return "".concat(name, " callback"); } var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); - return name + "(" + args + ") callback"; + return "".concat(name, "(").concat(args, ") callback"); } } return ""; @@ -142542,7 +143254,7 @@ var ts; else if (ts.isPropertyAccessExpression(expr)) { var left = getCalledExpressionName(expr.expression); var right = expr.name.text; - return left === undefined ? right : left + "." + right; + return left === undefined ? right : "".concat(left, ".").concat(right); } else { return undefined; @@ -142550,9 +143262,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; default: return false; @@ -142666,7 +143378,7 @@ var ts; var numberOfNewLines = 0; while (scanner.getTokenPos() < endPos) { var tokenKind = scanner.scan(); - if (tokenKind === 4 /* NewLineTrivia */) { + if (tokenKind === 4 /* SyntaxKind.NewLineTrivia */) { numberOfNewLines++; if (numberOfNewLines >= 2) { return true; @@ -142684,7 +143396,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); - var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */); + var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* TransformFlags.ContainsJsx */); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -142953,11 +143665,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return declaration.moduleSpecifier; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -142996,19 +143708,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!s1.importClause) return 0; if (s1.importClause.isTypeOnly) return 1; - if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* SyntaxKind.NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return 5; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return 6; } } @@ -143061,7 +143773,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* SyntaxKind.ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* OutliningSpanKind.Imports */)); } } function visitNonImportNode(n) { @@ -143069,7 +143781,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* EndOfFileToken */) { + if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* SyntaxKind.EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (ts.isFunctionLike(n) && ts.isBinaryExpression(n.parent) && ts.isPropertyAccessExpression(n.parent.left)) { @@ -143119,7 +143831,7 @@ var ts; } if (!result[1]) { var span = ts.createTextSpanFromBounds(sourceFile.text.indexOf("//", currentLineStart), lineEnd); - regions.push(createOutliningSpan(span, "region" /* Region */, span, /*autoCollapse*/ false, result[2] || "#region")); + regions.push(createOutliningSpan(span, "region" /* OutliningSpanKind.Region */, span, /*autoCollapse*/ false, result[2] || "#region")); } else { var region = regions.pop(); @@ -143154,7 +143866,7 @@ var ts; var _a = comments_1[_i], kind = _a.kind, pos_1 = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: // never fold region delimiters into single-line comment regions var commentText = sourceText.slice(pos_1, end); if (isRegionDelimiter(commentText)) { @@ -143170,9 +143882,9 @@ var ts; lastSingleLineCommentEnd = end; singleLineCommentCount++; break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: combineAndAddMultipleSingleLineComments(); - out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* OutliningSpanKind.Comment */)); singleLineCommentCount = 0; break; default: @@ -143183,7 +143895,7 @@ var ts; function combineAndAddMultipleSingleLineComments() { // Only outline spans of two or more consecutive single line comments if (singleLineCommentCount > 1) { - out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* OutliningSpanKind.Comment */)); } } } @@ -143197,7 +143909,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -143205,23 +143917,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 240 /* DoStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 292 /* CatchClause */: + case 240 /* SyntaxKind.DoStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 292 /* SyntaxKind.CatchClause */: return spanForNode(n.parent); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -143229,52 +143941,52 @@ var ts; default: // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); + return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* OutliningSpanKind.Code */); } - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanForNode(n.parent); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 263 /* CaseBlock */: - case 182 /* TypeLiteral */: - case 201 /* ObjectBindingPattern */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 263 /* SyntaxKind.CaseBlock */: + case 182 /* SyntaxKind.TypeLiteral */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return spanForNode(n); - case 184 /* TupleType */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 184 /* SyntaxKind.TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return spanForNodeArray(n.statements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 204 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 278 /* JsxElement */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* SyntaxKind.OpenBracketToken */); + case 278 /* SyntaxKind.JsxElement */: return spanForJSXElement(n); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return spanForJSXFragment(n); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 202 /* ArrayBindingPattern */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 214 /* ArrowFunction */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 214 /* SyntaxKind.ArrowFunction */: return spanForArrowFunction(n); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return spanForCallExpression(n); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanForParenthesizedExpression(n); } function spanForCallExpression(node) { if (!node.arguments.length) { return undefined; } - var openToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); - var closeToken = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + var openToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); + var closeToken = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!openToken || !closeToken || ts.positionsAreOnSameLine(openToken.pos, closeToken.pos, sourceFile)) { return undefined; } @@ -143285,33 +143997,33 @@ var ts; return undefined; } var textSpan = ts.createTextSpanFromBounds(node.body.getFullStart(), node.body.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); var tagName = node.openingElement.tagName.getText(sourceFile); var bannerText = "<" + tagName + ">..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXFragment(node) { var textSpan = ts.createTextSpanFromBounds(node.openingFragment.getStart(sourceFile), node.closingFragment.getEnd()); var bannerText = "<>..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXAttributes(node) { if (node.properties.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForTemplateLiteral(node) { - if (node.kind === 14 /* NoSubstitutionTemplateLiteral */ && node.text.length === 0) { + if (node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ && node.text.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 18 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal or call expression, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -143320,32 +144032,32 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open, close) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 18 /* OpenBraceToken */; } - if (close === void 0) { close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } + if (close === void 0) { close = open === 18 /* SyntaxKind.OpenBraceToken */ ? 19 /* SyntaxKind.CloseBraceToken */ : 23 /* SyntaxKind.CloseBracketToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); var closeToken = ts.findChildOfKind(n, close, sourceFile); return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart); } function spanForNodeArray(nodeArray) { - return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* Code */) : undefined; + return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* OutliningSpanKind.Code */) : undefined; } function spanForParenthesizedExpression(node) { if (ts.positionsAreOnSameLine(node.getStart(), node.getEnd(), sourceFile)) return undefined; var textSpan = ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } } function functionSpan(node, body, sourceFile) { var openToken = tryGetFunctionOpenToken(node, body, sourceFile); - var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* ArrowFunction */); + var closeToken = ts.findChildOfKind(body, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* SyntaxKind.ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } var textSpan = ts.createTextSpanFromBounds(useFullStart ? openToken.getFullStart() : openToken.getStart(sourceFile), closeToken.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); } function createOutliningSpan(textSpan, kind, hintSpan, autoCollapse, bannerText) { if (hintSpan === void 0) { hintSpan = textSpan; } @@ -143355,12 +144067,12 @@ var ts; } function tryGetFunctionOpenToken(node, body, sourceFile) { if (ts.isNodeArrayMultiLine(node.parameters, sourceFile)) { - var openParenToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + var openParenToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (openParenToken) { return openParenToken; } } - return ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); + return ts.findChildOfKind(body, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); } })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); })(ts || (ts = {})); @@ -143486,7 +144198,7 @@ var ts; // // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. - if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* space */ && ch !== 42 /* asterisk */; })) { + if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* CharacterCodes.space */ && ch !== 42 /* CharacterCodes.asterisk */; })) { var match = matchTextChunk(candidate, segment.totalTextChunk, stringToWordSpans); if (match) return match; @@ -143538,7 +144250,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ + return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { @@ -143615,10 +144327,10 @@ var ts; } function isUpperCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -143628,10 +144340,10 @@ var ts; } function isLowerCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -143642,13 +144354,13 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_7 = function (start) { + var _loop_6 = function (start) { if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) { return { value: start }; } }; for (var start = 0; start <= n; start++) { - var state_3 = _loop_7(start); + var state_3 = _loop_6(start); if (typeof state_3 === "object") return state_3.value; } @@ -143656,10 +144368,10 @@ var ts; } function toLowerCase(ch) { // Fast convert for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return 97 /* a */ + (ch - 65 /* A */); + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { + return 97 /* CharacterCodes.a */ + (ch - 65 /* CharacterCodes.A */); } - if (ch < 127 /* maxAsciiCharacter */) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */) { return ch; } // TODO: find a way to compute this for any unicode characters in a @@ -143668,10 +144380,10 @@ var ts; } function isDigit(ch) { // TODO(cyrusn): Find a way to support this for unicode digits. - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* CharacterCodes._ */ || ch === 36 /* CharacterCodes.$ */; } function breakPatternIntoTextChunks(pattern) { var result = []; @@ -143740,35 +144452,35 @@ var ts; } function charIsPunctuation(ch) { switch (ch) { - case 33 /* exclamation */: - case 34 /* doubleQuote */: - case 35 /* hash */: - case 37 /* percent */: - case 38 /* ampersand */: - case 39 /* singleQuote */: - case 40 /* openParen */: - case 41 /* closeParen */: - case 42 /* asterisk */: - case 44 /* comma */: - case 45 /* minus */: - case 46 /* dot */: - case 47 /* slash */: - case 58 /* colon */: - case 59 /* semicolon */: - case 63 /* question */: - case 64 /* at */: - case 91 /* openBracket */: - case 92 /* backslash */: - case 93 /* closeBracket */: - case 95 /* _ */: - case 123 /* openBrace */: - case 125 /* closeBrace */: + case 33 /* CharacterCodes.exclamation */: + case 34 /* CharacterCodes.doubleQuote */: + case 35 /* CharacterCodes.hash */: + case 37 /* CharacterCodes.percent */: + case 38 /* CharacterCodes.ampersand */: + case 39 /* CharacterCodes.singleQuote */: + case 40 /* CharacterCodes.openParen */: + case 41 /* CharacterCodes.closeParen */: + case 42 /* CharacterCodes.asterisk */: + case 44 /* CharacterCodes.comma */: + case 45 /* CharacterCodes.minus */: + case 46 /* CharacterCodes.dot */: + case 47 /* CharacterCodes.slash */: + case 58 /* CharacterCodes.colon */: + case 59 /* CharacterCodes.semicolon */: + case 63 /* CharacterCodes.question */: + case 64 /* CharacterCodes.at */: + case 91 /* CharacterCodes.openBracket */: + case 92 /* CharacterCodes.backslash */: + case 93 /* CharacterCodes.closeBracket */: + case 95 /* CharacterCodes._ */: + case 123 /* CharacterCodes.openBrace */: + case 125 /* CharacterCodes.closeBrace */: return true; } return false; } function isAllPunctuation(identifier, start, end) { - return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* _ */; }, start, end); + return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* CharacterCodes._ */; }, start, end); } function transitionFromUpperToLower(identifier, index, wordStart) { // Cases this supports: @@ -143829,7 +144541,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var pragmaContext = { - languageVersion: 1 /* ES5 */, + languageVersion: 1 /* ScriptTarget.ES5 */, pragmas: undefined, checkJsDirective: undefined, referencedFiles: [], @@ -143850,10 +144562,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 18 /* OpenBraceToken */) { + if (currentToken === 18 /* SyntaxKind.OpenBraceToken */) { braceNesting++; } - else if (currentToken === 19 /* CloseBraceToken */) { + else if (currentToken === 19 /* SyntaxKind.CloseBraceToken */) { braceNesting--; } return currentToken; @@ -143883,12 +144595,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 135 /* DeclareKeyword */) { + if (token === 135 /* SyntaxKind.DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 141 /* ModuleKeyword */) { + if (token === 141 /* SyntaxKind.ModuleKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { recordAmbientExternalModule(); } } @@ -143900,54 +144612,54 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 24 /* DotToken */) { + if (lastToken === 24 /* SyntaxKind.DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 100 /* ImportKeyword */) { + if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 10 /* StringLiteral */) { + else if (token === 10 /* SyntaxKind.StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 156 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */ || - token === 79 /* Identifier */ || + return token !== 156 /* SyntaxKind.FromKeyword */ && (token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */ || + token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 63 /* EqualsToken */) { + else if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 27 /* CommaToken */) { + else if (token === 27 /* SyntaxKind.CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -143956,18 +144668,18 @@ var ts; return true; } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -143975,15 +144687,15 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 127 /* AsKeyword */) { + if (token === 127 /* SyntaxKind.AsKeyword */) { token = nextToken(); - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -143999,31 +144711,31 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 93 /* ExportKeyword */) { + if (token === 93 /* SyntaxKind.ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */; + return token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */; }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -144031,31 +144743,31 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 100 /* ImportKeyword */) { + else if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 79 /* Identifier */ || + return token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 63 /* EqualsToken */) { + if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -144069,12 +144781,12 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 146 /* RequireKeyword */) { + if (token === 146 /* SyntaxKind.RequireKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || - allowTemplateLiterals && token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || + allowTemplateLiterals && token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // require("mod"); recordModuleName(); } @@ -144085,16 +144797,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* SyntaxKind.Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 20 /* OpenParenToken */) { + if (token !== 20 /* SyntaxKind.OpenParenToken */) { return true; } token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 27 /* CommaToken */) { + if (token === 27 /* SyntaxKind.CommaToken */) { token = nextToken(); } else { @@ -144103,15 +144815,15 @@ var ts; } } // should be start of dependency list - if (token !== 22 /* OpenBracketToken */) { + if (token !== 22 /* SyntaxKind.OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* SyntaxKind.CloseBracketToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { // record string literals as module names - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { recordModuleName(); } token = nextToken(); @@ -144139,31 +144851,31 @@ var ts; // AnySymbol.import("mod") // AnySymbol.nested.import("mod") while (true) { - if (ts.scanner.getToken() === 1 /* EndOfFileToken */) { + if (ts.scanner.getToken() === 1 /* SyntaxKind.EndOfFileToken */) { break; } - if (ts.scanner.getToken() === 15 /* TemplateHead */) { + if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) { var stack = [ts.scanner.getToken()]; var token = ts.scanner.scan(); loop: while (ts.length(stack)) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: tryConsumeImport(); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: stack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.length(stack)) { stack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (ts.length(stack)) { - if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) { - if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) { + if (ts.lastOrUndefined(stack) === 15 /* SyntaxKind.TemplateHead */) { + if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* SyntaxKind.TemplateTail */) { stack.pop(); } } @@ -144250,13 +144962,13 @@ var ts; if (!symbol) { if (ts.isStringLiteralLike(node)) { var type = ts.getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker); - if (type && ((type.flags & 128 /* StringLiteral */) || ((type.flags & 1048576 /* Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* StringLiteral */); })))) { - return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile); + if (type && ((type.flags & 128 /* TypeFlags.StringLiteral */) || ((type.flags & 1048576 /* TypeFlags.Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); })))) { + return getRenameInfoSuccess(node.text, node.text, "string" /* ScriptElementKind.string */, "", node, sourceFile); } } else if (ts.isLabelName(node)) { var name = ts.getTextOfNode(node); - return getRenameInfoSuccess(name, name, "label" /* label */, "" /* none */, node, sourceFile); + return getRenameInfoSuccess(name, name, "label" /* ScriptElementKind.label */, "" /* ScriptElementKindModifier.none */, node, sourceFile); } return undefined; } @@ -144269,7 +144981,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* SymbolFlags.Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { @@ -144281,7 +144993,7 @@ var ts; return getRenameInfoError(wouldRenameNodeModules); } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -144290,10 +145002,10 @@ var ts; } function isDefinedInLibraryFile(program, declaration) { var sourceFile = declaration.getSourceFile(); - return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Extension.Dts */); } function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) { - if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) { + if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* SymbolFlags.Alias */) { var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); }); if (importSpecifier && !importSpecifier.propertyName) { symbol = checker.getAliasedSymbol(symbol); @@ -144319,7 +145031,7 @@ var ts; if (declPackage) { var length_2 = Math.min(originalPackage.length, declPackage.length); for (var i = 0; i <= length_2; i++) { - if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) { + if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* Comparison.EqualTo */) { return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder; } } @@ -144344,7 +145056,7 @@ var ts; return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); var name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; - var kind = withoutIndex === undefined ? "module" /* moduleElement */ : "directory" /* directory */; + var kind = withoutIndex === undefined ? "module" /* ScriptElementKind.moduleElement */ : "directory" /* ScriptElementKind.directory */; var indexAfterLastSlash = node.text.lastIndexOf("/") + 1; // Span should only be the last component of the path. + 1 to account for the quote character. var triggerSpan = ts.createTextSpan(node.getStart(sourceFile) + 1 + indexAfterLastSlash, node.text.length - indexAfterLastSlash); @@ -144354,7 +145066,7 @@ var ts; kind: kind, displayName: name, fullDisplayName: name, - kindModifiers: "" /* none */, + kindModifiers: "" /* ScriptElementKindModifier.none */, triggerSpan: triggerSpan, }; } @@ -144384,13 +145096,13 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return true; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); default: return false; @@ -144405,7 +145117,7 @@ var ts; var SmartSelectionRange; (function (SmartSelectionRange) { function getSmartSelectionRange(pos, sourceFile) { - var _a; + var _a, _b; var selectionRange = { textSpan: ts.createTextSpanFromBounds(sourceFile.getFullStart(), sourceFile.getEnd()) }; @@ -144422,7 +145134,7 @@ var ts; break outer; } var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); - if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment && comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { pushSelectionCommentRange(comment.pos, comment.end); } if (positionShouldSnapToNode(sourceFile, pos, node)) { @@ -144457,6 +145169,17 @@ var ts; if (ts.hasJSDocNodes(node) && ((_a = node.jsDoc) === null || _a === void 0 ? void 0 : _a.length)) { pushSelectionRange(ts.first(node.jsDoc).getStart(), end); } + // (#39618 & #49807) + // When the node is a SyntaxList and its first child has a JSDoc comment, then the node's + // `start` (which usually is the result of calling `node.getStart()`) points to the first + // token after the JSDoc comment. So, we have to make sure we'd pushed the selection + // covering the JSDoc comment before diving further. + if (ts.isSyntaxList(node)) { + var firstChild = node.getChildren()[0]; + if (firstChild && ts.hasJSDocNodes(firstChild) && ((_b = firstChild.jsDoc) === null || _b === void 0 ? void 0 : _b.length) && firstChild.getStart() !== node.pos) { + start = Math.min(start, ts.first(firstChild.jsDoc).getStart()); + } + } pushSelectionRange(start, end); // String literals should have a stop both inside and outside their quotes. if (ts.isStringLiteral(node) || ts.isTemplateLiteral(node)) { @@ -144490,7 +145213,7 @@ var ts; function pushSelectionCommentRange(start, end) { pushSelectionRange(start, end); var pos = start; - while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + while (sourceFile.text.charCodeAt(pos) === 47 /* CharacterCodes.slash */) { pos++; } pushSelectionRange(pos, end); @@ -144530,6 +145253,7 @@ var ts; * other as well as of other top-level statements and declarations. */ function getSelectionChildren(node) { + var _a; // Group top-level imports if (ts.isSourceFile(node)) { return groupChildren(node.getChildAt(0).getChildren(), isImport); @@ -144545,28 +145269,28 @@ var ts; // because it allows the mapped type to become an object type with a // few keystrokes. if (ts.isMappedTypeNode(node)) { - var _a = node.getChildren(), openBraceToken = _a[0], children = _a.slice(1); + var _b = node.getChildren(), openBraceToken = _b[0], children = _b.slice(1); var closeBraceToken = ts.Debug.checkDefined(children.pop()); - ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */); - ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); + ts.Debug.assertEqual(openBraceToken.kind, 18 /* SyntaxKind.OpenBraceToken */); + ts.Debug.assertEqual(closeBraceToken.kind, 19 /* SyntaxKind.CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 145 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 57 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 145 /* SyntaxKind.ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* SyntaxKind.QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; - return kind === 22 /* OpenBracketToken */ || - kind === 163 /* TypeParameter */ || - kind === 23 /* CloseBracketToken */; + return kind === 22 /* SyntaxKind.OpenBracketToken */ || + kind === 163 /* SyntaxKind.TypeParameter */ || + kind === 23 /* SyntaxKind.CloseBracketToken */; }); return [ openBraceToken, // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; })), closeBraceToken, ]; @@ -144576,10 +145300,13 @@ var ts; var children = groupChildren(node.getChildren(), function (child) { return child === node.name || ts.contains(node.modifiers, child); }); - return splitChildren(children, function (_a) { + var firstJSDocChild = ((_a = children[0]) === null || _a === void 0 ? void 0 : _a.kind) === 320 /* SyntaxKind.JSDoc */ ? children[0] : undefined; + var withJSDocSeparated = firstJSDocChild ? children.slice(1) : children; + var splittedChildren = splitChildren(withJSDocSeparated, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; }); + return firstJSDocChild ? [firstJSDocChild, createSyntaxList(splittedChildren)] : splittedChildren; } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. if (ts.isParameter(node)) { @@ -144591,14 +145318,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } return node.getChildren(); @@ -144654,7 +145381,7 @@ var ts; var leftChildren = children.slice(0, splitTokenIndex); var splitToken = children[splitTokenIndex]; var lastToken = ts.last(children); - var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SemicolonToken */; + var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */; var rightChildren = children.slice(splitTokenIndex + 1, separateLastToken ? children.length - 1 : undefined); var result = ts.compact([ leftChildren.length ? createSyntaxList(leftChildren) : undefined, @@ -144669,25 +145396,25 @@ var ts; } function isListOpener(token) { var kind = token && token.kind; - return kind === 18 /* OpenBraceToken */ - || kind === 22 /* OpenBracketToken */ - || kind === 20 /* OpenParenToken */ - || kind === 280 /* JsxOpeningElement */; + return kind === 18 /* SyntaxKind.OpenBraceToken */ + || kind === 22 /* SyntaxKind.OpenBracketToken */ + || kind === 20 /* SyntaxKind.OpenParenToken */ + || kind === 280 /* SyntaxKind.JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; - return kind === 19 /* CloseBraceToken */ - || kind === 23 /* CloseBracketToken */ - || kind === 21 /* CloseParenToken */ - || kind === 281 /* JsxClosingElement */; + return kind === 19 /* SyntaxKind.CloseBraceToken */ + || kind === 23 /* SyntaxKind.CloseBracketToken */ + || kind === 21 /* SyntaxKind.CloseParenToken */ + || kind === 281 /* SyntaxKind.JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 340 /* JSDocParameterTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 345 /* JSDocTypedefTag */: - case 342 /* JSDocThisTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 342 /* SyntaxKind.JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -144734,7 +145461,7 @@ var ts; return ts.isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined; } return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { - return candidateInfo.kind === 0 /* Candidate */ + return candidateInfo.kind === 0 /* CandidateOrTypeKind.Candidate */ ? createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker) : createTypeHelpItems(candidateInfo.symbol, argumentInfo, sourceFile, typeChecker); }); @@ -144748,27 +145475,27 @@ var ts; function getCandidateOrTypeInfo(_a, checker, sourceFile, startingToken, onlyUseSyntacticOwners) { var invocation = _a.invocation, argumentCount = _a.argumentCount; switch (invocation.kind) { - case 0 /* Call */: { + case 0 /* InvocationKind.Call */: { if (onlyUseSyntacticOwners && !isSyntacticOwner(startingToken, invocation.node, sourceFile)) { return undefined; } var candidates = []; var resolvedSignature = checker.getResolvedSignatureForSignatureHelp(invocation.node, candidates, argumentCount); // TODO: GH#18217 - return candidates.length === 0 ? undefined : { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; + return candidates.length === 0 ? undefined : { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; } - case 1 /* TypeArgs */: { + case 1 /* InvocationKind.TypeArgs */: { var called = invocation.called; if (onlyUseSyntacticOwners && !containsPrecedingToken(startingToken, sourceFile, ts.isIdentifier(called) ? called.parent : called)) { return undefined; } var candidates = ts.getPossibleGenericSignatures(called, argumentCount, checker); if (candidates.length !== 0) - return { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; var symbol = checker.getSymbolAtLocation(called); - return symbol && { kind: 1 /* Type */, symbol: symbol }; + return symbol && { kind: 1 /* CandidateOrTypeKind.Type */, symbol: symbol }; } - case 2 /* Contextual */: - return { kind: 0 /* Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; + case 2 /* InvocationKind.Contextual */: + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; default: return ts.Debug.assertNever(invocation); } @@ -144778,20 +145505,20 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 27 /* CommaToken */: { + case 27 /* SyntaxKind.CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; } } function createJSSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind === 2 /* Contextual */) + if (argumentInfo.invocation.kind === 2 /* InvocationKind.Contextual */) return undefined; // See if we can find some symbol with the call expression name that has call signatures. var expression = getExpressionFromInvocation(argumentInfo.invocation); @@ -144827,7 +145554,7 @@ var ts; } function getArgumentInfoForCompletions(node, position, sourceFile) { var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); - return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? undefined + return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* InvocationKind.Call */ ? undefined : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; } SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; @@ -144844,7 +145571,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* SyntaxKind.LessThanToken */ || node.kind === 20 /* SyntaxKind.OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -144887,7 +145614,7 @@ var ts; return undefined; var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var isTypeParameterList = !!parent.typeArguments && parent.typeArguments.pos === list.pos; - return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* InvocationKind.Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { // Check if we're actually inside the template; @@ -144897,10 +145624,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 223 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 223 /* SyntaxKind.TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -144925,7 +145652,7 @@ var ts; var attributeSpanEnd = ts.skipTrivia(sourceFile.text, parent.attributes.end, /*stopAfterLineBreak*/ false); return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: parent }, + invocation: { kind: 0 /* InvocationKind.Call */, node: parent }, argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), argumentIndex: 0, argumentCount: 1 @@ -144935,7 +145662,7 @@ var ts; var typeArgInfo = ts.getPossibleTypeArgumentsInfo(node, sourceFile); if (typeArgInfo) { var called = typeArgInfo.called, nTypeArguments = typeArgInfo.nTypeArguments; - var invocation = { kind: 1 /* TypeArgs */, called: called }; + var invocation = { kind: 1 /* InvocationKind.TypeArgs */, called: called }; var argumentsSpan = ts.createTextSpanFromBounds(called.getStart(sourceFile), node.end); return { isTypeParameterList: true, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: nTypeArguments, argumentCount: nTypeArguments + 1 }; } @@ -144964,28 +145691,28 @@ var ts; var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures()); if (signature === undefined) return undefined; - var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; + var invocation = { kind: 2 /* InvocationKind.Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) { - if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) + if (startingToken.kind !== 20 /* SyntaxKind.OpenParenToken */ && startingToken.kind !== 27 /* SyntaxKind.CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* SyntaxKind.OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; var argumentCount_1 = countBinaryExpressionParameters(highestBinary); return contextualType_1 && { contextualType: contextualType_1, argumentIndex: argumentIndex_1, argumentCount: argumentCount_1, argumentsSpan: ts.createTextSpanFromNode(parent) }; } @@ -144995,7 +145722,7 @@ var ts; } // The type of a function type node has a symbol at that node, but it's better to use the symbol for a parameter or type alias. function chooseBetterSymbol(s) { - return s.name === "__type" /* Type */ + return s.name === "__type" /* InternalSymbolName.Type */ ? ts.firstDefined(s.declarations, function (d) { return ts.isFunctionTypeNode(d) ? d.parent.symbol : undefined; }) || s : s; } @@ -145017,7 +145744,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 27 /* CommaToken */) { + if (child.kind !== 27 /* SyntaxKind.CommaToken */) { argumentIndex++; } } @@ -145036,8 +145763,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); - if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* SyntaxKind.CommaToken */; }); + if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* SyntaxKind.CommaToken */) { argumentCount++; } return argumentCount; @@ -145075,7 +145802,7 @@ var ts; } return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: tagExpression }, + invocation: { kind: 0 /* InvocationKind.Call */, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -145106,7 +145833,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -145115,17 +145842,17 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) { - var _loop_8 = function (n) { + var _loop_7 = function (n) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. - ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); }); + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: ".concat(ts.Debug.formatSyntaxKind(n.kind), ", parent: ").concat(ts.Debug.formatSyntaxKind(n.parent.kind)); }); var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker); if (argumentInfo) { return { value: argumentInfo }; } }; for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) { - var state_4 = _loop_8(n); + var state_4 = _loop_7(n); if (typeof state_4 === "object") return state_4.value; } @@ -145138,17 +145865,17 @@ var ts; return children[indexOfOpenerToken + 1]; } function getExpressionFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; + return invocation.kind === 0 /* InvocationKind.Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; } function getEnclosingDeclarationFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? invocation.node : invocation.kind === 1 /* TypeArgs */ ? invocation.called : invocation.node; + return invocation.kind === 0 /* InvocationKind.Call */ ? invocation.node : invocation.kind === 1 /* InvocationKind.TypeArgs */ ? invocation.called : invocation.node; } - var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var signatureHelpNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; function createSignatureHelpItems(candidates, resolvedSignature, _a, sourceFile, typeChecker, useFullPrefix) { var _b; var isTypeParameterList = _a.isTypeParameterList, argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; var enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation); - var callTargetSymbol = invocation.kind === 2 /* Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); + var callTargetSymbol = invocation.kind === 2 /* InvocationKind.Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); var callTargetDisplayParts = callTargetSymbol ? ts.symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : ts.emptyArray; var items = ts.map(candidates, function (candidateSignature) { return getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile); }); if (argumentIndex !== 0) { @@ -145205,10 +145932,10 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(checker); - var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* LessThanToken */)], false); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], false); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile); return ts.map(infos, function (_a) { @@ -145241,9 +145968,9 @@ var ts; return checker.getExpandedParameters(candidateSignature).map(function (paramList) { var params = ts.factory.createNodeArray(__spreadArray(__spreadArray([], thisParameter, true), ts.map(paramList, function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }), true)); var parameterParts = ts.mapToDisplayParts(function (writer) { - printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* ListFormat.CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts, true) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], parameterParts, true) }; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { @@ -145251,33 +145978,33 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.factory.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration, signatureHelpNodeBuilderFlags); })); - printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* ListFormat.TypeParameters */, args, sourceFile, writer); } }); var lists = checker.getExpandedParameters(candidateSignature); var isVariadic = !checker.hasEffectiveRestParameter(candidateSignature) ? function (_) { return false; } : lists.length === 1 ? function (_) { return true; } - : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* RestParameter */); }; + : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* CheckFlags.RestParameter */); }; return lists.map(function (parameterList) { return ({ isVariadic: isVariadic(parameterList), parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* OpenParenToken */)], false), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)], false), + suffix: [ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - var isRest = !!(parameter.checkFlags & 32768 /* RestParameter */); + var isRest = !!(parameter.checkFlags & 32768 /* CheckFlags.RestParameter */); return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional, isRest: isRest }; } function createSignatureHelpParameterForTypeParameter(typeParameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } @@ -145290,7 +146017,7 @@ var ts; (function (InlayHints) { var maxHintsLength = 30; var leadingParameterNameCommentRegexFactory = function (name) { - return new RegExp("^\\s?/\\*\\*?\\s?" + name + "\\s?\\*\\/\\s?$"); + return new RegExp("^\\s?/\\*\\*?\\s?".concat(name, "\\s?\\*\\/\\s?$")); }; function shouldShowParameterNameHints(preferences) { return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all"; @@ -145311,14 +146038,14 @@ var ts; return; } switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) { @@ -145354,25 +146081,25 @@ var ts; } function addParameterHints(text, position, isFirstVariadicArgument) { result.push({ - text: "" + (isFirstVariadicArgument ? "..." : "") + truncation(text, maxHintsLength) + ":", + text: "".concat(isFirstVariadicArgument ? "..." : "").concat(truncation(text, maxHintsLength), ":"), position: position, - kind: "Parameter" /* Parameter */, + kind: "Parameter" /* InlayHintKind.Parameter */, whitespaceAfter: true, }); } function addTypeHints(text, position) { result.push({ - text: ": " + truncation(text, maxHintsLength), + text: ": ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Type" /* Type */, + kind: "Type" /* InlayHintKind.Type */, whitespaceBefore: true, }); } function addEnumMemberValueHints(text, position) { result.push({ - text: "= " + truncation(text, maxHintsLength), + text: "= ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Enum" /* Enum */, + kind: "Enum" /* InlayHintKind.Enum */, whitespaceBefore: true, }); } @@ -145386,7 +146113,7 @@ var ts; } } function isModuleReferenceType(type) { - return type.symbol && (type.symbol.flags & 1536 /* Module */); + return type.symbol && (type.symbol.flags & 1536 /* SymbolFlags.Module */); } function visitVariableLikeDeclaration(decl) { if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) { @@ -145462,17 +146189,17 @@ var ts; } function isHintableLiteral(node) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; return ts.isLiteralExpression(operand) || ts.isIdentifier(operand) && ts.isInfinityOrNaNString(operand.escapedText); } - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var name = node.escapedText; return isUndefined(name) || ts.isInfinityOrNaNString(name); } @@ -145481,7 +146208,7 @@ var ts; } function visitFunctionDeclarationLikeForReturnType(decl) { if (ts.isArrowFunction(decl)) { - if (!ts.findChildOfKind(decl, 20 /* OpenParenToken */, file)) { + if (!ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, file)) { return; } } @@ -145504,7 +146231,7 @@ var ts; addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl)); } function getTypeAnnotationPosition(decl) { - var closeParenToken = ts.findChildOfKind(decl, 21 /* CloseParenToken */, file); + var closeParenToken = ts.findChildOfKind(decl, 21 /* SyntaxKind.CloseParenToken */, file); if (closeParenToken) { return closeParenToken.end; } @@ -145549,13 +146276,13 @@ var ts; return text; } function printTypeInSingleLine(type) { - var flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var flags = 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; var options = { removeComments: true }; var printer = ts.createPrinter(options); return ts.usingSingleLineStringWriter(function (writer) { var typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer); ts.Debug.assertIsDefined(typeNode, "should always get typenode"); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ file, writer); }); } function isUndefined(name) { @@ -145624,7 +146351,7 @@ var ts; var options = program.getCompilerOptions(); var outPath = ts.outFile(options); var declarationPath = outPath ? - ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; @@ -145733,7 +146460,7 @@ var ts; program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; var checker = program.getTypeChecker(); - var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]); + var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]); if (!isCommonJSFile && sourceFile.commonJsModuleIndicator && (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) && @@ -145769,7 +146496,7 @@ var ts; else { if (ts.isVariableStatement(node) && node.parent === sourceFile && - node.declarationList.flags & 2 /* Const */ && + node.declarationList.flags & 2 /* NodeFlags.Const */ && node.declarationList.declarations.length === 1) { var init = node.declarationList.declarations[0].initializer; if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { @@ -145791,16 +146518,16 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); var kind = ts.getAssignmentDeclarationKind(expression); - return kind === 1 /* ExportsProperty */ || kind === 2 /* ModuleExports */; + return kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ || kind === 2 /* AssignmentDeclarationKind.ModuleExports */; } default: return false; @@ -145812,12 +146539,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -145887,26 +146614,26 @@ var ts; if (node.arguments.length < maxArguments) return true; return maxArguments === 1 || ts.some(node.arguments, function (arg) { - return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; + return arg.kind === 104 /* SyntaxKind.NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var functionFlags = ts.getFunctionFlags(arg); - if (functionFlags & 1 /* Generator */) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { return false; } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return true; - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: { + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: { var symbol = checker.getSymbolAtLocation(arg); if (!symbol) { return false; @@ -145919,28 +146646,28 @@ var ts; } } function getKeyFromNode(exp) { - return exp.pos.toString() + ":" + exp.end.toString(); + return "".concat(exp.pos.toString(), ":").concat(exp.end.toString()); } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 213 /* FunctionExpression */) { + if (node.kind === 213 /* SyntaxKind.FunctionExpression */) { if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) { return true; } var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false); return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size))); } - if (node.kind === 256 /* FunctionDeclaration */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } function canBeConvertedToAsync(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -145953,32 +146680,32 @@ var ts; (function (ts) { var SymbolDisplay; (function (SymbolDisplay) { - var symbolDisplayNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var symbolDisplayNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(typeChecker, symbol, location) { var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result !== "" /* unknown */) { + if (result !== "" /* ScriptElementKind.unknown */) { return result; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; - } - if (flags & 384 /* Enum */) - return "enum" /* enumElement */; - if (flags & 524288 /* TypeAlias */) - return "type" /* typeElement */; - if (flags & 64 /* Interface */) - return "interface" /* interfaceElement */; - if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; - if (flags & 8 /* EnumMember */) - return "enum member" /* enumMemberElement */; - if (flags & 2097152 /* Alias */) - return "alias" /* alias */; - if (flags & 1536 /* Module */) - return "module" /* moduleElement */; + if (flags & 32 /* SymbolFlags.Class */) { + return ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */) ? + "local class" /* ScriptElementKind.localClassElement */ : "class" /* ScriptElementKind.classElement */; + } + if (flags & 384 /* SymbolFlags.Enum */) + return "enum" /* ScriptElementKind.enumElement */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + return "type" /* ScriptElementKind.typeElement */; + if (flags & 64 /* SymbolFlags.Interface */) + return "interface" /* ScriptElementKind.interfaceElement */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + return "type parameter" /* ScriptElementKind.typeParameterElement */; + if (flags & 8 /* SymbolFlags.EnumMember */) + return "enum member" /* ScriptElementKind.enumMemberElement */; + if (flags & 2097152 /* SymbolFlags.Alias */) + return "alias" /* ScriptElementKind.alias */; + if (flags & 1536 /* SymbolFlags.Module */) + return "module" /* ScriptElementKind.moduleElement */; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; @@ -145986,52 +146713,52 @@ var ts; var roots = typeChecker.getRootSymbols(symbol); // If this is a method from a mapped type, leave as a method so long as it still has a call signature. if (roots.length === 1 - && ts.first(roots).flags & 8192 /* Method */ + && ts.first(roots).flags & 8192 /* SymbolFlags.Method */ // Ensure the mapped version is still a method, as opposed to `{ [K in keyof I]: number }`. && typeChecker.getTypeOfSymbolAtLocation(symbol, location).getNonNullableType().getCallSignatures().length !== 0) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } if (typeChecker.isUndefinedSymbol(symbol)) { - return "var" /* variableElement */; + return "var" /* ScriptElementKind.variableElement */; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var" /* localVariableElement */; + return "local var" /* ScriptElementKind.localVariableElement */; } - if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { - return "parameter" /* parameterElement */; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { + return "parameter" /* ScriptElementKind.parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter" /* parameterElement */; + return "parameter" /* ScriptElementKind.parameterElement */; } else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { - return "const" /* constElement */; + return "const" /* ScriptElementKind.constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let" /* letElement */; + return "let" /* ScriptElementKind.letElement */; } - return isLocalVariableOrFunction(symbol) ? "local var" /* localVariableElement */ : "var" /* variableElement */; + return isLocalVariableOrFunction(symbol) ? "local var" /* ScriptElementKind.localVariableElement */ : "var" /* ScriptElementKind.variableElement */; } - if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */; + if (flags & 16 /* SymbolFlags.Function */) + return isLocalVariableOrFunction(symbol) ? "local function" /* ScriptElementKind.localFunctionElement */ : "function" /* ScriptElementKind.functionElement */; // FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag. // So, even when the location is just on the declaration of setter, this function returns getter. - if (flags & 32768 /* GetAccessor */) - return "getter" /* memberGetAccessorElement */; - if (flags & 65536 /* SetAccessor */) - return "setter" /* memberSetAccessorElement */; - if (flags & 8192 /* Method */) - return "method" /* memberFunctionElement */; - if (flags & 16384 /* Constructor */) - return "constructor" /* constructorImplementationElement */; - if (flags & 4 /* Property */) { - if (flags & 33554432 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { + if (flags & 32768 /* SymbolFlags.GetAccessor */) + return "getter" /* ScriptElementKind.memberGetAccessorElement */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + return "setter" /* ScriptElementKind.memberSetAccessorElement */; + if (flags & 8192 /* SymbolFlags.Method */) + return "method" /* ScriptElementKind.memberFunctionElement */; + if (flags & 16384 /* SymbolFlags.Constructor */) + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + if (flags & 4 /* SymbolFlags.Property */) { + if (flags & 33554432 /* SymbolFlags.Transient */ && symbol.checkFlags & 6 /* CheckFlags.Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return "property" /* memberVariableElement */; + if (rootSymbolFlags & (98308 /* SymbolFlags.PropertyOrAccessor */ | 3 /* SymbolFlags.Variable */)) { + return "property" /* ScriptElementKind.memberVariableElement */; } }); if (!unionPropertyKind) { @@ -146039,23 +146766,23 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } return unionPropertyKind; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getNormalizedSymbolModifiers(symbol) { if (symbol.declarations && symbol.declarations.length) { var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* ModifierFlags.Deprecated */ + : 0 /* ModifierFlags.None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -146065,10 +146792,10 @@ var ts; } function getSymbolModifiers(typeChecker, symbol) { if (!symbol) { - return "" /* none */; + return "" /* ScriptElementKindModifier.none */; } var modifiers = new ts.Set(getNormalizedSymbolModifiers(symbol)); - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); if (resolvedSymbol !== symbol) { ts.forEach(getNormalizedSymbolModifiers(resolvedSymbol), function (modifier) { @@ -146076,10 +146803,10 @@ var ts; }); } } - if (symbol.flags & 16777216 /* Optional */) { - modifiers.add("optional" /* optionalModifier */); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + modifiers.add("optional" /* ScriptElementKindModifier.optionalModifier */); } - return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* none */; + return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* ScriptElementKindModifier.none */; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location @@ -146090,41 +146817,41 @@ var ts; var documentation = []; var tags = []; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; + var symbolKind = semanticMeaning & 1 /* SemanticMeaning.Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* ScriptElementKind.unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); + var isThisExpression = location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* ScriptElementKind.primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */ || symbolFlags & 32 /* SymbolFlags.Class */ || symbolFlags & 2097152 /* SymbolFlags.Alias */) { // If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor - if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) { + if (symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */) { var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; }); if (declaration) { switch (declaration.kind) { - case 172 /* GetAccessor */: - symbolKind = "getter" /* memberGetAccessorElement */; + case 172 /* SyntaxKind.GetAccessor */: + symbolKind = "getter" /* ScriptElementKind.memberGetAccessorElement */; break; - case 173 /* SetAccessor */: - symbolKind = "setter" /* memberSetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: + symbolKind = "setter" /* ScriptElementKind.memberSetAccessorElement */; break; default: ts.Debug.assertNever(declaration); } } else { - symbolKind = "property" /* memberVariableElement */; + symbolKind = "property" /* ScriptElementKind.memberVariableElement */; } } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (location.parent && location.parent.kind === 206 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -146144,7 +146871,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 209 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 209 /* SyntaxKind.NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SyntaxKind.SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -146152,21 +146879,21 @@ var ts; signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + if (useConstructSignatures && (symbolFlags & 32 /* SymbolFlags.Class */)) { // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - else if (symbolFlags & 2097152 /* Alias */) { - symbolKind = "alias" /* alias */; + else if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + symbolKind = "alias" /* ScriptElementKind.alias */; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -146175,29 +146902,29 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: + case "JSX attribute" /* ScriptElementKind.jsxAttribute */: + case "property" /* ScriptElementKind.memberVariableElement */: + case "var" /* ScriptElementKind.variableElement */: + case "const" /* ScriptElementKind.constElement */: + case "let" /* ScriptElementKind.letElement */: + case "parameter" /* ScriptElementKind.parameterElement */: + case "local var" /* ScriptElementKind.localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); - if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); + if (!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* SymbolFormatFlags.AllowAnyNodeKind */ | 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); + addSignatureDisplayParts(signature, allSignatures, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */); break; default: // Just signature @@ -146207,31 +146934,31 @@ var ts; hasMultipleSignatures = allSignatures.length > 1; } } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 134 /* ConstructorKeyword */ && location.parent.kind === 171 /* Constructor */)) { // At constructor keyword of constructor declaration + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* SymbolFlags.Accessor */)) || // name of function declaration + (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ && location.parent.kind === 171 /* SyntaxKind.Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 134 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 171 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 171 /* Constructor */) { + if (functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */) { // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* SyntaxKind.CallSignature */ && + !(type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ || type.symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */) ? type.symbol : symbol, symbolKind); } if (signature) { addSignatureDisplayParts(signature, allSignatures); @@ -146241,63 +146968,63 @@ var ts; } } } - if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { + if (symbolFlags & 32 /* SymbolFlags.Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushSymbolKind("local class" /* localClassElement */); + pushSymbolKind("local class" /* ScriptElementKind.localClassElement */); } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* SyntaxKind.ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 64 /* SymbolFlags.Interface */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* SyntaxKind.InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 524288 /* SymbolFlags.TypeAlias */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* TypeFormatFlags.InTypeAlias */)); } - if (symbolFlags & 384 /* Enum */) { + if (symbolFlags & 384 /* SymbolFlags.Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* SyntaxKind.ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* SyntaxKind.EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if (symbolFlags & 1536 /* Module */ && !isThisExpression) { + if (symbolFlags & 1536 /* SymbolFlags.Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 261 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 142 /* NamespaceKeyword */ : 141 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 261 /* SyntaxKind.ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* SyntaxKind.Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 142 /* SyntaxKind.NamespaceKeyword */ : 141 /* SyntaxKind.ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 262144 /* SymbolFlags.TypeParameter */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -146308,7 +147035,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 163 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -146316,21 +147043,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 175 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + if (declaration.kind === 175 /* SyntaxKind.ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 174 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 174 /* SyntaxKind.CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 259 /* TypeAliasDeclaration */) { + else if (declaration.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -146338,22 +147065,22 @@ var ts; } } } - if (symbolFlags & 8 /* EnumMember */) { - symbolKind = "enum member" /* enumMemberElement */; + if (symbolFlags & 8 /* SymbolFlags.EnumMember */) { + symbolKind = "enum member" /* ScriptElementKind.enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; - if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* EnumMember */) { + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* SyntaxKind.EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } } } // don't use symbolFlags since getAliasedSymbol requires the flag on the symbol itself - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { prefixNextMeaning(); if (!hasAddedSymbolInfo) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); @@ -146362,7 +147089,7 @@ var ts; var declarationName = ts.getNameOfDeclaration(resolvedNode); if (declarationName) { var isExternalModuleDeclaration = ts.isModuleWithStringLiteralName(resolvedNode) && - ts.hasSyntacticModifier(resolvedNode, 2 /* Ambient */); + ts.hasSyntacticModifier(resolvedNode, 2 /* ModifierFlags.Ambient */); var shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration; var resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, resolvedSymbol, ts.getSourceFileOfNode(resolvedNode), resolvedNode, declarationName, semanticMeaning, shouldUseAliasName ? symbol : resolvedSymbol); displayParts.push.apply(displayParts, resolvedInfo.displayParts); @@ -146378,42 +147105,42 @@ var ts; } if (symbol.declarations) { switch (symbol.declarations[0].kind) { - case 264 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(142 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(142 /* SyntaxKind.NamespaceKeyword */)); break; - case 271 /* ExportAssignment */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 271 /* SyntaxKind.ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* SyntaxKind.EqualsToken */ : 88 /* SyntaxKind.DefaultKeyword */)); break; - case 275 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 275 /* SyntaxKind.ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(100 /* SyntaxKind.ImportKeyword */)); } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(146 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(146 /* SyntaxKind.RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -146423,30 +147150,30 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "" /* unknown */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */) { if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === "property" /* memberVariableElement */ || - symbolKind === "getter" /* memberGetAccessorElement */ || - symbolKind === "setter" /* memberSetAccessorElement */ || - symbolKind === "JSX attribute" /* jsxAttribute */ || - symbolFlags & 3 /* Variable */ || - symbolKind === "local var" /* localVariableElement */ || + if (symbolKind === "property" /* ScriptElementKind.memberVariableElement */ || + symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || + symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */ || + symbolKind === "JSX attribute" /* ScriptElementKind.jsxAttribute */ || + symbolFlags & 3 /* SymbolFlags.Variable */ || + symbolKind === "local var" /* ScriptElementKind.localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially - if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + if (type.symbol && type.symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeNode(4 /* EmitHint.Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -146457,17 +147184,17 @@ var ts; var labelDecl = symbol.target.tupleLabelDeclaration; ts.Debug.assertNode(labelDecl.name, ts.isIdentifier); displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart(ts.idText(labelDecl.name))); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } } - else if (symbolFlags & 16 /* Function */ || - symbolFlags & 8192 /* Method */ || - symbolFlags & 16384 /* Constructor */ || - symbolFlags & 131072 /* Signature */ || - symbolFlags & 98304 /* Accessor */ || - symbolKind === "method" /* memberFunctionElement */) { + else if (symbolFlags & 16 /* SymbolFlags.Function */ || + symbolFlags & 8192 /* SymbolFlags.Method */ || + symbolFlags & 16384 /* SymbolFlags.Constructor */ || + symbolFlags & 131072 /* SymbolFlags.Signature */ || + symbolFlags & 98304 /* SymbolFlags.Accessor */ || + symbolKind === "method" /* ScriptElementKind.memberFunctionElement */) { var allSignatures = type.getNonNullableType().getCallSignatures(); if (allSignatures.length) { addSignatureDisplayParts(allSignatures[0], allSignatures); @@ -146483,14 +147210,14 @@ var ts; if (documentation.length === 0 && !hasMultipleSignatures) { documentation = symbol.getContextualDocumentationComment(enclosingDeclaration, typeChecker); } - if (documentation.length === 0 && symbolFlags & 4 /* Property */) { + if (documentation.length === 0 && symbolFlags & 4 /* SymbolFlags.Property */) { // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SourceFile */; })) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SyntaxKind.SourceFile */; })) { for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (!declaration.parent || declaration.parent.kind !== 221 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -146541,23 +147268,23 @@ var ts; } function addAliasPrefixIfNecessary() { if (alias) { - pushSymbolKind("alias" /* alias */); + pushSymbolKind("alias" /* ScriptElementKind.alias */); displayParts.push(ts.spacePart()); } } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(101 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* SyntaxKind.InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { if (alias && symbolToDisplay === symbol) { symbolToDisplay = alias; } - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */ | 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); - if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + displayParts.push(ts.punctuationPart(57 /* SyntaxKind.QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -146572,31 +147299,31 @@ var ts; } function pushSymbolKind(symbolKind) { switch (symbolKind) { - case "var" /* variableElement */: - case "function" /* functionElement */: - case "let" /* letElement */: - case "const" /* constElement */: - case "constructor" /* constructorImplementationElement */: + case "var" /* ScriptElementKind.variableElement */: + case "function" /* ScriptElementKind.functionElement */: + case "let" /* ScriptElementKind.letElement */: + case "const" /* ScriptElementKind.constElement */: + case "constructor" /* ScriptElementKind.constructorImplementationElement */: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); return; } } function addSignatureDisplayParts(signature, allSignatures, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(39 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); + displayParts.push(ts.operatorPart(39 /* SyntaxKind.PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } documentation = signature.getDocumentationComment(typeChecker); tags = signature.getJsDocTags(); @@ -146608,7 +147335,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* ListFormat.TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -146620,16 +147347,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 213 /* FunctionExpression */) { + if (declaration.kind === 213 /* SyntaxKind.FunctionExpression */) { return true; } - if (declaration.kind !== 254 /* VariableDeclaration */ && declaration.kind !== 256 /* FunctionDeclaration */) { + if (declaration.kind !== 254 /* SyntaxKind.VariableDeclaration */ && declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 305 /* SourceFile */ || parent.kind === 262 /* ModuleBlock */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ || parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return false; } } @@ -146738,7 +147465,7 @@ var ts; commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_9 = function (opt) { + var _loop_8 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -146757,7 +147484,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_9(opt); + _loop_8(opt); } return options; } @@ -146834,8 +147561,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* SyntaxKind.OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* SyntaxKind.CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -146853,8 +147580,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); + var jsxScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 1 /* LanguageVariant.JSX */); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -146866,7 +147593,7 @@ var ts; ScanAction[ScanAction["RescanJsxAttributeValue"] = 6] = "RescanJsxAttributeValue"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { - var scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + var scanner = languageVariant === 1 /* LanguageVariant.JSX */ ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -146894,7 +147621,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* SyntaxKind.NewLineTrivia */; } else { scanner.scan(); @@ -146922,11 +147649,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 33 /* GreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return true; } return false; @@ -146934,12 +147661,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 285 /* JsxAttribute */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 285 /* SyntaxKind.JsxAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* SyntaxKind.Identifier */; } } return false; @@ -146948,29 +147675,29 @@ var ts; return ts.isJsxText(node); } function shouldRescanSlashToken(container) { - return container.kind === 13 /* RegularExpressionLiteral */; + return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 16 /* TemplateMiddle */ || - container.kind === 17 /* TemplateTail */; + return container.kind === 16 /* SyntaxKind.TemplateMiddle */ || + container.kind === 17 /* SyntaxKind.TemplateTail */; } function shouldRescanJsxAttributeValue(node) { return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; + return t === 43 /* SyntaxKind.SlashToken */ || t === 68 /* SyntaxKind.SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : - shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : - shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : - shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : - shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* ScanAction.RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* ScanAction.RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* ScanAction.RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* ScanAction.RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* ScanAction.RescanJsxText */ : + shouldRescanJsxAttributeValue(n) ? 6 /* ScanAction.RescanJsxAttributeValue */ : + 0 /* ScanAction.Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -147002,7 +147729,7 @@ var ts; trailingTrivia = []; } trailingTrivia.push(trivia); - if (currentToken === 4 /* NewLineTrivia */) { + if (currentToken === 4 /* SyntaxKind.NewLineTrivia */) { // move past new line scanner.scan(); break; @@ -147013,40 +147740,40 @@ var ts; } function getNextToken(n, expectedScanAction) { var token = scanner.getToken(); - lastScanAction = 0 /* Scan */; + lastScanAction = 0 /* ScanAction.Scan */; switch (expectedScanAction) { - case 1 /* RescanGreaterThanToken */: - if (token === 31 /* GreaterThanToken */) { - lastScanAction = 1 /* RescanGreaterThanToken */; + case 1 /* ScanAction.RescanGreaterThanToken */: + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + lastScanAction = 1 /* ScanAction.RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 2 /* RescanSlashToken */: + case 2 /* ScanAction.RescanSlashToken */: if (startsWithSlashToken(token)) { - lastScanAction = 2 /* RescanSlashToken */; + lastScanAction = 2 /* ScanAction.RescanSlashToken */; var newToken = scanner.reScanSlashToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 3 /* RescanTemplateToken */: - if (token === 19 /* CloseBraceToken */) { - lastScanAction = 3 /* RescanTemplateToken */; + case 3 /* ScanAction.RescanTemplateToken */: + if (token === 19 /* SyntaxKind.CloseBraceToken */) { + lastScanAction = 3 /* ScanAction.RescanTemplateToken */; return scanner.reScanTemplateToken(/* isTaggedTemplate */ false); } break; - case 4 /* RescanJsxIdentifier */: - lastScanAction = 4 /* RescanJsxIdentifier */; + case 4 /* ScanAction.RescanJsxIdentifier */: + lastScanAction = 4 /* ScanAction.RescanJsxIdentifier */; return scanner.scanJsxIdentifier(); - case 5 /* RescanJsxText */: - lastScanAction = 5 /* RescanJsxText */; + case 5 /* ScanAction.RescanJsxText */: + lastScanAction = 5 /* ScanAction.RescanJsxText */; return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); - case 6 /* RescanJsxAttributeValue */: - lastScanAction = 6 /* RescanJsxAttributeValue */; + case 6 /* ScanAction.RescanJsxAttributeValue */: + lastScanAction = 6 /* ScanAction.RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); - case 0 /* Scan */: + case 0 /* ScanAction.Scan */: break; default: ts.Debug.assertNever(expectedScanAction); @@ -147055,15 +147782,15 @@ var ts; } function readEOFTokenRange() { ts.Debug.assert(isOnEOF()); - return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* SyntaxKind.EndOfFileToken */); } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); + return current !== 1 /* SyntaxKind.EndOfFileToken */ && !ts.isTrivia(current); } function isOnEOF() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current === 1 /* EndOfFileToken */; + return current === 1 /* SyntaxKind.EndOfFileToken */; } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, @@ -147130,8 +147857,8 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 160 /* LastToken */; token++) { - if (token !== 1 /* EndOfFileToken */) { + for (var token = 0 /* SyntaxKind.FirstToken */; token <= 160 /* SyntaxKind.LastToken */; token++) { + if (token !== 1 /* SyntaxKind.EndOfFileToken */) { allTokens.push(token); } } @@ -147143,263 +147870,263 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* MultiLineCommentTrivia */], false)); - var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* EndOfFileToken */], false)); - var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 160 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); - var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 160 /* OfKeyword */, 127 /* AsKeyword */, 139 /* IsKeyword */]; - var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* SyntaxKind.MultiLineCommentTrivia */], false)); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* SyntaxKind.EndOfFileToken */], false)); + var keywords = tokenRangeFromRange(81 /* SyntaxKind.FirstKeyword */, 160 /* SyntaxKind.LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* SyntaxKind.FirstBinaryOperator */, 78 /* SyntaxKind.LastBinaryOperator */); + var binaryKeywordOperators = [101 /* SyntaxKind.InKeyword */, 102 /* SyntaxKind.InstanceOfKeyword */, 160 /* SyntaxKind.OfKeyword */, 127 /* SyntaxKind.AsKeyword */, 139 /* SyntaxKind.IsKeyword */]; + var unaryPrefixOperators = [45 /* SyntaxKind.PlusPlusToken */, 46 /* SyntaxKind.MinusMinusToken */, 54 /* SyntaxKind.TildeToken */, 53 /* SyntaxKind.ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ + 8 /* SyntaxKind.NumericLiteral */, 9 /* SyntaxKind.BigIntLiteral */, 79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, + 22 /* SyntaxKind.OpenBracketToken */, 18 /* SyntaxKind.OpenBraceToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */ ]; - var unaryPreincrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostincrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var unaryPredecrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostdecrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords, true); + var unaryPreincrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostincrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPredecrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostdecrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var comments = [2 /* SyntaxKind.SingleLineCommentTrivia */, 3 /* SyntaxKind.MultiLineCommentTrivia */]; + var typeNames = __spreadArray([79 /* SyntaxKind.Identifier */], ts.typeKeywords, true); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* SyntaxKind.Identifier */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 84 /* SyntaxKind.ClassKeyword */, 93 /* SyntaxKind.ExportKeyword */, 100 /* SyntaxKind.ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* SyntaxKind.CloseParenToken */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 90 /* SyntaxKind.DoKeyword */, 111 /* SyntaxKind.TryKeyword */, 96 /* SyntaxKind.FinallyKeyword */, 91 /* SyntaxKind.ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), - rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SyntaxKind.SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* SyntaxKind.ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterColon", 58 /* SyntaxKind.ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* SyntaxKind.QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* RuleAction.InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterQuestionMark", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* SyntaxKind.ImportKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* RuleAction.DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* SyntaxKind.PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* SyntaxKind.MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* SyntaxKind.PlusPlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* SyntaxKind.PlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* SyntaxKind.PlusToken */, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* SyntaxKind.MinusMinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* SyntaxKind.MinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* SyntaxKind.MinusToken */, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, [27 /* SyntaxKind.CommaToken */, 26 /* SyntaxKind.SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* SyntaxKind.CloseBraceToken */, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), + rule("SpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, anyTokenExcept(21 /* SyntaxKind.CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* RuleAction.InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 91 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 115 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* SyntaxKind.CloseBraceToken */, 91 /* SyntaxKind.ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* SyntaxKind.CloseBraceToken */, 115 /* SyntaxKind.WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 79 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 98 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterConditionalClosingParen", 21 /* SyntaxKind.CloseParenToken */, 22 /* SyntaxKind.OpenBracketToken */, [isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* SyntaxKind.AsteriskToken */, 79 /* SyntaxKind.Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 98 /* SyntaxKind.FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [136 /* GetKeyword */, 149 /* SetKeyword */], 79 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 105 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [113 /* VarKeyword */, 109 /* ThrowKeyword */, 103 /* NewKeyword */, 89 /* DeleteKeyword */, 105 /* ReturnKeyword */, 112 /* TypeOfKeyword */, 132 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [119 /* LetKeyword */, 85 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), + rule("SpaceAfterGetSetInMember", [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */], 79 /* SyntaxKind.Identifier */, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 105 /* SyntaxKind.ReturnKeyword */, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterCertainKeywords", [113 /* SyntaxKind.VarKeyword */, 109 /* SyntaxKind.ThrowKeyword */, 103 /* SyntaxKind.NewKeyword */, 89 /* SyntaxKind.DeleteKeyword */, 105 /* SyntaxKind.ReturnKeyword */, 112 /* SyntaxKind.TypeOfKeyword */, 132 /* SyntaxKind.AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [119 /* SyntaxKind.LetKeyword */, 85 /* SyntaxKind.ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* RuleAction.DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* SyntaxKind.VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* RuleAction.InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 131 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 131 /* SyntaxKind.AsyncKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* SyntaxKind.AsyncKeyword */, [98 /* SyntaxKind.FunctionKeyword */, 79 /* SyntaxKind.Identifier */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */], [14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, 15 /* SyntaxKind.TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 79 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeJsxAttribute", anyToken, 79 /* SyntaxKind.Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SyntaxKind.SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SyntaxKind.SlashToken */, 31 /* SyntaxKind.GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* SyntaxKind.EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* SyntaxKind.EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [141 /* ModuleKeyword */, 146 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [141 /* SyntaxKind.ModuleKeyword */, 146 /* SyntaxKind.RequireKeyword */], 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 126 /* AbstractKeyword */, - 84 /* ClassKeyword */, - 135 /* DeclareKeyword */, - 88 /* DefaultKeyword */, - 92 /* EnumKeyword */, - 93 /* ExportKeyword */, - 94 /* ExtendsKeyword */, - 136 /* GetKeyword */, - 117 /* ImplementsKeyword */, - 100 /* ImportKeyword */, - 118 /* InterfaceKeyword */, - 141 /* ModuleKeyword */, - 142 /* NamespaceKeyword */, - 121 /* PrivateKeyword */, - 123 /* PublicKeyword */, - 122 /* ProtectedKeyword */, - 145 /* ReadonlyKeyword */, - 149 /* SetKeyword */, - 124 /* StaticKeyword */, - 152 /* TypeKeyword */, - 156 /* FromKeyword */, - 140 /* KeyOfKeyword */, - 137 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 156 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 135 /* SyntaxKind.DeclareKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 92 /* SyntaxKind.EnumKeyword */, + 93 /* SyntaxKind.ExportKeyword */, + 94 /* SyntaxKind.ExtendsKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 117 /* SyntaxKind.ImplementsKeyword */, + 100 /* SyntaxKind.ImportKeyword */, + 118 /* SyntaxKind.InterfaceKeyword */, + 141 /* SyntaxKind.ModuleKeyword */, + 142 /* SyntaxKind.NamespaceKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 152 /* SyntaxKind.TypeKeyword */, + 156 /* SyntaxKind.FromKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 137 /* SyntaxKind.InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* SyntaxKind.ExtendsKeyword */, 117 /* SyntaxKind.ImplementsKeyword */, 156 /* SyntaxKind.FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterModuleName", 10 /* SyntaxKind.StringLiteral */, 18 /* SyntaxKind.OpenBraceToken */, [isModuleDeclContext], 4 /* RuleAction.InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeArrow", anyToken, 38 /* SyntaxKind.EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterArrow", 38 /* SyntaxKind.EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* SyntaxKind.DotDotDotToken */, 79 /* SyntaxKind.Identifier */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* SyntaxKind.QuestionToken */, [21 /* SyntaxKind.CloseParenToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* RuleAction.DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* SyntaxKind.CloseParenToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* SyntaxKind.LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* SyntaxKind.GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* SyntaxKind.GreaterThanToken */, [20 /* SyntaxKind.OpenParenToken */, 22 /* SyntaxKind.OpenBracketToken */, 31 /* SyntaxKind.GreaterThanToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* RuleAction.DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeAt", [21 /* SyntaxKind.CloseParenToken */, 79 /* SyntaxKind.Identifier */], 59 /* SyntaxKind.AtToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAt", 59 /* SyntaxKind.AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 126 /* AbstractKeyword */, - 79 /* Identifier */, - 93 /* ExportKeyword */, - 88 /* DefaultKeyword */, - 84 /* ClassKeyword */, - 124 /* StaticKeyword */, - 123 /* PublicKeyword */, - 121 /* PrivateKeyword */, - 122 /* ProtectedKeyword */, - 136 /* GetKeyword */, - 149 /* SetKeyword */, - 22 /* OpenBracketToken */, - 41 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 79 /* SyntaxKind.Identifier */, + 93 /* SyntaxKind.ExportKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 22 /* SyntaxKind.OpenBracketToken */, + 41 /* SyntaxKind.AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* SyntaxKind.ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* SyntaxKind.NewKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* SyntaxKind.LessThanToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* RuleAction.DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* SyntaxKind.OpenParenToken */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after opening and before closing empty brace brackets - rule("SpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* DeleteSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* RuleAction.DeleteSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* RuleAction.DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), - rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), - rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), - rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* RuleAction.DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* RuleAction.InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* SyntaxKind.CommaToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* AsyncKeyword */, 82 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* SyntaxKind.AsyncKeyword */, 82 /* SyntaxKind.CaseKeyword */), 22 /* SyntaxKind.OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* SyntaxKind.CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 132 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* SyntaxKind.ForKeyword */, 132 /* SyntaxKind.AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* SyntaxKind.CloseParenToken */, 90 /* SyntaxKind.DoKeyword */, 91 /* SyntaxKind.ElseKeyword */, 82 /* SyntaxKind.CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* RuleAction.InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* SyntaxKind.TryKeyword */, 83 /* SyntaxKind.CatchKeyword */, 96 /* SyntaxKind.FinallyKeyword */], 18 /* SyntaxKind.OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules, true), userConfigurableRules, true), lowPriorityCommonRules, true); } @@ -147417,7 +148144,7 @@ var ts; * @param flags whether the rule deletes a line or not, defaults to no-op */ function rule(debugName, left, right, context, action, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* RuleFlags.None */; } return { leftTokenRange: toTokenRange(left), rightTokenRange: toTokenRange(right), rule: { debugName: debugName, context: context, action: action, flags: flags } }; } function tokenRangeFrom(tokens) { @@ -147458,54 +148185,54 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 242 /* ForStatement */; + return context.contextNode.kind === 242 /* SyntaxKind.ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 221 /* BinaryExpression */: - return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 222 /* ConditionalExpression */: - case 189 /* ConditionalType */: - case 229 /* AsExpression */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 177 /* TypePredicate */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 221 /* SyntaxKind.BinaryExpression */: + return context.contextNode.operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; + case 222 /* SyntaxKind.ConditionalExpression */: + case 189 /* SyntaxKind.ConditionalType */: + case 229 /* SyntaxKind.AsExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 177 /* SyntaxKind.TypePredicate */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // equals in type X = ... // falls through - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // equal in export = 1 // falls through - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // equal in let a = 0 // falls through - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // equal in p = 0 // falls through - case 164 /* Parameter */: - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 164 /* SyntaxKind.Parameter */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // "in" keyword in for (let x in []) { } - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 163 /* TypeParameter */: - return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 163 /* SyntaxKind.TypeParameter */: + return context.currentTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.nextTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 244 /* ForOfStatement */: - return context.currentTokenSpan.kind === 160 /* OfKeyword */ || context.nextTokenSpan.kind === 160 /* OfKeyword */; + case 244 /* SyntaxKind.ForOfStatement */: + return context.currentTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */ || context.nextTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */; } return false; } @@ -147517,22 +148244,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 167 /* PropertyDeclaration */ || - contextKind === 166 /* PropertySignature */ || - contextKind === 164 /* Parameter */ || - contextKind === 254 /* VariableDeclaration */ || + return contextKind === 167 /* SyntaxKind.PropertyDeclaration */ || + contextKind === 166 /* SyntaxKind.PropertySignature */ || + contextKind === 164 /* SyntaxKind.Parameter */ || + contextKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 222 /* ConditionalExpression */ || - context.contextNode.kind === 189 /* ConditionalType */; + return context.contextNode.kind === 222 /* SyntaxKind.ConditionalExpression */ || + context.contextNode.kind === 189 /* SyntaxKind.ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 201 /* ObjectBindingPattern */ || - context.contextNode.kind === 195 /* MappedType */ || + return context.contextNode.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || + context.contextNode.kind === 195 /* SyntaxKind.MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -147558,34 +148285,34 @@ var ts; return true; } switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 205 /* ObjectLiteralExpression */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 262 /* SyntaxKind.ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 174 /* CallSignature */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 258 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 258 /* SyntaxKind.InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -147594,40 +148321,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 256 /* FunctionDeclaration */ || context.contextNode.kind === 213 /* FunctionExpression */; + return context.contextNode.kind === 256 /* SyntaxKind.FunctionDeclaration */ || context.contextNode.kind === 213 /* SyntaxKind.FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 182 /* TypeLiteral */: - case 261 /* ModuleDeclaration */: - case 272 /* ExportDeclaration */: - case 273 /* NamedExports */: - case 266 /* ImportDeclaration */: - case 269 /* NamedImports */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 273 /* SyntaxKind.NamedExports */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 269 /* SyntaxKind.NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 292 /* CatchClause */: - case 262 /* ModuleBlock */: - case 249 /* SwitchStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 292 /* SyntaxKind.CatchClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 249 /* SyntaxKind.SwitchStatement */: return true; - case 235 /* Block */: { + case 235 /* SyntaxKind.Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 214 /* ArrowFunction */ && blockParent.kind !== 213 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 214 /* SyntaxKind.ArrowFunction */ && blockParent.kind !== 213 /* SyntaxKind.FunctionExpression */) { return true; } } @@ -147636,71 +148363,71 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 248 /* WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 248 /* SyntaxKind.WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 205 /* ObjectLiteralExpression */; + return context.contextNode.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 208 /* CallExpression */; + return context.contextNode.kind === 208 /* SyntaxKind.CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 209 /* NewExpression */; + return context.contextNode.kind === 209 /* SyntaxKind.NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 27 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* SyntaxKind.CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* SyntaxKind.CloseBracketToken */; } function isNextTokenNotCloseParen(context) { - return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; + return context.nextTokenSpan.kind !== 21 /* SyntaxKind.CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 214 /* ArrowFunction */; + return context.contextNode.kind === 214 /* SyntaxKind.ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 200 /* ImportType */; + return context.contextNode.kind === 200 /* SyntaxKind.ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxTextContext(context) { - return context.contextNode.kind !== 11 /* JsxText */; + return context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 278 /* JsxElement */ && context.contextNode.kind !== 282 /* JsxFragment */; + return context.contextNode.kind !== 278 /* SyntaxKind.JsxElement */ && context.contextNode.kind !== 282 /* SyntaxKind.JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 288 /* JsxExpression */ || context.contextNode.kind === 287 /* JsxSpreadAttribute */; + return context.contextNode.kind === 288 /* SyntaxKind.JsxExpression */ || context.contextNode.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 285 /* JsxAttribute */; + return context.nextTokenParent.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 285 /* JsxAttribute */; + return context.contextNode.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 279 /* JsxSelfClosingElement */; + return context.contextNode.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -147715,45 +148442,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 255 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { - return context.formattingRequestKind !== 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormattingRequestKind.FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 261 /* ModuleDeclaration */; + return context.contextNode.kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 182 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 182 /* SyntaxKind.TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 175 /* ConstructSignature */; + return context.contextNode.kind === 175 /* SyntaxKind.ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { + if (token.kind !== 29 /* SyntaxKind.LessThanToken */ && token.kind !== 31 /* SyntaxKind.GreaterThanToken */) { return false; } switch (parent.kind) { - case 178 /* TypeReference */: - case 211 /* TypeAssertionExpression */: - case 259 /* TypeAliasDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return true; default: return false; @@ -147764,28 +148491,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 211 /* TypeAssertionExpression */; + return context.contextNode.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 217 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* SyntaxKind.VoidKeyword */ && context.currentTokenParent.kind === 217 /* SyntaxKind.VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 224 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 224 /* SyntaxKind.YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 230 /* NonNullExpression */; + return context.contextNode.kind === 230 /* SyntaxKind.NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; default: return false; @@ -147807,15 +148534,15 @@ var ts; var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; if (startLine === endLine) { - return nextTokenKind === 19 /* CloseBraceToken */ - || nextTokenKind === 1 /* EndOfFileToken */; + return nextTokenKind === 19 /* SyntaxKind.CloseBraceToken */ + || nextTokenKind === 1 /* SyntaxKind.EndOfFileToken */; } - if (nextTokenKind === 234 /* SemicolonClassElement */ || - nextTokenKind === 26 /* SemicolonToken */) { + if (nextTokenKind === 234 /* SyntaxKind.SemicolonClassElement */ || + nextTokenKind === 26 /* SyntaxKind.SemicolonToken */) { return false; } - if (context.contextNode.kind === 258 /* InterfaceDeclaration */ || - context.contextNode.kind === 259 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + context.contextNode.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -147824,25 +148551,25 @@ var ts; // } return !ts.isPropertySignature(context.currentTokenParent) || !!context.currentTokenParent.type - || nextTokenKind !== 20 /* OpenParenToken */; + || nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */; } if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 242 /* ForStatement */ - && context.currentTokenParent.kind !== 236 /* EmptyStatement */ - && context.currentTokenParent.kind !== 234 /* SemicolonClassElement */ - && nextTokenKind !== 22 /* OpenBracketToken */ - && nextTokenKind !== 20 /* OpenParenToken */ - && nextTokenKind !== 39 /* PlusToken */ - && nextTokenKind !== 40 /* MinusToken */ - && nextTokenKind !== 43 /* SlashToken */ - && nextTokenKind !== 13 /* RegularExpressionLiteral */ - && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 223 /* TemplateExpression */ - && nextTokenKind !== 15 /* TemplateHead */ - && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ - && nextTokenKind !== 24 /* DotToken */; + return context.currentTokenParent.kind !== 242 /* SyntaxKind.ForStatement */ + && context.currentTokenParent.kind !== 236 /* SyntaxKind.EmptyStatement */ + && context.currentTokenParent.kind !== 234 /* SyntaxKind.SemicolonClassElement */ + && nextTokenKind !== 22 /* SyntaxKind.OpenBracketToken */ + && nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */ + && nextTokenKind !== 39 /* SyntaxKind.PlusToken */ + && nextTokenKind !== 40 /* SyntaxKind.MinusToken */ + && nextTokenKind !== 43 /* SyntaxKind.SlashToken */ + && nextTokenKind !== 13 /* SyntaxKind.RegularExpressionLiteral */ + && nextTokenKind !== 27 /* SyntaxKind.CommaToken */ + && nextTokenKind !== 223 /* SyntaxKind.TemplateExpression */ + && nextTokenKind !== 15 /* SyntaxKind.TemplateHead */ + && nextTokenKind !== 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* SyntaxKind.DotToken */; } function isSemicolonInsertionContext(context) { return ts.positionIsASICandidate(context.currentTokenSpan.end, context.currentTokenParent, context.sourceFile); @@ -147871,17 +148598,17 @@ var ts; */ function getRuleActionExclusion(ruleAction) { var mask = 0; - if (ruleAction & 1 /* StopProcessingSpaceActions */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 1 /* RuleAction.StopProcessingSpaceActions */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 2 /* StopProcessingTokenActions */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 2 /* RuleAction.StopProcessingTokenActions */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } - if (ruleAction & 28 /* ModifySpaceAction */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 28 /* RuleAction.ModifySpaceAction */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 96 /* ModifyTokenAction */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 96 /* RuleAction.ModifyTokenAction */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } return mask; } @@ -147930,12 +148657,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 160 /* LastKeyword */ && column <= 160 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 160 /* SyntaxKind.LastKeyword */ && column <= 160 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 160 /* LastToken */ + 1; + var mapRowLength = 160 /* SyntaxKind.LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -147961,7 +148688,7 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action & 3 /* StopAction */ ? + var position = rule.action & 3 /* RuleAction.StopAction */ ? specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : rule.context !== formatting.anyContext ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : @@ -148030,16 +148757,16 @@ var ts; // end value is exclusive so add 1 to the result end: endOfFormatSpan + 1 }; - return formatSpan(span, sourceFile, formatContext, 2 /* FormatOnEnter */); + return formatSpan(span, sourceFile, formatContext, 2 /* FormattingRequestKind.FormatOnEnter */); } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormattingRequestKind.FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -148061,12 +148788,12 @@ var ts; pos: ts.getLineStartPositionForPosition(outermostNode.getStart(sourceFile), sourceFile), end: position }; - return formatSpan(textRange, sourceFile, formatContext, 4 /* FormatOnOpeningCurlyBrace */); + return formatSpan(textRange, sourceFile, formatContext, 4 /* FormattingRequestKind.FormatOnOpeningCurlyBrace */); } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormattingRequestKind.FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, formatContext) { @@ -148074,7 +148801,7 @@ var ts; pos: 0, end: sourceFile.text.length }; - return formatSpan(span, sourceFile, formatContext, 0 /* FormatDocument */); + return formatSpan(span, sourceFile, formatContext, 0 /* FormattingRequestKind.FormatDocument */); } formatting.formatDocument = formatDocument; function formatSelection(start, end, sourceFile, formatContext) { @@ -148083,7 +148810,7 @@ var ts; pos: ts.getLineStartPositionForPosition(start, sourceFile), end: end, }; - return formatSpan(span, sourceFile, formatContext, 1 /* FormatSelection */); + return formatSpan(span, sourceFile, formatContext, 1 /* FormattingRequestKind.FormatSelection */); } formatting.formatSelection = formatSelection; /** @@ -148123,17 +148850,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 262 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 305 /* SourceFile */: - case 235 /* Block */: - case 262 /* ModuleBlock */: + return !!body && body.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -148230,11 +148957,11 @@ var ts; * to the initial indentation. */ function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1 /* Unknown */; + var previousLine = -1 /* Constants.Unknown */; var child; while (n) { var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + if (previousLine !== -1 /* Constants.Unknown */ && line !== previousLine) { break; } if (formatting.SmartIndenter.shouldIndentChildNode(options, n, child, sourceFile)) { @@ -148248,7 +148975,7 @@ var ts; } function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: node.pos, end: node.end }; - return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormattingRequestKind.FormatSelection */, function (_) { return false; }, // assume that node does not have any errors sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; @@ -148272,11 +148999,12 @@ var ts; var options = _a.options, getRules = _a.getRules, host = _a.host; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); + var previousRangeTriviaEnd; var previousRange; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine = -1 /* Unknown */; + var indentationOnLastIndentedLine = -1 /* Constants.Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -148300,10 +149028,30 @@ var ts; } } if (previousRange && formattingScanner.getStartPos() >= originalRange.end) { + // Formatting edits happen by looking at pairs of contiguous tokens (see `processPair`), + // typically inserting or deleting whitespace between them. The recursive `processNode` + // logic above bails out as soon as it encounters a token that is beyond the end of the + // range we're supposed to format (or if we reach the end of the file). But this potentially + // leaves out an edit that would occur *inside* the requested range but cannot be discovered + // without looking at one token *beyond* the end of the range: consider the line `x = { }` + // with a selection from the beginning of the line to the space inside the curly braces, + // inclusive. We would expect a format-selection would delete the space (if rules apply), + // but in order to do that, we need to process the pair ["{", "}"], but we stopped processing + // just before getting there. This block handles this trailing edit. var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() : formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token : undefined; - if (tokenInfo) { + if (tokenInfo && tokenInfo.pos === previousRangeTriviaEnd) { + // We need to check that tokenInfo and previousRange are contiguous: the `originalRange` + // may have ended in the middle of a token, which means we will have stopped formatting + // on that token, leaving `previousRange` pointing to the token before it, but already + // having moved the formatting scanner (where we just got `tokenInfo`) to the next token. + // If this happens, our supposed pair [previousRange, tokenInfo] actually straddles the + // token that intersects the end of the range we're supposed to format, so the pair will + // produce bogus edits if we try to `processPair`. Recall that the point of this logic is + // to perform a trailing edit at the end of the selection range: but there can be no valid + // edit in the middle of a token where the range ended, so if we have a non-contiguous + // pair here, we're already done and we can ignore it. var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent; processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent, /*dynamicIndentation*/ undefined); @@ -148321,7 +149069,7 @@ var ts; function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) { - if (inheritedIndentation !== -1 /* Unknown */) { + if (inheritedIndentation !== -1 /* Constants.Unknown */) { return inheritedIndentation; } } @@ -148336,7 +149084,7 @@ var ts; return baseIndentSize > column ? baseIndentSize : column; } } - return -1 /* Unknown */; + return -1 /* Constants.Unknown */; } function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { var delta = formatting.SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize : 0; @@ -148349,8 +149097,8 @@ var ts; delta: Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta) }; } - else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 20 /* OpenParenToken */ && startLine === lastIndentedLine) { + else if (inheritedIndentation === -1 /* Constants.Unknown */) { + if (node.kind === 20 /* SyntaxKind.OpenParenToken */ && startLine === lastIndentedLine) { // the is used for chaining methods formatting // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; @@ -148375,19 +149123,19 @@ var ts; return modifier.kind; } switch (node.kind) { - case 257 /* ClassDeclaration */: return 84 /* ClassKeyword */; - case 258 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; - case 256 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; - case 260 /* EnumDeclaration */: return 260 /* EnumDeclaration */; - case 172 /* GetAccessor */: return 136 /* GetKeyword */; - case 173 /* SetAccessor */: return 149 /* SetKeyword */; - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return 84 /* SyntaxKind.ClassKeyword */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return 118 /* SyntaxKind.InterfaceKeyword */; + case 256 /* SyntaxKind.FunctionDeclaration */: return 98 /* SyntaxKind.FunctionKeyword */; + case 260 /* SyntaxKind.EnumDeclaration */: return 260 /* SyntaxKind.EnumDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: return 136 /* SyntaxKind.GetKeyword */; + case 173 /* SyntaxKind.SetAccessor */: return 149 /* SyntaxKind.SetKeyword */; + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - return 41 /* AsteriskToken */; + return 41 /* SyntaxKind.AsteriskToken */; } // falls through - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -148402,12 +149150,12 @@ var ts; // .. { // // comment // } - case 19 /* CloseBraceToken */: - case 23 /* CloseBracketToken */: - case 21 /* CloseParenToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + case 21 /* SyntaxKind.CloseParenToken */: return indentation + getDelta(container); } - return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; + return tokenIndentation !== -1 /* Constants.Unknown */ ? tokenIndentation : indentation; }, // if list end token is LessThanToken '>' then its delta should be explicitly suppressed // so that LessThanToken as a binary operator can still be indented. @@ -148434,25 +149182,25 @@ var ts; function shouldAddDelta(line, kind, container) { switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 18 /* OpenBraceToken */: - case 19 /* CloseBraceToken */: - case 21 /* CloseParenToken */: - case 91 /* ElseKeyword */: - case 115 /* WhileKeyword */: - case 59 /* AtToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 21 /* SyntaxKind.CloseParenToken */: + case 91 /* SyntaxKind.ElseKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 59 /* SyntaxKind.AtToken */: return false; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: switch (container.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return false; } break; - case 22 /* OpenBracketToken */: - case 23 /* CloseBracketToken */: - if (container.kind !== 195 /* MappedType */) { + case 22 /* SyntaxKind.OpenBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + if (container.kind !== 195 /* SyntaxKind.MappedType */) { return false; } break; @@ -148487,7 +149235,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Constants.Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -148500,6 +149248,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { + ts.Debug.assert(!ts.nodeIsSynthesized(child)); if (ts.nodeIsMissing(child)) { return inheritedIndentation; } @@ -148510,10 +149259,10 @@ var ts; undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; } // if child is a list item - try to get its indentation, only if parent is within the original range. - var childIndentationAmount = -1 /* Unknown */; + var childIndentationAmount = -1 /* Constants.Unknown */; if (isListItem && ts.rangeContainsRange(originalRange, parent)) { childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1 /* Unknown */) { + if (childIndentationAmount !== -1 /* Constants.Unknown */) { inheritedIndentation = childIndentationAmount; } } @@ -148549,23 +149298,24 @@ var ts; // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); // JSX text shouldn't affect indenting - if (child.kind !== 11 /* JsxText */) { + if (child.kind !== 11 /* SyntaxKind.JsxText */) { ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 165 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 165 /* SyntaxKind.Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 204 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && inheritedIndentation === -1 /* Constants.Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; } function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { ts.Debug.assert(ts.isNodeArray(nodes)); + ts.Debug.assert(!ts.nodeIsSynthesized(nodes)); var listStartToken = getOpenTokenForList(parent, nodes); var listDynamicIndentation = parentDynamicIndentation; var startLine = parentStartLine; @@ -148576,7 +149326,7 @@ var ts; } return; } - if (listStartToken !== 0 /* Unknown */) { + if (listStartToken !== 0 /* SyntaxKind.Unknown */) { // introduce a new indentation scope for lists (including list start and end tokens) while (formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); @@ -148589,7 +149339,7 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); var indentationOnListStartToken = void 0; - if (indentationOnLastIndentedLine !== -1 /* Unknown */) { + if (indentationOnLastIndentedLine !== -1 /* Constants.Unknown */) { // scanner just processed list start token so consider last indentation as list indentation // function foo(): { // last indentation was 0, list item will be indented based on this value // foo: number; @@ -148608,15 +149358,15 @@ var ts; } } } - var inheritedIndentation = -1 /* Unknown */; + var inheritedIndentation = -1 /* Constants.Unknown */; for (var i = 0; i < nodes.length; i++) { var child = nodes[i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0); } var listEndToken = getCloseTokenForOpenToken(listStartToken); - if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { + if (listEndToken !== 0 /* SyntaxKind.Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 27 /* CommaToken */) { + if (tokenInfo.token.kind === 27 /* SyntaxKind.CommaToken */) { // consume the comma consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined; @@ -148638,7 +149388,7 @@ var ts; if (currentTokenInfo.leadingTrivia) { processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); } - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); if (isTokenInRange) { @@ -148648,31 +149398,32 @@ var ts; lineAction = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); // do not indent comments\token if token range overlaps with some error if (!rangeHasError) { - if (lineAction === 0 /* None */) { + if (lineAction === 0 /* LineAction.None */) { // indent token only if end line of previous range does not match start line of the token var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; } else { - indentToken = lineAction === 1 /* LineAdded */; + indentToken = lineAction === 1 /* LineAction.LineAdded */; } } } if (currentTokenInfo.trailingTrivia) { + previousRangeTriviaEnd = ts.last(currentTokenInfo.trailingTrivia).end; processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + -1 /* Constants.Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); indentNextTokenOrTrivia = indentTriviaItems(currentTokenInfo.leadingTrivia, commentIndentation_1, indentNextTokenOrTrivia, function (item) { return insertIndentation(item.pos, commentIndentation_1, /*lineAdded*/ false); }); } // indent token only if is it is in target range and does not overlap with any error ranges - if (tokenIndentation !== -1 /* Unknown */ && indentNextTokenOrTrivia) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAdded */); + if (tokenIndentation !== -1 /* Constants.Unknown */ && indentNextTokenOrTrivia) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAction.LineAdded */); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; } @@ -148686,19 +149437,19 @@ var ts; var triviaItem = trivia_1[_i]; var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: if (triviaInRange) { indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: if (indentNextTokenOrTrivia && triviaInRange) { indentSingleLine(triviaItem); } indentNextTokenOrTrivia = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: indentNextTokenOrTrivia = true; break; } @@ -148716,7 +149467,7 @@ var ts; } function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line @@ -148729,6 +149480,7 @@ var ts; } } previousRange = range; + previousRangeTriviaEnd = range.end; previousParent = parent; previousRangeStartLine = rangeStart.line; return lineAction; @@ -148737,7 +149489,7 @@ var ts; formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); var rules = getRules(formattingContext); var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false; - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (rules) { // Apply rules in reverse order so that higher priority rules (which are first in the array) // win in a conflict with lower priority rules. @@ -148745,14 +149497,14 @@ var ts; lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); if (dynamicIndentation) { switch (lineAction) { - case 2 /* LineRemoved */: + case 2 /* LineAction.LineRemoved */: // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode); } break; - case 1 /* LineAdded */: + case 1 /* LineAction.LineAdded */: // Handle the case where token2 is moved to the new line. // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. @@ -148761,15 +149513,15 @@ var ts; } break; default: - ts.Debug.assert(lineAction === 0 /* None */); + ts.Debug.assert(lineAction === 0 /* LineAction.None */); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* RuleAction.DeleteSpace */) && rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */; }); } else { - trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* EndOfFileToken */; + trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* SyntaxKind.EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -148795,7 +149547,7 @@ var ts; function characterToColumn(startLinePosition, characterInLine) { var column = 0; for (var i = 0; i < characterInLine; i++) { - if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* tab */) { + if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* CharacterCodes.tab */) { column += options.tabSize - column % options.tabSize; } else { @@ -148926,48 +149678,48 @@ var ts; function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* StopProcessingSpaceActions */: + case 1 /* RuleAction.StopProcessingSpaceActions */: // no action required - return 0 /* None */; - case 16 /* DeleteSpace */: + return 0 /* LineAction.None */; + case 16 /* RuleAction.DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 32 /* DeleteToken */: + case 32 /* RuleAction.DeleteToken */: recordDelete(previousRange.pos, previousRange.end - previousRange.pos); break; - case 8 /* InsertNewLine */: + case 8 /* RuleAction.InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } // edit should not be applied if we have one line feed between elements var lineDelta = currentStartLine - previousStartLine; if (lineDelta !== 1) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, ts.getNewLineOrDefaultFromHost(host, options)); - return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; + return onLaterLine ? 0 /* LineAction.None */ : 1 /* LineAction.LineAdded */; } break; - case 4 /* InsertSpace */: + case 4 /* RuleAction.InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* CharacterCodes.space */) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 64 /* InsertTrailingSemicolon */: + case 64 /* RuleAction.InsertTrailingSemicolon */: recordInsert(previousRange.end, ";"); } - return 0 /* None */; + return 0 /* LineAction.None */; } } var LineAction; @@ -149009,71 +149761,71 @@ var ts; // // Internally, we represent the end of the comment at the newline and closing '/', respectively. // - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); + position === range.end && (range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.parameters === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.arguments === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 178 /* TypeReference */: - case 210 /* TaggedTemplateExpression */: - case 181 /* TypeQuery */: - case 228 /* ExpressionWithTypeArguments */: - case 200 /* ImportType */: + case 178 /* SyntaxKind.TypeReference */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 181 /* SyntaxKind.TypeQuery */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 200 /* SyntaxKind.ImportType */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 182 /* TypeLiteral */: - return 18 /* OpenBraceToken */; + case 182 /* SyntaxKind.TypeLiteral */: + return 18 /* SyntaxKind.OpenBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 20 /* OpenParenToken */: - return 21 /* CloseParenToken */; - case 29 /* LessThanToken */: - return 31 /* GreaterThanToken */; - case 18 /* OpenBraceToken */: - return 19 /* CloseBraceToken */; + case 20 /* SyntaxKind.OpenParenToken */: + return 21 /* SyntaxKind.CloseParenToken */; + case 29 /* SyntaxKind.LessThanToken */: + return 31 /* SyntaxKind.GreaterThanToken */; + case 18 /* SyntaxKind.OpenBraceToken */: + return 19 /* SyntaxKind.CloseBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } var internedSizes; var internedTabsIndentation; @@ -149159,7 +149911,7 @@ var ts; var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); // eslint-disable-next-line no-null/no-null var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); - if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -149195,21 +149947,21 @@ var ts; // y: undefined, // } // ``` - var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */; + var isObjectLiteral = currentToken.kind === 18 /* SyntaxKind.OpenBraceToken */ && currentToken.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* SyntaxKind.CommaToken */ && precedingToken.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } } var containerList = getListByPosition(position, precedingToken.parent, sourceFile); // use list position if the preceding token is before any list items if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) { - var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; + var useTheSameBaseIndentation = [213 /* SyntaxKind.FunctionExpression */, 214 /* SyntaxKind.ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize; return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217 } @@ -149229,7 +149981,7 @@ var ts; return column; } var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); - return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; + return firstNonWhitespaceCharacterCode === 42 /* CharacterCodes.asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { // move backwards until we find a line with a non-whitespace character, @@ -149254,9 +150006,9 @@ var ts; if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(options, current, previous, sourceFile, /*isNextChild*/ true)) { var currentStart = getStartLineAndCharacterForNode(current, sourceFile); var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); - var indentationDelta = nextTokenKind !== 0 /* Unknown */ + var indentationDelta = nextTokenKind !== 0 /* NextTokenKind.Unknown */ // handle cases when codefix is about to be inserted before the close brace - ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0 + ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* NextTokenKind.CloseBrace */ ? options.indentSize : 0 : lineAtPosition !== currentStart.line ? options.indentSize : 0; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } @@ -149265,7 +150017,7 @@ var ts; // function foo(a // | preceding node 'a' does share line with its parent but indentation is expected var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, /*listIndentsChild*/ true); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } previous = current; @@ -149319,12 +150071,12 @@ var ts; // }) looking at the relationship between the list and *first* list item. var listIndentsChild = !!firstListChild && getStartLineAndCharacterForNode(firstListChild, sourceFile).line > containingListOrParentStart.line; var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, listIndentsChild); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } // try to fetch actual indentation for current node from source text actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } } @@ -149363,7 +150115,7 @@ var ts; } else { // handle broken code gracefully - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } } /* @@ -149374,9 +150126,9 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 305 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 305 /* SyntaxKind.SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } @@ -149389,13 +150141,13 @@ var ts; function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current, sourceFile); if (!nextToken) { - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } - if (nextToken.kind === 18 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* SyntaxKind.OpenBraceToken */) { // open braces are always indented at the parent level - return 1 /* OpenBrace */; + return 1 /* NextTokenKind.OpenBrace */; } - else if (nextToken.kind === 19 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -149405,9 +150157,9 @@ var ts; // class A { // $} var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine ? 2 /* CloseBrace */ : 0 /* Unknown */; + return lineAtPosition === nextTokenStartLine ? 2 /* NextTokenKind.CloseBrace */ : 0 /* NextTokenKind.Unknown */; } - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); @@ -149422,8 +150174,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 239 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); + if (parent.kind === 239 /* SyntaxKind.IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* SyntaxKind.ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -149503,42 +150255,42 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getList(node.typeArguments); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return getList(node.properties); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getList(node.elements); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return getList(node.members); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return getList(node.parameters); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return getList(node.typeParameters); - case 209 /* NewExpression */: - case 208 /* CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return getList(node.declarations); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return getList(node.elements); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -149556,27 +150308,27 @@ var ts; } function getActualIndentationForListStartLine(list, sourceFile, options) { if (!list) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 255 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); - if (result !== -1 /* Unknown */) { + if (result !== -1 /* Value.Unknown */) { return result; } } return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -149585,7 +150337,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 27 /* CommaToken */) { + if (list[i].kind === 27 /* SyntaxKind.CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -149595,7 +150347,7 @@ var ts; } lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); @@ -149616,7 +150368,7 @@ var ts; if (!ts.isWhiteSpaceSingleLine(ch)) { break; } - if (ch === 9 /* tab */) { + if (ch === 9 /* CharacterCodes.tab */) { column += options.tabSize + (column % options.tabSize); } else { @@ -149632,98 +150384,98 @@ var ts; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { - var childKind = child ? child.kind : 0 /* Unknown */; + var childKind = child ? child.kind : 0 /* SyntaxKind.Unknown */; switch (parent.kind) { - case 238 /* ExpressionStatement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 204 /* ArrayLiteralExpression */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 195 /* MappedType */: - case 184 /* TupleType */: - case 263 /* CaseBlock */: - case 290 /* DefaultClause */: - case 289 /* CaseClause */: - case 212 /* ParenthesizedExpression */: - case 206 /* PropertyAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 237 /* VariableStatement */: - case 271 /* ExportAssignment */: - case 247 /* ReturnStatement */: - case 222 /* ConditionalExpression */: - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: - case 279 /* JsxSelfClosingElement */: - case 288 /* JsxExpression */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 164 /* Parameter */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 191 /* ParenthesizedType */: - case 210 /* TaggedTemplateExpression */: - case 218 /* AwaitExpression */: - case 273 /* NamedExports */: - case 269 /* NamedImports */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 167 /* PropertyDeclaration */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 195 /* SyntaxKind.MappedType */: + case 184 /* SyntaxKind.TupleType */: + case 263 /* SyntaxKind.CaseBlock */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 237 /* SyntaxKind.VariableStatement */: + case 271 /* SyntaxKind.ExportAssignment */: + case 247 /* SyntaxKind.ReturnStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 164 /* SyntaxKind.Parameter */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 273 /* SyntaxKind.NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 254 /* VariableDeclaration */: - case 296 /* PropertyAssignment */: - case 221 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 254 /* SyntaxKind.VariableDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind === 221 /* BinaryExpression */ && sourceFile && child && childKind === 278 /* JsxElement */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && sourceFile && child && childKind === 278 /* SyntaxKind.JsxElement */) { var parentStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, parent.pos)).line; var childStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, child.pos)).line; return parentStartLine !== childStartLine; } - if (parent.kind !== 221 /* BinaryExpression */) { + if (parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { return true; } break; - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return childKind !== 235 /* Block */; - case 214 /* ArrowFunction */: - if (sourceFile && childKind === 212 /* ParenthesizedExpression */) { + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return childKind !== 235 /* SyntaxKind.Block */; + case 214 /* SyntaxKind.ArrowFunction */: + if (sourceFile && childKind === 212 /* SyntaxKind.ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 235 /* Block */; - case 272 /* ExportDeclaration */: - return childKind !== 273 /* NamedExports */; - case 266 /* ImportDeclaration */: - return childKind !== 267 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 269 /* NamedImports */); - case 278 /* JsxElement */: - return childKind !== 281 /* JsxClosingElement */; - case 282 /* JsxFragment */: - return childKind !== 284 /* JsxClosingFragment */; - case 188 /* IntersectionType */: - case 187 /* UnionType */: - if (childKind === 182 /* TypeLiteral */ || childKind === 184 /* TupleType */) { + return childKind !== 235 /* SyntaxKind.Block */; + case 272 /* SyntaxKind.ExportDeclaration */: + return childKind !== 273 /* SyntaxKind.NamedExports */; + case 266 /* SyntaxKind.ImportDeclaration */: + return childKind !== 267 /* SyntaxKind.ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 269 /* SyntaxKind.NamedImports */); + case 278 /* SyntaxKind.JsxElement */: + return childKind !== 281 /* SyntaxKind.JsxClosingElement */; + case 282 /* SyntaxKind.JsxFragment */: + return childKind !== 284 /* SyntaxKind.JsxClosingFragment */; + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + if (childKind === 182 /* SyntaxKind.TypeLiteral */ || childKind === 184 /* SyntaxKind.TupleType */) { return false; } break; @@ -149734,11 +150486,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: - return parent.kind !== 235 /* Block */; + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + return parent.kind !== 235 /* SyntaxKind.Block */; default: return false; } @@ -149828,7 +150580,7 @@ var ts; i++; continue; } - return ch === 47 /* slash */; + return ch === 47 /* CharacterCodes.slash */; } return false; } @@ -149912,7 +150664,7 @@ var ts; var comment = comments_2[_i]; // Single line can break the loop as trivia will only be this line. // Comments on subsequest lines are also ignored. - if (comment.kind === 2 /* SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { + if (comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { break; } // Get the end line of the comment and compare against the end line of the node. @@ -149955,7 +150707,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 205 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* SyntaxKind.CommaToken */ || (candidate.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -150061,7 +150813,7 @@ var ts; }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 27 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* SyntaxKind.CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -150125,7 +150877,7 @@ var ts; var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); - var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; + var text = "".concat(insertAtLineStart ? "" : this.newLineCharacter, "//").concat(commentText).concat(this.newLineCharacter).concat(indent); this.insertText(sourceFile, token.getStart(sourceFile), text); }; ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { @@ -150178,7 +150930,7 @@ var ts; var _a; var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return false; // Function missing parentheses, give up @@ -150187,19 +150939,19 @@ var ts; } } else { - endNode = (_a = (node.kind === 254 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { - var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; + var start = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile).getStart(sourceFile) + 1; var suffix = node.parameters.length ? ", " : ""; this.insertNodeAt(sourceFile, start, type, { prefix: "this: ", suffix: suffix }); }; ChangeTracker.prototype.insertTypeParameters = function (sourceFile, node, typeParameters) { // If no `(`, is an arrow function `x => x`, so use the pos of the first parameter - var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">", joiner: ", " }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, inserted, blankLineBetween) { @@ -150340,8 +151092,8 @@ var ts; if (needSemicolonBetween(after, newNode)) { // check if previous statement ends with semicolon // if not - insert semicolon to preserve the code from changing the meaning due to ASI - if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { - this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SemicolonToken */)); + if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* CharacterCodes.semicolon */) { + this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -150349,22 +151101,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n".concat(options.prefix) : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 254 /* VariableDeclaration */: - case 10 /* StringLiteral */: - case 79 /* Identifier */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 10 /* SyntaxKind.StringLiteral */: + case 79 /* SyntaxKind.Identifier */: return { prefix: ", " }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return { prefix: " " }; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -150373,28 +151125,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 214 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + if (node.kind === 214 /* SyntaxKind.ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* SyntaxKind.EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* SyntaxKind.FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` - this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); + this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function ".concat(name, "(")); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } - if (node.body.kind !== 235 /* Block */) { + if (node.body.kind !== 235 /* SyntaxKind.Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(105 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* SyntaxKind.OpenBraceToken */), ts.factory.createToken(105 /* SyntaxKind.ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */), ts.factory.createToken(19 /* SyntaxKind.CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 213 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 213 /* SyntaxKind.FunctionExpression */ ? 98 /* SyntaxKind.FunctionKeyword */ : 84 /* SyntaxKind.ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -150449,7 +151201,7 @@ var ts; var nextNode = containingList[index + 1]; var startPos = skipWhitespacesAndLineBreaks(sourceFile.text, nextNode.getFullStart()); // write separator and leading trivia of the next element as suffix - var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + var suffix = "".concat(ts.tokenToString(nextToken.kind)).concat(sourceFile.text.substring(nextToken.end, startPos)); this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } @@ -150466,12 +151218,12 @@ var ts; // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise // i.e. var x = 1 // this is x // | new element will be inserted at this position - separator = 27 /* CommaToken */; + separator = 27 /* SyntaxKind.CommaToken */; } else { // element has more than one element, pick separator from the list var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); - separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* SyntaxKind.CommaToken */; // determine if list is multiline by checking lines of after element and element that precedes it. var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; @@ -150494,7 +151246,7 @@ var ts; this.replaceRange(sourceFile, ts.createRange(insertPos), newNode, { indentation: indentation, prefix: this.newLineCharacter }); } else { - this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: ts.tokenToString(separator) + " " }); + this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: "".concat(ts.tokenToString(separator), " ") }); } } }; @@ -150522,7 +151274,7 @@ var ts; ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. - var _loop_10 = function (sourceFile, node) { + var _loop_9 = function (sourceFile, node) { if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { if (ts.isArray(node)) { this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node)); @@ -150535,7 +151287,7 @@ var ts; var this_1 = this; for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) { var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node; - _loop_10(sourceFile, node); + _loop_9(sourceFile, node); } deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); @@ -150571,10 +151323,10 @@ var ts; }()); textChanges_3.ChangeTracker = ChangeTracker; function updateJSDocHost(parent) { - if (parent.kind !== 214 /* ArrowFunction */) { + if (parent.kind !== 214 /* SyntaxKind.ArrowFunction */) { return parent; } - var jsDocNode = parent.parent.kind === 167 /* PropertyDeclaration */ ? + var jsDocNode = parent.parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ? parent.parent : parent.parent.parent; jsDocNode.jsDoc = parent.jsDoc; @@ -150586,16 +151338,16 @@ var ts; return undefined; } switch (oldTag.kind) { - case 340 /* JSDocParameterTag */: { + case 340 /* SyntaxKind.JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment) : undefined; } - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -150604,8 +151356,8 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - var open = ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile); - var close = ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile); + var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); + var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); return [open === null || open === void 0 ? void 0 : open.end, close === null || close === void 0 ? void 0 : close.end]; } function getMembersOrProperties(node) { @@ -150623,14 +151375,14 @@ var ts; // order changes by start position // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa. var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); - var _loop_11 = function (i) { + var _loop_10 = function (i) { ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () { - return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range); + return "".concat(JSON.stringify(normalized[i].range), " and ").concat(JSON.stringify(normalized[i + 1].range)); }); }; // verify that change intervals do not overlap, except possibly at end points. for (var i = 0; i < normalized.length - 1; i++) { - _loop_11(i); + _loop_10(i); } var textChanges = ts.mapDefined(normalized, function (c) { var span = ts.createTextSpanFromRange(c.range); @@ -150652,8 +151404,8 @@ var ts; changesToText.newFileChanges = newFileChanges; function newFileChangesWorker(oldFile, scriptKind, statements, newLineCharacter, formatContext) { // TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this - var nonFormattedText = statements.map(function (s) { return s === 4 /* NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); - var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ESNext */, /*setParentNodes*/ true, scriptKind); + var nonFormattedText = statements.map(function (s) { return s === 4 /* SyntaxKind.NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ScriptTarget.ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); return applyChanges(nonFormattedText, changes) + newLineCharacter; } @@ -150708,7 +151460,7 @@ var ts; neverAsciiEscape: true, preserveSourceNewlines: true, terminateUnterminatedLiterals: true - }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + }, writer).writeNode(4 /* EmitHint.Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -150716,7 +151468,7 @@ var ts; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var _a = changes[i], span = _a.span, newText = _a.newText; - text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); + text = "".concat(text.substring(0, span.start)).concat(newText).concat(text.substring(ts.textSpanEnd(span))); } return text; } @@ -150726,7 +151478,7 @@ var ts; } // A transformation context that won't perform parenthesization, as some parenthesization rules // are more aggressive than is strictly necessary. - var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); + var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes @@ -150937,7 +151689,7 @@ var ts; var firstNodeLine; for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { var range = ranges_1[_b]; - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { if (ts.isPinnedComment(text, range.pos)) { lastComment = { range: range, pinnedOrTripleSlash: true }; continue; @@ -150977,7 +151729,7 @@ var ts; var charCode = text.charCodeAt(position); if (ts.isLineBreak(charCode)) { position++; - if (position < text.length && charCode === 13 /* carriageReturn */ && text.charCodeAt(position) === 10 /* lineFeed */) { + if (position < text.length && charCode === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(position) === 10 /* CharacterCodes.lineFeed */) { position++; } } @@ -150989,18 +151741,18 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 164 /* Parameter */: { + case 164 /* SyntaxKind.Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && - !ts.findChildOfKind(oldFunction, 20 /* OpenParenToken */, sourceFile)) { + !ts.findChildOfKind(oldFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile)) { // Lambdas with exactly one parameter are special because, after removal, there // must be an empty parameter list (i.e. `()`) and this won't necessarily be the // case if the parameter is simply removed (e.g. in `x => 1`). @@ -151011,17 +151763,17 @@ var ts; } break; } - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax); // For first import, leave header comment in place, otherwise only delete JSDoc comments deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, }); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 202 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -151029,13 +151781,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -151044,17 +151796,17 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -151083,7 +151835,7 @@ var ts; // import |d,| * as ns from './file' var start = importClause.name.getStart(sourceFile); var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); - if (nextToken && nextToken.kind === 27 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* SyntaxKind.CommaToken */) { // shift first non-whitespace position after comma to the start position of the node var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); changes.deleteRange(sourceFile, { pos: start, end: end }); @@ -151105,15 +151857,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 266 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 266 /* SyntaxKind.ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 292 /* CatchClause */) { + if (parent.kind === 292 /* SyntaxKind.CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* SyntaxKind.OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* SyntaxKind.CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -151122,14 +151874,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -151316,8 +152068,8 @@ var ts; }); function makeChange(changeTracker, sourceFile, assertion) { var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } function getAssertion(sourceFile, pos) { @@ -151401,7 +152153,7 @@ var ts; } } fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.add(ts.getNodeId(insertionSite)); - var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* Async */))); + var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* ModifierFlags.Async */))); changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier); } function getFixableErrorSpanDeclaration(sourceFile, span) { @@ -151538,19 +152290,19 @@ var ts; } var isCompleteFix = identifiers.isCompleteFix; var initializers; - var _loop_12 = function (identifier) { + var _loop_11 = function (identifier) { var symbol = checker.getSymbolAtLocation(identifier); if (!symbol) { return "continue"; } var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 237 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 237 /* SyntaxKind.VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || - ts.hasSyntacticModifier(variableStatement, 1 /* Export */) || + ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { isCompleteFix = false; @@ -151571,7 +152323,7 @@ var ts; }; for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { var identifier = _a[_i]; - _loop_12(identifier); + _loop_11(identifier); } return initializers && { initializers: initializers, @@ -151618,15 +152370,15 @@ var ts; // Promise as an invalid operand. So if the whole binary expression is // typed `any` as a result, there is a strong likelihood that this Promise // is accidentally missing `await`. - checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; + checker.getTypeAtLocation(errorNode).flags & 1 /* TypeFlags.Any */; } function isInsideAwaitableBody(node) { - return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* NodeFlags.AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* FunctionDeclaration */ || - ancestor.parent.kind === 213 /* FunctionExpression */ || - ancestor.parent.kind === 214 /* ArrowFunction */ || - ancestor.parent.kind === 169 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + ancestor.parent.kind === 213 /* SyntaxKind.FunctionExpression */ || + ancestor.parent.kind === 214 /* SyntaxKind.ArrowFunction */ || + ancestor.parent.kind === 169 /* SyntaxKind.MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -151715,7 +152467,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -151739,16 +152491,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* SyntaxKind.ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 79 /* Identifier */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 79 /* SyntaxKind.Identifier */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return true; default: return false; @@ -151762,9 +152514,9 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 79 /* Identifier */: - case 221 /* BinaryExpression */: - case 27 /* CommaToken */: + case 79 /* SyntaxKind.Identifier */: + case 221 /* SyntaxKind.BinaryExpression */: + case 27 /* SyntaxKind.CommaToken */: return true; default: return false; @@ -151774,10 +152526,10 @@ var ts; if (!ts.isBinaryExpression(expression)) { return false; } - if (expression.operatorToken.kind === 27 /* CommaToken */) { + if (expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 63 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -151812,9 +152564,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 167 /* PropertyDeclaration */ && + if (declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 135 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 135 /* SyntaxKind.DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -151928,7 +152680,7 @@ var ts; if (!errorNode) { return undefined; } - else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return { source: errorNode.parent.right, target: errorNode.parent.left }; } else if (ts.isVariableDeclaration(errorNode.parent) && errorNode.parent.initializer) { @@ -151968,7 +152720,7 @@ var ts; var add = toAdd_1[_i]; var d = add.valueDeclaration; if (d && (ts.isPropertySignature(d) || ts.isPropertyDeclaration(d)) && d.type) { - var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* UnionType */ ? d.type.types : [d.type], true), [ + var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* SyntaxKind.UnionType */ ? d.type.types : [d.type], true), [ ts.factory.createTypeReferenceNode("undefined") ], false)); changes.replaceNode(d.getSourceFile(), d.type, t); @@ -152021,9 +152773,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -152033,7 +152785,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -152048,30 +152800,30 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return transformJSDocOptionalType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return transformJSDocType(node.type); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return transformJSDocNullableType(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return transformJSDocVariadicType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return transformJSDocFunctionType(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); - ts.setEmitFlags(visited, 1 /* SingleLine */); + ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */); return visited; } } @@ -152088,13 +152840,13 @@ var ts; var _a; // TODO: This does not properly handle `function(new:C, string)` per https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#the-javascript-type-language // however we do handle it correctly in `serializeTypeForDeclaration` in checker.ts - return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 318 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 318 /* SyntaxKind.JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : node.dotDotDotToken; return ts.factory.createParameterDeclaration(node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -152131,11 +152883,11 @@ var ts; function transformJSDocIndexSignature(node) { var index = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*modifiers*/ undefined, [index], node.typeArguments[1])]); - ts.setEmitFlags(indexSignature, 1 /* SingleLine */); + ts.setEmitFlags(indexSignature, 1 /* EmitFlags.SingleLine */); return indexSignature; } })(codefix = ts.codefix || (ts.codefix = {})); @@ -152162,7 +152914,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */))) { // Bad input return undefined; } @@ -152195,14 +152947,14 @@ var ts; if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements); } } else { - createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)], memberElements); + createClassElement(member, [ts.factory.createToken(124 /* SyntaxKind.StaticKeyword */)], memberElements); } }); } @@ -152253,7 +153005,7 @@ var ts; function createClassElement(symbol, modifiers, members) { // Right now the only thing we can convert are function expressions, which are marked as methods // or { x: y } type prototype assignments, which are marked as ObjectLiteral - if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + if (!(symbol.flags & 8192 /* SymbolFlags.Method */) && !(symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */)) { return; } var memberDeclaration = symbol.valueDeclaration; @@ -152272,7 +153024,7 @@ var ts; return; } // 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 === 238 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -152324,7 +153076,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -152335,14 +153087,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 235 /* Block */) { + if (arrowFunctionBody.kind === 235 /* SyntaxKind.Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -152359,7 +153111,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -152370,7 +153122,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -152397,7 +153149,7 @@ var ts; } if (ts.isStringLiteralLike(propName)) { return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text) - : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */) + : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* QuotePreference.Single */) : propName; } return undefined; @@ -152455,8 +153207,8 @@ var ts; return; } var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos); - changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, { suffix: " " }); - var _loop_13 = function (returnStatement) { + changes.insertModifierAt(sourceFile, pos, 131 /* SyntaxKind.AsyncKeyword */, { suffix: " " }); + var _loop_12 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false); @@ -152478,7 +153230,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var returnStatement = returnStatements_1[_i]; - var state_5 = _loop_13(returnStatement); + var state_5 = _loop_12(returnStatement); if (typeof state_5 === "object") return state_5.value; } @@ -152530,7 +153282,7 @@ var ts; // NOTE: this is a mostly copy of `isReferenceToType` from checker.ts. While this violates DRY, it keeps // `isReferenceToType` in checker local to the checker to avoid the cost of a property lookup on `ts`. function isReferenceToType(type, target) { - return (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + return (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getExplicitPromisedTypeOfPromiseReturningCallExpression(node, callback, checker) { @@ -152593,7 +153345,7 @@ var ts; var ident = (firstParameter === null || firstParameter === void 0 ? void 0 : firstParameter.valueDeclaration) && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) - || ts.factory.createUniqueName("result", 16 /* Optimistic */); + || ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -152674,7 +153426,7 @@ var ts; } function isNullOrUndefined(_a, node) { var checker = _a.checker; - if (node.kind === 104 /* NullKeyword */) + if (node.kind === 104 /* SyntaxKind.NullKeyword */) return true; if (ts.isIdentifier(node) && !ts.isGeneratedIdentifier(node) && ts.idText(node) === "undefined") { var symbol = checker.getSymbolAtLocation(node); @@ -152683,7 +153435,7 @@ var ts; return false; } function createUniqueSynthName(prevArgName) { - var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* Optimistic */); + var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* GeneratedIdentifierFlags.Optimistic */); return createSynthIdentifier(renamedPrevArg); } function getPossibleNameForVarDecl(node, transformer, continuationArgName) { @@ -152703,7 +153455,7 @@ var ts; }); } else { - possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* Optimistic */), continuationArgName.types); + possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */), continuationArgName.types); } // We are about to write a 'let' variable declaration, but `transformExpression` for both // the try block and catch/finally block will assign to this name. Setting this flag indicates @@ -152719,10 +153471,10 @@ var ts; if (possibleNameForVarDecl && !shouldReturn(node, transformer)) { varDeclIdentifier = ts.getSynthesizedDeepClone(declareSynthIdentifier(possibleNameForVarDecl)); var typeArray = possibleNameForVarDecl.types; - var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */); + var unionType = transformer.checker.getUnionType(typeArray, 2 /* UnionReduction.Subtype */); var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); var varDecl = [ts.factory.createVariableDeclaration(varDeclIdentifier, /*exclamationToken*/ undefined, unionTypeNode)]; - var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* Let */)); + var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* NodeFlags.Let */)); statements.push(varDeclList); } statements.push(tryStatement); @@ -152732,7 +153484,7 @@ var ts; ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingPattern(continuationArgName)), /*exclamationToken*/ undefined, /*type*/ undefined, varDeclIdentifier) - ], 2 /* Const */))); + ], 2 /* NodeFlags.Const */))); } return statements; } @@ -152837,12 +153589,12 @@ var ts; /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingName(variableName)), /*exclamationToken*/ undefined, typeAnnotation, rightHandSide) - ], 2 /* Const */)) + ], 2 /* NodeFlags.Const */)) ]; } function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) { if (typeAnnotation && expressionToReturn) { - var name = ts.factory.createUniqueName("result", 16 /* Optimistic */); + var name = ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); return __spreadArray(__spreadArray([], createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), true), [ ts.factory.createReturnStatement(name) ], false); @@ -152858,11 +153610,11 @@ var ts; function transformCallbackArgument(func, hasContinuation, continuationArgName, inputArgName, parent, transformer) { var _a; switch (func.kind) { - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // do not produce a transformed statement for a null argument break; - case 206 /* PropertyAccessExpression */: - case 79 /* Identifier */: // identifier includes undefined + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: // identifier includes undefined if (!inputArgName) { // undefined was argument passed to promise handler break; @@ -152872,7 +153624,7 @@ var ts; return maybeAnnotateAndReturn(synthCall, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker)); } var type = transformer.checker.getTypeAtLocation(func); - var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!callSignatures.length) { // if identifier in handler has no call signatures, it's invalid return silentFail(); @@ -152883,8 +153635,8 @@ var ts; continuationArgName.types.push(transformer.checker.getAwaitedType(returnType) || returnType); } return varDeclOrAssignment; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: { + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_a = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _a === void 0 ? void 0 : _a.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -152986,7 +153738,7 @@ var ts; return !!checker.getPromisedTypeOfPromise(type) ? ts.factory.createAwaitExpression(rightHandSide) : rightHandSide; } function getLastCallSignature(type, checker) { - var callSignatures = checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); return ts.lastOrUndefined(callSignatures); } function removeReturns(stmts, prevArgName, transformer, seenReturnStatement) { @@ -153003,7 +153755,7 @@ var ts; ret.push(ts.factory.createExpressionStatement(ts.factory.createAssignment(referenceSynthIdentifier(prevArgName), possiblyAwaitedExpression))); } else { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* NodeFlags.Const */)))); } } } @@ -153013,7 +153765,7 @@ var ts; } // if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables if (!seenReturnStatement && prevArgName !== undefined) { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* NodeFlags.Const */)))); } return ret; } @@ -153095,12 +153847,12 @@ var ts; } function createSynthIdentifier(identifier, types) { if (types === void 0) { types = []; } - return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; + return { kind: 0 /* SynthBindingNameKind.Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; } function createSynthBindingPattern(bindingPattern, elements, types) { if (elements === void 0) { elements = ts.emptyArray; } if (types === void 0) { types = []; } - return { kind: 1 /* BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; + return { kind: 1 /* SynthBindingNameKind.BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; } function referenceSynthIdentifier(synthId) { synthId.hasBeenReferenced = true; @@ -153121,10 +153873,10 @@ var ts; return synthId.identifier; } function isSynthIdentifier(bindingName) { - return bindingName.kind === 0 /* Identifier */; + return bindingName.kind === 0 /* SynthBindingNameKind.Identifier */; } function isSynthBindingPattern(bindingName) { - return bindingName.kind === 1 /* BindingPattern */; + return bindingName.kind === 1 /* SynthBindingNameKind.BindingPattern */; } function shouldReturn(expression, transformer) { return !!expression.original && transformer.setOfExpressionsToReturn.has(ts.getNodeId(expression.original)); @@ -153162,10 +153914,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -153205,9 +153957,9 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. - res.set(text, makeUniqueName("_" + text, identifiers)); + res.set(text, makeUniqueName("_".concat(text), identifiers)); } }); return res; @@ -153225,29 +153977,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression) && ts.isIdentifier(node.name)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -153294,8 +154046,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -153303,11 +154055,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form ".concat(name.kind)); } } function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) { @@ -153346,19 +154098,19 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return undefined; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 169 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 169 /* SyntaxKind.MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)], prop, useSitesToUnqualify); default: - ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind ".concat(prop.kind)); } }); return statements && [statements, false]; @@ -153387,8 +154139,8 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyMap; - return exports.has("export=" /* ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : - !exports.has("default" /* Default */) ? [[reExportStar(moduleSpecifier)], false] : + return exports.has("export=" /* InternalSymbolName.ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default" /* InternalSymbolName.Default */) ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } @@ -153403,23 +154155,23 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* SyntaxKind.SemicolonToken */, sourceFile); if (semi) changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* SyntaxKind.DotToken */, sourceFile), [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { - var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)]; switch (exported.kind) { - case 213 /* FunctionExpression */: { + case 213 /* SyntaxKind.FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -153427,10 +154179,10 @@ var ts; } } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -153450,7 +154202,7 @@ var ts; : ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode); function replaceNode(original) { // We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions - if (original.kind === 206 /* PropertyAccessExpression */) { + if (original.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var replacement = useSitesToUnqualify.get(original); // Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing useSitesToUnqualify.delete(original); @@ -153465,7 +154217,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -153476,7 +154228,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 202 /* ArrayBindingPattern */: { + case 202 /* SyntaxKind.ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -153487,10 +154239,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind ".concat(name.kind)); } } /** @@ -153547,7 +154299,7 @@ var ts; // Identifiers helpers function makeUniqueName(name, identifiers) { while (identifiers.original.has(name) || identifiers.additional.has(name)) { - name = "_" + name; + name = "_".concat(name); } identifiers.additional.add(name); return name; @@ -153569,11 +154321,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return parent.name !== node; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return parent.propertyName !== node; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -153595,7 +154347,7 @@ var ts; return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName !== undefined && propertyName !== name ? ts.factory.createIdentifier(propertyName) : undefined, ts.factory.createIdentifier(name)); } function makeConst(modifiers, name, init) { - return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* Const */)); + return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* NodeFlags.Const */)); } function makeExportDeclaration(exportSpecifiers, moduleSpecifier) { return ts.factory.createExportDeclaration( @@ -153624,7 +154376,7 @@ var ts; if (!qualifiedName) return undefined; var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, qualifiedName); }); - var newText = qualifiedName.left.text + "[\"" + qualifiedName.right.text + "\"]"; + var newText = "".concat(qualifiedName.left.text, "[\"").concat(qualifiedName.right.text, "\"]"); return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Rewrite_as_the_indexed_access_type_0, newText], fixId, ts.Diagnostics.Rewrite_all_as_indexed_access_types)]; }, fixIds: [fixId], @@ -153684,7 +154436,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 152 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 152 /* SyntaxKind.TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.modifiers, @@ -153851,7 +154603,7 @@ var ts; return ts.Debug.checkDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { - return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* ModifierFlags.Private */); } function addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { var checker = context.program.getTypeChecker(); @@ -153864,10 +154616,10 @@ var ts; var classType = checker.getTypeAtLocation(classDeclaration); var constructor = ts.find(classDeclaration.members, function (m) { return ts.isConstructorDeclaration(m); }); if (!classType.getNumberIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */); + createMissingIndexSignatureDeclaration(implementedType, 1 /* IndexKind.Number */); } if (!classType.getStringIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); + createMissingIndexSignatureDeclaration(implementedType, 0 /* IndexKind.String */); } var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host); codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); }); @@ -153973,20 +154725,20 @@ var ts; var fixes = info.fixes, symbolName = info.symbolName; var fix = ts.first(fixes); switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addToNamespace.push(fix); break; - case 1 /* JsdocTypeImport */: + case 1 /* ImportFixKind.JsdocTypeImport */: importType.push(fix); break; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly; var key = String(ts.getNodeId(importClauseOrBindingPattern)); var entry = addToExisting.get(key); if (!entry) { addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: new ts.Map() }); } - if (importKind === 0 /* Named */) { + if (importKind === 0 /* ImportKind.Named */) { var prevValue = entry === null || entry === void 0 ? void 0 : entry.namedImports.get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); } @@ -153999,32 +154751,32 @@ var ts; } break; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, addAsTypeOnly = fix.addAsTypeOnly; var entry = getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly); ts.Debug.assert(entry.useRequire === useRequire, "(Add new) Tried to add an `import` and a `require` for the same module"); switch (importKind) { - case 1 /* Default */: + case 1 /* ImportKind.Default */: ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport.name === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = { name: symbolName, addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) === null || _b === void 0 ? void 0 : _b.addAsTypeOnly, addAsTypeOnly) }; break; - case 0 /* Named */: + case 0 /* ImportKind.Named */: var prevValue = (entry.namedImports || (entry.namedImports = new ts.Map())).get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); break; - case 3 /* CommonJS */: - case 2 /* Namespace */: + case 3 /* ImportKind.CommonJS */: + case 2 /* ImportKind.Namespace */: ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly }; break; } break; } - case 4 /* PromoteTypeOnly */: + case 4 /* ImportFixKind.PromoteTypeOnly */: // Excluding from fix-all break; default: - ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); + ts.Debug.assertNever(fix, "fix wasn't never - got kind ".concat(fix.kind)); } function reduceAddAsTypeOnlyValues(prevValue, newValue) { // `NotAllowed` overrides `Required` because one addition of a new import might be required to be type-only @@ -154052,13 +154804,13 @@ var ts; namespaceLikeImport: undefined, useRequire: useRequire }; - if (importKind === 1 /* Default */ && addAsTypeOnly === 2 /* Required */) { + if (importKind === 1 /* ImportKind.Default */ && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */) { if (typeOnlyEntry) return typeOnlyEntry; newImports.set(typeOnlyKey, newEntry); return newEntry; } - if (addAsTypeOnly === 1 /* Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { + if (addAsTypeOnly === 1 /* AddAsTypeOnly.Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { return (typeOnlyEntry || nonTypeOnlyEntry); } if (nonTypeOnlyEntry) { @@ -154068,7 +154820,7 @@ var ts; return newEntry; } function newImportsKey(moduleSpecifier, topLevelTypeOnly) { - return (topLevelTypeOnly ? 1 : 0) + "|" + moduleSpecifier; + return "".concat(topLevelTypeOnly ? 1 : 0, "|").concat(moduleSpecifier); } } function writeFixes(changeTracker) { @@ -154158,7 +154910,7 @@ var ts; var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions); var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program); var includeSymbolNameInDescription = symbolName !== symbolToken.text; - return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions)); + return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* QuotePreference.Double */, compilerOptions)); } codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction; function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) { @@ -154186,7 +154938,7 @@ var ts; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; + return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; } } } @@ -154209,7 +154961,7 @@ var ts; for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) { - result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); + result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); } } }); @@ -154261,7 +155013,7 @@ var ts; if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; + return { kind: 0 /* ImportFixKind.UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -154269,11 +155021,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport); return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol); default: @@ -154283,11 +155035,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return declaration.name.text; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text; default: return ts.Debug.assertNever(declaration); @@ -154296,31 +155048,31 @@ var ts; function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, symbol, targetFlags, checker, compilerOptions) { if (!isValidTypeOnlyUseSite) { // Can't use a type-only import if the usage is an emitting position - return 4 /* NotAllowed */; + return 4 /* AddAsTypeOnly.NotAllowed */; } - if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* Error */) { + if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */) { // Not writing a (top-level) type-only import here would create an error because the runtime dependency is unnecessary - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } if (compilerOptions.isolatedModules && compilerOptions.preserveValueImports && - (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { + (!(targetFlags & 111551 /* SymbolFlags.Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { // A type-only import is required for this symbol if under these settings if the symbol will // be erased, which will happen if the target symbol is purely a type or if it was exported/imported // as type-only already somewhere between this import and the target. - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } - return 1 /* Allowed */; + return 1 /* AddAsTypeOnly.Allowed */; } function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - if (importKind === 3 /* CommonJS */ || importKind === 2 /* Namespace */ || declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (importKind === 3 /* ImportKind.CommonJS */ || importKind === 2 /* ImportKind.Namespace */ || declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // These kinds of imports are not combinable with anything return undefined; } - if (declaration.kind === 254 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 201 /* ObjectBindingPattern */ - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } + if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { + return (importKind === 0 /* ImportKind.Named */ || importKind === 1 /* ImportKind.Default */) && declaration.name.kind === 201 /* SyntaxKind.ObjectBindingPattern */ + ? { kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* AddAsTypeOnly.NotAllowed */ } : undefined; } var importClause = declaration.importClause; @@ -154329,22 +155081,22 @@ var ts; var name = importClause.name, namedBindings = importClause.namedBindings; // A type-only import may not have both a default and named imports, so the only way a name can // be added to an existing type-only import is adding a named import to existing named bindings. - if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings)) + if (importClause.isTypeOnly && !(importKind === 0 /* ImportKind.Named */ && namedBindings)) return undefined; // N.B. we don't have to figure out whether to use the main program checker // or the AutoImportProvider checker because we're adding to an existing import; the existence of // the import guarantees the symbol came from the main program. var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ false, symbol, targetFlags, checker, compilerOptions); - if (importKind === 1 /* Default */ && (name || // Cannot add a default import to a declaration that already has one - addAsTypeOnly === 2 /* Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings + if (importKind === 1 /* ImportKind.Default */ && (name || // Cannot add a default import to a declaration that already has one + addAsTypeOnly === 2 /* AddAsTypeOnly.Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings )) return undefined; - if (importKind === 0 /* Named */ && - (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import + if (importKind === 0 /* ImportKind.Named */ && + (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* SyntaxKind.NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import ) return undefined; return { - kind: 2 /* AddToExisting */, + kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, @@ -154363,7 +155115,7 @@ var ts; (importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent); } } - else if (i.kind === 266 /* ImportDeclaration */ || i.kind === 265 /* ImportEqualsDeclaration */) { + else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); if (moduleSymbol) { (importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i); @@ -154374,7 +155126,7 @@ var ts; getImportsForExportInfo: function (_a) { var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol; // Can't use an es6 import for a type in JS. - if (!(targetFlags & 111551 /* Value */) && ts.isSourceFileJS(importingFile)) + if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile)) return ts.emptyArray; var matchingDeclarations = importMap === null || importMap === void 0 ? void 0 : importMap.get(ts.getSymbolId(moduleSymbol)); if (!matchingDeclarations) @@ -154425,15 +155177,15 @@ var ts; var fixes = ts.flatMap(exportInfo, function (exportInfo, i) { var checker = getChecker(exportInfo.isFromPackageJson); var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers; - var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */); + var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* SymbolFlags.Value */); var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions); computedWithoutCacheCount += computedWithoutCache ? 1 : 0; return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) { return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined : // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : + !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* ImportFixKind.JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : { - kind: 3 /* AddNew */, + kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), useRequire: useRequire, @@ -154455,9 +155207,9 @@ var ts; var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (moduleSpecifier) { var addAsTypeOnly = useRequire - ? 4 /* NotAllowed */ + ? 4 /* AddAsTypeOnly.NotAllowed */ : getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, symbol, targetFlags, checker, compilerOptions); - return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; + return { kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; } } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -154488,23 +155240,23 @@ var ts; if (!ts.some(fixes)) return; // These will always be placed first if available, and are better than other kinds - if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) { + if (fixes[0].kind === 0 /* ImportFixKind.UseNamespace */ || fixes[0].kind === 2 /* ImportFixKind.AddToExisting */) { return fixes[0]; } return fixes.reduce(function (best, fix) { // Takes true branch of conditional if `fix` is better than `best` - return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best; + return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* Comparison.LessThan */ ? fix : best; }); } /** @returns `Comparison.LessThan` if `a` is better than `b`. */ function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) { - if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + if (a.kind !== 0 /* ImportFixKind.UseNamespace */ && b.kind !== 0 /* ImportFixKind.UseNamespace */) { return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath)) || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export. // E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`. @@ -154527,10 +155279,10 @@ var ts; } function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) { if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; if (ts.startsWith(b, "node:") && !ts.startsWith(a, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* GreaterThan */ : -1 /* LessThan */; - return 0 /* EqualTo */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* Comparison.GreaterThan */ : -1 /* Comparison.LessThan */; + return 0 /* Comparison.EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var _b; @@ -154541,7 +155293,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; + var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* ExportKind.UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined; var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes; @@ -154555,7 +155307,7 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } /** @@ -154564,10 +155316,10 @@ var ts; */ function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) { switch (exportKind) { - case 0 /* Named */: return 0 /* Named */; - case 1 /* Default */: return 1 /* Default */; - case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); - case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 0 /* ExportKind.Named */: return 0 /* ImportKind.Named */; + case 1 /* ExportKind.Default */: return 1 /* ImportKind.Default */; + case 2 /* ExportKind.ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 3 /* ExportKind.UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); default: return ts.Debug.assertNever(exportKind); } } @@ -154575,7 +155327,7 @@ var ts; function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { - return 1 /* Default */; + return 1 /* ImportKind.Default */; } // When a synthetic `default` is unavailable, use `import..require` if the module kind supports it. var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -154584,9 +155336,9 @@ var ts; case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */; + return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; } - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: case ts.ModuleKind.ES2020: @@ -154594,12 +155346,12 @@ var ts; case ts.ModuleKind.ESNext: case ts.ModuleKind.None: // Fall back to the `import * as ns` style import. - return 2 /* Namespace */; + return 2 /* ImportKind.Namespace */; case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: - return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */; + return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; default: - return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind ".concat(moduleKind)); } } function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { @@ -154608,7 +155360,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, but appears as an identifier. - if (symbolName === "default" /* Default */) { + if (symbolName === "default" /* InternalSymbolName.Default */) { return undefined; } var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken); @@ -154622,13 +155374,13 @@ var ts; } function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) { var checker = program.getTypeChecker(); - var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); if (!symbol) return undefined; var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol); if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile) return undefined; - return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; + return { kind: 4 /* ImportFixKind.PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; } function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; @@ -154643,8 +155395,8 @@ var ts; function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) { if (ts.isIntrinsicJsxName(symbolToken.text)) return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory - var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); - return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */); + var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); + return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* SymbolFlags.Value */); } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) { @@ -154676,7 +155428,7 @@ var ts; // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* ExportKind.Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; @@ -154687,14 +155439,14 @@ var ts; // 1. 'import =' will not work in es2015+ TS files, so the decision is between a default // and a namespace import, based on allowSyntheticDefaultImports/esModuleInterop. if (!isJS && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { - return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */; } // 2. 'import =' will not work in JavaScript, so the decision is between a default import, // a namespace import, and const/require. if (isJS) { return ts.isExternalModule(importingFile) || forceImportKeyword - ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ - : 3 /* CommonJS */; + ? allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */ + : 3 /* ImportKind.CommonJS */; } // 3. At this point the most correct choice is probably 'import =', but people // really hate that, so look to see if the importing file has any precedent @@ -154703,12 +155455,12 @@ var ts; var statement = _a[_i]; // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; } } // 4. We have no precedent to go on, so just use a default import if // allowSyntheticDefaultImports/esModuleInterop is enabled. - return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 3 /* ImportKind.CommonJS */; } function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { var diag; @@ -154719,45 +155471,45 @@ var ts; } function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addNamespaceQualifier(changes, sourceFile, fix); - return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; - case 1 /* JsdocTypeImport */: + return [ts.Diagnostics.Change_0_to_1, symbolName, "".concat(fix.namespacePrefix, ".").concat(symbolName)]; + case 1 /* ImportFixKind.JsdocTypeImport */: addImportType(changes, sourceFile, fix, quotePreference); return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName]; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier; - doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); + doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes] : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes]; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire; var getDeclarations = useRequire ? getNewRequires : getNewImports; - var defaultImport = importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; - var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; - var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var defaultImport = importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var namedImports = importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; + var namespaceLikeImport = importKind === 2 /* ImportKind.Namespace */ || importKind === 3 /* ImportKind.CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier] : [ts.Diagnostics.Add_import_from_0, moduleSpecifier]; } - case 4 /* PromoteTypeOnly */: { + case 4 /* ImportFixKind.PromoteTypeOnly */: { var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration; var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile); - return promotedDeclaration.kind === 270 /* ImportSpecifier */ + return promotedDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)] : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)]; } default: - return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); + return ts.Debug.assertNever(fix, "Unexpected fix kind ".concat(fix.kind)); } } function getModuleSpecifierText(promotedDeclaration) { var _a, _b; - return promotedDeclaration.kind === 265 /* ImportEqualsDeclaration */ + return promotedDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText() : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text; } @@ -154765,7 +155517,7 @@ var ts; // See comment in `doAddExistingFix` on constant with the same name. var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules; switch (aliasDeclaration.kind) { - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: if (aliasDeclaration.isTypeOnly) { if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) { changes.delete(sourceFile, aliasDeclaration); @@ -154783,13 +155535,13 @@ var ts; promoteImportClause(aliasDeclaration.parent.parent); return aliasDeclaration.parent.parent; } - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: promoteImportClause(aliasDeclaration); return aliasDeclaration; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: promoteImportClause(aliasDeclaration.parent); return aliasDeclaration.parent; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1)); return aliasDeclaration; default: @@ -154801,7 +155553,7 @@ var ts; var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports); if (namedImports && namedImports.elements.length > 1) { if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) && - aliasDeclaration.kind === 270 /* ImportSpecifier */ && + aliasDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && namedImports.elements.indexOf(aliasDeclaration) !== 0) { // The import specifier being promoted will be the only non-type-only, // import in the NamedImports, so it should be moved to the front. @@ -154811,7 +155563,7 @@ var ts; for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) { var element = _a[_i]; if (element !== aliasDeclaration && !element.isTypeOnly) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, element); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, element); } } } @@ -154820,7 +155572,7 @@ var ts; } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) { var _a; - if (clause.kind === 201 /* ObjectBindingPattern */) { + if (clause.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport.name, "default"); } @@ -154830,7 +155582,7 @@ var ts; } return; } - var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* NotAllowed */; }); + var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* AddAsTypeOnly.NotAllowed */; }); var existingSpecifiers = clause.namedBindings && ((_a = ts.tryCast(clause.namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements); // If we are promoting from a type-only import and `--isolatedModules` and `--preserveValueImports` // are enabled, we need to make every existing import specifier type-only. It may be possible that @@ -154881,7 +155633,7 @@ var ts; if (convertExistingToTypeOnly && existingSpecifiers) { for (var _d = 0, existingSpecifiers_1 = existingSpecifiers; _d < existingSpecifiers_1.length; _d++) { var specifier = existingSpecifiers_1[_d]; - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, specifier); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, specifier); } } } @@ -154905,11 +155657,11 @@ var ts; } function getImportTypePrefix(moduleSpecifier, quotePreference) { var quote = ts.getQuoteFromPreference(quotePreference); - return "import(" + quote + moduleSpecifier + quote + ")."; + return "import(".concat(quote).concat(moduleSpecifier).concat(quote, ")."); } function needsTypeOnly(_a) { var addAsTypeOnly = _a.addAsTypeOnly; - return addAsTypeOnly === 2 /* Required */; + return addAsTypeOnly === 2 /* AddAsTypeOnly.Required */; } function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport) { var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); @@ -154918,12 +155670,12 @@ var ts; var topLevelTypeOnly_1 = (!defaultImport || needsTypeOnly(defaultImport)) && ts.every(namedImports, needsTypeOnly); statements = ts.combine(statements, ts.makeImport(defaultImport && ts.factory.createIdentifier(defaultImport.name), namedImports === null || namedImports === void 0 ? void 0 : namedImports.map(function (_a) { var addAsTypeOnly = _a.addAsTypeOnly, name = _a.name; - return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* Required */, + return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */, /*propertyName*/ undefined, ts.factory.createIdentifier(name)); }), moduleSpecifier, quotePreference, topLevelTypeOnly_1)); } if (namespaceLikeImport) { - var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ + var declaration = namespaceLikeImport.importKind === 3 /* ImportKind.CommonJS */ ? ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, needsTypeOnly(namespaceLikeImport), ts.factory.createIdentifier(namespaceLikeImport.name), ts.factory.createExternalModuleReference(quotedModuleSpecifier)) : ts.factory.createImportDeclaration( @@ -154962,7 +155714,7 @@ var ts; ts.factory.createVariableDeclaration(typeof name === "string" ? ts.factory.createIdentifier(name) : name, /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createCallExpression(ts.factory.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -154999,7 +155751,7 @@ var ts; lastCharWasValid = isValid; } // Need `|| "_"` to ensure result isn't empty. - return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; + return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_".concat(res); } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; })(codefix = ts.codefix || (ts.codefix = {})); @@ -155025,54 +155777,90 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var sourceFile = context.sourceFile, span = context.span, program = context.program; - var related = getDiagnosticRelatedInfo(program, sourceFile, span); - if (!related) { + var sourceFile = context.sourceFile, span = context.span, program = context.program, preferences = context.preferences, host = context.host; + var info = getInfo(program, sourceFile, span); + if (info === undefined) return; - } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, program, preferences, host, sourceFile, info); }); return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag); - if (!info) - return; - return addMissingConstraint(changes, info); - }); }, + getAllCodeActions: function (context) { + var program = context.program, preferences = context.preferences, host = context.host; + var seen = new ts.Map(); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length)); + if (info) { + if (ts.addToSeen(seen, ts.getNodeId(info.declaration))) { + return addMissingConstraint(changes, program, preferences, host, diag.file, info); + } + } + return undefined; + }); + })); + } }); - function getDiagnosticRelatedInfo(program, sourceFile, span) { + function getInfo(program, sourceFile, span) { var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; }); - if (!diag || !diag.relatedInformation) + if (diag === undefined || diag.relatedInformation === undefined) return; var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; }); - if (!related) + if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined) return; - return related; - } - function addMissingConstraint(changes, related) { - var decl = findAncestorMatchingSpan(related.file, related); - if (!decl) + var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length)); + if (declaration === undefined) return; - if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) { - decl = decl.parent; + if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) { + declaration = declaration.parent; + } + if (ts.isTypeParameterDeclaration(declaration)) { + // should only issue fix on type parameters written using `extends` + if (ts.isMappedTypeNode(declaration.parent)) + return; + var token = ts.getTokenAtPosition(sourceFile, span.start); + var checker = program.getTypeChecker(); + var constraint = tryGetConstraintType(checker, token) || tryGetConstraintFromDiagnosticMessage(related.messageText); + return { constraint: constraint, declaration: declaration, token: token }; + } + return undefined; + } + function addMissingConstraint(changes, program, preferences, host, sourceFile, info) { + var declaration = info.declaration, constraint = info.constraint; + var checker = program.getTypeChecker(); + if (ts.isString(constraint)) { + changes.insertText(sourceFile, declaration.name.end, " extends ".concat(constraint)); + } + else { + var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); + var tracker = codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }); + var importAdder = codefix.createImportAdder(sourceFile, program, preferences, host); + var typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, scriptTarget, /*flags*/ undefined, tracker); + if (typeNode) { + changes.replaceNode(sourceFile, declaration, ts.factory.updateTypeParameterDeclaration(declaration, /*modifiers*/ undefined, declaration.name, typeNode, declaration.default)); + importAdder.writeFixes(changes); + } } - if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent)) - return; // should only issue fix on type parameters written using `extends` - var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/); - if (!newConstraint) - return; - var newConstraintText = newConstraint[1]; - changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText); } function findAncestorMatchingSpan(sourceFile, span) { - var token = ts.getTokenAtPosition(sourceFile, span.start); var end = ts.textSpanEnd(span); + var token = ts.getTokenAtPosition(sourceFile, span.start); while (token.end < end) { token = token.parent; } return token; } + function tryGetConstraintFromDiagnosticMessage(messageText) { + var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1]; + return constraint; + } + function tryGetConstraintType(checker, node) { + if (ts.isTypeNode(node.parent)) { + return checker.getTypeArgumentConstraint(node.parent); + } + var contextualType = ts.isExpression(node) ? checker.getContextualType(node) : undefined; + return contextualType || checker.getTypeAtLocation(node); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -155205,7 +155993,7 @@ var ts; accessibilityModifier ? accessibilityModifier.end : lastDecorator ? ts.skipTrivia(sourceFile.text, lastDecorator.end) : classElement.getStart(sourceFile); var options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " }; - changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* OverrideKeyword */, options); + changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* SyntaxKind.OverrideKeyword */, options); } function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { var classElement = findContainerClassElementLike(sourceFile, pos); @@ -155219,13 +156007,13 @@ var ts; } function isClassElementLikeHasJSDoc(node) { switch (node.kind) { - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.isParameterPropertyDeclaration(node, node.parent); default: return false; @@ -155267,7 +156055,7 @@ var ts; }); function doChange(changes, sourceFile, node, preferences) { var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */); + var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* QuotePreference.Single */); changes.replaceNode(sourceFile, node, ts.isPropertyAccessChain(node) ? ts.factory.createElementAccessChain(node.expression, node.questionDotToken, argumentsExpression) : ts.factory.createElementAccessExpression(node.expression, argumentsExpression)); @@ -155307,7 +156095,7 @@ var ts; if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn)) return undefined; if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function - var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* SyntaxKind.FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -155326,7 +156114,7 @@ var ts; else { // `function f() {}` => `const f = () => {}` // `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`. - changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -155357,7 +156145,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 197 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 197 /* SyntaxKind.NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -155366,16 +156154,16 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 185 /* OptionalType */ || unwrappedType.kind === 186 /* RestType */ || unwrappedType.kind === 191 /* ParenthesizedType */) { - if (unwrappedType.kind === 185 /* OptionalType */) { + while (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */ || unwrappedType.kind === 186 /* SyntaxKind.RestType */ || unwrappedType.kind === 191 /* SyntaxKind.ParenthesizedType */) { + if (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 186 /* RestType */) { + else if (unwrappedType.kind === 186 /* SyntaxKind.RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; } - var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined), unwrappedType); + var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined), unwrappedType); if (updated === namedTupleMember) { return; } @@ -155441,18 +156229,18 @@ var ts; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); - if (parent.flags & 32 /* OptionalChain */) { + if (parent.flags & 32 /* NodeFlags.OptionalChain */) { containingType = checker.getNonNullableType(containingType); } suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType); } - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { var receiverType = checker.getTypeAtLocation(parent.right); suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, receiverType); } else if (ts.isQualifiedName(parent) && parent.right === node) { var symbol = checker.getSymbolAtLocation(parent.left); - if (symbol && symbol.flags & 1536 /* Module */) { + if (symbol && symbol.flags & 1536 /* SymbolFlags.Module */) { suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(parent.right, symbol); } } @@ -155470,7 +156258,7 @@ var ts; var props = checker.getContextualTypeForArgumentAtIndex(tag, 0); suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props); } - else if (ts.hasSyntacticModifier(parent, 16384 /* Override */) && ts.isClassElement(parent) && parent.name === node) { + else if (ts.hasSyntacticModifier(parent, 16384 /* ModifierFlags.Override */) && ts.isClassElement(parent) && parent.name === node) { var baseDeclaration = ts.findAncestor(node, ts.isClassLike); var baseTypeNode = baseDeclaration ? ts.getEffectiveBaseTypeNode(baseDeclaration) : undefined; var baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : undefined; @@ -155503,14 +156291,14 @@ var ts; } function convertSemanticMeaningToSymbolFlags(meaning) { var flags = 0; - if (meaning & 4 /* Namespace */) { - flags |= 1920 /* Namespace */; + if (meaning & 4 /* SemanticMeaning.Namespace */) { + flags |= 1920 /* SymbolFlags.Namespace */; } - if (meaning & 2 /* Type */) { - flags |= 788968 /* Type */; + if (meaning & 2 /* SemanticMeaning.Type */) { + flags |= 788968 /* SymbolFlags.Type */; } - if (meaning & 1 /* Value */) { - flags |= 111551 /* Value */; + if (meaning & 1 /* SemanticMeaning.Value */) { + flags |= 111551 /* SymbolFlags.Value */; } return flags; } @@ -155582,7 +156370,7 @@ var ts; }); }, }); function createObjectTypeFromLabeledExpression(checker, label, expression) { - var member = checker.createSymbol(4 /* Property */, label.escapedText); + var member = checker.createSymbol(4 /* SymbolFlags.Property */, label.escapedText); member.type = checker.getTypeAtLocation(expression); var members = ts.createSymbolTable([member]); return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], []); @@ -155641,7 +156429,7 @@ var ts; if (isFunctionType) { var sig = checker.getSignatureFromDeclaration(declaration); if (sig) { - if (ts.hasSyntacticModifier(declaration, 256 /* Async */)) { + if (ts.hasSyntacticModifier(declaration, 256 /* ModifierFlags.Async */)) { exprType = checker.createPromiseType(exprType); } var newSig = checker.createSignature(declaration, sig.typeParameters, sig.thisParameter, sig.parameters, exprType, @@ -155685,19 +156473,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: return declaration.initializer; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 297 /* ShorthandPropertyAssignment */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return undefined; } } @@ -155759,19 +156547,19 @@ var ts; if (!info) { return undefined; } - if (info.kind === 3 /* ObjectLiteral */) { + if (info.kind === 3 /* InfoKind.ObjectLiteral */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); }); return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)]; } - if (info.kind === 4 /* JsxAttributes */) { + if (info.kind === 4 /* InfoKind.JsxAttributes */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); }); return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)]; } - if (info.kind === 2 /* Function */) { + if (info.kind === 2 /* InfoKind.Function */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); }); return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)]; } - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); }); return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; } @@ -155789,20 +156577,20 @@ var ts; if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { return; } - if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) { + if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* InfoKind.Function */) { addFunctionDeclaration(changes, context, info); } - else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) { + else if (fixId === fixMissingProperties && info.kind === 3 /* InfoKind.ObjectLiteral */) { addObjectLiteralProperties(changes, context, info); } - else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) { + else if (fixId === fixMissingAttributes && info.kind === 4 /* InfoKind.JsxAttributes */) { addJsxAttributes(changes, context, info); } else { - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { addEnumMemberDeclaration(changes, checker, info); } - if (info.kind === 0 /* TypeLikeDeclaration */) { + if (info.kind === 0 /* InfoKind.TypeLikeDeclaration */) { var parentDeclaration = info.parentDeclaration, token_1 = info.token; var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; }); if (!infos.some(function (i) { return i.token.text === token_1.text; })) { @@ -155813,7 +156601,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, declaration) { var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker); - var _loop_14 = function (info) { + var _loop_13 = function (info) { // If some superclass added this property, don't add it again. if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -155826,21 +156614,21 @@ var ts; var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, modifierFlags = info.modifierFlags, token = info.token, call = info.call, isJSFile = info.isJSFile; // Always prefer to add a method declaration if possible. if (call && !ts.isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile); + addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* ModifierFlags.Static */, parentDeclaration, declSourceFile); } else { if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration) && !ts.isTypeLiteralNode(parentDeclaration)) { - addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); + addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); } else { var typeNode = getTypeNode(checker, parentDeclaration, token); - addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */); + addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* ModifierFlags.Static */); } } }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_14(info); + _loop_13(info); } }); })); @@ -155861,12 +156649,12 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, tokenPos); var parent = token.parent; if (errorCode === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) { - if (!(token.kind === 18 /* OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) + if (!(token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) return undefined; var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; }); if (argIndex < 0) return undefined; - var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* Call */)); + var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */)); if (!(signature && signature.declaration && signature.parameters[argIndex])) return undefined; var param = signature.parameters[argIndex].valueDeclaration; @@ -155875,7 +156663,7 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; } if (!ts.isMemberName(token)) return undefined; @@ -155883,17 +156671,17 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; } if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) { var target = ts.getEmitScriptTarget(program.getCompilerOptions()); var attributes = getUnmatchedAttributes(checker, target, token.parent); if (!ts.length(attributes)) return undefined; - return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; + return { kind: 4 /* InfoKind.JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; } - if (ts.isIdentifier(token) && ts.isCallExpression(parent)) { - return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile }; + if (ts.isIdentifier(token) && ts.isCallExpression(parent) && parent.expression === token) { + return { kind: 2 /* InfoKind.Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* ModifierFlags.None */, parentDeclaration: sourceFile }; } if (!ts.isPropertyAccessExpression(parent)) return undefined; @@ -155905,13 +156693,13 @@ var ts; var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration); var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile(); if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration }; } var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile); if (sourceFile.commonJsModuleIndicator) return undefined; if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile }; } } var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); @@ -155925,15 +156713,15 @@ var ts; if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration))) return undefined; var declSourceFile = declaration.getSourceFile(); - var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* None */ : - (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */); + var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* ModifierFlags.None */ : + (makeStatic ? 32 /* ModifierFlags.Static */ : 0 /* ModifierFlags.None */) | (ts.startsWithUnderscore(token.text) ? 8 /* ModifierFlags.Private */ : 0 /* ModifierFlags.None */); var isJSFile = ts.isSourceFileJS(declSourceFile); var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; + return { kind: 0 /* InfoKind.TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; } var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) { - return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration }; + return { kind: 1 /* InfoKind.Enum */, token: token, parentDeclaration: enumDeclaration }; } return undefined; } @@ -155949,18 +156737,18 @@ var ts; if (ts.isInterfaceDeclaration(parentDeclaration) || ts.isTypeLiteralNode(parentDeclaration)) { return undefined; } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); }); if (changes.length === 0) { return undefined; } - var diagnostic = modifierFlags & 32 /* Static */ ? ts.Diagnostics.Initialize_static_property_0 : + var diagnostic = modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Initialize_static_property_0 : ts.isPrivateIdentifier(token) ? ts.Diagnostics.Declare_a_private_field_named_0 : ts.Diagnostics.Initialize_property_0_in_the_constructor; return codefix.createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members); } function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 226 /* ClassExpression */) { + if (classDeclaration.kind === 226 /* SyntaxKind.ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -155996,32 +156784,32 @@ var ts; function createActionsForAddMissingMemberInTypeScriptFile(context, _a) { var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token; var memberName = token.text; - var isStatic = modifierFlags & 32 /* Static */; + var isStatic = modifierFlags & 32 /* ModifierFlags.Static */; var typeNode = getTypeNode(context.program.getTypeChecker(), parentDeclaration, token); var addPropertyDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName, typeNode, modifierFlags); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; if (isStatic || ts.isPrivateIdentifier(token)) { return actions; } - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); } actions.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode)); return actions; } function getTypeNode(checker, node, token) { var typeNode; - if (token.parent.parent.kind === 221 /* BinaryExpression */) { + if (token.parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); - typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NoTruncation */); + typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NodeBuilderFlags.NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NodeBuilderFlags.NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) { var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; @@ -156049,7 +156837,7 @@ var ts; } function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "x", @@ -156072,15 +156860,15 @@ var ts; } var methodName = token.text; var addMethodDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, call, token, modifierFlags, parentDeclaration, declSourceFile); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); + var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); } return actions; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var kind = ts.isClassLike(parentDeclaration) ? 169 /* MethodDeclaration */ : 168 /* MethodSignature */; + var kind = ts.isClassLike(parentDeclaration) ? 169 /* SyntaxKind.MethodDeclaration */ : 168 /* SyntaxKind.MethodSignature */; var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression); if (containingMethodDeclaration) { @@ -156100,7 +156888,7 @@ var ts; */ var hasStringInitializer = ts.some(parentDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 402653316 /* StringLike */); + return !!(type && type.flags & 402653316 /* TypeFlags.StringLike */); }); var enumMember = ts.factory.createEnumMember(token, hasStringInitializer ? ts.factory.createStringLiteral(token.text) : undefined); changes.replaceNode(parentDeclaration.getSourceFile(), parentDeclaration, ts.factory.updateEnumDeclaration(parentDeclaration, parentDeclaration.modifiers, parentDeclaration.name, ts.concatenate(parentDeclaration.members, ts.singleElementArray(enumMember))), { @@ -156110,7 +156898,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* SyntaxKind.FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); importAdder.writeFixes(changes); } @@ -156140,7 +156928,7 @@ var ts; var checker = context.program.getTypeChecker(); var props = ts.map(info.properties, function (prop) { var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop), info.parentDeclaration); - return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer); + return ts.factory.createPropertyAssignment(createPropertyNameFromSymbol(prop, target, quotePreference, checker), initializer); }); var options = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, @@ -156151,42 +156939,42 @@ var ts; importAdder.writeFixes(changes); } function tryGetValueFromType(context, checker, importAdder, quotePreference, type, enclosingDeclaration) { - if (type.flags & 3 /* AnyOrUnknown */) { + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return createUndefined(); } - if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { - return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { return ts.factory.createNumericLiteral(0); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { return ts.factory.createBigIntLiteral("0n"); } - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return ts.factory.createFalse(); } - if (type.flags & 1056 /* EnumLike */) { + if (type.flags & 1056 /* TypeFlags.EnumLike */) { var enumMember = type.symbol.exports ? ts.firstOrUndefined(ts.arrayFrom(type.symbol.exports.values())) : type.symbol; - var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); + var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* SymbolFlags.Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); return enumMember === undefined || name === undefined ? ts.factory.createNumericLiteral(0) : ts.factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { return ts.factory.createNumericLiteral(type.value); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } - if (type.flags & 128 /* StringLiteral */) { - return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & 128 /* TypeFlags.StringLiteral */) { + return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { return ts.factory.createNull(); } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t, enclosingDeclaration); }); return expression !== null && expression !== void 0 ? expression : createUndefined(); } @@ -156200,17 +156988,17 @@ var ts; }); return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */) { + if (ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) { var decl = ts.find(type.symbol.declarations || ts.emptyArray, ts.or(ts.isFunctionTypeNode, ts.isMethodSignature, ts.isMethodDeclaration)); if (decl === undefined) return createUndefined(); - var signature = checker.getSignaturesOfType(type, 0 /* Call */); + var signature = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (signature === undefined) return createUndefined(); - var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder); + var func = codefix.createSignatureDeclarationFromSignature(213 /* SyntaxKind.FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder); return func !== null && func !== void 0 ? func : createUndefined(); } - if (ts.getObjectFlags(type) & 1 /* Class */) { + if (ts.getObjectFlags(type) & 1 /* ObjectFlags.Class */) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (classDeclaration === undefined || ts.hasAbstractModifier(classDeclaration)) return createUndefined(); @@ -156225,8 +157013,8 @@ var ts; return ts.factory.createIdentifier("undefined"); } function isObjectLiteralType(type) { - return (type.flags & 524288 /* Object */) && - ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); + return (type.flags & 524288 /* TypeFlags.Object */) && + ((ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); } function getUnmatchedAttributes(checker, target, source) { var attrsType = checker.getContextualType(source.attributes); @@ -156250,7 +157038,7 @@ var ts; } } return ts.filter(targetProps, function (targetProp) { - return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName)); + return ts.isIdentifierText(targetProp.name, target, 1 /* LanguageVariant.JSX */) && !((targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */) || seenNames.has(targetProp.escapedName)); }); } function tryGetContainingMethodDeclaration(node, callExpression) { @@ -156260,6 +157048,15 @@ var ts; var declaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); }); return declaration && declaration.parent === node ? declaration : undefined; } + function createPropertyNameFromSymbol(symbol, target, quotePreference, checker) { + if (ts.isTransientSymbol(symbol) && symbol.nameType && symbol.nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + var expression = checker.symbolToExpression(symbol.nameType.symbol, 111551 /* SymbolFlags.Value */, symbol.valueDeclaration, 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */); + if (expression) { + return ts.factory.createComputedPropertyName(expression); + } + } + return ts.createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === 0 /* QuotePreference.Single */); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -156335,7 +157132,7 @@ var ts; break; } default: - ts.Debug.fail("Bad fixId: " + context.fixId); + ts.Debug.fail("Bad fixId: ".concat(context.fixId)); } }); }, @@ -156410,7 +157207,7 @@ var ts; // See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files // (now named `codeFixClassExtendAbstractPrivateProperty.ts`) var flags = ts.getSyntacticModifierFlags(ts.first(symbol.getDeclarations())); - return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + return !(flags & 8 /* ModifierFlags.Private */) && !!(flags & 128 /* ModifierFlags.Abstract */); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -156453,7 +157250,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 108 /* ThisKeyword */) + if (token.kind !== 108 /* SyntaxKind.ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -156597,7 +157394,7 @@ var ts; codeFixes.push(codefix.createCodeFixActionWithoutFixAll("fixModuleOption", changes, [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0, "esnext"])); } var target = ts.getEmitScriptTarget(compilerOptions); - var targetOutOfRange = target < 4 /* ES2017 */ || target > 99 /* ESNext */; + var targetOutOfRange = target < 4 /* ScriptTarget.ES2017 */ || target > 99 /* ScriptTarget.ESNext */; if (targetOutOfRange) { var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { var configObject = ts.getTsConfigObjectLiteralExpression(configFile); @@ -156676,17 +157473,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* SyntaxKind.ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* SyntaxKind.ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 94 /* ExtendsKeyword */ && - heritageClauses[1].token === 117 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* SyntaxKind.ExtendsKeyword */ && + heritageClauses[1].token === 117 /* SyntaxKind.ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* SyntaxKind.CommaToken */)); // Rough heuristic: delete trailing whitespace after keyword so that it's not excessive. // (Trailing because leading might be indentation, which is more sensitive.) var text = sourceFile.text; @@ -156783,7 +157580,7 @@ var ts; if (!isValidCharacter(character)) { return; } - var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(sourceFile, preferences, character) + "}"; + var replacement = useHtmlEntity ? htmlEntity[character] : "{".concat(ts.quote(sourceFile, preferences, character), "}"); changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -156890,7 +157687,7 @@ var ts; var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start); if (!importDeclaration) return; - var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); + var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); }); var actions; if (namespaceChanges.length) { @@ -156905,7 +157702,7 @@ var ts; }); function getImportDeclaration(sourceFile, program, start) { var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier); - if (!identifier || identifier.parent.kind !== 178 /* TypeReference */) + if (!identifier || identifier.parent.kind !== 178 /* SyntaxKind.TypeReference */) return; var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(identifier); @@ -156917,11 +157714,11 @@ var ts; // new type-only import declaration, but honestly I doubt anyone will ever use this // codefix at all, so it's probably not worth the lines of code. function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) { - if (importDeclaration.kind === 265 /* ImportEqualsDeclaration */) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importDeclaration.name); + if (importDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importDeclaration.name); return; } - var importClause = importDeclaration.kind === 267 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent; + var importClause = importDeclaration.kind === 267 /* SyntaxKind.ImportClause */ ? importDeclaration : importDeclaration.parent.parent; if (importClause.name && importClause.namedBindings) { // Cannot convert an import with a default import and named bindings to type-only // (it's a grammar error). @@ -156929,7 +157726,7 @@ var ts; } var checker = program.getTypeChecker(); var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) { - if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */) + if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* SymbolFlags.Value */) return true; }); if (importsValue) { @@ -156938,7 +157735,7 @@ var ts; // Don't convert it to type-only. return; } - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importClause); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importClause); } function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) { ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent); @@ -156974,7 +157771,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 29 /* LessThanToken */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -157016,7 +157813,7 @@ var ts; ]; } var result = []; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -157058,13 +157855,13 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 137 /* InferKeyword */ || isImport(token)) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 29 /* LessThanToken */) { + else if (token.kind === 29 /* SyntaxKind.LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (ts.isObjectBindingPattern(token.parent)) { @@ -157087,7 +157884,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -157098,7 +157895,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -157107,18 +157904,18 @@ var ts; changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } function isImport(token) { - return token.kind === 100 /* ImportKeyword */ - || token.kind === 79 /* Identifier */ && (token.parent.kind === 270 /* ImportSpecifier */ || token.parent.kind === 267 /* ImportClause */); + return token.kind === 100 /* SyntaxKind.ImportKeyword */ + || token.kind === 79 /* SyntaxKind.Identifier */ && (token.parent.kind === 270 /* SyntaxKind.ImportSpecifier */ || token.parent.kind === 267 /* SyntaxKind.ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 100 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function canDeleteEntireVariableStatement(sourceFile, token) { return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token; } function deleteEntireVariableStatement(changes, sourceFile, node) { - changes.delete(sourceFile, node.parent.kind === 237 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -157127,15 +157924,15 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { - changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_" + token.text)); + changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_".concat(token.text))); if (ts.isParameter(token.parent)) { ts.getJSDocParameterTags(token.parent).forEach(function (tag) { if (ts.isIdentifier(tag.name)) { - changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_" + tag.name.text)); + changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_".concat(tag.name.text))); } }); } @@ -157143,14 +157940,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return true; } } @@ -157205,8 +158002,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: var index = parent.parameters.indexOf(parameter); var referent = ts.isMethodDeclaration(parent) ? parent.name : parent; var entries = ts.FindAllReferences.Core.getReferencedSymbolsForNode(parent.pos, referent, program, sourceFiles, cancellationToken); @@ -157215,7 +158012,7 @@ var ts; var entry = entries_2[_i]; for (var _a = 0, _b = entry.references; _a < _b.length; _a++) { var reference = _b[_a]; - if (reference.kind === 1 /* Node */) { + if (reference.kind === 1 /* FindAllReferences.EntryKind.Node */) { // argument in super(...) var isSuperCall_1 = ts.isSuperKeyword(reference.node) && ts.isCallExpression(reference.node.parent) @@ -157236,20 +158033,20 @@ var ts; } } return true; - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. return isLastParameter(parent, parameter, isFixAll); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Setter must have a parameter return false; - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Getter cannot have parameters return true; default: @@ -157310,7 +158107,7 @@ var ts; var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -157321,8 +158118,8 @@ var ts; return; } // falls through - case 241 /* WhileStatement */: - case 242 /* ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: changes.delete(sourceFile, container); return; } @@ -157371,7 +158168,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* SyntaxKind.ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -157395,10 +158192,10 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 314 /* JSDocNullableType */) { + if (typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` - actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* TypeFlags.Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -157415,7 +158212,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* TypeFlags.Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -157432,22 +158229,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 229 /* AsExpression */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: - case 172 /* GetAccessor */: - case 176 /* IndexSignature */: - case 195 /* MappedType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 211 /* TypeAssertionExpression */: - case 254 /* VariableDeclaration */: + case 229 /* SyntaxKind.AsExpression */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 176 /* SyntaxKind.IndexSignature */: + case 195 /* SyntaxKind.MappedType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; default: return false; @@ -157482,7 +158279,7 @@ var ts; }); } }); function doChange(changes, sourceFile, name) { - changes.replaceNodeWithText(sourceFile, name, name.text + "()"); + changes.replaceNodeWithText(sourceFile, name, "".concat(name.text, "()")); } function getCallName(sourceFile, start) { var token = ts.getTokenAtPosition(sourceFile, start); @@ -157550,15 +158347,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: insertBefore = containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* SyntaxKind.FunctionKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */; + case 214 /* SyntaxKind.ArrowFunction */: + var kind = containingFunction.typeParameters ? 29 /* SyntaxKind.LessThanToken */ : 20 /* SyntaxKind.OpenParenToken */; insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -157573,11 +158370,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* SyntaxKind.Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 131 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 131 /* SyntaxKind.AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -157739,7 +158536,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* SyntaxKind.Identifier */ && token.kind !== 25 /* SyntaxKind.DotDotDotToken */ && token.kind !== 108 /* SyntaxKind.ThisKeyword */) { return undefined; } var parent = token.parent; @@ -157840,9 +158637,9 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { - var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { @@ -157850,7 +158647,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { @@ -157893,7 +158690,7 @@ var ts; function annotate(changes, importAdder, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* SyntaxKind.PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -157929,7 +158726,7 @@ var ts; var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host); if (typeNode) { var name = ts.factory.cloneNode(param.name); - ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(name, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); return { name: ts.factory.cloneNode(param.name), param: param, isOptional: !!inference.isOptional, typeNode: typeNode }; } }); @@ -157937,9 +158734,9 @@ var ts; return; } if (ts.isArrowFunction(signature) || ts.isFunctionExpression(signature)) { - var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) { - changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); } ts.forEach(inferences, function (_a) { var typeNode = _a.typeNode, param = _a.param; @@ -157948,7 +158745,7 @@ var ts; changes.insertNodeAt(sourceFile, param.getStart(sourceFile), jsDoc, { suffix: " " }); }); if (needParens) { - changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } else { @@ -157962,7 +158759,7 @@ var ts; function getReferences(token, program, cancellationToken) { // Position shouldn't matter since token is not a SourceFile. return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) { - return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; + return entry.kind !== 0 /* FindAllReferences.EntryKind.Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; }); } function inferTypeForVariableFromUsage(token, program, cancellationToken) { @@ -157980,19 +158777,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 171 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 134 /* ConstructorKeyword */, sourceFile); + case 171 /* SyntaxKind.Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: searchToken = containingFunction.name; break; } @@ -158134,24 +158931,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: usage.isNumber = true; break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -158159,20 +158956,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -158196,13 +158993,13 @@ var ts; } function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: usage.isNumber = true; break; - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: @@ -158212,65 +159009,65 @@ var ts; function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: // MultiplicativeOperator // falls through - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: // ShiftOperator // falls through - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator // falls through - case 50 /* AmpersandToken */: - case 51 /* BarToken */: - case 52 /* CaretToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 51 /* SyntaxKind.BarToken */: + case 52 /* SyntaxKind.CaretToken */: // CompoundAssignmentOperator // falls through - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 74 /* BarEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: // AdditiveOperator // falls through - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: // RelationalOperator // falls through - case 29 /* LessThanToken */: - case 32 /* LessThanEqualsToken */: - case 31 /* GreaterThanToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 1056 /* EnumLike */) { + if (operandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, operandType); } else { usage.isNumber = true; } break; - case 64 /* PlusEqualsToken */: - case 39 /* PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 1056 /* EnumLike */) { + if (otherOperandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, otherOperandType); } - else if (otherOperandType.flags & 296 /* NumberLike */) { + else if (otherOperandType.flags & 296 /* TypeFlags.NumberLike */) { usage.isNumber = true; } - else if (otherOperandType.flags & 402653316 /* StringLike */) { + else if (otherOperandType.flags & 402653316 /* TypeFlags.StringLike */) { usage.isString = true; } - else if (otherOperandType.flags & 1 /* Any */) { + else if (otherOperandType.flags & 1 /* TypeFlags.Any */) { // do nothing, maybe we'll learn something elsewhere } else { @@ -158278,31 +159075,31 @@ var ts; } break; // AssignmentOperators - case 63 /* EqualsToken */: - case 34 /* EqualsEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (node === parent.left) { usage.isString = true; } break; // LogicalOperator Or NullishCoalescing - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 254 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: - case 102 /* InstanceOfKeyword */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: // nothing to infer here break; } @@ -158322,7 +159119,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 208 /* CallExpression */) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -158347,7 +159144,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent.argumentExpression); var indexUsage = createEmptyUsage(); calculateUsageOfNode(parent, indexUsage); - if (indexType.flags & 296 /* NumberLike */) { + if (indexType.flags & 296 /* TypeFlags.NumberLike */) { usage.numberIndex = indexUsage; } else { @@ -158394,21 +159191,21 @@ var ts; low: function (t) { return t === stringNumber; } }, { - high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); }, - low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); } + high: function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); }, + low: function (t) { return !!(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); } }, { - high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); }, - low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); } + high: function (t) { return !(t.flags & (98304 /* TypeFlags.Nullable */ | 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) && !(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); }, + low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); } } ]; var good = removeLowPriorityInferences(inferences, priorities); - var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; }); + var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */; }); if (anons.length) { - good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); }); + good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */); }); good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* UnionReduction.Subtype */)); } function combineAnonymousTypes(anons) { if (anons.length === 1) { @@ -158427,22 +159224,22 @@ var ts; var p = _b[_a]; props.add(p.name, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType()); } - calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); - constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); - var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* String */); + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* SignatureKind.Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* SignatureKind.Construct */)); + var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* IndexKind.String */); if (stringIndexInfo) { stringIndices.push(stringIndexInfo.type); stringIndexReadonly = stringIndexReadonly || stringIndexInfo.isReadonly; } - var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* Number */); + var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* IndexKind.Number */); if (numberIndexInfo) { numberIndices.push(numberIndexInfo.type); numberIndexReadonly = numberIndexReadonly || numberIndexInfo.isReadonly; } } var members = ts.mapEntries(props, function (name, types) { - var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0; - var s = checker.createSymbol(4 /* Property */ | isOptional, name); + var isOptional = types.length < anons.length ? 16777216 /* SymbolFlags.Optional */ : 0; + var s = checker.createSymbol(4 /* SymbolFlags.Property */ | isOptional, name); s.type = checker.getUnionType(types); return [name, s]; }); @@ -158474,7 +159271,7 @@ var ts; var candidateTypes = (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); }); var callsType = ((_c = usage.calls) === null || _c === void 0 ? void 0 : _c.length) ? inferStructuralType(usage) : undefined; if (callsType && candidateTypes) { - types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* Subtype */)); + types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* UnionReduction.Subtype */)); } else { if (callsType) { @@ -158491,7 +159288,7 @@ var ts; var members = new ts.Map(); if (usage.properties) { usage.properties.forEach(function (u, name) { - var symbol = checker.createSymbol(4 /* Property */, name); + var symbol = checker.createSymbol(4 /* SymbolFlags.Property */, name); symbol.type = combineFromUsage(u); members.set(name, symbol); }); @@ -158519,7 +159316,7 @@ var ts; return true; } if (propUsage.calls) { - var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + var sigs = checker.getSignaturesOfType(source, 0 /* SignatureKind.Call */); return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); } else { @@ -158533,7 +159330,7 @@ var ts; * 2. inference to/from calls with a single signature */ function inferInstantiationFromUsage(type, usage) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !usage.properties) { return type; } var generic = type.target; @@ -158552,10 +159349,10 @@ var ts; if (genericType === typeParameter) { return [usageType]; } - else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + else if (genericType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); } - else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + else if (ts.getObjectFlags(genericType) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(usageType) & 4 /* ObjectFlags.Reference */) { // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference var genericArgs = checker.getTypeArguments(genericType); var usageArgs = checker.getTypeArguments(usageType); @@ -158569,8 +159366,8 @@ var ts; } return types; } - var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); - var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* SignatureKind.Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* SignatureKind.Call */); if (genericSigs.length === 1 && usageSigs.length === 1) { return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } @@ -158605,27 +159402,27 @@ var ts; function getSignatureFromCalls(calls) { var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); - var _loop_15 = function (i) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + var _loop_14 = function (i) { + var symbol = checker.createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg".concat(i))); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { - symbol.flags |= 16777216 /* Optional */; + symbol.flags |= 16777216 /* SymbolFlags.Optional */; } parameters.push(symbol); }; for (var i = 0; i < length; i++) { - _loop_15(i); + _loop_14(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* SignatureFlags.None */); } function addCandidateType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } function addCandidateThisType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } @@ -158709,7 +159506,7 @@ var ts; codefix.createCodeFixActionWithoutFixAll(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [ ts.createTextChange(sourceFile.checkJsDirective ? ts.createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end) - : ts.createTextSpan(0, 0), "// @ts-nocheck" + newLineCharacter), + : ts.createTextSpan(0, 0), "// @ts-nocheck".concat(newLineCharacter)), ])], ts.Diagnostics.Disable_checking_for_this_file), ]; if (ts.textChanges.isValidLocationToAddComment(sourceFile, span.start)) { @@ -158776,7 +159573,7 @@ var ts; * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub. */ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) { - if (preserveOptional === void 0) { preserveOptional = 3 /* All */; } + if (preserveOptional === void 0) { preserveOptional = 3 /* PreserveOptionalFlags.All */; } if (isAmbient === void 0) { isAmbient = false; } var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { @@ -158789,13 +159586,13 @@ var ts; var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration)); var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); - var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient; + var optional = !!(symbol.flags & 16777216 /* SymbolFlags.Optional */); + var ambient = !!(enclosingDeclaration.flags & 16777216 /* NodeFlags.Ambient */) || isAmbient; var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + var flags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { var importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); @@ -158804,11 +159601,11 @@ var ts; importSymbols(importAdder, importableReference.symbols); } } - addClassElement(ts.factory.createPropertyDeclaration(modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, + addClassElement(ts.factory.createPropertyDeclaration(modifiers, name, optional && (preserveOptional & 2 /* PreserveOptionalFlags.Property */) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -158835,8 +159632,8 @@ var ts; } break; } - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -158844,7 +159641,7 @@ var ts; // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures(); if (!ts.some(signatures)) { break; } @@ -158866,13 +159663,13 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), modifiers, quotePreference, body)); } } break; } function outputMethod(quotePreference, signature, modifiers, name, body) { - var method = createSignatureDeclarationFromSignature(169 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder); + var method = createSignatureDeclarationFromSignature(169 /* SyntaxKind.MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), enclosingDeclaration, importAdder); if (method) addClassElement(method); } @@ -158882,10 +159679,10 @@ var ts; var program = context.program; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); - var flags = 1 /* NoTruncation */ - | 256 /* SuppressAnyReturnType */ - | 524288 /* AllowEmptyTuple */ - | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */); + var flags = 1 /* NodeBuilderFlags.NoTruncation */ + | 256 /* NodeBuilderFlags.SuppressAnyReturnType */ + | 524288 /* NodeBuilderFlags.AllowEmptyTuple */ + | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; @@ -158938,7 +159735,7 @@ var ts; } } } - var questionToken = optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var questionToken = optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var asteriskToken = signatureDeclaration.asteriskToken; if (ts.isFunctionExpression(signatureDeclaration)) { return ts.factory.updateFunctionExpression(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body); @@ -158963,38 +159760,50 @@ var ts; var names = ts.map(args, function (arg) { return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined; }); - var types = isJs ? [] : ts.map(args, function (arg) { - return typeToAutoImportableTypeNode(checker, importAdder, checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, scriptTarget, /*flags*/ undefined, tracker); - }); + var instanceTypes = isJs ? [] : ts.map(args, function (arg) { return checker.getTypeAtLocation(arg); }); + var _a = getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker), argumentTypeNodes = _a.argumentTypeNodes, argumentTypeParameters = _a.argumentTypeParameters; var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; var asteriskToken = ts.isYieldExpression(parent) - ? ts.factory.createToken(41 /* AsteriskToken */) + ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined; - var typeParameters = isJs || typeArguments === undefined - ? undefined - : ts.map(typeArguments, function (_, i) { - return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); - }); - var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs); + var typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments); + var parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs); var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); switch (kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createMethodDeclaration(modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return ts.factory.createMethodSignature(modifiers, name, - /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */) : type); - case 256 /* FunctionDeclaration */: + /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */) : type); + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference)); default: ts.Debug.fail("Unexpected kind"); } } codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression; + function createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments) { + var usedNames = new ts.Set(argumentTypeParameters.map(function (pair) { return pair[0]; })); + var constraintsByName = new ts.Map(argumentTypeParameters); + if (typeArguments) { + var typeArgumentsWithNewTypes = typeArguments.filter(function (typeArgument) { return !argumentTypeParameters.some(function (pair) { var _a; return checker.getTypeAtLocation(typeArgument) === ((_a = pair[1]) === null || _a === void 0 ? void 0 : _a.argumentType); }); }); + var targetSize = usedNames.size + typeArgumentsWithNewTypes.length; + for (var i = 0; usedNames.size < targetSize; i += 1) { + usedNames.add(createTypeParameterName(i)); + } + } + return ts.map(ts.arrayFrom(usedNames.values()), function (usedName) { var _a; return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, usedName, (_a = constraintsByName.get(usedName)) === null || _a === void 0 ? void 0 : _a.constraint); }); + } + function createTypeParameterName(index) { + return 84 /* CharacterCodes.T */ + index <= 90 /* CharacterCodes.Z */ + ? String.fromCharCode(84 /* CharacterCodes.T */ + index) + : "T".concat(index); + } function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) { var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker); if (typeNode && ts.isImportTypeNode(typeNode)) { @@ -159008,15 +159817,107 @@ var ts; return ts.getSynthesizedDeepClone(typeNode); } codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode; + function typeContainsTypeParameter(type) { + if (type.isUnionOrIntersection()) { + return type.types.some(typeContainsTypeParameter); + } + return type.flags & 262144 /* TypeFlags.TypeParameter */; + } + function getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, flags, tracker) { + // Types to be used as the types of the parameters in the new function + // E.g. from this source: + // added("", 0) + // The value will look like: + // [{ typeName: { text: "string" } }, { typeName: { text: "number" }] + // And in the output function will generate: + // function added(a: string, b: number) { ... } + var argumentTypeNodes = []; + // Names of type parameters provided as arguments to the call + // E.g. from this source: + // added(value); + // The value will look like: + // [ + // ["T", { argumentType: { typeName: { text: "T" } } } ], + // ["U", { argumentType: { typeName: { text: "U" } } } ], + // ] + // And in the output function will generate: + // function added() { ... } + var argumentTypeParameters = new ts.Map(); + for (var i = 0; i < instanceTypes.length; i += 1) { + var instanceType = instanceTypes[i]; + // If the instance type contains a deep reference to an existing type parameter, + // instead of copying the full union or intersection, create a new type parameter + // E.g. from this source: + // function existing(value: T | U & string) { + // added/*1*/(value); + // We don't want to output this: + // function added(value: T | U & string) { ... } + // We instead want to output: + // function added(value: T) { ... } + if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) { + var synthesizedTypeParameterName = createTypeParameterName(i); + argumentTypeNodes.push(ts.factory.createTypeReferenceNode(synthesizedTypeParameterName)); + argumentTypeParameters.set(synthesizedTypeParameterName, undefined); + continue; + } + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + var widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType); + var argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker); + if (!argumentTypeNode) { + continue; + } + argumentTypeNodes.push(argumentTypeNode); + var argumentTypeParameter = getFirstTypeParameterName(instanceType); + // If the instance type is a type parameter with a constraint (other than an anonymous object), + // remember that constraint for when we create the new type parameter + // E.g. from this source: + // function existing(value: T) { + // added/*1*/(value); + // We don't want to output this: + // function added(value: T) { ... } + // We instead want to output: + // function added(value: T) { ... } + var instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint) + ? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker) + : undefined; + if (argumentTypeParameter) { + argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint }); + } + } + return { argumentTypeNodes: argumentTypeNodes, argumentTypeParameters: ts.arrayFrom(argumentTypeParameters.entries()) }; + } + codefix.getArgumentTypesAndTypeParameters = getArgumentTypesAndTypeParameters; + function isAnonymousObjectConstraintType(type) { + return (type.flags & 524288 /* TypeFlags.Object */) && type.objectFlags === 16 /* ObjectFlags.Anonymous */; + } + function getFirstTypeParameterName(type) { + var _a; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + for (var _i = 0, _b = type.types; _i < _b.length; _i++) { + var subType = _b[_i]; + var subTypeName = getFirstTypeParameterName(subType); + if (subTypeName) { + return subTypeName; + } + } + } + return type.flags & 262144 /* TypeFlags.TypeParameter */ + ? (_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName() + : undefined; + } function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { var parameters = []; + var parameterNameCounts = new ts.Map(); for (var i = 0; i < argCount; i++) { + var parameterName = (names === null || names === void 0 ? void 0 : names[i]) || "arg".concat(i); + var parameterNameCount = parameterNameCounts.get(parameterName); + parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1); var newParameter = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, - /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), + /*name*/ parameterName + (parameterNameCount || ""), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, + /*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -159045,8 +159946,8 @@ var ts; var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { var restParameter = ts.factory.createParameterDeclaration( - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)), + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)), /*initializer*/ undefined); parameters.push(restParameter); } @@ -159061,7 +159962,7 @@ var ts; } function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) { return ts.factory.createMethodDeclaration(modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); + /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); } function createStubbedMethodBody(quotePreference) { return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference); @@ -159070,16 +159971,16 @@ var ts; return ts.factory.createBlock([ts.factory.createThrowStatement(ts.factory.createNewExpression(ts.factory.createIdentifier("Error"), /*typeArguments*/ undefined, // TODO Handle auto quote preference. - [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* Single */)]))], + [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* QuotePreference.Single */)]))], /*multiline*/ true); } codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { - if (flags & 4 /* Public */) { - return ts.factory.createToken(123 /* PublicKeyword */); + if (flags & 4 /* ModifierFlags.Public */) { + return ts.factory.createToken(123 /* SyntaxKind.PublicKeyword */); } - else if (flags & 16 /* Protected */) { - return ts.factory.createToken(122 /* ProtectedKeyword */); + else if (flags & 16 /* ModifierFlags.Protected */) { + return ts.factory.createToken(122 /* SyntaxKind.ProtectedKeyword */); } return undefined; } @@ -159152,7 +160053,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -159228,17 +160129,17 @@ var ts; return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } function prepareModifierFlagsForAccessor(modifierFlags) { - modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor - modifierFlags &= ~8 /* Private */; - if (!(modifierFlags & 16 /* Protected */)) { - modifierFlags |= 4 /* Public */; + modifierFlags &= ~64 /* ModifierFlags.Readonly */; // avoid Readonly modifier because it will convert to get accessor + modifierFlags &= ~8 /* ModifierFlags.Private */; + if (!(modifierFlags & 16 /* ModifierFlags.Protected */)) { + modifierFlags |= 4 /* ModifierFlags.Public */; } return modifierFlags; } function prepareModifierFlagsForField(modifierFlags) { - modifierFlags &= ~4 /* Public */; - modifierFlags &= ~16 /* Protected */; - modifierFlags |= 8 /* Private */; + modifierFlags &= ~4 /* ModifierFlags.Public */; + modifierFlags &= ~16 /* ModifierFlags.Protected */; + modifierFlags |= 8 /* ModifierFlags.Private */; return modifierFlags; } function getAccessorConvertiblePropertyAtPosition(file, program, start, end, considerEmptySpans) { @@ -159247,7 +160148,7 @@ var ts; var cursorRequest = start === end && considerEmptySpans; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier - var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; + var meaning = 28 /* ModifierFlags.AccessibilityModifier */ | 32 /* ModifierFlags.Static */ | 64 /* ModifierFlags.Readonly */; if (!declaration || (!(ts.nodeOverlapsWithStartEnd(declaration.name, file, start, end) || cursorRequest))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_property_for_which_to_generate_accessor) @@ -159258,20 +160159,20 @@ var ts; error: ts.getLocaleSpecificMessage(ts.Diagnostics.Name_is_not_valid) }; } - if (((ts.getEffectiveModifierFlags(declaration) & 125951 /* Modifier */) | meaning) !== meaning) { + if (((ts.getEffectiveModifierFlags(declaration) & 125951 /* ModifierFlags.Modifier */) | meaning) !== meaning) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_property_with_modifier) }; } var name = declaration.name.text; var startWithUnderscore = ts.startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_".concat(name), file), declaration.name); var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 164 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 164 /* SyntaxKind.Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -159324,13 +160225,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 108 /* ThisKeyword */ && + node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.factory.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -159345,7 +160246,7 @@ var ts; var type = typeChecker.getTypeFromTypeNode(typeNode); if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) { var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode]; - return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)], false)); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)], false)); } } return typeNode; @@ -159357,7 +160258,7 @@ var ts; var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); if (!superSymbol) break; - var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; + var symbol = superSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; @@ -159403,7 +160304,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* CallExpression */ : 209 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* SyntaxKind.CallExpression */ : 209 /* SyntaxKind.NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -159521,7 +160422,7 @@ var ts; } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { ts.suppressLeadingAndTrailingTrivia(propertyDeclaration); - var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* SyntaxKind.ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, info) { @@ -159529,7 +160430,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, sourceFile, info) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode]; var unionTypeNode = ts.factory.createUnionTypeNode(types); if (info.isJs) { @@ -159558,7 +160459,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } else if (type.isStringLiteral()) { @@ -159567,7 +160468,7 @@ var ts; else if (type.isNumberLiteral()) { return ts.factory.createNumericLiteral(type.value); } - else if (type.flags & 2048 /* BigIntLiteral */) { + else if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } else if (type.isUnion()) { @@ -159575,7 +160476,7 @@ var ts; } else if (type.isClass()) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); - if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* Abstract */)) + if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* ModifierFlags.Abstract */)) return undefined; var constructorDeclaration = ts.getFirstConstructorWithBody(classDeclaration); if (constructorDeclaration && constructorDeclaration.parameters.length) @@ -159751,8 +160652,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 200 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* SyntaxKind.ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 200 /* SyntaxKind.ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -159815,7 +160716,7 @@ var ts; var children = []; var current = node; while (true) { - if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { children.push(current.left); if (ts.isJsxChild(current.right)) { children.push(current.right); @@ -159881,7 +160782,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type, /*members*/ undefined); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [ @@ -159939,7 +160840,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* SyntaxKind.AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -159950,7 +160851,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* SyntaxKind.NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -160021,7 +160922,7 @@ var ts; var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.parent, ts.isVariableDeclarationList); if (declaration === undefined) return; - var constToken = ts.findChildOfKind(declaration, 85 /* ConstKeyword */, sourceFile); + var constToken = ts.findChildOfKind(declaration, 85 /* SyntaxKind.ConstKeyword */, sourceFile); if (constToken === undefined) return; return ts.createRange(constToken.pos, constToken.end); @@ -160058,14 +160959,14 @@ var ts; }); function getInfo(sourceFile, pos, _) { var node = ts.getTokenAtPosition(sourceFile, pos); - return (node.kind === 26 /* SemicolonToken */ && + return (node.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent && (ts.isObjectLiteralExpression(node.parent) || ts.isArrayLiteralExpression(node.parent))) ? { node: node } : undefined; } function doChange(changes, sourceFile, _a) { var node = _a.node; - var newNode = ts.factory.createToken(27 /* CommaToken */); + var newNode = ts.factory.createToken(27 /* SyntaxKind.CommaToken */); changes.replaceNode(sourceFile, node, newNode); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -160113,7 +161014,7 @@ var ts; // append ` | void` to type argument var typeArgument = typeArguments[0]; var needsParens = !ts.isUnionTypeNode(typeArgument) && !ts.isParenthesizedTypeNode(typeArgument) && - ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -160125,14 +161026,14 @@ var ts; var parameter = signature === null || signature === void 0 ? void 0 : signature.parameters[0]; var parameterType = parameter && checker.getTypeOfSymbolAtLocation(parameter, decl.parent.parent); if (ts.isInJSFile(decl)) { - if (!parameterType || parameterType.flags & 3 /* AnyOrUnknown */) { + if (!parameterType || parameterType.flags & 3 /* TypeFlags.AnyOrUnknown */) { // give the expression a type changes.insertText(sourceFile, decl.parent.parent.end, ")"); changes.insertText(sourceFile, ts.skipTrivia(sourceFile.text, decl.parent.parent.pos), "/** @type {Promise} */("); } } else { - if (!parameterType || parameterType.flags & 2 /* Unknown */) { + if (!parameterType || parameterType.flags & 2 /* TypeFlags.Unknown */) { // add `void` type argument changes.insertText(sourceFile, decl.parent.parent.expression.end, ""); } @@ -160208,16 +161109,16 @@ var ts; var file = context.file, program = context.program; var span = ts.getRefactorContextSpan(context); var token = ts.getTokenAtPosition(file, span.start); - var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); + var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* ModifierFlags.Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var checker = program.getTypeChecker(); var exportingModuleSymbol = getExportingModuleSymbol(exportNode, checker); - var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); - var wasDefault = !!(flags & 512 /* Default */); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ModifierFlags.ExportDefault */ : 0 /* ModifierFlags.None */); + var wasDefault = !!(flags & 512 /* ModifierFlags.Default */); // If source file already has a default export, don't offer refactor. - if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + if (!(flags & 1 /* ModifierFlags.Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* InternalSymbolName.Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } var noSymbolError = function (id) { @@ -160225,22 +161126,22 @@ var ts; : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; }; switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: { var node = exportNode; if (!node.name) return undefined; return noSymbolError(node.name) || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. - if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { + if (!(vs.declarationList.flags & 2 /* NodeFlags.Const */) || vs.declarationList.declarations.length !== 1) { return undefined; } var decl = ts.first(vs.declarationList.declarations); @@ -160250,7 +161151,7 @@ var ts; return noSymbolError(decl.name) || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var node = exportNode; if (node.isExportEquals) return undefined; @@ -160274,18 +161175,18 @@ var ts; changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports([spec]))); } else { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* SyntaxKind.DefaultKeyword */), "Should find a default keyword in modifier list")); } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* SyntaxKind.ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* SyntaxKind.DefaultKeyword */)); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;` var decl = ts.first(exportNode.declarationList.declarations); if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) { @@ -160294,15 +161195,15 @@ var ts; break; } // falls through - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text))); break; default: - ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind ".concat(exportNode.kind)); } } } @@ -160325,18 +161226,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 267 /* ImportClause */: { + case 267 /* SyntaxKind.ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -160345,10 +161246,10 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 268 /* NamespaceImport */) { + else if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); - var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* QuotePreference.Double */; var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } @@ -160359,7 +161260,7 @@ var ts; } break; } - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: var importTypeNode = parent; changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, importTypeNode.assertions, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf)); break; @@ -160370,11 +161271,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 270 /* ImportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.factory.createIdentifier(parent.name.text); @@ -160387,7 +161288,7 @@ var ts; } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -160396,7 +161297,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); + ts.Debug.assertNever(parent, "Unexpected parent kind ".concat(parent.kind)); } } function makeImportSpecifier(propertyName, name) { @@ -160426,17 +161327,17 @@ var ts; var _a; var refactorName = "Convert import"; var actions = (_a = {}, - _a[0 /* Named */] = { + _a[0 /* ImportKind.Named */] = { name: "Convert namespace import to named imports", description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message, kind: "refactor.rewrite.import.named", }, - _a[2 /* Namespace */] = { + _a[2 /* ImportKind.Namespace */] = { name: "Convert named imports to namespace import", description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message, kind: "refactor.rewrite.import.namespace", }, - _a[1 /* Default */] = { + _a[1 /* ImportKind.Default */] = { name: "Convert named imports to default import", description: ts.Diagnostics.Convert_named_imports_to_default_import.message, kind: "refactor.rewrite.import.default", @@ -160488,13 +161389,13 @@ var ts; if (!importClause.namedBindings) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) }; } - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { - return { convertTo: 0 /* Named */, import: importClause.namedBindings }; + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { + return { convertTo: 0 /* ImportKind.Named */, import: importClause.namedBindings }; } var shouldUseDefault = getShouldUseDefault(context.program, importClause); return shouldUseDefault - ? { convertTo: 1 /* Default */, import: importClause.namedBindings } - : { convertTo: 2 /* Namespace */, import: importClause.namedBindings }; + ? { convertTo: 1 /* ImportKind.Default */, import: importClause.namedBindings } + : { convertTo: 2 /* ImportKind.Namespace */, import: importClause.namedBindings }; } function getShouldUseDefault(program, importClause) { return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()) @@ -160502,11 +161403,11 @@ var ts; } function doChange(sourceFile, program, changes, info) { var checker = program.getTypeChecker(); - if (info.convertTo === 0 /* Named */) { + if (info.convertTo === 0 /* ImportKind.Named */) { doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { - doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */); + doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* ImportKind.Default */); } } function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { @@ -160519,7 +161420,7 @@ var ts; } else { var exportName = getRightOfPropertyAccessOrQualifiedName(id.parent).text; - if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + if (checker.resolveName(exportName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } ts.Debug.assert(getLeftOfPropertyAccessOrQualifiedName(id.parent) === id, "Parent expression should match id"); @@ -160568,14 +161469,14 @@ var ts; toConvertSymbols.add(symbol); } }); - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ESNext */) : "module"; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ScriptTarget.ESNext */) : "module"; function hasNamespaceNameConflict(namedImport) { // We need to check if the preferred namespace name (`preferredName`) we'd like to use in the refactored code will present a name conflict. // A name conflict means that, in a scope where we would like to use the preferred namespace name, there already exists a symbol with that name in that scope. // We are going to use the namespace name in the scopes the named imports being refactored are referenced, // so we look for conflicts by looking at every reference to those named imports. return !!ts.FindAllReferences.Core.eachSymbolReferenceInFile(namedImport.name, checker, sourceFile, function (id) { - var symbol = checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(preferredName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (symbol) { // There already is a symbol with the same name as the preferred namespace name. if (toConvertSymbols.has(symbol)) { // `preferredName` resolves to a symbol for one of the named import references we are going to transform into namespace import references... return ts.isExportSpecifier(id.parent); // ...but if this reference is an export specifier, it will not be transformed, so it is a conflict; otherwise, it will be renamed and is not a conflict. @@ -160590,7 +161491,7 @@ var ts; // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics. // More specifically, those are named imports that appear in named exports in the original code, e.g. `a` in `import { a } from "m"; export { a }`. var neededNamedImports = new ts.Set(); - var _loop_16 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName); @@ -160607,7 +161508,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_16(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, shouldUseDefault ? ts.factory.createIdentifier(namespaceImportName) @@ -160724,7 +161625,7 @@ var ts; } } function getBinaryInfo(expression) { - if (expression.operatorToken.kind !== 55 /* AmpersandAmpersandToken */) { + if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) }; } ; @@ -160740,7 +161641,7 @@ var ts; */ function getOccurrencesInExpression(matchTo, expression) { var occurrences = []; - while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var match = getMatchingStart(ts.skipParentheses(matchTo), ts.skipParentheses(expression.right)); if (!match) { break; @@ -160866,17 +161767,17 @@ var ts; occurrences.pop(); if (ts.isCallExpression(toConvert)) { return isOccurrence ? - ts.factory.createCallChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : + ts.factory.createCallChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : ts.factory.createCallChain(chain, toConvert.questionDotToken, toConvert.typeArguments, toConvert.arguments); } else if (ts.isPropertyAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.name) : + ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.name) : ts.factory.createPropertyAccessChain(chain, toConvert.questionDotToken, toConvert.name); } else if (ts.isElementAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.argumentExpression) : + ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.argumentExpression) : ts.factory.createElementAccessChain(chain, toConvert.questionDotToken, toConvert.argumentExpression); } } @@ -160891,7 +161792,7 @@ var ts; changes.replaceNodeRange(sourceFile, firstOccurrence, finalExpression, convertedChain); } else if (ts.isConditionalExpression(expression)) { - changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* QuestionQuestionToken */), expression.whenFalse)); + changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* SyntaxKind.QuestionQuestionToken */), expression.whenFalse)); } } } @@ -160937,27 +161838,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 175 /* ConstructSignature */: { + case 175 /* SyntaxKind.ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -160978,24 +161879,24 @@ var ts; } return ts.factory.createNodeArray([ ts.factory.createParameterDeclaration( - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), "args", + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), "args", /*questionToken*/ undefined, ts.factory.createUnionTypeNode(ts.map(signatureDeclarations, convertSignatureParametersToTuple))) ]); } function convertSignatureParametersToTuple(decl) { var members = ts.map(decl.parameters, convertParameterToNamedTupleMember); - return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* None */ : 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* EmitFlags.None */ : 1 /* EmitFlags.SingleLine */); } function convertParameterToNamedTupleMember(p) { ts.Debug.assert(ts.isIdentifier(p.name)); // This is checked during refactoring applicability checking - var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); if (newComment.length) { ts.setSyntheticLeadingComments(result, [{ - text: "*\n" + newComment.split("\n").map(function (c) { return " * " + c; }).join("\n") + "\n ", - kind: 3 /* MultiLineCommentTrivia */, + text: "*\n".concat(newComment.split("\n").map(function (c) { return " * ".concat(c); }).join("\n"), "\n "), + kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, pos: -1, end: -1, hasTrailingNewLine: true, @@ -161008,12 +161909,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: return true; } return false; @@ -161024,6 +161925,9 @@ var ts; if (!containingDecl) { return; } + if (ts.isFunctionLikeDeclaration(containingDecl) && containingDecl.body && ts.rangeContainsPosition(containingDecl.body, startPosition)) { + return; + } var checker = program.getTypeChecker(); var signatureSymbol = containingDecl.symbol; if (!signatureSymbol) { @@ -161139,7 +162043,7 @@ var ts; usedFunctionNames.set(description, true); functionActions.push({ description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), kind: extractFunctionAction.kind }); } @@ -161147,7 +162051,7 @@ var ts; else if (!innermostErrorFunctionAction) { innermostErrorFunctionAction = { description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), notApplicableReason: getStringError(functionExtraction.errors), kind: extractFunctionAction.kind }; @@ -161163,7 +162067,7 @@ var ts; usedConstantNames.set(description_1, true); constantActions.push({ description: description_1, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), kind: extractConstantAction.kind }); } @@ -161171,7 +162075,7 @@ var ts; else if (!innermostErrorConstantAction) { innermostErrorConstantAction = { description: description, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), notApplicableReason: getStringError(constantExtraction.errors), kind: extractConstantAction.kind }; @@ -161316,7 +162220,7 @@ var ts; // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - if (start.flags & 8388608 /* JSDoc */) { + if (start.flags & 8388608 /* NodeFlags.JSDoc */) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; } if (start.parent !== end.parent) { @@ -161405,20 +162309,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 167 /* PropertyDeclaration */) { + if (current.kind === 167 /* SyntaxKind.PropertyDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 164 /* Parameter */) { + else if (current.kind === 164 /* SyntaxKind.Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 171 /* Constructor */) { + if (ctorOrMethod.kind === 171 /* SyntaxKind.Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 169 /* MethodDeclaration */) { + else if (current.kind === 169 /* SyntaxKind.MethodDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -161442,7 +162346,7 @@ var ts; if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 16777216 /* Ambient */) { + if (nodeToCheck.flags & 16777216 /* NodeFlags.Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -161451,14 +162355,14 @@ var ts; checkForStaticContext(nodeToCheck, containingClass); } var errors; - var permittedJumps = 4 /* Return */; + var permittedJumps = 4 /* PermittedJumps.Return */; var seenLabels; visit(nodeToCheck); if (rangeFacts & RangeFacts.UsesThis) { var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false); - if (container.kind === 256 /* FunctionDeclaration */ || - (container.kind === 169 /* MethodDeclaration */ && container.parent.kind === 205 /* ObjectLiteralExpression */) || - container.kind === 213 /* FunctionExpression */) { + if (container.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) || + container.kind === 213 /* SyntaxKind.FunctionExpression */) { rangeFacts |= RangeFacts.UsesThisInFunction; } } @@ -161469,8 +162373,8 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 254 /* VariableDeclaration */) ? node.parent.parent : node; - if (ts.hasSyntacticModifier(declaringNode, 1 /* Export */)) { + var declaringNode = (node.kind === 254 /* SyntaxKind.VariableDeclaration */) ? node.parent.parent : node; + if (ts.hasSyntacticModifier(declaringNode, 1 /* ModifierFlags.Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! // Also TODO: GH#19956 @@ -161481,16 +162385,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 208 /* CallExpression */) { + if (node.parent.kind === 208 /* SyntaxKind.CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -161503,7 +162407,7 @@ var ts; thisNode = node; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -161518,64 +162422,64 @@ var ts; } }); // falls through - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); } // falls through - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 239 /* IfStatement */: - permittedJumps = 0 /* None */; + case 239 /* SyntaxKind.IfStatement */: + permittedJumps &= ~4 /* PermittedJumps.Return */; break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // forbid all jumps inside try blocks - permittedJumps = 0 /* None */; + permittedJumps = 0 /* PermittedJumps.None */; break; - case 235 /* Block */: - if (node.parent && node.parent.kind === 252 /* TryStatement */ && node.parent.finallyBlock === node) { + case 235 /* SyntaxKind.Block */: + if (node.parent && node.parent.kind === 252 /* SyntaxKind.TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks - permittedJumps = 4 /* Return */; + permittedJumps = 4 /* PermittedJumps.Return */; } break; - case 290 /* DefaultClause */: - case 289 /* CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: // allow unlabeled break inside case clauses - permittedJumps |= 1 /* Break */; + permittedJumps |= 1 /* PermittedJumps.Break */; break; default: if (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false)) { // allow unlabeled break/continue inside loops - permittedJumps |= 1 /* Break */ | 2 /* Continue */; + permittedJumps |= 1 /* PermittedJumps.Break */ | 2 /* PermittedJumps.Continue */; } break; } switch (node.kind) { - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; thisNode = node; break; - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: { + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -161584,21 +162488,21 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 246 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 246 /* SyntaxKind.BreakStatement */ ? 1 /* PermittedJumps.Break */ : 2 /* PermittedJumps.Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 247 /* ReturnStatement */: - if (permittedJumps & 4 /* Return */) { + case 247 /* SyntaxKind.ReturnStatement */: + if (permittedJumps & 4 /* PermittedJumps.Return */) { rangeFacts |= RangeFacts.HasReturn; } else { @@ -161621,7 +162525,7 @@ var ts; function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { var start = startNode.getStart(sourceFile); var end = endNode.getEnd(); - if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + if (sourceFile.text.charCodeAt(end) === 59 /* CharacterCodes.semicolon */) { end++; } return { start: start, length: end - start }; @@ -161667,7 +162571,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 164 /* Parameter */) { + if (current.kind === 164 /* SyntaxKind.Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -161678,7 +162582,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 305 /* SourceFile */) { + if (current.kind === 305 /* SyntaxKind.SourceFile */) { return scopes; } } @@ -161718,11 +162622,11 @@ var ts; : getDescriptionForModuleLikeDeclaration(scope); var functionDescription; var constantDescription; - if (scopeDescription === 1 /* Global */) { + if (scopeDescription === 1 /* SpecialScope.Global */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "global"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "global"]); } - else if (scopeDescription === 0 /* Module */) { + else if (scopeDescription === 0 /* SpecialScope.Module */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "module"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "module"]); } @@ -161768,34 +162672,34 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return scope.name - ? "function '" + scope.name.text + "'" + ? "function '".concat(scope.name.text, "'") : ts.ANONYMOUS; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return "arrow function"; - case 169 /* MethodDeclaration */: - return "method '" + scope.name.getText() + "'"; - case 172 /* GetAccessor */: - return "'get " + scope.name.getText() + "'"; - case 173 /* SetAccessor */: - return "'set " + scope.name.getText() + "'"; + case 169 /* SyntaxKind.MethodDeclaration */: + return "method '".concat(scope.name.getText(), "'"); + case 172 /* SyntaxKind.GetAccessor */: + return "'get ".concat(scope.name.getText(), "'"); + case 173 /* SyntaxKind.SetAccessor */: + return "'set ".concat(scope.name.getText(), "'"); default: - throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); + throw ts.Debug.assertNever(scope, "Unexpected scope kind ".concat(scope.kind)); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 257 /* ClassDeclaration */ - ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" - : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + return scope.kind === 257 /* SyntaxKind.ClassDeclaration */ + ? scope.name ? "class '".concat(scope.name.text, "'") : "anonymous class declaration" + : scope.name ? "class expression '".concat(scope.name.text, "'") : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 262 /* ModuleBlock */ - ? "namespace '" + scope.parent.name.getText() + "'" - : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; + return scope.kind === 262 /* SyntaxKind.ModuleBlock */ + ? "namespace '".concat(scope.parent.name.getText(), "'") + : scope.externalModuleIndicator ? 0 /* SpecialScope.Module */ : 1 /* SpecialScope.Global */; } var SpecialScope; (function (SpecialScope) { @@ -161826,7 +162730,7 @@ var ts; var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" type = checker.getBaseTypeOfLiteralType(type); - typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NoTruncation */); + typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NodeBuilderFlags.NoTruncation */); } var paramDecl = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, @@ -161834,7 +162738,7 @@ var ts; /*name*/ name, /*questionToken*/ undefined, typeNode); parameters.push(paramDecl); - if (usage.usage === 2 /* Write */) { + if (usage.usage === 2 /* Usage.Write */) { (writes || (writes = [])).push(usage); } callArguments.push(ts.factory.createIdentifier(name)); @@ -161853,7 +162757,7 @@ var ts; // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); - returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217 + returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 } var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; ts.suppressLeadingAndTrailingTrivia(body); @@ -161861,14 +162765,14 @@ var ts; var callThis = !!(range.facts & RangeFacts.UsesThisInFunction); if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(131 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(131 /* SyntaxKind.AsyncKeyword */)); } - newFunction = ts.factory.createMethodDeclaration(modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, + newFunction = ts.factory.createMethodDeclaration(modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { @@ -161877,10 +162781,10 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ "this", - /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NoTruncation */), + /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NodeBuilderFlags.NoTruncation */), /*initializer*/ undefined)); } - newFunction = ts.factory.createFunctionDeclaration(range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + newFunction = ts.factory.createFunctionDeclaration(range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* SyntaxKind.AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -161901,7 +162805,7 @@ var ts; var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call); + call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.factory.createAwaitExpression(call); @@ -161935,7 +162839,7 @@ var ts; /*propertyName*/ undefined, /*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name))); // Being returned through an object literal will have widened the type. - var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */); + var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NodeBuilderFlags.NoTruncation */); typeElements.push(ts.factory.createPropertySignature( /*modifiers*/ undefined, /*name*/ variableDeclaration.symbol.name, @@ -161946,7 +162850,7 @@ var ts; } var typeLiteral = sawExplicitType ? ts.factory.createTypeLiteralNode(typeElements) : undefined; if (typeLiteral) { - ts.setEmitFlags(typeLiteral, 1 /* SingleLine */); + ts.setEmitFlags(typeLiteral, 1 /* EmitFlags.SingleLine */); } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.factory.createObjectBindingPattern(bindingElements), @@ -161961,8 +162865,8 @@ var ts; for (var _c = 0, exposedVariableDeclarations_2 = exposedVariableDeclarations; _c < exposedVariableDeclarations_2.length; _c++) { var variableDeclaration = exposedVariableDeclarations_2[_c]; var flags = variableDeclaration.parent.flags; - if (flags & 2 /* Const */) { - flags = (flags & ~2 /* Const */) | 1 /* Let */; + if (flags & 2 /* NodeFlags.Const */) { + flags = (flags & ~2 /* NodeFlags.Const */) | 1 /* NodeFlags.Let */; } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(variableDeclaration.symbol.name, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(variableDeclaration.type))], flags))); @@ -161971,7 +162875,7 @@ var ts; if (returnValueProperty) { // has both writes and return, need to create variable declaration to hold return value; newNodes.push(ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* Let */))); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* NodeFlags.Let */))); } var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (returnValueProperty) { @@ -162028,9 +162932,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* SyntaxKind.UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } } /** @@ -162043,13 +162947,13 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable var file = scope.getSourceFile(); - var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) + var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) ? node.name.text : ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJSFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined - : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 + : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(ts.skipParentheses(node), substitutions); (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); @@ -162057,11 +162961,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(145 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration(modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); var localReference = ts.factory.createPropertyAccessExpression(rangeFacts & RangeFacts.InStaticRegion @@ -162092,16 +162996,16 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 238 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); changeTracker.replaceNode(context.file, node.parent, newVariableStatement); } else { var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); // Declare var nodeToInsertBefore = getNodeToInsertConstantBefore(node, scope); if (nodeToInsertBefore.pos === 0) { @@ -162111,7 +163015,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -162138,7 +163042,7 @@ var ts; if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) return { variableType: variableType, initializer: initializer }; var functionType = checker.getTypeAtLocation(node); - var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* SignatureKind.Call */)); // If no function signature, maybe there was an error, do nothing if (!functionSignature) return { variableType: variableType, initializer: initializer }; @@ -162157,7 +163061,7 @@ var ts; var paramType = checker.getTypeAtLocation(p); if (paramType === checker.getAnyType()) hasAny = true; - parameters.push(ts.factory.updateParameterDeclaration(p, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + parameters.push(ts.factory.updateParameterDeclaration(p, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NodeBuilderFlags.NoTruncation */), p.initializer)); } } // If a parameter was inferred as any we skip adding function parameters at all. @@ -162167,7 +163071,7 @@ var ts; return { variableType: variableType, initializer: initializer }; variableType = undefined; if (ts.isArrowFunction(initializer)) { - initializer = ts.factory.updateArrowFunction(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + initializer = ts.factory.updateArrowFunction(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); } else { if (functionSignature && !!functionSignature.thisParameter) { @@ -162179,10 +163083,10 @@ var ts; parameters.splice(0, 0, ts.factory.createParameterDeclaration( /* modifiers */ undefined, /* dotDotDotToken */ undefined, "this", - /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NodeBuilderFlags.NoTruncation */))); } } - initializer = ts.factory.updateFunctionExpression(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + initializer = ts.factory.updateFunctionExpression(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.body); } return { variableType: variableType, initializer: initializer }; } @@ -162429,7 +163333,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* TypeFlags.Void */ | 131072 /* TypeFlags.Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -162498,7 +163402,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_17 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -162513,11 +163417,11 @@ var ts; var hasWrite = false; var readonlyClassPropertyWrite; usagesPerScope[i].usages.forEach(function (value) { - if (value.usage === 2 /* Write */) { + if (value.usage === 2 /* Usage.Write */) { hasWrite = true; - if (value.symbol.flags & 106500 /* ClassMember */ && + if (value.symbol.flags & 106500 /* SymbolFlags.ClassMember */ && value.symbol.valueDeclaration && - ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* ModifierFlags.Readonly */)) { readonlyClassPropertyWrite = value.symbol.valueDeclaration; } } @@ -162541,7 +163445,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_17(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -162561,7 +163465,7 @@ var ts; } } function collectUsages(node, valueUsage) { - if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (valueUsage === void 0) { valueUsage = 1 /* Usage.Read */; } if (inGenericContext) { var type = checker.getTypeAtLocation(node); recordTypeParameterUsages(type); @@ -162571,11 +163475,11 @@ var ts; } if (ts.isAssignmentExpression(node)) { // use 'write' as default usage for values - collectUsages(node.left, 2 /* Write */); + collectUsages(node.left, 2 /* Usage.Write */); collectUsages(node.right); } else if (ts.isUnaryExpressionWithWrite(node)) { - collectUsages(node.operand, 2 /* Write */); + collectUsages(node.operand, 2 /* Usage.Write */); } else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { // use 'write' as default usage for values @@ -162649,7 +163553,7 @@ var ts; // declaration is located in range to be extracted - do nothing return undefined; } - if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Write */) { + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Usage.Write */) { // this is write to a reference located outside of the target scope and range is extracted into generator // currently this is unsupported scenario var diag = ts.createDiagnosticForNode(identifier, Messages.cannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators); @@ -162676,7 +163580,7 @@ var ts; else if (isTypeName) { // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument // so there's no problem. - if (!(symbol.flags & 262144 /* TypeParameter */)) { + if (!(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var diag = ts.createDiagnosticForNode(identifier, Messages.typeWillNotBeVisibleInTheNewScope); functionErrorsPerScope[i].push(diag); constantErrorsPerScope[i].push(diag); @@ -162757,30 +163661,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return false; } switch (node.kind) { - case 10 /* StringLiteral */: - return parent.kind !== 266 /* ImportDeclaration */ && - parent.kind !== 270 /* ImportSpecifier */; - case 225 /* SpreadElement */: - case 201 /* ObjectBindingPattern */: - case 203 /* BindingElement */: + case 10 /* SyntaxKind.StringLiteral */: + return parent.kind !== 266 /* SyntaxKind.ImportDeclaration */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */; + case 225 /* SyntaxKind.SpreadElement */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 203 /* SyntaxKind.BindingElement */: return false; - case 79 /* Identifier */: - return parent.kind !== 203 /* BindingElement */ && - parent.kind !== 270 /* ImportSpecifier */ && - parent.kind !== 275 /* ExportSpecifier */; + case 79 /* SyntaxKind.Identifier */: + return parent.kind !== 203 /* SyntaxKind.BindingElement */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */ && + parent.kind !== 275 /* SyntaxKind.ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 235 /* Block */: - case 305 /* SourceFile */: - case 262 /* ModuleBlock */: - case 289 /* CaseClause */: + case 235 /* SyntaxKind.Block */: + case 305 /* SyntaxKind.SourceFile */: + case 262 /* SyntaxKind.ModuleBlock */: + case 289 /* SyntaxKind.CaseClause */: return true; default: return false; @@ -162926,7 +163830,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var typeName = node.typeName; - var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); + var symbol = checker.resolveName(typeName.text, typeName, 262144 /* SymbolFlags.TypeParameter */, /* excludeGlobals */ true); for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) { var decl = _a[_i]; if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) { @@ -162957,7 +163861,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* SymbolFlags.Value */, /* excludeGlobals */ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -162969,7 +163873,7 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.forEachChild(node, visitor); } @@ -162993,7 +163897,7 @@ var ts; } function doTypedefChange(changes, file, name, info) { var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; - ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(selection, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name)); var templates = []; ts.forEach(typeParameters, function (typeParameter) { @@ -163148,7 +164052,7 @@ var ts; var usage = getUsageInfo(oldFile, toMove.all, checker); var currentDirectory = ts.getDirectoryPath(oldFile.fileName); var extension = ts.extensionFromPath(oldFile.fileName); - var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host); + var newModuleName = makeUniqueModuleName(getNewModuleName(usage.oldFileImportsFromNewFile, usage.movedSymbols), extension, currentDirectory, host); var newFileNameWithExtension = newModuleName + extension; // If previous file was global, this is easy. changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences)); @@ -163177,11 +164081,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return true; - case 265 /* ImportEqualsDeclaration */: - return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 237 /* VariableStatement */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return !ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); + case 237 /* SyntaxKind.VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -163221,7 +164125,7 @@ var ts; var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax); if (imports.length && body.length) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [ - 4 /* NewLineTrivia */ + 4 /* SyntaxKind.NewLineTrivia */ ], false), body, true); } return __spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), body, true); @@ -163242,10 +164146,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_18 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_19 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -163267,35 +164171,35 @@ var ts; }; for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) { var statement = _c[_b]; - _loop_19(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_18(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* NamespaceImport */ ? + case 266 /* SyntaxKind.ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { - var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ESNext */); + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ScriptTarget.ESNext */); var needUniqueName = false; var toChange = []; ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { if (!ts.isPropertyAccessExpression(ref.parent)) return; - needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true); + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { toChange.push(ref); } @@ -163313,21 +164217,21 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString, /*assertClause*/ undefined); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function moduleSpecifierFromImport(i) { - return (i.kind === 266 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 265 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 266 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -163353,7 +164257,7 @@ var ts; var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { - if (symbol.escapedName === "default" /* Default */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */) { defaultImport = ts.factory.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217 } else { @@ -163377,7 +164281,7 @@ var ts; } } function makeVariableStatement(name, type, initializer, flags) { - if (flags === void 0) { flags = 2 /* Const */; } + if (flags === void 0) { flags = 2 /* NodeFlags.Const */; } return ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, initializer)], flags)); } function createRequireCall(moduleSpecifier) { @@ -163397,19 +164301,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind ".concat(importDecl.kind)); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -163418,7 +164322,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 268 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -163430,7 +164334,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 269 /* NamedImports */) { + else if (namedBindings.kind === 269 /* SyntaxKind.NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -163443,14 +164347,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: break; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -163492,7 +164396,7 @@ var ts; if (markSeenTop(top)) { addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax); } - if (ts.hasSyntacticModifier(decl, 512 /* Default */)) { + if (ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */)) { oldFileDefault = name; } else { @@ -163509,17 +164413,17 @@ var ts; var name = ts.combinePaths(inDirectory, newModuleName + extension); if (!host.fileExists(name)) return newModuleName; - newModuleName = moduleName + "." + i; + newModuleName = "".concat(moduleName, ".").concat(i); } } - function getNewModuleName(movedSymbols) { - return movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile"; + function getNewModuleName(importsFromNewFile, movedSymbols) { + return importsFromNewFile.forEachEntry(ts.symbolNameNoDefault) || movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile"; } function getUsageInfo(oldFile, toMove, checker) { var movedSymbols = new SymbolSet(); var oldImportsNeededByNewFile = new SymbolSet(); var newFileImportsFromOldFile = new SymbolSet(); - var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* ContainsJsx */); }); + var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */); }); var jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx); if (jsxNamespaceSymbol) { // Might not exist (e.g. in non-compiling code) oldImportsNeededByNewFile.add(jsxNamespaceSymbol); @@ -163553,7 +164457,7 @@ var ts; if (ts.contains(toMove, statement)) continue; // jsxNamespaceSymbol will only be set iff it is in oldImportsNeededByNewFile. - if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) { + if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */)) { unusedImportsFromOldFile.delete(jsxNamespaceSymbol); } forEachReference(statement, checker, function (symbol) { @@ -163571,7 +164475,7 @@ var ts; // Strictly speaking, this could resolve to a symbol other than the JSX namespace. // This will produce erroneous output (probably, an incorrectly copied import) but // is expected to be very rare and easily reversible. - var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* Namespace */, /*excludeGlobals*/ true); + var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* SymbolFlags.Namespace */, /*excludeGlobals*/ true); return !!jsxNamespaceSymbol && ts.some(jsxNamespaceSymbol.declarations, isInImport) ? jsxNamespaceSymbol : undefined; @@ -163580,14 +164484,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: return true; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -163599,7 +164503,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -163609,18 +164513,18 @@ var ts; ? ts.factory.createImportDeclaration(/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined) : undefined; } - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); + return ts.Debug.assertNever(i, "Unexpected import kind ".concat(i.kind)); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -163630,11 +164534,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return keep(name) ? name : undefined; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return name; - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined; @@ -163691,13 +164595,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -163705,19 +164609,19 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return cb(statement); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; - return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ + return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* AssignmentDeclarationKind.ExportsProperty */ ? cb(statement) : undefined; } @@ -163725,13 +164629,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); + return ts.Debug.assertNever(name, "Unexpected name kind ".concat(name.kind)); } } function nameOfTopLevelDeclaration(d) { @@ -163739,9 +164643,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return d.parent.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -163763,7 +164667,7 @@ var ts; function isExported(sourceFile, decl, useEs6Exports, name) { var _a; if (useEs6Exports) { - return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); + return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); } return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); }); } @@ -163771,29 +164675,29 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.canHaveModifiers(d) ? ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], ts.getModifiers(d)) : undefined; + var modifiers = ts.canHaveModifiers(d) ? ts.concatenate([ts.factory.createModifier(93 /* SyntaxKind.ExportKeyword */)], ts.getModifiers(d)) : undefined; switch (d.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var decorators = ts.canHaveDecorators(d) ? ts.getDecorators(d) : undefined; return ts.factory.updateClassDeclaration(d, ts.concatenate(decorators, modifiers), d.name, d.typeParameters, d.heritageClauses, d.members); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, modifiers, d.name, d.body); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, modifiers, d.name, d.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, modifiers, d.name, d.typeParameters, d.type); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); + return ts.Debug.assertNever(d, "Unexpected declaration kind ".concat(d.kind)); } } function addCommonjsExport(decl) { @@ -163801,26 +164705,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.emptyArray; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); + return ts.Debug.assertNever(decl, "Unexpected decl kind ".concat(decl.kind)); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* EqualsToken */, ts.factory.createIdentifier(name))); + return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* SyntaxKind.EqualsToken */, ts.factory.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -163883,14 +164787,14 @@ var ts; if (actionName === addBracesAction.name) { var returnStatement_1 = ts.factory.createReturnStatement(expression); body = ts.factory.createBlock([returnStatement_1], /* multiLine */ true); - ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); + ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); } else if (actionName === removeBracesAction.name && returnStatement) { var actualExpression = expression || ts.factory.createVoidZero(); body = ts.needsParentheses(actualExpression) ? ts.factory.createParenthesizedExpression(actualExpression) : actualExpression; - ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } else { ts.Debug.fail("invalid action"); @@ -164024,7 +164928,7 @@ var ts; var contextualSymbols = ts.map(functionNames, function (name) { return getSymbolForContextualType(name, checker); }); for (var _i = 0, referenceEntries_1 = referenceEntries; _i < referenceEntries_1.length; _i++) { var entry = referenceEntries_1[_i]; - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* FindAllReferences.EntryKind.Span */) { groupedReferences.valid = false; continue; } @@ -164123,7 +165027,7 @@ var ts; if (element) { var contextualType = checker.getContextualTypeForObjectLiteralElement(element); var symbol = contextualType === null || contextualType === void 0 ? void 0 : contextualType.getSymbol(); - if (symbol && !(ts.getCheckFlags(symbol) & 6 /* Synthetic */)) { + if (symbol && !(ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */)) { return symbol; } } @@ -164153,15 +165057,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -164171,7 +165075,7 @@ var ts; } break; // x["foo"](...) - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -164190,14 +165094,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -164209,7 +165113,7 @@ var ts; } function entryToType(entry) { var reference = entry.node; - if (ts.getMeaningFromLocation(reference) === 2 /* Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { + if (ts.getMeaningFromLocation(reference) === 2 /* SemanticMeaning.Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { return reference; } return undefined; @@ -164243,16 +165147,16 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralExpression(functionDeclaration.parent)) { var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker); // don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change return ((_a = contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 && isSingleImplementation(functionDeclaration, checker); } return isSingleImplementation(functionDeclaration, checker); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -164260,8 +165164,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -164271,7 +165175,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* SyntaxKind.DefaultKeyword */); return !!defaultKeyword; } return true; @@ -164375,7 +165279,7 @@ var ts; } function createParameterTypeNode(parameters) { var members = ts.map(parameters, createPropertySignatureFromParameterDeclaration); - var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* SingleLine */); + var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* EmitFlags.SingleLine */); return typeNode; } function createPropertySignatureFromParameterDeclaration(parameterDeclaration) { @@ -164384,7 +165288,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.factory.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType); + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : parameterDeclaration.questionToken, parameterType); ts.suppressLeadingAndTrailingTrivia(propertySignature); ts.copyComments(parameterDeclaration.name, propertySignature.name); if (parameterDeclaration.type && propertySignature.type) { @@ -164409,15 +165313,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -164428,30 +165332,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return [functionDeclaration.name]; - case 171 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 226 /* ClassExpression */) { + case 171 /* SyntaxKind.Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* SyntaxKind.ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 226 /* SyntaxKind.ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return [functionDeclaration.parent.name]; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind ".concat(functionDeclaration.kind)); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -164532,16 +165436,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 63 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return false; - case 223 /* TemplateExpression */: - case 221 /* BinaryExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -164559,7 +165463,7 @@ var ts; if (!(leftHasString || ts.isStringLiteral(current.right) || ts.isTemplateExpression(current.right))) { return { nodes: [current], operators: [], hasString: false, validOperators: true }; } - var currentOperatorValid = current.operatorToken.kind === 39 /* PlusToken */; + var currentOperatorValid = current.operatorToken.kind === 39 /* SyntaxKind.PlusToken */; var validOperators = leftOperatorValid && currentOperatorValid; nodes.push(current.right); operators.push(current.operatorToken); @@ -164572,7 +165476,7 @@ var ts; // "foo" + /* comment */ "bar" var copyTrailingOperatorComments = function (operators, file) { return function (index, targetNode) { if (index < operators.length) { - ts.copyTrailingComments(operators[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(operators[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } }; }; // to copy comments following the string @@ -164581,7 +165485,7 @@ var ts; return function (indexes, targetNode) { while (indexes.length > 0) { var index = indexes.shift(); - ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); copyOperatorComments(index, targetNode); } }; @@ -164635,7 +165539,7 @@ var ts; var templateSpans = []; var templateHead = ts.factory.createTemplateHead(headText, rawHeadText); copyCommentFromStringLiterals(headIndexes, templateHead); - var _loop_20 = function (i) { + var _loop_19 = function (i) { var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]); copyOperatorComments(i, currentNode); var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3]; @@ -164664,7 +165568,7 @@ var ts; }; var out_i_1; for (var i = begin; i < nodes.length; i++) { - _loop_20(i); + _loop_19(i); i = out_i_1; } return ts.factory.createTemplateExpression(templateHead, templateSpans); @@ -164673,8 +165577,8 @@ var ts; // "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar" function copyExpressionComments(node) { var file = node.getSourceFile(); - ts.copyTrailingComments(node, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(node, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } function getExpressionFromParenthesesOrExpression(node) { if (ts.isParenthesizedExpression(node)) { @@ -164869,7 +165773,7 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* ModifierFlags.Export */) | ts.getEffectiveModifierFlags(func); var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); var newNode = ts.factory.createFunctionDeclaration(ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { @@ -164895,7 +165799,7 @@ var ts; else { body = func.body; } - var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* EqualsGreaterThanToken */), body); + var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), body); return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, func, newNode); }); } function canBeConvertedToExpression(body, head) { @@ -164955,13 +165859,13 @@ var ts; return ts.emptyArray; } function doChange(sourceFile, changes, declaration, typeNode) { - var closeParen = ts.findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile); + var closeParen = ts.findChildOfKind(declaration, 21 /* SyntaxKind.CloseParenToken */, sourceFile); var needParens = ts.isArrowFunction(declaration) && closeParen === undefined; var endNode = needParens ? ts.first(declaration.parameters) : closeParen; if (endNode) { if (needParens) { - changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* OpenParenToken */)); - changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); + changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } changes.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); } @@ -164971,7 +165875,7 @@ var ts; return; var token = ts.getTokenAtPosition(context.file, context.startPosition); var declaration = ts.findAncestor(token, function (n) { - return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : + return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : isConvertibleDeclaration(n); }); if (!declaration || !declaration.body || declaration.type) { @@ -164982,17 +165886,17 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); + var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NodeBuilderFlags.NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; } } function isConvertibleDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return true; default: return false; @@ -165019,20 +165923,20 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : - kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : + kind === 79 /* SyntaxKind.Identifier */ ? new IdentifierObject(79 /* SyntaxKind.Identifier */, pos, end) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* SyntaxKind.PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 50720768 /* ContextFlags */; + node.flags = parent.flags & 50720768 /* NodeFlags.ContextFlags */; return node; } var NodeObject = /** @class */ (function () { function NodeObject(kind, pos, end) { this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.kind = kind; } @@ -165094,8 +165998,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 309 /* FirstJSDocNode */ || kid.kind > 347 /* LastJSDocNode */; }); - return child.kind < 161 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 309 /* SyntaxKind.FirstJSDocNode */ || kid.kind > 347 /* SyntaxKind.LastJSDocNode */; }); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -165106,7 +166010,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 161 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -165154,19 +166058,19 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 79 /* Identifier */) { - ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); + if (token === 79 /* SyntaxKind.Identifier */) { + ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia")); } nodes.push(createNode(token, pos, textPos, parent)); } pos = textPos; - if (token === 1 /* EndOfFileToken */) { + if (token === 1 /* SyntaxKind.EndOfFileToken */) { break; } } } function createSyntaxList(nodes, parent) { - var list = createNode(348 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(348 /* SyntaxKind.SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { @@ -165183,9 +166087,9 @@ var ts; // Set properties in same order as NodeObject this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } TokenOrIdentifierObject.prototype.getSourceFile = function () { @@ -165225,7 +166129,7 @@ var ts; return this.getChildren()[index]; }; TokenOrIdentifierObject.prototype.getChildren = function () { - return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; + return this.kind === 1 /* SyntaxKind.EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -165276,20 +166180,25 @@ var ts; return this.documentationComment; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { - switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + if (context) { + if (ts.isGetAccessor(context)) { if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } - return this.contextualGetAccessorDocumentationComment; - case 173 /* SetAccessor */: + if (ts.length(this.contextualGetAccessorDocumentationComment)) { + return this.contextualGetAccessorDocumentationComment; + } + } + if (ts.isSetAccessor(context)) { if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); } - return this.contextualSetAccessorDocumentationComment; - default: - return this.getDocumentationComment(checker); + if (ts.length(this.contextualSetAccessorDocumentationComment)) { + return this.contextualSetAccessorDocumentationComment; + } + } } + return this.getDocumentationComment(checker); }; SymbolObject.prototype.getJsDocTags = function (checker) { if (this.tags === undefined) { @@ -165298,20 +166207,25 @@ var ts; return this.tags; }; SymbolObject.prototype.getContextualJsDocTags = function (context, checker) { - switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + if (context) { + if (ts.isGetAccessor(context)) { if (!this.contextualGetAccessorTags) { this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker); } - return this.contextualGetAccessorTags; - case 173 /* SetAccessor */: + if (ts.length(this.contextualGetAccessorTags)) { + return this.contextualGetAccessorTags; + } + } + if (ts.isSetAccessor(context)) { if (!this.contextualSetAccessorTags) { this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker); } - return this.contextualSetAccessorTags; - default: - return this.getJsDocTags(checker); + if (ts.length(this.contextualSetAccessorTags)) { + return this.contextualSetAccessorTags; + } + } } + return this.getJsDocTags(checker); }; return SymbolObject; }()); @@ -165328,7 +166242,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 79 /* Identifier */; + _this.kind = 79 /* SyntaxKind.Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -165340,7 +166254,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 79 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* SyntaxKind.Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -165355,7 +166269,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* SyntaxKind.PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -165377,16 +166291,16 @@ var ts; return this.checker.getAugmentedPropertiesOfType(this); }; TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0 /* Call */); + return this.checker.getSignaturesOfType(this, 0 /* SignatureKind.Call */); }; TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1 /* Construct */); + return this.checker.getSignaturesOfType(this, 1 /* SignatureKind.Construct */); }; TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0 /* String */); + return this.checker.getIndexTypeOfType(this, 0 /* IndexKind.String */); }; TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1 /* Number */); + return this.checker.getIndexTypeOfType(this, 1 /* IndexKind.Number */); }; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; @@ -165407,41 +166321,41 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 1048576 /* Union */); + return !!(this.flags & 1048576 /* TypeFlags.Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 2097152 /* Intersection */); + return !!(this.flags & 2097152 /* TypeFlags.Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 3145728 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* TypeFlags.UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 384 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* TypeFlags.StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 128 /* StringLiteral */); + return !!(this.flags & 128 /* TypeFlags.StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 256 /* NumberLiteral */); + return !!(this.flags & 256 /* TypeFlags.NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 262144 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeFlags.TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { - return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); + return !!(ts.getObjectFlags(this) & 3 /* ObjectFlags.ClassOrInterface */); }; TypeObject.prototype.isClass = function () { - return !!(ts.getObjectFlags(this) & 1 /* Class */); + return !!(ts.getObjectFlags(this) & 1 /* ObjectFlags.Class */); }; TypeObject.prototype.isIndexType = function () { - return !!(this.flags & 4194304 /* Index */); + return !!(this.flags & 4194304 /* TypeFlags.Index */); }; Object.defineProperty(TypeObject.prototype, "typeArguments", { /** * This polyfills `referenceType.typeArguments` for API consumers */ get: function () { - if (ts.getObjectFlags(this) & 4 /* Reference */) { + if (ts.getObjectFlags(this) & 4 /* ObjectFlags.Reference */) { return this.checker.getTypeArguments(this); } return undefined; @@ -165500,12 +166414,12 @@ var ts; var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker); if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) { var seenSymbols_1 = new ts.Set(); - var _loop_21 = function (declaration) { + var _loop_20 = function (declaration) { var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; if (!seenSymbols_1.has(symbol)) { seenSymbols_1.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualJsDocTags(declaration, checker); } return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; @@ -165517,7 +166431,7 @@ var ts; }; for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { var declaration = declarations_7[_i]; - _loop_21(declaration); + _loop_20(declaration); } } return tags; @@ -165528,11 +166442,11 @@ var ts; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker); if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) { var seenSymbols_2 = new ts.Set(); - var _loop_22 = function (declaration) { + var _loop_21 = function (declaration) { var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { if (!seenSymbols_2.has(symbol)) { seenSymbols_2.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualDocumentationComment(declaration, checker); } return symbol.getDocumentationComment(checker); @@ -165544,14 +166458,14 @@ var ts; }; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - _loop_22(declaration); + _loop_21(declaration); } } return doc; } function findBaseOfDeclaration(checker, declaration, cb) { var _a; - var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ ? declaration.parent.parent : declaration.parent; + var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ ? declaration.parent.parent : declaration.parent; if (!classOrInterfaceDeclaration) return; var isStaticMember = ts.hasStaticModifier(declaration); @@ -165566,7 +166480,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 305 /* SourceFile */; + _this.kind = 305 /* SyntaxKind.SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -165625,10 +166539,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -165648,31 +166562,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 182 /* SyntaxKind.TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { break; } // falls through - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -165683,12 +166597,12 @@ var ts; } } // falls through - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: addDeclaration(node); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -165701,7 +166615,7 @@ var ts; } } break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -165713,7 +166627,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -165722,8 +166636,8 @@ var ts; } } break; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) !== 0 /* AssignmentDeclarationKind.None */) { addDeclaration(node); } // falls through @@ -165792,8 +166706,8 @@ var ts; function getDefaultCompilerOptions() { // Always default to "ScriptTarget.ES5" for the language service return { - target: 1 /* ES5 */, - jsx: 1 /* Preserve */ + target: 1 /* ScriptTarget.ES5 */, + jsx: 1 /* JsxEmit.Preserve */ }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; @@ -165818,7 +166732,7 @@ var ts; if (this.currentFileName !== fileName) { // This is a new file, just parse it var options = { - languageVersion: 99 /* Latest */, + languageVersion: 99 /* ScriptTarget.Latest */, impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(fileName, this.host.getCurrentDirectory(), ((_c = (_b = (_a = this.host).getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getCanonicalFileName) || ts.hostGetCanonicalFileName(this.host)), (_h = (_g = (_f = (_e = (_d = this.host).getCompilerHost) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.getModuleResolutionCache) === null || _g === void 0 ? void 0 : _g.call(_f)) === null || _h === void 0 ? void 0 : _h.getPackageJsonInfoCache(), this.host, this.host.getCompilationSettings()), setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings()) }; @@ -165915,7 +166829,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -165945,7 +166859,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -166035,7 +166949,7 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - var error = new Error("Could not find source file: '" + fileName + "'."); + var error = new Error("Could not find source file: '".concat(fileName, "'.")); // We've been having trouble debugging this, so attach sidecar data for the tsserver log. // See https://github.com/microsoft/TypeScript/issues/30180. error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); @@ -166062,7 +166976,10 @@ var ts; program = undefined; // TODO: GH#18217 lastTypesRootVersion = typeRootsVersion; } - var rootFileNames = host.getScriptFileNames(); + // This array is retained by the program and will be used to determine if the program is up to date, + // so we need to make a copy in case the host mutates the underlying array - otherwise it would look + // like every program always has the host's current list of root files. + var rootFileNames = host.getScriptFileNames().slice(); // Get a fresh cache of the host information var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; @@ -166173,7 +167090,7 @@ var ts; return result; } function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { - var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + var result = getOrCreateSourceFile(configFileName, 100 /* ScriptTarget.JSON */); if (!result) return undefined; result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); @@ -166195,12 +167112,12 @@ var ts; // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat); } - function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { - return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); + function getOrCreateSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) { + return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile); } - function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) { + function getOrCreateSourceFileByPath(fileName, path, languageVersionOrOptions, _onError, shouldCreateNewSourceFile) { ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host."); // The program is asking for this file, check first if the host can locate it. // If the host can not locate the file, then it does not exist. return undefined @@ -166243,17 +167160,17 @@ var ts; // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" if (scriptKind === oldSourceFile.scriptKind) { - return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind); + return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions); } else { // Release old source file and fall through to aquire new file with new script kind - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat); } } // We didn't already have the file. Fall through and acquire it from the registry. } // Could not find this file in the old program, create a new SourceFile for it. - return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind); + return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions); } } // TODO: GH#18217 frequently asserted as defined @@ -166320,7 +167237,7 @@ var ts; if (!sourceFile) return undefined; var rawNode = ts.getTouchingPropertyName(sourceFile, docSpan.textSpan.start); - var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* References */ }); + var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }); return adjustedNode; } } @@ -166332,7 +167249,7 @@ var ts; // Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()); ts.forEach(program.getSourceFiles(), function (f) { - return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind); + return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind, f.impliedNodeFormat); }); program = undefined; // TODO: GH#18217 } @@ -166400,8 +167317,8 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { var type_2 = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined; return type_2 && { - kind: "" /* unknown */, - kindModifiers: "" /* none */, + kind: "" /* ScriptElementKind.unknown */, + kindModifiers: "" /* ScriptElementKindModifier.none */, textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile), displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(nodeForQuickInfo)); }), documentation: type_2.symbol ? type_2.symbol.getDocumentationComment(typeChecker) : undefined, @@ -166434,18 +167351,18 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 106 /* SuperKeyword */: - case 197 /* NamedTupleMember */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 106 /* SyntaxKind.SuperKeyword */: + case 197 /* SyntaxKind.NamedTupleMember */: return true; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return ts.isImportMeta(node); default: return false; @@ -166471,7 +167388,7 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* HighlightSpanKind.writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); @@ -166495,17 +167412,17 @@ var ts; }); } else { - return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); + return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* FindAllReferences.FindReferencesUse.Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); } } function getReferencesAtPosition(fileName, position) { synchronizeHostData(); - return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry); + return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, ts.FindAllReferences.toReferenceEntry); } function getReferencesWorker(node, position, options, cb) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. - var sourceFiles = options && options.use === 2 /* Rename */ + var sourceFiles = options && options.use === 2 /* FindAllReferences.FindReferencesUse.Rename */ ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) : program.getSourceFiles(); return ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, cb); @@ -166552,16 +167469,16 @@ var ts; return undefined; } switch (node.kind) { - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: - case 10 /* StringLiteral */: - case 95 /* FalseKeyword */: - case 110 /* TrueKeyword */: - case 104 /* NullKeyword */: - case 106 /* SuperKeyword */: - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 79 /* Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: + case 10 /* SyntaxKind.StringLiteral */: + case 95 /* SyntaxKind.FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 79 /* SyntaxKind.Identifier */: break; // Cant create the text span default: @@ -166577,7 +167494,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 261 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -166607,8 +167524,8 @@ var ts; } function getSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "2020" /* TwentyTwenty */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "2020" /* SemanticClassificationFormat.TwentyTwenty */) { return ts.classifier.v2020.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); } else { @@ -166617,8 +167534,8 @@ var ts; } function getEncodedSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "original" /* Original */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "original" /* SemanticClassificationFormat.Original */) { return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } else { @@ -166639,10 +167556,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = new ts.Map(ts.getEntries((_a = {}, - _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, - _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, - _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, + _a[18 /* SyntaxKind.OpenBraceToken */] = 19 /* SyntaxKind.CloseBraceToken */, + _a[20 /* SyntaxKind.OpenParenToken */] = 21 /* SyntaxKind.CloseParenToken */, + _a[22 /* SyntaxKind.OpenBracketToken */] = 23 /* SyntaxKind.CloseBracketToken */, + _a[31 /* SyntaxKind.GreaterThanToken */] = 29 /* SyntaxKind.LessThanToken */, _a))); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -166739,7 +167656,7 @@ var ts; // var x = new foo<| ( with class foo{} ) // or // var y = 3 <| - if (openingBrace === 60 /* lessThan */) { + if (openingBrace === 60 /* CharacterCodes.lessThan */) { return false; } var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -166748,15 +167665,15 @@ var ts; return false; } if (ts.isInsideJsxElementOrAttribute(sourceFile, position)) { - return openingBrace === 123 /* openBrace */; + return openingBrace === 123 /* CharacterCodes.openBrace */; } if (ts.isInTemplateString(sourceFile, position)) { return false; } switch (openingBrace) { - case 39 /* singleQuote */: - case 34 /* doubleQuote */: - case 96 /* backtick */: + case 39 /* CharacterCodes.singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 96 /* CharacterCodes.backtick */: return !ts.isInComment(sourceFile, position); } return true; @@ -166766,12 +167683,12 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxElement(token.parent) ? token.parent : undefined; if (element && isUnclosedTag(element)) { - return { newText: "" }; + return { newText: "") }; } - var fragment = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent + var fragment = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxFragment(token.parent) ? token.parent : undefined; if (fragment && isUnclosedFragment(fragment)) { return { newText: "" }; @@ -166868,14 +167785,14 @@ var ts; commentRange.end++; } positions.push(commentRange.pos); - if (commentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (commentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { positions.push(commentRange.end); } hasComment = true; pos = commentRange.end + 1; } else { // If it's not in a comment range, then we need to comment the uncommented portions. - var newPos = text.substring(pos, textRange.end).search("(" + openMultilineRegex + ")|(" + closeMultilineRegex + ")"); + var newPos = text.substring(pos, textRange.end).search("(".concat(openMultilineRegex, ")|(").concat(closeMultilineRegex, ")")); isCommenting = insertComment !== undefined ? insertComment : isCommenting || !ts.isTextWhiteSpaceLike(text, pos, newPos === -1 ? textRange.end : pos + newPos); // If isCommenting is already true we don't need to check whitespace again. @@ -166885,7 +167802,7 @@ var ts; // If it didn't found a comment and isCommenting is false means is only empty space. // We want to insert comment in this scenario. if (isCommenting || !hasComment) { - if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SingleLineCommentTrivia */) { + if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SyntaxKind.SingleLineCommentTrivia */) { ts.insertSorted(positions, textRange.pos, ts.compareValues); } ts.insertSorted(positions, textRange.end, ts.compareValues); @@ -166971,10 +167888,10 @@ var ts; var commentRange = ts.isInComment(sourceFile, i); if (commentRange) { switch (commentRange.kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: textChanges.push.apply(textChanges, toggleLineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); } i = commentRange.end + 1; @@ -166989,12 +167906,12 @@ var ts; } function isUnclosedFragment(_a) { var closingFragment = _a.closingFragment, parent = _a.parent; - return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); + return !!(closingFragment.flags & 131072 /* NodeFlags.ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); - return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; + return range && (!onlyMultiLine || range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -167112,9 +168029,9 @@ var ts; return new RegExp(regExpString, "gim"); } function isLetterOrDigit(char) { - return (char >= 97 /* a */ && char <= 122 /* z */) || - (char >= 65 /* A */ && char <= 90 /* Z */) || - (char >= 48 /* _0 */ && char <= 57 /* _9 */); + return (char >= 97 /* CharacterCodes.a */ && char <= 122 /* CharacterCodes.z */) || + (char >= 65 /* CharacterCodes.A */ && char <= 90 /* CharacterCodes.Z */) || + (char >= 48 /* CharacterCodes._0 */ && char <= 57 /* CharacterCodes._9 */); } function isNodeModulesFile(path) { return ts.stringContains(path, "/node_modules/"); @@ -167249,6 +168166,7 @@ var ts; getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getProgram: getProgram, + getCurrentProgram: function () { return program; }, getAutoImportProvider: getAutoImportProvider, updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols, getApplicableRefactors: getApplicableRefactors, @@ -167271,14 +168189,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidOperationsInPartialSemanticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.PartialSemantic")); }; }); break; case ts.LanguageServiceMode.Syntactic: invalidOperationsInSyntacticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.Syntactic")); }; }); break; @@ -167325,7 +168243,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 277 /* ExternalModuleReference */ || + node.parent.kind === 277 /* SyntaxKind.ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -167340,16 +168258,16 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 162 /* ComputedPropertyName */) { + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 205 /* ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* JsxAttributes */) && + (node.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* SyntaxKind.JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -167391,7 +168309,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 207 /* ElementAccessExpression */ && + node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -167438,7 +168356,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 16777216 /* Ambient */) { + if (tokenAtLocation.flags & 16777216 /* NodeFlags.Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -167484,144 +168402,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return spanInVariableDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return spanInParameterDeclaration(node); - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return spanInFunctionDeclaration(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanInBlock(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInBlock(node.block); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: // span in statement return spanInNode(node.statement); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return spanInForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // span on complete module if it is instantiated - if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 203 /* BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 203 /* SyntaxKind.BindingElement */: // span on complete node return textSpan(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: // span in statement return spanInNode(node.statement); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return spanInNodeArray(parent.modifiers, node, ts.isDecorator); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return undefined; // Tokens: - case 26 /* SemicolonToken */: - case 1 /* EndOfFileToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return spanInPreviousNode(node); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return spanInOpenBraceToken(node); - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: return spanInCloseBraceToken(node); - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: return spanInCloseBracketToken(node); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return spanInOpenParenToken(node); - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: return spanInCloseParenToken(node); - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: return spanInColonToken(node); - case 31 /* GreaterThanToken */: - case 29 /* LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return spanInWhileKeyword(node); - case 91 /* ElseKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return spanInNextNode(node); - case 160 /* OfKeyword */: + case 160 /* SyntaxKind.OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -167633,14 +168551,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 79 /* Identifier */ || - node.kind === 225 /* SpreadElement */ || - node.kind === 296 /* PropertyAssignment */ || - node.kind === 297 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 225 /* SyntaxKind.SpreadElement */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 221 /* BinaryExpression */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -167649,35 +168567,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or // { a = expression, b, c } = someExpression return textSpan(node); } - if (operatorToken.kind === 27 /* CommaToken */) { + if (operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return textSpan(node); - case 221 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 27 /* CommaToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -167686,21 +168604,21 @@ var ts; } } switch (node.parent.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -167708,7 +168626,7 @@ var ts; } break; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -167738,7 +168656,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 243 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -167749,8 +168667,8 @@ var ts; // Breakpoint is possible in variableDeclaration only if there is initialization // or its declaration from 'for of' if ((ts.hasOnlyExpressionInitializer(variableDeclaration) && variableDeclaration.initializer) || - ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 244 /* ForOfStatement */) { + ts.hasSyntacticModifier(variableDeclaration, 1 /* ModifierFlags.Export */) || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -167765,7 +168683,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - ts.hasSyntacticModifier(parameter, 4 /* Public */ | 8 /* Private */); + ts.hasSyntacticModifier(parameter, 4 /* ModifierFlags.Public */ | 8 /* ModifierFlags.Private */); } function spanInParameterDeclaration(parameter) { if (ts.isBindingPattern(parameter.name)) { @@ -167790,8 +168708,8 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 257 /* ClassDeclaration */ && functionDeclaration.kind !== 171 /* Constructor */); + return ts.hasSyntacticModifier(functionDeclaration, 1 /* ModifierFlags.Export */) || + (functionDeclaration.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && functionDeclaration.kind !== 171 /* SyntaxKind.Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -167814,26 +168732,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 261 /* ModuleDeclaration */: - if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { + case 261 /* SyntaxKind.ModuleDeclaration */: + if (ts.getModuleInstanceState(block.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 243 /* ForInStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -167858,21 +168776,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 203 /* BindingElement */) { + if (bindingPattern.parent.kind === 203 /* SyntaxKind.BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 202 /* ArrayBindingPattern */ && node.kind !== 201 /* ObjectBindingPattern */); - var elements = node.kind === 204 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 202 /* SyntaxKind.ArrayBindingPattern */ && node.kind !== 201 /* SyntaxKind.ObjectBindingPattern */); + var elements = node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -167880,18 +168798,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 221 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -167899,25 +168817,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: // If this is not an instantiated module block, no bp span - if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 260 /* EnumDeclaration */: - case 257 /* ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // Span on close brace token return textSpan(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -167925,7 +168843,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -167941,7 +168859,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -167956,12 +168874,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 240 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 208 /* CallExpression */ || - node.parent.kind === 209 /* NewExpression */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 208 /* SyntaxKind.CallExpression */ || + node.parent.kind === 209 /* SyntaxKind.NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 212 /* ParenthesizedExpression */) { + if (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -167970,21 +168888,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 212 /* ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -167994,20 +168912,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ || - node.parent.kind === 164 /* Parameter */) { + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.parent.kind === 164 /* SyntaxKind.Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 211 /* TypeAssertionExpression */) { + if (node.parent.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 240 /* DoStatement */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -168015,7 +168933,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -168183,7 +169101,7 @@ var ts; return this.shimHost.getScriptKind(fileName); // TODO: GH#18217 } else { - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } }; LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { @@ -168273,13 +169191,13 @@ var ts; var result = action(); if (logPerformance) { var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); + logger.log("".concat(actionDescription, " completed in ").concat(end - start, " msec")); if (ts.isString(result)) { var str = result; if (str.length > 128) { str = str.substring(0, 128) + "..."; } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + logger.log(" result.length=".concat(str.length, ", result='").concat(JSON.stringify(str), "'")); } } return result; @@ -168361,7 +169279,7 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + this.forwardJSONCall("refresh(".concat(throwOnError, ")"), function () { return null; } // eslint-disable-line no-null/no-null ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { @@ -168377,43 +169295,43 @@ var ts; }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSyntacticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSemanticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSuggestionDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSuggestionDiagnostics('" + fileName + "')", function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); + return this.forwardJSONCall("getSuggestionDiagnostics('".concat(fileName, "')"), function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); }; LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { var _this = this; @@ -168429,7 +169347,7 @@ var ts; */ LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + return this.forwardJSONCall("getQuickInfoAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); }; /// NAMEORDOTTEDNAMESPAN /** @@ -168438,7 +169356,7 @@ var ts; */ LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + return this.forwardJSONCall("getNameOrDottedNameSpan('".concat(fileName, "', ").concat(startPos, ", ").concat(endPos, ")"), function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); }; /** * STATEMENTSPAN @@ -168446,12 +169364,12 @@ var ts; */ LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + return this.forwardJSONCall("getBreakpointStatementAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); + return this.forwardJSONCall("getSignatureHelpItems('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** @@ -168460,7 +169378,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); }; /** * Computes the definition location and file for the symbol @@ -168468,7 +169386,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAndBoundSpan = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAndBoundSpan('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); + return this.forwardJSONCall("getDefinitionAndBoundSpan('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); }; /// GOTO Type /** @@ -168477,7 +169395,7 @@ var ts; */ LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getTypeDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); }; /// GOTO Implementation /** @@ -168486,37 +169404,37 @@ var ts; */ LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + return this.forwardJSONCall("getImplementationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) { var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); }); + return this.forwardJSONCall("getRenameInfo('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getRenameInfo(fileName, position, preferences); }); }; LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getSmartSelectionRange('" + fileName + "', " + position + ")", function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); + return this.forwardJSONCall("getSmartSelectionRange('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); }; LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename) { var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ", " + providePrefixAndSuffixTextForRename + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); + return this.forwardJSONCall("findRenameLocations('".concat(fileName, "', ").concat(position, ", ").concat(findInStrings, ", ").concat(findInComments, ", ").concat(providePrefixAndSuffixTextForRename, ")"), function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); }; /// GET BRACE MATCHING LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + return this.forwardJSONCall("getBraceMatchingAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(openingBrace, ")"), function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { var _this = this; - return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + return this.forwardJSONCall("getSpanOfEnclosingComment('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getIndentationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); }); @@ -168524,23 +169442,23 @@ var ts; /// GET REFERENCES LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getReferencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + return this.forwardJSONCall("findReferences('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.findReferences(fileName, position); }); }; LanguageServiceShimObject.prototype.getFileReferences = function (fileName) { var _this = this; - return this.forwardJSONCall("getFileReferences('" + fileName + ")", function () { return _this.languageService.getFileReferences(fileName); }); + return this.forwardJSONCall("getFileReferences('".concat(fileName, ")"), function () { return _this.languageService.getFileReferences(fileName); }); }; LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getOccurrencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getDocumentHighlights('".concat(fileName, "', ").concat(position, ")"), function () { var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); // workaround for VS document highlighting issue - keep only items from the initial file var normalizedName = ts.toFileNameLowerCase(ts.normalizeSlashes(fileName)); @@ -168555,108 +169473,108 @@ var ts; */ LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) { var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); + return this.forwardJSONCall("getCompletionsAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(preferences, ", ").concat(formattingSettings, ")"), function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); }; /** Get a string based representation of a completion list entry details */ LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { + return this.forwardJSONCall("getCompletionEntryDetails('".concat(fileName, "', ").concat(position, ", '").concat(entryName, "')"), function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + return this.forwardJSONCall("getFormattingEditsForRange('".concat(fileName, "', ").concat(start, ", ").concat(end, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + return this.forwardJSONCall("getFormattingEditsForDocument('".concat(fileName, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('".concat(fileName, "', ").concat(position, ", '").concat(key, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + return this.forwardJSONCall("getNavigateToItems('".concat(searchValue, "', ").concat(maxResultCount, ", ").concat(fileName, ")"), function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); }; LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + return this.forwardJSONCall("getNavigationBarItems('".concat(fileName, "')"), function () { return _this.languageService.getNavigationBarItems(fileName); }); }; LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + return this.forwardJSONCall("getNavigationTree('".concat(fileName, "')"), function () { return _this.languageService.getNavigationTree(fileName); }); }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + return this.forwardJSONCall("getOutliningSpans('".concat(fileName, "')"), function () { return _this.languageService.getOutliningSpans(fileName); }); }; LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + return this.forwardJSONCall("getTodoComments('".concat(fileName, "')"), function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); }; /// CALL HIERARCHY LanguageServiceShimObject.prototype.prepareCallHierarchy = function (fileName, position) { var _this = this; - return this.forwardJSONCall("prepareCallHierarchy('" + fileName + "', " + position + ")", function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); + return this.forwardJSONCall("prepareCallHierarchy('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyIncomingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyIncomingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyIncomingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyOutgoingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideInlayHints = function (fileName, span, preference) { var _this = this; - return this.forwardJSONCall("provideInlayHints('" + fileName + "', '" + JSON.stringify(span) + "', " + JSON.stringify(preference) + ")", function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); + return this.forwardJSONCall("provideInlayHints('".concat(fileName, "', '").concat(JSON.stringify(span), "', ").concat(JSON.stringify(preference), ")"), function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); }; /// Emit LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + return this.forwardJSONCall("getEmitOutput('".concat(fileName, "')"), function () { var _a = _this.languageService.getEmitOutput(fileName), diagnostics = _a.diagnostics, rest = __rest(_a, ["diagnostics"]); return __assign(__assign({}, rest), { diagnostics: _this.realizeDiagnostics(diagnostics) }); }); }; LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", + return forwardCall(this.logger, "getEmitOutput('".concat(fileName, "')"), /*returnJson*/ false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); }; LanguageServiceShimObject.prototype.toggleLineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleLineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleLineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleLineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleLineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.toggleMultilineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleMultilineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleMultilineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.commentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("commentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.commentSelection(fileName, textRange); }); + return this.forwardJSONCall("commentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.commentSelection(fileName, textRange); }); }; LanguageServiceShimObject.prototype.uncommentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("uncommentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.uncommentSelection(fileName, textRange); }); + return this.forwardJSONCall("uncommentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.uncommentSelection(fileName, textRange); }); }; return LanguageServiceShimObject; }(ShimBase)); @@ -168706,11 +169624,11 @@ var ts; }; CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + return this.forwardJSONCall("resolveModuleName('".concat(fileName, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) { + if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Extension.Ts */ && result.resolvedModule.extension !== ".tsx" /* Extension.Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Extension.Dts */) { resolvedFileName = undefined; } return { @@ -168722,7 +169640,7 @@ var ts; }; CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + return this.forwardJSONCall("resolveTypeReferenceDirective(".concat(fileName, ")"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); return { @@ -168734,7 +169652,7 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getPreProcessedFileInfo('".concat(fileName, "')"), function () { // for now treat files as JavaScript var result = ts.preProcessFile(ts.getSnapshotText(sourceTextSnapshot), /* readImportFiles */ true, /* detectJavaScriptImports */ true); return { @@ -168749,7 +169667,7 @@ var ts; }; CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('".concat(compilerOptionsJson, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); }); @@ -168771,7 +169689,7 @@ var ts; }; CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getTSConfigFileInfo('".concat(fileName, "')"), function () { var result = ts.parseJsonText(fileName, ts.getSnapshotText(sourceTextSnapshot)); var normalizedFileName = ts.normalizeSlashes(fileName); var configFile = ts.parseJsonSourceFileConfigFileContent(result, _this.host, ts.getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName); @@ -168971,7 +169889,7 @@ var ts; function nowString() { // E.g. "12:34:56.789" var d = new Date(); - return ts.padLeft(d.getHours().toString(), 2, "0") + ":" + ts.padLeft(d.getMinutes().toString(), 2, "0") + ":" + ts.padLeft(d.getSeconds().toString(), 2, "0") + "." + ts.padLeft(d.getMilliseconds().toString(), 3, "0"); + return "".concat(ts.padLeft(d.getHours().toString(), 2, "0"), ":").concat(ts.padLeft(d.getMinutes().toString(), 2, "0"), ":").concat(ts.padLeft(d.getSeconds().toString(), 2, "0"), ".").concat(ts.padLeft(d.getMilliseconds().toString(), 3, "0")); } server.nowString = nowString; })(server = ts.server || (ts.server = {})); @@ -168982,7 +169900,7 @@ var ts; var JsTyping; (function (JsTyping) { function isTypingUpToDate(cachedTyping, availableTypingVersions) { - var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); + var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts".concat(ts.versionMajorMinor)) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; @@ -169035,7 +169953,7 @@ var ts; "worker_threads", "zlib" ]; - JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:" + name; }); + JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:".concat(name); }); JsTyping.nodeCoreModuleList = __spreadArray(__spreadArray([], unprefixedNodeCoreModuleList, true), JsTyping.prefixedNodeCoreModuleList, true); JsTyping.nodeCoreModules = new ts.Set(JsTyping.nodeCoreModuleList); function nonRelativeModuleNameForTypingCache(moduleName) { @@ -169110,7 +170028,7 @@ var ts; var excludeTypingName = exclude_1[_i]; var didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) - log("Typing for " + excludeTypingName + " is in exclude list, will be ignored."); + log("Typing for ".concat(excludeTypingName, " is in exclude list, will be ignored.")); } var newTypingNames = []; var cachedTypingPaths = []; @@ -169124,7 +170042,7 @@ var ts; }); var result = { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; if (log) - log("Result: " + JSON.stringify(result)); + log("Result: ".concat(JSON.stringify(result))); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { @@ -169133,7 +170051,7 @@ var ts; } function addInferredTypings(typingNames, message) { if (log) - log(message + ": " + JSON.stringify(typingNames)); + log("".concat(message, ": ").concat(JSON.stringify(typingNames))); ts.forEach(typingNames, addInferredTyping); } /** @@ -169155,7 +170073,7 @@ var ts; filesToWatch.push(manifestPath); manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config; manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys); - addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies"); + addInferredTypings(manifestTypingNames, "Typing names in '".concat(manifestPath, "' dependencies")); } // Now we scan the directories for typing information in // already-installed dependencies (if present). Note that this @@ -169183,7 +170101,7 @@ var ts; // This is #1 described above. ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); }) // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json` - : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) + : host.readDirectory(packagesFolderPath, [".json" /* Extension.Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) .filter(function (manifestPath) { if (ts.getBaseFileName(manifestPath) !== manifestName) { return false; @@ -169199,7 +170117,7 @@ var ts; !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo` }); if (log) - log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames)); + log("Searching for typing names in ".concat(packagesFolderPath, "; all files: ").concat(JSON.stringify(dependencyManifestNames))); // Once we have the names of things to look up, we iterate over // and either collect their included typings, or add them to the // list of typings we need to look up separately. @@ -169218,12 +170136,12 @@ var ts; var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName)); if (host.fileExists(absolutePath)) { if (log) - log(" Package '" + manifest_1.name + "' provides its own types."); + log(" Package '".concat(manifest_1.name, "' provides its own types.")); inferredTypings.set(manifest_1.name, absolutePath); } else { if (log) - log(" Package '" + manifest_1.name + "' provides its own types but they are missing."); + log(" Package '".concat(manifest_1.name, "' provides its own types but they are missing.")); } } else { @@ -169249,7 +170167,7 @@ var ts; if (fromFileNames.length) { addInferredTypings(fromFileNames, "Inferred typings from file names"); } - var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); }); + var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Extension.Jsx */); }); if (hasJsxFile) { if (log) log("Inferred 'react' typings due to presence of '.jsx' extension"); @@ -169277,16 +170195,16 @@ var ts; JsTyping.validatePackageName = validatePackageName; function validatePackageNameWorker(packageName, supportScopedPackage) { if (!packageName) { - return 1 /* EmptyName */; + return 1 /* NameValidationResult.EmptyName */; } if (packageName.length > maxPackageNameLength) { - return 2 /* NameTooLong */; + return 2 /* NameValidationResult.NameTooLong */; } - if (packageName.charCodeAt(0) === 46 /* dot */) { - return 3 /* NameStartsWithDot */; + if (packageName.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + return 3 /* NameValidationResult.NameStartsWithDot */; } - if (packageName.charCodeAt(0) === 95 /* _ */) { - return 4 /* NameStartsWithUnderscore */; + if (packageName.charCodeAt(0) === 95 /* CharacterCodes._ */) { + return 4 /* NameValidationResult.NameStartsWithUnderscore */; } // check if name is scope package like: starts with @ and has one '/' in the middle // scoped packages are not currently supported @@ -169294,20 +170212,20 @@ var ts; var matches = /^@([^/]+)\/([^/]+)$/.exec(packageName); if (matches) { var scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false); - if (scopeResult !== 0 /* Ok */) { + if (scopeResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[1], isScopeName: true, result: scopeResult }; } var packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false); - if (packageResult !== 0 /* Ok */) { + if (packageResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[2], isScopeName: false, result: packageResult }; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } } if (encodeURIComponent(packageName) !== packageName) { - return 5 /* NameContainsNonURISafeCharacters */; + return 5 /* NameValidationResult.NameContainsNonURISafeCharacters */; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } function renderPackageNameValidationFailure(result, typing) { return typeof result === "object" ? @@ -169318,17 +170236,17 @@ var ts; function renderPackageNameValidationFailureWorker(typing, result, name, isScopeName) { var kind = isScopeName ? "Scope" : "Package"; switch (result) { - case 1 /* EmptyName */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot be empty"; - case 2 /* NameTooLong */: - return "'" + typing + "':: " + kind + " name '" + name + "' should be less than " + maxPackageNameLength + " characters"; - case 3 /* NameStartsWithDot */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '.'"; - case 4 /* NameStartsWithUnderscore */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '_'"; - case 5 /* NameContainsNonURISafeCharacters */: - return "'" + typing + "':: " + kind + " name '" + name + "' contains non URI safe characters"; - case 0 /* Ok */: + case 1 /* NameValidationResult.EmptyName */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot be empty"); + case 2 /* NameValidationResult.NameTooLong */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' should be less than ").concat(maxPackageNameLength, " characters"); + case 3 /* NameValidationResult.NameStartsWithDot */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '.'"); + case 4 /* NameValidationResult.NameStartsWithUnderscore */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '_'"); + case 5 /* NameValidationResult.NameContainsNonURISafeCharacters */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' contains non URI safe characters"); + case 0 /* NameValidationResult.Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: throw ts.Debug.assertNever(result); @@ -169380,7 +170298,7 @@ var ts; } Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + throw new Error("Project '".concat(project.getProjectName(), "' does not contain document '").concat(fileName, "'")); } Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; })(Errors = server.Errors || (server.Errors = {})); @@ -169421,17 +170339,17 @@ var ts; } server.isInferredProjectName = isInferredProjectName; function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; + return "/dev/null/inferredProject".concat(counter, "*"); } server.makeInferredProjectName = makeInferredProjectName; /*@internal*/ function makeAutoImportProviderProjectName(counter) { - return "/dev/null/autoImportProviderProject" + counter + "*"; + return "/dev/null/autoImportProviderProject".concat(counter, "*"); } server.makeAutoImportProviderProjectName = makeAutoImportProviderProjectName; /*@internal*/ function makeAuxiliaryProjectName(counter) { - return "/dev/null/auxiliaryProject" + counter + "*"; + return "/dev/null/auxiliaryProject".concat(counter, "*"); } server.makeAuxiliaryProjectName = makeAuxiliaryProjectName; function createSortedArray() { @@ -169466,7 +170384,7 @@ var ts; // schedule new operation, pass arguments this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); if (this.logger) { - this.logger.info("Scheduled: " + operationId + (pendingTimeout ? ", Cancelled earlier one" : "")); + this.logger.info("Scheduled: ".concat(operationId).concat(pendingTimeout ? ", Cancelled earlier one" : "")); } }; ThrottledOperations.prototype.cancel = function (operationId) { @@ -169480,7 +170398,7 @@ var ts; ts.perfLogger.logStartScheduledOperation(operationId); self.pendingTimeouts.delete(operationId); if (self.logger) { - self.logger.info("Running: " + operationId); + self.logger.info("Running: ".concat(operationId)); } cb(); ts.perfLogger.logStopScheduledOperation(); @@ -169509,7 +170427,7 @@ var ts; self.host.gc(); // TODO: GH#18217 if (log) { var after = self.host.getMemoryUsage(); // TODO: GH#18217 - self.logger.perftrc("GC::before " + before + ", after " + after); + self.logger.perftrc("GC::before ".concat(before, ", after ").concat(after)); } ts.perfLogger.logStopScheduledOperation(); }; @@ -169853,8 +170771,8 @@ var ts; } TextStorage.prototype.getVersion = function () { return this.svc - ? "SVC-" + this.version.svc + "-" + this.svc.getSnapshotVersion() - : "Text-" + this.version.text; + ? "SVC-".concat(this.version.svc, "-").concat(this.svc.getSnapshotVersion()) + : "Text-".concat(this.version.text); }; TextStorage.prototype.hasScriptVersionCache_TestOnly = function () { return this.svc !== undefined; @@ -169997,7 +170915,7 @@ var ts; if (fileSize > server.maxFileSize) { ts.Debug.assert(!!this.info.containingProjects.length); var service = this.info.containingProjects[0].projectService; - service.logger.info("Skipped loading contents of large file " + fileName + " for info " + this.info.fileName + ": fileSize: " + fileSize); + service.logger.info("Skipped loading contents of large file ".concat(fileName, " for info ").concat(this.info.fileName, ": fileSize: ").concat(fileSize)); this.info.containingProjects[0].projectService.sendLargeFileReferencedEvent(fileName, fileSize); return { text: "", fileSize: fileSize }; } @@ -170350,7 +171268,7 @@ var ts; return location; }; ScriptInfo.prototype.isJavaScript = function () { - return this.scriptKind === 1 /* JS */ || this.scriptKind === 2 /* JSX */; + return this.scriptKind === 1 /* ScriptKind.JS */ || this.scriptKind === 2 /* ScriptKind.JSX */; }; /*@internal*/ ScriptInfo.prototype.getLineInfo = function () { @@ -170378,14 +171296,14 @@ var ts; return project; } function failIfInvalidPosition(position) { - ts.Debug.assert(typeof position === "number", "Expected position " + position + " to be a number."); + ts.Debug.assert(typeof position === "number", "Expected position ".concat(position, " to be a number.")); ts.Debug.assert(position >= 0, "Expected position to be non-negative."); } function failIfInvalidLocation(location) { - ts.Debug.assert(typeof location.line === "number", "Expected line " + location.line + " to be a number."); - ts.Debug.assert(typeof location.offset === "number", "Expected offset " + location.offset + " to be a number."); - ts.Debug.assert(location.line > 0, "Expected line to be non-" + (location.line === 0 ? "zero" : "negative")); - ts.Debug.assert(location.offset > 0, "Expected offset to be non-" + (location.offset === 0 ? "zero" : "negative")); + ts.Debug.assert(typeof location.line === "number", "Expected line ".concat(location.line, " to be a number.")); + ts.Debug.assert(typeof location.offset === "number", "Expected offset ".concat(location.offset, " to be a number.")); + ts.Debug.assert(location.line > 0, "Expected line to be non-".concat(location.line === 0 ? "zero" : "negative")); + ts.Debug.assert(location.offset > 0, "Expected offset to be non-".concat(location.offset === 0 ? "zero" : "negative")); } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); @@ -170529,15 +171447,15 @@ var ts; var info = infos_1[_i]; var fileSize = includeSizes ? info.getTelemetryFileSize() : 0; switch (info.scriptKind) { - case 1 /* JS */: + case 1 /* ScriptKind.JS */: result.js += 1; result.jsSize += fileSize; break; - case 2 /* JSX */: + case 2 /* ScriptKind.JSX */: result.jsx += 1; result.jsxSize += fileSize; break; - case 3 /* TS */: + case 3 /* ScriptKind.TS */: if (ts.isDeclarationFileName(info.fileName)) { result.dts += 1; result.dtsSize += fileSize; @@ -170547,11 +171465,11 @@ var ts; result.tsSize += fileSize; } break; - case 4 /* TSX */: + case 4 /* ScriptKind.TSX */: result.tsx += 1; result.tsxSize += fileSize; break; - case 7 /* Deferred */: + case 7 /* ScriptKind.Deferred */: result.deferred += 1; result.deferredSize += fileSize; break; @@ -170576,7 +171494,7 @@ var ts; server.allFilesAreJsOrDts = allFilesAreJsOrDts; /* @internal */ function hasNoTypeScriptSource(fileNames) { - return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.isDeclarationFileName(fileName)) || ts.fileExtensionIs(fileName, ".tsx" /* Tsx */); }); + return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Extension.Ts */) && !ts.isDeclarationFileName(fileName)) || ts.fileExtensionIs(fileName, ".tsx" /* Extension.Tsx */); }); } server.hasNoTypeScriptSource = hasNoTypeScriptSource; function isGeneratedFileWatcher(watch) { @@ -170698,11 +171616,11 @@ var ts; }; Project.resolveModule = function (moduleName, initialDir, host, log, logErrors) { var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules"))); - log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); + log("Loading ".concat(moduleName, " from ").concat(initialDir, " (resolved to ").concat(resolvedPath, ")")); var result = host.require(resolvedPath, moduleName); // TODO: GH#18217 if (result.error) { var err = result.error.stack || result.error.message || JSON.stringify(result.error); - (logErrors || log)("Failed to load module '" + moduleName + "' from " + resolvedPath + ": " + err); + (logErrors || log)("Failed to load module '".concat(moduleName, "' from ").concat(resolvedPath, ": ").concat(err)); return undefined; } return result.module; @@ -170716,7 +171634,7 @@ var ts; case 0: ts.Debug.assertIsDefined(host.importServicePlugin); resolvedPath = ts.combinePaths(initialDir, "node_modules"); - log("Dynamically importing " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); + log("Dynamically importing ".concat(moduleName, " from ").concat(initialDir, " (resolved to ").concat(resolvedPath, ")")); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); @@ -170731,7 +171649,7 @@ var ts; case 4: if (result.error) { err = result.error.stack || result.error.message || JSON.stringify(result.error); - (logErrors || log)("Failed to dynamically import module '" + moduleName + "' from " + resolvedPath + ": " + err); + (logErrors || log)("Failed to dynamically import module '".concat(moduleName, "' from ").concat(resolvedPath, ": ").concat(err)); return [2 /*return*/, undefined]; } return [2 /*return*/, result.module]; @@ -170885,16 +171803,16 @@ var ts; }; /*@internal*/ Project.prototype.watchAffectingFileLocation = function (file, cb) { - return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.PackageJson, this); + return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.AffectingFileLocation, this); }; /*@internal*/ Project.prototype.clearInvalidateResolutionOfFailedLookupTimer = function () { - return this.projectService.throttledOperations.cancel(this.getProjectName() + "FailedLookupInvalidation"); + return this.projectService.throttledOperations.cancel("".concat(this.getProjectName(), "FailedLookupInvalidation")); }; /*@internal*/ Project.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () { var _this = this; - this.projectService.throttledOperations.schedule(this.getProjectName() + "FailedLookupInvalidation", /*delay*/ 1000, function () { + this.projectService.throttledOperations.schedule("".concat(this.getProjectName(), "FailedLookupInvalidation"), /*delay*/ 1000, function () { if (_this.resolutionCache.invalidateResolutionsOfFailedLookupLocations()) { _this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(_this); } @@ -170998,7 +171916,7 @@ var ts; } server.updateProjectIfDirty(this); this.builderState = ts.BuilderState.create(this.program, this.projectService.toCanonicalFileName, this.builderState, /*disableUseFileVersionAsSignature*/ true); - return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, ts.maybeBind(this.projectService.host, this.projectService.host.createHash)), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; }); + return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, ts.maybeBind(this.projectService.host, this.projectService.host.createHash), this.getCanonicalFileName), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; }); }; /** * Returns true if emit was conducted @@ -171072,7 +171990,7 @@ var ts; return plugin.module.getExternalFiles(_this); } catch (e) { - _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); + _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: ".concat(e)); if (e.stack) { _this.projectService.logger.info(e.stack); } @@ -171179,7 +172097,7 @@ var ts; } return ts.map(this.program.getSourceFiles(), function (sourceFile) { var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.resolvedPath); - ts.Debug.assert(!!scriptInfo, "getScriptInfo", function () { return "scriptInfo for a file '" + sourceFile.fileName + "' Path: '" + sourceFile.path + "' / '" + sourceFile.resolvedPath + "' is missing."; }); + ts.Debug.assert(!!scriptInfo, "getScriptInfo", function () { return "scriptInfo for a file '".concat(sourceFile.fileName, "' Path: '").concat(sourceFile.path, "' / '").concat(sourceFile.resolvedPath, "' is missing."); }); return scriptInfo; }); }; @@ -171353,7 +172271,7 @@ var ts; */ Project.prototype.updateGraph = function () { var _a; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] }); ts.perfLogger.logStartUpdateGraph(); this.resolutionCache.startRecordingFilesWithChangedResolutions(); var hasNewProgram = this.updateGraphWorker(); @@ -171422,23 +172340,23 @@ var ts; }; Project.prototype.updateGraphWorker = function () { var _this = this; - var oldProgram = this.program; + var oldProgram = this.languageService.getCurrentProgram(); ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project"); - this.writeLog("Starting updateGraphWorker: Project: " + this.getProjectName()); + this.writeLog("Starting updateGraphWorker: Project: ".concat(this.getProjectName())); var start = ts.timestamp(); this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution(); this.resolutionCache.startCachingPerDirectoryResolution(); this.program = this.languageService.getProgram(); // TODO: GH#18217 this.dirty = false; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution"); - this.resolutionCache.finishCachingPerDirectoryResolution(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "finishCachingPerDirectoryResolution"); + this.resolutionCache.finishCachingPerDirectoryResolution(this.program, oldProgram); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); ts.Debug.assert(oldProgram === undefined || this.program !== undefined); // bump up the version if // - oldProgram is not set - this is a first time updateGraph is called // - newProgram is different from the old program and structure of the old program was not reused. var hasNewProgram = false; - if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 2 /* Completely */))) { + if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 2 /* StructureIsReused.Completely */))) { hasNewProgram = true; if (oldProgram) { for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { @@ -171464,7 +172382,7 @@ var ts; var outPath = ts.outFile(this.compilerOptions); if (isGeneratedFileWatcher(this.generatedFilesMap)) { // --out - if (!outPath || !this.isValidGeneratedFileWatcher(ts.removeFileExtension(outPath) + ".d.ts" /* Dts */, this.generatedFilesMap)) { + if (!outPath || !this.isValidGeneratedFileWatcher(ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */, this.generatedFilesMap)) { this.clearGeneratedFileWatch(); } } @@ -171528,7 +172446,7 @@ var ts; }, function (removed) { return _this.detachScriptInfoFromProject(removed); }); var elapsed = ts.timestamp() - start; this.sendPerformanceEvent("UpdateGraph", elapsed); - this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + (this.program ? " structureIsReused:: " + ts.StructureIsReused[this.program.structureIsReused] : "") + " Elapsed: " + elapsed + "ms"); + this.writeLog("Finishing updateGraphWorker: Project: ".concat(this.getProjectName(), " Version: ").concat(this.getProjectVersion(), " structureChanged: ").concat(hasNewProgram).concat(this.program ? " structureIsReused:: ".concat(ts.StructureIsReused[this.program.structureIsReused]) : "", " Elapsed: ").concat(elapsed, "ms")); if (this.hasAddedorRemovedFiles) { this.print(/*writeProjectFileNames*/ true); } @@ -171588,7 +172506,7 @@ var ts; var path = this.toPath(sourceFile); if (this.generatedFilesMap) { if (isGeneratedFileWatcher(this.generatedFilesMap)) { - ts.Debug.fail(this.projectName + " Expected to not have --out watcher for generated file with options: " + JSON.stringify(this.compilerOptions)); + ts.Debug.fail("".concat(this.projectName, " Expected to not have --out watcher for generated file with options: ").concat(JSON.stringify(this.compilerOptions))); return; } if (this.generatedFilesMap.has(path)) @@ -171640,20 +172558,20 @@ var ts; if (!this.program) return "\tFiles (0) NoProgram\n"; var sourceFiles = this.program.getSourceFiles(); - var strBuilder = "\tFiles (" + sourceFiles.length + ")\n"; + var strBuilder = "\tFiles (".concat(sourceFiles.length, ")\n"); if (writeProjectFileNames) { for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var file = sourceFiles_1[_i]; - strBuilder += "\t" + file.fileName + "\n"; + strBuilder += "\t".concat(file.fileName, "\n"); } strBuilder += "\n\n"; - ts.explainFiles(this.program, function (s) { return strBuilder += "\t" + s + "\n"; }); + ts.explainFiles(this.program, function (s) { return strBuilder += "\t".concat(s, "\n"); }); } return strBuilder; }; /*@internal*/ Project.prototype.print = function (writeProjectFileNames) { - this.writeLog("Project '" + this.projectName + "' (" + ProjectKind[this.projectKind] + ")"); + this.writeLog("Project '".concat(this.projectName, "' (").concat(ProjectKind[this.projectKind], ")")); this.writeLog(this.filesToString(writeProjectFileNames && this.projectService.logger.hasLevel(server.LogLevel.verbose))); this.writeLog("-----------------------------------------------"); if (this.autoImportProviderHost) { @@ -171817,7 +172735,7 @@ var ts; if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) return "continue"; // Provide global: true so plugins can detect why they can't find their config - this_1.projectService.logger.info("Loading global plugin " + globalPluginName); + this_1.projectService.logger.info("Loading global plugin ".concat(globalPluginName)); this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides); }; var this_1 = this; @@ -171900,7 +172818,7 @@ var ts; } else { ts.forEach(errorLogs, function (message) { return _this.projectService.logger.info(message); }); - this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name); + this.projectService.logger.info("Couldn't find ".concat(pluginConfigEntry.name)); } }; Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) { @@ -171909,7 +172827,7 @@ var ts; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { - this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did not expose a proper factory function"); + this.projectService.logger.info("Skipped loading plugin ".concat(configEntry.name, " because it did not expose a proper factory function")); return; } var info = { @@ -171926,7 +172844,7 @@ var ts; var k = _a[_i]; // eslint-disable-next-line no-in-operator if (!(k in newLS)) { - this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); + this.projectService.logger.info("Plugin activation warning: Missing proxied method ".concat(k, " in created LS. Patching.")); newLS[k] = this.languageService[k]; } } @@ -171935,7 +172853,7 @@ var ts; this.plugins.push({ name: configEntry.name, module: pluginModule }); } catch (e) { - this.projectService.logger.info("Plugin activation failed: " + e); + this.projectService.logger.info("Plugin activation failed: ".concat(e)); } }; /*@internal*/ @@ -171985,11 +172903,11 @@ var ts; }; /*@internal*/ Project.prototype.includePackageJsonAutoImports = function () { - if (this.projectService.includePackageJsonAutoImports() === 0 /* Off */ || + if (this.projectService.includePackageJsonAutoImports() === 0 /* PackageJsonAutoImportPreference.Off */ || !this.languageServiceEnabled || ts.isInsideNodeModules(this.currentDirectory) || !this.isDefaultProjectForOpenFiles()) { - return 0 /* Off */; + return 0 /* PackageJsonAutoImportPreference.Off */; } return this.projectService.includePackageJsonAutoImports(); }; @@ -172030,7 +172948,7 @@ var ts; } var dependencySelection = this.includePackageJsonAutoImports(); if (dependencySelection) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getPackageJsonAutoImportProvider"); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "getPackageJsonAutoImportProvider"); var start = ts.timestamp(); this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getModuleResolutionHostForAutoImportProvider(), this.documentRegistry); if (this.autoImportProviderHost) { @@ -172085,7 +173003,7 @@ var ts; server.Project = Project; function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) { var sourceFiles = program.getSourceFiles(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getUnresolvedImports", { count: sourceFiles.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "getUnresolvedImports", { count: sourceFiles.length }); var ambientModules = program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); }); var result = ts.sortAndDeduplicate(ts.flatMap(sourceFiles, function (sourceFile) { return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile); @@ -172254,8 +173172,8 @@ var ts; var symlinkCache_1 = hostProject.getSymlinkCache(); var _loop_2 = function (name) { // Avoid creating a large project that would significantly slow down time to editor interactivity - if (dependencySelection === 2 /* Auto */ && dependenciesAdded > this_2.maxDependencies) { - hostProject.log("AutoImportProviderProject: attempted to add more than " + this_2.maxDependencies + " dependencies. Aborting."); + if (dependencySelection === 2 /* PackageJsonAutoImportPreference.Auto */ && dependenciesAdded > this_2.maxDependencies) { + hostProject.log("AutoImportProviderProject: attempted to add more than ".concat(this_2.maxDependencies, " dependencies. Aborting.")); return { value: ts.emptyArray }; } // 1. Try to load from the implementation package. For many dependencies, the @@ -172275,7 +173193,7 @@ var ts; // typings cache location, if enabled. var done = ts.forEach([hostProject.currentDirectory, hostProject.getGlobalTypingsCacheLocation()], function (directory) { if (directory) { - var typesPackageJson = ts.resolvePackageNameToPackageJson("@types/" + name, directory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache()); + var typesPackageJson = ts.resolvePackageNameToPackageJson("@types/".concat(name), directory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache()); if (typesPackageJson) { var entrypoints = getRootNamesFromPackageJson(typesPackageJson, program, symlinkCache_1); rootNames = ts.concatenate(rootNames, entrypoints); @@ -172304,7 +173222,7 @@ var ts; } } if (rootNames === null || rootNames === void 0 ? void 0 : rootNames.length) { - hostProject.log("AutoImportProviderProject: found " + rootNames.length + " root files in " + dependenciesAdded + " dependencies in " + (ts.timestamp() - start) + " ms"); + hostProject.log("AutoImportProviderProject: found ".concat(rootNames.length, " root files in ").concat(dependenciesAdded, " dependencies in ").concat(ts.timestamp() - start, " ms")); } return rootNames || ts.emptyArray; function addDependency(dependency) { @@ -172335,7 +173253,7 @@ var ts; }; /*@internal*/ AutoImportProviderProject.create = function (dependencySelection, hostProject, moduleResolutionHost, documentRegistry) { - if (dependencySelection === 0 /* Off */) { + if (dependencySelection === 0 /* PackageJsonAutoImportPreference.Off */) { return undefined; } var compilerOptions = __assign(__assign({}, hostProject.getCompilerOptions()), this.compilerOptionsOverrides); @@ -172401,7 +173319,7 @@ var ts; }; /*@internal*/ AutoImportProviderProject.prototype.includePackageJsonAutoImports = function () { - return 0 /* Off */; + return 0 /* PackageJsonAutoImportPreference.Off */; }; AutoImportProviderProject.prototype.getTypeAcquisition = function () { return { enable: false }; @@ -172566,7 +173484,7 @@ var ts; var searchPaths = __spreadArray([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations, true); if (this.projectService.allowLocalPluginLoads) { var local = ts.getDirectoryPath(this.canonicalConfigFilePath); - this.projectService.logger.info("Local plugin loading enabled; adding " + local + " to search paths"); + this.projectService.logger.info("Local plugin loading enabled; adding ".concat(local, " to search paths")); searchPaths.unshift(local); } // Enable tsconfig-specified plugins @@ -172845,15 +173763,15 @@ var ts; function convertScriptKindName(scriptKindName) { switch (scriptKindName) { case "JS": - return 1 /* JS */; + return 1 /* ScriptKind.JS */; case "JSX": - return 2 /* JSX */; + return 2 /* ScriptKind.JSX */; case "TS": - return 3 /* TS */; + return 3 /* ScriptKind.TS */; case "TSX": - return 4 /* TSX */; + return 4 /* ScriptKind.TSX */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } server.convertScriptKindName = convertScriptKindName; @@ -172992,7 +173910,7 @@ var ts; return forEachAnyProjectReferenceKind(project, function (resolvedRef) { return callbackRefProject(project, cb, resolvedRef.sourceFile.path); }, function (projectRef) { return callbackRefProject(project, cb, project.toPath(ts.resolveProjectReferencePath(projectRef))); }, function (potentialProjectRef) { return callbackRefProject(project, cb, potentialProjectRef); }); } function getDetailWatchInfo(watchType, project) { - return (ts.isString(project) ? "Config: " + project + " " : project ? "Project: " + project.getProjectName() + " " : "") + "WatchType: " + watchType; + return "".concat(ts.isString(project) ? "Config: ".concat(project, " ") : project ? "Project: ".concat(project.getProjectName(), " ") : "", "WatchType: ").concat(watchType); } function isScriptInfoWatchedFromNodeModules(info) { return !info.isScriptOpen() && info.mTime !== undefined; @@ -173199,7 +174117,7 @@ var ts; try { var fileContent = this.host.readFile(this.typesMapLocation); // TODO: GH#18217 if (fileContent === undefined) { - this.logger.info("Provided types map file \"" + this.typesMapLocation + "\" doesn't exist"); + this.logger.info("Provided types map file \"".concat(this.typesMapLocation, "\" doesn't exist")); return; } var raw = JSON.parse(fileContent); @@ -173217,7 +174135,7 @@ var ts; } } catch (e) { - this.logger.info("Error loading types map: " + e); + this.logger.info("Error loading types map: ".concat(e)); this.safelist = defaultTypeSafeList; this.legacySafelist.clear(); } @@ -173541,7 +174459,7 @@ var ts; var fsResult = config.cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); if (ts.getBaseFileName(fileOrDirectoryPath) === "package.json" && !ts.isInsideNodeModules(fileOrDirectoryPath) && (fsResult && fsResult.fileExists || !fsResult && _this.host.fileExists(fileOrDirectoryPath))) { - _this.logger.info("Config: " + configFileName + " Detected new package.json: " + fileOrDirectory); + _this.logger.info("Config: ".concat(configFileName, " Detected new package.json: ").concat(fileOrDirectory)); _this.onAddPackageJson(fileOrDirectoryPath); } var configuredProjectForConfig = _this.findConfiguredProjectByProjectName(configFileName); @@ -173663,14 +174581,14 @@ var ts; this.logger.info("`remove Project::"); project.print(/*writeProjectFileNames*/ true); project.close(); - if (ts.Debug.shouldAssert(1 /* Normal */)) { - this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project), "Found script Info still attached to project", function () { return project.projectName + ": ScriptInfos still attached: " + JSON.stringify(ts.arrayFrom(ts.mapDefinedIterator(_this.filenameToScriptInfo.values(), function (info) { return info.isAttached(project) ? + if (ts.Debug.shouldAssert(1 /* AssertionLevel.Normal */)) { + this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project), "Found script Info still attached to project", function () { return "".concat(project.projectName, ": ScriptInfos still attached: ").concat(JSON.stringify(ts.arrayFrom(ts.mapDefinedIterator(_this.filenameToScriptInfo.values(), function (info) { return info.isAttached(project) ? { fileName: info.fileName, projects: info.containingProjects.map(function (p) { return p.projectName; }), hasMixedContent: info.hasMixedContent } : undefined; })), - /*replacer*/ undefined, " "); }); }); + /*replacer*/ undefined, " ")); }); }); } // Remove the project from pending project updates this.pendingProjectUpdates.delete(project.getProjectName()); @@ -173889,7 +174807,7 @@ var ts; // created when any of the script infos are added as root of inferred project if (this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) { // If we cannot watch config file existence without configured project, close the configured file watcher - if (!ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath))) { + if (!ts.canWatchDirectoryOrFile(ts.getDirectoryPath(canonicalConfigFilePath))) { configFileExistenceInfo.watcher.close(); configFileExistenceInfo.watcher = noopConfigFileWatcher; } @@ -173969,7 +174887,7 @@ var ts; // Set this file as the root of inferred project (configFileExistenceInfo.openFilesImpactedByConfigFile || (configFileExistenceInfo.openFilesImpactedByConfigFile = new ts.Map())).set(info.path, true); // If there is no configured project for this config file, add the file watcher - configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath)) ? + configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.canWatchDirectoryOrFile(ts.getDirectoryPath(canonicalConfigFilePath)) ? _this.watchFactory.watchFile(configFileName, function (_filename, eventKind) { return _this.onConfigFileChanged(canonicalConfigFilePath, eventKind); }, ts.PollingInterval.High, _this.hostConfiguration.watchOptions, ts.WatchType.ConfigFileForInferredRoot) : noopConfigFileWatcher); }); @@ -174071,15 +174989,15 @@ var ts; if (result !== undefined) return result || undefined; } - this.logger.info("Search path: " + ts.getDirectoryPath(info.fileName)); + this.logger.info("Search path: ".concat(ts.getDirectoryPath(info.fileName))); var configFileName = this.forEachConfigFileLocation(info, function (canonicalConfigFilePath, configFileName) { return _this.configFileExists(configFileName, canonicalConfigFilePath, info); }); if (configFileName) { - this.logger.info("For info: " + info.fileName + " :: Config file name: " + configFileName); + this.logger.info("For info: ".concat(info.fileName, " :: Config file name: ").concat(configFileName)); } else { - this.logger.info("For info: " + info.fileName + " :: No config files found."); + this.logger.info("For info: ".concat(info.fileName, " :: No config files found.")); } if (isOpenScriptInfo(info)) { this.configFileForOpenFiles.set(info.path, configFileName || false); @@ -174098,8 +175016,8 @@ var ts; this.logger.info("Open files: "); this.openFiles.forEach(function (projectRootPath, path) { var info = _this.getScriptInfoForPath(path); - _this.logger.info("\tFileName: " + info.fileName + " ProjectRootPath: " + projectRootPath); - _this.logger.info("\t\tProjects: " + info.containingProjects.map(function (p) { return p.getProjectName(); })); + _this.logger.info("\tFileName: ".concat(info.fileName, " ProjectRootPath: ").concat(projectRootPath)); + _this.logger.info("\t\tProjects: ".concat(info.containingProjects.map(function (p) { return p.getProjectName(); }))); }); this.logger.endGroup(); }; @@ -174138,7 +175056,7 @@ var ts; .map(function (name) { return ({ name: name, size: _this.host.getFileSize(name) }); }) .sort(function (a, b) { return b.size - a.size; }) .slice(0, 5); - this.logger.info("Non TS file size exceeded limit (" + totalNonTsFileSize + "). Largest files: " + top5LargestFiles.map(function (file) { return file.name + ":" + file.size; }).join(", ")); + this.logger.info("Non TS file size exceeded limit (".concat(totalNonTsFileSize, "). Largest files: ").concat(top5LargestFiles.map(function (file) { return "".concat(file.name, ":").concat(file.size); }).join(", "))); // Keep the size as zero since it's disabled return fileName; } @@ -174207,8 +175125,8 @@ var ts; }; /* @internal */ ProjectService.prototype.createConfiguredProject = function (configFileName) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "createConfiguredProject", { configFilePath: configFileName }); - this.logger.info("Creating configuration project " + configFileName); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "createConfiguredProject", { configFilePath: configFileName }); + this.logger.info("Creating configuration project ".concat(configFileName)); var canonicalConfigFilePath = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); // We could be in this scenario if project is the configured project tracked by external project @@ -174256,7 +175174,7 @@ var ts; /* @internal */ ProjectService.prototype.loadConfiguredProject = function (project, reason) { var _this = this; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath }); this.sendProjectLoadingStartEvent(project, reason); // Read updated contents from disk var configFilename = server.asNormalizedPath(ts.normalizePath(project.getConfigFilePath())); @@ -174321,12 +175239,12 @@ var ts; if (parsedCommandLine.errors.length) { configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); } - this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ + this.logger.info("Config: ".concat(configFilename, " : ").concat(JSON.stringify({ rootNames: parsedCommandLine.fileNames, options: parsedCommandLine.options, watchOptions: parsedCommandLine.watchOptions, projectReferences: parsedCommandLine.projectReferences - }, /*replacer*/ undefined, " ")); + }, /*replacer*/ undefined, " "))); var oldCommandLine = (_b = configFileExistenceInfo.config) === null || _b === void 0 ? void 0 : _b.parsedCommandLine; if (!configFileExistenceInfo.config) { configFileExistenceInfo.config = { parsedCommandLine: parsedCommandLine, cachedDirectoryStructureHost: cachedDirectoryStructureHost, projects: new ts.Map() }; @@ -174356,7 +175274,7 @@ var ts; // Update projects var ensureProjectsForOpenFiles = false; (_a = _this.sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (canonicalPath) { - ensureProjectsForOpenFiles = _this.delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalPath, "Change in extended config file " + extendedConfigFileName + " detected") || ensureProjectsForOpenFiles; + ensureProjectsForOpenFiles = _this.delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalPath, "Change in extended config file ".concat(extendedConfigFileName, " detected")) || ensureProjectsForOpenFiles; }); if (ensureProjectsForOpenFiles) _this.delayEnsureProjectForOpenFiles(); @@ -174512,7 +175430,7 @@ var ts; // Clear the cache since we are reloading the project from disk host.clearCache(); var configFileName = project.getConfigFilePath(); - this.logger.info((isInitialLoad ? "Loading" : "Reloading") + " configured project " + configFileName); + this.logger.info("".concat(isInitialLoad ? "Loading" : "Reloading", " configured project ").concat(configFileName)); // Load project from the disk this.loadConfiguredProject(project, reason); project.updateGraph(); @@ -174651,7 +175569,7 @@ var ts; var path = _a[0], scriptInfo = _a[1]; return ({ path: path, fileName: scriptInfo.fileName }); }); - this.logger.msg("Could not find file " + JSON.stringify(fileName) + ".\nAll files are: " + JSON.stringify(names), server.Msg.Err); + this.logger.msg("Could not find file ".concat(JSON.stringify(fileName), ".\nAll files are: ").concat(JSON.stringify(names)), server.Msg.Err); }; /** * Returns the projects that contain script info through SymLink @@ -174744,7 +175662,7 @@ var ts; } } } - }, 1 /* Recursive */, this.hostConfiguration.watchOptions, ts.WatchType.NodeModules); + }, 1 /* WatchDirectoryFlags.Recursive */, this.hostConfiguration.watchOptions, ts.WatchType.NodeModules); var result = { refreshScriptInfoRefCount: 0, affectedModuleSpecifierCacheProjects: undefined, @@ -174835,9 +175753,9 @@ var ts; var info = this.getScriptInfoForPath(path); if (!info) { var isDynamic = server.isDynamicFileName(fileName); - ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"; }); - ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"; }); - ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory || this.useInferredProjectPerProjectRoot, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nDynamic files must always be opened with service's current directory or service should support inferred project per projectRootPath."; }); + ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"); }); + ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"); }); + ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory || this.useInferredProjectPerProjectRoot, "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nDynamic files must always be opened with service's current directory or service should support inferred project per projectRootPath."); }); // If the file is not opened by client and the file doesnot exist on the disk, return if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) { return; @@ -175016,13 +175934,13 @@ var ts; var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); if (info) { info.setOptions(convertFormatOptions(args.formatOptions), args.preferences); - this.logger.info("Host configuration update for file " + args.file); + this.logger.info("Host configuration update for file ".concat(args.file)); } } else { if (args.hostInfo !== undefined) { this.hostConfiguration.hostInfo = args.hostInfo; - this.logger.info("Host information " + args.hostInfo); + this.logger.info("Host information ".concat(args.hostInfo)); } if (args.formatOptions) { this.hostConfiguration.formatCodeOptions = __assign(__assign({}, this.hostConfiguration.formatCodeOptions), convertFormatOptions(args.formatOptions)); @@ -175054,7 +175972,7 @@ var ts; } if (args.watchOptions) { this.hostConfiguration.watchOptions = (_a = convertWatchOptions(args.watchOptions)) === null || _a === void 0 ? void 0 : _a.watchOptions; - this.logger.info("Host watch options changed to " + JSON.stringify(this.hostConfiguration.watchOptions) + ", it will be take effect for next watches."); + this.logger.info("Host watch options changed to ".concat(JSON.stringify(this.hostConfiguration.watchOptions), ", it will be take effect for next watches.")); } } }; @@ -175266,7 +176184,7 @@ var ts; ? originalLocation : location; } - configuredProject = this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + configuredProject = this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: ".concat(originalFileInfo.fileName).concat(location !== originalLocation ? " for location: " + location.fileName : "")); } updateProjectIfDirty(configuredProject); var projectContainsOriginalInfo = function (project) { @@ -175278,7 +176196,7 @@ var ts; configuredProject = forEachResolvedProjectReferenceProject(configuredProject, fileName, function (child) { updateProjectIfDirty(child); return projectContainsOriginalInfo(child) ? child : undefined; - }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution " + configuredProject.projectName + " to find possible configured project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution ".concat(configuredProject.projectName, " to find possible configured project for original file: ").concat(originalFileInfo.fileName).concat(location !== originalLocation ? " for location: " + location.fileName : "")); if (!configuredProject) return undefined; if (configuredProject === project) @@ -175332,7 +176250,7 @@ var ts; if (configFileName) { project = this.findConfiguredProjectByProjectName(configFileName); if (!project) { - project = this.createLoadAndUpdateConfiguredProject(configFileName, "Creating possible configured project for " + info.fileName + " to open"); + project = this.createLoadAndUpdateConfiguredProject(configFileName, "Creating possible configured project for ".concat(info.fileName, " to open")); defaultConfigProjectIsCreated = true; } else { @@ -175362,7 +176280,7 @@ var ts; if (!projectForConfigFileDiag && child.containsScriptInfo(info)) { projectForConfigFileDiag = child; } - }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution " + project.projectName + " to find possible configured project for " + info.fileName + " to open"); + }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution ".concat(project.projectName, " to find possible configured project for ").concat(info.fileName, " to open")); } // Send the event only if the project got created as part of this open request and info is part of the project if (projectForConfigFileDiag) { @@ -175424,7 +176342,7 @@ var ts; return; // find or delay load the project var ancestor = this.findConfiguredProjectByProjectName(configFileName) || - this.createConfiguredProjectWithDelayLoad(configFileName, "Creating project possibly referencing default composite project " + project.getProjectName() + " of open file " + info.fileName); + this.createConfiguredProjectWithDelayLoad(configFileName, "Creating project possibly referencing default composite project ".concat(project.getProjectName(), " of open file ").concat(info.fileName)); if (ancestor.isInitialLoadPending()) { // Set a potential project reference ancestor.setPotentialProjectReference(project.canonicalConfigFilePath); @@ -175467,7 +176385,7 @@ var ts; // Load this project, var configFileName = server.toNormalizedPath(child.sourceFile.fileName); var childProject = project.projectService.findConfiguredProjectByProjectName(configFileName) || - project.projectService.createAndLoadConfiguredProject(configFileName, "Creating project referenced by : " + project.projectName + " as it references project " + referencedProject.sourceFile.fileName); + project.projectService.createAndLoadConfiguredProject(configFileName, "Creating project referenced by : ".concat(project.projectName, " as it references project ").concat(referencedProject.sourceFile.fileName)); updateProjectIfDirty(childProject); // Ensure children for this project this.ensureProjectChildren(childProject, forProjects, seenProjects); @@ -175768,7 +176686,7 @@ var ts; for (var _b = 0, normalizedNames_1 = normalizedNames; _b < normalizedNames_1.length; _b++) { var root = normalizedNames_1[_b]; if (rule.match.test(root)) { - this_3.logger.info("Excluding files based on rule " + name + " matching file '" + root + "'"); + this_3.logger.info("Excluding files based on rule ".concat(name, " matching file '").concat(root, "'")); // If the file matches, collect its types packages and exclude rules if (rule.types) { for (var _c = 0, _d = rule.types; _c < _d.length; _c++) { @@ -175793,7 +176711,7 @@ var ts; if (typeof groupNumberOrString === "number") { if (!ts.isString(groups[groupNumberOrString])) { // Specification was wrong - exclude nothing! - _this.logger.info("Incorrect RegExp specification in safelist rule " + name + " - not enough groups"); + _this.logger.info("Incorrect RegExp specification in safelist rule ".concat(name, " - not enough groups")); // * can't appear in a filename; escape it because it's feeding into a RegExp return "\\*"; } @@ -175841,7 +176759,7 @@ var ts; var cleanedTypingName = ts.removeMinAndVersionNumbers(inferredTypingName); var typeName = this_4.legacySafelist.get(cleanedTypingName); if (typeName !== undefined) { - this_4.logger.info("Excluded '" + normalizedNames[i] + "' because it matched " + cleanedTypingName + " from the legacy safelist"); + this_4.logger.info("Excluded '".concat(normalizedNames[i], "' because it matched ").concat(cleanedTypingName, " from the legacy safelist")); excludedFiles.push(normalizedNames[i]); // *exclude* it from the project... exclude = true; @@ -175971,8 +176889,8 @@ var ts; if (!project) { // errors are stored in the project, do not need to update the graph project = this.getHostPreferences().lazyConfiguredProjectsFromExternalProject ? - this.createConfiguredProjectWithDelayLoad(tsconfigFile, "Creating configured project in external project: " + proj.projectFileName) : - this.createLoadAndUpdateConfiguredProject(tsconfigFile, "Creating configured project in external project: " + proj.projectFileName); + this.createConfiguredProjectWithDelayLoad(tsconfigFile, "Creating configured project in external project: ".concat(proj.projectFileName)) : + this.createLoadAndUpdateConfiguredProject(tsconfigFile, "Creating configured project in external project: ".concat(proj.projectFileName)); } if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { // keep project alive even if no documents are opened - its lifetime is bound to the lifetime of containing external project @@ -175992,7 +176910,7 @@ var ts; ProjectService.prototype.hasDeferredExtension = function () { for (var _i = 0, _a = this.hostConfiguration.extraFileExtensions; _i < _a.length; _i++) { // TODO: GH#18217 var extension = _a[_i]; - if (extension.scriptKind === 7 /* Deferred */) { + if (extension.scriptKind === 7 /* ScriptKind.Deferred */) { return true; } } @@ -176005,9 +176923,9 @@ var ts; this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); return; } - this.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); + this.logger.info("Enabling plugin ".concat(pluginConfigEntry.name, " from candidate paths: ").concat(searchPaths.join(","))); if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) { - this.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name"); + this.logger.info("Skipped loading plugin ".concat(pluginConfigEntry.name || JSON.stringify(pluginConfigEntry), " because only package name is allowed plugin name")); return; } // If the host supports dynamic import, begin enabling the plugin asynchronously. @@ -176157,11 +177075,11 @@ var ts; var processDirectory = function (directory) { switch (packageJsonCache.directoryHasPackageJson(directory)) { // Sync and check same directory again - case 3 /* Maybe */: + case 3 /* Ternary.Maybe */: packageJsonCache.searchDirectoryAndAncestors(directory); return processDirectory(directory); // Check package.json - case -1 /* True */: + case -1 /* Ternary.True */: var packageJsonFileName = ts.combinePaths(directory, "package.json"); _this.watchPackageJsonFile(packageJsonFileName); var info = packageJsonCache.getInDirectory(directory); @@ -176180,9 +177098,9 @@ var ts; var _this = this; return ts.forEachAncestorDirectory(fileName, function (directory) { switch (_this.packageJsonCache.directoryHasPackageJson(_this.toPath(directory))) { - case -1 /* True */: return directory; - case 0 /* False */: return undefined; - case 3 /* Maybe */: + case -1 /* Ternary.True */: return directory; + case 0 /* Ternary.False */: return undefined; + case 3 /* Ternary.Maybe */: return _this.host.fileExists(ts.combinePaths(directory, "package.json")) ? directory : undefined; @@ -176221,9 +177139,9 @@ var ts; /*@internal*/ ProjectService.prototype.includePackageJsonAutoImports = function () { switch (this.hostConfiguration.preferences.includePackageJsonAutoImports) { - case "on": return 1 /* On */; - case "off": return 0 /* Off */; - default: return 2 /* Auto */; + case "on": return 1 /* PackageJsonAutoImportPreference.On */; + case "off": return 0 /* PackageJsonAutoImportPreference.Off */; + default: return 2 /* PackageJsonAutoImportPreference.Auto */; } }; /*@internal*/ @@ -176351,7 +177269,7 @@ var ts; return cache || (cache = new ts.Map()); } function key(fromFileName, preferences, options) { - return fromFileName + "," + preferences.importModuleSpecifierEnding + "," + preferences.importModuleSpecifierPreference + "," + options.overrideImportMode; + return "".concat(fromFileName, ",").concat(preferences.importModuleSpecifierEnding, ",").concat(preferences.importModuleSpecifierPreference, ",").concat(options.overrideImportMode); } function createInfo(modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies) { return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isBlockedByPackageJsonDependencies: isBlockedByPackageJsonDependencies }; @@ -176382,7 +177300,7 @@ var ts; directoryHasPackageJson: directoryHasPackageJson, searchDirectoryAndAncestors: function (directory) { ts.forEachAncestorDirectory(directory, function (ancestor) { - if (directoryHasPackageJson(ancestor) !== 3 /* Maybe */) { + if (directoryHasPackageJson(ancestor) !== 3 /* Ternary.Maybe */) { return true; } var packageJsonFileName = host.toPath(ts.combinePaths(ancestor, "package.json")); @@ -176401,9 +177319,9 @@ var ts; directoriesWithoutPackageJson.delete(ts.getDirectoryPath(fileName)); } function directoryHasPackageJson(directory) { - return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* True */ : - directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : - 3 /* Maybe */; + return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* Ternary.True */ : + directoriesWithoutPackageJson.has(directory) ? 0 /* Ternary.False */ : + 3 /* Ternary.Maybe */; } } server.createPackageJsonCache = createPackageJsonCache; @@ -176510,10 +177428,10 @@ var ts; var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); if (verboseLogging) { - logger.info(msg.type + ":" + server.indent(json)); + logger.info("".concat(msg.type, ":").concat(server.indent(json))); } var len = byteLength(json, "utf8"); - return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; + return "Content-Length: ".concat(1 + len, "\r\n\r\n").concat(json).concat(newLine); } server.formatMessage = formatMessage; /** @@ -176560,10 +177478,10 @@ var ts; try { if (this.operationHost.isCancellationRequested()) { stop = true; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepCanceled", { seq: this.requestId, early: true }); } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "stepAction", { seq: this.requestId }); action(this); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -176574,11 +177492,11 @@ var ts; stop = true; // ignore cancellation request if (e instanceof ts.OperationCanceledException) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepCanceled", { seq: this.requestId }); } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepError", { seq: this.requestId, message: e.message }); - this.operationHost.logError(e, "delayed processing of request " + this.requestId); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepError", { seq: this.requestId, message: e.message }); + this.operationHost.logError(e, "delayed processing of request ".concat(this.requestId)); } } if (stop || !this.hasPendingWork()) { @@ -176657,13 +177575,15 @@ var ts; function getDefinitionLocation(defaultProject, initialLocation, isForRename) { var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, /*stopAtAlias*/ isForRename); var info = infos && ts.firstOrUndefined(infos); + // Note that the value of `isLocal` may depend on whether or not the checker has run on the containing file + // (implying that FAR cascading behavior may depend on request order) return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined; } function getReferencesWorker(projects, defaultProject, initialLocation, logger) { var _a, _b; var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation, /*isForRename*/ false, function (project, position) { - logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName()); + logger.info("Finding references to ".concat(position.fileName, " position ").concat(position.pos, " in project ").concat(project.getProjectName())); return project.getLanguageService().findReferences(position.fileName, position.pos); }, function (referencedSymbol, cb) { cb(documentSpanLocation(referencedSymbol.definition)); @@ -176796,16 +177716,16 @@ var ts; function getPerProjectReferences(projects, defaultProject, initialLocation, isForRename, getResultsForPosition, forPositionInResult) { // If `getResultsForPosition` returns results for a project, they go in here var resultsMap = new ts.Map(); - var queue = []; + var queue = ts.createQueue(); // In order to get accurate isDefinition values for `defaultProject`, // we need to ensure that it is searched from `initialLocation`. // The easiest way to do this is to search it first. - queue.push({ project: defaultProject, location: initialLocation }); + queue.enqueue({ project: defaultProject, location: initialLocation }); // This will queue `defaultProject` a second time, but it will be dropped // as a dup when it is dequeued. forEachProjectInProjects(projects, initialLocation.fileName, function (project, path) { var location = { fileName: path, pos: initialLocation.pos }; - queue.push({ project: project, location: location }); + queue.enqueue({ project: project, location: location }); }); var projectService = defaultProject.projectService; var cancellationToken = defaultProject.getCancellationToken(); @@ -176820,22 +177740,13 @@ var ts; // The keys of resultsMap allow us to check which projects have already been searched, but we also // maintain a set of strings because that's what `loadAncestorProjectTree` wants. var searchedProjectKeys = new ts.Set(); - onCancellation: while (queue.length) { - while (queue.length) { + onCancellation: while (!queue.isEmpty()) { + while (!queue.isEmpty()) { if (cancellationToken.isCancellationRequested()) break onCancellation; - var skipCount = 0; - for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++) - ; - if (skipCount === queue.length) { - queue.length = 0; - break; - } - if (skipCount > 0) { - queue.splice(0, skipCount); - } - // NB: we may still skip if it's a project reference redirect - var _a = queue.shift(), project = _a.project, location = _a.location; + var _a = queue.dequeue(), project = _a.project, location = _a.location; + if (resultsMap.has(project)) + continue; if (isLocationProjectReferenceRedirect(project, location)) continue; var projectResults = searchPosition(project, location); @@ -176856,7 +177767,7 @@ var ts; return; // Can loop forever without this (enqueue here, dequeue above, repeat) var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition); if (location) { - queue.push({ project: project, location: location }); + queue.enqueue({ project: project, location: location }); } }); } @@ -176884,7 +177795,7 @@ var ts; for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) { var project_1 = _a[_i]; if (!project_1.isOrphan() && !resultsMap.has(project_1)) { // Optimization: don't enqueue if will be discarded - queue.push({ project: project_1, location: originalLocation }); + queue.enqueue({ project: project_1, location: originalLocation }); } } var symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo); @@ -176893,7 +177804,7 @@ var ts; for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) { var symlinkedProject = symlinkedProjects_2[_i]; if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded - queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } }); + queue.enqueue({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } }); } } }); @@ -177447,14 +178358,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidPartialSemanticModeCommands.forEach(function (commandName) { return _this.handlers.set(commandName, function (request) { - throw new Error("Request: " + request.command + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("Request: ".concat(request.command, " not allowed in LanguageServiceMode.PartialSemantic")); }); }); break; case ts.LanguageServiceMode.Syntactic: invalidSyntacticModeCommands.forEach(function (commandName) { return _this.handlers.set(commandName, function (request) { - throw new Error("Request: " + request.command + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("Request: ".concat(request.command, " not allowed in LanguageServiceMode.Syntactic")); }); }); break; @@ -177529,7 +178440,7 @@ var ts; }; Session.prototype.projectsUpdatedInBackgroundEvent = function (openFiles) { var _this = this; - this.projectService.logger.info("got projects updated in background, updating diagnostics for " + openFiles); + this.projectService.logger.info("got projects updated in background, updating diagnostics for ".concat(openFiles)); if (openFiles.length) { if (!this.suppressDiagnosticEvents && !this.noGetErrOnBackgroundUpdate) { // For now only queue error checking for open files. We can change this to include non open files as well @@ -177559,17 +178470,17 @@ var ts; var scriptInfo = project.getScriptInfoForNormalizedPath(file); if (scriptInfo) { var text = ts.getSnapshotText(scriptInfo.getSnapshot()); - msg += "\n\nFile text of " + fileRequest.file + ":" + server.indent(text) + "\n"; + msg += "\n\nFile text of ".concat(fileRequest.file, ":").concat(server.indent(text), "\n"); } } catch (_b) { } // eslint-disable-line no-empty } if (err.ProgramFiles) { - msg += "\n\nProgram files: " + JSON.stringify(err.ProgramFiles) + "\n"; + msg += "\n\nProgram files: ".concat(JSON.stringify(err.ProgramFiles), "\n"); msg += "\n\nProjects::\n"; var counter_1 = 0; var addProjectInfo = function (project) { - msg += "\nProject '" + project.projectName + "' (" + server.ProjectKind[project.projectKind] + ") " + counter_1 + "\n"; + msg += "\nProject '".concat(project.projectName, "' (").concat(server.ProjectKind[project.projectKind], ") ").concat(counter_1, "\n"); msg += project.filesToString(/*writeProjectFileNames*/ true); msg += "\n-----------------------------------------------\n"; counter_1++; @@ -177584,7 +178495,7 @@ var ts; Session.prototype.send = function (msg) { if (msg.type === "event" && !this.canUseEvents) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + this.logger.info("Session does not support events: ignored event: ".concat(JSON.stringify(msg))); } return; } @@ -177592,7 +178503,7 @@ var ts; }; Session.prototype.writeMessage = function (msg) { var msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine); - ts.perfLogger.logEvent("Response message size: " + msgText.length); + ts.perfLogger.logEvent("Response message size: ".concat(msgText.length)); this.host.write(msgText); }; Session.prototype.event = function (body, eventName) { @@ -177644,7 +178555,7 @@ var ts; this.send(res); }; Session.prototype.semanticCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "semanticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "semanticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails var diags = isDeclarationFileInJSOnlyNonConfiguredProject(project, file) ? server.emptyArray : project.getLanguageService().getSemanticDiagnostics(file).filter(function (d) { return !!d.file; }); @@ -177652,12 +178563,12 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; Session.prototype.syntacticCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "syntacticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "syntacticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSyntacticDiagnostics(file), "syntaxDiag"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; Session.prototype.suggestionCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "suggestionCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "suggestionCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; @@ -177735,7 +178646,7 @@ var ts; if (!projects) { return; } - this.logger.info("cleaning " + caption); + this.logger.info("cleaning ".concat(caption)); for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { var p = projects_4[_i]; p.getLanguageService(/*ensureSynchronized*/ false).cleanupSemanticCache(); @@ -177756,7 +178667,7 @@ var ts; }; Session.prototype.getEncodedSemanticClassifications = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var format = args.format === "2020" ? "2020" /* TwentyTwenty */ : "original" /* Original */; + var format = args.format === "2020" ? "2020" /* SemanticClassificationFormat.TwentyTwenty */ : "original" /* SemanticClassificationFormat.Original */; return project.getLanguageService().getEncodedSemanticClassifications(file, args, format); }; Session.prototype.getProject = function (projectFileName) { @@ -177923,7 +178834,7 @@ var ts; var packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex); var packageJsonCache = (_a = project.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache(); var compilerOptions = project.getCompilationSettings(); - var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions); + var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), ts.getTemporaryModuleResolutionState(packageJsonCache, project, compilerOptions)); if (!packageJson) return undefined; // Use fake options instead of actual compiler options to avoid following export map if the project uses node16 or nodenext - @@ -177943,7 +178854,7 @@ var ts; else { // It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package. var pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1); - var specifier = packageName + "/" + ts.removeFileExtension(pathToFileInPackage); + var specifier = "".concat(packageName, "/").concat(ts.removeFileExtension(pathToFileInPackage)); var implementationResolution = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile)[0]; return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName; } @@ -177982,7 +178893,7 @@ var ts; } var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position); var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode); - var importSpecifier = symbol && ts.getDeclarationOfKind(symbol, 270 /* ImportSpecifier */); + var importSpecifier = symbol && ts.getDeclarationOfKind(symbol, 270 /* SyntaxKind.ImportSpecifier */); if (!importSpecifier) return undefined; var nameToSearch = ((_a = importSpecifier.propertyName) === null || _a === void 0 ? void 0 : _a.text) || importSpecifier.name.text; @@ -178313,7 +179224,7 @@ var ts; var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); }); return { refs: refs, - symbolName: "\"" + args.file + "\"" + symbolName: "\"".concat(args.file, "\"") }; }; /** @@ -178514,7 +179425,7 @@ var ts; var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, triggerKind: args.triggerKind, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions }), project.projectService.getFormatCodeOptions(file)); if (completions === undefined) return undefined; - if (kind === "completions-full" /* CompletionsFull */) + if (kind === "completions-full" /* protocol.CommandTypes.CompletionsFull */) return completions; var prefix = args.prefix || ""; var entries = ts.mapDefined(completions.entries, function (entry) { @@ -178541,7 +179452,7 @@ var ts; }; } }); - if (kind === "completions" /* Completions */) { + if (kind === "completions" /* protocol.CommandTypes.Completions */) { if (completions.metadata) entries.metadata = completions.metadata; return entries; @@ -178941,7 +179852,7 @@ var ts; }); var badCode = args.errorCodes.find(function (c) { return !existingDiagCodes_1.includes(c); }); if (badCode !== undefined) { - e.message = "BADCLIENT: Bad error code, " + badCode + " not found in range " + startPosition + ".." + endPosition + " (found: " + existingDiagCodes_1.join(", ") + "); could have caused this error:\n" + e.message; + e.message = "BADCLIENT: Bad error code, ".concat(badCode, " not found in range ").concat(startPosition, "..").concat(endPosition, " (found: ").concat(existingDiagCodes_1.join(", "), "); could have caused this error:\n").concat(e.message); } throw e; } @@ -179218,7 +180129,7 @@ var ts; }; Session.prototype.addProtocolHandler = function (command, handler) { if (this.handlers.has(command)) { - throw new Error("Protocol handler already exists for command \"" + command + "\""); + throw new Error("Protocol handler already exists for command \"".concat(command, "\"")); } this.handlers.set(command, handler); }; @@ -179249,8 +180160,8 @@ var ts; return response; } else { - this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err); - this.doOutput(/*info*/ undefined, server.CommandNames.Unknown, request.seq, /*success*/ false, "Unrecognized JSON command: " + request.command); + this.logger.msg("Unrecognized JSON command:".concat(server.stringifyIndented(request)), server.Msg.Err); + this.doOutput(/*info*/ undefined, server.CommandNames.Unknown, request.seq, /*success*/ false, "Unrecognized JSON command: ".concat(request.command)); return { responseRequired: false }; } }; @@ -179261,7 +180172,7 @@ var ts; if (this.logger.hasLevel(server.LogLevel.requestTime)) { start = this.hrtime(); if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("request:" + server.indent(this.toStringMessage(message))); + this.logger.info("request:".concat(server.indent(this.toStringMessage(message)))); } } var request; @@ -179269,23 +180180,23 @@ var ts; try { request = this.parseMessage(message); relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "request", { seq: request.seq, command: request.command }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "request", { seq: request.seq, command: request.command }); ts.perfLogger.logStartCommand("" + request.command, this.toStringMessage(message).substring(0, 100)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (this.logger.hasLevel(server.LogLevel.requestTime)) { var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); if (responseRequired) { - this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); + this.logger.perftrc("".concat(request.seq, "::").concat(request.command, ": elapsed time (in milliseconds) ").concat(elapsedTime)); } else { - this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); + this.logger.perftrc("".concat(request.seq, "::").concat(request.command, ": async elapsed time (in milliseconds) ").concat(elapsedTime)); } } // Note: Log before writing the response, else the editor can complete its activity before the server does ts.perfLogger.logStopCommand("" + request.command, "Success"); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "response", { seq: request.seq, command: request.command, success: !!response }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "response", { seq: request.seq, command: request.command, success: !!response }); if (response) { this.doOutput(response, request.command, request.seq, /*success*/ true); } @@ -179299,13 +180210,13 @@ var ts; if (err instanceof ts.OperationCanceledException) { // Handle cancellation exceptions ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "commandCanceled", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "commandCanceled", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command }); this.doOutput({ canceled: true }, request.command, request.seq, /*success*/ true); return; } this.logErrorWorker(err, this.toStringMessage(message), relevantFile); ts.perfLogger.logStopCommand("" + (request && request.command), "Error: " + err); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "commandError", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command, message: err.message }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "commandError", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command, message: err.message }); this.doOutput( /*info*/ undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, /*success*/ false, "Error processing request. " + err.message + "\n" + err.stack); @@ -179416,7 +180327,7 @@ var ts; this.goSubtree = true; this.lineIndex = new LineIndex(); this.endBranch = []; - this.state = 2 /* Entire */; + this.state = 2 /* CharRangeSection.Entire */; this.initialText = ""; this.trailingText = ""; this.lineIndex.root = new LineNode(); @@ -179507,7 +180418,7 @@ var ts; // have visited the path for start of range, now looking for end // if range is on single line, we will never make this state transition if (lineCollection === this.lineCollectionAtBranch) { - this.state = 4 /* End */; + this.state = 4 /* CharRangeSection.End */; } // always pop stack because post only called when child has been visited this.stack.pop(); @@ -179515,9 +180426,9 @@ var ts; EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { // currentNode corresponds to parent, but in the new tree var currentNode = this.stack[this.stack.length - 1]; - if ((this.state === 2 /* Entire */) && (nodeType === 1 /* Start */)) { + if ((this.state === 2 /* CharRangeSection.Entire */) && (nodeType === 1 /* CharRangeSection.Start */)) { // if range is on single line, we will never make this state transition - this.state = 1 /* Start */; + this.state = 1 /* CharRangeSection.Start */; this.branchNode = currentNode; this.lineCollectionAtBranch = lineCollection; } @@ -179530,14 +180441,14 @@ var ts; return new LineNode(); } switch (nodeType) { - case 0 /* PreStart */: + case 0 /* CharRangeSection.PreStart */: this.goSubtree = false; - if (this.state !== 4 /* End */) { + if (this.state !== 4 /* CharRangeSection.End */) { currentNode.add(lineCollection); } break; - case 1 /* Start */: - if (this.state === 4 /* End */) { + case 1 /* CharRangeSection.Start */: + if (this.state === 4 /* CharRangeSection.End */) { this.goSubtree = false; } else { @@ -179546,8 +180457,8 @@ var ts; this.startPath.push(child); } break; - case 2 /* Entire */: - if (this.state !== 4 /* End */) { + case 2 /* CharRangeSection.Entire */: + if (this.state !== 4 /* CharRangeSection.End */) { child = fresh(lineCollection); currentNode.add(child); this.startPath.push(child); @@ -179560,11 +180471,11 @@ var ts; } } break; - case 3 /* Mid */: + case 3 /* CharRangeSection.Mid */: this.goSubtree = false; break; - case 4 /* End */: - if (this.state !== 4 /* End */) { + case 4 /* CharRangeSection.End */: + if (this.state !== 4 /* CharRangeSection.End */) { this.goSubtree = false; } else { @@ -179575,9 +180486,9 @@ var ts; } } break; - case 5 /* PostEnd */: + case 5 /* CharRangeSection.PostEnd */: this.goSubtree = false; - if (this.state !== 1 /* Start */) { + if (this.state !== 1 /* CharRangeSection.Start */) { currentNode.add(lineCollection); } break; @@ -179588,10 +180499,10 @@ var ts; }; // just gather text from the leaves EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === 1 /* Start */) { + if (this.state === 1 /* CharRangeSection.Start */) { this.initialText = ll.text.substring(0, relativeStart); } - else if (this.state === 2 /* Entire */) { + else if (this.state === 2 /* CharRangeSection.Entire */) { this.initialText = ll.text.substring(0, relativeStart); this.trailingText = ll.text.substring(relativeStart + relativeLength); } @@ -179949,20 +180860,20 @@ var ts; // find sub-tree containing start var adjustedStart = rangeStart; while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0 /* PreStart */); + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0 /* CharRangeSection.PreStart */); adjustedStart -= childCharCount; childIndex++; childCharCount = this.children[childIndex].charCount(); } // Case I: both start and end of range in same subtree if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2 /* Entire */)) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2 /* CharRangeSection.Entire */)) { return; } } else { // Case II: start and end of range in different subtrees (possibly with subtrees in the middle) - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1 /* Start */)) { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1 /* CharRangeSection.Start */)) { return; } var adjustedLength = rangeLength - (childCharCount - adjustedStart); @@ -179970,7 +180881,7 @@ var ts; var child = this.children[childIndex]; childCharCount = child.charCount(); while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, 3 /* Mid */)) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, 3 /* CharRangeSection.Mid */)) { return; } adjustedLength -= childCharCount; @@ -179978,7 +180889,7 @@ var ts; childCharCount = this.children[childIndex].charCount(); } if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4 /* End */)) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4 /* CharRangeSection.End */)) { return; } } @@ -179988,7 +180899,7 @@ var ts; var clen = this.children.length; if (childIndex < (clen - 1)) { for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, 5 /* PostEnd */); + this.skipChild(0, 0, ej, walkFns, 5 /* CharRangeSection.PostEnd */); } } } @@ -180218,7 +181129,7 @@ var ts; } if (!this.canWrite()) return; - s = "[" + server.nowString() + "] " + s + "\n"; + s = "[".concat(server.nowString(), "] ").concat(s, "\n"); if (!this.inGroup || this.firstInGroup) { var prefix = BaseLogger.padStringRight(type + " " + this.seq.toString(), " "); s = prefix + s; @@ -180393,12 +181304,12 @@ var ts; WorkerSession.prototype.send = function (msg) { if (msg.type === "event" && !this.canUseEvents) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + this.logger.info("Session does not support events: ignored event: ".concat(JSON.stringify(msg))); } return; } if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info(msg.type + ":" + server.indent(JSON.stringify(msg))); + this.logger.info("".concat(msg.type, ":").concat(server.indent(JSON.stringify(msg)))); } this.webHost.writeMessage(msg); }; @@ -180433,7 +181344,7 @@ var ts; for (var _i = 0, _a = Object.keys(deprecations); _i < _a.length; _i++) { var key = _a[_i]; var index = +key; - if (!isNaN(index) && ts.hasProperty(overloads, "" + index)) { + if (!isNaN(index) && ts.hasProperty(overloads, "".concat(index))) { overloads[index] = ts.Debug.deprecate(overloads[index], __assign(__assign({}, deprecations[index]), { name: name })); } } @@ -180456,7 +181367,7 @@ var ts; ts.createOverload = createOverload; function createBinder(overloads, binder) { return function (args) { - for (var i = 0; ts.hasProperty(overloads, "" + i) && ts.hasProperty(binder, "" + i); i++) { + for (var i = 0; ts.hasProperty(overloads, "".concat(i)) && ts.hasProperty(binder, "".concat(i)); i++) { var fn = binder[i]; if (fn(args)) { return i; @@ -181107,11 +182018,11 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic)` or the factory supplied by your transformation context instead. */ ts.createOptimisticUniqueName = ts.Debug.deprecate(function createOptimisticUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */); }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel)` or the factory supplied by your transformation context instead. */ ts.createFileLevelUniqueName = ts.Debug.deprecate(function createFileLevelUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */ | 32 /* FileLevel */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); }, factoryDeprecation); /** @deprecated Use `factory.createIndexSignature` or the factory supplied by your transformation context instead. */ ts.createIndexSignature = ts.Debug.deprecate(function createIndexSignature(decorators, modifiers, parameters, type) { @@ -181158,7 +182069,7 @@ var ts; } else { type = operatorOrType; - operator = 140 /* KeyOfKeyword */; + operator = 140 /* SyntaxKind.KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -181195,7 +182106,7 @@ var ts; /** @deprecated Use `factory.createConditional` or the factory supplied by your transformation context instead. */ ts.createConditional = ts.Debug.deprecate(function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { return arguments.length === 5 ? ts.factory.createConditionalExpression(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) : - arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* ColonToken */), whenTrueOrWhenFalse) : + arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* SyntaxKind.QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* SyntaxKind.ColonToken */), whenTrueOrWhenFalse) : ts.Debug.fail("Argument count mismatch"); }, factoryDeprecation); /** @deprecated Use `factory.createYield` or the factory supplied by your transformation context instead. */ @@ -181336,9 +182247,9 @@ var ts; ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) { if (pos === void 0) { pos = 0; } if (end === void 0) { end = 0; } - return ts.setTextRangePosEnd(kind === 305 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 80 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 305 /* SyntaxKind.SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* SyntaxKind.Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : !ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) : ts.parseBaseNodeFactory.createBaseNode(kind), pos, end); }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." }); @@ -181366,7 +182277,7 @@ var ts; (function (ts) { /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", @@ -182829,13 +183740,13 @@ var ts; function getEntireValue(initialIndex) { var pathStart = args[initialIndex]; var extraPartCounter = 0; - if (pathStart.charCodeAt(0) === 34 /* doubleQuote */ && - pathStart.charCodeAt(pathStart.length - 1) !== 34 /* doubleQuote */) { + if (pathStart.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */ && + pathStart.charCodeAt(pathStart.length - 1) !== 34 /* CharacterCodes.doubleQuote */) { for (var i = initialIndex + 1; i < args.length; i++) { pathStart += " "; pathStart += args[i]; extraPartCounter++; - if (pathStart.charCodeAt(pathStart.length - 1) === 34 /* doubleQuote */) + if (pathStart.charCodeAt(pathStart.length - 1) === 34 /* CharacterCodes.doubleQuote */) break; } } @@ -182922,7 +183833,7 @@ var ts; } } }; - var pending = []; + var pending = ts.createQueue(); var canWrite = true; if (useWatchGuard) { var currentDrive_1 = extractWatchDirectoryCacheKey(sys.resolvePath(sys.getCurrentDirectory()), /*currentDriveKey*/ undefined); @@ -182932,23 +183843,23 @@ var ts; var status = cacheKey && statusCache_1.get(cacheKey); if (status === undefined) { if (logger.hasLevel(server.LogLevel.verbose)) { - logger.info(cacheKey + " for path " + path + " not found in cache..."); + logger.info("".concat(cacheKey, " for path ").concat(path, " not found in cache...")); } try { var args = [ts.combinePaths(__dirname, "watchGuard.js"), path]; if (logger.hasLevel(server.LogLevel.verbose)) { - logger.info("Starting " + process.execPath + " with args:" + server.stringifyIndented(args)); + logger.info("Starting ".concat(process.execPath, " with args:").concat(server.stringifyIndented(args))); } childProcess.execFileSync(process.execPath, args, { stdio: "ignore", env: { ELECTRON_RUN_AS_NODE: "1" } }); status = true; if (logger.hasLevel(server.LogLevel.verbose)) { - logger.info("WatchGuard for path " + path + " returned: OK"); + logger.info("WatchGuard for path ".concat(path, " returned: OK")); } } catch (e) { status = false; if (logger.hasLevel(server.LogLevel.verbose)) { - logger.info("WatchGuard for path " + path + " returned: " + e.message); + logger.info("WatchGuard for path ".concat(path, " returned: ").concat(e.message)); } } if (cacheKey) { @@ -182956,7 +183867,7 @@ var ts; } } else if (logger.hasLevel(server.LogLevel.verbose)) { - logger.info("watchDirectory for " + path + " uses cached drive information."); + logger.info("watchDirectory for ".concat(path, " uses cached drive information.")); } if (status) { // this drive is safe to use - call real 'watchDirectory' @@ -183051,7 +183962,7 @@ var ts; } function writeMessage(buf) { if (!canWrite) { - pending.push(buf); + pending.enqueue(buf); } else { canWrite = false; @@ -183060,8 +183971,8 @@ var ts; } function setCanWriteFlagAndWriteMessageIfNecessary() { canWrite = true; - if (pending.length) { - writeMessage(pending.shift()); + if (!pending.isEmpty()) { + writeMessage(pending.dequeue()); } } function extractWatchDirectoryCacheKey(path, currentDriveKey) { @@ -183078,11 +183989,11 @@ var ts; // relative path - assume file is on the current drive return currentDriveKey; } - if (path.charCodeAt(1) === 58 /* colon */ && path.charCodeAt(2) === 47 /* slash */) { + if (path.charCodeAt(1) === 58 /* CharacterCodes.colon */ && path.charCodeAt(2) === 47 /* CharacterCodes.slash */) { // rooted path that starts with c:/... - extract drive letter return ts.toFileNameLowerCase(path.charAt(0)); } - if (path.charCodeAt(0) === 47 /* slash */ && path.charCodeAt(1) !== 47 /* slash */) { + if (path.charCodeAt(0) === 47 /* CharacterCodes.slash */ && path.charCodeAt(1) !== 47 /* CharacterCodes.slash */) { // rooted path that starts with slash - /somename - use key for current drive return currentDriveKey; } @@ -183090,7 +184001,7 @@ var ts; return undefined; } function isUNCPath(s) { - return s.length > 2 && s.charCodeAt(0) === 47 /* slash */ && s.charCodeAt(1) === 47 /* slash */; + return s.length > 2 && s.charCodeAt(0) === 47 /* CharacterCodes.slash */ && s.charCodeAt(1) === 47 /* CharacterCodes.slash */; } // This is the function that catches the exceptions when watching directory, and yet lets project service continue to function // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point @@ -183099,7 +184010,7 @@ var ts; return originalWatchDirectory(path, callback, recursive, options); } catch (e) { - logger.info("Exception when creating directory watcher: " + e.message); + logger.info("Exception when creating directory watcher: ".concat(e.message)); return ts.noopFileWatcher; } } @@ -183131,7 +184042,7 @@ var ts; this.validateDefaultNpmLocation = validateDefaultNpmLocation; this.event = event; this.activeRequestCount = 0; - this.requestQueue = []; + this.requestQueue = ts.createQueue(); this.requestMap = new ts.Map(); // Maps operation ID to newest requestQueue entry with that ID /** We will lazily request the types registry on the first call to `isKnownTypesPackageName` and store it in `typesRegistryCache`. */ this.requestedRegistry = false; @@ -183139,7 +184050,7 @@ var ts; NodeTypingsInstaller.prototype.isKnownTypesPackageName = function (name) { // We want to avoid looking this up in the registry as that is expensive. So first check that it's actually an NPM package. var validationResult = ts.JsTyping.validatePackageName(name); - if (validationResult !== 0 /* Ok */) { + if (validationResult !== 0 /* JsTyping.NameValidationResult.Ok */) { return false; } if (this.requestedRegistry) { @@ -183168,7 +184079,7 @@ var ts; args.push(server.Arguments.EnableTelemetry); } if (this.logger.loggingEnabled() && this.logger.getLogFileName()) { - args.push(server.Arguments.LogFile, ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-" + process.pid + ".log")); + args.push(server.Arguments.LogFile, ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-".concat(process.pid, ".log"))); } if (this.typingSafeListLocation) { args.push(server.Arguments.TypingSafeListLocation, this.typingSafeListLocation); @@ -183192,7 +184103,7 @@ var ts; var currentPort = match[2] !== undefined ? +match[2] : match[1].charAt(0) === "d" ? 5858 : 9229; - execArgv.push("--" + match[1] + "=" + (currentPort + 1)); + execArgv.push("--".concat(match[1], "=").concat(currentPort + 1)); break; } } @@ -183218,13 +184129,13 @@ var ts; var request = server.createInstallTypingsRequest(project, typeAcquisition, unresolvedImports); if (this.logger.hasLevel(server.LogLevel.verbose)) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Scheduling throttled operation:" + server.stringifyIndented(request)); + this.logger.info("Scheduling throttled operation:".concat(server.stringifyIndented(request))); } } var operationId = project.getProjectName(); var operation = function () { if (_this.logger.hasLevel(server.LogLevel.verbose)) { - _this.logger.info("Sending request:" + server.stringifyIndented(request)); + _this.logger.info("Sending request:".concat(server.stringifyIndented(request))); } _this.send(request); }; @@ -183234,15 +184145,15 @@ var ts; } else { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Deferring request for: " + operationId); + this.logger.info("Deferring request for: ".concat(operationId)); } - this.requestQueue.push(queuedRequest); + this.requestQueue.enqueue(queuedRequest); this.requestMap.set(operationId, queuedRequest); } }; NodeTypingsInstaller.prototype.handleMessage = function (response) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Received response:" + server.stringifyIndented(response)); + this.logger.info("Received response:".concat(server.stringifyIndented(response))); } switch (response.kind) { case server.EventTypesRegistry: @@ -183312,15 +184223,15 @@ var ts; else { ts.Debug.fail("Received too many responses"); } - while (this.requestQueue.length > 0) { - var queuedRequest = this.requestQueue.shift(); + while (!this.requestQueue.isEmpty()) { + var queuedRequest = this.requestQueue.dequeue(); if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { this.requestMap.delete(queuedRequest.operationId); this.scheduleRequest(queuedRequest); break; } if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Skipping defunct request for: " + queuedRequest.operationId); + this.logger.info("Skipping defunct request for: ".concat(queuedRequest.operationId)); } } this.projectService.updateTypingsForProject(response); @@ -183333,7 +184244,7 @@ var ts; }; NodeTypingsInstaller.prototype.scheduleRequest = function (request) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Scheduling request for: " + request.operationId); + this.logger.info("Scheduling request for: ".concat(request.operationId)); } this.activeRequestCount++; this.host.setTimeout(request.operation, NodeTypingsInstaller.requestDelayMillis); @@ -183381,7 +184292,7 @@ var ts; if (this.canUseEvents && this.eventPort) { if (!this.eventSocket) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("eventPort: event \"" + eventName + "\" queued, but socket not yet initialized"); + this.logger.info("eventPort: event \"".concat(eventName, "\" queued, but socket not yet initialized")); } (this.socketEventQueue || (this.socketEventQueue = [])).push({ body: body, eventName: eventName }); return; @@ -183425,7 +184336,7 @@ var ts; var verboseLogging = logger.hasLevel(server.LogLevel.verbose); if (verboseLogging) { var json = JSON.stringify(msg); - logger.info(msg.type + ":" + server.indent(json)); + logger.info("".concat(msg.type, ":").concat(server.indent(json))); } process.send(msg); }; @@ -183487,7 +184398,7 @@ var ts; return ts.combinePaths(ts.combinePaths(cacheLocation, "typescript"), ts.versionMajorMinor); } default: - return ts.Debug.fail("unsupported platform '" + process.platform + "'"); + return ts.Debug.fail("unsupported platform '".concat(process.platform, "'")); } } function getNonWindowsCacheLocation(platformIsDarwin) { @@ -183497,7 +184408,7 @@ var ts; var usersDir = platformIsDarwin ? "Users" : "home"; var homePath = (os.homedir && os.homedir()) || process.env.HOME || - ((process.env.LOGNAME || process.env.USER) && "/" + usersDir + "/" + (process.env.LOGNAME || process.env.USER)) || + ((process.env.LOGNAME || process.env.USER) && "/".concat(usersDir, "/").concat(process.env.LOGNAME || process.env.USER)) || os.tmpdir(); var cacheFolder = platformIsDarwin ? "Library/Caches" @@ -183670,10 +184581,10 @@ var ts; var args = _a.args, logger = _a.logger, cancellationToken = _a.cancellationToken, serverMode = _a.serverMode, unknownServerMode = _a.unknownServerMode, startServer = _a.startSession; var syntaxOnly = server.hasArgument("--syntaxOnly"); logger.info("Starting TS Server"); - logger.info("Version: " + ts.version); - logger.info("Arguments: " + args.join(" ")); - logger.info("Platform: " + platform + " NodeVersion: " + ts.getNodeMajorVersion() + " CaseSensitive: " + ts.sys.useCaseSensitiveFileNames); - logger.info("ServerMode: " + serverMode + " syntaxOnly: " + syntaxOnly + " hasUnknownServerMode: " + unknownServerMode); + logger.info("Version: ".concat(ts.version)); + logger.info("Arguments: ".concat(args.join(" "))); + logger.info("Platform: ".concat(platform, " NodeVersion: ").concat(ts.getNodeMajorVersion(), " CaseSensitive: ").concat(ts.sys.useCaseSensitiveFileNames)); + logger.info("ServerMode: ".concat(serverMode, " syntaxOnly: ").concat(syntaxOnly, " hasUnknownServerMode: ").concat(unknownServerMode)); ts.setStackTraceLimit(); if (ts.Debug.isDebugging) { ts.Debug.enableDebugInfo(); diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index fb15ec4f0113b..103b3664e8b14 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -2096,6 +2096,12 @@ declare namespace ts { * It is _public_ so that (pre)transformers can set this field, * since it switches the builtin `node` module transform. Generally speaking, if unset, * the field is treated as though it is `ModuleKind.CommonJS`. + * + * Note that this field is only set by the module resolution process when + * `moduleResolution` is `Node16` or `NodeNext`, which is implied by the `module` setting + * of `Node16` or `NodeNext`, respectively, but may be overriden (eg, by a `moduleResolution` + * of `node`). If so, this field will be unset and source files will be considered to be + * CommonJS-output-format by the node module transformer and type checker, regardless of extension or context. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; } @@ -2420,6 +2426,7 @@ declare namespace ts { UseAliasDefinedOutsideCurrentScope = 16384, UseSingleQuotesForStringLiteralType = 268435456, NoTypeReduction = 536870912, + OmitThisParameter = 33554432, AllowThisInObjectLiteral = 32768, AllowQualifiedNameInPlaceOfIdentifier = 65536, /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ @@ -2450,6 +2457,7 @@ declare namespace ts { UseAliasDefinedOutsideCurrentScope = 16384, UseSingleQuotesForStringLiteralType = 268435456, NoTypeReduction = 536870912, + OmitThisParameter = 33554432, AllowUniqueESSymbolType = 1048576, AddUndefined = 131072, WriteArrowStyleSignature = 262144, @@ -2458,7 +2466,7 @@ declare namespace ts { InFirstTypeArgument = 4194304, InTypeAlias = 8388608, /** @deprecated */ WriteOwnNameForAnyLike = 0, - NodeBuilderFlagsMask = 814775659 + NodeBuilderFlagsMask = 848330091 } export enum SymbolFormatFlags { None = 0, @@ -4456,6 +4464,12 @@ declare namespace ts { /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. + * + * This does *not* return type parameters from a jsdoc reference to a generic type, eg + * + * type Id = (x: T) => T + * /** @type {Id} / + * function id(x) { return x } */ function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; @@ -5405,6 +5419,10 @@ declare namespace ts { resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[]; + /** + * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + */ + getModuleResolutionCache?(): ModuleResolutionCache | undefined; } interface WatchCompilerHost extends ProgramHost, WatchHost { /** Instead of using output d.ts file from project reference, use its source file */ @@ -6884,8 +6902,8 @@ declare namespace ts { * @param version Current version of the file. Only used if the file was not found * in the registry and a new one was created. */ - acquireDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; - acquireDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; + acquireDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; + acquireDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; /** * Request an updated version of an already existing SourceFile with a given fileName * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile @@ -6901,8 +6919,8 @@ declare namespace ts { * @param scriptSnapshot Text of the file. * @param version Current version of the file. */ - updateDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; - updateDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; + updateDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; + updateDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey; /** * Informs the DocumentRegistry that a file is not needed any longer. @@ -6912,9 +6930,10 @@ declare namespace ts { * * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file + * @param scriptKind The script kind of the file to be released */ - /**@deprecated pass scriptKind for correctness */ - releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + /**@deprecated pass scriptKind and impliedNodeFormat for correctness */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind?: ScriptKind): void; /** * Informs the DocumentRegistry that a file is not needed any longer. * @@ -6924,12 +6943,13 @@ declare namespace ts { * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file * @param scriptKind The script kind of the file to be released + * @param impliedNodeFormat The implied source file format of the file to be released */ - releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind, impliedNodeFormat: SourceFile["impliedNodeFormat"]): void; /** - * @deprecated pass scriptKind for correctness */ - releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; - releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; + * @deprecated pass scriptKind for and impliedNodeFormat correctness */ + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind?: ScriptKind): void; + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind, impliedNodeFormat: SourceFile["impliedNodeFormat"]): void; reportStats(): string; } type DocumentRegistryBucketKey = string & { diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index d0486144734a6..83540854d4366 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -21,7 +21,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -303,7 +303,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "4.8.1-rc"; /* @internal */ var Comparison; (function (Comparison) { @@ -350,7 +350,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); /* @internal */ @@ -1050,9 +1050,9 @@ var ts; case true: // relational comparison // falls through - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: continue; - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If `array` is sorted, `next` should **never** be less than `last`. return ts.Debug.fail("Array is unsorted."); } @@ -1088,7 +1088,7 @@ var ts; var prevElement = array[0]; for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) { var element = _a[_i]; - if (comparer(prevElement, element) === 1 /* GreaterThan */) { + if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) { return false; } prevElement = element; @@ -1142,27 +1142,27 @@ var ts; loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) { if (offsetB > 0) { // Ensure `arrayB` is properly sorted. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */); } loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) { if (offsetA > startA) { // Ensure `arrayA` is properly sorted. We only need to perform this check if // `offsetA` has changed since we entered the loop. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */); } switch (comparer(arrayB[offsetB], arrayA[offsetA])) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If B is less than A, B does not exist in arrayA. Add B to the result and // move to the next element in arrayB without changing the current position // in arrayA. result.push(arrayB[offsetB]); continue loopB; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: // If B is equal to A, B exists in arrayA. Move to the next element in // arrayB without adding B to the result or changing the current position // in arrayA. continue loopB; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: // If B is greater than A, we need to keep looking for B in arrayA. Move to // the next element in arrayA and recheck. continue loopA; @@ -1402,12 +1402,12 @@ var ts; var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle], middle); switch (keyComparer(midKey, key)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: low = middle + 1; break; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: return middle; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: high = middle - 1; break; } @@ -1679,6 +1679,43 @@ var ts; return createMultiMap(); } ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap; + function createQueue(items) { + var elements = (items === null || items === void 0 ? void 0 : items.slice()) || []; + var headIndex = 0; + function isEmpty() { + return headIndex === elements.length; + } + function enqueue() { + var items = []; + for (var _i = 0; _i < arguments.length; _i++) { + items[_i] = arguments[_i]; + } + elements.push.apply(elements, items); + } + function dequeue() { + if (isEmpty()) { + throw new Error("Queue is empty"); + } + var result = elements[headIndex]; + elements[headIndex] = undefined; // Don't keep referencing dequeued item + headIndex++; + // If more than half of the queue is empty, copy the remaining elements to the + // front and shrink the array (unless we'd be saving fewer than 100 slots) + if (headIndex > 100 && headIndex > (elements.length >> 1)) { + var newLength = elements.length - headIndex; + elements.copyWithin(/*target*/ 0, /*start*/ headIndex); + elements.length = newLength; + headIndex = 0; + } + return result; + } + return { + enqueue: enqueue, + dequeue: dequeue, + isEmpty: isEmpty, + }; + } + ts.createQueue = createQueue; /** * Creates a Set with custom equality and hash code functionality. This is useful when you * want to use something looser than object identity - e.g. "has the same span". @@ -1861,12 +1898,16 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; /** Does nothing. */ function noop(_) { } ts.noop = noop; + ts.noopPush = { + push: noop, + length: 0 + }; /** Do nothing and return false */ function returnFalse() { return false; @@ -1952,7 +1993,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -2024,11 +2065,11 @@ var ts; } ts.equateStringsCaseSensitive = equateStringsCaseSensitive; function compareComparableValues(a, b) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + a < b ? -1 /* Comparison.LessThan */ : + 1 /* Comparison.GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -2046,7 +2087,7 @@ var ts; } ts.compareTextSpans = compareTextSpans; function min(a, b, compare) { - return compare(a, b) === -1 /* LessThan */ ? a : b; + return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b; } ts.min = min; /** @@ -2063,14 +2104,14 @@ var ts; */ function compareStringsCaseInsensitive(a, b) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; a = a.toUpperCase(); b = b.toUpperCase(); - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive; /** @@ -2101,13 +2142,13 @@ var ts; return createStringComparer; function compareWithCallback(a, b, comparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; var value = comparer(a, b); - return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } function createIntlCollatorStringComparer(locale) { // Intl.Collator.prototype.compare is bound to the collator. See NOTE in @@ -2137,7 +2178,7 @@ var ts; return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b); } function compareStrings(a, b) { - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } } function getStringComparerFactory() { @@ -2198,9 +2239,9 @@ var ts; } ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI; function compareProperties(a, b, key, comparer) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : comparer(a[key], b[key]); } ts.compareProperties = compareProperties; @@ -2222,7 +2263,7 @@ var ts; * and 1 insertion/deletion at 3 characters) */ function getSpellingSuggestion(name, candidates, getName) { - var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34)); + var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34)); var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother. var bestCandidate; for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { @@ -2319,24 +2360,24 @@ var ts; var end = fileName.length; for (var pos = end - 1; pos > 0; pos--) { var ch = fileName.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) { // Match a \d+ segment do { --pos; ch = fileName.charCodeAt(pos); - } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */); } - else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) { // Looking for "min" or "min" // Already matched the 'n' --pos; ch = fileName.charCodeAt(pos); - if (ch !== 105 /* i */ && ch !== 73 /* I */) { + if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) { break; } --pos; ch = fileName.charCodeAt(pos); - if (ch !== 109 /* m */ && ch !== 77 /* M */) { + if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) { break; } --pos; @@ -2346,7 +2387,7 @@ var ts; // This character is not part of either suffix pattern break; } - if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) { break; } end = pos; @@ -2402,7 +2443,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; /** @@ -2503,12 +2544,12 @@ var ts; var newItem = newItems[newIndex]; var oldItem = oldItems[oldIndex]; var compareResult = comparer(newItem, oldItem); - if (compareResult === -1 /* LessThan */) { + if (compareResult === -1 /* Comparison.LessThan */) { inserted(newItem); newIndex++; hasChanges = true; } - else if (compareResult === 1 /* GreaterThan */) { + else if (compareResult === 1 /* Comparison.GreaterThan */) { deleted(oldItem); oldIndex++; hasChanges = true; @@ -2639,7 +2680,7 @@ var ts; (function (Debug) { var typeScriptVersion; /* eslint-disable prefer-const */ - var currentAssertionLevel = 0 /* None */; + var currentAssertionLevel = 0 /* AssertionLevel.None */; Debug.currentLogLevel = LogLevel.Warning; Debug.isDebugging = false; function getTypeScriptVersion() { @@ -2718,7 +2759,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2726,12 +2767,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2741,26 +2782,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2791,42 +2832,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2847,7 +2888,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; /** @@ -2951,6 +2992,22 @@ var ts; return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true); } Debug.formatFlowFlags = formatFlowFlags; + function formatRelationComparisonResult(result) { + return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true); + } + Debug.formatRelationComparisonResult = formatRelationComparisonResult; + function formatCheckMode(mode) { + return formatEnum(mode, ts.CheckMode, /*isFlags*/ true); + } + Debug.formatCheckMode = formatCheckMode; + function formatSignatureCheckMode(mode) { + return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true); + } + Debug.formatSignatureCheckMode = formatSignatureCheckMode; + function formatTypeFacts(facts) { + return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true); + } + Debug.formatTypeFacts = formatTypeFacts; var isDebugInfoEnabled = false; var extendedDebugModule; function extendedDebug() { @@ -2975,20 +3032,20 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" : - this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" : - this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" : - this.flags & 16 /* Assignment */ ? "FlowAssignment" : - this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" : - this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" : - this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" : - this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" : - this.flags & 512 /* Call */ ? "FlowCall" : - this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" : - this.flags & 1 /* Unreachable */ ? "FlowUnreachable" : + var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" : + this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" : + this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" : + this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" : "UnknownFlow"; - var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, @@ -3027,7 +3084,7 @@ var ts; // We don't care, this is debug code that's only enabled with a debugger attached - // we're just taking note of it for anyone checking regex performance in the future. defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -3079,10 +3136,10 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" : + var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" : "Symbol"; - var remainingSymbolFlags = this.flags & ~33554432 /* Transient */; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */; + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -3091,35 +3148,35 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" : - this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 /* BigIntLiteral */ ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : - this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : - this.flags & 32 /* Enum */ ? "EnumType" : - this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType " + this.intrinsicName : - this.flags & 1048576 /* Union */ ? "UnionType" : - this.flags & 2097152 /* Intersection */ ? "IntersectionType" : - this.flags & 4194304 /* Index */ ? "IndexType" : - this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : - this.flags & 16777216 /* Conditional */ ? "ConditionalType" : - this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : - this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : - this.flags & 524288 /* Object */ ? - this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : - this.objectFlags & 4 /* Reference */ ? "TypeReference" : - this.objectFlags & 8 /* Tuple */ ? "TupleType" : - this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : - this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : - this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : + var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" : + this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : + this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" : + this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) : + this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" : + this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" : + this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* TypeFlags.Object */ ? + this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" : + this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" : + this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" : + this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0; + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { // avoid recomputing @@ -3151,11 +3208,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -3187,7 +3244,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -3234,10 +3291,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -3281,6 +3338,48 @@ var ts; return wrapFunction(deprecation, func); } Debug.deprecate = deprecate; + function formatVariance(varianceFlags) { + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; + var result = variance === 0 /* VarianceFlags.Invariant */ ? "in out" : + variance === 3 /* VarianceFlags.Bivariant */ ? "[bivariant]" : + variance === 2 /* VarianceFlags.Contravariant */ ? "in" : + variance === 1 /* VarianceFlags.Covariant */ ? "out" : + variance === 4 /* VarianceFlags.Independent */ ? "[independent]" : ""; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { + result += " (unmeasurable)"; + } + else if (varianceFlags & 16 /* VarianceFlags.Unreliable */) { + result += " (unreliable)"; + } + return result; + } + Debug.formatVariance = formatVariance; + var DebugTypeMapper = /** @class */ (function () { + function DebugTypeMapper() { + } + DebugTypeMapper.prototype.__debugToString = function () { + var _a; + type(this); + switch (this.kind) { + case 3 /* TypeMapKind.Function */: return ((_a = this.debugInfo) === null || _a === void 0 ? void 0 : _a.call(this)) || "(function mapper)"; + case 0 /* TypeMapKind.Simple */: return "".concat(this.source.__debugTypeToString(), " -> ").concat(this.target.__debugTypeToString()); + case 1 /* TypeMapKind.Array */: return ts.zipWith(this.sources, this.targets || ts.map(this.sources, function () { return "any"; }), function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(typeof t === "string" ? t : t.__debugTypeToString()); }).join(", "); + case 2 /* TypeMapKind.Deferred */: return ts.zipWith(this.sources, this.targets, function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(t().__debugTypeToString()); }).join(", "); + case 5 /* TypeMapKind.Merged */: + case 4 /* TypeMapKind.Composite */: return "m1: ".concat(this.mapper1.__debugToString().split("\n").join("\n "), "\nm2: ").concat(this.mapper2.__debugToString().split("\n").join("\n ")); + default: return assertNever(this); + } + }; + return DebugTypeMapper; + }()); + Debug.DebugTypeMapper = DebugTypeMapper; + function attachDebugPrototypeIfDebug(mapper) { + if (Debug.isDebugging) { + return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype); + } + return mapper; + } + Debug.attachDebugPrototypeIfDebug = attachDebugPrototypeIfDebug; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); /* @internal */ @@ -3353,9 +3452,9 @@ var ts; // https://semver.org/#spec-item-11 // > Build metadata does not figure into precedence if (this === other) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (other === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; return ts.compareValues(this.major, other.major) || ts.compareValues(this.minor, other.minor) || ts.compareValues(this.patch, other.patch) @@ -3370,11 +3469,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -3403,11 +3502,11 @@ var ts; // > When major, minor, and patch are equal, a pre-release version has lower precedence // > than a normal version. if (left === right) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (left.length === 0) - return right.length === 0 ? 0 /* EqualTo */ : 1 /* GreaterThan */; + return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */; if (right.length === 0) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; // https://semver.org/#spec-item-11 // > Precedence for two pre-release versions with the same major, minor, and patch version // > MUST be determined by comparing each dot separated identifier from left to right until @@ -3424,7 +3523,7 @@ var ts; // https://semver.org/#spec-item-11 // > Numeric identifiers always have lower precedence than non-numeric identifiers. if (leftIsNumeric !== rightIsNumeric) - return leftIsNumeric ? -1 /* LessThan */ : 1 /* GreaterThan */; + return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; // https://semver.org/#spec-item-11 // > identifiers consisting of only digits are compared numerically var result = ts.compareValues(+leftIdentifier, +rightIdentifier); @@ -3641,7 +3740,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); /*@internal*/ @@ -3939,7 +4038,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3951,11 +4050,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -4022,9 +4121,9 @@ var ts; eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } tracingEnabled.push = push; - function pop() { + function pop(results) { ts.Debug.assert(eventStack.length > 0); - writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); + writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results); eventStack.length--; } tracingEnabled.pop = pop; @@ -4038,27 +4137,28 @@ var ts; tracingEnabled.popAll = popAll; // sample every 10ms var sampleInterval = 1000 * 10; - function writeStackEvent(index, endTime) { + function writeStackEvent(index, endTime, results) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { + ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`"); writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); } // test if [time,endTime) straddles a sampling point else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === "server" && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */) return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -4094,7 +4194,7 @@ var ts; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) var display = void 0; - if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { + if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) { try { display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } @@ -4103,7 +4203,7 @@ var ts; } } var indexedAccessProperties = {}; - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, @@ -4111,7 +4211,7 @@ var ts; }; } var referenceProperties = {}; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { var referenceType = type; referenceProperties = { instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, @@ -4120,7 +4220,7 @@ var ts; }; } var conditionalProperties = {}; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var conditionalType = type; conditionalProperties = { conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, @@ -4130,7 +4230,7 @@ var ts; }; } var substitutionProperties = {}; - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { var substitutionType = type; substitutionProperties = { substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, @@ -4138,7 +4238,7 @@ var ts; }; } var reverseMappedProperties = {}; - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { var reverseMappedType = type; reverseMappedProperties = { reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, @@ -4147,7 +4247,7 @@ var ts; }; } var evolvingArrayProperties = {}; - if (objectFlags & 256 /* EvolvingArray */) { + if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) { var evolvingArrayType = type; evolvingArrayProperties = { evolvingArrayElementType: evolvingArrayType.elementType.id, @@ -4165,7 +4265,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -4886,6 +4986,7 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; @@ -4926,6 +5027,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter"; // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -4937,7 +5039,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; /** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 814775659] = "NodeBuilderFlagsMask"; + TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -5416,9 +5518,10 @@ var ts; (function (TypeMapKind) { TypeMapKind[TypeMapKind["Simple"] = 0] = "Simple"; TypeMapKind[TypeMapKind["Array"] = 1] = "Array"; - TypeMapKind[TypeMapKind["Function"] = 2] = "Function"; - TypeMapKind[TypeMapKind["Composite"] = 3] = "Composite"; - TypeMapKind[TypeMapKind["Merged"] = 4] = "Merged"; + TypeMapKind[TypeMapKind["Deferred"] = 2] = "Deferred"; + TypeMapKind[TypeMapKind["Function"] = 3] = "Function"; + TypeMapKind[TypeMapKind["Composite"] = 4] = "Composite"; + TypeMapKind[TypeMapKind["Merged"] = 5] = "Merged"; })(TypeMapKind = ts.TypeMapKind || (ts.TypeMapKind = {})); var InferencePriority; (function (InferencePriority) { @@ -5813,10 +5916,8 @@ var ts; TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait"; TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper"; TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier"; - // Please leave this as 1 << 29. - // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. - // It is a good reminder of how much room we have left - TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["ContainsPrivateIdentifierInExpression"] = 536870912] = "ContainsPrivateIdentifierInExpression"; + TransformFlags[TransformFlags["HasComputedFlags"] = -2147483648] = "HasComputedFlags"; // Assertions // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript"; @@ -5835,23 +5936,23 @@ var ts; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes"; - TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes"; - TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes"; + TransformFlags[TransformFlags["OuterExpressionExcludes"] = -2147483648] = "OuterExpressionExcludes"; + TransformFlags[TransformFlags["PropertyAccessExcludes"] = -2147483648] = "PropertyAccessExcludes"; + TransformFlags[TransformFlags["NodeExcludes"] = -2147483648] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = -2072174592] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = -1937940480] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = -1937948672] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = -2005057536] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = -2013249536] = "PropertyExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = -2147344384] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = -1941676032] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes"; - TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; - TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes"; - TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = -2147278848] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = -2147450880] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = -2146893824] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = -2147483648] = "ParameterExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = -2147418112] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = -2147450880] = "BindingPatternExcludes"; TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper"; // Propagating flags // - Bitmasks for flags that should propagate from a child @@ -6104,37 +6205,37 @@ var ts; { name: "no-default-lib", optional: true }, { name: "resolution-mode", optional: true } ], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-dependency": { args: [{ name: "path" }, { name: "name", optional: true }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-module": { args: [{ name: "name" }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "ts-check": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "ts-nocheck": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "jsx": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxfrag": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsximportsource": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxruntime": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, }; })(ts || (ts = {})); @@ -6206,7 +6307,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -6423,7 +6524,7 @@ var ts; }; } function createDirectoryWatcher(dirName, dirPath, fallbackOptions) { - var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) { + var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName, modifiedTime) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" if (!ts.isString(relativeFileName)) return; @@ -6651,7 +6752,7 @@ var ts; function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) { // Iterate through existing children and update the watches if needed var parentWatcher = cache.get(dirPath); - if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) { + if (parentWatcher && fileSystemEntryExists(dirName, 1 /* FileSystemEntryKind.Directory */)) { // Schedule the update and postpone invoke for callbacks scheduleUpdateChildWatches(dirName, dirPath, fileName, options); return; @@ -6676,7 +6777,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -6689,7 +6790,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -6705,7 +6806,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -6724,11 +6825,11 @@ var ts; if (!parentWatcher) return false; var newChildWatches; - var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) { + var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* FileSystemEntryKind.Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) { var childFullName = ts.getNormalizedAbsolutePath(child, parentDir); // Filter our the symbolic link directories since those arent included in recursive watch // which is same behaviour when recursive: true is passed to fs.watch - return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : undefined; + return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* Comparison.EqualTo */ ? childFullName : undefined; }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher); parentWatcher.childWatches = newChildWatches || ts.emptyArray; return hasChanges; @@ -6826,7 +6927,7 @@ var ts; case ts.WatchFileKind.FixedChunkSizePolling: return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: - return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime), + return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); case ts.WatchFileKind.UseFsEventsOnParentDirectory: if (!nonPollingWatchFile) { @@ -6881,7 +6982,7 @@ var ts; } function watchDirectory(directoryName, callback, recursive, options) { if (fsSupportsRecursiveFsWatch) { - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); } if (!hostRecursiveDirectoryWatcher) { hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({ @@ -6913,7 +7014,7 @@ var ts; /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchDirectoryKind.UseFsEvents: - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: ts.Debug.assertNever(watchDirectoryKind); } @@ -6952,14 +7053,16 @@ var ts; return { close: function () { // Close the watcher (either existing file system entry watcher or missing file system entry watcher) - watcher.close(); - watcher = undefined; + if (watcher) { + watcher.close(); + watcher = undefined; + } } }; function updateWatcher(createWatcher) { // If watcher is not closed, update it if (watcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); watcher.close(); watcher = createWatcher(); } @@ -6970,7 +7073,7 @@ var ts; */ function watchPresentFileSystemEntry() { if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -6989,7 +7092,7 @@ var ts; // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -7284,7 +7387,7 @@ var ts; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -7293,7 +7396,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -7309,7 +7412,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -7507,8 +7610,8 @@ var ts; return false; } switch (entryKind) { - case 0 /* File */: return stat.isFile(); - case 1 /* Directory */: return stat.isDirectory(); + case 0 /* FileSystemEntryKind.File */: return stat.isFile(); + case 1 /* FileSystemEntryKind.Directory */: return stat.isDirectory(); default: return false; } } @@ -7520,10 +7623,10 @@ var ts; } } function fileExists(path) { - return fileSystemEntryExists(path, 0 /* File */); + return fileSystemEntryExists(path, 0 /* FileSystemEntryKind.File */); } function directoryExists(path) { - return fileSystemEntryExists(path, 1 /* Directory */); + return fileSystemEntryExists(path, 1 /* FileSystemEntryKind.Directory */); } function getDirectories(path) { return getAccessibleFileSystemEntries(path).directories.slice(); @@ -7594,8 +7697,8 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* AssertionLevel.Normal */ + : 0 /* AssertionLevel.None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7618,7 +7721,7 @@ var ts; * Determines whether a charCode corresponds to `/` or `\`. */ function isAnyDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */; } ts.isAnyDirectorySeparator = isAnyDirectorySeparator; /** @@ -7705,16 +7808,16 @@ var ts; ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; //// Path Parsing function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) || + (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */); } function getFileUrlVolumeSeparatorEnd(url, start) { var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) + if (ch0 === 58 /* CharacterCodes.colon */) return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) { var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */) return start + 3; } return -1; @@ -7728,18 +7831,18 @@ var ts; return 0; var ch0 = path.charCodeAt(0); // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) { if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); + var p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); if (p1 < 0) return path.length; // UNC: "//server" or "\\server" return p1 + 1; // UNC: "//server/" or "\\server\" } // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) { var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */) return 3; // DOS: "c:/" or "c:\" if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") @@ -7759,7 +7862,7 @@ var ts; isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) { // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" return ~(volumeSeparatorEnd + 1); } @@ -7836,7 +7939,7 @@ var ts; function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { if (!ts.startsWith(extension, ".")) extension = "." + extension; - if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) { var pathExtension = path.slice(path.length - extension.length); if (stringEqualityComparer(pathExtension, extension)) { return pathExtension; @@ -8120,17 +8223,17 @@ var ts; var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; // NOTE: Performance optimization - shortcut if the root segments differ as there would be no // need to perform path reduction. var aRoot = a.substring(0, getRootLength(a)); var bRoot = b.substring(0, getRootLength(b)); var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { + if (result !== 0 /* Comparison.EqualTo */) { return result; } // NOTE: Performance optimization - shortcut if there are no relative path segments in @@ -8147,7 +8250,7 @@ var ts; var sharedLength = Math.min(aComponents.length, bComponents.length); for (var i = 1; i < sharedLength; i++) { var result_2 = componentComparer(aComponents[i], bComponents[i]); - if (result_2 !== 0 /* EqualTo */) { + if (result_2 !== 0 /* Comparison.EqualTo */) { return result_2; } } @@ -8662,13 +8765,24 @@ var ts; resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."), Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"), + File_is_ECMAScript_module_because_0_has_field_type_with_value_module: diag(1458, ts.DiagnosticCategory.Message, "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458", "File is ECMAScript module because '{0}' has field \"type\" with value \"module\""), + File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module: diag(1459, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459", "File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\""), + File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""), + File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"), The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."), - Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."), + Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead."), catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."), An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), + An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."), + Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."), + The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead: diag(1479, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_reference_1479", "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"{0}\")' call instead."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module: diag(1480, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_packag_1480", "To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1: diag(1481, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Co_1481", "To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'."), + To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0: diag(1482, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0_1482", "To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'."), + To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module: diag(1483, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module_1483", "To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -8882,6 +8996,7 @@ var ts; Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."), Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."), Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."), + A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, ts.DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."), Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."), All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."), Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."), @@ -9169,6 +9284,7 @@ var ts; The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), + Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), 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}'."), @@ -10148,100 +10264,100 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 79 /* Identifier */; + return token >= 79 /* SyntaxKind.Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* SyntaxKind.GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; /** @internal */ ts.textToKeywordObj = (_a = { - abstract: 126 /* AbstractKeyword */, - any: 130 /* AnyKeyword */, - as: 127 /* AsKeyword */, - asserts: 128 /* AssertsKeyword */, - assert: 129 /* AssertKeyword */, - bigint: 158 /* BigIntKeyword */, - boolean: 133 /* BooleanKeyword */, - break: 81 /* BreakKeyword */, - case: 82 /* CaseKeyword */, - catch: 83 /* CatchKeyword */, - class: 84 /* ClassKeyword */, - continue: 86 /* ContinueKeyword */, - const: 85 /* ConstKeyword */ + abstract: 126 /* SyntaxKind.AbstractKeyword */, + any: 130 /* SyntaxKind.AnyKeyword */, + as: 127 /* SyntaxKind.AsKeyword */, + asserts: 128 /* SyntaxKind.AssertsKeyword */, + assert: 129 /* SyntaxKind.AssertKeyword */, + bigint: 158 /* SyntaxKind.BigIntKeyword */, + boolean: 133 /* SyntaxKind.BooleanKeyword */, + break: 81 /* SyntaxKind.BreakKeyword */, + case: 82 /* SyntaxKind.CaseKeyword */, + catch: 83 /* SyntaxKind.CatchKeyword */, + class: 84 /* SyntaxKind.ClassKeyword */, + continue: 86 /* SyntaxKind.ContinueKeyword */, + const: 85 /* SyntaxKind.ConstKeyword */ }, - _a["" + "constructor"] = 134 /* ConstructorKeyword */, - _a.debugger = 87 /* DebuggerKeyword */, - _a.declare = 135 /* DeclareKeyword */, - _a.default = 88 /* DefaultKeyword */, - _a.delete = 89 /* DeleteKeyword */, - _a.do = 90 /* DoKeyword */, - _a.else = 91 /* ElseKeyword */, - _a.enum = 92 /* EnumKeyword */, - _a.export = 93 /* ExportKeyword */, - _a.extends = 94 /* ExtendsKeyword */, - _a.false = 95 /* FalseKeyword */, - _a.finally = 96 /* FinallyKeyword */, - _a.for = 97 /* ForKeyword */, - _a.from = 156 /* FromKeyword */, - _a.function = 98 /* FunctionKeyword */, - _a.get = 136 /* GetKeyword */, - _a.if = 99 /* IfKeyword */, - _a.implements = 117 /* ImplementsKeyword */, - _a.import = 100 /* ImportKeyword */, - _a.in = 101 /* InKeyword */, - _a.infer = 137 /* InferKeyword */, - _a.instanceof = 102 /* InstanceOfKeyword */, - _a.interface = 118 /* InterfaceKeyword */, - _a.intrinsic = 138 /* IntrinsicKeyword */, - _a.is = 139 /* IsKeyword */, - _a.keyof = 140 /* KeyOfKeyword */, - _a.let = 119 /* LetKeyword */, - _a.module = 141 /* ModuleKeyword */, - _a.namespace = 142 /* NamespaceKeyword */, - _a.never = 143 /* NeverKeyword */, - _a.new = 103 /* NewKeyword */, - _a.null = 104 /* NullKeyword */, - _a.number = 147 /* NumberKeyword */, - _a.object = 148 /* ObjectKeyword */, - _a.package = 120 /* PackageKeyword */, - _a.private = 121 /* PrivateKeyword */, - _a.protected = 122 /* ProtectedKeyword */, - _a.public = 123 /* PublicKeyword */, - _a.override = 159 /* OverrideKeyword */, - _a.out = 144 /* OutKeyword */, - _a.readonly = 145 /* ReadonlyKeyword */, - _a.require = 146 /* RequireKeyword */, - _a.global = 157 /* GlobalKeyword */, - _a.return = 105 /* ReturnKeyword */, - _a.set = 149 /* SetKeyword */, - _a.static = 124 /* StaticKeyword */, - _a.string = 150 /* StringKeyword */, - _a.super = 106 /* SuperKeyword */, - _a.switch = 107 /* SwitchKeyword */, - _a.symbol = 151 /* SymbolKeyword */, - _a.this = 108 /* ThisKeyword */, - _a.throw = 109 /* ThrowKeyword */, - _a.true = 110 /* TrueKeyword */, - _a.try = 111 /* TryKeyword */, - _a.type = 152 /* TypeKeyword */, - _a.typeof = 112 /* TypeOfKeyword */, - _a.undefined = 153 /* UndefinedKeyword */, - _a.unique = 154 /* UniqueKeyword */, - _a.unknown = 155 /* UnknownKeyword */, - _a.var = 113 /* VarKeyword */, - _a.void = 114 /* VoidKeyword */, - _a.while = 115 /* WhileKeyword */, - _a.with = 116 /* WithKeyword */, - _a.yield = 125 /* YieldKeyword */, - _a.async = 131 /* AsyncKeyword */, - _a.await = 132 /* AwaitKeyword */, - _a.of = 160 /* OfKeyword */, + _a["" + "constructor"] = 134 /* SyntaxKind.ConstructorKeyword */, + _a.debugger = 87 /* SyntaxKind.DebuggerKeyword */, + _a.declare = 135 /* SyntaxKind.DeclareKeyword */, + _a.default = 88 /* SyntaxKind.DefaultKeyword */, + _a.delete = 89 /* SyntaxKind.DeleteKeyword */, + _a.do = 90 /* SyntaxKind.DoKeyword */, + _a.else = 91 /* SyntaxKind.ElseKeyword */, + _a.enum = 92 /* SyntaxKind.EnumKeyword */, + _a.export = 93 /* SyntaxKind.ExportKeyword */, + _a.extends = 94 /* SyntaxKind.ExtendsKeyword */, + _a.false = 95 /* SyntaxKind.FalseKeyword */, + _a.finally = 96 /* SyntaxKind.FinallyKeyword */, + _a.for = 97 /* SyntaxKind.ForKeyword */, + _a.from = 156 /* SyntaxKind.FromKeyword */, + _a.function = 98 /* SyntaxKind.FunctionKeyword */, + _a.get = 136 /* SyntaxKind.GetKeyword */, + _a.if = 99 /* SyntaxKind.IfKeyword */, + _a.implements = 117 /* SyntaxKind.ImplementsKeyword */, + _a.import = 100 /* SyntaxKind.ImportKeyword */, + _a.in = 101 /* SyntaxKind.InKeyword */, + _a.infer = 137 /* SyntaxKind.InferKeyword */, + _a.instanceof = 102 /* SyntaxKind.InstanceOfKeyword */, + _a.interface = 118 /* SyntaxKind.InterfaceKeyword */, + _a.intrinsic = 138 /* SyntaxKind.IntrinsicKeyword */, + _a.is = 139 /* SyntaxKind.IsKeyword */, + _a.keyof = 140 /* SyntaxKind.KeyOfKeyword */, + _a.let = 119 /* SyntaxKind.LetKeyword */, + _a.module = 141 /* SyntaxKind.ModuleKeyword */, + _a.namespace = 142 /* SyntaxKind.NamespaceKeyword */, + _a.never = 143 /* SyntaxKind.NeverKeyword */, + _a.new = 103 /* SyntaxKind.NewKeyword */, + _a.null = 104 /* SyntaxKind.NullKeyword */, + _a.number = 147 /* SyntaxKind.NumberKeyword */, + _a.object = 148 /* SyntaxKind.ObjectKeyword */, + _a.package = 120 /* SyntaxKind.PackageKeyword */, + _a.private = 121 /* SyntaxKind.PrivateKeyword */, + _a.protected = 122 /* SyntaxKind.ProtectedKeyword */, + _a.public = 123 /* SyntaxKind.PublicKeyword */, + _a.override = 159 /* SyntaxKind.OverrideKeyword */, + _a.out = 144 /* SyntaxKind.OutKeyword */, + _a.readonly = 145 /* SyntaxKind.ReadonlyKeyword */, + _a.require = 146 /* SyntaxKind.RequireKeyword */, + _a.global = 157 /* SyntaxKind.GlobalKeyword */, + _a.return = 105 /* SyntaxKind.ReturnKeyword */, + _a.set = 149 /* SyntaxKind.SetKeyword */, + _a.static = 124 /* SyntaxKind.StaticKeyword */, + _a.string = 150 /* SyntaxKind.StringKeyword */, + _a.super = 106 /* SyntaxKind.SuperKeyword */, + _a.switch = 107 /* SyntaxKind.SwitchKeyword */, + _a.symbol = 151 /* SyntaxKind.SymbolKeyword */, + _a.this = 108 /* SyntaxKind.ThisKeyword */, + _a.throw = 109 /* SyntaxKind.ThrowKeyword */, + _a.true = 110 /* SyntaxKind.TrueKeyword */, + _a.try = 111 /* SyntaxKind.TryKeyword */, + _a.type = 152 /* SyntaxKind.TypeKeyword */, + _a.typeof = 112 /* SyntaxKind.TypeOfKeyword */, + _a.undefined = 153 /* SyntaxKind.UndefinedKeyword */, + _a.unique = 154 /* SyntaxKind.UniqueKeyword */, + _a.unknown = 155 /* SyntaxKind.UnknownKeyword */, + _a.var = 113 /* SyntaxKind.VarKeyword */, + _a.void = 114 /* SyntaxKind.VoidKeyword */, + _a.while = 115 /* SyntaxKind.WhileKeyword */, + _a.with = 116 /* SyntaxKind.WithKeyword */, + _a.yield = 125 /* SyntaxKind.YieldKeyword */, + _a.async = 131 /* SyntaxKind.AsyncKeyword */, + _a.await = 132 /* SyntaxKind.AwaitKeyword */, + _a.of = 160 /* SyntaxKind.OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* SyntaxKind.OpenBraceToken */, "}": 19 /* SyntaxKind.CloseBraceToken */, "(": 20 /* SyntaxKind.OpenParenToken */, ")": 21 /* SyntaxKind.CloseParenToken */, "[": 22 /* SyntaxKind.OpenBracketToken */, "]": 23 /* SyntaxKind.CloseBracketToken */, ".": 24 /* SyntaxKind.DotToken */, "...": 25 /* SyntaxKind.DotDotDotToken */, ";": 26 /* SyntaxKind.SemicolonToken */, ",": 27 /* SyntaxKind.CommaToken */, "<": 29 /* SyntaxKind.LessThanToken */, ">": 31 /* SyntaxKind.GreaterThanToken */, "<=": 32 /* SyntaxKind.LessThanEqualsToken */, ">=": 33 /* SyntaxKind.GreaterThanEqualsToken */, "==": 34 /* SyntaxKind.EqualsEqualsToken */, "!=": 35 /* SyntaxKind.ExclamationEqualsToken */, "===": 36 /* SyntaxKind.EqualsEqualsEqualsToken */, "!==": 37 /* SyntaxKind.ExclamationEqualsEqualsToken */, "=>": 38 /* SyntaxKind.EqualsGreaterThanToken */, "+": 39 /* SyntaxKind.PlusToken */, "-": 40 /* SyntaxKind.MinusToken */, "**": 42 /* SyntaxKind.AsteriskAsteriskToken */, "*": 41 /* SyntaxKind.AsteriskToken */, "/": 43 /* SyntaxKind.SlashToken */, "%": 44 /* SyntaxKind.PercentToken */, "++": 45 /* SyntaxKind.PlusPlusToken */, "--": 46 /* SyntaxKind.MinusMinusToken */, "<<": 47 /* SyntaxKind.LessThanLessThanToken */, ">": 48 /* SyntaxKind.GreaterThanGreaterThanToken */, ">>>": 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* SyntaxKind.AmpersandToken */, "|": 51 /* SyntaxKind.BarToken */, "^": 52 /* SyntaxKind.CaretToken */, "!": 53 /* SyntaxKind.ExclamationToken */, "~": 54 /* SyntaxKind.TildeToken */, "&&": 55 /* SyntaxKind.AmpersandAmpersandToken */, "||": 56 /* SyntaxKind.BarBarToken */, "?": 57 /* SyntaxKind.QuestionToken */, "??": 60 /* SyntaxKind.QuestionQuestionToken */, "?.": 28 /* SyntaxKind.QuestionDotToken */, ":": 58 /* SyntaxKind.ColonToken */, "=": 63 /* SyntaxKind.EqualsToken */, "+=": 64 /* SyntaxKind.PlusEqualsToken */, "-=": 65 /* SyntaxKind.MinusEqualsToken */, "*=": 66 /* SyntaxKind.AsteriskEqualsToken */, "**=": 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */, "/=": 68 /* SyntaxKind.SlashEqualsToken */, "%=": 69 /* SyntaxKind.PercentEqualsToken */, "<<=": 70 /* SyntaxKind.LessThanLessThanEqualsToken */, ">>=": 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* SyntaxKind.AmpersandEqualsToken */, "|=": 74 /* SyntaxKind.BarEqualsToken */, "^=": 78 /* SyntaxKind.CaretEqualsToken */, "||=": 75 /* SyntaxKind.BarBarEqualsToken */, "&&=": 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */, "??=": 77 /* SyntaxKind.QuestionQuestionEqualsToken */, "@": 59 /* SyntaxKind.AtToken */, "#": 62 /* SyntaxKind.HashToken */, "`": 61 /* SyntaxKind.BacktickToken */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -10330,16 +10446,16 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { @@ -10368,17 +10484,17 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: result.push(lineStart); lineStart = pos; break; default: - if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) { result.push(lineStart); lineStart = pos; } @@ -10403,7 +10519,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -10481,18 +10597,18 @@ var ts; function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; + return ch === 32 /* CharacterCodes.space */ || + ch === 9 /* CharacterCodes.tab */ || + ch === 11 /* CharacterCodes.verticalTab */ || + ch === 12 /* CharacterCodes.formFeed */ || + ch === 160 /* CharacterCodes.nonBreakingSpace */ || + ch === 133 /* CharacterCodes.nextLine */ || + ch === 5760 /* CharacterCodes.ogham */ || + ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ || + ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ || + ch === 8287 /* CharacterCodes.mathematicalSpace */ || + ch === 12288 /* CharacterCodes.ideographicSpace */ || + ch === 65279 /* CharacterCodes.byteOrderMark */; } ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; function isLineBreak(ch) { @@ -10506,50 +10622,50 @@ var ts; // \u2029 Paragraph separator // Only the characters in Table 3 are treated as line terminators. Other new line or line // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; + return ch === 10 /* CharacterCodes.lineFeed */ || + ch === 13 /* CharacterCodes.carriageReturn */ || + ch === 8232 /* CharacterCodes.lineSeparator */ || + ch === 8233 /* CharacterCodes.paragraphSeparator */; } ts.isLineBreak = isLineBreak; function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isHexDigit(ch) { - return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */; + return isDigit(ch) || ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */ || ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */; } function isCodePoint(code) { return code <= 0x10FFFF; } /* @internal */ function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 55 /* CharacterCodes._7 */; } ts.isOctalDigit = isOctalDigit; function couldStartTrivia(text, pos) { // Keep in sync with skipTrivia var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: + case 13 /* CharacterCodes.carriageReturn */: + case 10 /* CharacterCodes.lineFeed */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 47 /* CharacterCodes.slash */: // starts of normal trivia // falls through - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: // Starts of conflict marker trivia return true; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: // Only if its the beginning can we have #! trivia return pos === 0; default: - return ch > 127 /* maxAsciiCharacter */; + return ch > 127 /* CharacterCodes.maxAsciiCharacter */; } } ts.couldStartTrivia = couldStartTrivia; @@ -10563,29 +10679,29 @@ var ts; while (true) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (stopAfterLineBreak) { return pos; } canConsumeStar = !!inJSDoc; continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: if (stopAtComments) { break; } - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { @@ -10596,10 +10712,10 @@ var ts; canConsumeStar = false; continue; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10609,24 +10725,24 @@ var ts; continue; } break; - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); canConsumeStar = false; continue; } break; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); canConsumeStar = false; continue; } break; - case 42 /* asterisk */: + case 42 /* CharacterCodes.asterisk */: if (canConsumeStar) { pos++; canConsumeStar = false; @@ -10634,7 +10750,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -10658,8 +10774,8 @@ var ts; return false; } } - return ch === 61 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + return ch === 61 /* CharacterCodes.equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* CharacterCodes.space */; } } return false; @@ -10670,18 +10786,18 @@ var ts; } var ch = text.charCodeAt(pos); var len = text.length; - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { while (pos < len && !isLineBreak(text.charCodeAt(pos))) { pos++; } } else { - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); // Consume everything from the start of a ||||||| or ======= marker to the start // of the next ======= or >>>>>>> marker. while (pos < len) { var currentChar = text.charCodeAt(pos); - if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { + if ((currentChar === 61 /* CharacterCodes.equals */ || currentChar === 62 /* CharacterCodes.greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -10742,12 +10858,12 @@ var ts; scan: while (pos >= 0 && pos < text.length) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (trailing) { break scan; @@ -10757,20 +10873,20 @@ var ts; pendingHasTrailingNewLine = true; } continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: var nextChar = text.charCodeAt(pos + 1); var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + if (nextChar === 47 /* CharacterCodes.slash */ || nextChar === 42 /* CharacterCodes.asterisk */) { + var kind = nextChar === 47 /* CharacterCodes.slash */ ? 2 /* SyntaxKind.SingleLineCommentTrivia */ : 3 /* SyntaxKind.MultiLineCommentTrivia */; var startPos = pos; pos += 2; - if (nextChar === 47 /* slash */) { + if (nextChar === 47 /* CharacterCodes.slash */) { while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { hasTrailingNewLine = true; @@ -10781,7 +10897,7 @@ var ts; } else { while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10806,7 +10922,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -10861,17 +10977,17 @@ var ts; } ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } ts.isIdentifierStart = isIdentifierStart; function isIdentifierPart(ch, languageVersion, identifierVariant) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ || ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || // "-" and ":" are valid in JSX Identifiers - (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + (identifierVariant === 1 /* LanguageVariant.JSX */ ? (ch === 45 /* CharacterCodes.minus */ || ch === 58 /* CharacterCodes.colon */) : false) || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; /* @internal */ @@ -10890,7 +11006,7 @@ var ts; ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + if (languageVariant === void 0) { languageVariant = 0 /* LanguageVariant.Standard */; } var text = textInitial; // Current position (end position of text of current token) var pos; @@ -10913,15 +11029,15 @@ var ts; getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, - hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, - hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, - hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; }, - isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; }, - isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* TokenFlags.UnicodeEscape */) !== 0; }, + hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* TokenFlags.ExtendedUnicodeEscape */) !== 0; }, + hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */) !== 0; }, + hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* TokenFlags.PrecedingJSDocComment */) !== 0; }, + isIdentifier: function () { return token === 79 /* SyntaxKind.Identifier */ || token > 116 /* SyntaxKind.LastReservedWord */; }, + isReservedWord: function () { return token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */; }, + isUnterminated: function () { return (tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, - getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, + getNumericLiteralFlags: function () { return tokenFlags & 1008 /* TokenFlags.NumericLiteralFlags */; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, reScanAsteriskEqualsToken: reScanAsteriskEqualsToken, @@ -10976,8 +11092,8 @@ var ts; var result = ""; while (true) { var ch = text.charCodeAt(pos); - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -11001,7 +11117,7 @@ var ts; } break; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return result + text.substring(start, pos); @@ -11011,15 +11127,15 @@ var ts; var mainFragment = scanNumberFragment(); var decimalFragment; var scientificFragment; - if (text.charCodeAt(pos) === 46 /* dot */) { + if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) { pos++; decimalFragment = scanNumberFragment(); } var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) { pos++; - tokenFlags |= 16 /* Scientific */; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + tokenFlags |= 16 /* TokenFlags.Scientific */; + if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos++; var preNumericPart = pos; var finalFragment = scanNumberFragment(); @@ -11032,7 +11148,7 @@ var ts; } } var result; - if (tokenFlags & 512 /* ContainsSeparator */) { + if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) { result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; @@ -11044,10 +11160,10 @@ var ts; else { result = text.substring(start, end); // No need to use all the fragments; no _ removal needed } - if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { - checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* Scientific */)); + if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) { + checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */)); return { - type: 8 /* NumericLiteral */, + type: 8 /* SyntaxKind.NumericLiteral */, value: "" + +result // if value is not an integer, it can be safely coerced to a number }; } @@ -11105,8 +11221,8 @@ var ts; var isPreviousTokenSeparator = false; while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); - if (canHaveSeparators && ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (canHaveSeparators && ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -11121,11 +11237,11 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 65 /* A */ && ch <= 70 /* F */) { - ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase + if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) { + ch += 97 /* CharacterCodes.a */ - 65 /* CharacterCodes.A */; // standardize hex literals to lowercase } - else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || - (ch >= 97 /* a */ && ch <= 102 /* f */))) { + else if (!((ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) || + (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */))) { break; } valueChars.push(ch); @@ -11135,7 +11251,7 @@ var ts; if (valueChars.length < minCount) { valueChars = []; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return String.fromCharCode.apply(String, valueChars); @@ -11149,7 +11265,7 @@ var ts; while (true) { if (pos >= end) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11159,7 +11275,7 @@ var ts; pos++; break; } - if (ch === 92 /* backslash */ && !jsxAttributeString) { + if (ch === 92 /* CharacterCodes.backslash */ && !jsxAttributeString) { result += text.substring(start, pos); result += scanEscapeSequence(); start = pos; @@ -11167,7 +11283,7 @@ var ts; } if (isLineBreak(ch) && !jsxAttributeString) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11180,7 +11296,7 @@ var ts; * a literal component of a TemplateExpression. */ function scanTemplateAndSetTokenValue(isTaggedTemplate) { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + var startedWithBacktick = text.charCodeAt(pos) === 96 /* CharacterCodes.backtick */; pos++; var start = pos; var contents = ""; @@ -11188,28 +11304,28 @@ var ts; while (true) { if (pos >= end) { contents += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } var currChar = text.charCodeAt(pos); // '`' - if (currChar === 96 /* backtick */) { + if (currChar === 96 /* CharacterCodes.backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } // '${' - if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + if (currChar === 36 /* CharacterCodes.$ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* CharacterCodes.openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* SyntaxKind.TemplateHead */ : 16 /* SyntaxKind.TemplateMiddle */; break; } // Escape character - if (currChar === 92 /* backslash */) { + if (currChar === 92 /* CharacterCodes.backslash */) { contents += text.substring(start, pos); contents += scanEscapeSequence(isTaggedTemplate); start = pos; @@ -11217,10 +11333,10 @@ var ts; } // Speculated ECMAScript 6 Spec 11.8.6.1: // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { + if (currChar === 13 /* CharacterCodes.carriageReturn */) { contents += text.substring(start, pos); pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } contents += "\n"; @@ -11243,47 +11359,47 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 48 /* _0 */: + case 48 /* CharacterCodes._0 */: // '\01' if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } return "\0"; - case 98 /* b */: + case 98 /* CharacterCodes.b */: return "\b"; - case 116 /* t */: + case 116 /* CharacterCodes.t */: return "\t"; - case 110 /* n */: + case 110 /* CharacterCodes.n */: return "\n"; - case 118 /* v */: + case 118 /* CharacterCodes.v */: return "\v"; - case 102 /* f */: + case 102 /* CharacterCodes.f */: return "\f"; - case 114 /* r */: + case 114 /* CharacterCodes.r */: return "\r"; - case 39 /* singleQuote */: + case 39 /* CharacterCodes.singleQuote */: return "\'"; - case 34 /* doubleQuote */: + case 34 /* CharacterCodes.doubleQuote */: return "\""; - case 117 /* u */: + case 117 /* CharacterCodes.u */: if (isTaggedTemplate) { // '\u' or '\u0' or '\u00' or '\u000' for (var escapePos = pos; escapePos < pos + 4; escapePos++) { - if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) { + if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* CharacterCodes.openBrace */) { pos = escapePos; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } } // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + if (pos < end && text.charCodeAt(pos) === 123 /* CharacterCodes.openBrace */) { pos++; // '\u{' if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } if (isTaggedTemplate) { @@ -11291,29 +11407,29 @@ var ts; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; // '\u{Not Code Point' or '\u{CodePoint' - if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* CharacterCodes.closeBrace */) { + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else { pos = savePos; } } - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; return scanExtendedUnicodeEscape(); } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: + case 120 /* CharacterCodes.x */: if (isTaggedTemplate) { if (!isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else if (!isHexDigit(text.charCodeAt(pos + 1))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } @@ -11321,14 +11437,14 @@ var ts; return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: + case 10 /* CharacterCodes.lineFeed */: + case 8232 /* CharacterCodes.lineSeparator */: + case 8233 /* CharacterCodes.paragraphSeparator */: return ""; default: return String.fromCharCode(ch); @@ -11361,7 +11477,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) === 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -11377,7 +11493,7 @@ var ts; // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* CharacterCodes.u */) { var start_1 = pos; pos += 2; var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false); @@ -11387,7 +11503,7 @@ var ts; return -1; } function peekExtendedUnicodeEscape() { - if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) { var start_2 = pos; pos += 3; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); @@ -11405,11 +11521,11 @@ var ts; if (isIdentifierPart(ch, languageVersion)) { pos += charSize(ch); } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { ch = peekExtendedUnicodeEscape(); if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; result += scanExtendedUnicodeEscape(); start = pos; continue; @@ -11418,7 +11534,7 @@ var ts; if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; result += text.substring(start, pos); result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters @@ -11437,14 +11553,14 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 12) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { var keyword = textToKeyword.get(tokenValue); if (keyword !== undefined) { return token = keyword; } } } - return token = 79 /* Identifier */; + return token = 79 /* SyntaxKind.Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -11455,8 +11571,8 @@ var ts; while (true) { var ch = text.charCodeAt(pos); // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (separatorAllowed) { separatorAllowed = false; isPreviousTokenSeparator = true; @@ -11471,101 +11587,101 @@ var ts; continue; } separatorAllowed = true; - if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { + if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) { break; } value += text[pos]; pos++; isPreviousTokenSeparator = false; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return value; } function checkBigIntSuffix() { - if (text.charCodeAt(pos) === 110 /* n */) { + if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) { tokenValue += "n"; // Use base 10 instead of base 2 or base 8 for shorter literals - if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + if (tokenFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; } pos++; - return 9 /* BigIntLiteral */; + return 9 /* SyntaxKind.BigIntLiteral */; } else { // not a bigint, so can convert to number in simplified form // Number() may not support 0b or 0o, so use parseInt() instead - var numericValue = tokenFlags & 128 /* BinarySpecifier */ + var numericValue = tokenFlags & 128 /* TokenFlags.BinarySpecifier */ ? parseInt(tokenValue.slice(2), 2) // skip "0b" - : tokenFlags & 256 /* OctalSpecifier */ + : tokenFlags & 256 /* TokenFlags.OctalSpecifier */ ? parseInt(tokenValue.slice(2), 8) // skip "0o" : +tokenValue; tokenValue = "" + numericValue; - return 8 /* NumericLiteral */; + return 8 /* SyntaxKind.NumericLiteral */; } } function scan() { var _a; startPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + if (ch === 35 /* CharacterCodes.hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { continue; } else { - return token = 6 /* ShebangTrivia */; + return token = 6 /* SyntaxKind.ShebangTrivia */; } } switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - tokenFlags |= 1 /* PrecedingLineBreak */; + case 10 /* CharacterCodes.lineFeed */: + case 13 /* CharacterCodes.carriageReturn */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; if (skipTrivia) { pos++; continue; } else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + if (ch === 13 /* CharacterCodes.carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { // consume both CR and LF pos += 2; } else { pos++; } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 5760 /* ogham */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 8287 /* mathematicalSpace */: - case 12288 /* ideographicSpace */: - case 65279 /* byteOrderMark */: + return token = 4 /* SyntaxKind.NewLineTrivia */; + } + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 160 /* CharacterCodes.nonBreakingSpace */: + case 5760 /* CharacterCodes.ogham */: + case 8192 /* CharacterCodes.enQuad */: + case 8193 /* CharacterCodes.emQuad */: + case 8194 /* CharacterCodes.enSpace */: + case 8195 /* CharacterCodes.emSpace */: + case 8196 /* CharacterCodes.threePerEmSpace */: + case 8197 /* CharacterCodes.fourPerEmSpace */: + case 8198 /* CharacterCodes.sixPerEmSpace */: + case 8199 /* CharacterCodes.figureSpace */: + case 8200 /* CharacterCodes.punctuationSpace */: + case 8201 /* CharacterCodes.thinSpace */: + case 8202 /* CharacterCodes.hairSpace */: + case 8203 /* CharacterCodes.zeroWidthSpace */: + case 8239 /* CharacterCodes.narrowNoBreakSpace */: + case 8287 /* CharacterCodes.mathematicalSpace */: + case 12288 /* CharacterCodes.ideographicSpace */: + case 65279 /* CharacterCodes.byteOrderMark */: if (skipTrivia) { pos++; continue; @@ -11574,98 +11690,98 @@ var ts; while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; + return token = 5 /* SyntaxKind.WhitespaceTrivia */; } - case 33 /* exclamation */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; + case 33 /* CharacterCodes.exclamation */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } - return pos += 2, token = 35 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* SyntaxKind.ExclamationEqualsToken */; } pos++; - return token = 53 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + return token = 53 /* SyntaxKind.ExclamationToken */; + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(); - return token = 10 /* StringLiteral */; - case 96 /* backtick */: + return token = 10 /* SyntaxKind.StringLiteral */; + case 96 /* CharacterCodes.backtick */: return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* PercentEqualsToken */; + case 37 /* CharacterCodes.percent */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 69 /* SyntaxKind.PercentEqualsToken */; } pos++; - return token = 44 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; + return token = 44 /* SyntaxKind.PercentToken */; + case 38 /* CharacterCodes.ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* CharacterCodes.ampersand */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */; } - return pos += 2, token = 55 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* SyntaxKind.AmpersandAmpersandToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* AmpersandEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 73 /* SyntaxKind.AmpersandEqualsToken */; } pos++; - return token = 50 /* AmpersandToken */; - case 40 /* openParen */: + return token = 50 /* SyntaxKind.AmpersandToken */; + case 40 /* CharacterCodes.openParen */: pos++; - return token = 20 /* OpenParenToken */; - case 41 /* closeParen */: + return token = 20 /* SyntaxKind.OpenParenToken */; + case 41 /* CharacterCodes.closeParen */: pos++; - return token = 21 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AsteriskEqualsToken */; + return token = 21 /* SyntaxKind.CloseParenToken */; + case 42 /* CharacterCodes.asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 66 /* SyntaxKind.AsteriskEqualsToken */; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 42 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* SyntaxKind.AsteriskAsteriskToken */; } pos++; - if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { + if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */)) { // decoration at the start of a JSDoc comment line asteriskSeen = true; continue; } - return token = 41 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 45 /* PlusPlusToken */; + return token = 41 /* SyntaxKind.AsteriskToken */; + case 43 /* CharacterCodes.plus */: + if (text.charCodeAt(pos + 1) === 43 /* CharacterCodes.plus */) { + return pos += 2, token = 45 /* SyntaxKind.PlusPlusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PlusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 64 /* SyntaxKind.PlusEqualsToken */; } pos++; - return token = 39 /* PlusToken */; - case 44 /* comma */: + return token = 39 /* SyntaxKind.PlusToken */; + case 44 /* CharacterCodes.comma */: pos++; - return token = 27 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 46 /* MinusMinusToken */; + return token = 27 /* SyntaxKind.CommaToken */; + case 45 /* CharacterCodes.minus */: + if (text.charCodeAt(pos + 1) === 45 /* CharacterCodes.minus */) { + return pos += 2, token = 46 /* SyntaxKind.MinusMinusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* MinusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 65 /* SyntaxKind.MinusEqualsToken */; } pos++; - return token = 40 /* MinusToken */; - case 46 /* dot */: + return token = 40 /* SyntaxKind.MinusToken */; + case 46 /* CharacterCodes.dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; - return token = 8 /* NumericLiteral */; + return token = 8 /* SyntaxKind.NumericLiteral */; } - if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 25 /* DotDotDotToken */; + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && text.charCodeAt(pos + 2) === 46 /* CharacterCodes.dot */) { + return pos += 3, token = 25 /* SyntaxKind.DotDotDotToken */; } pos++; - return token = 24 /* DotToken */; - case 47 /* slash */: + return token = 24 /* SyntaxKind.DotToken */; + case 47 /* CharacterCodes.slash */: // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < end) { if (isLineBreak(text.charCodeAt(pos))) { @@ -11678,20 +11794,20 @@ var ts; continue; } else { - return token = 2 /* SingleLineCommentTrivia */; + return token = 2 /* SyntaxKind.SingleLineCommentTrivia */; } } // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) { - tokenFlags |= 2 /* PrecedingJSDocComment */; + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) !== 47 /* CharacterCodes.slash */) { + tokenFlags |= 2 /* TokenFlags.PrecedingJSDocComment */; } var commentClosed = false; var lastLineStart = tokenPos; while (pos < end) { var ch_1 = text.charCodeAt(pos); - if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (ch_1 === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; commentClosed = true; break; @@ -11699,7 +11815,7 @@ var ts; pos++; if (isLineBreak(ch_1)) { lastLineStart = pos; - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; } } commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart); @@ -11711,18 +11827,18 @@ var ts; } else { if (!commentClosed) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; } - return token = 3 /* MultiLineCommentTrivia */; + return token = 3 /* SyntaxKind.MultiLineCommentTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* SlashEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 68 /* SyntaxKind.SlashEqualsToken */; } pos++; - return token = 43 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + return token = 43 /* SyntaxKind.SlashToken */; + case 48 /* CharacterCodes._0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* CharacterCodes.X */ || text.charCodeAt(pos + 1) === 120 /* CharacterCodes.x */)) { pos += 2; tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); if (!tokenValue) { @@ -11730,10 +11846,10 @@ var ts; tokenValue = "0"; } tokenValue = "0x" + tokenValue; - tokenFlags |= 64 /* HexSpecifier */; + tokenFlags |= 64 /* TokenFlags.HexSpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* CharacterCodes.B */ || text.charCodeAt(pos + 1) === 98 /* CharacterCodes.b */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 2); if (!tokenValue) { @@ -11741,10 +11857,10 @@ var ts; tokenValue = "0"; } tokenValue = "0b" + tokenValue; - tokenFlags |= 128 /* BinarySpecifier */; + tokenFlags |= 128 /* TokenFlags.BinarySpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* CharacterCodes.O */ || text.charCodeAt(pos + 1) === 111 /* CharacterCodes.o */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 8); if (!tokenValue) { @@ -11752,175 +11868,175 @@ var ts; tokenValue = "0"; } tokenValue = "0o" + tokenValue; - tokenFlags |= 256 /* OctalSpecifier */; + tokenFlags |= 256 /* TokenFlags.OctalSpecifier */; return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - tokenFlags |= 32 /* Octal */; - return token = 8 /* NumericLiteral */; + tokenFlags |= 32 /* TokenFlags.Octal */; + return token = 8 /* SyntaxKind.NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). // falls through - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: + case 49 /* CharacterCodes._1 */: + case 50 /* CharacterCodes._2 */: + case 51 /* CharacterCodes._3 */: + case 52 /* CharacterCodes._4 */: + case 53 /* CharacterCodes._5 */: + case 54 /* CharacterCodes._6 */: + case 55 /* CharacterCodes._7 */: + case 56 /* CharacterCodes._8 */: + case 57 /* CharacterCodes._9 */: (_a = scanNumber(), token = _a.type, tokenValue = _a.value); return token; - case 58 /* colon */: + case 58 /* CharacterCodes.colon */: pos++; - return token = 58 /* ColonToken */; - case 59 /* semicolon */: + return token = 58 /* SyntaxKind.ColonToken */; + case 59 /* CharacterCodes.semicolon */: pos++; - return token = 26 /* SemicolonToken */; - case 60 /* lessThan */: + return token = 26 /* SyntaxKind.SemicolonToken */; + case 60 /* CharacterCodes.lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 70 /* SyntaxKind.LessThanLessThanEqualsToken */; } - return pos += 2, token = 47 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* SyntaxKind.LessThanLessThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 32 /* LessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 32 /* SyntaxKind.LessThanEqualsToken */; } - if (languageVariant === 1 /* JSX */ && - text.charCodeAt(pos + 1) === 47 /* slash */ && - text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 30 /* LessThanSlashToken */; + if (languageVariant === 1 /* LanguageVariant.JSX */ && + text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */ && + text.charCodeAt(pos + 2) !== 42 /* CharacterCodes.asterisk */) { + return pos += 2, token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; - case 61 /* equals */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 61 /* CharacterCodes.equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 36 /* SyntaxKind.EqualsEqualsEqualsToken */; } - return pos += 2, token = 34 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* SyntaxKind.EqualsEqualsToken */; } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 38 /* EqualsGreaterThanToken */; + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + return pos += 2, token = 38 /* SyntaxKind.EqualsGreaterThanToken */; } pos++; - return token = 63 /* EqualsToken */; - case 62 /* greaterThan */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } pos++; - return token = 31 /* GreaterThanToken */; - case 63 /* question */: - if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) { - return pos += 2, token = 28 /* QuestionDotToken */; + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 63 /* CharacterCodes.question */: + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && !isDigit(text.charCodeAt(pos + 2))) { + return pos += 2, token = 28 /* SyntaxKind.QuestionDotToken */; } - if (text.charCodeAt(pos + 1) === 63 /* question */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; + if (text.charCodeAt(pos + 1) === 63 /* CharacterCodes.question */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } - return pos += 2, token = 60 /* QuestionQuestionToken */; + return pos += 2, token = 60 /* SyntaxKind.QuestionQuestionToken */; } pos++; - return token = 57 /* QuestionToken */; - case 91 /* openBracket */: + return token = 57 /* SyntaxKind.QuestionToken */; + case 91 /* CharacterCodes.openBracket */: pos++; - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: pos++; - return token = 23 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 78 /* CaretEqualsToken */; + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 94 /* CharacterCodes.caret */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 78 /* SyntaxKind.CaretEqualsToken */; } pos++; - return token = 52 /* CaretToken */; - case 123 /* openBrace */: + return token = 52 /* SyntaxKind.CaretToken */; + case 123 /* CharacterCodes.openBrace */: pos++; - return token = 18 /* OpenBraceToken */; - case 124 /* bar */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 124 /* CharacterCodes.bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 75 /* BarBarEqualsToken */; + if (text.charCodeAt(pos + 1) === 124 /* CharacterCodes.bar */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 75 /* SyntaxKind.BarBarEqualsToken */; } - return pos += 2, token = 56 /* BarBarToken */; + return pos += 2, token = 56 /* SyntaxKind.BarBarToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 74 /* BarEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 74 /* SyntaxKind.BarEqualsToken */; } pos++; - return token = 51 /* BarToken */; - case 125 /* closeBrace */: + return token = 51 /* SyntaxKind.BarToken */; + case 125 /* CharacterCodes.closeBrace */: pos++; - return token = 19 /* CloseBraceToken */; - case 126 /* tilde */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 126 /* CharacterCodes.tilde */: pos++; - return token = 54 /* TildeToken */; - case 64 /* at */: + return token = 54 /* SyntaxKind.TildeToken */; + case 64 /* CharacterCodes.at */: pos++; - return token = 59 /* AtToken */; - case 92 /* backslash */: + return token = 59 /* SyntaxKind.AtToken */; + case 92 /* CharacterCodes.backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } error(ts.Diagnostics.Invalid_character); pos++; - return token = 0 /* Unknown */; - case 35 /* hash */: + return token = 0 /* SyntaxKind.Unknown */; + case 35 /* CharacterCodes.hash */: if (pos !== 0 && text[pos + 1] === "!") { error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file); pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; @@ -11930,7 +12046,7 @@ var ts; tokenValue = String.fromCharCode(codePointAt(text, pos)); error(ts.Diagnostics.Invalid_character, pos++, charSize(ch)); } - return token = 80 /* PrivateIdentifier */; + return token = 80 /* SyntaxKind.PrivateIdentifier */; default: var identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { @@ -11941,23 +12057,23 @@ var ts; continue; } else if (isLineBreak(ch)) { - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; pos += charSize(ch); continue; } var size = charSize(ch); error(ts.Diagnostics.Invalid_character, pos, size); pos += size; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } } function reScanInvalidIdentifier() { - ts.Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); + ts.Debug.assert(token === 0 /* SyntaxKind.Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); pos = tokenPos = startPos; tokenFlags = 0; var ch = codePointAt(text, pos); - var identifierKind = scanIdentifier(ch, 99 /* ESNext */); + var identifierKind = scanIdentifier(ch, 99 /* ScriptTarget.ESNext */); if (identifierKind) { return token = identifierKind; } @@ -11971,41 +12087,41 @@ var ts; while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { + if (ch === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return getIdentifierToken(); } } function reScanGreaterToken() { - if (token === 31 /* GreaterThanToken */) { - if (text.charCodeAt(pos) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + if (text.charCodeAt(pos) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 48 /* GreaterThanGreaterThanToken */; + return token = 48 /* SyntaxKind.GreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos) === 61 /* equals */) { + if (text.charCodeAt(pos) === 61 /* CharacterCodes.equals */) { pos++; - return token = 33 /* GreaterThanEqualsToken */; + return token = 33 /* SyntaxKind.GreaterThanEqualsToken */; } } return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* SyntaxKind.AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 63 /* EqualsToken */; + return token = 63 /* SyntaxKind.EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { + if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -12013,13 +12129,13 @@ var ts; // If we reach the end of a file, or hit a newline, then this is an unterminated // regex. Report error and return what we have so far. if (p >= end) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -12028,19 +12144,19 @@ var ts; // reset the flag and just advance to the next char. inEscape = false; } - else if (ch === 47 /* slash */ && !inCharacterClass) { + else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) { // A slash within a character class is permissible, // but in general it signals the end of the regexp literal. p++; break; } - else if (ch === 91 /* openBracket */) { + else if (ch === 91 /* CharacterCodes.openBracket */) { inCharacterClass = true; } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { inEscape = true; } - else if (ch === 93 /* closeBracket */) { + else if (ch === 93 /* CharacterCodes.closeBracket */) { inCharacterClass = false; } p++; @@ -12050,7 +12166,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 13 /* RegularExpressionLiteral */; + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } return token; } @@ -12071,9 +12187,9 @@ var ts; } switch (match[1]) { case "ts-expect-error": - return 0 /* ExpectError */; + return 0 /* CommentDirectiveType.ExpectError */; case "ts-ignore": - return 1 /* Ignore */; + return 1 /* CommentDirectiveType.Ignore */; } return undefined; } @@ -12081,7 +12197,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken(isTaggedTemplate) { - ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* SyntaxKind.CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(isTaggedTemplate); } @@ -12095,42 +12211,42 @@ var ts; return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { - if (token === 47 /* LessThanLessThanToken */) { + if (token === 47 /* SyntaxKind.LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } return token; } function reScanHashToken() { - if (token === 80 /* PrivateIdentifier */) { + if (token === 80 /* SyntaxKind.PrivateIdentifier */) { pos = tokenPos + 1; - return token = 62 /* HashToken */; + return token = 62 /* SyntaxKind.HashToken */; } return token; } function reScanQuestionToken() { - ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + ts.Debug.assert(token === 60 /* SyntaxKind.QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; - return token = 57 /* QuestionToken */; + return token = 57 /* SyntaxKind.QuestionToken */; } function scanJsxToken(allowMultilineJsxText) { if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (char === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; - return token = 30 /* LessThanSlashToken */; + return token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { pos++; - return token = 18 /* OpenBraceToken */; + return token = 18 /* SyntaxKind.OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -12138,20 +12254,20 @@ var ts; // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { break; } - if (char === 60 /* lessThan */) { + if (char === 60 /* CharacterCodes.lessThan */) { if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } break; } - if (char === 62 /* greaterThan */) { + if (char === 62 /* CharacterCodes.greaterThan */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1); } - if (char === 125 /* closeBrace */) { + if (char === 125 /* CharacterCodes.closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. @@ -12174,7 +12290,7 @@ var ts; pos++; } tokenValue = text.substring(startPos, pos); - return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* SyntaxKind.JsxTextAllWhiteSpaces */ : 11 /* SyntaxKind.JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -12187,16 +12303,16 @@ var ts; var namespaceSeparator = false; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */) { + if (ch === 45 /* CharacterCodes.minus */) { tokenValue += "-"; pos++; continue; } - else if (ch === 58 /* colon */ && !namespaceSeparator) { + else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) { tokenValue += ":"; pos++; namespaceSeparator = true; - token = 79 /* Identifier */; // swap from keyword kind to identifier kind + token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -12217,10 +12333,10 @@ var ts; function scanJsxAttributeValue() { startPos = pos; switch (text.charCodeAt(pos)) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 10 /* StringLiteral */; + return token = 10 /* SyntaxKind.StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -12232,86 +12348,86 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); pos += charSize(ch); switch (ch) { - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; - case 64 /* at */: - return token = 59 /* AtToken */; - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + return token = 5 /* SyntaxKind.WhitespaceTrivia */; + case 64 /* CharacterCodes.at */: + return token = 59 /* SyntaxKind.AtToken */; + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - tokenFlags |= 1 /* PrecedingLineBreak */; - return token = 4 /* NewLineTrivia */; - case 42 /* asterisk */: - return token = 41 /* AsteriskToken */; - case 123 /* openBrace */: - return token = 18 /* OpenBraceToken */; - case 125 /* closeBrace */: - return token = 19 /* CloseBraceToken */; - case 91 /* openBracket */: - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: - return token = 23 /* CloseBracketToken */; - case 60 /* lessThan */: - return token = 29 /* LessThanToken */; - case 62 /* greaterThan */: - return token = 31 /* GreaterThanToken */; - case 61 /* equals */: - return token = 63 /* EqualsToken */; - case 44 /* comma */: - return token = 27 /* CommaToken */; - case 46 /* dot */: - return token = 24 /* DotToken */; - case 96 /* backtick */: - return token = 61 /* BacktickToken */; - case 35 /* hash */: - return token = 62 /* HashToken */; - case 92 /* backslash */: + case 10 /* CharacterCodes.lineFeed */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; + return token = 4 /* SyntaxKind.NewLineTrivia */; + case 42 /* CharacterCodes.asterisk */: + return token = 41 /* SyntaxKind.AsteriskToken */; + case 123 /* CharacterCodes.openBrace */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 125 /* CharacterCodes.closeBrace */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 91 /* CharacterCodes.openBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 60 /* CharacterCodes.lessThan */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 62 /* CharacterCodes.greaterThan */: + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 61 /* CharacterCodes.equals */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 44 /* CharacterCodes.comma */: + return token = 27 /* SyntaxKind.CommaToken */; + case 46 /* CharacterCodes.dot */: + return token = 24 /* SyntaxKind.DotToken */; + case 96 /* CharacterCodes.backtick */: + return token = 61 /* SyntaxKind.BacktickToken */; + case 35 /* CharacterCodes.hash */: + return token = 62 /* SyntaxKind.HashToken */; + case 92 /* CharacterCodes.backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); - if (char === 92 /* backslash */) { + if (char === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return token = getIdentifierToken(); } else { - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } function speculationHelper(callback, isLookahead) { @@ -12386,9 +12502,9 @@ var ts; pos = textPos; startPos = textPos; tokenPos = textPos; - token = 0 /* Unknown */; + token = 0 /* SyntaxKind.Unknown */; tokenValue = undefined; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -12454,23 +12570,23 @@ var ts; ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; function getDefaultLibFileName(options) { switch (ts.getEmitScriptTarget(options)) { - case 99 /* ESNext */: + case 99 /* ScriptTarget.ESNext */: return "lib.esnext.full.d.ts"; - case 9 /* ES2022 */: + case 9 /* ScriptTarget.ES2022 */: return "lib.es2022.full.d.ts"; - case 8 /* ES2021 */: + case 8 /* ScriptTarget.ES2021 */: return "lib.es2021.full.d.ts"; - case 7 /* ES2020 */: + case 7 /* ScriptTarget.ES2020 */: return "lib.es2020.full.d.ts"; - case 6 /* ES2019 */: + case 6 /* ScriptTarget.ES2019 */: return "lib.es2019.full.d.ts"; - case 5 /* ES2018 */: + case 5 /* ScriptTarget.ES2018 */: return "lib.es2018.full.d.ts"; - case 4 /* ES2017 */: + case 4 /* ScriptTarget.ES2017 */: return "lib.es2017.full.d.ts"; - case 3 /* ES2016 */: + case 3 /* ScriptTarget.ES2016 */: return "lib.es2016.full.d.ts"; - case 2 /* ES2015 */: + case 2 /* ScriptTarget.ES2015 */: return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; @@ -12678,9 +12794,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 163 /* TypeParameter */) { + if (d && d.kind === 163 /* SyntaxKind.TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return current; } } @@ -12688,7 +12804,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 171 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) && parent.kind === 171 /* SyntaxKind.Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12718,14 +12834,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 254 /* VariableDeclaration */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 255 /* VariableDeclarationList */) { + if (node && node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 237 /* VariableStatement */) { + if (node && node.kind === 237 /* SyntaxKind.VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12839,7 +12955,7 @@ var ts; * @param node The node to test. */ function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + return (node.flags & 8 /* NodeFlags.Synthesized */) === 0; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { @@ -12857,7 +12973,7 @@ var ts; ts.getParseTreeNode = getParseTreeNode; /** Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' */ function escapeLeadingUnderscores(identifier) { - return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); + return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* CharacterCodes._ */ && identifier.charCodeAt(1) === 95 /* CharacterCodes._ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; /** @@ -12868,7 +12984,7 @@ var ts; */ function unescapeLeadingUnderscores(identifier) { var id = identifier; - return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id; + return id.length >= 3 && id.charCodeAt(0) === 95 /* CharacterCodes._ */ && id.charCodeAt(1) === 95 /* CharacterCodes._ */ && id.charCodeAt(2) === 95 /* CharacterCodes._ */ ? id.substr(1) : id; } ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores; function idText(identifierOrPrivateName) { @@ -12898,30 +13014,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 221 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { + if (expr.kind === 221 /* SyntaxKind.BinaryExpression */ && expr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return expr.name; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12956,42 +13072,42 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return declaration; - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: { + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 161 /* QualifiedName */) { + if (name.kind === 161 /* SyntaxKind.QualifiedName */) { return name.right; } break; } - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { - case 1 /* ExportsProperty */: - case 4 /* ThisProperty */: - case 5 /* Property */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return expr_1.arguments[1]; default: return undefined; } } - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 339 /* JSDocEnumTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -13035,7 +13151,7 @@ var ts; } ts.getDecorators = getDecorators; function getModifiers(node) { - if (ts.hasSyntacticModifier(node, 125951 /* Modifier */)) { + if (ts.hasSyntacticModifier(node, 125951 /* ModifierFlags.Modifier */)) { return ts.filter(node.modifiers, isModifier); } } @@ -13296,27 +13412,33 @@ var ts; /** Gets the text of a jsdoc comment, flattening links to their text. */ function getTextOfJSDocComment(comment) { return typeof comment === "string" ? comment - : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* SyntaxKind.JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; function formatJSDocLink(link) { - var kind = link.kind === 324 /* JSDocLink */ ? "link" - : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" + var kind = link.kind === 324 /* SyntaxKind.JSDocLink */ ? "link" + : link.kind === 325 /* SyntaxKind.JSDocLinkCode */ ? "linkcode" : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. + * + * This does *not* return type parameters from a jsdoc reference to a generic type, eg + * + * type Id = (x: T) => T + * /** @type {Id} / + * function id(x) { return x } */ function getEffectiveTypeParameterDeclarations(node) { if (ts.isJSDocSignature(node)) { return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 320 /* JSDoc */); + ts.Debug.assert(node.parent.kind === 320 /* SyntaxKind.JSDoc */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13346,33 +13468,33 @@ var ts; ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region function isMemberName(node) { - return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; + return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */ || node.kind === 172 /* GetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */ || node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { - return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessChain(node) { - return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isElementAccessChain = isElementAccessChain; function isCallChain(node) { - return ts.isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isCallExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isCallChain = isCallChain; function isOptionalChain(node) { var kind = node.kind; - return !!(node.flags & 32 /* OptionalChain */) && - (kind === 206 /* PropertyAccessExpression */ - || kind === 207 /* ElementAccessExpression */ - || kind === 208 /* CallExpression */ - || kind === 230 /* NonNullExpression */); + return !!(node.flags & 32 /* NodeFlags.OptionalChain */) && + (kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 207 /* SyntaxKind.ElementAccessExpression */ + || kind === 208 /* SyntaxKind.CallExpression */ + || kind === 230 /* SyntaxKind.NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -13407,7 +13529,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -13416,25 +13538,25 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function skipPartiallyEmittedExpressions(node) { - return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */); + return ts.skipOuterExpressions(node, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isNonNullChain(node) { - return ts.isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isNonNullExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 246 /* BreakStatement */ || node.kind === 245 /* ContinueStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */ || node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 274 /* NamespaceExport */ || node.kind === 273 /* NamedExports */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return true; default: return false; @@ -13443,12 +13565,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 300 /* UnparsedPrologue */ || - node.kind === 304 /* UnparsedSyntheticReference */; + node.kind === 300 /* SyntaxKind.UnparsedPrologue */ || + node.kind === 304 /* SyntaxKind.UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 347 /* JSDocPropertyTag */ || node.kind === 340 /* JSDocParameterTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */ || node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -13464,7 +13586,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 161 /* FirstNode */; + return kind >= 161 /* SyntaxKind.FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13473,7 +13595,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 160 /* LastToken */; + return kind >= 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -13494,7 +13616,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; + return 8 /* SyntaxKind.FirstLiteralToken */ <= kind && kind <= 14 /* SyntaxKind.LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13504,11 +13626,11 @@ var ts; /** @internal */ function isLiteralExpressionOfObject(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 13 /* RegularExpressionLiteral */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; } return false; @@ -13517,7 +13639,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; + return 14 /* SyntaxKind.FirstTemplateToken */ <= kind && kind <= 17 /* SyntaxKind.LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13526,8 +13648,8 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 16 /* TemplateMiddle */ - || kind === 17 /* TemplateTail */; + return kind === 16 /* SyntaxKind.TemplateMiddle */ + || kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isImportOrExportSpecifier(node) { @@ -13536,13 +13658,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.isTypeOnly || node.parent.parent.isTypeOnly; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.isTypeOnly; - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -13554,13 +13676,13 @@ var ts; } ts.isAssertionKey = isAssertionKey; function isStringTextContainingNode(node) { - return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* SyntaxKind.StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; + return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) > 0 /* GeneratedIdentifierFlags.None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers @@ -13578,20 +13700,20 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 88 /* DefaultKeyword */: - case 93 /* ExportKeyword */: - case 101 /* InKeyword */: - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 124 /* StaticKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; } return false; @@ -13599,12 +13721,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ModifierFlags.ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 159 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* SyntaxKind.StaticKeyword */ || idToken === 159 /* SyntaxKind.OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13613,24 +13735,24 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 80 /* PrivateIdentifier */ - || kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 162 /* ComputedPropertyName */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 80 /* SyntaxKind.PrivateIdentifier */ + || kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */ + || kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 201 /* ObjectBindingPattern */ - || kind === 202 /* ArrayBindingPattern */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */ + || kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13650,18 +13772,18 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; /* @internal */ function isBooleanLiteral(node) { - return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */; + return node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */; } ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -13670,14 +13792,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 180 /* ConstructorType */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13692,30 +13814,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 234 /* SemicolonClassElement */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */); + return node && (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */); + return node && (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -13729,13 +13851,13 @@ var ts; ts.isModifierLike = isModifierLike; function isTypeElement(node) { var kind = node.kind; - return kind === 175 /* ConstructSignature */ - || kind === 174 /* CallSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */ - || kind === 176 /* IndexSignature */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 174 /* SyntaxKind.CallSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13744,12 +13866,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 298 /* SpreadAssignment */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 298 /* SyntaxKind.SpreadAssignment */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13764,8 +13886,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; } return false; @@ -13776,8 +13898,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 202 /* ArrayBindingPattern */ - || kind === 201 /* ObjectBindingPattern */; + return kind === 202 /* SyntaxKind.ArrayBindingPattern */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */; } return false; } @@ -13785,15 +13907,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 204 /* ArrayLiteralExpression */ - || kind === 205 /* ObjectLiteralExpression */; + return kind === 204 /* SyntaxKind.ArrayLiteralExpression */ + || kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 203 /* BindingElement */ - || kind === 227 /* OmittedExpression */; + return kind === 203 /* SyntaxKind.BindingElement */ + || kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13802,9 +13924,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: return true; } return false; @@ -13825,8 +13947,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return true; } return false; @@ -13835,10 +13957,10 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentElement(node) { switch (node.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: // AssignmentProperty - case 297 /* ShorthandPropertyAssignment */: // AssignmentProperty - case 298 /* SpreadAssignment */: // AssignmentRestProperty + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: // AssignmentProperty + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // AssignmentProperty + case 298 /* SyntaxKind.SpreadAssignment */: // AssignmentRestProperty return true; } return false; @@ -13850,8 +13972,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; } return false; @@ -13860,26 +13982,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */ - || kind === 200 /* ImportType */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 200 /* SyntaxKind.ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: return true; default: return false; @@ -13887,13 +14009,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 208 /* CallExpression */ || node.kind === 209 /* NewExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */ || node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 223 /* TemplateExpression */ - || kind === 14 /* NoSubstitutionTemplateLiteral */; + return kind === 223 /* SyntaxKind.TemplateExpression */ + || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13903,36 +14025,36 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 209 /* NewExpression */: - case 208 /* CallExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 210 /* TaggedTemplateExpression */: - case 204 /* ArrayLiteralExpression */: - case 212 /* ParenthesizedExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression - case 13 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 110 /* TrueKeyword */: - case 106 /* SuperKeyword */: - case 230 /* NonNullExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 231 /* MetaProperty */: - case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 230 /* SyntaxKind.NonNullExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 231 /* SyntaxKind.MetaProperty */: + case 100 /* SyntaxKind.ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13945,13 +14067,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 218 /* AwaitExpression */: - case 211 /* TypeAssertionExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13960,11 +14082,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 45 /* PlusPlusToken */ || - expr.operator === 46 /* MinusMinusToken */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || + expr.operator === 46 /* SyntaxKind.MinusMinusToken */; default: return false; } @@ -13981,15 +14103,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - case 214 /* ArrowFunction */: - case 221 /* BinaryExpression */: - case 225 /* SpreadElement */: - case 229 /* AsExpression */: - case 227 /* OmittedExpression */: - case 351 /* CommaListExpression */: - case 350 /* PartiallyEmittedExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 221 /* SyntaxKind.BinaryExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 229 /* SyntaxKind.AsExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13997,8 +14119,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 211 /* TypeAssertionExpression */ - || kind === 229 /* AsExpression */; + return kind === 211 /* SyntaxKind.TypeAssertionExpression */ + || kind === 229 /* SyntaxKind.AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -14009,13 +14131,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14033,18 +14155,18 @@ var ts; ts.hasScopeMarker = hasScopeMarker; /* @internal */ function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */) && !ts.isAmbientModule(result); } ts.needsScopeMarker = needsScopeMarker; /* @internal */ function isExternalModuleIndicator(result) { // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* Export */); + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */); } ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 243 /* ForInStatement */ || node.kind === 244 /* ForOfStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */ || node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14068,115 +14190,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */ - || kind === 79 /* Identifier */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 261 /* ModuleDeclaration */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 269 /* NamedImports */ - || kind === 268 /* NamespaceImport */; + return kind === 269 /* SyntaxKind.NamedImports */ + || kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ || node.kind === 260 /* EnumDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 214 /* ArrowFunction */ - || kind === 203 /* BindingElement */ - || kind === 257 /* ClassDeclaration */ - || kind === 226 /* ClassExpression */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 171 /* Constructor */ - || kind === 260 /* EnumDeclaration */ - || kind === 299 /* EnumMember */ - || kind === 275 /* ExportSpecifier */ - || kind === 256 /* FunctionDeclaration */ - || kind === 213 /* FunctionExpression */ - || kind === 172 /* GetAccessor */ - || kind === 267 /* ImportClause */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 270 /* ImportSpecifier */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 285 /* JsxAttribute */ - || kind === 169 /* MethodDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 261 /* ModuleDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 268 /* NamespaceImport */ - || kind === 274 /* NamespaceExport */ - || kind === 164 /* Parameter */ - || kind === 296 /* PropertyAssignment */ - || kind === 167 /* PropertyDeclaration */ - || kind === 166 /* PropertySignature */ - || kind === 173 /* SetAccessor */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 163 /* TypeParameter */ - || kind === 254 /* VariableDeclaration */ - || kind === 345 /* JSDocTypedefTag */ - || kind === 338 /* JSDocCallbackTag */ - || kind === 347 /* JSDocPropertyTag */; + return kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 203 /* SyntaxKind.BindingElement */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 299 /* SyntaxKind.EnumMember */ + || kind === 275 /* SyntaxKind.ExportSpecifier */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 267 /* SyntaxKind.ImportClause */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 270 /* SyntaxKind.ImportSpecifier */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 268 /* SyntaxKind.NamespaceImport */ + || kind === 274 /* SyntaxKind.NamespaceExport */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 254 /* SyntaxKind.VariableDeclaration */ + || kind === 345 /* SyntaxKind.JSDocTypedefTag */ + || kind === 338 /* SyntaxKind.JSDocCallbackTag */ + || kind === 347 /* SyntaxKind.JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 246 /* BreakStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 240 /* DoStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 236 /* EmptyStatement */ - || kind === 243 /* ForInStatement */ - || kind === 244 /* ForOfStatement */ - || kind === 242 /* ForStatement */ - || kind === 239 /* IfStatement */ - || kind === 250 /* LabeledStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 249 /* SwitchStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 252 /* TryStatement */ - || kind === 237 /* VariableStatement */ - || kind === 241 /* WhileStatement */ - || kind === 248 /* WithStatement */ - || kind === 349 /* NotEmittedStatement */ - || kind === 353 /* EndOfDeclarationMarker */ - || kind === 352 /* MergeDeclarationMarker */; + return kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 236 /* SyntaxKind.EmptyStatement */ + || kind === 243 /* SyntaxKind.ForInStatement */ + || kind === 244 /* SyntaxKind.ForOfStatement */ + || kind === 242 /* SyntaxKind.ForStatement */ + || kind === 239 /* SyntaxKind.IfStatement */ + || kind === 250 /* SyntaxKind.LabeledStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 249 /* SyntaxKind.SwitchStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 252 /* SyntaxKind.TryStatement */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 241 /* SyntaxKind.WhileStatement */ + || kind === 248 /* SyntaxKind.WithStatement */ + || kind === 349 /* SyntaxKind.NotEmittedStatement */ + || kind === 353 /* SyntaxKind.EndOfDeclarationMarker */ + || kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 163 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 344 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { + return (node.parent && node.parent.kind !== 344 /* SyntaxKind.JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14203,10 +14325,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 235 /* Block */) + if (node.kind !== 235 /* SyntaxKind.Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 252 /* TryStatement */ || node.parent.kind === 292 /* CatchClause */) { + if (node.parent.kind === 252 /* SyntaxKind.TryStatement */ || node.parent.kind === 292 /* SyntaxKind.CatchClause */) { return false; } } @@ -14220,76 +14342,76 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 235 /* Block */; + || kind === 235 /* SyntaxKind.Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 277 /* ExternalModuleReference */ - || kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 277 /* SyntaxKind.ExternalModuleReference */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 108 /* ThisKeyword */ - || kind === 79 /* Identifier */ - || kind === 206 /* PropertyAccessExpression */; + return kind === 108 /* SyntaxKind.ThisKeyword */ + || kind === 79 /* SyntaxKind.Identifier */ + || kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 278 /* JsxElement */ - || kind === 288 /* JsxExpression */ - || kind === 279 /* JsxSelfClosingElement */ - || kind === 11 /* JsxText */ - || kind === 282 /* JsxFragment */; + return kind === 278 /* SyntaxKind.JsxElement */ + || kind === 288 /* SyntaxKind.JsxExpression */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */ + || kind === 11 /* SyntaxKind.JsxText */ + || kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 285 /* JsxAttribute */ - || kind === 287 /* JsxSpreadAttribute */; + return kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 288 /* JsxExpression */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 288 /* SyntaxKind.JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 280 /* JsxOpeningElement */ - || kind === 279 /* JsxSelfClosingElement */; + return kind === 280 /* SyntaxKind.JsxOpeningElement */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 289 /* CaseClause */ - || kind === 290 /* DefaultClause */; + return kind === 289 /* SyntaxKind.CaseClause */ + || kind === 290 /* SyntaxKind.DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 309 /* FirstJSDocNode */ && node.kind <= 347 /* LastJSDocNode */; + return node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 320 /* JSDoc */ - || node.kind === 319 /* JSDocNamepathType */ - || node.kind === 321 /* JSDocText */ + return node.kind === 320 /* SyntaxKind.JSDoc */ + || node.kind === 319 /* SyntaxKind.JSDocNamepathType */ + || node.kind === 321 /* SyntaxKind.JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) @@ -14299,15 +14421,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 327 /* FirstJSDocTagNode */ && node.kind <= 347 /* LastJSDocTagNode */; + return node.kind >= 327 /* SyntaxKind.FirstJSDocTagNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14333,12 +14455,12 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: return true; default: return false; @@ -14346,12 +14468,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 285 /* JsxAttribute */ || node.kind === 287 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 285 /* SyntaxKind.JsxAttribute */ || node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 178 /* TypeReference */ || node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14380,11 +14502,11 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */ || node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; function isJSDocLinkLike(node) { - return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 324 /* SyntaxKind.JSDocLink */ || node.kind === 325 /* SyntaxKind.JSDocLinkCode */ || node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkLike = isJSDocLinkLike; function hasRestParameter(s) { @@ -14394,7 +14516,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isRestParameter = isRestParameter; // #endregion @@ -14435,7 +14557,7 @@ var ts; } ts.createSymbolTable = createSymbolTable; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } ts.isTransientSymbol = isTransientSymbol; var stringWriter = createSingleLineStringWriter(); @@ -14596,11 +14718,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -14631,28 +14753,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 1048576 /* HasAggregatedChildData */)) { + if (!(node.flags & 1048576 /* NodeFlags.HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* NodeFlags.ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 1048576 /* HasAggregatedChildData */; + node.flags |= 1048576 /* NodeFlags.HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 305 /* SourceFile */) { + while (node && node.kind !== 305 /* SyntaxKind.SourceFile */) { node = node.parent; } return node; @@ -14663,16 +14785,16 @@ var ts; } ts.getSourceFileOfModule = getSourceFileOfModule; function isPlainJsFile(file, checkJs) { - return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined; + return !!file && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */) && !file.checkJsDirective && checkJs === undefined; } ts.isPlainJsFile = isPlainJsFile; function isStatementWithLocals(node) { switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return true; } return false; @@ -14687,7 +14809,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -14740,7 +14862,7 @@ var ts; if (node === undefined) { return true; } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -14774,7 +14896,7 @@ var ts; return to; } function isAnyPrologueDirective(node) { - return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } /** * Prepends statements to an array while taking care of prologue directives. @@ -14806,9 +14928,9 @@ var ts; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments - if (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + if (text.charCodeAt(commentPos + 1) === 47 /* CharacterCodes.slash */ && commentPos + 2 < commentEnd && - text.charCodeAt(commentPos + 2) === 47 /* slash */) { + text.charCodeAt(commentPos + 2) === 47 /* CharacterCodes.slash */) { var textSubStr = text.substring(commentPos, commentEnd); return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || @@ -14820,13 +14942,13 @@ var ts; } ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; function isPinnedComment(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 33 /* exclamation */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 33 /* CharacterCodes.exclamation */; } ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -14835,7 +14957,7 @@ var ts; return ts.arrayFrom(directivesByLine.entries()) .filter(function (_a) { var line = _a[0], directive = _a[1]; - return directive.type === 0 /* ExpectError */ && !usedLines.get(line); + return directive.type === 0 /* CommentDirectiveType.ExpectError */ && !usedLines.get(line); }) .map(function (_a) { var _ = _a[0], directive = _a[1]; @@ -14843,10 +14965,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -14857,7 +14979,7 @@ var ts; if (nodeIsMissing(node)) { return node.pos; } - if (ts.isJSDocNode(node) || node.kind === 11 /* JsxText */) { + if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) { // JsxText cannot actually contain comments, even though the scanner will think it sees comments return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } @@ -14868,7 +14990,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 348 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -15036,56 +15158,56 @@ var ts; // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { - case 10 /* StringLiteral */: { - var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : - flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + case 10 /* SyntaxKind.StringLiteral */: { + var escapeText = flags & 2 /* GetLiteralTextFlags.JsxAttributeEscape */ ? escapeJsxAttributeString : + flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; if (node.singleQuote) { - return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + return "'" + escapeText(node.text, 39 /* CharacterCodes.singleQuote */) + "'"; } else { - return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + return '"' + escapeText(node.text, 34 /* CharacterCodes.doubleQuote */) + '"'; } } - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: { // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. - var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; - var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* CharacterCodes.backtick */)); switch (node.kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return "`" + rawText + "${"; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: return "}" + rawText + "${"; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: return "}" + rawText + "`"; } break; } - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return node.text; - case 13 /* RegularExpressionLiteral */: - if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) { - return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/"); + case 13 /* SyntaxKind.RegularExpressionLiteral */: + if (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) { + return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* CharacterCodes.backslash */ ? " /" : "/"); } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { - if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated)) { + if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) { return false; } - if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) { - return !!(flags & 8 /* AllowNumericSeparator */); + if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) { + return !!(flags & 8 /* GetLiteralTextFlags.AllowNumericSeparator */); } return !ts.isBigIntLiteral(node); } @@ -15100,21 +15222,21 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || + return (ts.getCombinedNodeFlags(declaration) & 3 /* NodeFlags.BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* SyntaxKind.StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -15138,16 +15260,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return !!node && node.kind === 261 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 305 /* SourceFile */ || - node.kind === 261 /* ModuleDeclaration */ || + return node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 1024 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* NodeFlags.GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -15159,9 +15281,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return ts.isExternalModule(node.parent); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -15185,10 +15307,10 @@ var ts; function isEffectiveStrictModeSourceFile(node, compilerOptions) { // We can only verify strict mode for JS/TS files switch (node.scriptKind) { - case 1 /* JS */: - case 3 /* TS */: - case 2 /* JSX */: - case 4 /* TSX */: + case 1 /* ScriptKind.JS */: + case 3 /* ScriptKind.TS */: + case 2 /* ScriptKind.JSX */: + case 4 /* ScriptKind.TSX */: break; default: return false; @@ -15218,24 +15340,24 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 292 /* CatchClause */: - case 261 /* ModuleDeclaration */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 167 /* PropertyDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 292 /* SyntaxKind.CatchClause */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); @@ -15245,9 +15367,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 323 /* JSDocSignature */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 323 /* SyntaxKind.JSDocSignature */: return true; default: ts.assertType(node); @@ -15257,25 +15379,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: ts.assertType(node); @@ -15285,8 +15407,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -15299,15 +15421,15 @@ var ts; ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 237 /* VariableStatement */: - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return true; default: return false; @@ -15348,19 +15470,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 162 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function tryGetTextOfPropertyName(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return undefined; @@ -15375,21 +15497,21 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return "this"; - case 80 /* PrivateIdentifier */: - case 79 /* Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); @@ -15479,7 +15601,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 235 /* Block */) { + if (node.body && node.body.kind === 235 /* SyntaxKind.Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -15493,7 +15615,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -15502,29 +15624,29 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 268 /* NamespaceImport */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 268 /* SyntaxKind.NamespaceImport */: errorNode = node.name; break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -15556,36 +15678,36 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isJsonSourceFile(file) { - return file.scriptKind === 6 /* JSON */; + return file.scriptKind === 6 /* ScriptKind.JSON */; } ts.isJsonSourceFile = isJsonSourceFile; function isEnumConst(node) { - return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(ts.getCombinedModifierFlags(node) & 2048 /* ModifierFlags.Const */); } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* ModifierFlags.Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); + return !!(ts.getCombinedNodeFlags(node) & 2 /* NodeFlags.Const */); } ts.isVarConst = isVarConst; function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); + return !!(ts.getCombinedNodeFlags(node) & 1 /* NodeFlags.Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 100 /* ImportKeyword */ + && n.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -15594,12 +15716,12 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 238 /* ExpressionStatement */ - && node.expression.kind === 10 /* StringLiteral */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */ + && node.expression.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isCustomPrologue(node) { - return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } ts.isCustomPrologue = isCustomPrologue; function isHoistedFunction(node) { @@ -15618,24 +15740,24 @@ var ts; } ts.isHoistedVariableStatement = isHoistedVariableStatement; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* SyntaxKind.JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 164 /* Parameter */ || - node.kind === 163 /* TypeParameter */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 214 /* ArrowFunction */ || - node.kind === 212 /* ParenthesizedExpression */ || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 275 /* ExportSpecifier */) ? + var commentRanges = (node.kind === 164 /* SyntaxKind.Parameter */ || + node.kind === 163 /* SyntaxKind.TypeParameter */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 214 /* SyntaxKind.ArrowFunction */ || + node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + return text.charCodeAt(comment.pos + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; @@ -15644,48 +15766,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (177 /* FirstTypeNode */ <= node.kind && node.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= node.kind && node.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return true; - case 114 /* VoidKeyword */: - return node.parent.kind !== 217 /* VoidExpression */; - case 228 /* ExpressionWithTypeArguments */: + case 114 /* SyntaxKind.VoidKeyword */: + return node.parent.kind !== 217 /* SyntaxKind.VoidExpression */; + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 163 /* TypeParameter */: - return node.parent.kind === 195 /* MappedType */ || node.parent.kind === 190 /* InferType */; + case 163 /* SyntaxKind.TypeParameter */: + return node.parent.kind === 195 /* SyntaxKind.MappedType */ || node.parent.kind === 190 /* SyntaxKind.InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */ || node.kind === 206 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: - case 108 /* ThisKeyword */: { + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: { var parent = node.parent; - if (parent.kind === 181 /* TypeQuery */) { + if (parent.kind === 181 /* SyntaxKind.TypeQuery */) { return false; } - if (parent.kind === 200 /* ImportType */) { + if (parent.kind === 200 /* SyntaxKind.ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -15694,40 +15816,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (177 /* FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (parent.kind) { - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return node === parent.constraint; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return node === parent.constraint; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return node === parent.type; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return node === parent.type; - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return node === parent.type; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return node === parent.type; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.contains(parent.typeArguments, node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -15752,23 +15874,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitor(node); - case 263 /* CaseBlock */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 263 /* SyntaxKind.CaseBlock */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return ts.forEachChild(node, traverse); } } @@ -15778,23 +15900,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -15817,10 +15939,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 183 /* ArrayType */) { + if (node && node.kind === 183 /* SyntaxKind.ArrayType */) { return node.elementType; } - else if (node && node.kind === 178 /* TypeReference */) { + else if (node && node.kind === 178 /* SyntaxKind.TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15830,12 +15952,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 182 /* TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 182 /* SyntaxKind.TypeLiteral */: return node.members; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return node.properties; } } @@ -15843,14 +15965,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 203 /* BindingElement */: - case 299 /* EnumMember */: - case 164 /* Parameter */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 299 /* SyntaxKind.EnumMember */: + case 164 /* SyntaxKind.Parameter */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } } @@ -15862,21 +15984,21 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ - && node.parent.parent.kind === 237 /* VariableStatement */; + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ + && node.parent.parent.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isCommonJsExportedExpression(node) { if (!isInJSFile(node)) return false; - return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) || + return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) || isCommonJsExportPropertyAssignment(node.parent); } ts.isCommonJsExportedExpression = isCommonJsExportedExpression; function isCommonJsExportPropertyAssignment(node) { if (!isInJSFile(node)) return false; - return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */); + return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* AssignmentDeclarationKind.ExportsProperty */); } ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment; function isValidESSymbolDeclaration(node) { @@ -15887,13 +16009,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return true; } return false; @@ -15904,7 +16026,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 250 /* LabeledStatement */) { + if (node.statement.kind !== 250 /* SyntaxKind.LabeledStatement */) { return node.statement; } node = node.statement; @@ -15912,30 +16034,30 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 235 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 169 /* MethodDeclaration */ && node.parent.kind === 205 /* ObjectLiteralExpression */; + return node && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethodOrAccessor(node) { - return (node.kind === 169 /* MethodDeclaration */ || node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) && - (node.parent.kind === 205 /* ObjectLiteralExpression */ || - node.parent.kind === 226 /* ClassExpression */); + return (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) && + (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || + node.parent.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor; function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1 /* Identifier */; + return predicate && predicate.kind === 1 /* TypePredicateKind.Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0 /* This */; + return predicate && predicate.kind === 0 /* TypePredicateKind.This */; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 296 /* PropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */) { var propName = tryGetTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15997,14 +16119,14 @@ var ts; } ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 305 /* SourceFile */); + ts.Debug.assert(node.kind !== 305 /* SyntaxKind.SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -16019,9 +16141,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -16032,27 +16154,27 @@ var ts; node = node.parent; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 261 /* ModuleDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 260 /* EnumDeclaration */: - case 305 /* SourceFile */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 305 /* SyntaxKind.SourceFile */: return node; } } @@ -16065,17 +16187,17 @@ var ts; switch (node.kind) { // Arrow functions use the same scope, but may do so in a "delayed" manner // For example, `const getThis = () => this` may be before a super() call in a derived constructor - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 167 /* PropertyDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Object properties can have computed names; only method-like bodies start a new scope return true; default: @@ -16099,9 +16221,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return container; } } @@ -16123,28 +16245,28 @@ var ts; return node; } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: node = node.parent; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return node; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -16160,21 +16282,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 213 /* FunctionExpression */ || func.kind === 214 /* ArrowFunction */) { + if (func.kind === 213 /* SyntaxKind.FunctionExpression */ || func.kind === 214 /* SyntaxKind.ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 212 /* ParenthesizedExpression */) { + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 208 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 106 /* SuperKeyword */ + return node.kind === 106 /* SyntaxKind.SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -16183,8 +16305,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 106 /* SuperKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -16192,34 +16314,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 108 /* ThisKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function isThisInitializedObjectBindingExpression(node) { return !!node && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) && ts.isBinaryExpression(node.parent.parent) - && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */ - && node.parent.parent.right.kind === 108 /* ThisKeyword */; + && node.parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && node.parent.parent.right.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: return node; } return undefined; @@ -16227,10 +16349,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return node.tag; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -16243,25 +16365,25 @@ var ts; return false; } switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // classes are valid targets return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 257 /* ClassDeclaration */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + return parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 257 /* ClassDeclaration */; - case 164 /* Parameter */: + && parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 164 /* SyntaxKind.Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 171 /* Constructor */ - || parent.kind === 169 /* MethodDeclaration */ - || parent.kind === 173 /* SetAccessor */) - && grandparent.kind === 257 /* ClassDeclaration */; + && (parent.kind === 171 /* SyntaxKind.Constructor */ + || parent.kind === 169 /* SyntaxKind.MethodDeclaration */ + || parent.kind === 173 /* SyntaxKind.SetAccessor */) + && grandparent.kind === 257 /* SyntaxKind.ClassDeclaration */; } return false; } @@ -16277,11 +16399,11 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -16297,9 +16419,9 @@ var ts; ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 280 /* JsxOpeningElement */ || - parent.kind === 279 /* JsxSelfClosingElement */ || - parent.kind === 281 /* JsxClosingElement */) { + if (parent.kind === 280 /* SyntaxKind.JsxOpeningElement */ || + parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || + parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return parent.tagName === node; } return false; @@ -16307,66 +16429,66 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 13 /* RegularExpressionLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 229 /* AsExpression */: - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 221 /* BinaryExpression */: - case 222 /* ConditionalExpression */: - case 225 /* SpreadElement */: - case 223 /* TemplateExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 224 /* YieldExpression */: - case 218 /* AwaitExpression */: - case 231 /* MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 223 /* SyntaxKind.TemplateExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 224 /* SyntaxKind.YieldExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 231 /* SyntaxKind.MetaProperty */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return !ts.isHeritageClause(node.parent); - case 161 /* QualifiedName */: - while (node.parent.kind === 161 /* QualifiedName */) { + case 161 /* SyntaxKind.QualifiedName */: + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 311 /* JSDocMemberName */: + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 311 /* SyntaxKind.JSDocMemberName */: while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 80 /* PrivateIdentifier */: - return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */; - case 79 /* Identifier */: - if (node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 80 /* SyntaxKind.PrivateIdentifier */: + return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; + case 79 /* SyntaxKind.Identifier */: + if (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -16376,49 +16498,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: return parent.initializer === node; - case 238 /* ExpressionStatement */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 247 /* ReturnStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 251 /* ThrowStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 251 /* SyntaxKind.ThrowStatement */: return parent.expression === node; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forInStatement.expression === node; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return node === parent.expression; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node === parent.expression; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return node === parent.expression; - case 165 /* Decorator */: - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: - case 298 /* SpreadAssignment */: + case 165 /* SyntaxKind.Decorator */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 298 /* SyntaxKind.SpreadAssignment */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return parent.expression === node && !isPartOfTypeNode(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -16426,10 +16548,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 161 /* QualifiedName */ || node.kind === 79 /* Identifier */) { + while (node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 79 /* SyntaxKind.Identifier */) { node = node.parent; } - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -16437,7 +16559,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -16450,7 +16572,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -16462,11 +16584,11 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 262144 /* JavaScriptFile */); + return !!node && !!(node.flags & 262144 /* NodeFlags.JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 67108864 /* JsonFile */); + return !!node && !!(node.flags & 67108864 /* NodeFlags.JsonFile */); } ts.isInJsonFile = isInJsonFile; function isSourceFileNotJson(file) { @@ -16474,7 +16596,7 @@ var ts; } ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { - return !!node && !!(node.flags & 8388608 /* JSDoc */); + return !!node && !!(node.flags & 8388608 /* NodeFlags.JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -16482,15 +16604,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 150 /* StringKeyword */ || node.typeArguments[0].kind === 147 /* NumberKeyword */); + (node.typeArguments[0].kind === 150 /* SyntaxKind.StringKeyword */ || node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 208 /* CallExpression */) { + if (callExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* SyntaxKind.Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -16527,11 +16649,11 @@ var ts; } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { - return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */; + return charCode === 39 /* CharacterCodes.singleQuote */ || charCode === 34 /* CharacterCodes.doubleQuote */; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isStringDoubleQuoted(str, sourceFile) { - return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; + return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; function isAssignmentDeclaration(decl) { @@ -16542,7 +16664,7 @@ var ts; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && ts.isBinaryExpression(node.initializer) && - (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && + (node.initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -16569,7 +16691,7 @@ var ts; * 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 === 63 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -16595,11 +16717,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 213 /* FunctionExpression */ || e.kind === 214 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 213 /* FunctionExpression */ || - initializer.kind === 226 /* ClassExpression */ || - initializer.kind === 214 /* ArrowFunction */) { + if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ || + initializer.kind === 226 /* SyntaxKind.ClassExpression */ || + initializer.kind === 214 /* SyntaxKind.ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -16617,7 +16739,7 @@ var ts; */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { var e = ts.isBinaryExpression(initializer) - && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && (initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; @@ -16625,7 +16747,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -16633,8 +16755,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -16657,7 +16779,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 108 /* ThisKeyword */ || + (initializer.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -16696,7 +16818,7 @@ var ts; /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); - return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; + return special === 5 /* AssignmentDeclarationKind.Property */ || isInJSFile(expr) ? special : 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; function isBindableObjectDefinePropertyCall(expr) { @@ -16721,14 +16843,14 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; /** Any series of property and element accesses, ending in a literal element access */ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -16747,23 +16869,23 @@ var ts; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } var entityName = expr.arguments[0]; if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { - return 8 /* ObjectDefinePropertyExports */; + return 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */; } if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { - return 9 /* ObjectDefinePrototypeProperty */; + return 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */; } - return 7 /* ObjectDefinePropertyValue */; + return 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { - return 0 /* None */; + if (expr.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + return 0 /* AssignmentDeclarationKind.None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } - return 6 /* Prototype */; + return 6 /* AssignmentDeclarationKind.Prototype */; } return getAssignmentDeclarationPropertyAccessKind(expr.left); } @@ -16800,17 +16922,17 @@ var ts; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 108 /* ThisKeyword */) { - return 4 /* ThisProperty */; + if (lhs.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { + return 4 /* AssignmentDeclarationKind.ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr - return 2 /* ModuleExports */; + return 2 /* AssignmentDeclarationKind.ModuleExports */; } else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr - return 3 /* PrototypeProperty */; + return 3 /* AssignmentDeclarationKind.PrototypeProperty */; } var nextToLast = lhs; while (!ts.isIdentifier(nextToLast.expression)) { @@ -16822,14 +16944,14 @@ var ts; // ExportsProperty does not support binding with computed names isBindableStaticAccessExpression(lhs)) { // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... - return 1 /* ExportsProperty */; + return 1 /* AssignmentDeclarationKind.ExportsProperty */; } if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) { // F.G...x = expr - return 5 /* Property */; + return 5 /* AssignmentDeclarationKind.Property */; } } - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { @@ -16840,12 +16962,12 @@ var ts; } ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression; function isPrototypePropertyAssignment(node) { - return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */; + return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 238 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -16853,7 +16975,7 @@ var ts; function setValueDeclaration(symbol, node) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) && + !(node.flags & 16777216 /* NodeFlags.Ambient */ && !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { // other kinds of value declarations take precedence over modules and assignment declarations @@ -16866,17 +16988,17 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 256 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 256 /* SyntaxKind.FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { var _a, _b; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0]; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike); default: ts.Debug.assertNever(node); @@ -16889,14 +17011,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.parent; - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return node.parent.parent; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16906,17 +17028,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.moduleSpecifier; - case 265 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 277 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 200 /* ImportType */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 200 /* SyntaxKind.ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return node.arguments[0]; - case 261 /* ModuleDeclaration */: - return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; + case 261 /* SyntaxKind.ModuleDeclaration */: + return node.name.kind === 10 /* SyntaxKind.StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -16924,11 +17046,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16936,7 +17058,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 266 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16957,13 +17079,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 164 /* Parameter */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return node.questionToken !== undefined; } } @@ -16977,7 +17099,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 345 /* JSDocTypedefTag */ || node.kind === 338 /* JSDocCallbackTag */ || node.kind === 339 /* JSDocEnumTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || node.kind === 338 /* SyntaxKind.JSDocCallbackTag */ || node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16987,27 +17109,27 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 63 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && + getAssignmentDeclarationKind(node.expression) !== 0 /* AssignmentDeclarationKind.None */ && ts.isBinaryExpression(node.expression.right) && - (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) + (node.expression.right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return node.initializer; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return node.initializer; } } @@ -17019,7 +17141,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 261 /* ModuleDeclaration */ + node.body.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? node.body : undefined; } @@ -17034,11 +17156,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc))); } - if (node.kind === 164 /* Parameter */) { + if (node.kind === 164 /* SyntaxKind.Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 163 /* TypeParameter */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -17067,13 +17189,13 @@ var ts; } function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 296 /* PropertyAssignment */ || - parent.kind === 271 /* ExportAssignment */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 238 /* ExpressionStatement */ && node.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 247 /* ReturnStatement */ || + if (parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + parent.kind === 271 /* SyntaxKind.ExportAssignment */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 247 /* SyntaxKind.ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -17084,7 +17206,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -17108,7 +17230,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* SyntaxKind.Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -17181,41 +17303,41 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + binaryOperator === 63 /* SyntaxKind.EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* AssignmentKind.Definite */ : 2 /* AssignmentKind.Compound */ : + 0 /* AssignmentKind.None */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 212 /* ParenthesizedExpression */: - case 204 /* ArrayLiteralExpression */: - case 225 /* SpreadElement */: - case 230 /* NonNullExpression */: + return unaryOperator === 45 /* SyntaxKind.PlusPlusToken */ || unaryOperator === 46 /* SyntaxKind.MinusMinusToken */ ? 2 /* AssignmentKind.Compound */ : 0 /* AssignmentKind.None */; + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + return parent.initializer === node ? 1 /* AssignmentKind.Definite */ : 0 /* AssignmentKind.None */; + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 230 /* SyntaxKind.NonNullExpression */: node = parent; break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: node = parent.parent; break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (parent.name !== node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (parent.name === node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; default: - return 0 /* None */; + return 0 /* AssignmentKind.None */; } parent = node.parent; } @@ -17226,7 +17348,7 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0 /* None */; + return getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */; } ts.isAssignmentTarget = isAssignmentTarget; /** @@ -17235,22 +17357,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 235 /* Block */: - case 237 /* VariableStatement */: - case 248 /* WithStatement */: - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 235 /* SyntaxKind.Block */: + case 237 /* SyntaxKind.VariableStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return true; } return false; @@ -17267,11 +17389,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 191 /* ParenthesizedType */); + return walkUp(node, 191 /* SyntaxKind.ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 212 /* ParenthesizedExpression */); + return walkUp(node, 212 /* SyntaxKind.ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -17281,7 +17403,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 191 /* ParenthesizedType */) { + while (node && node.kind === 191 /* SyntaxKind.ParenthesizedType */) { child = node; node = node.parent; } @@ -17296,18 +17418,18 @@ var ts; ts.skipTypeParentheses = skipTypeParentheses; function skipParentheses(node, excludeJSDocTypeAssertions) { var flags = excludeJSDocTypeAssertions ? - 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : - 1 /* Parentheses */; + 1 /* OuterExpressionKinds.Parentheses */ | 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ : + 1 /* OuterExpressionKinds.Parentheses */; return ts.skipOuterExpressions(node, flags); } ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 206 /* PropertyAccessExpression */ && node.kind !== 207 /* ElementAccessExpression */) { + if (node.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 207 /* SyntaxKind.ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 215 /* DeleteExpression */; + return node && node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -17328,13 +17450,13 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -17345,13 +17467,13 @@ var ts; else { var binExp = parent.parent; return ts.isBinaryExpression(binExp) && - getAssignmentDeclarationKind(binExp) !== 0 /* None */ && + getAssignmentDeclarationKind(binExp) !== 0 /* AssignmentDeclarationKind.None */ && (binExp.left.symbol || binExp.symbol) && ts.getNameOfDeclaration(binExp) === name ? binExp : undefined; } - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -17360,7 +17482,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 162 /* ComputedPropertyName */ && + node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -17368,29 +17490,29 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 206 /* PropertyAccessExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 203 /* BindingElement */: - case 270 /* ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 275 /* ExportSpecifier */: - case 285 /* JsxAttribute */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 285 /* SyntaxKind.JsxAttribute */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: // Any name in an export specifier or JSX Attribute or Jsx Element return true; } @@ -17413,38 +17535,38 @@ var ts; // const x = require("...").y // const { x } = require("...").y function isAliasSymbolDeclaration(node) { - if (node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - node.kind === 267 /* ImportClause */ && !!node.name || - node.kind === 268 /* NamespaceImport */ || - node.kind === 274 /* NamespaceExport */ || - node.kind === 270 /* ImportSpecifier */ || - node.kind === 275 /* ExportSpecifier */ || - node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) { + if (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name || + node.kind === 268 /* SyntaxKind.NamespaceImport */ || + node.kind === 274 /* SyntaxKind.NamespaceExport */ || + node.kind === 270 /* SyntaxKind.ImportSpecifier */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ && exportAssignmentIsAlias(node)) { return true; } - return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && exportAssignmentIsAlias(node) || ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableExpression(node.parent.right)); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 268 /* NamespaceImport */: - case 275 /* ExportSpecifier */: - case 271 /* ExportAssignment */: - case 265 /* ImportEqualsDeclaration */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 271 /* SyntaxKind.ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 161 /* QualifiedName */); + } while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -17463,7 +17585,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* PropertyAssignment */ ? node.initializer : + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -17480,7 +17602,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -17489,7 +17611,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* SyntaxKind.ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -17502,7 +17624,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -17529,11 +17651,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 81 /* FirstKeyword */ <= token && token <= 160 /* LastKeyword */; + return 81 /* SyntaxKind.FirstKeyword */ <= token && token <= 160 /* SyntaxKind.LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 126 /* FirstContextualKeyword */ <= token && token <= 160 /* LastContextualKeyword */; + return 126 /* SyntaxKind.FirstContextualKeyword */ <= token && token <= 160 /* SyntaxKind.LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -17541,7 +17663,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; + return 117 /* SyntaxKind.FirstFutureReservedWord */ <= token && token <= 125 /* SyntaxKind.LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -17560,7 +17682,7 @@ var ts; } ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + return 2 /* SyntaxKind.FirstTriviaToken */ <= token && token <= 7 /* SyntaxKind.LastTriviaToken */; } ts.isTrivia = isTrivia; var FunctionFlags; @@ -17573,38 +17695,38 @@ var ts; })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { - return 4 /* Invalid */; + return 4 /* FunctionFlags.Invalid */; } - var flags = 0 /* Normal */; + var flags = 0 /* FunctionFlags.Normal */; switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - flags |= 1 /* Generator */; + flags |= 1 /* FunctionFlags.Generator */; } // falls through - case 214 /* ArrowFunction */: - if (hasSyntacticModifier(node, 256 /* Async */)) { - flags |= 2 /* Async */; + case 214 /* SyntaxKind.ArrowFunction */: + if (hasSyntacticModifier(node, 256 /* ModifierFlags.Async */)) { + flags |= 2 /* FunctionFlags.Async */; } break; } if (!node.body) { - flags |= 4 /* Invalid */; + flags |= 4 /* FunctionFlags.Invalid */; } return flags; } ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined - && hasSyntacticModifier(node, 256 /* Async */); + && hasSyntacticModifier(node, 256 /* ModifierFlags.Async */); } return false; } @@ -17614,7 +17736,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* SyntaxKind.PlusToken */ || node.operator === 40 /* SyntaxKind.MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -17631,7 +17753,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) { + if (!(name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || name.kind === 207 /* SyntaxKind.ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -17641,19 +17763,19 @@ var ts; ts.isDynamicName = isDynamicName; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { - if (nameExpression.operator === 40 /* MinusToken */) { + if (nameExpression.operator === 40 /* SyntaxKind.MinusToken */) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } return nameExpression.operand.text; @@ -17666,10 +17788,10 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return true; default: return false; @@ -17685,11 +17807,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -17704,7 +17826,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -17713,11 +17835,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 164 /* Parameter */; + return root.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 203 /* BindingElement */) { + while (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return node; @@ -17725,15 +17847,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 213 /* FunctionExpression */ - || kind === 256 /* FunctionDeclaration */ - || kind === 214 /* ArrowFunction */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 261 /* ModuleDeclaration */ - || kind === 305 /* SourceFile */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 305 /* SyntaxKind.SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -17752,58 +17874,58 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 209 /* NewExpression */: - return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - return 1 /* Right */; - case 221 /* BinaryExpression */: + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 0 /* Associativity.Left */ : 1 /* Associativity.Right */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + return 1 /* Associativity.Right */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operator) { - case 42 /* AsteriskAsteriskToken */: - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 1 /* Right */; - } - } - return 0 /* Left */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 1 /* Associativity.Right */; + } + } + return 0 /* Associativity.Left */; } ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 221 /* BinaryExpression */) { + if (expression.kind === 221 /* SyntaxKind.BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 219 /* PrefixUnaryExpression */ || expression.kind === 220 /* PostfixUnaryExpression */) { + else if (expression.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || expression.kind === 220 /* SyntaxKind.PostfixUnaryExpression */) { return expression.operator; } else { @@ -17982,129 +18104,129 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 351 /* CommaListExpression */: - return 0 /* Comma */; - case 225 /* SpreadElement */: - return 1 /* Spread */; - case 224 /* YieldExpression */: - return 2 /* Yield */; - case 222 /* ConditionalExpression */: - return 4 /* Conditional */; - case 221 /* BinaryExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + return 0 /* OperatorPrecedence.Comma */; + case 225 /* SyntaxKind.SpreadElement */: + return 1 /* OperatorPrecedence.Spread */; + case 224 /* SyntaxKind.YieldExpression */: + return 2 /* OperatorPrecedence.Yield */; + case 222 /* SyntaxKind.ConditionalExpression */: + return 4 /* OperatorPrecedence.Conditional */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operatorKind) { - case 27 /* CommaToken */: - return 0 /* Comma */; - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 3 /* Assignment */; + case 27 /* SyntaxKind.CommaToken */: + return 0 /* OperatorPrecedence.Comma */; + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 3 /* OperatorPrecedence.Assignment */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - return 16 /* Unary */; - case 220 /* PostfixUnaryExpression */: - return 17 /* Update */; - case 208 /* CallExpression */: - return 18 /* LeftHandSide */; - case 209 /* NewExpression */: - return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 210 /* TaggedTemplateExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 231 /* MetaProperty */: - return 19 /* Member */; - case 229 /* AsExpression */: - return 11 /* Relational */; - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 212 /* ParenthesizedExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - return 20 /* Primary */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + return 16 /* OperatorPrecedence.Unary */; + case 220 /* SyntaxKind.PostfixUnaryExpression */: + return 17 /* OperatorPrecedence.Update */; + case 208 /* SyntaxKind.CallExpression */: + return 18 /* OperatorPrecedence.LeftHandSide */; + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 19 /* OperatorPrecedence.Member */ : 18 /* OperatorPrecedence.LeftHandSide */; + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 231 /* SyntaxKind.MetaProperty */: + return 19 /* OperatorPrecedence.Member */; + case 229 /* SyntaxKind.AsExpression */: + return 11 /* OperatorPrecedence.Relational */; + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + return 20 /* OperatorPrecedence.Primary */; default: - return -1 /* Invalid */; + return -1 /* OperatorPrecedence.Invalid */; } } ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 60 /* QuestionQuestionToken */: - return 4 /* Coalesce */; - case 56 /* BarBarToken */: - return 5 /* LogicalOR */; - case 55 /* AmpersandAmpersandToken */: - return 6 /* LogicalAND */; - case 51 /* BarToken */: - return 7 /* BitwiseOR */; - case 52 /* CaretToken */: - return 8 /* BitwiseXOR */; - case 50 /* AmpersandToken */: - return 9 /* BitwiseAND */; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - return 10 /* Equality */; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - return 11 /* Relational */; - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - return 12 /* Shift */; - case 39 /* PlusToken */: - case 40 /* MinusToken */: - return 13 /* Additive */; - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - return 14 /* Multiplicative */; - case 42 /* AsteriskAsteriskToken */: - return 15 /* Exponentiation */; + case 60 /* SyntaxKind.QuestionQuestionToken */: + return 4 /* OperatorPrecedence.Coalesce */; + case 56 /* SyntaxKind.BarBarToken */: + return 5 /* OperatorPrecedence.LogicalOR */; + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + return 6 /* OperatorPrecedence.LogicalAND */; + case 51 /* SyntaxKind.BarToken */: + return 7 /* OperatorPrecedence.BitwiseOR */; + case 52 /* SyntaxKind.CaretToken */: + return 8 /* OperatorPrecedence.BitwiseXOR */; + case 50 /* SyntaxKind.AmpersandToken */: + return 9 /* OperatorPrecedence.BitwiseAND */; + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + return 10 /* OperatorPrecedence.Equality */; + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + return 11 /* OperatorPrecedence.Relational */; + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + return 12 /* OperatorPrecedence.Shift */; + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + return 13 /* OperatorPrecedence.Additive */; + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + return 14 /* OperatorPrecedence.Multiplicative */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + return 15 /* OperatorPrecedence.Exponentiation */; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. @@ -18114,9 +18236,9 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !!i.expression; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return !i.containsOnlyTriviaWhiteSpaces; default: return true; @@ -18231,9 +18353,9 @@ var ts; return "\\u" + paddedHexCode; } function getReplacement(c, offset, input) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); - if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) { + if (lookAhead >= 48 /* CharacterCodes._0 */ && lookAhead <= 57 /* CharacterCodes._9 */) { // If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode) return "\\x00"; } @@ -18248,8 +18370,8 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : - quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 96 /* CharacterCodes.backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* CharacterCodes.singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } @@ -18279,13 +18401,13 @@ var ts; return "&#x" + hexCharCode + ";"; } function getJsxAttributeStringReplacement(c) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { return "�"; } return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0)); } function escapeJsxAttributeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 39 /* CharacterCodes.singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : jsxDoubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement); } @@ -18304,13 +18426,13 @@ var ts; } ts.stripQuotes = stripQuotes; function isQuoteOrBacktick(charCode) { - return charCode === 39 /* singleQuote */ || - charCode === 34 /* doubleQuote */ || - charCode === 96 /* backtick */; + return charCode === 39 /* CharacterCodes.singleQuote */ || + charCode === 34 /* CharacterCodes.doubleQuote */ || + charCode === 96 /* CharacterCodes.backtick */; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); + return (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; var indentStrings = ["", " "]; @@ -18555,20 +18677,20 @@ var ts; } ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker; function getDeclarationEmitExtensionForPath(path) { - return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : - ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : - ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well - ".d.ts" /* Dts */; + return ts.fileExtensionIsOneOf(path, [".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? ".d.mts" /* Extension.Dmts */ : + ts.fileExtensionIsOneOf(path, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? ".d.cts" /* Extension.Dcts */ : + ts.fileExtensionIsOneOf(path, [".json" /* Extension.Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + ".d.ts" /* Extension.Dts */; } ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; /** * This function is an inverse of `getDeclarationEmitExtensionForPath`. */ function getPossibleOriginalInputExtensionForExtension(path) { - return ts.fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : - ts.fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : - ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Json */] : - [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */]; + return ts.fileExtensionIsOneOf(path, [".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */] : + ts.fileExtensionIsOneOf(path, [".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */] : + ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Extension.Json */] : + [".tsx" /* Extension.Tsx */, ".ts" /* Extension.Ts */, ".jsx" /* Extension.Jsx */, ".js" /* Extension.Js */]; } ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension; function outFile(options) { @@ -18696,7 +18818,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* SyntaxKind.Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function isThisInTypeQuery(node) { @@ -18706,11 +18828,11 @@ var ts; while (ts.isQualifiedName(node.parent) && node.parent.left === node) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */; + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 108 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* SyntaxKind.ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -18721,10 +18843,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 173 /* SetAccessor */) { + else if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { setAccessor = accessor; } else { @@ -18744,10 +18866,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 172 /* GetAccessor */ && !getAccessor) { + if (member.kind === 172 /* SyntaxKind.GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 173 /* SetAccessor */ && !setAccessor) { + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -18796,7 +18918,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* SyntaxKind.JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18913,7 +19035,7 @@ var ts; } ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); var lineCount = lineMap.length; var firstCommentLineIndent = void 0; @@ -18988,7 +19110,7 @@ var ts; function calculateIndent(text, pos, end) { var currentLineIndent = 0; for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9 /* tab */) { + if (text.charCodeAt(pos) === 9 /* CharacterCodes.tab */) { // Tabs = TabSize = indent size and go to next tabStop currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } @@ -19000,11 +19122,11 @@ var ts; return currentLineIndent; } function hasEffectiveModifiers(node) { - return getEffectiveModifierFlags(node) !== 0 /* None */; + return getEffectiveModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasEffectiveModifiers = hasEffectiveModifiers; function hasSyntacticModifiers(node) { - return getSyntacticModifierFlags(node) !== 0 /* None */; + return getSyntacticModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasSyntacticModifiers = hasSyntacticModifiers; function hasEffectiveModifier(node, flags) { @@ -19021,27 +19143,27 @@ var ts; } ts.isStatic = isStatic; function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 32 /* ModifierFlags.Static */); } ts.hasStaticModifier = hasStaticModifier; function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16384 /* ModifierFlags.Override */); } ts.hasOverrideModifier = hasOverrideModifier; function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 128 /* Abstract */); + return hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); } ts.hasAbstractModifier = hasAbstractModifier; function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */); } ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 64 /* ModifierFlags.Readonly */); } ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier; function hasDecorators(node) { - return hasSyntacticModifier(node, 131072 /* Decorator */); + return hasSyntacticModifier(node, 131072 /* ModifierFlags.Decorator */); } ts.hasDecorators = hasDecorators; function getSelectedEffectiveModifierFlags(node, flags) { @@ -19053,16 +19175,16 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 160 /* LastToken */) { - return 0 /* None */; + if (node.kind >= 0 /* SyntaxKind.FirstToken */ && node.kind <= 160 /* SyntaxKind.LastToken */) { + return 0 /* ModifierFlags.None */; } - if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { - node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; + if (!(node.modifierFlagsCache & 536870912 /* ModifierFlags.HasComputedFlags */)) { + node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* ModifierFlags.HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* ModifierFlags.HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { + node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* ModifierFlags.HasComputedJSDocModifiers */; } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return node.modifierFlagsCache & ~(536870912 /* ModifierFlags.HasComputedFlags */ | 4096 /* ModifierFlags.HasComputedJSDocModifiers */); } /** * Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance. @@ -19087,22 +19209,22 @@ var ts; } ts.getSyntacticModifierFlags = getSyntacticModifierFlags; function getJSDocModifierFlagsNoCache(node) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (!!node.parent && !ts.isParameter(node)) { if (isInJSFile(node)) { if (ts.getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 4 /* ModifierFlags.Public */; if (ts.getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 8 /* ModifierFlags.Private */; if (ts.getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 16 /* ModifierFlags.Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; if (ts.getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 8192 /* ModifierFlags.Deprecated */; } return flags; } @@ -19121,15 +19243,15 @@ var ts; * NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc. */ function getSyntacticModifierFlagsNoCache(node) { - var flags = ts.canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* None */; - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { - flags |= 1 /* Export */; + var flags = ts.canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* ModifierFlags.None */; + if (node.flags & 4 /* NodeFlags.NestedNamespace */ || (node.kind === 79 /* SyntaxKind.Identifier */ && node.isInJSDocNamespace)) { + flags |= 1 /* ModifierFlags.Export */; } return flags; } ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache; function modifiersToFlags(modifiers) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (modifiers) { for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; @@ -19141,23 +19263,23 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 124 /* StaticKeyword */: return 32 /* Static */; - case 123 /* PublicKeyword */: return 4 /* Public */; - case 122 /* ProtectedKeyword */: return 16 /* Protected */; - case 121 /* PrivateKeyword */: return 8 /* Private */; - case 126 /* AbstractKeyword */: return 128 /* Abstract */; - case 93 /* ExportKeyword */: return 1 /* Export */; - case 135 /* DeclareKeyword */: return 2 /* Ambient */; - case 85 /* ConstKeyword */: return 2048 /* Const */; - case 88 /* DefaultKeyword */: return 512 /* Default */; - case 131 /* AsyncKeyword */: return 256 /* Async */; - case 145 /* ReadonlyKeyword */: return 64 /* Readonly */; - case 159 /* OverrideKeyword */: return 16384 /* Override */; - case 101 /* InKeyword */: return 32768 /* In */; - case 144 /* OutKeyword */: return 65536 /* Out */; - case 165 /* Decorator */: return 131072 /* Decorator */; - } - return 0 /* None */; + case 124 /* SyntaxKind.StaticKeyword */: return 32 /* ModifierFlags.Static */; + case 123 /* SyntaxKind.PublicKeyword */: return 4 /* ModifierFlags.Public */; + case 122 /* SyntaxKind.ProtectedKeyword */: return 16 /* ModifierFlags.Protected */; + case 121 /* SyntaxKind.PrivateKeyword */: return 8 /* ModifierFlags.Private */; + case 126 /* SyntaxKind.AbstractKeyword */: return 128 /* ModifierFlags.Abstract */; + case 93 /* SyntaxKind.ExportKeyword */: return 1 /* ModifierFlags.Export */; + case 135 /* SyntaxKind.DeclareKeyword */: return 2 /* ModifierFlags.Ambient */; + case 85 /* SyntaxKind.ConstKeyword */: return 2048 /* ModifierFlags.Const */; + case 88 /* SyntaxKind.DefaultKeyword */: return 512 /* ModifierFlags.Default */; + case 131 /* SyntaxKind.AsyncKeyword */: return 256 /* ModifierFlags.Async */; + case 145 /* SyntaxKind.ReadonlyKeyword */: return 64 /* ModifierFlags.Readonly */; + case 159 /* SyntaxKind.OverrideKeyword */: return 16384 /* ModifierFlags.Override */; + case 101 /* SyntaxKind.InKeyword */: return 32768 /* ModifierFlags.In */; + case 144 /* SyntaxKind.OutKeyword */: return 65536 /* ModifierFlags.Out */; + case 165 /* SyntaxKind.Decorator */: return 131072 /* ModifierFlags.Decorator */; + } + return 0 /* ModifierFlags.None */; } ts.modifierToFlag = modifierToFlag; function createModifiers(modifierFlags) { @@ -19165,15 +19287,15 @@ var ts; } ts.createModifiers = createModifiers; function isLogicalOperator(token) { - return token === 56 /* BarBarToken */ - || token === 55 /* AmpersandAmpersandToken */ - || token === 53 /* ExclamationToken */; + return token === 56 /* SyntaxKind.BarBarToken */ + || token === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || token === 53 /* SyntaxKind.ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 75 /* BarBarEqualsToken */ - || token === 76 /* AmpersandAmpersandEqualsToken */ - || token === 77 /* QuestionQuestionEqualsToken */; + return token === 75 /* SyntaxKind.BarBarEqualsToken */ + || token === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */ + || token === 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -19181,7 +19303,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; + return token >= 63 /* SyntaxKind.FirstAssignment */ && token <= 78 /* SyntaxKind.LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -19194,14 +19316,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 63 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -19213,8 +19335,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 205 /* ObjectLiteralExpression */ - || kind === 204 /* ArrayLiteralExpression */; + return kind === 205 /* SyntaxKind.ObjectLiteralExpression */ + || kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } return false; } @@ -19224,33 +19346,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* SyntaxKind.Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 79 /* Identifier */ - || node.kind === 108 /* ThisKeyword */ - || node.kind === 106 /* SuperKeyword */ - || node.kind === 231 /* MetaProperty */ - || node.kind === 206 /* PropertyAccessExpression */ && isDottedName(node.expression) - || node.kind === 212 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 108 /* SyntaxKind.ThisKeyword */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */ + || node.kind === 231 /* SyntaxKind.MetaProperty */ + || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -19281,8 +19403,8 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isRightSideOfAccessExpression(node) { @@ -19297,12 +19419,12 @@ var ts; } ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 205 /* ObjectLiteralExpression */ && + return expression.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 204 /* ArrayLiteralExpression */ && + return expression.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -19318,7 +19440,7 @@ var ts; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isExportDefaultSymbol(symbol) { - return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* Default */); + return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* ModifierFlags.Default */); } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTSExtension(fileName) { @@ -19489,9 +19611,9 @@ var ts; var lineFeed = "\n"; function getNewLineCharacter(options, getNewLine) { switch (options.newLine) { - case 0 /* CarriageReturnLineFeed */: + case 0 /* NewLineKind.CarriageReturnLineFeed */: return carriageReturnLineFeed; - case 1 /* LineFeed */: + case 1 /* NewLineKind.LineFeed */: return lineFeed; } return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed; @@ -19636,8 +19758,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -19661,32 +19783,33 @@ var ts; } ts.closeFileWatcher = closeFileWatcher; function getCheckFlags(symbol) { - return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; + return symbol.flags & 33554432 /* SymbolFlags.Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration)) + || (s.flags & 32768 /* SymbolFlags.GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* SymbolFlags.Class */ ? flags : flags & ~28 /* ModifierFlags.AccessibilityModifier */; } - if (getCheckFlags(s) & 6 /* Synthetic */) { + if (getCheckFlags(s) & 6 /* CheckFlags.Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; - var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + var accessModifier = checkFlags & 1024 /* CheckFlags.ContainsPrivate */ ? 8 /* ModifierFlags.Private */ : + checkFlags & 256 /* CheckFlags.ContainsPublic */ ? 4 /* ModifierFlags.Public */ : + 16 /* ModifierFlags.Protected */; + var staticModifier = checkFlags & 2048 /* CheckFlags.ContainsStatic */ ? 32 /* ModifierFlags.Static */ : 0; return accessModifier | staticModifier; } - if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + if (s.flags & 4194304 /* SymbolFlags.Prototype */) { + return 4 /* ModifierFlags.Public */ | 32 /* ModifierFlags.Static */; } return 0; } ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol; function skipAlias(symbol, checker) { - return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol; + return symbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(symbol) : symbol; } ts.skipAlias = skipAlias; /** See comment on `declareModuleMember` in `binder.ts`. */ @@ -19695,11 +19818,11 @@ var ts; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; function isWriteOnlyAccess(node) { - return accessKind(node) === 1 /* Write */; + return accessKind(node) === 1 /* AccessKind.Write */; } ts.isWriteOnlyAccess = isWriteOnlyAccess; function isWriteAccess(node) { - return accessKind(node) !== 0 /* Read */; + return accessKind(node) !== 0 /* AccessKind.Read */; } ts.isWriteAccess = isWriteAccess; var AccessKind; @@ -19714,47 +19837,47 @@ var ts; function accessKind(node) { var parent = node.parent; if (!parent) - return 0 /* Read */; + return 0 /* AccessKind.Read */; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return accessKind(parent); - case 220 /* PostfixUnaryExpression */: - case 219 /* PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var operator = parent.operator; - return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 221 /* BinaryExpression */: + return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? writeOrReadWrite() : 0 /* AccessKind.Read */; + case 221 /* SyntaxKind.BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() - : 0 /* Read */; - case 206 /* PropertyAccessExpression */: - return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 296 /* PropertyAssignment */: { + operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : writeOrReadWrite() + : 0 /* AccessKind.Read */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent); + case 296 /* SyntaxKind.PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. - return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 204 /* ArrayLiteralExpression */: + return node === parent.objectAssignmentInitializer ? 0 /* AccessKind.Read */ : accessKind(parent.parent); + case 204 /* SyntaxKind.ArrayLiteralExpression */: return accessKind(parent); default: - return 0 /* Read */; + return 0 /* AccessKind.Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* SyntaxKind.ExpressionStatement */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */; } } function reverseAccessKind(a) { switch (a) { - case 0 /* Read */: - return 1 /* Write */; - case 1 /* Write */: - return 0 /* Read */; - case 2 /* ReadWrite */: - return 2 /* ReadWrite */; + case 0 /* AccessKind.Read */: + return 1 /* AccessKind.Write */; + case 1 /* AccessKind.Write */: + return 0 /* AccessKind.Read */; + case 2 /* AccessKind.ReadWrite */: + return 2 /* AccessKind.ReadWrite */; default: return ts.Debug.assertNever(a); } @@ -19824,9 +19947,9 @@ var ts; } ts.mutateMap = mutateMap; function isAbstractConstructorSymbol(symbol) { - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 128 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); } return false; } @@ -19837,11 +19960,11 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0; + return type.flags & 3899393 /* TypeFlags.ObjectFlagsType */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { - return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0; + return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length !== 0; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { @@ -19888,44 +20011,44 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) - || kind === 130 /* AnyKeyword */ - || kind === 155 /* UnknownKeyword */ - || kind === 147 /* NumberKeyword */ - || kind === 158 /* BigIntKeyword */ - || kind === 148 /* ObjectKeyword */ - || kind === 133 /* BooleanKeyword */ - || kind === 150 /* StringKeyword */ - || kind === 151 /* SymbolKeyword */ - || kind === 114 /* VoidKeyword */ - || kind === 153 /* UndefinedKeyword */ - || kind === 143 /* NeverKeyword */ - || kind === 228 /* ExpressionWithTypeArguments */ - || kind === 312 /* JSDocAllType */ - || kind === 313 /* JSDocUnknownType */ - || kind === 314 /* JSDocNullableType */ - || kind === 315 /* JSDocNonNullableType */ - || kind === 316 /* JSDocOptionalType */ - || kind === 317 /* JSDocFunctionType */ - || kind === 318 /* JSDocVariadicType */; + return (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) + || kind === 130 /* SyntaxKind.AnyKeyword */ + || kind === 155 /* SyntaxKind.UnknownKeyword */ + || kind === 147 /* SyntaxKind.NumberKeyword */ + || kind === 158 /* SyntaxKind.BigIntKeyword */ + || kind === 148 /* SyntaxKind.ObjectKeyword */ + || kind === 133 /* SyntaxKind.BooleanKeyword */ + || kind === 150 /* SyntaxKind.StringKeyword */ + || kind === 151 /* SyntaxKind.SymbolKeyword */ + || kind === 114 /* SyntaxKind.VoidKeyword */ + || kind === 153 /* SyntaxKind.UndefinedKeyword */ + || kind === 143 /* SyntaxKind.NeverKeyword */ + || kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ + || kind === 312 /* SyntaxKind.JSDocAllType */ + || kind === 313 /* SyntaxKind.JSDocUnknownType */ + || kind === 314 /* SyntaxKind.JSDocNullableType */ + || kind === 315 /* SyntaxKind.JSDocNonNullableType */ + || kind === 316 /* SyntaxKind.JSDocOptionalType */ + || kind === 317 /* SyntaxKind.JSDocFunctionType */ + || kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */ || node.kind === 207 /* ElementAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 206 /* PropertyAccessExpression */) { + if (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 207 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 207 /* SyntaxKind.ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; function isBundleFileTextLike(section) { switch (section.kind) { - case "text" /* Text */: - case "internal" /* Internal */: + case "text" /* BundleFileSectionKind.Text */: + case "internal" /* BundleFileSectionKind.Internal */: return true; default: return false; @@ -19933,7 +20056,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 269 /* NamedImports */ || node.kind === 273 /* NamedExports */; + return node.kind === 269 /* SyntaxKind.NamedImports */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -19948,13 +20071,13 @@ var ts; return walkAccessExpression(name.parent); } function walkAccessExpression(access) { - if (access.kind === 206 /* PropertyAccessExpression */) { + if (access.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var res = action(access.name); if (res !== undefined) { return res; } } - else if (access.kind === 207 /* ElementAccessExpression */) { + else if (access.kind === 207 /* SyntaxKind.ElementAccessExpression */) { if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) { var res = action(access.argumentExpression); if (res !== undefined) { @@ -19981,28 +20104,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: node = node.operand; continue; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: node = node.left; continue; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: node = node.condition; continue; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: node = node.tag; continue; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 229 /* AsExpression */: - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: - case 230 /* NonNullExpression */: - case 350 /* PartiallyEmittedExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: node = node.expression; continue; } @@ -20036,9 +20159,9 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; } @@ -20047,8 +20170,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } function Identifier(kind, pos, end) { @@ -20056,8 +20179,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; this.flowNode = undefined; @@ -20252,7 +20375,7 @@ var ts; function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -20261,43 +20384,43 @@ var ts; ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (d1.relatedInformation && d2.relatedInformation) { return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { var d2i = d2.relatedInformation[index]; return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; + }) || 0 /* Comparison.EqualTo */; } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + return d1.relatedInformation ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; } function compareMessageText(t1, t2) { if (typeof t1 === "string" && typeof t2 === "string") { return ts.compareStringsCaseSensitive(t1, t2); } else if (typeof t1 === "string") { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (typeof t2 === "string") { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); if (res) { return res; } if (!t1.next && !t2.next) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (!t1.next) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } if (!t2.next) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var len = Math.min(t1.next.length, t2.next.length); for (var i = 0; i < len; i++) { @@ -20307,16 +20430,16 @@ var ts; } } if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* ScriptKind.TSX */ || scriptKind === 2 /* ScriptKind.JSX */ || scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 6 /* ScriptKind.JSON */ ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */; } ts.getLanguageVariant = getLanguageVariant; /** @@ -20325,7 +20448,7 @@ var ts; * Unfortunately, there's no `NodeFlag` space to do the same for JSX. */ function walkTreeForJSXTags(node) { - if (!(node.transformFlags & 2 /* ContainsJsx */)) + if (!(node.transformFlags & 2 /* TransformFlags.ContainsJsx */)) return undefined; return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags); } @@ -20342,7 +20465,7 @@ var ts; // Excludes declaration files - they still require an explicit `export {}` or the like // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files // that aren't esm-mode (meaning not in a `type: module` scope). - return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined; + return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]))) && !file.isDeclarationFile ? true : undefined; } function getSetExternalModuleIndicator(options) { // TODO: Should this callback be cached? @@ -20362,13 +20485,10 @@ var ts; // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness var checks = [ts.isFileProbablyExternalModule]; - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { checks.push(isFileModuleFromUsingJSXTag); } - var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { - checks.push(isFileForcedToBeModuleByFormat); - } + checks.push(isFileForcedToBeModuleByFormat); var combined_1 = ts.or.apply(void 0, checks); var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); }; return callback; @@ -20377,15 +20497,15 @@ var ts; ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator; function getEmitScriptTarget(compilerOptions) { return compilerOptions.target || - (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ES2022 */) || - (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) || - 0 /* ES3 */; + (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ScriptTarget.ES2022 */) || + (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ScriptTarget.ESNext */) || + 0 /* ScriptTarget.ES3 */; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function getEmitModuleResolutionKind(compilerOptions) { @@ -20483,7 +20603,7 @@ var ts; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function getUseDefineForClassFields(compilerOptions) { - return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */ : compilerOptions.useDefineForClassFields; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { @@ -20504,14 +20624,14 @@ var ts; ts.getCompilerOptionValue = getCompilerOptionValue; function getJSXTransformEnabled(options) { var jsx = options.jsx; - return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */; + return jsx === 2 /* JsxEmit.React */ || jsx === 4 /* JsxEmit.ReactJSX */ || jsx === 5 /* JsxEmit.ReactJSXDev */; } ts.getJSXTransformEnabled = getJSXTransformEnabled; function getJSXImplicitImportBase(compilerOptions, file) { var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; - return compilerOptions.jsx === 4 /* ReactJSX */ || - compilerOptions.jsx === 5 /* ReactJSXDev */ || + return compilerOptions.jsx === 4 /* JsxEmit.ReactJSX */ || + compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ || compilerOptions.jsxImportSource || jsxImportSourcePragma ? (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : @@ -20519,13 +20639,13 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { + if (str.charCodeAt(i) === 42 /* CharacterCodes.asterisk */) { if (!seenAsterisk) { seenAsterisk = true; } @@ -20624,9 +20744,9 @@ var ts; function escapeRegExpCharacter(match) { return "\\" + match; } - var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; + var wildcardCharCodes = [42 /* CharacterCodes.asterisk */, 63 /* CharacterCodes.question */]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { /** * Matches any single directory segment unless it is the last segment and a .min.js file @@ -20639,7 +20759,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { @@ -20648,7 +20768,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -20666,10 +20786,10 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); // If excluding, match "foo/bar/baz...", but if including, only allow "foo". var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -20691,7 +20811,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -20728,11 +20848,11 @@ var ts; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { + if (component.charCodeAt(0) === 42 /* CharacterCodes.asterisk */) { componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } - else if (component.charCodeAt(0) === 63 /* question */) { + else if (component.charCodeAt(0) === 63 /* CharacterCodes.question */) { componentPattern += "[^./]"; component = component.substr(1); } @@ -20769,7 +20889,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -20894,44 +21014,44 @@ var ts; // If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt // to get the ScriptKind from the file name. If it cannot be resolved // from the file name then the default 'TS' script kind is returned. - return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */; + return scriptKind || getScriptKindFromFileName(fileName) || 3 /* ScriptKind.TS */; } ts.ensureScriptKind = ensureScriptKind; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: - case ".cjs" /* Cjs */: - case ".mjs" /* Mjs */: - return 1 /* JS */; - case ".jsx" /* Jsx */: - return 2 /* JSX */; - case ".ts" /* Ts */: - case ".cts" /* Cts */: - case ".mts" /* Mts */: - return 3 /* TS */; - case ".tsx" /* Tsx */: - return 4 /* TSX */; - case ".json" /* Json */: - return 6 /* JSON */; + case ".js" /* Extension.Js */: + case ".cjs" /* Extension.Cjs */: + case ".mjs" /* Extension.Mjs */: + return 1 /* ScriptKind.JS */; + case ".jsx" /* Extension.Jsx */: + return 2 /* ScriptKind.JSX */; + case ".ts" /* Extension.Ts */: + case ".cts" /* Extension.Cts */: + case ".mts" /* Extension.Mts */: + return 3 /* ScriptKind.TS */; + case ".tsx" /* Extension.Tsx */: + return 4 /* ScriptKind.TSX */; + case ".json" /* Extension.Json */: + return 6 /* ScriptKind.JSON */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } ts.getScriptKindFromFileName = getScriptKindFromFileName; /** * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ - ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]]; + ts.supportedTSExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */]]; ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions); - var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false); + var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Extension.Json */]], false); /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */]; - ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]]; + var supportedTSExtensionsForExtractExtension = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */]; + ts.supportedJSExtensions = [[".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".mjs" /* Extension.Mjs */], [".cjs" /* Extension.Cjs */]]; ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); - var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]]; - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false); - ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]; + var allSupportedExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */]]; + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Extension.Json */]], false); + ts.supportedDeclarationExtensions = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */]; function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { @@ -20939,7 +21059,7 @@ var ts; } var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; var flatBuiltins = ts.flatten(builtins); - var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); + var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* ScriptKind.Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); return extensions; } ts.getSupportedExtensions = getSupportedExtensions; @@ -20950,11 +21070,11 @@ var ts; return allSupportedExtensionsWithJson; if (supportedExtensions === ts.supportedTSExtensions) return supportedTSExtensionsWithJson; - return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false); + return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Extension.Json */]], false); } ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { - return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; + return scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 2 /* ScriptKind.JSX */; } function hasJSFileExtension(fileName) { return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -20985,7 +21105,7 @@ var ts; return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); } ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; - var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; + var extensionsToRemove = [".d.ts" /* Extension.Dts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".ts" /* Extension.Ts */, ".js" /* Extension.Js */, ".tsx" /* Extension.Tsx */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -21038,11 +21158,11 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTS(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */; + return ext === ".ts" /* Extension.Ts */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".d.ts" /* Extension.Dts */ || ext === ".cts" /* Extension.Cts */ || ext === ".mts" /* Extension.Mts */ || ext === ".d.mts" /* Extension.Dmts */ || ext === ".d.cts" /* Extension.Dcts */; } ts.extensionIsTS = extensionIsTS; function resolutionExtensionIsTSOrJson(ext) { - return extensionIsTS(ext) || ext === ".json" /* Json */; + return extensionIsTS(ext) || ext === ".json" /* Extension.Json */; } ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; /** @@ -21051,7 +21171,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -21160,23 +21280,23 @@ var ts; function parsePseudoBigInt(stringValue) { var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" - case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 98 /* CharacterCodes.b */: + case 66 /* CharacterCodes.B */: // 0b or 0B log2Base = 1; break; - case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 111 /* CharacterCodes.o */: + case 79 /* CharacterCodes.O */: // 0o or 0O log2Base = 3; break; - case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 120 /* CharacterCodes.x */: + case 88 /* CharacterCodes.X */: // 0x or 0X log2Base = 4; break; default: // already in decimal; omit trailing "n" var nIndex = stringValue.length - 1; // Skip leading 0s var nonZeroStart = 0; - while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) { + while (stringValue.charCodeAt(nonZeroStart) === 48 /* CharacterCodes._0 */) { nonZeroStart++; } return stringValue.slice(nonZeroStart, nIndex) || "0"; @@ -21192,10 +21312,10 @@ var ts; var segment = bitOffset >>> 4; var digitChar = stringValue.charCodeAt(i); // Find character range: 0-9 < A-F < a-f - var digit = digitChar <= 57 /* _9 */ - ? digitChar - 48 /* _0 */ + var digit = digitChar <= 57 /* CharacterCodes._9 */ + ? digitChar - 48 /* CharacterCodes._0 */ : 10 + digitChar - - (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + (digitChar <= 70 /* CharacterCodes.F */ ? 65 /* CharacterCodes.A */ : 97 /* CharacterCodes.a */); var shiftedDigit = digit << (bitOffset & 15); segments[segment] |= shiftedDigit; var residual = shiftedDigit >>> 16; @@ -21230,7 +21350,7 @@ var ts; } ts.pseudoBigIntToString = pseudoBigIntToString; function isValidTypeOnlyAliasUseSite(useSite) { - return !!(useSite.flags & 16777216 /* Ambient */) + return !!(useSite.flags & 16777216 /* NodeFlags.Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) @@ -21241,34 +21361,34 @@ var ts; return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite; } function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 79 /* Identifier */ || node.kind === 206 /* PropertyAccessExpression */) { + while (node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 258 /* InterfaceDeclaration */ || containerKind === 182 /* TypeLiteral */; + return containerKind === 258 /* SyntaxKind.InterfaceDeclaration */ || containerKind === 182 /* SyntaxKind.TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 79 /* Identifier */) + if (node.kind !== 79 /* SyntaxKind.Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return true; - case 206 /* PropertyAccessExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* SyntaxKind.ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* SyntaxKind.InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -21409,7 +21529,7 @@ var ts; node = parent; continue; } - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // left side of comma is always unused if (node === parent.left) return true; @@ -21429,22 +21549,22 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 190 /* InferType */ ? undefined : parent_1.typeParameters; - case 164 /* Parameter */: + return parent_1.kind === 190 /* SyntaxKind.InferType */ ? undefined : parent_1.typeParameters; + case 164 /* SyntaxKind.Parameter */: return node.parent.parameters; - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node.parent.templateSpans; - case 165 /* Decorator */: { + case 165 /* SyntaxKind.Decorator */: { var parent_2 = node.parent; return ts.canHaveDecorators(parent_2) ? parent_2.modifiers : ts.canHaveIllegalDecorators(parent_2) ? parent_2.decorators : undefined; } - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -21452,45 +21572,45 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 182 /* TypeLiteral */: - case 258 /* InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return parent.types; - case 184 /* TupleType */: - case 204 /* ArrayLiteralExpression */: - case 351 /* CommaListExpression */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 184 /* SyntaxKind.TupleType */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return parent.elements; - case 205 /* ObjectLiteralExpression */: - case 286 /* JsxAttributes */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 286 /* SyntaxKind.JsxAttributes */: return parent.properties; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 278 /* JsxElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 282 /* SyntaxKind.JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: return parent.statements; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return parent.clauses; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return parent.statements; } } @@ -21502,7 +21622,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 214 /* ArrowFunction */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -21520,7 +21640,7 @@ var ts; } ts.isInfinityOrNaNString = isInfinityOrNaNString; function isCatchClauseVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function isParameterOrCatchClauseVariable(symbol) { @@ -21529,7 +21649,7 @@ var ts; } ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable; function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 213 /* FunctionExpression */ || node.kind === 214 /* ArrowFunction */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */ || node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction; function escapeSnippetText(text) { @@ -21568,7 +21688,7 @@ var ts; } ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral; function isThisTypeParameter(type) { - return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); + return !!(type.flags & 262144 /* TypeFlags.TypeParameter */ && type.isThisType); } ts.isThisTypeParameter = isThisTypeParameter; function getNodeModulePathParts(fullPath) { @@ -21588,45 +21708,45 @@ var ts; })(States || (States = {})); var partStart = 0; var partEnd = 0; - var state = 0 /* BeforeNodeModules */; + var state = 0 /* States.BeforeNodeModules */; while (partEnd >= 0) { partStart = partEnd; partEnd = fullPath.indexOf("/", partStart + 1); switch (state) { - case 0 /* BeforeNodeModules */: + case 0 /* States.BeforeNodeModules */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { topLevelNodeModulesIndex = partStart; topLevelPackageNameIndex = partEnd; - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } break; - case 1 /* NodeModules */: - case 2 /* Scope */: - if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { - state = 2 /* Scope */; + case 1 /* States.NodeModules */: + case 2 /* States.Scope */: + if (state === 1 /* States.NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* States.Scope */; } else { packageRootIndex = partEnd; - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; - case 3 /* PackageContent */: + case 3 /* States.PackageContent */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } else { - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; } } fileNameIndex = partStart; - return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; + return state > 1 /* States.NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; } ts.getNodeModulePathParts = getNodeModulePathParts; function getParameterTypeNode(parameter) { var _a; - return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; + return parameter.kind === 340 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; } ts.getParameterTypeNode = getParameterTypeNode; })(ts || (ts = {})); @@ -21751,28 +21871,28 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* SyntaxKind.BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 214 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 214 /* SyntaxKind.ArrowFunction */ && binaryOperatorPrecedence > 3 /* OperatorPrecedence.Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If the operand is the right side of a right-associative binary operation // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 224 /* YieldExpression */) { + && binaryOperatorAssociativity === 1 /* Associativity.Right */ + && operand.kind === 224 /* SyntaxKind.YieldExpression */) { return false; } return true; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: return false; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: if (isLeftSideOfBinary) { // No need to parenthesize the left operand when the binary operator is // left associative: @@ -21783,7 +21903,7 @@ var ts; // right associative: // (a/b)**x -> (a/b)**x // (a**b)**x -> (a**b)**x - return binaryOperatorAssociativity === 1 /* Right */; + return binaryOperatorAssociativity === 1 /* Associativity.Right */; } else { if (ts.isBinaryExpression(emittedOperand) @@ -21803,8 +21923,8 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 39 /* PlusToken */) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; + if (binaryOperator === 39 /* SyntaxKind.PlusToken */) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* SyntaxKind.Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; } @@ -21820,7 +21940,7 @@ var ts; // x/(a*b) -> x/(a*b) // x**(a/b) -> x**(a/b) var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0 /* Left */; + return operandAssociativity === 0 /* Associativity.Left */; } } } @@ -21838,10 +21958,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 41 /* AsteriskToken */ - || binaryOperator === 51 /* BarToken */ - || binaryOperator === 50 /* AmpersandToken */ - || binaryOperator === 52 /* CaretToken */; + return binaryOperator === 41 /* SyntaxKind.AsteriskToken */ + || binaryOperator === 51 /* SyntaxKind.BarToken */ + || binaryOperator === 50 /* SyntaxKind.AmpersandToken */ + || binaryOperator === 52 /* SyntaxKind.CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -21854,7 +21974,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -21862,11 +21982,11 @@ var ts; var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind - : 0 /* Unknown */; + : 0 /* SyntaxKind.Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended @@ -21880,7 +22000,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 212 /* ParenthesizedExpression */) { + if (skipped.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -21897,10 +22017,10 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(222 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(222 /* SyntaxKind.ConditionalExpression */, 57 /* SyntaxKind.QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* Comparison.GreaterThan */) { return factory.createParenthesizedExpression(condition); } return condition; @@ -21930,8 +22050,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: needsParens = true; } } @@ -21944,9 +22064,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return factory.createParenthesizedExpression(expression); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -21957,7 +22077,7 @@ var ts; * Wraps an expression in parentheses if it is needed in order to use the expression for * property or element access. */ - function parenthesizeLeftSideOfAccess(expression) { + function parenthesizeLeftSideOfAccess(expression, optionalChain) { // isLeftHandSideExpression is almost the correct criterion for when it is not necessary // to parenthesize the expression before a dot. The known exception is: // @@ -21966,7 +22086,8 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 /* SyntaxKind.NewExpression */ || emittedExpression.arguments) + && (optionalChain || !ts.isOptionalChain(emittedExpression))) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -21988,7 +22109,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, 27 /* SyntaxKind.CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -21997,21 +22118,21 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 213 /* FunctionExpression */ || kind === 214 /* ArrowFunction */) { + if (kind === 213 /* SyntaxKind.FunctionExpression */ || kind === 214 /* SyntaxKind.ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); - return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); + return factory.restoreOuterExpressions(expression, updated, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 205 /* ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* FunctionExpression */) { + if (leftmostExpressionKind === 205 /* SyntaxKind.ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* SyntaxKind.FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } @@ -22029,16 +22150,16 @@ var ts; // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type function parenthesizeCheckTypeOfConditionalType(checkType) { switch (checkType.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 189 /* ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(checkType); } return checkType; } function parenthesizeExtendsTypeOfConditionalType(extendsType) { switch (extendsType.kind) { - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(extendsType); } return extendsType; @@ -22050,8 +22171,8 @@ var ts; // - A union type constituent has the same precedence as the check type of a conditional type function parenthesizeConstituentTypeOfUnionType(type) { switch (type.kind) { - case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened - case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 187 /* SyntaxKind.UnionType */: // Not strictly necessary, but a union containing a union should have been flattened + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeCheckTypeOfConditionalType(type); @@ -22066,8 +22187,8 @@ var ts; // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized) function parenthesizeConstituentTypeOfIntersectionType(type) { switch (type.kind) { - case 187 /* UnionType */: - case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfUnionType(type); @@ -22084,14 +22205,14 @@ var ts; // function parenthesizeOperandOfTypeOperator(type) { switch (type.kind) { - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfIntersectionType(type); } function parenthesizeOperandOfReadonlyTypeOperator(type) { switch (type.kind) { - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -22111,9 +22232,9 @@ var ts; // function parenthesizeNonArrayTypeOfPostfixType(type) { switch (type.kind) { - case 190 /* InferType */: - case 193 /* TypeOperator */: - case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 190 /* SyntaxKind.InferType */: + case 193 /* SyntaxKind.TypeOperator */: + case 181 /* SyntaxKind.TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -22307,11 +22428,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -22369,10 +22490,10 @@ var ts; */ /* @internal */ function createNodeFactory(flags, baseFactory) { - var update = flags & 8 /* NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; + var update = flags & 8 /* NodeFactoryFlags.NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; // Lazily load the parenthesizer, node converters, and some factory methods until they are used. - var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); - var converters = ts.memoize(function () { return flags & 2 /* NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); + var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NodeFactoryFlags.NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); + var converters = ts.memoize(function () { return flags & 2 /* NodeFactoryFlags.NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); // lazy initializaton of common operator factories var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; }); var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; }); @@ -22503,12 +22624,12 @@ var ts; updateArrayLiteralExpression: updateArrayLiteralExpression, createObjectLiteralExpression: createObjectLiteralExpression, updateObjectLiteralExpression: updateObjectLiteralExpression, - createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* NoIndentation */); } : + createPropertyAccessExpression: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessExpression, updatePropertyAccessExpression: updatePropertyAccessExpression, - createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* NoIndentation */); } : + createPropertyAccessChain: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessChain, updatePropertyAccessChain: updatePropertyAccessChain, createElementAccessExpression: createElementAccessExpression, @@ -22664,18 +22785,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* SyntaxKind.JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* SyntaxKind.JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -22711,30 +22832,30 @@ var ts; createJSDocLinkPlain: createJSDocLinkPlain, updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* JSDocReadonlyTag */); }, - get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* JSDocOverrideTag */); }, - get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* JSDocOverrideTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -22802,38 +22923,38 @@ var ts; updateSyntheticReferenceExpression: updateSyntheticReferenceExpression, cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities - get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, - get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, - get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, - get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, - get createBitwiseXor() { return getBinaryCreateFunction(52 /* CaretToken */); }, - get createBitwiseAnd() { return getBinaryCreateFunction(50 /* AmpersandToken */); }, - get createStrictEquality() { return getBinaryCreateFunction(36 /* EqualsEqualsEqualsToken */); }, - get createStrictInequality() { return getBinaryCreateFunction(37 /* ExclamationEqualsEqualsToken */); }, - get createEquality() { return getBinaryCreateFunction(34 /* EqualsEqualsToken */); }, - get createInequality() { return getBinaryCreateFunction(35 /* ExclamationEqualsToken */); }, - get createLessThan() { return getBinaryCreateFunction(29 /* LessThanToken */); }, - get createLessThanEquals() { return getBinaryCreateFunction(32 /* LessThanEqualsToken */); }, - get createGreaterThan() { return getBinaryCreateFunction(31 /* GreaterThanToken */); }, - get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* GreaterThanEqualsToken */); }, - get createLeftShift() { return getBinaryCreateFunction(47 /* LessThanLessThanToken */); }, - get createRightShift() { return getBinaryCreateFunction(48 /* GreaterThanGreaterThanToken */); }, - get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* GreaterThanGreaterThanGreaterThanToken */); }, - get createAdd() { return getBinaryCreateFunction(39 /* PlusToken */); }, - get createSubtract() { return getBinaryCreateFunction(40 /* MinusToken */); }, - get createMultiply() { return getBinaryCreateFunction(41 /* AsteriskToken */); }, - get createDivide() { return getBinaryCreateFunction(43 /* SlashToken */); }, - get createModulo() { return getBinaryCreateFunction(44 /* PercentToken */); }, - get createExponent() { return getBinaryCreateFunction(42 /* AsteriskAsteriskToken */); }, - get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* PlusToken */); }, - get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* MinusToken */); }, - get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* MinusMinusToken */); }, - get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* TildeToken */); }, - get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* ExclamationToken */); }, - get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* MinusMinusToken */); }, + get createComma() { return getBinaryCreateFunction(27 /* SyntaxKind.CommaToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* SyntaxKind.EqualsToken */); }, + get createLogicalOr() { return getBinaryCreateFunction(56 /* SyntaxKind.BarBarToken */); }, + get createLogicalAnd() { return getBinaryCreateFunction(55 /* SyntaxKind.AmpersandAmpersandToken */); }, + get createBitwiseOr() { return getBinaryCreateFunction(51 /* SyntaxKind.BarToken */); }, + get createBitwiseXor() { return getBinaryCreateFunction(52 /* SyntaxKind.CaretToken */); }, + get createBitwiseAnd() { return getBinaryCreateFunction(50 /* SyntaxKind.AmpersandToken */); }, + get createStrictEquality() { return getBinaryCreateFunction(36 /* SyntaxKind.EqualsEqualsEqualsToken */); }, + get createStrictInequality() { return getBinaryCreateFunction(37 /* SyntaxKind.ExclamationEqualsEqualsToken */); }, + get createEquality() { return getBinaryCreateFunction(34 /* SyntaxKind.EqualsEqualsToken */); }, + get createInequality() { return getBinaryCreateFunction(35 /* SyntaxKind.ExclamationEqualsToken */); }, + get createLessThan() { return getBinaryCreateFunction(29 /* SyntaxKind.LessThanToken */); }, + get createLessThanEquals() { return getBinaryCreateFunction(32 /* SyntaxKind.LessThanEqualsToken */); }, + get createGreaterThan() { return getBinaryCreateFunction(31 /* SyntaxKind.GreaterThanToken */); }, + get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* SyntaxKind.GreaterThanEqualsToken */); }, + get createLeftShift() { return getBinaryCreateFunction(47 /* SyntaxKind.LessThanLessThanToken */); }, + get createRightShift() { return getBinaryCreateFunction(48 /* SyntaxKind.GreaterThanGreaterThanToken */); }, + get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */); }, + get createAdd() { return getBinaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createSubtract() { return getBinaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createMultiply() { return getBinaryCreateFunction(41 /* SyntaxKind.AsteriskToken */); }, + get createDivide() { return getBinaryCreateFunction(43 /* SyntaxKind.SlashToken */); }, + get createModulo() { return getBinaryCreateFunction(44 /* SyntaxKind.PercentToken */); }, + get createExponent() { return getBinaryCreateFunction(42 /* SyntaxKind.AsteriskAsteriskToken */); }, + get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, + get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* SyntaxKind.TildeToken */); }, + get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* SyntaxKind.ExclamationToken */); }, + get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, // Compound nodes createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression, createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction, @@ -22937,11 +23058,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -22959,7 +23080,7 @@ var ts; node.typeParameters = asNodeArray(typeParameters); node.transformFlags |= propagateChildrenFlags(node.typeParameters); if (typeParameters) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type) { @@ -22970,7 +23091,7 @@ var ts; propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used for quick info node.typeArguments = undefined; return node; @@ -22985,9 +23106,9 @@ var ts; function createBaseFunctionLikeDeclaration(kind, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; if (!body) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseInterfaceOrClassLikeDeclaration(kind, modifiers, name, typeParameters, heritageClauses) { @@ -23013,7 +23134,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } // @@ -23026,21 +23147,21 @@ var ts; } // @api function createNumericLiteral(value, numericLiteralFlags) { - if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* None */; } - var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); + if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* TokenFlags.None */; } + var node = createBaseLiteral(8 /* SyntaxKind.NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; - if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 1024 /* ContainsES2015 */; + if (numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api function createBigIntLiteral(value) { - var node = createBaseLiteral(9 /* BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); - node.transformFlags |= 4 /* ContainsESNext */; + var node = createBaseLiteral(9 /* SyntaxKind.BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } function createBaseStringLiteral(text, isSingleQuote) { - var node = createBaseLiteral(10 /* StringLiteral */, text); + var node = createBaseLiteral(10 /* SyntaxKind.StringLiteral */, text); node.singleQuote = isSingleQuote; return node; } @@ -23049,7 +23170,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -23060,19 +23181,19 @@ var ts; } // @api function createRegularExpressionLiteral(text) { - var node = createBaseLiteral(13 /* RegularExpressionLiteral */, text); + var node = createBaseLiteral(13 /* SyntaxKind.RegularExpressionLiteral */, text); return node; } // @api function createLiteralLikeNode(kind, text) { switch (kind) { - case 8 /* NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); - case 9 /* BigIntLiteral */: return createBigIntLiteral(text); - case 10 /* StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); - case 11 /* JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); - case 12 /* JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); - case 13 /* RegularExpressionLiteral */: return createRegularExpressionLiteral(text); - case 14 /* NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); + case 8 /* SyntaxKind.NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); + case 9 /* SyntaxKind.BigIntLiteral */: return createBigIntLiteral(text); + case 10 /* SyntaxKind.StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); + case 11 /* SyntaxKind.JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); + case 13 /* SyntaxKind.RegularExpressionLiteral */: return createRegularExpressionLiteral(text); + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); } } // @@ -23082,10 +23203,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 79 /* Identifier */) { + if (originalKeywordKind === 79 /* SyntaxKind.Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -23104,8 +23225,8 @@ var ts; // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 132 /* AwaitKeyword */) { - node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { + node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; } return node; } @@ -23117,9 +23238,9 @@ var ts; } // @api function createTempVariable(recordTempVariable, reservedInNestedScopes) { - var flags = 1 /* Auto */; + var flags = 1 /* GeneratedIdentifierFlags.Auto */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; var name = createBaseGeneratedIdentifier("", flags); if (recordTempVariable) { recordTempVariable(name); @@ -23129,25 +23250,25 @@ var ts; /** Create a unique temporary variable for use in a loop. */ // @api function createLoopVariable(reservedInNestedScopes) { - var flags = 2 /* Loop */; + var flags = 2 /* GeneratedIdentifierFlags.Loop */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api function createUniqueName(text, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - ts.Debug.assert((flags & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); - return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags); + if (flags === void 0) { flags = 0 /* GeneratedIdentifierFlags.None */; } + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + ts.Debug.assert((flags & (16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)) !== 32 /* GeneratedIdentifierFlags.FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); + return createBaseGeneratedIdentifier(text, 3 /* GeneratedIdentifierFlags.Unique */ | flags); } /** Create a unique name generated for a node. */ // @api function getGeneratedNameForNode(node, flags) { if (flags === void 0) { flags = 0; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* Node */ | flags); + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* GeneratedIdentifierFlags.Node */ | flags); name.original = node; return name; } @@ -23155,9 +23276,9 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 16777216 /* ContainsClassFields */; + node.transformFlags |= 16777216 /* TransformFlags.ContainsClassFields */; return node; } // @@ -23167,51 +23288,51 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 160 /* LastToken */, "Invalid token"); - ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); - ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token >= 0 /* SyntaxKind.FirstToken */ && token <= 160 /* SyntaxKind.LastToken */, "Invalid token"); + ts.Debug.assert(token <= 14 /* SyntaxKind.FirstTemplateToken */ || token >= 17 /* SyntaxKind.LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); + ts.Debug.assert(token <= 8 /* SyntaxKind.FirstLiteralToken */ || token >= 14 /* SyntaxKind.LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); + ts.Debug.assert(token !== 79 /* SyntaxKind.Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); - var transformFlags = 0 /* None */; + var transformFlags = 0 /* TransformFlags.None */; switch (token) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; break; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 126 /* AbstractKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 155 /* UnknownKeyword */: - case 153 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. - transformFlags = 1 /* ContainsTypeScript */; + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + transformFlags = 1 /* TransformFlags.ContainsTypeScript */; break; - case 106 /* SuperKeyword */: - transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */; + case 106 /* SyntaxKind.SuperKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */ | 134217728 /* TransformFlags.ContainsLexicalSuper */; break; - case 124 /* StaticKeyword */: - transformFlags = 1024 /* ContainsES2015 */; + case 124 /* SyntaxKind.StaticKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */; break; - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 16384 /* ContainsLexicalThis */; + transformFlags = 16384 /* TransformFlags.ContainsLexicalThis */; break; } if (transformFlags) { @@ -23224,23 +23345,23 @@ var ts; // // @api function createSuper() { - return createToken(106 /* SuperKeyword */); + return createToken(106 /* SyntaxKind.SuperKeyword */); } // @api function createThis() { - return createToken(108 /* ThisKeyword */); + return createToken(108 /* SyntaxKind.ThisKeyword */); } // @api function createNull() { - return createToken(104 /* NullKeyword */); + return createToken(104 /* SyntaxKind.NullKeyword */); } // @api function createTrue() { - return createToken(110 /* TrueKeyword */); + return createToken(110 /* SyntaxKind.TrueKeyword */); } // @api function createFalse() { - return createToken(95 /* FalseKeyword */); + return createToken(95 /* SyntaxKind.FalseKeyword */); } // // Modifiers @@ -23252,34 +23373,34 @@ var ts; // @api function createModifiersFromModifierFlags(flags) { var result = []; - if (flags & 1 /* Export */) - result.push(createModifier(93 /* ExportKeyword */)); - if (flags & 2 /* Ambient */) - result.push(createModifier(135 /* DeclareKeyword */)); - if (flags & 512 /* Default */) - result.push(createModifier(88 /* DefaultKeyword */)); - if (flags & 2048 /* Const */) - result.push(createModifier(85 /* ConstKeyword */)); - if (flags & 4 /* Public */) - result.push(createModifier(123 /* PublicKeyword */)); - if (flags & 8 /* Private */) - result.push(createModifier(121 /* PrivateKeyword */)); - if (flags & 16 /* Protected */) - result.push(createModifier(122 /* ProtectedKeyword */)); - if (flags & 128 /* Abstract */) - result.push(createModifier(126 /* AbstractKeyword */)); - if (flags & 32 /* Static */) - result.push(createModifier(124 /* StaticKeyword */)); - if (flags & 16384 /* Override */) - result.push(createModifier(159 /* OverrideKeyword */)); - if (flags & 64 /* Readonly */) - result.push(createModifier(145 /* ReadonlyKeyword */)); - if (flags & 256 /* Async */) - result.push(createModifier(131 /* AsyncKeyword */)); - if (flags & 32768 /* In */) - result.push(createModifier(101 /* InKeyword */)); - if (flags & 65536 /* Out */) - result.push(createModifier(144 /* OutKeyword */)); + if (flags & 1 /* ModifierFlags.Export */) + result.push(createModifier(93 /* SyntaxKind.ExportKeyword */)); + if (flags & 2 /* ModifierFlags.Ambient */) + result.push(createModifier(135 /* SyntaxKind.DeclareKeyword */)); + if (flags & 512 /* ModifierFlags.Default */) + result.push(createModifier(88 /* SyntaxKind.DefaultKeyword */)); + if (flags & 2048 /* ModifierFlags.Const */) + result.push(createModifier(85 /* SyntaxKind.ConstKeyword */)); + if (flags & 4 /* ModifierFlags.Public */) + result.push(createModifier(123 /* SyntaxKind.PublicKeyword */)); + if (flags & 8 /* ModifierFlags.Private */) + result.push(createModifier(121 /* SyntaxKind.PrivateKeyword */)); + if (flags & 16 /* ModifierFlags.Protected */) + result.push(createModifier(122 /* SyntaxKind.ProtectedKeyword */)); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push(createModifier(126 /* SyntaxKind.AbstractKeyword */)); + if (flags & 32 /* ModifierFlags.Static */) + result.push(createModifier(124 /* SyntaxKind.StaticKeyword */)); + if (flags & 16384 /* ModifierFlags.Override */) + result.push(createModifier(159 /* SyntaxKind.OverrideKeyword */)); + if (flags & 64 /* ModifierFlags.Readonly */) + result.push(createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); + if (flags & 256 /* ModifierFlags.Async */) + result.push(createModifier(131 /* SyntaxKind.AsyncKeyword */)); + if (flags & 32768 /* ModifierFlags.In */) + result.push(createModifier(101 /* SyntaxKind.InKeyword */)); + if (flags & 65536 /* ModifierFlags.Out */) + result.push(createModifier(144 /* SyntaxKind.OutKeyword */)); return result.length ? result : undefined; } // @@ -23287,7 +23408,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(161 /* QualifiedName */); + var node = createBaseNode(161 /* SyntaxKind.QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -23304,12 +23425,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(162 /* ComputedPropertyName */); + var node = createBaseNode(162 /* SyntaxKind.ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 131072 /* ContainsComputedPropertyName */; + 1024 /* TransformFlags.ContainsES2015 */ | + 131072 /* TransformFlags.ContainsComputedPropertyName */; return node; } // @api @@ -23323,10 +23444,10 @@ var ts; // // @api function createTypeParameterDeclaration(modifiers, name, constraint, defaultType) { - var node = createBaseNamedDeclaration(163 /* TypeParameter */, modifiers, name); + var node = createBaseNamedDeclaration(163 /* SyntaxKind.TypeParameter */, modifiers, name); node.constraint = constraint; node.default = defaultType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23340,22 +23461,22 @@ var ts; } // @api function createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164 /* Parameter */, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(164 /* SyntaxKind.Parameter */, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.questionToken); if (questionToken) - node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) - node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ModifierFlags.ParameterPropertyModifier */) + node.transformFlags |= 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; } return node; } @@ -23372,13 +23493,13 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(165 /* Decorator */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseNode(165 /* SyntaxKind.Decorator */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 8192 /* ContainsTypeScriptClassSyntax */ | - 33554432 /* ContainsDecorators */; + 1 /* TransformFlags.ContainsTypeScript */ | + 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */ | + 33554432 /* TransformFlags.ContainsDecorators */; return node; } // @api @@ -23392,10 +23513,10 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(166 /* PropertySignature */, modifiers, name); + var node = createBaseNamedDeclaration(166 /* SyntaxKind.PropertySignature */, modifiers, name); node.type = type; node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.initializer = undefined; return node; @@ -23418,18 +23539,18 @@ var ts; } // @api function createPropertyDeclaration(modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(167 /* PropertyDeclaration */, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(167 /* SyntaxKind.PropertyDeclaration */, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 16777216 /* ContainsClassFields */; + 16777216 /* TransformFlags.ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */; } - if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23446,9 +23567,9 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168 /* MethodSignature */, modifiers, name, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(168 /* SyntaxKind.MethodSignature */, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23464,26 +23585,26 @@ var ts; } // @api function createMethodDeclaration(modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(169 /* MethodDeclaration */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(169 /* SyntaxKind.MethodDeclaration */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (questionToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } // The following properties are used only to report grammar errors node.exclamationToken = undefined; @@ -23510,12 +23631,12 @@ var ts; } // @api function createClassStaticBlockDeclaration(body) { - var node = createBaseGenericNamedDeclaration(170 /* ClassStaticBlockDeclaration */, + var node = createBaseGenericNamedDeclaration(170 /* SyntaxKind.ClassStaticBlockDeclaration */, /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined); node.body = body; - node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */; + node.transformFlags = propagateChildFlags(body) | 16777216 /* TransformFlags.ContainsClassFields */; // The following properties are used only to report grammar errors node.decorators = undefined; node.modifiers = undefined; @@ -23536,11 +23657,11 @@ var ts; } // @api function createConstructorDeclaration(modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(171 /* Constructor */, modifiers, + var node = createBaseFunctionLikeDeclaration(171 /* SyntaxKind.Constructor */, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; // The following properties are used only to report grammar errors node.decorators = undefined; node.typeParameters = undefined; @@ -23565,7 +23686,7 @@ var ts; } // @api function createGetAccessorDeclaration(modifiers, name, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(172 /* GetAccessor */, modifiers, name, + var node = createBaseFunctionLikeDeclaration(172 /* SyntaxKind.GetAccessor */, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); // The following properties are used only to report grammar errors node.typeParameters = undefined; @@ -23589,7 +23710,7 @@ var ts; } // @api function createSetAccessorDeclaration(modifiers, name, parameters, body) { - var node = createBaseFunctionLikeDeclaration(173 /* SetAccessor */, modifiers, name, + var node = createBaseFunctionLikeDeclaration(173 /* SyntaxKind.SetAccessor */, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); // The following properties are used only to report grammar errors @@ -23615,10 +23736,10 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* CallSignature */, + var node = createBaseSignatureDeclaration(174 /* SyntaxKind.CallSignature */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23631,10 +23752,10 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(175 /* SyntaxKind.ConstructSignature */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23647,10 +23768,10 @@ var ts; } // @api function createIndexSignature(modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(176 /* IndexSignature */, modifiers, + var node = createBaseSignatureDeclaration(176 /* SyntaxKind.IndexSignature */, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23663,10 +23784,10 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(199 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(199 /* SyntaxKind.TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23685,11 +23806,11 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(177 /* TypePredicate */); + var node = createBaseNode(177 /* SyntaxKind.TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23702,10 +23823,10 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(178 /* TypeReference */); + var node = createBaseNode(178 /* SyntaxKind.TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23717,10 +23838,10 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(179 /* FunctionType */, + var node = createBaseSignatureDeclaration(179 /* SyntaxKind.FunctionType */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.modifiers = undefined; return node; @@ -23750,9 +23871,9 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(180 /* ConstructorType */, modifiers, + var node = createBaseSignatureDeclaration(180 /* SyntaxKind.ConstructorType */, modifiers, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } /** @deprecated */ @@ -23783,10 +23904,10 @@ var ts; } // @api function createTypeQueryNode(exprName, typeArguments) { - var node = createBaseNode(181 /* TypeQuery */); + var node = createBaseNode(181 /* SyntaxKind.TypeQuery */); node.exprName = exprName; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23798,9 +23919,9 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(182 /* TypeLiteral */); + var node = createBaseNode(182 /* SyntaxKind.TypeLiteral */); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23811,9 +23932,9 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(183 /* ArrayType */); + var node = createBaseNode(183 /* SyntaxKind.ArrayType */); node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23824,9 +23945,9 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(184 /* TupleType */); + var node = createBaseNode(184 /* SyntaxKind.TupleType */); node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23837,12 +23958,12 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(197 /* NamedTupleMember */); + var node = createBaseNode(197 /* SyntaxKind.NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23856,9 +23977,9 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(185 /* OptionalType */); + var node = createBaseNode(185 /* SyntaxKind.OptionalType */); node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23869,9 +23990,9 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(186 /* RestType */); + var node = createBaseNode(186 /* SyntaxKind.RestType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23883,7 +24004,7 @@ var ts; function createUnionOrIntersectionTypeNode(kind, types, parenthesize) { var node = createBaseNode(kind); node.types = factory.createNodeArray(parenthesize(types)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateUnionOrIntersectionTypeNode(node, types, parenthesize) { @@ -23893,7 +24014,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); + return createUnionOrIntersectionTypeNode(187 /* SyntaxKind.UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); } // @api function updateUnionTypeNode(node, types) { @@ -23901,7 +24022,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); + return createUnionOrIntersectionTypeNode(188 /* SyntaxKind.IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); } // @api function updateIntersectionTypeNode(node, types) { @@ -23909,12 +24030,12 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(189 /* ConditionalType */); + var node = createBaseNode(189 /* SyntaxKind.ConditionalType */); node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType); node.trueType = trueType; node.falseType = falseType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23928,9 +24049,9 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(190 /* InferType */); + var node = createBaseNode(190 /* SyntaxKind.InferType */); node.typeParameter = typeParameter; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23941,10 +24062,10 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(198 /* TemplateLiteralType */); + var node = createBaseNode(198 /* SyntaxKind.TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23957,13 +24078,13 @@ var ts; // @api function createImportTypeNode(argument, assertions, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(200 /* ImportType */); + var node = createBaseNode(200 /* SyntaxKind.ImportType */); node.argument = argument; node.assertions = assertions; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23979,9 +24100,9 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(191 /* ParenthesizedType */); + var node = createBaseNode(191 /* SyntaxKind.ParenthesizedType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23992,18 +24113,18 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(192 /* ThisType */); - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseNode(192 /* SyntaxKind.ThisType */); + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(193 /* TypeOperator */); + var node = createBaseNode(193 /* SyntaxKind.TypeOperator */); node.operator = operator; - node.type = operator === 145 /* ReadonlyKeyword */ ? + node.type = operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) : parenthesizerRules().parenthesizeOperandOfTypeOperator(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24014,10 +24135,10 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(194 /* IndexedAccessType */); + var node = createBaseNode(194 /* SyntaxKind.IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType); node.indexType = indexType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24029,14 +24150,14 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) { - var node = createBaseNode(195 /* MappedType */); + var node = createBaseNode(195 /* SyntaxKind.MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; node.questionToken = questionToken; node.type = type; node.members = members && createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24052,9 +24173,9 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(196 /* LiteralType */); + var node = createBaseNode(196 /* SyntaxKind.LiteralType */); node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24068,16 +24189,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(201 /* ObjectBindingPattern */); + var node = createBaseNode(201 /* SyntaxKind.ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 524288 /* ContainsBindingPattern */; - if (node.transformFlags & 32768 /* ContainsRestOrSpread */) { + 1024 /* TransformFlags.ContainsES2015 */ | + 524288 /* TransformFlags.ContainsBindingPattern */; + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */) { node.transformFlags |= - 128 /* ContainsES2018 */ | - 65536 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 65536 /* TransformFlags.ContainsObjectRestOrSpread */; } return node; } @@ -24089,12 +24210,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(202 /* ArrayBindingPattern */); + var node = createBaseNode(202 /* SyntaxKind.ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 524288 /* ContainsBindingPattern */; + 1024 /* TransformFlags.ContainsES2015 */ | + 524288 /* TransformFlags.ContainsBindingPattern */; return node; } // @api @@ -24105,20 +24226,20 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(203 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(203 /* SyntaxKind.BindingElement */, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 32768 /* ContainsRestOrSpread */; + node.transformFlags |= 32768 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24140,7 +24261,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(204 /* ArrayLiteralExpression */); + var node = createBaseExpression(204 /* SyntaxKind.ArrayLiteralExpression */); // Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that // we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like // a trailing comma. @@ -24159,7 +24280,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(205 /* ObjectLiteralExpression */); + var node = createBaseExpression(205 /* SyntaxKind.ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -24173,20 +24294,20 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.name = asName(name); node.transformFlags = propagateChildFlags(node.expression) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); if (ts.isSuperKeyword(expression)) { // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24202,23 +24323,23 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 32 /* ContainsES2020 */ | + 32 /* TransformFlags.ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); return node; } // @api function updatePropertyAccessChain(node, expression, questionDotToken, name) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -24229,8 +24350,8 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | @@ -24239,8 +24360,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24256,21 +24377,21 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; return node; } // @api function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); // Because we are updating an existing ElementAccessChain we want to inherit its emitFlags // instead of using the default from createElementAccess return node.expression !== expression @@ -24281,8 +24402,8 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); node.transformFlags |= @@ -24290,13 +24411,13 @@ var ts; propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments); if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 8388608 /* ContainsDynamicImport */; + node.transformFlags |= 8388608 /* TransformFlags.ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 16384 /* ContainsLexicalThis */; + node.transformFlags |= 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24313,9 +24434,9 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -24324,18 +24445,18 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 16384 /* ContainsLexicalThis */; + node.transformFlags |= 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } // @api function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); return node.expression !== expression || node.questionDotToken !== questionDotToken || node.typeArguments !== typeArguments @@ -24345,7 +24466,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(209 /* NewExpression */); + var node = createBaseExpression(209 /* SyntaxKind.NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -24353,9 +24474,9 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24369,20 +24490,20 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(210 /* TaggedTemplateExpression */); - node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); + var node = createBaseExpression(210 /* SyntaxKind.TaggedTemplateExpression */); + node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false); node.typeArguments = asNodeArray(typeArguments); node.template = template; node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24396,13 +24517,13 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(211 /* TypeAssertionExpression */); + var node = createBaseExpression(211 /* SyntaxKind.TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24414,7 +24535,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(212 /* ParenthesizedExpression */); + var node = createBaseExpression(212 /* SyntaxKind.ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -24427,22 +24548,22 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(213 /* FunctionExpression */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(213 /* SyntaxKind.FunctionExpression */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -24460,14 +24581,14 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(214 /* ArrowFunction */, modifiers, + var node = createBaseFunctionLikeDeclaration(214 /* SyntaxKind.ArrowFunction */, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); - node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* SyntaxKind.EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 1024 /* ContainsES2015 */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */; + 1024 /* TransformFlags.ContainsES2015 */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */ | 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24484,7 +24605,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(215 /* DeleteExpression */); + var node = createBaseExpression(215 /* SyntaxKind.DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24497,7 +24618,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(216 /* TypeOfExpression */); + var node = createBaseExpression(216 /* SyntaxKind.TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24510,7 +24631,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(217 /* VoidExpression */); + var node = createBaseExpression(217 /* SyntaxKind.VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24523,13 +24644,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(218 /* AwaitExpression */); + var node = createBaseExpression(218 /* SyntaxKind.AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */ | - 2097152 /* ContainsAwait */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 2097152 /* TransformFlags.ContainsAwait */; return node; } // @api @@ -24540,17 +24661,17 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(219 /* PrefixUnaryExpression */); + var node = createBaseExpression(219 /* SyntaxKind.PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); // Only set this flag for non-generated identifiers and non-"local" names. See the // comment in `visitPreOrPostfixUnaryExpression` in module.ts - if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) && + if ((operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24562,7 +24683,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(220 /* PostfixUnaryExpression */); + var node = createBaseExpression(220 /* SyntaxKind.PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -24571,7 +24692,7 @@ var ts; if (ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24583,7 +24704,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(221 /* BinaryExpression */); + var node = createBaseExpression(221 /* SyntaxKind.BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -24593,46 +24714,49 @@ var ts; propagateChildFlags(node.left) | propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); - if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 32 /* ContainsES2020 */; + if (operatorKind === 60 /* SyntaxKind.QuestionQuestionToken */) { + node.transformFlags |= 32 /* TransformFlags.ContainsES2020 */; } - else if (operatorKind === 63 /* EqualsToken */) { + else if (operatorKind === 63 /* SyntaxKind.EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 512 /* ContainsES2016 */; + else if (operatorKind === 42 /* SyntaxKind.AsteriskAsteriskToken */ || operatorKind === 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 512 /* TransformFlags.ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 16 /* ContainsES2021 */; + node.transformFlags |= 16 /* TransformFlags.ContainsES2021 */; + } + if (operatorKind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { + node.transformFlags |= 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) - return 65536 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 128 /* ContainsES2018 */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) + return 65536 /* TransformFlags.ContainsObjectRestOrSpread */; + if (node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' // will not be correctly interpreted by the ES2018 transformer for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return 65536 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return 65536 /* TransformFlags.ContainsObjectRestOrSpread */; } - if (target.transformFlags & 128 /* ContainsES2018 */) { + if (target.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -24640,7 +24764,7 @@ var ts; } } } - return 0 /* None */; + return 0 /* TransformFlags.None */; } // @api function updateBinaryExpression(node, left, operator, right) { @@ -24652,11 +24776,11 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(222 /* ConditionalExpression */); + var node = createBaseExpression(222 /* SyntaxKind.ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); - node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); + node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* SyntaxKind.QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); - node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* ColonToken */); + node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* SyntaxKind.ColonToken */); node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse); node.transformFlags |= propagateChildFlags(node.condition) | @@ -24678,13 +24802,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(223 /* TemplateExpression */); + var node = createBaseExpression(223 /* SyntaxKind.TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24695,8 +24819,8 @@ var ts; : node; } function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) { - if (templateFlags === void 0) { templateFlags = 0 /* None */; } - ts.Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags."); + if (templateFlags === void 0) { templateFlags = 0 /* TokenFlags.None */; } + ts.Debug.assert(!(templateFlags & ~2048 /* TokenFlags.TemplateLiteralLikeFlags */), "Unsupported template flags."); // NOTE: without the assignment to `undefined`, we don't narrow the initial type of `cooked`. // eslint-disable-next-line no-undef-init var cooked = undefined; @@ -24722,41 +24846,41 @@ var ts; var node = createBaseToken(kind); node.text = text; node.rawText = rawText; - node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 1024 /* ContainsES2015 */; + node.templateFlags = templateFlags & 2048 /* TokenFlags.TemplateLiteralLikeFlags */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } // @api function createTemplateHead(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(15 /* TemplateHead */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(15 /* SyntaxKind.TemplateHead */, text, rawText, templateFlags); } // @api function createTemplateMiddle(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(16 /* TemplateMiddle */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(16 /* SyntaxKind.TemplateMiddle */, text, rawText, templateFlags); } // @api function createTemplateTail(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(17 /* TemplateTail */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(17 /* SyntaxKind.TemplateTail */, text, rawText, templateFlags); } // @api function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(14 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); } // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(224 /* YieldExpression */); + var node = createBaseExpression(224 /* SyntaxKind.YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 1048576 /* ContainsYield */; + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 1048576 /* TransformFlags.ContainsYield */; return node; } // @api @@ -24768,12 +24892,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(225 /* SpreadElement */); + var node = createBaseExpression(225 /* SyntaxKind.SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 32768 /* ContainsRestOrSpread */; + 1024 /* TransformFlags.ContainsES2015 */ | + 32768 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24784,8 +24908,8 @@ var ts; } // @api function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(226 /* ClassExpression */, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(226 /* SyntaxKind.ClassExpression */, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24800,17 +24924,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(227 /* OmittedExpression */); + return createBaseExpression(227 /* SyntaxKind.OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(228 /* ExpressionWithTypeArguments */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseNode(228 /* SyntaxKind.ExpressionWithTypeArguments */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24822,13 +24946,13 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(229 /* AsExpression */); + var node = createBaseExpression(229 /* SyntaxKind.AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24840,11 +24964,11 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24858,33 +24982,33 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function updateNonNullChain(node, expression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); return node.expression !== expression ? update(createNonNullChain(expression), node) : node; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(231 /* MetaProperty */); + var node = createBaseExpression(231 /* SyntaxKind.MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 103 /* NewKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 103 /* SyntaxKind.NewKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 100 /* ImportKeyword */: - node.transformFlags |= 4 /* ContainsESNext */; + case 100 /* SyntaxKind.ImportKeyword */: + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; break; default: return ts.Debug.assertNever(keywordToken); @@ -24902,13 +25026,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(233 /* TemplateSpan */); + var node = createBaseNode(233 /* SyntaxKind.TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24920,8 +25044,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(234 /* SemicolonClassElement */); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseNode(234 /* SyntaxKind.SemicolonClassElement */); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @@ -24929,7 +25053,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(235 /* Block */); + var node = createBaseNode(235 /* SyntaxKind.Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -24943,14 +25067,14 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(237 /* VariableStatement */); + var node = createBaseDeclaration(237 /* SyntaxKind.VariableStatement */); node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.declarationList); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24963,11 +25087,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(236 /* EmptyStatement */); + return createBaseNode(236 /* SyntaxKind.EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(238 /* ExpressionStatement */); + var node = createBaseNode(238 /* SyntaxKind.ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24980,7 +25104,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(239 /* IfStatement */); + var node = createBaseNode(239 /* SyntaxKind.IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -25000,7 +25124,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(240 /* DoStatement */); + var node = createBaseNode(240 /* SyntaxKind.DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -25017,7 +25141,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(241 /* WhileStatement */); + var node = createBaseNode(241 /* SyntaxKind.WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -25034,7 +25158,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(242 /* ForStatement */); + var node = createBaseNode(242 /* SyntaxKind.ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -25057,7 +25181,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(243 /* ForInStatement */); + var node = createBaseNode(243 /* SyntaxKind.ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -25077,7 +25201,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(244 /* ForOfStatement */); + var node = createBaseNode(244 /* SyntaxKind.ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -25087,9 +25211,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; return node; } // @api @@ -25103,11 +25227,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(245 /* ContinueStatement */); + var node = createBaseNode(245 /* SyntaxKind.ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -25118,11 +25242,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(246 /* BreakStatement */); + var node = createBaseNode(246 /* SyntaxKind.BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -25133,13 +25257,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(247 /* ReturnStatement */); + var node = createBaseNode(247 /* SyntaxKind.ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 128 /* TransformFlags.ContainsES2018 */ | + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -25150,7 +25274,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(248 /* WithStatement */); + var node = createBaseNode(248 /* SyntaxKind.WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -25167,7 +25291,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(249 /* SwitchStatement */); + var node = createBaseNode(249 /* SyntaxKind.SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -25184,7 +25308,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(250 /* LabeledStatement */); + var node = createBaseNode(250 /* SyntaxKind.LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -25201,7 +25325,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(251 /* ThrowStatement */); + var node = createBaseNode(251 /* SyntaxKind.ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -25214,7 +25338,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(252 /* TryStatement */); + var node = createBaseNode(252 /* SyntaxKind.TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -25234,16 +25358,16 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(253 /* DebuggerStatement */); + return createBaseNode(253 /* SyntaxKind.DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(254 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(254 /* SyntaxKind.VariableDeclaration */, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25258,17 +25382,17 @@ var ts; } // @api function createVariableDeclarationList(declarations, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(255 /* VariableDeclarationList */); - node.flags |= flags & 3 /* BlockScoped */; + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseNode(255 /* SyntaxKind.VariableDeclarationList */); + node.flags |= flags & 3 /* NodeFlags.BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; - if (flags & 3 /* BlockScoped */) { + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (flags & 3 /* NodeFlags.BlockScoped */) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBlockScopedBinding */; + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBlockScopedBinding */; } return node; } @@ -25280,25 +25404,25 @@ var ts; } // @api function createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(256 /* FunctionDeclaration */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(256 /* SyntaxKind.FunctionDeclaration */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; - if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } } // The following properties are used only to report grammar errors @@ -25326,14 +25450,14 @@ var ts; } // @api function createClassDeclaration(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(257 /* ClassDeclaration */, modifiers, name, typeParameters, heritageClauses, members); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseClassLikeDeclaration(257 /* SyntaxKind.ClassDeclaration */, modifiers, name, typeParameters, heritageClauses, members); + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { - node.transformFlags |= 1024 /* ContainsES2015 */; - if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; + if (node.transformFlags & 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } } return node; @@ -25350,9 +25474,9 @@ var ts; } // @api function createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(258 /* InterfaceDeclaration */, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(258 /* SyntaxKind.InterfaceDeclaration */, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25375,9 +25499,9 @@ var ts; } // @api function createTypeAliasDeclaration(modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(259 /* TypeAliasDeclaration */, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(259 /* SyntaxKind.TypeAliasDeclaration */, modifiers, name, typeParameters); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25399,12 +25523,12 @@ var ts; } // @api function createEnumDeclaration(modifiers, name, members) { - var node = createBaseNamedDeclaration(260 /* EnumDeclaration */, modifiers, name); + var node = createBaseNamedDeclaration(260 /* SyntaxKind.EnumDeclaration */, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25425,23 +25549,23 @@ var ts; } // @api function createModuleDeclaration(modifiers, name, body, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(261 /* ModuleDeclaration */); + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseDeclaration(261 /* SyntaxKind.ModuleDeclaration */); node.modifiers = asNodeArray(modifiers); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); + node.flags |= flags & (16 /* NodeFlags.Namespace */ | 4 /* NodeFlags.NestedNamespace */ | 1024 /* NodeFlags.GlobalAugmentation */); node.name = name; node.body = body; - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25462,7 +25586,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(262 /* ModuleBlock */); + var node = createBaseNode(262 /* SyntaxKind.ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -25475,7 +25599,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(263 /* CaseBlock */); + var node = createBaseNode(263 /* SyntaxKind.CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -25488,9 +25612,9 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(264 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(264 /* SyntaxKind.NamespaceExportDeclaration */, /*modifiers*/ undefined, name); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; node.modifiers = undefined; @@ -25511,13 +25635,13 @@ var ts; } // @api function createImportEqualsDeclaration(modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(265 /* ImportEqualsDeclaration */, modifiers, name); + var node = createBaseNamedDeclaration(265 /* SyntaxKind.ImportEqualsDeclaration */, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) - node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25539,7 +25663,7 @@ var ts; } // @api function createImportDeclaration(modifiers, importClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(266 /* ImportDeclaration */); + var node = createBaseDeclaration(266 /* SyntaxKind.ImportDeclaration */); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; @@ -25547,7 +25671,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25569,7 +25693,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(267 /* ImportClause */); + var node = createBaseNode(267 /* SyntaxKind.ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -25577,9 +25701,9 @@ var ts; propagateChildFlags(node.name) | propagateChildFlags(node.namedBindings); if (isTypeOnly) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25592,10 +25716,10 @@ var ts; } // @api function createAssertClause(elements, multiLine) { - var node = createBaseNode(293 /* AssertClause */); + var node = createBaseNode(293 /* SyntaxKind.AssertClause */); node.elements = createNodeArray(elements); node.multiLine = multiLine; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25607,10 +25731,10 @@ var ts; } // @api function createAssertEntry(name, value) { - var node = createBaseNode(294 /* AssertEntry */); + var node = createBaseNode(294 /* SyntaxKind.AssertEntry */); node.name = name; node.value = value; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25622,7 +25746,7 @@ var ts; } // @api function createImportTypeAssertionContainer(clause, multiLine) { - var node = createBaseNode(295 /* ImportTypeAssertionContainer */); + var node = createBaseNode(295 /* SyntaxKind.ImportTypeAssertionContainer */); node.assertClause = clause; node.multiLine = multiLine; return node; @@ -25636,10 +25760,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(268 /* NamespaceImport */); + var node = createBaseNode(268 /* SyntaxKind.NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25650,12 +25774,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(274 /* NamespaceExport */); + var node = createBaseNode(274 /* SyntaxKind.NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | - 4 /* ContainsESNext */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + 4 /* TransformFlags.ContainsESNext */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25666,10 +25790,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(269 /* NamedImports */); + var node = createBaseNode(269 /* SyntaxKind.NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25680,14 +25804,14 @@ var ts; } // @api function createImportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(270 /* ImportSpecifier */); + var node = createBaseNode(270 /* SyntaxKind.ImportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25700,14 +25824,14 @@ var ts; } // @api function createExportAssignment(modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(271 /* ExportAssignment */); + var node = createBaseDeclaration(271 /* SyntaxKind.ExportAssignment */); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* SyntaxKind.EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.expression); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25727,7 +25851,7 @@ var ts; } // @api function createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(272 /* ExportDeclaration */); + var node = createBaseDeclaration(272 /* SyntaxKind.ExportDeclaration */); node.modifiers = asNodeArray(modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; @@ -25737,7 +25861,7 @@ var ts; propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25760,10 +25884,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(273 /* NamedExports */); + var node = createBaseNode(273 /* SyntaxKind.NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25774,14 +25898,14 @@ var ts; } // @api function createExportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(275 /* ExportSpecifier */); + var node = createBaseNode(275 /* SyntaxKind.ExportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25794,7 +25918,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(276 /* MissingDeclaration */); + var node = createBaseDeclaration(276 /* SyntaxKind.MissingDeclaration */); return node; } // @@ -25802,10 +25926,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(277 /* ExternalModuleReference */); + var node = createBaseNode(277 /* SyntaxKind.ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25860,7 +25984,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(317 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(317 /* SyntaxKind.JSDocFunctionType */, /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); @@ -25876,7 +26000,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(322 /* JSDocTypeLiteral */); + var node = createBaseNode(322 /* SyntaxKind.JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -25890,7 +26014,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(309 /* JSDocTypeExpression */); + var node = createBaseNode(309 /* SyntaxKind.JSDocTypeExpression */); node.type = type; return node; } @@ -25902,7 +26026,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(323 /* JSDocSignature */); + var node = createBaseNode(323 /* SyntaxKind.JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -25931,7 +26055,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(344 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(344 /* SyntaxKind.JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -25948,7 +26072,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(345 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(345 /* SyntaxKind.JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25966,7 +26090,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(340 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(340 /* SyntaxKind.JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25987,7 +26111,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(347 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(347 /* SyntaxKind.JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -26008,7 +26132,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(338 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(338 /* SyntaxKind.JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -26026,7 +26150,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(328 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(328 /* SyntaxKind.JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -26041,13 +26165,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(329 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(329 /* SyntaxKind.JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(346 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(346 /* SyntaxKind.JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -26061,7 +26185,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(310 /* JSDocNameReference */); + var node = createBaseNode(310 /* SyntaxKind.JSDocNameReference */); node.name = name; return node; } @@ -26073,7 +26197,7 @@ var ts; } // @api function createJSDocMemberName(left, right) { - var node = createBaseNode(311 /* JSDocMemberName */); + var node = createBaseNode(311 /* SyntaxKind.JSDocMemberName */); node.left = left; node.right = right; node.transformFlags |= @@ -26090,7 +26214,7 @@ var ts; } // @api function createJSDocLink(name, text) { - var node = createBaseNode(324 /* JSDocLink */); + var node = createBaseNode(324 /* SyntaxKind.JSDocLink */); node.name = name; node.text = text; return node; @@ -26103,7 +26227,7 @@ var ts; } // @api function createJSDocLinkCode(name, text) { - var node = createBaseNode(325 /* JSDocLinkCode */); + var node = createBaseNode(325 /* SyntaxKind.JSDocLinkCode */); node.name = name; node.text = text; return node; @@ -26116,7 +26240,7 @@ var ts; } // @api function createJSDocLinkPlain(name, text) { - var node = createBaseNode(326 /* JSDocLinkPlain */); + var node = createBaseNode(326 /* SyntaxKind.JSDocLinkPlain */); node.name = name; node.text = text; return node; @@ -26188,7 +26312,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(327 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(327 /* SyntaxKind.JSDocTag */, tagName, comment); return node; } // @api @@ -26200,7 +26324,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(321 /* JSDocText */); + var node = createBaseNode(321 /* SyntaxKind.JSDocText */); node.text = text; return node; } @@ -26212,7 +26336,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(320 /* JSDoc */); + var node = createBaseNode(320 /* SyntaxKind.JSDoc */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -26229,7 +26353,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(278 /* JsxElement */); + var node = createBaseNode(278 /* SyntaxKind.JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -26237,7 +26361,7 @@ var ts; propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26250,7 +26374,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(279 /* JsxSelfClosingElement */); + var node = createBaseNode(279 /* SyntaxKind.JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -26258,9 +26382,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -26274,7 +26398,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(280 /* JsxOpeningElement */); + var node = createBaseNode(280 /* SyntaxKind.JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -26282,9 +26406,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -26298,11 +26422,11 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(281 /* JsxClosingElement */); + var node = createBaseNode(281 /* SyntaxKind.JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26313,7 +26437,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(282 /* JsxFragment */); + var node = createBaseNode(282 /* SyntaxKind.JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -26321,7 +26445,7 @@ var ts; propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26334,10 +26458,10 @@ var ts; } // @api function createJsxText(text, containsOnlyTriviaWhiteSpaces) { - var node = createBaseNode(11 /* JsxText */); + var node = createBaseNode(11 /* SyntaxKind.JsxText */); node.text = text; node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces; - node.transformFlags |= 2 /* ContainsJsx */; + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26349,25 +26473,25 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(283 /* JsxOpeningFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(283 /* SyntaxKind.JsxOpeningFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(284 /* JsxClosingFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(284 /* SyntaxKind.JsxClosingFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(285 /* JsxAttribute */); + var node = createBaseNode(285 /* SyntaxKind.JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26379,11 +26503,11 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(286 /* JsxAttributes */); + var node = createBaseNode(286 /* SyntaxKind.JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26394,11 +26518,11 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(287 /* JsxSpreadAttribute */); + var node = createBaseNode(287 /* SyntaxKind.JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26409,13 +26533,13 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(288 /* JsxExpression */); + var node = createBaseNode(288 /* SyntaxKind.JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26429,7 +26553,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(289 /* CaseClause */); + var node = createBaseNode(289 /* SyntaxKind.CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -26446,7 +26570,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(290 /* DefaultClause */); + var node = createBaseNode(290 /* SyntaxKind.DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -26459,16 +26583,16 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(291 /* HeritageClause */); + var node = createBaseNode(291 /* SyntaxKind.HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 94 /* ExtendsKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 94 /* SyntaxKind.ExtendsKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 117 /* ImplementsKeyword */: - node.transformFlags |= 1 /* ContainsTypeScript */; + case 117 /* SyntaxKind.ImplementsKeyword */: + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; break; default: return ts.Debug.assertNever(token); @@ -26483,7 +26607,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(292 /* CatchClause */); + var node = createBaseNode(292 /* SyntaxKind.CatchClause */); if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) { variableDeclaration = createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, @@ -26496,7 +26620,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 64 /* ContainsES2019 */; + node.transformFlags |= 64 /* TransformFlags.ContainsES2019 */; return node; } // @api @@ -26511,7 +26635,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(296 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(296 /* SyntaxKind.PropertyAssignment */, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -26543,12 +26667,12 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(297 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(297 /* SyntaxKind.ShorthandPropertyAssignment */, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; // The following properties are used only to report grammar errors node.equalsToken = undefined; node.decorators = undefined; @@ -26577,12 +26701,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(298 /* SpreadAssignment */); + var node = createBaseNode(298 /* SyntaxKind.SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 65536 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 65536 /* TransformFlags.ContainsObjectRestOrSpread */; return node; } // @api @@ -26596,13 +26720,13 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(299 /* EnumMember */); + var node = createBaseNode(299 /* SyntaxKind.EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -26617,7 +26741,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -26634,7 +26758,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SourceFile */)); + var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */)); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -26673,7 +26797,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(306 /* Bundle */); + var node = createBaseNode(306 /* SyntaxKind.Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -26688,7 +26812,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(307 /* UnparsedSource */); + var node = createBaseNode(307 /* SyntaxKind.UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -26706,28 +26830,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(300 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(300 /* SyntaxKind.UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(301 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(301 /* SyntaxKind.UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 303 /* UnparsedInternalText */ : 302 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 303 /* SyntaxKind.UnparsedInternalText */ : 302 /* SyntaxKind.UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(304 /* UnparsedSyntheticReference */); + var node = createBaseNode(304 /* SyntaxKind.UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(308 /* InputFiles */); + var node = createBaseNode(308 /* SyntaxKind.InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -26738,7 +26862,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(232 /* SyntheticExpression */); + var node = createBaseNode(232 /* SyntaxKind.SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -26746,7 +26870,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(348 /* SyntaxList */); + var node = createBaseNode(348 /* SyntaxKind.SyntaxList */); node._children = children; return node; } @@ -26761,7 +26885,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(349 /* NotEmittedStatement */); + var node = createBaseNode(349 /* SyntaxKind.NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -26775,12 +26899,12 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(350 /* PartiallyEmittedExpression */); + var node = createBaseNode(350 /* SyntaxKind.PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -26803,7 +26927,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(351 /* CommaListExpression */); + var node = createBaseNode(351 /* SyntaxKind.CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -26820,7 +26944,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(353 /* EndOfDeclarationMarker */); + var node = createBaseNode(353 /* SyntaxKind.EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -26831,14 +26955,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(352 /* MergeDeclarationMarker */); + var node = createBaseNode(352 /* SyntaxKind.MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(354 /* SyntheticReferenceExpression */); + var node = createBaseNode(354 /* SyntaxKind.SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -26860,12 +26984,12 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); - clone.flags |= (node.flags & ~8 /* Synthesized */); + clone.flags |= (node.flags & ~8 /* NodeFlags.Synthesized */); clone.transformFlags = node.transformFlags; setOriginalNode(clone, node); for (var key in node) { @@ -26977,11 +27101,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 212 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 211 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 229 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 230 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 350 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 212 /* SyntaxKind.ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 211 /* SyntaxKind.TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 229 /* SyntaxKind.AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 230 /* SyntaxKind.NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -27007,7 +27131,7 @@ var ts; && !ts.some(ts.getSyntheticTrailingComments(node)); } function restoreOuterExpressions(outerExpression, innerExpression, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression)); } @@ -27028,20 +27152,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cacheIdentifiers; - case 108 /* ThisKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return false; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -27049,7 +27173,7 @@ var ts; } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } - var callee = ts.skipOuterExpressions(expression, 15 /* All */); + var callee = ts.skipOuterExpressions(expression, 15 /* OuterExpressionKinds.All */); var thisArg; var target; if (ts.isSuperProperty(callee)) { @@ -27058,13 +27182,13 @@ var ts; } else if (ts.isSuperKeyword(callee)) { thisArg = createThis(); - target = languageVersion !== undefined && languageVersion < 2 /* ES2015 */ + target = languageVersion !== undefined && languageVersion < 2 /* ScriptTarget.ES2015 */ ? ts.setTextRange(createIdentifier("_super"), callee) : callee; } - else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + else if (ts.getEmitFlags(callee) & 4096 /* EmitFlags.HelperName */) { thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false); } else if (ts.isPropertyAccessExpression(callee)) { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { @@ -27093,7 +27217,7 @@ var ts; else { // for `a()` target is `a` and thisArg is `void 0` thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); } return { target: target, thisArg: thisArg }; } @@ -27127,9 +27251,9 @@ var ts; var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent); emitFlags |= ts.getEmitFlags(nodeName); if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(name, emitFlags); return name; @@ -27148,7 +27272,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getInternalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */ | 32768 /* EmitFlags.InternalName */); } /** * Gets the local name of a declaration. This is primarily used for declarations that can be @@ -27161,7 +27285,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */); } /** * Gets the export name of a declaration. This is primarily used for declarations that can be @@ -27174,7 +27298,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192 /* ExportName */); + return getName(node, allowComments, allowSourceMaps, 8192 /* EmitFlags.ExportName */); } /** * Gets the name of a declaration for use in declarations. @@ -27199,9 +27323,9 @@ var ts; ts.setTextRange(qualifiedName, name); var emitFlags = 0; if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; @@ -27218,7 +27342,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -27276,7 +27400,7 @@ var ts; var numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) { + if (ts.getEmitFlags(statement) & 1048576 /* EmitFlags.CustomPrologue */ && filter(statement)) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -27467,52 +27591,52 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 343 /* JSDocTypeTag */: return "type"; - case 341 /* JSDocReturnTag */: return "returns"; - case 342 /* JSDocThisTag */: return "this"; - case 339 /* JSDocEnumTag */: return "enum"; - case 330 /* JSDocAuthorTag */: return "author"; - case 332 /* JSDocClassTag */: return "class"; - case 333 /* JSDocPublicTag */: return "public"; - case 334 /* JSDocPrivateTag */: return "private"; - case 335 /* JSDocProtectedTag */: return "protected"; - case 336 /* JSDocReadonlyTag */: return "readonly"; - case 337 /* JSDocOverrideTag */: return "override"; - case 344 /* JSDocTemplateTag */: return "template"; - case 345 /* JSDocTypedefTag */: return "typedef"; - case 340 /* JSDocParameterTag */: return "param"; - case 347 /* JSDocPropertyTag */: return "prop"; - case 338 /* JSDocCallbackTag */: return "callback"; - case 328 /* JSDocAugmentsTag */: return "augments"; - case 329 /* JSDocImplementsTag */: return "implements"; + case 343 /* SyntaxKind.JSDocTypeTag */: return "type"; + case 341 /* SyntaxKind.JSDocReturnTag */: return "returns"; + case 342 /* SyntaxKind.JSDocThisTag */: return "this"; + case 339 /* SyntaxKind.JSDocEnumTag */: return "enum"; + case 330 /* SyntaxKind.JSDocAuthorTag */: return "author"; + case 332 /* SyntaxKind.JSDocClassTag */: return "class"; + case 333 /* SyntaxKind.JSDocPublicTag */: return "public"; + case 334 /* SyntaxKind.JSDocPrivateTag */: return "private"; + case 335 /* SyntaxKind.JSDocProtectedTag */: return "protected"; + case 336 /* SyntaxKind.JSDocReadonlyTag */: return "readonly"; + case 337 /* SyntaxKind.JSDocOverrideTag */: return "override"; + case 344 /* SyntaxKind.JSDocTemplateTag */: return "template"; + case 345 /* SyntaxKind.JSDocTypedefTag */: return "typedef"; + case 340 /* SyntaxKind.JSDocParameterTag */: return "param"; + case 347 /* SyntaxKind.JSDocPropertyTag */: return "prop"; + case 338 /* SyntaxKind.JSDocCallbackTag */: return "callback"; + case 328 /* SyntaxKind.JSDocAugmentsTag */: return "augments"; + case 329 /* SyntaxKind.JSDocImplementsTag */: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; var invalidValueSentinel = {}; function getCookedText(kind, rawText) { if (!rawTextScanner) { - rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + rawTextScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); } switch (kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: rawTextScanner.setText("`" + rawText + "`"); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: rawTextScanner.setText("}" + rawText + "`"); break; } var token = rawTextScanner.scan(); - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false); } if (rawTextScanner.isUnterminated()) { @@ -27521,14 +27645,14 @@ var ts; } var tokenValue; switch (token) { - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: tokenValue = rawTextScanner.getTokenValue(); break; } - if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* SyntaxKind.EndOfFileToken */) { rawTextScanner.setText(undefined); return invalidValueSentinel; } @@ -27537,22 +27661,22 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 134234112 /* TransformFlags.PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) - return 0 /* None */; + return 0 /* TransformFlags.None */; var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind); return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags; } function propagateChildrenFlags(children) { - return children ? children.transformFlags : 0 /* None */; + return children ? children.transformFlags : 0 /* TransformFlags.None */; } function aggregateChildrenFlags(children) { - var subtreeFlags = 0 /* None */; + var subtreeFlags = 0 /* TransformFlags.None */; for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { var child = children_2[_i]; subtreeFlags |= propagateChildFlags(child); @@ -27564,78 +27688,78 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) { - return -2 /* TypeExcludes */; + if (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) { + return -2 /* TransformFlags.TypeExcludes */; } switch (kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 204 /* ArrayLiteralExpression */: - return 536903680 /* ArrayLiteralOrCallOrNewExcludes */; - case 261 /* ModuleDeclaration */: - return 742678528 /* ModuleExcludes */; - case 164 /* Parameter */: - return 536870912 /* ParameterExcludes */; - case 214 /* ArrowFunction */: - return 612179968 /* ArrowFunctionExcludes */; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - return 746414080 /* FunctionExcludes */; - case 255 /* VariableDeclarationList */: - return 537460736 /* VariableDeclarationListExcludes */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return 537010176 /* ClassExcludes */; - case 171 /* Constructor */: - return 746405888 /* ConstructorExcludes */; - case 167 /* PropertyDeclaration */: - return 671105024 /* PropertyExcludes */; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return 679297024 /* MethodOrAccessorExcludes */; - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 150 /* StringKeyword */: - case 148 /* ObjectKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 163 /* TypeParameter */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return -2 /* TypeExcludes */; - case 205 /* ObjectLiteralExpression */: - return 537075712 /* ObjectLiteralExcludes */; - case 292 /* CatchClause */: - return 536936448 /* CatchClauseExcludes */; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - return 536903680 /* BindingPatternExcludes */; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - case 350 /* PartiallyEmittedExpression */: - case 212 /* ParenthesizedExpression */: - case 106 /* SuperKeyword */: - return 536870912 /* OuterExpressionExcludes */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - return 536870912 /* PropertyAccessExcludes */; + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return -2147450880 /* TransformFlags.ArrayLiteralOrCallOrNewExcludes */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return -1941676032 /* TransformFlags.ModuleExcludes */; + case 164 /* SyntaxKind.Parameter */: + return -2147483648 /* TransformFlags.ParameterExcludes */; + case 214 /* SyntaxKind.ArrowFunction */: + return -2072174592 /* TransformFlags.ArrowFunctionExcludes */; + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return -1937940480 /* TransformFlags.FunctionExcludes */; + case 255 /* SyntaxKind.VariableDeclarationList */: + return -2146893824 /* TransformFlags.VariableDeclarationListExcludes */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return -2147344384 /* TransformFlags.ClassExcludes */; + case 171 /* SyntaxKind.Constructor */: + return -1937948672 /* TransformFlags.ConstructorExcludes */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return -2013249536 /* TransformFlags.PropertyExcludes */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return -2005057536 /* TransformFlags.MethodOrAccessorExcludes */; + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 163 /* SyntaxKind.TypeParameter */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return -2 /* TransformFlags.TypeExcludes */; + case 205 /* SyntaxKind.ObjectLiteralExpression */: + return -2147278848 /* TransformFlags.ObjectLiteralExcludes */; + case 292 /* SyntaxKind.CatchClause */: + return -2147418112 /* TransformFlags.CatchClauseExcludes */; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return -2147450880 /* TransformFlags.BindingPatternExcludes */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 106 /* SyntaxKind.SuperKeyword */: + return -2147483648 /* TransformFlags.OuterExpressionExcludes */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + return -2147483648 /* TransformFlags.PropertyAccessExcludes */; default: - return 536870912 /* NodeExcludes */; + return -2147483648 /* TransformFlags.NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; var baseFactory = ts.createBaseNodeFactory(); function makeSynthetic(node) { - node.flags |= 8 /* Synthesized */; + node.flags |= 8 /* NodeFlags.Synthesized */; return node; } var syntheticFactory = { @@ -27645,7 +27769,7 @@ var ts; createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); }, createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); }, }; - ts.factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory); + ts.factory = createNodeFactory(4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */, syntheticFactory); function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { var stripInternal; var bundleFileInfo; @@ -27708,50 +27832,50 @@ var ts; for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "prologue" /* Prologue */: + case "prologue" /* BundleFileSectionKind.Prologue */: prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section)); break; - case "emitHelpers" /* EmitHelpers */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data)); break; - case "no-default-lib" /* NoDefaultLib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: hasNoDefaultLib = true; break; - case "reference" /* Reference */: + case "reference" /* BundleFileSectionKind.Reference */: referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data }); break; - case "type" /* Type */: + case "type" /* BundleFileSectionKind.Type */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "type-import" /* TypeResolutionModeImport */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext }); break; - case "type-require" /* TypeResolutionModeRequire */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS }); break; - case "lib" /* Lib */: + case "lib" /* BundleFileSectionKind.Lib */: libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "prepend" /* Prepend */: + case "prepend" /* BundleFileSectionKind.Prepend */: var prependTexts = void 0; for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { var text = _c[_b]; - if (!stripInternal || text.kind !== "internal" /* Internal */) { - prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* Internal */), text)); + if (!stripInternal || text.kind !== "internal" /* BundleFileSectionKind.Internal */) { + prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* BundleFileSectionKind.Internal */), text)); } } prependChildren = ts.addRange(prependChildren, prependTexts); texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray)); break; - case "internal" /* Internal */: + case "internal" /* BundleFileSectionKind.Internal */: if (stripInternal) { if (!texts) texts = []; break; } // falls through - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; default: ts.Debug.assertNever(section); @@ -27779,22 +27903,22 @@ var ts; for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "internal" /* Internal */: - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "internal" /* BundleFileSectionKind.Internal */: + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; - case "no-default-lib" /* NoDefaultLib */: - case "reference" /* Reference */: - case "type" /* Type */: - case "type-import" /* TypeResolutionModeImport */: - case "type-require" /* TypeResolutionModeRequire */: - case "lib" /* Lib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: + case "reference" /* BundleFileSectionKind.Reference */: + case "type" /* BundleFileSectionKind.Type */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: + case "lib" /* BundleFileSectionKind.Lib */: syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section)); break; // Ignore - case "prologue" /* Prologue */: - case "emitHelpers" /* EmitHelpers */: - case "prepend" /* Prepend */: + case "prologue" /* BundleFileSectionKind.Prologue */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: + case "prepend" /* BundleFileSectionKind.Prepend */: break; default: ts.Debug.assertNever(section); @@ -27822,7 +27946,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -27891,7 +28015,7 @@ var ts; if (trailingComments) destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) - destEmitNode.flags = flags & ~268435456 /* Immutable */; + destEmitNode.flags = flags & ~268435456 /* EmitFlags.Immutable */; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) @@ -27933,7 +28057,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -27942,7 +28066,7 @@ var ts; node.emitNode = {}; } else { - ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node."); + ts.Debug.assert(!(node.emitNode.flags & 268435456 /* EmitFlags.Immutable */), "Invalid attempt to mutate an immutable node."); } return node.emitNode; } @@ -27974,7 +28098,7 @@ var ts; */ function removeAllComments(node) { var emitNode = getOrCreateEmitNode(node); - emitNode.flags |= 1536 /* NoComments */; + emitNode.flags |= 1536 /* EmitFlags.NoComments */; emitNode.leadingComments = undefined; emitNode.trailingComments = undefined; return node; @@ -28210,7 +28334,7 @@ var ts; ts.setSnippetElement = setSnippetElement; /* @internal */ function ignoreSourceNewlines(node) { - getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; + getOrCreateEmitNode(node).flags |= 134217728 /* EmitFlags.IgnoreSourceNewlines */; return node; } ts.ignoreSourceNewlines = ignoreSourceNewlines; @@ -28233,8 +28357,8 @@ var ts; (function (ts) { function createEmitHelperFactory(context) { var factory = context.factory; - var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); }); - var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); }); + var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* EmitFlags.Immutable */); }); + var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* EmitFlags.Immutable */); }); return { getUnscopedHelperName: getUnscopedHelperName, // TypeScript Helpers @@ -28275,7 +28399,7 @@ var ts; * Gets an identifier for the name of an *unscoped* emit helper. */ function getUnscopedHelperName(name) { - return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* EmitFlags.HelperName */ | 2 /* EmitFlags.AdviseOnEmitNode */); } // TypeScript Helpers function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) { @@ -28310,7 +28434,7 @@ var ts; } // ES2018 Helpers function createAssignHelper(attributesSegments) { - if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } @@ -28326,7 +28450,7 @@ var ts; context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28380,13 +28504,13 @@ var ts; function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28399,7 +28523,7 @@ var ts; function createExtendsHelper(name) { context.requestEmitHelper(ts.extendsHelper); return factory.createCallExpression(getUnscopedHelperName("__extends"), - /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]); + /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)]); } function createTemplateObjectHelper(cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); @@ -28489,13 +28613,13 @@ var ts; /* @internal */ function compareEmitHelpers(x, y) { if (x === y) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === y.priority) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; if (y.priority === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; @@ -28902,7 +29026,7 @@ var ts; function isCallToHelper(firstSegment, helperName) { return ts.isCallExpression(firstSegment) && ts.isIdentifier(firstSegment.expression) - && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0 + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* EmitFlags.HelperName */) !== 0 && firstSegment.expression.escapedText === helperName; } ts.isCallToHelper = isCallToHelper; @@ -28911,750 +29035,750 @@ var ts; (function (ts) { // Literals function isNumericLiteral(node) { - return node.kind === 8 /* NumericLiteral */; + return node.kind === 8 /* SyntaxKind.NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; function isBigIntLiteral(node) { - return node.kind === 9 /* BigIntLiteral */; + return node.kind === 9 /* SyntaxKind.BigIntLiteral */; } ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 10 /* StringLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 11 /* JsxText */; + return node.kind === 11 /* SyntaxKind.JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 13 /* RegularExpressionLiteral */; + return node.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 15 /* TemplateHead */; + return node.kind === 15 /* SyntaxKind.TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 16 /* TemplateMiddle */; + return node.kind === 16 /* SyntaxKind.TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 17 /* TemplateTail */; + return node.kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateTail = isTemplateTail; // Punctuation function isDotDotDotToken(node) { - return node.kind === 25 /* DotDotDotToken */; + return node.kind === 25 /* SyntaxKind.DotDotDotToken */; } ts.isDotDotDotToken = isDotDotDotToken; /*@internal*/ function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; + return node.kind === 27 /* SyntaxKind.CommaToken */; } ts.isCommaToken = isCommaToken; function isPlusToken(node) { - return node.kind === 39 /* PlusToken */; + return node.kind === 39 /* SyntaxKind.PlusToken */; } ts.isPlusToken = isPlusToken; function isMinusToken(node) { - return node.kind === 40 /* MinusToken */; + return node.kind === 40 /* SyntaxKind.MinusToken */; } ts.isMinusToken = isMinusToken; function isAsteriskToken(node) { - return node.kind === 41 /* AsteriskToken */; + return node.kind === 41 /* SyntaxKind.AsteriskToken */; } ts.isAsteriskToken = isAsteriskToken; /*@internal*/ function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + return node.kind === 53 /* SyntaxKind.ExclamationToken */; } ts.isExclamationToken = isExclamationToken; /*@internal*/ function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + return node.kind === 57 /* SyntaxKind.QuestionToken */; } ts.isQuestionToken = isQuestionToken; /*@internal*/ function isColonToken(node) { - return node.kind === 58 /* ColonToken */; + return node.kind === 58 /* SyntaxKind.ColonToken */; } ts.isColonToken = isColonToken; /*@internal*/ function isQuestionDotToken(node) { - return node.kind === 28 /* QuestionDotToken */; + return node.kind === 28 /* SyntaxKind.QuestionDotToken */; } ts.isQuestionDotToken = isQuestionDotToken; /*@internal*/ function isEqualsGreaterThanToken(node) { - return node.kind === 38 /* EqualsGreaterThanToken */; + return node.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */; } ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 79 /* Identifier */; + return node.kind === 79 /* SyntaxKind.Identifier */; } ts.isIdentifier = isIdentifier; function isPrivateIdentifier(node) { - return node.kind === 80 /* PrivateIdentifier */; + return node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; // Reserved Words /* @internal */ function isExportModifier(node) { - return node.kind === 93 /* ExportKeyword */; + return node.kind === 93 /* SyntaxKind.ExportKeyword */; } ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 131 /* AsyncKeyword */; + return node.kind === 131 /* SyntaxKind.AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ function isAssertsKeyword(node) { - return node.kind === 128 /* AssertsKeyword */; + return node.kind === 128 /* SyntaxKind.AssertsKeyword */; } ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 132 /* AwaitKeyword */; + return node.kind === 132 /* SyntaxKind.AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 145 /* ReadonlyKeyword */; + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ function isStaticModifier(node) { - return node.kind === 124 /* StaticKeyword */; + return node.kind === 124 /* SyntaxKind.StaticKeyword */; } ts.isStaticModifier = isStaticModifier; /* @internal */ function isAbstractModifier(node) { - return node.kind === 126 /* AbstractKeyword */; + return node.kind === 126 /* SyntaxKind.AbstractKeyword */; } ts.isAbstractModifier = isAbstractModifier; /* @internal */ function isOverrideModifier(node) { - return node.kind === 159 /* OverrideKeyword */; + return node.kind === 159 /* SyntaxKind.OverrideKeyword */; } ts.isOverrideModifier = isOverrideModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 106 /* SuperKeyword */; + return node.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 100 /* ImportKeyword */; + return node.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 161 /* QualifiedName */; + return node.kind === 161 /* SyntaxKind.QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 162 /* ComputedPropertyName */; + return node.kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 163 /* TypeParameter */; + return node.kind === 163 /* SyntaxKind.TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 164 /* Parameter */; + return node.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 166 /* PropertySignature */; + return node.kind === 166 /* SyntaxKind.PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 167 /* PropertyDeclaration */; + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 168 /* MethodSignature */; + return node.kind === 168 /* SyntaxKind.MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassStaticBlockDeclaration(node) { - return node.kind === 170 /* ClassStaticBlockDeclaration */; + return node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 171 /* Constructor */; + return node.kind === 171 /* SyntaxKind.Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 174 /* CallSignature */; + return node.kind === 174 /* SyntaxKind.CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 175 /* ConstructSignature */; + return node.kind === 175 /* SyntaxKind.ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 176 /* IndexSignature */; + return node.kind === 176 /* SyntaxKind.IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 177 /* TypePredicate */; + return node.kind === 177 /* SyntaxKind.TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 178 /* TypeReference */; + return node.kind === 178 /* SyntaxKind.TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 179 /* FunctionType */; + return node.kind === 179 /* SyntaxKind.FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 180 /* ConstructorType */; + return node.kind === 180 /* SyntaxKind.ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 182 /* TypeLiteral */; + return node.kind === 182 /* SyntaxKind.TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 183 /* ArrayType */; + return node.kind === 183 /* SyntaxKind.ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 184 /* TupleType */; + return node.kind === 184 /* SyntaxKind.TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 197 /* NamedTupleMember */; + return node.kind === 197 /* SyntaxKind.NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 185 /* OptionalType */; + return node.kind === 185 /* SyntaxKind.OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 186 /* RestType */; + return node.kind === 186 /* SyntaxKind.RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 187 /* UnionType */; + return node.kind === 187 /* SyntaxKind.UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 188 /* IntersectionType */; + return node.kind === 188 /* SyntaxKind.IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 189 /* ConditionalType */; + return node.kind === 189 /* SyntaxKind.ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 190 /* InferType */; + return node.kind === 190 /* SyntaxKind.InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 191 /* ParenthesizedType */; + return node.kind === 191 /* SyntaxKind.ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 192 /* ThisType */; + return node.kind === 192 /* SyntaxKind.ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 193 /* TypeOperator */; + return node.kind === 193 /* SyntaxKind.TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 194 /* IndexedAccessType */; + return node.kind === 194 /* SyntaxKind.IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 195 /* MappedType */; + return node.kind === 195 /* SyntaxKind.MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 196 /* LiteralType */; + return node.kind === 196 /* SyntaxKind.LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 200 /* ImportType */; + return node.kind === 200 /* SyntaxKind.ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 199 /* TemplateLiteralTypeSpan */; + return node.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 198 /* TemplateLiteralType */; + return node.kind === 198 /* SyntaxKind.TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 201 /* ObjectBindingPattern */; + return node.kind === 201 /* SyntaxKind.ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 202 /* ArrayBindingPattern */; + return node.kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 203 /* BindingElement */; + return node.kind === 203 /* SyntaxKind.BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 204 /* ArrayLiteralExpression */; + return node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 205 /* ObjectLiteralExpression */; + return node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 207 /* ElementAccessExpression */; + return node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 208 /* CallExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 209 /* NewExpression */; + return node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 210 /* TaggedTemplateExpression */; + return node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 212 /* ParenthesizedExpression */; + return node.kind === 212 /* SyntaxKind.ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 213 /* FunctionExpression */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 214 /* ArrowFunction */; + return node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 215 /* DeleteExpression */; + return node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 216 /* TypeOfExpression */; + return node.kind === 216 /* SyntaxKind.TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 217 /* VoidExpression */; + return node.kind === 217 /* SyntaxKind.VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 218 /* AwaitExpression */; + return node.kind === 218 /* SyntaxKind.AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 219 /* PrefixUnaryExpression */; + return node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 220 /* PostfixUnaryExpression */; + return node.kind === 220 /* SyntaxKind.PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 221 /* BinaryExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 222 /* ConditionalExpression */; + return node.kind === 222 /* SyntaxKind.ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 223 /* TemplateExpression */; + return node.kind === 223 /* SyntaxKind.TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 224 /* YieldExpression */; + return node.kind === 224 /* SyntaxKind.YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 225 /* SpreadElement */; + return node.kind === 225 /* SyntaxKind.SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 226 /* ClassExpression */; + return node.kind === 226 /* SyntaxKind.ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 227 /* OmittedExpression */; + return node.kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 229 /* AsExpression */; + return node.kind === 229 /* SyntaxKind.AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 230 /* NonNullExpression */; + return node.kind === 230 /* SyntaxKind.NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 231 /* MetaProperty */; + return node.kind === 231 /* SyntaxKind.MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 232 /* SyntheticExpression */; + return node.kind === 232 /* SyntaxKind.SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 350 /* PartiallyEmittedExpression */; + return node.kind === 350 /* SyntaxKind.PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 351 /* CommaListExpression */; + return node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 233 /* TemplateSpan */; + return node.kind === 233 /* SyntaxKind.TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 234 /* SemicolonClassElement */; + return node.kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 235 /* Block */; + return node.kind === 235 /* SyntaxKind.Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 237 /* VariableStatement */; + return node.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 236 /* EmptyStatement */; + return node.kind === 236 /* SyntaxKind.EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 238 /* ExpressionStatement */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 239 /* IfStatement */; + return node.kind === 239 /* SyntaxKind.IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 240 /* DoStatement */; + return node.kind === 240 /* SyntaxKind.DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 241 /* WhileStatement */; + return node.kind === 241 /* SyntaxKind.WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 242 /* ForStatement */; + return node.kind === 242 /* SyntaxKind.ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 243 /* ForInStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 244 /* ForOfStatement */; + return node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 245 /* ContinueStatement */; + return node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 246 /* BreakStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 247 /* ReturnStatement */; + return node.kind === 247 /* SyntaxKind.ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 248 /* WithStatement */; + return node.kind === 248 /* SyntaxKind.WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 249 /* SwitchStatement */; + return node.kind === 249 /* SyntaxKind.SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 250 /* LabeledStatement */; + return node.kind === 250 /* SyntaxKind.LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 251 /* ThrowStatement */; + return node.kind === 251 /* SyntaxKind.ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 252 /* TryStatement */; + return node.kind === 252 /* SyntaxKind.TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 253 /* DebuggerStatement */; + return node.kind === 253 /* SyntaxKind.DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 255 /* VariableDeclarationList */; + return node.kind === 255 /* SyntaxKind.VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 256 /* FunctionDeclaration */; + return node.kind === 256 /* SyntaxKind.FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 257 /* ClassDeclaration */; + return node.kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 258 /* InterfaceDeclaration */; + return node.kind === 258 /* SyntaxKind.InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 259 /* TypeAliasDeclaration */; + return node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 260 /* EnumDeclaration */; + return node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 262 /* ModuleBlock */; + return node.kind === 262 /* SyntaxKind.ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 263 /* CaseBlock */; + return node.kind === 263 /* SyntaxKind.CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 264 /* NamespaceExportDeclaration */; + return node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 266 /* ImportDeclaration */; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 267 /* ImportClause */; + return node.kind === 267 /* SyntaxKind.ImportClause */; } ts.isImportClause = isImportClause; function isImportTypeAssertionContainer(node) { - return node.kind === 295 /* ImportTypeAssertionContainer */; + return node.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */; } ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer; function isAssertClause(node) { - return node.kind === 293 /* AssertClause */; + return node.kind === 293 /* SyntaxKind.AssertClause */; } ts.isAssertClause = isAssertClause; function isAssertEntry(node) { - return node.kind === 294 /* AssertEntry */; + return node.kind === 294 /* SyntaxKind.AssertEntry */; } ts.isAssertEntry = isAssertEntry; function isNamespaceImport(node) { - return node.kind === 268 /* NamespaceImport */; + return node.kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 274 /* NamespaceExport */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 269 /* NamedImports */; + return node.kind === 269 /* SyntaxKind.NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 270 /* ImportSpecifier */; + return node.kind === 270 /* SyntaxKind.ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 271 /* ExportAssignment */; + return node.kind === 271 /* SyntaxKind.ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 272 /* ExportDeclaration */; + return node.kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 273 /* NamedExports */; + return node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 275 /* ExportSpecifier */; + return node.kind === 275 /* SyntaxKind.ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 276 /* MissingDeclaration */; + return node.kind === 276 /* SyntaxKind.MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 349 /* NotEmittedStatement */; + return node.kind === 349 /* SyntaxKind.NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 354 /* SyntheticReferenceExpression */; + return node.kind === 354 /* SyntaxKind.SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 352 /* MergeDeclarationMarker */; + return node.kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 353 /* EndOfDeclarationMarker */; + return node.kind === 353 /* SyntaxKind.EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 277 /* ExternalModuleReference */; + return node.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 278 /* JsxElement */; + return node.kind === 278 /* SyntaxKind.JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 279 /* JsxSelfClosingElement */; + return node.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 280 /* JsxOpeningElement */; + return node.kind === 280 /* SyntaxKind.JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 281 /* JsxClosingElement */; + return node.kind === 281 /* SyntaxKind.JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 282 /* JsxFragment */; + return node.kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 283 /* JsxOpeningFragment */; + return node.kind === 283 /* SyntaxKind.JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 284 /* JsxClosingFragment */; + return node.kind === 284 /* SyntaxKind.JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 285 /* JsxAttribute */; + return node.kind === 285 /* SyntaxKind.JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 286 /* JsxAttributes */; + return node.kind === 286 /* SyntaxKind.JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 287 /* JsxSpreadAttribute */; + return node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 288 /* JsxExpression */; + return node.kind === 288 /* SyntaxKind.JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 289 /* CaseClause */; + return node.kind === 289 /* SyntaxKind.CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 290 /* DefaultClause */; + return node.kind === 290 /* SyntaxKind.DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 291 /* HeritageClause */; + return node.kind === 291 /* SyntaxKind.HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 292 /* CatchClause */; + return node.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 296 /* PropertyAssignment */; + return node.kind === 296 /* SyntaxKind.PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */; + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 298 /* SpreadAssignment */; + return node.kind === 298 /* SyntaxKind.SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 301 /* UnparsedPrepend */; + return node.kind === 301 /* SyntaxKind.UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -29662,176 +29786,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 305 /* SourceFile */; + return node.kind === 305 /* SyntaxKind.SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 306 /* Bundle */; + return node.kind === 306 /* SyntaxKind.Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 307 /* UnparsedSource */; + return node.kind === 307 /* SyntaxKind.UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 309 /* JSDocTypeExpression */; + return node.kind === 309 /* SyntaxKind.JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 310 /* JSDocNameReference */; + return node.kind === 310 /* SyntaxKind.JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; function isJSDocMemberName(node) { - return node.kind === 311 /* JSDocMemberName */; + return node.kind === 311 /* SyntaxKind.JSDocMemberName */; } ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 324 /* JSDocLink */; + return node.kind === 324 /* SyntaxKind.JSDocLink */; } ts.isJSDocLink = isJSDocLink; function isJSDocLinkCode(node) { - return node.kind === 325 /* JSDocLinkCode */; + return node.kind === 325 /* SyntaxKind.JSDocLinkCode */; } ts.isJSDocLinkCode = isJSDocLinkCode; function isJSDocLinkPlain(node) { - return node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 312 /* JSDocAllType */; + return node.kind === 312 /* SyntaxKind.JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 313 /* JSDocUnknownType */; + return node.kind === 313 /* SyntaxKind.JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 314 /* JSDocNullableType */; + return node.kind === 314 /* SyntaxKind.JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 315 /* JSDocNonNullableType */; + return node.kind === 315 /* SyntaxKind.JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 316 /* JSDocOptionalType */; + return node.kind === 316 /* SyntaxKind.JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 317 /* JSDocFunctionType */; + return node.kind === 317 /* SyntaxKind.JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 318 /* JSDocVariadicType */; + return node.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 319 /* JSDocNamepathType */; + return node.kind === 319 /* SyntaxKind.JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 320 /* JSDoc */; + return node.kind === 320 /* SyntaxKind.JSDoc */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 322 /* JSDocTypeLiteral */; + return node.kind === 322 /* SyntaxKind.JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 323 /* JSDocSignature */; + return node.kind === 323 /* SyntaxKind.JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 328 /* JSDocAugmentsTag */; + return node.kind === 328 /* SyntaxKind.JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 330 /* JSDocAuthorTag */; + return node.kind === 330 /* SyntaxKind.JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 332 /* JSDocClassTag */; + return node.kind === 332 /* SyntaxKind.JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 338 /* JSDocCallbackTag */; + return node.kind === 338 /* SyntaxKind.JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 333 /* JSDocPublicTag */; + return node.kind === 333 /* SyntaxKind.JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 334 /* JSDocPrivateTag */; + return node.kind === 334 /* SyntaxKind.JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 335 /* JSDocProtectedTag */; + return node.kind === 335 /* SyntaxKind.JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 336 /* JSDocReadonlyTag */; + return node.kind === 336 /* SyntaxKind.JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 337 /* JSDocOverrideTag */; + return node.kind === 337 /* SyntaxKind.JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 331 /* JSDocDeprecatedTag */; + return node.kind === 331 /* SyntaxKind.JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 346 /* JSDocSeeTag */; + return node.kind === 346 /* SyntaxKind.JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 339 /* JSDocEnumTag */; + return node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 340 /* JSDocParameterTag */; + return node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 341 /* JSDocReturnTag */; + return node.kind === 341 /* SyntaxKind.JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 342 /* JSDocThisTag */; + return node.kind === 342 /* SyntaxKind.JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 343 /* JSDocTypeTag */; + return node.kind === 343 /* SyntaxKind.JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 344 /* JSDocTemplateTag */; + return node.kind === 344 /* SyntaxKind.JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 345 /* JSDocTypedefTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 327 /* JSDocTag */; + return node.kind === 327 /* SyntaxKind.JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 347 /* JSDocPropertyTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 329 /* JSDocImplementsTag */; + return node.kind === 329 /* SyntaxKind.JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 348 /* SyntaxList */; + return n.kind === 348 /* SyntaxKind.SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -29851,7 +29975,7 @@ var ts; var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); - ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; + ts.getOrCreateEmitNode(expression).flags |= 64 /* EmitFlags.NoNestedSourceMaps */; return expression; } } @@ -30030,14 +30154,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -30076,7 +30200,7 @@ var ts; */ function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) { var operator = node.operator; - ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); + ts.Debug.assert(operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); var temp = factory.createTempVariable(recordTempVariable); expression = factory.createAssignment(temp, expression); ts.setTextRange(expression, node.operand); @@ -30101,14 +30225,14 @@ var ts; * Gets whether an identifier should only be referred to by its internal name. */ function isInternalName(node) { - return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + return (ts.getEmitFlags(node) & 32768 /* EmitFlags.InternalName */) !== 0; } ts.isInternalName = isInternalName; /** * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* EmitFlags.LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -30116,7 +30240,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* EmitFlags.ExportName */) !== 0; } ts.isExportName = isExportName; function isUseStrictPrologue(node) { @@ -30145,8 +30269,8 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 351 /* CommaListExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || + node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isJSDocTypeAssertion(node) { @@ -30162,26 +30286,26 @@ var ts; } ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType; function isOuterExpression(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } switch (node.kind) { - case 212 /* ParenthesizedExpression */: - if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { + case 212 /* SyntaxKind.ParenthesizedExpression */: + if (kinds & 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { return false; } - return (kinds & 1 /* Parentheses */) !== 0; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - return (kinds & 2 /* TypeAssertions */) !== 0; - case 230 /* NonNullExpression */: - return (kinds & 4 /* NonNullAssertions */) !== 0; - case 350 /* PartiallyEmittedExpression */: - return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; + return (kinds & 1 /* OuterExpressionKinds.Parentheses */) !== 0; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + return (kinds & 2 /* OuterExpressionKinds.TypeAssertions */) !== 0; + case 230 /* SyntaxKind.NonNullExpression */: + return (kinds & 4 /* OuterExpressionKinds.NonNullAssertions */) !== 0; + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + return (kinds & 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */) !== 0; } return false; } ts.isOuterExpression = isOuterExpression; function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } while (isOuterExpression(node, kinds)) { node = node.expression; } @@ -30189,7 +30313,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - return skipOuterExpressions(node, 6 /* Assertions */); + return skipOuterExpressions(node, 6 /* OuterExpressionKinds.Assertions */); } ts.skipAssertions = skipAssertions; function startOnNewLine(node) { @@ -30250,7 +30374,7 @@ var ts; var externalHelpersImportDeclaration = nodeFactory.createImportDeclaration( /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), /*assertClause*/ undefined); - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* EmitFlags.NeverApplyImportHelper */); return externalHelpersImportDeclaration; } } @@ -30295,10 +30419,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 266 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 266 /* SyntaxKind.ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 272 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -30417,7 +30541,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -30429,11 +30553,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -30465,12 +30589,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 225 /* SpreadElement */: - case 298 /* SpreadAssignment */: + case 225 /* SyntaxKind.SpreadElement */: + case 298 /* SyntaxKind.SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -30488,7 +30612,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -30503,7 +30627,7 @@ var ts; : propertyName; } break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -30518,7 +30642,7 @@ var ts; : propertyName; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -30533,21 +30657,21 @@ var ts; ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */; } /** * Gets the elements of a BindingOrAssignmentPattern */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -30568,86 +30692,86 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveIllegalType(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 173 /* SetAccessor */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.canHaveIllegalType = canHaveIllegalType; function canHaveIllegalTypeParameters(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.canHaveIllegalTypeParameters = canHaveIllegalTypeParameters; function canHaveDecorators(node) { var kind = node.kind; - return kind === 164 /* Parameter */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 226 /* ClassExpression */ - || kind === 257 /* ClassDeclaration */; + return kind === 164 /* SyntaxKind.Parameter */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.canHaveDecorators = canHaveDecorators; function canHaveIllegalDecorators(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 237 /* VariableStatement */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.canHaveIllegalDecorators = canHaveIllegalDecorators; function canHaveModifiers(node) { var kind = node.kind; - return kind === 163 /* TypeParameter */ - || kind === 164 /* Parameter */ - || kind === 166 /* PropertySignature */ - || kind === 167 /* PropertyDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 169 /* MethodDeclaration */ - || kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 180 /* ConstructorType */ - || kind === 213 /* FunctionExpression */ - || kind === 214 /* ArrowFunction */ - || kind === 226 /* ClassExpression */ - || kind === 237 /* VariableStatement */ - || kind === 256 /* FunctionDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 272 /* ExportDeclaration */; + return kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 180 /* SyntaxKind.ConstructorType */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; function canHaveIllegalModifiers(node) { var kind = node.kind; - return kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 179 /* FunctionType */ - || kind === 276 /* MissingDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 179 /* SyntaxKind.FunctionType */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.canHaveIllegalModifiers = canHaveIllegalModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -30658,68 +30782,68 @@ var ts; ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); function isLiteralTypeLikeExpression(node) { var kind = node.kind; - return kind === 104 /* NullKeyword */ - || kind === 110 /* TrueKeyword */ - || kind === 95 /* FalseKeyword */ + return kind === 104 /* SyntaxKind.NullKeyword */ + || kind === 110 /* SyntaxKind.TrueKeyword */ + || kind === 95 /* SyntaxKind.FalseKeyword */ || ts.isLiteralExpression(node) || ts.isPrefixUnaryExpression(node); } ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; function isExponentiationOperator(kind) { - return kind === 42 /* AsteriskAsteriskToken */; + return kind === 42 /* SyntaxKind.AsteriskAsteriskToken */; } function isMultiplicativeOperator(kind) { - return kind === 41 /* AsteriskToken */ - || kind === 43 /* SlashToken */ - || kind === 44 /* PercentToken */; + return kind === 41 /* SyntaxKind.AsteriskToken */ + || kind === 43 /* SyntaxKind.SlashToken */ + || kind === 44 /* SyntaxKind.PercentToken */; } function isMultiplicativeOperatorOrHigher(kind) { return isExponentiationOperator(kind) || isMultiplicativeOperator(kind); } function isAdditiveOperator(kind) { - return kind === 39 /* PlusToken */ - || kind === 40 /* MinusToken */; + return kind === 39 /* SyntaxKind.PlusToken */ + || kind === 40 /* SyntaxKind.MinusToken */; } function isAdditiveOperatorOrHigher(kind) { return isAdditiveOperator(kind) || isMultiplicativeOperatorOrHigher(kind); } function isShiftOperator(kind) { - return kind === 47 /* LessThanLessThanToken */ - || kind === 48 /* GreaterThanGreaterThanToken */ - || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */; + return kind === 47 /* SyntaxKind.LessThanLessThanToken */ + || kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ + || kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } function isShiftOperatorOrHigher(kind) { return isShiftOperator(kind) || isAdditiveOperatorOrHigher(kind); } function isRelationalOperator(kind) { - return kind === 29 /* LessThanToken */ - || kind === 32 /* LessThanEqualsToken */ - || kind === 31 /* GreaterThanToken */ - || kind === 33 /* GreaterThanEqualsToken */ - || kind === 102 /* InstanceOfKeyword */ - || kind === 101 /* InKeyword */; + return kind === 29 /* SyntaxKind.LessThanToken */ + || kind === 32 /* SyntaxKind.LessThanEqualsToken */ + || kind === 31 /* SyntaxKind.GreaterThanToken */ + || kind === 33 /* SyntaxKind.GreaterThanEqualsToken */ + || kind === 102 /* SyntaxKind.InstanceOfKeyword */ + || kind === 101 /* SyntaxKind.InKeyword */; } function isRelationalOperatorOrHigher(kind) { return isRelationalOperator(kind) || isShiftOperatorOrHigher(kind); } function isEqualityOperator(kind) { - return kind === 34 /* EqualsEqualsToken */ - || kind === 36 /* EqualsEqualsEqualsToken */ - || kind === 35 /* ExclamationEqualsToken */ - || kind === 37 /* ExclamationEqualsEqualsToken */; + return kind === 34 /* SyntaxKind.EqualsEqualsToken */ + || kind === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ + || kind === 35 /* SyntaxKind.ExclamationEqualsToken */ + || kind === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } function isEqualityOperatorOrHigher(kind) { return isEqualityOperator(kind) || isRelationalOperatorOrHigher(kind); } function isBitwiseOperator(kind) { - return kind === 50 /* AmpersandToken */ - || kind === 51 /* BarToken */ - || kind === 52 /* CaretToken */; + return kind === 50 /* SyntaxKind.AmpersandToken */ + || kind === 51 /* SyntaxKind.BarToken */ + || kind === 52 /* SyntaxKind.CaretToken */; } function isBitwiseOperatorOrHigher(kind) { return isBitwiseOperator(kind) @@ -30727,21 +30851,21 @@ var ts; } // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. function isLogicalOperator(kind) { - return kind === 55 /* AmpersandAmpersandToken */ - || kind === 56 /* BarBarToken */; + return kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || kind === 56 /* SyntaxKind.BarBarToken */; } function isLogicalOperatorOrHigher(kind) { return isLogicalOperator(kind) || isBitwiseOperatorOrHigher(kind); } function isAssignmentOperatorOrHigher(kind) { - return kind === 60 /* QuestionQuestionToken */ + return kind === 60 /* SyntaxKind.QuestionQuestionToken */ || isLogicalOperatorOrHigher(kind) || ts.isAssignmentOperator(kind); } function isBinaryOperator(kind) { return isAssignmentOperatorOrHigher(kind) - || kind === 27 /* CommaToken */; + || kind === 27 /* SyntaxKind.CommaToken */; } function isBinaryOperatorToken(node) { return isBinaryOperator(node.kind); @@ -30874,7 +30998,7 @@ var ts; return stackIndex; } function checkCircularity(stackIndex, nodeStack, node) { - if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + if (ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */)) { while (stackIndex >= 0) { ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); stackIndex--; @@ -30963,7 +31087,7 @@ var ts; createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); }, }; /* @internal */ - ts.parseNodeFactory = ts.createNodeFactory(1 /* NoParenthesizerRules */, ts.parseBaseNodeFactory); + ts.parseNodeFactory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.parseBaseNodeFactory); function visitNode(cbNode, node) { return node && cbNode(node); } @@ -30983,9 +31107,9 @@ var ts; } /*@internal*/ function isJSDocLikeText(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 42 /* asterisk */ && - text.charCodeAt(start + 3) !== 47 /* slash */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 3) !== 47 /* CharacterCodes.slash */; } ts.isJSDocLikeText = isJSDocLikeText; /*@internal*/ @@ -30997,14 +31121,14 @@ var ts; } ts.isFileProbablyExternalModule = isFileProbablyExternalModule; function isAnExternalModuleIndicatorNode(node) { - return ts.canHaveModifiers(node) && hasModifierOfKind(node, 93 /* ExportKeyword */) + return ts.canHaveModifiers(node) && hasModifierOfKind(node, 93 /* SyntaxKind.ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) || ts.isExportDeclaration(node) ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */ ? walkTreeForImportMeta(sourceFile) : undefined; } @@ -31016,7 +31140,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && node.name.escapedText === "meta"; } /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes @@ -31032,20 +31156,20 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 160 /* LastToken */) { + if (!node || node.kind <= 160 /* SyntaxKind.LastToken */) { return; } switch (node.kind) { - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -31053,67 +31177,67 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitNode(cbNode, node.expression); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.initializer); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || @@ -31123,14 +31247,14 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -31138,21 +31262,21 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -31161,7 +31285,7 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || @@ -31169,357 +31293,357 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return visitNode(cbNode, node.exprName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return visitNode(cbNode, node.elementType); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return visitNode(cbNode, node.typeParameter); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.assertions) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: return visitNode(cbNode, node.assertClause); - case 191 /* ParenthesizedType */: - case 193 /* TypeOperator */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 193 /* SyntaxKind.TypeOperator */: return visitNode(cbNode, node.type); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNodes(cbNode, cbNodes, node.members); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return visitNode(cbNode, node.literal); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitNode(cbNode, node.expression); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return visitNode(cbNode, node.expression); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitNode(cbNode, node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitNode(cbNode, node.expression); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return visitNode(cbNode, node.expression); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitNode(cbNode, node.name); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitNode(cbNode, node.expression); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitNode(cbNode, node.expression); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitNode(cbNode, node.label); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitNode(cbNode, node.expression); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return visitNode(cbNode, node.expression); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return visitNode(cbNode, node.expression); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return visitNodes(cbNode, cbNodes, node.elements); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.value); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNode(cbNode, node.name); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return visitNode(cbNode, node.name); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return visitNode(cbNode, node.name); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 185 /* OptionalType */: - case 186 /* RestType */: - case 309 /* JSDocTypeExpression */: - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 316 /* JSDocOptionalType */: - case 318 /* JSDocVariadicType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return visitNode(cbNode, node.type); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return visitNode(cbNode, node.name); - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || @@ -31528,64 +31652,64 @@ var ts; : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 330 /* JSDocAuthorTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 309 /* JSDocTypeExpression */ + node.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: - case 331 /* JSDocDeprecatedTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -31634,7 +31758,7 @@ var ts; continue; return res; } - if (current.kind >= 161 /* FirstNode */) { + if (current.kind >= 161 /* SyntaxKind.FirstNode */) { // add children in reverse order to the queue, so popping gives the first child for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { var child = _a[_i]; @@ -31659,13 +31783,13 @@ var ts; } function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat; - if (languageVersion === 100 /* JSON */) { - result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop); + if (languageVersion === 100 /* ScriptTarget.JSON */) { + result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* ScriptKind.JSON */, ts.noop); } else { var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) { @@ -31713,7 +31837,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -31741,8 +31865,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks // tslint:disable variable-name var NodeConstructor; @@ -31764,7 +31888,7 @@ var ts; createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)); }, createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); } }; - var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory); + var factory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */ | 2 /* NodeFactoryFlags.NoNodeConverters */ | 8 /* NodeFactoryFlags.NoOriginalNode */, baseNodeFactory); var fileName; var sourceFlags; var sourceText; @@ -31862,7 +31986,7 @@ var ts; var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); - if (scriptKind === 6 /* JSON */) { + if (scriptKind === 6 /* ScriptKind.JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); result_3.referencedFiles = ts.emptyArray; @@ -31881,25 +32005,25 @@ var ts; Parser.parseSourceFile = parseSourceFile; function parseIsolatedEntityName(content, languageVersion) { // Choice of `isDeclarationFile` should be arbitrary - initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* ScriptKind.JS */); // Prime the scanner. nextToken(); var entityName = parseEntityName(/*allowReservedWords*/ true); - var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + var isInvalid = token() === 1 /* SyntaxKind.EndOfFileToken */ && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; } Parser.parseIsolatedEntityName = parseIsolatedEntityName; function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { - if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; } + if (languageVersion === void 0) { languageVersion = 2 /* ScriptTarget.ES2015 */; } if (setParentNodes === void 0) { setParentNodes = false; } - initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* JSON */); + initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* ScriptKind.JSON */); sourceFlags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); var statements, endOfFileToken; - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { statements = createNodeArray([], pos, pos); endOfFileToken = parseTokenNode(); } @@ -31907,28 +32031,28 @@ var ts; // Loop and synthesize an ArrayLiteralExpression if there are more than // one top-level expressions to ensure all input text is consumed. var expressions = void 0; - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var expression_1 = void 0; switch (token()) { - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: expression_1 = parseArrayLiteralExpression(); break; - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: expression_1 = parseTokenNode(); break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + case 40 /* SyntaxKind.MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* SyntaxKind.NumericLiteral */ && nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parsePrefixUnaryExpression(); } else { expression_1 = parseObjectLiteralExpression(); } break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parseLiteralNode(); break; } @@ -31946,7 +32070,7 @@ var ts; } else { expressions = expression_1; - if (token() !== 1 /* EndOfFileToken */) { + if (token() !== 1 /* SyntaxKind.EndOfFileToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } } @@ -31955,10 +32079,10 @@ var ts; var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); - endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token); + endOfFileToken = parseExpectedToken(1 /* SyntaxKind.EndOfFileToken */, ts.Diagnostics.Unexpected_token); } // Set source file so that errors will be reported with this file name - var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); + var sourceFile = createSourceFile(fileName, 2 /* ScriptTarget.ES2015 */, 6 /* ScriptKind.JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); if (setParentNodes) { fixupParentReferences(sourceFile); } @@ -31995,15 +32119,15 @@ var ts; sourceFlags = 0; topLevel = true; switch (scriptKind) { - case 1 /* JS */: - case 2 /* JSX */: - contextFlags = 262144 /* JavaScriptFile */; + case 1 /* ScriptKind.JS */: + case 2 /* ScriptKind.JSX */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */; break; - case 6 /* JSON */: - contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */; + case 6 /* ScriptKind.JSON */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */ | 67108864 /* NodeFlags.JsonFile */; break; default: - contextFlags = 0 /* None */; + contextFlags = 0 /* NodeFlags.None */; break; } parseErrorBeforeNextFinishedNode = false; @@ -32035,13 +32159,13 @@ var ts; function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 16777216 /* Ambient */; + contextFlags |= 16777216 /* NodeFlags.Ambient */; } sourceFlags = contextFlags; // Prime the scanner. nextToken(); - var statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token() === 1 /* EndOfFileToken */); + var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement); + ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */); var endOfFileToken = addJSDocComment(parseTokenNode()); var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator); // A member of ReadonlyArray isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future @@ -32074,7 +32198,7 @@ var ts; node.jsDoc = jsDoc; if (hasDeprecatedTag) { hasDeprecatedTag = false; - node.flags |= 268435456 /* Deprecated */; + node.flags |= 268435456 /* NodeFlags.Deprecated */; } return node; } @@ -32102,12 +32226,12 @@ var ts; // reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones. speculationHelper(function () { var savedContextFlags = contextFlags; - contextFlags |= 32768 /* AwaitContext */; + contextFlags |= 32768 /* NodeFlags.AwaitContext */; scanner.setTextPos(nextStatement.pos); nextToken(); - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var startPos = scanner.getStartPos(); - var statement = parseListElement(0 /* SourceElements */, parseStatement); + var statement = parseListElement(0 /* ParsingContext.SourceElements */, parseStatement); statements.push(statement); if (startPos === scanner.getStartPos()) { nextToken(); @@ -32125,7 +32249,7 @@ var ts; } } contextFlags = savedContextFlags; - }, 2 /* Reparse */); + }, 2 /* SpeculationKind.Reparse */); // find the next statement containing an `await` start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1; }; @@ -32145,8 +32269,8 @@ var ts; syntaxCursor = savedSyntaxCursor; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { - return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */); + return !(node.flags & 32768 /* NodeFlags.AwaitContext */) + && !!(node.transformFlags & 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -32187,7 +32311,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setFields(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); setFields(sourceFile); } @@ -32214,16 +32338,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 4096 /* DisallowInContext */); + setContextFlag(val, 4096 /* NodeFlags.DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 8192 /* YieldContext */); + setContextFlag(val, 8192 /* NodeFlags.YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 16384 /* DecoratorContext */); + setContextFlag(val, 16384 /* NodeFlags.DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 32768 /* AwaitContext */); + setContextFlag(val, 32768 /* NodeFlags.AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -32264,52 +32388,52 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(4096 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(4096 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function allowConditionalTypesAnd(func) { - return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doOutsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function disallowConditionalTypesAnd(func) { - return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doInsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(8192 /* YieldContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(16384 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* NodeFlags.DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(32768 /* AwaitContext */, func); + return doInsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(32768 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(8192 /* YieldContext */); + return inContext(8192 /* NodeFlags.YieldContext */); } function inDisallowInContext() { - return inContext(4096 /* DisallowInContext */); + return inContext(4096 /* NodeFlags.DisallowInContext */); } function inDisallowConditionalTypesContext() { - return inContext(65536 /* DisallowConditionalTypesContext */); + return inContext(65536 /* NodeFlags.DisallowConditionalTypesContext */); } function inDecoratorContext() { - return inContext(16384 /* DecoratorContext */); + return inContext(16384 /* NodeFlags.DecoratorContext */); } function inAwaitContext() { - return inContext(32768 /* AwaitContext */); + return inContext(32768 /* NodeFlags.AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -32410,15 +32534,15 @@ var ts; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the // same. - var result = speculationKind !== 0 /* TryParse */ + var result = speculationKind !== 0 /* SpeculationKind.TryParse */ ? scanner.lookAhead(callback) : scanner.tryScan(callback); ts.Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. - if (!result || speculationKind !== 0 /* TryParse */) { + if (!result || speculationKind !== 0 /* SpeculationKind.TryParse */) { currentToken = saveToken; - if (speculationKind !== 2 /* Reparse */) { + if (speculationKind !== 2 /* SpeculationKind.Reparse */) { parseDiagnostics.length = saveParseDiagnosticsLength; } parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -32430,7 +32554,7 @@ var ts; * is returned from this function. */ function lookAhead(callback) { - return speculationHelper(callback, 1 /* Lookahead */); + return speculationHelper(callback, 1 /* SpeculationKind.Lookahead */); } /** Invokes the provided callback. If the callback returns something falsy, then it restores * the parser to the state it was in immediately prior to invoking the callback. If the @@ -32438,31 +32562,31 @@ var ts; * of invoking the callback is returned from this function. */ function tryParse(callback) { - return speculationHelper(callback, 0 /* TryParse */); + return speculationHelper(callback, 0 /* SpeculationKind.TryParse */); } function isBindingIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder. - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 125 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* SyntaxKind.YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -32500,7 +32624,7 @@ var ts; // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined; if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } var pos = ts.skipTrivia(sourceText, node.pos); @@ -32515,17 +32639,17 @@ var ts; // If a declared node failed to parse, it would have emitted a diagnostic already. return; case "interface": - parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "is": parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; case "module": case "namespace": - parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "type": - parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */); + parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* SyntaxKind.EqualsToken */); return; } // The user alternatively might have misspelled or forgotten to add a space after a common keyword. @@ -32535,7 +32659,7 @@ var ts; return; } // Unknown tokens are handled with their own errors in the scanner - if (token() === 0 /* Unknown */) { + if (token() === 0 /* SyntaxKind.Unknown */) { return; } // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. @@ -32560,24 +32684,24 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; } function parseSemicolonAfterPropertyName(name, type, initializer) { - if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 59 /* SyntaxKind.AtToken */ && !scanner.hasPrecedingLineBreak()) { parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); return; } - if (token() === 20 /* OpenParenToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); nextToken(); return; } if (type && !canParseSemicolon()) { if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); } else { parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer); @@ -32588,7 +32712,7 @@ var ts; return; } if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } parseErrorForMissingSemicolonAfter(name); @@ -32655,24 +32779,24 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 1 /* SyntaxKind.EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function tryParseSemicolon() { if (!canParseSemicolon()) { return false; } - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } function parseSemicolon() { - return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */); + return tryParseSemicolon() || parseExpected(26 /* SyntaxKind.SemicolonToken */); } function createNodeArray(elements, pos, end, hasTrailingComma) { var array = factory.createNodeArray(elements, hasTrailingComma); @@ -32689,7 +32813,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 131072 /* ThisNodeHasError */; + node.flags |= 131072 /* NodeFlags.ThisNodeHasError */; } return node; } @@ -32701,11 +32825,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* SyntaxKind.Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 276 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : + kind === 276 /* SyntaxKind.MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -32729,23 +32853,23 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(/*isIdentifier*/ true); } - if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) { + if (token() === 0 /* SyntaxKind.Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* SyntaxKind.Identifier */; })) { // Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser. return createIdentifier(/*isIdentifier*/ true); } identifierCount++; // Only for end of file because the error gets reported incorrectly on embedded script tags. - var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + var reportAtCurrentPosition = token() === 1 /* SyntaxKind.EndOfFileToken */; var isReservedWord = scanner.isReservedWord(); var msgArg = scanner.getTokenText(); var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* SyntaxKind.Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -32758,23 +32882,23 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */; } function isAssertionKey() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ || token() === 8 /* SyntaxKind.NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -32787,12 +32911,12 @@ var ts; // LiteralPropertyName // ComputedPropertyName[?Yield] var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. var expression = allowInAnd(parseExpression); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createComputedPropertyName(expression), pos); } function internPrivateIdentifier(text) { @@ -32820,23 +32944,23 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 92 /* EnumKeyword */; - case 93 /* ExportKeyword */: + return nextToken() === 92 /* SyntaxKind.EnumKeyword */; + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); - if (token() === 88 /* DefaultKeyword */) { + if (token() === 88 /* SyntaxKind.DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 152 /* TypeKeyword */) { + if (token() === 152 /* SyntaxKind.TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 124 /* StaticKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -32844,9 +32968,9 @@ var ts; } } function canFollowExportModifier() { - return token() !== 41 /* AsteriskToken */ - && token() !== 127 /* AsKeyword */ - && token() !== 18 /* OpenBraceToken */ + return token() !== 41 /* SyntaxKind.AsteriskToken */ + && token() !== 127 /* SyntaxKind.AsKeyword */ + && token() !== 18 /* SyntaxKind.OpenBraceToken */ && canFollowModifier(); } function nextTokenCanFollowExportModifier() { @@ -32857,18 +32981,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 22 /* OpenBracketToken */ - || token() === 18 /* OpenBraceToken */ - || token() === 41 /* AsteriskToken */ - || token() === 25 /* DotDotDotToken */ + return token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 41 /* SyntaxKind.AsteriskToken */ + || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || - token() === 118 /* InterfaceKeyword */ || - (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* SyntaxKind.ClassKeyword */ || token() === 98 /* SyntaxKind.FunctionKeyword */ || + token() === 118 /* SyntaxKind.InterfaceKeyword */ || + (token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -32877,50 +33001,50 @@ var ts; return true; } switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 2 /* SwitchClauses */: - return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 4 /* TypeMembers */: + return !(token() === 26 /* SyntaxKind.SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + case 2 /* ParsingContext.SwitchClauses */: + return token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 4 /* ParsingContext.TypeMembers */: return lookAhead(isTypeMemberStart); - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); - case 6 /* EnumMembers */: + return lookAhead(isClassMemberStart) || (token() === 26 /* SyntaxKind.SemicolonToken */ && !inErrorRecovery); + case 6 /* ParsingContext.EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); - case 12 /* ObjectLiteralMembers */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || isLiteralPropertyName(); + case 12 /* ParsingContext.ObjectLiteralMembers */: switch (token()) { - case 22 /* OpenBracketToken */: - case 41 /* AsteriskToken */: - case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* SyntaxKind.OpenBracketToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 24 /* SyntaxKind.DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; default: return isLiteralPropertyName(); } - case 18 /* RestProperties */: + case 18 /* ParsingContext.RestProperties */: return isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); - case 24 /* AssertEntries */: + case 9 /* ParsingContext.ObjectBindingElements */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); + case 24 /* ParsingContext.AssertEntries */: return isAssertionKey(); - case 7 /* HeritageClauseElement */: + case 7 /* ParsingContext.HeritageClauseElement */: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -32932,42 +33056,42 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 19 /* TypeParameters */: - return token() === 101 /* InKeyword */ || isIdentifier(); - case 15 /* ArrayLiteralMembers */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); + case 19 /* ParsingContext.TypeParameters */: + return token() === 101 /* SyntaxKind.InKeyword */ || isIdentifier(); + case 15 /* ParsingContext.ArrayLiteralMembers */: switch (token()) { - case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 27 /* SyntaxKind.CommaToken */: + case 24 /* SyntaxKind.DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) return true; } // falls through - case 11 /* ArgumentExpressions */: - return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: + case 11 /* ParsingContext.ArgumentExpressions */: + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isStartOfExpression(); + case 16 /* ParsingContext.Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); - case 17 /* JSDocParameters */: + case 17 /* ParsingContext.JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); - case 20 /* TypeArguments */: - case 21 /* TupleElementTypes */: - return token() === 27 /* CommaToken */ || isStartOfType(); - case 22 /* HeritageClauses */: + case 20 /* ParsingContext.TypeArguments */: + case 21 /* ParsingContext.TupleElementTypes */: + return token() === 27 /* SyntaxKind.CommaToken */ || isStartOfType(); + case 22 /* ParsingContext.HeritageClauses */: return isHeritageClause(); - case 23 /* ImportOrExportSpecifiers */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; - case 14 /* JsxChildren */: + case 13 /* ParsingContext.JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* SyntaxKind.OpenBraceToken */; + case 14 /* ParsingContext.JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 18 /* OpenBraceToken */); - if (nextToken() === 19 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* SyntaxKind.OpenBraceToken */); + if (nextToken() === 19 /* SyntaxKind.CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -32976,7 +33100,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; + return next === 27 /* SyntaxKind.CommaToken */ || next === 18 /* SyntaxKind.OpenBraceToken */ || next === 94 /* SyntaxKind.ExtendsKeyword */ || next === 117 /* SyntaxKind.ImplementsKeyword */; } return true; } @@ -32993,8 +33117,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 117 /* ImplementsKeyword */ || - token() === 94 /* ExtendsKeyword */) { + if (token() === 117 /* SyntaxKind.ImplementsKeyword */ || + token() === 94 /* SyntaxKind.ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -33009,51 +33133,51 @@ var ts; } // True if positioned at a list terminator function isListTerminator(kind) { - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { // Being at the end of the file ends all lists. return true; } switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 23 /* ImportOrExportSpecifiers */: - case 24 /* AssertEntries */: - return token() === 19 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: + case 2 /* ParsingContext.SwitchClauses */: + case 4 /* ParsingContext.TypeMembers */: + case 5 /* ParsingContext.ClassMembers */: + case 6 /* ParsingContext.EnumMembers */: + case 12 /* ParsingContext.ObjectLiteralMembers */: + case 9 /* ParsingContext.ObjectBindingElements */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: + case 24 /* ParsingContext.AssertEntries */: + return token() === 19 /* SyntaxKind.CloseBraceToken */; + case 3 /* ParsingContext.SwitchClauseStatements */: + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 7 /* ParsingContext.HeritageClauseElement */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 8 /* ParsingContext.VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 19 /* TypeParameters */: + case 19 /* ParsingContext.TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 11 /* ParsingContext.ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 21 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token() === 23 /* CloseBracketToken */; - case 17 /* JSDocParameters */: - case 16 /* Parameters */: - case 18 /* RestProperties */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 26 /* SyntaxKind.SemicolonToken */; + case 15 /* ParsingContext.ArrayLiteralMembers */: + case 21 /* ParsingContext.TupleElementTypes */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 23 /* SyntaxKind.CloseBracketToken */; + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: + case 18 /* ParsingContext.RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 20 /* TypeArguments */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + case 20 /* ParsingContext.TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 27 /* CommaToken */; - case 22 /* HeritageClauses */: - return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; - case 14 /* JsxChildren */: - return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() !== 27 /* SyntaxKind.CommaToken */; + case 22 /* ParsingContext.HeritageClauses */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 19 /* SyntaxKind.CloseBraceToken */; + case 13 /* ParsingContext.JsxAttributes */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 43 /* SyntaxKind.SlashToken */; + case 14 /* ParsingContext.JsxChildren */: + return token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -33073,7 +33197,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -33081,7 +33205,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 25 /* ParsingContext.Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -33115,7 +33239,7 @@ var ts; } return parseElement(); } - function currentNode(parsingContext) { + function currentNode(parsingContext, pos) { // If we don't have a cursor or the parsing context isn't reusable, there's nothing to reuse. // // If there is an outstanding parse error that we've encountered, but not attached to @@ -33128,7 +33252,7 @@ var ts; if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) { return undefined; } - var node = syntaxCursor.currentNode(scanner.getStartPos()); + var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos()); // Can't reuse a missing node. // Can't reuse a node that intersected the change range. // Can't reuse a node that contains a parse error. This is necessary so that we @@ -33147,7 +33271,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 50720768 /* ContextFlags */; + var nodeContextFlags = node.flags & 50720768 /* NodeFlags.ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -33170,38 +33294,38 @@ var ts; } function isReusableParsingContext(parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: - case 2 /* SwitchClauses */: - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - case 6 /* EnumMembers */: - case 4 /* TypeMembers */: - case 8 /* VariableDeclarations */: - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 5 /* ParsingContext.ClassMembers */: + case 2 /* ParsingContext.SwitchClauses */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: + case 6 /* ParsingContext.EnumMembers */: + case 4 /* ParsingContext.TypeMembers */: + case 8 /* ParsingContext.VariableDeclarations */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return true; } return false; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: return isReusableClassMember(node); - case 2 /* SwitchClauses */: + case 2 /* ParsingContext.SwitchClauses */: return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: return isReusableStatement(node); - case 6 /* EnumMembers */: + case 6 /* ParsingContext.EnumMembers */: return isReusableEnumMember(node); - case 4 /* TypeMembers */: + case 4 /* ParsingContext.TypeMembers */: return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isReusableVariableDeclaration(node); - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative @@ -33248,20 +33372,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 171 /* Constructor */: - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 234 /* SemicolonClassElement */: + case 171 /* SyntaxKind.Constructor */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 234 /* SyntaxKind.SemicolonClassElement */: return true; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ && + methodDeclaration.name.originalKeywordKind === 134 /* SyntaxKind.ConstructorKeyword */; return !nameIsConstructor; } } @@ -33270,8 +33394,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return true; } } @@ -33280,58 +33404,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 237 /* VariableStatement */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 238 /* ExpressionStatement */: - case 251 /* ThrowStatement */: - case 247 /* ReturnStatement */: - case 249 /* SwitchStatement */: - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 236 /* EmptyStatement */: - case 252 /* TryStatement */: - case 250 /* LabeledStatement */: - case 240 /* DoStatement */: - case 253 /* DebuggerStatement */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 166 /* PropertySignature */: - case 174 /* CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 174 /* SyntaxKind.CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 254 /* VariableDeclaration */) { + if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -33352,7 +33476,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 164 /* Parameter */) { + if (node.kind !== 164 /* SyntaxKind.Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -33370,40 +33494,42 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return token() === 88 /* DefaultKeyword */ - ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */)) + case 0 /* ParsingContext.SourceElements */: + return token() === 88 /* SyntaxKind.DefaultKeyword */ + ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* SyntaxKind.ExportKeyword */)) : parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); - case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); - case 18 /* RestProperties */: // fallthrough - case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); - case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); - case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); - case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 2 /* ParsingContext.SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); + case 3 /* ParsingContext.SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); + case 18 /* ParsingContext.RestProperties */: // fallthrough + case 4 /* ParsingContext.TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); + case 5 /* ParsingContext.ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case 6 /* ParsingContext.EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); + case 7 /* ParsingContext.HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); + case 8 /* ParsingContext.VariableDeclarations */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected); - case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); - case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); - case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); - case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); - case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); - case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 16 /* Parameters */: + case 9 /* ParsingContext.ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); + case 10 /* ParsingContext.ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); + case 11 /* ParsingContext.ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); + case 12 /* ParsingContext.ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); + case 15 /* ParsingContext.ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); + case 17 /* ParsingContext.JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* ParsingContext.Parameters */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); - case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); - case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); - case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); - case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);` + case 19 /* ParsingContext.TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); + case 20 /* ParsingContext.TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); + case 21 /* ParsingContext.TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); + case 22 /* ParsingContext.HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 13 /* ParsingContext.JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 14 /* ParsingContext.JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 24 /* ParsingContext.AssertEntries */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); // AssertionKey. + case 25 /* ParsingContext.Count */: return ts.Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker. + default: ts.Debug.assertNever(context); } } function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { @@ -33422,7 +33548,7 @@ var ts; } list.push(result); commaStart = scanner.getTokenPos(); - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -33432,13 +33558,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); + parseExpected(27 /* SyntaxKind.CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SyntaxKind.SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -33467,7 +33593,7 @@ var ts; return createNodeArray(list, listPos, /*end*/ undefined, commaStart >= 0); } function getExpectedCommaDiagnostic(kind) { - return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + return kind === 6 /* ParsingContext.EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; } function createMissingList() { var list = createNodeArray([], getNodePos()); @@ -33489,8 +33615,8 @@ var ts; var pos = getNodePos(); var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = getNodePos(); - while (parseOptional(24 /* DotToken */)) { - if (token() === 29 /* LessThanToken */) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -33529,12 +33655,12 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -33545,7 +33671,7 @@ var ts; do { node = parseTemplateSpan(isTaggedTemplate); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateExpression(isTaggedTemplate) { @@ -33563,7 +33689,7 @@ var ts; do { node = parseTemplateTypeSpan(); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateTypeSpan() { @@ -33571,13 +33697,13 @@ var ts; return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos); } function parseLiteralOfTemplateSpan(isTaggedTemplate) { - if (token() === 19 /* CloseBraceToken */) { + if (token() === 19 /* SyntaxKind.CloseBraceToken */) { reScanTemplateToken(isTaggedTemplate); return parseTemplateMiddleOrTemplateTail(); } else { // TODO(rbuckton): Do we need to call `parseExpectedToken` or can we just call `createMissingNode` directly? - return parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); + return parseExpectedToken(17 /* SyntaxKind.TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* SyntaxKind.CloseBraceToken */)); } } function parseTemplateSpan(isTaggedTemplate) { @@ -33592,30 +33718,30 @@ var ts; reScanTemplateHeadOrNoSubstitutionTemplate(); } var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* SyntaxKind.TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* SyntaxKind.TemplateMiddle */ || fragment.kind === 17 /* SyntaxKind.TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function getTemplateLiteralRawText(kind) { - var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var isLast = kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || kind === 17 /* SyntaxKind.TemplateTail */; var tokenText = scanner.getTokenText(); return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); } function parseLiteralLikeNode(kind) { var pos = getNodePos(); - var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : + var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TokenFlags.TemplateLiteralLikeFlags */) : // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal. But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) : ts.Debug.fail(); if (scanner.hasExtendedUnicodeEscape()) { @@ -33632,8 +33758,8 @@ var ts; return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { - return parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function parseTypeReference() { @@ -33643,14 +33769,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return ts.nodeIsMissing(node.typeName); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: { + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -33688,12 +33814,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 27 /* CommaToken */ || - token() === 19 /* CloseBraceToken */ || - token() === 21 /* CloseParenToken */ || - token() === 31 /* GreaterThanToken */ || - token() === 63 /* EqualsToken */ || - token() === 51 /* BarToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */ || + token() === 19 /* SyntaxKind.CloseBraceToken */ || + token() === 21 /* SyntaxKind.CloseParenToken */ || + token() === 31 /* SyntaxKind.GreaterThanToken */ || + token() === 63 /* SyntaxKind.EqualsToken */ || + token() === 51 /* SyntaxKind.BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } else { @@ -33705,8 +33831,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); if (lookAhead(nextTokenIsOpenParen)) { nextToken(); - var parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */ | 32 /* SignatureFlags.JSDoc */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc); } return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), /*typeArguments*/ undefined), pos); @@ -33714,9 +33840,9 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */ || token() === 103 /* SyntaxKind.NewKeyword */) { name = parseIdentifierName(); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); } return finishNode(factory.createParameterDeclaration( /*modifiers*/ undefined, @@ -33729,15 +33855,15 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(141 /* ModuleKeyword */)) { + if (parseOptional(141 /* SyntaxKind.ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { switch (token()) { - case 19 /* CloseBraceToken */: - case 1 /* EndOfFileToken */: - case 27 /* CommaToken */: - case 5 /* WhitespaceTrivia */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 1 /* SyntaxKind.EndOfFileToken */: + case 27 /* SyntaxKind.CommaToken */: + case 5 /* SyntaxKind.WhitespaceTrivia */: break terminate; default: nextTokenJSDoc(); @@ -33746,13 +33872,13 @@ var ts; scanner.setInJSDocType(false); return finishNode(moduleTag, pos); } - var hasDotDotDot = parseOptional(25 /* DotDotDotToken */); + var hasDotDotDot = parseOptional(25 /* SyntaxKind.DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -33760,7 +33886,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(112 /* TypeOfKeyword */); + parseExpected(112 /* SyntaxKind.TypeOfKeyword */); var entityName = parseEntityName(/*allowReservedWords*/ true); // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression. var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; @@ -33772,7 +33898,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -33791,21 +33917,21 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); } function parseTypeParameters() { - if (token() === 29 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (token() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function isStartOfParameter(isJSDocParameter) { - return token() === 25 /* DotDotDotToken */ || + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 59 /* AtToken */ || + token() === 59 /* SyntaxKind.AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseNameOfParameter(modifiers) { @@ -33829,7 +33955,7 @@ var ts; // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later // complaining about the use of the keywords. - return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */; + return isBindingIdentifier() || token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function parseParameter(inOuterAwaitContext) { return parseParameterWorker(inOuterAwaitContext); @@ -33844,8 +33970,8 @@ var ts; // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. - var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); - if (token() === 108 /* ThisKeyword */) { + var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators); + if (token() === 108 /* SyntaxKind.ThisKeyword */) { var node_1 = factory.createParameterDeclaration(decorators, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, parseTypeAnnotation(), @@ -33858,11 +33984,11 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var modifiers = combineDecoratorsAndModifiers(decorators, parseModifiers()); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); if (!allowAmbiguity && !isParameterNameStart()) { return undefined; } - var node = withJSDoc(finishNode(factory.createParameterDeclaration(modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createParameterDeclaration(modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* SyntaxKind.QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); topLevel = savedTopLevel; return node; } @@ -33872,16 +33998,16 @@ var ts; } } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 38 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* SyntaxKind.EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(58 /* ColonToken */)) { + else if (parseOptional(58 /* SyntaxKind.ColonToken */)) { return true; } - else if (isType && token() === 38 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */)); nextToken(); return true; } @@ -33903,11 +34029,11 @@ var ts; // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); - setYieldContext(!!(flags & 1 /* Yield */)); - setAwaitContext(!!(flags & 2 /* Await */)); - var parameters = flags & 32 /* JSDoc */ ? - parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) : - parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); + var parameters = flags & 32 /* SignatureFlags.JSDoc */ ? + parseDelimitedList(17 /* ParsingContext.JSDocParameters */, parseJSDocParameter) : + parseDelimitedList(16 /* ParsingContext.Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); return parameters; @@ -33926,17 +34052,17 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { return createMissingList(); } var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return parameters; } function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -33945,20 +34071,20 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 175 /* ConstructSignature */) { - parseExpected(103 /* NewKeyword */); + if (kind === 175 /* SyntaxKind.ConstructSignature */) { + parseExpected(103 /* SyntaxKind.NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 174 /* CallSignature */ + var node = kind === 174 /* SyntaxKind.CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); } function isIndexSignature() { - return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* SyntaxKind.OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -33978,7 +34104,7 @@ var ts; // [] // nextToken(); - if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -33997,21 +34123,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 57 /* QuestionToken */) { + if (token() !== 57 /* SyntaxKind.QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */; } function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) { - var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); + var parameters = parseBracketedList(16 /* ParsingContext.Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */); var type = parseTypeAnnotation(); parseTypeMemberSemicolon(); var node = factory.createIndexSignature(modifiers, parameters, type); @@ -34020,14 +34146,14 @@ var ts; } function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); var node; - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type); } else { @@ -34036,7 +34162,7 @@ var ts; // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === 63 /* EqualsToken */) + if (token() === 63 /* SyntaxKind.EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -34044,10 +34170,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 136 /* GetKeyword */ || - token() === 149 /* SetKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 136 /* SyntaxKind.GetKeyword */ || + token() === 149 /* SyntaxKind.SetKeyword */) { return true; } var idToken = false; @@ -34057,7 +34183,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -34068,30 +34194,30 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 57 /* QuestionToken */ || - token() === 58 /* ColonToken */ || - token() === 27 /* CommaToken */ || + return token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || + token() === 58 /* SyntaxKind.ColonToken */ || + token() === 27 /* SyntaxKind.CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(174 /* CallSignature */); + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { + return parseSignatureMember(174 /* SyntaxKind.CallSignature */); } - if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(175 /* ConstructSignature */); + if (token() === 103 /* SyntaxKind.NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(175 /* SyntaxKind.ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SyntaxKind.GetAccessor */, 4 /* SignatureFlags.Type */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SyntaxKind.SetAccessor */, 4 /* SignatureFlags.Type */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -34100,16 +34226,16 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; + return token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 24 /* DotToken */; + return nextToken() === 24 /* SyntaxKind.DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 20 /* OpenParenToken */: - case 29 /* LessThanToken */: - case 24 /* DotToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 24 /* SyntaxKind.DotToken */: return true; } return false; @@ -34120,9 +34246,9 @@ var ts; } function parseObjectTypeMembers() { var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -34131,51 +34257,51 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 145 /* ReadonlyKeyword */; + if (token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { + return nextToken() === 145 /* SyntaxKind.ReadonlyKeyword */; } - if (token() === 145 /* ReadonlyKeyword */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; + return token() === 22 /* SyntaxKind.OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* SyntaxKind.InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(101 /* InKeyword */); + parseExpected(101 /* SyntaxKind.InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos); } function parseMappedType() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var readonlyToken; - if (token() === 145 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 145 /* ReadonlyKeyword */) { - parseExpected(145 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + parseExpected(145 /* SyntaxKind.ReadonlyKeyword */); } } - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; - parseExpected(23 /* CloseBracketToken */); + var nameType = parseOptional(127 /* SyntaxKind.AsKeyword */) ? parseType() : undefined; + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var questionToken; - if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 57 /* SyntaxKind.QuestionToken */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { questionToken = parseTokenNode(); - if (questionToken.kind !== 57 /* QuestionToken */) { - parseExpected(57 /* QuestionToken */); + if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { + parseExpected(57 /* SyntaxKind.QuestionToken */); } } var type = parseTypeAnnotation(); parseSemicolon(); - var members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + var members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(25 /* DotDotDotToken */)) { + if (parseOptional(25 /* SyntaxKind.DotDotDotToken */)) { return finishNode(factory.createRestTypeNode(parseType()), pos); } var type = parseType(); @@ -34188,10 +34314,10 @@ var ts; return type; } function isNextTokenColonOrQuestionColon() { - return nextToken() === 58 /* ColonToken */ || (token() === 57 /* QuestionToken */ && nextToken() === 58 /* ColonToken */); + return nextToken() === 58 /* SyntaxKind.ColonToken */ || (token() === 57 /* SyntaxKind.QuestionToken */ && nextToken() === 58 /* SyntaxKind.ColonToken */); } function isTupleElementName() { - if (token() === 25 /* DotDotDotToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */) { return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon(); } return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon(); @@ -34200,10 +34326,10 @@ var ts; if (lookAhead(isTupleElementName)) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); - parseExpected(58 /* ColonToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var type = parseTupleElementType(); var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -34212,21 +34338,21 @@ var ts; } function parseTupleType() { var pos = getNodePos(); - return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */)), pos); + return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* ParsingContext.TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */)), pos); } function parseParenthesizedType() { var pos = getNodePos(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createParenthesizedType(type), pos); } function parseModifiersForConstructorType() { var modifiers; - if (token() === 126 /* AbstractKeyword */) { + if (token() === 126 /* SyntaxKind.AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* SyntaxKind.AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -34235,10 +34361,10 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(103 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* SyntaxKind.NewKeyword */); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(38 /* SyntaxKind.EqualsGreaterThanToken */, /*isType*/ false); var node = isConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory.createFunctionTypeNode(typeParameters, parameters, type); @@ -34248,34 +34374,34 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 24 /* DotToken */ ? undefined : node; + return token() === 24 /* SyntaxKind.DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { var pos = getNodePos(); if (negative) { nextToken(); } - var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? + var expression = token() === 110 /* SyntaxKind.TrueKeyword */ || token() === 95 /* SyntaxKind.FalseKeyword */ || token() === 104 /* SyntaxKind.NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { - expression = finishNode(factory.createPrefixUnaryExpression(40 /* MinusToken */, expression), pos); + expression = finishNode(factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, expression), pos); } return finishNode(factory.createLiteralTypeNode(expression), pos); } function isStartOfTypeOfImportType() { nextToken(); - return token() === 100 /* ImportKeyword */; + return token() === 100 /* SyntaxKind.ImportKeyword */; } function parseImportTypeAssertions() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - parseExpected(129 /* AssertKeyword */); - parseExpected(58 /* ColonToken */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); var clause = parseAssertClause(/*skipAssertKeyword*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -34284,89 +34410,89 @@ var ts; return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos); } function parseImportType() { - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(112 /* TypeOfKeyword */); - parseExpected(100 /* ImportKeyword */); - parseExpected(20 /* OpenParenToken */); + var isTypeOf = parseOptional(112 /* SyntaxKind.TypeOfKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); var assertions; - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { assertions = parseImportTypeAssertions(); } - parseExpected(21 /* CloseParenToken */); - var qualifier = parseOptional(24 /* DotToken */) ? parseEntityNameOfTypeReference() : undefined; + parseExpected(21 /* SyntaxKind.CloseParenToken */); + var qualifier = parseOptional(24 /* SyntaxKind.DotToken */) ? parseEntityNameOfTypeReference() : undefined; var typeArguments = parseTypeArgumentsOfTypeReference(); return finishNode(factory.createImportTypeNode(type, assertions, qualifier, typeArguments, isTypeOf), pos); } function nextTokenIsNumericOrBigIntLiteral() { nextToken(); - return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; + return token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 151 /* SymbolKeyword */: - case 133 /* BooleanKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 66 /* AsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return parseJSDocAllType(); - case 60 /* QuestionQuestionToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // If there is '??', treat it as prefix-'?' in JSDoc type. scanner.reScanQuestionToken(); // falls through - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseJSDocFunctionType(); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return parseLiteralTypeNode(); - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseTokenNode(); - case 108 /* ThisKeyword */: { + case 108 /* SyntaxKind.ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseTupleType(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedType(); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportType(); - case 128 /* AssertsKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateType(); default: return parseTypeReference(); @@ -34374,48 +34500,48 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 145 /* ReadonlyKeyword */: - case 151 /* SymbolKeyword */: - case 154 /* UniqueKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 112 /* TypeOfKeyword */: - case 143 /* NeverKeyword */: - case 18 /* OpenBraceToken */: - case 22 /* OpenBracketToken */: - case 29 /* LessThanToken */: - case 51 /* BarToken */: - case 50 /* AmpersandToken */: - case 103 /* NewKeyword */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 148 /* ObjectKeyword */: - case 41 /* AsteriskToken */: - case 57 /* QuestionToken */: - case 53 /* ExclamationToken */: - case 25 /* DotDotDotToken */: - case 137 /* InferKeyword */: - case 100 /* ImportKeyword */: - case 128 /* AssertsKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 51 /* SyntaxKind.BarToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 103 /* SyntaxKind.NewKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 41 /* SyntaxKind.AsteriskToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 137 /* SyntaxKind.InferKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: return true; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return !inStartOfParameter; - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -34425,18 +34551,18 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* SyntaxKind.CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var pos = getNodePos(); var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: nextToken(); type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos); break; - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: // If next token is start of a type we have a conditional type if (lookAhead(nextTokenIsStartOfType)) { return type; @@ -34444,15 +34570,15 @@ var ts; nextToken(); type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos); break; - case 22 /* OpenBracketToken */: - parseExpected(22 /* OpenBracketToken */); + case 22 /* SyntaxKind.OpenBracketToken */: + parseExpected(22 /* SyntaxKind.OpenBracketToken */); if (isStartOfType()) { var indexType = parseType(); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos); } else { - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createArrayTypeNode(type), pos); } break; @@ -34468,9 +34594,9 @@ var ts; return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos); } function tryParseConstraintOfInferType() { - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { var constraint = disallowConditionalTypesAnd(parseType); - if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) { + if (inDisallowConditionalTypesContext() || token() !== 57 /* SyntaxKind.QuestionToken */) { return constraint; } } @@ -34484,17 +34610,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(137 /* InferKeyword */); + parseExpected(137 /* SyntaxKind.InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 140 /* KeyOfKeyword */: - case 154 /* UniqueKeyword */: - case 145 /* ReadonlyKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: return parseTypeOperator(operator); - case 137 /* InferKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return parseInferType(); } return allowConditionalTypesAnd(parsePostfixTypeOrHigher); @@ -34523,7 +34649,7 @@ var ts; } function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) { var pos = getNodePos(); - var isUnionType = operator === 51 /* BarToken */; + var isUnionType = operator === 51 /* SyntaxKind.BarToken */; var hasLeadingOperator = parseOptional(operator); var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType(); @@ -34537,35 +34663,35 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(50 /* AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); + return parseUnionOrIntersectionType(50 /* SyntaxKind.AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(51 /* BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); + return parseUnionOrIntersectionType(51 /* SyntaxKind.BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); } function nextTokenIsNewKeyword() { nextToken(); - return token() === 103 /* NewKeyword */; + return token() === 103 /* SyntaxKind.NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return true; } - if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 103 /* NewKeyword */ || - token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* SyntaxKind.NewKeyword */ || + token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 108 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* SyntaxKind.ThisKeyword */) { nextToken(); return true; } - if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -34575,7 +34701,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */) { // ( ) // ( ... return true; @@ -34583,17 +34709,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || token() === 63 /* SyntaxKind.EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 21 /* CloseParenToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */) { nextToken(); - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -34614,65 +34740,65 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); - var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* SyntaxKind.AssertsKeyword */); + var parameterName = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(139 /* SyntaxKind.IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { - if (contextFlags & 40960 /* TypeExcludesFlags */) { - return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType); + if (contextFlags & 40960 /* NodeFlags.TypeExcludesFlags */) { + return doOutsideOfContext(40960 /* NodeFlags.TypeExcludesFlags */, parseType); } if (isStartOfFunctionTypeOrConstructorType()) { return parseFunctionOrConstructorType(); } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { + if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = disallowConditionalTypesAnd(parseType); - parseExpected(57 /* QuestionToken */); + parseExpected(57 /* SyntaxKind.QuestionToken */); var trueType = allowConditionalTypesAnd(parseType); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var falseType = allowConditionalTypesAnd(parseType); return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos); } return type; } function parseTypeAnnotation() { - return parseOptional(58 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* SyntaxKind.ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 20 /* OpenParenToken */: - case 22 /* OpenBracketToken */: - case 18 /* OpenBraceToken */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 103 /* NewKeyword */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 79 /* Identifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 20 /* SyntaxKind.OpenParenToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 103 /* SyntaxKind.NewKeyword */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 79 /* SyntaxKind.Identifier */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -34683,19 +34809,19 @@ var ts; return true; } switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 29 /* LessThanToken */: - case 132 /* AwaitKeyword */: - case 125 /* YieldKeyword */: - case 80 /* PrivateIdentifier */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 132 /* SyntaxKind.AwaitKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: + case 80 /* SyntaxKind.PrivateIdentifier */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -34713,10 +34839,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 18 /* OpenBraceToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && - token() !== 59 /* AtToken */ && + return token() !== 18 /* SyntaxKind.OpenBraceToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && + token() !== 59 /* SyntaxKind.AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -34731,7 +34857,7 @@ var ts; var pos = getNodePos(); var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); var operatorToken; - while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(27 /* SyntaxKind.CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos); } if (saveDecoratorContext) { @@ -34740,7 +34866,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined; + return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined; } function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) { // AssignmentExpression[in,yield]: @@ -34782,11 +34908,11 @@ var ts; // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. var pos = getNodePos(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -34802,7 +34928,7 @@ var ts; return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction); } function isYieldExpression() { - if (token() === 125 /* YieldKeyword */) { + if (token() === 125 /* SyntaxKind.YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -34838,8 +34964,8 @@ var ts; // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos); + (token() === 41 /* SyntaxKind.AsteriskToken */ || isStartOfExpression())) { + return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* SyntaxKind.AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos); } else { // if the next token is not on the same line as yield. or we don't have an '*' or @@ -34848,7 +34974,7 @@ var ts; } } function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) { - ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* SyntaxKind.EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var parameter = factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, identifier, @@ -34857,14 +34983,14 @@ var ts; /*initializer*/ undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction); var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { + if (triState === 0 /* Tristate.False */) { // It's definitely not a parenthesized arrow function expression. return undefined; } @@ -34872,7 +34998,7 @@ var ts; // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. - return triState === 1 /* True */ ? + return triState === 1 /* Tristate.True */ ? parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) : tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); }); } @@ -34881,44 +35007,44 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */ || token() === 131 /* SyntaxKind.AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. - return 1 /* True */; + return 1 /* Tristate.True */; } // Definitely not a parenthesized arrow function. - return 0 /* False */; + return 0 /* Tristate.False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; + return 0 /* Tristate.False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { - return 0 /* False */; + if (token() !== 20 /* SyntaxKind.OpenParenToken */ && token() !== 29 /* SyntaxKind.LessThanToken */) { + return 0 /* Tristate.False */; } } var first = token(); var second = nextToken(); - if (first === 20 /* OpenParenToken */) { - if (second === 21 /* CloseParenToken */) { + if (first === 20 /* SyntaxKind.OpenParenToken */) { + if (second === 21 /* SyntaxKind.CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 38 /* EqualsGreaterThanToken */: - case 58 /* ColonToken */: - case 18 /* OpenBraceToken */: - return 1 /* True */; + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 58 /* SyntaxKind.ColonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + return 1 /* Tristate.True */; default: - return 0 /* False */; + return 0 /* Tristate.False */; } } // If encounter "([" or "({", this could be the start of a binding pattern. @@ -34927,85 +35053,85 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { - return 2 /* Unknown */; + if (second === 22 /* SyntaxKind.OpenBracketToken */ || second === 18 /* SyntaxKind.OpenBraceToken */) { + return 2 /* Tristate.Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 25 /* DotDotDotToken */) { - return 1 /* True */; + if (second === 25 /* SyntaxKind.DotDotDotToken */) { + return 1 /* Tristate.True */; } // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { - if (nextToken() === 127 /* AsKeyword */) { + if (ts.isModifierKind(second) && second !== 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (nextToken() === 127 /* SyntaxKind.AsKeyword */) { // https://github.com/microsoft/TypeScript/issues/44466 - return 0 /* False */; + return 0 /* Tristate.False */; } - return 1 /* True */; + return 1 /* Tristate.True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 108 /* ThisKeyword */) { - return 0 /* False */; + if (!isIdentifier() && second !== 108 /* SyntaxKind.ThisKeyword */) { + return 0 /* Tristate.False */; } switch (nextToken()) { - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - return 1 /* True */; - case 57 /* QuestionToken */: + return 1 /* Tristate.True */; + case 57 /* SyntaxKind.QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { - return 1 /* True */; + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 63 /* SyntaxKind.EqualsToken */ || token() === 21 /* SyntaxKind.CloseParenToken */) { + return 1 /* Tristate.True */; } // Otherwise it is definitely not a lambda. - return 0 /* False */; - case 27 /* CommaToken */: - case 63 /* EqualsToken */: - case 21 /* CloseParenToken */: + return 0 /* Tristate.False */; + case 27 /* SyntaxKind.CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 21 /* SyntaxKind.CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } // It is definitely not an arrow function - return 0 /* False */; + return 0 /* Tristate.False */; } else { - ts.Debug.assert(first === 29 /* LessThanToken */); + ts.Debug.assert(first === 29 /* SyntaxKind.LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { - return 0 /* False */; + return 0 /* Tristate.False */; } // JSX overrides - if (languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* LanguageVariant.JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 94 /* ExtendsKeyword */) { + if (third === 94 /* SyntaxKind.ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 63 /* EqualsToken */: - case 31 /* GreaterThanToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: return false; default: return true; } } - else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) { + else if (third === 27 /* SyntaxKind.CommaToken */ || third === 63 /* SyntaxKind.EqualsToken */) { return true; } return false; }); if (isArrowFunctionInJsx) { - return 1 /* True */; + return 1 /* Tristate.True */; } - return 0 /* False */; + return 0 /* Tristate.False */; } // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } } function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { @@ -35021,11 +35147,11 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 131 /* AsyncKeyword */) { - if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* Tristate.True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier); } } @@ -35035,26 +35161,26 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { - return 0 /* False */; + if (scanner.hasPrecedingLineBreak() || token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 0 /* Tristate.False */; } // Check for un-parenthesized AsyncArrowFunction - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return 1 /* True */; + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 1 /* Tristate.True */; } } - return 0 /* False */; + return 0 /* Tristate.False */; } function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -35064,7 +35190,7 @@ var ts; // close paren. var typeParameters = parseTypeParameters(); var parameters; - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { if (!allowAmbiguity) { return undefined; } @@ -35081,12 +35207,12 @@ var ts; else { parameters = parseParametersWorker(isAsync, allowAmbiguity); } - if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) { + if (!parseExpected(21 /* SyntaxKind.CloseParenToken */) && !allowAmbiguity) { return undefined; } } - var hasReturnColon = token() === 58 /* ColonToken */; - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var hasReturnColon = token() === 58 /* SyntaxKind.ColonToken */; + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; } @@ -35101,19 +35227,19 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var unwrappedType = type; - while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* ParenthesizedType */) { + while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* SyntaxKind.ParenthesizedType */) { unwrappedType = unwrappedType.type; // Skip parens if need be } var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType); - if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* SyntaxKind.EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* SyntaxKind.OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = (lastToken === 38 /* SyntaxKind.EqualsGreaterThanToken */ || lastToken === 18 /* SyntaxKind.OpenBraceToken */) ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction) : parseIdentifier(); // Given: @@ -35137,7 +35263,7 @@ var ts; // Then allow the arrow function, and treat the second colon as terminating // the conditional expression. It's okay to do this because this code would // be a syntax error in JavaScript (as the second colon shouldn't be there). - if (token() !== 58 /* ColonToken */) { + if (token() !== 58 /* SyntaxKind.ColonToken */) { return undefined; } } @@ -35145,12 +35271,12 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) { - if (token() === 18 /* OpenBraceToken */) { - return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { + return parseFunctionBlock(isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */); } - if (token() !== 26 /* SemicolonToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && + if (token() !== 26 /* SyntaxKind.SemicolonToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -35167,7 +35293,7 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error. - return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */)); + return parseFunctionBlock(16 /* SignatureFlags.IgnoreMissingOpenBrace */ | (isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */)); } var savedTopLevel = topLevel; topLevel = false; @@ -35179,16 +35305,16 @@ var ts; } function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* SyntaxKind.ColonToken */), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) - : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -35196,7 +35322,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 101 /* InKeyword */ || t === 160 /* OfKeyword */; + return t === 101 /* SyntaxKind.InKeyword */ || t === 160 /* SyntaxKind.OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -35225,16 +35351,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 101 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* SyntaxKind.InKeyword */ && inDisallowInContext()) { break; } - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -35255,7 +35381,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 101 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* SyntaxKind.InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -35283,7 +35409,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 132 /* AwaitKeyword */) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -35316,7 +35442,7 @@ var ts; if (isUpdateExpression()) { var pos = getNodePos(); var updateExpression = parseUpdateExpression(); - return token() === 42 /* AsteriskAsteriskToken */ ? + return token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) : updateExpression; } @@ -35333,10 +35459,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 42 /* AsteriskAsteriskToken */) { + if (token() === 42 /* SyntaxKind.AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 211 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -35361,23 +35487,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parsePrefixUnaryExpression(); - case 89 /* DeleteKeyword */: + case 89 /* SyntaxKind.DeleteKeyword */: return parseDeleteExpression(); - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return parseTypeOfExpression(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseVoidExpression(); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 132 /* AwaitKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -35400,18 +35526,18 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 132 /* AwaitKeyword */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: return false; - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (languageVariant !== 1 /* JSX */) { + if (languageVariant !== 1 /* LanguageVariant.JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. @@ -35432,17 +35558,17 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + if (token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) { var pos = getNodePos(); return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos); } - else if (languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (languageVariant === 1 /* LanguageVariant.JSX */ && token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { var operator = token(); nextToken(); return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos); @@ -35483,29 +35609,29 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 100 /* ImportKeyword */) { + if (token() === 100 /* SyntaxKind.ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); - sourceFlags |= 4194304 /* PossiblyContainsImportMeta */; + expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos); + sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression or OptionalExpression. As such, we need to consume the rest @@ -35567,19 +35693,22 @@ var ts; function parseSuperExpression() { var pos = getNodePos(); var expression = parseTokenNode(); - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); + if (!isTemplateStartOfTaggedTemplate()) { + expression = factory.createExpressionWithTypeArguments(expression, typeArguments); + } } } - if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 24 /* SyntaxKind.DotToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* SyntaxKind.DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); // private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } @@ -35587,11 +35716,11 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 280 /* JsxOpeningElement */) { + if (opening.kind === 280 /* SyntaxKind.JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = void 0; var lastChild = children[children.length - 1]; - if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* JsxElement */ + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, @@ -35617,11 +35746,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 283 /* JsxOpeningFragment */) { + else if (opening.kind === 283 /* SyntaxKind.JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 279 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 279 /* SyntaxKind.JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -35632,11 +35761,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 29 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* SyntaxKind.LessThanToken */) { var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos_1); }); if (invalidElement) { - var operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false); + var operatorToken = createMissingNode(27 /* SyntaxKind.CommaToken */, /*reportAtCurrentPosition*/ false); ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0); parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element); return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos); @@ -35646,13 +35775,13 @@ var ts; } function parseJsxText() { var pos = getNodePos(); - var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* JsxTextAllWhiteSpaces */); + var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* SyntaxKind.JsxTextAllWhiteSpaces */); currentToken = scanner.scanJsxToken(); return finishNode(node, pos); } function parseJsxChild(openingTag, token) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // If we hit EOF, issue the error at the tag that lacks the closing element // rather than at the end of the file (which is useless) if (ts.isJsxOpeningFragment(openingTag)) { @@ -35666,15 +35795,15 @@ var ts; parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 30 /* LessThanSlashToken */: - case 7 /* ConflictMarkerTrivia */: + case 30 /* SyntaxKind.LessThanSlashToken */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: return undefined; - case 11 /* JsxText */: - case 12 /* JsxTextAllWhiteSpaces */: + case 11 /* SyntaxKind.JsxText */: + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return parseJsxText(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); @@ -35684,14 +35813,14 @@ var ts; var list = []; var listPos = getNodePos(); var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; + parsingContext |= 1 << 14 /* ParsingContext.JsxChildren */; while (true) { var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken()); if (!child) break; list.push(child); if (ts.isJsxOpeningElement(openingTag) - && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* JsxElement */ + && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { // stop after parsing a mismatched child like
...(
) in order to reattach the
higher @@ -35703,21 +35832,21 @@ var ts; } function parseJsxAttributes() { var pos = getNodePos(); - return finishNode(factory.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos); + return finishNode(factory.createJsxAttributes(parseList(13 /* ParsingContext.JsxAttributes */, parseJsxAttribute)), pos); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); - if (token() === 31 /* GreaterThanToken */) { + parseExpected(29 /* SyntaxKind.LessThanToken */); + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // See below for explanation of scanJsxText scanJsxText(); return finishNode(factory.createJsxOpeningFragment(), pos); } var tagName = parseJsxElementName(); - var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; + var typeArguments = (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; var attributes = parseJsxAttributes(); var node; - if (token() === 31 /* GreaterThanToken */) { + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors @@ -35725,8 +35854,8 @@ var ts; node = factory.createJsxOpeningElement(tagName, typeArguments, attributes); } else { - parseExpected(43 /* SlashToken */); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + parseExpected(43 /* SyntaxKind.SlashToken */); + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35747,39 +35876,39 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 108 /* ThisKeyword */ ? + var expression = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); } return expression; } function parseJsxExpression(inExpressionContext) { var pos = getNodePos(); - if (!parseExpected(18 /* OpenBraceToken */)) { + if (!parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { return undefined; } var dotDotDotToken; var expression; - if (token() !== 19 /* CloseBraceToken */) { - dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + if (token() !== 19 /* SyntaxKind.CloseBraceToken */) { + dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); // Only an AssignmentExpression is valid here per the JSX spec, // but we can unambiguously parse a comma sequence and provide // a better error message in grammar checking. expression = parseExpression(); } if (inExpressionContext) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { - if (parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(19 /* SyntaxKind.CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { scanJsxText(); } } return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos); } function parseJsxAttribute() { - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); @@ -35787,14 +35916,14 @@ var ts; return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos); } function parseJsxAttributeValue() { - if (token() === 63 /* EqualsToken */) { - if (scanJsxAttributeValue() === 10 /* StringLiteral */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { + if (scanJsxAttributeValue() === 10 /* SyntaxKind.StringLiteral */) { return parseLiteralNode(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxExpression(/*inExpressionContext*/ true); } - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } parseErrorAtCurrentToken(ts.Diagnostics.or_JSX_element_expected); @@ -35803,17 +35932,17 @@ var ts; } function parseJsxSpreadAttribute() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - parseExpected(25 /* DotDotDotToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseExpression(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); var tagName = parseJsxElementName(); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { nextToken(); @@ -35826,11 +35955,11 @@ var ts; } function parseJsxClosingFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35843,36 +35972,36 @@ var ts; } function parseTypeAssertion() { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); + parseExpected(29 /* SyntaxKind.LessThanToken */); var type = parseType(); - parseExpected(31 /* GreaterThanToken */); + parseExpected(31 /* SyntaxKind.GreaterThanToken */); var expression = parseSimpleUnaryExpression(); return finishNode(factory.createTypeAssertion(type, expression), pos); } function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) - || token() === 22 /* OpenBracketToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ || isTemplateStartOfTaggedTemplate(); } function isStartOfOptionalPropertyOrElementAccessChain() { - return token() === 28 /* QuestionDotToken */ + return token() === 28 /* SyntaxKind.QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); } function tryReparseOptionalChain(node) { - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { return true; } // check for an optional chain in a non-null expression if (ts.isNonNullExpression(node)) { var expr = node.expression; - while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) { + while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* NodeFlags.OptionalChain */)) { expr = expr.expression; } - if (expr.flags & 32 /* OptionalChain */) { + if (expr.flags & 32 /* NodeFlags.OptionalChain */) { // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. while (ts.isNonNullExpression(node)) { - node.flags |= 32 /* OptionalChain */; + node.flags |= 32 /* NodeFlags.OptionalChain */; node = node.expression; } return true; @@ -35889,12 +36018,17 @@ var ts; if (isOptionalChain && ts.isPrivateIdentifier(propertyAccess.name)) { parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers); } + if (ts.isExpressionWithTypeArguments(expression) && expression.typeArguments) { + var pos_2 = expression.typeArguments.pos - 1; + var end = ts.skipTrivia(sourceText, expression.typeArguments.end) + 1; + parseErrorAt(pos_2, end, ts.Diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access); + } return finishNode(propertyAccess, pos); } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; - if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* SyntaxKind.CloseBracketToken */) { + argumentExpression = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -35903,7 +36037,7 @@ var ts; } argumentExpression = argument; } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ? factory.createElementAccessChain(expression, questionDotToken, argumentExpression) : factory.createElementAccessExpression(expression, argumentExpression); @@ -35914,30 +36048,30 @@ var ts; var questionDotToken = void 0; var isPropertyAccess = false; if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { - questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + questionDotToken = parseExpectedToken(28 /* SyntaxKind.QuestionDotToken */); isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); } else { - isPropertyAccess = parseOptional(24 /* DotToken */); + isPropertyAccess = parseOptional(24 /* SyntaxKind.DotToken */); } if (isPropertyAccess) { expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { expression = parseElementAccessExpressionRest(pos, expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments - expression = !questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */ ? + expression = !questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) : parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined); continue; } if (!questionDotToken) { - if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); expression = finishNode(factory.createNonNullExpression(expression), pos); continue; @@ -35952,14 +36086,14 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; + return token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || token() === 15 /* SyntaxKind.TemplateHead */; } function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) { - var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* NoSubstitutionTemplateLiteral */ ? + var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(/*isTaggedTemplate*/ true)); - if (questionDotToken || tag.flags & 32 /* OptionalChain */) { - tagExpression.flags |= 32 /* OptionalChain */; + if (questionDotToken || tag.flags & 32 /* NodeFlags.OptionalChain */) { + tagExpression.flags |= 32 /* NodeFlags.OptionalChain */; } tagExpression.questionDotToken = questionDotToken; return finishNode(tagExpression, pos); @@ -35968,7 +36102,7 @@ var ts; while (true) { expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true); var typeArguments = void 0; - var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); + var questionDotToken = parseOptionalToken(28 /* SyntaxKind.QuestionDotToken */); if (questionDotToken) { typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { @@ -35976,9 +36110,9 @@ var ts; continue; } } - if (typeArguments || token() === 20 /* OpenParenToken */) { + if (typeArguments || token() === 20 /* SyntaxKind.OpenParenToken */) { // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments - if (!questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (!questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } @@ -35991,7 +36125,7 @@ var ts; } if (questionDotToken) { // We parsed `?.` but then failed to parse anything, so report a missing identifier here. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -35999,22 +36133,22 @@ var ts; return expression; } function parseArgumentList() { - parseExpected(20 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); + var result = parseDelimitedList(11 /* ParsingContext.ArgumentExpressions */, parseArgumentExpression); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) { + if ((contextFlags & 262144 /* NodeFlags.JavaScriptFile */) !== 0) { // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators. return undefined; } - if (reScanLessThanToken() !== 29 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* SyntaxKind.LessThanToken */) { return undefined; } nextToken(); - var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (reScanGreaterToken() !== 31 /* GreaterThanToken */) { + var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType); + if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -36028,17 +36162,17 @@ var ts; function canFollowTypeArgumentsInExpression() { switch (token()) { // These tokens can follow a type argument list in a call expression. - case 20 /* OpenParenToken */: // foo( - case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 15 /* TemplateHead */: // foo `...${100}...` + case 20 /* SyntaxKind.OpenParenToken */: // foo( + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* SyntaxKind.TemplateHead */: // foo `...${100}...` return true; // A type argument list followed by `<` never makes sense, and a type argument list followed // by `>` is ambiguous with a (re-scanned) `>>` operator, so we disqualify both. Also, in // this context, `+` and `-` are unary operators, not binary operators. - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: return false; } // We favor the type argument list interpretation when it is immediately followed by @@ -36047,24 +36181,24 @@ var ts; } function parsePrimaryExpression() { switch (token()) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return parseTokenNode(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedExpression(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseArrayLiteralExpression(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseObjectLiteralExpression(); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -36072,21 +36206,21 @@ var ts; break; } return parseFunctionExpression(); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassExpression(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionExpression(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateExpression(/* isTaggedTemplate */ false); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return parsePrivateIdentifier(); } return parseIdentifier(ts.Diagnostics.Expression_expected); @@ -36094,20 +36228,20 @@ var ts; function parseParenthesizedExpression() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc); } function parseSpreadElement() { var pos = getNodePos(); - parseExpected(25 /* DotDotDotToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { - return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : + return token() === 25 /* SyntaxKind.DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* SyntaxKind.CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); } function parseArgumentExpression() { @@ -36116,34 +36250,34 @@ var ts; function parseArrayLiteralExpression() { var pos = getNodePos(); var openBracketPosition = scanner.getTokenPos(); - var openBracketParsed = parseExpected(22 /* OpenBracketToken */); + var openBracketParsed = parseExpected(22 /* SyntaxKind.OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition); + var elements = parseDelimitedList(15 /* ParsingContext.ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpectedMatchingBrackets(22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, openBracketParsed, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (parseOptionalToken(25 /* DotDotDotToken */)) { + if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) { var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */, 0 /* SignatureFlags.None */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */, 0 /* SignatureFlags.None */); } - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - var exclamationToken = parseOptionalToken(53 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken); } // check if it is short-hand property assignment or normal property assignment @@ -36152,9 +36286,9 @@ var ts; // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var node; - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(63 /* EqualsToken */); + var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */); var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. @@ -36162,7 +36296,7 @@ var ts; node.equalsToken = equalsToken; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }); node = factory.createPropertyAssignment(name, initializer); } @@ -36176,10 +36310,10 @@ var ts; function parseObjectLiteralExpression() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var properties = parseDelimitedList(12 /* ParsingContext.ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -36193,17 +36327,17 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : parseOptionalBindingIdentifier(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlock(isGenerator | isAsync); setDecoratorContext(savedDecoratorContext); var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -36214,23 +36348,23 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(103 /* NewKeyword */); - if (parseOptional(24 /* DotToken */)) { + parseExpected(103 /* SyntaxKind.NewKeyword */); + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* SyntaxKind.NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false); var typeArguments; // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } - if (token() === 28 /* QuestionDotToken */) { + if (token() === 28 /* SyntaxKind.QuestionDotToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, ts.getTextOfNodeFromSourceText(sourceText, expression)); } - var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined; + var argumentList = token() === 20 /* SyntaxKind.OpenParenToken */ ? parseArgumentList() : undefined; return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos); } // STATEMENTS @@ -36238,13 +36372,13 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */, diagnosticMessage); if (openBraceParsed || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); - var statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); nextToken(); } @@ -36257,9 +36391,9 @@ var ts; } function parseFunctionBlock(flags, diagnosticMessage) { var savedYieldContext = inYieldContext(); - setYieldContext(!!(flags & 1 /* Yield */)); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); var savedAwaitContext = inAwaitContext(); - setAwaitContext(!!(flags & 2 /* Await */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); var savedTopLevel = topLevel; topLevel = false; // We may be in a [Decorator] context when parsing a function expression or @@ -36268,7 +36402,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage); + var block = parseBlock(!!(flags & 16 /* SignatureFlags.IgnoreMissingOpenBrace */), diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -36280,58 +36414,58 @@ var ts; function parseEmptyStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(26 /* SemicolonToken */); + parseExpected(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(99 /* IfKeyword */); + parseExpected(99 /* SyntaxKind.IfKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var thenStatement = parseStatement(); - var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + var elseStatement = parseOptional(91 /* SyntaxKind.ElseKeyword */) ? parseStatement() : undefined; return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(90 /* DoKeyword */); + parseExpected(90 /* SyntaxKind.DoKeyword */); var statement = parseStatement(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(26 /* SemicolonToken */); + parseOptional(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var statement = parseStatement(); return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(97 /* ForKeyword */); - var awaitToken = parseOptionalToken(132 /* AwaitKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(97 /* SyntaxKind.ForKeyword */); + var awaitToken = parseOptionalToken(132 /* SyntaxKind.AwaitKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var initializer; - if (token() !== 26 /* SemicolonToken */) { - if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { + if (token() !== 26 /* SyntaxKind.SemicolonToken */) { + if (token() === 113 /* SyntaxKind.VarKeyword */ || token() === 119 /* SyntaxKind.LetKeyword */ || token() === 85 /* SyntaxKind.ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -36339,26 +36473,26 @@ var ts; } } var node; - if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) { + if (awaitToken ? parseExpected(160 /* SyntaxKind.OfKeyword */) : parseOptional(160 /* SyntaxKind.OfKeyword */)) { var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(101 /* InKeyword */)) { + else if (parseOptional(101 /* SyntaxKind.InKeyword */)) { var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); } else { - parseExpected(26 /* SemicolonToken */); - var condition = token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var condition = token() !== 26 /* SyntaxKind.SemicolonToken */ && token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(26 /* SemicolonToken */); - var incrementor = token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var incrementor = token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36366,10 +36500,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 246 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); + parseExpected(kind === 246 /* SyntaxKind.BreakStatement */ ? 81 /* SyntaxKind.BreakKeyword */ : 86 /* SyntaxKind.ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 246 /* BreakStatement */ + var node = kind === 246 /* SyntaxKind.BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36377,7 +36511,7 @@ var ts; function parseReturnStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(105 /* ReturnKeyword */); + parseExpected(105 /* SyntaxKind.ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); @@ -36385,47 +36519,47 @@ var ts; function parseWithStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(116 /* WithKeyword */); + parseExpected(116 /* SyntaxKind.WithKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); - var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); + var statement = doInsideOfContext(33554432 /* NodeFlags.InWithStatement */, parseStatement); return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(82 /* CaseKeyword */); + parseExpected(82 /* SyntaxKind.CaseKeyword */); var expression = allowInAnd(parseExpression); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc); } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(88 /* DefaultKeyword */); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* SyntaxKind.CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var clauses = parseList(2 /* ParsingContext.SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createCaseBlock(clauses), pos); } function parseSwitchStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(107 /* SwitchKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(107 /* SyntaxKind.SwitchKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); var caseBlock = parseCaseBlock(); return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } @@ -36434,7 +36568,7 @@ var ts; // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(109 /* ThrowKeyword */); + parseExpected(109 /* SyntaxKind.ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' // directly as that might consume an expression on the following line. @@ -36454,25 +36588,25 @@ var ts; function parseTryStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(111 /* TryKeyword */); + parseExpected(111 /* SyntaxKind.TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 83 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* SyntaxKind.CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. var finallyBlock; - if (!catchClause || token() === 96 /* FinallyKeyword */) { - parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); + if (!catchClause || token() === 96 /* SyntaxKind.FinallyKeyword */) { + parseExpected(96 /* SyntaxKind.FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(83 /* CatchKeyword */); + parseExpected(83 /* SyntaxKind.CatchKeyword */); var variableDeclaration; - if (parseOptional(20 /* OpenParenToken */)) { + if (parseOptional(20 /* SyntaxKind.OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -36484,7 +36618,7 @@ var ts; function parseDebuggerStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(87 /* DebuggerKeyword */); + parseExpected(87 /* SyntaxKind.DebuggerKeyword */); parseSemicolon(); return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } @@ -36495,9 +36629,9 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var node; - var hasParen = token() === 20 /* OpenParenToken */; + var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */; var expression = allowInAnd(parseExpression); - if (ts.isIdentifier(expression) && parseOptional(58 /* ColonToken */)) { + if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) { node = factory.createLabeledStatement(expression, parseStatement()); } else { @@ -36518,25 +36652,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* SyntaxKind.ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* SyntaxKind.FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */ || token() === 10 /* SyntaxKind.StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -36559,44 +36693,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 157 /* GlobalKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; - case 100 /* ImportKeyword */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 79 /* SyntaxKind.Identifier */ || token() === 93 /* SyntaxKind.ExportKeyword */; + case 100 /* SyntaxKind.ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 93 /* ExportKeyword */: + return token() === 10 /* SyntaxKind.StringLiteral */ || token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 18 /* SyntaxKind.OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 93 /* SyntaxKind.ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 152 /* TypeKeyword */) { + if (currentToken_1 === 152 /* SyntaxKind.TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || - currentToken_1 === 127 /* AsKeyword */) { + if (currentToken_1 === 63 /* SyntaxKind.EqualsToken */ || currentToken_1 === 41 /* SyntaxKind.AsteriskToken */ || + currentToken_1 === 18 /* SyntaxKind.OpenBraceToken */ || currentToken_1 === 88 /* SyntaxKind.DefaultKeyword */ || + currentToken_1 === 127 /* SyntaxKind.AsKeyword */) { return true; } continue; - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: nextToken(); continue; default: @@ -36609,51 +36743,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 59 /* AtToken */: - case 26 /* SemicolonToken */: - case 18 /* OpenBraceToken */: - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 99 /* IfKeyword */: - case 90 /* DoKeyword */: - case 115 /* WhileKeyword */: - case 97 /* ForKeyword */: - case 86 /* ContinueKeyword */: - case 81 /* BreakKeyword */: - case 105 /* ReturnKeyword */: - case 116 /* WithKeyword */: - case 107 /* SwitchKeyword */: - case 109 /* ThrowKeyword */: - case 111 /* TryKeyword */: - case 87 /* DebuggerKeyword */: + case 59 /* SyntaxKind.AtToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 90 /* SyntaxKind.DoKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: + case 116 /* SyntaxKind.WithKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: + case 111 /* SyntaxKind.TryKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 85 /* ConstKeyword */: - case 93 /* ExportKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return isStartOfDeclaration(); - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 118 /* InterfaceKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 152 /* TypeKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -36663,7 +36797,7 @@ var ts; } function nextTokenIsBindingIdentifierOrStartOfDestructuring() { nextToken(); - return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; + return isBindingIdentifier() || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -36672,68 +36806,68 @@ var ts; } function parseStatement() { switch (token()) { - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: return parseEmptyStatement(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 119 /* LetKeyword */: + case 119 /* SyntaxKind.LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 99 /* IfKeyword */: + case 99 /* SyntaxKind.IfKeyword */: return parseIfStatement(); - case 90 /* DoKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return parseDoStatement(); - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return parseWhileStatement(); - case 97 /* ForKeyword */: + case 97 /* SyntaxKind.ForKeyword */: return parseForOrForInOrForOfStatement(); - case 86 /* ContinueKeyword */: - return parseBreakOrContinueStatement(245 /* ContinueStatement */); - case 81 /* BreakKeyword */: - return parseBreakOrContinueStatement(246 /* BreakStatement */); - case 105 /* ReturnKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + return parseBreakOrContinueStatement(245 /* SyntaxKind.ContinueStatement */); + case 81 /* SyntaxKind.BreakKeyword */: + return parseBreakOrContinueStatement(246 /* SyntaxKind.BreakStatement */); + case 105 /* SyntaxKind.ReturnKeyword */: return parseReturnStatement(); - case 116 /* WithKeyword */: + case 116 /* SyntaxKind.WithKeyword */: return parseWithStatement(); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return parseSwitchStatement(); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return parseThrowStatement(); - case 111 /* TryKeyword */: + case 111 /* SyntaxKind.TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return parseTryStatement(); - case 87 /* DebuggerKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: return parseDebuggerStatement(); - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: return parseDeclaration(); - case 131 /* AsyncKeyword */: - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 92 /* EnumKeyword */: - case 93 /* ExportKeyword */: - case 100 /* ImportKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 126 /* AbstractKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -36742,40 +36876,35 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 135 /* DeclareKeyword */; + return modifier.kind === 135 /* SyntaxKind.DeclareKeyword */; } function parseDeclaration() { - // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner - // if we can't reuse the declaration, so that we don't do this work twice? - // // `parseListElement` attempted to get the reused node at this position, // but the ambient context flag was not yet set, so the node appeared // not reusable in that context. - var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier); - if (isAmbient) { - var node = tryReuseAmbientDeclaration(); - if (node) { - return node; - } - } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(); + var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { + var node = tryReuseAmbientDeclaration(pos); + if (node) { + return node; + } for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); } else { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } - function tryReuseAmbientDeclaration() { - return doInsideOfContext(16777216 /* Ambient */, function () { - var node = currentNode(parsingContext); + function tryReuseAmbientDeclaration(pos) { + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { + var node = currentNode(parsingContext, pos); if (node) { return consumeNode(node); } @@ -36783,33 +36912,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 118 /* InterfaceKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* EnumKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 157 /* GlobalKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); switch (token()) { - case 88 /* DefaultKeyword */: - case 63 /* EqualsToken */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 63 /* SyntaxKind.EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 127 /* AsKeyword */: + case 127 /* SyntaxKind.AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36818,7 +36947,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(276 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -36829,38 +36958,44 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { - parseSemicolon(); - return; + if (token() !== 18 /* SyntaxKind.OpenBraceToken */) { + if (flags & 4 /* SignatureFlags.Type */) { + parseTypeMemberSemicolon(); + return; + } + if (canParseSemicolon()) { + parseSemicolon(); + return; + } } return parseFunctionBlock(flags, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { var pos = getNodePos(); - if (token() === 27 /* CommaToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */) { return finishNode(factory.createOmittedExpression(), pos); } - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierOrPattern(); var initializer = parseInitializer(); return finishNode(factory.createBindingElement(dotDotDotToken, /*propertyName*/ undefined, name, initializer), pos); } function parseObjectBindingElement() { var pos = getNodePos(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var tokenIsIdentifier = isBindingIdentifier(); var propertyName = parsePropertyName(); var name; - if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* SyntaxKind.ColonToken */) { name = propertyName; propertyName = undefined; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); name = parseIdentifierOrPattern(); } var initializer = parseInitializer(); @@ -36868,29 +37003,29 @@ var ts; } function parseObjectBindingPattern() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var elements = parseDelimitedList(9 /* ParsingContext.ObjectBindingElements */, parseObjectBindingElement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createObjectBindingPattern(elements), pos); } function parseArrayBindingPattern() { var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); - var elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(23 /* CloseBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); + var elements = parseDelimitedList(10 /* ParsingContext.ArrayBindingElements */, parseArrayBindingElement); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createArrayBindingPattern(elements), pos); } function isBindingIdentifierOrPrivateIdentifierOrPattern() { - return token() === 18 /* OpenBraceToken */ - || token() === 22 /* OpenBracketToken */ - || token() === 80 /* PrivateIdentifier */ + return token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 80 /* SyntaxKind.PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseObjectBindingPattern(); } return parseBindingIdentifier(privateIdentifierDiagnosticMessage); @@ -36903,8 +37038,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 79 /* Identifier */ && - token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && name.kind === 79 /* SyntaxKind.Identifier */ && + token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); @@ -36916,13 +37051,13 @@ var ts; var pos = getNodePos(); var flags = 0; switch (token()) { - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: break; - case 119 /* LetKeyword */: - flags |= 1 /* Let */; + case 119 /* SyntaxKind.LetKeyword */: + flags |= 1 /* NodeFlags.Let */; break; - case 85 /* ConstKeyword */: - flags |= 2 /* Const */; + case 85 /* SyntaxKind.ConstKeyword */: + flags |= 2 /* NodeFlags.Const */; break; default: ts.Debug.fail(); @@ -36938,19 +37073,19 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 160 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 160 /* SyntaxKind.OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); + declarations = parseDelimitedList(8 /* ParsingContext.VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); setDisallowInContext(savedDisallowIn); } return finishNode(factory.createVariableDeclarationList(declarations, flags), pos); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* SyntaxKind.CloseParenToken */; } function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) { var declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -36963,17 +37098,17 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. - var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */; + var name = modifierFlags & 512 /* ModifierFlags.Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = modifierFlags & 256 /* ModifierFlags.Async */ ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 1 /* ModifierFlags.Export */) setAwaitContext(/*value*/ true); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); setAwaitContext(savedAwaitContext); var node = factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -36981,10 +37116,10 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 134 /* ConstructorKeyword */) { - return parseExpected(134 /* ConstructorKeyword */); + if (token() === 134 /* SyntaxKind.ConstructorKeyword */) { + return parseExpected(134 /* SyntaxKind.ConstructorKeyword */); } - if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ && lookAhead(nextToken) === 20 /* SyntaxKind.OpenParenToken */) { return tryParse(function () { var literalNode = parseLiteralNode(); return literalNode.text === "constructor" ? literalNode : undefined; @@ -36995,9 +37130,9 @@ var ts; return tryParse(function () { if (parseConstructorName()) { var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */, ts.Diagnostics.or_expected); var node = factory.createConstructorDeclaration(modifiers, parameters, body); // Attach invalid nodes if they exist so that we can report them in the grammar checker. node.decorators = decorators; @@ -37008,11 +37143,11 @@ var ts; }); } function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) { - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); var node = factory.createMethodDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body); // An exclamation token on a method is invalid syntax and will be handled by the grammar checker @@ -37020,31 +37155,31 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) { - var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined; + var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* SyntaxKind.ExclamationToken */) : undefined; var type = parseTypeAnnotation(); - var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer); + var initializer = doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */ | 4096 /* NodeFlags.DisallowInContext */, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); var node = factory.createPropertyDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) { - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, /*exclamationToken*/ undefined, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); } - function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { + function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 172 /* GetAccessor */ + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(flags); + var node = kind === 172 /* SyntaxKind.GetAccessor */ ? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body) : factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors @@ -37055,7 +37190,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 59 /* AtToken */) { + if (token() === 59 /* SyntaxKind.AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -37072,7 +37207,7 @@ var ts; } nextToken(); } - if (token() === 41 /* AsteriskToken */) { + if (token() === 41 /* SyntaxKind.AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -37082,24 +37217,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 149 /* SetKeyword */ || idToken === 136 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 149 /* SyntaxKind.SetKeyword */ || idToken === 136 /* SyntaxKind.GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 20 /* OpenParenToken */: // Method declaration - case 29 /* LessThanToken */: // Generic Method declaration - case 53 /* ExclamationToken */: // Non-null assertion on property name - case 58 /* ColonToken */: // Type Annotation for declaration - case 63 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* SyntaxKind.OpenParenToken */: // Method declaration + case 29 /* SyntaxKind.LessThanToken */: // Generic Method declaration + case 53 /* SyntaxKind.ExclamationToken */: // Non-null assertion on property name + case 58 /* SyntaxKind.ColonToken */: // Type Annotation for declaration + case 63 /* SyntaxKind.EqualsToken */: // Initializer for declaration + case 57 /* SyntaxKind.QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -37113,7 +37248,7 @@ var ts; return false; } function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpectedToken(124 /* StaticKeyword */); + parseExpectedToken(124 /* SyntaxKind.StaticKeyword */); var body = parseClassStaticBlockBody(); var node = withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(body), pos), hasJSDoc); node.decorators = decorators; @@ -37131,7 +37266,7 @@ var ts; return body; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 132 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 132 /* SyntaxKind.AwaitKeyword */) { // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails // This simply parses the missing identifier and moves on. var pos = getNodePos(); @@ -37144,7 +37279,7 @@ var ts; } function tryParseDecorator() { var pos = getNodePos(); - if (!parseOptional(59 /* AtToken */)) { + if (!parseOptional(59 /* SyntaxKind.AtToken */)) { return undefined; } var expression = doInDecoratorContext(parseDecoratorExpression); @@ -37161,17 +37296,17 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } } - else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return undefined; } - else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) { + else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) { return undefined; } else { @@ -37201,7 +37336,7 @@ var ts; var pos = getNodePos(); var list, modifier, hasSeenStatic = false; while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) { - if (modifier.kind === 124 /* StaticKeyword */) + if (modifier.kind === 124 /* SyntaxKind.StaticKeyword */) hasSeenStatic = true; list = ts.append(list, modifier); } @@ -37209,33 +37344,33 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(131 /* SyntaxKind.AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; } function parseClassElement() { var pos = getNodePos(); - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { nextToken(); return finishNode(factory.createSemicolonClassElement(), pos); } var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true); - if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */, 0 /* SignatureFlags.None */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */, 0 /* SignatureFlags.None */); } - if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -37247,17 +37382,17 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */ || - token() === 41 /* AsteriskToken */ || - token() === 22 /* OpenBracketToken */) { + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */ || + token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 22 /* SyntaxKind.OpenBracketToken */) { var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); } else { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -37265,21 +37400,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* SyntaxKind.ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(84 /* ClassKeyword */); + parseExpected(84 /* SyntaxKind.ClassKeyword */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); @@ -37287,17 +37422,17 @@ var ts; setAwaitContext(/*value*/ true); var heritageClauses = parseHeritageClauses(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } members = parseClassMembers(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 257 /* ClassDeclaration */ + var node = kind === 257 /* SyntaxKind.ClassDeclaration */ ? factory.createClassDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members) : factory.createClassExpression(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -37313,45 +37448,45 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* SyntaxKind.ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(22 /* HeritageClauses */, parseHeritageClause); + return parseList(22 /* ParsingContext.HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* SyntaxKind.ExtendsKeyword */ || tok === 117 /* SyntaxKind.ImplementsKeyword */); // isListElement() should ensure this. nextToken(); - var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + var types = parseDelimitedList(7 /* ParsingContext.HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); } function parseExpressionWithTypeArguments() { var pos = getNodePos(); var expression = parseLeftHandSideExpressionOrHigher(); - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { return expression; } var typeArguments = tryParseTypeArguments(); return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos); } function tryParseTypeArguments() { - return token() === 29 /* LessThanToken */ ? - parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; + return token() === 29 /* SyntaxKind.LessThanToken */ ? + parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; + return token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; } function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); + return parseList(5 /* ParsingContext.ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(118 /* InterfaceKeyword */); + parseExpected(118 /* SyntaxKind.InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -37361,11 +37496,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(152 /* TypeKeyword */); + parseExpected(152 /* SyntaxKind.TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(63 /* EqualsToken */); - var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* SyntaxKind.EqualsToken */); + var type = token() === 138 /* SyntaxKind.IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(modifiers, name, typeParameters, type); node.decorators = decorators; @@ -37383,12 +37518,12 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(92 /* EnumKeyword */); + parseExpected(92 /* SyntaxKind.EnumKeyword */); var name = parseIdentifier(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* EnumMembers */, parseEnumMember); }); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* ParsingContext.EnumMembers */, parseEnumMember); }); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -37400,9 +37535,9 @@ var ts; function parseModuleBlock() { var pos = getNodePos(); var statements; - if (parseExpected(18 /* OpenBraceToken */)) { - statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { statements = createMissingList(); @@ -37412,10 +37547,10 @@ var ts; function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) { // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 16 /* Namespace */; + var namespaceFlag = flags & 16 /* NodeFlags.Namespace */; var name = parseIdentifier(); - var body = parseOptional(24 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) + var body = parseOptional(24 /* SyntaxKind.DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NodeFlags.NestedNamespace */ | namespaceFlag) : parseModuleBlock(); var node = factory.createModuleDeclaration(modifiers, name, body, flags); node.decorators = decorators; @@ -37424,17 +37559,17 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); - flags |= 1024 /* GlobalAugmentation */; + flags |= 1024 /* NodeFlags.GlobalAugmentation */; } else { name = parseLiteralNode(); name.text = internIdentifier(name.text); } var body; - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { body = parseModuleBlock(); } else { @@ -37446,37 +37581,37 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(142 /* NamespaceKeyword */)) { - flags |= 16 /* Namespace */; + else if (parseOptional(142 /* SyntaxKind.NamespaceKeyword */)) { + flags |= 16 /* NodeFlags.Namespace */; } else { - parseExpected(141 /* ModuleKeyword */); - if (token() === 10 /* StringLiteral */) { + parseExpected(141 /* SyntaxKind.ModuleKeyword */); + if (token() === 10 /* SyntaxKind.StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 146 /* RequireKeyword */ && + return token() === 146 /* SyntaxKind.RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 20 /* OpenParenToken */; + return nextToken() === 20 /* SyntaxKind.OpenParenToken */; } function nextTokenIsOpenBrace() { - return nextToken() === 18 /* OpenBraceToken */; + return nextToken() === 18 /* SyntaxKind.OpenBraceToken */; } function nextTokenIsSlash() { - return nextToken() === 43 /* SlashToken */; + return nextToken() === 43 /* SyntaxKind.SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(127 /* AsKeyword */); - parseExpected(142 /* NamespaceKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); + parseExpected(142 /* SyntaxKind.NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -37486,7 +37621,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(100 /* ImportKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); var afterImportPos = scanner.getStartPos(); // We don't parse the identifier here in await context, instead we will report a grammar error in the checker. var identifier; @@ -37494,7 +37629,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 156 /* FromKeyword */ && + if (token() !== 156 /* SyntaxKind.FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -37508,15 +37643,15 @@ var ts; // import ModuleSpecifier; var importClause; if (identifier || // import id - token() === 41 /* AsteriskToken */ || // import * - token() === 18 /* OpenBraceToken */ // import { + token() === 41 /* SyntaxKind.AsteriskToken */ || // import * + token() === 18 /* SyntaxKind.OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); var assertClause; - if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37526,21 +37661,21 @@ var ts; } function parseAssertEntry() { var pos = getNodePos(); - var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */); - parseExpected(58 /* ColonToken */); + var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* SyntaxKind.StringLiteral */); + parseExpected(58 /* SyntaxKind.ColonToken */); var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { var pos = getNodePos(); if (!skipAssertKeyword) { - parseExpected(129 /* AssertKeyword */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); } var openBracePosition = scanner.getTokenPos(); - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + var elements = parseDelimitedList(24 /* ParsingContext.AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -37554,15 +37689,15 @@ var ts; } } function tokenAfterImportDefinitelyProducesImportDeclaration() { - return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */; + return token() === 41 /* SyntaxKind.AsteriskToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 156 /* FromKeyword */; + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 156 /* SyntaxKind.FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(63 /* EqualsToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(modifiers, isTypeOnly, identifier, moduleReference); @@ -37581,8 +37716,8 @@ var ts; // parse namespace or named imports var namedBindings; if (!identifier || - parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* NamedImports */); + parseOptional(27 /* SyntaxKind.CommaToken */)) { + namedBindings = token() === 41 /* SyntaxKind.AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* SyntaxKind.NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -37593,14 +37728,14 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(146 /* RequireKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(146 /* SyntaxKind.RequireKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = parseModuleSpecifier(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createExternalModuleReference(expression), pos); } function parseModuleSpecifier() { - if (token() === 10 /* StringLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -37616,8 +37751,8 @@ var ts; // NameSpaceImport: // * as ImportedBinding var pos = getNodePos(); - parseExpected(41 /* AsteriskToken */); - parseExpected(127 /* AsKeyword */); + parseExpected(41 /* SyntaxKind.AsteriskToken */); + parseExpected(127 /* SyntaxKind.AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -37630,17 +37765,17 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 269 /* NamedImports */ - ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) - : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); + var node = kind === 269 /* SyntaxKind.NamedImports */ + ? factory.createNamedImports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)) + : factory.createNamedExports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { var hasJSDoc = hasPrecedingJSDocComment(); - return withJSDoc(parseImportOrExportSpecifier(275 /* ExportSpecifier */), hasJSDoc); + return withJSDoc(parseImportOrExportSpecifier(275 /* SyntaxKind.ExportSpecifier */), hasJSDoc); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(270 /* ImportSpecifier */); + return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -37665,10 +37800,10 @@ var ts; // import { type as } from "mod"; - isTypeOnly: true, name: as // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as ...? } var firstAs = parseIdentifierName(); - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as as ...? } var secondAs = parseIdentifierName(); if (ts.tokenIsIdentifierOrKeyword(token())) { @@ -37703,15 +37838,15 @@ var ts; name = parseNameWithKeywordCheck(); } } - if (canParseAsKeyword && token() === 127 /* AsKeyword */) { + if (canParseAsKeyword && token() === 127 /* SyntaxKind.AsKeyword */) { propertyName = name; - parseExpected(127 /* AsKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); name = parseNameWithKeywordCheck(); } - if (kind === 270 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 270 /* SyntaxKind.ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 270 /* ImportSpecifier */ + var node = kind === 270 /* SyntaxKind.ImportSpecifier */ ? factory.createImportSpecifier(isTypeOnly, propertyName, name) : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); @@ -37731,26 +37866,26 @@ var ts; var exportClause; var moduleSpecifier; var assertClause; - var isTypeOnly = parseOptional(152 /* TypeKeyword */); + var isTypeOnly = parseOptional(152 /* SyntaxKind.TypeKeyword */); var namespaceExportPos = getNodePos(); - if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(127 /* AsKeyword */)) { + if (parseOptional(41 /* SyntaxKind.AsteriskToken */)) { + if (parseOptional(127 /* SyntaxKind.AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(273 /* NamedExports */); + exportClause = parseNamedImportsOrExports(273 /* SyntaxKind.NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 156 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(156 /* FromKeyword */); + if (token() === 156 /* SyntaxKind.FromKeyword */ || (token() === 10 /* SyntaxKind.StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } - if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (moduleSpecifier && token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37763,11 +37898,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(63 /* EqualsToken */)) { + if (parseOptional(63 /* SyntaxKind.EqualsToken */)) { isExportEquals = true; } else { - parseExpected(88 /* DefaultKeyword */); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); } var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); parseSemicolon(); @@ -37814,11 +37949,11 @@ var ts; var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState("file.js", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); - var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop); + var sourceFile = createSourceFile("file.js", 99 /* ScriptTarget.Latest */, 1 /* ScriptKind.JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* SyntaxKind.EndOfFileToken */), 0 /* NodeFlags.None */, ts.noop); var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); if (jsDocDiagnostics) { sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile); @@ -37830,10 +37965,10 @@ var ts; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { var pos = getNodePos(); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* SyntaxKind.OpenBraceToken */); + var type = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocTypeExpression(type); fixupParentReferences(result); @@ -37842,16 +37977,16 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocNameReference() { var pos = getNodePos(); - var hasBrace = parseOptional(18 /* OpenBraceToken */); + var hasBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var p2 = getNodePos(); var entityName = parseEntityName(/* allowReservedWords*/ false); - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); } if (hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocNameReference(entityName); fixupParentReferences(result); @@ -37859,9 +37994,9 @@ var ts; } JSDocParser.parseJSDocNameReference = parseJSDocNameReference; function parseIsolatedJSDocComment(content, start, length) { - initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); - var sourceFile = { languageVariant: 0 /* Standard */, text: content }; + initializeState("", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); + var jsDoc = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var sourceFile = { languageVariant: 0 /* LanguageVariant.Standard */, text: content }; var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -37871,9 +38006,9 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); ts.setParent(comment, parent); - if (contextFlags & 262144 /* JavaScriptFile */) { + if (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) { if (!jsDocDiagnostics) { jsDocDiagnostics = []; } @@ -37921,7 +38056,7 @@ var ts; return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. - var state = 1 /* SawAsterisk */; + var state = 1 /* JSDocState.SawAsterisk */; var margin; // + 4 for leading '/** ' // + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character @@ -37934,16 +38069,16 @@ var ts; indent += text.length; } nextTokenJSDoc(); - while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + while (parseOptionalJsdoc(5 /* SyntaxKind.WhitespaceTrivia */)) ; - if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { - state = 0 /* BeginningOfLine */; + if (parseOptionalJsdoc(4 /* SyntaxKind.NewLineTrivia */)) { + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; } loop: while (true) { switch (token()) { - case 59 /* AtToken */: - if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { + case 59 /* SyntaxKind.AtToken */: + if (state === 0 /* JSDocState.BeginningOfLine */ || state === 1 /* JSDocState.SawAsterisk */) { removeTrailingWhitespace(comments); if (!commentsPos) commentsPos = getNodePos(); @@ -37951,35 +38086,35 @@ var ts; // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning // for malformed examples like `/** @param {string} x @returns {number} the length */` - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; margin = undefined; } else { pushComment(scanner.getTokenText()); } break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: comments.push(scanner.getTokenText()); - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: var asterisk = scanner.getTokenText(); - if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { + if (state === 1 /* JSDocState.SawAsterisk */ || state === 2 /* JSDocState.SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(asterisk); } else { // Ignore the first asterisk on a line - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += asterisk.length; } break; - case 5 /* WhitespaceTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // only collect whitespace if we're already saving comments or have just crossed the comment indent margin var whitespace = scanner.getTokenText(); - if (state === 2 /* SavingComments */) { + if (state === 2 /* JSDocState.SavingComments */) { comments.push(whitespace); } else if (margin !== undefined && indent + whitespace.length > margin) { @@ -37987,10 +38122,10 @@ var ts; } indent += whitespace.length; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -38009,7 +38144,7 @@ var ts; // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(scanner.getTokenText()); break; } @@ -38038,26 +38173,26 @@ var ts; // We must use infinite lookahead, as there could be any number of newlines :( while (true) { nextTokenJSDoc(); - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { return true; } - if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) { + if (!(token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */)) { return false; } } } function skipWhitespace() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } } - while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { nextTokenJSDoc(); } } function skipWhitespaceOrAsterisk() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return ""; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } @@ -38065,14 +38200,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* SyntaxKind.AsteriskToken */) || token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { indentText += scanner.getTokenText(); - if (token() === 4 /* NewLineTrivia */) { + if (token() === 4 /* SyntaxKind.NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 41 /* AsteriskToken */) { + else if (token() === 41 /* SyntaxKind.AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -38080,7 +38215,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -38129,7 +38264,7 @@ var ts; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, margin); + return parseParameterOrPropertyTag(start, tagName, 2 /* PropertyLikeParse.Parameter */, margin); case "return": case "returns": tag = parseReturnTag(start, tagName, margin, indentText); @@ -38167,7 +38302,7 @@ var ts; var comments = []; var parts = []; var linkEnd; - var state = 0 /* BeginningOfLine */; + var state = 0 /* JSDocState.BeginningOfLine */; var previousWhitespace = true; var margin; function pushComment(text) { @@ -38182,31 +38317,31 @@ var ts; if (initialMargin !== "") { pushComment(initialMargin); } - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; } var tok = token(); loop: while (true) { switch (tok) { - case 4 /* NewLineTrivia */: - state = 0 /* BeginningOfLine */; + case 4 /* SyntaxKind.NewLineTrivia */: + state = 0 /* JSDocState.BeginningOfLine */; // don't use pushComment here because we want to keep the margin unchanged comments.push(scanner.getTokenText()); indent = 0; break; - case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */ - || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { + case 59 /* SyntaxKind.AtToken */: + if (state === 3 /* JSDocState.SavingBackticks */ + || state === 2 /* JSDocState.SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace comments.push(scanner.getTokenText()); break; } scanner.setTextPos(scanner.getTextPos() - 1); // falls through - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // Done break loop; - case 5 /* WhitespaceTrivia */: - if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) { + case 5 /* SyntaxKind.WhitespaceTrivia */: + if (state === 2 /* JSDocState.SavingComments */ || state === 3 /* JSDocState.SavingBackticks */) { pushComment(scanner.getTokenText()); } else { @@ -38218,8 +38353,8 @@ var ts; indent += whitespace.length; } break; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -38233,32 +38368,32 @@ var ts; pushComment(scanner.getTokenText()); } break; - case 61 /* BacktickToken */: - if (state === 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; + case 61 /* SyntaxKind.BacktickToken */: + if (state === 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; } else { - state = 3 /* SavingBackticks */; + state = 3 /* JSDocState.SavingBackticks */; } pushComment(scanner.getTokenText()); break; - case 41 /* AsteriskToken */: - if (state === 0 /* BeginningOfLine */) { + case 41 /* SyntaxKind.AsteriskToken */: + if (state === 0 /* JSDocState.BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += 1; break; } // record the * as a comment // falls through default: - if (state !== 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; // leading identifiers start recording as well + if (state !== 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; // leading identifiers start recording as well } pushComment(scanner.getTokenText()); break; } - previousWhitespace = token() === 5 /* WhitespaceTrivia */; + previousWhitespace = token() === 5 /* SyntaxKind.WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); @@ -38275,7 +38410,7 @@ var ts; } function isNextJSDocTokenWhitespace() { var next = nextTokenJSDoc(); - return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + return next === 5 /* SyntaxKind.WhitespaceTrivia */ || next === 4 /* SyntaxKind.NewLineTrivia */; } function parseJSDocLink(start) { var linkType = tryParse(parseJSDocLinkPrefix); @@ -38290,14 +38425,14 @@ var ts; ? parseEntityName(/*allowReservedWords*/ true) : undefined; if (name) { - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); } } var text = []; - while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 19 /* SyntaxKind.CloseBraceToken */ && token() !== 4 /* SyntaxKind.NewLineTrivia */ && token() !== 1 /* SyntaxKind.EndOfFileToken */) { text.push(scanner.getTokenText()); nextTokenJSDoc(); } @@ -38308,8 +38443,8 @@ var ts; } function parseJSDocLinkPrefix() { skipWhitespaceOrAsterisk(); - if (token() === 18 /* OpenBraceToken */ - && nextTokenJSDoc() === 59 /* AtToken */ + if (token() === 18 /* SyntaxKind.OpenBraceToken */ + && nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { var kind = scanner.getTokenValue(); if (isJSDocLinkTag(kind)) @@ -38337,35 +38472,35 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* SyntaxKind.BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(61 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* SyntaxKind.BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(63 /* EqualsToken */)) { + if (parseOptionalToken(63 /* SyntaxKind.EqualsToken */)) { parseExpression(); } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -38381,12 +38516,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); - var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); + var nestedTypeLiteral = target !== 4 /* PropertyLikeParse.CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - var result = target === 1 /* Property */ + var result = target === 1 /* PropertyLikeParse.Property */ ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment); return finishNode(result, start); @@ -38397,12 +38532,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) { + if (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -38423,8 +38558,8 @@ var ts; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */ - || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); + var isMarkdownOrJSDocLink = token() === 22 /* SyntaxKind.OpenBracketToken */ + || lookAhead(function () { return nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference(); var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); @@ -38446,14 +38581,14 @@ var ts; var comments = []; var inEmail = false; var token = scanner.getToken(); - while (token !== 1 /* EndOfFileToken */ && token !== 4 /* NewLineTrivia */) { - if (token === 29 /* LessThanToken */) { + while (token !== 1 /* SyntaxKind.EndOfFileToken */ && token !== 4 /* SyntaxKind.NewLineTrivia */) { + if (token === 29 /* SyntaxKind.LessThanToken */) { inEmail = true; } - else if (token === 59 /* AtToken */ && !inEmail) { + else if (token === 59 /* SyntaxKind.AtToken */ && !inEmail) { break; } - else if (token === 31 /* GreaterThanToken */ && inEmail) { + else if (token === 31 /* SyntaxKind.GreaterThanToken */ && inEmail) { comments.push(scanner.getTokenText()); scanner.setTextPos(scanner.getTokenPos() + 1); break; @@ -38472,21 +38607,21 @@ var ts; return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(18 /* OpenBraceToken */); + var usedBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var pos = getNodePos(); var expression = parsePropertyAccessEntityNameExpression(); var typeArguments = tryParseTypeArguments(); var node = factory.createExpressionWithTypeArguments(expression, typeArguments); var res = finishNode(node, pos); if (usedBrace) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var pos = getNodePos(); var node = parseJSDocIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); node = finishNode(factory.createPropertyAccessExpression(node, name), pos); } @@ -38520,7 +38655,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 343 /* JSDocTypeTag */) { + if (child.kind === 343 /* SyntaxKind.JSDocTypeTag */) { if (childTypeTag) { var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { @@ -38537,7 +38672,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 183 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -38561,10 +38696,10 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(24 /* DotToken */)) { + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var body = parseJSDocTypeNameWithNamespace(/*nested*/ true); var jsDocNamespaceNode = factory.createModuleDeclaration( - /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NestedNamespace */ : undefined); + /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NodeFlags.NestedNamespace */ : undefined); return finishNode(jsDocNamespaceNode, pos); } if (nested) { @@ -38576,7 +38711,7 @@ var ts; var pos = getNodePos(); var child; var parameters; - while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { + while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* PropertyLikeParse.CallbackParameter */, indent); })) { parameters = ts.append(parameters, child); } return createNodeArray(parameters || [], pos); @@ -38587,9 +38722,9 @@ var ts; var comment = parseTagComments(indent); var parameters = parseCallbackTagParameters(indent); var returnTag = tryParse(function () { - if (parseOptionalJsdoc(59 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 341 /* JSDocReturnTag */) { + if (tag && tag.kind === 341 /* SyntaxKind.JSDocReturnTag */) { return tag; } } @@ -38614,18 +38749,18 @@ var ts; return a.escapedText === b.escapedText; } function parseChildPropertyTag(indent) { - return parseChildParameterOrPropertyTag(1 /* Property */, indent); + return parseChildParameterOrPropertyTag(1 /* PropertyLikeParse.Property */, indent); } function parseChildParameterOrPropertyTag(target, indent, name) { var canParseTag = true; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) && - target !== 4 /* CallbackParameter */ && + if (child && (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) && + target !== 4 /* PropertyLikeParse.CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -38633,26 +38768,26 @@ var ts; } seenAsterisk = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: canParseTag = true; seenAsterisk = false; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: canParseTag = false; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return false; } } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -38660,15 +38795,15 @@ var ts; var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(start, tagName); + return target === 1 /* PropertyLikeParse.Property */ && parseTypeTag(start, tagName); case "prop": case "property": - t = 1 /* Property */; + t = 1 /* PropertyLikeParse.Property */; break; case "arg": case "argument": case "param": - t = 2 /* Parameter */ | 4 /* CallbackParameter */; + t = 2 /* PropertyLikeParse.Parameter */ | 4 /* PropertyLikeParse.CallbackParameter */; break; default: return false; @@ -38680,7 +38815,7 @@ var ts; } function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } @@ -38688,9 +38823,9 @@ var ts; var defaultType; if (isBracketed) { skipWhitespace(); - parseExpected(63 /* EqualsToken */); - defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); - parseExpected(23 /* CloseBracketToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); + defaultType = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } if (ts.nodeIsMissing(name)) { return undefined; @@ -38707,7 +38842,7 @@ var ts; typeParameters.push(node); } skipWhitespaceOrAsterisk(); - } while (parseOptionalJsdoc(27 /* CommaToken */)); + } while (parseOptionalJsdoc(27 /* SyntaxKind.CommaToken */)); return createNodeArray(typeParameters, pos); } function parseTemplateTag(start, tagName, indent, indentText) { @@ -38722,7 +38857,7 @@ var ts; // TODO: Determine whether we should enforce this in the checker. // TODO: Consider moving the `constraint` to the first type parameter as we could then remove `getEffectiveConstraintOfTypeParameter`. // TODO: Consider only parsing a single type parameter if there is a constraint. - var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + var constraint = token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } @@ -38735,16 +38870,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); // Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking. // Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}> // but it's not worth it to enforce that restriction. } - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -38752,7 +38887,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -38769,7 +38904,7 @@ var ts; var IncrementalParser; (function (IncrementalParser) { function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */); checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); if (ts.textChangeRangeIsUnchanged(textChangeRange)) { // if the text didn't change, then we can just return our current source file as-is. @@ -38924,9 +39059,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 79 /* Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: return true; } return false; @@ -39000,10 +39135,10 @@ var ts; } function checkNodePositions(node, aggressiveChecks) { if (aggressiveChecks) { - var pos_2 = node.pos; + var pos_3 = node.pos; var visitNode_1 = function (child) { - ts.Debug.assert(child.pos >= pos_2); - pos_2 = child.end; + ts.Debug.assert(child.pos >= pos_3); + pos_3 = child.end; }; if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -39012,7 +39147,7 @@ var ts; } } forEachChild(node, visitNode_1); - ts.Debug.assert(pos_2 <= node.end); + ts.Debug.assert(pos_3 <= node.end); } } function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { @@ -39181,7 +39316,7 @@ var ts; var oldText = sourceFile.text; if (textChangeRange) { ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* AssertionLevel.VeryAggressive */)) { var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); var newTextPrefix = newText.substr(0, textChangeRange.span.start); ts.Debug.assert(oldTextPrefix === newTextPrefix); @@ -39196,7 +39331,7 @@ var ts; var currentArrayIndex = 0; ts.Debug.assert(currentArrayIndex < currentArray.length); var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; + var lastQueriedPosition = -1 /* InvalidPosition.Value */; return { currentNode: function (position) { // Only compute the current node if the position is different than the last time @@ -39234,7 +39369,7 @@ var ts; function findHighestListElementThatStartsAtPosition(position) { // Clear out any cached state about the last node we found. currentArray = undefined; - currentArrayIndex = -1 /* Value */; + currentArrayIndex = -1 /* InvalidPosition.Value */; current = undefined; // Recurse into the source file to find the highest node at this position. forEachChild(sourceFile, visitNode, visitArray); @@ -39414,18 +39549,18 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im; var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im; function extractPragmas(pragmas, range, text) { - var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); + var tripleSlash = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); if (tripleSlash) { var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks var pragma = ts.commentPragmas[name]; - if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) { + if (!pragma || !(pragma.kind & 1 /* PragmaKindFlags.TripleSlashXML */)) { return; } if (pragma.args) { @@ -39459,15 +39594,15 @@ var ts; } return; } - var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); + var singleLine = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); if (singleLine) { - return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); + return addPragmaForMatch(pragmas, range, 2 /* PragmaKindFlags.SingleLine */, singleLine); } - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { - addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch); + addPragmaForMatch(pragmas, range, 4 /* PragmaKindFlags.MultiLine */, multiLineMatch); } } } @@ -39510,10 +39645,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 79 /* Identifier */) { + if (lhs.kind === 79 /* SyntaxKind.Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 108 /* ThisKeyword */) { + if (lhs.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -39533,11 +39668,11 @@ var ts; defaultValueDescription: false, }; var jsxOptionMap = new ts.Map(ts.getEntries({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */, - "react-jsx": 4 /* ReactJSX */, - "react-jsxdev": 5 /* ReactJSXDev */, + "preserve": 1 /* JsxEmit.Preserve */, + "react-native": 3 /* JsxEmit.ReactNative */, + "react": 2 /* JsxEmit.React */, + "react-jsx": 4 /* JsxEmit.ReactJSX */, + "react-jsxdev": 5 /* JsxEmit.ReactJSXDev */, })); /* @internal */ ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) { @@ -39843,18 +39978,18 @@ var ts; name: "target", shortName: "t", type: new ts.Map(ts.getEntries({ - es3: 0 /* ES3 */, - es5: 1 /* ES5 */, - es6: 2 /* ES2015 */, - es2015: 2 /* ES2015 */, - es2016: 3 /* ES2016 */, - es2017: 4 /* ES2017 */, - es2018: 5 /* ES2018 */, - es2019: 6 /* ES2019 */, - es2020: 7 /* ES2020 */, - es2021: 8 /* ES2021 */, - es2022: 9 /* ES2022 */, - esnext: 99 /* ESNext */, + es3: 0 /* ScriptTarget.ES3 */, + es5: 1 /* ScriptTarget.ES5 */, + es6: 2 /* ScriptTarget.ES2015 */, + es2015: 2 /* ScriptTarget.ES2015 */, + es2016: 3 /* ScriptTarget.ES2016 */, + es2017: 4 /* ScriptTarget.ES2017 */, + es2018: 5 /* ScriptTarget.ES2018 */, + es2019: 6 /* ScriptTarget.ES2019 */, + es2020: 7 /* ScriptTarget.ES2020 */, + es2021: 8 /* ScriptTarget.ES2021 */, + es2022: 9 /* ScriptTarget.ES2022 */, + esnext: 99 /* ScriptTarget.ESNext */, })), affectsSourceFile: true, affectsModuleResolution: true, @@ -39864,7 +39999,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, - defaultValueDescription: 0 /* ES3 */, + defaultValueDescription: 0 /* ScriptTarget.ES3 */, }; /*@internal*/ ts.moduleOptionDeclaration = { @@ -40144,16 +40279,16 @@ var ts; { name: "importsNotUsedAsValues", type: new ts.Map(ts.getEntries({ - remove: 0 /* Remove */, - preserve: 1 /* Preserve */, - error: 2 /* Error */, + remove: 0 /* ImportsNotUsedAsValues.Remove */, + preserve: 1 /* ImportsNotUsedAsValues.Preserve */, + error: 2 /* ImportsNotUsedAsValues.Error */, })), affectsEmit: true, affectsSemanticDiagnostics: true, affectsMultiFileEmitBuildInfo: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, - defaultValueDescription: 0 /* Remove */, + defaultValueDescription: 0 /* ImportsNotUsedAsValues.Remove */, }, { name: "downlevelIteration", @@ -40608,8 +40743,8 @@ var ts; { name: "newLine", type: new ts.Map(ts.getEntries({ - crlf: 0 /* CarriageReturnLineFeed */, - lf: 1 /* LineFeed */ + crlf: 0 /* NewLineKind.CarriageReturnLineFeed */, + lf: 1 /* NewLineKind.LineFeed */ })), affectsEmit: true, affectsMultiFileEmitBuildInfo: true, @@ -40982,7 +41117,7 @@ var ts; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, - target: 3 /* ES2016 */, + target: 3 /* ScriptTarget.ES2016 */, strict: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, @@ -41007,8 +41142,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } /* @internal */ function parseCustomTypeOption(opt, value, errors) { @@ -41067,11 +41202,11 @@ var ts; while (i < args.length) { var s = args[i]; i++; - if (s.charCodeAt(0) === 64 /* at */) { + if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) { parseResponseFile(s.slice(1)); } - else if (s.charCodeAt(0) === 45 /* minus */) { - var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1); + else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) { + var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1); var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true); if (opt) { i = parseOptionValue(args, i, diagnostics, opt, options, errors); @@ -41100,14 +41235,14 @@ var ts; var args = []; var pos = 0; while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) + while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */) pos++; if (pos >= text.length) break; var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { + if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) { pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */) pos++; if (pos < text.length) { args.push(text.substring(start + 1, pos)); @@ -41118,7 +41253,7 @@ var ts; } } else { - while (text.charCodeAt(pos) > 32 /* space */) + while (text.charCodeAt(pos) > 32 /* CharacterCodes.space */) pos++; args.push(text.substring(start, pos)); } @@ -41453,7 +41588,7 @@ var ts; var _a; var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; - if (rootExpression && rootExpression.kind !== 205 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json")); // Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that @@ -41493,7 +41628,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 296 /* PropertyAssignment */) { + if (element.kind !== 296 /* SyntaxKind.PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -41560,16 +41695,16 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -41584,16 +41719,16 @@ var ts; } } return validateValue(text); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 219 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* SyntaxKind.MinusToken */ || valueExpression.operand.kind !== 8 /* SyntaxKind.NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -41610,7 +41745,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -41804,10 +41939,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -41858,19 +41993,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -41879,25 +42014,25 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); // Print out each row, aligning all the descriptions on the same column. for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -41952,7 +42087,7 @@ var ts; * file to. e.g. outDir */ function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -42302,8 +42437,8 @@ var ts; extendedConfig = ts.normalizeSlashes(extendedConfig); if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Extension.Json */)) { + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -42544,11 +42679,11 @@ var ts; var jsonOnlyIncludeRegexes; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { var _loop_6 = function (file) { - if (ts.fileExtensionIs(file, ".json" /* Json */)) { + if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { - var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Json */); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -42692,7 +42827,7 @@ var ts; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; - if (flags === 1 /* Recursive */) { + if (flags === 1 /* WatchDirectoryFlags.Recursive */) { recursiveKeys.push(key); } } @@ -42726,13 +42861,13 @@ var ts; key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) - ? 1 /* Recursive */ : 0 /* None */ + ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */ }; } if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) { return { key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)), - flags: 1 /* Recursive */ + flags: 1 /* WatchDirectoryFlags.Recursive */ }; } return undefined; @@ -42755,7 +42890,7 @@ var ts; } var higherPriorityPath = keyMapper(ts.changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { - if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) { + if (ext === ".d.ts" /* Extension.Dts */ && (ts.fileExtensionIs(file, ".js" /* Extension.Js */) || ts.fileExtensionIs(file, ".jsx" /* Extension.Jsx */))) { // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to // prevent breakage. @@ -42833,7 +42968,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -42989,7 +43124,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -43052,7 +43187,7 @@ var ts; var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); function arePathsEqual(path1, path2, host) { var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames; - return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */; + return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* Comparison.EqualTo */; } /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -43220,18 +43355,7 @@ var ts; * Does not try `@types/${packageName}` - use a second pass if needed. */ function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) { - var moduleResolutionState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ts.emptyArray, - features: NodeResolutionFeatures.None, - requestContainingDirectory: containingDirectory, - reportDiagnostic: ts.noop - }; + var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules"); @@ -43273,7 +43397,7 @@ var ts; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); // At this stage, skip results with leading dot. - if (baseFileName.charCodeAt(0) !== 46 /* dot */) { + if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) { // Return just the type directive names result.push(baseFileName); } @@ -43328,7 +43452,7 @@ var ts; ts.createCacheWithRedirects = createCacheWithRedirects; function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { var cache; - return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries }; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap }; function getPackageJsonInfo(packageJsonPath) { return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); } @@ -43342,6 +43466,9 @@ var ts; var iter = cache === null || cache === void 0 ? void 0 : cache.entries(); return iter ? ts.arrayFrom(iter) : []; } + function getInternalMap() { + return cache; + } } function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); @@ -43424,7 +43551,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -43445,21 +43572,24 @@ var ts; } ts.zipToModeAwareCache = zipToModeAwareCache; function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options)); var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); - moduleNameToDirectoryMap.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + } function update(options) { updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -43529,13 +43659,16 @@ var ts; } ts.createModuleResolutionCache = createModuleResolutionCache; function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + } } ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) { @@ -43606,10 +43739,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -43812,7 +43945,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -43961,7 +44094,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -44028,7 +44161,7 @@ var ts; } var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length; var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules); - if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) { + if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) { indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName); } return path.slice(0, indexAfterPackageName); @@ -44047,7 +44180,7 @@ var ts; */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { - var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); + var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Extension.Json */); var extension = extensionLess ? candidate.substring(extensionLess.length) : ""; return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } @@ -44064,7 +44197,7 @@ var ts; function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) { + if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Extension.Json */) && state.compilerOptions.resolveJsonModule)) { var extensionless = ts.removeFileExtension(candidate); var extension = candidate.substring(extensionless.length); if (state.traceEnabled) { @@ -44092,55 +44225,55 @@ var ts; switch (extensions) { case Extensions.DtsOnly: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); - default: return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".d.mts" /* Extension.Dmts */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".d.cts" /* Extension.Dcts */); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return tryExtension(".d.ts" /* Extension.Dts */); + default: return tryExtension(".d.ts" /* Extension.Dts */); } case Extensions.TypeScript: case Extensions.TsOnly: var useDts = extensions === Extensions.TypeScript; switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return useDts ? tryExtension(".d.ts" /* Dts */) : undefined; + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mts" /* Extension.Mts */) || (useDts ? tryExtension(".d.mts" /* Extension.Dmts */) : undefined); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cts" /* Extension.Cts */) || (useDts ? tryExtension(".d.cts" /* Extension.Dcts */) : undefined); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined; default: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined); + return tryExtension(".ts" /* Extension.Ts */) || tryExtension(".tsx" /* Extension.Tsx */) || (useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined); } case Extensions.JavaScript: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mjs" /* Mjs */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cjs" /* Cjs */); - case ".json" /* Json */: - return tryExtension(".json" /* Json */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mjs" /* Extension.Mjs */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cjs" /* Extension.Cjs */); + case ".json" /* Extension.Json */: + return tryExtension(".json" /* Extension.Json */); default: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js" /* Extension.Js */) || tryExtension(".jsx" /* Extension.Jsx */); } case Extensions.TSConfig: case Extensions.Json: - return tryExtension(".json" /* Json */); + return tryExtension(".json" /* Extension.Json */); } function tryExtension(ext) { var path = tryFile(candidate + ext, onlyRecordFailures, state); @@ -44191,18 +44324,9 @@ var ts; var entrypoints; var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript; var features = getDefaultNodeResolutionFeatures(options); - var requireState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ["node", "require", "types"], - features: features, - requestContainingDirectory: packageJsonInfo.packageDirectory, - reportDiagnostic: ts.noop - }; + var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); + requireState.conditions = ["node", "require", "types"]; + requireState.requestContainingDirectory = packageJsonInfo.packageDirectory; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path); @@ -44275,23 +44399,27 @@ var ts; } } } - /** - * A function for locating the package.json scope for a given path - */ /*@internal*/ - function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) { - var state = { + function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) { + return { host: host, compilerOptions: options, traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], + failedLookupLocations: ts.noopPush, + affectingLocations: ts.noopPush, packageJsonInfoCache: packageJsonInfoCache, - features: 0, - conditions: [], + features: NodeResolutionFeatures.None, + conditions: ts.emptyArray, requestContainingDirectory: undefined, reportDiagnostic: ts.noop }; + } + ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState; + /** + * A function for locating the package.json scope for a given path + */ + /*@internal*/ + function getPackageScopeForPath(fileName, state) { var parts = ts.getPathComponents(fileName); parts.pop(); while (parts.length > 0) { @@ -44429,16 +44557,16 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */; + return extension === ".js" /* Extension.Js */ || extension === ".jsx" /* Extension.Jsx */ || extension === ".mjs" /* Extension.Mjs */ || extension === ".cjs" /* Extension.Cjs */; case Extensions.TSConfig: case Extensions.Json: - return extension === ".json" /* Json */; + return extension === ".json" /* Extension.Json */; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */ || extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */ || extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; case Extensions.TsOnly: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */; + return extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; } } /* @internal */ @@ -44462,7 +44590,7 @@ var ts; var _a, _b; var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope || !scope.packageJsonContent.exports) { return undefined; } @@ -44475,7 +44603,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -44521,7 +44649,7 @@ var ts; } var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath); @@ -44544,6 +44672,7 @@ var ts; return toSearchResult(/*value*/ undefined); } /** + * @internal * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 - * "longest" has some nuance as to what "longest" means in the presence of pattern trailers */ @@ -44566,6 +44695,7 @@ var ts; return 1; return 0; } + ts.comparePatternKeys = comparePatternKeys; function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) { var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports); if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) { @@ -44773,7 +44903,7 @@ var ts; // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment); - var jsAndDtsExtensions = [".mjs" /* Mjs */, ".cjs" /* Cjs */, ".js" /* Js */, ".json" /* Json */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".d.ts" /* Dts */]; + var jsAndDtsExtensions = [".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */, ".js" /* Extension.Js */, ".json" /* Extension.Json */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".d.ts" /* Extension.Dts */]; for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) { var ext = jsAndDtsExtensions_1[_f]; if (ts.fileExtensionIs(possibleInputBase, ext)) { @@ -44958,7 +45088,7 @@ var ts; } /* @internal */ function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; /* @internal */ @@ -45104,14 +45234,14 @@ var ts; ts.setParent(node.body, node); ts.setParentRecursive(node.body, /*incremental*/ false); } - return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* ModuleInstanceState.Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateCached(node, visited) { if (visited === void 0) { visited = new ts.Map(); } var nodeId = ts.getNodeId(node); if (visited.has(nodeId)) { - return visited.get(nodeId) || 0 /* NonInstantiated */; + return visited.get(nodeId) || 0 /* ModuleInstanceState.NonInstantiated */; } visited.set(nodeId, undefined); var result = getModuleInstanceStateWorker(node, visited); @@ -45122,34 +45252,34 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return 0 /* NonInstantiated */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return 0 /* ModuleInstanceState.NonInstantiated */; // 2. const enum declarations - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (ts.isEnumConst(node)) { - return 2 /* ConstEnumOnly */; + return 2 /* ModuleInstanceState.ConstEnumOnly */; } break; // 3. non-exported import declarations - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { - return 0 /* NonInstantiated */; + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (!(ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { + return 0 /* ModuleInstanceState.NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* NamedExports */) { - var state = 0 /* NonInstantiated */; + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* SyntaxKind.NamedExports */) { + var state = 0 /* ModuleInstanceState.NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); if (specifierState > state) { state = specifierState; } - if (state === 1 /* Instantiated */) { + if (state === 1 /* ModuleInstanceState.Instantiated */) { return state; } } @@ -45157,21 +45287,21 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 262 /* ModuleBlock */: { - var state_1 = 0 /* NonInstantiated */; + case 262 /* SyntaxKind.ModuleBlock */: { + var state_1 = 0 /* ModuleInstanceState.NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); switch (childState) { - case 0 /* NonInstantiated */: + case 0 /* ModuleInstanceState.NonInstantiated */: // child is non-instantiated - continue searching return; - case 2 /* ConstEnumOnly */: + case 2 /* ModuleInstanceState.ConstEnumOnly */: // child is const enum only - record state and continue searching - state_1 = 2 /* ConstEnumOnly */; + state_1 = 2 /* ModuleInstanceState.ConstEnumOnly */; return; - case 1 /* Instantiated */: + case 1 /* ModuleInstanceState.Instantiated */: // child is instantiated - record state and stop - state_1 = 1 /* Instantiated */; + state_1 = 1 /* ModuleInstanceState.Instantiated */; return true; default: ts.Debug.assertNever(childState); @@ -45179,16 +45309,16 @@ var ts; }); return state_1; } - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { - return 0 /* NonInstantiated */; + return 0 /* ModuleInstanceState.NonInstantiated */; } } - return 1 /* Instantiated */; + return 1 /* ModuleInstanceState.Instantiated */; } function getModuleInstanceStateForAliasTarget(specifier, visited) { var name = specifier.propertyName || specifier.name; @@ -45208,7 +45338,7 @@ var ts; if (found === undefined || state > found) { found = state; } - if (found === 1 /* Instantiated */) { + if (found === 1 /* ModuleInstanceState.Instantiated */) { return found; } } @@ -45219,7 +45349,7 @@ var ts; } p = p.parent; } - return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + return 1 /* ModuleInstanceState.Instantiated */; // Couldn't locate, assume could refer to a value } var ContainerFlags; (function (ContainerFlags) { @@ -45293,8 +45423,8 @@ var ts; var symbolCount = 0; var Symbol; var classifiableNames; - var unreachableFlow = { flags: 1 /* Unreachable */ }; - var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; + var unreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; + var reportedUnreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); /** * Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file) @@ -45316,7 +45446,7 @@ var ts; ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* tracing.Phase.Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); bind(file); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); file.symbolCount = symbolCount; @@ -45343,7 +45473,7 @@ var ts; activeLabelList = undefined; hasExplicitReturn = false; inAssignmentPattern = false; - emitFlags = 0 /* None */; + emitFlags = 0 /* NodeFlags.None */; } return bindSourceFile; function bindInStrictMode(file, opts) { @@ -45363,33 +45493,33 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; symbol.declarations = ts.appendIfUnique(symbol.declarations, node); - if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } - if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && !symbol.members) { symbol.members = ts.createSymbolTable(); } // On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate) - if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { + if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { ts.setValueDeclaration(symbol, node); } } // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 271 /* ExportAssignment */) { - return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) { + return node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; } var name = ts.getNameOfDeclaration(node); if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -45415,36 +45545,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 171 /* Constructor */: - return "__constructor" /* Constructor */; - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - return "__call" /* Call */; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: - return "__new" /* New */; - case 176 /* IndexSignature */: - return "__index" /* Index */; - case 272 /* ExportDeclaration */: - return "__export" /* ExportStar */; - case 305 /* SourceFile */: + case 171 /* SyntaxKind.Constructor */: + return "__constructor" /* InternalSymbolName.Constructor */; + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + return "__call" /* InternalSymbolName.Call */; + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + return "__new" /* InternalSymbolName.New */; + case 176 /* SyntaxKind.IndexSignature */: + return "__index" /* InternalSymbolName.Index */; + case 272 /* SyntaxKind.ExportDeclaration */: + return "__export" /* InternalSymbolName.ExportStar */; + case 305 /* SyntaxKind.SourceFile */: // json file should behave as // module.exports = ... - return "export=" /* ExportEquals */; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { + return "export=" /* InternalSymbolName.ExportEquals */; + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */) { // module.exports = ... - return "export=" /* ExportEquals */; + return "export=" /* InternalSymbolName.ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 317 /* JSDocFunctionType */: - return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 164 /* Parameter */: + case 317 /* SyntaxKind.JSDocFunctionType */: + return (ts.isJSDocConstructSignature(node) ? "__new" /* InternalSymbolName.New */ : "__call" /* InternalSymbolName.Call */); + case 164 /* SyntaxKind.Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind), ", expected JSDocFunctionType"); }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -45463,14 +45593,14 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) { ts.Debug.assert(isComputedName || !ts.hasDynamicName(node)); - var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; + var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" - var name = isComputedName ? "__computed" /* Computed */ - : isDefaultExport && parent ? "default" /* Default */ + var name = isComputedName ? "__computed" /* InternalSymbolName.Computed */ + : isDefaultExport && parent ? "default" /* InternalSymbolName.Default */ : getDeclarationName(node); var symbol; if (name === undefined) { - symbol = createSymbol(0 /* None */, "__missing" /* Missing */); + symbol = createSymbol(0 /* SymbolFlags.None */, "__missing" /* InternalSymbolName.Missing */); } else { // Check and see if the symbol table already has a symbol with this name. If not, @@ -45497,11 +45627,11 @@ var ts; // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. symbol = symbolTable.get(name); - if (includes & 2885600 /* Classifiable */) { + if (includes & 2885600 /* SymbolFlags.Classifiable */) { classifiableNames.add(name); } if (!symbol) { - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); if (isReplaceableByMethod) symbol.isReplaceableByMethod = true; } @@ -45513,20 +45643,20 @@ var ts; if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); } - else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) { + else if (!(includes & 3 /* SymbolFlags.Variable */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { // Assignment declarations are allowed to merge with variables, no matter what other flags they have. if (ts.isNamedDeclaration(node)) { ts.setParent(node.name, node); } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message_1 = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; var messageNeedsName_1 = true; - if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ || includes & 384 /* SymbolFlags.Enum */) { message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; messageNeedsName_1 = false; } @@ -45546,7 +45676,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 271 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 271 /* SyntaxKind.ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -45554,9 +45684,9 @@ var ts; } } var relatedInformation_1 = []; - if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) && symbol.flags & (2097152 /* SymbolFlags.Alias */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { // export type T; - may have meant export type { T }? - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -45569,7 +45699,7 @@ var ts; }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false))); - symbol = createSymbol(0 /* None */, name); + symbol = createSymbol(0 /* SymbolFlags.None */, name); } } } @@ -45583,9 +45713,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); - if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 275 /* ExportSpecifier */ || (node.kind === 265 /* ImportEqualsDeclaration */ && hasExportModifier)) { + var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node); + if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -45609,11 +45739,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) { - if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) { + if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -45640,7 +45770,7 @@ var ts; return false; if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* ModifierFlags.Export */) return true; // This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should // already have calculated and branched on most of this. @@ -45673,21 +45803,21 @@ var ts; // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. - if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 214 /* ArrowFunction */) { + if (containerFlags & 1 /* ContainerFlags.IsContainer */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; - if (containerFlags & 32 /* HasLocals */) { + if (containerFlags & 32 /* ContainerFlags.HasLocals */) { container.locals = ts.createSymbolTable(); } addToContainerChain(container); } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { + else if (containerFlags & 2 /* ContainerFlags.IsBlockScopedContainer */) { blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (containerFlags & 4 /* IsControlFlowContainer */) { + if (containerFlags & 4 /* ContainerFlags.IsControlFlowContainer */) { var saveCurrentFlow = currentFlow; var saveBreakTarget = currentBreakTarget; var saveContinueTarget = currentContinueTarget; @@ -45695,22 +45825,22 @@ var ts; var saveExceptionTarget = currentExceptionTarget; var saveActiveLabelList = activeLabelList; var saveHasExplicitReturn = hasExplicitReturn; - var isImmediatelyInvoked = (containerFlags & 16 /* IsFunctionExpression */ && - !ts.hasSyntacticModifier(node, 256 /* Async */) && + var isImmediatelyInvoked = (containerFlags & 16 /* ContainerFlags.IsFunctionExpression */ && + !ts.hasSyntacticModifier(node, 256 /* ModifierFlags.Async */) && !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node)) || - node.kind === 170 /* ClassStaticBlockDeclaration */; + node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isImmediatelyInvoked) { - currentFlow = initFlowNode({ flags: 2 /* Start */ }); - if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); + if (containerFlags & (16 /* ContainerFlags.IsFunctionExpression */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { currentFlow.node = node; } } // 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 = isImmediatelyInvoked || node.kind === 171 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* SyntaxKind.Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -45718,21 +45848,21 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~2816 /* ReachabilityAndEmitFlags */; - if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 256 /* HasImplicitReturn */; + node.flags &= ~2816 /* NodeFlags.ReachabilityAndEmitFlags */; + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && containerFlags & 8 /* ContainerFlags.IsFunctionLike */ && ts.nodeIsPresent(node.body)) { + node.flags |= 256 /* NodeFlags.HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 512 /* HasExplicitReturn */; + node.flags |= 512 /* NodeFlags.HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 171 /* Constructor */ || node.kind === 170 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */))) { + if (node.kind === 171 /* SyntaxKind.Constructor */ || node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -45746,10 +45876,10 @@ var ts; activeLabelList = saveActiveLabelList; hasExplicitReturn = saveHasExplicitReturn; } - else if (containerFlags & 64 /* IsInterface */) { + else if (containerFlags & 64 /* ContainerFlags.IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* NodeFlags.ContainsThis */ : node.flags & ~128 /* NodeFlags.ContainsThis */; } else { bindChildren(node); @@ -45759,8 +45889,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -45783,59 +45913,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 237 /* FirstStatement */ && node.kind <= 253 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 237 /* SyntaxKind.FirstStatement */ && node.kind <= 253 /* SyntaxKind.LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: bindWhileStatement(node); break; - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: bindDoStatement(node); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: bindForStatement(node); break; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: bindForInOrForOfStatement(node); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: bindIfStatement(node); break; - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: bindReturnOrThrow(node); break; - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: bindTryStatement(node); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: bindSwitchStatement(node); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: bindCaseBlock(node); break; - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: bindCaseClause(node); break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: bindExpressionStatement(node); break; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: bindLabeledStatement(node); break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -45845,47 +45975,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bindCallExpressionFlow(node); break; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 305 /* SourceFile */: { + case 305 /* SyntaxKind.SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: bindBindingElementFlow(node); break; - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 296 /* PropertyAssignment */: - case 225 /* SpreadElement */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 225 /* SyntaxKind.SpreadElement */: // Carry over whether we are in an assignment pattern of Object and Array literals // as well as their children that are valid assignment targets. inAssignmentPattern = saveInAssignmentPattern; @@ -45899,22 +46029,22 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 108 /* ThisKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return containsNarrowableReference(expr); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return hasNarrowableArgument(expr); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isNarrowingExpression(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 219 /* PrefixUnaryExpression */: - return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 216 /* TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand); + case 216 /* SyntaxKind.TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -45922,7 +46052,7 @@ var ts; function isNarrowableReference(expr) { return ts.isDottedName(expr) || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) - || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(expr.right) || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } @@ -45938,7 +46068,7 @@ var ts; } } } - if (expr.expression.kind === 206 /* PropertyAccessExpression */ && + if (expr.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -45949,68 +46079,68 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return isNarrowingExpression(expr.right); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: return isNarrowableOperand(expr.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowableOperand(expr.right); } } return containsNarrowableReference(expr); } function createBranchLabel() { - return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); + return initFlowNode({ flags: 4 /* FlowFlags.BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); + return initFlowNode({ flags: 8 /* FlowFlags.LoopLabel */, antecedents: undefined }); } function createReduceLabel(target, antecedents, antecedent) { - return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); + return initFlowNode({ flags: 1024 /* FlowFlags.ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */; + flow.flags |= flow.flags & 2048 /* FlowFlags.Referenced */ ? 4096 /* FlowFlags.Shared */ : 2048 /* FlowFlags.Referenced */; } function addAntecedent(label, antecedent) { - if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { + if (!(antecedent.flags & 1 /* FlowFlags.Unreachable */) && !ts.contains(label.antecedents, antecedent)) { (label.antecedents || (label.antecedents = [])).push(antecedent); setFlowNodeReferenced(antecedent); } } function createFlowCondition(flags, antecedent, expression) { - if (antecedent.flags & 1 /* Unreachable */) { + if (antecedent.flags & 1 /* FlowFlags.Unreachable */) { return antecedent; } if (!expression) { - return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; + return flags & 32 /* FlowFlags.TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* SyntaxKind.TrueKeyword */ && flags & 64 /* FlowFlags.FalseCondition */ || + expression.kind === 95 /* SyntaxKind.FalseKeyword */ && flags & 32 /* FlowFlags.TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -46022,7 +46152,7 @@ var ts; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); + return initFlowNode({ flags: 128 /* FlowFlags.SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowMutation(flags, antecedent, node) { setFlowNodeReferenced(antecedent); @@ -46034,7 +46164,7 @@ var ts; } function createFlowCall(antecedent, node) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + return initFlowNode({ flags: 512 /* FlowFlags.Call */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -46049,28 +46179,28 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return parent.expression === node; - case 242 /* ForStatement */: - case 222 /* ConditionalExpression */: + case 242 /* SyntaxKind.ForStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 212 /* ParenthesizedExpression */) { + if (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 219 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && node.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.operand; } else { - return node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 56 /* BarBarToken */ || - node.operatorToken.kind === 60 /* QuestionQuestionToken */); + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || + node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */); } } } @@ -46080,7 +46210,7 @@ var ts; } function isTopLevelLogicalExpression(node) { while (ts.isParenthesizedExpression(node.parent) || - ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && @@ -46099,8 +46229,8 @@ var ts; function bindCondition(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindIterativeStatement(node, breakTarget, continueTarget) { @@ -46114,7 +46244,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 250 /* LabeledStatement */) { + while (label && node.parent.kind === 250 /* SyntaxKind.LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -46165,12 +46295,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 244 /* ForOfStatement */) { + if (node.kind === 244 /* SyntaxKind.ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 255 /* VariableDeclarationList */) { + if (node.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -46192,7 +46322,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 247 /* ReturnStatement */) { + if (node.kind === 247 /* SyntaxKind.ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -46209,7 +46339,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 246 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 246 /* SyntaxKind.BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -46280,7 +46410,7 @@ var ts; finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents); currentFlow = finallyLabel; bind(node.finallyBlock); - if (currentFlow.flags & 1 /* Unreachable */) { + if (currentFlow.flags & 1 /* FlowFlags.Unreachable */) { // If the end of the finally block is unreachable, the end of the entire try statement is unreachable. currentFlow = unreachableFlow; } @@ -46314,7 +46444,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* SyntaxKind.DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -46343,7 +46473,7 @@ var ts; var clause = clauses[i]; bind(clause); fallthroughFlow = currentFlow; - if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { clause.fallthroughFlowNode = currentFlow; } } @@ -46362,9 +46492,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { var call = node; - if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { + if (call.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -46388,7 +46518,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -46397,12 +46527,12 @@ var ts; } function bindAssignmentTargetFlow(node) { if (isNarrowableReference(node)) { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } - else if (node.kind === 204 /* ArrayLiteralExpression */) { + else if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 225 /* SpreadElement */) { + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -46410,16 +46540,16 @@ var ts; } } } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 296 /* PropertyAssignment */) { + if (p.kind === 296 /* SyntaxKind.PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 297 /* ShorthandPropertyAssignment */) { + else if (p.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 298 /* SpreadAssignment */) { + else if (p.kind === 298 /* SyntaxKind.SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -46427,7 +46557,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -46438,15 +46568,15 @@ var ts; if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) { doWithConditionalBranches(bind, node.right, trueTarget, falseTarget); bindAssignmentTargetFlow(node.left); - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } else { bindCondition(node.right, trueTarget, falseTarget); } } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 53 /* ExclamationToken */) { + if (node.operator === 53 /* SyntaxKind.ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -46456,14 +46586,14 @@ var ts; } else { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -46512,9 +46642,9 @@ var ts; // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too // For now, though, since the common cases are chained `+`, leaving it recursive is fine var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || - operator === 56 /* BarBarToken */ || - operator === 60 /* QuestionQuestionToken */ || + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + operator === 56 /* SyntaxKind.BarBarToken */ || + operator === 60 /* SyntaxKind.QuestionQuestionToken */ || ts.isLogicalOrCoalescingAssignmentOperator(operator)) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); @@ -46531,7 +46661,7 @@ var ts; function onLeft(left, state, node) { if (!state.skip) { var maybeBound = maybeBind(left); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(left); } return maybeBound; @@ -46545,7 +46675,7 @@ var ts; function onRight(right, state, node) { if (!state.skip) { var maybeBound = maybeBind(right); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(right); } return maybeBound; @@ -46556,10 +46686,10 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 63 /* EqualsToken */ && node.left.kind === 207 /* ElementAccessExpression */) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && node.left.kind === 207 /* SyntaxKind.ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } @@ -46584,7 +46714,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -46612,7 +46742,7 @@ var ts; } } else { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } } function bindVariableDeclarationFlow(node) { @@ -46639,7 +46769,7 @@ var ts; } function bindJSDocTypeAlias(node) { bind(node.tagName); - if (node.kind !== 339 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 339 /* SyntaxKind.JSDocEnumTag */ && node.fullName) { // don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); @@ -46651,28 +46781,28 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 169 /* MethodDeclaration */) { - addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + if (host && host.kind !== 169 /* SyntaxKind.MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* SymbolFlags.Class */); } } function bindOptionalExpression(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainRest(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -46698,8 +46828,8 @@ var ts; } doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); if (ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainFlow(node) { @@ -46737,76 +46867,76 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 213 /* FunctionExpression */ || expr.kind === 214 /* ArrowFunction */) { + if (expr.kind === 213 /* SyntaxKind.FunctionExpression */ || expr.kind === 214 /* SyntaxKind.ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } function getContainerFlags(node) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 286 /* JsxAttributes */: - return 1 /* IsContainer */; - case 258 /* InterfaceDeclaration */: - return 1 /* IsContainer */ | 64 /* IsInterface */; - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: - case 176 /* IndexSignature */: - return 1 /* IsContainer */ | 32 /* HasLocals */; - case 305 /* SourceFile */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 286 /* SyntaxKind.JsxAttributes */: + return 1 /* ContainerFlags.IsContainer */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */; + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: + case 176 /* SyntaxKind.IndexSignature */: + return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */; + case 305 /* SyntaxKind.SourceFile */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */; + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */; } // falls through - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 317 /* JSDocFunctionType */: - case 179 /* FunctionType */: - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: - case 170 /* ClassStaticBlockDeclaration */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 262 /* ModuleBlock */: - return 4 /* IsControlFlowContainer */; - case 167 /* PropertyDeclaration */: - return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 292 /* CatchClause */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 263 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 235 /* Block */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 179 /* SyntaxKind.FunctionType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */; + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 16 /* ContainerFlags.IsFunctionExpression */; + case 262 /* SyntaxKind.ModuleBlock */: + return 4 /* ContainerFlags.IsControlFlowContainer */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return node.initializer ? 4 /* ContainerFlags.IsControlFlowContainer */ : 0; + case 292 /* SyntaxKind.CatchClause */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 263 /* SyntaxKind.CaseBlock */: + return 2 /* ContainerFlags.IsBlockScopedContainer */; + case 235 /* SyntaxKind.Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -46823,9 +46953,9 @@ var ts; // By not creating a new block-scoped-container here, we ensure that both 'var x' // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. - return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* ContainerFlags.None */ : 2 /* ContainerFlags.IsBlockScopedContainer */; } - return 0 /* None */; + return 0 /* ContainerFlags.None */; } function addToContainerChain(next) { if (lastContainer) { @@ -46839,46 +46969,46 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 205 /* ObjectLiteralExpression */: - case 258 /* InterfaceDeclaration */: - case 286 /* JsxAttributes */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 286 /* SyntaxKind.JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 323 /* JSDocSignature */: - case 176 /* IndexSignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 317 /* JSDocFunctionType */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 170 /* ClassStaticBlockDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -46905,17 +47035,17 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 64 /* ExportContext */; + if (node.flags & 16777216 /* NodeFlags.Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* NodeFlags.ExportContext */; } else { - node.flags &= ~64 /* ExportContext */; + node.flags &= ~64 /* NodeFlags.ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isModuleAugmentationExternal(node)) { @@ -46923,25 +47053,25 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 10 /* StringLiteral */) { + if (node.name.kind === 10 /* SyntaxKind.StringLiteral */) { var text = node.name.text; pattern = ts.tryParsePattern(text); if (pattern === undefined) { errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); } } - var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */); + var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* SymbolFlags.ValueModule */, 110735 /* SymbolFlags.ValueModuleExcludes */); file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { var state = declareModuleSymbol(node); - if (state !== 0 /* NonInstantiated */) { + if (state !== 0 /* ModuleInstanceState.NonInstantiated */) { var symbol = node.symbol; // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only - symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) + symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) // Current must be `const enum` only - && state === 2 /* ConstEnumOnly */ + && state === 2 /* ModuleInstanceState.ConstEnumOnly */ // Can't have been set to 'false' in a previous merged symbol. ('undefined' OK) && symbol.constEnumOnlyModule !== false; } @@ -46949,8 +47079,8 @@ var ts; } function declareModuleSymbol(node) { var state = getModuleInstanceState(node); - var instantiated = state !== 0 /* NonInstantiated */; - declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + var instantiated = state !== 0 /* ModuleInstanceState.NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* SymbolFlags.ValueModule */ : 1024 /* SymbolFlags.NamespaceModule */, instantiated ? 110735 /* SymbolFlags.ValueModuleExcludes */ : 0 /* SymbolFlags.NamespaceModuleExcludes */); return state; } function bindFunctionOrConstructorType(node) { @@ -46960,56 +47090,25 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + var symbol = createSymbol(131072 /* SymbolFlags.Signature */, getDeclarationName(node)); // TODO: GH#18217 + addDeclarationToSymbol(symbol, node, 131072 /* SymbolFlags.Signature */); + var typeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* SymbolFlags.TypeLiteral */); typeLiteralSymbol.members = ts.createSymbolTable(); typeLiteralSymbol.members.set(symbol.escapedName, symbol); } function bindObjectLiteralExpression(node) { - var ElementKind; - (function (ElementKind) { - ElementKind[ElementKind["Property"] = 1] = "Property"; - ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; - })(ElementKind || (ElementKind = {})); - if (inStrictMode && !ts.isAssignmentTarget(node)) { - var seen = new ts.Map(); - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { - continue; - } - var identifier = prop.name; - // ECMA-262 11.1.5 Object Initializer - // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true - // a.This production is contained in strict code and IsDataDescriptor(previous) is true and - // IsDataDescriptor(propId.descriptor) is true. - // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. - // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. - // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true - // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; - var existingKind = seen.get(identifier.escapedText); - if (!existingKind) { - seen.set(identifier.escapedText, currentKind); - continue; - } - } - } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__object" /* InternalSymbolName.Object */); } function bindJsxAttributes(node) { - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__jsxAttributes" /* InternalSymbolName.JSXAttributes */); } function bindJsxAttribute(node, symbolFlags, symbolExcludes) { return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); - if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) { + if (symbolFlags & (8 /* SymbolFlags.EnumMember */ | 106500 /* SymbolFlags.ClassMember */)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); @@ -47017,10 +47116,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -47046,9 +47145,9 @@ var ts; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; var host = typeAlias.parent.parent; - container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* ContainerFlags.IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = initFlowNode({ flags: 2 /* Start */ }); + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -47059,8 +47158,8 @@ var ts; bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: if (!ts.isExternalOrCommonJsModule(file)) { container = undefined; } @@ -47068,29 +47167,29 @@ var ts; container = file; } break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: container = declName.parent.expression; break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: container = declName.parent.expression.name; break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } if (container) { - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + declareModuleMember(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* SyntaxKind.Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -47108,24 +47207,24 @@ var ts; function checkContextualIdentifier(node) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length && - !(node.flags & 16777216 /* Ambient */) && - !(node.flags & 8388608 /* JSDoc */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && + !(node.flags & 8388608 /* NodeFlags.JSDoc */) && !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 132 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); } - else if (node.flags & 32768 /* AwaitContext */) { + else if (node.flags & 32768 /* NodeFlags.AwaitContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } - else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -47167,7 +47266,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 79 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* SyntaxKind.Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -47178,7 +47277,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 79 /* Identifier */) { + if (name && name.kind === 79 /* SyntaxKind.Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -47217,10 +47316,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 305 /* SourceFile */ && - blockScopeContainer.kind !== 261 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ && + blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -47230,7 +47329,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -47246,7 +47345,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -47259,7 +47358,7 @@ var ts; } function checkStrictModeLabeledStatement(node) { // Grammar checking for labeledStatement - if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) { + if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ScriptTarget.ES2015 */) { if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) { errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here); } @@ -47317,11 +47416,11 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 160 /* LastToken */) { + if (node.kind > 160 /* SyntaxKind.LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); - if (containerFlags === 0 /* None */) { + if (containerFlags === 0 /* ContainerFlags.None */) { bindChildren(node); } else { @@ -47331,7 +47430,7 @@ var ts; } else { var saveParent = parent; - if (node.kind === 1 /* EndOfFileToken */) + if (node.kind === 1 /* SyntaxKind.EndOfFileToken */) parent = node; bindJSDoc(node); parent = saveParent; @@ -47379,7 +47478,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -47388,28 +47487,28 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); break; } // falls through - case 108 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* ShorthandPropertyAssignment */)) { + case 108 /* SyntaxKind.ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 231 /* MetaProperty */: - case 106 /* SuperKeyword */: + case 231 /* SyntaxKind.MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: node.flowNode = currentFlow; break; - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifier(node); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -47421,28 +47520,28 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForName(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* SymbolFlags.FunctionScopedVariable */ | 134217728 /* SymbolFlags.ModuleExports */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { - case 1 /* ExportsProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: bindExportsPropertyAssignment(node); break; - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: bindModuleExportsAssignment(node); break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: bindPrototypePropertyAssignment(node.left, node); break; - case 6 /* Prototype */: + case 6 /* AssignmentDeclarationKind.Prototype */: bindPrototypeAssignment(node); break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: bindThisPropertyAssignment(node); break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: var expression = node.left.expression; if (ts.isInJSFile(node) && ts.isIdentifier(expression)) { var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText); @@ -47453,94 +47552,94 @@ var ts; } bindSpecialPropertyAssignment(node); break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: // Nothing to do break; default: ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return checkStrictModeCatchClause(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkStrictModeWithStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: seenThisKeyword = true; return; - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: break; // Binding the children will handle everything - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return bindTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return bindParameter(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return bindPropertyWorker(node); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 299 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); + case 299 /* SyntaxKind.EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */); + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */); + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 256 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), ts.isObjectLiteralMethod(node) ? 0 /* SymbolFlags.PropertyExcludes */ : 103359 /* SymbolFlags.MethodExcludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: return bindFunctionDeclaration(node); - case 171 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 172 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 173 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: - case 180 /* ConstructorType */: + case 171 /* SyntaxKind.Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, /*symbolExcludes:*/ 0 /* SymbolFlags.None */); + case 172 /* SyntaxKind.GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46015 /* SymbolFlags.GetAccessorExcludes */); + case 173 /* SyntaxKind.SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78783 /* SymbolFlags.SetAccessorExcludes */); + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: + case 180 /* SyntaxKind.ConstructorType */: return bindFunctionOrConstructorType(node); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 195 /* MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 195 /* SyntaxKind.MappedType */: return bindAnonymousTypeWorker(node); - case 332 /* JSDocClassTag */: + case 332 /* SyntaxKind.JSDocClassTag */: return bindJSDocClassTag(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return bindFunctionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { - case 7 /* ObjectDefinePropertyValue */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: return bindObjectDefinePropertyAssignment(node); - case 8 /* ObjectDefinePropertyExports */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: return bindObjectDefinePropertyExport(node); - case 9 /* ObjectDefinePrototypeProperty */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return bindObjectDefinePrototypeProperty(node); - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: break; // Nothing to do default: return ts.Debug.fail("Unknown call expression assignment declaration kind"); @@ -47550,73 +47649,73 @@ var ts; } break; // Members of classes, interfaces, and modules - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 258 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 259 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 260 /* EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */); + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); + case 260 /* SyntaxKind.EnumDeclaration */: return bindEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return bindJsxAttributes(node); - case 285 /* JsxAttribute */: - return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); + case 285 /* SyntaxKind.JsxAttribute */: + return bindJsxAttribute(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); // Imports and exports - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 264 /* NamespaceExportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return bindImportClause(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return bindExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return bindExportAssignment(node); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 340 /* JSDocParameterTag */: - if (node.parent.kind === 323 /* JSDocSignature */) { + case 340 /* SyntaxKind.JSDocParameterTag */: + if (node.parent.kind === 323 /* SyntaxKind.JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 322 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 322 /* SyntaxKind.JSDocTypeLiteral */) { break; } // falls through - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; - return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ ? + 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */ : + 4 /* SymbolFlags.Property */; + return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* SymbolFlags.PropertyExcludes */); + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } function bindPropertyWorker(node) { - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } function bindAnonymousTypeWorker(node) { - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */); + return bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); } function bindSourceFileIfExternalModule() { setExportContextFlag(file); @@ -47627,27 +47726,27 @@ var ts; bindSourceFileAsExternalModule(); // Create symbol equivalent for the module.exports = {} var originalSymbol = file.symbol; - declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */); + declareSymbol(file.symbol.exports, file.symbol, file, 4 /* SymbolFlags.Property */, 67108863 /* SymbolFlags.All */); file.symbol = originalSymbol; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512 /* SymbolFlags.ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { // Incorrect export assignment in some sort of block construct - bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 111551 /* SymbolFlags.Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ + ? 2097152 /* SymbolFlags.Alias */ // An export default clause with any other expression exports a value - : 4 /* Property */; + : 4 /* SymbolFlags.Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) - var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); + var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* SymbolFlags.All */); if (node.isExportEquals) { // Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set. ts.setValueDeclaration(symbol, node); @@ -47667,28 +47766,28 @@ var ts; } else { file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable(); - declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 8388608 /* SymbolFlags.ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */); } else if (ts.isNamespaceExport(node.exportClause)) { // declareSymbol walks up parents to find name text, parent _must_ be set // but won't be set by the normal binder walk until `bindChildren` later on. ts.setParent(node.exportClause, node); - declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindImportClause(node) { if (node.name) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function setCommonJsModuleIndicator(node) { @@ -47709,13 +47808,13 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { - var flags = 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + var flags = 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* SymbolFlags.None */); } } function bindExportsPropertyAssignment(node) { @@ -47726,15 +47825,15 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression)); - var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */; + var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; ts.setParent(node.left, node); - declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */); } } function bindModuleExportsAssignment(node) { @@ -47755,13 +47854,13 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + ? 2097152 /* SymbolFlags.Alias */ + : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */ | 512 /* SymbolFlags.ValueModule */; + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); ts.setValueDeclaration(symbol, node); } function bindExportAssignedObjectMemberAlias(node) { - declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); @@ -47773,11 +47872,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -47791,17 +47890,17 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); } else { - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */); } - addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } break; - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -47810,19 +47909,19 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); } else { - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true); } break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; } else if (thisContainer.commonJsModuleIndicator) { - declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); + declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; default: @@ -47830,7 +47929,7 @@ var ts; } } function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) { - declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); + declareSymbol(symbolTable, symbol, node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); addLateBoundAssignmentDeclarationToSymbol(node, symbol); } function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { @@ -47839,10 +47938,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 108 /* ThisKeyword */) { + if (node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -47861,7 +47960,7 @@ var ts; var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); if (namespaceSymbol && namespaceSymbol.valueDeclaration) { // Ensure the namespace symbol becomes class-like - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } @@ -47882,7 +47981,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 305 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -47894,7 +47993,7 @@ var ts; return; } var rootExpr = ts.getLeftmostAccessExpression(node.left); - if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) { + if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* SymbolFlags.Alias */) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them @@ -47907,7 +48006,7 @@ var ts; bindExportsPropertyAssignment(node); } else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + bindAnonymousDeclaration(node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, "__computed" /* InternalSymbolName.Computed */); var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); addLateBoundAssignmentDeclarationToSymbol(node, sym); } @@ -47925,13 +48024,13 @@ var ts; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { - if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) { + if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* SymbolFlags.Alias */) { return namespaceSymbol; } if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers - var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */; - var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; + var flags_2 = 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */; + var excludeFlags_1 = 110735 /* SymbolFlags.ValueModuleExcludes */ & ~67108864 /* SymbolFlags.Assignment */; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_2); @@ -47945,7 +48044,7 @@ var ts; }); } if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } return namespaceSymbol; } @@ -47957,12 +48056,12 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var includes = 0 /* None */; - var excludes = 0 /* None */; + var includes = 0 /* SymbolFlags.None */; + var excludes = 0 /* SymbolFlags.None */; // Method-like if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { - includes = 8192 /* Method */; - excludes = 103359 /* MethodExcludes */; + includes = 8192 /* SymbolFlags.Method */; + excludes = 103359 /* SymbolFlags.MethodExcludes */; } // Maybe accessor-like else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { @@ -47972,27 +48071,27 @@ var ts; })) { // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) - includes |= 65536 /* SetAccessor */ | 4 /* Property */; - excludes |= 78783 /* SetAccessorExcludes */; + includes |= 65536 /* SymbolFlags.SetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 78783 /* SymbolFlags.SetAccessorExcludes */; } if (ts.some(declaration.arguments[2].properties, function (p) { var id = ts.getNameOfDeclaration(p); return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; })) { - includes |= 32768 /* GetAccessor */ | 4 /* Property */; - excludes |= 46015 /* GetAccessorExcludes */; + includes |= 32768 /* SymbolFlags.GetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 46015 /* SymbolFlags.GetAccessorExcludes */; } } - if (includes === 0 /* None */) { - includes = 4 /* Property */; - excludes = 0 /* PropertyExcludes */; + if (includes === 0 /* SymbolFlags.None */) { + includes = 4 /* SymbolFlags.Property */; + excludes = 0 /* SymbolFlags.PropertyExcludes */; } - declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* SymbolFlags.Assignment */, excludes & ~67108864 /* SymbolFlags.Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SourceFile */ - : propertyAccess.parent.parent.kind === 305 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SyntaxKind.SourceFile */ + : propertyAccess.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -48011,7 +48110,7 @@ var ts; * - with non-empty object literals if assigned to the prototype property */ function isExpandoSymbol(symbol) { - if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 1024 /* SymbolFlags.NamespaceModule */)) { return true; } var node = symbol.valueDeclaration; @@ -48026,7 +48125,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || init.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -48071,12 +48170,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 257 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); + if (node.kind === 257 /* SyntaxKind.ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */); } else { - var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__class" /* InternalSymbolName.Class */; + bindAnonymousDeclaration(node, 32 /* SymbolFlags.Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { classifiableNames.add(node.name.escapedText); @@ -48092,7 +48191,7 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype"); + var prototypeSymbol = createSymbol(4 /* SymbolFlags.Property */ | 4194304 /* SymbolFlags.Prototype */, "prototype"); var symbolExport = symbol.exports.get(prototypeSymbol.escapedName); if (symbolExport) { if (node.name) { @@ -48105,23 +48204,23 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent; + var possibleVariableDecl = node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node : node.parent.parent; if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !ts.getJSDocTypeTag(node) && - !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) { + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); + bindBlockScopedDeclaration(node, 2 /* SymbolFlags.BlockScopedVariable */, 111551 /* SymbolFlags.BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -48133,72 +48232,72 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) { + if (node.kind === 340 /* SyntaxKind.JSDocParameterTag */ && container.kind !== 323 /* SyntaxKind.JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) { + if (inStrictMode && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); + bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } if (currentFlow) { node.flowNode = currentFlow; } checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.escapedText : "__function" /* Function */; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__function" /* InternalSymbolName.Function */; + return bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { node.flowNode = currentFlow; } return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* InternalSymbolName.Computed */) : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function getInferTypeContainer(node) { @@ -48212,45 +48311,45 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } - else if (node.parent.kind === 190 /* InferType */) { + else if (node.parent.kind === 190 /* SyntaxKind.InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 + bindAnonymousDeclaration(node, 262144 /* SymbolFlags.TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); + return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { - if (!(currentFlow.flags & 1 /* Unreachable */)) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) { return false; } if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) || // report error on class declarations - node.kind === 257 /* ClassDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 261 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -48264,9 +48363,9 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 16777216 /* Ambient */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && (!ts.isVariableStatement(node) || - !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); }); } @@ -48290,27 +48389,28 @@ var ts; // Don't remove statements that can validly be used before they appear. return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) && // `var x;` may declare a variable used above - !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); + !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* NodeFlags.Let */ | 2 /* NodeFlags.Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 261 /* ModuleDeclaration */: - return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 260 /* EnumDeclaration */: - return ts.hasSyntacticModifier(s, 2048 /* Const */); + case 261 /* SyntaxKind.ModuleDeclaration */: + return getModuleInstanceState(s) !== 1 /* ModuleInstanceState.Instantiated */; + case 260 /* SyntaxKind.EnumDeclaration */: + return ts.hasSyntacticModifier(s, 2048 /* ModifierFlags.Const */); default: return false; } } function isExportsOrModuleExportsOrAlias(sourceFile, node) { var i = 0; - var q = [node]; - while (q.length && i < 100) { + var q = ts.createQueue(); + q.enqueue(node); + while (!q.isEmpty() && i < 100) { i++; - node = q.shift(); + node = q.dequeue(); if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } @@ -48318,10 +48418,10 @@ var ts; var symbol = lookupSymbolForName(sourceFile, node.escapedText); if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) { var init = symbol.valueDeclaration.initializer; - q.push(init); + q.enqueue(init); if (ts.isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) { - q.push(init.left); - q.push(init.right); + q.enqueue(init.left); + q.enqueue(init.right); } } } @@ -48385,32 +48485,32 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var objectType = type; var objectFlags = objectType.objectFlags; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { visitTypeReference(type); } - if (objectFlags & 32 /* Mapped */) { + if (objectFlags & 32 /* ObjectFlags.Mapped */) { visitMappedType(type); } - if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + if (objectFlags & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { visitInterfaceType(type); } - if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + if (objectFlags & (8 /* ObjectFlags.Tuple */ | 16 /* ObjectFlags.Anonymous */)) { visitObjectType(objectType); } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { visitIndexType(type); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { visitIndexedAccessType(type); } } @@ -48499,7 +48599,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 181 /* TypeQuery */) { + if (d.type && d.type.kind === 181 /* SyntaxKind.TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -48636,16 +48736,16 @@ var ts; // Masks TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask"; TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask"; - })(TypeFacts || (TypeFacts = {})); + })(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {})); var typeofNEFacts = new ts.Map(ts.getEntries({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ + string: 256 /* TypeFacts.TypeofNEString */, + number: 512 /* TypeFacts.TypeofNENumber */, + bigint: 1024 /* TypeFacts.TypeofNEBigInt */, + boolean: 2048 /* TypeFacts.TypeofNEBoolean */, + symbol: 4096 /* TypeFacts.TypeofNESymbol */, + undefined: 524288 /* TypeFacts.NEUndefined */, + object: 8192 /* TypeFacts.TypeofNEObject */, + function: 16384 /* TypeFacts.TypeofNEFunction */ })); var TypeSystemPropertyName; (function (TypeSystemPropertyName) { @@ -48671,7 +48771,7 @@ var ts; CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement"; // e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`, // we need to preserve generic types instead of substituting them for constraints - })(CheckMode || (CheckMode = {})); + })(CheckMode = ts.CheckMode || (ts.CheckMode = {})); var SignatureCheckMode; (function (SignatureCheckMode) { SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback"; @@ -48679,7 +48779,7 @@ var ts; SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes"; SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity"; SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback"; - })(SignatureCheckMode || (SignatureCheckMode = {})); + })(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {})); var IntersectionState; (function (IntersectionState) { IntersectionState[IntersectionState["None"] = 0] = "None"; @@ -48751,10 +48851,10 @@ var ts; IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize"; })(IntrinsicTypeKind || (IntrinsicTypeKind = {})); var intrinsicTypeKinds = new ts.Map(ts.getEntries({ - Uppercase: 0 /* Uppercase */, - Lowercase: 1 /* Lowercase */, - Capitalize: 2 /* Capitalize */, - Uncapitalize: 3 /* Uncapitalize */ + Uppercase: 0 /* IntrinsicTypeKind.Uppercase */, + Lowercase: 1 /* IntrinsicTypeKind.Lowercase */, + Capitalize: 2 /* IntrinsicTypeKind.Capitalize */, + Uncapitalize: 3 /* IntrinsicTypeKind.Uncapitalize */ })); function SymbolLinks() { } @@ -48779,8 +48879,8 @@ var ts; ts.getSymbolId = getSymbolId; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + return moduleState === 1 /* ModuleInstanceState.Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ModuleInstanceState.ConstEnumOnly */); } ts.isInstantiatedModule = isInstantiatedModule; function createTypeChecker(host) { @@ -48795,7 +48895,7 @@ var ts; return; sf.resolvedModules.forEach(function (r) { if (r && r.packageId) - map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name)); + map.set(r.packageId.name, r.extension === ".d.ts" /* Extension.Dts */ || !!map.get(r.packageId.name)); }); }); return map; @@ -48829,7 +48929,7 @@ var ts; var currentNode; var varianceTypeParameter; var emptySymbols = ts.createSymbolTable(); - var arrayVariances = [1 /* Covariant */]; + var arrayVariances = [1 /* VarianceFlags.Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -48843,20 +48943,20 @@ var ts; var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* ObjectFlags.FreshLiteral */; var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); - var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); + var undefinedSymbol = createSymbol(4 /* SymbolFlags.Property */, "undefined"); undefinedSymbol.declarations = []; - var globalThisSymbol = createSymbol(1536 /* Module */, "globalThis", 8 /* Readonly */); + var globalThisSymbol = createSymbol(1536 /* SymbolFlags.Module */, "globalThis", 8 /* CheckFlags.Readonly */); globalThisSymbol.exports = globals; globalThisSymbol.declarations = []; globals.set(globalThisSymbol.escapedName, globalThisSymbol); - var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); - var requireSymbol = createSymbol(4 /* Property */, "require"); + var argumentsSymbol = createSymbol(4 /* SymbolFlags.Property */, "arguments"); + var requireSymbol = createSymbol(4 /* SymbolFlags.Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; // for public members that accept a Node or one of its subtypes, we must guard against @@ -48908,10 +49008,10 @@ var ts; return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined; }, getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, - getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexInfosOfType: getIndexInfosOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexType: function (type) { return getIndexType(type); }, getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, @@ -49006,14 +49106,14 @@ var ts; if (!node) { return undefined; } - if (contextFlags & 4 /* Completions */) { + if (contextFlags & 4 /* ContextFlags.Completions */) { return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); }); } return getContextualType(node, contextFlags); }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); - return node ? getContextualTypeForObjectLiteralElement(node) : undefined; + return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined; }, getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); @@ -49021,19 +49121,19 @@ var ts; }, getContextualTypeForJsxAttribute: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); - return node && getContextualTypeForJsxAttribute(node); + return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined); }, isContextSensitive: isContextSensitive, getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* CheckMode.Normal */); }, getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) { - return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument); + return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* CheckMode.IsForStringLiteralArgumentCompletions */, editingArgument); }, getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* CheckMode.IsForSignatureHelp */); }, getExpandedParameters: getExpandedParameters, hasEffectiveRestParameter: hasEffectiveRestParameter, @@ -49119,7 +49219,7 @@ var ts; getSuggestionForNonexistentExport: getSuggestionForNonexistentExport, getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeFlags.TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -49156,10 +49256,10 @@ var ts; cancellationToken = ct; // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused checkSourceFileWithEagerDiagnostics(file); - ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* NodeCheckFlags.TypeChecked */)); diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); @@ -49227,35 +49327,35 @@ var ts; var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); var subtypeReductionCache = new ts.Map(); + var cachedTypes = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); - var unknownSymbol = createSymbol(4 /* Property */, "unknown"); - var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */); + var unknownSymbol = createSymbol(4 /* SymbolFlags.Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__" /* InternalSymbolName.Resolving */); var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var autoType = createIntrinsicType(1 /* Any */, "any"); - var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var errorType = createIntrinsicType(1 /* Any */, "error"); - var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */); - var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); - var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */); - var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; - var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */); - var stringType = createIntrinsicType(4 /* String */, "string"); - var numberType = createIntrinsicType(8 /* Number */, "number"); - var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); - var falseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); + var anyType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var autoType = createIntrinsicType(1 /* TypeFlags.Any */, "any", 262144 /* ObjectFlags.NonInferrableType */); + var wildcardType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var errorType = createIntrinsicType(1 /* TypeFlags.Any */, "error"); + var unresolvedType = createIntrinsicType(1 /* TypeFlags.Any */, "unresolved"); + var intrinsicMarkerType = createIntrinsicType(1 /* TypeFlags.Any */, "intrinsic"); + var unknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var nonNullUnknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var undefinedType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined", 65536 /* ObjectFlags.ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined") : undefinedType; + var nullType = createIntrinsicType(65536 /* TypeFlags.Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* TypeFlags.Null */, "null", 65536 /* ObjectFlags.ContainsWideningType */); + var stringType = createIntrinsicType(4 /* TypeFlags.String */, "string"); + var numberType = createIntrinsicType(8 /* TypeFlags.Number */, "number"); + var bigintType = createIntrinsicType(64 /* TypeFlags.BigInt */, "bigint"); + var falseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var regularFalseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var trueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); + var regularTrueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); trueType.regularType = regularTrueType; trueType.freshType = trueType; regularTrueType.regularType = regularTrueType; @@ -49265,28 +49365,40 @@ var ts; regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = getUnionType([regularFalseType, regularTrueType]); - var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16384 /* Void */, "void"); - var neverType = createIntrinsicType(131072 /* Never */, "never"); - var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */); - var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); - var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(4096 /* TypeFlags.ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16384 /* TypeFlags.Void */, "void"); + var neverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var silentNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never", 262144 /* ObjectFlags.NonInferrableType */); + var implicitNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* TypeFlags.NonPrimitive */, "object"); var stringOrNumberType = getUnionType([stringType, numberType]); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); - var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }, function () { return "(restrictive mapper)"; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? wildcardType : t; }, function () { return "(permissive mapper)"; }); + var uniqueLiteralType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? uniqueLiteralType : t; }, function () { return "(unique literal mapper)"; }); // replace all type parameters with the unique literal type (disregarding constraints) + var outofbandVarianceMarkerHandler; + var reportUnreliableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true); + } + return t; + }, function () { return "(unmeasurable reporter)"; }); + var reportUnmeasurableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false); + } + return t; + }, function () { return "(unreliable reporter)"; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); - emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + emptyJsxObjectType.objectFlags |= 2048 /* ObjectFlags.JsxAttributes */; + var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType; @@ -49295,7 +49407,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 262144 /* NonInferrableType */; + anyFunctionType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -49303,11 +49415,14 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var markerSuperTypeForCheck = createTypeParameter(); + var markerSubTypeForCheck = createTypeParameter(); + markerSubTypeForCheck.constraint = markerSuperTypeForCheck; + var noTypePredicate = createTypePredicate(1 /* TypePredicateKind.Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true); var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances var noIterationTypes = { @@ -49439,7 +49554,6 @@ var ts; var typeofType = createTypeofType(); var _jsxNamespace; var _jsxFactoryEntity; - var outofbandVarianceMarkerHandler; var subtypeRelation = new ts.Map(); var strictSubtypeRelation = new ts.Map(); var assignableRelation = new ts.Map(); @@ -49459,12 +49573,20 @@ var ts; [".mjs", ".mjs"], [".js", ".js"], [".cjs", ".cjs"], - [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"], + [".tsx", compilerOptions.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" : ".js"], [".jsx", ".jsx"], [".json", ".json"], ]; initializeTypeChecker(); return checker; + function getCachedType(key) { + return key ? cachedTypes.get(key) : undefined; + } + function setCachedType(key, type) { + if (key) + cachedTypes.set(key, type); + return type; + } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -49605,7 +49727,7 @@ var ts; return diagnostic; } function isDeprecatedSymbol(symbol) { - return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */); + return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* NodeFlags.Deprecated */); } function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); @@ -49619,44 +49741,44 @@ var ts; } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = new Symbol(flags | 33554432 /* Transient */, name); + var symbol = new Symbol(flags | 33554432 /* SymbolFlags.Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 111551 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 111550 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 0 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 900095 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 110991 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899503 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 788872 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 110735 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 103359 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 46015 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 78783 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 526824 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 788968 /* TypeAliasExcludes */; - if (flags & 2097152 /* Alias */) - result |= 2097152 /* AliasExcludes */; + if (flags & 2 /* SymbolFlags.BlockScopedVariable */) + result |= 111551 /* SymbolFlags.BlockScopedVariableExcludes */; + if (flags & 1 /* SymbolFlags.FunctionScopedVariable */) + result |= 111550 /* SymbolFlags.FunctionScopedVariableExcludes */; + if (flags & 4 /* SymbolFlags.Property */) + result |= 0 /* SymbolFlags.PropertyExcludes */; + if (flags & 8 /* SymbolFlags.EnumMember */) + result |= 900095 /* SymbolFlags.EnumMemberExcludes */; + if (flags & 16 /* SymbolFlags.Function */) + result |= 110991 /* SymbolFlags.FunctionExcludes */; + if (flags & 32 /* SymbolFlags.Class */) + result |= 899503 /* SymbolFlags.ClassExcludes */; + if (flags & 64 /* SymbolFlags.Interface */) + result |= 788872 /* SymbolFlags.InterfaceExcludes */; + if (flags & 256 /* SymbolFlags.RegularEnum */) + result |= 899327 /* SymbolFlags.RegularEnumExcludes */; + if (flags & 128 /* SymbolFlags.ConstEnum */) + result |= 899967 /* SymbolFlags.ConstEnumExcludes */; + if (flags & 512 /* SymbolFlags.ValueModule */) + result |= 110735 /* SymbolFlags.ValueModuleExcludes */; + if (flags & 8192 /* SymbolFlags.Method */) + result |= 103359 /* SymbolFlags.MethodExcludes */; + if (flags & 32768 /* SymbolFlags.GetAccessor */) + result |= 46015 /* SymbolFlags.GetAccessorExcludes */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + result |= 78783 /* SymbolFlags.SetAccessorExcludes */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + result |= 526824 /* SymbolFlags.TypeParameterExcludes */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + result |= 788968 /* SymbolFlags.TypeAliasExcludes */; + if (flags & 2097152 /* SymbolFlags.Alias */) + result |= 2097152 /* SymbolFlags.AliasExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -49688,13 +49810,13 @@ var ts; function mergeSymbol(target, source, unidirectional) { if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || - (source.flags | target.flags) & 67108864 /* Assignment */) { + (source.flags | target.flags) & 67108864 /* SymbolFlags.Assignment */) { if (source === target) { // This can happen when an export assigned namespace exports something also erroneously exported at the top level // See `declarationFileNoCrashOnExtraExportModifier` for an example return target; } - if (!(target.flags & 33554432 /* Transient */)) { + if (!(target.flags & 33554432 /* SymbolFlags.Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { return source; @@ -49702,7 +49824,7 @@ var ts; target = cloneSymbol(resolvedTarget); } // Javascript static-property-assignment declarations always merge, even though they are also values - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + if (source.flags & 512 /* SymbolFlags.ValueModule */ && target.flags & 512 /* SymbolFlags.ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums target.constEnumOnlyModule = false; } @@ -49725,7 +49847,7 @@ var ts; recordMergedSymbol(target, source); } } - else if (target.flags & 1024 /* NamespaceModule */) { + else if (target.flags & 1024 /* SymbolFlags.NamespaceModule */) { // Do not report an error when merging `var globalThis` with the built-in `globalThis`, // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. @@ -49734,8 +49856,8 @@ var ts; } } else { // error - var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); - var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var isEitherEnum = !!(target.flags & 384 /* SymbolFlags.Enum */ || source.flags & 384 /* SymbolFlags.Enum */); + var isEitherBlockScoped_1 = !!(target.flags & 2 /* SymbolFlags.BlockScopedVariable */ || source.flags & 2 /* SymbolFlags.BlockScopedVariable */); var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -49746,9 +49868,9 @@ var ts; var symbolName_1 = symbolToString(source); // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { - var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile; + var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* Comparison.LessThan */ ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -49791,7 +49913,7 @@ var ts; err.relatedInformation = err.relatedInformation || []; var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName); var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here); - if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; })) + if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* Comparison.EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* Comparison.EqualTo */; })) return "continue"; ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage); }; @@ -49833,7 +49955,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -49842,7 +49964,7 @@ var ts; } // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); - if (mainModule_1.flags & 1920 /* Namespace */) { + if (mainModule_1.flags & 1920 /* SymbolFlags.Namespace */) { // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you @@ -49857,9 +49979,9 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { // We may need to merge the module augmentation's exports into the target symbols of the resolved exports - var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); + var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */); for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) { var _e = _d[_i], key = _e[0], value = _e[1]; if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { @@ -49892,7 +50014,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks()); @@ -49902,17 +50024,17 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { var symbol = getMergedSymbol(symbols.get(name)); if (symbol) { - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors if (target === unknownSymbol || target.flags & meaning) { @@ -49932,8 +50054,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* SymbolFlags.Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* SymbolFlags.Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -49947,7 +50069,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!ts.outFile(compilerOptions)) || isInTypeQuery(usage) || - declaration.flags & 16777216 /* Ambient */) { + declaration.flags & 16777216 /* NodeFlags.Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -49961,17 +50083,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 203 /* BindingElement */) { + if (declaration.kind === 203 /* SyntaxKind.BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 203 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 203 /* SyntaxKind.BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* SyntaxKind.VariableDeclaration */), usage); } - else if (declaration.kind === 254 /* VariableDeclaration */) { + else if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -49985,7 +50107,7 @@ var ts; } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -50001,19 +50123,19 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 275 /* ExportSpecifier */ || (usage.parent.kind === 271 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 275 /* SyntaxKind.ExportSpecifier */ || (usage.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.isExportEquals) { return true; } - if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { + if (!!(usage.flags & 8388608 /* NodeFlags.JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -50028,9 +50150,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 237 /* VariableStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 237 /* SyntaxKind.VariableStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -50058,7 +50180,7 @@ var ts; var initializerOfProperty = propertyDeclaration.initializer === current; if (initializerOfProperty) { if (ts.isStatic(current.parent)) { - if (declaration.kind === 169 /* MethodDeclaration */) { + if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) { return true; } if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { @@ -50073,7 +50195,7 @@ var ts; } } else { - var isDeclarationInstanceProperty = declaration.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(declaration); + var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -50096,19 +50218,19 @@ var ts; return "quit"; } switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 172 /* GetAccessor */: - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -50133,7 +50255,7 @@ var ts; // - optional chaining pre-es2020 // - nullish coalesce pre-es2020 // - spread assignment in binding pattern pre-es2017 - if (target >= 2 /* ES2015 */) { + if (target >= 2 /* ScriptTarget.ES2015 */) { var links = getNodeLinks(functionLocation); if (links.declarationRequiresScopeChange === undefined) { links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false; @@ -50148,30 +50270,30 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: // do not descend into these return false; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !useDefineForClassFields; + return target < 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: // null coalesce and optional chain pre-es2020 produce temporary variables if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) { - return target < 7 /* ES2020 */; + return target < 7 /* ScriptTarget.ES2020 */; } if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) { - return target < 4 /* ES2017 */; + return target < 4 /* ScriptTarget.ES2017 */; } if (ts.isTypeNode(node)) return false; @@ -50224,35 +50346,35 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) { - useResult = result.flags & 262144 /* TypeParameter */ + if (meaning & result.flags & 788968 /* SymbolFlags.Type */ && lastLocation.kind !== 320 /* SyntaxKind.JSDoc */) { + useResult = result.flags & 262144 /* SymbolFlags.TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 164 /* Parameter */ || - lastLocation.kind === 340 /* JSDocParameterTag */ || - lastLocation.kind === 341 /* JSDocReturnTag */ || - lastLocation.kind === 163 /* TypeParameter */ + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || + lastLocation.kind === 340 /* SyntaxKind.JSDocParameterTag */ || + lastLocation.kind === 341 /* SyntaxKind.JSDocReturnTag */ || + lastLocation.kind === 163 /* SyntaxKind.TypeParameter */ // local types not visible outside the function body : false; } - if (meaning & result.flags & 3 /* Variable */) { + if (meaning & result.flags & 3 /* SymbolFlags.Variable */) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } - else if (result.flags & 1 /* FunctionScopedVariable */) { + else if (result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { // parameters are visible only inside function body, parameter list and return type // technically for parameter list case here we might mix parameters and variables declared in function, // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 164 /* Parameter */ || + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 189 /* ConditionalType */) { + else if (location.kind === 189 /* SyntaxKind.ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -50267,17 +50389,17 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols; - if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 305 /* SyntaxKind.SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports.get("default" /* Default */)) { + if (result = moduleExports.get("default" /* InternalSymbolName.Default */)) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { break loop; @@ -50297,13 +50419,13 @@ var ts; // which is not the desired behavior. var moduleExport = moduleExports.get(name); if (moduleExport && - moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 275 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* NamespaceExport */))) { + moduleExport.flags === 2097152 /* SymbolFlags.Alias */ && + (ts.getDeclarationOfKind(moduleExport, 275 /* SyntaxKind.ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* SyntaxKind.NamespaceExport */))) { break; } } // ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs) - if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) { + if (name !== "default" /* InternalSymbolName.Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */))) { if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) { result = undefined; } @@ -50312,12 +50434,12 @@ var ts; } } break; - case 260 /* EnumDeclaration */: - if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) { + case 260 /* SyntaxKind.EnumDeclaration */: + if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* SymbolFlags.EnumMember */)) { break loop; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -50327,20 +50449,21 @@ var ts; if (!ts.isStatic(location)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* SymbolFlags.Value */)) { // Remember the property node, it will be used later to report appropriate error + ts.Debug.assertNode(location, ts.isPropertyDeclaration); propertyWithInvalidInitializer = location; } } } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* SymbolFlags.Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -50355,7 +50478,7 @@ var ts; } break loop; } - if (location.kind === 226 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 226 /* SyntaxKind.ClassExpression */ && meaning & 32 /* SymbolFlags.Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -50363,11 +50486,11 @@ var ts; } } break; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* SyntaxKind.ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* SymbolFlags.Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -50383,39 +50506,39 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error - if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */) { break; } // falls through - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 213 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 213 /* SyntaxKind.FunctionExpression */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } - if (meaning & 16 /* Function */) { + if (meaning & 16 /* SymbolFlags.Function */) { var functionName = location.name; if (functionName && name === functionName.escapedText) { result = location.symbol; @@ -50423,7 +50546,7 @@ var ts; } } break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -50432,7 +50555,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 164 /* Parameter */) { + if (location.parent && location.parent.kind === 164 /* SyntaxKind.Parameter */) { location = location.parent; } // @@ -50447,20 +50570,20 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* SyntaxKind.ClassDeclaration */)) { location = location.parent; } break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -50468,7 +50591,7 @@ var ts; } } break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -50476,8 +50599,8 @@ var ts; } } break; - case 190 /* InferType */: - if (meaning & 262144 /* TypeParameter */) { + case 190 /* SyntaxKind.InferType */: + if (meaning & 262144 /* SymbolFlags.TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { result = location.typeParameter.symbol; @@ -50502,7 +50625,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 305 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 305 /* SyntaxKind.SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -50518,11 +50641,27 @@ var ts; } } } + // The invalid initializer error is needed in two situation: + // 1. When result is undefined, after checking for a missing "this." + // 2. When result is defined + function checkAndReportErrorForInvalidInitializer() { + if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */)) { + // We have a match, but the reference occurred within a property initializer and the identifier also binds + // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed + // with ESNext+useDefineForClassFields because the scope semantics are different. + error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos) + ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor + : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg)); + return true; + } + return false; + } if (!result) { if (nameNotFoundMessage) { addLazyDiagnostic(function () { if (!errorLocation || !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217 + !checkAndReportErrorForInvalidInitializer() && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) && @@ -50530,7 +50669,16 @@ var ts; !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { var suggestion = void 0; - if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { + var suggestedLib = void 0; + // Report missing lib first + if (nameArg) { + suggestedLib = getSuggestedLibForNonExistentName(nameArg); + if (suggestedLib) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib); + } + } + // then spelling suggestions + if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); if (isGlobalScopeAugmentationDeclaration) { @@ -50539,7 +50687,7 @@ var ts; if (suggestion) { var suggestionName = symbolToString(suggestion); var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false); - var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 + var message = meaning === 1920 /* SymbolFlags.Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1; var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName); @@ -50549,16 +50697,9 @@ var ts; } } } - if (!suggestion) { - if (nameArg) { - var lib = getSuggestedLibForNonExistentName(nameArg); - if (lib) { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib); - } - else { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); - } - } + // And then fall back to unspecified "not found" + if (!suggestion && !suggestedLib && nameArg) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); } suggestionCount++; } @@ -50566,12 +50707,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) { - // We have a match, but the reference occurred within a property initializer and the identifier also binds - // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed - // with ESNext+useDefineForClassFields because the scope semantics are different. - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg)); + else if (checkAndReportErrorForInvalidInitializer()) { return undefined; } // Perform extra checks only if error reporting was requested @@ -50589,22 +50725,22 @@ var ts; // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped if (errorLocation && - (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { + (meaning & 2 /* SymbolFlags.BlockScopedVariable */ || + ((meaning & 32 /* SymbolFlags.Class */ || meaning & 384 /* SymbolFlags.Enum */) && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { + if (exportOrLocalSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* SymbolFlags.Class */ || exportOrLocalSymbol.flags & 384 /* SymbolFlags.Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */ && !(originalLocation.flags & 8388608 /* NodeFlags.JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -50616,10 +50752,10 @@ var ts; error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation)); } } - if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { + if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ + var message = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -50633,31 +50769,31 @@ var ts; function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) { if (!typeOnlyDeclaration) return diagnostic; - return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); + return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 214 /* ArrowFunction */ && location.kind !== 213 /* FunctionExpression */) { + if (location.kind !== 214 /* SyntaxKind.ArrowFunction */ && location.kind !== 213 /* SyntaxKind.FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; } // generator functions and async functions are not inlined in control flow when immediately invoked - if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* Async */)) { + if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* ModifierFlags.Async */)) { return true; } return !ts.getImmediatelyInvokedFunctionExpression(location); } function isSelfReferenceLocation(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: // For `namespace N { N; }` + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -50670,7 +50806,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 163 /* TypeParameter */) { + if (decl.kind === 163 /* SyntaxKind.TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); @@ -50714,7 +50850,7 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { + if (expression && resolveEntityName(expression, 64 /* SymbolFlags.Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); return true; } @@ -50726,10 +50862,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -50739,9 +50875,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* SymbolFlags.Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -50760,9 +50896,9 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1920 /* Namespace */)) { + if (meaning & (788968 /* SymbolFlags.Type */ & ~1920 /* SymbolFlags.Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1920 /* SymbolFlags.Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name)); return true; } @@ -50773,14 +50909,14 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) { if (isPrimitiveTypeName(name)) { if (isExtendedByInterface(errorLocation)) { error(errorLocation, ts.Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, ts.unescapeLeadingUnderscores(name)); @@ -50790,8 +50926,8 @@ var ts; } return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) { var rawName = ts.unescapeLeadingUnderscores(name); if (isES2015OrLaterConstructorName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); @@ -50811,7 +50947,7 @@ var ts; var grandparent = node.parent.parent; var parentOfGrandparent = grandparent.parent; if (grandparent && parentOfGrandparent) { - var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* ExtendsKeyword */; + var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* SyntaxKind.ExtendsKeyword */; var isInterface = ts.isInterfaceDeclaration(parentOfGrandparent); return isExtending && isInterface; } @@ -50823,7 +50959,7 @@ var ts; }); if (container && container.members.length === 1) { var type = getDeclaredTypeOfSymbol(symbol); - return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true); + return !!(type.flags & 1048576 /* TypeFlags.Union */) && allTypesAssignableToKind(type, 384 /* TypeFlags.StringOrNumberLiteral */, /*strict*/ true); } return false; } @@ -50840,15 +50976,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -50858,29 +50994,29 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { var _a; - ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); - if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */)); + if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); - if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); - if (result.flags & 2 /* BlockScopedVariable */) { + if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } - else if (result.flags & 32 /* Class */) { + else if (result.flags & 32 /* SymbolFlags.Class */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } - else if (result.flags & 256 /* RegularEnum */) { + else if (result.flags & 256 /* SymbolFlags.RegularEnum */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } else { - ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */)); if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } @@ -50901,13 +51037,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.parent; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -50932,24 +51068,24 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ - || node.kind === 264 /* NamespaceExportDeclaration */ - || node.kind === 267 /* ImportClause */ && !!node.name - || node.kind === 268 /* NamespaceImport */ - || node.kind === 274 /* NamespaceExport */ - || node.kind === 270 /* ImportSpecifier */ - || node.kind === 275 /* ExportSpecifier */ - || node.kind === 271 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) - || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name + || node.kind === 268 /* SyntaxKind.NamespaceImport */ + || node.kind === 274 /* SyntaxKind.NamespaceExport */ + || node.kind === 270 /* SyntaxKind.ImportSpecifier */ + || node.kind === 275 /* SyntaxKind.ExportSpecifier */ + || node.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.exportAssignmentIsAlias(node) + || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 297 /* ShorthandPropertyAssignment */ - || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) - || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent); + || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) + || node.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -50962,7 +51098,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -50975,7 +51111,7 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var isExport = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */; + var isExport = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */; var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; @@ -50987,14 +51123,14 @@ var ts; } } function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) { - var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportValue = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node)); } function getUsageModeForExpression(usage) { return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined; @@ -51004,7 +51140,7 @@ var ts; } function isOnlyImportedAsDefault(usage) { var usageMode = getUsageModeForExpression(usage); - return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */); + return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Extension.Json */); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) { var usageMode = file && getUsageModeForExpression(usage); @@ -51021,7 +51157,7 @@ var ts; // Declaration files (and ambient modules) if (!file || file.isDeclarationFile) { // Definitely cannot have a synthetic default if they have a syntactic default member specified - var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration + var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) { return false; } @@ -51053,7 +51189,7 @@ var ts; exportDefaultSymbol = moduleSymbol; } else { - exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); + exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias); } var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier); @@ -51061,7 +51197,7 @@ var ts; if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) { if (hasExportAssignmentSymbol(moduleSymbol)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; - var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportAssignment = exportEqualsSymbol.valueDeclaration; var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName); if (exportAssignment) { @@ -51089,12 +51225,12 @@ var ts; } else { var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); + var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */); if (exportStar) { var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) { var _a, _b; return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && - ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); + ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */))); }); if (defaultExport) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default)); @@ -51138,7 +51274,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -51153,7 +51289,7 @@ var ts; return result; } function getExportOfModule(symbol, name, specifier, dontResolveAlias) { - if (symbol.flags & 1536 /* Module */) { + if (symbol.flags & 1536 /* SymbolFlags.Module */) { var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); @@ -51161,7 +51297,7 @@ var ts; } } function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); @@ -51177,7 +51313,7 @@ var ts; if (!ts.isIdentifier(name)) { return undefined; } - var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); + var suppressInteropError = name.escapedText === "default" /* InternalSymbolName.Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -51186,7 +51322,7 @@ var ts; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true); } else { @@ -51195,7 +51331,7 @@ var ts; // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); - if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { + if (symbolFromModule === undefined && name.escapedText === "default" /* InternalSymbolName.Default */) { var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -51216,7 +51352,7 @@ var ts; } } else { - if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)) { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { @@ -51233,7 +51369,7 @@ var ts; var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { - var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); + var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportedEqualsSymbol) { getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); @@ -51313,19 +51449,15 @@ var ts; if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { return undefined; } - var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } - function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { - var expression = node.initializer; - return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); - } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -51333,31 +51465,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: - case 254 /* VariableDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 270 /* ImportSpecifier */: - case 203 /* BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 275 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, dontRecursivelyResolve); + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 297 /* ShorthandPropertyAssignment */: - return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 296 /* PropertyAssignment */: - return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 296 /* SyntaxKind.PropertyAssignment */: + return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve); + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -51368,16 +51500,16 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); + return (symbol.flags & (2097152 /* SymbolFlags.Alias */ | excludes)) === 2097152 /* SymbolFlags.Alias */ || !!(symbol.flags & 2097152 /* SymbolFlags.Alias */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */); } function resolveSymbol(symbol, dontResolveAlias) { return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.aliasTarget) { links.aliasTarget = resolvingSymbol; @@ -51442,7 +51574,7 @@ var ts; function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) { var _a, _b, _c; if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) { - var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */)) !== null && _b !== void 0 ? _b : target; + var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)) !== null && _b !== void 0 ? _b : target; var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false; } @@ -51450,7 +51582,7 @@ var ts; } /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */ function getTypeOnlyAliasDeclaration(symbol) { - if (!(symbol.flags & 2097152 /* Alias */)) { + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) { return undefined; } var links = getSymbolLinks(symbol); @@ -51461,7 +51593,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); + ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -51482,7 +51614,7 @@ var ts; // position. if (ts.isInternalModuleImportEqualsDeclaration(node)) { var target = resolveSymbol(symbol); - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // import foo = checkExpressionCached(node.moduleReference); } @@ -51505,22 +51637,22 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* SyntaxKind.Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 161 /* QualifiedName */) { - return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + if (entityName.kind === 79 /* SyntaxKind.Identifier */ || entityName.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + return resolveEntityName(entityName, 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 265 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { - return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */); + return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); } function getContainingQualifiedNameNode(node) { while (ts.isQualifiedName(node.parent)) { @@ -51530,7 +51662,7 @@ var ts; } function tryGetQualifiedNameAsValue(node) { var left = ts.getFirstIdentifier(node); - var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true); + var symbol = resolveName(left, left.escapedText, 111551 /* SymbolFlags.Value */, undefined, left, /*isUse*/ true); if (!symbol) { return undefined; } @@ -51551,9 +51683,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* SymbolFlags.Value */ : 0); var symbol; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false)); @@ -51561,9 +51693,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 161 /* QualifiedName */ || name.kind === 206 /* PropertyAccessExpression */) { - var left = name.kind === 161 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 161 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 161 /* SyntaxKind.QualifiedName */ || name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var left = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.left : name.expression; + var right = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -51597,7 +51729,7 @@ var ts; } var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name); var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet - && (meaning & 788968 /* Type */) + && (meaning & 788968 /* SymbolFlags.Type */) && containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName); @@ -51605,8 +51737,8 @@ var ts; error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName)); return undefined; } - if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) { - var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */)); + if (meaning & 1920 /* SymbolFlags.Namespace */ && ts.isQualifiedName(name.parent)) { + var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* SymbolFlags.Type */)); if (exportedTypeSymbol) { error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText)); return undefined; @@ -51620,8 +51752,8 @@ var ts; else { throw ts.Debug.assertNever(name, "Unknown entity name kind."); } - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 271 /* ExportAssignment */)) { + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* SymbolFlags.Alias */ || name.parent.kind === 271 /* SyntaxKind.ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -51641,7 +51773,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* NodeFlags.JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -51662,7 +51794,7 @@ var ts; } if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) && ts.isBinaryExpression(host.parent.parent) && - ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { // X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration var symbol = getSymbolOfNode(host.parent.parent.left); if (symbol) { @@ -51693,7 +51825,7 @@ var ts; */ function getExpandoSymbol(symbol) { var decl = symbol.valueDeclaration; - if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* SymbolFlags.TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { return undefined; } var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); @@ -51760,7 +51892,40 @@ var ts; // An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of // normal mode restrictions if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { - error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); + if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) { + // ImportEquals in a ESM file resolving to another ESM file + error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference); + } + else { + // CJS file resolving to an ESM file + var diagnosticDetails = void 0; + var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName); + if (ext === ".ts" /* Extension.Ts */ || ext === ".js" /* Extension.Js */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".jsx" /* Extension.Jsx */) { + var scope = currentSourceFile.packageJsonScope; + var targetExt = ext === ".ts" /* Extension.Ts */ ? ".mts" /* Extension.Mts */ : ext === ".js" /* Extension.Js */ ? ".mjs" /* Extension.Mjs */ : undefined; + if (scope && !scope.packageJsonContent.type) { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, targetExt, ts.combinePaths(scope.packageDirectory, "package.json")); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0, ts.combinePaths(scope.packageDirectory, "package.json")); + } + } + else { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, targetExt); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module); + } + } + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, ts.chainDiagnosticMessages(diagnosticDetails, ts.Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference))); + } } } // merged symbol is module declaration symbol combined with all augmentations @@ -51825,12 +51990,12 @@ var ts; * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (moduleKind >= ts.ModuleKind.ES2015) { - replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js"; + replacedImportSource += tsExtension === ".mts" /* Extension.Mts */ ? ".mjs" : tsExtension === ".cts" /* Extension.Cts */ ? ".cjs" : ".js"; } error(errorNode, diag, tsExtension, replacedImportSource); } else if (!compilerOptions.resolveJsonModule && - ts.fileExtensionIs(moduleReference, ".json" /* Json */) && + ts.fileExtensionIs(moduleReference, ".json" /* Extension.Json */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); @@ -51877,27 +52042,27 @@ var ts; } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { - var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */), dontResolveAlias); var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* SymbolFlags.Alias */) { return exported; } var links = getSymbolLinks(exported); if (links.cjsExportMerged) { return links.cjsExportMerged; } - var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); - merged.flags = merged.flags | 512 /* ValueModule */; + var merged = exported.flags & 33554432 /* SymbolFlags.Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* SymbolFlags.ValueModule */; if (merged.exports === undefined) { merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { - if (name === "export=" /* ExportEquals */) + if (name === "export=" /* InternalSymbolName.ExportEquals */) return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); @@ -51911,7 +52076,7 @@ var ts; var _a; var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -51930,12 +52095,12 @@ var ts; var targetFile = (_a = moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat); if (ts.getESModuleInterop(compilerOptions) || isEsmCjsRef) { - var sigs = getSignaturesOfStructuredType(type, 0 /* Call */); + var sigs = getSignaturesOfStructuredType(type, 0 /* SignatureKind.Call */); if (!sigs || !sigs.length) { - sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); + sigs = getSignaturesOfStructuredType(type, 1 /* SignatureKind.Construct */); } if ((sigs && sigs.length) || - getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true) || + getPropertyOfType(type, "default" /* InternalSymbolName.Default */, /*skipObjectFunctionPropertyAugment*/ true) || isEsmCjsRef) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); @@ -51967,7 +52132,7 @@ var ts; return result; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; + return moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -52019,15 +52184,15 @@ var ts; return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; } function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { - return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || - ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ || + return !(resolvedExternalModuleType.flags & 131068 /* TypeFlags.Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* ObjectFlags.Class */ || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path isArrayType(resolvedExternalModuleType) || isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : - symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { @@ -52042,7 +52207,7 @@ var ts; if (!source) return; source.forEach(function (sourceSymbol, id) { - if (id === "default" /* Default */) + if (id === "default" /* InternalSymbolName.Default */) return; var targetSymbol = target.get(id); if (!targetSymbol) { @@ -52077,7 +52242,7 @@ var ts; } var symbols = new ts.Map(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports.get("__export" /* ExportStar */); + var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */); if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); @@ -52166,21 +52331,21 @@ var ts; function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) { var container = getParentOfSymbol(symbol); // Type parameters end up in the `members` lists but are not externally visible - if (container && !(symbol.flags & 262144 /* TypeParameter */)) { + if (container && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && - getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */, /*externalOnly*/ false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope } // we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type // which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`) var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) - && container.flags & 788968 /* Type */ - && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ - && meaning === 111551 /* Value */ + && container.flags & 788968 /* SymbolFlags.Type */ + && getDeclaredTypeOfSymbol(container).flags & 524288 /* TypeFlags.Object */ + && meaning === 111551 /* SymbolFlags.Value */ ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { return ts.forEachEntry(t, function (s) { if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { @@ -52204,7 +52369,7 @@ var ts; return getSymbolOfNode(d.parent.parent); } } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { return getSymbolOfNode(ts.getSourceFileOfNode(d)); } @@ -52225,7 +52390,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations); - if (meaning & 111551 /* Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { + if (meaning & 111551 /* SymbolFlags.Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) { return getSymbolOfNode(firstDecl.parent); } @@ -52233,7 +52398,7 @@ var ts; } function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) { var fileSymbol = getExternalModuleContainer(d); - var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); + var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } function getAliasForSymbolInContainer(container, symbol) { @@ -52243,7 +52408,7 @@ var ts; } // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return // the container itself as the alias for the symbol - var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + var exportEquals = container.exports && container.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { return container; } @@ -52267,17 +52432,17 @@ var ts; } } function getExportSymbolOfValueSymbolIfExported(symbol) { - return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 && symbol.exportSymbol || symbol); + return getMergedSymbol(symbol && (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol, includeTypeOnlyMembers) { - return !!(symbol.flags & 111551 /* Value */ || - symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); + return !!(symbol.flags & 111551 /* SymbolFlags.Value */ || + symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 171 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -52300,7 +52465,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(524288 /* Object */); + var type = createType(524288 /* TypeFlags.Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -52314,7 +52479,7 @@ var ts; return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { - var type = createType(262144 /* TypeParameter */); + var type = createType(262144 /* TypeFlags.TypeParameter */); if (symbol) type.symbol = symbol; return type; @@ -52324,11 +52489,11 @@ var ts; // with at least two underscores. The @ character indicates that the name is denoted by a well known ES // Symbol instance and the # character indicates that the name is a PrivateIdentifier. function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */ && - name.charCodeAt(2) !== 35 /* hash */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 64 /* CharacterCodes.at */ && + name.charCodeAt(2) !== 35 /* CharacterCodes.hash */; } function getNamedMembers(members) { var result; @@ -52360,14 +52525,14 @@ var ts; return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) { - return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); + return setStructuredTypeMembers(createObjectType(16 /* ObjectFlags.Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); } function getResolvedTypeWithoutAbstractConstructSignatures(type) { if (type.constructSignatures.length === 0) return type; if (type.objectTypeWithoutAbstractConstructSignatures) return type.objectTypeWithoutAbstractConstructSignatures; - var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); }); + var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (type.constructSignatures === constructSignatures) return type; var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos); @@ -52385,12 +52550,12 @@ var ts; } } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred @@ -52399,9 +52564,9 @@ var ts; return { value: result }; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -52412,7 +52577,7 @@ var ts; var table_1; // TODO: Should this filtered table be cached in some way? (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { - if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) { (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); @@ -52431,7 +52596,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); } @@ -52442,7 +52607,7 @@ var ts; var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -52486,9 +52651,9 @@ var ts; } // Check if symbol is any of the aliases in scope var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" /* ExportEquals */ - && symbolFromSymbolTable.escapedName !== "default" /* Default */ + if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ + && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */ && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) @@ -52496,7 +52661,7 @@ var ts; && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -52540,7 +52705,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -52555,10 +52720,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: continue; default: return false; @@ -52569,16 +52734,16 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* SymbolFlags.Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* SymbolFlags.Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) { var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ false); - return access.accessibility === 0 /* Accessible */; + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) { if (!ts.length(symbols)) @@ -52608,7 +52773,7 @@ var ts; } // Any meaning of a module symbol is always accessible via an `import` type return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } } @@ -52632,14 +52797,14 @@ var ts; } if (earlyModuleBail) { return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } if (hadAccessibleChain) { return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined, + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */) : undefined, }; } } @@ -52668,7 +52833,7 @@ var ts; if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { - accessibility: 2 /* CannotBeNamed */, + accessibility: 2 /* SymbolAccessibility.CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule), errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, @@ -52677,28 +52842,28 @@ var ts; } // Just a local name that is not accessible return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } - return { accessibility: 0 /* Accessible */ }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } function getExternalModuleContainer(declaration) { var node = ts.findAncestor(declaration, hasExternalModuleSymbol); return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* SyntaxKind.Identifier */; }), getIsDeclarationVisible)) { return undefined; } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { var _a, _b; if (!isDeclarationVisible(declaration)) { @@ -52706,27 +52871,39 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !ts.hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + !ts.hasSyntacticModifier(anyImportSyntax, 1 /* ModifierFlags.Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); } else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) && - !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* ModifierFlags.Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); } else if (ts.isLateVisibilityPaintedStatement(declaration) // unexported top-level statement - && !ts.hasSyntacticModifier(declaration, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration, 1 /* ModifierFlags.Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement - && ts.isVariableDeclaration(declaration.parent.parent) - && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) - && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) - && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { - return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + else if (ts.isBindingElement(declaration)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement + && ts.isVariableDeclaration(declaration.parent.parent) + && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* ModifierFlags.Export */) + && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) + && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + } + else if (symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement); + if (ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */)) { + return true; + } + if (!isDeclarationVisible(variableStatement.parent)) { + return false; + } + return addVisibleAlias(declaration, variableStatement); + } } // Declaration is not visible return false; @@ -52747,86 +52924,86 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 181 /* TypeQuery */ || - entityName.parent.kind === 228 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || - entityName.parent.kind === 162 /* ComputedPropertyName */) { + if (entityName.parent.kind === 181 /* SyntaxKind.TypeQuery */ || + entityName.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || + entityName.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Typeof value - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } - else if (entityName.kind === 161 /* QualifiedName */ || entityName.kind === 206 /* PropertyAccessExpression */ || - entityName.parent.kind === 265 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 161 /* SyntaxKind.QualifiedName */ || entityName.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 788968 /* Type */; + meaning = 788968 /* SymbolFlags.Type */; } var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); - if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) { - return { accessibility: 0 /* Accessible */ }; + if (symbol && symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && meaning & 788968 /* SymbolFlags.Type */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } - if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) { - return { accessibility: 0 /* Accessible */ }; + if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) { - if (flags === void 0) { flags = 4 /* AllowAnyNodeKind */; } - var nodeFlags = 70221824 /* IgnoreErrors */; - if (flags & 2 /* UseOnlyExternalAliasing */) { - nodeFlags |= 128 /* UseOnlyExternalAliasing */; + if (flags === void 0) { flags = 4 /* SymbolFormatFlags.AllowAnyNodeKind */; } + var nodeFlags = 70221824 /* NodeBuilderFlags.IgnoreErrors */; + if (flags & 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */) { + nodeFlags |= 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */; } - if (flags & 1 /* WriteTypeParametersOrArguments */) { - nodeFlags |= 512 /* WriteTypeParametersInQualifiedName */; + if (flags & 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */) { + nodeFlags |= 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; } - if (flags & 8 /* UseAliasDefinedOutsideCurrentScope */) { - nodeFlags |= 16384 /* UseAliasDefinedOutsideCurrentScope */; + if (flags & 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */) { + nodeFlags |= 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; } - if (flags & 16 /* DoNotIncludeSymbolChain */) { - nodeFlags |= 134217728 /* DoNotIncludeSymbolChain */; + if (flags & 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */) { + nodeFlags |= 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */; } - var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; + var builder = flags & 4 /* SymbolFormatFlags.AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SyntaxKind.SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; - if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructorType */ : 179 /* FunctionType */; + if (flags & 262144 /* TypeFormatFlags.WriteArrowStyleSignature */) { + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 180 /* SyntaxKind.ConstructorType */ : 179 /* SyntaxKind.FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructSignature */ : 174 /* CallSignature */; + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 175 /* SyntaxKind.ConstructSignature */ : 174 /* SyntaxKind.CallSignature */; } - var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); + var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* EmitHint.Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } - var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */; - var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer); + var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* TypeFormatFlags.NoTruncation */; + var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | (noTruncation ? 1 /* NodeBuilderFlags.NoTruncation */ : 0), writer); if (typeNode === undefined) return ts.Debug.fail("should always get typenode"); // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. @@ -52834,7 +53011,7 @@ var ts; var options = { removeComments: type !== unresolvedType }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { @@ -52852,17 +53029,17 @@ var ts; return [leftStr, rightStr]; } function getTypeNameForErrorDisplay(type) { - return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); + return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { - if (flags === void 0) { flags = 0 /* None */; } - return flags & 814775659 /* NodeBuilderFlagsMask */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + return flags & 848330091 /* TypeFormatFlags.NodeBuilderFlagsMask */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); + return !!type.symbol && !!(type.symbol.flags & 32 /* SymbolFlags.Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* TypeFlags.Object */) && !!(ts.getObjectFlags(type) & 16777216 /* ObjectFlags.IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -52896,12 +53073,12 @@ var ts; }; function withContext(enclosingDeclaration, flags, tracker, cb) { var _a, _b; - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0); var context = { enclosingDeclaration: enclosingDeclaration, - flags: flags || 0 /* None */, + flags: flags || 0 /* NodeBuilderFlags.None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache), @@ -52923,7 +53100,7 @@ var ts; }; context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); - if (context.truncating && context.flags & 1 /* NoTruncation */) { + if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) { (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); } return context.encounteredError ? undefined : resultingNode; @@ -52958,62 +53135,68 @@ var ts; function checkTruncationLength(context) { if (context.truncating) return context.truncating; - return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); + return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { + var savedFlags = context.flags; + var typeNode = typeToTypeNodeWorker(type, context); + context.flags = savedFlags; + return typeNode; + } + function typeToTypeNodeWorker(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } - var inTypeAlias = context.flags & 8388608 /* InTypeAlias */; - context.flags &= ~8388608 /* InTypeAlias */; + var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */; + context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */; if (!type) { - if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (!(context.flags & 536870912 /* NoTypeReduction */)) { + if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) { type = getReducedType(type); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { if (type.aliasSymbol) { return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); } if (type === unresolvedType) { - return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved"); + return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved"); } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */); } - if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + if (type.flags & 2 /* TypeFlags.Unknown */) { + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } - if (type.flags & 4 /* String */) { + if (type.flags & 4 /* TypeFlags.String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(158 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */); } - if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { + if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */); } - if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { + if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */); if (getDeclaredTypeOfSymbol(parentSymbol) === type) { return parentName; } var memberName = ts.symbolName(type.symbol); - if (ts.isIdentifierText(memberName, 0 /* ES3 */)) { + if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) { return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); } if (ts.isImportTypeNode(parentName)) { @@ -53027,66 +53210,66 @@ var ts; return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + if (type.flags & 1056 /* TypeFlags.EnumLike */) { + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - if (type.flags & 128 /* StringLiteral */) { + if (type.flags & 128 /* TypeFlags.StringLiteral */) { context.approximateLength += (type.value.length + 2); - return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */)); + return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */)), 16777216 /* EmitFlags.NoAsciiEscaping */)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); + return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value))); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse()); } - if (type.flags & 8192 /* UniqueESSymbol */) { - if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + if (!(context.flags & 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 111551 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* SymbolFlags.Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(154 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(154 /* SyntaxKind.UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */)); } - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */); } - if (type.flags & 32768 /* Undefined */) { + if (type.flags & 32768 /* TypeFlags.Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { context.approximateLength += 4; return ts.factory.createLiteralTypeNode(ts.factory.createNull()); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */); } - if (type.flags & 4096 /* ESSymbol */) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */); } - if (type.flags & 67108864 /* NonPrimitive */) { + if (type.flags & 67108864 /* TypeFlags.NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(148 /* SyntaxKind.ObjectKeyword */); } if (ts.isThisTypeParameter(type)) { - if (context.flags & 4194304 /* InObjectTypeLiteral */) { - if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { + if (context.flags & 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */) { + if (!context.encounteredError && !(context.flags & 32768 /* NodeBuilderFlags.AllowThisInObjectLiteral */)) { context.encounteredError = true; } if (context.tracker.reportInaccessibleThisError) { @@ -53096,22 +53279,22 @@ var ts; context.approximateLength += 4; return ts.factory.createThisTypeNode(); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* SymbolFlags.Class */)) return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes); if (ts.length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) { return ts.factory.createArrayTypeNode(typeArgumentNodes[0]); } - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); } var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & 4 /* ObjectFlags.Reference */) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } - if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ || objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); var constraintNode = void 0; var constraint = getConstraintOfTypeParameter(type); @@ -53128,8 +53311,8 @@ var ts; } return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode)); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 262144 /* TypeParameter */ && + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name_2 = typeParameterToName(type, context); context.approximateLength += ts.idText(name_2).length; @@ -53137,43 +53320,43 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? - (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; + var name = (type === markerSuperTypeForCheck || type === markerSubTypeForCheck) && varianceTypeParameter && varianceTypeParameter.symbol ? + (type === markerSubTypeForCheck ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined); } - if (type.flags & 1048576 /* Union */ && type.origin) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.origin) { type = type.origin; } - if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { - var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + var types = type.flags & 1048576 /* TypeFlags.Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - return type.flags & 1048576 /* Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); } else { - if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!context.encounteredError && !(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } return undefined; // TODO: GH#18217 } } - if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, indexTypeNode); } - if (type.flags & 134217728 /* TemplateLiteral */) { + if (type.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts_1 = type.texts; var types_1 = type.types; var templateHead = ts.factory.createTemplateHead(texts_1[0]); @@ -53181,32 +53364,32 @@ var ts; context.approximateLength += 2; return ts.factory.createTemplateLiteralType(templateHead, templateSpans); } - if (type.flags & 268435456 /* StringMapping */) { + if (type.flags & 268435456 /* TypeFlags.StringMapping */) { var typeNode = typeToTypeNodeHelper(type.type, context); - return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, [typeNode]); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); }); } - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return typeToTypeNodeHelper(type.baseType, context); } return ts.Debug.fail("Should be unreachable."); function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); context.approximateLength += 15; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeFlags.TypeParameter */)) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); var newTypeVariable = ts.factory.createTypeReferenceNode(name); context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type - var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.mapper); var saveInferTypeParameters_1 = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); @@ -53223,7 +53406,7 @@ var ts; // On the other hand, // checkType extends infer T extends checkType ? T extends extendsType ? trueType : falseType : never; // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS. - return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -53235,9 +53418,9 @@ var ts; } function typeToTypeNodeOrCircularityElision(type) { var _a, _b, _c; - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) { - if (!(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + if (!(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b); } @@ -53247,8 +53430,12 @@ var ts; } return typeToTypeNodeHelper(type, context); } + function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) { + return isMappedTypeWithKeyofConstraintDeclaration(type) + && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */); + } function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -53256,27 +53443,28 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); } - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; - var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined); context.approximateLength += 10; - var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + var result = ts.setEmitFlags(mappedTypeNode, 1 /* EmitFlags.SingleLine */); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { // homomorphic mapped type with a non-homomorphic naive inlining // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting // type stays homomorphic - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName), originalConstraint.flags & 2 /* TypeFlags.Unknown */ ? undefined : typeToTypeNodeHelper(originalConstraint, context))), result, ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } return result; } @@ -53285,16 +53473,16 @@ var ts; var typeId = type.id; var symbol = type.symbol; if (symbol) { - var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = isClassInstanceSide(type) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */; if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ + else if (symbol.flags & 32 /* SymbolFlags.Class */ && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* Accessible */)) || - symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */)) || + symbol.flags & (384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); } @@ -53303,7 +53491,7 @@ var ts; var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 788968 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* SymbolFlags.Type */); } else { return createElidedInformationPlaceholder(context); @@ -53319,26 +53507,26 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var _a; - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* SymbolFlags.Method */) && // typeof static method ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); }); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* SymbolFlags.Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 305 /* SourceFile */ || declaration.parent.kind === 262 /* ModuleBlock */; + return declaration.parent.kind === 305 /* SyntaxKind.SourceFile */ || declaration.parent.kind === 262 /* SyntaxKind.ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + return (!!(context.flags & 4096 /* NodeBuilderFlags.UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively + (!(context.flags & 8 /* NodeBuilderFlags.UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } function visitAndTransformType(type, transform) { var _a, _b; var typeId = type.id; - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : - type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) : + var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */; + var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) : type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : undefined; // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead @@ -53350,7 +53538,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -53409,20 +53597,20 @@ var ts; if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { context.approximateLength += 2; - return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* EmitFlags.SingleLine */); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* SyntaxKind.FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* SyntaxKind.ConstructorType */, context); return signatureNode; } } - var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); }); + var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (ts.some(abstractSignatures)) { var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature); // count the number of type elements excluding abstract constructors @@ -53431,8 +53619,8 @@ var ts; resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per // the logic in `createTypeNodesFromResolvedType`. - (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? - ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* Prototype */); }) : + (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ ? + ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */); }) : ts.length(resolved.properties)); // don't include an empty object literal if there were no other static-side // properties to write, i.e. `abstract class C { }` becomes `abstract new () => {}` @@ -53444,27 +53632,27 @@ var ts; return typeToTypeNodeHelper(getIntersectionType(types), context); } var savedFlags = context.flags; - context.flags |= 4194304 /* InObjectTypeLiteral */; + context.flags |= 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */; var members = createTypeNodesFromResolvedType(resolved); context.flags = savedFlags; var typeLiteralNode = ts.factory.createTypeLiteralNode(members); context.approximateLength += 2; - ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); + ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* NodeBuilderFlags.MultilineObjectLiterals */) ? 0 : 1 /* EmitFlags.SingleLine */); return typeLiteralNode; } function typeReferenceToTypeNode(type) { var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { - if (context.flags & 2 /* WriteArrayAsGenericType */) { + if (context.flags & 2 /* NodeBuilderFlags.WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]); } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, arrayType); } - else if (type.target.objectFlags & 8 /* Tuple */) { - typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); }); + else if (type.target.objectFlags & 8 /* ObjectFlags.Tuple */) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* ElementFlags.Optional */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -53472,7 +53660,7 @@ var ts; if (type.target.labeledElementDeclarations) { for (var i = 0; i < tupleConstituentNodes.length; i++) { var flags = type.target.elementFlags[i]; - tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* Variable */ ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : + tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* ElementFlags.Variable */ ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* ElementFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]); } } @@ -53480,23 +53668,23 @@ var ts; for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) { var flags = type.target.elementFlags[i]; tupleConstituentNodes[i] = - flags & 12 /* Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : - flags & 2 /* Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : + flags & 12 /* ElementFlags.Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : + flags & 2 /* ElementFlags.Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]; } } - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } - if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + if (context.encounteredError || (context.flags & 524288 /* NodeBuilderFlags.AllowEmptyTuple */)) { + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 } - else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && + else if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { @@ -53520,8 +53708,8 @@ var ts; if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_3 = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var ref = symbolToTypeNode(parent, context, 788968 /* SymbolFlags.Type */, typeArgumentSlice); context.flags = flags_3; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -53533,8 +53721,8 @@ var ts; typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); } var flags = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -53598,17 +53786,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* SyntaxKind.CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - if (signature.flags & 4 /* Abstract */) + if (signature.flags & 4 /* SignatureFlags.Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* SyntaxKind.ConstructSignature */, context)); } for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { var info = _e[_d]; - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); } var properties = resolvedType.properties; if (!properties) { @@ -53618,16 +53806,16 @@ var ts; for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) { var propertySymbol = properties_1[_f]; i++; - if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) { - if (propertySymbol.flags & 4194304 /* Prototype */) { + if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) { + if (propertySymbol.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } - if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName)); } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... " + (properties.length - i) + " more ...", /*questionToken*/ undefined, /*type*/ undefined)); + typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... ".concat(properties.length - i, " more ..."), /*questionToken*/ undefined, /*type*/ undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -53638,10 +53826,10 @@ var ts; } function createElidedInformationPlaceholder(context) { context.approximateLength += 3; - if (!(context.flags & 1 /* NoTruncation */)) { + if (!(context.flags & 1 /* NodeBuilderFlags.NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -53651,14 +53839,14 @@ var ts; // Since anonymous types usually come from expressions, this allows us to preserve the output // for deep mappings which likely come from expressions, while truncating those parts which // come from mappings over library functions. - return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) + return !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */) && (ts.contains(context.reverseMappedStack, propertySymbol) || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) - && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* ObjectFlags.Anonymous */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { var _a, _b; - var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); + var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */); var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; @@ -53686,12 +53874,12 @@ var ts; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined; - if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { - var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); + var optionalToken = propertySymbol.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { + var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* TypeFlags.Undefined */); }), 0 /* SignatureKind.Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* SyntaxKind.MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -53705,12 +53893,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -53719,11 +53907,11 @@ var ts; } function preserveCommentsOn(node) { var _a; - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* JSDocPropertyTag */; })) { - var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; }); var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { - ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } } else if (propertySymbol.valueDeclaration) { @@ -53742,12 +53930,12 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", /*typeArguments*/ undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), /*typeArguments*/ undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } } - var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); + var mayHaveNameCollisions = !(context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */); /** Map from type reference identifier text to [type, index in `result` where the type node is] */ var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; var result_5 = []; @@ -53756,7 +53944,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -53781,7 +53969,7 @@ var ts; // type node for each entry by that name with the // `UseFullyQualifiedType` flag enabled. var saveContextFlags = context.flags; - context.flags |= 64 /* UseFullyQualifiedType */; + context.flags |= 64 /* NodeBuilderFlags.UseFullyQualifiedType */; seenNames.forEach(function (types) { if (!ts.arrayIsHomogeneous(types, function (_a, _b) { var a = _a[0]; @@ -53815,21 +54003,21 @@ var ts; if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); } - if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { + if (!indexInfo.type && !(context.flags & 2097152 /* NodeBuilderFlags.AllowEmptyIndexInfoType */)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); - return ts.factory.createIndexSignature(indexInfo.isReadonly ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + return ts.factory.createIndexSignature(indexInfo.isReadonly ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; - var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; + var suppressAny = context.flags & 256 /* NodeBuilderFlags.SuppressAnyReturnType */; if (suppressAny) - context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s + context.flags &= ~256 /* NodeBuilderFlags.SuppressAnyReturnType */; // suppress only toplevel `any`s context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum var typeParameters; var typeArguments; - if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { + if (context.flags & 32 /* NodeBuilderFlags.WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); }); } else { @@ -53837,19 +54025,19 @@ var ts; } var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; // If the expanded parameter list had a variadic in a non-trailing position, don't expand it - var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); - var thisParameter = tryGetThisParameterDeclaration(signature, context); + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* CheckFlags.RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* SyntaxKind.Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var thisParameter = context.flags & 33554432 /* NodeBuilderFlags.OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); } var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(128 /* AssertsKeyword */) : + var assertsModifier = typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined; - var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : + var parameterName = typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* EmitFlags.NoAsciiEscaping */) : ts.factory.createThisTypeNode(); var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode); @@ -53860,28 +54048,28 @@ var ts; returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); } else if (!suppressAny) { - returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 180 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 180 /* SyntaxKind.ConstructorType */) && signature.flags & 4 /* SignatureFlags.Abstract */) { var flags = ts.modifiersToFlags(modifiers); - modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); - } - var node = kind === 174 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 175 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 168 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 169 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 171 /* Constructor */ ? ts.factory.createConstructorDeclaration(modifiers, parameters, /*body*/ undefined) : - kind === 172 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 173 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 176 /* IndexSignature */ ? ts.factory.createIndexSignature(modifiers, parameters, returnTypeNode) : - kind === 317 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 179 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 180 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 256 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 213 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 214 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* ModifierFlags.Abstract */); + } + var node = kind === 174 /* SyntaxKind.CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 175 /* SyntaxKind.ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 168 /* SyntaxKind.MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 169 /* SyntaxKind.MethodDeclaration */ ? ts.factory.createMethodDeclaration(modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 171 /* SyntaxKind.Constructor */ ? ts.factory.createConstructorDeclaration(modifiers, parameters, /*body*/ undefined) : + kind === 172 /* SyntaxKind.GetAccessor */ ? ts.factory.createGetAccessorDeclaration(modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 173 /* SyntaxKind.SetAccessor */ ? ts.factory.createSetAccessorDeclaration(modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 176 /* SyntaxKind.IndexSignature */ ? ts.factory.createIndexSignature(modifiers, parameters, returnTypeNode) : + kind === 317 /* SyntaxKind.JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 179 /* SyntaxKind.FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 180 /* SyntaxKind.ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 213 /* SyntaxKind.FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 214 /* SyntaxKind.ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -53904,7 +54092,7 @@ var ts; } function typeParameterToDeclarationWithConstraint(type, context, constraintNode) { var savedContextFlags = context.flags; - context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic + context.flags &= ~512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic var modifiers = ts.factory.createModifiersFromModifierFlags(getVarianceModifiers(type)); var name = typeParameterToName(type, context); var defaultParameter = getDefaultFromTypeParameter(type); @@ -53918,26 +54106,26 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* SyntaxKind.Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* SyntaxKind.JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && ts.canHaveModifiers(parameterDeclaration) ? ts.map(ts.getModifiers(parameterDeclaration), ts.factory.cloneNode) : undefined; - var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; - var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; + var modifiers = !(context.flags & 8192 /* NodeBuilderFlags.OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && ts.canHaveModifiers(parameterDeclaration) ? ts.map(ts.getModifiers(parameterDeclaration), ts.factory.cloneNode) : undefined; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* CheckFlags.RestParameter */; + var dotDotDotToken = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 161 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* EmitFlags.NoAsciiEscaping */) : + parameterDeclaration.name.kind === 161 /* SyntaxKind.QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* EmitFlags.NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* CheckFlags.OptionalParameter */; + var questionToken = isOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var parameterNode = ts.factory.createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); context.approximateLength += ts.symbolName(parameterSymbol).length + 3; @@ -53963,7 +54151,7 @@ var ts; if (!ts.nodeIsSynthesized(visited)) { visited = ts.factory.cloneNode(visited); } - return ts.setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); + return ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */ | 16777216 /* EmitFlags.NoAsciiEscaping */); } } } @@ -53972,9 +54160,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = ts.getFirstIdentifier(accessExpression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* SymbolFlags.Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -53984,8 +54172,8 @@ var ts; function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) { + var isTypeParameter = symbol.flags & 262144 /* SymbolFlags.TypeParameter */; + if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */) && !(context.flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */)) { chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } @@ -53995,7 +54183,7 @@ var ts; return chain; /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol, meaning, endOfChain) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */)); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */)); var parentSpecifiers; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -54014,8 +54202,8 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { - if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && - getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + if (parent.exports && parent.exports.get("export=" /* InternalSymbolName.ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* InternalSymbolName.ExportEquals */), symbol)) { // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent // No need to lookup an alias for the symbol in itself accessibleSymbolChain = parentChain; @@ -54034,7 +54222,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */))) { // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return; @@ -54064,7 +54252,7 @@ var ts; function typeParametersToTypeParameterDeclarations(symbol, context) { var typeParameterNodes; var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + if (targetSymbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 524288 /* SymbolFlags.TypeAlias */)) { typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); })); } return typeParameterNodes; @@ -54079,11 +54267,11 @@ var ts; } (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId); var typeParameterNodes; - if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { + if (context.flags & 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { var parentSymbol = symbol; var nextSymbol_1 = chain[index + 1]; - if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) { - var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol); + if (ts.getCheckFlags(nextSymbol_1) & 1 /* CheckFlags.Instantiated */) { + var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(parentSymbol) : parentSymbol); typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context); } else { @@ -54103,11 +54291,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context, overrideImportMode) { var _a; - var file = ts.getDeclarationOfKind(symbol, 305 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SyntaxKind.SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -54159,7 +54347,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -54168,8 +54356,8 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var _a, _b, _c, _d; - var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 111551 /* Value */; + var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module + var isTypeOf = meaning === 111551 /* SymbolFlags.Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -54191,7 +54379,7 @@ var ts; if (!specifier) { specifier = getSpecifierForModuleSymbol(chain[0], context); } - if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & 67108864 /* NodeBuilderFlags.AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { var oldSpecifier = specifier; if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set @@ -54253,16 +54441,16 @@ var ts; var parent = chain[index - 1]; var symbolName; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; symbolName = getNameOfSymbolAsWritten(symbol, context); context.approximateLength += (symbolName ? symbolName.length : 0) + 1; - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } else { if (parent && getExportsOfSymbol(parent)) { var exports_2 = getExportsOfSymbol(parent); ts.forEachEntry(exports_2, function (ex, name) { - if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* InternalSymbolName.ExportEquals */) { symbolName = ts.unescapeLeadingUnderscores(name); return true; } @@ -54281,7 +54469,7 @@ var ts; symbolName = getNameOfSymbolAsWritten(symbol, context); } context.approximateLength += symbolName.length + 1; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + if (!(context.flags & 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access @@ -54293,7 +54481,7 @@ var ts; return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName))); } } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; if (index > stopper) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); @@ -54306,9 +54494,9 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context, type) { - var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* SymbolFlags.Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); if (result) { - if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) { + if (result.flags & 262144 /* SymbolFlags.TypeParameter */ && result === type.symbol) { return false; } return true; @@ -54317,23 +54505,23 @@ var ts; } function typeParameterToName(type, context) { var _a, _b; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { return cached; } } - var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 79 /* Identifier */)) { + var result = symbolToName(type.symbol, context, 788968 /* SymbolFlags.Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 79 /* SyntaxKind.Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -54350,7 +54538,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* NodeBuilderFlags.AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -54358,13 +54546,13 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -54376,38 +54564,38 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); } - var canUsePropertyAccess = firstChar === 35 /* hash */ ? + var canUsePropertyAccess = firstChar === 35 /* CharacterCodes.hash */ ? symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) : ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier; } else { - if (firstChar === 91 /* openBracket */) { + if (firstChar === 91 /* CharacterCodes.openBracket */) { symbolName = symbolName.substring(1, symbolName.length - 1); firstChar = symbolName.charCodeAt(0); } var expression = void 0; - if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) { - expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */); + if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* SymbolFlags.EnumMember */)) { + expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* CharacterCodes.singleQuote */); } else if (("" + +symbolName) === symbolName) { expression = ts.factory.createNumericLiteral(+symbolName); } if (!expression) { - expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); expression.symbol = symbol; } return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression); @@ -54436,7 +54624,7 @@ var ts; function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { return ts.factory.createStringLiteral(name, !!singleQuote); @@ -54446,8 +54634,8 @@ var ts; } return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions)); } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* SymbolFlags.Value */)); } } } @@ -54481,7 +54669,7 @@ var ts; 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); + return !(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag @@ -54502,9 +54690,9 @@ var ts; } } var oldFlags = context.flags; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { - context.flags |= 1048576 /* AllowUniqueESSymbolType */; + context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } var result = typeToTypeNodeHelper(type, context); context.flags = oldFlags; @@ -54516,7 +54704,7 @@ var ts; return true; } if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { - return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode; + return getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */) === typeFromTypeNode; } return false; } @@ -54525,7 +54713,7 @@ var ts; var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { var annotated = getTypeFromTypeNode(annotation); - var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + var thisInstantiated = annotated.flags & 262144 /* TypeFlags.TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { @@ -54544,20 +54732,20 @@ var ts; introducesError = true; return { introducesError: introducesError, node: node }; } - var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + var sym = resolveEntityName(leftmost, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); if (sym) { - if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) { + if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */) { introducesError = true; } else { - (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */); + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */); includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym); } if (ts.isIdentifier(node)) { var type = getDeclaredTypeOfSymbol(sym); - var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); + var name = sym.flags & 262144 /* SymbolFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); name.symbol = sym; // for quickinfo, which uses identifier symbol information - return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) }; + return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* EmitFlags.NoAsciiEscaping */) }; } } return { introducesError: introducesError, node: node }; @@ -54575,17 +54763,17 @@ var ts; return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 319 /* SyntaxKind.JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -54599,11 +54787,11 @@ var ts; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; return ts.factory.createPropertySignature( - /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -54618,15 +54806,15 @@ var ts; return ts.factory.createConstructorTypeNode( /*modifiers*/ undefined, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration( /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) { + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } if (ts.isLiteralImportTypeNode(node)) { @@ -54635,7 +54823,7 @@ var ts; nodeSymbol && ( // The import type resolved using jsdoc fallback logic - (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */)) || + (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* SymbolFlags.Type */)) || // The import type had type arguments autofilled by js fallback logic !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); @@ -54650,17 +54838,17 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); function getEffectiveDotDotDotForParameter(p) { - return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined); + return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined); } /** Note that `new:T` parameters are not handled, but should be before calling this function. */ function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -54691,8 +54879,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* SyntaxKind.MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* SyntaxKind.MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -54705,10 +54893,10 @@ var ts; var oldcontext = context; context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); - if (accessibleResult.accessibility === 0 /* Accessible */) { + if (accessibleResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Lookup the root symbol of the chain of refs we'll use to access it and serialize it var chain = lookupSymbolChainWorker(sym, context, meaning); - if (!(sym.flags & 4 /* Property */)) { + if (!(sym.flags & 4 /* SymbolFlags.Property */)) { includePrivateSymbol(chain[0]); } } @@ -54723,16 +54911,16 @@ var ts; void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` }); var addingDeclare = !bundled; - var exportEquals = symbolTable.get("export=" /* ExportEquals */); - if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + var exportEquals = symbolTable.get("export=" /* InternalSymbolName.ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* SymbolFlags.Alias */) { symbolTable = ts.createSymbolTable(); // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) - symbolTable.set("export=" /* ExportEquals */, exportEquals); + symbolTable.set("export=" /* InternalSymbolName.ExportEquals */, exportEquals); } visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 79 /* Identifier */; + return !!node && node.kind === 79 /* SyntaxKind.Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -54749,7 +54937,7 @@ var ts; ns.body && ts.isModuleBlock(ns.body)) { // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments - var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* Export */); }); + var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* ModifierFlags.Export */); }); var name_3 = ns.name; var body = ns.body; if (ts.length(excessExports)) { @@ -54764,9 +54952,9 @@ var ts; results = []; // If the namespace contains no export assignments or declarations, and no declarations flagged with `export`, then _everything_ is exported - // to respect this as the top level, we need to add an `export` modifier to everything - var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); + var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* ModifierFlags.Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); ts.forEach(body.statements, function (s) { - addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + addResult(s, mixinExportFlag_1 ? 1 /* ModifierFlags.Export */ : 0 /* ModifierFlags.None */); // Recalculates the ambient (and export, if applicable from above) flag }); statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true); } @@ -54860,11 +55048,11 @@ var ts; isTypeDeclaration(node); } function addExportModifier(node) { - var flags = (ts.getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; + var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */; return ts.factory.updateModifiers(node, flags); } function removeExportModifier(node) { - var flags = ts.getEffectiveModifierFlags(node) & ~1 /* Export */; + var flags = ts.getEffectiveModifierFlags(node) & ~1 /* ModifierFlags.Export */; return ts.factory.updateModifiers(node, flags); } function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { @@ -54897,12 +55085,11 @@ var ts; if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { var oldContext = context; context = cloneNodeBuilderContext(context); - var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); if (context.reportedDiagnostic) { oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context } context = oldContext; - return result; } } // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias @@ -54917,37 +55104,37 @@ var ts; function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { var _a, _b, _c, _d; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isDefault = symbol.escapedName === "default" /* Default */; - if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */; + if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( context.encounteredError = true; // TODO: Issue error via symbol tracker? return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name } - var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ - || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault; // `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); - var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && - symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && - symbol.escapedName !== "export=" /* ExportEquals */; + var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ && + symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) && + symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); - if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { serializeTypeAlias(symbol, symbolName, modifierFlags); } // Need to skip over export= symbols below - json source files get a single `Property` flagged // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. - if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) - && symbol.escapedName !== "export=" /* ExportEquals */ - && !(symbol.flags & 4194304 /* Prototype */) - && !(symbol.flags & 32 /* Class */) + if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) + && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */) + && !(symbol.flags & 32 /* SymbolFlags.Class */) && !isConstMergedWithNSPrintableAsSignatureMerge) { if (propertyAsAlias) { var createdExport = serializeMaybeAliasAssignment(symbol); @@ -54959,21 +55146,21 @@ var ts; else { var type = getTypeOfSymbol(symbol); var localName = getInternalSymbolName(symbol, symbolName); - if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); } else { // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` - var flags = !(symbol.flags & 2 /* BlockScopedVariable */) + var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) - ? 2 /* Const */ + ? 2 /* NodeFlags.Const */ : undefined : isConstVariable(symbol) - ? 2 /* Const */ - : 1 /* Let */; - var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + ? 2 /* NodeFlags.Const */ + : 1 /* NodeFlags.Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* SymbolFlags.Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; @@ -54984,14 +55171,14 @@ var ts; var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */); - context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* ModifierFlags.None */); + context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* SymbolFlags.Value */); } else { var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~1 /* ModifierFlags.Export */ : modifierFlags); if (name !== localName && !isPrivate) { // We rename the variable declaration we generate for Property symbols since they may have a name which // conflicts with a local declaration. For example, given input: @@ -55016,7 +55203,7 @@ var ts; // To create an export named `g` that does _not_ shadow the local `g` addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* ModifierFlags.None */); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -55024,11 +55211,11 @@ var ts; } } } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { serializeEnum(symbol, symbolName, modifierFlags); } - if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ + if (symbol.flags & 32 /* SymbolFlags.Class */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { @@ -55041,20 +55228,20 @@ var ts; serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } } - if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + if ((symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeModule(symbol, symbolName, modifierFlags); } // The class meaning serialization should handle serializing all interface members - if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) { + if (symbol.flags & 64 /* SymbolFlags.Interface */ && !(symbol.flags & 32 /* SymbolFlags.Class */)) { serializeInterface(symbol, symbolName, modifierFlags); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } - if (symbol.flags & 8388608 /* ExportStar */) { + if (symbol.flags & 8388608 /* SymbolFlags.ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration if (symbol.declarations) { @@ -55063,17 +55250,17 @@ var ts; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); if (!resolvedModule) continue; - addResult(ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + addResult(ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* ModifierFlags.None */); } } } if (needsPostExportDefault) { - addResult(ts.factory.createExportAssignment(/*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + addResult(ts.factory.createExportAssignment(/*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* ModifierFlags.None */); } else if (needsExportDeclaration) { addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* ModifierFlags.None */); } } function includePrivateSymbol(symbol) { @@ -55086,7 +55273,7 @@ var ts; // will throw a wrench in this, since those may have been nested, but we'll need to synthesize them in the outer scope // anyway, as that's the only place the import they translate to is valid. In such a case, we might need to use a unique name // for the moved import; which hopefully the above `getUnusedName` call should produce. - var isExternalImportAlias = !!(symbol.flags & 2097152 /* Alias */) && !ts.some(symbol.declarations, function (d) { + var isExternalImportAlias = !!(symbol.flags & 2097152 /* SymbolFlags.Alias */) && !ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, ts.isExportDeclaration) || ts.isNamespaceExport(d) || (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference)); @@ -55100,23 +55287,23 @@ var ts; // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { - var newModifierFlags = 0 /* None */; + var newModifierFlags = 0 /* ModifierFlags.None */; var enclosingDeclaration_1 = context.enclosingDeclaration && (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && + if (additionalModifierFlags & 1 /* ModifierFlags.Export */ && enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) && canHaveExportModifier(node)) { // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private - newModifierFlags |= 1 /* Export */; + newModifierFlags |= 1 /* ModifierFlags.Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) && + if (addingDeclare && !(newModifierFlags & 1 /* ModifierFlags.Export */) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* NodeFlags.Ambient */)) && (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope - newModifierFlags |= 2 /* Ambient */; + newModifierFlags |= 2 /* ModifierFlags.Ambient */; } - if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { - newModifierFlags |= 512 /* Default */; + if ((additionalModifierFlags & 512 /* ModifierFlags.Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* ModifierFlags.Default */; } if (newModifierFlags) { node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node)); @@ -55132,14 +55319,14 @@ var ts; var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias); var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined); var oldFlags = context.flags; - context.flags |= 8388608 /* InTypeAlias */; + context.flags |= 8388608 /* NodeBuilderFlags.InTypeAlias */; var oldEnclosingDecl = context.enclosingDeclaration; context.enclosingDeclaration = jsdocAliasDecl; var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); - addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; context.enclosingDeclaration = oldEnclosingDecl; } @@ -55150,10 +55337,10 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 174 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 175 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* SignatureKind.Call */, interfaceType, baseType, 174 /* SyntaxKind.CallSignature */); + var constructSignatures = serializeSignatures(1 /* SignatureKind.Construct */, interfaceType, baseType, 175 /* SyntaxKind.ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* SymbolFlags.Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); } @@ -55161,7 +55348,7 @@ var ts; return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); } function isTypeOnlyNamespace(symbol) { - return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); }); } function serializeModule(symbol, symbolName, modifierFlags) { var members = getNamespaceMembersForSerialization(symbol); @@ -55174,14 +55361,14 @@ var ts; // so we don't even have placeholders to fill in. if (ts.length(realMembers)) { var localName = getInternalSymbolName(symbol, symbolName); - serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* SymbolFlags.Function */ | 67108864 /* SymbolFlags.Assignment */))); } if (ts.length(mergedMembers)) { var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); var localName = getInternalSymbolName(symbol, symbolName); var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; }), function (s) { var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); @@ -55196,11 +55383,11 @@ var ts; return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name === targetName ? undefined : targetName, name); })))]); addResult(ts.factory.createModuleDeclaration( - /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* NodeFlags.Namespace */), 0 /* ModifierFlags.None */); } } function serializeEnum(symbol, symbolName, modifierFlags) { - addResult(ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + addResult(ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* ModifierFlags.Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* SymbolFlags.EnumMember */); }), function (p) { // TODO: Handle computed names // I hate that to get the initialized value we need to walk back to the declarations here; but there's no // other way to get the possible const value of an enum member that I'm aware of, as the value is cached @@ -55212,22 +55399,22 @@ var ts; })), modifierFlags); } function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 256 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 256 /* SyntaxKind.FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports - if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + if (!(symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } function getSignatureTextRangeLocation(signature) { if (signature.declaration && signature.declaration.parent) { - if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* AssignmentDeclarationKind.Property */) { return signature.declaration.parent; } // for expressions assigned to `var`s, use the `var` as the text range @@ -55261,7 +55448,7 @@ var ts; // emit akin to the above would be needed. // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace, enclosingDeclaration); fakespace.locals = ts.createSymbolTable(props); fakespace.symbol = props[0].parent; @@ -55281,15 +55468,15 @@ var ts; // replace namespace with synthetic version var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); - var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* InternalSymbolName.Default */))])) : d; }); + var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* ModifierFlags.Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); // namespaces can never be default exported } } function isNamespaceMember(p) { - return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); + return !!(p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */)) || + !(p.flags & 4194304 /* SymbolFlags.Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); } function sanitizeJSDocImplements(clauses) { var result = ts.mapDefined(clauses, function (e) { @@ -55338,7 +55525,7 @@ var ts; var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* SyntaxKind.ImplementsKeyword */, implementsExpressions)], true); var symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from @@ -55364,17 +55551,17 @@ var ts; ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); // When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether // the value is ever initialized with a class or function-like value. For cases where `X` could never be // created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable. var isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && ts.isInJSFile(symbol.valueDeclaration) && - !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); + !ts.some(getSignaturesOfType(staticType, 1 /* SignatureKind.Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? - [ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 171 /* Constructor */); + [ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(8 /* ModifierFlags.Private */), [], /*body*/ undefined)] : + serializeSignatures(1 /* SignatureKind.Construct */, staticType, staticBaseType, 171 /* SyntaxKind.Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -55416,34 +55603,34 @@ var ts; // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === "export=" /* InternalSymbolName.ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match - verbatimTargetName = "default" /* Default */; + verbatimTargetName = "default" /* InternalSymbolName.Default */; } var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 203 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* VariableDeclaration */) { + case 203 /* SyntaxKind.BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* SyntaxKind.VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier( /*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), - /*importClause*/ undefined), 0 /* None */); + /*importClause*/ undefined), 0 /* ModifierFlags.None */); break; } // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 297 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* BinaryExpression */) { + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* SyntaxKind.BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -55453,7 +55640,7 @@ var ts; // import _x = require('y'); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */); + /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* ModifierFlags.None */); // import x = _x.z addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, @@ -55461,48 +55648,48 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // This _specifically_ only exists to handle json declarations - where we make aliases, but since // we emit no declarations for the json document, must not refer to it in the declarations - if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { + if (target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { serializeMaybeAliasAssignment(symbol); break; } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node); + var isLocalImport = !(target.flags & 512 /* SymbolFlags.ValueModule */) && !ts.isVariableDeclaration(node); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createIdentifier(localName), isLocalImport - ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) - : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); + ? symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false) + : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* ModifierFlags.None */); break; - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse - addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* ModifierFlags.None */); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* ModifierFlags.None */); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause( /*isTypeOnly*/ false, @@ -55510,9 +55697,9 @@ var ts; ts.factory.createImportSpecifier( /*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -55520,16 +55707,16 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 221 /* BinaryExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier - if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */ || symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } else { @@ -55543,18 +55730,18 @@ var ts; function serializeExportSpecifier(localName, targetName, specifier) { addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* ModifierFlags.None */); } /** * Returns `true` if an export assignment or declaration was produced for the symbol */ function serializeMaybeAliasAssignment(symbol) { - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return false; } var name = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isExportEquals = name === "export=" /* ExportEquals */; - var isDefault = name === "default" /* Default */; + var isExportEquals = name === "export=" /* InternalSymbolName.ExportEquals */; + var isDefault = name === "default" /* InternalSymbolName.Default */; var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault; // synthesize export = ref // ref should refer to either be a locally scoped symbol which we need to emit, or @@ -55569,7 +55756,7 @@ var ts; // Technically, this is all that's required in the case where the assignment is an entity name expression var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl)); var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; - var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); if (referenced || target) { includePrivateSymbol(referenced || target); } @@ -55582,7 +55769,7 @@ var ts; context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( - /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* SymbolFlags.All */))); } else { if (first_1 === expr && first_1) { @@ -55597,7 +55784,7 @@ var ts; var varName = getUnusedName(name, symbol); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)), 0 /* ModifierFlags.None */); serializeExportSpecifier(name, varName); } } @@ -55612,17 +55799,17 @@ var ts; var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* ModifierFlags.None */ : 1 /* ModifierFlags.Export */); } else { var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* SymbolFlags.Property */ && target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ModifierFlags.Ambient */ + : name === varName ? 1 /* ModifierFlags.Export */ + : 0 /* ModifierFlags.None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -55641,11 +55828,11 @@ var ts; // context source file, and whose property names are all valid identifiers and not late-bound, _and_ // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); - return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + return ts.getObjectFlags(typeToSerialize) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */) && !ts.length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class - !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && - !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* SignatureKind.Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* SignatureKind.Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && @@ -55656,33 +55843,33 @@ var ts; return function serializePropertySymbol(p, isStatic, baseType) { var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); - var isPrivate = !!(modifierFlags & 8 /* Private */); - if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + var isPrivate = !!(modifierFlags & 8 /* ModifierFlags.Private */); + if (isStatic && (p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members return []; } - if (p.flags & 4194304 /* Prototype */ || + if (p.flags & 4194304 /* SymbolFlags.Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) - && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && (p.flags & 16777216 /* SymbolFlags.Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* SymbolFlags.Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* ModifierFlags.Async */) | (isStatic ? 32 /* ModifierFlags.Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); - if (p.flags & 98304 /* Accessor */ && useAccessors) { + if (p.flags & 98304 /* SymbolFlags.Accessor */ && useAccessors) { var result = []; - if (p.flags & 65536 /* SetAccessor */) { + if (p.flags & 65536 /* SymbolFlags.SetAccessor */) { result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], /*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } - if (p.flags & 32768 /* GetAccessor */) { - var isPrivate_1 = modifierFlags & 8 /* Private */; + if (p.flags & 32768 /* SymbolFlags.GetAccessor */) { + var isPrivate_1 = modifierFlags & 8 /* ModifierFlags.Private */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } @@ -55690,17 +55877,17 @@ var ts; } // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints - else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { - return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), + else if (p.flags & (4 /* SymbolFlags.Property */ | 3 /* SymbolFlags.Variable */ | 98304 /* SymbolFlags.Accessor */)) { + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } - if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + if (p.flags & (8192 /* SymbolFlags.Method */ | 16 /* SymbolFlags.Function */)) { var type = getTypeOfSymbol(p); - var signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { - return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); + if (flag & 8 /* ModifierFlags.Private */) { + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, /*type*/ undefined, /*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } @@ -55710,7 +55897,7 @@ var ts; // Each overload becomes a separate method declaration, in order var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, { name: name, - questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + questionToken: p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; @@ -55719,7 +55906,7 @@ var ts; return results_1; } // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -55727,13 +55914,13 @@ var ts; } function serializeSignatures(kind, input, baseType, outputKind) { var signatures = getSignaturesOfType(input, kind); - if (kind === 1 /* Construct */) { + if (kind === 1 /* SignatureKind.Construct */) { if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // No base type, every constructor is empty - elide the extraneous `constructor()` } if (baseType) { // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations - var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + var baseSigs = getSignaturesOfType(baseType, 1 /* SignatureKind.Construct */); if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list } @@ -55754,7 +55941,7 @@ var ts; for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { var s = signatures_4[_i]; if (s.declaration) { - privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */); } } if (privateProtected) { @@ -55789,15 +55976,15 @@ var ts; return results; } function serializeBaseType(t, staticType, rootName) { - var ref = trySerializeAsTypeReference(t, 111551 /* Value */); + var ref = trySerializeAsTypeReference(t, 111551 /* SymbolFlags.Value */); if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context)) - ], 2 /* Const */)); - addResult(statement, 0 /* None */); + ], 2 /* NodeFlags.Const */)); + addResult(statement, 0 /* ModifierFlags.None */); return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), /*typeArgs*/ undefined); } function trySerializeAsTypeReference(t, flags) { @@ -55807,22 +55994,22 @@ var ts; // which we can't write out in a syntactically valid way as an expression if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) { typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); - reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.target.symbol, context, 788968 /* SymbolFlags.Type */); } else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) { - reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */); } if (reference) { return ts.factory.createExpressionWithTypeArguments(reference, typeArgs); } } function serializeImplementedType(t) { - var ref = trySerializeAsTypeReference(t, 788968 /* Type */); + var ref = trySerializeAsTypeReference(t, 788968 /* SymbolFlags.Type */); if (ref) { return ref; } if (t.symbol) { - return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* Type */), /*typeArgs*/ undefined); + return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */), /*typeArgs*/ undefined); } } function getUnusedName(input, symbol) { @@ -55840,7 +56027,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -55849,17 +56036,17 @@ var ts; return input; } function getNameCandidateWorker(symbol, localName) { - if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + if (localName === "default" /* InternalSymbolName.Default */ || localName === "__class" /* InternalSymbolName.Class */ || localName === "__function" /* InternalSymbolName.Function */) { var flags = context.flags; - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; var nameCandidate = getNameOfSymbolAsWritten(symbol, context); context.flags = flags; localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; } - if (localName === "default" /* Default */) { + if (localName === "default" /* InternalSymbolName.Default */) { localName = "_default"; } - else if (localName === "export=" /* ExportEquals */) { + else if (localName === "export=" /* InternalSymbolName.ExportEquals */) { localName = "_exports"; } localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); @@ -55878,14 +56065,14 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined, typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */) // TODO: GH#18217 ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); return writer; } } @@ -55895,10 +56082,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 98304 /* Nullable */)) { - if (t.flags & (512 /* BooleanLiteral */ | 1024 /* EnumLiteral */)) { - var baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 1048576 /* Union */) { + if (!(t.flags & 98304 /* TypeFlags.Nullable */)) { + if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) { + var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 1048576 /* TypeFlags.Union */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -55910,25 +56097,25 @@ var ts; result.push(t); } } - if (flags & 65536 /* Null */) + if (flags & 65536 /* TypeFlags.Null */) result.push(nullType); - if (flags & 32768 /* Undefined */) + if (flags & 32768 /* TypeFlags.Undefined */) result.push(undefinedType); return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 8 /* ModifierFlags.Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 16 /* ModifierFlags.Protected */) { return "protected"; } return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { + if (type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 259 /* TypeAliasDeclaration */) { + if (node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -55936,27 +56123,27 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 262 /* ModuleBlock */ && + node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 305 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 305 /* SyntaxKind.SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\""; + return "\"".concat(ts.escapeString(name, 34 /* CharacterCodes.doubleQuote */), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -55968,9 +56155,9 @@ var ts; * It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`. */ function getNameOfSymbolAsWritten(symbol, context) { - if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && + if (context && symbol.escapedName === "default" /* InternalSymbolName.Default */ && !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default` - (!(context.flags & 16777216 /* InInitialEntityName */) || + (!(context.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default` !symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default` @@ -55984,9 +56171,9 @@ var ts; if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } - if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* Late */)) { + if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */)) { var nameType = getSymbolLinks(symbol).nameType; - if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType && nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { // Computed property name isn't late bound, but has a well-known name type - use name type to generate a symbol name var result = getNameOfSymbolFromNameType(symbol, context); if (result !== undefined) { @@ -55999,17 +56186,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 254 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 226 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 226 /* SyntaxKind.ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -56026,84 +56213,84 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return isDeclarationVisible(node.parent.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 256 /* FunctionDeclaration */: - case 260 /* EnumDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) { + if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) && + !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 164 /* Parameter */: - case 262 /* ModuleBlock */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 178 /* TypeReference */: - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 164 /* SyntaxKind.Parameter */: + case 262 /* SyntaxKind.ModuleBlock */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 178 /* SyntaxKind.TypeReference */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: return false; // Type parameters are always visible - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: // Source file and namespace export are always visible // falls through - case 305 /* SourceFile */: - case 264 /* NamespaceExportDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return false; default: return false; @@ -56112,11 +56299,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 271 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 275 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } var result; var visited; @@ -56140,7 +56327,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol && visited) { if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) { buildVisibleNodeList(importSymbol.declarations); @@ -56189,23 +56376,23 @@ var ts; } function hasType(target, propertyName) { switch (propertyName) { - case 0 /* Type */: + case 0 /* TypeSystemPropertyName.Type */: return !!getSymbolLinks(target).type; - case 5 /* EnumTagType */: + case 5 /* TypeSystemPropertyName.EnumTagType */: return !!(getNodeLinks(target).resolvedEnumType); - case 2 /* DeclaredType */: + case 2 /* TypeSystemPropertyName.DeclaredType */: return !!getSymbolLinks(target).declaredType; - case 1 /* ResolvedBaseConstructorType */: + case 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */: return !!target.resolvedBaseConstructorType; - case 3 /* ResolvedReturnType */: + case 3 /* TypeSystemPropertyName.ResolvedReturnType */: return !!target.resolvedReturnType; - case 4 /* ImmediateBaseConstraint */: + case 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */: return !!target.immediateBaseConstraint; - case 6 /* ResolvedTypeArguments */: + case 6 /* TypeSystemPropertyName.ResolvedTypeArguments */: return !!target.resolvedTypeArguments; - case 7 /* ResolvedBaseTypes */: + case 7 /* TypeSystemPropertyName.ResolvedBaseTypes */: return !!target.baseTypesResolved; - case 8 /* WriteType */: + case 8 /* TypeSystemPropertyName.WriteType */: return !!getSymbolLinks(target).writeType; } return ts.Debug.assertNever(propertyName); @@ -56222,12 +56409,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 255 /* VariableDeclarationList */: - case 270 /* ImportSpecifier */: - case 269 /* NamedImports */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 255 /* SyntaxKind.VariableDeclarationList */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 269 /* SyntaxKind.NamedImports */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: return false; default: return true; @@ -56252,28 +56439,28 @@ var ts; return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType; } function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; + return type && (type.flags & 1 /* TypeFlags.Any */) !== 0; } function isErrorType(type) { // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for // a reference to an unresolved symbol. We want those to behave like the errorType. - return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol); + return type === errorType || !!(type.flags & 1 /* TypeFlags.Any */ && type.aliasSymbol); } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node, checkMode) { - if (checkMode !== 0 /* Normal */) { + if (checkMode !== 0 /* CheckMode.Normal */) { return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (source.flags & 131072 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); + if (source.flags & 131072 /* TypeFlags.Never */) { return emptyObjectType; } - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); @@ -56281,9 +56468,9 @@ var ts; var unspreadableToRestKeys = []; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); + var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) - && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) + && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } @@ -56298,7 +56485,7 @@ var ts; // they are explicitly omitted, as they would in the non-generic case. omitKeyType = getUnionType(__spreadArray([omitKeyType], unspreadableToRestKeys, true)); } - if (omitKeyType.flags & 131072 /* Never */) { + if (omitKeyType.flags & 131072 /* TypeFlags.Never */) { return source; } var omitTypeAlias = getGlobalOmitSymbol(); @@ -56313,15 +56500,15 @@ var ts; members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false)); } var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source)); - result.objectFlags |= 4194304 /* ObjectRestType */; + result.objectFlags |= 4194304 /* ObjectFlags.ObjectRestType */; return result; } function isGenericTypeWithUndefinedConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* TypeFlags.Undefined */); } function getNonUndefinedType(type) { - var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; - return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */); + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288 /* TypeFacts.NEUndefined */); } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: @@ -56357,34 +56544,34 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ancestor.initializer; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 203 /* BindingElement */ && parent.kind === 201 /* ObjectBindingPattern */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */ && parent.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 296 /* PropertyAssignment */ || node.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.kind === 296 /* SyntaxKind.PropertyAssignment */ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); } function getLiteralPropertyNameText(name) { var type = getLiteralTypeFromPropertyName(name); - return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : undefined; + return type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */) ? "" + type.value : undefined; } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { - var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var checkMode = declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode); return parentType && getBindingElementTypeFromParentType(declaration, parentType); } @@ -56395,18 +56582,18 @@ var ts; } var pattern = declaration.parent; // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 16777216 /* NodeFlags.Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` - else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) { - parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* TypeFacts.EQUndefined */)) { + parentType = getTypeWithFacts(parentType, 524288 /* TypeFacts.NEUndefined */); } var type; - if (pattern.kind === 201 /* ObjectBindingPattern */) { + if (pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); - if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* TypeFlags.Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return errorType; } @@ -56423,7 +56610,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* AccessFlags.ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -56431,7 +56618,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern); + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* IterationUse.PossiblyOutOfBounds */), parentType, undefinedType, pattern); var index_2 = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { // If the parent is a tuple type, the rest element has a tuple type of the @@ -56443,7 +56630,7 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getNumberLiteralType(index_2); - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } @@ -56457,9 +56644,9 @@ var ts; if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type; + return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)) & 16777216 /* TypeFacts.IsUndefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)], 2 /* UnionReduction.Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -56470,11 +56657,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* SyntaxKind.NullKeyword */ || expr.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 204 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, isProperty, isOptional) { if (isProperty === void 0) { isProperty = false; } @@ -56485,11 +56672,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode))); - return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -56511,11 +56698,11 @@ var ts; } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) { + !(ts.getCombinedModifierFlags(declaration) & 1 /* ModifierFlags.Export */) && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. - if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array @@ -56527,8 +56714,8 @@ var ts; if (ts.isParameter(declaration)) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 173 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* GetAccessor */); + if (func.kind === 173 /* SyntaxKind.SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* SyntaxKind.GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -56546,7 +56733,7 @@ var ts; return type_1; } // Use contextual parameter type if one is available - var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); + var type = declaration.symbol.escapedName === "this" /* InternalSymbolName.This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { return addOptionality(type, /*isProperty*/ false, isOptional); } @@ -56569,14 +56756,14 @@ var ts; if (!ts.hasStaticModifier(declaration)) { var constructor = findConstructorDeclaration(declaration.parent); var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } else { var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } @@ -56605,7 +56792,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 207 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 207 /* SyntaxKind.ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -56627,7 +56814,7 @@ var ts; 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 === 171 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(container))) { return container; } } @@ -56687,7 +56874,7 @@ var ts; } function getFlowTypeOfProperty(reference, prop) { var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) - && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* ModifierFlags.Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); @@ -56726,7 +56913,7 @@ var ts; var kind = ts.isAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } @@ -56756,12 +56943,12 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes); } } var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); - if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -56785,7 +56972,7 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - type.objectFlags |= 4096 /* JSLiteral */; + type.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { @@ -56841,13 +57028,13 @@ var ts; if (containsSameNamedThisProperty(expression.left, expression.right)) { return anyType; } - var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); + var isDirectExport = kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right)) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 524288 /* Object */ && - kind === 2 /* ModuleExports */ && - symbol.escapedName === "export=" /* ExportEquals */) { + if (type.flags & 524288 /* TypeFlags.Object */ && + kind === 2 /* AssignmentDeclarationKind.ModuleExports */ && + symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); ts.copyEntries(exportedType.members, members_4); @@ -56858,8 +57045,8 @@ var ts; (resolvedSymbol || symbol).exports.forEach(function (s, name) { var _a; var exportedMember = members_4.get(name); - if (exportedMember && exportedMember !== s) { - if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) { + if (exportedMember && exportedMember !== s && !(s.flags & 2097152 /* SymbolFlags.Alias */)) { + if (s.flags & 111551 /* SymbolFlags.Value */ && exportedMember.flags & 111551 /* SymbolFlags.Value */) { // If the member has an additional value-like declaration, union the types from the two declarations, // but issue an error if they occurred in two different files. The purpose is to support a JS file with // a pattern like: @@ -56897,15 +57084,15 @@ var ts; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = type.aliasTypeArguments; } - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { result.aliasSymbol = type.symbol; var args = getTypeArguments(type); result.aliasTypeArguments = ts.length(args) ? args : undefined; } } - result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag - if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */); // Propagate JSLiteral flag + if (result.symbol && result.symbol.flags & 32 /* SymbolFlags.Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { + result.objectFlags |= 16777216 /* ObjectFlags.IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -56917,16 +57104,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 108 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 171 /* Constructor */ || - thisContainer.kind === 256 /* FunctionDeclaration */ || - (thisContainer.kind === 213 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 171 /* SyntaxKind.Constructor */ || + thisContainer.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (thisContainer.kind === 213 /* SyntaxKind.FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -56946,7 +57133,7 @@ var ts; // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType))); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -56954,17 +57141,13 @@ var ts; if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAny(element, anyType); } - // When we're including the pattern in the type (an indication we're obtaining a contextual type), we - // use the non-inferrable any type. Inference will never directly infer this type, but it is possible - // to infer a type that contains it, e.g. for a binding pattern like [foo] or { foo }. In such cases, - // widening of the binding pattern type substitutes a regular any for the non-inferrable any. - return includePatternInType ? nonInferrableAnyType : anyType; + return anyType; } // Return the type implied by an object binding pattern function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -56974,11 +57157,11 @@ var ts; var exprType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(exprType)) { // do not include computed properties in the implied type - objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; return; } var text = getPropertyNameFromType(exprType); - var flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0); + var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; @@ -56988,7 +57171,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56996,18 +57179,18 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 203 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { - return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1; - var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* Rest */ : i >= minLength ? 2 /* Optional */ : 1 /* Required */; }); + var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; }); var result = createTupleType(elementTypes, elementFlags); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -57021,7 +57204,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 201 /* ObjectBindingPattern */ + return pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -57035,7 +57218,7 @@ var ts; // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors); + return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* CheckMode.Normal */), declaration, reportErrors); } function isGlobalSymbolConstructor(node) { var symbol = getSymbolOfNode(node); @@ -57045,14 +57228,14 @@ var ts; function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol` - if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { type = getESSymbolLikeTypeForNode(declaration); } if (reportErrors) { reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -57069,7 +57252,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 164 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(node) { @@ -57093,14 +57276,14 @@ var ts; } function getTypeOfVariableOrParameterOrPropertyWorker(symbol) { // Handle prototype property - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return getTypeOfPrototypeProperty(symbol); } // CommonsJS require and module both have type any. if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { + if (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); var result = createSymbol(fileSymbol.flags, "exports"); result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; @@ -57141,15 +57324,15 @@ var ts; return getTypeOfAccessors(symbol); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 271 /* ExportAssignment */) { + if (declaration.kind === 271 /* SyntaxKind.ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -57168,7 +57351,7 @@ var ts; || ts.isMethodSignature(declaration) || ts.isSourceFile(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } type = ts.isBinaryExpression(declaration.parent) ? @@ -57182,10 +57365,10 @@ var ts; type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration); } else if (ts.isShorthandPropertyAssignment(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* CheckMode.Normal */); } else if (ts.isObjectLiteralMethod(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* CheckMode.Normal */); } else if (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration) @@ -57208,7 +57391,7 @@ var ts; } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -57217,7 +57400,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -57242,11 +57425,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); // We try to resolve a getter type annotation, a setter type annotation, or a getter function // body return type inference, in that order. var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || @@ -57281,10 +57464,10 @@ var ts; function getWriteTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.writeType) { - if (!pushTypeResolution(symbol, 8 /* WriteType */)) { + if (!pushTypeResolution(symbol, 8 /* TypeSystemPropertyName.WriteType */)) { return errorType; } - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); var writeType = getAnnotatedAccessorType(setter); if (!popTypeResolution()) { if (getAnnotatedAccessorTypeNode(setter)) { @@ -57299,8 +57482,8 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : - baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + return baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeFlags.TypeVariable */); }) : undefined; } function getTypeOfFuncClassEnumModule(symbol) { @@ -57321,21 +57504,21 @@ var ts; } function getTypeOfFuncClassEnumModuleWorker(symbol) { var declaration = symbol.valueDeclaration; - if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 221 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 221 /* BinaryExpression */)) { + declaration.parent.kind === 221 /* SyntaxKind.BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } - else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { + else if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { var resolvedModule = resolveExternalModuleSymbol(symbol); if (resolvedModule !== symbol) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */)); + var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)); var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule); if (!popTypeResolution()) { return reportCircularityError(symbol); @@ -57343,13 +57526,13 @@ var ts; return type_3; } } - var type = createObjectType(16 /* Anonymous */, symbol); - if (symbol.flags & 32 /* Class */) { + var type = createObjectType(16 /* ObjectFlags.Anonymous */, symbol); + if (symbol.flags & 32 /* SymbolFlags.Class */) { var baseTypeVariable = getBaseTypeVariableOfClass(symbol); return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type; + return strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ ? getOptionalType(type) : type; } } function getTypeOfEnumMember(symbol) { @@ -57370,7 +57553,7 @@ var ts; links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType - : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } return links.type; @@ -57391,7 +57574,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 164 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 164 /* SyntaxKind.Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -57404,7 +57587,7 @@ var ts; if (!links.type) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); } return links.type; } @@ -57413,7 +57596,7 @@ var ts; if (!links.writeType && links.deferralWriteConstituents) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); + links.writeType = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); } return links.writeType; } @@ -57424,15 +57607,15 @@ var ts; */ function getWriteTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (symbol.flags & 4 /* Property */) { - return checkFlags & 2 /* SyntheticProperty */ ? - checkFlags & 65536 /* DeferredType */ ? + if (symbol.flags & 4 /* SymbolFlags.Property */) { + return checkFlags & 2 /* CheckFlags.SyntheticProperty */ ? + checkFlags & 65536 /* CheckFlags.DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : symbol.writeType || symbol.type : getTypeOfSymbol(symbol); } - if (symbol.flags & 98304 /* Accessor */) { - return checkFlags & 1 /* Instantiated */ ? + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { + return checkFlags & 1 /* CheckFlags.Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol); } @@ -57440,56 +57623,56 @@ var ts; } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (checkFlags & 65536 /* DeferredType */) { + if (checkFlags & 65536 /* CheckFlags.DeferredType */) { return getTypeOfSymbolWithDeferredType(symbol); } - if (checkFlags & 1 /* Instantiated */) { + if (checkFlags & 1 /* CheckFlags.Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (checkFlags & 262144 /* Mapped */) { + if (checkFlags & 262144 /* CheckFlags.Mapped */) { return getTypeOfMappedSymbol(symbol); } - if (checkFlags & 8192 /* ReverseMapped */) { + if (checkFlags & 8192 /* CheckFlags.ReverseMapped */) { return getTypeOfReverseMappedSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & 98304 /* Accessor */) { + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getTypeOfAlias(symbol); } return errorType; } function getNonMissingTypeOfSymbol(symbol) { - return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* SymbolFlags.Optional */)); } function isReferenceToType(type, target) { return type !== undefined && target !== undefined - && (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + && (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getTargetType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target : type; } // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { - if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, check); } return false; @@ -57512,7 +57695,7 @@ var ts; if (node && ts.isBinaryExpression(node)) { // prototype assignments get the outer type parameters of their constructor function var assignmentKind = ts.getAssignmentDeclarationKind(node); - if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { var symbol = getSymbolOfNode(node.left); if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { node = symbol.parent.valueDeclaration; @@ -57523,46 +57706,46 @@ var ts; return undefined; } switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: - case 338 /* JSDocCallbackTag */: - case 195 /* MappedType */: - case 189 /* ConditionalType */: { + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 195 /* SyntaxKind.MappedType */: + case 189 /* SyntaxKind.ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 195 /* MappedType */) { + if (node.kind === 195 /* SyntaxKind.MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 189 /* ConditionalType */) { + else if (node.kind === 189 /* SyntaxKind.ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */ || node.kind === 258 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 320 /* JSDoc */: { + case 320 /* SyntaxKind.JSDoc */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -57573,7 +57756,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* SymbolFlags.Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -57586,9 +57769,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 257 /* ClassDeclaration */ || - node.kind === 226 /* ClassExpression */ || + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || + node.kind === 226 /* SyntaxKind.ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -57605,7 +57788,7 @@ var ts; // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single // rest parameter of type any[]. function isMixinConstructorType(type) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length === 1) { var s = signatures[0]; if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) { @@ -57616,10 +57799,10 @@ var ts; return false; } function isConstructorType(type) { - if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length > 0) { return true; } - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isMixinConstructorType(constraint); } @@ -57632,7 +57815,7 @@ var ts; function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); var isJavascript = ts.isInJSFile(location); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); + return ts.filter(getSignaturesOfType(type, 1 /* SignatureKind.Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); @@ -57655,7 +57838,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + if (!pushTypeResolution(type, 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */)) { return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -57663,7 +57846,7 @@ var ts; ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -57672,13 +57855,13 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = errorType; } - if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* TypeFlags.Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - if (baseConstructorType.flags & 262144 /* TypeParameter */) { + if (baseConstructorType.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(baseConstructorType); var ctorReturn = unknownType; if (constraint) { - var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + var ctorSig = getSignaturesOfType(constraint, 1 /* SignatureKind.Construct */); if (ctorSig[0]) { ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } @@ -57718,19 +57901,19 @@ var ts; return resolvedImplementsTypes; } function reportCircularBaseType(node, type) { - error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); } function getBaseTypes(type) { if (!type.baseTypesResolved) { - if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) { - if (type.objectFlags & 8 /* Tuple */) { + if (pushTypeResolution(type, 7 /* TypeSystemPropertyName.ResolvedBaseTypes */)) { + if (type.objectFlags & 8 /* ObjectFlags.Tuple */) { type.resolvedBaseTypes = [getTupleBaseType(type)]; } - else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (type.symbol.flags & 32 /* Class */) { + else if (type.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { + if (type.symbol.flags & 32 /* SymbolFlags.Class */) { resolveBaseTypesOfClass(type); } - if (type.symbol.flags & 64 /* Interface */) { + if (type.symbol.flags & 64 /* SymbolFlags.Interface */) { resolveBaseTypesOfInterface(type); } } @@ -57740,7 +57923,7 @@ var ts; if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 257 /* ClassDeclaration */ || declaration.kind === 258 /* InterfaceDeclaration */) { + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -57751,26 +57934,26 @@ var ts; return type.resolvedBaseTypes; } function getTupleBaseType(type) { - var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; }); + var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; }); return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly); } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); var baseType; var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; - if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && + if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } - else if (baseConstructorType.flags & 1 /* Any */) { + else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) { baseType = baseConstructorType; } else { @@ -57795,7 +57978,7 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); return type.resolvedBaseTypes = ts.emptyArray; } if (type.resolvedBaseTypes === ts.resolvingEmptyArray) { @@ -57820,7 +58003,7 @@ var ts; } // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getBaseConstraintOfType(type); if (constraint) { return isValidBaseType(constraint); @@ -57828,15 +58011,15 @@ var ts; } // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? // There's no reason a `T` should be allowed while a `Readonly` should not. - return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType)); + return !!(type.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 1 /* TypeFlags.Any */) && !isGenericMappedType(type) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isValidBaseType)); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; if (type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -57876,8 +58059,8 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */) { - if (declaration.flags & 128 /* ContainsThis */) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { + if (declaration.flags & 128 /* NodeFlags.ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -57885,8 +58068,8 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + var baseSymbol = resolveEntityName(node.expression, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* SymbolFlags.Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } } @@ -57900,7 +58083,7 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; + var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */; var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol @@ -57914,8 +58097,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isThislessInterface(symbol)) { - type.objectFlags |= 4 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) { + type.objectFlags |= 4 /* ObjectFlags.Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -57936,7 +58119,7 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + if (!pushTypeResolution(symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { return errorType; } var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found"); @@ -57955,11 +58138,11 @@ var ts; } else { type = errorType; - if (declaration.kind === 339 /* JSDocEnumTag */) { + if (declaration.kind === 339 /* SyntaxKind.JSDocEnumTag */) { error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } } links.declaredType = type; @@ -57970,7 +58153,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 221 /* BinaryExpression */) { + else if (expr.kind === 221 /* SyntaxKind.BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -57978,19 +58161,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 16777216 /* Ambient */); + return !(member.flags & 16777216 /* NodeFlags.Ambient */); } switch (expr.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; - case 79 /* Identifier */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; + case 79 /* SyntaxKind.Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -58005,11 +58188,11 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { - return links.enumKind = 1 /* Literal */; + return links.enumKind = 1 /* EnumKind.Literal */; } if (!isLiteralEnumMember(member)) { hasNonLiteralMember = true; @@ -58018,23 +58201,23 @@ var ts; } } } - return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; + return links.enumKind = hasNonLiteralMember ? 0 /* EnumKind.Numeric */ : 1 /* EnumKind.Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (links.declaredType) { return links.declaredType; } - if (getEnumKind(symbol) === 1 /* Literal */) { + if (getEnumKind(symbol) === 1 /* EnumKind.Literal */) { enumCount++; var memberTypeList = []; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -58046,15 +58229,15 @@ var ts; } } if (memberTypeList.length) { - var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 1048576 /* Union */) { - enumType_1.flags |= 1024 /* EnumLiteral */; + var enumType_1 = getUnionType(memberTypeList, 1 /* UnionReduction.Literal */, symbol, /*aliasTypeArguments*/ undefined); + if (enumType_1.flags & 1048576 /* TypeFlags.Union */) { + enumType_1.flags |= 1024 /* TypeFlags.EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(32 /* Enum */); + var enumType = createType(32 /* TypeFlags.Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -58080,22 +58263,22 @@ var ts; return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getDeclaredTypeOfEnumMember(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getDeclaredTypeOfAlias(symbol); } return undefined; @@ -58107,22 +58290,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 196 /* LiteralType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 196 /* SyntaxKind.LiteralType */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isThislessType(node.elementType); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -58148,7 +58331,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 171 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 171 /* SyntaxKind.Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -58164,14 +58347,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -58208,8 +58391,8 @@ var ts; type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; type.declaredIndexInfos = ts.emptyArray; - type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); - type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); + type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* InternalSymbolName.Call */)); + type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* InternalSymbolName.New */)); type.declaredIndexInfos = getIndexInfosOfSymbol(symbol); } return type; @@ -58218,7 +58401,7 @@ var ts; * Indicates whether a type can be used as a property name. */ function isTypeUsableAsPropertyName(type) { - return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -58237,9 +58420,9 @@ var ts; && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) === 64 /* at */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) === 64 /* CharacterCodes.at */; } /** * Indicates whether a declaration has a late-bindable dynamic name. @@ -58264,10 +58447,10 @@ var ts; * Gets the symbolic name for a member from its type. */ function getPropertyNameFromType(type) { - if (type.flags & 8192 /* UniqueESSymbol */) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { return type.escapedName; } - if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -58278,7 +58461,7 @@ var ts; * members. */ function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { - ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol."); + ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { @@ -58287,7 +58470,7 @@ var ts; else if (!member.symbol.isReplaceableByMethod) { symbol.declarations.push(member); } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -58336,7 +58519,7 @@ var ts; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. var lateSymbol = lateSymbols.get(memberName); if (!lateSymbol) - lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */)); + lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. @@ -58345,10 +58528,10 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_5 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); + var name_5 = !(type.flags & 8192 /* TypeFlags.UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_5); }); error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_5); - lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); + lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */); } lateSymbol.nameType = type; addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); @@ -58366,9 +58549,9 @@ var ts; function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) { var links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */; + var isStatic_1 = resolutionKind === "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */; var earlySymbols = !isStatic_1 ? symbol.members : - symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModuleWorker(symbol) : symbol.exports; // In the event we recursively resolve the members/exports of the symbol, we // set the initial value of resolvedMembers/resolvedExports to the early-bound @@ -58394,10 +58577,10 @@ var ts; for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { var member = decls_1[_c]; var assignmentKind = ts.getAssignmentDeclarationKind(member); - var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + var isInstanceMember = assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */ || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) - || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ - || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + || assignmentKind === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */; // A straight `Prototype` assignment probably can never have a computed name if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } @@ -58413,8 +58596,8 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ - ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ + ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* MembersOrExportsResolutionKind.resolvedMembers */) : symbol.members || emptySymbols; } /** @@ -58424,7 +58607,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol) { - if (symbol.flags & 106500 /* ClassMember */ && symbol.escapedName === "__computed" /* Computed */) { + if (symbol.flags & 106500 /* SymbolFlags.ClassMember */ && symbol.escapedName === "__computed" /* InternalSymbolName.Computed */) { var links = getSymbolLinks(symbol); if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol @@ -58441,7 +58624,7 @@ var ts; return symbol; } function getTypeWithThisArgument(type, thisArgument, needApparentType) { - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { var target = type.target; var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { @@ -58449,7 +58632,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }); return types !== type.types ? getIntersectionType(types) : type; } @@ -58485,8 +58668,8 @@ var ts; var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* SignatureKind.Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* SignatureKind.Construct */)); var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)]; indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); })); } @@ -58521,7 +58704,7 @@ var ts; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; result.compositeSignatures = sig.compositeSignatures; @@ -58531,24 +58714,24 @@ var ts; function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); result.compositeSignatures = unionSignatures; - result.compositeKind = 1048576 /* Union */; + result.compositeKind = 1048576 /* TypeFlags.Union */; result.target = undefined; result.mapper = undefined; return result; } function getOptionalCallSignature(signature, callChainFlags) { - if ((signature.flags & 24 /* CallChainFlags */) === callChainFlags) { + if ((signature.flags & 24 /* SignatureFlags.CallChainFlags */) === callChainFlags) { return signature; } if (!signature.optionalCallSignatureCache) { signature.optionalCallSignatureCache = {}; } - var key = callChainFlags === 8 /* IsInnerCallChain */ ? "inner" : "outer"; + var key = callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ ? "inner" : "outer"; return signature.optionalCallSignatureCache[key] || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags)); } function createOptionalCallSignature(signature, callChainFlags) { - ts.Debug.assert(callChainFlags === 8 /* IsInnerCallChain */ || callChainFlags === 16 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); + ts.Debug.assert(callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ || callChainFlags === 16 /* SignatureFlags.IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); var result = cloneSignature(signature); result.flags |= callChainFlags; return result; @@ -58560,7 +58743,7 @@ var ts; if (isTupleType(restType)) { return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)]; } - else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && ts.every(restType.types, isTupleType)) { + else if (!skipUnionExpanding && restType.flags & 1048576 /* TypeFlags.Union */ && ts.every(restType.types, isTupleType)) { return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); }); } } @@ -58573,10 +58756,10 @@ var ts; var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]); var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType); var flags = restType.target.elementFlags[i]; - var checkFlags = flags & 12 /* Variable */ ? 32768 /* RestParameter */ : - flags & 2 /* Optional */ ? 16384 /* OptionalParameter */ : 0; - var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); - symbol.type = flags & 4 /* Rest */ ? createArrayType(t) : t; + var checkFlags = flags & 12 /* ElementFlags.Variable */ ? 32768 /* CheckFlags.RestParameter */ : + flags & 2 /* ElementFlags.Optional */ ? 16384 /* CheckFlags.OptionalParameter */ : 0; + var symbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, name, checkFlags); + symbol.type = flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t; return symbol; }); return ts.concatenate(sig.parameters.slice(0, restIndex), restParams); @@ -58584,11 +58767,11 @@ var ts; } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol); - var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* Abstract */); + var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* Abstract */ : 0 /* None */)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* SignatureFlags.Abstract */ : 0 /* SignatureFlags.None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -58603,7 +58786,7 @@ var ts; var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; - sig.flags = isAbstract ? sig.flags | 4 /* Abstract */ : sig.flags & ~4 /* Abstract */; + sig.flags = isAbstract ? sig.flags | 4 /* SignatureFlags.Abstract */ : sig.flags & ~4 /* SignatureFlags.Abstract */; result.push(sig); } } @@ -58766,12 +58949,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -58793,11 +58976,11 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 1048576 /* Union */; - result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 1048576 /* TypeFlags.Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -58822,8 +59005,8 @@ var ts; function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); })); - var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* SignatureKind.Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */); })); var indexInfos = getUnionIndexInfos(type.types); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos); } @@ -58831,7 +59014,7 @@ var ts; return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } function findMixins(types) { - var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; }); + var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */).length > 0; }); var mixinFlags = ts.map(types, isMixinConstructorType); if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) { var firstMixinIndex = mixinFlags.indexOf(/*searchElement*/ true); @@ -58846,7 +59029,7 @@ var ts; mixedTypes.push(type); } else if (mixinFlags[i]) { - mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* SignatureKind.Construct */)[0])); } } return getIntersectionType(mixedTypes); @@ -58868,7 +59051,7 @@ var ts; // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature // 'new(s: string) => A & B'. if (!mixinFlags[i]) { - var signatures = getSignaturesOfType(t, 1 /* Construct */); + var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */); if (signatures.length && mixinCount > 0) { signatures = ts.map(signatures, function (s) { var clone = cloneSignature(s); @@ -58878,7 +59061,7 @@ var ts; } constructSignatures = appendSignatures(constructSignatures, signatures); } - callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */)); indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos); }; for (var i = 0; i < types.length; i++) { @@ -58917,18 +59100,18 @@ var ts; if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); - var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* SignatureKind.Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* SignatureKind.Construct */), type.mapper); var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper); setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1); return; } var symbol = getMergedSymbol(type.symbol); - if (symbol.flags & 2048 /* TypeLiteral */) { + if (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_7 = getMembersOfSymbol(symbol); - var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */)); - var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */)); + var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* InternalSymbolName.Call */)); + var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* InternalSymbolName.New */)); var indexInfos_2 = getIndexInfosOfSymbol(symbol); setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2); return; @@ -58942,7 +59125,7 @@ var ts; var varsOnly_1 = new ts.Map(); members.forEach(function (p) { var _a; - if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { + if (!(p.flags & 418 /* SymbolFlags.BlockScoped */) && !(p.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { varsOnly_1.set(p.escapedName, p); } }); @@ -58951,10 +59134,10 @@ var ts; } var baseConstructorIndexInfo; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 8650752 /* TypeFlags.TypeVariable */)) { members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -58970,8 +59153,8 @@ var ts; if (baseConstructorIndexInfo) { indexInfos = ts.append(indexInfos, baseConstructorIndexInfo); } - if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* TypeFlags.Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* TypeFlags.NumberLike */); }))) { indexInfos = ts.append(indexInfos, enumNumberIndexInfo); } } @@ -58980,16 +59163,16 @@ var ts; // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list // will never be observed because a qualified name can't reference signatures. - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } // And likewise for construct signatures for classes - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; - if (symbol.flags & 16 /* Function */) { + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* InternalSymbolName.Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* SymbolFlags.Function */) { constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? - createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) : + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */) : undefined; })); } if (!constructSignatures.length) { @@ -59007,20 +59190,20 @@ var ts; function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, stringType); var modifiers = getMappedTypeModifiers(type.mappedType); - var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; - var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; + var readonlyMask = modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? false : true; + var optionalMask = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 0 : 16777216 /* SymbolFlags.Optional */; var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; - var checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0); - var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); + var checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* CheckFlags.Readonly */ : 0); + var inferredProp = createSymbol(4 /* SymbolFlags.Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ - && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ - && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) { + if (type.constraintType.type.flags & 8388608 /* TypeFlags.IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeFlags.TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* TypeFlags.TypeParameter */) { // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of // type identities produced, we simplify such indexed access occurences @@ -59041,11 +59224,11 @@ var ts; // bound includes those keys that are known to always be present, for example because // because of constraints on type parameters (e.g. 'keyof T' for a constrained T). function getLowerBoundOfKeyType(type) { - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var t = getApparentType(type.type); return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { if (type.root.isDistributive) { var checkType = type.checkType; var constraint = getLowerBoundOfKeyType(checkType); @@ -59055,29 +59238,29 @@ var ts; } return type; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getLowerBoundOfKeyType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType)); } return type; } function getIsLateCheckFlag(s) { - return ts.getCheckFlags(s) & 4096 /* Late */; + return ts.getCheckFlags(s) & 4096 /* CheckFlags.Late */; } function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; cb(getLiteralTypeFromProperty(prop, include)); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { cb(stringType); } else { for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) { var info = _c[_b]; - if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + if (!stringsOnly || info.keyType.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { cb(info.keyType); } } @@ -59097,7 +59280,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* TypeFlags.StringLiteral */ : 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType); @@ -59125,13 +59308,13 @@ var ts; } else { var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined; - var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || - !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); - var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || - !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); - var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; + var isOptional = !!(templateModifiers & 4 /* MappedTypeModifiers.IncludeOptional */ || + !(templateModifiers & 8 /* MappedTypeModifiers.ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */); + var isReadonly = !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ || + !(templateModifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); + var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */; var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0; - var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, lateFlag | 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); + var prop = createSymbol(4 /* SymbolFlags.Property */ | (isOptional ? 16777216 /* SymbolFlags.Optional */ : 0), propName, lateFlag | 262144 /* CheckFlags.Mapped */ | (isReadonly ? 8 /* CheckFlags.Readonly */ : 0) | (stripOptional ? 524288 /* CheckFlags.StripOptional */ : 0)); prop.mappedType = type; prop.nameType = propNameType; prop.keyType = keyType; @@ -59144,12 +59327,12 @@ var ts; members.set(propName, prop); } } - else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) { - var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : - propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : + else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* TypeFlags.Any */ | 32 /* TypeFlags.Enum */)) { + var indexKeyType = propNameType.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */) ? stringType : + propNameType.flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */) ? numberType : propNameType; var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); - var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */)); indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true); } } @@ -59157,7 +59340,7 @@ var ts; function getTypeOfMappedSymbol(symbol) { if (!symbol.type) { var mappedType = symbol.mappedType; - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { mappedType.containsError = true; return errorType; } @@ -59167,8 +59350,8 @@ var ts; // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. - var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : + var type = strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + symbol.checkFlags & 524288 /* CheckFlags.StripOptional */ ? removeMissingOrUndefinedType(propType) : propType; if (!popTypeResolution()) { error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); @@ -59194,7 +59377,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -59202,8 +59385,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 193 /* TypeOperator */ && - constraintDeclaration.operator === 140 /* KeyOfKeyword */; + return constraintDeclaration.kind === 193 /* SyntaxKind.TypeOperator */ && + constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -59219,20 +59402,20 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* SyntaxKind.MinusToken */ ? 8 /* MappedTypeModifiers.ExcludeOptional */ : 4 /* MappedTypeModifiers.IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); - return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0; + return modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? -1 : modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 1 : 0; } function getCombinedMappedTypeOptionality(type) { var optionality = getMappedTypeOptionality(type); @@ -59240,42 +59423,48 @@ var ts; return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0); } function isPartialMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */); } function isGenericMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 524288 /* Object */) { - if (type.objectFlags & 4 /* Reference */) { + if (type.flags & 524288 /* TypeFlags.Object */) { + if (type.objectFlags & 4 /* ObjectFlags.Reference */) { resolveTypeReferenceMembers(type); } - else if (type.objectFlags & 3 /* ClassOrInterface */) { + else if (type.objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 1024 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { resolveReverseMappedTypeMembers(type); } - else if (type.objectFlags & 16 /* Anonymous */) { + else if (type.objectFlags & 16 /* ObjectFlags.Anonymous */) { resolveAnonymousTypeMembers(type); } - else if (type.objectFlags & 32 /* Mapped */) { + else if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { resolveMappedTypeMembers(type); } + else { + ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags)); + } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { resolveIntersectionTypeMembers(type); } + else { + ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags)); + } } return type; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -59284,7 +59473,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -59308,7 +59497,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type without index signature - if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) { + if (type.flags & 1048576 /* TypeFlags.Union */ && getIndexInfosOfType(current).length === 0) { break; } } @@ -59318,13 +59507,13 @@ var ts; } function getPropertiesOfType(type) { type = getReducedApparentType(type); - return type.flags & 3145728 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function forEachPropertyOfType(type, action) { type = getReducedApparentType(type); - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) { if (isNamedMember(symbol, escapedName)) { action(symbol, escapedName); @@ -59343,7 +59532,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 1048576 /* Union */)) { + if (!(unionType.flags & 1048576 /* TypeFlags.Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -59362,9 +59551,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -59425,7 +59614,7 @@ var ts; var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint && constraint !== type.checkType) { var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); - if (!(instantiated.flags & 131072 /* Never */)) { + if (!(instantiated.flags & 131072 /* TypeFlags.Never */)) { return instantiated; } } @@ -59443,11 +59632,11 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { var t = types_5[_i]; - if (t.flags & 465829888 /* Instantiable */) { + if (t.flags & 465829888 /* TypeFlags.Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { @@ -59457,7 +59646,7 @@ var ts; } } } - else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) { + else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */ || isEmptyAnonymousObjectType(t)) { hasDisjointDomainType = true; } } @@ -59469,21 +59658,22 @@ var ts; // intersection operation to reduce the union constraints. for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { var t = types_6[_a]; - if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) { + if (t.flags & 469892092 /* TypeFlags.DisjointDomains */ || isEmptyAnonymousObjectType(t)) { constraints = ts.append(constraints, t); } } } - return getIntersectionType(constraints); + // The source types were normalized; ensure the result is normalized too. + return getNormalizedType(getIntersectionType(constraints), /*writing*/ false); } return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { + if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -59508,7 +59698,7 @@ var ts; return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t) { if (!t.immediateBaseConstraint) { - if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) { + if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) { return circularConstraintType; } var result = void 0; @@ -59525,7 +59715,7 @@ var ts; stack.pop(); } if (!popTypeResolution()) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var errorNode = getConstraintDeclaration(t); if (errorNode) { var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t)); @@ -59545,13 +59735,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 3145728 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = t.types; var baseTypes = []; var different = false; @@ -59571,23 +59761,23 @@ var ts; if (!different) { return t; } - return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* TypeFlags.Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* TypeFlags.Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 4194304 /* Index */) { + if (t.flags & 4194304 /* TypeFlags.Index */) { return keyofConstraintType; } - if (t.flags & 134217728 /* TemplateLiteral */) { + if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var types = t.types; var constraints = ts.mapDefined(types, getBaseConstraint); return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType; } - if (t.flags & 268435456 /* StringMapping */) { + if (t.flags & 268435456 /* TypeFlags.StringMapping */) { var constraint = getBaseConstraint(t.type); return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType; } - if (t.flags & 8388608 /* IndexedAccess */) { + if (t.flags & 8388608 /* TypeFlags.IndexedAccess */) { if (isMappedTypeGenericIndexedAccess(t)) { // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic, // we substitute an instantiation of E where P is replaced with X. @@ -59598,11 +59788,11 @@ var ts; var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } - if (t.flags & 16777216 /* Conditional */) { + if (t.flags & 16777216 /* TypeFlags.Conditional */) { var constraint = getConstraintFromConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 33554432 /* Substitution */) { + if (t.flags & 33554432 /* TypeFlags.Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -59669,9 +59859,9 @@ var ts; } function isMappedTypeGenericIndexedAccess(type) { var objectType; - return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && + return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && - !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType); + !(getMappedTypeModifiers(objectType) & 8 /* MappedTypeModifiers.ExcludeOptional */) && !objectType.declaration.nameType); } /** * For a type parameter, return the base constraint of the type parameter. For the string, number, @@ -59679,17 +59869,17 @@ var ts; * type itself. */ function getApparentType(type) { - var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; - return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 402653316 /* StringLike */ ? globalStringType : - t.flags & 296 /* NumberLike */ ? globalNumberType : - t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : - t.flags & 528 /* BooleanLike */ ? globalBooleanType : - t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : - t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : - t.flags & 4194304 /* Index */ ? keyofConstraintType : - t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : + var t = !(type.flags & 465829888 /* TypeFlags.Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; + return ts.getObjectFlags(t) & 32 /* ObjectFlags.Mapped */ ? getApparentTypeOfMappedType(t) : + t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType : + t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType : + t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType() : + t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType : + t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType() : + t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType : + t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : + t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType : t; } function getReducedApparentType(type) { @@ -59704,21 +59894,21 @@ var ts; var singleProp; var propSet; var indexTypes; - var isUnion = containingType.flags & 1048576 /* Union */; + var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */; // Flags we want to propagate to the result if they exist in all source symbols - var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; - var syntheticFlag = 4 /* SyntheticMethod */; - var checkFlags = isUnion ? 0 : 8 /* Readonly */; + var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */; + var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */; + var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */; var mergedInstantiations = false; for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { var current = _c[_i]; var type = getApparentType(current); - if (!(isErrorType(type) || type.flags & 131072 /* Never */)) { + if (!(isErrorType(type) || type.flags & 131072 /* TypeFlags.Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop) { if (isUnion) { - optionalFlag |= (prop.flags & 16777216 /* Optional */); + optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */); } else { optionalFlag &= prop.flags; @@ -59731,7 +59921,7 @@ var ts; // If the symbols are instances of one another with identical types - consider the symbols // equivalent and just use the first one, which thus allows us to avoid eliding private // members when intersecting a (this-)instantiations of a class with it's raw base or another instance - if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) { + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) { // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` @@ -59749,41 +59939,41 @@ var ts; } } if (isUnion && isReadonlySymbol(prop)) { - checkFlags |= 8 /* Readonly */; + checkFlags |= 8 /* CheckFlags.Readonly */; } else if (!isUnion && !isReadonlySymbol(prop)) { - checkFlags &= ~8 /* Readonly */; + checkFlags &= ~8 /* CheckFlags.Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) ? 256 /* CheckFlags.ContainsPublic */ : 0) | + (modifiers & 16 /* ModifierFlags.Protected */ ? 512 /* CheckFlags.ContainsProtected */ : 0) | + (modifiers & 8 /* ModifierFlags.Private */ ? 1024 /* CheckFlags.ContainsPrivate */ : 0) | + (modifiers & 32 /* ModifierFlags.Static */ ? 2048 /* CheckFlags.ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { - syntheticFlag = 2 /* SyntheticProperty */; + syntheticFlag = 2 /* CheckFlags.SyntheticProperty */; } } else if (isUnion) { var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name); if (indexInfo) { - checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); + checkFlags |= 32 /* CheckFlags.WritePartial */ | (indexInfo.isReadonly ? 8 /* CheckFlags.Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ContainsSpread */)) { - checkFlags |= 32 /* WritePartial */; + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ObjectFlags.ContainsSpread */)) { + checkFlags |= 32 /* CheckFlags.WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } else { - checkFlags |= 16 /* ReadPartial */; + checkFlags |= 16 /* CheckFlags.ReadPartial */; } } } } - if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) { + if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) { // No property was found, or, in a union, a property has a private or protected declaration in one // constituent, but is missing or has a different declaration in another constituent. return undefined; } - if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { + if (!propSet && !(checkFlags & 16 /* CheckFlags.ReadPartial */) && !indexTypes) { if (mergedInstantiations) { // No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents) // Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!) @@ -59825,18 +60015,18 @@ var ts; writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType); } else if (type !== firstType) { - checkFlags |= 64 /* HasNonUniformType */; + checkFlags |= 64 /* CheckFlags.HasNonUniformType */; } if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) { - checkFlags |= 128 /* HasLiteralType */; + checkFlags |= 128 /* CheckFlags.HasLiteralType */; } - if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) { - checkFlags |= 131072 /* HasNeverType */; + if (type.flags & 131072 /* TypeFlags.Never */ && type !== uniqueLiteralType) { + checkFlags |= 131072 /* CheckFlags.HasNeverType */; } propTypes.push(type); } ts.addRange(propTypes, indexTypes); - var result = createSymbol(4 /* Property */ | optionalFlag, name, syntheticFlag | checkFlags); + var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags); result.containingType = containingType; if (!hasNonUniformValueDeclaration && firstValueDeclaration) { result.valueDeclaration = firstValueDeclaration; @@ -59849,7 +60039,7 @@ var ts; result.nameType = nameType; if (propTypes.length > 2) { // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed - result.checkFlags |= 65536 /* DeferredType */; + result.checkFlags |= 65536 /* CheckFlags.DeferredType */; result.deferralParent = containingType; result.deferralConstituents = propTypes; result.deferralWriteConstituents = writeTypes; @@ -59883,7 +60073,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) { var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment); // We need to filter out partial properties in union types - return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined; + return property && !(ts.getCheckFlags(property) & 16 /* CheckFlags.ReadPartial */) ? property : undefined; } /** * Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. @@ -59892,15 +60082,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 16777216 /* ContainsIntersections */) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } - else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 16777216 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 16777216 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* IsNeverIntersection */ : 0); + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { + if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) { + type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0); } - return type.objectFlags & 33554432 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type; } return type; } @@ -59910,7 +60100,7 @@ var ts; return unionType; } var reduced = getUnionType(reducedTypes); - if (reduced.flags & 1048576 /* Union */) { + if (reduced.flags & 1048576 /* TypeFlags.Union */) { reduced.resolvedReducedType = reduced; } return reduced; @@ -59921,23 +60111,23 @@ var ts; function isDiscriminantWithNeverType(prop) { // Return true for a synthetic non-optional property with non-uniform types, where at least one is // a literal type and none is never, that reduces to never. - return !(prop.flags & 16777216 /* Optional */) && - (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ && - !!(getTypeOfSymbol(prop).flags & 131072 /* Never */); + return !(prop.flags & 16777216 /* SymbolFlags.Optional */) && + (ts.getCheckFlags(prop) & (192 /* CheckFlags.Discriminant */ | 131072 /* CheckFlags.HasNeverType */)) === 192 /* CheckFlags.Discriminant */ && + !!(getTypeOfSymbol(prop).flags & 131072 /* TypeFlags.Never */); } function isConflictingPrivateProperty(prop) { // Return true for a synthetic property with multiple declarations, at least one of which is private. - return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); + return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* CheckFlags.ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 33554432 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(neverProp)); } var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty); if (privateProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(privateProp)); } } return errorInfo; @@ -59952,7 +60142,7 @@ var ts; */ function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment, includeTypeOnlyMembers) { type = getReducedApparentType(type); - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol, includeTypeOnlyMembers)) { @@ -59972,15 +60162,15 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + return kind === 0 /* SignatureKind.Call */ ? resolved.callSignatures : resolved.constructSignatures; } return ts.emptyArray; } @@ -60026,10 +60216,10 @@ var ts; // signature applies to types assignable to 'number', `${number}` and numeric string literal types. return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value)); + target === numberType && (source === numericStringType || !!(source.flags & 128 /* TypeFlags.StringLiteral */) && ts.isNumericLiteralName(source.value)); } function getIndexInfosOfStructuredType(type) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return resolved.indexInfos; } @@ -60061,12 +60251,15 @@ var ts; // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(declaration) { + var _a; var result; - for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) { - var node = _a[_i]; + for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) { + var node = _b[_i]; result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol)); } - return result; + return (result === null || result === void 0 ? void 0 : result.length) ? result + : ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters + : undefined; } function symbolsToArray(symbols) { var result = []; @@ -60080,17 +60273,17 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 316 /* JSDocOptionalType */ + node.type && node.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* SymbolFlags.ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -60105,7 +60298,7 @@ var ts; // Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used // in grammar checks and checking for `void` too early results in parameter types widening too early // and causes some noImplicitAny errors to be lost. - return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */); + return parameterIndex >= getMinArgumentCount(signature, 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */ | 2 /* MinArgumentCountFlags.VoidIsNonOptional */); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -60123,7 +60316,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -60172,7 +60365,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -60184,7 +60377,7 @@ var ts; !ts.hasJSDocParameterTags(declaration) && !ts.getJSDocType(declaration); if (isUntypedSignatureInJSFile) { - flags |= 32 /* IsUntypedSignatureInJSFile */; + flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */; } // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -60194,19 +60387,19 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature - if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); + if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) { + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } - if (i === 0 && paramSymbol.escapedName === "this" /* This */) { + if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) { hasThisParameter = true; thisParameter = param.symbol; } else { parameters.push(paramSymbol); } - if (type && type.kind === 196 /* LiteralType */) { - flags |= 2 /* HasLiteralTypes */; + if (type && type.kind === 196 /* SyntaxKind.LiteralType */) { + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || @@ -60218,25 +60411,25 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) && + if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 171 /* Constructor */ ? + var classType = declaration.kind === 171 /* SyntaxKind.Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } - if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* Abstract */) || - ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* Abstract */)) { - flags |= 4 /* Abstract */; + if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */) || + ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* ModifierFlags.Abstract */)) { + flags |= 4 /* SignatureFlags.Abstract */; } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); @@ -60258,7 +60451,7 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */); + var syntheticArgsSymbol = createSymbol(3 /* SymbolFlags.Variable */, "args", 32768 /* CheckFlags.RestParameter */); if (lastParamVariadicType) { // Parameter has effective annotation, lock in type syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)); @@ -60267,7 +60460,7 @@ var ts; // Parameter has no annotation // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been // cached by `getTypeOfSymbol` yet. - syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */; + syntheticArgsSymbol.checkFlags |= 65536 /* CheckFlags.DeferredType */; syntheticArgsSymbol.deferralParent = neverType; syntheticArgsSymbol.deferralConstituents = [anyArrayType]; syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType]; @@ -60300,7 +60493,7 @@ var ts; function containsArgumentsReference(declaration) { var links = getNodeLinks(declaration); if (links.containsArgumentsReference === undefined) { - if (links.flags & 8192 /* CaptureArguments */) { + if (links.flags & 8192 /* NodeCheckFlags.CaptureArguments */) { links.containsArgumentsReference = true; } else { @@ -60312,18 +60505,18 @@ var ts; if (!node) return false; switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return node.name.kind === 162 /* ComputedPropertyName */ + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && traverse(node.name); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return traverse(node.expression); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return traverse(node.initializer); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -60395,26 +60588,26 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 192 /* ThisType */ ? - createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : - createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); + return parameterName.kind === 192 /* SyntaxKind.ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* TypePredicateKind.AssertsThis */ : 0 /* TypePredicateKind.This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* TypePredicateKind.AssertsIdentifier */ : 1 /* TypePredicateKind.Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getUnionOrIntersectionType(types, kind, unionReduction) { - return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + return kind !== 2097152 /* TypeFlags.Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + if (!pushTypeResolution(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* UnionReduction.Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); - if (signature.flags & 8 /* IsInnerCallChain */) { + if (signature.flags & 8 /* SignatureFlags.IsInnerCallChain */) { type = addOptionalTypeMarker(type); } - else if (signature.flags & 16 /* IsOuterCallChain */) { + else if (signature.flags & 16 /* SignatureFlags.IsOuterCallChain */) { type = getOptionalType(type); } if (!popTypeResolution()) { @@ -60441,7 +60634,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 171 /* Constructor */) { + if (declaration.kind === 171 /* SyntaxKind.Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -60451,12 +60644,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 172 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SyntaxKind.SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -60465,7 +60658,7 @@ var ts; return getReturnTypeOfTypeTag(declaration); } function isResolvingReturnTypeOfSignature(signature) { - return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { return tryGetRestTypeOfSignature(signature) || anyType; @@ -60559,8 +60752,8 @@ var ts; if (!signature.isolatedSignatureType) { var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind; // If declaration is undefined, it is likely to be the signature of the default constructor. - var isConstructor = kind === undefined || kind === 171 /* Constructor */ || kind === 175 /* ConstructSignature */ || kind === 180 /* ConstructorType */; - var type = createObjectType(16 /* Anonymous */); + var isConstructor = kind === undefined || kind === 171 /* SyntaxKind.Constructor */ || kind === 175 /* SyntaxKind.ConstructSignature */ || kind === 180 /* SyntaxKind.ConstructorType */; + var type = createObjectType(16 /* ObjectFlags.Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; type.callSignatures = !isConstructor ? [signature] : ts.emptyArray; @@ -60574,7 +60767,7 @@ var ts; return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; } function getIndexSymbolFromSymbolTable(symbolTable) { - return symbolTable.get("__index" /* Index */); + return symbolTable.get("__index" /* InternalSymbolName.Index */); } function createIndexInfo(keyType, type, isReadonly, declaration) { return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration }; @@ -60592,7 +60785,7 @@ var ts; if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), function (keyType) { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) { - indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* ModifierFlags.Readonly */), declaration)); } }); } @@ -60607,8 +60800,8 @@ var ts; return ts.emptyArray; } function isValidIndexKeyType(type) { - return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || - !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); + return !!(type.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 4096 /* TypeFlags.ESSymbol */)) || isPatternLiteralType(type) || + !!(type.flags & 2097152 /* TypeFlags.Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -60617,21 +60810,20 @@ var ts; var _a; var inferences; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { - for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { - var declaration = _b[_i]; - if (declaration.parent.kind === 190 /* InferType */) { + var _loop_15 = function (declaration) { + if (declaration.parent.kind === 190 /* SyntaxKind.InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; - if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) { - var typeReference = grandParent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(childTypeParameter); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (grandParent.kind === 178 /* SyntaxKind.TypeReference */ && !omitTypeReferences) { + var typeReference_1 = grandParent; + var typeParameters_1 = getTypeParametersForTypeReference(typeReference_1); + if (typeParameters_1) { + var index = typeReference_1.typeArguments.indexOf(childTypeParameter); + if (index < typeParameters_1.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters_1[index]); if (declaredConstraint) { // Type parameter constraints can reference other type parameters so // constraints need to be instantiated. If instantiation produces the @@ -60639,7 +60831,9 @@ var ts; // type Foo = [T, U]; // type Bar = T extends Foo ? Foo : T; // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var mapper = makeDeferredTypeMapper(typeParameters_1, typeParameters_1.map(function (_, index) { return function () { + return getEffectiveTypeArgumentAtIndex(typeReference_1, typeParameters_1, index); + }; })); var constraint = instantiateType(declaredConstraint, mapper); if (constraint !== typeParameter) { inferences = ts.append(inferences, constraint); @@ -60650,33 +60844,37 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 164 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 186 /* RestType */ || - grandParent.kind === 197 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 164 /* SyntaxKind.Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 186 /* SyntaxKind.RestType */ || + grandParent.kind === 197 /* SyntaxKind.NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' // constraint. - else if (grandParent.kind === 199 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */) { inferences = ts.append(inferences, stringType); } // When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any' // constraint. - else if (grandParent.kind === 163 /* TypeParameter */ && grandParent.parent.kind === 195 /* MappedType */) { + else if (grandParent.kind === 163 /* SyntaxKind.TypeParameter */ && grandParent.parent.kind === 195 /* SyntaxKind.MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template // of the check type's mapped type - else if (grandParent.kind === 195 /* MappedType */ && grandParent.type && - ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* ConditionalType */ && - grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* MappedType */ && + else if (grandParent.kind === 195 /* SyntaxKind.MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* SyntaxKind.ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* SyntaxKind.MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); inferences = ts.append(inferences, instantiateType(nodeType, makeUnaryTypeMapper(getDeclaredTypeOfTypeParameter(getSymbolOfNode(checkMappedType_1.typeParameter)), checkMappedType_1.typeParameter.constraint ? getTypeFromTypeNode(checkMappedType_1.typeParameter.constraint) : keyofConstraintType))); } } + }; + for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + _loop_15(declaration); } } return inferences && getIntersectionType(inferences); @@ -60695,10 +60893,10 @@ var ts; } else { var type = getTypeFromTypeNode(constraintDeclaration); - if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed + if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 195 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -60707,7 +60905,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -60735,29 +60933,29 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type - // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // of an object literal or a non-inferrable type. This is because there are operations in the type checker // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - if (!(type.flags & excludeKinds)) { + if (excludeKinds === undefined || !(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } } - return result & 458752 /* PropagatingFlags */; + return result & 458752 /* ObjectFlags.PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations.get(id); if (!type) { - type = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); target.instantiations.set(id, type); - type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; + type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0; type.target = target; type.resolvedTypeArguments = typeArguments; } @@ -60777,7 +60975,7 @@ var ts; var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; } - var type = createObjectType(4 /* Reference */, target.symbol); + var type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; @@ -60788,13 +60986,13 @@ var ts; function getTypeArguments(type) { var _a, _b; if (!type.resolvedTypeArguments) { - if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) { + if (!pushTypeResolution(type, 6 /* TypeSystemPropertyName.ResolvedTypeArguments */)) { return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 178 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 178 /* SyntaxKind.TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -60829,14 +61027,14 @@ var ts; missingAugmentsTag ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; - var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); + var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) return errorType; } } - if (node.kind === 178 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -60867,12 +61065,12 @@ var ts; * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ function getTypeFromTypeAliasReference(node, symbol) { - if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) { + if (ts.getCheckFlags(symbol) & 1048576 /* CheckFlags.Unresolved */) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); var id = getAliasId(symbol, typeArguments); var errorType_1 = errorTypes.get(id); if (!errorType_1) { - errorType_1 = createIntrinsicType(1 /* Any */, "error"); + errorType_1 = createIntrinsicType(1 /* TypeFlags.Any */, "error"); errorType_1.aliasSymbol = symbol; errorType_1.aliasTypeArguments = typeArguments; errorTypes.set(id, errorType_1); @@ -60907,9 +61105,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -60921,21 +61119,21 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { - var identifier = name.kind === 161 /* QualifiedName */ ? name.right : - name.kind === 206 /* PropertyAccessExpression */ ? name.name : + var identifier = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? name.name : name; var text = identifier.escapedText; if (text) { - var parentSymbol = name.kind === 161 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : - name.kind === 206 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : + var parentSymbol = name.kind === 161 /* SyntaxKind.QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { - unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */)); + unresolvedSymbols.set(path, result = createSymbol(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */)); result.parent = parentSymbol; result.declaredType = unresolvedType; } @@ -60957,10 +61155,10 @@ var ts; return errorType; } symbol = getExpandoSymbol(symbol) || symbol; - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getTypeFromClassOrInterfaceReference(node, symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) @@ -60968,14 +61166,14 @@ var ts; if (res) { return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType; } - if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + if (symbol.flags & 111551 /* SymbolFlags.Value */ && isJSDocTypeReference(node)) { var jsdocType = getTypeFromJSDocValueReference(node, symbol); if (jsdocType) { return jsdocType; } else { // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(node, 788968 /* Type */); + resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */); return getTypeOfSymbol(symbol); } } @@ -60991,7 +61189,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 200 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 200 /* SyntaxKind.ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); @@ -61002,22 +61200,22 @@ var ts; return links.resolvedJSDocType; } function getSubstitutionType(baseType, substitute) { - if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) { + if (substitute.flags & 3 /* TypeFlags.AnyOrUnknown */ || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; } - var result = createType(33554432 /* Substitution */); + var result = createType(33554432 /* TypeFlags.Substitution */); result.baseType = baseType; result.substitute = substitute; substitutionTypes.set(id, result); return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 184 /* TupleType */ && node.elements.length === 1; + return node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -61027,16 +61225,16 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 320 /* JSDoc */) { + while (node && !ts.isStatement(node) && node.kind !== 320 /* SyntaxKind.JSDoc */) { var parent = node.parent; // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax - if (parent.kind === 164 /* Parameter */) { + if (parent.kind === 164 /* SyntaxKind.Parameter */) { covariant = !covariant; } // Always substitute on type parameters, regardless of variance, since even // in contravariant positions, they may rely on substituted constraints to be valid - if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 189 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeFlags.TypeVariable */) && parent.kind === 189 /* SyntaxKind.ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -61044,7 +61242,7 @@ var ts; } // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the // template type XXX, K has an added constraint of number | `${number}`. - else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 195 /* MappedType */ && node === parent.type) { + else if (type.flags & 262144 /* TypeFlags.TypeParameter */ && parent.kind === 195 /* SyntaxKind.MappedType */ && node === parent.type) { var mappedType = getTypeFromTypeNode(parent); if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { var typeParameter = getHomomorphicTypeVariable(mappedType); @@ -61061,7 +61259,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */); + return !!(node.flags & 8388608 /* NodeFlags.JSDoc */) && (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 200 /* SyntaxKind.ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -61117,7 +61315,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -61129,13 +61327,13 @@ var ts; } var symbol = void 0; var type = void 0; - var meaning = 788968 /* Type */; + var meaning = 788968 /* SymbolFlags.Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); if (!type) { symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true); if (symbol === unknownSymbol) { - symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */); + symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */); } else { resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any @@ -61176,9 +61374,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declaration; } } @@ -61188,7 +61386,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 524288 /* Object */)) { + if (!(type.flags & 524288 /* TypeFlags.Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -61199,13 +61397,13 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* SymbolFlags.Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalTypeAliasSymbol(name, arity, reportErrors) { - var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); if (symbol) { // Resolve the declared type of the symbol. This resolves type parameters for the type // alias so that we can check arity. @@ -61241,9 +61439,9 @@ var ts; function getGlobalImportMetaExpressionType() { if (!deferredGlobalImportMetaExpressionType) { // Create a synthetic type `ImportMetaExpression { meta: MetaProperty }` - var symbol = createSymbol(0 /* None */, "ImportMetaExpression"); + var symbol = createSymbol(0 /* SymbolFlags.None */, "ImportMetaExpression"); var importMetaType = getGlobalImportMetaType(); - var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */); + var metaPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "meta", 8 /* CheckFlags.Readonly */); metaPropertySymbol.parent = symbol; metaPropertySymbol.type = importMetaType; var members = ts.createSymbolTable([metaPropertySymbol]); @@ -61308,7 +61506,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -61346,20 +61544,20 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 185 /* OptionalType */: - return 2 /* Optional */; - case 186 /* RestType */: + case 185 /* SyntaxKind.OptionalType */: + return 2 /* ElementFlags.Optional */; + case 186 /* SyntaxKind.RestType */: return getRestTypeElementFlags(node); - case 197 /* NamedTupleMember */: - return node.questionToken ? 2 /* Optional */ : + case 197 /* SyntaxKind.NamedTupleMember */: + return node.questionToken ? 2 /* ElementFlags.Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + 1 /* ElementFlags.Required */; default: - return 1 /* Required */; + return 1 /* ElementFlags.Required */; } } function getRestTypeElementFlags(node) { - return getArrayElementTypeNode(node.type) ? 4 /* Rest */ : 8 /* Variadic */; + return getArrayElementTypeNode(node.type) ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */; } function getArrayOrTupleTargetType(node) { var readonly = isReadonlyTypeOperator(node.parent); @@ -61368,14 +61566,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* SyntaxKind.NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 184 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* SyntaxKind.ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 184 /* SyntaxKind.TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -61384,18 +61582,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 194 /* IndexedAccessType */: - case 189 /* ConditionalType */: - case 193 /* TypeOperator */: - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 189 /* SyntaxKind.ConditionalType */: + case 193 /* SyntaxKind.TypeOperator */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return isResolvedByTypeAlias(parent); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } return false; @@ -61404,28 +61602,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 178 /* TypeReference */: - return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 181 /* TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */).flags & 524288 /* SymbolFlags.TypeAlias */); + case 181 /* SyntaxKind.TypeQuery */: return true; - case 193 /* TypeOperator */: - return node.operator !== 154 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 197 /* NamedTupleMember */: - case 316 /* JSDocOptionalType */: - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 193 /* SyntaxKind.TypeOperator */: + return node.operator !== 154 /* SyntaxKind.UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 186 /* RestType */: - return node.type.kind !== 183 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 186 /* SyntaxKind.RestType */: + return node.type.kind !== 183 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -61438,33 +61636,33 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 184 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 184 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 184 /* SyntaxKind.TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* ElementFlags.Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 145 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } - var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* Required */; }), readonly, namedMemberDeclarations); + var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* ElementFlags.Required */; }), readonly, namedMemberDeclarations); return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget; } function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { - if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) { + if (elementFlags.length === 1 && elementFlags[0] & 4 /* ElementFlags.Rest */) { // [...X[]] is equivalent to just X[] return readonly ? globalReadonlyArrayType : globalArrayType; } - var key = ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*"; }).join() + + var key = ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? "#" : f & 2 /* ElementFlags.Optional */ ? "?" : f & 4 /* ElementFlags.Rest */ ? "." : "*"; }).join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : ""); var type = tupleTypes.get(key); @@ -61482,7 +61680,7 @@ var ts; // is true for each of the synthesized type parameters. function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { var arity = elementFlags.length; - var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* Required */ | 8 /* Variadic */)); }); + var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* ElementFlags.Required */ | 8 /* ElementFlags.Variadic */)); }); var typeParameters; var properties = []; var combinedFlags = 0; @@ -61492,8 +61690,8 @@ var ts; var typeParameter = typeParameters[i] = createTypeParameter(); var flags = elementFlags[i]; combinedFlags |= flags; - if (!(combinedFlags & 12 /* Variable */)) { - var property = createSymbol(4 /* Property */ | (flags & 2 /* Optional */ ? 16777216 /* Optional */ : 0), "" + i, readonly ? 8 /* Readonly */ : 0); + if (!(combinedFlags & 12 /* ElementFlags.Variable */)) { + var property = createSymbol(4 /* SymbolFlags.Property */ | (flags & 2 /* ElementFlags.Optional */ ? 16777216 /* SymbolFlags.Optional */ : 0), "" + i, readonly ? 8 /* CheckFlags.Readonly */ : 0); property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i]; property.type = typeParameter; properties.push(property); @@ -61501,8 +61699,8 @@ var ts; } } var fixedLength = properties.length; - var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0); - if (combinedFlags & 12 /* Variable */) { + var lengthSymbol = createSymbol(4 /* SymbolFlags.Property */, "length", readonly ? 8 /* CheckFlags.Readonly */ : 0); + if (combinedFlags & 12 /* ElementFlags.Variable */) { lengthSymbol.type = numberType; } else { @@ -61512,7 +61710,7 @@ var ts; lengthSymbol.type = getUnionType(literalTypes); } properties.push(lengthSymbol); - var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); + var type = createObjectType(8 /* ObjectFlags.Tuple */ | 4 /* ObjectFlags.Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -61530,26 +61728,26 @@ var ts; type.elementFlags = elementFlags; type.minLength = minLength; type.fixedLength = fixedLength; - type.hasRestElement = !!(combinedFlags & 12 /* Variable */); + type.hasRestElement = !!(combinedFlags & 12 /* ElementFlags.Variable */); type.combinedFlags = combinedFlags; type.readonly = readonly; type.labeledElementDeclarations = namedMemberDeclarations; return type; } function createNormalizedTypeReference(target, typeArguments) { - return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); + return target.objectFlags & 8 /* ObjectFlags.Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); } function createNormalizedTupleType(target, elementTypes) { var _a, _b, _c; - if (!(target.combinedFlags & 14 /* NonRequired */)) { + if (!(target.combinedFlags & 14 /* ElementFlags.NonRequired */)) { // No need to normalize when we only have regular required elements return createTypeReference(target, elementTypes); } - if (target.combinedFlags & 8 /* Variadic */) { + if (target.combinedFlags & 8 /* ElementFlags.Variadic */) { // Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z] - var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* ElementFlags.Variadic */ && t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex_1 >= 0) { - return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ? + return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : unknownType; })) ? mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) : errorType; } @@ -61565,13 +61763,13 @@ var ts; var lastRequiredIndex = -1; var firstRestIndex = -1; var lastOptionalOrRestIndex = -1; - var _loop_15 = function (i) { + var _loop_16 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; - if (flags & 8 /* Variadic */) { - if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) { + if (flags & 8 /* ElementFlags.Variadic */) { + if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type)) { // Generic variadic elements stay as they are. - addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + addElement(type, 8 /* ElementFlags.Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { var elements = getTypeArguments(type); @@ -61586,7 +61784,7 @@ var ts; } else { // Treat everything else as an array type and create a rest element. - addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); + addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* ElementFlags.Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); } } else { @@ -61595,18 +61793,18 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - var state_4 = _loop_15(i); + var state_4 = _loop_16(i); if (typeof state_4 === "object") return state_4.value; } // Turn optional elements preceding the last required element into required elements for (var i = 0; i < lastRequiredIndex; i++) { - if (expandedFlags[i] & 2 /* Optional */) - expandedFlags[i] = 1 /* Required */; + if (expandedFlags[i] & 2 /* ElementFlags.Optional */) + expandedFlags[i] = 1 /* ElementFlags.Required */; } if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) { // Turn elements between first rest and last optional/rest into a single rest element - expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; })); + expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; })); expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); @@ -61616,13 +61814,13 @@ var ts; expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget; function addElement(type, flags, declaration) { - if (flags & 1 /* Required */) { + if (flags & 1 /* ElementFlags.Required */) { lastRequiredIndex = expandedFlags.length; } - if (flags & 4 /* Rest */ && firstRestIndex < 0) { + if (flags & 4 /* ElementFlags.Rest */ && firstRestIndex < 0) { firstRestIndex = expandedFlags.length; } - if (flags & (2 /* Optional */ | 4 /* Rest */)) { + if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) { lastOptionalOrRestIndex = expandedFlags.length; } expandedTypes.push(type); @@ -61674,19 +61872,19 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 1048576 /* Union */) { - return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* Union */ : 0), type.types); + if (flags & 1048576 /* TypeFlags.Union */) { + return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* TypeFlags.Union */ : 0), type.types); } // We ignore 'never' types in unions - if (!(flags & 131072 /* Never */)) { - includes |= flags & 205258751 /* IncludesMask */; - if (flags & 465829888 /* Instantiable */) - includes |= 33554432 /* IncludesInstantiable */; + if (!(flags & 131072 /* TypeFlags.Never */)) { + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; + if (flags & 465829888 /* TypeFlags.Instantiable */) + includes |= 33554432 /* TypeFlags.IncludesInstantiable */; if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; - if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 65536 /* ContainsWideningType */)) - includes |= 4194304 /* IncludesNonWideningType */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; + if (!strictNullChecks && flags & 98304 /* TypeFlags.Nullable */) { + if (!(ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */)) + includes |= 4194304 /* TypeFlags.IncludesNonWideningType */; } else { var len = typeSet.length; @@ -61720,18 +61918,18 @@ var ts; // We assume that redundant primitive types have already been removed from the types array and that there // are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty // object types, and if none of those are present we can exclude primitive types from the subtype check. - var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); + var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); var len = types.length; var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (hasEmptyObject || source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { // Find the first property with a unit type, if any. When constituents have a property by the same name // but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype // reduction of large discriminated union types. - var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? + var keyProperty = source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : undefined; var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); @@ -61745,20 +61943,20 @@ var ts; // caps union types at 1000 unique object types. var estimatedCount = (count / (len - i)) * len; if (estimatedCount > 1000000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return undefined; } } count++; - if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (keyProperty && target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { continue; } } - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || + if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* ObjectFlags.Class */) || + !(ts.getObjectFlags(getTargetType(target)) & 1 /* ObjectFlags.Class */) || isTypeDerivedFrom(source, target))) { ts.orderedRemoveItemAt(types, i); break; @@ -61776,11 +61974,11 @@ var ts; i--; var t = types[i]; var flags = t.flags; - var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || - flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ || + flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ || + flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ || + flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ || + reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -61791,30 +61989,30 @@ var ts; var templates = ts.filter(types, isPatternLiteralType); if (templates.length) { var i = types.length; - var _loop_16 = function () { + var _loop_17 = function () { i--; var t = types[i]; - if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { + if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { ts.orderedRemoveItemAt(types, i); } }; while (i > 0) { - _loop_16(); + _loop_17(); } } } function isNamedUnionType(type) { - return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin)); + return !!(type.flags & 1048576 /* TypeFlags.Union */ && (type.aliasSymbol || type.origin)); } function addNamedUnions(namedUnions, types) { for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { var t = types_11[_i]; - if (t.flags & 1048576 /* Union */) { + if (t.flags & 1048576 /* TypeFlags.Union */) { var origin = t.origin; - if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { + if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* TypeFlags.Union */)) { ts.pushIfUnique(namedUnions, t); } - else if (origin && origin.flags & 1048576 /* Union */) { + else if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { addNamedUnions(namedUnions, origin.types); } } @@ -61833,7 +62031,7 @@ var ts; // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) { - if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } + if (unionReduction === void 0) { unionReduction = 1 /* UnionReduction.Literal */; } if (types.length === 0) { return neverType; } @@ -61842,48 +62040,48 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (unionReduction !== 0 /* None */) { - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? - includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : - includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; + if (unionReduction !== 0 /* UnionReduction.None */) { + if (includes & 3 /* TypeFlags.AnyOrUnknown */) { + return includes & 1 /* TypeFlags.Any */ ? + includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType : + includes & 65536 /* TypeFlags.Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; } - if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { + if (exactOptionalPropertyTypes && includes & 32768 /* TypeFlags.Undefined */) { var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { ts.orderedRemoveItemAt(typeSet, missingIndex); } } - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + if (includes & (2944 /* TypeFlags.Literal */ | 8192 /* TypeFlags.UniqueESSymbol */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* UnionReduction.Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* TypeFlags.StringLiteral */ && includes & 134217728 /* TypeFlags.TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (unionReduction === 2 /* Subtype */) { - typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (unionReduction === 2 /* UnionReduction.Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* TypeFlags.Object */)); if (!typeSet) { return errorType; } } if (typeSet.length === 0) { - return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : - includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 65536 /* TypeFlags.Null */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* TypeFlags.Undefined */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType; } } - if (!origin && includes & 1048576 /* Union */) { + if (!origin && includes & 1048576 /* TypeFlags.Union */) { var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; - var _loop_17 = function (t) { + var _loop_18 = function (t) { if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) { reducedTypes.push(t); } }; for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) { var t = typeSet_1[_i]; - _loop_17(t); + _loop_18(t); } if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) { return namedUnions[0]; @@ -61896,11 +62094,11 @@ var ts; var t = namedUnions_1[_a]; insertType(reducedTypes, t); } - origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); + origin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, reducedTypes); } } - var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 36323363 /* TypeFlags.NotPrimitiveUnion */ ? 0 : 32768 /* ObjectFlags.PrimitiveUnion */) | + (includes & 2097152 /* TypeFlags.Intersection */ ? 16777216 /* ObjectFlags.ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } function getUnionOrIntersectionTypePredicate(signatures, kind) { @@ -61909,8 +62107,8 @@ var ts; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { - if (kind !== 2097152 /* Intersection */) { + if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { + if (kind !== 2097152 /* TypeFlags.Intersection */) { continue; } else { @@ -61947,20 +62145,20 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving + origin.flags & 1048576 /* TypeFlags.Union */ ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 /* TypeFlags.Intersection */ ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { - type = createType(1048576 /* Union */); - type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* TypeFlags.Union */); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); type.types = types; type.origin = origin; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) { - type.flags |= 16 /* Boolean */; + if (types.length === 2 && types[0].flags & 512 /* TypeFlags.BooleanLiteral */ && types[1].flags & 512 /* TypeFlags.BooleanLiteral */) { + type.flags |= 16 /* TypeFlags.Boolean */; type.intrinsicName = "boolean"; } unionTypes.set(id, type); @@ -61971,41 +62169,41 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* UnionReduction.Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & 16777216 /* IncludesEmptyObject */)) { - includes |= 16777216 /* IncludesEmptyObject */; + if (!(includes & 16777216 /* TypeFlags.IncludesEmptyObject */)) { + includes |= 16777216 /* TypeFlags.IncludesEmptyObject */; typeSet.set(type.id.toString(), type); } } else { - if (flags & 3 /* AnyOrUnknown */) { + if (flags & 3 /* TypeFlags.AnyOrUnknown */) { if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; } - else if (strictNullChecks || !(flags & 98304 /* Nullable */)) { + else if (strictNullChecks || !(flags & 98304 /* TypeFlags.Nullable */)) { if (exactOptionalPropertyTypes && type === missingType) { - includes |= 262144 /* IncludesMissingType */; + includes |= 262144 /* TypeFlags.IncludesMissingType */; type = undefinedType; } if (!typeSet.has(type.id.toString())) { - if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { + if (type.flags & 109440 /* TypeFlags.Unit */ && includes & 109440 /* TypeFlags.Unit */) { // We have seen two distinct unit types which means we should reduce to an // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. - includes |= 67108864 /* NonPrimitive */; + includes |= 67108864 /* TypeFlags.NonPrimitive */; } typeSet.set(type.id.toString(), type); } } - includes |= flags & 205258751 /* IncludesMask */; + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; } return includes; } @@ -62023,12 +62221,12 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || - t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || - t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ || - isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */; + var remove = t.flags & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + t.flags & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + t.flags & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + t.flags & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */ || + t.flags & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */ || + isEmptyAnonymousObjectType(t) && includes & 470302716 /* TypeFlags.DefinitelyNonNullable */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -62041,10 +62239,10 @@ var ts; for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) { var u = unionTypes_1[_i]; if (!containsType(u.types, type)) { - var primitive = type.flags & 128 /* StringLiteral */ ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + var primitive = type.flags & 128 /* TypeFlags.StringLiteral */ ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : undefined; if (!primitive || !containsType(u.types, primitive)) { return false; @@ -62058,11 +62256,11 @@ var ts; */ function extractRedundantTemplateLiterals(types) { var i = types.length; - var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); }); + var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); }); while (i > 0) { i--; var t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */)) continue; for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) { var t2 = literals_1[_i]; @@ -62079,7 +62277,7 @@ var ts; return false; } function eachIsUnionContaining(types, flag) { - return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); + return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); } function removeFromEach(types, flag) { for (var i = 0; i < types.length; i++) { @@ -62091,7 +62289,7 @@ var ts; // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); }); if (index < 0) { return false; } @@ -62100,7 +62298,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -62129,12 +62327,12 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { - var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + var result = createType(2097152 /* TypeFlags.Intersection */); + result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -62163,37 +62361,37 @@ var ts; // a symbol-like type and a type known to be non-symbol-like, or // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. - if (includes & 131072 /* Never */) { + if (includes & 131072 /* TypeFlags.Never */) { return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; } - if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || - includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || - includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || - includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || - includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || - includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || - includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) || + includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) || + includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) || + includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) || + includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) || + includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) || + includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } - if (includes & 1 /* Any */) { - return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType; + if (includes & 1 /* TypeFlags.Any */) { + return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 98304 /* Nullable */) { - return includes & 32768 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) { + return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || - includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || - includes & 16384 /* Void */ && includes & 32768 /* Undefined */ || - includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) { + if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */ || + includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */ || + includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 470302716 /* TypeFlags.DefinitelyNonNullable */) { if (!noSupertypeReduction) removeRedundantSupertypes(typeSet, includes); } - if (includes & 262144 /* IncludesMissingType */) { + if (includes & 262144 /* TypeFlags.IncludesMissingType */) { typeSet[typeSet.indexOf(undefinedType)] = missingType; } if (typeSet.length === 0) { @@ -62205,21 +62403,21 @@ var ts; var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { - if (includes & 1048576 /* Union */) { + if (includes & 1048576 /* TypeFlags.Union */) { if (intersectUnionsOfPrimitiveTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) { + else if (eachIsUnionContaining(typeSet, 32768 /* TypeFlags.Undefined */)) { var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType; - removeFromEach(typeSet, 32768 /* Undefined */); - result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + removeFromEach(typeSet, 32768 /* TypeFlags.Undefined */); + result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) { - removeFromEach(typeSet, 65536 /* Null */); - result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + else if (eachIsUnionContaining(typeSet, 65536 /* TypeFlags.Null */)) { + removeFromEach(typeSet, 65536 /* TypeFlags.Null */); + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } else { // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of @@ -62232,8 +62430,8 @@ var ts; // We attach a denormalized origin type when at least one constituent of the cross-product union is an // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and // the denormalized origin has fewer constituents than the union itself. - var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined; - result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin); + var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* TypeFlags.Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* TypeFlags.Intersection */, typeSet) : undefined; + result = getUnionType(constituents, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments, origin); } } else { @@ -62244,12 +62442,12 @@ var ts; return result; } function getCrossProductUnionSize(types) { - return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* Union */ ? n * t.types.length : t.flags & 131072 /* Never */ ? 0 : n; }, 1); + return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* TypeFlags.Union */ ? n * t.types.length : t.flags & 131072 /* TypeFlags.Never */ ? 0 : n; }, 1); } function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return false; } @@ -62262,7 +62460,7 @@ var ts; var constituents = types.slice(); var n = i; for (var j = types.length - 1; j >= 0; j--) { - if (types[j].flags & 1048576 /* Union */) { + if (types[j].flags & 1048576 /* TypeFlags.Union */) { var sourceTypes = types[j].types; var length_5 = sourceTypes.length; constituents[j] = sourceTypes[n % length_5]; @@ -62270,14 +62468,14 @@ var ts; } } var t = getIntersectionType(constituents); - if (!(t.flags & 131072 /* Never */)) + if (!(t.flags & 131072 /* TypeFlags.Never */)) intersections.push(t); } return intersections; } function getConstituentCount(type) { - return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 : - type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) : + return !(type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) || type.aliasSymbol ? 1 : + type.flags & 1048576 /* TypeFlags.Union */ && type.origin ? getConstituentCount(type.origin) : getConstituentCountOfTypes(type.types); } function getConstituentCountOfTypes(types) { @@ -62288,19 +62486,19 @@ var ts; if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); var types = ts.map(node.types, getTypeFromTypeNode); - var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType; + var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) && types[1] === emptyTypeLiteralType; links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction); } return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(4194304 /* Index */); + var result = createType(4194304 /* TypeFlags.Index */); result.type = type; result.stringsOnly = stringsOnly; return result; } function createOriginIndexType(type) { - var result = createOriginType(4194304 /* Index */); + var result = createOriginType(4194304 /* TypeFlags.Index */); result.type = type; return result; } @@ -62332,7 +62530,7 @@ var ts; // so we only eagerly manifest the keys if the constraint is nongeneric if (!isGenericIndexType(constraintType)) { var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); } else { // we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later @@ -62348,8 +62546,8 @@ var ts; } // we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType, // so we can return the union that preserves aliases/origin data if possible - var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes); - if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { + var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)); }) : getUnionType(keyTypes); + if (result.flags & 1048576 /* TypeFlags.Union */ && constraintType.flags & 1048576 /* TypeFlags.Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { return constraintType; } return result; @@ -62369,12 +62567,12 @@ var ts; var typeVariable = getTypeParameterFromMappedType(mappedType); return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); function isDistributive(type) { - return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true : - type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) : - type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : - type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) : - type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) : + return type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */ | 262144 /* TypeFlags.TypeParameter */ | 524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */) ? true : + type.flags & 16777216 /* TypeFlags.Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? isDistributive(type.substitute) : + type.flags & 268435456 /* TypeFlags.StringMapping */ ? isDistributive(type.type) : false; } } @@ -62386,11 +62584,11 @@ var ts; getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); - type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") : + type = prop.escapedName === "default" /* InternalSymbolName.Default */ ? getStringLiteralType("default") : name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined); } if (type && type.flags & include) { @@ -62400,14 +62598,14 @@ var ts; return neverType; } function isKeyTypeIncluded(keyType, include) { - return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); + return !!(keyType.flags & include || keyType.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); } function getLiteralTypeFromProperties(type, include, includeOrigin) { - var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; + var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); }); var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? - info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); - return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, + info.keyType === stringType && include & 8 /* TypeFlags.Number */ ? stringOrNumberType : info.keyType : neverType; }); + return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* UnionReduction.Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); } /** @@ -62417,24 +62615,27 @@ var ts; * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible). */ function isPossiblyReducibleByInstantiation(type) { - return ts.some(type.types, function (t) { - var uniqueFilled = getUniqueLiteralFilledInstantiation(t); - return getReducedType(uniqueFilled) !== uniqueFilled; - }); + var uniqueFilled = getUniqueLiteralFilledInstantiation(type); + return getReducedType(uniqueFilled) !== uniqueFilled; + } + function shouldDeferIndexType(type) { + return !!(type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || + isGenericTupleType(type) || + isGenericMappedType(type) && !hasDistributiveNameType(type) || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) || + type.flags & 2097152 /* TypeFlags.Intersection */ && maybeTypeOfKind(type, 465829888 /* TypeFlags.Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType)); } function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type) - ? getIndexTypeForGenericType(type, stringsOnly) - : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : + return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 1048576 /* TypeFlags.Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : - type.flags & 2 /* Unknown */ ? neverType : - type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : - getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); + type.flags & 2 /* TypeFlags.Unknown */ ? neverType : + type.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */) ? keyofConstraintType : + getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* TypeFlags.StringLiteral */ : 402653316 /* TypeFlags.StringLike */) | (stringsOnly ? 0 : 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -62445,21 +62646,21 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 131072 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* TypeFlags.Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 140 /* KeyOfKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 154 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 151 /* SymbolKeyword */ + case 154 /* SyntaxKind.UniqueKeyword */: + links.resolvedType = node.type.kind === 151 /* SyntaxKind.SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 145 /* ReadonlyKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -62476,7 +62677,7 @@ var ts; return links.resolvedType; } function getTemplateLiteralType(texts, types) { - var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex >= 0) { return checkCrossProductUnion(types) ? mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : @@ -62495,10 +62696,10 @@ var ts; return getStringLiteralType(text); } newTexts.push(text); - if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) { + if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -62509,13 +62710,13 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; var addText = isTextsArray ? texts[i + 1] : texts; - if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) { + if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) { text += getTemplateStringForType(t) || ""; text += addText; if (!isTextsArray) return true; } - else if (t.flags & 134217728 /* TemplateLiteral */) { + else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { text += t.texts[0]; if (!addSpans(t.texts, t.types)) return false; @@ -62528,7 +62729,7 @@ var ts; newTexts.push(text); text = addText; } - else if (t.flags & 2097152 /* Intersection */) { + else if (t.flags & 2097152 /* TypeFlags.Intersection */) { var added = addSpans(texts[i + 1], t.types); if (!added) return false; @@ -62541,47 +62742,47 @@ var ts; } } function getTemplateStringForType(type) { - return type.flags & 128 /* StringLiteral */ ? type.value : - type.flags & 256 /* NumberLiteral */ ? "" + type.value : - type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : - type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? "" + type.value : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : + type.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) ? type.intrinsicName : undefined; } function createTemplateLiteralType(texts, types) { - var type = createType(134217728 /* TemplateLiteral */); + var type = createType(134217728 /* TypeFlags.TemplateLiteral */); type.texts = texts; type.types = types; return type; } function getStringMappingType(symbol, type) { - return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : + return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : // Mapping> === Mapping - type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : - isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) : - type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : - type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) : + type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type : + isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* TypeFlags.StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) : type; } function applyStringMapping(symbol, str) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return str.toUpperCase(); - case 1 /* Lowercase */: return str.toLowerCase(); - case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); - case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); + case 0 /* IntrinsicTypeKind.Uppercase */: return str.toUpperCase(); + case 1 /* IntrinsicTypeKind.Lowercase */: return str.toLowerCase(); + case 2 /* IntrinsicTypeKind.Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); + case 3 /* IntrinsicTypeKind.Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); } return str; } function applyTemplateStringMapping(symbol, texts, types) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; - case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; - case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; - case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + case 0 /* IntrinsicTypeKind.Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 1 /* IntrinsicTypeKind.Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 2 /* IntrinsicTypeKind.Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + case 3 /* IntrinsicTypeKind.Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; } return [texts, types]; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -62589,13 +62790,13 @@ var ts; return result; } function createStringMappingType(symbol, type) { - var result = createType(268435456 /* StringMapping */); + var result = createType(268435456 /* TypeFlags.StringMapping */); result.symbol = symbol; result.type = type; return result; } function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { - var type = createType(8388608 /* IndexedAccess */); + var type = createType(8388608 /* TypeFlags.IndexedAccess */); type.objectType = objectType; type.indexType = indexType; type.accessFlags = accessFlags; @@ -62616,16 +62817,16 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 4096 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) { return true; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getResolvedBaseConstraint(type); return constraint !== type && isJSLiteralType(constraint); } @@ -62640,26 +62841,26 @@ var ts; undefined; } function isUncalledFunctionReference(node, symbol) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent; if (ts.isCallLikeExpression(parent)) { return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node); } - return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } return true; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { - if (accessFlags & 256 /* Contextual */) { + if (accessFlags & 256 /* AccessFlags.Contextual */) { return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* AccessFlags.ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } @@ -62669,7 +62870,7 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 8 /* CacheSymbol */) { + if (accessFlags & 8 /* AccessFlags.CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -62677,50 +62878,57 @@ var ts; } } var propType = getTypeOfSymbol(prop); - return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? + return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* AssignmentKind.Definite */ ? getFlowTypeOfReference(accessExpression, propType) : propType; } - if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { + if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) { + var index = +propName; + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* AccessFlags.NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { + if (index < 0) { + error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value); + return undefinedType; + } error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); } else { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } } - errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); - return mapType(objectType, function (t) { - var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; - }); + if (index >= 0) { + errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); + return mapType(objectType, function (t) { + var restType = getRestTypeOfTupleType(t) || undefinedType; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; + }); + } } } - if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { + if (!(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */)) { + if (objectType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) { return objectType; } // If no index signature is applicable, we default to the string index signature. In effect, this means the string // index signature applies even when accessing with a symbol-like type. var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType); if (indexInfo) { - if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { + if (accessFlags & 2 /* AccessFlags.NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } return undefined; } - if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } - if (indexType.flags & 131072 /* Never */) { + if (indexType.flags & 131072 /* TypeFlags.Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -62728,21 +62936,21 @@ var ts; } if (accessExpression && !isConstEnumObjectType(objectType)) { if (isObjectLiteralType(objectType)) { - if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (noImplicitAny && indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType))); return undefinedType; } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { var types = ts.map(objectType.properties, function (property) { return getTypeOfSymbol(property); }); return getUnionType(ts.append(types, undefinedType)); } } - if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* SymbolFlags.BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* AccessFlags.SuppressNoImplicitAnyError */)) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { var typeName = typeToString(objectType); error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]"); @@ -62764,20 +62972,20 @@ var ts; } else { var errorInfo = void 0; - if (indexType.flags & 1024 /* EnumLiteral */) { + if (indexType.flags & 1024 /* TypeFlags.EnumLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType)); } - else if (indexType.flags & 8192 /* UniqueESSymbol */) { + else if (indexType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression); errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType)); } - else if (indexType.flags & 128 /* StringLiteral */) { + else if (indexType.flags & 128 /* TypeFlags.StringLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & 256 /* NumberLiteral */) { + else if (indexType.flags & 256 /* TypeFlags.NumberLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType)); } errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType)); @@ -62794,10 +63002,10 @@ var ts; } if (accessNode) { var indexNode = getIndexNodeForAccessExpression(accessNode); - if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { + else if (indexType.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { @@ -62815,62 +63023,62 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 194 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 162 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 194 /* SyntaxKind.IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type)); + return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */ && isPatternLiteralPlaceholderType(type.type)); } function isPatternLiteralType(type) { - return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); + return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); } function isGenericType(type) { return !!getGenericObjectFlags(type); } function isGenericObjectType(type) { - return !!(getGenericObjectFlags(type) & 4194304 /* IsGenericObjectType */); + return !!(getGenericObjectFlags(type) & 4194304 /* ObjectFlags.IsGenericObjectType */); } function isGenericIndexType(type) { - return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */); + return !!(getGenericObjectFlags(type) & 8388608 /* ObjectFlags.IsGenericIndexType */); } function getGenericObjectFlags(type) { - if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 33554432 /* TypeFlags.Substitution */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | - (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0); + return (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* ObjectFlags.IsGenericObjectType */ : 0) | + (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* ObjectFlags.IsGenericIndexType */ : 0); } function getSimplifiedType(type, writing) { - return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : - type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : + return type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getSimplifiedConditionalType(type, writing) : type; } function distributeIndexOverObjectType(objectType, indexType, writing) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 3145728 /* UnionOrIntersection */) { + if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); }); - return objectType.flags & 2097152 /* Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); + return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); } } function distributeObjectOverIndexType(objectType, indexType, writing) { // T[A | B] -> T[A] | T[B] (reading) // T[A | B] -> T[A] & T[B] (writing) - if (indexType.flags & 1048576 /* Union */) { + if (indexType.flags & 1048576 /* TypeFlags.Union */) { var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); }); return writing ? getIntersectionType(types) : getUnionType(types); } @@ -62895,7 +63103,7 @@ var ts; return type[cache] = distributedOverIndex; } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 465829888 /* Instantiable */)) { + if (!(indexType.flags & 465829888 /* TypeFlags.Instantiable */)) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] @@ -62909,8 +63117,8 @@ var ts; // A generic tuple type indexed by a number exists only when the index type doesn't select a // fixed element. We simplify to either the combined type of all elements (when the index type // the actual number type) or to the combined type of all non-fixed elements. - if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) { - var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); + if (isGenericTupleType(objectType) && indexType.flags & 296 /* TypeFlags.NumberLike */) { + var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* TypeFlags.Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); if (elementType) { return type[cache] = elementType; } @@ -62932,19 +63140,19 @@ var ts; var trueType = getTrueTypeFromConditionalType(type); var falseType = getFalseTypeFromConditionalType(type); // Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`. - if (falseType.flags & 131072 /* Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { - if (checkType.flags & 1 /* Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + if (falseType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { + if (checkType.flags & 1 /* TypeFlags.Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return getSimplifiedType(trueType, writing); } else if (isIntersectionEmpty(checkType, extendsType)) { // Always false return neverType; } } - else if (trueType.flags & 131072 /* Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { - if (!(checkType.flags & 1 /* Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + else if (trueType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { + if (!(checkType.flags & 1 /* TypeFlags.Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return neverType; } - else if (checkType.flags & 1 /* Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false + else if (checkType.flags & 1 /* TypeFlags.Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false return getSimplifiedType(falseType, writing); } } @@ -62954,7 +63162,7 @@ var ts; * Invokes union simplification logic to determine if an intersection is considered empty as a union constituent */ function isIntersectionEmpty(type1, type2) { - return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* Never */); + return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* TypeFlags.Never */); } function substituteIndexedMappedType(objectType, index) { var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); @@ -62962,12 +63170,12 @@ var ts; return instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper); } function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { - if (t.flags & 384 /* StringOrNumberLiteral */) { + if (t.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var propName = getPropertyNameFromType(t); if (ts.isNumericLiteralName(propName)) { var index = +propName; @@ -62978,33 +63186,33 @@ var ts; }); } function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. - if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { indexType = stringType; } // In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to // an index signature have 'undefined' included in their type. - if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) - accessFlags |= 1 /* IncludeUndefined */; + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* AccessFlags.ExpressionPosition */) + accessFlags |= 1 /* AccessFlags.IncludeUndefined */; // If the index type is generic, or if the object type is generic and doesn't originate in an expression and // the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing // a higher-order index access where we cannot meaningfully access the properties of the object type. Note that // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* SyntaxKind.IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { - if (objectType.flags & 3 /* AnyOrUnknown */) { + if (objectType.flags & 3 /* TypeFlags.AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var persistentAccessFlags = accessFlags & 1 /* AccessFlags.Persistent */; var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { @@ -63016,12 +63224,12 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getReducedApparentType(objectType); - if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* TypeFlags.Union */ && !(indexType.flags & 16 /* TypeFlags.Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* AccessFlags.SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -63037,11 +63245,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 4 /* Writing */ + return accessFlags & 4 /* AccessFlags.Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) - : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); + : getUnionType(propTypes, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* AccessFlags.CacheSymbol */ | 64 /* AccessFlags.ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -63049,8 +63257,8 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); - links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && + var resolved = getIndexedAccessType(objectType, indexType, 0 /* AccessFlags.None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + links.resolvedType = resolved.flags & 8388608 /* TypeFlags.IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConditionalFlowTypeOfType(resolved, node) : resolved; @@ -63060,7 +63268,7 @@ var ts; function getTypeFromMappedTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(32 /* Mapped */, node.symbol); + var type = createObjectType(32 /* ObjectFlags.Mapped */, node.symbol); type.declaration = node; type.aliasSymbol = getAliasSymbolForTypeNode(node); type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol); @@ -63072,11 +63280,11 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return type.baseType; } - if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ || - type.indexType.flags & 33554432 /* Substitution */)) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */ && (type.objectType.flags & 33554432 /* TypeFlags.Substitution */ || + type.indexType.flags & 33554432 /* TypeFlags.Substitution */)) { return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType)); } return type; @@ -63107,7 +63315,7 @@ var ts; var result; var extraTypes; var tailCount = 0; - var _loop_18 = function () { + var _loop_19 = function () { if (tailCount === 1000) { error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); result = errorType; @@ -63141,7 +63349,7 @@ var ts; // * The mapper that maps the clone to its inference result (`context.mapper`) var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter); var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined; - var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */); + var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */); if (freshMapper) { var freshCombinedMapper = combineTypeMappers(mapper, freshMapper); for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) { @@ -63159,7 +63367,7 @@ var ts; // We don't want inferences from constraints as they may cause us to eagerly resolve the // conditional type instead of deferring resolution. Also, we always want strict function // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); } var innerMapper = combineTypeMappers(freshMapper, context.mapper); // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the @@ -63175,15 +63383,15 @@ var ts; // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, // then no instantiations will be and we can just return the false branch type. - if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */ && !isUnwrapped) { + if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) { (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } // If falseType is an immediately nested conditional type that isn't distributive or has an // identical checkType, switch to that type and loop. var falseType_1 = getTypeFromTypeNode(root.node.falseType); - if (falseType_1.flags & 16777216 /* Conditional */) { + if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) { var newRoot = falseType_1.root; if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { root = newRoot; @@ -63201,7 +63409,7 @@ var ts; // that has no constraint. This ensures that, for example, the type // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. - if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { + if (inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { var trueType_1 = getTypeFromTypeNode(root.node.trueType); var trueMapper = combinedMapper || mapper; if (canTailRecurse(trueType_1, trueMapper)) { @@ -63212,7 +63420,7 @@ var ts; } } // Return a deferred type for a check that is neither definitely true nor definitely false - result = createType(16777216 /* Conditional */); + result = createType(16777216 /* TypeFlags.Conditional */); result.root = root; result.checkType = instantiateType(root.checkType, mapper); result.extendsType = instantiateType(root.extendsType, mapper); @@ -63228,7 +63436,7 @@ var ts; // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive // cases we increment the tail recursion counter and stop after 1000 iterations. while (true) { - var state_5 = _loop_18(); + var state_5 = _loop_19(); if (typeof state_5 === "object") return state_5.value; if (state_5 === "break") @@ -63240,14 +63448,14 @@ var ts; // type. Note that recursion is possible only through aliased conditional types, so we only increment the tail // recursion counter for those. function canTailRecurse(newType, newMapper) { - if (newType.flags & 16777216 /* Conditional */ && newMapper) { + if (newType.flags & 16777216 /* TypeFlags.Conditional */ && newMapper) { var newRoot = newType.root; if (newRoot.outerTypeParameters) { var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper); var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); }); var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments); var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined; - if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) { + if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */))) { root = newRoot; mapper = newRootMapper; aliasSymbol = undefined; @@ -63275,7 +63483,7 @@ var ts; var result; if (node.locals) { node.locals.forEach(function (symbol) { - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { result = ts.append(result, getDeclaredTypeOfSymbol(symbol)); } }); @@ -63298,7 +63506,7 @@ var ts; node: node, checkType: checkType, extendsType: getTypeFromTypeNode(node.extendsType), - isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeFlags.TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -63329,6 +63537,7 @@ var ts; } } function getTypeFromImportTypeNode(node) { + var _a; var links = getNodeLinks(node); if (!links.resolvedType) { if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments @@ -63341,27 +63550,30 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* SymbolFlags.Value */ : node.flags & 8388608 /* NodeFlags.JSDoc */ ? 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ : 788968 /* SymbolFlags.Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } + var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)); var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); if (!ts.nodeIsMissing(node.qualifier)) { var nameStack = getIdentifierChain(node.qualifier); var currentNamespace = moduleSymbol; var current = void 0; while (current = nameStack.shift()) { - var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning; + var meaning = nameStack.length ? 1920 /* SymbolFlags.Namespace */ : targetMeaning; // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from // the `exports` lookup process that only looks up namespace members which is used for most type references var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace)); - var next = node.isTypeOf + var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true) - : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + : undefined; + var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable; if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); return links.resolvedType = errorType; @@ -63377,7 +63589,7 @@ var ts; links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 111551 /* Value */ + var errorMessage = targetMeaning === 111551 /* SymbolFlags.Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -63391,7 +63603,7 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 111551 /* Value */) { + if (meaning === 111551 /* SymbolFlags.Value */) { return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { @@ -63407,7 +63619,7 @@ var ts; links.resolvedType = emptyTypeLiteralType; } else { - var type = createObjectType(16 /* Anonymous */, node.symbol); + var type = createObjectType(16 /* ObjectFlags.Anonymous */, node.symbol); type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); if (ts.isJSDocTypeLiteral(node) && node.isArrayType) { @@ -63420,7 +63632,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -63429,13 +63641,13 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function isNonGenericObjectType(type) { - return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + return !!(type.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(type); } function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) { - return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); + return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return type; } if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { @@ -63455,13 +63667,13 @@ var ts; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // do nothing, skip privates } else if (isSpreadableProperty(prop)) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - var flags = 4 /* Property */ | 16777216 /* Optional */; - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */; + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -63470,7 +63682,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return spread; } } @@ -63480,31 +63692,31 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, symbol, objectFlags, readonly) { - if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + if (left.flags & 1 /* TypeFlags.Any */ || right.flags & 1 /* TypeFlags.Any */) { return anyType; } - if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + if (left.flags & 2 /* TypeFlags.Unknown */ || right.flags & 2 /* TypeFlags.Unknown */) { return unknownType; } - if (left.flags & 131072 /* Never */) { + if (left.flags & 131072 /* TypeFlags.Never */) { return right; } - if (right.flags & 131072 /* Never */) { + if (right.flags & 131072 /* TypeFlags.Never */) { return left; } left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); - if (left.flags & 1048576 /* Union */) { + if (left.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) : errorType; } right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); - if (right.flags & 1048576 /* Union */) { + if (right.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) : errorType; } - if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { + if (right.flags & (528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)) { return left; } if (isGenericObjectType(left) || isGenericObjectType(right)) { @@ -63514,7 +63726,7 @@ var ts; // When the left type is an intersection, we may need to merge the last constituent of the // intersection with the right type. For example when the left type is 'T & { a: string }' // and the right type is '{ b: string }' we produce 'T & { a: string, b: string }'. - if (left.flags & 2097152 /* Intersection */) { + if (left.flags & 2097152 /* TypeFlags.Intersection */) { var types = left.types; var lastLeft = types[types.length - 1]; if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { @@ -63528,7 +63740,7 @@ var ts; var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { @@ -63543,11 +63755,11 @@ var ts; if (members.has(leftProp.escapedName)) { var rightProp = members.get(leftProp.escapedName); var rightType = getTypeOfSymbol(rightProp); - if (rightProp.flags & 16777216 /* Optional */) { + if (rightProp.flags & 16777216 /* SymbolFlags.Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); + var flags = 4 /* SymbolFlags.Property */ | (leftProp.flags & 16777216 /* SymbolFlags.Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */); + result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* UnionReduction.Subtype */); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -63560,23 +63772,23 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); })); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */ | 2097152 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 2097152 /* ObjectFlags.ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { var _a; return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && - (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + (!(prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) || !((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); }))); } function getSpreadSymbol(prop, readonly) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) { return prop; } - var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var flags = 4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */); + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -63594,7 +63806,7 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 2944 /* Literal */) { + if (type.flags & 2944 /* TypeFlags.Literal */) { if (!type.freshType) { var freshType = createLiteralType(type.flags, type.value, type.symbol, type); freshType.freshType = freshType; @@ -63605,39 +63817,39 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 2944 /* Literal */ ? type.regularType : - type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : + return type.flags & 2944 /* TypeFlags.Literal */ ? type.regularType : + type.flags & 1048576 /* TypeFlags.Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + return !!(type.flags & 2944 /* TypeFlags.Literal */) && type.freshType === type; } function getStringLiteralType(value) { var type; return stringLiteralTypes.get(value) || - (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type); + (stringLiteralTypes.set(value, type = createLiteralType(128 /* TypeFlags.StringLiteral */, value)), type); } function getNumberLiteralType(value) { var type; return numberLiteralTypes.get(value) || - (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type); + (numberLiteralTypes.set(value, type = createLiteralType(256 /* TypeFlags.NumberLiteral */, value)), type); } function getBigIntLiteralType(value) { var type; var key = ts.pseudoBigIntToString(value); return bigIntLiteralTypes.get(key) || - (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type); + (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* TypeFlags.BigIntLiteral */, value)), type); } function getEnumLiteralType(value, enumId, symbol) { var type; var qualifier = typeof value === "string" ? "@" : "#"; var key = enumId + qualifier + value; - var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */); + var flags = 1024 /* TypeFlags.EnumLiteral */ | (typeof value === "string" ? 128 /* TypeFlags.StringLiteral */ : 256 /* TypeFlags.NumberLiteral */); return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type); } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 104 /* NullKeyword */) { + if (node.literal.kind === 104 /* SyntaxKind.NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -63647,9 +63859,9 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(8192 /* UniqueESSymbol */); + var type = createType(8192 /* TypeFlags.UniqueESSymbol */); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -63665,20 +63877,20 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) { if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } // inside x.prototype = { ... } - if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; } // /** @return {this} */ // x.prototype.m = function() { ... } - var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; - if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; } // inside constructor function C() { ... } @@ -63700,17 +63912,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 186 /* RestType */ || node.kind === 197 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 186 /* SyntaxKind.RestType */ || node.kind === 197 /* SyntaxKind.NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return node.elementType; } return undefined; @@ -63726,99 +63938,99 @@ var ts; } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return anyType; - case 155 /* UnknownKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return unknownType; - case 150 /* StringKeyword */: + case 150 /* SyntaxKind.StringKeyword */: return stringType; - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return numberType; - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return bigintType; - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return booleanType; - case 151 /* SymbolKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: return esSymbolType; - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return voidType; - case 153 /* UndefinedKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: return undefinedType; - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 143 /* NeverKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return neverType; - case 148 /* ObjectKeyword */: - return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 138 /* IntrinsicKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + return node.flags & 262144 /* NodeFlags.JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; + case 138 /* SyntaxKind.IntrinsicKeyword */: return intrinsicMarkerType; - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return getTypeFromLiteralTypeNode(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getTypeFromTypeReference(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return getTypeFromTypeQueryNode(node); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return getTypeFromOptionalTypeNode(node); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return getTypeFromUnionTypeNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 191 /* ParenthesizedType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: return getTypeFromRestTypeNode(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return getTypeFromMappedTypeNode(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return getTypeFromInferTypeNode(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -63856,9 +64068,9 @@ var ts; } function getMappedType(type, mapper) { switch (mapper.kind) { - case 0 /* Simple */: + case 0 /* TypeMapKind.Simple */: return type === mapper.source ? mapper.target : type; - case 1 /* Array */: + case 1 /* TypeMapKind.Array */: { var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -63867,25 +64079,39 @@ var ts; } } return type; - case 2 /* Function */: + } + case 2 /* TypeMapKind.Deferred */: { + var sources = mapper.sources; + var targets = mapper.targets; + for (var i = 0; i < sources.length; i++) { + if (type === sources[i]) { + return targets[i](); + } + } + return type; + } + case 3 /* TypeMapKind.Function */: return mapper.func(type); - case 3 /* Composite */: - case 4 /* Merged */: + case 4 /* TypeMapKind.Composite */: + case 5 /* TypeMapKind.Merged */: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 4 /* TypeMapKind.Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0 /* Simple */, source: source, target: target }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 0 /* TypeMapKind.Simple */, source: source, target: target }); } function makeArrayTypeMapper(sources, targets) { - return { kind: 1 /* Array */, sources: sources, targets: targets }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 1 /* TypeMapKind.Array */, sources: sources, targets: targets }); + } + function makeFunctionTypeMapper(func, debugInfo) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 3 /* TypeMapKind.Function */, func: func, debugInfo: ts.Debug.isDebugging ? debugInfo : undefined }); } - function makeFunctionTypeMapper(func) { - return { kind: 2 /* Function */, func: func }; + function makeDeferredTypeMapper(sources, targets) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 2 /* TypeMapKind.Deferred */, sources: sources, targets: targets }); } function makeCompositeTypeMapper(kind, mapper1, mapper2) { - return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: kind, mapper1: mapper1, mapper2: mapper2 }); } function createTypeEraser(sources) { return createTypeMapper(sources, /*targets*/ undefined); @@ -63895,19 +64121,20 @@ var ts; * This is used during inference when instantiating type parameter defaults. */ function createBackreferenceMapper(context, index) { - return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); + var forwardInferences = context.inferences.slice(index); + return createTypeMapper(ts.map(forwardInferences, function (i) { return i.typeParameter; }), ts.map(forwardInferences, function () { return unknownType; })); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4 /* TypeMapKind.Composite */, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -63940,7 +64167,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -63952,7 +64179,7 @@ var ts; // be affected by instantiation, simply return the symbol itself. return symbol; } - if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + if (ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) { // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -63961,7 +64188,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (8 /* Readonly */ | 4096 /* Late */ | 16384 /* OptionalParameter */ | 32768 /* RestParameter */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* CheckFlags.Instantiated */ | ts.getCheckFlags(symbol) & (8 /* CheckFlags.Readonly */ | 4096 /* CheckFlags.Late */ | 16384 /* CheckFlags.OptionalParameter */ | 32768 /* CheckFlags.RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -63975,12 +64202,12 @@ var ts; return result; } function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { - var declaration = type.objectFlags & 4 /* Reference */ ? type.node : - type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : + var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node : + type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); - var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : - type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType : + type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type; var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type @@ -63993,8 +64220,8 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; - typeParameters = (target.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -64015,8 +64242,8 @@ var ts; var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } @@ -64025,8 +64252,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.parent.kind === 178 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 200 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -64035,7 +64262,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 235 /* Block */ || n.kind === 189 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -64044,15 +64271,15 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return !!tp.isThisType; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return true; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return !node.type && !!node.body || ts.some(node.typeParameters, containsReference) || ts.some(node.parameters, containsReference) || @@ -64063,9 +64290,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { var typeVariable = getActualTypeVariable(constraintType.type); - if (typeVariable.flags & 262144 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeFlags.TypeParameter */) { return typeVariable; } } @@ -64087,10 +64314,10 @@ var ts; var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) { + if (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && t !== wildcardType && !isErrorType(t)) { if (!type.declaration.nameType) { var constraint = void 0; - if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && + if (isArrayType(t) || t.flags & 1 /* TypeFlags.Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } @@ -64111,7 +64338,7 @@ var ts; return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments); } function getModifiedReadonlyState(state, modifiers) { - return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state; + return modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? true : modifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */ ? false : state; } function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) { // When a tuple type is generic (i.e. when it contains variadic elements), we want to eagerly map the @@ -64120,14 +64347,14 @@ var ts; // normalization to resolve the non-generic parts of the resulting tuple. var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) { - var singleton = elementFlags[i] & 8 /* Variadic */ ? t : - elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : + var singleton = elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : + elementFlags[i] & 4 /* ElementFlags.Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]); // The singleton is never a generic tuple type, so it is safe to recurse here. return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper)); }); var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType)); - return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* Variadic */; }), newReadonly); + return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* ElementFlags.Variadic */; }), newReadonly); } function instantiateMappedArrayType(arrayType, mappedType, mapper) { var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper); @@ -64137,11 +64364,11 @@ var ts; function instantiateMappedTupleType(tupleType, mappedType, mapper) { var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { - return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); + return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* ElementFlags.Optional */), mapper); }); var modifiers = getMappedTypeModifiers(mappedType); - var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) : - modifiers & 8 /* ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var newTupleModifiers = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? 2 /* ElementFlags.Optional */ : f; }) : + modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : elementFlags; var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers); return ts.contains(elementTypes, errorType) ? errorType : @@ -64151,13 +64378,13 @@ var ts; var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + return strictNullChecks && modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + strictNullChecks && modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { - var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); - if (type.objectFlags & 32 /* Mapped */) { + var result = createObjectType(type.objectFlags | 64 /* ObjectFlags.Instantiated */, type.symbol); + if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { result.declaration = type.declaration; // C.f. instantiateSignature var origTypeParameter = getTypeParameterFromMappedType(type); @@ -64166,13 +64393,14 @@ var ts; mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper); freshTypeParameter.mapper = mapper; } - if (type.objectFlags & 8388608 /* InstantiationExpressionType */) { + if (type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */) { result.node = type.node; } result.target = type; result.mapper = mapper; result.aliasSymbol = aliasSymbol || type.aliasSymbol; result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0; return result; } function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { @@ -64191,7 +64419,7 @@ var ts; // Distributive conditional types are distributed over union types. For example, when the // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the // result is (A extends U ? X : Y) | (B extends U ? X : Y). - result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? + result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); @@ -64211,7 +64439,7 @@ var ts; // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } @@ -64224,62 +64452,62 @@ var ts; } function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; - if (flags & 262144 /* TypeParameter */) { + if (flags & 262144 /* TypeFlags.TypeParameter */) { return getMappedType(type, mapper); } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { var objectFlags = type.objectFlags; - if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !type.node) { + if (objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + if (objectFlags & 4 /* ObjectFlags.Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { return instantiateReverseMappedType(type, mapper); } return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } - if (flags & 3145728 /* UnionOrIntersection */) { - var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; - var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; + if (flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + var origin = type.flags & 1048576 /* TypeFlags.Union */ ? type.origin : undefined; + var types = origin && origin.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); if (newTypes === types && aliasSymbol === type.aliasSymbol) { return type; } var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); - return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? + return flags & 2097152 /* TypeFlags.Intersection */ || origin && origin.flags & 2097152 /* TypeFlags.Intersection */ ? getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : - getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); + getUnionType(newTypes, 1 /* UnionReduction.Literal */, newAliasSymbol, newAliasTypeArguments); } - if (flags & 4194304 /* Index */) { + if (flags & 4194304 /* TypeFlags.Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 134217728 /* TemplateLiteral */) { + if (flags & 134217728 /* TypeFlags.TemplateLiteral */) { return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper)); } - if (flags & 268435456 /* StringMapping */) { + if (flags & 268435456 /* TypeFlags.StringMapping */) { return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } - if (flags & 8388608 /* IndexedAccess */) { + if (flags & 8388608 /* TypeFlags.IndexedAccess */) { var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); } - if (flags & 16777216 /* Conditional */) { + if (flags & 16777216 /* TypeFlags.Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } - if (flags & 33554432 /* Substitution */) { + if (flags & 33554432 /* TypeFlags.Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); - if (maybeVariable.flags & 8650752 /* TypeVariable */) { + if (maybeVariable.flags & 8650752 /* TypeFlags.TypeVariable */) { return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper)); } else { var sub = instantiateType(type.substitute, mapper); - if (sub.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { + if (sub.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { return maybeVariable; } return sub; @@ -64289,11 +64517,11 @@ var ts; } function instantiateReverseMappedType(type, mapper) { var innerMappedType = instantiateType(type.mappedType, mapper); - if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + if (!(ts.getObjectFlags(innerMappedType) & 32 /* ObjectFlags.Mapped */)) { return type; } var innerIndexType = instantiateType(type.constraintType, mapper); - if (!(innerIndexType.flags & 4194304 /* Index */)) { + if (!(innerIndexType.flags & 4194304 /* TypeFlags.Index */)) { return type; } var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); @@ -64303,15 +64531,15 @@ var ts; return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable } function getUniqueLiteralFilledInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper)); } function getPermissiveInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); } function getRestrictiveInstantiation(type) { - if (type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */)) { + if (type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) { return type; } if (type.restrictiveInstantiation) { @@ -64332,35 +64560,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 221 /* BinaryExpression */: - return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && + case 221 /* SyntaxKind.BinaryExpression */: + return (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return isContextSensitive(node.initializer); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isContextSensitive(node.expression); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 285 /* JsxAttribute */: { + case 285 /* SyntaxKind.JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 288 /* JsxExpression */: { + case 288 /* SyntaxKind.JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -64374,17 +64602,17 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* SyntaxKind.Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { - var result = createObjectType(16 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* ObjectFlags.Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = ts.emptyArray; @@ -64393,7 +64621,7 @@ var ts; return result; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -64403,13 +64631,13 @@ var ts; return isTypeRelatedTo(source, target, identityRelation); } function compareTypesIdentical(source, target) { - return isTypeRelatedTo(source, target, identityRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, identityRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesAssignable(source, target) { - return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesSubtypeOf(source, target) { - return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); @@ -64426,11 +64654,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 1048576 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : - target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 1048576 /* TypeFlags.Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* TypeFlags.Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType)); } /** @@ -64468,7 +64696,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* TypeFlags.Conditional */ || (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { if (!node || isOrHasGenericConditional(target)) @@ -64478,35 +64706,35 @@ var ts; return true; } switch (node.kind) { - case 288 /* JsxExpression */: - case 212 /* ParenthesizedExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 27 /* CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; } function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { - var callSignatures = getSignaturesOfType(source, 0 /* Call */); - var constructSignatures = getSignaturesOfType(source, 1 /* Construct */); + var callSignatures = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructSignatures = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) { var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = errorOutputContainer || {}; checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj); @@ -64530,7 +64758,7 @@ var ts; if (!sourceSig) { return false; } - var targetSignatures = getSignaturesOfType(target, 0 /* Call */); + var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */); if (!ts.length(targetSignatures)) { return false; } @@ -64548,7 +64776,7 @@ var ts; if (target.symbol && ts.length(target.symbol.declarations)) { ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); } - if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0 + if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 // exclude cases where source itself is promisy - this way we don't make a suggestion when relating // an IPromise and a Promise that are slightly different && !getTypeOfPropertyOfType(sourceReturn, "then") @@ -64565,7 +64793,7 @@ var ts; if (idx) { return idx; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { var best = getBestMatchingType(source, target); if (best) { return getIndexedAccessTypeOrUndefined(best, nameType); @@ -64575,7 +64803,7 @@ var ts; function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) { next.contextualType = sourcePropType; try { - return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType); + return checkExpressionForMutableLocation(next, 1 /* CheckMode.Contextual */, sourcePropType); } finally { next.contextualType = undefined; @@ -64592,7 +64820,7 @@ var ts; for (var status = iterator.next(); !status.done; status = iterator.next()) { var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType); - if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) + if (!targetPropType || targetPropType.flags & 8388608 /* TypeFlags.IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); if (!sourcePropType) @@ -64612,8 +64840,8 @@ var ts; resultObj.errors = [diag]; } else { - var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); - var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); targetPropType = removeMissingType(targetPropType, targetIsOptional); sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); @@ -64637,7 +64865,7 @@ var ts; if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) { var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0]; if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) { - ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); } } } @@ -64703,18 +64931,18 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: if (child.containsOnlyTriviaWhiteSpaces) { break; // Whitespace only jsx text isn't real jsx text } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -64739,7 +64967,7 @@ var ts; var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); }); if (moreThanOneRealChildren) { if (arrayLikeTargetParts !== neverType) { - var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */)); + var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */)); var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic); result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result; } @@ -64821,7 +65049,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & (131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -64831,7 +65059,7 @@ var ts; var oldContext = node.contextualType; node.contextualType = target; try { - var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); + var tupleizedType = checkArrayLiteral(node, 1 /* CheckMode.Contextual */, /*forceTuple*/ true); node.contextualType = oldContext; if (isTupleLikeType(tupleizedType)) { return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); @@ -64856,17 +65084,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 131072 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* TypeFlags.Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 173 /* SetAccessor */: return [3 /*break*/, 2]; - case 172 /* GetAccessor */: return [3 /*break*/, 2]; - case 169 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 297 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 296 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 173 /* SyntaxKind.SetAccessor */: return [3 /*break*/, 2]; + case 172 /* SyntaxKind.GetAccessor */: return [3 /*break*/, 2]; + case 169 /* SyntaxKind.MethodDeclaration */: return [3 /*break*/, 2]; + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 296 /* SyntaxKind.PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -64888,7 +65116,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & (131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -64900,8 +65128,8 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* IgnoreReturnTypes */ : 0, /*reportErrors*/ false, - /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* False */; + return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* SignatureCheckMode.IgnoreReturnTypes */ : 0, /*reportErrors*/ false, + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* Ternary.False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -64917,16 +65145,16 @@ var ts; function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isAnySignature(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var targetCount = getParameterCount(target); var sourceHasMoreParameters = !hasEffectiveRestParameter(target) && - (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); + (checkMode & 8 /* SignatureCheckMode.StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); if (sourceHasMoreParameters) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); @@ -64938,10 +65166,10 @@ var ts; if (sourceRestType || targetRestType) { void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers); } - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 169 /* MethodDeclaration */ && - kind !== 168 /* MethodSignature */ && kind !== 171 /* Constructor */; - var result = -1 /* True */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + var strictVariance = !(checkMode & 3 /* SignatureCheckMode.Callback */) && strictFunctionTypes && kind !== 169 /* SyntaxKind.MethodDeclaration */ && + kind !== 168 /* SyntaxKind.MethodSignature */ && kind !== 171 /* SyntaxKind.Constructor */; + var result = -1 /* Ternary.True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { var targetThisType = getThisTypeOfSignature(target); @@ -64953,7 +65181,7 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64972,27 +65200,27 @@ var ts; // similar to return values, callback parameters are output positions. This means that a Promise, // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) // with respect to T. - var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); - var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); + var sourceSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getTypeFacts(sourceType) & 50331648 /* IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* IsUndefinedOrNull */); + (getTypeFacts(sourceType) & 50331648 /* TypeFacts.IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* TypeFacts.IsUndefinedOrNull */); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : - !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* SignatureCheckMode.StrictArity */) | (strictVariance ? 2 /* SignatureCheckMode.StrictCallback */ : 1 /* SignatureCheckMode.BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : + !(checkMode & 3 /* SignatureCheckMode.Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { - related = 0 /* False */; + if (related && checkMode & 8 /* SignatureCheckMode.StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + related = 0 /* Ternary.False */; } if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } } - if (!(checkMode & 4 /* IgnoreReturnTypes */)) { + if (!(checkMode & 4 /* SignatureCheckMode.IgnoreReturnTypes */)) { // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType @@ -65015,14 +65243,14 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } else { // When relating callback signatures, we still need to relate return types bi-variantly as otherwise // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } // wouldn't be co-variant for T without this rule. - result &= checkMode & 1 /* BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + result &= checkMode & 1 /* SignatureCheckMode.BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); if (!result && reportErrors && incompatibleErrorReporter) { incompatibleErrorReporter(sourceReturnType, targetReturnType); @@ -65037,21 +65265,21 @@ var ts; errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { + if (source.kind === 1 /* TypePredicateKind.Identifier */ || source.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var related = source.type === target.type ? -1 /* True */ : + var related = source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; - if (related === 0 /* False */ && reportErrors) { + 0 /* Ternary.False */; + if (related === 0 /* Ternary.False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return related; @@ -65077,33 +65305,33 @@ var ts; t.indexInfos.length === 0; } function isEmptyObjectType(type) { - return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 67108864 /* NonPrimitive */ ? true : - type.flags & 1048576 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* TypeFlags.Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 67108864 /* TypeFlags.NonPrimitive */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isEmptyObjectType) : false; } function isEmptyAnonymousObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) || - type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && (type.members && isEmptyResolvedType(type) || + type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); } function isUnknownLikeUnionType(type) { - if (strictNullChecks && type.flags & 1048576 /* Union */) { - if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) { + if (strictNullChecks && type.flags & 1048576 /* TypeFlags.Union */) { + if (!(type.objectFlags & 33554432 /* ObjectFlags.IsUnknownLikeUnionComputed */)) { var types = type.types; - type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ && - types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0); + type.objectFlags |= 33554432 /* ObjectFlags.IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* TypeFlags.Undefined */ && + types[1].flags & 65536 /* TypeFlags.Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* ObjectFlags.IsUnknownLikeUnion */ : 0); } - return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */); + return !!(type.objectFlags & 67108864 /* ObjectFlags.IsUnknownLikeUnion */); } return false; } function containsUndefinedType(type) { - return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */); + return !!((type.flags & 1048576 /* TypeFlags.Union */ ? type.types[0] : type).flags & 32768 /* TypeFlags.Undefined */); } function isStringIndexSignatureOnlyType(type) { - return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || - type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || + return type.flags & 524288 /* TypeFlags.Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -65112,83 +65340,83 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var entry = enumRelation.get(id); - if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { - return !!(entry & 1 /* Succeeded */); + if (entry !== undefined && !(!(entry & 4 /* RelationComparisonResult.Reported */) && entry & 2 /* RelationComparisonResult.Failed */ && errorReporter)) { + return !!(entry & 1 /* RelationComparisonResult.Succeeded */); } - if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* SymbolFlags.RegularEnum */) || !(targetSymbol.flags & 256 /* SymbolFlags.RegularEnum */)) { + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) { var property = _a[_i]; - if (property.flags & 8 /* EnumMember */) { + if (property.flags & 8 /* SymbolFlags.EnumMember */) { var targetProperty = getPropertyOfType(targetEnumType, property.escapedName); - if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { + if (!targetProperty || !(targetProperty.flags & 8 /* SymbolFlags.EnumMember */)) { if (errorReporter) { - errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */)); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); } else { - enumRelation.set(id, 2 /* Failed */); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */); } return false; } } } - enumRelation.set(id, 1 /* Succeeded */); + enumRelation.set(id, 1 /* RelationComparisonResult.Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) + if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType) return true; - if (t & 131072 /* Never */) + if (t & 131072 /* TypeFlags.Never */) return false; - if (s & 402653316 /* StringLike */ && t & 4 /* String */) + if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */) return true; - if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && - t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 296 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */) return true; - if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && - t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) + if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */) return true; - if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */) return true; - if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) + if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */) return true; - if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { - if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) { + if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && + if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`. // Since unions and intersections may reduce to `never`, we exclude them here. - if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) + if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */))) return true; - if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) + if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */)) return true; - if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */))) + if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */))) return true; if (relation === assignableRelation || relation === comparableRelation) { - if (s & 1 /* Any */) + if (s & 1 /* TypeFlags.Any */) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any // numeric enum literal type. This rule exists for backwards compatibility reasons because // bit-flag enum types sometimes look like literal enum types with numeric literal values. - if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */)) return true; // Anything is assignable to a union containing undefined, null, and {} if (isUnknownLikeUnionType(target)) @@ -65207,38 +65435,38 @@ var ts; return true; } if (relation !== identityRelation) { - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { return true; } } - else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) { + else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) { // We have excluded types that may simplify to other forms, so types must have identical flags if (source.flags !== target.flags) return false; - if (source.flags & 67358815 /* Singleton */) + if (source.flags & 67358815 /* TypeFlags.Singleton */) return true; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false)); + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { + var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false)); if (related !== undefined) { - return !!(related & 1 /* Succeeded */); + return !!(related & 1 /* RelationComparisonResult.Succeeded */); } } - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { var t = isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type : - type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) : - type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : - type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : + ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type : + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? writing ? type.baseType : type.substitute : + type.flags & 25165824 /* TypeFlags.Simplifiable */ ? getSimplifiedType(type, writing) : type; if (t === type) return t; @@ -65250,7 +65478,7 @@ var ts; if (reduced !== type) { return reduced; } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); }); if (normalizedTypes !== type.types) { return getIntersectionType(normalizedTypes); @@ -65278,19 +65506,19 @@ var ts; var maybeCount = 0; var sourceDepth = 0; var targetDepth = 0; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; var overflow = false; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid var lastSkippedInfo; var incompatibleStack; var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage); + var result = isRelatedTo(source, target, 3 /* RecursionFlags.Both */, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack) { reportIncompatibleStack(); } if (overflow) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -65328,10 +65556,10 @@ var ts; diagnostics.add(diag); } } - if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) { + if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* Ternary.False */) { ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } - return result !== 0 /* False */; + return result !== 0 /* Ternary.False */; function resetErrorInfo(saved) { errorInfo = saved.errorInfo; lastSkippedInfo = saved.lastSkippedInfo; @@ -65376,24 +65604,24 @@ var ts; case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { // Parenthesize a `new` if there is one if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; // If leading, just print back the arg (irrespective of if it's a valid identifier) if (path.length === 0) { - path = "" + str; + path = "".concat(str); } // Otherwise write a dotted name if possible else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } // Failing that, check if the name is already a computed name else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } // And finally write out a computed name as a last resort else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -65422,7 +65650,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -65435,7 +65663,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -65487,7 +65715,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 /* TypeFlags.TypeParameter */ && target !== markerSuperTypeForCheck && target !== markerSubTypeForCheck) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -65509,7 +65737,7 @@ var ts; message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; } else { - if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */ && target.flags & 1048576 /* TypeFlags.Union */) { var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target); if (suggestedType) { reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType)); @@ -65571,7 +65799,7 @@ var ts; return true; } function isRelatedToWorker(source, target, reportErrors) { - return isRelatedTo(source, target, 3 /* Both */, reportErrors); + return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors); } /** * Compare two types and return @@ -65580,19 +65808,19 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) { - if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; } + if (recursionFlags === void 0) { recursionFlags = 3 /* RecursionFlags.Both */; } if (reportErrors === void 0) { reportErrors = false; } - if (intersectionState === void 0) { intersectionState = 0 /* None */; } + if (intersectionState === void 0) { intersectionState = 0 /* IntersectionState.None */; } // Before normalization: if `source` is type an object type, and `target` is primitive, // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result - if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) { + if (originalSource.flags & 524288 /* TypeFlags.Object */ && originalTarget.flags & 131068 /* TypeFlags.Primitive */) { if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (reportErrors) { reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and @@ -65601,73 +65829,73 @@ var ts; var source = getNormalizedType(originalSource, /*writing*/ false); var target = getNormalizedType(originalTarget, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; if (relation === identityRelation) { if (source.flags !== target.flags) - return 0 /* False */; - if (source.flags & 67358815 /* Singleton */) - return -1 /* True */; + return 0 /* Ternary.False */; + if (source.flags & 67358815 /* TypeFlags.Singleton */) + return -1 /* Ternary.True */; traceUnionsOrIntersectionsTooLarge(source, target); - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* IntersectionState.None */, recursionFlags); } // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, // as we break down the _target_ union first, _then_ get the source constraint - so for every // member of the target, we attempt to find a match in the source. This avoids that in cases where // the target is exactly the constraint. - if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) { - return -1 /* True */; + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && getConstraintOfType(source) === target) { + return -1 /* Ternary.True */; } // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined // plus a single non-nullable type. If so, remove null and/or undefined from the target type. - if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) { + if (source.flags & 470302716 /* TypeFlags.DefinitelyNonNullable */ && target.flags & 1048576 /* TypeFlags.Union */) { var types = target.types; - var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : - types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : + var candidate = types.length === 2 && types[0].flags & 98304 /* TypeFlags.Nullable */ ? types[1] : + types.length === 3 && types[0].flags & 98304 /* TypeFlags.Nullable */ && types[1].flags & 98304 /* TypeFlags.Nullable */ ? types[2] : undefined; - if (candidate && !(candidate.flags & 98304 /* Nullable */)) { + if (candidate && !(candidate.flags & 98304 /* TypeFlags.Nullable */)) { target = getNormalizedType(candidate, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) - return -1 /* True */; - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* FreshLiteral */); + return -1 /* Ternary.True */; + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* IntersectionState.Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) && - source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && - target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* IntersectionState.Target */) && + source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType && + target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source); var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target); - var calls = getSignaturesOfType(source, 0 /* Call */); - var constructs = getSignaturesOfType(source, 1 /* Construct */); - if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) || - constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) { + var calls = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructs = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString); } else { reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString); } } - return 0 /* False */; + return 0 /* Ternary.False */; } traceUnionsOrIntersectionsTooLarge(source, target); - var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) || - target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */); + var skipCaching = source.flags & 1048576 /* TypeFlags.Union */ && source.types.length < 4 && !(target.flags & 1048576 /* TypeFlags.Union */) || + target.flags & 1048576 /* TypeFlags.Union */ && target.types.length < 4 && !(source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */); var result_7 = skipCaching ? unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) : recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags); @@ -65686,10 +65914,10 @@ 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_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) { + if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) { inPropertyCheck = true; - result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags); + result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags); inPropertyCheck = false; } if (result_7) { @@ -65699,7 +65927,7 @@ var ts; if (reportErrors) { reportErrorResults(originalSource, originalTarget, source, target, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { var _a, _b; @@ -65711,20 +65939,20 @@ var ts; if (maybeSuppress) { overrideNextErrorInfo--; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true); if (errorInfo !== currentError) { maybeSuppress = !!errorInfo; } } - if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 131068 /* TypeFlags.Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* TypeFlags.Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } - else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) { + else if (ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && target.flags & 2097152 /* TypeFlags.Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -65743,7 +65971,7 @@ var ts; return; } reportRelationError(headMessage, source, target); - if (source.flags & 262144 /* TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) { + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) { var syntheticParam = cloneTypeParameter(source); syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam)); if (hasNonCircularBaseConstraint(syntheticParam)) { @@ -65756,17 +65984,17 @@ var ts; if (!ts.tracing) { return; } - if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { + if ((source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) && (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* ObjectFlags.PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } var sourceSize = sourceUnionOrIntersection.types.length; var targetSize = targetUnionOrIntersection.types.length; if (sourceSize * targetSize > 1E6) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { + ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { sourceId: source.id, sourceSize: sourceSize, targetId: target.id, @@ -65781,7 +66009,7 @@ var ts; var appendPropType = function (propTypes, type) { var _a; type = getApparentType(type); - var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); + var prop = type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType; return ts.append(propTypes, propType); }; @@ -65789,21 +66017,21 @@ var ts; } function hasExcessProperties(source, target, reportErrors) { var _a; - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* JSLiteral */) { + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* ObjectFlags.JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; } var reducedTarget = target; var checkTypes; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); - checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; + checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget]; } - var _loop_19 = function (prop) { + var _loop_20 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { @@ -65856,7 +66084,7 @@ var ts; } return { value: true }; } - if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) { + if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* RecursionFlags.Both */, reportErrors)) { if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop)); } @@ -65866,7 +66094,7 @@ var ts; }; for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { var prop = _b[_i]; - var state_6 = _loop_19(prop); + var state_6 = _loop_20(prop); if (typeof state_6 === "object") return state_6.value; } @@ -65879,28 +66107,28 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState); } - if (target.flags & 1048576 /* Union */) { - return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); + if (target.flags & 1048576 /* TypeFlags.Union */) { + return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */) && !(target.flags & 131068 /* TypeFlags.Primitive */)); } - if (target.flags & 2097152 /* Intersection */) { - return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */); + if (target.flags & 2097152 /* TypeFlags.Intersection */) { + return typeRelatedToEachType(source, target, reportErrors, 2 /* IntersectionState.Target */); } // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the // constraints of all non-primitive types in the source into a new intersection. We do this because the // intersection may further constrain the constraints of the non-primitive types. For example, given a type // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't // appear to be comparable to '2'. - if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { + if (relation === comparableRelation && target.flags & 131068 /* TypeFlags.Primitive */) { var constraints = ts.sameMap(source.types, getBaseConstraintOrType); if (constraints !== source.types) { source = getIntersectionType(constraints); - if (!(source.flags & 2097152 /* Intersection */)) { - return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false); + if (!(source.flags & 2097152 /* TypeFlags.Intersection */)) { + return isRelatedTo(source, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false); } } } @@ -65908,16 +66136,16 @@ var ts; // Don't report errors though. Elaborating on whether a source constituent is related to the target is // not actually useful and leads to some confusing error messages. Instead, we rely on the caller // checking whether the full intersection viewed as an object is related to the target. - return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */); + return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* IntersectionState.Source */); } function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65925,13 +66153,13 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { if (containsType(targetTypes, source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var match = getMatchingUnionConstituentForType(target, source); if (match) { - var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65939,7 +66167,7 @@ var ts; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; - var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65948,19 +66176,19 @@ var ts; // Elaborate only if we can find a best matching type in the target union var bestMatchingType = getBestMatchingType(source, target, isRelatedTo); if (bestMatchingType) { - isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true); + isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true); } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToEachType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var targetTypes = target.types; for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { var targetType = targetTypes_2[_i]; - var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(source, targetType, 2 /* RecursionFlags.Target */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65968,50 +66196,50 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors, intersectionState) { var sourceTypes = source.types; - if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { - return -1 /* True */; + if (source.flags & 1048576 /* TypeFlags.Union */ && containsType(sourceTypes, target)) { + return -1 /* Ternary.True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceTypes[i], target, 1 /* RecursionFlags.Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); if (related) { return related; } } - return 0 /* False */; + return 0 /* Ternary.False */; } function getUndefinedStrippedTargetIfNeeded(source, target) { // As a builtin type, `undefined` is a very low type ID - making it almsot always first, making this a very fast check to see // if we need to strip `undefined` from the target - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && - !(source.types[0].flags & 32768 /* Undefined */) && target.types[0].flags & 32768 /* Undefined */) { - return extractTypesOfKind(target, ~32768 /* Undefined */); + if (source.flags & 1048576 /* TypeFlags.Union */ && target.flags & 1048576 /* TypeFlags.Union */ && + !(source.types[0].flags & 32768 /* TypeFlags.Undefined */) && target.types[0].flags & 32768 /* TypeFlags.Undefined */) { + return extractTypesOfKind(target, ~32768 /* TypeFlags.Undefined */); } return target; } function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; // We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath // since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target); for (var i = 0; i < sourceTypes.length; i++) { var sourceType = sourceTypes[i]; - if (undefinedStrippedTarget.flags & 1048576 /* Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { + if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison // such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union - var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); if (related_1) { result &= related_1; continue; } } - var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66022,54 +66250,54 @@ var ts; if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; + return 0 /* Ternary.False */; } var length = sources.length <= targets.length ? sources.length : targets.length; - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < length; i++) { // When variance information isn't available we default to covariance. This happens // in the process of computing variance information for recursive types and when // comparing 'this' type arguments. - var varianceFlags = i < variances.length ? variances[i] : 1 /* Covariant */; - var variance = varianceFlags & 7 /* VarianceMask */; + var varianceFlags = i < variances.length ? variances[i] : 1 /* VarianceFlags.Covariant */; + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; // We ignore arguments for independent type parameters (because they're never witnessed). - if (variance !== 4 /* Independent */) { + if (variance !== 4 /* VarianceFlags.Independent */) { var s = sources[i]; var t = targets[i]; - var related = -1 /* True */; - if (varianceFlags & 8 /* Unmeasurable */) { + var related = -1 /* Ternary.True */; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_. // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be) - related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); + related = relation === identityRelation ? isRelatedTo(s, t, 3 /* RecursionFlags.Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); } - else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 1 /* VarianceFlags.Covariant */) { + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 2 /* VarianceFlags.Contravariant */) { + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 3 /* Bivariant */) { + else if (variance === 3 /* VarianceFlags.Bivariant */) { // In the bivariant case we first compare contravariantly without reporting // errors. Then, if that doesn't succeed, we compare covariantly with error // reporting. Thus, error elaboration will be based on the the covariant check, // which is generally easier to reason about. - related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false); + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (related) { - related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related &= isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66083,28 +66311,28 @@ var ts; // and issue an error. Otherwise, actually compare the structure of the two types. function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) { if (overflow) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0); + var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0); var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false); var entry = relation.get(id); if (entry !== undefined) { - if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { + if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - var saved = entry & 24 /* ReportsMask */; - if (saved & 8 /* ReportsUnmeasurable */) { - instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); + var saved = entry & 24 /* RelationComparisonResult.ReportsMask */; + if (saved & 8 /* RelationComparisonResult.ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMapper); } - if (saved & 16 /* ReportsUnreliable */) { - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + if (saved & 16 /* RelationComparisonResult.ReportsUnreliable */) { + instantiateType(source, reportUnreliableMapper); } } - return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* RelationComparisonResult.Succeeded */ ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } } if (!maybeKeys) { @@ -66120,42 +66348,42 @@ var ts; for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) { - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } } if (sourceDepth === 100 || targetDepth === 100) { overflow = true; - return 0 /* False */; + return 0 /* Ternary.False */; } } var maybeStart = maybeCount; maybeKeys[maybeCount] = id; maybeCount++; var saveExpandingFlags = expandingFlags; - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceStack[sourceDepth] = source; sourceDepth++; - if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) - expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 1 /* ExpandingFlags.Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) + expandingFlags |= 1 /* ExpandingFlags.Source */; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetStack[targetDepth] = target; targetDepth++; - if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) - expandingFlags |= 2 /* Target */; + if (!(expandingFlags & 2 /* ExpandingFlags.Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) + expandingFlags |= 2 /* ExpandingFlags.Target */; } var originalHandler; var propagatingVarianceFlags = 0; if (outofbandVarianceMarkerHandler) { originalHandler = outofbandVarianceMarkerHandler; outofbandVarianceMarkerHandler = function (onlyUnreliable) { - propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + propagatingVarianceFlags |= onlyUnreliable ? 16 /* RelationComparisonResult.ReportsUnreliable */ : 8 /* RelationComparisonResult.ReportsUnmeasurable */; return originalHandler(onlyUnreliable); }; } var result; - if (expandingFlags === 3 /* Both */) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + if (expandingFlags === 3 /* ExpandingFlags.Both */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -66163,30 +66391,30 @@ var ts; depth: sourceDepth, targetDepth: targetDepth }); - result = 3 /* Maybe */; + result = 3 /* Ternary.Maybe */; } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceDepth--; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetDepth--; } expandingFlags = saveExpandingFlags; if (result) { - if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) { - if (result === -1 /* True */ || result === 3 /* Maybe */) { + if (result === -1 /* Ternary.True */ || (sourceDepth === 0 && targetDepth === 0)) { + if (result === -1 /* Ternary.True */ || result === 3 /* Ternary.Maybe */) { // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + relation.set(maybeKeys[i], 1 /* RelationComparisonResult.Succeeded */ | propagatingVarianceFlags); } } maybeCount = maybeStart; @@ -66195,46 +66423,73 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); + relation.set(id, (reportErrors ? 4 /* RelationComparisonResult.Reported */ : 0) | 2 /* RelationComparisonResult.Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - if (intersectionState & 4 /* PropertyCheck */) { - return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); + var saveErrorInfo = captureErrorCalculationState(); + var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo); + if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) { + // The combined constraint of an intersection type is the intersection of the constraints of + // the constituents. When an intersection type contains instantiable types with union type + // constraints, there are situations where we need to examine the combined constraint. One is + // when the target is a union type. Another is when the intersection contains types belonging + // to one of the disjoint domains. For example, given type variables T and U, each with the + // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and + // we need to check this constraint against a union on the target side. Also, given a type + // variable V constrained to 'string | number', 'V & number' has a combined constraint of + // 'string & number | number & number' which reduces to just 'number'. + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */)); + if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + } + } + if (result) { + resetErrorInfo(saveErrorInfo); + } + return result; + } + function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) { + if (intersectionState & 4 /* IntersectionState.PropertyCheck */) { + return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */); } var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = captureErrorCalculationState(); var sourceFlags = source.flags; var targetFlags = target.flags; if (relation === identityRelation) { // We've already checked that source.flags and target.flags are identical - if (sourceFlags & 3145728 /* UnionOrIntersection */) { + if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { var result_8 = eachTypeRelatedToSomeType(source, target); if (result_8) { result_8 &= eachTypeRelatedToSomeType(target, source); } return result_8; } - if (sourceFlags & 4194304 /* Index */) { - return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (sourceFlags & 8388608 /* IndexedAccess */) { - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } } - if (sourceFlags & 16777216 /* Conditional */) { + if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { + if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } @@ -66242,60 +66497,37 @@ var ts; } } } - if (sourceFlags & 33554432 /* Substitution */) { - return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 33554432 /* TypeFlags.Substitution */) { + return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (!(sourceFlags & 524288 /* Object */)) { - return 0 /* False */; + if (!(sourceFlags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } } - else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) { + else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) { - // The combined constraint of an intersection type is the intersection of the constraints of - // the constituents. When an intersection type contains instantiable types with union type - // constraints, there are situations where we need to examine the combined constraint. One is - // when the target is a union type. Another is when the intersection contains types belonging - // to one of the disjoint domains. For example, given type variables T and U, each with the - // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and - // we need to check this constraint against a union on the target side. Also, given a type - // variable V constrained to 'string | number', 'V & number' has a combined constraint of - // 'string & number | number & number' which reduces to just 'number'. - // This also handles type parameters, as a type parameter with a union constraint compared against a union - // needs to have its constraint hoisted into an intersection with said type parameter, this way - // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) - // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); - if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself - // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); - return result; - } - } - } // The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle: // Source is instantiable (e.g. source has union or intersection constraint). // Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }). // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }). - if (!(sourceFlags & 465829888 /* Instantiable */ || - sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ || - sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) { - return 0 /* False */; + if (!(sourceFlags & 465829888 /* TypeFlags.Instantiable */ || + sourceFlags & 524288 /* TypeFlags.Object */ && targetFlags & 1048576 /* TypeFlags.Union */ || + sourceFlags & 2097152 /* TypeFlags.Intersection */ && targetFlags & (524288 /* TypeFlags.Object */ | 1048576 /* TypeFlags.Union */ | 465829888 /* TypeFlags.Instantiable */))) { + return 0 /* Ternary.False */; } } // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. - if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && source.aliasTypeArguments && + if (sourceFlags & (524288 /* TypeFlags.Object */ | 16777216 /* TypeFlags.Conditional */) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) { var variances = getAliasVariances(source.aliasSymbol); if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState); if (varianceResult !== undefined) { @@ -66304,48 +66536,48 @@ var ts; } // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T], // and U is assignable to [...T] when U is constrained to a mutable array or tuple type. - if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) || - isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) { + if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* RecursionFlags.Source */)) || + isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* RecursionFlags.Target */))) { return result; } - if (targetFlags & 262144 /* TypeParameter */) { + if (targetFlags & 262144 /* TypeFlags.TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) { - if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { + if (ts.getObjectFlags(source) & 32 /* ObjectFlags.Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* RecursionFlags.Both */)) { + if (!(getMappedTypeModifiers(source) & 4 /* MappedTypeModifiers.IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(templateType, indexedAccessType, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } } - if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) { + if (relation === comparableRelation && sourceFlags & 262144 /* TypeFlags.TypeParameter */) { // This is a carve-out in comparability to essentially forbid comparing a type parameter // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!) var constraint = getConstraintOfTypeParameter(source); if (constraint && hasNonCircularBaseConstraint(source)) { - while (constraint && constraint.flags & 262144 /* TypeParameter */) { - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) { + while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) { + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { return result; } constraint = getConstraintOfTypeParameter(constraint); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetFlags & 4194304 /* Index */) { + else if (targetFlags & 4194304 /* TypeFlags.Index */) { var targetType_1 = target.type; // A keyof S is related to a keyof T if T is related to S. - if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(targetType_1, source.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } if (isTupleType(targetType_1)) { // An index type can have a tuple type target when the tuple type contains variadic elements. // Check if the source is related to the known keys of the tuple type. - if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -66358,8 +66590,8 @@ var ts; // false positives. For example, given 'T extends { [K in keyof T]: string }', // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when // related to other types. - if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } else if (isGenericMappedType(targetType_1)) { @@ -66374,7 +66606,7 @@ var ts; // missing from the `constraintType` which will otherwise be mapped in the object var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1)); var mappedKeys_1 = []; - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); }); // We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side) targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false)); @@ -66382,21 +66614,20 @@ var ts; else { targetKeys = nameType_1 || constraintType; } - if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, targetKeys, 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } } } - else if (targetFlags & 8388608 /* IndexedAccess */) { - if (sourceFlags & 8388608 /* IndexedAccess */) { + else if (targetFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { // Relate components directly before falling back to constraint relationships // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors); + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } if (reportErrors) { @@ -66411,14 +66642,14 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0); + var accessFlags = 4 /* AccessFlags.Writing */ | (baseObjectType !== objectType ? 2 /* AccessFlags.NoIndexSignatures */ : 0); var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); if (constraint) { if (reportErrors && originalErrorInfo) { // create a new chain for the constraint error resetErrorInfo(saveErrorInfo); } - if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, constraint, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain @@ -66437,12 +66668,12 @@ var ts; var keysRemapped = !!target.declaration.nameType; var templateType = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); - if (!(modifiers & 8 /* ExcludeOptional */)) { + if (!(modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */)) { // If the mapped type has shape `{ [P in Q]: T[P] }`, // source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`. - if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source && + if (!keysRemapped && templateType.flags & 8388608 /* TypeFlags.IndexedAccess */ && templateType.objectType === source && templateType.indexType === getTypeParameterFromMappedType(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!isGenericMappedType(source)) { // If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`. @@ -66450,22 +66681,22 @@ var ts; var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target); // Type of the keys of source type `S`, i.e. `keyof S`. var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true); - var includeOptional = modifiers & 4 /* IncludeOptional */; + var includeOptional = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */; var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined; // A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T. // A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`. if (includeOptional - ? !(filteredByApplicability.flags & 131072 /* Never */) - : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) { + ? !(filteredByApplicability.flags & 131072 /* TypeFlags.Never */) + : isRelatedTo(targetKeys, sourceKeys, 3 /* RecursionFlags.Both */)) { var templateType_1 = getTemplateTypeFromMappedType(target); var typeParameter = getTypeParameterFromMappedType(target); // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj` // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`. - var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */); - if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { - if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) { + var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* TypeFlags.Nullable */); + if (!keysRemapped && nonNullComponent.flags & 8388608 /* TypeFlags.IndexedAccess */ && nonNullComponent.indexType === typeParameter) { + if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -66485,7 +66716,7 @@ var ts; : typeParameter; var indexedAccessType = getIndexedAccessType(source, indexingType); // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type. - if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } @@ -66495,12 +66726,11 @@ var ts; } } } - else if (targetFlags & 16777216 /* Conditional */) { + else if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { - resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } var c = target; // We check for a relationship to a conditional type target only when the conditional type has no @@ -66511,47 +66741,44 @@ var ts; var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType)); // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) - if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) { - result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false); + if (result = skipTrue ? -1 /* Ternary.True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false)) { + result &= skipFalse ? -1 /* Ternary.True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (result) { - resetErrorInfo(saveErrorInfo); return result; } } } } - else if (targetFlags & 134217728 /* TemplateLiteral */) { - if (sourceFlags & 134217728 /* TemplateLiteral */) { + else if (targetFlags & 134217728 /* TypeFlags.TemplateLiteral */) { + if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */) { if (relation === comparableRelation) { - return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */; + return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* Ternary.False */ : -1 /* Ternary.True */; } // Report unreliable variance for type variables referenced in template literal type placeholders. // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + instantiateType(source, reportUnreliableMapper); } if (isTypeMatchedByTemplateLiteralType(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } - else if (target.flags & 268435456 /* StringMapping */) { - if (!(source.flags & 268435456 /* StringMapping */)) { + else if (target.flags & 268435456 /* TypeFlags.StringMapping */) { + if (!(source.flags & 268435456 /* TypeFlags.StringMapping */)) { if (isMemberOfStringMapping(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } } - if (sourceFlags & 8650752 /* TypeVariable */) { + if (sourceFlags & 8650752 /* TypeFlags.TypeVariable */) { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch - if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) { + if (!(sourceFlags & 8388608 /* TypeFlags.IndexedAccess */ && targetFlags & 8388608 /* TypeFlags.IndexedAccess */)) { var constraint = getConstraintOfType(source) || unknownType; // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* RecursionFlags.Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeFlags.TypeParameter */), /*headMessage*/ undefined, intersectionState)) { return result; } if (isMappedTypeGenericIndexedAccess(source)) { @@ -66559,55 +66786,49 @@ var ts; // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X. var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { - if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } } } } - else if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + else if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(keyofConstraintType, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } - else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) { - if (!(targetFlags & 134217728 /* TemplateLiteral */)) { + else if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */ && !(targetFlags & 524288 /* TypeFlags.Object */)) { + if (!(targetFlags & 134217728 /* TypeFlags.TemplateLiteral */)) { var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { - resetErrorInfo(saveErrorInfo); + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { return result; } } } - else if (sourceFlags & 268435456 /* StringMapping */) { - if (targetFlags & 268435456 /* StringMapping */) { + else if (sourceFlags & 268435456 /* TypeFlags.StringMapping */) { + if (targetFlags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol !== target.symbol) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } else { var constraint = getBaseConstraintOfType(source); - if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { - resetErrorInfo(saveErrorInfo); + if (constraint && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { return result; } } } - else if (sourceFlags & 16777216 /* Conditional */) { + else if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { - resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } - if (targetFlags & 16777216 /* Conditional */) { + if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -66616,18 +66837,17 @@ var ts; var mapper = void 0; if (sourceParams) { // If the source has infer type parameters, we instantiate them in the context of the target - var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* InferenceFlags.None */, isRelatedToWorker); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } if (isTypeIdenticalTo(sourceExtends, target.extendsType) && - (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) { - if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors); + (isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* RecursionFlags.Both */))) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -66637,8 +66857,7 @@ var ts; // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { - if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(distributiveConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } @@ -66647,8 +66866,7 @@ var ts; // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!). var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(defaultConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } @@ -66656,31 +66874,30 @@ var ts; else { // An empty object type is related to any mapped type that includes a '?' modifier. if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } - return 0 /* False */; + return 0 /* Ternary.False */; } - var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */); + var sourceIsPrimitive = !!(sourceFlags & 131068 /* TypeFlags.Primitive */); if (relation !== identityRelation) { source = getApparentType(source); sourceFlags = source.flags; } else if (isGenericMappedType(source)) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && source.target === target.target && !isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) { // When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType, // and an empty array literal wouldn't be assignable to a `never[]` without this check. if (isEmptyArrayLiteralType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance @@ -66690,7 +66907,7 @@ var ts; // effectively means we measure variance only from type parameter occurrences that aren't nested in // recursive instantiations of the generic type. if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState); if (varianceResult !== undefined) { @@ -66699,32 +66916,32 @@ var ts; } else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { - return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* RecursionFlags.Both */, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple // or `target` is an array and source is a tuple - in both cases the types cannot be identical, by construction - return 0 /* False */; + return 0 /* Ternary.False */; } } // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` // and not `{} <- fresh({}) <- {[idx: string]: any}` - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source)) { - return 0 /* False */; + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* ObjectFlags.FreshLiteral */ && !isEmptyObjectType(source)) { + return 0 /* Ternary.False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 524288 /* TypeFlags.Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState); if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 0 /* SignatureKind.Call */, reportStructuralErrors); if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 1 /* SignatureKind.Construct */, reportStructuralErrors); if (result) { result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState); } @@ -66741,9 +66958,9 @@ var ts; // there exists a constituent of T for every combination of the discriminants of S // with respect to T. We do not report errors here, as we will use the existing // error result from checking each constituent of the union. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) { - var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); - if (objectOnlyTarget.flags & 1048576 /* Union */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 1048576 /* TypeFlags.Union */) { + var objectOnlyTarget = extractTypesOfKind(target, 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 33554432 /* TypeFlags.Substitution */); + if (objectOnlyTarget.flags & 1048576 /* TypeFlags.Union */) { var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); if (result_9) { return result_9; @@ -66751,7 +66968,7 @@ var ts; } } } - return 0 /* False */; + return 0 /* Ternary.False */; function countMessageChainBreadth(info) { if (!info) return 0; @@ -66761,7 +66978,7 @@ var ts; if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; } - if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { + if (ts.some(variances, function (v) { return !!(v & 24 /* VarianceFlags.AllowsStructuralFallback */); })) { // If some type parameter was `Unmeasurable` or `Unreliable`, and we couldn't pass by assuming it was identical, then we // have to allow a structural fallback check // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially @@ -66788,8 +67005,8 @@ var ts; // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceMask */) === 0 /* Invariant */; }))) { - return 0 /* False */; + if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceFlags.VarianceMask */) === 0 /* VarianceFlags.Invariant */; }))) { + return 0 /* Ternary.False */; } // We remember the original error information so we can restore it in case the structural // comparison unexpectedly succeeds. This can happen when the structural comparison result @@ -66799,18 +67016,6 @@ var ts; } } } - function reportUnmeasurableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false); - } - return p; - } - function reportUnreliableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true); - } - return p; - } // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice // that S and T are contra-variant whereas X and Y are co-variant. @@ -66820,15 +67025,15 @@ var ts; if (modifiersRelated) { var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); - var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) { + var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMapper : reportUnreliableMapper); + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors); + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors); } } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToDiscriminatedType(source, target) { // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. @@ -66843,7 +67048,7 @@ var ts; var sourceProperties = getPropertiesOfType(source); var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); if (!sourcePropertiesFiltered) - return 0 /* False */; + return 0 /* Ternary.False */; // Though we could compute the number of combinations as we generate // the matrix, this would incur additional memory overhead due to // array allocations. To reduce this overhead, we first compute @@ -66855,8 +67060,8 @@ var ts; numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); - return 0 /* False */; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + return 0 /* Ternary.False */; } } // Compute the set of types for each discriminant property. @@ -66865,7 +67070,7 @@ var ts; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); - sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ + sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* TypeFlags.Union */ ? sourcePropertyType.types : [sourcePropertyType]; excludedProperties.add(sourceProperty.escapedName); @@ -66874,11 +67079,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_20 = function (combination) { + var _loop_21 = function (combination) { var hasMatch = false; outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) { var type = _d[_c]; - var _loop_21 = function (i) { + var _loop_22 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfType(type, sourceProperty.escapedName); if (!targetProperty) @@ -66886,7 +67091,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* IntersectionState.None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -66894,7 +67099,7 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_8 = _loop_21(i); + var state_8 = _loop_22(i); switch (state_8) { case "continue-outer": continue outer; } @@ -66903,30 +67108,30 @@ var ts; hasMatch = true; } if (!hasMatch) { - return { value: 0 /* False */ }; + return { value: 0 /* Ternary.False */ }; } }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_7 = _loop_20(combination); + var state_7 = _loop_21(combination); if (typeof state_7 === "object") return state_7.value; } // Compare the remaining non-discriminant properties of each match. - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* None */); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* IntersectionState.None */); if (result) { - result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 0 /* SignatureKind.Call */, /*reportStructuralErrors*/ false); if (result) { - result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 1 /* SignatureKind.Construct */, /*reportStructuralErrors*/ false); if (result && !(isTupleType(source) && isTupleType(type))) { // Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the // element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems // with index type assignability as the types for the excluded discriminants are still included // in the index type. - result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); + result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* IntersectionState.None */); } } } @@ -66953,40 +67158,40 @@ var ts; return result || properties; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { - var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */); var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); var effectiveSource = getTypeOfSourceProperty(sourceProp); - return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source)); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetPropFlags & 16 /* Protected */) { + else if (targetPropFlags & 16 /* ModifierFlags.Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (sourcePropFlags & 16 /* Protected */) { + else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Ensure {readonly a: whatever} is not a subtype of {a: whatever}, // while {a: whatever} is a subtype of {readonly a: whatever}. @@ -66996,7 +67201,7 @@ var ts; // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction if (relation === strictSubtypeRelation && isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // If the target comes from a partial union prop, allow `undefined` in the target type var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState); @@ -67004,10 +67209,10 @@ var ts; if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // When checking for comparability, be more lenient with optional properties. - if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { + if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -67018,7 +67223,7 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } return related; } @@ -67029,7 +67234,7 @@ var ts; && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) && source.symbol - && source.symbol.flags & 32 /* Class */) { + && source.symbol.flags & 32 /* SymbolFlags.Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) { @@ -67071,29 +67276,29 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (isTupleType(target)) { if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); - var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* Rest */ : 4 /* Rest */; - var targetRestFlag = target.target.combinedFlags & 4 /* Rest */; + var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */; + var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */; var sourceMinLength = isTupleType(source) ? source.target.minLength : 0; var targetMinLength = target.target.minLength; if (!sourceRestFlag && sourceArity < targetMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && targetArity < sourceMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { @@ -67104,38 +67309,38 @@ var ts; reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity); } } - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceTypeArguments = getTypeArguments(source); var targetTypeArguments = getTypeArguments(target); - var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* NonRest */) : 0, getStartElementCount(target.target, 11 /* NonRest */)); - var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* NonRest */) : 0); + var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */)); + var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0); var canExcludeDiscriminants = !!excludedProperties; for (var i = 0; i < targetArity; i++) { var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity; - var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* Rest */; + var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */; var targetFlags = target.target.elementFlags[i]; - if (targetFlags & 8 /* Variadic */ && !(sourceFlags & 8 /* Variadic */)) { + if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (sourceFlags & 8 /* Variadic */ && !(targetFlags & 12 /* Variable */)) { + if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) { if (reportErrors) { reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (targetFlags & 1 /* Required */ && !(sourceFlags & 1 /* Required */)) { + if (targetFlags & 1 /* ElementFlags.Required */ && !(sourceFlags & 1 /* ElementFlags.Required */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } // We can only exclude discriminant properties if we have not yet encountered a variable-length element. if (canExcludeDiscriminants) { - if (sourceFlags & 12 /* Variable */ || targetFlags & 12 /* Variable */) { + if (sourceFlags & 12 /* ElementFlags.Variable */ || targetFlags & 12 /* ElementFlags.Variable */) { canExcludeDiscriminants = false; } if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) { @@ -67143,12 +67348,12 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* ElementFlags.Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : - removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); - var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + var targetCheckType = sourceFlags & 8 /* ElementFlags.Variadic */ && targetFlags & 4 /* ElementFlags.Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* ElementFlags.Optional */)); + var related = isRelatedTo(sourceType, targetCheckType, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { @@ -67158,14 +67363,14 @@ var ts; reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i); } } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } - if (target.target.combinedFlags & 12 /* Variable */) { - return 0 /* False */; + if (target.target.combinedFlags & 12 /* ElementFlags.Variable */) { + return 0 /* Ternary.False */; } } var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); @@ -67174,18 +67379,18 @@ var ts; if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) { reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (isObjectLiteralType(target)) { for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) { var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType.flags & 32768 /* Undefined */)) { + if (!(sourceType.flags & 32768 /* TypeFlags.Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } } @@ -67197,12 +67402,12 @@ var ts; for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; var name = targetProp.escapedName; - if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { + if (!(targetProp.flags & 4194304 /* SymbolFlags.Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67211,24 +67416,24 @@ var ts; return result; } function propertiesIdenticalTo(source, target, excludedProperties) { - if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { - return 0 /* False */; + if (!(source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName); if (!targetProp) { - return 0 /* False */; + return 0 /* Ternary.False */; } var related = compareProperties(sourceProp, targetProp, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67240,17 +67445,17 @@ var ts; return signaturesIdenticalTo(source, target, kind); } if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; + return -1 /* Ternary.True */; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { - var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); - var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) { + var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */); + var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */); if (sourceIsAbstract && !targetIsAbstract) { // An abstract constructor type is not assignable to a non-abstract constructor type // as it would otherwise be possible to new an abstract class. Note that the assignability @@ -67259,18 +67464,18 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } - var result = -1 /* True */; - var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; + var result = -1 /* Ternary.True */; + var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; var sourceObjectFlags = ts.getObjectFlags(source); var targetObjectFlags = ts.getObjectFlags(target); - if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol || - sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) { + if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol || + sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters @@ -67278,7 +67483,7 @@ var ts; for (var i = 0; i < targetSignatures.length; i++) { var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67293,10 +67498,10 @@ var ts; var sourceSignature = ts.first(sourceSignatures); var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); - if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* Constructor */)) { + if (!result && reportErrors && kind === 1 /* SignatureKind.Construct */ && (sourceObjectFlags & targetObjectFlags) && + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* SyntaxKind.Constructor */)) { var constructSignatureToString = function (signature) { - return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); + return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */, kind); }; reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature)); reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible); @@ -67322,18 +67527,18 @@ var ts; if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } return result; } function shouldReportUnmatchedPropertyError(source, target) { - var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* Call */); - var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* Construct */); + var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* SignatureKind.Call */); + var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* SignatureKind.Construct */); var typeProperties = getPropertiesOfObjectType(source); if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) { - if ((getSignaturesOfType(target, 0 /* Call */).length && typeCallSignatures.length) || - (getSignaturesOfType(target, 1 /* Construct */).length && typeConstructSignatures.length)) { + if ((getSignaturesOfType(target, 0 /* SignatureKind.Call */).length && typeCallSignatures.length) || + (getSignaturesOfType(target, 1 /* SignatureKind.Construct */).length && typeConstructSignatures.length)) { return true; // target has similar signature kinds to source, still focus on the unmatched property } return false; @@ -67356,45 +67561,45 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* SignatureCheckMode.StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, reportUnreliableMapper); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } function membersRelatedToIndexInfo(source, targetInfo, reportErrors) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var keyType = targetInfo.keyType; - var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); + var props = source.flags & 2097152 /* TypeFlags.Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { var prop = props_2[_i]; // Skip over ignored JSX and symbol-named members if (isIgnoredJsxProperty(source, prop)) { continue; } - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), keyType)) { var propType = getNonMissingTypeOfSymbol(prop); - var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) + var type = exactOptionalPropertyTypes || propType.flags & 32768 /* TypeFlags.Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* SymbolFlags.Optional */) ? propType - : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors); + : getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */); + var related = isRelatedTo(type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67404,7 +67609,7 @@ var ts; if (isApplicableIndexType(info.keyType, keyType)) { var related = indexInfoRelatedTo(info, targetInfo, reportErrors); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67412,7 +67617,7 @@ var ts; return result; } function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { - var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors); + var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related && reportErrors) { if (sourceInfo.keyType === targetInfo.keyType) { reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); @@ -67429,14 +67634,14 @@ var ts; } var indexInfos = getIndexInfosOfType(target); var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; }); - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) { var targetInfo = indexInfos_5[_i]; - var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : - isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) : + var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* TypeFlags.Any */ ? -1 /* Ternary.True */ : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors) : typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67447,46 +67652,46 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } - if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) { + if (!(intersectionState & 1 /* IntersectionState.Source */) && isObjectTypeWithInferableIndex(source)) { // Intersection constituents are never considered to have an inferred index signature return membersRelatedToIndexInfo(source, targetInfo, reportErrors); } if (reportErrors) { reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } function indexSignaturesIdenticalTo(source, target) { var sourceInfos = getIndexInfosOfType(source); var targetInfos = getIndexInfosOfType(target); if (sourceInfos.length !== targetInfos.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) { var targetInfo = targetInfos_1[_i]; var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType); - if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { - return 0 /* False */; + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { + return 0 /* Ternary.False */; } } - return -1 /* True */; + return -1 /* Ternary.True */; } function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. - if (targetAccessibility === 8 /* Private */) { + if (targetAccessibility === 8 /* ModifierFlags.Private */) { return true; } // A public and protected signature is assignable to a protected signature. - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 16 /* ModifierFlags.Protected */ && sourceAccessibility !== 8 /* ModifierFlags.Private */) { return true; } // Only a public signature is assignable to public signature. - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 16 /* ModifierFlags.Protected */ && !sourceAccessibility) { return true; } if (reportErrors) { @@ -67499,19 +67704,19 @@ var ts; // Okay, yes, 'boolean' is a union of 'true | false', but that's not useful // in error reporting scenarios. If you need to use this function but that detail matters, // feel free to add a flag. - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return false; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getConstraintOfType(type); if (constraint && constraint !== type) { return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */); + return isUnitType(type) || !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */); } function getExactOptionalUnassignableProperties(source, target) { if (isTupleType(source) && isTupleType(target)) @@ -67520,7 +67725,7 @@ var ts; .filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); }); } function isExactOptionalPropertyMismatch(source, target) { - return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target); + return !!source && !!target && maybeTypeOfKind(source, 32768 /* TypeFlags.Undefined */) && !!containsMissingType(target); } function getExactOptionalProperties(type) { return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); }); @@ -67540,7 +67745,7 @@ var ts; for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; var targetProp = getUnionOrIntersectionProperty(target, propertyName); - if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) { + if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* CheckFlags.ReadPartial */) { continue; } var i = 0; @@ -67575,12 +67780,12 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && - resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); + resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* SymbolFlags.Optional */); }); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -67596,7 +67801,7 @@ var ts; } function getVariances(type) { // Arrays and tuples are known to be covariant, no need to spend time computing this. - return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */ ? + return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* ObjectFlags.Tuple */ ? arrayVariances : getVariancesWorker(type.symbol, type.typeParameters); } @@ -67612,14 +67817,14 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var links = getSymbolLinks(symbol); if (!links.variances) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; - var _loop_22 = function (tp) { + var _loop_23 = function (tp) { var modifiers = getVarianceModifiers(tp); - var variance = modifiers & 65536 /* Out */ ? - modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : - modifiers & 32768 /* In */ ? 2 /* Contravariant */ : undefined; + var variance = modifiers & 65536 /* ModifierFlags.Out */ ? + modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ : + modifiers & 32768 /* ModifierFlags.In */ ? 2 /* VarianceFlags.Contravariant */ : undefined; if (variance === undefined) { var unmeasurable_1 = false; var unreliable_1 = false; @@ -67630,33 +67835,33 @@ var ts; // invariance, covariance, contravariance or bivariance. var typeWithSuper = createMarkerType(symbol, tp, markerSuperType); var typeWithSub = createMarkerType(symbol, tp, markerSubType); - variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* Covariant */ : 0) | - (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* Contravariant */ : 0); + variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* VarianceFlags.Covariant */ : 0) | + (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* VarianceFlags.Contravariant */ : 0); // If the instantiations appear to be related bivariantly it may be because the // type parameter is independent (i.e. it isn't witnessed anywhere in the generic // type). To determine this we compare instantiations where the type parameter is // replaced with marker types that are known to be unrelated. - if (variance === 3 /* Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; + if (variance === 3 /* VarianceFlags.Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { + variance = 4 /* VarianceFlags.Independent */; } outofbandVarianceMarkerHandler = oldHandler; if (unmeasurable_1 || unreliable_1) { if (unmeasurable_1) { - variance |= 8 /* Unmeasurable */; + variance |= 8 /* VarianceFlags.Unmeasurable */; } if (unreliable_1) { - variance |= 16 /* Unreliable */; + variance |= 16 /* VarianceFlags.Unreliable */; } } } variances.push(variance); }; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - _loop_22(tp); + for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { + var tp = typeParameters_2[_i]; + _loop_23(tp); } links.variances = variances; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) }); } return links.variances; } @@ -67666,7 +67871,7 @@ var ts; if (isErrorType(type)) { return type; } - var result = symbol.flags & 524288 /* TypeAlias */ ? + var result = symbol.flags & 524288 /* SymbolFlags.TypeAlias */ ? getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) : createTypeReference(type, instantiateTypes(type.typeParameters, mapper)); markerTypes.add(getTypeId(result)); @@ -67677,34 +67882,34 @@ var ts; } function getVarianceModifiers(tp) { var _a, _b; - return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* In */); }) ? 32768 /* In */ : 0) | - (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* Out */); }) ? 65536 /* Out */ : 0); + return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* ModifierFlags.In */); }) ? 32768 /* ModifierFlags.In */ : 0) | + (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* ModifierFlags.Out */); }) ? 65536 /* ModifierFlags.Out */ : 0); } // Return true if the given type reference has a 'void' type argument for a covariant type parameter. // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(typeArguments, variances) { for (var i = 0; i < variances.length; i++) { - if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) { + if ((variances[i] & 7 /* VarianceFlags.VarianceMask */) === 1 /* VarianceFlags.Covariant */ && typeArguments[i].flags & 16384 /* TypeFlags.Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeFlags.TypeParameter */ && !getConstraintOfTypeParameter(type); } function isNonDeferredTypeReference(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeFlags.TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) { var typeParameters = []; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); // getTypeReferenceId(A) returns "111=0-12=1" // where A.id=111 and number.id=12 function getTypeReferenceId(type, depth) { @@ -67712,7 +67917,7 @@ var ts; var result = "" + type.target.id; for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { if (ignoreConstraints || isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); if (index < 0) { @@ -67748,12 +67953,12 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (ts.getCheckFlags(prop) & 6 /* Synthetic */) { + if (ts.getCheckFlags(prop) & 6 /* CheckFlags.Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.escapedName); @@ -67768,7 +67973,7 @@ var ts; } // Return the declaring class type of a property or undefined if property not declared in class function getDeclaringClass(prop) { - return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + return prop.parent && prop.parent.flags & 32 /* SymbolFlags.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) { @@ -67786,13 +67991,13 @@ var ts; } // Return true if source property is a valid override of protected parts of target property. function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* ModifierFlags.Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); } // Return true if the given class derives from each of the declaring classes of the protected // constituents of the given property. function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* ModifierFlags.Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons @@ -67838,14 +68043,14 @@ var ts; // reference the type have a recursion identity that differs from the object identity. function getRecursionIdentity(type) { // Object and array literals are known not to contain recursive references and don't need a recursion identity. - if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { - if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { + if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) { + if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) { // Deferred type references are tracked through their associated AST node. This gives us finer // granularity than using their associated target because each manifest type reference has a // unique AST node. return type.node; } - if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) { // We track all object types that have an associated symbol (representing the origin of the type), but // exclude the static side of classes from this check since it shares its symbol with the instance side. return type.symbol; @@ -67855,49 +68060,49 @@ var ts; return type.target; } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { return type.symbol; } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { type = type.objectType; - } while (type.flags & 8388608 /* IndexedAccess */); + } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */); return type; } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { // The root object represents the origin of the conditional type return type.root; } return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; + return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */; } function compareProperties(sourceProp, targetProp, compareTypes) { // Two members are considered identical when // - they are public properties with identical names, optionality, and types, // - they are private or protected properties originating in the same declaration and having identical types if (sourceProp === targetProp) { - return -1 /* True */; + return -1 /* Ternary.True */; } - var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; + var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (sourcePropAccessibility) { if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } else { - if ((sourceProp.flags & 16777216 /* Optional */) !== (targetProp.flags & 16777216 /* Optional */)) { - return 0 /* False */; + if ((sourceProp.flags & 16777216 /* SymbolFlags.Optional */) !== (targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { + return 0 /* Ternary.False */; } } if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -67928,14 +68133,14 @@ var ts; function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!(isMatchingSignature(source, target, partialMatch))) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that the two signatures have the same number of type parameters. if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that type parameter constraints and defaults match. If they do, instantiate the source // signature with the type parameters of the target signature and continue the comparison. @@ -67946,12 +68151,12 @@ var ts; var t = target.typeParameters[i]; if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) { - return 0 /* False */; + return 0 /* Ternary.False */; } } source = instantiateSignature(source, mapper, /*eraseTypeParameters*/ true); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (!ignoreThisTypes) { var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType) { @@ -67959,7 +68164,7 @@ var ts; if (targetThisType) { var related = compareTypes(sourceThisType, targetThisType); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67971,7 +68176,7 @@ var ts; var t = getTypeAtPosition(target, i); var related = compareTypes(t, s); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67985,56 +68190,52 @@ var ts; return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : - source.type === target.type ? -1 /* True */ : + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* Ternary.False */ : + source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + 0 /* Ternary.False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - var baseType = getBaseTypeOfLiteralType(t); - if (!commonBaseType) { - commonBaseType = baseType; - } - if (baseType === t || baseType !== commonBaseType) { - return false; + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + var baseType = getBaseTypeOfLiteralType(t); + commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType); + if (baseType === t || baseType !== commonBaseType) { + return false; + } } } return true; } - // When the candidate types are all literal types with the same base type, return a union - // of those literal types. Otherwise, return the leftmost type for which no type to the - // right is a supertype. - function getSupertypeOrUnion(types) { - if (types.length === 1) { - return types[0]; - } - return literalTypesWithSameBaseType(types) ? - getUnionType(types) : - ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + function getCombinedTypeFlags(types) { + return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 /* TypeFlags.Union */ ? getCombinedTypeFlags(t.types) : t.flags); }, 0); } function getCommonSupertype(types) { - if (!strictNullChecks) { - return getSupertypeOrUnion(types); - } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (primaryTypes.length) { - var supertypeOrUnion = getSupertypeOrUnion(primaryTypes); - return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true)); + if (types.length === 1) { + return types[0]; } - return getUnionType(types, 2 /* Subtype */); + // Remove nullable types from each of the candidates. + var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304 /* TypeFlags.Nullable */); }); }) : types; + // When the candidate types are all literal types with the same base type, return a union + // of those literal types. Otherwise, return the leftmost type for which no type to the + // right is a supertype. + var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? + getUnionType(primaryTypes) : + ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + // Add any nullable types that occurred in the candidates back to the result. + return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* TypeFlags.Nullable */); } // Return the leftmost type for which no type to the right is a subtype. function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); } function isReadonlyArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && type.target === globalReadonlyArrayType; } function isArrayOrTupleType(type) { return isArrayType(type) || isTupleType(type); @@ -68048,22 +68249,22 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || !(type.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function getSingleBaseForNonAugmentingSubtype(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ObjectFlags.ClassOrInterface */)) { return undefined; } - if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { - return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + if (ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* ObjectFlags.IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; } - type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + type.objectFlags |= 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */; var target = type.target; - if (ts.getObjectFlags(target) & 1 /* Class */) { + if (ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { var baseTypeNode = getBaseTypeNodeOfClass(target); // A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only // check for base types specified as simple qualified names. - if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 206 /* PropertyAccessExpression */) { + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* SyntaxKind.Identifier */ && baseTypeNode.expression.kind !== 206 /* SyntaxKind.PropertyAccessExpression */) { return undefined; } } @@ -68078,7 +68279,7 @@ var ts; if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); } - type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + type.objectFlags |= 67108864 /* ObjectFlags.IdenticalBaseTypeExists */; return type.cachedEquivalentBaseType = instantiatedBase; } function isEmptyLiteralType(type) { @@ -68105,44 +68306,49 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); + return !(type.flags & (109440 /* TypeFlags.Unit */ | 131072 /* TypeFlags.Never */)); } function isUnitType(type) { - return !!(type.flags & 109440 /* Unit */); + return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : - !!(type.flags & 109440 /* Unit */); + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* TypeFlags.Unit */); } function extractUnitType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type; + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; } function isLiteralType(type) { - return type.flags & 16 /* Boolean */ ? true : - type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + return type.flags & 16 /* TypeFlags.Boolean */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? type.flags & 1024 /* TypeFlags.EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 512 /* BooleanLiteral */ ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? getBaseTypeOfLiteralTypeUnion(type) : type; } + function getBaseTypeOfLiteralTypeUnion(type) { + var _a; + var key = "B".concat(getTypeId(type)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType)); + } function getWidenedLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : - type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : - type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : - type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* TypeFlags.StringLiteral */ && isFreshLiteralType(type) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ && isFreshLiteralType(type) ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedLiteralType) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -68173,10 +68379,10 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required. */ function isTupleType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target.objectFlags & 8 /* ObjectFlags.Tuple */); } function isGenericTupleType(type) { - return isTupleType(type) && !!(type.target.combinedFlags & 8 /* Variadic */); + return isTupleType(type) && !!(type.target.combinedFlags & 8 /* ElementFlags.Variadic */); } function isSingleElementGenericTupleType(type) { return isGenericTupleType(type) && type.target.elementFlags.length === 1; @@ -68197,7 +68403,7 @@ var ts; var elementTypes = []; for (var i = index; i < length; i++) { var t = typeArguments[i]; - elementTypes.push(type.target.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t); + elementTypes.push(type.target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t); } return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes); } @@ -68205,28 +68411,28 @@ var ts; } function isTupleTypeStructureMatching(t1, t2) { return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && - ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */); }); + ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* ElementFlags.Variable */) === (t2.target.elementFlags[i] & 12 /* ElementFlags.Variable */); }); } function isZeroBigInt(_a) { var value = _a.value; return value.base10Value === "0"; } function removeDefinitelyFalsyTypes(type) { - return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* Truthy */); }); + return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* TypeFacts.Truthy */); }); } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 4 /* String */ ? emptyStringType : - type.flags & 8 /* Number */ ? zeroType : - type.flags & 64 /* BigInt */ ? zeroBigIntType : + return type.flags & 4 /* TypeFlags.String */ ? emptyStringType : + type.flags & 8 /* TypeFlags.Number */ ? zeroType : + type.flags & 64 /* TypeFlags.BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || - type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || - type.flags & 128 /* StringLiteral */ && type.value === "" || - type.flags & 256 /* NumberLiteral */ && type.value === 0 || - type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + type.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */ | 3 /* TypeFlags.AnyOrUnknown */) || + type.flags & 128 /* TypeFlags.StringLiteral */ && type.value === "" || + type.flags & 256 /* TypeFlags.NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isZeroBigInt(type) ? type : neverType; } /** @@ -68235,27 +68441,27 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */); return missing === 0 ? type : - missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 65536 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* TypeFlags.Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* TypeFlags.Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type, isProperty) { if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); + return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { - deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; + deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* SymbolFlags.TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) : getIntersectionType([type, emptyObjectType]); } function getNonNullableType(type) { - return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function addOptionalTypeMarker(type) { return strictNullChecks ? getUnionType([type, optionalType]) : type; @@ -68275,10 +68481,10 @@ var ts; return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type; } function containsMissingType(type) { - return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, missingType)); } function removeMissingOrUndefinedType(type) { - return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */); + return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */); } /** * Is source potentially coercible to target type under `==`. @@ -68301,8 +68507,8 @@ var ts; * @param target */ function isCoercibleUnderDoubleEquals(source, target) { - return ((source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0) - && ((target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0); + return ((source.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 512 /* TypeFlags.BooleanLiteral */)) !== 0) + && ((target.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 16 /* TypeFlags.Boolean */)) !== 0); } /** * Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module @@ -68310,15 +68516,15 @@ var ts; */ function isObjectTypeWithInferableIndex(type) { var objectFlags = ts.getObjectFlags(type); - return type.flags & 2097152 /* Intersection */ + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol - && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 - && !(type.symbol.flags & 32 /* Class */) - && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + && (type.symbol.flags & (4096 /* SymbolFlags.ObjectLiteral */ | 2048 /* SymbolFlags.TypeLiteral */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !== 0 + && !(type.symbol.flags & 32 /* SymbolFlags.Class */) + && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectFlags.ObjectRestType */) || !!(objectFlags & 1024 /* ObjectFlags.ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { - var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); + var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* CheckFlags.Readonly */); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -68348,7 +68554,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* ObjectFlags.FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -68359,7 +68565,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~8192 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~8192 /* ObjectFlags.FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -68389,7 +68595,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) { var t = _a[_i]; - if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ObjectFlags.ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -68401,7 +68607,7 @@ var ts; return context.resolvedProperties; } function getWidenedProperty(prop, context) { - if (!(prop.flags & 4 /* Property */)) { + if (!(prop.flags & 4 /* SymbolFlags.Property */)) { // Since get accessors already widen their return value there is no need to // widen accessor based properties here. return prop; @@ -68417,7 +68623,7 @@ var ts; return cached; } var result = createSymbolWithType(prop, missingType); - result.flags |= 16777216 /* Optional */; + result.flags |= 16777216 /* SymbolFlags.Optional */; undefinedProperties.set(prop.escapedName, result); return result; } @@ -68436,33 +68642,33 @@ var ts; } } var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); })); - result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* JSLiteral */ | 262144 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */)); // Retain js literal flag through widening return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 196608 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } var result = void 0; - if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) { + if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) { result = anyType; } else if (isObjectLiteralType(type)) { result = getWidenedTypeOfObjectLiteral(type, context); } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayOrTupleType(type)) { @@ -68488,8 +68694,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 65536 /* ContainsWideningType */) { - if (type.flags & 1048576 /* Union */) { + if (ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -68514,7 +68720,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (ts.getObjectFlags(t) & 65536 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 65536 /* ObjectFlags.ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -68533,17 +68739,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 221 /* BinaryExpression */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 221 /* SyntaxKind.BinaryExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* SymbolFlags.Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : ""); @@ -68554,25 +68760,25 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (noImplicitAny && !declaration.name) { - if (wideningKind === 3 /* GeneratorYield */) { + if (wideningKind === 3 /* WideningKind.GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); } else { @@ -68581,10 +68787,10 @@ var ts; return; } diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage : - wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : + wideningKind === 3 /* WideningKind.GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -68596,7 +68802,7 @@ var ts; } function reportErrorsFromWidening(declaration, type, wideningKind) { addLazyDiagnostic(function () { - if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -68648,27 +68854,29 @@ var ts; signature: signature, flags: flags, compareTypes: compareTypes, - mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ true); }), - nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ false); }), + mapper: reportUnmeasurableMapper, + nonFixingMapper: reportUnmeasurableMapper, }; + context.mapper = makeFixingMapperForContext(context); + context.nonFixingMapper = makeNonFixingMapperForContext(context); return context; } - function mapToInferredType(context, t, fix) { - var inferences = context.inferences; - for (var i = 0; i < inferences.length; i++) { - var inference = inferences[i]; - if (t === inference.typeParameter) { - if (fix && !inference.isFixed) { - // Before we commit to a particular inference (and thus lock out any further inferences), - // we infer from any intra-expression inference sites we have collected. - inferFromIntraExpressionSites(context); - clearCachedInferences(inferences); - inference.isFixed = true; - } - return getInferredType(context, i); + function makeFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (inference, i) { return function () { + if (!inference.isFixed) { + // Before we commit to a particular inference (and thus lock out any further inferences), + // we infer from any intra-expression inference sites we have collected. + inferFromIntraExpressionSites(context); + clearCachedInferences(context.inferences); + inference.isFixed = true; } - } - return t; + return getInferredType(context, i); + }; })); + } + function makeNonFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (_, i) { return function () { + return getInferredType(context, i); + }; })); } function clearCachedInferences(inferences) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { @@ -68699,9 +68907,9 @@ var ts; if (context.intraExpressionInferenceSites) { for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) { var _b = _a[_i], node = _b.node, type = _b.type; - var contextualType = node.kind === 169 /* MethodDeclaration */ ? - getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : - getContextualType(node, 2 /* NoConstraints */); + var contextualType = node.kind === 169 /* SyntaxKind.MethodDeclaration */ ? + getContextualTypeForObjectLiteralMethod(node, 2 /* ContextFlags.NoConstraints */) : + getContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { inferTypes(context.inferences, type, contextualType); } @@ -68747,40 +68955,40 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 1048576 /* CouldContainTypeVariables */); + if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */); } - var result = !!(type.flags & 465829888 /* Instantiable */ || - 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 */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); - if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0); + var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ || + type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); + if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) { + type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SourceFile */ ? true : n.kind === 261 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SyntaxKind.SourceFile */ ? true : n.kind === 261 /* SyntaxKind.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); }) || - type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || + type.flags & 16777216 /* TypeFlags.Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 128 /* StringLiteral */)) { + if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); - var literalProp = createSymbol(4 /* Property */, name); + var literalProp = createSymbol(4 /* SymbolFlags.Property */, name); literalProp.type = anyType; if (t.symbol) { literalProp.declarations = t.symbol.declarations; @@ -68788,7 +68996,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; + var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos); } /** @@ -68816,7 +69024,7 @@ var ts; // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 262144 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 262144 /* ObjectFlags.NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -68833,14 +69041,14 @@ var ts; } if (isTupleType(source)) { var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); - var elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? - ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var elementFlags = getMappedTypeModifiers(target) & 4 /* MappedTypeModifiers.IncludeOptional */ ? + ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : source.target.elementFlags; return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations); } // For all other object types we infer a new object type where the reverse mapping has been // applied to the type of each property. - var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ObjectFlags.ReverseMapped */ | 16 /* ObjectFlags.Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; @@ -68875,7 +69083,7 @@ var ts; if (isStaticPrivateIdentifierProperty(targetProp)) { return [3 /*break*/, 5]; } - if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */))) return [3 /*break*/, 5]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */))) return [3 /*break*/, 5]; sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!!sourceProp) return [3 /*break*/, 3]; return [4 /*yield*/, targetProp]; @@ -68885,9 +69093,9 @@ var ts; case 3: if (!matchDiscriminantProperties) return [3 /*break*/, 5]; targetType = getTypeOfSymbol(targetProp); - if (!(targetType.flags & 109440 /* Unit */)) return [3 /*break*/, 5]; + if (!(targetType.flags & 109440 /* TypeFlags.Unit */)) return [3 /*break*/, 5]; sourceType = getTypeOfSymbol(sourceProp); - if (!!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; + if (!!(sourceType.flags & 1 /* TypeFlags.Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; return [4 /*yield*/, targetProp]; case 4: _a.sent(); @@ -68905,7 +69113,7 @@ var ts; return result.value; } function tupleTypesDefinitelyUnrelated(source, target) { - return !(target.target.combinedFlags & 8 /* Variadic */) && target.target.minLength > source.target.minLength || + return !(target.target.combinedFlags & 8 /* ElementFlags.Variadic */) && target.target.minLength > source.target.minLength || !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength); } function typesDefinitelyUnrelated(source, target) { @@ -68916,7 +69124,7 @@ var ts; !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false); } function getTypeFromInference(inference) { - return inference.candidates ? getUnionType(inference.candidates, 2 /* Subtype */) : + return inference.candidates ? getUnionType(inference.candidates, 2 /* UnionReduction.Subtype */) : inference.contraCandidates ? getIntersectionType(inference.contraCandidates) : undefined; } @@ -68953,7 +69161,7 @@ var ts; */ function parseBigIntLiteralType(text) { var negative = text.startsWith("-"); - var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n"); + var base10Value = ts.parsePseudoBigInt("".concat(negative ? text.slice(1) : text, "n")); return getBigIntLiteralType({ negative: negative, base10Value: base10Value }); } /** @@ -68964,12 +69172,12 @@ var ts; function isValidBigIntString(s, roundTripOnly) { if (s === "") return false; - var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.ESNext */, /*skipTrivia*/ false); var success = true; scanner.setOnError(function () { return success = false; }); scanner.setText(s + "n"); var result = scanner.scan(); - var negative = result === 40 /* MinusToken */; + var negative = result === 40 /* SyntaxKind.MinusToken */; if (negative) { result = scanner.scan(); } @@ -68979,17 +69187,17 @@ var ts; // * a bigint can be scanned, and that when it is scanned, it is // * the full length of the input string (so the scanner is one character beyond the augmented input length) // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) - return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */) + return success && result === 9 /* SyntaxKind.BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* TokenFlags.ContainsSeparator */) && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) })); } function isMemberOfStringMapping(source, target) { - if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) { + if (target.flags & (4 /* TypeFlags.String */ | 3 /* TypeFlags.AnyOrUnknown */)) { return true; } - if (target.flags & 134217728 /* TemplateLiteral */) { + if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { return isTypeAssignableTo(source, target); } - if (target.flags & 268435456 /* StringMapping */) { + if (target.flags & 268435456 /* TypeFlags.StringMapping */) { // We need to see whether applying the same mappings of the target // onto the source would produce an identical type *and* that // it's compatible with the inner-most non-string-mapped type. @@ -68998,7 +69206,7 @@ var ts; // and the source is compatible with the unmapped target, then they must // still reside in the same domain. var mappingStack = []; - while (target.flags & 268435456 /* StringMapping */) { + while (target.flags & 268435456 /* TypeFlags.StringMapping */) { mappingStack.unshift(target.symbol); target = target.type; } @@ -69008,25 +69216,25 @@ var ts; return false; } function isValidTypeForTemplateLiteralPlaceholder(source, target) { - if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + if (source === target || target.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)) { return true; } - if (source.flags & 128 /* StringLiteral */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */) { var value = source.value; - return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) || - target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) || - target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName || - target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target)); + return !!(target.flags & 8 /* TypeFlags.Number */ && isValidNumberString(value, /*roundTripOnly*/ false) || + target.flags & 64 /* TypeFlags.BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) || + target.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) && value === target.intrinsicName || + target.flags & 268435456 /* TypeFlags.StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target)); } - if (source.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts = source.texts; return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target); } return isTypeAssignableTo(source, target); } function inferTypesFromTemplateLiteralType(source, target) { - return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : - source.flags & 134217728 /* TemplateLiteral */ ? + return source.flags & 128 /* TypeFlags.StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : undefined; @@ -69036,7 +69244,7 @@ var ts; return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); }); } function getStringLikeTypeForType(type) { - return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); + return type.flags & (1 /* TypeFlags.Any */ | 402653316 /* TypeFlags.StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); } // This function infers from the text parts and type parts of a source literal to a target template literal. The number // of text parts is always one more than the number of type parts, and a source string literal is treated as a source @@ -69118,12 +69326,12 @@ var ts; if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 2048 /* MaxValue */; + var inferencePriority = 2048 /* InferencePriority.MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; var targetStack; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { if (!couldContainTypeVariables(target)) { @@ -69139,13 +69347,16 @@ var ts; propagationType = savePropagationType; return; } - if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - // Source and target are types originating in the same generic type alias declaration. - // Simply infer from source type arguments to target type arguments. - inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) { + if (source.aliasTypeArguments) { + // Source and target are types originating in the same generic type alias declaration. + // Simply infer from source type arguments to target type arguments. + inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + } + // And if there weren't any type arguments, there's no reason to run inference as the types must be the same. return; } - if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + if (source === target && source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { // When source and target are the same union or intersection type, just relate each constituent // type to itself. for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -69154,10 +69365,10 @@ var ts; } return; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { // First, infer between identically matching source and target constituents and remove the // matching types. - var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _b = inferFromMatchingTypes(source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; // Next, infer between closely matching source and target constituents and remove // the matching types. Types closely match when they are instantiations of the same // object type or instantiations of the same type alias. @@ -69172,21 +69383,21 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - inferWithPriority(source, target, 1 /* NakedTypeVariable */); + inferWithPriority(source, target, 1 /* InferencePriority.NakedTypeVariable */); return; } source = getUnionType(sources); } - else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + else if (target.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { // We reduce intersection types only when they contain naked type parameters. For example, when // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the // string[] on the source side and infer string for T. // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" // in such scenarios. - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { // Infer between identically matching source and target constituents and remove the matching types. - var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + var _d = inferFromMatchingTypes(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; if (sources.length === 0 || targets.length === 0) { return; } @@ -69194,23 +69405,31 @@ var ts; target = getIntersectionType(targets); } } - else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { + else if (target.flags & (8388608 /* TypeFlags.IndexedAccess */ | 33554432 /* TypeFlags.Substitution */)) { target = getActualTypeVariable(target); } - if (target.flags & 8650752 /* TypeVariable */) { - // If target is a type parameter, make an inference, unless the source type contains - // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). - // Because the anyFunctionType is internal, it should not be exposed to the user by adding - // it as an inference candidate. Hopefully, a better candidate will come along that does - // not contain anyFunctionType when we come back to this argument for its second round - // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard - // when constructing types from type parameters that had no inference candidates). - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (target.flags & 8650752 /* TypeFlags.TypeVariable */) { + // Skip inference if the source is "blocked", which is used by the language service to + // prevent inference on nodes currently being edited. + if (isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); if (inference) { - if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) { + // If target is a type parameter, make an inference, unless the source type contains + // a "non-inferrable" type. Types with this flag set are markers used to prevent inference. + // + // For example: + // - anyFunctionType is a wildcard type that's used to avoid contextually typing functions; + // it's internal, so should not be exposed to the user by adding it as a candidate. + // - autoType (and autoArrayType) is a special "any" used in control flow; like anyFunctionType, + // it's internal and should not be observable. + // - silentNeverType is returned by getInferredType when instantiating a generic function for + // inference (and a type variable has no mapping). + // + // This flag is infectious; if we produce Box (where never is silentNeverType), Box is + // also non-inferrable. + if (ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */) { return; } if (!inference.isFixed) { @@ -69235,7 +69454,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* InferencePriority.ReturnType */) && target.flags & 262144 /* TypeFlags.TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -69248,11 +69467,11 @@ var ts; if (simplified !== target) { inferFromTypes(source, simplified); } - else if (target.flags & 8388608 /* IndexedAccess */) { + else if (target.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexType = getSimplifiedType(target.indexType, /*writing*/ false); // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can. - if (indexType.flags & 465829888 /* Instantiable */) { + if (indexType.flags & 465829888 /* TypeFlags.Instantiable */) { var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false); if (simplified_1 && simplified_1 !== target) { inferFromTypes(source, simplified_1); @@ -69260,45 +69479,38 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } - else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { - contravariant = !contravariant; - inferFromTypes(source.type, target.type); - contravariant = !contravariant; + else if (source.flags & 4194304 /* TypeFlags.Index */ && target.flags & 4194304 /* TypeFlags.Index */) { + inferFromContravariantTypes(source.type, target.type); } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* TypeFlags.String */) && target.flags & 4194304 /* TypeFlags.Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); - contravariant = !contravariant; - inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); - contravariant = !contravariant; + inferFromContravariantTypesWithPriority(empty, target.type, 256 /* InferencePriority.LiteralKeyof */); } - else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { + else if (source.flags & 8388608 /* TypeFlags.IndexedAccess */ && target.flags & 8388608 /* TypeFlags.IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) { + else if (source.flags & 268435456 /* TypeFlags.StringMapping */ && target.flags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol === target.symbol) { inferFromTypes(source.type, target.type); } } - else if (source.flags & 33554432 /* Substitution */) { + else if (source.flags & 33554432 /* TypeFlags.Substitution */) { inferFromTypes(source.baseType, target); - var oldPriority = priority; - priority |= 4 /* SubstituteSource */; - inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority - priority = oldPriority; + inferWithPriority(source.substitute, target, 4 /* InferencePriority.SubstituteSource */); // Make substitute inference at a lower priority } - else if (target.flags & 16777216 /* Conditional */) { + else if (target.flags & 16777216 /* TypeFlags.Conditional */) { invokeOnce(source, target, inferToConditionalType); } - else if (target.flags & 3145728 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } - else if (source.flags & 1048576 /* Union */) { + else if (source.flags & 1048576 /* TypeFlags.Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) { @@ -69306,17 +69518,17 @@ var ts; inferFromTypes(sourceType, target); } } - else if (target.flags & 134217728 /* TemplateLiteral */) { + else if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { inferToTemplateLiteralType(source, target); } else { source = getReducedType(source); - if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* InferencePriority.NoConstraints */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` // with the simplified source. - if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */))) { // TODO: The `allowComplexConstraintInference` flag is a hack! This forbids inference from complex constraints within constraints! // This isn't required algorithmically, but rather is used to lower the memory burden caused by performing inference // that is _too good_ in projects with complicated constraints (eg, fp-ts). In such cases, if we did not limit ourselves @@ -69329,7 +69541,7 @@ var ts; } source = apparentSource; } - if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { invokeOnce(source, target, inferFromObjectTypes); } } @@ -69340,6 +69552,18 @@ var ts; inferFromTypes(source, target); priority = savePriority; } + function inferFromContravariantTypesWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromContravariantTypes(source, target); + priority = savePriority; + } + function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferToMultipleTypes(source, targets, targetFlags); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -69347,19 +69571,19 @@ var ts; inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); + (visited || (visited = new ts.Map())).set(key, -1 /* InferencePriority.Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. var saveExpandingFlags = expandingFlags; var sourceIdentity = getRecursionIdentity(source); var targetIdentity = getRecursionIdentity(target); if (ts.contains(sourceStack, sourceIdentity)) - expandingFlags |= 1 /* Source */; + expandingFlags |= 1 /* ExpandingFlags.Source */; if (ts.contains(targetStack, targetIdentity)) - expandingFlags |= 2 /* Target */; - if (expandingFlags !== 3 /* Both */) { + expandingFlags |= 2 /* ExpandingFlags.Target */; + if (expandingFlags !== 3 /* ExpandingFlags.Both */) { (sourceStack || (sourceStack = [])).push(sourceIdentity); (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); @@ -69367,7 +69591,7 @@ var ts; sourceStack.pop(); } else { - inferencePriority = -1 /* Circularity */; + inferencePriority = -1 /* InferencePriority.Circularity */; } expandingFlags = saveExpandingFlags; visited.set(key, inferencePriority); @@ -69395,7 +69619,7 @@ var ts; function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; for (var i = 0; i < count; i++) { - if (i < variances.length && (variances[i] & 7 /* VarianceMask */) === 2 /* Contravariant */) { + if (i < variances.length && (variances[i] & 7 /* VarianceFlags.VarianceMask */) === 2 /* VarianceFlags.Contravariant */) { inferFromContravariantTypes(sourceTypes[i], targetTypes[i]); } else { @@ -69404,17 +69628,20 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { - contravariant = !contravariant; - inferFromTypes(source, target); - contravariant = !contravariant; + contravariant = !contravariant; + inferFromTypes(source, target); + contravariant = !contravariant; + } + function inferFromContravariantTypesIfStrictFunctionTypes(source, target) { + if (strictFunctionTypes || priority & 1024 /* InferencePriority.AlwaysStrict */) { + inferFromContravariantTypes(source, target); } else { inferFromTypes(source, target); } } function getInferenceInfoForType(type) { - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) { var inference = inferences_2[_i]; if (type === inference.typeParameter) { @@ -69428,7 +69655,7 @@ var ts; var typeVariable; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var type = types_14[_i]; - var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + var t = type.flags & 2097152 /* TypeFlags.Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; } @@ -69438,9 +69665,9 @@ var ts; } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; - if (targetFlags & 1048576 /* Union */) { + if (targetFlags & 1048576 /* TypeFlags.Union */) { var nakedTypeVariable = void 0; - var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; + var sources = source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we @@ -69456,11 +69683,11 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; - inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* InferencePriority.Circularity */; inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } @@ -69471,7 +69698,7 @@ var ts; // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); if (intersectionTypeVariable) { - inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + inferWithPriority(source, intersectionTypeVariable, 1 /* InferencePriority.NakedTypeVariable */); } return; } @@ -69505,17 +69732,17 @@ var ts; // less specific. For example, when inferring from Promise to T | Promise, // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. - if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { + if (targetFlags & 2097152 /* TypeFlags.Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferWithPriority(source, t, 1 /* NakedTypeVariable */); + inferWithPriority(source, t, 1 /* InferencePriority.NakedTypeVariable */); } } } } function inferToMappedType(source, target, constraintType) { - if (constraintType.flags & 1048576 /* Union */) { + if (constraintType.flags & 1048576 /* TypeFlags.Union */) { var result = false; for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { var type = _a[_i]; @@ -69523,7 +69750,7 @@ var ts; } return result; } - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -69535,17 +69762,17 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* NonInferrableType */ ? - 16 /* PartialHomomorphicMappedType */ : - 8 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */ ? + 16 /* InferencePriority.PartialHomomorphicMappedType */ : + 8 /* InferencePriority.HomomorphicMappedType */); } } return true; } - if (constraintType.flags & 262144 /* TypeParameter */) { + if (constraintType.flags & 262144 /* TypeFlags.TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* InferencePriority.MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -69564,18 +69791,15 @@ var ts; return false; } function inferToConditionalType(source, target) { - if (source.flags & 16777216 /* Conditional */) { + if (source.flags & 16777216 /* TypeFlags.Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } else { - var savePriority = priority; - priority |= contravariant ? 64 /* ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; - inferToMultipleTypes(source, targetTypes, target.flags); - priority = savePriority; + inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 /* InferencePriority.ContravariantConditional */ : 0); } } function inferToTemplateLiteralType(source, target) { @@ -69588,47 +69812,47 @@ var ts; // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might // succeed. That would be a pointless and confusing outcome. if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) { - var _loop_23 = function (i) { + var _loop_24 = function (i) { var source_1 = matches ? matches[i] : neverType; var target_3 = types[i]; // If we are inferring from a string literal type to a type variable whose constraint includes one of the // allowed template literal placeholder types, infer from a literal type corresponding to the constraint. - if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) { + if (source_1.flags & 128 /* TypeFlags.StringLiteral */ && target_3.flags & 8650752 /* TypeFlags.TypeVariable */) { var inferenceContext = getInferenceInfoForType(target_3); var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined; if (constraint && !isTypeAny(constraint)) { - var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint]; + var constraintTypes = constraint.flags & 1048576 /* TypeFlags.Union */ ? constraint.types : [constraint]; var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0); // If the constraint contains `string`, we don't need to look for a more preferred type - if (!(allTypeFlags_1 & 4 /* String */)) { + if (!(allTypeFlags_1 & 4 /* TypeFlags.String */)) { var str_1 = source_1.value; // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers - if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) { - allTypeFlags_1 &= ~296 /* NumberLike */; + if (allTypeFlags_1 & 296 /* TypeFlags.NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) { + allTypeFlags_1 &= ~296 /* TypeFlags.NumberLike */; } // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints - if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) { - allTypeFlags_1 &= ~2112 /* BigIntLike */; + if (allTypeFlags_1 & 2112 /* TypeFlags.BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) { + allTypeFlags_1 &= ~2112 /* TypeFlags.BigIntLike */; } // for each type in the constraint, find the highest priority matching type var matchingType = ts.reduceLeft(constraintTypes, function (left, right) { return !(right.flags & allTypeFlags_1) ? left : - left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 : - left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 : - left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 : - left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right : - left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) : - left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) : - left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right : - left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) : - left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right : - left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType : - left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right : - left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right : - left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right : + left.flags & 4 /* TypeFlags.String */ ? left : right.flags & 4 /* TypeFlags.String */ ? source_1 : + left.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? left : right.flags & 134217728 /* TypeFlags.TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 : + left.flags & 268435456 /* TypeFlags.StringMapping */ ? left : right.flags & 268435456 /* TypeFlags.StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 : + left.flags & 128 /* TypeFlags.StringLiteral */ ? left : right.flags & 128 /* TypeFlags.StringLiteral */ && right.value === str_1 ? right : + left.flags & 8 /* TypeFlags.Number */ ? left : right.flags & 8 /* TypeFlags.Number */ ? getNumberLiteralType(+str_1) : + left.flags & 32 /* TypeFlags.Enum */ ? left : right.flags & 32 /* TypeFlags.Enum */ ? getNumberLiteralType(+str_1) : + left.flags & 256 /* TypeFlags.NumberLiteral */ ? left : right.flags & 256 /* TypeFlags.NumberLiteral */ && right.value === +str_1 ? right : + left.flags & 64 /* TypeFlags.BigInt */ ? left : right.flags & 64 /* TypeFlags.BigInt */ ? parseBigIntLiteralType(str_1) : + left.flags & 2048 /* TypeFlags.BigIntLiteral */ ? left : right.flags & 2048 /* TypeFlags.BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right : + left.flags & 16 /* TypeFlags.Boolean */ ? left : right.flags & 16 /* TypeFlags.Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType : + left.flags & 512 /* TypeFlags.BooleanLiteral */ ? left : right.flags & 512 /* TypeFlags.BooleanLiteral */ && right.intrinsicName === str_1 ? right : + left.flags & 32768 /* TypeFlags.Undefined */ ? left : right.flags & 32768 /* TypeFlags.Undefined */ && right.intrinsicName === str_1 ? right : + left.flags & 65536 /* TypeFlags.Null */ ? left : right.flags & 65536 /* TypeFlags.Null */ && right.intrinsicName === str_1 ? right : left; }, neverType); - if (!(matchingType.flags & 131072 /* Never */)) { + if (!(matchingType.flags & 131072 /* TypeFlags.Never */)) { inferFromTypes(matchingType, target_3); return "continue"; } @@ -69638,12 +69862,12 @@ var ts; inferFromTypes(source_1, target_3); }; for (var i = 0; i < types.length; i++) { - _loop_23(i); + _loop_24(i); } } } function inferFromObjectTypes(source, target) { - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); return; @@ -69658,7 +69882,7 @@ var ts; if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType); } - if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) { + if (ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */ && !target.declaration.nameType) { var constraintType = getConstraintTypeFromMappedType(target); if (inferToMappedType(source, target, constraintType)) { return; @@ -69681,21 +69905,21 @@ var ts; return; } var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0; - var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* Fixed */) : 0); + var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* ElementFlags.Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* ElementFlags.Fixed */) : 0); // Infer between starting fixed elements. for (var i = 0; i < startLength; i++) { inferFromTypes(getTypeArguments(source)[i], elementTypes[i]); } - if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* Rest */) { + if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Single rest element remains in source, infer from that to every element in target var restType = getTypeArguments(source)[startLength]; for (var i = startLength; i < targetArity - endLength; i++) { - inferFromTypes(elementFlags[i] & 8 /* Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); + inferFromTypes(elementFlags[i] & 8 /* ElementFlags.Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); } } else { var middleLength = targetArity - startLength - endLength; - if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* Variadic */ && isTupleType(source)) { + if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* ElementFlags.Variadic */ && isTupleType(source)) { // Middle of target is [...T, ...U] and source is tuple type var targetInfo = getInferenceInfoForType(elementTypes[startLength]); if (targetInfo && targetInfo.impliedArity !== undefined) { @@ -69704,14 +69928,14 @@ var ts; inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]); } } - else if (middleLength === 1 && elementFlags[startLength] & 8 /* Variadic */) { + else if (middleLength === 1 && elementFlags[startLength] & 8 /* ElementFlags.Variadic */) { // Middle of target is exactly one variadic element. Infer the slice between the fixed parts in the source. // If target ends in optional element(s), make a lower priority a speculative inference. - var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* Optional */; + var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* ElementFlags.Optional */; var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]); - inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* SpeculativeTuple */ : 0); + inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* InferencePriority.SpeculativeTuple */ : 0); } - else if (middleLength === 1 && elementFlags[startLength] & 4 /* Rest */) { + else if (middleLength === 1 && elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Middle of target is exactly one rest element. If middle of source is not empty, infer union of middle element types. var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0]; if (restType) { @@ -69731,8 +69955,8 @@ var ts; } } inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); + inferFromSignatures(source, target, 0 /* SignatureKind.Call */); + inferFromSignatures(source, target, 1 /* SignatureKind.Construct */); inferFromIndexTypes(source, target); } } @@ -69752,25 +69976,22 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */); for (var i = 0; i < len; i++) { - inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); + inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); } } - function inferFromSignature(source, target, skipParameters) { - if (!skipParameters) { - var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */; - applyToParameterTypes(source, target, inferFromContravariantTypes); - bivariant = saveBivariant; - } + function inferFromSignature(source, target) { + var saveBivariant = bivariant; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + // Once we descend into a bivariant signature we remain bivariant for all nested inferences + bivariant = bivariant || kind === 169 /* SyntaxKind.MethodDeclaration */ || kind === 168 /* SyntaxKind.MethodSignature */ || kind === 171 /* SyntaxKind.Constructor */; + applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes); + bivariant = saveBivariant; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables - var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */) ? 8 /* InferencePriority.HomomorphicMappedType */ : 0; var indexInfos = getIndexInfosOfType(target); if (isObjectTypeWithInferableIndex(source)) { for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) { @@ -69778,9 +69999,9 @@ var ts; var propTypes = []; for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { var propType = getTypeOfSymbol(prop); - propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType); + propTypes.push(prop.flags & 16777216 /* SymbolFlags.Optional */ ? removeMissingOrUndefinedType(propType) : propType); } } for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) { @@ -69805,34 +70026,34 @@ var ts; } function isTypeOrBaseIdenticalTo(s, t) { return exactOptionalPropertyTypes && t === missingType ? s === t : - (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */)); + (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* TypeFlags.String */ && s.flags & 128 /* TypeFlags.StringLiteral */ || t.flags & 8 /* TypeFlags.Number */ && s.flags & 256 /* TypeFlags.NumberLiteral */)); } function isTypeCloselyMatchedBy(s, t) { - return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + return !!(s.flags & 524288 /* TypeFlags.Object */ && t.flags & 524288 /* TypeFlags.Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* TypeFlags.Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); } function isObjectLiteralType(type) { - return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); + return !!(ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 16384 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectFlags.ObjectLiteral */ | 16384 /* ObjectFlags.ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType); if (objectLiterals.length) { - var literalsType = getUnionType(objectLiterals, 2 /* Subtype */); + var literalsType = getUnionType(objectLiterals, 2 /* UnionReduction.Subtype */); return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]); } } return candidates; } function getContravariantInference(inference) { - return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { // Extract all object and array literal types and replace them with a single widened and normalized type. @@ -69849,8 +70070,8 @@ var ts; candidates; // If all inferences were made from a position that implies a combined result, infer a union type. // Otherwise, infer a common supertype. - var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? - getUnionType(baseCandidates, 2 /* Subtype */) : + var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? + getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); } @@ -69864,14 +70085,14 @@ var ts; if (inference.contraCandidates) { // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'. - inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) && + inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* TypeFlags.Never */) && ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ? inferredCovariantType_1 : getContravariantInference(inference); } else if (inferredCovariantType_1) { inferredType = inferredCovariantType_1; } - else if (context.flags & 1 /* NoDefault */) { + else if (context.flags & 1 /* InferenceFlags.NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. inferredType = silentNeverType; } @@ -69892,7 +70113,7 @@ var ts; else { inferredType = getTypeFromInference(inference); } - inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* AnyDefault */)); + inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* InferenceFlags.AnyDefault */)); var constraint = getConstraintOfTypeParameter(inference.typeParameter); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper); @@ -69962,7 +70183,7 @@ var ts; } // falls through default: - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -69974,7 +70195,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false) || unknownSymbol; } return links.resolvedSymbol; @@ -69983,7 +70204,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 161 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* SyntaxKind.TypeQuery */ ? true : n.kind === 79 /* SyntaxKind.Identifier */ || n.kind === 161 /* SyntaxKind.QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -69991,70 +70212,79 @@ var ts; // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } // falls through - case 108 /* ThisKeyword */: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); return left && left + "." + node.right.escapedText; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); return key && key + "." + propName; } + break; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + // Handle pseudo-references originating in getNarrowedTypeOfSymbol. + return "".concat(getNodeId(node), "#").concat(getTypeId(declaredType)); } return undefined; } function isMatchingReference(source, target) { switch (target.kind) { - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isMatchingReference(source, target.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || - (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); + (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 231 /* MetaProperty */: - return target.kind === 231 /* MetaProperty */ + case 231 /* SyntaxKind.MetaProperty */: + return target.kind === 231 /* SyntaxKind.MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isThisInTypeQuery(source) ? - target.kind === 108 /* ThisKeyword */ : - target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 254 /* VariableDeclaration */ || target.kind === 203 /* BindingElement */) && + target.kind === 108 /* SyntaxKind.ThisKeyword */ : + target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 108 /* ThisKeyword */: - return target.kind === 108 /* ThisKeyword */; - case 106 /* SuperKeyword */: - return target.kind === 106 /* SuperKeyword */; - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return target.kind === 108 /* SyntaxKind.ThisKeyword */; + case 106 /* SyntaxKind.SuperKeyword */: + return target.kind === 106 /* SyntaxKind.SuperKeyword */; + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var sourcePropertyName = getAccessedPropertyName(source); var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined; return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName && isMatchingReference(source.expression, target.expression); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 221 /* BinaryExpression */: - return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); + case 221 /* SyntaxKind.BinaryExpression */: + return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target)); } return false; } @@ -70075,15 +70305,15 @@ var ts; return undefined; } function tryGetNameFromType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : - type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? type.escapedName : + type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; } function tryGetElementAccessExpressionName(node) { if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) { return ts.escapeLeadingUnderscores(node.argumentExpression.text); } if (ts.isEntityNameExpression(node.argumentExpression)) { - var symbol = resolveEntityName(node.argumentExpression, 111551 /* Value */, /*ignoreErrors*/ true); + var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); if (!symbol || !isConstVariable(symbol)) return undefined; var declaration = symbol.valueDeclaration; @@ -70122,12 +70352,12 @@ var ts; return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 1048576 /* Union */) { + if (type && type.flags & 1048576 /* TypeFlags.Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (prop && ts.getCheckFlags(prop) & 2 /* CheckFlags.SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = - (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && + (prop.checkFlags & 192 /* CheckFlags.Discriminant */) === 192 /* CheckFlags.Discriminant */ && !isGenericType(getTypeOfSymbol(prop)); } return !!prop.isDiscriminantProperty; @@ -70156,8 +70386,8 @@ var ts; function mapTypesByKeyProperty(types, name) { var map = new ts.Map(); var count = 0; - var _loop_24 = function (type) { - if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var _loop_25 = function (type) { + if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { if (!isLiteralType(discriminant)) { @@ -70182,7 +70412,7 @@ var ts; }; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var type = types_15[_i]; - var state_9 = _loop_24(type); + var state_9 = _loop_25(type); if (typeof state_9 === "object") return state_9.value; } @@ -70193,15 +70423,15 @@ var ts; function getKeyPropertyName(unionType) { var types = unionType.types; // We only construct maps for unions with many non-primitive constituents. - if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* PrimitiveUnion */ || - ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) { + if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* ObjectFlags.PrimitiveUnion */ || + ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)); }) < 10) { return undefined; } if (unionType.keyPropertyName === undefined) { // The candidate key property name is the name of the first property with a unit type in one of the // constituent types. var keyPropertyName = ts.forEach(types, function (t) { - return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ? + return t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : undefined; }); @@ -70225,7 +70455,7 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); @@ -70242,7 +70472,7 @@ var ts; } } } - if (expression.expression.kind === 206 /* PropertyAccessExpression */ && + if (expression.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -70256,7 +70486,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -70271,23 +70501,25 @@ var ts; // For example, when a variable of type number | string | boolean is assigned a value of type number | boolean, // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { - if (declaredType !== assignedType) { - if (assignedType.flags & 131072 /* Never */) { - return assignedType; - } - var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) { - reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types - } - // Our crude heuristic produces an invalid result in some cases: see GH#26130. - // For now, when that happens, we give up and don't narrow at all. (This also - // means we'll never narrow for erroneous assignments where the assigned type - // is not assignable to the declared type.) - if (isTypeAssignableTo(assignedType, reducedType)) { - return reducedType; - } + var _a; + if (declaredType === assignedType) { + return declaredType; } - return declaredType; + if (assignedType.flags & 131072 /* TypeFlags.Never */) { + return assignedType; + } + var key = "A".concat(getTypeId(declaredType), ",").concat(getTypeId(assignedType)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType)); + } + function getAssignmentReducedTypeWorker(declaredType, assignedType) { + var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); + // Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type. + var reducedType = assignedType.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType; + // Our crude heuristic produces an invalid result in some cases: see GH#26130. + // For now, when that happens, we give up and don't narrow at all. (This also + // means we'll never narrow for erroneous assignments where the assigned type + // is not assignable to the declared type.) + return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType; } function isFunctionObjectType(type) { // We do a quick check for a "bind" property before performing the more expensive subtype @@ -70297,95 +70529,95 @@ var ts; resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { - if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) { + if (type.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */)) { type = getBaseConstraintOfType(type) || unknownType; } var flags = type.flags; - if (flags & (4 /* String */ | 268435456 /* StringMapping */)) { - return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; + if (flags & (4 /* TypeFlags.String */ | 268435456 /* TypeFlags.StringMapping */)) { + return strictNullChecks ? 16317953 /* TypeFacts.StringStrictFacts */ : 16776705 /* TypeFacts.StringFacts */; } - if (flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) { - var isEmpty = flags & 128 /* StringLiteral */ && type.value === ""; + if (flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + var isEmpty = flags & 128 /* TypeFlags.StringLiteral */ && type.value === ""; return strictNullChecks ? - isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : - isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* TypeFacts.EmptyStringStrictFacts */ : 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* TypeFacts.EmptyStringFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; + if (flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */)) { + return strictNullChecks ? 16317698 /* TypeFacts.NumberStrictFacts */ : 16776450 /* TypeFacts.NumberFacts */; } - if (flags & 256 /* NumberLiteral */) { + if (flags & 256 /* TypeFlags.NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : - isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + isZero ? 12123394 /* TypeFacts.ZeroNumberStrictFacts */ : 7929090 /* TypeFacts.NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* TypeFacts.ZeroNumberFacts */ : 16776450 /* TypeFacts.NonZeroNumberFacts */; } - if (flags & 64 /* BigInt */) { - return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + if (flags & 64 /* TypeFlags.BigInt */) { + return strictNullChecks ? 16317188 /* TypeFacts.BigIntStrictFacts */ : 16775940 /* TypeFacts.BigIntFacts */; } - if (flags & 2048 /* BigIntLiteral */) { + if (flags & 2048 /* TypeFlags.BigIntLiteral */) { var isZero = isZeroBigInt(type); return strictNullChecks ? - isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : - isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; + isZero ? 12122884 /* TypeFacts.ZeroBigIntStrictFacts */ : 7928580 /* TypeFacts.NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* TypeFacts.ZeroBigIntFacts */ : 16775940 /* TypeFacts.NonZeroBigIntFacts */; } - if (flags & 16 /* Boolean */) { - return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; + if (flags & 16 /* TypeFlags.Boolean */) { + return strictNullChecks ? 16316168 /* TypeFacts.BooleanStrictFacts */ : 16774920 /* TypeFacts.BooleanFacts */; } - if (flags & 528 /* BooleanLike */) { + if (flags & 528 /* TypeFlags.BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* TypeFacts.FalseStrictFacts */ : 7927560 /* TypeFacts.TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* TypeFacts.FalseFacts */ : 16774920 /* TypeFacts.TrueFacts */; } - if (flags & 524288 /* Object */) { - return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : + if (flags & 524288 /* TypeFlags.Object */) { + return ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && isEmptyObjectType(type) ? + strictNullChecks ? 83427327 /* TypeFacts.EmptyObjectStrictFacts */ : 83886079 /* TypeFacts.EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : - strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + strictNullChecks ? 7880640 /* TypeFacts.FunctionStrictFacts */ : 16728000 /* TypeFacts.FunctionFacts */ : + strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 16384 /* Void */) { - return 9830144 /* VoidFacts */; + if (flags & 16384 /* TypeFlags.Void */) { + return 9830144 /* TypeFacts.VoidFacts */; } - if (flags & 32768 /* Undefined */) { - return 26607360 /* UndefinedFacts */; + if (flags & 32768 /* TypeFlags.Undefined */) { + return 26607360 /* TypeFacts.UndefinedFacts */; } - if (flags & 65536 /* Null */) { - return 42917664 /* NullFacts */; + if (flags & 65536 /* TypeFlags.Null */) { + return 42917664 /* TypeFacts.NullFacts */; } - if (flags & 12288 /* ESSymbolLike */) { - return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; + if (flags & 12288 /* TypeFlags.ESSymbolLike */) { + return strictNullChecks ? 7925520 /* TypeFacts.SymbolStrictFacts */ : 16772880 /* TypeFacts.SymbolFacts */; } - if (flags & 67108864 /* NonPrimitive */) { - return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + if (flags & 67108864 /* TypeFlags.NonPrimitive */) { + return strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 131072 /* Never */) { - return 0 /* None */; + if (flags & 131072 /* TypeFlags.Never */) { + return 0 /* TypeFacts.None */; } - if (flags & 1048576 /* Union */) { - return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* None */); + if (flags & 1048576 /* TypeFlags.Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* TypeFacts.None */); } - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionTypeFacts(type); } - return 83886079 /* UnknownFacts */; + return 83886079 /* TypeFacts.UnknownFacts */; } function getIntersectionTypeFacts(type) { // When an intersection contains a primitive type we ignore object type constituents as they are // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type. - var ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */); + var ignoreObjects = maybeTypeOfKind(type, 131068 /* TypeFlags.Primitive */); // When computing the type facts of an intersection type, certain type facts are computed as `and` // and others are computed as `or`. - var oredFacts = 0 /* None */; - var andedFacts = 134217727 /* All */; + var oredFacts = 0 /* TypeFacts.None */; + var andedFacts = 134217727 /* TypeFacts.All */; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (!(ignoreObjects && t.flags & 524288 /* Object */)) { + if (!(ignoreObjects && t.flags & 524288 /* TypeFlags.Object */)) { var f = getTypeFacts(t); oredFacts |= f; andedFacts &= f; } } - return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */; + return oredFacts & 8256 /* TypeFacts.OrFactsMask */ | andedFacts & 134209471 /* TypeFacts.AndFactsMask */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -70394,16 +70626,16 @@ var ts; // unknown with the union {} | null | undefined (and reduces that accordingly), and it intersects remaining // instantiable types with {}, {} | null, or {} | undefined in order to remove null and/or undefined. function getAdjustedTypeWithFacts(type, facts) { - var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts)); + var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */ ? unknownUnionType : type, facts)); if (strictNullChecks) { switch (facts) { - case 524288 /* NEUndefined */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; }); - case 1048576 /* NENull */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; }); - case 2097152 /* NEUndefinedOrNull */: - case 4194304 /* Truthy */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; }); + case 524288 /* TypeFacts.NEUndefined */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* TypeFacts.EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* TypeFacts.EQNull */ && !maybeTypeOfKind(reduced, 65536 /* TypeFlags.Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; }); + case 1048576 /* TypeFacts.NENull */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* TypeFacts.EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* TypeFacts.EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* TypeFlags.Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; }); + case 2097152 /* TypeFacts.NEUndefinedOrNull */: + case 4194304 /* TypeFacts.Truthy */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; }); } } return reduced; @@ -70426,7 +70658,7 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || - includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || + includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || errorType; } function includeUndefinedInIndexSignature(type) { @@ -70437,18 +70669,18 @@ var ts; type; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); + return createArrayType(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 204 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 221 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 244 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -70465,21 +70697,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return stringType; - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return undefinedType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -70487,7 +70719,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 201 /* ObjectBindingPattern */ ? + var type = pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -70505,37 +70737,37 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 243 /* ForInStatement */) { + if (node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 254 /* VariableDeclaration */ ? + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 254 /* VariableDeclaration */ && node.initializer && + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 203 /* BindingElement */ && node.parent.kind === 221 /* BinaryExpression */ && + node.kind !== 203 /* SyntaxKind.BindingElement */ && node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return getReferenceCandidate(node.right); } } @@ -70543,13 +70775,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 212 /* ParenthesizedExpression */ || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.left === node || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -70568,25 +70800,25 @@ var ts; // Get the type names from all cases in a switch on `typeof`. The default clause and/or duplicate type names are // represented as undefined. Return undefined if one or more case clause expressions are not string literals. function getSwitchClauseTypeOfWitnesses(switchStatement) { - if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) { + if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* SyntaxKind.CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) { return undefined; } var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - var text = clause.kind === 289 /* CaseClause */ ? clause.expression.text : undefined; + var text = clause.kind === 289 /* SyntaxKind.CaseClause */ ? clause.expression.text : undefined; witnesses.push(text && !ts.contains(witnesses, text) ? text : undefined); } return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 1048576 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* TypeFlags.Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* TypeFlags.Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -70595,25 +70827,25 @@ var ts; } return true; } - if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* TypeFlags.EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.forEach(type.types, f) : f(type); } function someType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.every(type.types, f) : f(type); } function everyContainedType(type, f) { - return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var types = type.types; var filtered = ts.filter(types, f); if (filtered === types) { @@ -70621,45 +70853,45 @@ var ts; } var origin = type.origin; var newOrigin = void 0; - if (origin && origin.flags & 1048576 /* Union */) { + if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { // If the origin type is a (denormalized) union type, filter its non-union constituents. If that ends // up removing a smaller number of types than in the normalized constituent set (meaning some of the // filtered types are within nested unions in the origin), then we can't construct a new origin type. // Otherwise, if we have exactly one type left in the origin set, return that as the filtered type. // Otherwise, construct a new filtered origin type. var originTypes = origin.types; - var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* Union */) || f(t); }); + var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) || f(t); }); if (originTypes.length - originFiltered.length === types.length - filtered.length) { if (originFiltered.length === 1) { return originFiltered[0]; } - newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + newOrigin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, originFiltered); } } return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } - return type.flags & 131072 /* Never */ || f(type) ? type : neverType; + return type.flags & 131072 /* TypeFlags.Never */ || f(type) ? type : neverType; } function removeType(type, targetType) { return filterType(type, function (t) { return t !== targetType; }); } function countTypes(type) { - return type.flags & 1048576 /* Union */ ? type.types.length : 1; + return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1; } function mapType(type, mapper, noReductions) { - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return type; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return mapper(type); } var origin = type.origin; - var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types; + var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? origin.types : type.types; var mappedTypes; var changed = false; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; - var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t); + var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { if (!mappedTypes) { @@ -70670,11 +70902,11 @@ var ts; } } } - return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; + return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type; } function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { - return type.flags & 1048576 /* Union */ && aliasSymbol ? - getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper); } function extractTypesOfKind(type, kind) { @@ -70686,13 +70918,13 @@ var ts; // true intersection because it is more costly and, when applied to union types, generates a large number of // types we don't actually care about. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && - maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) { + if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) && + maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : - isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; + return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) : + isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) : + t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) : + t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -70704,14 +70936,14 @@ var ts; return flowType.flags === 0 ? flowType.type : flowType; } function createFlowType(type, incomplete) { - return incomplete ? { flags: 0, type: type.flags & 131072 /* Never */ ? silentNeverType : type } : type; + return incomplete ? { flags: 0, type: type.flags & 131072 /* TypeFlags.Never */ ? silentNeverType : type } : type; } // An evolving array type tracks the element types that have so far been seen in an // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(256 /* EvolvingArray */); + var result = createObjectType(256 /* ObjectFlags.EvolvingArray */); result.elementType = elementType; return result; } @@ -70726,10 +70958,10 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 131072 /* Never */ ? + return elementType.flags & 131072 /* TypeFlags.Never */ ? autoArrayType : - createArrayType(elementType.flags & 1048576 /* Union */ ? - getUnionType(elementType.types, 2 /* Subtype */) : + createArrayType(elementType.flags & 1048576 /* TypeFlags.Union */ ? + getUnionType(elementType.types, 2 /* UnionReduction.Subtype */) : elementType); } // We perform subtype reduction upon obtaining the final array type from an evolving array type. @@ -70737,17 +70969,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { var t = types_17[_i]; - if (!(t.flags & 131072 /* Never */)) { - if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + if (!(ts.getObjectFlags(t) & 256 /* ObjectFlags.EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -70761,16 +70993,16 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 208 /* CallExpression */ + parent.parent.kind === 208 /* SyntaxKind.CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 207 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 221 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 63 /* EqualsToken */ && + parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* TypeFlags.NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(node) { @@ -70779,11 +71011,11 @@ var ts; ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer)); } function getExplicitTypeOfSymbol(symbol, diagnostic) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { + if (ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */) { var origin = symbol.syntheticOrigin; if (origin && getExplicitTypeOfSymbol(origin)) { return getTypeOfSymbol(symbol); @@ -70794,11 +71026,11 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); } } @@ -70813,16 +71045,16 @@ var ts; // parameter symbols with declarations that have explicit type annotations. Such references are // resolvable with no possibility of triggering circularities in control flow analysis. function getTypeOfDottedName(node, diagnostic) { - if (!(node.flags & 33554432 /* InWithStatement */)) { + if (!(node.flags & 33554432 /* NodeFlags.InWithStatement */)) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); - return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 108 /* ThisKeyword */: + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 108 /* SyntaxKind.ThisKeyword */: return getExplicitThisType(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 206 /* PropertyAccessExpression */: { + case 206 /* SyntaxKind.PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -70840,7 +71072,7 @@ var ts; } return undefined; } - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -70854,10 +71086,10 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 106 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -70865,7 +71097,7 @@ var ts; funcType = checkNonNullExpression(node.expression); } } - var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* SignatureKind.Call */); var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : undefined; @@ -70875,10 +71107,10 @@ var ts; } function hasTypePredicateOrNeverReturnType(signature) { return !!(getTypePredicateOfSignature(signature) || - signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* TypeFlags.Never */); } function getTypePredicateArgument(predicate, callExpression) { - if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + if (predicate.kind === 1 /* TypePredicateKind.Identifier */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { return callExpression.arguments[predicate.parameterIndex]; } var invokedExpression = ts.skipParentheses(callExpression.expression); @@ -70898,8 +71130,8 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 95 /* FalseKeyword */ || node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || - node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + return node.kind === 95 /* SyntaxKind.FalseKeyword */ || node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { while (true) { @@ -70907,7 +71139,7 @@ var ts; return lastFlowNodeReachable; } var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var reachable = flowNodeReachable[id]; @@ -70915,30 +71147,30 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && predicate.kind === 3 /* AssertsIdentifier */ && !predicate.type) { + if (predicate && predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && !predicate.type) { var predicateArgument = flow.node.arguments[predicate.parameterIndex]; if (predicateArgument && isFalseExpression(predicateArgument)) { return false; } } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return false; } } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is reachable if any branch is reachable. return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { var antecedents = flow.antecedents; if (antecedents === undefined || antecedents.length === 0) { return false; @@ -70946,7 +71178,7 @@ var ts; // A loop is reachable if the control flow path that leads to the top is reachable. flow = antecedents[0]; } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { // The control flow path representing an unmatched value in a switch statement with // no default clause is unreachable if the switch statement is exhaustive. if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { @@ -70954,7 +71186,7 @@ var ts; } flow = flow.antecedent; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { // Cache is unreliable once we start adjusting labels lastFlowNode = undefined; var target = flow.target; @@ -70965,7 +71197,7 @@ var ts; return result; } else { - return !(flags & 1 /* Unreachable */); + return !(flags & 1 /* FlowFlags.Unreachable */); } } } @@ -70974,7 +71206,7 @@ var ts; function isPostSuperFlowNode(flow, noCacheCheck) { while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var postSuper = flowNodePostSuper[id]; @@ -70982,24 +71214,24 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 128 /* SwitchClause */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */ | 128 /* FlowFlags.SwitchClause */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 106 /* SuperKeyword */) { + else if (flags & 512 /* FlowFlags.Call */) { + if (flow.node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return true; } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is post-super if every branch is post-super. return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { // A loop is post-super if the control flow path that leads to the top is post-super. flow = flow.antecedents[0]; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; @@ -71009,18 +71241,18 @@ var ts; } else { // Unreachable nodes are considered post-super to silence errors - return !!(flags & 1 /* Unreachable */); + return !!(flags & 1 /* FlowFlags.Unreachable */); } } } function isConstantReference(node) { switch (node.kind) { - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var symbol = getResolvedSymbol(node); return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); } @@ -71046,8 +71278,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* ObjectFlags.EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* SyntaxKind.NonNullExpression */ && !(resultType.flags & 131072 /* TypeFlags.Never */) && getTypeWithFacts(resultType, 2097152 /* TypeFacts.NEUndefinedOrNull */).flags & 131072 /* TypeFlags.Never */) { return declaredType; } // The non-null unknown type should never escape control flow analysis. @@ -71063,7 +71295,7 @@ var ts; if (flowDepth === 2000) { // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error // and disable further control flow analysis in the containing function or module body. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -71072,7 +71304,7 @@ var ts; var sharedFlow; while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -71085,56 +71317,56 @@ var ts; sharedFlow = flow; } var type = void 0; - if (flags & 16 /* Assignment */) { + if (flags & 16 /* FlowFlags.Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { type = getTypeAtFlowCall(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 96 /* Condition */) { + else if (flags & 96 /* FlowFlags.Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flags & 12 /* Label */) { + else if (flags & 12 /* FlowFlags.Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flags & 4 /* BranchLabel */ ? + type = flags & 4 /* FlowFlags.BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* FlowFlags.ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; type = getTypeAtFlowNode(flow.antecedent); target.antecedents = saveAntecedents; } - else if (flags & 2 /* Start */) { + else if (flags & 2 /* FlowFlags.Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 206 /* PropertyAccessExpression */ && - reference.kind !== 207 /* ElementAccessExpression */ && - reference.kind !== 108 /* ThisKeyword */) { + reference.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && + reference.kind !== 207 /* SyntaxKind.ElementAccessExpression */ && + reference.kind !== 108 /* SyntaxKind.ThisKeyword */) { flow = container.flowNode; continue; } @@ -71158,7 +71390,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -71170,7 +71402,7 @@ var ts; if (!isReachableFlowNode(flow)) { return unreachableNeverType; } - if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { + if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -71181,7 +71413,7 @@ var ts; var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* TypeFlags.Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; @@ -71198,29 +71430,29 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 213 /* FunctionExpression */ || init.kind === 214 /* ArrowFunction */)) { + if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { - return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)))); } // Assignment doesn't affect reference return undefined; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - if (node.kind === 95 /* FalseKeyword */) { + if (node.kind === 95 /* SyntaxKind.FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 221 /* BinaryExpression */) { - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } - if (node.operatorToken.kind === 56 /* BarBarToken */) { + if (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); } } @@ -71230,15 +71462,15 @@ var ts; var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + if (predicate && (predicate.kind === 2 /* TypePredicateKind.AssertsThis */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = finalizeEvolvingArrayType(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]) : + predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return unreachableNeverType; } } @@ -71247,15 +71479,15 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 208 /* CallExpression */ ? + var expr = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { + if (ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -71264,7 +71496,7 @@ var ts; else { // We must get the context free expression type so as to not recur in an uncached fashion on the LHS (which causes exponential blowup in compile time) var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -71278,7 +71510,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -71288,7 +71520,7 @@ var ts; // have the complete type. We proceed by switching to the silent never type which // doesn't report errors when operators are applied to it. Note that this is the // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { @@ -71303,16 +71535,16 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 216 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* TypeFlags.Undefined */ | 131072 /* TypeFlags.Never */)); }); } - else if (expr.kind === 216 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* TypeFlags.Never */ || t.flags & 128 /* TypeFlags.StringLiteral */ && t.value === "undefined"); }); } } var access = getDiscriminantPropertyAccess(expr, type); @@ -71329,7 +71561,7 @@ var ts; var bypassFlow; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { + if (!bypassFlow && antecedent.flags & 128 /* FlowFlags.SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { // The antecedent is the bypass branch of a potentially exhaustive switch statement. bypassFlow = antecedent; continue; @@ -71373,7 +71605,7 @@ var ts; } } } - return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -71399,7 +71631,7 @@ var ts; // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { - return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* Literal */), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* UnionReduction.Literal */), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -71452,7 +71684,7 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } @@ -71467,7 +71699,7 @@ var ts; return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))); } var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction)); - if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) { + if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* TypeFlags.Union */ && ts.arraysEqual(result.types, declaredType.types)) { return declaredType; } return result; @@ -71513,8 +71745,8 @@ var ts; return undefined; } function getDiscriminantPropertyAccess(expr, computedType) { - var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + var type = declaredType.flags & 1048576 /* TypeFlags.Union */ ? declaredType : computedType; + if (type.flags & 1048576 /* TypeFlags.Union */) { var access = getCandidateDiscriminantPropertyAccess(expr); if (access) { var name = getAccessedPropertyName(access); @@ -71530,8 +71762,8 @@ var ts; if (propName === undefined) { return type; } - var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); - var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* TypeFlags.Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } @@ -71539,16 +71771,16 @@ var ts; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); - return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType); + return !(narrowedPropType.flags & 131072 /* TypeFlags.Never */) && isTypeComparableTo(narrowedPropType, discriminantType); }); } function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { - if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + if ((operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* TypeFlags.Union */) { var keyPropertyName = getKeyPropertyName(type); if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); if (candidate) { - return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate : + return operator === (assumeTrue ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) ? candidate : isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) : type; } @@ -71557,7 +71789,7 @@ var ts; return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); }); } function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) { - if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { + if (clauseStart < clauseEnd && type.flags & 1048576 /* TypeFlags.Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); if (candidate !== unknownType) { @@ -71568,51 +71800,51 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); + return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { - type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + type = getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); }); } return type; } function isTypePresencePossible(type, propName, assumeTrue) { var prop = getPropertyOfType(type, propName); if (prop) { - return prop.flags & 16777216 /* Optional */ ? true : assumeTrue; + return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue; } return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue; } function narrowByInKeyword(type, name, assumeTrue) { - if (type.flags & 1048576 /* Union */ - || type.flags & 524288 /* Object */ && declaredType !== type + if (type.flags & 1048576 /* TypeFlags.Union */ + || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type || ts.isThisTypeParameter(type) - || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { + || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); }); } return type; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -71644,35 +71876,35 @@ var ts; return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (ts.isPrivateIdentifier(expr.left)) { return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue); } var target = getReferenceCandidate(expr.right); var leftType = getTypeOfNode(expr.left); - if (leftType.flags & 128 /* StringLiteral */) { + if (leftType.flags & 128 /* TypeFlags.StringLiteral */) { var name = ts.escapeLeadingUnderscores(leftType.value); if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && getAccessedPropertyName(reference) === name) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } if (isMatchingReference(reference, target)) { return narrowByInKeyword(type, name, assumeTrue); } } break; - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return narrowType(type, expr.right, assumeTrue); // Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those // expressions down to individual conditional control flows. However, we may encounter them when analyzing // aliased conditional expressions. - case 55 /* AmpersandAmpersandToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: return assumeTrue ? narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) : getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]); - case 56 /* BarBarToken */: + case 56 /* SyntaxKind.BarBarToken */: return assumeTrue ? getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) : narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); @@ -71693,7 +71925,7 @@ var ts; var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true); } function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { // We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows: @@ -71705,45 +71937,45 @@ var ts; // When operator is !== and type of value is undefined, null and undefined is removed from type of obj in true branch. // When operator is == and type of value is null or undefined, null and undefined is removed from type of obj in false branch. // When operator is != and type of value is null or undefined, null and undefined is removed from type of obj in true branch. - var equalsOperator = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; - var nullableFlags = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */; + var equalsOperator = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; + var nullableFlags = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? 98304 /* TypeFlags.Nullable */ : 32768 /* TypeFlags.Undefined */; var valueType = getTypeOfExpression(value); // Note that we include any and unknown in the exclusion test because their domain includes null and undefined. var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) || - equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); }); - return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* TypeFlags.AnyOrUnknown */ | nullableFlags)); }); + return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeByEquality(type, operator, value, assumeTrue) { - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { return type; } - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { - if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && assumeTrue && (operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { + if (valueType.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { return valueType; } - if (valueType.flags & 524288 /* Object */) { + if (valueType.flags & 524288 /* TypeFlags.Object */) { return nonPrimitiveType; } return type; } - if (valueType.flags & 98304 /* Nullable */) { + if (valueType.flags & 98304 /* TypeFlags.Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : - valueType.flags & 65536 /* Null */ ? - assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : - assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; + assumeTrue ? 262144 /* TypeFacts.EQUndefinedOrNull */ : 2097152 /* TypeFacts.NEUndefinedOrNull */ : + valueType.flags & 65536 /* TypeFlags.Null */ ? + assumeTrue ? 131072 /* TypeFacts.EQNull */ : 1048576 /* TypeFacts.NENull */ : + assumeTrue ? 65536 /* TypeFacts.EQUndefined */ : 524288 /* TypeFacts.NEUndefined */; return getAdjustedTypeWithFacts(type, facts); } if (assumeTrue) { - var filterFn = operator === 34 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); @@ -71755,23 +71987,23 @@ var ts; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { - return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } return assumeTrue ? narrowTypeByTypeName(type, literal.text) : - getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */); + getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeFacts.TypeofNEHostObject */); } function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); - return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify @@ -71784,16 +72016,16 @@ var ts; } var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); - if ((type.flags & 2 /* Unknown */) && !hasDefaultClause) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && !hasDefaultClause) { var groundClauseTypes = void 0; for (var i = 0; i < clauseTypes.length; i += 1) { var t = clauseTypes[i]; - if (t.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if (t.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { if (groundClauseTypes !== undefined) { groundClauseTypes.push(t); } } - else if (t.flags & 524288 /* Object */) { + else if (t.flags & 524288 /* TypeFlags.Object */) { if (groundClauseTypes === undefined) { groundClauseTypes = clauseTypes.slice(0, i); } @@ -71806,26 +72038,26 @@ var ts; return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes); } var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* TypeFlags.Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); - return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]); } function narrowTypeByTypeName(type, typeName) { switch (typeName) { - case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeofEQString */); - case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeofEQNumber */); - case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeofEQBigInt */); - case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeofEQBoolean */); - case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeofEQSymbol */); - case "object": return type.flags & 1 /* Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* EQNull */)]); - case "function": return type.flags & 1 /* Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeofEQFunction */); - case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* EQUndefined */); + case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeFacts.TypeofEQString */); + case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeFacts.TypeofEQNumber */); + case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeFacts.TypeofEQBigInt */); + case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeFacts.TypeofEQBoolean */); + case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeFacts.TypeofEQSymbol */); + case "object": return type.flags & 1 /* TypeFlags.Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeFacts.TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* TypeFacts.EQNull */)]); + case "function": return type.flags & 1 /* TypeFlags.Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeFacts.TypeofEQFunction */); + case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* TypeFacts.EQUndefined */); } - return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */); + return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeFacts.TypeofEQHostObject */); } function narrowTypeByTypeFacts(type, impliedType, facts) { return mapType(type, function (t) { @@ -71850,7 +72082,7 @@ var ts; return type; } // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause. - var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* DefaultClause */; }); + var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* SyntaxKind.DefaultClause */; }); var hasDefaultClause = clauseStart === clauseEnd || (defaultIndex >= clauseStart && defaultIndex < clauseEnd); if (hasDefaultClause) { // In the default clause we filter constituents down to those that are not-equal to all handled cases. @@ -71868,7 +72100,7 @@ var ts; } function narrowTypeByConstructor(type, operator, identifier, assumeTrue) { // Do not narrow when checking inequality. - if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) { + if (assumeTrue ? (operator !== 34 /* SyntaxKind.EqualsEqualsToken */ && operator !== 36 /* SyntaxKind.EqualsEqualsEqualsToken */) : (operator !== 35 /* SyntaxKind.ExclamationEqualsToken */ && operator !== 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { return type; } // Get the type of the constructor identifier expression, if it is not a function then do not narrow. @@ -71898,8 +72130,8 @@ var ts; // This is because you may have a class `A` that defines some set of properties, and another class `B` // that defines the same set of properties as class `A`, in that case they are structurally the same // type, but when you do something like `instanceOfA.constructor === B` it will return false. - if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ || - target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) { + if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ || + target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { return source.symbol === target.symbol; } // For all other types just check that the `source` type is a subtype of the `target` type. @@ -71910,7 +72142,7 @@ var ts; var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { - return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } @@ -71933,46 +72165,65 @@ var ts; return type; } if (!targetType) { - var constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(rightType, 1 /* SignatureKind.Construct */); targetType = constructSignatures.length ? getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) : emptyObjectType; } // We can't narrow a union based off instanceof without negated types see #31576 for more info - if (!assumeTrue && rightType.flags & 1048576 /* Union */) { + if (!assumeTrue && rightType.flags & 1048576 /* TypeFlags.Union */) { var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); }); if (!nonConstructorTypeInUnion) return type; } - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true); } - function getNarrowedType(type, candidate, assumeTrue, isRelated) { + function getNarrowedType(type, candidate, assumeTrue, checkDerived) { + var _a; + var key = type.flags & 1048576 /* TypeFlags.Union */ ? "N".concat(getTypeId(type), ",").concat(getTypeId(candidate), ",").concat((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined; + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived)); + } + function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) { + var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf; if (!assumeTrue) { return filterType(type, function (t) { return !isRelated(t, candidate); }); } - // If the current type is a union type, remove all constituents that couldn't be instances of - // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 1048576 /* Union */) { - var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072 /* Never */)) { - return assignableType; - } + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { + return candidate; } - // If the candidate type is a subtype of the target type, narrow to the candidate type. - // Otherwise, if the target type is assignable to the candidate type, keep the target type. - // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate - // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the - // two types. - return isTypeSubtypeOf(candidate, type) ? candidate : - isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, type) ? candidate : - getIntersectionType([type, candidate]); + // We first attempt to filter the current type, narrowing constituents as appropriate and removing + // constituents that are unrelated to the candidate. + var keyPropertyName = type.flags & 1048576 /* TypeFlags.Union */ ? getKeyPropertyName(type) : undefined; + var narrowedType = mapType(candidate, function (c) { + // If a discriminant property is available, use that to reduce the type. + var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName); + var matching = discriminant && getConstituentTypeForKeyType(type, discriminant); + // For each constituent t in the current type, if t and and c are directly related, pick the most + // specific of the two. When t and c are related in both directions, we prefer c for type predicates + // because that is the asserted type, but t for `instanceof` because generics aren't reflected in + // prototype object types. + var directlyRelated = mapType(matching || type, checkDerived ? + function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } : + function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; }); + // If no constituents are directly related, create intersections for any generic constituents that + // are related by constraint. + return directlyRelated.flags & 131072 /* TypeFlags.Never */ ? + mapType(type, function (t) { return maybeTypeOfKind(t, 465829888 /* TypeFlags.Instantiable */) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType; }) : + directlyRelated; + }); + // If filtering produced a non-empty type, return that. Otherwise, pick the most specific of the two + // based on assignability, or as a last resort produce an intersection. + return !(narrowedType.flags & 131072 /* TypeFlags.Never */) ? narrowedType : + isTypeSubtypeOf(candidate, type) ? candidate : + isTypeAssignableTo(type, candidate) ? type : + isTypeAssignableTo(candidate, type) ? candidate : + getIntersectionType([type, candidate]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; var predicate = signature && getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + if (predicate && (predicate.kind === 0 /* TypePredicateKind.This */ || predicate.kind === 1 /* TypePredicateKind.Identifier */)) { return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } @@ -71982,7 +72233,7 @@ var ts; ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) { var argument = callExpression.arguments[0]; if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } } } @@ -71994,15 +72245,15 @@ var ts; var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && - !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { - type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + !(getTypeFacts(predicate.type) & 65536 /* TypeFacts.EQUndefined */)) { + type = getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); }); } } } @@ -72013,11 +72264,11 @@ var ts; function narrowType(type, expr, assumeTrue) { // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` if (ts.isExpressionOfOptionalChainRoot(expr) || - ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */ && expr.parent.left === expr) { return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline // up to five levels of aliased conditional expressions that are themselves declared as const variables. if (!isMatchingReference(reference, expr) && inlineLevel < 5) { @@ -72033,20 +72284,20 @@ var ts; } } // falls through - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 219 /* PrefixUnaryExpression */: - if (expr.operator === 53 /* ExclamationToken */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (expr.operator === 53 /* SyntaxKind.ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -72055,11 +72306,11 @@ var ts; } function narrowTypeByOptionality(type, expr, assumePresent) { if (isMatchingReference(reference, expr)) { - return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); }); } return type; } @@ -72070,7 +72321,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { + if (location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -72094,9 +72345,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 262 /* ModuleBlock */ || - node.kind === 305 /* SourceFile */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 262 /* SyntaxKind.ModuleBlock */ || + node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; }); } // Check if a parameter or catch variable is assigned anywhere @@ -72106,8 +72357,8 @@ var ts; } var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(parent); - if (!(links.flags & 8388608 /* AssignmentsMarked */)) { - links.flags |= 8388608 /* AssignmentsMarked */; + if (!(links.flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */)) { + links.flags |= 8388608 /* NodeCheckFlags.AssignmentsMarked */; if (!hasParentWithAssignmentsMarked(parent)) { markNodeAssignments(parent); } @@ -72116,11 +72367,11 @@ var ts; } function hasParentWithAssignmentsMarked(node) { return !!ts.findAncestor(node.parent, function (node) { - return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); + return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */); }); } function markNodeAssignments(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); if (ts.isParameterOrCatchClauseVariable(symbol)) { @@ -72133,18 +72384,18 @@ var ts; } } function isConstVariable(symbol) { - return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0; + return symbol.flags & 3 /* SymbolFlags.Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */) !== 0; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { - if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { + if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 164 /* Parameter */ && + declaration.kind === 164 /* SyntaxKind.Parameter */ && declaration.initializer && - getTypeFacts(declaredType) & 16777216 /* IsUndefined */ && - !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* IsUndefined */); + getTypeFacts(declaredType) & 16777216 /* TypeFacts.IsUndefined */ && + !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* TypeFacts.IsUndefined */); popTypeResolution(); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType; } else { reportCircularityError(declaration.symbol); @@ -72156,19 +72407,19 @@ var ts; // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of // a generic type without a nullable constraint and x is a generic type. This is because when both obj // and x are of generic types T and K, we want the resulting type to be T[K]. - return parent.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 161 /* QualifiedName */ || - parent.kind === 208 /* CallExpression */ && parent.expression === node || - parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node && + return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 161 /* SyntaxKind.QualifiedName */ || + parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node || + parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { - return type.flags & 2097152 /* Intersection */ ? + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isGenericTypeWithUnionConstraint) : - !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */)); } function isGenericTypeWithoutNullableConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* TypeFlags.Nullable */)); } function hasContextualTypeWithNoGenericTypes(node, checkMode) { // Computing the contextual type for a child of a JSX element involves resolving the type of the @@ -72177,9 +72428,9 @@ var ts; // as we want the type of a rest element to be generic when possible. var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && - (checkMode && checkMode & 64 /* RestBindingElement */ ? - getContextualType(node, 8 /* SkipBindingPatterns */) - : getContextualType(node)); + (checkMode && checkMode & 64 /* CheckMode.RestBindingElement */ ? + getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) + : getContextualType(node, /*contextFlags*/ undefined)); return contextualType && !isGenericType(contextualType); } function getNarrowableTypeForReference(type, reference, checkMode) { @@ -72190,7 +72441,7 @@ var ts; // control flow analysis an opportunity to narrow it further. For example, for a reference of a type // parameter type 'T extends string | undefined' with a contextual type 'string', we substitute // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. - var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && + var substituteConstraints = !(checkMode && checkMode & 2 /* CheckMode.Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode)); return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type; @@ -72211,9 +72462,9 @@ var ts; }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled // (because the const enum value will not be inlined), or if (2) the alias is an export // of a const enum declaration that will be preserved. @@ -72256,16 +72507,16 @@ var ts; // destructuring from the narrowed parent type. if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { var parent = declaration.parent.parent; - if (parent.kind === 254 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 164 /* Parameter */) { + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || parent.kind === 164 /* SyntaxKind.Parameter */) { var links = getNodeLinks(parent); - if (!(links.flags & 268435456 /* InCheckIdentifier */)) { - links.flags |= 268435456 /* InCheckIdentifier */; - var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */); - links.flags &= ~268435456 /* InCheckIdentifier */; - if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 164 /* Parameter */ && isSymbolAssigned(symbol))) { + if (!(links.flags & 268435456 /* NodeCheckFlags.InCheckIdentifier */)) { + links.flags |= 268435456 /* NodeCheckFlags.InCheckIdentifier */; + var parentType = getTypeForBindingElementParent(parent, 0 /* CheckMode.Normal */); + links.flags &= ~268435456 /* NodeCheckFlags.InCheckIdentifier */; + if (parentType && parentType.flags & 1048576 /* TypeFlags.Union */ && !(parent.kind === 164 /* SyntaxKind.Parameter */ && isSymbolAssigned(symbol))) { var pattern = declaration.parent; var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode); - if (narrowedType.flags & 131072 /* Never */) { + if (narrowedType.flags & 131072 /* TypeFlags.Never */) { return neverType; } return getBindingElementTypeFromParentType(declaration, narrowedType); @@ -72299,7 +72550,7 @@ var ts; var contextualSignature = getContextualSignature(func); if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) { var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0])); - if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { + if (restType.flags & 1048576 /* TypeFlags.Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode); var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0); return getIndexedAccessType(narrowedType, getNumberLiteralType(index)); @@ -72330,20 +72581,18 @@ var ts; return errorType; } var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 214 /* ArrowFunction */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } - else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { + else if (ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; + getNodeLinks(container).flags |= 8192 /* NodeCheckFlags.CaptureArguments */; return getTypeOfSymbol(symbol); } - // We should only mark aliases as referenced if there isn't a local value declaration - // for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that - if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) { + if (shouldMarkIdentifierAliasReferenced(node)) { markAliasReferenced(symbol, node); } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); @@ -72352,32 +72601,32 @@ var ts; addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (declaration && localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 257 /* ClassDeclaration */ + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { if (container === declaration && container.name !== node) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; break; } container = ts.getContainingClass(container); } } - else if (declaration.kind === 226 /* ClassExpression */) { + else if (declaration.kind === 226 /* SyntaxKind.ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 305 /* SourceFile */) { + while (container.kind !== 305 /* SyntaxKind.SourceFile */) { if (container.parent === declaration) { if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; } break; } @@ -72389,19 +72638,19 @@ var ts; var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { - if (!(localOrExportSymbol.flags & 3 /* Variable */) && - !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum - : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class - : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace - : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function - : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import + if (!(localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) && + !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* SymbolFlags.ValueModule */)) { + var assignmentError = localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 /* SymbolFlags.Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { - if (localOrExportSymbol.flags & 3 /* Variable */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol)); } else { @@ -72410,11 +72659,11 @@ var ts; return errorType; } } - var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; + var isAlias = localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */; // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (localOrExportSymbol.flags & 3 /* Variable */) { - if (assignmentKind === 1 /* Definite */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { + if (assignmentKind === 1 /* AssignmentKind.Definite */) { return type; } } @@ -72431,17 +72680,17 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* SyntaxKind.Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - var isModuleExports = symbol.flags & 134217728 /* ModuleExports */; + var isModuleExports = symbol.flags & 134217728 /* SymbolFlags.ModuleExports */; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* FunctionExpression */ || - flowContainer.kind === 214 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* SyntaxKind.FunctionExpression */ || + flowContainer.kind === 214 /* SyntaxKind.ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -72449,11 +72698,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) || - node.parent.kind === 230 /* NonNullExpression */ || - declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 16777216 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) || + node.parent.kind === 230 /* SyntaxKind.NonNullExpression */ || + declaration.kind === 254 /* SyntaxKind.VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 16777216 /* NodeFlags.Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -72477,6 +72726,25 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function shouldMarkIdentifierAliasReferenced(node) { + var _a; + var parent = node.parent; + if (parent) { + // A property access expression LHS? checkPropertyAccessExpression will handle that. + if (ts.isPropertyAccessExpression(parent) && parent.expression === node) { + return false; + } + // Next two check for an identifier inside a type only export. + if (ts.isExportSpecifier(parent) && parent.isTypeOnly) { + return false; + } + var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent; + if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) { + return false; + } + } + return true; + } function isInsideFunctionOrInstancePropertyInitializer(node, threshold) { return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); }); } @@ -72487,11 +72755,11 @@ var ts; return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); }); } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES2015 */ || - (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || + (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 32 /* SymbolFlags.Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 292 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 292 /* SyntaxKind.CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -72506,12 +72774,12 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); - links.flags |= 131072 /* ContainsCapturedBlockScopeBinding */; + links.flags |= 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */; var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []); ts.pushIfUnique(capturedBindings, symbol); if (part === container.initializer) { @@ -72521,22 +72789,22 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { - getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; + getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */; } } // set 'declared inside loop' bit on the block-scoped binding - getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } if (isCaptured) { - getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; } } function isBindingCapturedByNode(node, decl) { @@ -72546,7 +72814,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 212 /* ParenthesizedExpression */) { + while (current.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -72554,9 +72822,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 219 /* PrefixUnaryExpression */ || current.parent.kind === 220 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || current.parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || expr.operator === 46 /* SyntaxKind.MinusMinusToken */; } if (!isAssigned) { return false; @@ -72566,13 +72834,13 @@ var ts; return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 167 /* PropertyDeclaration */ || container.kind === 171 /* Constructor */) { + getNodeLinks(node).flags |= 2 /* NodeCheckFlags.LexicalThis */; + if (container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || container.kind === 171 /* SyntaxKind.Constructor */) { var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + getNodeLinks(classNode).flags |= 4 /* NodeCheckFlags.CaptureThis */; } else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; + getNodeLinks(container).flags |= 4 /* NodeCheckFlags.CaptureThis */; } } function findFirstSuperCall(node) { @@ -72614,36 +72882,36 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 171 /* Constructor */) { + if (container.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 214 /* ArrowFunction */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } // When targeting es6, mark that we'll need to capture `this` in its lexically bound scope. - if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { + if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ScriptTarget.ES2015 */) { captureLexicalThis(node, container); } var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); @@ -72678,7 +72946,7 @@ var ts; var className = getClassNameFromPrototypeMethod(container); if (isInJS && className) { var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* SymbolFlags.Function */)) { thisType = getDeclaredTypeOfSymbol(classSymbol).thisType; } } @@ -72726,9 +72994,9 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 213 /* FunctionExpression */ && + if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isBinaryExpression(container.parent) && - ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' return container.parent // x.prototype.y = container .left // x.prototype.y @@ -72736,31 +73004,31 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 169 /* MethodDeclaration */ && - container.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && + container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 213 /* FunctionExpression */ && - container.parent.kind === 296 /* PropertyAssignment */ && - container.parent.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && + container.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && + container.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.parent.left.expression; } // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 213 /* FunctionExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && ts.isObjectLiteralExpression(container.parent.parent) && ts.isCallExpression(container.parent.parent.parent) && container.parent.parent.parent.arguments[2] === container.parent.parent && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.parent.arguments[0].expression; } // Object.defineProperty(x, "method", { value() { } }); @@ -72772,17 +73040,17 @@ var ts; ts.isObjectLiteralExpression(container.parent) && ts.isCallExpression(container.parent.parent) && container.parent.parent.arguments[2] === container.parent && - ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.arguments[0].expression; } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 317 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 317 /* SyntaxKind.JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && - jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) { + jsDocFunctionType.parameters[0].name.escapedText === "this" /* InternalSymbolName.This */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -72792,18 +73060,18 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* SyntaxKind.Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 208 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 208 /* SyntaxKind.CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 214 /* ArrowFunction */) { + while (container && container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; + needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -72814,14 +73082,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* ComputedPropertyName */; }); - if (current && current.kind === 162 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* SyntaxKind.ComputedPropertyName */; }); + if (current && current.kind === 162 /* SyntaxKind.ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -72829,26 +73097,26 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 171 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.isStatic(container) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; + nodeCheckFlag = 512 /* NodeCheckFlags.SuperStatic */; if (!isCallExpression && - languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && + languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && (ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) { // for `super.x` or `super[x]` in a static initializer, mark all enclosing // block scope containers so that we can report potential collisions with // `Reflect`. ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) { if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) { - getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */; + getNodeLinks(current).flags |= 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */; } }); } } else { - nodeCheckFlag = 256 /* SuperInstance */; + nodeCheckFlag = 256 /* NodeCheckFlags.SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. @@ -72910,12 +73178,12 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 169 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { - getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */; } else { - getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */; } } if (needToCaptureLexicalThis) { @@ -72924,8 +73192,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 205 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES2015 */) { + if (container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; } @@ -72945,12 +73213,12 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 171 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 171 /* SyntaxKind.Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } - return nodeCheckFlag === 512 /* SuperStatic */ + return nodeCheckFlag === 512 /* NodeCheckFlags.SuperStatic */ ? getBaseConstructorTypeOfClass(classType) : getTypeWithThisArgument(baseClassType, classType.thisType); function isLegalUsageOfSuperExpression(container) { @@ -72960,7 +73228,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 171 /* Constructor */; + return container.kind === 171 /* SyntaxKind.Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -72968,23 +73236,23 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { if (ts.isStatic(container)) { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 170 /* ClassStaticBlockDeclaration */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } else { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 166 /* PropertySignature */ || - container.kind === 171 /* Constructor */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 166 /* SyntaxKind.PropertySignature */ || + container.kind === 171 /* SyntaxKind.Constructor */; } } } @@ -72992,22 +73260,22 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 169 /* MethodDeclaration */ || - func.kind === 172 /* GetAccessor */ || - func.kind === 173 /* SetAccessor */) && func.parent.kind === 205 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 213 /* FunctionExpression */ && func.parent.kind === 296 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ || + func.kind === 172 /* SyntaxKind.GetAccessor */ || + func.kind === 173 /* SyntaxKind.SetAccessor */) && func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ? func.parent : + func.kind === 213 /* SyntaxKind.FunctionExpression */ && func.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -73026,7 +73294,7 @@ var ts; // We have an object literal method. Check if the containing object literal has a contextual type // that includes a ThisType. If so, T is the contextual type for 'this'. We continue looking in // any directly enclosing object literals. - var contextualType = getApparentTypeOfContextualType(containingLiteral); + var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined); var literal = containingLiteral; var type = contextualType; while (type) { @@ -73034,11 +73302,11 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 296 /* PropertyAssignment */) { + if (literal.parent.kind !== 296 /* SyntaxKind.PropertyAssignment */) { break; } literal = literal.parent.parent; - type = getApparentTypeOfContextualType(literal); + type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined); } // There was no contextual ThisType for the containing object literal, so the contextual type // for 'this' is the non-null form of the contextual type for the containing object literal or @@ -73048,7 +73316,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -73076,7 +73344,7 @@ var ts; var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* Normal */); + return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; @@ -73095,31 +73363,31 @@ var ts; tryGetTypeAtPosition(contextualSignature, index); } } - function getContextualTypeForVariableLikeDeclaration(declaration) { + function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) { var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); if (typeNode) { return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return getContextuallyTypedParameterType(declaration); - case 203 /* BindingElement */: - return getContextualTypeForBindingElement(declaration); - case 167 /* PropertyDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + return getContextualTypeForBindingElement(declaration, contextFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isStatic(declaration)) { - return getContextualTypeForStaticPropertyDeclaration(declaration); + return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags); } // By default, do nothing and return undefined - only the above cases have context implied by a parent } } - function getContextualTypeForBindingElement(declaration) { + function getContextualTypeForBindingElement(declaration, contextFlags) { var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */); + var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || + parent.kind !== 203 /* SyntaxKind.BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 202 /* ArrayBindingPattern */) { + if (parent.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -73131,8 +73399,8 @@ var ts; return getTypeOfPropertyOfType(parentType, text); } } - function getContextualTypeForStaticPropertyDeclaration(declaration) { - var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent); + function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) { + var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags); if (!parentType) return undefined; return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName); @@ -73148,32 +73416,35 @@ var ts; function getContextualTypeForInitializerExpression(node, contextFlags) { var declaration = node.parent; if (ts.hasInitializer(declaration) && node === declaration.initializer) { - var result = getContextualTypeForVariableLikeDeclaration(declaration); + var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags); if (result) { return result; } - if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) { + if (!(contextFlags & 8 /* ContextFlags.SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) { return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } } return undefined; } - function getContextualTypeForReturnExpression(node) { + function getContextualTypeForReturnExpression(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); - if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function - var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; - var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined); - if (!iterationTypes) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { // Generator or AsyncGenerator function + var isAsyncGenerator_1 = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + if (contextualReturnType.flags & 1048576 /* TypeFlags.Union */) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, type, isAsyncGenerator_1); }); + } + var iterationReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, contextualReturnType, (functionFlags & 2 /* FunctionFlags.Async */) !== 0); + if (!iterationReturnType) { return undefined; } - contextualReturnType = iterationTypes.returnType; + contextualReturnType = iterationReturnType; // falls through to unwrap Promise for AsyncGenerators } - if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function + if (functionFlags & 2 /* FunctionFlags.Async */) { // Async function or AsyncGenerator function // Get the awaited type without the `Awaited` alias var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); @@ -73191,15 +73462,19 @@ var ts; } return undefined; } - function getContextualTypeForYieldOperand(node) { + function getContextualTypeForYieldOperand(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { var functionFlags = ts.getFunctionFlags(func); - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { + var isAsyncGenerator_2 = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + if (!node.asteriskToken && contextualReturnType.flags & 1048576 /* TypeFlags.Union */) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, type, isAsyncGenerator_2); }); + } return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, contextualReturnType, isAsyncGenerator_2); } } return undefined; @@ -73218,15 +73493,15 @@ var ts; return false; } function getContextualIterationType(kind, functionDecl) { - var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); - var contextualReturnType = getContextualReturnType(functionDecl); + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* FunctionFlags.Async */); + var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) || undefined; } return undefined; } - function getContextualReturnType(functionDecl) { + function getContextualReturnType(functionDecl, contextFlags) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed var returnType = getReturnTypeFromAnnotation(functionDecl); @@ -73241,7 +73516,7 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl); if (iife) { - return getContextualType(iife); + return getContextualType(iife, contextFlags); } return undefined; } @@ -73265,11 +73540,11 @@ var ts; } var restIndex = signature.parameters.length - 1; return signatureHasRestParameter(signature) && argIndex >= restIndex ? - getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) : getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 210 /* TaggedTemplateExpression */) { + if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -73278,13 +73553,13 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 63 /* EqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -73293,8 +73568,8 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: return undefined; @@ -73315,6 +73590,14 @@ var ts; var lhsType = getTypeOfExpression(e.expression); return ts.isPrivateIdentifier(e.name) ? tryGetPrivateIdentifierPropertyOfType(lhsType, e.name) : getPropertyOfType(lhsType, e.name.escapedText); } + if (ts.isElementAccessExpression(e)) { + var propType = checkExpressionCached(e.argumentExpression); + if (!isTypeUsableAsPropertyName(propType)) { + return undefined; + } + var lhsType = getTypeOfExpression(e.expression); + return getPropertyOfType(lhsType, getPropertyNameFromType(propType)); + } return undefined; function tryGetPrivateIdentifierPropertyOfType(type, id) { var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(id.escapedText, id); @@ -73327,8 +73610,8 @@ var ts; var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { - case 0 /* None */: - case 4 /* ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var lhsSymbol = getSymbolForExpression(binaryExpression.left); var decl = lhsSymbol && lhsSymbol.valueDeclaration; // Unannotated, uninitialized property declarations have a type implied by their usage in the constructor. @@ -73338,11 +73621,11 @@ var ts; return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || (ts.isPropertyDeclaration(decl) ? decl.initializer && getTypeOfExpression(binaryExpression.left) : undefined); } - if (kind === 0 /* None */) { + if (kind === 0 /* AssignmentDeclarationKind.None */) { return getTypeOfExpression(binaryExpression.left); } return getContextualTypeForThisPropertyAssignment(binaryExpression); - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { return getContextualTypeForThisPropertyAssignment(binaryExpression); } @@ -73363,7 +73646,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* SymbolFlags.Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated_1) { @@ -73377,18 +73660,18 @@ var ts; } return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left); } - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; // falls through - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration); var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration); return annotated ? getTypeFromTypeNode(annotated) : undefined; - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); @@ -73396,14 +73679,14 @@ var ts; } function isPossiblyAliasedThisProperty(declaration, kind) { if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); } - if (kind === 4 /* ThisProperty */) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */) { return true; } - if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) { + if (!ts.isInJSFile(declaration) || kind !== 5 /* AssignmentDeclarationKind.Property */ || !ts.isIdentifier(declaration.left.expression)) { return false; } var name = declaration.left.expression.escapedText; - var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); + var symbol = resolveName(declaration.left, name, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } function getContextualTypeForThisPropertyAssignment(binaryExpression) { @@ -73427,11 +73710,11 @@ var ts; return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined; } function isCircularMappedProperty(symbol) { - return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0); + return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0); } function getTypeOfPropertyOfContextualType(type, name, nameType) { return mapType(type, function (t) { - if (t.flags & 2097152 /* Intersection */) { + if (t.flags & 2097152 /* TypeFlags.Intersection */) { var intersection = t; var newTypes = ts.mapDefined(intersection.types, getTypeOfConcretePropertyOfContextualType); if (newTypes.length > 0) { @@ -73459,7 +73742,7 @@ var ts; } return undefined; } - if (t.flags & 3670016 /* StructuredType */) { + if (t.flags & 3670016 /* TypeFlags.StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop); @@ -73475,7 +73758,7 @@ var ts; } function getTypeOfApplicableIndexInfoOfContextualType(t) { var _a; - if (!(t.flags & 3670016 /* StructuredType */)) { + if (!(t.flags & 3670016 /* TypeFlags.StructuredType */)) { return undefined; } return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type; @@ -73486,7 +73769,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -73494,7 +73777,7 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; - var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags); if (propertyAssignmentType) { return propertyAssignmentType; } @@ -73521,7 +73804,7 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, + || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* IterationUse.Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, /*noReductions*/ true)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -73529,8 +73812,8 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined; } - function getContextualTypeForChildJsxExpression(node, child) { - var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName); + function getContextualTypeForChildJsxExpression(node, child, contextFlags) { + var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags); // JSX expression is in children of JSX Element, we will look for an "children" attribute (we get the name from JSX.ElementAttributesProperty) var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) { @@ -73548,27 +73831,27 @@ var ts; } }, /*noReductions*/ true)); } - function getContextualTypeForJsxExpression(node) { + function getContextualTypeForJsxExpression(node, contextFlags) { var exprParent = node.parent; return ts.isJsxAttributeLike(exprParent) - ? getContextualType(node) + ? getContextualType(node, contextFlags) : ts.isJsxElement(exprParent) - ? getContextualTypeForChildJsxExpression(exprParent, node) + ? getContextualTypeForChildJsxExpression(exprParent, node, contextFlags) : undefined; } - function getContextualTypeForJsxAttribute(attribute) { + function getContextualTypeForJsxAttribute(attribute, contextFlags) { // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type // which is a type of the parameter of the signature we are trying out. // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName if (ts.isJsxAttribute(attribute)) { - var attributesType = getApparentTypeOfContextualType(attribute.parent); + var attributesType = getApparentTypeOfContextualType(attribute.parent, contextFlags); if (!attributesType || isTypeAny(attributesType)) { return undefined; } return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { - return getContextualType(attribute.parent); + return getContextualType(attribute.parent, contextFlags); } } // Return true if the given expression is possibly a discriminant value. We limit the kinds of @@ -73576,29 +73859,29 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 79 /* Identifier */: - case 153 /* UndefinedKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 153 /* SyntaxKind.UndefinedKeyword */: return true; - case 206 /* PropertyAccessExpression */: - case 212 /* ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* SyntaxKind.JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -73607,21 +73890,21 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* ContextFlags.NoConstraints */ && instantiatedType.flags & 8650752 /* TypeFlags.TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : - apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + return apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing // return type inferences is available, instantiate those types using that mapper. function instantiateContextualType(contextualType, node, contextFlags) { - if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) { + if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) { var inferenceContext = getInferenceContext(node); // If no inferences have been made, nothing is gained from instantiating as type parameters // would just be replaced with their defaults similar to the apparent type. - if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { + if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { // For contextual signatures we incorporate all inferences made so far, e.g. from return // types as well as arguments to the left in a function call. return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); @@ -73632,7 +73915,7 @@ var ts; // the 'boolean' type from the contextual type such that contextually typed boolean // literals actually end up widening to 'boolean' (see #48363). var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); - return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? + return type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : type; } @@ -73643,13 +73926,13 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { return instantiateType(type, mapper); } - if (type.flags & 1048576 /* Union */) { - return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* None */); + if (type.flags & 1048576 /* TypeFlags.Union */) { + return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* UnionReduction.None */); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); })); } return type; @@ -73672,7 +73955,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -73681,65 +73964,65 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 214 /* ArrowFunction */: - case 247 /* ReturnStatement */: - return getContextualTypeForReturnExpression(node); - case 224 /* YieldExpression */: - return getContextualTypeForYieldOperand(parent); - case 218 /* AwaitExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 247 /* SyntaxKind.ReturnStatement */: + return getContextualTypeForReturnExpression(node, contextFlags); + case 224 /* SyntaxKind.YieldExpression */: + return getContextualTypeForYieldOperand(parent, contextFlags); + case 218 /* SyntaxKind.AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return getContextualTypeForArgument(parent, node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 204 /* ArrayLiteralExpression */: { + case 204 /* SyntaxKind.ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 233 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 223 /* TemplateExpression */); + case 233 /* SyntaxKind.TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 223 /* SyntaxKind.TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return !tag ? getContextualType(parent, contextFlags) : ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(tag.typeExpression.type); } - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return getContextualType(parent, contextFlags); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return tryGetTypeFromEffectiveTypeNode(parent); - case 288 /* JsxExpression */: - return getContextualTypeForJsxExpression(parent); - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - return getContextualTypeForJsxAttribute(parent); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + return getContextualTypeForJsxExpression(parent, contextFlags); + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + return getContextualTypeForJsxAttribute(parent, contextFlags); + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; function tryFindWhenConstTypeReference(node) { - return getContextualType(node); + return getContextualType(node, contextFlags); } } function getInferenceContext(node) { @@ -73747,7 +74030,7 @@ var ts; return ancestor && ancestor.inferenceContext; } function getContextualJsxElementAttributesType(node, contextFlags) { - if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) { + if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* ContextFlags.Completions */) { // Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit // _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type // (as below) instead! @@ -73756,7 +74039,7 @@ var ts; return getContextualTypeForArgumentAtIndex(node, 0); } function getEffectiveFirstArgumentForJsxSignature(signature, node) { - return getJsxReferenceKind(node) !== 0 /* Component */ + return getJsxReferenceKind(node) !== 0 /* JsxReferenceKind.Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } @@ -73801,7 +74084,7 @@ var ts; return getOrCreateTypeFromSignature(fakeSignature); } var tagType = checkExpressionCached(context.tagName); - if (tagType.flags & 128 /* StringLiteral */) { + if (tagType.flags & 128 /* TypeFlags.StringLiteral */) { var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); if (!result) { return errorType; @@ -73816,7 +74099,7 @@ var ts; if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); - if (managedSym.flags & 524288 /* TypeAlias */) { + if (managedSym.flags & 524288 /* SymbolFlags.TypeAlias */) { var params = getSymbolLinks(managedSym).typeParameters; if (ts.length(params) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); @@ -73917,12 +74200,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -73944,18 +74227,18 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 2097152 /* Intersection */; - result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 2097152 /* TypeFlags.Intersection */; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. function getContextualCallSignature(type, node) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } @@ -73985,16 +74268,16 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */); if (!type) { return undefined; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -74023,38 +74306,38 @@ var ts; } } function checkSpreadExpression(node, checkMode) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); + return checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, arrayOrIterableType, undefinedType, node.expression); } function checkSyntheticExpression(node) { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 203 /* BindingElement */ && !!node.initializer) || - (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); + return (node.kind === 203 /* SyntaxKind.BindingElement */ && !!node.initializer) || + (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; var elementCount = elements.length; var elementTypes = []; var elementFlags = []; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined); var inDestructuringPattern = ts.isAssignmentTarget(node); var inConstContext = isConstContext(node); var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 225 /* SpreadElement */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var spreadType = checkExpression(e.expression, checkMode, forceTuple); if (isArrayLikeType(spreadType)) { elementTypes.push(spreadType); - elementFlags.push(8 /* Variadic */); + elementFlags.push(8 /* ElementFlags.Variadic */); } else if (inDestructuringPattern) { // Given the following situation: @@ -74070,27 +74353,27 @@ var ts; // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. var restElementType = getIndexTypeOfType(spreadType, numberType) || - getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || + getIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || unknownType; elementTypes.push(restElementType); - elementFlags.push(4 /* Rest */); + elementFlags.push(4 /* ElementFlags.Rest */); } else { - elementTypes.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, e.expression)); - elementFlags.push(4 /* Rest */); + elementTypes.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, e.expression)); + elementFlags.push(4 /* ElementFlags.Rest */); } } - else if (exactOptionalPropertyTypes && e.kind === 227 /* OmittedExpression */) { + else if (exactOptionalPropertyTypes && e.kind === 227 /* SyntaxKind.OmittedExpression */) { hasOmittedExpression = true; elementTypes.push(missingType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); - elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); - if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) { + elementFlags.push(hasOmittedExpression ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */); + if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && isContextSensitive(e)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context addIntraExpressionInferenceSite(inferenceContext, e, type); @@ -74104,28 +74387,28 @@ var ts; return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? - getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* Subtype */) : + getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* UnionReduction.Subtype */) : strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext)); } function createArrayLiteralType(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */)) { return type; } var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 16384 /* ArrayLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 16384 /* ObjectFlags.ArrayLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return isNumericComputedName(name); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isNumericLiteralName(name.escapedText); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return ts.isNumericLiteralName(name.text); default: return false; @@ -74134,14 +74417,14 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* TypeFlags.NumberLike */); } function checkComputedPropertyName(node) { var links = getNodeLinks(node.expression); if (!links.resolvedType) { if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent)) - && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */ - && node.parent.kind !== 172 /* GetAccessor */ && node.parent.kind !== 173 /* SetAccessor */) { + && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ + && node.parent.kind !== 172 /* SyntaxKind.GetAccessor */ && node.parent.kind !== 173 /* SyntaxKind.SetAccessor */) { return links.resolvedType = errorType; } links.resolvedType = checkExpression(node.expression); @@ -74152,17 +74435,17 @@ var ts; var enclosingIterationStatement = getEnclosingIterationStatement(container); if (enclosingIterationStatement) { // The computed field name will use a block scoped binding which can be unique for each iteration of the loop. - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; // The generated variable which stores the computed field name must be block-scoped. - getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; // The generated variable which stores the class must be block-scoped. - getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node.parent.parent).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } } // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 98304 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* TypeFlags.Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -74178,7 +74461,7 @@ var ts; var _a; var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) && - isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */)); + isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* TypeFlags.ESSymbol */)); } function getObjectLiteralIndexInfo(node, offset, properties, keyType) { var propTypes = []; @@ -74190,11 +74473,11 @@ var ts; propTypes.push(getTypeOfSymbol(properties[i])); } } - var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType; + var unionType = propTypes.length ? getUnionType(propTypes, 2 /* UnionReduction.Subtype */) : undefinedType; return createIndexInfo(keyType, unionType, isConstContext(node)); } function getImmediateAliasedSymbol(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); @@ -74212,11 +74495,11 @@ var ts; var propertiesTable = ts.createSymbolTable(); var propertiesArray = []; var spread = emptyObjectType; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* SyntaxKind.ObjectLiteralExpression */); var inConstContext = isConstContext(node); - var checkFlags = inConstContext ? 8 /* Readonly */ : 0; + var checkFlags = inConstContext ? 8 /* CheckFlags.Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -74238,16 +74521,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 296 /* PropertyAssignment */ || - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 296 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -74259,29 +74542,29 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 458752 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 458752 /* ObjectFlags.PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? - createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : - createSymbol(4 /* Property */ | member.flags, member.escapedName, checkFlags); + createSymbol(4 /* SymbolFlags.Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* CheckFlags.Late */) : + createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName, checkFlags); if (nameType) { prop.nameType = nameType; } if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 296 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 297 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 16777216 /* Optional */; + prop.flags |= 16777216 /* SymbolFlags.Optional */; } } - else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.escapedName); if (impliedProp) { - prop.flags |= impliedProp.flags & 16777216 /* Optional */; + prop.flags |= impliedProp.flags & 16777216 /* SymbolFlags.Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -74296,17 +74579,17 @@ var ts; prop.target = member; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); - if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && - (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) { + if (contextualType && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && + (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || memberDecl.kind === 169 /* SyntaxKind.MethodDeclaration */) && isContextSensitive(memberDecl)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context - var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl; + var inferenceNode = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? memberDecl.initializer : memberDecl; addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type); } } - else if (memberDecl.kind === 298 /* SpreadAssignment */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + else if (memberDecl.kind === 298 /* SyntaxKind.SpreadAssignment */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(memberDecl, 2 /* ExternalEmitHelpers.Assign */); } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -74340,10 +74623,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 172 /* GetAccessor */ || memberDecl.kind === 173 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 172 /* SyntaxKind.GetAccessor */ || memberDecl.kind === 173 /* SyntaxKind.SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -74368,11 +74651,11 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 298 /* SyntaxKind.SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { - if (!(prop.flags & 16777216 /* Optional */)) { + if (!(prop.flags & 16777216 /* SymbolFlags.Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } propertiesTable.set(prop.escapedName, prop); @@ -74404,12 +74687,12 @@ var ts; if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType)); var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 4096 /* JSLiteral */; + result.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; } if (patternWithComputedProperties) { - result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; } if (inDestructuringPattern) { result.pattern = node; @@ -74419,8 +74702,8 @@ var ts; } function isValidSpreadType(type) { var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType)); - return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || - t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); + return !!(t.flags & (1 /* TypeFlags.Any */ | 67108864 /* TypeFlags.NonPrimitive */ | 524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + t.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); @@ -74466,7 +74749,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* SyntaxKind.Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -74490,15 +74773,15 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 2048 /* JsxAttributes */; + var objectFlags = 2048 /* ObjectFlags.JsxAttributes */; var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { var attributeDecl = _a[_i]; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); - objectFlags |= ts.getObjectFlags(exprType) & 458752 /* PropagatingFlags */; - var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); + objectFlags |= ts.getObjectFlags(exprType) & 458752 /* ObjectFlags.PropagatingFlags */; + var attributeSymbol = createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; if (member.valueDeclaration) { @@ -74513,7 +74796,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 287 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 287 /* SyntaxKind.JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -74540,7 +74823,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 278 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 278 /* SyntaxKind.JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -74551,10 +74834,10 @@ var ts; if (explicitlySpecifyChildrenAttribute) { error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName)); } - var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); + var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process - var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); + var childrenPropSymbol = createSymbol(4 /* SymbolFlags.Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); @@ -74582,7 +74865,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return result; } } @@ -74592,12 +74875,12 @@ var ts; var child = _a[_i]; // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that // because then type of children property will have constituent of string type. - if (child.kind === 11 /* JsxText */) { + if (child.kind === 11 /* SyntaxKind.JsxText */) { if (!child.containsOnlyTriviaWhiteSpaces) { childrenTypes.push(stringType); } } - else if (child.kind === 288 /* JsxExpression */ && !child.expression) { + else if (child.kind === 288 /* SyntaxKind.JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -74609,7 +74892,7 @@ var ts; function checkSpreadPropOverrides(type, props, spread) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var right = _a[_i]; - if (!(right.flags & 16777216 /* Optional */)) { + if (!(right.flags & 16777216 /* SymbolFlags.Optional */)) { var left = props.get(right.escapedName); if (left) { var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); @@ -74629,7 +74912,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* SymbolFlags.Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -74648,13 +74931,13 @@ var ts; return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; + links.jsxFlags |= 1 /* JsxFlags.IntrinsicNamedElement */; return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + links.jsxFlags |= 2 /* JsxFlags.IntrinsicIndexedElement */; return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found @@ -74703,10 +74986,10 @@ var ts; var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location); if (!resolvedNamespace || resolvedNamespace === unknownSymbol) { var namespaceName = getJsxNamespace(location); - resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + resolvedNamespace = resolveName(location, namespaceName, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); } if (resolvedNamespace) { - var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */)); + var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* SymbolFlags.Namespace */)); if (candidate && candidate !== unknownSymbol) { if (links) { links.jsxNamespace = candidate; @@ -74719,7 +75002,7 @@ var ts; } } // JSX global fallback - var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined)); + var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined)); if (s === unknownSymbol) { return undefined; // TODO: GH#18217 } @@ -74734,7 +75017,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* SymbolFlags.Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -74758,7 +75041,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* SymbolFlags.Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -74772,10 +75055,10 @@ var ts; return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } function getUninstantiatedJsxSignaturesOfType(elementType, caller) { - if (elementType.flags & 4 /* String */) { + if (elementType.flags & 4 /* TypeFlags.String */) { return [anySignature]; } - else if (elementType.flags & 128 /* StringLiteral */) { + else if (elementType.flags & 128 /* TypeFlags.StringLiteral */) { var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller); if (!intrinsicType) { error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements); @@ -74788,12 +75071,12 @@ var ts; } var apparentElemType = getApparentType(elementType); // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(apparentElemType, 1 /* Construct */); + var signatures = getSignaturesOfType(apparentElemType, 1 /* SignatureKind.Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures - signatures = getSignaturesOfType(apparentElemType, 0 /* Call */); + signatures = getSignaturesOfType(apparentElemType, 0 /* SignatureKind.Call */); } - if (signatures.length === 0 && apparentElemType.flags & 1048576 /* Union */) { + if (signatures.length === 0 && apparentElemType.flags & 1048576 /* TypeFlags.Union */) { // If each member has some combination of new/call signatures; make a union signature list for those signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); })); } @@ -74821,13 +75104,13 @@ var ts; return anyType; } function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { - if (refKind === 1 /* Function */) { + if (refKind === 1 /* JsxReferenceKind.Function */) { var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); if (sfcReturnConstraint) { checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } - else if (refKind === 0 /* Component */) { + else if (refKind === 0 /* JsxReferenceKind.Component */) { var classConstraint = getJsxElementClassTypeAt(openingLikeElement); if (classConstraint) { // Issue an error if this return type isn't assignable to JSX.ElementClass, failing that @@ -74858,10 +75141,10 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + if (links.jsxFlags & 1 /* JsxFlags.IntrinsicNamedElement */) { return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + else if (links.jsxFlags & 2 /* JsxFlags.IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType; } @@ -74895,7 +75178,7 @@ var ts; } function checkJsxPreconditions(errorNode) { // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + if ((compilerOptions.jsx || 0 /* JsxEmit.None */) === 0 /* JsxEmit.None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } if (getJsxElementTypeAt(errorNode) === undefined) { @@ -74913,20 +75196,20 @@ var ts; if (!getJsxNamespaceContainerForImplicitImport(node)) { // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; + var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* JsxEmit.React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var jsxFactoryNamespace = getJsxNamespace(node); var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; // allow null as jsxFragmentFactory var jsxFactorySym = void 0; if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); + jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); } if (jsxFactorySym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not jsxFactory as there wont be error being emitted - jsxFactorySym.isReferenced = 67108863 /* All */; + jsxFactorySym.isReferenced = 67108863 /* SymbolFlags.All */; // If react/jsxFactory symbol is alias, mark it as refereced - if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { + if (jsxFactorySym.flags & 2097152 /* SymbolFlags.Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { markAliasSymbolAsReferenced(jsxFactorySym); } } @@ -74935,7 +75218,7 @@ var ts; var file = ts.getSourceFileOfNode(node); var localJsxNamespace = getLocalJsxNamespace(file); if (localJsxNamespace) { - resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); + resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); } } } @@ -74960,7 +75243,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 524288 /* Object */) { + if (targetType.flags & 524288 /* TypeFlags.Object */) { // For backwards compatibility a symbol-named property is satisfied by a string index signature. This // is incorrect and inconsistent with element access expressions, where it is an error, so eventually // we should remove this exception. @@ -74972,7 +75255,7 @@ var ts; return true; } } - else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { + else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -74983,10 +75266,10 @@ var ts; return false; } function isExcessPropertyCheckTarget(type) { - return !!(type.flags & 524288 /* Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || - type.flags & 67108864 /* NonPrimitive */ || - type.flags & 1048576 /* Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); + return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) || + type.flags & 67108864 /* TypeFlags.NonPrimitive */ || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); } function checkJsxExpression(node, checkMode) { checkGrammarJsxExpression(node); @@ -75009,13 +75292,13 @@ var ts; * Note that this is not tracked well within the compiler, so the answer may be incorrect. */ function isPrototypeProperty(symbol) { - if (symbol.flags & 8192 /* Method */ || ts.getCheckFlags(symbol) & 4 /* SyntheticMethod */) { + if (symbol.flags & 8192 /* SymbolFlags.Method */ || ts.getCheckFlags(symbol) & 4 /* CheckFlags.SyntheticMethod */) { return true; } if (ts.isInJSFile(symbol.valueDeclaration)) { var parent = symbol.valueDeclaration.parent; return parent && ts.isBinaryExpression(parent) && - ts.getAssignmentDeclarationKind(parent) === 3 /* PrototypeProperty */; + ts.getAssignmentDeclarationKind(parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } } /** @@ -75029,9 +75312,9 @@ var ts; function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } var errorNode = !reportError ? undefined : - node.kind === 161 /* QualifiedName */ ? node.right : - node.kind === 200 /* ImportType */ ? node : - node.kind === 203 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + node.kind === 161 /* SyntaxKind.QualifiedName */ ? node.right : + node.kind === 200 /* SyntaxKind.ImportType */ ? node : + node.kind === 203 /* SyntaxKind.BindingElement */ && node.propertyName ? node.propertyName : node.name; return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode); } /** @@ -75054,7 +75337,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { if (errorNode) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -75062,7 +75345,7 @@ var ts; return false; } } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -75074,7 +75357,7 @@ var ts; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + if ((flags & 128 /* ModifierFlags.Abstract */) && symbolHasNonMethodDeclaration(prop) && (ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { @@ -75085,12 +75368,12 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { return true; } // Property is known to be private or protected at this point // Private property is accessible if the property is within the declaring class - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -75117,7 +75400,7 @@ var ts; // static member access is disallowed enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 32 /* ModifierFlags.Static */ || !enclosingClass) { if (errorNode) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } @@ -75125,10 +75408,10 @@ var ts; } } // No further restrictions for static properties - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return true; } - if (containingType.flags & 262144 /* TypeParameter */) { + if (containingType.flags & 262144 /* TypeFlags.TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -75143,10 +75426,10 @@ var ts; function getEnclosingClassFromThisParameter(node) { var thisParameter = getThisParameterFromNodeContext(node); var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type); - if (thisType && thisType.flags & 262144 /* TypeParameter */) { + if (thisType && thisType.flags & 262144 /* TypeFlags.TypeParameter */) { thisType = getConstraintOfTypeParameter(thisType); } - if (thisType && ts.getObjectFlags(thisType) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (thisType && ts.getObjectFlags(thisType) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { return getTargetType(thisType); } return undefined; @@ -75156,39 +75439,39 @@ var ts; return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined; } function symbolHasNonMethodDeclaration(symbol) { - return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); + return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* SymbolFlags.Method */); }); } function checkNonNullExpression(node) { return checkNonNullType(checkExpression(node), node); } function isNullableType(type) { - return !!(getTypeFacts(type) & 50331648 /* IsUndefinedOrNull */); + return !!(getTypeFacts(type) & 50331648 /* TypeFacts.IsUndefinedOrNull */); } function getNonNullableTypeIfNeeded(type) { return isNullableType(type) ? getNonNullableType(type) : type; } function reportObjectPossiblyNullOrUndefinedError(node, facts) { - error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? + error(node, facts & 16777216 /* TypeFacts.IsUndefined */ ? facts & 33554432 /* TypeFacts.IsNull */ ? ts.Diagnostics.Object_is_possibly_null_or_undefined : ts.Diagnostics.Object_is_possibly_undefined : ts.Diagnostics.Object_is_possibly_null); } function reportCannotInvokePossiblyNullOrUndefinedError(node, facts) { - error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? + error(node, facts & 16777216 /* TypeFacts.IsUndefined */ ? facts & 33554432 /* TypeFacts.IsNull */ ? ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); } function checkNonNullTypeWithReporter(type, node, reportError) { - if (strictNullChecks && type.flags & 2 /* Unknown */) { + if (strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } var facts = getTypeFacts(type); - if (facts & 50331648 /* IsUndefinedOrNull */) { + if (facts & 50331648 /* TypeFacts.IsUndefinedOrNull */) { reportError(node, facts); var t = getNonNullableType(type); - return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; + return t.flags & (98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */) ? errorType : t; } return type; } @@ -75197,13 +75480,13 @@ var ts; } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); - if (nonNullType.flags & 16384 /* Void */) { + if (nonNullType.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.Object_is_possibly_undefined); } return nonNullType; } function checkPropertyAccessExpression(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } function checkPropertyAccessChain(node, checkMode) { @@ -75216,7 +75499,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 212 /* ParenthesizedExpression */) { + while (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -75240,7 +75523,7 @@ var ts; if (!ts.isExpressionNode(privId)) { return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression); } - var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* InKeyword */; + var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) { return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId)); } @@ -75312,16 +75595,16 @@ var ts; function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); - var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); + var apparentType = getApparentType(assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { - if (languageVersion < 99 /* ESNext */) { - if (assignmentKind !== 0 /* None */) { - checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + if (assignmentKind !== 0 /* AssignmentKind.None */) { + checkExternalEmitHelpers(node, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } - if (assignmentKind !== 1 /* Definite */) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + if (assignmentKind !== 1 /* AssignmentKind.Definite */) { + checkExternalEmitHelpers(node, 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */); } } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); @@ -75343,8 +75626,8 @@ var ts; return errorType; } else { - var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* AssignmentKind.Definite */) { error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); } } @@ -75356,7 +75639,7 @@ var ts; } return isErrorType(apparentType) ? errorType : apparentType; } - prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === 161 /* QualifiedName */); + prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === 161 /* SyntaxKind.QualifiedName */); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined @@ -75366,13 +75649,13 @@ var ts; // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`. if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || - !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && node.parent.kind === 299 /* EnumMember */)) || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* SymbolFlags.EnumMember */ && node.parent.kind === 299 /* SyntaxKind.EnumMember */)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; if (!prop) { - var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? + var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined; if (!(indexInfo && indexInfo.type)) { var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true); @@ -75380,7 +75663,7 @@ var ts; return anyType; } if (leftType.symbol === globalThisSymbol) { - if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */)) { + if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* SymbolFlags.BlockScoped */)) { error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); } else if (noImplicitAny) { @@ -75400,7 +75683,7 @@ var ts; if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) { error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText)); } - if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) { + if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* NodeFlags.Deprecated */) { addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText); } } @@ -75412,7 +75695,7 @@ var ts; markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; var writing = ts.isWriteAccess(node); - checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 106 /* SyntaxKind.SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; @@ -75431,11 +75714,11 @@ var ts; function isUncheckedJSSuggestion(node, suggestion, excludeClasses) { var file = ts.getSourceFileOfNode(node); if (file) { - if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) { + if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */)) { var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode); return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) - && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */) - && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */); + && !(excludeClasses && suggestion && suggestion.flags & 32 /* SymbolFlags.Class */) + && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */); } } return false; @@ -75445,12 +75728,12 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (assignmentKind === 1 /* Definite */) { - return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + if (assignmentKind === 1 /* AssignmentKind.Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* SymbolFlags.Optional */)); } if (prop && - !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) - && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + !(prop.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */ | 98304 /* SymbolFlags.Accessor */)) + && !(prop.flags & 8192 /* SymbolFlags.Method */ && propType.flags & 1048576 /* TypeFlags.Union */) && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } @@ -75463,12 +75746,12 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isPropertyWithoutInitializer(declaration)) { if (!ts.isStatic(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) { + if (flowContainer.kind === 171 /* SyntaxKind.Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { assumeUninitialized = true; } } @@ -75499,13 +75782,13 @@ var ts; && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* Static */) + && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* ModifierFlags.Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 257 /* ClassDeclaration */ && - node.parent.kind !== 178 /* TypeReference */ && - !(valueDeclaration.flags & 16777216 /* Ambient */) && + else if (valueDeclaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && + node.parent.kind !== 178 /* SyntaxKind.TypeReference */ && + !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -75516,25 +75799,25 @@ var ts; function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 296 /* PropertyAssignment */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 298 /* SpreadAssignment */: - case 162 /* ComputedPropertyName */: - case 233 /* TemplateSpan */: - case 288 /* JsxExpression */: - case 285 /* JsxAttribute */: - case 286 /* JsxAttributes */: - case 287 /* JsxSpreadAttribute */: - case 280 /* JsxOpeningElement */: - case 228 /* ExpressionWithTypeArguments */: - case 291 /* HeritageClause */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 298 /* SyntaxKind.SpreadAssignment */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 233 /* SyntaxKind.TemplateSpan */: + case 288 /* SyntaxKind.JsxExpression */: + case 285 /* SyntaxKind.JsxAttribute */: + case 286 /* SyntaxKind.JsxAttributes */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 291 /* SyntaxKind.HeritageClause */: return false; - case 214 /* ArrowFunction */: - case 238 /* ExpressionStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -75546,7 +75829,7 @@ var ts; * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. */ function isPropertyDeclaredInAncestorClass(prop) { - if (!(prop.parent.flags & 32 /* Class */)) { + if (!(prop.parent.flags & 32 /* SymbolFlags.Class */)) { return false; } var classType = getTypeOfSymbol(prop.parent); @@ -75571,7 +75854,7 @@ var ts; function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { var errorInfo; var relatedInfo; - if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { + if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* TypeFlags.Union */ && !(containingType.flags & 131068 /* TypeFlags.Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) { @@ -75659,7 +75942,7 @@ var ts; } } function getSuggestedSymbolForNonexistentClassMember(name, baseType) { - return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */); + return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* SymbolFlags.ClassMember */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); @@ -75670,7 +75953,7 @@ var ts; } name = ts.idText(name); } - return getSpellingSuggestionForName(name, props, 111551 /* Value */); + return getSpellingSuggestionForName(name, props, 111551 /* SymbolFlags.Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -75678,7 +75961,7 @@ var ts; var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; }) : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; }) : undefined; - return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* Value */); + return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* SymbolFlags.Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -75697,7 +75980,7 @@ var ts; var candidates; if (symbols === globals) { var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1))) - ? createSymbol(524288 /* TypeAlias */, s) + ? createSymbol(524288 /* SymbolFlags.TypeAlias */, s) : undefined; }); candidates = primitives.concat(ts.arrayFrom(symbols.values())); } @@ -75713,7 +75996,7 @@ var ts; return symbolResult && ts.symbolName(symbolResult); } function getSuggestedSymbolForNonexistentModule(name, targetModule) { - return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */); + return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* SymbolFlags.ModuleMember */); } function getSuggestionForNonexistentExport(name, targetModule) { var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule); @@ -75744,7 +76027,7 @@ var ts; return suggestion; } function getSuggestedTypeForNonexistentStringLiteralType(source, target) { - var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); }); + var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); }); return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; }); } /** @@ -75772,7 +76055,7 @@ var ts; if (candidate.flags & meaning) { return candidateName; } - if (candidate.flags & 2097152 /* Alias */) { + if (candidate.flags & 2097152 /* SymbolFlags.Alias */) { var alias = tryResolveAlias(candidate); if (alias && alias.flags & meaning) { return candidateName; @@ -75782,16 +76065,16 @@ var ts; } } function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { - var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; + var valueDeclaration = prop && (prop.flags & 106500 /* SymbolFlags.ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } - var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); + var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* ModifierFlags.Private */); var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } - if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { + if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SymbolFlags.SetAccessor */)) { return; } if (isSelfTypeAccess) { @@ -75801,19 +76084,19 @@ var ts; return; } } - (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; + (ts.getCheckFlags(prop) & 1 /* CheckFlags.Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* SymbolFlags.All */; } function isSelfTypeAccess(name, parent) { - return name.kind === 108 /* ThisKeyword */ + return name.kind === 108 /* SyntaxKind.ThisKeyword */ || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 161 /* SyntaxKind.QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } @@ -75828,7 +76111,7 @@ var ts; * @param property the accessed property's symbol. */ function isValidPropertyAccessForCompletions(node, type, property) { - return isPropertyAccessible(node, node.kind === 206 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, + return isPropertyAccessible(node, node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, /* isWrite */ false, type, property); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } @@ -75868,13 +76151,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 79 /* Identifier */) { + else if (initializer.kind === 79 /* SyntaxKind.Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -75891,13 +76174,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 79 /* Identifier */) { + if (e.kind === 79 /* SyntaxKind.Identifier */) { var symbol = getResolvedSymbol(e); - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 243 /* ForInStatement */ && + if (node.kind === 243 /* SyntaxKind.ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -75911,7 +76194,7 @@ var ts; return false; } function checkIndexedAccess(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkElementAccessChain(node, checkMode) : checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } function checkElementAccessChain(node, checkMode) { @@ -75920,7 +76203,7 @@ var ts; return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } function checkElementAccessExpression(node, exprType, checkMode) { - var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; + var objectType = ts.getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); if (isErrorType(objectType) || objectType === silentNeverType) { @@ -75932,8 +76215,8 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : - 32 /* ExpressionPosition */; + 4 /* AccessFlags.Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* AccessFlags.NoIndexSignatures */ : 0) : + 32 /* AccessFlags.ExpressionPosition */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -75946,13 +76229,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 165 /* Decorator */) { + else if (node.kind !== 165 /* SyntaxKind.Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -76016,16 +76299,16 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 225 /* SpreadElement */ || arg.kind === 232 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } function acceptsVoid(t) { - return !!(t.flags & 16384 /* Void */); + return !!(t.flags & 16384 /* TypeFlags.Void */); } function acceptsVoidUndefinedUnknownOrAny(t) { - return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */)); + return !!(t.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 2 /* TypeFlags.Unknown */ | 1 /* TypeFlags.Any */)); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -76033,9 +76316,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 223 /* TemplateExpression */) { + if (node.template.kind === 223 /* SyntaxKind.TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -76046,11 +76329,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = node.template; - ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 165 /* Decorator */) { + else if (node.kind === 165 /* SyntaxKind.Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -76064,7 +76347,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 209 /* NewExpression */); + ts.Debug.assert(node.kind === 209 /* SyntaxKind.NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -76088,7 +76371,7 @@ var ts; } for (var i = argCount; i < effectiveMinimumArguments; i++) { var type = getTypeAtPosition(signature, i); - if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* TypeFlags.Never */) { return false; } } @@ -76104,20 +76387,20 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false); } function getSingleCallOrConstructSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false) || - getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false) || + getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ false); } function getSingleSignature(type, kind, allowMembers) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) { - if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + if (kind === 0 /* SignatureKind.Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { return resolved.callSignatures[0]; } - if (kind === 1 /* Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + if (kind === 1 /* SignatureKind.Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { return resolved.constructSignatures[0]; } } @@ -76126,12 +76409,12 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) { - var context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes); + var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes); // We clone the inferenceContext to avoid fixing. For example, when the source signature is (x: T) => T[] and // the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any') // for T but leave it possible to later infer '[any]' back to A. var restType = getEffectiveRestType(contextualSignature); - var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); + var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; applyToParameterTypes(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -76139,7 +76422,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 128 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -76167,14 +76450,14 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 165 /* Decorator */) { + if (node.kind !== 165 /* SyntaxKind.Decorator */) { var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }); - var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */); + var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */); if (contextualType) { var inferenceTargetType = getReturnTypeOfSignature(signature); if (couldContainTypeVariables(inferenceTargetType)) { var outerContext = getInferenceContext(node); - var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType; + var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) !== contextualType; // A return type inference from a binding pattern can be used in instantiating the contextual // type of an argument later in inference, but cannot stand on its own as the final return type. // It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`, @@ -76189,7 +76472,7 @@ var ts; // We clone the inference context to avoid disturbing a resolution in progress for an // outer call expression. Effectively we just want a snapshot of whatever has been // inferred for any outer call expression so far. - var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */)); + var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* InferenceFlags.NoDefault */)); var instantiatedType = instantiateType(contextualType, outerMapper); // If the contextual type is a generic function type with a single call signature, we // instantiate the type with its own type parameters and type arguments. This ensures that @@ -76203,7 +76486,7 @@ var ts; getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */); } // Create a type mapper for instantiating generic contextual types using the inferences made // from the return type. We need a separate inference pass here because (a) instantiation of @@ -76218,7 +76501,7 @@ var ts; } var restType = getNonArrayRestType(signature); var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; }); if (info) { info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined; @@ -76231,7 +76514,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */ && !(checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { var paramType = getTypeAtPosition(signature, i); if (couldContainTypeVariables(paramType)) { var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); @@ -76246,10 +76529,10 @@ var ts; return getInferredTypes(context); } function getMutableArrayOrTupleType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : - type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getMutableArrayOrTupleType) : + type.flags & 1 /* TypeFlags.Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, /*readonly*/ false, type.target.labeledElementDeclarations) : - createTupleType([type], [8 /* Variadic */]); + createTupleType([type], [8 /* ElementFlags.Variadic */]); } function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) { if (index >= argCount - 1) { @@ -76257,7 +76540,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 232 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -76267,24 +76550,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 232 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 225 /* SpreadElement */ ? arg.expression : arg)); - flags.push(4 /* Rest */); + types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg)); + flags.push(4 /* ElementFlags.Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */); + var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); - flags.push(1 /* Required */); + flags.push(1 /* ElementFlags.Required */); } - if (arg.kind === 232 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -76314,16 +76597,16 @@ var ts; } function getJsxReferenceKind(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } var tagType = getApparentType(checkExpression(node.tagName)); - if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { - return 0 /* Component */; + if (ts.length(getSignaturesOfType(tagType, 1 /* SignatureKind.Construct */))) { + return 0 /* JsxReferenceKind.Component */; } - if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { - return 1 /* Function */; + if (ts.length(getSignaturesOfType(tagType, 0 /* SignatureKind.Call */))) { + return 1 /* JsxReferenceKind.Function */; } - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. @@ -76348,7 +76631,7 @@ var ts; if (!tagType) { return true; } - var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */); + var tagCallSignatures = getSignaturesOfType(tagType, 0 /* SignatureKind.Call */); if (!ts.length(tagCallSignatures)) { return true; } @@ -76356,12 +76639,12 @@ var ts; if (!factory) { return true; } - var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); + var factorySymbol = resolveEntityName(factory, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); if (!factorySymbol) { return true; } var factoryType = getTypeOfSymbol(factorySymbol); - var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */); + var callSignatures = getSignaturesOfType(factoryType, 0 /* SignatureKind.Call */); if (!ts.length(callSignatures)) { return true; } @@ -76371,7 +76654,7 @@ var ts; for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) { var sig = callSignatures_1[_i]; var firstparam = getTypeAtPosition(sig, 0); - var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */); + var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* SignatureKind.Call */); if (!ts.length(signaturesOfParam)) continue; for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) { @@ -76428,7 +76711,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 209 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -76446,13 +76729,13 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; + var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); @@ -76491,8 +76774,8 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - var expression = node.kind === 208 /* CallExpression */ ? node.expression : - node.kind === 210 /* TaggedTemplateExpression */ ? node.tag : undefined; + var expression = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression : + node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */ ? node.tag : undefined; if (expression) { var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { @@ -76510,17 +76793,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 165 /* Decorator */) { + if (node.kind === 165 /* SyntaxKind.Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -76531,15 +76814,15 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_25 = function (i) { + var _loop_26 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 225 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; var flags = spreadType.target.elementFlags[i]; - var syntheticArg = createSyntheticExpression(arg, flags & 4 /* Rest */ ? createArrayType(t) : t, !!(flags & 12 /* Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + var syntheticArg = createSyntheticExpression(arg, flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t, !!(flags & 12 /* ElementFlags.Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); effectiveArgs_1.push(syntheticArg); }); } @@ -76548,7 +76831,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_25(i); + _loop_26(i); } return effectiveArgs_1; } @@ -76561,30 +76844,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 171 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 171 /* SyntaxKind.Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 167 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && languageVersion !== 0 /* ScriptTarget.ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -76598,17 +76881,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return 1; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return 2; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments - return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 164 /* Parameter */: + return languageVersion === 0 /* ScriptTarget.ES3 */ || signature.parameters.length <= 2 ? 2 : 3; + case 164 /* SyntaxKind.Parameter */: return 3; default: return ts.Debug.fail(); @@ -76642,7 +76925,7 @@ var ts; function isPromiseResolveArityError(node) { if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression)) return false; - var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); + var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, undefined, undefined, false); var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { return false; @@ -76750,15 +77033,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 210 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 165 /* Decorator */; + var isTaggedTemplate = node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; + var isDecorator = node.kind === 165 /* SyntaxKind.Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; - if (!isDecorator) { + if (!isDecorator && !ts.isSuperCall(node)) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -76785,8 +77068,8 @@ var ts; // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; - var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */; - argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */; + var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* CheckMode.SkipContextSensitive */ : 0 /* CheckMode.Normal */; + argCheckMode |= checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; // The following variables are captured and modified by calls to chooseOverload. // If overload resolution or type argument inference fails, we want to report the // best error possible. The best error is one which says that an argument was not @@ -76814,7 +77097,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 208 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* CheckMode.IsForSignatureHelp */) && node.kind === 208 /* SyntaxKind.CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -76834,6 +77117,15 @@ var ts; if (result) { return result; } + result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + // Preemptively cache the result; getResolvedSignature will do this after we return, but + // we need to ensure that the result is present for the error checks below so that if + // this signature is encountered again, we handle the circularity (rather than producing a + // different result which may produce no errors and assert). Callers of getResolvedSignature + // don't hit this issue because they only observe this result after it's had a chance to + // be cached, but the error reporting code below executes before getResolvedSignature sets + // resolvedSignature. + getNodeLinks(node).resolvedSignature = result; // No signatures were applicable. Now report errors based on the last applicable signature with // no arguments excluded from assignability checks. // If candidate is undefined, it means that no candidates had a suitable arity. In that case, @@ -76847,7 +77139,7 @@ var ts; chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error); chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call); } - var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, function () { return chain_1; }); + var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, function () { return chain_1; }); if (diags) { for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) { var d = diags_1[_i]; @@ -76868,9 +77160,9 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_26 = function (c) { + var _loop_27 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { if (diags_2.length <= min_3) { min_3 = diags_2.length; @@ -76886,7 +77178,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_26(c); + _loop_27(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -76925,7 +77217,7 @@ var ts; } } } - return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + return result; function addImplementationSuccessElaboration(failed, diagnostic) { var _a, _b; var oldCandidatesForArgumentError = candidatesForArgumentError; @@ -76955,7 +77247,7 @@ var ts; if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { return undefined; } - if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { + if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { candidatesForArgumentError = [candidate]; return undefined; } @@ -76978,9 +77270,9 @@ var ts; } } else { - inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext); - argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */; + inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); + argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */; } checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a @@ -77002,10 +77294,10 @@ var ts; // If one or more context sensitive arguments were excluded, we start including // them now (and keeping do so for any subsequent candidates) and perform a second // round of type inference and applicability checking for this particular candidate. - argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */; + argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); - checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); + checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a // signature with different arity and we need to perform another arity check. if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) { @@ -77044,7 +77336,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_27 = function (i) { + var _loop_28 = function (i) { var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : i < s.parameters.length ? s.parameters[i] : undefined; }); @@ -77052,17 +77344,17 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_27(i); + _loop_28(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; if (restParameterSymbols.length !== 0) { - var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); + var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* UnionReduction.Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } if (candidates.some(signatureHasLiteralTypes)) { - flags |= 2 /* HasLiteralTypes */; + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. @@ -77075,7 +77367,7 @@ var ts; return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { - return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); + return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* UnionReduction.Subtype */)); } function createCombinedSymbolForOverloadFailure(sources, type) { // This function is currently only used for erroneous overloads, so it's good enough to just use the first source. @@ -77112,8 +77404,8 @@ var ts; return typeArguments; } function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) { - var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext); + var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* CheckMode.SkipContextSensitive */ | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); return createSignatureInstantiation(candidate, typeArgumentTypes); } function getLongestCandidateIndex(candidates, argsCount) { @@ -77133,7 +77425,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -77148,7 +77440,7 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } } return resolveUntypedCall(node); @@ -77157,13 +77449,13 @@ var ts; var funcType = checkExpression(node.expression); if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); - callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + callChainFlags = nonOptionalType === funcType ? 0 /* SignatureFlags.None */ : + ts.isOutermostOptionalChain(node) ? 16 /* SignatureFlags.IsOuterCallChain */ : + 8 /* SignatureFlags.IsInnerCallChain */; funcType = nonOptionalType; } else { - callChainFlags = 0 /* None */; + callChainFlags = 0 /* SignatureFlags.None */; } funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { @@ -77178,8 +77470,8 @@ var ts; // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; // TS 1.0 Spec: 4.12 // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. @@ -77206,7 +77498,7 @@ var ts; relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation); + invocationError(node.expression, apparentType, 0 /* SignatureKind.Call */, relatedInformation); } return resolveErrorCall(node); } @@ -77220,9 +77512,9 @@ var ts; // returns a function type, we choose to defer processing. This narrowly permits function composition // operators to flow inferences through return types, but otherwise processes calls right away. We // use the resolvingSignature singleton to indicate that we deferred processing. This result will be - // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and + // propagated out and eventually turned into silentNeverType (a type that is assignable to anything and // from which we never make inferences). - if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { skippedGenericFunction(node, checkMode); return resolvingSignature; } @@ -77243,11 +77535,11 @@ var ts; */ function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have no common signatures. - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeFlags.TypeParameter */) || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* TypeFlags.Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { - if (node.arguments && languageVersion < 1 /* ES5 */) { + if (node.arguments && languageVersion < 1 /* ScriptTarget.ES5 */) { var spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); @@ -77280,7 +77572,7 @@ var ts; // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(expressionType, 1 /* SignatureKind.Construct */); if (constructSignatures.length) { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); @@ -77289,24 +77581,24 @@ var ts; // then it cannot be instantiated. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); })) { + if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); })) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* Abstract */)) { + if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* ModifierFlags.Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. It is an error to have a Void this type. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + var callSignatures = getSignaturesOfType(expressionType, 0 /* SignatureKind.Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -77317,14 +77609,14 @@ var ts; } return signature; } - invocationError(node.expression, expressionType, 1 /* Construct */); + invocationError(node.expression, expressionType, 1 /* SignatureKind.Construct */); return resolveErrorCall(node); } function someSignature(signatures, f) { if (ts.isArray(signatures)) { return ts.some(signatures, function (signature) { return someSignature(signature, f); }); } - return signatures.compositeKind === 1048576 /* Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); + return signatures.compositeKind === 1048576 /* TypeFlags.Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); } function typeHasProtectedAccessibleBase(target, type) { var baseTypes = getBaseTypes(type); @@ -77332,7 +77624,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 2097152 /* Intersection */) { + if (firstBase.flags & 2097152 /* TypeFlags.Intersection */) { var types = firstBase.types; var mixinFlags = findMixins(types); var i = 0; @@ -77340,7 +77632,7 @@ var ts; var intersectionMember = _a[_i]; // We want to ignore mixin ctors if (!mixinFlags[i]) { - if (ts.getObjectFlags(intersectionMember) & (1 /* Class */ | 2 /* Interface */)) { + if (ts.getObjectFlags(intersectionMember) & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { if (intersectionMember.symbol === target) { return true; } @@ -77363,9 +77655,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 171 /* Constructor */) { + if (!modifiers || declaration.kind !== 171 /* SyntaxKind.Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -77373,16 +77665,16 @@ var ts; // A private or protected constructor can only be instantiated within its own class (or a subclass, for protected) if (!isNodeWithinClass(node, declaringClassDeclaration)) { var containingClass = ts.getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 16 /* ModifierFlags.Protected */) { var containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 8 /* ModifierFlags.Private */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 16 /* ModifierFlags.Protected */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -77391,10 +77683,10 @@ var ts; } function invocationErrorDetails(errorTarget, apparentType, kind) { var errorInfo; - var isCall = kind === 0 /* Call */; + var isCall = kind === 0 /* SignatureKind.Call */; var awaitedType = getAwaitedType(apparentType); var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0; - if (apparentType.flags & 1048576 /* Union */) { + if (apparentType.flags & 1048576 /* TypeFlags.Union */) { var types = apparentType.types; var hasSignatures = false; for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { @@ -77444,7 +77736,7 @@ var ts; // Diagnose get accessors incorrectly called as functions if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol; - if (resolvedSymbol && resolvedSymbol.flags & 32768 /* GetAccessor */) { + if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) { headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } @@ -77488,8 +77780,8 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -77499,26 +77791,26 @@ var ts; diagnostics.add(diagnostic); return resolveErrorCall(node); } - invocationError(node.tag, apparentType, 0 /* Call */); + invocationError(node.tag, apparentType, 0 /* SignatureKind.Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -77533,8 +77825,8 @@ var ts; if (isErrorType(apparentType)) { return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -77545,38 +77837,38 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* Call */); + var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* SignatureKind.Call */); var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage); var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage)); } diagnostics.add(diag); - invocationErrorRecovery(apparentType, 0 /* Call */, diag); + invocationErrorRecovery(apparentType, 0 /* SignatureKind.Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); - var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* SymbolFlags.Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* SymbolFlags.Type */, node); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, 0 /* None */); + /*returnTypePredicate*/ undefined, 1, 0 /* SignatureFlags.None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); var fakeSignature = createSignatureForJSXIntrinsic(node, result); - checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* CheckMode.Normal */), result, node.tagName, node.attributes); if (ts.length(node.typeArguments)) { ts.forEach(node.typeArguments, checkSourceElement); diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments))); @@ -77597,7 +77889,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -77613,16 +77905,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -77645,7 +77937,7 @@ var ts; return cached; } links.resolvedSignature = resolvingSignature; - var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */); + var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* CheckMode.Normal */); // When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call // resolution should be deferred. if (result !== resolvingSignature) { @@ -77686,7 +77978,7 @@ var ts; var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target); inferred.exports = inferred.exports || ts.createSymbolTable(); inferred.members = inferred.members || ts.createSymbolTable(); - inferred.flags |= source.flags & 32 /* Class */; + inferred.flags |= source.flags & 32 /* SymbolFlags.Class */; if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) { mergeSymbolTable(inferred.exports, source.exports); } @@ -77722,16 +78014,16 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } - else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + else if (parentNodeOperator === 56 /* SyntaxKind.BarBarToken */ || parentNodeOperator === 60 /* SyntaxKind.QuestionQuestionToken */) { if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -77754,10 +78046,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 206 /* PropertyAccessExpression */) { + while (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -77773,19 +78065,19 @@ var ts; var signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode); if (signature === resolvingSignature) { // CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that - // returns a function type. We defer checking and return nonInferrableType. - return nonInferrableType; + // returns a function type. We defer checking and return silentNeverType. + return silentNeverType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return voidType; } - if (node.kind === 209 /* NewExpression */) { + if (node.kind === 209 /* SyntaxKind.NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 171 /* Constructor */ && - declaration.kind !== 175 /* ConstructSignature */ && - declaration.kind !== 180 /* ConstructorType */ && + declaration.kind !== 171 /* SyntaxKind.Constructor */ && + declaration.kind !== 175 /* SyntaxKind.ConstructSignature */ && + declaration.kind !== 180 /* SyntaxKind.ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -77802,11 +78094,11 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* TypeFlags.ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 208 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* ExpressionStatement */ && - returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (node.kind === 208 /* SyntaxKind.CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && + returnType.flags & 16384 /* TypeFlags.Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); } @@ -77819,14 +78111,14 @@ var ts; var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - jsAssignmentType.objectFlags |= 4096 /* JSLiteral */; + jsAssignmentType.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } return returnType; } function checkDeprecatedSignature(signature, node) { - if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) { + if (signature.declaration && signature.declaration.flags & 268435456 /* NodeFlags.Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); @@ -77835,20 +78127,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 208 /* CallExpression */: - case 165 /* Decorator */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 165 /* SyntaxKind.Decorator */: + case 209 /* SyntaxKind.NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.argumentExpression; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -77870,7 +78162,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -77885,13 +78177,13 @@ var ts; for (var i = 2; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* TypeFlags.Undefined */ || specifierType.flags & 65536 /* TypeFlags.Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } if (optionsType) { var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true); if (importCallOptionsType !== emptyObjectType) { - checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]); + checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* TypeFlags.Undefined */), node.arguments[1]); } } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -77907,11 +78199,11 @@ var ts; } function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) { var memberTable = ts.createSymbolTable(); - var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + var newSymbol = createSymbol(2097152 /* SymbolFlags.Alias */, "default" /* InternalSymbolName.Default */); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); newSymbol.aliasTarget = resolveSymbol(symbol); - memberTable.set("default" /* Default */, newSymbol); + memberTable.set("default" /* InternalSymbolName.Default */, newSymbol); return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); } function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) { @@ -77934,7 +78226,7 @@ var ts; var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier); if (hasSyntheticDefault) { - var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var anonymousSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; @@ -77954,40 +78246,40 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } // project includes symbol named 'require' - make sure that it is ambient and local non-alias - if (resolvedRequire.flags & 2097152 /* Alias */) { + if (resolvedRequire.flags & 2097152 /* SymbolFlags.Alias */) { return false; } - var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 256 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 254 /* VariableDeclaration */ - : 0 /* Unknown */; - if (targetDeclarationKind !== 0 /* Unknown */) { + var targetDeclarationKind = resolvedRequire.flags & 16 /* SymbolFlags.Function */ + ? 256 /* SyntaxKind.FunctionDeclaration */ + : resolvedRequire.flags & 3 /* SymbolFlags.Variable */ + ? 254 /* SyntaxKind.VariableDeclaration */ + : 0 /* SyntaxKind.Unknown */; + if (targetDeclarationKind !== 0 /* SyntaxKind.Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 16777216 /* Ambient */); + return !!decl && !!(decl.flags & 16777216 /* NodeFlags.Ambient */); } return false; } function checkTaggedTemplateExpression(node) { if (!checkGrammarTaggedTemplateChain(node)) checkGrammarTypeArguments(node, node.typeArguments); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 262144 /* ExternalEmitHelpers.MakeTemplateObject */); } var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); return getReturnTypeOfSignature(signature); } function checkAssertion(node) { - if (node.kind === 211 /* TypeAssertionExpression */) { + if (node.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { var file = ts.getSourceFileOfNode(node); - if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */])) { grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } @@ -77995,31 +78287,31 @@ var ts; } function isValidConstAssertionArgument(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 223 /* TemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) || + op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node.expression; var symbol = getTypeOfNode(expr).symbol; - if (symbol && symbol.flags & 2097152 /* Alias */) { + if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = resolveAlias(symbol); } - return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); + return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */); } return false; } @@ -78050,12 +78342,12 @@ var ts; return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType); } function checkNonNullAssertion(node) { - return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkNonNullChain(node) : getNonNullableType(checkExpression(node.expression)); } function checkExpressionWithTypeArguments(node) { checkGrammarExpressionWithTypeArguments(node); - var exprType = node.kind === 228 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : + var exprType = node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? checkExpression(node.expression) : ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName); var typeArguments = node.typeArguments; @@ -78080,7 +78372,7 @@ var ts; } return result; function getInstantiatedTypePart(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var callSignatures = getInstantiatedSignatures(resolved.callSignatures); var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures); @@ -78088,12 +78380,12 @@ var ts; hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0); if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) { var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos); - result_11.objectFlags |= 8388608 /* InstantiationExpressionType */; + result_11.objectFlags |= 8388608 /* ObjectFlags.InstantiationExpressionType */; result_11.node = node; return result_11; } } - else if (type.flags & 58982400 /* InstantiableNonPrimitive */) { + else if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { var constraint = getBaseConstraintOfType(type); if (constraint) { var instantiated = getInstantiatedTypePart(constraint); @@ -78102,10 +78394,10 @@ var ts; } } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getInstantiatedType); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart)); } return type; @@ -78121,19 +78413,19 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 103 /* NewKeyword */) { + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 100 /* ImportKeyword */) { + if (node.keywordToken === 100 /* SyntaxKind.ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); } function checkMetaPropertyKeyword(node) { switch (node.keywordToken) { - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return getGlobalImportMetaExpressionType(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: var type = checkNewTargetMetaProperty(node); return isErrorType(type) ? errorType : createNewTargetExpressionType(type); default: @@ -78146,7 +78438,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -78165,7 +78457,7 @@ var ts; error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { @@ -78198,7 +78490,7 @@ var ts; } function getParameterIdentifierNameAtPosition(signature, pos) { var _a; - if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* JSDocFunctionType */) { + if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* SyntaxKind.JSDocFunctionType */) { return undefined; } var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -78230,7 +78522,7 @@ var ts; return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); } function isValidDeclarationForTupleLabel(d) { - return d.kind === 197 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 197 /* SyntaxKind.NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -78280,11 +78572,11 @@ var ts; for (var i = pos; i < parameterCount; i++) { if (!restType || i < parameterCount - 1) { types.push(getTypeAtPosition(source, i)); - flags.push(i < minArgumentCount ? 1 /* Required */ : 2 /* Optional */); + flags.push(i < minArgumentCount ? 1 /* ElementFlags.Required */ : 2 /* ElementFlags.Optional */); } else { types.push(restType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } var name = getNameableDeclarationAtPosition(source, i); if (name) { @@ -78308,14 +78600,14 @@ var ts; return length; } function getMinArgumentCount(signature, flags) { - var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */; - var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */; + var strongArityForUntypedJS = flags & 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */; + var voidIsNonOptional = flags & 2 /* MinArgumentCountFlags.VoidIsNonOptional */; if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) { var minArgumentCount = void 0; if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { - var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); + var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* ElementFlags.Required */); }); var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; if (requiredCount > 0) { minArgumentCount = signature.parameters.length - 1 + requiredCount; @@ -78323,7 +78615,7 @@ var ts; } } if (minArgumentCount === undefined) { - if (!strongArityForUntypedJS && signature.flags & 32 /* IsUntypedSignatureInJSFile */) { + if (!strongArityForUntypedJS && signature.flags & 32 /* SignatureFlags.IsUntypedSignatureInJSFile */) { return 0; } minArgumentCount = signature.minArgumentCount; @@ -78333,7 +78625,7 @@ var ts; } for (var i = minArgumentCount - 1; i >= 0; i--) { var type = getTypeAtPosition(signature, i); - if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, acceptsVoid).flags & 131072 /* TypeFlags.Never */) { break; } minArgumentCount = i; @@ -78363,7 +78655,7 @@ var ts; } function getNonArrayRestType(signature) { var restType = getEffectiveRestType(signature); - return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined; + return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* TypeFlags.Never */) === 0 ? restType : undefined; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -78382,17 +78674,6 @@ var ts; } } } - var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144 /* TypeParameter */) { - // The contextual signature has a generic rest parameter. We first instantiate the contextual - // signature (without fixing type parameters) and assign types to contextually typed parameters. - var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); - assignContextualParameterTypes(signature, instantiatedContext); - // We then infer from a tuple type representing the parameters that correspond to the contextual - // rest parameter. - var restPos = getParameterCount(context) - 1; - inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType); - } } function assignContextualParameterTypes(signature, context) { if (context.typeParameters) { @@ -78427,7 +78708,7 @@ var ts; ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration) // a declarationless parameter may still have a `.type` already set by its construction logic // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type - : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) { + : !!(ts.getCheckFlags(parameter) & 65536 /* CheckFlags.DeferredType */)) { var contextualParameterType = getRestTypeAtPosition(context, len); assignParameterType(parameter, contextualParameterType); } @@ -78447,7 +78728,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter)); - if (declaration && declaration.name.kind !== 79 /* Identifier */) { + if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); @@ -78466,7 +78747,7 @@ var ts; var element = _a[_i]; if (!ts.isOmittedExpression(element)) { var type = getBindingElementTypeFromParentType(element, parentType); - if (element.name.kind === 79 /* Identifier */) { + if (element.name.kind === 79 /* SyntaxKind.Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = type; } else { @@ -78514,8 +78795,8 @@ var ts; } function createNewTargetExpressionType(targetType) { // Create a synthetic type `NewTargetExpression { target: TargetType; }` - var symbol = createSymbol(0 /* None */, "NewTargetExpression"); - var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */); + var symbol = createSymbol(0 /* SymbolFlags.None */, "NewTargetExpression"); + var targetPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "target", 8 /* CheckFlags.Readonly */); targetPropertySymbol.parent = symbol; targetPropertySymbol.type = targetType; var members = ts.createSymbolTable([targetPropertySymbol]); @@ -78527,14 +78808,14 @@ var ts; return errorType; } var functionFlags = ts.getFunctionFlags(func); - var isAsync = (functionFlags & 2 /* Async */) !== 0; - var isGenerator = (functionFlags & 1 /* Generator */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + var isGenerator = (functionFlags & 1 /* FunctionFlags.Generator */) !== 0; var returnType; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 235 /* Block */) { // Async or normal arrow function - returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); + if (func.body.kind !== 235 /* SyntaxKind.Block */) { // Async or normal arrow function + returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -78549,47 +78830,47 @@ var ts; fallbackReturnType = neverType; } else if (returnTypes.length > 0) { - returnType = getUnionType(returnTypes, 2 /* Subtype */); + returnType = getUnionType(returnTypes, 2 /* UnionReduction.Subtype */); } var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes; - yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* Subtype */) : undefined; + yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* UnionReduction.Subtype */) : undefined; nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined; } else { // Async or normal function var types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, voidType) // Async function : voidType; // Normal function } // Return a union of the return expression types. - returnType = getUnionType(types, 2 /* Subtype */); + returnType = getUnionType(types, 2 /* UnionReduction.Subtype */); } if (returnType || yieldType || nextType) { if (yieldType) - reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */); + reportErrorsFromWidening(func, yieldType, 3 /* WideningKind.GeneratorYield */); if (returnType) - reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */); + reportErrorsFromWidening(func, returnType, 1 /* WideningKind.FunctionReturn */); if (nextType) - reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */); + reportErrorsFromWidening(func, nextType, 2 /* WideningKind.GeneratorNext */); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); var contextualType = !contextualSignature ? undefined : contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : - instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); + instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined); if (isGenerator) { - yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync); - returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync); - nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* Next */, isAsync); + yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* IterationTypeKind.Yield */, isAsync); + returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* IterationTypeKind.Return */, isAsync); + nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* IterationTypeKind.Next */, isAsync); } else { returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync); @@ -78603,7 +78884,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* IterationTypeKind.Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -78646,17 +78927,17 @@ var ts; function checkAndAggregateYieldOperandTypes(func, checkMode) { var yieldTypes = []; var nextTypes = []; - var isAsync = (ts.getFunctionFlags(func) & 2 /* Async */) !== 0; + var isAsync = (ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) !== 0; ts.forEachYieldExpression(func.body, function (yieldExpression) { var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType; ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync)); var nextType; if (yieldExpression.asteriskToken) { - var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, yieldExpression.expression); + var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, yieldExpression.expression); nextType = iterationTypes && iterationTypes.nextType; } else { - nextType = getContextualType(yieldExpression); + nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined); } if (nextType) ts.pushIfUnique(nextTypes, nextType); @@ -78666,17 +78947,17 @@ var ts; function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) { var errorNode = node.expression || node; // A `yield*` expression effectively yields everything that its operand yields - var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, expressionType, sentType, errorNode) : expressionType; + var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, expressionType, sentType, errorNode) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } // Return the combined not-equal type facts for all cases except those between the start and end indices. function getNotEqualFactsFromTypeofSwitch(start, end, witnesses) { - var facts = 0 /* None */; + var facts = 0 /* TypeFacts.None */; for (var i = 0; i < witnesses.length; i++) { var witness = i < start || i >= end ? witnesses[i] : undefined; - facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeofNEHostObject */ : 0; + facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeFacts.TypeofNEHostObject */ : 0; } return facts; } @@ -78685,7 +78966,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 216 /* TypeOfExpression */) { + if (node.expression.kind === 216 /* SyntaxKind.TypeOfExpression */) { var witnesses = getSwitchClauseTypeOfWitnesses(node); if (!witnesses) { return false; @@ -78693,9 +78974,9 @@ var ts; var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression)); // Get the not-equal flags for all handled cases. var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses); - if (operandConstraint.flags & 3 /* AnyOrUnknown */) { + if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) { // We special case the top types to be exhaustive when all cases are handled. - return (556800 /* AllTypeofNE */ & notEqualFacts_2) === 556800 /* AllTypeofNE */; + return (556800 /* TypeFacts.AllTypeofNE */ & notEqualFacts_2) === 556800 /* TypeFacts.AllTypeofNE */; } // A missing not-equal flag indicates that the type wasn't handled by some case. return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; }); @@ -78722,15 +79003,15 @@ var ts; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */); - if (functionFlags & 2 /* Async */) { + var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); + if (functionFlags & 2 /* FunctionFlags.Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -78751,11 +79032,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 169 /* MethodDeclaration */: - return func.parent.kind === 205 /* ObjectLiteralExpression */; + case 169 /* SyntaxKind.MethodDeclaration */: + return func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; default: return false; } @@ -78776,17 +79057,17 @@ var ts; var functionFlags = ts.getFunctionFlags(func); var type = returnType && unwrapReturnType(returnType, functionFlags); // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) { + if (type && maybeTypeOfKind(type, 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 168 /* SyntaxKind.MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* SyntaxKind.Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* NodeFlags.HasExplicitReturn */; var errorNode = ts.getEffectiveReturnTypeNode(func) || func; - if (type && type.flags & 131072 /* Never */) { + if (type && type.flags & 131072 /* TypeFlags.Never */) { error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { @@ -78815,13 +79096,13 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (ts.isFunctionExpression(node)) { checkCollisionsForDeclarationName(node, node.name); } // The identityMapper object is used to indicate that function expressions are wildcards - if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { + if (checkMode && checkMode & 4 /* CheckMode.SkipContextSensitive */ && isContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type @@ -78832,9 +79113,9 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray); - returnOnlyType.objectFlags |= 262144 /* NonInferrableType */; + returnOnlyType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -78842,7 +79123,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 213 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 213 /* SyntaxKind.FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -78851,25 +79132,30 @@ var ts; function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) { var links = getNodeLinks(node); // Check if function expression is contextually typed and assign parameter types if so. - if (!(links.flags & 1024 /* ContextChecked */)) { + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { - links.flags |= 1024 /* ContextChecked */; - var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* Call */)); + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { + links.flags |= 1024 /* NodeCheckFlags.ContextChecked */; + var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* SignatureKind.Call */)); if (!signature) { return; } if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); - if (checkMode && checkMode & 2 /* Inferential */) { + var instantiatedContextualSignature = void 0; + if (checkMode && checkMode & 2 /* CheckMode.Inferential */) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); + var restType = getEffectiveRestType(contextualSignature); + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { + instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper); + } } - var instantiatedContextualSignature = inferenceContext ? - instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature; + instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ? + instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature); assignContextualParameterTypes(signature, instantiatedContextualSignature); } else { @@ -78888,7 +79174,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -78901,7 +79187,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 235 /* Block */) { + if (node.body.kind === 235 /* SyntaxKind.Block */) { checkSourceElement(node.body); } else { @@ -78913,7 +79199,7 @@ var ts; var exprType = checkExpression(node.body); var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { // Async function var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } @@ -78971,27 +79257,27 @@ var ts; // Enum members // Object.defineProperty assignments with writable false or no setter // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(ts.getCheckFlags(symbol) & 8 /* Readonly */ || - symbol.flags & 4 /* Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || - symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || - symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - symbol.flags & 8 /* EnumMember */ || + return !!(ts.getCheckFlags(symbol) & 8 /* CheckFlags.Readonly */ || + symbol.flags & 4 /* SymbolFlags.Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* ModifierFlags.Readonly */ || + symbol.flags & 3 /* SymbolFlags.Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */ || + symbol.flags & 98304 /* SymbolFlags.Accessor */ && !(symbol.flags & 65536 /* SymbolFlags.SetAccessor */) || + symbol.flags & 8 /* SymbolFlags.EnumMember */ || ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; - if (assignmentKind === 0 /* None */) { + if (assignmentKind === 0 /* AssignmentKind.None */) { // no assigment means it doesn't matter whether the entity is readonly return false; } if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. - if (symbol.flags & 4 /* Property */ && + if (symbol.flags & 4 /* SymbolFlags.Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 108 /* ThisKeyword */) { + expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 171 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -79012,11 +79298,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; - if (symbol_2.flags & 2097152 /* Alias */) { + if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 268 /* NamespaceImport */; + return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */; } } } @@ -79024,12 +79310,12 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { + var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */); + if (node.kind !== 79 /* SyntaxKind.Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { error(expr, invalidOptionalChainMessage); return false; } @@ -79058,8 +79344,8 @@ var ts; function checkDeleteExpressionMustBeOptional(expr, symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks && - !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && - !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) { + !(type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) && + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* SymbolFlags.Optional */ : getTypeFacts(type) & 16777216 /* TypeFacts.IsUndefined */)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -79077,7 +79363,7 @@ var ts; if (container && ts.isClassStaticBlockDeclaration(container)) { error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); } - else if (!(node.flags & 32768 /* AwaitContext */)) { + else if (!(node.flags & 32768 /* NodeFlags.AwaitContext */)) { if (ts.isInTopLevelContext(node)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -79099,7 +79385,7 @@ var ts; case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: case ts.ModuleKind.System: - if (languageVersion >= 4 /* ES2017 */) { + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { break; } // fallthrough @@ -79116,7 +79402,7 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); - if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + if (container && container.kind !== 171 /* SyntaxKind.Constructor */ && (ts.getFunctionFlags(container) & 2 /* FunctionFlags.Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -79132,7 +79418,7 @@ var ts; addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); }); var operandType = checkExpression(node.expression); var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) { + if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* TypeFlags.AnyOrUnknown */)) { addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); } return awaitedType; @@ -79143,16 +79429,16 @@ var ts; return silentNeverType; } switch (node.operand.kind) { - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: switch (node.operator) { - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text)); - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text)); } break; - case 9 /* BigIntLiteral */: - if (node.operator === 40 /* MinusToken */) { + case 9 /* SyntaxKind.BigIntLiteral */: + if (node.operator === 40 /* SyntaxKind.MinusToken */) { return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -79160,28 +79446,28 @@ var ts; } } switch (node.operator) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* TypeFlags.ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 39 /* PlusToken */) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + if (node.operator === 39 /* SyntaxKind.PlusToken */) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* TypeFlags.BigIntLike */)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); - return facts === 4194304 /* Truthy */ ? falseType : - facts === 8388608 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* TypeFacts.Truthy */ | 8388608 /* TypeFacts.Falsy */); + return facts === 4194304 /* TypeFacts.Truthy */ ? falseType : + facts === 8388608 /* TypeFacts.Falsy */ ? trueType : booleanType; - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -79204,8 +79490,8 @@ var ts; return getUnaryResultType(operandType); } function getUnaryResultType(operandType) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* TypeFlags.AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* TypeFlags.NumberLike */) ? numberOrBigIntType : bigintType; } @@ -79225,7 +79511,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { var t = types_20[_i]; @@ -79240,30 +79526,30 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { + if (strict && source.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */)) { return false; } - return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || - !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* TypeFlags.NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 402653316 /* TypeFlags.StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 528 /* TypeFlags.BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 16384 /* TypeFlags.Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 65536 /* TypeFlags.Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 32768 /* TypeFlags.Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 4096 /* TypeFlags.ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 67108864 /* TypeFlags.NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 1048576 /* Union */ ? + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; + return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { if (leftType === silentNeverType || rightType === silentNeverType) { @@ -79275,7 +79561,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 131068 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -79289,8 +79575,8 @@ var ts; return silentNeverType; } if (ts.isPrivateIdentifier(left)) { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(left, 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */); } // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors @@ -79303,8 +79589,8 @@ var ts; leftType = checkNonNullType(leftType, left); // TypeScript 1.0 spec (April 2014): 4.15.5 // Require the left operand to be of type Any, the String primitive type, or the Number primitive type. - if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { + if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol); } } @@ -79329,9 +79615,9 @@ var ts; // // The result is always of the Boolean primitive type. var rightTypeConstraint = getConstraintOfType(rightType); - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - !maybeTypeOfKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */))) { + if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; @@ -79351,7 +79637,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 296 /* PropertyAssignment */ || property.kind === 297 /* ShorthandPropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */ || property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -79362,17 +79648,17 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* AccessFlags.ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 297 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 298 /* SpreadAssignment */) { + else if (property.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(property, 4 /* Rest */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(property, 4 /* ExternalEmitHelpers.Rest */); } var nonRestNames = []; if (allProperties) { @@ -79394,18 +79680,18 @@ var ts; } function checkArrayLiteralAssignment(node, sourceType, checkMode) { var elements = node.elements; - if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; + var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | 128 /* IterationUse.PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 225 /* SpreadElement */) { - type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); + if (node.elements[i].kind === 225 /* SyntaxKind.SpreadElement */) { + type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); } @@ -79414,15 +79700,15 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 227 /* OmittedExpression */) { - if (element.kind !== 225 /* SpreadElement */) { + if (element.kind !== 227 /* SyntaxKind.OmittedExpression */) { + if (element.kind !== 225 /* SyntaxKind.SpreadElement */) { var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; - var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; + var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* TypeFacts.NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); } @@ -79433,7 +79719,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 221 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { + if (restExpression.kind === 221 /* SyntaxKind.BinaryExpression */ && restExpression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -79449,14 +79735,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 297 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* IsUndefined */)) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* TypeFacts.IsUndefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -79465,35 +79751,35 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { + if (target.kind === 221 /* SyntaxKind.BinaryExpression */ && target.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; // A default value is specified, so remove undefined from the final type. if (strictNullChecks) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } } - if (target.kind === 205 /* ObjectLiteralExpression */) { + if (target.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 204 /* ArrayLiteralExpression */) { + if (target.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 298 /* SpreadAssignment */ ? + var error = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 298 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { - checkExternalEmitHelpers(target.parent, 1048576 /* ClassPrivateFieldSet */); + checkExternalEmitHelpers(target.parent, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } return sourceType; } @@ -79508,59 +79794,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 210 /* TaggedTemplateExpression */: - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 153 /* UndefinedKeyword */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 216 /* TypeOfExpression */: - case 230 /* NonNullExpression */: - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: return true; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 53 /* ExclamationToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: return true; } return false; // Some forms listed here for clarity - case 217 /* VoidExpression */: // Explicit opt-out - case 211 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 229 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 217 /* SyntaxKind.VoidExpression */: // Explicit opt-out + case 211 /* SyntaxKind.TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 229 /* SyntaxKind.AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* TypeFlags.Nullable */) !== 0 || isTypeComparableTo(source, target); } function createCheckBinaryExpression() { var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); @@ -79591,9 +79877,9 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (node.left.kind === 205 /* ObjectLiteralExpression */ || node.left.kind === 204 /* ArrayLiteralExpression */)) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && (node.left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { state.skip = true; - setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* SyntaxKind.ThisKeyword */)); return state; } return state; @@ -79610,9 +79896,13 @@ var ts; setLeftType(state, leftType); setLastResult(state, /*type*/ undefined); var operator = operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */) { + var parent = node.parent; + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ + || ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */)) { + parent = parent.parent; + } checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } checkTruthinessOfType(leftType, node.left); @@ -79671,11 +79961,11 @@ var ts; } function checkGrammarNullishCoalesceWithLogicalExpression(node) { var left = node.left, operatorToken = node.operatorToken, right = node.right; - if (operatorToken.kind === 60 /* QuestionQuestionToken */) { - if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || left.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } - if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || right.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } } @@ -79684,11 +79974,11 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (left.kind === 205 /* ObjectLiteralExpression */ || left.kind === 204 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); + if (operator === 63 /* SyntaxKind.EqualsToken */ && (left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* SyntaxKind.ThisKeyword */); } var leftType; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -79700,28 +79990,28 @@ var ts; function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) { var operator = operatorToken.kind; switch (operator) { - case 41 /* AsteriskToken */: - case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 44 /* PercentToken */: - case 69 /* PercentEqualsToken */: - case 40 /* MinusToken */: - case 65 /* MinusEqualsToken */: - case 47 /* LessThanLessThanToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 44 /* SyntaxKind.PercentToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 40 /* SyntaxKind.MinusToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -79730,8 +80020,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 528 /* BooleanLike */) && - (rightType.flags & 528 /* BooleanLike */) && + if ((leftType.flags & 528 /* TypeFlags.BooleanLike */) && + (rightType.flags & 528 /* TypeFlags.BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); return numberType; @@ -79742,21 +80032,21 @@ var ts; var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, /*isAwaitValid*/ true); var resultType_1; // If both are any or unknown, allow operation; assume it will resolve to number - if ((isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */)) || + if ((isTypeAssignableToKind(leftType, 3 /* TypeFlags.AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* TypeFlags.AnyOrUnknown */)) || // Or, if neither could be bigint, implicit coercion results in a number result - !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + !(maybeTypeOfKind(leftType, 2112 /* TypeFlags.BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* TypeFlags.BigIntLike */))) { resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; - case 42 /* AsteriskAsteriskToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - if (languageVersion < 3 /* ES2016 */) { + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } } @@ -79772,26 +80062,26 @@ var ts; } return resultType_1; } - case 39 /* PlusToken */: - case 64 /* PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* TypeFlags.NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* TypeFlags.NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true)) { // If both operands are of the BigInt primitive type, the result is of the BigInt primitive type. resultType = bigintType; } - else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -79809,21 +80099,21 @@ var ts; // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. - var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */; + var closeEnoughKind_1 = 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 3 /* TypeFlags.AnyOrUnknown */; reportOperatorError(function (left, right) { return isTypeAssignableToKind(left, closeEnoughKind_1) && isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 64 /* PlusEqualsToken */) { + if (operator === 64 /* SyntaxKind.PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -79832,60 +80122,60 @@ var ts; }); } return booleanType; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: if (ts.isLiteralExpressionOfObject(left) || ts.isLiteralExpressionOfObject(right)) { - var eqType = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; + var eqType = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true"); } reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 55 /* AmpersandAmpersandToken */: - case 76 /* AmpersandAmpersandEqualsToken */: { - var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: { + var resultType_2 = getTypeFacts(leftType) & 4194304 /* TypeFacts.Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 76 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } - case 56 /* BarBarToken */: - case 75 /* BarBarEqualsToken */: { - var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? - getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : + case 56 /* SyntaxKind.BarBarToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: { + var resultType_3 = getTypeFacts(leftType) & 8388608 /* TypeFacts.Falsy */ ? + getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 75 /* BarBarEqualsToken */) { + if (operator === 75 /* SyntaxKind.BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } - case 60 /* QuestionQuestionToken */: - case 77 /* QuestionQuestionEqualsToken */: { - var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? - getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: { + var resultType_4 = getTypeFacts(leftType) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 77 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* SyntaxKind.QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 63 /* EqualsToken */: - var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; + case 63 /* SyntaxKind.EqualsToken */: + var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* AssignmentDeclarationKind.None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { - if (!(rightType.flags & 524288 /* Object */) || - declKind !== 2 /* ModuleExports */ && - declKind !== 6 /* Prototype */ && + if (!(rightType.flags & 524288 /* TypeFlags.Object */) || + declKind !== 2 /* AssignmentDeclarationKind.ModuleExports */ && + declKind !== 6 /* AssignmentDeclarationKind.Prototype */ && !isEmptyObjectType(rightType) && !isFunctionObjectType(rightType) && - !(ts.getObjectFlags(rightType) & 1 /* Class */)) { + !(ts.getObjectFlags(rightType) & 1 /* ObjectFlags.Class */)) { // don't check assignability of module.exports=, C.prototype=, or expando types because they will necessarily be incomplete checkAssignmentOperator(rightType); } @@ -79895,7 +80185,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { var sf = ts.getSourceFileOfNode(left); var sourceText = sf.text; @@ -79913,16 +80203,16 @@ var ts; return ts.Debug.fail(); } function bothAreBigIntLike(left, right) { - return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + return isTypeAssignableToKind(left, 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableToKind(right, 2112 /* TypeFlags.BigIntLike */); } function checkAssignmentDeclaration(kind, rightType) { - if (kind === 2 /* ModuleExports */) { + if (kind === 2 /* AssignmentDeclarationKind.ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { var prop = _a[_i]; var propType = getTypeOfSymbol(prop); - if (propType.symbol && propType.symbol.flags & 32 /* Class */) { + if (propType.symbol && propType.symbol.flags & 32 /* SymbolFlags.Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* SymbolFlags.Type */, undefined, name, /*isUse*/ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) { addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); @@ -79932,12 +80222,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : - maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* TypeFlags.ESSymbolLike */) ? left : + maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* TypeFlags.ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -79947,15 +80237,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - return 56 /* BarBarToken */; - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - return 37 /* ExclamationEqualsEqualsToken */; - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: - return 55 /* AmpersandAmpersandToken */; + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + return 56 /* SyntaxKind.BarBarToken */; + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + return 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + return 55 /* SyntaxKind.AmpersandAmpersandToken */; default: return undefined; } @@ -79974,7 +80264,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { var headMessage = void 0; - if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) { + if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* TypeFlags.Undefined */)) { var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText); if (isExactOptionalPropertyMismatch(valueType, target)) { headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target; @@ -79988,13 +80278,13 @@ var ts; function isAssignmentDeclaration(kind) { var _a; switch (kind) { - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: return true; - case 1 /* ExportsProperty */: - case 5 /* Property */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: - case 4 /* ThisProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var symbol = getSymbolOfNode(left); var init = ts.getAssignedExpandoInitializer(right); return !!init && ts.isObjectLiteralExpression(init) && @@ -80037,12 +80327,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: typeName = "false"; break; - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -80068,20 +80358,20 @@ var ts; if (!func) return anyType; var functionFlags = ts.getFunctionFlags(func); - if (!(functionFlags & 1 /* Generator */)) { + if (!(functionFlags & 1 /* FunctionFlags.Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; } - var isAsync = (functionFlags & 2 /* Async */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; if (node.asteriskToken) { // Async generator functions prior to ESNext require the __await, __asyncDelegator, // and __asyncValues helpers - if (isAsync && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */); + if (isAsync && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 26624 /* ExternalEmitHelpers.AsyncDelegatorIncludes */); } // Generator functions prior to ES2015 require the __values helper - if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 256 /* Values */); + if (!isAsync && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.Values */); } } // There is no point in doing an assignability check if the function @@ -80098,20 +80388,20 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression); } if (node.asteriskToken) { - var use = isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */; - return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression) + var use = isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */; + return getIterationTypeOfIterable(use, 1 /* IterationTypeKind.Return */, yieldExpressionType, node.expression) || anyType; } else if (returnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) + return getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, isAsync) || anyType; } - var type = getContextualIterationType(2 /* Next */, func); + var type = getContextualIterationType(2 /* IterationTypeKind.Next */, func); if (!type) { type = anyType; addLazyDiagnostic(function () { if (noImplicitAny && !ts.expressionResultIsUnused(node)) { - var contextualType = getContextualType(node); + var contextualType = getContextualType(node, /*contextFlags*/ undefined); if (!contextualType || isTypeAny(contextualType)) { error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation); } @@ -80120,7 +80410,7 @@ var ts; } return type; function checkYieldExpressionGrammar() { - if (!(node.flags & 8192 /* YieldContext */)) { + if (!(node.flags & 8192 /* NodeFlags.YieldContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -80133,7 +80423,7 @@ var ts; checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); - return getUnionType([type1, type2], 2 /* Subtype */); + return getUnionType([type1, type2], 2 /* UnionReduction.Subtype */); } function isTemplateLiteralContext(node) { var parent = node.parent; @@ -80146,20 +80436,20 @@ var ts; for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { var span = _a[_i]; var type = checkExpression(span.expression); - if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) { error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; + return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { - return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || - type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); + return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) || + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */)); } function getContextNode(node) { - if (node.kind === 286 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 286 /* SyntaxKind.JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -80171,7 +80461,7 @@ var ts; try { context.contextualType = contextualType; context.inferenceContext = inferenceContext; - var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0)); + var type = checkExpression(node, checkMode | 1 /* CheckMode.Contextual */ | (inferenceContext ? 2 /* CheckMode.Inferential */ : 0)); // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type // parameters. This information is no longer needed after the call to checkExpression. if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { @@ -80180,7 +80470,7 @@ var ts; // We strip literal freshness when an appropriate contextual type is present such that contextually typed // literals always preserve their literal types (otherwise they might widen during type inference). An alternative // here would be to not mark contextually typed literals as fresh in the first place. - var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* TypeFlags.Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -80193,7 +80483,7 @@ var ts; } } function checkExpressionCached(node, checkMode) { - if (checkMode && checkMode !== 0 /* Normal */) { + if (checkMode && checkMode !== 0 /* CheckMode.Normal */) { return checkExpression(node, checkMode); } var links = getNodeLinks(node); @@ -80213,17 +80503,17 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 211 /* TypeAssertionExpression */ || - node.kind === 229 /* AsExpression */ || + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */ || + node.kind === 229 /* SyntaxKind.AsExpression */ || ts.isJSDocTypeAssertion(node); } function checkDeclarationInitializer(declaration, checkMode, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? - checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */) + checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* CheckMode.Normal */) : checkExpressionCached(initializer, checkMode)); - return ts.isParameter(declaration) && declaration.name.kind === 202 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -80233,9 +80523,9 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 203 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 203 /* SyntaxKind.BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); } @@ -80244,7 +80534,7 @@ var ts; return createTupleType(elementTypes, elementFlags, type.target.readonly); } function widenTypeInferredFromInitializer(declaration, type) { - var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); + var widened = ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); @@ -80259,28 +80549,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 3145728 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || unknownType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* TypeFlags.String */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* TypeFlags.Number */) && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + maybeTypeOfKind(constraint, 64 /* TypeFlags.BigInt */) && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + maybeTypeOfKind(constraint, 4096 /* TypeFlags.ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || - contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* TypeFlags.StringLiteral */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + contextualType.flags & 256 /* TypeFlags.NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + contextualType.flags & 2048 /* TypeFlags.BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + contextualType.flags & 512 /* TypeFlags.BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* TypeFlags.BooleanLiteral */) || + contextualType.flags & 8192 /* TypeFlags.UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */)); } return false; } @@ -80295,13 +80585,13 @@ var ts; var type = checkExpression(node, checkMode, forceTuple); return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) : isTypeAssertion(node) ? type : - getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node)); + getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined)); } function checkPropertyAssignment(node, checkMode) { // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -80312,23 +80602,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { - if (checkMode && checkMode & (2 /* Inferential */ | 8 /* SkipGenericFunctions */)) { - var callSignature = getSingleSignature(type, 0 /* Call */, /*allowMembers*/ true); - var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); + if (checkMode && checkMode & (2 /* CheckMode.Inferential */ | 8 /* CheckMode.SkipGenericFunctions */)) { + var callSignature = getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ true); + var constructSignature = getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + var contextualType = getApparentTypeOfContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { - var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); + var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { - if (checkMode & 8 /* SkipGenericFunctions */) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */) { skippedGenericFunction(node, checkMode); return anyFunctionType; } @@ -80376,11 +80666,11 @@ var ts; return type; } function skippedGenericFunction(node, checkMode) { - if (checkMode & 2 /* Inferential */) { + if (checkMode & 2 /* CheckMode.Inferential */) { // We have skipped a generic function during inferential typing. Obtain the inference context and // indicate this has occurred such that we know a second pass of inference is be needed. var context = getInferenceContext(node); - context.flags |= 4 /* SkippedGenericFunction */; + context.flags |= 4 /* InferenceFlags.SkippedGenericFunction */; } } function hasInferenceCandidates(info) { @@ -80405,12 +80695,12 @@ var ts; var result = []; var oldTypeParameters; var newTypeParameters; - for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { - var tp = typeParameters_2[_i]; + for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { + var tp = typeParameters_3[_i]; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); - var symbol = createSymbol(262144 /* TypeParameter */, newName); + var symbol = createSymbol(262144 /* SymbolFlags.TypeParameter */, newName); var newTypeParameter = createTypeParameter(symbol); newTypeParameter.target = tp; oldTypeParameters = ts.append(oldTypeParameters, tp); @@ -80435,7 +80725,7 @@ var ts; } function getUniqueTypeParameterName(typeParameters, baseName) { var len = baseName.length; - while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* _0 */ && baseName.charCodeAt(len - 1) <= 57 /* _9 */) + while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* CharacterCodes._0 */ && baseName.charCodeAt(len - 1) <= 57 /* CharacterCodes._9 */) len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { @@ -80468,7 +80758,7 @@ var ts; return quickType; } // If a type has been cached for the node, return it. - if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) { + if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) { var cachedType = flowTypeCache[getNodeId(node)]; if (cachedType) { return cachedType; @@ -80480,7 +80770,7 @@ var ts; if (flowInvocationCount !== startInvocationCount) { var cache = flowTypeCache || (flowTypeCache = []); cache[getNodeId(node)] = type; - ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */); + ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */); } return type; } @@ -80495,7 +80785,7 @@ var ts; expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -80505,8 +80795,8 @@ var ts; else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { return getTypeFromTypeNode(expr.type); } - else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { + else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ || + node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) { return checkExpression(node); } return undefined; @@ -80526,7 +80816,7 @@ var ts; var saveContextualType = node.contextualType; node.contextualType = anyType; try { - var type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */); + var type = links.contextFreeType = checkExpression(node, 4 /* CheckMode.SkipContextSensitive */); return type; } finally { @@ -80537,7 +80827,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -80555,18 +80845,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 207 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 181 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 275 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { - ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 16777216 /* Ambient */) { + if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -80584,113 +80874,113 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return checkIdentifier(node, checkMode); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifierExpression(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return checkThisExpression(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return nullWideningType; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getFreshTypeOfLiteralType(getStringLiteralType(node.text)); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text)); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: false, base10Value: ts.parsePseudoBigInt(node.text) })); - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: return trueType; - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return falseType; - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return checkTemplateExpression(node); - case 13 /* RegularExpressionLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: return globalRegExpType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return checkQualifiedName(node, checkMode); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 208 /* CallExpression */: - if (node.expression.kind === 100 /* ImportKeyword */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.expression.kind === 100 /* SyntaxKind.ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checkCallExpression(node, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return checkClassExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return checkTypeOfExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return checkAssertion(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return checkNonNullAssertion(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return checkExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkMetaProperty(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkDeleteExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return checkVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return checkAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return checkSpreadExpression(node, checkMode); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return undefinedWideningType; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return checkYieldExpression(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return checkSyntheticExpression(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return checkJsxExpression(node, checkMode); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return checkJsxElement(node, checkMode); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return checkJsxFragment(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -80724,16 +81014,18 @@ var ts; var modifiers = getVarianceModifiers(typeParameter); if (modifiers) { var symbol = getSymbolOfNode(node.parent); - if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) { + if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */))) { error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); } - else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType); + else if (modifiers === 32768 /* ModifierFlags.In */ || modifiers === 65536 /* ModifierFlags.Out */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) }); + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck); var saveVarianceTypeParameter = typeParameter; varianceTypeParameter = typeParameter; checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); varianceTypeParameter = saveVarianceTypeParameter; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } } } @@ -80746,28 +81038,28 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 171 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { + if (!(func.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 171 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 171 /* SyntaxKind.Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } - if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { + if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) { error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); } if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) { if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 171 /* Constructor */ || func.kind === 175 /* ConstructSignature */ || func.kind === 180 /* ConstructorType */) { + if (func.kind === 171 /* SyntaxKind.Constructor */ || func.kind === 175 /* SyntaxKind.ConstructSignature */ || func.kind === 180 /* SyntaxKind.ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 172 /* GetAccessor */ || func.kind === 173 /* SetAccessor */) { + if (func.kind === 172 /* SyntaxKind.GetAccessor */ || func.kind === 173 /* SyntaxKind.SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -80791,7 +81083,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { + if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -80825,13 +81117,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 179 /* FunctionType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 179 /* SyntaxKind.FunctionType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -80845,11 +81137,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* SyntaxKind.Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 202 /* ArrayBindingPattern */ || name.kind === 201 /* ObjectBindingPattern */) { + else if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -80858,29 +81150,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 176 /* IndexSignature */) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 179 /* FunctionType */ || node.kind === 256 /* FunctionDeclaration */ || node.kind === 180 /* ConstructorType */ || - node.kind === 174 /* CallSignature */ || node.kind === 171 /* Constructor */ || - node.kind === 175 /* ConstructSignature */) { + else if (node.kind === 179 /* SyntaxKind.FunctionType */ || node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 180 /* SyntaxKind.ConstructorType */ || + node.kind === 174 /* SyntaxKind.CallSignature */ || node.kind === 171 /* SyntaxKind.Constructor */ || + node.kind === 175 /* SyntaxKind.ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); - if (!(functionFlags & 4 /* Invalid */)) { + if (!(functionFlags & 4 /* FunctionFlags.Invalid */)) { // Async generators prior to ESNext require the __await and __asyncGenerator helpers - if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 3 /* FunctionFlags.AsyncGenerator */ && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 6144 /* ExternalEmitHelpers.AsyncGeneratorIncludes */); } // Async functions prior to ES2017 require the __awaiter helper - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { - checkExternalEmitHelpers(node, 64 /* Awaiter */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */ && languageVersion < 4 /* ScriptTarget.ES2017 */) { + checkExternalEmitHelpers(node, 64 /* ExternalEmitHelpers.Awaiter */); } // Generator functions, Async functions, and Async Generator functions prior to // ES2015 require the __generator helper - if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 128 /* Generator */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) !== 0 /* FunctionFlags.Normal */ && languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 128 /* ExternalEmitHelpers.Generator */); } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); @@ -80896,17 +81188,17 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (returnTypeNode) { var functionFlags_1 = ts.getFunctionFlags(node); - if ((functionFlags_1 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) { + if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) { var returnType = getTypeFromTypeNode(returnTypeNode); if (returnType === voidType) { error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -80918,18 +81210,18 @@ var ts; // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; - var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || generatorYieldType; - var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || unknownType; - var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* Async */)); + var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType; + var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType; + var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType; + var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */)); checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode); } } - else if ((functionFlags_1 & 3 /* AsyncGenerator */) === 2 /* Async */) { + else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 176 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) { + if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -80941,11 +81233,11 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 171 /* Constructor */) { + if (member.kind === 171 /* SyntaxKind.Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); + addName(instanceNames, param.name, param.name.escapedText, 3 /* DeclarationMeaning.GetOrSetAccessor */); } } } @@ -80956,24 +81248,24 @@ var ts; continue; } var isPrivate = ts.isPrivateIdentifier(name); - var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0; + var privateStaticFlags = isPrivate && isStaticMember ? 16 /* DeclarationMeaning.PrivateStatic */ : 0; var names = isPrivate ? privateIdentifiers : isStaticMember ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 172 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); + case 172 /* SyntaxKind.GetAccessor */: + addName(names, name, memberName, 1 /* DeclarationMeaning.GetAccessor */ | privateStaticFlags); break; - case 173 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); + case 173 /* SyntaxKind.SetAccessor */: + addName(names, name, memberName, 2 /* DeclarationMeaning.SetAccessor */ | privateStaticFlags); break; - case 167 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: + addName(names, name, memberName, 3 /* DeclarationMeaning.GetOrSetAccessor */ | privateStaticFlags); break; - case 169 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); + case 169 /* SyntaxKind.MethodDeclaration */: + addName(names, name, memberName, 8 /* DeclarationMeaning.Method */ | privateStaticFlags); break; } } @@ -80983,19 +81275,19 @@ var ts; var prev = names.get(name); if (prev) { // For private identifiers, do not allow mixing of static and instance members with the same name - if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + if ((prev & 16 /* DeclarationMeaning.PrivateStatic */) !== (meaning & 16 /* DeclarationMeaning.PrivateStatic */)) { error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - var prevIsMethod = !!(prev & 8 /* Method */); - var isMethod = !!(meaning & 8 /* Method */); + var prevIsMethod = !!(prev & 8 /* DeclarationMeaning.Method */); + var isMethod = !!(meaning & 8 /* DeclarationMeaning.Method */); if (prevIsMethod || isMethod) { if (prevIsMethod !== isMethod) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered } - else if (prev & meaning & ~16 /* PrivateStatic */) { + else if (prev & meaning & ~16 /* DeclarationMeaning.PrivateStatic */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { @@ -81044,15 +81336,15 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 166 /* PropertySignature */) { + if (member.kind === 166 /* SyntaxKind.PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: memberName = name.text; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: memberName = ts.idText(name); break; default: @@ -81069,7 +81361,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -81083,7 +81375,7 @@ var ts; var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var indexSignatureMap_1 = new ts.Map(); - var _loop_28 = function (declaration) { + var _loop_29 = function (declaration) { if (declaration.parameters.length === 1 && declaration.parameters[0].type) { forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) { var entry = indexSignatureMap_1.get(getTypeId(type)); @@ -81098,7 +81390,7 @@ var ts; }; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - _loop_28(declaration); + _loop_29(declaration); } indexSignatureMap_1.forEach(function (entry) { if (entry.declarations.length > 1) { @@ -81117,7 +81409,7 @@ var ts; checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); // property signatures already report "initializer not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* PropertyDeclaration */ && node.initializer) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && node.initializer) { error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -81137,7 +81429,7 @@ var ts; // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // method signatures already report "implementation not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 169 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } // Private named methods are only allowed in class declarations @@ -81147,9 +81439,9 @@ var ts; setNodeLinksForPrivateIdentifierScope(node); } function setNodeLinksForPrivateIdentifierScope(node) { - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ScriptTarget.ESNext */) { for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; + getNodeLinks(lexicalScope).flags |= 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */; } // If this is a private element in a class expression inside the body of a loop, // then we must use a block-scoped binding to store the additional variables required @@ -81157,8 +81449,8 @@ var ts; if (ts.isClassExpression(node.parent)) { var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); if (enclosingIterationStatement) { - getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(node.name).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } } @@ -81190,7 +81482,7 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 167 /* PropertyDeclaration */ && + return n.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(n) && !!n.initializer; } @@ -81211,9 +81503,9 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && + var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ModifierFlags.ParameterPropertyModifier */); })); if (superCallShouldBeRootLevel) { // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional // See GH #8277 @@ -81252,7 +81544,7 @@ var ts; return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body; } function nodeImmediatelyReferencesSuperOrThis(node) { - if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || node.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } if (ts.isThisContainerOrFunctionBlock(node)) { @@ -81273,9 +81565,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 172 /* GetAccessor */) { - if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { - if (!(node.flags & 512 /* HasExplicitReturn */)) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* NodeFlags.HasImplicitReturn */)) { + if (!(node.flags & 512 /* NodeFlags.HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -81283,25 +81575,25 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var symbol = getSymbolOfNode(node); - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); - if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { - getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* NodeCheckFlags.TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* NodeCheckFlags.TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); var setterFlags = ts.getEffectiveModifierFlags(setter); - if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) { + if ((getterFlags & 128 /* ModifierFlags.Abstract */) !== (setterFlags & 128 /* ModifierFlags.Abstract */)) { error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) || - ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) { + if (((getterFlags & 16 /* ModifierFlags.Protected */) && !(setterFlags & (16 /* ModifierFlags.Protected */ | 8 /* ModifierFlags.Private */))) || + ((getterFlags & 8 /* ModifierFlags.Private */) && !(setterFlags & 8 /* ModifierFlags.Private */))) { error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -81313,7 +81605,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -81321,6 +81613,12 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function getEffectiveTypeArgumentAtIndex(node, typeParameters, index) { + if (index < typeParameters.length) { + return getTypeFromTypeNode(node.typeArguments[index]); + } + return getEffectiveTypeArguments(node, typeParameters)[index]; + } function getEffectiveTypeArguments(node, typeParameters) { return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node)); } @@ -81345,15 +81643,15 @@ var ts; if (!isErrorType(type)) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || - (ts.getObjectFlags(type) & 4 /* Reference */ ? type.target.localTypeParameters : undefined); + return symbol.flags & 524288 /* SymbolFlags.TypeAlias */ && getSymbolLinks(symbol).typeParameters || + (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target.localTypeParameters : undefined); } } return undefined; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 178 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -81369,10 +81667,10 @@ var ts; } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) { + if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) { addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } - if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -81411,29 +81709,29 @@ var ts; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) { var e = elementTypes_1[_i]; - if (e.kind !== 197 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 197 /* SyntaxKind.NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } var flags = getTupleElementFlags(e); - if (flags & 8 /* Variadic */) { + if (flags & 8 /* ElementFlags.Variadic */) { var type = getTypeFromTypeNode(e.type); if (!isArrayLikeType(type)) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); break; } - if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) { + if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* ElementFlags.Rest */) { seenRestElement = true; } } - else if (flags & 4 /* Rest */) { + else if (flags & 4 /* ElementFlags.Rest */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element); break; } seenRestElement = true; } - else if (flags & 2 /* Optional */) { + else if (flags & 2 /* ElementFlags.Optional */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element); break; @@ -81453,15 +81751,15 @@ var ts; getTypeFromTypeNode(node); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 8388608 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* TypeFlags.IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 207 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && - ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { + if (accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + ts.getObjectFlags(objectType) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; @@ -81469,14 +81767,14 @@ var ts; // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. var apparentObjectType = getApparentType(objectType); - if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { return type; } if (isGenericObjectType(objectType)) { var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode); if (propertyName_1) { var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); }); - if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) { error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1)); return errorType; } @@ -81525,7 +81823,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* SyntaxKind.ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -81535,7 +81833,7 @@ var ts; if (!links.typeParametersChecked) { links.typeParametersChecked = true; var typeParameter = getDeclaredTypeOfTypeParameter(symbol); - var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */); + var declarations = ts.getDeclarationsOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); @@ -81576,31 +81874,31 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 185 /* OptionalType */) { + if (node.type.kind === 185 /* SyntaxKind.OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 186 /* RestType */) { + if (node.type.kind === 186 /* SyntaxKind.RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* NodeFlags.Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 258 /* InterfaceDeclaration */ && - n.parent.kind !== 257 /* ClassDeclaration */ && - n.parent.kind !== 226 /* ClassExpression */ && - n.flags & 16777216 /* Ambient */) { - if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { + if (n.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */ && + n.parent.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + n.parent.kind !== 226 /* SyntaxKind.ClassExpression */ && + n.flags & 16777216 /* NodeFlags.Ambient */) { + if (!(flags & 2 /* ModifierFlags.Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; } return flags & flagsToCheck; } @@ -81625,16 +81923,16 @@ var ts; var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; - if (deviation & 1 /* Export */) { + if (deviation & 1 /* ModifierFlags.Export */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 2 /* ModifierFlags.Ambient */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 128 /* Abstract */) { + else if (deviation & 128 /* ModifierFlags.Abstract */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -81651,8 +81949,8 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; - var someNodeFlags = 0 /* None */; + var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */; + var someNodeFlags = 0 /* ModifierFlags.None */; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; var allHaveQuestionToken = true; @@ -81661,7 +81959,7 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0; function reportImplementationExpectedError(node) { if (node.name && ts.nodeIsMissing(node.name)) { return; @@ -81690,7 +81988,7 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */) && + var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) && ts.isStatic(node) !== ts.isStatic(subsequentNode); // we can get here in two cases // 1. mixed static and instance class members @@ -81715,7 +82013,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -81731,8 +82029,8 @@ var ts; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var current = declarations_5[_i]; var node = current; - var inAmbientContext = node.flags & 16777216 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -81743,10 +82041,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 256 /* FunctionDeclaration */ || node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */ || node.kind === 171 /* Constructor */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */ || node.kind === 171 /* SyntaxKind.Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -81790,13 +82088,13 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { - var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* ClassDeclaration */; }) + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* SymbolFlags.Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* SyntaxKind.ClassDeclaration */; }) .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - var diagnostic = declaration.kind === 257 /* ClassDeclaration */ + var diagnostic = declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 - : declaration.kind === 256 /* FunctionDeclaration */ + : declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : undefined; if (diagnostic) { @@ -81806,7 +82104,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* ModifierFlags.Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -81846,15 +82144,15 @@ var ts; if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; + var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 512 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */); + if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) { + if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -81887,56 +82185,56 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: - return 2 /* ExportType */; - case 261 /* ModuleDeclaration */: - return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4 /* ExportNamespace */ | 1 /* ExportValue */ - : 4 /* ExportNamespace */; - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - return 2 /* ExportType */ | 1 /* ExportValue */; - case 305 /* SourceFile */: - return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + return 2 /* DeclarationSpaces.ExportType */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* ModuleInstanceState.NonInstantiated */ + ? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */ + : 4 /* DeclarationSpaces.ExportNamespace */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */; + case 305 /* SyntaxKind.SourceFile */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */; + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: var node_2 = d; var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(expression)) { - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; } d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: - var result_12 = 0 /* None */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + var result_12 = 0 /* DeclarationSpaces.None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 256 /* FunctionDeclaration */: - case 270 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* SyntaxKind.Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) // or SyntaxKind.PropertyAccessExpression - `thing.aField = 42;` // all of which are pretty much always values, or at least imply a value meaning. // It may be apprpriate to treat these as aliases in the future. - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); } @@ -81972,14 +82270,14 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } // primitives with a `{ then() }` won't be unwrapped/adopted. - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { return undefined; } var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : ts.emptyArray; + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* SignatureKind.Call */) : ts.emptyArray; if (thenSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); @@ -82008,18 +82306,18 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* TypeFacts.NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* SignatureKind.Call */); if (onfulfilledParameterSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); } return undefined; } - return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* Subtype */); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* UnionReduction.Subtype */); } /** * Gets the "awaited type" of a type. @@ -82039,16 +82337,16 @@ var ts; * Determines whether a type is an object with a callable `then` member. */ function isThenableType(type) { - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { // primitive types cannot be considered "thenable" since they are not objects. return false; } var thenFunction = getTypeOfPropertyOfType(type, "then"); - return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; + return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* TypeFacts.NEUndefinedOrNull */), 0 /* SignatureKind.Call */).length > 0; } function isAwaitedTypeInstantiation(type) { var _a; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false); return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1; } @@ -82058,10 +82356,38 @@ var ts; * For a generic `Awaited`, gets `T`. */ function unwrapAwaitedType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, unwrapAwaitedType) : isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } + function isAwaitedTypeNeeded(type) { + // If this is already an `Awaited`, we shouldn't wrap it. This helps to avoid `Awaited>` in higher-order. + if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) { + return false; + } + // We only need `Awaited` if `T` contains possibly non-primitive types. + if (isGenericObjectType(type)) { + var baseConstraint = getBaseConstraintOfType(type); + // We only need `Awaited` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, + // or is promise-like. + if (baseConstraint ? + baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) : + maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) { + return true; + } + } + return false; + } + function tryCreateAwaitedType(type) { + // Nothing to do if `Awaited` doesn't exist + var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); + if (awaitedSymbol) { + // Unwrap unions that may contain `Awaited`, otherwise its possible to manufacture an `Awaited | U>` where + // an `Awaited` would suffice. + return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); + } + return undefined; + } function createAwaitedTypeIfNeeded(type) { // We wrap type `T` in `Awaited` based on the following conditions: // - `T` is not already an `Awaited`, and @@ -82070,26 +82396,10 @@ var ts; // - `T` has no base constraint, or // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or // - The base constraint of `T` is an object type with a callable `then` method. - if (isTypeAny(type)) { - return type; - } - // If this is already an `Awaited`, just return it. This helps to avoid `Awaited>` in higher-order. - if (isAwaitedTypeInstantiation(type)) { - return type; - } - // Only instantiate `Awaited` if `T` contains possibly non-primitive types. - if (isGenericObjectType(type)) { - var baseConstraint = getBaseConstraintOfType(type); - // Only instantiate `Awaited` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, - // or is promise-like. - if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { - // Nothing to do if `Awaited` doesn't exist - var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); - if (awaitedSymbol) { - // Unwrap unions that may contain `Awaited`, otherwise its possible to manufacture an `Awaited | U>` where - // an `Awaited` would suffice. - return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); - } + if (isAwaitedTypeNeeded(type)) { + var awaitedType = tryCreateAwaitedType(type); + if (awaitedType) { + return awaitedType; } } ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like."); @@ -82128,9 +82438,22 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } // For a union, get a union of the awaited types of each constituent. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { + if (awaitedTypeStack.lastIndexOf(type.id) >= 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; - return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); + awaitedTypeStack.push(type.id); + var mapped = mapType(type, mapper); + awaitedTypeStack.pop(); + return typeAsAwaitable.awaitedTypeOfType = mapped; + } + // If `type` is generic and should be wrapped in `Awaited`, return it. + if (isAwaitedTypeNeeded(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; } var thisTypeForErrorOut = { value: undefined }; var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut); @@ -82251,7 +82574,7 @@ var ts; // } // var returnType = getTypeFromTypeNode(returnTypeNode); - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { if (isErrorType(returnType)) { return; } @@ -82274,10 +82597,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (isErrorType(promiseConstructorType)) { - if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* SyntaxKind.Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -82297,7 +82620,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* SymbolFlags.Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -82310,26 +82633,26 @@ var ts; var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { + if (returnType.flags & 1 /* TypeFlags.Any */) { return; } var headMessage; var expectedReturnType; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any; expectedReturnType = voidType; break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); @@ -82351,9 +82674,9 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* SyntaxKind.Identifier */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */) | 2097152 /* SymbolFlags.Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true); - if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) { + if (rootSymbol && rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) { if (symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) { @@ -82388,15 +82711,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; } } @@ -82405,13 +82728,13 @@ var ts; var commonEntityName; for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { var typeNode = types_21[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */ || typeNode.kind === 197 /* SyntaxKind.NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -82456,15 +82779,15 @@ var ts; if (!firstDecorator) { return; } - checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 164 /* Parameter */) { - checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + checkExternalEmitHelpers(firstDecorator, 8 /* ExternalEmitHelpers.Decorate */); + if (node.kind === 164 /* SyntaxKind.Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* ExternalEmitHelpers.Param */); } if (compilerOptions.emitDecoratorMetadata) { - checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); + checkExternalEmitHelpers(firstDecorator, 16 /* ExternalEmitHelpers.Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -82473,23 +82796,23 @@ var ts; } } break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - var otherKind = node.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + var otherKind = node.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -82589,9 +82912,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; default: return undefined; @@ -82605,7 +82928,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -82621,7 +82944,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find( // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* NodeFlags.JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -82631,7 +82954,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 168 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 168 /* SyntaxKind.MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics); @@ -82649,7 +82972,7 @@ var ts; if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { reportImplicitAny(node, anyType); } - if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) { + if (functionFlags & 1 /* FunctionFlags.Generator */ && ts.nodeIsPresent(body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -82677,42 +83000,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 305 /* SourceFile */: - case 261 /* ModuleDeclaration */: - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 305 /* SyntaxKind.SourceFile */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -82723,41 +83046,41 @@ var ts; function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(declaration, 0 /* Local */, ts.createDiagnosticForNode(node, message, name)); + addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name)); } function isIdentifierThatStartsWithUnderscore(node) { - return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; + return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* CharacterCodes._ */; } function checkUnusedClassMembers(node, addDiagnostic) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - if (member.kind === 173 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && member.symbol.flags & 32768 /* SymbolFlags.GetAccessor */) { // Already would have reported an error on the getter. break; } var symbol = getSymbolOfNode(member); if (!symbol.isReferenced - && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) - && !(member.flags & 16777216 /* Ambient */)) { - addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); + && (ts.hasEffectiveModifier(member, 8 /* ModifierFlags.Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) + && !(member.flags & 16777216 /* NodeFlags.Ambient */)) { + addDiagnostic(member, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { - addDiagnostic(parameter, 0 /* Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); + if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* ModifierFlags.Private */)) { + addDiagnostic(parameter, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); } } break; - case 176 /* IndexSignature */: - case 234 /* SemicolonClassElement */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 234 /* SyntaxKind.SemicolonClassElement */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Can't be private break; default: @@ -82768,7 +83091,7 @@ var ts; function checkUnusedInferTypeParameter(node, addDiagnostic) { var typeParameter = node.typeParameter; if (isTypeParameterUnused(typeParameter)) { - addDiagnostic(node, 1 /* Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); + addDiagnostic(node, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); } } function checkUnusedTypeParameters(node, addDiagnostic) { @@ -82779,13 +83102,13 @@ var ts; return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); - for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { - var typeParameter = typeParameters_3[_i]; + for (var _i = 0, typeParameters_4 = typeParameters; _i < typeParameters_4.length; _i++) { + var typeParameter = typeParameters_4[_i]; if (!isTypeParameterUnused(typeParameter)) continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 190 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 190 /* SyntaxKind.InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -82797,17 +83120,17 @@ var ts; //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); } } else { //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); } } } function isTypeParameterUnused(typeParameter) { - return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); + return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* SymbolFlags.TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); } function addToGroup(map, key, value, getKey) { var keyString = String(getKey(key)); @@ -82844,7 +83167,7 @@ var ts; nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. - if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { + if (local.flags & 262144 /* SymbolFlags.TypeParameter */ ? !(local.flags & 3 /* SymbolFlags.Variable */ && !(local.isReferenced & 3 /* SymbolFlags.Variable */)) : local.isReferenced || local.exportSymbol) { return; } if (local.declarations) { @@ -82875,7 +83198,7 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } else { - addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + addDiagnostic(parameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } } @@ -82891,10 +83214,10 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 268 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { - addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 + addDiagnostic(importDecl, 0 /* UnusedKind.Local */, unuseds.length === 1 ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); } @@ -82907,9 +83230,9 @@ var ts; }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; - var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; + var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -82928,14 +83251,14 @@ var ts; unusedVariables.forEach(function (_a) { var declarationList = _a[0], declarations = _a[1]; if (declarationList.declarations.length === declarations.length) { - addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 + addDiagnostic(declarationList, 0 /* UnusedKind.Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { var decl = declarations_6[_i]; - addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); + addDiagnostic(decl, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); } } }); @@ -82958,24 +83281,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.idText(name); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 267 /* ImportClause */ || node.kind === 270 /* ImportSpecifier */ || node.kind === 268 /* NamespaceImport */; + return node.kind === 267 /* SyntaxKind.ImportClause */ || node.kind === 270 /* SyntaxKind.ImportSpecifier */ || node.kind === 268 /* SyntaxKind.NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 267 /* ImportClause */ ? decl : decl.kind === 268 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 267 /* SyntaxKind.ImportClause */ ? decl : decl.kind === 268 /* SyntaxKind.NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 235 /* Block */) { + if (node.kind === 235 /* SyntaxKind.Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -82992,7 +83315,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* NodeFlags.Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -83010,17 +83333,17 @@ var ts; if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - if (node.kind === 167 /* PropertyDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 169 /* MethodDeclaration */ || - node.kind === 168 /* MethodSignature */ || - node.kind === 172 /* GetAccessor */ || - node.kind === 173 /* SetAccessor */ || - node.kind === 296 /* PropertyAssignment */) { + if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */ || + node.kind === 168 /* SyntaxKind.MethodSignature */ || + node.kind === 172 /* SyntaxKind.GetAccessor */ || + node.kind === 173 /* SyntaxKind.SetAccessor */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */) { // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // ambient context - no codegen impact return false; } @@ -83040,8 +83363,8 @@ var ts; // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 4 /* NodeCheckFlags.CaptureThis */) { + var isDeclaration_1 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -83055,8 +83378,8 @@ var ts; } function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 8 /* NodeCheckFlags.CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -83077,46 +83400,46 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { + if (!name || languageVersion >= 4 /* ScriptTarget.ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* NodeFlags.HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) { - if (languageVersion <= 8 /* ES2021 */ + if (languageVersion <= 8 /* ScriptTarget.ES2021 */ && (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) { potentialWeakMapSetCollisions.push(node); } } function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); - if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { + if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */) { ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); } } function recordPotentialCollisionWithReflectInGeneratedCode(node, name) { - if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ + if (name && languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && needCollisionCheckForIdentifier(node, name, "Reflect")) { potentialReflectCollisions.push(node); } @@ -83127,7 +83450,7 @@ var ts; // ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(member) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; break; } @@ -83135,13 +83458,13 @@ var ts; } else if (ts.isFunctionExpression(node)) { // FunctionExpression names don't contribute to their containers, but do matter for their contents - if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(node) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } else { var container = ts.getEnclosingBlockScopeContainer(node); - if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (container && getNodeCheckFlags(container) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } @@ -83159,7 +83482,7 @@ var ts; recordPotentialCollisionWithReflectInGeneratedCode(node, name); if (ts.isClassLike(node)) { checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0); - if (!(node.flags & 16777216 /* Ambient */)) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */)) { checkClassNameCollisionWithObject(name); } } @@ -83191,35 +83514,35 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3 /* NodeFlags.BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 254 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { + if (symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) return ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* SymbolFlags.Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 237 /* VariableStatement */ && varDeclList.parent.parent + localDeclarationSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* NodeFlags.BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); + var container = varDeclList.parent.kind === 237 /* SyntaxKind.VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 235 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 262 /* ModuleBlock */ || - container.kind === 261 /* ModuleDeclaration */ || - container.kind === 305 /* SourceFile */); + (container.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(container.parent) || + container.kind === 262 /* SyntaxKind.ModuleBlock */ || + container.kind === 261 /* SyntaxKind.ModuleDeclaration */ || + container.kind === 305 /* SyntaxKind.SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -83250,7 +83573,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { checkExpressionCached(node.initializer); @@ -83268,16 +83591,16 @@ var ts; potentialUnusedRenamedBindingElementsInTypes.push(node); return; } - if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { - checkExternalEmitHelpers(node, 4 /* Rest */); + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ScriptTarget.ES2018 */) { + checkExternalEmitHelpers(node, 4 /* ExternalEmitHelpers.Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 162 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access var parent = node.parent.parent; - var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var parentCheckMode = node.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(parent, parentCheckMode); var name = node.propertyName || node.name; if (parentType && !ts.isBindingPattern(name)) { @@ -83287,15 +83610,15 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SyntaxKind.SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 202 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (node.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } ts.forEach(node.name.elements, checkSourceElement); } @@ -83306,7 +83629,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = ts.hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */; + var needCheckInitializer = ts.hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */; var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression)); if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -83323,7 +83646,7 @@ var ts; // check the binding pattern with empty elements if (needCheckWidenedType) { if (ts.isArrayBindingPattern(node.name)) { - checkIteratedTypeOrElementType(65 /* Destructuring */, widenedType, undefinedType, node); + checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, widenedType, undefinedType, node); } else if (strictNullChecks) { checkNonNullNonVoidType(widenedType, node); @@ -83334,7 +83657,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* SyntaxKind.BindingElement */ ? node.parent.parent : node)) { checkAliasSymbol(node); return; } @@ -83348,7 +83671,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -83364,7 +83687,7 @@ var ts; var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (!isErrorType(type) && !isErrorType(declarationType) && !isTypeIdenticalTo(type, declarationType) && - !(symbol.flags & 67108864 /* Assignment */)) { + !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { @@ -83374,10 +83697,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */) { + if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionsForDeclarationName(node, node.name); @@ -83385,7 +83708,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 167 /* PropertyDeclaration */ || nextDeclaration.kind === 166 /* PropertySignature */ + var message = nextDeclaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 166 /* SyntaxKind.PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -83395,24 +83718,24 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 164 /* Parameter */ && right.kind === 254 /* VariableDeclaration */) || - (left.kind === 254 /* VariableDeclaration */ && right.kind === 164 /* Parameter */)) { + if ((left.kind === 164 /* SyntaxKind.Parameter */ && right.kind === 254 /* SyntaxKind.VariableDeclaration */) || + (left.kind === 254 /* SyntaxKind.VariableDeclaration */ && right.kind === 164 /* SyntaxKind.Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* ModifierFlags.Private */ | + 16 /* ModifierFlags.Protected */ | + 256 /* ModifierFlags.Async */ | + 128 /* ModifierFlags.Abstract */ | + 64 /* ModifierFlags.Readonly */ | + 32 /* ModifierFlags.Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -83438,7 +83761,7 @@ var ts; checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 236 /* EmptyStatement */) { + if (node.thenStatement.kind === 236 /* SyntaxKind.EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -83447,27 +83770,27 @@ var ts; if (!strictNullChecks) return; helper(condExpr, body); - while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) { + while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { condExpr = condExpr.left; helper(condExpr, body); } function helper(condExpr, body) { var location = ts.isBinaryExpression(condExpr) && - (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */) + (condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || condExpr.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) ? condExpr.right : condExpr; if (ts.isModuleExportsAccessExpression(location)) return; var type = checkTruthinessExpression(location); var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression); - if (!(getTypeFacts(type) & 4194304 /* Truthy */) || isPropertyExpressionCast) + if (!(getTypeFacts(type) & 4194304 /* TypeFacts.Truthy */) || isPropertyExpressionCast) return; // While it technically should be invalid for any known-truthy value // to be tested, we de-scope to functions and Promises unreferenced in // the block as a heuristic to identify the most common bugs. There // are too many false positives for values sourced from type // definitions without strictNullChecks otherwise. - var callSignatures = getSignaturesOfType(type, 0 /* Call */); + var callSignatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var isPromise = !!getAwaitedTypeOfPromise(type); if (callSignatures.length === 0 && !isPromise) { return; @@ -83507,7 +83830,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { + testedExpression.kind === 108 /* SyntaxKind.ThisKeyword */ && childExpression.kind === 108 /* SyntaxKind.ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -83531,7 +83854,7 @@ var ts; }); } function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { - while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { var symbol = getSymbolAtLocation(child); @@ -83561,7 +83884,7 @@ var ts; checkSourceElement(node.statement); } function checkTruthinessOfType(type, node) { - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -83572,12 +83895,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -83602,29 +83925,29 @@ var ts; } else { var functionFlags = ts.getFunctionFlags(container); - if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { + if ((functionFlags & (4 /* FunctionFlags.Invalid */ | 2 /* FunctionFlags.Async */)) === 2 /* FunctionFlags.Async */ && languageVersion < 99 /* ScriptTarget.ESNext */) { // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper - checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + checkExternalEmitHelpers(node, 16384 /* ExternalEmitHelpers.ForAwaitOfIncludes */); } } } - else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) { + else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ScriptTarget.ES2015 */) { // for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled - checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.ForOfIncludes */); } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -83656,7 +83979,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -83670,7 +83993,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -83683,7 +84006,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -83700,7 +84023,7 @@ var ts; } } function checkRightHandSideOfForOf(statement) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) { @@ -83715,14 +84038,14 @@ var ts; * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) { - var allowAsyncIterables = (use & 2 /* AllowsAsyncIterablesFlag */) !== 0; + var allowAsyncIterables = (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) !== 0; if (inputType === neverType) { reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } - var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var uplevelIteration = languageVersion >= 2 /* ScriptTarget.ES2015 */; var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; - var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */); + var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* IterationUse.PossiblyOutOfBounds */); // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. @@ -83731,10 +84054,10 @@ var ts; var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined); if (checkAssignability) { if (iterationTypes) { - var diagnostic = use & 8 /* ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : - use & 32 /* SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : - use & 64 /* DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : - use & 16 /* YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : + var diagnostic = use & 8 /* IterationUse.ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : + use & 32 /* IterationUse.SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : + use & 64 /* IterationUse.DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : + use & 16 /* IterationUse.YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : undefined; if (diagnostic) { checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic); @@ -83751,22 +84074,22 @@ var ts; // If strings are permitted, remove any string-like constituents from the array type. // This allows us to find other non-string element types from an array unioned with // a string. - if (use & 4 /* AllowsStringInputFlag */) { - if (arrayType.flags & 1048576 /* Union */) { + if (use & 4 /* IterationUse.AllowsStringInputFlag */) { + if (arrayType.flags & 1048576 /* TypeFlags.Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* TypeFlags.StringLike */); }); if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, 2 /* Subtype */); + arrayType = getUnionType(filteredTypes, 2 /* UnionReduction.Subtype */); } } - else if (arrayType.flags & 402653316 /* StringLike */) { + else if (arrayType.flags & 402653316 /* TypeFlags.StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { if (errorNode) { error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); reportedError = true; @@ -83774,7 +84097,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 131072 /* Never */) { + if (arrayType.flags & 131072 /* TypeFlags.Never */) { return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType; } } @@ -83786,7 +84109,7 @@ var ts; // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var allowsStrings = !!(use & 4 /* IterationUse.AllowsStringInputFlag */) && !hasStringConstituent; var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } @@ -83795,12 +84118,12 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, numberType); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { + if (arrayElementType.flags & 402653316 /* TypeFlags.StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } - return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); + return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* UnionReduction.Subtype */); } - return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + return (use & 128 /* IterationUse.PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { var _a; if (downlevelIteration) { @@ -83808,7 +84131,7 @@ var ts; ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] : [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]; } - var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); + var yieldType = getIterationTypeOfIterable(use, 0 /* IterationTypeKind.Yield */, inputType, /*errorNode*/ undefined); if (yieldType) { return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } @@ -83857,9 +84180,9 @@ var ts; // more frequently created (i.e. `Iterator`). Iteration types // are also cached on the type they are requested for, so we shouldn't need to maintain // the cache for less-frequently used types. - if (yieldType.flags & 67359327 /* Intrinsic */ && - returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && - nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) { + if (yieldType.flags & 67359327 /* TypeFlags.Intrinsic */ && + returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */) && + nextType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { var id = getTypeListId([yieldType, returnType, nextType]); var iterationTypes = iterationTypesCache.get(id); if (!iterationTypes) { @@ -83926,37 +84249,56 @@ var ts; * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method. */ function getIterationTypesOfIterable(type, use, errorNode) { + var _a, _b; if (isTypeAny(type)) { return anyIterationTypes; } - if (!(type.flags & 1048576 /* Union */)) { - var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } return undefined; } + else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) { + for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) { + var diag = _c[_i]; + diagnostics.add(diag); + } + } return iterationTypes_1; } - var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; + var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; var cachedTypes = getCachedIterationTypes(type, cacheKey); if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; var allIterationTypes; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituent = _a[_i]; - var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); + for (var _d = 0, _e = type.types; _d < _e.length; _d++) { + var constituent = _e[_d]; + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; } - else { - allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); + else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) { + for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) { + var diag = _g[_f]; + diagnostics.add(diag); + } } + allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); } var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes; setCachedIterationTypes(type, cacheKey, iterationTypes); @@ -83984,47 +84326,62 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterable` instead. */ - function getIterationTypesOfIterableWorker(type, use, errorNode) { + function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) { if (isTypeAny(type)) { return anyIterationTypes; } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + // If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached. + // In addition, we should not cache any new results for this call. + var noCache = false; + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 /* ForOfFlag */ ? - getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : - iterationTypes; + if (iterationTypes === noIterationTypes && errorNode) { + // ignore the cached value + noCache = true; + } + else { + return use & 8 /* IterationUse.ForOfFlag */ ? + getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : + iterationTypes; + } } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { - // for a sync iterable in an async context, only use the cached types if they are valid. - if (iterationTypes !== noIterationTypes) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); - } + if (iterationTypes === noIterationTypes && errorNode) { + // ignore the cached value + noCache = true; } else { - return iterationTypes; + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + // for a sync iterable in an async context, only use the cached types if they are valid. + if (iterationTypes !== noIterationTypes) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); + } + } + else { + return iterationTypes; + } } } } - if (use & 2 /* AllowsAsyncIterablesFlag */) { - var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { - var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { + var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes - ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) - : noIterationTypes); + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); } else { return iterationTypes; @@ -84045,7 +84402,7 @@ var ts; } function getIterationTypesOfGlobalIterableType(globalType, resolver) { var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) || - getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined); + getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false); return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes; } /** @@ -84087,7 +84444,7 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like @@ -84099,26 +84456,26 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterable` instead. */ - function getIterationTypesOfIterableSlow(type, resolver, errorNode) { + function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); - var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; + var methodType = method && !(method.flags & 16777216 /* SymbolFlags.Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); + return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } - var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : undefined; if (!ts.some(signatures)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); + return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature)); - var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes; - return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); + var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes; + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); } function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) { var message = allowAsyncIterables ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator; - errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); + return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); } /** * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type. @@ -84126,13 +84483,29 @@ var ts; * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` * record is returned. Otherwise, `undefined` is returned. */ - function getIterationTypesOfIterator(type, resolver, errorNode) { + function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) { + return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false); + } + /** + * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type. + * + * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` + * record is returned. Otherwise, `undefined` is returned. + * + * NOTE: You probably don't want to call this directly and should be calling + * `getIterationTypesOfIterator` instead. + */ + function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) { if (isTypeAny(type)) { return anyIterationTypes; } var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) || - getIterationTypesOfIteratorFast(type, resolver) || - getIterationTypesOfIteratorSlow(type, resolver, errorNode); + getIterationTypesOfIteratorFast(type, resolver); + if (iterationTypes === noIterationTypes && errorNode) { + iterationTypes = undefined; + noCache = true; + } + iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache)); return iterationTypes === noIterationTypes ? undefined : iterationTypes; } /** @@ -84170,7 +84543,7 @@ var ts; // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || - getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined); + getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false); var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType; return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType)); } @@ -84186,13 +84559,13 @@ var ts; // > If the end was not reached `done` is `false` and a value is available. // > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`. var doneType = getTypeOfPropertyOfType(type, "done") || falseType; - return isTypeAssignableTo(kind === 0 /* Yield */ ? falseType : trueType, doneType); + return isTypeAssignableTo(kind === 0 /* IterationTypeKind.Yield */ ? falseType : trueType, doneType); } function isYieldIteratorResult(type) { - return isIteratorResult(type, 0 /* Yield */); + return isIteratorResult(type, 0 /* IterationTypeKind.Yield */); } function isReturnIteratorResult(type) { - return isIteratorResult(type, 1 /* Return */); + return isIteratorResult(type, 1 /* IterationTypeKind.Return */); } /** * Gets the *yield* and *return* types of an `IteratorResult`-like type. @@ -84240,30 +84613,36 @@ var ts; * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` * record is returned. Otherwise, we return `undefined`. */ - function getIterationTypesOfMethod(type, resolver, methodName, errorNode) { - var _a, _b, _c, _d; + function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) { + var _a, _b, _c, _d, _e, _f; var method = getPropertyOfType(type, methodName); // Ignore 'return' or 'throw' if they are missing. if (!method && methodName !== "next") { return undefined; } - var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* Optional */)) - ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */) + var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* SymbolFlags.Optional */)) + ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* TypeFacts.NEUndefinedOrNull */) : undefined; if (isTypeAny(methodType)) { // `return()` and `throw()` don't provide a *next* type. return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext; } // Both async and non-async iterators *must* have a `next` method. - var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : ts.emptyArray; + var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : ts.emptyArray; if (methodSignatures.length === 0) { if (errorNode) { var diagnostic = methodName === "next" ? resolver.mustHaveANextMethodDiagnostic : resolver.mustBeAMethodDiagnostic; - error(errorNode, diagnostic, methodName); + if (errorOutputContainer) { + (_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName)); + } + else { + error(errorNode, diagnostic, methodName); + } } - return methodName === "next" ? anyIterationTypes : undefined; + return methodName === "next" ? noIterationTypes : undefined; } // If the method signature comes exclusively from the global iterator or generator type, // create iteration types from its type arguments like `getIterationTypesOfIteratorFast` @@ -84275,8 +84654,8 @@ var ts; if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) { var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false); var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false); - var isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get(methodName)) === methodType.symbol; - var isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) === null || _c === void 0 ? void 0 : _c.members) === null || _d === void 0 ? void 0 : _d.get(methodName)) === methodType.symbol; + var isGeneratorMethod = ((_c = (_b = globalGeneratorType.symbol) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.get(methodName)) === methodType.symbol; + var isIteratorMethod = !isGeneratorMethod && ((_e = (_d = globalIteratorType.symbol) === null || _d === void 0 ? void 0 : _d.members) === null || _e === void 0 ? void 0 : _e.get(methodName)) === methodType.symbol; if (isGeneratorMethod || isIteratorMethod) { var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType; var mapper = methodType.mapper; @@ -84316,7 +84695,13 @@ var ts; var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType); if (iterationTypes === noIterationTypes) { if (errorNode) { - error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + if (errorOutputContainer) { + (_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName)); + } + else { + error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + } } yieldType = anyType; returnTypes = ts.append(returnTypes, anyType); @@ -84337,13 +84722,13 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterator` instead. */ - function getIterationTypesOfIteratorSlow(type, resolver, errorNode) { + function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var iterationTypes = combineIterationTypes([ - getIterationTypesOfMethod(type, resolver, "next", errorNode), - getIterationTypesOfMethod(type, resolver, "return", errorNode), - getIterationTypesOfMethod(type, resolver, "throw", errorNode), + getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer), ]); - return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); } /** * Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like, @@ -84361,10 +84746,10 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + var use = isAsyncGenerator ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) || - getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined); + getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined); } function checkBreakOrContinueStatement(node) { // Grammar checking @@ -84373,15 +84758,20 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { - var isGenerator = !!(functionFlags & 1 /* Generator */); - var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : - isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : - returnType; + var isGenerator = !!(functionFlags & 1 /* FunctionFlags.Generator */); + var isAsync = !!(functionFlags & 2 /* FunctionFlags.Async */); + if (isGenerator) { + var returnIterationType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, isAsync); + if (!returnIterationType) { + return errorType; + } + return isAsync ? getAwaitedTypeNoAlias(unwrapAwaitedType(returnIterationType)) : returnIterationType; + } + return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* TypeFlags.Void */ | 3 /* TypeFlags.AnyOrUnknown */); } function checkReturnStatement(node) { var _a; @@ -84401,21 +84791,21 @@ var ts; var signature = getSignatureFromDeclaration(container); var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(container); - if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* TypeFlags.Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (container.kind === 173 /* SetAccessor */) { + if (container.kind === 173 /* SyntaxKind.SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (getReturnTypeFromAnnotation(container)) { var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; - var unwrappedExprType = functionFlags & 2 /* Async */ + var unwrappedExprType = functionFlags & 2 /* FunctionFlags.Async */ ? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; if (unwrappedReturnType) { @@ -84426,7 +84816,7 @@ var ts; } } } - else if (container.kind !== 171 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { + else if (container.kind !== 171 /* SyntaxKind.Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -84434,7 +84824,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 32768 /* AwaitContext */) { + if (node.flags & 32768 /* NodeFlags.AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -84455,7 +84845,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 290 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -84464,7 +84854,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause)); } ts.forEach(clause.statements, checkSourceElement); @@ -84501,7 +84891,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 250 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 250 /* SyntaxKind.LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -84533,8 +84923,8 @@ var ts; var declaration = catchClause.variableDeclaration; var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); if (typeNode) { - var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */); - if (type && !(type.flags & 3 /* AnyOrUnknown */)) { + var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */); + if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) { grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } @@ -84546,7 +84936,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -84566,8 +84956,8 @@ var ts; } for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) { - checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); + if (!(isStaticIndex && prop.flags & 4194304 /* SymbolFlags.Prototype */)) { + checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); } } var typeDeclaration = symbol.valueDeclaration; @@ -84596,10 +84986,11 @@ var ts; return; } var indexInfos = getApplicableIndexInfos(type, propNameType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ || - name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; - var _loop_29 = function (info) { + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; + var propDeclaration = declaration && declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || + name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined; + var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var _loop_30 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and @@ -84607,20 +84998,24 @@ var ts; var errorNode = localPropDeclaration || localIndexDeclaration || (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined); if (errorNode && !isTypeAssignableTo(propType, info.type)) { - error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + if (propDeclaration && errorNode !== propDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop))); + } + diagnostics.add(diagnostic); } }; for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) { var info = indexInfos_9[_i]; - _loop_29(info); + _loop_30(info); } } function checkIndexConstraintForIndexSignature(type, checkInfo) { var declaration = checkInfo.declaration; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; - var _loop_30 = function (info) { + var _loop_31 = function (info) { if (info === checkInfo) return "continue"; var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; @@ -84635,7 +85030,7 @@ var ts; }; for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) { var info = indexInfos_10[_i]; - _loop_30(info); + _loop_31(info); } } function checkTypeNameIsReserved(name, message) { @@ -84659,7 +85054,7 @@ var ts; * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name) { - if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" + if (languageVersion >= 1 /* ScriptTarget.ES5 */ && name.escapedText === "Object" && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) { error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } @@ -84738,9 +85133,9 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 178 /* TypeReference */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */) { var type = getTypeFromTypeReference(node); - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { if (type.symbol === getSymbolOfNode(typeParameters[i])) { error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters); @@ -84828,7 +85223,7 @@ var ts; if (firstDecorator && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { grammarErrorOnNode(firstDecorator, ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) { + if (!node.name && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -84849,15 +85244,15 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */); } // check both @extends and extends if both are specified. var extendsNode = ts.getClassExtendsHeritageElement(node); @@ -84889,18 +85284,18 @@ var ts; // Report static side error only when instance type is assignable checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); } - if (baseConstructorType.flags & 8650752 /* TypeVariable */) { + if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) { if (!isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { - var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); + if (constructSignatures.some(function (signature) { return signature.flags & 4 /* SignatureFlags.Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* SymbolFlags.Class */) && !(baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); @@ -84935,7 +85330,7 @@ var ts; var t = getReducedType(getTypeFromTypeNode(typeRefNode)); if (!isErrorType(t)) { if (isValidBaseType(t)) { - var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? + var genericDiag = t.symbol && t.symbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : ts.Diagnostics.Class_0_incorrectly_implements_interface_1; var baseWithThis = getTypeWithThisArgument(t, type.thisType); @@ -84955,7 +85350,7 @@ var ts; var baseTypes = baseTypeNode && getBaseTypes(type); var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined; var baseStaticType = getBaseConstructorTypeOfClass(type); - var _loop_31 = function (member) { + var _loop_32 = function (member) { if (ts.hasAmbientModifier(member)) { return "continue"; } @@ -84972,7 +85367,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_31(member); + _loop_32(member); } } /** @@ -84985,7 +85380,7 @@ var ts; && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); if (!declaredProp) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined); } @@ -84999,7 +85394,7 @@ var ts; */ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) { var isJs = ts.isInJSFile(node); - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { var memberEscapedName = ts.escapeLeadingUnderscores(memberName); var thisType = memberIsStatic ? staticType : typeWithThis; @@ -85018,12 +85413,12 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier); if (memberHasOverrideModifier) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } if (!baseHasAbstract) { if (errorNode) { @@ -85036,13 +85431,13 @@ var ts; ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; error(errorNode, diag, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } else if (memberHasAbstractModifier && baseHasAbstract) { if (errorNode) { error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } } } @@ -85053,14 +85448,14 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_32 = function (member) { + var _loop_33 = function (member) { if (ts.isStatic(member)) { return "continue"; } @@ -85079,7 +85474,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_32(member); + _loop_33(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -85087,10 +85482,10 @@ var ts; } } function checkBaseTypeAccessibility(type, node) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) { var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -85106,7 +85501,7 @@ var ts; */ function getMemberOverrideModifierStatus(node, member) { if (!member.name) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -85118,7 +85513,7 @@ var ts; var baseStaticType = getBaseConstructorTypeOfClass(type); var memberHasOverrideModifier = member.parent ? ts.hasOverrideModifier(member) - : ts.hasSyntacticModifier(member, 16384 /* Override */); + : ts.hasSyntacticModifier(member, 16384 /* ModifierFlags.Override */); var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member), /* memberIsParameterProperty */ false, memberName); @@ -85126,11 +85521,11 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return ts.getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; + return ts.getCheckFlags(s) & 1 /* CheckFlags.Instantiated */ ? s.target : s; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 257 /* ClassDeclaration */ || d.kind === 258 /* InterfaceDeclaration */; + return d.kind === 257 /* SyntaxKind.ClassDeclaration */ || d.kind === 258 /* SyntaxKind.InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -85150,9 +85545,9 @@ var ts; var _a, _b, _c, _d; // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - var _loop_33 = function (baseProperty) { + var _loop_34 = function (baseProperty) { var base = getTargetSymbol(baseProperty); - if (base.flags & 4194304 /* Prototype */) { + if (base.flags & 4194304 /* SymbolFlags.Prototype */) { return "continue"; } var baseSymbol = getPropertyOfObjectType(type, base.escapedName); @@ -85171,7 +85566,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* ModifierFlags.Abstract */))) { // Searches other base types for a declaration that would satisfy the inherited abstract member. // (The class may have more than one base type via declaration merging with an interface with the // same name.) @@ -85185,7 +85580,7 @@ var ts; return "continue-basePropertyCheck"; } } - if (derivedClassDecl.kind === 226 /* ClassExpression */) { + if (derivedClassDecl.kind === 226 /* SyntaxKind.ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -85196,23 +85591,23 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 8 /* ModifierFlags.Private */ || derivedDeclarationFlags & 8 /* ModifierFlags.Private */) { return "continue"; } var errorMessage = void 0; - var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; - var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + var basePropertyFlags = base.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor - if ((ts.getCheckFlags(base) & 6 /* Synthetic */ + if ((ts.getCheckFlags(base) & 6 /* CheckFlags.Synthetic */ ? (_a = base.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); }) : (_b = base.declarations) === null || _b === void 0 ? void 0 : _b.every(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); })) - || ts.getCheckFlags(base) & 262144 /* Mapped */ + || ts.getCheckFlags(base) & 262144 /* CheckFlags.Mapped */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { return "continue"; } - var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */; - var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */; + var overriddenInstanceProperty = basePropertyFlags !== 4 /* SymbolFlags.Property */ && derivedPropertyFlags === 4 /* SymbolFlags.Property */; + var overriddenInstanceAccessor = basePropertyFlags === 4 /* SymbolFlags.Property */ && derivedPropertyFlags !== 4 /* SymbolFlags.Property */; if (overriddenInstanceProperty || overriddenInstanceAccessor) { var errorMessage_1 = overriddenInstanceProperty ? ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property : @@ -85220,12 +85615,12 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !d.initializer; }); if (uninitialized - && !(derived.flags & 33554432 /* Transient */) - && !(baseDeclarationFlags & 128 /* Abstract */) - && !(derivedDeclarationFlags & 128 /* Abstract */) - && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) { + && !(derived.flags & 33554432 /* SymbolFlags.Transient */) + && !(baseDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !(derivedDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* NodeFlags.Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -85241,15 +85636,15 @@ var ts; return "continue"; } else if (isPrototypeProperty(base)) { - if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* SymbolFlags.Property */) { return "continue"; } else { - ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + ts.Debug.assert(!!(derived.flags & 98304 /* SymbolFlags.Accessor */)); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } - else if (base.flags & 98304 /* Accessor */) { + else if (base.flags & 98304 /* SymbolFlags.Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } else { @@ -85260,14 +85655,14 @@ var ts; }; basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; - var state_10 = _loop_33(baseProperty); + var state_10 = _loop_34(baseProperty); switch (state_10) { case "continue-basePropertyCheck": continue basePropertyCheck; } } } function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) { - return baseDeclarationFlags & 128 /* Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer) + return baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer) || ts.isInterfaceDeclaration(declaration.parent); } function getNonInheritedProperties(type, baseTypes, properties) { @@ -85326,20 +85721,20 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) { continue; } if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || containsUndefinedType(type))) { + if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || containsUndefinedType(type))) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -85349,7 +85744,7 @@ var ts; } } function isPropertyWithoutInitializer(node) { - return node.kind === 167 /* PropertyDeclaration */ && + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; @@ -85392,7 +85787,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -85425,7 +85820,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 138 /* IntrinsicKeyword */) { + if (node.type.kind === 138 /* SyntaxKind.IntrinsicKeyword */) { if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); } @@ -85437,8 +85832,8 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { - nodeLinks.flags |= 16384 /* EnumValuesComputed */; + if (!(nodeLinks.flags & 16384 /* NodeCheckFlags.EnumValuesComputed */)) { + nodeLinks.flags |= 16384 /* NodeCheckFlags.EnumValuesComputed */; var autoValue = 0; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -85463,7 +85858,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -85480,7 +85875,7 @@ var ts; var enumKind = getEnumKind(getSymbolOfNode(member.parent)); var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; - var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); + var value = enumKind === 1 /* EnumKind.Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { if (isConstEnum && typeof value === "number" && !isFinite(value)) { error(initializer, isNaN(value) ? @@ -85488,20 +85883,20 @@ var ts; ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); } } - else if (enumKind === 1 /* Literal */) { + else if (enumKind === 1 /* EnumKind.Literal */) { error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members); return 0; } else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 16777216 /* Ambient */) { + else if (member.parent.flags & 16777216 /* NodeFlags.Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { // Only here do we need to check that the initializer is assignable to the enum type. var source = checkExpression(initializer); - if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) { + if (!isTypeAssignableToKind(source, 296 /* TypeFlags.NumberLike */)) { error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); } else { @@ -85511,60 +85906,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 39 /* PlusToken */: return value_2; - case 40 /* MinusToken */: return -value_2; - case 54 /* TildeToken */: return ~value_2; + case 39 /* SyntaxKind.PlusToken */: return value_2; + case 40 /* SyntaxKind.MinusToken */: return -value_2; + case 54 /* SyntaxKind.TildeToken */: return ~value_2; } } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 51 /* BarToken */: return left | right; - case 50 /* AmpersandToken */: return left & right; - case 48 /* GreaterThanGreaterThanToken */: return left >> right; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 47 /* LessThanLessThanToken */: return left << right; - case 52 /* CaretToken */: return left ^ right; - case 41 /* AsteriskToken */: return left * right; - case 43 /* SlashToken */: return left / right; - case 39 /* PlusToken */: return left + right; - case 40 /* MinusToken */: return left - right; - case 44 /* PercentToken */: return left % right; - case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); - } - } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { + case 51 /* SyntaxKind.BarToken */: return left | right; + case 50 /* SyntaxKind.AmpersandToken */: return left & right; + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return left >> right; + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* SyntaxKind.LessThanLessThanToken */: return left << right; + case 52 /* SyntaxKind.CaretToken */: return left ^ right; + case 41 /* SyntaxKind.AsteriskToken */: return left * right; + case 43 /* SyntaxKind.SlashToken */: return left / right; + case 39 /* SyntaxKind.PlusToken */: return left + right; + case 40 /* SyntaxKind.MinusToken */: return left - right; + case 44 /* SyntaxKind.PercentToken */: return left % right; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { return left + right; } break; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return expr.text; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return evaluate(expr.expression); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var identifier = expr; if (ts.isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (isConstantMemberAccess(expr)) { var type = getTypeOfExpression(expr.expression); - if (type.symbol && type.symbol.flags & 384 /* Enum */) { + if (type.symbol && type.symbol.flags & 384 /* SymbolFlags.Enum */) { var name = void 0; - if (expr.kind === 206 /* PropertyAccessExpression */) { + if (expr.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { name = expr.name.escapedText; } else { @@ -85600,9 +85995,9 @@ var ts; if (type === errorType) { return false; } - return node.kind === 79 /* Identifier */ || - node.kind === 206 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 207 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 207 /* SyntaxKind.ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -85636,7 +86031,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 260 /* EnumDeclaration */) { + if (declaration.kind !== 260 /* SyntaxKind.EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -85665,9 +86060,9 @@ var ts; if (declarations) { for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { var declaration = declarations_9[_i]; - if ((declaration.kind === 257 /* ClassDeclaration */ || - (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 16777216 /* Ambient */)) { + if ((declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || + (declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { return declaration; } } @@ -85698,7 +86093,7 @@ var ts; function checkModuleDeclarationDiagnostics() { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 16777216 /* Ambient */; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -85711,7 +86106,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* SyntaxKind.StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -85721,7 +86116,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !inAmbientContext && symbol.declarations && symbol.declarations.length > 1 @@ -85737,10 +86132,10 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* SyntaxKind.ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* NodeCheckFlags.LexicalModuleMergesWithClass */; } } if (isAmbientExternalModule) { @@ -85750,7 +86145,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Transient */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* SymbolFlags.Transient */); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -85782,23 +86177,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -85809,12 +86204,12 @@ var ts; break; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 256 /* FunctionDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -85824,7 +86219,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Transient */); + var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -85835,20 +86230,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } @@ -85862,9 +86257,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 272 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -85907,12 +86302,12 @@ var ts; // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). symbol = getMergedSymbol(symbol.exportSymbol || symbol); // A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within - if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) { + if (ts.isInJSFile(node) && !(target.flags & 111551 /* SymbolFlags.Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) { var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name : ts.isNamedDeclaration(node) ? node.name : node; - ts.Debug.assert(node.kind !== 274 /* NamespaceExport */); - if (node.kind === 275 /* ExportSpecifier */) { + ts.Debug.assert(node.kind !== 274 /* SyntaxKind.NamespaceExport */); + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */) { var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files); var alreadyExportedSymbol = (_b = (_a = ts.getSourceFileOfNode(node).symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.get((node.propertyName || node.name).escapedText); if (alreadyExportedSymbol === target) { @@ -85923,47 +86318,47 @@ var ts; } } else { - ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */); + ts.Debug.assert(node.kind !== 254 /* SyntaxKind.VariableDeclaration */); var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)); var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "..."; var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName); - error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"" + moduleSpecifier + "\")." + importedIdentifier); + error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"".concat(moduleSpecifier, "\").").concat(importedIdentifier)); } return; } - var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | - (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | - (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) | + (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) | + (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 275 /* ExportSpecifier */ ? + var message = node.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } if (compilerOptions.isolatedModules && !ts.isTypeOnlyImportOrExportDeclaration(node) - && !(node.flags & 16777216 /* Ambient */)) { + && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol); - var isType = !(target.flags & 111551 /* Value */); + var isType = !(target.flags & 111551 /* SymbolFlags.Value */); if (isType || typeOnlyAlias) { switch (node.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: { + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { if (compilerOptions.preserveValueImports) { ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name"); var message = isType ? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled; - var name = ts.idText(node.kind === 270 /* ImportSpecifier */ ? node.propertyName || node.name : node.name); + var name = ts.idText(node.kind === 270 /* SyntaxKind.ImportSpecifier */ ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); } - if (isType && node.kind === 265 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* ModifierFlags.Export */)) { error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided); } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // Don't allow re-exporting an export that will be elided when `--isolatedModules` is set. // The exception is that `import type { A } from './a'; export { A }` is allowed // because single-file analysis can determine that the export should be dropped. @@ -85988,15 +86383,15 @@ var ts; } } function isDeprecatedAliasedSymbol(symbol) { - return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } function checkDeprecatedAliasedSymbol(symbol, location) { - if (!(symbol.flags & 2097152 /* Alias */)) + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) return symbol; var targetSymbol = resolveAlias(symbol); if (targetSymbol === unknownSymbol) return targetSymbol; - while (symbol.flags & 2097152 /* Alias */) { + while (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = getImmediateAliasedSymbol(symbol); if (target) { if (target === targetSymbol) @@ -86022,11 +86417,11 @@ var ts; function checkImportBinding(node) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 270 /* ImportSpecifier */ && + if (node.kind === 270 /* SyntaxKind.ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && ts.getESModuleInterop(compilerOptions) && moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } function checkAssertClause(declaration) { @@ -86072,11 +86467,11 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { @@ -86098,20 +86493,20 @@ var ts; checkGrammarDecoratorsAndModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 277 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = ts.getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 788968 /* Type */) { + if (target.flags & 788968 /* SymbolFlags.Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -86120,7 +86515,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -86135,8 +86530,8 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } - if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { - checkExternalEmitHelpers(node, 4194304 /* CreateBinding */); + if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) { + checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */); } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -86144,10 +86539,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 16777216 /* Ambient */; - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && + !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */; + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -86167,12 +86562,12 @@ var ts; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop if (ts.getESModuleInterop(compilerOptions)) { - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { // export * from "foo" - checkExternalEmitHelpers(node, 32768 /* ExportStar */); + checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */); } } } @@ -86182,7 +86577,7 @@ var ts; function checkGrammarExportDeclaration(node) { var _a; if (node.isTypeOnly) { - if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* NamedExports */) { + if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* SyntaxKind.NamedExports */) { return checkGrammarNamedImportsOrExports(node.exportClause); } else { @@ -86192,7 +86587,7 @@ var ts; return false; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 305 /* SourceFile */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 261 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 305 /* SyntaxKind.SourceFile */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -86240,15 +86635,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { - markExportAsReferenced(node); - var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); - if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) { + markExportAsReferenced(node); + } + var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { checkExpressionCached(node.propertyName || node.name); } } @@ -86258,7 +86655,7 @@ var ts; moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.idText(node.propertyName || node.name) === "default") { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } } @@ -86270,8 +86667,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -86288,14 +86685,14 @@ var ts; if (typeAnnotationNode) { checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression); } - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { var id = node.expression; - var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + var sym = resolveEntityName(id, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { markAliasReferenced(sym, id); // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) - var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // However if it is a value, we need to check it's being used correctly checkExpressionCached(node.expression); } @@ -86311,10 +86708,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 16777216 /* NodeFlags.Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -86349,11 +86746,11 @@ var ts; } // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (flags & (1920 /* Namespace */ | 384 /* Enum */)) { + if (flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) { return; } var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration))); - if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + if (flags & 524288 /* SymbolFlags.TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) return; @@ -86403,181 +86800,181 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 237 /* FirstStatement */ && kind <= 253 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 237 /* SyntaxKind.FirstStatement */ && kind <= 253 /* SyntaxKind.LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return checkTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return checkParameter(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return checkPropertyDeclaration(node); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checkPropertySignature(node); - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return checkSignatureDeclaration(node); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return checkMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return checkClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return checkConstructorDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return checkAccessorDeclaration(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return checkTypeReferenceNode(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return checkTypePredicate(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return checkTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return checkTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return checkArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return checkTupleType(node); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return checkUnionOrIntersectionType(node); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 186 /* RestType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: return checkSourceElement(node.type); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return checkThisType(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return checkTypeOperator(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return checkConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return checkInferType(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return checkTemplateLiteralType(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return checkImportType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return checkNamedTupleMember(node); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return checkJSDocTypeTag(node); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return checkJSDocLinkLikeTag(node); - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return checkJSDocParameterTag(node); - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 322 /* JSDocTypeLiteral */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return checkSourceElement(node.type); - case 333 /* JSDocPublicTag */: - case 335 /* JSDocProtectedTag */: - case 334 /* JSDocPrivateTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: return checkJSDocAccessibilityModifiers(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return checkIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return checkMappedType(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return checkFunctionDeclaration(node); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return checkBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return checkVariableStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return checkExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return checkIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return checkDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return checkWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return checkForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return checkForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkForOfStatement(node); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return checkBreakOrContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return checkReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return checkSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return checkThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return checkTryStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checkVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return checkBindingElement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return checkClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return checkEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return checkModuleDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return checkImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return checkExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return checkExportAssignment(node); - case 236 /* EmptyStatement */: - case 253 /* DebuggerStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -86667,7 +87064,7 @@ var ts; function checkNodeDeferred(node) { var enclosingFile = ts.getSourceFileOfNode(node); var links = getNodeLinks(enclosingFile); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { links.deferredNodes || (links.deferredNodes = new ts.Set()); links.deferredNodes.add(node); } @@ -86679,41 +87076,41 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: - case 280 /* JsxOpeningElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: checkAccessorDeclaration(node); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: checkClassExpressionDeferred(node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: checkTypeParameterDeferred(node); break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: checkJsxElementDeferred(node); break; } @@ -86721,7 +87118,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); @@ -86733,9 +87130,9 @@ var ts; return false; } switch (kind) { - case 0 /* Local */: + case 0 /* UnusedKind.Local */: return !!compilerOptions.noUnusedLocals; - case 1 /* Parameter */: + case 1 /* UnusedKind.Parameter */: return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); @@ -86747,7 +87144,7 @@ var ts; // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node) { var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } @@ -86768,7 +87165,7 @@ var ts; // This relies on the results of other lazy diagnostics, so must be computed after them if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { diagnostics.add(diag); } }); @@ -86777,7 +87174,7 @@ var ts; checkPotentialUncheckedRenamedBindingElementsInTypes(); } }); - if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && + if (compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ && !node.isDeclarationFile && ts.isExternalModule(node)) { checkImportsForTypeOnlyConversion(node); @@ -86801,7 +87198,7 @@ var ts; ts.forEach(potentialReflectCollisions, checkReflectCollision); ts.clear(potentialReflectCollisions); } - links.flags |= 1 /* TypeChecked */; + links.flags |= 1 /* NodeCheckFlags.TypeChecked */; } } function getDiagnostics(sourceFile, ct) { @@ -86871,14 +87268,14 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 33554432 /* InWithStatement */) { + if (location.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } var symbols = ts.createSymbolTable(); var isStaticSymbol = false; populateSymbols(); - symbols.delete("this" /* This */); // Not a symbol, a keyword + symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -86886,17 +87283,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 261 /* ModuleDeclaration */: - copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 261 /* SyntaxKind.ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */); break; - case 260 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + case 260 /* SyntaxKind.EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -86904,17 +87301,17 @@ var ts; // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. // falls through - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStaticSymbol) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */); } break; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -86958,7 +87355,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* SyntaxKind.NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -86966,25 +87363,25 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 79 /* Identifier */ && + return name.kind === 79 /* SyntaxKind.Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 163 /* TypeParameter */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 163 /* SyntaxKind.TypeParameter */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return true; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.isTypeOnly; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -86992,16 +87389,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 178 /* TypeReference */; + return node.parent.kind === 178 /* SyntaxKind.TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 206 /* PropertyAccessExpression */) { + while (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 228 /* ExpressionWithTypeArguments */; + return node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -87029,13 +87426,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 161 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 161 /* SyntaxKind.QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 265 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 271 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -87046,12 +87443,12 @@ var ts; function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { - case 1 /* ExportsProperty */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return getSymbolOfNode(entityName.parent); - case 4 /* ThisProperty */: - case 2 /* ModuleExports */: - case 5 /* Property */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: + case 5 /* AssignmentDeclarationKind.Property */: return getSymbolOfNode(entityName.parent.parent); } } @@ -87061,7 +87458,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 200 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 200 /* SyntaxKind.ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -87071,7 +87468,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 206 /* PropertyAccessExpression */ && + name.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { @@ -87081,17 +87478,17 @@ var ts; } } } - if (name.parent.kind === 271 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, - /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 265 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 265 /* SyntaxKind.ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -87107,28 +87504,28 @@ var ts; name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { - var meaning = 0 /* None */; + var meaning = 0 /* SymbolFlags.None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 228 /* ExpressionWithTypeArguments */) { - meaning = 788968 /* Type */; + if (name.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { + meaning = 788968 /* SymbolFlags.Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { - meaning |= 111551 /* Value */; + meaning |= 111551 /* SymbolFlags.Value */; } } else { - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } - meaning |= 2097152 /* Alias */; + meaning |= 2097152 /* SymbolFlags.Alias */; var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined; if (entityNameSymbol) { return entityNameSymbol; } } - if (name.parent.kind === 340 /* JSDocParameterTag */) { + if (name.parent.kind === 340 /* SyntaxKind.JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 163 /* TypeParameter */ && name.parent.parent.kind === 344 /* JSDocTemplateTag */) { + if (name.parent.kind === 163 /* SyntaxKind.TypeParameter */ && name.parent.parent.kind === 344 /* SyntaxKind.JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -87139,8 +87536,8 @@ var ts; return undefined; } var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); - var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */; - if (name.kind === 79 /* Identifier */) { + var meaning = isJSDoc_1 ? 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */ : 111551 /* SymbolFlags.Value */; + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; @@ -87157,16 +87554,16 @@ var ts; else if (ts.isPrivateIdentifier(name)) { return getSymbolForPrivateIdentifierExpression(name); } - else if (name.kind === 206 /* PropertyAccessExpression */ || name.kind === 161 /* QualifiedName */) { + else if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 161 /* SyntaxKind.QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 206 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name, 0 /* Normal */); + if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* CheckMode.Normal */); } else { - checkQualifiedName(name, 0 /* Normal */); + checkQualifiedName(name, 0 /* CheckMode.Normal */); } if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { return resolveJSDocMemberName(name); @@ -87178,12 +87575,12 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 178 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 178 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } - if (name.parent.kind === 177 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + if (name.parent.kind === 177 /* SyntaxKind.TypePredicate */) { + return resolveEntityName(name, /*meaning*/ 1 /* SymbolFlags.FunctionScopedVariable */); } return undefined; } @@ -87198,7 +87595,7 @@ var ts; function resolveJSDocMemberName(name, ignoreErrors, container) { if (ts.isEntityName(name)) { // resolve static values first - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */; var symbol = resolveEntityName(name, meaning, ignoreErrors, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); if (!symbol && ts.isIdentifier(name) && container) { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); @@ -87210,18 +87607,18 @@ var ts; var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left, ignoreErrors, container); var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; if (left) { - var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var proto = left.flags & 111551 /* SymbolFlags.Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); return getPropertyOfType(t, right); } } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -87235,12 +87632,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 203 /* BindingElement */ && - grandParent.kind === 201 /* ObjectBindingPattern */ && + else if (parent.kind === 203 /* SyntaxKind.BindingElement */ && + grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -87249,7 +87646,7 @@ var ts; } } else if (ts.isMetaProperty(parent) && parent.name === node) { - if (parent.keywordToken === 103 /* NewKeyword */ && ts.idText(node) === "target") { + if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") { // `target` in `new.target` return checkNewTargetMetaProperty(parent).symbol; } @@ -87257,7 +87654,7 @@ var ts; // we have a fake expression type made for other reasons already, whose transient `meta` // member should more exactly be the kind of (declarationless) symbol we want. // (See #44364 and #45031 for relevant implementation PRs) - if (parent.keywordToken === 100 /* ImportKeyword */ && ts.idText(node) === "meta") { + if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") { return getGlobalImportMetaExpressionType().members.get("meta"); } // no other meta properties are valid syntax, thus no others should have symbols @@ -87265,15 +87662,15 @@ var ts; } } switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: if (!ts.isThisInTypeQuery(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } // falls through - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -87285,25 +87682,25 @@ var ts; return checkExpression(node).symbol; } // falls through - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkExpression(node).symbol; - case 134 /* ConstructorKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 171 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 171 /* SyntaxKind.Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // 1). import x = require("./mo/*gotToDefinitionHere*/d") // 2). External module name in an import declaration // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 266 /* ImportDeclaration */ || node.parent.kind === 272 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.parent.kind === 272 /* SyntaxKind.ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -87312,7 +87709,7 @@ var ts; return getSymbolOfNode(parent); } // falls through - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: // index access var objectType = ts.isElementAccessExpression(parent) ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined @@ -87320,19 +87717,19 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 88 /* DefaultKeyword */: - case 98 /* FunctionKeyword */: - case 38 /* EqualsGreaterThanToken */: - case 84 /* ClassKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 84 /* SyntaxKind.ClassKeyword */: return getSymbolOfNode(node.parent); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; - case 100 /* ImportKeyword */: - case 103 /* NewKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkExpression(node).symbol; default: return undefined; @@ -87342,14 +87739,14 @@ var ts; if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { var keyType_1 = getLiteralTypeFromPropertyName(node); var objectType = getTypeOfExpression(node.parent.expression); - var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType]; + var objectTypes = objectType.flags & 1048576 /* TypeFlags.Union */ ? objectType.types : [objectType]; return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); }); } return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 297 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */); } return undefined; } @@ -87358,17 +87755,17 @@ var ts; if (ts.isExportSpecifier(node)) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } else { - return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + return resolveEntityName(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } } function getTypeOfNode(node) { if (ts.isSourceFile(node) && !ts.isExternalModule(node)) { return errorType; } - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -87409,7 +87806,7 @@ var ts; return errorType; } if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType; + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType; } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolAtLocation(node); @@ -87430,23 +87827,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 205 /* ObjectLiteralExpression */ || expr.kind === 204 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 244 /* ForOfStatement */) { + if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 221 /* BinaryExpression */) { + if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 296 /* PropertyAssignment */) { + if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) { var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); @@ -87456,7 +87853,7 @@ var ts; var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -87489,14 +87886,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return getStringLiteralType(ts.idText(name)); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getStringLiteralType(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* TypeFlags.ESSymbolLike */) ? nameType : stringType; default: return ts.Debug.fail("Unsupported property name."); } @@ -87506,8 +87903,8 @@ var ts; function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = ts.createSymbolTable(getPropertiesOfType(type)); - var functionType = getSignaturesOfType(type, 0 /* Call */).length ? globalCallableFunctionType : - getSignaturesOfType(type, 1 /* Construct */).length ? globalNewableFunctionType : + var functionType = getSignaturesOfType(type, 0 /* SignatureKind.Call */).length ? globalCallableFunctionType : + getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length ? globalNewableFunctionType : undefined; if (functionType) { ts.forEach(getPropertiesOfType(functionType), function (p) { @@ -87526,10 +87923,10 @@ var ts; return roots ? ts.flatMap(roots, getRootSymbols) : [symbol]; } function getImmediateRootSymbols(symbol) { - if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { + if (ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */) { return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); }); } - else if (symbol.flags & 33554432 /* Transient */) { + else if (symbol.flags & 33554432 /* SymbolFlags.Transient */) { var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin; return leftSpread ? [leftSpread, rightSpread] : syntheticOrigin ? [syntheticOrigin] @@ -87576,13 +87973,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 111551 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* SymbolFlags.Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 111551 /* Value */); + return s && !!(s.flags & 111551 /* SymbolFlags.Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -87600,19 +87997,19 @@ var ts; // declaration if it contains an exported member with the same name. var symbol = getReferencedValueSymbol(node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node)); if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { + if (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) { // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (!prefixLocals && exportSymbol.flags & 944 /* ExportHasLocal */ && !(exportSymbol.flags & 3 /* Variable */)) { + if (!prefixLocals && exportSymbol.flags & 944 /* SymbolFlags.ExportHasLocal */ && !(exportSymbol.flags & 3 /* SymbolFlags.Variable */)) { return undefined; } symbol = exportSymbol; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SyntaxKind.SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -87635,7 +88032,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -87644,20 +88041,20 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* SyntaxKind.CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* SymbolFlags.BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } - else if (nodeLinks_1.flags & 262144 /* CapturedBlockScopedBinding */) { + else if (nodeLinks_1.flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */) { // binding is captured in the function // should be renamed if: // - binding is not top level - top level bindings never collide with anything @@ -87673,9 +88070,9 @@ var ts; // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything - var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; + var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 235 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 235 /* SyntaxKind.Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -87716,20 +88113,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: var symbol = getSymbolOfNode(node); return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 271 /* ExportAssignment */: - return node.expression && node.expression.kind === 79 /* Identifier */ ? + case 271 /* SyntaxKind.ExportAssignment */: + return node.expression && node.expression.kind === 79 /* SyntaxKind.Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } @@ -87737,7 +88134,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 305 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -87754,7 +88151,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 111551 /* Value */) && + return !!(target.flags & 111551 /* SymbolFlags.Value */) && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -87768,8 +88165,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217 - if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && - target.flags & 111551 /* Value */ && + if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ && + target.flags & 111551 /* SymbolFlags.Value */ && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; @@ -87807,13 +88204,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -87821,10 +88218,10 @@ var ts; return false; } var symbol = getSymbolOfNode(declaration); - if (!symbol || !(symbol.flags & 16 /* Function */)) { + if (!symbol || !(symbol.flags & 16 /* SymbolFlags.Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* SymbolFlags.Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -87847,19 +88244,19 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 299 /* EnumMember */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 299 /* SyntaxKind.EnumMember */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 299 /* EnumMember */) { + if (node.kind === 299 /* SyntaxKind.EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { + if (symbol && (symbol.flags & 8 /* SymbolFlags.EnumMember */)) { // inline property\index accesses only for const enums var member = symbol.valueDeclaration; if (ts.isEnumConst(member.parent)) { @@ -87869,7 +88266,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* TypeFlags.Object */) && getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { var _a, _b; @@ -87885,14 +88282,14 @@ var ts; // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var isTypeOnly = false; if (ts.isQualifiedName(typeName)) { - var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)); } - var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); - var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol; + var valueSymbol = resolveEntityName(typeName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(valueSymbol) : valueSymbol; isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration))); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (resolvedSymbol && resolvedSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) { @@ -87911,28 +88308,28 @@ var ts; if (isErrorType(type)) { return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 3 /* AnyOrUnknown */) { + else if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* TypeFlags.Void */ | 98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* TypeFlags.BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* TypeFlags.NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* TypeFlags.BigIntLike */)) { return ts.TypeReferenceSerializationKind.BigIntLikeType; } - else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 402653316 /* TypeFlags.StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* TypeFlags.ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -87948,37 +88345,37 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + var type = symbol && !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 131072 /* SymbolFlags.Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol) { - flags |= 1048576 /* AllowUniqueESSymbolType */; + flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } if (addUndefined) { type = getOptionalType(type); } - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); - return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function hasGlobalName(name) { return globals.has(ts.escapeLeadingUnderscores(name)); @@ -87997,7 +88394,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -88018,7 +88415,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* TypeFlags.EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* SymbolFlags.Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse(); if (enumResult) return enumResult; @@ -88126,18 +88523,18 @@ var ts; isLateBound: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); - return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */); + return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */); }, getJsxFactoryEntity: getJsxFactoryEntity, getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 173 /* SetAccessor */ ? 172 /* GetAccessor */ : 173 /* SetAccessor */; + var otherKind = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? 172 /* SyntaxKind.GetAccessor */ : 173 /* SyntaxKind.SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 173 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 172 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -88153,7 +88550,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 305 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 305 /* SyntaxKind.SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -88190,7 +88587,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 228 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* HeritageClause */; + return node.parent && node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -88198,12 +88595,19 @@ var ts; if (!fileToDirective) { return undefined; } + // computed property name should use node as value // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + var meaning; + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; + } + else { + meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; + if ((node.kind === 79 /* SyntaxKind.Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; + } } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -88250,7 +88654,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -88278,12 +88682,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 261 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 305 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -88354,7 +88758,7 @@ var ts; getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; - getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* Anonymous */, globalThisSymbol); + getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* ObjectFlags.Anonymous */, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -88416,28 +88820,28 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* NodeFlags.Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* ExternalEmitHelpers.FirstEmitHelper */; helper <= 4194304 /* ExternalEmitHelpers.LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* SymbolFlags.Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } - else if (helper & 524288 /* ClassPrivateFieldGet */) { + else if (helper & 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4); } } - else if (helper & 1048576 /* ClassPrivateFieldSet */) { + else if (helper & 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); } } - else if (helper & 1024 /* SpreadArray */) { + else if (helper & 1024 /* ExternalEmitHelpers.SpreadArray */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3); } @@ -88451,29 +88855,29 @@ var ts; } function getHelperName(helper) { switch (helper) { - case 1 /* Extends */: return "__extends"; - case 2 /* Assign */: return "__assign"; - case 4 /* Rest */: return "__rest"; - case 8 /* Decorate */: return "__decorate"; - case 16 /* Metadata */: return "__metadata"; - case 32 /* Param */: return "__param"; - case 64 /* Awaiter */: return "__awaiter"; - case 128 /* Generator */: return "__generator"; - case 256 /* Values */: return "__values"; - case 512 /* Read */: return "__read"; - case 1024 /* SpreadArray */: return "__spreadArray"; - case 2048 /* Await */: return "__await"; - case 4096 /* AsyncGenerator */: return "__asyncGenerator"; - case 8192 /* AsyncDelegator */: return "__asyncDelegator"; - case 16384 /* AsyncValues */: return "__asyncValues"; - case 32768 /* ExportStar */: return "__exportStar"; - case 65536 /* ImportStar */: return "__importStar"; - case 131072 /* ImportDefault */: return "__importDefault"; - case 262144 /* MakeTemplateObject */: return "__makeTemplateObject"; - case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; - case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; - case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn"; - case 4194304 /* CreateBinding */: return "__createBinding"; + case 1 /* ExternalEmitHelpers.Extends */: return "__extends"; + case 2 /* ExternalEmitHelpers.Assign */: return "__assign"; + case 4 /* ExternalEmitHelpers.Rest */: return "__rest"; + case 8 /* ExternalEmitHelpers.Decorate */: return "__decorate"; + case 16 /* ExternalEmitHelpers.Metadata */: return "__metadata"; + case 32 /* ExternalEmitHelpers.Param */: return "__param"; + case 64 /* ExternalEmitHelpers.Awaiter */: return "__awaiter"; + case 128 /* ExternalEmitHelpers.Generator */: return "__generator"; + case 256 /* ExternalEmitHelpers.Values */: return "__values"; + case 512 /* ExternalEmitHelpers.Read */: return "__read"; + case 1024 /* ExternalEmitHelpers.SpreadArray */: return "__spreadArray"; + case 2048 /* ExternalEmitHelpers.Await */: return "__await"; + case 4096 /* ExternalEmitHelpers.AsyncGenerator */: return "__asyncGenerator"; + case 8192 /* ExternalEmitHelpers.AsyncDelegator */: return "__asyncDelegator"; + case 16384 /* ExternalEmitHelpers.AsyncValues */: return "__asyncValues"; + case 32768 /* ExternalEmitHelpers.ExportStar */: return "__exportStar"; + case 65536 /* ExternalEmitHelpers.ImportStar */: return "__importStar"; + case 131072 /* ExternalEmitHelpers.ImportDefault */: return "__importDefault"; + case 262144 /* ExternalEmitHelpers.MakeTemplateObject */: return "__makeTemplateObject"; + case 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */: return "__classPrivateFieldGet"; + case 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */: return "__classPrivateFieldSet"; + case 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */: return "__classPrivateFieldIn"; + case 4194304 /* ExternalEmitHelpers.CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -88495,14 +88899,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 169 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) { + else if (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (ts.hasDecorators(accessors.firstAccessor) && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -88516,71 +88920,71 @@ var ts; return quickResult; } var lastStatic, lastDeclare, lastAsync, lastOverride; - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (ts.isDecorator(modifier)) continue; - if (modifier.kind !== 145 /* ReadonlyKeyword */) { - if (node.kind === 166 /* PropertySignature */ || node.kind === 168 /* MethodSignature */) { + if (modifier.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.kind === 166 /* SyntaxKind.PropertySignature */ || node.kind === 168 /* SyntaxKind.MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 176 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */ && (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } - if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 144 /* OutKeyword */) { - if (node.kind === 163 /* TypeParameter */) { + if (modifier.kind !== 101 /* SyntaxKind.InKeyword */ && modifier.kind !== 144 /* SyntaxKind.OutKeyword */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 85 /* ConstKeyword */: - if (node.kind !== 260 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); + case 85 /* SyntaxKind.ConstKeyword */: + if (node.kind !== 260 /* SyntaxKind.EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* SyntaxKind.ConstKeyword */)); } break; - case 159 /* OverrideKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; lastOverride = modifier; break; - case 123 /* PublicKeyword */: - case 122 /* ProtectedKeyword */: - case 121 /* PrivateKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 28 /* ModifierFlags.AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); } - else if (flags & 32 /* Static */) { + else if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } - else if (flags & 128 /* Abstract */) { - if (modifier.kind === 121 /* PrivateKeyword */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { + if (modifier.kind === 121 /* SyntaxKind.PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -88592,185 +88996,185 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 124 /* StaticKeyword */: - if (flags & 32 /* Static */) { + case 124 /* SyntaxKind.StaticKeyword */: + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 32 /* ModifierFlags.Static */; lastStatic = modifier; break; - case 145 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + case 145 /* SyntaxKind.ReadonlyKeyword */: + if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */ && node.kind !== 176 /* IndexSignature */ && node.kind !== 164 /* Parameter */) { + else if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */ && node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 164 /* SyntaxKind.Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; break; - case 93 /* ExportKeyword */: - if (flags & 1 /* Export */) { + case 93 /* SyntaxKind.ExportKeyword */: + if (flags & 1 /* ModifierFlags.Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; break; - case 88 /* DefaultKeyword */: - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* SyntaxKind.DefaultKeyword */: + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } - else if (!(flags & 1 /* Export */)) { + else if (!(flags & 1 /* ModifierFlags.Export */)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } - flags |= 512 /* Default */; + flags |= 512 /* ModifierFlags.Default */; break; - case 135 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + case 135 /* SyntaxKind.DeclareKeyword */: + if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) { + else if ((node.parent.flags & 16777216 /* NodeFlags.Ambient */) && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; lastDeclare = modifier; break; - case 126 /* AbstractKeyword */: - if (flags & 128 /* Abstract */) { + case 126 /* SyntaxKind.AbstractKeyword */: + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 257 /* ClassDeclaration */ && - node.kind !== 180 /* ConstructorType */) { - if (node.kind !== 169 /* MethodDeclaration */ && - node.kind !== 167 /* PropertyDeclaration */ && - node.kind !== 172 /* GetAccessor */ && - node.kind !== 173 /* SetAccessor */) { + if (node.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + node.kind !== 180 /* SyntaxKind.ConstructorType */) { + if (node.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + node.kind !== 172 /* SyntaxKind.GetAccessor */ && + node.kind !== 173 /* SyntaxKind.SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 257 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 256 /* Async */ && lastAsync) { + if (flags & 256 /* ModifierFlags.Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } } - if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 128 /* Abstract */; + flags |= 128 /* ModifierFlags.Abstract */; break; - case 131 /* AsyncKeyword */: - if (flags & 256 /* Async */) { + case 131 /* SyntaxKind.AsyncKeyword */: + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */ || node.parent.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 256 /* Async */; + flags |= 256 /* ModifierFlags.Async */; lastAsync = modifier; break; - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; - var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out"; - if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + var inOutFlag = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? 32768 /* ModifierFlags.In */ : 65536 /* ModifierFlags.Out */; + var inOutText = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? "in" : "out"; + if (node.kind !== 163 /* SyntaxKind.TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 32768 /* ModifierFlags.In */ && flags & 65536 /* ModifierFlags.Out */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; break; } } - if (node.kind === 171 /* Constructor */) { - if (flags & 32 /* Static */) { + if (node.kind === 171 /* SyntaxKind.Constructor */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; } - else if ((node.kind === 266 /* ImportDeclaration */ || node.kind === 265 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) && flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -88788,48 +89192,48 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 261 /* ModuleDeclaration */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return false; - case 170 /* ClassStaticBlockDeclaration */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 264 /* NamespaceExportDeclaration */: - case 179 /* FunctionType */: - case 276 /* MissingDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 276 /* SyntaxKind.MissingDeclaration */: return true; default: - if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return false; } switch (node.kind) { - case 256 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */); - case 257 /* ClassDeclaration */: - case 180 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 237 /* VariableStatement */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 131 /* SyntaxKind.AsyncKeyword */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 180 /* SyntaxKind.ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* SyntaxKind.AbstractKeyword */); + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 260 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); + case 260 /* SyntaxKind.EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* SyntaxKind.ConstKeyword */); default: ts.Debug.assertNever(node); } @@ -88846,10 +89250,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -88878,7 +89282,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 16777216 /* NodeFlags.Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -88903,7 +89307,7 @@ var ts; return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); }); } function checkGrammarForUseStrictSimpleParameterList(node) { - if (languageVersion >= 3 /* ES2016 */) { + if (languageVersion >= 3 /* ScriptTarget.ES2016 */) { var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements); if (useStrictDirective_1) { var nonSimpleParameters = getNonSimpleParameters(node.parameters); @@ -88938,7 +89342,7 @@ var ts; return false; } if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { - if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */])) { grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } @@ -88974,7 +89378,7 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } var type = getTypeFromTypeNode(parameter.type); - if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { + if (someType(type, function (t) { return !!(t.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead); } if (!everyType(type, isValidIndexKeyType)) { @@ -89003,7 +89407,7 @@ var ts; checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } function checkGrammarTaggedTemplateChain(node) { - if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + if (node.questionDotToken || node.flags & 32 /* NodeFlags.OptionalChain */) { return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); } return false; @@ -89031,7 +89435,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -89044,7 +89448,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -89060,14 +89464,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -89078,21 +89482,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 221 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 221 /* SyntaxKind.BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 169 /* MethodDeclaration */); - if (node.flags & 16777216 /* Ambient */) { + ts.Debug.assert(node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -89110,7 +89514,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -89121,23 +89525,23 @@ var ts; continue; } var name = prop.name; - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 297 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } - if (name.kind === 80 /* PrivateIdentifier */) { + if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (ts.canHaveModifiers(prop) && prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (ts.isModifier(mod) && (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 169 /* MethodDeclaration */)) { + if (ts.isModifier(mod) && (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */)) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -89158,24 +89562,24 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name.kind === 8 /* NumericLiteral */) { + if (name.kind === 8 /* SyntaxKind.NumericLiteral */) { checkGrammarNumericLiteral(name); } - currentKind = 4 /* PropertyAssignment */; + currentKind = 4 /* DeclarationMeaning.PropertyAssignment */; break; - case 169 /* MethodDeclaration */: - currentKind = 8 /* Method */; + case 169 /* SyntaxKind.MethodDeclaration */: + currentKind = 8 /* DeclarationMeaning.Method */; break; - case 172 /* GetAccessor */: - currentKind = 1 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + currentKind = 1 /* DeclarationMeaning.GetAccessor */; break; - case 173 /* SetAccessor */: - currentKind = 2 /* SetAccessor */; + case 173 /* SyntaxKind.SetAccessor */: + currentKind = 2 /* DeclarationMeaning.SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -89190,14 +89594,14 @@ var ts; seen.set(effectiveName, currentKind); } else { - if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) { + if ((currentKind & 8 /* DeclarationMeaning.Method */) && (existingKind & 8 /* DeclarationMeaning.Method */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) { + else if ((currentKind & 4 /* DeclarationMeaning.PropertyAssignment */) && (existingKind & 4 /* DeclarationMeaning.PropertyAssignment */)) { grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name)); } - else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { - if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* DeclarationMeaning.GetOrSetAccessor */) && (existingKind & 3 /* DeclarationMeaning.GetOrSetAccessor */)) { + if (existingKind !== 3 /* DeclarationMeaning.GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -89217,7 +89621,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 287 /* JsxSpreadAttribute */) { + if (attr.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -89227,7 +89631,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 288 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 288 /* SyntaxKind.JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -89262,8 +89666,8 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 244 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { + if (forInOrOfStatement.kind === 244 /* SyntaxKind.ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { if (!hasParseDiagnostics(sourceFile)) { @@ -89281,7 +89685,7 @@ var ts; case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: case ts.ModuleKind.System: - if (languageVersion >= 4 /* ES2017 */) { + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { break; } // fallthrough @@ -89296,8 +89700,8 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 171 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); + if (func && func.kind !== 171 /* SyntaxKind.Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -89308,12 +89712,12 @@ var ts; return false; } } - if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) && + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */) && ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") { grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async); return false; } - if (forInOrOfStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -89328,20 +89732,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -89351,22 +89755,22 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) { - if (languageVersion < 1 /* ES5 */) { + if (!(accessor.flags & 16777216 /* NodeFlags.Ambient */) && (accessor.parent.kind !== 182 /* SyntaxKind.TypeLiteral */) && (accessor.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */)) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - if (accessor.parent.kind === 182 /* TypeLiteral */ || accessor.parent.kind === 258 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 182 /* SyntaxKind.TypeLiteral */ || accessor.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -89374,11 +89778,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 173 /* SetAccessor */) { + if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -89400,17 +89804,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 154 /* UniqueKeyword */) { - if (node.type.kind !== 151 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SymbolKeyword */)); + if (node.operator === 154 /* SyntaxKind.UniqueKeyword */) { + if (node.type.kind !== 151 /* SyntaxKind.SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -89420,26 +89824,26 @@ var ts; } } switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 79 /* Identifier */) { + if (decl.name.kind !== 79 /* SyntaxKind.Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); } - if (!(decl.parent.flags & 2 /* Const */)) { + if (!(decl.parent.flags & 2 /* NodeFlags.Const */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (!ts.isStatic(parent) || !ts.hasEffectiveReadonlyModifier(parent)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 166 /* PropertySignature */: - if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { + case 166 /* SyntaxKind.PropertySignature */: + if (!ts.hasSyntacticModifier(parent, 64 /* ModifierFlags.Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -89447,9 +89851,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 145 /* ReadonlyKeyword */) { - if (node.type.kind !== 183 /* ArrayType */ && node.type.kind !== 184 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SymbolKeyword */)); + else if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.type.kind !== 183 /* SyntaxKind.ArrayType */ && node.type.kind !== 184 /* SyntaxKind.TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } } } @@ -89462,10 +89866,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 169 /* MethodDeclaration */) { - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) { + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -89483,7 +89887,7 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } // Technically, computed properties in ambient contexts is disallowed @@ -89491,17 +89895,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 169 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 182 /* TypeLiteral */) { + else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -89512,11 +89916,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 245 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 245 /* SyntaxKind.ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -89524,8 +89928,8 @@ var ts; return false; } break; - case 249 /* SwitchStatement */: - if (node.kind === 246 /* BreakStatement */ && !node.label) { + case 249 /* SyntaxKind.SwitchStatement */: + if (node.kind === 246 /* SyntaxKind.BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -89540,13 +89944,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -89570,18 +89974,18 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; } function isBigIntLiteralExpression(expr) { - return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 9 /* BigIntLiteral */; + return expr.kind === 9 /* SyntaxKind.BigIntLiteral */ || + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 9 /* SyntaxKind.BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) { - return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* TypeFlags.EnumLiteral */); } } function checkAmbientInitializer(node) { @@ -89589,7 +89993,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || + initializer.kind === 110 /* SyntaxKind.TrueKeyword */ || initializer.kind === 95 /* SyntaxKind.FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -89600,14 +90004,11 @@ var ts; else { return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } - if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) { - if (node.flags & 16777216 /* Ambient */) { + if (node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */ && node.parent.parent.kind !== 244 /* SyntaxKind.ForOfStatement */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -89619,7 +90020,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 237 /* SyntaxKind.VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* NodeFlags.Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -89628,7 +90029,7 @@ var ts; return grammarErrorOnNode(node.exclamationToken, message); } if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System && - !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* ModifierFlags.Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -89641,7 +90042,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -89658,8 +90059,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 79 /* Identifier */) { - if (name.originalKeywordKind === 119 /* LetKeyword */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { + if (name.originalKeywordKind === 119 /* SyntaxKind.LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -89686,15 +90087,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return false; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -89712,12 +90113,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -89775,7 +90176,7 @@ var ts; } } function checkGrammarProperty(node) { - if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) { + if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) { return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); } if (ts.isClassLike(node.parent)) { @@ -89785,11 +90186,11 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { return true; } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -89809,11 +90210,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { + node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -89835,14 +90236,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 259 /* TypeAliasDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 272 /* ExportDeclaration */ || - node.kind === 271 /* ExportAssignment */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */ | 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -89850,7 +90251,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 237 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 237 /* SyntaxKind.VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -89859,10 +90260,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -89873,7 +90274,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 235 /* Block */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 235 /* SyntaxKind.Block */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -89890,19 +90291,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.numericLiteralFlags & 32 /* Octal */) { + if (node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { var diagnosticMessage = void 0; - if (languageVersion >= 1 /* ES5 */) { + if (languageVersion >= 1 /* ScriptTarget.ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 196 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 196 /* SyntaxKind.LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 299 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 299 /* SyntaxKind.EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* SyntaxKind.MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -89915,7 +90316,7 @@ var ts; // We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "." // e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`. var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1; - var isScientific = node.numericLiteralFlags & 16 /* Scientific */; + var isScientific = node.numericLiteralFlags & 16 /* TokenFlags.Scientific */; // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway if (isFractional || isScientific) { @@ -89936,7 +90337,7 @@ var ts; var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); if (!literalType) { - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { return true; } @@ -89970,7 +90371,7 @@ var ts; if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } - if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* NamedImports */) { + if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* SyntaxKind.NamedImports */) { return checkGrammarNamedImportsOrExports(node.namedBindings); } return false; @@ -89978,7 +90379,7 @@ var ts; function checkGrammarNamedImportsOrExports(namedBindings) { return !!ts.forEach(namedBindings.elements, function (specifier) { if (specifier.isTypeOnly) { - return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* ImportSpecifier */ + return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* SyntaxKind.ImportSpecifier */ ? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement : ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); } @@ -90013,14 +90414,14 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { + if (sourceObjectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */) && unionTarget.flags & 1048576 /* TypeFlags.Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 524288 /* Object */) { + if (target.flags & 524288 /* TypeFlags.Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); - if (overlapObjFlags & 4 /* Reference */) { + if (overlapObjFlags & 4 /* ObjectFlags.Reference */) { return source.target === target.target; } - if (overlapObjFlags & 16 /* Anonymous */) { + if (overlapObjFlags & 16 /* ObjectFlags.Anonymous */) { return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; } } @@ -90029,35 +90430,35 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectFlags.ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } function findBestTypeForInvokable(source, unionTarget) { - var signatureKind = 0 /* Call */; + var signatureKind = 0 /* SignatureKind.Call */; var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 || - (signatureKind = 1 /* Construct */, getSignaturesOfType(source, signatureKind).length > 0); + (signatureKind = 1 /* SignatureKind.Construct */, getSignaturesOfType(source, signatureKind).length > 0); if (hasSignatures) { return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; }); } } function findMostOverlappyType(source, unionTarget) { var bestMatch; - if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(source.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var matchingCount = 0; for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) { var target = _a[_i]; - if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(target.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]); - if (overlap.flags & 4194304 /* Index */) { + if (overlap.flags & 4194304 /* TypeFlags.Index */) { // perfect overlap of keys return target; } - else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) { + else if (isUnitType(overlap) || overlap.flags & 1048576 /* TypeFlags.Union */) { // We only want to account for literal types otherwise. // If we have a union of index types, it seems likely that we // needed to elaborate between two generic mapped types anyway. - var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; + var len = overlap.flags & 1048576 /* TypeFlags.Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; if (len >= matchingCount) { bestMatch = target; matchingCount = len; @@ -90069,9 +90470,9 @@ var ts; return bestMatch; } function filterPrimitivesIfContainsNonPrimitive(type) { - if (maybeTypeOfKind(type, 67108864 /* NonPrimitive */)) { - var result = filterType(type, function (t) { return !(t.flags & 131068 /* Primitive */); }); - if (!(result.flags & 131072 /* Never */)) { + if (maybeTypeOfKind(type, 67108864 /* TypeFlags.NonPrimitive */)) { + var result = filterType(type, function (t) { return !(t.flags & 131068 /* TypeFlags.Primitive */); }); + if (!(result.flags & 131072 /* TypeFlags.Never */)) { return result; } } @@ -90079,7 +90480,7 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { - if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { + if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) { var match = getMatchingUnionConstituentForType(target, source); if (match) { return match; @@ -90101,14 +90502,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 256 /* FunctionDeclaration */ && declaration.kind !== 169 /* MethodDeclaration */) || + return (declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */ && declaration.kind !== 169 /* SyntaxKind.MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -90128,17 +90529,17 @@ var ts; })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { - case 0 /* Yield */: return "yieldType"; - case 1 /* Return */: return "returnType"; - case 2 /* Next */: return "nextType"; + case 0 /* IterationTypeKind.Yield */: return "yieldType"; + case 1 /* IterationTypeKind.Return */: return "returnType"; + case 2 /* IterationTypeKind.Next */: return "nextType"; } } function signatureHasRestParameter(s) { - return !!(s.flags & 1 /* HasRestParameter */); + return !!(s.flags & 1 /* SignatureFlags.HasRestParameter */); } ts.signatureHasRestParameter = signatureHasRestParameter; function signatureHasLiteralTypes(s) { - return !!(s.flags & 2 /* HasLiteralTypes */); + return !!(s.flags & 2 /* SignatureFlags.HasLiteralTypes */); } ts.signatureHasLiteralTypes = signatureHasLiteralTypes; })(ts || (ts = {})); @@ -90278,7 +90679,7 @@ var ts; var updated; context.startLexicalEnvironment(); if (nodes) { - context.setLexicalEnvironmentFlags(1 /* InParameters */, true); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, true); updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression @@ -90286,11 +90687,11 @@ var ts; // exists in a different lexical scope. To address this, we move any binding patterns and initializers // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list // when the emit target is greater than ES2015. - if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ && - ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (context.getLexicalEnvironmentFlags() & 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */ && + ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { updated = addDefaultValueAssignmentsIfNeeded(updated, context); } - context.setLexicalEnvironmentFlags(1 /* InParameters */, false); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, false); } context.suspendLexicalEnvironment(); return updated; @@ -90337,8 +90738,8 @@ var ts; function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { var factory = context.factory; context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ - factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */))); + factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */))); return factory.updateParameterDeclaration(parameter, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, /*initializer*/ undefined); } @@ -90384,446 +90785,446 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 160 /* LastToken */) || kind === 192 /* ThisType */) { + if ((kind > 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */) || kind === 192 /* SyntaxKind.ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: ts.Debug.type(node); return factory.updateParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: ts.Debug.type(node); return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: ts.Debug.type(node); return factory.updateMethodDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: ts.Debug.type(node); context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); return factory.updateClassStaticBlockDeclaration(node, visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: ts.Debug.type(node); return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: ts.Debug.type(node); return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: ts.Debug.type(node); return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: ts.Debug.type(node); return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: ts.Debug.type(node); - return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 295 /* ImportTypeAssertionContainer */: + return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: ts.Debug.type(node); - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 191 /* ParenthesizedType */: + return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); + case 191 /* SyntaxKind.ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: ts.Debug.type(node); return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: ts.Debug.type(node); return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 206 /* PropertyAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName)); } ts.Debug.type(node); return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); - case 207 /* ElementAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 208 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: ts.Debug.type(node); return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: ts.Debug.type(node); - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 211 /* TypeAssertionExpression */: + return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: ts.Debug.type(node); return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: ts.Debug.type(node); return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: ts.Debug.type(node); return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: ts.Debug.type(node); return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 230 /* NonNullExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 230 /* SyntaxKind.NonNullExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: ts.Debug.type(node); return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: ts.Debug.type(node); return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: ts.Debug.type(node); return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: ts.Debug.type(node); return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: ts.Debug.type(node); return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: ts.Debug.type(node); return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: ts.Debug.type(node); return factory.updateFunctionDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: ts.Debug.type(node); return factory.updateModuleDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: ts.Debug.type(node); return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: ts.Debug.type(node); return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode)); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: ts.Debug.type(node); return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: ts.Debug.type(node); return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: ts.Debug.type(node); return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: ts.Debug.type(node); return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.type(node); return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: ts.Debug.type(node); return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -91048,7 +91449,7 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - appendMappingCharCode(59 /* semicolon */); + appendMappingCharCode(59 /* CharacterCodes.semicolon */); lastGeneratedLine++; } while (lastGeneratedLine < pendingGeneratedLine); // Only need to set this once @@ -91058,7 +91459,7 @@ var ts; ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - appendMappingCharCode(44 /* comma */); + appendMappingCharCode(44 /* CharacterCodes.comma */); } } // 1. Relative generated character @@ -91201,14 +91602,14 @@ var ts; next: function () { while (!done && pos < mappings.length) { var ch = mappings.charCodeAt(pos); - if (ch === 59 /* semicolon */) { + if (ch === 59 /* CharacterCodes.semicolon */) { // new line generatedLine++; generatedCharacter = 0; pos++; continue; } - if (ch === 44 /* comma */) { + if (ch === 44 /* CharacterCodes.comma */) { // Next entry is on same line - no action needed pos++; continue; @@ -91285,8 +91686,8 @@ var ts; } function isSourceMappingSegmentEnd() { return (pos === mappings.length || - mappings.charCodeAt(pos) === 44 /* comma */ || - mappings.charCodeAt(pos) === 59 /* semicolon */); + mappings.charCodeAt(pos) === 44 /* CharacterCodes.comma */ || + mappings.charCodeAt(pos) === 59 /* CharacterCodes.semicolon */); } function base64VLQFormatDecode() { var moreDigits = true; @@ -91336,19 +91737,19 @@ var ts; } ts.isSourceMapping = isSourceMapping; function base64FormatEncode(value) { - return value >= 0 && value < 26 ? 65 /* A */ + value : - value >= 26 && value < 52 ? 97 /* a */ + value - 26 : - value >= 52 && value < 62 ? 48 /* _0 */ + value - 52 : - value === 62 ? 43 /* plus */ : - value === 63 ? 47 /* slash */ : - ts.Debug.fail(value + ": not a base64 value"); + return value >= 0 && value < 26 ? 65 /* CharacterCodes.A */ + value : + value >= 26 && value < 52 ? 97 /* CharacterCodes.a */ + value - 26 : + value >= 52 && value < 62 ? 48 /* CharacterCodes._0 */ + value - 52 : + value === 62 ? 43 /* CharacterCodes.plus */ : + value === 63 ? 47 /* CharacterCodes.slash */ : + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ ? ch - 65 /* A */ : - ch >= 97 /* a */ && ch <= 122 /* z */ ? ch - 97 /* a */ + 26 : - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ ? ch - 48 /* _0 */ + 52 : - ch === 43 /* plus */ ? 62 : - ch === 47 /* slash */ ? 63 : + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ ? ch - 65 /* CharacterCodes.A */ : + ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ? ch - 97 /* CharacterCodes.a */ + 26 : + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ ? ch - 48 /* CharacterCodes._0 */ + 52 : + ch === 43 /* CharacterCodes.plus */ ? 62 : + ch === 47 /* CharacterCodes.slash */ ? 63 : -1; } function isSourceMappedPosition(value) { @@ -91416,7 +91817,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -91509,12 +91910,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* InternalSymbolName.Default */; } function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -91565,7 +91966,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -91578,13 +91979,13 @@ var ts; hasImportDefault = true; } break; - case 265 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 277 /* ExternalModuleReference */) { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -91615,23 +92016,23 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 237 /* VariableStatement */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + case 237 /* SyntaxKind.VariableStatement */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames); } } break; - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default function() { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -91649,9 +92050,9 @@ var ts; } } break; - case 257 /* ClassDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default class { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -91732,7 +92133,7 @@ var ts; */ function isSimpleCopiableExpression(expression) { return ts.isStringLiteralLike(expression) || - expression.kind === 8 /* NumericLiteral */ || + expression.kind === 8 /* SyntaxKind.NumericLiteral */ || ts.isKeyword(expression.kind) || ts.isIdentifier(expression); } @@ -91747,27 +92148,27 @@ var ts; } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 64 /* FirstCompoundAssignment */ - && kind <= 78 /* LastCompoundAssignment */; + return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */ + && kind <= 78 /* SyntaxKind.LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 64 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 65 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 68 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 69 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 74 /* BarEqualsToken */: return 51 /* BarToken */; - case 78 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + case 64 /* SyntaxKind.PlusEqualsToken */: return 39 /* SyntaxKind.PlusToken */; + case 65 /* SyntaxKind.MinusEqualsToken */: return 40 /* SyntaxKind.MinusToken */; + case 66 /* SyntaxKind.AsteriskEqualsToken */: return 41 /* SyntaxKind.AsteriskToken */; + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return 42 /* SyntaxKind.AsteriskAsteriskToken */; + case 68 /* SyntaxKind.SlashEqualsToken */: return 43 /* SyntaxKind.SlashToken */; + case 69 /* SyntaxKind.PercentEqualsToken */: return 44 /* SyntaxKind.PercentToken */; + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: return 47 /* SyntaxKind.LessThanLessThanToken */; + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: return 48 /* SyntaxKind.GreaterThanGreaterThanToken */; + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; + case 73 /* SyntaxKind.AmpersandEqualsToken */: return 50 /* SyntaxKind.AmpersandToken */; + case 74 /* SyntaxKind.BarEqualsToken */: return 51 /* SyntaxKind.BarToken */; + case 78 /* SyntaxKind.CaretEqualsToken */: return 52 /* SyntaxKind.CaretToken */; + case 75 /* SyntaxKind.BarBarEqualsToken */: return 56 /* SyntaxKind.BarBarToken */; + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: return 55 /* SyntaxKind.AmpersandAmpersandToken */; + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return 60 /* SyntaxKind.QuestionQuestionToken */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -91829,7 +92230,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 167 /* PropertyDeclaration */ + return member.kind === 167 /* SyntaxKind.PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -91893,12 +92294,12 @@ var ts; */ function getAllDecoratorsOfClassElement(member, parent) { switch (member.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return getAllDecoratorsOfAccessors(member, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -92234,9 +92635,9 @@ var ts; var element = elements[i]; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); - if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */)) + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */ + && !(element.transformFlags & (32768 /* TransformFlags.ContainsRestOrSpread */ | 65536 /* TransformFlags.ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* TransformFlags.ContainsRestOrSpread */ | 65536 /* TransformFlags.ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -92277,14 +92678,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + if (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ && flattenContext.downlevelIteration) { // Read the elements of the iterable into an array value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) ? undefined : numElements), location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + else if (numElements !== 1 && (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ || numElements === 0) || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -92299,10 +92700,10 @@ var ts; var restContainingElements; for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (flattenContext.level >= 1 /* ObjectRest */) { + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -92505,7 +92906,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + var isLast = node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || node.kind === 17 /* SyntaxKind.TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); } // Newline normalization: @@ -92559,8 +92960,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -92580,14 +92981,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -92636,16 +93037,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 262 /* ModuleBlock */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 262 /* SyntaxKind.ModuleBlock */: + case 235 /* SyntaxKind.Block */: currentLexicalScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { break; } // Record these declarations provided that they have a name. @@ -92656,7 +93057,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 257 /* SyntaxKind.ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)); } break; } @@ -92675,7 +93076,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { return visitTypeScript(node); } return node; @@ -92695,10 +93096,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -92711,7 +93112,7 @@ var ts; // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes // We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`, // and will trigger debug failures when debug verbosity is turned up - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { // This node contains TypeScript, so we should visit its children. return ts.visitEachChild(node, visitor, context); } @@ -92719,13 +93120,13 @@ var ts; return node; } switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -92745,15 +93146,15 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 272 /* ExportDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 267 /* ImportClause */ || - (node.kind === 265 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 277 /* ExternalModuleReference */)) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ || + (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && + node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } - else if (node.transformFlags & 1 /* ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* Export */)) { + else if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return visitTypeScript(node); } return node; @@ -92773,27 +93174,27 @@ var ts; */ function classElementVisitorWorker(node, parent) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node, parent); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node, parent); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node, parent); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return ts.visitEachChild(node, visitor, context); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Index signatures are elided return; default: @@ -92805,17 +93206,17 @@ var ts; } function objectLiteralElementVisitorWorker(node, parent) { switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitor(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node, parent); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node, parent); @@ -92826,10 +93227,10 @@ var ts; function modifierVisitor(node) { if (ts.isDecorator(node)) return undefined; - if (ts.modifierToFlag(node.kind) & 116958 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 116958 /* ModifierFlags.TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* SyntaxKind.ExportKeyword */) { return undefined; } return node; @@ -92840,72 +93241,72 @@ var ts; * @param node The node to visit. */ function visitTypeScript(node) { - if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { // TypeScript ambient declarations are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 145 /* ReadonlyKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 185 /* OptionalType */: - case 186 /* RestType */: - case 182 /* TypeLiteral */: - case 177 /* TypePredicate */: - case 163 /* TypeParameter */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 133 /* BooleanKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 143 /* NeverKeyword */: - case 114 /* VoidKeyword */: - case 151 /* SymbolKeyword */: - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 181 /* TypeQuery */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 189 /* ConditionalType */: - case 191 /* ParenthesizedType */: - case 192 /* ThisType */: - case 193 /* TypeOperator */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 196 /* LiteralType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 177 /* SyntaxKind.TypePredicate */: + case 163 /* SyntaxKind.TypeParameter */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 181 /* SyntaxKind.TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 189 /* SyntaxKind.ConditionalType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 192 /* SyntaxKind.ThisType */: + case 193 /* SyntaxKind.TypeOperator */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 196 /* SyntaxKind.LiteralType */: // TypeScript type nodes are elided. // falls through - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // TypeScript index signatures are elided. return undefined; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return factory.createNotEmittedStatement(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -92915,7 +93316,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -92925,34 +93326,34 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors"); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -92962,40 +93363,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -93012,28 +93413,28 @@ var ts; return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement)); } function getClassFacts(node, staticProperties) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; if (ts.some(staticProperties)) - facts |= 1 /* HasStaticInitializedProperties */; + facts |= 1 /* ClassFacts.HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) - facts |= 64 /* IsDerivedClass */; + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */) + facts |= 64 /* ClassFacts.IsDerivedClass */; if (ts.classOrConstructorParameterIsDecorated(node)) - facts |= 2 /* HasConstructorDecorators */; + facts |= 2 /* ClassFacts.HasConstructorDecorators */; if (ts.childIsDecorated(node)) - facts |= 4 /* HasMemberDecorators */; + facts |= 4 /* ClassFacts.HasMemberDecorators */; if (isExportOfNamespace(node)) - facts |= 8 /* IsExportOfNamespace */; + facts |= 8 /* ClassFacts.IsExportOfNamespace */; else if (isDefaultExternalModuleExport(node)) - facts |= 32 /* IsDefaultExternalExport */; + facts |= 32 /* ClassFacts.IsDefaultExternalExport */; else if (isNamedExternalModuleExport(node)) - facts |= 16 /* IsNamedExternalExport */; - if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */)) - facts |= 128 /* UseImmediatelyInvokedFunctionExpression */; + facts |= 16 /* ClassFacts.IsNamedExternalExport */; + if (languageVersion <= 1 /* ScriptTarget.ES5 */ && (facts & 7 /* ClassFacts.MayNeedImmediatelyInvokedFunctionExpression */)) + facts |= 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.hasDecorators(node) @@ -93042,20 +93443,20 @@ var ts; || ts.some(node.members, hasTypeScriptClassSyntax); } function visitClassDeclaration(node) { - if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) { + if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement)); } var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); } - var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); + var name = node.name || (facts & 5 /* ClassFacts.NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); var allDecorators = ts.getAllDecoratorsOfClass(node); var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators); // we do not emit modifiers on the declaration if we are emitting an IIFE - var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */) + var modifiers = !(facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) : ts.elideNodes(factory, node.modifiers); // preserve positions, if available // ${modifiers} class ${name} ${heritageClauses} { @@ -93066,12 +93467,12 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. var emitFlags = ts.getEmitFlags(node); - if (facts & 1 /* HasStaticInitializedProperties */) { - emitFlags |= 32 /* NoTrailingSourceMap */; + if (facts & 1 /* ClassFacts.HasStaticInitializedProperties */) { + emitFlags |= 32 /* EmitFlags.NoTrailingSourceMap */; } ts.setEmitFlags(classStatement, emitFlags); var statements = [classStatement]; - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the // 'es2015' transformer can properly nest static initializers and decorators. The result // looks something like: @@ -93083,20 +93484,20 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); var localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(localName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment()); var iife = factory.createImmediatelyInvokedArrowFunction(statements); - ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); + ts.setEmitFlags(iife, 33554432 /* EmitFlags.TypeScriptClassWrapper */); var varStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), @@ -93112,21 +93513,21 @@ var ts; // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. - if (facts & 8 /* IsExportOfNamespace */) { + if (facts & 8 /* ClassFacts.IsExportOfNamespace */) { addExportMemberAssignment(statements, node); } - else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { - if (facts & 32 /* IsDefaultExternalExport */) { + else if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* ClassFacts.HasConstructorDecorators */) { + if (facts & 32 /* ClassFacts.IsDefaultExternalExport */) { statements.push(factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } - else if (facts & 16 /* IsNamedExternalExport */) { + else if (facts & 16 /* ClassFacts.IsNamedExternalExport */) { statements.push(factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -93197,11 +93598,11 @@ var ts; var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression); var helper = emitHelpers().createParamHelper(expression, parameterOffset); ts.setTextRange(helper, parameterDecorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); var decorator = factory.createDecorator(helper); ts.setSourceMapRange(decorator, parameterDecorator.expression); ts.setCommentRange(decorator, parameterDecorator.expression); - ts.setEmitFlags(decorator, 1536 /* NoComments */); + ts.setEmitFlags(decorator, 1536 /* EmitFlags.NoComments */); decorators.push(decorator); } return decorators; @@ -93239,15 +93640,15 @@ var ts; if (typeSerializer) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); properties = ts.append(properties, typeProperty); } if (shouldAddParamTypesMetadata(node)) { - var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container))); + var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container))); properties = ts.append(properties, paramTypeProperty); } if (shouldAddReturnTypeMetadata(node)) { - var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); properties = ts.append(properties, returnTypeProperty); } if (properties) { @@ -93265,10 +93666,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 167 /* PropertyDeclaration */; + return kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -93278,7 +93679,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -93289,12 +93690,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; } return false; @@ -93356,7 +93757,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 117 /* ImplementsKeyword */) { + if (node.token === 117 /* SyntaxKind.ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -93384,7 +93785,7 @@ var ts; return !ts.nodeIsMissing(node.body); } function visitPropertyDeclaration(node, parent) { - var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */); + var isAmbient = node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); if (isAmbient && !ts.hasDecorators(node)) { return undefined; } @@ -93392,7 +93793,7 @@ var ts; var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators); // Preserve a `declare x` property with decorators to be handled by the decorators transform if (isAmbient) { - return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, factory.createModifiersFromModifierFlags(2 /* Ambient */)), ts.visitNode(node.name, visitor, ts.isPropertyName), + return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, factory.createModifiersFromModifierFlags(2 /* ModifierFlags.Ambient */)), ts.visitNode(node.name, visitor, ts.isPropertyName), /*questionOrExclamationToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); @@ -93444,7 +93845,8 @@ var ts; statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); + var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start)); // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); @@ -93464,14 +93866,14 @@ var ts; } // TODO(rbuckton): Does this need to be parented? var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 48 /* EmitFlags.NoSourceMap */); // TODO(rbuckton): Does this need to be parented? var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(localName, 1536 /* NoComments */); + ts.setEmitFlags(localName, 1536 /* EmitFlags.NoComments */); return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1)))); } function visitMethodDeclaration(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitFunctionLikeDeclaration(node)) { @@ -93491,10 +93893,10 @@ var ts; * @param node The declaration node. */ function shouldEmitAccessorDeclaration(node) { - return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */)); + return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)); } function visitGetAccessor(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitAccessorDeclaration(node)) { @@ -93507,7 +93909,7 @@ var ts; /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([])); } function visitSetAccessor(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitAccessorDeclaration(node)) { @@ -93561,7 +93963,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -93581,7 +93983,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createNamespaceExportExpression); } else { @@ -93599,7 +94001,7 @@ var ts; return updated; } function visitParenthesizedExpression(node) { - var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */); + var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* OuterExpressionKinds.Assertions */); if (ts.isAssertionExpression(innerExpression)) { // Make sure we consider all nested cast expressions, e.g.: // (-A).x; @@ -93676,7 +94078,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. @@ -93684,7 +94086,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the enum. @@ -93692,7 +94094,7 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93758,7 +94160,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* SyntaxKind.StringLiteral */ ? innerAssignment : factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -93846,12 +94248,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 305 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 305 /* SyntaxKind.SourceFile */ ? 0 /* NodeFlags.None */ : 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 260 /* EnumDeclaration */) { + if (node.kind === 260 /* SyntaxKind.EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -93876,7 +94278,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.addEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.addEmitFlags(statement, 1024 /* EmitFlags.NoTrailingComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -93886,7 +94288,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = factory.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* EmitFlags.NoComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -93907,7 +94309,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. @@ -93915,7 +94317,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the namespace. @@ -93923,7 +94325,7 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93976,7 +94378,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 262 /* ModuleBlock */) { + if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -94023,13 +94425,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 262 /* ModuleBlock */) { - ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); + if (!node.body || node.body.kind !== 262 /* SyntaxKind.ModuleBlock */) { + ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* EmitFlags.NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -94052,8 +94454,8 @@ var ts; // Elide the declaration if the import clause was elided. var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause || - compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */ + compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ ? factory.updateImportDeclaration(node, /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) : undefined; @@ -94076,14 +94478,14 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 268 /* NamespaceImport */) { + if (node.kind === 268 /* SyntaxKind.NamespaceImport */) { // Elide a namespace import if it is not referenced. return shouldEmitAliasDeclaration(node) ? node : undefined; } else { // Elide named imports if all of its import specifiers are elided and settings allow. - var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; } @@ -94124,8 +94526,8 @@ var ts; return node; } // Elide the export declaration if all of its named exports are elided. - var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause ? factory.updateExportDeclaration(node, @@ -94184,7 +94586,7 @@ var ts; if (ts.isExternalModuleImportEqualsDeclaration(node)) { var isReferenced = shouldEmitAliasDeclaration(node); // If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'. - if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) { + if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */) { return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration( /*modifiers*/ undefined, /*importClause*/ undefined, node.moduleReference.expression, @@ -94196,7 +94598,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference); - ts.setEmitFlags(moduleReference, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -94217,7 +94619,7 @@ var ts; * @param node The node to test. */ function isExportOfNamespace(node) { - return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is exported from an external module. @@ -94225,7 +94627,7 @@ var ts; * @param node The node to test. */ function isExternalModuleExport(node) { - return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is a named export from an external module. @@ -94234,7 +94636,7 @@ var ts; */ function isNamedExternalModuleExport(node) { return isExternalModuleExport(node) - && !ts.hasSyntacticModifier(node, 512 /* Default */); + && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Gets a value indicating whether the node is the default export of an external module. @@ -94243,7 +94645,7 @@ var ts; */ function isDefaultExternalModuleExport(node) { return isExternalModuleExport(node) - && ts.hasSyntacticModifier(node, 512 /* Default */); + && ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } function addExportMemberAssignment(statements, node) { var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node)); @@ -94277,27 +94679,27 @@ var ts; return factory.getGeneratedNameForNode(node); } function enableSubstitutionForNonQualifiedEnumMembers() { - if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { - enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */) === 0) { + enabledSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } function enableSubstitutionForNamespaceExports() { - if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) { - enabledSubstitutions |= 2 /* NamespaceExports */; + if ((enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) === 0) { + enabledSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(79 /* Identifier */); - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(261 /* ModuleDeclaration */); + context.enableEmitNotification(261 /* SyntaxKind.ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 261 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 260 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 260 /* SyntaxKind.EnumDeclaration */; } /** * Hook for node emit. @@ -94312,11 +94714,11 @@ var ts; if (ts.isSourceFile(node)) { currentSourceFile = node; } - if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { - applicableSubstitutions |= 2 /* NamespaceExports */; + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && isTransformedModuleDeclaration(node)) { + applicableSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; } - if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { - applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; + if (enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { + applicableSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; @@ -94330,7 +94732,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -94339,7 +94741,7 @@ var ts; return node; } function substituteShorthandPropertyAssignment(node) { - if (enabledSubstitutions & 2 /* NamespaceExports */) { + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) { var name = node.name; var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { @@ -94356,11 +94758,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -94375,9 +94777,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 305 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 261 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 260 /* EnumDeclaration */); + if (container && container.kind !== 305 /* SyntaxKind.SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && container.kind === 261 /* SyntaxKind.ModuleDeclaration */) || + (applicableSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && container.kind === 260 /* SyntaxKind.EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -94403,7 +94805,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3 /* SyntaxKind.MultiLineCommentTrivia */, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -94466,13 +94868,13 @@ var ts; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); - var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */; + var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ScriptTarget.ES2022 */; // We need to transform `this` in a static initializer into a reference to the class // when targeting < ES2022 since the assignment will be moved outside of the class body. - var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */; + var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ScriptTarget.ES2022 */; // We don't need to transform `super` property access when targeting ES5, ES3 because // the es2015 transformation handles those. - var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */; + var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ScriptTarget.ES2015 */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -94498,7 +94900,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ES2022 */) { + || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ScriptTarget.ES2022 */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -94506,50 +94908,50 @@ var ts; return visited; } function visitorWorker(node, valueIsDiscarded) { - if (node.transformFlags & 16777216 /* ContainsClassFields */) { + if (node.transformFlags & 16777216 /* TransformFlags.ContainsClassFields */) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassLike(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return visitPrivateIdentifier(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitClassStaticBlockDeclaration(node); } } - if (node.transformFlags & 16777216 /* ContainsClassFields */ || - node.transformFlags & 134217728 /* ContainsLexicalSuper */ && + if (node.transformFlags & 16777216 /* TransformFlags.ContainsClassFields */ || + node.transformFlags & 134217728 /* TransformFlags.ContainsLexicalSuper */ && shouldTransformSuperInStaticInitializers && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; currentStaticPropertyDeclarationOrStaticBlock = undefined; var result = ts.visitEachChild(node, visitor, context); @@ -94568,17 +94970,17 @@ var ts; } function heritageClauseVisitor(node) { switch (node.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return ts.visitEachChild(node, heritageClauseVisitor, context); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitExpressionWithTypeArguments(node); } return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -94608,7 +95010,7 @@ var ts; } var privId = node.left; ts.Debug.assertNode(privId, ts.isPrivateIdentifier); - ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */); + ts.Debug.assert(node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */); var info = accessPrivateIdentifier(privId); if (info) { var receiver = ts.visitNode(node.right, visitor, ts.isExpression); @@ -94624,19 +95026,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return visitor(node); @@ -94685,10 +95087,10 @@ var ts; ts.Debug.assert(ts.isPrivateIdentifier(node.name)); var info = accessPrivateIdentifier(node.name); ts.Debug.assert(info, "Undeclared private name for property declaration."); - if (info.kind === "m" /* Method */) { + if (info.kind === "m" /* PrivateIdentifierKind.Method */) { return info.methodName; } - if (info.kind === "a" /* Accessor */) { + if (info.kind === "a" /* PrivateIdentifierKind.Accessor */) { if (ts.isGetAccessor(node)) { return info.getterName; } @@ -94747,11 +95149,11 @@ var ts; function createPrivateIdentifierAccessHelper(info, receiver) { ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94770,7 +95172,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94789,7 +95191,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94803,16 +95205,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { - if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { + var operand = ts.skipParentheses(node.operand); + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) { var info = void 0; - if (info = accessPrivateIdentifier(node.operand.name)) { - var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); + if (info = accessPrivateIdentifier(operand.name)) { + var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); - expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */); + expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* SyntaxKind.EqualsToken */); ts.setOriginalNode(expression, node); ts.setTextRange(expression, node); if (temp) { @@ -94823,7 +95226,7 @@ var ts; } } else if (shouldTransformSuperInStaticInitializers && - ts.isSuperProperty(node.operand) && + ts.isSuperProperty(operand) && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { // converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)` @@ -94835,32 +95238,32 @@ var ts; // converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)` // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)` var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { - var operand = visitInvalidSuperProperty(node.operand); + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { + var expression = visitInvalidSuperProperty(operand); return ts.isPrefixUnaryExpression(node) ? - factory.updatePrefixUnaryExpression(node, operand) : - factory.updatePostfixUnaryExpression(node, operand); + factory.updatePrefixUnaryExpression(node, expression) : + factory.updatePostfixUnaryExpression(node, expression); } if (classConstructor && superClassReference) { var setterName = void 0; var getterName = void 0; - if (ts.isPropertyAccessExpression(node.operand)) { - if (ts.isIdentifier(node.operand.name)) { - getterName = setterName = factory.createStringLiteralFromNode(node.operand.name); + if (ts.isPropertyAccessExpression(operand)) { + if (ts.isIdentifier(operand.name)) { + getterName = setterName = factory.createStringLiteralFromNode(operand.name); } } else { - if (ts.isSimpleInlineableExpression(node.operand.argumentExpression)) { - getterName = setterName = node.operand.argumentExpression; + if (ts.isSimpleInlineableExpression(operand.argumentExpression)) { + getterName = setterName = operand.argumentExpression; } else { getterName = factory.createTempVariable(hoistVariableDeclaration); - setterName = factory.createAssignment(getterName, ts.visitNode(node.operand.argumentExpression, visitor, ts.isExpression)); + setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression)); } } if (setterName && getterName) { var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor); - ts.setTextRange(expression, node.operand); + ts.setTextRange(expression, operand); var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor); @@ -94951,7 +95354,7 @@ var ts; var iife = factory.createImmediatelyInvokedArrowFunction(statements); ts.setOriginalNode(iife, node); ts.setTextRange(iife, node); - ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(iife, 2 /* EmitFlags.AdviseOnEmitNode */); return iife; } } @@ -94978,7 +95381,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); } if (classConstructor && superClassReference) { @@ -95020,7 +95423,7 @@ var ts; } } } - if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) { + if (node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { return visitPrivateIdentifierInInExpression(node); } return ts.visitEachChild(node, visitor, context); @@ -95035,12 +95438,12 @@ var ts; } ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, /* f */ undefined); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -95080,28 +95483,28 @@ var ts; return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function getClassFacts(node) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; var original = ts.getOriginalNode(node); if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) { - facts |= 1 /* ClassWasDecorated */; + facts |= 1 /* ClassFacts.ClassWasDecorated */; } for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (!ts.isStatic(member)) continue; if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) { - facts |= 2 /* NeedsClassConstructorReference */; + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { - if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) { - facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */; - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */; + if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */) { + facts |= 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */; + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } } - if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) { - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */; + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* TransformFlags.ContainsLexicalSuper */) { + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */ | 4 /* ClassFacts.NeedsClassSuperReference */; } } } @@ -95109,8 +95512,8 @@ var ts; return facts; } function visitExpressionWithTypeArguments(node) { - var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */; - if (facts & 4 /* NeedsClassSuperReference */) { + var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* ClassFacts.None */; + if (facts & 4 /* ClassFacts.NeedsClassSuperReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true); getClassLexicalEnvironment().superClassReference = temp; return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)), @@ -95123,19 +95526,19 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If a class has private static fields, or a static field has a `this` or `super` reference, // then we need to allocate a temp variable to hold on to that reference. var pendingClassReferenceAssignment; - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node)); } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); var statements = [ factory.updateClassDeclaration(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) @@ -95163,7 +95566,7 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If this class expression is a transformation of a decorated class declaration, @@ -95173,19 +95576,19 @@ var ts; // In this case, we use pendingStatements to produce the same output as the // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. - var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */); + var isDecoratedClassDeclaration = !!(facts & 1 /* ClassFacts.ClassWasDecorated */); var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; var temp; function createClassTempVar() { var classCheckFlags = resolver.getNodeCheckFlags(node); - var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; - var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + var isClassWithConstructorReference = classCheckFlags & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); } - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { temp = createClassTempVar(); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } @@ -95214,12 +95617,12 @@ var ts; // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); var alias = factory.cloneNode(temp); - alias.autoGenerateFlags &= ~8 /* ReservedInNestedScopes */; + alias.autoGenerateFlags &= ~8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; classAliases[ts.getOriginalNodeId(node)] = alias; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* EmitFlags.Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression))); // Add any pending expressions leftover from elided or relocated computed property names ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine)); @@ -95272,13 +95675,13 @@ var ts; /*typeArguments*/ undefined, []))); } function isClassElementThatRequiresConstructorStatement(member) { - if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* ModifierFlags.Abstract */)) { return false; } if (useDefineForClassFields) { // If we are using define semantics and targeting ESNext or higher, // then we don't need to transform any class properties. - return languageVersion < 9 /* ES2022 */; + return languageVersion < 9 /* ScriptTarget.ES2022 */; } return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member); } @@ -95467,7 +95870,7 @@ var ts; if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) { // capture the lexical environment for the member ts.setOriginalNode(transformed, property); - ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(transformed, 2 /* EmitFlags.AdviseOnEmitNode */); classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment); } currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; @@ -95486,7 +95889,7 @@ var ts; if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - if (privateIdentifierInfo.kind === "f" /* Field */) { + if (privateIdentifierInfo.kind === "f" /* PrivateIdentifierKind.Field */) { if (!privateIdentifierInfo.isStatic) { return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); } @@ -95506,7 +95909,7 @@ var ts; return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); - if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* ModifierFlags.Abstract */)) { return undefined; } var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero() @@ -95525,32 +95928,32 @@ var ts; } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* ClassPropertySubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForClassStaticThisOrSuperReference() { - if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) { - enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */; + if ((enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */) === 0) { + enabledSubstitutions |= 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */; // substitute `this` in a static field initializer - context.enableSubstitution(108 /* ThisKeyword */); + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); // these push a new lexical environment that is not the class lexical environment - context.enableEmitNotification(256 /* FunctionDeclaration */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // these push a new lexical environment that is not the class lexical environment, except // when they have a computed property name - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(167 /* PropertyDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(167 /* SyntaxKind.PropertyDeclaration */); // class lexical environments are restored when entering a computed property name - context.enableEmitNotification(162 /* ComputedPropertyName */); + context.enableEmitNotification(162 /* SyntaxKind.ComputedPropertyName */); } } /** @@ -95589,13 +95992,13 @@ var ts; } } switch (node.kind) { - case 213 /* FunctionExpression */: - if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { + case 213 /* SyntaxKind.FunctionExpression */: + if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */) { break; } // falls through - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = undefined; @@ -95605,10 +96008,10 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; @@ -95618,7 +96021,7 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 162 /* ComputedPropertyName */: { + case 162 /* SyntaxKind.ComputedPropertyName */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; @@ -95639,24 +96042,24 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisExpression(node); } return node; } function substituteThisExpression(node) { - if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { + if (enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.createParenthesizedExpression(factory.createVoidZero()); } if (classConstructor) { @@ -95669,8 +96072,8 @@ var ts; return trySubstituteClassAlias(node) || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -95703,7 +96106,7 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(generatedName); } else { @@ -95723,7 +96126,7 @@ var ts; } function getClassLexicalEnvironment() { return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = { - facts: 0 /* None */, + facts: 0 /* ClassFacts.None */, classConstructor: undefined, superClassReference: undefined, privateIdentifierEnvironment: undefined, @@ -95756,7 +96159,7 @@ var ts; if (ts.isPropertyDeclaration(node)) { var variableName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, variableName: variableName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95766,7 +96169,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { var functionName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: functionName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95775,12 +96178,12 @@ var ts; } else if (ts.isGetAccessorDeclaration(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: classConstructor, @@ -95791,12 +96194,12 @@ var ts; } else if (ts.isSetAccessorDeclaration(node)) { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: classConstructor, @@ -95812,7 +96215,7 @@ var ts; else if (ts.isPropertyDeclaration(node)) { var weakMapName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, brandCheckIdentifier: weakMapName, isStatic: false, variableName: undefined, @@ -95824,7 +96227,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: createHoistedVariableForPrivateName(text, node), brandCheckIdentifier: weakSetName, isStatic: false, @@ -95835,12 +96238,12 @@ var ts; ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); if (ts.isGetAccessor(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: weakSetName, @@ -95851,12 +96254,12 @@ var ts; } else { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: weakSetName, @@ -95873,9 +96276,9 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16 /* Optimistic */); - if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) { + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */); + if (resolver.getNodeCheckFlags(node) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(identifier); } else { @@ -95917,9 +96320,9 @@ var ts; // differently inside the function. if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); } - return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */)); + return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* SyntaxKind.EqualsToken */)); } function visitArrayAssignmentTarget(node) { var target = ts.getTargetOfBindingOrAssignmentElement(node); @@ -95933,7 +96336,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95973,7 +96376,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -96081,15 +96484,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: return serializeTypeNode(node.type); - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createIdentifier("Function"); default: return ts.factory.createVoidZero(); @@ -96125,7 +96528,7 @@ var ts; return ts.factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 172 /* GetAccessor */) { + if (container && node.kind === 172 /* SyntaxKind.GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -96170,67 +96573,67 @@ var ts; } node = ts.skipTypeParentheses(node); switch (node.kind) { - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return ts.factory.createVoidZero(); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return ts.factory.createIdentifier("Function"); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return ts.factory.createIdentifier("Array"); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? ts.factory.createVoidZero() : ts.factory.createIdentifier("Boolean"); - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return ts.factory.createIdentifier("Boolean"); - case 198 /* TemplateLiteralType */: - case 150 /* StringKeyword */: + case 198 /* SyntaxKind.TemplateLiteralType */: + case 150 /* SyntaxKind.StringKeyword */: return ts.factory.createIdentifier("String"); - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return ts.factory.createIdentifier("Object"); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return serializeLiteralOfLiteralTypeNode(node.literal); - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return ts.factory.createIdentifier("Number"); - case 158 /* BigIntKeyword */: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); - case 151 /* SymbolKeyword */: - return getGlobalConstructor("Symbol", 2 /* ES2015 */); - case 178 /* TypeReference */: + case 158 /* SyntaxKind.BigIntKeyword */: + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); + case 151 /* SyntaxKind.SymbolKeyword */: + return getGlobalConstructor("Symbol", 2 /* ScriptTarget.ES2015 */); + case 178 /* SyntaxKind.TypeReference */: return serializeTypeReferenceNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ true); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ false); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], /*isIntersection*/ false); - case 193 /* TypeOperator */: - if (node.operator === 145 /* ReadonlyKeyword */) { + case 193 /* SyntaxKind.TypeOperator */: + if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 181 /* TypeQuery */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 182 /* TypeLiteral */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 192 /* ThisType */: - case 200 /* ImportType */: + case 181 /* SyntaxKind.TypeQuery */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 200 /* SyntaxKind.ImportType */: break; // handle JSDoc types from an invalid parse - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 317 /* JSDocFunctionType */: - case 318 /* JSDocVariadicType */: - case 319 /* JSDocNamepathType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 318 /* SyntaxKind.JSDocVariadicType */: + case 319 /* SyntaxKind.JSDocNamepathType */: break; - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 316 /* JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -96239,27 +96642,27 @@ var ts; } function serializeLiteralOfLiteralTypeNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.factory.createIdentifier("String"); - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; switch (operand.kind) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return serializeLiteralOfLiteralTypeNode(operand); default: return ts.Debug.failBadSyntaxKind(operand); } } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.factory.createIdentifier("Number"); - case 9 /* BigIntLiteral */: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 9 /* SyntaxKind.BigIntLiteral */: + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return ts.factory.createIdentifier("Boolean"); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return ts.factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node); @@ -96271,20 +96674,20 @@ var ts; for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { var typeNode = types_22[_i]; typeNode = ts.skipTypeParentheses(typeNode); - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { if (isIntersection) return ts.factory.createVoidZero(); // Reduce to `never` in an intersection continue; // Elide `never` in a union } - if (typeNode.kind === 155 /* UnknownKeyword */) { + if (typeNode.kind === 155 /* SyntaxKind.UnknownKeyword */) { if (!isIntersection) return ts.factory.createIdentifier("Object"); // Reduce to `unknown` in a union continue; // Elide `unknown` in an intersection } - if (typeNode.kind === 130 /* AnyKeyword */) { + if (typeNode.kind === 130 /* SyntaxKind.AnyKeyword */) { return ts.factory.createIdentifier("Object"); // Reduce to `any` in a union or intersection } - if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */) || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */) || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedConstituent = serializeTypeNode(typeNode); @@ -96365,7 +96768,7 @@ var ts; case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: return ts.factory.createVoidZero(); case ts.TypeReferenceSerializationKind.BigIntLikeType: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); case ts.TypeReferenceSerializationKind.BooleanType: return ts.factory.createIdentifier("Boolean"); case ts.TypeReferenceSerializationKind.NumberLikeType: @@ -96375,7 +96778,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return ts.factory.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return getGlobalConstructor("Symbol", 2 /* ES2015 */); + return getGlobalConstructor("Symbol", 2 /* ScriptTarget.ES2015 */); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: return ts.factory.createIdentifier("Function"); case ts.TypeReferenceSerializationKind.Promise: @@ -96405,12 +96808,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { // A -> typeof A !== "undefined" && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 79 /* Identifier */) { + if (node.left.kind === 79 /* SyntaxKind.Identifier */) { // A.B -> typeof A !== "undefined" && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -96425,14 +96828,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -96483,28 +96886,28 @@ var ts; return ts.isDecorator(node) ? undefined : node; } function visitor(node) { - if (!(node.transformFlags & 33554432 /* ContainsDecorators */)) { + if (!(node.transformFlags & 33554432 /* TransformFlags.ContainsDecorators */)) { return node; } switch (node.kind) { - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are elided. They will be emitted as part of `visitClassDeclaration`. return undefined; - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructorDeclaration(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitSetAccessorDeclaration(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return visitGetAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameterDeclaration(node); default: return ts.visitEachChild(node, visitor, context); @@ -96513,39 +96916,72 @@ var ts; function visitClassDeclaration(node) { if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node))) return ts.visitEachChild(node, visitor, context); - var classStatement = ts.hasDecorators(node) ? - createClassDeclarationHeadWithDecorators(node, node.name) : - createClassDeclarationHeadWithoutDecorators(node, node.name); - var statements = [classStatement]; - // Write any decorators of the node. - addClassElementDecorationStatements(statements, node, /*isStatic*/ false); - addClassElementDecorationStatements(statements, node, /*isStatic*/ true); - addConstructorDecorationStatement(statements, node); + var statements = ts.hasDecorators(node) ? + transformClassDeclarationWithClassDecorators(node, node.name) : + transformClassDeclarationWithoutClassDecorators(node, node.name); if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } + function decoratorContainsPrivateIdentifierInExpression(decorator) { + return !!(decorator.transformFlags & 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); + } + function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) { + return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression); + } + function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (!ts.canHaveDecorators(member)) + continue; + var allDecorators = ts.getAllDecoratorsOfClassElement(member, node); + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression)) + return true; + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression)) + return true; + } + return false; + } + function transformDecoratorsOfClassElements(node, members) { + var decorationStatements = []; + addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ false); + addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ true); + if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) { + members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [ + factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, /*multiLine*/ true)) + ], false)), members); + decorationStatements = undefined; + } + return { decorationStatements: decorationStatements, members: members }; + } /** * Transforms a non-decorated class declaration. * * @param node A ClassDeclaration node. * @param name The name of the class. */ - function createClassDeclarationHeadWithoutDecorators(node, name) { + function transformClassDeclarationWithoutClassDecorators(node, name) { // ${modifiers} class ${name} ${heritageClauses} { // ${members} // } - return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement)); + var _a; + var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = ts.visitNodes(node.members, visitor, ts.isClassElement); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var updated = factory.updateClassDeclaration(node, modifiers, name, + /*typeParameters*/ undefined, heritageClauses, members); + return ts.addRange([updated], decorationStatements); } /** * Transforms a decorated class declaration and appends the resulting statements. If * the class requires an alias to avoid issues with double-binding, the alias is returned. */ - function createClassDeclarationHeadWithDecorators(node, name) { + function transformClassDeclarationWithClassDecorators(node, name) { // When we emit an ES6 class that has a class decorator, we must tailor the // emit to certain specific cases. // @@ -96631,11 +97067,12 @@ var ts; // | var C_1; // --------------------------------------------------------------------- // + var _a; var location = ts.moveRangePastModifiers(node); var classAlias = getClassAliasIfNeeded(node); // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var declName = languageVersion <= 2 /* ES2015 */ ? + var declName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { @@ -96643,7 +97080,11 @@ var ts; // } var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = ts.visitNodes(node.members, visitor, ts.isClassElement); - var classExpression = factory.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var classExpression = factory.createClassExpression( + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); ts.setTextRange(classExpression, location); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference @@ -96653,11 +97094,14 @@ var ts; factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) - ], 1 /* Let */)); + ], 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); ts.setTextRange(statement, location); ts.setCommentRange(statement, node); - return statement; + var statements = [statement]; + ts.addRange(statements, decorationStatements); + addConstructorDecorationStatement(statements, node); + return statements; } function visitClassExpression(node) { // Legacy decorators were not supported on class expressions @@ -96690,7 +97134,7 @@ var ts; return finishClassElement(factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock)), node); } function visitPropertyDeclaration(node) { - if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { return undefined; } return finishClassElement(factory.updatePropertyDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), @@ -96707,7 +97151,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -96817,9 +97261,9 @@ var ts; // ], C.prototype, "prop"); // var prefix = getClassMemberPrefix(node, member); - var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */)); - var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 167 /* PropertyDeclaration */ + var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* ModifierFlags.Ambient */)); + var descriptor = languageVersion > 0 /* ScriptTarget.ES3 */ + ? member.kind === 167 /* SyntaxKind.PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -96828,7 +97272,7 @@ var ts; : factory.createNull() : undefined; var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member)); return helper; } @@ -96857,12 +97301,12 @@ var ts; var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var localName = languageVersion <= 2 /* ES2015 */ ? + var localName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 1536 /* NoComments */); + ts.setEmitFlags(expression, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node)); return expression; } @@ -96888,7 +97332,7 @@ var ts; var decorator = decorators_1[_i]; var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); ts.setTextRange(helper, decorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); expressions.push(helper); } } @@ -96921,7 +97365,7 @@ var ts; if (!classAliases) { // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } @@ -96932,7 +97376,7 @@ var ts; * double-binding semantics for the class name. */ function getClassAliasIfNeeded(node) { - if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) { + if (resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; @@ -96956,14 +97400,14 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -96974,7 +97418,7 @@ var ts; } function trySubstituteClassAlias(node) { if (classAliases) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -97046,8 +97490,8 @@ var ts; if (node.isDeclarationFile) { return node; } - setContextFlag(1 /* NonTopLevel */, false); - setContextFlag(2 /* HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); + setContextFlag(1 /* ContextFlags.NonTopLevel */, false); + setContextFlag(2 /* ContextFlags.HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -97059,10 +97503,10 @@ var ts; return (contextFlags & flags) !== 0; } function inTopLevelContext() { - return !inContext(1 /* NonTopLevel */); + return !inContext(1 /* ContextFlags.NonTopLevel */); } function inHasLexicalThisContext() { - return inContext(2 /* HasLexicalThis */); + return inContext(2 /* ContextFlags.HasLexicalThis */); } function doWithContext(flags, cb, value) { var contextFlagsToSet = flags & ~contextFlags; @@ -97078,39 +97522,39 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 256 /* TransformFlags.ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 169 /* MethodDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 256 /* FunctionDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 213 /* FunctionExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 214 /* ArrowFunction */: - return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitMethodDeclaration, node); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionDeclaration, node); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionExpression, node); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithContext(1 /* ContextFlags.NonTopLevel */, visitArrowFunction, node); + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -97118,27 +97562,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatementInAsyncBody(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatementInAsyncBody(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClauseInAsyncBody(node); - case 235 /* Block */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 248 /* WithStatement */: - case 250 /* LabeledStatement */: + case 235 /* SyntaxKind.Block */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -97220,7 +97664,7 @@ var ts; return factory.updateMethodDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97235,7 +97679,7 @@ var ts; function visitFunctionDeclaration(node) { return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97250,7 +97694,7 @@ var ts; function visitFunctionExpression(node) { return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97265,7 +97709,7 @@ var ts; function visitArrowFunction(node) { return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97286,7 +97730,7 @@ var ts; function isVariableDeclarationListWithCollidingName(node) { return !!node && ts.isVariableDeclarationList(node) - && !(node.flags & 3 /* BlockScoped */) + && !(node.flags & 3 /* NodeFlags.BlockScoped */) && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { @@ -97340,9 +97784,9 @@ var ts; resumeLexicalEnvironment(); var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 214 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + var promiseConstructor = languageVersion < 2 /* ScriptTarget.ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 214 /* SyntaxKind.ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* NodeCheckFlags.CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -97368,7 +97812,7 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); if (capturedSuperProperties.size) { @@ -97381,10 +97825,10 @@ var ts; ts.setTextRange(block, node.body); if (emitSuperHelpers && hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -97428,21 +97872,21 @@ var ts; return undefined; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -97455,8 +97899,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -97483,30 +97927,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -97526,19 +97970,19 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), location); } } @@ -97548,7 +97992,7 @@ var ts; function createSuperAccessVariableStatement(factory, resolver, node, names) { // Create a variable declaration with a getter/setter (if binding) definition for each name: // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... }); - var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) !== 0; + var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0; var accessors = []; names.forEach(function (_, key) { var name = ts.unescapeLeadingUnderscores(key); @@ -97558,7 +98002,7 @@ var ts; /* typeParameters */ undefined, /* parameters */ [], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */)))); + /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */)))); if (hasBinding) { getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction( /* modifiers */ undefined, @@ -97572,20 +98016,20 @@ var ts; /* initializer */ undefined) ], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */), factory.createIdentifier("v"))))); + /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v"))))); } accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter))); }); return factory.createVariableStatement( /* modifiers */ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), /* typeArguments */ undefined, [ factory.createNull(), factory.createObjectLiteralExpression(accessors, /* multiline */ true) ])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; })(ts || (ts = {})); @@ -97655,7 +98099,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -97687,7 +98131,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 131 /* AsyncKeyword */) { + if (node.kind === 131 /* SyntaxKind.AsyncKeyword */) { return undefined; } return node; @@ -97709,88 +98153,88 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 244 /* ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + return doWithHierarchyFacts(visitDefault, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: - return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 217 /* VoidExpression */: + case 242 /* SyntaxKind.ForStatement */: + return doWithHierarchyFacts(visitForStatement, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); - case 171 /* Constructor */: - return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 169 /* MethodDeclaration */: - return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 172 /* GetAccessor */: - return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 173 /* SetAccessor */: - return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 256 /* FunctionDeclaration */: - return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 213 /* FunctionExpression */: - return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 214 /* ArrowFunction */: - return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 164 /* Parameter */: + case 171 /* SyntaxKind.Constructor */: + return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 172 /* SyntaxKind.GetAccessor */: + return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 173 /* SyntaxKind.SetAccessor */: + return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithHierarchyFacts(visitArrowFunction, node, 2 /* HierarchyFacts.ArrowFunctionExcludes */, 0 /* HierarchyFacts.ArrowFunctionIncludes */); + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithHierarchyFacts(visitDefault, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); } function visitYieldExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { if (node.asteriskToken) { var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression); return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression( @@ -97804,15 +98248,15 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitReturnStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero())); } return ts.visitEachChild(node, visitor, context); } function visitLabeledStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 244 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 244 /* SyntaxKind.ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -97824,7 +98268,7 @@ var ts; var objects = []; for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { var e = elements_5[_i]; - if (e.kind === 298 /* SpreadAssignment */) { + if (e.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -97833,7 +98277,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 296 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 296 /* SyntaxKind.PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -97844,7 +98288,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { // spread elements emit like so: // non-spread elements are chunked together into object literals, and then all are passed to __assign: // { a, ...o, b } => __assign(__assign({a}, o), {b}); @@ -97867,7 +98311,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 205 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -97894,9 +98338,9 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* HierarchyFacts.SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? + 0 /* HierarchyFacts.StrictModeSourceFileIncludes */ : + 1 /* HierarchyFacts.SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -97917,10 +98361,10 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -97948,10 +98392,10 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name); - var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); + var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* FlattenLevel.ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { block = factory.updateBlock(block, __spreadArray([ @@ -97963,7 +98407,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; var visited = ts.visitEachChild(node, visitor, context); @@ -97989,8 +98433,8 @@ var ts; } function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); @@ -98007,8 +98451,8 @@ var ts; * @param node A ForOfStatement. */ function visitForOfStatement(node, outermostLabeledStatement) { - var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + if (node.initializer.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -98036,7 +98480,7 @@ var ts; } return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), + ], 1 /* NodeFlags.Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), /*multiLine*/ true), bodyLocation)); } return node; @@ -98056,10 +98500,10 @@ var ts; statements.push(statement); } return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), - /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function createDownlevelAwait(expression) { - return enclosingFunctionFlags & 1 /* Generator */ + return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(expression)) : factory.createAwaitExpression(expression); } @@ -98078,18 +98522,18 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 2 /* IterationContainer */ ? + var initializer = ancestorFacts & 2 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) : callValues; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), /*incrementor*/ undefined, /*statement*/ convertForOfStatementHead(node, getValue)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setOriginalNode(forStatement, node); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -98097,15 +98541,15 @@ var ts; factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } function parameterVisitor(node) { @@ -98120,7 +98564,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -98137,7 +98581,7 @@ var ts; if (parameters) { parameters.add(parameter); } - else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { parameters = new ts.Set(); } } @@ -98179,13 +98623,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateMethodDeclaration(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateMethodDeclaration(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifierLike) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98197,13 +98641,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionDeclaration(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionDeclaration(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98227,13 +98671,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98250,13 +98694,13 @@ var ts; capturedSuperProperties = new ts.Set(); hasSuperElementAccess = false; var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */))); + /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */))); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties); @@ -98267,10 +98711,10 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.updateBlock(node.body, statements); if (emitSuperHelpers && hasSuperElementAccess) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -98309,11 +98753,11 @@ var ts; // // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts if (parameter.name.elements.length > 0) { - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)); + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98322,7 +98766,7 @@ var ts; var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); var assignment = factory.createAssignment(name, initializer); var statement = factory.createExpressionStatement(assignment); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98338,32 +98782,32 @@ var ts; // } var name = factory.cloneNode(parameter.name); ts.setTextRange(name, parameter.name); - ts.setEmitFlags(name, 48 /* NoSourceMap */); + ts.setEmitFlags(name, 48 /* EmitFlags.NoSourceMap */); var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); - ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */); + ts.addEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | 1536 /* EmitFlags.NoComments */); var assignment = factory.createAssignment(name, initializer); ts.setTextRange(assignment, parameter); - ts.setEmitFlags(assignment, 1536 /* NoComments */); + ts.setEmitFlags(assignment, 1536 /* EmitFlags.NoComments */); var block = factory.createBlock([factory.createExpressionStatement(assignment)]); ts.setTextRange(block, parameter); - ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined"); var statement = factory.createIfStatement(typeCheck, block); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); statements = ts.append(statements, statement); } } - else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { containsPrecedingObjectRestOrSpread = true; - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter), + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* FlattenLevel.ObjectRest */, factory.getGeneratedNameForNode(parameter), /*doNotRecordTempVariablesInLine*/ false, /*skipInitializer*/ true); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98371,21 +98815,21 @@ var ts; return statements; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -98398,8 +98842,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -98426,30 +98870,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -98469,14 +98913,14 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } @@ -98501,11 +98945,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 64 /* TransformFlags.ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -98533,29 +98977,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 32 /* TransformFlags.ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 221 /* BinaryExpression */: - if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98597,7 +99041,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 206 /* PropertyAccessExpression */ + expression = node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -98620,10 +99064,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 208 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 208 /* SyntaxKind.CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -98632,7 +99076,7 @@ var ts; var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false); var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left; - var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */); + var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); if (!ts.isSimpleCopiableExpression(capturedLeft)) { capturedLeft = factory.createTempVariable(hoistVariableDeclaration); leftExpression = factory.createAssignment(capturedLeft, leftExpression); @@ -98642,8 +99086,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -98653,17 +99097,17 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 206 /* PropertyAccessExpression */ + rightExpression = segment.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (i === 0 && leftThisArg) { if (!ts.isGeneratedIdentifier(leftThisArg)) { leftThisArg = factory.cloneNode(leftThisArg); - ts.addEmitFlags(leftThisArg, 1536 /* NoComments */); + ts.addEmitFlags(leftThisArg, 1536 /* EmitFlags.NoComments */); } - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SyntaxKind.SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -98680,7 +99124,7 @@ var ts; return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target; } function createNotNullCondition(left, right, invert) { - return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* BarBarToken */ : 55 /* AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createVoidZero())); + return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* SyntaxKind.BarBarToken */ : 55 /* SyntaxKind.AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createVoidZero())); } function transformNullishCoalescingExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -98714,11 +99158,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) { + if ((node.transformFlags & 16 /* TransformFlags.ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -98768,7 +99212,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 4 /* TransformFlags.ContainsESNext */) === 0) { return node; } switch (node.kind) { @@ -98792,12 +99236,12 @@ var ts; if (currentFileState.filenameDeclaration) { return currentFileState.filenameDeclaration.name; } - var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); + var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); currentFileState.filenameDeclaration = declaration; return currentFileState.filenameDeclaration.name; } function getJsxFactoryCalleePrimitive(isStaticChildren) { - return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; + return compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; } function getJsxFactoryCallee(isStaticChildren) { var type = getJsxFactoryCalleePrimitive(isStaticChildren); @@ -98823,7 +99267,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); + var generatedName = factory.createUniqueName("_".concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */ | 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */); var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -98845,7 +99289,7 @@ var ts; ts.addEmitHelpers(visited, context.readEmitHelpers()); var statements = visited.statements; if (currentFileState.filenameDeclaration) { - statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */))); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* NodeFlags.Const */))); } if (currentFileState.utilizedImplicitRuntimeImports) { for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { @@ -98862,7 +99306,7 @@ var ts; factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); ts.setParentRecursive(requireStatement, /*incremental*/ false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement); } @@ -98878,7 +99322,7 @@ var ts; return visited; } function visitor(node) { - if (node.transformFlags & 2 /* ContainsJsx */) { + if (node.transformFlags & 2 /* TransformFlags.ContainsJsx */) { return visitorWorker(node); } else { @@ -98887,13 +99331,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98901,15 +99345,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return visitJsxText(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -98978,7 +99422,7 @@ var ts; if (keyAttr) { args.push(transformJsxAttributeInitializer(keyAttr.initializer)); } - if (compilerOptions.jsx === 5 /* ReactJSXDev */) { + if (compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */) { var originalFile = ts.getOriginalNode(currentSourceFile); if (originalFile && ts.isSourceFile(originalFile)) { // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature @@ -99043,7 +99487,7 @@ var ts; } function transformJsxAttributesToObjectProps(attrs, children) { var target = ts.getEmitScriptTarget(compilerOptions); - return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : + return target && target >= 5 /* ScriptTarget.ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : transformJsxAttributesToExpression(attrs, children); } function transformJsxAttributesToProps(attrs, children) { @@ -99083,14 +99527,14 @@ var ts; if (node === undefined) { return factory.createTrue(); } - if (node.kind === 10 /* StringLiteral */) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */) { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - if (node.kind === 288 /* JsxExpression */) { + if (node.kind === 288 /* SyntaxKind.JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -99191,7 +99635,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 278 /* JsxElement */) { + if (node.kind === 278 /* SyntaxKind.JsxElement */) { return getTagName(node.openingElement); } else { @@ -99494,11 +99938,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 512 /* TransformFlags.ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -99506,9 +99950,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 67 /* AsteriskAsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -99698,7 +100142,7 @@ var ts; currentSourceFile = undefined; currentText = undefined; taggedTemplateStringDeclarations = undefined; - hierarchyFacts = 0 /* None */; + hierarchyFacts = 0 /* HierarchyFacts.None */; return visited; } /** @@ -99708,7 +100152,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -99719,15 +100163,15 @@ var ts; * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* HierarchyFacts.SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 247 /* ReturnStatement */ + return (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */) !== 0 + && node.kind === 247 /* SyntaxKind.ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -99742,11 +100186,11 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 1024 /* TransformFlags.ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) + || (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) - || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; + || (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) !== 0; } function visitor(node) { return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node; @@ -99758,9 +100202,9 @@ var ts; if (shouldVisitNode(node)) { var original = ts.getOriginalNode(node); if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) { - var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.StaticInitializerExcludes */, 16449 /* HierarchyFacts.StaticInitializerIncludes */); var result = visitorWorker(node, /*expressionResultIsUnused*/ false); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); return result; } return visitorWorker(node, /*expressionResultIsUnused*/ false); @@ -99768,115 +100212,115 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return undefined; // elide static keyword - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitArrowFunction(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return visitIdentifier(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitVariableDeclarationList(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitBreakOrContinueStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return visitTemplateLiteral(node); - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return visitStringLiteral(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return visitNumericLiteral(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitSpreadElement(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return visitThisKeyword(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitMetaProperty(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(8064 /* HierarchyFacts.SourceFileExcludes */, 64 /* HierarchyFacts.SourceFileIncludes */); var prologue = []; var statements = []; startLexicalEnvironment(); @@ -99887,14 +100331,14 @@ var ts; } factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureThisForNodeIfNeeded(prologue, node); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + convertedLoopState.allowedNonLabeledJumps |= 2 /* Jump.Break */; var result = ts.visitEachChild(node, visitor, context); convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; return result; @@ -99902,17 +100346,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCaseBlock(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function returnCapturedThis(node) { - return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)), node); } function visitReturnStatement(node) { if (convertedLoopState) { - convertedLoopState.nonLocalJumps |= 8 /* Return */; + convertedLoopState.nonLocalJumps |= 8 /* Jump.Return */; if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { node = returnCapturedThis(node); } @@ -99928,11 +100372,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } if (convertedLoopState) { - if (hierarchyFacts & 2 /* ArrowFunction */) { + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */) { // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -99959,30 +100403,30 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 246 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 246 /* SyntaxKind.BreakStatement */ ? 2 /* Jump.Break */ : 4 /* Jump.Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 246 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Jump.Break */; labelMarker = "break"; } else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; + convertedLoopState.nonLocalJumps |= 4 /* Jump.Continue */; // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. labelMarker = "continue"; } } else { - if (node.kind === 246 /* BreakStatement */) { - labelMarker = "break-" + label.escapedText; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } @@ -99991,15 +100435,15 @@ var ts; var outParams = convertedLoopState.loopOutParameters; var expr = void 0; for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + var copyExpr = copyOutParameter(outParams[i], 1 /* CopyDirection.ToOutParameter */); if (i === 0) { expr = copyExpr; } else { - expr = factory.createBinaryExpression(expr, 27 /* CommaToken */, copyExpr); + expr = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, copyExpr); } } - returnExpression = factory.createBinaryExpression(expr, 27 /* CommaToken */, returnExpression); + returnExpression = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, returnExpression); } return factory.createReturnStatement(returnExpression); } @@ -100032,18 +100476,18 @@ var ts; ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - var exportStatement = ts.hasSyntacticModifier(node, 512 /* Default */) + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + var exportStatement = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? factory.createExportDefault(factory.getLocalName(node)) : factory.createExternalModuleExport(factory.getLocalName(node)); ts.setOriginalNode(exportStatement, statement); statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -100100,25 +100544,25 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */))] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* Indented */) | 524288 /* ReuseTempVariableScope */); + ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */) | 524288 /* EmitFlags.ReuseTempVariableScope */); // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = factory.createPartiallyEmittedExpression(classFunction); ts.setTextRangeEnd(inner, node.end); - ts.setEmitFlags(inner, 1536 /* NoComments */); + ts.setEmitFlags(inner, 1536 /* EmitFlags.NoComments */); var outer = factory.createPartiallyEmittedExpression(inner); ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos)); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); - ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + ts.addSyntheticLeadingComment(result, 3 /* SyntaxKind.MultiLineCommentTrivia */, "* @class "); return result; } /** @@ -100136,19 +100580,19 @@ var ts; addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(constructorLikeName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -100174,7 +100618,7 @@ var ts; function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); + var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = factory.createFunctionDeclaration( @@ -100184,10 +100628,10 @@ var ts; /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); + ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; } /** @@ -100221,7 +100665,7 @@ var ts; ts.setTextRange(statementsArray, node.members); var block = factory.createBlock(statementsArray, /*multiLine*/ true); ts.setTextRange(block, node); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -100236,7 +100680,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -100280,7 +100724,7 @@ var ts; superCallExpression = visitSuperCallInBody(superCall); } if (superCallExpression) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + hierarchyFacts |= 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */; } // Add parameter defaults at the beginning of the output, with prologue statements addDefaultValueAssignmentsIfNeeded(prologue, constructor); @@ -100290,7 +100734,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) { + if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -100313,7 +100757,7 @@ var ts; var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1)); - ts.setEmitFlags(superCall_1, 1536 /* NoComments */); + ts.setEmitFlags(superCall_1, 1536 /* EmitFlags.NoComments */); statements.push(returnStatement); } else { @@ -100352,7 +100796,7 @@ var ts; } } if (!isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))); } } } @@ -100402,11 +100846,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 247 /* ReturnStatement */) { + if (statement.kind === 247 /* SyntaxKind.ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 239 /* IfStatement */) { + else if (statement.kind === 239 /* SyntaxKind.IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -100414,7 +100858,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 235 /* Block */) { + else if (statement.kind === 235 /* SyntaxKind.Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -100423,10 +100867,10 @@ var ts; return false; } function createActualThis() { - return ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */); + return ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */); } function createDefaultSuperCallOrThis() { - return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); + return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -100513,11 +100957,11 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } else if (initializer) { - ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } return false; @@ -100535,11 +100979,11 @@ var ts; var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment( // TODO(rbuckton): Does this need to be parented? - ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); + ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); ts.insertStatementAfterCustomPrologue(statements, statement); } /** @@ -100570,10 +101014,10 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. // TODO(rbuckton): Does this need to be parented? - var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); - ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); + var declarationName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + ts.setEmitFlags(declarationName, 48 /* EmitFlags.NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -100583,7 +101027,7 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, factory.createArrayLiteralExpression([])) ])), - /*location*/ parameter), 1048576 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* EmitFlags.CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -100595,13 +101039,13 @@ var ts; : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* EmitFlags.CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 79 /* Identifier */) { + if (parameter.name.kind !== 79 /* SyntaxKind.Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, expressionName))), parameter), 1048576 /* EmitFlags.CustomPrologue */)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; @@ -100614,7 +101058,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 214 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* HierarchyFacts.CapturedLexicalThis */ && node.kind !== 214 /* SyntaxKind.ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -100628,7 +101072,7 @@ var ts; */ function insertSuperThisCaptureThisForNode(statements, superExpression) { enableSubstitutionsForCapturedThis(); - var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression)); + var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* SyntaxKind.EqualsToken */, superExpression)); ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression); ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent); } @@ -100636,38 +101080,38 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); ts.setSourceMapRange(captureThisStatement, node); ts.insertStatementAfterCustomPrologue(statements, captureThisStatement); } function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { - if (hierarchyFacts & 32768 /* NewTarget */) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return statements; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. - newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); + newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), - /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"), + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), 102 /* SyntaxKind.InstanceOfKeyword */, factory.getLocalName(node))), + /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"), /*colonToken*/ undefined, factory.createVoidZero()); break; default: @@ -100675,11 +101119,11 @@ var ts; } var captureNewTargetStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, newTarget) ])); - ts.setEmitFlags(captureNewTargetStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureNewTargetStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); if (copyOnWrite) { statements = statements.slice(); } @@ -100698,21 +101142,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -100751,7 +101195,7 @@ var ts; var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, /*location*/ member.name); e = factory.createAssignment(memberName, memberFunction); } - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); + ts.setEmitFlags(memberFunction, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.setTextRange(factory.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); @@ -100759,7 +101203,7 @@ var ts; // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 48 /* NoSourceMap */); + ts.setEmitFlags(statement, 48 /* EmitFlags.NoSourceMap */); return statement; } /** @@ -100773,7 +101217,7 @@ var ts; // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } @@ -100789,20 +101233,20 @@ var ts; // arguments are both mapped contiguously to the accessor name. // TODO(rbuckton): Does this need to be parented? var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(target, 1536 /* EmitFlags.NoComments */ | 32 /* EmitFlags.NoTrailingSourceMap */); ts.setSourceMapRange(target, firstAccessor.name); var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName); if (ts.isPrivateIdentifier(visitedAccessorName)) { return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015."); } var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 16 /* EmitFlags.NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(getterFunction, 512 /* EmitFlags.NoLeadingComments */); var getter = factory.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -100810,7 +101254,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(setterFunction, 512 /* EmitFlags.NoLeadingComments */); var setter = factory.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -100833,12 +101277,12 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (node.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); + var ancestorFacts = enterSubtree(15232 /* HierarchyFacts.ArrowFunctionExcludes */, 66 /* HierarchyFacts.ArrowFunctionIncludes */); var func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -100847,9 +101291,9 @@ var ts; /*type*/ undefined, transformFunctionBody(node)); ts.setTextRange(func, node); ts.setOriginalNode(func, node); - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); // If an arrow function contains - exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.ArrowFunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return func; } @@ -100859,17 +101303,17 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ - ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */ + ? enterSubtree(32662 /* HierarchyFacts.AsyncFunctionBodyExcludes */, 69 /* HierarchyFacts.AsyncFunctionBodyIncludes */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionExpression(node, /*modifiers*/ undefined, node.asteriskToken, name, @@ -100884,13 +101328,13 @@ var ts; function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, /*typeParameters*/ undefined, parameters, @@ -100907,14 +101351,14 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node) - ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + ? enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */ | 8 /* HierarchyFacts.NonStaticClassElement */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ && !name && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, @@ -100957,7 +101401,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 214 /* ArrowFunction */); + ts.Debug.assert(node.kind === 214 /* SyntaxKind.ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -100976,7 +101420,7 @@ var ts; var returnStatement = factory.createReturnStatement(expression); ts.setTextRange(returnStatement, body); ts.moveSyntheticComments(returnStatement, body); - ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1024 /* EmitFlags.NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -100997,10 +101441,10 @@ var ts; var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine); ts.setTextRange(block, node.body); if (!multiLine && singleLine) { - ts.setEmitFlags(block, 1 /* SingleLine */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* SyntaxKind.CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -101010,11 +101454,11 @@ var ts; // A function body is not a block scope. return ts.visitEachChild(node, visitor, context); } - var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ - ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) - : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */); + var ancestorFacts = hierarchyFacts & 256 /* HierarchyFacts.IterationStatement */ + ? enterSubtree(7104 /* HierarchyFacts.IterationStatementBlockExcludes */, 512 /* HierarchyFacts.IterationStatementBlockIncludes */) + : enterSubtree(6976 /* HierarchyFacts.BlockExcludes */, 128 /* HierarchyFacts.BlockIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -101045,9 +101489,9 @@ var ts; function visitBinaryExpression(node, expressionResultIsUnused) { // If we are here it is because this is a destructuring assignment. if (ts.isDestructuringAssignment(node)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -101075,12 +101519,12 @@ var ts; function isVariableStatementOfTypeScriptClassWrapper(node) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer - && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */); + && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* EmitFlags.TypeScriptClassWrapper */); } function visitVariableStatement(node) { - var ancestorFacts = enterSubtree(0 /* None */, ts.hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.None */, ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? 32 /* HierarchyFacts.ExportedVariableStatement */ : 0 /* HierarchyFacts.None */); var updated; - if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { + if (convertedLoopState && (node.declarationList.flags & 3 /* NodeFlags.BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -101089,10 +101533,10 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); + assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* FlattenLevel.All */); } else { - assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -101109,7 +101553,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -101118,11 +101562,11 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) { - if (node.flags & 3 /* BlockScoped */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */ || node.transformFlags & 524288 /* TransformFlags.ContainsBindingPattern */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var declarations = ts.flatMap(node.declarations, node.flags & 1 /* Let */ + var declarations = ts.flatMap(node.declarations, node.flags & 1 /* NodeFlags.Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration); var declarationList = factory.createVariableDeclarationList(declarations); @@ -101131,7 +101575,7 @@ var ts; ts.setCommentRange(declarationList, node); // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. - if (node.transformFlags & 524288 /* ContainsBindingPattern */ + if (node.transformFlags & 524288 /* TransformFlags.ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -101197,18 +101641,18 @@ var ts; // * Why loop initializer is excluded? // - Since we've introduced a fresh name it already will be undefined. var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 262144 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 524288 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 + var isCapturedInFunction = flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + var emittedAsTopLevel = (hierarchyFacts & 64 /* HierarchyFacts.TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); + && (hierarchyFacts & 512 /* HierarchyFacts.IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0 + && (hierarchyFacts & 4096 /* HierarchyFacts.ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0)); + && (hierarchyFacts & (2048 /* HierarchyFacts.ForStatement */ | 4096 /* HierarchyFacts.ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -101235,16 +101679,16 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var ancestorFacts = enterSubtree(32 /* HierarchyFacts.ExportedVariableStatement */, 0 /* HierarchyFacts.None */); var updated; if (ts.isBindingPattern(node.name)) { - updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* FlattenLevel.All */, + /*value*/ undefined, (ancestorFacts & 32 /* HierarchyFacts.ExportedVariableStatement */) !== 0); } else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function recordLabel(node) { @@ -101264,50 +101708,50 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function visitDoOrWhileStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(0 /* HierarchyFacts.DoOrWhileStatementExcludes */, 1280 /* HierarchyFacts.DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } function visitForStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(5056 /* HierarchyFacts.ForStatementExcludes */, 3328 /* HierarchyFacts.ForStatementIncludes */, node, outermostLabeledStatement); } function visitEachChildOfForStatement(node) { return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); } function visitForInStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; var initializer = node.initializer; if (ts.isVariableDeclarationList(initializer)) { - if (node.initializer.flags & 3 /* BlockScoped */) { + if (node.initializer.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* FlattenLevel.All */, boundValue); var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old @@ -101355,7 +101799,7 @@ var ts; } function createSyntheticBlockForConvertedStatements(statements) { return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), - /*multiLine*/ true), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: @@ -101387,18 +101831,18 @@ var ts; var counter = factory.createLoopVariable(); var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); + ts.setEmitFlags(expression, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(expression)); var forStatement = ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(counter, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(factory.createVariableDeclaration(rhsReference, /*exclamationToken*/ undefined, /*type*/ undefined, expression), node.expression) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression), /*incrementor*/ ts.setTextRange(factory.createPostfixIncrement(counter), node.expression), /*statement*/ convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)), /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } @@ -101414,33 +101858,33 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 1024 /* IterationContainer */ + var initializer = ancestorFacts & 1024 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values]) : values; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result, /*exclamationToken*/ undefined, /*type*/ undefined, next) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), /*incrementor*/ factory.createAssignment(result, next), /*statement*/ convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([ factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* EmitFlags.SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } /** @@ -101455,9 +101899,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 1048576 /* ContainsYield */ && - hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) { + if ((property.transformFlags & 1048576 /* TransformFlags.ContainsYield */ && + hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* SyntaxKind.ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -101470,7 +101914,7 @@ var ts; var temp = factory.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* Indented */ : 0)); + var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* EmitFlags.Indented */ : 0)); if (node.multiLine) { ts.startOnNewLine(assignment); } @@ -101482,7 +101926,7 @@ var ts; return factory.inlineExpressions(expressions); } function shouldConvertPartOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 131072 /* ContainsCapturedBlockScopeBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */) !== 0; } function shouldConvertInitializerOfForStatement(node) { return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer); @@ -101498,7 +101942,7 @@ var ts; || shouldConvertInitializerOfForStatement(node); } function shouldConvertBodyOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */) !== 0; } /** * Records constituents of name for the given variable to be hoisted in the outer scope. @@ -101509,7 +101953,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -101529,7 +101973,7 @@ var ts; // we get here if we are trying to emit normal loop loop inside converted loop // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + convertedLoopState.allowedNonLabeledJumps = 2 /* Jump.Break */ | 4 /* Jump.Continue */; } var result = convert ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts) @@ -101573,11 +102017,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 242 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 243 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 244 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 240 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 241 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 242 /* SyntaxKind.ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 243 /* SyntaxKind.ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 244 /* SyntaxKind.ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 240 /* SyntaxKind.DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 241 /* SyntaxKind.WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -101602,11 +102046,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -101615,7 +102059,7 @@ var ts; var loopParameters = []; // variables declared in the loop initializer that will be changed inside the loop var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) { var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) || shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node); @@ -101728,15 +102172,15 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0; - var emitFlags = 0 /* None */; + var containsYield = (node.initializer.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 0 /* EmitFlags.None */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && hierarchyFacts & 4 /* AsyncFunctionBody */) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; var statements = []; statements.push(factory.createVariableStatement(/*modifiers*/ undefined, node.initializer)); - copyOutParameters(currentState.loopOutParameters, 2 /* Initializer */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 2 /* LoopOutParameterFlags.Initializer */, 1 /* CopyDirection.ToOutParameter */, statements); // This transforms the following ES2015 syntax: // // for (let i = (setImmediate(() => console.log(i)), 0); i < 2; i++) { @@ -101762,12 +102206,12 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, ts.visitNode(factory.createBlock(statements, /*multiLine*/ true), visitor, ts.isBlock)), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } @@ -101829,7 +102273,7 @@ var ts; statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue())))); } if (shouldConvertConditionOfForStatement(node)) { - statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); + statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -101838,17 +102282,17 @@ var ts; else { statements.push(statement); } - copyOutParameters(currentState.loopOutParameters, 1 /* Body */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 1 /* CopyDirection.ToOutParameter */, statements); ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment); var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0; - var emitFlags = 524288 /* ReuseTempVariableScope */; + var containsYield = (node.statement.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 524288 /* EmitFlags.ReuseTempVariableScope */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && (hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) !== 0) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; // This transforms the following ES2015 syntax (in addition to other variations): // // for (let i = 0; i < 2; i++) { @@ -101868,18 +102312,18 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); + var source = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.originalName : outParam.outParamName; + return factory.createBinaryExpression(target, 63 /* SyntaxKind.EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -101892,7 +102336,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = factory.createCallExpression(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; return factory.createExpressionStatement(callResult); } @@ -101901,27 +102345,27 @@ var ts; // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop // simple loops are emitted as just 'loop()'; // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Jump.Continue */) && !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = factory.createCallExpression(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; if (isSimpleLoop) { statements.push(factory.createExpressionStatement(callResult)); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); } else { var loopResultName = factory.createUniqueName("state"); var stateVariable = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, /*exclamationToken*/ undefined, /*type*/ undefined, callResult)])); statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Jump.Return */) { var returnStatement = void 0; if (outerState) { - outerState.nonLocalJumps |= 8 /* Return */; + outerState.nonLocalJumps |= 8 /* Jump.Return */; returnStatement = factory.createReturnStatement(loopResultName); } else { @@ -101929,7 +102373,7 @@ var ts; } statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement)); } - if (state.nonLocalJumps & 2 /* Break */) { + if (state.nonLocalJumps & 2 /* Jump.Break */) { statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { @@ -101988,19 +102432,19 @@ var ts; else { loopParameters.push(factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); var checkFlags = resolver.getNodeCheckFlags(decl); - if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { var outParamName = factory.createUniqueName("out_" + ts.idText(name)); var flags = 0; - if (checkFlags & 4194304 /* NeedsLoopOutParameter */) { - flags |= 1 /* Body */; + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */) { + flags |= 1 /* LoopOutParameterFlags.Body */; } if (ts.isForStatement(container)) { if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) { - flags |= 2 /* Initializer */; + flags |= 2 /* LoopOutParameterFlags.Initializer */; } if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) || container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) { - flags |= 1 /* Body */; + flags |= 1 /* LoopOutParameterFlags.Body */; } } loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName }); @@ -102022,20 +102466,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -102090,14 +102534,14 @@ var ts; return expression; } function visitCatchClause(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated; ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = factory.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* FlattenLevel.All */, temp); var list = factory.createVariableDeclarationList(vars); ts.setTextRange(list, node.variableDeclaration); var destructure = factory.createVariableStatement(/*modifiers*/ undefined, list); @@ -102106,7 +102550,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function addStatementToStartOfBlock(block, statement) { @@ -102125,7 +102569,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); - ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 512 /* EmitFlags.NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } @@ -102138,17 +102582,17 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.modifiers, node.name, parameters, node.type, body); } else { updated = factory.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -102191,11 +102635,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { + if (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 106 /* SuperKeyword */ || + if (expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -102268,7 +102712,7 @@ var ts; // }()) // var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); - if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) { + if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression); } // The underlying call (3) is another IIFE that may contain a '_super' argument. @@ -102325,15 +102769,15 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. - if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || - node.expression.kind === 106 /* SuperKeyword */ || + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */ || + node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 106 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + ts.setEmitFlags(thisArg, 4 /* EmitFlags.NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 32768 /* ContainsRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -102347,7 +102791,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -102359,12 +102803,12 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); + resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis - ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) + ? factory.createAssignment(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), initializer) : initializer; } return ts.setOriginalNode(resultingCall, node); @@ -102453,13 +102897,13 @@ var ts; } } var helpers = emitHelpers(); - var startsWithSpread = segments[0].kind !== 0 /* None */; + var startsWithSpread = segments[0].kind !== 0 /* SpreadSegmentKind.None */; var expression = startsWithSpread ? factory.createArrayLiteralExpression() : segments[0].expression; for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) { var segment = segments[i]; // If this is for an argument list, it doesn't matter if the array is packed or sparse - expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList); + expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !isArgumentList); } return expression; } @@ -102475,12 +102919,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); // We don't need to pack already packed array literals, or existing calls to the `__read` helper. var isCallToReadHelper = ts.isCallToHelper(expression, "___read"); - var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */; + var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* SpreadSegmentKind.PackedSpread */ : 1 /* SpreadSegmentKind.UnpackedSpread */; // We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`. - if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { + if (compilerOptions.downlevelIteration && kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { expression = emitHelpers().createReadHelper(expression, /*count*/ undefined); // the `__read` helper returns a packed array, so we don't need to ensure a packed array - kind = 2 /* PackedSpread */; + kind = 2 /* SpreadSegmentKind.PackedSpread */; } return createSpreadSegment(kind, expression); } @@ -102488,7 +102932,7 @@ var ts; var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); // We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to // `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements` - return createSpreadSegment(0 /* None */, expression); + return createSpreadSegment(0 /* SpreadSegmentKind.None */, expression); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -102518,7 +102962,7 @@ var ts; * @param node A string literal. */ function visitNumericLiteral(node) { - if (node.numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) { + if (node.numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { return ts.setTextRange(factory.createNumericLiteral(node.text), node); } return node; @@ -102553,15 +102997,15 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ + return hierarchyFacts & 8 /* HierarchyFacts.NonStaticClassElement */ && !isExpressionOfCall - ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") - : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), "prototype") + : factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { - hierarchyFacts |= 32768 /* NewTarget */; - return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */ && node.name.escapedText === "target") { + hierarchyFacts |= 32768 /* HierarchyFacts.NewTarget */; + return factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } return node; } @@ -102573,13 +103017,13 @@ var ts; * @param emitCallback The callback used to emit the node. */ function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ - ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ - : 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, ts.getEmitFlags(node) & 8 /* EmitFlags.CapturesThis */ + ? 65 /* HierarchyFacts.FunctionIncludes */ | 16 /* HierarchyFacts.CapturesThis */ + : 65 /* HierarchyFacts.FunctionIncludes */); previousOnEmitNode(hint, node, emitCallback); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return; } previousOnEmitNode(hint, node, emitCallback); @@ -102589,9 +103033,9 @@ var ts; * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* ES2015SubstitutionFlags.BlockScopedBindings */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } /** @@ -102599,16 +103043,16 @@ var ts; * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(108 /* ThisKeyword */); - context.enableEmitNotification(171 /* Constructor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(214 /* ArrowFunction */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(256 /* FunctionDeclaration */); + if ((enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* ES2015SubstitutionFlags.CapturedThis */; + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(214 /* SyntaxKind.ArrowFunction */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); } } /** @@ -102619,7 +103063,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -102633,7 +103077,7 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return ts.setTextRange(factory.getGeneratedNameForNode(original), node); @@ -102649,10 +103093,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -102665,9 +103109,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -102678,7 +103122,7 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node); @@ -102715,9 +103159,9 @@ var ts; * @param node The ThisKeyword node. */ function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && hierarchyFacts & 16 /* CapturesThis */) { - return ts.setTextRange(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ + && hierarchyFacts & 16 /* HierarchyFacts.CapturesThis */) { + return ts.setTextRange(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node); } return node; } @@ -102734,19 +103178,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* SyntaxKind.ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SyntaxKind.SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SyntaxKind.SpreadElement */) { return false; } var expression = callArgument.expression; @@ -102769,18 +103213,18 @@ var ts; // enable emit notification only if using --jsx preserve or react-native var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + if (compilerOptions.jsx === 1 /* JsxEmit.Preserve */ || compilerOptions.jsx === 3 /* JsxEmit.ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(280 /* JsxOpeningElement */); - context.enableEmitNotification(281 /* JsxClosingElement */); - context.enableEmitNotification(279 /* JsxSelfClosingElement */); + context.enableEmitNotification(280 /* SyntaxKind.JsxOpeningElement */); + context.enableEmitNotification(281 /* SyntaxKind.JsxClosingElement */); + context.enableEmitNotification(279 /* SyntaxKind.JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(296 /* PropertyAssignment */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(296 /* SyntaxKind.PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -102799,9 +103243,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -102861,7 +103305,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -103041,11 +103485,11 @@ var ts; })(Instruction || (Instruction = {})); function getInstructionName(instruction) { switch (instruction) { - case 2 /* Return */: return "return"; - case 3 /* Break */: return "break"; - case 4 /* Yield */: return "yield"; - case 5 /* YieldStar */: return "yield*"; - case 7 /* Endfinally */: return "endfinally"; + case 2 /* Instruction.Return */: return "return"; + case 3 /* Instruction.Break */: return "break"; + case 4 /* Instruction.Yield */: return "yield"; + case 5 /* Instruction.YieldStar */: return "yield*"; + case 7 /* Instruction.Endfinally */: return "endfinally"; default: return undefined; // TODO: GH#18217 } } @@ -103099,7 +103543,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 2048 /* TransformFlags.ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -103122,7 +103566,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 2048 /* ContainsGenerator */) { + else if (transformFlags & 2048 /* TransformFlags.ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -103136,13 +103580,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -103155,30 +103599,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitBreakStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 1048576 /* ContainsYield */) { + if (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (2048 /* TransformFlags.ContainsGenerator */ | 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -103193,23 +103637,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitConditionalExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -103222,9 +103666,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -103382,13 +103826,13 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 1048576 /* ContainsYield */) { + if (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -103413,9 +103857,9 @@ var ts; function visitBinaryExpression(node) { var assoc = ts.getExpressionAssociativity(node); switch (assoc) { - case 0 /* Left */: + case 0 /* Associativity.Left */: return visitLeftAssociativeBinaryExpression(node); - case 1 /* Right */: + case 1 /* Associativity.Right */: return visitRightAssociativeBinaryExpression(node); default: return ts.Debug.assertNever(assoc); @@ -103431,7 +103875,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // [source] // a.b = yield; // @@ -103443,7 +103887,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // [source] // a[b] = yield; // @@ -103475,7 +103919,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 27 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return visitCommaExpression(node); } // [source] @@ -103509,13 +103953,13 @@ var ts; visit(node.right); return factory.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { visit(node.left); visit(node.right); } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -103532,12 +103976,12 @@ var ts; var pendingExpressions = []; for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var elem = _a[_i]; - if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { pendingExpressions.push(visitCommaExpression(elem)); } else { if (containsYield(elem) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression)); @@ -103582,7 +104026,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -103648,7 +104092,7 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { // NOTE: `expression` must be defined for `yield*`. - var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* EmitFlags.Iterator */) === 0 ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node) : expression; emitYieldStar(iterator, /*location*/ node); @@ -103837,35 +104281,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return transformAndEmitBlock(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return transformAndEmitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return transformAndEmitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return transformAndEmitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return transformAndEmitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return transformAndEmitForInStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return transformAndEmitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return transformAndEmitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return transformAndEmitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return transformAndEmitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return transformAndEmitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -104295,7 +104739,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 290 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -104308,7 +104752,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -104440,7 +104884,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -104453,7 +104897,7 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; @@ -104484,7 +104928,7 @@ var ts; return node; } function cacheExpression(node) { - if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return node; } var temp = factory.createTempVariable(hoistVariableDeclaration); @@ -104530,7 +104974,7 @@ var ts; blockStack = []; } var index = blockActions.length; - blockActions[index] = 0 /* Open */; + blockActions[index] = 0 /* BlockAction.Open */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.push(block); @@ -104544,7 +104988,7 @@ var ts; if (block === undefined) return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; - blockActions[index] = 1 /* Close */; + blockActions[index] = 1 /* BlockAction.Close */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.pop(); @@ -104573,7 +105017,7 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 1 /* With */, + kind: 1 /* CodeBlockKind.With */, expression: expression, startLabel: startLabel, endLabel: endLabel @@ -104583,7 +105027,7 @@ var ts; * Ends a code block for a generated `with` statement. */ function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); + ts.Debug.assert(peekBlockKind() === 1 /* CodeBlockKind.With */); var block = endBlock(); markLabel(block.endLabel); } @@ -104595,8 +105039,8 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, + kind: 0 /* CodeBlockKind.Exception */, + state: 0 /* ExceptionBlockState.Try */, startLabel: startLabel, endLabel: endLabel }); @@ -104609,7 +105053,7 @@ var ts; * @param variable The catch variable. */ function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); // generated identifiers should already be unique within a file var name; if (ts.isGeneratedIdentifier(variable.name)) { @@ -104622,18 +105066,18 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); + ts.Debug.assert(exception.state < 1 /* ExceptionBlockState.Catch */); var endLabel = exception.endLabel; emitBreak(endLabel); var catchLabel = defineLabel(); markLabel(catchLabel); - exception.state = 1 /* Catch */; + exception.state = 1 /* ExceptionBlockState.Catch */; exception.catchVariable = name; exception.catchLabel = catchLabel; emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), /*typeArguments*/ undefined, [])); @@ -104643,24 +105087,24 @@ var ts; * Enters the `finally` block of a generated `try` statement. */ function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); + ts.Debug.assert(exception.state < 2 /* ExceptionBlockState.Finally */); var endLabel = exception.endLabel; emitBreak(endLabel); var finallyLabel = defineLabel(); markLabel(finallyLabel); - exception.state = 2 /* Finally */; + exception.state = 2 /* ExceptionBlockState.Finally */; exception.finallyLabel = finallyLabel; } /** * Ends the code block for a generated `try` statement. */ function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = endBlock(); var state = exception.state; - if (state < 2 /* Finally */) { + if (state < 2 /* ExceptionBlockState.Finally */) { emitBreak(exception.endLabel); } else { @@ -104668,7 +105112,7 @@ var ts; } markLabel(exception.endLabel); emitNop(); - exception.state = 3 /* Done */; + exception.state = 3 /* ExceptionBlockState.Done */; } /** * Begins a code block that supports `break` or `continue` statements that are defined in @@ -104678,7 +105122,7 @@ var ts; */ function beginScriptLoopBlock() { beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: true, breakLabel: -1, continueLabel: -1 @@ -104695,7 +105139,7 @@ var ts; function beginLoopBlock(continueLabel) { var breakLabel = defineLabel(); beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: false, breakLabel: breakLabel, continueLabel: continueLabel, @@ -104707,7 +105151,7 @@ var ts; * generated code or in the source tree. */ function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + ts.Debug.assert(peekBlockKind() === 3 /* CodeBlockKind.Loop */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -104721,7 +105165,7 @@ var ts; */ function beginScriptSwitchBlock() { beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: true, breakLabel: -1 }); @@ -104734,7 +105178,7 @@ var ts; function beginSwitchBlock() { var breakLabel = defineLabel(); beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: false, breakLabel: breakLabel, }); @@ -104744,7 +105188,7 @@ var ts; * Ends a code block that supports `break` statements that are defined in generated code. */ function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + ts.Debug.assert(peekBlockKind() === 2 /* CodeBlockKind.Switch */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -104753,7 +105197,7 @@ var ts; } function beginScriptLabeledBlock(labelText) { beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: true, labelText: labelText, breakLabel: -1 @@ -104762,14 +105206,14 @@ var ts; function beginLabeledBlock(labelText) { var breakLabel = defineLabel(); beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: false, labelText: labelText, breakLabel: breakLabel }); } function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + ts.Debug.assert(peekBlockKind() === 4 /* CodeBlockKind.Labeled */); var block = endBlock(); if (!block.isScript) { markLabel(block.breakLabel); @@ -104781,8 +105225,8 @@ var ts; * @param block A code block. */ function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; + return block.kind === 2 /* CodeBlockKind.Switch */ + || block.kind === 3 /* CodeBlockKind.Loop */; } /** * Indicates whether the provided block supports `break` statements with labels. @@ -104790,7 +105234,7 @@ var ts; * @param block A code block. */ function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; + return block.kind === 4 /* CodeBlockKind.Labeled */; } /** * Indicates whether the provided block supports `continue` statements. @@ -104798,7 +105242,7 @@ var ts; * @param block A code block. */ function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; + return block.kind === 3 /* CodeBlockKind.Loop */; } function hasImmediateContainingLabeledBlock(labelText, start) { for (var j = start; j >= 0; j--) { @@ -104895,7 +105339,7 @@ var ts; */ function createInstruction(instruction) { var literal = factory.createNumericLiteral(instruction); - ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); + ts.addSyntheticTrailingComment(literal, 3 /* SyntaxKind.MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -104907,7 +105351,7 @@ var ts; function createInlineBreak(label, location) { ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) ])), location); } @@ -104919,8 +105363,8 @@ var ts; */ function createInlineReturn(expression, location) { return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), location); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. @@ -104933,7 +105377,7 @@ var ts; * Emits an empty instruction. */ function emitNop() { - emitWorker(0 /* Nop */); + emitWorker(0 /* OpCode.Nop */); } /** * Emits a Statement. @@ -104942,7 +105386,7 @@ var ts; */ function emitStatement(node) { if (node) { - emitWorker(1 /* Statement */, [node]); + emitWorker(1 /* OpCode.Statement */, [node]); } else { emitNop(); @@ -104956,7 +105400,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); + emitWorker(2 /* OpCode.Assign */, [left, right], location); } /** * Emits a Break operation to the specified label. @@ -104965,7 +105409,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); + emitWorker(3 /* OpCode.Break */, [label], location); } /** * Emits a Break operation to the specified label when a condition evaluates to a truthy @@ -104976,7 +105420,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + emitWorker(4 /* OpCode.BreakWhenTrue */, [label, condition], location); } /** * Emits a Break to the specified label when a condition evaluates to a falsey value at @@ -104987,7 +105431,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + emitWorker(5 /* OpCode.BreakWhenFalse */, [label, condition], location); } /** * Emits a YieldStar operation for the provided expression. @@ -104996,7 +105440,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + emitWorker(7 /* OpCode.YieldStar */, [expression], location); } /** * Emits a Yield operation for the provided expression. @@ -105005,7 +105449,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + emitWorker(6 /* OpCode.Yield */, [expression], location); } /** * Emits a Return operation for the provided expression. @@ -105014,7 +105458,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + emitWorker(8 /* OpCode.Return */, [expression], location); } /** * Emits a Throw operation for the provided expression. @@ -105023,13 +105467,13 @@ var ts; * @param location An optional source map location for the assignment. */ function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + emitWorker(9 /* OpCode.Throw */, [expression], location); } /** * Emits an Endfinally operation. This is used to handle `finally` block semantics. */ function emitEndfinally() { - emitWorker(10 /* Endfinally */); + emitWorker(10 /* OpCode.Endfinally */); } /** * Emits an operation. @@ -105073,7 +105517,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, factory.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* EmitFlags.ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -105246,8 +105690,8 @@ var ts; var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; switch (block.kind) { - case 0 /* Exception */: - if (blockAction === 0 /* Open */) { + case 0 /* CodeBlockKind.Exception */: + if (blockAction === 0 /* BlockAction.Open */) { if (!exceptionBlockStack) { exceptionBlockStack = []; } @@ -105257,18 +105701,18 @@ var ts; exceptionBlockStack.push(currentExceptionBlock); currentExceptionBlock = block; } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { currentExceptionBlock = exceptionBlockStack.pop(); } break; - case 1 /* With */: - if (blockAction === 0 /* Open */) { + case 1 /* CodeBlockKind.With */: + if (blockAction === 0 /* BlockAction.Open */) { if (!withBlockStack) { withBlockStack = []; } withBlockStack.push(block); } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { withBlockStack.pop(); } break; @@ -105292,33 +105736,33 @@ var ts; lastOperationWasAbrupt = false; lastOperationWasCompletion = false; var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { + if (opcode === 0 /* OpCode.Nop */) { return; } - else if (opcode === 10 /* Endfinally */) { + else if (opcode === 10 /* OpCode.Endfinally */) { return writeEndfinally(); } var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { + if (opcode === 1 /* OpCode.Statement */) { return writeStatement(args[0]); } var location = operationLocations[operationIndex]; switch (opcode) { - case 2 /* Assign */: + case 2 /* OpCode.Assign */: return writeAssign(args[0], args[1], location); - case 3 /* Break */: + case 3 /* OpCode.Break */: return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: + case 4 /* OpCode.BreakWhenTrue */: return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: + case 5 /* OpCode.BreakWhenFalse */: return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: + case 6 /* OpCode.Yield */: return writeYield(args[0], location); - case 7 /* YieldStar */: + case 7 /* OpCode.YieldStar */: return writeYieldStar(args[0], location); - case 8 /* Return */: + case 8 /* OpCode.Return */: return writeReturn(args[0], location); - case 9 /* Throw */: + case 9 /* OpCode.Throw */: return writeThrow(args[0], location); } } @@ -105368,8 +105812,8 @@ var ts; lastOperationWasAbrupt = true; lastOperationWasCompletion = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -105380,9 +105824,9 @@ var ts; function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -105393,9 +105837,9 @@ var ts; */ function writeBreakWhenTrue(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -105406,9 +105850,9 @@ var ts; */ function writeBreakWhenFalse(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -105419,8 +105863,8 @@ var ts; function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(4 /* Instruction.Yield */), expression] + : [createInstruction(4 /* Instruction.Yield */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -105431,9 +105875,9 @@ var ts; function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(5 /* YieldStar */), + createInstruction(5 /* Instruction.YieldStar */), expression - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -105441,7 +105885,7 @@ var ts; function writeEndfinally() { lastOperationWasAbrupt = true; writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(7 /* Endfinally */) + createInstruction(7 /* Instruction.Endfinally */) ]))); } } @@ -105468,12 +105912,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(208 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(210 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -105489,7 +105933,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 8388608 /* ContainsDynamicImport */ || + node.transformFlags & 8388608 /* TransformFlags.ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -105625,7 +106069,7 @@ var ts; factory.createIdentifier("exports") ])) ]), - ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* EmitFlags.SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ @@ -105710,7 +106154,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } @@ -105779,13 +106223,13 @@ var ts; if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); statements.push(statement); } } @@ -105801,23 +106245,23 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -105826,30 +106270,30 @@ var ts; function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (8388608 /* TransformFlags.ContainsDynamicImport */ | 4096 /* TransformFlags.ContainsDestructuringAssignment */ | 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -105865,24 +106309,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -105908,7 +106352,7 @@ var ts; } function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded, createAllExportExpressions); } return ts.visitEachChild(node, visitor, context); } @@ -105934,7 +106378,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -105977,7 +106421,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -106004,7 +106448,7 @@ var ts; // }); needUMDDynamicImportHelper = true; if (ts.isSimpleCopiableExpression(arg)) { - var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */); + var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* EmitFlags.NoComments */); return factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, @@ -106040,7 +106484,7 @@ var ts; /*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) ]); var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, parameters, @@ -106058,7 +106502,7 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); @@ -106079,7 +106523,7 @@ var ts; requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, @@ -106099,13 +106543,13 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { @@ -106114,7 +106558,7 @@ var ts; return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { @@ -106161,7 +106605,7 @@ var ts; } } statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), /*location*/ node), /*original*/ node)); } @@ -106175,7 +106619,7 @@ var ts; /*type*/ undefined, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) - ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + ], languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */))); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -106209,7 +106653,7 @@ var ts; ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)); } else { @@ -106219,11 +106663,11 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); } } else { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node)); } } @@ -106264,12 +106708,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && - !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && + !(ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); @@ -106320,7 +106764,7 @@ var ts; */ function visitFunctionDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), /*type*/ undefined, ts.visitEachChild(node.body, visitor, context)), @@ -106347,7 +106791,7 @@ var ts; */ function visitClassDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); } @@ -106373,7 +106817,7 @@ var ts; var statements; var variables; var expressions; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var modifiers = void 0; var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. @@ -106431,7 +106875,7 @@ var ts; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. - ts.setEmitFlags(expression, 4 /* NoSubstitution */); + ts.setEmitFlags(expression, 4 /* EmitFlags.NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; @@ -106446,7 +106890,7 @@ var ts; function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), - /*visitor*/ undefined, context, 0 /* All */, + /*visitor*/ undefined, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAllExportExpressions); } else { @@ -106468,7 +106912,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -106480,7 +106924,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -106523,10 +106967,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -106609,8 +107053,8 @@ var ts; if (currentModuleInfo.exportEquals) { return statements; } - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -106655,7 +107099,7 @@ var ts; } function createUnderscoreUnderscoreESModule() { var statement; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())); } else { @@ -106668,7 +107112,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); return statement; } /** @@ -106683,7 +107127,7 @@ var ts; var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -106695,7 +107139,7 @@ var ts; * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { - return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), + return ts.setTextRange(liveBinding && languageVersion !== 0 /* ScriptTarget.ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), @@ -106722,8 +107166,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -106739,7 +107183,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); @@ -106764,7 +107208,7 @@ var ts; if (node.id && noSubstitution[node.id]) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -106799,13 +107243,13 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); } return node; @@ -106814,9 +107258,9 @@ var ts; if (ts.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); noSubstitution[ts.getNodeId(expression)] = true; - if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateCallExpression(node, expression, - /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.arguments), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -106825,9 +107269,9 @@ var ts; if (ts.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); noSubstitution[ts.getNodeId(tag)] = true; - if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, - /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.template), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -106840,16 +107284,16 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } return node; } - else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -106938,11 +107382,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(231 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(231 /* SyntaxKind.MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -106962,7 +107406,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* TransformFlags.ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -107009,7 +107453,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ]), node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* EmitFlags.NoTrailingComments */); if (!ts.outFile(compilerOptions)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -107131,8 +107575,8 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 - var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ? - factory.createModifiersFromModifierFlags(256 /* Async */) : + var modifiers = node.transformFlags & 2097152 /* TransformFlags.ContainsAwait */ ? + factory.createModifiersFromModifierFlags(256 /* ModifierFlags.Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -107166,7 +107610,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 272 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 272 /* SyntaxKind.ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -107231,7 +107675,7 @@ var ts; factory.createForInStatement(factory.createVariableDeclarationList([ factory.createVariableDeclaration(n) ]), m, factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */) ])), factory.createExpressionStatement(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exports])) @@ -107255,19 +107699,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -107326,13 +107770,13 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); default: return topLevelNestedVisitor(node); @@ -107408,7 +107852,7 @@ var ts; * @param node The node to visit. */ function visitFunctionDeclaration(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock))); @@ -107460,7 +107904,7 @@ var ts; return ts.visitNode(node, visitor, ts.isStatement); } var expressions; - var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; @@ -107510,9 +107954,9 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 305 /* SourceFile */ - || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + return (ts.getEmitFlags(node) & 2097152 /* EmitFlags.NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 305 /* SyntaxKind.SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* NodeFlags.BlockScoped */) === 0); } /** * Transform an initialized variable declaration into an expression. @@ -107523,7 +107967,7 @@ var ts; function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAssignment) : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name; } @@ -107575,9 +108019,9 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); - var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* ModifierFlags.Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); } return node; @@ -107588,7 +108032,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -107637,10 +108081,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -107734,8 +108178,8 @@ var ts; return statements; } var excludeName; - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createStringLiteral("default") : decl.name; + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory.getLocalName(decl)); excludeName = ts.getTextOfIdentifierOrLiteral(exportName); } @@ -107795,7 +108239,7 @@ var ts; var statement = factory.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -107807,7 +108251,7 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name; - ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* EmitFlags.NoComments */); return ts.setCommentRange(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // @@ -107820,43 +108264,43 @@ var ts; */ function topLevelNestedVisitor(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ true); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitDefaultClause(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitTryStatement(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -108038,30 +108482,30 @@ var ts; * @param node The node to visit. */ function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4096 /* TransformFlags.ContainsDestructuringAssignment */ | 8388608 /* TransformFlags.ContainsDynamicImport */ | 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node)) { return visitImportCallExpression(node); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -108111,7 +108555,7 @@ var ts; */ function visitDestructuringAssignment(node, valueIsDiscarded) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); } @@ -108141,7 +108585,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 305 /* SourceFile */; + return container !== undefined && container.kind === 305 /* SyntaxKind.SourceFile */; } else { return false; @@ -108157,7 +108601,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -108202,8 +108646,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -108219,7 +108663,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -108254,10 +108698,10 @@ var ts; if (isSubstitutionPrevented(node)) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } - else if (hint === 4 /* Unspecified */) { + else if (hint === 4 /* EmitHint.Unspecified */) { return substituteUnspecified(node); } return node; @@ -108269,7 +108713,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -108304,11 +108748,11 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return substituteMetaProperty(node); } return node; @@ -108320,7 +108764,7 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); @@ -108398,7 +108842,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -108441,8 +108885,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(305 /* SourceFile */); - context.enableSubstitution(79 /* Identifier */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); var helperNameSubstitutions; var currentSourceFile; var importRequireStatements; @@ -108481,14 +108925,14 @@ var ts; } function visitor(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` // is available, just because the output is reasonable for a node-like runtime. return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -108506,23 +108950,23 @@ var ts; args.push(moduleName); } if (!importRequireStatements) { - var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */); + var createRequireName = factory.createUniqueName("_createRequire", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var importStatement = factory.createImportDeclaration( /*modifiers*/ undefined, factory.createImportClause( /*isTypeOnly*/ false, /*name*/ undefined, factory.createNamedImports([ factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName) ])), factory.createStringLiteral("module")); - var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */); + var requireHelperName = factory.createUniqueName("__require", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var requireStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(requireHelperName, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ - factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) + factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) ])) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)); importRequireStatements = [importStatement, requireStatement]; } var name = importRequireStatements[1].declarationList.declarations[0].name; @@ -108543,12 +108987,12 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); statements = appendExportsOfImportEqualsDeclaration(statements, node); return ts.singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, factory.createExportDeclaration( /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))]))); } @@ -108613,7 +109057,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return substituteHelperName(node); } return node; @@ -108622,7 +109066,7 @@ var ts; var name = ts.idText(node); var substitution = helperNameSubstitutions.get(name); if (!substitution) { - helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */)); + helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)); } return substitution; } @@ -108645,8 +109089,8 @@ var ts; var cjsOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(305 /* SourceFile */); - context.enableEmitNotification(305 /* SourceFile */); + context.enableSubstitution(305 /* SyntaxKind.SourceFile */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); var currentSourceFile; return transformSourceFileOrBundle; function onSubstituteNode(hint, node) { @@ -108693,7 +109137,7 @@ var ts; return result; } function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -108748,14 +109192,14 @@ var ts; function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -108777,14 +109221,14 @@ var ts; function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; @@ -108808,7 +109252,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -108826,31 +109270,31 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind)); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(node.kind))); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 167 /* PropertyDeclaration */ || node.kind === 206 /* PropertyAccessExpression */ || node.kind === 166 /* PropertySignature */ || - (node.kind === 164 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 166 /* SyntaxKind.PropertySignature */ || + (node.kind === 164 /* SyntaxKind.Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */ || node.kind === 164 /* Parameter */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 164 /* SyntaxKind.Parameter */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -108873,7 +109317,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.isStatic(node)) { @@ -108890,14 +109334,14 @@ var ts; else { if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1; @@ -108912,36 +109356,36 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; @@ -108953,9 +109397,9 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -108978,40 +109422,40 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; @@ -109022,61 +109466,61 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 256 /* FunctionDeclaration */: - case 179 /* FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind)); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind))); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 179 /* FunctionType */: - case 256 /* FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -109093,7 +109537,7 @@ var ts; // Heritage clause is written by user so it can always be named if (ts.isClassDeclaration(node.parent.parent)) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0; @@ -109142,7 +109586,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 164 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 164 /* SyntaxKind.Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -109161,13 +109605,13 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* NodeBuilderFlags.MultilineObjectLiterals */ | + 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ | + 4096 /* NodeBuilderFlags.UseTypeOfFunction */ | + 8 /* NodeBuilderFlags.UseStructuralFallback */ | + 524288 /* NodeBuilderFlags.AllowEmptyTuple */ | + 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ | + 1 /* NodeBuilderFlags.NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -109227,7 +109671,7 @@ var ts; } function trackReferencedAmbientModule(node, symbol) { // If it is visible via `// `, then we should just use that - var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* SymbolFlags.All */); if (ts.length(directives)) { return recordTypeReferenceDirectivesIfNecessary(directives); } @@ -109236,7 +109680,7 @@ var ts; refs.set(ts.getOriginalNodeId(container), container); } function handleSymbolAccessibilityError(symbolAccessibilityResult) { - if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccessibilityResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { if (!lateMarkedStatements) { @@ -109272,7 +109716,7 @@ var ts; } } function trackSymbol(symbol, enclosingDeclaration, meaning) { - if (symbol.flags & 262144 /* TypeParameter */) + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) return false; var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); @@ -109348,10 +109792,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 305 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 305 /* SyntaxKind.SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -109374,14 +109818,14 @@ var ts; resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([factory.createModifier(135 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -109518,11 +109962,11 @@ var ts; return ret; } function filterBindingPatternInitializersAndRenamings(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return name; } else { - if (name.kind === 202 /* ArrayBindingPattern */) { + if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -109530,7 +109974,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 227 /* OmittedExpression */) { + if (elem.kind === 227 /* SyntaxKind.OmittedExpression */) { return elem; } if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) { @@ -109547,7 +109991,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } - var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* SyntaxKind.QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -109564,7 +110008,7 @@ var ts; return undefined; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { // Private nodes emit no types (except private parameter properties, whose parameter types are actually visible) return; } @@ -109572,19 +110016,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 164 /* Parameter */ && + var shouldUseResolverType = node.kind === 164 /* SyntaxKind.Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return factory.createKeywordTypeNode(130 /* AnyKeyword */); + return factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -109592,12 +110036,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 164 /* Parameter */ - || node.kind === 167 /* PropertyDeclaration */ - || node.kind === 166 /* PropertySignature */) { + if (node.kind === 164 /* SyntaxKind.Parameter */ + || node.kind === 167 /* SyntaxKind.PropertyDeclaration */ + || node.kind === 166 /* SyntaxKind.PropertySignature */) { if (ts.isPropertySignature(node) || !node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -109608,28 +110052,28 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !getBindingNameVisible(node); - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return false; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; } return false; @@ -109656,7 +110100,7 @@ var ts; } } function updateParamsList(node, params, modifierMask) { - if (ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); @@ -109692,7 +110136,7 @@ var ts; return factory.createNodeArray(newParams || ts.emptyArray); } function ensureTypeParams(node, params) { - return ts.hasEffectiveModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); + return ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } function isEnclosingDeclaration(node) { return ts.isSourceFile(node) @@ -109718,7 +110162,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* ModuleDeclaration */ && parent.kind !== 200 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && parent.kind !== 200 /* SyntaxKind.ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -109738,7 +110182,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, decl.modifiers, decl.isTypeOnly, decl.name, factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); @@ -109763,7 +110207,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } - if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; @@ -109808,7 +110252,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.Debug.formatSyntaxKind(i.kind))); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -109866,10 +110310,10 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* TypeLiteral */ || input.kind === 195 /* MappedType */) && input.parent.kind !== 259 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* SyntaxKind.TypeLiteral */ || input.kind === 195 /* SyntaxKind.MappedType */) && input.parent.kind !== 259 /* SyntaxKind.TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { - if (ts.hasEffectiveModifier(input, 8 /* Private */)) { + if (ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload return cleanup(factory.createPropertyDeclaration(ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); @@ -109887,28 +110331,28 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 228 /* ExpressionWithTypeArguments */: { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( - /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* None */), + /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* ModifierFlags.None */), /*body*/ undefined); return cleanup(ctor); } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -109917,44 +110361,44 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 172 /* GetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(factory.updateGetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), + return cleanup(factory.updateGetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 173 /* SetAccessor */: { + case 173 /* SyntaxKind.SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } - return cleanup(factory.updateSetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), + return cleanup(factory.updateSetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), /*body*/ undefined)); } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 176 /* IndexSignature */: { - return cleanup(factory.updateIndexSignature(input, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */))); + case 176 /* SyntaxKind.IndexSignature */: { + return cleanup(factory.updateIndexSignature(input, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */))); } - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -109962,13 +110406,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 163 /* TypeParameter */: { + case 163 /* SyntaxKind.TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 189 /* ConditionalType */: { + case 189 /* SyntaxKind.ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -109980,22 +110424,22 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 179 /* FunctionType */: { + case 179 /* SyntaxKind.FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 180 /* ConstructorType */: { + case 180 /* SyntaxKind.ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 200 /* ImportType */: { + case 200 /* SyntaxKind.ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind)); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(input.kind))); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { - ts.setEmitFlags(input, 1 /* SingleLine */); + ts.setEmitFlags(input, 1 /* EmitFlags.SingleLine */); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { @@ -110018,7 +110462,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 169 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -110028,7 +110472,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 272 /* ExportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -110037,17 +110481,17 @@ var ts; // Rewrite external module names if necessary return factory.updateExportDeclaration(input, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 79 /* Identifier */) { + if (input.expression.kind === 79 /* SyntaxKind.Identifier */) { return input; } else { - var newId = factory.createUniqueName("_default", 16 /* Optimistic */); + var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input @@ -110055,7 +110499,7 @@ var ts; errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); preserveJsDoc(statement, input); ts.removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.modifiers, newId)]; @@ -110068,12 +110512,12 @@ var ts; return input; } function stripExportModifiers(statement) { - if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* Default */) || !ts.canHaveModifiers(statement)) { + if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) { // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (257023 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (257023 /* ModifierFlags.All */ ^ 1 /* ModifierFlags.Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { @@ -110084,10 +110528,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -110108,12 +110552,12 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 258 /* InterfaceDeclaration */: { + case 258 /* SyntaxKind.InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), @@ -110121,7 +110565,7 @@ var ts; if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration - var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace_1, enclosingDeclaration); fakespace_1.locals = ts.createSymbolTable(props); fakespace_1.symbol = props[0].parent; @@ -110140,10 +110584,10 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* SyntaxKind.ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { - declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); + declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* ModifierFlags.None */); }); } else { declarations.push(factory.createExportDeclaration( @@ -110153,11 +110597,11 @@ var ts; return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); })))); } - var namespaceDecl = factory.createModuleDeclaration(ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */); - if (!ts.hasEffectiveModifier(clean, 512 /* Default */)) { + var namespaceDecl = factory.createModuleDeclaration(ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* NodeFlags.Namespace */); + if (!ts.hasEffectiveModifier(clean, 512 /* ModifierFlags.Default */)) { return [clean, namespaceDecl]; } - var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ExportDefault */) | 2 /* Ambient */); + var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ModifierFlags.ExportDefault */) | 2 /* ModifierFlags.Ambient */); var cleanDeclaration = factory.updateFunctionDeclaration(clean, modifiers, /*asteriskToken*/ undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, /*body*/ undefined); @@ -110175,17 +110619,17 @@ var ts; return clean; } } - case 261 /* ModuleDeclaration */: { + case 261 /* SyntaxKind.ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 262 /* ModuleBlock */) { + if (inner && inner.kind === 262 /* SyntaxKind.ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 16777216 /* Ambient */) { + if (input.flags & 16777216 /* NodeFlags.Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -110219,7 +110663,7 @@ var ts; return cleanup(factory.updateModuleDeclaration(input, mods, input.name, body)); } } - case 257 /* ClassDeclaration */: { + case 257 /* SyntaxKind.ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -110229,10 +110673,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ModifierFlags.ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 79 /* Identifier */) { + if (param.name.kind === 79 /* SyntaxKind.Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration(ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } else { @@ -110271,26 +110715,26 @@ var ts; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* SyntaxKind.NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16 /* Optimistic */); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 94 /* ExtendsKeyword */) { + if (clause.token === 94 /* SyntaxKind.ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* SyntaxKind.NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 } @@ -110299,10 +110743,10 @@ var ts; return cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 260 /* EnumDeclaration */: { + case 260 /* SyntaxKind.EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -110313,7 +110757,7 @@ var ts; } } // Anything left unhandled is an error, so this should be unreachable - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind)); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.Debug.formatSyntaxKind(input.kind))); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -110321,7 +110765,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 261 /* ModuleDeclaration */) { + if (input.kind === 261 /* SyntaxKind.ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -110344,7 +110788,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 227 /* OmittedExpression */) { + if (e.kind === 227 /* SyntaxKind.OmittedExpression */) { return; } if (e.name) { @@ -110392,12 +110836,12 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 257023 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files - var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 305 /* SourceFile */; + var mask = 257023 /* ModifierFlags.All */ ^ (4 /* ModifierFlags.Public */ | 256 /* ModifierFlags.Async */ | 16384 /* ModifierFlags.Override */); // No async and override modifiers in declaration files + var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* ModifierFlags.Ambient */ : 0 /* ModifierFlags.None */; + var parentIsFile = node.parent.kind === 305 /* SyntaxKind.SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { - mask ^= 2 /* Ambient */; - additions = 0 /* None */; + mask ^= 2 /* ModifierFlags.Ambient */; + additions = 0 /* ModifierFlags.None */; } return maskModifierFlags(node, mask, additions); } @@ -110417,13 +110861,13 @@ var ts; } function transformHeritageClauses(nodes) { return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* SyntaxKind.ExtendsKeyword */ && t.expression.kind === 104 /* SyntaxKind.NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return true; } return false; @@ -110433,22 +110877,22 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 257023 /* All */ ^ 4 /* Public */; } - if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } + if (modifierMask === void 0) { modifierMask = 257023 /* ModifierFlags.All */ ^ 4 /* ModifierFlags.Public */; } + if (modifierAdditions === void 0) { modifierAdditions = 0 /* ModifierFlags.None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; - if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { + if (flags & 512 /* ModifierFlags.Default */ && !(flags & 1 /* ModifierFlags.Export */)) { // A non-exported default is a nonsequitor - we usually try to remove all export modifiers // from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid - flags ^= 1 /* Export */; + flags ^= 1 /* ModifierFlags.Export */; } - if (flags & 512 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) + if (flags & 512 /* ModifierFlags.Default */ && flags & 2 /* ModifierFlags.Ambient */) { + flags ^= 2 /* ModifierFlags.Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) } return flags; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 172 /* GetAccessor */ + return accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -110457,52 +110901,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return !ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */); + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 237 /* VariableStatement */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 254 /* VariableDeclaration */: - case 163 /* TypeParameter */: - case 228 /* ExpressionWithTypeArguments */: - case 178 /* TypeReference */: - case 189 /* ConditionalType */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 200 /* ImportType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 189 /* SyntaxKind.ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 200 /* SyntaxKind.ImportType */: return true; } return false; @@ -110560,35 +111004,35 @@ var ts; if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); } - if (languageVersion < 99 /* ESNext */) { + if (languageVersion < 99 /* ScriptTarget.ESNext */) { transformers.push(ts.transformESNext); } - if (languageVersion < 8 /* ES2021 */) { + if (languageVersion < 8 /* ScriptTarget.ES2021 */) { transformers.push(ts.transformES2021); } - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { transformers.push(ts.transformES2020); } - if (languageVersion < 6 /* ES2019 */) { + if (languageVersion < 6 /* ScriptTarget.ES2019 */) { transformers.push(ts.transformES2019); } - if (languageVersion < 5 /* ES2018 */) { + if (languageVersion < 5 /* ScriptTarget.ES2018 */) { transformers.push(ts.transformES2018); } - if (languageVersion < 4 /* ES2017 */) { + if (languageVersion < 4 /* ScriptTarget.ES2017 */) { transformers.push(ts.transformES2017); } - if (languageVersion < 3 /* ES2016 */) { + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { transformers.push(ts.transformES2016); } - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { transformers.push(ts.transformES5); } ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory)); @@ -110642,11 +111086,11 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(355 /* Count */); + var enabledSyntaxKindFeatures = new Array(355 /* SyntaxKind.Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; - var lexicalEnvironmentFlags = 0 /* None */; + var lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var lexicalEnvironmentStatementsStack = []; @@ -110659,7 +111103,7 @@ var ts; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; - var state = 0 /* Uninitialized */; + var state = 0 /* TransformationState.Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer // initialization. @@ -110689,13 +111133,13 @@ var ts; isEmitNotificationEnabled: isEmitNotificationEnabled, get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onEmitNode = value; }, @@ -110719,17 +111163,17 @@ var ts; return node; }; // prevent modification of transformation hooks. - state = 1 /* Initialized */; + state = 1 /* TransformationState.Initialized */; // Transform each node. var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 305 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "transformNodes", node.kind === 305 /* SyntaxKind.SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. - state = 2 /* Completed */; + state = 2 /* TransformationState.Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { @@ -110747,15 +111191,15 @@ var ts; * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 1 /* SyntaxKindFeatureFlags.Substitution */; } /** * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 - && (ts.getEmitFlags(node) & 4 /* NoSubstitution */) === 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* SyntaxKindFeatureFlags.Substitution */) !== 0 + && (ts.getEmitFlags(node) & 4 /* EmitFlags.NoSubstitution */) === 0; } /** * Emits a node with possible substitution. @@ -110765,23 +111209,23 @@ var ts; * @param emitCallback The callback used to emit the node or its substitute. */ function substituteNode(hint, node) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot substitute a node after the result is disposed."); return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 2 /* SyntaxKindFeatureFlags.EmitNotifications */; } /** * Determines whether before/after emit notifications should be raised in the pretty * printer when it emits a node. */ function isEmitNotificationEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (ts.getEmitFlags(node) & 2 /* AdviseOnEmitNode */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 2 /* SyntaxKindFeatureFlags.EmitNotifications */) !== 0 + || (ts.getEmitFlags(node) & 2 /* EmitFlags.AdviseOnEmitNode */) !== 0; } /** * Emits a node with possible emit notification. @@ -110791,7 +111235,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { // TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed // (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739) @@ -110807,26 +111251,26 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* NoNestedSourceMaps */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* EmitFlags.NoNestedSourceMaps */); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; } else { lexicalEnvironmentVariableDeclarations.push(decl); } - if (lexicalEnvironmentFlags & 1 /* InParameters */) { - lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */; + if (lexicalEnvironmentFlags & 1 /* LexicalEnvironmentFlags.InParameters */) { + lexicalEnvironmentFlags |= 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */; } } /** * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(func, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(func, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -110838,9 +111282,9 @@ var ts; * Adds an initialization statement to the top of the lexical environment. */ function addInitializationStatement(node) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(node, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(node, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentStatements) { lexicalEnvironmentStatements = [node]; } @@ -110853,8 +111297,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -110868,19 +111312,19 @@ var ts; lexicalEnvironmentVariableDeclarations = undefined; lexicalEnvironmentFunctionDeclarations = undefined; lexicalEnvironmentStatements = undefined; - lexicalEnvironmentFlags = 0 /* None */; + lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -110889,8 +111333,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || @@ -110902,7 +111346,7 @@ var ts; if (lexicalEnvironmentVariableDeclarations) { var statement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); if (!statements) { statements = [statement]; } @@ -110945,8 +111389,8 @@ var ts; * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. */ function startBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot start a block scope after transformation has completed."); blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; blockScopeStackOffset++; blockScopedVariableDeclarations = undefined; @@ -110955,12 +111399,12 @@ var ts; * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. */ function endBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot end a block scope after transformation has completed."); var statements = ts.some(blockScopedVariableDeclarations) ? [ factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* NodeFlags.Let */)) ] : undefined; blockScopeStackOffset--; blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; @@ -110974,8 +111418,8 @@ var ts; (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); } function requestEmitHelper(helper) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); if (helper.dependencies) { for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) { @@ -110986,14 +111430,14 @@ var ts; emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } function dispose() { - if (state < 3 /* Disposed */) { + if (state < 3 /* TransformationState.Disposed */) { // Clean up emit nodes on parse tree for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; @@ -111008,7 +111452,7 @@ var ts; onEmitNode = undefined; emitHelpers = undefined; // Prevent further use of the transformation result. - state = 3 /* Disposed */; + state = 3 /* TransformationState.Disposed */; } } } @@ -111047,7 +111491,7 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ function isBuildInfoFile(file) { - return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + return ts.fileExtensionIs(file, ".tsbuildinfo" /* Extension.TsBuildInfo */); } ts.isBuildInfoFile = isBuildInfoFile; /*@internal*/ @@ -111113,7 +111557,7 @@ var ts; ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : configFileExtensionLess; } - return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + return buildInfoExtensionLess + ".tsbuildinfo" /* Extension.TsBuildInfo */; } ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ @@ -111121,7 +111565,7 @@ var ts; var outPath = ts.outFile(options); var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; @@ -111130,7 +111574,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 306 /* Bundle */) { + if (sourceFile.kind === 306 /* SyntaxKind.Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -111138,7 +111582,7 @@ var ts; var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it var isJsonEmittedToSameLocation = isJsonFile && - ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; @@ -111152,11 +111596,11 @@ var ts; } /* @internal */ function getOutputExtension(fileName, options) { - return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : - options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : - ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : - ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : - ".js" /* Js */; + return ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) ? ".json" /* Extension.Json */ : + options.jsx === 1 /* JsxEmit.Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Extension.Jsx */, ".tsx" /* Extension.Tsx */]) ? ".jsx" /* Extension.Jsx */ : + ts.fileExtensionIsOneOf(fileName, [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ".mjs" /* Extension.Mjs */ : + ts.fileExtensionIsOneOf(fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ".cjs" /* Extension.Cjs */ : + ".js" /* Extension.Js */; } ts.getOutputExtension = getOutputExtension; function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) { @@ -111172,9 +111616,9 @@ var ts; function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { if (configFile.options.emitDeclarationOnly) return undefined; - var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options)); - return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? + return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* Comparison.EqualTo */ ? outputFileName : undefined; } @@ -111203,16 +111647,16 @@ var ts; return; var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -111281,7 +111725,7 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { @@ -111291,7 +111735,7 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) return jsFilePath; - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) continue; if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); @@ -111300,7 +111744,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ @@ -111316,7 +111760,6 @@ var ts; var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit; var bundleBuildInfo; var emitSkipped = false; - var exportedModulesFromDeclarationEmit; // Emit each output file enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile); @@ -111326,7 +111769,6 @@ var ts; diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList, - exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; @@ -111338,13 +111780,13 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { @@ -111389,7 +111831,7 @@ var ts; return; } // Make sure not to write js file and source map file if any of them cannot be written - if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) { + if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) { emitSkipped = true; return; } @@ -111418,7 +111860,7 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); if (bundleBuildInfo) @@ -111454,7 +111896,7 @@ var ts; noEmitHelpers: true, module: compilerOptions.module, target: compilerOptions.target, - sourceMap: compilerOptions.sourceMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, @@ -111474,17 +111916,13 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { - sourceMap: !forceDtsEmit && compilerOptions.declarationMap, + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, { + sourceMap: printerOptions.sourceMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) { - var sourceFile = declarationTransform.transformed[0]; - exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; - } } declarationTransform.dispose(); if (bundleBuildInfo) @@ -111492,7 +111930,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -111503,9 +111941,10 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) { + var sourceFileOrBundle = transform.transformed[0]; + var bundle = sourceFileOrBundle.kind === 306 /* SyntaxKind.Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -111530,14 +111969,14 @@ var ts; if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); sourceMapUrlPos = writer.getTextPos(); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); // Tools can sometimes see this line as a source mapping url comment } // Write the source map if (sourceMapFilePath) { var sourceMap = sourceMapGenerator.toString(); ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles); if (printer.bundleFileInfo) - printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); } } else { @@ -111545,17 +111984,17 @@ var ts; } // Write the output file var text = writer.getText(); - ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); + ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics }); // We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo // This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode if (printer.bundleFileInfo) - printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash)); // Reset state writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 305 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Extension.Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -111586,7 +112025,7 @@ var ts; // Encode the sourceMap into the sourceMap url var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -111679,8 +112118,8 @@ var ts; ts.setParent(literal, statement); return statement; }); - var eofToken = ts.factory.createToken(1 /* EndOfFileToken */); - var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* None */); + var eofToken = ts.factory.createToken(1 /* SyntaxKind.EndOfFileToken */); + var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* NodeFlags.None */); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : ""; ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0); @@ -111714,25 +112153,25 @@ var ts; if (!jsFileText) return jsFilePath; // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it - if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) + if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) return jsFilePath; var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); // error if no source map or for now if inline sourcemap if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) return sourceMapFilePath || "inline sourcemap decoding"; - if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) + if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) return sourceMapFilePath; // read declaration text var declarationText = declarationFilePath && host.readFile(declarationFilePath); if (declarationFilePath && !declarationText) return declarationFilePath; - if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) + if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) return declarationFilePath; var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); // error if no source map or for now if inline sourcemap if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) return declarationMapPath || "inline sourcemap decoding"; - if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) + if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) return declarationMapPath; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, @@ -111772,8 +112211,7 @@ var ts; newBuildInfo.program = buildInfo.program; if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) { // Update the output signature - newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash); - newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime(); + newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData); } // Update sourceFileInfo var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; @@ -111795,7 +112233,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -111848,7 +112286,7 @@ var ts; var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined; var recordInternalSection = printerOptions.recordInternalSection; var sourceFileTextPos = 0; - var sourceFileTextKind = "text" /* Text */; + var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -111888,20 +112326,20 @@ var ts; }; function printNode(hint, node, sourceFile) { switch (hint) { - case 0 /* SourceFile */: + case 0 /* EmitHint.SourceFile */: ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); break; - case 2 /* IdentifierName */: + case 2 /* EmitHint.IdentifierName */: ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); break; - case 1 /* Expression */: + case 1 /* EmitHint.Expression */: ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); break; } switch (node.kind) { - case 305 /* SourceFile */: return printFile(node); - case 306 /* Bundle */: return printBundle(node); - case 307 /* UnparsedSource */: return printUnparsedSource(node); + case 305 /* SyntaxKind.SourceFile */: return printFile(node); + case 306 /* SyntaxKind.Bundle */: return printBundle(node); + case 307 /* SyntaxKind.UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -111957,11 +112395,11 @@ var ts; currentSourceFile && (ts.isDeclaration(node) || ts.isVariableStatement(node)) && ts.isInternalDeclaration(node, currentSourceFile) && - sourceFileTextKind !== "internal" /* Internal */) { + sourceFileTextKind !== "internal" /* BundleFileSectionKind.Internal */) { var prevSourceFileTextKind = sourceFileTextKind; recordBundleFileTextLikeSection(writer.getTextPos()); sourceFileTextPos = getTextPosWithWriteLine(); - sourceFileTextKind = "internal" /* Internal */; + sourceFileTextKind = "internal" /* BundleFileSectionKind.Internal */; return prevSourceFileTextKind; } return undefined; @@ -111996,7 +112434,7 @@ var ts; var savedSections = bundleFileInfo && bundleFileInfo.sections; if (savedSections) bundleFileInfo.sections = []; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, prepend, /*sourceFile*/ undefined); if (bundleFileInfo) { var newSections = bundleFileInfo.sections; bundleFileInfo.sections = savedSections; @@ -112007,7 +112445,7 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), - kind: "prepend" /* Prepend */, + kind: "prepend" /* BundleFileSectionKind.Prepend */, data: relativeToBuildInfo(prepend.fileName), texts: newSections }); @@ -112017,7 +112455,7 @@ var ts; sourceFileTextPos = getTextPosWithWriteLine(); for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { var sourceFile = _e[_d]; - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); } if (bundleFileInfo && bundle.sourceFiles.length) { var end = writer.getTextPos(); @@ -112044,7 +112482,7 @@ var ts; function writeUnparsedSource(unparsed, output) { var previousWriter = writer; setWriter(output, /*_sourceMapGenerator*/ undefined); - print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } @@ -112054,7 +112492,7 @@ var ts; setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; } @@ -112093,7 +112531,7 @@ var ts; autoGeneratedIdToGeneratedName = []; generatedNames = new ts.Set(); tempFlagsStack = []; - tempFlags = 0 /* Auto */; + tempFlags = 0 /* TempFlags.Auto */; reservedNamesStack = []; currentSourceFile = undefined; currentLineMap = undefined; @@ -112107,24 +112545,24 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); + pipelineEmit(4 /* EmitHint.Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) return; - pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); + pipelineEmit(2 /* EmitHint.IdentifierName */, node, /*parenthesizerRule*/ undefined); } function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - pipelineEmit(1 /* Expression */, node, parenthesizerRule); + pipelineEmit(1 /* EmitHint.Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* EmitHint.JsxAttributeValue */ : 4 /* EmitHint.Unspecified */, node); } function beforeEmitNode(node) { - if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* EmitFlags.IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } } @@ -112133,7 +112571,7 @@ var ts; } function pipelineEmit(emitHint, node, parenthesizerRule) { currentParenthesizerRule = parenthesizerRule; - var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, emitHint, node); pipelinePhase(emitHint, node); currentParenthesizerRule = undefined; } @@ -112149,12 +112587,12 @@ var ts; } function getPipelinePhase(phase, emitHint, node) { switch (phase) { - case 0 /* Notification */: + case 0 /* PipelinePhase.Notification */: if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) { return pipelineEmitWithNotification; } // falls through - case 1 /* Substitution */: + case 1 /* PipelinePhase.Substitution */: if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { if (currentParenthesizerRule) { lastSubstitution = currentParenthesizerRule(lastSubstitution); @@ -112162,17 +112600,17 @@ var ts; return pipelineEmitWithSubstitution; } // falls through - case 2 /* Comments */: + case 2 /* PipelinePhase.Comments */: if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through - case 3 /* SourceMaps */: + case 3 /* PipelinePhase.SourceMaps */: if (shouldEmitSourceMaps(node)) { return pipelineEmitWithSourceMaps; } // falls through - case 4 /* Emit */: + case 4 /* PipelinePhase.Emit */: return pipelineEmitWithHint; default: return ts.Debug.assertNever(phase); @@ -112182,7 +112620,7 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); + var pipelinePhase = getNextPipelinePhase(0 /* PipelinePhase.Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { @@ -112208,346 +112646,346 @@ var ts; return emitSnippetNode(hint, node, snippet); } } - if (hint === 0 /* SourceFile */) + if (hint === 0 /* EmitHint.SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); - if (hint === 2 /* IdentifierName */) + if (hint === 2 /* EmitHint.IdentifierName */) return emitIdentifier(ts.cast(node, ts.isIdentifier)); - if (hint === 6 /* JsxAttributeValue */) + if (hint === 6 /* EmitHint.JsxAttributeValue */) return emitLiteral(ts.cast(node, ts.isStringLiteral), /*jsxAttributeEscape*/ true); - if (hint === 3 /* MappedTypeParameter */) + if (hint === 3 /* EmitHint.MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); - if (hint === 5 /* EmbeddedStatement */) { + if (hint === 5 /* EmitHint.EmbeddedStatement */) { ts.Debug.assertNode(node, ts.isEmptyStatement); return emitEmptyStatement(/*isEmbeddedStatement*/ true); } - if (hint === 4 /* Unspecified */) { + if (hint === 4 /* EmitHint.Unspecified */) { switch (node.kind) { // Pseudo-literals - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return emitQualifiedName(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return emitTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return emitParameter(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return emitDecorator(node); // Type members - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return emitPropertySignature(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return emitPropertyDeclaration(node); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return emitMethodSignature(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return emitMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return emitClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return emitConstructor(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return emitAccessorDeclaration(node); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return emitCallSignature(node); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return emitConstructSignature(node); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return emitIndexSignature(node); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return emitTypePredicate(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return emitTypeReference(node); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return emitFunctionType(node); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return emitConstructorType(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return emitTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return emitTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return emitArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return emitTupleType(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return emitUnionType(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return emitIntersectionType(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return emitConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return emitInferType(node); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return emitParenthesizedType(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return emitThisType(); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return emitTypeOperator(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return emitIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return emitMappedType(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return emitLiteralType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return emitNamedTupleMember(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return emitTemplateType(node); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return emitImportTypeNode(node); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return emitBindingElement(node); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return emitTemplateSpan(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return emitBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return emitVariableStatement(node); - case 236 /* EmptyStatement */: + case 236 /* SyntaxKind.EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return emitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return emitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return emitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return emitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return emitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return emitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return emitForOfStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return emitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return emitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return emitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return emitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return emitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return emitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return emitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return emitTryStatement(node); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return emitVariableDeclaration(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return emitVariableDeclarationList(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return emitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return emitClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return emitEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return emitModuleDeclaration(node); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return emitModuleBlock(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return emitCaseBlock(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return emitImportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return emitImportClause(node); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return emitNamespaceImport(node); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return emitNamespaceExport(node); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: return emitNamedImports(node); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return emitImportSpecifier(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return emitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return emitExportDeclaration(node); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: return emitNamedExports(node); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return emitExportSpecifier(node); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return emitAssertClause(node); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return emitAssertEntry(node); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return; // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return emitJsxText(node); - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 281 /* JsxClosingElement */: - case 284 /* JsxClosingFragment */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 284 /* SyntaxKind.JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return emitJsxAttribute(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return emitJsxAttributes(node); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return emitJsxExpression(node); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return emitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return emitDefaultClause(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return emitHeritageClause(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return emitCatchClause(node); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return emitPropertyAssignment(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return emitEnumMember(node); // Unparsed - case 300 /* UnparsedPrologue */: + case 300 /* SyntaxKind.UnparsedPrologue */: return writeUnparsedNode(node); - case 307 /* UnparsedSource */: - case 301 /* UnparsedPrepend */: + case 307 /* SyntaxKind.UnparsedSource */: + case 301 /* SyntaxKind.UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return emitUnparsedTextLike(node); - case 304 /* UnparsedSyntheticReference */: + case 304 /* SyntaxKind.UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return emitSourceFile(node); - case 306 /* Bundle */: + case 306 /* SyntaxKind.Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 308 /* InputFiles */: + case 308 /* SyntaxKind.InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return emitJSDocNameReference(node); - case 312 /* JSDocAllType */: + case 312 /* SyntaxKind.JSDocAllType */: return writePunctuation("*"); - case 313 /* JSDocUnknownType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return writePunctuation("?"); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return emitJSDocNullableType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return emitJSDocOptionalType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return emitJSDocFunctionType(node); - case 186 /* RestType */: - case 318 /* JSDocVariadicType */: + case 186 /* SyntaxKind.RestType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 319 /* JSDocNamepathType */: + case 319 /* SyntaxKind.JSDocNamepathType */: return; - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return emitJSDoc(node); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return emitJSDocSignature(node); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 337 /* JSDocOverrideTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 337 /* SyntaxKind.JSDocOverrideTag */: return emitJSDocSimpleTag(node); - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 330 /* JSDocAuthorTag */: - case 331 /* JSDocDeprecatedTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: return; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 339 /* JSDocEnumTag */: - case 341 /* JSDocReturnTag */: - case 342 /* JSDocThisTag */: - case 343 /* JSDocTypeTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 349 /* NotEmittedStatement */: - case 353 /* EndOfDeclarationMarker */: - case 352 /* MergeDeclarationMarker */: + case 349 /* SyntaxKind.NotEmittedStatement */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { - hint = 1 /* Expression */; + hint = 1 /* EmitHint.Expression */; if (substituteNode !== ts.noEmitSubstitution) { var substitute = substituteNode(hint, node) || node; if (substitute !== node) { @@ -112559,101 +112997,101 @@ var ts; } } } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { switch (node.kind) { // Literals - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return emitNumericOrBigIntLiteral(node); - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Expressions - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return emitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return emitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return emitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return emitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return emitArrowFunction(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return emitDeleteExpression(node); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return emitTypeOfExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return emitVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return emitAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return emitBinaryExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return emitConditionalExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return emitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return emitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return emitSpreadElement(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return emitClassExpression(node); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return emitAsExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return emitNonNullExpression(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return emitMetaProperty(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return emitJsxElement(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 349 /* NotEmittedStatement */: + case 349 /* SyntaxKind.NotEmittedStatement */: return; - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return emitCommaList(node); - case 352 /* MergeDeclarationMarker */: - case 353 /* EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return; - case 354 /* SyntheticReferenceExpression */: + case 354 /* SyntaxKind.SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -112661,7 +113099,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -112671,7 +113109,7 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); + var pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, hint, node); ts.Debug.assertIsDefined(lastSubstitution); node = lastSubstitution; lastSubstitution = undefined; @@ -112701,7 +113139,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 306 /* Bundle */ ? node : undefined; + var bundle = node.kind === 306 /* SyntaxKind.Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -112743,7 +113181,7 @@ var ts; writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* BundleFileSectionKind.EmitHelpers */, data: helper.name }); helpersEmitted = true; } } @@ -112771,7 +113209,7 @@ var ts; function emitLiteral(node, jsxAttributeEscape) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* SyntaxKind.StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -112801,9 +113239,9 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* SyntaxKind.UnparsedText */ ? + "text" /* BundleFileSectionKind.Text */ : + "internal" /* BundleFileSectionKind.Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -112822,25 +113260,25 @@ var ts; // function emitSnippetNode(hint, node, snippet) { switch (snippet.kind) { - case 1 /* Placeholder */: + case 1 /* SnippetKind.Placeholder */: emitPlaceholder(hint, node, snippet); break; - case 0 /* TabStop */: + case 0 /* SnippetKind.TabStop */: emitTabStop(hint, node, snippet); break; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); // `${2:` + nonEscapingWrite("${".concat(snippet.order, ":")); // `${2:` pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` nonEscapingWrite("}"); // `}` // `${2:...}` } function emitTabStop(hint, node, snippet) { // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text. - ts.Debug.assert(node.kind === 236 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); - ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + ts.Debug.assert(node.kind === 236 /* SyntaxKind.EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); + ts.Debug.assert(hint !== 5 /* EmitHint.EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); + nonEscapingWrite("$".concat(snippet.order)); } // // Identifiers @@ -112848,7 +113286,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* ListFormat.TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -112863,7 +113301,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112899,7 +113337,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 317 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -112960,7 +113398,7 @@ var ts; } function emitAccessorDeclaration(node) { emitDecoratorsAndModifiers(node, node.modifiers); - writeKeyword(node.kind === 172 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 172 /* SyntaxKind.GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -113065,8 +113503,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineTypeLiteralMembers */ : 32897 /* ListFormat.MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* ListFormat.NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -113079,16 +113517,16 @@ var ts; emit(node.type); } function emitTupleType(node) { - emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */; - emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); - emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.pos, writePunctuation, node); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 528 /* ListFormat.SingleLineTupleTypeElements */ : 657 /* ListFormat.MultiLineTupleTypeElements */; + emitList(node, node.elements, flags | 524288 /* ListFormat.NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.elements.end, writePunctuation, node); } function emitNamedTupleMember(node) { emit(node.dotDotDotToken); emit(node.name); emit(node.questionToken); - emitTokenWithComment(58 /* ColonToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.name.end, writePunctuation, node); writeSpace(); emit(node.type); } @@ -113097,10 +113535,10 @@ var ts; writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); + emitList(node, node.types, 516 /* ListFormat.UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); + emitList(node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); } function emitConditionalType(node) { emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType); @@ -113133,7 +113571,7 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ? + var parenthesizerRule = node.operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizer.parenthesizeOperandOfReadonlyTypeOperator : parenthesizer.parenthesizeOperandOfTypeOperator; emit(node.type, parenthesizerRule); @@ -113147,7 +113585,7 @@ var ts; function emitMappedType(node) { var emitFlags = ts.getEmitFlags(node); writePunctuation("{"); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { @@ -113156,13 +113594,13 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 145 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* EmitHint.MappedTypeParameter */, node.typeParameter); if (node.nameType) { writeSpace(); writeKeyword("as"); @@ -113172,7 +113610,7 @@ var ts; writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 57 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { writePunctuation("?"); } } @@ -113180,14 +113618,14 @@ var ts; writeSpace(); emit(node.type); writeTrailingSemicolon(); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { writeLine(); decreaseIndent(); } - emitList(node, node.members, 2 /* PreserveLines */); + emitList(node, node.members, 2 /* ListFormat.PreserveLines */); writePunctuation("}"); } function emitLiteralType(node) { @@ -113195,7 +113633,7 @@ var ts; } function emitTemplateType(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitImportTypeNode(node) { if (node.isTypeOf) { @@ -113214,7 +113652,7 @@ var ts; writePunctuation(":"); writeSpace(); var elements = node.assertions.assertClause.elements; - emitList(node.assertions.assertClause, elements, 526226 /* ImportClauseEntries */); + emitList(node.assertions.assertClause, elements, 526226 /* ListFormat.ImportClauseEntries */); writeSpace(); writePunctuation("}"); } @@ -113230,12 +113668,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ListFormat.ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ListFormat.ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -113253,29 +113691,29 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + emitExpressionList(node, elements, 8914 /* ListFormat.ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ScriptTarget.ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* ListFormat.AllowTrailingComma */ : 0 /* ListFormat.None */; + emitList(node, node.properties, 526226 /* ListFormat.ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); } } function emitPropertyAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); - var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos); + var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* SyntaxKind.DotToken */), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + var shouldEmitDotDot = token.kind !== 28 /* SyntaxKind.QuestionDotToken */ && mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); @@ -113301,7 +113739,7 @@ var ts; var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true, /*jsxAttributeEscape*/ false); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* SyntaxKind.DotToken */)); } else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer @@ -113314,12 +113752,12 @@ var ts; function emitElementAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); - emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -113332,17 +113770,17 @@ var ts; } emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* SyntaxKind.NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 18960 /* ListFormat.NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -113364,12 +113802,12 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); - emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -113387,22 +113825,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* SyntaxKind.DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* SyntaxKind.TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* SyntaxKind.VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(132 /* SyntaxKind.AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -113427,9 +113865,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 219 /* PrefixUnaryExpression */ - && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) - || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); + return operand.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ + && ((node.operator === 39 /* SyntaxKind.PlusToken */ && (operand.operator === 39 /* SyntaxKind.PlusToken */ || operand.operator === 45 /* SyntaxKind.PlusPlusToken */)) + || (node.operator === 40 /* SyntaxKind.MinusToken */ && (operand.operator === 40 /* SyntaxKind.MinusToken */ || operand.operator === 46 /* SyntaxKind.MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); @@ -113470,12 +113908,12 @@ var ts; return maybeEmitExpression(next, parent, "left"); } function onOperator(operatorToken, _state, node) { - var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */; + var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken); var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(operatorToken.pos); - writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); } @@ -113506,11 +113944,11 @@ var ts; var parenthesizerRule = side === "left" ? parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, 1 /* EmitHint.Expression */, next); if (pipelinePhase === pipelineEmitWithSubstitution) { ts.Debug.assertIsDefined(lastSubstitution); next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); - pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, 1 /* EmitHint.Expression */, next); lastSubstitution = undefined; } if (pipelinePhase === pipelineEmitWithComments || @@ -113521,7 +113959,7 @@ var ts; } } currentParenthesizerRule = parenthesizerRule; - pipelinePhase(1 /* Expression */, next); + pipelinePhase(1 /* EmitHint.Expression */, next); } } function emitConditionalExpression(node) { @@ -113543,15 +113981,15 @@ var ts; } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* SyntaxKind.YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma); } function emitSpreadElement(node) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { @@ -113594,10 +114032,10 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineBlockStatements */ : 129 /* ListFormat.MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* ListFormat.MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -113623,16 +114061,16 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SyntaxKind.IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 239 /* IfStatement */) { + emitTokenWithComment(91 /* SyntaxKind.ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 239 /* SyntaxKind.IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -113642,14 +114080,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* SyntaxKind.WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* SyntaxKind.DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -113665,45 +114103,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* SyntaxKind.InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(160 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(160 /* SyntaxKind.OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { emit(node); } else { @@ -113712,12 +114150,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* SyntaxKind.ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* SyntaxKind.BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -113740,13 +114178,13 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 288 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function commentWillEmitNewLine(node) { - return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; + return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; } function willEmitLeadingNewLine(node) { if (!currentSourceFile) @@ -113786,40 +114224,40 @@ var ts; return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node)); } function emitReturnStatement(node) { - emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* SyntaxKind.ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* SyntaxKind.WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SyntaxKind.SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* SyntaxKind.ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* SyntaxKind.TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -113828,13 +114266,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* SyntaxKind.FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* SyntaxKind.DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -113850,7 +114288,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 528 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* ListFormat.VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -113867,7 +114305,7 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } @@ -113904,7 +114342,7 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (ts.getEmitFlags(body) & 1 /* SingleLine */) { + if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) { return true; } if (body.multiLine) { @@ -113913,14 +114351,14 @@ var ts; if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (getLeadingLineTerminatorCount(body, ts.firstOrUndefined(body.statements), 2 /* PreserveLines */) - || getClosingLineTerminatorCount(body, ts.lastOrUndefined(body.statements), 2 /* PreserveLines */, body.statements)) { + if (getLeadingLineTerminatorCount(body, ts.firstOrUndefined(body.statements), 2 /* ListFormat.PreserveLines */) + || getClosingLineTerminatorCount(body, ts.lastOrUndefined(body.statements), 2 /* ListFormat.PreserveLines */, body.statements)) { return false; } var previousStatement; for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { var statement = _b[_a]; - if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) { + if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) { return false; } previousStatement = statement; @@ -113937,7 +114375,7 @@ var ts; : emitBlockFunctionBodyWorker; emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); - writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* SyntaxKind.CloseBraceToken */, body.statements.end, writePunctuation, body); onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { @@ -113950,11 +114388,11 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* ListFormat.SingleLineFunctionBodyStatements */); increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); + emitList(body, body.statements, 1 /* ListFormat.MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -113968,15 +114406,15 @@ var ts; writeSpace(); emitIdentifierName(node.name); } - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); + emitList(node, node.heritageClauses, 0 /* ListFormat.ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* ClassMembers */); + emitList(node, node.members, 129 /* ListFormat.ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -113988,10 +114426,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 512 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* ListFormat.HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* InterfaceMembers */); + emitList(node, node.members, 129 /* ListFormat.InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -114013,13 +114451,13 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 145 /* EnumMembers */); + emitList(node, node.members, 145 /* ListFormat.EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 1024 /* GlobalAugmentation */) { - writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); + if (~node.flags & 1024 /* NodeFlags.GlobalAugmentation */) { + writeKeyword(node.flags & 16 /* NodeFlags.Namespace */ ? "namespace" : "module"); writeSpace(); } emit(node.name); @@ -114041,27 +114479,27 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 129 /* CaseBlockClauses */); - emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* ListFormat.CaseBlockClauses */); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -114070,12 +114508,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(156 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -114086,20 +114524,20 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -114110,37 +114548,37 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression, node.isExportEquals ? - parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* SyntaxKind.EqualsToken */) : parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(152 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(156 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -114150,10 +114588,10 @@ var ts; writeTrailingSemicolon(); } function emitAssertClause(node) { - emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(129 /* SyntaxKind.AssertKeyword */, node.pos, writeKeyword, node); writeSpace(); var elements = node.elements; - emitList(node, elements, 526226 /* ImportClauseEntries */); + emitList(node, elements, 526226 /* ListFormat.ImportClauseEntries */); } function emitAssertEntry(node) { emit(node.name); @@ -114161,26 +114599,26 @@ var ts; writeSpace(); var value = node.value; /** @see {emitPropertyAssignment} */ - if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(value) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(value); emitTrailingCommentsOfPosition(commentRange.pos); } emit(value); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(142 /* SyntaxKind.NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); } function emitNamespaceExport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -114192,7 +114630,7 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { @@ -114203,7 +114641,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -114222,7 +114660,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -114235,7 +114673,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -114264,7 +114702,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 262656 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* ListFormat.JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -114295,17 +114733,17 @@ var ts; if (isMultiline) { writer.increaseIndent(); } - var end = emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + var end = emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); emit(node.dotDotDotToken); emitExpression(node.expression); - emitTokenWithComment(19 /* CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); if (isMultiline) { writer.decreaseIndent(); } } } function emitJsxTagName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -114316,13 +114754,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* SyntaxKind.CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -114333,14 +114771,14 @@ var ts; ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 163969 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* ListFormat.CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 128 /* Indented */); + format &= ~(1 /* ListFormat.MultiLine */ | 128 /* ListFormat.Indented */); } else { - emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -114348,15 +114786,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 528 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* ListFormat.HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* SyntaxKind.CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -114376,7 +114814,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(initializer) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -114393,7 +114831,7 @@ var ts; } function emitSpreadAssignment(node) { if (node.expression) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } @@ -114424,12 +114862,12 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 343 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 343 /* SyntaxKind.JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } else { - emitList(node, node.tags, 33 /* JSDocComment */); + emitList(node, node.tags, 33 /* ListFormat.JSDocComment */); } } writeSpace(); @@ -114463,13 +114901,13 @@ var ts; emitJSDocTagName(tag.tagName); emitJSDocTypeExpression(tag.constraint); writeSpace(); - emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitList(tag, tag.typeParameters, 528 /* ListFormat.CommaListElements */); emitJSDocComment(tag.comment); } function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 309 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -114488,7 +114926,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 322 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 322 /* SyntaxKind.JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -114506,14 +114944,14 @@ var ts; emitJSDocComment(tag.comment); } function emitJSDocTypeLiteral(lit) { - emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* ListFormat.JSDocComment */); } function emitJSDocSignature(sig) { if (sig.typeParameters) { - emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* ListFormat.JSDocComment */); } if (sig.parameters) { - emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* ListFormat.JSDocComment */); } if (sig.type) { writeLine(); @@ -114594,21 +115032,21 @@ var ts; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -114616,28 +115054,28 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* BundleFileSectionKind.Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_23 = types; _d < types_23.length; _d++) { var directive = types_23[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* BundleFileSectionKind.Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */ : "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* BundleFileSectionKind.Lib */, data: directive.fileName }); writeLine(); } } @@ -114648,22 +115086,22 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* ListFormat.MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes function emitPartiallyEmittedExpression(node) { var emitFlags = ts.getEmitFlags(node); - if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) { + if (!(emitFlags & 512 /* EmitFlags.NoLeadingComments */) && node.pos !== node.expression.pos) { emitTrailingCommentsOfPosition(node.expression.pos); } emitExpression(node.expression); - if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) { + if (!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */) && node.end !== node.expression.end) { emitLeadingCommentsOfPosition(node.expression.end); } } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); + emitExpressionList(node, node.elements, 528 /* ListFormat.CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -114684,7 +115122,7 @@ var ts; var pos = writer.getTextPos(); emit(statement); if (recordBundleFileSection && bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.add(statement.expression.text); } @@ -114705,7 +115143,7 @@ var ts; var pos = writer.getTextPos(); emit(prologue); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: prologue.data }); if (seenPrologueDirectives) { seenPrologueDirectives.add(prologue.data); } @@ -114829,7 +115267,7 @@ var ts; textRange.pos = modifiers.pos; if (pos === modifiers.length - 1) textRange.end = modifiers.end; - emitNodeListItems(emit, node, modifiers, lastMode === "modifiers" ? 2359808 /* Modifiers */ : 2146305 /* Decorators */, + emitNodeListItems(emit, node, modifiers, lastMode === "modifiers" ? 2359808 /* ListFormat.Modifiers */ : 2146305 /* ListFormat.Decorators */, /*parenthesizerRule*/ undefined, start, pos - start, /*hasTrailingComma*/ false, textRange); start = pos; @@ -114840,7 +115278,7 @@ var ts; } } function emitModifiers(node, modifiers) { - emitList(node, modifiers, 2359808 /* Modifiers */); + emitList(node, modifiers, 2359808 /* ListFormat.Modifiers */); } function emitTypeAnnotation(node) { if (node) { @@ -114852,7 +115290,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node, parenthesizerRule); } @@ -114882,7 +115320,7 @@ var ts; } } function emitEmbeddedStatement(parent, node) { - if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* EmitFlags.SingleLine */) { writeSpace(); emit(node); } @@ -114890,7 +115328,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - pipelineEmit(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmitHint.EmbeddedStatement */, node); } else { emit(node); @@ -114899,19 +115337,19 @@ var ts; } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 2146305 /* Decorators */); + emitList(parentNode, decorators, 2146305 /* ListFormat.Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector); + emitList(parentNode, typeArguments, 53776 /* ListFormat.TypeArguments */, typeArgumentParenthesizerRuleSelector); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures return emitTypeArguments(parentNode, parentNode.typeArguments); } - emitList(parentNode, typeParameters, 53776 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* ListFormat.TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 2576 /* Parameters */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -114930,32 +115368,32 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */ & ~2048 /* ListFormat.Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* ListFormat.IndexSignatureParameters */); } function writeDelimiter(format) { - switch (format & 60 /* DelimitersMask */) { - case 0 /* None */: + switch (format & 60 /* ListFormat.DelimitersMask */) { + case 0 /* ListFormat.None */: break; - case 16 /* CommaDelimited */: + case 16 /* ListFormat.CommaDelimited */: writePunctuation(","); break; - case 4 /* BarDelimited */: + case 4 /* ListFormat.BarDelimited */: writeSpace(); writePunctuation("|"); break; - case 32 /* AsteriskDelimited */: + case 32 /* ListFormat.AsteriskDelimited */: writeSpace(); writePunctuation("*"); writeSpace(); break; - case 8 /* AmpersandDelimited */: + case 8 /* ListFormat.AmpersandDelimited */: writeSpace(); writePunctuation("&"); break; @@ -114971,16 +115409,16 @@ var ts; if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; - if (isUndefined && format & 16384 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* ListFormat.OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 32768 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* ListFormat.OptionalIfEmpty */) { onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); return; } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists @@ -114989,10 +115427,10 @@ var ts; onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { + if (format & 1 /* ListFormat.MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } - else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */ && !(format & 524288 /* ListFormat.NoSpaceIfEmpty */)) { writeSpace(); } } @@ -115000,7 +115438,7 @@ var ts; emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, children.hasTrailingComma, children); } onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } @@ -115014,18 +115452,18 @@ var ts; */ function emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, hasTrailingComma, childrenTextRange) { // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* ListFormat.NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format); if (leadingLineTerminatorCount) { writeLine(leadingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (format & 256 /* SpaceBetweenBraces */) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { increaseIndent(); } var emitListItem = getEmitListItem(emit, parenthesizerRule); @@ -115036,7 +115474,7 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. - if (format & 32 /* AsteriskDelimited */) { + if (format & 32 /* ListFormat.AsteriskDelimited */) { // always write JSDoc in the format "\n *" writeLine(); writeDelimiter(format); @@ -115048,7 +115486,7 @@ var ts; // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + if (format & 60 /* ListFormat.DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -115058,14 +115496,14 @@ var ts; if (separatingLineTerminatorCount > 0) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* ListFormat.LinesMask */ | 128 /* ListFormat.Indented */)) === 0 /* ListFormat.SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(separatingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* ListFormat.SpaceBetweenSiblings */) { writeSpace(); } } @@ -115088,11 +115526,11 @@ var ts; } // Write a trailing comma, if requested. var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; - var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* NoTrailingComments */); - var emitTrailingComma = hasTrailingComma && (format & 64 /* AllowTrailingComma */) && (format & 16 /* CommaDelimited */); + var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */); + var emitTrailingComma = hasTrailingComma && (format & 64 /* ListFormat.AllowTrailingComma */) && (format & 16 /* ListFormat.CommaDelimited */); if (emitTrailingComma) { if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(27 /* CommaToken */, previousSibling.end, writePunctuation, previousSibling); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, previousSibling.end, writePunctuation, previousSibling); } else { writePunctuation(","); @@ -115104,11 +115542,11 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* ListFormat.DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(emitTrailingComma && (childrenTextRange === null || childrenTextRange === void 0 ? void 0 : childrenTextRange.end) ? childrenTextRange.end : previousSibling.end); } // Decrease the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { decreaseIndent(); } recordBundleFileInternalSectionEnd(previousSourceFileTextKind); @@ -115117,7 +115555,7 @@ var ts; if (closingLineTerminatorCount) { writeLine(closingLineTerminatorCount); } - else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) { + else if (format & (2097152 /* ListFormat.SpaceAfterList */ | 256 /* ListFormat.SpaceBetweenBraces */)) { writeSpace(); } } @@ -115199,7 +115637,7 @@ var ts; return pos < 0 ? pos : pos + tokenString.length; } function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) { - if (ts.getEmitFlags(parentNode) & 1 /* SingleLine */) { + if (ts.getEmitFlags(parentNode) & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else if (preserveSourceNewlines) { @@ -115249,8 +115687,8 @@ var ts; } } function getLeadingLineTerminatorCount(parentNode, firstChild, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } if (firstChild === undefined) { @@ -115274,7 +115712,7 @@ var ts; // leading newline to start the modifiers. return 0; } - if (firstChild.kind === 11 /* JsxText */) { + if (firstChild.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } @@ -115291,14 +115729,14 @@ var ts; return 1; } } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { if (previousNode === undefined || nextNode === undefined) { return 0; } - if (nextNode.kind === 11 /* JsxText */) { + if (nextNode.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } @@ -115316,7 +115754,7 @@ var ts; } // If the two nodes are not comparable, add a line terminator based on the format that can indicate // whether new lines are preferred or not. - return format & 65536 /* PreferNewLine */ ? 1 : 0; + return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -115325,11 +115763,11 @@ var ts; else if (ts.getStartsOnNewLine(nextNode)) { return 1; } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getClosingLineTerminatorCount(parentNode, lastChild, format, childrenTextRange) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } if (lastChild === undefined) { @@ -115346,7 +115784,7 @@ var ts; return 1; } } - if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) { + if (format & 1 /* ListFormat.MultiLine */ && !(format & 131072 /* ListFormat.NoTrailingNewLine */)) { return 1; } return 0; @@ -115375,14 +115813,14 @@ var ts; return lines; } function writeLineSeparatorsAndIndentBefore(node, parent) { - var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, 0 /* None */); + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, 0 /* ListFormat.None */); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false); } return !!leadingNewlines; } function writeLineSeparatorsAfter(node, parent) { - var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, 0 /* None */, /*childrenTextRange*/ undefined); + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, 0 /* ListFormat.None */, /*childrenTextRange*/ undefined); if (trailingNewlines) { writeLine(trailingNewlines); } @@ -115391,14 +115829,14 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } function getLinesBetweenNodes(parent, node1, node2) { - if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + if (ts.getEmitFlags(parent) & 131072 /* EmitFlags.NoIndentation */) { return 0; } parent = skipSynthesizedParentheses(parent); @@ -115421,7 +115859,7 @@ var ts; && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node) { - while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -115449,29 +115887,29 @@ var ts; return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) { - if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); } } - var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0) - | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0) - | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0) - | (printerOptions.target && printerOptions.target === 99 /* ESNext */ ? 8 /* AllowNumericSeparator */ : 0); + var flags = (neverAsciiEscape ? 1 /* GetLiteralTextFlags.NeverAsciiEscape */ : 0) + | (jsxAttributeEscape ? 2 /* GetLiteralTextFlags.JsxAttributeEscape */ : 0) + | (printerOptions.terminateUnterminatedLiterals ? 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ : 0) + | (printerOptions.target && printerOptions.target === 99 /* ScriptTarget.ESNext */ ? 8 /* GetLiteralTextFlags.AllowNumericSeparator */ : 0); return ts.getLiteralText(node, currentSourceFile, flags); } /** * Push a new name generation scope. */ function pushNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlagsStack.push(tempFlags); @@ -115482,7 +115920,7 @@ var ts; * Pop the current name generation scope. */ function popNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlags = tempFlagsStack.pop(); @@ -115498,84 +115936,84 @@ var ts; if (!node) return; switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.forEach(node.statements, generateNames); break; - case 250 /* LabeledStatement */: - case 248 /* WithStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: generateNames(node.statement); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: generateNames(node.caseBlock); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: generateNames(node.declarationList); break; - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: generateNameIfNeeded(node.name); - if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: generateNames(node.importClause); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: generateNameIfNeeded(node.name); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: generateNameIfNeeded(node.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.forEach(node.elements, generateNames); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -115584,12 +116022,12 @@ var ts; if (!node) return; switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -115608,7 +116046,7 @@ var ts; * Generate the text for a generated identifier. */ function generateName(name) { - if ((name.autoGenerateFlags & 7 /* KindMask */) === 4 /* Node */) { + if ((name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) === 4 /* GeneratedIdentifierFlags.Node */) { // Node names generate unique names based on their original node // and are cached based on that node's id. return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags); @@ -115647,7 +116085,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */)) { return false; } } @@ -115661,7 +116099,7 @@ var ts; */ function makeTempVariableName(flags, reservedInNestedScopes) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + var name = flags === 268435456 /* TempFlags._i */ ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; if (reservedInNestedScopes) { @@ -115671,12 +116109,12 @@ var ts; } } while (true) { - var count = tempFlags & 268435455 /* CountMask */; + var count = tempFlags & 268435455 /* TempFlags.CountMask */; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { var name = count < 26 - ? "_" + String.fromCharCode(97 /* a */ + count) + ? "_" + String.fromCharCode(97 /* CharacterCodes.a */ + count) : "_" + (count - 26); if (isUniqueName(name)) { if (reservedInNestedScopes) { @@ -115708,7 +116146,7 @@ var ts; } } // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* CharacterCodes._ */) { baseName += "_"; } var i = 1; @@ -115762,48 +116200,48 @@ var ts; if (ts.isIdentifier(node.name)) { return generateNameCached(node.name); } - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } /** * Generates a unique name from a node. */ function generateNameForNode(node, flags) { switch (node.kind) { - case 79 /* Identifier */: - return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: + case 79 /* SyntaxKind.Identifier */: + return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(flags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return generateNameForExportDefault(); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return generateNameForClassExpression(); - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return generateNameForMethodOrAccessor(node); - case 162 /* ComputedPropertyName */: - return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); + case 162 /* SyntaxKind.ComputedPropertyName */: + return makeTempVariableName(0 /* TempFlags.Auto */, /*reserveInNestedScopes*/ true); default: - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } } /** * Generates a unique identifier for a node. */ function makeName(name) { - switch (name.autoGenerateFlags & 7 /* KindMask */) { - case 1 /* Auto */: - return makeTempVariableName(0 /* Auto */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 2 /* Loop */: - return makeTempVariableName(268435456 /* _i */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 3 /* Unique */: - return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); + switch (name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) { + case 1 /* GeneratedIdentifierFlags.Auto */: + return makeTempVariableName(0 /* TempFlags.Auto */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 2 /* GeneratedIdentifierFlags.Loop */: + return makeTempVariableName(268435456 /* TempFlags._i */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 3 /* GeneratedIdentifierFlags.Unique */: + return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* GeneratedIdentifierFlags.FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); } return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -115819,7 +116257,7 @@ var ts; // if "node" is a different generated name (having a different // "autoGenerateId"), use it and stop traversing. if (ts.isIdentifier(node) - && !!(node.autoGenerateFlags & 4 /* Node */) + && !!(node.autoGenerateFlags & 4 /* GeneratedIdentifierFlags.Node */) && node.autoGenerateId !== autoGenerateId) { break; } @@ -115830,7 +116268,7 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var pipelinePhase = getNextPipelinePhase(2 /* PipelinePhase.Comments */, hint, node); var savedContainerPos = containerPos; var savedContainerEnd = containerEnd; var savedDeclarationListContainerEnd = declarationListContainerEnd; @@ -115843,7 +116281,7 @@ var ts; var commentRange = ts.getCommentRange(node); // Emit leading comments emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = true; } } @@ -115851,7 +116289,7 @@ var ts; var emitFlags = ts.getEmitFlags(node); var commentRange = ts.getCommentRange(node); // Emit trailing comments - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = false; } emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); @@ -115865,25 +116303,25 @@ var ts; hasWrittenComment = false; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; // Save current container state on the stack. if ((pos > 0 || end > 0) && pos !== end) { // Emit leading comments if the position is not synthesized and the node // has not opted out from emitting leading comments. if (!skipLeadingComments) { - emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */); } - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. containerPos = pos; } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* NoTrailingComments */) !== 0)) { + if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) { // As above. containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -115893,7 +116331,7 @@ var ts; } function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -115902,18 +116340,18 @@ var ts; declarationListContainerEnd = savedDeclarationListContainerEnd; // Emit trailing comments if the position is not synthesized and the node // has not opted out from emitting leading comments and is an emitted node. - if (!skipTrailingComments && node.kind !== 349 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 349 /* SyntaxKind.NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); } function emitLeadingSynthesizedComment(comment) { - if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasLeadingNewline || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasTrailingNewLine || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } else { @@ -115931,25 +116369,25 @@ var ts; } function writeSynthesizedComment(comment) { var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + var lineMap = comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); } function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; + return comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); var pos = detachedRange.pos, end = detachedRange.end; var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0; + var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0; if (!skipLeadingComments) { emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); } exitComment(); - if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */ && !commentsDisabled) { commentsDisabled = true; emitCallback(node); commentsDisabled = false; @@ -116038,7 +116476,7 @@ var ts; if (hasTrailingNewLine) { writer.writeLine(); } - else if (kind === 3 /* MultiLineCommentTrivia */) { + else if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { writer.writeSpace(" "); } } @@ -116080,7 +116518,7 @@ var ts; emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); - if (kind === 2 /* SingleLineCommentTrivia */) { + if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); // still write a newline for single-line comments, so closing tokens aren't written on the same line } } @@ -116165,7 +116603,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMaps(hint, node) { - var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); + var pipelinePhase = getNextPipelinePhase(3 /* PipelinePhase.SourceMaps */, hint, node); emitSourceMapsBeforeNode(node); pipelinePhase(hint, node); emitSourceMapsAfterNode(node); @@ -116183,12 +116621,12 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 16 /* EmitFlags.NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = true; } } @@ -116198,11 +116636,11 @@ var ts; var sourceMapRange = ts.getSourceMapRange(node); // Emit trailing sourcemap if (!ts.isUnparsedNode(node)) { - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 32 /* EmitFlags.NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } @@ -116255,17 +116693,17 @@ var ts; return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; + var emitFlags = emitNode && emitNode.flags || 0 /* EmitFlags.None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; var source = range && range.source || sourceMapSource; tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 128 /* EmitFlags.NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } tokenPos = emitCallback(token, writer, tokenPos); if (range) tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 256 /* EmitFlags.NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } return tokenPos; @@ -116296,23 +116734,23 @@ var ts; sourceMapSourceIndex = sourceIndex; } function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Extension.Json */); } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[1024 /* Braces */] = ["{", "}"]; - brackets[2048 /* Parenthesis */] = ["(", ")"]; - brackets[4096 /* AngleBrackets */] = ["<", ">"]; - brackets[8192 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* ListFormat.Braces */] = ["{", "}"]; + brackets[2048 /* ListFormat.Parenthesis */] = ["(", ")"]; + brackets[4096 /* ListFormat.AngleBrackets */] = ["<", ">"]; + brackets[8192 /* ListFormat.SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 15360 /* BracketsMask */][0]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 15360 /* BracketsMask */][1]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -116678,7 +117116,7 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; @@ -116687,11 +117125,11 @@ var ts; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) @@ -116713,9 +117151,9 @@ var ts; var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; - if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) || - hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + if (hasSourceFile((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + hasSourceFile((filePathWithoutExtension + ".tsx" /* Extension.Tsx */))) { + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -116748,7 +117186,7 @@ var ts; ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop); var plainInvokeFactory = { watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); }, - watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options); }, + watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* WatchDirectoryFlags.Recursive */) !== 0, options); }, }; var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ? { @@ -116783,36 +117221,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -116822,16 +117260,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -117012,7 +117450,7 @@ var ts; if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output // Cache json or buildInfo - if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { + if (!ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -117023,7 +117461,7 @@ var ts; if (value) return value; var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); - if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */))) { + if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) { sourceFileCache.set(key, sourceFile); } return sourceFile; @@ -117113,12 +117551,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -117206,9 +117644,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -117222,7 +117660,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -117285,7 +117723,7 @@ var ts; var mode = getModeForFileReference(name, containingFileMode); // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -117401,7 +117839,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -117580,22 +118018,33 @@ var ts; * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format */ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { + var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options); + return typeof result === "object" ? result.impliedNodeFormat : result; + } + ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + /*@internal*/ + function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: - return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext : - ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS : - ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : + return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ts.ModuleKind.ESNext : + ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ts.ModuleKind.CommonJS : + ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Extension.Dts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */]) ? lookupFromPackageJson() : undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline default: return undefined; } function lookupFromPackageJson() { - var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options); - return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options); + var packageJsonLocations = []; + state.failedLookupLocations = packageJsonLocations; + state.affectingLocations = packageJsonLocations; + var packageJsonScope = ts.getPackageScopeForPath(fileName, state); + var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope }; } } - ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker; /** @internal */ ts.plainJSErrors = new ts.Set([ // binder errors @@ -117743,7 +118192,7 @@ var ts; var modulesWithElidedImports = new ts.Map(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = new ts.Map(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -117824,16 +118273,16 @@ var ts; forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists; var readFile = host.readFile.bind(host); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structureIsReused; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { @@ -117861,7 +118310,7 @@ var ts; var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); }); for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) { var fileName = _c[_b]; - if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index }); } } @@ -117870,13 +118319,13 @@ var ts; }); } } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferences", { count: typeReferences.length }); // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); @@ -117920,7 +118369,7 @@ var ts; for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { var oldSourceFile = oldSourceFiles_1[_i]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); - if (shouldCreateNewSourceFile || !newFile || + if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || // old file wasn't redirect but new file is (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); @@ -118010,9 +118459,9 @@ var ts; // Add file processingDiagnostics fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) { switch (diagnostic.kind) { - case 1 /* FilePreprocessingFileExplainingDiagnostic */: + case 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */: return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray)); - case 0 /* FilePreprocessingReferencedDiagnostic */: + case 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */: var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end; return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false))); default: @@ -118063,7 +118512,7 @@ var ts; return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); @@ -118078,7 +118527,7 @@ var ts; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode); ts.performance.mark("afterResolveTypeReference"); @@ -118160,7 +118609,7 @@ var ts; return classifiableNames; } function resolveModuleNamesReusingOldState(moduleNames, file) { - if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { + if (structureIsReused === 0 /* StructureIsReused.Not */ && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); @@ -118257,7 +118706,7 @@ var ts; // `result[i]` is either a `ResolvedModuleFull` or a marker. // If it is the former, we can leave it as is. if (result[i] === predictedToResolveToAmbientModuleMarker) { - result[i] = undefined; // TODO: GH#18217 + result[i] = undefined; } } else { @@ -118313,24 +118762,24 @@ var ts; }); } function tryReuseStructureFromOldProgram() { - var _a; + var _a, _b; if (!oldProgram) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); if (ts.changesAffectModuleResolution(oldOptions, options)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // there is an old program, check if we can reuse its structure var oldRootNames = oldProgram.getRootFileNames(); if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); @@ -118338,12 +118787,12 @@ var ts; // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; var modifiedSourceFiles = []; - structureIsReused = 2 /* Completely */; + structureIsReused = 2 /* StructureIsReused.Completely */; // If the missing file paths are now present, it can change the progam structure, // and hence cant reuse the structure. // This is same as how we dont reuse the structure if one of the file from old program is now missing if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } var oldSourceFiles = oldProgram.getSourceFiles(); var SeenPackageName; @@ -118354,12 +118803,15 @@ var ts; var seenPackageNames = new ts.Map(); for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { var oldSourceFile = oldSourceFiles_2[_i]; + var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options); var newSourceFile = host.getSourceFileByPath - ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 + ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat) + : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217 if (!newSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } + newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope; ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; if (oldSourceFile.redirectInfo) { @@ -118367,7 +118819,7 @@ var ts; // This lets us know if the unredirected file has changed. If it has we should break the redirect. if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { // Underlying file has changed. Might not redirect anymore. Must rebuild program. - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; newSourceFile = oldSourceFile; // Use the redirect. @@ -118375,7 +118827,7 @@ var ts; else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) { // If a redirected-to source file changes, the redirect may be broken. if (newSourceFile !== oldSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; } @@ -118392,80 +118844,85 @@ var ts; // If there are 2 different source files for the same package name and at least one of them changes, // they might become redirects. So we must rebuild the program. var prevKind = seenPackageNames.get(packageName); - var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; - if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { - return 0 /* Not */; + var newKind = fileChanged ? 1 /* SeenPackageName.Modified */ : 0 /* SeenPackageName.Exists */; + if ((prevKind !== undefined && newKind === 1 /* SeenPackageName.Modified */) || prevKind === 1 /* SeenPackageName.Modified */) { + return 0 /* StructureIsReused.Not */; } seenPackageNames.set(packageName, newKind); } if (fileChanged) { + if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) { + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } // The `newSourceFile` object was created for the new program. - if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check tripleslash references - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - // check imports and module augmentations - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { - // imports has changed - structureIsReused = 1 /* SafeModules */; - } - if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { - // moduleAugmentations has changed - structureIsReused = 1 /* SafeModules */; - } - if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) { - // dynamicImport has changed - structureIsReused = 1 /* SafeModules */; - } - if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { - // 'types' references has changed - structureIsReused = 1 /* SafeModules */; + else { + // check imports and module augmentations + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + // moduleAugmentations has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if ((oldSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */)) { + // dynamicImport has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { + // 'types' references has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else if (hasInvalidatedResolution(oldSourceFile.path)) { // 'module/types' references could have changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; // add file to the modified list so that we will resolve it later modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); - for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) { - var oldFile = oldSourceFiles_3[_b]; + for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) { + var oldFile = oldSourceFiles_3[_c]; if (!ts.contains(modifiedFiles, oldFile)) { - for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) { - var moduleName = _d[_c]; + for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) { + var moduleName = _e[_d]; ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); } } } // try to verify results of module resolution - for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) { - var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile; + for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) { + var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile; var moduleNames = getModuleNames(newSourceFile); var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile); // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions); } else { @@ -118476,24 +118933,24 @@ var ts; // ensure that types resolutions are still correct var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo); if (typeReferenceResolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } - if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { - return 1 /* SafeModules */; + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) { + return 1 /* StructureIsReused.SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length); - for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) { - var newSourceFile = newSourceFiles_1[_g]; + for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) { + var newSourceFile = newSourceFiles_1[_h]; filesByName.set(newSourceFile.path, newSourceFile); } var oldFilesByNameMap = oldProgram.getFilesByNameMap(); @@ -118518,7 +118975,7 @@ var ts; sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules; - return 2 /* Completely */; + return 2 /* StructureIsReused.Completely */; } function getEmitHost(writeFileCallback) { return { @@ -118563,7 +119020,7 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -118615,7 +119072,7 @@ var ts; return typeChecker || (typeChecker = ts.createTypeChecker(program)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -118735,7 +119192,7 @@ var ts; } var typeChecker = getTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); - var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */; + var isJs = sourceFile.scriptKind === 1 /* ScriptKind.JS */ || sourceFile.scriptKind === 2 /* ScriptKind.JSX */; var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options); var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs); var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; @@ -118743,8 +119200,8 @@ var ts; // - plain JS: .js files with no // ts-check and checkJs: undefined // - check JS: .js files with either // ts-check or checkJs: true // - external: files that are added by plugins - var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ - || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* ScriptKind.TS */ || sourceFile.scriptKind === 4 /* ScriptKind.TSX */ + || sourceFile.scriptKind === 5 /* ScriptKind.External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* ScriptKind.Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; if (isPlainJs) { @@ -118823,22 +119280,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 254 /* VariableDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 254 /* SyntaxKind.VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -118846,65 +119303,65 @@ var ts; } } switch (node.kind) { - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type")); return "skip"; } break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: var heritageClause = node; - if (heritageClause.token === 117 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 258 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* SyntaxKind.InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 261 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */); + case 261 /* SyntaxKind.ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* NodeFlags.Namespace */ ? ts.tokenToString(142 /* SyntaxKind.NamespaceKeyword */) : ts.tokenToString(141 /* SyntaxKind.ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 260 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); + case 260 /* SyntaxKind.EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* SyntaxKind.EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -118913,53 +119370,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 237 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 237 /* SyntaxKind.VariableStatement */); return "skip"; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (ts.isModifier(modifier) && modifier.kind !== 124 /* StaticKeyword */) { + if (ts.isModifier(modifier) && modifier.kind !== 124 /* SyntaxKind.StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers && ts.some(nodes, ts.isModifier)) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 210 /* TaggedTemplateExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -118972,27 +119429,27 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 135 /* DeclareKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 124 /* StaticKeyword */: - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: } } } @@ -119062,20 +119519,20 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 79 /* Identifier */ - ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 10 /* StringLiteral */ && a.text === b.text; + return a.kind === 79 /* SyntaxKind.Identifier */ + ? b.kind === 79 /* SyntaxKind.Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* SyntaxKind.StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); var importDecl = ts.factory.createImportDeclaration(/*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); - ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(importDecl, 67108864 /* EmitFlags.NeverApplyImportHelper */); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); // explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them // (which is required to build the dependency graph for incremental emit) - externalHelpersModuleReference.flags &= ~8 /* Synthesized */; - importDecl.flags &= ~8 /* Synthesized */; + externalHelpersModuleReference.flags &= ~8 /* NodeFlags.Synthesized */; + importDecl.flags &= ~8 /* NodeFlags.Synthesized */; return externalHelpersModuleReference; } function collectExternalModuleReferences(file) { @@ -119106,7 +119563,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -119128,7 +119585,7 @@ var ts; } } else if (ts.isModuleDeclaration(node)) { - if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) { node.name.parent = node; var nameText = ts.getTextOfIdentifierOrLiteral(node.name); // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -119183,7 +119640,7 @@ var ts; function getNodeAtPosition(sourceFile, position) { var current = sourceFile; var getContainingChild = function (child) { - if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* EndOfFileToken */)))) { + if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) { return child; } }; @@ -119276,13 +119733,16 @@ var ts; addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]); } } - function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) { + var _a; var redirect = Object.create(redirectTarget); redirect.fileName = fileName; redirect.path = path; redirect.resolvedPath = resolvedPath; redirect.originalFileName = originalFileName; redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + redirect.packageJsonScope = sourceFileOptions.packageJsonScope; sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); Object.defineProperties(redirect, { id: { @@ -119298,7 +119758,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], @@ -119311,14 +119771,14 @@ var ts; // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront. - var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); - return { - languageVersion: ts.getEmitScriptTarget(options), - impliedNodeFormat: impliedNodeFormat, - setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options) - }; + var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); + var languageVersion = ts.getEmitScriptTarget(options); + var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options); + return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) : + { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator }; } function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { + var _a, _b; var path = toPath(fileName); if (useSourceOfProjectReferenceRedirect) { var source = getSourceOfProjectReferenceRedirect(path); @@ -119405,14 +119865,15 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile); + var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options); + var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat)); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. // Instead of creating a duplicate, just redirect to the existing one. - var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217 + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions); redirectTargetsMap.add(fileFromPackageId.path, fileName); addFileToFilesByName(dupFile, path, redirectedPath); addFileIncludeReason(dupFile, reason); @@ -119433,6 +119894,8 @@ var ts; file.path = path; file.resolvedPath = toPath(fileName); file.originalFileName = originalFileName; + file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined; + file.packageJsonScope = sourceFileOptions.packageJsonScope; addFileIncludeReason(file, reason); if (host.useCaseSensitiveFileNames()) { var pathLowerCase = ts.toFileNameLowerCase(path); @@ -119483,7 +119946,7 @@ var ts; } function getProjectReferenceRedirectProject(fileName) { // Ignore dts or any json files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -119493,7 +119956,7 @@ var ts; function getProjectReferenceOutputName(referencedProject, fileName) { var out = ts.outFile(referencedProject.commandLine.options); return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.changeExtension(out, ".d.ts" /* Extension.Dts */) : ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames()); } /** @@ -119526,13 +119989,13 @@ var ts; var out = ts.outFile(resolvedRef.commandLine.options); if (out) { // Dont know which source file it means so return true? - var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + var outputDts = ts.changeExtension(out, ".d.ts" /* Extension.Dts */); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); } else { var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); }); ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -119578,7 +120041,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -119637,7 +120100,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -119657,7 +120120,7 @@ var ts; var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 0 /* FilePreprocessingReferencedDiagnostic */, + kind: 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */, reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }, diagnostic: diagnostic, args: [libName, suggestion] @@ -119704,7 +120167,7 @@ var ts; && index < file.imports.length && !elideImport && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) - && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */)); + && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* NodeFlags.JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -119765,7 +120228,7 @@ var ts; else { // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); - sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + sourceFile = host.getSourceFile(refPath, 100 /* ScriptTarget.JSON */); addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { projectReferenceRedirects.set(sourceFilePath, false); @@ -119905,19 +120368,19 @@ var ts; var languageVersion = ts.getEmitScriptTarget(options); var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ScriptTarget.ES2015 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } if (options.preserveConstEnums === false) { createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules"); } - var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* ScriptKind.JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName))); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ScriptTarget.ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -119956,7 +120419,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + if (options.useDefineForClassFields && languageVersion === 0 /* ScriptTarget.ES3 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !ts.getAllowJSCompilerOption(options)) { @@ -119978,7 +120441,7 @@ var ts; if (options.reactNamespace) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { @@ -119992,7 +120455,7 @@ var ts; if (!options.jsxFactory) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { @@ -120000,12 +120463,12 @@ var ts; } } if (options.reactNamespace) { - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx)); } } if (options.jsxImportSource) { - if (options.jsx === 2 /* React */) { + if (options.jsx === 2 /* JsxEmit.React */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); } } @@ -120063,7 +120526,7 @@ var ts; fileIncludeReasons = undefined; var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason); var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon); - var redirectInfo = file && ts.explainIfFileIsRedirect(file); + var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file); var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false)); return location && isReferenceFileLocation(location) ? ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : @@ -120084,7 +120547,7 @@ var ts; } function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) { (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 1 /* FilePreprocessingFileExplainingDiagnostic */, + kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */, file: file && file.path, fileProcessingReason: fileProcessingReason, diagnostic: diagnostic, @@ -120323,7 +120786,7 @@ var ts; // If options have --outFile or --out just check that var out = ts.outFile(options); if (out) { - return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); + return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Extension.Dts */); } // If declarationDir is specified, return if its a file in that directory if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { @@ -120336,13 +120799,13 @@ var ts; if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || - !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Extension.Tsx */)); } return false; } function isSameFile(file1, file2) { - return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; } function getSymlinkCache() { if (host.getSymlinkCache) { @@ -120443,12 +120906,12 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || // Any parent directory of declaration dir ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || // Any directory inside declaration dir - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -120501,7 +120964,7 @@ var ts; if (isFile && result) { // Store the real path for the file' var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -120597,17 +121060,17 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ".tsx" /* Extension.Tsx */: return needJsx(); - case ".jsx" /* Jsx */: + case ".jsx" /* Extension.Jsx */: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ".js" /* Extension.Js */: return needAllowJs(); - case ".json" /* Json */: + case ".json" /* Extension.Json */: return needResolveJsonModule(); } function needJsx() { @@ -120626,7 +121089,7 @@ var ts; var res = imports.map(function (i) { return i.text; }); for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { var aug = moduleAugmentations_1[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -120641,7 +121104,7 @@ var ts; var augIndex = imports.length; for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) { var aug = moduleAugmentations_2[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { if (index === augIndex) return aug; augIndex++; @@ -120657,8 +121120,8 @@ var ts; (function (ts) { function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit; - return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; + var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics; + return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); } @@ -120882,23 +121345,23 @@ var ts; /** * Gets the files affected by the path from the program */ - function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var _a, _b; - var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash); + var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName); (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear(); (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); return result; } BuilderState.getFilesAffectedBy = getFilesAffectedBy; - function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var sourceFile = programOfThisState.getSourceFileByPath(path); if (!sourceFile) { return ts.emptyArray; } - if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) { + if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) { return [sourceFile]; } - return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash); + return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName); } BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState; function updateSignatureOfFile(state, signature, path) { @@ -120909,7 +121372,7 @@ var ts; /** * Returns if the shape of the signature has changed since last emit */ - function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) { + function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) { var _a; if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; } // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate @@ -120919,18 +121382,16 @@ var ts; var prevSignature = info.signature; var latestSignature; if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) { - var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, - /*emitOnlyDtsFiles*/ true, cancellationToken, - /*customTransformers*/ undefined, - /*forceDtsEmit*/ true); - var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); - if (firstDts_1) { - ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); - latestSignature = computeSignature(firstDts_1.text, computeHash); + programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) { + ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: ".concat(fileName)); + latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data); if (latestSignature !== prevSignature) { - updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit); + updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit); } - } + }, cancellationToken, + /*emitOnlyDtsFiles*/ true, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); } // Default is to use file version as signature if (latestSignature === undefined) { @@ -120953,10 +121414,6 @@ var ts; return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; - function computeSignature(text, computeHash) { - return (computeHash || ts.generateDjb2Hash)(text); - } - BuilderState.computeSignature = computeSignature; /** * Coverts the declaration emit result into exported modules map */ @@ -121106,7 +121563,7 @@ var ts; /** * When program emits modular code, gets the files affected by the sourceFile whose shape has changed */ - function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) { + function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) { if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } @@ -121126,7 +121583,7 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath); seenFileNamesMap.set(currentPath, currentSourceFile); - if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) { + if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) { queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath)); } } @@ -121166,7 +121623,7 @@ var ts; state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature; } state.changedFilesSet = new ts.Set(); - state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined; + state.latestChangedDtsFile = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.latestChangedDtsFile : undefined; var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && @@ -121237,7 +121694,7 @@ var ts; } else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); }); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* BuilderFileEmit.Full */); }); ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } @@ -121290,7 +121747,7 @@ var ts; programEmitComplete: state.programEmitComplete, emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: state.latestChangedDtsFile, hasChangedEmitSignature: state.hasChangedEmitSignature, changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined, }; @@ -121303,7 +121760,7 @@ var ts; state.programEmitComplete = savedEmitState.programEmitComplete; state.emitSignatures = savedEmitState.emitSignatures; state.outSignature = savedEmitState.outSignature; - state.dtsChangeTime = savedEmitState.dtsChangeTime; + state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile; state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature; if (savedEmitState.changedFilesSet) state.changedFilesSet = savedEmitState.changedFilesSet; @@ -121320,7 +121777,7 @@ var ts; * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained */ - function getNextAffectedFile(state, cancellationToken, computeHash, host) { + function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; while (true) { var affectedFiles = state.affectedFiles; @@ -121332,7 +121789,7 @@ var ts; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { // Set the next affected file as seen and remove the cached semantic diagnostics state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); return affectedFile; } affectedFilesIndex++; @@ -121360,7 +121817,7 @@ var ts; return program; } // Get next batch of affected files - state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash); + state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName); state.currentChangedFilePath = nextKey.value; state.affectedFilesIndex = 0; if (!state.seenAffectedFiles) @@ -121411,7 +121868,7 @@ var ts; * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { @@ -121419,18 +121876,18 @@ var ts; // When a change affects the global scope, all files are considered to be affected without updating their signature // That means when affected file is handled, its signature can be out of date // To avoid this, ensure that we update the signature for any affected file in this scenario. - ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash); + ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName); return; } if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) return; - handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); } /** * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, * Also we need to make sure signature is updated for these files */ - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); @@ -121441,10 +121898,10 @@ var ts; // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. - ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); + addToAffectedFilesPendingEmit(state, path, 0 /* BuilderFileEmit.DtsOnly */); } } } @@ -121466,20 +121923,20 @@ var ts; var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } - function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) return false; // Every file needs to be handled ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined) - .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); }); removeDiagnosticsOfLibraryFiles(state); return true; } /** * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit */ - function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit @@ -121497,9 +121954,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host)) return; - handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -121511,11 +121968,11 @@ var ts; // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; var references = state.referencedMap.getKeys(exportedFromPath); return references && ts.forEachKey(references, function (filePath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); }); } @@ -121523,22 +121980,22 @@ var ts; * handle dts and semantic diagnostics on file and iterate on anything that exports this file * return true when all work is done and we can exit handling dts emit and semantic diagnostics */ - function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) return undefined; - if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; - handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host); // If exported modules has path, all files referencing file exported from are affected (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); // Remove diagnostics of files that import this file (without going to exports of referencing files) (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal - state, referencingFilePath, cancellationToken, computeHash, host); + state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host); }); return undefined; } @@ -121617,14 +122074,14 @@ var ts; /** * Gets the program information to be emitted in buildInfo so that we can use it to create new program */ - function getProgramBuildInfo(state, getCanonicalFileName, host) { + function getProgramBuildInfo(state, getCanonicalFileName) { var outFilePath = ts.outFile(state.compilerOptions); if (outFilePath && !state.compilerOptions.composite) return; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - // Update the dtsChange time in buildInfo - state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime; + // Convert the file name to Path here if we set the fileName instead to optimize multiple d.ts file emits and having to compute Canonical path + var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined; if (outFilePath) { var fileNames_1 = []; var fileInfos_1 = []; @@ -121640,7 +122097,7 @@ var ts; fileInfos: fileInfos_1, options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result_15; } @@ -121742,7 +122199,7 @@ var ts; affectedFilesPendingEmit: affectedFilesPendingEmit, changeFileSet: changeFileSet, emitSignatures: emitSignatures, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result; function relativeToBuildInfoEnsuringAbsolutePath(path) { @@ -121857,8 +122314,39 @@ var ts; return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray }; } ts.getBuilderCreationParameters = getBuilderCreationParameters; - function computeSignature(text, data, computeHash) { - return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash); + function getTextHandlingSourceMapForSignature(text, data) { + return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text; + } + function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) { + var _a; + text = getTextHandlingSourceMapForSignature(text, data); + var sourceFileDirectory; + if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) { + text += data.diagnostics.map(function (diagnostic) { + return "".concat(locationInfo(diagnostic)).concat(ts.DiagnosticCategory[diagnostic.category]).concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText)); + }).join("\n"); + } + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text); + function flattenDiagnosticMessageText(diagnostic) { + return ts.isString(diagnostic) ? + diagnostic : + diagnostic === undefined ? + "" : + !diagnostic.next ? + diagnostic.messageText : + diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n"); + } + function locationInfo(diagnostic) { + if (diagnostic.file.resolvedPath === sourceFile.resolvedPath) + return "(".concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + if (sourceFileDirectory === undefined) + sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath); + return "".concat(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)), "(").concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + } + } + ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics; + function computeSignature(text, computeHash, data) { + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data)); } ts.computeSignature = computeSignature; function createBuilderProgram(kind, _a) { @@ -121879,7 +122367,7 @@ var ts; */ var computeHash = ts.maybeBind(host, host.createHash); var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); - newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); }; + newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); }; // To ensure that we arent storing any references to old program or new program without state newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; @@ -121889,6 +122377,7 @@ var ts; builderProgram.getState = getState; builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); }; builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); }; + builderProgram.hasChangedEmitSignature = function () { return !!state.hasChangedEmitSignature; }; builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); }; builderProgram.getSemanticDiagnostics = getSemanticDiagnostics; builderProgram.emit = emit; @@ -121919,8 +122408,8 @@ var ts; * in that order would be used to write the files */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); - var emitKind = 1 /* Full */; + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); + var emitKind = 1 /* BuilderFileEmit.Full */; var isPendingEmitFile = false; if (!affected) { if (!ts.outFile(state.compilerOptions)) { @@ -121933,7 +122422,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* BuilderFileEmit.Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } @@ -121952,36 +122441,39 @@ var ts; // Otherwise just affected file ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ? getWriteFileCallback(writeFile, customTransformers) : - writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } function getWriteFileCallback(writeFile, customTransformers) { return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f, _g; if (ts.isDeclarationFileName(fileName)) { if (!ts.outFile(state.compilerOptions)) { ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); - var newSignature = void 0; + var emitSignature = void 0; if (!customTransformers) { var file = sourceFiles[0]; var info = state.fileInfos.get(file.resolvedPath); if (info.signature === file.version) { - newSignature = computeSignature(text, data, computeHash); - if (newSignature !== file.version) { // Update it + var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data); + // With d.ts diagnostics they are also part of the signature so emitSignature will be different from it since its just hash of d.ts + if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length)) + emitSignature = signature; + if (signature !== file.version) { // Update it if (host.storeFilesChangingSignatureDuringEmit) - (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); if (state.exportedModulesMap) ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit); if (state.affectedFiles) { // Keep old signature so we know what to undo if cancellation happens - var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath); + var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath); if (existing === undefined) - (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); - info.signature = newSignature; + ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); + info.signature = signature; } else { // These are directly commited - info.signature = newSignature; - (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); + info.signature = signature; + (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear(); } } } @@ -121991,20 +122483,24 @@ var ts; // and would need their d.ts change time in --build mode if (state.compilerOptions.composite) { var filePath = sourceFiles[0].resolvedPath; - var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath); - newSignature || (newSignature = computeSignature(text, data, computeHash)); - if (newSignature !== oldSignature) { - (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature); - state.hasChangedEmitSignature = true; - } + var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath); + emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data)); + // Dont write dts files if they didn't change + if (emitSignature === oldSignature) + return; + ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature); + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } else if (state.compilerOptions.composite) { - var newSignature = computeSignature(text, data, computeHash); - if (newSignature !== state.outSignature) { - state.outSignature = newSignature; - state.hasChangedEmitSignature = true; - } + var newSignature = computeSignature(text, computeHash, data); + // Dont write dts files if they didn't change + if (newSignature === state.outSignature) + return; + state.outSignature = newSignature; + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } if (writeFile) @@ -122064,7 +122560,7 @@ var ts; // If every file pending emit is pending on only dts emit || ts.every(state.affectedFilesPendingEmit, function (path, index) { return index < state.affectedFilesPendingEmitIndex || - state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */; + state.affectedFilesPendingEmitKind.get(path) === 0 /* BuilderFileEmit.DtsOnly */; })) { clearAffectedFilesPendingEmit(state); } @@ -122080,7 +122576,7 @@ var ts; */ function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); if (!affected) { // Done return undefined; @@ -122092,7 +122588,7 @@ var ts; // Add file to affected file pending emit to handle for later emit time // Apart for emit builder do this for tsbuildinfo, do this for non emit builder when noEmit is set as tsbuildinfo is written and reused between emitters if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) { - addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* Full */); + addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* BuilderFileEmit.Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -122167,11 +122663,12 @@ var ts; var state; var filePaths; var filePathsSetList; + var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined; if (isProgramBundleEmitBuildInfo(program)) { state = { fileInfos: new ts.Map(), compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, outSignature: program.outSignature, }; } @@ -122204,7 +122701,7 @@ var ts; affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)), - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined, }; } @@ -122231,6 +122728,7 @@ var ts; getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, emitBuildInfo: ts.notImplemented, close: ts.noop, + hasChangedEmitSignature: ts.returnFalse, }; function toPath(path) { return ts.toPath(path, buildInfoDirectory, getCanonicalFileName); @@ -122333,7 +122831,7 @@ var ts; * "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot" * @param dirPath */ - function canWatchDirectory(dirPath) { + function canWatchDirectoryOrFile(dirPath) { var rootLength = ts.getRootLength(dirPath); if (dirPath.length === rootLength) { // Ignore "/", "c:/" @@ -122345,7 +122843,7 @@ var ts; return false; } var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); - var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */; if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart @@ -122370,7 +122868,7 @@ var ts; } return true; } - ts.canWatchDirectory = canWatchDirectory; + ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; var filesWithInvalidatedResolutions; @@ -122379,7 +122877,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolutionsWithOnlyAffectingLocations = []; var resolvedFileToResolution = ts.createMultiMap(); + var impliedFormatPackageJsons = new ts.Map(); var hasChangedAutomaticTypeDirectiveNames = false; + var affectingPathChecksForFile; var affectingPathChecks; var failedLookupChecks; var startsWithPathChecks; @@ -122404,7 +122904,7 @@ var ts; * This helps in not having to comb through all resolutions when files are added/removed * Note that .d.ts file also has .d.ts extension hence will be part of default extensions */ - var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; + var failedLookupDefaultExtensions = [".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); var fileWatchesOfAffectingLocations = new ts.Map(); @@ -122419,7 +122919,7 @@ var ts; finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions, // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) - startCachingPerDirectoryResolution: clearPerDirectoryResolutions, + startCachingPerDirectoryResolution: startCachingPerDirectoryResolution, finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution, resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, @@ -122463,9 +122963,10 @@ var ts; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; affectingPathChecks = undefined; - // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update - // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) - clearPerDirectoryResolutions(); + affectingPathChecksForFile = undefined; + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); + impliedFormatPackageJsons.clear(); hasChangedAutomaticTypeDirectiveNames = false; } function startRecordingFilesWithChangedResolutions() { @@ -122497,15 +122998,44 @@ var ts; return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } - function clearPerDirectoryResolutions() { - moduleResolutionCache.clear(); - typeReferenceDirectiveResolutionCache.clear(); + function startCachingPerDirectoryResolution() { + moduleResolutionCache.clearAllExceptPackageJsonInfoCache(); + typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache(); + // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update + // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } - function finishCachingPerDirectoryResolution() { + function finishCachingPerDirectoryResolution(newProgram, oldProgram) { filesWithInvalidatedNonRelativeUnresolvedImports = undefined; - clearPerDirectoryResolutions(); + nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); + nonRelativeExternalModuleResolutions.clear(); + // Update file watches + if (newProgram !== oldProgram) { + newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) { + var _a, _b, _c; + var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0; + var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray; + for (var i = existing.length; i < expected; i++) { + createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false); + } + if (existing.length > expected) { + for (var i = expected; i < existing.length; i++) { + fileWatchesOfAffectingLocations.get(existing[i]).files--; + } + } + if (expected) + impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations); + else + impliedFormatPackageJsons.delete(newFile.path); + }); + impliedFormatPackageJsons.forEach(function (existing, path) { + if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) { + existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; }); + impliedFormatPackageJsons.delete(path); + } + }); + } directoryWatchesOfFailedLookups.forEach(function (watcher, path) { if (watcher.refCount === 0) { directoryWatchesOfFailedLookups.delete(path); @@ -122513,11 +123043,9 @@ var ts; } }); fileWatchesOfAffectingLocations.forEach(function (watcher, path) { - if (watcher.refCount === 0) { + if (watcher.files === 0 && watcher.resolutions === 0) { fileWatchesOfAffectingLocations.delete(path); watcher.watcher.close(); - // Ensure when watching symlinked package.json, we can close the actual file watcher only once - watcher.watcher = ts.noopFileWatcher; } }); hasChangedAutomaticTypeDirectiveNames = false; @@ -122717,7 +123245,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution return { @@ -122744,7 +123272,7 @@ var ts; } // If the directory is node_modules use it to watch, always watch it recursively if (ts.isNodeModulesDirectory(dirPath)) { - return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; + return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; // Use some ancestor of the root directory @@ -122762,7 +123290,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; + return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -122833,46 +123361,65 @@ var ts; // Watch package json for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) { var affectingLocation = affectingLocations_1[_i]; - createFileWatcherOfAffectingLocation(affectingLocation); + createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true); } } - function createFileWatcherOfAffectingLocation(affectingLocation) { - var path = resolutionHost.toPath(affectingLocation); - var fileWatcher = fileWatchesOfAffectingLocations.get(path); + function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) { + var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation); if (fileWatcher) { - fileWatcher.refCount++; + if (forResolution) + fileWatcher.resolutions++; + else + fileWatcher.files++; return; } var locationToWatch = affectingLocation; - var locationToWatchPath = path; if (resolutionHost.realpath) { locationToWatch = resolutionHost.realpath(affectingLocation); - locationToWatchPath = resolutionHost.toPath(locationToWatch); - if (path !== locationToWatchPath) { - var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath); + if (affectingLocation !== locationToWatch) { + var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch); if (fileWatcher_1) { - fileWatcher_1.refCount++; - fileWatcher_1.paths.add(path); - fileWatchesOfAffectingLocations.set(path, fileWatcher_1); + if (forResolution) + fileWatcher_1.resolutions++; + else + fileWatcher_1.files++; + fileWatcher_1.paths.add(affectingLocation); + fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1); return; } } } var paths = new ts.Set(); - paths.add(locationToWatchPath); - var watcher = { - watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { - cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind); - paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); }); + paths.add(locationToWatch); + var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ? + resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { + cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind); + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + paths.forEach(function (path) { + if (watcher.resolutions) + (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path); + if (watcher.files) + (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path); + packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path)); + }); resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); - }), - refCount: 1, + }) : ts.noopFileWatcher; + var watcher = { + watcher: actualWatcher !== ts.noopFileWatcher ? { + close: function () { + actualWatcher.close(); + // Ensure when watching symlinked package.json, we can close the actual file watcher only once + actualWatcher = ts.noopFileWatcher; + } + } : actualWatcher, + resolutions: forResolution ? 1 : 0, + files: forResolution ? 0 : 1, paths: paths, }; - fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher); - if (path !== locationToWatchPath) { - fileWatchesOfAffectingLocations.set(path, watcher); - paths.add(path); + fileWatchesOfAffectingLocations.set(locationToWatch, watcher); + if (affectingLocation !== locationToWatch) { + fileWatchesOfAffectingLocations.set(affectingLocation, watcher); + paths.add(affectingLocation); } } function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) { @@ -122940,8 +123487,8 @@ var ts; } for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) { var affectingLocation = affectingLocations_2[_a]; - var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation)); - watcher.refCount--; + var watcher = fileWatchesOfAffectingLocations.get(affectingLocation); + watcher.resolutions--; } } function removeDirectoryWatcher(dirPath) { @@ -122957,7 +123504,7 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); - }, nonRecursive ? 0 /* None */ : 1 /* Recursive */); + }, nonRecursive ? 0 /* WatchDirectoryFlags.None */ : 1 /* WatchDirectoryFlags.Recursive */); } function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) { // Deleted file, stop watching failed lookups for all the resolutions in the file @@ -122968,7 +123515,7 @@ var ts; } } function removeResolutionsFromProjectReferenceRedirects(filePath) { - if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) + if (!ts.fileExtensionIs(filePath, ".json" /* Extension.Json */)) return; var program = resolutionHost.getCurrentProgram(); if (!program) @@ -122995,7 +123542,7 @@ var ts; resolution.isInvalidated = invalidated = true; for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) { var containingFilePath = _b[_a]; - (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); // When its a file with inferred types resolution, invalidate type reference directive resolution hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile); } @@ -123062,10 +123609,25 @@ var ts; resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { + var _a; + var invalidated = false; + if (affectingPathChecksForFile) { + (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) { + if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) { + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path); + invalidated = true; + } + }); + affectingPathChecksForFile = undefined; + } if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) { - return false; + return invalidated; + } + invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated; + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) { + packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; }); } - var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); failedLookupChecks = undefined; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; @@ -123078,17 +123640,15 @@ var ts; return true; if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) return false; - return resolution.failedLookupLocations.some(function (location) { - var locationPath = resolutionHost.toPath(location); - return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || - ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || - ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); - }); + return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); }); + } + function isInvalidatedFailedLookup(locationPath) { + return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); } function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) { - return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { - return affectingPathChecks.has(resolutionHost.toPath(location)); - }); + return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); }); } function closeTypeRootsWatch() { ts.clearMap(typeRootsWatches, ts.closeFileWatcher); @@ -123119,7 +123679,7 @@ var ts; if (dirPath) { scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); } - }, 1 /* Recursive */); + }, 1 /* WatchDirectoryFlags.Recursive */); } /** * Watches the types that would get added as part of getAutomaticTypeDirectiveNames @@ -123154,7 +123714,7 @@ var ts; function directoryExistsForTypeRootWatch(nodeTypesDirectory) { var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory)); var dirPath = resolutionHost.toPath(dir); - return dirPath === rootPath || canWatchDirectory(dirPath); + return dirPath === rootPath || canWatchDirectoryOrFile(dirPath); } } ts.createResolutionCache = createResolutionCache; @@ -123187,28 +123747,28 @@ var ts; function getPreferences(host, _a, compilerOptions, importingSourceFile) { var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding; return { - relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : - importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* RelativePreference.Relative */ : + importModuleSpecifierPreference === "non-relative" ? 1 /* RelativePreference.NonRelative */ : + importModuleSpecifierPreference === "project-relative" ? 3 /* RelativePreference.ExternalNonRelative */ : + 2 /* RelativePreference.Shortest */, ending: getEnding(), }; function getEnding() { switch (importModuleSpecifierEnding) { - case "minimal": return 0 /* Minimal */; - case "index": return 1 /* Index */; - case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + case "minimal": return 0 /* Ending.Minimal */; + case "index": return 1 /* Ending.Index */; + case "js": return 2 /* Ending.JsExtension */; + default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* Ending.JsExtension */ + : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) { return { - relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, + relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* RelativePreference.Relative */ : 1 /* RelativePreference.NonRelative */, ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? - 2 /* JsExtension */ : - ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + 2 /* Ending.JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */, }; } function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { @@ -123265,7 +123825,7 @@ var ts; var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || - getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); + getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { if (options === void 0) { options = {}; } @@ -123321,7 +123881,7 @@ var ts; return undefined; var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text; // If the preference is for non relative and the module specifier is relative, ignore it - return preferences.relativePreference !== 1 /* NonRelative */ || !ts.pathIsRelative(specifier) ? + return preferences.relativePreference !== 1 /* RelativePreference.NonRelative */ || !ts.pathIsRelative(specifier) ? specifier : undefined; }); }); @@ -123348,7 +123908,7 @@ var ts; return nodeModulesSpecifiers; } if (!specifier && !modulePath.isRedirect) { - var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences); + var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); if (ts.pathIsBareSpecifier(local)) { pathsSpecifiers = ts.append(pathsSpecifiers, local); } @@ -123376,13 +123936,13 @@ var ts; var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory }; } - function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) { + function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) { var ending = _a.ending, relativePreference = _a.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); - if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { + if (!baseUrl && !paths || relativePreference === 0 /* RelativePreference.Relative */) { return relativePath; } var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); @@ -123390,16 +123950,15 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; + var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions); + var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths; if (!nonRelative) { return relativePath; } - if (relativePreference === 1 /* NonRelative */) { + if (relativePreference === 1 /* RelativePreference.NonRelative */) { return nonRelative; } - if (relativePreference === 3 /* ExternalNonRelative */) { + if (relativePreference === 3 /* RelativePreference.ExternalNonRelative */) { var projectDirectory = compilerOptions.configFilePath ? ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory()); @@ -123433,7 +123992,7 @@ var ts; } return relativePath; } - if (relativePreference !== 2 /* Shortest */) + if (relativePreference !== 2 /* RelativePreference.Shortest */) ts.Debug.assertNever(relativePreference); // Prefer a relative import over a baseUrl import if it has fewer components. return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; @@ -123441,7 +124000,7 @@ var ts; function countPathComponents(path) { var count = 0; for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) { - if (path.charCodeAt(i) === 47 /* slash */) + if (path.charCodeAt(i) === 47 /* CharacterCodes.slash */) count++; } return count; @@ -123545,7 +124104,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_34 = function (directory) { + var _loop_35 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -123569,7 +124128,7 @@ var ts; }; var out_directory_1; for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { - var state_11 = _loop_34(directory); + var state_11 = _loop_35(directory); directory = out_directory_1; if (state_11 === "break") break; @@ -123612,11 +124171,11 @@ var ts; var exportSymbol = checker.getSymbolAtLocation(exportAssignment); if (!exportSymbol) return; - var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; + var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; if (originalExportSymbol === d.symbol) return topNamespace.parent.parent; function getTopNamespace(namespaceDeclaration) { - while (namespaceDeclaration.flags & 4 /* NestedNamespace */) { + while (namespaceDeclaration.flags & 4 /* NodeFlags.NestedNamespace */) { namespaceDeclaration = namespaceDeclaration.parent; } return namespaceDeclaration; @@ -123627,28 +124186,102 @@ var ts; return ambientModuleDeclare.name.text; } } - function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) { + function getAllowedEndings(preferredEnding, compilerOptions, importMode) { + if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) { + return [2 /* Ending.JsExtension */]; + } + switch (preferredEnding) { + case 2 /* Ending.JsExtension */: return [2 /* Ending.JsExtension */, 0 /* Ending.Minimal */, 1 /* Ending.Index */]; + case 1 /* Ending.Index */: return [1 /* Ending.Index */, 0 /* Ending.Minimal */, 2 /* Ending.JsExtension */]; + case 0 /* Ending.Minimal */: return [0 /* Ending.Minimal */, 1 /* Ending.Index */, 2 /* Ending.JsExtension */]; + default: ts.Debug.assertNever(preferredEnding); + } + } + function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) { for (var key in paths) { - for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { - var patternText_1 = _a[_i]; - var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1)); + var _loop_36 = function (patternText_1) { + var pattern = ts.normalizePath(patternText_1); var indexOfStar = pattern.indexOf("*"); + // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly, + // meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution + // causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file + // and matches the '*'. For example: + // + // Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action + // ---------------------->------------------------------->--------------------->--------------------------------------------------------------- + // import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm] + // import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm] + // + // (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516) + // + // The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in + // the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result. + // (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid + // extension for a module specifier.) + // + // Here, this means we need to be careful about whether we generate a match from the target filename (typically with a + // .ts extension) or the possible relative module specifiers representing that file: + // + // Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results + // --------------------<----------------------------------------------<------------------------------<-------------------||---------------------------- + // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none) + // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js + // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none) + // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*"] <- (none) || @app/foo, @app/foo/index, @app/foo/index.js + // dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js + // + // The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of + // relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes + // into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js' + // exists) and (c) that they are ordered by preference. The last row shows that the filename result and module + // specifier results are not mutually exclusive. Note that the filename result is a higher priority in module + // resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result + // in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be + // sorted among the others for a particular value of `importModuleSpecifierEnding`. + var candidates = allowedEndings.map(function (ending) { return ({ + ending: ending, + value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) + }); }); + if (ts.tryGetExtensionFromPath(pattern)) { + candidates.push({ ending: undefined, value: relativeToBaseUrl }); + } if (indexOfStar !== -1) { - var prefix = pattern.substr(0, indexOfStar); - var suffix = pattern.substr(indexOfStar + 1); - if (relativeToBaseUrl.length >= prefix.length + suffix.length && - ts.startsWith(relativeToBaseUrl, prefix) && - ts.endsWith(relativeToBaseUrl, suffix) || - !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); - return key.replace("*", matchedStar); + var prefix = pattern.substring(0, indexOfStar); + var suffix = pattern.substring(indexOfStar + 1); + for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) { + var _c = candidates_3[_b], ending = _c.ending, value = _c.value; + if (value.length >= prefix.length + suffix.length && + ts.startsWith(value, prefix) && + ts.endsWith(value, suffix) && + validateEnding({ ending: ending, value: value })) { + var matchedStar = value.substring(prefix.length, value.length - suffix.length); + return { value: key.replace("*", matchedStar) }; + } } } - else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) { - return key; + else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Ending.Minimal */ && pattern === c.value; }) || + ts.some(candidates, function (c) { return c.ending === 0 /* Ending.Minimal */ && pattern === c.value && validateEnding(c); })) { + return { value: key }; } + }; + for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { + var patternText_1 = _a[_i]; + var state_12 = _loop_36(patternText_1); + if (typeof state_12 === "object") + return state_12.value; } } + function validateEnding(_a) { + var ending = _a.ending, value = _a.value; + // Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename + // is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only + // here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls), + // do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the + // `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is + // that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally + // everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.) + return ending !== 0 /* Ending.Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host); + } } var MatchingMode; (function (MatchingMode) { @@ -123657,23 +124290,23 @@ var ts; MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern"; })(MatchingMode || (MatchingMode = {})); function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { - if (mode === void 0) { mode = 0 /* Exact */; } + if (mode === void 0) { mode = 0 /* MatchingMode.Exact */; } if (typeof exports === "string") { var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined); var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined; switch (mode) { - case 0 /* Exact */: - if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) { + case 0 /* MatchingMode.Exact */: + if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* Comparison.EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* Comparison.EqualTo */)) { return { moduleFileToTry: packageName }; } break; - case 1 /* Directory */: + case 1 /* MatchingMode.Directory */: if (ts.containsPath(pathOrPattern, targetFilePath)) { var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false); return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) }; } break; - case 2 /* Pattern */: + case 2 /* MatchingMode.Pattern */: var starPos = pathOrPattern.indexOf("*"); var leadingSlice = pathOrPattern.slice(0, starPos); var trailingSlice = pathOrPattern.slice(starPos + 1); @@ -123700,9 +124333,9 @@ var ts; // * exact mappings (no *, does not end with /) return ts.forEach(ts.getOwnKeys(exports), function (k) { var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined); - var mode = ts.endsWith(k, "/") ? 1 /* Directory */ - : ts.stringContains(k, "*") ? 2 /* Pattern */ - : 0 /* Exact */; + var mode = ts.endsWith(k, "/") ? 1 /* MatchingMode.Directory */ + : ts.stringContains(k, "*") ? 2 /* MatchingMode.Pattern */ + : 0 /* MatchingMode.Exact */; return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode); }); } @@ -123744,10 +124377,10 @@ var ts; return undefined; } // Simplify the full file path to something that can be resolved by Node. + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { - var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; var moduleFileName = void 0; while (true) { @@ -123796,15 +124429,13 @@ var ts; var packageRootPath = path.substring(0, packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); var moduleFileToTry = path; + var maybeBlockedByTypesVersions = false; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); + var importMode = overrideMode || importingSourceFile.impliedNodeFormat; if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { - // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate - // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is - // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` - // with, so for now we just stick with the mode of the file. - var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"]; + var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"]; var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions) : undefined; @@ -123823,16 +124454,26 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { + var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options); + if (fromPaths === undefined) { + maybeBlockedByTypesVersions = true; + } + else { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } // If the file is the main module, it can be imported by the package name var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; - if (ts.isString(mainFileRelative)) { + if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) { + // The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path + // explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable. + // (The only way this can happen is if some file in a package that's not resolvable from outside the + // package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It + // happens very easily in fourslash tests though, since every test file listed gets included. See + // importNameCodeFix_typesVersions.ts for an example.) var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { + // ^ An arbitrary removal of file extension for this comparison is almost certainly wrong return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry }; } } @@ -123851,7 +124492,7 @@ var ts; if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }])); + var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }])); for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) { var e = extensions_3[_i]; var fullPath = path + e; @@ -123867,15 +124508,15 @@ var ts; }); } function removeExtensionAndIndexPostFix(fileName, ending, options, host) { - if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) + if (ts.fileExtensionIsOneOf(fileName, [".json" /* Extension.Json */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) return fileName; var noExtension = ts.removeFileExtension(fileName); if (fileName === noExtension) return fileName; - if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) + if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { - case 0 /* Minimal */: + case 0 /* Ending.Minimal */: var withoutIndex = ts.removeSuffix(noExtension, "/index"); if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { // Can't remove index if there's a file by the same name as the directory. @@ -123883,9 +124524,9 @@ var ts; return noExtension; } return withoutIndex; - case 1 /* Index */: + case 1 /* Ending.Index */: return noExtension; - case 2 /* JsExtension */: + case 2 /* Ending.JsExtension */: return noExtension + getJSExtensionForFile(fileName, options); default: return ts.Debug.assertNever(ending); @@ -123893,28 +124534,28 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); switch (ext) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: - return ".js" /* Js */; - case ".tsx" /* Tsx */: - return options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; - case ".js" /* Js */: - case ".jsx" /* Jsx */: - case ".json" /* Json */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: + return ".js" /* Extension.Js */; + case ".tsx" /* Extension.Tsx */: + return options.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" /* Extension.Jsx */ : ".js" /* Extension.Js */; + case ".js" /* Extension.Js */: + case ".jsx" /* Extension.Jsx */: + case ".json" /* Extension.Json */: return ext; - case ".d.mts" /* Dmts */: - case ".mts" /* Mts */: - case ".mjs" /* Mjs */: - return ".mjs" /* Mjs */; - case ".d.cts" /* Dcts */: - case ".cts" /* Cts */: - case ".cjs" /* Cjs */: - return ".cjs" /* Cjs */; + case ".d.mts" /* Extension.Dmts */: + case ".mts" /* Extension.Mts */: + case ".mjs" /* Extension.Mjs */: + return ".mjs" /* Extension.Mjs */; + case ".d.cts" /* Extension.Dcts */: + case ".cts" /* Extension.Cts */: + case ".cjs" /* Extension.Cjs */: + return ".cjs" /* Extension.Cjs */; default: return undefined; } @@ -123996,8 +124637,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -124005,8 +124646,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -124029,7 +124670,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -124062,7 +124703,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -124075,7 +124716,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -124098,7 +124739,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -124125,25 +124766,48 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; - function explainIfFileIsRedirect(file, fileNameConvertor) { + function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) { + var _a; var result; if (file.path !== file.resolvedPath) { - (result || (result = [])).push(ts.chainDiagnosticMessages( + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor))); } if (file.redirectInfo) { - (result || (result = [])).push(ts.chainDiagnosticMessages( + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor))); } + if (ts.isExternalOrCommonJsModule(file)) { + switch (file.impliedNodeFormat) { + case ts.ModuleKind.ESNext: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + break; + case ts.ModuleKind.CommonJS: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, file.packageJsonScope.packageJsonContent.type ? + ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module : + ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found)); + } + break; + } + } return result; } - ts.explainIfFileIsRedirect = explainIfFileIsRedirect; + ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat; function getMatchedFileSpec(program, fileName) { var _a; var configFile = program.getCompilerOptions().configFile; @@ -124163,14 +124827,14 @@ var ts; // Return true if its default include spec if (configFile.configFileSpecs.isDefaultIncludeSpec) return true; - var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Extension.Json */); var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames(); return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) { - if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Json */)) + if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Extension.Json */)) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -124179,7 +124843,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -124305,7 +124969,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -124353,6 +125017,7 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", + AffectingFileLocation: "File location affecting resolution", TypeRoots: "Type roots", ConfigFileOfReferencedProject: "Config file of referened project", ExtendedConfigOfReferencedProject: "Extended config file of referenced project", @@ -124413,7 +125078,6 @@ var ts; readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, - now: ts.maybeBind(host, host.now), }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -124571,7 +125235,6 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - host.now = ts.maybeBind(system, system.now); ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -124622,7 +125285,6 @@ var ts; var parsedConfigs; // Parsed commandline and watching cached for referenced projects var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation - var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files @@ -124653,7 +125315,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -124679,7 +125341,7 @@ var ts; compilerHost.getCompilationSettings = function () { return compilerOptions; }; compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect); compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); }; - compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); }; + compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); }; compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); }; compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; }; compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations; @@ -124713,6 +125375,9 @@ var ts; return host.resolveTypeReferenceDirectives.apply(host, args); }) : (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); }); + compilerHost.getModuleResolutionCache = host.resolveModuleNames ? + ts.maybeBind(host, host.getModuleResolutionCache) : + (function () { return resolutionCache.getModuleResolutionCache(); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); synchronizeProgram(); @@ -124775,12 +125440,12 @@ var ts; var program = getCurrentBuilderProgram(); if (hasChangedCompilerOptions) { newLine = updateNewLine(); - if (program && (changesAffectResolution || ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) { + if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) { resolutionCache.clear(); } } // All resolutions are invalid if user provided resolutions - var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution); + var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { @@ -124796,7 +125461,6 @@ var ts; } createNewProgram(hasInvalidatedResolution); } - changesAffectResolution = false; // reset for next sync reportFileChangeDetectedOnCreateProgram = false; if (host.afterProgramCreate && program !== builderProgram) { host.afterProgramCreate(builderProgram); @@ -124806,18 +125470,19 @@ var ts; function createNewProgram(hasInvalidatedResolution) { // Compile the program writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; resolutionCache.startCachingPerDirectoryResolution(); compilerHost.hasInvalidatedResolution = hasInvalidatedResolution; compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames; + var oldProgram = getCurrentProgram(); builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); - resolutionCache.finishCachingPerDirectoryResolution(); + resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram); // Update watches ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath); if (needsUpdateInTypeRootWatch) { @@ -124899,9 +125564,6 @@ var ts; sourceFilesCache.set(path, false); } } - if (sourceFile) { - sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings()); - } return sourceFile; } return hostSourceFile.sourceFile; @@ -124964,7 +125626,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -125025,7 +125687,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -125066,7 +125728,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -125295,7 +125957,7 @@ var ts; UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function resolveConfigFileProjectName(project) { - if (ts.fileExtensionIs(project, ".json" /* Json */)) { + if (ts.fileExtensionIs(project, ".json" /* Extension.Json */)) { return project; } return ts.combinePaths(project, "tsconfig.json"); @@ -125358,8 +126020,8 @@ var ts; */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -125417,6 +126079,7 @@ var ts; compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); + compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache); var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined; if (!compilerHost.resolveModuleNames) { @@ -125899,8 +126562,7 @@ var ts; } // Actual Emit var host = state.host, compilerHost = state.compilerHost; - var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; - var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined; + var resultFlags = ((_d = program.hasChangedEmitSignature) === null || _d === void 0 ? void 0 : _d.call(program)) ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged; var emitterDiagnostics = ts.createDiagnosticCollection(); var emittedOutputs = new ts.Map(); var options = program.getCompilerOptions(); @@ -125908,17 +126570,11 @@ var ts; var outputTimeStampMap; var now; outputFiles.forEach(function (_a) { - var _b, _c; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; var path = toPath(state, name); emittedOutputs.set(toPath(state, name), name); - if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, options); - // Buildinfo has information on when last dts change time - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo === null || existingBuildInfo === void 0 ? void 0 : existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { - resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; - } - } + if (buildInfo) + setBuildInfo(state, buildInfo, projectPath, options, resultFlags); ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); if (!isIncremental && state.watch) { (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host))); @@ -125932,7 +126588,7 @@ var ts; ts.Debug.assert(step === BuildStep.EmitBuildInfo); var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) { if (data === null || data === void 0 ? void 0 : data.buildInfo) - setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions()); + setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions(), BuildResultFlags.DeclarationOutputUnchanged); if (writeFileCallback) writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data); else @@ -125965,7 +126621,6 @@ var ts; state.diagnostics.delete(projectPath); state.projectStatus.set(projectPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath), oldestOutputFileName: oldestOutputFileName }); afterProgramDone(state, program, config); @@ -126007,10 +126662,10 @@ var ts; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; emittedOutputs.set(toPath(state, name), name); if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, config.options); - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { + if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) { resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; } + setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags); } ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); }); @@ -126171,7 +126826,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -126185,7 +126840,7 @@ var ts; } function afterProgramDone(state, program, config) { if (program) { - if (program && state.write) + if (state.write) ts.listFiles(program, state.write); if (state.host.afterProgramEmitAndDiagnostics) { state.host.afterProgramEmitAndDiagnostics(program); @@ -126201,7 +126856,7 @@ var ts; // Since buildinfo has changeset and diagnostics when doing multi file emit, only --out cannot emit buildinfo if it has errors var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -126269,15 +126924,23 @@ var ts; state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map()); return result; } - function setBuildInfo(state, buildInfo, resolvedConfigPath, options) { + function setBuildInfo(state, buildInfo, resolvedConfigPath, options, resultFlags) { var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath); + var modifiedTime = getCurrentTime(state.host); if (existing) { existing.buildInfo = buildInfo; - existing.modifiedTime = getCurrentTime(state.host); + existing.modifiedTime = modifiedTime; + if (!(resultFlags & BuildResultFlags.DeclarationOutputUnchanged)) + existing.latestChangedDtsTime = modifiedTime; } else { - state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) }); + state.buildInfoCache.set(resolvedConfigPath, { + path: toPath(state, buildInfoPath), + buildInfo: buildInfo, + modifiedTime: modifiedTime, + latestChangedDtsTime: resultFlags & BuildResultFlags.DeclarationOutputUnchanged ? undefined : modifiedTime, + }); } } function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) { @@ -126309,7 +126972,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { - var _a, _b, _c; + var _a, _b; // Container if no files are specified in the project if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) { return { @@ -126321,8 +126984,8 @@ var ts; var force = !!state.options.force; if (project.projectReferences) { state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream }); - for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) { - var ref = _d[_i]; + for (var _i = 0, _c = project.projectReferences; _i < _c.length; _i++) { + var ref = _c[_i]; var resolvedRef = ts.resolveProjectReferencePath(ref); var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef); var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath); @@ -126362,7 +127025,6 @@ var ts; var buildInfoTime; var buildInfoProgram; var buildInfoVersionMap; - var newestDeclarationFileContentChangedTime; if (buildInfoPath) { var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath); buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath); @@ -126399,8 +127061,6 @@ var ts; } oldestOutputFileTime = buildInfoTime; oldestOutputFileName = buildInfoPath; - // Get the last dtsChange time from build info - newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; } // Check input files var newestInputFileName = undefined; @@ -126408,13 +127068,13 @@ var ts; /** True if input file has changed timestamp but text is not changed, we can then do only timestamp updates on output to make it look up-to-date later */ var pseudoInputUpToDate = false; // Get timestamps of input files - for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) { - var inputFile = _f[_e]; + for (var _d = 0, _e = project.fileNames; _d < _e.length; _d++) { + var inputFile = _e[_d]; var inputTime = getModifiedTime(state, inputFile); if (inputTime === ts.missingFileModifiedTime) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } // If an buildInfo is older than the newest input, we can stop checking @@ -126450,8 +127110,8 @@ var ts; // Collect the expected outputs of this project var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath); - for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) { - var output = outputs_1[_g]; + for (var _f = 0, outputs_1 = outputs; _f < outputs_1.length; _f++) { + var output = outputs_1[_f]; var path = toPath(state, output); // Output is missing; can stop checking var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path); @@ -126489,8 +127149,8 @@ var ts; var usesPrepend = false; var upstreamChangedProject; if (referenceStatuses) { - for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) { - var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath; + for (var _g = 0, referenceStatuses_1 = referenceStatuses; _g < referenceStatuses_1.length; _g++) { + var _h = referenceStatuses_1[_g], ref = _h.ref, refStatus = _h.refStatus, resolvedConfig = _h.resolvedConfig, resolvedRefPath = _h.resolvedRefPath; usesPrepend = usesPrepend || !!(ref.prepend); // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it @@ -126507,7 +127167,8 @@ var ts; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + var newestDeclarationFileContentChangedTime = getLatestChangedDtsTime(state, resolvedConfig.options, resolvedRefPath); + if (newestDeclarationFileContentChangedTime && newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -126550,7 +127211,6 @@ var ts; pseudoInputUpToDate ? ts.UpToDateStatusType.UpToDateWithInputFileText : ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, newestInputFileTime: newestInputFileTime, newestInputFileName: newestInputFileName, oldestOutputFileName: oldestOutputFileName @@ -126634,13 +127294,17 @@ var ts; outputTimeStampMap.delete(key); }); } - function getDtsChangeTime(state, options, resolvedConfigPath) { - var _a; + function getLatestChangedDtsTime(state, options, resolvedConfigPath) { if (!options.composite) return undefined; - var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); - var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined); - return ((_a = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.program) === null || _a === void 0 ? void 0 : _a.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; + var entry = ts.Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath)); + if (entry.latestChangedDtsTime !== undefined) + return entry.latestChangedDtsTime || undefined; + var latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ? + state.host.getModifiedTime(ts.getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, ts.getDirectoryPath(entry.path))) : + undefined; + entry.latestChangedDtsTime = latestChangedDtsTime || false; + return latestChangedDtsTime; } function updateOutputTimestamps(state, proj, resolvedPath) { if (state.options.dry) { @@ -126649,7 +127313,6 @@ var ts; updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0); state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath), oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames()) }); } @@ -126785,7 +127448,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -127135,7 +127798,7 @@ var ts; function nowString() { // E.g. "12:34:56.789" var d = new Date(); - return ts.padLeft(d.getHours().toString(), 2, "0") + ":" + ts.padLeft(d.getMinutes().toString(), 2, "0") + ":" + ts.padLeft(d.getSeconds().toString(), 2, "0") + "." + ts.padLeft(d.getMilliseconds().toString(), 3, "0"); + return "".concat(ts.padLeft(d.getHours().toString(), 2, "0"), ":").concat(ts.padLeft(d.getMinutes().toString(), 2, "0"), ":").concat(ts.padLeft(d.getSeconds().toString(), 2, "0"), ".").concat(ts.padLeft(d.getMilliseconds().toString(), 3, "0")); } server.nowString = nowString; })(server = ts.server || (ts.server = {})); @@ -127146,7 +127809,7 @@ var ts; var JsTyping; (function (JsTyping) { function isTypingUpToDate(cachedTyping, availableTypingVersions) { - var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); + var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts".concat(ts.versionMajorMinor)) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; @@ -127199,7 +127862,7 @@ var ts; "worker_threads", "zlib" ]; - JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:" + name; }); + JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:".concat(name); }); JsTyping.nodeCoreModuleList = __spreadArray(__spreadArray([], unprefixedNodeCoreModuleList, true), JsTyping.prefixedNodeCoreModuleList, true); JsTyping.nodeCoreModules = new ts.Set(JsTyping.nodeCoreModuleList); function nonRelativeModuleNameForTypingCache(moduleName) { @@ -127274,7 +127937,7 @@ var ts; var excludeTypingName = exclude_1[_i]; var didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) - log("Typing for " + excludeTypingName + " is in exclude list, will be ignored."); + log("Typing for ".concat(excludeTypingName, " is in exclude list, will be ignored.")); } var newTypingNames = []; var cachedTypingPaths = []; @@ -127288,7 +127951,7 @@ var ts; }); var result = { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; if (log) - log("Result: " + JSON.stringify(result)); + log("Result: ".concat(JSON.stringify(result))); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { @@ -127297,7 +127960,7 @@ var ts; } function addInferredTypings(typingNames, message) { if (log) - log(message + ": " + JSON.stringify(typingNames)); + log("".concat(message, ": ").concat(JSON.stringify(typingNames))); ts.forEach(typingNames, addInferredTyping); } /** @@ -127319,7 +127982,7 @@ var ts; filesToWatch.push(manifestPath); manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config; manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys); - addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies"); + addInferredTypings(manifestTypingNames, "Typing names in '".concat(manifestPath, "' dependencies")); } // Now we scan the directories for typing information in // already-installed dependencies (if present). Note that this @@ -127347,7 +128010,7 @@ var ts; // This is #1 described above. ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); }) // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json` - : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) + : host.readDirectory(packagesFolderPath, [".json" /* Extension.Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) .filter(function (manifestPath) { if (ts.getBaseFileName(manifestPath) !== manifestName) { return false; @@ -127363,7 +128026,7 @@ var ts; !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo` }); if (log) - log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames)); + log("Searching for typing names in ".concat(packagesFolderPath, "; all files: ").concat(JSON.stringify(dependencyManifestNames))); // Once we have the names of things to look up, we iterate over // and either collect their included typings, or add them to the // list of typings we need to look up separately. @@ -127382,12 +128045,12 @@ var ts; var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName)); if (host.fileExists(absolutePath)) { if (log) - log(" Package '" + manifest_1.name + "' provides its own types."); + log(" Package '".concat(manifest_1.name, "' provides its own types.")); inferredTypings.set(manifest_1.name, absolutePath); } else { if (log) - log(" Package '" + manifest_1.name + "' provides its own types but they are missing."); + log(" Package '".concat(manifest_1.name, "' provides its own types but they are missing.")); } } else { @@ -127413,7 +128076,7 @@ var ts; if (fromFileNames.length) { addInferredTypings(fromFileNames, "Inferred typings from file names"); } - var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); }); + var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Extension.Jsx */); }); if (hasJsxFile) { if (log) log("Inferred 'react' typings due to presence of '.jsx' extension"); @@ -127441,16 +128104,16 @@ var ts; JsTyping.validatePackageName = validatePackageName; function validatePackageNameWorker(packageName, supportScopedPackage) { if (!packageName) { - return 1 /* EmptyName */; + return 1 /* NameValidationResult.EmptyName */; } if (packageName.length > maxPackageNameLength) { - return 2 /* NameTooLong */; + return 2 /* NameValidationResult.NameTooLong */; } - if (packageName.charCodeAt(0) === 46 /* dot */) { - return 3 /* NameStartsWithDot */; + if (packageName.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + return 3 /* NameValidationResult.NameStartsWithDot */; } - if (packageName.charCodeAt(0) === 95 /* _ */) { - return 4 /* NameStartsWithUnderscore */; + if (packageName.charCodeAt(0) === 95 /* CharacterCodes._ */) { + return 4 /* NameValidationResult.NameStartsWithUnderscore */; } // check if name is scope package like: starts with @ and has one '/' in the middle // scoped packages are not currently supported @@ -127458,20 +128121,20 @@ var ts; var matches = /^@([^/]+)\/([^/]+)$/.exec(packageName); if (matches) { var scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false); - if (scopeResult !== 0 /* Ok */) { + if (scopeResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[1], isScopeName: true, result: scopeResult }; } var packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false); - if (packageResult !== 0 /* Ok */) { + if (packageResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[2], isScopeName: false, result: packageResult }; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } } if (encodeURIComponent(packageName) !== packageName) { - return 5 /* NameContainsNonURISafeCharacters */; + return 5 /* NameValidationResult.NameContainsNonURISafeCharacters */; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } function renderPackageNameValidationFailure(result, typing) { return typeof result === "object" ? @@ -127482,17 +128145,17 @@ var ts; function renderPackageNameValidationFailureWorker(typing, result, name, isScopeName) { var kind = isScopeName ? "Scope" : "Package"; switch (result) { - case 1 /* EmptyName */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot be empty"; - case 2 /* NameTooLong */: - return "'" + typing + "':: " + kind + " name '" + name + "' should be less than " + maxPackageNameLength + " characters"; - case 3 /* NameStartsWithDot */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '.'"; - case 4 /* NameStartsWithUnderscore */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '_'"; - case 5 /* NameContainsNonURISafeCharacters */: - return "'" + typing + "':: " + kind + " name '" + name + "' contains non URI safe characters"; - case 0 /* Ok */: + case 1 /* NameValidationResult.EmptyName */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot be empty"); + case 2 /* NameValidationResult.NameTooLong */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' should be less than ").concat(maxPackageNameLength, " characters"); + case 3 /* NameValidationResult.NameStartsWithDot */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '.'"); + case 4 /* NameValidationResult.NameStartsWithUnderscore */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '_'"); + case 5 /* NameValidationResult.NameContainsNonURISafeCharacters */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' contains non URI safe characters"); + case 0 /* NameValidationResult.Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: throw ts.Debug.assertNever(result); @@ -127864,7 +128527,7 @@ var ts; (function (ts) { // These utilities are common to multiple language service features. //#region - ts.scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); var SemanticMeaning; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -127875,66 +128538,66 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 292 /* CatchClause */: - case 285 /* JsxAttribute */: - return 1 /* Value */; - case 163 /* TypeParameter */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 182 /* TypeLiteral */: - return 2 /* Type */; - case 345 /* JSDocTypedefTag */: + case 254 /* SyntaxKind.VariableDeclaration */: + return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* SemanticMeaning.All */ : 1 /* SemanticMeaning.Value */; + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 292 /* SyntaxKind.CatchClause */: + case 285 /* SyntaxKind.JsxAttribute */: + return 1 /* SemanticMeaning.Value */; + case 163 /* SyntaxKind.TypeParameter */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + return 2 /* SemanticMeaning.Type */; + case 345 /* SyntaxKind.JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. - return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 299 /* EnumMember */: - case 257 /* ClassDeclaration */: - return 1 /* Value */ | 2 /* Type */; - case 261 /* ModuleDeclaration */: + return node.name === undefined ? 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */ : 2 /* SemanticMeaning.Type */; + case 299 /* SyntaxKind.EnumMember */: + case 257 /* SyntaxKind.ClassDeclaration */: + return 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */; + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isAmbientModule(node)) { - return 4 /* Namespace */ | 1 /* Value */; + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { - return 4 /* Namespace */ | 1 /* Value */; + else if (ts.getModuleInstanceState(node) === 1 /* ModuleInstanceState.Instantiated */) { + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } else { - return 4 /* Namespace */; - } - case 260 /* EnumDeclaration */: - case 269 /* NamedImports */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: - return 7 /* All */; + return 4 /* SemanticMeaning.Namespace */; + } + case 260 /* SyntaxKind.EnumDeclaration */: + case 269 /* SyntaxKind.NamedImports */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: + return 7 /* SemanticMeaning.All */; // An external module can be a Value - case 305 /* SourceFile */: - return 4 /* Namespace */ | 1 /* Value */; + case 305 /* SyntaxKind.SourceFile */: + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); var parent = node.parent; - if (node.kind === 305 /* SourceFile */) { - return 1 /* Value */; + if (node.kind === 305 /* SyntaxKind.SourceFile */) { + return 1 /* SemanticMeaning.Value */; } else if (ts.isExportAssignment(parent) || ts.isExportSpecifier(parent) @@ -127942,7 +128605,7 @@ var ts; || ts.isImportSpecifier(parent) || ts.isImportClause(parent) || ts.isImportEqualsDeclaration(parent) && node === parent.name) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { return getMeaningFromRightHandSideOfImportEquals(node); @@ -127951,24 +128614,24 @@ var ts; return getMeaningFromDeclaration(parent); } else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isTypeReference(node)) { - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (isNamespaceReference(node)) { - return 4 /* Namespace */; + return 4 /* SemanticMeaning.Namespace */; } else if (ts.isTypeParameterDeclaration(parent)) { ts.Debug.assert(ts.isJSDocTemplateTag(parent.parent)); // Else would be handled by isDeclarationName - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (ts.isLiteralTypeNode(parent)) { // This might be T["name"], which is actually referencing a property and not a type. So allow both meanings. - return 2 /* Type */ | 1 /* Value */; + return 2 /* SemanticMeaning.Type */ | 1 /* SemanticMeaning.Value */; } else { - return 1 /* Value */; + return 1 /* SemanticMeaning.Value */; } } ts.getMeaningFromLocation = getMeaningFromLocation; @@ -127976,11 +128639,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 161 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 265 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 161 /* SyntaxKind.QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? 7 /* SemanticMeaning.All */ : 4 /* SemanticMeaning.Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -127992,27 +128655,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 161 /* QualifiedName */) { - while (root.parent && root.parent.kind === 161 /* QualifiedName */) { + if (root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + while (root.parent && root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 178 /* TypeReference */ && !isLastClause; + return root.parent.kind === 178 /* SyntaxKind.TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 206 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 206 /* PropertyAccessExpression */) { + if (root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 228 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 257 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || - (decl.kind === 258 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); + return (decl.kind === 257 /* SyntaxKind.ClassDeclaration */ && root.parent.parent.token === 117 /* SyntaxKind.ImplementsKeyword */) || + (decl.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && root.parent.parent.token === 94 /* SyntaxKind.ExtendsKeyword */); } return false; } @@ -128021,17 +128684,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return !ts.isExpressionNode(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return true; } switch (node.parent.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return true; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return !node.parent.isTypeOf; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isPartOfTypeNode(node.parent); } return false; @@ -128098,7 +128761,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 250 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 250 /* SyntaxKind.LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -128159,22 +128822,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 261 /* ModuleDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.parent.argumentExpression === node; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return true; - case 196 /* LiteralType */: - return node.parent.parent.kind === 194 /* IndexedAccessType */; + case 196 /* SyntaxKind.LiteralType */: + return node.parent.parent.kind === 194 /* SyntaxKind.IndexedAccessType */; default: return false; } @@ -128198,17 +128861,17 @@ var ts; return undefined; } switch (node.kind) { - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return node; } } @@ -128216,108 +128879,108 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 305 /* SourceFile */: - return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 261 /* ModuleDeclaration */: - return "module" /* moduleElement */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return "class" /* classElement */; - case 258 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 259 /* TypeAliasDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - return "type" /* typeElement */; - case 260 /* EnumDeclaration */: return "enum" /* enumElement */; - case 254 /* VariableDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + return ts.isExternalModule(node) ? "module" /* ScriptElementKind.moduleElement */ : "script" /* ScriptElementKind.scriptElement */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return "module" /* ScriptElementKind.moduleElement */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return "class" /* ScriptElementKind.classElement */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return "interface" /* ScriptElementKind.interfaceElement */; + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + return "type" /* ScriptElementKind.typeElement */; + case 260 /* SyntaxKind.EnumDeclaration */: return "enum" /* ScriptElementKind.enumElement */; + case 254 /* SyntaxKind.VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - return "function" /* functionElement */; - case 172 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 173 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - return "method" /* memberFunctionElement */; - case 296 /* PropertyAssignment */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + return "function" /* ScriptElementKind.functionElement */; + case 172 /* SyntaxKind.GetAccessor */: return "getter" /* ScriptElementKind.memberGetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: return "setter" /* ScriptElementKind.memberSetAccessorElement */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + return "method" /* ScriptElementKind.memberFunctionElement */; + case 296 /* SyntaxKind.PropertyAssignment */: var initializer = node.initializer; - return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: - return "property" /* memberVariableElement */; - case 176 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 175 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 174 /* CallSignature */: return "call" /* callSignatureElement */; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: - return "constructor" /* constructorImplementationElement */; - case 163 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 299 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 164 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - return "alias" /* alias */; - case 221 /* BinaryExpression */: + return ts.isFunctionLike(initializer) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: + return "property" /* ScriptElementKind.memberVariableElement */; + case 176 /* SyntaxKind.IndexSignature */: return "index" /* ScriptElementKind.indexSignatureElement */; + case 175 /* SyntaxKind.ConstructSignature */: return "construct" /* ScriptElementKind.constructSignatureElement */; + case 174 /* SyntaxKind.CallSignature */: return "call" /* ScriptElementKind.callSignatureElement */; + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + case 163 /* SyntaxKind.TypeParameter */: return "type parameter" /* ScriptElementKind.typeParameterElement */; + case 299 /* SyntaxKind.EnumMember */: return "enum member" /* ScriptElementKind.enumMemberElement */; + case 164 /* SyntaxKind.Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) ? "property" /* ScriptElementKind.memberVariableElement */ : "parameter" /* ScriptElementKind.parameterElement */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + return "alias" /* ScriptElementKind.alias */; + case 221 /* SyntaxKind.BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: - case 0 /* None */: - return "" /* unknown */; - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: + case 0 /* AssignmentDeclarationKind.None */: + return "" /* ScriptElementKind.unknown */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: var rightKind = getNodeKind(right); - return rightKind === "" /* unknown */ ? "const" /* constElement */ : rightKind; - case 3 /* PrototypeProperty */: - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 4 /* ThisProperty */: - return "property" /* memberVariableElement */; // property - case 5 /* Property */: + return rightKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : rightKind; + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 4 /* AssignmentDeclarationKind.ThisProperty */: + return "property" /* ScriptElementKind.memberVariableElement */; // property + case 5 /* AssignmentDeclarationKind.Property */: // static method / property - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 6 /* Prototype */: - return "local class" /* localClassElement */; + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 6 /* AssignmentDeclarationKind.Prototype */: + return "local class" /* ScriptElementKind.localClassElement */; default: { ts.assertType(kind); - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } } - case 79 /* Identifier */: - return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 271 /* ExportAssignment */: + case 79 /* SyntaxKind.Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* ScriptElementKind.alias */ : "" /* ScriptElementKind.unknown */; + case 271 /* SyntaxKind.ExportAssignment */: var scriptKind = getNodeKind(node.expression); // If the expression didn't come back with something (like it does for an identifiers) - return scriptKind === "" /* unknown */ ? "const" /* constElement */ : scriptKind; + return scriptKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : scriptKind; default: - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ + ? "const" /* ScriptElementKind.constElement */ : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "let" /* ScriptElementKind.letElement */ + : "var" /* ScriptElementKind.variableElement */; } } ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* SyntaxKind.Parameter */; default: return false; } @@ -128382,42 +129045,42 @@ var ts; return false; } switch (n.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 201 /* ObjectBindingPattern */: - case 182 /* TypeLiteral */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 263 /* CaseBlock */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: - return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 292 /* CatchClause */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 182 /* SyntaxKind.TypeLiteral */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 263 /* SyntaxKind.CaseBlock */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: + return nodeEndsWith(n, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + case 292 /* SyntaxKind.CatchClause */: return isCompletedNode(n.block, sourceFile); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: if (!n.arguments) { return true; } // falls through - case 208 /* CallExpression */: - case 212 /* ParenthesizedExpression */: - case 191 /* ParenthesizedType */: - return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 208 /* SyntaxKind.CallExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + return nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -128426,66 +129089,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 261 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 261 /* SyntaxKind.ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 204 /* ArrayLiteralExpression */: - case 202 /* ArrayBindingPattern */: - case 207 /* ElementAccessExpression */: - case 162 /* ComputedPropertyName */: - case 184 /* TupleType */: - return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 176 /* IndexSignature */: + hasChildOfKind(n, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 184 /* SyntaxKind.TupleType */: + return nodeEndsWith(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 176 /* SyntaxKind.IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + return hasChildOfKind(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 115 /* SyntaxKind.WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 216 /* TypeOfExpression */: - case 215 /* DeleteExpression */: - case 217 /* VoidExpression */: - case 224 /* YieldExpression */: - case 225 /* SpreadElement */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 225 /* SyntaxKind.SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -128502,7 +129165,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SyntaxKind.SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -128545,13 +129208,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 84 /* ClassKeyword */; + return node.kind === 84 /* SyntaxKind.ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 98 /* FunctionKeyword */; + return node.kind === 98 /* SyntaxKind.FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -128610,13 +129273,13 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return getAdjustedLocationForClass(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return getAdjustedLocationForFunction(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return node; } } @@ -128706,30 +129369,30 @@ var ts; // // NOTE: If the node is a modifier, we don't adjust its location if it is the `default` modifier as that is handled // specially by `getSymbolAtLocation`. - if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? ts.canHaveModifiers(parent) && ts.contains(parent.modifiers, node) : - node.kind === 84 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 98 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 118 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 92 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 152 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 142 /* NamespaceKeyword */ || node.kind === 141 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 136 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 149 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* SyntaxKind.DefaultKeyword */) ? ts.canHaveModifiers(parent) && ts.contains(parent.modifiers, node) : + node.kind === 84 /* SyntaxKind.ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : + node.kind === 98 /* SyntaxKind.FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : + node.kind === 118 /* SyntaxKind.InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : + node.kind === 92 /* SyntaxKind.EnumKeyword */ ? ts.isEnumDeclaration(parent) : + node.kind === 152 /* SyntaxKind.TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 142 /* SyntaxKind.NamespaceKeyword */ || node.kind === 141 /* SyntaxKind.ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 136 /* SyntaxKind.GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 149 /* SyntaxKind.SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && + if ((node.kind === 113 /* SyntaxKind.VarKeyword */ || node.kind === 85 /* SyntaxKind.ConstKeyword */ || node.kind === 119 /* SyntaxKind.LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 152 /* TypeKeyword */) { + if (node.kind === 152 /* SyntaxKind.TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -128755,7 +129418,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 127 /* AsKeyword */) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -128771,13 +129434,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* SyntaxKind.ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 93 /* ExportKeyword */) { + if (node.kind === 93 /* SyntaxKind.ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -128796,12 +129459,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 146 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 146 /* SyntaxKind.RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 156 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 156 /* SyntaxKind.FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -128809,13 +129472,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* SyntaxKind.ExtendsKeyword */ || node.kind === 117 /* SyntaxKind.ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 94 /* ExtendsKeyword */) { + if (node.kind === 94 /* SyntaxKind.ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -128826,20 +129489,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 137 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 137 /* SyntaxKind.InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 140 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* KeyOfKeyword */ && + if (node.kind === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 145 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* ReadonlyKeyword */ && + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -128854,29 +129517,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 132 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* SyntaxKind.NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* SyntaxKind.TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 132 /* SyntaxKind.AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* SyntaxKind.YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* SyntaxKind.DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* SyntaxKind.InKeyword */ || node.kind === 102 /* SyntaxKind.InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 160 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isForInStatement(parent) || + node.kind === 160 /* SyntaxKind.OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -128945,25 +129608,31 @@ var ts; // flag causes us to return the first node whose end position matches the position and which produces and acceptable token // kind. Meanwhile, if includePrecedingTokenAtEndPosition is unset, we look for the first node whose start is <= the // position and whose end is greater than the position. + // There are more sophisticated end tests later, but this one is very fast + // and allows us to skip a bunch of work + var end = children[middle].getEnd(); + if (end < position) { + return -1 /* Comparison.LessThan */; + } var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } // first element whose start position is before the input and whose end position is after or equal to the input - if (nodeContainsPosition(children[middle])) { + if (nodeContainsPosition(children[middle], start, end)) { if (children[middle - 1]) { // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position if (nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // this complex condition makes us left-recur around a zero-length node when includePrecedingTokenAtEndPosition is set, rather than right-recur on it if (includePrecedingTokenAtEndPosition && start === position && children[middle - 1] && children[middle - 1].getEnd() === position && nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (foundToken) { return { value: foundToken }; @@ -128982,14 +129651,17 @@ var ts; case "continue-outer": continue outer; } } - function nodeContainsPosition(node) { - var start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true); + function nodeContainsPosition(node, start, end) { + end !== null && end !== void 0 ? end : (end = node.getEnd()); + if (end < position) { + return false; + } + start !== null && start !== void 0 ? start : (start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true)); if (start > position) { // If this child begins after position, then all subsequent children will as well. return false; } - var end = node.getEnd(); - if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) { + if (position < end || (position === end && (node.kind === 1 /* SyntaxKind.EndOfFileToken */ || includeEndPosition))) { return true; } else if (includePrecedingTokenAtEndPosition && end === position) { @@ -129058,7 +129730,7 @@ var ts; ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; function find(n) { - if (isNonWhitespaceToken(n) && n.kind !== 1 /* EndOfFileToken */) { + if (isNonWhitespaceToken(n) && n.kind !== 1 /* SyntaxKind.EndOfFileToken */) { return n; } var children = n.getChildren(sourceFile); @@ -129070,11 +129742,11 @@ var ts; if (position < children[middle].end) { // first element whose end position is greater than the input position if (!children[middle - 1] || position >= children[middle - 1].end) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (i >= 0 && children[i]) { var child = children[i]; @@ -129099,7 +129771,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SyntaxKind.SourceFile */ || n.kind === 1 /* SyntaxKind.EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -129130,7 +129802,7 @@ var ts; for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 279 /* JsxSelfClosingElement */)) { + if (i === 0 && (parentKind === 11 /* SyntaxKind.JsxText */ || parentKind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); } } @@ -129166,25 +129838,25 @@ var ts; if (!token) { return false; } - if (token.kind === 11 /* JsxText */) { + if (token.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
Hello |
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 281 /* JsxClosingElement */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return true; } return false; @@ -129203,10 +129875,10 @@ var ts; if (ts.isJsxText(token)) { return true; } - if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -129215,17 +129887,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 279 /* JsxSelfClosingElement */ && node.kind <= 288 /* JsxExpression */ - || node.kind === 11 /* JsxText */ - || node.kind === 29 /* LessThanToken */ - || node.kind === 31 /* GreaterThanToken */ - || node.kind === 79 /* Identifier */ - || node.kind === 19 /* CloseBraceToken */ - || node.kind === 18 /* OpenBraceToken */ - || node.kind === 43 /* SlashToken */) { + if (node.kind >= 279 /* SyntaxKind.JsxSelfClosingElement */ && node.kind <= 288 /* SyntaxKind.JsxExpression */ + || node.kind === 11 /* SyntaxKind.JsxText */ + || node.kind === 29 /* SyntaxKind.LessThanToken */ + || node.kind === 31 /* SyntaxKind.GreaterThanToken */ + || node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 19 /* SyntaxKind.CloseBraceToken */ + || node.kind === 18 /* SyntaxKind.OpenBraceToken */ + || node.kind === 43 /* SyntaxKind.SlashToken */) { node = node.parent; } - else if (node.kind === 278 /* JsxElement */) { + else if (node.kind === 278 /* SyntaxKind.JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -129315,10 +129987,10 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); - if (token && token.kind === 28 /* QuestionDotToken */) { + if (token && token.kind === 28 /* SyntaxKind.QuestionDotToken */) { token = findPrecedingToken(token.getFullStart(), sourceFile); } if (!token || !ts.isIdentifier(token)) @@ -129328,56 +130000,56 @@ var ts; } remainingLessThanTokens--; break; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 48 /* GreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: remainingLessThanTokens++; break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* SyntaxKind.OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: nTypeArguments++; break; - case 38 /* EqualsGreaterThanToken */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: // falls through - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: // falls through - case 112 /* TypeOfKeyword */: - case 94 /* ExtendsKeyword */: - case 140 /* KeyOfKeyword */: - case 24 /* DotToken */: - case 51 /* BarToken */: - case 57 /* QuestionToken */: - case 58 /* ColonToken */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 94 /* SyntaxKind.ExtendsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 24 /* SyntaxKind.DotToken */: + case 51 /* SyntaxKind.BarToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 58 /* SyntaxKind.ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -129409,52 +130081,52 @@ var ts; function nodeHasTokens(n, sourceFile) { // If we have a token or node that has a non-zero width, it must have tokens. // Note: getWidth() does not take trivia into account. - return n.kind === 1 /* EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; + return n.kind === 1 /* SyntaxKind.EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node, excludeFlags) { - if (excludeFlags === void 0) { excludeFlags = 0 /* None */; } + if (excludeFlags === void 0) { excludeFlags = 0 /* ModifierFlags.None */; } var result = []; var flags = ts.isDeclaration(node) ? ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(node) & ~excludeFlags - : 0 /* None */; - if (flags & 8 /* Private */) - result.push("private" /* privateMemberModifier */); - if (flags & 16 /* Protected */) - result.push("protected" /* protectedMemberModifier */); - if (flags & 4 /* Public */) - result.push("public" /* publicMemberModifier */); - if (flags & 32 /* Static */ || ts.isClassStaticBlockDeclaration(node)) - result.push("static" /* staticModifier */); - if (flags & 128 /* Abstract */) - result.push("abstract" /* abstractModifier */); - if (flags & 1 /* Export */) - result.push("export" /* exportedModifier */); - if (flags & 8192 /* Deprecated */) - result.push("deprecated" /* deprecatedModifier */); - if (node.flags & 16777216 /* Ambient */) - result.push("declare" /* ambientModifier */); - if (node.kind === 271 /* ExportAssignment */) - result.push("export" /* exportedModifier */); - return result.length > 0 ? result.join(",") : "" /* none */; + : 0 /* ModifierFlags.None */; + if (flags & 8 /* ModifierFlags.Private */) + result.push("private" /* ScriptElementKindModifier.privateMemberModifier */); + if (flags & 16 /* ModifierFlags.Protected */) + result.push("protected" /* ScriptElementKindModifier.protectedMemberModifier */); + if (flags & 4 /* ModifierFlags.Public */) + result.push("public" /* ScriptElementKindModifier.publicMemberModifier */); + if (flags & 32 /* ModifierFlags.Static */ || ts.isClassStaticBlockDeclaration(node)) + result.push("static" /* ScriptElementKindModifier.staticModifier */); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push("abstract" /* ScriptElementKindModifier.abstractModifier */); + if (flags & 1 /* ModifierFlags.Export */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + if (flags & 8192 /* ModifierFlags.Deprecated */) + result.push("deprecated" /* ScriptElementKindModifier.deprecatedModifier */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) + result.push("declare" /* ScriptElementKindModifier.ambientModifier */); + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + return result.length > 0 ? result.join(",") : "" /* ScriptElementKindModifier.none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 178 /* TypeReference */ || node.kind === 208 /* CallExpression */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 208 /* SyntaxKind.CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 257 /* ClassDeclaration */ || node.kind === 258 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isComment(kind) { - return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; + return kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || kind === 3 /* SyntaxKind.MultiLineCommentTrivia */; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 10 /* StringLiteral */ - || kind === 13 /* RegularExpressionLiteral */ + if (kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 13 /* SyntaxKind.RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -129462,7 +130134,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; + return 18 /* SyntaxKind.FirstPunctuation */ <= kind && kind <= 78 /* SyntaxKind.LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -129472,9 +130144,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: return true; } return false; @@ -129487,18 +130159,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 204 /* ArrayLiteralExpression */ || - node.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || + node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 221 /* BinaryExpression */ && + if (node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 63 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 244 /* ForOfStatement */ && + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -129506,7 +130178,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -129529,8 +130201,8 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTextSpanFromStringLiteralLikeContent(contextToken); default: return createTextSpanFromNode(contextToken); @@ -129568,32 +130240,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 130 /* AnyKeyword */, - 128 /* AssertsKeyword */, - 158 /* BigIntKeyword */, - 133 /* BooleanKeyword */, - 95 /* FalseKeyword */, - 137 /* InferKeyword */, - 140 /* KeyOfKeyword */, - 143 /* NeverKeyword */, - 104 /* NullKeyword */, - 147 /* NumberKeyword */, - 148 /* ObjectKeyword */, - 145 /* ReadonlyKeyword */, - 150 /* StringKeyword */, - 151 /* SymbolKeyword */, - 110 /* TrueKeyword */, - 114 /* VoidKeyword */, - 153 /* UndefinedKeyword */, - 154 /* UniqueKeyword */, - 155 /* UnknownKeyword */, + 130 /* SyntaxKind.AnyKeyword */, + 128 /* SyntaxKind.AssertsKeyword */, + 158 /* SyntaxKind.BigIntKeyword */, + 133 /* SyntaxKind.BooleanKeyword */, + 95 /* SyntaxKind.FalseKeyword */, + 137 /* SyntaxKind.InferKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 143 /* SyntaxKind.NeverKeyword */, + 104 /* SyntaxKind.NullKeyword */, + 147 /* SyntaxKind.NumberKeyword */, + 148 /* SyntaxKind.ObjectKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 150 /* SyntaxKind.StringKeyword */, + 151 /* SyntaxKind.SymbolKeyword */, + 110 /* SyntaxKind.TrueKeyword */, + 114 /* SyntaxKind.VoidKeyword */, + 153 /* SyntaxKind.UndefinedKeyword */, + 154 /* SyntaxKind.UniqueKeyword */, + 155 /* SyntaxKind.UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 152 /* TypeKeyword */; + return node.kind === 152 /* SyntaxKind.TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; function isTypeKeywordTokenOrIdentifier(node) { @@ -129602,7 +130274,7 @@ var ts; ts.isTypeKeywordTokenOrIdentifier = isTypeKeywordTokenOrIdentifier; /** True if the symbol is for an external module, as opposed to a namespace. */ function isExternalModuleSymbol(moduleSymbol) { - return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */; + return !!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isExternalModuleSymbol = isExternalModuleSymbol; function nodeSeenTracker() { @@ -129630,7 +130302,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 162 /* ComputedPropertyName */ + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name); @@ -129645,7 +130317,7 @@ var ts; } ts.programContainsEsModules = programContainsEsModules; function compilerOptionsIndicateEsModules(compilerOptions) { - return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit; + return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ || !!compilerOptions.noEmit; } ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules; function createModuleSpecifierResolutionHost(program, host) { @@ -129693,7 +130365,7 @@ var ts; } ts.makeImport = makeImport; function makeStringLiteral(text, quotePreference) { - return ts.factory.createStringLiteral(text, quotePreference === 0 /* Single */); + return ts.factory.createStringLiteral(text, quotePreference === 0 /* QuotePreference.Single */); } ts.makeStringLiteral = makeStringLiteral; var QuotePreference; @@ -129702,25 +130374,25 @@ var ts; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); function quotePreferenceFromString(str, sourceFile) { - return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* QuotePreference.Double */ : 0 /* QuotePreference.Single */; } ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference && preferences.quotePreference !== "auto") { - return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; + return preferences.quotePreference === "single" ? 0 /* QuotePreference.Single */ : 1 /* QuotePreference.Double */; } else { // ignore synthetic import added when importHelpers: true var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, function (n) { return ts.isStringLiteral(n) && !ts.nodeIsSynthesized(n.parent); }); - return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* QuotePreference.Double */; } } ts.getQuotePreference = getQuotePreference; function getQuoteFromPreference(qp) { switch (qp) { - case 0 /* Single */: return "'"; - case 1 /* Double */: return '"'; + case 0 /* QuotePreference.Single */: return "'"; + case 1 /* QuotePreference.Double */: return '"'; default: return ts.Debug.assertNever(qp); } } @@ -129731,12 +130403,12 @@ var ts; } ts.symbolNameNoDefault = symbolNameNoDefault; function symbolEscapedNameNoDefault(symbol) { - if (symbol.escapedName !== "default" /* Default */) { + if (symbol.escapedName !== "default" /* InternalSymbolName.Default */) { return symbol.escapedName; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* SyntaxKind.Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -129780,7 +130452,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 237 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 237 /* SyntaxKind.VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate); var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports]; if (!existingImportStatements.length) { @@ -129993,34 +130665,34 @@ var ts; return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } - if (flags & 4 /* Property */) + if (flags & 4 /* SymbolFlags.Property */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 32768 /* GetAccessor */) + if (flags & 32768 /* SymbolFlags.GetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 65536 /* SetAccessor */) + if (flags & 65536 /* SymbolFlags.SetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 8 /* EnumMember */) + if (flags & 8 /* SymbolFlags.EnumMember */) return ts.SymbolDisplayPartKind.enumMemberName; - if (flags & 16 /* Function */) + if (flags & 16 /* SymbolFlags.Function */) return ts.SymbolDisplayPartKind.functionName; - if (flags & 32 /* Class */) + if (flags & 32 /* SymbolFlags.Class */) return ts.SymbolDisplayPartKind.className; - if (flags & 64 /* Interface */) + if (flags & 64 /* SymbolFlags.Interface */) return ts.SymbolDisplayPartKind.interfaceName; - if (flags & 384 /* Enum */) + if (flags & 384 /* SymbolFlags.Enum */) return ts.SymbolDisplayPartKind.enumName; - if (flags & 1536 /* Module */) + if (flags & 1536 /* SymbolFlags.Module */) return ts.SymbolDisplayPartKind.moduleName; - if (flags & 8192 /* Method */) + if (flags & 8192 /* SymbolFlags.Method */) return ts.SymbolDisplayPartKind.methodName; - if (flags & 262144 /* TypeParameter */) + if (flags & 262144 /* SymbolFlags.TypeParameter */) return ts.SymbolDisplayPartKind.typeParameterName; - if (flags & 524288 /* TypeAlias */) + if (flags & 524288 /* SymbolFlags.TypeAlias */) return ts.SymbolDisplayPartKind.aliasName; - if (flags & 2097152 /* Alias */) + if (flags & 2097152 /* SymbolFlags.Alias */) return ts.SymbolDisplayPartKind.aliasName; return ts.SymbolDisplayPartKind.text; } @@ -130097,7 +130769,7 @@ var ts; var prefix = ts.isJSDocLink(link) ? "link" : ts.isJSDocLinkCode(link) ? "linkcode" : "linkplain"; - var parts = [linkPart("{@" + prefix + " ")]; + var parts = [linkPart("{@".concat(prefix, " "))]; if (!link.name) { if (link.text) { parts.push(linkTextPart(link.text)); @@ -130124,8 +130796,8 @@ var ts; ts.buildLinkParts = buildLinkParts; function skipSeparatorFromLinkText(text) { var pos = 0; - if (text.charCodeAt(pos++) === 124 /* bar */) { - while (pos < text.length && text.charCodeAt(pos) === 32 /* space */) + if (text.charCodeAt(pos++) === 124 /* CharacterCodes.bar */) { + while (pos < text.length && text.charCodeAt(pos) === 32 /* CharacterCodes.space */) pos++; return text.slice(pos); } @@ -130175,22 +130847,22 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* SymbolFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer); + typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } - flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + flags |= 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */ | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */ | 8192 /* TypeFormatFlags.OmitParameterModifiers */; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer); }); @@ -130200,7 +130872,7 @@ var ts; var file = enclosingDeclaration.getSourceFile(); return mapToDisplayParts(function (writer) { var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - printer.writeNode(4 /* Unspecified */, node, file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, node, file, writer); }); } ts.nodeToDisplayParts = nodeToDisplayParts; @@ -130228,10 +130900,10 @@ var ts; } ts.getSymbolTarget = getSymbolTarget; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } function isAliasSymbol(symbol) { - return (symbol.flags & 2097152 /* Alias */) !== 0; + return (symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0; } function getUniqueSymbolId(symbol, checker) { return ts.getSymbolId(ts.skipAlias(symbol, checker)); @@ -130320,14 +130992,14 @@ var ts; * Sets EmitFlags to suppress leading trivia on the node. */ function suppressLeadingTrivia(node) { - addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); + addEmitFlagsRecursively(node, 512 /* EmitFlags.NoLeadingComments */, getFirstChild); } ts.suppressLeadingTrivia = suppressLeadingTrivia; /** * Sets EmitFlags to suppress trailing trivia on the node. */ function suppressTrailingTrivia(node) { - addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); + addEmitFlagsRecursively(node, 1024 /* EmitFlags.NoTrailingComments */, ts.getLastChild); } ts.suppressTrailingTrivia = suppressTrailingTrivia; function copyComments(sourceNode, targetNode) { @@ -130346,7 +131018,7 @@ var ts; var start = node.getFullStart(); var end = node.getStart(); for (var i = start; i < end; i++) { - if (text.charCodeAt(i) === 10 /* lineFeed */) + if (text.charCodeAt(i) === 10 /* CharacterCodes.lineFeed */) return true; } return false; @@ -130363,7 +131035,7 @@ var ts; function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { - nameText = baseName + "_" + i; + nameText = "".concat(baseName, "_").concat(i); } return nameText; } @@ -130382,7 +131054,7 @@ var ts; for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { var change = textChanges_1[_b]; var span = change.span, newText = change.newText; - var index = indexInTextChange(newText, name); + var index = indexInTextChange(newText, ts.escapeString(name)); if (index !== -1) { lastPos = span.start + delta + index; // If the reference comes first, return immediately. @@ -130420,7 +131092,7 @@ var ts; ts.copyTrailingAsLeadingComments = copyTrailingAsLeadingComments; function getAddCommentsFunction(targetNode, sourceFile, commentKind, hasTrailingNewLine, cb) { return function (pos, end, kind, htnl) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // Remove leading /* pos += 2; // Remove trailing */ @@ -130446,7 +131118,7 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || ts.isObjectLiteralExpression(expression) || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } @@ -130454,15 +131126,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checker.getContextualType(parent); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -130473,15 +131145,15 @@ var ts; // Editors can pass in undefined or empty string - we want to infer the preference in those cases. var quotePreference = getQuotePreference(sourceFile, preferences); var quoted = JSON.stringify(text); - return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; + return quotePreference === 0 /* QuotePreference.Single */ ? "'".concat(ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"'), "'") : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: return true; default: return false; @@ -130490,10 +131162,10 @@ var ts; ts.isEqualityOperatorKind = isEqualityOperatorKind; function isStringLiteralOrTemplate(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 210 /* TaggedTemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return true; default: return false; @@ -130513,9 +131185,9 @@ var ts; var checker = program.getTypeChecker(); var typeIsAccessible = true; var notAccessible = function () { return typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { + var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NodeBuilderFlags.NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */; return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, @@ -130527,48 +131199,48 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 174 /* CallSignature */ - || kind === 175 /* ConstructSignature */ - || kind === 176 /* IndexSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */; + return kind === 174 /* SyntaxKind.CallSignature */ + || kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */; } function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 261 /* ModuleDeclaration */; + return kind === 261 /* SyntaxKind.ModuleDeclaration */; } function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 237 /* VariableStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 240 /* DoStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 246 /* BreakStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 167 /* PropertyDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); function nodeIsASICandidate(node, sourceFile) { var lastToken = node.getLastToken(sourceFile); - if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + if (lastToken && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */) { return false; } if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { - if (lastToken && lastToken.kind === 27 /* CommaToken */) { + if (lastToken && lastToken.kind === 27 /* SyntaxKind.CommaToken */) { return false; } } @@ -130588,12 +131260,12 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 240 /* DoStatement */) { + if (node.kind === 240 /* SyntaxKind.DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); var nextToken = findNextToken(node, topNode, sourceFile); - if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + if (!nextToken || nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { return true; } var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; @@ -130617,7 +131289,7 @@ var ts; ts.forEachChild(sourceFile, function visit(node) { if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } else { @@ -130626,10 +131298,10 @@ var ts; } else if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } - else if (lastToken && lastToken.kind !== 27 /* CommaToken */) { + else if (lastToken && lastToken.kind !== 27 /* SyntaxKind.CommaToken */) { var lastTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, lastToken.getStart(sourceFile)).line; var nextTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, ts.getSpanOfTokenAtPosition(sourceFile, lastToken.end).start).line; // Avoid counting missing semicolon in single-line objects: @@ -130753,16 +131425,16 @@ var ts; } } var dependencyGroups = [ - [1 /* Dependencies */, info.dependencies], - [2 /* DevDependencies */, info.devDependencies], - [8 /* OptionalDependencies */, info.optionalDependencies], - [4 /* PeerDependencies */, info.peerDependencies], + [1 /* PackageJsonDependencyGroup.Dependencies */, info.dependencies], + [2 /* PackageJsonDependencyGroup.DevDependencies */, info.devDependencies], + [8 /* PackageJsonDependencyGroup.OptionalDependencies */, info.optionalDependencies], + [4 /* PackageJsonDependencyGroup.PeerDependencies */, info.peerDependencies], ]; return __assign(__assign({}, info), { parseable: !!content, fileName: fileName, get: get, has: function (dependencyName, inGroups) { return !!get(dependencyName, inGroups); } }); function get(dependencyName, inGroups) { - if (inGroups === void 0) { inGroups = 15 /* All */; } + if (inGroups === void 0) { inGroups = 15 /* PackageJsonDependencyGroup.All */; } for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; if (deps && (inGroups & group_1)) { @@ -130857,7 +131529,7 @@ var ts; var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); // Scoped packages if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; + return "".concat(components[0], "/").concat(components[1]); } return components[0]; } @@ -130977,20 +131649,20 @@ var ts; } ts.getNameForExportedSymbol = getNameForExportedSymbol; function needsNameFromDeclaration(symbol) { - return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */); + return !(symbol.flags & 33554432 /* SymbolFlags.Transient */) && (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */ || symbol.escapedName === "default" /* InternalSymbolName.Default */); } function getDefaultLikeExportNameFromDeclaration(symbol) { return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; }); } function getSymbolParentOrFail(symbol) { var _a; - return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " + - ("Declarations: " + ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { + return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: ".concat(ts.Debug.formatSymbolFlags(symbol.flags), ". ") + + "Declarations: ".concat((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { var kind = ts.Debug.formatSyntaxKind(d.kind); var inJS = ts.isInJSFile(d); var expression = d.expression; - return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: " + ts.Debug.formatSyntaxKind(expression.kind) + ")" : ""); - }).join(", ")) + ".")); + return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: ".concat(ts.Debug.formatSyntaxKind(expression.kind), ")") : ""); + }).join(", "), ".")); } /** * Useful to check whether a string contains another string at a specific index @@ -131023,7 +131695,7 @@ var ts; } ts.stringContainsAt = stringContainsAt; function startsWithUnderscore(name) { - return name.charCodeAt(0) === 95 /* _ */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */; } ts.startsWithUnderscore = startsWithUnderscore; function isGlobalDeclaration(declaration) { @@ -131041,7 +131713,7 @@ var ts; } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* ModifierFlags.Deprecated */); } ts.isDeprecatedDeclaration = isDeprecatedDeclaration; function shouldUseUriStyleNodeCoreModules(file, program) { @@ -131054,7 +131726,7 @@ var ts; } ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules; function getNewLineKind(newLineCharacter) { - return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + return newLineCharacter === "\n" ? 1 /* NewLineKind.LineFeed */ : 0 /* NewLineKind.CarriageReturnLineFeed */; } ts.getNewLineKind = getNewLineKind; function diagnosticToString(diag) { @@ -131074,7 +131746,7 @@ var ts; } ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting; function jsxModeNeedsExplicitImport(jsx) { - return jsx === 2 /* React */ || jsx === 3 /* ReactNative */; + return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */; } ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport; // #endregion @@ -131146,7 +131818,7 @@ var ts; } } } - var isDefault = exportKind === 1 /* Default */; + var isDefault = exportKind === 1 /* ExportKind.Default */; var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol; // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`. // 2. A re-export merged with an export from a module augmentation can result in `symbol` @@ -131155,7 +131827,7 @@ var ts; // 3. Otherwise, we have a default/namespace import that can be imported by any name, and // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to // get a better name. - var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol) + var names = exportKind === 0 /* ExportKind.Named */ || ts.isExternalModuleSymbol(namedSymbol) ? ts.unescapeLeadingUnderscores(symbolTableKey) : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined); var symbolName = typeof names === "string" ? names : names[0]; @@ -131163,8 +131835,8 @@ var ts; var moduleName = ts.stripQuotes(moduleSymbol.name); var id = exportInfoId++; var target = ts.skipAlias(symbol, checker); - var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol; - var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol; + var storedSymbol = symbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : symbol; + var storedModuleSymbol = moduleSymbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : moduleSymbol; if (!storedSymbol || !storedModuleSymbol) symbols.set(id, [symbol, moduleSymbol]); exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), { @@ -131253,9 +131925,9 @@ var ts; var moduleSymbol = info.moduleSymbol || cachedModuleSymbol || ts.Debug.checkDefined(info.moduleFile ? checker.getMergedSymbol(info.moduleFile.symbol) : checker.tryFindAmbientModule(info.moduleName)); - var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportEquals */ + var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportKind.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) - : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '" + info.symbolName + "' by key '" + info.symbolTableKey + "' in module " + moduleSymbol.name); + : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '".concat(info.symbolName, "' by key '").concat(info.symbolTableKey, "' in module ").concat(moduleSymbol.name)); symbols.set(id, [symbol, moduleSymbol]); return { symbol: symbol, @@ -131268,7 +131940,7 @@ var ts; } function key(importedName, symbol, ambientModuleName, checker) { var moduleKey = ambientModuleName || ""; - return importedName + "|" + ts.getSymbolId(ts.skipAlias(symbol, checker)) + "|" + moduleKey; + return "".concat(importedName, "|").concat(ts.getSymbolId(ts.skipAlias(symbol, checker)), "|").concat(moduleKey); } function parseKey(key) { var symbolName = key.substring(0, key.indexOf("|")); @@ -131364,7 +132036,7 @@ var ts; if (autoImportProvider) { var start = ts.timestamp(); forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: ".concat(ts.timestamp() - start)); } } ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; @@ -131413,11 +132085,11 @@ var ts; // Note: I think we shouldn't actually see resolved module symbols here, but weird merges // can cause it to happen: see 'completionsImport_mergedReExport.ts' if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { - cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); + cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* ExportKind.Default */ ? "default" /* InternalSymbolName.Default */ : "export=" /* InternalSymbolName.ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); } checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { - cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker); + cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* ExportKind.Named */, isFromPackageJson, checker); } }); }); @@ -131427,7 +132099,7 @@ var ts; cache.clear(); throw err; } - (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in ".concat(ts.timestamp() - start, " ms")); return cache; } ts.getExportInfoMap = getExportInfoMap; @@ -131446,10 +132118,10 @@ var ts; function getDefaultLikeExportWorker(moduleSymbol, checker) { var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) - return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ }; - var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); + return { symbol: exportEquals, exportKind: 2 /* ExportKind.ExportEquals */ }; + var defaultExport = checker.tryGetMemberInModuleExports("default" /* InternalSymbolName.Default */, moduleSymbol); if (defaultExport) - return { symbol: defaultExport, exportKind: 1 /* Default */ }; + return { symbol: defaultExport, exportKind: 1 /* ExportKind.Default */ }; } function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -131458,7 +132130,7 @@ var ts; var name = getNameForExportDefault(defaultExport); if (name !== undefined) return { symbolForMeaning: defaultExport, name: name }; - if (defaultExport.flags & 2097152 /* Alias */) { + if (defaultExport.flags & 2097152 /* SymbolFlags.Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); if (aliased && aliased.parent) { // - `aliased` will be undefined if the module is exporting an unresolvable name, @@ -131468,8 +132140,8 @@ var ts; return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } - if (defaultExport.escapedName !== "default" /* Default */ && - defaultExport.escapedName !== "export=" /* ExportEquals */) { + if (defaultExport.escapedName !== "default" /* InternalSymbolName.Default */ && + defaultExport.escapedName !== "export=" /* InternalSymbolName.ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; @@ -131481,7 +132153,7 @@ var ts; return (_a = ts.tryCast(ts.skipOuterExpressions(declaration.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); + ts.Debug.assert(declaration.name.text === "default" /* InternalSymbolName.Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -131491,15 +132163,15 @@ var ts; (function (ts) { /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { return convertClassificationsToResult(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); } // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var token = 0 /* Unknown */; - var lastNonTriviaToken = 0 /* Unknown */; + var token = 0 /* SyntaxKind.Unknown */; + var lastNonTriviaToken = 0 /* SyntaxKind.Unknown */; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -131525,10 +132197,10 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(15 /* TemplateHead */); + templateStack.push(15 /* SyntaxKind.TemplateHead */); } scanner.setText(text); - var endOfLineState = 0 /* None */; + var endOfLineState = 0 /* EndOfLineState.None */; var spans = []; // We can run into an unfortunate interaction between the lexical and syntactic classifier // when the user is typing something generic. Consider the case where the user types: @@ -131564,68 +132236,68 @@ var ts; endOfLineState = end_1; } } - } while (token !== 1 /* EndOfFileToken */); + } while (token !== 1 /* SyntaxKind.EndOfFileToken */); function handleToken() { switch (token) { - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { - token = 13 /* RegularExpressionLiteral */; + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } break; - case 29 /* LessThanToken */: - if (lastNonTriviaToken === 79 /* Identifier */) { + case 29 /* SyntaxKind.LessThanToken */: + if (lastNonTriviaToken === 79 /* SyntaxKind.Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 130 /* AnyKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: templateStack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 15 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* SyntaxKind.TemplateHead */) { token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 17 /* TemplateTail */) { + if (token === 17 /* SyntaxKind.TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* SyntaxKind.TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* SyntaxKind.OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -131634,15 +132306,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 24 /* DotToken */) { - token = 79 /* Identifier */; + if (lastNonTriviaToken === 24 /* SyntaxKind.DotToken */) { + token = 79 /* SyntaxKind.Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } } } @@ -131656,59 +132328,59 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 79 /* Identifier */, - 10 /* StringLiteral */, - 8 /* NumericLiteral */, - 9 /* BigIntLiteral */, - 13 /* RegularExpressionLiteral */, - 108 /* ThisKeyword */, - 45 /* PlusPlusToken */, - 46 /* MinusMinusToken */, - 21 /* CloseParenToken */, - 23 /* CloseBracketToken */, - 19 /* CloseBraceToken */, - 110 /* TrueKeyword */, - 95 /* FalseKeyword */, + 79 /* SyntaxKind.Identifier */, + 10 /* SyntaxKind.StringLiteral */, + 8 /* SyntaxKind.NumericLiteral */, + 9 /* SyntaxKind.BigIntLiteral */, + 13 /* SyntaxKind.RegularExpressionLiteral */, + 108 /* SyntaxKind.ThisKeyword */, + 45 /* SyntaxKind.PlusPlusToken */, + 46 /* SyntaxKind.MinusMinusToken */, + 21 /* SyntaxKind.CloseParenToken */, + 23 /* SyntaxKind.CloseBracketToken */, + 19 /* SyntaxKind.CloseBraceToken */, + 110 /* SyntaxKind.TrueKeyword */, + 95 /* SyntaxKind.FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 10 /* StringLiteral */: { + case 10 /* SyntaxKind.StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; var tokenText = scanner.getTokenText(); var lastCharIndex = tokenText.length - 1; var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* CharacterCodes.backslash */) { numBackslashes++; } // If we have an odd number of backslashes, then the multiline string is unclosed if ((numBackslashes & 1) === 0) return undefined; - return tokenText.charCodeAt(0) === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + return tokenText.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */ ? 3 /* EndOfLineState.InDoubleQuoteStringLiteral */ : 2 /* EndOfLineState.InSingleQuoteStringLiteral */; } - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Check to see if the multiline comment was unclosed. - return scanner.isUnterminated() ? 1 /* InMultiLineCommentTrivia */ : undefined; + return scanner.isUnterminated() ? 1 /* EndOfLineState.InMultiLineCommentTrivia */ : undefined; default: if (ts.isTemplateLiteralKind(token)) { if (!scanner.isUnterminated()) { return undefined; } switch (token) { - case 17 /* TemplateTail */: - return 5 /* InTemplateMiddleOrTail */; - case 14 /* NoSubstitutionTemplateLiteral */: - return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + case 17 /* SyntaxKind.TemplateTail */: + return 5 /* EndOfLineState.InTemplateMiddleOrTail */; + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + return 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* SyntaxKind.TemplateHead */ ? 6 /* EndOfLineState.InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { - if (classification === 8 /* whiteSpace */) { + if (classification === 8 /* ClassificationType.whiteSpace */) { // Don't bother with whitespace classifications. They're not needed. return; } @@ -131750,23 +132422,23 @@ var ts; } function convertClassification(type) { switch (type) { - case 1 /* comment */: return ts.TokenClass.Comment; - case 3 /* keyword */: return ts.TokenClass.Keyword; - case 4 /* numericLiteral */: return ts.TokenClass.NumberLiteral; - case 25 /* bigintLiteral */: return ts.TokenClass.BigIntLiteral; - case 5 /* operator */: return ts.TokenClass.Operator; - case 6 /* stringLiteral */: return ts.TokenClass.StringLiteral; - case 8 /* whiteSpace */: return ts.TokenClass.Whitespace; - case 10 /* punctuation */: return ts.TokenClass.Punctuation; - case 2 /* identifier */: - case 11 /* className */: - case 12 /* enumName */: - case 13 /* interfaceName */: - case 14 /* moduleName */: - case 15 /* typeParameterName */: - case 16 /* typeAliasName */: - case 9 /* text */: - case 17 /* parameterName */: + case 1 /* ClassificationType.comment */: return ts.TokenClass.Comment; + case 3 /* ClassificationType.keyword */: return ts.TokenClass.Keyword; + case 4 /* ClassificationType.numericLiteral */: return ts.TokenClass.NumberLiteral; + case 25 /* ClassificationType.bigintLiteral */: return ts.TokenClass.BigIntLiteral; + case 5 /* ClassificationType.operator */: return ts.TokenClass.Operator; + case 6 /* ClassificationType.stringLiteral */: return ts.TokenClass.StringLiteral; + case 8 /* ClassificationType.whiteSpace */: return ts.TokenClass.Whitespace; + case 10 /* ClassificationType.punctuation */: return ts.TokenClass.Punctuation; + case 2 /* ClassificationType.identifier */: + case 11 /* ClassificationType.className */: + case 12 /* ClassificationType.enumName */: + case 13 /* ClassificationType.interfaceName */: + case 14 /* ClassificationType.moduleName */: + case 15 /* ClassificationType.typeParameterName */: + case 16 /* ClassificationType.typeAliasName */: + case 9 /* ClassificationType.text */: + case 17 /* ClassificationType.parameterName */: return ts.TokenClass.Identifier; default: return undefined; // TODO: GH#18217 Debug.assertNever(type); @@ -131780,10 +132452,10 @@ var ts; return true; } switch (keyword2) { - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 134 /* ConstructorKeyword */: - case 124 /* StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -131796,19 +132468,19 @@ var ts; // If we're in a multiline comment, then prepend: /* // (and a newline). That way when we lex we'll think we're still in a multiline comment. switch (lexState) { - case 3 /* InDoubleQuoteStringLiteral */: + case 3 /* EndOfLineState.InDoubleQuoteStringLiteral */: return { prefix: "\"\\\n" }; - case 2 /* InSingleQuoteStringLiteral */: + case 2 /* EndOfLineState.InSingleQuoteStringLiteral */: return { prefix: "'\\\n" }; - case 1 /* InMultiLineCommentTrivia */: + case 1 /* EndOfLineState.InMultiLineCommentTrivia */: return { prefix: "/*\n" }; - case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: + case 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */: return { prefix: "`\n" }; - case 5 /* InTemplateMiddleOrTail */: + case 5 /* EndOfLineState.InTemplateMiddleOrTail */: return { prefix: "}\n", pushTemplate: true }; - case 6 /* InTemplateSubstitutionPosition */: + case 6 /* EndOfLineState.InTemplateSubstitutionPosition */: return { prefix: "", pushTemplate: true }; - case 0 /* None */: + case 0 /* EndOfLineState.None */: return { prefix: "" }; default: return ts.Debug.assertNever(lexState); @@ -131816,47 +132488,47 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 50 /* AmpersandToken */: - case 52 /* CaretToken */: - case 51 /* BarToken */: - case 55 /* AmpersandAmpersandToken */: - case 56 /* BarBarToken */: - case 74 /* BarEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 63 /* EqualsToken */: - case 27 /* CommaToken */: - case 60 /* QuestionQuestionToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 52 /* SyntaxKind.CaretToken */: + case 51 /* SyntaxKind.BarToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return true; default: return false; @@ -131864,12 +132536,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: return true; default: return false; @@ -131877,36 +132549,36 @@ var ts; } function classFromKind(token) { if (ts.isKeyword(token)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5 /* operator */; + return 5 /* ClassificationType.operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { - return 10 /* punctuation */; + else if (token >= 18 /* SyntaxKind.FirstPunctuation */ && token <= 78 /* SyntaxKind.LastPunctuation */) { + return 10 /* ClassificationType.punctuation */; } switch (token) { - case 8 /* NumericLiteral */: - return 4 /* numericLiteral */; - case 9 /* BigIntLiteral */: - return 25 /* bigintLiteral */; - case 10 /* StringLiteral */: - return 6 /* stringLiteral */; - case 13 /* RegularExpressionLiteral */: - return 7 /* regularExpressionLiteral */; - case 7 /* ConflictMarkerTrivia */: - case 3 /* MultiLineCommentTrivia */: - case 2 /* SingleLineCommentTrivia */: - return 1 /* comment */; - case 5 /* WhitespaceTrivia */: - case 4 /* NewLineTrivia */: - return 8 /* whiteSpace */; - case 79 /* Identifier */: + case 8 /* SyntaxKind.NumericLiteral */: + return 4 /* ClassificationType.numericLiteral */; + case 9 /* SyntaxKind.BigIntLiteral */: + return 25 /* ClassificationType.bigintLiteral */; + case 10 /* SyntaxKind.StringLiteral */: + return 6 /* ClassificationType.stringLiteral */; + case 13 /* SyntaxKind.RegularExpressionLiteral */: + return 7 /* ClassificationType.regularExpressionLiteral */; + case 7 /* SyntaxKind.ConflictMarkerTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + return 1 /* ClassificationType.comment */; + case 5 /* SyntaxKind.WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + return 8 /* ClassificationType.whiteSpace */; + case 79 /* SyntaxKind.Identifier */: default: if (ts.isTemplateLiteralKind(token)) { - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } /* @internal */ @@ -131926,13 +132598,13 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -131957,10 +132629,10 @@ var ts; } node.forEachChild(cb); }); - return { spans: spans, endOfLineState: 0 /* None */ }; + return { spans: spans, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, end, type) { var length = end - start; - ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); + ts.Debug.assert(length > 0, "Classification had non-positive length of ".concat(length)); spans.push(start); spans.push(length); spans.push(type); @@ -131969,29 +132641,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function classifySymbol(symbol, meaningAtPosition, checker) { var flags = symbol.getFlags(); - if ((flags & 2885600 /* Classifiable */) === 0 /* None */) { + if ((flags & 2885600 /* SymbolFlags.Classifiable */) === 0 /* SymbolFlags.None */) { return undefined; } - else if (flags & 32 /* Class */) { - return 11 /* className */; + else if (flags & 32 /* SymbolFlags.Class */) { + return 11 /* ClassificationType.className */; } - else if (flags & 384 /* Enum */) { - return 12 /* enumName */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 12 /* ClassificationType.enumName */; } - else if (flags & 524288 /* TypeAlias */) { - return 16 /* typeAliasName */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 16 /* ClassificationType.typeAliasName */; } - else if (flags & 1536 /* Module */) { + else if (flags & 1536 /* SymbolFlags.Module */) { // Only classify a module as such if // - It appears in a namespace context. // - There exists a module declaration which actually impacts the value side. - return meaningAtPosition & 4 /* Namespace */ || meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol) ? 14 /* moduleName */ : undefined; + return meaningAtPosition & 4 /* SemanticMeaning.Namespace */ || meaningAtPosition & 1 /* SemanticMeaning.Value */ && hasValueSideModule(symbol) ? 14 /* ClassificationType.moduleName */ : undefined; } - else if (flags & 2097152 /* Alias */) { + else if (flags & 2097152 /* SymbolFlags.Alias */) { return classifySymbol(checker.getAliasedSymbol(symbol), meaningAtPosition, checker); } - else if (meaningAtPosition & 2 /* Type */) { - return flags & 64 /* Interface */ ? 13 /* interfaceName */ : flags & 262144 /* TypeParameter */ ? 15 /* typeParameterName */ : undefined; + else if (meaningAtPosition & 2 /* SemanticMeaning.Type */) { + return flags & 64 /* SymbolFlags.Interface */ ? 13 /* ClassificationType.interfaceName */ : flags & 262144 /* SymbolFlags.TypeParameter */ ? 15 /* ClassificationType.typeParameterName */ : undefined; } else { return undefined; @@ -132000,35 +132672,35 @@ var ts; /** Returns true if there exists a module that introduces entities on the value side. */ function hasValueSideModule(symbol) { return ts.some(symbol.declarations, function (declaration) { - return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; + return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* ModuleInstanceState.Instantiated */; }); } function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return "comment" /* comment */; - case 2 /* identifier */: return "identifier" /* identifier */; - case 3 /* keyword */: return "keyword" /* keyword */; - case 4 /* numericLiteral */: return "number" /* numericLiteral */; - case 25 /* bigintLiteral */: return "bigint" /* bigintLiteral */; - case 5 /* operator */: return "operator" /* operator */; - case 6 /* stringLiteral */: return "string" /* stringLiteral */; - case 8 /* whiteSpace */: return "whitespace" /* whiteSpace */; - case 9 /* text */: return "text" /* text */; - case 10 /* punctuation */: return "punctuation" /* punctuation */; - case 11 /* className */: return "class name" /* className */; - case 12 /* enumName */: return "enum name" /* enumName */; - case 13 /* interfaceName */: return "interface name" /* interfaceName */; - case 14 /* moduleName */: return "module name" /* moduleName */; - case 15 /* typeParameterName */: return "type parameter name" /* typeParameterName */; - case 16 /* typeAliasName */: return "type alias name" /* typeAliasName */; - case 17 /* parameterName */: return "parameter name" /* parameterName */; - case 18 /* docCommentTagName */: return "doc comment tag name" /* docCommentTagName */; - case 19 /* jsxOpenTagName */: return "jsx open tag name" /* jsxOpenTagName */; - case 20 /* jsxCloseTagName */: return "jsx close tag name" /* jsxCloseTagName */; - case 21 /* jsxSelfClosingTagName */: return "jsx self closing tag name" /* jsxSelfClosingTagName */; - case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; - case 23 /* jsxText */: return "jsx text" /* jsxText */; - case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + case 1 /* ClassificationType.comment */: return "comment" /* ClassificationTypeNames.comment */; + case 2 /* ClassificationType.identifier */: return "identifier" /* ClassificationTypeNames.identifier */; + case 3 /* ClassificationType.keyword */: return "keyword" /* ClassificationTypeNames.keyword */; + case 4 /* ClassificationType.numericLiteral */: return "number" /* ClassificationTypeNames.numericLiteral */; + case 25 /* ClassificationType.bigintLiteral */: return "bigint" /* ClassificationTypeNames.bigintLiteral */; + case 5 /* ClassificationType.operator */: return "operator" /* ClassificationTypeNames.operator */; + case 6 /* ClassificationType.stringLiteral */: return "string" /* ClassificationTypeNames.stringLiteral */; + case 8 /* ClassificationType.whiteSpace */: return "whitespace" /* ClassificationTypeNames.whiteSpace */; + case 9 /* ClassificationType.text */: return "text" /* ClassificationTypeNames.text */; + case 10 /* ClassificationType.punctuation */: return "punctuation" /* ClassificationTypeNames.punctuation */; + case 11 /* ClassificationType.className */: return "class name" /* ClassificationTypeNames.className */; + case 12 /* ClassificationType.enumName */: return "enum name" /* ClassificationTypeNames.enumName */; + case 13 /* ClassificationType.interfaceName */: return "interface name" /* ClassificationTypeNames.interfaceName */; + case 14 /* ClassificationType.moduleName */: return "module name" /* ClassificationTypeNames.moduleName */; + case 15 /* ClassificationType.typeParameterName */: return "type parameter name" /* ClassificationTypeNames.typeParameterName */; + case 16 /* ClassificationType.typeAliasName */: return "type alias name" /* ClassificationTypeNames.typeAliasName */; + case 17 /* ClassificationType.parameterName */: return "parameter name" /* ClassificationTypeNames.parameterName */; + case 18 /* ClassificationType.docCommentTagName */: return "doc comment tag name" /* ClassificationTypeNames.docCommentTagName */; + case 19 /* ClassificationType.jsxOpenTagName */: return "jsx open tag name" /* ClassificationTypeNames.jsxOpenTagName */; + case 20 /* ClassificationType.jsxCloseTagName */: return "jsx close tag name" /* ClassificationTypeNames.jsxCloseTagName */; + case 21 /* ClassificationType.jsxSelfClosingTagName */: return "jsx self closing tag name" /* ClassificationTypeNames.jsxSelfClosingTagName */; + case 22 /* ClassificationType.jsxAttribute */: return "jsx attribute" /* ClassificationTypeNames.jsxAttribute */; + case 23 /* ClassificationType.jsxText */: return "jsx text" /* ClassificationTypeNames.jsxText */; + case 24 /* ClassificationType.jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* ClassificationTypeNames.jsxAttributeStringLiteralValue */; default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type); } } @@ -132054,11 +132726,11 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; + return { spans: result, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, length, type) { result.push(start); result.push(length); @@ -132080,12 +132752,12 @@ var ts; return start; } switch (kind) { - case 4 /* NewLineTrivia */: - case 5 /* WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // Don't bother with newlines/whitespace. continue; - case 2 /* SingleLineCommentTrivia */: - case 3 /* MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Only bother with the trivia if it at least intersects the span of interest. classifyComment(token, kind, start, width); // Classifying a comment might cause us to reuse the trivia scanner @@ -132093,21 +132765,21 @@ var ts; // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; - case 7 /* ConflictMarkerTrivia */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { + pushClassification(start, width, 1 /* ClassificationType.comment */); continue; } // for the ||||||| and ======== markers, add a comment for the first line, // and then lex all subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); classifyDisabledMergeCode(text, start, end); break; - case 6 /* ShebangTrivia */: + case 6 /* SyntaxKind.ShebangTrivia */: // TODO: Maybe we should classify these. break; default: @@ -132116,7 +132788,7 @@ var ts; } } function classifyComment(token, kind, start, width) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // See if this is a doc comment. If so, we'll classify certain portions of it // specially. var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); @@ -132127,7 +132799,7 @@ var ts; return; } } - else if (kind === 2 /* SingleLineCommentTrivia */) { + else if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { if (tryClassifyTripleSlashComment(start, width)) { return; } @@ -132136,7 +132808,7 @@ var ts; pushCommentRange(start, width); } function pushCommentRange(start, width) { - pushClassification(start, width, 1 /* comment */); + pushClassification(start, width, 1 /* ClassificationType.comment */); } function classifyJSDocComment(docComment) { var _a, _b, _c, _d, _e, _f, _g; @@ -132149,51 +132821,51 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" + pushClassification(tag.pos, 1, 10 /* ClassificationType.punctuation */); // "@" + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* ClassificationType.docCommentTagName */); // e.g. "param" pos = tag.tagName.end; var commentStart = tag.tagName.end; switch (tag.kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var param = tag; processJSDocParameterTag(param); commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end; break; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var prop = tag; commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; commentStart = tag.typeParameters.end; break; - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: var type = tag; - commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; break; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: commentStart = tag.typeExpression.end; break; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = tag.typeExpression.end; break; - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: commentStart = tag.typeExpression.end; break; - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; break; - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: commentStart = tag.class.end; break; } @@ -132212,7 +132884,7 @@ var ts; function processJSDocParameterTag(tag) { if (tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } if (tag.typeExpression) { @@ -132222,7 +132894,7 @@ var ts; } if (!tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } } @@ -132247,9 +132919,9 @@ var ts; var pos = start; pushCommentRange(pos, match[1].length); // /// pos += match[1].length; - pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pushClassification(pos, match[2].length, 10 /* ClassificationType.punctuation */); // < pos += match[2].length; - pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pushClassification(pos, match[3].length, 21 /* ClassificationType.jsxSelfClosingTagName */); // element name pos += match[3].length; var attrText = match[4]; var attrPos = pos; @@ -132263,19 +132935,19 @@ var ts; pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + pushClassification(attrPos, attrMatch[2].length, 22 /* ClassificationType.jsxAttribute */); // attribute name attrPos += attrMatch[2].length; if (attrMatch[3].length) { pushCommentRange(attrPos, attrMatch[3].length); // whitespace attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + pushClassification(attrPos, attrMatch[4].length, 5 /* ClassificationType.operator */); // = attrPos += attrMatch[4].length; if (attrMatch[5].length) { pushCommentRange(attrPos, attrMatch[5].length); // whitespace attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + pushClassification(attrPos, attrMatch[6].length, 24 /* ClassificationType.jsxAttributeStringLiteralValue */); // attribute value attrPos += attrMatch[6].length; } pos += match[4].length; @@ -132283,7 +132955,7 @@ var ts; pushCommentRange(attrPos, pos - attrPos); } if (match[5]) { - pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pushClassification(pos, match[5].length, 10 /* ClassificationType.punctuation */); // /> pos += match[5].length; } var end = start + width; @@ -132307,7 +132979,7 @@ var ts; break; } } - pushClassification(start, i - start, 1 /* comment */); + pushClassification(start, i - start, 1 /* ClassificationType.comment */); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { classifyDisabledCodeToken(); @@ -132334,10 +133006,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* SyntaxKind.JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* SyntaxKind.JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -132350,24 +133022,24 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: if (token.parent.tagName === token) { - return 19 /* jsxOpenTagName */; + return 19 /* ClassificationType.jsxOpenTagName */; } break; - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: if (token.parent.tagName === token) { - return 20 /* jsxCloseTagName */; + return 20 /* ClassificationType.jsxCloseTagName */; } break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: if (token.parent.tagName === token) { - return 21 /* jsxSelfClosingTagName */; + return 21 /* ClassificationType.jsxSelfClosingTagName */; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: if (token.parent.name === token) { - return 22 /* jsxAttribute */; + return 22 /* ClassificationType.jsxAttribute */; } break; } @@ -132378,97 +133050,97 @@ var ts; // classify based on that instead. function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { + if (tokenKind === 29 /* SyntaxKind.LessThanToken */ || tokenKind === 31 /* SyntaxKind.GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } } if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 63 /* EqualsToken */) { + if (tokenKind === 63 /* SyntaxKind.EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 254 /* VariableDeclaration */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 164 /* Parameter */ || - parent.kind === 285 /* JsxAttribute */) { - return 5 /* operator */; + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 164 /* SyntaxKind.Parameter */ || + parent.kind === 285 /* SyntaxKind.JsxAttribute */) { + return 5 /* ClassificationType.operator */; } } - if (parent.kind === 221 /* BinaryExpression */ || - parent.kind === 219 /* PrefixUnaryExpression */ || - parent.kind === 220 /* PostfixUnaryExpression */ || - parent.kind === 222 /* ConditionalExpression */) { - return 5 /* operator */; + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ || + parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || + parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */ || + parent.kind === 222 /* SyntaxKind.ConditionalExpression */) { + return 5 /* ClassificationType.operator */; } } - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } - else if (tokenKind === 8 /* NumericLiteral */) { - return 4 /* numericLiteral */; + else if (tokenKind === 8 /* SyntaxKind.NumericLiteral */) { + return 4 /* ClassificationType.numericLiteral */; } - else if (tokenKind === 9 /* BigIntLiteral */) { - return 25 /* bigintLiteral */; + else if (tokenKind === 9 /* SyntaxKind.BigIntLiteral */) { + return 25 /* ClassificationType.bigintLiteral */; } - else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 285 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 10 /* SyntaxKind.StringLiteral */) { + return token && token.parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? 24 /* ClassificationType.jsxAttributeStringLiteralValue */ : 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 13 /* RegularExpressionLiteral */) { + else if (tokenKind === 13 /* SyntaxKind.RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } else if (ts.isTemplateLiteralKind(tokenKind)) { // TODO (drosen): we should *also* get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 11 /* JsxText */) { - return 23 /* jsxText */; + else if (tokenKind === 11 /* SyntaxKind.JsxText */) { + return 23 /* ClassificationType.jsxText */; } - else if (tokenKind === 79 /* Identifier */) { + else if (tokenKind === 79 /* SyntaxKind.Identifier */) { if (token) { switch (token.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: if (token.parent.name === token) { - return 11 /* className */; + return 11 /* ClassificationType.className */; } return; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: if (token.parent.name === token) { - return 15 /* typeParameterName */; + return 15 /* ClassificationType.typeParameterName */; } return; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: if (token.parent.name === token) { - return 13 /* interfaceName */; + return 13 /* ClassificationType.interfaceName */; } return; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (token.parent.name === token) { - return 12 /* enumName */; + return 12 /* ClassificationType.enumName */; } return; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (token.parent.name === token) { - return 14 /* moduleName */; + return 14 /* ClassificationType.moduleName */; } return; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (token.parent.name === token) { - return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; + return ts.isThisIdentifier(token) ? 3 /* ClassificationType.keyword */ : 17 /* ClassificationType.parameterName */; } return; } if (ts.isConstTypeReference(token.parent)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } function processElement(element) { @@ -132544,14 +133216,14 @@ var ts; function getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span) { return { spans: getSemanticTokens(program, sourceFile, span, cancellationToken), - endOfLineState: 0 /* None */ + endOfLineState: 0 /* EndOfLineState.None */ }; } v2020.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getSemanticTokens(program, sourceFile, span, cancellationToken) { var resultTokens = []; var collector = function (node, typeIdx, modifierSet) { - resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* typeOffset */) + modifierSet); + resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* TokenEncodingConsts.typeOffset */) + modifierSet); }; if (program && sourceFile) { collectTokens(program, sourceFile, span, collector, cancellationToken); @@ -132563,13 +133235,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -132585,7 +133257,7 @@ var ts; if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node) && !ts.isInfinityOrNaNString(node.escapedText)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } var typeIdx = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -132594,38 +133266,38 @@ var ts; if (node.parent) { var parentIsDeclaration = (ts.isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx); if (parentIsDeclaration && node.parent.name === node) { - modifierSet = 1 << 0 /* declaration */; + modifierSet = 1 << 0 /* TokenModifier.declaration */; } } // property declaration in constructor - if (typeIdx === 6 /* parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { - typeIdx = 9 /* property */; + if (typeIdx === 6 /* TokenType.parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { + typeIdx = 9 /* TokenType.property */; } typeIdx = reclassifyByType(typeChecker, node, typeIdx); var decl = symbol.valueDeclaration; if (decl) { var modifiers = ts.getCombinedModifierFlags(decl); var nodeFlags = ts.getCombinedNodeFlags(decl); - if (modifiers & 32 /* Static */) { - modifierSet |= 1 << 1 /* static */; + if (modifiers & 32 /* ModifierFlags.Static */) { + modifierSet |= 1 << 1 /* TokenModifier.static */; } - if (modifiers & 256 /* Async */) { - modifierSet |= 1 << 2 /* async */; + if (modifiers & 256 /* ModifierFlags.Async */) { + modifierSet |= 1 << 2 /* TokenModifier.async */; } - if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) { - if ((modifiers & 64 /* Readonly */) || (nodeFlags & 2 /* Const */) || (symbol.getFlags() & 8 /* EnumMember */)) { - modifierSet |= 1 << 3 /* readonly */; + if (typeIdx !== 0 /* TokenType.class */ && typeIdx !== 2 /* TokenType.interface */) { + if ((modifiers & 64 /* ModifierFlags.Readonly */) || (nodeFlags & 2 /* NodeFlags.Const */) || (symbol.getFlags() & 8 /* SymbolFlags.EnumMember */)) { + modifierSet |= 1 << 3 /* TokenModifier.readonly */; } } - if ((typeIdx === 7 /* variable */ || typeIdx === 10 /* function */) && isLocalDeclaration(decl, sourceFile)) { - modifierSet |= 1 << 5 /* local */; + if ((typeIdx === 7 /* TokenType.variable */ || typeIdx === 10 /* TokenType.function */) && isLocalDeclaration(decl, sourceFile)) { + modifierSet |= 1 << 5 /* TokenModifier.local */; } if (program.isSourceFileDefaultLibrary(decl.getSourceFile())) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } } else if (symbol.declarations && symbol.declarations.some(function (d) { return program.isSourceFileDefaultLibrary(d.getSourceFile()); })) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } collector(node, typeIdx, modifierSet); } @@ -132638,22 +133310,22 @@ var ts; } function classifySymbol(symbol, meaning) { var flags = symbol.getFlags(); - if (flags & 32 /* Class */) { - return 0 /* class */; + if (flags & 32 /* SymbolFlags.Class */) { + return 0 /* TokenType.class */; } - else if (flags & 384 /* Enum */) { - return 1 /* enum */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 1 /* TokenType.enum */; } - else if (flags & 524288 /* TypeAlias */) { - return 5 /* type */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 5 /* TokenType.type */; } - else if (flags & 64 /* Interface */) { - if (meaning & 2 /* Type */) { - return 2 /* interface */; + else if (flags & 64 /* SymbolFlags.Interface */) { + if (meaning & 2 /* SemanticMeaning.Type */) { + return 2 /* TokenType.interface */; } } - else if (flags & 262144 /* TypeParameter */) { - return 4 /* typeParameter */; + else if (flags & 262144 /* SymbolFlags.TypeParameter */) { + return 4 /* TokenType.typeParameter */; } var decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0]; if (decl && ts.isBindingElement(decl)) { @@ -132663,17 +133335,17 @@ var ts; } function reclassifyByType(typeChecker, node, typeIdx) { // type based classifications - if (typeIdx === 7 /* variable */ || typeIdx === 9 /* property */ || typeIdx === 6 /* parameter */) { + if (typeIdx === 7 /* TokenType.variable */ || typeIdx === 9 /* TokenType.property */ || typeIdx === 6 /* TokenType.parameter */) { var type_1 = typeChecker.getTypeAtLocation(node); if (type_1) { var test = function (condition) { return condition(type_1) || type_1.isUnion() && type_1.types.some(condition); }; - if (typeIdx !== 6 /* parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { - return 0 /* class */; + if (typeIdx !== 6 /* TokenType.parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { + return 0 /* TokenType.class */; } if (test(function (t) { return t.getCallSignatures().length > 0; }) && !test(function (t) { return t.getProperties().length > 0; }) || isExpressionInCallExpression(node)) { - return typeIdx === 9 /* property */ ? 11 /* member */ : 10 /* function */; + return typeIdx === 9 /* TokenType.property */ ? 11 /* TokenType.member */ : 10 /* TokenType.function */; } } } @@ -132715,25 +133387,25 @@ var ts; return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node); } var tokenFromDeclarationMapping = new ts.Map([ - [254 /* VariableDeclaration */, 7 /* variable */], - [164 /* Parameter */, 6 /* parameter */], - [167 /* PropertyDeclaration */, 9 /* property */], - [261 /* ModuleDeclaration */, 3 /* namespace */], - [260 /* EnumDeclaration */, 1 /* enum */], - [299 /* EnumMember */, 8 /* enumMember */], - [257 /* ClassDeclaration */, 0 /* class */], - [169 /* MethodDeclaration */, 11 /* member */], - [256 /* FunctionDeclaration */, 10 /* function */], - [213 /* FunctionExpression */, 10 /* function */], - [168 /* MethodSignature */, 11 /* member */], - [172 /* GetAccessor */, 9 /* property */], - [173 /* SetAccessor */, 9 /* property */], - [166 /* PropertySignature */, 9 /* property */], - [258 /* InterfaceDeclaration */, 2 /* interface */], - [259 /* TypeAliasDeclaration */, 5 /* type */], - [163 /* TypeParameter */, 4 /* typeParameter */], - [296 /* PropertyAssignment */, 9 /* property */], - [297 /* ShorthandPropertyAssignment */, 9 /* property */] + [254 /* SyntaxKind.VariableDeclaration */, 7 /* TokenType.variable */], + [164 /* SyntaxKind.Parameter */, 6 /* TokenType.parameter */], + [167 /* SyntaxKind.PropertyDeclaration */, 9 /* TokenType.property */], + [261 /* SyntaxKind.ModuleDeclaration */, 3 /* TokenType.namespace */], + [260 /* SyntaxKind.EnumDeclaration */, 1 /* TokenType.enum */], + [299 /* SyntaxKind.EnumMember */, 8 /* TokenType.enumMember */], + [257 /* SyntaxKind.ClassDeclaration */, 0 /* TokenType.class */], + [169 /* SyntaxKind.MethodDeclaration */, 11 /* TokenType.member */], + [256 /* SyntaxKind.FunctionDeclaration */, 10 /* TokenType.function */], + [213 /* SyntaxKind.FunctionExpression */, 10 /* TokenType.function */], + [168 /* SyntaxKind.MethodSignature */, 11 /* TokenType.member */], + [172 /* SyntaxKind.GetAccessor */, 9 /* TokenType.property */], + [173 /* SyntaxKind.SetAccessor */, 9 /* TokenType.property */], + [166 /* SyntaxKind.PropertySignature */, 9 /* TokenType.property */], + [258 /* SyntaxKind.InterfaceDeclaration */, 2 /* TokenType.interface */], + [259 /* SyntaxKind.TypeAliasDeclaration */, 5 /* TokenType.type */], + [163 /* SyntaxKind.TypeParameter */, 4 /* TokenType.typeParameter */], + [296 /* SyntaxKind.PropertyAssignment */, 9 /* TokenType.property */], + [297 /* SyntaxKind.ShorthandPropertyAssignment */, 9 /* TokenType.property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -132745,6 +133417,26 @@ var ts; (function (Completions) { var StringCompletions; (function (StringCompletions) { + var _a; + var kindPrecedence = (_a = {}, + _a["directory" /* ScriptElementKind.directory */] = 0, + _a["script" /* ScriptElementKind.scriptElement */] = 1, + _a["external module name" /* ScriptElementKind.externalModuleName */] = 2, + _a); + function createNameAndKindSet() { + var map = new ts.Map(); + function add(value) { + var existing = map.get(value.name); + if (!existing || kindPrecedence[existing.kind] < kindPrecedence[value.kind]) { + map.set(value.name, value); + } + } + return { + add: add, + has: map.has.bind(map), + values: map.values.bind(map), + }; + } function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) { if (ts.isInReferenceComment(sourceFile, position)) { var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host); @@ -132764,19 +133456,19 @@ var ts; } var optionalReplacementSpan = ts.createTextSpanFromStringLiteralLikeContent(contextToken); switch (completion.kind) { - case 0 /* Paths */: + case 0 /* StringLiteralCompletionKind.Paths */: return convertPathCompletions(completion.paths); - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var entries = ts.createSortedArray(); - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options, + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ScriptTarget.ESNext */, log, 4 /* CompletionKind.String */, preferences, options, /*formatContext*/ undefined); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } - case 2 /* Types */: { + case 2 /* StringLiteralCompletionKind.Types */: { var entries = completion.types.map(function (type) { return ({ name: type.value, - kindModifiers: "" /* none */, - kind: "string" /* string */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "string" /* ScriptElementKind.string */, sortText: Completions.SortText.LocationPriority, replacementSpan: ts.getReplacementSpanForContextToken(contextToken) }); }); @@ -132795,16 +133487,16 @@ var ts; StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { switch (completion.kind) { - case 0 /* Paths */: { + case 0 /* StringLiteralCompletionKind.Paths */: { var match = ts.find(completion.paths, function (p) { return p.name === name; }); return match && Completions.createCompletionDetails(name, kindModifiersFromExtension(match.extension), match.kind, [ts.textPart(name)]); } - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var match = ts.find(completion.symbols, function (s) { return s.name === name; }); return match && Completions.createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; + case 2 /* StringLiteralCompletionKind.Types */: + return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, "type" /* ScriptElementKind.typeElement */, [ts.textPart(name)]) : undefined; default: return ts.Debug.assertNever(completion); } @@ -132820,20 +133512,20 @@ var ts; } function kindModifiersFromExtension(extension) { switch (extension) { - case ".d.ts" /* Dts */: return ".d.ts" /* dtsModifier */; - case ".js" /* Js */: return ".js" /* jsModifier */; - case ".json" /* Json */: return ".json" /* jsonModifier */; - case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; - case ".ts" /* Ts */: return ".ts" /* tsModifier */; - case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; - case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */; - case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */; - case ".mts" /* Mts */: return ".mts" /* mtsModifier */; - case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */; - case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */; - case ".cts" /* Cts */: return ".cts" /* ctsModifier */; - case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); - case undefined: return "" /* none */; + case ".d.ts" /* Extension.Dts */: return ".d.ts" /* ScriptElementKindModifier.dtsModifier */; + case ".js" /* Extension.Js */: return ".js" /* ScriptElementKindModifier.jsModifier */; + case ".json" /* Extension.Json */: return ".json" /* ScriptElementKindModifier.jsonModifier */; + case ".jsx" /* Extension.Jsx */: return ".jsx" /* ScriptElementKindModifier.jsxModifier */; + case ".ts" /* Extension.Ts */: return ".ts" /* ScriptElementKindModifier.tsModifier */; + case ".tsx" /* Extension.Tsx */: return ".tsx" /* ScriptElementKindModifier.tsxModifier */; + case ".d.mts" /* Extension.Dmts */: return ".d.mts" /* ScriptElementKindModifier.dmtsModifier */; + case ".mjs" /* Extension.Mjs */: return ".mjs" /* ScriptElementKindModifier.mjsModifier */; + case ".mts" /* Extension.Mts */: return ".mts" /* ScriptElementKindModifier.mtsModifier */; + case ".d.cts" /* Extension.Dcts */: return ".d.cts" /* ScriptElementKindModifier.dctsModifier */; + case ".cjs" /* Extension.Cjs */: return ".cjs" /* ScriptElementKindModifier.cjsModifier */; + case ".cts" /* Extension.Cts */: return ".cts" /* ScriptElementKindModifier.ctsModifier */; + case ".tsbuildinfo" /* Extension.TsBuildInfo */: return ts.Debug.fail("Extension ".concat(".tsbuildinfo" /* Extension.TsBuildInfo */, " is unsupported.")); + case undefined: return "" /* ScriptElementKindModifier.none */; default: return ts.Debug.assertNever(extension); } @@ -132847,44 +133539,44 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 196 /* LiteralType */: { - var grandParent = walkUpParentheses(parent.parent); - switch (grandParent.kind) { - case 178 /* TypeReference */: { - var typeReference_1 = grandParent; - var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); + case 196 /* SyntaxKind.LiteralType */: { + var grandParent_1 = walkUpParentheses(parent.parent); + switch (grandParent_1.kind) { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: { + var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === grandParent_1; }); if (typeArgument) { - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; } return undefined; } - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; // bar: string; // } // let x: Foo["/*completion position*/"] - var _a = grandParent, indexType = _a.indexType, objectType = _a.objectType; + var _a = grandParent_1, indexType = _a.indexType, objectType = _a.objectType; if (!ts.rangeContainsPosition(indexType, position)) { return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 200 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; - case 187 /* UnionType */: { - if (!ts.isTypeReferenceNode(grandParent.parent)) { + case 200 /* SyntaxKind.ImportType */: + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 187 /* SyntaxKind.UnionType */: { + if (!ts.isTypeReferenceNode(grandParent_1.parent)) { return undefined; } - var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent); - var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent_1, parent); + var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent_1)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: false }; } default: return undefined; } } - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -132901,7 +133593,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 207 /* ElementAccessExpression */: { + case 207 /* SyntaxKind.ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -132914,41 +133606,41 @@ var ts; } return undefined; } - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 285 /* JsxAttribute */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 285 /* SyntaxKind.JsxAttribute */: if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? parent.parent : node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `require(""` or `import("")`) - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 277 /* ExternalModuleReference */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 277 /* SyntaxKind.ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } function fromContextualType() { // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" - return { kind: 2 /* Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; } } function walkUpParentheses(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -132975,14 +133667,14 @@ var ts; type = propType; } } - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* TypeFlags.String */); return getStringLiteralTypes(type, uniques); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: isNewIdentifier }; } function stringLiteralCompletionsFromProperties(type) { return type && { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; @@ -132991,10 +133683,10 @@ var ts; var contextualType = checker.getContextualType(objectLiteralExpression); if (!contextualType) return undefined; - var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* Completions */); + var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* ContextFlags.Completions */); var symbols = Completions.getPropertiesForObjectExpression(contextualType, completionsType, objectLiteralExpression, checker); return { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: symbols, hasIndexSignature: ts.hasIndexSignature(contextualType) }; @@ -133005,13 +133697,13 @@ var ts; return ts.emptyArray; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : - type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; + type.isStringLiteral() && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; } function directoryResult(name) { - return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); + return nameAndKind(name, "directory" /* ScriptElementKind.directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); @@ -133026,18 +133718,19 @@ var ts; } function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) { var literalValue = ts.normalizeSlashes(node.text); + var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption()) - : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker); function getIncludeExtensionOption() { var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; - return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */; + return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */ : 0 /* IncludeExtensionsOption.Exclude */; } } function getExtensionOptions(compilerOptions, includeExtensionsOption) { - if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; } + if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* IncludeExtensionsOption.Exclude */; } return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption }; } function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, includeExtensions) { @@ -133046,7 +133739,7 @@ var ts; return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } else { - return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath); + return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values()); } } function isEmitResolutionKindUsingNodeModules(compilerOptions) { @@ -133082,7 +133775,7 @@ var ts; var basePath = compilerOptions.project || host.getCurrentDirectory(); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase); - return ts.flatMap(baseDirectories, function (baseDirectory) { return getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude); }); + return ts.flatMap(baseDirectories, function (baseDirectory) { return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values()); }); } var IncludeExtensionsOption; (function (IncludeExtensionsOption) { @@ -133093,10 +133786,9 @@ var ts; /** * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) { - var _b; - var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption; - if (result === void 0) { result = []; } + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensionOptions, host, exclude, result) { + var _a; + if (result === void 0) { result = createNameAndKindSet(); } if (fragment === undefined) { fragment = ""; } @@ -133120,11 +133812,11 @@ var ts; var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; if (typeof typesVersions === "object") { - var versionPaths = (_b = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _b === void 0 ? void 0 : _b.paths; + var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths; if (versionPaths) { var packageDirectory = ts.getDirectoryPath(packageJsonPath); var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length); - if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) { + if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) { // A true result means one of the `versionPaths` was matched, which will block relative resolution // to files and folders from here. All reachable paths given the pattern match are already added. return result; @@ -133136,39 +133828,17 @@ var ts; if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = new ts.Map(); // maps file to its extension for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var filePath = files_1[_i]; filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* Comparison.EqualTo */) { continue; } - var foundFileName = void 0; - var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings()); - if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) { - foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath)); - foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); - } - else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) { - foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension); - foundFiles.set(foundFileName, outputExtension); - } - else { - foundFileName = ts.getBaseFileName(filePath); - foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); - } + var _b = getFilenameWithExtensionOption(ts.getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _b.name, extension = _b.extension; + result.add(nameAndKind(name, "script" /* ScriptElementKind.scriptElement */, extension)); } - foundFiles.forEach(function (ext, foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); - }); } // If possible, get folder completion as well var directories = ts.tryGetDirectories(host, baseDirectory); @@ -133177,27 +133847,52 @@ var ts; var directory = directories_1[_c]; var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); if (directoryName !== "@types") { - result.push(directoryResult(directoryName)); + result.add(directoryResult(directoryName)); } } } return result; } + function getFilenameWithExtensionOption(name, compilerOptions, includeExtensionsOption) { + var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions); + if (includeExtensionsOption === 0 /* IncludeExtensionsOption.Exclude */ && !ts.fileExtensionIsOneOf(name, [".json" /* Extension.Json */, ".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) { + return { name: ts.removeFileExtension(name), extension: ts.tryGetExtensionFromPath(name) }; + } + else if ((ts.fileExtensionIsOneOf(name, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */]) || includeExtensionsOption === 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */) && outputExtension) { + return { name: ts.changeExtension(name, outputExtension), extension: outputExtension }; + } + else { + return { name: name, extension: ts.tryGetExtensionFromPath(name) }; + } + } /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */ - function addCompletionEntriesFromPaths(result, fragment, baseDirectory, fileExtensions, paths, host) { - var _a; + function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) { + var getPatternsForKey = function (key) { return paths[key]; }; + var comparePaths = function (a, b) { + var patternA = ts.tryParsePattern(a); + var patternB = ts.tryParsePattern(b); + var lengthA = typeof patternA === "object" ? patternA.prefix.length : a.length; + var lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length; + return ts.compareValues(lengthB, lengthA); + }; + return addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, ts.getOwnKeys(paths), getPatternsForKey, comparePaths); + } + /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */ + function addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths) { var pathResults = []; - var matchedPathPrefixLength = -1; - for (var path in paths) { - if (!ts.hasProperty(paths, path)) + var matchedPath; + for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { + var key = keys_1[_i]; + if (key === ".") continue; - var patterns = paths[path]; + var keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./" + var patterns = getPatternsForKey(key); if (patterns) { - var pathPattern = ts.tryParsePattern(path); + var pathPattern = ts.tryParsePattern(keyWithoutLeadingDotSlash); if (!pathPattern) continue; var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment); - var isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength); + var isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === -1 /* Comparison.LessThan */); if (isLongestMatch) { // If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g. // for `import {} from "some-package/|"` with a typesVersions: @@ -133210,13 +133905,13 @@ var ts; // added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both // ./dist/foo and ./foo, when only the latter will actually be resolvable. // See pathCompletionsTypesVersionsWildcard6.ts. - matchedPathPrefixLength = pathPattern.prefix.length; + matchedPath = key; pathResults = pathResults.filter(function (r) { return !r.matchedPattern; }); } - if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) { + if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== 1 /* Comparison.GreaterThan */) { pathResults.push({ matchedPattern: isMatch, - results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host) + results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host) .map(function (_a) { var name = _a.name, kind = _a.kind, extension = _a.extension; return nameAndKind(name, kind, extension); @@ -133225,10 +133920,8 @@ var ts; } } } - var equatePaths = ((_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host)) ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive; - var equateResults = function (a, b) { return equatePaths(a.name, b.name); }; - pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); }); - return matchedPathPrefixLength > -1; + pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (r) { return result.add(r); }); }); + return matchedPath !== undefined; } /** * Check all of the declared modules and those in node modules. Possible sources of modules: @@ -133237,22 +133930,22 @@ var ts; * Modules from node_modules (i.e. those listed in package.json) * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions */ - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) { + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, includeExtensionsOption, typeChecker) { var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result = []; - var extensionOptions = getExtensionOptions(compilerOptions); + var result = createNameAndKindSet(); + var extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption); if (baseUrl) { var projectDir = compilerOptions.project || host.getCurrentDirectory(); var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl)); getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result); if (paths) { - addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host); + addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths); } } var fragmentDirectory = getFragmentDirectory(fragment); for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) { var ambientName = _a[_i]; - result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.add(nameAndKind(ambientName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (isEmitResolutionKindUsingNodeModules(compilerOptions)) { @@ -133260,15 +133953,13 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_3 = function (moduleName) { - if (!result.some(function (entry) { return entry.name === moduleName; })) { - foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); - } - }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { var moduleName = _c[_b]; - _loop_3(moduleName); + var moduleResult = nameAndKind(moduleName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined); + if (!result.has(moduleResult.name)) { + foundGlobal = true; + result.add(moduleResult); + } } } if (!foundGlobal) { @@ -133294,39 +133985,19 @@ var ts; } packagePath = ts.combinePaths(packagePath, subName); } - var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json"); + var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath); + var packageFile = ts.combinePaths(packageDirectory, "package.json"); if (ts.tryFileExists(host, packageFile)) { var packageJson = ts.readJson(packageFile, host); - var exports = packageJson.exports; - if (exports) { - if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null + var exports_1 = packageJson.exports; + if (exports_1) { + if (typeof exports_1 !== "object" || exports_1 === null) { // eslint-disable-line no-null/no-null return; // null exports or entrypoint only, no sub-modules available } - var keys = ts.getOwnKeys(exports); - var fragmentSubpath_1 = components.join("/"); - var processedKeys = ts.mapDefined(keys, function (k) { - if (k === ".") - return undefined; - if (!ts.startsWith(k, "./")) - return undefined; - var subpath = k.substring(2); - if (!ts.startsWith(subpath, fragmentSubpath_1)) - return undefined; - // subpath is a valid export (barring conditions, which we don't currently check here) - if (!ts.stringContains(subpath, "*")) { - return subpath; - } - // pattern export - only return everything up to the `*`, so the user can autocomplete, then - // keep filling in the pattern (we could speculatively return a list of options by hitting disk, - // but conditions will make that somewhat awkward, as each condition may have a different set of possible - // options for the `*`. - return subpath.slice(0, subpath.indexOf("*")); - }); - ts.forEach(processedKeys, function (k) { - if (k) { - result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined)); - } - }); + var keys = ts.getOwnKeys(exports_1); + var fragmentSubpath = components.join("/") + (components.length && ts.hasTrailingDirectorySeparator(fragment) ? "/" : ""); + var conditions_1 = mode === ts.ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"]; + addCompletionEntriesFromPathsOrExports(result, fragmentSubpath, packageDirectory, extensionOptions, host, keys, function (key) { return ts.singleElementArray(getPatternFromFirstMatchingCondition(exports_1[key], conditions_1)); }, ts.comparePatternKeys); return; } } @@ -133336,31 +134007,44 @@ var ts; ts.forEachAncestorDirectory(scriptPath, ancestorLookup); } } - return result; + return ts.arrayFrom(result.values()); + } + function getPatternFromFirstMatchingCondition(target, conditions) { + if (typeof target === "string") { + return target; + } + if (target && typeof target === "object" && !ts.isArray(target)) { + for (var condition in target) { + if (condition === "default" || conditions.indexOf(condition) > -1 || ts.isApplicableVersionedTypesKey(conditions, condition)) { + var pattern = target[condition]; + return getPatternFromFirstMatchingCondition(pattern, conditions); + } + } + } } function getFragmentDirectory(fragment) { return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; } - function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { + function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. - return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray; + return !ts.stringContains(path, "*") ? justPathMappingName(path, "script" /* ScriptElementKind.scriptElement */) : ts.emptyArray; } var pathPrefix = path.slice(0, path.length - 1); var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix); if (remainingFragment === undefined) { var starIsFullPathComponent = path[path.length - 2] === "/"; - return starIsFullPathComponent ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", baseUrl, pattern, fileExtensions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) { + return starIsFullPathComponent ? justPathMappingName(pathPrefix, "directory" /* ScriptElementKind.directory */) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) { var name = _a.name, rest = __rest(_a, ["name"]); return (__assign({ name: pathPrefix + name }, rest)); }); }); } - return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); - function justPathMappingName(name) { - return ts.startsWith(name, fragment) ? [directoryResult(ts.removeTrailingDirectorySeparator(name))] : ts.emptyArray; + return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, host); }); + function justPathMappingName(name, kind) { + return ts.startsWith(name, fragment) ? [{ name: ts.removeTrailingDirectorySeparator(name), kind: kind, extension: undefined }] : ts.emptyArray; } } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, host) { if (!host.readDirectory) { return undefined; } @@ -133379,21 +134063,33 @@ var ts; var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory; var normalizedSuffix = ts.normalizePath(parsed.suffix); // Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b". - var baseDirectory = ts.normalizePath(ts.combinePaths(baseUrl, expandedPrefixDirectory)); + var baseDirectory = ts.normalizePath(ts.combinePaths(packageDirectory, expandedPrefixDirectory)); var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { - var extension = ts.tryGetExtensionFromPath(match); - var name = trimPrefixAndSuffix(match); - return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); - }); - var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { - var name = trimPrefixAndSuffix(dir); - return name === undefined ? undefined : directoryResult(name); + // If we have a suffix, then we read the directory all the way down to avoid returning completions for + // directories that don't contain files that would match the suffix. A previous comment here was concerned + // about the case where `normalizedSuffix` includes a `?` character, which should be interpreted literally, + // but will match any single character as part of the `include` pattern in `tryReadDirectory`. This is not + // a problem, because (in the extremely unusual circumstance where the suffix has a `?` in it) a `?` + // interpreted as "any character" can only return *too many* results as compared to the literal + // interpretation, so we can filter those superfluous results out via `trimPrefixAndSuffix` as we've always + // done. + var includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*"; + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var trimmedWithPattern = trimPrefixAndSuffix(match); + if (trimmedWithPattern) { + if (containsSlash(trimmedWithPattern)) { + return directoryResult(ts.getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]); + } + var _a = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _a.name, extension = _a.extension; + return nameAndKind(name, "script" /* ScriptElementKind.scriptElement */, extension); + } }); + // If we had a suffix, we already recursively searched for all possible files that could match + // it and returned the directories leading to those files. Otherwise, assume any directory could + // have something valid to import. + var directories = normalizedSuffix + ? ts.emptyArray + : ts.mapDefined(ts.tryGetDirectories(host, baseDirectory), function (dir) { return dir === "node_modules" ? undefined : directoryResult(dir); }); return __spreadArray(__spreadArray([], matches, true), directories, true); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); @@ -133433,13 +134129,13 @@ var ts; } var prefix = match[1], kind = match[2], toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path) + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* IncludeExtensionsOption.Include */), host, sourceFile.path) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) : ts.Debug.fail(); - return addReplacementSpans(toComplete, range.pos + prefix.length, names); + return addReplacementSpans(toComplete, range.pos + prefix.length, ts.arrayFrom(names.values())); } function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) { - if (result === void 0) { result = []; } + if (result === void 0) { result = createNameAndKindSet(); } // Check for typings specified in compiler options var seen = new ts.Map(); var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; @@ -133464,7 +134160,7 @@ var ts; continue; if (fragmentDirectory === undefined) { if (!seen.has(packageName)) { - result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.add(nameAndKind(packageName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); seen.set(packageName, true); } } @@ -133506,14 +134202,14 @@ var ts; var offset = index !== -1 ? index + 1 : 0; // If the range is an identifier, span is unnecessary. var length = text.length - offset; - return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); + return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ScriptTarget.ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); } // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* CharacterCodes.dot */ ? 2 : 1; var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + return slashCharCode === 47 /* CharacterCodes.slash */ || slashCharCode === 92 /* CharacterCodes.backslash */; } return false; } @@ -133570,7 +134266,7 @@ var ts; return "z" + sortText; }, ObjectLiteralProperty: function (presetSortText, symbolDisplayName) { - return presetSortText + "\0" + symbolDisplayName + "\0"; + return "".concat(presetSortText, "\0").concat(symbolDisplayName, "\0"); }, SortBelow: function (sortText) { return sortText + "1"; @@ -133612,16 +134308,16 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsThisType(origin) { - return !!(origin.kind & 1 /* ThisType */); + return !!(origin.kind & 1 /* SymbolOriginInfoKind.ThisType */); } function originIsSymbolMember(origin) { - return !!(origin.kind & 2 /* SymbolMember */); + return !!(origin.kind & 2 /* SymbolOriginInfoKind.SymbolMember */); } function originIsExport(origin) { - return !!(origin && origin.kind & 4 /* Export */); + return !!(origin && origin.kind & 4 /* SymbolOriginInfoKind.Export */); } function originIsResolvedExport(origin) { - return !!(origin && origin.kind === 32 /* ResolvedExport */); + return !!(origin && origin.kind === 32 /* SymbolOriginInfoKind.ResolvedExport */); } function originIncludesSymbolName(origin) { return originIsExport(origin) || originIsResolvedExport(origin); @@ -133630,16 +134326,16 @@ var ts; return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { - return !!(origin.kind & 8 /* Promise */); + return !!(origin.kind & 8 /* SymbolOriginInfoKind.Promise */); } function originIsNullableMember(origin) { - return !!(origin.kind & 16 /* Nullable */); + return !!(origin.kind & 16 /* SymbolOriginInfoKind.Nullable */); } function originIsTypeOnlyAlias(origin) { - return !!(origin && origin.kind & 64 /* TypeOnlyAlias */); + return !!(origin && origin.kind & 64 /* SymbolOriginInfoKind.TypeOnlyAlias */); } function originIsObjectLiteralMethod(origin) { - return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */); + return !!(origin && origin.kind & 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */); } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { @@ -133680,10 +134376,10 @@ var ts; resolvedAny: function () { return resolvedCount > 0; }, resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; }, }); - var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : ""; - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, logPrefix + ": resolved " + resolvedCount + " module specifiers, plus " + ambientCount + " ambient and " + resolvedFromCacheCount + " from cache" + hitRateMessage); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (skippedAny ? "incomplete" : "complete")); - (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start)); + var hitRateMessage = cacheAttemptCount ? " (".concat((resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1), "% hit rate)") : ""; + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "".concat(logPrefix, ": resolved ").concat(resolvedCount, " module specifiers, plus ").concat(ambientCount, " ambient and ").concat(resolvedFromCacheCount, " from cache").concat(hitRateMessage)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "".concat(logPrefix, ": response is ").concat(skippedAny ? "incomplete" : "complete")); + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "".concat(logPrefix, ": ").concat(ts.timestamp() - start)); return result; function tryResolve(exportInfo, symbolName, isFromAmbientModule) { if (isFromAmbientModule) { @@ -133726,7 +134422,7 @@ var ts; // we can continue it from the cached previous response. var compilerOptions = program.getCompilerOptions(); var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined; - if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { + if (incompleteCompletionsCache && completionKind === 3 /* CompletionTriggerKind.TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { var incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken); if (incompleteContinuation) { return incompleteContinuation; @@ -133740,7 +134436,7 @@ var ts; return stringCompletions; } if (previousToken && ts.isBreakOrContinueStatement(previousToken.parent) - && (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) { + && (previousToken.kind === 81 /* SyntaxKind.BreakKeyword */ || previousToken.kind === 86 /* SyntaxKind.ContinueKeyword */ || previousToken.kind === 79 /* SyntaxKind.Identifier */)) { return getLabelCompletionAtPosition(previousToken.parent); } var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken); @@ -133748,21 +134444,21 @@ var ts; return undefined; } switch (completionData.kind) { - case 0 /* Data */: + case 0 /* CompletionDataKind.Data */: var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position); if (response === null || response === void 0 ? void 0 : response.isIncomplete) { incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response); } return response; - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: // If the current position is a jsDoc tag name, only tag names should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagNameCompletions()); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: // If the current position is a jsDoc tag, only tags should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); - case 4 /* Keywords */: + case 4 /* CompletionDataKind.Keywords */: return specificKeywordCompletionInfo(completionData.keywordCompletions, completionData.isNewIdentifierLocation); default: return ts.Debug.assertNever(completionData); @@ -133779,16 +134475,16 @@ var ts; function compareCompletionEntries(entryInArray, entryToInsert) { var _a, _b; var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText); - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name); } - if (result === 0 /* EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { + if (result === 0 /* Comparison.EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { // Sort same-named auto-imports by module specifier result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier); } - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { // Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first. - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } return result; } @@ -133819,10 +134515,10 @@ var ts; if (result === "skipped") return entry; if (!result || result === "failed") { - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '" + entry.name + "' from '" + entry.source + "'"); + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '".concat(entry.name, "' from '").concat(entry.source, "'")); return undefined; } - var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); + var newOrigin = __assign(__assign({}, origin), { kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); // Mutating for performance... feels sketchy but nobody else uses the cache, // so why bother allocating a bunch of new objects? entry.data = originToCompletionEntryData(newOrigin); @@ -133836,7 +134532,7 @@ var ts; return entries; }); previousResponse.entries = newEntries; - previousResponse.flags = (previousResponse.flags || 0) | 4 /* IsContinuation */; + previousResponse.flags = (previousResponse.flags || 0) | 4 /* CompletionInfoFlags.IsContinuation */; return previousResponse; } function jsdocCompletionInfo(entries) { @@ -133845,8 +134541,8 @@ var ts; function keywordToCompletionEntry(keyword) { return { name: ts.tokenToString(keyword), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }; } @@ -133860,62 +134556,61 @@ var ts; } function keywordCompletionData(keywordFilters, filterOutTsOnlyKeywords, isNewIdentifierLocation) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: getKeywordCompletions(keywordFilters, filterOutTsOnlyKeywords), isNewIdentifierLocation: isNewIdentifierLocation, }; } function keywordFiltersFromSyntaxKind(keywordCompletion) { switch (keywordCompletion) { - case 152 /* TypeKeyword */: return 8 /* TypeKeyword */; + case 152 /* SyntaxKind.TypeKeyword */: return 8 /* KeywordCompletionFilters.TypeKeyword */; default: ts.Debug.fail("Unknown mapping from SyntaxKind to KeywordCompletionFilters"); } } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) { var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant - if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); if (completionInfo) { return completionInfo; } } var entries = ts.createSortedArray(); - if (isUncheckedFile(sourceFile, compilerOptions)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); - getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); - } - else { - if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { - return undefined; - } - getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); + var isChecked = isCheckedFile(sourceFile, compilerOptions); + if (isChecked && !isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* KeywordCompletionFilters.None */) { + return undefined; } - if (keywordFilters !== 0 /* None */) { - var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; })); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); + if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) { for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) { var keywordEntry = _a[_i]; - if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) { + if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) { + uniqueNames.add(keywordEntry.name); ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } } - var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) { var keywordEntry = _c[_b]; - if (!entryNames.has(keywordEntry.name)) { + if (!uniqueNames.has(keywordEntry.name)) { + uniqueNames.add(keywordEntry.name); ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) { var literal = literals_1[_d]; - ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true); + var literalEntry = createCompletionEntryForLiteral(sourceFile, preferences, literal); + uniqueNames.add(literalEntry.name); + ts.insertSorted(entries, literalEntry, compareCompletionEntries, /*allowDuplicates*/ true); + } + if (!isChecked) { + getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); } return { flags: completionData.flags, @@ -133927,14 +134622,14 @@ var ts; entries: entries, }; } - function isUncheckedFile(sourceFile, compilerOptions) { - return ts.isSourceFileJS(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); + function isCheckedFile(sourceFile, compilerOptions) { + return !ts.isSourceFileJS(sourceFile) || !!ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); } function isMemberCompletionKind(kind) { switch (kind) { - case 0 /* ObjectPropertyDeclaration */: - case 3 /* MemberLike */: - case 2 /* PropertyAccess */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: + case 3 /* CompletionKind.MemberLike */: + case 2 /* CompletionKind.PropertyAccess */: return true; default: return false; @@ -133944,12 +134639,12 @@ var ts; // We wanna walk up the tree till we find a JSX closing element var jsxClosingElement = ts.findAncestor(location, function (node) { switch (node.kind) { - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return true; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return false; default: return "quit"; @@ -133968,14 +134663,14 @@ var ts; // var x = // var y = // the completion list at "1" and "2" will contain "MainComponent.Child" with a replacement span of closing tag name - var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* SyntaxKind.GreaterThanToken */, sourceFile); var tagName = jsxClosingElement.parent.openingElement.tagName; var closingTag = tagName.getText(sourceFile); var fullClosingTag = closingTag + (hasClosingAngleBracket ? "" : ">"); var replacementSpan = ts.createTextSpanFromNode(jsxClosingElement.tagName); var entry = { name: fullClosingTag, - kind: "class" /* classElement */, + kind: "class" /* ScriptElementKind.classElement */, kindModifiers: undefined, sortText: Completions.SortText.LocationPriority, }; @@ -133994,7 +134689,7 @@ var ts; uniqueNames.add(realName); ts.insertSorted(entries, { name: realName, - kind: "warning" /* warning */, + kind: "warning" /* ScriptElementKind.warning */, kindModifiers: "", sortText: Completions.SortText.JavascriptIdentifiers, isFromUncheckedFile: true @@ -134007,7 +134702,7 @@ var ts; ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal); } function createCompletionEntryForLiteral(sourceFile, preferences, literal) { - return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority }; + return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority }; } function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; @@ -134024,18 +134719,18 @@ var ts; var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { insertText = needsConvertPropertyAccess - ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(sourceFile, preferences, name) + "]" - : "this" + (insertQuestionDot ? "?." : ".") + name; + ? "this".concat(insertQuestionDot ? "?." : "", "[").concat(quotePropertyName(sourceFile, preferences, name), "]") + : "this".concat(insertQuestionDot ? "?." : ".").concat(name); } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { - insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(sourceFile, preferences, name) + "]" : "[" + name + "]" : name; + insertText = useBraces ? needsConvertPropertyAccess ? "[".concat(quotePropertyName(sourceFile, preferences, name), "]") : "[".concat(name, "]") : name; if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { - insertText = "?." + insertText; + insertText = "?.".concat(insertText); } - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || - ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* SyntaxKind.DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* SyntaxKind.QuestionDotToken */, sourceFile); if (!dot) { return undefined; } @@ -134046,7 +134741,7 @@ var ts; if (isJsxInitializer) { if (insertText === undefined) insertText = name; - insertText = "{" + insertText + "}"; + insertText = "{".concat(insertText, "}"); if (typeof isJsxInitializer !== "boolean") { replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } @@ -134059,8 +134754,8 @@ var ts; if (precedingToken && ts.positionIsASICandidate(precedingToken.end, precedingToken.parent, sourceFile)) { awaitText = ";"; } - awaitText += "(await " + propertyAccessToConvert.expression.getText() + ")"; - insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + awaitText += "(await ".concat(propertyAccessToConvert.expression.getText(), ")"); + insertText = needsConvertPropertyAccess ? "".concat(awaitText).concat(insertText) : "".concat(awaitText).concat(insertQuestionDot ? "?." : ".").concat(insertText); replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } if (originIsResolvedExport(origin)) { @@ -134070,12 +134765,12 @@ var ts; isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; } } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { hasAction = true; } if (preferences.includeCompletionsWithClassMemberSnippets && preferences.includeCompletionsWithInsertText && - completionKind === 3 /* MemberLike */ && + completionKind === 3 /* CompletionKind.MemberLike */ && isClassLikeMemberCompletion(symbol, location)) { var importAdder = void 0; (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan); @@ -134099,11 +134794,11 @@ var ts; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. if (preferences.jsxAttributeCompletionStyle === "auto" - && !(type.flags & 528 /* BooleanLike */) - && !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) { - if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) { + && !(type.flags & 528 /* TypeFlags.BooleanLike */) + && !(type.flags & 1048576 /* TypeFlags.Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* TypeFlags.BooleanLike */); }))) { + if (type.flags & 402653316 /* TypeFlags.StringLike */ || (type.flags & 1048576 /* TypeFlags.Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* TypeFlags.StringLike */ | 32768 /* TypeFlags.Undefined */)); }))) { // If is string like or undefined use quotes - insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1"); + insertText = "".concat(ts.escapeSnippetText(name), "=").concat(ts.quote(sourceFile, preferences, "$1")); isSnippet = true; } else { @@ -134112,7 +134807,7 @@ var ts; } } if (useBraces_1) { - insertText = ts.escapeSnippetText(name) + "={$1}"; + insertText = "".concat(ts.escapeSnippetText(name), "={$1}"); isSnippet = true; } } @@ -134154,8 +134849,8 @@ var ts; return false; } // Completion symbol must be for a class member. - var memberFlags = 106500 /* ClassMember */ - & 900095 /* EnumMemberExcludes */; + var memberFlags = 106500 /* SymbolFlags.ClassMember */ + & 900095 /* SymbolFlags.EnumMemberExcludes */; /* In `class C { | @@ -134214,16 +134909,16 @@ var ts; // Note: this assumes we won't have more than one body in the completion nodes, which should be the case. var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; // Whether the suggested member should be abstract. // e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`. var _a = getPresentModifiers(contextToken), presentModifiers = _a.modifiers, modifiersSpan = _a.span; - var isAbstract = !!(presentModifiers & 128 /* Abstract */); + var isAbstract = !!(presentModifiers & 128 /* ModifierFlags.Abstract */); var completionNodes = []; ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder, // `addNewNodeForMemberSymbol` calls this callback function for each new member node @@ -134234,13 +134929,13 @@ var ts; // - One node; // - More than one node if the member is overloaded (e.g. a method with overload signatures). function (node) { - var requiredModifiers = 0 /* None */; + var requiredModifiers = 0 /* ModifierFlags.None */; if (isAbstract) { - requiredModifiers |= 128 /* Abstract */; + requiredModifiers |= 128 /* ModifierFlags.Abstract */; } if (ts.isClassElement(node) - && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) { - requiredModifiers |= 16384 /* Override */; + && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* MemberOverrideStatus.NeedsOverride */) { + requiredModifiers |= 16384 /* ModifierFlags.Override */; } if (!completionNodes.length) { // Keep track of added missing required modifiers and modifiers already present. @@ -134251,9 +134946,9 @@ var ts; } node = ts.factory.updateModifiers(node, modifiers); completionNodes.push(node); - }, body, 2 /* Property */, isAbstract); + }, body, 2 /* codefix.PreserveOptionalFlags.Property */, isAbstract); if (completionNodes.length) { - var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */; + var format = 1 /* ListFormat.MultiLine */ | 131072 /* ListFormat.NoTrailingNewLine */; replacementSpan = modifiersSpan; // If we have access to formatting settings, we print the nodes using the emitter, // and then format the printed text. @@ -134268,9 +134963,9 @@ var ts; } function getPresentModifiers(contextToken) { if (!contextToken) { - return { modifiers: 0 /* None */ }; + return { modifiers: 0 /* ModifierFlags.None */ }; } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; var span; var contextMod; /* @@ -134297,7 +134992,7 @@ var ts; span = ts.createTextSpanFromNode(contextToken); } if (ts.isPropertyDeclaration(contextToken.parent)) { - modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers) & 125951 /* Modifier */; + modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers) & 125951 /* ModifierFlags.Modifier */; span = ts.createTextSpanFromNode(contextToken.parent); } return { modifiers: modifiers, span: span }; @@ -134327,10 +135022,10 @@ var ts; newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))), }); if (formatContext) { - insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); + insertText = printer.printAndFormatSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); } else { - insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); + insertText = printer.printSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); } var signaturePrinter = ts.createPrinter({ removeComments: true, @@ -134343,7 +135038,7 @@ var ts; var methodSignature = ts.factory.createMethodSignature( /*modifiers*/ undefined, /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type); - var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) }; + var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) }; return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails }; } ; @@ -134357,18 +135052,18 @@ var ts; var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false); var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + var builderFlags = 33554432 /* NodeBuilderFlags.OmitThisParameter */ | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: { - var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10 - ? checker.getUnionType(type.types, 2 /* Subtype */) + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: { + var effectiveType = type.flags & 1048576 /* TypeFlags.Union */ && type.types.length < 10 + ? checker.getUnionType(type.types, 2 /* UnionReduction.Subtype */) : type; - if (effectiveType.flags & 1048576 /* Union */) { + if (effectiveType.flags & 1048576 /* TypeFlags.Union */) { // Only offer the completion if there's a single function type component. - var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; }); + var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; }); if (functionTypes.length === 1) { effectiveType = functionTypes[0]; } @@ -134376,7 +135071,7 @@ var ts; return undefined; } } - var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */); + var signatures = checker.getSignaturesOfType(effectiveType, 0 /* SignatureKind.Call */); if (signatures.length !== 1) { // We don't support overloads in object literals. return undefined; @@ -134389,7 +135084,7 @@ var ts; if (preferences.includeCompletionsWithSnippetText) { var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); @@ -134489,11 +135184,11 @@ var ts; return unresolvedData; } function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) { - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; var isFromPackageJson = !!data.isPackageJsonImport; if (completionEntryDataIsResolved(data)) { var resolvedOrigin = { - kind: 32 /* ResolvedExport */, + kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, exportName: data.exportName, moduleSpecifier: data.moduleSpecifier, symbolName: completionName, @@ -134505,7 +135200,7 @@ var ts; return resolvedOrigin; } var unresolvedOrigin = { - kind: 4 /* Export */, + kind: 4 /* SymbolOriginInfoKind.Export */, exportName: data.exportName, exportMapKey: data.exportMapKey, symbolName: completionName, @@ -134521,21 +135216,21 @@ var ts; var sourceFile = importCompletionNode.getSourceFile(); var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); - var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ : + origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ : + 0 /* ExportKind.Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true); var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly); var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken); - var topLevelTypeOnlyText = isTopLevelTypeOnly ? " " + ts.tokenToString(152 /* TypeKeyword */) + " " : " "; - var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(152 /* TypeKeyword */) + " " : ""; + var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : " "; + var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : ""; var suffix = useSemicolons ? ";" : ""; switch (importKind) { - case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; - case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix }; - case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix }; - case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix }; + case 3 /* ImportKind.CommonJS */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " = require(").concat(quotedModuleSpecifier, ")").concat(suffix) }; + case 1 /* ImportKind.Default */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 2 /* ImportKind.Namespace */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "* as ").concat(ts.escapeSnippetText(name), " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 0 /* ImportKind.Named */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "{ ").concat(importSpecifierTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " } from ").concat(quotedModuleSpecifier).concat(suffix) }; } } function quotePropertyName(sourceFile, preferences, name) { @@ -134546,7 +135241,7 @@ var ts; } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || - !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; + !!(localSymbol.flags & 1048576 /* SymbolFlags.ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; } function getSourceFromOrigin(origin) { if (originIsExport(origin)) { @@ -134555,10 +135250,10 @@ var ts; if (originIsResolvedExport(origin)) { return origin.moduleSpecifier; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* SymbolOriginInfoKind.ThisType */) { return CompletionSource.ThisProperty; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { return CompletionSource.TypeOnlyAlias; } } @@ -134577,7 +135272,7 @@ var ts; var symbol = symbols[i]; var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); - if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { + if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* CompletionKind.Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; @@ -134630,7 +135325,7 @@ var ts; allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin); // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(allFlags & 1920 /* Namespace */); + return !!(allFlags & 1920 /* SymbolFlags.Namespace */); } if (isTypeOnlyLocation) { // It's a type, but you can reach it by namespace.type as well @@ -134638,7 +135333,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(allFlags & 111551 /* Value */); + return !!(allFlags & 111551 /* SymbolFlags.Value */); } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; @@ -134662,8 +135357,8 @@ var ts; uniques.set(name, true); entries.push({ name: name, - kindModifiers: "" /* none */, - kind: "label" /* label */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "label" /* ScriptElementKind.label */, sortText: Completions.SortText.LocationPriority }); } @@ -134694,7 +135389,7 @@ var ts; if (!completionData) { return { type: "none" }; } - if (completionData.kind !== 0 /* Data */) { + if (completionData.kind !== 0 /* CompletionDataKind.Data */) { return { type: "request", request: completionData }; } var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; @@ -134708,8 +135403,8 @@ var ts; return ts.firstDefined(symbols, function (symbol, index) { var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); - return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ - || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */) + return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* SymbolFlags.ClassMember */ + || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */) || getSourceFromOrigin(origin) === entryId.source) ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; @@ -134729,14 +135424,14 @@ var ts; case "request": { var request = symbolCompletion.request; switch (request.kind) { - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: return ts.JsDoc.getJSDocTagNameCompletionDetails(name); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: return ts.JsDoc.getJSDocTagCompletionDetails(name); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); - case 4 /* Keywords */: - return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + case 4 /* CompletionDataKind.Keywords */: + return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } @@ -134748,22 +135443,22 @@ var ts; } case "literal": { var literal = symbolCompletion.literal; - return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); + return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* ScriptElementKind.string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. - return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: ts.Debug.assertNever(symbolCompletion); } } Completions.getCompletionEntryDetails = getCompletionEntryDetails; function createSimpleDetails(name, kind, kind2) { - return createCompletionDetails(name, "" /* none */, kind, [ts.displayPart(name, kind2)]); + return createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, kind, [ts.displayPart(name, kind2)]); } function createCompletionDetailsForSymbol(symbol, checker, sourceFile, location, cancellationToken, codeActions, sourceDisplay) { var _a = checker.runWithCancellationToken(cancellationToken, function (checker) { - return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* All */); + return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* SemanticMeaning.All */); }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(checker, symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } @@ -134803,7 +135498,7 @@ var ts; var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); var moduleSymbol = origin.moduleSymbol; var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); + var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier); return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -134835,7 +135530,7 @@ var ts; return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { var symbol = type && type.symbol; // Don't include make a recommended completion for an abstract class - return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol)) + return symbol && (symbol.flags & (8 /* SymbolFlags.EnumMember */ | 384 /* SymbolFlags.Enum */ | 32 /* SymbolFlags.Class */) && !ts.isAbstractConstructorSymbol(symbol)) ? getFirstSymbolInChain(symbol, previousToken, checker) : undefined; }); @@ -134843,31 +135538,31 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return checker.getContextualType(parent); - case 82 /* CaseKeyword */: + case 82 /* SyntaxKind.CaseKeyword */: var caseClause = ts.tryCast(parent, ts.isCaseClause); return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? // At `,`, treat this as the next argument after the comma. - checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* SyntaxKind.CommaToken */ ? 1 : 0)) : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side checker.getTypeAtLocation(parent.left) : @@ -134875,18 +135570,18 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* SymbolFlags.All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { var _a; - return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; })); + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SyntaxKind.SourceFile */; })); } function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) { var typeChecker = program.getTypeChecker(); - var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions); + var inCheckedFile = isCheckedFile(sourceFile, compilerOptions); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) @@ -134898,10 +135593,10 @@ var ts; var isInSnippetScope = false; if (insideComment) { if (ts.hasDocComment(sourceFile, position)) { - if (sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + if (sourceFile.text.charCodeAt(position - 1) === 64 /* CharacterCodes.at */) { // The current position is next to the '@' sign, when no tag name being provided yet. // Provide a full list of tag names - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } else { // When completion is requested without "@", we will have check to make sure that @@ -134922,7 +135617,7 @@ var ts; // */ var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) { - return { kind: 2 /* JsDocTag */ }; + return { kind: 2 /* CompletionDataKind.JsDocTag */ }; } } } @@ -134932,21 +135627,21 @@ var ts; var tag = getJsDocTagAtPosition(currentToken, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } var typeExpression = tryGetTypeExpressionFromTag(tag); if (typeExpression) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 347 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 347 /* SyntaxKind.JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression); } } if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) { - return { kind: 3 /* JsDocParameterName */, tag: tag }; + return { kind: 3 /* CompletionDataKind.JsDocParameterName */, tag: tag }; } } if (!insideJsDocTagTypeExpression) { @@ -134977,16 +135672,16 @@ var ts; var isJsxIdentifierExpected = false; var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); - var keywordFilters = 0 /* None */; + var keywordFilters = 0 /* KeywordCompletionFilters.None */; var isNewIdentifierLocation = false; - var flags = 0 /* None */; + var flags = 0 /* CompletionInfoFlags.None */; if (contextToken) { var importStatementCompletion = getImportStatementCompletionInfo(contextToken); isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation; if (importStatementCompletion.keywordCompletion) { if (importStatementCompletion.isKeywordOnlyCompletion) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)], isNewIdentifierLocation: isNewIdentifierLocation, }; @@ -134999,7 +135694,7 @@ var ts; // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients // to opt in with the `includeCompletionsForImportStatements` user preference. importCompletionNode = importStatementCompletion.replacementNode; - flags |= 2 /* IsImportStatementCompletion */; + flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */; } // Bail out if this is a known invalid completion location if (!importCompletionNode && isCompletionListBlocker(contextToken)) { @@ -135009,11 +135704,11 @@ var ts; : undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { - isRightOfDot = contextToken.kind === 24 /* DotToken */; - isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; + if (contextToken.kind === 24 /* SyntaxKind.DotToken */ || contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* SyntaxKind.DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert); @@ -135021,7 +135716,7 @@ var ts; ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && node.end === contextToken.pos && node.getChildCount(sourceFile) && - ts.last(node.getChildren(sourceFile)).kind !== 21 /* CloseParenToken */)) { + ts.last(node.getChildren(sourceFile)).kind !== 21 /* SyntaxKind.CloseParenToken */)) { // This is likely dot from incorrectly parsed expression and user is starting to write spread // eg: Math.min(./**/) // const x = function (./**/) {} @@ -135029,18 +135724,18 @@ var ts; return undefined; } break; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: node = parent.left; break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: node = parent.name; break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: node = parent; break; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: node = parent.getFirstToken(sourceFile); - ts.Debug.assert(node.kind === 100 /* ImportKeyword */ || node.kind === 103 /* NewKeyword */); + ts.Debug.assert(node.kind === 100 /* SyntaxKind.ImportKeyword */ || node.kind === 103 /* SyntaxKind.NewKeyword */); break; default: // There is nothing that precedes the dot, so this likely just a stray character @@ -135048,58 +135743,58 @@ var ts; return undefined; } } - else if (!importCompletionNode && sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) { // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 206 /* PropertyAccessExpression */) { + if (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 278 /* JsxElement */ || currentToken.parent.kind === 280 /* JsxOpeningElement */) { + case 31 /* SyntaxKind.GreaterThanToken */: + if (currentToken.parent.kind === 278 /* SyntaxKind.JsxElement */ || currentToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { location = currentToken; } break; - case 43 /* SlashToken */: - if (currentToken.parent.kind === 279 /* JsxSelfClosingElement */) { + case 43 /* SyntaxKind.SlashToken */: + if (currentToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 281 /* JsxClosingElement */: - if (contextToken.kind === 43 /* SlashToken */) { + case 281 /* SyntaxKind.JsxClosingElement */: + if (contextToken.kind === 43 /* SyntaxKind.SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: isJsxIdentifierExpected = true; - if (contextToken.kind === 29 /* LessThanToken */) { + if (contextToken.kind === 29 /* SyntaxKind.LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` - if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { + if (previousToken.kind === 19 /* SyntaxKind.CloseBraceToken */ && currentToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -135107,16 +135802,16 @@ var ts; break; } switch (previousToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: isJsxInitializer = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: isJsxIdentifierExpected = true; // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* SyntaxKind.EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -135125,7 +135820,7 @@ var ts; } } var semanticStart = ts.timestamp(); - var completionKind = 5 /* None */; + var completionKind = 5 /* CompletionKind.None */; var isNonContextualObjectLiteral = false; var hasUnresolvedAutoImports = false; // This also gets mutated in nested-functions after the return @@ -135145,8 +135840,8 @@ var ts; symbols = typeChecker.getJsxIntrinsicTagNamesAt(location); ts.Debug.assertEachIsDefined(symbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else if (isStartingCloseTag) { var tagName = contextToken.parent.parent.openingElement.tagName; @@ -135154,8 +135849,8 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the @@ -135169,10 +135864,10 @@ var ts; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); var contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker); - var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : undefined; }); + var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* TypeFlags.EnumLiteral */) ? t.value : undefined; }); var recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker); return { - kind: 0 /* Data */, + kind: 0 /* CompletionDataKind.Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, @@ -135197,13 +135892,13 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 345 /* JSDocTypedefTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return true; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return !!tag.constraint; default: return false; @@ -135212,13 +135907,13 @@ var ts; function tryGetTypeExpressionFromTag(tag) { if (isTagWithTypeExpression(tag)) { var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression; - return typeExpression && typeExpression.kind === 309 /* JSDocTypeExpression */ ? typeExpression : undefined; + return typeExpression && typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? typeExpression : undefined; } return undefined; } function getTypeScriptMemberSymbols() { // Right of dot member completion list - completionKind = 2 /* PropertyAccess */; + completionKind = 2 /* CompletionKind.PropertyAccess */; // Since this is qualified name check it's a type node location var isImportType = ts.isLiteralImportTypeNode(node); var isTypeLocation = insideJsDocTagTypeExpression @@ -135233,7 +135928,7 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & (1536 /* Module */ | 384 /* Enum */)) { + if (symbol.flags & (1536 /* SymbolFlags.Module */ | 384 /* SymbolFlags.Enum */)) { // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); @@ -135241,7 +135936,7 @@ var ts; var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); }; var isValidAccess = isNamespaceName // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. - ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } + ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* SymbolFlags.Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -135255,7 +135950,7 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 305 /* SourceFile */ && d.kind !== 261 /* ModuleDeclaration */ && d.kind !== 260 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 305 /* SyntaxKind.SourceFile */ && d.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 260 /* SyntaxKind.EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -135269,7 +135964,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } return; } @@ -135293,7 +135988,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } } function addTypeProperties(type, insertAwait, insertQuestionDot) { @@ -135301,16 +135996,8 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent; - if (inUncheckedFile) { - // In javascript files, for union types, we don't just get the members that - // the individual types have in common, we also include all the members that - // each individual type has. This is because we're going to add all identifiers - // anyways. So we might as well elevate the members that were at least part - // of the individual types to a higher status since we know what they are. - symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); })); - } - else { + var propertyAccess = node.kind === 200 /* SyntaxKind.ImportType */ ? node : node.parent; + if (inCheckedFile) { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { @@ -135318,6 +136005,14 @@ var ts; } } } + else { + // In javascript files, for union types, we don't just get the members that + // the individual types have in common, we also include all the members that + // each individual type has. This is because we're going to add all identifiers + // anyways. So we might as well elevate the members that were at least part + // of the individual types to a higher status since we know what they are. + symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); })); + } if (insertAwait && preferences.includeCompletionsWithInsertText) { var promiseType = typeChecker.getPromisedTypeOfPromise(type); if (promiseType) { @@ -135348,12 +136043,12 @@ var ts; if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) || typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) { - symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolOriginInfoKind.SymbolMemberNoExport */) }; } else { var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined; var moduleSpecifier = ((importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences))).getModuleSpecifierForBestExportInfo([{ - exportKind: 0 /* Named */, + exportKind: 0 /* ExportKind.Named */, moduleFileName: fileName, isFromPackageJson: false, moduleSymbol: moduleSymbol, @@ -135362,7 +136057,7 @@ var ts; }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)) || {}).moduleSpecifier; if (moduleSpecifier) { var origin = { - kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false, symbolName: firstAccessibleSymbol.name, @@ -135393,15 +136088,15 @@ var ts; function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { - symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* SymbolOriginInfoKind.Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* SymbolOriginInfoKind.Nullable */ }; } } } function getNullableSymbolOriginInfoKind(kind) { - return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + return insertQuestionDot ? kind | 16 /* SymbolOriginInfoKind.Nullable */ : kind; } } /** Given 'a.b.c', returns 'a'. */ @@ -135417,44 +136112,44 @@ var ts; || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() - || (getGlobalCompletions(), 1 /* Success */); - return result === 1 /* Success */; + || (getGlobalCompletions(), 1 /* GlobalsSearch.Success */); + return result === 1 /* GlobalsSearch.Success */; } function tryGetConstructorCompletion() { if (!tryGetConstructorLikeCompletionContainer(contextToken)) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // no members, only keywords - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; // Declaring new property/method/accessor isNewIdentifierLocation = true; // Has keywords for constructor parameter - keywordFilters = 4 /* ConstructorParameterKeywords */; - return 1 /* Success */; + keywordFilters = 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */; + return 1 /* GlobalsSearch.Success */; } function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) - return 0 /* Continue */; - var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* Completions */); + return 0 /* GlobalsSearch.Continue */; + var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* ContextFlags.Completions */); symbols = ts.concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties)); setSortTextToOptionalMember(); - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function tryGetImportCompletionSymbols() { if (!importCompletionNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; isNewIdentifierLocation = true; collectAutoImports(); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function getGlobalCompletions() { - keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; + keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */ : 1 /* KeywordCompletionFilters.All */; // Get all entities in the current scope. - completionKind = 1 /* Global */; + completionKind = 1 /* CompletionKind.Global */; isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); @@ -135489,7 +136184,7 @@ var ts; position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); - var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnlyLocation ? 0 /* SymbolFlags.None */ : 111551 /* SymbolFlags.Value */) | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */; var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken); symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings)); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); @@ -135499,21 +136194,21 @@ var ts; !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords; } - if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) { + if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* SymbolFlags.Value */)) { var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); if (typeOnlyAliasDeclaration) { - var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; + var origin = { kind: 64 /* SymbolOriginInfoKind.TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; symbolToOriginInfoMap[i] = origin; } } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SyntaxKind.SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; - symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* SymbolOriginInfoKind.ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers; } @@ -135522,8 +136217,8 @@ var ts; collectAutoImports(); if (isTypeOnlyLocation) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* KeywordCompletionFilters.TypeAssertionKeywords */ + : 7 /* KeywordCompletionFilters.TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -135547,10 +136242,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 305 /* SourceFile */: - case 223 /* TemplateExpression */: - case 288 /* JsxExpression */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 223 /* SyntaxKind.TemplateExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 235 /* SyntaxKind.Block */: return true; default: return ts.isStatement(scopeNode); @@ -135566,29 +136261,29 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - ((contextToken.kind === 112 /* TypeOfKeyword */ && - (contextToken.parent.kind === 181 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || - (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 177 /* TypePredicate */)); + ((contextToken.kind === 112 /* SyntaxKind.TypeOfKeyword */ && + (contextToken.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* SyntaxKind.AssertsKeyword */ && contextToken.parent.kind === 177 /* SyntaxKind.TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 58 /* ColonToken */: - return parentKind === 167 /* PropertyDeclaration */ || - parentKind === 166 /* PropertySignature */ || - parentKind === 164 /* Parameter */ || - parentKind === 254 /* VariableDeclaration */ || + case 58 /* SyntaxKind.ColonToken */: + return parentKind === 167 /* SyntaxKind.PropertyDeclaration */ || + parentKind === 166 /* SyntaxKind.PropertySignature */ || + parentKind === 164 /* SyntaxKind.Parameter */ || + parentKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 63 /* EqualsToken */: - return parentKind === 259 /* TypeAliasDeclaration */; - case 127 /* AsKeyword */: - return parentKind === 229 /* AsExpression */; - case 29 /* LessThanToken */: - return parentKind === 178 /* TypeReference */ || - parentKind === 211 /* TypeAssertionExpression */; - case 94 /* ExtendsKeyword */: - return parentKind === 163 /* TypeParameter */; + case 63 /* SyntaxKind.EqualsToken */: + return parentKind === 259 /* SyntaxKind.TypeAliasDeclaration */; + case 127 /* SyntaxKind.AsKeyword */: + return parentKind === 229 /* SyntaxKind.AsExpression */; + case 29 /* SyntaxKind.LessThanToken */: + return parentKind === 178 /* SyntaxKind.TypeReference */ || + parentKind === 211 /* SyntaxKind.TypeAssertionExpression */; + case 94 /* SyntaxKind.ExtendsKeyword */: + return parentKind === 163 /* SyntaxKind.TypeParameter */; } } return false; @@ -135603,7 +136298,7 @@ var ts; // Asking for completion details for an item that is not an auto-import return; } - flags |= 1 /* MayIncludeAutoImports */; + flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */; // import { type | -> token text should be blank var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken && importCompletionNode @@ -135622,13 +136317,13 @@ var ts; return false; if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return false; - if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */)) + if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */)) return false; - if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */))) + if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */))) return false; // Do not try to auto-import something with a lowercase first letter for a JSX tag var firstChar = symbolName.charCodeAt(0); - if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */)) + if (isRightOfOpenTag && (firstChar < 65 /* CharacterCodes.A */ || firstChar > 90 /* CharacterCodes.Z */)) return false; if (detailsEntryId) return true; @@ -135664,14 +136359,14 @@ var ts; if (result !== "skipped") { (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier); } - var isDefaultExport = exportInfo.exportKind === 1 /* Default */; + var isDefaultExport = exportInfo.exportKind === 1 /* ExportKind.Default */; var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol; pushAutoImportSymbol(symbol, { - kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + kind: moduleSpecifier ? 32 /* SymbolOriginInfoKind.ResolvedExport */ : 4 /* SymbolOriginInfoKind.Export */, moduleSpecifier: moduleSpecifier, symbolName: symbolName, exportMapKey: exportMapKey, - exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name, + exportName: exportInfo.exportKind === 2 /* ExportKind.ExportEquals */ ? "export=" /* InternalSymbolName.ExportEquals */ : exportInfo.symbol.name, fileName: exportInfo.moduleFileName, isDefaultExport: isDefaultExport, moduleSymbol: exportInfo.moduleSymbol, @@ -135679,8 +136374,8 @@ var ts; }); }); hasUnresolvedAutoImports = context.skippedAny(); - flags |= context.resolvedAny() ? 8 /* ResolvedModuleSpecifiers */ : 0; - flags |= context.resolvedBeyondLimit() ? 16 /* ResolvedModuleSpecifiersBeyondLimit */ : 0; + flags |= context.resolvedAny() ? 8 /* CompletionInfoFlags.ResolvedModuleSpecifiers */ : 0; + flags |= context.resolvedBeyondLimit() ? 16 /* CompletionInfoFlags.ResolvedModuleSpecifiersBeyondLimit */ : 0; }); function isImportableExportInfo(info) { var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); @@ -135717,7 +136412,7 @@ var ts; return; } var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions), - /*origin*/ undefined, 0 /* ObjectPropertyDeclaration */, + /*origin*/ undefined, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (!displayName) { return; @@ -135727,8 +136422,8 @@ var ts; if (!entryProps) { return; } - var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps); - flags |= 32 /* MayIncludeMethodSnippets */; + var origin = __assign({ kind: 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */ }, entryProps); + flags |= 32 /* CompletionInfoFlags.MayIncludeMethodSnippets */; symbolToOriginInfoMap[symbols.length] = origin; symbols.push(member); }); @@ -135743,7 +136438,7 @@ var ts; `bar` will have symbol flag `Method`, `foo` will have symbol flag `Property`. */ - if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) { + if (!(symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */))) { return false; } return true; @@ -135770,27 +136465,27 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 11 /* JsxText */) { + if (contextToken.kind === 11 /* SyntaxKind.JsxText */) { return true; } - if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */ && contextToken.parent) { // /**/ /> // /**/ > // - contextToken: GreaterThanToken (before cursor) // - location: JsxSelfClosingElement or JsxOpeningElement // - contextToken.parent === location - if (location === contextToken.parent && (location.kind === 280 /* JsxOpeningElement */ || location.kind === 279 /* JsxSelfClosingElement */)) { + if (location === contextToken.parent && (location.kind === 280 /* SyntaxKind.JsxOpeningElement */ || location.kind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { return false; } - if (contextToken.parent.kind === 280 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { //
/**/ // - contextToken: GreaterThanToken (before cursor) // - location: JSXElement // - different parents (JSXOpeningElement, JSXElement) - return location.parent.kind !== 280 /* JsxOpeningElement */; + return location.parent.kind !== 280 /* SyntaxKind.JsxOpeningElement */; } - if (contextToken.parent.kind === 281 /* JsxClosingElement */ || contextToken.parent.kind === 279 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* JsxElement */; + if (contextToken.parent.kind === 281 /* SyntaxKind.JsxClosingElement */ || contextToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* SyntaxKind.JsxElement */; } } return false; @@ -135801,45 +136496,45 @@ var ts; var tokenKind = keywordForNode(contextToken); // Previous token may have been a keyword that was converted to an identifier. switch (tokenKind) { - case 27 /* CommaToken */: - return containingNodeKind === 208 /* CallExpression */ // func( a, | - || containingNodeKind === 171 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 209 /* NewExpression */ // new C(a, | - || containingNodeKind === 204 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 221 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 179 /* FunctionType */ // var x: (s: string, list| - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { x, | - case 20 /* OpenParenToken */: - return containingNodeKind === 208 /* CallExpression */ // func( | - || containingNodeKind === 171 /* Constructor */ // constructor( | - || containingNodeKind === 209 /* NewExpression */ // new C(a| - || containingNodeKind === 212 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 191 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 22 /* OpenBracketToken */: - return containingNodeKind === 204 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 176 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 162 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 141 /* ModuleKeyword */: // module | - case 142 /* NamespaceKeyword */: // namespace | - case 100 /* ImportKeyword */: // import | + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( a, | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a, | + || containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [a, | + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */ // const x = (a, | + || containingNodeKind === 179 /* SyntaxKind.FunctionType */ // var x: (s: string, list| + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { x, | + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( | + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a| + || containingNodeKind === 212 /* SyntaxKind.ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 191 /* SyntaxKind.ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [ | + || containingNodeKind === 176 /* SyntaxKind.IndexSignature */ // [ | : string ] + || containingNodeKind === 162 /* SyntaxKind.ComputedPropertyName */; // [ | /* this can become an index signature */ + case 141 /* SyntaxKind.ModuleKeyword */: // module | + case 142 /* SyntaxKind.NamespaceKeyword */: // namespace | + case 100 /* SyntaxKind.ImportKeyword */: // import | return true; - case 24 /* DotToken */: - return containingNodeKind === 261 /* ModuleDeclaration */; // module A.| - case 18 /* OpenBraceToken */: - return containingNodeKind === 257 /* ClassDeclaration */ // class A { | - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { | - case 63 /* EqualsToken */: - return containingNodeKind === 254 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 221 /* BinaryExpression */; // x = a| - case 15 /* TemplateHead */: - return containingNodeKind === 223 /* TemplateExpression */; // `aa ${| - case 16 /* TemplateMiddle */: - return containingNodeKind === 233 /* TemplateSpan */; // `aa ${10} dd ${| - case 131 /* AsyncKeyword */: - return containingNodeKind === 169 /* MethodDeclaration */ // const obj = { async c|() - || containingNodeKind === 297 /* ShorthandPropertyAssignment */; // const obj = { async c| - case 41 /* AsteriskToken */: - return containingNodeKind === 169 /* MethodDeclaration */; // const obj = { * c| + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 261 /* SyntaxKind.ModuleDeclaration */; // module A.| + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ // class A { | + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { | + case 63 /* SyntaxKind.EqualsToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ // const x = a| + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */; // x = a| + case 15 /* SyntaxKind.TemplateHead */: + return containingNodeKind === 223 /* SyntaxKind.TemplateExpression */; // `aa ${| + case 16 /* SyntaxKind.TemplateMiddle */: + return containingNodeKind === 233 /* SyntaxKind.TemplateSpan */; // `aa ${10} dd ${| + case 131 /* SyntaxKind.AsyncKeyword */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */ // const obj = { async c|() + || containingNodeKind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; // const obj = { async c| + case 41 /* SyntaxKind.AsteriskToken */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */; // const obj = { * c| } if (isClassMemberCompletionKeyword(tokenKind)) { return true; @@ -135858,21 +136553,21 @@ var ts; function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { var typeLiteralNode = tryGetTypeLiteralNode(contextToken); if (!typeLiteralNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; var containerTypeNode = intersectionTypeNode || typeLiteralNode; var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); if (!containerExpectedType) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var containerActualType = typeChecker.getTypeFromTypeNode(containerTypeNode); var members = getPropertiesForCompletion(containerExpectedType, typeChecker); var existingMembers = getPropertiesForCompletion(containerActualType, typeChecker); var existingMemberEscapedNames = new ts.Set(); existingMembers.forEach(function (s) { return existingMemberEscapedNames.add(s.escapedName); }); symbols = ts.concatenate(symbols, ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); })); - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; isNewIdentifierLocation = true; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. @@ -135884,22 +136579,22 @@ var ts; var symbolsStartIndex = symbols.length; var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); if (!objectLikeContainer) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from contextual/inferred/declared type. - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { - if (objectLikeContainer.flags & 33554432 /* InWithStatement */) { - return 2 /* Fail */; + if (objectLikeContainer.flags & 33554432 /* NodeFlags.InWithStatement */) { + return 2 /* GlobalsSearch.Fail */; } isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } - var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* Completions */); + var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* ContextFlags.Completions */); var hasStringIndexType = (completionsType || instantiatedType).getStringIndexType(); var hasNumberIndextype = (completionsType || instantiatedType).getNumberIndexType(); isNewIdentifierLocation = !!hasStringIndexType || !!hasNumberIndextype; @@ -135909,12 +136604,12 @@ var ts; // Edge case: If NumberIndexType exists if (!hasNumberIndextype) { isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } } } else { - ts.Debug.assert(objectLikeContainer.kind === 201 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 201 /* SyntaxKind.ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -135925,19 +136620,19 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 164 /* SyntaxKind.Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 169 /* MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SyntaxKind.SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } if (canGetType) { var typeForObject_1 = typeChecker.getTypeAtLocation(objectLikeContainer); if (!typeForObject_1) - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; typeMembers = typeChecker.getPropertiesOfType(typeForObject_1).filter(function (propertySymbol) { return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*writing*/ false, typeForObject_1, propertySymbol); }); @@ -135949,14 +136644,14 @@ var ts; var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)); symbols = ts.concatenate(symbols, filteredMembers); setSortTextToOptionalMember(); - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */ + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && preferences.includeCompletionsWithObjectLiteralMethodSnippets && preferences.includeCompletionsWithInsertText) { transformObjectLiteralMembersSortText(symbolsStartIndex); collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer); } } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in import clauses and export clauses @@ -135973,38 +136668,38 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { if (!contextToken) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // `import { |` or `import { a as 0, | }` or `import { type | }` - var namedImportsOrExports = contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : + var namedImportsOrExports = contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : ts.isTypeKeywordTokenOrIdentifier(contextToken) ? ts.tryCast(contextToken.parent.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We can at least offer `type` at `import { |` if (!ts.isTypeKeywordTokenOrIdentifier(contextToken)) { - keywordFilters = 8 /* TypeKeyword */; + keywordFilters = 8 /* KeywordCompletionFilters.TypeKeyword */; } // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 269 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) { isNewIdentifierLocation = true; - return namedImportsOrExports.kind === 269 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? 2 /* GlobalsSearch.Fail */ : 0 /* GlobalsSearch.Continue */; } var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) { isNewIdentifierLocation = true; - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; } - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); var existing = new ts.Set(namedImportsOrExports.elements.filter(function (n) { return !isCurrentlyEditingNode(n); }).map(function (n) { return (n.propertyName || n.name).escapedText; })); - var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); }); + var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* InternalSymbolName.Default */ && !existing.has(e.escapedName); }); symbols = ts.concatenate(symbols, uniques); if (!uniques.length) { // If there's nothing else to import, don't offer `type` either - keywordFilters = 0 /* None */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Adds local declarations for completions in named exports: @@ -136017,14 +136712,14 @@ var ts; */ function tryGetLocalNamedExportCompletionSymbols() { var _a; - var namedExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) + var namedExports = contextToken && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedExports) : undefined; if (!namedExports) { - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } var localsContainer = ts.findAncestor(namedExports, ts.or(ts.isSourceFile, ts.isModuleDeclaration)); - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; isNewIdentifierLocation = false; (_a = localsContainer.locals) === null || _a === void 0 ? void 0 : _a.forEach(function (symbol, name) { var _a, _b; @@ -136033,7 +136728,7 @@ var ts; symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember; } }); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in class declaration @@ -136042,48 +136737,48 @@ var ts; function tryGetClassLikeCompletionSymbols() { var decl = tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position); if (!decl) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from parent type. - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : - ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; + keywordFilters = contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ ? 0 /* KeywordCompletionFilters.None */ : + ts.isClassLike(decl) ? 2 /* KeywordCompletionFilters.ClassElementKeywords */ : 3 /* KeywordCompletionFilters.InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) - return 1 /* Success */; - var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; + return 1 /* GlobalsSearch.Success */; + var classElement = contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* ModifierFlags.None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* SyntaxKind.Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": - classElementModifierFlags = classElementModifierFlags | 8 /* Private */; + classElementModifierFlags = classElementModifierFlags | 8 /* ModifierFlags.Private */; break; case "static": - classElementModifierFlags = classElementModifierFlags | 32 /* Static */; + classElementModifierFlags = classElementModifierFlags | 32 /* ModifierFlags.Static */; break; case "override": - classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + classElementModifierFlags = classElementModifierFlags | 16384 /* ModifierFlags.Override */; break; } } if (ts.isClassStaticBlockDeclaration(classElement)) { - classElementModifierFlags |= 32 /* Static */; + classElementModifierFlags |= 32 /* ModifierFlags.Static */; } // No member list for private methods - if (!(classElementModifierFlags & 8 /* Private */)) { + if (!(classElementModifierFlags & 8 /* ModifierFlags.Private */)) { // List of property symbols of base type that are not private and already implemented - var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* ModifierFlags.Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); var baseSymbols = ts.flatMap(baseTypeNodes, function (baseTypeNode) { var type = typeChecker.getTypeAtLocation(baseTypeNode); - return classElementModifierFlags & 32 /* Static */ ? + return classElementModifierFlags & 32 /* ModifierFlags.Static */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); }); symbols = ts.concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags)); } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function isConstructorParameterCompletion(node) { return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent) @@ -136097,8 +136792,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 20 /* OpenParenToken */: - case 27 /* CommaToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 27 /* SyntaxKind.CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -136128,23 +136823,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 31 /* GreaterThanToken */: // End of a type argument list - case 30 /* LessThanSlashToken */: - case 43 /* SlashToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: - case 286 /* JsxAttributes */: - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 279 /* JsxSelfClosingElement */ || parent.kind === 280 /* JsxOpeningElement */)) { - if (contextToken.kind === 31 /* GreaterThanToken */) { + case 31 /* SyntaxKind.GreaterThanToken */: // End of a type argument list + case 30 /* SyntaxKind.LessThanSlashToken */: + case 43 /* SyntaxKind.SlashToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 286 /* SyntaxKind.JsxAttributes */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + if (parent && (parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || parent.kind === 280 /* SyntaxKind.JsxOpeningElement */)) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SyntaxKind.SlashToken */)) break; } return parent; } - else if (parent.kind === 285 /* JsxAttribute */) { + else if (parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136155,8 +136850,8 @@ var ts; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement - case 10 /* StringLiteral */: - if (parent && ((parent.kind === 285 /* JsxAttribute */) || (parent.kind === 287 /* JsxSpreadAttribute */))) { + case 10 /* SyntaxKind.StringLiteral */: + if (parent && ((parent.kind === 285 /* SyntaxKind.JsxAttribute */) || (parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136164,10 +136859,10 @@ var ts; return parent.parent.parent; } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (parent && - parent.kind === 288 /* JsxExpression */ && - parent.parent && parent.parent.kind === 285 /* JsxAttribute */) { + parent.kind === 288 /* SyntaxKind.JsxExpression */ && + parent.parent && parent.parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136175,7 +136870,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 287 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136194,75 +136889,75 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 27 /* CommaToken */: - return containingNodeKind === 254 /* VariableDeclaration */ || + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 237 /* VariableStatement */ || - containingNodeKind === 260 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 237 /* SyntaxKind.VariableStatement */ || + containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 24 /* DotToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [.| - case 58 /* ColonToken */: - return containingNodeKind === 203 /* BindingElement */; // var {x :html| - case 22 /* OpenBracketToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [x| - case 20 /* OpenParenToken */: - return containingNodeKind === 292 /* CatchClause */ || + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [.| + case 58 /* SyntaxKind.ColonToken */: + return containingNodeKind === 203 /* SyntaxKind.BindingElement */; // var {x :html| + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [x| + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 292 /* SyntaxKind.CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 18 /* OpenBraceToken */: - return containingNodeKind === 260 /* EnumDeclaration */; // enum a { | - case 29 /* LessThanToken */: - return containingNodeKind === 257 /* ClassDeclaration */ || // class A< | - containingNodeKind === 226 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 259 /* TypeAliasDeclaration */ || // type List< | + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */; // enum a { | + case 29 /* SyntaxKind.LessThanToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ || // class A< | + containingNodeKind === 226 /* SyntaxKind.ClassExpression */ || // var C = class D< | + containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A< | + containingNodeKind === 259 /* SyntaxKind.TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 124 /* StaticKeyword */: - return containingNodeKind === 167 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 25 /* DotDotDotToken */: - return containingNodeKind === 164 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 202 /* ArrayBindingPattern */); // var [...z| - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - return containingNodeKind === 164 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 127 /* AsKeyword */: - return containingNodeKind === 270 /* ImportSpecifier */ || - containingNodeKind === 275 /* ExportSpecifier */ || - containingNodeKind === 268 /* NamespaceImport */; - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + return containingNodeKind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* SyntaxKind.DotDotDotToken */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ || + (!!parent.parent && parent.parent.kind === 202 /* SyntaxKind.ArrayBindingPattern */); // var [...z| + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* SyntaxKind.AsKeyword */: + return containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ || + containingNodeKind === 275 /* SyntaxKind.ExportSpecifier */ || + containingNodeKind === 268 /* SyntaxKind.NamespaceImport */; + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 79 /* Identifier */: - if (containingNodeKind === 270 /* ImportSpecifier */ && + case 79 /* SyntaxKind.Identifier */: + if (containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ && contextToken === parent.name && contextToken.text === "type") { // import { type | } return false; } break; - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 118 /* InterfaceKeyword */: - case 98 /* FunctionKeyword */: - case 113 /* VarKeyword */: - case 100 /* ImportKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 137 /* InferKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return true; - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: // import { type foo| } - return containingNodeKind !== 270 /* ImportSpecifier */; - case 41 /* AsteriskToken */: + return containingNodeKind !== 270 /* SyntaxKind.ImportSpecifier */; + case 41 /* SyntaxKind.AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword corresponding to class member completion keyword @@ -136283,21 +136978,21 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 126 /* AbstractKeyword */: - case 84 /* ClassKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 98 /* FunctionKeyword */: - case 118 /* InterfaceKeyword */: - case 119 /* LetKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 124 /* StaticKeyword */: - case 113 /* VarKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return true; - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } // If we are inside a class declaration, and `constructor` is totally not present, @@ -136306,7 +137001,7 @@ var ts; if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { return false; // Don't block completions. } - var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* PropertyDeclaration */); + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* SyntaxKind.PropertyDeclaration */); // If we are inside a class declaration and typing `constructor` after property declaration... if (ancestorPropertyDeclaraion && contextToken !== previousToken @@ -136317,7 +137012,7 @@ var ts; if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { return false; // Don't block completions. } - else if (contextToken.kind !== 63 /* EqualsToken */ + else if (contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ // Should not block: `class C { blah = c/**/ }` // But should block: `class C { blah = somewhat c/**/ }` and `class C { blah: SomeType c/**/ }` && (ts.isInitializedProperty(ancestorPropertyDeclaraion) @@ -136333,22 +137028,22 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isPreviousPropertyDeclarationTerminated(contextToken, position) { - return contextToken.kind !== 63 /* EqualsToken */ && - (contextToken.kind === 26 /* SemicolonToken */ + return contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ && + (contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 171 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 171 /* SyntaxKind.Constructor */; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8 /* NumericLiteral */) { + if (contextToken.kind === 8 /* SyntaxKind.NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -136366,13 +137061,13 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 296 /* PropertyAssignment */ && - m.kind !== 297 /* ShorthandPropertyAssignment */ && - m.kind !== 203 /* BindingElement */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */ && - m.kind !== 298 /* SpreadAssignment */) { + if (m.kind !== 296 /* SyntaxKind.PropertyAssignment */ && + m.kind !== 297 /* SyntaxKind.ShorthandPropertyAssignment */ && + m.kind !== 203 /* SyntaxKind.BindingElement */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */ && + m.kind !== 298 /* SyntaxKind.SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -136385,7 +137080,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 79 /* Identifier */) { + if (m.propertyName.kind === 79 /* SyntaxKind.Identifier */) { existingName = m.propertyName.escapedText; } } @@ -136419,7 +137114,7 @@ var ts; function setSortTextToOptionalMember() { symbols.forEach(function (m) { var _a; - if (m.flags & 16777216 /* Optional */) { + if (m.flags & 16777216 /* SymbolFlags.Optional */) { var symbolId = ts.getSymbolId(m); symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember; } @@ -136444,7 +137139,7 @@ var ts; var symbolId = ts.getSymbolId(symbol); var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var target = ts.getEmitScriptTarget(compilerOptions); - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */, + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (displayName) { var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority; @@ -136463,10 +137158,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 167 /* PropertyDeclaration */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */) { + if (m.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -136474,11 +137169,11 @@ var ts; continue; } // Dont filter member even if the name matches if it is declared private in the list - if (ts.hasEffectiveModifier(m, 8 /* Private */)) { + if (ts.hasEffectiveModifier(m, 8 /* ModifierFlags.Private */)) { continue; } // do not filter it out if the static presence doesnt match - if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { + if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* ModifierFlags.Static */)) { continue; } var existingName = ts.getPropertyNameForPropertyNameNode(m.name); @@ -136489,7 +137184,7 @@ var ts; return baseSymbols.filter(function (propertySymbol) { return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && - !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && + !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* ModifierFlags.Private */) && !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } @@ -136508,7 +137203,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 285 /* JsxAttribute */) { + if (attr.kind === 285 /* SyntaxKind.JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -136531,15 +137226,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 18 /* SyntaxKind.OpenBraceToken */: // const x = { | + case 27 /* SyntaxKind.CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -136562,12 +137257,12 @@ var ts; undefined; if (!moduleSymbol) return undefined; - var symbol = data.exportName === "export=" /* ExportEquals */ + var symbol = data.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); if (!symbol) return undefined; - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) }; } @@ -136576,27 +137271,27 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) + || symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { - case 3 /* MemberLike */: + case 3 /* CompletionKind.MemberLike */: return undefined; - case 0 /* ObjectPropertyDeclaration */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; - case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 2 /* CompletionKind.PropertyAccess */: + case 1 /* CompletionKind.Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 - return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; - case 5 /* None */: - case 4 /* String */: + return name.charCodeAt(0) === 32 /* CharacterCodes.space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; + case 5 /* CompletionKind.None */: + case 4 /* CompletionKind.String */: return validNameResult; default: ts.Debug.assertNever(kind); @@ -136606,11 +137301,11 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 81 /* FirstKeyword */; i <= 160 /* LastKeyword */; i++) { + for (var i = 81 /* SyntaxKind.FirstKeyword */; i <= 160 /* SyntaxKind.LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords }); } @@ -136619,7 +137314,7 @@ var ts; function getKeywordCompletions(keywordFilter, filterOutTsOnlyKeywords) { if (!filterOutTsOnlyKeywords) return getTypescriptKeywordCompletions(keywordFilter); - var index = keywordFilter + 8 /* Last */ + 1; + var index = keywordFilter + 8 /* KeywordCompletionFilters.Last */ + 1; return _keywordCompletions[index] || (_keywordCompletions[index] = getTypescriptKeywordCompletions(keywordFilter) .filter(function (entry) { return !isTypeScriptOnlyKeyword(ts.stringToToken(entry.name)); })); @@ -136628,30 +137323,30 @@ var ts; return _keywordCompletions[keywordFilter] || (_keywordCompletions[keywordFilter] = allKeywordsCompletions().filter(function (entry) { var kind = ts.stringToToken(entry.name); switch (keywordFilter) { - case 0 /* None */: + case 0 /* KeywordCompletionFilters.None */: return false; - case 1 /* All */: + case 1 /* KeywordCompletionFilters.All */: return isFunctionLikeBodyKeyword(kind) - || kind === 135 /* DeclareKeyword */ - || kind === 141 /* ModuleKeyword */ - || kind === 152 /* TypeKeyword */ - || kind === 142 /* NamespaceKeyword */ - || kind === 126 /* AbstractKeyword */ - || ts.isTypeKeyword(kind) && kind !== 153 /* UndefinedKeyword */; - case 5 /* FunctionLikeBodyKeywords */: + || kind === 135 /* SyntaxKind.DeclareKeyword */ + || kind === 141 /* SyntaxKind.ModuleKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ + || kind === 142 /* SyntaxKind.NamespaceKeyword */ + || kind === 126 /* SyntaxKind.AbstractKeyword */ + || ts.isTypeKeyword(kind) && kind !== 153 /* SyntaxKind.UndefinedKeyword */; + case 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); - case 2 /* ClassElementKeywords */: + case 2 /* KeywordCompletionFilters.ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); - case 3 /* InterfaceElementKeywords */: + case 3 /* KeywordCompletionFilters.InterfaceElementKeywords */: return isInterfaceOrTypeLiteralCompletionKeyword(kind); - case 4 /* ConstructorParameterKeywords */: + case 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); - case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; - case 7 /* TypeKeywords */: + case 6 /* KeywordCompletionFilters.TypeAssertionKeywords */: + return ts.isTypeKeyword(kind) || kind === 85 /* SyntaxKind.ConstKeyword */; + case 7 /* KeywordCompletionFilters.TypeKeywords */: return ts.isTypeKeyword(kind); - case 8 /* TypeKeyword */: - return kind === 152 /* TypeKeyword */; + case 8 /* KeywordCompletionFilters.TypeKeyword */: + return kind === 152 /* SyntaxKind.TypeKeyword */; default: return ts.Debug.assertNever(keywordFilter); } @@ -136659,64 +137354,64 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 130 /* AnyKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 157 /* GlobalKeyword */: - case 117 /* ImplementsKeyword */: - case 137 /* InferKeyword */: - case 118 /* InterfaceKeyword */: - case 139 /* IsKeyword */: - case 140 /* KeyOfKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 143 /* NeverKeyword */: - case 147 /* NumberKeyword */: - case 148 /* ObjectKeyword */: - case 159 /* OverrideKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: - case 150 /* StringKeyword */: - case 151 /* SymbolKeyword */: - case 152 /* TypeKeyword */: - case 154 /* UniqueKeyword */: - case 155 /* UnknownKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 117 /* SyntaxKind.ImplementsKeyword */: + case 137 /* SyntaxKind.InferKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 139 /* SyntaxKind.IsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 145 /* ReadonlyKeyword */; + return kind === 145 /* SyntaxKind.ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 134 /* ConstructorKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 131 /* AsyncKeyword */ - || kind === 132 /* AwaitKeyword */ - || kind === 127 /* AsKeyword */ - || kind === 152 /* TypeKeyword */ + return kind === 131 /* SyntaxKind.AsyncKeyword */ + || kind === 132 /* SyntaxKind.AwaitKeyword */ + || kind === 127 /* SyntaxKind.AsKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { - return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; + return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* SyntaxKind.Unknown */ : node.kind; } function getContextualKeywords(contextToken, position) { var entries = []; @@ -136737,9 +137432,9 @@ var ts; && contextToken === parent.moduleSpecifier && tokenLine === currentLine) { entries.push({ - name: ts.tokenToString(129 /* AssertKeyword */), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + name: ts.tokenToString(129 /* SyntaxKind.AssertKeyword */), + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }); } @@ -136755,7 +137450,7 @@ var ts; } function getPropertiesForObjectExpression(contextualType, completionsType, obj, checker) { var hasCompletionsType = completionsType && completionsType !== contextualType; - var type = hasCompletionsType && !(completionsType.flags & 3 /* AnyOrUnknown */) + var type = hasCompletionsType && !(completionsType.flags & 3 /* TypeFlags.AnyOrUnknown */) ? checker.getUnionType([contextualType, completionsType]) : contextualType; var properties = getApparentProperties(type, obj, checker); @@ -136777,7 +137472,7 @@ var ts; if (!type.isUnion()) return type.getApparentProperties(); return checker.getAllPossiblePropertiesOfTypes(ts.filter(type.types, function (memberType) { - return !(memberType.flags & 131068 /* Primitive */ + return !(memberType.flags & 131068 /* TypeFlags.Primitive */ || checker.isArrayLikeType(memberType) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, node) || ts.typeHasCallOrConstructSignatures(memberType, checker) @@ -136785,7 +137480,7 @@ var ts; })); } function containsNonPublicProperties(props) { - return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */); }); + return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */); }); } /** * Gets all properties on a type, but if that type is a union of several types, @@ -136803,15 +137498,19 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile)) { return cls; } break; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { + var originalKeywordKind = location.originalKeywordKind; + if (originalKeywordKind && ts.isKeyword(originalKeywordKind)) { + return undefined; + } // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -136825,22 +137524,22 @@ var ts; if (!contextToken) return undefined; // class C { blah; constructor/**/ } and so on - if (location.kind === 134 /* ConstructorKeyword */ + if (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ // class C { blah \n constructor/**/ } || (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) { return ts.findAncestor(contextToken, ts.isClassLike); } switch (contextToken.kind) { - case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* SyntaxKind.EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; - case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SyntaxKind.SemicolonToken */: // class c {getValue(): number; | } + case 19 /* SyntaxKind.CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* SyntaxKind.OpenBraceToken */: // class c { | + case 27 /* SyntaxKind.CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -136851,7 +137550,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -136860,15 +137559,15 @@ var ts; return undefined; var parent = node.parent; switch (node.kind) { - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.isTypeLiteralNode(parent)) { return parent; } break; - case 26 /* SemicolonToken */: - case 27 /* CommaToken */: - case 79 /* Identifier */: - if (parent.kind === 166 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + case 26 /* SyntaxKind.SemicolonToken */: + case 27 /* SyntaxKind.CommaToken */: + case 79 /* SyntaxKind.Identifier */: + if (parent.kind === 166 /* SyntaxKind.PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { return parent.parent; } break; @@ -136885,11 +137584,11 @@ var ts; if (!t) return undefined; switch (node.kind) { - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); - case 188 /* IntersectionType */: - case 182 /* TypeLiteral */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 187 /* SyntaxKind.UnionType */: return t; } } @@ -136911,13 +137610,13 @@ var ts; return !!contextToken && ts.isPrivateIdentifier(contextToken) && !!ts.getContainingClass(contextToken); case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* SyntaxKind.LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SyntaxKind.SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); case " ": - return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SourceFile */; + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SyntaxKind.SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -136930,22 +137629,22 @@ var ts; function isProbablyGlobalType(type, sourceFile, checker) { // The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in // lib.webworker.d.ts, so checking against `self` is also a check against `window` when it exists. - var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (selfSymbol && checker.getTypeOfSymbolAtLocation(selfSymbol, sourceFile) === type) { return true; } - var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalSymbol && checker.getTypeOfSymbolAtLocation(globalSymbol, sourceFile) === type) { return true; } - var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalThisSymbol && checker.getTypeOfSymbolAtLocation(globalThisSymbol, sourceFile) === type) { return true; } return false; } function isStaticProperty(symbol) { - return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); + return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* ModifierFlags.Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); } function tryGetObjectLiteralContextualType(node, typeChecker) { var type = typeChecker.getContextualType(node); @@ -136953,7 +137652,7 @@ var ts; return type; } var parent = ts.walkUpParenthesizedExpressions(node.parent); - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && node === parent.left) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && node === parent.left) { // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(parent); } @@ -136970,7 +137669,7 @@ var ts; return { isKeywordOnlyCompletion: isKeywordOnlyCompletion, keywordCompletion: keywordCompletion, - isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* TypeKeyword */), + isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* SyntaxKind.TypeKeyword */), replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined @@ -136978,23 +137677,23 @@ var ts; function getCandidate() { var parent = contextToken.parent; if (ts.isImportEqualsDeclaration(parent)) { - keywordCompletion = contextToken.kind === 152 /* TypeKeyword */ ? undefined : 152 /* TypeKeyword */; + keywordCompletion = contextToken.kind === 152 /* SyntaxKind.TypeKeyword */ ? undefined : 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; } if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) { return parent; } if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { - if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* OpenBraceToken */ || - contextToken.kind === 100 /* ImportKeyword */ || - contextToken.kind === 27 /* CommaToken */)) { - keywordCompletion = 152 /* TypeKeyword */; + if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || + contextToken.kind === 100 /* SyntaxKind.ImportKeyword */ || + contextToken.kind === 27 /* SyntaxKind.CommaToken */)) { + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; } if (canCompleteFromNamedBindings(parent)) { // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` - if (contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */) { + if (contextToken.kind === 19 /* SyntaxKind.CloseBraceToken */ || contextToken.kind === 79 /* SyntaxKind.Identifier */) { isKeywordOnlyCompletion = true; - keywordCompletion = 156 /* FromKeyword */; + keywordCompletion = 156 /* SyntaxKind.FromKeyword */; } else { return parent.parent.parent; @@ -137004,12 +137703,12 @@ var ts; } if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { // A lone import keyword with nothing following it does not parse as a statement at all - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return contextToken; } if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { // `import s| from` - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; } return undefined; @@ -137049,8 +137748,8 @@ var ts; // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings. return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker)); function nonAliasCanBeReferencedAtTypeLocation(symbol) { - return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) || - !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && + return !!(symbol.flags & 788968 /* SymbolFlags.Type */) || checker.isUnknownSymbol(symbol) || + !!(symbol.flags & 1536 /* SymbolFlags.Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); } } @@ -137087,8 +137786,8 @@ var ts; var testChar = lowercaseCharacters.charCodeAt(characterIndex); if (strChar === testChar || strChar === toUpperCharCode(testChar)) { matchedFirstCharacter || (matchedFirstCharacter = prevChar === undefined || // Beginning of word - 97 /* a */ <= prevChar && prevChar <= 122 /* z */ && 65 /* A */ <= strChar && strChar <= 90 /* Z */ || // camelCase transition - prevChar === 95 /* _ */ && strChar !== 95 /* _ */); // snake_case transition + 97 /* CharacterCodes.a */ <= prevChar && prevChar <= 122 /* CharacterCodes.z */ && 65 /* CharacterCodes.A */ <= strChar && strChar <= 90 /* CharacterCodes.Z */ || // camelCase transition + prevChar === 95 /* CharacterCodes._ */ && strChar !== 95 /* CharacterCodes._ */); // snake_case transition if (matchedFirstCharacter) { characterIndex++; } @@ -137102,7 +137801,7 @@ var ts; return false; } function toUpperCharCode(charCode) { - if (97 /* a */ <= charCode && charCode <= 122 /* z */) { + if (97 /* CharacterCodes.a */ <= charCode && charCode <= 122 /* CharacterCodes.z */) { return charCode - 32; } return charCode; @@ -137132,7 +137831,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" /* none */ + kind: "none" /* HighlightSpanKind.none */ }; } function getSemanticDocumentHighlights(position, node, program, cancellationToken, sourceFilesToSearch) { @@ -137162,46 +137861,46 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 99 /* IfKeyword */: - case 91 /* ElseKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 105 /* ReturnKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 111 /* TryKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: - var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* SyntaxKind.TryKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: + var tryStatement = node.kind === 83 /* SyntaxKind.CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 82 /* CaseKeyword */: - case 88 /* DefaultKeyword */: { + case 82 /* SyntaxKind.CaseKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 81 /* BreakKeyword */: - case 86 /* ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 97 /* ForKeyword */: - case 115 /* WhileKeyword */: - case 90 /* DoKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 134 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* ConstructorKeyword */]); - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [136 /* GetKeyword */, 149 /* SetKeyword */]); - case 132 /* AwaitKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* SyntaxKind.ConstructorKeyword */]); + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */]); + case 132 /* SyntaxKind.AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 125 /* YieldKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return undefined; default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -137244,7 +137943,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -137276,16 +137975,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 249 /* SwitchStatement */: - if (statement.kind === 245 /* ContinueStatement */) { + case 249 /* SyntaxKind.SwitchStatement */: + if (statement.kind === 245 /* SyntaxKind.ContinueStatement */) { return false; } // falls through - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -137301,41 +138000,41 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { + if (modifierFlag & 128 /* ModifierFlags.Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members, true), [declaration], false); } else { return container.statements; } - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters, true), (ts.isClassLike(container.parent) ? container.parent.members : []), true); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { + if (modifierFlag & (28 /* ModifierFlags.AccessibilityModifier */ | 64 /* ModifierFlags.Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { return __spreadArray(__spreadArray([], nodes, true), constructor.parameters, true); } } - else if (modifierFlag & 128 /* Abstract */) { + else if (modifierFlag & 128 /* ModifierFlags.Abstract */) { return __spreadArray(__spreadArray([], nodes, true), [container], false); } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -137354,12 +138053,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* SyntaxKind.ForKeyword */, 115 /* SyntaxKind.WhileKeyword */, 90 /* SyntaxKind.DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 240 /* DoStatement */) { + if (loopNode.kind === 240 /* SyntaxKind.DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* SyntaxKind.WhileKeyword */)) { break; } } @@ -137367,7 +138066,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */, 86 /* SyntaxKind.ContinueKeyword */); } }); return keywords; @@ -137376,13 +138075,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -137390,13 +138089,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SyntaxKind.SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* SyntaxKind.CaseKeyword */, 88 /* SyntaxKind.DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */); } }); }); @@ -137404,13 +138103,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* SyntaxKind.TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* SyntaxKind.CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* SyntaxKind.FinallyKeyword */); } return keywords; } @@ -137421,13 +138120,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); } return keywords; @@ -137439,11 +138138,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); return keywords; } @@ -137455,13 +138154,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 131 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 131 /* SyntaxKind.AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 132 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 132 /* SyntaxKind.AwaitKeyword */); } }); }); @@ -137476,7 +138175,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* SyntaxKind.YieldKeyword */); } }); }); @@ -137495,7 +138194,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* SyntaxKind.ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -137510,7 +138209,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ }); i++; // skip the next keyword continue; @@ -137530,10 +138229,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 99 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* SyntaxKind.IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* SyntaxKind.ElseKeyword */)) { break; } } @@ -137599,60 +138298,64 @@ var ts; } return settingsOrHost; } - function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings)); - return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); + return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions); } - function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { - return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind); + function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { + return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind, languageVersionOrOptions); } - function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings)); - return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); + return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions); } - function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { - return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); + function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { + return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind, languageVersionOrOptions); } function getDocumentRegistryEntry(bucketEntry, scriptKind) { var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided")); - ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry); + ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:".concat(scriptKind, " and sourceFile.scriptKind: ").concat(entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind, ", !entry: ").concat(!entry)); return entry; } - function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) { + function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind, languageVersionOrOptions) { var _a, _b, _c, _d; scriptKind = ts.ensureScriptKind(fileName, scriptKind); var compilationSettings = getCompilationSettings(compilationSettingsOrHost); var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost; - var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings); - var sourceFileOptions = { - languageVersion: scriptTarget, - impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), - setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings) - }; + var scriptTarget = scriptKind === 6 /* ScriptKind.JSON */ ? 100 /* ScriptTarget.JSON */ : ts.getEmitScriptTarget(compilationSettings); + var sourceFileOptions = typeof languageVersionOrOptions === "object" ? + languageVersionOrOptions : + { + languageVersion: scriptTarget, + impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), + setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings) + }; + sourceFileOptions.languageVersion = scriptTarget; var oldBucketCount = buckets.size; - var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); + var keyWithMode = getDocumentRegistryBucketKeyWithMode(key, sourceFileOptions.impliedNodeFormat); + var bucket = ts.getOrUpdate(buckets, keyWithMode, function () { return new ts.Map(); }); if (ts.tracing) { if (buckets.size > oldBucketCount) { // It is interesting, but not definitively problematic if a build requires multiple document registry buckets - // perhaps they are for two projects that don't have any overlap. // Bonus: these events can help us interpret the more interesting event below. - ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: keyWithMode }); } // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations. // If this occurs unexpectedly, the fix is likely to synchronize the project settings. // Skip .d.ts files to reduce noise (should also cover most of node_modules). var otherBucketKey = !ts.isDeclarationFileName(path) && - ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; }); + ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== keyWithMode && bucket.has(path) && bucketKey; }); if (otherBucketKey) { - ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: keyWithMode }); } } var bucketEntry = bucket.get(path); var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); if (!entry && externalCache) { - var sourceFile = externalCache.getDocument(key, path); + var sourceFile = externalCache.getDocument(keyWithMode, path); if (sourceFile) { ts.Debug.assert(acquiring); entry = { @@ -137666,7 +138369,7 @@ var ts; // Have never seen this file with these settings. Create a new source file for it. var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind); if (externalCache) { - externalCache.setDocument(key, path, sourceFile); + externalCache.setDocument(keyWithMode, path, sourceFile); } entry = { sourceFile: sourceFile, @@ -137681,7 +138384,7 @@ var ts; if (entry.sourceFile.version !== version) { entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217 if (externalCache) { - externalCache.setDocument(key, path, entry.sourceFile); + externalCache.setDocument(keyWithMode, path, entry.sourceFile); } } // If we're acquiring, then this is the first time this LS is asking for this document. @@ -137710,13 +138413,13 @@ var ts; } } } - function releaseDocument(fileName, compilationSettings, scriptKind) { + function releaseDocument(fileName, compilationSettings, scriptKind, impliedNodeFormat) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(compilationSettings); - return releaseDocumentWithKey(path, key, scriptKind); + return releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat); } - function releaseDocumentWithKey(path, key, scriptKind) { - var bucket = ts.Debug.checkDefined(buckets.get(key)); + function releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat) { + var bucket = ts.Debug.checkDefined(buckets.get(getDocumentRegistryBucketKeyWithMode(key, impliedNodeFormat))); var bucketEntry = bucket.get(path); var entry = getDocumentRegistryEntry(bucketEntry, scriptKind); entry.languageServiceRefCount--; @@ -137760,18 +138463,21 @@ var ts; return "" + value; } if (ts.isArray(value)) { - return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]"; + return "[".concat((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(","), "]"); } var str = "{"; for (var key in value) { if (ts.hasProperty(value, key)) { - str += key + ": " + compilerOptionValueToString(value[key]); + str += "".concat(key, ": ").concat(compilerOptionValueToString(value[key])); } } return str + "}"; } function getKeyForCompilationSettings(settings) { - return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined); + return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|".concat(settings.pathsBasePath) : undefined); + } + function getDocumentRegistryBucketKeyWithMode(key, mode) { + return (mode ? "".concat(key, "|").concat(mode) : key); } })(ts || (ts = {})); /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ @@ -137838,43 +138544,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 254 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { var name = parent.name; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { directImports.push(name); break; } } } break; - case 79 /* Identifier */: // for 'const x = require("y"); + case 79 /* SyntaxKind.Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 265 /* ImportEqualsDeclaration */: - handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* ModifierFlags.Export */), /*alreadyAddedDirect*/ false); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); } - else if (direct.exportClause.kind === 274 /* NamespaceExport */) { + else if (direct.exportClause.kind === 274 /* SyntaxKind.NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -137883,7 +138589,7 @@ var ts; directImports.push(direct); } break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -137909,14 +138615,14 @@ var ts; }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { - if (exportKind === 2 /* ExportEquals */) { + if (exportKind === 2 /* ExportKind.ExportEquals */) { // This is a direct import, not import-as-namespace. if (!alreadyAddedDirect) directImports.push(importDeclaration); } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 305 /* SourceFile */ || sourceFileLike.kind === 261 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ || sourceFileLike.kind === 261 /* SyntaxKind.ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -137938,7 +138644,7 @@ var ts; var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); if (!moduleSymbol) return; - ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */)); var directImports = getDirectImports(moduleSymbol); if (directImports) { for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { @@ -137972,33 +138678,33 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 265 /* ImportEqualsDeclaration */) { + if (decl.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 79 /* Identifier */) { + if (decl.kind === 79 /* SyntaxKind.Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 200 /* ImportType */) { + if (decl.kind === 200 /* SyntaxKind.ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(firstIdentifier); } } - else if (exportKind === 2 /* ExportEquals */) { + else if (exportKind === 2 /* ExportKind.ExportEquals */) { singleReferences.push(decl.argument.literal); } return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* SyntaxKind.StringLiteral */) { return; } - if (decl.kind === 272 /* ExportDeclaration */) { + if (decl.kind === 272 /* SyntaxKind.ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -138007,12 +138713,12 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. - if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { + if (exportKind === 0 /* ExportKind.Named */ || exportKind === 1 /* ExportKind.Default */) { searchForNamedImport(namedBindings); } break; @@ -138023,7 +138729,7 @@ var ts; // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals. // If a default import has the same name as the default export, allow to rename it. // Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that. - if (name && (exportKind === 1 /* Default */ || exportKind === 2 /* ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { + if (name && (exportKind === 1 /* ExportKind.Default */ || exportKind === 2 /* ExportKind.ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { var defaultImportAlias = checker.getSymbolAtLocation(name); addSearch(name, defaultImportAlias); } @@ -138035,7 +138741,7 @@ var ts; */ function handleNamespaceImportLike(importName) { // Don't rename an import that already has a different name than the export. - if (exportKind === 2 /* ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } @@ -138060,7 +138766,7 @@ var ts; } } else { - var localSymbol = element.kind === 275 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 275 /* SyntaxKind.ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -138069,7 +138775,7 @@ var ts; } function isNameMatch(name) { // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports - return name === exportSymbol.escapedName || exportKind !== 0 /* Named */ && name === "default" /* Default */; + return name === exportSymbol.escapedName || exportKind !== 0 /* ExportKind.Named */ && name === "default" /* InternalSymbolName.Default */; } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ @@ -138089,7 +138795,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SyntaxKind.SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -138137,7 +138843,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 305 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -138152,15 +138858,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -138185,7 +138891,7 @@ var ts; var parent = node.parent; var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 206 /* PropertyAccessExpression */) { + if (parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) @@ -138198,21 +138904,21 @@ var ts; } else { var exportNode = getExportNode(parent, node); - if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* Export */)) { + if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* ModifierFlags.Export */)) { if (ts.isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) { // We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement. if (comingFromExport) { return undefined; } var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); - return { kind: 0 /* Import */, symbol: lhsSymbol }; + return { kind: 0 /* ImportExport.Import */, symbol: lhsSymbol }; } else { return exportInfo(symbol, getExportKindForDeclaration(exportNode)); } } else if (ts.isNamespaceExport(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } // If we are in `export = a;` or `export default a;`, `parent` is the export assignment. else if (ts.isExportAssignment(parent)) { @@ -138230,24 +138936,24 @@ var ts; return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. if (!ex.symbol.parent) return undefined; - var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; + var exportKind = ex.isExportEquals ? 2 /* ExportKind.ExportEquals */ : 1 /* ExportKind.Default */; + return { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; switch (ts.getAssignmentDeclarationKind(node)) { - case 1 /* ExportsProperty */: - kind = 0 /* Named */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + kind = 0 /* ExportKind.Named */; break; - case 2 /* ModuleExports */: - kind = 2 /* ExportEquals */; + case 2 /* AssignmentDeclarationKind.ModuleExports */: + kind = 2 /* ExportKind.ExportEquals */; break; default: return undefined; @@ -138274,22 +138980,22 @@ var ts; // If `importedName` is undefined, do continue searching as the export is anonymous. // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) var importedName = ts.symbolEscapedNameNoDefault(importedSymbol); - if (importedName === undefined || importedName === "default" /* Default */ || importedName === symbol.escapedName) { - return { kind: 0 /* Import */, symbol: importedSymbol }; + if (importedName === undefined || importedName === "default" /* InternalSymbolName.Default */ || importedName === symbol.escapedName) { + return { kind: 0 /* ImportExport.Import */, symbol: importedSymbol }; } } function exportInfo(symbol, kind) { var exportInfo = getExportInfo(symbol, kind, checker); - return exportInfo && { kind: 1 /* Export */, symbol: symbol, exportInfo: exportInfo }; + return exportInfo && { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: exportInfo }; } // Not meant for use with export specifiers or export assignment. function getExportKindForDeclaration(node) { - return ts.hasSyntacticModifier(node, 512 /* Default */) ? 1 /* Default */ : 0 /* Named */; + return ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; } } FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; function getExportEqualsLocalSymbol(importedSymbol, checker) { - if (importedSymbol.flags & 2097152 /* Alias */) { + if (importedSymbol.flags & 2097152 /* SymbolFlags.Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); @@ -138319,16 +139025,16 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent); default: return false; @@ -138358,7 +139064,7 @@ var ts; } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) - && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) { + && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) { return checker.getExportSpecifierLocalTargetSymbol(declaration.name); } } @@ -138369,21 +139075,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 305 /* SourceFile */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 262 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 262 /* SyntaxKind.ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 277 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* SyntaxKind.StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -138410,7 +139116,7 @@ var ts; EntryKind[EntryKind["SearchedPropertyFoundLocal"] = 4] = "SearchedPropertyFoundLocal"; })(EntryKind = FindAllReferences.EntryKind || (FindAllReferences.EntryKind = {})); function nodeEntry(node, kind) { - if (kind === void 0) { kind = 1 /* Node */; } + if (kind === void 0) { kind = 1 /* EntryKind.Node */; } return { kind: kind, node: node.name || node, @@ -138438,7 +139144,7 @@ var ts; node.parent.parent.left === node.parent ? node.parent.parent : undefined; - if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* None */) { + if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* AssignmentDeclarationKind.None */) { return getContextNode(binaryExpression); } } @@ -138477,7 +139183,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ModifierFlags.ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -138486,7 +139192,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -138494,28 +139200,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextNode(node.parent.parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 267 /* ImportClause */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return { start: node.initializer, end: node.expression }; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -138556,7 +139262,7 @@ var ts; })(FindReferencesUse = FindAllReferences.FindReferencesUse || (FindAllReferences.FindReferencesUse = {})); function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); - var options = { use: 1 /* References */ }; + var options = { use: 1 /* FindReferencesUse.References */ }; var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options); var checker = program.getTypeChecker(); // Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition @@ -138573,33 +139279,33 @@ var ts; } FindAllReferences.findReferencedSymbols = findReferencedSymbols; function isDefinitionForReference(node) { - return node.kind === 88 /* DefaultKeyword */ + return node.kind === 88 /* SyntaxKind.DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 206 /* PropertyAccessExpression */ - || node.parent.kind === 203 /* BindingElement */ - || node.parent.kind === 207 /* ElementAccessExpression */ - || node.kind === 106 /* SuperKeyword */) { + if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || node.parent.kind === 203 /* SyntaxKind.BindingElement */ + || node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries, true); } - else { - var queue = entries && __spreadArray([], entries, true); + else if (entries) { + var queue = ts.createQueue(entries); var seenNodes = new ts.Map(); - while (queue && queue.length) { - var entry = queue.shift(); + while (!queue.isEmpty()) { + var entry = queue.dequeue(); if (!ts.addToSeen(seenNodes, ts.getNodeId(entry.node))) { continue; } referenceEntries = ts.append(referenceEntries, entry); var entries_1 = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, entry.node, entry.node.pos); if (entries_1) { - queue.push.apply(queue, entries_1); + queue.enqueue.apply(queue, entries_1); } } } @@ -138608,18 +139314,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var result_2 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); }); return result_2; } - else if (node.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -138627,7 +139333,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* References */ }); + return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* FindReferencesUse.References */ }); } } function findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, convertEntry) { @@ -138646,7 +139352,7 @@ var ts; function definitionToReferencedSymbolDefinitionInfo(def, checker, originalNode) { var info = (function () { switch (def.type) { - case 0 /* Symbol */: { + case 0 /* DefinitionKind.Symbol */: { var symbol = def.symbol; var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind; var name_1 = displayParts_1.map(function (p) { return p.text; }).join(""); @@ -138654,32 +139360,32 @@ var ts; var node = declaration ? (ts.getNameOfDeclaration(declaration) || declaration) : originalNode; return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_1, kind: kind_1, displayParts: displayParts_1, context: getContextNode(declaration) }); } - case 1 /* Label */: { + case 1 /* DefinitionKind.Label */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* ScriptElementKind.label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); } - case 2 /* Keyword */: { + case 2 /* DefinitionKind.Keyword */: { var node = def.node; var name_2 = ts.tokenToString(node.kind); - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* keyword */, displayParts: [{ text: name_2, kind: "keyword" /* keyword */ }] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* ScriptElementKind.keyword */, displayParts: [{ text: name_2, kind: "keyword" /* ScriptElementKind.keyword */ }] }); } - case 3 /* This */: { + case 3 /* DefinitionKind.This */: { var node = def.node; var symbol = checker.getSymbolAtLocation(node); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node).displayParts || [ts.textPart("this")]; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* variableElement */, displayParts: displayParts_2 }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* ScriptElementKind.variableElement */, displayParts: displayParts_2 }); } - case 4 /* String */: { + case 4 /* DefinitionKind.String */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* ScriptElementKind.variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); } - case 5 /* TripleSlashReference */: { + case 5 /* DefinitionKind.TripleSlashReference */: { return { textSpan: ts.createTextSpanFromRange(def.reference), sourceFile: def.file, name: def.reference.fileName, - kind: "string" /* string */, - displayParts: [ts.displayPart("\"" + def.reference.fileName + "\"", ts.SymbolDisplayPartKind.stringLiteral)] + kind: "string" /* ScriptElementKind.string */, + displayParts: [ts.displayPart("\"".concat(def.reference.fileName, "\""), ts.SymbolDisplayPartKind.stringLiteral)] }; } default: @@ -138687,7 +139393,7 @@ var ts; } })(); var sourceFile = info.sourceFile, textSpan = info.textSpan, name = info.name, kind = info.kind, displayParts = info.displayParts, context = info.context; - return __assign({ containerKind: "" /* unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); + return __assign({ containerKind: "" /* ScriptElementKind.unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); } function getFileAndTextSpanFromNode(node) { var sourceFile = node.getSourceFile(); @@ -138710,19 +139416,19 @@ var ts; var referenceEntry = toReferenceEntry(entry); if (!symbol) return referenceEntry; - return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) }); + return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* EntryKind.Span */ && isDeclarationOfSymbol(entry.node, symbol) }); } function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return __assign(__assign({}, documentSpan), { isWriteAccess: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }); } FindAllReferences.toReferenceEntry = toReferenceEntry; function entryToDocumentSpan(entry) { - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { textSpan: entry.textSpan, fileName: entry.fileName }; } else { @@ -138732,7 +139438,7 @@ var ts; } } function getPrefixAndSuffixText(entry, originalNode, checker) { - if (entry.kind !== 0 /* Span */ && ts.isIdentifier(originalNode)) { + if (entry.kind !== 0 /* EntryKind.Span */ && ts.isIdentifier(originalNode)) { var node = entry.node, kind = entry.kind; var parent = node.parent; var name = originalNode.text; @@ -138740,10 +139446,10 @@ var ts; if (isShorthandAssignment || (ts.isObjectBindingElementWithoutPropertyName(parent) && parent.name === node && parent.dotDotDotToken === undefined)) { var prefixColon = { prefixText: name + ": " }; var suffixColon = { suffixText: ": " + name }; - if (kind === 3 /* SearchedLocalFoundProperty */) { + if (kind === 3 /* EntryKind.SearchedLocalFoundProperty */) { return prefixColon; } - if (kind === 4 /* SearchedPropertyFoundLocal */) { + if (kind === 4 /* EntryKind.SearchedPropertyFoundLocal */) { return suffixColon; } // In `const o = { x }; o.x`, symbolAtLocation at `x` in `{ x }` is the property symbol. @@ -138777,12 +139483,12 @@ var ts; } function toImplementationLocation(entry, checker) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind !== 0 /* Span */) { + if (entry.kind !== 0 /* EntryKind.Span */) { var node = entry.node; return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* ScriptElementKind.unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -138790,16 +139496,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return { - kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "interface" /* ScriptElementKind.interfaceElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } - else if (node.kind === 226 /* ClassExpression */) { + else if (node.kind === 226 /* SyntaxKind.ClassExpression */) { return { - kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "local class" /* ScriptElementKind.localClassElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } else { @@ -138808,17 +139514,17 @@ var ts; } function toHighlightSpan(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { fileName: documentSpan.fileName, span: { textSpan: documentSpan.textSpan, - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ } }; } var writeAccess = isWriteAccessForReference(entry.node); - var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, isInString: entry.kind === 2 /* StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); + var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* HighlightSpanKind.writtenReference */ : "reference" /* HighlightSpanKind.reference */, isInString: entry.kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); return { fileName: documentSpan.fileName, span: span }; } FindAllReferences.toHighlightSpan = toHighlightSpan; @@ -138833,14 +139539,14 @@ var ts; return ts.createTextSpanFromBounds(start, end); } function getTextSpanOfEntry(entry) { - return entry.kind === 0 /* Span */ ? entry.textSpan : + return entry.kind === 0 /* EntryKind.Span */ ? entry.textSpan : getTextSpan(entry.node, entry.node.getSourceFile()); } FindAllReferences.getTextSpanOfEntry = getTextSpanOfEntry; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* SyntaxKind.DefaultKeyword */ || ts.isWriteAccess(node); } /** Whether a reference, `node`, is a definition of the `target` symbol */ function isDeclarationOfSymbol(node, target) { @@ -138848,9 +139554,9 @@ var ts; if (!target) return false; var source = ts.getDeclarationFromName(node) || - (node.kind === 88 /* DefaultKeyword */ ? node.parent + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ ? node.parent : ts.isLiteralComputedPropertyDeclarationName(node) ? node.parent.parent - : node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent + : node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent : undefined); var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined; return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; }))); @@ -138862,50 +139568,50 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 16777216 /* Ambient */)) + if (!!(decl.flags & 16777216 /* NodeFlags.Ambient */)) return true; switch (decl.kind) { - case 221 /* BinaryExpression */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 88 /* DefaultKeyword */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 275 /* ExportSpecifier */: - case 267 /* ImportClause */: // default import - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 258 /* InterfaceDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 285 /* JsxAttribute */: - case 261 /* ModuleDeclaration */: - case 264 /* NamespaceExportDeclaration */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - case 164 /* Parameter */: - case 297 /* ShorthandPropertyAssignment */: - case 259 /* TypeAliasDeclaration */: - case 163 /* TypeParameter */: + case 221 /* SyntaxKind.BinaryExpression */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: // default import + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 285 /* SyntaxKind.JsxAttribute */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + case 164 /* SyntaxKind.Parameter */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return !!decl.body; - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 168 /* MethodSignature */: - case 166 /* PropertySignature */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 168 /* SyntaxKind.MethodSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -138934,7 +139640,7 @@ var ts; return undefined; } return [{ - definition: { type: 5 /* TripleSlashReference */, reference: resolvedRef.reference, file: node }, + definition: { type: 5 /* DefinitionKind.TripleSlashReference */, reference: resolvedRef.reference, file: node }, references: getReferencesForNonModule(resolvedRef.file, fileIncludeReasons, program) || ts.emptyArray }]; } @@ -138956,7 +139662,7 @@ var ts; var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { - return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; + return [{ definition: { type: 4 /* DefinitionKind.String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; } // Fall through to string literal references. This is not very likely to return // anything useful, but I guess it's better than nothing, and there's an existing @@ -138966,11 +139672,11 @@ var ts; } return undefined; } - if (symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); } var moduleReferences = getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet); - if (moduleReferences && !(symbol.flags & 33554432 /* Transient */)) { + if (moduleReferences && !(symbol.flags & 33554432 /* SymbolFlags.Transient */)) { return moduleReferences; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(node, symbol, checker); @@ -138981,10 +139687,10 @@ var ts; } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function getAdjustedNode(node, options) { - if (options.use === 1 /* References */) { + if (options.use === 1 /* FindReferencesUse.References */) { node = ts.getAdjustedReferenceLocation(node); } - else if (options.use === 2 /* Rename */) { + else if (options.use === 2 /* FindReferencesUse.Rename */) { node = ts.getAdjustedRenameLocation(node); } return node; @@ -139012,7 +139718,7 @@ var ts; var location = ts.getReferencedFileLocation(program.getSourceFileByPath, ref); if (ts.isReferenceFileLocation(location)) { entries = ts.append(entries, { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: referencingFile.fileName, textSpan: ts.createTextSpanFromRange(location) }); @@ -139032,10 +139738,10 @@ var ts; return undefined; } function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet) { - var moduleSourceFile = (symbol.flags & 1536 /* Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); + var moduleSourceFile = (symbol.flags & 1536 /* SymbolFlags.Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; - var exportEquals = symbol.exports.get("export=" /* ExportEquals */); + var exportEquals = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. var moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) @@ -139062,14 +139768,14 @@ var ts; result = references; continue; } - var _loop_4 = function (entry) { - if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { + var _loop_3 = function (entry) { + if (!entry.definition || entry.definition.type !== 0 /* DefinitionKind.Symbol */) { result.push(entry); return "continue"; } var symbol = entry.definition.symbol; var refIndex = ts.findIndex(result, function (ref) { return !!ref.definition && - ref.definition.type === 0 /* Symbol */ && + ref.definition.type === 0 /* DefinitionKind.Symbol */ && ref.definition.symbol === symbol; }); if (refIndex === -1) { result.push(entry); @@ -139094,13 +139800,13 @@ var ts; }; for (var _b = 0, references_2 = references; _b < references_2.length; _b++) { var entry = references_2[_b]; - _loop_4(entry); + _loop_3(entry); } } return result; } function getSourceFileIndexOfEntry(program, entry) { - var sourceFile = entry.kind === 0 /* Span */ ? + var sourceFile = entry.kind === 0 /* EntryKind.Span */ ? program.getSourceFile(entry.fileName) : entry.node.getSourceFile(); return program.getSourceFiles().indexOf(sourceFile); @@ -139121,7 +139827,7 @@ var ts; } else { return { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: reference.referencingFile.fileName, textSpan: ts.createTextSpanFromRange(reference.ref), }; @@ -139131,21 +139837,21 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } break; default: // This may be merged with something. - ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); + ts.Debug.assert(!!(symbol.flags & 33554432 /* SymbolFlags.Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } } - var exported = symbol.exports.get("export=" /* ExportEquals */); + var exported = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exported === null || exported === void 0 ? void 0 : exported.declarations) { for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -139153,41 +139859,41 @@ var ts; if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : - ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* SyntaxKind.ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } } } - return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; + return references.length ? [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 145 /* ReadonlyKeyword */ + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 145 /* ReadonlyKeyword */; + && node.parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A void expression (i.e., `void foo()`) is not special, but the `void` type is. - if (node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(node.parent)) { return undefined; } // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 145 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } if (ts.isImportMeta(node.parent) && node.parent.name === node) { return getAllReferencesForImportMeta(sourceFiles, cancellationToken); } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { - return [{ definition: { type: 2 /* Keyword */, node: node }, references: [nodeEntry(node)] }]; + return [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: node }, references: [nodeEntry(node)] }]; } // Labels if (ts.isJumpStatementTarget(node)) { @@ -139203,7 +139909,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -139212,20 +139918,20 @@ var ts; function getReferencedSymbolsForSymbol(originalSymbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options) { var symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, /*useLocalSymbolForExportSpecifier*/ !isForRenameWithPrefixAndSuffixText(options)) || originalSymbol; // Compute the meaning from the location and the symbol it references - var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; + var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* SemanticMeaning.All */; var result = []; - var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); + var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* SpecialSearchKind.None */, checker, cancellationToken, searchMeaning, options, result); var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) || !symbol.declarations ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); if (exportSpecifier) { // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { + else if (node && node.kind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.escapedName === "default" /* InternalSymbolName.Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* ExportKind.Default */ }, state); } else { - var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* FindReferencesUse.Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); getReferencesInContainerOrFiles(symbol, state, search); } return result; @@ -139248,17 +139954,17 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 171 /* Constructor */: - case 134 /* ConstructorKeyword */: - return 1 /* Constructor */; - case 79 /* Identifier */: + case 171 /* SyntaxKind.Constructor */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return 1 /* SpecialSearchKind.Constructor */; + case 79 /* SyntaxKind.Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); - return 2 /* Class */; + return 2 /* SpecialSearchKind.Class */; } // falls through default: - return 0 /* None */; + return 0 /* SpecialSearchKind.None */; } } /** Handle a few special cases relating to export/import specifiers. */ @@ -139271,10 +139977,10 @@ var ts; return ts.firstDefined(symbol.declarations, function (decl) { if (!decl.parent) { // Ignore UMD module and global merge - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return undefined; // Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here. - ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol)); + ts.Debug.fail("Unexpected symbol at ".concat(ts.Debug.formatSyntaxKind(node.kind), ": ").concat(ts.Debug.formatSymbol(symbol))); } return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent) ? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name) @@ -139288,7 +139994,7 @@ var ts; SpecialSearchKind[SpecialSearchKind["Class"] = 2] = "Class"; })(SpecialSearchKind || (SpecialSearchKind = {})); function getNonModuleSymbolOfMergedModuleSymbol(symbol) { - if (!(symbol.flags & (1536 /* Module */ | 33554432 /* Transient */))) + if (!(symbol.flags & (1536 /* SymbolFlags.Module */ | 33554432 /* SymbolFlags.Transient */))) return undefined; var decl = symbol.declarations && ts.find(symbol.declarations, function (d) { return !ts.isSourceFile(d) && !ts.isModuleDeclaration(d); }); return decl && decl.symbol; @@ -139340,7 +140046,7 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* Rename */); + return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* FindReferencesUse.Rename */); }; /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { @@ -139363,7 +140069,7 @@ var ts; var references = this.symbolIdToReferences[symbolId]; if (!references) { references = this.symbolIdToReferences[symbolId] = []; - this.result.push({ definition: { type: 0 /* Symbol */, symbol: searchSymbol }, references: references }); + this.result.push({ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSymbol }, references: references }); } return function (node, kind) { return references.push(nodeEntry(node, kind)); }; }; @@ -139371,7 +140077,7 @@ var ts; State.prototype.addStringOrCommentReference = function (fileName, textSpan) { this.result.push({ definition: undefined, - references: [{ kind: 0 /* Span */, fileName: fileName, textSpan: textSpan }] + references: [{ kind: 0 /* EntryKind.Span */, fileName: fileName, textSpan: textSpan }] }); }; /** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */ @@ -139402,19 +140108,19 @@ var ts; // For each import, find all references to that import in its source file. for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; - getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* Export */), state); + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* ImportExport.Export */), state); } if (indirectUsers.length) { var indirectSearch = void 0; switch (exportInfo.exportKind) { - case 0 /* Named */: - indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* Export */); + case 0 /* ExportKind.Named */: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */); break; - case 1 /* Default */: + case 1 /* ExportKind.Default */: // Search for a property access to '.default'. This can't be renamed. - indirectSearch = state.options.use === 2 /* Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* Export */, { text: "default" }); + indirectSearch = state.options.use === 2 /* FindReferencesUse.Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */, { text: "default" }); break; - case 2 /* ExportEquals */: + case 2 /* ExportKind.ExportEquals */: break; } if (indirectSearch) { @@ -139427,7 +140133,7 @@ var ts; } function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken); - var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { var importLocation = importSearches_2[_i][0]; cb(importLocation); @@ -139455,13 +140161,13 @@ var ts; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; - if (state.options.use !== 2 /* Rename */) + if (state.options.use !== 2 /* FindReferencesUse.Rename */) return true; // Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;` if (!ts.isIdentifier(singleRef)) return false; // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename. - return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* Default */); + return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* InternalSymbolName.Default */); } // Go to the symbol we imported from and find references for it. function searchForImportedSymbol(symbol, state) { @@ -139471,7 +140177,7 @@ var ts; var declaration = _a[_i]; var exportingFile = declaration.getSourceFile(); // Need to search in the file even if it's not in the search-file set, because it might export the symbol. - getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* Import */), state, state.includesSourceFile(exportingFile)); + getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* ImportExport.Import */), state, state.includesSourceFile(exportingFile)); } } /** Search for all occurrences of an identifier in a source file (and filter out the ones that match). */ @@ -139497,17 +140203,17 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 213 /* FunctionExpression */ || valueDeclaration.kind === 226 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 213 /* SyntaxKind.FunctionExpression */ || valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */)) { return valueDeclaration; } if (!declarations) { return undefined; } // If this is private property or method, the scope is the containing class - if (flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); + if (flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)) { + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 257 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 257 /* SyntaxKind.ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -139524,7 +140230,7 @@ var ts; - The parent is an external module: then we should only search in the module (and recurse on the export later). - But if the parent has `export as namespace`, the symbol is globally visible through that namespace. */ - var exposedByParent = parent && !(symbol.flags & 262144 /* TypeParameter */); + var exposedByParent = parent && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */); if (exposedByParent && !(ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { return undefined; } @@ -139536,7 +140242,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -139655,8 +140361,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* ScriptTarget.Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* ScriptTarget.Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -139671,27 +140377,27 @@ var ts; // Only pick labels that are either the target label, or have a target that is the target label return node === targetLabel || (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel) ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 1 /* Label */, node: targetLabel }, references: references }]; + return [{ definition: { type: 1 /* DefinitionKind.Label */, node: targetLabel }, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: if (ts.isJSDocMemberName(node.parent)) { return true; } // falls through I guess - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.text.length === searchSymbolName.length; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && str.text.length === searchSymbolName.length; } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -139707,7 +140413,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { @@ -139718,7 +140424,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getReferencesInSourceFile(sourceFile, search, state, addReferencesHere) { if (addReferencesHere === void 0) { addReferencesHere = true; } @@ -139769,7 +140475,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* SyntaxKind.Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -139779,14 +140485,14 @@ var ts; return; } switch (state.specialSearchKind) { - case 0 /* None */: + case 0 /* SpecialSearchKind.None */: if (addReferencesHere) addReference(referenceLocation, relatedSymbol, state); break; - case 1 /* Constructor */: + case 1 /* SpecialSearchKind.Constructor */: addConstructorReferences(referenceLocation, sourceFile, search, state); break; - case 2 /* Class */: + case 2 /* SpecialSearchKind.Class */: addClassStaticThisReferences(referenceLocation, search, state); break; default: @@ -139794,7 +140500,7 @@ var ts; } // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) - && referenceLocation.parent.kind === 203 /* BindingElement */ + && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In @@ -139814,7 +140520,7 @@ var ts; } if (!propertyName) { // Don't rename at `export { default } from "m";`. (but do continue to search for imports of the re-export) - if (!(state.options.use === 2 /* Rename */ && (name.escapedText === "default" /* Default */))) { + if (!(state.options.use === 2 /* FindReferencesUse.Rename */ && (name.escapedText === "default" /* InternalSymbolName.Default */))) { addRef(); } } @@ -139824,7 +140530,7 @@ var ts; if (!exportDeclaration.moduleSpecifier) { addRef(); } - if (addReferencesHere && state.options.use !== 2 /* Rename */ && state.markSeenReExportRHS(name)) { + if (addReferencesHere && state.options.use !== 2 /* FindReferencesUse.Rename */ && state.markSeenReExportRHS(name)) { addReference(name, ts.Debug.checkDefined(exportSpecifier.symbol), state); } } @@ -139835,9 +140541,9 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; - var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */; + var exportKind = isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); if (exportInfo) { @@ -139845,7 +140551,7 @@ var ts; } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. - if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { + if (search.comingFrom !== 1 /* ImportExport.Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { var imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (imported) searchForImportedSymbol(imported, state); @@ -139872,11 +140578,11 @@ var ts; } } function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { - var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* Export */); + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* ImportExport.Export */); if (!importOrExport) return; var symbol = importOrExport.symbol; - if (importOrExport.kind === 0 /* Import */) { + if (importOrExport.kind === 0 /* ImportExport.Import */) { if (!(isForRenameWithPrefixAndSuffixText(state.options))) { searchForImportedSymbol(symbol, state); } @@ -139896,14 +140602,14 @@ var ts; * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the * position of property accessing, the referenceEntry of such position will be handled in the first case. */ - if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + if (!(flags & 33554432 /* SymbolFlags.Transient */) && name && search.includes(shorthandValueSymbol)) { addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator // if rename symbol from default export anonymous function, for example `export default function() {}`, we do not need to add reference - if (state.options.use === 2 /* Rename */ && referenceLocation.kind === 88 /* DefaultKeyword */) { + if (state.options.use === 2 /* FindReferencesUse.Rename */ && referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */) { return; } var addRef = state.referenceAdder(symbol); @@ -139921,7 +140627,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -139937,7 +140643,7 @@ var ts; function addClassStaticThisReferences(referenceLocation, search, state) { addReference(referenceLocation, search.symbol, state); var classLike = referenceLocation.parent; - if (state.options.use === 2 /* Rename */ || !ts.isClassLike(classLike)) + if (state.options.use === 2 /* FindReferencesUse.Rename */ || !ts.isClassLike(classLike)) return; ts.Debug.assert(classLike.name === referenceLocation); var addRef = state.referenceAdder(search.symbol); @@ -139948,7 +140654,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 108 /* ThisKeyword */) { + if (node.kind === 108 /* SyntaxKind.ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -139967,18 +140673,18 @@ var ts; if (constructorSymbol && constructorSymbol.declarations) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 134 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 171 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 169 /* MethodDeclaration */) { + if (decl && decl.kind === 169 /* SyntaxKind.MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* SyntaxKind.ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -139989,7 +140695,7 @@ var ts; } } function getClassConstructorSymbol(classSymbol) { - return classSymbol.members && classSymbol.members.get("__constructor" /* Constructor */); + return classSymbol.members && classSymbol.members.get("__constructor" /* InternalSymbolName.Constructor */); } /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(classDeclaration, addNode) { @@ -139999,10 +140705,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 171 /* Constructor */); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SyntaxKind.SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -140026,10 +140732,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 79 /* Identifier */) { + if (refNode.kind !== 79 /* SyntaxKind.Identifier */) { return; } - if (refNode.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -140049,7 +140755,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 235 /* Block */) { + if (body.kind === 235 /* SyntaxKind.Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -140077,13 +140783,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 204 /* ArrayLiteralExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; default: return false; @@ -140134,15 +140840,15 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -140151,7 +140857,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 106 /* SuperKeyword */) { + if (node.kind !== 106 /* SyntaxKind.SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -140160,46 +140866,46 @@ var ts; // and has the same static qualifier as the original 'super's owner. return container && ts.isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; + return [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 79 /* Identifier */ && node.parent.kind === 164 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 164 /* SyntaxKind.Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 305 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -140207,26 +140913,26 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 205 /* ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // Make sure the container belongs to the same class/object literals // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag; - case 305 /* SourceFile */: - return container.kind === 305 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 305 /* SyntaxKind.SourceFile */: + return container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); var thisParameter = ts.firstDefined(references, function (r) { return ts.isParameter(r.node.parent) ? r.node : undefined; }); return [{ - definition: { type: 3 /* This */, node: thisParameter || thisOrSuperKeyword }, + definition: { type: 3 /* DefinitionKind.This */, node: thisParameter || thisOrSuperKeyword }, references: references }]; } @@ -140239,18 +140945,18 @@ var ts; if (type) { var refType = ts.getContextualTypeFromParentOrAncestorTypeNode(ref, checker); if (type !== checker.getStringType() && type === refType) { - return nodeEntry(ref, 2 /* StringLiteral */); + return nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } else { return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined : - nodeEntry(ref, 2 /* StringLiteral */); + nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } }); }); return [{ - definition: { type: 4 /* String */, node: node }, + definition: { type: 4 /* DefinitionKind.String */, node: node }, references: references }]; } @@ -140295,30 +141001,30 @@ var ts; var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); // gets the local symbol if (shorthandValueSymbol && isForRenamePopulateSearchSymbolSet) { // When renaming 'x' in `const o = { x }`, just rename the local variable, not the property. - return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); } // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set var contextualType = checker.getContextualType(containingObjectLiteralElement.parent); - var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* SearchedPropertyFoundLocal */); }); + var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* EntryKind.SearchedPropertyFoundLocal */); }); if (res_1) return res_1; // If the location is name of property symbol from object literal destructuring pattern // Search the property symbol // for ( { property: p2 } of elems) { } var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); - var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* SearchedPropertyFoundLocal */); + var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* EntryKind.SearchedPropertyFoundLocal */); if (res1) return res1; - var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); if (res2) return res2; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(location, symbol, checker); if (aliasedSymbol) { // In case of UMD module and global merging, search for global as well - var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_2) return res_2; } @@ -140328,14 +141034,14 @@ var ts; if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); - ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] - return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); + ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* SymbolFlags.FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* SymbolFlags.Property */)); // is [parameter, property] + return fromRoot(symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { - var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_3) return res_3; } @@ -140350,7 +141056,7 @@ var ts; else { bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); } - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } ts.Debug.assert(isForRenamePopulateSearchSymbolSet); // due to the above assert and the arguments at the uses of this function, @@ -140358,7 +141064,7 @@ var ts; var includeOriginalSymbolOfBindingElement = onlyIncludeBindingElementAtReferenceLocation; if (includeOriginalSymbolOfBindingElement) { var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } function fromRoot(sym, kind) { // If this is a union property: @@ -140370,13 +141076,13 @@ var ts; return ts.firstDefined(checker.getRootSymbols(sym), function (rootSymbol) { return cbSymbol(sym, rootSymbol, /*baseSymbol*/ undefined, kind) // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol) + || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) && allowBaseTypes(rootSymbol) ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base, kind); }) : undefined); }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* SyntaxKind.BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -140398,7 +141104,7 @@ var ts; // interface C extends C { // /*findRef*/propName: string; // } - if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + if (!(symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) return; return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { var type = checker.getTypeAtLocation(typeReference); @@ -140412,12 +141118,12 @@ var ts; if (!symbol.valueDeclaration) return false; var modifierFlags = ts.getEffectiveModifierFlags(symbol.valueDeclaration); - return !!(modifierFlags & 32 /* Static */); + return !!(modifierFlags & 32 /* ModifierFlags.Static */); } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, /*isForRenamePopulateSearchSymbolSet*/ false, - /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { + /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* FindReferencesUse.Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { // check whether the symbol used to search itself is just the searched one. if (baseSymbol) { // static method/property and instance method/property might have the same name. Only check static or only check instance. @@ -140427,7 +141133,7 @@ var ts; } return search.includes(baseSymbol || rootSymbol || sym) // For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol. - ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* Synthetic */) ? rootSymbol : sym, kind: kind } + ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* CheckFlags.Synthetic */) ? rootSymbol : sym, kind: kind } : undefined; }, /*allowBaseTypes*/ function (rootSymbol) { @@ -140467,7 +141173,7 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : (ts.isVariableLike(node) ? ts.hasInitializer(node) : ts.isFunctionLikeDeclaration(node) ? !!node.body : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); @@ -140478,7 +141184,7 @@ var ts; if (shorthandSymbol) { for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { + if (ts.getMeaningFromDeclaration(declaration) & 1 /* SemanticMeaning.Value */) { addReference(declaration); } } @@ -140507,12 +141213,12 @@ var ts; var propertyAccessExpression = ts.isRightSideOfPropertyAccess(location) ? location.parent : undefined; var lhsType = propertyAccessExpression && checker.getTypeAtLocation(propertyAccessExpression.expression); var res = ts.mapDefined(lhsType && (lhsType.isUnionOrIntersection() ? lhsType.types : lhsType.symbol === symbol.parent ? undefined : [lhsType]), function (t) { - return t.symbol && t.symbol.flags & (32 /* Class */ | 64 /* Interface */) ? t.symbol : undefined; + return t.symbol && t.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) ? t.symbol : undefined; }); return res.length === 0 ? undefined : res; } function isForRenameWithPrefixAndSuffixText(options) { - return options.use === 2 /* Rename */ && options.providePrefixAndSuffixTextForRename; + return options.use === 2 /* FindReferencesUse.Rename */ && options.providePrefixAndSuffixTextForRename; } })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); @@ -140532,7 +141238,7 @@ var ts; && ts.isVariableDeclaration(node.parent) && node === node.parent.initializer && ts.isIdentifier(node.parent.name) - && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* Const */); + && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* NodeFlags.Const */); } /** * Indicates whether a node could possibly be a call hierarchy declaration. @@ -140581,7 +141287,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -140605,8 +141311,8 @@ var ts; var end = pos + 6; /* "static".length */ var typeChecker = program.getTypeChecker(); var symbol = typeChecker.getSymbolAtLocation(node.parent); - var prefix = symbol ? typeChecker.symbolToString(symbol, node.parent) + " " : ""; - return { text: prefix + "static {}", pos: pos, end: end }; + var prefix = symbol ? "".concat(typeChecker.symbolToString(symbol, node.parent), " ") : ""; + return { text: "".concat(prefix, "static {}"), pos: pos, end: end }; } var declName = isConstNamedExpression(node) ? node.parent.name : ts.Debug.checkDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name"); @@ -140626,7 +141332,7 @@ var ts; if (text === undefined) { // get the text from printing the node on a single line without comments... var printer_1 = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* Unspecified */, node, node.getSourceFile(), writer); }); + text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* EmitHint.Unspecified */, node, node.getSourceFile(), writer); }); } return { text: text, pos: declName.getStart(), end: declName.getEnd() }; } @@ -140639,16 +141345,16 @@ var ts; return; } switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText(); } return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText(); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -140675,8 +141381,8 @@ var ts; var declarations; if (symbol && symbol.declarations) { var indices = ts.indicesOf(symbol.declarations); - var keys_1 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); }); - indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_1[a].file, keys_1[b].file) || keys_1[a].pos - keys_1[b].pos; }); + var keys_2 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); }); + indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_2[a].file, keys_2[b].file) || keys_2[a].pos - keys_2[b].pos; }); var sortedDeclarations = ts.map(indices, function (i) { return symbol.declarations[i]; }); var lastDecl = void 0; for (var _i = 0, sortedDeclarations_1 = sortedDeclarations; _i < sortedDeclarations_1.length; _i++) { @@ -140746,7 +141452,7 @@ var ts; } return undefined; } - if (location.kind === 124 /* StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { + if (location.kind === 124 /* SyntaxKind.StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { location = location.parent; continue; } @@ -140757,7 +141463,7 @@ var ts; if (!followingSymbol) { var symbol = typeChecker.getSymbolAtLocation(location); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } if (symbol.valueDeclaration) { @@ -140787,7 +141493,7 @@ var ts; return x !== undefined; } function convertEntryToCallSite(entry) { - if (entry.kind === 1 /* Node */) { + if (entry.kind === 1 /* FindAllReferences.EntryKind.Node */) { var node = entry.node; if (ts.isCallOrNewExpressionTarget(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) || ts.isTaggedTemplateTag(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) @@ -140817,7 +141523,7 @@ var ts; return []; } var location = getCallHierarchyDeclarationReferenceNode(declaration); - var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* References */ }, convertEntryToCallSite), isDefined); + var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, convertEntryToCallSite), isDefined); return calls ? ts.group(calls, getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToIncomingCall(program, entries); }) : []; } CallHierarchy.getIncomingCalls = getIncomingCalls; @@ -140845,7 +141551,7 @@ var ts; function collect(node) { if (!node) return; - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // do not descend into ambient nodes. return; } @@ -140862,59 +141568,59 @@ var ts; return; } switch (node.kind) { - case 79 /* Identifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 79 /* SyntaxKind.Identifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: recordCallSite(node); return; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: recordCallSite(node); collect(node.expression); return; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -140931,7 +141637,7 @@ var ts; ts.forEach(node.statements, collect); } function collectCallSitesOfModuleDeclaration(node, collect) { - if (!ts.hasSyntacticModifier(node, 2 /* Ambient */) && node.body && ts.isModuleBlock(node.body)) { + if (!ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) && node.body && ts.isModuleBlock(node.body)) { ts.forEach(node.body.statements, collect); } } @@ -140972,25 +141678,25 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: collectCallSitesOfClassStaticBlockDeclaration(node, collect); break; default: @@ -141006,7 +141712,7 @@ var ts; } /** Gets the call sites that call out of the provided call hierarchy declaration. */ function getOutgoingCalls(program, declaration) { - if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) { + if (declaration.flags & 16777216 /* NodeFlags.Ambient */ || ts.isMethodSignature(declaration)) { return []; } return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); }); @@ -141124,7 +141830,7 @@ var ts; } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) { var allFiles = program.getSourceFiles(); - var _loop_5 = function (sourceFile) { + var _loop_4 = function (sourceFile) { var newFromOld = oldToNew(sourceFile.fileName); var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); @@ -141156,7 +141862,7 @@ var ts; }; for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { var sourceFile = allFiles_1[_i]; - _loop_5(sourceFile); + _loop_4(sourceFile); } } function combineNormal(pathA, pathB) { @@ -141261,13 +141967,13 @@ var ts; } var parent = node.parent; var typeChecker = program.getTypeChecker(); - if (node.kind === 159 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { + if (node.kind === 159 /* SyntaxKind.OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray; } // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 + return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { var classDecl = node.parent.parent; @@ -141278,7 +141984,7 @@ var ts; return ts.map(staticBlocks, function (staticBlock) { var pos = ts.moveRangePastModifiers(staticBlock).pos; pos = ts.skipTrivia(sourceFile_1.text, pos); - return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); + return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* ScriptElementKind.constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); }); } var _d = getSymbol(node, typeChecker, stopAtAlias), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution; @@ -141302,7 +142008,7 @@ var ts; fileName: ref.resolvedFileName, containerName: undefined, containerKind: undefined, - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, textSpan: ts.createTextSpan(0, 0), failedAliasResolution: failedAliasResolution, isAmbient: ts.isDeclarationFileName(ref.resolvedFileName), @@ -141329,7 +142035,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); + return node.kind === 106 /* SyntaxKind.SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -141337,7 +142043,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray; return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); @@ -141471,12 +142177,12 @@ var ts; // If a function returns 'void' or some other type with no definition, just return the function definition. var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution); return typeDefinitions.length ? typeDefinitions - : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) + : !(symbol.flags & 111551 /* SymbolFlags.Value */) && symbol.flags & 788968 /* SymbolFlags.Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) : undefined; } GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition; function definitionFromType(type, checker, node, failedAliasResolution) { - return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) { + return ts.flatMap(type.isUnion() && !(type.flags & 32 /* TypeFlags.Enum */) ? type.types : [type], function (t) { return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution); }); } @@ -141520,7 +142226,7 @@ var ts; // import {A, B} from "mod"; // to jump to the implementation directly. var failedAliasResolution = false; - if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* SymbolFlags.Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { return { symbol: aliased }; @@ -141537,13 +142243,13 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 79 /* Identifier */) { + if (node.kind !== 79 /* SyntaxKind.Identifier */) { return false; } if (node.parent === declaration) { return true; } - if (declaration.kind === 268 /* NamespaceImport */) { + if (declaration.kind === 268 /* SyntaxKind.NamespaceImport */) { return false; } return true; @@ -141575,7 +142281,7 @@ var ts; return "quit"; return false; }); - return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */; + return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* AssignmentDeclarationKind.Property */; } function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) { var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; }); @@ -141585,7 +142291,7 @@ var ts; function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* SymbolFlags.Class */ && !(symbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* SyntaxKind.ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -141625,7 +142331,7 @@ var ts; textSpan = ts.createTextSpanFromNode(name, sourceFile); } return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217 - containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* NodeFlags.Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); } function isDefinitionVisible(checker, declaration) { if (checker.isDeclarationVisible(declaration)) @@ -141637,22 +142343,22 @@ var ts; return isDefinitionVisible(checker, declaration.parent); // Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // Private/protected properties/methods are not visible - if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + if (ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) return false; // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: return isDefinitionVisible(checker, declaration.parent); default: return false; @@ -141669,7 +142375,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, name: name, containerName: undefined, containerKind: undefined, @@ -141690,9 +142396,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return true; default: return false; @@ -141798,17 +142504,17 @@ var ts; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var jsdoc = _a[_i]; - var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 327 /* JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); }); + var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 327 /* SyntaxKind.JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); }); // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @typedefs are themselves declarations with associated comments // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation if (jsdoc.comment === undefined && !inheritDoc || ts.isJSDoc(jsdoc) - && declaration.kind !== 345 /* JSDocTypedefTag */ && declaration.kind !== 338 /* JSDocCallbackTag */ + && declaration.kind !== 345 /* SyntaxKind.JSDocTypedefTag */ && declaration.kind !== 338 /* SyntaxKind.JSDocCallbackTag */ && jsdoc.tags - && jsdoc.tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + && jsdoc.tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !jsdoc.tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { continue; } var newparts = jsdoc.comment ? getDisplayPartsFromComment(jsdoc.comment, checker) : []; @@ -141828,11 +142534,11 @@ var ts; } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return [declaration]; - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -141846,8 +142552,8 @@ var ts; // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation - if (tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + if (tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { return; } for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) { @@ -141862,17 +142568,17 @@ var ts; if (typeof comment === "string") { return [ts.textPart(comment)]; } - return ts.flatMap(comment, function (node) { return node.kind === 321 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); + return ts.flatMap(comment, function (node) { return node.kind === 321 /* SyntaxKind.JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); } function getCommentDisplayParts(tag, checker) { var comment = tag.comment, kind = tag.kind; var namePart = getTagNameDisplayPart(kind); switch (kind) { - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return withNode(tag.class); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return withNode(tag.class); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: var templateTag = tag; var displayParts_3 = []; if (templateTag.constraint) { @@ -141886,7 +142592,7 @@ var ts; ts.forEach(templateTag.typeParameters, function (tp) { displayParts_3.push(namePart(tp.getText())); if (lastTypeParameter_1 !== tp) { - displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]); + displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]); } }); } @@ -141894,13 +142600,13 @@ var ts; displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true)); } return displayParts_3; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return withNode(tag.typeExpression); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: - case 346 /* JSDocSeeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: var name = tag.name; return name ? withNode(name) : comment === undefined ? undefined @@ -141927,14 +142633,14 @@ var ts; } function getTagNameDisplayPart(kind) { switch (kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return ts.parameterNamePart; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return ts.propertyNamePart; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return ts.typeParameterNamePart; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return ts.typeAliasNamePart; default: return ts.textPart; @@ -141944,7 +142650,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword" /* keyword */, + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority, }; @@ -141955,8 +142661,8 @@ var ts; function getJSDocTagCompletions() { return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { - name: "@" + tagName, - kind: "keyword" /* keyword */, + name: "@".concat(tagName), + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; @@ -141966,7 +142672,7 @@ var ts; function getJSDocTagCompletionDetails(name) { return { name: name, - kind: "" /* unknown */, + kind: "" /* ScriptElementKind.unknown */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -141992,14 +142698,14 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; + return { name: name, kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; function getJSDocParameterNameCompletionDetails(name) { return { name: name, - kind: "parameter" /* parameterElement */, + kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -142048,8 +142754,12 @@ var ts; return undefined; } var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn; - var commentOwnerJSDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? ts.lastOrUndefined(commentOwner.jsDoc) : undefined; - if (commentOwner.getStart(sourceFile) < position || commentOwnerJSDoc && commentOwnerJSDoc !== existingDocComment) { + var commentOwnerJsDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? commentOwner.jsDoc : undefined; + var lastJsDoc = ts.lastOrUndefined(commentOwnerJsDoc); + if (commentOwner.getStart(sourceFile) < position + || lastJsDoc + && existingDocComment + && lastJsDoc !== existingDocComment) { return undefined; } var indentationStr = getIndentationStringAtPosition(sourceFile, position); @@ -142066,7 +142776,9 @@ var ts; // * if the caret was directly in front of the object, then we add an extra line and indentation. var openComment = "/**"; var closeComment = " */"; - if (tags) { + // If any of the existing jsDoc has tags, ignore adding new ones. + var hasTag = (commentOwnerJsDoc || []).some(function (jsDoc) { return !!jsDoc.tags; }); + if (tags && !hasTag) { var preamble = openComment + newLine + indentationStr + " * "; var endLine = tokenStart === position ? newLine + indentationStr : ""; var result = preamble + newLine + tags + indentationStr + closeComment + endLine; @@ -142086,37 +142798,37 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* SyntaxKind.Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; - return indentationStr + " * @param " + type + paramName + newLine; + return "".concat(indentationStr, " * @param ").concat(type).concat(paramName).concat(newLine); }).join(""); } function returnsDocComment(indentationStr, newLine) { - return indentationStr + " * @returns" + newLine; + return "".concat(indentationStr, " * @returns").concat(newLine); } function getCommentOwnerInfo(tokenAtPos, options) { return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: var host = commentOwner; return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer, options); - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 166 /* PropertySignature */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -142126,25 +142838,25 @@ var ts; ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return "quit"; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 261 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 238 /* ExpressionStatement */: + return commentOwner.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 238 /* SyntaxKind.ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression, options); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var be = commentOwner; - if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { + if (ts.getAssignmentDeclarationKind(be) === 0 /* AssignmentDeclarationKind.None */) { return "quit"; } return ts.isFunctionLike(be.right) ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; @@ -142157,14 +142869,14 @@ var ts; || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 212 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return rightHandSide; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -142180,7 +142892,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_6 = function (sourceFile) { + var _loop_5 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && sourceFile.isDeclarationFile) { return "continue"; @@ -142192,7 +142904,7 @@ var ts; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var sourceFile = sourceFiles_4[_i]; - _loop_6(sourceFile); + _loop_5(sourceFile); } rawItems.sort(compareNavigateToItems); return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); @@ -142223,9 +142935,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -142235,7 +142947,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 162 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -142252,7 +142964,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 162 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -142286,7 +142998,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, + containerKind: containerName ? ts.getNodeKind(container) : "" /* ScriptElementKind.unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -142469,7 +143181,7 @@ var ts; */ function hasNavigationBarName(node) { return !ts.hasDynamicName(node) || - (node.kind !== 221 /* BinaryExpression */ && + (node.kind !== 221 /* SyntaxKind.BinaryExpression */ && ts.isPropertyAccessExpression(node.name.expression) && ts.isIdentifier(node.name.expression.expression) && ts.idText(node.name.expression.expression) === "Symbol"); @@ -142482,7 +143194,7 @@ var ts; return; } switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -142494,25 +143206,25 @@ var ts; } } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 168 /* SyntaxKind.MethodSignature */: if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (hasNavigationBarName(node)) { addNodeWithRecursiveInitializer(node); } break; - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -142524,7 +143236,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -142535,17 +143247,17 @@ var ts; } } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: var expression = node.expression; // Use the expression as the name of the SpreadAssignment, otherwise show as . ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); break; - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: - case 254 /* VariableDeclaration */: { + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: { var child = node; if (ts.isBindingPattern(child.name)) { addChildrenRecursively(child.name); @@ -142555,7 +143267,7 @@ var ts; } break; } - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -142563,11 +143275,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -142577,9 +143289,9 @@ var ts; } endNode(); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -142587,10 +143299,10 @@ var ts; } endNode(); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression_1 = node.expression; var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 : ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined; @@ -142604,27 +143316,27 @@ var ts; } break; } - case 275 /* ExportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 176 /* IndexSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 259 /* TypeAliasDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: addLeafNode(node); break; - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: addNodeWithRecursiveChild(node, node.right); return; - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: { + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; - var prototypeAccess = special === 3 /* PrototypeProperty */ ? + var prototypeAccess = special === 3 /* AssignmentDeclarationKind.PrototypeProperty */ ? assignmentTarget.expression : assignmentTarget; var depth = 0; @@ -142638,7 +143350,7 @@ var ts; else { _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; } - if (special === 6 /* Prototype */) { + if (special === 6 /* AssignmentDeclarationKind.Prototype */) { if (ts.isObjectLiteralExpression(binaryExpression.right)) { if (binaryExpression.right.properties.length > 0) { startNode(binaryExpression, className); @@ -142658,10 +143370,10 @@ var ts; endNestedNodes(depth); return; } - case 7 /* ObjectDefinePropertyValue */: - case 9 /* ObjectDefinePrototypeProperty */: { + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: { var defineCall = node; - var className = special === 7 /* ObjectDefinePropertyValue */ ? + var className = special === 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */ ? defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; @@ -142674,7 +143386,7 @@ var ts; endNestedNodes(depth); return; } - case 5 /* Property */: { + case 5 /* AssignmentDeclarationKind.Property */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; var targetFunction = assignmentTarget.expression; @@ -142692,9 +143404,9 @@ var ts; } break; } - case 4 /* ThisProperty */: - case 0 /* None */: - case 8 /* ObjectDefinePropertyExports */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: break; default: ts.Debug.assertNever(special); @@ -142750,16 +143462,16 @@ var ts; }); } var isEs5ClassMember = (_a = {}, - _a[5 /* Property */] = true, - _a[3 /* PrototypeProperty */] = true, - _a[7 /* ObjectDefinePropertyValue */] = true, - _a[9 /* ObjectDefinePrototypeProperty */] = true, - _a[0 /* None */] = false, - _a[1 /* ExportsProperty */] = false, - _a[2 /* ModuleExports */] = false, - _a[8 /* ObjectDefinePropertyExports */] = false, - _a[6 /* Prototype */] = true, - _a[4 /* ThisProperty */] = false, + _a[5 /* AssignmentDeclarationKind.Property */] = true, + _a[3 /* AssignmentDeclarationKind.PrototypeProperty */] = true, + _a[7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */] = true, + _a[9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */] = true, + _a[0 /* AssignmentDeclarationKind.None */] = false, + _a[1 /* AssignmentDeclarationKind.ExportsProperty */] = false, + _a[2 /* AssignmentDeclarationKind.ModuleExports */] = false, + _a[8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */] = false, + _a[6 /* AssignmentDeclarationKind.Prototype */] = true, + _a[4 /* AssignmentDeclarationKind.ThisProperty */] = false, _a); function tryMergeEs5Class(a, b, bIndex, parent) { function isPossibleConstructor(node) { @@ -142767,10 +143479,10 @@ var ts; } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -142834,7 +143546,7 @@ var ts; } return true; } - return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + return bAssignmentDeclarationKind === 0 /* AssignmentDeclarationKind.None */ ? false : true; } function tryMerge(a, b, bIndex, parent) { // const v = false as boolean; @@ -142853,12 +143565,12 @@ var ts; return false; } switch (a.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.isStatic(a) === ts.isStatic(b); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return areSameModule(a, b) && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: @@ -142866,7 +143578,7 @@ var ts; } } function isSynthesized(node) { - return !!(node.flags & 8 /* Synthesized */); + return !!(node.flags & 8 /* NodeFlags.Synthesized */); } // We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }` // We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };` @@ -142880,7 +143592,7 @@ var ts; if (!a.body || !b.body) { return a.body === b.body; } - return a.body.kind === b.body.kind && (a.body.kind !== 261 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 261 /* SyntaxKind.ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -142910,7 +143622,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -142919,53 +143631,53 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { var text = ts.isIdentifier(name) ? name.text - : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : ts.isElementAccessExpression(name) ? "[".concat(nodeText(name.argumentExpression), "]") : nodeText(name); if (text.length > 0) { return cleanText(text); } } switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" + ? "\"".concat(ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))), "\"") : ""; - case 271 /* ExportAssignment */: - return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + case 271 /* SyntaxKind.ExportAssignment */: + return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } // We may get a string with newlines or other whitespace in the case of an object dereference // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return "new()"; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return "()"; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return "[]"; default: return ""; @@ -142998,19 +143710,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 305 /* SourceFile */: - case 259 /* TypeAliasDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return true; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -143020,10 +143732,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: return true; default: return false; @@ -143085,7 +143797,7 @@ var ts; function getFullyQualifiedModuleName(moduleDeclaration) { // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)]; - while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -143099,13 +143811,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 162 /* ComputedPropertyName */; + return !member.name || member.name.kind === 162 /* SyntaxKind.ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 305 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 254 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -143120,7 +143832,7 @@ var ts; return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -143128,7 +143840,7 @@ var ts; return nodeText(parent.name); } // Default exports are named "default" - else if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + else if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } else if (ts.isClassLike(node)) { @@ -143139,10 +143851,10 @@ var ts; if (name !== undefined) { name = cleanText(name); if (name.length > maxLength) { - return name + " callback"; + return "".concat(name, " callback"); } var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); - return name + "(" + args + ") callback"; + return "".concat(name, "(").concat(args, ") callback"); } } return ""; @@ -143155,7 +143867,7 @@ var ts; else if (ts.isPropertyAccessExpression(expr)) { var left = getCalledExpressionName(expr.expression); var right = expr.name.text; - return left === undefined ? right : left + "." + right; + return left === undefined ? right : "".concat(left, ".").concat(right); } else { return undefined; @@ -143163,9 +143875,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; default: return false; @@ -143279,7 +143991,7 @@ var ts; var numberOfNewLines = 0; while (scanner.getTokenPos() < endPos) { var tokenKind = scanner.scan(); - if (tokenKind === 4 /* NewLineTrivia */) { + if (tokenKind === 4 /* SyntaxKind.NewLineTrivia */) { numberOfNewLines++; if (numberOfNewLines >= 2) { return true; @@ -143297,7 +144009,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); - var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */); + var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* TransformFlags.ContainsJsx */); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -143566,11 +144278,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return declaration.moduleSpecifier; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -143609,19 +144321,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!s1.importClause) return 0; if (s1.importClause.isTypeOnly) return 1; - if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* SyntaxKind.NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return 5; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return 6; } } @@ -143674,7 +144386,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* SyntaxKind.ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* OutliningSpanKind.Imports */)); } } function visitNonImportNode(n) { @@ -143682,7 +144394,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* EndOfFileToken */) { + if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* SyntaxKind.EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (ts.isFunctionLike(n) && ts.isBinaryExpression(n.parent) && ts.isPropertyAccessExpression(n.parent.left)) { @@ -143732,7 +144444,7 @@ var ts; } if (!result[1]) { var span = ts.createTextSpanFromBounds(sourceFile.text.indexOf("//", currentLineStart), lineEnd); - regions.push(createOutliningSpan(span, "region" /* Region */, span, /*autoCollapse*/ false, result[2] || "#region")); + regions.push(createOutliningSpan(span, "region" /* OutliningSpanKind.Region */, span, /*autoCollapse*/ false, result[2] || "#region")); } else { var region = regions.pop(); @@ -143767,7 +144479,7 @@ var ts; var _a = comments_1[_i], kind = _a.kind, pos_1 = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: // never fold region delimiters into single-line comment regions var commentText = sourceText.slice(pos_1, end); if (isRegionDelimiter(commentText)) { @@ -143783,9 +144495,9 @@ var ts; lastSingleLineCommentEnd = end; singleLineCommentCount++; break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: combineAndAddMultipleSingleLineComments(); - out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* OutliningSpanKind.Comment */)); singleLineCommentCount = 0; break; default: @@ -143796,7 +144508,7 @@ var ts; function combineAndAddMultipleSingleLineComments() { // Only outline spans of two or more consecutive single line comments if (singleLineCommentCount > 1) { - out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* OutliningSpanKind.Comment */)); } } } @@ -143810,7 +144522,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -143818,23 +144530,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 240 /* DoStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 292 /* CatchClause */: + case 240 /* SyntaxKind.DoStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 292 /* SyntaxKind.CatchClause */: return spanForNode(n.parent); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -143842,52 +144554,52 @@ var ts; default: // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); + return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* OutliningSpanKind.Code */); } - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanForNode(n.parent); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 263 /* CaseBlock */: - case 182 /* TypeLiteral */: - case 201 /* ObjectBindingPattern */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 263 /* SyntaxKind.CaseBlock */: + case 182 /* SyntaxKind.TypeLiteral */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return spanForNode(n); - case 184 /* TupleType */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 184 /* SyntaxKind.TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return spanForNodeArray(n.statements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 204 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 278 /* JsxElement */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* SyntaxKind.OpenBracketToken */); + case 278 /* SyntaxKind.JsxElement */: return spanForJSXElement(n); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return spanForJSXFragment(n); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 202 /* ArrayBindingPattern */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 214 /* ArrowFunction */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 214 /* SyntaxKind.ArrowFunction */: return spanForArrowFunction(n); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return spanForCallExpression(n); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanForParenthesizedExpression(n); } function spanForCallExpression(node) { if (!node.arguments.length) { return undefined; } - var openToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); - var closeToken = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + var openToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); + var closeToken = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!openToken || !closeToken || ts.positionsAreOnSameLine(openToken.pos, closeToken.pos, sourceFile)) { return undefined; } @@ -143898,33 +144610,33 @@ var ts; return undefined; } var textSpan = ts.createTextSpanFromBounds(node.body.getFullStart(), node.body.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); var tagName = node.openingElement.tagName.getText(sourceFile); var bannerText = "<" + tagName + ">..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXFragment(node) { var textSpan = ts.createTextSpanFromBounds(node.openingFragment.getStart(sourceFile), node.closingFragment.getEnd()); var bannerText = "<>..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXAttributes(node) { if (node.properties.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForTemplateLiteral(node) { - if (node.kind === 14 /* NoSubstitutionTemplateLiteral */ && node.text.length === 0) { + if (node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ && node.text.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 18 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal or call expression, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -143933,32 +144645,32 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open, close) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 18 /* OpenBraceToken */; } - if (close === void 0) { close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } + if (close === void 0) { close = open === 18 /* SyntaxKind.OpenBraceToken */ ? 19 /* SyntaxKind.CloseBraceToken */ : 23 /* SyntaxKind.CloseBracketToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); var closeToken = ts.findChildOfKind(n, close, sourceFile); return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart); } function spanForNodeArray(nodeArray) { - return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* Code */) : undefined; + return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* OutliningSpanKind.Code */) : undefined; } function spanForParenthesizedExpression(node) { if (ts.positionsAreOnSameLine(node.getStart(), node.getEnd(), sourceFile)) return undefined; var textSpan = ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } } function functionSpan(node, body, sourceFile) { var openToken = tryGetFunctionOpenToken(node, body, sourceFile); - var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* ArrowFunction */); + var closeToken = ts.findChildOfKind(body, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* SyntaxKind.ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } var textSpan = ts.createTextSpanFromBounds(useFullStart ? openToken.getFullStart() : openToken.getStart(sourceFile), closeToken.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); } function createOutliningSpan(textSpan, kind, hintSpan, autoCollapse, bannerText) { if (hintSpan === void 0) { hintSpan = textSpan; } @@ -143968,12 +144680,12 @@ var ts; } function tryGetFunctionOpenToken(node, body, sourceFile) { if (ts.isNodeArrayMultiLine(node.parameters, sourceFile)) { - var openParenToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + var openParenToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (openParenToken) { return openParenToken; } } - return ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); + return ts.findChildOfKind(body, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); } })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); })(ts || (ts = {})); @@ -144099,7 +144811,7 @@ var ts; // // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. - if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* space */ && ch !== 42 /* asterisk */; })) { + if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* CharacterCodes.space */ && ch !== 42 /* CharacterCodes.asterisk */; })) { var match = matchTextChunk(candidate, segment.totalTextChunk, stringToWordSpans); if (match) return match; @@ -144151,7 +144863,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ + return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { @@ -144228,10 +144940,10 @@ var ts; } function isUpperCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -144241,10 +144953,10 @@ var ts; } function isLowerCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -144255,13 +144967,13 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_7 = function (start) { + var _loop_6 = function (start) { if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) { return { value: start }; } }; for (var start = 0; start <= n; start++) { - var state_3 = _loop_7(start); + var state_3 = _loop_6(start); if (typeof state_3 === "object") return state_3.value; } @@ -144269,10 +144981,10 @@ var ts; } function toLowerCase(ch) { // Fast convert for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return 97 /* a */ + (ch - 65 /* A */); + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { + return 97 /* CharacterCodes.a */ + (ch - 65 /* CharacterCodes.A */); } - if (ch < 127 /* maxAsciiCharacter */) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */) { return ch; } // TODO: find a way to compute this for any unicode characters in a @@ -144281,10 +144993,10 @@ var ts; } function isDigit(ch) { // TODO(cyrusn): Find a way to support this for unicode digits. - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* CharacterCodes._ */ || ch === 36 /* CharacterCodes.$ */; } function breakPatternIntoTextChunks(pattern) { var result = []; @@ -144353,35 +145065,35 @@ var ts; } function charIsPunctuation(ch) { switch (ch) { - case 33 /* exclamation */: - case 34 /* doubleQuote */: - case 35 /* hash */: - case 37 /* percent */: - case 38 /* ampersand */: - case 39 /* singleQuote */: - case 40 /* openParen */: - case 41 /* closeParen */: - case 42 /* asterisk */: - case 44 /* comma */: - case 45 /* minus */: - case 46 /* dot */: - case 47 /* slash */: - case 58 /* colon */: - case 59 /* semicolon */: - case 63 /* question */: - case 64 /* at */: - case 91 /* openBracket */: - case 92 /* backslash */: - case 93 /* closeBracket */: - case 95 /* _ */: - case 123 /* openBrace */: - case 125 /* closeBrace */: + case 33 /* CharacterCodes.exclamation */: + case 34 /* CharacterCodes.doubleQuote */: + case 35 /* CharacterCodes.hash */: + case 37 /* CharacterCodes.percent */: + case 38 /* CharacterCodes.ampersand */: + case 39 /* CharacterCodes.singleQuote */: + case 40 /* CharacterCodes.openParen */: + case 41 /* CharacterCodes.closeParen */: + case 42 /* CharacterCodes.asterisk */: + case 44 /* CharacterCodes.comma */: + case 45 /* CharacterCodes.minus */: + case 46 /* CharacterCodes.dot */: + case 47 /* CharacterCodes.slash */: + case 58 /* CharacterCodes.colon */: + case 59 /* CharacterCodes.semicolon */: + case 63 /* CharacterCodes.question */: + case 64 /* CharacterCodes.at */: + case 91 /* CharacterCodes.openBracket */: + case 92 /* CharacterCodes.backslash */: + case 93 /* CharacterCodes.closeBracket */: + case 95 /* CharacterCodes._ */: + case 123 /* CharacterCodes.openBrace */: + case 125 /* CharacterCodes.closeBrace */: return true; } return false; } function isAllPunctuation(identifier, start, end) { - return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* _ */; }, start, end); + return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* CharacterCodes._ */; }, start, end); } function transitionFromUpperToLower(identifier, index, wordStart) { // Cases this supports: @@ -144442,7 +145154,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var pragmaContext = { - languageVersion: 1 /* ES5 */, + languageVersion: 1 /* ScriptTarget.ES5 */, pragmas: undefined, checkJsDirective: undefined, referencedFiles: [], @@ -144463,10 +145175,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 18 /* OpenBraceToken */) { + if (currentToken === 18 /* SyntaxKind.OpenBraceToken */) { braceNesting++; } - else if (currentToken === 19 /* CloseBraceToken */) { + else if (currentToken === 19 /* SyntaxKind.CloseBraceToken */) { braceNesting--; } return currentToken; @@ -144496,12 +145208,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 135 /* DeclareKeyword */) { + if (token === 135 /* SyntaxKind.DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 141 /* ModuleKeyword */) { + if (token === 141 /* SyntaxKind.ModuleKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { recordAmbientExternalModule(); } } @@ -144513,54 +145225,54 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 24 /* DotToken */) { + if (lastToken === 24 /* SyntaxKind.DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 100 /* ImportKeyword */) { + if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 10 /* StringLiteral */) { + else if (token === 10 /* SyntaxKind.StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 156 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */ || - token === 79 /* Identifier */ || + return token !== 156 /* SyntaxKind.FromKeyword */ && (token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */ || + token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 63 /* EqualsToken */) { + else if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 27 /* CommaToken */) { + else if (token === 27 /* SyntaxKind.CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -144569,18 +145281,18 @@ var ts; return true; } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -144588,15 +145300,15 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 127 /* AsKeyword */) { + if (token === 127 /* SyntaxKind.AsKeyword */) { token = nextToken(); - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -144612,31 +145324,31 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 93 /* ExportKeyword */) { + if (token === 93 /* SyntaxKind.ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */; + return token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */; }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -144644,31 +145356,31 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 100 /* ImportKeyword */) { + else if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 79 /* Identifier */ || + return token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 63 /* EqualsToken */) { + if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -144682,12 +145394,12 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 146 /* RequireKeyword */) { + if (token === 146 /* SyntaxKind.RequireKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || - allowTemplateLiterals && token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || + allowTemplateLiterals && token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // require("mod"); recordModuleName(); } @@ -144698,16 +145410,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* SyntaxKind.Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 20 /* OpenParenToken */) { + if (token !== 20 /* SyntaxKind.OpenParenToken */) { return true; } token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 27 /* CommaToken */) { + if (token === 27 /* SyntaxKind.CommaToken */) { token = nextToken(); } else { @@ -144716,15 +145428,15 @@ var ts; } } // should be start of dependency list - if (token !== 22 /* OpenBracketToken */) { + if (token !== 22 /* SyntaxKind.OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* SyntaxKind.CloseBracketToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { // record string literals as module names - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { recordModuleName(); } token = nextToken(); @@ -144752,31 +145464,31 @@ var ts; // AnySymbol.import("mod") // AnySymbol.nested.import("mod") while (true) { - if (ts.scanner.getToken() === 1 /* EndOfFileToken */) { + if (ts.scanner.getToken() === 1 /* SyntaxKind.EndOfFileToken */) { break; } - if (ts.scanner.getToken() === 15 /* TemplateHead */) { + if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) { var stack = [ts.scanner.getToken()]; var token = ts.scanner.scan(); loop: while (ts.length(stack)) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: tryConsumeImport(); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: stack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.length(stack)) { stack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (ts.length(stack)) { - if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) { - if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) { + if (ts.lastOrUndefined(stack) === 15 /* SyntaxKind.TemplateHead */) { + if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* SyntaxKind.TemplateTail */) { stack.pop(); } } @@ -144863,13 +145575,13 @@ var ts; if (!symbol) { if (ts.isStringLiteralLike(node)) { var type = ts.getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker); - if (type && ((type.flags & 128 /* StringLiteral */) || ((type.flags & 1048576 /* Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* StringLiteral */); })))) { - return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile); + if (type && ((type.flags & 128 /* TypeFlags.StringLiteral */) || ((type.flags & 1048576 /* TypeFlags.Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); })))) { + return getRenameInfoSuccess(node.text, node.text, "string" /* ScriptElementKind.string */, "", node, sourceFile); } } else if (ts.isLabelName(node)) { var name = ts.getTextOfNode(node); - return getRenameInfoSuccess(name, name, "label" /* label */, "" /* none */, node, sourceFile); + return getRenameInfoSuccess(name, name, "label" /* ScriptElementKind.label */, "" /* ScriptElementKindModifier.none */, node, sourceFile); } return undefined; } @@ -144882,7 +145594,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* SymbolFlags.Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { @@ -144894,7 +145606,7 @@ var ts; return getRenameInfoError(wouldRenameNodeModules); } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -144903,10 +145615,10 @@ var ts; } function isDefinedInLibraryFile(program, declaration) { var sourceFile = declaration.getSourceFile(); - return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Extension.Dts */); } function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) { - if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) { + if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* SymbolFlags.Alias */) { var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); }); if (importSpecifier && !importSpecifier.propertyName) { symbol = checker.getAliasedSymbol(symbol); @@ -144932,7 +145644,7 @@ var ts; if (declPackage) { var length_2 = Math.min(originalPackage.length, declPackage.length); for (var i = 0; i <= length_2; i++) { - if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) { + if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* Comparison.EqualTo */) { return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder; } } @@ -144957,7 +145669,7 @@ var ts; return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); var name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; - var kind = withoutIndex === undefined ? "module" /* moduleElement */ : "directory" /* directory */; + var kind = withoutIndex === undefined ? "module" /* ScriptElementKind.moduleElement */ : "directory" /* ScriptElementKind.directory */; var indexAfterLastSlash = node.text.lastIndexOf("/") + 1; // Span should only be the last component of the path. + 1 to account for the quote character. var triggerSpan = ts.createTextSpan(node.getStart(sourceFile) + 1 + indexAfterLastSlash, node.text.length - indexAfterLastSlash); @@ -144967,7 +145679,7 @@ var ts; kind: kind, displayName: name, fullDisplayName: name, - kindModifiers: "" /* none */, + kindModifiers: "" /* ScriptElementKindModifier.none */, triggerSpan: triggerSpan, }; } @@ -144997,13 +145709,13 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return true; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); default: return false; @@ -145018,7 +145730,7 @@ var ts; var SmartSelectionRange; (function (SmartSelectionRange) { function getSmartSelectionRange(pos, sourceFile) { - var _a; + var _a, _b; var selectionRange = { textSpan: ts.createTextSpanFromBounds(sourceFile.getFullStart(), sourceFile.getEnd()) }; @@ -145035,7 +145747,7 @@ var ts; break outer; } var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); - if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment && comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { pushSelectionCommentRange(comment.pos, comment.end); } if (positionShouldSnapToNode(sourceFile, pos, node)) { @@ -145070,6 +145782,17 @@ var ts; if (ts.hasJSDocNodes(node) && ((_a = node.jsDoc) === null || _a === void 0 ? void 0 : _a.length)) { pushSelectionRange(ts.first(node.jsDoc).getStart(), end); } + // (#39618 & #49807) + // When the node is a SyntaxList and its first child has a JSDoc comment, then the node's + // `start` (which usually is the result of calling `node.getStart()`) points to the first + // token after the JSDoc comment. So, we have to make sure we'd pushed the selection + // covering the JSDoc comment before diving further. + if (ts.isSyntaxList(node)) { + var firstChild = node.getChildren()[0]; + if (firstChild && ts.hasJSDocNodes(firstChild) && ((_b = firstChild.jsDoc) === null || _b === void 0 ? void 0 : _b.length) && firstChild.getStart() !== node.pos) { + start = Math.min(start, ts.first(firstChild.jsDoc).getStart()); + } + } pushSelectionRange(start, end); // String literals should have a stop both inside and outside their quotes. if (ts.isStringLiteral(node) || ts.isTemplateLiteral(node)) { @@ -145103,7 +145826,7 @@ var ts; function pushSelectionCommentRange(start, end) { pushSelectionRange(start, end); var pos = start; - while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + while (sourceFile.text.charCodeAt(pos) === 47 /* CharacterCodes.slash */) { pos++; } pushSelectionRange(pos, end); @@ -145143,6 +145866,7 @@ var ts; * other as well as of other top-level statements and declarations. */ function getSelectionChildren(node) { + var _a; // Group top-level imports if (ts.isSourceFile(node)) { return groupChildren(node.getChildAt(0).getChildren(), isImport); @@ -145158,28 +145882,28 @@ var ts; // because it allows the mapped type to become an object type with a // few keystrokes. if (ts.isMappedTypeNode(node)) { - var _a = node.getChildren(), openBraceToken = _a[0], children = _a.slice(1); + var _b = node.getChildren(), openBraceToken = _b[0], children = _b.slice(1); var closeBraceToken = ts.Debug.checkDefined(children.pop()); - ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */); - ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); + ts.Debug.assertEqual(openBraceToken.kind, 18 /* SyntaxKind.OpenBraceToken */); + ts.Debug.assertEqual(closeBraceToken.kind, 19 /* SyntaxKind.CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 145 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 57 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 145 /* SyntaxKind.ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* SyntaxKind.QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; - return kind === 22 /* OpenBracketToken */ || - kind === 163 /* TypeParameter */ || - kind === 23 /* CloseBracketToken */; + return kind === 22 /* SyntaxKind.OpenBracketToken */ || + kind === 163 /* SyntaxKind.TypeParameter */ || + kind === 23 /* SyntaxKind.CloseBracketToken */; }); return [ openBraceToken, // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; })), closeBraceToken, ]; @@ -145189,10 +145913,13 @@ var ts; var children = groupChildren(node.getChildren(), function (child) { return child === node.name || ts.contains(node.modifiers, child); }); - return splitChildren(children, function (_a) { + var firstJSDocChild = ((_a = children[0]) === null || _a === void 0 ? void 0 : _a.kind) === 320 /* SyntaxKind.JSDoc */ ? children[0] : undefined; + var withJSDocSeparated = firstJSDocChild ? children.slice(1) : children; + var splittedChildren = splitChildren(withJSDocSeparated, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; }); + return firstJSDocChild ? [firstJSDocChild, createSyntaxList(splittedChildren)] : splittedChildren; } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. if (ts.isParameter(node)) { @@ -145204,14 +145931,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } return node.getChildren(); @@ -145267,7 +145994,7 @@ var ts; var leftChildren = children.slice(0, splitTokenIndex); var splitToken = children[splitTokenIndex]; var lastToken = ts.last(children); - var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SemicolonToken */; + var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */; var rightChildren = children.slice(splitTokenIndex + 1, separateLastToken ? children.length - 1 : undefined); var result = ts.compact([ leftChildren.length ? createSyntaxList(leftChildren) : undefined, @@ -145282,25 +146009,25 @@ var ts; } function isListOpener(token) { var kind = token && token.kind; - return kind === 18 /* OpenBraceToken */ - || kind === 22 /* OpenBracketToken */ - || kind === 20 /* OpenParenToken */ - || kind === 280 /* JsxOpeningElement */; + return kind === 18 /* SyntaxKind.OpenBraceToken */ + || kind === 22 /* SyntaxKind.OpenBracketToken */ + || kind === 20 /* SyntaxKind.OpenParenToken */ + || kind === 280 /* SyntaxKind.JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; - return kind === 19 /* CloseBraceToken */ - || kind === 23 /* CloseBracketToken */ - || kind === 21 /* CloseParenToken */ - || kind === 281 /* JsxClosingElement */; + return kind === 19 /* SyntaxKind.CloseBraceToken */ + || kind === 23 /* SyntaxKind.CloseBracketToken */ + || kind === 21 /* SyntaxKind.CloseParenToken */ + || kind === 281 /* SyntaxKind.JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 340 /* JSDocParameterTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 345 /* JSDocTypedefTag */: - case 342 /* JSDocThisTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 342 /* SyntaxKind.JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -145347,7 +146074,7 @@ var ts; return ts.isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined; } return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { - return candidateInfo.kind === 0 /* Candidate */ + return candidateInfo.kind === 0 /* CandidateOrTypeKind.Candidate */ ? createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker) : createTypeHelpItems(candidateInfo.symbol, argumentInfo, sourceFile, typeChecker); }); @@ -145361,27 +146088,27 @@ var ts; function getCandidateOrTypeInfo(_a, checker, sourceFile, startingToken, onlyUseSyntacticOwners) { var invocation = _a.invocation, argumentCount = _a.argumentCount; switch (invocation.kind) { - case 0 /* Call */: { + case 0 /* InvocationKind.Call */: { if (onlyUseSyntacticOwners && !isSyntacticOwner(startingToken, invocation.node, sourceFile)) { return undefined; } var candidates = []; var resolvedSignature = checker.getResolvedSignatureForSignatureHelp(invocation.node, candidates, argumentCount); // TODO: GH#18217 - return candidates.length === 0 ? undefined : { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; + return candidates.length === 0 ? undefined : { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; } - case 1 /* TypeArgs */: { + case 1 /* InvocationKind.TypeArgs */: { var called = invocation.called; if (onlyUseSyntacticOwners && !containsPrecedingToken(startingToken, sourceFile, ts.isIdentifier(called) ? called.parent : called)) { return undefined; } var candidates = ts.getPossibleGenericSignatures(called, argumentCount, checker); if (candidates.length !== 0) - return { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; var symbol = checker.getSymbolAtLocation(called); - return symbol && { kind: 1 /* Type */, symbol: symbol }; + return symbol && { kind: 1 /* CandidateOrTypeKind.Type */, symbol: symbol }; } - case 2 /* Contextual */: - return { kind: 0 /* Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; + case 2 /* InvocationKind.Contextual */: + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; default: return ts.Debug.assertNever(invocation); } @@ -145391,20 +146118,20 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 27 /* CommaToken */: { + case 27 /* SyntaxKind.CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; } } function createJSSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind === 2 /* Contextual */) + if (argumentInfo.invocation.kind === 2 /* InvocationKind.Contextual */) return undefined; // See if we can find some symbol with the call expression name that has call signatures. var expression = getExpressionFromInvocation(argumentInfo.invocation); @@ -145440,7 +146167,7 @@ var ts; } function getArgumentInfoForCompletions(node, position, sourceFile) { var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); - return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? undefined + return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* InvocationKind.Call */ ? undefined : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; } SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; @@ -145457,7 +146184,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* SyntaxKind.LessThanToken */ || node.kind === 20 /* SyntaxKind.OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -145500,7 +146227,7 @@ var ts; return undefined; var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var isTypeParameterList = !!parent.typeArguments && parent.typeArguments.pos === list.pos; - return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* InvocationKind.Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { // Check if we're actually inside the template; @@ -145510,10 +146237,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 223 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 223 /* SyntaxKind.TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -145538,7 +146265,7 @@ var ts; var attributeSpanEnd = ts.skipTrivia(sourceFile.text, parent.attributes.end, /*stopAfterLineBreak*/ false); return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: parent }, + invocation: { kind: 0 /* InvocationKind.Call */, node: parent }, argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), argumentIndex: 0, argumentCount: 1 @@ -145548,7 +146275,7 @@ var ts; var typeArgInfo = ts.getPossibleTypeArgumentsInfo(node, sourceFile); if (typeArgInfo) { var called = typeArgInfo.called, nTypeArguments = typeArgInfo.nTypeArguments; - var invocation = { kind: 1 /* TypeArgs */, called: called }; + var invocation = { kind: 1 /* InvocationKind.TypeArgs */, called: called }; var argumentsSpan = ts.createTextSpanFromBounds(called.getStart(sourceFile), node.end); return { isTypeParameterList: true, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: nTypeArguments, argumentCount: nTypeArguments + 1 }; } @@ -145577,28 +146304,28 @@ var ts; var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures()); if (signature === undefined) return undefined; - var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; + var invocation = { kind: 2 /* InvocationKind.Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) { - if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) + if (startingToken.kind !== 20 /* SyntaxKind.OpenParenToken */ && startingToken.kind !== 27 /* SyntaxKind.CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* SyntaxKind.OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; var argumentCount_1 = countBinaryExpressionParameters(highestBinary); return contextualType_1 && { contextualType: contextualType_1, argumentIndex: argumentIndex_1, argumentCount: argumentCount_1, argumentsSpan: ts.createTextSpanFromNode(parent) }; } @@ -145608,7 +146335,7 @@ var ts; } // The type of a function type node has a symbol at that node, but it's better to use the symbol for a parameter or type alias. function chooseBetterSymbol(s) { - return s.name === "__type" /* Type */ + return s.name === "__type" /* InternalSymbolName.Type */ ? ts.firstDefined(s.declarations, function (d) { return ts.isFunctionTypeNode(d) ? d.parent.symbol : undefined; }) || s : s; } @@ -145630,7 +146357,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 27 /* CommaToken */) { + if (child.kind !== 27 /* SyntaxKind.CommaToken */) { argumentIndex++; } } @@ -145649,8 +146376,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); - if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* SyntaxKind.CommaToken */; }); + if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* SyntaxKind.CommaToken */) { argumentCount++; } return argumentCount; @@ -145688,7 +146415,7 @@ var ts; } return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: tagExpression }, + invocation: { kind: 0 /* InvocationKind.Call */, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -145719,7 +146446,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -145728,17 +146455,17 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) { - var _loop_8 = function (n) { + var _loop_7 = function (n) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. - ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); }); + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: ".concat(ts.Debug.formatSyntaxKind(n.kind), ", parent: ").concat(ts.Debug.formatSyntaxKind(n.parent.kind)); }); var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker); if (argumentInfo) { return { value: argumentInfo }; } }; for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) { - var state_4 = _loop_8(n); + var state_4 = _loop_7(n); if (typeof state_4 === "object") return state_4.value; } @@ -145751,17 +146478,17 @@ var ts; return children[indexOfOpenerToken + 1]; } function getExpressionFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; + return invocation.kind === 0 /* InvocationKind.Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; } function getEnclosingDeclarationFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? invocation.node : invocation.kind === 1 /* TypeArgs */ ? invocation.called : invocation.node; + return invocation.kind === 0 /* InvocationKind.Call */ ? invocation.node : invocation.kind === 1 /* InvocationKind.TypeArgs */ ? invocation.called : invocation.node; } - var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var signatureHelpNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; function createSignatureHelpItems(candidates, resolvedSignature, _a, sourceFile, typeChecker, useFullPrefix) { var _b; var isTypeParameterList = _a.isTypeParameterList, argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; var enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation); - var callTargetSymbol = invocation.kind === 2 /* Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); + var callTargetSymbol = invocation.kind === 2 /* InvocationKind.Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); var callTargetDisplayParts = callTargetSymbol ? ts.symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : ts.emptyArray; var items = ts.map(candidates, function (candidateSignature) { return getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile); }); if (argumentIndex !== 0) { @@ -145818,10 +146545,10 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(checker); - var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* LessThanToken */)], false); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], false); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile); return ts.map(infos, function (_a) { @@ -145854,9 +146581,9 @@ var ts; return checker.getExpandedParameters(candidateSignature).map(function (paramList) { var params = ts.factory.createNodeArray(__spreadArray(__spreadArray([], thisParameter, true), ts.map(paramList, function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }), true)); var parameterParts = ts.mapToDisplayParts(function (writer) { - printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* ListFormat.CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts, true) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], parameterParts, true) }; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { @@ -145864,33 +146591,33 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.factory.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration, signatureHelpNodeBuilderFlags); })); - printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* ListFormat.TypeParameters */, args, sourceFile, writer); } }); var lists = checker.getExpandedParameters(candidateSignature); var isVariadic = !checker.hasEffectiveRestParameter(candidateSignature) ? function (_) { return false; } : lists.length === 1 ? function (_) { return true; } - : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* RestParameter */); }; + : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* CheckFlags.RestParameter */); }; return lists.map(function (parameterList) { return ({ isVariadic: isVariadic(parameterList), parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* OpenParenToken */)], false), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)], false), + suffix: [ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - var isRest = !!(parameter.checkFlags & 32768 /* RestParameter */); + var isRest = !!(parameter.checkFlags & 32768 /* CheckFlags.RestParameter */); return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional, isRest: isRest }; } function createSignatureHelpParameterForTypeParameter(typeParameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } @@ -145903,7 +146630,7 @@ var ts; (function (InlayHints) { var maxHintsLength = 30; var leadingParameterNameCommentRegexFactory = function (name) { - return new RegExp("^\\s?/\\*\\*?\\s?" + name + "\\s?\\*\\/\\s?$"); + return new RegExp("^\\s?/\\*\\*?\\s?".concat(name, "\\s?\\*\\/\\s?$")); }; function shouldShowParameterNameHints(preferences) { return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all"; @@ -145924,14 +146651,14 @@ var ts; return; } switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) { @@ -145967,25 +146694,25 @@ var ts; } function addParameterHints(text, position, isFirstVariadicArgument) { result.push({ - text: "" + (isFirstVariadicArgument ? "..." : "") + truncation(text, maxHintsLength) + ":", + text: "".concat(isFirstVariadicArgument ? "..." : "").concat(truncation(text, maxHintsLength), ":"), position: position, - kind: "Parameter" /* Parameter */, + kind: "Parameter" /* InlayHintKind.Parameter */, whitespaceAfter: true, }); } function addTypeHints(text, position) { result.push({ - text: ": " + truncation(text, maxHintsLength), + text: ": ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Type" /* Type */, + kind: "Type" /* InlayHintKind.Type */, whitespaceBefore: true, }); } function addEnumMemberValueHints(text, position) { result.push({ - text: "= " + truncation(text, maxHintsLength), + text: "= ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Enum" /* Enum */, + kind: "Enum" /* InlayHintKind.Enum */, whitespaceBefore: true, }); } @@ -145999,7 +146726,7 @@ var ts; } } function isModuleReferenceType(type) { - return type.symbol && (type.symbol.flags & 1536 /* Module */); + return type.symbol && (type.symbol.flags & 1536 /* SymbolFlags.Module */); } function visitVariableLikeDeclaration(decl) { if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) { @@ -146075,17 +146802,17 @@ var ts; } function isHintableLiteral(node) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; return ts.isLiteralExpression(operand) || ts.isIdentifier(operand) && ts.isInfinityOrNaNString(operand.escapedText); } - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var name = node.escapedText; return isUndefined(name) || ts.isInfinityOrNaNString(name); } @@ -146094,7 +146821,7 @@ var ts; } function visitFunctionDeclarationLikeForReturnType(decl) { if (ts.isArrowFunction(decl)) { - if (!ts.findChildOfKind(decl, 20 /* OpenParenToken */, file)) { + if (!ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, file)) { return; } } @@ -146117,7 +146844,7 @@ var ts; addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl)); } function getTypeAnnotationPosition(decl) { - var closeParenToken = ts.findChildOfKind(decl, 21 /* CloseParenToken */, file); + var closeParenToken = ts.findChildOfKind(decl, 21 /* SyntaxKind.CloseParenToken */, file); if (closeParenToken) { return closeParenToken.end; } @@ -146162,13 +146889,13 @@ var ts; return text; } function printTypeInSingleLine(type) { - var flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var flags = 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; var options = { removeComments: true }; var printer = ts.createPrinter(options); return ts.usingSingleLineStringWriter(function (writer) { var typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer); ts.Debug.assertIsDefined(typeNode, "should always get typenode"); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ file, writer); }); } function isUndefined(name) { @@ -146237,7 +146964,7 @@ var ts; var options = program.getCompilerOptions(); var outPath = ts.outFile(options); var declarationPath = outPath ? - ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; @@ -146346,7 +147073,7 @@ var ts; program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; var checker = program.getTypeChecker(); - var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]); + var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]); if (!isCommonJSFile && sourceFile.commonJsModuleIndicator && (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) && @@ -146382,7 +147109,7 @@ var ts; else { if (ts.isVariableStatement(node) && node.parent === sourceFile && - node.declarationList.flags & 2 /* Const */ && + node.declarationList.flags & 2 /* NodeFlags.Const */ && node.declarationList.declarations.length === 1) { var init = node.declarationList.declarations[0].initializer; if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { @@ -146404,16 +147131,16 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); var kind = ts.getAssignmentDeclarationKind(expression); - return kind === 1 /* ExportsProperty */ || kind === 2 /* ModuleExports */; + return kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ || kind === 2 /* AssignmentDeclarationKind.ModuleExports */; } default: return false; @@ -146425,12 +147152,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -146500,26 +147227,26 @@ var ts; if (node.arguments.length < maxArguments) return true; return maxArguments === 1 || ts.some(node.arguments, function (arg) { - return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; + return arg.kind === 104 /* SyntaxKind.NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var functionFlags = ts.getFunctionFlags(arg); - if (functionFlags & 1 /* Generator */) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { return false; } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return true; - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: { + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: { var symbol = checker.getSymbolAtLocation(arg); if (!symbol) { return false; @@ -146532,28 +147259,28 @@ var ts; } } function getKeyFromNode(exp) { - return exp.pos.toString() + ":" + exp.end.toString(); + return "".concat(exp.pos.toString(), ":").concat(exp.end.toString()); } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 213 /* FunctionExpression */) { + if (node.kind === 213 /* SyntaxKind.FunctionExpression */) { if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) { return true; } var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false); return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size))); } - if (node.kind === 256 /* FunctionDeclaration */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } function canBeConvertedToAsync(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -146566,32 +147293,32 @@ var ts; (function (ts) { var SymbolDisplay; (function (SymbolDisplay) { - var symbolDisplayNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var symbolDisplayNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(typeChecker, symbol, location) { var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result !== "" /* unknown */) { + if (result !== "" /* ScriptElementKind.unknown */) { return result; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; - } - if (flags & 384 /* Enum */) - return "enum" /* enumElement */; - if (flags & 524288 /* TypeAlias */) - return "type" /* typeElement */; - if (flags & 64 /* Interface */) - return "interface" /* interfaceElement */; - if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; - if (flags & 8 /* EnumMember */) - return "enum member" /* enumMemberElement */; - if (flags & 2097152 /* Alias */) - return "alias" /* alias */; - if (flags & 1536 /* Module */) - return "module" /* moduleElement */; + if (flags & 32 /* SymbolFlags.Class */) { + return ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */) ? + "local class" /* ScriptElementKind.localClassElement */ : "class" /* ScriptElementKind.classElement */; + } + if (flags & 384 /* SymbolFlags.Enum */) + return "enum" /* ScriptElementKind.enumElement */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + return "type" /* ScriptElementKind.typeElement */; + if (flags & 64 /* SymbolFlags.Interface */) + return "interface" /* ScriptElementKind.interfaceElement */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + return "type parameter" /* ScriptElementKind.typeParameterElement */; + if (flags & 8 /* SymbolFlags.EnumMember */) + return "enum member" /* ScriptElementKind.enumMemberElement */; + if (flags & 2097152 /* SymbolFlags.Alias */) + return "alias" /* ScriptElementKind.alias */; + if (flags & 1536 /* SymbolFlags.Module */) + return "module" /* ScriptElementKind.moduleElement */; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; @@ -146599,52 +147326,52 @@ var ts; var roots = typeChecker.getRootSymbols(symbol); // If this is a method from a mapped type, leave as a method so long as it still has a call signature. if (roots.length === 1 - && ts.first(roots).flags & 8192 /* Method */ + && ts.first(roots).flags & 8192 /* SymbolFlags.Method */ // Ensure the mapped version is still a method, as opposed to `{ [K in keyof I]: number }`. && typeChecker.getTypeOfSymbolAtLocation(symbol, location).getNonNullableType().getCallSignatures().length !== 0) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } if (typeChecker.isUndefinedSymbol(symbol)) { - return "var" /* variableElement */; + return "var" /* ScriptElementKind.variableElement */; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var" /* localVariableElement */; + return "local var" /* ScriptElementKind.localVariableElement */; } - if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { - return "parameter" /* parameterElement */; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { + return "parameter" /* ScriptElementKind.parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter" /* parameterElement */; + return "parameter" /* ScriptElementKind.parameterElement */; } else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { - return "const" /* constElement */; + return "const" /* ScriptElementKind.constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let" /* letElement */; + return "let" /* ScriptElementKind.letElement */; } - return isLocalVariableOrFunction(symbol) ? "local var" /* localVariableElement */ : "var" /* variableElement */; + return isLocalVariableOrFunction(symbol) ? "local var" /* ScriptElementKind.localVariableElement */ : "var" /* ScriptElementKind.variableElement */; } - if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */; + if (flags & 16 /* SymbolFlags.Function */) + return isLocalVariableOrFunction(symbol) ? "local function" /* ScriptElementKind.localFunctionElement */ : "function" /* ScriptElementKind.functionElement */; // FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag. // So, even when the location is just on the declaration of setter, this function returns getter. - if (flags & 32768 /* GetAccessor */) - return "getter" /* memberGetAccessorElement */; - if (flags & 65536 /* SetAccessor */) - return "setter" /* memberSetAccessorElement */; - if (flags & 8192 /* Method */) - return "method" /* memberFunctionElement */; - if (flags & 16384 /* Constructor */) - return "constructor" /* constructorImplementationElement */; - if (flags & 4 /* Property */) { - if (flags & 33554432 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { + if (flags & 32768 /* SymbolFlags.GetAccessor */) + return "getter" /* ScriptElementKind.memberGetAccessorElement */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + return "setter" /* ScriptElementKind.memberSetAccessorElement */; + if (flags & 8192 /* SymbolFlags.Method */) + return "method" /* ScriptElementKind.memberFunctionElement */; + if (flags & 16384 /* SymbolFlags.Constructor */) + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + if (flags & 4 /* SymbolFlags.Property */) { + if (flags & 33554432 /* SymbolFlags.Transient */ && symbol.checkFlags & 6 /* CheckFlags.Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return "property" /* memberVariableElement */; + if (rootSymbolFlags & (98308 /* SymbolFlags.PropertyOrAccessor */ | 3 /* SymbolFlags.Variable */)) { + return "property" /* ScriptElementKind.memberVariableElement */; } }); if (!unionPropertyKind) { @@ -146652,23 +147379,23 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } return unionPropertyKind; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getNormalizedSymbolModifiers(symbol) { if (symbol.declarations && symbol.declarations.length) { var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* ModifierFlags.Deprecated */ + : 0 /* ModifierFlags.None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -146678,10 +147405,10 @@ var ts; } function getSymbolModifiers(typeChecker, symbol) { if (!symbol) { - return "" /* none */; + return "" /* ScriptElementKindModifier.none */; } var modifiers = new ts.Set(getNormalizedSymbolModifiers(symbol)); - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); if (resolvedSymbol !== symbol) { ts.forEach(getNormalizedSymbolModifiers(resolvedSymbol), function (modifier) { @@ -146689,10 +147416,10 @@ var ts; }); } } - if (symbol.flags & 16777216 /* Optional */) { - modifiers.add("optional" /* optionalModifier */); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + modifiers.add("optional" /* ScriptElementKindModifier.optionalModifier */); } - return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* none */; + return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* ScriptElementKindModifier.none */; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location @@ -146703,41 +147430,41 @@ var ts; var documentation = []; var tags = []; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; + var symbolKind = semanticMeaning & 1 /* SemanticMeaning.Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* ScriptElementKind.unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); + var isThisExpression = location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* ScriptElementKind.primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */ || symbolFlags & 32 /* SymbolFlags.Class */ || symbolFlags & 2097152 /* SymbolFlags.Alias */) { // If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor - if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) { + if (symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */) { var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; }); if (declaration) { switch (declaration.kind) { - case 172 /* GetAccessor */: - symbolKind = "getter" /* memberGetAccessorElement */; + case 172 /* SyntaxKind.GetAccessor */: + symbolKind = "getter" /* ScriptElementKind.memberGetAccessorElement */; break; - case 173 /* SetAccessor */: - symbolKind = "setter" /* memberSetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: + symbolKind = "setter" /* ScriptElementKind.memberSetAccessorElement */; break; default: ts.Debug.assertNever(declaration); } } else { - symbolKind = "property" /* memberVariableElement */; + symbolKind = "property" /* ScriptElementKind.memberVariableElement */; } } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (location.parent && location.parent.kind === 206 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -146757,7 +147484,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 209 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 209 /* SyntaxKind.NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SyntaxKind.SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -146765,21 +147492,21 @@ var ts; signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + if (useConstructSignatures && (symbolFlags & 32 /* SymbolFlags.Class */)) { // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - else if (symbolFlags & 2097152 /* Alias */) { - symbolKind = "alias" /* alias */; + else if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + symbolKind = "alias" /* ScriptElementKind.alias */; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -146788,29 +147515,29 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: + case "JSX attribute" /* ScriptElementKind.jsxAttribute */: + case "property" /* ScriptElementKind.memberVariableElement */: + case "var" /* ScriptElementKind.variableElement */: + case "const" /* ScriptElementKind.constElement */: + case "let" /* ScriptElementKind.letElement */: + case "parameter" /* ScriptElementKind.parameterElement */: + case "local var" /* ScriptElementKind.localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); - if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); + if (!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* SymbolFormatFlags.AllowAnyNodeKind */ | 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); + addSignatureDisplayParts(signature, allSignatures, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */); break; default: // Just signature @@ -146820,31 +147547,31 @@ var ts; hasMultipleSignatures = allSignatures.length > 1; } } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 134 /* ConstructorKeyword */ && location.parent.kind === 171 /* Constructor */)) { // At constructor keyword of constructor declaration + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* SymbolFlags.Accessor */)) || // name of function declaration + (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ && location.parent.kind === 171 /* SyntaxKind.Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 134 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 171 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 171 /* Constructor */) { + if (functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */) { // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* SyntaxKind.CallSignature */ && + !(type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ || type.symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */) ? type.symbol : symbol, symbolKind); } if (signature) { addSignatureDisplayParts(signature, allSignatures); @@ -146854,63 +147581,63 @@ var ts; } } } - if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { + if (symbolFlags & 32 /* SymbolFlags.Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushSymbolKind("local class" /* localClassElement */); + pushSymbolKind("local class" /* ScriptElementKind.localClassElement */); } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* SyntaxKind.ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 64 /* SymbolFlags.Interface */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* SyntaxKind.InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 524288 /* SymbolFlags.TypeAlias */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* TypeFormatFlags.InTypeAlias */)); } - if (symbolFlags & 384 /* Enum */) { + if (symbolFlags & 384 /* SymbolFlags.Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* SyntaxKind.ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* SyntaxKind.EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if (symbolFlags & 1536 /* Module */ && !isThisExpression) { + if (symbolFlags & 1536 /* SymbolFlags.Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 261 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 142 /* NamespaceKeyword */ : 141 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 261 /* SyntaxKind.ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* SyntaxKind.Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 142 /* SyntaxKind.NamespaceKeyword */ : 141 /* SyntaxKind.ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 262144 /* SymbolFlags.TypeParameter */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -146921,7 +147648,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 163 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -146929,21 +147656,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 175 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + if (declaration.kind === 175 /* SyntaxKind.ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 174 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 174 /* SyntaxKind.CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 259 /* TypeAliasDeclaration */) { + else if (declaration.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -146951,22 +147678,22 @@ var ts; } } } - if (symbolFlags & 8 /* EnumMember */) { - symbolKind = "enum member" /* enumMemberElement */; + if (symbolFlags & 8 /* SymbolFlags.EnumMember */) { + symbolKind = "enum member" /* ScriptElementKind.enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; - if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* EnumMember */) { + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* SyntaxKind.EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } } } // don't use symbolFlags since getAliasedSymbol requires the flag on the symbol itself - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { prefixNextMeaning(); if (!hasAddedSymbolInfo) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); @@ -146975,7 +147702,7 @@ var ts; var declarationName = ts.getNameOfDeclaration(resolvedNode); if (declarationName) { var isExternalModuleDeclaration = ts.isModuleWithStringLiteralName(resolvedNode) && - ts.hasSyntacticModifier(resolvedNode, 2 /* Ambient */); + ts.hasSyntacticModifier(resolvedNode, 2 /* ModifierFlags.Ambient */); var shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration; var resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, resolvedSymbol, ts.getSourceFileOfNode(resolvedNode), resolvedNode, declarationName, semanticMeaning, shouldUseAliasName ? symbol : resolvedSymbol); displayParts.push.apply(displayParts, resolvedInfo.displayParts); @@ -146991,42 +147718,42 @@ var ts; } if (symbol.declarations) { switch (symbol.declarations[0].kind) { - case 264 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(142 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(142 /* SyntaxKind.NamespaceKeyword */)); break; - case 271 /* ExportAssignment */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 271 /* SyntaxKind.ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* SyntaxKind.EqualsToken */ : 88 /* SyntaxKind.DefaultKeyword */)); break; - case 275 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 275 /* SyntaxKind.ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(100 /* SyntaxKind.ImportKeyword */)); } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(146 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(146 /* SyntaxKind.RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -147036,30 +147763,30 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "" /* unknown */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */) { if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === "property" /* memberVariableElement */ || - symbolKind === "getter" /* memberGetAccessorElement */ || - symbolKind === "setter" /* memberSetAccessorElement */ || - symbolKind === "JSX attribute" /* jsxAttribute */ || - symbolFlags & 3 /* Variable */ || - symbolKind === "local var" /* localVariableElement */ || + if (symbolKind === "property" /* ScriptElementKind.memberVariableElement */ || + symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || + symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */ || + symbolKind === "JSX attribute" /* ScriptElementKind.jsxAttribute */ || + symbolFlags & 3 /* SymbolFlags.Variable */ || + symbolKind === "local var" /* ScriptElementKind.localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially - if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + if (type.symbol && type.symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeNode(4 /* EmitHint.Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -147070,17 +147797,17 @@ var ts; var labelDecl = symbol.target.tupleLabelDeclaration; ts.Debug.assertNode(labelDecl.name, ts.isIdentifier); displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart(ts.idText(labelDecl.name))); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } } - else if (symbolFlags & 16 /* Function */ || - symbolFlags & 8192 /* Method */ || - symbolFlags & 16384 /* Constructor */ || - symbolFlags & 131072 /* Signature */ || - symbolFlags & 98304 /* Accessor */ || - symbolKind === "method" /* memberFunctionElement */) { + else if (symbolFlags & 16 /* SymbolFlags.Function */ || + symbolFlags & 8192 /* SymbolFlags.Method */ || + symbolFlags & 16384 /* SymbolFlags.Constructor */ || + symbolFlags & 131072 /* SymbolFlags.Signature */ || + symbolFlags & 98304 /* SymbolFlags.Accessor */ || + symbolKind === "method" /* ScriptElementKind.memberFunctionElement */) { var allSignatures = type.getNonNullableType().getCallSignatures(); if (allSignatures.length) { addSignatureDisplayParts(allSignatures[0], allSignatures); @@ -147096,14 +147823,14 @@ var ts; if (documentation.length === 0 && !hasMultipleSignatures) { documentation = symbol.getContextualDocumentationComment(enclosingDeclaration, typeChecker); } - if (documentation.length === 0 && symbolFlags & 4 /* Property */) { + if (documentation.length === 0 && symbolFlags & 4 /* SymbolFlags.Property */) { // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SourceFile */; })) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SyntaxKind.SourceFile */; })) { for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (!declaration.parent || declaration.parent.kind !== 221 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -147154,23 +147881,23 @@ var ts; } function addAliasPrefixIfNecessary() { if (alias) { - pushSymbolKind("alias" /* alias */); + pushSymbolKind("alias" /* ScriptElementKind.alias */); displayParts.push(ts.spacePart()); } } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(101 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* SyntaxKind.InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { if (alias && symbolToDisplay === symbol) { symbolToDisplay = alias; } - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */ | 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); - if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + displayParts.push(ts.punctuationPart(57 /* SyntaxKind.QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -147185,31 +147912,31 @@ var ts; } function pushSymbolKind(symbolKind) { switch (symbolKind) { - case "var" /* variableElement */: - case "function" /* functionElement */: - case "let" /* letElement */: - case "const" /* constElement */: - case "constructor" /* constructorImplementationElement */: + case "var" /* ScriptElementKind.variableElement */: + case "function" /* ScriptElementKind.functionElement */: + case "let" /* ScriptElementKind.letElement */: + case "const" /* ScriptElementKind.constElement */: + case "constructor" /* ScriptElementKind.constructorImplementationElement */: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); return; } } function addSignatureDisplayParts(signature, allSignatures, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(39 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); + displayParts.push(ts.operatorPart(39 /* SyntaxKind.PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } documentation = signature.getDocumentationComment(typeChecker); tags = signature.getJsDocTags(); @@ -147221,7 +147948,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* ListFormat.TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -147233,16 +147960,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 213 /* FunctionExpression */) { + if (declaration.kind === 213 /* SyntaxKind.FunctionExpression */) { return true; } - if (declaration.kind !== 254 /* VariableDeclaration */ && declaration.kind !== 256 /* FunctionDeclaration */) { + if (declaration.kind !== 254 /* SyntaxKind.VariableDeclaration */ && declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 305 /* SourceFile */ || parent.kind === 262 /* ModuleBlock */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ || parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return false; } } @@ -147351,7 +148078,7 @@ var ts; commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_9 = function (opt) { + var _loop_8 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -147370,7 +148097,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_9(opt); + _loop_8(opt); } return options; } @@ -147447,8 +148174,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* SyntaxKind.OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* SyntaxKind.CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -147466,8 +148193,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); + var jsxScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 1 /* LanguageVariant.JSX */); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -147479,7 +148206,7 @@ var ts; ScanAction[ScanAction["RescanJsxAttributeValue"] = 6] = "RescanJsxAttributeValue"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { - var scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + var scanner = languageVariant === 1 /* LanguageVariant.JSX */ ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -147507,7 +148234,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* SyntaxKind.NewLineTrivia */; } else { scanner.scan(); @@ -147535,11 +148262,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 33 /* GreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return true; } return false; @@ -147547,12 +148274,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 285 /* JsxAttribute */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 285 /* SyntaxKind.JsxAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* SyntaxKind.Identifier */; } } return false; @@ -147561,29 +148288,29 @@ var ts; return ts.isJsxText(node); } function shouldRescanSlashToken(container) { - return container.kind === 13 /* RegularExpressionLiteral */; + return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 16 /* TemplateMiddle */ || - container.kind === 17 /* TemplateTail */; + return container.kind === 16 /* SyntaxKind.TemplateMiddle */ || + container.kind === 17 /* SyntaxKind.TemplateTail */; } function shouldRescanJsxAttributeValue(node) { return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; + return t === 43 /* SyntaxKind.SlashToken */ || t === 68 /* SyntaxKind.SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : - shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : - shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : - shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : - shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* ScanAction.RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* ScanAction.RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* ScanAction.RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* ScanAction.RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* ScanAction.RescanJsxText */ : + shouldRescanJsxAttributeValue(n) ? 6 /* ScanAction.RescanJsxAttributeValue */ : + 0 /* ScanAction.Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -147615,7 +148342,7 @@ var ts; trailingTrivia = []; } trailingTrivia.push(trivia); - if (currentToken === 4 /* NewLineTrivia */) { + if (currentToken === 4 /* SyntaxKind.NewLineTrivia */) { // move past new line scanner.scan(); break; @@ -147626,40 +148353,40 @@ var ts; } function getNextToken(n, expectedScanAction) { var token = scanner.getToken(); - lastScanAction = 0 /* Scan */; + lastScanAction = 0 /* ScanAction.Scan */; switch (expectedScanAction) { - case 1 /* RescanGreaterThanToken */: - if (token === 31 /* GreaterThanToken */) { - lastScanAction = 1 /* RescanGreaterThanToken */; + case 1 /* ScanAction.RescanGreaterThanToken */: + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + lastScanAction = 1 /* ScanAction.RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 2 /* RescanSlashToken */: + case 2 /* ScanAction.RescanSlashToken */: if (startsWithSlashToken(token)) { - lastScanAction = 2 /* RescanSlashToken */; + lastScanAction = 2 /* ScanAction.RescanSlashToken */; var newToken = scanner.reScanSlashToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 3 /* RescanTemplateToken */: - if (token === 19 /* CloseBraceToken */) { - lastScanAction = 3 /* RescanTemplateToken */; + case 3 /* ScanAction.RescanTemplateToken */: + if (token === 19 /* SyntaxKind.CloseBraceToken */) { + lastScanAction = 3 /* ScanAction.RescanTemplateToken */; return scanner.reScanTemplateToken(/* isTaggedTemplate */ false); } break; - case 4 /* RescanJsxIdentifier */: - lastScanAction = 4 /* RescanJsxIdentifier */; + case 4 /* ScanAction.RescanJsxIdentifier */: + lastScanAction = 4 /* ScanAction.RescanJsxIdentifier */; return scanner.scanJsxIdentifier(); - case 5 /* RescanJsxText */: - lastScanAction = 5 /* RescanJsxText */; + case 5 /* ScanAction.RescanJsxText */: + lastScanAction = 5 /* ScanAction.RescanJsxText */; return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); - case 6 /* RescanJsxAttributeValue */: - lastScanAction = 6 /* RescanJsxAttributeValue */; + case 6 /* ScanAction.RescanJsxAttributeValue */: + lastScanAction = 6 /* ScanAction.RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); - case 0 /* Scan */: + case 0 /* ScanAction.Scan */: break; default: ts.Debug.assertNever(expectedScanAction); @@ -147668,15 +148395,15 @@ var ts; } function readEOFTokenRange() { ts.Debug.assert(isOnEOF()); - return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* SyntaxKind.EndOfFileToken */); } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); + return current !== 1 /* SyntaxKind.EndOfFileToken */ && !ts.isTrivia(current); } function isOnEOF() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current === 1 /* EndOfFileToken */; + return current === 1 /* SyntaxKind.EndOfFileToken */; } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, @@ -147743,8 +148470,8 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 160 /* LastToken */; token++) { - if (token !== 1 /* EndOfFileToken */) { + for (var token = 0 /* SyntaxKind.FirstToken */; token <= 160 /* SyntaxKind.LastToken */; token++) { + if (token !== 1 /* SyntaxKind.EndOfFileToken */) { allTokens.push(token); } } @@ -147756,263 +148483,263 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* MultiLineCommentTrivia */], false)); - var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* EndOfFileToken */], false)); - var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 160 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); - var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 160 /* OfKeyword */, 127 /* AsKeyword */, 139 /* IsKeyword */]; - var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* SyntaxKind.MultiLineCommentTrivia */], false)); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* SyntaxKind.EndOfFileToken */], false)); + var keywords = tokenRangeFromRange(81 /* SyntaxKind.FirstKeyword */, 160 /* SyntaxKind.LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* SyntaxKind.FirstBinaryOperator */, 78 /* SyntaxKind.LastBinaryOperator */); + var binaryKeywordOperators = [101 /* SyntaxKind.InKeyword */, 102 /* SyntaxKind.InstanceOfKeyword */, 160 /* SyntaxKind.OfKeyword */, 127 /* SyntaxKind.AsKeyword */, 139 /* SyntaxKind.IsKeyword */]; + var unaryPrefixOperators = [45 /* SyntaxKind.PlusPlusToken */, 46 /* SyntaxKind.MinusMinusToken */, 54 /* SyntaxKind.TildeToken */, 53 /* SyntaxKind.ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ + 8 /* SyntaxKind.NumericLiteral */, 9 /* SyntaxKind.BigIntLiteral */, 79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, + 22 /* SyntaxKind.OpenBracketToken */, 18 /* SyntaxKind.OpenBraceToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */ ]; - var unaryPreincrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostincrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var unaryPredecrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostdecrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords, true); + var unaryPreincrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostincrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPredecrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostdecrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var comments = [2 /* SyntaxKind.SingleLineCommentTrivia */, 3 /* SyntaxKind.MultiLineCommentTrivia */]; + var typeNames = __spreadArray([79 /* SyntaxKind.Identifier */], ts.typeKeywords, true); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* SyntaxKind.Identifier */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 84 /* SyntaxKind.ClassKeyword */, 93 /* SyntaxKind.ExportKeyword */, 100 /* SyntaxKind.ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* SyntaxKind.CloseParenToken */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 90 /* SyntaxKind.DoKeyword */, 111 /* SyntaxKind.TryKeyword */, 96 /* SyntaxKind.FinallyKeyword */, 91 /* SyntaxKind.ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), - rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SyntaxKind.SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* SyntaxKind.ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterColon", 58 /* SyntaxKind.ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* SyntaxKind.QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* RuleAction.InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterQuestionMark", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* SyntaxKind.ImportKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* RuleAction.DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* SyntaxKind.PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* SyntaxKind.MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* SyntaxKind.PlusPlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* SyntaxKind.PlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* SyntaxKind.PlusToken */, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* SyntaxKind.MinusMinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* SyntaxKind.MinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* SyntaxKind.MinusToken */, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, [27 /* SyntaxKind.CommaToken */, 26 /* SyntaxKind.SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* SyntaxKind.CloseBraceToken */, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), + rule("SpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, anyTokenExcept(21 /* SyntaxKind.CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* RuleAction.InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 91 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 115 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* SyntaxKind.CloseBraceToken */, 91 /* SyntaxKind.ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* SyntaxKind.CloseBraceToken */, 115 /* SyntaxKind.WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 79 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 98 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterConditionalClosingParen", 21 /* SyntaxKind.CloseParenToken */, 22 /* SyntaxKind.OpenBracketToken */, [isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* SyntaxKind.AsteriskToken */, 79 /* SyntaxKind.Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 98 /* SyntaxKind.FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [136 /* GetKeyword */, 149 /* SetKeyword */], 79 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 105 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [113 /* VarKeyword */, 109 /* ThrowKeyword */, 103 /* NewKeyword */, 89 /* DeleteKeyword */, 105 /* ReturnKeyword */, 112 /* TypeOfKeyword */, 132 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [119 /* LetKeyword */, 85 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), + rule("SpaceAfterGetSetInMember", [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */], 79 /* SyntaxKind.Identifier */, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 105 /* SyntaxKind.ReturnKeyword */, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterCertainKeywords", [113 /* SyntaxKind.VarKeyword */, 109 /* SyntaxKind.ThrowKeyword */, 103 /* SyntaxKind.NewKeyword */, 89 /* SyntaxKind.DeleteKeyword */, 105 /* SyntaxKind.ReturnKeyword */, 112 /* SyntaxKind.TypeOfKeyword */, 132 /* SyntaxKind.AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [119 /* SyntaxKind.LetKeyword */, 85 /* SyntaxKind.ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* RuleAction.DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* SyntaxKind.VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* RuleAction.InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 131 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 131 /* SyntaxKind.AsyncKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* SyntaxKind.AsyncKeyword */, [98 /* SyntaxKind.FunctionKeyword */, 79 /* SyntaxKind.Identifier */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */], [14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, 15 /* SyntaxKind.TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 79 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeJsxAttribute", anyToken, 79 /* SyntaxKind.Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SyntaxKind.SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SyntaxKind.SlashToken */, 31 /* SyntaxKind.GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* SyntaxKind.EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* SyntaxKind.EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [141 /* ModuleKeyword */, 146 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [141 /* SyntaxKind.ModuleKeyword */, 146 /* SyntaxKind.RequireKeyword */], 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 126 /* AbstractKeyword */, - 84 /* ClassKeyword */, - 135 /* DeclareKeyword */, - 88 /* DefaultKeyword */, - 92 /* EnumKeyword */, - 93 /* ExportKeyword */, - 94 /* ExtendsKeyword */, - 136 /* GetKeyword */, - 117 /* ImplementsKeyword */, - 100 /* ImportKeyword */, - 118 /* InterfaceKeyword */, - 141 /* ModuleKeyword */, - 142 /* NamespaceKeyword */, - 121 /* PrivateKeyword */, - 123 /* PublicKeyword */, - 122 /* ProtectedKeyword */, - 145 /* ReadonlyKeyword */, - 149 /* SetKeyword */, - 124 /* StaticKeyword */, - 152 /* TypeKeyword */, - 156 /* FromKeyword */, - 140 /* KeyOfKeyword */, - 137 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 156 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 135 /* SyntaxKind.DeclareKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 92 /* SyntaxKind.EnumKeyword */, + 93 /* SyntaxKind.ExportKeyword */, + 94 /* SyntaxKind.ExtendsKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 117 /* SyntaxKind.ImplementsKeyword */, + 100 /* SyntaxKind.ImportKeyword */, + 118 /* SyntaxKind.InterfaceKeyword */, + 141 /* SyntaxKind.ModuleKeyword */, + 142 /* SyntaxKind.NamespaceKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 152 /* SyntaxKind.TypeKeyword */, + 156 /* SyntaxKind.FromKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 137 /* SyntaxKind.InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* SyntaxKind.ExtendsKeyword */, 117 /* SyntaxKind.ImplementsKeyword */, 156 /* SyntaxKind.FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterModuleName", 10 /* SyntaxKind.StringLiteral */, 18 /* SyntaxKind.OpenBraceToken */, [isModuleDeclContext], 4 /* RuleAction.InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeArrow", anyToken, 38 /* SyntaxKind.EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterArrow", 38 /* SyntaxKind.EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* SyntaxKind.DotDotDotToken */, 79 /* SyntaxKind.Identifier */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* SyntaxKind.QuestionToken */, [21 /* SyntaxKind.CloseParenToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* RuleAction.DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* SyntaxKind.CloseParenToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* SyntaxKind.LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* SyntaxKind.GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* SyntaxKind.GreaterThanToken */, [20 /* SyntaxKind.OpenParenToken */, 22 /* SyntaxKind.OpenBracketToken */, 31 /* SyntaxKind.GreaterThanToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* RuleAction.DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeAt", [21 /* SyntaxKind.CloseParenToken */, 79 /* SyntaxKind.Identifier */], 59 /* SyntaxKind.AtToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAt", 59 /* SyntaxKind.AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 126 /* AbstractKeyword */, - 79 /* Identifier */, - 93 /* ExportKeyword */, - 88 /* DefaultKeyword */, - 84 /* ClassKeyword */, - 124 /* StaticKeyword */, - 123 /* PublicKeyword */, - 121 /* PrivateKeyword */, - 122 /* ProtectedKeyword */, - 136 /* GetKeyword */, - 149 /* SetKeyword */, - 22 /* OpenBracketToken */, - 41 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 79 /* SyntaxKind.Identifier */, + 93 /* SyntaxKind.ExportKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 22 /* SyntaxKind.OpenBracketToken */, + 41 /* SyntaxKind.AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* SyntaxKind.ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* SyntaxKind.NewKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* SyntaxKind.LessThanToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* RuleAction.DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* SyntaxKind.OpenParenToken */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after opening and before closing empty brace brackets - rule("SpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* DeleteSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* RuleAction.DeleteSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* RuleAction.DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), - rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), - rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), - rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* RuleAction.DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* RuleAction.InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* SyntaxKind.CommaToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* AsyncKeyword */, 82 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* SyntaxKind.AsyncKeyword */, 82 /* SyntaxKind.CaseKeyword */), 22 /* SyntaxKind.OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* SyntaxKind.CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 132 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* SyntaxKind.ForKeyword */, 132 /* SyntaxKind.AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* SyntaxKind.CloseParenToken */, 90 /* SyntaxKind.DoKeyword */, 91 /* SyntaxKind.ElseKeyword */, 82 /* SyntaxKind.CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* RuleAction.InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* SyntaxKind.TryKeyword */, 83 /* SyntaxKind.CatchKeyword */, 96 /* SyntaxKind.FinallyKeyword */], 18 /* SyntaxKind.OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules, true), userConfigurableRules, true), lowPriorityCommonRules, true); } @@ -148030,7 +148757,7 @@ var ts; * @param flags whether the rule deletes a line or not, defaults to no-op */ function rule(debugName, left, right, context, action, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* RuleFlags.None */; } return { leftTokenRange: toTokenRange(left), rightTokenRange: toTokenRange(right), rule: { debugName: debugName, context: context, action: action, flags: flags } }; } function tokenRangeFrom(tokens) { @@ -148071,54 +148798,54 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 242 /* ForStatement */; + return context.contextNode.kind === 242 /* SyntaxKind.ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 221 /* BinaryExpression */: - return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 222 /* ConditionalExpression */: - case 189 /* ConditionalType */: - case 229 /* AsExpression */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 177 /* TypePredicate */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 221 /* SyntaxKind.BinaryExpression */: + return context.contextNode.operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; + case 222 /* SyntaxKind.ConditionalExpression */: + case 189 /* SyntaxKind.ConditionalType */: + case 229 /* SyntaxKind.AsExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 177 /* SyntaxKind.TypePredicate */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // equals in type X = ... // falls through - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // equal in export = 1 // falls through - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // equal in let a = 0 // falls through - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // equal in p = 0 // falls through - case 164 /* Parameter */: - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 164 /* SyntaxKind.Parameter */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // "in" keyword in for (let x in []) { } - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 163 /* TypeParameter */: - return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 163 /* SyntaxKind.TypeParameter */: + return context.currentTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.nextTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 244 /* ForOfStatement */: - return context.currentTokenSpan.kind === 160 /* OfKeyword */ || context.nextTokenSpan.kind === 160 /* OfKeyword */; + case 244 /* SyntaxKind.ForOfStatement */: + return context.currentTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */ || context.nextTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */; } return false; } @@ -148130,22 +148857,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 167 /* PropertyDeclaration */ || - contextKind === 166 /* PropertySignature */ || - contextKind === 164 /* Parameter */ || - contextKind === 254 /* VariableDeclaration */ || + return contextKind === 167 /* SyntaxKind.PropertyDeclaration */ || + contextKind === 166 /* SyntaxKind.PropertySignature */ || + contextKind === 164 /* SyntaxKind.Parameter */ || + contextKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 222 /* ConditionalExpression */ || - context.contextNode.kind === 189 /* ConditionalType */; + return context.contextNode.kind === 222 /* SyntaxKind.ConditionalExpression */ || + context.contextNode.kind === 189 /* SyntaxKind.ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 201 /* ObjectBindingPattern */ || - context.contextNode.kind === 195 /* MappedType */ || + return context.contextNode.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || + context.contextNode.kind === 195 /* SyntaxKind.MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -148171,34 +148898,34 @@ var ts; return true; } switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 205 /* ObjectLiteralExpression */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 262 /* SyntaxKind.ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 174 /* CallSignature */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 258 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 258 /* SyntaxKind.InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -148207,40 +148934,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 256 /* FunctionDeclaration */ || context.contextNode.kind === 213 /* FunctionExpression */; + return context.contextNode.kind === 256 /* SyntaxKind.FunctionDeclaration */ || context.contextNode.kind === 213 /* SyntaxKind.FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 182 /* TypeLiteral */: - case 261 /* ModuleDeclaration */: - case 272 /* ExportDeclaration */: - case 273 /* NamedExports */: - case 266 /* ImportDeclaration */: - case 269 /* NamedImports */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 273 /* SyntaxKind.NamedExports */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 269 /* SyntaxKind.NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 292 /* CatchClause */: - case 262 /* ModuleBlock */: - case 249 /* SwitchStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 292 /* SyntaxKind.CatchClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 249 /* SyntaxKind.SwitchStatement */: return true; - case 235 /* Block */: { + case 235 /* SyntaxKind.Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 214 /* ArrowFunction */ && blockParent.kind !== 213 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 214 /* SyntaxKind.ArrowFunction */ && blockParent.kind !== 213 /* SyntaxKind.FunctionExpression */) { return true; } } @@ -148249,71 +148976,71 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 248 /* WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 248 /* SyntaxKind.WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 205 /* ObjectLiteralExpression */; + return context.contextNode.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 208 /* CallExpression */; + return context.contextNode.kind === 208 /* SyntaxKind.CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 209 /* NewExpression */; + return context.contextNode.kind === 209 /* SyntaxKind.NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 27 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* SyntaxKind.CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* SyntaxKind.CloseBracketToken */; } function isNextTokenNotCloseParen(context) { - return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; + return context.nextTokenSpan.kind !== 21 /* SyntaxKind.CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 214 /* ArrowFunction */; + return context.contextNode.kind === 214 /* SyntaxKind.ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 200 /* ImportType */; + return context.contextNode.kind === 200 /* SyntaxKind.ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxTextContext(context) { - return context.contextNode.kind !== 11 /* JsxText */; + return context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 278 /* JsxElement */ && context.contextNode.kind !== 282 /* JsxFragment */; + return context.contextNode.kind !== 278 /* SyntaxKind.JsxElement */ && context.contextNode.kind !== 282 /* SyntaxKind.JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 288 /* JsxExpression */ || context.contextNode.kind === 287 /* JsxSpreadAttribute */; + return context.contextNode.kind === 288 /* SyntaxKind.JsxExpression */ || context.contextNode.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 285 /* JsxAttribute */; + return context.nextTokenParent.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 285 /* JsxAttribute */; + return context.contextNode.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 279 /* JsxSelfClosingElement */; + return context.contextNode.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -148328,45 +149055,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 255 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { - return context.formattingRequestKind !== 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormattingRequestKind.FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 261 /* ModuleDeclaration */; + return context.contextNode.kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 182 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 182 /* SyntaxKind.TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 175 /* ConstructSignature */; + return context.contextNode.kind === 175 /* SyntaxKind.ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { + if (token.kind !== 29 /* SyntaxKind.LessThanToken */ && token.kind !== 31 /* SyntaxKind.GreaterThanToken */) { return false; } switch (parent.kind) { - case 178 /* TypeReference */: - case 211 /* TypeAssertionExpression */: - case 259 /* TypeAliasDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return true; default: return false; @@ -148377,28 +149104,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 211 /* TypeAssertionExpression */; + return context.contextNode.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 217 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* SyntaxKind.VoidKeyword */ && context.currentTokenParent.kind === 217 /* SyntaxKind.VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 224 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 224 /* SyntaxKind.YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 230 /* NonNullExpression */; + return context.contextNode.kind === 230 /* SyntaxKind.NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; default: return false; @@ -148420,15 +149147,15 @@ var ts; var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; if (startLine === endLine) { - return nextTokenKind === 19 /* CloseBraceToken */ - || nextTokenKind === 1 /* EndOfFileToken */; + return nextTokenKind === 19 /* SyntaxKind.CloseBraceToken */ + || nextTokenKind === 1 /* SyntaxKind.EndOfFileToken */; } - if (nextTokenKind === 234 /* SemicolonClassElement */ || - nextTokenKind === 26 /* SemicolonToken */) { + if (nextTokenKind === 234 /* SyntaxKind.SemicolonClassElement */ || + nextTokenKind === 26 /* SyntaxKind.SemicolonToken */) { return false; } - if (context.contextNode.kind === 258 /* InterfaceDeclaration */ || - context.contextNode.kind === 259 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + context.contextNode.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -148437,25 +149164,25 @@ var ts; // } return !ts.isPropertySignature(context.currentTokenParent) || !!context.currentTokenParent.type - || nextTokenKind !== 20 /* OpenParenToken */; + || nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */; } if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 242 /* ForStatement */ - && context.currentTokenParent.kind !== 236 /* EmptyStatement */ - && context.currentTokenParent.kind !== 234 /* SemicolonClassElement */ - && nextTokenKind !== 22 /* OpenBracketToken */ - && nextTokenKind !== 20 /* OpenParenToken */ - && nextTokenKind !== 39 /* PlusToken */ - && nextTokenKind !== 40 /* MinusToken */ - && nextTokenKind !== 43 /* SlashToken */ - && nextTokenKind !== 13 /* RegularExpressionLiteral */ - && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 223 /* TemplateExpression */ - && nextTokenKind !== 15 /* TemplateHead */ - && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ - && nextTokenKind !== 24 /* DotToken */; + return context.currentTokenParent.kind !== 242 /* SyntaxKind.ForStatement */ + && context.currentTokenParent.kind !== 236 /* SyntaxKind.EmptyStatement */ + && context.currentTokenParent.kind !== 234 /* SyntaxKind.SemicolonClassElement */ + && nextTokenKind !== 22 /* SyntaxKind.OpenBracketToken */ + && nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */ + && nextTokenKind !== 39 /* SyntaxKind.PlusToken */ + && nextTokenKind !== 40 /* SyntaxKind.MinusToken */ + && nextTokenKind !== 43 /* SyntaxKind.SlashToken */ + && nextTokenKind !== 13 /* SyntaxKind.RegularExpressionLiteral */ + && nextTokenKind !== 27 /* SyntaxKind.CommaToken */ + && nextTokenKind !== 223 /* SyntaxKind.TemplateExpression */ + && nextTokenKind !== 15 /* SyntaxKind.TemplateHead */ + && nextTokenKind !== 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* SyntaxKind.DotToken */; } function isSemicolonInsertionContext(context) { return ts.positionIsASICandidate(context.currentTokenSpan.end, context.currentTokenParent, context.sourceFile); @@ -148484,17 +149211,17 @@ var ts; */ function getRuleActionExclusion(ruleAction) { var mask = 0; - if (ruleAction & 1 /* StopProcessingSpaceActions */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 1 /* RuleAction.StopProcessingSpaceActions */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 2 /* StopProcessingTokenActions */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 2 /* RuleAction.StopProcessingTokenActions */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } - if (ruleAction & 28 /* ModifySpaceAction */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 28 /* RuleAction.ModifySpaceAction */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 96 /* ModifyTokenAction */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 96 /* RuleAction.ModifyTokenAction */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } return mask; } @@ -148543,12 +149270,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 160 /* LastKeyword */ && column <= 160 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 160 /* SyntaxKind.LastKeyword */ && column <= 160 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 160 /* LastToken */ + 1; + var mapRowLength = 160 /* SyntaxKind.LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -148574,7 +149301,7 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action & 3 /* StopAction */ ? + var position = rule.action & 3 /* RuleAction.StopAction */ ? specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : rule.context !== formatting.anyContext ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : @@ -148643,16 +149370,16 @@ var ts; // end value is exclusive so add 1 to the result end: endOfFormatSpan + 1 }; - return formatSpan(span, sourceFile, formatContext, 2 /* FormatOnEnter */); + return formatSpan(span, sourceFile, formatContext, 2 /* FormattingRequestKind.FormatOnEnter */); } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormattingRequestKind.FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -148674,12 +149401,12 @@ var ts; pos: ts.getLineStartPositionForPosition(outermostNode.getStart(sourceFile), sourceFile), end: position }; - return formatSpan(textRange, sourceFile, formatContext, 4 /* FormatOnOpeningCurlyBrace */); + return formatSpan(textRange, sourceFile, formatContext, 4 /* FormattingRequestKind.FormatOnOpeningCurlyBrace */); } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormattingRequestKind.FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, formatContext) { @@ -148687,7 +149414,7 @@ var ts; pos: 0, end: sourceFile.text.length }; - return formatSpan(span, sourceFile, formatContext, 0 /* FormatDocument */); + return formatSpan(span, sourceFile, formatContext, 0 /* FormattingRequestKind.FormatDocument */); } formatting.formatDocument = formatDocument; function formatSelection(start, end, sourceFile, formatContext) { @@ -148696,7 +149423,7 @@ var ts; pos: ts.getLineStartPositionForPosition(start, sourceFile), end: end, }; - return formatSpan(span, sourceFile, formatContext, 1 /* FormatSelection */); + return formatSpan(span, sourceFile, formatContext, 1 /* FormattingRequestKind.FormatSelection */); } formatting.formatSelection = formatSelection; /** @@ -148736,17 +149463,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 262 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 305 /* SourceFile */: - case 235 /* Block */: - case 262 /* ModuleBlock */: + return !!body && body.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -148843,11 +149570,11 @@ var ts; * to the initial indentation. */ function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1 /* Unknown */; + var previousLine = -1 /* Constants.Unknown */; var child; while (n) { var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + if (previousLine !== -1 /* Constants.Unknown */ && line !== previousLine) { break; } if (formatting.SmartIndenter.shouldIndentChildNode(options, n, child, sourceFile)) { @@ -148861,7 +149588,7 @@ var ts; } function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: node.pos, end: node.end }; - return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormattingRequestKind.FormatSelection */, function (_) { return false; }, // assume that node does not have any errors sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; @@ -148885,11 +149612,12 @@ var ts; var options = _a.options, getRules = _a.getRules, host = _a.host; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); + var previousRangeTriviaEnd; var previousRange; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine = -1 /* Unknown */; + var indentationOnLastIndentedLine = -1 /* Constants.Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -148913,10 +149641,30 @@ var ts; } } if (previousRange && formattingScanner.getStartPos() >= originalRange.end) { + // Formatting edits happen by looking at pairs of contiguous tokens (see `processPair`), + // typically inserting or deleting whitespace between them. The recursive `processNode` + // logic above bails out as soon as it encounters a token that is beyond the end of the + // range we're supposed to format (or if we reach the end of the file). But this potentially + // leaves out an edit that would occur *inside* the requested range but cannot be discovered + // without looking at one token *beyond* the end of the range: consider the line `x = { }` + // with a selection from the beginning of the line to the space inside the curly braces, + // inclusive. We would expect a format-selection would delete the space (if rules apply), + // but in order to do that, we need to process the pair ["{", "}"], but we stopped processing + // just before getting there. This block handles this trailing edit. var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() : formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token : undefined; - if (tokenInfo) { + if (tokenInfo && tokenInfo.pos === previousRangeTriviaEnd) { + // We need to check that tokenInfo and previousRange are contiguous: the `originalRange` + // may have ended in the middle of a token, which means we will have stopped formatting + // on that token, leaving `previousRange` pointing to the token before it, but already + // having moved the formatting scanner (where we just got `tokenInfo`) to the next token. + // If this happens, our supposed pair [previousRange, tokenInfo] actually straddles the + // token that intersects the end of the range we're supposed to format, so the pair will + // produce bogus edits if we try to `processPair`. Recall that the point of this logic is + // to perform a trailing edit at the end of the selection range: but there can be no valid + // edit in the middle of a token where the range ended, so if we have a non-contiguous + // pair here, we're already done and we can ignore it. var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent; processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent, /*dynamicIndentation*/ undefined); @@ -148934,7 +149682,7 @@ var ts; function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) { - if (inheritedIndentation !== -1 /* Unknown */) { + if (inheritedIndentation !== -1 /* Constants.Unknown */) { return inheritedIndentation; } } @@ -148949,7 +149697,7 @@ var ts; return baseIndentSize > column ? baseIndentSize : column; } } - return -1 /* Unknown */; + return -1 /* Constants.Unknown */; } function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { var delta = formatting.SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize : 0; @@ -148962,8 +149710,8 @@ var ts; delta: Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta) }; } - else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 20 /* OpenParenToken */ && startLine === lastIndentedLine) { + else if (inheritedIndentation === -1 /* Constants.Unknown */) { + if (node.kind === 20 /* SyntaxKind.OpenParenToken */ && startLine === lastIndentedLine) { // the is used for chaining methods formatting // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; @@ -148988,19 +149736,19 @@ var ts; return modifier.kind; } switch (node.kind) { - case 257 /* ClassDeclaration */: return 84 /* ClassKeyword */; - case 258 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; - case 256 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; - case 260 /* EnumDeclaration */: return 260 /* EnumDeclaration */; - case 172 /* GetAccessor */: return 136 /* GetKeyword */; - case 173 /* SetAccessor */: return 149 /* SetKeyword */; - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return 84 /* SyntaxKind.ClassKeyword */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return 118 /* SyntaxKind.InterfaceKeyword */; + case 256 /* SyntaxKind.FunctionDeclaration */: return 98 /* SyntaxKind.FunctionKeyword */; + case 260 /* SyntaxKind.EnumDeclaration */: return 260 /* SyntaxKind.EnumDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: return 136 /* SyntaxKind.GetKeyword */; + case 173 /* SyntaxKind.SetAccessor */: return 149 /* SyntaxKind.SetKeyword */; + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - return 41 /* AsteriskToken */; + return 41 /* SyntaxKind.AsteriskToken */; } // falls through - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -149015,12 +149763,12 @@ var ts; // .. { // // comment // } - case 19 /* CloseBraceToken */: - case 23 /* CloseBracketToken */: - case 21 /* CloseParenToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + case 21 /* SyntaxKind.CloseParenToken */: return indentation + getDelta(container); } - return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; + return tokenIndentation !== -1 /* Constants.Unknown */ ? tokenIndentation : indentation; }, // if list end token is LessThanToken '>' then its delta should be explicitly suppressed // so that LessThanToken as a binary operator can still be indented. @@ -149047,25 +149795,25 @@ var ts; function shouldAddDelta(line, kind, container) { switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 18 /* OpenBraceToken */: - case 19 /* CloseBraceToken */: - case 21 /* CloseParenToken */: - case 91 /* ElseKeyword */: - case 115 /* WhileKeyword */: - case 59 /* AtToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 21 /* SyntaxKind.CloseParenToken */: + case 91 /* SyntaxKind.ElseKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 59 /* SyntaxKind.AtToken */: return false; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: switch (container.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return false; } break; - case 22 /* OpenBracketToken */: - case 23 /* CloseBracketToken */: - if (container.kind !== 195 /* MappedType */) { + case 22 /* SyntaxKind.OpenBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + if (container.kind !== 195 /* SyntaxKind.MappedType */) { return false; } break; @@ -149100,7 +149848,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Constants.Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -149113,6 +149861,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { + ts.Debug.assert(!ts.nodeIsSynthesized(child)); if (ts.nodeIsMissing(child)) { return inheritedIndentation; } @@ -149123,10 +149872,10 @@ var ts; undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; } // if child is a list item - try to get its indentation, only if parent is within the original range. - var childIndentationAmount = -1 /* Unknown */; + var childIndentationAmount = -1 /* Constants.Unknown */; if (isListItem && ts.rangeContainsRange(originalRange, parent)) { childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1 /* Unknown */) { + if (childIndentationAmount !== -1 /* Constants.Unknown */) { inheritedIndentation = childIndentationAmount; } } @@ -149162,23 +149911,24 @@ var ts; // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); // JSX text shouldn't affect indenting - if (child.kind !== 11 /* JsxText */) { + if (child.kind !== 11 /* SyntaxKind.JsxText */) { ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 165 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 165 /* SyntaxKind.Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 204 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && inheritedIndentation === -1 /* Constants.Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; } function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { ts.Debug.assert(ts.isNodeArray(nodes)); + ts.Debug.assert(!ts.nodeIsSynthesized(nodes)); var listStartToken = getOpenTokenForList(parent, nodes); var listDynamicIndentation = parentDynamicIndentation; var startLine = parentStartLine; @@ -149189,7 +149939,7 @@ var ts; } return; } - if (listStartToken !== 0 /* Unknown */) { + if (listStartToken !== 0 /* SyntaxKind.Unknown */) { // introduce a new indentation scope for lists (including list start and end tokens) while (formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); @@ -149202,7 +149952,7 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); var indentationOnListStartToken = void 0; - if (indentationOnLastIndentedLine !== -1 /* Unknown */) { + if (indentationOnLastIndentedLine !== -1 /* Constants.Unknown */) { // scanner just processed list start token so consider last indentation as list indentation // function foo(): { // last indentation was 0, list item will be indented based on this value // foo: number; @@ -149221,15 +149971,15 @@ var ts; } } } - var inheritedIndentation = -1 /* Unknown */; + var inheritedIndentation = -1 /* Constants.Unknown */; for (var i = 0; i < nodes.length; i++) { var child = nodes[i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0); } var listEndToken = getCloseTokenForOpenToken(listStartToken); - if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { + if (listEndToken !== 0 /* SyntaxKind.Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 27 /* CommaToken */) { + if (tokenInfo.token.kind === 27 /* SyntaxKind.CommaToken */) { // consume the comma consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined; @@ -149251,7 +150001,7 @@ var ts; if (currentTokenInfo.leadingTrivia) { processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); } - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); if (isTokenInRange) { @@ -149261,31 +150011,32 @@ var ts; lineAction = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); // do not indent comments\token if token range overlaps with some error if (!rangeHasError) { - if (lineAction === 0 /* None */) { + if (lineAction === 0 /* LineAction.None */) { // indent token only if end line of previous range does not match start line of the token var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; } else { - indentToken = lineAction === 1 /* LineAdded */; + indentToken = lineAction === 1 /* LineAction.LineAdded */; } } } if (currentTokenInfo.trailingTrivia) { + previousRangeTriviaEnd = ts.last(currentTokenInfo.trailingTrivia).end; processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + -1 /* Constants.Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); indentNextTokenOrTrivia = indentTriviaItems(currentTokenInfo.leadingTrivia, commentIndentation_1, indentNextTokenOrTrivia, function (item) { return insertIndentation(item.pos, commentIndentation_1, /*lineAdded*/ false); }); } // indent token only if is it is in target range and does not overlap with any error ranges - if (tokenIndentation !== -1 /* Unknown */ && indentNextTokenOrTrivia) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAdded */); + if (tokenIndentation !== -1 /* Constants.Unknown */ && indentNextTokenOrTrivia) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAction.LineAdded */); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; } @@ -149299,19 +150050,19 @@ var ts; var triviaItem = trivia_1[_i]; var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: if (triviaInRange) { indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: if (indentNextTokenOrTrivia && triviaInRange) { indentSingleLine(triviaItem); } indentNextTokenOrTrivia = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: indentNextTokenOrTrivia = true; break; } @@ -149329,7 +150080,7 @@ var ts; } function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line @@ -149342,6 +150093,7 @@ var ts; } } previousRange = range; + previousRangeTriviaEnd = range.end; previousParent = parent; previousRangeStartLine = rangeStart.line; return lineAction; @@ -149350,7 +150102,7 @@ var ts; formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); var rules = getRules(formattingContext); var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false; - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (rules) { // Apply rules in reverse order so that higher priority rules (which are first in the array) // win in a conflict with lower priority rules. @@ -149358,14 +150110,14 @@ var ts; lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); if (dynamicIndentation) { switch (lineAction) { - case 2 /* LineRemoved */: + case 2 /* LineAction.LineRemoved */: // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode); } break; - case 1 /* LineAdded */: + case 1 /* LineAction.LineAdded */: // Handle the case where token2 is moved to the new line. // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. @@ -149374,15 +150126,15 @@ var ts; } break; default: - ts.Debug.assert(lineAction === 0 /* None */); + ts.Debug.assert(lineAction === 0 /* LineAction.None */); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* RuleAction.DeleteSpace */) && rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */; }); } else { - trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* EndOfFileToken */; + trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* SyntaxKind.EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -149408,7 +150160,7 @@ var ts; function characterToColumn(startLinePosition, characterInLine) { var column = 0; for (var i = 0; i < characterInLine; i++) { - if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* tab */) { + if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* CharacterCodes.tab */) { column += options.tabSize - column % options.tabSize; } else { @@ -149539,48 +150291,48 @@ var ts; function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* StopProcessingSpaceActions */: + case 1 /* RuleAction.StopProcessingSpaceActions */: // no action required - return 0 /* None */; - case 16 /* DeleteSpace */: + return 0 /* LineAction.None */; + case 16 /* RuleAction.DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 32 /* DeleteToken */: + case 32 /* RuleAction.DeleteToken */: recordDelete(previousRange.pos, previousRange.end - previousRange.pos); break; - case 8 /* InsertNewLine */: + case 8 /* RuleAction.InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } // edit should not be applied if we have one line feed between elements var lineDelta = currentStartLine - previousStartLine; if (lineDelta !== 1) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, ts.getNewLineOrDefaultFromHost(host, options)); - return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; + return onLaterLine ? 0 /* LineAction.None */ : 1 /* LineAction.LineAdded */; } break; - case 4 /* InsertSpace */: + case 4 /* RuleAction.InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* CharacterCodes.space */) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 64 /* InsertTrailingSemicolon */: + case 64 /* RuleAction.InsertTrailingSemicolon */: recordInsert(previousRange.end, ";"); } - return 0 /* None */; + return 0 /* LineAction.None */; } } var LineAction; @@ -149622,71 +150374,71 @@ var ts; // // Internally, we represent the end of the comment at the newline and closing '/', respectively. // - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); + position === range.end && (range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.parameters === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.arguments === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 178 /* TypeReference */: - case 210 /* TaggedTemplateExpression */: - case 181 /* TypeQuery */: - case 228 /* ExpressionWithTypeArguments */: - case 200 /* ImportType */: + case 178 /* SyntaxKind.TypeReference */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 181 /* SyntaxKind.TypeQuery */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 200 /* SyntaxKind.ImportType */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 182 /* TypeLiteral */: - return 18 /* OpenBraceToken */; + case 182 /* SyntaxKind.TypeLiteral */: + return 18 /* SyntaxKind.OpenBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 20 /* OpenParenToken */: - return 21 /* CloseParenToken */; - case 29 /* LessThanToken */: - return 31 /* GreaterThanToken */; - case 18 /* OpenBraceToken */: - return 19 /* CloseBraceToken */; + case 20 /* SyntaxKind.OpenParenToken */: + return 21 /* SyntaxKind.CloseParenToken */; + case 29 /* SyntaxKind.LessThanToken */: + return 31 /* SyntaxKind.GreaterThanToken */; + case 18 /* SyntaxKind.OpenBraceToken */: + return 19 /* SyntaxKind.CloseBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } var internedSizes; var internedTabsIndentation; @@ -149772,7 +150524,7 @@ var ts; var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); // eslint-disable-next-line no-null/no-null var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); - if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -149808,21 +150560,21 @@ var ts; // y: undefined, // } // ``` - var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */; + var isObjectLiteral = currentToken.kind === 18 /* SyntaxKind.OpenBraceToken */ && currentToken.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* SyntaxKind.CommaToken */ && precedingToken.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } } var containerList = getListByPosition(position, precedingToken.parent, sourceFile); // use list position if the preceding token is before any list items if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) { - var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; + var useTheSameBaseIndentation = [213 /* SyntaxKind.FunctionExpression */, 214 /* SyntaxKind.ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize; return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217 } @@ -149842,7 +150594,7 @@ var ts; return column; } var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); - return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; + return firstNonWhitespaceCharacterCode === 42 /* CharacterCodes.asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { // move backwards until we find a line with a non-whitespace character, @@ -149867,9 +150619,9 @@ var ts; if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(options, current, previous, sourceFile, /*isNextChild*/ true)) { var currentStart = getStartLineAndCharacterForNode(current, sourceFile); var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); - var indentationDelta = nextTokenKind !== 0 /* Unknown */ + var indentationDelta = nextTokenKind !== 0 /* NextTokenKind.Unknown */ // handle cases when codefix is about to be inserted before the close brace - ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0 + ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* NextTokenKind.CloseBrace */ ? options.indentSize : 0 : lineAtPosition !== currentStart.line ? options.indentSize : 0; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } @@ -149878,7 +150630,7 @@ var ts; // function foo(a // | preceding node 'a' does share line with its parent but indentation is expected var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, /*listIndentsChild*/ true); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } previous = current; @@ -149932,12 +150684,12 @@ var ts; // }) looking at the relationship between the list and *first* list item. var listIndentsChild = !!firstListChild && getStartLineAndCharacterForNode(firstListChild, sourceFile).line > containingListOrParentStart.line; var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, listIndentsChild); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } // try to fetch actual indentation for current node from source text actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } } @@ -149976,7 +150728,7 @@ var ts; } else { // handle broken code gracefully - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } } /* @@ -149987,9 +150739,9 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 305 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 305 /* SyntaxKind.SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } @@ -150002,13 +150754,13 @@ var ts; function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current, sourceFile); if (!nextToken) { - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } - if (nextToken.kind === 18 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* SyntaxKind.OpenBraceToken */) { // open braces are always indented at the parent level - return 1 /* OpenBrace */; + return 1 /* NextTokenKind.OpenBrace */; } - else if (nextToken.kind === 19 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -150018,9 +150770,9 @@ var ts; // class A { // $} var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine ? 2 /* CloseBrace */ : 0 /* Unknown */; + return lineAtPosition === nextTokenStartLine ? 2 /* NextTokenKind.CloseBrace */ : 0 /* NextTokenKind.Unknown */; } - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); @@ -150035,8 +150787,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 239 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); + if (parent.kind === 239 /* SyntaxKind.IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* SyntaxKind.ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -150116,42 +150868,42 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getList(node.typeArguments); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return getList(node.properties); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getList(node.elements); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return getList(node.members); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return getList(node.parameters); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return getList(node.typeParameters); - case 209 /* NewExpression */: - case 208 /* CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return getList(node.declarations); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return getList(node.elements); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -150169,27 +150921,27 @@ var ts; } function getActualIndentationForListStartLine(list, sourceFile, options) { if (!list) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 255 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); - if (result !== -1 /* Unknown */) { + if (result !== -1 /* Value.Unknown */) { return result; } } return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -150198,7 +150950,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 27 /* CommaToken */) { + if (list[i].kind === 27 /* SyntaxKind.CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -150208,7 +150960,7 @@ var ts; } lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); @@ -150229,7 +150981,7 @@ var ts; if (!ts.isWhiteSpaceSingleLine(ch)) { break; } - if (ch === 9 /* tab */) { + if (ch === 9 /* CharacterCodes.tab */) { column += options.tabSize + (column % options.tabSize); } else { @@ -150245,98 +150997,98 @@ var ts; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { - var childKind = child ? child.kind : 0 /* Unknown */; + var childKind = child ? child.kind : 0 /* SyntaxKind.Unknown */; switch (parent.kind) { - case 238 /* ExpressionStatement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 204 /* ArrayLiteralExpression */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 195 /* MappedType */: - case 184 /* TupleType */: - case 263 /* CaseBlock */: - case 290 /* DefaultClause */: - case 289 /* CaseClause */: - case 212 /* ParenthesizedExpression */: - case 206 /* PropertyAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 237 /* VariableStatement */: - case 271 /* ExportAssignment */: - case 247 /* ReturnStatement */: - case 222 /* ConditionalExpression */: - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: - case 279 /* JsxSelfClosingElement */: - case 288 /* JsxExpression */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 164 /* Parameter */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 191 /* ParenthesizedType */: - case 210 /* TaggedTemplateExpression */: - case 218 /* AwaitExpression */: - case 273 /* NamedExports */: - case 269 /* NamedImports */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 167 /* PropertyDeclaration */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 195 /* SyntaxKind.MappedType */: + case 184 /* SyntaxKind.TupleType */: + case 263 /* SyntaxKind.CaseBlock */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 237 /* SyntaxKind.VariableStatement */: + case 271 /* SyntaxKind.ExportAssignment */: + case 247 /* SyntaxKind.ReturnStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 164 /* SyntaxKind.Parameter */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 273 /* SyntaxKind.NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 254 /* VariableDeclaration */: - case 296 /* PropertyAssignment */: - case 221 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 254 /* SyntaxKind.VariableDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind === 221 /* BinaryExpression */ && sourceFile && child && childKind === 278 /* JsxElement */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && sourceFile && child && childKind === 278 /* SyntaxKind.JsxElement */) { var parentStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, parent.pos)).line; var childStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, child.pos)).line; return parentStartLine !== childStartLine; } - if (parent.kind !== 221 /* BinaryExpression */) { + if (parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { return true; } break; - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return childKind !== 235 /* Block */; - case 214 /* ArrowFunction */: - if (sourceFile && childKind === 212 /* ParenthesizedExpression */) { + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return childKind !== 235 /* SyntaxKind.Block */; + case 214 /* SyntaxKind.ArrowFunction */: + if (sourceFile && childKind === 212 /* SyntaxKind.ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 235 /* Block */; - case 272 /* ExportDeclaration */: - return childKind !== 273 /* NamedExports */; - case 266 /* ImportDeclaration */: - return childKind !== 267 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 269 /* NamedImports */); - case 278 /* JsxElement */: - return childKind !== 281 /* JsxClosingElement */; - case 282 /* JsxFragment */: - return childKind !== 284 /* JsxClosingFragment */; - case 188 /* IntersectionType */: - case 187 /* UnionType */: - if (childKind === 182 /* TypeLiteral */ || childKind === 184 /* TupleType */) { + return childKind !== 235 /* SyntaxKind.Block */; + case 272 /* SyntaxKind.ExportDeclaration */: + return childKind !== 273 /* SyntaxKind.NamedExports */; + case 266 /* SyntaxKind.ImportDeclaration */: + return childKind !== 267 /* SyntaxKind.ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 269 /* SyntaxKind.NamedImports */); + case 278 /* SyntaxKind.JsxElement */: + return childKind !== 281 /* SyntaxKind.JsxClosingElement */; + case 282 /* SyntaxKind.JsxFragment */: + return childKind !== 284 /* SyntaxKind.JsxClosingFragment */; + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + if (childKind === 182 /* SyntaxKind.TypeLiteral */ || childKind === 184 /* SyntaxKind.TupleType */) { return false; } break; @@ -150347,11 +151099,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: - return parent.kind !== 235 /* Block */; + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + return parent.kind !== 235 /* SyntaxKind.Block */; default: return false; } @@ -150441,7 +151193,7 @@ var ts; i++; continue; } - return ch === 47 /* slash */; + return ch === 47 /* CharacterCodes.slash */; } return false; } @@ -150525,7 +151277,7 @@ var ts; var comment = comments_2[_i]; // Single line can break the loop as trivia will only be this line. // Comments on subsequest lines are also ignored. - if (comment.kind === 2 /* SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { + if (comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { break; } // Get the end line of the comment and compare against the end line of the node. @@ -150568,7 +151320,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 205 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* SyntaxKind.CommaToken */ || (candidate.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -150674,7 +151426,7 @@ var ts; }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 27 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* SyntaxKind.CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -150738,7 +151490,7 @@ var ts; var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); - var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; + var text = "".concat(insertAtLineStart ? "" : this.newLineCharacter, "//").concat(commentText).concat(this.newLineCharacter).concat(indent); this.insertText(sourceFile, token.getStart(sourceFile), text); }; ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { @@ -150791,7 +151543,7 @@ var ts; var _a; var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return false; // Function missing parentheses, give up @@ -150800,19 +151552,19 @@ var ts; } } else { - endNode = (_a = (node.kind === 254 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { - var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; + var start = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile).getStart(sourceFile) + 1; var suffix = node.parameters.length ? ", " : ""; this.insertNodeAt(sourceFile, start, type, { prefix: "this: ", suffix: suffix }); }; ChangeTracker.prototype.insertTypeParameters = function (sourceFile, node, typeParameters) { // If no `(`, is an arrow function `x => x`, so use the pos of the first parameter - var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">", joiner: ", " }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, inserted, blankLineBetween) { @@ -150953,8 +151705,8 @@ var ts; if (needSemicolonBetween(after, newNode)) { // check if previous statement ends with semicolon // if not - insert semicolon to preserve the code from changing the meaning due to ASI - if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { - this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SemicolonToken */)); + if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* CharacterCodes.semicolon */) { + this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -150962,22 +151714,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n".concat(options.prefix) : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 254 /* VariableDeclaration */: - case 10 /* StringLiteral */: - case 79 /* Identifier */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 10 /* SyntaxKind.StringLiteral */: + case 79 /* SyntaxKind.Identifier */: return { prefix: ", " }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return { prefix: " " }; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -150986,28 +151738,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 214 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + if (node.kind === 214 /* SyntaxKind.ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* SyntaxKind.EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* SyntaxKind.FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` - this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); + this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function ".concat(name, "(")); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } - if (node.body.kind !== 235 /* Block */) { + if (node.body.kind !== 235 /* SyntaxKind.Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(105 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* SyntaxKind.OpenBraceToken */), ts.factory.createToken(105 /* SyntaxKind.ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */), ts.factory.createToken(19 /* SyntaxKind.CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 213 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 213 /* SyntaxKind.FunctionExpression */ ? 98 /* SyntaxKind.FunctionKeyword */ : 84 /* SyntaxKind.ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -151062,7 +151814,7 @@ var ts; var nextNode = containingList[index + 1]; var startPos = skipWhitespacesAndLineBreaks(sourceFile.text, nextNode.getFullStart()); // write separator and leading trivia of the next element as suffix - var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + var suffix = "".concat(ts.tokenToString(nextToken.kind)).concat(sourceFile.text.substring(nextToken.end, startPos)); this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } @@ -151079,12 +151831,12 @@ var ts; // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise // i.e. var x = 1 // this is x // | new element will be inserted at this position - separator = 27 /* CommaToken */; + separator = 27 /* SyntaxKind.CommaToken */; } else { // element has more than one element, pick separator from the list var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); - separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* SyntaxKind.CommaToken */; // determine if list is multiline by checking lines of after element and element that precedes it. var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; @@ -151107,7 +151859,7 @@ var ts; this.replaceRange(sourceFile, ts.createRange(insertPos), newNode, { indentation: indentation, prefix: this.newLineCharacter }); } else { - this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: ts.tokenToString(separator) + " " }); + this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: "".concat(ts.tokenToString(separator), " ") }); } } }; @@ -151135,7 +151887,7 @@ var ts; ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. - var _loop_10 = function (sourceFile, node) { + var _loop_9 = function (sourceFile, node) { if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { if (ts.isArray(node)) { this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node)); @@ -151148,7 +151900,7 @@ var ts; var this_1 = this; for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) { var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node; - _loop_10(sourceFile, node); + _loop_9(sourceFile, node); } deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); @@ -151184,10 +151936,10 @@ var ts; }()); textChanges_3.ChangeTracker = ChangeTracker; function updateJSDocHost(parent) { - if (parent.kind !== 214 /* ArrowFunction */) { + if (parent.kind !== 214 /* SyntaxKind.ArrowFunction */) { return parent; } - var jsDocNode = parent.parent.kind === 167 /* PropertyDeclaration */ ? + var jsDocNode = parent.parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ? parent.parent : parent.parent.parent; jsDocNode.jsDoc = parent.jsDoc; @@ -151199,16 +151951,16 @@ var ts; return undefined; } switch (oldTag.kind) { - case 340 /* JSDocParameterTag */: { + case 340 /* SyntaxKind.JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment) : undefined; } - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -151217,8 +151969,8 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - var open = ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile); - var close = ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile); + var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); + var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); return [open === null || open === void 0 ? void 0 : open.end, close === null || close === void 0 ? void 0 : close.end]; } function getMembersOrProperties(node) { @@ -151236,14 +151988,14 @@ var ts; // order changes by start position // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa. var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); - var _loop_11 = function (i) { + var _loop_10 = function (i) { ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () { - return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range); + return "".concat(JSON.stringify(normalized[i].range), " and ").concat(JSON.stringify(normalized[i + 1].range)); }); }; // verify that change intervals do not overlap, except possibly at end points. for (var i = 0; i < normalized.length - 1; i++) { - _loop_11(i); + _loop_10(i); } var textChanges = ts.mapDefined(normalized, function (c) { var span = ts.createTextSpanFromRange(c.range); @@ -151265,8 +152017,8 @@ var ts; changesToText.newFileChanges = newFileChanges; function newFileChangesWorker(oldFile, scriptKind, statements, newLineCharacter, formatContext) { // TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this - var nonFormattedText = statements.map(function (s) { return s === 4 /* NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); - var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ESNext */, /*setParentNodes*/ true, scriptKind); + var nonFormattedText = statements.map(function (s) { return s === 4 /* SyntaxKind.NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ScriptTarget.ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); return applyChanges(nonFormattedText, changes) + newLineCharacter; } @@ -151321,7 +152073,7 @@ var ts; neverAsciiEscape: true, preserveSourceNewlines: true, terminateUnterminatedLiterals: true - }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + }, writer).writeNode(4 /* EmitHint.Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -151329,7 +152081,7 @@ var ts; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var _a = changes[i], span = _a.span, newText = _a.newText; - text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); + text = "".concat(text.substring(0, span.start)).concat(newText).concat(text.substring(ts.textSpanEnd(span))); } return text; } @@ -151339,7 +152091,7 @@ var ts; } // A transformation context that won't perform parenthesization, as some parenthesization rules // are more aggressive than is strictly necessary. - var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); + var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes @@ -151550,7 +152302,7 @@ var ts; var firstNodeLine; for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { var range = ranges_1[_b]; - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { if (ts.isPinnedComment(text, range.pos)) { lastComment = { range: range, pinnedOrTripleSlash: true }; continue; @@ -151590,7 +152342,7 @@ var ts; var charCode = text.charCodeAt(position); if (ts.isLineBreak(charCode)) { position++; - if (position < text.length && charCode === 13 /* carriageReturn */ && text.charCodeAt(position) === 10 /* lineFeed */) { + if (position < text.length && charCode === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(position) === 10 /* CharacterCodes.lineFeed */) { position++; } } @@ -151602,18 +152354,18 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 164 /* Parameter */: { + case 164 /* SyntaxKind.Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && - !ts.findChildOfKind(oldFunction, 20 /* OpenParenToken */, sourceFile)) { + !ts.findChildOfKind(oldFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile)) { // Lambdas with exactly one parameter are special because, after removal, there // must be an empty parameter list (i.e. `()`) and this won't necessarily be the // case if the parameter is simply removed (e.g. in `x => 1`). @@ -151624,17 +152376,17 @@ var ts; } break; } - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax); // For first import, leave header comment in place, otherwise only delete JSDoc comments deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, }); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 202 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -151642,13 +152394,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -151657,17 +152409,17 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -151696,7 +152448,7 @@ var ts; // import |d,| * as ns from './file' var start = importClause.name.getStart(sourceFile); var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); - if (nextToken && nextToken.kind === 27 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* SyntaxKind.CommaToken */) { // shift first non-whitespace position after comma to the start position of the node var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); changes.deleteRange(sourceFile, { pos: start, end: end }); @@ -151718,15 +152470,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 266 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 266 /* SyntaxKind.ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 292 /* CatchClause */) { + if (parent.kind === 292 /* SyntaxKind.CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* SyntaxKind.OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* SyntaxKind.CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -151735,14 +152487,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -151929,8 +152681,8 @@ var ts; }); function makeChange(changeTracker, sourceFile, assertion) { var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } function getAssertion(sourceFile, pos) { @@ -152014,7 +152766,7 @@ var ts; } } fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.add(ts.getNodeId(insertionSite)); - var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* Async */))); + var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* ModifierFlags.Async */))); changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier); } function getFixableErrorSpanDeclaration(sourceFile, span) { @@ -152151,19 +152903,19 @@ var ts; } var isCompleteFix = identifiers.isCompleteFix; var initializers; - var _loop_12 = function (identifier) { + var _loop_11 = function (identifier) { var symbol = checker.getSymbolAtLocation(identifier); if (!symbol) { return "continue"; } var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 237 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 237 /* SyntaxKind.VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || - ts.hasSyntacticModifier(variableStatement, 1 /* Export */) || + ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { isCompleteFix = false; @@ -152184,7 +152936,7 @@ var ts; }; for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { var identifier = _a[_i]; - _loop_12(identifier); + _loop_11(identifier); } return initializers && { initializers: initializers, @@ -152231,15 +152983,15 @@ var ts; // Promise as an invalid operand. So if the whole binary expression is // typed `any` as a result, there is a strong likelihood that this Promise // is accidentally missing `await`. - checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; + checker.getTypeAtLocation(errorNode).flags & 1 /* TypeFlags.Any */; } function isInsideAwaitableBody(node) { - return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* NodeFlags.AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* FunctionDeclaration */ || - ancestor.parent.kind === 213 /* FunctionExpression */ || - ancestor.parent.kind === 214 /* ArrowFunction */ || - ancestor.parent.kind === 169 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + ancestor.parent.kind === 213 /* SyntaxKind.FunctionExpression */ || + ancestor.parent.kind === 214 /* SyntaxKind.ArrowFunction */ || + ancestor.parent.kind === 169 /* SyntaxKind.MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -152328,7 +153080,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -152352,16 +153104,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* SyntaxKind.ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 79 /* Identifier */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 79 /* SyntaxKind.Identifier */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return true; default: return false; @@ -152375,9 +153127,9 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 79 /* Identifier */: - case 221 /* BinaryExpression */: - case 27 /* CommaToken */: + case 79 /* SyntaxKind.Identifier */: + case 221 /* SyntaxKind.BinaryExpression */: + case 27 /* SyntaxKind.CommaToken */: return true; default: return false; @@ -152387,10 +153139,10 @@ var ts; if (!ts.isBinaryExpression(expression)) { return false; } - if (expression.operatorToken.kind === 27 /* CommaToken */) { + if (expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 63 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -152425,9 +153177,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 167 /* PropertyDeclaration */ && + if (declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 135 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 135 /* SyntaxKind.DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -152541,7 +153293,7 @@ var ts; if (!errorNode) { return undefined; } - else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return { source: errorNode.parent.right, target: errorNode.parent.left }; } else if (ts.isVariableDeclaration(errorNode.parent) && errorNode.parent.initializer) { @@ -152581,7 +153333,7 @@ var ts; var add = toAdd_1[_i]; var d = add.valueDeclaration; if (d && (ts.isPropertySignature(d) || ts.isPropertyDeclaration(d)) && d.type) { - var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* UnionType */ ? d.type.types : [d.type], true), [ + var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* SyntaxKind.UnionType */ ? d.type.types : [d.type], true), [ ts.factory.createTypeReferenceNode("undefined") ], false)); changes.replaceNode(d.getSourceFile(), d.type, t); @@ -152634,9 +153386,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -152646,7 +153398,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -152661,30 +153413,30 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return transformJSDocOptionalType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return transformJSDocType(node.type); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return transformJSDocNullableType(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return transformJSDocVariadicType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return transformJSDocFunctionType(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); - ts.setEmitFlags(visited, 1 /* SingleLine */); + ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */); return visited; } } @@ -152701,13 +153453,13 @@ var ts; var _a; // TODO: This does not properly handle `function(new:C, string)` per https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#the-javascript-type-language // however we do handle it correctly in `serializeTypeForDeclaration` in checker.ts - return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 318 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 318 /* SyntaxKind.JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : node.dotDotDotToken; return ts.factory.createParameterDeclaration(node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -152744,11 +153496,11 @@ var ts; function transformJSDocIndexSignature(node) { var index = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*modifiers*/ undefined, [index], node.typeArguments[1])]); - ts.setEmitFlags(indexSignature, 1 /* SingleLine */); + ts.setEmitFlags(indexSignature, 1 /* EmitFlags.SingleLine */); return indexSignature; } })(codefix = ts.codefix || (ts.codefix = {})); @@ -152775,7 +153527,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */))) { // Bad input return undefined; } @@ -152808,14 +153560,14 @@ var ts; if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements); } } else { - createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)], memberElements); + createClassElement(member, [ts.factory.createToken(124 /* SyntaxKind.StaticKeyword */)], memberElements); } }); } @@ -152866,7 +153618,7 @@ var ts; function createClassElement(symbol, modifiers, members) { // Right now the only thing we can convert are function expressions, which are marked as methods // or { x: y } type prototype assignments, which are marked as ObjectLiteral - if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + if (!(symbol.flags & 8192 /* SymbolFlags.Method */) && !(symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */)) { return; } var memberDeclaration = symbol.valueDeclaration; @@ -152885,7 +153637,7 @@ var ts; return; } // 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 === 238 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -152937,7 +153689,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -152948,14 +153700,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 235 /* Block */) { + if (arrowFunctionBody.kind === 235 /* SyntaxKind.Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -152972,7 +153724,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -152983,7 +153735,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -153010,7 +153762,7 @@ var ts; } if (ts.isStringLiteralLike(propName)) { return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text) - : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */) + : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* QuotePreference.Single */) : propName; } return undefined; @@ -153068,8 +153820,8 @@ var ts; return; } var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos); - changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, { suffix: " " }); - var _loop_13 = function (returnStatement) { + changes.insertModifierAt(sourceFile, pos, 131 /* SyntaxKind.AsyncKeyword */, { suffix: " " }); + var _loop_12 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false); @@ -153091,7 +153843,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var returnStatement = returnStatements_1[_i]; - var state_5 = _loop_13(returnStatement); + var state_5 = _loop_12(returnStatement); if (typeof state_5 === "object") return state_5.value; } @@ -153143,7 +153895,7 @@ var ts; // NOTE: this is a mostly copy of `isReferenceToType` from checker.ts. While this violates DRY, it keeps // `isReferenceToType` in checker local to the checker to avoid the cost of a property lookup on `ts`. function isReferenceToType(type, target) { - return (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + return (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getExplicitPromisedTypeOfPromiseReturningCallExpression(node, callback, checker) { @@ -153206,7 +153958,7 @@ var ts; var ident = (firstParameter === null || firstParameter === void 0 ? void 0 : firstParameter.valueDeclaration) && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) - || ts.factory.createUniqueName("result", 16 /* Optimistic */); + || ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -153287,7 +154039,7 @@ var ts; } function isNullOrUndefined(_a, node) { var checker = _a.checker; - if (node.kind === 104 /* NullKeyword */) + if (node.kind === 104 /* SyntaxKind.NullKeyword */) return true; if (ts.isIdentifier(node) && !ts.isGeneratedIdentifier(node) && ts.idText(node) === "undefined") { var symbol = checker.getSymbolAtLocation(node); @@ -153296,7 +154048,7 @@ var ts; return false; } function createUniqueSynthName(prevArgName) { - var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* Optimistic */); + var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* GeneratedIdentifierFlags.Optimistic */); return createSynthIdentifier(renamedPrevArg); } function getPossibleNameForVarDecl(node, transformer, continuationArgName) { @@ -153316,7 +154068,7 @@ var ts; }); } else { - possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* Optimistic */), continuationArgName.types); + possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */), continuationArgName.types); } // We are about to write a 'let' variable declaration, but `transformExpression` for both // the try block and catch/finally block will assign to this name. Setting this flag indicates @@ -153332,10 +154084,10 @@ var ts; if (possibleNameForVarDecl && !shouldReturn(node, transformer)) { varDeclIdentifier = ts.getSynthesizedDeepClone(declareSynthIdentifier(possibleNameForVarDecl)); var typeArray = possibleNameForVarDecl.types; - var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */); + var unionType = transformer.checker.getUnionType(typeArray, 2 /* UnionReduction.Subtype */); var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); var varDecl = [ts.factory.createVariableDeclaration(varDeclIdentifier, /*exclamationToken*/ undefined, unionTypeNode)]; - var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* Let */)); + var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* NodeFlags.Let */)); statements.push(varDeclList); } statements.push(tryStatement); @@ -153345,7 +154097,7 @@ var ts; ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingPattern(continuationArgName)), /*exclamationToken*/ undefined, /*type*/ undefined, varDeclIdentifier) - ], 2 /* Const */))); + ], 2 /* NodeFlags.Const */))); } return statements; } @@ -153450,12 +154202,12 @@ var ts; /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingName(variableName)), /*exclamationToken*/ undefined, typeAnnotation, rightHandSide) - ], 2 /* Const */)) + ], 2 /* NodeFlags.Const */)) ]; } function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) { if (typeAnnotation && expressionToReturn) { - var name = ts.factory.createUniqueName("result", 16 /* Optimistic */); + var name = ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); return __spreadArray(__spreadArray([], createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), true), [ ts.factory.createReturnStatement(name) ], false); @@ -153471,11 +154223,11 @@ var ts; function transformCallbackArgument(func, hasContinuation, continuationArgName, inputArgName, parent, transformer) { var _a; switch (func.kind) { - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // do not produce a transformed statement for a null argument break; - case 206 /* PropertyAccessExpression */: - case 79 /* Identifier */: // identifier includes undefined + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: // identifier includes undefined if (!inputArgName) { // undefined was argument passed to promise handler break; @@ -153485,7 +154237,7 @@ var ts; return maybeAnnotateAndReturn(synthCall, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker)); } var type = transformer.checker.getTypeAtLocation(func); - var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!callSignatures.length) { // if identifier in handler has no call signatures, it's invalid return silentFail(); @@ -153496,8 +154248,8 @@ var ts; continuationArgName.types.push(transformer.checker.getAwaitedType(returnType) || returnType); } return varDeclOrAssignment; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: { + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_a = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _a === void 0 ? void 0 : _a.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -153599,7 +154351,7 @@ var ts; return !!checker.getPromisedTypeOfPromise(type) ? ts.factory.createAwaitExpression(rightHandSide) : rightHandSide; } function getLastCallSignature(type, checker) { - var callSignatures = checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); return ts.lastOrUndefined(callSignatures); } function removeReturns(stmts, prevArgName, transformer, seenReturnStatement) { @@ -153616,7 +154368,7 @@ var ts; ret.push(ts.factory.createExpressionStatement(ts.factory.createAssignment(referenceSynthIdentifier(prevArgName), possiblyAwaitedExpression))); } else { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* NodeFlags.Const */)))); } } } @@ -153626,7 +154378,7 @@ var ts; } // if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables if (!seenReturnStatement && prevArgName !== undefined) { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* NodeFlags.Const */)))); } return ret; } @@ -153708,12 +154460,12 @@ var ts; } function createSynthIdentifier(identifier, types) { if (types === void 0) { types = []; } - return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; + return { kind: 0 /* SynthBindingNameKind.Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; } function createSynthBindingPattern(bindingPattern, elements, types) { if (elements === void 0) { elements = ts.emptyArray; } if (types === void 0) { types = []; } - return { kind: 1 /* BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; + return { kind: 1 /* SynthBindingNameKind.BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; } function referenceSynthIdentifier(synthId) { synthId.hasBeenReferenced = true; @@ -153734,10 +154486,10 @@ var ts; return synthId.identifier; } function isSynthIdentifier(bindingName) { - return bindingName.kind === 0 /* Identifier */; + return bindingName.kind === 0 /* SynthBindingNameKind.Identifier */; } function isSynthBindingPattern(bindingName) { - return bindingName.kind === 1 /* BindingPattern */; + return bindingName.kind === 1 /* SynthBindingNameKind.BindingPattern */; } function shouldReturn(expression, transformer) { return !!expression.original && transformer.setOfExpressionsToReturn.has(ts.getNodeId(expression.original)); @@ -153775,10 +154527,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -153818,9 +154570,9 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. - res.set(text, makeUniqueName("_" + text, identifiers)); + res.set(text, makeUniqueName("_".concat(text), identifiers)); } }); return res; @@ -153838,29 +154590,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression) && ts.isIdentifier(node.name)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -153907,8 +154659,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -153916,11 +154668,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form ".concat(name.kind)); } } function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) { @@ -153959,19 +154711,19 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return undefined; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 169 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 169 /* SyntaxKind.MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)], prop, useSitesToUnqualify); default: - ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind ".concat(prop.kind)); } }); return statements && [statements, false]; @@ -154000,8 +154752,8 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyMap; - return exports.has("export=" /* ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : - !exports.has("default" /* Default */) ? [[reExportStar(moduleSpecifier)], false] : + return exports.has("export=" /* InternalSymbolName.ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default" /* InternalSymbolName.Default */) ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } @@ -154016,23 +154768,23 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* SyntaxKind.SemicolonToken */, sourceFile); if (semi) changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* SyntaxKind.DotToken */, sourceFile), [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { - var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)]; switch (exported.kind) { - case 213 /* FunctionExpression */: { + case 213 /* SyntaxKind.FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -154040,10 +154792,10 @@ var ts; } } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -154063,7 +154815,7 @@ var ts; : ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode); function replaceNode(original) { // We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions - if (original.kind === 206 /* PropertyAccessExpression */) { + if (original.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var replacement = useSitesToUnqualify.get(original); // Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing useSitesToUnqualify.delete(original); @@ -154078,7 +154830,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -154089,7 +154841,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 202 /* ArrayBindingPattern */: { + case 202 /* SyntaxKind.ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -154100,10 +154852,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind ".concat(name.kind)); } } /** @@ -154160,7 +154912,7 @@ var ts; // Identifiers helpers function makeUniqueName(name, identifiers) { while (identifiers.original.has(name) || identifiers.additional.has(name)) { - name = "_" + name; + name = "_".concat(name); } identifiers.additional.add(name); return name; @@ -154182,11 +154934,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return parent.name !== node; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return parent.propertyName !== node; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -154208,7 +154960,7 @@ var ts; return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName !== undefined && propertyName !== name ? ts.factory.createIdentifier(propertyName) : undefined, ts.factory.createIdentifier(name)); } function makeConst(modifiers, name, init) { - return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* Const */)); + return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* NodeFlags.Const */)); } function makeExportDeclaration(exportSpecifiers, moduleSpecifier) { return ts.factory.createExportDeclaration( @@ -154237,7 +154989,7 @@ var ts; if (!qualifiedName) return undefined; var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, qualifiedName); }); - var newText = qualifiedName.left.text + "[\"" + qualifiedName.right.text + "\"]"; + var newText = "".concat(qualifiedName.left.text, "[\"").concat(qualifiedName.right.text, "\"]"); return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Rewrite_as_the_indexed_access_type_0, newText], fixId, ts.Diagnostics.Rewrite_all_as_indexed_access_types)]; }, fixIds: [fixId], @@ -154297,7 +155049,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 152 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 152 /* SyntaxKind.TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.modifiers, @@ -154464,7 +155216,7 @@ var ts; return ts.Debug.checkDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { - return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* ModifierFlags.Private */); } function addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { var checker = context.program.getTypeChecker(); @@ -154477,10 +155229,10 @@ var ts; var classType = checker.getTypeAtLocation(classDeclaration); var constructor = ts.find(classDeclaration.members, function (m) { return ts.isConstructorDeclaration(m); }); if (!classType.getNumberIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */); + createMissingIndexSignatureDeclaration(implementedType, 1 /* IndexKind.Number */); } if (!classType.getStringIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); + createMissingIndexSignatureDeclaration(implementedType, 0 /* IndexKind.String */); } var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host); codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); }); @@ -154586,20 +155338,20 @@ var ts; var fixes = info.fixes, symbolName = info.symbolName; var fix = ts.first(fixes); switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addToNamespace.push(fix); break; - case 1 /* JsdocTypeImport */: + case 1 /* ImportFixKind.JsdocTypeImport */: importType.push(fix); break; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly; var key = String(ts.getNodeId(importClauseOrBindingPattern)); var entry = addToExisting.get(key); if (!entry) { addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: new ts.Map() }); } - if (importKind === 0 /* Named */) { + if (importKind === 0 /* ImportKind.Named */) { var prevValue = entry === null || entry === void 0 ? void 0 : entry.namedImports.get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); } @@ -154612,32 +155364,32 @@ var ts; } break; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, addAsTypeOnly = fix.addAsTypeOnly; var entry = getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly); ts.Debug.assert(entry.useRequire === useRequire, "(Add new) Tried to add an `import` and a `require` for the same module"); switch (importKind) { - case 1 /* Default */: + case 1 /* ImportKind.Default */: ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport.name === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = { name: symbolName, addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) === null || _b === void 0 ? void 0 : _b.addAsTypeOnly, addAsTypeOnly) }; break; - case 0 /* Named */: + case 0 /* ImportKind.Named */: var prevValue = (entry.namedImports || (entry.namedImports = new ts.Map())).get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); break; - case 3 /* CommonJS */: - case 2 /* Namespace */: + case 3 /* ImportKind.CommonJS */: + case 2 /* ImportKind.Namespace */: ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly }; break; } break; } - case 4 /* PromoteTypeOnly */: + case 4 /* ImportFixKind.PromoteTypeOnly */: // Excluding from fix-all break; default: - ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); + ts.Debug.assertNever(fix, "fix wasn't never - got kind ".concat(fix.kind)); } function reduceAddAsTypeOnlyValues(prevValue, newValue) { // `NotAllowed` overrides `Required` because one addition of a new import might be required to be type-only @@ -154665,13 +155417,13 @@ var ts; namespaceLikeImport: undefined, useRequire: useRequire }; - if (importKind === 1 /* Default */ && addAsTypeOnly === 2 /* Required */) { + if (importKind === 1 /* ImportKind.Default */ && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */) { if (typeOnlyEntry) return typeOnlyEntry; newImports.set(typeOnlyKey, newEntry); return newEntry; } - if (addAsTypeOnly === 1 /* Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { + if (addAsTypeOnly === 1 /* AddAsTypeOnly.Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { return (typeOnlyEntry || nonTypeOnlyEntry); } if (nonTypeOnlyEntry) { @@ -154681,7 +155433,7 @@ var ts; return newEntry; } function newImportsKey(moduleSpecifier, topLevelTypeOnly) { - return (topLevelTypeOnly ? 1 : 0) + "|" + moduleSpecifier; + return "".concat(topLevelTypeOnly ? 1 : 0, "|").concat(moduleSpecifier); } } function writeFixes(changeTracker) { @@ -154771,7 +155523,7 @@ var ts; var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions); var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program); var includeSymbolNameInDescription = symbolName !== symbolToken.text; - return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions)); + return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* QuotePreference.Double */, compilerOptions)); } codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction; function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) { @@ -154799,7 +155551,7 @@ var ts; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; + return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; } } } @@ -154822,7 +155574,7 @@ var ts; for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) { - result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); + result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); } } }); @@ -154874,7 +155626,7 @@ var ts; if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; + return { kind: 0 /* ImportFixKind.UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -154882,11 +155634,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport); return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol); default: @@ -154896,11 +155648,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return declaration.name.text; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text; default: return ts.Debug.assertNever(declaration); @@ -154909,31 +155661,31 @@ var ts; function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, symbol, targetFlags, checker, compilerOptions) { if (!isValidTypeOnlyUseSite) { // Can't use a type-only import if the usage is an emitting position - return 4 /* NotAllowed */; + return 4 /* AddAsTypeOnly.NotAllowed */; } - if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* Error */) { + if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */) { // Not writing a (top-level) type-only import here would create an error because the runtime dependency is unnecessary - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } if (compilerOptions.isolatedModules && compilerOptions.preserveValueImports && - (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { + (!(targetFlags & 111551 /* SymbolFlags.Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { // A type-only import is required for this symbol if under these settings if the symbol will // be erased, which will happen if the target symbol is purely a type or if it was exported/imported // as type-only already somewhere between this import and the target. - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } - return 1 /* Allowed */; + return 1 /* AddAsTypeOnly.Allowed */; } function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - if (importKind === 3 /* CommonJS */ || importKind === 2 /* Namespace */ || declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (importKind === 3 /* ImportKind.CommonJS */ || importKind === 2 /* ImportKind.Namespace */ || declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // These kinds of imports are not combinable with anything return undefined; } - if (declaration.kind === 254 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 201 /* ObjectBindingPattern */ - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } + if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { + return (importKind === 0 /* ImportKind.Named */ || importKind === 1 /* ImportKind.Default */) && declaration.name.kind === 201 /* SyntaxKind.ObjectBindingPattern */ + ? { kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* AddAsTypeOnly.NotAllowed */ } : undefined; } var importClause = declaration.importClause; @@ -154942,22 +155694,22 @@ var ts; var name = importClause.name, namedBindings = importClause.namedBindings; // A type-only import may not have both a default and named imports, so the only way a name can // be added to an existing type-only import is adding a named import to existing named bindings. - if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings)) + if (importClause.isTypeOnly && !(importKind === 0 /* ImportKind.Named */ && namedBindings)) return undefined; // N.B. we don't have to figure out whether to use the main program checker // or the AutoImportProvider checker because we're adding to an existing import; the existence of // the import guarantees the symbol came from the main program. var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ false, symbol, targetFlags, checker, compilerOptions); - if (importKind === 1 /* Default */ && (name || // Cannot add a default import to a declaration that already has one - addAsTypeOnly === 2 /* Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings + if (importKind === 1 /* ImportKind.Default */ && (name || // Cannot add a default import to a declaration that already has one + addAsTypeOnly === 2 /* AddAsTypeOnly.Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings )) return undefined; - if (importKind === 0 /* Named */ && - (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import + if (importKind === 0 /* ImportKind.Named */ && + (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* SyntaxKind.NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import ) return undefined; return { - kind: 2 /* AddToExisting */, + kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, @@ -154976,7 +155728,7 @@ var ts; (importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent); } } - else if (i.kind === 266 /* ImportDeclaration */ || i.kind === 265 /* ImportEqualsDeclaration */) { + else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); if (moduleSymbol) { (importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i); @@ -154987,7 +155739,7 @@ var ts; getImportsForExportInfo: function (_a) { var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol; // Can't use an es6 import for a type in JS. - if (!(targetFlags & 111551 /* Value */) && ts.isSourceFileJS(importingFile)) + if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile)) return ts.emptyArray; var matchingDeclarations = importMap === null || importMap === void 0 ? void 0 : importMap.get(ts.getSymbolId(moduleSymbol)); if (!matchingDeclarations) @@ -155038,15 +155790,15 @@ var ts; var fixes = ts.flatMap(exportInfo, function (exportInfo, i) { var checker = getChecker(exportInfo.isFromPackageJson); var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers; - var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */); + var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* SymbolFlags.Value */); var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions); computedWithoutCacheCount += computedWithoutCache ? 1 : 0; return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) { return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined : // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : + !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* ImportFixKind.JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : { - kind: 3 /* AddNew */, + kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), useRequire: useRequire, @@ -155068,9 +155820,9 @@ var ts; var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (moduleSpecifier) { var addAsTypeOnly = useRequire - ? 4 /* NotAllowed */ + ? 4 /* AddAsTypeOnly.NotAllowed */ : getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, symbol, targetFlags, checker, compilerOptions); - return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; + return { kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; } } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -155101,23 +155853,23 @@ var ts; if (!ts.some(fixes)) return; // These will always be placed first if available, and are better than other kinds - if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) { + if (fixes[0].kind === 0 /* ImportFixKind.UseNamespace */ || fixes[0].kind === 2 /* ImportFixKind.AddToExisting */) { return fixes[0]; } return fixes.reduce(function (best, fix) { // Takes true branch of conditional if `fix` is better than `best` - return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best; + return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* Comparison.LessThan */ ? fix : best; }); } /** @returns `Comparison.LessThan` if `a` is better than `b`. */ function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) { - if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + if (a.kind !== 0 /* ImportFixKind.UseNamespace */ && b.kind !== 0 /* ImportFixKind.UseNamespace */) { return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath)) || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export. // E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`. @@ -155140,10 +155892,10 @@ var ts; } function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) { if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; if (ts.startsWith(b, "node:") && !ts.startsWith(a, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* GreaterThan */ : -1 /* LessThan */; - return 0 /* EqualTo */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* Comparison.GreaterThan */ : -1 /* Comparison.LessThan */; + return 0 /* Comparison.EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var _b; @@ -155154,7 +155906,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; + var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* ExportKind.UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined; var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes; @@ -155168,7 +155920,7 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } /** @@ -155177,10 +155929,10 @@ var ts; */ function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) { switch (exportKind) { - case 0 /* Named */: return 0 /* Named */; - case 1 /* Default */: return 1 /* Default */; - case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); - case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 0 /* ExportKind.Named */: return 0 /* ImportKind.Named */; + case 1 /* ExportKind.Default */: return 1 /* ImportKind.Default */; + case 2 /* ExportKind.ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 3 /* ExportKind.UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); default: return ts.Debug.assertNever(exportKind); } } @@ -155188,7 +155940,7 @@ var ts; function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { - return 1 /* Default */; + return 1 /* ImportKind.Default */; } // When a synthetic `default` is unavailable, use `import..require` if the module kind supports it. var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -155197,9 +155949,9 @@ var ts; case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */; + return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; } - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: case ts.ModuleKind.ES2020: @@ -155207,12 +155959,12 @@ var ts; case ts.ModuleKind.ESNext: case ts.ModuleKind.None: // Fall back to the `import * as ns` style import. - return 2 /* Namespace */; + return 2 /* ImportKind.Namespace */; case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: - return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */; + return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; default: - return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind ".concat(moduleKind)); } } function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { @@ -155221,7 +155973,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, but appears as an identifier. - if (symbolName === "default" /* Default */) { + if (symbolName === "default" /* InternalSymbolName.Default */) { return undefined; } var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken); @@ -155235,13 +155987,13 @@ var ts; } function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) { var checker = program.getTypeChecker(); - var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); if (!symbol) return undefined; var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol); if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile) return undefined; - return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; + return { kind: 4 /* ImportFixKind.PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; } function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; @@ -155256,8 +156008,8 @@ var ts; function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) { if (ts.isIntrinsicJsxName(symbolToken.text)) return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory - var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); - return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */); + var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); + return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* SymbolFlags.Value */); } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) { @@ -155289,7 +156041,7 @@ var ts; // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* ExportKind.Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; @@ -155300,14 +156052,14 @@ var ts; // 1. 'import =' will not work in es2015+ TS files, so the decision is between a default // and a namespace import, based on allowSyntheticDefaultImports/esModuleInterop. if (!isJS && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { - return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */; } // 2. 'import =' will not work in JavaScript, so the decision is between a default import, // a namespace import, and const/require. if (isJS) { return ts.isExternalModule(importingFile) || forceImportKeyword - ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ - : 3 /* CommonJS */; + ? allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */ + : 3 /* ImportKind.CommonJS */; } // 3. At this point the most correct choice is probably 'import =', but people // really hate that, so look to see if the importing file has any precedent @@ -155316,12 +156068,12 @@ var ts; var statement = _a[_i]; // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; } } // 4. We have no precedent to go on, so just use a default import if // allowSyntheticDefaultImports/esModuleInterop is enabled. - return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 3 /* ImportKind.CommonJS */; } function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { var diag; @@ -155332,45 +156084,45 @@ var ts; } function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addNamespaceQualifier(changes, sourceFile, fix); - return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; - case 1 /* JsdocTypeImport */: + return [ts.Diagnostics.Change_0_to_1, symbolName, "".concat(fix.namespacePrefix, ".").concat(symbolName)]; + case 1 /* ImportFixKind.JsdocTypeImport */: addImportType(changes, sourceFile, fix, quotePreference); return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName]; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier; - doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); + doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes] : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes]; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire; var getDeclarations = useRequire ? getNewRequires : getNewImports; - var defaultImport = importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; - var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; - var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var defaultImport = importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var namedImports = importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; + var namespaceLikeImport = importKind === 2 /* ImportKind.Namespace */ || importKind === 3 /* ImportKind.CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier] : [ts.Diagnostics.Add_import_from_0, moduleSpecifier]; } - case 4 /* PromoteTypeOnly */: { + case 4 /* ImportFixKind.PromoteTypeOnly */: { var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration; var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile); - return promotedDeclaration.kind === 270 /* ImportSpecifier */ + return promotedDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)] : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)]; } default: - return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); + return ts.Debug.assertNever(fix, "Unexpected fix kind ".concat(fix.kind)); } } function getModuleSpecifierText(promotedDeclaration) { var _a, _b; - return promotedDeclaration.kind === 265 /* ImportEqualsDeclaration */ + return promotedDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText() : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text; } @@ -155378,7 +156130,7 @@ var ts; // See comment in `doAddExistingFix` on constant with the same name. var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules; switch (aliasDeclaration.kind) { - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: if (aliasDeclaration.isTypeOnly) { if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) { changes.delete(sourceFile, aliasDeclaration); @@ -155396,13 +156148,13 @@ var ts; promoteImportClause(aliasDeclaration.parent.parent); return aliasDeclaration.parent.parent; } - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: promoteImportClause(aliasDeclaration); return aliasDeclaration; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: promoteImportClause(aliasDeclaration.parent); return aliasDeclaration.parent; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1)); return aliasDeclaration; default: @@ -155414,7 +156166,7 @@ var ts; var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports); if (namedImports && namedImports.elements.length > 1) { if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) && - aliasDeclaration.kind === 270 /* ImportSpecifier */ && + aliasDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && namedImports.elements.indexOf(aliasDeclaration) !== 0) { // The import specifier being promoted will be the only non-type-only, // import in the NamedImports, so it should be moved to the front. @@ -155424,7 +156176,7 @@ var ts; for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) { var element = _a[_i]; if (element !== aliasDeclaration && !element.isTypeOnly) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, element); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, element); } } } @@ -155433,7 +156185,7 @@ var ts; } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) { var _a; - if (clause.kind === 201 /* ObjectBindingPattern */) { + if (clause.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport.name, "default"); } @@ -155443,7 +156195,7 @@ var ts; } return; } - var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* NotAllowed */; }); + var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* AddAsTypeOnly.NotAllowed */; }); var existingSpecifiers = clause.namedBindings && ((_a = ts.tryCast(clause.namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements); // If we are promoting from a type-only import and `--isolatedModules` and `--preserveValueImports` // are enabled, we need to make every existing import specifier type-only. It may be possible that @@ -155494,7 +156246,7 @@ var ts; if (convertExistingToTypeOnly && existingSpecifiers) { for (var _d = 0, existingSpecifiers_1 = existingSpecifiers; _d < existingSpecifiers_1.length; _d++) { var specifier = existingSpecifiers_1[_d]; - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, specifier); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, specifier); } } } @@ -155518,11 +156270,11 @@ var ts; } function getImportTypePrefix(moduleSpecifier, quotePreference) { var quote = ts.getQuoteFromPreference(quotePreference); - return "import(" + quote + moduleSpecifier + quote + ")."; + return "import(".concat(quote).concat(moduleSpecifier).concat(quote, ")."); } function needsTypeOnly(_a) { var addAsTypeOnly = _a.addAsTypeOnly; - return addAsTypeOnly === 2 /* Required */; + return addAsTypeOnly === 2 /* AddAsTypeOnly.Required */; } function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport) { var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); @@ -155531,12 +156283,12 @@ var ts; var topLevelTypeOnly_1 = (!defaultImport || needsTypeOnly(defaultImport)) && ts.every(namedImports, needsTypeOnly); statements = ts.combine(statements, ts.makeImport(defaultImport && ts.factory.createIdentifier(defaultImport.name), namedImports === null || namedImports === void 0 ? void 0 : namedImports.map(function (_a) { var addAsTypeOnly = _a.addAsTypeOnly, name = _a.name; - return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* Required */, + return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */, /*propertyName*/ undefined, ts.factory.createIdentifier(name)); }), moduleSpecifier, quotePreference, topLevelTypeOnly_1)); } if (namespaceLikeImport) { - var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ + var declaration = namespaceLikeImport.importKind === 3 /* ImportKind.CommonJS */ ? ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, needsTypeOnly(namespaceLikeImport), ts.factory.createIdentifier(namespaceLikeImport.name), ts.factory.createExternalModuleReference(quotedModuleSpecifier)) : ts.factory.createImportDeclaration( @@ -155575,7 +156327,7 @@ var ts; ts.factory.createVariableDeclaration(typeof name === "string" ? ts.factory.createIdentifier(name) : name, /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createCallExpression(ts.factory.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -155612,7 +156364,7 @@ var ts; lastCharWasValid = isValid; } // Need `|| "_"` to ensure result isn't empty. - return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; + return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_".concat(res); } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; })(codefix = ts.codefix || (ts.codefix = {})); @@ -155638,54 +156390,90 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var sourceFile = context.sourceFile, span = context.span, program = context.program; - var related = getDiagnosticRelatedInfo(program, sourceFile, span); - if (!related) { + var sourceFile = context.sourceFile, span = context.span, program = context.program, preferences = context.preferences, host = context.host; + var info = getInfo(program, sourceFile, span); + if (info === undefined) return; - } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, program, preferences, host, sourceFile, info); }); return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag); - if (!info) - return; - return addMissingConstraint(changes, info); - }); }, + getAllCodeActions: function (context) { + var program = context.program, preferences = context.preferences, host = context.host; + var seen = new ts.Map(); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length)); + if (info) { + if (ts.addToSeen(seen, ts.getNodeId(info.declaration))) { + return addMissingConstraint(changes, program, preferences, host, diag.file, info); + } + } + return undefined; + }); + })); + } }); - function getDiagnosticRelatedInfo(program, sourceFile, span) { + function getInfo(program, sourceFile, span) { var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; }); - if (!diag || !diag.relatedInformation) + if (diag === undefined || diag.relatedInformation === undefined) return; var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; }); - if (!related) + if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined) return; - return related; - } - function addMissingConstraint(changes, related) { - var decl = findAncestorMatchingSpan(related.file, related); - if (!decl) + var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length)); + if (declaration === undefined) return; - if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) { - decl = decl.parent; + if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) { + declaration = declaration.parent; + } + if (ts.isTypeParameterDeclaration(declaration)) { + // should only issue fix on type parameters written using `extends` + if (ts.isMappedTypeNode(declaration.parent)) + return; + var token = ts.getTokenAtPosition(sourceFile, span.start); + var checker = program.getTypeChecker(); + var constraint = tryGetConstraintType(checker, token) || tryGetConstraintFromDiagnosticMessage(related.messageText); + return { constraint: constraint, declaration: declaration, token: token }; + } + return undefined; + } + function addMissingConstraint(changes, program, preferences, host, sourceFile, info) { + var declaration = info.declaration, constraint = info.constraint; + var checker = program.getTypeChecker(); + if (ts.isString(constraint)) { + changes.insertText(sourceFile, declaration.name.end, " extends ".concat(constraint)); + } + else { + var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); + var tracker = codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }); + var importAdder = codefix.createImportAdder(sourceFile, program, preferences, host); + var typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, scriptTarget, /*flags*/ undefined, tracker); + if (typeNode) { + changes.replaceNode(sourceFile, declaration, ts.factory.updateTypeParameterDeclaration(declaration, /*modifiers*/ undefined, declaration.name, typeNode, declaration.default)); + importAdder.writeFixes(changes); + } } - if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent)) - return; // should only issue fix on type parameters written using `extends` - var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/); - if (!newConstraint) - return; - var newConstraintText = newConstraint[1]; - changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText); } function findAncestorMatchingSpan(sourceFile, span) { - var token = ts.getTokenAtPosition(sourceFile, span.start); var end = ts.textSpanEnd(span); + var token = ts.getTokenAtPosition(sourceFile, span.start); while (token.end < end) { token = token.parent; } return token; } + function tryGetConstraintFromDiagnosticMessage(messageText) { + var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1]; + return constraint; + } + function tryGetConstraintType(checker, node) { + if (ts.isTypeNode(node.parent)) { + return checker.getTypeArgumentConstraint(node.parent); + } + var contextualType = ts.isExpression(node) ? checker.getContextualType(node) : undefined; + return contextualType || checker.getTypeAtLocation(node); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -155818,7 +156606,7 @@ var ts; accessibilityModifier ? accessibilityModifier.end : lastDecorator ? ts.skipTrivia(sourceFile.text, lastDecorator.end) : classElement.getStart(sourceFile); var options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " }; - changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* OverrideKeyword */, options); + changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* SyntaxKind.OverrideKeyword */, options); } function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { var classElement = findContainerClassElementLike(sourceFile, pos); @@ -155832,13 +156620,13 @@ var ts; } function isClassElementLikeHasJSDoc(node) { switch (node.kind) { - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.isParameterPropertyDeclaration(node, node.parent); default: return false; @@ -155880,7 +156668,7 @@ var ts; }); function doChange(changes, sourceFile, node, preferences) { var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */); + var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* QuotePreference.Single */); changes.replaceNode(sourceFile, node, ts.isPropertyAccessChain(node) ? ts.factory.createElementAccessChain(node.expression, node.questionDotToken, argumentsExpression) : ts.factory.createElementAccessExpression(node.expression, argumentsExpression)); @@ -155920,7 +156708,7 @@ var ts; if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn)) return undefined; if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function - var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* SyntaxKind.FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -155939,7 +156727,7 @@ var ts; else { // `function f() {}` => `const f = () => {}` // `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`. - changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -155970,7 +156758,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 197 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 197 /* SyntaxKind.NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -155979,16 +156767,16 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 185 /* OptionalType */ || unwrappedType.kind === 186 /* RestType */ || unwrappedType.kind === 191 /* ParenthesizedType */) { - if (unwrappedType.kind === 185 /* OptionalType */) { + while (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */ || unwrappedType.kind === 186 /* SyntaxKind.RestType */ || unwrappedType.kind === 191 /* SyntaxKind.ParenthesizedType */) { + if (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 186 /* RestType */) { + else if (unwrappedType.kind === 186 /* SyntaxKind.RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; } - var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined), unwrappedType); + var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined), unwrappedType); if (updated === namedTupleMember) { return; } @@ -156054,18 +156842,18 @@ var ts; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); - if (parent.flags & 32 /* OptionalChain */) { + if (parent.flags & 32 /* NodeFlags.OptionalChain */) { containingType = checker.getNonNullableType(containingType); } suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType); } - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { var receiverType = checker.getTypeAtLocation(parent.right); suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, receiverType); } else if (ts.isQualifiedName(parent) && parent.right === node) { var symbol = checker.getSymbolAtLocation(parent.left); - if (symbol && symbol.flags & 1536 /* Module */) { + if (symbol && symbol.flags & 1536 /* SymbolFlags.Module */) { suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(parent.right, symbol); } } @@ -156083,7 +156871,7 @@ var ts; var props = checker.getContextualTypeForArgumentAtIndex(tag, 0); suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props); } - else if (ts.hasSyntacticModifier(parent, 16384 /* Override */) && ts.isClassElement(parent) && parent.name === node) { + else if (ts.hasSyntacticModifier(parent, 16384 /* ModifierFlags.Override */) && ts.isClassElement(parent) && parent.name === node) { var baseDeclaration = ts.findAncestor(node, ts.isClassLike); var baseTypeNode = baseDeclaration ? ts.getEffectiveBaseTypeNode(baseDeclaration) : undefined; var baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : undefined; @@ -156116,14 +156904,14 @@ var ts; } function convertSemanticMeaningToSymbolFlags(meaning) { var flags = 0; - if (meaning & 4 /* Namespace */) { - flags |= 1920 /* Namespace */; + if (meaning & 4 /* SemanticMeaning.Namespace */) { + flags |= 1920 /* SymbolFlags.Namespace */; } - if (meaning & 2 /* Type */) { - flags |= 788968 /* Type */; + if (meaning & 2 /* SemanticMeaning.Type */) { + flags |= 788968 /* SymbolFlags.Type */; } - if (meaning & 1 /* Value */) { - flags |= 111551 /* Value */; + if (meaning & 1 /* SemanticMeaning.Value */) { + flags |= 111551 /* SymbolFlags.Value */; } return flags; } @@ -156195,7 +156983,7 @@ var ts; }); }, }); function createObjectTypeFromLabeledExpression(checker, label, expression) { - var member = checker.createSymbol(4 /* Property */, label.escapedText); + var member = checker.createSymbol(4 /* SymbolFlags.Property */, label.escapedText); member.type = checker.getTypeAtLocation(expression); var members = ts.createSymbolTable([member]); return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], []); @@ -156254,7 +157042,7 @@ var ts; if (isFunctionType) { var sig = checker.getSignatureFromDeclaration(declaration); if (sig) { - if (ts.hasSyntacticModifier(declaration, 256 /* Async */)) { + if (ts.hasSyntacticModifier(declaration, 256 /* ModifierFlags.Async */)) { exprType = checker.createPromiseType(exprType); } var newSig = checker.createSignature(declaration, sig.typeParameters, sig.thisParameter, sig.parameters, exprType, @@ -156298,19 +157086,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: return declaration.initializer; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 297 /* ShorthandPropertyAssignment */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return undefined; } } @@ -156372,19 +157160,19 @@ var ts; if (!info) { return undefined; } - if (info.kind === 3 /* ObjectLiteral */) { + if (info.kind === 3 /* InfoKind.ObjectLiteral */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); }); return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)]; } - if (info.kind === 4 /* JsxAttributes */) { + if (info.kind === 4 /* InfoKind.JsxAttributes */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); }); return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)]; } - if (info.kind === 2 /* Function */) { + if (info.kind === 2 /* InfoKind.Function */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); }); return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)]; } - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); }); return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; } @@ -156402,20 +157190,20 @@ var ts; if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { return; } - if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) { + if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* InfoKind.Function */) { addFunctionDeclaration(changes, context, info); } - else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) { + else if (fixId === fixMissingProperties && info.kind === 3 /* InfoKind.ObjectLiteral */) { addObjectLiteralProperties(changes, context, info); } - else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) { + else if (fixId === fixMissingAttributes && info.kind === 4 /* InfoKind.JsxAttributes */) { addJsxAttributes(changes, context, info); } else { - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { addEnumMemberDeclaration(changes, checker, info); } - if (info.kind === 0 /* TypeLikeDeclaration */) { + if (info.kind === 0 /* InfoKind.TypeLikeDeclaration */) { var parentDeclaration = info.parentDeclaration, token_1 = info.token; var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; }); if (!infos.some(function (i) { return i.token.text === token_1.text; })) { @@ -156426,7 +157214,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, declaration) { var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker); - var _loop_14 = function (info) { + var _loop_13 = function (info) { // If some superclass added this property, don't add it again. if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -156439,21 +157227,21 @@ var ts; var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, modifierFlags = info.modifierFlags, token = info.token, call = info.call, isJSFile = info.isJSFile; // Always prefer to add a method declaration if possible. if (call && !ts.isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile); + addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* ModifierFlags.Static */, parentDeclaration, declSourceFile); } else { if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration) && !ts.isTypeLiteralNode(parentDeclaration)) { - addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); + addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); } else { var typeNode = getTypeNode(checker, parentDeclaration, token); - addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */); + addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* ModifierFlags.Static */); } } }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_14(info); + _loop_13(info); } }); })); @@ -156474,12 +157262,12 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, tokenPos); var parent = token.parent; if (errorCode === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) { - if (!(token.kind === 18 /* OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) + if (!(token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) return undefined; var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; }); if (argIndex < 0) return undefined; - var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* Call */)); + var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */)); if (!(signature && signature.declaration && signature.parameters[argIndex])) return undefined; var param = signature.parameters[argIndex].valueDeclaration; @@ -156488,7 +157276,7 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; } if (!ts.isMemberName(token)) return undefined; @@ -156496,17 +157284,17 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; } if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) { var target = ts.getEmitScriptTarget(program.getCompilerOptions()); var attributes = getUnmatchedAttributes(checker, target, token.parent); if (!ts.length(attributes)) return undefined; - return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; + return { kind: 4 /* InfoKind.JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; } - if (ts.isIdentifier(token) && ts.isCallExpression(parent)) { - return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile }; + if (ts.isIdentifier(token) && ts.isCallExpression(parent) && parent.expression === token) { + return { kind: 2 /* InfoKind.Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* ModifierFlags.None */, parentDeclaration: sourceFile }; } if (!ts.isPropertyAccessExpression(parent)) return undefined; @@ -156518,13 +157306,13 @@ var ts; var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration); var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile(); if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration }; } var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile); if (sourceFile.commonJsModuleIndicator) return undefined; if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile }; } } var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); @@ -156538,15 +157326,15 @@ var ts; if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration))) return undefined; var declSourceFile = declaration.getSourceFile(); - var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* None */ : - (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */); + var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* ModifierFlags.None */ : + (makeStatic ? 32 /* ModifierFlags.Static */ : 0 /* ModifierFlags.None */) | (ts.startsWithUnderscore(token.text) ? 8 /* ModifierFlags.Private */ : 0 /* ModifierFlags.None */); var isJSFile = ts.isSourceFileJS(declSourceFile); var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; + return { kind: 0 /* InfoKind.TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; } var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) { - return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration }; + return { kind: 1 /* InfoKind.Enum */, token: token, parentDeclaration: enumDeclaration }; } return undefined; } @@ -156562,18 +157350,18 @@ var ts; if (ts.isInterfaceDeclaration(parentDeclaration) || ts.isTypeLiteralNode(parentDeclaration)) { return undefined; } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); }); if (changes.length === 0) { return undefined; } - var diagnostic = modifierFlags & 32 /* Static */ ? ts.Diagnostics.Initialize_static_property_0 : + var diagnostic = modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Initialize_static_property_0 : ts.isPrivateIdentifier(token) ? ts.Diagnostics.Declare_a_private_field_named_0 : ts.Diagnostics.Initialize_property_0_in_the_constructor; return codefix.createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members); } function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 226 /* ClassExpression */) { + if (classDeclaration.kind === 226 /* SyntaxKind.ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -156609,32 +157397,32 @@ var ts; function createActionsForAddMissingMemberInTypeScriptFile(context, _a) { var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token; var memberName = token.text; - var isStatic = modifierFlags & 32 /* Static */; + var isStatic = modifierFlags & 32 /* ModifierFlags.Static */; var typeNode = getTypeNode(context.program.getTypeChecker(), parentDeclaration, token); var addPropertyDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName, typeNode, modifierFlags); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; if (isStatic || ts.isPrivateIdentifier(token)) { return actions; } - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); } actions.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode)); return actions; } function getTypeNode(checker, node, token) { var typeNode; - if (token.parent.parent.kind === 221 /* BinaryExpression */) { + if (token.parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); - typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NoTruncation */); + typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NodeBuilderFlags.NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NodeBuilderFlags.NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) { var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; @@ -156662,7 +157450,7 @@ var ts; } function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "x", @@ -156685,15 +157473,15 @@ var ts; } var methodName = token.text; var addMethodDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, call, token, modifierFlags, parentDeclaration, declSourceFile); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); + var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); } return actions; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var kind = ts.isClassLike(parentDeclaration) ? 169 /* MethodDeclaration */ : 168 /* MethodSignature */; + var kind = ts.isClassLike(parentDeclaration) ? 169 /* SyntaxKind.MethodDeclaration */ : 168 /* SyntaxKind.MethodSignature */; var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression); if (containingMethodDeclaration) { @@ -156713,7 +157501,7 @@ var ts; */ var hasStringInitializer = ts.some(parentDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 402653316 /* StringLike */); + return !!(type && type.flags & 402653316 /* TypeFlags.StringLike */); }); var enumMember = ts.factory.createEnumMember(token, hasStringInitializer ? ts.factory.createStringLiteral(token.text) : undefined); changes.replaceNode(parentDeclaration.getSourceFile(), parentDeclaration, ts.factory.updateEnumDeclaration(parentDeclaration, parentDeclaration.modifiers, parentDeclaration.name, ts.concatenate(parentDeclaration.members, ts.singleElementArray(enumMember))), { @@ -156723,7 +157511,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* SyntaxKind.FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); importAdder.writeFixes(changes); } @@ -156753,7 +157541,7 @@ var ts; var checker = context.program.getTypeChecker(); var props = ts.map(info.properties, function (prop) { var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop), info.parentDeclaration); - return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer); + return ts.factory.createPropertyAssignment(createPropertyNameFromSymbol(prop, target, quotePreference, checker), initializer); }); var options = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, @@ -156764,42 +157552,42 @@ var ts; importAdder.writeFixes(changes); } function tryGetValueFromType(context, checker, importAdder, quotePreference, type, enclosingDeclaration) { - if (type.flags & 3 /* AnyOrUnknown */) { + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return createUndefined(); } - if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { - return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { return ts.factory.createNumericLiteral(0); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { return ts.factory.createBigIntLiteral("0n"); } - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return ts.factory.createFalse(); } - if (type.flags & 1056 /* EnumLike */) { + if (type.flags & 1056 /* TypeFlags.EnumLike */) { var enumMember = type.symbol.exports ? ts.firstOrUndefined(ts.arrayFrom(type.symbol.exports.values())) : type.symbol; - var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); + var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* SymbolFlags.Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); return enumMember === undefined || name === undefined ? ts.factory.createNumericLiteral(0) : ts.factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { return ts.factory.createNumericLiteral(type.value); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } - if (type.flags & 128 /* StringLiteral */) { - return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & 128 /* TypeFlags.StringLiteral */) { + return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { return ts.factory.createNull(); } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t, enclosingDeclaration); }); return expression !== null && expression !== void 0 ? expression : createUndefined(); } @@ -156813,17 +157601,17 @@ var ts; }); return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */) { + if (ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) { var decl = ts.find(type.symbol.declarations || ts.emptyArray, ts.or(ts.isFunctionTypeNode, ts.isMethodSignature, ts.isMethodDeclaration)); if (decl === undefined) return createUndefined(); - var signature = checker.getSignaturesOfType(type, 0 /* Call */); + var signature = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (signature === undefined) return createUndefined(); - var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder); + var func = codefix.createSignatureDeclarationFromSignature(213 /* SyntaxKind.FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder); return func !== null && func !== void 0 ? func : createUndefined(); } - if (ts.getObjectFlags(type) & 1 /* Class */) { + if (ts.getObjectFlags(type) & 1 /* ObjectFlags.Class */) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (classDeclaration === undefined || ts.hasAbstractModifier(classDeclaration)) return createUndefined(); @@ -156838,8 +157626,8 @@ var ts; return ts.factory.createIdentifier("undefined"); } function isObjectLiteralType(type) { - return (type.flags & 524288 /* Object */) && - ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); + return (type.flags & 524288 /* TypeFlags.Object */) && + ((ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); } function getUnmatchedAttributes(checker, target, source) { var attrsType = checker.getContextualType(source.attributes); @@ -156863,7 +157651,7 @@ var ts; } } return ts.filter(targetProps, function (targetProp) { - return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName)); + return ts.isIdentifierText(targetProp.name, target, 1 /* LanguageVariant.JSX */) && !((targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */) || seenNames.has(targetProp.escapedName)); }); } function tryGetContainingMethodDeclaration(node, callExpression) { @@ -156873,6 +157661,15 @@ var ts; var declaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); }); return declaration && declaration.parent === node ? declaration : undefined; } + function createPropertyNameFromSymbol(symbol, target, quotePreference, checker) { + if (ts.isTransientSymbol(symbol) && symbol.nameType && symbol.nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + var expression = checker.symbolToExpression(symbol.nameType.symbol, 111551 /* SymbolFlags.Value */, symbol.valueDeclaration, 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */); + if (expression) { + return ts.factory.createComputedPropertyName(expression); + } + } + return ts.createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === 0 /* QuotePreference.Single */); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -156948,7 +157745,7 @@ var ts; break; } default: - ts.Debug.fail("Bad fixId: " + context.fixId); + ts.Debug.fail("Bad fixId: ".concat(context.fixId)); } }); }, @@ -157023,7 +157820,7 @@ var ts; // See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files // (now named `codeFixClassExtendAbstractPrivateProperty.ts`) var flags = ts.getSyntacticModifierFlags(ts.first(symbol.getDeclarations())); - return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + return !(flags & 8 /* ModifierFlags.Private */) && !!(flags & 128 /* ModifierFlags.Abstract */); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -157066,7 +157863,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 108 /* ThisKeyword */) + if (token.kind !== 108 /* SyntaxKind.ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -157210,7 +158007,7 @@ var ts; codeFixes.push(codefix.createCodeFixActionWithoutFixAll("fixModuleOption", changes, [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0, "esnext"])); } var target = ts.getEmitScriptTarget(compilerOptions); - var targetOutOfRange = target < 4 /* ES2017 */ || target > 99 /* ESNext */; + var targetOutOfRange = target < 4 /* ScriptTarget.ES2017 */ || target > 99 /* ScriptTarget.ESNext */; if (targetOutOfRange) { var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { var configObject = ts.getTsConfigObjectLiteralExpression(configFile); @@ -157289,17 +158086,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* SyntaxKind.ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* SyntaxKind.ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 94 /* ExtendsKeyword */ && - heritageClauses[1].token === 117 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* SyntaxKind.ExtendsKeyword */ && + heritageClauses[1].token === 117 /* SyntaxKind.ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* SyntaxKind.CommaToken */)); // Rough heuristic: delete trailing whitespace after keyword so that it's not excessive. // (Trailing because leading might be indentation, which is more sensitive.) var text = sourceFile.text; @@ -157396,7 +158193,7 @@ var ts; if (!isValidCharacter(character)) { return; } - var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(sourceFile, preferences, character) + "}"; + var replacement = useHtmlEntity ? htmlEntity[character] : "{".concat(ts.quote(sourceFile, preferences, character), "}"); changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -157503,7 +158300,7 @@ var ts; var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start); if (!importDeclaration) return; - var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); + var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); }); var actions; if (namespaceChanges.length) { @@ -157518,7 +158315,7 @@ var ts; }); function getImportDeclaration(sourceFile, program, start) { var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier); - if (!identifier || identifier.parent.kind !== 178 /* TypeReference */) + if (!identifier || identifier.parent.kind !== 178 /* SyntaxKind.TypeReference */) return; var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(identifier); @@ -157530,11 +158327,11 @@ var ts; // new type-only import declaration, but honestly I doubt anyone will ever use this // codefix at all, so it's probably not worth the lines of code. function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) { - if (importDeclaration.kind === 265 /* ImportEqualsDeclaration */) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importDeclaration.name); + if (importDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importDeclaration.name); return; } - var importClause = importDeclaration.kind === 267 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent; + var importClause = importDeclaration.kind === 267 /* SyntaxKind.ImportClause */ ? importDeclaration : importDeclaration.parent.parent; if (importClause.name && importClause.namedBindings) { // Cannot convert an import with a default import and named bindings to type-only // (it's a grammar error). @@ -157542,7 +158339,7 @@ var ts; } var checker = program.getTypeChecker(); var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) { - if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */) + if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* SymbolFlags.Value */) return true; }); if (importsValue) { @@ -157551,7 +158348,7 @@ var ts; // Don't convert it to type-only. return; } - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importClause); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importClause); } function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) { ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent); @@ -157587,7 +158384,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 29 /* LessThanToken */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -157629,7 +158426,7 @@ var ts; ]; } var result = []; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -157671,13 +158468,13 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 137 /* InferKeyword */ || isImport(token)) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 29 /* LessThanToken */) { + else if (token.kind === 29 /* SyntaxKind.LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (ts.isObjectBindingPattern(token.parent)) { @@ -157700,7 +158497,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -157711,7 +158508,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -157720,18 +158517,18 @@ var ts; changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } function isImport(token) { - return token.kind === 100 /* ImportKeyword */ - || token.kind === 79 /* Identifier */ && (token.parent.kind === 270 /* ImportSpecifier */ || token.parent.kind === 267 /* ImportClause */); + return token.kind === 100 /* SyntaxKind.ImportKeyword */ + || token.kind === 79 /* SyntaxKind.Identifier */ && (token.parent.kind === 270 /* SyntaxKind.ImportSpecifier */ || token.parent.kind === 267 /* SyntaxKind.ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 100 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function canDeleteEntireVariableStatement(sourceFile, token) { return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token; } function deleteEntireVariableStatement(changes, sourceFile, node) { - changes.delete(sourceFile, node.parent.kind === 237 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -157740,15 +158537,15 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { - changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_" + token.text)); + changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_".concat(token.text))); if (ts.isParameter(token.parent)) { ts.getJSDocParameterTags(token.parent).forEach(function (tag) { if (ts.isIdentifier(tag.name)) { - changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_" + tag.name.text)); + changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_".concat(tag.name.text))); } }); } @@ -157756,14 +158553,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return true; } } @@ -157818,8 +158615,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: var index = parent.parameters.indexOf(parameter); var referent = ts.isMethodDeclaration(parent) ? parent.name : parent; var entries = ts.FindAllReferences.Core.getReferencedSymbolsForNode(parent.pos, referent, program, sourceFiles, cancellationToken); @@ -157828,7 +158625,7 @@ var ts; var entry = entries_2[_i]; for (var _a = 0, _b = entry.references; _a < _b.length; _a++) { var reference = _b[_a]; - if (reference.kind === 1 /* Node */) { + if (reference.kind === 1 /* FindAllReferences.EntryKind.Node */) { // argument in super(...) var isSuperCall_1 = ts.isSuperKeyword(reference.node) && ts.isCallExpression(reference.node.parent) @@ -157849,20 +158646,20 @@ var ts; } } return true; - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. return isLastParameter(parent, parameter, isFixAll); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Setter must have a parameter return false; - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Getter cannot have parameters return true; default: @@ -157923,7 +158720,7 @@ var ts; var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -157934,8 +158731,8 @@ var ts; return; } // falls through - case 241 /* WhileStatement */: - case 242 /* ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: changes.delete(sourceFile, container); return; } @@ -157984,7 +158781,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* SyntaxKind.ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -158008,10 +158805,10 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 314 /* JSDocNullableType */) { + if (typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` - actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* TypeFlags.Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -158028,7 +158825,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* TypeFlags.Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -158045,22 +158842,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 229 /* AsExpression */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: - case 172 /* GetAccessor */: - case 176 /* IndexSignature */: - case 195 /* MappedType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 211 /* TypeAssertionExpression */: - case 254 /* VariableDeclaration */: + case 229 /* SyntaxKind.AsExpression */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 176 /* SyntaxKind.IndexSignature */: + case 195 /* SyntaxKind.MappedType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; default: return false; @@ -158095,7 +158892,7 @@ var ts; }); } }); function doChange(changes, sourceFile, name) { - changes.replaceNodeWithText(sourceFile, name, name.text + "()"); + changes.replaceNodeWithText(sourceFile, name, "".concat(name.text, "()")); } function getCallName(sourceFile, start) { var token = ts.getTokenAtPosition(sourceFile, start); @@ -158163,15 +158960,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: insertBefore = containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* SyntaxKind.FunctionKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */; + case 214 /* SyntaxKind.ArrowFunction */: + var kind = containingFunction.typeParameters ? 29 /* SyntaxKind.LessThanToken */ : 20 /* SyntaxKind.OpenParenToken */; insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -158186,11 +158983,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* SyntaxKind.Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 131 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 131 /* SyntaxKind.AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -158352,7 +159149,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* SyntaxKind.Identifier */ && token.kind !== 25 /* SyntaxKind.DotDotDotToken */ && token.kind !== 108 /* SyntaxKind.ThisKeyword */) { return undefined; } var parent = token.parent; @@ -158453,9 +159250,9 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { - var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { @@ -158463,7 +159260,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { @@ -158506,7 +159303,7 @@ var ts; function annotate(changes, importAdder, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* SyntaxKind.PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -158542,7 +159339,7 @@ var ts; var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host); if (typeNode) { var name = ts.factory.cloneNode(param.name); - ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(name, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); return { name: ts.factory.cloneNode(param.name), param: param, isOptional: !!inference.isOptional, typeNode: typeNode }; } }); @@ -158550,9 +159347,9 @@ var ts; return; } if (ts.isArrowFunction(signature) || ts.isFunctionExpression(signature)) { - var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) { - changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); } ts.forEach(inferences, function (_a) { var typeNode = _a.typeNode, param = _a.param; @@ -158561,7 +159358,7 @@ var ts; changes.insertNodeAt(sourceFile, param.getStart(sourceFile), jsDoc, { suffix: " " }); }); if (needParens) { - changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } else { @@ -158575,7 +159372,7 @@ var ts; function getReferences(token, program, cancellationToken) { // Position shouldn't matter since token is not a SourceFile. return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) { - return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; + return entry.kind !== 0 /* FindAllReferences.EntryKind.Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; }); } function inferTypeForVariableFromUsage(token, program, cancellationToken) { @@ -158593,19 +159390,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 171 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 134 /* ConstructorKeyword */, sourceFile); + case 171 /* SyntaxKind.Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: searchToken = containingFunction.name; break; } @@ -158747,24 +159544,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: usage.isNumber = true; break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -158772,20 +159569,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -158809,13 +159606,13 @@ var ts; } function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: usage.isNumber = true; break; - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: @@ -158825,65 +159622,65 @@ var ts; function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: // MultiplicativeOperator // falls through - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: // ShiftOperator // falls through - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator // falls through - case 50 /* AmpersandToken */: - case 51 /* BarToken */: - case 52 /* CaretToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 51 /* SyntaxKind.BarToken */: + case 52 /* SyntaxKind.CaretToken */: // CompoundAssignmentOperator // falls through - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 74 /* BarEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: // AdditiveOperator // falls through - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: // RelationalOperator // falls through - case 29 /* LessThanToken */: - case 32 /* LessThanEqualsToken */: - case 31 /* GreaterThanToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 1056 /* EnumLike */) { + if (operandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, operandType); } else { usage.isNumber = true; } break; - case 64 /* PlusEqualsToken */: - case 39 /* PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 1056 /* EnumLike */) { + if (otherOperandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, otherOperandType); } - else if (otherOperandType.flags & 296 /* NumberLike */) { + else if (otherOperandType.flags & 296 /* TypeFlags.NumberLike */) { usage.isNumber = true; } - else if (otherOperandType.flags & 402653316 /* StringLike */) { + else if (otherOperandType.flags & 402653316 /* TypeFlags.StringLike */) { usage.isString = true; } - else if (otherOperandType.flags & 1 /* Any */) { + else if (otherOperandType.flags & 1 /* TypeFlags.Any */) { // do nothing, maybe we'll learn something elsewhere } else { @@ -158891,31 +159688,31 @@ var ts; } break; // AssignmentOperators - case 63 /* EqualsToken */: - case 34 /* EqualsEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (node === parent.left) { usage.isString = true; } break; // LogicalOperator Or NullishCoalescing - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 254 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: - case 102 /* InstanceOfKeyword */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: // nothing to infer here break; } @@ -158935,7 +159732,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 208 /* CallExpression */) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -158960,7 +159757,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent.argumentExpression); var indexUsage = createEmptyUsage(); calculateUsageOfNode(parent, indexUsage); - if (indexType.flags & 296 /* NumberLike */) { + if (indexType.flags & 296 /* TypeFlags.NumberLike */) { usage.numberIndex = indexUsage; } else { @@ -159007,21 +159804,21 @@ var ts; low: function (t) { return t === stringNumber; } }, { - high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); }, - low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); } + high: function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); }, + low: function (t) { return !!(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); } }, { - high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); }, - low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); } + high: function (t) { return !(t.flags & (98304 /* TypeFlags.Nullable */ | 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) && !(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); }, + low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); } } ]; var good = removeLowPriorityInferences(inferences, priorities); - var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; }); + var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */; }); if (anons.length) { - good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); }); + good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */); }); good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* UnionReduction.Subtype */)); } function combineAnonymousTypes(anons) { if (anons.length === 1) { @@ -159040,22 +159837,22 @@ var ts; var p = _b[_a]; props.add(p.name, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType()); } - calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); - constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); - var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* String */); + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* SignatureKind.Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* SignatureKind.Construct */)); + var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* IndexKind.String */); if (stringIndexInfo) { stringIndices.push(stringIndexInfo.type); stringIndexReadonly = stringIndexReadonly || stringIndexInfo.isReadonly; } - var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* Number */); + var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* IndexKind.Number */); if (numberIndexInfo) { numberIndices.push(numberIndexInfo.type); numberIndexReadonly = numberIndexReadonly || numberIndexInfo.isReadonly; } } var members = ts.mapEntries(props, function (name, types) { - var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0; - var s = checker.createSymbol(4 /* Property */ | isOptional, name); + var isOptional = types.length < anons.length ? 16777216 /* SymbolFlags.Optional */ : 0; + var s = checker.createSymbol(4 /* SymbolFlags.Property */ | isOptional, name); s.type = checker.getUnionType(types); return [name, s]; }); @@ -159087,7 +159884,7 @@ var ts; var candidateTypes = (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); }); var callsType = ((_c = usage.calls) === null || _c === void 0 ? void 0 : _c.length) ? inferStructuralType(usage) : undefined; if (callsType && candidateTypes) { - types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* Subtype */)); + types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* UnionReduction.Subtype */)); } else { if (callsType) { @@ -159104,7 +159901,7 @@ var ts; var members = new ts.Map(); if (usage.properties) { usage.properties.forEach(function (u, name) { - var symbol = checker.createSymbol(4 /* Property */, name); + var symbol = checker.createSymbol(4 /* SymbolFlags.Property */, name); symbol.type = combineFromUsage(u); members.set(name, symbol); }); @@ -159132,7 +159929,7 @@ var ts; return true; } if (propUsage.calls) { - var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + var sigs = checker.getSignaturesOfType(source, 0 /* SignatureKind.Call */); return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); } else { @@ -159146,7 +159943,7 @@ var ts; * 2. inference to/from calls with a single signature */ function inferInstantiationFromUsage(type, usage) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !usage.properties) { return type; } var generic = type.target; @@ -159165,10 +159962,10 @@ var ts; if (genericType === typeParameter) { return [usageType]; } - else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + else if (genericType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); } - else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + else if (ts.getObjectFlags(genericType) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(usageType) & 4 /* ObjectFlags.Reference */) { // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference var genericArgs = checker.getTypeArguments(genericType); var usageArgs = checker.getTypeArguments(usageType); @@ -159182,8 +159979,8 @@ var ts; } return types; } - var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); - var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* SignatureKind.Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* SignatureKind.Call */); if (genericSigs.length === 1 && usageSigs.length === 1) { return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } @@ -159218,27 +160015,27 @@ var ts; function getSignatureFromCalls(calls) { var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); - var _loop_15 = function (i) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + var _loop_14 = function (i) { + var symbol = checker.createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg".concat(i))); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { - symbol.flags |= 16777216 /* Optional */; + symbol.flags |= 16777216 /* SymbolFlags.Optional */; } parameters.push(symbol); }; for (var i = 0; i < length; i++) { - _loop_15(i); + _loop_14(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* SignatureFlags.None */); } function addCandidateType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } function addCandidateThisType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } @@ -159322,7 +160119,7 @@ var ts; codefix.createCodeFixActionWithoutFixAll(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [ ts.createTextChange(sourceFile.checkJsDirective ? ts.createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end) - : ts.createTextSpan(0, 0), "// @ts-nocheck" + newLineCharacter), + : ts.createTextSpan(0, 0), "// @ts-nocheck".concat(newLineCharacter)), ])], ts.Diagnostics.Disable_checking_for_this_file), ]; if (ts.textChanges.isValidLocationToAddComment(sourceFile, span.start)) { @@ -159389,7 +160186,7 @@ var ts; * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub. */ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) { - if (preserveOptional === void 0) { preserveOptional = 3 /* All */; } + if (preserveOptional === void 0) { preserveOptional = 3 /* PreserveOptionalFlags.All */; } if (isAmbient === void 0) { isAmbient = false; } var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { @@ -159402,13 +160199,13 @@ var ts; var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration)); var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); - var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient; + var optional = !!(symbol.flags & 16777216 /* SymbolFlags.Optional */); + var ambient = !!(enclosingDeclaration.flags & 16777216 /* NodeFlags.Ambient */) || isAmbient; var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + var flags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { var importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); @@ -159417,11 +160214,11 @@ var ts; importSymbols(importAdder, importableReference.symbols); } } - addClassElement(ts.factory.createPropertyDeclaration(modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, + addClassElement(ts.factory.createPropertyDeclaration(modifiers, name, optional && (preserveOptional & 2 /* PreserveOptionalFlags.Property */) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -159448,8 +160245,8 @@ var ts; } break; } - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -159457,7 +160254,7 @@ var ts; // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures(); if (!ts.some(signatures)) { break; } @@ -159479,13 +160276,13 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), modifiers, quotePreference, body)); } } break; } function outputMethod(quotePreference, signature, modifiers, name, body) { - var method = createSignatureDeclarationFromSignature(169 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder); + var method = createSignatureDeclarationFromSignature(169 /* SyntaxKind.MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), enclosingDeclaration, importAdder); if (method) addClassElement(method); } @@ -159495,10 +160292,10 @@ var ts; var program = context.program; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); - var flags = 1 /* NoTruncation */ - | 256 /* SuppressAnyReturnType */ - | 524288 /* AllowEmptyTuple */ - | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */); + var flags = 1 /* NodeBuilderFlags.NoTruncation */ + | 256 /* NodeBuilderFlags.SuppressAnyReturnType */ + | 524288 /* NodeBuilderFlags.AllowEmptyTuple */ + | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; @@ -159551,7 +160348,7 @@ var ts; } } } - var questionToken = optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var questionToken = optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var asteriskToken = signatureDeclaration.asteriskToken; if (ts.isFunctionExpression(signatureDeclaration)) { return ts.factory.updateFunctionExpression(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body); @@ -159576,38 +160373,50 @@ var ts; var names = ts.map(args, function (arg) { return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined; }); - var types = isJs ? [] : ts.map(args, function (arg) { - return typeToAutoImportableTypeNode(checker, importAdder, checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, scriptTarget, /*flags*/ undefined, tracker); - }); + var instanceTypes = isJs ? [] : ts.map(args, function (arg) { return checker.getTypeAtLocation(arg); }); + var _a = getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker), argumentTypeNodes = _a.argumentTypeNodes, argumentTypeParameters = _a.argumentTypeParameters; var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; var asteriskToken = ts.isYieldExpression(parent) - ? ts.factory.createToken(41 /* AsteriskToken */) + ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined; - var typeParameters = isJs || typeArguments === undefined - ? undefined - : ts.map(typeArguments, function (_, i) { - return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); - }); - var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs); + var typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments); + var parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs); var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); switch (kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createMethodDeclaration(modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return ts.factory.createMethodSignature(modifiers, name, - /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */) : type); - case 256 /* FunctionDeclaration */: + /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */) : type); + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference)); default: ts.Debug.fail("Unexpected kind"); } } codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression; + function createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments) { + var usedNames = new ts.Set(argumentTypeParameters.map(function (pair) { return pair[0]; })); + var constraintsByName = new ts.Map(argumentTypeParameters); + if (typeArguments) { + var typeArgumentsWithNewTypes = typeArguments.filter(function (typeArgument) { return !argumentTypeParameters.some(function (pair) { var _a; return checker.getTypeAtLocation(typeArgument) === ((_a = pair[1]) === null || _a === void 0 ? void 0 : _a.argumentType); }); }); + var targetSize = usedNames.size + typeArgumentsWithNewTypes.length; + for (var i = 0; usedNames.size < targetSize; i += 1) { + usedNames.add(createTypeParameterName(i)); + } + } + return ts.map(ts.arrayFrom(usedNames.values()), function (usedName) { var _a; return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, usedName, (_a = constraintsByName.get(usedName)) === null || _a === void 0 ? void 0 : _a.constraint); }); + } + function createTypeParameterName(index) { + return 84 /* CharacterCodes.T */ + index <= 90 /* CharacterCodes.Z */ + ? String.fromCharCode(84 /* CharacterCodes.T */ + index) + : "T".concat(index); + } function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) { var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker); if (typeNode && ts.isImportTypeNode(typeNode)) { @@ -159621,15 +160430,107 @@ var ts; return ts.getSynthesizedDeepClone(typeNode); } codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode; + function typeContainsTypeParameter(type) { + if (type.isUnionOrIntersection()) { + return type.types.some(typeContainsTypeParameter); + } + return type.flags & 262144 /* TypeFlags.TypeParameter */; + } + function getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, flags, tracker) { + // Types to be used as the types of the parameters in the new function + // E.g. from this source: + // added("", 0) + // The value will look like: + // [{ typeName: { text: "string" } }, { typeName: { text: "number" }] + // And in the output function will generate: + // function added(a: string, b: number) { ... } + var argumentTypeNodes = []; + // Names of type parameters provided as arguments to the call + // E.g. from this source: + // added(value); + // The value will look like: + // [ + // ["T", { argumentType: { typeName: { text: "T" } } } ], + // ["U", { argumentType: { typeName: { text: "U" } } } ], + // ] + // And in the output function will generate: + // function added() { ... } + var argumentTypeParameters = new ts.Map(); + for (var i = 0; i < instanceTypes.length; i += 1) { + var instanceType = instanceTypes[i]; + // If the instance type contains a deep reference to an existing type parameter, + // instead of copying the full union or intersection, create a new type parameter + // E.g. from this source: + // function existing(value: T | U & string) { + // added/*1*/(value); + // We don't want to output this: + // function added(value: T | U & string) { ... } + // We instead want to output: + // function added(value: T) { ... } + if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) { + var synthesizedTypeParameterName = createTypeParameterName(i); + argumentTypeNodes.push(ts.factory.createTypeReferenceNode(synthesizedTypeParameterName)); + argumentTypeParameters.set(synthesizedTypeParameterName, undefined); + continue; + } + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + var widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType); + var argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker); + if (!argumentTypeNode) { + continue; + } + argumentTypeNodes.push(argumentTypeNode); + var argumentTypeParameter = getFirstTypeParameterName(instanceType); + // If the instance type is a type parameter with a constraint (other than an anonymous object), + // remember that constraint for when we create the new type parameter + // E.g. from this source: + // function existing(value: T) { + // added/*1*/(value); + // We don't want to output this: + // function added(value: T) { ... } + // We instead want to output: + // function added(value: T) { ... } + var instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint) + ? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker) + : undefined; + if (argumentTypeParameter) { + argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint }); + } + } + return { argumentTypeNodes: argumentTypeNodes, argumentTypeParameters: ts.arrayFrom(argumentTypeParameters.entries()) }; + } + codefix.getArgumentTypesAndTypeParameters = getArgumentTypesAndTypeParameters; + function isAnonymousObjectConstraintType(type) { + return (type.flags & 524288 /* TypeFlags.Object */) && type.objectFlags === 16 /* ObjectFlags.Anonymous */; + } + function getFirstTypeParameterName(type) { + var _a; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + for (var _i = 0, _b = type.types; _i < _b.length; _i++) { + var subType = _b[_i]; + var subTypeName = getFirstTypeParameterName(subType); + if (subTypeName) { + return subTypeName; + } + } + } + return type.flags & 262144 /* TypeFlags.TypeParameter */ + ? (_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName() + : undefined; + } function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { var parameters = []; + var parameterNameCounts = new ts.Map(); for (var i = 0; i < argCount; i++) { + var parameterName = (names === null || names === void 0 ? void 0 : names[i]) || "arg".concat(i); + var parameterNameCount = parameterNameCounts.get(parameterName); + parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1); var newParameter = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, - /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), + /*name*/ parameterName + (parameterNameCount || ""), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, + /*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -159658,8 +160559,8 @@ var ts; var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { var restParameter = ts.factory.createParameterDeclaration( - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)), + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)), /*initializer*/ undefined); parameters.push(restParameter); } @@ -159674,7 +160575,7 @@ var ts; } function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) { return ts.factory.createMethodDeclaration(modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); + /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); } function createStubbedMethodBody(quotePreference) { return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference); @@ -159683,16 +160584,16 @@ var ts; return ts.factory.createBlock([ts.factory.createThrowStatement(ts.factory.createNewExpression(ts.factory.createIdentifier("Error"), /*typeArguments*/ undefined, // TODO Handle auto quote preference. - [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* Single */)]))], + [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* QuotePreference.Single */)]))], /*multiline*/ true); } codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { - if (flags & 4 /* Public */) { - return ts.factory.createToken(123 /* PublicKeyword */); + if (flags & 4 /* ModifierFlags.Public */) { + return ts.factory.createToken(123 /* SyntaxKind.PublicKeyword */); } - else if (flags & 16 /* Protected */) { - return ts.factory.createToken(122 /* ProtectedKeyword */); + else if (flags & 16 /* ModifierFlags.Protected */) { + return ts.factory.createToken(122 /* SyntaxKind.ProtectedKeyword */); } return undefined; } @@ -159765,7 +160666,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -159841,17 +160742,17 @@ var ts; return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } function prepareModifierFlagsForAccessor(modifierFlags) { - modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor - modifierFlags &= ~8 /* Private */; - if (!(modifierFlags & 16 /* Protected */)) { - modifierFlags |= 4 /* Public */; + modifierFlags &= ~64 /* ModifierFlags.Readonly */; // avoid Readonly modifier because it will convert to get accessor + modifierFlags &= ~8 /* ModifierFlags.Private */; + if (!(modifierFlags & 16 /* ModifierFlags.Protected */)) { + modifierFlags |= 4 /* ModifierFlags.Public */; } return modifierFlags; } function prepareModifierFlagsForField(modifierFlags) { - modifierFlags &= ~4 /* Public */; - modifierFlags &= ~16 /* Protected */; - modifierFlags |= 8 /* Private */; + modifierFlags &= ~4 /* ModifierFlags.Public */; + modifierFlags &= ~16 /* ModifierFlags.Protected */; + modifierFlags |= 8 /* ModifierFlags.Private */; return modifierFlags; } function getAccessorConvertiblePropertyAtPosition(file, program, start, end, considerEmptySpans) { @@ -159860,7 +160761,7 @@ var ts; var cursorRequest = start === end && considerEmptySpans; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier - var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; + var meaning = 28 /* ModifierFlags.AccessibilityModifier */ | 32 /* ModifierFlags.Static */ | 64 /* ModifierFlags.Readonly */; if (!declaration || (!(ts.nodeOverlapsWithStartEnd(declaration.name, file, start, end) || cursorRequest))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_property_for_which_to_generate_accessor) @@ -159871,20 +160772,20 @@ var ts; error: ts.getLocaleSpecificMessage(ts.Diagnostics.Name_is_not_valid) }; } - if (((ts.getEffectiveModifierFlags(declaration) & 125951 /* Modifier */) | meaning) !== meaning) { + if (((ts.getEffectiveModifierFlags(declaration) & 125951 /* ModifierFlags.Modifier */) | meaning) !== meaning) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_property_with_modifier) }; } var name = declaration.name.text; var startWithUnderscore = ts.startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_".concat(name), file), declaration.name); var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 164 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 164 /* SyntaxKind.Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -159937,13 +160838,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 108 /* ThisKeyword */ && + node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.factory.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -159958,7 +160859,7 @@ var ts; var type = typeChecker.getTypeFromTypeNode(typeNode); if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) { var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode]; - return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)], false)); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)], false)); } } return typeNode; @@ -159970,7 +160871,7 @@ var ts; var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); if (!superSymbol) break; - var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; + var symbol = superSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; @@ -160016,7 +160917,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* CallExpression */ : 209 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* SyntaxKind.CallExpression */ : 209 /* SyntaxKind.NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -160134,7 +161035,7 @@ var ts; } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { ts.suppressLeadingAndTrailingTrivia(propertyDeclaration); - var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* SyntaxKind.ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, info) { @@ -160142,7 +161043,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, sourceFile, info) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode]; var unionTypeNode = ts.factory.createUnionTypeNode(types); if (info.isJs) { @@ -160171,7 +161072,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } else if (type.isStringLiteral()) { @@ -160180,7 +161081,7 @@ var ts; else if (type.isNumberLiteral()) { return ts.factory.createNumericLiteral(type.value); } - else if (type.flags & 2048 /* BigIntLiteral */) { + else if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } else if (type.isUnion()) { @@ -160188,7 +161089,7 @@ var ts; } else if (type.isClass()) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); - if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* Abstract */)) + if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* ModifierFlags.Abstract */)) return undefined; var constructorDeclaration = ts.getFirstConstructorWithBody(classDeclaration); if (constructorDeclaration && constructorDeclaration.parameters.length) @@ -160364,8 +161265,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 200 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* SyntaxKind.ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 200 /* SyntaxKind.ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -160428,7 +161329,7 @@ var ts; var children = []; var current = node; while (true) { - if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { children.push(current.left); if (ts.isJsxChild(current.right)) { children.push(current.right); @@ -160494,7 +161395,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type, /*members*/ undefined); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [ @@ -160552,7 +161453,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* SyntaxKind.AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -160563,7 +161464,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* SyntaxKind.NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -160634,7 +161535,7 @@ var ts; var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.parent, ts.isVariableDeclarationList); if (declaration === undefined) return; - var constToken = ts.findChildOfKind(declaration, 85 /* ConstKeyword */, sourceFile); + var constToken = ts.findChildOfKind(declaration, 85 /* SyntaxKind.ConstKeyword */, sourceFile); if (constToken === undefined) return; return ts.createRange(constToken.pos, constToken.end); @@ -160671,14 +161572,14 @@ var ts; }); function getInfo(sourceFile, pos, _) { var node = ts.getTokenAtPosition(sourceFile, pos); - return (node.kind === 26 /* SemicolonToken */ && + return (node.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent && (ts.isObjectLiteralExpression(node.parent) || ts.isArrayLiteralExpression(node.parent))) ? { node: node } : undefined; } function doChange(changes, sourceFile, _a) { var node = _a.node; - var newNode = ts.factory.createToken(27 /* CommaToken */); + var newNode = ts.factory.createToken(27 /* SyntaxKind.CommaToken */); changes.replaceNode(sourceFile, node, newNode); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -160726,7 +161627,7 @@ var ts; // append ` | void` to type argument var typeArgument = typeArguments[0]; var needsParens = !ts.isUnionTypeNode(typeArgument) && !ts.isParenthesizedTypeNode(typeArgument) && - ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -160738,14 +161639,14 @@ var ts; var parameter = signature === null || signature === void 0 ? void 0 : signature.parameters[0]; var parameterType = parameter && checker.getTypeOfSymbolAtLocation(parameter, decl.parent.parent); if (ts.isInJSFile(decl)) { - if (!parameterType || parameterType.flags & 3 /* AnyOrUnknown */) { + if (!parameterType || parameterType.flags & 3 /* TypeFlags.AnyOrUnknown */) { // give the expression a type changes.insertText(sourceFile, decl.parent.parent.end, ")"); changes.insertText(sourceFile, ts.skipTrivia(sourceFile.text, decl.parent.parent.pos), "/** @type {Promise} */("); } } else { - if (!parameterType || parameterType.flags & 2 /* Unknown */) { + if (!parameterType || parameterType.flags & 2 /* TypeFlags.Unknown */) { // add `void` type argument changes.insertText(sourceFile, decl.parent.parent.expression.end, ""); } @@ -160821,16 +161722,16 @@ var ts; var file = context.file, program = context.program; var span = ts.getRefactorContextSpan(context); var token = ts.getTokenAtPosition(file, span.start); - var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); + var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* ModifierFlags.Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var checker = program.getTypeChecker(); var exportingModuleSymbol = getExportingModuleSymbol(exportNode, checker); - var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); - var wasDefault = !!(flags & 512 /* Default */); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ModifierFlags.ExportDefault */ : 0 /* ModifierFlags.None */); + var wasDefault = !!(flags & 512 /* ModifierFlags.Default */); // If source file already has a default export, don't offer refactor. - if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + if (!(flags & 1 /* ModifierFlags.Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* InternalSymbolName.Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } var noSymbolError = function (id) { @@ -160838,22 +161739,22 @@ var ts; : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; }; switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: { var node = exportNode; if (!node.name) return undefined; return noSymbolError(node.name) || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. - if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { + if (!(vs.declarationList.flags & 2 /* NodeFlags.Const */) || vs.declarationList.declarations.length !== 1) { return undefined; } var decl = ts.first(vs.declarationList.declarations); @@ -160863,7 +161764,7 @@ var ts; return noSymbolError(decl.name) || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var node = exportNode; if (node.isExportEquals) return undefined; @@ -160887,18 +161788,18 @@ var ts; changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports([spec]))); } else { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* SyntaxKind.DefaultKeyword */), "Should find a default keyword in modifier list")); } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* SyntaxKind.ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* SyntaxKind.DefaultKeyword */)); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;` var decl = ts.first(exportNode.declarationList.declarations); if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) { @@ -160907,15 +161808,15 @@ var ts; break; } // falls through - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text))); break; default: - ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind ".concat(exportNode.kind)); } } } @@ -160938,18 +161839,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 267 /* ImportClause */: { + case 267 /* SyntaxKind.ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -160958,10 +161859,10 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 268 /* NamespaceImport */) { + else if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); - var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* QuotePreference.Double */; var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } @@ -160972,7 +161873,7 @@ var ts; } break; } - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: var importTypeNode = parent; changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, importTypeNode.assertions, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf)); break; @@ -160983,11 +161884,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 270 /* ImportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.factory.createIdentifier(parent.name.text); @@ -161000,7 +161901,7 @@ var ts; } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -161009,7 +161910,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); + ts.Debug.assertNever(parent, "Unexpected parent kind ".concat(parent.kind)); } } function makeImportSpecifier(propertyName, name) { @@ -161039,17 +161940,17 @@ var ts; var _a; var refactorName = "Convert import"; var actions = (_a = {}, - _a[0 /* Named */] = { + _a[0 /* ImportKind.Named */] = { name: "Convert namespace import to named imports", description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message, kind: "refactor.rewrite.import.named", }, - _a[2 /* Namespace */] = { + _a[2 /* ImportKind.Namespace */] = { name: "Convert named imports to namespace import", description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message, kind: "refactor.rewrite.import.namespace", }, - _a[1 /* Default */] = { + _a[1 /* ImportKind.Default */] = { name: "Convert named imports to default import", description: ts.Diagnostics.Convert_named_imports_to_default_import.message, kind: "refactor.rewrite.import.default", @@ -161101,13 +162002,13 @@ var ts; if (!importClause.namedBindings) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) }; } - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { - return { convertTo: 0 /* Named */, import: importClause.namedBindings }; + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { + return { convertTo: 0 /* ImportKind.Named */, import: importClause.namedBindings }; } var shouldUseDefault = getShouldUseDefault(context.program, importClause); return shouldUseDefault - ? { convertTo: 1 /* Default */, import: importClause.namedBindings } - : { convertTo: 2 /* Namespace */, import: importClause.namedBindings }; + ? { convertTo: 1 /* ImportKind.Default */, import: importClause.namedBindings } + : { convertTo: 2 /* ImportKind.Namespace */, import: importClause.namedBindings }; } function getShouldUseDefault(program, importClause) { return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()) @@ -161115,11 +162016,11 @@ var ts; } function doChange(sourceFile, program, changes, info) { var checker = program.getTypeChecker(); - if (info.convertTo === 0 /* Named */) { + if (info.convertTo === 0 /* ImportKind.Named */) { doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { - doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */); + doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* ImportKind.Default */); } } function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { @@ -161132,7 +162033,7 @@ var ts; } else { var exportName = getRightOfPropertyAccessOrQualifiedName(id.parent).text; - if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + if (checker.resolveName(exportName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } ts.Debug.assert(getLeftOfPropertyAccessOrQualifiedName(id.parent) === id, "Parent expression should match id"); @@ -161181,14 +162082,14 @@ var ts; toConvertSymbols.add(symbol); } }); - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ESNext */) : "module"; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ScriptTarget.ESNext */) : "module"; function hasNamespaceNameConflict(namedImport) { // We need to check if the preferred namespace name (`preferredName`) we'd like to use in the refactored code will present a name conflict. // A name conflict means that, in a scope where we would like to use the preferred namespace name, there already exists a symbol with that name in that scope. // We are going to use the namespace name in the scopes the named imports being refactored are referenced, // so we look for conflicts by looking at every reference to those named imports. return !!ts.FindAllReferences.Core.eachSymbolReferenceInFile(namedImport.name, checker, sourceFile, function (id) { - var symbol = checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(preferredName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (symbol) { // There already is a symbol with the same name as the preferred namespace name. if (toConvertSymbols.has(symbol)) { // `preferredName` resolves to a symbol for one of the named import references we are going to transform into namespace import references... return ts.isExportSpecifier(id.parent); // ...but if this reference is an export specifier, it will not be transformed, so it is a conflict; otherwise, it will be renamed and is not a conflict. @@ -161203,7 +162104,7 @@ var ts; // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics. // More specifically, those are named imports that appear in named exports in the original code, e.g. `a` in `import { a } from "m"; export { a }`. var neededNamedImports = new ts.Set(); - var _loop_16 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName); @@ -161220,7 +162121,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_16(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, shouldUseDefault ? ts.factory.createIdentifier(namespaceImportName) @@ -161337,7 +162238,7 @@ var ts; } } function getBinaryInfo(expression) { - if (expression.operatorToken.kind !== 55 /* AmpersandAmpersandToken */) { + if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) }; } ; @@ -161353,7 +162254,7 @@ var ts; */ function getOccurrencesInExpression(matchTo, expression) { var occurrences = []; - while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var match = getMatchingStart(ts.skipParentheses(matchTo), ts.skipParentheses(expression.right)); if (!match) { break; @@ -161479,17 +162380,17 @@ var ts; occurrences.pop(); if (ts.isCallExpression(toConvert)) { return isOccurrence ? - ts.factory.createCallChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : + ts.factory.createCallChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : ts.factory.createCallChain(chain, toConvert.questionDotToken, toConvert.typeArguments, toConvert.arguments); } else if (ts.isPropertyAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.name) : + ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.name) : ts.factory.createPropertyAccessChain(chain, toConvert.questionDotToken, toConvert.name); } else if (ts.isElementAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.argumentExpression) : + ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.argumentExpression) : ts.factory.createElementAccessChain(chain, toConvert.questionDotToken, toConvert.argumentExpression); } } @@ -161504,7 +162405,7 @@ var ts; changes.replaceNodeRange(sourceFile, firstOccurrence, finalExpression, convertedChain); } else if (ts.isConditionalExpression(expression)) { - changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* QuestionQuestionToken */), expression.whenFalse)); + changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* SyntaxKind.QuestionQuestionToken */), expression.whenFalse)); } } } @@ -161550,27 +162451,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 175 /* ConstructSignature */: { + case 175 /* SyntaxKind.ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -161591,24 +162492,24 @@ var ts; } return ts.factory.createNodeArray([ ts.factory.createParameterDeclaration( - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), "args", + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), "args", /*questionToken*/ undefined, ts.factory.createUnionTypeNode(ts.map(signatureDeclarations, convertSignatureParametersToTuple))) ]); } function convertSignatureParametersToTuple(decl) { var members = ts.map(decl.parameters, convertParameterToNamedTupleMember); - return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* None */ : 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* EmitFlags.None */ : 1 /* EmitFlags.SingleLine */); } function convertParameterToNamedTupleMember(p) { ts.Debug.assert(ts.isIdentifier(p.name)); // This is checked during refactoring applicability checking - var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); if (newComment.length) { ts.setSyntheticLeadingComments(result, [{ - text: "*\n" + newComment.split("\n").map(function (c) { return " * " + c; }).join("\n") + "\n ", - kind: 3 /* MultiLineCommentTrivia */, + text: "*\n".concat(newComment.split("\n").map(function (c) { return " * ".concat(c); }).join("\n"), "\n "), + kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, pos: -1, end: -1, hasTrailingNewLine: true, @@ -161621,12 +162522,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: return true; } return false; @@ -161637,6 +162538,9 @@ var ts; if (!containingDecl) { return; } + if (ts.isFunctionLikeDeclaration(containingDecl) && containingDecl.body && ts.rangeContainsPosition(containingDecl.body, startPosition)) { + return; + } var checker = program.getTypeChecker(); var signatureSymbol = containingDecl.symbol; if (!signatureSymbol) { @@ -161752,7 +162656,7 @@ var ts; usedFunctionNames.set(description, true); functionActions.push({ description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), kind: extractFunctionAction.kind }); } @@ -161760,7 +162664,7 @@ var ts; else if (!innermostErrorFunctionAction) { innermostErrorFunctionAction = { description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), notApplicableReason: getStringError(functionExtraction.errors), kind: extractFunctionAction.kind }; @@ -161776,7 +162680,7 @@ var ts; usedConstantNames.set(description_1, true); constantActions.push({ description: description_1, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), kind: extractConstantAction.kind }); } @@ -161784,7 +162688,7 @@ var ts; else if (!innermostErrorConstantAction) { innermostErrorConstantAction = { description: description, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), notApplicableReason: getStringError(constantExtraction.errors), kind: extractConstantAction.kind }; @@ -161929,7 +162833,7 @@ var ts; // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - if (start.flags & 8388608 /* JSDoc */) { + if (start.flags & 8388608 /* NodeFlags.JSDoc */) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; } if (start.parent !== end.parent) { @@ -162018,20 +162922,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 167 /* PropertyDeclaration */) { + if (current.kind === 167 /* SyntaxKind.PropertyDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 164 /* Parameter */) { + else if (current.kind === 164 /* SyntaxKind.Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 171 /* Constructor */) { + if (ctorOrMethod.kind === 171 /* SyntaxKind.Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 169 /* MethodDeclaration */) { + else if (current.kind === 169 /* SyntaxKind.MethodDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -162055,7 +162959,7 @@ var ts; if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 16777216 /* Ambient */) { + if (nodeToCheck.flags & 16777216 /* NodeFlags.Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -162064,14 +162968,14 @@ var ts; checkForStaticContext(nodeToCheck, containingClass); } var errors; - var permittedJumps = 4 /* Return */; + var permittedJumps = 4 /* PermittedJumps.Return */; var seenLabels; visit(nodeToCheck); if (rangeFacts & RangeFacts.UsesThis) { var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false); - if (container.kind === 256 /* FunctionDeclaration */ || - (container.kind === 169 /* MethodDeclaration */ && container.parent.kind === 205 /* ObjectLiteralExpression */) || - container.kind === 213 /* FunctionExpression */) { + if (container.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) || + container.kind === 213 /* SyntaxKind.FunctionExpression */) { rangeFacts |= RangeFacts.UsesThisInFunction; } } @@ -162082,8 +162986,8 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 254 /* VariableDeclaration */) ? node.parent.parent : node; - if (ts.hasSyntacticModifier(declaringNode, 1 /* Export */)) { + var declaringNode = (node.kind === 254 /* SyntaxKind.VariableDeclaration */) ? node.parent.parent : node; + if (ts.hasSyntacticModifier(declaringNode, 1 /* ModifierFlags.Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! // Also TODO: GH#19956 @@ -162094,16 +162998,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 208 /* CallExpression */) { + if (node.parent.kind === 208 /* SyntaxKind.CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -162116,7 +163020,7 @@ var ts; thisNode = node; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -162131,64 +163035,64 @@ var ts; } }); // falls through - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); } // falls through - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 239 /* IfStatement */: - permittedJumps = 0 /* None */; + case 239 /* SyntaxKind.IfStatement */: + permittedJumps &= ~4 /* PermittedJumps.Return */; break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // forbid all jumps inside try blocks - permittedJumps = 0 /* None */; + permittedJumps = 0 /* PermittedJumps.None */; break; - case 235 /* Block */: - if (node.parent && node.parent.kind === 252 /* TryStatement */ && node.parent.finallyBlock === node) { + case 235 /* SyntaxKind.Block */: + if (node.parent && node.parent.kind === 252 /* SyntaxKind.TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks - permittedJumps = 4 /* Return */; + permittedJumps = 4 /* PermittedJumps.Return */; } break; - case 290 /* DefaultClause */: - case 289 /* CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: // allow unlabeled break inside case clauses - permittedJumps |= 1 /* Break */; + permittedJumps |= 1 /* PermittedJumps.Break */; break; default: if (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false)) { // allow unlabeled break/continue inside loops - permittedJumps |= 1 /* Break */ | 2 /* Continue */; + permittedJumps |= 1 /* PermittedJumps.Break */ | 2 /* PermittedJumps.Continue */; } break; } switch (node.kind) { - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; thisNode = node; break; - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: { + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -162197,21 +163101,21 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 246 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 246 /* SyntaxKind.BreakStatement */ ? 1 /* PermittedJumps.Break */ : 2 /* PermittedJumps.Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 247 /* ReturnStatement */: - if (permittedJumps & 4 /* Return */) { + case 247 /* SyntaxKind.ReturnStatement */: + if (permittedJumps & 4 /* PermittedJumps.Return */) { rangeFacts |= RangeFacts.HasReturn; } else { @@ -162234,7 +163138,7 @@ var ts; function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { var start = startNode.getStart(sourceFile); var end = endNode.getEnd(); - if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + if (sourceFile.text.charCodeAt(end) === 59 /* CharacterCodes.semicolon */) { end++; } return { start: start, length: end - start }; @@ -162280,7 +163184,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 164 /* Parameter */) { + if (current.kind === 164 /* SyntaxKind.Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -162291,7 +163195,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 305 /* SourceFile */) { + if (current.kind === 305 /* SyntaxKind.SourceFile */) { return scopes; } } @@ -162331,11 +163235,11 @@ var ts; : getDescriptionForModuleLikeDeclaration(scope); var functionDescription; var constantDescription; - if (scopeDescription === 1 /* Global */) { + if (scopeDescription === 1 /* SpecialScope.Global */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "global"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "global"]); } - else if (scopeDescription === 0 /* Module */) { + else if (scopeDescription === 0 /* SpecialScope.Module */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "module"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "module"]); } @@ -162381,34 +163285,34 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return scope.name - ? "function '" + scope.name.text + "'" + ? "function '".concat(scope.name.text, "'") : ts.ANONYMOUS; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return "arrow function"; - case 169 /* MethodDeclaration */: - return "method '" + scope.name.getText() + "'"; - case 172 /* GetAccessor */: - return "'get " + scope.name.getText() + "'"; - case 173 /* SetAccessor */: - return "'set " + scope.name.getText() + "'"; + case 169 /* SyntaxKind.MethodDeclaration */: + return "method '".concat(scope.name.getText(), "'"); + case 172 /* SyntaxKind.GetAccessor */: + return "'get ".concat(scope.name.getText(), "'"); + case 173 /* SyntaxKind.SetAccessor */: + return "'set ".concat(scope.name.getText(), "'"); default: - throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); + throw ts.Debug.assertNever(scope, "Unexpected scope kind ".concat(scope.kind)); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 257 /* ClassDeclaration */ - ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" - : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + return scope.kind === 257 /* SyntaxKind.ClassDeclaration */ + ? scope.name ? "class '".concat(scope.name.text, "'") : "anonymous class declaration" + : scope.name ? "class expression '".concat(scope.name.text, "'") : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 262 /* ModuleBlock */ - ? "namespace '" + scope.parent.name.getText() + "'" - : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; + return scope.kind === 262 /* SyntaxKind.ModuleBlock */ + ? "namespace '".concat(scope.parent.name.getText(), "'") + : scope.externalModuleIndicator ? 0 /* SpecialScope.Module */ : 1 /* SpecialScope.Global */; } var SpecialScope; (function (SpecialScope) { @@ -162439,7 +163343,7 @@ var ts; var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" type = checker.getBaseTypeOfLiteralType(type); - typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NoTruncation */); + typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NodeBuilderFlags.NoTruncation */); } var paramDecl = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, @@ -162447,7 +163351,7 @@ var ts; /*name*/ name, /*questionToken*/ undefined, typeNode); parameters.push(paramDecl); - if (usage.usage === 2 /* Write */) { + if (usage.usage === 2 /* Usage.Write */) { (writes || (writes = [])).push(usage); } callArguments.push(ts.factory.createIdentifier(name)); @@ -162466,7 +163370,7 @@ var ts; // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); - returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217 + returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 } var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; ts.suppressLeadingAndTrailingTrivia(body); @@ -162474,14 +163378,14 @@ var ts; var callThis = !!(range.facts & RangeFacts.UsesThisInFunction); if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(131 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(131 /* SyntaxKind.AsyncKeyword */)); } - newFunction = ts.factory.createMethodDeclaration(modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, + newFunction = ts.factory.createMethodDeclaration(modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { @@ -162490,10 +163394,10 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ "this", - /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NoTruncation */), + /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NodeBuilderFlags.NoTruncation */), /*initializer*/ undefined)); } - newFunction = ts.factory.createFunctionDeclaration(range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + newFunction = ts.factory.createFunctionDeclaration(range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* SyntaxKind.AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -162514,7 +163418,7 @@ var ts; var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call); + call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.factory.createAwaitExpression(call); @@ -162548,7 +163452,7 @@ var ts; /*propertyName*/ undefined, /*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name))); // Being returned through an object literal will have widened the type. - var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */); + var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NodeBuilderFlags.NoTruncation */); typeElements.push(ts.factory.createPropertySignature( /*modifiers*/ undefined, /*name*/ variableDeclaration.symbol.name, @@ -162559,7 +163463,7 @@ var ts; } var typeLiteral = sawExplicitType ? ts.factory.createTypeLiteralNode(typeElements) : undefined; if (typeLiteral) { - ts.setEmitFlags(typeLiteral, 1 /* SingleLine */); + ts.setEmitFlags(typeLiteral, 1 /* EmitFlags.SingleLine */); } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.factory.createObjectBindingPattern(bindingElements), @@ -162574,8 +163478,8 @@ var ts; for (var _c = 0, exposedVariableDeclarations_2 = exposedVariableDeclarations; _c < exposedVariableDeclarations_2.length; _c++) { var variableDeclaration = exposedVariableDeclarations_2[_c]; var flags = variableDeclaration.parent.flags; - if (flags & 2 /* Const */) { - flags = (flags & ~2 /* Const */) | 1 /* Let */; + if (flags & 2 /* NodeFlags.Const */) { + flags = (flags & ~2 /* NodeFlags.Const */) | 1 /* NodeFlags.Let */; } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(variableDeclaration.symbol.name, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(variableDeclaration.type))], flags))); @@ -162584,7 +163488,7 @@ var ts; if (returnValueProperty) { // has both writes and return, need to create variable declaration to hold return value; newNodes.push(ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* Let */))); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* NodeFlags.Let */))); } var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (returnValueProperty) { @@ -162641,9 +163545,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* SyntaxKind.UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } } /** @@ -162656,13 +163560,13 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable var file = scope.getSourceFile(); - var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) + var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) ? node.name.text : ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJSFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined - : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 + : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(ts.skipParentheses(node), substitutions); (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); @@ -162670,11 +163574,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(145 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration(modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); var localReference = ts.factory.createPropertyAccessExpression(rangeFacts & RangeFacts.InStaticRegion @@ -162705,16 +163609,16 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 238 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); changeTracker.replaceNode(context.file, node.parent, newVariableStatement); } else { var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); // Declare var nodeToInsertBefore = getNodeToInsertConstantBefore(node, scope); if (nodeToInsertBefore.pos === 0) { @@ -162724,7 +163628,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -162751,7 +163655,7 @@ var ts; if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) return { variableType: variableType, initializer: initializer }; var functionType = checker.getTypeAtLocation(node); - var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* SignatureKind.Call */)); // If no function signature, maybe there was an error, do nothing if (!functionSignature) return { variableType: variableType, initializer: initializer }; @@ -162770,7 +163674,7 @@ var ts; var paramType = checker.getTypeAtLocation(p); if (paramType === checker.getAnyType()) hasAny = true; - parameters.push(ts.factory.updateParameterDeclaration(p, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + parameters.push(ts.factory.updateParameterDeclaration(p, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NodeBuilderFlags.NoTruncation */), p.initializer)); } } // If a parameter was inferred as any we skip adding function parameters at all. @@ -162780,7 +163684,7 @@ var ts; return { variableType: variableType, initializer: initializer }; variableType = undefined; if (ts.isArrowFunction(initializer)) { - initializer = ts.factory.updateArrowFunction(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + initializer = ts.factory.updateArrowFunction(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); } else { if (functionSignature && !!functionSignature.thisParameter) { @@ -162792,10 +163696,10 @@ var ts; parameters.splice(0, 0, ts.factory.createParameterDeclaration( /* modifiers */ undefined, /* dotDotDotToken */ undefined, "this", - /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NodeBuilderFlags.NoTruncation */))); } } - initializer = ts.factory.updateFunctionExpression(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + initializer = ts.factory.updateFunctionExpression(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.body); } return { variableType: variableType, initializer: initializer }; } @@ -163042,7 +163946,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* TypeFlags.Void */ | 131072 /* TypeFlags.Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -163111,7 +164015,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_17 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -163126,11 +164030,11 @@ var ts; var hasWrite = false; var readonlyClassPropertyWrite; usagesPerScope[i].usages.forEach(function (value) { - if (value.usage === 2 /* Write */) { + if (value.usage === 2 /* Usage.Write */) { hasWrite = true; - if (value.symbol.flags & 106500 /* ClassMember */ && + if (value.symbol.flags & 106500 /* SymbolFlags.ClassMember */ && value.symbol.valueDeclaration && - ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* ModifierFlags.Readonly */)) { readonlyClassPropertyWrite = value.symbol.valueDeclaration; } } @@ -163154,7 +164058,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_17(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -163174,7 +164078,7 @@ var ts; } } function collectUsages(node, valueUsage) { - if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (valueUsage === void 0) { valueUsage = 1 /* Usage.Read */; } if (inGenericContext) { var type = checker.getTypeAtLocation(node); recordTypeParameterUsages(type); @@ -163184,11 +164088,11 @@ var ts; } if (ts.isAssignmentExpression(node)) { // use 'write' as default usage for values - collectUsages(node.left, 2 /* Write */); + collectUsages(node.left, 2 /* Usage.Write */); collectUsages(node.right); } else if (ts.isUnaryExpressionWithWrite(node)) { - collectUsages(node.operand, 2 /* Write */); + collectUsages(node.operand, 2 /* Usage.Write */); } else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { // use 'write' as default usage for values @@ -163262,7 +164166,7 @@ var ts; // declaration is located in range to be extracted - do nothing return undefined; } - if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Write */) { + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Usage.Write */) { // this is write to a reference located outside of the target scope and range is extracted into generator // currently this is unsupported scenario var diag = ts.createDiagnosticForNode(identifier, Messages.cannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators); @@ -163289,7 +164193,7 @@ var ts; else if (isTypeName) { // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument // so there's no problem. - if (!(symbol.flags & 262144 /* TypeParameter */)) { + if (!(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var diag = ts.createDiagnosticForNode(identifier, Messages.typeWillNotBeVisibleInTheNewScope); functionErrorsPerScope[i].push(diag); constantErrorsPerScope[i].push(diag); @@ -163370,30 +164274,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return false; } switch (node.kind) { - case 10 /* StringLiteral */: - return parent.kind !== 266 /* ImportDeclaration */ && - parent.kind !== 270 /* ImportSpecifier */; - case 225 /* SpreadElement */: - case 201 /* ObjectBindingPattern */: - case 203 /* BindingElement */: + case 10 /* SyntaxKind.StringLiteral */: + return parent.kind !== 266 /* SyntaxKind.ImportDeclaration */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */; + case 225 /* SyntaxKind.SpreadElement */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 203 /* SyntaxKind.BindingElement */: return false; - case 79 /* Identifier */: - return parent.kind !== 203 /* BindingElement */ && - parent.kind !== 270 /* ImportSpecifier */ && - parent.kind !== 275 /* ExportSpecifier */; + case 79 /* SyntaxKind.Identifier */: + return parent.kind !== 203 /* SyntaxKind.BindingElement */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */ && + parent.kind !== 275 /* SyntaxKind.ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 235 /* Block */: - case 305 /* SourceFile */: - case 262 /* ModuleBlock */: - case 289 /* CaseClause */: + case 235 /* SyntaxKind.Block */: + case 305 /* SyntaxKind.SourceFile */: + case 262 /* SyntaxKind.ModuleBlock */: + case 289 /* SyntaxKind.CaseClause */: return true; default: return false; @@ -163539,7 +164443,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var typeName = node.typeName; - var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); + var symbol = checker.resolveName(typeName.text, typeName, 262144 /* SymbolFlags.TypeParameter */, /* excludeGlobals */ true); for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) { var decl = _a[_i]; if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) { @@ -163570,7 +164474,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* SymbolFlags.Value */, /* excludeGlobals */ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -163582,7 +164486,7 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.forEachChild(node, visitor); } @@ -163606,7 +164510,7 @@ var ts; } function doTypedefChange(changes, file, name, info) { var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; - ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(selection, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name)); var templates = []; ts.forEach(typeParameters, function (typeParameter) { @@ -163761,7 +164665,7 @@ var ts; var usage = getUsageInfo(oldFile, toMove.all, checker); var currentDirectory = ts.getDirectoryPath(oldFile.fileName); var extension = ts.extensionFromPath(oldFile.fileName); - var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host); + var newModuleName = makeUniqueModuleName(getNewModuleName(usage.oldFileImportsFromNewFile, usage.movedSymbols), extension, currentDirectory, host); var newFileNameWithExtension = newModuleName + extension; // If previous file was global, this is easy. changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences)); @@ -163790,11 +164694,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return true; - case 265 /* ImportEqualsDeclaration */: - return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 237 /* VariableStatement */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return !ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); + case 237 /* SyntaxKind.VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -163834,7 +164738,7 @@ var ts; var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax); if (imports.length && body.length) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [ - 4 /* NewLineTrivia */ + 4 /* SyntaxKind.NewLineTrivia */ ], false), body, true); } return __spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), body, true); @@ -163855,10 +164759,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_18 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_19 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -163880,35 +164784,35 @@ var ts; }; for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) { var statement = _c[_b]; - _loop_19(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_18(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* NamespaceImport */ ? + case 266 /* SyntaxKind.ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { - var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ESNext */); + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ScriptTarget.ESNext */); var needUniqueName = false; var toChange = []; ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { if (!ts.isPropertyAccessExpression(ref.parent)) return; - needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true); + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { toChange.push(ref); } @@ -163926,21 +164830,21 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString, /*assertClause*/ undefined); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function moduleSpecifierFromImport(i) { - return (i.kind === 266 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 265 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 266 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -163966,7 +164870,7 @@ var ts; var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { - if (symbol.escapedName === "default" /* Default */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */) { defaultImport = ts.factory.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217 } else { @@ -163990,7 +164894,7 @@ var ts; } } function makeVariableStatement(name, type, initializer, flags) { - if (flags === void 0) { flags = 2 /* Const */; } + if (flags === void 0) { flags = 2 /* NodeFlags.Const */; } return ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, initializer)], flags)); } function createRequireCall(moduleSpecifier) { @@ -164010,19 +164914,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind ".concat(importDecl.kind)); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -164031,7 +164935,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 268 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -164043,7 +164947,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 269 /* NamedImports */) { + else if (namedBindings.kind === 269 /* SyntaxKind.NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -164056,14 +164960,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: break; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -164105,7 +165009,7 @@ var ts; if (markSeenTop(top)) { addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax); } - if (ts.hasSyntacticModifier(decl, 512 /* Default */)) { + if (ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */)) { oldFileDefault = name; } else { @@ -164122,17 +165026,17 @@ var ts; var name = ts.combinePaths(inDirectory, newModuleName + extension); if (!host.fileExists(name)) return newModuleName; - newModuleName = moduleName + "." + i; + newModuleName = "".concat(moduleName, ".").concat(i); } } - function getNewModuleName(movedSymbols) { - return movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile"; + function getNewModuleName(importsFromNewFile, movedSymbols) { + return importsFromNewFile.forEachEntry(ts.symbolNameNoDefault) || movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile"; } function getUsageInfo(oldFile, toMove, checker) { var movedSymbols = new SymbolSet(); var oldImportsNeededByNewFile = new SymbolSet(); var newFileImportsFromOldFile = new SymbolSet(); - var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* ContainsJsx */); }); + var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */); }); var jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx); if (jsxNamespaceSymbol) { // Might not exist (e.g. in non-compiling code) oldImportsNeededByNewFile.add(jsxNamespaceSymbol); @@ -164166,7 +165070,7 @@ var ts; if (ts.contains(toMove, statement)) continue; // jsxNamespaceSymbol will only be set iff it is in oldImportsNeededByNewFile. - if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) { + if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */)) { unusedImportsFromOldFile.delete(jsxNamespaceSymbol); } forEachReference(statement, checker, function (symbol) { @@ -164184,7 +165088,7 @@ var ts; // Strictly speaking, this could resolve to a symbol other than the JSX namespace. // This will produce erroneous output (probably, an incorrectly copied import) but // is expected to be very rare and easily reversible. - var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* Namespace */, /*excludeGlobals*/ true); + var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* SymbolFlags.Namespace */, /*excludeGlobals*/ true); return !!jsxNamespaceSymbol && ts.some(jsxNamespaceSymbol.declarations, isInImport) ? jsxNamespaceSymbol : undefined; @@ -164193,14 +165097,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: return true; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -164212,7 +165116,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -164222,18 +165126,18 @@ var ts; ? ts.factory.createImportDeclaration(/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined) : undefined; } - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); + return ts.Debug.assertNever(i, "Unexpected import kind ".concat(i.kind)); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -164243,11 +165147,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return keep(name) ? name : undefined; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return name; - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined; @@ -164304,13 +165208,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -164318,19 +165222,19 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return cb(statement); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; - return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ + return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* AssignmentDeclarationKind.ExportsProperty */ ? cb(statement) : undefined; } @@ -164338,13 +165242,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); + return ts.Debug.assertNever(name, "Unexpected name kind ".concat(name.kind)); } } function nameOfTopLevelDeclaration(d) { @@ -164352,9 +165256,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return d.parent.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -164376,7 +165280,7 @@ var ts; function isExported(sourceFile, decl, useEs6Exports, name) { var _a; if (useEs6Exports) { - return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); + return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); } return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); }); } @@ -164384,29 +165288,29 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.canHaveModifiers(d) ? ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], ts.getModifiers(d)) : undefined; + var modifiers = ts.canHaveModifiers(d) ? ts.concatenate([ts.factory.createModifier(93 /* SyntaxKind.ExportKeyword */)], ts.getModifiers(d)) : undefined; switch (d.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var decorators = ts.canHaveDecorators(d) ? ts.getDecorators(d) : undefined; return ts.factory.updateClassDeclaration(d, ts.concatenate(decorators, modifiers), d.name, d.typeParameters, d.heritageClauses, d.members); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, modifiers, d.name, d.body); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, modifiers, d.name, d.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, modifiers, d.name, d.typeParameters, d.type); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); + return ts.Debug.assertNever(d, "Unexpected declaration kind ".concat(d.kind)); } } function addCommonjsExport(decl) { @@ -164414,26 +165318,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.emptyArray; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); + return ts.Debug.assertNever(decl, "Unexpected decl kind ".concat(decl.kind)); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* EqualsToken */, ts.factory.createIdentifier(name))); + return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* SyntaxKind.EqualsToken */, ts.factory.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -164496,14 +165400,14 @@ var ts; if (actionName === addBracesAction.name) { var returnStatement_1 = ts.factory.createReturnStatement(expression); body = ts.factory.createBlock([returnStatement_1], /* multiLine */ true); - ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); + ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); } else if (actionName === removeBracesAction.name && returnStatement) { var actualExpression = expression || ts.factory.createVoidZero(); body = ts.needsParentheses(actualExpression) ? ts.factory.createParenthesizedExpression(actualExpression) : actualExpression; - ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } else { ts.Debug.fail("invalid action"); @@ -164637,7 +165541,7 @@ var ts; var contextualSymbols = ts.map(functionNames, function (name) { return getSymbolForContextualType(name, checker); }); for (var _i = 0, referenceEntries_1 = referenceEntries; _i < referenceEntries_1.length; _i++) { var entry = referenceEntries_1[_i]; - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* FindAllReferences.EntryKind.Span */) { groupedReferences.valid = false; continue; } @@ -164736,7 +165640,7 @@ var ts; if (element) { var contextualType = checker.getContextualTypeForObjectLiteralElement(element); var symbol = contextualType === null || contextualType === void 0 ? void 0 : contextualType.getSymbol(); - if (symbol && !(ts.getCheckFlags(symbol) & 6 /* Synthetic */)) { + if (symbol && !(ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */)) { return symbol; } } @@ -164766,15 +165670,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -164784,7 +165688,7 @@ var ts; } break; // x["foo"](...) - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -164803,14 +165707,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -164822,7 +165726,7 @@ var ts; } function entryToType(entry) { var reference = entry.node; - if (ts.getMeaningFromLocation(reference) === 2 /* Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { + if (ts.getMeaningFromLocation(reference) === 2 /* SemanticMeaning.Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { return reference; } return undefined; @@ -164856,16 +165760,16 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralExpression(functionDeclaration.parent)) { var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker); // don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change return ((_a = contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 && isSingleImplementation(functionDeclaration, checker); } return isSingleImplementation(functionDeclaration, checker); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -164873,8 +165777,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -164884,7 +165788,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* SyntaxKind.DefaultKeyword */); return !!defaultKeyword; } return true; @@ -164988,7 +165892,7 @@ var ts; } function createParameterTypeNode(parameters) { var members = ts.map(parameters, createPropertySignatureFromParameterDeclaration); - var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* SingleLine */); + var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* EmitFlags.SingleLine */); return typeNode; } function createPropertySignatureFromParameterDeclaration(parameterDeclaration) { @@ -164997,7 +165901,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.factory.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType); + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : parameterDeclaration.questionToken, parameterType); ts.suppressLeadingAndTrailingTrivia(propertySignature); ts.copyComments(parameterDeclaration.name, propertySignature.name); if (parameterDeclaration.type && propertySignature.type) { @@ -165022,15 +165926,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -165041,30 +165945,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return [functionDeclaration.name]; - case 171 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 226 /* ClassExpression */) { + case 171 /* SyntaxKind.Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* SyntaxKind.ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 226 /* SyntaxKind.ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return [functionDeclaration.parent.name]; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind ".concat(functionDeclaration.kind)); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -165145,16 +166049,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 63 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return false; - case 223 /* TemplateExpression */: - case 221 /* BinaryExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -165172,7 +166076,7 @@ var ts; if (!(leftHasString || ts.isStringLiteral(current.right) || ts.isTemplateExpression(current.right))) { return { nodes: [current], operators: [], hasString: false, validOperators: true }; } - var currentOperatorValid = current.operatorToken.kind === 39 /* PlusToken */; + var currentOperatorValid = current.operatorToken.kind === 39 /* SyntaxKind.PlusToken */; var validOperators = leftOperatorValid && currentOperatorValid; nodes.push(current.right); operators.push(current.operatorToken); @@ -165185,7 +166089,7 @@ var ts; // "foo" + /* comment */ "bar" var copyTrailingOperatorComments = function (operators, file) { return function (index, targetNode) { if (index < operators.length) { - ts.copyTrailingComments(operators[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(operators[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } }; }; // to copy comments following the string @@ -165194,7 +166098,7 @@ var ts; return function (indexes, targetNode) { while (indexes.length > 0) { var index = indexes.shift(); - ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); copyOperatorComments(index, targetNode); } }; @@ -165248,7 +166152,7 @@ var ts; var templateSpans = []; var templateHead = ts.factory.createTemplateHead(headText, rawHeadText); copyCommentFromStringLiterals(headIndexes, templateHead); - var _loop_20 = function (i) { + var _loop_19 = function (i) { var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]); copyOperatorComments(i, currentNode); var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3]; @@ -165277,7 +166181,7 @@ var ts; }; var out_i_1; for (var i = begin; i < nodes.length; i++) { - _loop_20(i); + _loop_19(i); i = out_i_1; } return ts.factory.createTemplateExpression(templateHead, templateSpans); @@ -165286,8 +166190,8 @@ var ts; // "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar" function copyExpressionComments(node) { var file = node.getSourceFile(); - ts.copyTrailingComments(node, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(node, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } function getExpressionFromParenthesesOrExpression(node) { if (ts.isParenthesizedExpression(node)) { @@ -165482,7 +166386,7 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* ModifierFlags.Export */) | ts.getEffectiveModifierFlags(func); var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); var newNode = ts.factory.createFunctionDeclaration(ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { @@ -165508,7 +166412,7 @@ var ts; else { body = func.body; } - var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* EqualsGreaterThanToken */), body); + var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), body); return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, func, newNode); }); } function canBeConvertedToExpression(body, head) { @@ -165568,13 +166472,13 @@ var ts; return ts.emptyArray; } function doChange(sourceFile, changes, declaration, typeNode) { - var closeParen = ts.findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile); + var closeParen = ts.findChildOfKind(declaration, 21 /* SyntaxKind.CloseParenToken */, sourceFile); var needParens = ts.isArrowFunction(declaration) && closeParen === undefined; var endNode = needParens ? ts.first(declaration.parameters) : closeParen; if (endNode) { if (needParens) { - changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* OpenParenToken */)); - changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); + changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } changes.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); } @@ -165584,7 +166488,7 @@ var ts; return; var token = ts.getTokenAtPosition(context.file, context.startPosition); var declaration = ts.findAncestor(token, function (n) { - return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : + return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : isConvertibleDeclaration(n); }); if (!declaration || !declaration.body || declaration.type) { @@ -165595,17 +166499,17 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); + var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NodeBuilderFlags.NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; } } function isConvertibleDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return true; default: return false; @@ -165632,20 +166536,20 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : - kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : + kind === 79 /* SyntaxKind.Identifier */ ? new IdentifierObject(79 /* SyntaxKind.Identifier */, pos, end) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* SyntaxKind.PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 50720768 /* ContextFlags */; + node.flags = parent.flags & 50720768 /* NodeFlags.ContextFlags */; return node; } var NodeObject = /** @class */ (function () { function NodeObject(kind, pos, end) { this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.kind = kind; } @@ -165707,8 +166611,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 309 /* FirstJSDocNode */ || kid.kind > 347 /* LastJSDocNode */; }); - return child.kind < 161 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 309 /* SyntaxKind.FirstJSDocNode */ || kid.kind > 347 /* SyntaxKind.LastJSDocNode */; }); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -165719,7 +166623,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 161 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -165767,19 +166671,19 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 79 /* Identifier */) { - ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); + if (token === 79 /* SyntaxKind.Identifier */) { + ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia")); } nodes.push(createNode(token, pos, textPos, parent)); } pos = textPos; - if (token === 1 /* EndOfFileToken */) { + if (token === 1 /* SyntaxKind.EndOfFileToken */) { break; } } } function createSyntaxList(nodes, parent) { - var list = createNode(348 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(348 /* SyntaxKind.SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { @@ -165796,9 +166700,9 @@ var ts; // Set properties in same order as NodeObject this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } TokenOrIdentifierObject.prototype.getSourceFile = function () { @@ -165838,7 +166742,7 @@ var ts; return this.getChildren()[index]; }; TokenOrIdentifierObject.prototype.getChildren = function () { - return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; + return this.kind === 1 /* SyntaxKind.EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -165889,20 +166793,25 @@ var ts; return this.documentationComment; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { - switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + if (context) { + if (ts.isGetAccessor(context)) { if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } - return this.contextualGetAccessorDocumentationComment; - case 173 /* SetAccessor */: + if (ts.length(this.contextualGetAccessorDocumentationComment)) { + return this.contextualGetAccessorDocumentationComment; + } + } + if (ts.isSetAccessor(context)) { if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); } - return this.contextualSetAccessorDocumentationComment; - default: - return this.getDocumentationComment(checker); + if (ts.length(this.contextualSetAccessorDocumentationComment)) { + return this.contextualSetAccessorDocumentationComment; + } + } } + return this.getDocumentationComment(checker); }; SymbolObject.prototype.getJsDocTags = function (checker) { if (this.tags === undefined) { @@ -165911,20 +166820,25 @@ var ts; return this.tags; }; SymbolObject.prototype.getContextualJsDocTags = function (context, checker) { - switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + if (context) { + if (ts.isGetAccessor(context)) { if (!this.contextualGetAccessorTags) { this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker); } - return this.contextualGetAccessorTags; - case 173 /* SetAccessor */: + if (ts.length(this.contextualGetAccessorTags)) { + return this.contextualGetAccessorTags; + } + } + if (ts.isSetAccessor(context)) { if (!this.contextualSetAccessorTags) { this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker); } - return this.contextualSetAccessorTags; - default: - return this.getJsDocTags(checker); + if (ts.length(this.contextualSetAccessorTags)) { + return this.contextualSetAccessorTags; + } + } } + return this.getJsDocTags(checker); }; return SymbolObject; }()); @@ -165941,7 +166855,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 79 /* Identifier */; + _this.kind = 79 /* SyntaxKind.Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -165953,7 +166867,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 79 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* SyntaxKind.Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -165968,7 +166882,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* SyntaxKind.PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -165990,16 +166904,16 @@ var ts; return this.checker.getAugmentedPropertiesOfType(this); }; TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0 /* Call */); + return this.checker.getSignaturesOfType(this, 0 /* SignatureKind.Call */); }; TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1 /* Construct */); + return this.checker.getSignaturesOfType(this, 1 /* SignatureKind.Construct */); }; TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0 /* String */); + return this.checker.getIndexTypeOfType(this, 0 /* IndexKind.String */); }; TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1 /* Number */); + return this.checker.getIndexTypeOfType(this, 1 /* IndexKind.Number */); }; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; @@ -166020,41 +166934,41 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 1048576 /* Union */); + return !!(this.flags & 1048576 /* TypeFlags.Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 2097152 /* Intersection */); + return !!(this.flags & 2097152 /* TypeFlags.Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 3145728 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* TypeFlags.UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 384 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* TypeFlags.StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 128 /* StringLiteral */); + return !!(this.flags & 128 /* TypeFlags.StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 256 /* NumberLiteral */); + return !!(this.flags & 256 /* TypeFlags.NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 262144 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeFlags.TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { - return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); + return !!(ts.getObjectFlags(this) & 3 /* ObjectFlags.ClassOrInterface */); }; TypeObject.prototype.isClass = function () { - return !!(ts.getObjectFlags(this) & 1 /* Class */); + return !!(ts.getObjectFlags(this) & 1 /* ObjectFlags.Class */); }; TypeObject.prototype.isIndexType = function () { - return !!(this.flags & 4194304 /* Index */); + return !!(this.flags & 4194304 /* TypeFlags.Index */); }; Object.defineProperty(TypeObject.prototype, "typeArguments", { /** * This polyfills `referenceType.typeArguments` for API consumers */ get: function () { - if (ts.getObjectFlags(this) & 4 /* Reference */) { + if (ts.getObjectFlags(this) & 4 /* ObjectFlags.Reference */) { return this.checker.getTypeArguments(this); } return undefined; @@ -166113,12 +167027,12 @@ var ts; var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker); if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) { var seenSymbols_1 = new ts.Set(); - var _loop_21 = function (declaration) { + var _loop_20 = function (declaration) { var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; if (!seenSymbols_1.has(symbol)) { seenSymbols_1.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualJsDocTags(declaration, checker); } return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; @@ -166130,7 +167044,7 @@ var ts; }; for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { var declaration = declarations_7[_i]; - _loop_21(declaration); + _loop_20(declaration); } } return tags; @@ -166141,11 +167055,11 @@ var ts; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker); if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) { var seenSymbols_2 = new ts.Set(); - var _loop_22 = function (declaration) { + var _loop_21 = function (declaration) { var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { if (!seenSymbols_2.has(symbol)) { seenSymbols_2.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualDocumentationComment(declaration, checker); } return symbol.getDocumentationComment(checker); @@ -166157,14 +167071,14 @@ var ts; }; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - _loop_22(declaration); + _loop_21(declaration); } } return doc; } function findBaseOfDeclaration(checker, declaration, cb) { var _a; - var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ ? declaration.parent.parent : declaration.parent; + var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ ? declaration.parent.parent : declaration.parent; if (!classOrInterfaceDeclaration) return; var isStaticMember = ts.hasStaticModifier(declaration); @@ -166179,7 +167093,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 305 /* SourceFile */; + _this.kind = 305 /* SyntaxKind.SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -166238,10 +167152,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -166261,31 +167175,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 182 /* SyntaxKind.TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { break; } // falls through - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -166296,12 +167210,12 @@ var ts; } } // falls through - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: addDeclaration(node); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -166314,7 +167228,7 @@ var ts; } } break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -166326,7 +167240,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -166335,8 +167249,8 @@ var ts; } } break; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) !== 0 /* AssignmentDeclarationKind.None */) { addDeclaration(node); } // falls through @@ -166405,8 +167319,8 @@ var ts; function getDefaultCompilerOptions() { // Always default to "ScriptTarget.ES5" for the language service return { - target: 1 /* ES5 */, - jsx: 1 /* Preserve */ + target: 1 /* ScriptTarget.ES5 */, + jsx: 1 /* JsxEmit.Preserve */ }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; @@ -166431,7 +167345,7 @@ var ts; if (this.currentFileName !== fileName) { // This is a new file, just parse it var options = { - languageVersion: 99 /* Latest */, + languageVersion: 99 /* ScriptTarget.Latest */, impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(fileName, this.host.getCurrentDirectory(), ((_c = (_b = (_a = this.host).getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getCanonicalFileName) || ts.hostGetCanonicalFileName(this.host)), (_h = (_g = (_f = (_e = (_d = this.host).getCompilerHost) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.getModuleResolutionCache) === null || _g === void 0 ? void 0 : _g.call(_f)) === null || _h === void 0 ? void 0 : _h.getPackageJsonInfoCache(), this.host, this.host.getCompilationSettings()), setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings()) }; @@ -166528,7 +167442,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -166558,7 +167472,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -166648,7 +167562,7 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - var error = new Error("Could not find source file: '" + fileName + "'."); + var error = new Error("Could not find source file: '".concat(fileName, "'.")); // We've been having trouble debugging this, so attach sidecar data for the tsserver log. // See https://github.com/microsoft/TypeScript/issues/30180. error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); @@ -166675,7 +167589,10 @@ var ts; program = undefined; // TODO: GH#18217 lastTypesRootVersion = typeRootsVersion; } - var rootFileNames = host.getScriptFileNames(); + // This array is retained by the program and will be used to determine if the program is up to date, + // so we need to make a copy in case the host mutates the underlying array - otherwise it would look + // like every program always has the host's current list of root files. + var rootFileNames = host.getScriptFileNames().slice(); // Get a fresh cache of the host information var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; @@ -166786,7 +167703,7 @@ var ts; return result; } function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { - var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + var result = getOrCreateSourceFile(configFileName, 100 /* ScriptTarget.JSON */); if (!result) return undefined; result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); @@ -166808,12 +167725,12 @@ var ts; // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat); } - function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { - return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); + function getOrCreateSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) { + return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile); } - function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) { + function getOrCreateSourceFileByPath(fileName, path, languageVersionOrOptions, _onError, shouldCreateNewSourceFile) { ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host."); // The program is asking for this file, check first if the host can locate it. // If the host can not locate the file, then it does not exist. return undefined @@ -166856,17 +167773,17 @@ var ts; // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" if (scriptKind === oldSourceFile.scriptKind) { - return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind); + return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions); } else { // Release old source file and fall through to aquire new file with new script kind - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat); } } // We didn't already have the file. Fall through and acquire it from the registry. } // Could not find this file in the old program, create a new SourceFile for it. - return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind); + return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions); } } // TODO: GH#18217 frequently asserted as defined @@ -166933,7 +167850,7 @@ var ts; if (!sourceFile) return undefined; var rawNode = ts.getTouchingPropertyName(sourceFile, docSpan.textSpan.start); - var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* References */ }); + var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }); return adjustedNode; } } @@ -166945,7 +167862,7 @@ var ts; // Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()); ts.forEach(program.getSourceFiles(), function (f) { - return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind); + return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind, f.impliedNodeFormat); }); program = undefined; // TODO: GH#18217 } @@ -167013,8 +167930,8 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { var type_2 = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined; return type_2 && { - kind: "" /* unknown */, - kindModifiers: "" /* none */, + kind: "" /* ScriptElementKind.unknown */, + kindModifiers: "" /* ScriptElementKindModifier.none */, textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile), displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(nodeForQuickInfo)); }), documentation: type_2.symbol ? type_2.symbol.getDocumentationComment(typeChecker) : undefined, @@ -167047,18 +167964,18 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 106 /* SuperKeyword */: - case 197 /* NamedTupleMember */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 106 /* SyntaxKind.SuperKeyword */: + case 197 /* SyntaxKind.NamedTupleMember */: return true; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return ts.isImportMeta(node); default: return false; @@ -167084,7 +168001,7 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* HighlightSpanKind.writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); @@ -167108,17 +168025,17 @@ var ts; }); } else { - return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); + return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* FindAllReferences.FindReferencesUse.Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); } } function getReferencesAtPosition(fileName, position) { synchronizeHostData(); - return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry); + return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, ts.FindAllReferences.toReferenceEntry); } function getReferencesWorker(node, position, options, cb) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. - var sourceFiles = options && options.use === 2 /* Rename */ + var sourceFiles = options && options.use === 2 /* FindAllReferences.FindReferencesUse.Rename */ ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) : program.getSourceFiles(); return ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, cb); @@ -167165,16 +168082,16 @@ var ts; return undefined; } switch (node.kind) { - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: - case 10 /* StringLiteral */: - case 95 /* FalseKeyword */: - case 110 /* TrueKeyword */: - case 104 /* NullKeyword */: - case 106 /* SuperKeyword */: - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 79 /* Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: + case 10 /* SyntaxKind.StringLiteral */: + case 95 /* SyntaxKind.FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 79 /* SyntaxKind.Identifier */: break; // Cant create the text span default: @@ -167190,7 +168107,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 261 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -167220,8 +168137,8 @@ var ts; } function getSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "2020" /* TwentyTwenty */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "2020" /* SemanticClassificationFormat.TwentyTwenty */) { return ts.classifier.v2020.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); } else { @@ -167230,8 +168147,8 @@ var ts; } function getEncodedSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "original" /* Original */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "original" /* SemanticClassificationFormat.Original */) { return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } else { @@ -167252,10 +168169,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = new ts.Map(ts.getEntries((_a = {}, - _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, - _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, - _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, + _a[18 /* SyntaxKind.OpenBraceToken */] = 19 /* SyntaxKind.CloseBraceToken */, + _a[20 /* SyntaxKind.OpenParenToken */] = 21 /* SyntaxKind.CloseParenToken */, + _a[22 /* SyntaxKind.OpenBracketToken */] = 23 /* SyntaxKind.CloseBracketToken */, + _a[31 /* SyntaxKind.GreaterThanToken */] = 29 /* SyntaxKind.LessThanToken */, _a))); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -167352,7 +168269,7 @@ var ts; // var x = new foo<| ( with class foo{} ) // or // var y = 3 <| - if (openingBrace === 60 /* lessThan */) { + if (openingBrace === 60 /* CharacterCodes.lessThan */) { return false; } var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -167361,15 +168278,15 @@ var ts; return false; } if (ts.isInsideJsxElementOrAttribute(sourceFile, position)) { - return openingBrace === 123 /* openBrace */; + return openingBrace === 123 /* CharacterCodes.openBrace */; } if (ts.isInTemplateString(sourceFile, position)) { return false; } switch (openingBrace) { - case 39 /* singleQuote */: - case 34 /* doubleQuote */: - case 96 /* backtick */: + case 39 /* CharacterCodes.singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 96 /* CharacterCodes.backtick */: return !ts.isInComment(sourceFile, position); } return true; @@ -167379,12 +168296,12 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxElement(token.parent) ? token.parent : undefined; if (element && isUnclosedTag(element)) { - return { newText: "" }; + return { newText: "") }; } - var fragment = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent + var fragment = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxFragment(token.parent) ? token.parent : undefined; if (fragment && isUnclosedFragment(fragment)) { return { newText: "" }; @@ -167481,14 +168398,14 @@ var ts; commentRange.end++; } positions.push(commentRange.pos); - if (commentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (commentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { positions.push(commentRange.end); } hasComment = true; pos = commentRange.end + 1; } else { // If it's not in a comment range, then we need to comment the uncommented portions. - var newPos = text.substring(pos, textRange.end).search("(" + openMultilineRegex + ")|(" + closeMultilineRegex + ")"); + var newPos = text.substring(pos, textRange.end).search("(".concat(openMultilineRegex, ")|(").concat(closeMultilineRegex, ")")); isCommenting = insertComment !== undefined ? insertComment : isCommenting || !ts.isTextWhiteSpaceLike(text, pos, newPos === -1 ? textRange.end : pos + newPos); // If isCommenting is already true we don't need to check whitespace again. @@ -167498,7 +168415,7 @@ var ts; // If it didn't found a comment and isCommenting is false means is only empty space. // We want to insert comment in this scenario. if (isCommenting || !hasComment) { - if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SingleLineCommentTrivia */) { + if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SyntaxKind.SingleLineCommentTrivia */) { ts.insertSorted(positions, textRange.pos, ts.compareValues); } ts.insertSorted(positions, textRange.end, ts.compareValues); @@ -167584,10 +168501,10 @@ var ts; var commentRange = ts.isInComment(sourceFile, i); if (commentRange) { switch (commentRange.kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: textChanges.push.apply(textChanges, toggleLineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); } i = commentRange.end + 1; @@ -167602,12 +168519,12 @@ var ts; } function isUnclosedFragment(_a) { var closingFragment = _a.closingFragment, parent = _a.parent; - return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); + return !!(closingFragment.flags & 131072 /* NodeFlags.ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); - return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; + return range && (!onlyMultiLine || range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -167725,9 +168642,9 @@ var ts; return new RegExp(regExpString, "gim"); } function isLetterOrDigit(char) { - return (char >= 97 /* a */ && char <= 122 /* z */) || - (char >= 65 /* A */ && char <= 90 /* Z */) || - (char >= 48 /* _0 */ && char <= 57 /* _9 */); + return (char >= 97 /* CharacterCodes.a */ && char <= 122 /* CharacterCodes.z */) || + (char >= 65 /* CharacterCodes.A */ && char <= 90 /* CharacterCodes.Z */) || + (char >= 48 /* CharacterCodes._0 */ && char <= 57 /* CharacterCodes._9 */); } function isNodeModulesFile(path) { return ts.stringContains(path, "/node_modules/"); @@ -167862,6 +168779,7 @@ var ts; getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getProgram: getProgram, + getCurrentProgram: function () { return program; }, getAutoImportProvider: getAutoImportProvider, updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols, getApplicableRefactors: getApplicableRefactors, @@ -167884,14 +168802,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidOperationsInPartialSemanticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.PartialSemantic")); }; }); break; case ts.LanguageServiceMode.Syntactic: invalidOperationsInSyntacticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.Syntactic")); }; }); break; @@ -167938,7 +168856,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 277 /* ExternalModuleReference */ || + node.parent.kind === 277 /* SyntaxKind.ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -167953,16 +168871,16 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 162 /* ComputedPropertyName */) { + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 205 /* ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* JsxAttributes */) && + (node.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* SyntaxKind.JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -168004,7 +168922,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 207 /* ElementAccessExpression */ && + node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -168051,7 +168969,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 16777216 /* Ambient */) { + if (tokenAtLocation.flags & 16777216 /* NodeFlags.Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -168097,144 +169015,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return spanInVariableDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return spanInParameterDeclaration(node); - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return spanInFunctionDeclaration(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanInBlock(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInBlock(node.block); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: // span in statement return spanInNode(node.statement); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return spanInForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // span on complete module if it is instantiated - if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 203 /* BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 203 /* SyntaxKind.BindingElement */: // span on complete node return textSpan(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: // span in statement return spanInNode(node.statement); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return spanInNodeArray(parent.modifiers, node, ts.isDecorator); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return undefined; // Tokens: - case 26 /* SemicolonToken */: - case 1 /* EndOfFileToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return spanInPreviousNode(node); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return spanInOpenBraceToken(node); - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: return spanInCloseBraceToken(node); - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: return spanInCloseBracketToken(node); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return spanInOpenParenToken(node); - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: return spanInCloseParenToken(node); - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: return spanInColonToken(node); - case 31 /* GreaterThanToken */: - case 29 /* LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return spanInWhileKeyword(node); - case 91 /* ElseKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return spanInNextNode(node); - case 160 /* OfKeyword */: + case 160 /* SyntaxKind.OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -168246,14 +169164,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 79 /* Identifier */ || - node.kind === 225 /* SpreadElement */ || - node.kind === 296 /* PropertyAssignment */ || - node.kind === 297 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 225 /* SyntaxKind.SpreadElement */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 221 /* BinaryExpression */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -168262,35 +169180,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or // { a = expression, b, c } = someExpression return textSpan(node); } - if (operatorToken.kind === 27 /* CommaToken */) { + if (operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return textSpan(node); - case 221 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 27 /* CommaToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -168299,21 +169217,21 @@ var ts; } } switch (node.parent.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -168321,7 +169239,7 @@ var ts; } break; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -168351,7 +169269,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 243 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -168362,8 +169280,8 @@ var ts; // Breakpoint is possible in variableDeclaration only if there is initialization // or its declaration from 'for of' if ((ts.hasOnlyExpressionInitializer(variableDeclaration) && variableDeclaration.initializer) || - ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 244 /* ForOfStatement */) { + ts.hasSyntacticModifier(variableDeclaration, 1 /* ModifierFlags.Export */) || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -168378,7 +169296,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - ts.hasSyntacticModifier(parameter, 4 /* Public */ | 8 /* Private */); + ts.hasSyntacticModifier(parameter, 4 /* ModifierFlags.Public */ | 8 /* ModifierFlags.Private */); } function spanInParameterDeclaration(parameter) { if (ts.isBindingPattern(parameter.name)) { @@ -168403,8 +169321,8 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 257 /* ClassDeclaration */ && functionDeclaration.kind !== 171 /* Constructor */); + return ts.hasSyntacticModifier(functionDeclaration, 1 /* ModifierFlags.Export */) || + (functionDeclaration.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && functionDeclaration.kind !== 171 /* SyntaxKind.Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -168427,26 +169345,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 261 /* ModuleDeclaration */: - if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { + case 261 /* SyntaxKind.ModuleDeclaration */: + if (ts.getModuleInstanceState(block.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 243 /* ForInStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -168471,21 +169389,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 203 /* BindingElement */) { + if (bindingPattern.parent.kind === 203 /* SyntaxKind.BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 202 /* ArrayBindingPattern */ && node.kind !== 201 /* ObjectBindingPattern */); - var elements = node.kind === 204 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 202 /* SyntaxKind.ArrayBindingPattern */ && node.kind !== 201 /* SyntaxKind.ObjectBindingPattern */); + var elements = node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -168493,18 +169411,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 221 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -168512,25 +169430,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: // If this is not an instantiated module block, no bp span - if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 260 /* EnumDeclaration */: - case 257 /* ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // Span on close brace token return textSpan(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -168538,7 +169456,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -168554,7 +169472,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -168569,12 +169487,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 240 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 208 /* CallExpression */ || - node.parent.kind === 209 /* NewExpression */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 208 /* SyntaxKind.CallExpression */ || + node.parent.kind === 209 /* SyntaxKind.NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 212 /* ParenthesizedExpression */) { + if (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -168583,21 +169501,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 212 /* ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -168607,20 +169525,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ || - node.parent.kind === 164 /* Parameter */) { + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.parent.kind === 164 /* SyntaxKind.Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 211 /* TypeAssertionExpression */) { + if (node.parent.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 240 /* DoStatement */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -168628,7 +169546,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -168796,7 +169714,7 @@ var ts; return this.shimHost.getScriptKind(fileName); // TODO: GH#18217 } else { - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } }; LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { @@ -168886,13 +169804,13 @@ var ts; var result = action(); if (logPerformance) { var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); + logger.log("".concat(actionDescription, " completed in ").concat(end - start, " msec")); if (ts.isString(result)) { var str = result; if (str.length > 128) { str = str.substring(0, 128) + "..."; } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + logger.log(" result.length=".concat(str.length, ", result='").concat(JSON.stringify(str), "'")); } } return result; @@ -168974,7 +169892,7 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + this.forwardJSONCall("refresh(".concat(throwOnError, ")"), function () { return null; } // eslint-disable-line no-null/no-null ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { @@ -168990,43 +169908,43 @@ var ts; }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSyntacticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSemanticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSuggestionDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSuggestionDiagnostics('" + fileName + "')", function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); + return this.forwardJSONCall("getSuggestionDiagnostics('".concat(fileName, "')"), function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); }; LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { var _this = this; @@ -169042,7 +169960,7 @@ var ts; */ LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + return this.forwardJSONCall("getQuickInfoAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); }; /// NAMEORDOTTEDNAMESPAN /** @@ -169051,7 +169969,7 @@ var ts; */ LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + return this.forwardJSONCall("getNameOrDottedNameSpan('".concat(fileName, "', ").concat(startPos, ", ").concat(endPos, ")"), function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); }; /** * STATEMENTSPAN @@ -169059,12 +169977,12 @@ var ts; */ LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + return this.forwardJSONCall("getBreakpointStatementAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); + return this.forwardJSONCall("getSignatureHelpItems('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** @@ -169073,7 +169991,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); }; /** * Computes the definition location and file for the symbol @@ -169081,7 +169999,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAndBoundSpan = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAndBoundSpan('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); + return this.forwardJSONCall("getDefinitionAndBoundSpan('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); }; /// GOTO Type /** @@ -169090,7 +170008,7 @@ var ts; */ LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getTypeDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); }; /// GOTO Implementation /** @@ -169099,37 +170017,37 @@ var ts; */ LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + return this.forwardJSONCall("getImplementationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) { var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); }); + return this.forwardJSONCall("getRenameInfo('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getRenameInfo(fileName, position, preferences); }); }; LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getSmartSelectionRange('" + fileName + "', " + position + ")", function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); + return this.forwardJSONCall("getSmartSelectionRange('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); }; LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename) { var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ", " + providePrefixAndSuffixTextForRename + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); + return this.forwardJSONCall("findRenameLocations('".concat(fileName, "', ").concat(position, ", ").concat(findInStrings, ", ").concat(findInComments, ", ").concat(providePrefixAndSuffixTextForRename, ")"), function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); }; /// GET BRACE MATCHING LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + return this.forwardJSONCall("getBraceMatchingAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(openingBrace, ")"), function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { var _this = this; - return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + return this.forwardJSONCall("getSpanOfEnclosingComment('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getIndentationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); }); @@ -169137,23 +170055,23 @@ var ts; /// GET REFERENCES LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getReferencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + return this.forwardJSONCall("findReferences('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.findReferences(fileName, position); }); }; LanguageServiceShimObject.prototype.getFileReferences = function (fileName) { var _this = this; - return this.forwardJSONCall("getFileReferences('" + fileName + ")", function () { return _this.languageService.getFileReferences(fileName); }); + return this.forwardJSONCall("getFileReferences('".concat(fileName, ")"), function () { return _this.languageService.getFileReferences(fileName); }); }; LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getOccurrencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getDocumentHighlights('".concat(fileName, "', ").concat(position, ")"), function () { var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); // workaround for VS document highlighting issue - keep only items from the initial file var normalizedName = ts.toFileNameLowerCase(ts.normalizeSlashes(fileName)); @@ -169168,108 +170086,108 @@ var ts; */ LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) { var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); + return this.forwardJSONCall("getCompletionsAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(preferences, ", ").concat(formattingSettings, ")"), function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); }; /** Get a string based representation of a completion list entry details */ LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { + return this.forwardJSONCall("getCompletionEntryDetails('".concat(fileName, "', ").concat(position, ", '").concat(entryName, "')"), function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + return this.forwardJSONCall("getFormattingEditsForRange('".concat(fileName, "', ").concat(start, ", ").concat(end, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + return this.forwardJSONCall("getFormattingEditsForDocument('".concat(fileName, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('".concat(fileName, "', ").concat(position, ", '").concat(key, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + return this.forwardJSONCall("getNavigateToItems('".concat(searchValue, "', ").concat(maxResultCount, ", ").concat(fileName, ")"), function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); }; LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + return this.forwardJSONCall("getNavigationBarItems('".concat(fileName, "')"), function () { return _this.languageService.getNavigationBarItems(fileName); }); }; LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + return this.forwardJSONCall("getNavigationTree('".concat(fileName, "')"), function () { return _this.languageService.getNavigationTree(fileName); }); }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + return this.forwardJSONCall("getOutliningSpans('".concat(fileName, "')"), function () { return _this.languageService.getOutliningSpans(fileName); }); }; LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + return this.forwardJSONCall("getTodoComments('".concat(fileName, "')"), function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); }; /// CALL HIERARCHY LanguageServiceShimObject.prototype.prepareCallHierarchy = function (fileName, position) { var _this = this; - return this.forwardJSONCall("prepareCallHierarchy('" + fileName + "', " + position + ")", function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); + return this.forwardJSONCall("prepareCallHierarchy('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyIncomingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyIncomingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyIncomingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyOutgoingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideInlayHints = function (fileName, span, preference) { var _this = this; - return this.forwardJSONCall("provideInlayHints('" + fileName + "', '" + JSON.stringify(span) + "', " + JSON.stringify(preference) + ")", function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); + return this.forwardJSONCall("provideInlayHints('".concat(fileName, "', '").concat(JSON.stringify(span), "', ").concat(JSON.stringify(preference), ")"), function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); }; /// Emit LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + return this.forwardJSONCall("getEmitOutput('".concat(fileName, "')"), function () { var _a = _this.languageService.getEmitOutput(fileName), diagnostics = _a.diagnostics, rest = __rest(_a, ["diagnostics"]); return __assign(__assign({}, rest), { diagnostics: _this.realizeDiagnostics(diagnostics) }); }); }; LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", + return forwardCall(this.logger, "getEmitOutput('".concat(fileName, "')"), /*returnJson*/ false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); }; LanguageServiceShimObject.prototype.toggleLineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleLineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleLineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleLineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleLineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.toggleMultilineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleMultilineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleMultilineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.commentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("commentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.commentSelection(fileName, textRange); }); + return this.forwardJSONCall("commentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.commentSelection(fileName, textRange); }); }; LanguageServiceShimObject.prototype.uncommentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("uncommentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.uncommentSelection(fileName, textRange); }); + return this.forwardJSONCall("uncommentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.uncommentSelection(fileName, textRange); }); }; return LanguageServiceShimObject; }(ShimBase)); @@ -169319,11 +170237,11 @@ var ts; }; CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + return this.forwardJSONCall("resolveModuleName('".concat(fileName, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) { + if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Extension.Ts */ && result.resolvedModule.extension !== ".tsx" /* Extension.Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Extension.Dts */) { resolvedFileName = undefined; } return { @@ -169335,7 +170253,7 @@ var ts; }; CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + return this.forwardJSONCall("resolveTypeReferenceDirective(".concat(fileName, ")"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); return { @@ -169347,7 +170265,7 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getPreProcessedFileInfo('".concat(fileName, "')"), function () { // for now treat files as JavaScript var result = ts.preProcessFile(ts.getSnapshotText(sourceTextSnapshot), /* readImportFiles */ true, /* detectJavaScriptImports */ true); return { @@ -169362,7 +170280,7 @@ var ts; }; CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('".concat(compilerOptionsJson, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); }); @@ -169384,7 +170302,7 @@ var ts; }; CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getTSConfigFileInfo('".concat(fileName, "')"), function () { var result = ts.parseJsonText(fileName, ts.getSnapshotText(sourceTextSnapshot)); var normalizedFileName = ts.normalizeSlashes(fileName); var configFile = ts.parseJsonSourceFileConfigFileContent(result, _this.host, ts.getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName); @@ -169574,7 +170492,7 @@ var ts; } Errors.ThrowProjectLanguageServiceDisabled = ThrowProjectLanguageServiceDisabled; function ThrowProjectDoesNotContainDocument(fileName, project) { - throw new Error("Project '" + project.getProjectName() + "' does not contain document '" + fileName + "'"); + throw new Error("Project '".concat(project.getProjectName(), "' does not contain document '").concat(fileName, "'")); } Errors.ThrowProjectDoesNotContainDocument = ThrowProjectDoesNotContainDocument; })(Errors = server.Errors || (server.Errors = {})); @@ -169615,17 +170533,17 @@ var ts; } server.isInferredProjectName = isInferredProjectName; function makeInferredProjectName(counter) { - return "/dev/null/inferredProject" + counter + "*"; + return "/dev/null/inferredProject".concat(counter, "*"); } server.makeInferredProjectName = makeInferredProjectName; /*@internal*/ function makeAutoImportProviderProjectName(counter) { - return "/dev/null/autoImportProviderProject" + counter + "*"; + return "/dev/null/autoImportProviderProject".concat(counter, "*"); } server.makeAutoImportProviderProjectName = makeAutoImportProviderProjectName; /*@internal*/ function makeAuxiliaryProjectName(counter) { - return "/dev/null/auxiliaryProject" + counter + "*"; + return "/dev/null/auxiliaryProject".concat(counter, "*"); } server.makeAuxiliaryProjectName = makeAuxiliaryProjectName; function createSortedArray() { @@ -169660,7 +170578,7 @@ var ts; // schedule new operation, pass arguments this.pendingTimeouts.set(operationId, this.host.setTimeout(ThrottledOperations.run, delay, this, operationId, cb)); if (this.logger) { - this.logger.info("Scheduled: " + operationId + (pendingTimeout ? ", Cancelled earlier one" : "")); + this.logger.info("Scheduled: ".concat(operationId).concat(pendingTimeout ? ", Cancelled earlier one" : "")); } }; ThrottledOperations.prototype.cancel = function (operationId) { @@ -169674,7 +170592,7 @@ var ts; ts.perfLogger.logStartScheduledOperation(operationId); self.pendingTimeouts.delete(operationId); if (self.logger) { - self.logger.info("Running: " + operationId); + self.logger.info("Running: ".concat(operationId)); } cb(); ts.perfLogger.logStopScheduledOperation(); @@ -169703,7 +170621,7 @@ var ts; self.host.gc(); // TODO: GH#18217 if (log) { var after = self.host.getMemoryUsage(); // TODO: GH#18217 - self.logger.perftrc("GC::before " + before + ", after " + after); + self.logger.perftrc("GC::before ".concat(before, ", after ").concat(after)); } ts.perfLogger.logStopScheduledOperation(); }; @@ -170047,8 +170965,8 @@ var ts; } TextStorage.prototype.getVersion = function () { return this.svc - ? "SVC-" + this.version.svc + "-" + this.svc.getSnapshotVersion() - : "Text-" + this.version.text; + ? "SVC-".concat(this.version.svc, "-").concat(this.svc.getSnapshotVersion()) + : "Text-".concat(this.version.text); }; TextStorage.prototype.hasScriptVersionCache_TestOnly = function () { return this.svc !== undefined; @@ -170191,7 +171109,7 @@ var ts; if (fileSize > server.maxFileSize) { ts.Debug.assert(!!this.info.containingProjects.length); var service = this.info.containingProjects[0].projectService; - service.logger.info("Skipped loading contents of large file " + fileName + " for info " + this.info.fileName + ": fileSize: " + fileSize); + service.logger.info("Skipped loading contents of large file ".concat(fileName, " for info ").concat(this.info.fileName, ": fileSize: ").concat(fileSize)); this.info.containingProjects[0].projectService.sendLargeFileReferencedEvent(fileName, fileSize); return { text: "", fileSize: fileSize }; } @@ -170544,7 +171462,7 @@ var ts; return location; }; ScriptInfo.prototype.isJavaScript = function () { - return this.scriptKind === 1 /* JS */ || this.scriptKind === 2 /* JSX */; + return this.scriptKind === 1 /* ScriptKind.JS */ || this.scriptKind === 2 /* ScriptKind.JSX */; }; /*@internal*/ ScriptInfo.prototype.getLineInfo = function () { @@ -170572,14 +171490,14 @@ var ts; return project; } function failIfInvalidPosition(position) { - ts.Debug.assert(typeof position === "number", "Expected position " + position + " to be a number."); + ts.Debug.assert(typeof position === "number", "Expected position ".concat(position, " to be a number.")); ts.Debug.assert(position >= 0, "Expected position to be non-negative."); } function failIfInvalidLocation(location) { - ts.Debug.assert(typeof location.line === "number", "Expected line " + location.line + " to be a number."); - ts.Debug.assert(typeof location.offset === "number", "Expected offset " + location.offset + " to be a number."); - ts.Debug.assert(location.line > 0, "Expected line to be non-" + (location.line === 0 ? "zero" : "negative")); - ts.Debug.assert(location.offset > 0, "Expected offset to be non-" + (location.offset === 0 ? "zero" : "negative")); + ts.Debug.assert(typeof location.line === "number", "Expected line ".concat(location.line, " to be a number.")); + ts.Debug.assert(typeof location.offset === "number", "Expected offset ".concat(location.offset, " to be a number.")); + ts.Debug.assert(location.line > 0, "Expected line to be non-".concat(location.line === 0 ? "zero" : "negative")); + ts.Debug.assert(location.offset > 0, "Expected offset to be non-".concat(location.offset === 0 ? "zero" : "negative")); } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); @@ -170723,15 +171641,15 @@ var ts; var info = infos_1[_i]; var fileSize = includeSizes ? info.getTelemetryFileSize() : 0; switch (info.scriptKind) { - case 1 /* JS */: + case 1 /* ScriptKind.JS */: result.js += 1; result.jsSize += fileSize; break; - case 2 /* JSX */: + case 2 /* ScriptKind.JSX */: result.jsx += 1; result.jsxSize += fileSize; break; - case 3 /* TS */: + case 3 /* ScriptKind.TS */: if (ts.isDeclarationFileName(info.fileName)) { result.dts += 1; result.dtsSize += fileSize; @@ -170741,11 +171659,11 @@ var ts; result.tsSize += fileSize; } break; - case 4 /* TSX */: + case 4 /* ScriptKind.TSX */: result.tsx += 1; result.tsxSize += fileSize; break; - case 7 /* Deferred */: + case 7 /* ScriptKind.Deferred */: result.deferred += 1; result.deferredSize += fileSize; break; @@ -170770,7 +171688,7 @@ var ts; server.allFilesAreJsOrDts = allFilesAreJsOrDts; /* @internal */ function hasNoTypeScriptSource(fileNames) { - return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Ts */) && !ts.isDeclarationFileName(fileName)) || ts.fileExtensionIs(fileName, ".tsx" /* Tsx */); }); + return !fileNames.some(function (fileName) { return (ts.fileExtensionIs(fileName, ".ts" /* Extension.Ts */) && !ts.isDeclarationFileName(fileName)) || ts.fileExtensionIs(fileName, ".tsx" /* Extension.Tsx */); }); } server.hasNoTypeScriptSource = hasNoTypeScriptSource; function isGeneratedFileWatcher(watch) { @@ -170892,11 +171810,11 @@ var ts; }; Project.resolveModule = function (moduleName, initialDir, host, log, logErrors) { var resolvedPath = ts.normalizeSlashes(host.resolvePath(ts.combinePaths(initialDir, "node_modules"))); - log("Loading " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); + log("Loading ".concat(moduleName, " from ").concat(initialDir, " (resolved to ").concat(resolvedPath, ")")); var result = host.require(resolvedPath, moduleName); // TODO: GH#18217 if (result.error) { var err = result.error.stack || result.error.message || JSON.stringify(result.error); - (logErrors || log)("Failed to load module '" + moduleName + "' from " + resolvedPath + ": " + err); + (logErrors || log)("Failed to load module '".concat(moduleName, "' from ").concat(resolvedPath, ": ").concat(err)); return undefined; } return result.module; @@ -170910,7 +171828,7 @@ var ts; case 0: ts.Debug.assertIsDefined(host.importServicePlugin); resolvedPath = ts.combinePaths(initialDir, "node_modules"); - log("Dynamically importing " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")"); + log("Dynamically importing ".concat(moduleName, " from ").concat(initialDir, " (resolved to ").concat(resolvedPath, ")")); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); @@ -170925,7 +171843,7 @@ var ts; case 4: if (result.error) { err = result.error.stack || result.error.message || JSON.stringify(result.error); - (logErrors || log)("Failed to dynamically import module '" + moduleName + "' from " + resolvedPath + ": " + err); + (logErrors || log)("Failed to dynamically import module '".concat(moduleName, "' from ").concat(resolvedPath, ": ").concat(err)); return [2 /*return*/, undefined]; } return [2 /*return*/, result.module]; @@ -171079,16 +171997,16 @@ var ts; }; /*@internal*/ Project.prototype.watchAffectingFileLocation = function (file, cb) { - return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.PackageJson, this); + return this.projectService.watchFactory.watchFile(file, cb, ts.PollingInterval.High, this.projectService.getWatchOptions(this), ts.WatchType.AffectingFileLocation, this); }; /*@internal*/ Project.prototype.clearInvalidateResolutionOfFailedLookupTimer = function () { - return this.projectService.throttledOperations.cancel(this.getProjectName() + "FailedLookupInvalidation"); + return this.projectService.throttledOperations.cancel("".concat(this.getProjectName(), "FailedLookupInvalidation")); }; /*@internal*/ Project.prototype.scheduleInvalidateResolutionsOfFailedLookupLocations = function () { var _this = this; - this.projectService.throttledOperations.schedule(this.getProjectName() + "FailedLookupInvalidation", /*delay*/ 1000, function () { + this.projectService.throttledOperations.schedule("".concat(this.getProjectName(), "FailedLookupInvalidation"), /*delay*/ 1000, function () { if (_this.resolutionCache.invalidateResolutionsOfFailedLookupLocations()) { _this.projectService.delayUpdateProjectGraphAndEnsureProjectStructureForOpenFiles(_this); } @@ -171192,7 +172110,7 @@ var ts; } server.updateProjectIfDirty(this); this.builderState = ts.BuilderState.create(this.program, this.projectService.toCanonicalFileName, this.builderState, /*disableUseFileVersionAsSignature*/ true); - return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, ts.maybeBind(this.projectService.host, this.projectService.host.createHash)), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; }); + return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, ts.maybeBind(this.projectService.host, this.projectService.host.createHash), this.getCanonicalFileName), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; }); }; /** * Returns true if emit was conducted @@ -171266,7 +172184,7 @@ var ts; return plugin.module.getExternalFiles(_this); } catch (e) { - _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); + _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: ".concat(e)); if (e.stack) { _this.projectService.logger.info(e.stack); } @@ -171373,7 +172291,7 @@ var ts; } return ts.map(this.program.getSourceFiles(), function (sourceFile) { var scriptInfo = _this.projectService.getScriptInfoForPath(sourceFile.resolvedPath); - ts.Debug.assert(!!scriptInfo, "getScriptInfo", function () { return "scriptInfo for a file '" + sourceFile.fileName + "' Path: '" + sourceFile.path + "' / '" + sourceFile.resolvedPath + "' is missing."; }); + ts.Debug.assert(!!scriptInfo, "getScriptInfo", function () { return "scriptInfo for a file '".concat(sourceFile.fileName, "' Path: '").concat(sourceFile.path, "' / '").concat(sourceFile.resolvedPath, "' is missing."); }); return scriptInfo; }); }; @@ -171547,7 +172465,7 @@ var ts; */ Project.prototype.updateGraph = function () { var _a; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] }); ts.perfLogger.logStartUpdateGraph(); this.resolutionCache.startRecordingFilesWithChangedResolutions(); var hasNewProgram = this.updateGraphWorker(); @@ -171616,23 +172534,23 @@ var ts; }; Project.prototype.updateGraphWorker = function () { var _this = this; - var oldProgram = this.program; + var oldProgram = this.languageService.getCurrentProgram(); ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project"); - this.writeLog("Starting updateGraphWorker: Project: " + this.getProjectName()); + this.writeLog("Starting updateGraphWorker: Project: ".concat(this.getProjectName())); var start = ts.timestamp(); this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution(); this.resolutionCache.startCachingPerDirectoryResolution(); this.program = this.languageService.getProgram(); // TODO: GH#18217 this.dirty = false; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution"); - this.resolutionCache.finishCachingPerDirectoryResolution(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "finishCachingPerDirectoryResolution"); + this.resolutionCache.finishCachingPerDirectoryResolution(this.program, oldProgram); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); ts.Debug.assert(oldProgram === undefined || this.program !== undefined); // bump up the version if // - oldProgram is not set - this is a first time updateGraph is called // - newProgram is different from the old program and structure of the old program was not reused. var hasNewProgram = false; - if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 2 /* Completely */))) { + if (this.program && (!oldProgram || (this.program !== oldProgram && this.program.structureIsReused !== 2 /* StructureIsReused.Completely */))) { hasNewProgram = true; if (oldProgram) { for (var _i = 0, _a = oldProgram.getSourceFiles(); _i < _a.length; _i++) { @@ -171658,7 +172576,7 @@ var ts; var outPath = ts.outFile(this.compilerOptions); if (isGeneratedFileWatcher(this.generatedFilesMap)) { // --out - if (!outPath || !this.isValidGeneratedFileWatcher(ts.removeFileExtension(outPath) + ".d.ts" /* Dts */, this.generatedFilesMap)) { + if (!outPath || !this.isValidGeneratedFileWatcher(ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */, this.generatedFilesMap)) { this.clearGeneratedFileWatch(); } } @@ -171722,7 +172640,7 @@ var ts; }, function (removed) { return _this.detachScriptInfoFromProject(removed); }); var elapsed = ts.timestamp() - start; this.sendPerformanceEvent("UpdateGraph", elapsed); - this.writeLog("Finishing updateGraphWorker: Project: " + this.getProjectName() + " Version: " + this.getProjectVersion() + " structureChanged: " + hasNewProgram + (this.program ? " structureIsReused:: " + ts.StructureIsReused[this.program.structureIsReused] : "") + " Elapsed: " + elapsed + "ms"); + this.writeLog("Finishing updateGraphWorker: Project: ".concat(this.getProjectName(), " Version: ").concat(this.getProjectVersion(), " structureChanged: ").concat(hasNewProgram).concat(this.program ? " structureIsReused:: ".concat(ts.StructureIsReused[this.program.structureIsReused]) : "", " Elapsed: ").concat(elapsed, "ms")); if (this.hasAddedorRemovedFiles) { this.print(/*writeProjectFileNames*/ true); } @@ -171782,7 +172700,7 @@ var ts; var path = this.toPath(sourceFile); if (this.generatedFilesMap) { if (isGeneratedFileWatcher(this.generatedFilesMap)) { - ts.Debug.fail(this.projectName + " Expected to not have --out watcher for generated file with options: " + JSON.stringify(this.compilerOptions)); + ts.Debug.fail("".concat(this.projectName, " Expected to not have --out watcher for generated file with options: ").concat(JSON.stringify(this.compilerOptions))); return; } if (this.generatedFilesMap.has(path)) @@ -171834,20 +172752,20 @@ var ts; if (!this.program) return "\tFiles (0) NoProgram\n"; var sourceFiles = this.program.getSourceFiles(); - var strBuilder = "\tFiles (" + sourceFiles.length + ")\n"; + var strBuilder = "\tFiles (".concat(sourceFiles.length, ")\n"); if (writeProjectFileNames) { for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var file = sourceFiles_1[_i]; - strBuilder += "\t" + file.fileName + "\n"; + strBuilder += "\t".concat(file.fileName, "\n"); } strBuilder += "\n\n"; - ts.explainFiles(this.program, function (s) { return strBuilder += "\t" + s + "\n"; }); + ts.explainFiles(this.program, function (s) { return strBuilder += "\t".concat(s, "\n"); }); } return strBuilder; }; /*@internal*/ Project.prototype.print = function (writeProjectFileNames) { - this.writeLog("Project '" + this.projectName + "' (" + ProjectKind[this.projectKind] + ")"); + this.writeLog("Project '".concat(this.projectName, "' (").concat(ProjectKind[this.projectKind], ")")); this.writeLog(this.filesToString(writeProjectFileNames && this.projectService.logger.hasLevel(server.LogLevel.verbose))); this.writeLog("-----------------------------------------------"); if (this.autoImportProviderHost) { @@ -172011,7 +172929,7 @@ var ts; if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) return "continue"; // Provide global: true so plugins can detect why they can't find their config - this_1.projectService.logger.info("Loading global plugin " + globalPluginName); + this_1.projectService.logger.info("Loading global plugin ".concat(globalPluginName)); this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides); }; var this_1 = this; @@ -172094,7 +173012,7 @@ var ts; } else { ts.forEach(errorLogs, function (message) { return _this.projectService.logger.info(message); }); - this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name); + this.projectService.logger.info("Couldn't find ".concat(pluginConfigEntry.name)); } }; Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) { @@ -172103,7 +173021,7 @@ var ts; Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { if (typeof pluginModuleFactory !== "function") { - this.projectService.logger.info("Skipped loading plugin " + configEntry.name + " because it did not expose a proper factory function"); + this.projectService.logger.info("Skipped loading plugin ".concat(configEntry.name, " because it did not expose a proper factory function")); return; } var info = { @@ -172120,7 +173038,7 @@ var ts; var k = _a[_i]; // eslint-disable-next-line no-in-operator if (!(k in newLS)) { - this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); + this.projectService.logger.info("Plugin activation warning: Missing proxied method ".concat(k, " in created LS. Patching.")); newLS[k] = this.languageService[k]; } } @@ -172129,7 +173047,7 @@ var ts; this.plugins.push({ name: configEntry.name, module: pluginModule }); } catch (e) { - this.projectService.logger.info("Plugin activation failed: " + e); + this.projectService.logger.info("Plugin activation failed: ".concat(e)); } }; /*@internal*/ @@ -172179,11 +173097,11 @@ var ts; }; /*@internal*/ Project.prototype.includePackageJsonAutoImports = function () { - if (this.projectService.includePackageJsonAutoImports() === 0 /* Off */ || + if (this.projectService.includePackageJsonAutoImports() === 0 /* PackageJsonAutoImportPreference.Off */ || !this.languageServiceEnabled || ts.isInsideNodeModules(this.currentDirectory) || !this.isDefaultProjectForOpenFiles()) { - return 0 /* Off */; + return 0 /* PackageJsonAutoImportPreference.Off */; } return this.projectService.includePackageJsonAutoImports(); }; @@ -172224,7 +173142,7 @@ var ts; } var dependencySelection = this.includePackageJsonAutoImports(); if (dependencySelection) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getPackageJsonAutoImportProvider"); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "getPackageJsonAutoImportProvider"); var start = ts.timestamp(); this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getModuleResolutionHostForAutoImportProvider(), this.documentRegistry); if (this.autoImportProviderHost) { @@ -172279,7 +173197,7 @@ var ts; server.Project = Project; function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) { var sourceFiles = program.getSourceFiles(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getUnresolvedImports", { count: sourceFiles.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "getUnresolvedImports", { count: sourceFiles.length }); var ambientModules = program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); }); var result = ts.sortAndDeduplicate(ts.flatMap(sourceFiles, function (sourceFile) { return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile); @@ -172448,8 +173366,8 @@ var ts; var symlinkCache_1 = hostProject.getSymlinkCache(); var _loop_2 = function (name) { // Avoid creating a large project that would significantly slow down time to editor interactivity - if (dependencySelection === 2 /* Auto */ && dependenciesAdded > this_2.maxDependencies) { - hostProject.log("AutoImportProviderProject: attempted to add more than " + this_2.maxDependencies + " dependencies. Aborting."); + if (dependencySelection === 2 /* PackageJsonAutoImportPreference.Auto */ && dependenciesAdded > this_2.maxDependencies) { + hostProject.log("AutoImportProviderProject: attempted to add more than ".concat(this_2.maxDependencies, " dependencies. Aborting.")); return { value: ts.emptyArray }; } // 1. Try to load from the implementation package. For many dependencies, the @@ -172469,7 +173387,7 @@ var ts; // typings cache location, if enabled. var done = ts.forEach([hostProject.currentDirectory, hostProject.getGlobalTypingsCacheLocation()], function (directory) { if (directory) { - var typesPackageJson = ts.resolvePackageNameToPackageJson("@types/" + name, directory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache()); + var typesPackageJson = ts.resolvePackageNameToPackageJson("@types/".concat(name), directory, compilerOptions, moduleResolutionHost, program.getModuleResolutionCache()); if (typesPackageJson) { var entrypoints = getRootNamesFromPackageJson(typesPackageJson, program, symlinkCache_1); rootNames = ts.concatenate(rootNames, entrypoints); @@ -172498,7 +173416,7 @@ var ts; } } if (rootNames === null || rootNames === void 0 ? void 0 : rootNames.length) { - hostProject.log("AutoImportProviderProject: found " + rootNames.length + " root files in " + dependenciesAdded + " dependencies in " + (ts.timestamp() - start) + " ms"); + hostProject.log("AutoImportProviderProject: found ".concat(rootNames.length, " root files in ").concat(dependenciesAdded, " dependencies in ").concat(ts.timestamp() - start, " ms")); } return rootNames || ts.emptyArray; function addDependency(dependency) { @@ -172529,7 +173447,7 @@ var ts; }; /*@internal*/ AutoImportProviderProject.create = function (dependencySelection, hostProject, moduleResolutionHost, documentRegistry) { - if (dependencySelection === 0 /* Off */) { + if (dependencySelection === 0 /* PackageJsonAutoImportPreference.Off */) { return undefined; } var compilerOptions = __assign(__assign({}, hostProject.getCompilerOptions()), this.compilerOptionsOverrides); @@ -172595,7 +173513,7 @@ var ts; }; /*@internal*/ AutoImportProviderProject.prototype.includePackageJsonAutoImports = function () { - return 0 /* Off */; + return 0 /* PackageJsonAutoImportPreference.Off */; }; AutoImportProviderProject.prototype.getTypeAcquisition = function () { return { enable: false }; @@ -172760,7 +173678,7 @@ var ts; var searchPaths = __spreadArray([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations, true); if (this.projectService.allowLocalPluginLoads) { var local = ts.getDirectoryPath(this.canonicalConfigFilePath); - this.projectService.logger.info("Local plugin loading enabled; adding " + local + " to search paths"); + this.projectService.logger.info("Local plugin loading enabled; adding ".concat(local, " to search paths")); searchPaths.unshift(local); } // Enable tsconfig-specified plugins @@ -173039,15 +173957,15 @@ var ts; function convertScriptKindName(scriptKindName) { switch (scriptKindName) { case "JS": - return 1 /* JS */; + return 1 /* ScriptKind.JS */; case "JSX": - return 2 /* JSX */; + return 2 /* ScriptKind.JSX */; case "TS": - return 3 /* TS */; + return 3 /* ScriptKind.TS */; case "TSX": - return 4 /* TSX */; + return 4 /* ScriptKind.TSX */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } server.convertScriptKindName = convertScriptKindName; @@ -173186,7 +174104,7 @@ var ts; return forEachAnyProjectReferenceKind(project, function (resolvedRef) { return callbackRefProject(project, cb, resolvedRef.sourceFile.path); }, function (projectRef) { return callbackRefProject(project, cb, project.toPath(ts.resolveProjectReferencePath(projectRef))); }, function (potentialProjectRef) { return callbackRefProject(project, cb, potentialProjectRef); }); } function getDetailWatchInfo(watchType, project) { - return (ts.isString(project) ? "Config: " + project + " " : project ? "Project: " + project.getProjectName() + " " : "") + "WatchType: " + watchType; + return "".concat(ts.isString(project) ? "Config: ".concat(project, " ") : project ? "Project: ".concat(project.getProjectName(), " ") : "", "WatchType: ").concat(watchType); } function isScriptInfoWatchedFromNodeModules(info) { return !info.isScriptOpen() && info.mTime !== undefined; @@ -173393,7 +174311,7 @@ var ts; try { var fileContent = this.host.readFile(this.typesMapLocation); // TODO: GH#18217 if (fileContent === undefined) { - this.logger.info("Provided types map file \"" + this.typesMapLocation + "\" doesn't exist"); + this.logger.info("Provided types map file \"".concat(this.typesMapLocation, "\" doesn't exist")); return; } var raw = JSON.parse(fileContent); @@ -173411,7 +174329,7 @@ var ts; } } catch (e) { - this.logger.info("Error loading types map: " + e); + this.logger.info("Error loading types map: ".concat(e)); this.safelist = defaultTypeSafeList; this.legacySafelist.clear(); } @@ -173735,7 +174653,7 @@ var ts; var fsResult = config.cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); if (ts.getBaseFileName(fileOrDirectoryPath) === "package.json" && !ts.isInsideNodeModules(fileOrDirectoryPath) && (fsResult && fsResult.fileExists || !fsResult && _this.host.fileExists(fileOrDirectoryPath))) { - _this.logger.info("Config: " + configFileName + " Detected new package.json: " + fileOrDirectory); + _this.logger.info("Config: ".concat(configFileName, " Detected new package.json: ").concat(fileOrDirectory)); _this.onAddPackageJson(fileOrDirectoryPath); } var configuredProjectForConfig = _this.findConfiguredProjectByProjectName(configFileName); @@ -173857,14 +174775,14 @@ var ts; this.logger.info("`remove Project::"); project.print(/*writeProjectFileNames*/ true); project.close(); - if (ts.Debug.shouldAssert(1 /* Normal */)) { - this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project), "Found script Info still attached to project", function () { return project.projectName + ": ScriptInfos still attached: " + JSON.stringify(ts.arrayFrom(ts.mapDefinedIterator(_this.filenameToScriptInfo.values(), function (info) { return info.isAttached(project) ? + if (ts.Debug.shouldAssert(1 /* AssertionLevel.Normal */)) { + this.filenameToScriptInfo.forEach(function (info) { return ts.Debug.assert(!info.isAttached(project), "Found script Info still attached to project", function () { return "".concat(project.projectName, ": ScriptInfos still attached: ").concat(JSON.stringify(ts.arrayFrom(ts.mapDefinedIterator(_this.filenameToScriptInfo.values(), function (info) { return info.isAttached(project) ? { fileName: info.fileName, projects: info.containingProjects.map(function (p) { return p.projectName; }), hasMixedContent: info.hasMixedContent } : undefined; })), - /*replacer*/ undefined, " "); }); }); + /*replacer*/ undefined, " ")); }); }); } // Remove the project from pending project updates this.pendingProjectUpdates.delete(project.getProjectName()); @@ -174083,7 +175001,7 @@ var ts; // created when any of the script infos are added as root of inferred project if (this.configFileExistenceImpactsRootOfInferredProject(configFileExistenceInfo)) { // If we cannot watch config file existence without configured project, close the configured file watcher - if (!ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath))) { + if (!ts.canWatchDirectoryOrFile(ts.getDirectoryPath(canonicalConfigFilePath))) { configFileExistenceInfo.watcher.close(); configFileExistenceInfo.watcher = noopConfigFileWatcher; } @@ -174163,7 +175081,7 @@ var ts; // Set this file as the root of inferred project (configFileExistenceInfo.openFilesImpactedByConfigFile || (configFileExistenceInfo.openFilesImpactedByConfigFile = new ts.Map())).set(info.path, true); // If there is no configured project for this config file, add the file watcher - configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.canWatchDirectory(ts.getDirectoryPath(canonicalConfigFilePath)) ? + configFileExistenceInfo.watcher || (configFileExistenceInfo.watcher = ts.canWatchDirectoryOrFile(ts.getDirectoryPath(canonicalConfigFilePath)) ? _this.watchFactory.watchFile(configFileName, function (_filename, eventKind) { return _this.onConfigFileChanged(canonicalConfigFilePath, eventKind); }, ts.PollingInterval.High, _this.hostConfiguration.watchOptions, ts.WatchType.ConfigFileForInferredRoot) : noopConfigFileWatcher); }); @@ -174265,15 +175183,15 @@ var ts; if (result !== undefined) return result || undefined; } - this.logger.info("Search path: " + ts.getDirectoryPath(info.fileName)); + this.logger.info("Search path: ".concat(ts.getDirectoryPath(info.fileName))); var configFileName = this.forEachConfigFileLocation(info, function (canonicalConfigFilePath, configFileName) { return _this.configFileExists(configFileName, canonicalConfigFilePath, info); }); if (configFileName) { - this.logger.info("For info: " + info.fileName + " :: Config file name: " + configFileName); + this.logger.info("For info: ".concat(info.fileName, " :: Config file name: ").concat(configFileName)); } else { - this.logger.info("For info: " + info.fileName + " :: No config files found."); + this.logger.info("For info: ".concat(info.fileName, " :: No config files found.")); } if (isOpenScriptInfo(info)) { this.configFileForOpenFiles.set(info.path, configFileName || false); @@ -174292,8 +175210,8 @@ var ts; this.logger.info("Open files: "); this.openFiles.forEach(function (projectRootPath, path) { var info = _this.getScriptInfoForPath(path); - _this.logger.info("\tFileName: " + info.fileName + " ProjectRootPath: " + projectRootPath); - _this.logger.info("\t\tProjects: " + info.containingProjects.map(function (p) { return p.getProjectName(); })); + _this.logger.info("\tFileName: ".concat(info.fileName, " ProjectRootPath: ").concat(projectRootPath)); + _this.logger.info("\t\tProjects: ".concat(info.containingProjects.map(function (p) { return p.getProjectName(); }))); }); this.logger.endGroup(); }; @@ -174332,7 +175250,7 @@ var ts; .map(function (name) { return ({ name: name, size: _this.host.getFileSize(name) }); }) .sort(function (a, b) { return b.size - a.size; }) .slice(0, 5); - this.logger.info("Non TS file size exceeded limit (" + totalNonTsFileSize + "). Largest files: " + top5LargestFiles.map(function (file) { return file.name + ":" + file.size; }).join(", ")); + this.logger.info("Non TS file size exceeded limit (".concat(totalNonTsFileSize, "). Largest files: ").concat(top5LargestFiles.map(function (file) { return "".concat(file.name, ":").concat(file.size); }).join(", "))); // Keep the size as zero since it's disabled return fileName; } @@ -174401,8 +175319,8 @@ var ts; }; /* @internal */ ProjectService.prototype.createConfiguredProject = function (configFileName) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "createConfiguredProject", { configFilePath: configFileName }); - this.logger.info("Creating configuration project " + configFileName); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "createConfiguredProject", { configFilePath: configFileName }); + this.logger.info("Creating configuration project ".concat(configFileName)); var canonicalConfigFilePath = server.asNormalizedPath(this.toCanonicalFileName(configFileName)); var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath); // We could be in this scenario if project is the configured project tracked by external project @@ -174450,7 +175368,7 @@ var ts; /* @internal */ ProjectService.prototype.loadConfiguredProject = function (project, reason) { var _this = this; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath }); this.sendProjectLoadingStartEvent(project, reason); // Read updated contents from disk var configFilename = server.asNormalizedPath(ts.normalizePath(project.getConfigFilePath())); @@ -174515,12 +175433,12 @@ var ts; if (parsedCommandLine.errors.length) { configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); } - this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ + this.logger.info("Config: ".concat(configFilename, " : ").concat(JSON.stringify({ rootNames: parsedCommandLine.fileNames, options: parsedCommandLine.options, watchOptions: parsedCommandLine.watchOptions, projectReferences: parsedCommandLine.projectReferences - }, /*replacer*/ undefined, " ")); + }, /*replacer*/ undefined, " "))); var oldCommandLine = (_b = configFileExistenceInfo.config) === null || _b === void 0 ? void 0 : _b.parsedCommandLine; if (!configFileExistenceInfo.config) { configFileExistenceInfo.config = { parsedCommandLine: parsedCommandLine, cachedDirectoryStructureHost: cachedDirectoryStructureHost, projects: new ts.Map() }; @@ -174550,7 +175468,7 @@ var ts; // Update projects var ensureProjectsForOpenFiles = false; (_a = _this.sharedExtendedConfigFileWatchers.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (canonicalPath) { - ensureProjectsForOpenFiles = _this.delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalPath, "Change in extended config file " + extendedConfigFileName + " detected") || ensureProjectsForOpenFiles; + ensureProjectsForOpenFiles = _this.delayUpdateProjectsFromParsedConfigOnConfigFileChange(canonicalPath, "Change in extended config file ".concat(extendedConfigFileName, " detected")) || ensureProjectsForOpenFiles; }); if (ensureProjectsForOpenFiles) _this.delayEnsureProjectForOpenFiles(); @@ -174706,7 +175624,7 @@ var ts; // Clear the cache since we are reloading the project from disk host.clearCache(); var configFileName = project.getConfigFilePath(); - this.logger.info((isInitialLoad ? "Loading" : "Reloading") + " configured project " + configFileName); + this.logger.info("".concat(isInitialLoad ? "Loading" : "Reloading", " configured project ").concat(configFileName)); // Load project from the disk this.loadConfiguredProject(project, reason); project.updateGraph(); @@ -174845,7 +175763,7 @@ var ts; var path = _a[0], scriptInfo = _a[1]; return ({ path: path, fileName: scriptInfo.fileName }); }); - this.logger.msg("Could not find file " + JSON.stringify(fileName) + ".\nAll files are: " + JSON.stringify(names), server.Msg.Err); + this.logger.msg("Could not find file ".concat(JSON.stringify(fileName), ".\nAll files are: ").concat(JSON.stringify(names)), server.Msg.Err); }; /** * Returns the projects that contain script info through SymLink @@ -174938,7 +175856,7 @@ var ts; } } } - }, 1 /* Recursive */, this.hostConfiguration.watchOptions, ts.WatchType.NodeModules); + }, 1 /* WatchDirectoryFlags.Recursive */, this.hostConfiguration.watchOptions, ts.WatchType.NodeModules); var result = { refreshScriptInfoRefCount: 0, affectedModuleSpecifierCacheProjects: undefined, @@ -175029,9 +175947,9 @@ var ts; var info = this.getScriptInfoForPath(path); if (!info) { var isDynamic = server.isDynamicFileName(fileName); - ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"; }); - ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"; }); - ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory || this.useInferredProjectPerProjectRoot, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nDynamic files must always be opened with service's current directory or service should support inferred project per projectRootPath."; }); + ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"); }); + ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"); }); + ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory || this.useInferredProjectPerProjectRoot, "", function () { return "".concat(JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }), "\nDynamic files must always be opened with service's current directory or service should support inferred project per projectRootPath."); }); // If the file is not opened by client and the file doesnot exist on the disk, return if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) { return; @@ -175210,13 +176128,13 @@ var ts; var info = this.getScriptInfoForNormalizedPath(server.toNormalizedPath(args.file)); if (info) { info.setOptions(convertFormatOptions(args.formatOptions), args.preferences); - this.logger.info("Host configuration update for file " + args.file); + this.logger.info("Host configuration update for file ".concat(args.file)); } } else { if (args.hostInfo !== undefined) { this.hostConfiguration.hostInfo = args.hostInfo; - this.logger.info("Host information " + args.hostInfo); + this.logger.info("Host information ".concat(args.hostInfo)); } if (args.formatOptions) { this.hostConfiguration.formatCodeOptions = __assign(__assign({}, this.hostConfiguration.formatCodeOptions), convertFormatOptions(args.formatOptions)); @@ -175248,7 +176166,7 @@ var ts; } if (args.watchOptions) { this.hostConfiguration.watchOptions = (_a = convertWatchOptions(args.watchOptions)) === null || _a === void 0 ? void 0 : _a.watchOptions; - this.logger.info("Host watch options changed to " + JSON.stringify(this.hostConfiguration.watchOptions) + ", it will be take effect for next watches."); + this.logger.info("Host watch options changed to ".concat(JSON.stringify(this.hostConfiguration.watchOptions), ", it will be take effect for next watches.")); } } }; @@ -175460,7 +176378,7 @@ var ts; ? originalLocation : location; } - configuredProject = this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + configuredProject = this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: ".concat(originalFileInfo.fileName).concat(location !== originalLocation ? " for location: " + location.fileName : "")); } updateProjectIfDirty(configuredProject); var projectContainsOriginalInfo = function (project) { @@ -175472,7 +176390,7 @@ var ts; configuredProject = forEachResolvedProjectReferenceProject(configuredProject, fileName, function (child) { updateProjectIfDirty(child); return projectContainsOriginalInfo(child) ? child : undefined; - }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution " + configuredProject.projectName + " to find possible configured project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution ".concat(configuredProject.projectName, " to find possible configured project for original file: ").concat(originalFileInfo.fileName).concat(location !== originalLocation ? " for location: " + location.fileName : "")); if (!configuredProject) return undefined; if (configuredProject === project) @@ -175526,7 +176444,7 @@ var ts; if (configFileName) { project = this.findConfiguredProjectByProjectName(configFileName); if (!project) { - project = this.createLoadAndUpdateConfiguredProject(configFileName, "Creating possible configured project for " + info.fileName + " to open"); + project = this.createLoadAndUpdateConfiguredProject(configFileName, "Creating possible configured project for ".concat(info.fileName, " to open")); defaultConfigProjectIsCreated = true; } else { @@ -175556,7 +176474,7 @@ var ts; if (!projectForConfigFileDiag && child.containsScriptInfo(info)) { projectForConfigFileDiag = child; } - }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution " + project.projectName + " to find possible configured project for " + info.fileName + " to open"); + }, ProjectReferenceProjectLoadKind.FindCreateLoad, "Creating project referenced in solution ".concat(project.projectName, " to find possible configured project for ").concat(info.fileName, " to open")); } // Send the event only if the project got created as part of this open request and info is part of the project if (projectForConfigFileDiag) { @@ -175618,7 +176536,7 @@ var ts; return; // find or delay load the project var ancestor = this.findConfiguredProjectByProjectName(configFileName) || - this.createConfiguredProjectWithDelayLoad(configFileName, "Creating project possibly referencing default composite project " + project.getProjectName() + " of open file " + info.fileName); + this.createConfiguredProjectWithDelayLoad(configFileName, "Creating project possibly referencing default composite project ".concat(project.getProjectName(), " of open file ").concat(info.fileName)); if (ancestor.isInitialLoadPending()) { // Set a potential project reference ancestor.setPotentialProjectReference(project.canonicalConfigFilePath); @@ -175661,7 +176579,7 @@ var ts; // Load this project, var configFileName = server.toNormalizedPath(child.sourceFile.fileName); var childProject = project.projectService.findConfiguredProjectByProjectName(configFileName) || - project.projectService.createAndLoadConfiguredProject(configFileName, "Creating project referenced by : " + project.projectName + " as it references project " + referencedProject.sourceFile.fileName); + project.projectService.createAndLoadConfiguredProject(configFileName, "Creating project referenced by : ".concat(project.projectName, " as it references project ").concat(referencedProject.sourceFile.fileName)); updateProjectIfDirty(childProject); // Ensure children for this project this.ensureProjectChildren(childProject, forProjects, seenProjects); @@ -175962,7 +176880,7 @@ var ts; for (var _b = 0, normalizedNames_1 = normalizedNames; _b < normalizedNames_1.length; _b++) { var root = normalizedNames_1[_b]; if (rule.match.test(root)) { - this_3.logger.info("Excluding files based on rule " + name + " matching file '" + root + "'"); + this_3.logger.info("Excluding files based on rule ".concat(name, " matching file '").concat(root, "'")); // If the file matches, collect its types packages and exclude rules if (rule.types) { for (var _c = 0, _d = rule.types; _c < _d.length; _c++) { @@ -175987,7 +176905,7 @@ var ts; if (typeof groupNumberOrString === "number") { if (!ts.isString(groups[groupNumberOrString])) { // Specification was wrong - exclude nothing! - _this.logger.info("Incorrect RegExp specification in safelist rule " + name + " - not enough groups"); + _this.logger.info("Incorrect RegExp specification in safelist rule ".concat(name, " - not enough groups")); // * can't appear in a filename; escape it because it's feeding into a RegExp return "\\*"; } @@ -176035,7 +176953,7 @@ var ts; var cleanedTypingName = ts.removeMinAndVersionNumbers(inferredTypingName); var typeName = this_4.legacySafelist.get(cleanedTypingName); if (typeName !== undefined) { - this_4.logger.info("Excluded '" + normalizedNames[i] + "' because it matched " + cleanedTypingName + " from the legacy safelist"); + this_4.logger.info("Excluded '".concat(normalizedNames[i], "' because it matched ").concat(cleanedTypingName, " from the legacy safelist")); excludedFiles.push(normalizedNames[i]); // *exclude* it from the project... exclude = true; @@ -176165,8 +177083,8 @@ var ts; if (!project) { // errors are stored in the project, do not need to update the graph project = this.getHostPreferences().lazyConfiguredProjectsFromExternalProject ? - this.createConfiguredProjectWithDelayLoad(tsconfigFile, "Creating configured project in external project: " + proj.projectFileName) : - this.createLoadAndUpdateConfiguredProject(tsconfigFile, "Creating configured project in external project: " + proj.projectFileName); + this.createConfiguredProjectWithDelayLoad(tsconfigFile, "Creating configured project in external project: ".concat(proj.projectFileName)) : + this.createLoadAndUpdateConfiguredProject(tsconfigFile, "Creating configured project in external project: ".concat(proj.projectFileName)); } if (project && !ts.contains(exisingConfigFiles, tsconfigFile)) { // keep project alive even if no documents are opened - its lifetime is bound to the lifetime of containing external project @@ -176186,7 +177104,7 @@ var ts; ProjectService.prototype.hasDeferredExtension = function () { for (var _i = 0, _a = this.hostConfiguration.extraFileExtensions; _i < _a.length; _i++) { // TODO: GH#18217 var extension = _a[_i]; - if (extension.scriptKind === 7 /* Deferred */) { + if (extension.scriptKind === 7 /* ScriptKind.Deferred */) { return true; } } @@ -176199,9 +177117,9 @@ var ts; this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); return; } - this.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); + this.logger.info("Enabling plugin ".concat(pluginConfigEntry.name, " from candidate paths: ").concat(searchPaths.join(","))); if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) { - this.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name"); + this.logger.info("Skipped loading plugin ".concat(pluginConfigEntry.name || JSON.stringify(pluginConfigEntry), " because only package name is allowed plugin name")); return; } // If the host supports dynamic import, begin enabling the plugin asynchronously. @@ -176351,11 +177269,11 @@ var ts; var processDirectory = function (directory) { switch (packageJsonCache.directoryHasPackageJson(directory)) { // Sync and check same directory again - case 3 /* Maybe */: + case 3 /* Ternary.Maybe */: packageJsonCache.searchDirectoryAndAncestors(directory); return processDirectory(directory); // Check package.json - case -1 /* True */: + case -1 /* Ternary.True */: var packageJsonFileName = ts.combinePaths(directory, "package.json"); _this.watchPackageJsonFile(packageJsonFileName); var info = packageJsonCache.getInDirectory(directory); @@ -176374,9 +177292,9 @@ var ts; var _this = this; return ts.forEachAncestorDirectory(fileName, function (directory) { switch (_this.packageJsonCache.directoryHasPackageJson(_this.toPath(directory))) { - case -1 /* True */: return directory; - case 0 /* False */: return undefined; - case 3 /* Maybe */: + case -1 /* Ternary.True */: return directory; + case 0 /* Ternary.False */: return undefined; + case 3 /* Ternary.Maybe */: return _this.host.fileExists(ts.combinePaths(directory, "package.json")) ? directory : undefined; @@ -176415,9 +177333,9 @@ var ts; /*@internal*/ ProjectService.prototype.includePackageJsonAutoImports = function () { switch (this.hostConfiguration.preferences.includePackageJsonAutoImports) { - case "on": return 1 /* On */; - case "off": return 0 /* Off */; - default: return 2 /* Auto */; + case "on": return 1 /* PackageJsonAutoImportPreference.On */; + case "off": return 0 /* PackageJsonAutoImportPreference.Off */; + default: return 2 /* PackageJsonAutoImportPreference.Auto */; } }; /*@internal*/ @@ -176545,7 +177463,7 @@ var ts; return cache || (cache = new ts.Map()); } function key(fromFileName, preferences, options) { - return fromFileName + "," + preferences.importModuleSpecifierEnding + "," + preferences.importModuleSpecifierPreference + "," + options.overrideImportMode; + return "".concat(fromFileName, ",").concat(preferences.importModuleSpecifierEnding, ",").concat(preferences.importModuleSpecifierPreference, ",").concat(options.overrideImportMode); } function createInfo(modulePaths, moduleSpecifiers, isBlockedByPackageJsonDependencies) { return { modulePaths: modulePaths, moduleSpecifiers: moduleSpecifiers, isBlockedByPackageJsonDependencies: isBlockedByPackageJsonDependencies }; @@ -176576,7 +177494,7 @@ var ts; directoryHasPackageJson: directoryHasPackageJson, searchDirectoryAndAncestors: function (directory) { ts.forEachAncestorDirectory(directory, function (ancestor) { - if (directoryHasPackageJson(ancestor) !== 3 /* Maybe */) { + if (directoryHasPackageJson(ancestor) !== 3 /* Ternary.Maybe */) { return true; } var packageJsonFileName = host.toPath(ts.combinePaths(ancestor, "package.json")); @@ -176595,9 +177513,9 @@ var ts; directoriesWithoutPackageJson.delete(ts.getDirectoryPath(fileName)); } function directoryHasPackageJson(directory) { - return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* True */ : - directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : - 3 /* Maybe */; + return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* Ternary.True */ : + directoriesWithoutPackageJson.has(directory) ? 0 /* Ternary.False */ : + 3 /* Ternary.Maybe */; } } server.createPackageJsonCache = createPackageJsonCache; @@ -176704,10 +177622,10 @@ var ts; var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); if (verboseLogging) { - logger.info(msg.type + ":" + server.indent(json)); + logger.info("".concat(msg.type, ":").concat(server.indent(json))); } var len = byteLength(json, "utf8"); - return "Content-Length: " + (1 + len) + "\r\n\r\n" + json + newLine; + return "Content-Length: ".concat(1 + len, "\r\n\r\n").concat(json).concat(newLine); } server.formatMessage = formatMessage; /** @@ -176754,10 +177672,10 @@ var ts; try { if (this.operationHost.isCancellationRequested()) { stop = true; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId, early: true }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepCanceled", { seq: this.requestId, early: true }); } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "stepAction", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "stepAction", { seq: this.requestId }); action(this); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -176768,11 +177686,11 @@ var ts; stop = true; // ignore cancellation request if (e instanceof ts.OperationCanceledException) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepCanceled", { seq: this.requestId }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepCanceled", { seq: this.requestId }); } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "stepError", { seq: this.requestId, message: e.message }); - this.operationHost.logError(e, "delayed processing of request " + this.requestId); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "stepError", { seq: this.requestId, message: e.message }); + this.operationHost.logError(e, "delayed processing of request ".concat(this.requestId)); } } if (stop || !this.hasPendingWork()) { @@ -176851,13 +177769,15 @@ var ts; function getDefinitionLocation(defaultProject, initialLocation, isForRename) { var infos = defaultProject.getLanguageService().getDefinitionAtPosition(initialLocation.fileName, initialLocation.pos, /*searchOtherFilesOnly*/ false, /*stopAtAlias*/ isForRename); var info = infos && ts.firstOrUndefined(infos); + // Note that the value of `isLocal` may depend on whether or not the checker has run on the containing file + // (implying that FAR cascading behavior may depend on request order) return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined; } function getReferencesWorker(projects, defaultProject, initialLocation, logger) { var _a, _b; var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation, /*isForRename*/ false, function (project, position) { - logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName()); + logger.info("Finding references to ".concat(position.fileName, " position ").concat(position.pos, " in project ").concat(project.getProjectName())); return project.getLanguageService().findReferences(position.fileName, position.pos); }, function (referencedSymbol, cb) { cb(documentSpanLocation(referencedSymbol.definition)); @@ -176990,16 +177910,16 @@ var ts; function getPerProjectReferences(projects, defaultProject, initialLocation, isForRename, getResultsForPosition, forPositionInResult) { // If `getResultsForPosition` returns results for a project, they go in here var resultsMap = new ts.Map(); - var queue = []; + var queue = ts.createQueue(); // In order to get accurate isDefinition values for `defaultProject`, // we need to ensure that it is searched from `initialLocation`. // The easiest way to do this is to search it first. - queue.push({ project: defaultProject, location: initialLocation }); + queue.enqueue({ project: defaultProject, location: initialLocation }); // This will queue `defaultProject` a second time, but it will be dropped // as a dup when it is dequeued. forEachProjectInProjects(projects, initialLocation.fileName, function (project, path) { var location = { fileName: path, pos: initialLocation.pos }; - queue.push({ project: project, location: location }); + queue.enqueue({ project: project, location: location }); }); var projectService = defaultProject.projectService; var cancellationToken = defaultProject.getCancellationToken(); @@ -177014,22 +177934,13 @@ var ts; // The keys of resultsMap allow us to check which projects have already been searched, but we also // maintain a set of strings because that's what `loadAncestorProjectTree` wants. var searchedProjectKeys = new ts.Set(); - onCancellation: while (queue.length) { - while (queue.length) { + onCancellation: while (!queue.isEmpty()) { + while (!queue.isEmpty()) { if (cancellationToken.isCancellationRequested()) break onCancellation; - var skipCount = 0; - for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++) - ; - if (skipCount === queue.length) { - queue.length = 0; - break; - } - if (skipCount > 0) { - queue.splice(0, skipCount); - } - // NB: we may still skip if it's a project reference redirect - var _a = queue.shift(), project = _a.project, location = _a.location; + var _a = queue.dequeue(), project = _a.project, location = _a.location; + if (resultsMap.has(project)) + continue; if (isLocationProjectReferenceRedirect(project, location)) continue; var projectResults = searchPosition(project, location); @@ -177050,7 +177961,7 @@ var ts; return; // Can loop forever without this (enqueue here, dequeue above, repeat) var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition); if (location) { - queue.push({ project: project, location: location }); + queue.enqueue({ project: project, location: location }); } }); } @@ -177078,7 +177989,7 @@ var ts; for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) { var project_1 = _a[_i]; if (!project_1.isOrphan() && !resultsMap.has(project_1)) { // Optimization: don't enqueue if will be discarded - queue.push({ project: project_1, location: originalLocation }); + queue.enqueue({ project: project_1, location: originalLocation }); } } var symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo); @@ -177087,7 +177998,7 @@ var ts; for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) { var symlinkedProject = symlinkedProjects_2[_i]; if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded - queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } }); + queue.enqueue({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } }); } } }); @@ -177641,14 +178552,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidPartialSemanticModeCommands.forEach(function (commandName) { return _this.handlers.set(commandName, function (request) { - throw new Error("Request: " + request.command + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("Request: ".concat(request.command, " not allowed in LanguageServiceMode.PartialSemantic")); }); }); break; case ts.LanguageServiceMode.Syntactic: invalidSyntacticModeCommands.forEach(function (commandName) { return _this.handlers.set(commandName, function (request) { - throw new Error("Request: " + request.command + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("Request: ".concat(request.command, " not allowed in LanguageServiceMode.Syntactic")); }); }); break; @@ -177723,7 +178634,7 @@ var ts; }; Session.prototype.projectsUpdatedInBackgroundEvent = function (openFiles) { var _this = this; - this.projectService.logger.info("got projects updated in background, updating diagnostics for " + openFiles); + this.projectService.logger.info("got projects updated in background, updating diagnostics for ".concat(openFiles)); if (openFiles.length) { if (!this.suppressDiagnosticEvents && !this.noGetErrOnBackgroundUpdate) { // For now only queue error checking for open files. We can change this to include non open files as well @@ -177753,17 +178664,17 @@ var ts; var scriptInfo = project.getScriptInfoForNormalizedPath(file); if (scriptInfo) { var text = ts.getSnapshotText(scriptInfo.getSnapshot()); - msg += "\n\nFile text of " + fileRequest.file + ":" + server.indent(text) + "\n"; + msg += "\n\nFile text of ".concat(fileRequest.file, ":").concat(server.indent(text), "\n"); } } catch (_b) { } // eslint-disable-line no-empty } if (err.ProgramFiles) { - msg += "\n\nProgram files: " + JSON.stringify(err.ProgramFiles) + "\n"; + msg += "\n\nProgram files: ".concat(JSON.stringify(err.ProgramFiles), "\n"); msg += "\n\nProjects::\n"; var counter_1 = 0; var addProjectInfo = function (project) { - msg += "\nProject '" + project.projectName + "' (" + server.ProjectKind[project.projectKind] + ") " + counter_1 + "\n"; + msg += "\nProject '".concat(project.projectName, "' (").concat(server.ProjectKind[project.projectKind], ") ").concat(counter_1, "\n"); msg += project.filesToString(/*writeProjectFileNames*/ true); msg += "\n-----------------------------------------------\n"; counter_1++; @@ -177778,7 +178689,7 @@ var ts; Session.prototype.send = function (msg) { if (msg.type === "event" && !this.canUseEvents) { if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("Session does not support events: ignored event: " + JSON.stringify(msg)); + this.logger.info("Session does not support events: ignored event: ".concat(JSON.stringify(msg))); } return; } @@ -177786,7 +178697,7 @@ var ts; }; Session.prototype.writeMessage = function (msg) { var msgText = formatMessage(msg, this.logger, this.byteLength, this.host.newLine); - ts.perfLogger.logEvent("Response message size: " + msgText.length); + ts.perfLogger.logEvent("Response message size: ".concat(msgText.length)); this.host.write(msgText); }; Session.prototype.event = function (body, eventName) { @@ -177838,7 +178749,7 @@ var ts; this.send(res); }; Session.prototype.semanticCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "semanticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "semanticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails var diags = isDeclarationFileInJSOnlyNonConfiguredProject(project, file) ? server.emptyArray : project.getLanguageService().getSemanticDiagnostics(file).filter(function (d) { return !!d.file; }); @@ -177846,12 +178757,12 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; Session.prototype.syntacticCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "syntacticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "syntacticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSyntacticDiagnostics(file), "syntaxDiag"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; Session.prototype.suggestionCheck = function (file, project) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "suggestionCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "suggestionCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag"); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); }; @@ -177929,7 +178840,7 @@ var ts; if (!projects) { return; } - this.logger.info("cleaning " + caption); + this.logger.info("cleaning ".concat(caption)); for (var _i = 0, projects_4 = projects; _i < projects_4.length; _i++) { var p = projects_4[_i]; p.getLanguageService(/*ensureSynchronized*/ false).cleanupSemanticCache(); @@ -177950,7 +178861,7 @@ var ts; }; Session.prototype.getEncodedSemanticClassifications = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - var format = args.format === "2020" ? "2020" /* TwentyTwenty */ : "original" /* Original */; + var format = args.format === "2020" ? "2020" /* SemanticClassificationFormat.TwentyTwenty */ : "original" /* SemanticClassificationFormat.Original */; return project.getLanguageService().getEncodedSemanticClassifications(file, args, format); }; Session.prototype.getProject = function (projectFileName) { @@ -178117,7 +179028,7 @@ var ts; var packageDirectory = fileName.substring(0, nodeModulesPathParts.packageRootIndex); var packageJsonCache = (_a = project.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache(); var compilerOptions = project.getCompilationSettings(); - var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), packageJsonCache, project, compilerOptions); + var packageJson = ts.getPackageScopeForPath(project.toPath(packageDirectory + "/package.json"), ts.getTemporaryModuleResolutionState(packageJsonCache, project, compilerOptions)); if (!packageJson) return undefined; // Use fake options instead of actual compiler options to avoid following export map if the project uses node16 or nodenext - @@ -178137,7 +179048,7 @@ var ts; else { // It wasn't the main entrypoint but we are in node_modules. Try a subpath into the package. var pathToFileInPackage = fileName.substring(nodeModulesPathParts.packageRootIndex + 1); - var specifier = packageName + "/" + ts.removeFileExtension(pathToFileInPackage); + var specifier = "".concat(packageName, "/").concat(ts.removeFileExtension(pathToFileInPackage)); var implementationResolution = auxiliaryProject.resolveModuleNames([specifier], resolveFromFile)[0]; return implementationResolution === null || implementationResolution === void 0 ? void 0 : implementationResolution.resolvedFileName; } @@ -178176,7 +179087,7 @@ var ts; } var initialNode = ts.getTouchingPropertyName(program.getSourceFile(file), position); var symbol = program.getTypeChecker().getSymbolAtLocation(initialNode); - var importSpecifier = symbol && ts.getDeclarationOfKind(symbol, 270 /* ImportSpecifier */); + var importSpecifier = symbol && ts.getDeclarationOfKind(symbol, 270 /* SyntaxKind.ImportSpecifier */); if (!importSpecifier) return undefined; var nameToSearch = ((_a = importSpecifier.propertyName) === null || _a === void 0 ? void 0 : _a.text) || importSpecifier.name.text; @@ -178507,7 +179418,7 @@ var ts; var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); }); return { refs: refs, - symbolName: "\"" + args.file + "\"" + symbolName: "\"".concat(args.file, "\"") }; }; /** @@ -178708,7 +179619,7 @@ var ts; var completions = project.getLanguageService().getCompletionsAtPosition(file, position, __assign(__assign({}, server.convertUserPreferences(this.getPreferences(file))), { triggerCharacter: args.triggerCharacter, triggerKind: args.triggerKind, includeExternalModuleExports: args.includeExternalModuleExports, includeInsertTextCompletions: args.includeInsertTextCompletions }), project.projectService.getFormatCodeOptions(file)); if (completions === undefined) return undefined; - if (kind === "completions-full" /* CompletionsFull */) + if (kind === "completions-full" /* protocol.CommandTypes.CompletionsFull */) return completions; var prefix = args.prefix || ""; var entries = ts.mapDefined(completions.entries, function (entry) { @@ -178735,7 +179646,7 @@ var ts; }; } }); - if (kind === "completions" /* Completions */) { + if (kind === "completions" /* protocol.CommandTypes.Completions */) { if (completions.metadata) entries.metadata = completions.metadata; return entries; @@ -179135,7 +180046,7 @@ var ts; }); var badCode = args.errorCodes.find(function (c) { return !existingDiagCodes_1.includes(c); }); if (badCode !== undefined) { - e.message = "BADCLIENT: Bad error code, " + badCode + " not found in range " + startPosition + ".." + endPosition + " (found: " + existingDiagCodes_1.join(", ") + "); could have caused this error:\n" + e.message; + e.message = "BADCLIENT: Bad error code, ".concat(badCode, " not found in range ").concat(startPosition, "..").concat(endPosition, " (found: ").concat(existingDiagCodes_1.join(", "), "); could have caused this error:\n").concat(e.message); } throw e; } @@ -179412,7 +180323,7 @@ var ts; }; Session.prototype.addProtocolHandler = function (command, handler) { if (this.handlers.has(command)) { - throw new Error("Protocol handler already exists for command \"" + command + "\""); + throw new Error("Protocol handler already exists for command \"".concat(command, "\"")); } this.handlers.set(command, handler); }; @@ -179443,8 +180354,8 @@ var ts; return response; } else { - this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err); - this.doOutput(/*info*/ undefined, server.CommandNames.Unknown, request.seq, /*success*/ false, "Unrecognized JSON command: " + request.command); + this.logger.msg("Unrecognized JSON command:".concat(server.stringifyIndented(request)), server.Msg.Err); + this.doOutput(/*info*/ undefined, server.CommandNames.Unknown, request.seq, /*success*/ false, "Unrecognized JSON command: ".concat(request.command)); return { responseRequired: false }; } }; @@ -179455,7 +180366,7 @@ var ts; if (this.logger.hasLevel(server.LogLevel.requestTime)) { start = this.hrtime(); if (this.logger.hasLevel(server.LogLevel.verbose)) { - this.logger.info("request:" + server.indent(this.toStringMessage(message))); + this.logger.info("request:".concat(server.indent(this.toStringMessage(message)))); } } var request; @@ -179463,23 +180374,23 @@ var ts; try { request = this.parseMessage(message); relevantFile = request.arguments && request.arguments.file ? request.arguments : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "request", { seq: request.seq, command: request.command }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "request", { seq: request.seq, command: request.command }); ts.perfLogger.logStartCommand("" + request.command, this.toStringMessage(message).substring(0, 100)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* tracing.Phase.Session */, "executeCommand", { seq: request.seq, command: request.command }, /*separateBeginAndEnd*/ true); var _a = this.executeCommand(request), response = _a.response, responseRequired = _a.responseRequired; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (this.logger.hasLevel(server.LogLevel.requestTime)) { var elapsedTime = hrTimeToMilliseconds(this.hrtime(start)).toFixed(4); if (responseRequired) { - this.logger.perftrc(request.seq + "::" + request.command + ": elapsed time (in milliseconds) " + elapsedTime); + this.logger.perftrc("".concat(request.seq, "::").concat(request.command, ": elapsed time (in milliseconds) ").concat(elapsedTime)); } else { - this.logger.perftrc(request.seq + "::" + request.command + ": async elapsed time (in milliseconds) " + elapsedTime); + this.logger.perftrc("".concat(request.seq, "::").concat(request.command, ": async elapsed time (in milliseconds) ").concat(elapsedTime)); } } // Note: Log before writing the response, else the editor can complete its activity before the server does ts.perfLogger.logStopCommand("" + request.command, "Success"); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "response", { seq: request.seq, command: request.command, success: !!response }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "response", { seq: request.seq, command: request.command, success: !!response }); if (response) { this.doOutput(response, request.command, request.seq, /*success*/ true); } @@ -179493,13 +180404,13 @@ var ts; if (err instanceof ts.OperationCanceledException) { // Handle cancellation exceptions ts.perfLogger.logStopCommand("" + (request && request.command), "Canceled: " + err); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "commandCanceled", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "commandCanceled", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command }); this.doOutput({ canceled: true }, request.command, request.seq, /*success*/ true); return; } this.logErrorWorker(err, this.toStringMessage(message), relevantFile); ts.perfLogger.logStopCommand("" + (request && request.command), "Error: " + err); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "commandError", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command, message: err.message }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "commandError", { seq: request === null || request === void 0 ? void 0 : request.seq, command: request === null || request === void 0 ? void 0 : request.command, message: err.message }); this.doOutput( /*info*/ undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, /*success*/ false, "Error processing request. " + err.message + "\n" + err.stack); @@ -179610,7 +180521,7 @@ var ts; this.goSubtree = true; this.lineIndex = new LineIndex(); this.endBranch = []; - this.state = 2 /* Entire */; + this.state = 2 /* CharRangeSection.Entire */; this.initialText = ""; this.trailingText = ""; this.lineIndex.root = new LineNode(); @@ -179701,7 +180612,7 @@ var ts; // have visited the path for start of range, now looking for end // if range is on single line, we will never make this state transition if (lineCollection === this.lineCollectionAtBranch) { - this.state = 4 /* End */; + this.state = 4 /* CharRangeSection.End */; } // always pop stack because post only called when child has been visited this.stack.pop(); @@ -179709,9 +180620,9 @@ var ts; EditWalker.prototype.pre = function (_relativeStart, _relativeLength, lineCollection, _parent, nodeType) { // currentNode corresponds to parent, but in the new tree var currentNode = this.stack[this.stack.length - 1]; - if ((this.state === 2 /* Entire */) && (nodeType === 1 /* Start */)) { + if ((this.state === 2 /* CharRangeSection.Entire */) && (nodeType === 1 /* CharRangeSection.Start */)) { // if range is on single line, we will never make this state transition - this.state = 1 /* Start */; + this.state = 1 /* CharRangeSection.Start */; this.branchNode = currentNode; this.lineCollectionAtBranch = lineCollection; } @@ -179724,14 +180635,14 @@ var ts; return new LineNode(); } switch (nodeType) { - case 0 /* PreStart */: + case 0 /* CharRangeSection.PreStart */: this.goSubtree = false; - if (this.state !== 4 /* End */) { + if (this.state !== 4 /* CharRangeSection.End */) { currentNode.add(lineCollection); } break; - case 1 /* Start */: - if (this.state === 4 /* End */) { + case 1 /* CharRangeSection.Start */: + if (this.state === 4 /* CharRangeSection.End */) { this.goSubtree = false; } else { @@ -179740,8 +180651,8 @@ var ts; this.startPath.push(child); } break; - case 2 /* Entire */: - if (this.state !== 4 /* End */) { + case 2 /* CharRangeSection.Entire */: + if (this.state !== 4 /* CharRangeSection.End */) { child = fresh(lineCollection); currentNode.add(child); this.startPath.push(child); @@ -179754,11 +180665,11 @@ var ts; } } break; - case 3 /* Mid */: + case 3 /* CharRangeSection.Mid */: this.goSubtree = false; break; - case 4 /* End */: - if (this.state !== 4 /* End */) { + case 4 /* CharRangeSection.End */: + if (this.state !== 4 /* CharRangeSection.End */) { this.goSubtree = false; } else { @@ -179769,9 +180680,9 @@ var ts; } } break; - case 5 /* PostEnd */: + case 5 /* CharRangeSection.PostEnd */: this.goSubtree = false; - if (this.state !== 1 /* Start */) { + if (this.state !== 1 /* CharRangeSection.Start */) { currentNode.add(lineCollection); } break; @@ -179782,10 +180693,10 @@ var ts; }; // just gather text from the leaves EditWalker.prototype.leaf = function (relativeStart, relativeLength, ll) { - if (this.state === 1 /* Start */) { + if (this.state === 1 /* CharRangeSection.Start */) { this.initialText = ll.text.substring(0, relativeStart); } - else if (this.state === 2 /* Entire */) { + else if (this.state === 2 /* CharRangeSection.Entire */) { this.initialText = ll.text.substring(0, relativeStart); this.trailingText = ll.text.substring(relativeStart + relativeLength); } @@ -180143,20 +181054,20 @@ var ts; // find sub-tree containing start var adjustedStart = rangeStart; while (adjustedStart >= childCharCount) { - this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0 /* PreStart */); + this.skipChild(adjustedStart, rangeLength, childIndex, walkFns, 0 /* CharRangeSection.PreStart */); adjustedStart -= childCharCount; childIndex++; childCharCount = this.children[childIndex].charCount(); } // Case I: both start and end of range in same subtree if ((adjustedStart + rangeLength) <= childCharCount) { - if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2 /* Entire */)) { + if (this.execWalk(adjustedStart, rangeLength, walkFns, childIndex, 2 /* CharRangeSection.Entire */)) { return; } } else { // Case II: start and end of range in different subtrees (possibly with subtrees in the middle) - if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1 /* Start */)) { + if (this.execWalk(adjustedStart, childCharCount - adjustedStart, walkFns, childIndex, 1 /* CharRangeSection.Start */)) { return; } var adjustedLength = rangeLength - (childCharCount - adjustedStart); @@ -180164,7 +181075,7 @@ var ts; var child = this.children[childIndex]; childCharCount = child.charCount(); while (adjustedLength > childCharCount) { - if (this.execWalk(0, childCharCount, walkFns, childIndex, 3 /* Mid */)) { + if (this.execWalk(0, childCharCount, walkFns, childIndex, 3 /* CharRangeSection.Mid */)) { return; } adjustedLength -= childCharCount; @@ -180172,7 +181083,7 @@ var ts; childCharCount = this.children[childIndex].charCount(); } if (adjustedLength > 0) { - if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4 /* End */)) { + if (this.execWalk(0, adjustedLength, walkFns, childIndex, 4 /* CharRangeSection.End */)) { return; } } @@ -180182,7 +181093,7 @@ var ts; var clen = this.children.length; if (childIndex < (clen - 1)) { for (var ej = childIndex + 1; ej < clen; ej++) { - this.skipChild(0, 0, ej, walkFns, 5 /* PostEnd */); + this.skipChild(0, 0, ej, walkFns, 5 /* CharRangeSection.PostEnd */); } } } @@ -180373,7 +181284,7 @@ var ts; for (var _i = 0, _a = Object.keys(deprecations); _i < _a.length; _i++) { var key = _a[_i]; var index = +key; - if (!isNaN(index) && ts.hasProperty(overloads, "" + index)) { + if (!isNaN(index) && ts.hasProperty(overloads, "".concat(index))) { overloads[index] = ts.Debug.deprecate(overloads[index], __assign(__assign({}, deprecations[index]), { name: name })); } } @@ -180396,7 +181307,7 @@ var ts; ts.createOverload = createOverload; function createBinder(overloads, binder) { return function (args) { - for (var i = 0; ts.hasProperty(overloads, "" + i) && ts.hasProperty(binder, "" + i); i++) { + for (var i = 0; ts.hasProperty(overloads, "".concat(i)) && ts.hasProperty(binder, "".concat(i)); i++) { var fn = binder[i]; if (fn(args)) { return i; @@ -181047,11 +181958,11 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic)` or the factory supplied by your transformation context instead. */ ts.createOptimisticUniqueName = ts.Debug.deprecate(function createOptimisticUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */); }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel)` or the factory supplied by your transformation context instead. */ ts.createFileLevelUniqueName = ts.Debug.deprecate(function createFileLevelUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */ | 32 /* FileLevel */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); }, factoryDeprecation); /** @deprecated Use `factory.createIndexSignature` or the factory supplied by your transformation context instead. */ ts.createIndexSignature = ts.Debug.deprecate(function createIndexSignature(decorators, modifiers, parameters, type) { @@ -181098,7 +182009,7 @@ var ts; } else { type = operatorOrType; - operator = 140 /* KeyOfKeyword */; + operator = 140 /* SyntaxKind.KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -181135,7 +182046,7 @@ var ts; /** @deprecated Use `factory.createConditional` or the factory supplied by your transformation context instead. */ ts.createConditional = ts.Debug.deprecate(function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { return arguments.length === 5 ? ts.factory.createConditionalExpression(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) : - arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* ColonToken */), whenTrueOrWhenFalse) : + arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* SyntaxKind.QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* SyntaxKind.ColonToken */), whenTrueOrWhenFalse) : ts.Debug.fail("Argument count mismatch"); }, factoryDeprecation); /** @deprecated Use `factory.createYield` or the factory supplied by your transformation context instead. */ @@ -181276,9 +182187,9 @@ var ts; ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) { if (pos === void 0) { pos = 0; } if (end === void 0) { end = 0; } - return ts.setTextRangePosEnd(kind === 305 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 80 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 305 /* SyntaxKind.SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* SyntaxKind.Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : !ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) : ts.parseBaseNodeFactory.createBaseNode(kind), pos, end); }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." }); @@ -181306,7 +182217,7 @@ var ts; (function (ts) { /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index ed87f7ef8913b..3ea4fe3130e4b 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -2096,6 +2096,12 @@ declare namespace ts { * It is _public_ so that (pre)transformers can set this field, * since it switches the builtin `node` module transform. Generally speaking, if unset, * the field is treated as though it is `ModuleKind.CommonJS`. + * + * Note that this field is only set by the module resolution process when + * `moduleResolution` is `Node16` or `NodeNext`, which is implied by the `module` setting + * of `Node16` or `NodeNext`, respectively, but may be overriden (eg, by a `moduleResolution` + * of `node`). If so, this field will be unset and source files will be considered to be + * CommonJS-output-format by the node module transformer and type checker, regardless of extension or context. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; } @@ -2420,6 +2426,7 @@ declare namespace ts { UseAliasDefinedOutsideCurrentScope = 16384, UseSingleQuotesForStringLiteralType = 268435456, NoTypeReduction = 536870912, + OmitThisParameter = 33554432, AllowThisInObjectLiteral = 32768, AllowQualifiedNameInPlaceOfIdentifier = 65536, /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ @@ -2450,6 +2457,7 @@ declare namespace ts { UseAliasDefinedOutsideCurrentScope = 16384, UseSingleQuotesForStringLiteralType = 268435456, NoTypeReduction = 536870912, + OmitThisParameter = 33554432, AllowUniqueESSymbolType = 1048576, AddUndefined = 131072, WriteArrowStyleSignature = 262144, @@ -2458,7 +2466,7 @@ declare namespace ts { InFirstTypeArgument = 4194304, InTypeAlias = 8388608, /** @deprecated */ WriteOwnNameForAnyLike = 0, - NodeBuilderFlagsMask = 814775659 + NodeBuilderFlagsMask = 848330091 } export enum SymbolFormatFlags { None = 0, @@ -4456,6 +4464,12 @@ declare namespace ts { /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. + * + * This does *not* return type parameters from a jsdoc reference to a generic type, eg + * + * type Id = (x: T) => T + * /** @type {Id} / + * function id(x) { return x } */ function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; @@ -5405,6 +5419,10 @@ declare namespace ts { resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[]; + /** + * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + */ + getModuleResolutionCache?(): ModuleResolutionCache | undefined; } interface WatchCompilerHost extends ProgramHost, WatchHost { /** Instead of using output d.ts file from project reference, use its source file */ @@ -6884,8 +6902,8 @@ declare namespace ts { * @param version Current version of the file. Only used if the file was not found * in the registry and a new one was created. */ - acquireDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; - acquireDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; + acquireDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; + acquireDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; /** * Request an updated version of an already existing SourceFile with a given fileName * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile @@ -6901,8 +6919,8 @@ declare namespace ts { * @param scriptSnapshot Text of the file. * @param version Current version of the file. */ - updateDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; - updateDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; + updateDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; + updateDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey; /** * Informs the DocumentRegistry that a file is not needed any longer. @@ -6912,9 +6930,10 @@ declare namespace ts { * * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file + * @param scriptKind The script kind of the file to be released */ - /**@deprecated pass scriptKind for correctness */ - releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + /**@deprecated pass scriptKind and impliedNodeFormat for correctness */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind?: ScriptKind): void; /** * Informs the DocumentRegistry that a file is not needed any longer. * @@ -6924,12 +6943,13 @@ declare namespace ts { * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file * @param scriptKind The script kind of the file to be released + * @param impliedNodeFormat The implied source file format of the file to be released */ - releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind, impliedNodeFormat: SourceFile["impliedNodeFormat"]): void; /** - * @deprecated pass scriptKind for correctness */ - releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; - releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; + * @deprecated pass scriptKind for and impliedNodeFormat correctness */ + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind?: ScriptKind): void; + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind, impliedNodeFormat: SourceFile["impliedNodeFormat"]): void; reportStats(): string; } type DocumentRegistryBucketKey = string & { diff --git a/lib/typescript.js b/lib/typescript.js index 2bca0bfcf9ef4..d5dc098131b97 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -21,7 +21,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -294,7 +294,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "4.8.1-rc"; /* @internal */ var Comparison; (function (Comparison) { @@ -341,7 +341,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); /* @internal */ @@ -1041,9 +1041,9 @@ var ts; case true: // relational comparison // falls through - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: continue; - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If `array` is sorted, `next` should **never** be less than `last`. return ts.Debug.fail("Array is unsorted."); } @@ -1079,7 +1079,7 @@ var ts; var prevElement = array[0]; for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) { var element = _a[_i]; - if (comparer(prevElement, element) === 1 /* GreaterThan */) { + if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) { return false; } prevElement = element; @@ -1133,27 +1133,27 @@ var ts; loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) { if (offsetB > 0) { // Ensure `arrayB` is properly sorted. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */); } loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) { if (offsetA > startA) { // Ensure `arrayA` is properly sorted. We only need to perform this check if // `offsetA` has changed since we entered the loop. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */); } switch (comparer(arrayB[offsetB], arrayA[offsetA])) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If B is less than A, B does not exist in arrayA. Add B to the result and // move to the next element in arrayB without changing the current position // in arrayA. result.push(arrayB[offsetB]); continue loopB; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: // If B is equal to A, B exists in arrayA. Move to the next element in // arrayB without adding B to the result or changing the current position // in arrayA. continue loopB; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: // If B is greater than A, we need to keep looking for B in arrayA. Move to // the next element in arrayA and recheck. continue loopA; @@ -1393,12 +1393,12 @@ var ts; var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle], middle); switch (keyComparer(midKey, key)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: low = middle + 1; break; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: return middle; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: high = middle - 1; break; } @@ -1670,6 +1670,43 @@ var ts; return createMultiMap(); } ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap; + function createQueue(items) { + var elements = (items === null || items === void 0 ? void 0 : items.slice()) || []; + var headIndex = 0; + function isEmpty() { + return headIndex === elements.length; + } + function enqueue() { + var items = []; + for (var _i = 0; _i < arguments.length; _i++) { + items[_i] = arguments[_i]; + } + elements.push.apply(elements, items); + } + function dequeue() { + if (isEmpty()) { + throw new Error("Queue is empty"); + } + var result = elements[headIndex]; + elements[headIndex] = undefined; // Don't keep referencing dequeued item + headIndex++; + // If more than half of the queue is empty, copy the remaining elements to the + // front and shrink the array (unless we'd be saving fewer than 100 slots) + if (headIndex > 100 && headIndex > (elements.length >> 1)) { + var newLength = elements.length - headIndex; + elements.copyWithin(/*target*/ 0, /*start*/ headIndex); + elements.length = newLength; + headIndex = 0; + } + return result; + } + return { + enqueue: enqueue, + dequeue: dequeue, + isEmpty: isEmpty, + }; + } + ts.createQueue = createQueue; /** * Creates a Set with custom equality and hash code functionality. This is useful when you * want to use something looser than object identity - e.g. "has the same span". @@ -1852,12 +1889,16 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; /** Does nothing. */ function noop(_) { } ts.noop = noop; + ts.noopPush = { + push: noop, + length: 0 + }; /** Do nothing and return false */ function returnFalse() { return false; @@ -1943,7 +1984,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -2015,11 +2056,11 @@ var ts; } ts.equateStringsCaseSensitive = equateStringsCaseSensitive; function compareComparableValues(a, b) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + a < b ? -1 /* Comparison.LessThan */ : + 1 /* Comparison.GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -2037,7 +2078,7 @@ var ts; } ts.compareTextSpans = compareTextSpans; function min(a, b, compare) { - return compare(a, b) === -1 /* LessThan */ ? a : b; + return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b; } ts.min = min; /** @@ -2054,14 +2095,14 @@ var ts; */ function compareStringsCaseInsensitive(a, b) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; a = a.toUpperCase(); b = b.toUpperCase(); - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive; /** @@ -2092,13 +2133,13 @@ var ts; return createStringComparer; function compareWithCallback(a, b, comparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; var value = comparer(a, b); - return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } function createIntlCollatorStringComparer(locale) { // Intl.Collator.prototype.compare is bound to the collator. See NOTE in @@ -2128,7 +2169,7 @@ var ts; return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b); } function compareStrings(a, b) { - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } } function getStringComparerFactory() { @@ -2189,9 +2230,9 @@ var ts; } ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI; function compareProperties(a, b, key, comparer) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : comparer(a[key], b[key]); } ts.compareProperties = compareProperties; @@ -2213,7 +2254,7 @@ var ts; * and 1 insertion/deletion at 3 characters) */ function getSpellingSuggestion(name, candidates, getName) { - var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34)); + var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34)); var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother. var bestCandidate; for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { @@ -2310,24 +2351,24 @@ var ts; var end = fileName.length; for (var pos = end - 1; pos > 0; pos--) { var ch = fileName.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) { // Match a \d+ segment do { --pos; ch = fileName.charCodeAt(pos); - } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */); } - else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) { // Looking for "min" or "min" // Already matched the 'n' --pos; ch = fileName.charCodeAt(pos); - if (ch !== 105 /* i */ && ch !== 73 /* I */) { + if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) { break; } --pos; ch = fileName.charCodeAt(pos); - if (ch !== 109 /* m */ && ch !== 77 /* M */) { + if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) { break; } --pos; @@ -2337,7 +2378,7 @@ var ts; // This character is not part of either suffix pattern break; } - if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) { break; } end = pos; @@ -2393,7 +2434,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; /** @@ -2494,12 +2535,12 @@ var ts; var newItem = newItems[newIndex]; var oldItem = oldItems[oldIndex]; var compareResult = comparer(newItem, oldItem); - if (compareResult === -1 /* LessThan */) { + if (compareResult === -1 /* Comparison.LessThan */) { inserted(newItem); newIndex++; hasChanges = true; } - else if (compareResult === 1 /* GreaterThan */) { + else if (compareResult === 1 /* Comparison.GreaterThan */) { deleted(oldItem); oldIndex++; hasChanges = true; @@ -2630,7 +2671,7 @@ var ts; (function (Debug) { var typeScriptVersion; /* eslint-disable prefer-const */ - var currentAssertionLevel = 0 /* None */; + var currentAssertionLevel = 0 /* AssertionLevel.None */; Debug.currentLogLevel = LogLevel.Warning; Debug.isDebugging = false; function getTypeScriptVersion() { @@ -2709,7 +2750,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2717,12 +2758,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2732,26 +2773,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2782,42 +2823,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2838,7 +2879,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; /** @@ -2942,6 +2983,22 @@ var ts; return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true); } Debug.formatFlowFlags = formatFlowFlags; + function formatRelationComparisonResult(result) { + return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true); + } + Debug.formatRelationComparisonResult = formatRelationComparisonResult; + function formatCheckMode(mode) { + return formatEnum(mode, ts.CheckMode, /*isFlags*/ true); + } + Debug.formatCheckMode = formatCheckMode; + function formatSignatureCheckMode(mode) { + return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true); + } + Debug.formatSignatureCheckMode = formatSignatureCheckMode; + function formatTypeFacts(facts) { + return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true); + } + Debug.formatTypeFacts = formatTypeFacts; var isDebugInfoEnabled = false; var extendedDebugModule; function extendedDebug() { @@ -2966,20 +3023,20 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" : - this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" : - this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" : - this.flags & 16 /* Assignment */ ? "FlowAssignment" : - this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" : - this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" : - this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" : - this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" : - this.flags & 512 /* Call */ ? "FlowCall" : - this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" : - this.flags & 1 /* Unreachable */ ? "FlowUnreachable" : + var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" : + this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" : + this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" : + this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" : "UnknownFlow"; - var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, @@ -3018,7 +3075,7 @@ var ts; // We don't care, this is debug code that's only enabled with a debugger attached - // we're just taking note of it for anyone checking regex performance in the future. defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -3070,10 +3127,10 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" : + var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" : "Symbol"; - var remainingSymbolFlags = this.flags & ~33554432 /* Transient */; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */; + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -3082,35 +3139,35 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" : - this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 /* BigIntLiteral */ ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : - this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : - this.flags & 32 /* Enum */ ? "EnumType" : - this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType " + this.intrinsicName : - this.flags & 1048576 /* Union */ ? "UnionType" : - this.flags & 2097152 /* Intersection */ ? "IntersectionType" : - this.flags & 4194304 /* Index */ ? "IndexType" : - this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : - this.flags & 16777216 /* Conditional */ ? "ConditionalType" : - this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : - this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : - this.flags & 524288 /* Object */ ? - this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : - this.objectFlags & 4 /* Reference */ ? "TypeReference" : - this.objectFlags & 8 /* Tuple */ ? "TupleType" : - this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : - this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : - this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : + var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" : + this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : + this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" : + this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) : + this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" : + this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" : + this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* TypeFlags.Object */ ? + this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" : + this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" : + this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" : + this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0; + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { // avoid recomputing @@ -3142,11 +3199,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -3178,7 +3235,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -3225,10 +3282,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -3272,6 +3329,48 @@ var ts; return wrapFunction(deprecation, func); } Debug.deprecate = deprecate; + function formatVariance(varianceFlags) { + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; + var result = variance === 0 /* VarianceFlags.Invariant */ ? "in out" : + variance === 3 /* VarianceFlags.Bivariant */ ? "[bivariant]" : + variance === 2 /* VarianceFlags.Contravariant */ ? "in" : + variance === 1 /* VarianceFlags.Covariant */ ? "out" : + variance === 4 /* VarianceFlags.Independent */ ? "[independent]" : ""; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { + result += " (unmeasurable)"; + } + else if (varianceFlags & 16 /* VarianceFlags.Unreliable */) { + result += " (unreliable)"; + } + return result; + } + Debug.formatVariance = formatVariance; + var DebugTypeMapper = /** @class */ (function () { + function DebugTypeMapper() { + } + DebugTypeMapper.prototype.__debugToString = function () { + var _a; + type(this); + switch (this.kind) { + case 3 /* TypeMapKind.Function */: return ((_a = this.debugInfo) === null || _a === void 0 ? void 0 : _a.call(this)) || "(function mapper)"; + case 0 /* TypeMapKind.Simple */: return "".concat(this.source.__debugTypeToString(), " -> ").concat(this.target.__debugTypeToString()); + case 1 /* TypeMapKind.Array */: return ts.zipWith(this.sources, this.targets || ts.map(this.sources, function () { return "any"; }), function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(typeof t === "string" ? t : t.__debugTypeToString()); }).join(", "); + case 2 /* TypeMapKind.Deferred */: return ts.zipWith(this.sources, this.targets, function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(t().__debugTypeToString()); }).join(", "); + case 5 /* TypeMapKind.Merged */: + case 4 /* TypeMapKind.Composite */: return "m1: ".concat(this.mapper1.__debugToString().split("\n").join("\n "), "\nm2: ").concat(this.mapper2.__debugToString().split("\n").join("\n ")); + default: return assertNever(this); + } + }; + return DebugTypeMapper; + }()); + Debug.DebugTypeMapper = DebugTypeMapper; + function attachDebugPrototypeIfDebug(mapper) { + if (Debug.isDebugging) { + return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype); + } + return mapper; + } + Debug.attachDebugPrototypeIfDebug = attachDebugPrototypeIfDebug; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); /* @internal */ @@ -3344,9 +3443,9 @@ var ts; // https://semver.org/#spec-item-11 // > Build metadata does not figure into precedence if (this === other) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (other === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; return ts.compareValues(this.major, other.major) || ts.compareValues(this.minor, other.minor) || ts.compareValues(this.patch, other.patch) @@ -3361,11 +3460,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -3394,11 +3493,11 @@ var ts; // > When major, minor, and patch are equal, a pre-release version has lower precedence // > than a normal version. if (left === right) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (left.length === 0) - return right.length === 0 ? 0 /* EqualTo */ : 1 /* GreaterThan */; + return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */; if (right.length === 0) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; // https://semver.org/#spec-item-11 // > Precedence for two pre-release versions with the same major, minor, and patch version // > MUST be determined by comparing each dot separated identifier from left to right until @@ -3415,7 +3514,7 @@ var ts; // https://semver.org/#spec-item-11 // > Numeric identifiers always have lower precedence than non-numeric identifiers. if (leftIsNumeric !== rightIsNumeric) - return leftIsNumeric ? -1 /* LessThan */ : 1 /* GreaterThan */; + return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; // https://semver.org/#spec-item-11 // > identifiers consisting of only digits are compared numerically var result = ts.compareValues(+leftIdentifier, +rightIdentifier); @@ -3632,7 +3731,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); /*@internal*/ @@ -3930,7 +4029,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3942,11 +4041,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -4013,9 +4112,9 @@ var ts; eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } tracingEnabled.push = push; - function pop() { + function pop(results) { ts.Debug.assert(eventStack.length > 0); - writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); + writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results); eventStack.length--; } tracingEnabled.pop = pop; @@ -4029,27 +4128,28 @@ var ts; tracingEnabled.popAll = popAll; // sample every 10ms var sampleInterval = 1000 * 10; - function writeStackEvent(index, endTime) { + function writeStackEvent(index, endTime, results) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { + ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`"); writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); } // test if [time,endTime) straddles a sampling point else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === "server" && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */) return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -4085,7 +4185,7 @@ var ts; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) var display = void 0; - if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { + if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) { try { display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } @@ -4094,7 +4194,7 @@ var ts; } } var indexedAccessProperties = {}; - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, @@ -4102,7 +4202,7 @@ var ts; }; } var referenceProperties = {}; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { var referenceType = type; referenceProperties = { instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, @@ -4111,7 +4211,7 @@ var ts; }; } var conditionalProperties = {}; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var conditionalType = type; conditionalProperties = { conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, @@ -4121,7 +4221,7 @@ var ts; }; } var substitutionProperties = {}; - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { var substitutionType = type; substitutionProperties = { substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, @@ -4129,7 +4229,7 @@ var ts; }; } var reverseMappedProperties = {}; - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { var reverseMappedType = type; reverseMappedProperties = { reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, @@ -4138,7 +4238,7 @@ var ts; }; } var evolvingArrayProperties = {}; - if (objectFlags & 256 /* EvolvingArray */) { + if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) { var evolvingArrayType = type; evolvingArrayProperties = { evolvingArrayElementType: evolvingArrayType.elementType.id, @@ -4156,7 +4256,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -4877,6 +4977,7 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; @@ -4917,6 +5018,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter"; // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -4928,7 +5030,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; /** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 814775659] = "NodeBuilderFlagsMask"; + TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -5407,9 +5509,10 @@ var ts; (function (TypeMapKind) { TypeMapKind[TypeMapKind["Simple"] = 0] = "Simple"; TypeMapKind[TypeMapKind["Array"] = 1] = "Array"; - TypeMapKind[TypeMapKind["Function"] = 2] = "Function"; - TypeMapKind[TypeMapKind["Composite"] = 3] = "Composite"; - TypeMapKind[TypeMapKind["Merged"] = 4] = "Merged"; + TypeMapKind[TypeMapKind["Deferred"] = 2] = "Deferred"; + TypeMapKind[TypeMapKind["Function"] = 3] = "Function"; + TypeMapKind[TypeMapKind["Composite"] = 4] = "Composite"; + TypeMapKind[TypeMapKind["Merged"] = 5] = "Merged"; })(TypeMapKind = ts.TypeMapKind || (ts.TypeMapKind = {})); var InferencePriority; (function (InferencePriority) { @@ -5804,10 +5907,8 @@ var ts; TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait"; TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper"; TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier"; - // Please leave this as 1 << 29. - // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. - // It is a good reminder of how much room we have left - TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["ContainsPrivateIdentifierInExpression"] = 536870912] = "ContainsPrivateIdentifierInExpression"; + TransformFlags[TransformFlags["HasComputedFlags"] = -2147483648] = "HasComputedFlags"; // Assertions // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript"; @@ -5826,23 +5927,23 @@ var ts; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes"; - TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes"; - TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes"; + TransformFlags[TransformFlags["OuterExpressionExcludes"] = -2147483648] = "OuterExpressionExcludes"; + TransformFlags[TransformFlags["PropertyAccessExcludes"] = -2147483648] = "PropertyAccessExcludes"; + TransformFlags[TransformFlags["NodeExcludes"] = -2147483648] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = -2072174592] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = -1937940480] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = -1937948672] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = -2005057536] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = -2013249536] = "PropertyExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = -2147344384] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = -1941676032] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes"; - TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; - TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes"; - TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = -2147278848] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = -2147450880] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = -2146893824] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = -2147483648] = "ParameterExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = -2147418112] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = -2147450880] = "BindingPatternExcludes"; TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper"; // Propagating flags // - Bitmasks for flags that should propagate from a child @@ -6095,37 +6196,37 @@ var ts; { name: "no-default-lib", optional: true }, { name: "resolution-mode", optional: true } ], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-dependency": { args: [{ name: "path" }, { name: "name", optional: true }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-module": { args: [{ name: "name" }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "ts-check": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "ts-nocheck": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "jsx": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxfrag": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsximportsource": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxruntime": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, }; })(ts || (ts = {})); @@ -6197,7 +6298,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -6414,7 +6515,7 @@ var ts; }; } function createDirectoryWatcher(dirName, dirPath, fallbackOptions) { - var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) { + var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName, modifiedTime) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" if (!ts.isString(relativeFileName)) return; @@ -6642,7 +6743,7 @@ var ts; function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) { // Iterate through existing children and update the watches if needed var parentWatcher = cache.get(dirPath); - if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) { + if (parentWatcher && fileSystemEntryExists(dirName, 1 /* FileSystemEntryKind.Directory */)) { // Schedule the update and postpone invoke for callbacks scheduleUpdateChildWatches(dirName, dirPath, fileName, options); return; @@ -6667,7 +6768,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -6680,7 +6781,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -6696,7 +6797,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -6715,11 +6816,11 @@ var ts; if (!parentWatcher) return false; var newChildWatches; - var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) { + var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* FileSystemEntryKind.Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) { var childFullName = ts.getNormalizedAbsolutePath(child, parentDir); // Filter our the symbolic link directories since those arent included in recursive watch // which is same behaviour when recursive: true is passed to fs.watch - return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : undefined; + return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* Comparison.EqualTo */ ? childFullName : undefined; }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher); parentWatcher.childWatches = newChildWatches || ts.emptyArray; return hasChanges; @@ -6817,7 +6918,7 @@ var ts; case ts.WatchFileKind.FixedChunkSizePolling: return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: - return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime), + return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); case ts.WatchFileKind.UseFsEventsOnParentDirectory: if (!nonPollingWatchFile) { @@ -6872,7 +6973,7 @@ var ts; } function watchDirectory(directoryName, callback, recursive, options) { if (fsSupportsRecursiveFsWatch) { - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); } if (!hostRecursiveDirectoryWatcher) { hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({ @@ -6904,7 +7005,7 @@ var ts; /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchDirectoryKind.UseFsEvents: - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: ts.Debug.assertNever(watchDirectoryKind); } @@ -6943,14 +7044,16 @@ var ts; return { close: function () { // Close the watcher (either existing file system entry watcher or missing file system entry watcher) - watcher.close(); - watcher = undefined; + if (watcher) { + watcher.close(); + watcher = undefined; + } } }; function updateWatcher(createWatcher) { // If watcher is not closed, update it if (watcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); watcher.close(); watcher = createWatcher(); } @@ -6961,7 +7064,7 @@ var ts; */ function watchPresentFileSystemEntry() { if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -6980,7 +7083,7 @@ var ts; // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -7275,7 +7378,7 @@ var ts; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -7284,7 +7387,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -7300,7 +7403,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -7498,8 +7601,8 @@ var ts; return false; } switch (entryKind) { - case 0 /* File */: return stat.isFile(); - case 1 /* Directory */: return stat.isDirectory(); + case 0 /* FileSystemEntryKind.File */: return stat.isFile(); + case 1 /* FileSystemEntryKind.Directory */: return stat.isDirectory(); default: return false; } } @@ -7511,10 +7614,10 @@ var ts; } } function fileExists(path) { - return fileSystemEntryExists(path, 0 /* File */); + return fileSystemEntryExists(path, 0 /* FileSystemEntryKind.File */); } function directoryExists(path) { - return fileSystemEntryExists(path, 1 /* Directory */); + return fileSystemEntryExists(path, 1 /* FileSystemEntryKind.Directory */); } function getDirectories(path) { return getAccessibleFileSystemEntries(path).directories.slice(); @@ -7585,8 +7688,8 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* AssertionLevel.Normal */ + : 0 /* AssertionLevel.None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7609,7 +7712,7 @@ var ts; * Determines whether a charCode corresponds to `/` or `\`. */ function isAnyDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */; } ts.isAnyDirectorySeparator = isAnyDirectorySeparator; /** @@ -7696,16 +7799,16 @@ var ts; ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; //// Path Parsing function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) || + (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */); } function getFileUrlVolumeSeparatorEnd(url, start) { var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) + if (ch0 === 58 /* CharacterCodes.colon */) return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) { var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */) return start + 3; } return -1; @@ -7719,18 +7822,18 @@ var ts; return 0; var ch0 = path.charCodeAt(0); // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) { if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); + var p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); if (p1 < 0) return path.length; // UNC: "//server" or "\\server" return p1 + 1; // UNC: "//server/" or "\\server\" } // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) { var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */) return 3; // DOS: "c:/" or "c:\" if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") @@ -7750,7 +7853,7 @@ var ts; isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) { // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" return ~(volumeSeparatorEnd + 1); } @@ -7827,7 +7930,7 @@ var ts; function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { if (!ts.startsWith(extension, ".")) extension = "." + extension; - if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) { var pathExtension = path.slice(path.length - extension.length); if (stringEqualityComparer(pathExtension, extension)) { return pathExtension; @@ -8111,17 +8214,17 @@ var ts; var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; // NOTE: Performance optimization - shortcut if the root segments differ as there would be no // need to perform path reduction. var aRoot = a.substring(0, getRootLength(a)); var bRoot = b.substring(0, getRootLength(b)); var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { + if (result !== 0 /* Comparison.EqualTo */) { return result; } // NOTE: Performance optimization - shortcut if there are no relative path segments in @@ -8138,7 +8241,7 @@ var ts; var sharedLength = Math.min(aComponents.length, bComponents.length); for (var i = 1; i < sharedLength; i++) { var result_2 = componentComparer(aComponents[i], bComponents[i]); - if (result_2 !== 0 /* EqualTo */) { + if (result_2 !== 0 /* Comparison.EqualTo */) { return result_2; } } @@ -8653,13 +8756,24 @@ var ts; resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."), Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"), + File_is_ECMAScript_module_because_0_has_field_type_with_value_module: diag(1458, ts.DiagnosticCategory.Message, "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458", "File is ECMAScript module because '{0}' has field \"type\" with value \"module\""), + File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module: diag(1459, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459", "File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\""), + File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""), + File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"), The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."), - Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."), + Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead."), catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."), An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), + An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."), + Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."), + The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead: diag(1479, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_reference_1479", "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"{0}\")' call instead."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module: diag(1480, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_packag_1480", "To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1: diag(1481, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Co_1481", "To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'."), + To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0: diag(1482, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0_1482", "To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'."), + To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module: diag(1483, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module_1483", "To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -8873,6 +8987,7 @@ var ts; Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."), Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."), Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."), + A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, ts.DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."), Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."), All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."), Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."), @@ -9160,6 +9275,7 @@ var ts; The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), + Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), 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}'."), @@ -10139,100 +10255,100 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 79 /* Identifier */; + return token >= 79 /* SyntaxKind.Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* SyntaxKind.GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; /** @internal */ ts.textToKeywordObj = (_a = { - abstract: 126 /* AbstractKeyword */, - any: 130 /* AnyKeyword */, - as: 127 /* AsKeyword */, - asserts: 128 /* AssertsKeyword */, - assert: 129 /* AssertKeyword */, - bigint: 158 /* BigIntKeyword */, - boolean: 133 /* BooleanKeyword */, - break: 81 /* BreakKeyword */, - case: 82 /* CaseKeyword */, - catch: 83 /* CatchKeyword */, - class: 84 /* ClassKeyword */, - continue: 86 /* ContinueKeyword */, - const: 85 /* ConstKeyword */ + abstract: 126 /* SyntaxKind.AbstractKeyword */, + any: 130 /* SyntaxKind.AnyKeyword */, + as: 127 /* SyntaxKind.AsKeyword */, + asserts: 128 /* SyntaxKind.AssertsKeyword */, + assert: 129 /* SyntaxKind.AssertKeyword */, + bigint: 158 /* SyntaxKind.BigIntKeyword */, + boolean: 133 /* SyntaxKind.BooleanKeyword */, + break: 81 /* SyntaxKind.BreakKeyword */, + case: 82 /* SyntaxKind.CaseKeyword */, + catch: 83 /* SyntaxKind.CatchKeyword */, + class: 84 /* SyntaxKind.ClassKeyword */, + continue: 86 /* SyntaxKind.ContinueKeyword */, + const: 85 /* SyntaxKind.ConstKeyword */ }, - _a["" + "constructor"] = 134 /* ConstructorKeyword */, - _a.debugger = 87 /* DebuggerKeyword */, - _a.declare = 135 /* DeclareKeyword */, - _a.default = 88 /* DefaultKeyword */, - _a.delete = 89 /* DeleteKeyword */, - _a.do = 90 /* DoKeyword */, - _a.else = 91 /* ElseKeyword */, - _a.enum = 92 /* EnumKeyword */, - _a.export = 93 /* ExportKeyword */, - _a.extends = 94 /* ExtendsKeyword */, - _a.false = 95 /* FalseKeyword */, - _a.finally = 96 /* FinallyKeyword */, - _a.for = 97 /* ForKeyword */, - _a.from = 156 /* FromKeyword */, - _a.function = 98 /* FunctionKeyword */, - _a.get = 136 /* GetKeyword */, - _a.if = 99 /* IfKeyword */, - _a.implements = 117 /* ImplementsKeyword */, - _a.import = 100 /* ImportKeyword */, - _a.in = 101 /* InKeyword */, - _a.infer = 137 /* InferKeyword */, - _a.instanceof = 102 /* InstanceOfKeyword */, - _a.interface = 118 /* InterfaceKeyword */, - _a.intrinsic = 138 /* IntrinsicKeyword */, - _a.is = 139 /* IsKeyword */, - _a.keyof = 140 /* KeyOfKeyword */, - _a.let = 119 /* LetKeyword */, - _a.module = 141 /* ModuleKeyword */, - _a.namespace = 142 /* NamespaceKeyword */, - _a.never = 143 /* NeverKeyword */, - _a.new = 103 /* NewKeyword */, - _a.null = 104 /* NullKeyword */, - _a.number = 147 /* NumberKeyword */, - _a.object = 148 /* ObjectKeyword */, - _a.package = 120 /* PackageKeyword */, - _a.private = 121 /* PrivateKeyword */, - _a.protected = 122 /* ProtectedKeyword */, - _a.public = 123 /* PublicKeyword */, - _a.override = 159 /* OverrideKeyword */, - _a.out = 144 /* OutKeyword */, - _a.readonly = 145 /* ReadonlyKeyword */, - _a.require = 146 /* RequireKeyword */, - _a.global = 157 /* GlobalKeyword */, - _a.return = 105 /* ReturnKeyword */, - _a.set = 149 /* SetKeyword */, - _a.static = 124 /* StaticKeyword */, - _a.string = 150 /* StringKeyword */, - _a.super = 106 /* SuperKeyword */, - _a.switch = 107 /* SwitchKeyword */, - _a.symbol = 151 /* SymbolKeyword */, - _a.this = 108 /* ThisKeyword */, - _a.throw = 109 /* ThrowKeyword */, - _a.true = 110 /* TrueKeyword */, - _a.try = 111 /* TryKeyword */, - _a.type = 152 /* TypeKeyword */, - _a.typeof = 112 /* TypeOfKeyword */, - _a.undefined = 153 /* UndefinedKeyword */, - _a.unique = 154 /* UniqueKeyword */, - _a.unknown = 155 /* UnknownKeyword */, - _a.var = 113 /* VarKeyword */, - _a.void = 114 /* VoidKeyword */, - _a.while = 115 /* WhileKeyword */, - _a.with = 116 /* WithKeyword */, - _a.yield = 125 /* YieldKeyword */, - _a.async = 131 /* AsyncKeyword */, - _a.await = 132 /* AwaitKeyword */, - _a.of = 160 /* OfKeyword */, + _a["" + "constructor"] = 134 /* SyntaxKind.ConstructorKeyword */, + _a.debugger = 87 /* SyntaxKind.DebuggerKeyword */, + _a.declare = 135 /* SyntaxKind.DeclareKeyword */, + _a.default = 88 /* SyntaxKind.DefaultKeyword */, + _a.delete = 89 /* SyntaxKind.DeleteKeyword */, + _a.do = 90 /* SyntaxKind.DoKeyword */, + _a.else = 91 /* SyntaxKind.ElseKeyword */, + _a.enum = 92 /* SyntaxKind.EnumKeyword */, + _a.export = 93 /* SyntaxKind.ExportKeyword */, + _a.extends = 94 /* SyntaxKind.ExtendsKeyword */, + _a.false = 95 /* SyntaxKind.FalseKeyword */, + _a.finally = 96 /* SyntaxKind.FinallyKeyword */, + _a.for = 97 /* SyntaxKind.ForKeyword */, + _a.from = 156 /* SyntaxKind.FromKeyword */, + _a.function = 98 /* SyntaxKind.FunctionKeyword */, + _a.get = 136 /* SyntaxKind.GetKeyword */, + _a.if = 99 /* SyntaxKind.IfKeyword */, + _a.implements = 117 /* SyntaxKind.ImplementsKeyword */, + _a.import = 100 /* SyntaxKind.ImportKeyword */, + _a.in = 101 /* SyntaxKind.InKeyword */, + _a.infer = 137 /* SyntaxKind.InferKeyword */, + _a.instanceof = 102 /* SyntaxKind.InstanceOfKeyword */, + _a.interface = 118 /* SyntaxKind.InterfaceKeyword */, + _a.intrinsic = 138 /* SyntaxKind.IntrinsicKeyword */, + _a.is = 139 /* SyntaxKind.IsKeyword */, + _a.keyof = 140 /* SyntaxKind.KeyOfKeyword */, + _a.let = 119 /* SyntaxKind.LetKeyword */, + _a.module = 141 /* SyntaxKind.ModuleKeyword */, + _a.namespace = 142 /* SyntaxKind.NamespaceKeyword */, + _a.never = 143 /* SyntaxKind.NeverKeyword */, + _a.new = 103 /* SyntaxKind.NewKeyword */, + _a.null = 104 /* SyntaxKind.NullKeyword */, + _a.number = 147 /* SyntaxKind.NumberKeyword */, + _a.object = 148 /* SyntaxKind.ObjectKeyword */, + _a.package = 120 /* SyntaxKind.PackageKeyword */, + _a.private = 121 /* SyntaxKind.PrivateKeyword */, + _a.protected = 122 /* SyntaxKind.ProtectedKeyword */, + _a.public = 123 /* SyntaxKind.PublicKeyword */, + _a.override = 159 /* SyntaxKind.OverrideKeyword */, + _a.out = 144 /* SyntaxKind.OutKeyword */, + _a.readonly = 145 /* SyntaxKind.ReadonlyKeyword */, + _a.require = 146 /* SyntaxKind.RequireKeyword */, + _a.global = 157 /* SyntaxKind.GlobalKeyword */, + _a.return = 105 /* SyntaxKind.ReturnKeyword */, + _a.set = 149 /* SyntaxKind.SetKeyword */, + _a.static = 124 /* SyntaxKind.StaticKeyword */, + _a.string = 150 /* SyntaxKind.StringKeyword */, + _a.super = 106 /* SyntaxKind.SuperKeyword */, + _a.switch = 107 /* SyntaxKind.SwitchKeyword */, + _a.symbol = 151 /* SyntaxKind.SymbolKeyword */, + _a.this = 108 /* SyntaxKind.ThisKeyword */, + _a.throw = 109 /* SyntaxKind.ThrowKeyword */, + _a.true = 110 /* SyntaxKind.TrueKeyword */, + _a.try = 111 /* SyntaxKind.TryKeyword */, + _a.type = 152 /* SyntaxKind.TypeKeyword */, + _a.typeof = 112 /* SyntaxKind.TypeOfKeyword */, + _a.undefined = 153 /* SyntaxKind.UndefinedKeyword */, + _a.unique = 154 /* SyntaxKind.UniqueKeyword */, + _a.unknown = 155 /* SyntaxKind.UnknownKeyword */, + _a.var = 113 /* SyntaxKind.VarKeyword */, + _a.void = 114 /* SyntaxKind.VoidKeyword */, + _a.while = 115 /* SyntaxKind.WhileKeyword */, + _a.with = 116 /* SyntaxKind.WithKeyword */, + _a.yield = 125 /* SyntaxKind.YieldKeyword */, + _a.async = 131 /* SyntaxKind.AsyncKeyword */, + _a.await = 132 /* SyntaxKind.AwaitKeyword */, + _a.of = 160 /* SyntaxKind.OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* SyntaxKind.OpenBraceToken */, "}": 19 /* SyntaxKind.CloseBraceToken */, "(": 20 /* SyntaxKind.OpenParenToken */, ")": 21 /* SyntaxKind.CloseParenToken */, "[": 22 /* SyntaxKind.OpenBracketToken */, "]": 23 /* SyntaxKind.CloseBracketToken */, ".": 24 /* SyntaxKind.DotToken */, "...": 25 /* SyntaxKind.DotDotDotToken */, ";": 26 /* SyntaxKind.SemicolonToken */, ",": 27 /* SyntaxKind.CommaToken */, "<": 29 /* SyntaxKind.LessThanToken */, ">": 31 /* SyntaxKind.GreaterThanToken */, "<=": 32 /* SyntaxKind.LessThanEqualsToken */, ">=": 33 /* SyntaxKind.GreaterThanEqualsToken */, "==": 34 /* SyntaxKind.EqualsEqualsToken */, "!=": 35 /* SyntaxKind.ExclamationEqualsToken */, "===": 36 /* SyntaxKind.EqualsEqualsEqualsToken */, "!==": 37 /* SyntaxKind.ExclamationEqualsEqualsToken */, "=>": 38 /* SyntaxKind.EqualsGreaterThanToken */, "+": 39 /* SyntaxKind.PlusToken */, "-": 40 /* SyntaxKind.MinusToken */, "**": 42 /* SyntaxKind.AsteriskAsteriskToken */, "*": 41 /* SyntaxKind.AsteriskToken */, "/": 43 /* SyntaxKind.SlashToken */, "%": 44 /* SyntaxKind.PercentToken */, "++": 45 /* SyntaxKind.PlusPlusToken */, "--": 46 /* SyntaxKind.MinusMinusToken */, "<<": 47 /* SyntaxKind.LessThanLessThanToken */, ">": 48 /* SyntaxKind.GreaterThanGreaterThanToken */, ">>>": 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* SyntaxKind.AmpersandToken */, "|": 51 /* SyntaxKind.BarToken */, "^": 52 /* SyntaxKind.CaretToken */, "!": 53 /* SyntaxKind.ExclamationToken */, "~": 54 /* SyntaxKind.TildeToken */, "&&": 55 /* SyntaxKind.AmpersandAmpersandToken */, "||": 56 /* SyntaxKind.BarBarToken */, "?": 57 /* SyntaxKind.QuestionToken */, "??": 60 /* SyntaxKind.QuestionQuestionToken */, "?.": 28 /* SyntaxKind.QuestionDotToken */, ":": 58 /* SyntaxKind.ColonToken */, "=": 63 /* SyntaxKind.EqualsToken */, "+=": 64 /* SyntaxKind.PlusEqualsToken */, "-=": 65 /* SyntaxKind.MinusEqualsToken */, "*=": 66 /* SyntaxKind.AsteriskEqualsToken */, "**=": 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */, "/=": 68 /* SyntaxKind.SlashEqualsToken */, "%=": 69 /* SyntaxKind.PercentEqualsToken */, "<<=": 70 /* SyntaxKind.LessThanLessThanEqualsToken */, ">>=": 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* SyntaxKind.AmpersandEqualsToken */, "|=": 74 /* SyntaxKind.BarEqualsToken */, "^=": 78 /* SyntaxKind.CaretEqualsToken */, "||=": 75 /* SyntaxKind.BarBarEqualsToken */, "&&=": 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */, "??=": 77 /* SyntaxKind.QuestionQuestionEqualsToken */, "@": 59 /* SyntaxKind.AtToken */, "#": 62 /* SyntaxKind.HashToken */, "`": 61 /* SyntaxKind.BacktickToken */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -10321,16 +10437,16 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { @@ -10359,17 +10475,17 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: result.push(lineStart); lineStart = pos; break; default: - if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) { result.push(lineStart); lineStart = pos; } @@ -10394,7 +10510,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -10472,18 +10588,18 @@ var ts; function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; + return ch === 32 /* CharacterCodes.space */ || + ch === 9 /* CharacterCodes.tab */ || + ch === 11 /* CharacterCodes.verticalTab */ || + ch === 12 /* CharacterCodes.formFeed */ || + ch === 160 /* CharacterCodes.nonBreakingSpace */ || + ch === 133 /* CharacterCodes.nextLine */ || + ch === 5760 /* CharacterCodes.ogham */ || + ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ || + ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ || + ch === 8287 /* CharacterCodes.mathematicalSpace */ || + ch === 12288 /* CharacterCodes.ideographicSpace */ || + ch === 65279 /* CharacterCodes.byteOrderMark */; } ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; function isLineBreak(ch) { @@ -10497,50 +10613,50 @@ var ts; // \u2029 Paragraph separator // Only the characters in Table 3 are treated as line terminators. Other new line or line // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; + return ch === 10 /* CharacterCodes.lineFeed */ || + ch === 13 /* CharacterCodes.carriageReturn */ || + ch === 8232 /* CharacterCodes.lineSeparator */ || + ch === 8233 /* CharacterCodes.paragraphSeparator */; } ts.isLineBreak = isLineBreak; function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isHexDigit(ch) { - return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */; + return isDigit(ch) || ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */ || ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */; } function isCodePoint(code) { return code <= 0x10FFFF; } /* @internal */ function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 55 /* CharacterCodes._7 */; } ts.isOctalDigit = isOctalDigit; function couldStartTrivia(text, pos) { // Keep in sync with skipTrivia var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: + case 13 /* CharacterCodes.carriageReturn */: + case 10 /* CharacterCodes.lineFeed */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 47 /* CharacterCodes.slash */: // starts of normal trivia // falls through - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: // Starts of conflict marker trivia return true; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: // Only if its the beginning can we have #! trivia return pos === 0; default: - return ch > 127 /* maxAsciiCharacter */; + return ch > 127 /* CharacterCodes.maxAsciiCharacter */; } } ts.couldStartTrivia = couldStartTrivia; @@ -10554,29 +10670,29 @@ var ts; while (true) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (stopAfterLineBreak) { return pos; } canConsumeStar = !!inJSDoc; continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: if (stopAtComments) { break; } - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { @@ -10587,10 +10703,10 @@ var ts; canConsumeStar = false; continue; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10600,24 +10716,24 @@ var ts; continue; } break; - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); canConsumeStar = false; continue; } break; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); canConsumeStar = false; continue; } break; - case 42 /* asterisk */: + case 42 /* CharacterCodes.asterisk */: if (canConsumeStar) { pos++; canConsumeStar = false; @@ -10625,7 +10741,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -10649,8 +10765,8 @@ var ts; return false; } } - return ch === 61 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + return ch === 61 /* CharacterCodes.equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* CharacterCodes.space */; } } return false; @@ -10661,18 +10777,18 @@ var ts; } var ch = text.charCodeAt(pos); var len = text.length; - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { while (pos < len && !isLineBreak(text.charCodeAt(pos))) { pos++; } } else { - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); // Consume everything from the start of a ||||||| or ======= marker to the start // of the next ======= or >>>>>>> marker. while (pos < len) { var currentChar = text.charCodeAt(pos); - if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { + if ((currentChar === 61 /* CharacterCodes.equals */ || currentChar === 62 /* CharacterCodes.greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -10733,12 +10849,12 @@ var ts; scan: while (pos >= 0 && pos < text.length) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (trailing) { break scan; @@ -10748,20 +10864,20 @@ var ts; pendingHasTrailingNewLine = true; } continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: var nextChar = text.charCodeAt(pos + 1); var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + if (nextChar === 47 /* CharacterCodes.slash */ || nextChar === 42 /* CharacterCodes.asterisk */) { + var kind = nextChar === 47 /* CharacterCodes.slash */ ? 2 /* SyntaxKind.SingleLineCommentTrivia */ : 3 /* SyntaxKind.MultiLineCommentTrivia */; var startPos = pos; pos += 2; - if (nextChar === 47 /* slash */) { + if (nextChar === 47 /* CharacterCodes.slash */) { while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { hasTrailingNewLine = true; @@ -10772,7 +10888,7 @@ var ts; } else { while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10797,7 +10913,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -10852,17 +10968,17 @@ var ts; } ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } ts.isIdentifierStart = isIdentifierStart; function isIdentifierPart(ch, languageVersion, identifierVariant) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ || ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || // "-" and ":" are valid in JSX Identifiers - (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + (identifierVariant === 1 /* LanguageVariant.JSX */ ? (ch === 45 /* CharacterCodes.minus */ || ch === 58 /* CharacterCodes.colon */) : false) || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; /* @internal */ @@ -10881,7 +10997,7 @@ var ts; ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + if (languageVariant === void 0) { languageVariant = 0 /* LanguageVariant.Standard */; } var text = textInitial; // Current position (end position of text of current token) var pos; @@ -10904,15 +11020,15 @@ var ts; getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, - hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, - hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, - hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; }, - isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; }, - isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* TokenFlags.UnicodeEscape */) !== 0; }, + hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* TokenFlags.ExtendedUnicodeEscape */) !== 0; }, + hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */) !== 0; }, + hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* TokenFlags.PrecedingJSDocComment */) !== 0; }, + isIdentifier: function () { return token === 79 /* SyntaxKind.Identifier */ || token > 116 /* SyntaxKind.LastReservedWord */; }, + isReservedWord: function () { return token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */; }, + isUnterminated: function () { return (tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, - getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, + getNumericLiteralFlags: function () { return tokenFlags & 1008 /* TokenFlags.NumericLiteralFlags */; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, reScanAsteriskEqualsToken: reScanAsteriskEqualsToken, @@ -10967,8 +11083,8 @@ var ts; var result = ""; while (true) { var ch = text.charCodeAt(pos); - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10992,7 +11108,7 @@ var ts; } break; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return result + text.substring(start, pos); @@ -11002,15 +11118,15 @@ var ts; var mainFragment = scanNumberFragment(); var decimalFragment; var scientificFragment; - if (text.charCodeAt(pos) === 46 /* dot */) { + if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) { pos++; decimalFragment = scanNumberFragment(); } var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) { pos++; - tokenFlags |= 16 /* Scientific */; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + tokenFlags |= 16 /* TokenFlags.Scientific */; + if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos++; var preNumericPart = pos; var finalFragment = scanNumberFragment(); @@ -11023,7 +11139,7 @@ var ts; } } var result; - if (tokenFlags & 512 /* ContainsSeparator */) { + if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) { result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; @@ -11035,10 +11151,10 @@ var ts; else { result = text.substring(start, end); // No need to use all the fragments; no _ removal needed } - if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { - checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* Scientific */)); + if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) { + checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */)); return { - type: 8 /* NumericLiteral */, + type: 8 /* SyntaxKind.NumericLiteral */, value: "" + +result // if value is not an integer, it can be safely coerced to a number }; } @@ -11096,8 +11212,8 @@ var ts; var isPreviousTokenSeparator = false; while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); - if (canHaveSeparators && ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (canHaveSeparators && ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -11112,11 +11228,11 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 65 /* A */ && ch <= 70 /* F */) { - ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase + if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) { + ch += 97 /* CharacterCodes.a */ - 65 /* CharacterCodes.A */; // standardize hex literals to lowercase } - else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || - (ch >= 97 /* a */ && ch <= 102 /* f */))) { + else if (!((ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) || + (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */))) { break; } valueChars.push(ch); @@ -11126,7 +11242,7 @@ var ts; if (valueChars.length < minCount) { valueChars = []; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return String.fromCharCode.apply(String, valueChars); @@ -11140,7 +11256,7 @@ var ts; while (true) { if (pos >= end) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11150,7 +11266,7 @@ var ts; pos++; break; } - if (ch === 92 /* backslash */ && !jsxAttributeString) { + if (ch === 92 /* CharacterCodes.backslash */ && !jsxAttributeString) { result += text.substring(start, pos); result += scanEscapeSequence(); start = pos; @@ -11158,7 +11274,7 @@ var ts; } if (isLineBreak(ch) && !jsxAttributeString) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11171,7 +11287,7 @@ var ts; * a literal component of a TemplateExpression. */ function scanTemplateAndSetTokenValue(isTaggedTemplate) { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + var startedWithBacktick = text.charCodeAt(pos) === 96 /* CharacterCodes.backtick */; pos++; var start = pos; var contents = ""; @@ -11179,28 +11295,28 @@ var ts; while (true) { if (pos >= end) { contents += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } var currChar = text.charCodeAt(pos); // '`' - if (currChar === 96 /* backtick */) { + if (currChar === 96 /* CharacterCodes.backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } // '${' - if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + if (currChar === 36 /* CharacterCodes.$ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* CharacterCodes.openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* SyntaxKind.TemplateHead */ : 16 /* SyntaxKind.TemplateMiddle */; break; } // Escape character - if (currChar === 92 /* backslash */) { + if (currChar === 92 /* CharacterCodes.backslash */) { contents += text.substring(start, pos); contents += scanEscapeSequence(isTaggedTemplate); start = pos; @@ -11208,10 +11324,10 @@ var ts; } // Speculated ECMAScript 6 Spec 11.8.6.1: // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { + if (currChar === 13 /* CharacterCodes.carriageReturn */) { contents += text.substring(start, pos); pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } contents += "\n"; @@ -11234,47 +11350,47 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 48 /* _0 */: + case 48 /* CharacterCodes._0 */: // '\01' if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } return "\0"; - case 98 /* b */: + case 98 /* CharacterCodes.b */: return "\b"; - case 116 /* t */: + case 116 /* CharacterCodes.t */: return "\t"; - case 110 /* n */: + case 110 /* CharacterCodes.n */: return "\n"; - case 118 /* v */: + case 118 /* CharacterCodes.v */: return "\v"; - case 102 /* f */: + case 102 /* CharacterCodes.f */: return "\f"; - case 114 /* r */: + case 114 /* CharacterCodes.r */: return "\r"; - case 39 /* singleQuote */: + case 39 /* CharacterCodes.singleQuote */: return "\'"; - case 34 /* doubleQuote */: + case 34 /* CharacterCodes.doubleQuote */: return "\""; - case 117 /* u */: + case 117 /* CharacterCodes.u */: if (isTaggedTemplate) { // '\u' or '\u0' or '\u00' or '\u000' for (var escapePos = pos; escapePos < pos + 4; escapePos++) { - if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) { + if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* CharacterCodes.openBrace */) { pos = escapePos; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } } // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + if (pos < end && text.charCodeAt(pos) === 123 /* CharacterCodes.openBrace */) { pos++; // '\u{' if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } if (isTaggedTemplate) { @@ -11282,29 +11398,29 @@ var ts; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; // '\u{Not Code Point' or '\u{CodePoint' - if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* CharacterCodes.closeBrace */) { + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else { pos = savePos; } } - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; return scanExtendedUnicodeEscape(); } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: + case 120 /* CharacterCodes.x */: if (isTaggedTemplate) { if (!isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else if (!isHexDigit(text.charCodeAt(pos + 1))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } @@ -11312,14 +11428,14 @@ var ts; return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: + case 10 /* CharacterCodes.lineFeed */: + case 8232 /* CharacterCodes.lineSeparator */: + case 8233 /* CharacterCodes.paragraphSeparator */: return ""; default: return String.fromCharCode(ch); @@ -11352,7 +11468,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) === 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -11368,7 +11484,7 @@ var ts; // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* CharacterCodes.u */) { var start_1 = pos; pos += 2; var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false); @@ -11378,7 +11494,7 @@ var ts; return -1; } function peekExtendedUnicodeEscape() { - if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) { var start_2 = pos; pos += 3; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); @@ -11396,11 +11512,11 @@ var ts; if (isIdentifierPart(ch, languageVersion)) { pos += charSize(ch); } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { ch = peekExtendedUnicodeEscape(); if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; result += scanExtendedUnicodeEscape(); start = pos; continue; @@ -11409,7 +11525,7 @@ var ts; if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; result += text.substring(start, pos); result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters @@ -11428,14 +11544,14 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 12) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { var keyword = textToKeyword.get(tokenValue); if (keyword !== undefined) { return token = keyword; } } } - return token = 79 /* Identifier */; + return token = 79 /* SyntaxKind.Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -11446,8 +11562,8 @@ var ts; while (true) { var ch = text.charCodeAt(pos); // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (separatorAllowed) { separatorAllowed = false; isPreviousTokenSeparator = true; @@ -11462,101 +11578,101 @@ var ts; continue; } separatorAllowed = true; - if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { + if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) { break; } value += text[pos]; pos++; isPreviousTokenSeparator = false; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return value; } function checkBigIntSuffix() { - if (text.charCodeAt(pos) === 110 /* n */) { + if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) { tokenValue += "n"; // Use base 10 instead of base 2 or base 8 for shorter literals - if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + if (tokenFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; } pos++; - return 9 /* BigIntLiteral */; + return 9 /* SyntaxKind.BigIntLiteral */; } else { // not a bigint, so can convert to number in simplified form // Number() may not support 0b or 0o, so use parseInt() instead - var numericValue = tokenFlags & 128 /* BinarySpecifier */ + var numericValue = tokenFlags & 128 /* TokenFlags.BinarySpecifier */ ? parseInt(tokenValue.slice(2), 2) // skip "0b" - : tokenFlags & 256 /* OctalSpecifier */ + : tokenFlags & 256 /* TokenFlags.OctalSpecifier */ ? parseInt(tokenValue.slice(2), 8) // skip "0o" : +tokenValue; tokenValue = "" + numericValue; - return 8 /* NumericLiteral */; + return 8 /* SyntaxKind.NumericLiteral */; } } function scan() { var _a; startPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + if (ch === 35 /* CharacterCodes.hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { continue; } else { - return token = 6 /* ShebangTrivia */; + return token = 6 /* SyntaxKind.ShebangTrivia */; } } switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - tokenFlags |= 1 /* PrecedingLineBreak */; + case 10 /* CharacterCodes.lineFeed */: + case 13 /* CharacterCodes.carriageReturn */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; if (skipTrivia) { pos++; continue; } else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + if (ch === 13 /* CharacterCodes.carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { // consume both CR and LF pos += 2; } else { pos++; } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 5760 /* ogham */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 8287 /* mathematicalSpace */: - case 12288 /* ideographicSpace */: - case 65279 /* byteOrderMark */: + return token = 4 /* SyntaxKind.NewLineTrivia */; + } + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 160 /* CharacterCodes.nonBreakingSpace */: + case 5760 /* CharacterCodes.ogham */: + case 8192 /* CharacterCodes.enQuad */: + case 8193 /* CharacterCodes.emQuad */: + case 8194 /* CharacterCodes.enSpace */: + case 8195 /* CharacterCodes.emSpace */: + case 8196 /* CharacterCodes.threePerEmSpace */: + case 8197 /* CharacterCodes.fourPerEmSpace */: + case 8198 /* CharacterCodes.sixPerEmSpace */: + case 8199 /* CharacterCodes.figureSpace */: + case 8200 /* CharacterCodes.punctuationSpace */: + case 8201 /* CharacterCodes.thinSpace */: + case 8202 /* CharacterCodes.hairSpace */: + case 8203 /* CharacterCodes.zeroWidthSpace */: + case 8239 /* CharacterCodes.narrowNoBreakSpace */: + case 8287 /* CharacterCodes.mathematicalSpace */: + case 12288 /* CharacterCodes.ideographicSpace */: + case 65279 /* CharacterCodes.byteOrderMark */: if (skipTrivia) { pos++; continue; @@ -11565,98 +11681,98 @@ var ts; while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; + return token = 5 /* SyntaxKind.WhitespaceTrivia */; } - case 33 /* exclamation */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; + case 33 /* CharacterCodes.exclamation */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } - return pos += 2, token = 35 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* SyntaxKind.ExclamationEqualsToken */; } pos++; - return token = 53 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + return token = 53 /* SyntaxKind.ExclamationToken */; + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(); - return token = 10 /* StringLiteral */; - case 96 /* backtick */: + return token = 10 /* SyntaxKind.StringLiteral */; + case 96 /* CharacterCodes.backtick */: return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* PercentEqualsToken */; + case 37 /* CharacterCodes.percent */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 69 /* SyntaxKind.PercentEqualsToken */; } pos++; - return token = 44 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; + return token = 44 /* SyntaxKind.PercentToken */; + case 38 /* CharacterCodes.ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* CharacterCodes.ampersand */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */; } - return pos += 2, token = 55 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* SyntaxKind.AmpersandAmpersandToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* AmpersandEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 73 /* SyntaxKind.AmpersandEqualsToken */; } pos++; - return token = 50 /* AmpersandToken */; - case 40 /* openParen */: + return token = 50 /* SyntaxKind.AmpersandToken */; + case 40 /* CharacterCodes.openParen */: pos++; - return token = 20 /* OpenParenToken */; - case 41 /* closeParen */: + return token = 20 /* SyntaxKind.OpenParenToken */; + case 41 /* CharacterCodes.closeParen */: pos++; - return token = 21 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AsteriskEqualsToken */; + return token = 21 /* SyntaxKind.CloseParenToken */; + case 42 /* CharacterCodes.asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 66 /* SyntaxKind.AsteriskEqualsToken */; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 42 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* SyntaxKind.AsteriskAsteriskToken */; } pos++; - if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { + if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */)) { // decoration at the start of a JSDoc comment line asteriskSeen = true; continue; } - return token = 41 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 45 /* PlusPlusToken */; + return token = 41 /* SyntaxKind.AsteriskToken */; + case 43 /* CharacterCodes.plus */: + if (text.charCodeAt(pos + 1) === 43 /* CharacterCodes.plus */) { + return pos += 2, token = 45 /* SyntaxKind.PlusPlusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PlusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 64 /* SyntaxKind.PlusEqualsToken */; } pos++; - return token = 39 /* PlusToken */; - case 44 /* comma */: + return token = 39 /* SyntaxKind.PlusToken */; + case 44 /* CharacterCodes.comma */: pos++; - return token = 27 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 46 /* MinusMinusToken */; + return token = 27 /* SyntaxKind.CommaToken */; + case 45 /* CharacterCodes.minus */: + if (text.charCodeAt(pos + 1) === 45 /* CharacterCodes.minus */) { + return pos += 2, token = 46 /* SyntaxKind.MinusMinusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* MinusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 65 /* SyntaxKind.MinusEqualsToken */; } pos++; - return token = 40 /* MinusToken */; - case 46 /* dot */: + return token = 40 /* SyntaxKind.MinusToken */; + case 46 /* CharacterCodes.dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; - return token = 8 /* NumericLiteral */; + return token = 8 /* SyntaxKind.NumericLiteral */; } - if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 25 /* DotDotDotToken */; + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && text.charCodeAt(pos + 2) === 46 /* CharacterCodes.dot */) { + return pos += 3, token = 25 /* SyntaxKind.DotDotDotToken */; } pos++; - return token = 24 /* DotToken */; - case 47 /* slash */: + return token = 24 /* SyntaxKind.DotToken */; + case 47 /* CharacterCodes.slash */: // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < end) { if (isLineBreak(text.charCodeAt(pos))) { @@ -11669,20 +11785,20 @@ var ts; continue; } else { - return token = 2 /* SingleLineCommentTrivia */; + return token = 2 /* SyntaxKind.SingleLineCommentTrivia */; } } // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) { - tokenFlags |= 2 /* PrecedingJSDocComment */; + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) !== 47 /* CharacterCodes.slash */) { + tokenFlags |= 2 /* TokenFlags.PrecedingJSDocComment */; } var commentClosed = false; var lastLineStart = tokenPos; while (pos < end) { var ch_1 = text.charCodeAt(pos); - if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (ch_1 === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; commentClosed = true; break; @@ -11690,7 +11806,7 @@ var ts; pos++; if (isLineBreak(ch_1)) { lastLineStart = pos; - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; } } commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart); @@ -11702,18 +11818,18 @@ var ts; } else { if (!commentClosed) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; } - return token = 3 /* MultiLineCommentTrivia */; + return token = 3 /* SyntaxKind.MultiLineCommentTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* SlashEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 68 /* SyntaxKind.SlashEqualsToken */; } pos++; - return token = 43 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + return token = 43 /* SyntaxKind.SlashToken */; + case 48 /* CharacterCodes._0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* CharacterCodes.X */ || text.charCodeAt(pos + 1) === 120 /* CharacterCodes.x */)) { pos += 2; tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); if (!tokenValue) { @@ -11721,10 +11837,10 @@ var ts; tokenValue = "0"; } tokenValue = "0x" + tokenValue; - tokenFlags |= 64 /* HexSpecifier */; + tokenFlags |= 64 /* TokenFlags.HexSpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* CharacterCodes.B */ || text.charCodeAt(pos + 1) === 98 /* CharacterCodes.b */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 2); if (!tokenValue) { @@ -11732,10 +11848,10 @@ var ts; tokenValue = "0"; } tokenValue = "0b" + tokenValue; - tokenFlags |= 128 /* BinarySpecifier */; + tokenFlags |= 128 /* TokenFlags.BinarySpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* CharacterCodes.O */ || text.charCodeAt(pos + 1) === 111 /* CharacterCodes.o */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 8); if (!tokenValue) { @@ -11743,175 +11859,175 @@ var ts; tokenValue = "0"; } tokenValue = "0o" + tokenValue; - tokenFlags |= 256 /* OctalSpecifier */; + tokenFlags |= 256 /* TokenFlags.OctalSpecifier */; return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - tokenFlags |= 32 /* Octal */; - return token = 8 /* NumericLiteral */; + tokenFlags |= 32 /* TokenFlags.Octal */; + return token = 8 /* SyntaxKind.NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). // falls through - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: + case 49 /* CharacterCodes._1 */: + case 50 /* CharacterCodes._2 */: + case 51 /* CharacterCodes._3 */: + case 52 /* CharacterCodes._4 */: + case 53 /* CharacterCodes._5 */: + case 54 /* CharacterCodes._6 */: + case 55 /* CharacterCodes._7 */: + case 56 /* CharacterCodes._8 */: + case 57 /* CharacterCodes._9 */: (_a = scanNumber(), token = _a.type, tokenValue = _a.value); return token; - case 58 /* colon */: + case 58 /* CharacterCodes.colon */: pos++; - return token = 58 /* ColonToken */; - case 59 /* semicolon */: + return token = 58 /* SyntaxKind.ColonToken */; + case 59 /* CharacterCodes.semicolon */: pos++; - return token = 26 /* SemicolonToken */; - case 60 /* lessThan */: + return token = 26 /* SyntaxKind.SemicolonToken */; + case 60 /* CharacterCodes.lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 70 /* SyntaxKind.LessThanLessThanEqualsToken */; } - return pos += 2, token = 47 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* SyntaxKind.LessThanLessThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 32 /* LessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 32 /* SyntaxKind.LessThanEqualsToken */; } - if (languageVariant === 1 /* JSX */ && - text.charCodeAt(pos + 1) === 47 /* slash */ && - text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 30 /* LessThanSlashToken */; + if (languageVariant === 1 /* LanguageVariant.JSX */ && + text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */ && + text.charCodeAt(pos + 2) !== 42 /* CharacterCodes.asterisk */) { + return pos += 2, token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; - case 61 /* equals */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 61 /* CharacterCodes.equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 36 /* SyntaxKind.EqualsEqualsEqualsToken */; } - return pos += 2, token = 34 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* SyntaxKind.EqualsEqualsToken */; } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 38 /* EqualsGreaterThanToken */; + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + return pos += 2, token = 38 /* SyntaxKind.EqualsGreaterThanToken */; } pos++; - return token = 63 /* EqualsToken */; - case 62 /* greaterThan */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } pos++; - return token = 31 /* GreaterThanToken */; - case 63 /* question */: - if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) { - return pos += 2, token = 28 /* QuestionDotToken */; + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 63 /* CharacterCodes.question */: + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && !isDigit(text.charCodeAt(pos + 2))) { + return pos += 2, token = 28 /* SyntaxKind.QuestionDotToken */; } - if (text.charCodeAt(pos + 1) === 63 /* question */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; + if (text.charCodeAt(pos + 1) === 63 /* CharacterCodes.question */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } - return pos += 2, token = 60 /* QuestionQuestionToken */; + return pos += 2, token = 60 /* SyntaxKind.QuestionQuestionToken */; } pos++; - return token = 57 /* QuestionToken */; - case 91 /* openBracket */: + return token = 57 /* SyntaxKind.QuestionToken */; + case 91 /* CharacterCodes.openBracket */: pos++; - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: pos++; - return token = 23 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 78 /* CaretEqualsToken */; + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 94 /* CharacterCodes.caret */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 78 /* SyntaxKind.CaretEqualsToken */; } pos++; - return token = 52 /* CaretToken */; - case 123 /* openBrace */: + return token = 52 /* SyntaxKind.CaretToken */; + case 123 /* CharacterCodes.openBrace */: pos++; - return token = 18 /* OpenBraceToken */; - case 124 /* bar */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 124 /* CharacterCodes.bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 75 /* BarBarEqualsToken */; + if (text.charCodeAt(pos + 1) === 124 /* CharacterCodes.bar */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 75 /* SyntaxKind.BarBarEqualsToken */; } - return pos += 2, token = 56 /* BarBarToken */; + return pos += 2, token = 56 /* SyntaxKind.BarBarToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 74 /* BarEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 74 /* SyntaxKind.BarEqualsToken */; } pos++; - return token = 51 /* BarToken */; - case 125 /* closeBrace */: + return token = 51 /* SyntaxKind.BarToken */; + case 125 /* CharacterCodes.closeBrace */: pos++; - return token = 19 /* CloseBraceToken */; - case 126 /* tilde */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 126 /* CharacterCodes.tilde */: pos++; - return token = 54 /* TildeToken */; - case 64 /* at */: + return token = 54 /* SyntaxKind.TildeToken */; + case 64 /* CharacterCodes.at */: pos++; - return token = 59 /* AtToken */; - case 92 /* backslash */: + return token = 59 /* SyntaxKind.AtToken */; + case 92 /* CharacterCodes.backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } error(ts.Diagnostics.Invalid_character); pos++; - return token = 0 /* Unknown */; - case 35 /* hash */: + return token = 0 /* SyntaxKind.Unknown */; + case 35 /* CharacterCodes.hash */: if (pos !== 0 && text[pos + 1] === "!") { error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file); pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; @@ -11921,7 +12037,7 @@ var ts; tokenValue = String.fromCharCode(codePointAt(text, pos)); error(ts.Diagnostics.Invalid_character, pos++, charSize(ch)); } - return token = 80 /* PrivateIdentifier */; + return token = 80 /* SyntaxKind.PrivateIdentifier */; default: var identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { @@ -11932,23 +12048,23 @@ var ts; continue; } else if (isLineBreak(ch)) { - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; pos += charSize(ch); continue; } var size = charSize(ch); error(ts.Diagnostics.Invalid_character, pos, size); pos += size; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } } function reScanInvalidIdentifier() { - ts.Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); + ts.Debug.assert(token === 0 /* SyntaxKind.Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); pos = tokenPos = startPos; tokenFlags = 0; var ch = codePointAt(text, pos); - var identifierKind = scanIdentifier(ch, 99 /* ESNext */); + var identifierKind = scanIdentifier(ch, 99 /* ScriptTarget.ESNext */); if (identifierKind) { return token = identifierKind; } @@ -11962,41 +12078,41 @@ var ts; while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { + if (ch === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return getIdentifierToken(); } } function reScanGreaterToken() { - if (token === 31 /* GreaterThanToken */) { - if (text.charCodeAt(pos) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + if (text.charCodeAt(pos) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 48 /* GreaterThanGreaterThanToken */; + return token = 48 /* SyntaxKind.GreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos) === 61 /* equals */) { + if (text.charCodeAt(pos) === 61 /* CharacterCodes.equals */) { pos++; - return token = 33 /* GreaterThanEqualsToken */; + return token = 33 /* SyntaxKind.GreaterThanEqualsToken */; } } return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* SyntaxKind.AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 63 /* EqualsToken */; + return token = 63 /* SyntaxKind.EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { + if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -12004,13 +12120,13 @@ var ts; // If we reach the end of a file, or hit a newline, then this is an unterminated // regex. Report error and return what we have so far. if (p >= end) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -12019,19 +12135,19 @@ var ts; // reset the flag and just advance to the next char. inEscape = false; } - else if (ch === 47 /* slash */ && !inCharacterClass) { + else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) { // A slash within a character class is permissible, // but in general it signals the end of the regexp literal. p++; break; } - else if (ch === 91 /* openBracket */) { + else if (ch === 91 /* CharacterCodes.openBracket */) { inCharacterClass = true; } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { inEscape = true; } - else if (ch === 93 /* closeBracket */) { + else if (ch === 93 /* CharacterCodes.closeBracket */) { inCharacterClass = false; } p++; @@ -12041,7 +12157,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 13 /* RegularExpressionLiteral */; + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } return token; } @@ -12062,9 +12178,9 @@ var ts; } switch (match[1]) { case "ts-expect-error": - return 0 /* ExpectError */; + return 0 /* CommentDirectiveType.ExpectError */; case "ts-ignore": - return 1 /* Ignore */; + return 1 /* CommentDirectiveType.Ignore */; } return undefined; } @@ -12072,7 +12188,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken(isTaggedTemplate) { - ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* SyntaxKind.CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(isTaggedTemplate); } @@ -12086,42 +12202,42 @@ var ts; return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { - if (token === 47 /* LessThanLessThanToken */) { + if (token === 47 /* SyntaxKind.LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } return token; } function reScanHashToken() { - if (token === 80 /* PrivateIdentifier */) { + if (token === 80 /* SyntaxKind.PrivateIdentifier */) { pos = tokenPos + 1; - return token = 62 /* HashToken */; + return token = 62 /* SyntaxKind.HashToken */; } return token; } function reScanQuestionToken() { - ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + ts.Debug.assert(token === 60 /* SyntaxKind.QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; - return token = 57 /* QuestionToken */; + return token = 57 /* SyntaxKind.QuestionToken */; } function scanJsxToken(allowMultilineJsxText) { if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (char === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; - return token = 30 /* LessThanSlashToken */; + return token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { pos++; - return token = 18 /* OpenBraceToken */; + return token = 18 /* SyntaxKind.OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -12129,20 +12245,20 @@ var ts; // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { break; } - if (char === 60 /* lessThan */) { + if (char === 60 /* CharacterCodes.lessThan */) { if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } break; } - if (char === 62 /* greaterThan */) { + if (char === 62 /* CharacterCodes.greaterThan */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1); } - if (char === 125 /* closeBrace */) { + if (char === 125 /* CharacterCodes.closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. @@ -12165,7 +12281,7 @@ var ts; pos++; } tokenValue = text.substring(startPos, pos); - return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* SyntaxKind.JsxTextAllWhiteSpaces */ : 11 /* SyntaxKind.JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -12178,16 +12294,16 @@ var ts; var namespaceSeparator = false; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */) { + if (ch === 45 /* CharacterCodes.minus */) { tokenValue += "-"; pos++; continue; } - else if (ch === 58 /* colon */ && !namespaceSeparator) { + else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) { tokenValue += ":"; pos++; namespaceSeparator = true; - token = 79 /* Identifier */; // swap from keyword kind to identifier kind + token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -12208,10 +12324,10 @@ var ts; function scanJsxAttributeValue() { startPos = pos; switch (text.charCodeAt(pos)) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 10 /* StringLiteral */; + return token = 10 /* SyntaxKind.StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -12223,86 +12339,86 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); pos += charSize(ch); switch (ch) { - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; - case 64 /* at */: - return token = 59 /* AtToken */; - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + return token = 5 /* SyntaxKind.WhitespaceTrivia */; + case 64 /* CharacterCodes.at */: + return token = 59 /* SyntaxKind.AtToken */; + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - tokenFlags |= 1 /* PrecedingLineBreak */; - return token = 4 /* NewLineTrivia */; - case 42 /* asterisk */: - return token = 41 /* AsteriskToken */; - case 123 /* openBrace */: - return token = 18 /* OpenBraceToken */; - case 125 /* closeBrace */: - return token = 19 /* CloseBraceToken */; - case 91 /* openBracket */: - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: - return token = 23 /* CloseBracketToken */; - case 60 /* lessThan */: - return token = 29 /* LessThanToken */; - case 62 /* greaterThan */: - return token = 31 /* GreaterThanToken */; - case 61 /* equals */: - return token = 63 /* EqualsToken */; - case 44 /* comma */: - return token = 27 /* CommaToken */; - case 46 /* dot */: - return token = 24 /* DotToken */; - case 96 /* backtick */: - return token = 61 /* BacktickToken */; - case 35 /* hash */: - return token = 62 /* HashToken */; - case 92 /* backslash */: + case 10 /* CharacterCodes.lineFeed */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; + return token = 4 /* SyntaxKind.NewLineTrivia */; + case 42 /* CharacterCodes.asterisk */: + return token = 41 /* SyntaxKind.AsteriskToken */; + case 123 /* CharacterCodes.openBrace */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 125 /* CharacterCodes.closeBrace */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 91 /* CharacterCodes.openBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 60 /* CharacterCodes.lessThan */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 62 /* CharacterCodes.greaterThan */: + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 61 /* CharacterCodes.equals */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 44 /* CharacterCodes.comma */: + return token = 27 /* SyntaxKind.CommaToken */; + case 46 /* CharacterCodes.dot */: + return token = 24 /* SyntaxKind.DotToken */; + case 96 /* CharacterCodes.backtick */: + return token = 61 /* SyntaxKind.BacktickToken */; + case 35 /* CharacterCodes.hash */: + return token = 62 /* SyntaxKind.HashToken */; + case 92 /* CharacterCodes.backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); - if (char === 92 /* backslash */) { + if (char === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return token = getIdentifierToken(); } else { - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } function speculationHelper(callback, isLookahead) { @@ -12377,9 +12493,9 @@ var ts; pos = textPos; startPos = textPos; tokenPos = textPos; - token = 0 /* Unknown */; + token = 0 /* SyntaxKind.Unknown */; tokenValue = undefined; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -12445,23 +12561,23 @@ var ts; ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; function getDefaultLibFileName(options) { switch (ts.getEmitScriptTarget(options)) { - case 99 /* ESNext */: + case 99 /* ScriptTarget.ESNext */: return "lib.esnext.full.d.ts"; - case 9 /* ES2022 */: + case 9 /* ScriptTarget.ES2022 */: return "lib.es2022.full.d.ts"; - case 8 /* ES2021 */: + case 8 /* ScriptTarget.ES2021 */: return "lib.es2021.full.d.ts"; - case 7 /* ES2020 */: + case 7 /* ScriptTarget.ES2020 */: return "lib.es2020.full.d.ts"; - case 6 /* ES2019 */: + case 6 /* ScriptTarget.ES2019 */: return "lib.es2019.full.d.ts"; - case 5 /* ES2018 */: + case 5 /* ScriptTarget.ES2018 */: return "lib.es2018.full.d.ts"; - case 4 /* ES2017 */: + case 4 /* ScriptTarget.ES2017 */: return "lib.es2017.full.d.ts"; - case 3 /* ES2016 */: + case 3 /* ScriptTarget.ES2016 */: return "lib.es2016.full.d.ts"; - case 2 /* ES2015 */: + case 2 /* ScriptTarget.ES2015 */: return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; @@ -12669,9 +12785,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 163 /* TypeParameter */) { + if (d && d.kind === 163 /* SyntaxKind.TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return current; } } @@ -12679,7 +12795,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 171 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) && parent.kind === 171 /* SyntaxKind.Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12709,14 +12825,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 254 /* VariableDeclaration */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 255 /* VariableDeclarationList */) { + if (node && node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 237 /* VariableStatement */) { + if (node && node.kind === 237 /* SyntaxKind.VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12830,7 +12946,7 @@ var ts; * @param node The node to test. */ function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + return (node.flags & 8 /* NodeFlags.Synthesized */) === 0; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { @@ -12848,7 +12964,7 @@ var ts; ts.getParseTreeNode = getParseTreeNode; /** Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' */ function escapeLeadingUnderscores(identifier) { - return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); + return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* CharacterCodes._ */ && identifier.charCodeAt(1) === 95 /* CharacterCodes._ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; /** @@ -12859,7 +12975,7 @@ var ts; */ function unescapeLeadingUnderscores(identifier) { var id = identifier; - return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id; + return id.length >= 3 && id.charCodeAt(0) === 95 /* CharacterCodes._ */ && id.charCodeAt(1) === 95 /* CharacterCodes._ */ && id.charCodeAt(2) === 95 /* CharacterCodes._ */ ? id.substr(1) : id; } ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores; function idText(identifierOrPrivateName) { @@ -12889,30 +13005,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 221 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { + if (expr.kind === 221 /* SyntaxKind.BinaryExpression */ && expr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return expr.name; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12947,42 +13063,42 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return declaration; - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: { + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 161 /* QualifiedName */) { + if (name.kind === 161 /* SyntaxKind.QualifiedName */) { return name.right; } break; } - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { - case 1 /* ExportsProperty */: - case 4 /* ThisProperty */: - case 5 /* Property */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return expr_1.arguments[1]; default: return undefined; } } - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 339 /* JSDocEnumTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -13026,7 +13142,7 @@ var ts; } ts.getDecorators = getDecorators; function getModifiers(node) { - if (ts.hasSyntacticModifier(node, 125951 /* Modifier */)) { + if (ts.hasSyntacticModifier(node, 125951 /* ModifierFlags.Modifier */)) { return ts.filter(node.modifiers, isModifier); } } @@ -13287,27 +13403,33 @@ var ts; /** Gets the text of a jsdoc comment, flattening links to their text. */ function getTextOfJSDocComment(comment) { return typeof comment === "string" ? comment - : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* SyntaxKind.JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; function formatJSDocLink(link) { - var kind = link.kind === 324 /* JSDocLink */ ? "link" - : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" + var kind = link.kind === 324 /* SyntaxKind.JSDocLink */ ? "link" + : link.kind === 325 /* SyntaxKind.JSDocLinkCode */ ? "linkcode" : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. + * + * This does *not* return type parameters from a jsdoc reference to a generic type, eg + * + * type Id = (x: T) => T + * /** @type {Id} / + * function id(x) { return x } */ function getEffectiveTypeParameterDeclarations(node) { if (ts.isJSDocSignature(node)) { return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 320 /* JSDoc */); + ts.Debug.assert(node.parent.kind === 320 /* SyntaxKind.JSDoc */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13337,33 +13459,33 @@ var ts; ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region function isMemberName(node) { - return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; + return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */ || node.kind === 172 /* GetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */ || node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { - return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessChain(node) { - return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isElementAccessChain = isElementAccessChain; function isCallChain(node) { - return ts.isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isCallExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isCallChain = isCallChain; function isOptionalChain(node) { var kind = node.kind; - return !!(node.flags & 32 /* OptionalChain */) && - (kind === 206 /* PropertyAccessExpression */ - || kind === 207 /* ElementAccessExpression */ - || kind === 208 /* CallExpression */ - || kind === 230 /* NonNullExpression */); + return !!(node.flags & 32 /* NodeFlags.OptionalChain */) && + (kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 207 /* SyntaxKind.ElementAccessExpression */ + || kind === 208 /* SyntaxKind.CallExpression */ + || kind === 230 /* SyntaxKind.NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -13398,7 +13520,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -13407,25 +13529,25 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function skipPartiallyEmittedExpressions(node) { - return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */); + return ts.skipOuterExpressions(node, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isNonNullChain(node) { - return ts.isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isNonNullExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 246 /* BreakStatement */ || node.kind === 245 /* ContinueStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */ || node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 274 /* NamespaceExport */ || node.kind === 273 /* NamedExports */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return true; default: return false; @@ -13434,12 +13556,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 300 /* UnparsedPrologue */ || - node.kind === 304 /* UnparsedSyntheticReference */; + node.kind === 300 /* SyntaxKind.UnparsedPrologue */ || + node.kind === 304 /* SyntaxKind.UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 347 /* JSDocPropertyTag */ || node.kind === 340 /* JSDocParameterTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */ || node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -13455,7 +13577,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 161 /* FirstNode */; + return kind >= 161 /* SyntaxKind.FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13464,7 +13586,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 160 /* LastToken */; + return kind >= 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -13485,7 +13607,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; + return 8 /* SyntaxKind.FirstLiteralToken */ <= kind && kind <= 14 /* SyntaxKind.LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13495,11 +13617,11 @@ var ts; /** @internal */ function isLiteralExpressionOfObject(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 13 /* RegularExpressionLiteral */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; } return false; @@ -13508,7 +13630,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; + return 14 /* SyntaxKind.FirstTemplateToken */ <= kind && kind <= 17 /* SyntaxKind.LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13517,8 +13639,8 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 16 /* TemplateMiddle */ - || kind === 17 /* TemplateTail */; + return kind === 16 /* SyntaxKind.TemplateMiddle */ + || kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isImportOrExportSpecifier(node) { @@ -13527,13 +13649,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.isTypeOnly || node.parent.parent.isTypeOnly; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.isTypeOnly; - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -13545,13 +13667,13 @@ var ts; } ts.isAssertionKey = isAssertionKey; function isStringTextContainingNode(node) { - return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* SyntaxKind.StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; + return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) > 0 /* GeneratedIdentifierFlags.None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers @@ -13569,20 +13691,20 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 88 /* DefaultKeyword */: - case 93 /* ExportKeyword */: - case 101 /* InKeyword */: - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 124 /* StaticKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; } return false; @@ -13590,12 +13712,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ModifierFlags.ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 159 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* SyntaxKind.StaticKeyword */ || idToken === 159 /* SyntaxKind.OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13604,24 +13726,24 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 80 /* PrivateIdentifier */ - || kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 162 /* ComputedPropertyName */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 80 /* SyntaxKind.PrivateIdentifier */ + || kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */ + || kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 201 /* ObjectBindingPattern */ - || kind === 202 /* ArrayBindingPattern */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */ + || kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13641,18 +13763,18 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; /* @internal */ function isBooleanLiteral(node) { - return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */; + return node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */; } ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -13661,14 +13783,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 180 /* ConstructorType */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13683,30 +13805,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 234 /* SemicolonClassElement */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */); + return node && (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */); + return node && (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -13720,13 +13842,13 @@ var ts; ts.isModifierLike = isModifierLike; function isTypeElement(node) { var kind = node.kind; - return kind === 175 /* ConstructSignature */ - || kind === 174 /* CallSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */ - || kind === 176 /* IndexSignature */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 174 /* SyntaxKind.CallSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13735,12 +13857,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 298 /* SpreadAssignment */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 298 /* SyntaxKind.SpreadAssignment */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13755,8 +13877,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; } return false; @@ -13767,8 +13889,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 202 /* ArrayBindingPattern */ - || kind === 201 /* ObjectBindingPattern */; + return kind === 202 /* SyntaxKind.ArrayBindingPattern */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */; } return false; } @@ -13776,15 +13898,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 204 /* ArrayLiteralExpression */ - || kind === 205 /* ObjectLiteralExpression */; + return kind === 204 /* SyntaxKind.ArrayLiteralExpression */ + || kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 203 /* BindingElement */ - || kind === 227 /* OmittedExpression */; + return kind === 203 /* SyntaxKind.BindingElement */ + || kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13793,9 +13915,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: return true; } return false; @@ -13816,8 +13938,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return true; } return false; @@ -13826,10 +13948,10 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentElement(node) { switch (node.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: // AssignmentProperty - case 297 /* ShorthandPropertyAssignment */: // AssignmentProperty - case 298 /* SpreadAssignment */: // AssignmentRestProperty + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: // AssignmentProperty + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // AssignmentProperty + case 298 /* SyntaxKind.SpreadAssignment */: // AssignmentRestProperty return true; } return false; @@ -13841,8 +13963,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; } return false; @@ -13851,26 +13973,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */ - || kind === 200 /* ImportType */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 200 /* SyntaxKind.ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: return true; default: return false; @@ -13878,13 +14000,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 208 /* CallExpression */ || node.kind === 209 /* NewExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */ || node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 223 /* TemplateExpression */ - || kind === 14 /* NoSubstitutionTemplateLiteral */; + return kind === 223 /* SyntaxKind.TemplateExpression */ + || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13894,36 +14016,36 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 209 /* NewExpression */: - case 208 /* CallExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 210 /* TaggedTemplateExpression */: - case 204 /* ArrayLiteralExpression */: - case 212 /* ParenthesizedExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression - case 13 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 110 /* TrueKeyword */: - case 106 /* SuperKeyword */: - case 230 /* NonNullExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 231 /* MetaProperty */: - case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 230 /* SyntaxKind.NonNullExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 231 /* SyntaxKind.MetaProperty */: + case 100 /* SyntaxKind.ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13936,13 +14058,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 218 /* AwaitExpression */: - case 211 /* TypeAssertionExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13951,11 +14073,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 45 /* PlusPlusToken */ || - expr.operator === 46 /* MinusMinusToken */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || + expr.operator === 46 /* SyntaxKind.MinusMinusToken */; default: return false; } @@ -13972,15 +14094,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - case 214 /* ArrowFunction */: - case 221 /* BinaryExpression */: - case 225 /* SpreadElement */: - case 229 /* AsExpression */: - case 227 /* OmittedExpression */: - case 351 /* CommaListExpression */: - case 350 /* PartiallyEmittedExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 221 /* SyntaxKind.BinaryExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 229 /* SyntaxKind.AsExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13988,8 +14110,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 211 /* TypeAssertionExpression */ - || kind === 229 /* AsExpression */; + return kind === 211 /* SyntaxKind.TypeAssertionExpression */ + || kind === 229 /* SyntaxKind.AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -14000,13 +14122,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14024,18 +14146,18 @@ var ts; ts.hasScopeMarker = hasScopeMarker; /* @internal */ function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */) && !ts.isAmbientModule(result); } ts.needsScopeMarker = needsScopeMarker; /* @internal */ function isExternalModuleIndicator(result) { // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* Export */); + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */); } ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 243 /* ForInStatement */ || node.kind === 244 /* ForOfStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */ || node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14059,115 +14181,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */ - || kind === 79 /* Identifier */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 261 /* ModuleDeclaration */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 269 /* NamedImports */ - || kind === 268 /* NamespaceImport */; + return kind === 269 /* SyntaxKind.NamedImports */ + || kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ || node.kind === 260 /* EnumDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 214 /* ArrowFunction */ - || kind === 203 /* BindingElement */ - || kind === 257 /* ClassDeclaration */ - || kind === 226 /* ClassExpression */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 171 /* Constructor */ - || kind === 260 /* EnumDeclaration */ - || kind === 299 /* EnumMember */ - || kind === 275 /* ExportSpecifier */ - || kind === 256 /* FunctionDeclaration */ - || kind === 213 /* FunctionExpression */ - || kind === 172 /* GetAccessor */ - || kind === 267 /* ImportClause */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 270 /* ImportSpecifier */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 285 /* JsxAttribute */ - || kind === 169 /* MethodDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 261 /* ModuleDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 268 /* NamespaceImport */ - || kind === 274 /* NamespaceExport */ - || kind === 164 /* Parameter */ - || kind === 296 /* PropertyAssignment */ - || kind === 167 /* PropertyDeclaration */ - || kind === 166 /* PropertySignature */ - || kind === 173 /* SetAccessor */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 163 /* TypeParameter */ - || kind === 254 /* VariableDeclaration */ - || kind === 345 /* JSDocTypedefTag */ - || kind === 338 /* JSDocCallbackTag */ - || kind === 347 /* JSDocPropertyTag */; + return kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 203 /* SyntaxKind.BindingElement */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 299 /* SyntaxKind.EnumMember */ + || kind === 275 /* SyntaxKind.ExportSpecifier */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 267 /* SyntaxKind.ImportClause */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 270 /* SyntaxKind.ImportSpecifier */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 268 /* SyntaxKind.NamespaceImport */ + || kind === 274 /* SyntaxKind.NamespaceExport */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 254 /* SyntaxKind.VariableDeclaration */ + || kind === 345 /* SyntaxKind.JSDocTypedefTag */ + || kind === 338 /* SyntaxKind.JSDocCallbackTag */ + || kind === 347 /* SyntaxKind.JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 246 /* BreakStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 240 /* DoStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 236 /* EmptyStatement */ - || kind === 243 /* ForInStatement */ - || kind === 244 /* ForOfStatement */ - || kind === 242 /* ForStatement */ - || kind === 239 /* IfStatement */ - || kind === 250 /* LabeledStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 249 /* SwitchStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 252 /* TryStatement */ - || kind === 237 /* VariableStatement */ - || kind === 241 /* WhileStatement */ - || kind === 248 /* WithStatement */ - || kind === 349 /* NotEmittedStatement */ - || kind === 353 /* EndOfDeclarationMarker */ - || kind === 352 /* MergeDeclarationMarker */; + return kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 236 /* SyntaxKind.EmptyStatement */ + || kind === 243 /* SyntaxKind.ForInStatement */ + || kind === 244 /* SyntaxKind.ForOfStatement */ + || kind === 242 /* SyntaxKind.ForStatement */ + || kind === 239 /* SyntaxKind.IfStatement */ + || kind === 250 /* SyntaxKind.LabeledStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 249 /* SyntaxKind.SwitchStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 252 /* SyntaxKind.TryStatement */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 241 /* SyntaxKind.WhileStatement */ + || kind === 248 /* SyntaxKind.WithStatement */ + || kind === 349 /* SyntaxKind.NotEmittedStatement */ + || kind === 353 /* SyntaxKind.EndOfDeclarationMarker */ + || kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 163 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 344 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { + return (node.parent && node.parent.kind !== 344 /* SyntaxKind.JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14194,10 +14316,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 235 /* Block */) + if (node.kind !== 235 /* SyntaxKind.Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 252 /* TryStatement */ || node.parent.kind === 292 /* CatchClause */) { + if (node.parent.kind === 252 /* SyntaxKind.TryStatement */ || node.parent.kind === 292 /* SyntaxKind.CatchClause */) { return false; } } @@ -14211,76 +14333,76 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 235 /* Block */; + || kind === 235 /* SyntaxKind.Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 277 /* ExternalModuleReference */ - || kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 277 /* SyntaxKind.ExternalModuleReference */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 108 /* ThisKeyword */ - || kind === 79 /* Identifier */ - || kind === 206 /* PropertyAccessExpression */; + return kind === 108 /* SyntaxKind.ThisKeyword */ + || kind === 79 /* SyntaxKind.Identifier */ + || kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 278 /* JsxElement */ - || kind === 288 /* JsxExpression */ - || kind === 279 /* JsxSelfClosingElement */ - || kind === 11 /* JsxText */ - || kind === 282 /* JsxFragment */; + return kind === 278 /* SyntaxKind.JsxElement */ + || kind === 288 /* SyntaxKind.JsxExpression */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */ + || kind === 11 /* SyntaxKind.JsxText */ + || kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 285 /* JsxAttribute */ - || kind === 287 /* JsxSpreadAttribute */; + return kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 288 /* JsxExpression */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 288 /* SyntaxKind.JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 280 /* JsxOpeningElement */ - || kind === 279 /* JsxSelfClosingElement */; + return kind === 280 /* SyntaxKind.JsxOpeningElement */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 289 /* CaseClause */ - || kind === 290 /* DefaultClause */; + return kind === 289 /* SyntaxKind.CaseClause */ + || kind === 290 /* SyntaxKind.DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 309 /* FirstJSDocNode */ && node.kind <= 347 /* LastJSDocNode */; + return node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 320 /* JSDoc */ - || node.kind === 319 /* JSDocNamepathType */ - || node.kind === 321 /* JSDocText */ + return node.kind === 320 /* SyntaxKind.JSDoc */ + || node.kind === 319 /* SyntaxKind.JSDocNamepathType */ + || node.kind === 321 /* SyntaxKind.JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) @@ -14290,15 +14412,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 327 /* FirstJSDocTagNode */ && node.kind <= 347 /* LastJSDocTagNode */; + return node.kind >= 327 /* SyntaxKind.FirstJSDocTagNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14324,12 +14446,12 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: return true; default: return false; @@ -14337,12 +14459,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 285 /* JsxAttribute */ || node.kind === 287 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 285 /* SyntaxKind.JsxAttribute */ || node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 178 /* TypeReference */ || node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14371,11 +14493,11 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */ || node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; function isJSDocLinkLike(node) { - return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 324 /* SyntaxKind.JSDocLink */ || node.kind === 325 /* SyntaxKind.JSDocLinkCode */ || node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkLike = isJSDocLinkLike; function hasRestParameter(s) { @@ -14385,7 +14507,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isRestParameter = isRestParameter; // #endregion @@ -14426,7 +14548,7 @@ var ts; } ts.createSymbolTable = createSymbolTable; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } ts.isTransientSymbol = isTransientSymbol; var stringWriter = createSingleLineStringWriter(); @@ -14587,11 +14709,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -14622,28 +14744,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 1048576 /* HasAggregatedChildData */)) { + if (!(node.flags & 1048576 /* NodeFlags.HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* NodeFlags.ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 1048576 /* HasAggregatedChildData */; + node.flags |= 1048576 /* NodeFlags.HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 305 /* SourceFile */) { + while (node && node.kind !== 305 /* SyntaxKind.SourceFile */) { node = node.parent; } return node; @@ -14654,16 +14776,16 @@ var ts; } ts.getSourceFileOfModule = getSourceFileOfModule; function isPlainJsFile(file, checkJs) { - return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined; + return !!file && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */) && !file.checkJsDirective && checkJs === undefined; } ts.isPlainJsFile = isPlainJsFile; function isStatementWithLocals(node) { switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return true; } return false; @@ -14678,7 +14800,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -14731,7 +14853,7 @@ var ts; if (node === undefined) { return true; } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -14765,7 +14887,7 @@ var ts; return to; } function isAnyPrologueDirective(node) { - return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } /** * Prepends statements to an array while taking care of prologue directives. @@ -14797,9 +14919,9 @@ var ts; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments - if (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + if (text.charCodeAt(commentPos + 1) === 47 /* CharacterCodes.slash */ && commentPos + 2 < commentEnd && - text.charCodeAt(commentPos + 2) === 47 /* slash */) { + text.charCodeAt(commentPos + 2) === 47 /* CharacterCodes.slash */) { var textSubStr = text.substring(commentPos, commentEnd); return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || @@ -14811,13 +14933,13 @@ var ts; } ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; function isPinnedComment(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 33 /* exclamation */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 33 /* CharacterCodes.exclamation */; } ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -14826,7 +14948,7 @@ var ts; return ts.arrayFrom(directivesByLine.entries()) .filter(function (_a) { var line = _a[0], directive = _a[1]; - return directive.type === 0 /* ExpectError */ && !usedLines.get(line); + return directive.type === 0 /* CommentDirectiveType.ExpectError */ && !usedLines.get(line); }) .map(function (_a) { var _ = _a[0], directive = _a[1]; @@ -14834,10 +14956,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -14848,7 +14970,7 @@ var ts; if (nodeIsMissing(node)) { return node.pos; } - if (ts.isJSDocNode(node) || node.kind === 11 /* JsxText */) { + if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) { // JsxText cannot actually contain comments, even though the scanner will think it sees comments return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } @@ -14859,7 +14981,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 348 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -15027,56 +15149,56 @@ var ts; // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { - case 10 /* StringLiteral */: { - var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : - flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + case 10 /* SyntaxKind.StringLiteral */: { + var escapeText = flags & 2 /* GetLiteralTextFlags.JsxAttributeEscape */ ? escapeJsxAttributeString : + flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; if (node.singleQuote) { - return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + return "'" + escapeText(node.text, 39 /* CharacterCodes.singleQuote */) + "'"; } else { - return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + return '"' + escapeText(node.text, 34 /* CharacterCodes.doubleQuote */) + '"'; } } - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: { // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. - var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; - var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* CharacterCodes.backtick */)); switch (node.kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return "`" + rawText + "${"; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: return "}" + rawText + "${"; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: return "}" + rawText + "`"; } break; } - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return node.text; - case 13 /* RegularExpressionLiteral */: - if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) { - return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/"); + case 13 /* SyntaxKind.RegularExpressionLiteral */: + if (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) { + return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* CharacterCodes.backslash */ ? " /" : "/"); } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { - if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated)) { + if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) { return false; } - if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) { - return !!(flags & 8 /* AllowNumericSeparator */); + if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) { + return !!(flags & 8 /* GetLiteralTextFlags.AllowNumericSeparator */); } return !ts.isBigIntLiteral(node); } @@ -15091,21 +15213,21 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || + return (ts.getCombinedNodeFlags(declaration) & 3 /* NodeFlags.BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* SyntaxKind.StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -15129,16 +15251,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return !!node && node.kind === 261 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 305 /* SourceFile */ || - node.kind === 261 /* ModuleDeclaration */ || + return node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 1024 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* NodeFlags.GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -15150,9 +15272,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return ts.isExternalModule(node.parent); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -15176,10 +15298,10 @@ var ts; function isEffectiveStrictModeSourceFile(node, compilerOptions) { // We can only verify strict mode for JS/TS files switch (node.scriptKind) { - case 1 /* JS */: - case 3 /* TS */: - case 2 /* JSX */: - case 4 /* TSX */: + case 1 /* ScriptKind.JS */: + case 3 /* ScriptKind.TS */: + case 2 /* ScriptKind.JSX */: + case 4 /* ScriptKind.TSX */: break; default: return false; @@ -15209,24 +15331,24 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 292 /* CatchClause */: - case 261 /* ModuleDeclaration */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 167 /* PropertyDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 292 /* SyntaxKind.CatchClause */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); @@ -15236,9 +15358,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 323 /* JSDocSignature */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 323 /* SyntaxKind.JSDocSignature */: return true; default: ts.assertType(node); @@ -15248,25 +15370,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: ts.assertType(node); @@ -15276,8 +15398,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -15290,15 +15412,15 @@ var ts; ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 237 /* VariableStatement */: - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return true; default: return false; @@ -15339,19 +15461,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 162 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function tryGetTextOfPropertyName(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return undefined; @@ -15366,21 +15488,21 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return "this"; - case 80 /* PrivateIdentifier */: - case 79 /* Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); @@ -15470,7 +15592,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 235 /* Block */) { + if (node.body && node.body.kind === 235 /* SyntaxKind.Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -15484,7 +15606,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -15493,29 +15615,29 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 268 /* NamespaceImport */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 268 /* SyntaxKind.NamespaceImport */: errorNode = node.name; break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -15547,36 +15669,36 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isJsonSourceFile(file) { - return file.scriptKind === 6 /* JSON */; + return file.scriptKind === 6 /* ScriptKind.JSON */; } ts.isJsonSourceFile = isJsonSourceFile; function isEnumConst(node) { - return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(ts.getCombinedModifierFlags(node) & 2048 /* ModifierFlags.Const */); } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* ModifierFlags.Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); + return !!(ts.getCombinedNodeFlags(node) & 2 /* NodeFlags.Const */); } ts.isVarConst = isVarConst; function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); + return !!(ts.getCombinedNodeFlags(node) & 1 /* NodeFlags.Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 100 /* ImportKeyword */ + && n.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -15585,12 +15707,12 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 238 /* ExpressionStatement */ - && node.expression.kind === 10 /* StringLiteral */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */ + && node.expression.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isCustomPrologue(node) { - return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } ts.isCustomPrologue = isCustomPrologue; function isHoistedFunction(node) { @@ -15609,24 +15731,24 @@ var ts; } ts.isHoistedVariableStatement = isHoistedVariableStatement; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* SyntaxKind.JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 164 /* Parameter */ || - node.kind === 163 /* TypeParameter */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 214 /* ArrowFunction */ || - node.kind === 212 /* ParenthesizedExpression */ || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 275 /* ExportSpecifier */) ? + var commentRanges = (node.kind === 164 /* SyntaxKind.Parameter */ || + node.kind === 163 /* SyntaxKind.TypeParameter */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 214 /* SyntaxKind.ArrowFunction */ || + node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + return text.charCodeAt(comment.pos + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; @@ -15635,48 +15757,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (177 /* FirstTypeNode */ <= node.kind && node.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= node.kind && node.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return true; - case 114 /* VoidKeyword */: - return node.parent.kind !== 217 /* VoidExpression */; - case 228 /* ExpressionWithTypeArguments */: + case 114 /* SyntaxKind.VoidKeyword */: + return node.parent.kind !== 217 /* SyntaxKind.VoidExpression */; + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 163 /* TypeParameter */: - return node.parent.kind === 195 /* MappedType */ || node.parent.kind === 190 /* InferType */; + case 163 /* SyntaxKind.TypeParameter */: + return node.parent.kind === 195 /* SyntaxKind.MappedType */ || node.parent.kind === 190 /* SyntaxKind.InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */ || node.kind === 206 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: - case 108 /* ThisKeyword */: { + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: { var parent = node.parent; - if (parent.kind === 181 /* TypeQuery */) { + if (parent.kind === 181 /* SyntaxKind.TypeQuery */) { return false; } - if (parent.kind === 200 /* ImportType */) { + if (parent.kind === 200 /* SyntaxKind.ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -15685,40 +15807,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (177 /* FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (parent.kind) { - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return node === parent.constraint; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return node === parent.constraint; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return node === parent.type; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return node === parent.type; - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return node === parent.type; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return node === parent.type; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.contains(parent.typeArguments, node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -15743,23 +15865,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitor(node); - case 263 /* CaseBlock */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 263 /* SyntaxKind.CaseBlock */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return ts.forEachChild(node, traverse); } } @@ -15769,23 +15891,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -15808,10 +15930,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 183 /* ArrayType */) { + if (node && node.kind === 183 /* SyntaxKind.ArrayType */) { return node.elementType; } - else if (node && node.kind === 178 /* TypeReference */) { + else if (node && node.kind === 178 /* SyntaxKind.TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15821,12 +15943,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 182 /* TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 182 /* SyntaxKind.TypeLiteral */: return node.members; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return node.properties; } } @@ -15834,14 +15956,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 203 /* BindingElement */: - case 299 /* EnumMember */: - case 164 /* Parameter */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 299 /* SyntaxKind.EnumMember */: + case 164 /* SyntaxKind.Parameter */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } } @@ -15853,21 +15975,21 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ - && node.parent.parent.kind === 237 /* VariableStatement */; + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ + && node.parent.parent.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isCommonJsExportedExpression(node) { if (!isInJSFile(node)) return false; - return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) || + return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) || isCommonJsExportPropertyAssignment(node.parent); } ts.isCommonJsExportedExpression = isCommonJsExportedExpression; function isCommonJsExportPropertyAssignment(node) { if (!isInJSFile(node)) return false; - return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */); + return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* AssignmentDeclarationKind.ExportsProperty */); } ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment; function isValidESSymbolDeclaration(node) { @@ -15878,13 +16000,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return true; } return false; @@ -15895,7 +16017,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 250 /* LabeledStatement */) { + if (node.statement.kind !== 250 /* SyntaxKind.LabeledStatement */) { return node.statement; } node = node.statement; @@ -15903,30 +16025,30 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 235 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 169 /* MethodDeclaration */ && node.parent.kind === 205 /* ObjectLiteralExpression */; + return node && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethodOrAccessor(node) { - return (node.kind === 169 /* MethodDeclaration */ || node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) && - (node.parent.kind === 205 /* ObjectLiteralExpression */ || - node.parent.kind === 226 /* ClassExpression */); + return (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) && + (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || + node.parent.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor; function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1 /* Identifier */; + return predicate && predicate.kind === 1 /* TypePredicateKind.Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0 /* This */; + return predicate && predicate.kind === 0 /* TypePredicateKind.This */; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 296 /* PropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */) { var propName = tryGetTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15988,14 +16110,14 @@ var ts; } ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 305 /* SourceFile */); + ts.Debug.assert(node.kind !== 305 /* SyntaxKind.SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -16010,9 +16132,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -16023,27 +16145,27 @@ var ts; node = node.parent; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 261 /* ModuleDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 260 /* EnumDeclaration */: - case 305 /* SourceFile */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 305 /* SyntaxKind.SourceFile */: return node; } } @@ -16056,17 +16178,17 @@ var ts; switch (node.kind) { // Arrow functions use the same scope, but may do so in a "delayed" manner // For example, `const getThis = () => this` may be before a super() call in a derived constructor - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 167 /* PropertyDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Object properties can have computed names; only method-like bodies start a new scope return true; default: @@ -16090,9 +16212,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return container; } } @@ -16114,28 +16236,28 @@ var ts; return node; } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: node = node.parent; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return node; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -16151,21 +16273,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 213 /* FunctionExpression */ || func.kind === 214 /* ArrowFunction */) { + if (func.kind === 213 /* SyntaxKind.FunctionExpression */ || func.kind === 214 /* SyntaxKind.ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 212 /* ParenthesizedExpression */) { + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 208 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 106 /* SuperKeyword */ + return node.kind === 106 /* SyntaxKind.SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -16174,8 +16296,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 106 /* SuperKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -16183,34 +16305,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 108 /* ThisKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function isThisInitializedObjectBindingExpression(node) { return !!node && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) && ts.isBinaryExpression(node.parent.parent) - && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */ - && node.parent.parent.right.kind === 108 /* ThisKeyword */; + && node.parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && node.parent.parent.right.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: return node; } return undefined; @@ -16218,10 +16340,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return node.tag; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -16234,25 +16356,25 @@ var ts; return false; } switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // classes are valid targets return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 257 /* ClassDeclaration */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + return parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 257 /* ClassDeclaration */; - case 164 /* Parameter */: + && parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 164 /* SyntaxKind.Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 171 /* Constructor */ - || parent.kind === 169 /* MethodDeclaration */ - || parent.kind === 173 /* SetAccessor */) - && grandparent.kind === 257 /* ClassDeclaration */; + && (parent.kind === 171 /* SyntaxKind.Constructor */ + || parent.kind === 169 /* SyntaxKind.MethodDeclaration */ + || parent.kind === 173 /* SyntaxKind.SetAccessor */) + && grandparent.kind === 257 /* SyntaxKind.ClassDeclaration */; } return false; } @@ -16268,11 +16390,11 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -16288,9 +16410,9 @@ var ts; ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 280 /* JsxOpeningElement */ || - parent.kind === 279 /* JsxSelfClosingElement */ || - parent.kind === 281 /* JsxClosingElement */) { + if (parent.kind === 280 /* SyntaxKind.JsxOpeningElement */ || + parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || + parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return parent.tagName === node; } return false; @@ -16298,66 +16420,66 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 13 /* RegularExpressionLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 229 /* AsExpression */: - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 221 /* BinaryExpression */: - case 222 /* ConditionalExpression */: - case 225 /* SpreadElement */: - case 223 /* TemplateExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 224 /* YieldExpression */: - case 218 /* AwaitExpression */: - case 231 /* MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 223 /* SyntaxKind.TemplateExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 224 /* SyntaxKind.YieldExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 231 /* SyntaxKind.MetaProperty */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return !ts.isHeritageClause(node.parent); - case 161 /* QualifiedName */: - while (node.parent.kind === 161 /* QualifiedName */) { + case 161 /* SyntaxKind.QualifiedName */: + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 311 /* JSDocMemberName */: + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 311 /* SyntaxKind.JSDocMemberName */: while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 80 /* PrivateIdentifier */: - return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */; - case 79 /* Identifier */: - if (node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 80 /* SyntaxKind.PrivateIdentifier */: + return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; + case 79 /* SyntaxKind.Identifier */: + if (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -16367,49 +16489,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: return parent.initializer === node; - case 238 /* ExpressionStatement */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 247 /* ReturnStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 251 /* ThrowStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 251 /* SyntaxKind.ThrowStatement */: return parent.expression === node; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forInStatement.expression === node; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return node === parent.expression; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node === parent.expression; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return node === parent.expression; - case 165 /* Decorator */: - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: - case 298 /* SpreadAssignment */: + case 165 /* SyntaxKind.Decorator */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 298 /* SyntaxKind.SpreadAssignment */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return parent.expression === node && !isPartOfTypeNode(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -16417,10 +16539,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 161 /* QualifiedName */ || node.kind === 79 /* Identifier */) { + while (node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 79 /* SyntaxKind.Identifier */) { node = node.parent; } - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -16428,7 +16550,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -16441,7 +16563,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -16453,11 +16575,11 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 262144 /* JavaScriptFile */); + return !!node && !!(node.flags & 262144 /* NodeFlags.JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 67108864 /* JsonFile */); + return !!node && !!(node.flags & 67108864 /* NodeFlags.JsonFile */); } ts.isInJsonFile = isInJsonFile; function isSourceFileNotJson(file) { @@ -16465,7 +16587,7 @@ var ts; } ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { - return !!node && !!(node.flags & 8388608 /* JSDoc */); + return !!node && !!(node.flags & 8388608 /* NodeFlags.JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -16473,15 +16595,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 150 /* StringKeyword */ || node.typeArguments[0].kind === 147 /* NumberKeyword */); + (node.typeArguments[0].kind === 150 /* SyntaxKind.StringKeyword */ || node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 208 /* CallExpression */) { + if (callExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* SyntaxKind.Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -16518,11 +16640,11 @@ var ts; } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { - return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */; + return charCode === 39 /* CharacterCodes.singleQuote */ || charCode === 34 /* CharacterCodes.doubleQuote */; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isStringDoubleQuoted(str, sourceFile) { - return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; + return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; function isAssignmentDeclaration(decl) { @@ -16533,7 +16655,7 @@ var ts; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && ts.isBinaryExpression(node.initializer) && - (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && + (node.initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -16560,7 +16682,7 @@ var ts; * 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 === 63 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -16586,11 +16708,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 213 /* FunctionExpression */ || e.kind === 214 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 213 /* FunctionExpression */ || - initializer.kind === 226 /* ClassExpression */ || - initializer.kind === 214 /* ArrowFunction */) { + if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ || + initializer.kind === 226 /* SyntaxKind.ClassExpression */ || + initializer.kind === 214 /* SyntaxKind.ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -16608,7 +16730,7 @@ var ts; */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { var e = ts.isBinaryExpression(initializer) - && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && (initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; @@ -16616,7 +16738,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -16624,8 +16746,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -16648,7 +16770,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 108 /* ThisKeyword */ || + (initializer.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -16687,7 +16809,7 @@ var ts; /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); - return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; + return special === 5 /* AssignmentDeclarationKind.Property */ || isInJSFile(expr) ? special : 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; function isBindableObjectDefinePropertyCall(expr) { @@ -16712,14 +16834,14 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; /** Any series of property and element accesses, ending in a literal element access */ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -16738,23 +16860,23 @@ var ts; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } var entityName = expr.arguments[0]; if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { - return 8 /* ObjectDefinePropertyExports */; + return 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */; } if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { - return 9 /* ObjectDefinePrototypeProperty */; + return 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */; } - return 7 /* ObjectDefinePropertyValue */; + return 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { - return 0 /* None */; + if (expr.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + return 0 /* AssignmentDeclarationKind.None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } - return 6 /* Prototype */; + return 6 /* AssignmentDeclarationKind.Prototype */; } return getAssignmentDeclarationPropertyAccessKind(expr.left); } @@ -16791,17 +16913,17 @@ var ts; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 108 /* ThisKeyword */) { - return 4 /* ThisProperty */; + if (lhs.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { + return 4 /* AssignmentDeclarationKind.ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr - return 2 /* ModuleExports */; + return 2 /* AssignmentDeclarationKind.ModuleExports */; } else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr - return 3 /* PrototypeProperty */; + return 3 /* AssignmentDeclarationKind.PrototypeProperty */; } var nextToLast = lhs; while (!ts.isIdentifier(nextToLast.expression)) { @@ -16813,14 +16935,14 @@ var ts; // ExportsProperty does not support binding with computed names isBindableStaticAccessExpression(lhs)) { // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... - return 1 /* ExportsProperty */; + return 1 /* AssignmentDeclarationKind.ExportsProperty */; } if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) { // F.G...x = expr - return 5 /* Property */; + return 5 /* AssignmentDeclarationKind.Property */; } } - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { @@ -16831,12 +16953,12 @@ var ts; } ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression; function isPrototypePropertyAssignment(node) { - return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */; + return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 238 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -16844,7 +16966,7 @@ var ts; function setValueDeclaration(symbol, node) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) && + !(node.flags & 16777216 /* NodeFlags.Ambient */ && !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { // other kinds of value declarations take precedence over modules and assignment declarations @@ -16857,17 +16979,17 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 256 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 256 /* SyntaxKind.FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { var _a, _b; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0]; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike); default: ts.Debug.assertNever(node); @@ -16880,14 +17002,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.parent; - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return node.parent.parent; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16897,17 +17019,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.moduleSpecifier; - case 265 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 277 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 200 /* ImportType */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 200 /* SyntaxKind.ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return node.arguments[0]; - case 261 /* ModuleDeclaration */: - return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; + case 261 /* SyntaxKind.ModuleDeclaration */: + return node.name.kind === 10 /* SyntaxKind.StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -16915,11 +17037,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16927,7 +17049,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 266 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16948,13 +17070,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 164 /* Parameter */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return node.questionToken !== undefined; } } @@ -16968,7 +17090,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 345 /* JSDocTypedefTag */ || node.kind === 338 /* JSDocCallbackTag */ || node.kind === 339 /* JSDocEnumTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || node.kind === 338 /* SyntaxKind.JSDocCallbackTag */ || node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16978,27 +17100,27 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 63 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && + getAssignmentDeclarationKind(node.expression) !== 0 /* AssignmentDeclarationKind.None */ && ts.isBinaryExpression(node.expression.right) && - (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) + (node.expression.right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return node.initializer; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return node.initializer; } } @@ -17010,7 +17132,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 261 /* ModuleDeclaration */ + node.body.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? node.body : undefined; } @@ -17025,11 +17147,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc))); } - if (node.kind === 164 /* Parameter */) { + if (node.kind === 164 /* SyntaxKind.Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 163 /* TypeParameter */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -17058,13 +17180,13 @@ var ts; } function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 296 /* PropertyAssignment */ || - parent.kind === 271 /* ExportAssignment */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 238 /* ExpressionStatement */ && node.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 247 /* ReturnStatement */ || + if (parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + parent.kind === 271 /* SyntaxKind.ExportAssignment */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 247 /* SyntaxKind.ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -17075,7 +17197,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -17099,7 +17221,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* SyntaxKind.Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -17172,41 +17294,41 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + binaryOperator === 63 /* SyntaxKind.EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* AssignmentKind.Definite */ : 2 /* AssignmentKind.Compound */ : + 0 /* AssignmentKind.None */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 212 /* ParenthesizedExpression */: - case 204 /* ArrayLiteralExpression */: - case 225 /* SpreadElement */: - case 230 /* NonNullExpression */: + return unaryOperator === 45 /* SyntaxKind.PlusPlusToken */ || unaryOperator === 46 /* SyntaxKind.MinusMinusToken */ ? 2 /* AssignmentKind.Compound */ : 0 /* AssignmentKind.None */; + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + return parent.initializer === node ? 1 /* AssignmentKind.Definite */ : 0 /* AssignmentKind.None */; + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 230 /* SyntaxKind.NonNullExpression */: node = parent; break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: node = parent.parent; break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (parent.name !== node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (parent.name === node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; default: - return 0 /* None */; + return 0 /* AssignmentKind.None */; } parent = node.parent; } @@ -17217,7 +17339,7 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0 /* None */; + return getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */; } ts.isAssignmentTarget = isAssignmentTarget; /** @@ -17226,22 +17348,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 235 /* Block */: - case 237 /* VariableStatement */: - case 248 /* WithStatement */: - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 235 /* SyntaxKind.Block */: + case 237 /* SyntaxKind.VariableStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return true; } return false; @@ -17258,11 +17380,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 191 /* ParenthesizedType */); + return walkUp(node, 191 /* SyntaxKind.ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 212 /* ParenthesizedExpression */); + return walkUp(node, 212 /* SyntaxKind.ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -17272,7 +17394,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 191 /* ParenthesizedType */) { + while (node && node.kind === 191 /* SyntaxKind.ParenthesizedType */) { child = node; node = node.parent; } @@ -17287,18 +17409,18 @@ var ts; ts.skipTypeParentheses = skipTypeParentheses; function skipParentheses(node, excludeJSDocTypeAssertions) { var flags = excludeJSDocTypeAssertions ? - 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : - 1 /* Parentheses */; + 1 /* OuterExpressionKinds.Parentheses */ | 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ : + 1 /* OuterExpressionKinds.Parentheses */; return ts.skipOuterExpressions(node, flags); } ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 206 /* PropertyAccessExpression */ && node.kind !== 207 /* ElementAccessExpression */) { + if (node.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 207 /* SyntaxKind.ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 215 /* DeleteExpression */; + return node && node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -17319,13 +17441,13 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -17336,13 +17458,13 @@ var ts; else { var binExp = parent.parent; return ts.isBinaryExpression(binExp) && - getAssignmentDeclarationKind(binExp) !== 0 /* None */ && + getAssignmentDeclarationKind(binExp) !== 0 /* AssignmentDeclarationKind.None */ && (binExp.left.symbol || binExp.symbol) && ts.getNameOfDeclaration(binExp) === name ? binExp : undefined; } - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -17351,7 +17473,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 162 /* ComputedPropertyName */ && + node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -17359,29 +17481,29 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 206 /* PropertyAccessExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 203 /* BindingElement */: - case 270 /* ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 275 /* ExportSpecifier */: - case 285 /* JsxAttribute */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 285 /* SyntaxKind.JsxAttribute */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: // Any name in an export specifier or JSX Attribute or Jsx Element return true; } @@ -17404,38 +17526,38 @@ var ts; // const x = require("...").y // const { x } = require("...").y function isAliasSymbolDeclaration(node) { - if (node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - node.kind === 267 /* ImportClause */ && !!node.name || - node.kind === 268 /* NamespaceImport */ || - node.kind === 274 /* NamespaceExport */ || - node.kind === 270 /* ImportSpecifier */ || - node.kind === 275 /* ExportSpecifier */ || - node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) { + if (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name || + node.kind === 268 /* SyntaxKind.NamespaceImport */ || + node.kind === 274 /* SyntaxKind.NamespaceExport */ || + node.kind === 270 /* SyntaxKind.ImportSpecifier */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ && exportAssignmentIsAlias(node)) { return true; } - return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && exportAssignmentIsAlias(node) || ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableExpression(node.parent.right)); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 268 /* NamespaceImport */: - case 275 /* ExportSpecifier */: - case 271 /* ExportAssignment */: - case 265 /* ImportEqualsDeclaration */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 271 /* SyntaxKind.ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 161 /* QualifiedName */); + } while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -17454,7 +17576,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* PropertyAssignment */ ? node.initializer : + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -17471,7 +17593,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -17480,7 +17602,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* SyntaxKind.ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -17493,7 +17615,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -17520,11 +17642,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 81 /* FirstKeyword */ <= token && token <= 160 /* LastKeyword */; + return 81 /* SyntaxKind.FirstKeyword */ <= token && token <= 160 /* SyntaxKind.LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 126 /* FirstContextualKeyword */ <= token && token <= 160 /* LastContextualKeyword */; + return 126 /* SyntaxKind.FirstContextualKeyword */ <= token && token <= 160 /* SyntaxKind.LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -17532,7 +17654,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; + return 117 /* SyntaxKind.FirstFutureReservedWord */ <= token && token <= 125 /* SyntaxKind.LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -17551,7 +17673,7 @@ var ts; } ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + return 2 /* SyntaxKind.FirstTriviaToken */ <= token && token <= 7 /* SyntaxKind.LastTriviaToken */; } ts.isTrivia = isTrivia; var FunctionFlags; @@ -17564,38 +17686,38 @@ var ts; })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { - return 4 /* Invalid */; + return 4 /* FunctionFlags.Invalid */; } - var flags = 0 /* Normal */; + var flags = 0 /* FunctionFlags.Normal */; switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - flags |= 1 /* Generator */; + flags |= 1 /* FunctionFlags.Generator */; } // falls through - case 214 /* ArrowFunction */: - if (hasSyntacticModifier(node, 256 /* Async */)) { - flags |= 2 /* Async */; + case 214 /* SyntaxKind.ArrowFunction */: + if (hasSyntacticModifier(node, 256 /* ModifierFlags.Async */)) { + flags |= 2 /* FunctionFlags.Async */; } break; } if (!node.body) { - flags |= 4 /* Invalid */; + flags |= 4 /* FunctionFlags.Invalid */; } return flags; } ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined - && hasSyntacticModifier(node, 256 /* Async */); + && hasSyntacticModifier(node, 256 /* ModifierFlags.Async */); } return false; } @@ -17605,7 +17727,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* SyntaxKind.PlusToken */ || node.operator === 40 /* SyntaxKind.MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -17622,7 +17744,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) { + if (!(name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || name.kind === 207 /* SyntaxKind.ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -17632,19 +17754,19 @@ var ts; ts.isDynamicName = isDynamicName; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { - if (nameExpression.operator === 40 /* MinusToken */) { + if (nameExpression.operator === 40 /* SyntaxKind.MinusToken */) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } return nameExpression.operand.text; @@ -17657,10 +17779,10 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return true; default: return false; @@ -17676,11 +17798,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -17695,7 +17817,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -17704,11 +17826,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 164 /* Parameter */; + return root.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 203 /* BindingElement */) { + while (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return node; @@ -17716,15 +17838,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 213 /* FunctionExpression */ - || kind === 256 /* FunctionDeclaration */ - || kind === 214 /* ArrowFunction */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 261 /* ModuleDeclaration */ - || kind === 305 /* SourceFile */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 305 /* SyntaxKind.SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -17743,58 +17865,58 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 209 /* NewExpression */: - return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - return 1 /* Right */; - case 221 /* BinaryExpression */: + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 0 /* Associativity.Left */ : 1 /* Associativity.Right */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + return 1 /* Associativity.Right */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operator) { - case 42 /* AsteriskAsteriskToken */: - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 1 /* Right */; - } - } - return 0 /* Left */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 1 /* Associativity.Right */; + } + } + return 0 /* Associativity.Left */; } ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 221 /* BinaryExpression */) { + if (expression.kind === 221 /* SyntaxKind.BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 219 /* PrefixUnaryExpression */ || expression.kind === 220 /* PostfixUnaryExpression */) { + else if (expression.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || expression.kind === 220 /* SyntaxKind.PostfixUnaryExpression */) { return expression.operator; } else { @@ -17973,129 +18095,129 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 351 /* CommaListExpression */: - return 0 /* Comma */; - case 225 /* SpreadElement */: - return 1 /* Spread */; - case 224 /* YieldExpression */: - return 2 /* Yield */; - case 222 /* ConditionalExpression */: - return 4 /* Conditional */; - case 221 /* BinaryExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + return 0 /* OperatorPrecedence.Comma */; + case 225 /* SyntaxKind.SpreadElement */: + return 1 /* OperatorPrecedence.Spread */; + case 224 /* SyntaxKind.YieldExpression */: + return 2 /* OperatorPrecedence.Yield */; + case 222 /* SyntaxKind.ConditionalExpression */: + return 4 /* OperatorPrecedence.Conditional */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operatorKind) { - case 27 /* CommaToken */: - return 0 /* Comma */; - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 3 /* Assignment */; + case 27 /* SyntaxKind.CommaToken */: + return 0 /* OperatorPrecedence.Comma */; + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 3 /* OperatorPrecedence.Assignment */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - return 16 /* Unary */; - case 220 /* PostfixUnaryExpression */: - return 17 /* Update */; - case 208 /* CallExpression */: - return 18 /* LeftHandSide */; - case 209 /* NewExpression */: - return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 210 /* TaggedTemplateExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 231 /* MetaProperty */: - return 19 /* Member */; - case 229 /* AsExpression */: - return 11 /* Relational */; - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 212 /* ParenthesizedExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - return 20 /* Primary */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + return 16 /* OperatorPrecedence.Unary */; + case 220 /* SyntaxKind.PostfixUnaryExpression */: + return 17 /* OperatorPrecedence.Update */; + case 208 /* SyntaxKind.CallExpression */: + return 18 /* OperatorPrecedence.LeftHandSide */; + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 19 /* OperatorPrecedence.Member */ : 18 /* OperatorPrecedence.LeftHandSide */; + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 231 /* SyntaxKind.MetaProperty */: + return 19 /* OperatorPrecedence.Member */; + case 229 /* SyntaxKind.AsExpression */: + return 11 /* OperatorPrecedence.Relational */; + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + return 20 /* OperatorPrecedence.Primary */; default: - return -1 /* Invalid */; + return -1 /* OperatorPrecedence.Invalid */; } } ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 60 /* QuestionQuestionToken */: - return 4 /* Coalesce */; - case 56 /* BarBarToken */: - return 5 /* LogicalOR */; - case 55 /* AmpersandAmpersandToken */: - return 6 /* LogicalAND */; - case 51 /* BarToken */: - return 7 /* BitwiseOR */; - case 52 /* CaretToken */: - return 8 /* BitwiseXOR */; - case 50 /* AmpersandToken */: - return 9 /* BitwiseAND */; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - return 10 /* Equality */; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - return 11 /* Relational */; - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - return 12 /* Shift */; - case 39 /* PlusToken */: - case 40 /* MinusToken */: - return 13 /* Additive */; - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - return 14 /* Multiplicative */; - case 42 /* AsteriskAsteriskToken */: - return 15 /* Exponentiation */; + case 60 /* SyntaxKind.QuestionQuestionToken */: + return 4 /* OperatorPrecedence.Coalesce */; + case 56 /* SyntaxKind.BarBarToken */: + return 5 /* OperatorPrecedence.LogicalOR */; + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + return 6 /* OperatorPrecedence.LogicalAND */; + case 51 /* SyntaxKind.BarToken */: + return 7 /* OperatorPrecedence.BitwiseOR */; + case 52 /* SyntaxKind.CaretToken */: + return 8 /* OperatorPrecedence.BitwiseXOR */; + case 50 /* SyntaxKind.AmpersandToken */: + return 9 /* OperatorPrecedence.BitwiseAND */; + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + return 10 /* OperatorPrecedence.Equality */; + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + return 11 /* OperatorPrecedence.Relational */; + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + return 12 /* OperatorPrecedence.Shift */; + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + return 13 /* OperatorPrecedence.Additive */; + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + return 14 /* OperatorPrecedence.Multiplicative */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + return 15 /* OperatorPrecedence.Exponentiation */; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. @@ -18105,9 +18227,9 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !!i.expression; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return !i.containsOnlyTriviaWhiteSpaces; default: return true; @@ -18222,9 +18344,9 @@ var ts; return "\\u" + paddedHexCode; } function getReplacement(c, offset, input) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); - if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) { + if (lookAhead >= 48 /* CharacterCodes._0 */ && lookAhead <= 57 /* CharacterCodes._9 */) { // If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode) return "\\x00"; } @@ -18239,8 +18361,8 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : - quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 96 /* CharacterCodes.backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* CharacterCodes.singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } @@ -18270,13 +18392,13 @@ var ts; return "&#x" + hexCharCode + ";"; } function getJsxAttributeStringReplacement(c) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { return "�"; } return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0)); } function escapeJsxAttributeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 39 /* CharacterCodes.singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : jsxDoubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement); } @@ -18295,13 +18417,13 @@ var ts; } ts.stripQuotes = stripQuotes; function isQuoteOrBacktick(charCode) { - return charCode === 39 /* singleQuote */ || - charCode === 34 /* doubleQuote */ || - charCode === 96 /* backtick */; + return charCode === 39 /* CharacterCodes.singleQuote */ || + charCode === 34 /* CharacterCodes.doubleQuote */ || + charCode === 96 /* CharacterCodes.backtick */; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); + return (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; var indentStrings = ["", " "]; @@ -18546,20 +18668,20 @@ var ts; } ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker; function getDeclarationEmitExtensionForPath(path) { - return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : - ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : - ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well - ".d.ts" /* Dts */; + return ts.fileExtensionIsOneOf(path, [".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? ".d.mts" /* Extension.Dmts */ : + ts.fileExtensionIsOneOf(path, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? ".d.cts" /* Extension.Dcts */ : + ts.fileExtensionIsOneOf(path, [".json" /* Extension.Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + ".d.ts" /* Extension.Dts */; } ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; /** * This function is an inverse of `getDeclarationEmitExtensionForPath`. */ function getPossibleOriginalInputExtensionForExtension(path) { - return ts.fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : - ts.fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : - ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Json */] : - [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */]; + return ts.fileExtensionIsOneOf(path, [".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */] : + ts.fileExtensionIsOneOf(path, [".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */] : + ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Extension.Json */] : + [".tsx" /* Extension.Tsx */, ".ts" /* Extension.Ts */, ".jsx" /* Extension.Jsx */, ".js" /* Extension.Js */]; } ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension; function outFile(options) { @@ -18687,7 +18809,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* SyntaxKind.Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function isThisInTypeQuery(node) { @@ -18697,11 +18819,11 @@ var ts; while (ts.isQualifiedName(node.parent) && node.parent.left === node) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */; + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 108 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* SyntaxKind.ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -18712,10 +18834,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 173 /* SetAccessor */) { + else if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { setAccessor = accessor; } else { @@ -18735,10 +18857,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 172 /* GetAccessor */ && !getAccessor) { + if (member.kind === 172 /* SyntaxKind.GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 173 /* SetAccessor */ && !setAccessor) { + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -18787,7 +18909,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* SyntaxKind.JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18904,7 +19026,7 @@ var ts; } ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); var lineCount = lineMap.length; var firstCommentLineIndent = void 0; @@ -18979,7 +19101,7 @@ var ts; function calculateIndent(text, pos, end) { var currentLineIndent = 0; for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9 /* tab */) { + if (text.charCodeAt(pos) === 9 /* CharacterCodes.tab */) { // Tabs = TabSize = indent size and go to next tabStop currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } @@ -18991,11 +19113,11 @@ var ts; return currentLineIndent; } function hasEffectiveModifiers(node) { - return getEffectiveModifierFlags(node) !== 0 /* None */; + return getEffectiveModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasEffectiveModifiers = hasEffectiveModifiers; function hasSyntacticModifiers(node) { - return getSyntacticModifierFlags(node) !== 0 /* None */; + return getSyntacticModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasSyntacticModifiers = hasSyntacticModifiers; function hasEffectiveModifier(node, flags) { @@ -19012,27 +19134,27 @@ var ts; } ts.isStatic = isStatic; function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 32 /* ModifierFlags.Static */); } ts.hasStaticModifier = hasStaticModifier; function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16384 /* ModifierFlags.Override */); } ts.hasOverrideModifier = hasOverrideModifier; function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 128 /* Abstract */); + return hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); } ts.hasAbstractModifier = hasAbstractModifier; function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */); } ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 64 /* ModifierFlags.Readonly */); } ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier; function hasDecorators(node) { - return hasSyntacticModifier(node, 131072 /* Decorator */); + return hasSyntacticModifier(node, 131072 /* ModifierFlags.Decorator */); } ts.hasDecorators = hasDecorators; function getSelectedEffectiveModifierFlags(node, flags) { @@ -19044,16 +19166,16 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 160 /* LastToken */) { - return 0 /* None */; + if (node.kind >= 0 /* SyntaxKind.FirstToken */ && node.kind <= 160 /* SyntaxKind.LastToken */) { + return 0 /* ModifierFlags.None */; } - if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { - node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; + if (!(node.modifierFlagsCache & 536870912 /* ModifierFlags.HasComputedFlags */)) { + node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* ModifierFlags.HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* ModifierFlags.HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { + node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* ModifierFlags.HasComputedJSDocModifiers */; } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return node.modifierFlagsCache & ~(536870912 /* ModifierFlags.HasComputedFlags */ | 4096 /* ModifierFlags.HasComputedJSDocModifiers */); } /** * Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance. @@ -19078,22 +19200,22 @@ var ts; } ts.getSyntacticModifierFlags = getSyntacticModifierFlags; function getJSDocModifierFlagsNoCache(node) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (!!node.parent && !ts.isParameter(node)) { if (isInJSFile(node)) { if (ts.getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 4 /* ModifierFlags.Public */; if (ts.getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 8 /* ModifierFlags.Private */; if (ts.getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 16 /* ModifierFlags.Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; if (ts.getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 8192 /* ModifierFlags.Deprecated */; } return flags; } @@ -19112,15 +19234,15 @@ var ts; * NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc. */ function getSyntacticModifierFlagsNoCache(node) { - var flags = ts.canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* None */; - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { - flags |= 1 /* Export */; + var flags = ts.canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* ModifierFlags.None */; + if (node.flags & 4 /* NodeFlags.NestedNamespace */ || (node.kind === 79 /* SyntaxKind.Identifier */ && node.isInJSDocNamespace)) { + flags |= 1 /* ModifierFlags.Export */; } return flags; } ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache; function modifiersToFlags(modifiers) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (modifiers) { for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; @@ -19132,23 +19254,23 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 124 /* StaticKeyword */: return 32 /* Static */; - case 123 /* PublicKeyword */: return 4 /* Public */; - case 122 /* ProtectedKeyword */: return 16 /* Protected */; - case 121 /* PrivateKeyword */: return 8 /* Private */; - case 126 /* AbstractKeyword */: return 128 /* Abstract */; - case 93 /* ExportKeyword */: return 1 /* Export */; - case 135 /* DeclareKeyword */: return 2 /* Ambient */; - case 85 /* ConstKeyword */: return 2048 /* Const */; - case 88 /* DefaultKeyword */: return 512 /* Default */; - case 131 /* AsyncKeyword */: return 256 /* Async */; - case 145 /* ReadonlyKeyword */: return 64 /* Readonly */; - case 159 /* OverrideKeyword */: return 16384 /* Override */; - case 101 /* InKeyword */: return 32768 /* In */; - case 144 /* OutKeyword */: return 65536 /* Out */; - case 165 /* Decorator */: return 131072 /* Decorator */; - } - return 0 /* None */; + case 124 /* SyntaxKind.StaticKeyword */: return 32 /* ModifierFlags.Static */; + case 123 /* SyntaxKind.PublicKeyword */: return 4 /* ModifierFlags.Public */; + case 122 /* SyntaxKind.ProtectedKeyword */: return 16 /* ModifierFlags.Protected */; + case 121 /* SyntaxKind.PrivateKeyword */: return 8 /* ModifierFlags.Private */; + case 126 /* SyntaxKind.AbstractKeyword */: return 128 /* ModifierFlags.Abstract */; + case 93 /* SyntaxKind.ExportKeyword */: return 1 /* ModifierFlags.Export */; + case 135 /* SyntaxKind.DeclareKeyword */: return 2 /* ModifierFlags.Ambient */; + case 85 /* SyntaxKind.ConstKeyword */: return 2048 /* ModifierFlags.Const */; + case 88 /* SyntaxKind.DefaultKeyword */: return 512 /* ModifierFlags.Default */; + case 131 /* SyntaxKind.AsyncKeyword */: return 256 /* ModifierFlags.Async */; + case 145 /* SyntaxKind.ReadonlyKeyword */: return 64 /* ModifierFlags.Readonly */; + case 159 /* SyntaxKind.OverrideKeyword */: return 16384 /* ModifierFlags.Override */; + case 101 /* SyntaxKind.InKeyword */: return 32768 /* ModifierFlags.In */; + case 144 /* SyntaxKind.OutKeyword */: return 65536 /* ModifierFlags.Out */; + case 165 /* SyntaxKind.Decorator */: return 131072 /* ModifierFlags.Decorator */; + } + return 0 /* ModifierFlags.None */; } ts.modifierToFlag = modifierToFlag; function createModifiers(modifierFlags) { @@ -19156,15 +19278,15 @@ var ts; } ts.createModifiers = createModifiers; function isLogicalOperator(token) { - return token === 56 /* BarBarToken */ - || token === 55 /* AmpersandAmpersandToken */ - || token === 53 /* ExclamationToken */; + return token === 56 /* SyntaxKind.BarBarToken */ + || token === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || token === 53 /* SyntaxKind.ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 75 /* BarBarEqualsToken */ - || token === 76 /* AmpersandAmpersandEqualsToken */ - || token === 77 /* QuestionQuestionEqualsToken */; + return token === 75 /* SyntaxKind.BarBarEqualsToken */ + || token === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */ + || token === 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -19172,7 +19294,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; + return token >= 63 /* SyntaxKind.FirstAssignment */ && token <= 78 /* SyntaxKind.LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -19185,14 +19307,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 63 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -19204,8 +19326,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 205 /* ObjectLiteralExpression */ - || kind === 204 /* ArrayLiteralExpression */; + return kind === 205 /* SyntaxKind.ObjectLiteralExpression */ + || kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } return false; } @@ -19215,33 +19337,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* SyntaxKind.Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 79 /* Identifier */ - || node.kind === 108 /* ThisKeyword */ - || node.kind === 106 /* SuperKeyword */ - || node.kind === 231 /* MetaProperty */ - || node.kind === 206 /* PropertyAccessExpression */ && isDottedName(node.expression) - || node.kind === 212 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 108 /* SyntaxKind.ThisKeyword */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */ + || node.kind === 231 /* SyntaxKind.MetaProperty */ + || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -19272,8 +19394,8 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isRightSideOfAccessExpression(node) { @@ -19288,12 +19410,12 @@ var ts; } ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 205 /* ObjectLiteralExpression */ && + return expression.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 204 /* ArrayLiteralExpression */ && + return expression.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -19309,7 +19431,7 @@ var ts; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isExportDefaultSymbol(symbol) { - return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* Default */); + return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* ModifierFlags.Default */); } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTSExtension(fileName) { @@ -19480,9 +19602,9 @@ var ts; var lineFeed = "\n"; function getNewLineCharacter(options, getNewLine) { switch (options.newLine) { - case 0 /* CarriageReturnLineFeed */: + case 0 /* NewLineKind.CarriageReturnLineFeed */: return carriageReturnLineFeed; - case 1 /* LineFeed */: + case 1 /* NewLineKind.LineFeed */: return lineFeed; } return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed; @@ -19627,8 +19749,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -19652,32 +19774,33 @@ var ts; } ts.closeFileWatcher = closeFileWatcher; function getCheckFlags(symbol) { - return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; + return symbol.flags & 33554432 /* SymbolFlags.Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration)) + || (s.flags & 32768 /* SymbolFlags.GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* SymbolFlags.Class */ ? flags : flags & ~28 /* ModifierFlags.AccessibilityModifier */; } - if (getCheckFlags(s) & 6 /* Synthetic */) { + if (getCheckFlags(s) & 6 /* CheckFlags.Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; - var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + var accessModifier = checkFlags & 1024 /* CheckFlags.ContainsPrivate */ ? 8 /* ModifierFlags.Private */ : + checkFlags & 256 /* CheckFlags.ContainsPublic */ ? 4 /* ModifierFlags.Public */ : + 16 /* ModifierFlags.Protected */; + var staticModifier = checkFlags & 2048 /* CheckFlags.ContainsStatic */ ? 32 /* ModifierFlags.Static */ : 0; return accessModifier | staticModifier; } - if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + if (s.flags & 4194304 /* SymbolFlags.Prototype */) { + return 4 /* ModifierFlags.Public */ | 32 /* ModifierFlags.Static */; } return 0; } ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol; function skipAlias(symbol, checker) { - return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol; + return symbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(symbol) : symbol; } ts.skipAlias = skipAlias; /** See comment on `declareModuleMember` in `binder.ts`. */ @@ -19686,11 +19809,11 @@ var ts; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; function isWriteOnlyAccess(node) { - return accessKind(node) === 1 /* Write */; + return accessKind(node) === 1 /* AccessKind.Write */; } ts.isWriteOnlyAccess = isWriteOnlyAccess; function isWriteAccess(node) { - return accessKind(node) !== 0 /* Read */; + return accessKind(node) !== 0 /* AccessKind.Read */; } ts.isWriteAccess = isWriteAccess; var AccessKind; @@ -19705,47 +19828,47 @@ var ts; function accessKind(node) { var parent = node.parent; if (!parent) - return 0 /* Read */; + return 0 /* AccessKind.Read */; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return accessKind(parent); - case 220 /* PostfixUnaryExpression */: - case 219 /* PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var operator = parent.operator; - return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 221 /* BinaryExpression */: + return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? writeOrReadWrite() : 0 /* AccessKind.Read */; + case 221 /* SyntaxKind.BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() - : 0 /* Read */; - case 206 /* PropertyAccessExpression */: - return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 296 /* PropertyAssignment */: { + operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : writeOrReadWrite() + : 0 /* AccessKind.Read */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent); + case 296 /* SyntaxKind.PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. - return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 204 /* ArrayLiteralExpression */: + return node === parent.objectAssignmentInitializer ? 0 /* AccessKind.Read */ : accessKind(parent.parent); + case 204 /* SyntaxKind.ArrayLiteralExpression */: return accessKind(parent); default: - return 0 /* Read */; + return 0 /* AccessKind.Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* SyntaxKind.ExpressionStatement */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */; } } function reverseAccessKind(a) { switch (a) { - case 0 /* Read */: - return 1 /* Write */; - case 1 /* Write */: - return 0 /* Read */; - case 2 /* ReadWrite */: - return 2 /* ReadWrite */; + case 0 /* AccessKind.Read */: + return 1 /* AccessKind.Write */; + case 1 /* AccessKind.Write */: + return 0 /* AccessKind.Read */; + case 2 /* AccessKind.ReadWrite */: + return 2 /* AccessKind.ReadWrite */; default: return ts.Debug.assertNever(a); } @@ -19815,9 +19938,9 @@ var ts; } ts.mutateMap = mutateMap; function isAbstractConstructorSymbol(symbol) { - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 128 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); } return false; } @@ -19828,11 +19951,11 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0; + return type.flags & 3899393 /* TypeFlags.ObjectFlagsType */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { - return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0; + return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length !== 0; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { @@ -19879,44 +20002,44 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) - || kind === 130 /* AnyKeyword */ - || kind === 155 /* UnknownKeyword */ - || kind === 147 /* NumberKeyword */ - || kind === 158 /* BigIntKeyword */ - || kind === 148 /* ObjectKeyword */ - || kind === 133 /* BooleanKeyword */ - || kind === 150 /* StringKeyword */ - || kind === 151 /* SymbolKeyword */ - || kind === 114 /* VoidKeyword */ - || kind === 153 /* UndefinedKeyword */ - || kind === 143 /* NeverKeyword */ - || kind === 228 /* ExpressionWithTypeArguments */ - || kind === 312 /* JSDocAllType */ - || kind === 313 /* JSDocUnknownType */ - || kind === 314 /* JSDocNullableType */ - || kind === 315 /* JSDocNonNullableType */ - || kind === 316 /* JSDocOptionalType */ - || kind === 317 /* JSDocFunctionType */ - || kind === 318 /* JSDocVariadicType */; + return (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) + || kind === 130 /* SyntaxKind.AnyKeyword */ + || kind === 155 /* SyntaxKind.UnknownKeyword */ + || kind === 147 /* SyntaxKind.NumberKeyword */ + || kind === 158 /* SyntaxKind.BigIntKeyword */ + || kind === 148 /* SyntaxKind.ObjectKeyword */ + || kind === 133 /* SyntaxKind.BooleanKeyword */ + || kind === 150 /* SyntaxKind.StringKeyword */ + || kind === 151 /* SyntaxKind.SymbolKeyword */ + || kind === 114 /* SyntaxKind.VoidKeyword */ + || kind === 153 /* SyntaxKind.UndefinedKeyword */ + || kind === 143 /* SyntaxKind.NeverKeyword */ + || kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ + || kind === 312 /* SyntaxKind.JSDocAllType */ + || kind === 313 /* SyntaxKind.JSDocUnknownType */ + || kind === 314 /* SyntaxKind.JSDocNullableType */ + || kind === 315 /* SyntaxKind.JSDocNonNullableType */ + || kind === 316 /* SyntaxKind.JSDocOptionalType */ + || kind === 317 /* SyntaxKind.JSDocFunctionType */ + || kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */ || node.kind === 207 /* ElementAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 206 /* PropertyAccessExpression */) { + if (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 207 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 207 /* SyntaxKind.ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; function isBundleFileTextLike(section) { switch (section.kind) { - case "text" /* Text */: - case "internal" /* Internal */: + case "text" /* BundleFileSectionKind.Text */: + case "internal" /* BundleFileSectionKind.Internal */: return true; default: return false; @@ -19924,7 +20047,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 269 /* NamedImports */ || node.kind === 273 /* NamedExports */; + return node.kind === 269 /* SyntaxKind.NamedImports */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -19939,13 +20062,13 @@ var ts; return walkAccessExpression(name.parent); } function walkAccessExpression(access) { - if (access.kind === 206 /* PropertyAccessExpression */) { + if (access.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var res = action(access.name); if (res !== undefined) { return res; } } - else if (access.kind === 207 /* ElementAccessExpression */) { + else if (access.kind === 207 /* SyntaxKind.ElementAccessExpression */) { if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) { var res = action(access.argumentExpression); if (res !== undefined) { @@ -19972,28 +20095,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: node = node.operand; continue; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: node = node.left; continue; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: node = node.condition; continue; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: node = node.tag; continue; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 229 /* AsExpression */: - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: - case 230 /* NonNullExpression */: - case 350 /* PartiallyEmittedExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: node = node.expression; continue; } @@ -20027,9 +20150,9 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; } @@ -20038,8 +20161,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } function Identifier(kind, pos, end) { @@ -20047,8 +20170,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; this.flowNode = undefined; @@ -20243,7 +20366,7 @@ var ts; function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -20252,43 +20375,43 @@ var ts; ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (d1.relatedInformation && d2.relatedInformation) { return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { var d2i = d2.relatedInformation[index]; return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; + }) || 0 /* Comparison.EqualTo */; } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + return d1.relatedInformation ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; } function compareMessageText(t1, t2) { if (typeof t1 === "string" && typeof t2 === "string") { return ts.compareStringsCaseSensitive(t1, t2); } else if (typeof t1 === "string") { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (typeof t2 === "string") { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); if (res) { return res; } if (!t1.next && !t2.next) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (!t1.next) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } if (!t2.next) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var len = Math.min(t1.next.length, t2.next.length); for (var i = 0; i < len; i++) { @@ -20298,16 +20421,16 @@ var ts; } } if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* ScriptKind.TSX */ || scriptKind === 2 /* ScriptKind.JSX */ || scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 6 /* ScriptKind.JSON */ ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */; } ts.getLanguageVariant = getLanguageVariant; /** @@ -20316,7 +20439,7 @@ var ts; * Unfortunately, there's no `NodeFlag` space to do the same for JSX. */ function walkTreeForJSXTags(node) { - if (!(node.transformFlags & 2 /* ContainsJsx */)) + if (!(node.transformFlags & 2 /* TransformFlags.ContainsJsx */)) return undefined; return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags); } @@ -20333,7 +20456,7 @@ var ts; // Excludes declaration files - they still require an explicit `export {}` or the like // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files // that aren't esm-mode (meaning not in a `type: module` scope). - return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined; + return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]))) && !file.isDeclarationFile ? true : undefined; } function getSetExternalModuleIndicator(options) { // TODO: Should this callback be cached? @@ -20353,13 +20476,10 @@ var ts; // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness var checks = [ts.isFileProbablyExternalModule]; - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { checks.push(isFileModuleFromUsingJSXTag); } - var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { - checks.push(isFileForcedToBeModuleByFormat); - } + checks.push(isFileForcedToBeModuleByFormat); var combined_1 = ts.or.apply(void 0, checks); var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); }; return callback; @@ -20368,15 +20488,15 @@ var ts; ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator; function getEmitScriptTarget(compilerOptions) { return compilerOptions.target || - (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ES2022 */) || - (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) || - 0 /* ES3 */; + (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ScriptTarget.ES2022 */) || + (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ScriptTarget.ESNext */) || + 0 /* ScriptTarget.ES3 */; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function getEmitModuleResolutionKind(compilerOptions) { @@ -20474,7 +20594,7 @@ var ts; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function getUseDefineForClassFields(compilerOptions) { - return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */ : compilerOptions.useDefineForClassFields; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { @@ -20495,14 +20615,14 @@ var ts; ts.getCompilerOptionValue = getCompilerOptionValue; function getJSXTransformEnabled(options) { var jsx = options.jsx; - return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */; + return jsx === 2 /* JsxEmit.React */ || jsx === 4 /* JsxEmit.ReactJSX */ || jsx === 5 /* JsxEmit.ReactJSXDev */; } ts.getJSXTransformEnabled = getJSXTransformEnabled; function getJSXImplicitImportBase(compilerOptions, file) { var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; - return compilerOptions.jsx === 4 /* ReactJSX */ || - compilerOptions.jsx === 5 /* ReactJSXDev */ || + return compilerOptions.jsx === 4 /* JsxEmit.ReactJSX */ || + compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ || compilerOptions.jsxImportSource || jsxImportSourcePragma ? (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : @@ -20510,13 +20630,13 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { + if (str.charCodeAt(i) === 42 /* CharacterCodes.asterisk */) { if (!seenAsterisk) { seenAsterisk = true; } @@ -20615,9 +20735,9 @@ var ts; function escapeRegExpCharacter(match) { return "\\" + match; } - var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; + var wildcardCharCodes = [42 /* CharacterCodes.asterisk */, 63 /* CharacterCodes.question */]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { /** * Matches any single directory segment unless it is the last segment and a .min.js file @@ -20630,7 +20750,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { @@ -20639,7 +20759,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -20657,10 +20777,10 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); // If excluding, match "foo/bar/baz...", but if including, only allow "foo". var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -20682,7 +20802,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -20719,11 +20839,11 @@ var ts; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { + if (component.charCodeAt(0) === 42 /* CharacterCodes.asterisk */) { componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } - else if (component.charCodeAt(0) === 63 /* question */) { + else if (component.charCodeAt(0) === 63 /* CharacterCodes.question */) { componentPattern += "[^./]"; component = component.substr(1); } @@ -20760,7 +20880,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -20885,44 +21005,44 @@ var ts; // If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt // to get the ScriptKind from the file name. If it cannot be resolved // from the file name then the default 'TS' script kind is returned. - return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */; + return scriptKind || getScriptKindFromFileName(fileName) || 3 /* ScriptKind.TS */; } ts.ensureScriptKind = ensureScriptKind; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: - case ".cjs" /* Cjs */: - case ".mjs" /* Mjs */: - return 1 /* JS */; - case ".jsx" /* Jsx */: - return 2 /* JSX */; - case ".ts" /* Ts */: - case ".cts" /* Cts */: - case ".mts" /* Mts */: - return 3 /* TS */; - case ".tsx" /* Tsx */: - return 4 /* TSX */; - case ".json" /* Json */: - return 6 /* JSON */; + case ".js" /* Extension.Js */: + case ".cjs" /* Extension.Cjs */: + case ".mjs" /* Extension.Mjs */: + return 1 /* ScriptKind.JS */; + case ".jsx" /* Extension.Jsx */: + return 2 /* ScriptKind.JSX */; + case ".ts" /* Extension.Ts */: + case ".cts" /* Extension.Cts */: + case ".mts" /* Extension.Mts */: + return 3 /* ScriptKind.TS */; + case ".tsx" /* Extension.Tsx */: + return 4 /* ScriptKind.TSX */; + case ".json" /* Extension.Json */: + return 6 /* ScriptKind.JSON */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } ts.getScriptKindFromFileName = getScriptKindFromFileName; /** * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ - ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]]; + ts.supportedTSExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */]]; ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions); - var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false); + var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Extension.Json */]], false); /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */]; - ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]]; + var supportedTSExtensionsForExtractExtension = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */]; + ts.supportedJSExtensions = [[".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".mjs" /* Extension.Mjs */], [".cjs" /* Extension.Cjs */]]; ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); - var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]]; - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false); - ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]; + var allSupportedExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */]]; + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Extension.Json */]], false); + ts.supportedDeclarationExtensions = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */]; function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { @@ -20930,7 +21050,7 @@ var ts; } var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; var flatBuiltins = ts.flatten(builtins); - var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); + var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* ScriptKind.Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); return extensions; } ts.getSupportedExtensions = getSupportedExtensions; @@ -20941,11 +21061,11 @@ var ts; return allSupportedExtensionsWithJson; if (supportedExtensions === ts.supportedTSExtensions) return supportedTSExtensionsWithJson; - return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false); + return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Extension.Json */]], false); } ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { - return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; + return scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 2 /* ScriptKind.JSX */; } function hasJSFileExtension(fileName) { return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -20976,7 +21096,7 @@ var ts; return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); } ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; - var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; + var extensionsToRemove = [".d.ts" /* Extension.Dts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".ts" /* Extension.Ts */, ".js" /* Extension.Js */, ".tsx" /* Extension.Tsx */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -21029,11 +21149,11 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTS(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */; + return ext === ".ts" /* Extension.Ts */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".d.ts" /* Extension.Dts */ || ext === ".cts" /* Extension.Cts */ || ext === ".mts" /* Extension.Mts */ || ext === ".d.mts" /* Extension.Dmts */ || ext === ".d.cts" /* Extension.Dcts */; } ts.extensionIsTS = extensionIsTS; function resolutionExtensionIsTSOrJson(ext) { - return extensionIsTS(ext) || ext === ".json" /* Json */; + return extensionIsTS(ext) || ext === ".json" /* Extension.Json */; } ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; /** @@ -21042,7 +21162,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -21151,23 +21271,23 @@ var ts; function parsePseudoBigInt(stringValue) { var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" - case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 98 /* CharacterCodes.b */: + case 66 /* CharacterCodes.B */: // 0b or 0B log2Base = 1; break; - case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 111 /* CharacterCodes.o */: + case 79 /* CharacterCodes.O */: // 0o or 0O log2Base = 3; break; - case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 120 /* CharacterCodes.x */: + case 88 /* CharacterCodes.X */: // 0x or 0X log2Base = 4; break; default: // already in decimal; omit trailing "n" var nIndex = stringValue.length - 1; // Skip leading 0s var nonZeroStart = 0; - while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) { + while (stringValue.charCodeAt(nonZeroStart) === 48 /* CharacterCodes._0 */) { nonZeroStart++; } return stringValue.slice(nonZeroStart, nIndex) || "0"; @@ -21183,10 +21303,10 @@ var ts; var segment = bitOffset >>> 4; var digitChar = stringValue.charCodeAt(i); // Find character range: 0-9 < A-F < a-f - var digit = digitChar <= 57 /* _9 */ - ? digitChar - 48 /* _0 */ + var digit = digitChar <= 57 /* CharacterCodes._9 */ + ? digitChar - 48 /* CharacterCodes._0 */ : 10 + digitChar - - (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + (digitChar <= 70 /* CharacterCodes.F */ ? 65 /* CharacterCodes.A */ : 97 /* CharacterCodes.a */); var shiftedDigit = digit << (bitOffset & 15); segments[segment] |= shiftedDigit; var residual = shiftedDigit >>> 16; @@ -21221,7 +21341,7 @@ var ts; } ts.pseudoBigIntToString = pseudoBigIntToString; function isValidTypeOnlyAliasUseSite(useSite) { - return !!(useSite.flags & 16777216 /* Ambient */) + return !!(useSite.flags & 16777216 /* NodeFlags.Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) @@ -21232,34 +21352,34 @@ var ts; return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite; } function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 79 /* Identifier */ || node.kind === 206 /* PropertyAccessExpression */) { + while (node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 258 /* InterfaceDeclaration */ || containerKind === 182 /* TypeLiteral */; + return containerKind === 258 /* SyntaxKind.InterfaceDeclaration */ || containerKind === 182 /* SyntaxKind.TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 79 /* Identifier */) + if (node.kind !== 79 /* SyntaxKind.Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return true; - case 206 /* PropertyAccessExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* SyntaxKind.ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* SyntaxKind.InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -21400,7 +21520,7 @@ var ts; node = parent; continue; } - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // left side of comma is always unused if (node === parent.left) return true; @@ -21420,22 +21540,22 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 190 /* InferType */ ? undefined : parent_1.typeParameters; - case 164 /* Parameter */: + return parent_1.kind === 190 /* SyntaxKind.InferType */ ? undefined : parent_1.typeParameters; + case 164 /* SyntaxKind.Parameter */: return node.parent.parameters; - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node.parent.templateSpans; - case 165 /* Decorator */: { + case 165 /* SyntaxKind.Decorator */: { var parent_2 = node.parent; return ts.canHaveDecorators(parent_2) ? parent_2.modifiers : ts.canHaveIllegalDecorators(parent_2) ? parent_2.decorators : undefined; } - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -21443,45 +21563,45 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 182 /* TypeLiteral */: - case 258 /* InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return parent.types; - case 184 /* TupleType */: - case 204 /* ArrayLiteralExpression */: - case 351 /* CommaListExpression */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 184 /* SyntaxKind.TupleType */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return parent.elements; - case 205 /* ObjectLiteralExpression */: - case 286 /* JsxAttributes */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 286 /* SyntaxKind.JsxAttributes */: return parent.properties; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 278 /* JsxElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 282 /* SyntaxKind.JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: return parent.statements; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return parent.clauses; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return parent.statements; } } @@ -21493,7 +21613,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 214 /* ArrowFunction */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -21511,7 +21631,7 @@ var ts; } ts.isInfinityOrNaNString = isInfinityOrNaNString; function isCatchClauseVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function isParameterOrCatchClauseVariable(symbol) { @@ -21520,7 +21640,7 @@ var ts; } ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable; function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 213 /* FunctionExpression */ || node.kind === 214 /* ArrowFunction */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */ || node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction; function escapeSnippetText(text) { @@ -21559,7 +21679,7 @@ var ts; } ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral; function isThisTypeParameter(type) { - return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); + return !!(type.flags & 262144 /* TypeFlags.TypeParameter */ && type.isThisType); } ts.isThisTypeParameter = isThisTypeParameter; function getNodeModulePathParts(fullPath) { @@ -21579,45 +21699,45 @@ var ts; })(States || (States = {})); var partStart = 0; var partEnd = 0; - var state = 0 /* BeforeNodeModules */; + var state = 0 /* States.BeforeNodeModules */; while (partEnd >= 0) { partStart = partEnd; partEnd = fullPath.indexOf("/", partStart + 1); switch (state) { - case 0 /* BeforeNodeModules */: + case 0 /* States.BeforeNodeModules */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { topLevelNodeModulesIndex = partStart; topLevelPackageNameIndex = partEnd; - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } break; - case 1 /* NodeModules */: - case 2 /* Scope */: - if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { - state = 2 /* Scope */; + case 1 /* States.NodeModules */: + case 2 /* States.Scope */: + if (state === 1 /* States.NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* States.Scope */; } else { packageRootIndex = partEnd; - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; - case 3 /* PackageContent */: + case 3 /* States.PackageContent */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } else { - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; } } fileNameIndex = partStart; - return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; + return state > 1 /* States.NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; } ts.getNodeModulePathParts = getNodeModulePathParts; function getParameterTypeNode(parameter) { var _a; - return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; + return parameter.kind === 340 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; } ts.getParameterTypeNode = getParameterTypeNode; })(ts || (ts = {})); @@ -21742,28 +21862,28 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* SyntaxKind.BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 214 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 214 /* SyntaxKind.ArrowFunction */ && binaryOperatorPrecedence > 3 /* OperatorPrecedence.Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If the operand is the right side of a right-associative binary operation // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 224 /* YieldExpression */) { + && binaryOperatorAssociativity === 1 /* Associativity.Right */ + && operand.kind === 224 /* SyntaxKind.YieldExpression */) { return false; } return true; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: return false; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: if (isLeftSideOfBinary) { // No need to parenthesize the left operand when the binary operator is // left associative: @@ -21774,7 +21894,7 @@ var ts; // right associative: // (a/b)**x -> (a/b)**x // (a**b)**x -> (a**b)**x - return binaryOperatorAssociativity === 1 /* Right */; + return binaryOperatorAssociativity === 1 /* Associativity.Right */; } else { if (ts.isBinaryExpression(emittedOperand) @@ -21794,8 +21914,8 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 39 /* PlusToken */) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; + if (binaryOperator === 39 /* SyntaxKind.PlusToken */) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* SyntaxKind.Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; } @@ -21811,7 +21931,7 @@ var ts; // x/(a*b) -> x/(a*b) // x**(a/b) -> x**(a/b) var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0 /* Left */; + return operandAssociativity === 0 /* Associativity.Left */; } } } @@ -21829,10 +21949,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 41 /* AsteriskToken */ - || binaryOperator === 51 /* BarToken */ - || binaryOperator === 50 /* AmpersandToken */ - || binaryOperator === 52 /* CaretToken */; + return binaryOperator === 41 /* SyntaxKind.AsteriskToken */ + || binaryOperator === 51 /* SyntaxKind.BarToken */ + || binaryOperator === 50 /* SyntaxKind.AmpersandToken */ + || binaryOperator === 52 /* SyntaxKind.CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -21845,7 +21965,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -21853,11 +21973,11 @@ var ts; var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind - : 0 /* Unknown */; + : 0 /* SyntaxKind.Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended @@ -21871,7 +21991,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 212 /* ParenthesizedExpression */) { + if (skipped.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -21888,10 +22008,10 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(222 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(222 /* SyntaxKind.ConditionalExpression */, 57 /* SyntaxKind.QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* Comparison.GreaterThan */) { return factory.createParenthesizedExpression(condition); } return condition; @@ -21921,8 +22041,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: needsParens = true; } } @@ -21935,9 +22055,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return factory.createParenthesizedExpression(expression); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -21948,7 +22068,7 @@ var ts; * Wraps an expression in parentheses if it is needed in order to use the expression for * property or element access. */ - function parenthesizeLeftSideOfAccess(expression) { + function parenthesizeLeftSideOfAccess(expression, optionalChain) { // isLeftHandSideExpression is almost the correct criterion for when it is not necessary // to parenthesize the expression before a dot. The known exception is: // @@ -21957,7 +22077,8 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 /* SyntaxKind.NewExpression */ || emittedExpression.arguments) + && (optionalChain || !ts.isOptionalChain(emittedExpression))) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -21979,7 +22100,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, 27 /* SyntaxKind.CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -21988,21 +22109,21 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 213 /* FunctionExpression */ || kind === 214 /* ArrowFunction */) { + if (kind === 213 /* SyntaxKind.FunctionExpression */ || kind === 214 /* SyntaxKind.ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); - return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); + return factory.restoreOuterExpressions(expression, updated, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 205 /* ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* FunctionExpression */) { + if (leftmostExpressionKind === 205 /* SyntaxKind.ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* SyntaxKind.FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } @@ -22020,16 +22141,16 @@ var ts; // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type function parenthesizeCheckTypeOfConditionalType(checkType) { switch (checkType.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 189 /* ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(checkType); } return checkType; } function parenthesizeExtendsTypeOfConditionalType(extendsType) { switch (extendsType.kind) { - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(extendsType); } return extendsType; @@ -22041,8 +22162,8 @@ var ts; // - A union type constituent has the same precedence as the check type of a conditional type function parenthesizeConstituentTypeOfUnionType(type) { switch (type.kind) { - case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened - case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 187 /* SyntaxKind.UnionType */: // Not strictly necessary, but a union containing a union should have been flattened + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeCheckTypeOfConditionalType(type); @@ -22057,8 +22178,8 @@ var ts; // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized) function parenthesizeConstituentTypeOfIntersectionType(type) { switch (type.kind) { - case 187 /* UnionType */: - case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfUnionType(type); @@ -22075,14 +22196,14 @@ var ts; // function parenthesizeOperandOfTypeOperator(type) { switch (type.kind) { - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfIntersectionType(type); } function parenthesizeOperandOfReadonlyTypeOperator(type) { switch (type.kind) { - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -22102,9 +22223,9 @@ var ts; // function parenthesizeNonArrayTypeOfPostfixType(type) { switch (type.kind) { - case 190 /* InferType */: - case 193 /* TypeOperator */: - case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 190 /* SyntaxKind.InferType */: + case 193 /* SyntaxKind.TypeOperator */: + case 181 /* SyntaxKind.TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -22298,11 +22419,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -22360,10 +22481,10 @@ var ts; */ /* @internal */ function createNodeFactory(flags, baseFactory) { - var update = flags & 8 /* NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; + var update = flags & 8 /* NodeFactoryFlags.NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; // Lazily load the parenthesizer, node converters, and some factory methods until they are used. - var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); - var converters = ts.memoize(function () { return flags & 2 /* NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); + var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NodeFactoryFlags.NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); + var converters = ts.memoize(function () { return flags & 2 /* NodeFactoryFlags.NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); // lazy initializaton of common operator factories var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; }); var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; }); @@ -22494,12 +22615,12 @@ var ts; updateArrayLiteralExpression: updateArrayLiteralExpression, createObjectLiteralExpression: createObjectLiteralExpression, updateObjectLiteralExpression: updateObjectLiteralExpression, - createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* NoIndentation */); } : + createPropertyAccessExpression: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessExpression, updatePropertyAccessExpression: updatePropertyAccessExpression, - createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* NoIndentation */); } : + createPropertyAccessChain: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessChain, updatePropertyAccessChain: updatePropertyAccessChain, createElementAccessExpression: createElementAccessExpression, @@ -22655,18 +22776,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* SyntaxKind.JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* SyntaxKind.JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -22702,30 +22823,30 @@ var ts; createJSDocLinkPlain: createJSDocLinkPlain, updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* JSDocReadonlyTag */); }, - get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* JSDocOverrideTag */); }, - get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* JSDocOverrideTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -22793,38 +22914,38 @@ var ts; updateSyntheticReferenceExpression: updateSyntheticReferenceExpression, cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities - get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, - get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, - get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, - get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, - get createBitwiseXor() { return getBinaryCreateFunction(52 /* CaretToken */); }, - get createBitwiseAnd() { return getBinaryCreateFunction(50 /* AmpersandToken */); }, - get createStrictEquality() { return getBinaryCreateFunction(36 /* EqualsEqualsEqualsToken */); }, - get createStrictInequality() { return getBinaryCreateFunction(37 /* ExclamationEqualsEqualsToken */); }, - get createEquality() { return getBinaryCreateFunction(34 /* EqualsEqualsToken */); }, - get createInequality() { return getBinaryCreateFunction(35 /* ExclamationEqualsToken */); }, - get createLessThan() { return getBinaryCreateFunction(29 /* LessThanToken */); }, - get createLessThanEquals() { return getBinaryCreateFunction(32 /* LessThanEqualsToken */); }, - get createGreaterThan() { return getBinaryCreateFunction(31 /* GreaterThanToken */); }, - get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* GreaterThanEqualsToken */); }, - get createLeftShift() { return getBinaryCreateFunction(47 /* LessThanLessThanToken */); }, - get createRightShift() { return getBinaryCreateFunction(48 /* GreaterThanGreaterThanToken */); }, - get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* GreaterThanGreaterThanGreaterThanToken */); }, - get createAdd() { return getBinaryCreateFunction(39 /* PlusToken */); }, - get createSubtract() { return getBinaryCreateFunction(40 /* MinusToken */); }, - get createMultiply() { return getBinaryCreateFunction(41 /* AsteriskToken */); }, - get createDivide() { return getBinaryCreateFunction(43 /* SlashToken */); }, - get createModulo() { return getBinaryCreateFunction(44 /* PercentToken */); }, - get createExponent() { return getBinaryCreateFunction(42 /* AsteriskAsteriskToken */); }, - get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* PlusToken */); }, - get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* MinusToken */); }, - get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* MinusMinusToken */); }, - get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* TildeToken */); }, - get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* ExclamationToken */); }, - get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* MinusMinusToken */); }, + get createComma() { return getBinaryCreateFunction(27 /* SyntaxKind.CommaToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* SyntaxKind.EqualsToken */); }, + get createLogicalOr() { return getBinaryCreateFunction(56 /* SyntaxKind.BarBarToken */); }, + get createLogicalAnd() { return getBinaryCreateFunction(55 /* SyntaxKind.AmpersandAmpersandToken */); }, + get createBitwiseOr() { return getBinaryCreateFunction(51 /* SyntaxKind.BarToken */); }, + get createBitwiseXor() { return getBinaryCreateFunction(52 /* SyntaxKind.CaretToken */); }, + get createBitwiseAnd() { return getBinaryCreateFunction(50 /* SyntaxKind.AmpersandToken */); }, + get createStrictEquality() { return getBinaryCreateFunction(36 /* SyntaxKind.EqualsEqualsEqualsToken */); }, + get createStrictInequality() { return getBinaryCreateFunction(37 /* SyntaxKind.ExclamationEqualsEqualsToken */); }, + get createEquality() { return getBinaryCreateFunction(34 /* SyntaxKind.EqualsEqualsToken */); }, + get createInequality() { return getBinaryCreateFunction(35 /* SyntaxKind.ExclamationEqualsToken */); }, + get createLessThan() { return getBinaryCreateFunction(29 /* SyntaxKind.LessThanToken */); }, + get createLessThanEquals() { return getBinaryCreateFunction(32 /* SyntaxKind.LessThanEqualsToken */); }, + get createGreaterThan() { return getBinaryCreateFunction(31 /* SyntaxKind.GreaterThanToken */); }, + get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* SyntaxKind.GreaterThanEqualsToken */); }, + get createLeftShift() { return getBinaryCreateFunction(47 /* SyntaxKind.LessThanLessThanToken */); }, + get createRightShift() { return getBinaryCreateFunction(48 /* SyntaxKind.GreaterThanGreaterThanToken */); }, + get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */); }, + get createAdd() { return getBinaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createSubtract() { return getBinaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createMultiply() { return getBinaryCreateFunction(41 /* SyntaxKind.AsteriskToken */); }, + get createDivide() { return getBinaryCreateFunction(43 /* SyntaxKind.SlashToken */); }, + get createModulo() { return getBinaryCreateFunction(44 /* SyntaxKind.PercentToken */); }, + get createExponent() { return getBinaryCreateFunction(42 /* SyntaxKind.AsteriskAsteriskToken */); }, + get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, + get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* SyntaxKind.TildeToken */); }, + get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* SyntaxKind.ExclamationToken */); }, + get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, // Compound nodes createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression, createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction, @@ -22928,11 +23049,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -22950,7 +23071,7 @@ var ts; node.typeParameters = asNodeArray(typeParameters); node.transformFlags |= propagateChildrenFlags(node.typeParameters); if (typeParameters) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type) { @@ -22961,7 +23082,7 @@ var ts; propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used for quick info node.typeArguments = undefined; return node; @@ -22976,9 +23097,9 @@ var ts; function createBaseFunctionLikeDeclaration(kind, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; if (!body) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseInterfaceOrClassLikeDeclaration(kind, modifiers, name, typeParameters, heritageClauses) { @@ -23004,7 +23125,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } // @@ -23017,21 +23138,21 @@ var ts; } // @api function createNumericLiteral(value, numericLiteralFlags) { - if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* None */; } - var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); + if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* TokenFlags.None */; } + var node = createBaseLiteral(8 /* SyntaxKind.NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; - if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 1024 /* ContainsES2015 */; + if (numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api function createBigIntLiteral(value) { - var node = createBaseLiteral(9 /* BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); - node.transformFlags |= 4 /* ContainsESNext */; + var node = createBaseLiteral(9 /* SyntaxKind.BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } function createBaseStringLiteral(text, isSingleQuote) { - var node = createBaseLiteral(10 /* StringLiteral */, text); + var node = createBaseLiteral(10 /* SyntaxKind.StringLiteral */, text); node.singleQuote = isSingleQuote; return node; } @@ -23040,7 +23161,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -23051,19 +23172,19 @@ var ts; } // @api function createRegularExpressionLiteral(text) { - var node = createBaseLiteral(13 /* RegularExpressionLiteral */, text); + var node = createBaseLiteral(13 /* SyntaxKind.RegularExpressionLiteral */, text); return node; } // @api function createLiteralLikeNode(kind, text) { switch (kind) { - case 8 /* NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); - case 9 /* BigIntLiteral */: return createBigIntLiteral(text); - case 10 /* StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); - case 11 /* JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); - case 12 /* JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); - case 13 /* RegularExpressionLiteral */: return createRegularExpressionLiteral(text); - case 14 /* NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); + case 8 /* SyntaxKind.NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); + case 9 /* SyntaxKind.BigIntLiteral */: return createBigIntLiteral(text); + case 10 /* SyntaxKind.StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); + case 11 /* SyntaxKind.JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); + case 13 /* SyntaxKind.RegularExpressionLiteral */: return createRegularExpressionLiteral(text); + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); } } // @@ -23073,10 +23194,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 79 /* Identifier */) { + if (originalKeywordKind === 79 /* SyntaxKind.Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -23095,8 +23216,8 @@ var ts; // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 132 /* AwaitKeyword */) { - node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { + node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; } return node; } @@ -23108,9 +23229,9 @@ var ts; } // @api function createTempVariable(recordTempVariable, reservedInNestedScopes) { - var flags = 1 /* Auto */; + var flags = 1 /* GeneratedIdentifierFlags.Auto */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; var name = createBaseGeneratedIdentifier("", flags); if (recordTempVariable) { recordTempVariable(name); @@ -23120,25 +23241,25 @@ var ts; /** Create a unique temporary variable for use in a loop. */ // @api function createLoopVariable(reservedInNestedScopes) { - var flags = 2 /* Loop */; + var flags = 2 /* GeneratedIdentifierFlags.Loop */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api function createUniqueName(text, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - ts.Debug.assert((flags & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); - return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags); + if (flags === void 0) { flags = 0 /* GeneratedIdentifierFlags.None */; } + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + ts.Debug.assert((flags & (16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)) !== 32 /* GeneratedIdentifierFlags.FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); + return createBaseGeneratedIdentifier(text, 3 /* GeneratedIdentifierFlags.Unique */ | flags); } /** Create a unique name generated for a node. */ // @api function getGeneratedNameForNode(node, flags) { if (flags === void 0) { flags = 0; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* Node */ | flags); + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* GeneratedIdentifierFlags.Node */ | flags); name.original = node; return name; } @@ -23146,9 +23267,9 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 16777216 /* ContainsClassFields */; + node.transformFlags |= 16777216 /* TransformFlags.ContainsClassFields */; return node; } // @@ -23158,51 +23279,51 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 160 /* LastToken */, "Invalid token"); - ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); - ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token >= 0 /* SyntaxKind.FirstToken */ && token <= 160 /* SyntaxKind.LastToken */, "Invalid token"); + ts.Debug.assert(token <= 14 /* SyntaxKind.FirstTemplateToken */ || token >= 17 /* SyntaxKind.LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); + ts.Debug.assert(token <= 8 /* SyntaxKind.FirstLiteralToken */ || token >= 14 /* SyntaxKind.LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); + ts.Debug.assert(token !== 79 /* SyntaxKind.Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); - var transformFlags = 0 /* None */; + var transformFlags = 0 /* TransformFlags.None */; switch (token) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; break; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 126 /* AbstractKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 155 /* UnknownKeyword */: - case 153 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. - transformFlags = 1 /* ContainsTypeScript */; + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + transformFlags = 1 /* TransformFlags.ContainsTypeScript */; break; - case 106 /* SuperKeyword */: - transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */; + case 106 /* SyntaxKind.SuperKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */ | 134217728 /* TransformFlags.ContainsLexicalSuper */; break; - case 124 /* StaticKeyword */: - transformFlags = 1024 /* ContainsES2015 */; + case 124 /* SyntaxKind.StaticKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */; break; - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 16384 /* ContainsLexicalThis */; + transformFlags = 16384 /* TransformFlags.ContainsLexicalThis */; break; } if (transformFlags) { @@ -23215,23 +23336,23 @@ var ts; // // @api function createSuper() { - return createToken(106 /* SuperKeyword */); + return createToken(106 /* SyntaxKind.SuperKeyword */); } // @api function createThis() { - return createToken(108 /* ThisKeyword */); + return createToken(108 /* SyntaxKind.ThisKeyword */); } // @api function createNull() { - return createToken(104 /* NullKeyword */); + return createToken(104 /* SyntaxKind.NullKeyword */); } // @api function createTrue() { - return createToken(110 /* TrueKeyword */); + return createToken(110 /* SyntaxKind.TrueKeyword */); } // @api function createFalse() { - return createToken(95 /* FalseKeyword */); + return createToken(95 /* SyntaxKind.FalseKeyword */); } // // Modifiers @@ -23243,34 +23364,34 @@ var ts; // @api function createModifiersFromModifierFlags(flags) { var result = []; - if (flags & 1 /* Export */) - result.push(createModifier(93 /* ExportKeyword */)); - if (flags & 2 /* Ambient */) - result.push(createModifier(135 /* DeclareKeyword */)); - if (flags & 512 /* Default */) - result.push(createModifier(88 /* DefaultKeyword */)); - if (flags & 2048 /* Const */) - result.push(createModifier(85 /* ConstKeyword */)); - if (flags & 4 /* Public */) - result.push(createModifier(123 /* PublicKeyword */)); - if (flags & 8 /* Private */) - result.push(createModifier(121 /* PrivateKeyword */)); - if (flags & 16 /* Protected */) - result.push(createModifier(122 /* ProtectedKeyword */)); - if (flags & 128 /* Abstract */) - result.push(createModifier(126 /* AbstractKeyword */)); - if (flags & 32 /* Static */) - result.push(createModifier(124 /* StaticKeyword */)); - if (flags & 16384 /* Override */) - result.push(createModifier(159 /* OverrideKeyword */)); - if (flags & 64 /* Readonly */) - result.push(createModifier(145 /* ReadonlyKeyword */)); - if (flags & 256 /* Async */) - result.push(createModifier(131 /* AsyncKeyword */)); - if (flags & 32768 /* In */) - result.push(createModifier(101 /* InKeyword */)); - if (flags & 65536 /* Out */) - result.push(createModifier(144 /* OutKeyword */)); + if (flags & 1 /* ModifierFlags.Export */) + result.push(createModifier(93 /* SyntaxKind.ExportKeyword */)); + if (flags & 2 /* ModifierFlags.Ambient */) + result.push(createModifier(135 /* SyntaxKind.DeclareKeyword */)); + if (flags & 512 /* ModifierFlags.Default */) + result.push(createModifier(88 /* SyntaxKind.DefaultKeyword */)); + if (flags & 2048 /* ModifierFlags.Const */) + result.push(createModifier(85 /* SyntaxKind.ConstKeyword */)); + if (flags & 4 /* ModifierFlags.Public */) + result.push(createModifier(123 /* SyntaxKind.PublicKeyword */)); + if (flags & 8 /* ModifierFlags.Private */) + result.push(createModifier(121 /* SyntaxKind.PrivateKeyword */)); + if (flags & 16 /* ModifierFlags.Protected */) + result.push(createModifier(122 /* SyntaxKind.ProtectedKeyword */)); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push(createModifier(126 /* SyntaxKind.AbstractKeyword */)); + if (flags & 32 /* ModifierFlags.Static */) + result.push(createModifier(124 /* SyntaxKind.StaticKeyword */)); + if (flags & 16384 /* ModifierFlags.Override */) + result.push(createModifier(159 /* SyntaxKind.OverrideKeyword */)); + if (flags & 64 /* ModifierFlags.Readonly */) + result.push(createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); + if (flags & 256 /* ModifierFlags.Async */) + result.push(createModifier(131 /* SyntaxKind.AsyncKeyword */)); + if (flags & 32768 /* ModifierFlags.In */) + result.push(createModifier(101 /* SyntaxKind.InKeyword */)); + if (flags & 65536 /* ModifierFlags.Out */) + result.push(createModifier(144 /* SyntaxKind.OutKeyword */)); return result.length ? result : undefined; } // @@ -23278,7 +23399,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(161 /* QualifiedName */); + var node = createBaseNode(161 /* SyntaxKind.QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -23295,12 +23416,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(162 /* ComputedPropertyName */); + var node = createBaseNode(162 /* SyntaxKind.ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 131072 /* ContainsComputedPropertyName */; + 1024 /* TransformFlags.ContainsES2015 */ | + 131072 /* TransformFlags.ContainsComputedPropertyName */; return node; } // @api @@ -23314,10 +23435,10 @@ var ts; // // @api function createTypeParameterDeclaration(modifiers, name, constraint, defaultType) { - var node = createBaseNamedDeclaration(163 /* TypeParameter */, modifiers, name); + var node = createBaseNamedDeclaration(163 /* SyntaxKind.TypeParameter */, modifiers, name); node.constraint = constraint; node.default = defaultType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23331,22 +23452,22 @@ var ts; } // @api function createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164 /* Parameter */, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(164 /* SyntaxKind.Parameter */, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.questionToken); if (questionToken) - node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) - node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ModifierFlags.ParameterPropertyModifier */) + node.transformFlags |= 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; } return node; } @@ -23363,13 +23484,13 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(165 /* Decorator */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseNode(165 /* SyntaxKind.Decorator */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 8192 /* ContainsTypeScriptClassSyntax */ | - 33554432 /* ContainsDecorators */; + 1 /* TransformFlags.ContainsTypeScript */ | + 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */ | + 33554432 /* TransformFlags.ContainsDecorators */; return node; } // @api @@ -23383,10 +23504,10 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(166 /* PropertySignature */, modifiers, name); + var node = createBaseNamedDeclaration(166 /* SyntaxKind.PropertySignature */, modifiers, name); node.type = type; node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.initializer = undefined; return node; @@ -23409,18 +23530,18 @@ var ts; } // @api function createPropertyDeclaration(modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(167 /* PropertyDeclaration */, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(167 /* SyntaxKind.PropertyDeclaration */, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 16777216 /* ContainsClassFields */; + 16777216 /* TransformFlags.ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */; } - if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23437,9 +23558,9 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168 /* MethodSignature */, modifiers, name, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(168 /* SyntaxKind.MethodSignature */, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23455,26 +23576,26 @@ var ts; } // @api function createMethodDeclaration(modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(169 /* MethodDeclaration */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(169 /* SyntaxKind.MethodDeclaration */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (questionToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } // The following properties are used only to report grammar errors node.exclamationToken = undefined; @@ -23501,12 +23622,12 @@ var ts; } // @api function createClassStaticBlockDeclaration(body) { - var node = createBaseGenericNamedDeclaration(170 /* ClassStaticBlockDeclaration */, + var node = createBaseGenericNamedDeclaration(170 /* SyntaxKind.ClassStaticBlockDeclaration */, /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined); node.body = body; - node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */; + node.transformFlags = propagateChildFlags(body) | 16777216 /* TransformFlags.ContainsClassFields */; // The following properties are used only to report grammar errors node.decorators = undefined; node.modifiers = undefined; @@ -23527,11 +23648,11 @@ var ts; } // @api function createConstructorDeclaration(modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(171 /* Constructor */, modifiers, + var node = createBaseFunctionLikeDeclaration(171 /* SyntaxKind.Constructor */, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; // The following properties are used only to report grammar errors node.decorators = undefined; node.typeParameters = undefined; @@ -23556,7 +23677,7 @@ var ts; } // @api function createGetAccessorDeclaration(modifiers, name, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(172 /* GetAccessor */, modifiers, name, + var node = createBaseFunctionLikeDeclaration(172 /* SyntaxKind.GetAccessor */, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); // The following properties are used only to report grammar errors node.typeParameters = undefined; @@ -23580,7 +23701,7 @@ var ts; } // @api function createSetAccessorDeclaration(modifiers, name, parameters, body) { - var node = createBaseFunctionLikeDeclaration(173 /* SetAccessor */, modifiers, name, + var node = createBaseFunctionLikeDeclaration(173 /* SyntaxKind.SetAccessor */, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); // The following properties are used only to report grammar errors @@ -23606,10 +23727,10 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* CallSignature */, + var node = createBaseSignatureDeclaration(174 /* SyntaxKind.CallSignature */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23622,10 +23743,10 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(175 /* SyntaxKind.ConstructSignature */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23638,10 +23759,10 @@ var ts; } // @api function createIndexSignature(modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(176 /* IndexSignature */, modifiers, + var node = createBaseSignatureDeclaration(176 /* SyntaxKind.IndexSignature */, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23654,10 +23775,10 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(199 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(199 /* SyntaxKind.TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23676,11 +23797,11 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(177 /* TypePredicate */); + var node = createBaseNode(177 /* SyntaxKind.TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23693,10 +23814,10 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(178 /* TypeReference */); + var node = createBaseNode(178 /* SyntaxKind.TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23708,10 +23829,10 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(179 /* FunctionType */, + var node = createBaseSignatureDeclaration(179 /* SyntaxKind.FunctionType */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.modifiers = undefined; return node; @@ -23741,9 +23862,9 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(180 /* ConstructorType */, modifiers, + var node = createBaseSignatureDeclaration(180 /* SyntaxKind.ConstructorType */, modifiers, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } /** @deprecated */ @@ -23774,10 +23895,10 @@ var ts; } // @api function createTypeQueryNode(exprName, typeArguments) { - var node = createBaseNode(181 /* TypeQuery */); + var node = createBaseNode(181 /* SyntaxKind.TypeQuery */); node.exprName = exprName; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23789,9 +23910,9 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(182 /* TypeLiteral */); + var node = createBaseNode(182 /* SyntaxKind.TypeLiteral */); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23802,9 +23923,9 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(183 /* ArrayType */); + var node = createBaseNode(183 /* SyntaxKind.ArrayType */); node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23815,9 +23936,9 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(184 /* TupleType */); + var node = createBaseNode(184 /* SyntaxKind.TupleType */); node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23828,12 +23949,12 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(197 /* NamedTupleMember */); + var node = createBaseNode(197 /* SyntaxKind.NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23847,9 +23968,9 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(185 /* OptionalType */); + var node = createBaseNode(185 /* SyntaxKind.OptionalType */); node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23860,9 +23981,9 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(186 /* RestType */); + var node = createBaseNode(186 /* SyntaxKind.RestType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23874,7 +23995,7 @@ var ts; function createUnionOrIntersectionTypeNode(kind, types, parenthesize) { var node = createBaseNode(kind); node.types = factory.createNodeArray(parenthesize(types)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateUnionOrIntersectionTypeNode(node, types, parenthesize) { @@ -23884,7 +24005,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); + return createUnionOrIntersectionTypeNode(187 /* SyntaxKind.UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); } // @api function updateUnionTypeNode(node, types) { @@ -23892,7 +24013,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); + return createUnionOrIntersectionTypeNode(188 /* SyntaxKind.IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); } // @api function updateIntersectionTypeNode(node, types) { @@ -23900,12 +24021,12 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(189 /* ConditionalType */); + var node = createBaseNode(189 /* SyntaxKind.ConditionalType */); node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType); node.trueType = trueType; node.falseType = falseType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23919,9 +24040,9 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(190 /* InferType */); + var node = createBaseNode(190 /* SyntaxKind.InferType */); node.typeParameter = typeParameter; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23932,10 +24053,10 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(198 /* TemplateLiteralType */); + var node = createBaseNode(198 /* SyntaxKind.TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23948,13 +24069,13 @@ var ts; // @api function createImportTypeNode(argument, assertions, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(200 /* ImportType */); + var node = createBaseNode(200 /* SyntaxKind.ImportType */); node.argument = argument; node.assertions = assertions; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23970,9 +24091,9 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(191 /* ParenthesizedType */); + var node = createBaseNode(191 /* SyntaxKind.ParenthesizedType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23983,18 +24104,18 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(192 /* ThisType */); - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseNode(192 /* SyntaxKind.ThisType */); + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(193 /* TypeOperator */); + var node = createBaseNode(193 /* SyntaxKind.TypeOperator */); node.operator = operator; - node.type = operator === 145 /* ReadonlyKeyword */ ? + node.type = operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) : parenthesizerRules().parenthesizeOperandOfTypeOperator(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24005,10 +24126,10 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(194 /* IndexedAccessType */); + var node = createBaseNode(194 /* SyntaxKind.IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType); node.indexType = indexType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24020,14 +24141,14 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) { - var node = createBaseNode(195 /* MappedType */); + var node = createBaseNode(195 /* SyntaxKind.MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; node.questionToken = questionToken; node.type = type; node.members = members && createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24043,9 +24164,9 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(196 /* LiteralType */); + var node = createBaseNode(196 /* SyntaxKind.LiteralType */); node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24059,16 +24180,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(201 /* ObjectBindingPattern */); + var node = createBaseNode(201 /* SyntaxKind.ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 524288 /* ContainsBindingPattern */; - if (node.transformFlags & 32768 /* ContainsRestOrSpread */) { + 1024 /* TransformFlags.ContainsES2015 */ | + 524288 /* TransformFlags.ContainsBindingPattern */; + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */) { node.transformFlags |= - 128 /* ContainsES2018 */ | - 65536 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 65536 /* TransformFlags.ContainsObjectRestOrSpread */; } return node; } @@ -24080,12 +24201,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(202 /* ArrayBindingPattern */); + var node = createBaseNode(202 /* SyntaxKind.ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 524288 /* ContainsBindingPattern */; + 1024 /* TransformFlags.ContainsES2015 */ | + 524288 /* TransformFlags.ContainsBindingPattern */; return node; } // @api @@ -24096,20 +24217,20 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(203 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(203 /* SyntaxKind.BindingElement */, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 32768 /* ContainsRestOrSpread */; + node.transformFlags |= 32768 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24131,7 +24252,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(204 /* ArrayLiteralExpression */); + var node = createBaseExpression(204 /* SyntaxKind.ArrayLiteralExpression */); // Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that // we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like // a trailing comma. @@ -24150,7 +24271,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(205 /* ObjectLiteralExpression */); + var node = createBaseExpression(205 /* SyntaxKind.ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -24164,20 +24285,20 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.name = asName(name); node.transformFlags = propagateChildFlags(node.expression) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); if (ts.isSuperKeyword(expression)) { // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24193,23 +24314,23 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 32 /* ContainsES2020 */ | + 32 /* TransformFlags.ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); return node; } // @api function updatePropertyAccessChain(node, expression, questionDotToken, name) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -24220,8 +24341,8 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | @@ -24230,8 +24351,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24247,21 +24368,21 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; return node; } // @api function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); // Because we are updating an existing ElementAccessChain we want to inherit its emitFlags // instead of using the default from createElementAccess return node.expression !== expression @@ -24272,8 +24393,8 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); node.transformFlags |= @@ -24281,13 +24402,13 @@ var ts; propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments); if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 8388608 /* ContainsDynamicImport */; + node.transformFlags |= 8388608 /* TransformFlags.ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 16384 /* ContainsLexicalThis */; + node.transformFlags |= 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24304,9 +24425,9 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -24315,18 +24436,18 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 16384 /* ContainsLexicalThis */; + node.transformFlags |= 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } // @api function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); return node.expression !== expression || node.questionDotToken !== questionDotToken || node.typeArguments !== typeArguments @@ -24336,7 +24457,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(209 /* NewExpression */); + var node = createBaseExpression(209 /* SyntaxKind.NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -24344,9 +24465,9 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24360,20 +24481,20 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(210 /* TaggedTemplateExpression */); - node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); + var node = createBaseExpression(210 /* SyntaxKind.TaggedTemplateExpression */); + node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false); node.typeArguments = asNodeArray(typeArguments); node.template = template; node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24387,13 +24508,13 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(211 /* TypeAssertionExpression */); + var node = createBaseExpression(211 /* SyntaxKind.TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24405,7 +24526,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(212 /* ParenthesizedExpression */); + var node = createBaseExpression(212 /* SyntaxKind.ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -24418,22 +24539,22 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(213 /* FunctionExpression */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(213 /* SyntaxKind.FunctionExpression */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -24451,14 +24572,14 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(214 /* ArrowFunction */, modifiers, + var node = createBaseFunctionLikeDeclaration(214 /* SyntaxKind.ArrowFunction */, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); - node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* SyntaxKind.EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 1024 /* ContainsES2015 */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */; + 1024 /* TransformFlags.ContainsES2015 */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */ | 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24475,7 +24596,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(215 /* DeleteExpression */); + var node = createBaseExpression(215 /* SyntaxKind.DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24488,7 +24609,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(216 /* TypeOfExpression */); + var node = createBaseExpression(216 /* SyntaxKind.TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24501,7 +24622,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(217 /* VoidExpression */); + var node = createBaseExpression(217 /* SyntaxKind.VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24514,13 +24635,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(218 /* AwaitExpression */); + var node = createBaseExpression(218 /* SyntaxKind.AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */ | - 2097152 /* ContainsAwait */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 2097152 /* TransformFlags.ContainsAwait */; return node; } // @api @@ -24531,17 +24652,17 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(219 /* PrefixUnaryExpression */); + var node = createBaseExpression(219 /* SyntaxKind.PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); // Only set this flag for non-generated identifiers and non-"local" names. See the // comment in `visitPreOrPostfixUnaryExpression` in module.ts - if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) && + if ((operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24553,7 +24674,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(220 /* PostfixUnaryExpression */); + var node = createBaseExpression(220 /* SyntaxKind.PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -24562,7 +24683,7 @@ var ts; if (ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24574,7 +24695,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(221 /* BinaryExpression */); + var node = createBaseExpression(221 /* SyntaxKind.BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -24584,46 +24705,49 @@ var ts; propagateChildFlags(node.left) | propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); - if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 32 /* ContainsES2020 */; + if (operatorKind === 60 /* SyntaxKind.QuestionQuestionToken */) { + node.transformFlags |= 32 /* TransformFlags.ContainsES2020 */; } - else if (operatorKind === 63 /* EqualsToken */) { + else if (operatorKind === 63 /* SyntaxKind.EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 512 /* ContainsES2016 */; + else if (operatorKind === 42 /* SyntaxKind.AsteriskAsteriskToken */ || operatorKind === 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 512 /* TransformFlags.ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 16 /* ContainsES2021 */; + node.transformFlags |= 16 /* TransformFlags.ContainsES2021 */; + } + if (operatorKind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { + node.transformFlags |= 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) - return 65536 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 128 /* ContainsES2018 */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) + return 65536 /* TransformFlags.ContainsObjectRestOrSpread */; + if (node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' // will not be correctly interpreted by the ES2018 transformer for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return 65536 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return 65536 /* TransformFlags.ContainsObjectRestOrSpread */; } - if (target.transformFlags & 128 /* ContainsES2018 */) { + if (target.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -24631,7 +24755,7 @@ var ts; } } } - return 0 /* None */; + return 0 /* TransformFlags.None */; } // @api function updateBinaryExpression(node, left, operator, right) { @@ -24643,11 +24767,11 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(222 /* ConditionalExpression */); + var node = createBaseExpression(222 /* SyntaxKind.ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); - node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); + node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* SyntaxKind.QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); - node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* ColonToken */); + node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* SyntaxKind.ColonToken */); node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse); node.transformFlags |= propagateChildFlags(node.condition) | @@ -24669,13 +24793,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(223 /* TemplateExpression */); + var node = createBaseExpression(223 /* SyntaxKind.TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24686,8 +24810,8 @@ var ts; : node; } function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) { - if (templateFlags === void 0) { templateFlags = 0 /* None */; } - ts.Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags."); + if (templateFlags === void 0) { templateFlags = 0 /* TokenFlags.None */; } + ts.Debug.assert(!(templateFlags & ~2048 /* TokenFlags.TemplateLiteralLikeFlags */), "Unsupported template flags."); // NOTE: without the assignment to `undefined`, we don't narrow the initial type of `cooked`. // eslint-disable-next-line no-undef-init var cooked = undefined; @@ -24713,41 +24837,41 @@ var ts; var node = createBaseToken(kind); node.text = text; node.rawText = rawText; - node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 1024 /* ContainsES2015 */; + node.templateFlags = templateFlags & 2048 /* TokenFlags.TemplateLiteralLikeFlags */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } // @api function createTemplateHead(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(15 /* TemplateHead */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(15 /* SyntaxKind.TemplateHead */, text, rawText, templateFlags); } // @api function createTemplateMiddle(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(16 /* TemplateMiddle */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(16 /* SyntaxKind.TemplateMiddle */, text, rawText, templateFlags); } // @api function createTemplateTail(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(17 /* TemplateTail */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(17 /* SyntaxKind.TemplateTail */, text, rawText, templateFlags); } // @api function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(14 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); } // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(224 /* YieldExpression */); + var node = createBaseExpression(224 /* SyntaxKind.YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 1048576 /* ContainsYield */; + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 1048576 /* TransformFlags.ContainsYield */; return node; } // @api @@ -24759,12 +24883,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(225 /* SpreadElement */); + var node = createBaseExpression(225 /* SyntaxKind.SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 32768 /* ContainsRestOrSpread */; + 1024 /* TransformFlags.ContainsES2015 */ | + 32768 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24775,8 +24899,8 @@ var ts; } // @api function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(226 /* ClassExpression */, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(226 /* SyntaxKind.ClassExpression */, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24791,17 +24915,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(227 /* OmittedExpression */); + return createBaseExpression(227 /* SyntaxKind.OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(228 /* ExpressionWithTypeArguments */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseNode(228 /* SyntaxKind.ExpressionWithTypeArguments */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24813,13 +24937,13 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(229 /* AsExpression */); + var node = createBaseExpression(229 /* SyntaxKind.AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24831,11 +24955,11 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24849,33 +24973,33 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function updateNonNullChain(node, expression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); return node.expression !== expression ? update(createNonNullChain(expression), node) : node; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(231 /* MetaProperty */); + var node = createBaseExpression(231 /* SyntaxKind.MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 103 /* NewKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 103 /* SyntaxKind.NewKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 100 /* ImportKeyword */: - node.transformFlags |= 4 /* ContainsESNext */; + case 100 /* SyntaxKind.ImportKeyword */: + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; break; default: return ts.Debug.assertNever(keywordToken); @@ -24893,13 +25017,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(233 /* TemplateSpan */); + var node = createBaseNode(233 /* SyntaxKind.TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24911,8 +25035,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(234 /* SemicolonClassElement */); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseNode(234 /* SyntaxKind.SemicolonClassElement */); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @@ -24920,7 +25044,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(235 /* Block */); + var node = createBaseNode(235 /* SyntaxKind.Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -24934,14 +25058,14 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(237 /* VariableStatement */); + var node = createBaseDeclaration(237 /* SyntaxKind.VariableStatement */); node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.declarationList); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24954,11 +25078,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(236 /* EmptyStatement */); + return createBaseNode(236 /* SyntaxKind.EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(238 /* ExpressionStatement */); + var node = createBaseNode(238 /* SyntaxKind.ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24971,7 +25095,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(239 /* IfStatement */); + var node = createBaseNode(239 /* SyntaxKind.IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -24991,7 +25115,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(240 /* DoStatement */); + var node = createBaseNode(240 /* SyntaxKind.DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -25008,7 +25132,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(241 /* WhileStatement */); + var node = createBaseNode(241 /* SyntaxKind.WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -25025,7 +25149,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(242 /* ForStatement */); + var node = createBaseNode(242 /* SyntaxKind.ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -25048,7 +25172,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(243 /* ForInStatement */); + var node = createBaseNode(243 /* SyntaxKind.ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -25068,7 +25192,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(244 /* ForOfStatement */); + var node = createBaseNode(244 /* SyntaxKind.ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -25078,9 +25202,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; return node; } // @api @@ -25094,11 +25218,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(245 /* ContinueStatement */); + var node = createBaseNode(245 /* SyntaxKind.ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -25109,11 +25233,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(246 /* BreakStatement */); + var node = createBaseNode(246 /* SyntaxKind.BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -25124,13 +25248,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(247 /* ReturnStatement */); + var node = createBaseNode(247 /* SyntaxKind.ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 128 /* TransformFlags.ContainsES2018 */ | + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -25141,7 +25265,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(248 /* WithStatement */); + var node = createBaseNode(248 /* SyntaxKind.WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -25158,7 +25282,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(249 /* SwitchStatement */); + var node = createBaseNode(249 /* SyntaxKind.SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -25175,7 +25299,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(250 /* LabeledStatement */); + var node = createBaseNode(250 /* SyntaxKind.LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -25192,7 +25316,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(251 /* ThrowStatement */); + var node = createBaseNode(251 /* SyntaxKind.ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -25205,7 +25329,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(252 /* TryStatement */); + var node = createBaseNode(252 /* SyntaxKind.TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -25225,16 +25349,16 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(253 /* DebuggerStatement */); + return createBaseNode(253 /* SyntaxKind.DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(254 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(254 /* SyntaxKind.VariableDeclaration */, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25249,17 +25373,17 @@ var ts; } // @api function createVariableDeclarationList(declarations, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(255 /* VariableDeclarationList */); - node.flags |= flags & 3 /* BlockScoped */; + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseNode(255 /* SyntaxKind.VariableDeclarationList */); + node.flags |= flags & 3 /* NodeFlags.BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; - if (flags & 3 /* BlockScoped */) { + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (flags & 3 /* NodeFlags.BlockScoped */) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBlockScopedBinding */; + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBlockScopedBinding */; } return node; } @@ -25271,25 +25395,25 @@ var ts; } // @api function createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(256 /* FunctionDeclaration */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(256 /* SyntaxKind.FunctionDeclaration */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; - if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } } // The following properties are used only to report grammar errors @@ -25317,14 +25441,14 @@ var ts; } // @api function createClassDeclaration(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(257 /* ClassDeclaration */, modifiers, name, typeParameters, heritageClauses, members); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseClassLikeDeclaration(257 /* SyntaxKind.ClassDeclaration */, modifiers, name, typeParameters, heritageClauses, members); + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { - node.transformFlags |= 1024 /* ContainsES2015 */; - if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; + if (node.transformFlags & 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } } return node; @@ -25341,9 +25465,9 @@ var ts; } // @api function createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(258 /* InterfaceDeclaration */, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(258 /* SyntaxKind.InterfaceDeclaration */, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25366,9 +25490,9 @@ var ts; } // @api function createTypeAliasDeclaration(modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(259 /* TypeAliasDeclaration */, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(259 /* SyntaxKind.TypeAliasDeclaration */, modifiers, name, typeParameters); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25390,12 +25514,12 @@ var ts; } // @api function createEnumDeclaration(modifiers, name, members) { - var node = createBaseNamedDeclaration(260 /* EnumDeclaration */, modifiers, name); + var node = createBaseNamedDeclaration(260 /* SyntaxKind.EnumDeclaration */, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25416,23 +25540,23 @@ var ts; } // @api function createModuleDeclaration(modifiers, name, body, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(261 /* ModuleDeclaration */); + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseDeclaration(261 /* SyntaxKind.ModuleDeclaration */); node.modifiers = asNodeArray(modifiers); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); + node.flags |= flags & (16 /* NodeFlags.Namespace */ | 4 /* NodeFlags.NestedNamespace */ | 1024 /* NodeFlags.GlobalAugmentation */); node.name = name; node.body = body; - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25453,7 +25577,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(262 /* ModuleBlock */); + var node = createBaseNode(262 /* SyntaxKind.ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -25466,7 +25590,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(263 /* CaseBlock */); + var node = createBaseNode(263 /* SyntaxKind.CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -25479,9 +25603,9 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(264 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(264 /* SyntaxKind.NamespaceExportDeclaration */, /*modifiers*/ undefined, name); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; node.modifiers = undefined; @@ -25502,13 +25626,13 @@ var ts; } // @api function createImportEqualsDeclaration(modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(265 /* ImportEqualsDeclaration */, modifiers, name); + var node = createBaseNamedDeclaration(265 /* SyntaxKind.ImportEqualsDeclaration */, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) - node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25530,7 +25654,7 @@ var ts; } // @api function createImportDeclaration(modifiers, importClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(266 /* ImportDeclaration */); + var node = createBaseDeclaration(266 /* SyntaxKind.ImportDeclaration */); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; @@ -25538,7 +25662,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25560,7 +25684,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(267 /* ImportClause */); + var node = createBaseNode(267 /* SyntaxKind.ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -25568,9 +25692,9 @@ var ts; propagateChildFlags(node.name) | propagateChildFlags(node.namedBindings); if (isTypeOnly) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25583,10 +25707,10 @@ var ts; } // @api function createAssertClause(elements, multiLine) { - var node = createBaseNode(293 /* AssertClause */); + var node = createBaseNode(293 /* SyntaxKind.AssertClause */); node.elements = createNodeArray(elements); node.multiLine = multiLine; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25598,10 +25722,10 @@ var ts; } // @api function createAssertEntry(name, value) { - var node = createBaseNode(294 /* AssertEntry */); + var node = createBaseNode(294 /* SyntaxKind.AssertEntry */); node.name = name; node.value = value; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25613,7 +25737,7 @@ var ts; } // @api function createImportTypeAssertionContainer(clause, multiLine) { - var node = createBaseNode(295 /* ImportTypeAssertionContainer */); + var node = createBaseNode(295 /* SyntaxKind.ImportTypeAssertionContainer */); node.assertClause = clause; node.multiLine = multiLine; return node; @@ -25627,10 +25751,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(268 /* NamespaceImport */); + var node = createBaseNode(268 /* SyntaxKind.NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25641,12 +25765,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(274 /* NamespaceExport */); + var node = createBaseNode(274 /* SyntaxKind.NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | - 4 /* ContainsESNext */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + 4 /* TransformFlags.ContainsESNext */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25657,10 +25781,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(269 /* NamedImports */); + var node = createBaseNode(269 /* SyntaxKind.NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25671,14 +25795,14 @@ var ts; } // @api function createImportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(270 /* ImportSpecifier */); + var node = createBaseNode(270 /* SyntaxKind.ImportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25691,14 +25815,14 @@ var ts; } // @api function createExportAssignment(modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(271 /* ExportAssignment */); + var node = createBaseDeclaration(271 /* SyntaxKind.ExportAssignment */); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* SyntaxKind.EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.expression); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25718,7 +25842,7 @@ var ts; } // @api function createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(272 /* ExportDeclaration */); + var node = createBaseDeclaration(272 /* SyntaxKind.ExportDeclaration */); node.modifiers = asNodeArray(modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; @@ -25728,7 +25852,7 @@ var ts; propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25751,10 +25875,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(273 /* NamedExports */); + var node = createBaseNode(273 /* SyntaxKind.NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25765,14 +25889,14 @@ var ts; } // @api function createExportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(275 /* ExportSpecifier */); + var node = createBaseNode(275 /* SyntaxKind.ExportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25785,7 +25909,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(276 /* MissingDeclaration */); + var node = createBaseDeclaration(276 /* SyntaxKind.MissingDeclaration */); return node; } // @@ -25793,10 +25917,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(277 /* ExternalModuleReference */); + var node = createBaseNode(277 /* SyntaxKind.ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25851,7 +25975,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(317 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(317 /* SyntaxKind.JSDocFunctionType */, /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); @@ -25867,7 +25991,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(322 /* JSDocTypeLiteral */); + var node = createBaseNode(322 /* SyntaxKind.JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -25881,7 +26005,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(309 /* JSDocTypeExpression */); + var node = createBaseNode(309 /* SyntaxKind.JSDocTypeExpression */); node.type = type; return node; } @@ -25893,7 +26017,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(323 /* JSDocSignature */); + var node = createBaseNode(323 /* SyntaxKind.JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -25922,7 +26046,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(344 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(344 /* SyntaxKind.JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -25939,7 +26063,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(345 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(345 /* SyntaxKind.JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25957,7 +26081,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(340 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(340 /* SyntaxKind.JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25978,7 +26102,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(347 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(347 /* SyntaxKind.JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25999,7 +26123,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(338 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(338 /* SyntaxKind.JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -26017,7 +26141,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(328 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(328 /* SyntaxKind.JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -26032,13 +26156,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(329 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(329 /* SyntaxKind.JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(346 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(346 /* SyntaxKind.JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -26052,7 +26176,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(310 /* JSDocNameReference */); + var node = createBaseNode(310 /* SyntaxKind.JSDocNameReference */); node.name = name; return node; } @@ -26064,7 +26188,7 @@ var ts; } // @api function createJSDocMemberName(left, right) { - var node = createBaseNode(311 /* JSDocMemberName */); + var node = createBaseNode(311 /* SyntaxKind.JSDocMemberName */); node.left = left; node.right = right; node.transformFlags |= @@ -26081,7 +26205,7 @@ var ts; } // @api function createJSDocLink(name, text) { - var node = createBaseNode(324 /* JSDocLink */); + var node = createBaseNode(324 /* SyntaxKind.JSDocLink */); node.name = name; node.text = text; return node; @@ -26094,7 +26218,7 @@ var ts; } // @api function createJSDocLinkCode(name, text) { - var node = createBaseNode(325 /* JSDocLinkCode */); + var node = createBaseNode(325 /* SyntaxKind.JSDocLinkCode */); node.name = name; node.text = text; return node; @@ -26107,7 +26231,7 @@ var ts; } // @api function createJSDocLinkPlain(name, text) { - var node = createBaseNode(326 /* JSDocLinkPlain */); + var node = createBaseNode(326 /* SyntaxKind.JSDocLinkPlain */); node.name = name; node.text = text; return node; @@ -26179,7 +26303,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(327 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(327 /* SyntaxKind.JSDocTag */, tagName, comment); return node; } // @api @@ -26191,7 +26315,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(321 /* JSDocText */); + var node = createBaseNode(321 /* SyntaxKind.JSDocText */); node.text = text; return node; } @@ -26203,7 +26327,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(320 /* JSDoc */); + var node = createBaseNode(320 /* SyntaxKind.JSDoc */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -26220,7 +26344,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(278 /* JsxElement */); + var node = createBaseNode(278 /* SyntaxKind.JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -26228,7 +26352,7 @@ var ts; propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26241,7 +26365,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(279 /* JsxSelfClosingElement */); + var node = createBaseNode(279 /* SyntaxKind.JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -26249,9 +26373,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -26265,7 +26389,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(280 /* JsxOpeningElement */); + var node = createBaseNode(280 /* SyntaxKind.JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -26273,9 +26397,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -26289,11 +26413,11 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(281 /* JsxClosingElement */); + var node = createBaseNode(281 /* SyntaxKind.JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26304,7 +26428,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(282 /* JsxFragment */); + var node = createBaseNode(282 /* SyntaxKind.JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -26312,7 +26436,7 @@ var ts; propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26325,10 +26449,10 @@ var ts; } // @api function createJsxText(text, containsOnlyTriviaWhiteSpaces) { - var node = createBaseNode(11 /* JsxText */); + var node = createBaseNode(11 /* SyntaxKind.JsxText */); node.text = text; node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces; - node.transformFlags |= 2 /* ContainsJsx */; + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26340,25 +26464,25 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(283 /* JsxOpeningFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(283 /* SyntaxKind.JsxOpeningFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(284 /* JsxClosingFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(284 /* SyntaxKind.JsxClosingFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(285 /* JsxAttribute */); + var node = createBaseNode(285 /* SyntaxKind.JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26370,11 +26494,11 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(286 /* JsxAttributes */); + var node = createBaseNode(286 /* SyntaxKind.JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26385,11 +26509,11 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(287 /* JsxSpreadAttribute */); + var node = createBaseNode(287 /* SyntaxKind.JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26400,13 +26524,13 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(288 /* JsxExpression */); + var node = createBaseNode(288 /* SyntaxKind.JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26420,7 +26544,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(289 /* CaseClause */); + var node = createBaseNode(289 /* SyntaxKind.CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -26437,7 +26561,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(290 /* DefaultClause */); + var node = createBaseNode(290 /* SyntaxKind.DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -26450,16 +26574,16 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(291 /* HeritageClause */); + var node = createBaseNode(291 /* SyntaxKind.HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 94 /* ExtendsKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 94 /* SyntaxKind.ExtendsKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 117 /* ImplementsKeyword */: - node.transformFlags |= 1 /* ContainsTypeScript */; + case 117 /* SyntaxKind.ImplementsKeyword */: + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; break; default: return ts.Debug.assertNever(token); @@ -26474,7 +26598,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(292 /* CatchClause */); + var node = createBaseNode(292 /* SyntaxKind.CatchClause */); if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) { variableDeclaration = createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, @@ -26487,7 +26611,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 64 /* ContainsES2019 */; + node.transformFlags |= 64 /* TransformFlags.ContainsES2019 */; return node; } // @api @@ -26502,7 +26626,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(296 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(296 /* SyntaxKind.PropertyAssignment */, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -26534,12 +26658,12 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(297 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(297 /* SyntaxKind.ShorthandPropertyAssignment */, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; // The following properties are used only to report grammar errors node.equalsToken = undefined; node.decorators = undefined; @@ -26568,12 +26692,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(298 /* SpreadAssignment */); + var node = createBaseNode(298 /* SyntaxKind.SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 65536 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 65536 /* TransformFlags.ContainsObjectRestOrSpread */; return node; } // @api @@ -26587,13 +26711,13 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(299 /* EnumMember */); + var node = createBaseNode(299 /* SyntaxKind.EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -26608,7 +26732,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -26625,7 +26749,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SourceFile */)); + var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */)); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -26664,7 +26788,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(306 /* Bundle */); + var node = createBaseNode(306 /* SyntaxKind.Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -26679,7 +26803,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(307 /* UnparsedSource */); + var node = createBaseNode(307 /* SyntaxKind.UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -26697,28 +26821,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(300 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(300 /* SyntaxKind.UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(301 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(301 /* SyntaxKind.UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 303 /* UnparsedInternalText */ : 302 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 303 /* SyntaxKind.UnparsedInternalText */ : 302 /* SyntaxKind.UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(304 /* UnparsedSyntheticReference */); + var node = createBaseNode(304 /* SyntaxKind.UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(308 /* InputFiles */); + var node = createBaseNode(308 /* SyntaxKind.InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -26729,7 +26853,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(232 /* SyntheticExpression */); + var node = createBaseNode(232 /* SyntaxKind.SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -26737,7 +26861,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(348 /* SyntaxList */); + var node = createBaseNode(348 /* SyntaxKind.SyntaxList */); node._children = children; return node; } @@ -26752,7 +26876,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(349 /* NotEmittedStatement */); + var node = createBaseNode(349 /* SyntaxKind.NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -26766,12 +26890,12 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(350 /* PartiallyEmittedExpression */); + var node = createBaseNode(350 /* SyntaxKind.PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -26794,7 +26918,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(351 /* CommaListExpression */); + var node = createBaseNode(351 /* SyntaxKind.CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -26811,7 +26935,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(353 /* EndOfDeclarationMarker */); + var node = createBaseNode(353 /* SyntaxKind.EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -26822,14 +26946,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(352 /* MergeDeclarationMarker */); + var node = createBaseNode(352 /* SyntaxKind.MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(354 /* SyntheticReferenceExpression */); + var node = createBaseNode(354 /* SyntaxKind.SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -26851,12 +26975,12 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); - clone.flags |= (node.flags & ~8 /* Synthesized */); + clone.flags |= (node.flags & ~8 /* NodeFlags.Synthesized */); clone.transformFlags = node.transformFlags; setOriginalNode(clone, node); for (var key in node) { @@ -26968,11 +27092,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 212 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 211 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 229 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 230 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 350 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 212 /* SyntaxKind.ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 211 /* SyntaxKind.TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 229 /* SyntaxKind.AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 230 /* SyntaxKind.NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -26998,7 +27122,7 @@ var ts; && !ts.some(ts.getSyntheticTrailingComments(node)); } function restoreOuterExpressions(outerExpression, innerExpression, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression)); } @@ -27019,20 +27143,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cacheIdentifiers; - case 108 /* ThisKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return false; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -27040,7 +27164,7 @@ var ts; } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } - var callee = ts.skipOuterExpressions(expression, 15 /* All */); + var callee = ts.skipOuterExpressions(expression, 15 /* OuterExpressionKinds.All */); var thisArg; var target; if (ts.isSuperProperty(callee)) { @@ -27049,13 +27173,13 @@ var ts; } else if (ts.isSuperKeyword(callee)) { thisArg = createThis(); - target = languageVersion !== undefined && languageVersion < 2 /* ES2015 */ + target = languageVersion !== undefined && languageVersion < 2 /* ScriptTarget.ES2015 */ ? ts.setTextRange(createIdentifier("_super"), callee) : callee; } - else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + else if (ts.getEmitFlags(callee) & 4096 /* EmitFlags.HelperName */) { thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false); } else if (ts.isPropertyAccessExpression(callee)) { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { @@ -27084,7 +27208,7 @@ var ts; else { // for `a()` target is `a` and thisArg is `void 0` thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); } return { target: target, thisArg: thisArg }; } @@ -27118,9 +27242,9 @@ var ts; var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent); emitFlags |= ts.getEmitFlags(nodeName); if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(name, emitFlags); return name; @@ -27139,7 +27263,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getInternalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */ | 32768 /* EmitFlags.InternalName */); } /** * Gets the local name of a declaration. This is primarily used for declarations that can be @@ -27152,7 +27276,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */); } /** * Gets the export name of a declaration. This is primarily used for declarations that can be @@ -27165,7 +27289,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192 /* ExportName */); + return getName(node, allowComments, allowSourceMaps, 8192 /* EmitFlags.ExportName */); } /** * Gets the name of a declaration for use in declarations. @@ -27190,9 +27314,9 @@ var ts; ts.setTextRange(qualifiedName, name); var emitFlags = 0; if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; @@ -27209,7 +27333,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -27267,7 +27391,7 @@ var ts; var numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) { + if (ts.getEmitFlags(statement) & 1048576 /* EmitFlags.CustomPrologue */ && filter(statement)) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -27458,52 +27582,52 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 343 /* JSDocTypeTag */: return "type"; - case 341 /* JSDocReturnTag */: return "returns"; - case 342 /* JSDocThisTag */: return "this"; - case 339 /* JSDocEnumTag */: return "enum"; - case 330 /* JSDocAuthorTag */: return "author"; - case 332 /* JSDocClassTag */: return "class"; - case 333 /* JSDocPublicTag */: return "public"; - case 334 /* JSDocPrivateTag */: return "private"; - case 335 /* JSDocProtectedTag */: return "protected"; - case 336 /* JSDocReadonlyTag */: return "readonly"; - case 337 /* JSDocOverrideTag */: return "override"; - case 344 /* JSDocTemplateTag */: return "template"; - case 345 /* JSDocTypedefTag */: return "typedef"; - case 340 /* JSDocParameterTag */: return "param"; - case 347 /* JSDocPropertyTag */: return "prop"; - case 338 /* JSDocCallbackTag */: return "callback"; - case 328 /* JSDocAugmentsTag */: return "augments"; - case 329 /* JSDocImplementsTag */: return "implements"; + case 343 /* SyntaxKind.JSDocTypeTag */: return "type"; + case 341 /* SyntaxKind.JSDocReturnTag */: return "returns"; + case 342 /* SyntaxKind.JSDocThisTag */: return "this"; + case 339 /* SyntaxKind.JSDocEnumTag */: return "enum"; + case 330 /* SyntaxKind.JSDocAuthorTag */: return "author"; + case 332 /* SyntaxKind.JSDocClassTag */: return "class"; + case 333 /* SyntaxKind.JSDocPublicTag */: return "public"; + case 334 /* SyntaxKind.JSDocPrivateTag */: return "private"; + case 335 /* SyntaxKind.JSDocProtectedTag */: return "protected"; + case 336 /* SyntaxKind.JSDocReadonlyTag */: return "readonly"; + case 337 /* SyntaxKind.JSDocOverrideTag */: return "override"; + case 344 /* SyntaxKind.JSDocTemplateTag */: return "template"; + case 345 /* SyntaxKind.JSDocTypedefTag */: return "typedef"; + case 340 /* SyntaxKind.JSDocParameterTag */: return "param"; + case 347 /* SyntaxKind.JSDocPropertyTag */: return "prop"; + case 338 /* SyntaxKind.JSDocCallbackTag */: return "callback"; + case 328 /* SyntaxKind.JSDocAugmentsTag */: return "augments"; + case 329 /* SyntaxKind.JSDocImplementsTag */: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; var invalidValueSentinel = {}; function getCookedText(kind, rawText) { if (!rawTextScanner) { - rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + rawTextScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); } switch (kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: rawTextScanner.setText("`" + rawText + "`"); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: rawTextScanner.setText("}" + rawText + "`"); break; } var token = rawTextScanner.scan(); - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false); } if (rawTextScanner.isUnterminated()) { @@ -27512,14 +27636,14 @@ var ts; } var tokenValue; switch (token) { - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: tokenValue = rawTextScanner.getTokenValue(); break; } - if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* SyntaxKind.EndOfFileToken */) { rawTextScanner.setText(undefined); return invalidValueSentinel; } @@ -27528,22 +27652,22 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 134234112 /* TransformFlags.PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) - return 0 /* None */; + return 0 /* TransformFlags.None */; var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind); return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags; } function propagateChildrenFlags(children) { - return children ? children.transformFlags : 0 /* None */; + return children ? children.transformFlags : 0 /* TransformFlags.None */; } function aggregateChildrenFlags(children) { - var subtreeFlags = 0 /* None */; + var subtreeFlags = 0 /* TransformFlags.None */; for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { var child = children_2[_i]; subtreeFlags |= propagateChildFlags(child); @@ -27555,78 +27679,78 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) { - return -2 /* TypeExcludes */; + if (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) { + return -2 /* TransformFlags.TypeExcludes */; } switch (kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 204 /* ArrayLiteralExpression */: - return 536903680 /* ArrayLiteralOrCallOrNewExcludes */; - case 261 /* ModuleDeclaration */: - return 742678528 /* ModuleExcludes */; - case 164 /* Parameter */: - return 536870912 /* ParameterExcludes */; - case 214 /* ArrowFunction */: - return 612179968 /* ArrowFunctionExcludes */; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - return 746414080 /* FunctionExcludes */; - case 255 /* VariableDeclarationList */: - return 537460736 /* VariableDeclarationListExcludes */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return 537010176 /* ClassExcludes */; - case 171 /* Constructor */: - return 746405888 /* ConstructorExcludes */; - case 167 /* PropertyDeclaration */: - return 671105024 /* PropertyExcludes */; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return 679297024 /* MethodOrAccessorExcludes */; - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 150 /* StringKeyword */: - case 148 /* ObjectKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 163 /* TypeParameter */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return -2 /* TypeExcludes */; - case 205 /* ObjectLiteralExpression */: - return 537075712 /* ObjectLiteralExcludes */; - case 292 /* CatchClause */: - return 536936448 /* CatchClauseExcludes */; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - return 536903680 /* BindingPatternExcludes */; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - case 350 /* PartiallyEmittedExpression */: - case 212 /* ParenthesizedExpression */: - case 106 /* SuperKeyword */: - return 536870912 /* OuterExpressionExcludes */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - return 536870912 /* PropertyAccessExcludes */; + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return -2147450880 /* TransformFlags.ArrayLiteralOrCallOrNewExcludes */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return -1941676032 /* TransformFlags.ModuleExcludes */; + case 164 /* SyntaxKind.Parameter */: + return -2147483648 /* TransformFlags.ParameterExcludes */; + case 214 /* SyntaxKind.ArrowFunction */: + return -2072174592 /* TransformFlags.ArrowFunctionExcludes */; + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return -1937940480 /* TransformFlags.FunctionExcludes */; + case 255 /* SyntaxKind.VariableDeclarationList */: + return -2146893824 /* TransformFlags.VariableDeclarationListExcludes */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return -2147344384 /* TransformFlags.ClassExcludes */; + case 171 /* SyntaxKind.Constructor */: + return -1937948672 /* TransformFlags.ConstructorExcludes */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return -2013249536 /* TransformFlags.PropertyExcludes */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return -2005057536 /* TransformFlags.MethodOrAccessorExcludes */; + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 163 /* SyntaxKind.TypeParameter */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return -2 /* TransformFlags.TypeExcludes */; + case 205 /* SyntaxKind.ObjectLiteralExpression */: + return -2147278848 /* TransformFlags.ObjectLiteralExcludes */; + case 292 /* SyntaxKind.CatchClause */: + return -2147418112 /* TransformFlags.CatchClauseExcludes */; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return -2147450880 /* TransformFlags.BindingPatternExcludes */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 106 /* SyntaxKind.SuperKeyword */: + return -2147483648 /* TransformFlags.OuterExpressionExcludes */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + return -2147483648 /* TransformFlags.PropertyAccessExcludes */; default: - return 536870912 /* NodeExcludes */; + return -2147483648 /* TransformFlags.NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; var baseFactory = ts.createBaseNodeFactory(); function makeSynthetic(node) { - node.flags |= 8 /* Synthesized */; + node.flags |= 8 /* NodeFlags.Synthesized */; return node; } var syntheticFactory = { @@ -27636,7 +27760,7 @@ var ts; createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); }, createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); }, }; - ts.factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory); + ts.factory = createNodeFactory(4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */, syntheticFactory); function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { var stripInternal; var bundleFileInfo; @@ -27699,50 +27823,50 @@ var ts; for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "prologue" /* Prologue */: + case "prologue" /* BundleFileSectionKind.Prologue */: prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section)); break; - case "emitHelpers" /* EmitHelpers */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data)); break; - case "no-default-lib" /* NoDefaultLib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: hasNoDefaultLib = true; break; - case "reference" /* Reference */: + case "reference" /* BundleFileSectionKind.Reference */: referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data }); break; - case "type" /* Type */: + case "type" /* BundleFileSectionKind.Type */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "type-import" /* TypeResolutionModeImport */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext }); break; - case "type-require" /* TypeResolutionModeRequire */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS }); break; - case "lib" /* Lib */: + case "lib" /* BundleFileSectionKind.Lib */: libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "prepend" /* Prepend */: + case "prepend" /* BundleFileSectionKind.Prepend */: var prependTexts = void 0; for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { var text = _c[_b]; - if (!stripInternal || text.kind !== "internal" /* Internal */) { - prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* Internal */), text)); + if (!stripInternal || text.kind !== "internal" /* BundleFileSectionKind.Internal */) { + prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* BundleFileSectionKind.Internal */), text)); } } prependChildren = ts.addRange(prependChildren, prependTexts); texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray)); break; - case "internal" /* Internal */: + case "internal" /* BundleFileSectionKind.Internal */: if (stripInternal) { if (!texts) texts = []; break; } // falls through - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; default: ts.Debug.assertNever(section); @@ -27770,22 +27894,22 @@ var ts; for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "internal" /* Internal */: - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "internal" /* BundleFileSectionKind.Internal */: + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; - case "no-default-lib" /* NoDefaultLib */: - case "reference" /* Reference */: - case "type" /* Type */: - case "type-import" /* TypeResolutionModeImport */: - case "type-require" /* TypeResolutionModeRequire */: - case "lib" /* Lib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: + case "reference" /* BundleFileSectionKind.Reference */: + case "type" /* BundleFileSectionKind.Type */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: + case "lib" /* BundleFileSectionKind.Lib */: syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section)); break; // Ignore - case "prologue" /* Prologue */: - case "emitHelpers" /* EmitHelpers */: - case "prepend" /* Prepend */: + case "prologue" /* BundleFileSectionKind.Prologue */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: + case "prepend" /* BundleFileSectionKind.Prepend */: break; default: ts.Debug.assertNever(section); @@ -27813,7 +27937,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -27882,7 +28006,7 @@ var ts; if (trailingComments) destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) - destEmitNode.flags = flags & ~268435456 /* Immutable */; + destEmitNode.flags = flags & ~268435456 /* EmitFlags.Immutable */; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) @@ -27924,7 +28048,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -27933,7 +28057,7 @@ var ts; node.emitNode = {}; } else { - ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node."); + ts.Debug.assert(!(node.emitNode.flags & 268435456 /* EmitFlags.Immutable */), "Invalid attempt to mutate an immutable node."); } return node.emitNode; } @@ -27965,7 +28089,7 @@ var ts; */ function removeAllComments(node) { var emitNode = getOrCreateEmitNode(node); - emitNode.flags |= 1536 /* NoComments */; + emitNode.flags |= 1536 /* EmitFlags.NoComments */; emitNode.leadingComments = undefined; emitNode.trailingComments = undefined; return node; @@ -28201,7 +28325,7 @@ var ts; ts.setSnippetElement = setSnippetElement; /* @internal */ function ignoreSourceNewlines(node) { - getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; + getOrCreateEmitNode(node).flags |= 134217728 /* EmitFlags.IgnoreSourceNewlines */; return node; } ts.ignoreSourceNewlines = ignoreSourceNewlines; @@ -28224,8 +28348,8 @@ var ts; (function (ts) { function createEmitHelperFactory(context) { var factory = context.factory; - var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); }); - var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); }); + var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* EmitFlags.Immutable */); }); + var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* EmitFlags.Immutable */); }); return { getUnscopedHelperName: getUnscopedHelperName, // TypeScript Helpers @@ -28266,7 +28390,7 @@ var ts; * Gets an identifier for the name of an *unscoped* emit helper. */ function getUnscopedHelperName(name) { - return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* EmitFlags.HelperName */ | 2 /* EmitFlags.AdviseOnEmitNode */); } // TypeScript Helpers function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) { @@ -28301,7 +28425,7 @@ var ts; } // ES2018 Helpers function createAssignHelper(attributesSegments) { - if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } @@ -28317,7 +28441,7 @@ var ts; context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28371,13 +28495,13 @@ var ts; function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28390,7 +28514,7 @@ var ts; function createExtendsHelper(name) { context.requestEmitHelper(ts.extendsHelper); return factory.createCallExpression(getUnscopedHelperName("__extends"), - /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]); + /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)]); } function createTemplateObjectHelper(cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); @@ -28480,13 +28604,13 @@ var ts; /* @internal */ function compareEmitHelpers(x, y) { if (x === y) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === y.priority) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; if (y.priority === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; @@ -28893,7 +29017,7 @@ var ts; function isCallToHelper(firstSegment, helperName) { return ts.isCallExpression(firstSegment) && ts.isIdentifier(firstSegment.expression) - && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0 + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* EmitFlags.HelperName */) !== 0 && firstSegment.expression.escapedText === helperName; } ts.isCallToHelper = isCallToHelper; @@ -28902,750 +29026,750 @@ var ts; (function (ts) { // Literals function isNumericLiteral(node) { - return node.kind === 8 /* NumericLiteral */; + return node.kind === 8 /* SyntaxKind.NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; function isBigIntLiteral(node) { - return node.kind === 9 /* BigIntLiteral */; + return node.kind === 9 /* SyntaxKind.BigIntLiteral */; } ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 10 /* StringLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 11 /* JsxText */; + return node.kind === 11 /* SyntaxKind.JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 13 /* RegularExpressionLiteral */; + return node.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 15 /* TemplateHead */; + return node.kind === 15 /* SyntaxKind.TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 16 /* TemplateMiddle */; + return node.kind === 16 /* SyntaxKind.TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 17 /* TemplateTail */; + return node.kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateTail = isTemplateTail; // Punctuation function isDotDotDotToken(node) { - return node.kind === 25 /* DotDotDotToken */; + return node.kind === 25 /* SyntaxKind.DotDotDotToken */; } ts.isDotDotDotToken = isDotDotDotToken; /*@internal*/ function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; + return node.kind === 27 /* SyntaxKind.CommaToken */; } ts.isCommaToken = isCommaToken; function isPlusToken(node) { - return node.kind === 39 /* PlusToken */; + return node.kind === 39 /* SyntaxKind.PlusToken */; } ts.isPlusToken = isPlusToken; function isMinusToken(node) { - return node.kind === 40 /* MinusToken */; + return node.kind === 40 /* SyntaxKind.MinusToken */; } ts.isMinusToken = isMinusToken; function isAsteriskToken(node) { - return node.kind === 41 /* AsteriskToken */; + return node.kind === 41 /* SyntaxKind.AsteriskToken */; } ts.isAsteriskToken = isAsteriskToken; /*@internal*/ function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + return node.kind === 53 /* SyntaxKind.ExclamationToken */; } ts.isExclamationToken = isExclamationToken; /*@internal*/ function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + return node.kind === 57 /* SyntaxKind.QuestionToken */; } ts.isQuestionToken = isQuestionToken; /*@internal*/ function isColonToken(node) { - return node.kind === 58 /* ColonToken */; + return node.kind === 58 /* SyntaxKind.ColonToken */; } ts.isColonToken = isColonToken; /*@internal*/ function isQuestionDotToken(node) { - return node.kind === 28 /* QuestionDotToken */; + return node.kind === 28 /* SyntaxKind.QuestionDotToken */; } ts.isQuestionDotToken = isQuestionDotToken; /*@internal*/ function isEqualsGreaterThanToken(node) { - return node.kind === 38 /* EqualsGreaterThanToken */; + return node.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */; } ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 79 /* Identifier */; + return node.kind === 79 /* SyntaxKind.Identifier */; } ts.isIdentifier = isIdentifier; function isPrivateIdentifier(node) { - return node.kind === 80 /* PrivateIdentifier */; + return node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; // Reserved Words /* @internal */ function isExportModifier(node) { - return node.kind === 93 /* ExportKeyword */; + return node.kind === 93 /* SyntaxKind.ExportKeyword */; } ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 131 /* AsyncKeyword */; + return node.kind === 131 /* SyntaxKind.AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ function isAssertsKeyword(node) { - return node.kind === 128 /* AssertsKeyword */; + return node.kind === 128 /* SyntaxKind.AssertsKeyword */; } ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 132 /* AwaitKeyword */; + return node.kind === 132 /* SyntaxKind.AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 145 /* ReadonlyKeyword */; + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ function isStaticModifier(node) { - return node.kind === 124 /* StaticKeyword */; + return node.kind === 124 /* SyntaxKind.StaticKeyword */; } ts.isStaticModifier = isStaticModifier; /* @internal */ function isAbstractModifier(node) { - return node.kind === 126 /* AbstractKeyword */; + return node.kind === 126 /* SyntaxKind.AbstractKeyword */; } ts.isAbstractModifier = isAbstractModifier; /* @internal */ function isOverrideModifier(node) { - return node.kind === 159 /* OverrideKeyword */; + return node.kind === 159 /* SyntaxKind.OverrideKeyword */; } ts.isOverrideModifier = isOverrideModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 106 /* SuperKeyword */; + return node.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 100 /* ImportKeyword */; + return node.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 161 /* QualifiedName */; + return node.kind === 161 /* SyntaxKind.QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 162 /* ComputedPropertyName */; + return node.kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 163 /* TypeParameter */; + return node.kind === 163 /* SyntaxKind.TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 164 /* Parameter */; + return node.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 166 /* PropertySignature */; + return node.kind === 166 /* SyntaxKind.PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 167 /* PropertyDeclaration */; + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 168 /* MethodSignature */; + return node.kind === 168 /* SyntaxKind.MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassStaticBlockDeclaration(node) { - return node.kind === 170 /* ClassStaticBlockDeclaration */; + return node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 171 /* Constructor */; + return node.kind === 171 /* SyntaxKind.Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 174 /* CallSignature */; + return node.kind === 174 /* SyntaxKind.CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 175 /* ConstructSignature */; + return node.kind === 175 /* SyntaxKind.ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 176 /* IndexSignature */; + return node.kind === 176 /* SyntaxKind.IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 177 /* TypePredicate */; + return node.kind === 177 /* SyntaxKind.TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 178 /* TypeReference */; + return node.kind === 178 /* SyntaxKind.TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 179 /* FunctionType */; + return node.kind === 179 /* SyntaxKind.FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 180 /* ConstructorType */; + return node.kind === 180 /* SyntaxKind.ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 182 /* TypeLiteral */; + return node.kind === 182 /* SyntaxKind.TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 183 /* ArrayType */; + return node.kind === 183 /* SyntaxKind.ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 184 /* TupleType */; + return node.kind === 184 /* SyntaxKind.TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 197 /* NamedTupleMember */; + return node.kind === 197 /* SyntaxKind.NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 185 /* OptionalType */; + return node.kind === 185 /* SyntaxKind.OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 186 /* RestType */; + return node.kind === 186 /* SyntaxKind.RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 187 /* UnionType */; + return node.kind === 187 /* SyntaxKind.UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 188 /* IntersectionType */; + return node.kind === 188 /* SyntaxKind.IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 189 /* ConditionalType */; + return node.kind === 189 /* SyntaxKind.ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 190 /* InferType */; + return node.kind === 190 /* SyntaxKind.InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 191 /* ParenthesizedType */; + return node.kind === 191 /* SyntaxKind.ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 192 /* ThisType */; + return node.kind === 192 /* SyntaxKind.ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 193 /* TypeOperator */; + return node.kind === 193 /* SyntaxKind.TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 194 /* IndexedAccessType */; + return node.kind === 194 /* SyntaxKind.IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 195 /* MappedType */; + return node.kind === 195 /* SyntaxKind.MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 196 /* LiteralType */; + return node.kind === 196 /* SyntaxKind.LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 200 /* ImportType */; + return node.kind === 200 /* SyntaxKind.ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 199 /* TemplateLiteralTypeSpan */; + return node.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 198 /* TemplateLiteralType */; + return node.kind === 198 /* SyntaxKind.TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 201 /* ObjectBindingPattern */; + return node.kind === 201 /* SyntaxKind.ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 202 /* ArrayBindingPattern */; + return node.kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 203 /* BindingElement */; + return node.kind === 203 /* SyntaxKind.BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 204 /* ArrayLiteralExpression */; + return node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 205 /* ObjectLiteralExpression */; + return node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 207 /* ElementAccessExpression */; + return node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 208 /* CallExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 209 /* NewExpression */; + return node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 210 /* TaggedTemplateExpression */; + return node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 212 /* ParenthesizedExpression */; + return node.kind === 212 /* SyntaxKind.ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 213 /* FunctionExpression */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 214 /* ArrowFunction */; + return node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 215 /* DeleteExpression */; + return node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 216 /* TypeOfExpression */; + return node.kind === 216 /* SyntaxKind.TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 217 /* VoidExpression */; + return node.kind === 217 /* SyntaxKind.VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 218 /* AwaitExpression */; + return node.kind === 218 /* SyntaxKind.AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 219 /* PrefixUnaryExpression */; + return node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 220 /* PostfixUnaryExpression */; + return node.kind === 220 /* SyntaxKind.PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 221 /* BinaryExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 222 /* ConditionalExpression */; + return node.kind === 222 /* SyntaxKind.ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 223 /* TemplateExpression */; + return node.kind === 223 /* SyntaxKind.TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 224 /* YieldExpression */; + return node.kind === 224 /* SyntaxKind.YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 225 /* SpreadElement */; + return node.kind === 225 /* SyntaxKind.SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 226 /* ClassExpression */; + return node.kind === 226 /* SyntaxKind.ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 227 /* OmittedExpression */; + return node.kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 229 /* AsExpression */; + return node.kind === 229 /* SyntaxKind.AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 230 /* NonNullExpression */; + return node.kind === 230 /* SyntaxKind.NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 231 /* MetaProperty */; + return node.kind === 231 /* SyntaxKind.MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 232 /* SyntheticExpression */; + return node.kind === 232 /* SyntaxKind.SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 350 /* PartiallyEmittedExpression */; + return node.kind === 350 /* SyntaxKind.PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 351 /* CommaListExpression */; + return node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 233 /* TemplateSpan */; + return node.kind === 233 /* SyntaxKind.TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 234 /* SemicolonClassElement */; + return node.kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 235 /* Block */; + return node.kind === 235 /* SyntaxKind.Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 237 /* VariableStatement */; + return node.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 236 /* EmptyStatement */; + return node.kind === 236 /* SyntaxKind.EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 238 /* ExpressionStatement */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 239 /* IfStatement */; + return node.kind === 239 /* SyntaxKind.IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 240 /* DoStatement */; + return node.kind === 240 /* SyntaxKind.DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 241 /* WhileStatement */; + return node.kind === 241 /* SyntaxKind.WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 242 /* ForStatement */; + return node.kind === 242 /* SyntaxKind.ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 243 /* ForInStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 244 /* ForOfStatement */; + return node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 245 /* ContinueStatement */; + return node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 246 /* BreakStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 247 /* ReturnStatement */; + return node.kind === 247 /* SyntaxKind.ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 248 /* WithStatement */; + return node.kind === 248 /* SyntaxKind.WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 249 /* SwitchStatement */; + return node.kind === 249 /* SyntaxKind.SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 250 /* LabeledStatement */; + return node.kind === 250 /* SyntaxKind.LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 251 /* ThrowStatement */; + return node.kind === 251 /* SyntaxKind.ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 252 /* TryStatement */; + return node.kind === 252 /* SyntaxKind.TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 253 /* DebuggerStatement */; + return node.kind === 253 /* SyntaxKind.DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 255 /* VariableDeclarationList */; + return node.kind === 255 /* SyntaxKind.VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 256 /* FunctionDeclaration */; + return node.kind === 256 /* SyntaxKind.FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 257 /* ClassDeclaration */; + return node.kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 258 /* InterfaceDeclaration */; + return node.kind === 258 /* SyntaxKind.InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 259 /* TypeAliasDeclaration */; + return node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 260 /* EnumDeclaration */; + return node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 262 /* ModuleBlock */; + return node.kind === 262 /* SyntaxKind.ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 263 /* CaseBlock */; + return node.kind === 263 /* SyntaxKind.CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 264 /* NamespaceExportDeclaration */; + return node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 266 /* ImportDeclaration */; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 267 /* ImportClause */; + return node.kind === 267 /* SyntaxKind.ImportClause */; } ts.isImportClause = isImportClause; function isImportTypeAssertionContainer(node) { - return node.kind === 295 /* ImportTypeAssertionContainer */; + return node.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */; } ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer; function isAssertClause(node) { - return node.kind === 293 /* AssertClause */; + return node.kind === 293 /* SyntaxKind.AssertClause */; } ts.isAssertClause = isAssertClause; function isAssertEntry(node) { - return node.kind === 294 /* AssertEntry */; + return node.kind === 294 /* SyntaxKind.AssertEntry */; } ts.isAssertEntry = isAssertEntry; function isNamespaceImport(node) { - return node.kind === 268 /* NamespaceImport */; + return node.kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 274 /* NamespaceExport */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 269 /* NamedImports */; + return node.kind === 269 /* SyntaxKind.NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 270 /* ImportSpecifier */; + return node.kind === 270 /* SyntaxKind.ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 271 /* ExportAssignment */; + return node.kind === 271 /* SyntaxKind.ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 272 /* ExportDeclaration */; + return node.kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 273 /* NamedExports */; + return node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 275 /* ExportSpecifier */; + return node.kind === 275 /* SyntaxKind.ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 276 /* MissingDeclaration */; + return node.kind === 276 /* SyntaxKind.MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 349 /* NotEmittedStatement */; + return node.kind === 349 /* SyntaxKind.NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 354 /* SyntheticReferenceExpression */; + return node.kind === 354 /* SyntaxKind.SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 352 /* MergeDeclarationMarker */; + return node.kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 353 /* EndOfDeclarationMarker */; + return node.kind === 353 /* SyntaxKind.EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 277 /* ExternalModuleReference */; + return node.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 278 /* JsxElement */; + return node.kind === 278 /* SyntaxKind.JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 279 /* JsxSelfClosingElement */; + return node.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 280 /* JsxOpeningElement */; + return node.kind === 280 /* SyntaxKind.JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 281 /* JsxClosingElement */; + return node.kind === 281 /* SyntaxKind.JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 282 /* JsxFragment */; + return node.kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 283 /* JsxOpeningFragment */; + return node.kind === 283 /* SyntaxKind.JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 284 /* JsxClosingFragment */; + return node.kind === 284 /* SyntaxKind.JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 285 /* JsxAttribute */; + return node.kind === 285 /* SyntaxKind.JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 286 /* JsxAttributes */; + return node.kind === 286 /* SyntaxKind.JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 287 /* JsxSpreadAttribute */; + return node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 288 /* JsxExpression */; + return node.kind === 288 /* SyntaxKind.JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 289 /* CaseClause */; + return node.kind === 289 /* SyntaxKind.CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 290 /* DefaultClause */; + return node.kind === 290 /* SyntaxKind.DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 291 /* HeritageClause */; + return node.kind === 291 /* SyntaxKind.HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 292 /* CatchClause */; + return node.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 296 /* PropertyAssignment */; + return node.kind === 296 /* SyntaxKind.PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */; + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 298 /* SpreadAssignment */; + return node.kind === 298 /* SyntaxKind.SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 301 /* UnparsedPrepend */; + return node.kind === 301 /* SyntaxKind.UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -29653,176 +29777,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 305 /* SourceFile */; + return node.kind === 305 /* SyntaxKind.SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 306 /* Bundle */; + return node.kind === 306 /* SyntaxKind.Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 307 /* UnparsedSource */; + return node.kind === 307 /* SyntaxKind.UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 309 /* JSDocTypeExpression */; + return node.kind === 309 /* SyntaxKind.JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 310 /* JSDocNameReference */; + return node.kind === 310 /* SyntaxKind.JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; function isJSDocMemberName(node) { - return node.kind === 311 /* JSDocMemberName */; + return node.kind === 311 /* SyntaxKind.JSDocMemberName */; } ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 324 /* JSDocLink */; + return node.kind === 324 /* SyntaxKind.JSDocLink */; } ts.isJSDocLink = isJSDocLink; function isJSDocLinkCode(node) { - return node.kind === 325 /* JSDocLinkCode */; + return node.kind === 325 /* SyntaxKind.JSDocLinkCode */; } ts.isJSDocLinkCode = isJSDocLinkCode; function isJSDocLinkPlain(node) { - return node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 312 /* JSDocAllType */; + return node.kind === 312 /* SyntaxKind.JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 313 /* JSDocUnknownType */; + return node.kind === 313 /* SyntaxKind.JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 314 /* JSDocNullableType */; + return node.kind === 314 /* SyntaxKind.JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 315 /* JSDocNonNullableType */; + return node.kind === 315 /* SyntaxKind.JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 316 /* JSDocOptionalType */; + return node.kind === 316 /* SyntaxKind.JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 317 /* JSDocFunctionType */; + return node.kind === 317 /* SyntaxKind.JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 318 /* JSDocVariadicType */; + return node.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 319 /* JSDocNamepathType */; + return node.kind === 319 /* SyntaxKind.JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 320 /* JSDoc */; + return node.kind === 320 /* SyntaxKind.JSDoc */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 322 /* JSDocTypeLiteral */; + return node.kind === 322 /* SyntaxKind.JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 323 /* JSDocSignature */; + return node.kind === 323 /* SyntaxKind.JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 328 /* JSDocAugmentsTag */; + return node.kind === 328 /* SyntaxKind.JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 330 /* JSDocAuthorTag */; + return node.kind === 330 /* SyntaxKind.JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 332 /* JSDocClassTag */; + return node.kind === 332 /* SyntaxKind.JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 338 /* JSDocCallbackTag */; + return node.kind === 338 /* SyntaxKind.JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 333 /* JSDocPublicTag */; + return node.kind === 333 /* SyntaxKind.JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 334 /* JSDocPrivateTag */; + return node.kind === 334 /* SyntaxKind.JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 335 /* JSDocProtectedTag */; + return node.kind === 335 /* SyntaxKind.JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 336 /* JSDocReadonlyTag */; + return node.kind === 336 /* SyntaxKind.JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 337 /* JSDocOverrideTag */; + return node.kind === 337 /* SyntaxKind.JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 331 /* JSDocDeprecatedTag */; + return node.kind === 331 /* SyntaxKind.JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 346 /* JSDocSeeTag */; + return node.kind === 346 /* SyntaxKind.JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 339 /* JSDocEnumTag */; + return node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 340 /* JSDocParameterTag */; + return node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 341 /* JSDocReturnTag */; + return node.kind === 341 /* SyntaxKind.JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 342 /* JSDocThisTag */; + return node.kind === 342 /* SyntaxKind.JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 343 /* JSDocTypeTag */; + return node.kind === 343 /* SyntaxKind.JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 344 /* JSDocTemplateTag */; + return node.kind === 344 /* SyntaxKind.JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 345 /* JSDocTypedefTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 327 /* JSDocTag */; + return node.kind === 327 /* SyntaxKind.JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 347 /* JSDocPropertyTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 329 /* JSDocImplementsTag */; + return node.kind === 329 /* SyntaxKind.JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 348 /* SyntaxList */; + return n.kind === 348 /* SyntaxKind.SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -29842,7 +29966,7 @@ var ts; var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); - ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; + ts.getOrCreateEmitNode(expression).flags |= 64 /* EmitFlags.NoNestedSourceMaps */; return expression; } } @@ -30021,14 +30145,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -30067,7 +30191,7 @@ var ts; */ function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) { var operator = node.operator; - ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); + ts.Debug.assert(operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); var temp = factory.createTempVariable(recordTempVariable); expression = factory.createAssignment(temp, expression); ts.setTextRange(expression, node.operand); @@ -30092,14 +30216,14 @@ var ts; * Gets whether an identifier should only be referred to by its internal name. */ function isInternalName(node) { - return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + return (ts.getEmitFlags(node) & 32768 /* EmitFlags.InternalName */) !== 0; } ts.isInternalName = isInternalName; /** * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* EmitFlags.LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -30107,7 +30231,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* EmitFlags.ExportName */) !== 0; } ts.isExportName = isExportName; function isUseStrictPrologue(node) { @@ -30136,8 +30260,8 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 351 /* CommaListExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || + node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isJSDocTypeAssertion(node) { @@ -30153,26 +30277,26 @@ var ts; } ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType; function isOuterExpression(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } switch (node.kind) { - case 212 /* ParenthesizedExpression */: - if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { + case 212 /* SyntaxKind.ParenthesizedExpression */: + if (kinds & 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { return false; } - return (kinds & 1 /* Parentheses */) !== 0; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - return (kinds & 2 /* TypeAssertions */) !== 0; - case 230 /* NonNullExpression */: - return (kinds & 4 /* NonNullAssertions */) !== 0; - case 350 /* PartiallyEmittedExpression */: - return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; + return (kinds & 1 /* OuterExpressionKinds.Parentheses */) !== 0; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + return (kinds & 2 /* OuterExpressionKinds.TypeAssertions */) !== 0; + case 230 /* SyntaxKind.NonNullExpression */: + return (kinds & 4 /* OuterExpressionKinds.NonNullAssertions */) !== 0; + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + return (kinds & 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */) !== 0; } return false; } ts.isOuterExpression = isOuterExpression; function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } while (isOuterExpression(node, kinds)) { node = node.expression; } @@ -30180,7 +30304,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - return skipOuterExpressions(node, 6 /* Assertions */); + return skipOuterExpressions(node, 6 /* OuterExpressionKinds.Assertions */); } ts.skipAssertions = skipAssertions; function startOnNewLine(node) { @@ -30241,7 +30365,7 @@ var ts; var externalHelpersImportDeclaration = nodeFactory.createImportDeclaration( /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), /*assertClause*/ undefined); - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* EmitFlags.NeverApplyImportHelper */); return externalHelpersImportDeclaration; } } @@ -30286,10 +30410,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 266 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 266 /* SyntaxKind.ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 272 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -30408,7 +30532,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -30420,11 +30544,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -30456,12 +30580,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 225 /* SpreadElement */: - case 298 /* SpreadAssignment */: + case 225 /* SyntaxKind.SpreadElement */: + case 298 /* SyntaxKind.SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -30479,7 +30603,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -30494,7 +30618,7 @@ var ts; : propertyName; } break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -30509,7 +30633,7 @@ var ts; : propertyName; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -30524,21 +30648,21 @@ var ts; ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */; } /** * Gets the elements of a BindingOrAssignmentPattern */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -30559,86 +30683,86 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveIllegalType(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 173 /* SetAccessor */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.canHaveIllegalType = canHaveIllegalType; function canHaveIllegalTypeParameters(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.canHaveIllegalTypeParameters = canHaveIllegalTypeParameters; function canHaveDecorators(node) { var kind = node.kind; - return kind === 164 /* Parameter */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 226 /* ClassExpression */ - || kind === 257 /* ClassDeclaration */; + return kind === 164 /* SyntaxKind.Parameter */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.canHaveDecorators = canHaveDecorators; function canHaveIllegalDecorators(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 237 /* VariableStatement */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.canHaveIllegalDecorators = canHaveIllegalDecorators; function canHaveModifiers(node) { var kind = node.kind; - return kind === 163 /* TypeParameter */ - || kind === 164 /* Parameter */ - || kind === 166 /* PropertySignature */ - || kind === 167 /* PropertyDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 169 /* MethodDeclaration */ - || kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 180 /* ConstructorType */ - || kind === 213 /* FunctionExpression */ - || kind === 214 /* ArrowFunction */ - || kind === 226 /* ClassExpression */ - || kind === 237 /* VariableStatement */ - || kind === 256 /* FunctionDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 272 /* ExportDeclaration */; + return kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 180 /* SyntaxKind.ConstructorType */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; function canHaveIllegalModifiers(node) { var kind = node.kind; - return kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 179 /* FunctionType */ - || kind === 276 /* MissingDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 179 /* SyntaxKind.FunctionType */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.canHaveIllegalModifiers = canHaveIllegalModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -30649,68 +30773,68 @@ var ts; ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); function isLiteralTypeLikeExpression(node) { var kind = node.kind; - return kind === 104 /* NullKeyword */ - || kind === 110 /* TrueKeyword */ - || kind === 95 /* FalseKeyword */ + return kind === 104 /* SyntaxKind.NullKeyword */ + || kind === 110 /* SyntaxKind.TrueKeyword */ + || kind === 95 /* SyntaxKind.FalseKeyword */ || ts.isLiteralExpression(node) || ts.isPrefixUnaryExpression(node); } ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; function isExponentiationOperator(kind) { - return kind === 42 /* AsteriskAsteriskToken */; + return kind === 42 /* SyntaxKind.AsteriskAsteriskToken */; } function isMultiplicativeOperator(kind) { - return kind === 41 /* AsteriskToken */ - || kind === 43 /* SlashToken */ - || kind === 44 /* PercentToken */; + return kind === 41 /* SyntaxKind.AsteriskToken */ + || kind === 43 /* SyntaxKind.SlashToken */ + || kind === 44 /* SyntaxKind.PercentToken */; } function isMultiplicativeOperatorOrHigher(kind) { return isExponentiationOperator(kind) || isMultiplicativeOperator(kind); } function isAdditiveOperator(kind) { - return kind === 39 /* PlusToken */ - || kind === 40 /* MinusToken */; + return kind === 39 /* SyntaxKind.PlusToken */ + || kind === 40 /* SyntaxKind.MinusToken */; } function isAdditiveOperatorOrHigher(kind) { return isAdditiveOperator(kind) || isMultiplicativeOperatorOrHigher(kind); } function isShiftOperator(kind) { - return kind === 47 /* LessThanLessThanToken */ - || kind === 48 /* GreaterThanGreaterThanToken */ - || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */; + return kind === 47 /* SyntaxKind.LessThanLessThanToken */ + || kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ + || kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } function isShiftOperatorOrHigher(kind) { return isShiftOperator(kind) || isAdditiveOperatorOrHigher(kind); } function isRelationalOperator(kind) { - return kind === 29 /* LessThanToken */ - || kind === 32 /* LessThanEqualsToken */ - || kind === 31 /* GreaterThanToken */ - || kind === 33 /* GreaterThanEqualsToken */ - || kind === 102 /* InstanceOfKeyword */ - || kind === 101 /* InKeyword */; + return kind === 29 /* SyntaxKind.LessThanToken */ + || kind === 32 /* SyntaxKind.LessThanEqualsToken */ + || kind === 31 /* SyntaxKind.GreaterThanToken */ + || kind === 33 /* SyntaxKind.GreaterThanEqualsToken */ + || kind === 102 /* SyntaxKind.InstanceOfKeyword */ + || kind === 101 /* SyntaxKind.InKeyword */; } function isRelationalOperatorOrHigher(kind) { return isRelationalOperator(kind) || isShiftOperatorOrHigher(kind); } function isEqualityOperator(kind) { - return kind === 34 /* EqualsEqualsToken */ - || kind === 36 /* EqualsEqualsEqualsToken */ - || kind === 35 /* ExclamationEqualsToken */ - || kind === 37 /* ExclamationEqualsEqualsToken */; + return kind === 34 /* SyntaxKind.EqualsEqualsToken */ + || kind === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ + || kind === 35 /* SyntaxKind.ExclamationEqualsToken */ + || kind === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } function isEqualityOperatorOrHigher(kind) { return isEqualityOperator(kind) || isRelationalOperatorOrHigher(kind); } function isBitwiseOperator(kind) { - return kind === 50 /* AmpersandToken */ - || kind === 51 /* BarToken */ - || kind === 52 /* CaretToken */; + return kind === 50 /* SyntaxKind.AmpersandToken */ + || kind === 51 /* SyntaxKind.BarToken */ + || kind === 52 /* SyntaxKind.CaretToken */; } function isBitwiseOperatorOrHigher(kind) { return isBitwiseOperator(kind) @@ -30718,21 +30842,21 @@ var ts; } // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. function isLogicalOperator(kind) { - return kind === 55 /* AmpersandAmpersandToken */ - || kind === 56 /* BarBarToken */; + return kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || kind === 56 /* SyntaxKind.BarBarToken */; } function isLogicalOperatorOrHigher(kind) { return isLogicalOperator(kind) || isBitwiseOperatorOrHigher(kind); } function isAssignmentOperatorOrHigher(kind) { - return kind === 60 /* QuestionQuestionToken */ + return kind === 60 /* SyntaxKind.QuestionQuestionToken */ || isLogicalOperatorOrHigher(kind) || ts.isAssignmentOperator(kind); } function isBinaryOperator(kind) { return isAssignmentOperatorOrHigher(kind) - || kind === 27 /* CommaToken */; + || kind === 27 /* SyntaxKind.CommaToken */; } function isBinaryOperatorToken(node) { return isBinaryOperator(node.kind); @@ -30865,7 +30989,7 @@ var ts; return stackIndex; } function checkCircularity(stackIndex, nodeStack, node) { - if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + if (ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */)) { while (stackIndex >= 0) { ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); stackIndex--; @@ -30954,7 +31078,7 @@ var ts; createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); }, }; /* @internal */ - ts.parseNodeFactory = ts.createNodeFactory(1 /* NoParenthesizerRules */, ts.parseBaseNodeFactory); + ts.parseNodeFactory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.parseBaseNodeFactory); function visitNode(cbNode, node) { return node && cbNode(node); } @@ -30974,9 +31098,9 @@ var ts; } /*@internal*/ function isJSDocLikeText(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 42 /* asterisk */ && - text.charCodeAt(start + 3) !== 47 /* slash */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 3) !== 47 /* CharacterCodes.slash */; } ts.isJSDocLikeText = isJSDocLikeText; /*@internal*/ @@ -30988,14 +31112,14 @@ var ts; } ts.isFileProbablyExternalModule = isFileProbablyExternalModule; function isAnExternalModuleIndicatorNode(node) { - return ts.canHaveModifiers(node) && hasModifierOfKind(node, 93 /* ExportKeyword */) + return ts.canHaveModifiers(node) && hasModifierOfKind(node, 93 /* SyntaxKind.ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) || ts.isExportDeclaration(node) ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */ ? walkTreeForImportMeta(sourceFile) : undefined; } @@ -31007,7 +31131,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && node.name.escapedText === "meta"; } /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes @@ -31023,20 +31147,20 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 160 /* LastToken */) { + if (!node || node.kind <= 160 /* SyntaxKind.LastToken */) { return; } switch (node.kind) { - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -31044,67 +31168,67 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitNode(cbNode, node.expression); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.initializer); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || @@ -31114,14 +31238,14 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -31129,21 +31253,21 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -31152,7 +31276,7 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || @@ -31160,357 +31284,357 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return visitNode(cbNode, node.exprName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return visitNode(cbNode, node.elementType); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return visitNode(cbNode, node.typeParameter); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.assertions) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: return visitNode(cbNode, node.assertClause); - case 191 /* ParenthesizedType */: - case 193 /* TypeOperator */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 193 /* SyntaxKind.TypeOperator */: return visitNode(cbNode, node.type); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNodes(cbNode, cbNodes, node.members); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return visitNode(cbNode, node.literal); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitNode(cbNode, node.expression); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return visitNode(cbNode, node.expression); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitNode(cbNode, node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitNode(cbNode, node.expression); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return visitNode(cbNode, node.expression); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitNode(cbNode, node.name); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitNode(cbNode, node.expression); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitNode(cbNode, node.expression); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitNode(cbNode, node.label); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitNode(cbNode, node.expression); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return visitNode(cbNode, node.expression); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return visitNode(cbNode, node.expression); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return visitNodes(cbNode, cbNodes, node.elements); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.value); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNode(cbNode, node.name); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return visitNode(cbNode, node.name); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return visitNode(cbNode, node.name); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 185 /* OptionalType */: - case 186 /* RestType */: - case 309 /* JSDocTypeExpression */: - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 316 /* JSDocOptionalType */: - case 318 /* JSDocVariadicType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return visitNode(cbNode, node.type); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return visitNode(cbNode, node.name); - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || @@ -31519,64 +31643,64 @@ var ts; : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 330 /* JSDocAuthorTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 309 /* JSDocTypeExpression */ + node.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: - case 331 /* JSDocDeprecatedTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -31625,7 +31749,7 @@ var ts; continue; return res; } - if (current.kind >= 161 /* FirstNode */) { + if (current.kind >= 161 /* SyntaxKind.FirstNode */) { // add children in reverse order to the queue, so popping gives the first child for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { var child = _a[_i]; @@ -31650,13 +31774,13 @@ var ts; } function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat; - if (languageVersion === 100 /* JSON */) { - result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop); + if (languageVersion === 100 /* ScriptTarget.JSON */) { + result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* ScriptKind.JSON */, ts.noop); } else { var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) { @@ -31704,7 +31828,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -31732,8 +31856,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks // tslint:disable variable-name var NodeConstructor; @@ -31755,7 +31879,7 @@ var ts; createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)); }, createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); } }; - var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory); + var factory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */ | 2 /* NodeFactoryFlags.NoNodeConverters */ | 8 /* NodeFactoryFlags.NoOriginalNode */, baseNodeFactory); var fileName; var sourceFlags; var sourceText; @@ -31853,7 +31977,7 @@ var ts; var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); - if (scriptKind === 6 /* JSON */) { + if (scriptKind === 6 /* ScriptKind.JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); result_3.referencedFiles = ts.emptyArray; @@ -31872,25 +31996,25 @@ var ts; Parser.parseSourceFile = parseSourceFile; function parseIsolatedEntityName(content, languageVersion) { // Choice of `isDeclarationFile` should be arbitrary - initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* ScriptKind.JS */); // Prime the scanner. nextToken(); var entityName = parseEntityName(/*allowReservedWords*/ true); - var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + var isInvalid = token() === 1 /* SyntaxKind.EndOfFileToken */ && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; } Parser.parseIsolatedEntityName = parseIsolatedEntityName; function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { - if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; } + if (languageVersion === void 0) { languageVersion = 2 /* ScriptTarget.ES2015 */; } if (setParentNodes === void 0) { setParentNodes = false; } - initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* JSON */); + initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* ScriptKind.JSON */); sourceFlags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); var statements, endOfFileToken; - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { statements = createNodeArray([], pos, pos); endOfFileToken = parseTokenNode(); } @@ -31898,28 +32022,28 @@ var ts; // Loop and synthesize an ArrayLiteralExpression if there are more than // one top-level expressions to ensure all input text is consumed. var expressions = void 0; - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var expression_1 = void 0; switch (token()) { - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: expression_1 = parseArrayLiteralExpression(); break; - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: expression_1 = parseTokenNode(); break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + case 40 /* SyntaxKind.MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* SyntaxKind.NumericLiteral */ && nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parsePrefixUnaryExpression(); } else { expression_1 = parseObjectLiteralExpression(); } break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parseLiteralNode(); break; } @@ -31937,7 +32061,7 @@ var ts; } else { expressions = expression_1; - if (token() !== 1 /* EndOfFileToken */) { + if (token() !== 1 /* SyntaxKind.EndOfFileToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } } @@ -31946,10 +32070,10 @@ var ts; var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); - endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token); + endOfFileToken = parseExpectedToken(1 /* SyntaxKind.EndOfFileToken */, ts.Diagnostics.Unexpected_token); } // Set source file so that errors will be reported with this file name - var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); + var sourceFile = createSourceFile(fileName, 2 /* ScriptTarget.ES2015 */, 6 /* ScriptKind.JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); if (setParentNodes) { fixupParentReferences(sourceFile); } @@ -31986,15 +32110,15 @@ var ts; sourceFlags = 0; topLevel = true; switch (scriptKind) { - case 1 /* JS */: - case 2 /* JSX */: - contextFlags = 262144 /* JavaScriptFile */; + case 1 /* ScriptKind.JS */: + case 2 /* ScriptKind.JSX */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */; break; - case 6 /* JSON */: - contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */; + case 6 /* ScriptKind.JSON */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */ | 67108864 /* NodeFlags.JsonFile */; break; default: - contextFlags = 0 /* None */; + contextFlags = 0 /* NodeFlags.None */; break; } parseErrorBeforeNextFinishedNode = false; @@ -32026,13 +32150,13 @@ var ts; function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 16777216 /* Ambient */; + contextFlags |= 16777216 /* NodeFlags.Ambient */; } sourceFlags = contextFlags; // Prime the scanner. nextToken(); - var statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token() === 1 /* EndOfFileToken */); + var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement); + ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */); var endOfFileToken = addJSDocComment(parseTokenNode()); var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator); // A member of ReadonlyArray isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future @@ -32065,7 +32189,7 @@ var ts; node.jsDoc = jsDoc; if (hasDeprecatedTag) { hasDeprecatedTag = false; - node.flags |= 268435456 /* Deprecated */; + node.flags |= 268435456 /* NodeFlags.Deprecated */; } return node; } @@ -32093,12 +32217,12 @@ var ts; // reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones. speculationHelper(function () { var savedContextFlags = contextFlags; - contextFlags |= 32768 /* AwaitContext */; + contextFlags |= 32768 /* NodeFlags.AwaitContext */; scanner.setTextPos(nextStatement.pos); nextToken(); - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var startPos = scanner.getStartPos(); - var statement = parseListElement(0 /* SourceElements */, parseStatement); + var statement = parseListElement(0 /* ParsingContext.SourceElements */, parseStatement); statements.push(statement); if (startPos === scanner.getStartPos()) { nextToken(); @@ -32116,7 +32240,7 @@ var ts; } } contextFlags = savedContextFlags; - }, 2 /* Reparse */); + }, 2 /* SpeculationKind.Reparse */); // find the next statement containing an `await` start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1; }; @@ -32136,8 +32260,8 @@ var ts; syntaxCursor = savedSyntaxCursor; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { - return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */); + return !(node.flags & 32768 /* NodeFlags.AwaitContext */) + && !!(node.transformFlags & 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -32178,7 +32302,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setFields(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); setFields(sourceFile); } @@ -32205,16 +32329,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 4096 /* DisallowInContext */); + setContextFlag(val, 4096 /* NodeFlags.DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 8192 /* YieldContext */); + setContextFlag(val, 8192 /* NodeFlags.YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 16384 /* DecoratorContext */); + setContextFlag(val, 16384 /* NodeFlags.DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 32768 /* AwaitContext */); + setContextFlag(val, 32768 /* NodeFlags.AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -32255,52 +32379,52 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(4096 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(4096 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function allowConditionalTypesAnd(func) { - return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doOutsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function disallowConditionalTypesAnd(func) { - return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doInsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(8192 /* YieldContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(16384 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* NodeFlags.DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(32768 /* AwaitContext */, func); + return doInsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(32768 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(8192 /* YieldContext */); + return inContext(8192 /* NodeFlags.YieldContext */); } function inDisallowInContext() { - return inContext(4096 /* DisallowInContext */); + return inContext(4096 /* NodeFlags.DisallowInContext */); } function inDisallowConditionalTypesContext() { - return inContext(65536 /* DisallowConditionalTypesContext */); + return inContext(65536 /* NodeFlags.DisallowConditionalTypesContext */); } function inDecoratorContext() { - return inContext(16384 /* DecoratorContext */); + return inContext(16384 /* NodeFlags.DecoratorContext */); } function inAwaitContext() { - return inContext(32768 /* AwaitContext */); + return inContext(32768 /* NodeFlags.AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -32401,15 +32525,15 @@ var ts; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the // same. - var result = speculationKind !== 0 /* TryParse */ + var result = speculationKind !== 0 /* SpeculationKind.TryParse */ ? scanner.lookAhead(callback) : scanner.tryScan(callback); ts.Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. - if (!result || speculationKind !== 0 /* TryParse */) { + if (!result || speculationKind !== 0 /* SpeculationKind.TryParse */) { currentToken = saveToken; - if (speculationKind !== 2 /* Reparse */) { + if (speculationKind !== 2 /* SpeculationKind.Reparse */) { parseDiagnostics.length = saveParseDiagnosticsLength; } parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -32421,7 +32545,7 @@ var ts; * is returned from this function. */ function lookAhead(callback) { - return speculationHelper(callback, 1 /* Lookahead */); + return speculationHelper(callback, 1 /* SpeculationKind.Lookahead */); } /** Invokes the provided callback. If the callback returns something falsy, then it restores * the parser to the state it was in immediately prior to invoking the callback. If the @@ -32429,31 +32553,31 @@ var ts; * of invoking the callback is returned from this function. */ function tryParse(callback) { - return speculationHelper(callback, 0 /* TryParse */); + return speculationHelper(callback, 0 /* SpeculationKind.TryParse */); } function isBindingIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder. - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 125 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* SyntaxKind.YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -32491,7 +32615,7 @@ var ts; // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined; if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } var pos = ts.skipTrivia(sourceText, node.pos); @@ -32506,17 +32630,17 @@ var ts; // If a declared node failed to parse, it would have emitted a diagnostic already. return; case "interface": - parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "is": parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; case "module": case "namespace": - parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "type": - parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */); + parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* SyntaxKind.EqualsToken */); return; } // The user alternatively might have misspelled or forgotten to add a space after a common keyword. @@ -32526,7 +32650,7 @@ var ts; return; } // Unknown tokens are handled with their own errors in the scanner - if (token() === 0 /* Unknown */) { + if (token() === 0 /* SyntaxKind.Unknown */) { return; } // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. @@ -32551,24 +32675,24 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; } function parseSemicolonAfterPropertyName(name, type, initializer) { - if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 59 /* SyntaxKind.AtToken */ && !scanner.hasPrecedingLineBreak()) { parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); return; } - if (token() === 20 /* OpenParenToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); nextToken(); return; } if (type && !canParseSemicolon()) { if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); } else { parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer); @@ -32579,7 +32703,7 @@ var ts; return; } if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } parseErrorForMissingSemicolonAfter(name); @@ -32646,24 +32770,24 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 1 /* SyntaxKind.EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function tryParseSemicolon() { if (!canParseSemicolon()) { return false; } - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } function parseSemicolon() { - return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */); + return tryParseSemicolon() || parseExpected(26 /* SyntaxKind.SemicolonToken */); } function createNodeArray(elements, pos, end, hasTrailingComma) { var array = factory.createNodeArray(elements, hasTrailingComma); @@ -32680,7 +32804,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 131072 /* ThisNodeHasError */; + node.flags |= 131072 /* NodeFlags.ThisNodeHasError */; } return node; } @@ -32692,11 +32816,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* SyntaxKind.Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 276 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : + kind === 276 /* SyntaxKind.MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -32720,23 +32844,23 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(/*isIdentifier*/ true); } - if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) { + if (token() === 0 /* SyntaxKind.Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* SyntaxKind.Identifier */; })) { // Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser. return createIdentifier(/*isIdentifier*/ true); } identifierCount++; // Only for end of file because the error gets reported incorrectly on embedded script tags. - var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + var reportAtCurrentPosition = token() === 1 /* SyntaxKind.EndOfFileToken */; var isReservedWord = scanner.isReservedWord(); var msgArg = scanner.getTokenText(); var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* SyntaxKind.Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -32749,23 +32873,23 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */; } function isAssertionKey() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ || token() === 8 /* SyntaxKind.NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -32778,12 +32902,12 @@ var ts; // LiteralPropertyName // ComputedPropertyName[?Yield] var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. var expression = allowInAnd(parseExpression); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createComputedPropertyName(expression), pos); } function internPrivateIdentifier(text) { @@ -32811,23 +32935,23 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 92 /* EnumKeyword */; - case 93 /* ExportKeyword */: + return nextToken() === 92 /* SyntaxKind.EnumKeyword */; + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); - if (token() === 88 /* DefaultKeyword */) { + if (token() === 88 /* SyntaxKind.DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 152 /* TypeKeyword */) { + if (token() === 152 /* SyntaxKind.TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 124 /* StaticKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -32835,9 +32959,9 @@ var ts; } } function canFollowExportModifier() { - return token() !== 41 /* AsteriskToken */ - && token() !== 127 /* AsKeyword */ - && token() !== 18 /* OpenBraceToken */ + return token() !== 41 /* SyntaxKind.AsteriskToken */ + && token() !== 127 /* SyntaxKind.AsKeyword */ + && token() !== 18 /* SyntaxKind.OpenBraceToken */ && canFollowModifier(); } function nextTokenCanFollowExportModifier() { @@ -32848,18 +32972,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 22 /* OpenBracketToken */ - || token() === 18 /* OpenBraceToken */ - || token() === 41 /* AsteriskToken */ - || token() === 25 /* DotDotDotToken */ + return token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 41 /* SyntaxKind.AsteriskToken */ + || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || - token() === 118 /* InterfaceKeyword */ || - (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* SyntaxKind.ClassKeyword */ || token() === 98 /* SyntaxKind.FunctionKeyword */ || + token() === 118 /* SyntaxKind.InterfaceKeyword */ || + (token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -32868,50 +32992,50 @@ var ts; return true; } switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 2 /* SwitchClauses */: - return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 4 /* TypeMembers */: + return !(token() === 26 /* SyntaxKind.SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + case 2 /* ParsingContext.SwitchClauses */: + return token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 4 /* ParsingContext.TypeMembers */: return lookAhead(isTypeMemberStart); - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); - case 6 /* EnumMembers */: + return lookAhead(isClassMemberStart) || (token() === 26 /* SyntaxKind.SemicolonToken */ && !inErrorRecovery); + case 6 /* ParsingContext.EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); - case 12 /* ObjectLiteralMembers */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || isLiteralPropertyName(); + case 12 /* ParsingContext.ObjectLiteralMembers */: switch (token()) { - case 22 /* OpenBracketToken */: - case 41 /* AsteriskToken */: - case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* SyntaxKind.OpenBracketToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 24 /* SyntaxKind.DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; default: return isLiteralPropertyName(); } - case 18 /* RestProperties */: + case 18 /* ParsingContext.RestProperties */: return isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); - case 24 /* AssertEntries */: + case 9 /* ParsingContext.ObjectBindingElements */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); + case 24 /* ParsingContext.AssertEntries */: return isAssertionKey(); - case 7 /* HeritageClauseElement */: + case 7 /* ParsingContext.HeritageClauseElement */: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -32923,42 +33047,42 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 19 /* TypeParameters */: - return token() === 101 /* InKeyword */ || isIdentifier(); - case 15 /* ArrayLiteralMembers */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); + case 19 /* ParsingContext.TypeParameters */: + return token() === 101 /* SyntaxKind.InKeyword */ || isIdentifier(); + case 15 /* ParsingContext.ArrayLiteralMembers */: switch (token()) { - case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 27 /* SyntaxKind.CommaToken */: + case 24 /* SyntaxKind.DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) return true; } // falls through - case 11 /* ArgumentExpressions */: - return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: + case 11 /* ParsingContext.ArgumentExpressions */: + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isStartOfExpression(); + case 16 /* ParsingContext.Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); - case 17 /* JSDocParameters */: + case 17 /* ParsingContext.JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); - case 20 /* TypeArguments */: - case 21 /* TupleElementTypes */: - return token() === 27 /* CommaToken */ || isStartOfType(); - case 22 /* HeritageClauses */: + case 20 /* ParsingContext.TypeArguments */: + case 21 /* ParsingContext.TupleElementTypes */: + return token() === 27 /* SyntaxKind.CommaToken */ || isStartOfType(); + case 22 /* ParsingContext.HeritageClauses */: return isHeritageClause(); - case 23 /* ImportOrExportSpecifiers */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; - case 14 /* JsxChildren */: + case 13 /* ParsingContext.JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* SyntaxKind.OpenBraceToken */; + case 14 /* ParsingContext.JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 18 /* OpenBraceToken */); - if (nextToken() === 19 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* SyntaxKind.OpenBraceToken */); + if (nextToken() === 19 /* SyntaxKind.CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -32967,7 +33091,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; + return next === 27 /* SyntaxKind.CommaToken */ || next === 18 /* SyntaxKind.OpenBraceToken */ || next === 94 /* SyntaxKind.ExtendsKeyword */ || next === 117 /* SyntaxKind.ImplementsKeyword */; } return true; } @@ -32984,8 +33108,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 117 /* ImplementsKeyword */ || - token() === 94 /* ExtendsKeyword */) { + if (token() === 117 /* SyntaxKind.ImplementsKeyword */ || + token() === 94 /* SyntaxKind.ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -33000,51 +33124,51 @@ var ts; } // True if positioned at a list terminator function isListTerminator(kind) { - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { // Being at the end of the file ends all lists. return true; } switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 23 /* ImportOrExportSpecifiers */: - case 24 /* AssertEntries */: - return token() === 19 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: + case 2 /* ParsingContext.SwitchClauses */: + case 4 /* ParsingContext.TypeMembers */: + case 5 /* ParsingContext.ClassMembers */: + case 6 /* ParsingContext.EnumMembers */: + case 12 /* ParsingContext.ObjectLiteralMembers */: + case 9 /* ParsingContext.ObjectBindingElements */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: + case 24 /* ParsingContext.AssertEntries */: + return token() === 19 /* SyntaxKind.CloseBraceToken */; + case 3 /* ParsingContext.SwitchClauseStatements */: + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 7 /* ParsingContext.HeritageClauseElement */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 8 /* ParsingContext.VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 19 /* TypeParameters */: + case 19 /* ParsingContext.TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 11 /* ParsingContext.ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 21 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token() === 23 /* CloseBracketToken */; - case 17 /* JSDocParameters */: - case 16 /* Parameters */: - case 18 /* RestProperties */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 26 /* SyntaxKind.SemicolonToken */; + case 15 /* ParsingContext.ArrayLiteralMembers */: + case 21 /* ParsingContext.TupleElementTypes */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 23 /* SyntaxKind.CloseBracketToken */; + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: + case 18 /* ParsingContext.RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 20 /* TypeArguments */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + case 20 /* ParsingContext.TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 27 /* CommaToken */; - case 22 /* HeritageClauses */: - return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; - case 14 /* JsxChildren */: - return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() !== 27 /* SyntaxKind.CommaToken */; + case 22 /* ParsingContext.HeritageClauses */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 19 /* SyntaxKind.CloseBraceToken */; + case 13 /* ParsingContext.JsxAttributes */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 43 /* SyntaxKind.SlashToken */; + case 14 /* ParsingContext.JsxChildren */: + return token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -33064,7 +33188,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -33072,7 +33196,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 25 /* ParsingContext.Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -33106,7 +33230,7 @@ var ts; } return parseElement(); } - function currentNode(parsingContext) { + function currentNode(parsingContext, pos) { // If we don't have a cursor or the parsing context isn't reusable, there's nothing to reuse. // // If there is an outstanding parse error that we've encountered, but not attached to @@ -33119,7 +33243,7 @@ var ts; if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) { return undefined; } - var node = syntaxCursor.currentNode(scanner.getStartPos()); + var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos()); // Can't reuse a missing node. // Can't reuse a node that intersected the change range. // Can't reuse a node that contains a parse error. This is necessary so that we @@ -33138,7 +33262,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 50720768 /* ContextFlags */; + var nodeContextFlags = node.flags & 50720768 /* NodeFlags.ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -33161,38 +33285,38 @@ var ts; } function isReusableParsingContext(parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: - case 2 /* SwitchClauses */: - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - case 6 /* EnumMembers */: - case 4 /* TypeMembers */: - case 8 /* VariableDeclarations */: - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 5 /* ParsingContext.ClassMembers */: + case 2 /* ParsingContext.SwitchClauses */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: + case 6 /* ParsingContext.EnumMembers */: + case 4 /* ParsingContext.TypeMembers */: + case 8 /* ParsingContext.VariableDeclarations */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return true; } return false; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: return isReusableClassMember(node); - case 2 /* SwitchClauses */: + case 2 /* ParsingContext.SwitchClauses */: return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: return isReusableStatement(node); - case 6 /* EnumMembers */: + case 6 /* ParsingContext.EnumMembers */: return isReusableEnumMember(node); - case 4 /* TypeMembers */: + case 4 /* ParsingContext.TypeMembers */: return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isReusableVariableDeclaration(node); - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative @@ -33239,20 +33363,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 171 /* Constructor */: - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 234 /* SemicolonClassElement */: + case 171 /* SyntaxKind.Constructor */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 234 /* SyntaxKind.SemicolonClassElement */: return true; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ && + methodDeclaration.name.originalKeywordKind === 134 /* SyntaxKind.ConstructorKeyword */; return !nameIsConstructor; } } @@ -33261,8 +33385,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return true; } } @@ -33271,58 +33395,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 237 /* VariableStatement */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 238 /* ExpressionStatement */: - case 251 /* ThrowStatement */: - case 247 /* ReturnStatement */: - case 249 /* SwitchStatement */: - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 236 /* EmptyStatement */: - case 252 /* TryStatement */: - case 250 /* LabeledStatement */: - case 240 /* DoStatement */: - case 253 /* DebuggerStatement */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 166 /* PropertySignature */: - case 174 /* CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 174 /* SyntaxKind.CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 254 /* VariableDeclaration */) { + if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -33343,7 +33467,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 164 /* Parameter */) { + if (node.kind !== 164 /* SyntaxKind.Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -33361,40 +33485,42 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return token() === 88 /* DefaultKeyword */ - ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */)) + case 0 /* ParsingContext.SourceElements */: + return token() === 88 /* SyntaxKind.DefaultKeyword */ + ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* SyntaxKind.ExportKeyword */)) : parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); - case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); - case 18 /* RestProperties */: // fallthrough - case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); - case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); - case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); - case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 2 /* ParsingContext.SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); + case 3 /* ParsingContext.SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); + case 18 /* ParsingContext.RestProperties */: // fallthrough + case 4 /* ParsingContext.TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); + case 5 /* ParsingContext.ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case 6 /* ParsingContext.EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); + case 7 /* ParsingContext.HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); + case 8 /* ParsingContext.VariableDeclarations */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected); - case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); - case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); - case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); - case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); - case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); - case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 16 /* Parameters */: + case 9 /* ParsingContext.ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); + case 10 /* ParsingContext.ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); + case 11 /* ParsingContext.ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); + case 12 /* ParsingContext.ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); + case 15 /* ParsingContext.ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); + case 17 /* ParsingContext.JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* ParsingContext.Parameters */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); - case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); - case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); - case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); - case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);` + case 19 /* ParsingContext.TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); + case 20 /* ParsingContext.TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); + case 21 /* ParsingContext.TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); + case 22 /* ParsingContext.HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 13 /* ParsingContext.JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 14 /* ParsingContext.JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 24 /* ParsingContext.AssertEntries */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); // AssertionKey. + case 25 /* ParsingContext.Count */: return ts.Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker. + default: ts.Debug.assertNever(context); } } function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { @@ -33413,7 +33539,7 @@ var ts; } list.push(result); commaStart = scanner.getTokenPos(); - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -33423,13 +33549,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); + parseExpected(27 /* SyntaxKind.CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SyntaxKind.SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -33458,7 +33584,7 @@ var ts; return createNodeArray(list, listPos, /*end*/ undefined, commaStart >= 0); } function getExpectedCommaDiagnostic(kind) { - return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + return kind === 6 /* ParsingContext.EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; } function createMissingList() { var list = createNodeArray([], getNodePos()); @@ -33480,8 +33606,8 @@ var ts; var pos = getNodePos(); var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = getNodePos(); - while (parseOptional(24 /* DotToken */)) { - if (token() === 29 /* LessThanToken */) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -33520,12 +33646,12 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -33536,7 +33662,7 @@ var ts; do { node = parseTemplateSpan(isTaggedTemplate); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateExpression(isTaggedTemplate) { @@ -33554,7 +33680,7 @@ var ts; do { node = parseTemplateTypeSpan(); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateTypeSpan() { @@ -33562,13 +33688,13 @@ var ts; return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos); } function parseLiteralOfTemplateSpan(isTaggedTemplate) { - if (token() === 19 /* CloseBraceToken */) { + if (token() === 19 /* SyntaxKind.CloseBraceToken */) { reScanTemplateToken(isTaggedTemplate); return parseTemplateMiddleOrTemplateTail(); } else { // TODO(rbuckton): Do we need to call `parseExpectedToken` or can we just call `createMissingNode` directly? - return parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); + return parseExpectedToken(17 /* SyntaxKind.TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* SyntaxKind.CloseBraceToken */)); } } function parseTemplateSpan(isTaggedTemplate) { @@ -33583,30 +33709,30 @@ var ts; reScanTemplateHeadOrNoSubstitutionTemplate(); } var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* SyntaxKind.TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* SyntaxKind.TemplateMiddle */ || fragment.kind === 17 /* SyntaxKind.TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function getTemplateLiteralRawText(kind) { - var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var isLast = kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || kind === 17 /* SyntaxKind.TemplateTail */; var tokenText = scanner.getTokenText(); return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); } function parseLiteralLikeNode(kind) { var pos = getNodePos(); - var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : + var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TokenFlags.TemplateLiteralLikeFlags */) : // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal. But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) : ts.Debug.fail(); if (scanner.hasExtendedUnicodeEscape()) { @@ -33623,8 +33749,8 @@ var ts; return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { - return parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function parseTypeReference() { @@ -33634,14 +33760,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return ts.nodeIsMissing(node.typeName); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: { + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -33679,12 +33805,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 27 /* CommaToken */ || - token() === 19 /* CloseBraceToken */ || - token() === 21 /* CloseParenToken */ || - token() === 31 /* GreaterThanToken */ || - token() === 63 /* EqualsToken */ || - token() === 51 /* BarToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */ || + token() === 19 /* SyntaxKind.CloseBraceToken */ || + token() === 21 /* SyntaxKind.CloseParenToken */ || + token() === 31 /* SyntaxKind.GreaterThanToken */ || + token() === 63 /* SyntaxKind.EqualsToken */ || + token() === 51 /* SyntaxKind.BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } else { @@ -33696,8 +33822,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); if (lookAhead(nextTokenIsOpenParen)) { nextToken(); - var parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */ | 32 /* SignatureFlags.JSDoc */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc); } return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), /*typeArguments*/ undefined), pos); @@ -33705,9 +33831,9 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */ || token() === 103 /* SyntaxKind.NewKeyword */) { name = parseIdentifierName(); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); } return finishNode(factory.createParameterDeclaration( /*modifiers*/ undefined, @@ -33720,15 +33846,15 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(141 /* ModuleKeyword */)) { + if (parseOptional(141 /* SyntaxKind.ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { switch (token()) { - case 19 /* CloseBraceToken */: - case 1 /* EndOfFileToken */: - case 27 /* CommaToken */: - case 5 /* WhitespaceTrivia */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 1 /* SyntaxKind.EndOfFileToken */: + case 27 /* SyntaxKind.CommaToken */: + case 5 /* SyntaxKind.WhitespaceTrivia */: break terminate; default: nextTokenJSDoc(); @@ -33737,13 +33863,13 @@ var ts; scanner.setInJSDocType(false); return finishNode(moduleTag, pos); } - var hasDotDotDot = parseOptional(25 /* DotDotDotToken */); + var hasDotDotDot = parseOptional(25 /* SyntaxKind.DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -33751,7 +33877,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(112 /* TypeOfKeyword */); + parseExpected(112 /* SyntaxKind.TypeOfKeyword */); var entityName = parseEntityName(/*allowReservedWords*/ true); // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression. var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; @@ -33763,7 +33889,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -33782,21 +33908,21 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); } function parseTypeParameters() { - if (token() === 29 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (token() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function isStartOfParameter(isJSDocParameter) { - return token() === 25 /* DotDotDotToken */ || + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 59 /* AtToken */ || + token() === 59 /* SyntaxKind.AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseNameOfParameter(modifiers) { @@ -33820,7 +33946,7 @@ var ts; // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later // complaining about the use of the keywords. - return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */; + return isBindingIdentifier() || token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function parseParameter(inOuterAwaitContext) { return parseParameterWorker(inOuterAwaitContext); @@ -33835,8 +33961,8 @@ var ts; // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. - var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); - if (token() === 108 /* ThisKeyword */) { + var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators); + if (token() === 108 /* SyntaxKind.ThisKeyword */) { var node_1 = factory.createParameterDeclaration(decorators, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, parseTypeAnnotation(), @@ -33849,11 +33975,11 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var modifiers = combineDecoratorsAndModifiers(decorators, parseModifiers()); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); if (!allowAmbiguity && !isParameterNameStart()) { return undefined; } - var node = withJSDoc(finishNode(factory.createParameterDeclaration(modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createParameterDeclaration(modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* SyntaxKind.QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); topLevel = savedTopLevel; return node; } @@ -33863,16 +33989,16 @@ var ts; } } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 38 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* SyntaxKind.EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(58 /* ColonToken */)) { + else if (parseOptional(58 /* SyntaxKind.ColonToken */)) { return true; } - else if (isType && token() === 38 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */)); nextToken(); return true; } @@ -33894,11 +34020,11 @@ var ts; // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); - setYieldContext(!!(flags & 1 /* Yield */)); - setAwaitContext(!!(flags & 2 /* Await */)); - var parameters = flags & 32 /* JSDoc */ ? - parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) : - parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); + var parameters = flags & 32 /* SignatureFlags.JSDoc */ ? + parseDelimitedList(17 /* ParsingContext.JSDocParameters */, parseJSDocParameter) : + parseDelimitedList(16 /* ParsingContext.Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); return parameters; @@ -33917,17 +34043,17 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { return createMissingList(); } var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return parameters; } function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -33936,20 +34062,20 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 175 /* ConstructSignature */) { - parseExpected(103 /* NewKeyword */); + if (kind === 175 /* SyntaxKind.ConstructSignature */) { + parseExpected(103 /* SyntaxKind.NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 174 /* CallSignature */ + var node = kind === 174 /* SyntaxKind.CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); } function isIndexSignature() { - return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* SyntaxKind.OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -33969,7 +34095,7 @@ var ts; // [] // nextToken(); - if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -33988,21 +34114,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 57 /* QuestionToken */) { + if (token() !== 57 /* SyntaxKind.QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */; } function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) { - var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); + var parameters = parseBracketedList(16 /* ParsingContext.Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */); var type = parseTypeAnnotation(); parseTypeMemberSemicolon(); var node = factory.createIndexSignature(modifiers, parameters, type); @@ -34011,14 +34137,14 @@ var ts; } function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); var node; - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type); } else { @@ -34027,7 +34153,7 @@ var ts; // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === 63 /* EqualsToken */) + if (token() === 63 /* SyntaxKind.EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -34035,10 +34161,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 136 /* GetKeyword */ || - token() === 149 /* SetKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 136 /* SyntaxKind.GetKeyword */ || + token() === 149 /* SyntaxKind.SetKeyword */) { return true; } var idToken = false; @@ -34048,7 +34174,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -34059,30 +34185,30 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 57 /* QuestionToken */ || - token() === 58 /* ColonToken */ || - token() === 27 /* CommaToken */ || + return token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || + token() === 58 /* SyntaxKind.ColonToken */ || + token() === 27 /* SyntaxKind.CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(174 /* CallSignature */); + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { + return parseSignatureMember(174 /* SyntaxKind.CallSignature */); } - if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(175 /* ConstructSignature */); + if (token() === 103 /* SyntaxKind.NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(175 /* SyntaxKind.ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SyntaxKind.GetAccessor */, 4 /* SignatureFlags.Type */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SyntaxKind.SetAccessor */, 4 /* SignatureFlags.Type */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -34091,16 +34217,16 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; + return token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 24 /* DotToken */; + return nextToken() === 24 /* SyntaxKind.DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 20 /* OpenParenToken */: - case 29 /* LessThanToken */: - case 24 /* DotToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 24 /* SyntaxKind.DotToken */: return true; } return false; @@ -34111,9 +34237,9 @@ var ts; } function parseObjectTypeMembers() { var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -34122,51 +34248,51 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 145 /* ReadonlyKeyword */; + if (token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { + return nextToken() === 145 /* SyntaxKind.ReadonlyKeyword */; } - if (token() === 145 /* ReadonlyKeyword */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; + return token() === 22 /* SyntaxKind.OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* SyntaxKind.InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(101 /* InKeyword */); + parseExpected(101 /* SyntaxKind.InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos); } function parseMappedType() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var readonlyToken; - if (token() === 145 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 145 /* ReadonlyKeyword */) { - parseExpected(145 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + parseExpected(145 /* SyntaxKind.ReadonlyKeyword */); } } - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; - parseExpected(23 /* CloseBracketToken */); + var nameType = parseOptional(127 /* SyntaxKind.AsKeyword */) ? parseType() : undefined; + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var questionToken; - if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 57 /* SyntaxKind.QuestionToken */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { questionToken = parseTokenNode(); - if (questionToken.kind !== 57 /* QuestionToken */) { - parseExpected(57 /* QuestionToken */); + if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { + parseExpected(57 /* SyntaxKind.QuestionToken */); } } var type = parseTypeAnnotation(); parseSemicolon(); - var members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + var members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(25 /* DotDotDotToken */)) { + if (parseOptional(25 /* SyntaxKind.DotDotDotToken */)) { return finishNode(factory.createRestTypeNode(parseType()), pos); } var type = parseType(); @@ -34179,10 +34305,10 @@ var ts; return type; } function isNextTokenColonOrQuestionColon() { - return nextToken() === 58 /* ColonToken */ || (token() === 57 /* QuestionToken */ && nextToken() === 58 /* ColonToken */); + return nextToken() === 58 /* SyntaxKind.ColonToken */ || (token() === 57 /* SyntaxKind.QuestionToken */ && nextToken() === 58 /* SyntaxKind.ColonToken */); } function isTupleElementName() { - if (token() === 25 /* DotDotDotToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */) { return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon(); } return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon(); @@ -34191,10 +34317,10 @@ var ts; if (lookAhead(isTupleElementName)) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); - parseExpected(58 /* ColonToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var type = parseTupleElementType(); var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -34203,21 +34329,21 @@ var ts; } function parseTupleType() { var pos = getNodePos(); - return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */)), pos); + return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* ParsingContext.TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */)), pos); } function parseParenthesizedType() { var pos = getNodePos(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createParenthesizedType(type), pos); } function parseModifiersForConstructorType() { var modifiers; - if (token() === 126 /* AbstractKeyword */) { + if (token() === 126 /* SyntaxKind.AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* SyntaxKind.AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -34226,10 +34352,10 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(103 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* SyntaxKind.NewKeyword */); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(38 /* SyntaxKind.EqualsGreaterThanToken */, /*isType*/ false); var node = isConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory.createFunctionTypeNode(typeParameters, parameters, type); @@ -34239,34 +34365,34 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 24 /* DotToken */ ? undefined : node; + return token() === 24 /* SyntaxKind.DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { var pos = getNodePos(); if (negative) { nextToken(); } - var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? + var expression = token() === 110 /* SyntaxKind.TrueKeyword */ || token() === 95 /* SyntaxKind.FalseKeyword */ || token() === 104 /* SyntaxKind.NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { - expression = finishNode(factory.createPrefixUnaryExpression(40 /* MinusToken */, expression), pos); + expression = finishNode(factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, expression), pos); } return finishNode(factory.createLiteralTypeNode(expression), pos); } function isStartOfTypeOfImportType() { nextToken(); - return token() === 100 /* ImportKeyword */; + return token() === 100 /* SyntaxKind.ImportKeyword */; } function parseImportTypeAssertions() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - parseExpected(129 /* AssertKeyword */); - parseExpected(58 /* ColonToken */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); var clause = parseAssertClause(/*skipAssertKeyword*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -34275,89 +34401,89 @@ var ts; return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos); } function parseImportType() { - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(112 /* TypeOfKeyword */); - parseExpected(100 /* ImportKeyword */); - parseExpected(20 /* OpenParenToken */); + var isTypeOf = parseOptional(112 /* SyntaxKind.TypeOfKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); var assertions; - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { assertions = parseImportTypeAssertions(); } - parseExpected(21 /* CloseParenToken */); - var qualifier = parseOptional(24 /* DotToken */) ? parseEntityNameOfTypeReference() : undefined; + parseExpected(21 /* SyntaxKind.CloseParenToken */); + var qualifier = parseOptional(24 /* SyntaxKind.DotToken */) ? parseEntityNameOfTypeReference() : undefined; var typeArguments = parseTypeArgumentsOfTypeReference(); return finishNode(factory.createImportTypeNode(type, assertions, qualifier, typeArguments, isTypeOf), pos); } function nextTokenIsNumericOrBigIntLiteral() { nextToken(); - return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; + return token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 151 /* SymbolKeyword */: - case 133 /* BooleanKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 66 /* AsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return parseJSDocAllType(); - case 60 /* QuestionQuestionToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // If there is '??', treat it as prefix-'?' in JSDoc type. scanner.reScanQuestionToken(); // falls through - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseJSDocFunctionType(); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return parseLiteralTypeNode(); - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseTokenNode(); - case 108 /* ThisKeyword */: { + case 108 /* SyntaxKind.ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseTupleType(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedType(); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportType(); - case 128 /* AssertsKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateType(); default: return parseTypeReference(); @@ -34365,48 +34491,48 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 145 /* ReadonlyKeyword */: - case 151 /* SymbolKeyword */: - case 154 /* UniqueKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 112 /* TypeOfKeyword */: - case 143 /* NeverKeyword */: - case 18 /* OpenBraceToken */: - case 22 /* OpenBracketToken */: - case 29 /* LessThanToken */: - case 51 /* BarToken */: - case 50 /* AmpersandToken */: - case 103 /* NewKeyword */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 148 /* ObjectKeyword */: - case 41 /* AsteriskToken */: - case 57 /* QuestionToken */: - case 53 /* ExclamationToken */: - case 25 /* DotDotDotToken */: - case 137 /* InferKeyword */: - case 100 /* ImportKeyword */: - case 128 /* AssertsKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 51 /* SyntaxKind.BarToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 103 /* SyntaxKind.NewKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 41 /* SyntaxKind.AsteriskToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 137 /* SyntaxKind.InferKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: return true; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return !inStartOfParameter; - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -34416,18 +34542,18 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* SyntaxKind.CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var pos = getNodePos(); var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: nextToken(); type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos); break; - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: // If next token is start of a type we have a conditional type if (lookAhead(nextTokenIsStartOfType)) { return type; @@ -34435,15 +34561,15 @@ var ts; nextToken(); type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos); break; - case 22 /* OpenBracketToken */: - parseExpected(22 /* OpenBracketToken */); + case 22 /* SyntaxKind.OpenBracketToken */: + parseExpected(22 /* SyntaxKind.OpenBracketToken */); if (isStartOfType()) { var indexType = parseType(); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos); } else { - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createArrayTypeNode(type), pos); } break; @@ -34459,9 +34585,9 @@ var ts; return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos); } function tryParseConstraintOfInferType() { - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { var constraint = disallowConditionalTypesAnd(parseType); - if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) { + if (inDisallowConditionalTypesContext() || token() !== 57 /* SyntaxKind.QuestionToken */) { return constraint; } } @@ -34475,17 +34601,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(137 /* InferKeyword */); + parseExpected(137 /* SyntaxKind.InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 140 /* KeyOfKeyword */: - case 154 /* UniqueKeyword */: - case 145 /* ReadonlyKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: return parseTypeOperator(operator); - case 137 /* InferKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return parseInferType(); } return allowConditionalTypesAnd(parsePostfixTypeOrHigher); @@ -34514,7 +34640,7 @@ var ts; } function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) { var pos = getNodePos(); - var isUnionType = operator === 51 /* BarToken */; + var isUnionType = operator === 51 /* SyntaxKind.BarToken */; var hasLeadingOperator = parseOptional(operator); var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType(); @@ -34528,35 +34654,35 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(50 /* AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); + return parseUnionOrIntersectionType(50 /* SyntaxKind.AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(51 /* BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); + return parseUnionOrIntersectionType(51 /* SyntaxKind.BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); } function nextTokenIsNewKeyword() { nextToken(); - return token() === 103 /* NewKeyword */; + return token() === 103 /* SyntaxKind.NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return true; } - if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 103 /* NewKeyword */ || - token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* SyntaxKind.NewKeyword */ || + token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 108 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* SyntaxKind.ThisKeyword */) { nextToken(); return true; } - if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -34566,7 +34692,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */) { // ( ) // ( ... return true; @@ -34574,17 +34700,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || token() === 63 /* SyntaxKind.EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 21 /* CloseParenToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */) { nextToken(); - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -34605,65 +34731,65 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); - var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* SyntaxKind.AssertsKeyword */); + var parameterName = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(139 /* SyntaxKind.IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { - if (contextFlags & 40960 /* TypeExcludesFlags */) { - return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType); + if (contextFlags & 40960 /* NodeFlags.TypeExcludesFlags */) { + return doOutsideOfContext(40960 /* NodeFlags.TypeExcludesFlags */, parseType); } if (isStartOfFunctionTypeOrConstructorType()) { return parseFunctionOrConstructorType(); } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { + if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = disallowConditionalTypesAnd(parseType); - parseExpected(57 /* QuestionToken */); + parseExpected(57 /* SyntaxKind.QuestionToken */); var trueType = allowConditionalTypesAnd(parseType); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var falseType = allowConditionalTypesAnd(parseType); return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos); } return type; } function parseTypeAnnotation() { - return parseOptional(58 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* SyntaxKind.ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 20 /* OpenParenToken */: - case 22 /* OpenBracketToken */: - case 18 /* OpenBraceToken */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 103 /* NewKeyword */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 79 /* Identifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 20 /* SyntaxKind.OpenParenToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 103 /* SyntaxKind.NewKeyword */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 79 /* SyntaxKind.Identifier */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -34674,19 +34800,19 @@ var ts; return true; } switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 29 /* LessThanToken */: - case 132 /* AwaitKeyword */: - case 125 /* YieldKeyword */: - case 80 /* PrivateIdentifier */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 132 /* SyntaxKind.AwaitKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: + case 80 /* SyntaxKind.PrivateIdentifier */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -34704,10 +34830,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 18 /* OpenBraceToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && - token() !== 59 /* AtToken */ && + return token() !== 18 /* SyntaxKind.OpenBraceToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && + token() !== 59 /* SyntaxKind.AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -34722,7 +34848,7 @@ var ts; var pos = getNodePos(); var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); var operatorToken; - while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(27 /* SyntaxKind.CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos); } if (saveDecoratorContext) { @@ -34731,7 +34857,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined; + return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined; } function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) { // AssignmentExpression[in,yield]: @@ -34773,11 +34899,11 @@ var ts; // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. var pos = getNodePos(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -34793,7 +34919,7 @@ var ts; return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction); } function isYieldExpression() { - if (token() === 125 /* YieldKeyword */) { + if (token() === 125 /* SyntaxKind.YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -34829,8 +34955,8 @@ var ts; // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos); + (token() === 41 /* SyntaxKind.AsteriskToken */ || isStartOfExpression())) { + return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* SyntaxKind.AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos); } else { // if the next token is not on the same line as yield. or we don't have an '*' or @@ -34839,7 +34965,7 @@ var ts; } } function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) { - ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* SyntaxKind.EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var parameter = factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, identifier, @@ -34848,14 +34974,14 @@ var ts; /*initializer*/ undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction); var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { + if (triState === 0 /* Tristate.False */) { // It's definitely not a parenthesized arrow function expression. return undefined; } @@ -34863,7 +34989,7 @@ var ts; // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. - return triState === 1 /* True */ ? + return triState === 1 /* Tristate.True */ ? parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) : tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); }); } @@ -34872,44 +34998,44 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */ || token() === 131 /* SyntaxKind.AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. - return 1 /* True */; + return 1 /* Tristate.True */; } // Definitely not a parenthesized arrow function. - return 0 /* False */; + return 0 /* Tristate.False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; + return 0 /* Tristate.False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { - return 0 /* False */; + if (token() !== 20 /* SyntaxKind.OpenParenToken */ && token() !== 29 /* SyntaxKind.LessThanToken */) { + return 0 /* Tristate.False */; } } var first = token(); var second = nextToken(); - if (first === 20 /* OpenParenToken */) { - if (second === 21 /* CloseParenToken */) { + if (first === 20 /* SyntaxKind.OpenParenToken */) { + if (second === 21 /* SyntaxKind.CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 38 /* EqualsGreaterThanToken */: - case 58 /* ColonToken */: - case 18 /* OpenBraceToken */: - return 1 /* True */; + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 58 /* SyntaxKind.ColonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + return 1 /* Tristate.True */; default: - return 0 /* False */; + return 0 /* Tristate.False */; } } // If encounter "([" or "({", this could be the start of a binding pattern. @@ -34918,85 +35044,85 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { - return 2 /* Unknown */; + if (second === 22 /* SyntaxKind.OpenBracketToken */ || second === 18 /* SyntaxKind.OpenBraceToken */) { + return 2 /* Tristate.Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 25 /* DotDotDotToken */) { - return 1 /* True */; + if (second === 25 /* SyntaxKind.DotDotDotToken */) { + return 1 /* Tristate.True */; } // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { - if (nextToken() === 127 /* AsKeyword */) { + if (ts.isModifierKind(second) && second !== 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (nextToken() === 127 /* SyntaxKind.AsKeyword */) { // https://github.com/microsoft/TypeScript/issues/44466 - return 0 /* False */; + return 0 /* Tristate.False */; } - return 1 /* True */; + return 1 /* Tristate.True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 108 /* ThisKeyword */) { - return 0 /* False */; + if (!isIdentifier() && second !== 108 /* SyntaxKind.ThisKeyword */) { + return 0 /* Tristate.False */; } switch (nextToken()) { - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - return 1 /* True */; - case 57 /* QuestionToken */: + return 1 /* Tristate.True */; + case 57 /* SyntaxKind.QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { - return 1 /* True */; + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 63 /* SyntaxKind.EqualsToken */ || token() === 21 /* SyntaxKind.CloseParenToken */) { + return 1 /* Tristate.True */; } // Otherwise it is definitely not a lambda. - return 0 /* False */; - case 27 /* CommaToken */: - case 63 /* EqualsToken */: - case 21 /* CloseParenToken */: + return 0 /* Tristate.False */; + case 27 /* SyntaxKind.CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 21 /* SyntaxKind.CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } // It is definitely not an arrow function - return 0 /* False */; + return 0 /* Tristate.False */; } else { - ts.Debug.assert(first === 29 /* LessThanToken */); + ts.Debug.assert(first === 29 /* SyntaxKind.LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { - return 0 /* False */; + return 0 /* Tristate.False */; } // JSX overrides - if (languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* LanguageVariant.JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 94 /* ExtendsKeyword */) { + if (third === 94 /* SyntaxKind.ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 63 /* EqualsToken */: - case 31 /* GreaterThanToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: return false; default: return true; } } - else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) { + else if (third === 27 /* SyntaxKind.CommaToken */ || third === 63 /* SyntaxKind.EqualsToken */) { return true; } return false; }); if (isArrowFunctionInJsx) { - return 1 /* True */; + return 1 /* Tristate.True */; } - return 0 /* False */; + return 0 /* Tristate.False */; } // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } } function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { @@ -35012,11 +35138,11 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 131 /* AsyncKeyword */) { - if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* Tristate.True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier); } } @@ -35026,26 +35152,26 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { - return 0 /* False */; + if (scanner.hasPrecedingLineBreak() || token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 0 /* Tristate.False */; } // Check for un-parenthesized AsyncArrowFunction - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return 1 /* True */; + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 1 /* Tristate.True */; } } - return 0 /* False */; + return 0 /* Tristate.False */; } function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -35055,7 +35181,7 @@ var ts; // close paren. var typeParameters = parseTypeParameters(); var parameters; - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { if (!allowAmbiguity) { return undefined; } @@ -35072,12 +35198,12 @@ var ts; else { parameters = parseParametersWorker(isAsync, allowAmbiguity); } - if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) { + if (!parseExpected(21 /* SyntaxKind.CloseParenToken */) && !allowAmbiguity) { return undefined; } } - var hasReturnColon = token() === 58 /* ColonToken */; - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var hasReturnColon = token() === 58 /* SyntaxKind.ColonToken */; + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; } @@ -35092,19 +35218,19 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var unwrappedType = type; - while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* ParenthesizedType */) { + while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* SyntaxKind.ParenthesizedType */) { unwrappedType = unwrappedType.type; // Skip parens if need be } var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType); - if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* SyntaxKind.EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* SyntaxKind.OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = (lastToken === 38 /* SyntaxKind.EqualsGreaterThanToken */ || lastToken === 18 /* SyntaxKind.OpenBraceToken */) ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction) : parseIdentifier(); // Given: @@ -35128,7 +35254,7 @@ var ts; // Then allow the arrow function, and treat the second colon as terminating // the conditional expression. It's okay to do this because this code would // be a syntax error in JavaScript (as the second colon shouldn't be there). - if (token() !== 58 /* ColonToken */) { + if (token() !== 58 /* SyntaxKind.ColonToken */) { return undefined; } } @@ -35136,12 +35262,12 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) { - if (token() === 18 /* OpenBraceToken */) { - return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { + return parseFunctionBlock(isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */); } - if (token() !== 26 /* SemicolonToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && + if (token() !== 26 /* SyntaxKind.SemicolonToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -35158,7 +35284,7 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error. - return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */)); + return parseFunctionBlock(16 /* SignatureFlags.IgnoreMissingOpenBrace */ | (isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */)); } var savedTopLevel = topLevel; topLevel = false; @@ -35170,16 +35296,16 @@ var ts; } function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* SyntaxKind.ColonToken */), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) - : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -35187,7 +35313,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 101 /* InKeyword */ || t === 160 /* OfKeyword */; + return t === 101 /* SyntaxKind.InKeyword */ || t === 160 /* SyntaxKind.OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -35216,16 +35342,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 101 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* SyntaxKind.InKeyword */ && inDisallowInContext()) { break; } - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -35246,7 +35372,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 101 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* SyntaxKind.InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -35274,7 +35400,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 132 /* AwaitKeyword */) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -35307,7 +35433,7 @@ var ts; if (isUpdateExpression()) { var pos = getNodePos(); var updateExpression = parseUpdateExpression(); - return token() === 42 /* AsteriskAsteriskToken */ ? + return token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) : updateExpression; } @@ -35324,10 +35450,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 42 /* AsteriskAsteriskToken */) { + if (token() === 42 /* SyntaxKind.AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 211 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -35352,23 +35478,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parsePrefixUnaryExpression(); - case 89 /* DeleteKeyword */: + case 89 /* SyntaxKind.DeleteKeyword */: return parseDeleteExpression(); - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return parseTypeOfExpression(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseVoidExpression(); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 132 /* AwaitKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -35391,18 +35517,18 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 132 /* AwaitKeyword */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: return false; - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (languageVariant !== 1 /* JSX */) { + if (languageVariant !== 1 /* LanguageVariant.JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. @@ -35423,17 +35549,17 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + if (token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) { var pos = getNodePos(); return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos); } - else if (languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (languageVariant === 1 /* LanguageVariant.JSX */ && token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { var operator = token(); nextToken(); return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos); @@ -35474,29 +35600,29 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 100 /* ImportKeyword */) { + if (token() === 100 /* SyntaxKind.ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); - sourceFlags |= 4194304 /* PossiblyContainsImportMeta */; + expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos); + sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression or OptionalExpression. As such, we need to consume the rest @@ -35558,19 +35684,22 @@ var ts; function parseSuperExpression() { var pos = getNodePos(); var expression = parseTokenNode(); - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); + if (!isTemplateStartOfTaggedTemplate()) { + expression = factory.createExpressionWithTypeArguments(expression, typeArguments); + } } } - if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 24 /* SyntaxKind.DotToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* SyntaxKind.DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); // private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } @@ -35578,11 +35707,11 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 280 /* JsxOpeningElement */) { + if (opening.kind === 280 /* SyntaxKind.JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = void 0; var lastChild = children[children.length - 1]; - if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* JsxElement */ + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, @@ -35608,11 +35737,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 283 /* JsxOpeningFragment */) { + else if (opening.kind === 283 /* SyntaxKind.JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 279 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 279 /* SyntaxKind.JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -35623,11 +35752,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 29 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* SyntaxKind.LessThanToken */) { var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos_1); }); if (invalidElement) { - var operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false); + var operatorToken = createMissingNode(27 /* SyntaxKind.CommaToken */, /*reportAtCurrentPosition*/ false); ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0); parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element); return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos); @@ -35637,13 +35766,13 @@ var ts; } function parseJsxText() { var pos = getNodePos(); - var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* JsxTextAllWhiteSpaces */); + var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* SyntaxKind.JsxTextAllWhiteSpaces */); currentToken = scanner.scanJsxToken(); return finishNode(node, pos); } function parseJsxChild(openingTag, token) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // If we hit EOF, issue the error at the tag that lacks the closing element // rather than at the end of the file (which is useless) if (ts.isJsxOpeningFragment(openingTag)) { @@ -35657,15 +35786,15 @@ var ts; parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 30 /* LessThanSlashToken */: - case 7 /* ConflictMarkerTrivia */: + case 30 /* SyntaxKind.LessThanSlashToken */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: return undefined; - case 11 /* JsxText */: - case 12 /* JsxTextAllWhiteSpaces */: + case 11 /* SyntaxKind.JsxText */: + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return parseJsxText(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); @@ -35675,14 +35804,14 @@ var ts; var list = []; var listPos = getNodePos(); var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; + parsingContext |= 1 << 14 /* ParsingContext.JsxChildren */; while (true) { var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken()); if (!child) break; list.push(child); if (ts.isJsxOpeningElement(openingTag) - && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* JsxElement */ + && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { // stop after parsing a mismatched child like
...(
) in order to reattach the
higher @@ -35694,21 +35823,21 @@ var ts; } function parseJsxAttributes() { var pos = getNodePos(); - return finishNode(factory.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos); + return finishNode(factory.createJsxAttributes(parseList(13 /* ParsingContext.JsxAttributes */, parseJsxAttribute)), pos); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); - if (token() === 31 /* GreaterThanToken */) { + parseExpected(29 /* SyntaxKind.LessThanToken */); + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // See below for explanation of scanJsxText scanJsxText(); return finishNode(factory.createJsxOpeningFragment(), pos); } var tagName = parseJsxElementName(); - var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; + var typeArguments = (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; var attributes = parseJsxAttributes(); var node; - if (token() === 31 /* GreaterThanToken */) { + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors @@ -35716,8 +35845,8 @@ var ts; node = factory.createJsxOpeningElement(tagName, typeArguments, attributes); } else { - parseExpected(43 /* SlashToken */); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + parseExpected(43 /* SyntaxKind.SlashToken */); + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35738,39 +35867,39 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 108 /* ThisKeyword */ ? + var expression = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); } return expression; } function parseJsxExpression(inExpressionContext) { var pos = getNodePos(); - if (!parseExpected(18 /* OpenBraceToken */)) { + if (!parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { return undefined; } var dotDotDotToken; var expression; - if (token() !== 19 /* CloseBraceToken */) { - dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + if (token() !== 19 /* SyntaxKind.CloseBraceToken */) { + dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); // Only an AssignmentExpression is valid here per the JSX spec, // but we can unambiguously parse a comma sequence and provide // a better error message in grammar checking. expression = parseExpression(); } if (inExpressionContext) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { - if (parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(19 /* SyntaxKind.CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { scanJsxText(); } } return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos); } function parseJsxAttribute() { - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); @@ -35778,14 +35907,14 @@ var ts; return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos); } function parseJsxAttributeValue() { - if (token() === 63 /* EqualsToken */) { - if (scanJsxAttributeValue() === 10 /* StringLiteral */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { + if (scanJsxAttributeValue() === 10 /* SyntaxKind.StringLiteral */) { return parseLiteralNode(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxExpression(/*inExpressionContext*/ true); } - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } parseErrorAtCurrentToken(ts.Diagnostics.or_JSX_element_expected); @@ -35794,17 +35923,17 @@ var ts; } function parseJsxSpreadAttribute() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - parseExpected(25 /* DotDotDotToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseExpression(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); var tagName = parseJsxElementName(); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { nextToken(); @@ -35817,11 +35946,11 @@ var ts; } function parseJsxClosingFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35834,36 +35963,36 @@ var ts; } function parseTypeAssertion() { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); + parseExpected(29 /* SyntaxKind.LessThanToken */); var type = parseType(); - parseExpected(31 /* GreaterThanToken */); + parseExpected(31 /* SyntaxKind.GreaterThanToken */); var expression = parseSimpleUnaryExpression(); return finishNode(factory.createTypeAssertion(type, expression), pos); } function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) - || token() === 22 /* OpenBracketToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ || isTemplateStartOfTaggedTemplate(); } function isStartOfOptionalPropertyOrElementAccessChain() { - return token() === 28 /* QuestionDotToken */ + return token() === 28 /* SyntaxKind.QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); } function tryReparseOptionalChain(node) { - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { return true; } // check for an optional chain in a non-null expression if (ts.isNonNullExpression(node)) { var expr = node.expression; - while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) { + while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* NodeFlags.OptionalChain */)) { expr = expr.expression; } - if (expr.flags & 32 /* OptionalChain */) { + if (expr.flags & 32 /* NodeFlags.OptionalChain */) { // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. while (ts.isNonNullExpression(node)) { - node.flags |= 32 /* OptionalChain */; + node.flags |= 32 /* NodeFlags.OptionalChain */; node = node.expression; } return true; @@ -35880,12 +36009,17 @@ var ts; if (isOptionalChain && ts.isPrivateIdentifier(propertyAccess.name)) { parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers); } + if (ts.isExpressionWithTypeArguments(expression) && expression.typeArguments) { + var pos_2 = expression.typeArguments.pos - 1; + var end = ts.skipTrivia(sourceText, expression.typeArguments.end) + 1; + parseErrorAt(pos_2, end, ts.Diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access); + } return finishNode(propertyAccess, pos); } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; - if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* SyntaxKind.CloseBracketToken */) { + argumentExpression = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -35894,7 +36028,7 @@ var ts; } argumentExpression = argument; } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ? factory.createElementAccessChain(expression, questionDotToken, argumentExpression) : factory.createElementAccessExpression(expression, argumentExpression); @@ -35905,30 +36039,30 @@ var ts; var questionDotToken = void 0; var isPropertyAccess = false; if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { - questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + questionDotToken = parseExpectedToken(28 /* SyntaxKind.QuestionDotToken */); isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); } else { - isPropertyAccess = parseOptional(24 /* DotToken */); + isPropertyAccess = parseOptional(24 /* SyntaxKind.DotToken */); } if (isPropertyAccess) { expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { expression = parseElementAccessExpressionRest(pos, expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments - expression = !questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */ ? + expression = !questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) : parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined); continue; } if (!questionDotToken) { - if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); expression = finishNode(factory.createNonNullExpression(expression), pos); continue; @@ -35943,14 +36077,14 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; + return token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || token() === 15 /* SyntaxKind.TemplateHead */; } function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) { - var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* NoSubstitutionTemplateLiteral */ ? + var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(/*isTaggedTemplate*/ true)); - if (questionDotToken || tag.flags & 32 /* OptionalChain */) { - tagExpression.flags |= 32 /* OptionalChain */; + if (questionDotToken || tag.flags & 32 /* NodeFlags.OptionalChain */) { + tagExpression.flags |= 32 /* NodeFlags.OptionalChain */; } tagExpression.questionDotToken = questionDotToken; return finishNode(tagExpression, pos); @@ -35959,7 +36093,7 @@ var ts; while (true) { expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true); var typeArguments = void 0; - var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); + var questionDotToken = parseOptionalToken(28 /* SyntaxKind.QuestionDotToken */); if (questionDotToken) { typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { @@ -35967,9 +36101,9 @@ var ts; continue; } } - if (typeArguments || token() === 20 /* OpenParenToken */) { + if (typeArguments || token() === 20 /* SyntaxKind.OpenParenToken */) { // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments - if (!questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (!questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } @@ -35982,7 +36116,7 @@ var ts; } if (questionDotToken) { // We parsed `?.` but then failed to parse anything, so report a missing identifier here. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -35990,22 +36124,22 @@ var ts; return expression; } function parseArgumentList() { - parseExpected(20 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); + var result = parseDelimitedList(11 /* ParsingContext.ArgumentExpressions */, parseArgumentExpression); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) { + if ((contextFlags & 262144 /* NodeFlags.JavaScriptFile */) !== 0) { // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators. return undefined; } - if (reScanLessThanToken() !== 29 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* SyntaxKind.LessThanToken */) { return undefined; } nextToken(); - var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (reScanGreaterToken() !== 31 /* GreaterThanToken */) { + var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType); + if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -36019,17 +36153,17 @@ var ts; function canFollowTypeArgumentsInExpression() { switch (token()) { // These tokens can follow a type argument list in a call expression. - case 20 /* OpenParenToken */: // foo( - case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 15 /* TemplateHead */: // foo `...${100}...` + case 20 /* SyntaxKind.OpenParenToken */: // foo( + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* SyntaxKind.TemplateHead */: // foo `...${100}...` return true; // A type argument list followed by `<` never makes sense, and a type argument list followed // by `>` is ambiguous with a (re-scanned) `>>` operator, so we disqualify both. Also, in // this context, `+` and `-` are unary operators, not binary operators. - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: return false; } // We favor the type argument list interpretation when it is immediately followed by @@ -36038,24 +36172,24 @@ var ts; } function parsePrimaryExpression() { switch (token()) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return parseTokenNode(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedExpression(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseArrayLiteralExpression(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseObjectLiteralExpression(); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -36063,21 +36197,21 @@ var ts; break; } return parseFunctionExpression(); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassExpression(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionExpression(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateExpression(/* isTaggedTemplate */ false); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return parsePrivateIdentifier(); } return parseIdentifier(ts.Diagnostics.Expression_expected); @@ -36085,20 +36219,20 @@ var ts; function parseParenthesizedExpression() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc); } function parseSpreadElement() { var pos = getNodePos(); - parseExpected(25 /* DotDotDotToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { - return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : + return token() === 25 /* SyntaxKind.DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* SyntaxKind.CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); } function parseArgumentExpression() { @@ -36107,34 +36241,34 @@ var ts; function parseArrayLiteralExpression() { var pos = getNodePos(); var openBracketPosition = scanner.getTokenPos(); - var openBracketParsed = parseExpected(22 /* OpenBracketToken */); + var openBracketParsed = parseExpected(22 /* SyntaxKind.OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition); + var elements = parseDelimitedList(15 /* ParsingContext.ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpectedMatchingBrackets(22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, openBracketParsed, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (parseOptionalToken(25 /* DotDotDotToken */)) { + if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) { var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */, 0 /* SignatureFlags.None */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */, 0 /* SignatureFlags.None */); } - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - var exclamationToken = parseOptionalToken(53 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken); } // check if it is short-hand property assignment or normal property assignment @@ -36143,9 +36277,9 @@ var ts; // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var node; - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(63 /* EqualsToken */); + var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */); var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. @@ -36153,7 +36287,7 @@ var ts; node.equalsToken = equalsToken; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }); node = factory.createPropertyAssignment(name, initializer); } @@ -36167,10 +36301,10 @@ var ts; function parseObjectLiteralExpression() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var properties = parseDelimitedList(12 /* ParsingContext.ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -36184,17 +36318,17 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : parseOptionalBindingIdentifier(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlock(isGenerator | isAsync); setDecoratorContext(savedDecoratorContext); var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -36205,23 +36339,23 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(103 /* NewKeyword */); - if (parseOptional(24 /* DotToken */)) { + parseExpected(103 /* SyntaxKind.NewKeyword */); + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* SyntaxKind.NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false); var typeArguments; // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } - if (token() === 28 /* QuestionDotToken */) { + if (token() === 28 /* SyntaxKind.QuestionDotToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, ts.getTextOfNodeFromSourceText(sourceText, expression)); } - var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined; + var argumentList = token() === 20 /* SyntaxKind.OpenParenToken */ ? parseArgumentList() : undefined; return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos); } // STATEMENTS @@ -36229,13 +36363,13 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */, diagnosticMessage); if (openBraceParsed || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); - var statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); nextToken(); } @@ -36248,9 +36382,9 @@ var ts; } function parseFunctionBlock(flags, diagnosticMessage) { var savedYieldContext = inYieldContext(); - setYieldContext(!!(flags & 1 /* Yield */)); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); var savedAwaitContext = inAwaitContext(); - setAwaitContext(!!(flags & 2 /* Await */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); var savedTopLevel = topLevel; topLevel = false; // We may be in a [Decorator] context when parsing a function expression or @@ -36259,7 +36393,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage); + var block = parseBlock(!!(flags & 16 /* SignatureFlags.IgnoreMissingOpenBrace */), diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -36271,58 +36405,58 @@ var ts; function parseEmptyStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(26 /* SemicolonToken */); + parseExpected(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(99 /* IfKeyword */); + parseExpected(99 /* SyntaxKind.IfKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var thenStatement = parseStatement(); - var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + var elseStatement = parseOptional(91 /* SyntaxKind.ElseKeyword */) ? parseStatement() : undefined; return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(90 /* DoKeyword */); + parseExpected(90 /* SyntaxKind.DoKeyword */); var statement = parseStatement(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(26 /* SemicolonToken */); + parseOptional(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var statement = parseStatement(); return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(97 /* ForKeyword */); - var awaitToken = parseOptionalToken(132 /* AwaitKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(97 /* SyntaxKind.ForKeyword */); + var awaitToken = parseOptionalToken(132 /* SyntaxKind.AwaitKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var initializer; - if (token() !== 26 /* SemicolonToken */) { - if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { + if (token() !== 26 /* SyntaxKind.SemicolonToken */) { + if (token() === 113 /* SyntaxKind.VarKeyword */ || token() === 119 /* SyntaxKind.LetKeyword */ || token() === 85 /* SyntaxKind.ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -36330,26 +36464,26 @@ var ts; } } var node; - if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) { + if (awaitToken ? parseExpected(160 /* SyntaxKind.OfKeyword */) : parseOptional(160 /* SyntaxKind.OfKeyword */)) { var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(101 /* InKeyword */)) { + else if (parseOptional(101 /* SyntaxKind.InKeyword */)) { var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); } else { - parseExpected(26 /* SemicolonToken */); - var condition = token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var condition = token() !== 26 /* SyntaxKind.SemicolonToken */ && token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(26 /* SemicolonToken */); - var incrementor = token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var incrementor = token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36357,10 +36491,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 246 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); + parseExpected(kind === 246 /* SyntaxKind.BreakStatement */ ? 81 /* SyntaxKind.BreakKeyword */ : 86 /* SyntaxKind.ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 246 /* BreakStatement */ + var node = kind === 246 /* SyntaxKind.BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36368,7 +36502,7 @@ var ts; function parseReturnStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(105 /* ReturnKeyword */); + parseExpected(105 /* SyntaxKind.ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); @@ -36376,47 +36510,47 @@ var ts; function parseWithStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(116 /* WithKeyword */); + parseExpected(116 /* SyntaxKind.WithKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); - var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); + var statement = doInsideOfContext(33554432 /* NodeFlags.InWithStatement */, parseStatement); return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(82 /* CaseKeyword */); + parseExpected(82 /* SyntaxKind.CaseKeyword */); var expression = allowInAnd(parseExpression); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc); } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(88 /* DefaultKeyword */); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* SyntaxKind.CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var clauses = parseList(2 /* ParsingContext.SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createCaseBlock(clauses), pos); } function parseSwitchStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(107 /* SwitchKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(107 /* SyntaxKind.SwitchKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); var caseBlock = parseCaseBlock(); return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } @@ -36425,7 +36559,7 @@ var ts; // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(109 /* ThrowKeyword */); + parseExpected(109 /* SyntaxKind.ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' // directly as that might consume an expression on the following line. @@ -36445,25 +36579,25 @@ var ts; function parseTryStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(111 /* TryKeyword */); + parseExpected(111 /* SyntaxKind.TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 83 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* SyntaxKind.CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. var finallyBlock; - if (!catchClause || token() === 96 /* FinallyKeyword */) { - parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); + if (!catchClause || token() === 96 /* SyntaxKind.FinallyKeyword */) { + parseExpected(96 /* SyntaxKind.FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(83 /* CatchKeyword */); + parseExpected(83 /* SyntaxKind.CatchKeyword */); var variableDeclaration; - if (parseOptional(20 /* OpenParenToken */)) { + if (parseOptional(20 /* SyntaxKind.OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -36475,7 +36609,7 @@ var ts; function parseDebuggerStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(87 /* DebuggerKeyword */); + parseExpected(87 /* SyntaxKind.DebuggerKeyword */); parseSemicolon(); return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } @@ -36486,9 +36620,9 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var node; - var hasParen = token() === 20 /* OpenParenToken */; + var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */; var expression = allowInAnd(parseExpression); - if (ts.isIdentifier(expression) && parseOptional(58 /* ColonToken */)) { + if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) { node = factory.createLabeledStatement(expression, parseStatement()); } else { @@ -36509,25 +36643,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* SyntaxKind.ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* SyntaxKind.FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */ || token() === 10 /* SyntaxKind.StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -36550,44 +36684,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 157 /* GlobalKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; - case 100 /* ImportKeyword */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 79 /* SyntaxKind.Identifier */ || token() === 93 /* SyntaxKind.ExportKeyword */; + case 100 /* SyntaxKind.ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 93 /* ExportKeyword */: + return token() === 10 /* SyntaxKind.StringLiteral */ || token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 18 /* SyntaxKind.OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 93 /* SyntaxKind.ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 152 /* TypeKeyword */) { + if (currentToken_1 === 152 /* SyntaxKind.TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || - currentToken_1 === 127 /* AsKeyword */) { + if (currentToken_1 === 63 /* SyntaxKind.EqualsToken */ || currentToken_1 === 41 /* SyntaxKind.AsteriskToken */ || + currentToken_1 === 18 /* SyntaxKind.OpenBraceToken */ || currentToken_1 === 88 /* SyntaxKind.DefaultKeyword */ || + currentToken_1 === 127 /* SyntaxKind.AsKeyword */) { return true; } continue; - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: nextToken(); continue; default: @@ -36600,51 +36734,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 59 /* AtToken */: - case 26 /* SemicolonToken */: - case 18 /* OpenBraceToken */: - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 99 /* IfKeyword */: - case 90 /* DoKeyword */: - case 115 /* WhileKeyword */: - case 97 /* ForKeyword */: - case 86 /* ContinueKeyword */: - case 81 /* BreakKeyword */: - case 105 /* ReturnKeyword */: - case 116 /* WithKeyword */: - case 107 /* SwitchKeyword */: - case 109 /* ThrowKeyword */: - case 111 /* TryKeyword */: - case 87 /* DebuggerKeyword */: + case 59 /* SyntaxKind.AtToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 90 /* SyntaxKind.DoKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: + case 116 /* SyntaxKind.WithKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: + case 111 /* SyntaxKind.TryKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 85 /* ConstKeyword */: - case 93 /* ExportKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return isStartOfDeclaration(); - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 118 /* InterfaceKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 152 /* TypeKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -36654,7 +36788,7 @@ var ts; } function nextTokenIsBindingIdentifierOrStartOfDestructuring() { nextToken(); - return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; + return isBindingIdentifier() || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -36663,68 +36797,68 @@ var ts; } function parseStatement() { switch (token()) { - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: return parseEmptyStatement(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 119 /* LetKeyword */: + case 119 /* SyntaxKind.LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 99 /* IfKeyword */: + case 99 /* SyntaxKind.IfKeyword */: return parseIfStatement(); - case 90 /* DoKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return parseDoStatement(); - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return parseWhileStatement(); - case 97 /* ForKeyword */: + case 97 /* SyntaxKind.ForKeyword */: return parseForOrForInOrForOfStatement(); - case 86 /* ContinueKeyword */: - return parseBreakOrContinueStatement(245 /* ContinueStatement */); - case 81 /* BreakKeyword */: - return parseBreakOrContinueStatement(246 /* BreakStatement */); - case 105 /* ReturnKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + return parseBreakOrContinueStatement(245 /* SyntaxKind.ContinueStatement */); + case 81 /* SyntaxKind.BreakKeyword */: + return parseBreakOrContinueStatement(246 /* SyntaxKind.BreakStatement */); + case 105 /* SyntaxKind.ReturnKeyword */: return parseReturnStatement(); - case 116 /* WithKeyword */: + case 116 /* SyntaxKind.WithKeyword */: return parseWithStatement(); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return parseSwitchStatement(); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return parseThrowStatement(); - case 111 /* TryKeyword */: + case 111 /* SyntaxKind.TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return parseTryStatement(); - case 87 /* DebuggerKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: return parseDebuggerStatement(); - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: return parseDeclaration(); - case 131 /* AsyncKeyword */: - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 92 /* EnumKeyword */: - case 93 /* ExportKeyword */: - case 100 /* ImportKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 126 /* AbstractKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -36733,40 +36867,35 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 135 /* DeclareKeyword */; + return modifier.kind === 135 /* SyntaxKind.DeclareKeyword */; } function parseDeclaration() { - // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner - // if we can't reuse the declaration, so that we don't do this work twice? - // // `parseListElement` attempted to get the reused node at this position, // but the ambient context flag was not yet set, so the node appeared // not reusable in that context. - var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier); - if (isAmbient) { - var node = tryReuseAmbientDeclaration(); - if (node) { - return node; - } - } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(); + var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { + var node = tryReuseAmbientDeclaration(pos); + if (node) { + return node; + } for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); } else { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } - function tryReuseAmbientDeclaration() { - return doInsideOfContext(16777216 /* Ambient */, function () { - var node = currentNode(parsingContext); + function tryReuseAmbientDeclaration(pos) { + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { + var node = currentNode(parsingContext, pos); if (node) { return consumeNode(node); } @@ -36774,33 +36903,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 118 /* InterfaceKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* EnumKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 157 /* GlobalKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); switch (token()) { - case 88 /* DefaultKeyword */: - case 63 /* EqualsToken */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 63 /* SyntaxKind.EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 127 /* AsKeyword */: + case 127 /* SyntaxKind.AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36809,7 +36938,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(276 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -36820,38 +36949,44 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { - parseSemicolon(); - return; + if (token() !== 18 /* SyntaxKind.OpenBraceToken */) { + if (flags & 4 /* SignatureFlags.Type */) { + parseTypeMemberSemicolon(); + return; + } + if (canParseSemicolon()) { + parseSemicolon(); + return; + } } return parseFunctionBlock(flags, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { var pos = getNodePos(); - if (token() === 27 /* CommaToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */) { return finishNode(factory.createOmittedExpression(), pos); } - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierOrPattern(); var initializer = parseInitializer(); return finishNode(factory.createBindingElement(dotDotDotToken, /*propertyName*/ undefined, name, initializer), pos); } function parseObjectBindingElement() { var pos = getNodePos(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var tokenIsIdentifier = isBindingIdentifier(); var propertyName = parsePropertyName(); var name; - if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* SyntaxKind.ColonToken */) { name = propertyName; propertyName = undefined; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); name = parseIdentifierOrPattern(); } var initializer = parseInitializer(); @@ -36859,29 +36994,29 @@ var ts; } function parseObjectBindingPattern() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var elements = parseDelimitedList(9 /* ParsingContext.ObjectBindingElements */, parseObjectBindingElement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createObjectBindingPattern(elements), pos); } function parseArrayBindingPattern() { var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); - var elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(23 /* CloseBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); + var elements = parseDelimitedList(10 /* ParsingContext.ArrayBindingElements */, parseArrayBindingElement); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createArrayBindingPattern(elements), pos); } function isBindingIdentifierOrPrivateIdentifierOrPattern() { - return token() === 18 /* OpenBraceToken */ - || token() === 22 /* OpenBracketToken */ - || token() === 80 /* PrivateIdentifier */ + return token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 80 /* SyntaxKind.PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseObjectBindingPattern(); } return parseBindingIdentifier(privateIdentifierDiagnosticMessage); @@ -36894,8 +37029,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 79 /* Identifier */ && - token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && name.kind === 79 /* SyntaxKind.Identifier */ && + token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); @@ -36907,13 +37042,13 @@ var ts; var pos = getNodePos(); var flags = 0; switch (token()) { - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: break; - case 119 /* LetKeyword */: - flags |= 1 /* Let */; + case 119 /* SyntaxKind.LetKeyword */: + flags |= 1 /* NodeFlags.Let */; break; - case 85 /* ConstKeyword */: - flags |= 2 /* Const */; + case 85 /* SyntaxKind.ConstKeyword */: + flags |= 2 /* NodeFlags.Const */; break; default: ts.Debug.fail(); @@ -36929,19 +37064,19 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 160 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 160 /* SyntaxKind.OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); + declarations = parseDelimitedList(8 /* ParsingContext.VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); setDisallowInContext(savedDisallowIn); } return finishNode(factory.createVariableDeclarationList(declarations, flags), pos); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* SyntaxKind.CloseParenToken */; } function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) { var declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -36954,17 +37089,17 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. - var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */; + var name = modifierFlags & 512 /* ModifierFlags.Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = modifierFlags & 256 /* ModifierFlags.Async */ ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 1 /* ModifierFlags.Export */) setAwaitContext(/*value*/ true); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); setAwaitContext(savedAwaitContext); var node = factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -36972,10 +37107,10 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 134 /* ConstructorKeyword */) { - return parseExpected(134 /* ConstructorKeyword */); + if (token() === 134 /* SyntaxKind.ConstructorKeyword */) { + return parseExpected(134 /* SyntaxKind.ConstructorKeyword */); } - if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ && lookAhead(nextToken) === 20 /* SyntaxKind.OpenParenToken */) { return tryParse(function () { var literalNode = parseLiteralNode(); return literalNode.text === "constructor" ? literalNode : undefined; @@ -36986,9 +37121,9 @@ var ts; return tryParse(function () { if (parseConstructorName()) { var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */, ts.Diagnostics.or_expected); var node = factory.createConstructorDeclaration(modifiers, parameters, body); // Attach invalid nodes if they exist so that we can report them in the grammar checker. node.decorators = decorators; @@ -36999,11 +37134,11 @@ var ts; }); } function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) { - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); var node = factory.createMethodDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body); // An exclamation token on a method is invalid syntax and will be handled by the grammar checker @@ -37011,31 +37146,31 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) { - var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined; + var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* SyntaxKind.ExclamationToken */) : undefined; var type = parseTypeAnnotation(); - var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer); + var initializer = doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */ | 4096 /* NodeFlags.DisallowInContext */, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); var node = factory.createPropertyDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) { - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, /*exclamationToken*/ undefined, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); } - function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { + function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 172 /* GetAccessor */ + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(flags); + var node = kind === 172 /* SyntaxKind.GetAccessor */ ? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body) : factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors @@ -37046,7 +37181,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 59 /* AtToken */) { + if (token() === 59 /* SyntaxKind.AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -37063,7 +37198,7 @@ var ts; } nextToken(); } - if (token() === 41 /* AsteriskToken */) { + if (token() === 41 /* SyntaxKind.AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -37073,24 +37208,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 149 /* SetKeyword */ || idToken === 136 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 149 /* SyntaxKind.SetKeyword */ || idToken === 136 /* SyntaxKind.GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 20 /* OpenParenToken */: // Method declaration - case 29 /* LessThanToken */: // Generic Method declaration - case 53 /* ExclamationToken */: // Non-null assertion on property name - case 58 /* ColonToken */: // Type Annotation for declaration - case 63 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* SyntaxKind.OpenParenToken */: // Method declaration + case 29 /* SyntaxKind.LessThanToken */: // Generic Method declaration + case 53 /* SyntaxKind.ExclamationToken */: // Non-null assertion on property name + case 58 /* SyntaxKind.ColonToken */: // Type Annotation for declaration + case 63 /* SyntaxKind.EqualsToken */: // Initializer for declaration + case 57 /* SyntaxKind.QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -37104,7 +37239,7 @@ var ts; return false; } function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpectedToken(124 /* StaticKeyword */); + parseExpectedToken(124 /* SyntaxKind.StaticKeyword */); var body = parseClassStaticBlockBody(); var node = withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(body), pos), hasJSDoc); node.decorators = decorators; @@ -37122,7 +37257,7 @@ var ts; return body; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 132 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 132 /* SyntaxKind.AwaitKeyword */) { // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails // This simply parses the missing identifier and moves on. var pos = getNodePos(); @@ -37135,7 +37270,7 @@ var ts; } function tryParseDecorator() { var pos = getNodePos(); - if (!parseOptional(59 /* AtToken */)) { + if (!parseOptional(59 /* SyntaxKind.AtToken */)) { return undefined; } var expression = doInDecoratorContext(parseDecoratorExpression); @@ -37152,17 +37287,17 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } } - else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return undefined; } - else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) { + else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) { return undefined; } else { @@ -37192,7 +37327,7 @@ var ts; var pos = getNodePos(); var list, modifier, hasSeenStatic = false; while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) { - if (modifier.kind === 124 /* StaticKeyword */) + if (modifier.kind === 124 /* SyntaxKind.StaticKeyword */) hasSeenStatic = true; list = ts.append(list, modifier); } @@ -37200,33 +37335,33 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(131 /* SyntaxKind.AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; } function parseClassElement() { var pos = getNodePos(); - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { nextToken(); return finishNode(factory.createSemicolonClassElement(), pos); } var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true); - if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */, 0 /* SignatureFlags.None */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */, 0 /* SignatureFlags.None */); } - if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -37238,17 +37373,17 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */ || - token() === 41 /* AsteriskToken */ || - token() === 22 /* OpenBracketToken */) { + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */ || + token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 22 /* SyntaxKind.OpenBracketToken */) { var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); } else { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -37256,21 +37391,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* SyntaxKind.ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(84 /* ClassKeyword */); + parseExpected(84 /* SyntaxKind.ClassKeyword */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); @@ -37278,17 +37413,17 @@ var ts; setAwaitContext(/*value*/ true); var heritageClauses = parseHeritageClauses(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } members = parseClassMembers(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 257 /* ClassDeclaration */ + var node = kind === 257 /* SyntaxKind.ClassDeclaration */ ? factory.createClassDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members) : factory.createClassExpression(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -37304,45 +37439,45 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* SyntaxKind.ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(22 /* HeritageClauses */, parseHeritageClause); + return parseList(22 /* ParsingContext.HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* SyntaxKind.ExtendsKeyword */ || tok === 117 /* SyntaxKind.ImplementsKeyword */); // isListElement() should ensure this. nextToken(); - var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + var types = parseDelimitedList(7 /* ParsingContext.HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); } function parseExpressionWithTypeArguments() { var pos = getNodePos(); var expression = parseLeftHandSideExpressionOrHigher(); - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { return expression; } var typeArguments = tryParseTypeArguments(); return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos); } function tryParseTypeArguments() { - return token() === 29 /* LessThanToken */ ? - parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; + return token() === 29 /* SyntaxKind.LessThanToken */ ? + parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; + return token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; } function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); + return parseList(5 /* ParsingContext.ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(118 /* InterfaceKeyword */); + parseExpected(118 /* SyntaxKind.InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -37352,11 +37487,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(152 /* TypeKeyword */); + parseExpected(152 /* SyntaxKind.TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(63 /* EqualsToken */); - var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* SyntaxKind.EqualsToken */); + var type = token() === 138 /* SyntaxKind.IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(modifiers, name, typeParameters, type); node.decorators = decorators; @@ -37374,12 +37509,12 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(92 /* EnumKeyword */); + parseExpected(92 /* SyntaxKind.EnumKeyword */); var name = parseIdentifier(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* EnumMembers */, parseEnumMember); }); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* ParsingContext.EnumMembers */, parseEnumMember); }); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -37391,9 +37526,9 @@ var ts; function parseModuleBlock() { var pos = getNodePos(); var statements; - if (parseExpected(18 /* OpenBraceToken */)) { - statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { statements = createMissingList(); @@ -37403,10 +37538,10 @@ var ts; function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) { // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 16 /* Namespace */; + var namespaceFlag = flags & 16 /* NodeFlags.Namespace */; var name = parseIdentifier(); - var body = parseOptional(24 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) + var body = parseOptional(24 /* SyntaxKind.DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NodeFlags.NestedNamespace */ | namespaceFlag) : parseModuleBlock(); var node = factory.createModuleDeclaration(modifiers, name, body, flags); node.decorators = decorators; @@ -37415,17 +37550,17 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); - flags |= 1024 /* GlobalAugmentation */; + flags |= 1024 /* NodeFlags.GlobalAugmentation */; } else { name = parseLiteralNode(); name.text = internIdentifier(name.text); } var body; - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { body = parseModuleBlock(); } else { @@ -37437,37 +37572,37 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(142 /* NamespaceKeyword */)) { - flags |= 16 /* Namespace */; + else if (parseOptional(142 /* SyntaxKind.NamespaceKeyword */)) { + flags |= 16 /* NodeFlags.Namespace */; } else { - parseExpected(141 /* ModuleKeyword */); - if (token() === 10 /* StringLiteral */) { + parseExpected(141 /* SyntaxKind.ModuleKeyword */); + if (token() === 10 /* SyntaxKind.StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 146 /* RequireKeyword */ && + return token() === 146 /* SyntaxKind.RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 20 /* OpenParenToken */; + return nextToken() === 20 /* SyntaxKind.OpenParenToken */; } function nextTokenIsOpenBrace() { - return nextToken() === 18 /* OpenBraceToken */; + return nextToken() === 18 /* SyntaxKind.OpenBraceToken */; } function nextTokenIsSlash() { - return nextToken() === 43 /* SlashToken */; + return nextToken() === 43 /* SyntaxKind.SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(127 /* AsKeyword */); - parseExpected(142 /* NamespaceKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); + parseExpected(142 /* SyntaxKind.NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -37477,7 +37612,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(100 /* ImportKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); var afterImportPos = scanner.getStartPos(); // We don't parse the identifier here in await context, instead we will report a grammar error in the checker. var identifier; @@ -37485,7 +37620,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 156 /* FromKeyword */ && + if (token() !== 156 /* SyntaxKind.FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -37499,15 +37634,15 @@ var ts; // import ModuleSpecifier; var importClause; if (identifier || // import id - token() === 41 /* AsteriskToken */ || // import * - token() === 18 /* OpenBraceToken */ // import { + token() === 41 /* SyntaxKind.AsteriskToken */ || // import * + token() === 18 /* SyntaxKind.OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); var assertClause; - if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37517,21 +37652,21 @@ var ts; } function parseAssertEntry() { var pos = getNodePos(); - var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */); - parseExpected(58 /* ColonToken */); + var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* SyntaxKind.StringLiteral */); + parseExpected(58 /* SyntaxKind.ColonToken */); var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { var pos = getNodePos(); if (!skipAssertKeyword) { - parseExpected(129 /* AssertKeyword */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); } var openBracePosition = scanner.getTokenPos(); - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + var elements = parseDelimitedList(24 /* ParsingContext.AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -37545,15 +37680,15 @@ var ts; } } function tokenAfterImportDefinitelyProducesImportDeclaration() { - return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */; + return token() === 41 /* SyntaxKind.AsteriskToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 156 /* FromKeyword */; + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 156 /* SyntaxKind.FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(63 /* EqualsToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(modifiers, isTypeOnly, identifier, moduleReference); @@ -37572,8 +37707,8 @@ var ts; // parse namespace or named imports var namedBindings; if (!identifier || - parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* NamedImports */); + parseOptional(27 /* SyntaxKind.CommaToken */)) { + namedBindings = token() === 41 /* SyntaxKind.AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* SyntaxKind.NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -37584,14 +37719,14 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(146 /* RequireKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(146 /* SyntaxKind.RequireKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = parseModuleSpecifier(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createExternalModuleReference(expression), pos); } function parseModuleSpecifier() { - if (token() === 10 /* StringLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -37607,8 +37742,8 @@ var ts; // NameSpaceImport: // * as ImportedBinding var pos = getNodePos(); - parseExpected(41 /* AsteriskToken */); - parseExpected(127 /* AsKeyword */); + parseExpected(41 /* SyntaxKind.AsteriskToken */); + parseExpected(127 /* SyntaxKind.AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -37621,17 +37756,17 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 269 /* NamedImports */ - ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) - : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); + var node = kind === 269 /* SyntaxKind.NamedImports */ + ? factory.createNamedImports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)) + : factory.createNamedExports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { var hasJSDoc = hasPrecedingJSDocComment(); - return withJSDoc(parseImportOrExportSpecifier(275 /* ExportSpecifier */), hasJSDoc); + return withJSDoc(parseImportOrExportSpecifier(275 /* SyntaxKind.ExportSpecifier */), hasJSDoc); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(270 /* ImportSpecifier */); + return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -37656,10 +37791,10 @@ var ts; // import { type as } from "mod"; - isTypeOnly: true, name: as // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as ...? } var firstAs = parseIdentifierName(); - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as as ...? } var secondAs = parseIdentifierName(); if (ts.tokenIsIdentifierOrKeyword(token())) { @@ -37694,15 +37829,15 @@ var ts; name = parseNameWithKeywordCheck(); } } - if (canParseAsKeyword && token() === 127 /* AsKeyword */) { + if (canParseAsKeyword && token() === 127 /* SyntaxKind.AsKeyword */) { propertyName = name; - parseExpected(127 /* AsKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); name = parseNameWithKeywordCheck(); } - if (kind === 270 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 270 /* SyntaxKind.ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 270 /* ImportSpecifier */ + var node = kind === 270 /* SyntaxKind.ImportSpecifier */ ? factory.createImportSpecifier(isTypeOnly, propertyName, name) : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); @@ -37722,26 +37857,26 @@ var ts; var exportClause; var moduleSpecifier; var assertClause; - var isTypeOnly = parseOptional(152 /* TypeKeyword */); + var isTypeOnly = parseOptional(152 /* SyntaxKind.TypeKeyword */); var namespaceExportPos = getNodePos(); - if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(127 /* AsKeyword */)) { + if (parseOptional(41 /* SyntaxKind.AsteriskToken */)) { + if (parseOptional(127 /* SyntaxKind.AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(273 /* NamedExports */); + exportClause = parseNamedImportsOrExports(273 /* SyntaxKind.NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 156 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(156 /* FromKeyword */); + if (token() === 156 /* SyntaxKind.FromKeyword */ || (token() === 10 /* SyntaxKind.StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } - if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (moduleSpecifier && token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37754,11 +37889,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(63 /* EqualsToken */)) { + if (parseOptional(63 /* SyntaxKind.EqualsToken */)) { isExportEquals = true; } else { - parseExpected(88 /* DefaultKeyword */); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); } var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); parseSemicolon(); @@ -37805,11 +37940,11 @@ var ts; var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState("file.js", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); - var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop); + var sourceFile = createSourceFile("file.js", 99 /* ScriptTarget.Latest */, 1 /* ScriptKind.JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* SyntaxKind.EndOfFileToken */), 0 /* NodeFlags.None */, ts.noop); var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); if (jsDocDiagnostics) { sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile); @@ -37821,10 +37956,10 @@ var ts; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { var pos = getNodePos(); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* SyntaxKind.OpenBraceToken */); + var type = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocTypeExpression(type); fixupParentReferences(result); @@ -37833,16 +37968,16 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocNameReference() { var pos = getNodePos(); - var hasBrace = parseOptional(18 /* OpenBraceToken */); + var hasBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var p2 = getNodePos(); var entityName = parseEntityName(/* allowReservedWords*/ false); - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); } if (hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocNameReference(entityName); fixupParentReferences(result); @@ -37850,9 +37985,9 @@ var ts; } JSDocParser.parseJSDocNameReference = parseJSDocNameReference; function parseIsolatedJSDocComment(content, start, length) { - initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); - var sourceFile = { languageVariant: 0 /* Standard */, text: content }; + initializeState("", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); + var jsDoc = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var sourceFile = { languageVariant: 0 /* LanguageVariant.Standard */, text: content }; var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -37862,9 +37997,9 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); ts.setParent(comment, parent); - if (contextFlags & 262144 /* JavaScriptFile */) { + if (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) { if (!jsDocDiagnostics) { jsDocDiagnostics = []; } @@ -37912,7 +38047,7 @@ var ts; return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. - var state = 1 /* SawAsterisk */; + var state = 1 /* JSDocState.SawAsterisk */; var margin; // + 4 for leading '/** ' // + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character @@ -37925,16 +38060,16 @@ var ts; indent += text.length; } nextTokenJSDoc(); - while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + while (parseOptionalJsdoc(5 /* SyntaxKind.WhitespaceTrivia */)) ; - if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { - state = 0 /* BeginningOfLine */; + if (parseOptionalJsdoc(4 /* SyntaxKind.NewLineTrivia */)) { + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; } loop: while (true) { switch (token()) { - case 59 /* AtToken */: - if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { + case 59 /* SyntaxKind.AtToken */: + if (state === 0 /* JSDocState.BeginningOfLine */ || state === 1 /* JSDocState.SawAsterisk */) { removeTrailingWhitespace(comments); if (!commentsPos) commentsPos = getNodePos(); @@ -37942,35 +38077,35 @@ var ts; // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning // for malformed examples like `/** @param {string} x @returns {number} the length */` - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; margin = undefined; } else { pushComment(scanner.getTokenText()); } break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: comments.push(scanner.getTokenText()); - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: var asterisk = scanner.getTokenText(); - if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { + if (state === 1 /* JSDocState.SawAsterisk */ || state === 2 /* JSDocState.SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(asterisk); } else { // Ignore the first asterisk on a line - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += asterisk.length; } break; - case 5 /* WhitespaceTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // only collect whitespace if we're already saving comments or have just crossed the comment indent margin var whitespace = scanner.getTokenText(); - if (state === 2 /* SavingComments */) { + if (state === 2 /* JSDocState.SavingComments */) { comments.push(whitespace); } else if (margin !== undefined && indent + whitespace.length > margin) { @@ -37978,10 +38113,10 @@ var ts; } indent += whitespace.length; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -38000,7 +38135,7 @@ var ts; // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(scanner.getTokenText()); break; } @@ -38029,26 +38164,26 @@ var ts; // We must use infinite lookahead, as there could be any number of newlines :( while (true) { nextTokenJSDoc(); - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { return true; } - if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) { + if (!(token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */)) { return false; } } } function skipWhitespace() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } } - while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { nextTokenJSDoc(); } } function skipWhitespaceOrAsterisk() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return ""; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } @@ -38056,14 +38191,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* SyntaxKind.AsteriskToken */) || token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { indentText += scanner.getTokenText(); - if (token() === 4 /* NewLineTrivia */) { + if (token() === 4 /* SyntaxKind.NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 41 /* AsteriskToken */) { + else if (token() === 41 /* SyntaxKind.AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -38071,7 +38206,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -38120,7 +38255,7 @@ var ts; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, margin); + return parseParameterOrPropertyTag(start, tagName, 2 /* PropertyLikeParse.Parameter */, margin); case "return": case "returns": tag = parseReturnTag(start, tagName, margin, indentText); @@ -38158,7 +38293,7 @@ var ts; var comments = []; var parts = []; var linkEnd; - var state = 0 /* BeginningOfLine */; + var state = 0 /* JSDocState.BeginningOfLine */; var previousWhitespace = true; var margin; function pushComment(text) { @@ -38173,31 +38308,31 @@ var ts; if (initialMargin !== "") { pushComment(initialMargin); } - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; } var tok = token(); loop: while (true) { switch (tok) { - case 4 /* NewLineTrivia */: - state = 0 /* BeginningOfLine */; + case 4 /* SyntaxKind.NewLineTrivia */: + state = 0 /* JSDocState.BeginningOfLine */; // don't use pushComment here because we want to keep the margin unchanged comments.push(scanner.getTokenText()); indent = 0; break; - case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */ - || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { + case 59 /* SyntaxKind.AtToken */: + if (state === 3 /* JSDocState.SavingBackticks */ + || state === 2 /* JSDocState.SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace comments.push(scanner.getTokenText()); break; } scanner.setTextPos(scanner.getTextPos() - 1); // falls through - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // Done break loop; - case 5 /* WhitespaceTrivia */: - if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) { + case 5 /* SyntaxKind.WhitespaceTrivia */: + if (state === 2 /* JSDocState.SavingComments */ || state === 3 /* JSDocState.SavingBackticks */) { pushComment(scanner.getTokenText()); } else { @@ -38209,8 +38344,8 @@ var ts; indent += whitespace.length; } break; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -38224,32 +38359,32 @@ var ts; pushComment(scanner.getTokenText()); } break; - case 61 /* BacktickToken */: - if (state === 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; + case 61 /* SyntaxKind.BacktickToken */: + if (state === 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; } else { - state = 3 /* SavingBackticks */; + state = 3 /* JSDocState.SavingBackticks */; } pushComment(scanner.getTokenText()); break; - case 41 /* AsteriskToken */: - if (state === 0 /* BeginningOfLine */) { + case 41 /* SyntaxKind.AsteriskToken */: + if (state === 0 /* JSDocState.BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += 1; break; } // record the * as a comment // falls through default: - if (state !== 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; // leading identifiers start recording as well + if (state !== 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; // leading identifiers start recording as well } pushComment(scanner.getTokenText()); break; } - previousWhitespace = token() === 5 /* WhitespaceTrivia */; + previousWhitespace = token() === 5 /* SyntaxKind.WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); @@ -38266,7 +38401,7 @@ var ts; } function isNextJSDocTokenWhitespace() { var next = nextTokenJSDoc(); - return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + return next === 5 /* SyntaxKind.WhitespaceTrivia */ || next === 4 /* SyntaxKind.NewLineTrivia */; } function parseJSDocLink(start) { var linkType = tryParse(parseJSDocLinkPrefix); @@ -38281,14 +38416,14 @@ var ts; ? parseEntityName(/*allowReservedWords*/ true) : undefined; if (name) { - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); } } var text = []; - while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 19 /* SyntaxKind.CloseBraceToken */ && token() !== 4 /* SyntaxKind.NewLineTrivia */ && token() !== 1 /* SyntaxKind.EndOfFileToken */) { text.push(scanner.getTokenText()); nextTokenJSDoc(); } @@ -38299,8 +38434,8 @@ var ts; } function parseJSDocLinkPrefix() { skipWhitespaceOrAsterisk(); - if (token() === 18 /* OpenBraceToken */ - && nextTokenJSDoc() === 59 /* AtToken */ + if (token() === 18 /* SyntaxKind.OpenBraceToken */ + && nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { var kind = scanner.getTokenValue(); if (isJSDocLinkTag(kind)) @@ -38328,35 +38463,35 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* SyntaxKind.BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(61 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* SyntaxKind.BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(63 /* EqualsToken */)) { + if (parseOptionalToken(63 /* SyntaxKind.EqualsToken */)) { parseExpression(); } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -38372,12 +38507,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); - var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); + var nestedTypeLiteral = target !== 4 /* PropertyLikeParse.CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - var result = target === 1 /* Property */ + var result = target === 1 /* PropertyLikeParse.Property */ ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment); return finishNode(result, start); @@ -38388,12 +38523,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) { + if (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -38414,8 +38549,8 @@ var ts; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */ - || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); + var isMarkdownOrJSDocLink = token() === 22 /* SyntaxKind.OpenBracketToken */ + || lookAhead(function () { return nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference(); var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); @@ -38437,14 +38572,14 @@ var ts; var comments = []; var inEmail = false; var token = scanner.getToken(); - while (token !== 1 /* EndOfFileToken */ && token !== 4 /* NewLineTrivia */) { - if (token === 29 /* LessThanToken */) { + while (token !== 1 /* SyntaxKind.EndOfFileToken */ && token !== 4 /* SyntaxKind.NewLineTrivia */) { + if (token === 29 /* SyntaxKind.LessThanToken */) { inEmail = true; } - else if (token === 59 /* AtToken */ && !inEmail) { + else if (token === 59 /* SyntaxKind.AtToken */ && !inEmail) { break; } - else if (token === 31 /* GreaterThanToken */ && inEmail) { + else if (token === 31 /* SyntaxKind.GreaterThanToken */ && inEmail) { comments.push(scanner.getTokenText()); scanner.setTextPos(scanner.getTokenPos() + 1); break; @@ -38463,21 +38598,21 @@ var ts; return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(18 /* OpenBraceToken */); + var usedBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var pos = getNodePos(); var expression = parsePropertyAccessEntityNameExpression(); var typeArguments = tryParseTypeArguments(); var node = factory.createExpressionWithTypeArguments(expression, typeArguments); var res = finishNode(node, pos); if (usedBrace) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var pos = getNodePos(); var node = parseJSDocIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); node = finishNode(factory.createPropertyAccessExpression(node, name), pos); } @@ -38511,7 +38646,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 343 /* JSDocTypeTag */) { + if (child.kind === 343 /* SyntaxKind.JSDocTypeTag */) { if (childTypeTag) { var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { @@ -38528,7 +38663,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 183 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -38552,10 +38687,10 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(24 /* DotToken */)) { + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var body = parseJSDocTypeNameWithNamespace(/*nested*/ true); var jsDocNamespaceNode = factory.createModuleDeclaration( - /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NestedNamespace */ : undefined); + /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NodeFlags.NestedNamespace */ : undefined); return finishNode(jsDocNamespaceNode, pos); } if (nested) { @@ -38567,7 +38702,7 @@ var ts; var pos = getNodePos(); var child; var parameters; - while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { + while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* PropertyLikeParse.CallbackParameter */, indent); })) { parameters = ts.append(parameters, child); } return createNodeArray(parameters || [], pos); @@ -38578,9 +38713,9 @@ var ts; var comment = parseTagComments(indent); var parameters = parseCallbackTagParameters(indent); var returnTag = tryParse(function () { - if (parseOptionalJsdoc(59 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 341 /* JSDocReturnTag */) { + if (tag && tag.kind === 341 /* SyntaxKind.JSDocReturnTag */) { return tag; } } @@ -38605,18 +38740,18 @@ var ts; return a.escapedText === b.escapedText; } function parseChildPropertyTag(indent) { - return parseChildParameterOrPropertyTag(1 /* Property */, indent); + return parseChildParameterOrPropertyTag(1 /* PropertyLikeParse.Property */, indent); } function parseChildParameterOrPropertyTag(target, indent, name) { var canParseTag = true; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) && - target !== 4 /* CallbackParameter */ && + if (child && (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) && + target !== 4 /* PropertyLikeParse.CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -38624,26 +38759,26 @@ var ts; } seenAsterisk = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: canParseTag = true; seenAsterisk = false; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: canParseTag = false; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return false; } } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -38651,15 +38786,15 @@ var ts; var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(start, tagName); + return target === 1 /* PropertyLikeParse.Property */ && parseTypeTag(start, tagName); case "prop": case "property": - t = 1 /* Property */; + t = 1 /* PropertyLikeParse.Property */; break; case "arg": case "argument": case "param": - t = 2 /* Parameter */ | 4 /* CallbackParameter */; + t = 2 /* PropertyLikeParse.Parameter */ | 4 /* PropertyLikeParse.CallbackParameter */; break; default: return false; @@ -38671,7 +38806,7 @@ var ts; } function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } @@ -38679,9 +38814,9 @@ var ts; var defaultType; if (isBracketed) { skipWhitespace(); - parseExpected(63 /* EqualsToken */); - defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); - parseExpected(23 /* CloseBracketToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); + defaultType = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } if (ts.nodeIsMissing(name)) { return undefined; @@ -38698,7 +38833,7 @@ var ts; typeParameters.push(node); } skipWhitespaceOrAsterisk(); - } while (parseOptionalJsdoc(27 /* CommaToken */)); + } while (parseOptionalJsdoc(27 /* SyntaxKind.CommaToken */)); return createNodeArray(typeParameters, pos); } function parseTemplateTag(start, tagName, indent, indentText) { @@ -38713,7 +38848,7 @@ var ts; // TODO: Determine whether we should enforce this in the checker. // TODO: Consider moving the `constraint` to the first type parameter as we could then remove `getEffectiveConstraintOfTypeParameter`. // TODO: Consider only parsing a single type parameter if there is a constraint. - var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + var constraint = token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } @@ -38726,16 +38861,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); // Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking. // Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}> // but it's not worth it to enforce that restriction. } - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -38743,7 +38878,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -38760,7 +38895,7 @@ var ts; var IncrementalParser; (function (IncrementalParser) { function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */); checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); if (ts.textChangeRangeIsUnchanged(textChangeRange)) { // if the text didn't change, then we can just return our current source file as-is. @@ -38915,9 +39050,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 79 /* Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: return true; } return false; @@ -38991,10 +39126,10 @@ var ts; } function checkNodePositions(node, aggressiveChecks) { if (aggressiveChecks) { - var pos_2 = node.pos; + var pos_3 = node.pos; var visitNode_1 = function (child) { - ts.Debug.assert(child.pos >= pos_2); - pos_2 = child.end; + ts.Debug.assert(child.pos >= pos_3); + pos_3 = child.end; }; if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -39003,7 +39138,7 @@ var ts; } } forEachChild(node, visitNode_1); - ts.Debug.assert(pos_2 <= node.end); + ts.Debug.assert(pos_3 <= node.end); } } function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { @@ -39172,7 +39307,7 @@ var ts; var oldText = sourceFile.text; if (textChangeRange) { ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* AssertionLevel.VeryAggressive */)) { var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); var newTextPrefix = newText.substr(0, textChangeRange.span.start); ts.Debug.assert(oldTextPrefix === newTextPrefix); @@ -39187,7 +39322,7 @@ var ts; var currentArrayIndex = 0; ts.Debug.assert(currentArrayIndex < currentArray.length); var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; + var lastQueriedPosition = -1 /* InvalidPosition.Value */; return { currentNode: function (position) { // Only compute the current node if the position is different than the last time @@ -39225,7 +39360,7 @@ var ts; function findHighestListElementThatStartsAtPosition(position) { // Clear out any cached state about the last node we found. currentArray = undefined; - currentArrayIndex = -1 /* Value */; + currentArrayIndex = -1 /* InvalidPosition.Value */; current = undefined; // Recurse into the source file to find the highest node at this position. forEachChild(sourceFile, visitNode, visitArray); @@ -39405,18 +39540,18 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im; var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im; function extractPragmas(pragmas, range, text) { - var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); + var tripleSlash = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); if (tripleSlash) { var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks var pragma = ts.commentPragmas[name]; - if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) { + if (!pragma || !(pragma.kind & 1 /* PragmaKindFlags.TripleSlashXML */)) { return; } if (pragma.args) { @@ -39450,15 +39585,15 @@ var ts; } return; } - var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); + var singleLine = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); if (singleLine) { - return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); + return addPragmaForMatch(pragmas, range, 2 /* PragmaKindFlags.SingleLine */, singleLine); } - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { - addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch); + addPragmaForMatch(pragmas, range, 4 /* PragmaKindFlags.MultiLine */, multiLineMatch); } } } @@ -39501,10 +39636,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 79 /* Identifier */) { + if (lhs.kind === 79 /* SyntaxKind.Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 108 /* ThisKeyword */) { + if (lhs.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -39524,11 +39659,11 @@ var ts; defaultValueDescription: false, }; var jsxOptionMap = new ts.Map(ts.getEntries({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */, - "react-jsx": 4 /* ReactJSX */, - "react-jsxdev": 5 /* ReactJSXDev */, + "preserve": 1 /* JsxEmit.Preserve */, + "react-native": 3 /* JsxEmit.ReactNative */, + "react": 2 /* JsxEmit.React */, + "react-jsx": 4 /* JsxEmit.ReactJSX */, + "react-jsxdev": 5 /* JsxEmit.ReactJSXDev */, })); /* @internal */ ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) { @@ -39834,18 +39969,18 @@ var ts; name: "target", shortName: "t", type: new ts.Map(ts.getEntries({ - es3: 0 /* ES3 */, - es5: 1 /* ES5 */, - es6: 2 /* ES2015 */, - es2015: 2 /* ES2015 */, - es2016: 3 /* ES2016 */, - es2017: 4 /* ES2017 */, - es2018: 5 /* ES2018 */, - es2019: 6 /* ES2019 */, - es2020: 7 /* ES2020 */, - es2021: 8 /* ES2021 */, - es2022: 9 /* ES2022 */, - esnext: 99 /* ESNext */, + es3: 0 /* ScriptTarget.ES3 */, + es5: 1 /* ScriptTarget.ES5 */, + es6: 2 /* ScriptTarget.ES2015 */, + es2015: 2 /* ScriptTarget.ES2015 */, + es2016: 3 /* ScriptTarget.ES2016 */, + es2017: 4 /* ScriptTarget.ES2017 */, + es2018: 5 /* ScriptTarget.ES2018 */, + es2019: 6 /* ScriptTarget.ES2019 */, + es2020: 7 /* ScriptTarget.ES2020 */, + es2021: 8 /* ScriptTarget.ES2021 */, + es2022: 9 /* ScriptTarget.ES2022 */, + esnext: 99 /* ScriptTarget.ESNext */, })), affectsSourceFile: true, affectsModuleResolution: true, @@ -39855,7 +39990,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, - defaultValueDescription: 0 /* ES3 */, + defaultValueDescription: 0 /* ScriptTarget.ES3 */, }; /*@internal*/ ts.moduleOptionDeclaration = { @@ -40135,16 +40270,16 @@ var ts; { name: "importsNotUsedAsValues", type: new ts.Map(ts.getEntries({ - remove: 0 /* Remove */, - preserve: 1 /* Preserve */, - error: 2 /* Error */, + remove: 0 /* ImportsNotUsedAsValues.Remove */, + preserve: 1 /* ImportsNotUsedAsValues.Preserve */, + error: 2 /* ImportsNotUsedAsValues.Error */, })), affectsEmit: true, affectsSemanticDiagnostics: true, affectsMultiFileEmitBuildInfo: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, - defaultValueDescription: 0 /* Remove */, + defaultValueDescription: 0 /* ImportsNotUsedAsValues.Remove */, }, { name: "downlevelIteration", @@ -40599,8 +40734,8 @@ var ts; { name: "newLine", type: new ts.Map(ts.getEntries({ - crlf: 0 /* CarriageReturnLineFeed */, - lf: 1 /* LineFeed */ + crlf: 0 /* NewLineKind.CarriageReturnLineFeed */, + lf: 1 /* NewLineKind.LineFeed */ })), affectsEmit: true, affectsMultiFileEmitBuildInfo: true, @@ -40973,7 +41108,7 @@ var ts; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, - target: 3 /* ES2016 */, + target: 3 /* ScriptTarget.ES2016 */, strict: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, @@ -40998,8 +41133,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } /* @internal */ function parseCustomTypeOption(opt, value, errors) { @@ -41058,11 +41193,11 @@ var ts; while (i < args.length) { var s = args[i]; i++; - if (s.charCodeAt(0) === 64 /* at */) { + if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) { parseResponseFile(s.slice(1)); } - else if (s.charCodeAt(0) === 45 /* minus */) { - var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1); + else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) { + var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1); var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true); if (opt) { i = parseOptionValue(args, i, diagnostics, opt, options, errors); @@ -41091,14 +41226,14 @@ var ts; var args = []; var pos = 0; while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) + while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */) pos++; if (pos >= text.length) break; var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { + if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) { pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */) pos++; if (pos < text.length) { args.push(text.substring(start + 1, pos)); @@ -41109,7 +41244,7 @@ var ts; } } else { - while (text.charCodeAt(pos) > 32 /* space */) + while (text.charCodeAt(pos) > 32 /* CharacterCodes.space */) pos++; args.push(text.substring(start, pos)); } @@ -41444,7 +41579,7 @@ var ts; var _a; var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; - if (rootExpression && rootExpression.kind !== 205 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json")); // Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that @@ -41484,7 +41619,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 296 /* PropertyAssignment */) { + if (element.kind !== 296 /* SyntaxKind.PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -41551,16 +41686,16 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -41575,16 +41710,16 @@ var ts; } } return validateValue(text); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 219 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* SyntaxKind.MinusToken */ || valueExpression.operand.kind !== 8 /* SyntaxKind.NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -41601,7 +41736,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -41795,10 +41930,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -41849,19 +41984,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -41870,25 +42005,25 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); // Print out each row, aligning all the descriptions on the same column. for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -41943,7 +42078,7 @@ var ts; * file to. e.g. outDir */ function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -42293,8 +42428,8 @@ var ts; extendedConfig = ts.normalizeSlashes(extendedConfig); if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Extension.Json */)) { + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -42535,11 +42670,11 @@ var ts; var jsonOnlyIncludeRegexes; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { var _loop_6 = function (file) { - if (ts.fileExtensionIs(file, ".json" /* Json */)) { + if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { - var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Json */); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -42683,7 +42818,7 @@ var ts; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; - if (flags === 1 /* Recursive */) { + if (flags === 1 /* WatchDirectoryFlags.Recursive */) { recursiveKeys.push(key); } } @@ -42717,13 +42852,13 @@ var ts; key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) - ? 1 /* Recursive */ : 0 /* None */ + ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */ }; } if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) { return { key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)), - flags: 1 /* Recursive */ + flags: 1 /* WatchDirectoryFlags.Recursive */ }; } return undefined; @@ -42746,7 +42881,7 @@ var ts; } var higherPriorityPath = keyMapper(ts.changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { - if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) { + if (ext === ".d.ts" /* Extension.Dts */ && (ts.fileExtensionIs(file, ".js" /* Extension.Js */) || ts.fileExtensionIs(file, ".jsx" /* Extension.Jsx */))) { // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to // prevent breakage. @@ -42824,7 +42959,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -42980,7 +43115,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -43043,7 +43178,7 @@ var ts; var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); function arePathsEqual(path1, path2, host) { var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames; - return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */; + return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* Comparison.EqualTo */; } /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -43211,18 +43346,7 @@ var ts; * Does not try `@types/${packageName}` - use a second pass if needed. */ function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) { - var moduleResolutionState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ts.emptyArray, - features: NodeResolutionFeatures.None, - requestContainingDirectory: containingDirectory, - reportDiagnostic: ts.noop - }; + var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules"); @@ -43264,7 +43388,7 @@ var ts; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); // At this stage, skip results with leading dot. - if (baseFileName.charCodeAt(0) !== 46 /* dot */) { + if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) { // Return just the type directive names result.push(baseFileName); } @@ -43319,7 +43443,7 @@ var ts; ts.createCacheWithRedirects = createCacheWithRedirects; function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { var cache; - return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries }; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap }; function getPackageJsonInfo(packageJsonPath) { return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); } @@ -43333,6 +43457,9 @@ var ts; var iter = cache === null || cache === void 0 ? void 0 : cache.entries(); return iter ? ts.arrayFrom(iter) : []; } + function getInternalMap() { + return cache; + } } function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); @@ -43415,7 +43542,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -43436,21 +43563,24 @@ var ts; } ts.zipToModeAwareCache = zipToModeAwareCache; function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options)); var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); - moduleNameToDirectoryMap.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + } function update(options) { updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -43520,13 +43650,16 @@ var ts; } ts.createModuleResolutionCache = createModuleResolutionCache; function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + } } ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) { @@ -43597,10 +43730,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -43803,7 +43936,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -43952,7 +44085,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -44019,7 +44152,7 @@ var ts; } var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length; var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules); - if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) { + if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) { indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName); } return path.slice(0, indexAfterPackageName); @@ -44038,7 +44171,7 @@ var ts; */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { - var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); + var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Extension.Json */); var extension = extensionLess ? candidate.substring(extensionLess.length) : ""; return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } @@ -44055,7 +44188,7 @@ var ts; function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) { + if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Extension.Json */) && state.compilerOptions.resolveJsonModule)) { var extensionless = ts.removeFileExtension(candidate); var extension = candidate.substring(extensionless.length); if (state.traceEnabled) { @@ -44083,55 +44216,55 @@ var ts; switch (extensions) { case Extensions.DtsOnly: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); - default: return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".d.mts" /* Extension.Dmts */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".d.cts" /* Extension.Dcts */); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return tryExtension(".d.ts" /* Extension.Dts */); + default: return tryExtension(".d.ts" /* Extension.Dts */); } case Extensions.TypeScript: case Extensions.TsOnly: var useDts = extensions === Extensions.TypeScript; switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return useDts ? tryExtension(".d.ts" /* Dts */) : undefined; + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mts" /* Extension.Mts */) || (useDts ? tryExtension(".d.mts" /* Extension.Dmts */) : undefined); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cts" /* Extension.Cts */) || (useDts ? tryExtension(".d.cts" /* Extension.Dcts */) : undefined); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined; default: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined); + return tryExtension(".ts" /* Extension.Ts */) || tryExtension(".tsx" /* Extension.Tsx */) || (useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined); } case Extensions.JavaScript: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mjs" /* Mjs */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cjs" /* Cjs */); - case ".json" /* Json */: - return tryExtension(".json" /* Json */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mjs" /* Extension.Mjs */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cjs" /* Extension.Cjs */); + case ".json" /* Extension.Json */: + return tryExtension(".json" /* Extension.Json */); default: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js" /* Extension.Js */) || tryExtension(".jsx" /* Extension.Jsx */); } case Extensions.TSConfig: case Extensions.Json: - return tryExtension(".json" /* Json */); + return tryExtension(".json" /* Extension.Json */); } function tryExtension(ext) { var path = tryFile(candidate + ext, onlyRecordFailures, state); @@ -44182,18 +44315,9 @@ var ts; var entrypoints; var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript; var features = getDefaultNodeResolutionFeatures(options); - var requireState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ["node", "require", "types"], - features: features, - requestContainingDirectory: packageJsonInfo.packageDirectory, - reportDiagnostic: ts.noop - }; + var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); + requireState.conditions = ["node", "require", "types"]; + requireState.requestContainingDirectory = packageJsonInfo.packageDirectory; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path); @@ -44266,23 +44390,27 @@ var ts; } } } - /** - * A function for locating the package.json scope for a given path - */ /*@internal*/ - function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) { - var state = { + function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) { + return { host: host, compilerOptions: options, traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], + failedLookupLocations: ts.noopPush, + affectingLocations: ts.noopPush, packageJsonInfoCache: packageJsonInfoCache, - features: 0, - conditions: [], + features: NodeResolutionFeatures.None, + conditions: ts.emptyArray, requestContainingDirectory: undefined, reportDiagnostic: ts.noop }; + } + ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState; + /** + * A function for locating the package.json scope for a given path + */ + /*@internal*/ + function getPackageScopeForPath(fileName, state) { var parts = ts.getPathComponents(fileName); parts.pop(); while (parts.length > 0) { @@ -44420,16 +44548,16 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */; + return extension === ".js" /* Extension.Js */ || extension === ".jsx" /* Extension.Jsx */ || extension === ".mjs" /* Extension.Mjs */ || extension === ".cjs" /* Extension.Cjs */; case Extensions.TSConfig: case Extensions.Json: - return extension === ".json" /* Json */; + return extension === ".json" /* Extension.Json */; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */ || extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */ || extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; case Extensions.TsOnly: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */; + return extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; } } /* @internal */ @@ -44453,7 +44581,7 @@ var ts; var _a, _b; var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope || !scope.packageJsonContent.exports) { return undefined; } @@ -44466,7 +44594,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -44512,7 +44640,7 @@ var ts; } var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath); @@ -44535,6 +44663,7 @@ var ts; return toSearchResult(/*value*/ undefined); } /** + * @internal * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 - * "longest" has some nuance as to what "longest" means in the presence of pattern trailers */ @@ -44557,6 +44686,7 @@ var ts; return 1; return 0; } + ts.comparePatternKeys = comparePatternKeys; function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) { var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports); if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) { @@ -44764,7 +44894,7 @@ var ts; // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment); - var jsAndDtsExtensions = [".mjs" /* Mjs */, ".cjs" /* Cjs */, ".js" /* Js */, ".json" /* Json */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".d.ts" /* Dts */]; + var jsAndDtsExtensions = [".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */, ".js" /* Extension.Js */, ".json" /* Extension.Json */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".d.ts" /* Extension.Dts */]; for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) { var ext = jsAndDtsExtensions_1[_f]; if (ts.fileExtensionIs(possibleInputBase, ext)) { @@ -44949,7 +45079,7 @@ var ts; } /* @internal */ function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; /* @internal */ @@ -45095,14 +45225,14 @@ var ts; ts.setParent(node.body, node); ts.setParentRecursive(node.body, /*incremental*/ false); } - return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* ModuleInstanceState.Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateCached(node, visited) { if (visited === void 0) { visited = new ts.Map(); } var nodeId = ts.getNodeId(node); if (visited.has(nodeId)) { - return visited.get(nodeId) || 0 /* NonInstantiated */; + return visited.get(nodeId) || 0 /* ModuleInstanceState.NonInstantiated */; } visited.set(nodeId, undefined); var result = getModuleInstanceStateWorker(node, visited); @@ -45113,34 +45243,34 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return 0 /* NonInstantiated */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return 0 /* ModuleInstanceState.NonInstantiated */; // 2. const enum declarations - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (ts.isEnumConst(node)) { - return 2 /* ConstEnumOnly */; + return 2 /* ModuleInstanceState.ConstEnumOnly */; } break; // 3. non-exported import declarations - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { - return 0 /* NonInstantiated */; + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (!(ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { + return 0 /* ModuleInstanceState.NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* NamedExports */) { - var state = 0 /* NonInstantiated */; + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* SyntaxKind.NamedExports */) { + var state = 0 /* ModuleInstanceState.NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); if (specifierState > state) { state = specifierState; } - if (state === 1 /* Instantiated */) { + if (state === 1 /* ModuleInstanceState.Instantiated */) { return state; } } @@ -45148,21 +45278,21 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 262 /* ModuleBlock */: { - var state_1 = 0 /* NonInstantiated */; + case 262 /* SyntaxKind.ModuleBlock */: { + var state_1 = 0 /* ModuleInstanceState.NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); switch (childState) { - case 0 /* NonInstantiated */: + case 0 /* ModuleInstanceState.NonInstantiated */: // child is non-instantiated - continue searching return; - case 2 /* ConstEnumOnly */: + case 2 /* ModuleInstanceState.ConstEnumOnly */: // child is const enum only - record state and continue searching - state_1 = 2 /* ConstEnumOnly */; + state_1 = 2 /* ModuleInstanceState.ConstEnumOnly */; return; - case 1 /* Instantiated */: + case 1 /* ModuleInstanceState.Instantiated */: // child is instantiated - record state and stop - state_1 = 1 /* Instantiated */; + state_1 = 1 /* ModuleInstanceState.Instantiated */; return true; default: ts.Debug.assertNever(childState); @@ -45170,16 +45300,16 @@ var ts; }); return state_1; } - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { - return 0 /* NonInstantiated */; + return 0 /* ModuleInstanceState.NonInstantiated */; } } - return 1 /* Instantiated */; + return 1 /* ModuleInstanceState.Instantiated */; } function getModuleInstanceStateForAliasTarget(specifier, visited) { var name = specifier.propertyName || specifier.name; @@ -45199,7 +45329,7 @@ var ts; if (found === undefined || state > found) { found = state; } - if (found === 1 /* Instantiated */) { + if (found === 1 /* ModuleInstanceState.Instantiated */) { return found; } } @@ -45210,7 +45340,7 @@ var ts; } p = p.parent; } - return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + return 1 /* ModuleInstanceState.Instantiated */; // Couldn't locate, assume could refer to a value } var ContainerFlags; (function (ContainerFlags) { @@ -45284,8 +45414,8 @@ var ts; var symbolCount = 0; var Symbol; var classifiableNames; - var unreachableFlow = { flags: 1 /* Unreachable */ }; - var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; + var unreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; + var reportedUnreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); /** * Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file) @@ -45307,7 +45437,7 @@ var ts; ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* tracing.Phase.Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); bind(file); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); file.symbolCount = symbolCount; @@ -45334,7 +45464,7 @@ var ts; activeLabelList = undefined; hasExplicitReturn = false; inAssignmentPattern = false; - emitFlags = 0 /* None */; + emitFlags = 0 /* NodeFlags.None */; } return bindSourceFile; function bindInStrictMode(file, opts) { @@ -45354,33 +45484,33 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; symbol.declarations = ts.appendIfUnique(symbol.declarations, node); - if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } - if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && !symbol.members) { symbol.members = ts.createSymbolTable(); } // On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate) - if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { + if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { ts.setValueDeclaration(symbol, node); } } // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 271 /* ExportAssignment */) { - return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) { + return node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; } var name = ts.getNameOfDeclaration(node); if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -45406,36 +45536,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 171 /* Constructor */: - return "__constructor" /* Constructor */; - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - return "__call" /* Call */; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: - return "__new" /* New */; - case 176 /* IndexSignature */: - return "__index" /* Index */; - case 272 /* ExportDeclaration */: - return "__export" /* ExportStar */; - case 305 /* SourceFile */: + case 171 /* SyntaxKind.Constructor */: + return "__constructor" /* InternalSymbolName.Constructor */; + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + return "__call" /* InternalSymbolName.Call */; + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + return "__new" /* InternalSymbolName.New */; + case 176 /* SyntaxKind.IndexSignature */: + return "__index" /* InternalSymbolName.Index */; + case 272 /* SyntaxKind.ExportDeclaration */: + return "__export" /* InternalSymbolName.ExportStar */; + case 305 /* SyntaxKind.SourceFile */: // json file should behave as // module.exports = ... - return "export=" /* ExportEquals */; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { + return "export=" /* InternalSymbolName.ExportEquals */; + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */) { // module.exports = ... - return "export=" /* ExportEquals */; + return "export=" /* InternalSymbolName.ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 317 /* JSDocFunctionType */: - return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 164 /* Parameter */: + case 317 /* SyntaxKind.JSDocFunctionType */: + return (ts.isJSDocConstructSignature(node) ? "__new" /* InternalSymbolName.New */ : "__call" /* InternalSymbolName.Call */); + case 164 /* SyntaxKind.Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind), ", expected JSDocFunctionType"); }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -45454,14 +45584,14 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) { ts.Debug.assert(isComputedName || !ts.hasDynamicName(node)); - var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; + var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" - var name = isComputedName ? "__computed" /* Computed */ - : isDefaultExport && parent ? "default" /* Default */ + var name = isComputedName ? "__computed" /* InternalSymbolName.Computed */ + : isDefaultExport && parent ? "default" /* InternalSymbolName.Default */ : getDeclarationName(node); var symbol; if (name === undefined) { - symbol = createSymbol(0 /* None */, "__missing" /* Missing */); + symbol = createSymbol(0 /* SymbolFlags.None */, "__missing" /* InternalSymbolName.Missing */); } else { // Check and see if the symbol table already has a symbol with this name. If not, @@ -45488,11 +45618,11 @@ var ts; // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. symbol = symbolTable.get(name); - if (includes & 2885600 /* Classifiable */) { + if (includes & 2885600 /* SymbolFlags.Classifiable */) { classifiableNames.add(name); } if (!symbol) { - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); if (isReplaceableByMethod) symbol.isReplaceableByMethod = true; } @@ -45504,20 +45634,20 @@ var ts; if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); } - else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) { + else if (!(includes & 3 /* SymbolFlags.Variable */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { // Assignment declarations are allowed to merge with variables, no matter what other flags they have. if (ts.isNamedDeclaration(node)) { ts.setParent(node.name, node); } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message_1 = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; var messageNeedsName_1 = true; - if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ || includes & 384 /* SymbolFlags.Enum */) { message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; messageNeedsName_1 = false; } @@ -45537,7 +45667,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 271 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 271 /* SyntaxKind.ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -45545,9 +45675,9 @@ var ts; } } var relatedInformation_1 = []; - if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) && symbol.flags & (2097152 /* SymbolFlags.Alias */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { // export type T; - may have meant export type { T }? - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -45560,7 +45690,7 @@ var ts; }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false))); - symbol = createSymbol(0 /* None */, name); + symbol = createSymbol(0 /* SymbolFlags.None */, name); } } } @@ -45574,9 +45704,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); - if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 275 /* ExportSpecifier */ || (node.kind === 265 /* ImportEqualsDeclaration */ && hasExportModifier)) { + var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node); + if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -45600,11 +45730,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) { - if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) { + if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -45631,7 +45761,7 @@ var ts; return false; if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* ModifierFlags.Export */) return true; // This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should // already have calculated and branched on most of this. @@ -45664,21 +45794,21 @@ var ts; // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. - if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 214 /* ArrowFunction */) { + if (containerFlags & 1 /* ContainerFlags.IsContainer */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; - if (containerFlags & 32 /* HasLocals */) { + if (containerFlags & 32 /* ContainerFlags.HasLocals */) { container.locals = ts.createSymbolTable(); } addToContainerChain(container); } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { + else if (containerFlags & 2 /* ContainerFlags.IsBlockScopedContainer */) { blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (containerFlags & 4 /* IsControlFlowContainer */) { + if (containerFlags & 4 /* ContainerFlags.IsControlFlowContainer */) { var saveCurrentFlow = currentFlow; var saveBreakTarget = currentBreakTarget; var saveContinueTarget = currentContinueTarget; @@ -45686,22 +45816,22 @@ var ts; var saveExceptionTarget = currentExceptionTarget; var saveActiveLabelList = activeLabelList; var saveHasExplicitReturn = hasExplicitReturn; - var isImmediatelyInvoked = (containerFlags & 16 /* IsFunctionExpression */ && - !ts.hasSyntacticModifier(node, 256 /* Async */) && + var isImmediatelyInvoked = (containerFlags & 16 /* ContainerFlags.IsFunctionExpression */ && + !ts.hasSyntacticModifier(node, 256 /* ModifierFlags.Async */) && !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node)) || - node.kind === 170 /* ClassStaticBlockDeclaration */; + node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isImmediatelyInvoked) { - currentFlow = initFlowNode({ flags: 2 /* Start */ }); - if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); + if (containerFlags & (16 /* ContainerFlags.IsFunctionExpression */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { currentFlow.node = node; } } // 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 = isImmediatelyInvoked || node.kind === 171 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* SyntaxKind.Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -45709,21 +45839,21 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~2816 /* ReachabilityAndEmitFlags */; - if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 256 /* HasImplicitReturn */; + node.flags &= ~2816 /* NodeFlags.ReachabilityAndEmitFlags */; + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && containerFlags & 8 /* ContainerFlags.IsFunctionLike */ && ts.nodeIsPresent(node.body)) { + node.flags |= 256 /* NodeFlags.HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 512 /* HasExplicitReturn */; + node.flags |= 512 /* NodeFlags.HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 171 /* Constructor */ || node.kind === 170 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */))) { + if (node.kind === 171 /* SyntaxKind.Constructor */ || node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -45737,10 +45867,10 @@ var ts; activeLabelList = saveActiveLabelList; hasExplicitReturn = saveHasExplicitReturn; } - else if (containerFlags & 64 /* IsInterface */) { + else if (containerFlags & 64 /* ContainerFlags.IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* NodeFlags.ContainsThis */ : node.flags & ~128 /* NodeFlags.ContainsThis */; } else { bindChildren(node); @@ -45750,8 +45880,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -45774,59 +45904,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 237 /* FirstStatement */ && node.kind <= 253 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 237 /* SyntaxKind.FirstStatement */ && node.kind <= 253 /* SyntaxKind.LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: bindWhileStatement(node); break; - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: bindDoStatement(node); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: bindForStatement(node); break; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: bindForInOrForOfStatement(node); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: bindIfStatement(node); break; - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: bindReturnOrThrow(node); break; - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: bindTryStatement(node); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: bindSwitchStatement(node); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: bindCaseBlock(node); break; - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: bindCaseClause(node); break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: bindExpressionStatement(node); break; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: bindLabeledStatement(node); break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -45836,47 +45966,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bindCallExpressionFlow(node); break; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 305 /* SourceFile */: { + case 305 /* SyntaxKind.SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: bindBindingElementFlow(node); break; - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 296 /* PropertyAssignment */: - case 225 /* SpreadElement */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 225 /* SyntaxKind.SpreadElement */: // Carry over whether we are in an assignment pattern of Object and Array literals // as well as their children that are valid assignment targets. inAssignmentPattern = saveInAssignmentPattern; @@ -45890,22 +46020,22 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 108 /* ThisKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return containsNarrowableReference(expr); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return hasNarrowableArgument(expr); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isNarrowingExpression(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 219 /* PrefixUnaryExpression */: - return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 216 /* TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand); + case 216 /* SyntaxKind.TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -45913,7 +46043,7 @@ var ts; function isNarrowableReference(expr) { return ts.isDottedName(expr) || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) - || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(expr.right) || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } @@ -45929,7 +46059,7 @@ var ts; } } } - if (expr.expression.kind === 206 /* PropertyAccessExpression */ && + if (expr.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -45940,68 +46070,68 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return isNarrowingExpression(expr.right); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: return isNarrowableOperand(expr.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowableOperand(expr.right); } } return containsNarrowableReference(expr); } function createBranchLabel() { - return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); + return initFlowNode({ flags: 4 /* FlowFlags.BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); + return initFlowNode({ flags: 8 /* FlowFlags.LoopLabel */, antecedents: undefined }); } function createReduceLabel(target, antecedents, antecedent) { - return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); + return initFlowNode({ flags: 1024 /* FlowFlags.ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */; + flow.flags |= flow.flags & 2048 /* FlowFlags.Referenced */ ? 4096 /* FlowFlags.Shared */ : 2048 /* FlowFlags.Referenced */; } function addAntecedent(label, antecedent) { - if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { + if (!(antecedent.flags & 1 /* FlowFlags.Unreachable */) && !ts.contains(label.antecedents, antecedent)) { (label.antecedents || (label.antecedents = [])).push(antecedent); setFlowNodeReferenced(antecedent); } } function createFlowCondition(flags, antecedent, expression) { - if (antecedent.flags & 1 /* Unreachable */) { + if (antecedent.flags & 1 /* FlowFlags.Unreachable */) { return antecedent; } if (!expression) { - return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; + return flags & 32 /* FlowFlags.TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* SyntaxKind.TrueKeyword */ && flags & 64 /* FlowFlags.FalseCondition */ || + expression.kind === 95 /* SyntaxKind.FalseKeyword */ && flags & 32 /* FlowFlags.TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -46013,7 +46143,7 @@ var ts; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); + return initFlowNode({ flags: 128 /* FlowFlags.SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowMutation(flags, antecedent, node) { setFlowNodeReferenced(antecedent); @@ -46025,7 +46155,7 @@ var ts; } function createFlowCall(antecedent, node) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + return initFlowNode({ flags: 512 /* FlowFlags.Call */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -46040,28 +46170,28 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return parent.expression === node; - case 242 /* ForStatement */: - case 222 /* ConditionalExpression */: + case 242 /* SyntaxKind.ForStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 212 /* ParenthesizedExpression */) { + if (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 219 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && node.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.operand; } else { - return node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 56 /* BarBarToken */ || - node.operatorToken.kind === 60 /* QuestionQuestionToken */); + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || + node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */); } } } @@ -46071,7 +46201,7 @@ var ts; } function isTopLevelLogicalExpression(node) { while (ts.isParenthesizedExpression(node.parent) || - ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && @@ -46090,8 +46220,8 @@ var ts; function bindCondition(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindIterativeStatement(node, breakTarget, continueTarget) { @@ -46105,7 +46235,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 250 /* LabeledStatement */) { + while (label && node.parent.kind === 250 /* SyntaxKind.LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -46156,12 +46286,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 244 /* ForOfStatement */) { + if (node.kind === 244 /* SyntaxKind.ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 255 /* VariableDeclarationList */) { + if (node.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -46183,7 +46313,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 247 /* ReturnStatement */) { + if (node.kind === 247 /* SyntaxKind.ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -46200,7 +46330,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 246 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 246 /* SyntaxKind.BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -46271,7 +46401,7 @@ var ts; finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents); currentFlow = finallyLabel; bind(node.finallyBlock); - if (currentFlow.flags & 1 /* Unreachable */) { + if (currentFlow.flags & 1 /* FlowFlags.Unreachable */) { // If the end of the finally block is unreachable, the end of the entire try statement is unreachable. currentFlow = unreachableFlow; } @@ -46305,7 +46435,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* SyntaxKind.DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -46334,7 +46464,7 @@ var ts; var clause = clauses[i]; bind(clause); fallthroughFlow = currentFlow; - if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { clause.fallthroughFlowNode = currentFlow; } } @@ -46353,9 +46483,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { var call = node; - if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { + if (call.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -46379,7 +46509,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -46388,12 +46518,12 @@ var ts; } function bindAssignmentTargetFlow(node) { if (isNarrowableReference(node)) { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } - else if (node.kind === 204 /* ArrayLiteralExpression */) { + else if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 225 /* SpreadElement */) { + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -46401,16 +46531,16 @@ var ts; } } } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 296 /* PropertyAssignment */) { + if (p.kind === 296 /* SyntaxKind.PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 297 /* ShorthandPropertyAssignment */) { + else if (p.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 298 /* SpreadAssignment */) { + else if (p.kind === 298 /* SyntaxKind.SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -46418,7 +46548,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -46429,15 +46559,15 @@ var ts; if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) { doWithConditionalBranches(bind, node.right, trueTarget, falseTarget); bindAssignmentTargetFlow(node.left); - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } else { bindCondition(node.right, trueTarget, falseTarget); } } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 53 /* ExclamationToken */) { + if (node.operator === 53 /* SyntaxKind.ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -46447,14 +46577,14 @@ var ts; } else { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -46503,9 +46633,9 @@ var ts; // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too // For now, though, since the common cases are chained `+`, leaving it recursive is fine var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || - operator === 56 /* BarBarToken */ || - operator === 60 /* QuestionQuestionToken */ || + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + operator === 56 /* SyntaxKind.BarBarToken */ || + operator === 60 /* SyntaxKind.QuestionQuestionToken */ || ts.isLogicalOrCoalescingAssignmentOperator(operator)) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); @@ -46522,7 +46652,7 @@ var ts; function onLeft(left, state, node) { if (!state.skip) { var maybeBound = maybeBind(left); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(left); } return maybeBound; @@ -46536,7 +46666,7 @@ var ts; function onRight(right, state, node) { if (!state.skip) { var maybeBound = maybeBind(right); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(right); } return maybeBound; @@ -46547,10 +46677,10 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 63 /* EqualsToken */ && node.left.kind === 207 /* ElementAccessExpression */) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && node.left.kind === 207 /* SyntaxKind.ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } @@ -46575,7 +46705,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -46603,7 +46733,7 @@ var ts; } } else { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } } function bindVariableDeclarationFlow(node) { @@ -46630,7 +46760,7 @@ var ts; } function bindJSDocTypeAlias(node) { bind(node.tagName); - if (node.kind !== 339 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 339 /* SyntaxKind.JSDocEnumTag */ && node.fullName) { // don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); @@ -46642,28 +46772,28 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 169 /* MethodDeclaration */) { - addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + if (host && host.kind !== 169 /* SyntaxKind.MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* SymbolFlags.Class */); } } function bindOptionalExpression(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainRest(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -46689,8 +46819,8 @@ var ts; } doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); if (ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainFlow(node) { @@ -46728,76 +46858,76 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 213 /* FunctionExpression */ || expr.kind === 214 /* ArrowFunction */) { + if (expr.kind === 213 /* SyntaxKind.FunctionExpression */ || expr.kind === 214 /* SyntaxKind.ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } function getContainerFlags(node) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 286 /* JsxAttributes */: - return 1 /* IsContainer */; - case 258 /* InterfaceDeclaration */: - return 1 /* IsContainer */ | 64 /* IsInterface */; - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: - case 176 /* IndexSignature */: - return 1 /* IsContainer */ | 32 /* HasLocals */; - case 305 /* SourceFile */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 286 /* SyntaxKind.JsxAttributes */: + return 1 /* ContainerFlags.IsContainer */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */; + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: + case 176 /* SyntaxKind.IndexSignature */: + return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */; + case 305 /* SyntaxKind.SourceFile */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */; + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */; } // falls through - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 317 /* JSDocFunctionType */: - case 179 /* FunctionType */: - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: - case 170 /* ClassStaticBlockDeclaration */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 262 /* ModuleBlock */: - return 4 /* IsControlFlowContainer */; - case 167 /* PropertyDeclaration */: - return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 292 /* CatchClause */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 263 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 235 /* Block */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 179 /* SyntaxKind.FunctionType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */; + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 16 /* ContainerFlags.IsFunctionExpression */; + case 262 /* SyntaxKind.ModuleBlock */: + return 4 /* ContainerFlags.IsControlFlowContainer */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return node.initializer ? 4 /* ContainerFlags.IsControlFlowContainer */ : 0; + case 292 /* SyntaxKind.CatchClause */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 263 /* SyntaxKind.CaseBlock */: + return 2 /* ContainerFlags.IsBlockScopedContainer */; + case 235 /* SyntaxKind.Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -46814,9 +46944,9 @@ var ts; // By not creating a new block-scoped-container here, we ensure that both 'var x' // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. - return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* ContainerFlags.None */ : 2 /* ContainerFlags.IsBlockScopedContainer */; } - return 0 /* None */; + return 0 /* ContainerFlags.None */; } function addToContainerChain(next) { if (lastContainer) { @@ -46830,46 +46960,46 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 205 /* ObjectLiteralExpression */: - case 258 /* InterfaceDeclaration */: - case 286 /* JsxAttributes */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 286 /* SyntaxKind.JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 323 /* JSDocSignature */: - case 176 /* IndexSignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 317 /* JSDocFunctionType */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 170 /* ClassStaticBlockDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -46896,17 +47026,17 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 64 /* ExportContext */; + if (node.flags & 16777216 /* NodeFlags.Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* NodeFlags.ExportContext */; } else { - node.flags &= ~64 /* ExportContext */; + node.flags &= ~64 /* NodeFlags.ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isModuleAugmentationExternal(node)) { @@ -46914,25 +47044,25 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 10 /* StringLiteral */) { + if (node.name.kind === 10 /* SyntaxKind.StringLiteral */) { var text = node.name.text; pattern = ts.tryParsePattern(text); if (pattern === undefined) { errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); } } - var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */); + var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* SymbolFlags.ValueModule */, 110735 /* SymbolFlags.ValueModuleExcludes */); file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { var state = declareModuleSymbol(node); - if (state !== 0 /* NonInstantiated */) { + if (state !== 0 /* ModuleInstanceState.NonInstantiated */) { var symbol = node.symbol; // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only - symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) + symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) // Current must be `const enum` only - && state === 2 /* ConstEnumOnly */ + && state === 2 /* ModuleInstanceState.ConstEnumOnly */ // Can't have been set to 'false' in a previous merged symbol. ('undefined' OK) && symbol.constEnumOnlyModule !== false; } @@ -46940,8 +47070,8 @@ var ts; } function declareModuleSymbol(node) { var state = getModuleInstanceState(node); - var instantiated = state !== 0 /* NonInstantiated */; - declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + var instantiated = state !== 0 /* ModuleInstanceState.NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* SymbolFlags.ValueModule */ : 1024 /* SymbolFlags.NamespaceModule */, instantiated ? 110735 /* SymbolFlags.ValueModuleExcludes */ : 0 /* SymbolFlags.NamespaceModuleExcludes */); return state; } function bindFunctionOrConstructorType(node) { @@ -46951,56 +47081,25 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + var symbol = createSymbol(131072 /* SymbolFlags.Signature */, getDeclarationName(node)); // TODO: GH#18217 + addDeclarationToSymbol(symbol, node, 131072 /* SymbolFlags.Signature */); + var typeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* SymbolFlags.TypeLiteral */); typeLiteralSymbol.members = ts.createSymbolTable(); typeLiteralSymbol.members.set(symbol.escapedName, symbol); } function bindObjectLiteralExpression(node) { - var ElementKind; - (function (ElementKind) { - ElementKind[ElementKind["Property"] = 1] = "Property"; - ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; - })(ElementKind || (ElementKind = {})); - if (inStrictMode && !ts.isAssignmentTarget(node)) { - var seen = new ts.Map(); - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { - continue; - } - var identifier = prop.name; - // ECMA-262 11.1.5 Object Initializer - // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true - // a.This production is contained in strict code and IsDataDescriptor(previous) is true and - // IsDataDescriptor(propId.descriptor) is true. - // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. - // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. - // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true - // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; - var existingKind = seen.get(identifier.escapedText); - if (!existingKind) { - seen.set(identifier.escapedText, currentKind); - continue; - } - } - } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__object" /* InternalSymbolName.Object */); } function bindJsxAttributes(node) { - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__jsxAttributes" /* InternalSymbolName.JSXAttributes */); } function bindJsxAttribute(node, symbolFlags, symbolExcludes) { return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); - if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) { + if (symbolFlags & (8 /* SymbolFlags.EnumMember */ | 106500 /* SymbolFlags.ClassMember */)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); @@ -47008,10 +47107,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -47037,9 +47136,9 @@ var ts; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; var host = typeAlias.parent.parent; - container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* ContainerFlags.IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = initFlowNode({ flags: 2 /* Start */ }); + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -47050,8 +47149,8 @@ var ts; bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: if (!ts.isExternalOrCommonJsModule(file)) { container = undefined; } @@ -47059,29 +47158,29 @@ var ts; container = file; } break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: container = declName.parent.expression; break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: container = declName.parent.expression.name; break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } if (container) { - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + declareModuleMember(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* SyntaxKind.Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -47099,24 +47198,24 @@ var ts; function checkContextualIdentifier(node) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length && - !(node.flags & 16777216 /* Ambient */) && - !(node.flags & 8388608 /* JSDoc */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && + !(node.flags & 8388608 /* NodeFlags.JSDoc */) && !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 132 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); } - else if (node.flags & 32768 /* AwaitContext */) { + else if (node.flags & 32768 /* NodeFlags.AwaitContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } - else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -47158,7 +47257,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 79 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* SyntaxKind.Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -47169,7 +47268,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 79 /* Identifier */) { + if (name && name.kind === 79 /* SyntaxKind.Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -47208,10 +47307,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 305 /* SourceFile */ && - blockScopeContainer.kind !== 261 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ && + blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -47221,7 +47320,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -47237,7 +47336,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -47250,7 +47349,7 @@ var ts; } function checkStrictModeLabeledStatement(node) { // Grammar checking for labeledStatement - if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) { + if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ScriptTarget.ES2015 */) { if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) { errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here); } @@ -47308,11 +47407,11 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 160 /* LastToken */) { + if (node.kind > 160 /* SyntaxKind.LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); - if (containerFlags === 0 /* None */) { + if (containerFlags === 0 /* ContainerFlags.None */) { bindChildren(node); } else { @@ -47322,7 +47421,7 @@ var ts; } else { var saveParent = parent; - if (node.kind === 1 /* EndOfFileToken */) + if (node.kind === 1 /* SyntaxKind.EndOfFileToken */) parent = node; bindJSDoc(node); parent = saveParent; @@ -47370,7 +47469,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -47379,28 +47478,28 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); break; } // falls through - case 108 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* ShorthandPropertyAssignment */)) { + case 108 /* SyntaxKind.ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 231 /* MetaProperty */: - case 106 /* SuperKeyword */: + case 231 /* SyntaxKind.MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: node.flowNode = currentFlow; break; - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifier(node); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -47412,28 +47511,28 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForName(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* SymbolFlags.FunctionScopedVariable */ | 134217728 /* SymbolFlags.ModuleExports */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { - case 1 /* ExportsProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: bindExportsPropertyAssignment(node); break; - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: bindModuleExportsAssignment(node); break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: bindPrototypePropertyAssignment(node.left, node); break; - case 6 /* Prototype */: + case 6 /* AssignmentDeclarationKind.Prototype */: bindPrototypeAssignment(node); break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: bindThisPropertyAssignment(node); break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: var expression = node.left.expression; if (ts.isInJSFile(node) && ts.isIdentifier(expression)) { var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText); @@ -47444,94 +47543,94 @@ var ts; } bindSpecialPropertyAssignment(node); break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: // Nothing to do break; default: ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return checkStrictModeCatchClause(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkStrictModeWithStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: seenThisKeyword = true; return; - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: break; // Binding the children will handle everything - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return bindTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return bindParameter(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return bindPropertyWorker(node); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 299 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); + case 299 /* SyntaxKind.EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */); + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */); + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 256 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), ts.isObjectLiteralMethod(node) ? 0 /* SymbolFlags.PropertyExcludes */ : 103359 /* SymbolFlags.MethodExcludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: return bindFunctionDeclaration(node); - case 171 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 172 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 173 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: - case 180 /* ConstructorType */: + case 171 /* SyntaxKind.Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, /*symbolExcludes:*/ 0 /* SymbolFlags.None */); + case 172 /* SyntaxKind.GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46015 /* SymbolFlags.GetAccessorExcludes */); + case 173 /* SyntaxKind.SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78783 /* SymbolFlags.SetAccessorExcludes */); + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: + case 180 /* SyntaxKind.ConstructorType */: return bindFunctionOrConstructorType(node); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 195 /* MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 195 /* SyntaxKind.MappedType */: return bindAnonymousTypeWorker(node); - case 332 /* JSDocClassTag */: + case 332 /* SyntaxKind.JSDocClassTag */: return bindJSDocClassTag(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return bindFunctionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { - case 7 /* ObjectDefinePropertyValue */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: return bindObjectDefinePropertyAssignment(node); - case 8 /* ObjectDefinePropertyExports */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: return bindObjectDefinePropertyExport(node); - case 9 /* ObjectDefinePrototypeProperty */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return bindObjectDefinePrototypeProperty(node); - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: break; // Nothing to do default: return ts.Debug.fail("Unknown call expression assignment declaration kind"); @@ -47541,73 +47640,73 @@ var ts; } break; // Members of classes, interfaces, and modules - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 258 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 259 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 260 /* EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */); + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); + case 260 /* SyntaxKind.EnumDeclaration */: return bindEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return bindJsxAttributes(node); - case 285 /* JsxAttribute */: - return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); + case 285 /* SyntaxKind.JsxAttribute */: + return bindJsxAttribute(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); // Imports and exports - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 264 /* NamespaceExportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return bindImportClause(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return bindExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return bindExportAssignment(node); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 340 /* JSDocParameterTag */: - if (node.parent.kind === 323 /* JSDocSignature */) { + case 340 /* SyntaxKind.JSDocParameterTag */: + if (node.parent.kind === 323 /* SyntaxKind.JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 322 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 322 /* SyntaxKind.JSDocTypeLiteral */) { break; } // falls through - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; - return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ ? + 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */ : + 4 /* SymbolFlags.Property */; + return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* SymbolFlags.PropertyExcludes */); + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } function bindPropertyWorker(node) { - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } function bindAnonymousTypeWorker(node) { - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */); + return bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); } function bindSourceFileIfExternalModule() { setExportContextFlag(file); @@ -47618,27 +47717,27 @@ var ts; bindSourceFileAsExternalModule(); // Create symbol equivalent for the module.exports = {} var originalSymbol = file.symbol; - declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */); + declareSymbol(file.symbol.exports, file.symbol, file, 4 /* SymbolFlags.Property */, 67108863 /* SymbolFlags.All */); file.symbol = originalSymbol; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512 /* SymbolFlags.ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { // Incorrect export assignment in some sort of block construct - bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 111551 /* SymbolFlags.Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ + ? 2097152 /* SymbolFlags.Alias */ // An export default clause with any other expression exports a value - : 4 /* Property */; + : 4 /* SymbolFlags.Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) - var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); + var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* SymbolFlags.All */); if (node.isExportEquals) { // Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set. ts.setValueDeclaration(symbol, node); @@ -47658,28 +47757,28 @@ var ts; } else { file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable(); - declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 8388608 /* SymbolFlags.ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */); } else if (ts.isNamespaceExport(node.exportClause)) { // declareSymbol walks up parents to find name text, parent _must_ be set // but won't be set by the normal binder walk until `bindChildren` later on. ts.setParent(node.exportClause, node); - declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindImportClause(node) { if (node.name) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function setCommonJsModuleIndicator(node) { @@ -47700,13 +47799,13 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { - var flags = 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + var flags = 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* SymbolFlags.None */); } } function bindExportsPropertyAssignment(node) { @@ -47717,15 +47816,15 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression)); - var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */; + var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; ts.setParent(node.left, node); - declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */); } } function bindModuleExportsAssignment(node) { @@ -47746,13 +47845,13 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + ? 2097152 /* SymbolFlags.Alias */ + : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */ | 512 /* SymbolFlags.ValueModule */; + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); ts.setValueDeclaration(symbol, node); } function bindExportAssignedObjectMemberAlias(node) { - declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); @@ -47764,11 +47863,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -47782,17 +47881,17 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); } else { - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */); } - addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } break; - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -47801,19 +47900,19 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); } else { - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true); } break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; } else if (thisContainer.commonJsModuleIndicator) { - declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); + declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; default: @@ -47821,7 +47920,7 @@ var ts; } } function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) { - declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); + declareSymbol(symbolTable, symbol, node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); addLateBoundAssignmentDeclarationToSymbol(node, symbol); } function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { @@ -47830,10 +47929,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 108 /* ThisKeyword */) { + if (node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -47852,7 +47951,7 @@ var ts; var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); if (namespaceSymbol && namespaceSymbol.valueDeclaration) { // Ensure the namespace symbol becomes class-like - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } @@ -47873,7 +47972,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 305 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -47885,7 +47984,7 @@ var ts; return; } var rootExpr = ts.getLeftmostAccessExpression(node.left); - if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) { + if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* SymbolFlags.Alias */) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them @@ -47898,7 +47997,7 @@ var ts; bindExportsPropertyAssignment(node); } else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + bindAnonymousDeclaration(node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, "__computed" /* InternalSymbolName.Computed */); var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); addLateBoundAssignmentDeclarationToSymbol(node, sym); } @@ -47916,13 +48015,13 @@ var ts; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { - if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) { + if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* SymbolFlags.Alias */) { return namespaceSymbol; } if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers - var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */; - var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; + var flags_2 = 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */; + var excludeFlags_1 = 110735 /* SymbolFlags.ValueModuleExcludes */ & ~67108864 /* SymbolFlags.Assignment */; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_2); @@ -47936,7 +48035,7 @@ var ts; }); } if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } return namespaceSymbol; } @@ -47948,12 +48047,12 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var includes = 0 /* None */; - var excludes = 0 /* None */; + var includes = 0 /* SymbolFlags.None */; + var excludes = 0 /* SymbolFlags.None */; // Method-like if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { - includes = 8192 /* Method */; - excludes = 103359 /* MethodExcludes */; + includes = 8192 /* SymbolFlags.Method */; + excludes = 103359 /* SymbolFlags.MethodExcludes */; } // Maybe accessor-like else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { @@ -47963,27 +48062,27 @@ var ts; })) { // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) - includes |= 65536 /* SetAccessor */ | 4 /* Property */; - excludes |= 78783 /* SetAccessorExcludes */; + includes |= 65536 /* SymbolFlags.SetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 78783 /* SymbolFlags.SetAccessorExcludes */; } if (ts.some(declaration.arguments[2].properties, function (p) { var id = ts.getNameOfDeclaration(p); return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; })) { - includes |= 32768 /* GetAccessor */ | 4 /* Property */; - excludes |= 46015 /* GetAccessorExcludes */; + includes |= 32768 /* SymbolFlags.GetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 46015 /* SymbolFlags.GetAccessorExcludes */; } } - if (includes === 0 /* None */) { - includes = 4 /* Property */; - excludes = 0 /* PropertyExcludes */; + if (includes === 0 /* SymbolFlags.None */) { + includes = 4 /* SymbolFlags.Property */; + excludes = 0 /* SymbolFlags.PropertyExcludes */; } - declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* SymbolFlags.Assignment */, excludes & ~67108864 /* SymbolFlags.Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SourceFile */ - : propertyAccess.parent.parent.kind === 305 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SyntaxKind.SourceFile */ + : propertyAccess.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -48002,7 +48101,7 @@ var ts; * - with non-empty object literals if assigned to the prototype property */ function isExpandoSymbol(symbol) { - if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 1024 /* SymbolFlags.NamespaceModule */)) { return true; } var node = symbol.valueDeclaration; @@ -48017,7 +48116,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || init.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -48062,12 +48161,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 257 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); + if (node.kind === 257 /* SyntaxKind.ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */); } else { - var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__class" /* InternalSymbolName.Class */; + bindAnonymousDeclaration(node, 32 /* SymbolFlags.Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { classifiableNames.add(node.name.escapedText); @@ -48083,7 +48182,7 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype"); + var prototypeSymbol = createSymbol(4 /* SymbolFlags.Property */ | 4194304 /* SymbolFlags.Prototype */, "prototype"); var symbolExport = symbol.exports.get(prototypeSymbol.escapedName); if (symbolExport) { if (node.name) { @@ -48096,23 +48195,23 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent; + var possibleVariableDecl = node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node : node.parent.parent; if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !ts.getJSDocTypeTag(node) && - !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) { + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); + bindBlockScopedDeclaration(node, 2 /* SymbolFlags.BlockScopedVariable */, 111551 /* SymbolFlags.BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -48124,72 +48223,72 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) { + if (node.kind === 340 /* SyntaxKind.JSDocParameterTag */ && container.kind !== 323 /* SyntaxKind.JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) { + if (inStrictMode && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); + bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } if (currentFlow) { node.flowNode = currentFlow; } checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.escapedText : "__function" /* Function */; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__function" /* InternalSymbolName.Function */; + return bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { node.flowNode = currentFlow; } return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* InternalSymbolName.Computed */) : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function getInferTypeContainer(node) { @@ -48203,45 +48302,45 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } - else if (node.parent.kind === 190 /* InferType */) { + else if (node.parent.kind === 190 /* SyntaxKind.InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 + bindAnonymousDeclaration(node, 262144 /* SymbolFlags.TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); + return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { - if (!(currentFlow.flags & 1 /* Unreachable */)) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) { return false; } if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) || // report error on class declarations - node.kind === 257 /* ClassDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 261 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -48255,9 +48354,9 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 16777216 /* Ambient */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && (!ts.isVariableStatement(node) || - !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); }); } @@ -48281,27 +48380,28 @@ var ts; // Don't remove statements that can validly be used before they appear. return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) && // `var x;` may declare a variable used above - !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); + !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* NodeFlags.Let */ | 2 /* NodeFlags.Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 261 /* ModuleDeclaration */: - return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 260 /* EnumDeclaration */: - return ts.hasSyntacticModifier(s, 2048 /* Const */); + case 261 /* SyntaxKind.ModuleDeclaration */: + return getModuleInstanceState(s) !== 1 /* ModuleInstanceState.Instantiated */; + case 260 /* SyntaxKind.EnumDeclaration */: + return ts.hasSyntacticModifier(s, 2048 /* ModifierFlags.Const */); default: return false; } } function isExportsOrModuleExportsOrAlias(sourceFile, node) { var i = 0; - var q = [node]; - while (q.length && i < 100) { + var q = ts.createQueue(); + q.enqueue(node); + while (!q.isEmpty() && i < 100) { i++; - node = q.shift(); + node = q.dequeue(); if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } @@ -48309,10 +48409,10 @@ var ts; var symbol = lookupSymbolForName(sourceFile, node.escapedText); if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) { var init = symbol.valueDeclaration.initializer; - q.push(init); + q.enqueue(init); if (ts.isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) { - q.push(init.left); - q.push(init.right); + q.enqueue(init.left); + q.enqueue(init.right); } } } @@ -48376,32 +48476,32 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var objectType = type; var objectFlags = objectType.objectFlags; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { visitTypeReference(type); } - if (objectFlags & 32 /* Mapped */) { + if (objectFlags & 32 /* ObjectFlags.Mapped */) { visitMappedType(type); } - if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + if (objectFlags & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { visitInterfaceType(type); } - if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + if (objectFlags & (8 /* ObjectFlags.Tuple */ | 16 /* ObjectFlags.Anonymous */)) { visitObjectType(objectType); } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { visitIndexType(type); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { visitIndexedAccessType(type); } } @@ -48490,7 +48590,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 181 /* TypeQuery */) { + if (d.type && d.type.kind === 181 /* SyntaxKind.TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -48627,16 +48727,16 @@ var ts; // Masks TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask"; TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask"; - })(TypeFacts || (TypeFacts = {})); + })(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {})); var typeofNEFacts = new ts.Map(ts.getEntries({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ + string: 256 /* TypeFacts.TypeofNEString */, + number: 512 /* TypeFacts.TypeofNENumber */, + bigint: 1024 /* TypeFacts.TypeofNEBigInt */, + boolean: 2048 /* TypeFacts.TypeofNEBoolean */, + symbol: 4096 /* TypeFacts.TypeofNESymbol */, + undefined: 524288 /* TypeFacts.NEUndefined */, + object: 8192 /* TypeFacts.TypeofNEObject */, + function: 16384 /* TypeFacts.TypeofNEFunction */ })); var TypeSystemPropertyName; (function (TypeSystemPropertyName) { @@ -48662,7 +48762,7 @@ var ts; CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement"; // e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`, // we need to preserve generic types instead of substituting them for constraints - })(CheckMode || (CheckMode = {})); + })(CheckMode = ts.CheckMode || (ts.CheckMode = {})); var SignatureCheckMode; (function (SignatureCheckMode) { SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback"; @@ -48670,7 +48770,7 @@ var ts; SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes"; SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity"; SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback"; - })(SignatureCheckMode || (SignatureCheckMode = {})); + })(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {})); var IntersectionState; (function (IntersectionState) { IntersectionState[IntersectionState["None"] = 0] = "None"; @@ -48742,10 +48842,10 @@ var ts; IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize"; })(IntrinsicTypeKind || (IntrinsicTypeKind = {})); var intrinsicTypeKinds = new ts.Map(ts.getEntries({ - Uppercase: 0 /* Uppercase */, - Lowercase: 1 /* Lowercase */, - Capitalize: 2 /* Capitalize */, - Uncapitalize: 3 /* Uncapitalize */ + Uppercase: 0 /* IntrinsicTypeKind.Uppercase */, + Lowercase: 1 /* IntrinsicTypeKind.Lowercase */, + Capitalize: 2 /* IntrinsicTypeKind.Capitalize */, + Uncapitalize: 3 /* IntrinsicTypeKind.Uncapitalize */ })); function SymbolLinks() { } @@ -48770,8 +48870,8 @@ var ts; ts.getSymbolId = getSymbolId; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + return moduleState === 1 /* ModuleInstanceState.Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ModuleInstanceState.ConstEnumOnly */); } ts.isInstantiatedModule = isInstantiatedModule; function createTypeChecker(host) { @@ -48786,7 +48886,7 @@ var ts; return; sf.resolvedModules.forEach(function (r) { if (r && r.packageId) - map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name)); + map.set(r.packageId.name, r.extension === ".d.ts" /* Extension.Dts */ || !!map.get(r.packageId.name)); }); }); return map; @@ -48820,7 +48920,7 @@ var ts; var currentNode; var varianceTypeParameter; var emptySymbols = ts.createSymbolTable(); - var arrayVariances = [1 /* Covariant */]; + var arrayVariances = [1 /* VarianceFlags.Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -48834,20 +48934,20 @@ var ts; var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* ObjectFlags.FreshLiteral */; var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); - var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); + var undefinedSymbol = createSymbol(4 /* SymbolFlags.Property */, "undefined"); undefinedSymbol.declarations = []; - var globalThisSymbol = createSymbol(1536 /* Module */, "globalThis", 8 /* Readonly */); + var globalThisSymbol = createSymbol(1536 /* SymbolFlags.Module */, "globalThis", 8 /* CheckFlags.Readonly */); globalThisSymbol.exports = globals; globalThisSymbol.declarations = []; globals.set(globalThisSymbol.escapedName, globalThisSymbol); - var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); - var requireSymbol = createSymbol(4 /* Property */, "require"); + var argumentsSymbol = createSymbol(4 /* SymbolFlags.Property */, "arguments"); + var requireSymbol = createSymbol(4 /* SymbolFlags.Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; // for public members that accept a Node or one of its subtypes, we must guard against @@ -48899,10 +48999,10 @@ var ts; return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined; }, getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, - getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexInfosOfType: getIndexInfosOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexType: function (type) { return getIndexType(type); }, getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, @@ -48997,14 +49097,14 @@ var ts; if (!node) { return undefined; } - if (contextFlags & 4 /* Completions */) { + if (contextFlags & 4 /* ContextFlags.Completions */) { return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); }); } return getContextualType(node, contextFlags); }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); - return node ? getContextualTypeForObjectLiteralElement(node) : undefined; + return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined; }, getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); @@ -49012,19 +49112,19 @@ var ts; }, getContextualTypeForJsxAttribute: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); - return node && getContextualTypeForJsxAttribute(node); + return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined); }, isContextSensitive: isContextSensitive, getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* CheckMode.Normal */); }, getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) { - return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument); + return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* CheckMode.IsForStringLiteralArgumentCompletions */, editingArgument); }, getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* CheckMode.IsForSignatureHelp */); }, getExpandedParameters: getExpandedParameters, hasEffectiveRestParameter: hasEffectiveRestParameter, @@ -49110,7 +49210,7 @@ var ts; getSuggestionForNonexistentExport: getSuggestionForNonexistentExport, getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeFlags.TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -49147,10 +49247,10 @@ var ts; cancellationToken = ct; // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused checkSourceFileWithEagerDiagnostics(file); - ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* NodeCheckFlags.TypeChecked */)); diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); @@ -49218,35 +49318,35 @@ var ts; var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); var subtypeReductionCache = new ts.Map(); + var cachedTypes = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); - var unknownSymbol = createSymbol(4 /* Property */, "unknown"); - var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */); + var unknownSymbol = createSymbol(4 /* SymbolFlags.Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__" /* InternalSymbolName.Resolving */); var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var autoType = createIntrinsicType(1 /* Any */, "any"); - var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var errorType = createIntrinsicType(1 /* Any */, "error"); - var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */); - var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); - var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */); - var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; - var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */); - var stringType = createIntrinsicType(4 /* String */, "string"); - var numberType = createIntrinsicType(8 /* Number */, "number"); - var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); - var falseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); + var anyType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var autoType = createIntrinsicType(1 /* TypeFlags.Any */, "any", 262144 /* ObjectFlags.NonInferrableType */); + var wildcardType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var errorType = createIntrinsicType(1 /* TypeFlags.Any */, "error"); + var unresolvedType = createIntrinsicType(1 /* TypeFlags.Any */, "unresolved"); + var intrinsicMarkerType = createIntrinsicType(1 /* TypeFlags.Any */, "intrinsic"); + var unknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var nonNullUnknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var undefinedType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined", 65536 /* ObjectFlags.ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined") : undefinedType; + var nullType = createIntrinsicType(65536 /* TypeFlags.Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* TypeFlags.Null */, "null", 65536 /* ObjectFlags.ContainsWideningType */); + var stringType = createIntrinsicType(4 /* TypeFlags.String */, "string"); + var numberType = createIntrinsicType(8 /* TypeFlags.Number */, "number"); + var bigintType = createIntrinsicType(64 /* TypeFlags.BigInt */, "bigint"); + var falseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var regularFalseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var trueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); + var regularTrueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); trueType.regularType = regularTrueType; trueType.freshType = trueType; regularTrueType.regularType = regularTrueType; @@ -49256,28 +49356,40 @@ var ts; regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = getUnionType([regularFalseType, regularTrueType]); - var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16384 /* Void */, "void"); - var neverType = createIntrinsicType(131072 /* Never */, "never"); - var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */); - var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); - var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(4096 /* TypeFlags.ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16384 /* TypeFlags.Void */, "void"); + var neverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var silentNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never", 262144 /* ObjectFlags.NonInferrableType */); + var implicitNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* TypeFlags.NonPrimitive */, "object"); var stringOrNumberType = getUnionType([stringType, numberType]); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); - var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }, function () { return "(restrictive mapper)"; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? wildcardType : t; }, function () { return "(permissive mapper)"; }); + var uniqueLiteralType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? uniqueLiteralType : t; }, function () { return "(unique literal mapper)"; }); // replace all type parameters with the unique literal type (disregarding constraints) + var outofbandVarianceMarkerHandler; + var reportUnreliableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true); + } + return t; + }, function () { return "(unmeasurable reporter)"; }); + var reportUnmeasurableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false); + } + return t; + }, function () { return "(unreliable reporter)"; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); - emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + emptyJsxObjectType.objectFlags |= 2048 /* ObjectFlags.JsxAttributes */; + var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType; @@ -49286,7 +49398,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 262144 /* NonInferrableType */; + anyFunctionType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -49294,11 +49406,14 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var markerSuperTypeForCheck = createTypeParameter(); + var markerSubTypeForCheck = createTypeParameter(); + markerSubTypeForCheck.constraint = markerSuperTypeForCheck; + var noTypePredicate = createTypePredicate(1 /* TypePredicateKind.Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true); var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances var noIterationTypes = { @@ -49430,7 +49545,6 @@ var ts; var typeofType = createTypeofType(); var _jsxNamespace; var _jsxFactoryEntity; - var outofbandVarianceMarkerHandler; var subtypeRelation = new ts.Map(); var strictSubtypeRelation = new ts.Map(); var assignableRelation = new ts.Map(); @@ -49450,12 +49564,20 @@ var ts; [".mjs", ".mjs"], [".js", ".js"], [".cjs", ".cjs"], - [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"], + [".tsx", compilerOptions.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" : ".js"], [".jsx", ".jsx"], [".json", ".json"], ]; initializeTypeChecker(); return checker; + function getCachedType(key) { + return key ? cachedTypes.get(key) : undefined; + } + function setCachedType(key, type) { + if (key) + cachedTypes.set(key, type); + return type; + } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -49596,7 +49718,7 @@ var ts; return diagnostic; } function isDeprecatedSymbol(symbol) { - return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */); + return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* NodeFlags.Deprecated */); } function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); @@ -49610,44 +49732,44 @@ var ts; } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = new Symbol(flags | 33554432 /* Transient */, name); + var symbol = new Symbol(flags | 33554432 /* SymbolFlags.Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 111551 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 111550 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 0 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 900095 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 110991 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899503 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 788872 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 110735 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 103359 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 46015 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 78783 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 526824 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 788968 /* TypeAliasExcludes */; - if (flags & 2097152 /* Alias */) - result |= 2097152 /* AliasExcludes */; + if (flags & 2 /* SymbolFlags.BlockScopedVariable */) + result |= 111551 /* SymbolFlags.BlockScopedVariableExcludes */; + if (flags & 1 /* SymbolFlags.FunctionScopedVariable */) + result |= 111550 /* SymbolFlags.FunctionScopedVariableExcludes */; + if (flags & 4 /* SymbolFlags.Property */) + result |= 0 /* SymbolFlags.PropertyExcludes */; + if (flags & 8 /* SymbolFlags.EnumMember */) + result |= 900095 /* SymbolFlags.EnumMemberExcludes */; + if (flags & 16 /* SymbolFlags.Function */) + result |= 110991 /* SymbolFlags.FunctionExcludes */; + if (flags & 32 /* SymbolFlags.Class */) + result |= 899503 /* SymbolFlags.ClassExcludes */; + if (flags & 64 /* SymbolFlags.Interface */) + result |= 788872 /* SymbolFlags.InterfaceExcludes */; + if (flags & 256 /* SymbolFlags.RegularEnum */) + result |= 899327 /* SymbolFlags.RegularEnumExcludes */; + if (flags & 128 /* SymbolFlags.ConstEnum */) + result |= 899967 /* SymbolFlags.ConstEnumExcludes */; + if (flags & 512 /* SymbolFlags.ValueModule */) + result |= 110735 /* SymbolFlags.ValueModuleExcludes */; + if (flags & 8192 /* SymbolFlags.Method */) + result |= 103359 /* SymbolFlags.MethodExcludes */; + if (flags & 32768 /* SymbolFlags.GetAccessor */) + result |= 46015 /* SymbolFlags.GetAccessorExcludes */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + result |= 78783 /* SymbolFlags.SetAccessorExcludes */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + result |= 526824 /* SymbolFlags.TypeParameterExcludes */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + result |= 788968 /* SymbolFlags.TypeAliasExcludes */; + if (flags & 2097152 /* SymbolFlags.Alias */) + result |= 2097152 /* SymbolFlags.AliasExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -49679,13 +49801,13 @@ var ts; function mergeSymbol(target, source, unidirectional) { if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || - (source.flags | target.flags) & 67108864 /* Assignment */) { + (source.flags | target.flags) & 67108864 /* SymbolFlags.Assignment */) { if (source === target) { // This can happen when an export assigned namespace exports something also erroneously exported at the top level // See `declarationFileNoCrashOnExtraExportModifier` for an example return target; } - if (!(target.flags & 33554432 /* Transient */)) { + if (!(target.flags & 33554432 /* SymbolFlags.Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { return source; @@ -49693,7 +49815,7 @@ var ts; target = cloneSymbol(resolvedTarget); } // Javascript static-property-assignment declarations always merge, even though they are also values - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + if (source.flags & 512 /* SymbolFlags.ValueModule */ && target.flags & 512 /* SymbolFlags.ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums target.constEnumOnlyModule = false; } @@ -49716,7 +49838,7 @@ var ts; recordMergedSymbol(target, source); } } - else if (target.flags & 1024 /* NamespaceModule */) { + else if (target.flags & 1024 /* SymbolFlags.NamespaceModule */) { // Do not report an error when merging `var globalThis` with the built-in `globalThis`, // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. @@ -49725,8 +49847,8 @@ var ts; } } else { // error - var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); - var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var isEitherEnum = !!(target.flags & 384 /* SymbolFlags.Enum */ || source.flags & 384 /* SymbolFlags.Enum */); + var isEitherBlockScoped_1 = !!(target.flags & 2 /* SymbolFlags.BlockScopedVariable */ || source.flags & 2 /* SymbolFlags.BlockScopedVariable */); var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -49737,9 +49859,9 @@ var ts; var symbolName_1 = symbolToString(source); // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { - var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile; + var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* Comparison.LessThan */ ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -49782,7 +49904,7 @@ var ts; err.relatedInformation = err.relatedInformation || []; var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName); var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here); - if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; })) + if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* Comparison.EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* Comparison.EqualTo */; })) return "continue"; ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage); }; @@ -49824,7 +49946,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -49833,7 +49955,7 @@ var ts; } // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); - if (mainModule_1.flags & 1920 /* Namespace */) { + if (mainModule_1.flags & 1920 /* SymbolFlags.Namespace */) { // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you @@ -49848,9 +49970,9 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { // We may need to merge the module augmentation's exports into the target symbols of the resolved exports - var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); + var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */); for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) { var _e = _d[_i], key = _e[0], value = _e[1]; if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { @@ -49883,7 +50005,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks()); @@ -49893,17 +50015,17 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { var symbol = getMergedSymbol(symbols.get(name)); if (symbol) { - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors if (target === unknownSymbol || target.flags & meaning) { @@ -49923,8 +50045,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* SymbolFlags.Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* SymbolFlags.Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -49938,7 +50060,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!ts.outFile(compilerOptions)) || isInTypeQuery(usage) || - declaration.flags & 16777216 /* Ambient */) { + declaration.flags & 16777216 /* NodeFlags.Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -49952,17 +50074,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 203 /* BindingElement */) { + if (declaration.kind === 203 /* SyntaxKind.BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 203 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 203 /* SyntaxKind.BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* SyntaxKind.VariableDeclaration */), usage); } - else if (declaration.kind === 254 /* VariableDeclaration */) { + else if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -49976,7 +50098,7 @@ var ts; } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -49992,19 +50114,19 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 275 /* ExportSpecifier */ || (usage.parent.kind === 271 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 275 /* SyntaxKind.ExportSpecifier */ || (usage.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.isExportEquals) { return true; } - if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { + if (!!(usage.flags & 8388608 /* NodeFlags.JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -50019,9 +50141,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 237 /* VariableStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 237 /* SyntaxKind.VariableStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -50049,7 +50171,7 @@ var ts; var initializerOfProperty = propertyDeclaration.initializer === current; if (initializerOfProperty) { if (ts.isStatic(current.parent)) { - if (declaration.kind === 169 /* MethodDeclaration */) { + if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) { return true; } if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { @@ -50064,7 +50186,7 @@ var ts; } } else { - var isDeclarationInstanceProperty = declaration.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(declaration); + var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -50087,19 +50209,19 @@ var ts; return "quit"; } switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 172 /* GetAccessor */: - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -50124,7 +50246,7 @@ var ts; // - optional chaining pre-es2020 // - nullish coalesce pre-es2020 // - spread assignment in binding pattern pre-es2017 - if (target >= 2 /* ES2015 */) { + if (target >= 2 /* ScriptTarget.ES2015 */) { var links = getNodeLinks(functionLocation); if (links.declarationRequiresScopeChange === undefined) { links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false; @@ -50139,30 +50261,30 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: // do not descend into these return false; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !useDefineForClassFields; + return target < 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: // null coalesce and optional chain pre-es2020 produce temporary variables if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) { - return target < 7 /* ES2020 */; + return target < 7 /* ScriptTarget.ES2020 */; } if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) { - return target < 4 /* ES2017 */; + return target < 4 /* ScriptTarget.ES2017 */; } if (ts.isTypeNode(node)) return false; @@ -50215,35 +50337,35 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) { - useResult = result.flags & 262144 /* TypeParameter */ + if (meaning & result.flags & 788968 /* SymbolFlags.Type */ && lastLocation.kind !== 320 /* SyntaxKind.JSDoc */) { + useResult = result.flags & 262144 /* SymbolFlags.TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 164 /* Parameter */ || - lastLocation.kind === 340 /* JSDocParameterTag */ || - lastLocation.kind === 341 /* JSDocReturnTag */ || - lastLocation.kind === 163 /* TypeParameter */ + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || + lastLocation.kind === 340 /* SyntaxKind.JSDocParameterTag */ || + lastLocation.kind === 341 /* SyntaxKind.JSDocReturnTag */ || + lastLocation.kind === 163 /* SyntaxKind.TypeParameter */ // local types not visible outside the function body : false; } - if (meaning & result.flags & 3 /* Variable */) { + if (meaning & result.flags & 3 /* SymbolFlags.Variable */) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } - else if (result.flags & 1 /* FunctionScopedVariable */) { + else if (result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { // parameters are visible only inside function body, parameter list and return type // technically for parameter list case here we might mix parameters and variables declared in function, // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 164 /* Parameter */ || + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 189 /* ConditionalType */) { + else if (location.kind === 189 /* SyntaxKind.ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -50258,17 +50380,17 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols; - if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 305 /* SyntaxKind.SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports.get("default" /* Default */)) { + if (result = moduleExports.get("default" /* InternalSymbolName.Default */)) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { break loop; @@ -50288,13 +50410,13 @@ var ts; // which is not the desired behavior. var moduleExport = moduleExports.get(name); if (moduleExport && - moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 275 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* NamespaceExport */))) { + moduleExport.flags === 2097152 /* SymbolFlags.Alias */ && + (ts.getDeclarationOfKind(moduleExport, 275 /* SyntaxKind.ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* SyntaxKind.NamespaceExport */))) { break; } } // ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs) - if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) { + if (name !== "default" /* InternalSymbolName.Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */))) { if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) { result = undefined; } @@ -50303,12 +50425,12 @@ var ts; } } break; - case 260 /* EnumDeclaration */: - if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) { + case 260 /* SyntaxKind.EnumDeclaration */: + if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* SymbolFlags.EnumMember */)) { break loop; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -50318,20 +50440,21 @@ var ts; if (!ts.isStatic(location)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* SymbolFlags.Value */)) { // Remember the property node, it will be used later to report appropriate error + ts.Debug.assertNode(location, ts.isPropertyDeclaration); propertyWithInvalidInitializer = location; } } } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* SymbolFlags.Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -50346,7 +50469,7 @@ var ts; } break loop; } - if (location.kind === 226 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 226 /* SyntaxKind.ClassExpression */ && meaning & 32 /* SymbolFlags.Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -50354,11 +50477,11 @@ var ts; } } break; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* SyntaxKind.ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* SymbolFlags.Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -50374,39 +50497,39 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error - if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */) { break; } // falls through - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 213 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 213 /* SyntaxKind.FunctionExpression */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } - if (meaning & 16 /* Function */) { + if (meaning & 16 /* SymbolFlags.Function */) { var functionName = location.name; if (functionName && name === functionName.escapedText) { result = location.symbol; @@ -50414,7 +50537,7 @@ var ts; } } break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -50423,7 +50546,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 164 /* Parameter */) { + if (location.parent && location.parent.kind === 164 /* SyntaxKind.Parameter */) { location = location.parent; } // @@ -50438,20 +50561,20 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* SyntaxKind.ClassDeclaration */)) { location = location.parent; } break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -50459,7 +50582,7 @@ var ts; } } break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -50467,8 +50590,8 @@ var ts; } } break; - case 190 /* InferType */: - if (meaning & 262144 /* TypeParameter */) { + case 190 /* SyntaxKind.InferType */: + if (meaning & 262144 /* SymbolFlags.TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { result = location.typeParameter.symbol; @@ -50493,7 +50616,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 305 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 305 /* SyntaxKind.SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -50509,11 +50632,27 @@ var ts; } } } + // The invalid initializer error is needed in two situation: + // 1. When result is undefined, after checking for a missing "this." + // 2. When result is defined + function checkAndReportErrorForInvalidInitializer() { + if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */)) { + // We have a match, but the reference occurred within a property initializer and the identifier also binds + // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed + // with ESNext+useDefineForClassFields because the scope semantics are different. + error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos) + ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor + : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg)); + return true; + } + return false; + } if (!result) { if (nameNotFoundMessage) { addLazyDiagnostic(function () { if (!errorLocation || !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217 + !checkAndReportErrorForInvalidInitializer() && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) && @@ -50521,7 +50660,16 @@ var ts; !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { var suggestion = void 0; - if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { + var suggestedLib = void 0; + // Report missing lib first + if (nameArg) { + suggestedLib = getSuggestedLibForNonExistentName(nameArg); + if (suggestedLib) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib); + } + } + // then spelling suggestions + if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); if (isGlobalScopeAugmentationDeclaration) { @@ -50530,7 +50678,7 @@ var ts; if (suggestion) { var suggestionName = symbolToString(suggestion); var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false); - var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 + var message = meaning === 1920 /* SymbolFlags.Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1; var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName); @@ -50540,16 +50688,9 @@ var ts; } } } - if (!suggestion) { - if (nameArg) { - var lib = getSuggestedLibForNonExistentName(nameArg); - if (lib) { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib); - } - else { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); - } - } + // And then fall back to unspecified "not found" + if (!suggestion && !suggestedLib && nameArg) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); } suggestionCount++; } @@ -50557,12 +50698,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) { - // We have a match, but the reference occurred within a property initializer and the identifier also binds - // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed - // with ESNext+useDefineForClassFields because the scope semantics are different. - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg)); + else if (checkAndReportErrorForInvalidInitializer()) { return undefined; } // Perform extra checks only if error reporting was requested @@ -50580,22 +50716,22 @@ var ts; // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped if (errorLocation && - (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { + (meaning & 2 /* SymbolFlags.BlockScopedVariable */ || + ((meaning & 32 /* SymbolFlags.Class */ || meaning & 384 /* SymbolFlags.Enum */) && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { + if (exportOrLocalSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* SymbolFlags.Class */ || exportOrLocalSymbol.flags & 384 /* SymbolFlags.Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */ && !(originalLocation.flags & 8388608 /* NodeFlags.JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -50607,10 +50743,10 @@ var ts; error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation)); } } - if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { + if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ + var message = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -50624,31 +50760,31 @@ var ts; function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) { if (!typeOnlyDeclaration) return diagnostic; - return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); + return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 214 /* ArrowFunction */ && location.kind !== 213 /* FunctionExpression */) { + if (location.kind !== 214 /* SyntaxKind.ArrowFunction */ && location.kind !== 213 /* SyntaxKind.FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; } // generator functions and async functions are not inlined in control flow when immediately invoked - if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* Async */)) { + if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* ModifierFlags.Async */)) { return true; } return !ts.getImmediatelyInvokedFunctionExpression(location); } function isSelfReferenceLocation(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: // For `namespace N { N; }` + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -50661,7 +50797,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 163 /* TypeParameter */) { + if (decl.kind === 163 /* SyntaxKind.TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); @@ -50705,7 +50841,7 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { + if (expression && resolveEntityName(expression, 64 /* SymbolFlags.Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); return true; } @@ -50717,10 +50853,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -50730,9 +50866,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* SymbolFlags.Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -50751,9 +50887,9 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1920 /* Namespace */)) { + if (meaning & (788968 /* SymbolFlags.Type */ & ~1920 /* SymbolFlags.Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1920 /* SymbolFlags.Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name)); return true; } @@ -50764,14 +50900,14 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) { if (isPrimitiveTypeName(name)) { if (isExtendedByInterface(errorLocation)) { error(errorLocation, ts.Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, ts.unescapeLeadingUnderscores(name)); @@ -50781,8 +50917,8 @@ var ts; } return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) { var rawName = ts.unescapeLeadingUnderscores(name); if (isES2015OrLaterConstructorName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); @@ -50802,7 +50938,7 @@ var ts; var grandparent = node.parent.parent; var parentOfGrandparent = grandparent.parent; if (grandparent && parentOfGrandparent) { - var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* ExtendsKeyword */; + var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* SyntaxKind.ExtendsKeyword */; var isInterface = ts.isInterfaceDeclaration(parentOfGrandparent); return isExtending && isInterface; } @@ -50814,7 +50950,7 @@ var ts; }); if (container && container.members.length === 1) { var type = getDeclaredTypeOfSymbol(symbol); - return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true); + return !!(type.flags & 1048576 /* TypeFlags.Union */) && allTypesAssignableToKind(type, 384 /* TypeFlags.StringOrNumberLiteral */, /*strict*/ true); } return false; } @@ -50831,15 +50967,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -50849,29 +50985,29 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { var _a; - ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); - if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */)); + if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); - if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); - if (result.flags & 2 /* BlockScopedVariable */) { + if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } - else if (result.flags & 32 /* Class */) { + else if (result.flags & 32 /* SymbolFlags.Class */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } - else if (result.flags & 256 /* RegularEnum */) { + else if (result.flags & 256 /* SymbolFlags.RegularEnum */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } else { - ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */)); if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } @@ -50892,13 +51028,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.parent; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -50923,24 +51059,24 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ - || node.kind === 264 /* NamespaceExportDeclaration */ - || node.kind === 267 /* ImportClause */ && !!node.name - || node.kind === 268 /* NamespaceImport */ - || node.kind === 274 /* NamespaceExport */ - || node.kind === 270 /* ImportSpecifier */ - || node.kind === 275 /* ExportSpecifier */ - || node.kind === 271 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) - || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name + || node.kind === 268 /* SyntaxKind.NamespaceImport */ + || node.kind === 274 /* SyntaxKind.NamespaceExport */ + || node.kind === 270 /* SyntaxKind.ImportSpecifier */ + || node.kind === 275 /* SyntaxKind.ExportSpecifier */ + || node.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.exportAssignmentIsAlias(node) + || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 297 /* ShorthandPropertyAssignment */ - || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) - || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent); + || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) + || node.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -50953,7 +51089,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -50966,7 +51102,7 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var isExport = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */; + var isExport = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */; var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; @@ -50978,14 +51114,14 @@ var ts; } } function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) { - var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportValue = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node)); } function getUsageModeForExpression(usage) { return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined; @@ -50995,7 +51131,7 @@ var ts; } function isOnlyImportedAsDefault(usage) { var usageMode = getUsageModeForExpression(usage); - return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */); + return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Extension.Json */); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) { var usageMode = file && getUsageModeForExpression(usage); @@ -51012,7 +51148,7 @@ var ts; // Declaration files (and ambient modules) if (!file || file.isDeclarationFile) { // Definitely cannot have a synthetic default if they have a syntactic default member specified - var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration + var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) { return false; } @@ -51044,7 +51180,7 @@ var ts; exportDefaultSymbol = moduleSymbol; } else { - exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); + exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias); } var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier); @@ -51052,7 +51188,7 @@ var ts; if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) { if (hasExportAssignmentSymbol(moduleSymbol)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; - var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportAssignment = exportEqualsSymbol.valueDeclaration; var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName); if (exportAssignment) { @@ -51080,12 +51216,12 @@ var ts; } else { var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); + var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */); if (exportStar) { var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) { var _a, _b; return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && - ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); + ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */))); }); if (defaultExport) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default)); @@ -51129,7 +51265,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -51144,7 +51280,7 @@ var ts; return result; } function getExportOfModule(symbol, name, specifier, dontResolveAlias) { - if (symbol.flags & 1536 /* Module */) { + if (symbol.flags & 1536 /* SymbolFlags.Module */) { var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); @@ -51152,7 +51288,7 @@ var ts; } } function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); @@ -51168,7 +51304,7 @@ var ts; if (!ts.isIdentifier(name)) { return undefined; } - var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); + var suppressInteropError = name.escapedText === "default" /* InternalSymbolName.Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -51177,7 +51313,7 @@ var ts; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true); } else { @@ -51186,7 +51322,7 @@ var ts; // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); - if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { + if (symbolFromModule === undefined && name.escapedText === "default" /* InternalSymbolName.Default */) { var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -51207,7 +51343,7 @@ var ts; } } else { - if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)) { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { @@ -51224,7 +51360,7 @@ var ts; var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { - var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); + var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportedEqualsSymbol) { getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); @@ -51304,19 +51440,15 @@ var ts; if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { return undefined; } - var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } - function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { - var expression = node.initializer; - return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); - } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -51324,31 +51456,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: - case 254 /* VariableDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 270 /* ImportSpecifier */: - case 203 /* BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 275 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, dontRecursivelyResolve); + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 297 /* ShorthandPropertyAssignment */: - return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 296 /* PropertyAssignment */: - return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 296 /* SyntaxKind.PropertyAssignment */: + return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve); + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -51359,16 +51491,16 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); + return (symbol.flags & (2097152 /* SymbolFlags.Alias */ | excludes)) === 2097152 /* SymbolFlags.Alias */ || !!(symbol.flags & 2097152 /* SymbolFlags.Alias */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */); } function resolveSymbol(symbol, dontResolveAlias) { return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.aliasTarget) { links.aliasTarget = resolvingSymbol; @@ -51433,7 +51565,7 @@ var ts; function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) { var _a, _b, _c; if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) { - var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */)) !== null && _b !== void 0 ? _b : target; + var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)) !== null && _b !== void 0 ? _b : target; var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false; } @@ -51441,7 +51573,7 @@ var ts; } /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */ function getTypeOnlyAliasDeclaration(symbol) { - if (!(symbol.flags & 2097152 /* Alias */)) { + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) { return undefined; } var links = getSymbolLinks(symbol); @@ -51452,7 +51584,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); + ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -51473,7 +51605,7 @@ var ts; // position. if (ts.isInternalModuleImportEqualsDeclaration(node)) { var target = resolveSymbol(symbol); - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // import foo = checkExpressionCached(node.moduleReference); } @@ -51496,22 +51628,22 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* SyntaxKind.Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 161 /* QualifiedName */) { - return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + if (entityName.kind === 79 /* SyntaxKind.Identifier */ || entityName.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + return resolveEntityName(entityName, 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 265 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { - return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */); + return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); } function getContainingQualifiedNameNode(node) { while (ts.isQualifiedName(node.parent)) { @@ -51521,7 +51653,7 @@ var ts; } function tryGetQualifiedNameAsValue(node) { var left = ts.getFirstIdentifier(node); - var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true); + var symbol = resolveName(left, left.escapedText, 111551 /* SymbolFlags.Value */, undefined, left, /*isUse*/ true); if (!symbol) { return undefined; } @@ -51542,9 +51674,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* SymbolFlags.Value */ : 0); var symbol; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false)); @@ -51552,9 +51684,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 161 /* QualifiedName */ || name.kind === 206 /* PropertyAccessExpression */) { - var left = name.kind === 161 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 161 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 161 /* SyntaxKind.QualifiedName */ || name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var left = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.left : name.expression; + var right = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -51588,7 +51720,7 @@ var ts; } var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name); var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet - && (meaning & 788968 /* Type */) + && (meaning & 788968 /* SymbolFlags.Type */) && containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName); @@ -51596,8 +51728,8 @@ var ts; error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName)); return undefined; } - if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) { - var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */)); + if (meaning & 1920 /* SymbolFlags.Namespace */ && ts.isQualifiedName(name.parent)) { + var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* SymbolFlags.Type */)); if (exportedTypeSymbol) { error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText)); return undefined; @@ -51611,8 +51743,8 @@ var ts; else { throw ts.Debug.assertNever(name, "Unknown entity name kind."); } - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 271 /* ExportAssignment */)) { + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* SymbolFlags.Alias */ || name.parent.kind === 271 /* SyntaxKind.ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -51632,7 +51764,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* NodeFlags.JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -51653,7 +51785,7 @@ var ts; } if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) && ts.isBinaryExpression(host.parent.parent) && - ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { // X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration var symbol = getSymbolOfNode(host.parent.parent.left); if (symbol) { @@ -51684,7 +51816,7 @@ var ts; */ function getExpandoSymbol(symbol) { var decl = symbol.valueDeclaration; - if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* SymbolFlags.TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { return undefined; } var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); @@ -51751,7 +51883,40 @@ var ts; // An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of // normal mode restrictions if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { - error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); + if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) { + // ImportEquals in a ESM file resolving to another ESM file + error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference); + } + else { + // CJS file resolving to an ESM file + var diagnosticDetails = void 0; + var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName); + if (ext === ".ts" /* Extension.Ts */ || ext === ".js" /* Extension.Js */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".jsx" /* Extension.Jsx */) { + var scope = currentSourceFile.packageJsonScope; + var targetExt = ext === ".ts" /* Extension.Ts */ ? ".mts" /* Extension.Mts */ : ext === ".js" /* Extension.Js */ ? ".mjs" /* Extension.Mjs */ : undefined; + if (scope && !scope.packageJsonContent.type) { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, targetExt, ts.combinePaths(scope.packageDirectory, "package.json")); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0, ts.combinePaths(scope.packageDirectory, "package.json")); + } + } + else { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, targetExt); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module); + } + } + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, ts.chainDiagnosticMessages(diagnosticDetails, ts.Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference))); + } } } // merged symbol is module declaration symbol combined with all augmentations @@ -51816,12 +51981,12 @@ var ts; * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (moduleKind >= ts.ModuleKind.ES2015) { - replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js"; + replacedImportSource += tsExtension === ".mts" /* Extension.Mts */ ? ".mjs" : tsExtension === ".cts" /* Extension.Cts */ ? ".cjs" : ".js"; } error(errorNode, diag, tsExtension, replacedImportSource); } else if (!compilerOptions.resolveJsonModule && - ts.fileExtensionIs(moduleReference, ".json" /* Json */) && + ts.fileExtensionIs(moduleReference, ".json" /* Extension.Json */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); @@ -51868,27 +52033,27 @@ var ts; } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { - var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */), dontResolveAlias); var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* SymbolFlags.Alias */) { return exported; } var links = getSymbolLinks(exported); if (links.cjsExportMerged) { return links.cjsExportMerged; } - var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); - merged.flags = merged.flags | 512 /* ValueModule */; + var merged = exported.flags & 33554432 /* SymbolFlags.Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* SymbolFlags.ValueModule */; if (merged.exports === undefined) { merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { - if (name === "export=" /* ExportEquals */) + if (name === "export=" /* InternalSymbolName.ExportEquals */) return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); @@ -51902,7 +52067,7 @@ var ts; var _a; var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -51921,12 +52086,12 @@ var ts; var targetFile = (_a = moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat); if (ts.getESModuleInterop(compilerOptions) || isEsmCjsRef) { - var sigs = getSignaturesOfStructuredType(type, 0 /* Call */); + var sigs = getSignaturesOfStructuredType(type, 0 /* SignatureKind.Call */); if (!sigs || !sigs.length) { - sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); + sigs = getSignaturesOfStructuredType(type, 1 /* SignatureKind.Construct */); } if ((sigs && sigs.length) || - getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true) || + getPropertyOfType(type, "default" /* InternalSymbolName.Default */, /*skipObjectFunctionPropertyAugment*/ true) || isEsmCjsRef) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); @@ -51958,7 +52123,7 @@ var ts; return result; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; + return moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -52010,15 +52175,15 @@ var ts; return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; } function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { - return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || - ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ || + return !(resolvedExternalModuleType.flags & 131068 /* TypeFlags.Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* ObjectFlags.Class */ || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path isArrayType(resolvedExternalModuleType) || isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : - symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { @@ -52033,7 +52198,7 @@ var ts; if (!source) return; source.forEach(function (sourceSymbol, id) { - if (id === "default" /* Default */) + if (id === "default" /* InternalSymbolName.Default */) return; var targetSymbol = target.get(id); if (!targetSymbol) { @@ -52068,7 +52233,7 @@ var ts; } var symbols = new ts.Map(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports.get("__export" /* ExportStar */); + var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */); if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); @@ -52157,21 +52322,21 @@ var ts; function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) { var container = getParentOfSymbol(symbol); // Type parameters end up in the `members` lists but are not externally visible - if (container && !(symbol.flags & 262144 /* TypeParameter */)) { + if (container && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && - getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */, /*externalOnly*/ false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope } // we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type // which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`) var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) - && container.flags & 788968 /* Type */ - && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ - && meaning === 111551 /* Value */ + && container.flags & 788968 /* SymbolFlags.Type */ + && getDeclaredTypeOfSymbol(container).flags & 524288 /* TypeFlags.Object */ + && meaning === 111551 /* SymbolFlags.Value */ ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { return ts.forEachEntry(t, function (s) { if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { @@ -52195,7 +52360,7 @@ var ts; return getSymbolOfNode(d.parent.parent); } } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { return getSymbolOfNode(ts.getSourceFileOfNode(d)); } @@ -52216,7 +52381,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations); - if (meaning & 111551 /* Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { + if (meaning & 111551 /* SymbolFlags.Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) { return getSymbolOfNode(firstDecl.parent); } @@ -52224,7 +52389,7 @@ var ts; } function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) { var fileSymbol = getExternalModuleContainer(d); - var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); + var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } function getAliasForSymbolInContainer(container, symbol) { @@ -52234,7 +52399,7 @@ var ts; } // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return // the container itself as the alias for the symbol - var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + var exportEquals = container.exports && container.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { return container; } @@ -52258,17 +52423,17 @@ var ts; } } function getExportSymbolOfValueSymbolIfExported(symbol) { - return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 && symbol.exportSymbol || symbol); + return getMergedSymbol(symbol && (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol, includeTypeOnlyMembers) { - return !!(symbol.flags & 111551 /* Value */ || - symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); + return !!(symbol.flags & 111551 /* SymbolFlags.Value */ || + symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 171 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -52291,7 +52456,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(524288 /* Object */); + var type = createType(524288 /* TypeFlags.Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -52305,7 +52470,7 @@ var ts; return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { - var type = createType(262144 /* TypeParameter */); + var type = createType(262144 /* TypeFlags.TypeParameter */); if (symbol) type.symbol = symbol; return type; @@ -52315,11 +52480,11 @@ var ts; // with at least two underscores. The @ character indicates that the name is denoted by a well known ES // Symbol instance and the # character indicates that the name is a PrivateIdentifier. function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */ && - name.charCodeAt(2) !== 35 /* hash */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 64 /* CharacterCodes.at */ && + name.charCodeAt(2) !== 35 /* CharacterCodes.hash */; } function getNamedMembers(members) { var result; @@ -52351,14 +52516,14 @@ var ts; return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) { - return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); + return setStructuredTypeMembers(createObjectType(16 /* ObjectFlags.Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); } function getResolvedTypeWithoutAbstractConstructSignatures(type) { if (type.constructSignatures.length === 0) return type; if (type.objectTypeWithoutAbstractConstructSignatures) return type.objectTypeWithoutAbstractConstructSignatures; - var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); }); + var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (type.constructSignatures === constructSignatures) return type; var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos); @@ -52376,12 +52541,12 @@ var ts; } } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred @@ -52390,9 +52555,9 @@ var ts; return { value: result }; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -52403,7 +52568,7 @@ var ts; var table_1; // TODO: Should this filtered table be cached in some way? (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { - if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) { (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); @@ -52422,7 +52587,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); } @@ -52433,7 +52598,7 @@ var ts; var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -52477,9 +52642,9 @@ var ts; } // Check if symbol is any of the aliases in scope var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" /* ExportEquals */ - && symbolFromSymbolTable.escapedName !== "default" /* Default */ + if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ + && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */ && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) @@ -52487,7 +52652,7 @@ var ts; && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -52531,7 +52696,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -52546,10 +52711,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: continue; default: return false; @@ -52560,16 +52725,16 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* SymbolFlags.Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* SymbolFlags.Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) { var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ false); - return access.accessibility === 0 /* Accessible */; + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) { if (!ts.length(symbols)) @@ -52599,7 +52764,7 @@ var ts; } // Any meaning of a module symbol is always accessible via an `import` type return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } } @@ -52623,14 +52788,14 @@ var ts; } if (earlyModuleBail) { return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } if (hadAccessibleChain) { return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined, + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */) : undefined, }; } } @@ -52659,7 +52824,7 @@ var ts; if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { - accessibility: 2 /* CannotBeNamed */, + accessibility: 2 /* SymbolAccessibility.CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule), errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, @@ -52668,28 +52833,28 @@ var ts; } // Just a local name that is not accessible return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } - return { accessibility: 0 /* Accessible */ }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } function getExternalModuleContainer(declaration) { var node = ts.findAncestor(declaration, hasExternalModuleSymbol); return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* SyntaxKind.Identifier */; }), getIsDeclarationVisible)) { return undefined; } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { var _a, _b; if (!isDeclarationVisible(declaration)) { @@ -52697,27 +52862,39 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !ts.hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + !ts.hasSyntacticModifier(anyImportSyntax, 1 /* ModifierFlags.Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); } else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) && - !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* ModifierFlags.Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); } else if (ts.isLateVisibilityPaintedStatement(declaration) // unexported top-level statement - && !ts.hasSyntacticModifier(declaration, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration, 1 /* ModifierFlags.Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement - && ts.isVariableDeclaration(declaration.parent.parent) - && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) - && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) - && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { - return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + else if (ts.isBindingElement(declaration)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement + && ts.isVariableDeclaration(declaration.parent.parent) + && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* ModifierFlags.Export */) + && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) + && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + } + else if (symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement); + if (ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */)) { + return true; + } + if (!isDeclarationVisible(variableStatement.parent)) { + return false; + } + return addVisibleAlias(declaration, variableStatement); + } } // Declaration is not visible return false; @@ -52738,86 +52915,86 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 181 /* TypeQuery */ || - entityName.parent.kind === 228 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || - entityName.parent.kind === 162 /* ComputedPropertyName */) { + if (entityName.parent.kind === 181 /* SyntaxKind.TypeQuery */ || + entityName.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || + entityName.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Typeof value - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } - else if (entityName.kind === 161 /* QualifiedName */ || entityName.kind === 206 /* PropertyAccessExpression */ || - entityName.parent.kind === 265 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 161 /* SyntaxKind.QualifiedName */ || entityName.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 788968 /* Type */; + meaning = 788968 /* SymbolFlags.Type */; } var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); - if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) { - return { accessibility: 0 /* Accessible */ }; + if (symbol && symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && meaning & 788968 /* SymbolFlags.Type */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } - if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) { - return { accessibility: 0 /* Accessible */ }; + if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) { - if (flags === void 0) { flags = 4 /* AllowAnyNodeKind */; } - var nodeFlags = 70221824 /* IgnoreErrors */; - if (flags & 2 /* UseOnlyExternalAliasing */) { - nodeFlags |= 128 /* UseOnlyExternalAliasing */; + if (flags === void 0) { flags = 4 /* SymbolFormatFlags.AllowAnyNodeKind */; } + var nodeFlags = 70221824 /* NodeBuilderFlags.IgnoreErrors */; + if (flags & 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */) { + nodeFlags |= 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */; } - if (flags & 1 /* WriteTypeParametersOrArguments */) { - nodeFlags |= 512 /* WriteTypeParametersInQualifiedName */; + if (flags & 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */) { + nodeFlags |= 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; } - if (flags & 8 /* UseAliasDefinedOutsideCurrentScope */) { - nodeFlags |= 16384 /* UseAliasDefinedOutsideCurrentScope */; + if (flags & 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */) { + nodeFlags |= 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; } - if (flags & 16 /* DoNotIncludeSymbolChain */) { - nodeFlags |= 134217728 /* DoNotIncludeSymbolChain */; + if (flags & 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */) { + nodeFlags |= 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */; } - var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; + var builder = flags & 4 /* SymbolFormatFlags.AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SyntaxKind.SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; - if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructorType */ : 179 /* FunctionType */; + if (flags & 262144 /* TypeFormatFlags.WriteArrowStyleSignature */) { + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 180 /* SyntaxKind.ConstructorType */ : 179 /* SyntaxKind.FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructSignature */ : 174 /* CallSignature */; + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 175 /* SyntaxKind.ConstructSignature */ : 174 /* SyntaxKind.CallSignature */; } - var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); + var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* EmitHint.Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } - var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */; - var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer); + var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* TypeFormatFlags.NoTruncation */; + var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | (noTruncation ? 1 /* NodeBuilderFlags.NoTruncation */ : 0), writer); if (typeNode === undefined) return ts.Debug.fail("should always get typenode"); // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. @@ -52825,7 +53002,7 @@ var ts; var options = { removeComments: type !== unresolvedType }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { @@ -52843,17 +53020,17 @@ var ts; return [leftStr, rightStr]; } function getTypeNameForErrorDisplay(type) { - return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); + return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { - if (flags === void 0) { flags = 0 /* None */; } - return flags & 814775659 /* NodeBuilderFlagsMask */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + return flags & 848330091 /* TypeFormatFlags.NodeBuilderFlagsMask */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); + return !!type.symbol && !!(type.symbol.flags & 32 /* SymbolFlags.Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* TypeFlags.Object */) && !!(ts.getObjectFlags(type) & 16777216 /* ObjectFlags.IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -52887,12 +53064,12 @@ var ts; }; function withContext(enclosingDeclaration, flags, tracker, cb) { var _a, _b; - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0); var context = { enclosingDeclaration: enclosingDeclaration, - flags: flags || 0 /* None */, + flags: flags || 0 /* NodeBuilderFlags.None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache), @@ -52914,7 +53091,7 @@ var ts; }; context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); - if (context.truncating && context.flags & 1 /* NoTruncation */) { + if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) { (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); } return context.encounteredError ? undefined : resultingNode; @@ -52949,62 +53126,68 @@ var ts; function checkTruncationLength(context) { if (context.truncating) return context.truncating; - return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); + return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { + var savedFlags = context.flags; + var typeNode = typeToTypeNodeWorker(type, context); + context.flags = savedFlags; + return typeNode; + } + function typeToTypeNodeWorker(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } - var inTypeAlias = context.flags & 8388608 /* InTypeAlias */; - context.flags &= ~8388608 /* InTypeAlias */; + var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */; + context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */; if (!type) { - if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (!(context.flags & 536870912 /* NoTypeReduction */)) { + if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) { type = getReducedType(type); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { if (type.aliasSymbol) { return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); } if (type === unresolvedType) { - return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved"); + return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved"); } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */); } - if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + if (type.flags & 2 /* TypeFlags.Unknown */) { + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } - if (type.flags & 4 /* String */) { + if (type.flags & 4 /* TypeFlags.String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(158 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */); } - if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { + if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */); } - if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { + if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */); if (getDeclaredTypeOfSymbol(parentSymbol) === type) { return parentName; } var memberName = ts.symbolName(type.symbol); - if (ts.isIdentifierText(memberName, 0 /* ES3 */)) { + if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) { return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); } if (ts.isImportTypeNode(parentName)) { @@ -53018,66 +53201,66 @@ var ts; return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + if (type.flags & 1056 /* TypeFlags.EnumLike */) { + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - if (type.flags & 128 /* StringLiteral */) { + if (type.flags & 128 /* TypeFlags.StringLiteral */) { context.approximateLength += (type.value.length + 2); - return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */)); + return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */)), 16777216 /* EmitFlags.NoAsciiEscaping */)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); + return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value))); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse()); } - if (type.flags & 8192 /* UniqueESSymbol */) { - if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + if (!(context.flags & 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 111551 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* SymbolFlags.Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(154 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(154 /* SyntaxKind.UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */)); } - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */); } - if (type.flags & 32768 /* Undefined */) { + if (type.flags & 32768 /* TypeFlags.Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { context.approximateLength += 4; return ts.factory.createLiteralTypeNode(ts.factory.createNull()); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */); } - if (type.flags & 4096 /* ESSymbol */) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */); } - if (type.flags & 67108864 /* NonPrimitive */) { + if (type.flags & 67108864 /* TypeFlags.NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(148 /* SyntaxKind.ObjectKeyword */); } if (ts.isThisTypeParameter(type)) { - if (context.flags & 4194304 /* InObjectTypeLiteral */) { - if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { + if (context.flags & 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */) { + if (!context.encounteredError && !(context.flags & 32768 /* NodeBuilderFlags.AllowThisInObjectLiteral */)) { context.encounteredError = true; } if (context.tracker.reportInaccessibleThisError) { @@ -53087,22 +53270,22 @@ var ts; context.approximateLength += 4; return ts.factory.createThisTypeNode(); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* SymbolFlags.Class */)) return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes); if (ts.length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) { return ts.factory.createArrayTypeNode(typeArgumentNodes[0]); } - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); } var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & 4 /* ObjectFlags.Reference */) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } - if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ || objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); var constraintNode = void 0; var constraint = getConstraintOfTypeParameter(type); @@ -53119,8 +53302,8 @@ var ts; } return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode)); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 262144 /* TypeParameter */ && + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name_2 = typeParameterToName(type, context); context.approximateLength += ts.idText(name_2).length; @@ -53128,43 +53311,43 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? - (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; + var name = (type === markerSuperTypeForCheck || type === markerSubTypeForCheck) && varianceTypeParameter && varianceTypeParameter.symbol ? + (type === markerSubTypeForCheck ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined); } - if (type.flags & 1048576 /* Union */ && type.origin) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.origin) { type = type.origin; } - if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { - var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + var types = type.flags & 1048576 /* TypeFlags.Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - return type.flags & 1048576 /* Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); } else { - if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!context.encounteredError && !(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } return undefined; // TODO: GH#18217 } } - if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, indexTypeNode); } - if (type.flags & 134217728 /* TemplateLiteral */) { + if (type.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts_1 = type.texts; var types_1 = type.types; var templateHead = ts.factory.createTemplateHead(texts_1[0]); @@ -53172,32 +53355,32 @@ var ts; context.approximateLength += 2; return ts.factory.createTemplateLiteralType(templateHead, templateSpans); } - if (type.flags & 268435456 /* StringMapping */) { + if (type.flags & 268435456 /* TypeFlags.StringMapping */) { var typeNode = typeToTypeNodeHelper(type.type, context); - return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, [typeNode]); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); }); } - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return typeToTypeNodeHelper(type.baseType, context); } return ts.Debug.fail("Should be unreachable."); function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); context.approximateLength += 15; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeFlags.TypeParameter */)) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); var newTypeVariable = ts.factory.createTypeReferenceNode(name); context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type - var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.mapper); var saveInferTypeParameters_1 = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); @@ -53214,7 +53397,7 @@ var ts; // On the other hand, // checkType extends infer T extends checkType ? T extends extendsType ? trueType : falseType : never; // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS. - return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -53226,9 +53409,9 @@ var ts; } function typeToTypeNodeOrCircularityElision(type) { var _a, _b, _c; - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) { - if (!(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + if (!(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b); } @@ -53238,8 +53421,12 @@ var ts; } return typeToTypeNodeHelper(type, context); } + function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) { + return isMappedTypeWithKeyofConstraintDeclaration(type) + && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */); + } function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -53247,27 +53434,28 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); } - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; - var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined); context.approximateLength += 10; - var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + var result = ts.setEmitFlags(mappedTypeNode, 1 /* EmitFlags.SingleLine */); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { // homomorphic mapped type with a non-homomorphic naive inlining // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting // type stays homomorphic - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName), originalConstraint.flags & 2 /* TypeFlags.Unknown */ ? undefined : typeToTypeNodeHelper(originalConstraint, context))), result, ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } return result; } @@ -53276,16 +53464,16 @@ var ts; var typeId = type.id; var symbol = type.symbol; if (symbol) { - var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = isClassInstanceSide(type) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */; if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ + else if (symbol.flags & 32 /* SymbolFlags.Class */ && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* Accessible */)) || - symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */)) || + symbol.flags & (384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); } @@ -53294,7 +53482,7 @@ var ts; var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 788968 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* SymbolFlags.Type */); } else { return createElidedInformationPlaceholder(context); @@ -53310,26 +53498,26 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var _a; - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* SymbolFlags.Method */) && // typeof static method ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); }); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* SymbolFlags.Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 305 /* SourceFile */ || declaration.parent.kind === 262 /* ModuleBlock */; + return declaration.parent.kind === 305 /* SyntaxKind.SourceFile */ || declaration.parent.kind === 262 /* SyntaxKind.ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + return (!!(context.flags & 4096 /* NodeBuilderFlags.UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively + (!(context.flags & 8 /* NodeBuilderFlags.UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } function visitAndTransformType(type, transform) { var _a, _b; var typeId = type.id; - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : - type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) : + var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */; + var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) : type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : undefined; // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead @@ -53341,7 +53529,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -53400,20 +53588,20 @@ var ts; if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { context.approximateLength += 2; - return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* EmitFlags.SingleLine */); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* SyntaxKind.FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* SyntaxKind.ConstructorType */, context); return signatureNode; } } - var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); }); + var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (ts.some(abstractSignatures)) { var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature); // count the number of type elements excluding abstract constructors @@ -53422,8 +53610,8 @@ var ts; resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per // the logic in `createTypeNodesFromResolvedType`. - (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? - ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* Prototype */); }) : + (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ ? + ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */); }) : ts.length(resolved.properties)); // don't include an empty object literal if there were no other static-side // properties to write, i.e. `abstract class C { }` becomes `abstract new () => {}` @@ -53435,27 +53623,27 @@ var ts; return typeToTypeNodeHelper(getIntersectionType(types), context); } var savedFlags = context.flags; - context.flags |= 4194304 /* InObjectTypeLiteral */; + context.flags |= 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */; var members = createTypeNodesFromResolvedType(resolved); context.flags = savedFlags; var typeLiteralNode = ts.factory.createTypeLiteralNode(members); context.approximateLength += 2; - ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); + ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* NodeBuilderFlags.MultilineObjectLiterals */) ? 0 : 1 /* EmitFlags.SingleLine */); return typeLiteralNode; } function typeReferenceToTypeNode(type) { var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { - if (context.flags & 2 /* WriteArrayAsGenericType */) { + if (context.flags & 2 /* NodeBuilderFlags.WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]); } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, arrayType); } - else if (type.target.objectFlags & 8 /* Tuple */) { - typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); }); + else if (type.target.objectFlags & 8 /* ObjectFlags.Tuple */) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* ElementFlags.Optional */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -53463,7 +53651,7 @@ var ts; if (type.target.labeledElementDeclarations) { for (var i = 0; i < tupleConstituentNodes.length; i++) { var flags = type.target.elementFlags[i]; - tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* Variable */ ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : + tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* ElementFlags.Variable */ ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* ElementFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]); } } @@ -53471,23 +53659,23 @@ var ts; for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) { var flags = type.target.elementFlags[i]; tupleConstituentNodes[i] = - flags & 12 /* Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : - flags & 2 /* Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : + flags & 12 /* ElementFlags.Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : + flags & 2 /* ElementFlags.Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]; } } - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } - if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + if (context.encounteredError || (context.flags & 524288 /* NodeBuilderFlags.AllowEmptyTuple */)) { + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 } - else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && + else if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { @@ -53511,8 +53699,8 @@ var ts; if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_3 = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var ref = symbolToTypeNode(parent, context, 788968 /* SymbolFlags.Type */, typeArgumentSlice); context.flags = flags_3; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -53524,8 +53712,8 @@ var ts; typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); } var flags = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -53589,17 +53777,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* SyntaxKind.CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - if (signature.flags & 4 /* Abstract */) + if (signature.flags & 4 /* SignatureFlags.Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* SyntaxKind.ConstructSignature */, context)); } for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { var info = _e[_d]; - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); } var properties = resolvedType.properties; if (!properties) { @@ -53609,16 +53797,16 @@ var ts; for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) { var propertySymbol = properties_1[_f]; i++; - if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) { - if (propertySymbol.flags & 4194304 /* Prototype */) { + if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) { + if (propertySymbol.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } - if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName)); } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... " + (properties.length - i) + " more ...", /*questionToken*/ undefined, /*type*/ undefined)); + typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... ".concat(properties.length - i, " more ..."), /*questionToken*/ undefined, /*type*/ undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -53629,10 +53817,10 @@ var ts; } function createElidedInformationPlaceholder(context) { context.approximateLength += 3; - if (!(context.flags & 1 /* NoTruncation */)) { + if (!(context.flags & 1 /* NodeBuilderFlags.NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -53642,14 +53830,14 @@ var ts; // Since anonymous types usually come from expressions, this allows us to preserve the output // for deep mappings which likely come from expressions, while truncating those parts which // come from mappings over library functions. - return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) + return !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */) && (ts.contains(context.reverseMappedStack, propertySymbol) || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) - && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* ObjectFlags.Anonymous */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { var _a, _b; - var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); + var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */); var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; @@ -53677,12 +53865,12 @@ var ts; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined; - if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { - var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); + var optionalToken = propertySymbol.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { + var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* TypeFlags.Undefined */); }), 0 /* SignatureKind.Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* SyntaxKind.MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -53696,12 +53884,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -53710,11 +53898,11 @@ var ts; } function preserveCommentsOn(node) { var _a; - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* JSDocPropertyTag */; })) { - var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; }); var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { - ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } } else if (propertySymbol.valueDeclaration) { @@ -53733,12 +53921,12 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", /*typeArguments*/ undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), /*typeArguments*/ undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } } - var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); + var mayHaveNameCollisions = !(context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */); /** Map from type reference identifier text to [type, index in `result` where the type node is] */ var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; var result_5 = []; @@ -53747,7 +53935,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -53772,7 +53960,7 @@ var ts; // type node for each entry by that name with the // `UseFullyQualifiedType` flag enabled. var saveContextFlags = context.flags; - context.flags |= 64 /* UseFullyQualifiedType */; + context.flags |= 64 /* NodeBuilderFlags.UseFullyQualifiedType */; seenNames.forEach(function (types) { if (!ts.arrayIsHomogeneous(types, function (_a, _b) { var a = _a[0]; @@ -53806,21 +53994,21 @@ var ts; if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); } - if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { + if (!indexInfo.type && !(context.flags & 2097152 /* NodeBuilderFlags.AllowEmptyIndexInfoType */)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); - return ts.factory.createIndexSignature(indexInfo.isReadonly ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + return ts.factory.createIndexSignature(indexInfo.isReadonly ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; - var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; + var suppressAny = context.flags & 256 /* NodeBuilderFlags.SuppressAnyReturnType */; if (suppressAny) - context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s + context.flags &= ~256 /* NodeBuilderFlags.SuppressAnyReturnType */; // suppress only toplevel `any`s context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum var typeParameters; var typeArguments; - if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { + if (context.flags & 32 /* NodeBuilderFlags.WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); }); } else { @@ -53828,19 +54016,19 @@ var ts; } var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; // If the expanded parameter list had a variadic in a non-trailing position, don't expand it - var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); - var thisParameter = tryGetThisParameterDeclaration(signature, context); + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* CheckFlags.RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* SyntaxKind.Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var thisParameter = context.flags & 33554432 /* NodeBuilderFlags.OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); } var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(128 /* AssertsKeyword */) : + var assertsModifier = typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined; - var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : + var parameterName = typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* EmitFlags.NoAsciiEscaping */) : ts.factory.createThisTypeNode(); var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode); @@ -53851,28 +54039,28 @@ var ts; returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); } else if (!suppressAny) { - returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 180 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 180 /* SyntaxKind.ConstructorType */) && signature.flags & 4 /* SignatureFlags.Abstract */) { var flags = ts.modifiersToFlags(modifiers); - modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); - } - var node = kind === 174 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 175 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 168 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 169 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 171 /* Constructor */ ? ts.factory.createConstructorDeclaration(modifiers, parameters, /*body*/ undefined) : - kind === 172 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 173 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 176 /* IndexSignature */ ? ts.factory.createIndexSignature(modifiers, parameters, returnTypeNode) : - kind === 317 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 179 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 180 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 256 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 213 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 214 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* ModifierFlags.Abstract */); + } + var node = kind === 174 /* SyntaxKind.CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 175 /* SyntaxKind.ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 168 /* SyntaxKind.MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 169 /* SyntaxKind.MethodDeclaration */ ? ts.factory.createMethodDeclaration(modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 171 /* SyntaxKind.Constructor */ ? ts.factory.createConstructorDeclaration(modifiers, parameters, /*body*/ undefined) : + kind === 172 /* SyntaxKind.GetAccessor */ ? ts.factory.createGetAccessorDeclaration(modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 173 /* SyntaxKind.SetAccessor */ ? ts.factory.createSetAccessorDeclaration(modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 176 /* SyntaxKind.IndexSignature */ ? ts.factory.createIndexSignature(modifiers, parameters, returnTypeNode) : + kind === 317 /* SyntaxKind.JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 179 /* SyntaxKind.FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 180 /* SyntaxKind.ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 213 /* SyntaxKind.FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 214 /* SyntaxKind.ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -53895,7 +54083,7 @@ var ts; } function typeParameterToDeclarationWithConstraint(type, context, constraintNode) { var savedContextFlags = context.flags; - context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic + context.flags &= ~512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic var modifiers = ts.factory.createModifiersFromModifierFlags(getVarianceModifiers(type)); var name = typeParameterToName(type, context); var defaultParameter = getDefaultFromTypeParameter(type); @@ -53909,26 +54097,26 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* SyntaxKind.Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* SyntaxKind.JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && ts.canHaveModifiers(parameterDeclaration) ? ts.map(ts.getModifiers(parameterDeclaration), ts.factory.cloneNode) : undefined; - var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; - var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; + var modifiers = !(context.flags & 8192 /* NodeBuilderFlags.OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && ts.canHaveModifiers(parameterDeclaration) ? ts.map(ts.getModifiers(parameterDeclaration), ts.factory.cloneNode) : undefined; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* CheckFlags.RestParameter */; + var dotDotDotToken = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 161 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* EmitFlags.NoAsciiEscaping */) : + parameterDeclaration.name.kind === 161 /* SyntaxKind.QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* EmitFlags.NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* CheckFlags.OptionalParameter */; + var questionToken = isOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var parameterNode = ts.factory.createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); context.approximateLength += ts.symbolName(parameterSymbol).length + 3; @@ -53954,7 +54142,7 @@ var ts; if (!ts.nodeIsSynthesized(visited)) { visited = ts.factory.cloneNode(visited); } - return ts.setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); + return ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */ | 16777216 /* EmitFlags.NoAsciiEscaping */); } } } @@ -53963,9 +54151,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = ts.getFirstIdentifier(accessExpression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* SymbolFlags.Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -53975,8 +54163,8 @@ var ts; function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) { + var isTypeParameter = symbol.flags & 262144 /* SymbolFlags.TypeParameter */; + if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */) && !(context.flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */)) { chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } @@ -53986,7 +54174,7 @@ var ts; return chain; /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol, meaning, endOfChain) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */)); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */)); var parentSpecifiers; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -54005,8 +54193,8 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { - if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && - getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + if (parent.exports && parent.exports.get("export=" /* InternalSymbolName.ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* InternalSymbolName.ExportEquals */), symbol)) { // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent // No need to lookup an alias for the symbol in itself accessibleSymbolChain = parentChain; @@ -54025,7 +54213,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */))) { // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return; @@ -54055,7 +54243,7 @@ var ts; function typeParametersToTypeParameterDeclarations(symbol, context) { var typeParameterNodes; var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + if (targetSymbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 524288 /* SymbolFlags.TypeAlias */)) { typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); })); } return typeParameterNodes; @@ -54070,11 +54258,11 @@ var ts; } (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId); var typeParameterNodes; - if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { + if (context.flags & 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { var parentSymbol = symbol; var nextSymbol_1 = chain[index + 1]; - if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) { - var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol); + if (ts.getCheckFlags(nextSymbol_1) & 1 /* CheckFlags.Instantiated */) { + var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(parentSymbol) : parentSymbol); typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context); } else { @@ -54094,11 +54282,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context, overrideImportMode) { var _a; - var file = ts.getDeclarationOfKind(symbol, 305 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SyntaxKind.SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -54150,7 +54338,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -54159,8 +54347,8 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var _a, _b, _c, _d; - var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 111551 /* Value */; + var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module + var isTypeOf = meaning === 111551 /* SymbolFlags.Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -54182,7 +54370,7 @@ var ts; if (!specifier) { specifier = getSpecifierForModuleSymbol(chain[0], context); } - if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & 67108864 /* NodeBuilderFlags.AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { var oldSpecifier = specifier; if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set @@ -54244,16 +54432,16 @@ var ts; var parent = chain[index - 1]; var symbolName; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; symbolName = getNameOfSymbolAsWritten(symbol, context); context.approximateLength += (symbolName ? symbolName.length : 0) + 1; - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } else { if (parent && getExportsOfSymbol(parent)) { var exports_2 = getExportsOfSymbol(parent); ts.forEachEntry(exports_2, function (ex, name) { - if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* InternalSymbolName.ExportEquals */) { symbolName = ts.unescapeLeadingUnderscores(name); return true; } @@ -54272,7 +54460,7 @@ var ts; symbolName = getNameOfSymbolAsWritten(symbol, context); } context.approximateLength += symbolName.length + 1; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + if (!(context.flags & 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access @@ -54284,7 +54472,7 @@ var ts; return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName))); } } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; if (index > stopper) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); @@ -54297,9 +54485,9 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context, type) { - var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* SymbolFlags.Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); if (result) { - if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) { + if (result.flags & 262144 /* SymbolFlags.TypeParameter */ && result === type.symbol) { return false; } return true; @@ -54308,23 +54496,23 @@ var ts; } function typeParameterToName(type, context) { var _a, _b; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { return cached; } } - var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 79 /* Identifier */)) { + var result = symbolToName(type.symbol, context, 788968 /* SymbolFlags.Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 79 /* SyntaxKind.Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -54341,7 +54529,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* NodeBuilderFlags.AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -54349,13 +54537,13 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -54367,38 +54555,38 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); } - var canUsePropertyAccess = firstChar === 35 /* hash */ ? + var canUsePropertyAccess = firstChar === 35 /* CharacterCodes.hash */ ? symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) : ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier; } else { - if (firstChar === 91 /* openBracket */) { + if (firstChar === 91 /* CharacterCodes.openBracket */) { symbolName = symbolName.substring(1, symbolName.length - 1); firstChar = symbolName.charCodeAt(0); } var expression = void 0; - if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) { - expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */); + if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* SymbolFlags.EnumMember */)) { + expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* CharacterCodes.singleQuote */); } else if (("" + +symbolName) === symbolName) { expression = ts.factory.createNumericLiteral(+symbolName); } if (!expression) { - expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); expression.symbol = symbol; } return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression); @@ -54427,7 +54615,7 @@ var ts; function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { return ts.factory.createStringLiteral(name, !!singleQuote); @@ -54437,8 +54625,8 @@ var ts; } return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions)); } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* SymbolFlags.Value */)); } } } @@ -54472,7 +54660,7 @@ var ts; 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); + return !(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag @@ -54493,9 +54681,9 @@ var ts; } } var oldFlags = context.flags; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { - context.flags |= 1048576 /* AllowUniqueESSymbolType */; + context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } var result = typeToTypeNodeHelper(type, context); context.flags = oldFlags; @@ -54507,7 +54695,7 @@ var ts; return true; } if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { - return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode; + return getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */) === typeFromTypeNode; } return false; } @@ -54516,7 +54704,7 @@ var ts; var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { var annotated = getTypeFromTypeNode(annotation); - var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + var thisInstantiated = annotated.flags & 262144 /* TypeFlags.TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { @@ -54535,20 +54723,20 @@ var ts; introducesError = true; return { introducesError: introducesError, node: node }; } - var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + var sym = resolveEntityName(leftmost, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); if (sym) { - if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) { + if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */) { introducesError = true; } else { - (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */); + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */); includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym); } if (ts.isIdentifier(node)) { var type = getDeclaredTypeOfSymbol(sym); - var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); + var name = sym.flags & 262144 /* SymbolFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); name.symbol = sym; // for quickinfo, which uses identifier symbol information - return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) }; + return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* EmitFlags.NoAsciiEscaping */) }; } } return { introducesError: introducesError, node: node }; @@ -54566,17 +54754,17 @@ var ts; return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 319 /* SyntaxKind.JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -54590,11 +54778,11 @@ var ts; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; return ts.factory.createPropertySignature( - /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -54609,15 +54797,15 @@ var ts; return ts.factory.createConstructorTypeNode( /*modifiers*/ undefined, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration( /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) { + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } if (ts.isLiteralImportTypeNode(node)) { @@ -54626,7 +54814,7 @@ var ts; nodeSymbol && ( // The import type resolved using jsdoc fallback logic - (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */)) || + (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* SymbolFlags.Type */)) || // The import type had type arguments autofilled by js fallback logic !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); @@ -54641,17 +54829,17 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); function getEffectiveDotDotDotForParameter(p) { - return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined); + return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined); } /** Note that `new:T` parameters are not handled, but should be before calling this function. */ function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -54682,8 +54870,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* SyntaxKind.MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* SyntaxKind.MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -54696,10 +54884,10 @@ var ts; var oldcontext = context; context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); - if (accessibleResult.accessibility === 0 /* Accessible */) { + if (accessibleResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Lookup the root symbol of the chain of refs we'll use to access it and serialize it var chain = lookupSymbolChainWorker(sym, context, meaning); - if (!(sym.flags & 4 /* Property */)) { + if (!(sym.flags & 4 /* SymbolFlags.Property */)) { includePrivateSymbol(chain[0]); } } @@ -54714,16 +54902,16 @@ var ts; void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` }); var addingDeclare = !bundled; - var exportEquals = symbolTable.get("export=" /* ExportEquals */); - if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + var exportEquals = symbolTable.get("export=" /* InternalSymbolName.ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* SymbolFlags.Alias */) { symbolTable = ts.createSymbolTable(); // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) - symbolTable.set("export=" /* ExportEquals */, exportEquals); + symbolTable.set("export=" /* InternalSymbolName.ExportEquals */, exportEquals); } visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 79 /* Identifier */; + return !!node && node.kind === 79 /* SyntaxKind.Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -54740,7 +54928,7 @@ var ts; ns.body && ts.isModuleBlock(ns.body)) { // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments - var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* Export */); }); + var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* ModifierFlags.Export */); }); var name_3 = ns.name; var body = ns.body; if (ts.length(excessExports)) { @@ -54755,9 +54943,9 @@ var ts; results = []; // If the namespace contains no export assignments or declarations, and no declarations flagged with `export`, then _everything_ is exported - // to respect this as the top level, we need to add an `export` modifier to everything - var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); + var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* ModifierFlags.Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); ts.forEach(body.statements, function (s) { - addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + addResult(s, mixinExportFlag_1 ? 1 /* ModifierFlags.Export */ : 0 /* ModifierFlags.None */); // Recalculates the ambient (and export, if applicable from above) flag }); statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true); } @@ -54851,11 +55039,11 @@ var ts; isTypeDeclaration(node); } function addExportModifier(node) { - var flags = (ts.getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; + var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */; return ts.factory.updateModifiers(node, flags); } function removeExportModifier(node) { - var flags = ts.getEffectiveModifierFlags(node) & ~1 /* Export */; + var flags = ts.getEffectiveModifierFlags(node) & ~1 /* ModifierFlags.Export */; return ts.factory.updateModifiers(node, flags); } function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { @@ -54888,12 +55076,11 @@ var ts; if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { var oldContext = context; context = cloneNodeBuilderContext(context); - var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); if (context.reportedDiagnostic) { oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context } context = oldContext; - return result; } } // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias @@ -54908,37 +55095,37 @@ var ts; function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { var _a, _b, _c, _d; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isDefault = symbol.escapedName === "default" /* Default */; - if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */; + if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( context.encounteredError = true; // TODO: Issue error via symbol tracker? return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name } - var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ - || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault; // `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); - var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && - symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && - symbol.escapedName !== "export=" /* ExportEquals */; + var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ && + symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) && + symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); - if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { serializeTypeAlias(symbol, symbolName, modifierFlags); } // Need to skip over export= symbols below - json source files get a single `Property` flagged // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. - if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) - && symbol.escapedName !== "export=" /* ExportEquals */ - && !(symbol.flags & 4194304 /* Prototype */) - && !(symbol.flags & 32 /* Class */) + if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) + && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */) + && !(symbol.flags & 32 /* SymbolFlags.Class */) && !isConstMergedWithNSPrintableAsSignatureMerge) { if (propertyAsAlias) { var createdExport = serializeMaybeAliasAssignment(symbol); @@ -54950,21 +55137,21 @@ var ts; else { var type = getTypeOfSymbol(symbol); var localName = getInternalSymbolName(symbol, symbolName); - if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); } else { // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` - var flags = !(symbol.flags & 2 /* BlockScopedVariable */) + var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) - ? 2 /* Const */ + ? 2 /* NodeFlags.Const */ : undefined : isConstVariable(symbol) - ? 2 /* Const */ - : 1 /* Let */; - var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + ? 2 /* NodeFlags.Const */ + : 1 /* NodeFlags.Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* SymbolFlags.Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; @@ -54975,14 +55162,14 @@ var ts; var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */); - context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* ModifierFlags.None */); + context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* SymbolFlags.Value */); } else { var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~1 /* ModifierFlags.Export */ : modifierFlags); if (name !== localName && !isPrivate) { // We rename the variable declaration we generate for Property symbols since they may have a name which // conflicts with a local declaration. For example, given input: @@ -55007,7 +55194,7 @@ var ts; // To create an export named `g` that does _not_ shadow the local `g` addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* ModifierFlags.None */); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -55015,11 +55202,11 @@ var ts; } } } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { serializeEnum(symbol, symbolName, modifierFlags); } - if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ + if (symbol.flags & 32 /* SymbolFlags.Class */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { @@ -55032,20 +55219,20 @@ var ts; serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } } - if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + if ((symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeModule(symbol, symbolName, modifierFlags); } // The class meaning serialization should handle serializing all interface members - if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) { + if (symbol.flags & 64 /* SymbolFlags.Interface */ && !(symbol.flags & 32 /* SymbolFlags.Class */)) { serializeInterface(symbol, symbolName, modifierFlags); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } - if (symbol.flags & 8388608 /* ExportStar */) { + if (symbol.flags & 8388608 /* SymbolFlags.ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration if (symbol.declarations) { @@ -55054,17 +55241,17 @@ var ts; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); if (!resolvedModule) continue; - addResult(ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + addResult(ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* ModifierFlags.None */); } } } if (needsPostExportDefault) { - addResult(ts.factory.createExportAssignment(/*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + addResult(ts.factory.createExportAssignment(/*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* ModifierFlags.None */); } else if (needsExportDeclaration) { addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* ModifierFlags.None */); } } function includePrivateSymbol(symbol) { @@ -55077,7 +55264,7 @@ var ts; // will throw a wrench in this, since those may have been nested, but we'll need to synthesize them in the outer scope // anyway, as that's the only place the import they translate to is valid. In such a case, we might need to use a unique name // for the moved import; which hopefully the above `getUnusedName` call should produce. - var isExternalImportAlias = !!(symbol.flags & 2097152 /* Alias */) && !ts.some(symbol.declarations, function (d) { + var isExternalImportAlias = !!(symbol.flags & 2097152 /* SymbolFlags.Alias */) && !ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, ts.isExportDeclaration) || ts.isNamespaceExport(d) || (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference)); @@ -55091,23 +55278,23 @@ var ts; // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { - var newModifierFlags = 0 /* None */; + var newModifierFlags = 0 /* ModifierFlags.None */; var enclosingDeclaration_1 = context.enclosingDeclaration && (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && + if (additionalModifierFlags & 1 /* ModifierFlags.Export */ && enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) && canHaveExportModifier(node)) { // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private - newModifierFlags |= 1 /* Export */; + newModifierFlags |= 1 /* ModifierFlags.Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) && + if (addingDeclare && !(newModifierFlags & 1 /* ModifierFlags.Export */) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* NodeFlags.Ambient */)) && (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope - newModifierFlags |= 2 /* Ambient */; + newModifierFlags |= 2 /* ModifierFlags.Ambient */; } - if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { - newModifierFlags |= 512 /* Default */; + if ((additionalModifierFlags & 512 /* ModifierFlags.Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* ModifierFlags.Default */; } if (newModifierFlags) { node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node)); @@ -55123,14 +55310,14 @@ var ts; var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias); var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined); var oldFlags = context.flags; - context.flags |= 8388608 /* InTypeAlias */; + context.flags |= 8388608 /* NodeBuilderFlags.InTypeAlias */; var oldEnclosingDecl = context.enclosingDeclaration; context.enclosingDeclaration = jsdocAliasDecl; var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); - addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; context.enclosingDeclaration = oldEnclosingDecl; } @@ -55141,10 +55328,10 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 174 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 175 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* SignatureKind.Call */, interfaceType, baseType, 174 /* SyntaxKind.CallSignature */); + var constructSignatures = serializeSignatures(1 /* SignatureKind.Construct */, interfaceType, baseType, 175 /* SyntaxKind.ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* SymbolFlags.Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); } @@ -55152,7 +55339,7 @@ var ts; return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); } function isTypeOnlyNamespace(symbol) { - return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); }); } function serializeModule(symbol, symbolName, modifierFlags) { var members = getNamespaceMembersForSerialization(symbol); @@ -55165,14 +55352,14 @@ var ts; // so we don't even have placeholders to fill in. if (ts.length(realMembers)) { var localName = getInternalSymbolName(symbol, symbolName); - serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* SymbolFlags.Function */ | 67108864 /* SymbolFlags.Assignment */))); } if (ts.length(mergedMembers)) { var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); var localName = getInternalSymbolName(symbol, symbolName); var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; }), function (s) { var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); @@ -55187,11 +55374,11 @@ var ts; return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name === targetName ? undefined : targetName, name); })))]); addResult(ts.factory.createModuleDeclaration( - /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* NodeFlags.Namespace */), 0 /* ModifierFlags.None */); } } function serializeEnum(symbol, symbolName, modifierFlags) { - addResult(ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + addResult(ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* ModifierFlags.Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* SymbolFlags.EnumMember */); }), function (p) { // TODO: Handle computed names // I hate that to get the initialized value we need to walk back to the declarations here; but there's no // other way to get the possible const value of an enum member that I'm aware of, as the value is cached @@ -55203,22 +55390,22 @@ var ts; })), modifierFlags); } function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 256 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 256 /* SyntaxKind.FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports - if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + if (!(symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } function getSignatureTextRangeLocation(signature) { if (signature.declaration && signature.declaration.parent) { - if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* AssignmentDeclarationKind.Property */) { return signature.declaration.parent; } // for expressions assigned to `var`s, use the `var` as the text range @@ -55252,7 +55439,7 @@ var ts; // emit akin to the above would be needed. // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace, enclosingDeclaration); fakespace.locals = ts.createSymbolTable(props); fakespace.symbol = props[0].parent; @@ -55272,15 +55459,15 @@ var ts; // replace namespace with synthetic version var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); - var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* InternalSymbolName.Default */))])) : d; }); + var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* ModifierFlags.Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); // namespaces can never be default exported } } function isNamespaceMember(p) { - return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); + return !!(p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */)) || + !(p.flags & 4194304 /* SymbolFlags.Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); } function sanitizeJSDocImplements(clauses) { var result = ts.mapDefined(clauses, function (e) { @@ -55329,7 +55516,7 @@ var ts; var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* SyntaxKind.ImplementsKeyword */, implementsExpressions)], true); var symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from @@ -55355,17 +55542,17 @@ var ts; ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); // When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether // the value is ever initialized with a class or function-like value. For cases where `X` could never be // created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable. var isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && ts.isInJSFile(symbol.valueDeclaration) && - !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); + !ts.some(getSignaturesOfType(staticType, 1 /* SignatureKind.Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? - [ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 171 /* Constructor */); + [ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(8 /* ModifierFlags.Private */), [], /*body*/ undefined)] : + serializeSignatures(1 /* SignatureKind.Construct */, staticType, staticBaseType, 171 /* SyntaxKind.Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -55407,34 +55594,34 @@ var ts; // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === "export=" /* InternalSymbolName.ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match - verbatimTargetName = "default" /* Default */; + verbatimTargetName = "default" /* InternalSymbolName.Default */; } var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 203 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* VariableDeclaration */) { + case 203 /* SyntaxKind.BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* SyntaxKind.VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier( /*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), - /*importClause*/ undefined), 0 /* None */); + /*importClause*/ undefined), 0 /* ModifierFlags.None */); break; } // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 297 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* BinaryExpression */) { + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* SyntaxKind.BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -55444,7 +55631,7 @@ var ts; // import _x = require('y'); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */); + /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* ModifierFlags.None */); // import x = _x.z addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, @@ -55452,48 +55639,48 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // This _specifically_ only exists to handle json declarations - where we make aliases, but since // we emit no declarations for the json document, must not refer to it in the declarations - if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { + if (target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { serializeMaybeAliasAssignment(symbol); break; } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node); + var isLocalImport = !(target.flags & 512 /* SymbolFlags.ValueModule */) && !ts.isVariableDeclaration(node); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createIdentifier(localName), isLocalImport - ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) - : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); + ? symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false) + : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* ModifierFlags.None */); break; - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse - addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* ModifierFlags.None */); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* ModifierFlags.None */); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause( /*isTypeOnly*/ false, @@ -55501,9 +55688,9 @@ var ts; ts.factory.createImportSpecifier( /*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -55511,16 +55698,16 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 221 /* BinaryExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier - if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */ || symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } else { @@ -55534,18 +55721,18 @@ var ts; function serializeExportSpecifier(localName, targetName, specifier) { addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* ModifierFlags.None */); } /** * Returns `true` if an export assignment or declaration was produced for the symbol */ function serializeMaybeAliasAssignment(symbol) { - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return false; } var name = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isExportEquals = name === "export=" /* ExportEquals */; - var isDefault = name === "default" /* Default */; + var isExportEquals = name === "export=" /* InternalSymbolName.ExportEquals */; + var isDefault = name === "default" /* InternalSymbolName.Default */; var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault; // synthesize export = ref // ref should refer to either be a locally scoped symbol which we need to emit, or @@ -55560,7 +55747,7 @@ var ts; // Technically, this is all that's required in the case where the assignment is an entity name expression var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl)); var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; - var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); if (referenced || target) { includePrivateSymbol(referenced || target); } @@ -55573,7 +55760,7 @@ var ts; context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( - /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* SymbolFlags.All */))); } else { if (first_1 === expr && first_1) { @@ -55588,7 +55775,7 @@ var ts; var varName = getUnusedName(name, symbol); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)), 0 /* ModifierFlags.None */); serializeExportSpecifier(name, varName); } } @@ -55603,17 +55790,17 @@ var ts; var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* ModifierFlags.None */ : 1 /* ModifierFlags.Export */); } else { var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* SymbolFlags.Property */ && target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ModifierFlags.Ambient */ + : name === varName ? 1 /* ModifierFlags.Export */ + : 0 /* ModifierFlags.None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -55632,11 +55819,11 @@ var ts; // context source file, and whose property names are all valid identifiers and not late-bound, _and_ // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); - return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + return ts.getObjectFlags(typeToSerialize) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */) && !ts.length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class - !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && - !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* SignatureKind.Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* SignatureKind.Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && @@ -55647,33 +55834,33 @@ var ts; return function serializePropertySymbol(p, isStatic, baseType) { var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); - var isPrivate = !!(modifierFlags & 8 /* Private */); - if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + var isPrivate = !!(modifierFlags & 8 /* ModifierFlags.Private */); + if (isStatic && (p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members return []; } - if (p.flags & 4194304 /* Prototype */ || + if (p.flags & 4194304 /* SymbolFlags.Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) - && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && (p.flags & 16777216 /* SymbolFlags.Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* SymbolFlags.Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* ModifierFlags.Async */) | (isStatic ? 32 /* ModifierFlags.Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); - if (p.flags & 98304 /* Accessor */ && useAccessors) { + if (p.flags & 98304 /* SymbolFlags.Accessor */ && useAccessors) { var result = []; - if (p.flags & 65536 /* SetAccessor */) { + if (p.flags & 65536 /* SymbolFlags.SetAccessor */) { result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], /*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } - if (p.flags & 32768 /* GetAccessor */) { - var isPrivate_1 = modifierFlags & 8 /* Private */; + if (p.flags & 32768 /* SymbolFlags.GetAccessor */) { + var isPrivate_1 = modifierFlags & 8 /* ModifierFlags.Private */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } @@ -55681,17 +55868,17 @@ var ts; } // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints - else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { - return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), + else if (p.flags & (4 /* SymbolFlags.Property */ | 3 /* SymbolFlags.Variable */ | 98304 /* SymbolFlags.Accessor */)) { + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } - if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + if (p.flags & (8192 /* SymbolFlags.Method */ | 16 /* SymbolFlags.Function */)) { var type = getTypeOfSymbol(p); - var signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { - return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); + if (flag & 8 /* ModifierFlags.Private */) { + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, /*type*/ undefined, /*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } @@ -55701,7 +55888,7 @@ var ts; // Each overload becomes a separate method declaration, in order var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, { name: name, - questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + questionToken: p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; @@ -55710,7 +55897,7 @@ var ts; return results_1; } // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -55718,13 +55905,13 @@ var ts; } function serializeSignatures(kind, input, baseType, outputKind) { var signatures = getSignaturesOfType(input, kind); - if (kind === 1 /* Construct */) { + if (kind === 1 /* SignatureKind.Construct */) { if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // No base type, every constructor is empty - elide the extraneous `constructor()` } if (baseType) { // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations - var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + var baseSigs = getSignaturesOfType(baseType, 1 /* SignatureKind.Construct */); if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list } @@ -55745,7 +55932,7 @@ var ts; for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { var s = signatures_4[_i]; if (s.declaration) { - privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */); } } if (privateProtected) { @@ -55780,15 +55967,15 @@ var ts; return results; } function serializeBaseType(t, staticType, rootName) { - var ref = trySerializeAsTypeReference(t, 111551 /* Value */); + var ref = trySerializeAsTypeReference(t, 111551 /* SymbolFlags.Value */); if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context)) - ], 2 /* Const */)); - addResult(statement, 0 /* None */); + ], 2 /* NodeFlags.Const */)); + addResult(statement, 0 /* ModifierFlags.None */); return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), /*typeArgs*/ undefined); } function trySerializeAsTypeReference(t, flags) { @@ -55798,22 +55985,22 @@ var ts; // which we can't write out in a syntactically valid way as an expression if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) { typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); - reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.target.symbol, context, 788968 /* SymbolFlags.Type */); } else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) { - reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */); } if (reference) { return ts.factory.createExpressionWithTypeArguments(reference, typeArgs); } } function serializeImplementedType(t) { - var ref = trySerializeAsTypeReference(t, 788968 /* Type */); + var ref = trySerializeAsTypeReference(t, 788968 /* SymbolFlags.Type */); if (ref) { return ref; } if (t.symbol) { - return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* Type */), /*typeArgs*/ undefined); + return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */), /*typeArgs*/ undefined); } } function getUnusedName(input, symbol) { @@ -55831,7 +56018,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -55840,17 +56027,17 @@ var ts; return input; } function getNameCandidateWorker(symbol, localName) { - if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + if (localName === "default" /* InternalSymbolName.Default */ || localName === "__class" /* InternalSymbolName.Class */ || localName === "__function" /* InternalSymbolName.Function */) { var flags = context.flags; - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; var nameCandidate = getNameOfSymbolAsWritten(symbol, context); context.flags = flags; localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; } - if (localName === "default" /* Default */) { + if (localName === "default" /* InternalSymbolName.Default */) { localName = "_default"; } - else if (localName === "export=" /* ExportEquals */) { + else if (localName === "export=" /* InternalSymbolName.ExportEquals */) { localName = "_exports"; } localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); @@ -55869,14 +56056,14 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined, typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */) // TODO: GH#18217 ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); return writer; } } @@ -55886,10 +56073,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 98304 /* Nullable */)) { - if (t.flags & (512 /* BooleanLiteral */ | 1024 /* EnumLiteral */)) { - var baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 1048576 /* Union */) { + if (!(t.flags & 98304 /* TypeFlags.Nullable */)) { + if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) { + var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 1048576 /* TypeFlags.Union */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -55901,25 +56088,25 @@ var ts; result.push(t); } } - if (flags & 65536 /* Null */) + if (flags & 65536 /* TypeFlags.Null */) result.push(nullType); - if (flags & 32768 /* Undefined */) + if (flags & 32768 /* TypeFlags.Undefined */) result.push(undefinedType); return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 8 /* ModifierFlags.Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 16 /* ModifierFlags.Protected */) { return "protected"; } return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { + if (type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 259 /* TypeAliasDeclaration */) { + if (node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -55927,27 +56114,27 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 262 /* ModuleBlock */ && + node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 305 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 305 /* SyntaxKind.SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\""; + return "\"".concat(ts.escapeString(name, 34 /* CharacterCodes.doubleQuote */), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -55959,9 +56146,9 @@ var ts; * It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`. */ function getNameOfSymbolAsWritten(symbol, context) { - if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && + if (context && symbol.escapedName === "default" /* InternalSymbolName.Default */ && !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default` - (!(context.flags & 16777216 /* InInitialEntityName */) || + (!(context.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default` !symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default` @@ -55975,9 +56162,9 @@ var ts; if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } - if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* Late */)) { + if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */)) { var nameType = getSymbolLinks(symbol).nameType; - if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType && nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { // Computed property name isn't late bound, but has a well-known name type - use name type to generate a symbol name var result = getNameOfSymbolFromNameType(symbol, context); if (result !== undefined) { @@ -55990,17 +56177,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 254 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 226 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 226 /* SyntaxKind.ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -56017,84 +56204,84 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return isDeclarationVisible(node.parent.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 256 /* FunctionDeclaration */: - case 260 /* EnumDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) { + if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) && + !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 164 /* Parameter */: - case 262 /* ModuleBlock */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 178 /* TypeReference */: - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 164 /* SyntaxKind.Parameter */: + case 262 /* SyntaxKind.ModuleBlock */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 178 /* SyntaxKind.TypeReference */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: return false; // Type parameters are always visible - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: // Source file and namespace export are always visible // falls through - case 305 /* SourceFile */: - case 264 /* NamespaceExportDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return false; default: return false; @@ -56103,11 +56290,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 271 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 275 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } var result; var visited; @@ -56131,7 +56318,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol && visited) { if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) { buildVisibleNodeList(importSymbol.declarations); @@ -56180,23 +56367,23 @@ var ts; } function hasType(target, propertyName) { switch (propertyName) { - case 0 /* Type */: + case 0 /* TypeSystemPropertyName.Type */: return !!getSymbolLinks(target).type; - case 5 /* EnumTagType */: + case 5 /* TypeSystemPropertyName.EnumTagType */: return !!(getNodeLinks(target).resolvedEnumType); - case 2 /* DeclaredType */: + case 2 /* TypeSystemPropertyName.DeclaredType */: return !!getSymbolLinks(target).declaredType; - case 1 /* ResolvedBaseConstructorType */: + case 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */: return !!target.resolvedBaseConstructorType; - case 3 /* ResolvedReturnType */: + case 3 /* TypeSystemPropertyName.ResolvedReturnType */: return !!target.resolvedReturnType; - case 4 /* ImmediateBaseConstraint */: + case 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */: return !!target.immediateBaseConstraint; - case 6 /* ResolvedTypeArguments */: + case 6 /* TypeSystemPropertyName.ResolvedTypeArguments */: return !!target.resolvedTypeArguments; - case 7 /* ResolvedBaseTypes */: + case 7 /* TypeSystemPropertyName.ResolvedBaseTypes */: return !!target.baseTypesResolved; - case 8 /* WriteType */: + case 8 /* TypeSystemPropertyName.WriteType */: return !!getSymbolLinks(target).writeType; } return ts.Debug.assertNever(propertyName); @@ -56213,12 +56400,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 255 /* VariableDeclarationList */: - case 270 /* ImportSpecifier */: - case 269 /* NamedImports */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 255 /* SyntaxKind.VariableDeclarationList */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 269 /* SyntaxKind.NamedImports */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: return false; default: return true; @@ -56243,28 +56430,28 @@ var ts; return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType; } function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; + return type && (type.flags & 1 /* TypeFlags.Any */) !== 0; } function isErrorType(type) { // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for // a reference to an unresolved symbol. We want those to behave like the errorType. - return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol); + return type === errorType || !!(type.flags & 1 /* TypeFlags.Any */ && type.aliasSymbol); } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node, checkMode) { - if (checkMode !== 0 /* Normal */) { + if (checkMode !== 0 /* CheckMode.Normal */) { return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (source.flags & 131072 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); + if (source.flags & 131072 /* TypeFlags.Never */) { return emptyObjectType; } - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); @@ -56272,9 +56459,9 @@ var ts; var unspreadableToRestKeys = []; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); + var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) - && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) + && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } @@ -56289,7 +56476,7 @@ var ts; // they are explicitly omitted, as they would in the non-generic case. omitKeyType = getUnionType(__spreadArray([omitKeyType], unspreadableToRestKeys, true)); } - if (omitKeyType.flags & 131072 /* Never */) { + if (omitKeyType.flags & 131072 /* TypeFlags.Never */) { return source; } var omitTypeAlias = getGlobalOmitSymbol(); @@ -56304,15 +56491,15 @@ var ts; members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false)); } var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source)); - result.objectFlags |= 4194304 /* ObjectRestType */; + result.objectFlags |= 4194304 /* ObjectFlags.ObjectRestType */; return result; } function isGenericTypeWithUndefinedConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* TypeFlags.Undefined */); } function getNonUndefinedType(type) { - var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; - return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */); + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288 /* TypeFacts.NEUndefined */); } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: @@ -56348,34 +56535,34 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ancestor.initializer; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 203 /* BindingElement */ && parent.kind === 201 /* ObjectBindingPattern */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */ && parent.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 296 /* PropertyAssignment */ || node.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.kind === 296 /* SyntaxKind.PropertyAssignment */ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); } function getLiteralPropertyNameText(name) { var type = getLiteralTypeFromPropertyName(name); - return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : undefined; + return type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */) ? "" + type.value : undefined; } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { - var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var checkMode = declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode); return parentType && getBindingElementTypeFromParentType(declaration, parentType); } @@ -56386,18 +56573,18 @@ var ts; } var pattern = declaration.parent; // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 16777216 /* NodeFlags.Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` - else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) { - parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* TypeFacts.EQUndefined */)) { + parentType = getTypeWithFacts(parentType, 524288 /* TypeFacts.NEUndefined */); } var type; - if (pattern.kind === 201 /* ObjectBindingPattern */) { + if (pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); - if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* TypeFlags.Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return errorType; } @@ -56414,7 +56601,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* AccessFlags.ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -56422,7 +56609,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern); + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* IterationUse.PossiblyOutOfBounds */), parentType, undefinedType, pattern); var index_2 = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { // If the parent is a tuple type, the rest element has a tuple type of the @@ -56434,7 +56621,7 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getNumberLiteralType(index_2); - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } @@ -56448,9 +56635,9 @@ var ts; if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type; + return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)) & 16777216 /* TypeFacts.IsUndefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)], 2 /* UnionReduction.Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -56461,11 +56648,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* SyntaxKind.NullKeyword */ || expr.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 204 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, isProperty, isOptional) { if (isProperty === void 0) { isProperty = false; } @@ -56476,11 +56663,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode))); - return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -56502,11 +56689,11 @@ var ts; } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) { + !(ts.getCombinedModifierFlags(declaration) & 1 /* ModifierFlags.Export */) && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. - if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array @@ -56518,8 +56705,8 @@ var ts; if (ts.isParameter(declaration)) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 173 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* GetAccessor */); + if (func.kind === 173 /* SyntaxKind.SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* SyntaxKind.GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -56537,7 +56724,7 @@ var ts; return type_1; } // Use contextual parameter type if one is available - var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); + var type = declaration.symbol.escapedName === "this" /* InternalSymbolName.This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { return addOptionality(type, /*isProperty*/ false, isOptional); } @@ -56560,14 +56747,14 @@ var ts; if (!ts.hasStaticModifier(declaration)) { var constructor = findConstructorDeclaration(declaration.parent); var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } else { var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } @@ -56596,7 +56783,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 207 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 207 /* SyntaxKind.ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -56618,7 +56805,7 @@ var ts; 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 === 171 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(container))) { return container; } } @@ -56678,7 +56865,7 @@ var ts; } function getFlowTypeOfProperty(reference, prop) { var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) - && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* ModifierFlags.Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); @@ -56717,7 +56904,7 @@ var ts; var kind = ts.isAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } @@ -56747,12 +56934,12 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes); } } var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); - if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -56776,7 +56963,7 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - type.objectFlags |= 4096 /* JSLiteral */; + type.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { @@ -56832,13 +57019,13 @@ var ts; if (containsSameNamedThisProperty(expression.left, expression.right)) { return anyType; } - var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); + var isDirectExport = kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right)) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 524288 /* Object */ && - kind === 2 /* ModuleExports */ && - symbol.escapedName === "export=" /* ExportEquals */) { + if (type.flags & 524288 /* TypeFlags.Object */ && + kind === 2 /* AssignmentDeclarationKind.ModuleExports */ && + symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); ts.copyEntries(exportedType.members, members_4); @@ -56849,8 +57036,8 @@ var ts; (resolvedSymbol || symbol).exports.forEach(function (s, name) { var _a; var exportedMember = members_4.get(name); - if (exportedMember && exportedMember !== s) { - if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) { + if (exportedMember && exportedMember !== s && !(s.flags & 2097152 /* SymbolFlags.Alias */)) { + if (s.flags & 111551 /* SymbolFlags.Value */ && exportedMember.flags & 111551 /* SymbolFlags.Value */) { // If the member has an additional value-like declaration, union the types from the two declarations, // but issue an error if they occurred in two different files. The purpose is to support a JS file with // a pattern like: @@ -56888,15 +57075,15 @@ var ts; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = type.aliasTypeArguments; } - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { result.aliasSymbol = type.symbol; var args = getTypeArguments(type); result.aliasTypeArguments = ts.length(args) ? args : undefined; } } - result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag - if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */); // Propagate JSLiteral flag + if (result.symbol && result.symbol.flags & 32 /* SymbolFlags.Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { + result.objectFlags |= 16777216 /* ObjectFlags.IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -56908,16 +57095,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 108 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 171 /* Constructor */ || - thisContainer.kind === 256 /* FunctionDeclaration */ || - (thisContainer.kind === 213 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 171 /* SyntaxKind.Constructor */ || + thisContainer.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (thisContainer.kind === 213 /* SyntaxKind.FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -56937,7 +57124,7 @@ var ts; // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType))); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -56945,17 +57132,13 @@ var ts; if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAny(element, anyType); } - // When we're including the pattern in the type (an indication we're obtaining a contextual type), we - // use the non-inferrable any type. Inference will never directly infer this type, but it is possible - // to infer a type that contains it, e.g. for a binding pattern like [foo] or { foo }. In such cases, - // widening of the binding pattern type substitutes a regular any for the non-inferrable any. - return includePatternInType ? nonInferrableAnyType : anyType; + return anyType; } // Return the type implied by an object binding pattern function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -56965,11 +57148,11 @@ var ts; var exprType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(exprType)) { // do not include computed properties in the implied type - objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; return; } var text = getPropertyNameFromType(exprType); - var flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0); + var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; @@ -56979,7 +57162,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56987,18 +57170,18 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 203 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { - return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1; - var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* Rest */ : i >= minLength ? 2 /* Optional */ : 1 /* Required */; }); + var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; }); var result = createTupleType(elementTypes, elementFlags); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -57012,7 +57195,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 201 /* ObjectBindingPattern */ + return pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -57026,7 +57209,7 @@ var ts; // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors); + return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* CheckMode.Normal */), declaration, reportErrors); } function isGlobalSymbolConstructor(node) { var symbol = getSymbolOfNode(node); @@ -57036,14 +57219,14 @@ var ts; function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol` - if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { type = getESSymbolLikeTypeForNode(declaration); } if (reportErrors) { reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -57060,7 +57243,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 164 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(node) { @@ -57084,14 +57267,14 @@ var ts; } function getTypeOfVariableOrParameterOrPropertyWorker(symbol) { // Handle prototype property - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return getTypeOfPrototypeProperty(symbol); } // CommonsJS require and module both have type any. if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { + if (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); var result = createSymbol(fileSymbol.flags, "exports"); result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; @@ -57132,15 +57315,15 @@ var ts; return getTypeOfAccessors(symbol); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 271 /* ExportAssignment */) { + if (declaration.kind === 271 /* SyntaxKind.ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -57159,7 +57342,7 @@ var ts; || ts.isMethodSignature(declaration) || ts.isSourceFile(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } type = ts.isBinaryExpression(declaration.parent) ? @@ -57173,10 +57356,10 @@ var ts; type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration); } else if (ts.isShorthandPropertyAssignment(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* CheckMode.Normal */); } else if (ts.isObjectLiteralMethod(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* CheckMode.Normal */); } else if (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration) @@ -57199,7 +57382,7 @@ var ts; } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -57208,7 +57391,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -57233,11 +57416,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); // We try to resolve a getter type annotation, a setter type annotation, or a getter function // body return type inference, in that order. var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || @@ -57272,10 +57455,10 @@ var ts; function getWriteTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.writeType) { - if (!pushTypeResolution(symbol, 8 /* WriteType */)) { + if (!pushTypeResolution(symbol, 8 /* TypeSystemPropertyName.WriteType */)) { return errorType; } - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); var writeType = getAnnotatedAccessorType(setter); if (!popTypeResolution()) { if (getAnnotatedAccessorTypeNode(setter)) { @@ -57290,8 +57473,8 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : - baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + return baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeFlags.TypeVariable */); }) : undefined; } function getTypeOfFuncClassEnumModule(symbol) { @@ -57312,21 +57495,21 @@ var ts; } function getTypeOfFuncClassEnumModuleWorker(symbol) { var declaration = symbol.valueDeclaration; - if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 221 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 221 /* BinaryExpression */)) { + declaration.parent.kind === 221 /* SyntaxKind.BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } - else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { + else if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { var resolvedModule = resolveExternalModuleSymbol(symbol); if (resolvedModule !== symbol) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */)); + var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)); var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule); if (!popTypeResolution()) { return reportCircularityError(symbol); @@ -57334,13 +57517,13 @@ var ts; return type_3; } } - var type = createObjectType(16 /* Anonymous */, symbol); - if (symbol.flags & 32 /* Class */) { + var type = createObjectType(16 /* ObjectFlags.Anonymous */, symbol); + if (symbol.flags & 32 /* SymbolFlags.Class */) { var baseTypeVariable = getBaseTypeVariableOfClass(symbol); return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type; + return strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ ? getOptionalType(type) : type; } } function getTypeOfEnumMember(symbol) { @@ -57361,7 +57544,7 @@ var ts; links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType - : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } return links.type; @@ -57382,7 +57565,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 164 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 164 /* SyntaxKind.Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -57395,7 +57578,7 @@ var ts; if (!links.type) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); } return links.type; } @@ -57404,7 +57587,7 @@ var ts; if (!links.writeType && links.deferralWriteConstituents) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); + links.writeType = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); } return links.writeType; } @@ -57415,15 +57598,15 @@ var ts; */ function getWriteTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (symbol.flags & 4 /* Property */) { - return checkFlags & 2 /* SyntheticProperty */ ? - checkFlags & 65536 /* DeferredType */ ? + if (symbol.flags & 4 /* SymbolFlags.Property */) { + return checkFlags & 2 /* CheckFlags.SyntheticProperty */ ? + checkFlags & 65536 /* CheckFlags.DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : symbol.writeType || symbol.type : getTypeOfSymbol(symbol); } - if (symbol.flags & 98304 /* Accessor */) { - return checkFlags & 1 /* Instantiated */ ? + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { + return checkFlags & 1 /* CheckFlags.Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol); } @@ -57431,56 +57614,56 @@ var ts; } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (checkFlags & 65536 /* DeferredType */) { + if (checkFlags & 65536 /* CheckFlags.DeferredType */) { return getTypeOfSymbolWithDeferredType(symbol); } - if (checkFlags & 1 /* Instantiated */) { + if (checkFlags & 1 /* CheckFlags.Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (checkFlags & 262144 /* Mapped */) { + if (checkFlags & 262144 /* CheckFlags.Mapped */) { return getTypeOfMappedSymbol(symbol); } - if (checkFlags & 8192 /* ReverseMapped */) { + if (checkFlags & 8192 /* CheckFlags.ReverseMapped */) { return getTypeOfReverseMappedSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & 98304 /* Accessor */) { + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getTypeOfAlias(symbol); } return errorType; } function getNonMissingTypeOfSymbol(symbol) { - return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* SymbolFlags.Optional */)); } function isReferenceToType(type, target) { return type !== undefined && target !== undefined - && (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + && (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getTargetType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target : type; } // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { - if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, check); } return false; @@ -57503,7 +57686,7 @@ var ts; if (node && ts.isBinaryExpression(node)) { // prototype assignments get the outer type parameters of their constructor function var assignmentKind = ts.getAssignmentDeclarationKind(node); - if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { var symbol = getSymbolOfNode(node.left); if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { node = symbol.parent.valueDeclaration; @@ -57514,46 +57697,46 @@ var ts; return undefined; } switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: - case 338 /* JSDocCallbackTag */: - case 195 /* MappedType */: - case 189 /* ConditionalType */: { + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 195 /* SyntaxKind.MappedType */: + case 189 /* SyntaxKind.ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 195 /* MappedType */) { + if (node.kind === 195 /* SyntaxKind.MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 189 /* ConditionalType */) { + else if (node.kind === 189 /* SyntaxKind.ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */ || node.kind === 258 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 320 /* JSDoc */: { + case 320 /* SyntaxKind.JSDoc */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -57564,7 +57747,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* SymbolFlags.Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -57577,9 +57760,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 257 /* ClassDeclaration */ || - node.kind === 226 /* ClassExpression */ || + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || + node.kind === 226 /* SyntaxKind.ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -57596,7 +57779,7 @@ var ts; // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single // rest parameter of type any[]. function isMixinConstructorType(type) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length === 1) { var s = signatures[0]; if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) { @@ -57607,10 +57790,10 @@ var ts; return false; } function isConstructorType(type) { - if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length > 0) { return true; } - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isMixinConstructorType(constraint); } @@ -57623,7 +57806,7 @@ var ts; function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); var isJavascript = ts.isInJSFile(location); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); + return ts.filter(getSignaturesOfType(type, 1 /* SignatureKind.Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); @@ -57646,7 +57829,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + if (!pushTypeResolution(type, 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */)) { return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -57654,7 +57837,7 @@ var ts; ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -57663,13 +57846,13 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = errorType; } - if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* TypeFlags.Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - if (baseConstructorType.flags & 262144 /* TypeParameter */) { + if (baseConstructorType.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(baseConstructorType); var ctorReturn = unknownType; if (constraint) { - var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + var ctorSig = getSignaturesOfType(constraint, 1 /* SignatureKind.Construct */); if (ctorSig[0]) { ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } @@ -57709,19 +57892,19 @@ var ts; return resolvedImplementsTypes; } function reportCircularBaseType(node, type) { - error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); } function getBaseTypes(type) { if (!type.baseTypesResolved) { - if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) { - if (type.objectFlags & 8 /* Tuple */) { + if (pushTypeResolution(type, 7 /* TypeSystemPropertyName.ResolvedBaseTypes */)) { + if (type.objectFlags & 8 /* ObjectFlags.Tuple */) { type.resolvedBaseTypes = [getTupleBaseType(type)]; } - else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (type.symbol.flags & 32 /* Class */) { + else if (type.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { + if (type.symbol.flags & 32 /* SymbolFlags.Class */) { resolveBaseTypesOfClass(type); } - if (type.symbol.flags & 64 /* Interface */) { + if (type.symbol.flags & 64 /* SymbolFlags.Interface */) { resolveBaseTypesOfInterface(type); } } @@ -57731,7 +57914,7 @@ var ts; if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 257 /* ClassDeclaration */ || declaration.kind === 258 /* InterfaceDeclaration */) { + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -57742,26 +57925,26 @@ var ts; return type.resolvedBaseTypes; } function getTupleBaseType(type) { - var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; }); + var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; }); return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly); } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); var baseType; var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; - if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && + if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } - else if (baseConstructorType.flags & 1 /* Any */) { + else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) { baseType = baseConstructorType; } else { @@ -57786,7 +57969,7 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); return type.resolvedBaseTypes = ts.emptyArray; } if (type.resolvedBaseTypes === ts.resolvingEmptyArray) { @@ -57811,7 +57994,7 @@ var ts; } // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getBaseConstraintOfType(type); if (constraint) { return isValidBaseType(constraint); @@ -57819,15 +58002,15 @@ var ts; } // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? // There's no reason a `T` should be allowed while a `Readonly` should not. - return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType)); + return !!(type.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 1 /* TypeFlags.Any */) && !isGenericMappedType(type) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isValidBaseType)); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; if (type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -57867,8 +58050,8 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */) { - if (declaration.flags & 128 /* ContainsThis */) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { + if (declaration.flags & 128 /* NodeFlags.ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -57876,8 +58059,8 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + var baseSymbol = resolveEntityName(node.expression, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* SymbolFlags.Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } } @@ -57891,7 +58074,7 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; + var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */; var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol @@ -57905,8 +58088,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isThislessInterface(symbol)) { - type.objectFlags |= 4 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) { + type.objectFlags |= 4 /* ObjectFlags.Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -57927,7 +58110,7 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + if (!pushTypeResolution(symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { return errorType; } var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found"); @@ -57946,11 +58129,11 @@ var ts; } else { type = errorType; - if (declaration.kind === 339 /* JSDocEnumTag */) { + if (declaration.kind === 339 /* SyntaxKind.JSDocEnumTag */) { error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } } links.declaredType = type; @@ -57961,7 +58144,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 221 /* BinaryExpression */) { + else if (expr.kind === 221 /* SyntaxKind.BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -57969,19 +58152,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 16777216 /* Ambient */); + return !(member.flags & 16777216 /* NodeFlags.Ambient */); } switch (expr.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; - case 79 /* Identifier */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; + case 79 /* SyntaxKind.Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -57996,11 +58179,11 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { - return links.enumKind = 1 /* Literal */; + return links.enumKind = 1 /* EnumKind.Literal */; } if (!isLiteralEnumMember(member)) { hasNonLiteralMember = true; @@ -58009,23 +58192,23 @@ var ts; } } } - return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; + return links.enumKind = hasNonLiteralMember ? 0 /* EnumKind.Numeric */ : 1 /* EnumKind.Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (links.declaredType) { return links.declaredType; } - if (getEnumKind(symbol) === 1 /* Literal */) { + if (getEnumKind(symbol) === 1 /* EnumKind.Literal */) { enumCount++; var memberTypeList = []; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -58037,15 +58220,15 @@ var ts; } } if (memberTypeList.length) { - var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 1048576 /* Union */) { - enumType_1.flags |= 1024 /* EnumLiteral */; + var enumType_1 = getUnionType(memberTypeList, 1 /* UnionReduction.Literal */, symbol, /*aliasTypeArguments*/ undefined); + if (enumType_1.flags & 1048576 /* TypeFlags.Union */) { + enumType_1.flags |= 1024 /* TypeFlags.EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(32 /* Enum */); + var enumType = createType(32 /* TypeFlags.Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -58071,22 +58254,22 @@ var ts; return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getDeclaredTypeOfEnumMember(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getDeclaredTypeOfAlias(symbol); } return undefined; @@ -58098,22 +58281,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 196 /* LiteralType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 196 /* SyntaxKind.LiteralType */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isThislessType(node.elementType); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -58139,7 +58322,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 171 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 171 /* SyntaxKind.Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -58155,14 +58338,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -58199,8 +58382,8 @@ var ts; type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; type.declaredIndexInfos = ts.emptyArray; - type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); - type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); + type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* InternalSymbolName.Call */)); + type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* InternalSymbolName.New */)); type.declaredIndexInfos = getIndexInfosOfSymbol(symbol); } return type; @@ -58209,7 +58392,7 @@ var ts; * Indicates whether a type can be used as a property name. */ function isTypeUsableAsPropertyName(type) { - return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -58228,9 +58411,9 @@ var ts; && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) === 64 /* at */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) === 64 /* CharacterCodes.at */; } /** * Indicates whether a declaration has a late-bindable dynamic name. @@ -58255,10 +58438,10 @@ var ts; * Gets the symbolic name for a member from its type. */ function getPropertyNameFromType(type) { - if (type.flags & 8192 /* UniqueESSymbol */) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { return type.escapedName; } - if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -58269,7 +58452,7 @@ var ts; * members. */ function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { - ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol."); + ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { @@ -58278,7 +58461,7 @@ var ts; else if (!member.symbol.isReplaceableByMethod) { symbol.declarations.push(member); } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -58327,7 +58510,7 @@ var ts; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. var lateSymbol = lateSymbols.get(memberName); if (!lateSymbol) - lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */)); + lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. @@ -58336,10 +58519,10 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_5 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); + var name_5 = !(type.flags & 8192 /* TypeFlags.UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_5); }); error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_5); - lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); + lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */); } lateSymbol.nameType = type; addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); @@ -58357,9 +58540,9 @@ var ts; function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) { var links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */; + var isStatic_1 = resolutionKind === "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */; var earlySymbols = !isStatic_1 ? symbol.members : - symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModuleWorker(symbol) : symbol.exports; // In the event we recursively resolve the members/exports of the symbol, we // set the initial value of resolvedMembers/resolvedExports to the early-bound @@ -58385,10 +58568,10 @@ var ts; for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { var member = decls_1[_c]; var assignmentKind = ts.getAssignmentDeclarationKind(member); - var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + var isInstanceMember = assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */ || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) - || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ - || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + || assignmentKind === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */; // A straight `Prototype` assignment probably can never have a computed name if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } @@ -58404,8 +58587,8 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ - ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ + ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* MembersOrExportsResolutionKind.resolvedMembers */) : symbol.members || emptySymbols; } /** @@ -58415,7 +58598,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol) { - if (symbol.flags & 106500 /* ClassMember */ && symbol.escapedName === "__computed" /* Computed */) { + if (symbol.flags & 106500 /* SymbolFlags.ClassMember */ && symbol.escapedName === "__computed" /* InternalSymbolName.Computed */) { var links = getSymbolLinks(symbol); if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol @@ -58432,7 +58615,7 @@ var ts; return symbol; } function getTypeWithThisArgument(type, thisArgument, needApparentType) { - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { var target = type.target; var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { @@ -58440,7 +58623,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }); return types !== type.types ? getIntersectionType(types) : type; } @@ -58476,8 +58659,8 @@ var ts; var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* SignatureKind.Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* SignatureKind.Construct */)); var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)]; indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); })); } @@ -58512,7 +58695,7 @@ var ts; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; result.compositeSignatures = sig.compositeSignatures; @@ -58522,24 +58705,24 @@ var ts; function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); result.compositeSignatures = unionSignatures; - result.compositeKind = 1048576 /* Union */; + result.compositeKind = 1048576 /* TypeFlags.Union */; result.target = undefined; result.mapper = undefined; return result; } function getOptionalCallSignature(signature, callChainFlags) { - if ((signature.flags & 24 /* CallChainFlags */) === callChainFlags) { + if ((signature.flags & 24 /* SignatureFlags.CallChainFlags */) === callChainFlags) { return signature; } if (!signature.optionalCallSignatureCache) { signature.optionalCallSignatureCache = {}; } - var key = callChainFlags === 8 /* IsInnerCallChain */ ? "inner" : "outer"; + var key = callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ ? "inner" : "outer"; return signature.optionalCallSignatureCache[key] || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags)); } function createOptionalCallSignature(signature, callChainFlags) { - ts.Debug.assert(callChainFlags === 8 /* IsInnerCallChain */ || callChainFlags === 16 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); + ts.Debug.assert(callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ || callChainFlags === 16 /* SignatureFlags.IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); var result = cloneSignature(signature); result.flags |= callChainFlags; return result; @@ -58551,7 +58734,7 @@ var ts; if (isTupleType(restType)) { return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)]; } - else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && ts.every(restType.types, isTupleType)) { + else if (!skipUnionExpanding && restType.flags & 1048576 /* TypeFlags.Union */ && ts.every(restType.types, isTupleType)) { return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); }); } } @@ -58564,10 +58747,10 @@ var ts; var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]); var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType); var flags = restType.target.elementFlags[i]; - var checkFlags = flags & 12 /* Variable */ ? 32768 /* RestParameter */ : - flags & 2 /* Optional */ ? 16384 /* OptionalParameter */ : 0; - var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); - symbol.type = flags & 4 /* Rest */ ? createArrayType(t) : t; + var checkFlags = flags & 12 /* ElementFlags.Variable */ ? 32768 /* CheckFlags.RestParameter */ : + flags & 2 /* ElementFlags.Optional */ ? 16384 /* CheckFlags.OptionalParameter */ : 0; + var symbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, name, checkFlags); + symbol.type = flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t; return symbol; }); return ts.concatenate(sig.parameters.slice(0, restIndex), restParams); @@ -58575,11 +58758,11 @@ var ts; } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol); - var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* Abstract */); + var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* Abstract */ : 0 /* None */)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* SignatureFlags.Abstract */ : 0 /* SignatureFlags.None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -58594,7 +58777,7 @@ var ts; var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; - sig.flags = isAbstract ? sig.flags | 4 /* Abstract */ : sig.flags & ~4 /* Abstract */; + sig.flags = isAbstract ? sig.flags | 4 /* SignatureFlags.Abstract */ : sig.flags & ~4 /* SignatureFlags.Abstract */; result.push(sig); } } @@ -58757,12 +58940,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -58784,11 +58967,11 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 1048576 /* Union */; - result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 1048576 /* TypeFlags.Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -58813,8 +58996,8 @@ var ts; function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); })); - var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* SignatureKind.Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */); })); var indexInfos = getUnionIndexInfos(type.types); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos); } @@ -58822,7 +59005,7 @@ var ts; return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } function findMixins(types) { - var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; }); + var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */).length > 0; }); var mixinFlags = ts.map(types, isMixinConstructorType); if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) { var firstMixinIndex = mixinFlags.indexOf(/*searchElement*/ true); @@ -58837,7 +59020,7 @@ var ts; mixedTypes.push(type); } else if (mixinFlags[i]) { - mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* SignatureKind.Construct */)[0])); } } return getIntersectionType(mixedTypes); @@ -58859,7 +59042,7 @@ var ts; // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature // 'new(s: string) => A & B'. if (!mixinFlags[i]) { - var signatures = getSignaturesOfType(t, 1 /* Construct */); + var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */); if (signatures.length && mixinCount > 0) { signatures = ts.map(signatures, function (s) { var clone = cloneSignature(s); @@ -58869,7 +59052,7 @@ var ts; } constructSignatures = appendSignatures(constructSignatures, signatures); } - callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */)); indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos); }; for (var i = 0; i < types.length; i++) { @@ -58908,18 +59091,18 @@ var ts; if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); - var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* SignatureKind.Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* SignatureKind.Construct */), type.mapper); var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper); setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1); return; } var symbol = getMergedSymbol(type.symbol); - if (symbol.flags & 2048 /* TypeLiteral */) { + if (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_7 = getMembersOfSymbol(symbol); - var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */)); - var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */)); + var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* InternalSymbolName.Call */)); + var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* InternalSymbolName.New */)); var indexInfos_2 = getIndexInfosOfSymbol(symbol); setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2); return; @@ -58933,7 +59116,7 @@ var ts; var varsOnly_1 = new ts.Map(); members.forEach(function (p) { var _a; - if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { + if (!(p.flags & 418 /* SymbolFlags.BlockScoped */) && !(p.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { varsOnly_1.set(p.escapedName, p); } }); @@ -58942,10 +59125,10 @@ var ts; } var baseConstructorIndexInfo; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 8650752 /* TypeFlags.TypeVariable */)) { members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -58961,8 +59144,8 @@ var ts; if (baseConstructorIndexInfo) { indexInfos = ts.append(indexInfos, baseConstructorIndexInfo); } - if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* TypeFlags.Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* TypeFlags.NumberLike */); }))) { indexInfos = ts.append(indexInfos, enumNumberIndexInfo); } } @@ -58971,16 +59154,16 @@ var ts; // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list // will never be observed because a qualified name can't reference signatures. - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } // And likewise for construct signatures for classes - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; - if (symbol.flags & 16 /* Function */) { + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* InternalSymbolName.Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* SymbolFlags.Function */) { constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? - createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) : + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */) : undefined; })); } if (!constructSignatures.length) { @@ -58998,20 +59181,20 @@ var ts; function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, stringType); var modifiers = getMappedTypeModifiers(type.mappedType); - var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; - var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; + var readonlyMask = modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? false : true; + var optionalMask = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 0 : 16777216 /* SymbolFlags.Optional */; var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; - var checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0); - var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); + var checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* CheckFlags.Readonly */ : 0); + var inferredProp = createSymbol(4 /* SymbolFlags.Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ - && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ - && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) { + if (type.constraintType.type.flags & 8388608 /* TypeFlags.IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeFlags.TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* TypeFlags.TypeParameter */) { // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of // type identities produced, we simplify such indexed access occurences @@ -59032,11 +59215,11 @@ var ts; // bound includes those keys that are known to always be present, for example because // because of constraints on type parameters (e.g. 'keyof T' for a constrained T). function getLowerBoundOfKeyType(type) { - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var t = getApparentType(type.type); return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { if (type.root.isDistributive) { var checkType = type.checkType; var constraint = getLowerBoundOfKeyType(checkType); @@ -59046,29 +59229,29 @@ var ts; } return type; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getLowerBoundOfKeyType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType)); } return type; } function getIsLateCheckFlag(s) { - return ts.getCheckFlags(s) & 4096 /* Late */; + return ts.getCheckFlags(s) & 4096 /* CheckFlags.Late */; } function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; cb(getLiteralTypeFromProperty(prop, include)); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { cb(stringType); } else { for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) { var info = _c[_b]; - if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + if (!stringsOnly || info.keyType.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { cb(info.keyType); } } @@ -59088,7 +59271,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* TypeFlags.StringLiteral */ : 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType); @@ -59116,13 +59299,13 @@ var ts; } else { var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined; - var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || - !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); - var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || - !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); - var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; + var isOptional = !!(templateModifiers & 4 /* MappedTypeModifiers.IncludeOptional */ || + !(templateModifiers & 8 /* MappedTypeModifiers.ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */); + var isReadonly = !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ || + !(templateModifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); + var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */; var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0; - var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, lateFlag | 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); + var prop = createSymbol(4 /* SymbolFlags.Property */ | (isOptional ? 16777216 /* SymbolFlags.Optional */ : 0), propName, lateFlag | 262144 /* CheckFlags.Mapped */ | (isReadonly ? 8 /* CheckFlags.Readonly */ : 0) | (stripOptional ? 524288 /* CheckFlags.StripOptional */ : 0)); prop.mappedType = type; prop.nameType = propNameType; prop.keyType = keyType; @@ -59135,12 +59318,12 @@ var ts; members.set(propName, prop); } } - else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) { - var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : - propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : + else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* TypeFlags.Any */ | 32 /* TypeFlags.Enum */)) { + var indexKeyType = propNameType.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */) ? stringType : + propNameType.flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */) ? numberType : propNameType; var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); - var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */)); indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true); } } @@ -59148,7 +59331,7 @@ var ts; function getTypeOfMappedSymbol(symbol) { if (!symbol.type) { var mappedType = symbol.mappedType; - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { mappedType.containsError = true; return errorType; } @@ -59158,8 +59341,8 @@ var ts; // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. - var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : + var type = strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + symbol.checkFlags & 524288 /* CheckFlags.StripOptional */ ? removeMissingOrUndefinedType(propType) : propType; if (!popTypeResolution()) { error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); @@ -59185,7 +59368,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -59193,8 +59376,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 193 /* TypeOperator */ && - constraintDeclaration.operator === 140 /* KeyOfKeyword */; + return constraintDeclaration.kind === 193 /* SyntaxKind.TypeOperator */ && + constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -59210,20 +59393,20 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* SyntaxKind.MinusToken */ ? 8 /* MappedTypeModifiers.ExcludeOptional */ : 4 /* MappedTypeModifiers.IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); - return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0; + return modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? -1 : modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 1 : 0; } function getCombinedMappedTypeOptionality(type) { var optionality = getMappedTypeOptionality(type); @@ -59231,42 +59414,48 @@ var ts; return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0); } function isPartialMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */); } function isGenericMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 524288 /* Object */) { - if (type.objectFlags & 4 /* Reference */) { + if (type.flags & 524288 /* TypeFlags.Object */) { + if (type.objectFlags & 4 /* ObjectFlags.Reference */) { resolveTypeReferenceMembers(type); } - else if (type.objectFlags & 3 /* ClassOrInterface */) { + else if (type.objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 1024 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { resolveReverseMappedTypeMembers(type); } - else if (type.objectFlags & 16 /* Anonymous */) { + else if (type.objectFlags & 16 /* ObjectFlags.Anonymous */) { resolveAnonymousTypeMembers(type); } - else if (type.objectFlags & 32 /* Mapped */) { + else if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { resolveMappedTypeMembers(type); } + else { + ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags)); + } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { resolveIntersectionTypeMembers(type); } + else { + ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags)); + } } return type; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -59275,7 +59464,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -59299,7 +59488,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type without index signature - if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) { + if (type.flags & 1048576 /* TypeFlags.Union */ && getIndexInfosOfType(current).length === 0) { break; } } @@ -59309,13 +59498,13 @@ var ts; } function getPropertiesOfType(type) { type = getReducedApparentType(type); - return type.flags & 3145728 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function forEachPropertyOfType(type, action) { type = getReducedApparentType(type); - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) { if (isNamedMember(symbol, escapedName)) { action(symbol, escapedName); @@ -59334,7 +59523,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 1048576 /* Union */)) { + if (!(unionType.flags & 1048576 /* TypeFlags.Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -59353,9 +59542,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -59416,7 +59605,7 @@ var ts; var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint && constraint !== type.checkType) { var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); - if (!(instantiated.flags & 131072 /* Never */)) { + if (!(instantiated.flags & 131072 /* TypeFlags.Never */)) { return instantiated; } } @@ -59434,11 +59623,11 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { var t = types_5[_i]; - if (t.flags & 465829888 /* Instantiable */) { + if (t.flags & 465829888 /* TypeFlags.Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { @@ -59448,7 +59637,7 @@ var ts; } } } - else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) { + else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */ || isEmptyAnonymousObjectType(t)) { hasDisjointDomainType = true; } } @@ -59460,21 +59649,22 @@ var ts; // intersection operation to reduce the union constraints. for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { var t = types_6[_a]; - if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) { + if (t.flags & 469892092 /* TypeFlags.DisjointDomains */ || isEmptyAnonymousObjectType(t)) { constraints = ts.append(constraints, t); } } } - return getIntersectionType(constraints); + // The source types were normalized; ensure the result is normalized too. + return getNormalizedType(getIntersectionType(constraints), /*writing*/ false); } return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { + if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -59499,7 +59689,7 @@ var ts; return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t) { if (!t.immediateBaseConstraint) { - if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) { + if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) { return circularConstraintType; } var result = void 0; @@ -59516,7 +59706,7 @@ var ts; stack.pop(); } if (!popTypeResolution()) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var errorNode = getConstraintDeclaration(t); if (errorNode) { var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t)); @@ -59536,13 +59726,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 3145728 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = t.types; var baseTypes = []; var different = false; @@ -59562,23 +59752,23 @@ var ts; if (!different) { return t; } - return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* TypeFlags.Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* TypeFlags.Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 4194304 /* Index */) { + if (t.flags & 4194304 /* TypeFlags.Index */) { return keyofConstraintType; } - if (t.flags & 134217728 /* TemplateLiteral */) { + if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var types = t.types; var constraints = ts.mapDefined(types, getBaseConstraint); return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType; } - if (t.flags & 268435456 /* StringMapping */) { + if (t.flags & 268435456 /* TypeFlags.StringMapping */) { var constraint = getBaseConstraint(t.type); return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType; } - if (t.flags & 8388608 /* IndexedAccess */) { + if (t.flags & 8388608 /* TypeFlags.IndexedAccess */) { if (isMappedTypeGenericIndexedAccess(t)) { // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic, // we substitute an instantiation of E where P is replaced with X. @@ -59589,11 +59779,11 @@ var ts; var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } - if (t.flags & 16777216 /* Conditional */) { + if (t.flags & 16777216 /* TypeFlags.Conditional */) { var constraint = getConstraintFromConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 33554432 /* Substitution */) { + if (t.flags & 33554432 /* TypeFlags.Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -59660,9 +59850,9 @@ var ts; } function isMappedTypeGenericIndexedAccess(type) { var objectType; - return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && + return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && - !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType); + !(getMappedTypeModifiers(objectType) & 8 /* MappedTypeModifiers.ExcludeOptional */) && !objectType.declaration.nameType); } /** * For a type parameter, return the base constraint of the type parameter. For the string, number, @@ -59670,17 +59860,17 @@ var ts; * type itself. */ function getApparentType(type) { - var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; - return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 402653316 /* StringLike */ ? globalStringType : - t.flags & 296 /* NumberLike */ ? globalNumberType : - t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : - t.flags & 528 /* BooleanLike */ ? globalBooleanType : - t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : - t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : - t.flags & 4194304 /* Index */ ? keyofConstraintType : - t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : + var t = !(type.flags & 465829888 /* TypeFlags.Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; + return ts.getObjectFlags(t) & 32 /* ObjectFlags.Mapped */ ? getApparentTypeOfMappedType(t) : + t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType : + t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType : + t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType() : + t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType : + t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType() : + t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType : + t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : + t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType : t; } function getReducedApparentType(type) { @@ -59695,21 +59885,21 @@ var ts; var singleProp; var propSet; var indexTypes; - var isUnion = containingType.flags & 1048576 /* Union */; + var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */; // Flags we want to propagate to the result if they exist in all source symbols - var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; - var syntheticFlag = 4 /* SyntheticMethod */; - var checkFlags = isUnion ? 0 : 8 /* Readonly */; + var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */; + var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */; + var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */; var mergedInstantiations = false; for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { var current = _c[_i]; var type = getApparentType(current); - if (!(isErrorType(type) || type.flags & 131072 /* Never */)) { + if (!(isErrorType(type) || type.flags & 131072 /* TypeFlags.Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop) { if (isUnion) { - optionalFlag |= (prop.flags & 16777216 /* Optional */); + optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */); } else { optionalFlag &= prop.flags; @@ -59722,7 +59912,7 @@ var ts; // If the symbols are instances of one another with identical types - consider the symbols // equivalent and just use the first one, which thus allows us to avoid eliding private // members when intersecting a (this-)instantiations of a class with it's raw base or another instance - if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) { + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) { // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` @@ -59740,41 +59930,41 @@ var ts; } } if (isUnion && isReadonlySymbol(prop)) { - checkFlags |= 8 /* Readonly */; + checkFlags |= 8 /* CheckFlags.Readonly */; } else if (!isUnion && !isReadonlySymbol(prop)) { - checkFlags &= ~8 /* Readonly */; + checkFlags &= ~8 /* CheckFlags.Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) ? 256 /* CheckFlags.ContainsPublic */ : 0) | + (modifiers & 16 /* ModifierFlags.Protected */ ? 512 /* CheckFlags.ContainsProtected */ : 0) | + (modifiers & 8 /* ModifierFlags.Private */ ? 1024 /* CheckFlags.ContainsPrivate */ : 0) | + (modifiers & 32 /* ModifierFlags.Static */ ? 2048 /* CheckFlags.ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { - syntheticFlag = 2 /* SyntheticProperty */; + syntheticFlag = 2 /* CheckFlags.SyntheticProperty */; } } else if (isUnion) { var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name); if (indexInfo) { - checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); + checkFlags |= 32 /* CheckFlags.WritePartial */ | (indexInfo.isReadonly ? 8 /* CheckFlags.Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ContainsSpread */)) { - checkFlags |= 32 /* WritePartial */; + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ObjectFlags.ContainsSpread */)) { + checkFlags |= 32 /* CheckFlags.WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } else { - checkFlags |= 16 /* ReadPartial */; + checkFlags |= 16 /* CheckFlags.ReadPartial */; } } } } - if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) { + if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) { // No property was found, or, in a union, a property has a private or protected declaration in one // constituent, but is missing or has a different declaration in another constituent. return undefined; } - if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { + if (!propSet && !(checkFlags & 16 /* CheckFlags.ReadPartial */) && !indexTypes) { if (mergedInstantiations) { // No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents) // Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!) @@ -59816,18 +60006,18 @@ var ts; writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType); } else if (type !== firstType) { - checkFlags |= 64 /* HasNonUniformType */; + checkFlags |= 64 /* CheckFlags.HasNonUniformType */; } if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) { - checkFlags |= 128 /* HasLiteralType */; + checkFlags |= 128 /* CheckFlags.HasLiteralType */; } - if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) { - checkFlags |= 131072 /* HasNeverType */; + if (type.flags & 131072 /* TypeFlags.Never */ && type !== uniqueLiteralType) { + checkFlags |= 131072 /* CheckFlags.HasNeverType */; } propTypes.push(type); } ts.addRange(propTypes, indexTypes); - var result = createSymbol(4 /* Property */ | optionalFlag, name, syntheticFlag | checkFlags); + var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags); result.containingType = containingType; if (!hasNonUniformValueDeclaration && firstValueDeclaration) { result.valueDeclaration = firstValueDeclaration; @@ -59840,7 +60030,7 @@ var ts; result.nameType = nameType; if (propTypes.length > 2) { // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed - result.checkFlags |= 65536 /* DeferredType */; + result.checkFlags |= 65536 /* CheckFlags.DeferredType */; result.deferralParent = containingType; result.deferralConstituents = propTypes; result.deferralWriteConstituents = writeTypes; @@ -59874,7 +60064,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) { var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment); // We need to filter out partial properties in union types - return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined; + return property && !(ts.getCheckFlags(property) & 16 /* CheckFlags.ReadPartial */) ? property : undefined; } /** * Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. @@ -59883,15 +60073,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 16777216 /* ContainsIntersections */) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } - else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 16777216 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 16777216 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* IsNeverIntersection */ : 0); + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { + if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) { + type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0); } - return type.objectFlags & 33554432 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type; } return type; } @@ -59901,7 +60091,7 @@ var ts; return unionType; } var reduced = getUnionType(reducedTypes); - if (reduced.flags & 1048576 /* Union */) { + if (reduced.flags & 1048576 /* TypeFlags.Union */) { reduced.resolvedReducedType = reduced; } return reduced; @@ -59912,23 +60102,23 @@ var ts; function isDiscriminantWithNeverType(prop) { // Return true for a synthetic non-optional property with non-uniform types, where at least one is // a literal type and none is never, that reduces to never. - return !(prop.flags & 16777216 /* Optional */) && - (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ && - !!(getTypeOfSymbol(prop).flags & 131072 /* Never */); + return !(prop.flags & 16777216 /* SymbolFlags.Optional */) && + (ts.getCheckFlags(prop) & (192 /* CheckFlags.Discriminant */ | 131072 /* CheckFlags.HasNeverType */)) === 192 /* CheckFlags.Discriminant */ && + !!(getTypeOfSymbol(prop).flags & 131072 /* TypeFlags.Never */); } function isConflictingPrivateProperty(prop) { // Return true for a synthetic property with multiple declarations, at least one of which is private. - return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); + return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* CheckFlags.ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 33554432 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(neverProp)); } var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty); if (privateProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(privateProp)); } } return errorInfo; @@ -59943,7 +60133,7 @@ var ts; */ function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment, includeTypeOnlyMembers) { type = getReducedApparentType(type); - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol, includeTypeOnlyMembers)) { @@ -59963,15 +60153,15 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + return kind === 0 /* SignatureKind.Call */ ? resolved.callSignatures : resolved.constructSignatures; } return ts.emptyArray; } @@ -60017,10 +60207,10 @@ var ts; // signature applies to types assignable to 'number', `${number}` and numeric string literal types. return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value)); + target === numberType && (source === numericStringType || !!(source.flags & 128 /* TypeFlags.StringLiteral */) && ts.isNumericLiteralName(source.value)); } function getIndexInfosOfStructuredType(type) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return resolved.indexInfos; } @@ -60052,12 +60242,15 @@ var ts; // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(declaration) { + var _a; var result; - for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) { - var node = _a[_i]; + for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) { + var node = _b[_i]; result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol)); } - return result; + return (result === null || result === void 0 ? void 0 : result.length) ? result + : ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters + : undefined; } function symbolsToArray(symbols) { var result = []; @@ -60071,17 +60264,17 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 316 /* JSDocOptionalType */ + node.type && node.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* SymbolFlags.ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -60096,7 +60289,7 @@ var ts; // Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used // in grammar checks and checking for `void` too early results in parameter types widening too early // and causes some noImplicitAny errors to be lost. - return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */); + return parameterIndex >= getMinArgumentCount(signature, 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */ | 2 /* MinArgumentCountFlags.VoidIsNonOptional */); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -60114,7 +60307,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -60163,7 +60356,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -60175,7 +60368,7 @@ var ts; !ts.hasJSDocParameterTags(declaration) && !ts.getJSDocType(declaration); if (isUntypedSignatureInJSFile) { - flags |= 32 /* IsUntypedSignatureInJSFile */; + flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */; } // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -60185,19 +60378,19 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature - if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); + if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) { + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } - if (i === 0 && paramSymbol.escapedName === "this" /* This */) { + if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) { hasThisParameter = true; thisParameter = param.symbol; } else { parameters.push(paramSymbol); } - if (type && type.kind === 196 /* LiteralType */) { - flags |= 2 /* HasLiteralTypes */; + if (type && type.kind === 196 /* SyntaxKind.LiteralType */) { + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || @@ -60209,25 +60402,25 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) && + if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 171 /* Constructor */ ? + var classType = declaration.kind === 171 /* SyntaxKind.Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } - if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* Abstract */) || - ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* Abstract */)) { - flags |= 4 /* Abstract */; + if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */) || + ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* ModifierFlags.Abstract */)) { + flags |= 4 /* SignatureFlags.Abstract */; } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); @@ -60249,7 +60442,7 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */); + var syntheticArgsSymbol = createSymbol(3 /* SymbolFlags.Variable */, "args", 32768 /* CheckFlags.RestParameter */); if (lastParamVariadicType) { // Parameter has effective annotation, lock in type syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)); @@ -60258,7 +60451,7 @@ var ts; // Parameter has no annotation // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been // cached by `getTypeOfSymbol` yet. - syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */; + syntheticArgsSymbol.checkFlags |= 65536 /* CheckFlags.DeferredType */; syntheticArgsSymbol.deferralParent = neverType; syntheticArgsSymbol.deferralConstituents = [anyArrayType]; syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType]; @@ -60291,7 +60484,7 @@ var ts; function containsArgumentsReference(declaration) { var links = getNodeLinks(declaration); if (links.containsArgumentsReference === undefined) { - if (links.flags & 8192 /* CaptureArguments */) { + if (links.flags & 8192 /* NodeCheckFlags.CaptureArguments */) { links.containsArgumentsReference = true; } else { @@ -60303,18 +60496,18 @@ var ts; if (!node) return false; switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return node.name.kind === 162 /* ComputedPropertyName */ + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && traverse(node.name); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return traverse(node.expression); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return traverse(node.initializer); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -60386,26 +60579,26 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 192 /* ThisType */ ? - createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : - createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); + return parameterName.kind === 192 /* SyntaxKind.ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* TypePredicateKind.AssertsThis */ : 0 /* TypePredicateKind.This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* TypePredicateKind.AssertsIdentifier */ : 1 /* TypePredicateKind.Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getUnionOrIntersectionType(types, kind, unionReduction) { - return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + return kind !== 2097152 /* TypeFlags.Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + if (!pushTypeResolution(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* UnionReduction.Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); - if (signature.flags & 8 /* IsInnerCallChain */) { + if (signature.flags & 8 /* SignatureFlags.IsInnerCallChain */) { type = addOptionalTypeMarker(type); } - else if (signature.flags & 16 /* IsOuterCallChain */) { + else if (signature.flags & 16 /* SignatureFlags.IsOuterCallChain */) { type = getOptionalType(type); } if (!popTypeResolution()) { @@ -60432,7 +60625,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 171 /* Constructor */) { + if (declaration.kind === 171 /* SyntaxKind.Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -60442,12 +60635,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 172 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SyntaxKind.SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -60456,7 +60649,7 @@ var ts; return getReturnTypeOfTypeTag(declaration); } function isResolvingReturnTypeOfSignature(signature) { - return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { return tryGetRestTypeOfSignature(signature) || anyType; @@ -60550,8 +60743,8 @@ var ts; if (!signature.isolatedSignatureType) { var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind; // If declaration is undefined, it is likely to be the signature of the default constructor. - var isConstructor = kind === undefined || kind === 171 /* Constructor */ || kind === 175 /* ConstructSignature */ || kind === 180 /* ConstructorType */; - var type = createObjectType(16 /* Anonymous */); + var isConstructor = kind === undefined || kind === 171 /* SyntaxKind.Constructor */ || kind === 175 /* SyntaxKind.ConstructSignature */ || kind === 180 /* SyntaxKind.ConstructorType */; + var type = createObjectType(16 /* ObjectFlags.Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; type.callSignatures = !isConstructor ? [signature] : ts.emptyArray; @@ -60565,7 +60758,7 @@ var ts; return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; } function getIndexSymbolFromSymbolTable(symbolTable) { - return symbolTable.get("__index" /* Index */); + return symbolTable.get("__index" /* InternalSymbolName.Index */); } function createIndexInfo(keyType, type, isReadonly, declaration) { return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration }; @@ -60583,7 +60776,7 @@ var ts; if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), function (keyType) { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) { - indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* ModifierFlags.Readonly */), declaration)); } }); } @@ -60598,8 +60791,8 @@ var ts; return ts.emptyArray; } function isValidIndexKeyType(type) { - return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || - !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); + return !!(type.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 4096 /* TypeFlags.ESSymbol */)) || isPatternLiteralType(type) || + !!(type.flags & 2097152 /* TypeFlags.Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -60608,21 +60801,20 @@ var ts; var _a; var inferences; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { - for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { - var declaration = _b[_i]; - if (declaration.parent.kind === 190 /* InferType */) { + var _loop_15 = function (declaration) { + if (declaration.parent.kind === 190 /* SyntaxKind.InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; - if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) { - var typeReference = grandParent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(childTypeParameter); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (grandParent.kind === 178 /* SyntaxKind.TypeReference */ && !omitTypeReferences) { + var typeReference_1 = grandParent; + var typeParameters_1 = getTypeParametersForTypeReference(typeReference_1); + if (typeParameters_1) { + var index = typeReference_1.typeArguments.indexOf(childTypeParameter); + if (index < typeParameters_1.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters_1[index]); if (declaredConstraint) { // Type parameter constraints can reference other type parameters so // constraints need to be instantiated. If instantiation produces the @@ -60630,7 +60822,9 @@ var ts; // type Foo = [T, U]; // type Bar = T extends Foo ? Foo : T; // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var mapper = makeDeferredTypeMapper(typeParameters_1, typeParameters_1.map(function (_, index) { return function () { + return getEffectiveTypeArgumentAtIndex(typeReference_1, typeParameters_1, index); + }; })); var constraint = instantiateType(declaredConstraint, mapper); if (constraint !== typeParameter) { inferences = ts.append(inferences, constraint); @@ -60641,33 +60835,37 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 164 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 186 /* RestType */ || - grandParent.kind === 197 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 164 /* SyntaxKind.Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 186 /* SyntaxKind.RestType */ || + grandParent.kind === 197 /* SyntaxKind.NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' // constraint. - else if (grandParent.kind === 199 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */) { inferences = ts.append(inferences, stringType); } // When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any' // constraint. - else if (grandParent.kind === 163 /* TypeParameter */ && grandParent.parent.kind === 195 /* MappedType */) { + else if (grandParent.kind === 163 /* SyntaxKind.TypeParameter */ && grandParent.parent.kind === 195 /* SyntaxKind.MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template // of the check type's mapped type - else if (grandParent.kind === 195 /* MappedType */ && grandParent.type && - ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* ConditionalType */ && - grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* MappedType */ && + else if (grandParent.kind === 195 /* SyntaxKind.MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* SyntaxKind.ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* SyntaxKind.MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); inferences = ts.append(inferences, instantiateType(nodeType, makeUnaryTypeMapper(getDeclaredTypeOfTypeParameter(getSymbolOfNode(checkMappedType_1.typeParameter)), checkMappedType_1.typeParameter.constraint ? getTypeFromTypeNode(checkMappedType_1.typeParameter.constraint) : keyofConstraintType))); } } + }; + for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + _loop_15(declaration); } } return inferences && getIntersectionType(inferences); @@ -60686,10 +60884,10 @@ var ts; } else { var type = getTypeFromTypeNode(constraintDeclaration); - if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed + if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 195 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -60698,7 +60896,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -60726,29 +60924,29 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type - // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // of an object literal or a non-inferrable type. This is because there are operations in the type checker // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - if (!(type.flags & excludeKinds)) { + if (excludeKinds === undefined || !(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } } - return result & 458752 /* PropagatingFlags */; + return result & 458752 /* ObjectFlags.PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations.get(id); if (!type) { - type = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); target.instantiations.set(id, type); - type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; + type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0; type.target = target; type.resolvedTypeArguments = typeArguments; } @@ -60768,7 +60966,7 @@ var ts; var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; } - var type = createObjectType(4 /* Reference */, target.symbol); + var type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; @@ -60779,13 +60977,13 @@ var ts; function getTypeArguments(type) { var _a, _b; if (!type.resolvedTypeArguments) { - if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) { + if (!pushTypeResolution(type, 6 /* TypeSystemPropertyName.ResolvedTypeArguments */)) { return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 178 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 178 /* SyntaxKind.TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -60820,14 +61018,14 @@ var ts; missingAugmentsTag ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; - var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); + var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) return errorType; } } - if (node.kind === 178 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -60858,12 +61056,12 @@ var ts; * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ function getTypeFromTypeAliasReference(node, symbol) { - if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) { + if (ts.getCheckFlags(symbol) & 1048576 /* CheckFlags.Unresolved */) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); var id = getAliasId(symbol, typeArguments); var errorType_1 = errorTypes.get(id); if (!errorType_1) { - errorType_1 = createIntrinsicType(1 /* Any */, "error"); + errorType_1 = createIntrinsicType(1 /* TypeFlags.Any */, "error"); errorType_1.aliasSymbol = symbol; errorType_1.aliasTypeArguments = typeArguments; errorTypes.set(id, errorType_1); @@ -60898,9 +61096,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -60912,21 +61110,21 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { - var identifier = name.kind === 161 /* QualifiedName */ ? name.right : - name.kind === 206 /* PropertyAccessExpression */ ? name.name : + var identifier = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? name.name : name; var text = identifier.escapedText; if (text) { - var parentSymbol = name.kind === 161 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : - name.kind === 206 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : + var parentSymbol = name.kind === 161 /* SyntaxKind.QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { - unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */)); + unresolvedSymbols.set(path, result = createSymbol(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */)); result.parent = parentSymbol; result.declaredType = unresolvedType; } @@ -60948,10 +61146,10 @@ var ts; return errorType; } symbol = getExpandoSymbol(symbol) || symbol; - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getTypeFromClassOrInterfaceReference(node, symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) @@ -60959,14 +61157,14 @@ var ts; if (res) { return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType; } - if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + if (symbol.flags & 111551 /* SymbolFlags.Value */ && isJSDocTypeReference(node)) { var jsdocType = getTypeFromJSDocValueReference(node, symbol); if (jsdocType) { return jsdocType; } else { // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(node, 788968 /* Type */); + resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */); return getTypeOfSymbol(symbol); } } @@ -60982,7 +61180,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 200 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 200 /* SyntaxKind.ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); @@ -60993,22 +61191,22 @@ var ts; return links.resolvedJSDocType; } function getSubstitutionType(baseType, substitute) { - if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) { + if (substitute.flags & 3 /* TypeFlags.AnyOrUnknown */ || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; } - var result = createType(33554432 /* Substitution */); + var result = createType(33554432 /* TypeFlags.Substitution */); result.baseType = baseType; result.substitute = substitute; substitutionTypes.set(id, result); return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 184 /* TupleType */ && node.elements.length === 1; + return node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -61018,16 +61216,16 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 320 /* JSDoc */) { + while (node && !ts.isStatement(node) && node.kind !== 320 /* SyntaxKind.JSDoc */) { var parent = node.parent; // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax - if (parent.kind === 164 /* Parameter */) { + if (parent.kind === 164 /* SyntaxKind.Parameter */) { covariant = !covariant; } // Always substitute on type parameters, regardless of variance, since even // in contravariant positions, they may rely on substituted constraints to be valid - if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 189 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeFlags.TypeVariable */) && parent.kind === 189 /* SyntaxKind.ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -61035,7 +61233,7 @@ var ts; } // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the // template type XXX, K has an added constraint of number | `${number}`. - else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 195 /* MappedType */ && node === parent.type) { + else if (type.flags & 262144 /* TypeFlags.TypeParameter */ && parent.kind === 195 /* SyntaxKind.MappedType */ && node === parent.type) { var mappedType = getTypeFromTypeNode(parent); if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { var typeParameter = getHomomorphicTypeVariable(mappedType); @@ -61052,7 +61250,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */); + return !!(node.flags & 8388608 /* NodeFlags.JSDoc */) && (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 200 /* SyntaxKind.ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -61108,7 +61306,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -61120,13 +61318,13 @@ var ts; } var symbol = void 0; var type = void 0; - var meaning = 788968 /* Type */; + var meaning = 788968 /* SymbolFlags.Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); if (!type) { symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true); if (symbol === unknownSymbol) { - symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */); + symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */); } else { resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any @@ -61167,9 +61365,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declaration; } } @@ -61179,7 +61377,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 524288 /* Object */)) { + if (!(type.flags & 524288 /* TypeFlags.Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -61190,13 +61388,13 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* SymbolFlags.Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalTypeAliasSymbol(name, arity, reportErrors) { - var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); if (symbol) { // Resolve the declared type of the symbol. This resolves type parameters for the type // alias so that we can check arity. @@ -61232,9 +61430,9 @@ var ts; function getGlobalImportMetaExpressionType() { if (!deferredGlobalImportMetaExpressionType) { // Create a synthetic type `ImportMetaExpression { meta: MetaProperty }` - var symbol = createSymbol(0 /* None */, "ImportMetaExpression"); + var symbol = createSymbol(0 /* SymbolFlags.None */, "ImportMetaExpression"); var importMetaType = getGlobalImportMetaType(); - var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */); + var metaPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "meta", 8 /* CheckFlags.Readonly */); metaPropertySymbol.parent = symbol; metaPropertySymbol.type = importMetaType; var members = ts.createSymbolTable([metaPropertySymbol]); @@ -61299,7 +61497,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -61337,20 +61535,20 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 185 /* OptionalType */: - return 2 /* Optional */; - case 186 /* RestType */: + case 185 /* SyntaxKind.OptionalType */: + return 2 /* ElementFlags.Optional */; + case 186 /* SyntaxKind.RestType */: return getRestTypeElementFlags(node); - case 197 /* NamedTupleMember */: - return node.questionToken ? 2 /* Optional */ : + case 197 /* SyntaxKind.NamedTupleMember */: + return node.questionToken ? 2 /* ElementFlags.Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + 1 /* ElementFlags.Required */; default: - return 1 /* Required */; + return 1 /* ElementFlags.Required */; } } function getRestTypeElementFlags(node) { - return getArrayElementTypeNode(node.type) ? 4 /* Rest */ : 8 /* Variadic */; + return getArrayElementTypeNode(node.type) ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */; } function getArrayOrTupleTargetType(node) { var readonly = isReadonlyTypeOperator(node.parent); @@ -61359,14 +61557,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* SyntaxKind.NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 184 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* SyntaxKind.ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 184 /* SyntaxKind.TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -61375,18 +61573,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 194 /* IndexedAccessType */: - case 189 /* ConditionalType */: - case 193 /* TypeOperator */: - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 189 /* SyntaxKind.ConditionalType */: + case 193 /* SyntaxKind.TypeOperator */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return isResolvedByTypeAlias(parent); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } return false; @@ -61395,28 +61593,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 178 /* TypeReference */: - return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 181 /* TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */).flags & 524288 /* SymbolFlags.TypeAlias */); + case 181 /* SyntaxKind.TypeQuery */: return true; - case 193 /* TypeOperator */: - return node.operator !== 154 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 197 /* NamedTupleMember */: - case 316 /* JSDocOptionalType */: - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 193 /* SyntaxKind.TypeOperator */: + return node.operator !== 154 /* SyntaxKind.UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 186 /* RestType */: - return node.type.kind !== 183 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 186 /* SyntaxKind.RestType */: + return node.type.kind !== 183 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -61429,33 +61627,33 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 184 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 184 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 184 /* SyntaxKind.TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* ElementFlags.Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 145 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } - var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* Required */; }), readonly, namedMemberDeclarations); + var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* ElementFlags.Required */; }), readonly, namedMemberDeclarations); return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget; } function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { - if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) { + if (elementFlags.length === 1 && elementFlags[0] & 4 /* ElementFlags.Rest */) { // [...X[]] is equivalent to just X[] return readonly ? globalReadonlyArrayType : globalArrayType; } - var key = ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*"; }).join() + + var key = ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? "#" : f & 2 /* ElementFlags.Optional */ ? "?" : f & 4 /* ElementFlags.Rest */ ? "." : "*"; }).join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : ""); var type = tupleTypes.get(key); @@ -61473,7 +61671,7 @@ var ts; // is true for each of the synthesized type parameters. function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { var arity = elementFlags.length; - var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* Required */ | 8 /* Variadic */)); }); + var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* ElementFlags.Required */ | 8 /* ElementFlags.Variadic */)); }); var typeParameters; var properties = []; var combinedFlags = 0; @@ -61483,8 +61681,8 @@ var ts; var typeParameter = typeParameters[i] = createTypeParameter(); var flags = elementFlags[i]; combinedFlags |= flags; - if (!(combinedFlags & 12 /* Variable */)) { - var property = createSymbol(4 /* Property */ | (flags & 2 /* Optional */ ? 16777216 /* Optional */ : 0), "" + i, readonly ? 8 /* Readonly */ : 0); + if (!(combinedFlags & 12 /* ElementFlags.Variable */)) { + var property = createSymbol(4 /* SymbolFlags.Property */ | (flags & 2 /* ElementFlags.Optional */ ? 16777216 /* SymbolFlags.Optional */ : 0), "" + i, readonly ? 8 /* CheckFlags.Readonly */ : 0); property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i]; property.type = typeParameter; properties.push(property); @@ -61492,8 +61690,8 @@ var ts; } } var fixedLength = properties.length; - var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0); - if (combinedFlags & 12 /* Variable */) { + var lengthSymbol = createSymbol(4 /* SymbolFlags.Property */, "length", readonly ? 8 /* CheckFlags.Readonly */ : 0); + if (combinedFlags & 12 /* ElementFlags.Variable */) { lengthSymbol.type = numberType; } else { @@ -61503,7 +61701,7 @@ var ts; lengthSymbol.type = getUnionType(literalTypes); } properties.push(lengthSymbol); - var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); + var type = createObjectType(8 /* ObjectFlags.Tuple */ | 4 /* ObjectFlags.Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -61521,26 +61719,26 @@ var ts; type.elementFlags = elementFlags; type.minLength = minLength; type.fixedLength = fixedLength; - type.hasRestElement = !!(combinedFlags & 12 /* Variable */); + type.hasRestElement = !!(combinedFlags & 12 /* ElementFlags.Variable */); type.combinedFlags = combinedFlags; type.readonly = readonly; type.labeledElementDeclarations = namedMemberDeclarations; return type; } function createNormalizedTypeReference(target, typeArguments) { - return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); + return target.objectFlags & 8 /* ObjectFlags.Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); } function createNormalizedTupleType(target, elementTypes) { var _a, _b, _c; - if (!(target.combinedFlags & 14 /* NonRequired */)) { + if (!(target.combinedFlags & 14 /* ElementFlags.NonRequired */)) { // No need to normalize when we only have regular required elements return createTypeReference(target, elementTypes); } - if (target.combinedFlags & 8 /* Variadic */) { + if (target.combinedFlags & 8 /* ElementFlags.Variadic */) { // Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z] - var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* ElementFlags.Variadic */ && t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex_1 >= 0) { - return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ? + return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : unknownType; })) ? mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) : errorType; } @@ -61556,13 +61754,13 @@ var ts; var lastRequiredIndex = -1; var firstRestIndex = -1; var lastOptionalOrRestIndex = -1; - var _loop_15 = function (i) { + var _loop_16 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; - if (flags & 8 /* Variadic */) { - if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) { + if (flags & 8 /* ElementFlags.Variadic */) { + if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type)) { // Generic variadic elements stay as they are. - addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + addElement(type, 8 /* ElementFlags.Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { var elements = getTypeArguments(type); @@ -61577,7 +61775,7 @@ var ts; } else { // Treat everything else as an array type and create a rest element. - addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); + addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* ElementFlags.Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); } } else { @@ -61586,18 +61784,18 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - var state_4 = _loop_15(i); + var state_4 = _loop_16(i); if (typeof state_4 === "object") return state_4.value; } // Turn optional elements preceding the last required element into required elements for (var i = 0; i < lastRequiredIndex; i++) { - if (expandedFlags[i] & 2 /* Optional */) - expandedFlags[i] = 1 /* Required */; + if (expandedFlags[i] & 2 /* ElementFlags.Optional */) + expandedFlags[i] = 1 /* ElementFlags.Required */; } if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) { // Turn elements between first rest and last optional/rest into a single rest element - expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; })); + expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; })); expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); @@ -61607,13 +61805,13 @@ var ts; expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget; function addElement(type, flags, declaration) { - if (flags & 1 /* Required */) { + if (flags & 1 /* ElementFlags.Required */) { lastRequiredIndex = expandedFlags.length; } - if (flags & 4 /* Rest */ && firstRestIndex < 0) { + if (flags & 4 /* ElementFlags.Rest */ && firstRestIndex < 0) { firstRestIndex = expandedFlags.length; } - if (flags & (2 /* Optional */ | 4 /* Rest */)) { + if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) { lastOptionalOrRestIndex = expandedFlags.length; } expandedTypes.push(type); @@ -61665,19 +61863,19 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 1048576 /* Union */) { - return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* Union */ : 0), type.types); + if (flags & 1048576 /* TypeFlags.Union */) { + return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* TypeFlags.Union */ : 0), type.types); } // We ignore 'never' types in unions - if (!(flags & 131072 /* Never */)) { - includes |= flags & 205258751 /* IncludesMask */; - if (flags & 465829888 /* Instantiable */) - includes |= 33554432 /* IncludesInstantiable */; + if (!(flags & 131072 /* TypeFlags.Never */)) { + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; + if (flags & 465829888 /* TypeFlags.Instantiable */) + includes |= 33554432 /* TypeFlags.IncludesInstantiable */; if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; - if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 65536 /* ContainsWideningType */)) - includes |= 4194304 /* IncludesNonWideningType */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; + if (!strictNullChecks && flags & 98304 /* TypeFlags.Nullable */) { + if (!(ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */)) + includes |= 4194304 /* TypeFlags.IncludesNonWideningType */; } else { var len = typeSet.length; @@ -61711,18 +61909,18 @@ var ts; // We assume that redundant primitive types have already been removed from the types array and that there // are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty // object types, and if none of those are present we can exclude primitive types from the subtype check. - var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); + var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); var len = types.length; var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (hasEmptyObject || source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { // Find the first property with a unit type, if any. When constituents have a property by the same name // but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype // reduction of large discriminated union types. - var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? + var keyProperty = source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : undefined; var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); @@ -61736,20 +61934,20 @@ var ts; // caps union types at 1000 unique object types. var estimatedCount = (count / (len - i)) * len; if (estimatedCount > 1000000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return undefined; } } count++; - if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (keyProperty && target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { continue; } } - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || + if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* ObjectFlags.Class */) || + !(ts.getObjectFlags(getTargetType(target)) & 1 /* ObjectFlags.Class */) || isTypeDerivedFrom(source, target))) { ts.orderedRemoveItemAt(types, i); break; @@ -61767,11 +61965,11 @@ var ts; i--; var t = types[i]; var flags = t.flags; - var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || - flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ || + flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ || + flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ || + flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ || + reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -61782,30 +61980,30 @@ var ts; var templates = ts.filter(types, isPatternLiteralType); if (templates.length) { var i = types.length; - var _loop_16 = function () { + var _loop_17 = function () { i--; var t = types[i]; - if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { + if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { ts.orderedRemoveItemAt(types, i); } }; while (i > 0) { - _loop_16(); + _loop_17(); } } } function isNamedUnionType(type) { - return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin)); + return !!(type.flags & 1048576 /* TypeFlags.Union */ && (type.aliasSymbol || type.origin)); } function addNamedUnions(namedUnions, types) { for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { var t = types_11[_i]; - if (t.flags & 1048576 /* Union */) { + if (t.flags & 1048576 /* TypeFlags.Union */) { var origin = t.origin; - if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { + if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* TypeFlags.Union */)) { ts.pushIfUnique(namedUnions, t); } - else if (origin && origin.flags & 1048576 /* Union */) { + else if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { addNamedUnions(namedUnions, origin.types); } } @@ -61824,7 +62022,7 @@ var ts; // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) { - if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } + if (unionReduction === void 0) { unionReduction = 1 /* UnionReduction.Literal */; } if (types.length === 0) { return neverType; } @@ -61833,48 +62031,48 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (unionReduction !== 0 /* None */) { - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? - includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : - includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; + if (unionReduction !== 0 /* UnionReduction.None */) { + if (includes & 3 /* TypeFlags.AnyOrUnknown */) { + return includes & 1 /* TypeFlags.Any */ ? + includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType : + includes & 65536 /* TypeFlags.Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; } - if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { + if (exactOptionalPropertyTypes && includes & 32768 /* TypeFlags.Undefined */) { var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { ts.orderedRemoveItemAt(typeSet, missingIndex); } } - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + if (includes & (2944 /* TypeFlags.Literal */ | 8192 /* TypeFlags.UniqueESSymbol */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* UnionReduction.Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* TypeFlags.StringLiteral */ && includes & 134217728 /* TypeFlags.TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (unionReduction === 2 /* Subtype */) { - typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (unionReduction === 2 /* UnionReduction.Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* TypeFlags.Object */)); if (!typeSet) { return errorType; } } if (typeSet.length === 0) { - return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : - includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 65536 /* TypeFlags.Null */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* TypeFlags.Undefined */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType; } } - if (!origin && includes & 1048576 /* Union */) { + if (!origin && includes & 1048576 /* TypeFlags.Union */) { var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; - var _loop_17 = function (t) { + var _loop_18 = function (t) { if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) { reducedTypes.push(t); } }; for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) { var t = typeSet_1[_i]; - _loop_17(t); + _loop_18(t); } if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) { return namedUnions[0]; @@ -61887,11 +62085,11 @@ var ts; var t = namedUnions_1[_a]; insertType(reducedTypes, t); } - origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); + origin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, reducedTypes); } } - var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 36323363 /* TypeFlags.NotPrimitiveUnion */ ? 0 : 32768 /* ObjectFlags.PrimitiveUnion */) | + (includes & 2097152 /* TypeFlags.Intersection */ ? 16777216 /* ObjectFlags.ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } function getUnionOrIntersectionTypePredicate(signatures, kind) { @@ -61900,8 +62098,8 @@ var ts; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { - if (kind !== 2097152 /* Intersection */) { + if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { + if (kind !== 2097152 /* TypeFlags.Intersection */) { continue; } else { @@ -61938,20 +62136,20 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving + origin.flags & 1048576 /* TypeFlags.Union */ ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 /* TypeFlags.Intersection */ ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { - type = createType(1048576 /* Union */); - type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* TypeFlags.Union */); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); type.types = types; type.origin = origin; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) { - type.flags |= 16 /* Boolean */; + if (types.length === 2 && types[0].flags & 512 /* TypeFlags.BooleanLiteral */ && types[1].flags & 512 /* TypeFlags.BooleanLiteral */) { + type.flags |= 16 /* TypeFlags.Boolean */; type.intrinsicName = "boolean"; } unionTypes.set(id, type); @@ -61962,41 +62160,41 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* UnionReduction.Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & 16777216 /* IncludesEmptyObject */)) { - includes |= 16777216 /* IncludesEmptyObject */; + if (!(includes & 16777216 /* TypeFlags.IncludesEmptyObject */)) { + includes |= 16777216 /* TypeFlags.IncludesEmptyObject */; typeSet.set(type.id.toString(), type); } } else { - if (flags & 3 /* AnyOrUnknown */) { + if (flags & 3 /* TypeFlags.AnyOrUnknown */) { if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; } - else if (strictNullChecks || !(flags & 98304 /* Nullable */)) { + else if (strictNullChecks || !(flags & 98304 /* TypeFlags.Nullable */)) { if (exactOptionalPropertyTypes && type === missingType) { - includes |= 262144 /* IncludesMissingType */; + includes |= 262144 /* TypeFlags.IncludesMissingType */; type = undefinedType; } if (!typeSet.has(type.id.toString())) { - if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { + if (type.flags & 109440 /* TypeFlags.Unit */ && includes & 109440 /* TypeFlags.Unit */) { // We have seen two distinct unit types which means we should reduce to an // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. - includes |= 67108864 /* NonPrimitive */; + includes |= 67108864 /* TypeFlags.NonPrimitive */; } typeSet.set(type.id.toString(), type); } } - includes |= flags & 205258751 /* IncludesMask */; + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; } return includes; } @@ -62014,12 +62212,12 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || - t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || - t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ || - isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */; + var remove = t.flags & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + t.flags & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + t.flags & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + t.flags & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */ || + t.flags & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */ || + isEmptyAnonymousObjectType(t) && includes & 470302716 /* TypeFlags.DefinitelyNonNullable */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -62032,10 +62230,10 @@ var ts; for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) { var u = unionTypes_1[_i]; if (!containsType(u.types, type)) { - var primitive = type.flags & 128 /* StringLiteral */ ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + var primitive = type.flags & 128 /* TypeFlags.StringLiteral */ ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : undefined; if (!primitive || !containsType(u.types, primitive)) { return false; @@ -62049,11 +62247,11 @@ var ts; */ function extractRedundantTemplateLiterals(types) { var i = types.length; - var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); }); + var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); }); while (i > 0) { i--; var t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */)) continue; for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) { var t2 = literals_1[_i]; @@ -62070,7 +62268,7 @@ var ts; return false; } function eachIsUnionContaining(types, flag) { - return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); + return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); } function removeFromEach(types, flag) { for (var i = 0; i < types.length; i++) { @@ -62082,7 +62280,7 @@ var ts; // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); }); if (index < 0) { return false; } @@ -62091,7 +62289,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -62120,12 +62318,12 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { - var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + var result = createType(2097152 /* TypeFlags.Intersection */); + result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -62154,37 +62352,37 @@ var ts; // a symbol-like type and a type known to be non-symbol-like, or // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. - if (includes & 131072 /* Never */) { + if (includes & 131072 /* TypeFlags.Never */) { return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; } - if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || - includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || - includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || - includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || - includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || - includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || - includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) || + includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) || + includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) || + includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) || + includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) || + includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) || + includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } - if (includes & 1 /* Any */) { - return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType; + if (includes & 1 /* TypeFlags.Any */) { + return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 98304 /* Nullable */) { - return includes & 32768 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) { + return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || - includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || - includes & 16384 /* Void */ && includes & 32768 /* Undefined */ || - includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) { + if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */ || + includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */ || + includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 470302716 /* TypeFlags.DefinitelyNonNullable */) { if (!noSupertypeReduction) removeRedundantSupertypes(typeSet, includes); } - if (includes & 262144 /* IncludesMissingType */) { + if (includes & 262144 /* TypeFlags.IncludesMissingType */) { typeSet[typeSet.indexOf(undefinedType)] = missingType; } if (typeSet.length === 0) { @@ -62196,21 +62394,21 @@ var ts; var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { - if (includes & 1048576 /* Union */) { + if (includes & 1048576 /* TypeFlags.Union */) { if (intersectUnionsOfPrimitiveTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) { + else if (eachIsUnionContaining(typeSet, 32768 /* TypeFlags.Undefined */)) { var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType; - removeFromEach(typeSet, 32768 /* Undefined */); - result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + removeFromEach(typeSet, 32768 /* TypeFlags.Undefined */); + result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) { - removeFromEach(typeSet, 65536 /* Null */); - result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + else if (eachIsUnionContaining(typeSet, 65536 /* TypeFlags.Null */)) { + removeFromEach(typeSet, 65536 /* TypeFlags.Null */); + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } else { // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of @@ -62223,8 +62421,8 @@ var ts; // We attach a denormalized origin type when at least one constituent of the cross-product union is an // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and // the denormalized origin has fewer constituents than the union itself. - var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined; - result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin); + var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* TypeFlags.Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* TypeFlags.Intersection */, typeSet) : undefined; + result = getUnionType(constituents, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments, origin); } } else { @@ -62235,12 +62433,12 @@ var ts; return result; } function getCrossProductUnionSize(types) { - return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* Union */ ? n * t.types.length : t.flags & 131072 /* Never */ ? 0 : n; }, 1); + return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* TypeFlags.Union */ ? n * t.types.length : t.flags & 131072 /* TypeFlags.Never */ ? 0 : n; }, 1); } function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return false; } @@ -62253,7 +62451,7 @@ var ts; var constituents = types.slice(); var n = i; for (var j = types.length - 1; j >= 0; j--) { - if (types[j].flags & 1048576 /* Union */) { + if (types[j].flags & 1048576 /* TypeFlags.Union */) { var sourceTypes = types[j].types; var length_5 = sourceTypes.length; constituents[j] = sourceTypes[n % length_5]; @@ -62261,14 +62459,14 @@ var ts; } } var t = getIntersectionType(constituents); - if (!(t.flags & 131072 /* Never */)) + if (!(t.flags & 131072 /* TypeFlags.Never */)) intersections.push(t); } return intersections; } function getConstituentCount(type) { - return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 : - type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) : + return !(type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) || type.aliasSymbol ? 1 : + type.flags & 1048576 /* TypeFlags.Union */ && type.origin ? getConstituentCount(type.origin) : getConstituentCountOfTypes(type.types); } function getConstituentCountOfTypes(types) { @@ -62279,19 +62477,19 @@ var ts; if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); var types = ts.map(node.types, getTypeFromTypeNode); - var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType; + var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) && types[1] === emptyTypeLiteralType; links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction); } return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(4194304 /* Index */); + var result = createType(4194304 /* TypeFlags.Index */); result.type = type; result.stringsOnly = stringsOnly; return result; } function createOriginIndexType(type) { - var result = createOriginType(4194304 /* Index */); + var result = createOriginType(4194304 /* TypeFlags.Index */); result.type = type; return result; } @@ -62323,7 +62521,7 @@ var ts; // so we only eagerly manifest the keys if the constraint is nongeneric if (!isGenericIndexType(constraintType)) { var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); } else { // we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later @@ -62339,8 +62537,8 @@ var ts; } // we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType, // so we can return the union that preserves aliases/origin data if possible - var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes); - if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { + var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)); }) : getUnionType(keyTypes); + if (result.flags & 1048576 /* TypeFlags.Union */ && constraintType.flags & 1048576 /* TypeFlags.Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { return constraintType; } return result; @@ -62360,12 +62558,12 @@ var ts; var typeVariable = getTypeParameterFromMappedType(mappedType); return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); function isDistributive(type) { - return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true : - type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) : - type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : - type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) : - type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) : + return type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */ | 262144 /* TypeFlags.TypeParameter */ | 524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */) ? true : + type.flags & 16777216 /* TypeFlags.Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? isDistributive(type.substitute) : + type.flags & 268435456 /* TypeFlags.StringMapping */ ? isDistributive(type.type) : false; } } @@ -62377,11 +62575,11 @@ var ts; getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); - type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") : + type = prop.escapedName === "default" /* InternalSymbolName.Default */ ? getStringLiteralType("default") : name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined); } if (type && type.flags & include) { @@ -62391,14 +62589,14 @@ var ts; return neverType; } function isKeyTypeIncluded(keyType, include) { - return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); + return !!(keyType.flags & include || keyType.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); } function getLiteralTypeFromProperties(type, include, includeOrigin) { - var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; + var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); }); var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? - info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); - return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, + info.keyType === stringType && include & 8 /* TypeFlags.Number */ ? stringOrNumberType : info.keyType : neverType; }); + return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* UnionReduction.Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); } /** @@ -62408,24 +62606,27 @@ var ts; * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible). */ function isPossiblyReducibleByInstantiation(type) { - return ts.some(type.types, function (t) { - var uniqueFilled = getUniqueLiteralFilledInstantiation(t); - return getReducedType(uniqueFilled) !== uniqueFilled; - }); + var uniqueFilled = getUniqueLiteralFilledInstantiation(type); + return getReducedType(uniqueFilled) !== uniqueFilled; + } + function shouldDeferIndexType(type) { + return !!(type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || + isGenericTupleType(type) || + isGenericMappedType(type) && !hasDistributiveNameType(type) || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) || + type.flags & 2097152 /* TypeFlags.Intersection */ && maybeTypeOfKind(type, 465829888 /* TypeFlags.Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType)); } function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type) - ? getIndexTypeForGenericType(type, stringsOnly) - : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : + return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 1048576 /* TypeFlags.Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : - type.flags & 2 /* Unknown */ ? neverType : - type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : - getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); + type.flags & 2 /* TypeFlags.Unknown */ ? neverType : + type.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */) ? keyofConstraintType : + getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* TypeFlags.StringLiteral */ : 402653316 /* TypeFlags.StringLike */) | (stringsOnly ? 0 : 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -62436,21 +62637,21 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 131072 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* TypeFlags.Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 140 /* KeyOfKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 154 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 151 /* SymbolKeyword */ + case 154 /* SyntaxKind.UniqueKeyword */: + links.resolvedType = node.type.kind === 151 /* SyntaxKind.SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 145 /* ReadonlyKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -62467,7 +62668,7 @@ var ts; return links.resolvedType; } function getTemplateLiteralType(texts, types) { - var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex >= 0) { return checkCrossProductUnion(types) ? mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : @@ -62486,10 +62687,10 @@ var ts; return getStringLiteralType(text); } newTexts.push(text); - if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) { + if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -62500,13 +62701,13 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; var addText = isTextsArray ? texts[i + 1] : texts; - if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) { + if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) { text += getTemplateStringForType(t) || ""; text += addText; if (!isTextsArray) return true; } - else if (t.flags & 134217728 /* TemplateLiteral */) { + else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { text += t.texts[0]; if (!addSpans(t.texts, t.types)) return false; @@ -62519,7 +62720,7 @@ var ts; newTexts.push(text); text = addText; } - else if (t.flags & 2097152 /* Intersection */) { + else if (t.flags & 2097152 /* TypeFlags.Intersection */) { var added = addSpans(texts[i + 1], t.types); if (!added) return false; @@ -62532,47 +62733,47 @@ var ts; } } function getTemplateStringForType(type) { - return type.flags & 128 /* StringLiteral */ ? type.value : - type.flags & 256 /* NumberLiteral */ ? "" + type.value : - type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : - type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? "" + type.value : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : + type.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) ? type.intrinsicName : undefined; } function createTemplateLiteralType(texts, types) { - var type = createType(134217728 /* TemplateLiteral */); + var type = createType(134217728 /* TypeFlags.TemplateLiteral */); type.texts = texts; type.types = types; return type; } function getStringMappingType(symbol, type) { - return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : + return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : // Mapping> === Mapping - type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : - isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) : - type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : - type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) : + type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type : + isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* TypeFlags.StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) : type; } function applyStringMapping(symbol, str) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return str.toUpperCase(); - case 1 /* Lowercase */: return str.toLowerCase(); - case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); - case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); + case 0 /* IntrinsicTypeKind.Uppercase */: return str.toUpperCase(); + case 1 /* IntrinsicTypeKind.Lowercase */: return str.toLowerCase(); + case 2 /* IntrinsicTypeKind.Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); + case 3 /* IntrinsicTypeKind.Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); } return str; } function applyTemplateStringMapping(symbol, texts, types) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; - case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; - case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; - case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + case 0 /* IntrinsicTypeKind.Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 1 /* IntrinsicTypeKind.Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 2 /* IntrinsicTypeKind.Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + case 3 /* IntrinsicTypeKind.Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; } return [texts, types]; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -62580,13 +62781,13 @@ var ts; return result; } function createStringMappingType(symbol, type) { - var result = createType(268435456 /* StringMapping */); + var result = createType(268435456 /* TypeFlags.StringMapping */); result.symbol = symbol; result.type = type; return result; } function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { - var type = createType(8388608 /* IndexedAccess */); + var type = createType(8388608 /* TypeFlags.IndexedAccess */); type.objectType = objectType; type.indexType = indexType; type.accessFlags = accessFlags; @@ -62607,16 +62808,16 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 4096 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) { return true; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getResolvedBaseConstraint(type); return constraint !== type && isJSLiteralType(constraint); } @@ -62631,26 +62832,26 @@ var ts; undefined; } function isUncalledFunctionReference(node, symbol) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent; if (ts.isCallLikeExpression(parent)) { return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node); } - return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } return true; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { - if (accessFlags & 256 /* Contextual */) { + if (accessFlags & 256 /* AccessFlags.Contextual */) { return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* AccessFlags.ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } @@ -62660,7 +62861,7 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 8 /* CacheSymbol */) { + if (accessFlags & 8 /* AccessFlags.CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -62668,50 +62869,57 @@ var ts; } } var propType = getTypeOfSymbol(prop); - return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? + return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* AssignmentKind.Definite */ ? getFlowTypeOfReference(accessExpression, propType) : propType; } - if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { + if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) { + var index = +propName; + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* AccessFlags.NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { + if (index < 0) { + error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value); + return undefinedType; + } error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); } else { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } } - errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); - return mapType(objectType, function (t) { - var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; - }); + if (index >= 0) { + errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); + return mapType(objectType, function (t) { + var restType = getRestTypeOfTupleType(t) || undefinedType; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; + }); + } } } - if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { + if (!(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */)) { + if (objectType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) { return objectType; } // If no index signature is applicable, we default to the string index signature. In effect, this means the string // index signature applies even when accessing with a symbol-like type. var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType); if (indexInfo) { - if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { + if (accessFlags & 2 /* AccessFlags.NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } return undefined; } - if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } - if (indexType.flags & 131072 /* Never */) { + if (indexType.flags & 131072 /* TypeFlags.Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -62719,21 +62927,21 @@ var ts; } if (accessExpression && !isConstEnumObjectType(objectType)) { if (isObjectLiteralType(objectType)) { - if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (noImplicitAny && indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType))); return undefinedType; } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { var types = ts.map(objectType.properties, function (property) { return getTypeOfSymbol(property); }); return getUnionType(ts.append(types, undefinedType)); } } - if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* SymbolFlags.BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* AccessFlags.SuppressNoImplicitAnyError */)) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { var typeName = typeToString(objectType); error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]"); @@ -62755,20 +62963,20 @@ var ts; } else { var errorInfo = void 0; - if (indexType.flags & 1024 /* EnumLiteral */) { + if (indexType.flags & 1024 /* TypeFlags.EnumLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType)); } - else if (indexType.flags & 8192 /* UniqueESSymbol */) { + else if (indexType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression); errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType)); } - else if (indexType.flags & 128 /* StringLiteral */) { + else if (indexType.flags & 128 /* TypeFlags.StringLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & 256 /* NumberLiteral */) { + else if (indexType.flags & 256 /* TypeFlags.NumberLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType)); } errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType)); @@ -62785,10 +62993,10 @@ var ts; } if (accessNode) { var indexNode = getIndexNodeForAccessExpression(accessNode); - if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { + else if (indexType.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { @@ -62806,62 +63014,62 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 194 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 162 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 194 /* SyntaxKind.IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type)); + return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */ && isPatternLiteralPlaceholderType(type.type)); } function isPatternLiteralType(type) { - return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); + return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); } function isGenericType(type) { return !!getGenericObjectFlags(type); } function isGenericObjectType(type) { - return !!(getGenericObjectFlags(type) & 4194304 /* IsGenericObjectType */); + return !!(getGenericObjectFlags(type) & 4194304 /* ObjectFlags.IsGenericObjectType */); } function isGenericIndexType(type) { - return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */); + return !!(getGenericObjectFlags(type) & 8388608 /* ObjectFlags.IsGenericIndexType */); } function getGenericObjectFlags(type) { - if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 33554432 /* TypeFlags.Substitution */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | - (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0); + return (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* ObjectFlags.IsGenericObjectType */ : 0) | + (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* ObjectFlags.IsGenericIndexType */ : 0); } function getSimplifiedType(type, writing) { - return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : - type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : + return type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getSimplifiedConditionalType(type, writing) : type; } function distributeIndexOverObjectType(objectType, indexType, writing) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 3145728 /* UnionOrIntersection */) { + if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); }); - return objectType.flags & 2097152 /* Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); + return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); } } function distributeObjectOverIndexType(objectType, indexType, writing) { // T[A | B] -> T[A] | T[B] (reading) // T[A | B] -> T[A] & T[B] (writing) - if (indexType.flags & 1048576 /* Union */) { + if (indexType.flags & 1048576 /* TypeFlags.Union */) { var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); }); return writing ? getIntersectionType(types) : getUnionType(types); } @@ -62886,7 +63094,7 @@ var ts; return type[cache] = distributedOverIndex; } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 465829888 /* Instantiable */)) { + if (!(indexType.flags & 465829888 /* TypeFlags.Instantiable */)) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] @@ -62900,8 +63108,8 @@ var ts; // A generic tuple type indexed by a number exists only when the index type doesn't select a // fixed element. We simplify to either the combined type of all elements (when the index type // the actual number type) or to the combined type of all non-fixed elements. - if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) { - var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); + if (isGenericTupleType(objectType) && indexType.flags & 296 /* TypeFlags.NumberLike */) { + var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* TypeFlags.Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); if (elementType) { return type[cache] = elementType; } @@ -62923,19 +63131,19 @@ var ts; var trueType = getTrueTypeFromConditionalType(type); var falseType = getFalseTypeFromConditionalType(type); // Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`. - if (falseType.flags & 131072 /* Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { - if (checkType.flags & 1 /* Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + if (falseType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { + if (checkType.flags & 1 /* TypeFlags.Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return getSimplifiedType(trueType, writing); } else if (isIntersectionEmpty(checkType, extendsType)) { // Always false return neverType; } } - else if (trueType.flags & 131072 /* Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { - if (!(checkType.flags & 1 /* Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + else if (trueType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { + if (!(checkType.flags & 1 /* TypeFlags.Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return neverType; } - else if (checkType.flags & 1 /* Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false + else if (checkType.flags & 1 /* TypeFlags.Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false return getSimplifiedType(falseType, writing); } } @@ -62945,7 +63153,7 @@ var ts; * Invokes union simplification logic to determine if an intersection is considered empty as a union constituent */ function isIntersectionEmpty(type1, type2) { - return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* Never */); + return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* TypeFlags.Never */); } function substituteIndexedMappedType(objectType, index) { var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); @@ -62953,12 +63161,12 @@ var ts; return instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper); } function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { - if (t.flags & 384 /* StringOrNumberLiteral */) { + if (t.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var propName = getPropertyNameFromType(t); if (ts.isNumericLiteralName(propName)) { var index = +propName; @@ -62969,33 +63177,33 @@ var ts; }); } function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. - if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { indexType = stringType; } // In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to // an index signature have 'undefined' included in their type. - if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) - accessFlags |= 1 /* IncludeUndefined */; + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* AccessFlags.ExpressionPosition */) + accessFlags |= 1 /* AccessFlags.IncludeUndefined */; // If the index type is generic, or if the object type is generic and doesn't originate in an expression and // the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing // a higher-order index access where we cannot meaningfully access the properties of the object type. Note that // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* SyntaxKind.IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { - if (objectType.flags & 3 /* AnyOrUnknown */) { + if (objectType.flags & 3 /* TypeFlags.AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var persistentAccessFlags = accessFlags & 1 /* AccessFlags.Persistent */; var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { @@ -63007,12 +63215,12 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getReducedApparentType(objectType); - if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* TypeFlags.Union */ && !(indexType.flags & 16 /* TypeFlags.Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* AccessFlags.SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -63028,11 +63236,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 4 /* Writing */ + return accessFlags & 4 /* AccessFlags.Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) - : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); + : getUnionType(propTypes, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* AccessFlags.CacheSymbol */ | 64 /* AccessFlags.ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -63040,8 +63248,8 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); - links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && + var resolved = getIndexedAccessType(objectType, indexType, 0 /* AccessFlags.None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + links.resolvedType = resolved.flags & 8388608 /* TypeFlags.IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConditionalFlowTypeOfType(resolved, node) : resolved; @@ -63051,7 +63259,7 @@ var ts; function getTypeFromMappedTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(32 /* Mapped */, node.symbol); + var type = createObjectType(32 /* ObjectFlags.Mapped */, node.symbol); type.declaration = node; type.aliasSymbol = getAliasSymbolForTypeNode(node); type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol); @@ -63063,11 +63271,11 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return type.baseType; } - if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ || - type.indexType.flags & 33554432 /* Substitution */)) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */ && (type.objectType.flags & 33554432 /* TypeFlags.Substitution */ || + type.indexType.flags & 33554432 /* TypeFlags.Substitution */)) { return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType)); } return type; @@ -63098,7 +63306,7 @@ var ts; var result; var extraTypes; var tailCount = 0; - var _loop_18 = function () { + var _loop_19 = function () { if (tailCount === 1000) { error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); result = errorType; @@ -63132,7 +63340,7 @@ var ts; // * The mapper that maps the clone to its inference result (`context.mapper`) var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter); var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined; - var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */); + var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */); if (freshMapper) { var freshCombinedMapper = combineTypeMappers(mapper, freshMapper); for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) { @@ -63150,7 +63358,7 @@ var ts; // We don't want inferences from constraints as they may cause us to eagerly resolve the // conditional type instead of deferring resolution. Also, we always want strict function // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); } var innerMapper = combineTypeMappers(freshMapper, context.mapper); // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the @@ -63166,15 +63374,15 @@ var ts; // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, // then no instantiations will be and we can just return the false branch type. - if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */ && !isUnwrapped) { + if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) { (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } // If falseType is an immediately nested conditional type that isn't distributive or has an // identical checkType, switch to that type and loop. var falseType_1 = getTypeFromTypeNode(root.node.falseType); - if (falseType_1.flags & 16777216 /* Conditional */) { + if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) { var newRoot = falseType_1.root; if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { root = newRoot; @@ -63192,7 +63400,7 @@ var ts; // that has no constraint. This ensures that, for example, the type // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. - if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { + if (inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { var trueType_1 = getTypeFromTypeNode(root.node.trueType); var trueMapper = combinedMapper || mapper; if (canTailRecurse(trueType_1, trueMapper)) { @@ -63203,7 +63411,7 @@ var ts; } } // Return a deferred type for a check that is neither definitely true nor definitely false - result = createType(16777216 /* Conditional */); + result = createType(16777216 /* TypeFlags.Conditional */); result.root = root; result.checkType = instantiateType(root.checkType, mapper); result.extendsType = instantiateType(root.extendsType, mapper); @@ -63219,7 +63427,7 @@ var ts; // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive // cases we increment the tail recursion counter and stop after 1000 iterations. while (true) { - var state_5 = _loop_18(); + var state_5 = _loop_19(); if (typeof state_5 === "object") return state_5.value; if (state_5 === "break") @@ -63231,14 +63439,14 @@ var ts; // type. Note that recursion is possible only through aliased conditional types, so we only increment the tail // recursion counter for those. function canTailRecurse(newType, newMapper) { - if (newType.flags & 16777216 /* Conditional */ && newMapper) { + if (newType.flags & 16777216 /* TypeFlags.Conditional */ && newMapper) { var newRoot = newType.root; if (newRoot.outerTypeParameters) { var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper); var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); }); var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments); var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined; - if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) { + if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */))) { root = newRoot; mapper = newRootMapper; aliasSymbol = undefined; @@ -63266,7 +63474,7 @@ var ts; var result; if (node.locals) { node.locals.forEach(function (symbol) { - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { result = ts.append(result, getDeclaredTypeOfSymbol(symbol)); } }); @@ -63289,7 +63497,7 @@ var ts; node: node, checkType: checkType, extendsType: getTypeFromTypeNode(node.extendsType), - isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeFlags.TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -63320,6 +63528,7 @@ var ts; } } function getTypeFromImportTypeNode(node) { + var _a; var links = getNodeLinks(node); if (!links.resolvedType) { if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments @@ -63332,27 +63541,30 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* SymbolFlags.Value */ : node.flags & 8388608 /* NodeFlags.JSDoc */ ? 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ : 788968 /* SymbolFlags.Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } + var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)); var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); if (!ts.nodeIsMissing(node.qualifier)) { var nameStack = getIdentifierChain(node.qualifier); var currentNamespace = moduleSymbol; var current = void 0; while (current = nameStack.shift()) { - var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning; + var meaning = nameStack.length ? 1920 /* SymbolFlags.Namespace */ : targetMeaning; // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from // the `exports` lookup process that only looks up namespace members which is used for most type references var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace)); - var next = node.isTypeOf + var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true) - : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + : undefined; + var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable; if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); return links.resolvedType = errorType; @@ -63368,7 +63580,7 @@ var ts; links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 111551 /* Value */ + var errorMessage = targetMeaning === 111551 /* SymbolFlags.Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -63382,7 +63594,7 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 111551 /* Value */) { + if (meaning === 111551 /* SymbolFlags.Value */) { return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { @@ -63398,7 +63610,7 @@ var ts; links.resolvedType = emptyTypeLiteralType; } else { - var type = createObjectType(16 /* Anonymous */, node.symbol); + var type = createObjectType(16 /* ObjectFlags.Anonymous */, node.symbol); type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); if (ts.isJSDocTypeLiteral(node) && node.isArrayType) { @@ -63411,7 +63623,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -63420,13 +63632,13 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function isNonGenericObjectType(type) { - return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + return !!(type.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(type); } function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) { - return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); + return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return type; } if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { @@ -63446,13 +63658,13 @@ var ts; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // do nothing, skip privates } else if (isSpreadableProperty(prop)) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - var flags = 4 /* Property */ | 16777216 /* Optional */; - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */; + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -63461,7 +63673,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return spread; } } @@ -63471,31 +63683,31 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, symbol, objectFlags, readonly) { - if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + if (left.flags & 1 /* TypeFlags.Any */ || right.flags & 1 /* TypeFlags.Any */) { return anyType; } - if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + if (left.flags & 2 /* TypeFlags.Unknown */ || right.flags & 2 /* TypeFlags.Unknown */) { return unknownType; } - if (left.flags & 131072 /* Never */) { + if (left.flags & 131072 /* TypeFlags.Never */) { return right; } - if (right.flags & 131072 /* Never */) { + if (right.flags & 131072 /* TypeFlags.Never */) { return left; } left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); - if (left.flags & 1048576 /* Union */) { + if (left.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) : errorType; } right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); - if (right.flags & 1048576 /* Union */) { + if (right.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) : errorType; } - if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { + if (right.flags & (528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)) { return left; } if (isGenericObjectType(left) || isGenericObjectType(right)) { @@ -63505,7 +63717,7 @@ var ts; // When the left type is an intersection, we may need to merge the last constituent of the // intersection with the right type. For example when the left type is 'T & { a: string }' // and the right type is '{ b: string }' we produce 'T & { a: string, b: string }'. - if (left.flags & 2097152 /* Intersection */) { + if (left.flags & 2097152 /* TypeFlags.Intersection */) { var types = left.types; var lastLeft = types[types.length - 1]; if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { @@ -63519,7 +63731,7 @@ var ts; var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { @@ -63534,11 +63746,11 @@ var ts; if (members.has(leftProp.escapedName)) { var rightProp = members.get(leftProp.escapedName); var rightType = getTypeOfSymbol(rightProp); - if (rightProp.flags & 16777216 /* Optional */) { + if (rightProp.flags & 16777216 /* SymbolFlags.Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); + var flags = 4 /* SymbolFlags.Property */ | (leftProp.flags & 16777216 /* SymbolFlags.Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */); + result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* UnionReduction.Subtype */); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -63551,23 +63763,23 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); })); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */ | 2097152 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 2097152 /* ObjectFlags.ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { var _a; return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && - (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + (!(prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) || !((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); }))); } function getSpreadSymbol(prop, readonly) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) { return prop; } - var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var flags = 4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */); + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -63585,7 +63797,7 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 2944 /* Literal */) { + if (type.flags & 2944 /* TypeFlags.Literal */) { if (!type.freshType) { var freshType = createLiteralType(type.flags, type.value, type.symbol, type); freshType.freshType = freshType; @@ -63596,39 +63808,39 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 2944 /* Literal */ ? type.regularType : - type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : + return type.flags & 2944 /* TypeFlags.Literal */ ? type.regularType : + type.flags & 1048576 /* TypeFlags.Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + return !!(type.flags & 2944 /* TypeFlags.Literal */) && type.freshType === type; } function getStringLiteralType(value) { var type; return stringLiteralTypes.get(value) || - (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type); + (stringLiteralTypes.set(value, type = createLiteralType(128 /* TypeFlags.StringLiteral */, value)), type); } function getNumberLiteralType(value) { var type; return numberLiteralTypes.get(value) || - (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type); + (numberLiteralTypes.set(value, type = createLiteralType(256 /* TypeFlags.NumberLiteral */, value)), type); } function getBigIntLiteralType(value) { var type; var key = ts.pseudoBigIntToString(value); return bigIntLiteralTypes.get(key) || - (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type); + (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* TypeFlags.BigIntLiteral */, value)), type); } function getEnumLiteralType(value, enumId, symbol) { var type; var qualifier = typeof value === "string" ? "@" : "#"; var key = enumId + qualifier + value; - var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */); + var flags = 1024 /* TypeFlags.EnumLiteral */ | (typeof value === "string" ? 128 /* TypeFlags.StringLiteral */ : 256 /* TypeFlags.NumberLiteral */); return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type); } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 104 /* NullKeyword */) { + if (node.literal.kind === 104 /* SyntaxKind.NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -63638,9 +63850,9 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(8192 /* UniqueESSymbol */); + var type = createType(8192 /* TypeFlags.UniqueESSymbol */); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -63656,20 +63868,20 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) { if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } // inside x.prototype = { ... } - if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; } // /** @return {this} */ // x.prototype.m = function() { ... } - var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; - if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; } // inside constructor function C() { ... } @@ -63691,17 +63903,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 186 /* RestType */ || node.kind === 197 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 186 /* SyntaxKind.RestType */ || node.kind === 197 /* SyntaxKind.NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return node.elementType; } return undefined; @@ -63717,99 +63929,99 @@ var ts; } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return anyType; - case 155 /* UnknownKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return unknownType; - case 150 /* StringKeyword */: + case 150 /* SyntaxKind.StringKeyword */: return stringType; - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return numberType; - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return bigintType; - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return booleanType; - case 151 /* SymbolKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: return esSymbolType; - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return voidType; - case 153 /* UndefinedKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: return undefinedType; - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 143 /* NeverKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return neverType; - case 148 /* ObjectKeyword */: - return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 138 /* IntrinsicKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + return node.flags & 262144 /* NodeFlags.JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; + case 138 /* SyntaxKind.IntrinsicKeyword */: return intrinsicMarkerType; - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return getTypeFromLiteralTypeNode(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getTypeFromTypeReference(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return getTypeFromTypeQueryNode(node); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return getTypeFromOptionalTypeNode(node); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return getTypeFromUnionTypeNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 191 /* ParenthesizedType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: return getTypeFromRestTypeNode(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return getTypeFromMappedTypeNode(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return getTypeFromInferTypeNode(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -63847,9 +64059,9 @@ var ts; } function getMappedType(type, mapper) { switch (mapper.kind) { - case 0 /* Simple */: + case 0 /* TypeMapKind.Simple */: return type === mapper.source ? mapper.target : type; - case 1 /* Array */: + case 1 /* TypeMapKind.Array */: { var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -63858,25 +64070,39 @@ var ts; } } return type; - case 2 /* Function */: + } + case 2 /* TypeMapKind.Deferred */: { + var sources = mapper.sources; + var targets = mapper.targets; + for (var i = 0; i < sources.length; i++) { + if (type === sources[i]) { + return targets[i](); + } + } + return type; + } + case 3 /* TypeMapKind.Function */: return mapper.func(type); - case 3 /* Composite */: - case 4 /* Merged */: + case 4 /* TypeMapKind.Composite */: + case 5 /* TypeMapKind.Merged */: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 4 /* TypeMapKind.Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0 /* Simple */, source: source, target: target }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 0 /* TypeMapKind.Simple */, source: source, target: target }); } function makeArrayTypeMapper(sources, targets) { - return { kind: 1 /* Array */, sources: sources, targets: targets }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 1 /* TypeMapKind.Array */, sources: sources, targets: targets }); + } + function makeFunctionTypeMapper(func, debugInfo) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 3 /* TypeMapKind.Function */, func: func, debugInfo: ts.Debug.isDebugging ? debugInfo : undefined }); } - function makeFunctionTypeMapper(func) { - return { kind: 2 /* Function */, func: func }; + function makeDeferredTypeMapper(sources, targets) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 2 /* TypeMapKind.Deferred */, sources: sources, targets: targets }); } function makeCompositeTypeMapper(kind, mapper1, mapper2) { - return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: kind, mapper1: mapper1, mapper2: mapper2 }); } function createTypeEraser(sources) { return createTypeMapper(sources, /*targets*/ undefined); @@ -63886,19 +64112,20 @@ var ts; * This is used during inference when instantiating type parameter defaults. */ function createBackreferenceMapper(context, index) { - return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); + var forwardInferences = context.inferences.slice(index); + return createTypeMapper(ts.map(forwardInferences, function (i) { return i.typeParameter; }), ts.map(forwardInferences, function () { return unknownType; })); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4 /* TypeMapKind.Composite */, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -63931,7 +64158,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -63943,7 +64170,7 @@ var ts; // be affected by instantiation, simply return the symbol itself. return symbol; } - if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + if (ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) { // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -63952,7 +64179,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (8 /* Readonly */ | 4096 /* Late */ | 16384 /* OptionalParameter */ | 32768 /* RestParameter */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* CheckFlags.Instantiated */ | ts.getCheckFlags(symbol) & (8 /* CheckFlags.Readonly */ | 4096 /* CheckFlags.Late */ | 16384 /* CheckFlags.OptionalParameter */ | 32768 /* CheckFlags.RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -63966,12 +64193,12 @@ var ts; return result; } function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { - var declaration = type.objectFlags & 4 /* Reference */ ? type.node : - type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : + var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node : + type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); - var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : - type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType : + type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type; var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type @@ -63984,8 +64211,8 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; - typeParameters = (target.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -64006,8 +64233,8 @@ var ts; var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } @@ -64016,8 +64243,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.parent.kind === 178 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 200 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -64026,7 +64253,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 235 /* Block */ || n.kind === 189 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -64035,15 +64262,15 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return !!tp.isThisType; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return true; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return !node.type && !!node.body || ts.some(node.typeParameters, containsReference) || ts.some(node.parameters, containsReference) || @@ -64054,9 +64281,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { var typeVariable = getActualTypeVariable(constraintType.type); - if (typeVariable.flags & 262144 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeFlags.TypeParameter */) { return typeVariable; } } @@ -64078,10 +64305,10 @@ var ts; var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) { + if (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && t !== wildcardType && !isErrorType(t)) { if (!type.declaration.nameType) { var constraint = void 0; - if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && + if (isArrayType(t) || t.flags & 1 /* TypeFlags.Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } @@ -64102,7 +64329,7 @@ var ts; return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments); } function getModifiedReadonlyState(state, modifiers) { - return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state; + return modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? true : modifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */ ? false : state; } function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) { // When a tuple type is generic (i.e. when it contains variadic elements), we want to eagerly map the @@ -64111,14 +64338,14 @@ var ts; // normalization to resolve the non-generic parts of the resulting tuple. var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) { - var singleton = elementFlags[i] & 8 /* Variadic */ ? t : - elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : + var singleton = elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : + elementFlags[i] & 4 /* ElementFlags.Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]); // The singleton is never a generic tuple type, so it is safe to recurse here. return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper)); }); var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType)); - return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* Variadic */; }), newReadonly); + return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* ElementFlags.Variadic */; }), newReadonly); } function instantiateMappedArrayType(arrayType, mappedType, mapper) { var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper); @@ -64128,11 +64355,11 @@ var ts; function instantiateMappedTupleType(tupleType, mappedType, mapper) { var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { - return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); + return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* ElementFlags.Optional */), mapper); }); var modifiers = getMappedTypeModifiers(mappedType); - var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) : - modifiers & 8 /* ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var newTupleModifiers = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? 2 /* ElementFlags.Optional */ : f; }) : + modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : elementFlags; var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers); return ts.contains(elementTypes, errorType) ? errorType : @@ -64142,13 +64369,13 @@ var ts; var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + return strictNullChecks && modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + strictNullChecks && modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { - var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); - if (type.objectFlags & 32 /* Mapped */) { + var result = createObjectType(type.objectFlags | 64 /* ObjectFlags.Instantiated */, type.symbol); + if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { result.declaration = type.declaration; // C.f. instantiateSignature var origTypeParameter = getTypeParameterFromMappedType(type); @@ -64157,13 +64384,14 @@ var ts; mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper); freshTypeParameter.mapper = mapper; } - if (type.objectFlags & 8388608 /* InstantiationExpressionType */) { + if (type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */) { result.node = type.node; } result.target = type; result.mapper = mapper; result.aliasSymbol = aliasSymbol || type.aliasSymbol; result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0; return result; } function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { @@ -64182,7 +64410,7 @@ var ts; // Distributive conditional types are distributed over union types. For example, when the // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the // result is (A extends U ? X : Y) | (B extends U ? X : Y). - result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? + result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); @@ -64202,7 +64430,7 @@ var ts; // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } @@ -64215,62 +64443,62 @@ var ts; } function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; - if (flags & 262144 /* TypeParameter */) { + if (flags & 262144 /* TypeFlags.TypeParameter */) { return getMappedType(type, mapper); } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { var objectFlags = type.objectFlags; - if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !type.node) { + if (objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + if (objectFlags & 4 /* ObjectFlags.Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { return instantiateReverseMappedType(type, mapper); } return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } - if (flags & 3145728 /* UnionOrIntersection */) { - var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; - var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; + if (flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + var origin = type.flags & 1048576 /* TypeFlags.Union */ ? type.origin : undefined; + var types = origin && origin.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); if (newTypes === types && aliasSymbol === type.aliasSymbol) { return type; } var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); - return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? + return flags & 2097152 /* TypeFlags.Intersection */ || origin && origin.flags & 2097152 /* TypeFlags.Intersection */ ? getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : - getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); + getUnionType(newTypes, 1 /* UnionReduction.Literal */, newAliasSymbol, newAliasTypeArguments); } - if (flags & 4194304 /* Index */) { + if (flags & 4194304 /* TypeFlags.Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 134217728 /* TemplateLiteral */) { + if (flags & 134217728 /* TypeFlags.TemplateLiteral */) { return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper)); } - if (flags & 268435456 /* StringMapping */) { + if (flags & 268435456 /* TypeFlags.StringMapping */) { return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } - if (flags & 8388608 /* IndexedAccess */) { + if (flags & 8388608 /* TypeFlags.IndexedAccess */) { var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); } - if (flags & 16777216 /* Conditional */) { + if (flags & 16777216 /* TypeFlags.Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } - if (flags & 33554432 /* Substitution */) { + if (flags & 33554432 /* TypeFlags.Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); - if (maybeVariable.flags & 8650752 /* TypeVariable */) { + if (maybeVariable.flags & 8650752 /* TypeFlags.TypeVariable */) { return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper)); } else { var sub = instantiateType(type.substitute, mapper); - if (sub.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { + if (sub.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { return maybeVariable; } return sub; @@ -64280,11 +64508,11 @@ var ts; } function instantiateReverseMappedType(type, mapper) { var innerMappedType = instantiateType(type.mappedType, mapper); - if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + if (!(ts.getObjectFlags(innerMappedType) & 32 /* ObjectFlags.Mapped */)) { return type; } var innerIndexType = instantiateType(type.constraintType, mapper); - if (!(innerIndexType.flags & 4194304 /* Index */)) { + if (!(innerIndexType.flags & 4194304 /* TypeFlags.Index */)) { return type; } var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); @@ -64294,15 +64522,15 @@ var ts; return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable } function getUniqueLiteralFilledInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper)); } function getPermissiveInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); } function getRestrictiveInstantiation(type) { - if (type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */)) { + if (type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) { return type; } if (type.restrictiveInstantiation) { @@ -64323,35 +64551,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 221 /* BinaryExpression */: - return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && + case 221 /* SyntaxKind.BinaryExpression */: + return (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return isContextSensitive(node.initializer); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isContextSensitive(node.expression); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 285 /* JsxAttribute */: { + case 285 /* SyntaxKind.JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 288 /* JsxExpression */: { + case 288 /* SyntaxKind.JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -64365,17 +64593,17 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* SyntaxKind.Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { - var result = createObjectType(16 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* ObjectFlags.Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = ts.emptyArray; @@ -64384,7 +64612,7 @@ var ts; return result; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -64394,13 +64622,13 @@ var ts; return isTypeRelatedTo(source, target, identityRelation); } function compareTypesIdentical(source, target) { - return isTypeRelatedTo(source, target, identityRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, identityRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesAssignable(source, target) { - return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesSubtypeOf(source, target) { - return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); @@ -64417,11 +64645,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 1048576 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : - target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 1048576 /* TypeFlags.Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* TypeFlags.Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType)); } /** @@ -64459,7 +64687,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* TypeFlags.Conditional */ || (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { if (!node || isOrHasGenericConditional(target)) @@ -64469,35 +64697,35 @@ var ts; return true; } switch (node.kind) { - case 288 /* JsxExpression */: - case 212 /* ParenthesizedExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 27 /* CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; } function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { - var callSignatures = getSignaturesOfType(source, 0 /* Call */); - var constructSignatures = getSignaturesOfType(source, 1 /* Construct */); + var callSignatures = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructSignatures = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) { var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = errorOutputContainer || {}; checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj); @@ -64521,7 +64749,7 @@ var ts; if (!sourceSig) { return false; } - var targetSignatures = getSignaturesOfType(target, 0 /* Call */); + var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */); if (!ts.length(targetSignatures)) { return false; } @@ -64539,7 +64767,7 @@ var ts; if (target.symbol && ts.length(target.symbol.declarations)) { ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); } - if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0 + if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 // exclude cases where source itself is promisy - this way we don't make a suggestion when relating // an IPromise and a Promise that are slightly different && !getTypeOfPropertyOfType(sourceReturn, "then") @@ -64556,7 +64784,7 @@ var ts; if (idx) { return idx; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { var best = getBestMatchingType(source, target); if (best) { return getIndexedAccessTypeOrUndefined(best, nameType); @@ -64566,7 +64794,7 @@ var ts; function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) { next.contextualType = sourcePropType; try { - return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType); + return checkExpressionForMutableLocation(next, 1 /* CheckMode.Contextual */, sourcePropType); } finally { next.contextualType = undefined; @@ -64583,7 +64811,7 @@ var ts; for (var status = iterator.next(); !status.done; status = iterator.next()) { var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType); - if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) + if (!targetPropType || targetPropType.flags & 8388608 /* TypeFlags.IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); if (!sourcePropType) @@ -64603,8 +64831,8 @@ var ts; resultObj.errors = [diag]; } else { - var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); - var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); targetPropType = removeMissingType(targetPropType, targetIsOptional); sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); @@ -64628,7 +64856,7 @@ var ts; if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) { var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0]; if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) { - ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); } } } @@ -64694,18 +64922,18 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: if (child.containsOnlyTriviaWhiteSpaces) { break; // Whitespace only jsx text isn't real jsx text } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -64730,7 +64958,7 @@ var ts; var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); }); if (moreThanOneRealChildren) { if (arrayLikeTargetParts !== neverType) { - var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */)); + var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */)); var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic); result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result; } @@ -64812,7 +65040,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & (131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -64822,7 +65050,7 @@ var ts; var oldContext = node.contextualType; node.contextualType = target; try { - var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); + var tupleizedType = checkArrayLiteral(node, 1 /* CheckMode.Contextual */, /*forceTuple*/ true); node.contextualType = oldContext; if (isTupleLikeType(tupleizedType)) { return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); @@ -64847,17 +65075,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 131072 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* TypeFlags.Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 173 /* SetAccessor */: return [3 /*break*/, 2]; - case 172 /* GetAccessor */: return [3 /*break*/, 2]; - case 169 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 297 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 296 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 173 /* SyntaxKind.SetAccessor */: return [3 /*break*/, 2]; + case 172 /* SyntaxKind.GetAccessor */: return [3 /*break*/, 2]; + case 169 /* SyntaxKind.MethodDeclaration */: return [3 /*break*/, 2]; + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 296 /* SyntaxKind.PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -64879,7 +65107,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & (131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -64891,8 +65119,8 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* IgnoreReturnTypes */ : 0, /*reportErrors*/ false, - /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* False */; + return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* SignatureCheckMode.IgnoreReturnTypes */ : 0, /*reportErrors*/ false, + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* Ternary.False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -64908,16 +65136,16 @@ var ts; function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isAnySignature(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var targetCount = getParameterCount(target); var sourceHasMoreParameters = !hasEffectiveRestParameter(target) && - (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); + (checkMode & 8 /* SignatureCheckMode.StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); if (sourceHasMoreParameters) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); @@ -64929,10 +65157,10 @@ var ts; if (sourceRestType || targetRestType) { void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers); } - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 169 /* MethodDeclaration */ && - kind !== 168 /* MethodSignature */ && kind !== 171 /* Constructor */; - var result = -1 /* True */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + var strictVariance = !(checkMode & 3 /* SignatureCheckMode.Callback */) && strictFunctionTypes && kind !== 169 /* SyntaxKind.MethodDeclaration */ && + kind !== 168 /* SyntaxKind.MethodSignature */ && kind !== 171 /* SyntaxKind.Constructor */; + var result = -1 /* Ternary.True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { var targetThisType = getThisTypeOfSignature(target); @@ -64944,7 +65172,7 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64963,27 +65191,27 @@ var ts; // similar to return values, callback parameters are output positions. This means that a Promise, // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) // with respect to T. - var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); - var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); + var sourceSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getTypeFacts(sourceType) & 50331648 /* IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* IsUndefinedOrNull */); + (getTypeFacts(sourceType) & 50331648 /* TypeFacts.IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* TypeFacts.IsUndefinedOrNull */); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : - !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* SignatureCheckMode.StrictArity */) | (strictVariance ? 2 /* SignatureCheckMode.StrictCallback */ : 1 /* SignatureCheckMode.BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : + !(checkMode & 3 /* SignatureCheckMode.Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { - related = 0 /* False */; + if (related && checkMode & 8 /* SignatureCheckMode.StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + related = 0 /* Ternary.False */; } if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } } - if (!(checkMode & 4 /* IgnoreReturnTypes */)) { + if (!(checkMode & 4 /* SignatureCheckMode.IgnoreReturnTypes */)) { // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType @@ -65006,14 +65234,14 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } else { // When relating callback signatures, we still need to relate return types bi-variantly as otherwise // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } // wouldn't be co-variant for T without this rule. - result &= checkMode & 1 /* BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + result &= checkMode & 1 /* SignatureCheckMode.BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); if (!result && reportErrors && incompatibleErrorReporter) { incompatibleErrorReporter(sourceReturnType, targetReturnType); @@ -65028,21 +65256,21 @@ var ts; errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { + if (source.kind === 1 /* TypePredicateKind.Identifier */ || source.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var related = source.type === target.type ? -1 /* True */ : + var related = source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; - if (related === 0 /* False */ && reportErrors) { + 0 /* Ternary.False */; + if (related === 0 /* Ternary.False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return related; @@ -65068,33 +65296,33 @@ var ts; t.indexInfos.length === 0; } function isEmptyObjectType(type) { - return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 67108864 /* NonPrimitive */ ? true : - type.flags & 1048576 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* TypeFlags.Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 67108864 /* TypeFlags.NonPrimitive */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isEmptyObjectType) : false; } function isEmptyAnonymousObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) || - type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && (type.members && isEmptyResolvedType(type) || + type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); } function isUnknownLikeUnionType(type) { - if (strictNullChecks && type.flags & 1048576 /* Union */) { - if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) { + if (strictNullChecks && type.flags & 1048576 /* TypeFlags.Union */) { + if (!(type.objectFlags & 33554432 /* ObjectFlags.IsUnknownLikeUnionComputed */)) { var types = type.types; - type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ && - types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0); + type.objectFlags |= 33554432 /* ObjectFlags.IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* TypeFlags.Undefined */ && + types[1].flags & 65536 /* TypeFlags.Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* ObjectFlags.IsUnknownLikeUnion */ : 0); } - return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */); + return !!(type.objectFlags & 67108864 /* ObjectFlags.IsUnknownLikeUnion */); } return false; } function containsUndefinedType(type) { - return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */); + return !!((type.flags & 1048576 /* TypeFlags.Union */ ? type.types[0] : type).flags & 32768 /* TypeFlags.Undefined */); } function isStringIndexSignatureOnlyType(type) { - return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || - type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || + return type.flags & 524288 /* TypeFlags.Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -65103,83 +65331,83 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var entry = enumRelation.get(id); - if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { - return !!(entry & 1 /* Succeeded */); + if (entry !== undefined && !(!(entry & 4 /* RelationComparisonResult.Reported */) && entry & 2 /* RelationComparisonResult.Failed */ && errorReporter)) { + return !!(entry & 1 /* RelationComparisonResult.Succeeded */); } - if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* SymbolFlags.RegularEnum */) || !(targetSymbol.flags & 256 /* SymbolFlags.RegularEnum */)) { + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) { var property = _a[_i]; - if (property.flags & 8 /* EnumMember */) { + if (property.flags & 8 /* SymbolFlags.EnumMember */) { var targetProperty = getPropertyOfType(targetEnumType, property.escapedName); - if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { + if (!targetProperty || !(targetProperty.flags & 8 /* SymbolFlags.EnumMember */)) { if (errorReporter) { - errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */)); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); } else { - enumRelation.set(id, 2 /* Failed */); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */); } return false; } } } - enumRelation.set(id, 1 /* Succeeded */); + enumRelation.set(id, 1 /* RelationComparisonResult.Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) + if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType) return true; - if (t & 131072 /* Never */) + if (t & 131072 /* TypeFlags.Never */) return false; - if (s & 402653316 /* StringLike */ && t & 4 /* String */) + if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */) return true; - if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && - t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 296 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */) return true; - if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && - t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) + if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */) return true; - if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */) return true; - if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) + if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */) return true; - if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { - if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) { + if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && + if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`. // Since unions and intersections may reduce to `never`, we exclude them here. - if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) + if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */))) return true; - if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) + if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */)) return true; - if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */))) + if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */))) return true; if (relation === assignableRelation || relation === comparableRelation) { - if (s & 1 /* Any */) + if (s & 1 /* TypeFlags.Any */) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any // numeric enum literal type. This rule exists for backwards compatibility reasons because // bit-flag enum types sometimes look like literal enum types with numeric literal values. - if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */)) return true; // Anything is assignable to a union containing undefined, null, and {} if (isUnknownLikeUnionType(target)) @@ -65198,38 +65426,38 @@ var ts; return true; } if (relation !== identityRelation) { - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { return true; } } - else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) { + else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) { // We have excluded types that may simplify to other forms, so types must have identical flags if (source.flags !== target.flags) return false; - if (source.flags & 67358815 /* Singleton */) + if (source.flags & 67358815 /* TypeFlags.Singleton */) return true; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false)); + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { + var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false)); if (related !== undefined) { - return !!(related & 1 /* Succeeded */); + return !!(related & 1 /* RelationComparisonResult.Succeeded */); } } - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { var t = isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type : - type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) : - type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : - type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : + ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type : + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? writing ? type.baseType : type.substitute : + type.flags & 25165824 /* TypeFlags.Simplifiable */ ? getSimplifiedType(type, writing) : type; if (t === type) return t; @@ -65241,7 +65469,7 @@ var ts; if (reduced !== type) { return reduced; } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); }); if (normalizedTypes !== type.types) { return getIntersectionType(normalizedTypes); @@ -65269,19 +65497,19 @@ var ts; var maybeCount = 0; var sourceDepth = 0; var targetDepth = 0; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; var overflow = false; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid var lastSkippedInfo; var incompatibleStack; var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage); + var result = isRelatedTo(source, target, 3 /* RecursionFlags.Both */, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack) { reportIncompatibleStack(); } if (overflow) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -65319,10 +65547,10 @@ var ts; diagnostics.add(diag); } } - if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) { + if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* Ternary.False */) { ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } - return result !== 0 /* False */; + return result !== 0 /* Ternary.False */; function resetErrorInfo(saved) { errorInfo = saved.errorInfo; lastSkippedInfo = saved.lastSkippedInfo; @@ -65367,24 +65595,24 @@ var ts; case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { // Parenthesize a `new` if there is one if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; // If leading, just print back the arg (irrespective of if it's a valid identifier) if (path.length === 0) { - path = "" + str; + path = "".concat(str); } // Otherwise write a dotted name if possible else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } // Failing that, check if the name is already a computed name else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } // And finally write out a computed name as a last resort else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -65413,7 +65641,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -65426,7 +65654,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -65478,7 +65706,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 /* TypeFlags.TypeParameter */ && target !== markerSuperTypeForCheck && target !== markerSubTypeForCheck) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -65500,7 +65728,7 @@ var ts; message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; } else { - if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */ && target.flags & 1048576 /* TypeFlags.Union */) { var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target); if (suggestedType) { reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType)); @@ -65562,7 +65790,7 @@ var ts; return true; } function isRelatedToWorker(source, target, reportErrors) { - return isRelatedTo(source, target, 3 /* Both */, reportErrors); + return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors); } /** * Compare two types and return @@ -65571,19 +65799,19 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) { - if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; } + if (recursionFlags === void 0) { recursionFlags = 3 /* RecursionFlags.Both */; } if (reportErrors === void 0) { reportErrors = false; } - if (intersectionState === void 0) { intersectionState = 0 /* None */; } + if (intersectionState === void 0) { intersectionState = 0 /* IntersectionState.None */; } // Before normalization: if `source` is type an object type, and `target` is primitive, // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result - if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) { + if (originalSource.flags & 524288 /* TypeFlags.Object */ && originalTarget.flags & 131068 /* TypeFlags.Primitive */) { if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (reportErrors) { reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and @@ -65592,73 +65820,73 @@ var ts; var source = getNormalizedType(originalSource, /*writing*/ false); var target = getNormalizedType(originalTarget, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; if (relation === identityRelation) { if (source.flags !== target.flags) - return 0 /* False */; - if (source.flags & 67358815 /* Singleton */) - return -1 /* True */; + return 0 /* Ternary.False */; + if (source.flags & 67358815 /* TypeFlags.Singleton */) + return -1 /* Ternary.True */; traceUnionsOrIntersectionsTooLarge(source, target); - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* IntersectionState.None */, recursionFlags); } // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, // as we break down the _target_ union first, _then_ get the source constraint - so for every // member of the target, we attempt to find a match in the source. This avoids that in cases where // the target is exactly the constraint. - if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) { - return -1 /* True */; + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && getConstraintOfType(source) === target) { + return -1 /* Ternary.True */; } // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined // plus a single non-nullable type. If so, remove null and/or undefined from the target type. - if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) { + if (source.flags & 470302716 /* TypeFlags.DefinitelyNonNullable */ && target.flags & 1048576 /* TypeFlags.Union */) { var types = target.types; - var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : - types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : + var candidate = types.length === 2 && types[0].flags & 98304 /* TypeFlags.Nullable */ ? types[1] : + types.length === 3 && types[0].flags & 98304 /* TypeFlags.Nullable */ && types[1].flags & 98304 /* TypeFlags.Nullable */ ? types[2] : undefined; - if (candidate && !(candidate.flags & 98304 /* Nullable */)) { + if (candidate && !(candidate.flags & 98304 /* TypeFlags.Nullable */)) { target = getNormalizedType(candidate, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) - return -1 /* True */; - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* FreshLiteral */); + return -1 /* Ternary.True */; + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* IntersectionState.Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) && - source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && - target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* IntersectionState.Target */) && + source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType && + target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source); var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target); - var calls = getSignaturesOfType(source, 0 /* Call */); - var constructs = getSignaturesOfType(source, 1 /* Construct */); - if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) || - constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) { + var calls = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructs = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString); } else { reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString); } } - return 0 /* False */; + return 0 /* Ternary.False */; } traceUnionsOrIntersectionsTooLarge(source, target); - var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) || - target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */); + var skipCaching = source.flags & 1048576 /* TypeFlags.Union */ && source.types.length < 4 && !(target.flags & 1048576 /* TypeFlags.Union */) || + target.flags & 1048576 /* TypeFlags.Union */ && target.types.length < 4 && !(source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */); var result_7 = skipCaching ? unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) : recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags); @@ -65677,10 +65905,10 @@ 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_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) { + if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) { inPropertyCheck = true; - result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags); + result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags); inPropertyCheck = false; } if (result_7) { @@ -65690,7 +65918,7 @@ var ts; if (reportErrors) { reportErrorResults(originalSource, originalTarget, source, target, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { var _a, _b; @@ -65702,20 +65930,20 @@ var ts; if (maybeSuppress) { overrideNextErrorInfo--; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true); if (errorInfo !== currentError) { maybeSuppress = !!errorInfo; } } - if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 131068 /* TypeFlags.Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* TypeFlags.Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } - else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) { + else if (ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && target.flags & 2097152 /* TypeFlags.Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -65734,7 +65962,7 @@ var ts; return; } reportRelationError(headMessage, source, target); - if (source.flags & 262144 /* TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) { + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) { var syntheticParam = cloneTypeParameter(source); syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam)); if (hasNonCircularBaseConstraint(syntheticParam)) { @@ -65747,17 +65975,17 @@ var ts; if (!ts.tracing) { return; } - if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { + if ((source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) && (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* ObjectFlags.PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } var sourceSize = sourceUnionOrIntersection.types.length; var targetSize = targetUnionOrIntersection.types.length; if (sourceSize * targetSize > 1E6) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { + ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { sourceId: source.id, sourceSize: sourceSize, targetId: target.id, @@ -65772,7 +66000,7 @@ var ts; var appendPropType = function (propTypes, type) { var _a; type = getApparentType(type); - var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); + var prop = type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType; return ts.append(propTypes, propType); }; @@ -65780,21 +66008,21 @@ var ts; } function hasExcessProperties(source, target, reportErrors) { var _a; - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* JSLiteral */) { + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* ObjectFlags.JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; } var reducedTarget = target; var checkTypes; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); - checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; + checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget]; } - var _loop_19 = function (prop) { + var _loop_20 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { @@ -65847,7 +66075,7 @@ var ts; } return { value: true }; } - if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) { + if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* RecursionFlags.Both */, reportErrors)) { if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop)); } @@ -65857,7 +66085,7 @@ var ts; }; for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { var prop = _b[_i]; - var state_6 = _loop_19(prop); + var state_6 = _loop_20(prop); if (typeof state_6 === "object") return state_6.value; } @@ -65870,28 +66098,28 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState); } - if (target.flags & 1048576 /* Union */) { - return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); + if (target.flags & 1048576 /* TypeFlags.Union */) { + return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */) && !(target.flags & 131068 /* TypeFlags.Primitive */)); } - if (target.flags & 2097152 /* Intersection */) { - return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */); + if (target.flags & 2097152 /* TypeFlags.Intersection */) { + return typeRelatedToEachType(source, target, reportErrors, 2 /* IntersectionState.Target */); } // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the // constraints of all non-primitive types in the source into a new intersection. We do this because the // intersection may further constrain the constraints of the non-primitive types. For example, given a type // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't // appear to be comparable to '2'. - if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { + if (relation === comparableRelation && target.flags & 131068 /* TypeFlags.Primitive */) { var constraints = ts.sameMap(source.types, getBaseConstraintOrType); if (constraints !== source.types) { source = getIntersectionType(constraints); - if (!(source.flags & 2097152 /* Intersection */)) { - return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false); + if (!(source.flags & 2097152 /* TypeFlags.Intersection */)) { + return isRelatedTo(source, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false); } } } @@ -65899,16 +66127,16 @@ var ts; // Don't report errors though. Elaborating on whether a source constituent is related to the target is // not actually useful and leads to some confusing error messages. Instead, we rely on the caller // checking whether the full intersection viewed as an object is related to the target. - return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */); + return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* IntersectionState.Source */); } function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65916,13 +66144,13 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { if (containsType(targetTypes, source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var match = getMatchingUnionConstituentForType(target, source); if (match) { - var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65930,7 +66158,7 @@ var ts; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; - var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65939,19 +66167,19 @@ var ts; // Elaborate only if we can find a best matching type in the target union var bestMatchingType = getBestMatchingType(source, target, isRelatedTo); if (bestMatchingType) { - isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true); + isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true); } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToEachType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var targetTypes = target.types; for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { var targetType = targetTypes_2[_i]; - var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(source, targetType, 2 /* RecursionFlags.Target */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65959,50 +66187,50 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors, intersectionState) { var sourceTypes = source.types; - if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { - return -1 /* True */; + if (source.flags & 1048576 /* TypeFlags.Union */ && containsType(sourceTypes, target)) { + return -1 /* Ternary.True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceTypes[i], target, 1 /* RecursionFlags.Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); if (related) { return related; } } - return 0 /* False */; + return 0 /* Ternary.False */; } function getUndefinedStrippedTargetIfNeeded(source, target) { // As a builtin type, `undefined` is a very low type ID - making it almsot always first, making this a very fast check to see // if we need to strip `undefined` from the target - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && - !(source.types[0].flags & 32768 /* Undefined */) && target.types[0].flags & 32768 /* Undefined */) { - return extractTypesOfKind(target, ~32768 /* Undefined */); + if (source.flags & 1048576 /* TypeFlags.Union */ && target.flags & 1048576 /* TypeFlags.Union */ && + !(source.types[0].flags & 32768 /* TypeFlags.Undefined */) && target.types[0].flags & 32768 /* TypeFlags.Undefined */) { + return extractTypesOfKind(target, ~32768 /* TypeFlags.Undefined */); } return target; } function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; // We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath // since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target); for (var i = 0; i < sourceTypes.length; i++) { var sourceType = sourceTypes[i]; - if (undefinedStrippedTarget.flags & 1048576 /* Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { + if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison // such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union - var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); if (related_1) { result &= related_1; continue; } } - var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66013,54 +66241,54 @@ var ts; if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; + return 0 /* Ternary.False */; } var length = sources.length <= targets.length ? sources.length : targets.length; - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < length; i++) { // When variance information isn't available we default to covariance. This happens // in the process of computing variance information for recursive types and when // comparing 'this' type arguments. - var varianceFlags = i < variances.length ? variances[i] : 1 /* Covariant */; - var variance = varianceFlags & 7 /* VarianceMask */; + var varianceFlags = i < variances.length ? variances[i] : 1 /* VarianceFlags.Covariant */; + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; // We ignore arguments for independent type parameters (because they're never witnessed). - if (variance !== 4 /* Independent */) { + if (variance !== 4 /* VarianceFlags.Independent */) { var s = sources[i]; var t = targets[i]; - var related = -1 /* True */; - if (varianceFlags & 8 /* Unmeasurable */) { + var related = -1 /* Ternary.True */; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_. // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be) - related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); + related = relation === identityRelation ? isRelatedTo(s, t, 3 /* RecursionFlags.Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); } - else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 1 /* VarianceFlags.Covariant */) { + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 2 /* VarianceFlags.Contravariant */) { + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 3 /* Bivariant */) { + else if (variance === 3 /* VarianceFlags.Bivariant */) { // In the bivariant case we first compare contravariantly without reporting // errors. Then, if that doesn't succeed, we compare covariantly with error // reporting. Thus, error elaboration will be based on the the covariant check, // which is generally easier to reason about. - related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false); + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (related) { - related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related &= isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66074,28 +66302,28 @@ var ts; // and issue an error. Otherwise, actually compare the structure of the two types. function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) { if (overflow) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0); + var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0); var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false); var entry = relation.get(id); if (entry !== undefined) { - if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { + if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - var saved = entry & 24 /* ReportsMask */; - if (saved & 8 /* ReportsUnmeasurable */) { - instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); + var saved = entry & 24 /* RelationComparisonResult.ReportsMask */; + if (saved & 8 /* RelationComparisonResult.ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMapper); } - if (saved & 16 /* ReportsUnreliable */) { - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + if (saved & 16 /* RelationComparisonResult.ReportsUnreliable */) { + instantiateType(source, reportUnreliableMapper); } } - return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* RelationComparisonResult.Succeeded */ ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } } if (!maybeKeys) { @@ -66111,42 +66339,42 @@ var ts; for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) { - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } } if (sourceDepth === 100 || targetDepth === 100) { overflow = true; - return 0 /* False */; + return 0 /* Ternary.False */; } } var maybeStart = maybeCount; maybeKeys[maybeCount] = id; maybeCount++; var saveExpandingFlags = expandingFlags; - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceStack[sourceDepth] = source; sourceDepth++; - if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) - expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 1 /* ExpandingFlags.Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) + expandingFlags |= 1 /* ExpandingFlags.Source */; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetStack[targetDepth] = target; targetDepth++; - if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) - expandingFlags |= 2 /* Target */; + if (!(expandingFlags & 2 /* ExpandingFlags.Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) + expandingFlags |= 2 /* ExpandingFlags.Target */; } var originalHandler; var propagatingVarianceFlags = 0; if (outofbandVarianceMarkerHandler) { originalHandler = outofbandVarianceMarkerHandler; outofbandVarianceMarkerHandler = function (onlyUnreliable) { - propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + propagatingVarianceFlags |= onlyUnreliable ? 16 /* RelationComparisonResult.ReportsUnreliable */ : 8 /* RelationComparisonResult.ReportsUnmeasurable */; return originalHandler(onlyUnreliable); }; } var result; - if (expandingFlags === 3 /* Both */) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + if (expandingFlags === 3 /* ExpandingFlags.Both */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -66154,30 +66382,30 @@ var ts; depth: sourceDepth, targetDepth: targetDepth }); - result = 3 /* Maybe */; + result = 3 /* Ternary.Maybe */; } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceDepth--; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetDepth--; } expandingFlags = saveExpandingFlags; if (result) { - if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) { - if (result === -1 /* True */ || result === 3 /* Maybe */) { + if (result === -1 /* Ternary.True */ || (sourceDepth === 0 && targetDepth === 0)) { + if (result === -1 /* Ternary.True */ || result === 3 /* Ternary.Maybe */) { // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + relation.set(maybeKeys[i], 1 /* RelationComparisonResult.Succeeded */ | propagatingVarianceFlags); } } maybeCount = maybeStart; @@ -66186,46 +66414,73 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); + relation.set(id, (reportErrors ? 4 /* RelationComparisonResult.Reported */ : 0) | 2 /* RelationComparisonResult.Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - if (intersectionState & 4 /* PropertyCheck */) { - return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); + var saveErrorInfo = captureErrorCalculationState(); + var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo); + if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) { + // The combined constraint of an intersection type is the intersection of the constraints of + // the constituents. When an intersection type contains instantiable types with union type + // constraints, there are situations where we need to examine the combined constraint. One is + // when the target is a union type. Another is when the intersection contains types belonging + // to one of the disjoint domains. For example, given type variables T and U, each with the + // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and + // we need to check this constraint against a union on the target side. Also, given a type + // variable V constrained to 'string | number', 'V & number' has a combined constraint of + // 'string & number | number & number' which reduces to just 'number'. + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */)); + if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + } + } + if (result) { + resetErrorInfo(saveErrorInfo); + } + return result; + } + function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) { + if (intersectionState & 4 /* IntersectionState.PropertyCheck */) { + return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */); } var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = captureErrorCalculationState(); var sourceFlags = source.flags; var targetFlags = target.flags; if (relation === identityRelation) { // We've already checked that source.flags and target.flags are identical - if (sourceFlags & 3145728 /* UnionOrIntersection */) { + if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { var result_8 = eachTypeRelatedToSomeType(source, target); if (result_8) { result_8 &= eachTypeRelatedToSomeType(target, source); } return result_8; } - if (sourceFlags & 4194304 /* Index */) { - return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (sourceFlags & 8388608 /* IndexedAccess */) { - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } } - if (sourceFlags & 16777216 /* Conditional */) { + if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { + if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } @@ -66233,60 +66488,37 @@ var ts; } } } - if (sourceFlags & 33554432 /* Substitution */) { - return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 33554432 /* TypeFlags.Substitution */) { + return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (!(sourceFlags & 524288 /* Object */)) { - return 0 /* False */; + if (!(sourceFlags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } } - else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) { + else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) { - // The combined constraint of an intersection type is the intersection of the constraints of - // the constituents. When an intersection type contains instantiable types with union type - // constraints, there are situations where we need to examine the combined constraint. One is - // when the target is a union type. Another is when the intersection contains types belonging - // to one of the disjoint domains. For example, given type variables T and U, each with the - // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and - // we need to check this constraint against a union on the target side. Also, given a type - // variable V constrained to 'string | number', 'V & number' has a combined constraint of - // 'string & number | number & number' which reduces to just 'number'. - // This also handles type parameters, as a type parameter with a union constraint compared against a union - // needs to have its constraint hoisted into an intersection with said type parameter, this way - // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) - // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); - if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself - // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); - return result; - } - } - } // The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle: // Source is instantiable (e.g. source has union or intersection constraint). // Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }). // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }). - if (!(sourceFlags & 465829888 /* Instantiable */ || - sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ || - sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) { - return 0 /* False */; + if (!(sourceFlags & 465829888 /* TypeFlags.Instantiable */ || + sourceFlags & 524288 /* TypeFlags.Object */ && targetFlags & 1048576 /* TypeFlags.Union */ || + sourceFlags & 2097152 /* TypeFlags.Intersection */ && targetFlags & (524288 /* TypeFlags.Object */ | 1048576 /* TypeFlags.Union */ | 465829888 /* TypeFlags.Instantiable */))) { + return 0 /* Ternary.False */; } } // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. - if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && source.aliasTypeArguments && + if (sourceFlags & (524288 /* TypeFlags.Object */ | 16777216 /* TypeFlags.Conditional */) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) { var variances = getAliasVariances(source.aliasSymbol); if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState); if (varianceResult !== undefined) { @@ -66295,48 +66527,48 @@ var ts; } // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T], // and U is assignable to [...T] when U is constrained to a mutable array or tuple type. - if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) || - isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) { + if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* RecursionFlags.Source */)) || + isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* RecursionFlags.Target */))) { return result; } - if (targetFlags & 262144 /* TypeParameter */) { + if (targetFlags & 262144 /* TypeFlags.TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) { - if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { + if (ts.getObjectFlags(source) & 32 /* ObjectFlags.Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* RecursionFlags.Both */)) { + if (!(getMappedTypeModifiers(source) & 4 /* MappedTypeModifiers.IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(templateType, indexedAccessType, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } } - if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) { + if (relation === comparableRelation && sourceFlags & 262144 /* TypeFlags.TypeParameter */) { // This is a carve-out in comparability to essentially forbid comparing a type parameter // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!) var constraint = getConstraintOfTypeParameter(source); if (constraint && hasNonCircularBaseConstraint(source)) { - while (constraint && constraint.flags & 262144 /* TypeParameter */) { - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) { + while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) { + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { return result; } constraint = getConstraintOfTypeParameter(constraint); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetFlags & 4194304 /* Index */) { + else if (targetFlags & 4194304 /* TypeFlags.Index */) { var targetType_1 = target.type; // A keyof S is related to a keyof T if T is related to S. - if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(targetType_1, source.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } if (isTupleType(targetType_1)) { // An index type can have a tuple type target when the tuple type contains variadic elements. // Check if the source is related to the known keys of the tuple type. - if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -66349,8 +66581,8 @@ var ts; // false positives. For example, given 'T extends { [K in keyof T]: string }', // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when // related to other types. - if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } else if (isGenericMappedType(targetType_1)) { @@ -66365,7 +66597,7 @@ var ts; // missing from the `constraintType` which will otherwise be mapped in the object var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1)); var mappedKeys_1 = []; - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); }); // We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side) targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false)); @@ -66373,21 +66605,20 @@ var ts; else { targetKeys = nameType_1 || constraintType; } - if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, targetKeys, 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } } } - else if (targetFlags & 8388608 /* IndexedAccess */) { - if (sourceFlags & 8388608 /* IndexedAccess */) { + else if (targetFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { // Relate components directly before falling back to constraint relationships // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors); + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } if (reportErrors) { @@ -66402,14 +66633,14 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0); + var accessFlags = 4 /* AccessFlags.Writing */ | (baseObjectType !== objectType ? 2 /* AccessFlags.NoIndexSignatures */ : 0); var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); if (constraint) { if (reportErrors && originalErrorInfo) { // create a new chain for the constraint error resetErrorInfo(saveErrorInfo); } - if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, constraint, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain @@ -66428,12 +66659,12 @@ var ts; var keysRemapped = !!target.declaration.nameType; var templateType = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); - if (!(modifiers & 8 /* ExcludeOptional */)) { + if (!(modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */)) { // If the mapped type has shape `{ [P in Q]: T[P] }`, // source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`. - if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source && + if (!keysRemapped && templateType.flags & 8388608 /* TypeFlags.IndexedAccess */ && templateType.objectType === source && templateType.indexType === getTypeParameterFromMappedType(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!isGenericMappedType(source)) { // If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`. @@ -66441,22 +66672,22 @@ var ts; var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target); // Type of the keys of source type `S`, i.e. `keyof S`. var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true); - var includeOptional = modifiers & 4 /* IncludeOptional */; + var includeOptional = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */; var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined; // A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T. // A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`. if (includeOptional - ? !(filteredByApplicability.flags & 131072 /* Never */) - : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) { + ? !(filteredByApplicability.flags & 131072 /* TypeFlags.Never */) + : isRelatedTo(targetKeys, sourceKeys, 3 /* RecursionFlags.Both */)) { var templateType_1 = getTemplateTypeFromMappedType(target); var typeParameter = getTypeParameterFromMappedType(target); // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj` // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`. - var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */); - if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { - if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) { + var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* TypeFlags.Nullable */); + if (!keysRemapped && nonNullComponent.flags & 8388608 /* TypeFlags.IndexedAccess */ && nonNullComponent.indexType === typeParameter) { + if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -66476,7 +66707,7 @@ var ts; : typeParameter; var indexedAccessType = getIndexedAccessType(source, indexingType); // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type. - if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } @@ -66486,12 +66717,11 @@ var ts; } } } - else if (targetFlags & 16777216 /* Conditional */) { + else if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { - resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } var c = target; // We check for a relationship to a conditional type target only when the conditional type has no @@ -66502,47 +66732,44 @@ var ts; var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType)); // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) - if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) { - result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false); + if (result = skipTrue ? -1 /* Ternary.True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false)) { + result &= skipFalse ? -1 /* Ternary.True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (result) { - resetErrorInfo(saveErrorInfo); return result; } } } } - else if (targetFlags & 134217728 /* TemplateLiteral */) { - if (sourceFlags & 134217728 /* TemplateLiteral */) { + else if (targetFlags & 134217728 /* TypeFlags.TemplateLiteral */) { + if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */) { if (relation === comparableRelation) { - return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */; + return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* Ternary.False */ : -1 /* Ternary.True */; } // Report unreliable variance for type variables referenced in template literal type placeholders. // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + instantiateType(source, reportUnreliableMapper); } if (isTypeMatchedByTemplateLiteralType(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } - else if (target.flags & 268435456 /* StringMapping */) { - if (!(source.flags & 268435456 /* StringMapping */)) { + else if (target.flags & 268435456 /* TypeFlags.StringMapping */) { + if (!(source.flags & 268435456 /* TypeFlags.StringMapping */)) { if (isMemberOfStringMapping(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } } - if (sourceFlags & 8650752 /* TypeVariable */) { + if (sourceFlags & 8650752 /* TypeFlags.TypeVariable */) { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch - if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) { + if (!(sourceFlags & 8388608 /* TypeFlags.IndexedAccess */ && targetFlags & 8388608 /* TypeFlags.IndexedAccess */)) { var constraint = getConstraintOfType(source) || unknownType; // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* RecursionFlags.Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeFlags.TypeParameter */), /*headMessage*/ undefined, intersectionState)) { return result; } if (isMappedTypeGenericIndexedAccess(source)) { @@ -66550,55 +66777,49 @@ var ts; // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X. var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { - if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } } } } - else if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + else if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(keyofConstraintType, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } - else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) { - if (!(targetFlags & 134217728 /* TemplateLiteral */)) { + else if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */ && !(targetFlags & 524288 /* TypeFlags.Object */)) { + if (!(targetFlags & 134217728 /* TypeFlags.TemplateLiteral */)) { var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { - resetErrorInfo(saveErrorInfo); + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { return result; } } } - else if (sourceFlags & 268435456 /* StringMapping */) { - if (targetFlags & 268435456 /* StringMapping */) { + else if (sourceFlags & 268435456 /* TypeFlags.StringMapping */) { + if (targetFlags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol !== target.symbol) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } else { var constraint = getBaseConstraintOfType(source); - if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { - resetErrorInfo(saveErrorInfo); + if (constraint && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { return result; } } } - else if (sourceFlags & 16777216 /* Conditional */) { + else if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { - resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } - if (targetFlags & 16777216 /* Conditional */) { + if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -66607,18 +66828,17 @@ var ts; var mapper = void 0; if (sourceParams) { // If the source has infer type parameters, we instantiate them in the context of the target - var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* InferenceFlags.None */, isRelatedToWorker); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } if (isTypeIdenticalTo(sourceExtends, target.extendsType) && - (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) { - if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors); + (isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* RecursionFlags.Both */))) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -66628,8 +66848,7 @@ var ts; // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { - if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(distributiveConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } @@ -66638,8 +66857,7 @@ var ts; // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!). var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(defaultConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } @@ -66647,31 +66865,30 @@ var ts; else { // An empty object type is related to any mapped type that includes a '?' modifier. if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } - return 0 /* False */; + return 0 /* Ternary.False */; } - var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */); + var sourceIsPrimitive = !!(sourceFlags & 131068 /* TypeFlags.Primitive */); if (relation !== identityRelation) { source = getApparentType(source); sourceFlags = source.flags; } else if (isGenericMappedType(source)) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && source.target === target.target && !isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) { // When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType, // and an empty array literal wouldn't be assignable to a `never[]` without this check. if (isEmptyArrayLiteralType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance @@ -66681,7 +66898,7 @@ var ts; // effectively means we measure variance only from type parameter occurrences that aren't nested in // recursive instantiations of the generic type. if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState); if (varianceResult !== undefined) { @@ -66690,32 +66907,32 @@ var ts; } else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { - return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* RecursionFlags.Both */, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple // or `target` is an array and source is a tuple - in both cases the types cannot be identical, by construction - return 0 /* False */; + return 0 /* Ternary.False */; } } // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` // and not `{} <- fresh({}) <- {[idx: string]: any}` - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source)) { - return 0 /* False */; + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* ObjectFlags.FreshLiteral */ && !isEmptyObjectType(source)) { + return 0 /* Ternary.False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 524288 /* TypeFlags.Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState); if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 0 /* SignatureKind.Call */, reportStructuralErrors); if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 1 /* SignatureKind.Construct */, reportStructuralErrors); if (result) { result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState); } @@ -66732,9 +66949,9 @@ var ts; // there exists a constituent of T for every combination of the discriminants of S // with respect to T. We do not report errors here, as we will use the existing // error result from checking each constituent of the union. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) { - var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); - if (objectOnlyTarget.flags & 1048576 /* Union */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 1048576 /* TypeFlags.Union */) { + var objectOnlyTarget = extractTypesOfKind(target, 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 33554432 /* TypeFlags.Substitution */); + if (objectOnlyTarget.flags & 1048576 /* TypeFlags.Union */) { var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); if (result_9) { return result_9; @@ -66742,7 +66959,7 @@ var ts; } } } - return 0 /* False */; + return 0 /* Ternary.False */; function countMessageChainBreadth(info) { if (!info) return 0; @@ -66752,7 +66969,7 @@ var ts; if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; } - if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { + if (ts.some(variances, function (v) { return !!(v & 24 /* VarianceFlags.AllowsStructuralFallback */); })) { // If some type parameter was `Unmeasurable` or `Unreliable`, and we couldn't pass by assuming it was identical, then we // have to allow a structural fallback check // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially @@ -66779,8 +66996,8 @@ var ts; // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceMask */) === 0 /* Invariant */; }))) { - return 0 /* False */; + if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceFlags.VarianceMask */) === 0 /* VarianceFlags.Invariant */; }))) { + return 0 /* Ternary.False */; } // We remember the original error information so we can restore it in case the structural // comparison unexpectedly succeeds. This can happen when the structural comparison result @@ -66790,18 +67007,6 @@ var ts; } } } - function reportUnmeasurableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false); - } - return p; - } - function reportUnreliableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true); - } - return p; - } // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice // that S and T are contra-variant whereas X and Y are co-variant. @@ -66811,15 +67016,15 @@ var ts; if (modifiersRelated) { var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); - var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) { + var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMapper : reportUnreliableMapper); + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors); + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors); } } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToDiscriminatedType(source, target) { // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. @@ -66834,7 +67039,7 @@ var ts; var sourceProperties = getPropertiesOfType(source); var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); if (!sourcePropertiesFiltered) - return 0 /* False */; + return 0 /* Ternary.False */; // Though we could compute the number of combinations as we generate // the matrix, this would incur additional memory overhead due to // array allocations. To reduce this overhead, we first compute @@ -66846,8 +67051,8 @@ var ts; numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); - return 0 /* False */; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + return 0 /* Ternary.False */; } } // Compute the set of types for each discriminant property. @@ -66856,7 +67061,7 @@ var ts; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); - sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ + sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* TypeFlags.Union */ ? sourcePropertyType.types : [sourcePropertyType]; excludedProperties.add(sourceProperty.escapedName); @@ -66865,11 +67070,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_20 = function (combination) { + var _loop_21 = function (combination) { var hasMatch = false; outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) { var type = _d[_c]; - var _loop_21 = function (i) { + var _loop_22 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfType(type, sourceProperty.escapedName); if (!targetProperty) @@ -66877,7 +67082,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* IntersectionState.None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -66885,7 +67090,7 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_8 = _loop_21(i); + var state_8 = _loop_22(i); switch (state_8) { case "continue-outer": continue outer; } @@ -66894,30 +67099,30 @@ var ts; hasMatch = true; } if (!hasMatch) { - return { value: 0 /* False */ }; + return { value: 0 /* Ternary.False */ }; } }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_7 = _loop_20(combination); + var state_7 = _loop_21(combination); if (typeof state_7 === "object") return state_7.value; } // Compare the remaining non-discriminant properties of each match. - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* None */); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* IntersectionState.None */); if (result) { - result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 0 /* SignatureKind.Call */, /*reportStructuralErrors*/ false); if (result) { - result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 1 /* SignatureKind.Construct */, /*reportStructuralErrors*/ false); if (result && !(isTupleType(source) && isTupleType(type))) { // Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the // element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems // with index type assignability as the types for the excluded discriminants are still included // in the index type. - result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); + result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* IntersectionState.None */); } } } @@ -66944,40 +67149,40 @@ var ts; return result || properties; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { - var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */); var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); var effectiveSource = getTypeOfSourceProperty(sourceProp); - return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source)); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetPropFlags & 16 /* Protected */) { + else if (targetPropFlags & 16 /* ModifierFlags.Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (sourcePropFlags & 16 /* Protected */) { + else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Ensure {readonly a: whatever} is not a subtype of {a: whatever}, // while {a: whatever} is a subtype of {readonly a: whatever}. @@ -66987,7 +67192,7 @@ var ts; // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction if (relation === strictSubtypeRelation && isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // If the target comes from a partial union prop, allow `undefined` in the target type var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState); @@ -66995,10 +67200,10 @@ var ts; if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // When checking for comparability, be more lenient with optional properties. - if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { + if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -67009,7 +67214,7 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } return related; } @@ -67020,7 +67225,7 @@ var ts; && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) && source.symbol - && source.symbol.flags & 32 /* Class */) { + && source.symbol.flags & 32 /* SymbolFlags.Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) { @@ -67062,29 +67267,29 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (isTupleType(target)) { if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); - var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* Rest */ : 4 /* Rest */; - var targetRestFlag = target.target.combinedFlags & 4 /* Rest */; + var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */; + var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */; var sourceMinLength = isTupleType(source) ? source.target.minLength : 0; var targetMinLength = target.target.minLength; if (!sourceRestFlag && sourceArity < targetMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && targetArity < sourceMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { @@ -67095,38 +67300,38 @@ var ts; reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity); } } - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceTypeArguments = getTypeArguments(source); var targetTypeArguments = getTypeArguments(target); - var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* NonRest */) : 0, getStartElementCount(target.target, 11 /* NonRest */)); - var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* NonRest */) : 0); + var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */)); + var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0); var canExcludeDiscriminants = !!excludedProperties; for (var i = 0; i < targetArity; i++) { var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity; - var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* Rest */; + var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */; var targetFlags = target.target.elementFlags[i]; - if (targetFlags & 8 /* Variadic */ && !(sourceFlags & 8 /* Variadic */)) { + if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (sourceFlags & 8 /* Variadic */ && !(targetFlags & 12 /* Variable */)) { + if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) { if (reportErrors) { reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (targetFlags & 1 /* Required */ && !(sourceFlags & 1 /* Required */)) { + if (targetFlags & 1 /* ElementFlags.Required */ && !(sourceFlags & 1 /* ElementFlags.Required */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } // We can only exclude discriminant properties if we have not yet encountered a variable-length element. if (canExcludeDiscriminants) { - if (sourceFlags & 12 /* Variable */ || targetFlags & 12 /* Variable */) { + if (sourceFlags & 12 /* ElementFlags.Variable */ || targetFlags & 12 /* ElementFlags.Variable */) { canExcludeDiscriminants = false; } if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) { @@ -67134,12 +67339,12 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* ElementFlags.Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : - removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); - var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + var targetCheckType = sourceFlags & 8 /* ElementFlags.Variadic */ && targetFlags & 4 /* ElementFlags.Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* ElementFlags.Optional */)); + var related = isRelatedTo(sourceType, targetCheckType, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { @@ -67149,14 +67354,14 @@ var ts; reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i); } } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } - if (target.target.combinedFlags & 12 /* Variable */) { - return 0 /* False */; + if (target.target.combinedFlags & 12 /* ElementFlags.Variable */) { + return 0 /* Ternary.False */; } } var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); @@ -67165,18 +67370,18 @@ var ts; if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) { reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (isObjectLiteralType(target)) { for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) { var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType.flags & 32768 /* Undefined */)) { + if (!(sourceType.flags & 32768 /* TypeFlags.Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } } @@ -67188,12 +67393,12 @@ var ts; for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; var name = targetProp.escapedName; - if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { + if (!(targetProp.flags & 4194304 /* SymbolFlags.Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67202,24 +67407,24 @@ var ts; return result; } function propertiesIdenticalTo(source, target, excludedProperties) { - if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { - return 0 /* False */; + if (!(source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName); if (!targetProp) { - return 0 /* False */; + return 0 /* Ternary.False */; } var related = compareProperties(sourceProp, targetProp, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67231,17 +67436,17 @@ var ts; return signaturesIdenticalTo(source, target, kind); } if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; + return -1 /* Ternary.True */; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { - var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); - var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) { + var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */); + var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */); if (sourceIsAbstract && !targetIsAbstract) { // An abstract constructor type is not assignable to a non-abstract constructor type // as it would otherwise be possible to new an abstract class. Note that the assignability @@ -67250,18 +67455,18 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } - var result = -1 /* True */; - var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; + var result = -1 /* Ternary.True */; + var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; var sourceObjectFlags = ts.getObjectFlags(source); var targetObjectFlags = ts.getObjectFlags(target); - if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol || - sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) { + if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol || + sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters @@ -67269,7 +67474,7 @@ var ts; for (var i = 0; i < targetSignatures.length; i++) { var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67284,10 +67489,10 @@ var ts; var sourceSignature = ts.first(sourceSignatures); var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); - if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* Constructor */)) { + if (!result && reportErrors && kind === 1 /* SignatureKind.Construct */ && (sourceObjectFlags & targetObjectFlags) && + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* SyntaxKind.Constructor */)) { var constructSignatureToString = function (signature) { - return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); + return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */, kind); }; reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature)); reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible); @@ -67313,18 +67518,18 @@ var ts; if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } return result; } function shouldReportUnmatchedPropertyError(source, target) { - var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* Call */); - var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* Construct */); + var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* SignatureKind.Call */); + var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* SignatureKind.Construct */); var typeProperties = getPropertiesOfObjectType(source); if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) { - if ((getSignaturesOfType(target, 0 /* Call */).length && typeCallSignatures.length) || - (getSignaturesOfType(target, 1 /* Construct */).length && typeConstructSignatures.length)) { + if ((getSignaturesOfType(target, 0 /* SignatureKind.Call */).length && typeCallSignatures.length) || + (getSignaturesOfType(target, 1 /* SignatureKind.Construct */).length && typeConstructSignatures.length)) { return true; // target has similar signature kinds to source, still focus on the unmatched property } return false; @@ -67347,45 +67552,45 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* SignatureCheckMode.StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, reportUnreliableMapper); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } function membersRelatedToIndexInfo(source, targetInfo, reportErrors) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var keyType = targetInfo.keyType; - var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); + var props = source.flags & 2097152 /* TypeFlags.Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { var prop = props_2[_i]; // Skip over ignored JSX and symbol-named members if (isIgnoredJsxProperty(source, prop)) { continue; } - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), keyType)) { var propType = getNonMissingTypeOfSymbol(prop); - var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) + var type = exactOptionalPropertyTypes || propType.flags & 32768 /* TypeFlags.Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* SymbolFlags.Optional */) ? propType - : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors); + : getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */); + var related = isRelatedTo(type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67395,7 +67600,7 @@ var ts; if (isApplicableIndexType(info.keyType, keyType)) { var related = indexInfoRelatedTo(info, targetInfo, reportErrors); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67403,7 +67608,7 @@ var ts; return result; } function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { - var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors); + var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related && reportErrors) { if (sourceInfo.keyType === targetInfo.keyType) { reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); @@ -67420,14 +67625,14 @@ var ts; } var indexInfos = getIndexInfosOfType(target); var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; }); - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) { var targetInfo = indexInfos_5[_i]; - var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : - isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) : + var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* TypeFlags.Any */ ? -1 /* Ternary.True */ : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors) : typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67438,46 +67643,46 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } - if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) { + if (!(intersectionState & 1 /* IntersectionState.Source */) && isObjectTypeWithInferableIndex(source)) { // Intersection constituents are never considered to have an inferred index signature return membersRelatedToIndexInfo(source, targetInfo, reportErrors); } if (reportErrors) { reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } function indexSignaturesIdenticalTo(source, target) { var sourceInfos = getIndexInfosOfType(source); var targetInfos = getIndexInfosOfType(target); if (sourceInfos.length !== targetInfos.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) { var targetInfo = targetInfos_1[_i]; var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType); - if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { - return 0 /* False */; + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { + return 0 /* Ternary.False */; } } - return -1 /* True */; + return -1 /* Ternary.True */; } function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. - if (targetAccessibility === 8 /* Private */) { + if (targetAccessibility === 8 /* ModifierFlags.Private */) { return true; } // A public and protected signature is assignable to a protected signature. - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 16 /* ModifierFlags.Protected */ && sourceAccessibility !== 8 /* ModifierFlags.Private */) { return true; } // Only a public signature is assignable to public signature. - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 16 /* ModifierFlags.Protected */ && !sourceAccessibility) { return true; } if (reportErrors) { @@ -67490,19 +67695,19 @@ var ts; // Okay, yes, 'boolean' is a union of 'true | false', but that's not useful // in error reporting scenarios. If you need to use this function but that detail matters, // feel free to add a flag. - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return false; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getConstraintOfType(type); if (constraint && constraint !== type) { return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */); + return isUnitType(type) || !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */); } function getExactOptionalUnassignableProperties(source, target) { if (isTupleType(source) && isTupleType(target)) @@ -67511,7 +67716,7 @@ var ts; .filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); }); } function isExactOptionalPropertyMismatch(source, target) { - return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target); + return !!source && !!target && maybeTypeOfKind(source, 32768 /* TypeFlags.Undefined */) && !!containsMissingType(target); } function getExactOptionalProperties(type) { return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); }); @@ -67531,7 +67736,7 @@ var ts; for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; var targetProp = getUnionOrIntersectionProperty(target, propertyName); - if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) { + if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* CheckFlags.ReadPartial */) { continue; } var i = 0; @@ -67566,12 +67771,12 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && - resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); + resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* SymbolFlags.Optional */); }); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -67587,7 +67792,7 @@ var ts; } function getVariances(type) { // Arrays and tuples are known to be covariant, no need to spend time computing this. - return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */ ? + return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* ObjectFlags.Tuple */ ? arrayVariances : getVariancesWorker(type.symbol, type.typeParameters); } @@ -67603,14 +67808,14 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var links = getSymbolLinks(symbol); if (!links.variances) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; - var _loop_22 = function (tp) { + var _loop_23 = function (tp) { var modifiers = getVarianceModifiers(tp); - var variance = modifiers & 65536 /* Out */ ? - modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : - modifiers & 32768 /* In */ ? 2 /* Contravariant */ : undefined; + var variance = modifiers & 65536 /* ModifierFlags.Out */ ? + modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ : + modifiers & 32768 /* ModifierFlags.In */ ? 2 /* VarianceFlags.Contravariant */ : undefined; if (variance === undefined) { var unmeasurable_1 = false; var unreliable_1 = false; @@ -67621,33 +67826,33 @@ var ts; // invariance, covariance, contravariance or bivariance. var typeWithSuper = createMarkerType(symbol, tp, markerSuperType); var typeWithSub = createMarkerType(symbol, tp, markerSubType); - variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* Covariant */ : 0) | - (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* Contravariant */ : 0); + variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* VarianceFlags.Covariant */ : 0) | + (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* VarianceFlags.Contravariant */ : 0); // If the instantiations appear to be related bivariantly it may be because the // type parameter is independent (i.e. it isn't witnessed anywhere in the generic // type). To determine this we compare instantiations where the type parameter is // replaced with marker types that are known to be unrelated. - if (variance === 3 /* Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; + if (variance === 3 /* VarianceFlags.Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { + variance = 4 /* VarianceFlags.Independent */; } outofbandVarianceMarkerHandler = oldHandler; if (unmeasurable_1 || unreliable_1) { if (unmeasurable_1) { - variance |= 8 /* Unmeasurable */; + variance |= 8 /* VarianceFlags.Unmeasurable */; } if (unreliable_1) { - variance |= 16 /* Unreliable */; + variance |= 16 /* VarianceFlags.Unreliable */; } } } variances.push(variance); }; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - _loop_22(tp); + for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { + var tp = typeParameters_2[_i]; + _loop_23(tp); } links.variances = variances; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) }); } return links.variances; } @@ -67657,7 +67862,7 @@ var ts; if (isErrorType(type)) { return type; } - var result = symbol.flags & 524288 /* TypeAlias */ ? + var result = symbol.flags & 524288 /* SymbolFlags.TypeAlias */ ? getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) : createTypeReference(type, instantiateTypes(type.typeParameters, mapper)); markerTypes.add(getTypeId(result)); @@ -67668,34 +67873,34 @@ var ts; } function getVarianceModifiers(tp) { var _a, _b; - return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* In */); }) ? 32768 /* In */ : 0) | - (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* Out */); }) ? 65536 /* Out */ : 0); + return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* ModifierFlags.In */); }) ? 32768 /* ModifierFlags.In */ : 0) | + (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* ModifierFlags.Out */); }) ? 65536 /* ModifierFlags.Out */ : 0); } // Return true if the given type reference has a 'void' type argument for a covariant type parameter. // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(typeArguments, variances) { for (var i = 0; i < variances.length; i++) { - if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) { + if ((variances[i] & 7 /* VarianceFlags.VarianceMask */) === 1 /* VarianceFlags.Covariant */ && typeArguments[i].flags & 16384 /* TypeFlags.Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeFlags.TypeParameter */ && !getConstraintOfTypeParameter(type); } function isNonDeferredTypeReference(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeFlags.TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) { var typeParameters = []; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); // getTypeReferenceId(A) returns "111=0-12=1" // where A.id=111 and number.id=12 function getTypeReferenceId(type, depth) { @@ -67703,7 +67908,7 @@ var ts; var result = "" + type.target.id; for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { if (ignoreConstraints || isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); if (index < 0) { @@ -67739,12 +67944,12 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (ts.getCheckFlags(prop) & 6 /* Synthetic */) { + if (ts.getCheckFlags(prop) & 6 /* CheckFlags.Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.escapedName); @@ -67759,7 +67964,7 @@ var ts; } // Return the declaring class type of a property or undefined if property not declared in class function getDeclaringClass(prop) { - return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + return prop.parent && prop.parent.flags & 32 /* SymbolFlags.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) { @@ -67777,13 +67982,13 @@ var ts; } // Return true if source property is a valid override of protected parts of target property. function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* ModifierFlags.Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); } // Return true if the given class derives from each of the declaring classes of the protected // constituents of the given property. function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* ModifierFlags.Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons @@ -67829,14 +68034,14 @@ var ts; // reference the type have a recursion identity that differs from the object identity. function getRecursionIdentity(type) { // Object and array literals are known not to contain recursive references and don't need a recursion identity. - if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { - if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { + if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) { + if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) { // Deferred type references are tracked through their associated AST node. This gives us finer // granularity than using their associated target because each manifest type reference has a // unique AST node. return type.node; } - if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) { // We track all object types that have an associated symbol (representing the origin of the type), but // exclude the static side of classes from this check since it shares its symbol with the instance side. return type.symbol; @@ -67846,49 +68051,49 @@ var ts; return type.target; } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { return type.symbol; } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { type = type.objectType; - } while (type.flags & 8388608 /* IndexedAccess */); + } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */); return type; } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { // The root object represents the origin of the conditional type return type.root; } return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; + return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */; } function compareProperties(sourceProp, targetProp, compareTypes) { // Two members are considered identical when // - they are public properties with identical names, optionality, and types, // - they are private or protected properties originating in the same declaration and having identical types if (sourceProp === targetProp) { - return -1 /* True */; + return -1 /* Ternary.True */; } - var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; + var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (sourcePropAccessibility) { if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } else { - if ((sourceProp.flags & 16777216 /* Optional */) !== (targetProp.flags & 16777216 /* Optional */)) { - return 0 /* False */; + if ((sourceProp.flags & 16777216 /* SymbolFlags.Optional */) !== (targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { + return 0 /* Ternary.False */; } } if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -67919,14 +68124,14 @@ var ts; function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!(isMatchingSignature(source, target, partialMatch))) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that the two signatures have the same number of type parameters. if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that type parameter constraints and defaults match. If they do, instantiate the source // signature with the type parameters of the target signature and continue the comparison. @@ -67937,12 +68142,12 @@ var ts; var t = target.typeParameters[i]; if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) { - return 0 /* False */; + return 0 /* Ternary.False */; } } source = instantiateSignature(source, mapper, /*eraseTypeParameters*/ true); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (!ignoreThisTypes) { var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType) { @@ -67950,7 +68155,7 @@ var ts; if (targetThisType) { var related = compareTypes(sourceThisType, targetThisType); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67962,7 +68167,7 @@ var ts; var t = getTypeAtPosition(target, i); var related = compareTypes(t, s); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67976,56 +68181,52 @@ var ts; return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : - source.type === target.type ? -1 /* True */ : + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* Ternary.False */ : + source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + 0 /* Ternary.False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - var baseType = getBaseTypeOfLiteralType(t); - if (!commonBaseType) { - commonBaseType = baseType; - } - if (baseType === t || baseType !== commonBaseType) { - return false; + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + var baseType = getBaseTypeOfLiteralType(t); + commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType); + if (baseType === t || baseType !== commonBaseType) { + return false; + } } } return true; } - // When the candidate types are all literal types with the same base type, return a union - // of those literal types. Otherwise, return the leftmost type for which no type to the - // right is a supertype. - function getSupertypeOrUnion(types) { - if (types.length === 1) { - return types[0]; - } - return literalTypesWithSameBaseType(types) ? - getUnionType(types) : - ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + function getCombinedTypeFlags(types) { + return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 /* TypeFlags.Union */ ? getCombinedTypeFlags(t.types) : t.flags); }, 0); } function getCommonSupertype(types) { - if (!strictNullChecks) { - return getSupertypeOrUnion(types); - } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (primaryTypes.length) { - var supertypeOrUnion = getSupertypeOrUnion(primaryTypes); - return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true)); + if (types.length === 1) { + return types[0]; } - return getUnionType(types, 2 /* Subtype */); + // Remove nullable types from each of the candidates. + var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304 /* TypeFlags.Nullable */); }); }) : types; + // When the candidate types are all literal types with the same base type, return a union + // of those literal types. Otherwise, return the leftmost type for which no type to the + // right is a supertype. + var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? + getUnionType(primaryTypes) : + ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + // Add any nullable types that occurred in the candidates back to the result. + return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* TypeFlags.Nullable */); } // Return the leftmost type for which no type to the right is a subtype. function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); } function isReadonlyArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && type.target === globalReadonlyArrayType; } function isArrayOrTupleType(type) { return isArrayType(type) || isTupleType(type); @@ -68039,22 +68240,22 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || !(type.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function getSingleBaseForNonAugmentingSubtype(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ObjectFlags.ClassOrInterface */)) { return undefined; } - if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { - return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + if (ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* ObjectFlags.IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; } - type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + type.objectFlags |= 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */; var target = type.target; - if (ts.getObjectFlags(target) & 1 /* Class */) { + if (ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { var baseTypeNode = getBaseTypeNodeOfClass(target); // A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only // check for base types specified as simple qualified names. - if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 206 /* PropertyAccessExpression */) { + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* SyntaxKind.Identifier */ && baseTypeNode.expression.kind !== 206 /* SyntaxKind.PropertyAccessExpression */) { return undefined; } } @@ -68069,7 +68270,7 @@ var ts; if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); } - type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + type.objectFlags |= 67108864 /* ObjectFlags.IdenticalBaseTypeExists */; return type.cachedEquivalentBaseType = instantiatedBase; } function isEmptyLiteralType(type) { @@ -68096,44 +68297,49 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); + return !(type.flags & (109440 /* TypeFlags.Unit */ | 131072 /* TypeFlags.Never */)); } function isUnitType(type) { - return !!(type.flags & 109440 /* Unit */); + return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : - !!(type.flags & 109440 /* Unit */); + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* TypeFlags.Unit */); } function extractUnitType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type; + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; } function isLiteralType(type) { - return type.flags & 16 /* Boolean */ ? true : - type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + return type.flags & 16 /* TypeFlags.Boolean */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? type.flags & 1024 /* TypeFlags.EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 512 /* BooleanLiteral */ ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? getBaseTypeOfLiteralTypeUnion(type) : type; } + function getBaseTypeOfLiteralTypeUnion(type) { + var _a; + var key = "B".concat(getTypeId(type)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType)); + } function getWidenedLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : - type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : - type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : - type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* TypeFlags.StringLiteral */ && isFreshLiteralType(type) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ && isFreshLiteralType(type) ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedLiteralType) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -68164,10 +68370,10 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required. */ function isTupleType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target.objectFlags & 8 /* ObjectFlags.Tuple */); } function isGenericTupleType(type) { - return isTupleType(type) && !!(type.target.combinedFlags & 8 /* Variadic */); + return isTupleType(type) && !!(type.target.combinedFlags & 8 /* ElementFlags.Variadic */); } function isSingleElementGenericTupleType(type) { return isGenericTupleType(type) && type.target.elementFlags.length === 1; @@ -68188,7 +68394,7 @@ var ts; var elementTypes = []; for (var i = index; i < length; i++) { var t = typeArguments[i]; - elementTypes.push(type.target.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t); + elementTypes.push(type.target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t); } return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes); } @@ -68196,28 +68402,28 @@ var ts; } function isTupleTypeStructureMatching(t1, t2) { return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && - ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */); }); + ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* ElementFlags.Variable */) === (t2.target.elementFlags[i] & 12 /* ElementFlags.Variable */); }); } function isZeroBigInt(_a) { var value = _a.value; return value.base10Value === "0"; } function removeDefinitelyFalsyTypes(type) { - return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* Truthy */); }); + return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* TypeFacts.Truthy */); }); } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 4 /* String */ ? emptyStringType : - type.flags & 8 /* Number */ ? zeroType : - type.flags & 64 /* BigInt */ ? zeroBigIntType : + return type.flags & 4 /* TypeFlags.String */ ? emptyStringType : + type.flags & 8 /* TypeFlags.Number */ ? zeroType : + type.flags & 64 /* TypeFlags.BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || - type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || - type.flags & 128 /* StringLiteral */ && type.value === "" || - type.flags & 256 /* NumberLiteral */ && type.value === 0 || - type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + type.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */ | 3 /* TypeFlags.AnyOrUnknown */) || + type.flags & 128 /* TypeFlags.StringLiteral */ && type.value === "" || + type.flags & 256 /* TypeFlags.NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isZeroBigInt(type) ? type : neverType; } /** @@ -68226,27 +68432,27 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */); return missing === 0 ? type : - missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 65536 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* TypeFlags.Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* TypeFlags.Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type, isProperty) { if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); + return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { - deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; + deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* SymbolFlags.TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) : getIntersectionType([type, emptyObjectType]); } function getNonNullableType(type) { - return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function addOptionalTypeMarker(type) { return strictNullChecks ? getUnionType([type, optionalType]) : type; @@ -68266,10 +68472,10 @@ var ts; return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type; } function containsMissingType(type) { - return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, missingType)); } function removeMissingOrUndefinedType(type) { - return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */); + return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */); } /** * Is source potentially coercible to target type under `==`. @@ -68292,8 +68498,8 @@ var ts; * @param target */ function isCoercibleUnderDoubleEquals(source, target) { - return ((source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0) - && ((target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0); + return ((source.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 512 /* TypeFlags.BooleanLiteral */)) !== 0) + && ((target.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 16 /* TypeFlags.Boolean */)) !== 0); } /** * Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module @@ -68301,15 +68507,15 @@ var ts; */ function isObjectTypeWithInferableIndex(type) { var objectFlags = ts.getObjectFlags(type); - return type.flags & 2097152 /* Intersection */ + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol - && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 - && !(type.symbol.flags & 32 /* Class */) - && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + && (type.symbol.flags & (4096 /* SymbolFlags.ObjectLiteral */ | 2048 /* SymbolFlags.TypeLiteral */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !== 0 + && !(type.symbol.flags & 32 /* SymbolFlags.Class */) + && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectFlags.ObjectRestType */) || !!(objectFlags & 1024 /* ObjectFlags.ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { - var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); + var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* CheckFlags.Readonly */); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -68339,7 +68545,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* ObjectFlags.FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -68350,7 +68556,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~8192 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~8192 /* ObjectFlags.FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -68380,7 +68586,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) { var t = _a[_i]; - if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ObjectFlags.ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -68392,7 +68598,7 @@ var ts; return context.resolvedProperties; } function getWidenedProperty(prop, context) { - if (!(prop.flags & 4 /* Property */)) { + if (!(prop.flags & 4 /* SymbolFlags.Property */)) { // Since get accessors already widen their return value there is no need to // widen accessor based properties here. return prop; @@ -68408,7 +68614,7 @@ var ts; return cached; } var result = createSymbolWithType(prop, missingType); - result.flags |= 16777216 /* Optional */; + result.flags |= 16777216 /* SymbolFlags.Optional */; undefinedProperties.set(prop.escapedName, result); return result; } @@ -68427,33 +68633,33 @@ var ts; } } var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); })); - result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* JSLiteral */ | 262144 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */)); // Retain js literal flag through widening return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 196608 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } var result = void 0; - if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) { + if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) { result = anyType; } else if (isObjectLiteralType(type)) { result = getWidenedTypeOfObjectLiteral(type, context); } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayOrTupleType(type)) { @@ -68479,8 +68685,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 65536 /* ContainsWideningType */) { - if (type.flags & 1048576 /* Union */) { + if (ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -68505,7 +68711,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (ts.getObjectFlags(t) & 65536 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 65536 /* ObjectFlags.ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -68524,17 +68730,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 221 /* BinaryExpression */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 221 /* SyntaxKind.BinaryExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* SymbolFlags.Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : ""); @@ -68545,25 +68751,25 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (noImplicitAny && !declaration.name) { - if (wideningKind === 3 /* GeneratorYield */) { + if (wideningKind === 3 /* WideningKind.GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); } else { @@ -68572,10 +68778,10 @@ var ts; return; } diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage : - wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : + wideningKind === 3 /* WideningKind.GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -68587,7 +68793,7 @@ var ts; } function reportErrorsFromWidening(declaration, type, wideningKind) { addLazyDiagnostic(function () { - if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -68639,27 +68845,29 @@ var ts; signature: signature, flags: flags, compareTypes: compareTypes, - mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ true); }), - nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ false); }), + mapper: reportUnmeasurableMapper, + nonFixingMapper: reportUnmeasurableMapper, }; + context.mapper = makeFixingMapperForContext(context); + context.nonFixingMapper = makeNonFixingMapperForContext(context); return context; } - function mapToInferredType(context, t, fix) { - var inferences = context.inferences; - for (var i = 0; i < inferences.length; i++) { - var inference = inferences[i]; - if (t === inference.typeParameter) { - if (fix && !inference.isFixed) { - // Before we commit to a particular inference (and thus lock out any further inferences), - // we infer from any intra-expression inference sites we have collected. - inferFromIntraExpressionSites(context); - clearCachedInferences(inferences); - inference.isFixed = true; - } - return getInferredType(context, i); + function makeFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (inference, i) { return function () { + if (!inference.isFixed) { + // Before we commit to a particular inference (and thus lock out any further inferences), + // we infer from any intra-expression inference sites we have collected. + inferFromIntraExpressionSites(context); + clearCachedInferences(context.inferences); + inference.isFixed = true; } - } - return t; + return getInferredType(context, i); + }; })); + } + function makeNonFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (_, i) { return function () { + return getInferredType(context, i); + }; })); } function clearCachedInferences(inferences) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { @@ -68690,9 +68898,9 @@ var ts; if (context.intraExpressionInferenceSites) { for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) { var _b = _a[_i], node = _b.node, type = _b.type; - var contextualType = node.kind === 169 /* MethodDeclaration */ ? - getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : - getContextualType(node, 2 /* NoConstraints */); + var contextualType = node.kind === 169 /* SyntaxKind.MethodDeclaration */ ? + getContextualTypeForObjectLiteralMethod(node, 2 /* ContextFlags.NoConstraints */) : + getContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { inferTypes(context.inferences, type, contextualType); } @@ -68738,40 +68946,40 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 1048576 /* CouldContainTypeVariables */); + if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */); } - var result = !!(type.flags & 465829888 /* Instantiable */ || - 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 */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); - if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0); + var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ || + type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); + if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) { + type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SourceFile */ ? true : n.kind === 261 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SyntaxKind.SourceFile */ ? true : n.kind === 261 /* SyntaxKind.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); }) || - type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || + type.flags & 16777216 /* TypeFlags.Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 128 /* StringLiteral */)) { + if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); - var literalProp = createSymbol(4 /* Property */, name); + var literalProp = createSymbol(4 /* SymbolFlags.Property */, name); literalProp.type = anyType; if (t.symbol) { literalProp.declarations = t.symbol.declarations; @@ -68779,7 +68987,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; + var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos); } /** @@ -68807,7 +69015,7 @@ var ts; // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 262144 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 262144 /* ObjectFlags.NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -68824,14 +69032,14 @@ var ts; } if (isTupleType(source)) { var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); - var elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? - ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var elementFlags = getMappedTypeModifiers(target) & 4 /* MappedTypeModifiers.IncludeOptional */ ? + ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : source.target.elementFlags; return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations); } // For all other object types we infer a new object type where the reverse mapping has been // applied to the type of each property. - var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ObjectFlags.ReverseMapped */ | 16 /* ObjectFlags.Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; @@ -68866,7 +69074,7 @@ var ts; if (isStaticPrivateIdentifierProperty(targetProp)) { return [3 /*break*/, 5]; } - if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */))) return [3 /*break*/, 5]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */))) return [3 /*break*/, 5]; sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!!sourceProp) return [3 /*break*/, 3]; return [4 /*yield*/, targetProp]; @@ -68876,9 +69084,9 @@ var ts; case 3: if (!matchDiscriminantProperties) return [3 /*break*/, 5]; targetType = getTypeOfSymbol(targetProp); - if (!(targetType.flags & 109440 /* Unit */)) return [3 /*break*/, 5]; + if (!(targetType.flags & 109440 /* TypeFlags.Unit */)) return [3 /*break*/, 5]; sourceType = getTypeOfSymbol(sourceProp); - if (!!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; + if (!!(sourceType.flags & 1 /* TypeFlags.Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; return [4 /*yield*/, targetProp]; case 4: _a.sent(); @@ -68896,7 +69104,7 @@ var ts; return result.value; } function tupleTypesDefinitelyUnrelated(source, target) { - return !(target.target.combinedFlags & 8 /* Variadic */) && target.target.minLength > source.target.minLength || + return !(target.target.combinedFlags & 8 /* ElementFlags.Variadic */) && target.target.minLength > source.target.minLength || !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength); } function typesDefinitelyUnrelated(source, target) { @@ -68907,7 +69115,7 @@ var ts; !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false); } function getTypeFromInference(inference) { - return inference.candidates ? getUnionType(inference.candidates, 2 /* Subtype */) : + return inference.candidates ? getUnionType(inference.candidates, 2 /* UnionReduction.Subtype */) : inference.contraCandidates ? getIntersectionType(inference.contraCandidates) : undefined; } @@ -68944,7 +69152,7 @@ var ts; */ function parseBigIntLiteralType(text) { var negative = text.startsWith("-"); - var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n"); + var base10Value = ts.parsePseudoBigInt("".concat(negative ? text.slice(1) : text, "n")); return getBigIntLiteralType({ negative: negative, base10Value: base10Value }); } /** @@ -68955,12 +69163,12 @@ var ts; function isValidBigIntString(s, roundTripOnly) { if (s === "") return false; - var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.ESNext */, /*skipTrivia*/ false); var success = true; scanner.setOnError(function () { return success = false; }); scanner.setText(s + "n"); var result = scanner.scan(); - var negative = result === 40 /* MinusToken */; + var negative = result === 40 /* SyntaxKind.MinusToken */; if (negative) { result = scanner.scan(); } @@ -68970,17 +69178,17 @@ var ts; // * a bigint can be scanned, and that when it is scanned, it is // * the full length of the input string (so the scanner is one character beyond the augmented input length) // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) - return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */) + return success && result === 9 /* SyntaxKind.BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* TokenFlags.ContainsSeparator */) && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) })); } function isMemberOfStringMapping(source, target) { - if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) { + if (target.flags & (4 /* TypeFlags.String */ | 3 /* TypeFlags.AnyOrUnknown */)) { return true; } - if (target.flags & 134217728 /* TemplateLiteral */) { + if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { return isTypeAssignableTo(source, target); } - if (target.flags & 268435456 /* StringMapping */) { + if (target.flags & 268435456 /* TypeFlags.StringMapping */) { // We need to see whether applying the same mappings of the target // onto the source would produce an identical type *and* that // it's compatible with the inner-most non-string-mapped type. @@ -68989,7 +69197,7 @@ var ts; // and the source is compatible with the unmapped target, then they must // still reside in the same domain. var mappingStack = []; - while (target.flags & 268435456 /* StringMapping */) { + while (target.flags & 268435456 /* TypeFlags.StringMapping */) { mappingStack.unshift(target.symbol); target = target.type; } @@ -68999,25 +69207,25 @@ var ts; return false; } function isValidTypeForTemplateLiteralPlaceholder(source, target) { - if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + if (source === target || target.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)) { return true; } - if (source.flags & 128 /* StringLiteral */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */) { var value = source.value; - return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) || - target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) || - target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName || - target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target)); + return !!(target.flags & 8 /* TypeFlags.Number */ && isValidNumberString(value, /*roundTripOnly*/ false) || + target.flags & 64 /* TypeFlags.BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) || + target.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) && value === target.intrinsicName || + target.flags & 268435456 /* TypeFlags.StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target)); } - if (source.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts = source.texts; return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target); } return isTypeAssignableTo(source, target); } function inferTypesFromTemplateLiteralType(source, target) { - return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : - source.flags & 134217728 /* TemplateLiteral */ ? + return source.flags & 128 /* TypeFlags.StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : undefined; @@ -69027,7 +69235,7 @@ var ts; return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); }); } function getStringLikeTypeForType(type) { - return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); + return type.flags & (1 /* TypeFlags.Any */ | 402653316 /* TypeFlags.StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); } // This function infers from the text parts and type parts of a source literal to a target template literal. The number // of text parts is always one more than the number of type parts, and a source string literal is treated as a source @@ -69109,12 +69317,12 @@ var ts; if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 2048 /* MaxValue */; + var inferencePriority = 2048 /* InferencePriority.MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; var targetStack; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { if (!couldContainTypeVariables(target)) { @@ -69130,13 +69338,16 @@ var ts; propagationType = savePropagationType; return; } - if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - // Source and target are types originating in the same generic type alias declaration. - // Simply infer from source type arguments to target type arguments. - inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) { + if (source.aliasTypeArguments) { + // Source and target are types originating in the same generic type alias declaration. + // Simply infer from source type arguments to target type arguments. + inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + } + // And if there weren't any type arguments, there's no reason to run inference as the types must be the same. return; } - if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + if (source === target && source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { // When source and target are the same union or intersection type, just relate each constituent // type to itself. for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -69145,10 +69356,10 @@ var ts; } return; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { // First, infer between identically matching source and target constituents and remove the // matching types. - var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _b = inferFromMatchingTypes(source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; // Next, infer between closely matching source and target constituents and remove // the matching types. Types closely match when they are instantiations of the same // object type or instantiations of the same type alias. @@ -69163,21 +69374,21 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - inferWithPriority(source, target, 1 /* NakedTypeVariable */); + inferWithPriority(source, target, 1 /* InferencePriority.NakedTypeVariable */); return; } source = getUnionType(sources); } - else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + else if (target.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { // We reduce intersection types only when they contain naked type parameters. For example, when // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the // string[] on the source side and infer string for T. // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" // in such scenarios. - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { // Infer between identically matching source and target constituents and remove the matching types. - var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + var _d = inferFromMatchingTypes(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; if (sources.length === 0 || targets.length === 0) { return; } @@ -69185,23 +69396,31 @@ var ts; target = getIntersectionType(targets); } } - else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { + else if (target.flags & (8388608 /* TypeFlags.IndexedAccess */ | 33554432 /* TypeFlags.Substitution */)) { target = getActualTypeVariable(target); } - if (target.flags & 8650752 /* TypeVariable */) { - // If target is a type parameter, make an inference, unless the source type contains - // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). - // Because the anyFunctionType is internal, it should not be exposed to the user by adding - // it as an inference candidate. Hopefully, a better candidate will come along that does - // not contain anyFunctionType when we come back to this argument for its second round - // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard - // when constructing types from type parameters that had no inference candidates). - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (target.flags & 8650752 /* TypeFlags.TypeVariable */) { + // Skip inference if the source is "blocked", which is used by the language service to + // prevent inference on nodes currently being edited. + if (isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); if (inference) { - if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) { + // If target is a type parameter, make an inference, unless the source type contains + // a "non-inferrable" type. Types with this flag set are markers used to prevent inference. + // + // For example: + // - anyFunctionType is a wildcard type that's used to avoid contextually typing functions; + // it's internal, so should not be exposed to the user by adding it as a candidate. + // - autoType (and autoArrayType) is a special "any" used in control flow; like anyFunctionType, + // it's internal and should not be observable. + // - silentNeverType is returned by getInferredType when instantiating a generic function for + // inference (and a type variable has no mapping). + // + // This flag is infectious; if we produce Box (where never is silentNeverType), Box is + // also non-inferrable. + if (ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */) { return; } if (!inference.isFixed) { @@ -69226,7 +69445,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* InferencePriority.ReturnType */) && target.flags & 262144 /* TypeFlags.TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -69239,11 +69458,11 @@ var ts; if (simplified !== target) { inferFromTypes(source, simplified); } - else if (target.flags & 8388608 /* IndexedAccess */) { + else if (target.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexType = getSimplifiedType(target.indexType, /*writing*/ false); // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can. - if (indexType.flags & 465829888 /* Instantiable */) { + if (indexType.flags & 465829888 /* TypeFlags.Instantiable */) { var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false); if (simplified_1 && simplified_1 !== target) { inferFromTypes(source, simplified_1); @@ -69251,45 +69470,38 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } - else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { - contravariant = !contravariant; - inferFromTypes(source.type, target.type); - contravariant = !contravariant; + else if (source.flags & 4194304 /* TypeFlags.Index */ && target.flags & 4194304 /* TypeFlags.Index */) { + inferFromContravariantTypes(source.type, target.type); } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* TypeFlags.String */) && target.flags & 4194304 /* TypeFlags.Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); - contravariant = !contravariant; - inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); - contravariant = !contravariant; + inferFromContravariantTypesWithPriority(empty, target.type, 256 /* InferencePriority.LiteralKeyof */); } - else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { + else if (source.flags & 8388608 /* TypeFlags.IndexedAccess */ && target.flags & 8388608 /* TypeFlags.IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) { + else if (source.flags & 268435456 /* TypeFlags.StringMapping */ && target.flags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol === target.symbol) { inferFromTypes(source.type, target.type); } } - else if (source.flags & 33554432 /* Substitution */) { + else if (source.flags & 33554432 /* TypeFlags.Substitution */) { inferFromTypes(source.baseType, target); - var oldPriority = priority; - priority |= 4 /* SubstituteSource */; - inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority - priority = oldPriority; + inferWithPriority(source.substitute, target, 4 /* InferencePriority.SubstituteSource */); // Make substitute inference at a lower priority } - else if (target.flags & 16777216 /* Conditional */) { + else if (target.flags & 16777216 /* TypeFlags.Conditional */) { invokeOnce(source, target, inferToConditionalType); } - else if (target.flags & 3145728 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } - else if (source.flags & 1048576 /* Union */) { + else if (source.flags & 1048576 /* TypeFlags.Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) { @@ -69297,17 +69509,17 @@ var ts; inferFromTypes(sourceType, target); } } - else if (target.flags & 134217728 /* TemplateLiteral */) { + else if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { inferToTemplateLiteralType(source, target); } else { source = getReducedType(source); - if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* InferencePriority.NoConstraints */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` // with the simplified source. - if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */))) { // TODO: The `allowComplexConstraintInference` flag is a hack! This forbids inference from complex constraints within constraints! // This isn't required algorithmically, but rather is used to lower the memory burden caused by performing inference // that is _too good_ in projects with complicated constraints (eg, fp-ts). In such cases, if we did not limit ourselves @@ -69320,7 +69532,7 @@ var ts; } source = apparentSource; } - if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { invokeOnce(source, target, inferFromObjectTypes); } } @@ -69331,6 +69543,18 @@ var ts; inferFromTypes(source, target); priority = savePriority; } + function inferFromContravariantTypesWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromContravariantTypes(source, target); + priority = savePriority; + } + function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferToMultipleTypes(source, targets, targetFlags); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -69338,19 +69562,19 @@ var ts; inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); + (visited || (visited = new ts.Map())).set(key, -1 /* InferencePriority.Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. var saveExpandingFlags = expandingFlags; var sourceIdentity = getRecursionIdentity(source); var targetIdentity = getRecursionIdentity(target); if (ts.contains(sourceStack, sourceIdentity)) - expandingFlags |= 1 /* Source */; + expandingFlags |= 1 /* ExpandingFlags.Source */; if (ts.contains(targetStack, targetIdentity)) - expandingFlags |= 2 /* Target */; - if (expandingFlags !== 3 /* Both */) { + expandingFlags |= 2 /* ExpandingFlags.Target */; + if (expandingFlags !== 3 /* ExpandingFlags.Both */) { (sourceStack || (sourceStack = [])).push(sourceIdentity); (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); @@ -69358,7 +69582,7 @@ var ts; sourceStack.pop(); } else { - inferencePriority = -1 /* Circularity */; + inferencePriority = -1 /* InferencePriority.Circularity */; } expandingFlags = saveExpandingFlags; visited.set(key, inferencePriority); @@ -69386,7 +69610,7 @@ var ts; function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; for (var i = 0; i < count; i++) { - if (i < variances.length && (variances[i] & 7 /* VarianceMask */) === 2 /* Contravariant */) { + if (i < variances.length && (variances[i] & 7 /* VarianceFlags.VarianceMask */) === 2 /* VarianceFlags.Contravariant */) { inferFromContravariantTypes(sourceTypes[i], targetTypes[i]); } else { @@ -69395,17 +69619,20 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { - contravariant = !contravariant; - inferFromTypes(source, target); - contravariant = !contravariant; + contravariant = !contravariant; + inferFromTypes(source, target); + contravariant = !contravariant; + } + function inferFromContravariantTypesIfStrictFunctionTypes(source, target) { + if (strictFunctionTypes || priority & 1024 /* InferencePriority.AlwaysStrict */) { + inferFromContravariantTypes(source, target); } else { inferFromTypes(source, target); } } function getInferenceInfoForType(type) { - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) { var inference = inferences_2[_i]; if (type === inference.typeParameter) { @@ -69419,7 +69646,7 @@ var ts; var typeVariable; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var type = types_14[_i]; - var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + var t = type.flags & 2097152 /* TypeFlags.Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; } @@ -69429,9 +69656,9 @@ var ts; } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; - if (targetFlags & 1048576 /* Union */) { + if (targetFlags & 1048576 /* TypeFlags.Union */) { var nakedTypeVariable = void 0; - var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; + var sources = source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we @@ -69447,11 +69674,11 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; - inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* InferencePriority.Circularity */; inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } @@ -69462,7 +69689,7 @@ var ts; // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); if (intersectionTypeVariable) { - inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + inferWithPriority(source, intersectionTypeVariable, 1 /* InferencePriority.NakedTypeVariable */); } return; } @@ -69496,17 +69723,17 @@ var ts; // less specific. For example, when inferring from Promise to T | Promise, // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. - if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { + if (targetFlags & 2097152 /* TypeFlags.Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferWithPriority(source, t, 1 /* NakedTypeVariable */); + inferWithPriority(source, t, 1 /* InferencePriority.NakedTypeVariable */); } } } } function inferToMappedType(source, target, constraintType) { - if (constraintType.flags & 1048576 /* Union */) { + if (constraintType.flags & 1048576 /* TypeFlags.Union */) { var result = false; for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { var type = _a[_i]; @@ -69514,7 +69741,7 @@ var ts; } return result; } - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -69526,17 +69753,17 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* NonInferrableType */ ? - 16 /* PartialHomomorphicMappedType */ : - 8 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */ ? + 16 /* InferencePriority.PartialHomomorphicMappedType */ : + 8 /* InferencePriority.HomomorphicMappedType */); } } return true; } - if (constraintType.flags & 262144 /* TypeParameter */) { + if (constraintType.flags & 262144 /* TypeFlags.TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* InferencePriority.MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -69555,18 +69782,15 @@ var ts; return false; } function inferToConditionalType(source, target) { - if (source.flags & 16777216 /* Conditional */) { + if (source.flags & 16777216 /* TypeFlags.Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } else { - var savePriority = priority; - priority |= contravariant ? 64 /* ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; - inferToMultipleTypes(source, targetTypes, target.flags); - priority = savePriority; + inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 /* InferencePriority.ContravariantConditional */ : 0); } } function inferToTemplateLiteralType(source, target) { @@ -69579,47 +69803,47 @@ var ts; // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might // succeed. That would be a pointless and confusing outcome. if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) { - var _loop_23 = function (i) { + var _loop_24 = function (i) { var source_1 = matches ? matches[i] : neverType; var target_3 = types[i]; // If we are inferring from a string literal type to a type variable whose constraint includes one of the // allowed template literal placeholder types, infer from a literal type corresponding to the constraint. - if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) { + if (source_1.flags & 128 /* TypeFlags.StringLiteral */ && target_3.flags & 8650752 /* TypeFlags.TypeVariable */) { var inferenceContext = getInferenceInfoForType(target_3); var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined; if (constraint && !isTypeAny(constraint)) { - var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint]; + var constraintTypes = constraint.flags & 1048576 /* TypeFlags.Union */ ? constraint.types : [constraint]; var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0); // If the constraint contains `string`, we don't need to look for a more preferred type - if (!(allTypeFlags_1 & 4 /* String */)) { + if (!(allTypeFlags_1 & 4 /* TypeFlags.String */)) { var str_1 = source_1.value; // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers - if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) { - allTypeFlags_1 &= ~296 /* NumberLike */; + if (allTypeFlags_1 & 296 /* TypeFlags.NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) { + allTypeFlags_1 &= ~296 /* TypeFlags.NumberLike */; } // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints - if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) { - allTypeFlags_1 &= ~2112 /* BigIntLike */; + if (allTypeFlags_1 & 2112 /* TypeFlags.BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) { + allTypeFlags_1 &= ~2112 /* TypeFlags.BigIntLike */; } // for each type in the constraint, find the highest priority matching type var matchingType = ts.reduceLeft(constraintTypes, function (left, right) { return !(right.flags & allTypeFlags_1) ? left : - left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 : - left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 : - left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 : - left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right : - left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) : - left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) : - left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right : - left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) : - left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right : - left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType : - left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right : - left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right : - left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right : + left.flags & 4 /* TypeFlags.String */ ? left : right.flags & 4 /* TypeFlags.String */ ? source_1 : + left.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? left : right.flags & 134217728 /* TypeFlags.TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 : + left.flags & 268435456 /* TypeFlags.StringMapping */ ? left : right.flags & 268435456 /* TypeFlags.StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 : + left.flags & 128 /* TypeFlags.StringLiteral */ ? left : right.flags & 128 /* TypeFlags.StringLiteral */ && right.value === str_1 ? right : + left.flags & 8 /* TypeFlags.Number */ ? left : right.flags & 8 /* TypeFlags.Number */ ? getNumberLiteralType(+str_1) : + left.flags & 32 /* TypeFlags.Enum */ ? left : right.flags & 32 /* TypeFlags.Enum */ ? getNumberLiteralType(+str_1) : + left.flags & 256 /* TypeFlags.NumberLiteral */ ? left : right.flags & 256 /* TypeFlags.NumberLiteral */ && right.value === +str_1 ? right : + left.flags & 64 /* TypeFlags.BigInt */ ? left : right.flags & 64 /* TypeFlags.BigInt */ ? parseBigIntLiteralType(str_1) : + left.flags & 2048 /* TypeFlags.BigIntLiteral */ ? left : right.flags & 2048 /* TypeFlags.BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right : + left.flags & 16 /* TypeFlags.Boolean */ ? left : right.flags & 16 /* TypeFlags.Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType : + left.flags & 512 /* TypeFlags.BooleanLiteral */ ? left : right.flags & 512 /* TypeFlags.BooleanLiteral */ && right.intrinsicName === str_1 ? right : + left.flags & 32768 /* TypeFlags.Undefined */ ? left : right.flags & 32768 /* TypeFlags.Undefined */ && right.intrinsicName === str_1 ? right : + left.flags & 65536 /* TypeFlags.Null */ ? left : right.flags & 65536 /* TypeFlags.Null */ && right.intrinsicName === str_1 ? right : left; }, neverType); - if (!(matchingType.flags & 131072 /* Never */)) { + if (!(matchingType.flags & 131072 /* TypeFlags.Never */)) { inferFromTypes(matchingType, target_3); return "continue"; } @@ -69629,12 +69853,12 @@ var ts; inferFromTypes(source_1, target_3); }; for (var i = 0; i < types.length; i++) { - _loop_23(i); + _loop_24(i); } } } function inferFromObjectTypes(source, target) { - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); return; @@ -69649,7 +69873,7 @@ var ts; if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType); } - if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) { + if (ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */ && !target.declaration.nameType) { var constraintType = getConstraintTypeFromMappedType(target); if (inferToMappedType(source, target, constraintType)) { return; @@ -69672,21 +69896,21 @@ var ts; return; } var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0; - var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* Fixed */) : 0); + var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* ElementFlags.Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* ElementFlags.Fixed */) : 0); // Infer between starting fixed elements. for (var i = 0; i < startLength; i++) { inferFromTypes(getTypeArguments(source)[i], elementTypes[i]); } - if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* Rest */) { + if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Single rest element remains in source, infer from that to every element in target var restType = getTypeArguments(source)[startLength]; for (var i = startLength; i < targetArity - endLength; i++) { - inferFromTypes(elementFlags[i] & 8 /* Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); + inferFromTypes(elementFlags[i] & 8 /* ElementFlags.Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); } } else { var middleLength = targetArity - startLength - endLength; - if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* Variadic */ && isTupleType(source)) { + if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* ElementFlags.Variadic */ && isTupleType(source)) { // Middle of target is [...T, ...U] and source is tuple type var targetInfo = getInferenceInfoForType(elementTypes[startLength]); if (targetInfo && targetInfo.impliedArity !== undefined) { @@ -69695,14 +69919,14 @@ var ts; inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]); } } - else if (middleLength === 1 && elementFlags[startLength] & 8 /* Variadic */) { + else if (middleLength === 1 && elementFlags[startLength] & 8 /* ElementFlags.Variadic */) { // Middle of target is exactly one variadic element. Infer the slice between the fixed parts in the source. // If target ends in optional element(s), make a lower priority a speculative inference. - var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* Optional */; + var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* ElementFlags.Optional */; var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]); - inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* SpeculativeTuple */ : 0); + inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* InferencePriority.SpeculativeTuple */ : 0); } - else if (middleLength === 1 && elementFlags[startLength] & 4 /* Rest */) { + else if (middleLength === 1 && elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Middle of target is exactly one rest element. If middle of source is not empty, infer union of middle element types. var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0]; if (restType) { @@ -69722,8 +69946,8 @@ var ts; } } inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); + inferFromSignatures(source, target, 0 /* SignatureKind.Call */); + inferFromSignatures(source, target, 1 /* SignatureKind.Construct */); inferFromIndexTypes(source, target); } } @@ -69743,25 +69967,22 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */); for (var i = 0; i < len; i++) { - inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); + inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); } } - function inferFromSignature(source, target, skipParameters) { - if (!skipParameters) { - var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */; - applyToParameterTypes(source, target, inferFromContravariantTypes); - bivariant = saveBivariant; - } + function inferFromSignature(source, target) { + var saveBivariant = bivariant; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + // Once we descend into a bivariant signature we remain bivariant for all nested inferences + bivariant = bivariant || kind === 169 /* SyntaxKind.MethodDeclaration */ || kind === 168 /* SyntaxKind.MethodSignature */ || kind === 171 /* SyntaxKind.Constructor */; + applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes); + bivariant = saveBivariant; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables - var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */) ? 8 /* InferencePriority.HomomorphicMappedType */ : 0; var indexInfos = getIndexInfosOfType(target); if (isObjectTypeWithInferableIndex(source)) { for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) { @@ -69769,9 +69990,9 @@ var ts; var propTypes = []; for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { var propType = getTypeOfSymbol(prop); - propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType); + propTypes.push(prop.flags & 16777216 /* SymbolFlags.Optional */ ? removeMissingOrUndefinedType(propType) : propType); } } for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) { @@ -69796,34 +70017,34 @@ var ts; } function isTypeOrBaseIdenticalTo(s, t) { return exactOptionalPropertyTypes && t === missingType ? s === t : - (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */)); + (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* TypeFlags.String */ && s.flags & 128 /* TypeFlags.StringLiteral */ || t.flags & 8 /* TypeFlags.Number */ && s.flags & 256 /* TypeFlags.NumberLiteral */)); } function isTypeCloselyMatchedBy(s, t) { - return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + return !!(s.flags & 524288 /* TypeFlags.Object */ && t.flags & 524288 /* TypeFlags.Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* TypeFlags.Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); } function isObjectLiteralType(type) { - return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); + return !!(ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 16384 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectFlags.ObjectLiteral */ | 16384 /* ObjectFlags.ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType); if (objectLiterals.length) { - var literalsType = getUnionType(objectLiterals, 2 /* Subtype */); + var literalsType = getUnionType(objectLiterals, 2 /* UnionReduction.Subtype */); return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]); } } return candidates; } function getContravariantInference(inference) { - return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { // Extract all object and array literal types and replace them with a single widened and normalized type. @@ -69840,8 +70061,8 @@ var ts; candidates; // If all inferences were made from a position that implies a combined result, infer a union type. // Otherwise, infer a common supertype. - var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? - getUnionType(baseCandidates, 2 /* Subtype */) : + var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? + getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); } @@ -69855,14 +70076,14 @@ var ts; if (inference.contraCandidates) { // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'. - inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) && + inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* TypeFlags.Never */) && ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ? inferredCovariantType_1 : getContravariantInference(inference); } else if (inferredCovariantType_1) { inferredType = inferredCovariantType_1; } - else if (context.flags & 1 /* NoDefault */) { + else if (context.flags & 1 /* InferenceFlags.NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. inferredType = silentNeverType; } @@ -69883,7 +70104,7 @@ var ts; else { inferredType = getTypeFromInference(inference); } - inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* AnyDefault */)); + inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* InferenceFlags.AnyDefault */)); var constraint = getConstraintOfTypeParameter(inference.typeParameter); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper); @@ -69953,7 +70174,7 @@ var ts; } // falls through default: - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -69965,7 +70186,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false) || unknownSymbol; } return links.resolvedSymbol; @@ -69974,7 +70195,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 161 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* SyntaxKind.TypeQuery */ ? true : n.kind === 79 /* SyntaxKind.Identifier */ || n.kind === 161 /* SyntaxKind.QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -69982,70 +70203,79 @@ var ts; // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } // falls through - case 108 /* ThisKeyword */: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); return left && left + "." + node.right.escapedText; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); return key && key + "." + propName; } + break; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + // Handle pseudo-references originating in getNarrowedTypeOfSymbol. + return "".concat(getNodeId(node), "#").concat(getTypeId(declaredType)); } return undefined; } function isMatchingReference(source, target) { switch (target.kind) { - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isMatchingReference(source, target.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || - (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); + (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 231 /* MetaProperty */: - return target.kind === 231 /* MetaProperty */ + case 231 /* SyntaxKind.MetaProperty */: + return target.kind === 231 /* SyntaxKind.MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isThisInTypeQuery(source) ? - target.kind === 108 /* ThisKeyword */ : - target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 254 /* VariableDeclaration */ || target.kind === 203 /* BindingElement */) && + target.kind === 108 /* SyntaxKind.ThisKeyword */ : + target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 108 /* ThisKeyword */: - return target.kind === 108 /* ThisKeyword */; - case 106 /* SuperKeyword */: - return target.kind === 106 /* SuperKeyword */; - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return target.kind === 108 /* SyntaxKind.ThisKeyword */; + case 106 /* SyntaxKind.SuperKeyword */: + return target.kind === 106 /* SyntaxKind.SuperKeyword */; + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var sourcePropertyName = getAccessedPropertyName(source); var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined; return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName && isMatchingReference(source.expression, target.expression); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 221 /* BinaryExpression */: - return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); + case 221 /* SyntaxKind.BinaryExpression */: + return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target)); } return false; } @@ -70066,15 +70296,15 @@ var ts; return undefined; } function tryGetNameFromType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : - type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? type.escapedName : + type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; } function tryGetElementAccessExpressionName(node) { if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) { return ts.escapeLeadingUnderscores(node.argumentExpression.text); } if (ts.isEntityNameExpression(node.argumentExpression)) { - var symbol = resolveEntityName(node.argumentExpression, 111551 /* Value */, /*ignoreErrors*/ true); + var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); if (!symbol || !isConstVariable(symbol)) return undefined; var declaration = symbol.valueDeclaration; @@ -70113,12 +70343,12 @@ var ts; return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 1048576 /* Union */) { + if (type && type.flags & 1048576 /* TypeFlags.Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (prop && ts.getCheckFlags(prop) & 2 /* CheckFlags.SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = - (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && + (prop.checkFlags & 192 /* CheckFlags.Discriminant */) === 192 /* CheckFlags.Discriminant */ && !isGenericType(getTypeOfSymbol(prop)); } return !!prop.isDiscriminantProperty; @@ -70147,8 +70377,8 @@ var ts; function mapTypesByKeyProperty(types, name) { var map = new ts.Map(); var count = 0; - var _loop_24 = function (type) { - if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var _loop_25 = function (type) { + if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { if (!isLiteralType(discriminant)) { @@ -70173,7 +70403,7 @@ var ts; }; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var type = types_15[_i]; - var state_9 = _loop_24(type); + var state_9 = _loop_25(type); if (typeof state_9 === "object") return state_9.value; } @@ -70184,15 +70414,15 @@ var ts; function getKeyPropertyName(unionType) { var types = unionType.types; // We only construct maps for unions with many non-primitive constituents. - if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* PrimitiveUnion */ || - ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) { + if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* ObjectFlags.PrimitiveUnion */ || + ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)); }) < 10) { return undefined; } if (unionType.keyPropertyName === undefined) { // The candidate key property name is the name of the first property with a unit type in one of the // constituent types. var keyPropertyName = ts.forEach(types, function (t) { - return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ? + return t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : undefined; }); @@ -70216,7 +70446,7 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); @@ -70233,7 +70463,7 @@ var ts; } } } - if (expression.expression.kind === 206 /* PropertyAccessExpression */ && + if (expression.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -70247,7 +70477,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -70262,23 +70492,25 @@ var ts; // For example, when a variable of type number | string | boolean is assigned a value of type number | boolean, // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { - if (declaredType !== assignedType) { - if (assignedType.flags & 131072 /* Never */) { - return assignedType; - } - var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) { - reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types - } - // Our crude heuristic produces an invalid result in some cases: see GH#26130. - // For now, when that happens, we give up and don't narrow at all. (This also - // means we'll never narrow for erroneous assignments where the assigned type - // is not assignable to the declared type.) - if (isTypeAssignableTo(assignedType, reducedType)) { - return reducedType; - } + var _a; + if (declaredType === assignedType) { + return declaredType; } - return declaredType; + if (assignedType.flags & 131072 /* TypeFlags.Never */) { + return assignedType; + } + var key = "A".concat(getTypeId(declaredType), ",").concat(getTypeId(assignedType)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType)); + } + function getAssignmentReducedTypeWorker(declaredType, assignedType) { + var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); + // Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type. + var reducedType = assignedType.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType; + // Our crude heuristic produces an invalid result in some cases: see GH#26130. + // For now, when that happens, we give up and don't narrow at all. (This also + // means we'll never narrow for erroneous assignments where the assigned type + // is not assignable to the declared type.) + return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType; } function isFunctionObjectType(type) { // We do a quick check for a "bind" property before performing the more expensive subtype @@ -70288,95 +70520,95 @@ var ts; resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { - if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) { + if (type.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */)) { type = getBaseConstraintOfType(type) || unknownType; } var flags = type.flags; - if (flags & (4 /* String */ | 268435456 /* StringMapping */)) { - return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; + if (flags & (4 /* TypeFlags.String */ | 268435456 /* TypeFlags.StringMapping */)) { + return strictNullChecks ? 16317953 /* TypeFacts.StringStrictFacts */ : 16776705 /* TypeFacts.StringFacts */; } - if (flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) { - var isEmpty = flags & 128 /* StringLiteral */ && type.value === ""; + if (flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + var isEmpty = flags & 128 /* TypeFlags.StringLiteral */ && type.value === ""; return strictNullChecks ? - isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : - isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* TypeFacts.EmptyStringStrictFacts */ : 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* TypeFacts.EmptyStringFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; + if (flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */)) { + return strictNullChecks ? 16317698 /* TypeFacts.NumberStrictFacts */ : 16776450 /* TypeFacts.NumberFacts */; } - if (flags & 256 /* NumberLiteral */) { + if (flags & 256 /* TypeFlags.NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : - isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + isZero ? 12123394 /* TypeFacts.ZeroNumberStrictFacts */ : 7929090 /* TypeFacts.NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* TypeFacts.ZeroNumberFacts */ : 16776450 /* TypeFacts.NonZeroNumberFacts */; } - if (flags & 64 /* BigInt */) { - return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + if (flags & 64 /* TypeFlags.BigInt */) { + return strictNullChecks ? 16317188 /* TypeFacts.BigIntStrictFacts */ : 16775940 /* TypeFacts.BigIntFacts */; } - if (flags & 2048 /* BigIntLiteral */) { + if (flags & 2048 /* TypeFlags.BigIntLiteral */) { var isZero = isZeroBigInt(type); return strictNullChecks ? - isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : - isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; + isZero ? 12122884 /* TypeFacts.ZeroBigIntStrictFacts */ : 7928580 /* TypeFacts.NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* TypeFacts.ZeroBigIntFacts */ : 16775940 /* TypeFacts.NonZeroBigIntFacts */; } - if (flags & 16 /* Boolean */) { - return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; + if (flags & 16 /* TypeFlags.Boolean */) { + return strictNullChecks ? 16316168 /* TypeFacts.BooleanStrictFacts */ : 16774920 /* TypeFacts.BooleanFacts */; } - if (flags & 528 /* BooleanLike */) { + if (flags & 528 /* TypeFlags.BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* TypeFacts.FalseStrictFacts */ : 7927560 /* TypeFacts.TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* TypeFacts.FalseFacts */ : 16774920 /* TypeFacts.TrueFacts */; } - if (flags & 524288 /* Object */) { - return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : + if (flags & 524288 /* TypeFlags.Object */) { + return ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && isEmptyObjectType(type) ? + strictNullChecks ? 83427327 /* TypeFacts.EmptyObjectStrictFacts */ : 83886079 /* TypeFacts.EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : - strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + strictNullChecks ? 7880640 /* TypeFacts.FunctionStrictFacts */ : 16728000 /* TypeFacts.FunctionFacts */ : + strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 16384 /* Void */) { - return 9830144 /* VoidFacts */; + if (flags & 16384 /* TypeFlags.Void */) { + return 9830144 /* TypeFacts.VoidFacts */; } - if (flags & 32768 /* Undefined */) { - return 26607360 /* UndefinedFacts */; + if (flags & 32768 /* TypeFlags.Undefined */) { + return 26607360 /* TypeFacts.UndefinedFacts */; } - if (flags & 65536 /* Null */) { - return 42917664 /* NullFacts */; + if (flags & 65536 /* TypeFlags.Null */) { + return 42917664 /* TypeFacts.NullFacts */; } - if (flags & 12288 /* ESSymbolLike */) { - return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; + if (flags & 12288 /* TypeFlags.ESSymbolLike */) { + return strictNullChecks ? 7925520 /* TypeFacts.SymbolStrictFacts */ : 16772880 /* TypeFacts.SymbolFacts */; } - if (flags & 67108864 /* NonPrimitive */) { - return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + if (flags & 67108864 /* TypeFlags.NonPrimitive */) { + return strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 131072 /* Never */) { - return 0 /* None */; + if (flags & 131072 /* TypeFlags.Never */) { + return 0 /* TypeFacts.None */; } - if (flags & 1048576 /* Union */) { - return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* None */); + if (flags & 1048576 /* TypeFlags.Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* TypeFacts.None */); } - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionTypeFacts(type); } - return 83886079 /* UnknownFacts */; + return 83886079 /* TypeFacts.UnknownFacts */; } function getIntersectionTypeFacts(type) { // When an intersection contains a primitive type we ignore object type constituents as they are // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type. - var ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */); + var ignoreObjects = maybeTypeOfKind(type, 131068 /* TypeFlags.Primitive */); // When computing the type facts of an intersection type, certain type facts are computed as `and` // and others are computed as `or`. - var oredFacts = 0 /* None */; - var andedFacts = 134217727 /* All */; + var oredFacts = 0 /* TypeFacts.None */; + var andedFacts = 134217727 /* TypeFacts.All */; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (!(ignoreObjects && t.flags & 524288 /* Object */)) { + if (!(ignoreObjects && t.flags & 524288 /* TypeFlags.Object */)) { var f = getTypeFacts(t); oredFacts |= f; andedFacts &= f; } } - return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */; + return oredFacts & 8256 /* TypeFacts.OrFactsMask */ | andedFacts & 134209471 /* TypeFacts.AndFactsMask */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -70385,16 +70617,16 @@ var ts; // unknown with the union {} | null | undefined (and reduces that accordingly), and it intersects remaining // instantiable types with {}, {} | null, or {} | undefined in order to remove null and/or undefined. function getAdjustedTypeWithFacts(type, facts) { - var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts)); + var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */ ? unknownUnionType : type, facts)); if (strictNullChecks) { switch (facts) { - case 524288 /* NEUndefined */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; }); - case 1048576 /* NENull */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; }); - case 2097152 /* NEUndefinedOrNull */: - case 4194304 /* Truthy */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; }); + case 524288 /* TypeFacts.NEUndefined */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* TypeFacts.EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* TypeFacts.EQNull */ && !maybeTypeOfKind(reduced, 65536 /* TypeFlags.Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; }); + case 1048576 /* TypeFacts.NENull */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* TypeFacts.EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* TypeFacts.EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* TypeFlags.Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; }); + case 2097152 /* TypeFacts.NEUndefinedOrNull */: + case 4194304 /* TypeFacts.Truthy */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; }); } } return reduced; @@ -70417,7 +70649,7 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || - includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || + includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || errorType; } function includeUndefinedInIndexSignature(type) { @@ -70428,18 +70660,18 @@ var ts; type; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); + return createArrayType(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 204 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 221 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 244 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -70456,21 +70688,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return stringType; - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return undefinedType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -70478,7 +70710,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 201 /* ObjectBindingPattern */ ? + var type = pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -70496,37 +70728,37 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 243 /* ForInStatement */) { + if (node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 254 /* VariableDeclaration */ ? + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 254 /* VariableDeclaration */ && node.initializer && + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 203 /* BindingElement */ && node.parent.kind === 221 /* BinaryExpression */ && + node.kind !== 203 /* SyntaxKind.BindingElement */ && node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return getReferenceCandidate(node.right); } } @@ -70534,13 +70766,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 212 /* ParenthesizedExpression */ || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.left === node || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -70559,25 +70791,25 @@ var ts; // Get the type names from all cases in a switch on `typeof`. The default clause and/or duplicate type names are // represented as undefined. Return undefined if one or more case clause expressions are not string literals. function getSwitchClauseTypeOfWitnesses(switchStatement) { - if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) { + if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* SyntaxKind.CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) { return undefined; } var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - var text = clause.kind === 289 /* CaseClause */ ? clause.expression.text : undefined; + var text = clause.kind === 289 /* SyntaxKind.CaseClause */ ? clause.expression.text : undefined; witnesses.push(text && !ts.contains(witnesses, text) ? text : undefined); } return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 1048576 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* TypeFlags.Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* TypeFlags.Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -70586,25 +70818,25 @@ var ts; } return true; } - if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* TypeFlags.EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.forEach(type.types, f) : f(type); } function someType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.every(type.types, f) : f(type); } function everyContainedType(type, f) { - return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var types = type.types; var filtered = ts.filter(types, f); if (filtered === types) { @@ -70612,45 +70844,45 @@ var ts; } var origin = type.origin; var newOrigin = void 0; - if (origin && origin.flags & 1048576 /* Union */) { + if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { // If the origin type is a (denormalized) union type, filter its non-union constituents. If that ends // up removing a smaller number of types than in the normalized constituent set (meaning some of the // filtered types are within nested unions in the origin), then we can't construct a new origin type. // Otherwise, if we have exactly one type left in the origin set, return that as the filtered type. // Otherwise, construct a new filtered origin type. var originTypes = origin.types; - var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* Union */) || f(t); }); + var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) || f(t); }); if (originTypes.length - originFiltered.length === types.length - filtered.length) { if (originFiltered.length === 1) { return originFiltered[0]; } - newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + newOrigin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, originFiltered); } } return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } - return type.flags & 131072 /* Never */ || f(type) ? type : neverType; + return type.flags & 131072 /* TypeFlags.Never */ || f(type) ? type : neverType; } function removeType(type, targetType) { return filterType(type, function (t) { return t !== targetType; }); } function countTypes(type) { - return type.flags & 1048576 /* Union */ ? type.types.length : 1; + return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1; } function mapType(type, mapper, noReductions) { - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return type; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return mapper(type); } var origin = type.origin; - var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types; + var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? origin.types : type.types; var mappedTypes; var changed = false; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; - var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t); + var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { if (!mappedTypes) { @@ -70661,11 +70893,11 @@ var ts; } } } - return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; + return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type; } function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { - return type.flags & 1048576 /* Union */ && aliasSymbol ? - getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper); } function extractTypesOfKind(type, kind) { @@ -70677,13 +70909,13 @@ var ts; // true intersection because it is more costly and, when applied to union types, generates a large number of // types we don't actually care about. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && - maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) { + if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) && + maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : - isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; + return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) : + isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) : + t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) : + t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -70695,14 +70927,14 @@ var ts; return flowType.flags === 0 ? flowType.type : flowType; } function createFlowType(type, incomplete) { - return incomplete ? { flags: 0, type: type.flags & 131072 /* Never */ ? silentNeverType : type } : type; + return incomplete ? { flags: 0, type: type.flags & 131072 /* TypeFlags.Never */ ? silentNeverType : type } : type; } // An evolving array type tracks the element types that have so far been seen in an // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(256 /* EvolvingArray */); + var result = createObjectType(256 /* ObjectFlags.EvolvingArray */); result.elementType = elementType; return result; } @@ -70717,10 +70949,10 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 131072 /* Never */ ? + return elementType.flags & 131072 /* TypeFlags.Never */ ? autoArrayType : - createArrayType(elementType.flags & 1048576 /* Union */ ? - getUnionType(elementType.types, 2 /* Subtype */) : + createArrayType(elementType.flags & 1048576 /* TypeFlags.Union */ ? + getUnionType(elementType.types, 2 /* UnionReduction.Subtype */) : elementType); } // We perform subtype reduction upon obtaining the final array type from an evolving array type. @@ -70728,17 +70960,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { var t = types_17[_i]; - if (!(t.flags & 131072 /* Never */)) { - if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + if (!(ts.getObjectFlags(t) & 256 /* ObjectFlags.EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -70752,16 +70984,16 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 208 /* CallExpression */ + parent.parent.kind === 208 /* SyntaxKind.CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 207 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 221 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 63 /* EqualsToken */ && + parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* TypeFlags.NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(node) { @@ -70770,11 +71002,11 @@ var ts; ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer)); } function getExplicitTypeOfSymbol(symbol, diagnostic) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { + if (ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */) { var origin = symbol.syntheticOrigin; if (origin && getExplicitTypeOfSymbol(origin)) { return getTypeOfSymbol(symbol); @@ -70785,11 +71017,11 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); } } @@ -70804,16 +71036,16 @@ var ts; // parameter symbols with declarations that have explicit type annotations. Such references are // resolvable with no possibility of triggering circularities in control flow analysis. function getTypeOfDottedName(node, diagnostic) { - if (!(node.flags & 33554432 /* InWithStatement */)) { + if (!(node.flags & 33554432 /* NodeFlags.InWithStatement */)) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); - return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 108 /* ThisKeyword */: + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 108 /* SyntaxKind.ThisKeyword */: return getExplicitThisType(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 206 /* PropertyAccessExpression */: { + case 206 /* SyntaxKind.PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -70831,7 +71063,7 @@ var ts; } return undefined; } - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -70845,10 +71077,10 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 106 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -70856,7 +71088,7 @@ var ts; funcType = checkNonNullExpression(node.expression); } } - var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* SignatureKind.Call */); var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : undefined; @@ -70866,10 +71098,10 @@ var ts; } function hasTypePredicateOrNeverReturnType(signature) { return !!(getTypePredicateOfSignature(signature) || - signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* TypeFlags.Never */); } function getTypePredicateArgument(predicate, callExpression) { - if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + if (predicate.kind === 1 /* TypePredicateKind.Identifier */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { return callExpression.arguments[predicate.parameterIndex]; } var invokedExpression = ts.skipParentheses(callExpression.expression); @@ -70889,8 +71121,8 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 95 /* FalseKeyword */ || node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || - node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + return node.kind === 95 /* SyntaxKind.FalseKeyword */ || node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { while (true) { @@ -70898,7 +71130,7 @@ var ts; return lastFlowNodeReachable; } var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var reachable = flowNodeReachable[id]; @@ -70906,30 +71138,30 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && predicate.kind === 3 /* AssertsIdentifier */ && !predicate.type) { + if (predicate && predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && !predicate.type) { var predicateArgument = flow.node.arguments[predicate.parameterIndex]; if (predicateArgument && isFalseExpression(predicateArgument)) { return false; } } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return false; } } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is reachable if any branch is reachable. return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { var antecedents = flow.antecedents; if (antecedents === undefined || antecedents.length === 0) { return false; @@ -70937,7 +71169,7 @@ var ts; // A loop is reachable if the control flow path that leads to the top is reachable. flow = antecedents[0]; } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { // The control flow path representing an unmatched value in a switch statement with // no default clause is unreachable if the switch statement is exhaustive. if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { @@ -70945,7 +71177,7 @@ var ts; } flow = flow.antecedent; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { // Cache is unreliable once we start adjusting labels lastFlowNode = undefined; var target = flow.target; @@ -70956,7 +71188,7 @@ var ts; return result; } else { - return !(flags & 1 /* Unreachable */); + return !(flags & 1 /* FlowFlags.Unreachable */); } } } @@ -70965,7 +71197,7 @@ var ts; function isPostSuperFlowNode(flow, noCacheCheck) { while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var postSuper = flowNodePostSuper[id]; @@ -70973,24 +71205,24 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 128 /* SwitchClause */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */ | 128 /* FlowFlags.SwitchClause */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 106 /* SuperKeyword */) { + else if (flags & 512 /* FlowFlags.Call */) { + if (flow.node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return true; } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is post-super if every branch is post-super. return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { // A loop is post-super if the control flow path that leads to the top is post-super. flow = flow.antecedents[0]; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; @@ -71000,18 +71232,18 @@ var ts; } else { // Unreachable nodes are considered post-super to silence errors - return !!(flags & 1 /* Unreachable */); + return !!(flags & 1 /* FlowFlags.Unreachable */); } } } function isConstantReference(node) { switch (node.kind) { - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var symbol = getResolvedSymbol(node); return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); } @@ -71037,8 +71269,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* ObjectFlags.EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* SyntaxKind.NonNullExpression */ && !(resultType.flags & 131072 /* TypeFlags.Never */) && getTypeWithFacts(resultType, 2097152 /* TypeFacts.NEUndefinedOrNull */).flags & 131072 /* TypeFlags.Never */) { return declaredType; } // The non-null unknown type should never escape control flow analysis. @@ -71054,7 +71286,7 @@ var ts; if (flowDepth === 2000) { // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error // and disable further control flow analysis in the containing function or module body. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -71063,7 +71295,7 @@ var ts; var sharedFlow; while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -71076,56 +71308,56 @@ var ts; sharedFlow = flow; } var type = void 0; - if (flags & 16 /* Assignment */) { + if (flags & 16 /* FlowFlags.Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { type = getTypeAtFlowCall(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 96 /* Condition */) { + else if (flags & 96 /* FlowFlags.Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flags & 12 /* Label */) { + else if (flags & 12 /* FlowFlags.Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flags & 4 /* BranchLabel */ ? + type = flags & 4 /* FlowFlags.BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* FlowFlags.ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; type = getTypeAtFlowNode(flow.antecedent); target.antecedents = saveAntecedents; } - else if (flags & 2 /* Start */) { + else if (flags & 2 /* FlowFlags.Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 206 /* PropertyAccessExpression */ && - reference.kind !== 207 /* ElementAccessExpression */ && - reference.kind !== 108 /* ThisKeyword */) { + reference.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && + reference.kind !== 207 /* SyntaxKind.ElementAccessExpression */ && + reference.kind !== 108 /* SyntaxKind.ThisKeyword */) { flow = container.flowNode; continue; } @@ -71149,7 +71381,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -71161,7 +71393,7 @@ var ts; if (!isReachableFlowNode(flow)) { return unreachableNeverType; } - if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { + if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -71172,7 +71404,7 @@ var ts; var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* TypeFlags.Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; @@ -71189,29 +71421,29 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 213 /* FunctionExpression */ || init.kind === 214 /* ArrowFunction */)) { + if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { - return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)))); } // Assignment doesn't affect reference return undefined; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - if (node.kind === 95 /* FalseKeyword */) { + if (node.kind === 95 /* SyntaxKind.FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 221 /* BinaryExpression */) { - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } - if (node.operatorToken.kind === 56 /* BarBarToken */) { + if (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); } } @@ -71221,15 +71453,15 @@ var ts; var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + if (predicate && (predicate.kind === 2 /* TypePredicateKind.AssertsThis */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = finalizeEvolvingArrayType(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]) : + predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return unreachableNeverType; } } @@ -71238,15 +71470,15 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 208 /* CallExpression */ ? + var expr = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { + if (ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -71255,7 +71487,7 @@ var ts; else { // We must get the context free expression type so as to not recur in an uncached fashion on the LHS (which causes exponential blowup in compile time) var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -71269,7 +71501,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -71279,7 +71511,7 @@ var ts; // have the complete type. We proceed by switching to the silent never type which // doesn't report errors when operators are applied to it. Note that this is the // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { @@ -71294,16 +71526,16 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 216 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* TypeFlags.Undefined */ | 131072 /* TypeFlags.Never */)); }); } - else if (expr.kind === 216 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* TypeFlags.Never */ || t.flags & 128 /* TypeFlags.StringLiteral */ && t.value === "undefined"); }); } } var access = getDiscriminantPropertyAccess(expr, type); @@ -71320,7 +71552,7 @@ var ts; var bypassFlow; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { + if (!bypassFlow && antecedent.flags & 128 /* FlowFlags.SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { // The antecedent is the bypass branch of a potentially exhaustive switch statement. bypassFlow = antecedent; continue; @@ -71364,7 +71596,7 @@ var ts; } } } - return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -71390,7 +71622,7 @@ var ts; // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { - return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* Literal */), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* UnionReduction.Literal */), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -71443,7 +71675,7 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } @@ -71458,7 +71690,7 @@ var ts; return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))); } var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction)); - if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) { + if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* TypeFlags.Union */ && ts.arraysEqual(result.types, declaredType.types)) { return declaredType; } return result; @@ -71504,8 +71736,8 @@ var ts; return undefined; } function getDiscriminantPropertyAccess(expr, computedType) { - var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + var type = declaredType.flags & 1048576 /* TypeFlags.Union */ ? declaredType : computedType; + if (type.flags & 1048576 /* TypeFlags.Union */) { var access = getCandidateDiscriminantPropertyAccess(expr); if (access) { var name = getAccessedPropertyName(access); @@ -71521,8 +71753,8 @@ var ts; if (propName === undefined) { return type; } - var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); - var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* TypeFlags.Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } @@ -71530,16 +71762,16 @@ var ts; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); - return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType); + return !(narrowedPropType.flags & 131072 /* TypeFlags.Never */) && isTypeComparableTo(narrowedPropType, discriminantType); }); } function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { - if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + if ((operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* TypeFlags.Union */) { var keyPropertyName = getKeyPropertyName(type); if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); if (candidate) { - return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate : + return operator === (assumeTrue ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) ? candidate : isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) : type; } @@ -71548,7 +71780,7 @@ var ts; return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); }); } function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) { - if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { + if (clauseStart < clauseEnd && type.flags & 1048576 /* TypeFlags.Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); if (candidate !== unknownType) { @@ -71559,51 +71791,51 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); + return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { - type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + type = getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); }); } return type; } function isTypePresencePossible(type, propName, assumeTrue) { var prop = getPropertyOfType(type, propName); if (prop) { - return prop.flags & 16777216 /* Optional */ ? true : assumeTrue; + return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue; } return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue; } function narrowByInKeyword(type, name, assumeTrue) { - if (type.flags & 1048576 /* Union */ - || type.flags & 524288 /* Object */ && declaredType !== type + if (type.flags & 1048576 /* TypeFlags.Union */ + || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type || ts.isThisTypeParameter(type) - || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { + || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); }); } return type; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -71635,35 +71867,35 @@ var ts; return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (ts.isPrivateIdentifier(expr.left)) { return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue); } var target = getReferenceCandidate(expr.right); var leftType = getTypeOfNode(expr.left); - if (leftType.flags & 128 /* StringLiteral */) { + if (leftType.flags & 128 /* TypeFlags.StringLiteral */) { var name = ts.escapeLeadingUnderscores(leftType.value); if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && getAccessedPropertyName(reference) === name) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } if (isMatchingReference(reference, target)) { return narrowByInKeyword(type, name, assumeTrue); } } break; - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return narrowType(type, expr.right, assumeTrue); // Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those // expressions down to individual conditional control flows. However, we may encounter them when analyzing // aliased conditional expressions. - case 55 /* AmpersandAmpersandToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: return assumeTrue ? narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) : getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]); - case 56 /* BarBarToken */: + case 56 /* SyntaxKind.BarBarToken */: return assumeTrue ? getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) : narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); @@ -71684,7 +71916,7 @@ var ts; var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true); } function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { // We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows: @@ -71696,45 +71928,45 @@ var ts; // When operator is !== and type of value is undefined, null and undefined is removed from type of obj in true branch. // When operator is == and type of value is null or undefined, null and undefined is removed from type of obj in false branch. // When operator is != and type of value is null or undefined, null and undefined is removed from type of obj in true branch. - var equalsOperator = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; - var nullableFlags = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */; + var equalsOperator = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; + var nullableFlags = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? 98304 /* TypeFlags.Nullable */ : 32768 /* TypeFlags.Undefined */; var valueType = getTypeOfExpression(value); // Note that we include any and unknown in the exclusion test because their domain includes null and undefined. var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) || - equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); }); - return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* TypeFlags.AnyOrUnknown */ | nullableFlags)); }); + return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeByEquality(type, operator, value, assumeTrue) { - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { return type; } - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { - if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && assumeTrue && (operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { + if (valueType.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { return valueType; } - if (valueType.flags & 524288 /* Object */) { + if (valueType.flags & 524288 /* TypeFlags.Object */) { return nonPrimitiveType; } return type; } - if (valueType.flags & 98304 /* Nullable */) { + if (valueType.flags & 98304 /* TypeFlags.Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : - valueType.flags & 65536 /* Null */ ? - assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : - assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; + assumeTrue ? 262144 /* TypeFacts.EQUndefinedOrNull */ : 2097152 /* TypeFacts.NEUndefinedOrNull */ : + valueType.flags & 65536 /* TypeFlags.Null */ ? + assumeTrue ? 131072 /* TypeFacts.EQNull */ : 1048576 /* TypeFacts.NENull */ : + assumeTrue ? 65536 /* TypeFacts.EQUndefined */ : 524288 /* TypeFacts.NEUndefined */; return getAdjustedTypeWithFacts(type, facts); } if (assumeTrue) { - var filterFn = operator === 34 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); @@ -71746,23 +71978,23 @@ var ts; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { - return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } return assumeTrue ? narrowTypeByTypeName(type, literal.text) : - getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */); + getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeFacts.TypeofNEHostObject */); } function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); - return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify @@ -71775,16 +72007,16 @@ var ts; } var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); - if ((type.flags & 2 /* Unknown */) && !hasDefaultClause) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && !hasDefaultClause) { var groundClauseTypes = void 0; for (var i = 0; i < clauseTypes.length; i += 1) { var t = clauseTypes[i]; - if (t.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if (t.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { if (groundClauseTypes !== undefined) { groundClauseTypes.push(t); } } - else if (t.flags & 524288 /* Object */) { + else if (t.flags & 524288 /* TypeFlags.Object */) { if (groundClauseTypes === undefined) { groundClauseTypes = clauseTypes.slice(0, i); } @@ -71797,26 +72029,26 @@ var ts; return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes); } var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* TypeFlags.Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); - return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]); } function narrowTypeByTypeName(type, typeName) { switch (typeName) { - case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeofEQString */); - case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeofEQNumber */); - case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeofEQBigInt */); - case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeofEQBoolean */); - case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeofEQSymbol */); - case "object": return type.flags & 1 /* Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* EQNull */)]); - case "function": return type.flags & 1 /* Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeofEQFunction */); - case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* EQUndefined */); + case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeFacts.TypeofEQString */); + case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeFacts.TypeofEQNumber */); + case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeFacts.TypeofEQBigInt */); + case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeFacts.TypeofEQBoolean */); + case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeFacts.TypeofEQSymbol */); + case "object": return type.flags & 1 /* TypeFlags.Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeFacts.TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* TypeFacts.EQNull */)]); + case "function": return type.flags & 1 /* TypeFlags.Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeFacts.TypeofEQFunction */); + case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* TypeFacts.EQUndefined */); } - return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */); + return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeFacts.TypeofEQHostObject */); } function narrowTypeByTypeFacts(type, impliedType, facts) { return mapType(type, function (t) { @@ -71841,7 +72073,7 @@ var ts; return type; } // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause. - var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* DefaultClause */; }); + var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* SyntaxKind.DefaultClause */; }); var hasDefaultClause = clauseStart === clauseEnd || (defaultIndex >= clauseStart && defaultIndex < clauseEnd); if (hasDefaultClause) { // In the default clause we filter constituents down to those that are not-equal to all handled cases. @@ -71859,7 +72091,7 @@ var ts; } function narrowTypeByConstructor(type, operator, identifier, assumeTrue) { // Do not narrow when checking inequality. - if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) { + if (assumeTrue ? (operator !== 34 /* SyntaxKind.EqualsEqualsToken */ && operator !== 36 /* SyntaxKind.EqualsEqualsEqualsToken */) : (operator !== 35 /* SyntaxKind.ExclamationEqualsToken */ && operator !== 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { return type; } // Get the type of the constructor identifier expression, if it is not a function then do not narrow. @@ -71889,8 +72121,8 @@ var ts; // This is because you may have a class `A` that defines some set of properties, and another class `B` // that defines the same set of properties as class `A`, in that case they are structurally the same // type, but when you do something like `instanceOfA.constructor === B` it will return false. - if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ || - target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) { + if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ || + target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { return source.symbol === target.symbol; } // For all other types just check that the `source` type is a subtype of the `target` type. @@ -71901,7 +72133,7 @@ var ts; var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { - return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } @@ -71924,46 +72156,65 @@ var ts; return type; } if (!targetType) { - var constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(rightType, 1 /* SignatureKind.Construct */); targetType = constructSignatures.length ? getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) : emptyObjectType; } // We can't narrow a union based off instanceof without negated types see #31576 for more info - if (!assumeTrue && rightType.flags & 1048576 /* Union */) { + if (!assumeTrue && rightType.flags & 1048576 /* TypeFlags.Union */) { var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); }); if (!nonConstructorTypeInUnion) return type; } - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true); } - function getNarrowedType(type, candidate, assumeTrue, isRelated) { + function getNarrowedType(type, candidate, assumeTrue, checkDerived) { + var _a; + var key = type.flags & 1048576 /* TypeFlags.Union */ ? "N".concat(getTypeId(type), ",").concat(getTypeId(candidate), ",").concat((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined; + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived)); + } + function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) { + var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf; if (!assumeTrue) { return filterType(type, function (t) { return !isRelated(t, candidate); }); } - // If the current type is a union type, remove all constituents that couldn't be instances of - // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 1048576 /* Union */) { - var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072 /* Never */)) { - return assignableType; - } + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { + return candidate; } - // If the candidate type is a subtype of the target type, narrow to the candidate type. - // Otherwise, if the target type is assignable to the candidate type, keep the target type. - // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate - // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the - // two types. - return isTypeSubtypeOf(candidate, type) ? candidate : - isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, type) ? candidate : - getIntersectionType([type, candidate]); + // We first attempt to filter the current type, narrowing constituents as appropriate and removing + // constituents that are unrelated to the candidate. + var keyPropertyName = type.flags & 1048576 /* TypeFlags.Union */ ? getKeyPropertyName(type) : undefined; + var narrowedType = mapType(candidate, function (c) { + // If a discriminant property is available, use that to reduce the type. + var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName); + var matching = discriminant && getConstituentTypeForKeyType(type, discriminant); + // For each constituent t in the current type, if t and and c are directly related, pick the most + // specific of the two. When t and c are related in both directions, we prefer c for type predicates + // because that is the asserted type, but t for `instanceof` because generics aren't reflected in + // prototype object types. + var directlyRelated = mapType(matching || type, checkDerived ? + function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } : + function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; }); + // If no constituents are directly related, create intersections for any generic constituents that + // are related by constraint. + return directlyRelated.flags & 131072 /* TypeFlags.Never */ ? + mapType(type, function (t) { return maybeTypeOfKind(t, 465829888 /* TypeFlags.Instantiable */) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType; }) : + directlyRelated; + }); + // If filtering produced a non-empty type, return that. Otherwise, pick the most specific of the two + // based on assignability, or as a last resort produce an intersection. + return !(narrowedType.flags & 131072 /* TypeFlags.Never */) ? narrowedType : + isTypeSubtypeOf(candidate, type) ? candidate : + isTypeAssignableTo(type, candidate) ? type : + isTypeAssignableTo(candidate, type) ? candidate : + getIntersectionType([type, candidate]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; var predicate = signature && getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + if (predicate && (predicate.kind === 0 /* TypePredicateKind.This */ || predicate.kind === 1 /* TypePredicateKind.Identifier */)) { return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } @@ -71973,7 +72224,7 @@ var ts; ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) { var argument = callExpression.arguments[0]; if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } } } @@ -71985,15 +72236,15 @@ var ts; var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && - !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { - type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + !(getTypeFacts(predicate.type) & 65536 /* TypeFacts.EQUndefined */)) { + type = getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); }); } } } @@ -72004,11 +72255,11 @@ var ts; function narrowType(type, expr, assumeTrue) { // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` if (ts.isExpressionOfOptionalChainRoot(expr) || - ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */ && expr.parent.left === expr) { return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline // up to five levels of aliased conditional expressions that are themselves declared as const variables. if (!isMatchingReference(reference, expr) && inlineLevel < 5) { @@ -72024,20 +72275,20 @@ var ts; } } // falls through - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 219 /* PrefixUnaryExpression */: - if (expr.operator === 53 /* ExclamationToken */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (expr.operator === 53 /* SyntaxKind.ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -72046,11 +72297,11 @@ var ts; } function narrowTypeByOptionality(type, expr, assumePresent) { if (isMatchingReference(reference, expr)) { - return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); }); } return type; } @@ -72061,7 +72312,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { + if (location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -72085,9 +72336,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 262 /* ModuleBlock */ || - node.kind === 305 /* SourceFile */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 262 /* SyntaxKind.ModuleBlock */ || + node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; }); } // Check if a parameter or catch variable is assigned anywhere @@ -72097,8 +72348,8 @@ var ts; } var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(parent); - if (!(links.flags & 8388608 /* AssignmentsMarked */)) { - links.flags |= 8388608 /* AssignmentsMarked */; + if (!(links.flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */)) { + links.flags |= 8388608 /* NodeCheckFlags.AssignmentsMarked */; if (!hasParentWithAssignmentsMarked(parent)) { markNodeAssignments(parent); } @@ -72107,11 +72358,11 @@ var ts; } function hasParentWithAssignmentsMarked(node) { return !!ts.findAncestor(node.parent, function (node) { - return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); + return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */); }); } function markNodeAssignments(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); if (ts.isParameterOrCatchClauseVariable(symbol)) { @@ -72124,18 +72375,18 @@ var ts; } } function isConstVariable(symbol) { - return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0; + return symbol.flags & 3 /* SymbolFlags.Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */) !== 0; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { - if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { + if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 164 /* Parameter */ && + declaration.kind === 164 /* SyntaxKind.Parameter */ && declaration.initializer && - getTypeFacts(declaredType) & 16777216 /* IsUndefined */ && - !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* IsUndefined */); + getTypeFacts(declaredType) & 16777216 /* TypeFacts.IsUndefined */ && + !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* TypeFacts.IsUndefined */); popTypeResolution(); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType; } else { reportCircularityError(declaration.symbol); @@ -72147,19 +72398,19 @@ var ts; // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of // a generic type without a nullable constraint and x is a generic type. This is because when both obj // and x are of generic types T and K, we want the resulting type to be T[K]. - return parent.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 161 /* QualifiedName */ || - parent.kind === 208 /* CallExpression */ && parent.expression === node || - parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node && + return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 161 /* SyntaxKind.QualifiedName */ || + parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node || + parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { - return type.flags & 2097152 /* Intersection */ ? + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isGenericTypeWithUnionConstraint) : - !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */)); } function isGenericTypeWithoutNullableConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* TypeFlags.Nullable */)); } function hasContextualTypeWithNoGenericTypes(node, checkMode) { // Computing the contextual type for a child of a JSX element involves resolving the type of the @@ -72168,9 +72419,9 @@ var ts; // as we want the type of a rest element to be generic when possible. var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && - (checkMode && checkMode & 64 /* RestBindingElement */ ? - getContextualType(node, 8 /* SkipBindingPatterns */) - : getContextualType(node)); + (checkMode && checkMode & 64 /* CheckMode.RestBindingElement */ ? + getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) + : getContextualType(node, /*contextFlags*/ undefined)); return contextualType && !isGenericType(contextualType); } function getNarrowableTypeForReference(type, reference, checkMode) { @@ -72181,7 +72432,7 @@ var ts; // control flow analysis an opportunity to narrow it further. For example, for a reference of a type // parameter type 'T extends string | undefined' with a contextual type 'string', we substitute // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. - var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && + var substituteConstraints = !(checkMode && checkMode & 2 /* CheckMode.Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode)); return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type; @@ -72202,9 +72453,9 @@ var ts; }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled // (because the const enum value will not be inlined), or if (2) the alias is an export // of a const enum declaration that will be preserved. @@ -72247,16 +72498,16 @@ var ts; // destructuring from the narrowed parent type. if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { var parent = declaration.parent.parent; - if (parent.kind === 254 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 164 /* Parameter */) { + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || parent.kind === 164 /* SyntaxKind.Parameter */) { var links = getNodeLinks(parent); - if (!(links.flags & 268435456 /* InCheckIdentifier */)) { - links.flags |= 268435456 /* InCheckIdentifier */; - var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */); - links.flags &= ~268435456 /* InCheckIdentifier */; - if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 164 /* Parameter */ && isSymbolAssigned(symbol))) { + if (!(links.flags & 268435456 /* NodeCheckFlags.InCheckIdentifier */)) { + links.flags |= 268435456 /* NodeCheckFlags.InCheckIdentifier */; + var parentType = getTypeForBindingElementParent(parent, 0 /* CheckMode.Normal */); + links.flags &= ~268435456 /* NodeCheckFlags.InCheckIdentifier */; + if (parentType && parentType.flags & 1048576 /* TypeFlags.Union */ && !(parent.kind === 164 /* SyntaxKind.Parameter */ && isSymbolAssigned(symbol))) { var pattern = declaration.parent; var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode); - if (narrowedType.flags & 131072 /* Never */) { + if (narrowedType.flags & 131072 /* TypeFlags.Never */) { return neverType; } return getBindingElementTypeFromParentType(declaration, narrowedType); @@ -72290,7 +72541,7 @@ var ts; var contextualSignature = getContextualSignature(func); if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) { var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0])); - if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { + if (restType.flags & 1048576 /* TypeFlags.Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode); var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0); return getIndexedAccessType(narrowedType, getNumberLiteralType(index)); @@ -72321,20 +72572,18 @@ var ts; return errorType; } var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 214 /* ArrowFunction */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } - else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { + else if (ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; + getNodeLinks(container).flags |= 8192 /* NodeCheckFlags.CaptureArguments */; return getTypeOfSymbol(symbol); } - // We should only mark aliases as referenced if there isn't a local value declaration - // for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that - if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) { + if (shouldMarkIdentifierAliasReferenced(node)) { markAliasReferenced(symbol, node); } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); @@ -72343,32 +72592,32 @@ var ts; addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (declaration && localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 257 /* ClassDeclaration */ + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { if (container === declaration && container.name !== node) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; break; } container = ts.getContainingClass(container); } } - else if (declaration.kind === 226 /* ClassExpression */) { + else if (declaration.kind === 226 /* SyntaxKind.ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 305 /* SourceFile */) { + while (container.kind !== 305 /* SyntaxKind.SourceFile */) { if (container.parent === declaration) { if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; } break; } @@ -72380,19 +72629,19 @@ var ts; var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { - if (!(localOrExportSymbol.flags & 3 /* Variable */) && - !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum - : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class - : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace - : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function - : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import + if (!(localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) && + !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* SymbolFlags.ValueModule */)) { + var assignmentError = localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 /* SymbolFlags.Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { - if (localOrExportSymbol.flags & 3 /* Variable */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol)); } else { @@ -72401,11 +72650,11 @@ var ts; return errorType; } } - var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; + var isAlias = localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */; // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (localOrExportSymbol.flags & 3 /* Variable */) { - if (assignmentKind === 1 /* Definite */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { + if (assignmentKind === 1 /* AssignmentKind.Definite */) { return type; } } @@ -72422,17 +72671,17 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* SyntaxKind.Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - var isModuleExports = symbol.flags & 134217728 /* ModuleExports */; + var isModuleExports = symbol.flags & 134217728 /* SymbolFlags.ModuleExports */; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* FunctionExpression */ || - flowContainer.kind === 214 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* SyntaxKind.FunctionExpression */ || + flowContainer.kind === 214 /* SyntaxKind.ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -72440,11 +72689,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) || - node.parent.kind === 230 /* NonNullExpression */ || - declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 16777216 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) || + node.parent.kind === 230 /* SyntaxKind.NonNullExpression */ || + declaration.kind === 254 /* SyntaxKind.VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 16777216 /* NodeFlags.Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -72468,6 +72717,25 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function shouldMarkIdentifierAliasReferenced(node) { + var _a; + var parent = node.parent; + if (parent) { + // A property access expression LHS? checkPropertyAccessExpression will handle that. + if (ts.isPropertyAccessExpression(parent) && parent.expression === node) { + return false; + } + // Next two check for an identifier inside a type only export. + if (ts.isExportSpecifier(parent) && parent.isTypeOnly) { + return false; + } + var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent; + if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) { + return false; + } + } + return true; + } function isInsideFunctionOrInstancePropertyInitializer(node, threshold) { return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); }); } @@ -72478,11 +72746,11 @@ var ts; return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); }); } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES2015 */ || - (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || + (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 32 /* SymbolFlags.Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 292 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 292 /* SyntaxKind.CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -72497,12 +72765,12 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); - links.flags |= 131072 /* ContainsCapturedBlockScopeBinding */; + links.flags |= 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */; var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []); ts.pushIfUnique(capturedBindings, symbol); if (part === container.initializer) { @@ -72512,22 +72780,22 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { - getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; + getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */; } } // set 'declared inside loop' bit on the block-scoped binding - getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } if (isCaptured) { - getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; } } function isBindingCapturedByNode(node, decl) { @@ -72537,7 +72805,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 212 /* ParenthesizedExpression */) { + while (current.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -72545,9 +72813,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 219 /* PrefixUnaryExpression */ || current.parent.kind === 220 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || current.parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || expr.operator === 46 /* SyntaxKind.MinusMinusToken */; } if (!isAssigned) { return false; @@ -72557,13 +72825,13 @@ var ts; return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 167 /* PropertyDeclaration */ || container.kind === 171 /* Constructor */) { + getNodeLinks(node).flags |= 2 /* NodeCheckFlags.LexicalThis */; + if (container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || container.kind === 171 /* SyntaxKind.Constructor */) { var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + getNodeLinks(classNode).flags |= 4 /* NodeCheckFlags.CaptureThis */; } else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; + getNodeLinks(container).flags |= 4 /* NodeCheckFlags.CaptureThis */; } } function findFirstSuperCall(node) { @@ -72605,36 +72873,36 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 171 /* Constructor */) { + if (container.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 214 /* ArrowFunction */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } // When targeting es6, mark that we'll need to capture `this` in its lexically bound scope. - if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { + if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ScriptTarget.ES2015 */) { captureLexicalThis(node, container); } var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); @@ -72669,7 +72937,7 @@ var ts; var className = getClassNameFromPrototypeMethod(container); if (isInJS && className) { var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* SymbolFlags.Function */)) { thisType = getDeclaredTypeOfSymbol(classSymbol).thisType; } } @@ -72717,9 +72985,9 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 213 /* FunctionExpression */ && + if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isBinaryExpression(container.parent) && - ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' return container.parent // x.prototype.y = container .left // x.prototype.y @@ -72727,31 +72995,31 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 169 /* MethodDeclaration */ && - container.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && + container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 213 /* FunctionExpression */ && - container.parent.kind === 296 /* PropertyAssignment */ && - container.parent.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && + container.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && + container.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.parent.left.expression; } // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 213 /* FunctionExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && ts.isObjectLiteralExpression(container.parent.parent) && ts.isCallExpression(container.parent.parent.parent) && container.parent.parent.parent.arguments[2] === container.parent.parent && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.parent.arguments[0].expression; } // Object.defineProperty(x, "method", { value() { } }); @@ -72763,17 +73031,17 @@ var ts; ts.isObjectLiteralExpression(container.parent) && ts.isCallExpression(container.parent.parent) && container.parent.parent.arguments[2] === container.parent && - ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.arguments[0].expression; } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 317 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 317 /* SyntaxKind.JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && - jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) { + jsDocFunctionType.parameters[0].name.escapedText === "this" /* InternalSymbolName.This */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -72783,18 +73051,18 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* SyntaxKind.Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 208 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 208 /* SyntaxKind.CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 214 /* ArrowFunction */) { + while (container && container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; + needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -72805,14 +73073,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* ComputedPropertyName */; }); - if (current && current.kind === 162 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* SyntaxKind.ComputedPropertyName */; }); + if (current && current.kind === 162 /* SyntaxKind.ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -72820,26 +73088,26 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 171 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.isStatic(container) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; + nodeCheckFlag = 512 /* NodeCheckFlags.SuperStatic */; if (!isCallExpression && - languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && + languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && (ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) { // for `super.x` or `super[x]` in a static initializer, mark all enclosing // block scope containers so that we can report potential collisions with // `Reflect`. ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) { if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) { - getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */; + getNodeLinks(current).flags |= 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */; } }); } } else { - nodeCheckFlag = 256 /* SuperInstance */; + nodeCheckFlag = 256 /* NodeCheckFlags.SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. @@ -72901,12 +73169,12 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 169 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { - getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */; } else { - getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */; } } if (needToCaptureLexicalThis) { @@ -72915,8 +73183,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 205 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES2015 */) { + if (container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; } @@ -72936,12 +73204,12 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 171 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 171 /* SyntaxKind.Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } - return nodeCheckFlag === 512 /* SuperStatic */ + return nodeCheckFlag === 512 /* NodeCheckFlags.SuperStatic */ ? getBaseConstructorTypeOfClass(classType) : getTypeWithThisArgument(baseClassType, classType.thisType); function isLegalUsageOfSuperExpression(container) { @@ -72951,7 +73219,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 171 /* Constructor */; + return container.kind === 171 /* SyntaxKind.Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -72959,23 +73227,23 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { if (ts.isStatic(container)) { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 170 /* ClassStaticBlockDeclaration */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } else { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 166 /* PropertySignature */ || - container.kind === 171 /* Constructor */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 166 /* SyntaxKind.PropertySignature */ || + container.kind === 171 /* SyntaxKind.Constructor */; } } } @@ -72983,22 +73251,22 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 169 /* MethodDeclaration */ || - func.kind === 172 /* GetAccessor */ || - func.kind === 173 /* SetAccessor */) && func.parent.kind === 205 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 213 /* FunctionExpression */ && func.parent.kind === 296 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ || + func.kind === 172 /* SyntaxKind.GetAccessor */ || + func.kind === 173 /* SyntaxKind.SetAccessor */) && func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ? func.parent : + func.kind === 213 /* SyntaxKind.FunctionExpression */ && func.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -73017,7 +73285,7 @@ var ts; // We have an object literal method. Check if the containing object literal has a contextual type // that includes a ThisType. If so, T is the contextual type for 'this'. We continue looking in // any directly enclosing object literals. - var contextualType = getApparentTypeOfContextualType(containingLiteral); + var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined); var literal = containingLiteral; var type = contextualType; while (type) { @@ -73025,11 +73293,11 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 296 /* PropertyAssignment */) { + if (literal.parent.kind !== 296 /* SyntaxKind.PropertyAssignment */) { break; } literal = literal.parent.parent; - type = getApparentTypeOfContextualType(literal); + type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined); } // There was no contextual ThisType for the containing object literal, so the contextual type // for 'this' is the non-null form of the contextual type for the containing object literal or @@ -73039,7 +73307,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -73067,7 +73335,7 @@ var ts; var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* Normal */); + return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; @@ -73086,31 +73354,31 @@ var ts; tryGetTypeAtPosition(contextualSignature, index); } } - function getContextualTypeForVariableLikeDeclaration(declaration) { + function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) { var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); if (typeNode) { return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return getContextuallyTypedParameterType(declaration); - case 203 /* BindingElement */: - return getContextualTypeForBindingElement(declaration); - case 167 /* PropertyDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + return getContextualTypeForBindingElement(declaration, contextFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isStatic(declaration)) { - return getContextualTypeForStaticPropertyDeclaration(declaration); + return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags); } // By default, do nothing and return undefined - only the above cases have context implied by a parent } } - function getContextualTypeForBindingElement(declaration) { + function getContextualTypeForBindingElement(declaration, contextFlags) { var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */); + var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || + parent.kind !== 203 /* SyntaxKind.BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 202 /* ArrayBindingPattern */) { + if (parent.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -73122,8 +73390,8 @@ var ts; return getTypeOfPropertyOfType(parentType, text); } } - function getContextualTypeForStaticPropertyDeclaration(declaration) { - var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent); + function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) { + var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags); if (!parentType) return undefined; return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName); @@ -73139,32 +73407,35 @@ var ts; function getContextualTypeForInitializerExpression(node, contextFlags) { var declaration = node.parent; if (ts.hasInitializer(declaration) && node === declaration.initializer) { - var result = getContextualTypeForVariableLikeDeclaration(declaration); + var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags); if (result) { return result; } - if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) { + if (!(contextFlags & 8 /* ContextFlags.SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) { return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } } return undefined; } - function getContextualTypeForReturnExpression(node) { + function getContextualTypeForReturnExpression(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); - if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function - var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; - var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined); - if (!iterationTypes) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { // Generator or AsyncGenerator function + var isAsyncGenerator_1 = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + if (contextualReturnType.flags & 1048576 /* TypeFlags.Union */) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, type, isAsyncGenerator_1); }); + } + var iterationReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, contextualReturnType, (functionFlags & 2 /* FunctionFlags.Async */) !== 0); + if (!iterationReturnType) { return undefined; } - contextualReturnType = iterationTypes.returnType; + contextualReturnType = iterationReturnType; // falls through to unwrap Promise for AsyncGenerators } - if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function + if (functionFlags & 2 /* FunctionFlags.Async */) { // Async function or AsyncGenerator function // Get the awaited type without the `Awaited` alias var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); @@ -73182,15 +73453,19 @@ var ts; } return undefined; } - function getContextualTypeForYieldOperand(node) { + function getContextualTypeForYieldOperand(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { var functionFlags = ts.getFunctionFlags(func); - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { + var isAsyncGenerator_2 = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + if (!node.asteriskToken && contextualReturnType.flags & 1048576 /* TypeFlags.Union */) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, type, isAsyncGenerator_2); }); + } return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, contextualReturnType, isAsyncGenerator_2); } } return undefined; @@ -73209,15 +73484,15 @@ var ts; return false; } function getContextualIterationType(kind, functionDecl) { - var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); - var contextualReturnType = getContextualReturnType(functionDecl); + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* FunctionFlags.Async */); + var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) || undefined; } return undefined; } - function getContextualReturnType(functionDecl) { + function getContextualReturnType(functionDecl, contextFlags) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed var returnType = getReturnTypeFromAnnotation(functionDecl); @@ -73232,7 +73507,7 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl); if (iife) { - return getContextualType(iife); + return getContextualType(iife, contextFlags); } return undefined; } @@ -73256,11 +73531,11 @@ var ts; } var restIndex = signature.parameters.length - 1; return signatureHasRestParameter(signature) && argIndex >= restIndex ? - getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) : getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 210 /* TaggedTemplateExpression */) { + if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -73269,13 +73544,13 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 63 /* EqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -73284,8 +73559,8 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: return undefined; @@ -73306,6 +73581,14 @@ var ts; var lhsType = getTypeOfExpression(e.expression); return ts.isPrivateIdentifier(e.name) ? tryGetPrivateIdentifierPropertyOfType(lhsType, e.name) : getPropertyOfType(lhsType, e.name.escapedText); } + if (ts.isElementAccessExpression(e)) { + var propType = checkExpressionCached(e.argumentExpression); + if (!isTypeUsableAsPropertyName(propType)) { + return undefined; + } + var lhsType = getTypeOfExpression(e.expression); + return getPropertyOfType(lhsType, getPropertyNameFromType(propType)); + } return undefined; function tryGetPrivateIdentifierPropertyOfType(type, id) { var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(id.escapedText, id); @@ -73318,8 +73601,8 @@ var ts; var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { - case 0 /* None */: - case 4 /* ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var lhsSymbol = getSymbolForExpression(binaryExpression.left); var decl = lhsSymbol && lhsSymbol.valueDeclaration; // Unannotated, uninitialized property declarations have a type implied by their usage in the constructor. @@ -73329,11 +73612,11 @@ var ts; return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || (ts.isPropertyDeclaration(decl) ? decl.initializer && getTypeOfExpression(binaryExpression.left) : undefined); } - if (kind === 0 /* None */) { + if (kind === 0 /* AssignmentDeclarationKind.None */) { return getTypeOfExpression(binaryExpression.left); } return getContextualTypeForThisPropertyAssignment(binaryExpression); - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { return getContextualTypeForThisPropertyAssignment(binaryExpression); } @@ -73354,7 +73637,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* SymbolFlags.Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated_1) { @@ -73368,18 +73651,18 @@ var ts; } return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left); } - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; // falls through - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration); var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration); return annotated ? getTypeFromTypeNode(annotated) : undefined; - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); @@ -73387,14 +73670,14 @@ var ts; } function isPossiblyAliasedThisProperty(declaration, kind) { if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); } - if (kind === 4 /* ThisProperty */) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */) { return true; } - if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) { + if (!ts.isInJSFile(declaration) || kind !== 5 /* AssignmentDeclarationKind.Property */ || !ts.isIdentifier(declaration.left.expression)) { return false; } var name = declaration.left.expression.escapedText; - var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); + var symbol = resolveName(declaration.left, name, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } function getContextualTypeForThisPropertyAssignment(binaryExpression) { @@ -73418,11 +73701,11 @@ var ts; return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined; } function isCircularMappedProperty(symbol) { - return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0); + return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0); } function getTypeOfPropertyOfContextualType(type, name, nameType) { return mapType(type, function (t) { - if (t.flags & 2097152 /* Intersection */) { + if (t.flags & 2097152 /* TypeFlags.Intersection */) { var intersection = t; var newTypes = ts.mapDefined(intersection.types, getTypeOfConcretePropertyOfContextualType); if (newTypes.length > 0) { @@ -73450,7 +73733,7 @@ var ts; } return undefined; } - if (t.flags & 3670016 /* StructuredType */) { + if (t.flags & 3670016 /* TypeFlags.StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop); @@ -73466,7 +73749,7 @@ var ts; } function getTypeOfApplicableIndexInfoOfContextualType(t) { var _a; - if (!(t.flags & 3670016 /* StructuredType */)) { + if (!(t.flags & 3670016 /* TypeFlags.StructuredType */)) { return undefined; } return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type; @@ -73477,7 +73760,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -73485,7 +73768,7 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; - var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags); if (propertyAssignmentType) { return propertyAssignmentType; } @@ -73512,7 +73795,7 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, + || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* IterationUse.Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, /*noReductions*/ true)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -73520,8 +73803,8 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined; } - function getContextualTypeForChildJsxExpression(node, child) { - var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName); + function getContextualTypeForChildJsxExpression(node, child, contextFlags) { + var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags); // JSX expression is in children of JSX Element, we will look for an "children" attribute (we get the name from JSX.ElementAttributesProperty) var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) { @@ -73539,27 +73822,27 @@ var ts; } }, /*noReductions*/ true)); } - function getContextualTypeForJsxExpression(node) { + function getContextualTypeForJsxExpression(node, contextFlags) { var exprParent = node.parent; return ts.isJsxAttributeLike(exprParent) - ? getContextualType(node) + ? getContextualType(node, contextFlags) : ts.isJsxElement(exprParent) - ? getContextualTypeForChildJsxExpression(exprParent, node) + ? getContextualTypeForChildJsxExpression(exprParent, node, contextFlags) : undefined; } - function getContextualTypeForJsxAttribute(attribute) { + function getContextualTypeForJsxAttribute(attribute, contextFlags) { // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type // which is a type of the parameter of the signature we are trying out. // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName if (ts.isJsxAttribute(attribute)) { - var attributesType = getApparentTypeOfContextualType(attribute.parent); + var attributesType = getApparentTypeOfContextualType(attribute.parent, contextFlags); if (!attributesType || isTypeAny(attributesType)) { return undefined; } return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { - return getContextualType(attribute.parent); + return getContextualType(attribute.parent, contextFlags); } } // Return true if the given expression is possibly a discriminant value. We limit the kinds of @@ -73567,29 +73850,29 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 79 /* Identifier */: - case 153 /* UndefinedKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 153 /* SyntaxKind.UndefinedKeyword */: return true; - case 206 /* PropertyAccessExpression */: - case 212 /* ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* SyntaxKind.JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -73598,21 +73881,21 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* ContextFlags.NoConstraints */ && instantiatedType.flags & 8650752 /* TypeFlags.TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : - apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + return apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing // return type inferences is available, instantiate those types using that mapper. function instantiateContextualType(contextualType, node, contextFlags) { - if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) { + if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) { var inferenceContext = getInferenceContext(node); // If no inferences have been made, nothing is gained from instantiating as type parameters // would just be replaced with their defaults similar to the apparent type. - if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { + if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { // For contextual signatures we incorporate all inferences made so far, e.g. from return // types as well as arguments to the left in a function call. return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); @@ -73623,7 +73906,7 @@ var ts; // the 'boolean' type from the contextual type such that contextually typed boolean // literals actually end up widening to 'boolean' (see #48363). var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); - return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? + return type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : type; } @@ -73634,13 +73917,13 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { return instantiateType(type, mapper); } - if (type.flags & 1048576 /* Union */) { - return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* None */); + if (type.flags & 1048576 /* TypeFlags.Union */) { + return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* UnionReduction.None */); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); })); } return type; @@ -73663,7 +73946,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -73672,65 +73955,65 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 214 /* ArrowFunction */: - case 247 /* ReturnStatement */: - return getContextualTypeForReturnExpression(node); - case 224 /* YieldExpression */: - return getContextualTypeForYieldOperand(parent); - case 218 /* AwaitExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 247 /* SyntaxKind.ReturnStatement */: + return getContextualTypeForReturnExpression(node, contextFlags); + case 224 /* SyntaxKind.YieldExpression */: + return getContextualTypeForYieldOperand(parent, contextFlags); + case 218 /* SyntaxKind.AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return getContextualTypeForArgument(parent, node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 204 /* ArrayLiteralExpression */: { + case 204 /* SyntaxKind.ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 233 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 223 /* TemplateExpression */); + case 233 /* SyntaxKind.TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 223 /* SyntaxKind.TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return !tag ? getContextualType(parent, contextFlags) : ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(tag.typeExpression.type); } - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return getContextualType(parent, contextFlags); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return tryGetTypeFromEffectiveTypeNode(parent); - case 288 /* JsxExpression */: - return getContextualTypeForJsxExpression(parent); - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - return getContextualTypeForJsxAttribute(parent); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + return getContextualTypeForJsxExpression(parent, contextFlags); + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + return getContextualTypeForJsxAttribute(parent, contextFlags); + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; function tryFindWhenConstTypeReference(node) { - return getContextualType(node); + return getContextualType(node, contextFlags); } } function getInferenceContext(node) { @@ -73738,7 +74021,7 @@ var ts; return ancestor && ancestor.inferenceContext; } function getContextualJsxElementAttributesType(node, contextFlags) { - if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) { + if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* ContextFlags.Completions */) { // Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit // _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type // (as below) instead! @@ -73747,7 +74030,7 @@ var ts; return getContextualTypeForArgumentAtIndex(node, 0); } function getEffectiveFirstArgumentForJsxSignature(signature, node) { - return getJsxReferenceKind(node) !== 0 /* Component */ + return getJsxReferenceKind(node) !== 0 /* JsxReferenceKind.Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } @@ -73792,7 +74075,7 @@ var ts; return getOrCreateTypeFromSignature(fakeSignature); } var tagType = checkExpressionCached(context.tagName); - if (tagType.flags & 128 /* StringLiteral */) { + if (tagType.flags & 128 /* TypeFlags.StringLiteral */) { var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); if (!result) { return errorType; @@ -73807,7 +74090,7 @@ var ts; if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); - if (managedSym.flags & 524288 /* TypeAlias */) { + if (managedSym.flags & 524288 /* SymbolFlags.TypeAlias */) { var params = getSymbolLinks(managedSym).typeParameters; if (ts.length(params) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); @@ -73908,12 +74191,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -73935,18 +74218,18 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 2097152 /* Intersection */; - result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 2097152 /* TypeFlags.Intersection */; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. function getContextualCallSignature(type, node) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } @@ -73976,16 +74259,16 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */); if (!type) { return undefined; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -74014,38 +74297,38 @@ var ts; } } function checkSpreadExpression(node, checkMode) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); + return checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, arrayOrIterableType, undefinedType, node.expression); } function checkSyntheticExpression(node) { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 203 /* BindingElement */ && !!node.initializer) || - (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); + return (node.kind === 203 /* SyntaxKind.BindingElement */ && !!node.initializer) || + (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; var elementCount = elements.length; var elementTypes = []; var elementFlags = []; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined); var inDestructuringPattern = ts.isAssignmentTarget(node); var inConstContext = isConstContext(node); var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 225 /* SpreadElement */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var spreadType = checkExpression(e.expression, checkMode, forceTuple); if (isArrayLikeType(spreadType)) { elementTypes.push(spreadType); - elementFlags.push(8 /* Variadic */); + elementFlags.push(8 /* ElementFlags.Variadic */); } else if (inDestructuringPattern) { // Given the following situation: @@ -74061,27 +74344,27 @@ var ts; // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. var restElementType = getIndexTypeOfType(spreadType, numberType) || - getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || + getIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || unknownType; elementTypes.push(restElementType); - elementFlags.push(4 /* Rest */); + elementFlags.push(4 /* ElementFlags.Rest */); } else { - elementTypes.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, e.expression)); - elementFlags.push(4 /* Rest */); + elementTypes.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, e.expression)); + elementFlags.push(4 /* ElementFlags.Rest */); } } - else if (exactOptionalPropertyTypes && e.kind === 227 /* OmittedExpression */) { + else if (exactOptionalPropertyTypes && e.kind === 227 /* SyntaxKind.OmittedExpression */) { hasOmittedExpression = true; elementTypes.push(missingType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); - elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); - if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) { + elementFlags.push(hasOmittedExpression ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */); + if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && isContextSensitive(e)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context addIntraExpressionInferenceSite(inferenceContext, e, type); @@ -74095,28 +74378,28 @@ var ts; return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? - getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* Subtype */) : + getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* UnionReduction.Subtype */) : strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext)); } function createArrayLiteralType(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */)) { return type; } var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 16384 /* ArrayLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 16384 /* ObjectFlags.ArrayLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return isNumericComputedName(name); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isNumericLiteralName(name.escapedText); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return ts.isNumericLiteralName(name.text); default: return false; @@ -74125,14 +74408,14 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* TypeFlags.NumberLike */); } function checkComputedPropertyName(node) { var links = getNodeLinks(node.expression); if (!links.resolvedType) { if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent)) - && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */ - && node.parent.kind !== 172 /* GetAccessor */ && node.parent.kind !== 173 /* SetAccessor */) { + && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ + && node.parent.kind !== 172 /* SyntaxKind.GetAccessor */ && node.parent.kind !== 173 /* SyntaxKind.SetAccessor */) { return links.resolvedType = errorType; } links.resolvedType = checkExpression(node.expression); @@ -74143,17 +74426,17 @@ var ts; var enclosingIterationStatement = getEnclosingIterationStatement(container); if (enclosingIterationStatement) { // The computed field name will use a block scoped binding which can be unique for each iteration of the loop. - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; // The generated variable which stores the computed field name must be block-scoped. - getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; // The generated variable which stores the class must be block-scoped. - getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node.parent.parent).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } } // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 98304 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* TypeFlags.Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -74169,7 +74452,7 @@ var ts; var _a; var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) && - isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */)); + isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* TypeFlags.ESSymbol */)); } function getObjectLiteralIndexInfo(node, offset, properties, keyType) { var propTypes = []; @@ -74181,11 +74464,11 @@ var ts; propTypes.push(getTypeOfSymbol(properties[i])); } } - var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType; + var unionType = propTypes.length ? getUnionType(propTypes, 2 /* UnionReduction.Subtype */) : undefinedType; return createIndexInfo(keyType, unionType, isConstContext(node)); } function getImmediateAliasedSymbol(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); @@ -74203,11 +74486,11 @@ var ts; var propertiesTable = ts.createSymbolTable(); var propertiesArray = []; var spread = emptyObjectType; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* SyntaxKind.ObjectLiteralExpression */); var inConstContext = isConstContext(node); - var checkFlags = inConstContext ? 8 /* Readonly */ : 0; + var checkFlags = inConstContext ? 8 /* CheckFlags.Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -74229,16 +74512,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 296 /* PropertyAssignment */ || - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 296 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -74250,29 +74533,29 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 458752 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 458752 /* ObjectFlags.PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? - createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : - createSymbol(4 /* Property */ | member.flags, member.escapedName, checkFlags); + createSymbol(4 /* SymbolFlags.Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* CheckFlags.Late */) : + createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName, checkFlags); if (nameType) { prop.nameType = nameType; } if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 296 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 297 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 16777216 /* Optional */; + prop.flags |= 16777216 /* SymbolFlags.Optional */; } } - else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.escapedName); if (impliedProp) { - prop.flags |= impliedProp.flags & 16777216 /* Optional */; + prop.flags |= impliedProp.flags & 16777216 /* SymbolFlags.Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -74287,17 +74570,17 @@ var ts; prop.target = member; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); - if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && - (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) { + if (contextualType && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && + (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || memberDecl.kind === 169 /* SyntaxKind.MethodDeclaration */) && isContextSensitive(memberDecl)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context - var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl; + var inferenceNode = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? memberDecl.initializer : memberDecl; addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type); } } - else if (memberDecl.kind === 298 /* SpreadAssignment */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + else if (memberDecl.kind === 298 /* SyntaxKind.SpreadAssignment */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(memberDecl, 2 /* ExternalEmitHelpers.Assign */); } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -74331,10 +74614,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 172 /* GetAccessor */ || memberDecl.kind === 173 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 172 /* SyntaxKind.GetAccessor */ || memberDecl.kind === 173 /* SyntaxKind.SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -74359,11 +74642,11 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 298 /* SyntaxKind.SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { - if (!(prop.flags & 16777216 /* Optional */)) { + if (!(prop.flags & 16777216 /* SymbolFlags.Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } propertiesTable.set(prop.escapedName, prop); @@ -74395,12 +74678,12 @@ var ts; if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType)); var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 4096 /* JSLiteral */; + result.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; } if (patternWithComputedProperties) { - result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; } if (inDestructuringPattern) { result.pattern = node; @@ -74410,8 +74693,8 @@ var ts; } function isValidSpreadType(type) { var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType)); - return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || - t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); + return !!(t.flags & (1 /* TypeFlags.Any */ | 67108864 /* TypeFlags.NonPrimitive */ | 524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + t.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); @@ -74457,7 +74740,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* SyntaxKind.Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -74481,15 +74764,15 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 2048 /* JsxAttributes */; + var objectFlags = 2048 /* ObjectFlags.JsxAttributes */; var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { var attributeDecl = _a[_i]; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); - objectFlags |= ts.getObjectFlags(exprType) & 458752 /* PropagatingFlags */; - var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); + objectFlags |= ts.getObjectFlags(exprType) & 458752 /* ObjectFlags.PropagatingFlags */; + var attributeSymbol = createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; if (member.valueDeclaration) { @@ -74504,7 +74787,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 287 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 287 /* SyntaxKind.JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -74531,7 +74814,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 278 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 278 /* SyntaxKind.JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -74542,10 +74825,10 @@ var ts; if (explicitlySpecifyChildrenAttribute) { error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName)); } - var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); + var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process - var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); + var childrenPropSymbol = createSymbol(4 /* SymbolFlags.Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); @@ -74573,7 +74856,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return result; } } @@ -74583,12 +74866,12 @@ var ts; var child = _a[_i]; // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that // because then type of children property will have constituent of string type. - if (child.kind === 11 /* JsxText */) { + if (child.kind === 11 /* SyntaxKind.JsxText */) { if (!child.containsOnlyTriviaWhiteSpaces) { childrenTypes.push(stringType); } } - else if (child.kind === 288 /* JsxExpression */ && !child.expression) { + else if (child.kind === 288 /* SyntaxKind.JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -74600,7 +74883,7 @@ var ts; function checkSpreadPropOverrides(type, props, spread) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var right = _a[_i]; - if (!(right.flags & 16777216 /* Optional */)) { + if (!(right.flags & 16777216 /* SymbolFlags.Optional */)) { var left = props.get(right.escapedName); if (left) { var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); @@ -74620,7 +74903,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* SymbolFlags.Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -74639,13 +74922,13 @@ var ts; return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; + links.jsxFlags |= 1 /* JsxFlags.IntrinsicNamedElement */; return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + links.jsxFlags |= 2 /* JsxFlags.IntrinsicIndexedElement */; return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found @@ -74694,10 +74977,10 @@ var ts; var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location); if (!resolvedNamespace || resolvedNamespace === unknownSymbol) { var namespaceName = getJsxNamespace(location); - resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + resolvedNamespace = resolveName(location, namespaceName, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); } if (resolvedNamespace) { - var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */)); + var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* SymbolFlags.Namespace */)); if (candidate && candidate !== unknownSymbol) { if (links) { links.jsxNamespace = candidate; @@ -74710,7 +74993,7 @@ var ts; } } // JSX global fallback - var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined)); + var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined)); if (s === unknownSymbol) { return undefined; // TODO: GH#18217 } @@ -74725,7 +75008,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* SymbolFlags.Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -74749,7 +75032,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* SymbolFlags.Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -74763,10 +75046,10 @@ var ts; return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } function getUninstantiatedJsxSignaturesOfType(elementType, caller) { - if (elementType.flags & 4 /* String */) { + if (elementType.flags & 4 /* TypeFlags.String */) { return [anySignature]; } - else if (elementType.flags & 128 /* StringLiteral */) { + else if (elementType.flags & 128 /* TypeFlags.StringLiteral */) { var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller); if (!intrinsicType) { error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements); @@ -74779,12 +75062,12 @@ var ts; } var apparentElemType = getApparentType(elementType); // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(apparentElemType, 1 /* Construct */); + var signatures = getSignaturesOfType(apparentElemType, 1 /* SignatureKind.Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures - signatures = getSignaturesOfType(apparentElemType, 0 /* Call */); + signatures = getSignaturesOfType(apparentElemType, 0 /* SignatureKind.Call */); } - if (signatures.length === 0 && apparentElemType.flags & 1048576 /* Union */) { + if (signatures.length === 0 && apparentElemType.flags & 1048576 /* TypeFlags.Union */) { // If each member has some combination of new/call signatures; make a union signature list for those signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); })); } @@ -74812,13 +75095,13 @@ var ts; return anyType; } function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { - if (refKind === 1 /* Function */) { + if (refKind === 1 /* JsxReferenceKind.Function */) { var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); if (sfcReturnConstraint) { checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } - else if (refKind === 0 /* Component */) { + else if (refKind === 0 /* JsxReferenceKind.Component */) { var classConstraint = getJsxElementClassTypeAt(openingLikeElement); if (classConstraint) { // Issue an error if this return type isn't assignable to JSX.ElementClass, failing that @@ -74849,10 +75132,10 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + if (links.jsxFlags & 1 /* JsxFlags.IntrinsicNamedElement */) { return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + else if (links.jsxFlags & 2 /* JsxFlags.IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType; } @@ -74886,7 +75169,7 @@ var ts; } function checkJsxPreconditions(errorNode) { // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + if ((compilerOptions.jsx || 0 /* JsxEmit.None */) === 0 /* JsxEmit.None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } if (getJsxElementTypeAt(errorNode) === undefined) { @@ -74904,20 +75187,20 @@ var ts; if (!getJsxNamespaceContainerForImplicitImport(node)) { // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; + var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* JsxEmit.React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var jsxFactoryNamespace = getJsxNamespace(node); var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; // allow null as jsxFragmentFactory var jsxFactorySym = void 0; if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); + jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); } if (jsxFactorySym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not jsxFactory as there wont be error being emitted - jsxFactorySym.isReferenced = 67108863 /* All */; + jsxFactorySym.isReferenced = 67108863 /* SymbolFlags.All */; // If react/jsxFactory symbol is alias, mark it as refereced - if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { + if (jsxFactorySym.flags & 2097152 /* SymbolFlags.Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { markAliasSymbolAsReferenced(jsxFactorySym); } } @@ -74926,7 +75209,7 @@ var ts; var file = ts.getSourceFileOfNode(node); var localJsxNamespace = getLocalJsxNamespace(file); if (localJsxNamespace) { - resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); + resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); } } } @@ -74951,7 +75234,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 524288 /* Object */) { + if (targetType.flags & 524288 /* TypeFlags.Object */) { // For backwards compatibility a symbol-named property is satisfied by a string index signature. This // is incorrect and inconsistent with element access expressions, where it is an error, so eventually // we should remove this exception. @@ -74963,7 +75246,7 @@ var ts; return true; } } - else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { + else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -74974,10 +75257,10 @@ var ts; return false; } function isExcessPropertyCheckTarget(type) { - return !!(type.flags & 524288 /* Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || - type.flags & 67108864 /* NonPrimitive */ || - type.flags & 1048576 /* Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); + return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) || + type.flags & 67108864 /* TypeFlags.NonPrimitive */ || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); } function checkJsxExpression(node, checkMode) { checkGrammarJsxExpression(node); @@ -75000,13 +75283,13 @@ var ts; * Note that this is not tracked well within the compiler, so the answer may be incorrect. */ function isPrototypeProperty(symbol) { - if (symbol.flags & 8192 /* Method */ || ts.getCheckFlags(symbol) & 4 /* SyntheticMethod */) { + if (symbol.flags & 8192 /* SymbolFlags.Method */ || ts.getCheckFlags(symbol) & 4 /* CheckFlags.SyntheticMethod */) { return true; } if (ts.isInJSFile(symbol.valueDeclaration)) { var parent = symbol.valueDeclaration.parent; return parent && ts.isBinaryExpression(parent) && - ts.getAssignmentDeclarationKind(parent) === 3 /* PrototypeProperty */; + ts.getAssignmentDeclarationKind(parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } } /** @@ -75020,9 +75303,9 @@ var ts; function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } var errorNode = !reportError ? undefined : - node.kind === 161 /* QualifiedName */ ? node.right : - node.kind === 200 /* ImportType */ ? node : - node.kind === 203 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + node.kind === 161 /* SyntaxKind.QualifiedName */ ? node.right : + node.kind === 200 /* SyntaxKind.ImportType */ ? node : + node.kind === 203 /* SyntaxKind.BindingElement */ && node.propertyName ? node.propertyName : node.name; return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode); } /** @@ -75045,7 +75328,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { if (errorNode) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -75053,7 +75336,7 @@ var ts; return false; } } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -75065,7 +75348,7 @@ var ts; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + if ((flags & 128 /* ModifierFlags.Abstract */) && symbolHasNonMethodDeclaration(prop) && (ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { @@ -75076,12 +75359,12 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { return true; } // Property is known to be private or protected at this point // Private property is accessible if the property is within the declaring class - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -75108,7 +75391,7 @@ var ts; // static member access is disallowed enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 32 /* ModifierFlags.Static */ || !enclosingClass) { if (errorNode) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } @@ -75116,10 +75399,10 @@ var ts; } } // No further restrictions for static properties - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return true; } - if (containingType.flags & 262144 /* TypeParameter */) { + if (containingType.flags & 262144 /* TypeFlags.TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -75134,10 +75417,10 @@ var ts; function getEnclosingClassFromThisParameter(node) { var thisParameter = getThisParameterFromNodeContext(node); var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type); - if (thisType && thisType.flags & 262144 /* TypeParameter */) { + if (thisType && thisType.flags & 262144 /* TypeFlags.TypeParameter */) { thisType = getConstraintOfTypeParameter(thisType); } - if (thisType && ts.getObjectFlags(thisType) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (thisType && ts.getObjectFlags(thisType) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { return getTargetType(thisType); } return undefined; @@ -75147,39 +75430,39 @@ var ts; return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined; } function symbolHasNonMethodDeclaration(symbol) { - return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); + return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* SymbolFlags.Method */); }); } function checkNonNullExpression(node) { return checkNonNullType(checkExpression(node), node); } function isNullableType(type) { - return !!(getTypeFacts(type) & 50331648 /* IsUndefinedOrNull */); + return !!(getTypeFacts(type) & 50331648 /* TypeFacts.IsUndefinedOrNull */); } function getNonNullableTypeIfNeeded(type) { return isNullableType(type) ? getNonNullableType(type) : type; } function reportObjectPossiblyNullOrUndefinedError(node, facts) { - error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? + error(node, facts & 16777216 /* TypeFacts.IsUndefined */ ? facts & 33554432 /* TypeFacts.IsNull */ ? ts.Diagnostics.Object_is_possibly_null_or_undefined : ts.Diagnostics.Object_is_possibly_undefined : ts.Diagnostics.Object_is_possibly_null); } function reportCannotInvokePossiblyNullOrUndefinedError(node, facts) { - error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? + error(node, facts & 16777216 /* TypeFacts.IsUndefined */ ? facts & 33554432 /* TypeFacts.IsNull */ ? ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); } function checkNonNullTypeWithReporter(type, node, reportError) { - if (strictNullChecks && type.flags & 2 /* Unknown */) { + if (strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } var facts = getTypeFacts(type); - if (facts & 50331648 /* IsUndefinedOrNull */) { + if (facts & 50331648 /* TypeFacts.IsUndefinedOrNull */) { reportError(node, facts); var t = getNonNullableType(type); - return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; + return t.flags & (98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */) ? errorType : t; } return type; } @@ -75188,13 +75471,13 @@ var ts; } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); - if (nonNullType.flags & 16384 /* Void */) { + if (nonNullType.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.Object_is_possibly_undefined); } return nonNullType; } function checkPropertyAccessExpression(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } function checkPropertyAccessChain(node, checkMode) { @@ -75207,7 +75490,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 212 /* ParenthesizedExpression */) { + while (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -75231,7 +75514,7 @@ var ts; if (!ts.isExpressionNode(privId)) { return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression); } - var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* InKeyword */; + var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) { return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId)); } @@ -75303,16 +75586,16 @@ var ts; function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); - var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); + var apparentType = getApparentType(assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { - if (languageVersion < 99 /* ESNext */) { - if (assignmentKind !== 0 /* None */) { - checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + if (assignmentKind !== 0 /* AssignmentKind.None */) { + checkExternalEmitHelpers(node, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } - if (assignmentKind !== 1 /* Definite */) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + if (assignmentKind !== 1 /* AssignmentKind.Definite */) { + checkExternalEmitHelpers(node, 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */); } } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); @@ -75334,8 +75617,8 @@ var ts; return errorType; } else { - var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* AssignmentKind.Definite */) { error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); } } @@ -75347,7 +75630,7 @@ var ts; } return isErrorType(apparentType) ? errorType : apparentType; } - prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === 161 /* QualifiedName */); + prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === 161 /* SyntaxKind.QualifiedName */); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined @@ -75357,13 +75640,13 @@ var ts; // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`. if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || - !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && node.parent.kind === 299 /* EnumMember */)) || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* SymbolFlags.EnumMember */ && node.parent.kind === 299 /* SyntaxKind.EnumMember */)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; if (!prop) { - var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? + var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined; if (!(indexInfo && indexInfo.type)) { var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true); @@ -75371,7 +75654,7 @@ var ts; return anyType; } if (leftType.symbol === globalThisSymbol) { - if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */)) { + if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* SymbolFlags.BlockScoped */)) { error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); } else if (noImplicitAny) { @@ -75391,7 +75674,7 @@ var ts; if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) { error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText)); } - if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) { + if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* NodeFlags.Deprecated */) { addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText); } } @@ -75403,7 +75686,7 @@ var ts; markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; var writing = ts.isWriteAccess(node); - checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 106 /* SyntaxKind.SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; @@ -75422,11 +75705,11 @@ var ts; function isUncheckedJSSuggestion(node, suggestion, excludeClasses) { var file = ts.getSourceFileOfNode(node); if (file) { - if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) { + if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */)) { var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode); return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) - && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */) - && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */); + && !(excludeClasses && suggestion && suggestion.flags & 32 /* SymbolFlags.Class */) + && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */); } } return false; @@ -75436,12 +75719,12 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (assignmentKind === 1 /* Definite */) { - return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + if (assignmentKind === 1 /* AssignmentKind.Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* SymbolFlags.Optional */)); } if (prop && - !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) - && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + !(prop.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */ | 98304 /* SymbolFlags.Accessor */)) + && !(prop.flags & 8192 /* SymbolFlags.Method */ && propType.flags & 1048576 /* TypeFlags.Union */) && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } @@ -75454,12 +75737,12 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isPropertyWithoutInitializer(declaration)) { if (!ts.isStatic(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) { + if (flowContainer.kind === 171 /* SyntaxKind.Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { assumeUninitialized = true; } } @@ -75490,13 +75773,13 @@ var ts; && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* Static */) + && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* ModifierFlags.Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 257 /* ClassDeclaration */ && - node.parent.kind !== 178 /* TypeReference */ && - !(valueDeclaration.flags & 16777216 /* Ambient */) && + else if (valueDeclaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && + node.parent.kind !== 178 /* SyntaxKind.TypeReference */ && + !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -75507,25 +75790,25 @@ var ts; function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 296 /* PropertyAssignment */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 298 /* SpreadAssignment */: - case 162 /* ComputedPropertyName */: - case 233 /* TemplateSpan */: - case 288 /* JsxExpression */: - case 285 /* JsxAttribute */: - case 286 /* JsxAttributes */: - case 287 /* JsxSpreadAttribute */: - case 280 /* JsxOpeningElement */: - case 228 /* ExpressionWithTypeArguments */: - case 291 /* HeritageClause */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 298 /* SyntaxKind.SpreadAssignment */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 233 /* SyntaxKind.TemplateSpan */: + case 288 /* SyntaxKind.JsxExpression */: + case 285 /* SyntaxKind.JsxAttribute */: + case 286 /* SyntaxKind.JsxAttributes */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 291 /* SyntaxKind.HeritageClause */: return false; - case 214 /* ArrowFunction */: - case 238 /* ExpressionStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -75537,7 +75820,7 @@ var ts; * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. */ function isPropertyDeclaredInAncestorClass(prop) { - if (!(prop.parent.flags & 32 /* Class */)) { + if (!(prop.parent.flags & 32 /* SymbolFlags.Class */)) { return false; } var classType = getTypeOfSymbol(prop.parent); @@ -75562,7 +75845,7 @@ var ts; function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { var errorInfo; var relatedInfo; - if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { + if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* TypeFlags.Union */ && !(containingType.flags & 131068 /* TypeFlags.Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) { @@ -75650,7 +75933,7 @@ var ts; } } function getSuggestedSymbolForNonexistentClassMember(name, baseType) { - return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */); + return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* SymbolFlags.ClassMember */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); @@ -75661,7 +75944,7 @@ var ts; } name = ts.idText(name); } - return getSpellingSuggestionForName(name, props, 111551 /* Value */); + return getSpellingSuggestionForName(name, props, 111551 /* SymbolFlags.Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -75669,7 +75952,7 @@ var ts; var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; }) : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; }) : undefined; - return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* Value */); + return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* SymbolFlags.Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -75688,7 +75971,7 @@ var ts; var candidates; if (symbols === globals) { var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1))) - ? createSymbol(524288 /* TypeAlias */, s) + ? createSymbol(524288 /* SymbolFlags.TypeAlias */, s) : undefined; }); candidates = primitives.concat(ts.arrayFrom(symbols.values())); } @@ -75704,7 +75987,7 @@ var ts; return symbolResult && ts.symbolName(symbolResult); } function getSuggestedSymbolForNonexistentModule(name, targetModule) { - return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */); + return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* SymbolFlags.ModuleMember */); } function getSuggestionForNonexistentExport(name, targetModule) { var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule); @@ -75735,7 +76018,7 @@ var ts; return suggestion; } function getSuggestedTypeForNonexistentStringLiteralType(source, target) { - var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); }); + var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); }); return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; }); } /** @@ -75763,7 +76046,7 @@ var ts; if (candidate.flags & meaning) { return candidateName; } - if (candidate.flags & 2097152 /* Alias */) { + if (candidate.flags & 2097152 /* SymbolFlags.Alias */) { var alias = tryResolveAlias(candidate); if (alias && alias.flags & meaning) { return candidateName; @@ -75773,16 +76056,16 @@ var ts; } } function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { - var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; + var valueDeclaration = prop && (prop.flags & 106500 /* SymbolFlags.ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } - var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); + var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* ModifierFlags.Private */); var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } - if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { + if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SymbolFlags.SetAccessor */)) { return; } if (isSelfTypeAccess) { @@ -75792,19 +76075,19 @@ var ts; return; } } - (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; + (ts.getCheckFlags(prop) & 1 /* CheckFlags.Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* SymbolFlags.All */; } function isSelfTypeAccess(name, parent) { - return name.kind === 108 /* ThisKeyword */ + return name.kind === 108 /* SyntaxKind.ThisKeyword */ || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 161 /* SyntaxKind.QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } @@ -75819,7 +76102,7 @@ var ts; * @param property the accessed property's symbol. */ function isValidPropertyAccessForCompletions(node, type, property) { - return isPropertyAccessible(node, node.kind === 206 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, + return isPropertyAccessible(node, node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, /* isWrite */ false, type, property); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } @@ -75859,13 +76142,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 79 /* Identifier */) { + else if (initializer.kind === 79 /* SyntaxKind.Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -75882,13 +76165,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 79 /* Identifier */) { + if (e.kind === 79 /* SyntaxKind.Identifier */) { var symbol = getResolvedSymbol(e); - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 243 /* ForInStatement */ && + if (node.kind === 243 /* SyntaxKind.ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -75902,7 +76185,7 @@ var ts; return false; } function checkIndexedAccess(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkElementAccessChain(node, checkMode) : checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } function checkElementAccessChain(node, checkMode) { @@ -75911,7 +76194,7 @@ var ts; return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } function checkElementAccessExpression(node, exprType, checkMode) { - var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; + var objectType = ts.getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); if (isErrorType(objectType) || objectType === silentNeverType) { @@ -75923,8 +76206,8 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : - 32 /* ExpressionPosition */; + 4 /* AccessFlags.Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* AccessFlags.NoIndexSignatures */ : 0) : + 32 /* AccessFlags.ExpressionPosition */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -75937,13 +76220,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 165 /* Decorator */) { + else if (node.kind !== 165 /* SyntaxKind.Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -76007,16 +76290,16 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 225 /* SpreadElement */ || arg.kind === 232 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } function acceptsVoid(t) { - return !!(t.flags & 16384 /* Void */); + return !!(t.flags & 16384 /* TypeFlags.Void */); } function acceptsVoidUndefinedUnknownOrAny(t) { - return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */)); + return !!(t.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 2 /* TypeFlags.Unknown */ | 1 /* TypeFlags.Any */)); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -76024,9 +76307,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 223 /* TemplateExpression */) { + if (node.template.kind === 223 /* SyntaxKind.TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -76037,11 +76320,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = node.template; - ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 165 /* Decorator */) { + else if (node.kind === 165 /* SyntaxKind.Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -76055,7 +76338,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 209 /* NewExpression */); + ts.Debug.assert(node.kind === 209 /* SyntaxKind.NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -76079,7 +76362,7 @@ var ts; } for (var i = argCount; i < effectiveMinimumArguments; i++) { var type = getTypeAtPosition(signature, i); - if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* TypeFlags.Never */) { return false; } } @@ -76095,20 +76378,20 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false); } function getSingleCallOrConstructSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false) || - getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false) || + getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ false); } function getSingleSignature(type, kind, allowMembers) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) { - if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + if (kind === 0 /* SignatureKind.Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { return resolved.callSignatures[0]; } - if (kind === 1 /* Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + if (kind === 1 /* SignatureKind.Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { return resolved.constructSignatures[0]; } } @@ -76117,12 +76400,12 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) { - var context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes); + var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes); // We clone the inferenceContext to avoid fixing. For example, when the source signature is (x: T) => T[] and // the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any') // for T but leave it possible to later infer '[any]' back to A. var restType = getEffectiveRestType(contextualSignature); - var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); + var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; applyToParameterTypes(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -76130,7 +76413,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 128 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -76158,14 +76441,14 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 165 /* Decorator */) { + if (node.kind !== 165 /* SyntaxKind.Decorator */) { var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }); - var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */); + var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */); if (contextualType) { var inferenceTargetType = getReturnTypeOfSignature(signature); if (couldContainTypeVariables(inferenceTargetType)) { var outerContext = getInferenceContext(node); - var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType; + var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) !== contextualType; // A return type inference from a binding pattern can be used in instantiating the contextual // type of an argument later in inference, but cannot stand on its own as the final return type. // It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`, @@ -76180,7 +76463,7 @@ var ts; // We clone the inference context to avoid disturbing a resolution in progress for an // outer call expression. Effectively we just want a snapshot of whatever has been // inferred for any outer call expression so far. - var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */)); + var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* InferenceFlags.NoDefault */)); var instantiatedType = instantiateType(contextualType, outerMapper); // If the contextual type is a generic function type with a single call signature, we // instantiate the type with its own type parameters and type arguments. This ensures that @@ -76194,7 +76477,7 @@ var ts; getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */); } // Create a type mapper for instantiating generic contextual types using the inferences made // from the return type. We need a separate inference pass here because (a) instantiation of @@ -76209,7 +76492,7 @@ var ts; } var restType = getNonArrayRestType(signature); var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; }); if (info) { info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined; @@ -76222,7 +76505,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */ && !(checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { var paramType = getTypeAtPosition(signature, i); if (couldContainTypeVariables(paramType)) { var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); @@ -76237,10 +76520,10 @@ var ts; return getInferredTypes(context); } function getMutableArrayOrTupleType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : - type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getMutableArrayOrTupleType) : + type.flags & 1 /* TypeFlags.Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, /*readonly*/ false, type.target.labeledElementDeclarations) : - createTupleType([type], [8 /* Variadic */]); + createTupleType([type], [8 /* ElementFlags.Variadic */]); } function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) { if (index >= argCount - 1) { @@ -76248,7 +76531,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 232 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -76258,24 +76541,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 232 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 225 /* SpreadElement */ ? arg.expression : arg)); - flags.push(4 /* Rest */); + types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg)); + flags.push(4 /* ElementFlags.Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */); + var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); - flags.push(1 /* Required */); + flags.push(1 /* ElementFlags.Required */); } - if (arg.kind === 232 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -76305,16 +76588,16 @@ var ts; } function getJsxReferenceKind(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } var tagType = getApparentType(checkExpression(node.tagName)); - if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { - return 0 /* Component */; + if (ts.length(getSignaturesOfType(tagType, 1 /* SignatureKind.Construct */))) { + return 0 /* JsxReferenceKind.Component */; } - if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { - return 1 /* Function */; + if (ts.length(getSignaturesOfType(tagType, 0 /* SignatureKind.Call */))) { + return 1 /* JsxReferenceKind.Function */; } - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. @@ -76339,7 +76622,7 @@ var ts; if (!tagType) { return true; } - var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */); + var tagCallSignatures = getSignaturesOfType(tagType, 0 /* SignatureKind.Call */); if (!ts.length(tagCallSignatures)) { return true; } @@ -76347,12 +76630,12 @@ var ts; if (!factory) { return true; } - var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); + var factorySymbol = resolveEntityName(factory, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); if (!factorySymbol) { return true; } var factoryType = getTypeOfSymbol(factorySymbol); - var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */); + var callSignatures = getSignaturesOfType(factoryType, 0 /* SignatureKind.Call */); if (!ts.length(callSignatures)) { return true; } @@ -76362,7 +76645,7 @@ var ts; for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) { var sig = callSignatures_1[_i]; var firstparam = getTypeAtPosition(sig, 0); - var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */); + var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* SignatureKind.Call */); if (!ts.length(signaturesOfParam)) continue; for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) { @@ -76419,7 +76702,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 209 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -76437,13 +76720,13 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; + var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); @@ -76482,8 +76765,8 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - var expression = node.kind === 208 /* CallExpression */ ? node.expression : - node.kind === 210 /* TaggedTemplateExpression */ ? node.tag : undefined; + var expression = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression : + node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */ ? node.tag : undefined; if (expression) { var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { @@ -76501,17 +76784,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 165 /* Decorator */) { + if (node.kind === 165 /* SyntaxKind.Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -76522,15 +76805,15 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_25 = function (i) { + var _loop_26 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 225 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; var flags = spreadType.target.elementFlags[i]; - var syntheticArg = createSyntheticExpression(arg, flags & 4 /* Rest */ ? createArrayType(t) : t, !!(flags & 12 /* Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + var syntheticArg = createSyntheticExpression(arg, flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t, !!(flags & 12 /* ElementFlags.Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); effectiveArgs_1.push(syntheticArg); }); } @@ -76539,7 +76822,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_25(i); + _loop_26(i); } return effectiveArgs_1; } @@ -76552,30 +76835,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 171 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 171 /* SyntaxKind.Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 167 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && languageVersion !== 0 /* ScriptTarget.ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -76589,17 +76872,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return 1; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return 2; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments - return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 164 /* Parameter */: + return languageVersion === 0 /* ScriptTarget.ES3 */ || signature.parameters.length <= 2 ? 2 : 3; + case 164 /* SyntaxKind.Parameter */: return 3; default: return ts.Debug.fail(); @@ -76633,7 +76916,7 @@ var ts; function isPromiseResolveArityError(node) { if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression)) return false; - var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); + var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, undefined, undefined, false); var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { return false; @@ -76741,15 +77024,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 210 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 165 /* Decorator */; + var isTaggedTemplate = node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; + var isDecorator = node.kind === 165 /* SyntaxKind.Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; - if (!isDecorator) { + if (!isDecorator && !ts.isSuperCall(node)) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -76776,8 +77059,8 @@ var ts; // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; - var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */; - argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */; + var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* CheckMode.SkipContextSensitive */ : 0 /* CheckMode.Normal */; + argCheckMode |= checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; // The following variables are captured and modified by calls to chooseOverload. // If overload resolution or type argument inference fails, we want to report the // best error possible. The best error is one which says that an argument was not @@ -76805,7 +77088,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 208 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* CheckMode.IsForSignatureHelp */) && node.kind === 208 /* SyntaxKind.CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -76825,6 +77108,15 @@ var ts; if (result) { return result; } + result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + // Preemptively cache the result; getResolvedSignature will do this after we return, but + // we need to ensure that the result is present for the error checks below so that if + // this signature is encountered again, we handle the circularity (rather than producing a + // different result which may produce no errors and assert). Callers of getResolvedSignature + // don't hit this issue because they only observe this result after it's had a chance to + // be cached, but the error reporting code below executes before getResolvedSignature sets + // resolvedSignature. + getNodeLinks(node).resolvedSignature = result; // No signatures were applicable. Now report errors based on the last applicable signature with // no arguments excluded from assignability checks. // If candidate is undefined, it means that no candidates had a suitable arity. In that case, @@ -76838,7 +77130,7 @@ var ts; chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error); chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call); } - var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, function () { return chain_1; }); + var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, function () { return chain_1; }); if (diags) { for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) { var d = diags_1[_i]; @@ -76859,9 +77151,9 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_26 = function (c) { + var _loop_27 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { if (diags_2.length <= min_3) { min_3 = diags_2.length; @@ -76877,7 +77169,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_26(c); + _loop_27(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -76916,7 +77208,7 @@ var ts; } } } - return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + return result; function addImplementationSuccessElaboration(failed, diagnostic) { var _a, _b; var oldCandidatesForArgumentError = candidatesForArgumentError; @@ -76946,7 +77238,7 @@ var ts; if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { return undefined; } - if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { + if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { candidatesForArgumentError = [candidate]; return undefined; } @@ -76969,9 +77261,9 @@ var ts; } } else { - inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext); - argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */; + inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); + argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */; } checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a @@ -76993,10 +77285,10 @@ var ts; // If one or more context sensitive arguments were excluded, we start including // them now (and keeping do so for any subsequent candidates) and perform a second // round of type inference and applicability checking for this particular candidate. - argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */; + argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); - checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); + checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a // signature with different arity and we need to perform another arity check. if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) { @@ -77035,7 +77327,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_27 = function (i) { + var _loop_28 = function (i) { var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : i < s.parameters.length ? s.parameters[i] : undefined; }); @@ -77043,17 +77335,17 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_27(i); + _loop_28(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; if (restParameterSymbols.length !== 0) { - var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); + var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* UnionReduction.Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } if (candidates.some(signatureHasLiteralTypes)) { - flags |= 2 /* HasLiteralTypes */; + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. @@ -77066,7 +77358,7 @@ var ts; return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { - return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); + return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* UnionReduction.Subtype */)); } function createCombinedSymbolForOverloadFailure(sources, type) { // This function is currently only used for erroneous overloads, so it's good enough to just use the first source. @@ -77103,8 +77395,8 @@ var ts; return typeArguments; } function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) { - var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext); + var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* CheckMode.SkipContextSensitive */ | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); return createSignatureInstantiation(candidate, typeArgumentTypes); } function getLongestCandidateIndex(candidates, argsCount) { @@ -77124,7 +77416,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -77139,7 +77431,7 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } } return resolveUntypedCall(node); @@ -77148,13 +77440,13 @@ var ts; var funcType = checkExpression(node.expression); if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); - callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + callChainFlags = nonOptionalType === funcType ? 0 /* SignatureFlags.None */ : + ts.isOutermostOptionalChain(node) ? 16 /* SignatureFlags.IsOuterCallChain */ : + 8 /* SignatureFlags.IsInnerCallChain */; funcType = nonOptionalType; } else { - callChainFlags = 0 /* None */; + callChainFlags = 0 /* SignatureFlags.None */; } funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { @@ -77169,8 +77461,8 @@ var ts; // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; // TS 1.0 Spec: 4.12 // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. @@ -77197,7 +77489,7 @@ var ts; relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation); + invocationError(node.expression, apparentType, 0 /* SignatureKind.Call */, relatedInformation); } return resolveErrorCall(node); } @@ -77211,9 +77503,9 @@ var ts; // returns a function type, we choose to defer processing. This narrowly permits function composition // operators to flow inferences through return types, but otherwise processes calls right away. We // use the resolvingSignature singleton to indicate that we deferred processing. This result will be - // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and + // propagated out and eventually turned into silentNeverType (a type that is assignable to anything and // from which we never make inferences). - if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { skippedGenericFunction(node, checkMode); return resolvingSignature; } @@ -77234,11 +77526,11 @@ var ts; */ function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have no common signatures. - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeFlags.TypeParameter */) || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* TypeFlags.Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { - if (node.arguments && languageVersion < 1 /* ES5 */) { + if (node.arguments && languageVersion < 1 /* ScriptTarget.ES5 */) { var spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); @@ -77271,7 +77563,7 @@ var ts; // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(expressionType, 1 /* SignatureKind.Construct */); if (constructSignatures.length) { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); @@ -77280,24 +77572,24 @@ var ts; // then it cannot be instantiated. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); })) { + if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); })) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* Abstract */)) { + if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* ModifierFlags.Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. It is an error to have a Void this type. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + var callSignatures = getSignaturesOfType(expressionType, 0 /* SignatureKind.Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -77308,14 +77600,14 @@ var ts; } return signature; } - invocationError(node.expression, expressionType, 1 /* Construct */); + invocationError(node.expression, expressionType, 1 /* SignatureKind.Construct */); return resolveErrorCall(node); } function someSignature(signatures, f) { if (ts.isArray(signatures)) { return ts.some(signatures, function (signature) { return someSignature(signature, f); }); } - return signatures.compositeKind === 1048576 /* Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); + return signatures.compositeKind === 1048576 /* TypeFlags.Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); } function typeHasProtectedAccessibleBase(target, type) { var baseTypes = getBaseTypes(type); @@ -77323,7 +77615,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 2097152 /* Intersection */) { + if (firstBase.flags & 2097152 /* TypeFlags.Intersection */) { var types = firstBase.types; var mixinFlags = findMixins(types); var i = 0; @@ -77331,7 +77623,7 @@ var ts; var intersectionMember = _a[_i]; // We want to ignore mixin ctors if (!mixinFlags[i]) { - if (ts.getObjectFlags(intersectionMember) & (1 /* Class */ | 2 /* Interface */)) { + if (ts.getObjectFlags(intersectionMember) & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { if (intersectionMember.symbol === target) { return true; } @@ -77354,9 +77646,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 171 /* Constructor */) { + if (!modifiers || declaration.kind !== 171 /* SyntaxKind.Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -77364,16 +77656,16 @@ var ts; // A private or protected constructor can only be instantiated within its own class (or a subclass, for protected) if (!isNodeWithinClass(node, declaringClassDeclaration)) { var containingClass = ts.getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 16 /* ModifierFlags.Protected */) { var containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 8 /* ModifierFlags.Private */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 16 /* ModifierFlags.Protected */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -77382,10 +77674,10 @@ var ts; } function invocationErrorDetails(errorTarget, apparentType, kind) { var errorInfo; - var isCall = kind === 0 /* Call */; + var isCall = kind === 0 /* SignatureKind.Call */; var awaitedType = getAwaitedType(apparentType); var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0; - if (apparentType.flags & 1048576 /* Union */) { + if (apparentType.flags & 1048576 /* TypeFlags.Union */) { var types = apparentType.types; var hasSignatures = false; for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { @@ -77435,7 +77727,7 @@ var ts; // Diagnose get accessors incorrectly called as functions if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol; - if (resolvedSymbol && resolvedSymbol.flags & 32768 /* GetAccessor */) { + if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) { headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } @@ -77479,8 +77771,8 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -77490,26 +77782,26 @@ var ts; diagnostics.add(diagnostic); return resolveErrorCall(node); } - invocationError(node.tag, apparentType, 0 /* Call */); + invocationError(node.tag, apparentType, 0 /* SignatureKind.Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -77524,8 +77816,8 @@ var ts; if (isErrorType(apparentType)) { return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -77536,38 +77828,38 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* Call */); + var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* SignatureKind.Call */); var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage); var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage)); } diagnostics.add(diag); - invocationErrorRecovery(apparentType, 0 /* Call */, diag); + invocationErrorRecovery(apparentType, 0 /* SignatureKind.Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); - var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* SymbolFlags.Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* SymbolFlags.Type */, node); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, 0 /* None */); + /*returnTypePredicate*/ undefined, 1, 0 /* SignatureFlags.None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); var fakeSignature = createSignatureForJSXIntrinsic(node, result); - checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* CheckMode.Normal */), result, node.tagName, node.attributes); if (ts.length(node.typeArguments)) { ts.forEach(node.typeArguments, checkSourceElement); diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments))); @@ -77588,7 +77880,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -77604,16 +77896,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -77636,7 +77928,7 @@ var ts; return cached; } links.resolvedSignature = resolvingSignature; - var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */); + var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* CheckMode.Normal */); // When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call // resolution should be deferred. if (result !== resolvingSignature) { @@ -77677,7 +77969,7 @@ var ts; var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target); inferred.exports = inferred.exports || ts.createSymbolTable(); inferred.members = inferred.members || ts.createSymbolTable(); - inferred.flags |= source.flags & 32 /* Class */; + inferred.flags |= source.flags & 32 /* SymbolFlags.Class */; if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) { mergeSymbolTable(inferred.exports, source.exports); } @@ -77713,16 +78005,16 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } - else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + else if (parentNodeOperator === 56 /* SyntaxKind.BarBarToken */ || parentNodeOperator === 60 /* SyntaxKind.QuestionQuestionToken */) { if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -77745,10 +78037,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 206 /* PropertyAccessExpression */) { + while (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -77764,19 +78056,19 @@ var ts; var signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode); if (signature === resolvingSignature) { // CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that - // returns a function type. We defer checking and return nonInferrableType. - return nonInferrableType; + // returns a function type. We defer checking and return silentNeverType. + return silentNeverType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return voidType; } - if (node.kind === 209 /* NewExpression */) { + if (node.kind === 209 /* SyntaxKind.NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 171 /* Constructor */ && - declaration.kind !== 175 /* ConstructSignature */ && - declaration.kind !== 180 /* ConstructorType */ && + declaration.kind !== 171 /* SyntaxKind.Constructor */ && + declaration.kind !== 175 /* SyntaxKind.ConstructSignature */ && + declaration.kind !== 180 /* SyntaxKind.ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -77793,11 +78085,11 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* TypeFlags.ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 208 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* ExpressionStatement */ && - returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (node.kind === 208 /* SyntaxKind.CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && + returnType.flags & 16384 /* TypeFlags.Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); } @@ -77810,14 +78102,14 @@ var ts; var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - jsAssignmentType.objectFlags |= 4096 /* JSLiteral */; + jsAssignmentType.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } return returnType; } function checkDeprecatedSignature(signature, node) { - if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) { + if (signature.declaration && signature.declaration.flags & 268435456 /* NodeFlags.Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); @@ -77826,20 +78118,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 208 /* CallExpression */: - case 165 /* Decorator */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 165 /* SyntaxKind.Decorator */: + case 209 /* SyntaxKind.NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.argumentExpression; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -77861,7 +78153,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -77876,13 +78168,13 @@ var ts; for (var i = 2; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* TypeFlags.Undefined */ || specifierType.flags & 65536 /* TypeFlags.Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } if (optionsType) { var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true); if (importCallOptionsType !== emptyObjectType) { - checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]); + checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* TypeFlags.Undefined */), node.arguments[1]); } } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -77898,11 +78190,11 @@ var ts; } function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) { var memberTable = ts.createSymbolTable(); - var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + var newSymbol = createSymbol(2097152 /* SymbolFlags.Alias */, "default" /* InternalSymbolName.Default */); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); newSymbol.aliasTarget = resolveSymbol(symbol); - memberTable.set("default" /* Default */, newSymbol); + memberTable.set("default" /* InternalSymbolName.Default */, newSymbol); return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); } function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) { @@ -77925,7 +78217,7 @@ var ts; var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier); if (hasSyntheticDefault) { - var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var anonymousSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; @@ -77945,40 +78237,40 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } // project includes symbol named 'require' - make sure that it is ambient and local non-alias - if (resolvedRequire.flags & 2097152 /* Alias */) { + if (resolvedRequire.flags & 2097152 /* SymbolFlags.Alias */) { return false; } - var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 256 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 254 /* VariableDeclaration */ - : 0 /* Unknown */; - if (targetDeclarationKind !== 0 /* Unknown */) { + var targetDeclarationKind = resolvedRequire.flags & 16 /* SymbolFlags.Function */ + ? 256 /* SyntaxKind.FunctionDeclaration */ + : resolvedRequire.flags & 3 /* SymbolFlags.Variable */ + ? 254 /* SyntaxKind.VariableDeclaration */ + : 0 /* SyntaxKind.Unknown */; + if (targetDeclarationKind !== 0 /* SyntaxKind.Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 16777216 /* Ambient */); + return !!decl && !!(decl.flags & 16777216 /* NodeFlags.Ambient */); } return false; } function checkTaggedTemplateExpression(node) { if (!checkGrammarTaggedTemplateChain(node)) checkGrammarTypeArguments(node, node.typeArguments); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 262144 /* ExternalEmitHelpers.MakeTemplateObject */); } var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); return getReturnTypeOfSignature(signature); } function checkAssertion(node) { - if (node.kind === 211 /* TypeAssertionExpression */) { + if (node.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { var file = ts.getSourceFileOfNode(node); - if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */])) { grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } @@ -77986,31 +78278,31 @@ var ts; } function isValidConstAssertionArgument(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 223 /* TemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) || + op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node.expression; var symbol = getTypeOfNode(expr).symbol; - if (symbol && symbol.flags & 2097152 /* Alias */) { + if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = resolveAlias(symbol); } - return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); + return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */); } return false; } @@ -78041,12 +78333,12 @@ var ts; return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType); } function checkNonNullAssertion(node) { - return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkNonNullChain(node) : getNonNullableType(checkExpression(node.expression)); } function checkExpressionWithTypeArguments(node) { checkGrammarExpressionWithTypeArguments(node); - var exprType = node.kind === 228 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : + var exprType = node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? checkExpression(node.expression) : ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName); var typeArguments = node.typeArguments; @@ -78071,7 +78363,7 @@ var ts; } return result; function getInstantiatedTypePart(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var callSignatures = getInstantiatedSignatures(resolved.callSignatures); var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures); @@ -78079,12 +78371,12 @@ var ts; hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0); if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) { var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos); - result_11.objectFlags |= 8388608 /* InstantiationExpressionType */; + result_11.objectFlags |= 8388608 /* ObjectFlags.InstantiationExpressionType */; result_11.node = node; return result_11; } } - else if (type.flags & 58982400 /* InstantiableNonPrimitive */) { + else if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { var constraint = getBaseConstraintOfType(type); if (constraint) { var instantiated = getInstantiatedTypePart(constraint); @@ -78093,10 +78385,10 @@ var ts; } } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getInstantiatedType); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart)); } return type; @@ -78112,19 +78404,19 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 103 /* NewKeyword */) { + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 100 /* ImportKeyword */) { + if (node.keywordToken === 100 /* SyntaxKind.ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); } function checkMetaPropertyKeyword(node) { switch (node.keywordToken) { - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return getGlobalImportMetaExpressionType(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: var type = checkNewTargetMetaProperty(node); return isErrorType(type) ? errorType : createNewTargetExpressionType(type); default: @@ -78137,7 +78429,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -78156,7 +78448,7 @@ var ts; error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { @@ -78189,7 +78481,7 @@ var ts; } function getParameterIdentifierNameAtPosition(signature, pos) { var _a; - if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* JSDocFunctionType */) { + if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* SyntaxKind.JSDocFunctionType */) { return undefined; } var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -78221,7 +78513,7 @@ var ts; return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); } function isValidDeclarationForTupleLabel(d) { - return d.kind === 197 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 197 /* SyntaxKind.NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -78271,11 +78563,11 @@ var ts; for (var i = pos; i < parameterCount; i++) { if (!restType || i < parameterCount - 1) { types.push(getTypeAtPosition(source, i)); - flags.push(i < minArgumentCount ? 1 /* Required */ : 2 /* Optional */); + flags.push(i < minArgumentCount ? 1 /* ElementFlags.Required */ : 2 /* ElementFlags.Optional */); } else { types.push(restType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } var name = getNameableDeclarationAtPosition(source, i); if (name) { @@ -78299,14 +78591,14 @@ var ts; return length; } function getMinArgumentCount(signature, flags) { - var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */; - var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */; + var strongArityForUntypedJS = flags & 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */; + var voidIsNonOptional = flags & 2 /* MinArgumentCountFlags.VoidIsNonOptional */; if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) { var minArgumentCount = void 0; if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { - var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); + var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* ElementFlags.Required */); }); var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; if (requiredCount > 0) { minArgumentCount = signature.parameters.length - 1 + requiredCount; @@ -78314,7 +78606,7 @@ var ts; } } if (minArgumentCount === undefined) { - if (!strongArityForUntypedJS && signature.flags & 32 /* IsUntypedSignatureInJSFile */) { + if (!strongArityForUntypedJS && signature.flags & 32 /* SignatureFlags.IsUntypedSignatureInJSFile */) { return 0; } minArgumentCount = signature.minArgumentCount; @@ -78324,7 +78616,7 @@ var ts; } for (var i = minArgumentCount - 1; i >= 0; i--) { var type = getTypeAtPosition(signature, i); - if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, acceptsVoid).flags & 131072 /* TypeFlags.Never */) { break; } minArgumentCount = i; @@ -78354,7 +78646,7 @@ var ts; } function getNonArrayRestType(signature) { var restType = getEffectiveRestType(signature); - return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined; + return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* TypeFlags.Never */) === 0 ? restType : undefined; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -78373,17 +78665,6 @@ var ts; } } } - var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144 /* TypeParameter */) { - // The contextual signature has a generic rest parameter. We first instantiate the contextual - // signature (without fixing type parameters) and assign types to contextually typed parameters. - var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); - assignContextualParameterTypes(signature, instantiatedContext); - // We then infer from a tuple type representing the parameters that correspond to the contextual - // rest parameter. - var restPos = getParameterCount(context) - 1; - inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType); - } } function assignContextualParameterTypes(signature, context) { if (context.typeParameters) { @@ -78418,7 +78699,7 @@ var ts; ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration) // a declarationless parameter may still have a `.type` already set by its construction logic // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type - : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) { + : !!(ts.getCheckFlags(parameter) & 65536 /* CheckFlags.DeferredType */)) { var contextualParameterType = getRestTypeAtPosition(context, len); assignParameterType(parameter, contextualParameterType); } @@ -78438,7 +78719,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter)); - if (declaration && declaration.name.kind !== 79 /* Identifier */) { + if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); @@ -78457,7 +78738,7 @@ var ts; var element = _a[_i]; if (!ts.isOmittedExpression(element)) { var type = getBindingElementTypeFromParentType(element, parentType); - if (element.name.kind === 79 /* Identifier */) { + if (element.name.kind === 79 /* SyntaxKind.Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = type; } else { @@ -78505,8 +78786,8 @@ var ts; } function createNewTargetExpressionType(targetType) { // Create a synthetic type `NewTargetExpression { target: TargetType; }` - var symbol = createSymbol(0 /* None */, "NewTargetExpression"); - var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */); + var symbol = createSymbol(0 /* SymbolFlags.None */, "NewTargetExpression"); + var targetPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "target", 8 /* CheckFlags.Readonly */); targetPropertySymbol.parent = symbol; targetPropertySymbol.type = targetType; var members = ts.createSymbolTable([targetPropertySymbol]); @@ -78518,14 +78799,14 @@ var ts; return errorType; } var functionFlags = ts.getFunctionFlags(func); - var isAsync = (functionFlags & 2 /* Async */) !== 0; - var isGenerator = (functionFlags & 1 /* Generator */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + var isGenerator = (functionFlags & 1 /* FunctionFlags.Generator */) !== 0; var returnType; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 235 /* Block */) { // Async or normal arrow function - returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); + if (func.body.kind !== 235 /* SyntaxKind.Block */) { // Async or normal arrow function + returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -78540,47 +78821,47 @@ var ts; fallbackReturnType = neverType; } else if (returnTypes.length > 0) { - returnType = getUnionType(returnTypes, 2 /* Subtype */); + returnType = getUnionType(returnTypes, 2 /* UnionReduction.Subtype */); } var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes; - yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* Subtype */) : undefined; + yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* UnionReduction.Subtype */) : undefined; nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined; } else { // Async or normal function var types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, voidType) // Async function : voidType; // Normal function } // Return a union of the return expression types. - returnType = getUnionType(types, 2 /* Subtype */); + returnType = getUnionType(types, 2 /* UnionReduction.Subtype */); } if (returnType || yieldType || nextType) { if (yieldType) - reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */); + reportErrorsFromWidening(func, yieldType, 3 /* WideningKind.GeneratorYield */); if (returnType) - reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */); + reportErrorsFromWidening(func, returnType, 1 /* WideningKind.FunctionReturn */); if (nextType) - reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */); + reportErrorsFromWidening(func, nextType, 2 /* WideningKind.GeneratorNext */); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); var contextualType = !contextualSignature ? undefined : contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : - instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); + instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined); if (isGenerator) { - yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync); - returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync); - nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* Next */, isAsync); + yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* IterationTypeKind.Yield */, isAsync); + returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* IterationTypeKind.Return */, isAsync); + nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* IterationTypeKind.Next */, isAsync); } else { returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync); @@ -78594,7 +78875,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* IterationTypeKind.Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -78637,17 +78918,17 @@ var ts; function checkAndAggregateYieldOperandTypes(func, checkMode) { var yieldTypes = []; var nextTypes = []; - var isAsync = (ts.getFunctionFlags(func) & 2 /* Async */) !== 0; + var isAsync = (ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) !== 0; ts.forEachYieldExpression(func.body, function (yieldExpression) { var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType; ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync)); var nextType; if (yieldExpression.asteriskToken) { - var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, yieldExpression.expression); + var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, yieldExpression.expression); nextType = iterationTypes && iterationTypes.nextType; } else { - nextType = getContextualType(yieldExpression); + nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined); } if (nextType) ts.pushIfUnique(nextTypes, nextType); @@ -78657,17 +78938,17 @@ var ts; function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) { var errorNode = node.expression || node; // A `yield*` expression effectively yields everything that its operand yields - var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, expressionType, sentType, errorNode) : expressionType; + var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, expressionType, sentType, errorNode) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } // Return the combined not-equal type facts for all cases except those between the start and end indices. function getNotEqualFactsFromTypeofSwitch(start, end, witnesses) { - var facts = 0 /* None */; + var facts = 0 /* TypeFacts.None */; for (var i = 0; i < witnesses.length; i++) { var witness = i < start || i >= end ? witnesses[i] : undefined; - facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeofNEHostObject */ : 0; + facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeFacts.TypeofNEHostObject */ : 0; } return facts; } @@ -78676,7 +78957,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 216 /* TypeOfExpression */) { + if (node.expression.kind === 216 /* SyntaxKind.TypeOfExpression */) { var witnesses = getSwitchClauseTypeOfWitnesses(node); if (!witnesses) { return false; @@ -78684,9 +78965,9 @@ var ts; var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression)); // Get the not-equal flags for all handled cases. var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses); - if (operandConstraint.flags & 3 /* AnyOrUnknown */) { + if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) { // We special case the top types to be exhaustive when all cases are handled. - return (556800 /* AllTypeofNE */ & notEqualFacts_2) === 556800 /* AllTypeofNE */; + return (556800 /* TypeFacts.AllTypeofNE */ & notEqualFacts_2) === 556800 /* TypeFacts.AllTypeofNE */; } // A missing not-equal flag indicates that the type wasn't handled by some case. return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; }); @@ -78713,15 +78994,15 @@ var ts; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */); - if (functionFlags & 2 /* Async */) { + var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); + if (functionFlags & 2 /* FunctionFlags.Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -78742,11 +79023,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 169 /* MethodDeclaration */: - return func.parent.kind === 205 /* ObjectLiteralExpression */; + case 169 /* SyntaxKind.MethodDeclaration */: + return func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; default: return false; } @@ -78767,17 +79048,17 @@ var ts; var functionFlags = ts.getFunctionFlags(func); var type = returnType && unwrapReturnType(returnType, functionFlags); // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) { + if (type && maybeTypeOfKind(type, 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 168 /* SyntaxKind.MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* SyntaxKind.Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* NodeFlags.HasExplicitReturn */; var errorNode = ts.getEffectiveReturnTypeNode(func) || func; - if (type && type.flags & 131072 /* Never */) { + if (type && type.flags & 131072 /* TypeFlags.Never */) { error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { @@ -78806,13 +79087,13 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (ts.isFunctionExpression(node)) { checkCollisionsForDeclarationName(node, node.name); } // The identityMapper object is used to indicate that function expressions are wildcards - if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { + if (checkMode && checkMode & 4 /* CheckMode.SkipContextSensitive */ && isContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type @@ -78823,9 +79104,9 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray); - returnOnlyType.objectFlags |= 262144 /* NonInferrableType */; + returnOnlyType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -78833,7 +79114,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 213 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 213 /* SyntaxKind.FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -78842,25 +79123,30 @@ var ts; function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) { var links = getNodeLinks(node); // Check if function expression is contextually typed and assign parameter types if so. - if (!(links.flags & 1024 /* ContextChecked */)) { + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { - links.flags |= 1024 /* ContextChecked */; - var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* Call */)); + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { + links.flags |= 1024 /* NodeCheckFlags.ContextChecked */; + var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* SignatureKind.Call */)); if (!signature) { return; } if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); - if (checkMode && checkMode & 2 /* Inferential */) { + var instantiatedContextualSignature = void 0; + if (checkMode && checkMode & 2 /* CheckMode.Inferential */) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); + var restType = getEffectiveRestType(contextualSignature); + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { + instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper); + } } - var instantiatedContextualSignature = inferenceContext ? - instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature; + instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ? + instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature); assignContextualParameterTypes(signature, instantiatedContextualSignature); } else { @@ -78879,7 +79165,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -78892,7 +79178,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 235 /* Block */) { + if (node.body.kind === 235 /* SyntaxKind.Block */) { checkSourceElement(node.body); } else { @@ -78904,7 +79190,7 @@ var ts; var exprType = checkExpression(node.body); var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { // Async function var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } @@ -78962,27 +79248,27 @@ var ts; // Enum members // Object.defineProperty assignments with writable false or no setter // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(ts.getCheckFlags(symbol) & 8 /* Readonly */ || - symbol.flags & 4 /* Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || - symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || - symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - symbol.flags & 8 /* EnumMember */ || + return !!(ts.getCheckFlags(symbol) & 8 /* CheckFlags.Readonly */ || + symbol.flags & 4 /* SymbolFlags.Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* ModifierFlags.Readonly */ || + symbol.flags & 3 /* SymbolFlags.Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */ || + symbol.flags & 98304 /* SymbolFlags.Accessor */ && !(symbol.flags & 65536 /* SymbolFlags.SetAccessor */) || + symbol.flags & 8 /* SymbolFlags.EnumMember */ || ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; - if (assignmentKind === 0 /* None */) { + if (assignmentKind === 0 /* AssignmentKind.None */) { // no assigment means it doesn't matter whether the entity is readonly return false; } if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. - if (symbol.flags & 4 /* Property */ && + if (symbol.flags & 4 /* SymbolFlags.Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 108 /* ThisKeyword */) { + expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 171 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -79003,11 +79289,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; - if (symbol_2.flags & 2097152 /* Alias */) { + if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 268 /* NamespaceImport */; + return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */; } } } @@ -79015,12 +79301,12 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { + var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */); + if (node.kind !== 79 /* SyntaxKind.Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { error(expr, invalidOptionalChainMessage); return false; } @@ -79049,8 +79335,8 @@ var ts; function checkDeleteExpressionMustBeOptional(expr, symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks && - !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && - !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) { + !(type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) && + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* SymbolFlags.Optional */ : getTypeFacts(type) & 16777216 /* TypeFacts.IsUndefined */)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -79068,7 +79354,7 @@ var ts; if (container && ts.isClassStaticBlockDeclaration(container)) { error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); } - else if (!(node.flags & 32768 /* AwaitContext */)) { + else if (!(node.flags & 32768 /* NodeFlags.AwaitContext */)) { if (ts.isInTopLevelContext(node)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -79090,7 +79376,7 @@ var ts; case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: case ts.ModuleKind.System: - if (languageVersion >= 4 /* ES2017 */) { + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { break; } // fallthrough @@ -79107,7 +79393,7 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); - if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + if (container && container.kind !== 171 /* SyntaxKind.Constructor */ && (ts.getFunctionFlags(container) & 2 /* FunctionFlags.Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -79123,7 +79409,7 @@ var ts; addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); }); var operandType = checkExpression(node.expression); var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) { + if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* TypeFlags.AnyOrUnknown */)) { addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); } return awaitedType; @@ -79134,16 +79420,16 @@ var ts; return silentNeverType; } switch (node.operand.kind) { - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: switch (node.operator) { - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text)); - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text)); } break; - case 9 /* BigIntLiteral */: - if (node.operator === 40 /* MinusToken */) { + case 9 /* SyntaxKind.BigIntLiteral */: + if (node.operator === 40 /* SyntaxKind.MinusToken */) { return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -79151,28 +79437,28 @@ var ts; } } switch (node.operator) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* TypeFlags.ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 39 /* PlusToken */) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + if (node.operator === 39 /* SyntaxKind.PlusToken */) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* TypeFlags.BigIntLike */)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); - return facts === 4194304 /* Truthy */ ? falseType : - facts === 8388608 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* TypeFacts.Truthy */ | 8388608 /* TypeFacts.Falsy */); + return facts === 4194304 /* TypeFacts.Truthy */ ? falseType : + facts === 8388608 /* TypeFacts.Falsy */ ? trueType : booleanType; - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -79195,8 +79481,8 @@ var ts; return getUnaryResultType(operandType); } function getUnaryResultType(operandType) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* TypeFlags.AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* TypeFlags.NumberLike */) ? numberOrBigIntType : bigintType; } @@ -79216,7 +79502,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { var t = types_20[_i]; @@ -79231,30 +79517,30 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { + if (strict && source.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */)) { return false; } - return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || - !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* TypeFlags.NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 402653316 /* TypeFlags.StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 528 /* TypeFlags.BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 16384 /* TypeFlags.Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 65536 /* TypeFlags.Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 32768 /* TypeFlags.Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 4096 /* TypeFlags.ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 67108864 /* TypeFlags.NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 1048576 /* Union */ ? + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; + return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { if (leftType === silentNeverType || rightType === silentNeverType) { @@ -79266,7 +79552,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 131068 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -79280,8 +79566,8 @@ var ts; return silentNeverType; } if (ts.isPrivateIdentifier(left)) { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(left, 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */); } // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors @@ -79294,8 +79580,8 @@ var ts; leftType = checkNonNullType(leftType, left); // TypeScript 1.0 spec (April 2014): 4.15.5 // Require the left operand to be of type Any, the String primitive type, or the Number primitive type. - if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { + if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol); } } @@ -79320,9 +79606,9 @@ var ts; // // The result is always of the Boolean primitive type. var rightTypeConstraint = getConstraintOfType(rightType); - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - !maybeTypeOfKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */))) { + if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; @@ -79342,7 +79628,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 296 /* PropertyAssignment */ || property.kind === 297 /* ShorthandPropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */ || property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -79353,17 +79639,17 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* AccessFlags.ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 297 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 298 /* SpreadAssignment */) { + else if (property.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(property, 4 /* Rest */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(property, 4 /* ExternalEmitHelpers.Rest */); } var nonRestNames = []; if (allProperties) { @@ -79385,18 +79671,18 @@ var ts; } function checkArrayLiteralAssignment(node, sourceType, checkMode) { var elements = node.elements; - if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; + var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | 128 /* IterationUse.PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 225 /* SpreadElement */) { - type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); + if (node.elements[i].kind === 225 /* SyntaxKind.SpreadElement */) { + type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); } @@ -79405,15 +79691,15 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 227 /* OmittedExpression */) { - if (element.kind !== 225 /* SpreadElement */) { + if (element.kind !== 227 /* SyntaxKind.OmittedExpression */) { + if (element.kind !== 225 /* SyntaxKind.SpreadElement */) { var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; - var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; + var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* TypeFacts.NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); } @@ -79424,7 +79710,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 221 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { + if (restExpression.kind === 221 /* SyntaxKind.BinaryExpression */ && restExpression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -79440,14 +79726,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 297 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* IsUndefined */)) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* TypeFacts.IsUndefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -79456,35 +79742,35 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { + if (target.kind === 221 /* SyntaxKind.BinaryExpression */ && target.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; // A default value is specified, so remove undefined from the final type. if (strictNullChecks) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } } - if (target.kind === 205 /* ObjectLiteralExpression */) { + if (target.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 204 /* ArrayLiteralExpression */) { + if (target.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 298 /* SpreadAssignment */ ? + var error = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 298 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { - checkExternalEmitHelpers(target.parent, 1048576 /* ClassPrivateFieldSet */); + checkExternalEmitHelpers(target.parent, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } return sourceType; } @@ -79499,59 +79785,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 210 /* TaggedTemplateExpression */: - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 153 /* UndefinedKeyword */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 216 /* TypeOfExpression */: - case 230 /* NonNullExpression */: - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: return true; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 53 /* ExclamationToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: return true; } return false; // Some forms listed here for clarity - case 217 /* VoidExpression */: // Explicit opt-out - case 211 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 229 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 217 /* SyntaxKind.VoidExpression */: // Explicit opt-out + case 211 /* SyntaxKind.TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 229 /* SyntaxKind.AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* TypeFlags.Nullable */) !== 0 || isTypeComparableTo(source, target); } function createCheckBinaryExpression() { var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); @@ -79582,9 +79868,9 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (node.left.kind === 205 /* ObjectLiteralExpression */ || node.left.kind === 204 /* ArrayLiteralExpression */)) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && (node.left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { state.skip = true; - setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* SyntaxKind.ThisKeyword */)); return state; } return state; @@ -79601,9 +79887,13 @@ var ts; setLeftType(state, leftType); setLastResult(state, /*type*/ undefined); var operator = operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */) { + var parent = node.parent; + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ + || ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */)) { + parent = parent.parent; + } checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } checkTruthinessOfType(leftType, node.left); @@ -79662,11 +79952,11 @@ var ts; } function checkGrammarNullishCoalesceWithLogicalExpression(node) { var left = node.left, operatorToken = node.operatorToken, right = node.right; - if (operatorToken.kind === 60 /* QuestionQuestionToken */) { - if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || left.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } - if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || right.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } } @@ -79675,11 +79965,11 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (left.kind === 205 /* ObjectLiteralExpression */ || left.kind === 204 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); + if (operator === 63 /* SyntaxKind.EqualsToken */ && (left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* SyntaxKind.ThisKeyword */); } var leftType; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -79691,28 +79981,28 @@ var ts; function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) { var operator = operatorToken.kind; switch (operator) { - case 41 /* AsteriskToken */: - case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 44 /* PercentToken */: - case 69 /* PercentEqualsToken */: - case 40 /* MinusToken */: - case 65 /* MinusEqualsToken */: - case 47 /* LessThanLessThanToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 44 /* SyntaxKind.PercentToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 40 /* SyntaxKind.MinusToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -79721,8 +80011,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 528 /* BooleanLike */) && - (rightType.flags & 528 /* BooleanLike */) && + if ((leftType.flags & 528 /* TypeFlags.BooleanLike */) && + (rightType.flags & 528 /* TypeFlags.BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); return numberType; @@ -79733,21 +80023,21 @@ var ts; var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, /*isAwaitValid*/ true); var resultType_1; // If both are any or unknown, allow operation; assume it will resolve to number - if ((isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */)) || + if ((isTypeAssignableToKind(leftType, 3 /* TypeFlags.AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* TypeFlags.AnyOrUnknown */)) || // Or, if neither could be bigint, implicit coercion results in a number result - !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + !(maybeTypeOfKind(leftType, 2112 /* TypeFlags.BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* TypeFlags.BigIntLike */))) { resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; - case 42 /* AsteriskAsteriskToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - if (languageVersion < 3 /* ES2016 */) { + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } } @@ -79763,26 +80053,26 @@ var ts; } return resultType_1; } - case 39 /* PlusToken */: - case 64 /* PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* TypeFlags.NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* TypeFlags.NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true)) { // If both operands are of the BigInt primitive type, the result is of the BigInt primitive type. resultType = bigintType; } - else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -79800,21 +80090,21 @@ var ts; // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. - var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */; + var closeEnoughKind_1 = 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 3 /* TypeFlags.AnyOrUnknown */; reportOperatorError(function (left, right) { return isTypeAssignableToKind(left, closeEnoughKind_1) && isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 64 /* PlusEqualsToken */) { + if (operator === 64 /* SyntaxKind.PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -79823,60 +80113,60 @@ var ts; }); } return booleanType; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: if (ts.isLiteralExpressionOfObject(left) || ts.isLiteralExpressionOfObject(right)) { - var eqType = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; + var eqType = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true"); } reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 55 /* AmpersandAmpersandToken */: - case 76 /* AmpersandAmpersandEqualsToken */: { - var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: { + var resultType_2 = getTypeFacts(leftType) & 4194304 /* TypeFacts.Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 76 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } - case 56 /* BarBarToken */: - case 75 /* BarBarEqualsToken */: { - var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? - getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : + case 56 /* SyntaxKind.BarBarToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: { + var resultType_3 = getTypeFacts(leftType) & 8388608 /* TypeFacts.Falsy */ ? + getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 75 /* BarBarEqualsToken */) { + if (operator === 75 /* SyntaxKind.BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } - case 60 /* QuestionQuestionToken */: - case 77 /* QuestionQuestionEqualsToken */: { - var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? - getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: { + var resultType_4 = getTypeFacts(leftType) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 77 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* SyntaxKind.QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 63 /* EqualsToken */: - var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; + case 63 /* SyntaxKind.EqualsToken */: + var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* AssignmentDeclarationKind.None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { - if (!(rightType.flags & 524288 /* Object */) || - declKind !== 2 /* ModuleExports */ && - declKind !== 6 /* Prototype */ && + if (!(rightType.flags & 524288 /* TypeFlags.Object */) || + declKind !== 2 /* AssignmentDeclarationKind.ModuleExports */ && + declKind !== 6 /* AssignmentDeclarationKind.Prototype */ && !isEmptyObjectType(rightType) && !isFunctionObjectType(rightType) && - !(ts.getObjectFlags(rightType) & 1 /* Class */)) { + !(ts.getObjectFlags(rightType) & 1 /* ObjectFlags.Class */)) { // don't check assignability of module.exports=, C.prototype=, or expando types because they will necessarily be incomplete checkAssignmentOperator(rightType); } @@ -79886,7 +80176,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { var sf = ts.getSourceFileOfNode(left); var sourceText = sf.text; @@ -79904,16 +80194,16 @@ var ts; return ts.Debug.fail(); } function bothAreBigIntLike(left, right) { - return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + return isTypeAssignableToKind(left, 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableToKind(right, 2112 /* TypeFlags.BigIntLike */); } function checkAssignmentDeclaration(kind, rightType) { - if (kind === 2 /* ModuleExports */) { + if (kind === 2 /* AssignmentDeclarationKind.ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { var prop = _a[_i]; var propType = getTypeOfSymbol(prop); - if (propType.symbol && propType.symbol.flags & 32 /* Class */) { + if (propType.symbol && propType.symbol.flags & 32 /* SymbolFlags.Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* SymbolFlags.Type */, undefined, name, /*isUse*/ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) { addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); @@ -79923,12 +80213,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : - maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* TypeFlags.ESSymbolLike */) ? left : + maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* TypeFlags.ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -79938,15 +80228,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - return 56 /* BarBarToken */; - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - return 37 /* ExclamationEqualsEqualsToken */; - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: - return 55 /* AmpersandAmpersandToken */; + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + return 56 /* SyntaxKind.BarBarToken */; + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + return 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + return 55 /* SyntaxKind.AmpersandAmpersandToken */; default: return undefined; } @@ -79965,7 +80255,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { var headMessage = void 0; - if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) { + if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* TypeFlags.Undefined */)) { var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText); if (isExactOptionalPropertyMismatch(valueType, target)) { headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target; @@ -79979,13 +80269,13 @@ var ts; function isAssignmentDeclaration(kind) { var _a; switch (kind) { - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: return true; - case 1 /* ExportsProperty */: - case 5 /* Property */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: - case 4 /* ThisProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var symbol = getSymbolOfNode(left); var init = ts.getAssignedExpandoInitializer(right); return !!init && ts.isObjectLiteralExpression(init) && @@ -80028,12 +80318,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: typeName = "false"; break; - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -80059,20 +80349,20 @@ var ts; if (!func) return anyType; var functionFlags = ts.getFunctionFlags(func); - if (!(functionFlags & 1 /* Generator */)) { + if (!(functionFlags & 1 /* FunctionFlags.Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; } - var isAsync = (functionFlags & 2 /* Async */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; if (node.asteriskToken) { // Async generator functions prior to ESNext require the __await, __asyncDelegator, // and __asyncValues helpers - if (isAsync && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */); + if (isAsync && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 26624 /* ExternalEmitHelpers.AsyncDelegatorIncludes */); } // Generator functions prior to ES2015 require the __values helper - if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 256 /* Values */); + if (!isAsync && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.Values */); } } // There is no point in doing an assignability check if the function @@ -80089,20 +80379,20 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression); } if (node.asteriskToken) { - var use = isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */; - return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression) + var use = isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */; + return getIterationTypeOfIterable(use, 1 /* IterationTypeKind.Return */, yieldExpressionType, node.expression) || anyType; } else if (returnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) + return getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, isAsync) || anyType; } - var type = getContextualIterationType(2 /* Next */, func); + var type = getContextualIterationType(2 /* IterationTypeKind.Next */, func); if (!type) { type = anyType; addLazyDiagnostic(function () { if (noImplicitAny && !ts.expressionResultIsUnused(node)) { - var contextualType = getContextualType(node); + var contextualType = getContextualType(node, /*contextFlags*/ undefined); if (!contextualType || isTypeAny(contextualType)) { error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation); } @@ -80111,7 +80401,7 @@ var ts; } return type; function checkYieldExpressionGrammar() { - if (!(node.flags & 8192 /* YieldContext */)) { + if (!(node.flags & 8192 /* NodeFlags.YieldContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -80124,7 +80414,7 @@ var ts; checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); - return getUnionType([type1, type2], 2 /* Subtype */); + return getUnionType([type1, type2], 2 /* UnionReduction.Subtype */); } function isTemplateLiteralContext(node) { var parent = node.parent; @@ -80137,20 +80427,20 @@ var ts; for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { var span = _a[_i]; var type = checkExpression(span.expression); - if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) { error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; + return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { - return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || - type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); + return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) || + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */)); } function getContextNode(node) { - if (node.kind === 286 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 286 /* SyntaxKind.JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -80162,7 +80452,7 @@ var ts; try { context.contextualType = contextualType; context.inferenceContext = inferenceContext; - var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0)); + var type = checkExpression(node, checkMode | 1 /* CheckMode.Contextual */ | (inferenceContext ? 2 /* CheckMode.Inferential */ : 0)); // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type // parameters. This information is no longer needed after the call to checkExpression. if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { @@ -80171,7 +80461,7 @@ var ts; // We strip literal freshness when an appropriate contextual type is present such that contextually typed // literals always preserve their literal types (otherwise they might widen during type inference). An alternative // here would be to not mark contextually typed literals as fresh in the first place. - var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* TypeFlags.Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -80184,7 +80474,7 @@ var ts; } } function checkExpressionCached(node, checkMode) { - if (checkMode && checkMode !== 0 /* Normal */) { + if (checkMode && checkMode !== 0 /* CheckMode.Normal */) { return checkExpression(node, checkMode); } var links = getNodeLinks(node); @@ -80204,17 +80494,17 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 211 /* TypeAssertionExpression */ || - node.kind === 229 /* AsExpression */ || + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */ || + node.kind === 229 /* SyntaxKind.AsExpression */ || ts.isJSDocTypeAssertion(node); } function checkDeclarationInitializer(declaration, checkMode, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? - checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */) + checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* CheckMode.Normal */) : checkExpressionCached(initializer, checkMode)); - return ts.isParameter(declaration) && declaration.name.kind === 202 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -80224,9 +80514,9 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 203 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 203 /* SyntaxKind.BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); } @@ -80235,7 +80525,7 @@ var ts; return createTupleType(elementTypes, elementFlags, type.target.readonly); } function widenTypeInferredFromInitializer(declaration, type) { - var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); + var widened = ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); @@ -80250,28 +80540,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 3145728 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || unknownType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* TypeFlags.String */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* TypeFlags.Number */) && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + maybeTypeOfKind(constraint, 64 /* TypeFlags.BigInt */) && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + maybeTypeOfKind(constraint, 4096 /* TypeFlags.ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || - contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* TypeFlags.StringLiteral */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + contextualType.flags & 256 /* TypeFlags.NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + contextualType.flags & 2048 /* TypeFlags.BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + contextualType.flags & 512 /* TypeFlags.BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* TypeFlags.BooleanLiteral */) || + contextualType.flags & 8192 /* TypeFlags.UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */)); } return false; } @@ -80286,13 +80576,13 @@ var ts; var type = checkExpression(node, checkMode, forceTuple); return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) : isTypeAssertion(node) ? type : - getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node)); + getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined)); } function checkPropertyAssignment(node, checkMode) { // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -80303,23 +80593,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { - if (checkMode && checkMode & (2 /* Inferential */ | 8 /* SkipGenericFunctions */)) { - var callSignature = getSingleSignature(type, 0 /* Call */, /*allowMembers*/ true); - var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); + if (checkMode && checkMode & (2 /* CheckMode.Inferential */ | 8 /* CheckMode.SkipGenericFunctions */)) { + var callSignature = getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ true); + var constructSignature = getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + var contextualType = getApparentTypeOfContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { - var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); + var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { - if (checkMode & 8 /* SkipGenericFunctions */) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */) { skippedGenericFunction(node, checkMode); return anyFunctionType; } @@ -80367,11 +80657,11 @@ var ts; return type; } function skippedGenericFunction(node, checkMode) { - if (checkMode & 2 /* Inferential */) { + if (checkMode & 2 /* CheckMode.Inferential */) { // We have skipped a generic function during inferential typing. Obtain the inference context and // indicate this has occurred such that we know a second pass of inference is be needed. var context = getInferenceContext(node); - context.flags |= 4 /* SkippedGenericFunction */; + context.flags |= 4 /* InferenceFlags.SkippedGenericFunction */; } } function hasInferenceCandidates(info) { @@ -80396,12 +80686,12 @@ var ts; var result = []; var oldTypeParameters; var newTypeParameters; - for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { - var tp = typeParameters_2[_i]; + for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { + var tp = typeParameters_3[_i]; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); - var symbol = createSymbol(262144 /* TypeParameter */, newName); + var symbol = createSymbol(262144 /* SymbolFlags.TypeParameter */, newName); var newTypeParameter = createTypeParameter(symbol); newTypeParameter.target = tp; oldTypeParameters = ts.append(oldTypeParameters, tp); @@ -80426,7 +80716,7 @@ var ts; } function getUniqueTypeParameterName(typeParameters, baseName) { var len = baseName.length; - while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* _0 */ && baseName.charCodeAt(len - 1) <= 57 /* _9 */) + while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* CharacterCodes._0 */ && baseName.charCodeAt(len - 1) <= 57 /* CharacterCodes._9 */) len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { @@ -80459,7 +80749,7 @@ var ts; return quickType; } // If a type has been cached for the node, return it. - if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) { + if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) { var cachedType = flowTypeCache[getNodeId(node)]; if (cachedType) { return cachedType; @@ -80471,7 +80761,7 @@ var ts; if (flowInvocationCount !== startInvocationCount) { var cache = flowTypeCache || (flowTypeCache = []); cache[getNodeId(node)] = type; - ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */); + ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */); } return type; } @@ -80486,7 +80776,7 @@ var ts; expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -80496,8 +80786,8 @@ var ts; else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { return getTypeFromTypeNode(expr.type); } - else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { + else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ || + node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) { return checkExpression(node); } return undefined; @@ -80517,7 +80807,7 @@ var ts; var saveContextualType = node.contextualType; node.contextualType = anyType; try { - var type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */); + var type = links.contextFreeType = checkExpression(node, 4 /* CheckMode.SkipContextSensitive */); return type; } finally { @@ -80528,7 +80818,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -80546,18 +80836,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 207 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 181 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 275 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { - ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 16777216 /* Ambient */) { + if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -80575,113 +80865,113 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return checkIdentifier(node, checkMode); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifierExpression(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return checkThisExpression(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return nullWideningType; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getFreshTypeOfLiteralType(getStringLiteralType(node.text)); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text)); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: false, base10Value: ts.parsePseudoBigInt(node.text) })); - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: return trueType; - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return falseType; - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return checkTemplateExpression(node); - case 13 /* RegularExpressionLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: return globalRegExpType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return checkQualifiedName(node, checkMode); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 208 /* CallExpression */: - if (node.expression.kind === 100 /* ImportKeyword */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.expression.kind === 100 /* SyntaxKind.ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checkCallExpression(node, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return checkClassExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return checkTypeOfExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return checkAssertion(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return checkNonNullAssertion(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return checkExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkMetaProperty(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkDeleteExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return checkVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return checkAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return checkSpreadExpression(node, checkMode); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return undefinedWideningType; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return checkYieldExpression(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return checkSyntheticExpression(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return checkJsxExpression(node, checkMode); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return checkJsxElement(node, checkMode); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return checkJsxFragment(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -80715,16 +81005,18 @@ var ts; var modifiers = getVarianceModifiers(typeParameter); if (modifiers) { var symbol = getSymbolOfNode(node.parent); - if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) { + if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */))) { error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); } - else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType); + else if (modifiers === 32768 /* ModifierFlags.In */ || modifiers === 65536 /* ModifierFlags.Out */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) }); + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck); var saveVarianceTypeParameter = typeParameter; varianceTypeParameter = typeParameter; checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); varianceTypeParameter = saveVarianceTypeParameter; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } } } @@ -80737,28 +81029,28 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 171 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { + if (!(func.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 171 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 171 /* SyntaxKind.Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } - if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { + if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) { error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); } if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) { if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 171 /* Constructor */ || func.kind === 175 /* ConstructSignature */ || func.kind === 180 /* ConstructorType */) { + if (func.kind === 171 /* SyntaxKind.Constructor */ || func.kind === 175 /* SyntaxKind.ConstructSignature */ || func.kind === 180 /* SyntaxKind.ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 172 /* GetAccessor */ || func.kind === 173 /* SetAccessor */) { + if (func.kind === 172 /* SyntaxKind.GetAccessor */ || func.kind === 173 /* SyntaxKind.SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -80782,7 +81074,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { + if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -80816,13 +81108,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 179 /* FunctionType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 179 /* SyntaxKind.FunctionType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -80836,11 +81128,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* SyntaxKind.Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 202 /* ArrayBindingPattern */ || name.kind === 201 /* ObjectBindingPattern */) { + else if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -80849,29 +81141,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 176 /* IndexSignature */) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 179 /* FunctionType */ || node.kind === 256 /* FunctionDeclaration */ || node.kind === 180 /* ConstructorType */ || - node.kind === 174 /* CallSignature */ || node.kind === 171 /* Constructor */ || - node.kind === 175 /* ConstructSignature */) { + else if (node.kind === 179 /* SyntaxKind.FunctionType */ || node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 180 /* SyntaxKind.ConstructorType */ || + node.kind === 174 /* SyntaxKind.CallSignature */ || node.kind === 171 /* SyntaxKind.Constructor */ || + node.kind === 175 /* SyntaxKind.ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); - if (!(functionFlags & 4 /* Invalid */)) { + if (!(functionFlags & 4 /* FunctionFlags.Invalid */)) { // Async generators prior to ESNext require the __await and __asyncGenerator helpers - if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 3 /* FunctionFlags.AsyncGenerator */ && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 6144 /* ExternalEmitHelpers.AsyncGeneratorIncludes */); } // Async functions prior to ES2017 require the __awaiter helper - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { - checkExternalEmitHelpers(node, 64 /* Awaiter */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */ && languageVersion < 4 /* ScriptTarget.ES2017 */) { + checkExternalEmitHelpers(node, 64 /* ExternalEmitHelpers.Awaiter */); } // Generator functions, Async functions, and Async Generator functions prior to // ES2015 require the __generator helper - if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 128 /* Generator */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) !== 0 /* FunctionFlags.Normal */ && languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 128 /* ExternalEmitHelpers.Generator */); } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); @@ -80887,17 +81179,17 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (returnTypeNode) { var functionFlags_1 = ts.getFunctionFlags(node); - if ((functionFlags_1 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) { + if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) { var returnType = getTypeFromTypeNode(returnTypeNode); if (returnType === voidType) { error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -80909,18 +81201,18 @@ var ts; // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; - var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || generatorYieldType; - var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || unknownType; - var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* Async */)); + var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType; + var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType; + var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType; + var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */)); checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode); } } - else if ((functionFlags_1 & 3 /* AsyncGenerator */) === 2 /* Async */) { + else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 176 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) { + if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -80932,11 +81224,11 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 171 /* Constructor */) { + if (member.kind === 171 /* SyntaxKind.Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); + addName(instanceNames, param.name, param.name.escapedText, 3 /* DeclarationMeaning.GetOrSetAccessor */); } } } @@ -80947,24 +81239,24 @@ var ts; continue; } var isPrivate = ts.isPrivateIdentifier(name); - var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0; + var privateStaticFlags = isPrivate && isStaticMember ? 16 /* DeclarationMeaning.PrivateStatic */ : 0; var names = isPrivate ? privateIdentifiers : isStaticMember ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 172 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); + case 172 /* SyntaxKind.GetAccessor */: + addName(names, name, memberName, 1 /* DeclarationMeaning.GetAccessor */ | privateStaticFlags); break; - case 173 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); + case 173 /* SyntaxKind.SetAccessor */: + addName(names, name, memberName, 2 /* DeclarationMeaning.SetAccessor */ | privateStaticFlags); break; - case 167 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: + addName(names, name, memberName, 3 /* DeclarationMeaning.GetOrSetAccessor */ | privateStaticFlags); break; - case 169 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); + case 169 /* SyntaxKind.MethodDeclaration */: + addName(names, name, memberName, 8 /* DeclarationMeaning.Method */ | privateStaticFlags); break; } } @@ -80974,19 +81266,19 @@ var ts; var prev = names.get(name); if (prev) { // For private identifiers, do not allow mixing of static and instance members with the same name - if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + if ((prev & 16 /* DeclarationMeaning.PrivateStatic */) !== (meaning & 16 /* DeclarationMeaning.PrivateStatic */)) { error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - var prevIsMethod = !!(prev & 8 /* Method */); - var isMethod = !!(meaning & 8 /* Method */); + var prevIsMethod = !!(prev & 8 /* DeclarationMeaning.Method */); + var isMethod = !!(meaning & 8 /* DeclarationMeaning.Method */); if (prevIsMethod || isMethod) { if (prevIsMethod !== isMethod) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered } - else if (prev & meaning & ~16 /* PrivateStatic */) { + else if (prev & meaning & ~16 /* DeclarationMeaning.PrivateStatic */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { @@ -81035,15 +81327,15 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 166 /* PropertySignature */) { + if (member.kind === 166 /* SyntaxKind.PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: memberName = name.text; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: memberName = ts.idText(name); break; default: @@ -81060,7 +81352,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -81074,7 +81366,7 @@ var ts; var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var indexSignatureMap_1 = new ts.Map(); - var _loop_28 = function (declaration) { + var _loop_29 = function (declaration) { if (declaration.parameters.length === 1 && declaration.parameters[0].type) { forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) { var entry = indexSignatureMap_1.get(getTypeId(type)); @@ -81089,7 +81381,7 @@ var ts; }; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - _loop_28(declaration); + _loop_29(declaration); } indexSignatureMap_1.forEach(function (entry) { if (entry.declarations.length > 1) { @@ -81108,7 +81400,7 @@ var ts; checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); // property signatures already report "initializer not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* PropertyDeclaration */ && node.initializer) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && node.initializer) { error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -81128,7 +81420,7 @@ var ts; // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // method signatures already report "implementation not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 169 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } // Private named methods are only allowed in class declarations @@ -81138,9 +81430,9 @@ var ts; setNodeLinksForPrivateIdentifierScope(node); } function setNodeLinksForPrivateIdentifierScope(node) { - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ScriptTarget.ESNext */) { for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; + getNodeLinks(lexicalScope).flags |= 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */; } // If this is a private element in a class expression inside the body of a loop, // then we must use a block-scoped binding to store the additional variables required @@ -81148,8 +81440,8 @@ var ts; if (ts.isClassExpression(node.parent)) { var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); if (enclosingIterationStatement) { - getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(node.name).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } } @@ -81181,7 +81473,7 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 167 /* PropertyDeclaration */ && + return n.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(n) && !!n.initializer; } @@ -81202,9 +81494,9 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && + var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ModifierFlags.ParameterPropertyModifier */); })); if (superCallShouldBeRootLevel) { // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional // See GH #8277 @@ -81243,7 +81535,7 @@ var ts; return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body; } function nodeImmediatelyReferencesSuperOrThis(node) { - if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || node.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } if (ts.isThisContainerOrFunctionBlock(node)) { @@ -81264,9 +81556,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 172 /* GetAccessor */) { - if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { - if (!(node.flags & 512 /* HasExplicitReturn */)) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* NodeFlags.HasImplicitReturn */)) { + if (!(node.flags & 512 /* NodeFlags.HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -81274,25 +81566,25 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var symbol = getSymbolOfNode(node); - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); - if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { - getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* NodeCheckFlags.TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* NodeCheckFlags.TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); var setterFlags = ts.getEffectiveModifierFlags(setter); - if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) { + if ((getterFlags & 128 /* ModifierFlags.Abstract */) !== (setterFlags & 128 /* ModifierFlags.Abstract */)) { error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) || - ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) { + if (((getterFlags & 16 /* ModifierFlags.Protected */) && !(setterFlags & (16 /* ModifierFlags.Protected */ | 8 /* ModifierFlags.Private */))) || + ((getterFlags & 8 /* ModifierFlags.Private */) && !(setterFlags & 8 /* ModifierFlags.Private */))) { error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -81304,7 +81596,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -81312,6 +81604,12 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function getEffectiveTypeArgumentAtIndex(node, typeParameters, index) { + if (index < typeParameters.length) { + return getTypeFromTypeNode(node.typeArguments[index]); + } + return getEffectiveTypeArguments(node, typeParameters)[index]; + } function getEffectiveTypeArguments(node, typeParameters) { return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node)); } @@ -81336,15 +81634,15 @@ var ts; if (!isErrorType(type)) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || - (ts.getObjectFlags(type) & 4 /* Reference */ ? type.target.localTypeParameters : undefined); + return symbol.flags & 524288 /* SymbolFlags.TypeAlias */ && getSymbolLinks(symbol).typeParameters || + (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target.localTypeParameters : undefined); } } return undefined; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 178 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -81360,10 +81658,10 @@ var ts; } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) { + if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) { addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } - if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -81402,29 +81700,29 @@ var ts; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) { var e = elementTypes_1[_i]; - if (e.kind !== 197 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 197 /* SyntaxKind.NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } var flags = getTupleElementFlags(e); - if (flags & 8 /* Variadic */) { + if (flags & 8 /* ElementFlags.Variadic */) { var type = getTypeFromTypeNode(e.type); if (!isArrayLikeType(type)) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); break; } - if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) { + if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* ElementFlags.Rest */) { seenRestElement = true; } } - else if (flags & 4 /* Rest */) { + else if (flags & 4 /* ElementFlags.Rest */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element); break; } seenRestElement = true; } - else if (flags & 2 /* Optional */) { + else if (flags & 2 /* ElementFlags.Optional */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element); break; @@ -81444,15 +81742,15 @@ var ts; getTypeFromTypeNode(node); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 8388608 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* TypeFlags.IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 207 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && - ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { + if (accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + ts.getObjectFlags(objectType) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; @@ -81460,14 +81758,14 @@ var ts; // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. var apparentObjectType = getApparentType(objectType); - if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { return type; } if (isGenericObjectType(objectType)) { var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode); if (propertyName_1) { var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); }); - if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) { error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1)); return errorType; } @@ -81516,7 +81814,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* SyntaxKind.ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -81526,7 +81824,7 @@ var ts; if (!links.typeParametersChecked) { links.typeParametersChecked = true; var typeParameter = getDeclaredTypeOfTypeParameter(symbol); - var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */); + var declarations = ts.getDeclarationsOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); @@ -81567,31 +81865,31 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 185 /* OptionalType */) { + if (node.type.kind === 185 /* SyntaxKind.OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 186 /* RestType */) { + if (node.type.kind === 186 /* SyntaxKind.RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* NodeFlags.Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 258 /* InterfaceDeclaration */ && - n.parent.kind !== 257 /* ClassDeclaration */ && - n.parent.kind !== 226 /* ClassExpression */ && - n.flags & 16777216 /* Ambient */) { - if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { + if (n.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */ && + n.parent.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + n.parent.kind !== 226 /* SyntaxKind.ClassExpression */ && + n.flags & 16777216 /* NodeFlags.Ambient */) { + if (!(flags & 2 /* ModifierFlags.Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; } return flags & flagsToCheck; } @@ -81616,16 +81914,16 @@ var ts; var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; - if (deviation & 1 /* Export */) { + if (deviation & 1 /* ModifierFlags.Export */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 2 /* ModifierFlags.Ambient */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 128 /* Abstract */) { + else if (deviation & 128 /* ModifierFlags.Abstract */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -81642,8 +81940,8 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; - var someNodeFlags = 0 /* None */; + var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */; + var someNodeFlags = 0 /* ModifierFlags.None */; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; var allHaveQuestionToken = true; @@ -81652,7 +81950,7 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0; function reportImplementationExpectedError(node) { if (node.name && ts.nodeIsMissing(node.name)) { return; @@ -81681,7 +81979,7 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */) && + var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) && ts.isStatic(node) !== ts.isStatic(subsequentNode); // we can get here in two cases // 1. mixed static and instance class members @@ -81706,7 +82004,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -81722,8 +82020,8 @@ var ts; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var current = declarations_5[_i]; var node = current; - var inAmbientContext = node.flags & 16777216 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -81734,10 +82032,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 256 /* FunctionDeclaration */ || node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */ || node.kind === 171 /* Constructor */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */ || node.kind === 171 /* SyntaxKind.Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -81781,13 +82079,13 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { - var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* ClassDeclaration */; }) + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* SymbolFlags.Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* SyntaxKind.ClassDeclaration */; }) .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - var diagnostic = declaration.kind === 257 /* ClassDeclaration */ + var diagnostic = declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 - : declaration.kind === 256 /* FunctionDeclaration */ + : declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : undefined; if (diagnostic) { @@ -81797,7 +82095,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* ModifierFlags.Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -81837,15 +82135,15 @@ var ts; if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; + var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 512 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */); + if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) { + if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -81878,56 +82176,56 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: - return 2 /* ExportType */; - case 261 /* ModuleDeclaration */: - return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4 /* ExportNamespace */ | 1 /* ExportValue */ - : 4 /* ExportNamespace */; - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - return 2 /* ExportType */ | 1 /* ExportValue */; - case 305 /* SourceFile */: - return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + return 2 /* DeclarationSpaces.ExportType */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* ModuleInstanceState.NonInstantiated */ + ? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */ + : 4 /* DeclarationSpaces.ExportNamespace */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */; + case 305 /* SyntaxKind.SourceFile */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */; + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: var node_2 = d; var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(expression)) { - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; } d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: - var result_12 = 0 /* None */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + var result_12 = 0 /* DeclarationSpaces.None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 256 /* FunctionDeclaration */: - case 270 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* SyntaxKind.Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) // or SyntaxKind.PropertyAccessExpression - `thing.aField = 42;` // all of which are pretty much always values, or at least imply a value meaning. // It may be apprpriate to treat these as aliases in the future. - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); } @@ -81963,14 +82261,14 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } // primitives with a `{ then() }` won't be unwrapped/adopted. - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { return undefined; } var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : ts.emptyArray; + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* SignatureKind.Call */) : ts.emptyArray; if (thenSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); @@ -81999,18 +82297,18 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* TypeFacts.NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* SignatureKind.Call */); if (onfulfilledParameterSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); } return undefined; } - return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* Subtype */); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* UnionReduction.Subtype */); } /** * Gets the "awaited type" of a type. @@ -82030,16 +82328,16 @@ var ts; * Determines whether a type is an object with a callable `then` member. */ function isThenableType(type) { - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { // primitive types cannot be considered "thenable" since they are not objects. return false; } var thenFunction = getTypeOfPropertyOfType(type, "then"); - return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; + return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* TypeFacts.NEUndefinedOrNull */), 0 /* SignatureKind.Call */).length > 0; } function isAwaitedTypeInstantiation(type) { var _a; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false); return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1; } @@ -82049,10 +82347,38 @@ var ts; * For a generic `Awaited`, gets `T`. */ function unwrapAwaitedType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, unwrapAwaitedType) : isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } + function isAwaitedTypeNeeded(type) { + // If this is already an `Awaited`, we shouldn't wrap it. This helps to avoid `Awaited>` in higher-order. + if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) { + return false; + } + // We only need `Awaited` if `T` contains possibly non-primitive types. + if (isGenericObjectType(type)) { + var baseConstraint = getBaseConstraintOfType(type); + // We only need `Awaited` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, + // or is promise-like. + if (baseConstraint ? + baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) : + maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) { + return true; + } + } + return false; + } + function tryCreateAwaitedType(type) { + // Nothing to do if `Awaited` doesn't exist + var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); + if (awaitedSymbol) { + // Unwrap unions that may contain `Awaited`, otherwise its possible to manufacture an `Awaited | U>` where + // an `Awaited` would suffice. + return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); + } + return undefined; + } function createAwaitedTypeIfNeeded(type) { // We wrap type `T` in `Awaited` based on the following conditions: // - `T` is not already an `Awaited`, and @@ -82061,26 +82387,10 @@ var ts; // - `T` has no base constraint, or // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or // - The base constraint of `T` is an object type with a callable `then` method. - if (isTypeAny(type)) { - return type; - } - // If this is already an `Awaited`, just return it. This helps to avoid `Awaited>` in higher-order. - if (isAwaitedTypeInstantiation(type)) { - return type; - } - // Only instantiate `Awaited` if `T` contains possibly non-primitive types. - if (isGenericObjectType(type)) { - var baseConstraint = getBaseConstraintOfType(type); - // Only instantiate `Awaited` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, - // or is promise-like. - if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { - // Nothing to do if `Awaited` doesn't exist - var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); - if (awaitedSymbol) { - // Unwrap unions that may contain `Awaited`, otherwise its possible to manufacture an `Awaited | U>` where - // an `Awaited` would suffice. - return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); - } + if (isAwaitedTypeNeeded(type)) { + var awaitedType = tryCreateAwaitedType(type); + if (awaitedType) { + return awaitedType; } } ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like."); @@ -82119,9 +82429,22 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } // For a union, get a union of the awaited types of each constituent. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { + if (awaitedTypeStack.lastIndexOf(type.id) >= 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; - return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); + awaitedTypeStack.push(type.id); + var mapped = mapType(type, mapper); + awaitedTypeStack.pop(); + return typeAsAwaitable.awaitedTypeOfType = mapped; + } + // If `type` is generic and should be wrapped in `Awaited`, return it. + if (isAwaitedTypeNeeded(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; } var thisTypeForErrorOut = { value: undefined }; var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut); @@ -82242,7 +82565,7 @@ var ts; // } // var returnType = getTypeFromTypeNode(returnTypeNode); - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { if (isErrorType(returnType)) { return; } @@ -82265,10 +82588,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (isErrorType(promiseConstructorType)) { - if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* SyntaxKind.Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -82288,7 +82611,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* SymbolFlags.Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -82301,26 +82624,26 @@ var ts; var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { + if (returnType.flags & 1 /* TypeFlags.Any */) { return; } var headMessage; var expectedReturnType; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any; expectedReturnType = voidType; break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); @@ -82342,9 +82665,9 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* SyntaxKind.Identifier */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */) | 2097152 /* SymbolFlags.Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true); - if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) { + if (rootSymbol && rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) { if (symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) { @@ -82379,15 +82702,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; } } @@ -82396,13 +82719,13 @@ var ts; var commonEntityName; for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { var typeNode = types_21[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */ || typeNode.kind === 197 /* SyntaxKind.NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -82447,15 +82770,15 @@ var ts; if (!firstDecorator) { return; } - checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 164 /* Parameter */) { - checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + checkExternalEmitHelpers(firstDecorator, 8 /* ExternalEmitHelpers.Decorate */); + if (node.kind === 164 /* SyntaxKind.Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* ExternalEmitHelpers.Param */); } if (compilerOptions.emitDecoratorMetadata) { - checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); + checkExternalEmitHelpers(firstDecorator, 16 /* ExternalEmitHelpers.Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -82464,23 +82787,23 @@ var ts; } } break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - var otherKind = node.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + var otherKind = node.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -82580,9 +82903,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; default: return undefined; @@ -82596,7 +82919,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -82612,7 +82935,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find( // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* NodeFlags.JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -82622,7 +82945,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 168 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 168 /* SyntaxKind.MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics); @@ -82640,7 +82963,7 @@ var ts; if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { reportImplicitAny(node, anyType); } - if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) { + if (functionFlags & 1 /* FunctionFlags.Generator */ && ts.nodeIsPresent(body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -82668,42 +82991,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 305 /* SourceFile */: - case 261 /* ModuleDeclaration */: - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 305 /* SyntaxKind.SourceFile */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -82714,41 +83037,41 @@ var ts; function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(declaration, 0 /* Local */, ts.createDiagnosticForNode(node, message, name)); + addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name)); } function isIdentifierThatStartsWithUnderscore(node) { - return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; + return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* CharacterCodes._ */; } function checkUnusedClassMembers(node, addDiagnostic) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - if (member.kind === 173 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && member.symbol.flags & 32768 /* SymbolFlags.GetAccessor */) { // Already would have reported an error on the getter. break; } var symbol = getSymbolOfNode(member); if (!symbol.isReferenced - && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) - && !(member.flags & 16777216 /* Ambient */)) { - addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); + && (ts.hasEffectiveModifier(member, 8 /* ModifierFlags.Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) + && !(member.flags & 16777216 /* NodeFlags.Ambient */)) { + addDiagnostic(member, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { - addDiagnostic(parameter, 0 /* Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); + if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* ModifierFlags.Private */)) { + addDiagnostic(parameter, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); } } break; - case 176 /* IndexSignature */: - case 234 /* SemicolonClassElement */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 234 /* SyntaxKind.SemicolonClassElement */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Can't be private break; default: @@ -82759,7 +83082,7 @@ var ts; function checkUnusedInferTypeParameter(node, addDiagnostic) { var typeParameter = node.typeParameter; if (isTypeParameterUnused(typeParameter)) { - addDiagnostic(node, 1 /* Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); + addDiagnostic(node, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); } } function checkUnusedTypeParameters(node, addDiagnostic) { @@ -82770,13 +83093,13 @@ var ts; return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); - for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { - var typeParameter = typeParameters_3[_i]; + for (var _i = 0, typeParameters_4 = typeParameters; _i < typeParameters_4.length; _i++) { + var typeParameter = typeParameters_4[_i]; if (!isTypeParameterUnused(typeParameter)) continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 190 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 190 /* SyntaxKind.InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -82788,17 +83111,17 @@ var ts; //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); } } else { //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); } } } function isTypeParameterUnused(typeParameter) { - return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); + return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* SymbolFlags.TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); } function addToGroup(map, key, value, getKey) { var keyString = String(getKey(key)); @@ -82835,7 +83158,7 @@ var ts; nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. - if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { + if (local.flags & 262144 /* SymbolFlags.TypeParameter */ ? !(local.flags & 3 /* SymbolFlags.Variable */ && !(local.isReferenced & 3 /* SymbolFlags.Variable */)) : local.isReferenced || local.exportSymbol) { return; } if (local.declarations) { @@ -82866,7 +83189,7 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } else { - addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + addDiagnostic(parameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } } @@ -82882,10 +83205,10 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 268 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { - addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 + addDiagnostic(importDecl, 0 /* UnusedKind.Local */, unuseds.length === 1 ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); } @@ -82898,9 +83221,9 @@ var ts; }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; - var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; + var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -82919,14 +83242,14 @@ var ts; unusedVariables.forEach(function (_a) { var declarationList = _a[0], declarations = _a[1]; if (declarationList.declarations.length === declarations.length) { - addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 + addDiagnostic(declarationList, 0 /* UnusedKind.Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { var decl = declarations_6[_i]; - addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); + addDiagnostic(decl, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); } } }); @@ -82949,24 +83272,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.idText(name); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 267 /* ImportClause */ || node.kind === 270 /* ImportSpecifier */ || node.kind === 268 /* NamespaceImport */; + return node.kind === 267 /* SyntaxKind.ImportClause */ || node.kind === 270 /* SyntaxKind.ImportSpecifier */ || node.kind === 268 /* SyntaxKind.NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 267 /* ImportClause */ ? decl : decl.kind === 268 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 267 /* SyntaxKind.ImportClause */ ? decl : decl.kind === 268 /* SyntaxKind.NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 235 /* Block */) { + if (node.kind === 235 /* SyntaxKind.Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -82983,7 +83306,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* NodeFlags.Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -83001,17 +83324,17 @@ var ts; if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - if (node.kind === 167 /* PropertyDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 169 /* MethodDeclaration */ || - node.kind === 168 /* MethodSignature */ || - node.kind === 172 /* GetAccessor */ || - node.kind === 173 /* SetAccessor */ || - node.kind === 296 /* PropertyAssignment */) { + if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */ || + node.kind === 168 /* SyntaxKind.MethodSignature */ || + node.kind === 172 /* SyntaxKind.GetAccessor */ || + node.kind === 173 /* SyntaxKind.SetAccessor */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */) { // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // ambient context - no codegen impact return false; } @@ -83031,8 +83354,8 @@ var ts; // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 4 /* NodeCheckFlags.CaptureThis */) { + var isDeclaration_1 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -83046,8 +83369,8 @@ var ts; } function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 8 /* NodeCheckFlags.CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -83068,46 +83391,46 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { + if (!name || languageVersion >= 4 /* ScriptTarget.ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* NodeFlags.HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) { - if (languageVersion <= 8 /* ES2021 */ + if (languageVersion <= 8 /* ScriptTarget.ES2021 */ && (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) { potentialWeakMapSetCollisions.push(node); } } function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); - if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { + if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */) { ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); } } function recordPotentialCollisionWithReflectInGeneratedCode(node, name) { - if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ + if (name && languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && needCollisionCheckForIdentifier(node, name, "Reflect")) { potentialReflectCollisions.push(node); } @@ -83118,7 +83441,7 @@ var ts; // ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(member) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; break; } @@ -83126,13 +83449,13 @@ var ts; } else if (ts.isFunctionExpression(node)) { // FunctionExpression names don't contribute to their containers, but do matter for their contents - if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(node) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } else { var container = ts.getEnclosingBlockScopeContainer(node); - if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (container && getNodeCheckFlags(container) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } @@ -83150,7 +83473,7 @@ var ts; recordPotentialCollisionWithReflectInGeneratedCode(node, name); if (ts.isClassLike(node)) { checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0); - if (!(node.flags & 16777216 /* Ambient */)) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */)) { checkClassNameCollisionWithObject(name); } } @@ -83182,35 +83505,35 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3 /* NodeFlags.BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 254 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { + if (symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) return ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* SymbolFlags.Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 237 /* VariableStatement */ && varDeclList.parent.parent + localDeclarationSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* NodeFlags.BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); + var container = varDeclList.parent.kind === 237 /* SyntaxKind.VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 235 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 262 /* ModuleBlock */ || - container.kind === 261 /* ModuleDeclaration */ || - container.kind === 305 /* SourceFile */); + (container.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(container.parent) || + container.kind === 262 /* SyntaxKind.ModuleBlock */ || + container.kind === 261 /* SyntaxKind.ModuleDeclaration */ || + container.kind === 305 /* SyntaxKind.SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -83241,7 +83564,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { checkExpressionCached(node.initializer); @@ -83259,16 +83582,16 @@ var ts; potentialUnusedRenamedBindingElementsInTypes.push(node); return; } - if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { - checkExternalEmitHelpers(node, 4 /* Rest */); + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ScriptTarget.ES2018 */) { + checkExternalEmitHelpers(node, 4 /* ExternalEmitHelpers.Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 162 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access var parent = node.parent.parent; - var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var parentCheckMode = node.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(parent, parentCheckMode); var name = node.propertyName || node.name; if (parentType && !ts.isBindingPattern(name)) { @@ -83278,15 +83601,15 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SyntaxKind.SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 202 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (node.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } ts.forEach(node.name.elements, checkSourceElement); } @@ -83297,7 +83620,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = ts.hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */; + var needCheckInitializer = ts.hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */; var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression)); if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -83314,7 +83637,7 @@ var ts; // check the binding pattern with empty elements if (needCheckWidenedType) { if (ts.isArrayBindingPattern(node.name)) { - checkIteratedTypeOrElementType(65 /* Destructuring */, widenedType, undefinedType, node); + checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, widenedType, undefinedType, node); } else if (strictNullChecks) { checkNonNullNonVoidType(widenedType, node); @@ -83325,7 +83648,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* SyntaxKind.BindingElement */ ? node.parent.parent : node)) { checkAliasSymbol(node); return; } @@ -83339,7 +83662,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -83355,7 +83678,7 @@ var ts; var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (!isErrorType(type) && !isErrorType(declarationType) && !isTypeIdenticalTo(type, declarationType) && - !(symbol.flags & 67108864 /* Assignment */)) { + !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { @@ -83365,10 +83688,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */) { + if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionsForDeclarationName(node, node.name); @@ -83376,7 +83699,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 167 /* PropertyDeclaration */ || nextDeclaration.kind === 166 /* PropertySignature */ + var message = nextDeclaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 166 /* SyntaxKind.PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -83386,24 +83709,24 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 164 /* Parameter */ && right.kind === 254 /* VariableDeclaration */) || - (left.kind === 254 /* VariableDeclaration */ && right.kind === 164 /* Parameter */)) { + if ((left.kind === 164 /* SyntaxKind.Parameter */ && right.kind === 254 /* SyntaxKind.VariableDeclaration */) || + (left.kind === 254 /* SyntaxKind.VariableDeclaration */ && right.kind === 164 /* SyntaxKind.Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* ModifierFlags.Private */ | + 16 /* ModifierFlags.Protected */ | + 256 /* ModifierFlags.Async */ | + 128 /* ModifierFlags.Abstract */ | + 64 /* ModifierFlags.Readonly */ | + 32 /* ModifierFlags.Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -83429,7 +83752,7 @@ var ts; checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 236 /* EmptyStatement */) { + if (node.thenStatement.kind === 236 /* SyntaxKind.EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -83438,27 +83761,27 @@ var ts; if (!strictNullChecks) return; helper(condExpr, body); - while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) { + while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { condExpr = condExpr.left; helper(condExpr, body); } function helper(condExpr, body) { var location = ts.isBinaryExpression(condExpr) && - (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */) + (condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || condExpr.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) ? condExpr.right : condExpr; if (ts.isModuleExportsAccessExpression(location)) return; var type = checkTruthinessExpression(location); var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression); - if (!(getTypeFacts(type) & 4194304 /* Truthy */) || isPropertyExpressionCast) + if (!(getTypeFacts(type) & 4194304 /* TypeFacts.Truthy */) || isPropertyExpressionCast) return; // While it technically should be invalid for any known-truthy value // to be tested, we de-scope to functions and Promises unreferenced in // the block as a heuristic to identify the most common bugs. There // are too many false positives for values sourced from type // definitions without strictNullChecks otherwise. - var callSignatures = getSignaturesOfType(type, 0 /* Call */); + var callSignatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var isPromise = !!getAwaitedTypeOfPromise(type); if (callSignatures.length === 0 && !isPromise) { return; @@ -83498,7 +83821,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { + testedExpression.kind === 108 /* SyntaxKind.ThisKeyword */ && childExpression.kind === 108 /* SyntaxKind.ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -83522,7 +83845,7 @@ var ts; }); } function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { - while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { var symbol = getSymbolAtLocation(child); @@ -83552,7 +83875,7 @@ var ts; checkSourceElement(node.statement); } function checkTruthinessOfType(type, node) { - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -83563,12 +83886,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -83593,29 +83916,29 @@ var ts; } else { var functionFlags = ts.getFunctionFlags(container); - if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { + if ((functionFlags & (4 /* FunctionFlags.Invalid */ | 2 /* FunctionFlags.Async */)) === 2 /* FunctionFlags.Async */ && languageVersion < 99 /* ScriptTarget.ESNext */) { // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper - checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + checkExternalEmitHelpers(node, 16384 /* ExternalEmitHelpers.ForAwaitOfIncludes */); } } } - else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) { + else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ScriptTarget.ES2015 */) { // for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled - checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.ForOfIncludes */); } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -83647,7 +83970,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -83661,7 +83984,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -83674,7 +83997,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -83691,7 +84014,7 @@ var ts; } } function checkRightHandSideOfForOf(statement) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) { @@ -83706,14 +84029,14 @@ var ts; * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) { - var allowAsyncIterables = (use & 2 /* AllowsAsyncIterablesFlag */) !== 0; + var allowAsyncIterables = (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) !== 0; if (inputType === neverType) { reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } - var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var uplevelIteration = languageVersion >= 2 /* ScriptTarget.ES2015 */; var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; - var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */); + var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* IterationUse.PossiblyOutOfBounds */); // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. @@ -83722,10 +84045,10 @@ var ts; var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined); if (checkAssignability) { if (iterationTypes) { - var diagnostic = use & 8 /* ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : - use & 32 /* SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : - use & 64 /* DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : - use & 16 /* YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : + var diagnostic = use & 8 /* IterationUse.ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : + use & 32 /* IterationUse.SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : + use & 64 /* IterationUse.DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : + use & 16 /* IterationUse.YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : undefined; if (diagnostic) { checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic); @@ -83742,22 +84065,22 @@ var ts; // If strings are permitted, remove any string-like constituents from the array type. // This allows us to find other non-string element types from an array unioned with // a string. - if (use & 4 /* AllowsStringInputFlag */) { - if (arrayType.flags & 1048576 /* Union */) { + if (use & 4 /* IterationUse.AllowsStringInputFlag */) { + if (arrayType.flags & 1048576 /* TypeFlags.Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* TypeFlags.StringLike */); }); if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, 2 /* Subtype */); + arrayType = getUnionType(filteredTypes, 2 /* UnionReduction.Subtype */); } } - else if (arrayType.flags & 402653316 /* StringLike */) { + else if (arrayType.flags & 402653316 /* TypeFlags.StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { if (errorNode) { error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); reportedError = true; @@ -83765,7 +84088,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 131072 /* Never */) { + if (arrayType.flags & 131072 /* TypeFlags.Never */) { return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType; } } @@ -83777,7 +84100,7 @@ var ts; // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var allowsStrings = !!(use & 4 /* IterationUse.AllowsStringInputFlag */) && !hasStringConstituent; var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } @@ -83786,12 +84109,12 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, numberType); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { + if (arrayElementType.flags & 402653316 /* TypeFlags.StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } - return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); + return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* UnionReduction.Subtype */); } - return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + return (use & 128 /* IterationUse.PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { var _a; if (downlevelIteration) { @@ -83799,7 +84122,7 @@ var ts; ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] : [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]; } - var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); + var yieldType = getIterationTypeOfIterable(use, 0 /* IterationTypeKind.Yield */, inputType, /*errorNode*/ undefined); if (yieldType) { return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } @@ -83848,9 +84171,9 @@ var ts; // more frequently created (i.e. `Iterator`). Iteration types // are also cached on the type they are requested for, so we shouldn't need to maintain // the cache for less-frequently used types. - if (yieldType.flags & 67359327 /* Intrinsic */ && - returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && - nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) { + if (yieldType.flags & 67359327 /* TypeFlags.Intrinsic */ && + returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */) && + nextType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { var id = getTypeListId([yieldType, returnType, nextType]); var iterationTypes = iterationTypesCache.get(id); if (!iterationTypes) { @@ -83917,37 +84240,56 @@ var ts; * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method. */ function getIterationTypesOfIterable(type, use, errorNode) { + var _a, _b; if (isTypeAny(type)) { return anyIterationTypes; } - if (!(type.flags & 1048576 /* Union */)) { - var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } return undefined; } + else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) { + for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) { + var diag = _c[_i]; + diagnostics.add(diag); + } + } return iterationTypes_1; } - var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; + var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; var cachedTypes = getCachedIterationTypes(type, cacheKey); if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; var allIterationTypes; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituent = _a[_i]; - var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); + for (var _d = 0, _e = type.types; _d < _e.length; _d++) { + var constituent = _e[_d]; + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; } - else { - allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); + else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) { + for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) { + var diag = _g[_f]; + diagnostics.add(diag); + } } + allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); } var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes; setCachedIterationTypes(type, cacheKey, iterationTypes); @@ -83975,47 +84317,62 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterable` instead. */ - function getIterationTypesOfIterableWorker(type, use, errorNode) { + function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) { if (isTypeAny(type)) { return anyIterationTypes; } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + // If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached. + // In addition, we should not cache any new results for this call. + var noCache = false; + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 /* ForOfFlag */ ? - getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : - iterationTypes; + if (iterationTypes === noIterationTypes && errorNode) { + // ignore the cached value + noCache = true; + } + else { + return use & 8 /* IterationUse.ForOfFlag */ ? + getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : + iterationTypes; + } } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { - // for a sync iterable in an async context, only use the cached types if they are valid. - if (iterationTypes !== noIterationTypes) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); - } + if (iterationTypes === noIterationTypes && errorNode) { + // ignore the cached value + noCache = true; } else { - return iterationTypes; + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + // for a sync iterable in an async context, only use the cached types if they are valid. + if (iterationTypes !== noIterationTypes) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); + } + } + else { + return iterationTypes; + } } } } - if (use & 2 /* AllowsAsyncIterablesFlag */) { - var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { - var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { + var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes - ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) - : noIterationTypes); + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); } else { return iterationTypes; @@ -84036,7 +84393,7 @@ var ts; } function getIterationTypesOfGlobalIterableType(globalType, resolver) { var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) || - getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined); + getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false); return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes; } /** @@ -84078,7 +84435,7 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like @@ -84090,26 +84447,26 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterable` instead. */ - function getIterationTypesOfIterableSlow(type, resolver, errorNode) { + function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); - var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; + var methodType = method && !(method.flags & 16777216 /* SymbolFlags.Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); + return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } - var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : undefined; if (!ts.some(signatures)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); + return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature)); - var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes; - return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); + var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes; + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); } function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) { var message = allowAsyncIterables ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator; - errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); + return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); } /** * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type. @@ -84117,13 +84474,29 @@ var ts; * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` * record is returned. Otherwise, `undefined` is returned. */ - function getIterationTypesOfIterator(type, resolver, errorNode) { + function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) { + return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false); + } + /** + * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type. + * + * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` + * record is returned. Otherwise, `undefined` is returned. + * + * NOTE: You probably don't want to call this directly and should be calling + * `getIterationTypesOfIterator` instead. + */ + function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) { if (isTypeAny(type)) { return anyIterationTypes; } var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) || - getIterationTypesOfIteratorFast(type, resolver) || - getIterationTypesOfIteratorSlow(type, resolver, errorNode); + getIterationTypesOfIteratorFast(type, resolver); + if (iterationTypes === noIterationTypes && errorNode) { + iterationTypes = undefined; + noCache = true; + } + iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache)); return iterationTypes === noIterationTypes ? undefined : iterationTypes; } /** @@ -84161,7 +84534,7 @@ var ts; // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || - getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined); + getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false); var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType; return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType)); } @@ -84177,13 +84550,13 @@ var ts; // > If the end was not reached `done` is `false` and a value is available. // > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`. var doneType = getTypeOfPropertyOfType(type, "done") || falseType; - return isTypeAssignableTo(kind === 0 /* Yield */ ? falseType : trueType, doneType); + return isTypeAssignableTo(kind === 0 /* IterationTypeKind.Yield */ ? falseType : trueType, doneType); } function isYieldIteratorResult(type) { - return isIteratorResult(type, 0 /* Yield */); + return isIteratorResult(type, 0 /* IterationTypeKind.Yield */); } function isReturnIteratorResult(type) { - return isIteratorResult(type, 1 /* Return */); + return isIteratorResult(type, 1 /* IterationTypeKind.Return */); } /** * Gets the *yield* and *return* types of an `IteratorResult`-like type. @@ -84231,30 +84604,36 @@ var ts; * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` * record is returned. Otherwise, we return `undefined`. */ - function getIterationTypesOfMethod(type, resolver, methodName, errorNode) { - var _a, _b, _c, _d; + function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) { + var _a, _b, _c, _d, _e, _f; var method = getPropertyOfType(type, methodName); // Ignore 'return' or 'throw' if they are missing. if (!method && methodName !== "next") { return undefined; } - var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* Optional */)) - ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */) + var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* SymbolFlags.Optional */)) + ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* TypeFacts.NEUndefinedOrNull */) : undefined; if (isTypeAny(methodType)) { // `return()` and `throw()` don't provide a *next* type. return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext; } // Both async and non-async iterators *must* have a `next` method. - var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : ts.emptyArray; + var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : ts.emptyArray; if (methodSignatures.length === 0) { if (errorNode) { var diagnostic = methodName === "next" ? resolver.mustHaveANextMethodDiagnostic : resolver.mustBeAMethodDiagnostic; - error(errorNode, diagnostic, methodName); + if (errorOutputContainer) { + (_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName)); + } + else { + error(errorNode, diagnostic, methodName); + } } - return methodName === "next" ? anyIterationTypes : undefined; + return methodName === "next" ? noIterationTypes : undefined; } // If the method signature comes exclusively from the global iterator or generator type, // create iteration types from its type arguments like `getIterationTypesOfIteratorFast` @@ -84266,8 +84645,8 @@ var ts; if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) { var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false); var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false); - var isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get(methodName)) === methodType.symbol; - var isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) === null || _c === void 0 ? void 0 : _c.members) === null || _d === void 0 ? void 0 : _d.get(methodName)) === methodType.symbol; + var isGeneratorMethod = ((_c = (_b = globalGeneratorType.symbol) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.get(methodName)) === methodType.symbol; + var isIteratorMethod = !isGeneratorMethod && ((_e = (_d = globalIteratorType.symbol) === null || _d === void 0 ? void 0 : _d.members) === null || _e === void 0 ? void 0 : _e.get(methodName)) === methodType.symbol; if (isGeneratorMethod || isIteratorMethod) { var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType; var mapper = methodType.mapper; @@ -84307,7 +84686,13 @@ var ts; var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType); if (iterationTypes === noIterationTypes) { if (errorNode) { - error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + if (errorOutputContainer) { + (_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName)); + } + else { + error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + } } yieldType = anyType; returnTypes = ts.append(returnTypes, anyType); @@ -84328,13 +84713,13 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterator` instead. */ - function getIterationTypesOfIteratorSlow(type, resolver, errorNode) { + function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var iterationTypes = combineIterationTypes([ - getIterationTypesOfMethod(type, resolver, "next", errorNode), - getIterationTypesOfMethod(type, resolver, "return", errorNode), - getIterationTypesOfMethod(type, resolver, "throw", errorNode), + getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer), ]); - return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); } /** * Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like, @@ -84352,10 +84737,10 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + var use = isAsyncGenerator ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) || - getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined); + getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined); } function checkBreakOrContinueStatement(node) { // Grammar checking @@ -84364,15 +84749,20 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { - var isGenerator = !!(functionFlags & 1 /* Generator */); - var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : - isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : - returnType; + var isGenerator = !!(functionFlags & 1 /* FunctionFlags.Generator */); + var isAsync = !!(functionFlags & 2 /* FunctionFlags.Async */); + if (isGenerator) { + var returnIterationType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, isAsync); + if (!returnIterationType) { + return errorType; + } + return isAsync ? getAwaitedTypeNoAlias(unwrapAwaitedType(returnIterationType)) : returnIterationType; + } + return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* TypeFlags.Void */ | 3 /* TypeFlags.AnyOrUnknown */); } function checkReturnStatement(node) { var _a; @@ -84392,21 +84782,21 @@ var ts; var signature = getSignatureFromDeclaration(container); var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(container); - if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* TypeFlags.Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (container.kind === 173 /* SetAccessor */) { + if (container.kind === 173 /* SyntaxKind.SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (getReturnTypeFromAnnotation(container)) { var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; - var unwrappedExprType = functionFlags & 2 /* Async */ + var unwrappedExprType = functionFlags & 2 /* FunctionFlags.Async */ ? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; if (unwrappedReturnType) { @@ -84417,7 +84807,7 @@ var ts; } } } - else if (container.kind !== 171 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { + else if (container.kind !== 171 /* SyntaxKind.Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -84425,7 +84815,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 32768 /* AwaitContext */) { + if (node.flags & 32768 /* NodeFlags.AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -84446,7 +84836,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 290 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -84455,7 +84845,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause)); } ts.forEach(clause.statements, checkSourceElement); @@ -84492,7 +84882,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 250 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 250 /* SyntaxKind.LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -84524,8 +84914,8 @@ var ts; var declaration = catchClause.variableDeclaration; var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); if (typeNode) { - var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */); - if (type && !(type.flags & 3 /* AnyOrUnknown */)) { + var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */); + if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) { grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } @@ -84537,7 +84927,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -84557,8 +84947,8 @@ var ts; } for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) { - checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); + if (!(isStaticIndex && prop.flags & 4194304 /* SymbolFlags.Prototype */)) { + checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); } } var typeDeclaration = symbol.valueDeclaration; @@ -84587,10 +84977,11 @@ var ts; return; } var indexInfos = getApplicableIndexInfos(type, propNameType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ || - name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; - var _loop_29 = function (info) { + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; + var propDeclaration = declaration && declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || + name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined; + var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var _loop_30 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and @@ -84598,20 +84989,24 @@ var ts; var errorNode = localPropDeclaration || localIndexDeclaration || (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined); if (errorNode && !isTypeAssignableTo(propType, info.type)) { - error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + if (propDeclaration && errorNode !== propDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop))); + } + diagnostics.add(diagnostic); } }; for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) { var info = indexInfos_9[_i]; - _loop_29(info); + _loop_30(info); } } function checkIndexConstraintForIndexSignature(type, checkInfo) { var declaration = checkInfo.declaration; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; - var _loop_30 = function (info) { + var _loop_31 = function (info) { if (info === checkInfo) return "continue"; var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; @@ -84626,7 +85021,7 @@ var ts; }; for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) { var info = indexInfos_10[_i]; - _loop_30(info); + _loop_31(info); } } function checkTypeNameIsReserved(name, message) { @@ -84650,7 +85045,7 @@ var ts; * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name) { - if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" + if (languageVersion >= 1 /* ScriptTarget.ES5 */ && name.escapedText === "Object" && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) { error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } @@ -84729,9 +85124,9 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 178 /* TypeReference */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */) { var type = getTypeFromTypeReference(node); - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { if (type.symbol === getSymbolOfNode(typeParameters[i])) { error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters); @@ -84819,7 +85214,7 @@ var ts; if (firstDecorator && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { grammarErrorOnNode(firstDecorator, ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) { + if (!node.name && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -84840,15 +85235,15 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */); } // check both @extends and extends if both are specified. var extendsNode = ts.getClassExtendsHeritageElement(node); @@ -84880,18 +85275,18 @@ var ts; // Report static side error only when instance type is assignable checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); } - if (baseConstructorType.flags & 8650752 /* TypeVariable */) { + if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) { if (!isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { - var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); + if (constructSignatures.some(function (signature) { return signature.flags & 4 /* SignatureFlags.Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* SymbolFlags.Class */) && !(baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); @@ -84926,7 +85321,7 @@ var ts; var t = getReducedType(getTypeFromTypeNode(typeRefNode)); if (!isErrorType(t)) { if (isValidBaseType(t)) { - var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? + var genericDiag = t.symbol && t.symbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : ts.Diagnostics.Class_0_incorrectly_implements_interface_1; var baseWithThis = getTypeWithThisArgument(t, type.thisType); @@ -84946,7 +85341,7 @@ var ts; var baseTypes = baseTypeNode && getBaseTypes(type); var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined; var baseStaticType = getBaseConstructorTypeOfClass(type); - var _loop_31 = function (member) { + var _loop_32 = function (member) { if (ts.hasAmbientModifier(member)) { return "continue"; } @@ -84963,7 +85358,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_31(member); + _loop_32(member); } } /** @@ -84976,7 +85371,7 @@ var ts; && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); if (!declaredProp) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined); } @@ -84990,7 +85385,7 @@ var ts; */ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) { var isJs = ts.isInJSFile(node); - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { var memberEscapedName = ts.escapeLeadingUnderscores(memberName); var thisType = memberIsStatic ? staticType : typeWithThis; @@ -85009,12 +85404,12 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier); if (memberHasOverrideModifier) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } if (!baseHasAbstract) { if (errorNode) { @@ -85027,13 +85422,13 @@ var ts; ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; error(errorNode, diag, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } else if (memberHasAbstractModifier && baseHasAbstract) { if (errorNode) { error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } } } @@ -85044,14 +85439,14 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_32 = function (member) { + var _loop_33 = function (member) { if (ts.isStatic(member)) { return "continue"; } @@ -85070,7 +85465,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_32(member); + _loop_33(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -85078,10 +85473,10 @@ var ts; } } function checkBaseTypeAccessibility(type, node) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) { var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -85097,7 +85492,7 @@ var ts; */ function getMemberOverrideModifierStatus(node, member) { if (!member.name) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -85109,7 +85504,7 @@ var ts; var baseStaticType = getBaseConstructorTypeOfClass(type); var memberHasOverrideModifier = member.parent ? ts.hasOverrideModifier(member) - : ts.hasSyntacticModifier(member, 16384 /* Override */); + : ts.hasSyntacticModifier(member, 16384 /* ModifierFlags.Override */); var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member), /* memberIsParameterProperty */ false, memberName); @@ -85117,11 +85512,11 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return ts.getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; + return ts.getCheckFlags(s) & 1 /* CheckFlags.Instantiated */ ? s.target : s; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 257 /* ClassDeclaration */ || d.kind === 258 /* InterfaceDeclaration */; + return d.kind === 257 /* SyntaxKind.ClassDeclaration */ || d.kind === 258 /* SyntaxKind.InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -85141,9 +85536,9 @@ var ts; var _a, _b, _c, _d; // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - var _loop_33 = function (baseProperty) { + var _loop_34 = function (baseProperty) { var base = getTargetSymbol(baseProperty); - if (base.flags & 4194304 /* Prototype */) { + if (base.flags & 4194304 /* SymbolFlags.Prototype */) { return "continue"; } var baseSymbol = getPropertyOfObjectType(type, base.escapedName); @@ -85162,7 +85557,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* ModifierFlags.Abstract */))) { // Searches other base types for a declaration that would satisfy the inherited abstract member. // (The class may have more than one base type via declaration merging with an interface with the // same name.) @@ -85176,7 +85571,7 @@ var ts; return "continue-basePropertyCheck"; } } - if (derivedClassDecl.kind === 226 /* ClassExpression */) { + if (derivedClassDecl.kind === 226 /* SyntaxKind.ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -85187,23 +85582,23 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 8 /* ModifierFlags.Private */ || derivedDeclarationFlags & 8 /* ModifierFlags.Private */) { return "continue"; } var errorMessage = void 0; - var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; - var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + var basePropertyFlags = base.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor - if ((ts.getCheckFlags(base) & 6 /* Synthetic */ + if ((ts.getCheckFlags(base) & 6 /* CheckFlags.Synthetic */ ? (_a = base.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); }) : (_b = base.declarations) === null || _b === void 0 ? void 0 : _b.every(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); })) - || ts.getCheckFlags(base) & 262144 /* Mapped */ + || ts.getCheckFlags(base) & 262144 /* CheckFlags.Mapped */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { return "continue"; } - var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */; - var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */; + var overriddenInstanceProperty = basePropertyFlags !== 4 /* SymbolFlags.Property */ && derivedPropertyFlags === 4 /* SymbolFlags.Property */; + var overriddenInstanceAccessor = basePropertyFlags === 4 /* SymbolFlags.Property */ && derivedPropertyFlags !== 4 /* SymbolFlags.Property */; if (overriddenInstanceProperty || overriddenInstanceAccessor) { var errorMessage_1 = overriddenInstanceProperty ? ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property : @@ -85211,12 +85606,12 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !d.initializer; }); if (uninitialized - && !(derived.flags & 33554432 /* Transient */) - && !(baseDeclarationFlags & 128 /* Abstract */) - && !(derivedDeclarationFlags & 128 /* Abstract */) - && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) { + && !(derived.flags & 33554432 /* SymbolFlags.Transient */) + && !(baseDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !(derivedDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* NodeFlags.Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -85232,15 +85627,15 @@ var ts; return "continue"; } else if (isPrototypeProperty(base)) { - if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* SymbolFlags.Property */) { return "continue"; } else { - ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + ts.Debug.assert(!!(derived.flags & 98304 /* SymbolFlags.Accessor */)); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } - else if (base.flags & 98304 /* Accessor */) { + else if (base.flags & 98304 /* SymbolFlags.Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } else { @@ -85251,14 +85646,14 @@ var ts; }; basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; - var state_10 = _loop_33(baseProperty); + var state_10 = _loop_34(baseProperty); switch (state_10) { case "continue-basePropertyCheck": continue basePropertyCheck; } } } function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) { - return baseDeclarationFlags & 128 /* Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer) + return baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer) || ts.isInterfaceDeclaration(declaration.parent); } function getNonInheritedProperties(type, baseTypes, properties) { @@ -85317,20 +85712,20 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) { continue; } if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || containsUndefinedType(type))) { + if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || containsUndefinedType(type))) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -85340,7 +85735,7 @@ var ts; } } function isPropertyWithoutInitializer(node) { - return node.kind === 167 /* PropertyDeclaration */ && + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; @@ -85383,7 +85778,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -85416,7 +85811,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 138 /* IntrinsicKeyword */) { + if (node.type.kind === 138 /* SyntaxKind.IntrinsicKeyword */) { if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); } @@ -85428,8 +85823,8 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { - nodeLinks.flags |= 16384 /* EnumValuesComputed */; + if (!(nodeLinks.flags & 16384 /* NodeCheckFlags.EnumValuesComputed */)) { + nodeLinks.flags |= 16384 /* NodeCheckFlags.EnumValuesComputed */; var autoValue = 0; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -85454,7 +85849,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -85471,7 +85866,7 @@ var ts; var enumKind = getEnumKind(getSymbolOfNode(member.parent)); var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; - var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); + var value = enumKind === 1 /* EnumKind.Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { if (isConstEnum && typeof value === "number" && !isFinite(value)) { error(initializer, isNaN(value) ? @@ -85479,20 +85874,20 @@ var ts; ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); } } - else if (enumKind === 1 /* Literal */) { + else if (enumKind === 1 /* EnumKind.Literal */) { error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members); return 0; } else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 16777216 /* Ambient */) { + else if (member.parent.flags & 16777216 /* NodeFlags.Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { // Only here do we need to check that the initializer is assignable to the enum type. var source = checkExpression(initializer); - if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) { + if (!isTypeAssignableToKind(source, 296 /* TypeFlags.NumberLike */)) { error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); } else { @@ -85502,60 +85897,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 39 /* PlusToken */: return value_2; - case 40 /* MinusToken */: return -value_2; - case 54 /* TildeToken */: return ~value_2; + case 39 /* SyntaxKind.PlusToken */: return value_2; + case 40 /* SyntaxKind.MinusToken */: return -value_2; + case 54 /* SyntaxKind.TildeToken */: return ~value_2; } } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 51 /* BarToken */: return left | right; - case 50 /* AmpersandToken */: return left & right; - case 48 /* GreaterThanGreaterThanToken */: return left >> right; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 47 /* LessThanLessThanToken */: return left << right; - case 52 /* CaretToken */: return left ^ right; - case 41 /* AsteriskToken */: return left * right; - case 43 /* SlashToken */: return left / right; - case 39 /* PlusToken */: return left + right; - case 40 /* MinusToken */: return left - right; - case 44 /* PercentToken */: return left % right; - case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); - } - } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { + case 51 /* SyntaxKind.BarToken */: return left | right; + case 50 /* SyntaxKind.AmpersandToken */: return left & right; + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return left >> right; + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* SyntaxKind.LessThanLessThanToken */: return left << right; + case 52 /* SyntaxKind.CaretToken */: return left ^ right; + case 41 /* SyntaxKind.AsteriskToken */: return left * right; + case 43 /* SyntaxKind.SlashToken */: return left / right; + case 39 /* SyntaxKind.PlusToken */: return left + right; + case 40 /* SyntaxKind.MinusToken */: return left - right; + case 44 /* SyntaxKind.PercentToken */: return left % right; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { return left + right; } break; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return expr.text; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return evaluate(expr.expression); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var identifier = expr; if (ts.isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (isConstantMemberAccess(expr)) { var type = getTypeOfExpression(expr.expression); - if (type.symbol && type.symbol.flags & 384 /* Enum */) { + if (type.symbol && type.symbol.flags & 384 /* SymbolFlags.Enum */) { var name = void 0; - if (expr.kind === 206 /* PropertyAccessExpression */) { + if (expr.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { name = expr.name.escapedText; } else { @@ -85591,9 +85986,9 @@ var ts; if (type === errorType) { return false; } - return node.kind === 79 /* Identifier */ || - node.kind === 206 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 207 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 207 /* SyntaxKind.ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -85627,7 +86022,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 260 /* EnumDeclaration */) { + if (declaration.kind !== 260 /* SyntaxKind.EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -85656,9 +86051,9 @@ var ts; if (declarations) { for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { var declaration = declarations_9[_i]; - if ((declaration.kind === 257 /* ClassDeclaration */ || - (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 16777216 /* Ambient */)) { + if ((declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || + (declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { return declaration; } } @@ -85689,7 +86084,7 @@ var ts; function checkModuleDeclarationDiagnostics() { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 16777216 /* Ambient */; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -85702,7 +86097,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* SyntaxKind.StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -85712,7 +86107,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !inAmbientContext && symbol.declarations && symbol.declarations.length > 1 @@ -85728,10 +86123,10 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* SyntaxKind.ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* NodeCheckFlags.LexicalModuleMergesWithClass */; } } if (isAmbientExternalModule) { @@ -85741,7 +86136,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Transient */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* SymbolFlags.Transient */); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -85773,23 +86168,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -85800,12 +86195,12 @@ var ts; break; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 256 /* FunctionDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -85815,7 +86210,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Transient */); + var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -85826,20 +86221,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } @@ -85853,9 +86248,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 272 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -85898,12 +86293,12 @@ var ts; // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). symbol = getMergedSymbol(symbol.exportSymbol || symbol); // A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within - if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) { + if (ts.isInJSFile(node) && !(target.flags & 111551 /* SymbolFlags.Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) { var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name : ts.isNamedDeclaration(node) ? node.name : node; - ts.Debug.assert(node.kind !== 274 /* NamespaceExport */); - if (node.kind === 275 /* ExportSpecifier */) { + ts.Debug.assert(node.kind !== 274 /* SyntaxKind.NamespaceExport */); + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */) { var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files); var alreadyExportedSymbol = (_b = (_a = ts.getSourceFileOfNode(node).symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.get((node.propertyName || node.name).escapedText); if (alreadyExportedSymbol === target) { @@ -85914,47 +86309,47 @@ var ts; } } else { - ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */); + ts.Debug.assert(node.kind !== 254 /* SyntaxKind.VariableDeclaration */); var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)); var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "..."; var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName); - error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"" + moduleSpecifier + "\")." + importedIdentifier); + error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"".concat(moduleSpecifier, "\").").concat(importedIdentifier)); } return; } - var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | - (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | - (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) | + (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) | + (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 275 /* ExportSpecifier */ ? + var message = node.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } if (compilerOptions.isolatedModules && !ts.isTypeOnlyImportOrExportDeclaration(node) - && !(node.flags & 16777216 /* Ambient */)) { + && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol); - var isType = !(target.flags & 111551 /* Value */); + var isType = !(target.flags & 111551 /* SymbolFlags.Value */); if (isType || typeOnlyAlias) { switch (node.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: { + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { if (compilerOptions.preserveValueImports) { ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name"); var message = isType ? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled; - var name = ts.idText(node.kind === 270 /* ImportSpecifier */ ? node.propertyName || node.name : node.name); + var name = ts.idText(node.kind === 270 /* SyntaxKind.ImportSpecifier */ ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); } - if (isType && node.kind === 265 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* ModifierFlags.Export */)) { error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided); } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // Don't allow re-exporting an export that will be elided when `--isolatedModules` is set. // The exception is that `import type { A } from './a'; export { A }` is allowed // because single-file analysis can determine that the export should be dropped. @@ -85979,15 +86374,15 @@ var ts; } } function isDeprecatedAliasedSymbol(symbol) { - return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } function checkDeprecatedAliasedSymbol(symbol, location) { - if (!(symbol.flags & 2097152 /* Alias */)) + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) return symbol; var targetSymbol = resolveAlias(symbol); if (targetSymbol === unknownSymbol) return targetSymbol; - while (symbol.flags & 2097152 /* Alias */) { + while (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = getImmediateAliasedSymbol(symbol); if (target) { if (target === targetSymbol) @@ -86013,11 +86408,11 @@ var ts; function checkImportBinding(node) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 270 /* ImportSpecifier */ && + if (node.kind === 270 /* SyntaxKind.ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && ts.getESModuleInterop(compilerOptions) && moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } function checkAssertClause(declaration) { @@ -86063,11 +86458,11 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { @@ -86089,20 +86484,20 @@ var ts; checkGrammarDecoratorsAndModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 277 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = ts.getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 788968 /* Type */) { + if (target.flags & 788968 /* SymbolFlags.Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -86111,7 +86506,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -86126,8 +86521,8 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } - if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { - checkExternalEmitHelpers(node, 4194304 /* CreateBinding */); + if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) { + checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */); } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -86135,10 +86530,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 16777216 /* Ambient */; - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && + !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */; + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -86158,12 +86553,12 @@ var ts; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop if (ts.getESModuleInterop(compilerOptions)) { - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { // export * from "foo" - checkExternalEmitHelpers(node, 32768 /* ExportStar */); + checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */); } } } @@ -86173,7 +86568,7 @@ var ts; function checkGrammarExportDeclaration(node) { var _a; if (node.isTypeOnly) { - if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* NamedExports */) { + if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* SyntaxKind.NamedExports */) { return checkGrammarNamedImportsOrExports(node.exportClause); } else { @@ -86183,7 +86578,7 @@ var ts; return false; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 305 /* SourceFile */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 261 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 305 /* SyntaxKind.SourceFile */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -86231,15 +86626,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { - markExportAsReferenced(node); - var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); - if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) { + markExportAsReferenced(node); + } + var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { checkExpressionCached(node.propertyName || node.name); } } @@ -86249,7 +86646,7 @@ var ts; moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.idText(node.propertyName || node.name) === "default") { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } } @@ -86261,8 +86658,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -86279,14 +86676,14 @@ var ts; if (typeAnnotationNode) { checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression); } - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { var id = node.expression; - var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + var sym = resolveEntityName(id, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { markAliasReferenced(sym, id); // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) - var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // However if it is a value, we need to check it's being used correctly checkExpressionCached(node.expression); } @@ -86302,10 +86699,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 16777216 /* NodeFlags.Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -86340,11 +86737,11 @@ var ts; } // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (flags & (1920 /* Namespace */ | 384 /* Enum */)) { + if (flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) { return; } var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration))); - if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + if (flags & 524288 /* SymbolFlags.TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) return; @@ -86394,181 +86791,181 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 237 /* FirstStatement */ && kind <= 253 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 237 /* SyntaxKind.FirstStatement */ && kind <= 253 /* SyntaxKind.LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return checkTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return checkParameter(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return checkPropertyDeclaration(node); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checkPropertySignature(node); - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return checkSignatureDeclaration(node); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return checkMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return checkClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return checkConstructorDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return checkAccessorDeclaration(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return checkTypeReferenceNode(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return checkTypePredicate(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return checkTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return checkTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return checkArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return checkTupleType(node); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return checkUnionOrIntersectionType(node); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 186 /* RestType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: return checkSourceElement(node.type); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return checkThisType(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return checkTypeOperator(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return checkConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return checkInferType(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return checkTemplateLiteralType(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return checkImportType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return checkNamedTupleMember(node); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return checkJSDocTypeTag(node); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return checkJSDocLinkLikeTag(node); - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return checkJSDocParameterTag(node); - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 322 /* JSDocTypeLiteral */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return checkSourceElement(node.type); - case 333 /* JSDocPublicTag */: - case 335 /* JSDocProtectedTag */: - case 334 /* JSDocPrivateTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: return checkJSDocAccessibilityModifiers(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return checkIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return checkMappedType(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return checkFunctionDeclaration(node); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return checkBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return checkVariableStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return checkExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return checkIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return checkDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return checkWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return checkForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return checkForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkForOfStatement(node); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return checkBreakOrContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return checkReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return checkSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return checkThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return checkTryStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checkVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return checkBindingElement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return checkClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return checkEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return checkModuleDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return checkImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return checkExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return checkExportAssignment(node); - case 236 /* EmptyStatement */: - case 253 /* DebuggerStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -86658,7 +87055,7 @@ var ts; function checkNodeDeferred(node) { var enclosingFile = ts.getSourceFileOfNode(node); var links = getNodeLinks(enclosingFile); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { links.deferredNodes || (links.deferredNodes = new ts.Set()); links.deferredNodes.add(node); } @@ -86670,41 +87067,41 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: - case 280 /* JsxOpeningElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: checkAccessorDeclaration(node); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: checkClassExpressionDeferred(node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: checkTypeParameterDeferred(node); break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: checkJsxElementDeferred(node); break; } @@ -86712,7 +87109,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); @@ -86724,9 +87121,9 @@ var ts; return false; } switch (kind) { - case 0 /* Local */: + case 0 /* UnusedKind.Local */: return !!compilerOptions.noUnusedLocals; - case 1 /* Parameter */: + case 1 /* UnusedKind.Parameter */: return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); @@ -86738,7 +87135,7 @@ var ts; // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node) { var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } @@ -86759,7 +87156,7 @@ var ts; // This relies on the results of other lazy diagnostics, so must be computed after them if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { diagnostics.add(diag); } }); @@ -86768,7 +87165,7 @@ var ts; checkPotentialUncheckedRenamedBindingElementsInTypes(); } }); - if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && + if (compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ && !node.isDeclarationFile && ts.isExternalModule(node)) { checkImportsForTypeOnlyConversion(node); @@ -86792,7 +87189,7 @@ var ts; ts.forEach(potentialReflectCollisions, checkReflectCollision); ts.clear(potentialReflectCollisions); } - links.flags |= 1 /* TypeChecked */; + links.flags |= 1 /* NodeCheckFlags.TypeChecked */; } } function getDiagnostics(sourceFile, ct) { @@ -86862,14 +87259,14 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 33554432 /* InWithStatement */) { + if (location.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } var symbols = ts.createSymbolTable(); var isStaticSymbol = false; populateSymbols(); - symbols.delete("this" /* This */); // Not a symbol, a keyword + symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -86877,17 +87274,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 261 /* ModuleDeclaration */: - copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 261 /* SyntaxKind.ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */); break; - case 260 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + case 260 /* SyntaxKind.EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -86895,17 +87292,17 @@ var ts; // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. // falls through - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStaticSymbol) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */); } break; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -86949,7 +87346,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* SyntaxKind.NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -86957,25 +87354,25 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 79 /* Identifier */ && + return name.kind === 79 /* SyntaxKind.Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 163 /* TypeParameter */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 163 /* SyntaxKind.TypeParameter */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return true; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.isTypeOnly; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -86983,16 +87380,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 178 /* TypeReference */; + return node.parent.kind === 178 /* SyntaxKind.TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 206 /* PropertyAccessExpression */) { + while (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 228 /* ExpressionWithTypeArguments */; + return node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -87020,13 +87417,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 161 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 161 /* SyntaxKind.QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 265 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 271 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -87037,12 +87434,12 @@ var ts; function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { - case 1 /* ExportsProperty */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return getSymbolOfNode(entityName.parent); - case 4 /* ThisProperty */: - case 2 /* ModuleExports */: - case 5 /* Property */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: + case 5 /* AssignmentDeclarationKind.Property */: return getSymbolOfNode(entityName.parent.parent); } } @@ -87052,7 +87449,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 200 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 200 /* SyntaxKind.ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -87062,7 +87459,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 206 /* PropertyAccessExpression */ && + name.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { @@ -87072,17 +87469,17 @@ var ts; } } } - if (name.parent.kind === 271 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, - /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 265 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 265 /* SyntaxKind.ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -87098,28 +87495,28 @@ var ts; name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { - var meaning = 0 /* None */; + var meaning = 0 /* SymbolFlags.None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 228 /* ExpressionWithTypeArguments */) { - meaning = 788968 /* Type */; + if (name.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { + meaning = 788968 /* SymbolFlags.Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { - meaning |= 111551 /* Value */; + meaning |= 111551 /* SymbolFlags.Value */; } } else { - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } - meaning |= 2097152 /* Alias */; + meaning |= 2097152 /* SymbolFlags.Alias */; var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined; if (entityNameSymbol) { return entityNameSymbol; } } - if (name.parent.kind === 340 /* JSDocParameterTag */) { + if (name.parent.kind === 340 /* SyntaxKind.JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 163 /* TypeParameter */ && name.parent.parent.kind === 344 /* JSDocTemplateTag */) { + if (name.parent.kind === 163 /* SyntaxKind.TypeParameter */ && name.parent.parent.kind === 344 /* SyntaxKind.JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -87130,8 +87527,8 @@ var ts; return undefined; } var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); - var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */; - if (name.kind === 79 /* Identifier */) { + var meaning = isJSDoc_1 ? 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */ : 111551 /* SymbolFlags.Value */; + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; @@ -87148,16 +87545,16 @@ var ts; else if (ts.isPrivateIdentifier(name)) { return getSymbolForPrivateIdentifierExpression(name); } - else if (name.kind === 206 /* PropertyAccessExpression */ || name.kind === 161 /* QualifiedName */) { + else if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 161 /* SyntaxKind.QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 206 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name, 0 /* Normal */); + if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* CheckMode.Normal */); } else { - checkQualifiedName(name, 0 /* Normal */); + checkQualifiedName(name, 0 /* CheckMode.Normal */); } if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { return resolveJSDocMemberName(name); @@ -87169,12 +87566,12 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 178 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 178 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } - if (name.parent.kind === 177 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + if (name.parent.kind === 177 /* SyntaxKind.TypePredicate */) { + return resolveEntityName(name, /*meaning*/ 1 /* SymbolFlags.FunctionScopedVariable */); } return undefined; } @@ -87189,7 +87586,7 @@ var ts; function resolveJSDocMemberName(name, ignoreErrors, container) { if (ts.isEntityName(name)) { // resolve static values first - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */; var symbol = resolveEntityName(name, meaning, ignoreErrors, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); if (!symbol && ts.isIdentifier(name) && container) { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); @@ -87201,18 +87598,18 @@ var ts; var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left, ignoreErrors, container); var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; if (left) { - var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var proto = left.flags & 111551 /* SymbolFlags.Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); return getPropertyOfType(t, right); } } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -87226,12 +87623,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 203 /* BindingElement */ && - grandParent.kind === 201 /* ObjectBindingPattern */ && + else if (parent.kind === 203 /* SyntaxKind.BindingElement */ && + grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -87240,7 +87637,7 @@ var ts; } } else if (ts.isMetaProperty(parent) && parent.name === node) { - if (parent.keywordToken === 103 /* NewKeyword */ && ts.idText(node) === "target") { + if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") { // `target` in `new.target` return checkNewTargetMetaProperty(parent).symbol; } @@ -87248,7 +87645,7 @@ var ts; // we have a fake expression type made for other reasons already, whose transient `meta` // member should more exactly be the kind of (declarationless) symbol we want. // (See #44364 and #45031 for relevant implementation PRs) - if (parent.keywordToken === 100 /* ImportKeyword */ && ts.idText(node) === "meta") { + if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") { return getGlobalImportMetaExpressionType().members.get("meta"); } // no other meta properties are valid syntax, thus no others should have symbols @@ -87256,15 +87653,15 @@ var ts; } } switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: if (!ts.isThisInTypeQuery(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } // falls through - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -87276,25 +87673,25 @@ var ts; return checkExpression(node).symbol; } // falls through - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkExpression(node).symbol; - case 134 /* ConstructorKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 171 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 171 /* SyntaxKind.Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // 1). import x = require("./mo/*gotToDefinitionHere*/d") // 2). External module name in an import declaration // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 266 /* ImportDeclaration */ || node.parent.kind === 272 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.parent.kind === 272 /* SyntaxKind.ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -87303,7 +87700,7 @@ var ts; return getSymbolOfNode(parent); } // falls through - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: // index access var objectType = ts.isElementAccessExpression(parent) ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined @@ -87311,19 +87708,19 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 88 /* DefaultKeyword */: - case 98 /* FunctionKeyword */: - case 38 /* EqualsGreaterThanToken */: - case 84 /* ClassKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 84 /* SyntaxKind.ClassKeyword */: return getSymbolOfNode(node.parent); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; - case 100 /* ImportKeyword */: - case 103 /* NewKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkExpression(node).symbol; default: return undefined; @@ -87333,14 +87730,14 @@ var ts; if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { var keyType_1 = getLiteralTypeFromPropertyName(node); var objectType = getTypeOfExpression(node.parent.expression); - var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType]; + var objectTypes = objectType.flags & 1048576 /* TypeFlags.Union */ ? objectType.types : [objectType]; return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); }); } return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 297 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */); } return undefined; } @@ -87349,17 +87746,17 @@ var ts; if (ts.isExportSpecifier(node)) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } else { - return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + return resolveEntityName(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } } function getTypeOfNode(node) { if (ts.isSourceFile(node) && !ts.isExternalModule(node)) { return errorType; } - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -87400,7 +87797,7 @@ var ts; return errorType; } if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType; + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType; } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolAtLocation(node); @@ -87421,23 +87818,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 205 /* ObjectLiteralExpression */ || expr.kind === 204 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 244 /* ForOfStatement */) { + if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 221 /* BinaryExpression */) { + if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 296 /* PropertyAssignment */) { + if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) { var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); @@ -87447,7 +87844,7 @@ var ts; var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -87480,14 +87877,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return getStringLiteralType(ts.idText(name)); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getStringLiteralType(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* TypeFlags.ESSymbolLike */) ? nameType : stringType; default: return ts.Debug.fail("Unsupported property name."); } @@ -87497,8 +87894,8 @@ var ts; function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = ts.createSymbolTable(getPropertiesOfType(type)); - var functionType = getSignaturesOfType(type, 0 /* Call */).length ? globalCallableFunctionType : - getSignaturesOfType(type, 1 /* Construct */).length ? globalNewableFunctionType : + var functionType = getSignaturesOfType(type, 0 /* SignatureKind.Call */).length ? globalCallableFunctionType : + getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length ? globalNewableFunctionType : undefined; if (functionType) { ts.forEach(getPropertiesOfType(functionType), function (p) { @@ -87517,10 +87914,10 @@ var ts; return roots ? ts.flatMap(roots, getRootSymbols) : [symbol]; } function getImmediateRootSymbols(symbol) { - if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { + if (ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */) { return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); }); } - else if (symbol.flags & 33554432 /* Transient */) { + else if (symbol.flags & 33554432 /* SymbolFlags.Transient */) { var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin; return leftSpread ? [leftSpread, rightSpread] : syntheticOrigin ? [syntheticOrigin] @@ -87567,13 +87964,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 111551 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* SymbolFlags.Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 111551 /* Value */); + return s && !!(s.flags & 111551 /* SymbolFlags.Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -87591,19 +87988,19 @@ var ts; // declaration if it contains an exported member with the same name. var symbol = getReferencedValueSymbol(node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node)); if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { + if (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) { // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (!prefixLocals && exportSymbol.flags & 944 /* ExportHasLocal */ && !(exportSymbol.flags & 3 /* Variable */)) { + if (!prefixLocals && exportSymbol.flags & 944 /* SymbolFlags.ExportHasLocal */ && !(exportSymbol.flags & 3 /* SymbolFlags.Variable */)) { return undefined; } symbol = exportSymbol; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SyntaxKind.SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -87626,7 +88023,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -87635,20 +88032,20 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* SyntaxKind.CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* SymbolFlags.BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } - else if (nodeLinks_1.flags & 262144 /* CapturedBlockScopedBinding */) { + else if (nodeLinks_1.flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */) { // binding is captured in the function // should be renamed if: // - binding is not top level - top level bindings never collide with anything @@ -87664,9 +88061,9 @@ var ts; // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything - var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; + var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 235 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 235 /* SyntaxKind.Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -87707,20 +88104,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: var symbol = getSymbolOfNode(node); return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 271 /* ExportAssignment */: - return node.expression && node.expression.kind === 79 /* Identifier */ ? + case 271 /* SyntaxKind.ExportAssignment */: + return node.expression && node.expression.kind === 79 /* SyntaxKind.Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } @@ -87728,7 +88125,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 305 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -87745,7 +88142,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 111551 /* Value */) && + return !!(target.flags & 111551 /* SymbolFlags.Value */) && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -87759,8 +88156,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217 - if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && - target.flags & 111551 /* Value */ && + if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ && + target.flags & 111551 /* SymbolFlags.Value */ && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; @@ -87798,13 +88195,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -87812,10 +88209,10 @@ var ts; return false; } var symbol = getSymbolOfNode(declaration); - if (!symbol || !(symbol.flags & 16 /* Function */)) { + if (!symbol || !(symbol.flags & 16 /* SymbolFlags.Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* SymbolFlags.Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -87838,19 +88235,19 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 299 /* EnumMember */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 299 /* SyntaxKind.EnumMember */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 299 /* EnumMember */) { + if (node.kind === 299 /* SyntaxKind.EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { + if (symbol && (symbol.flags & 8 /* SymbolFlags.EnumMember */)) { // inline property\index accesses only for const enums var member = symbol.valueDeclaration; if (ts.isEnumConst(member.parent)) { @@ -87860,7 +88257,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* TypeFlags.Object */) && getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { var _a, _b; @@ -87876,14 +88273,14 @@ var ts; // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var isTypeOnly = false; if (ts.isQualifiedName(typeName)) { - var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)); } - var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); - var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol; + var valueSymbol = resolveEntityName(typeName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(valueSymbol) : valueSymbol; isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration))); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (resolvedSymbol && resolvedSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) { @@ -87902,28 +88299,28 @@ var ts; if (isErrorType(type)) { return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 3 /* AnyOrUnknown */) { + else if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* TypeFlags.Void */ | 98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* TypeFlags.BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* TypeFlags.NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* TypeFlags.BigIntLike */)) { return ts.TypeReferenceSerializationKind.BigIntLikeType; } - else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 402653316 /* TypeFlags.StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* TypeFlags.ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -87939,37 +88336,37 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + var type = symbol && !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 131072 /* SymbolFlags.Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol) { - flags |= 1048576 /* AllowUniqueESSymbolType */; + flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } if (addUndefined) { type = getOptionalType(type); } - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); - return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function hasGlobalName(name) { return globals.has(ts.escapeLeadingUnderscores(name)); @@ -87988,7 +88385,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -88009,7 +88406,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* TypeFlags.EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* SymbolFlags.Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse(); if (enumResult) return enumResult; @@ -88117,18 +88514,18 @@ var ts; isLateBound: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); - return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */); + return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */); }, getJsxFactoryEntity: getJsxFactoryEntity, getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 173 /* SetAccessor */ ? 172 /* GetAccessor */ : 173 /* SetAccessor */; + var otherKind = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? 172 /* SyntaxKind.GetAccessor */ : 173 /* SyntaxKind.SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 173 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 172 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -88144,7 +88541,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 305 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 305 /* SyntaxKind.SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -88181,7 +88578,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 228 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* HeritageClause */; + return node.parent && node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -88189,12 +88586,19 @@ var ts; if (!fileToDirective) { return undefined; } + // computed property name should use node as value // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + var meaning; + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; + } + else { + meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; + if ((node.kind === 79 /* SyntaxKind.Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; + } } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -88241,7 +88645,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -88269,12 +88673,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 261 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 305 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -88345,7 +88749,7 @@ var ts; getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; - getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* Anonymous */, globalThisSymbol); + getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* ObjectFlags.Anonymous */, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -88407,28 +88811,28 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* NodeFlags.Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* ExternalEmitHelpers.FirstEmitHelper */; helper <= 4194304 /* ExternalEmitHelpers.LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* SymbolFlags.Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } - else if (helper & 524288 /* ClassPrivateFieldGet */) { + else if (helper & 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4); } } - else if (helper & 1048576 /* ClassPrivateFieldSet */) { + else if (helper & 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); } } - else if (helper & 1024 /* SpreadArray */) { + else if (helper & 1024 /* ExternalEmitHelpers.SpreadArray */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3); } @@ -88442,29 +88846,29 @@ var ts; } function getHelperName(helper) { switch (helper) { - case 1 /* Extends */: return "__extends"; - case 2 /* Assign */: return "__assign"; - case 4 /* Rest */: return "__rest"; - case 8 /* Decorate */: return "__decorate"; - case 16 /* Metadata */: return "__metadata"; - case 32 /* Param */: return "__param"; - case 64 /* Awaiter */: return "__awaiter"; - case 128 /* Generator */: return "__generator"; - case 256 /* Values */: return "__values"; - case 512 /* Read */: return "__read"; - case 1024 /* SpreadArray */: return "__spreadArray"; - case 2048 /* Await */: return "__await"; - case 4096 /* AsyncGenerator */: return "__asyncGenerator"; - case 8192 /* AsyncDelegator */: return "__asyncDelegator"; - case 16384 /* AsyncValues */: return "__asyncValues"; - case 32768 /* ExportStar */: return "__exportStar"; - case 65536 /* ImportStar */: return "__importStar"; - case 131072 /* ImportDefault */: return "__importDefault"; - case 262144 /* MakeTemplateObject */: return "__makeTemplateObject"; - case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; - case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; - case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn"; - case 4194304 /* CreateBinding */: return "__createBinding"; + case 1 /* ExternalEmitHelpers.Extends */: return "__extends"; + case 2 /* ExternalEmitHelpers.Assign */: return "__assign"; + case 4 /* ExternalEmitHelpers.Rest */: return "__rest"; + case 8 /* ExternalEmitHelpers.Decorate */: return "__decorate"; + case 16 /* ExternalEmitHelpers.Metadata */: return "__metadata"; + case 32 /* ExternalEmitHelpers.Param */: return "__param"; + case 64 /* ExternalEmitHelpers.Awaiter */: return "__awaiter"; + case 128 /* ExternalEmitHelpers.Generator */: return "__generator"; + case 256 /* ExternalEmitHelpers.Values */: return "__values"; + case 512 /* ExternalEmitHelpers.Read */: return "__read"; + case 1024 /* ExternalEmitHelpers.SpreadArray */: return "__spreadArray"; + case 2048 /* ExternalEmitHelpers.Await */: return "__await"; + case 4096 /* ExternalEmitHelpers.AsyncGenerator */: return "__asyncGenerator"; + case 8192 /* ExternalEmitHelpers.AsyncDelegator */: return "__asyncDelegator"; + case 16384 /* ExternalEmitHelpers.AsyncValues */: return "__asyncValues"; + case 32768 /* ExternalEmitHelpers.ExportStar */: return "__exportStar"; + case 65536 /* ExternalEmitHelpers.ImportStar */: return "__importStar"; + case 131072 /* ExternalEmitHelpers.ImportDefault */: return "__importDefault"; + case 262144 /* ExternalEmitHelpers.MakeTemplateObject */: return "__makeTemplateObject"; + case 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */: return "__classPrivateFieldGet"; + case 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */: return "__classPrivateFieldSet"; + case 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */: return "__classPrivateFieldIn"; + case 4194304 /* ExternalEmitHelpers.CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -88486,14 +88890,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 169 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) { + else if (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (ts.hasDecorators(accessors.firstAccessor) && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -88507,71 +88911,71 @@ var ts; return quickResult; } var lastStatic, lastDeclare, lastAsync, lastOverride; - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (ts.isDecorator(modifier)) continue; - if (modifier.kind !== 145 /* ReadonlyKeyword */) { - if (node.kind === 166 /* PropertySignature */ || node.kind === 168 /* MethodSignature */) { + if (modifier.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.kind === 166 /* SyntaxKind.PropertySignature */ || node.kind === 168 /* SyntaxKind.MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 176 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */ && (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } - if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 144 /* OutKeyword */) { - if (node.kind === 163 /* TypeParameter */) { + if (modifier.kind !== 101 /* SyntaxKind.InKeyword */ && modifier.kind !== 144 /* SyntaxKind.OutKeyword */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 85 /* ConstKeyword */: - if (node.kind !== 260 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); + case 85 /* SyntaxKind.ConstKeyword */: + if (node.kind !== 260 /* SyntaxKind.EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* SyntaxKind.ConstKeyword */)); } break; - case 159 /* OverrideKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; lastOverride = modifier; break; - case 123 /* PublicKeyword */: - case 122 /* ProtectedKeyword */: - case 121 /* PrivateKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 28 /* ModifierFlags.AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); } - else if (flags & 32 /* Static */) { + else if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } - else if (flags & 128 /* Abstract */) { - if (modifier.kind === 121 /* PrivateKeyword */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { + if (modifier.kind === 121 /* SyntaxKind.PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -88583,185 +88987,185 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 124 /* StaticKeyword */: - if (flags & 32 /* Static */) { + case 124 /* SyntaxKind.StaticKeyword */: + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 32 /* ModifierFlags.Static */; lastStatic = modifier; break; - case 145 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + case 145 /* SyntaxKind.ReadonlyKeyword */: + if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */ && node.kind !== 176 /* IndexSignature */ && node.kind !== 164 /* Parameter */) { + else if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */ && node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 164 /* SyntaxKind.Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; break; - case 93 /* ExportKeyword */: - if (flags & 1 /* Export */) { + case 93 /* SyntaxKind.ExportKeyword */: + if (flags & 1 /* ModifierFlags.Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; break; - case 88 /* DefaultKeyword */: - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* SyntaxKind.DefaultKeyword */: + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } - else if (!(flags & 1 /* Export */)) { + else if (!(flags & 1 /* ModifierFlags.Export */)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } - flags |= 512 /* Default */; + flags |= 512 /* ModifierFlags.Default */; break; - case 135 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + case 135 /* SyntaxKind.DeclareKeyword */: + if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) { + else if ((node.parent.flags & 16777216 /* NodeFlags.Ambient */) && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; lastDeclare = modifier; break; - case 126 /* AbstractKeyword */: - if (flags & 128 /* Abstract */) { + case 126 /* SyntaxKind.AbstractKeyword */: + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 257 /* ClassDeclaration */ && - node.kind !== 180 /* ConstructorType */) { - if (node.kind !== 169 /* MethodDeclaration */ && - node.kind !== 167 /* PropertyDeclaration */ && - node.kind !== 172 /* GetAccessor */ && - node.kind !== 173 /* SetAccessor */) { + if (node.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + node.kind !== 180 /* SyntaxKind.ConstructorType */) { + if (node.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + node.kind !== 172 /* SyntaxKind.GetAccessor */ && + node.kind !== 173 /* SyntaxKind.SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 257 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 256 /* Async */ && lastAsync) { + if (flags & 256 /* ModifierFlags.Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } } - if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 128 /* Abstract */; + flags |= 128 /* ModifierFlags.Abstract */; break; - case 131 /* AsyncKeyword */: - if (flags & 256 /* Async */) { + case 131 /* SyntaxKind.AsyncKeyword */: + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */ || node.parent.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 256 /* Async */; + flags |= 256 /* ModifierFlags.Async */; lastAsync = modifier; break; - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; - var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out"; - if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + var inOutFlag = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? 32768 /* ModifierFlags.In */ : 65536 /* ModifierFlags.Out */; + var inOutText = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? "in" : "out"; + if (node.kind !== 163 /* SyntaxKind.TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 32768 /* ModifierFlags.In */ && flags & 65536 /* ModifierFlags.Out */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; break; } } - if (node.kind === 171 /* Constructor */) { - if (flags & 32 /* Static */) { + if (node.kind === 171 /* SyntaxKind.Constructor */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; } - else if ((node.kind === 266 /* ImportDeclaration */ || node.kind === 265 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) && flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -88779,48 +89183,48 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 261 /* ModuleDeclaration */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return false; - case 170 /* ClassStaticBlockDeclaration */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 264 /* NamespaceExportDeclaration */: - case 179 /* FunctionType */: - case 276 /* MissingDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 276 /* SyntaxKind.MissingDeclaration */: return true; default: - if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return false; } switch (node.kind) { - case 256 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */); - case 257 /* ClassDeclaration */: - case 180 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 237 /* VariableStatement */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 131 /* SyntaxKind.AsyncKeyword */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 180 /* SyntaxKind.ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* SyntaxKind.AbstractKeyword */); + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 260 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); + case 260 /* SyntaxKind.EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* SyntaxKind.ConstKeyword */); default: ts.Debug.assertNever(node); } @@ -88837,10 +89241,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -88869,7 +89273,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 16777216 /* NodeFlags.Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -88894,7 +89298,7 @@ var ts; return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); }); } function checkGrammarForUseStrictSimpleParameterList(node) { - if (languageVersion >= 3 /* ES2016 */) { + if (languageVersion >= 3 /* ScriptTarget.ES2016 */) { var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements); if (useStrictDirective_1) { var nonSimpleParameters = getNonSimpleParameters(node.parameters); @@ -88929,7 +89333,7 @@ var ts; return false; } if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { - if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */])) { grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } @@ -88965,7 +89369,7 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } var type = getTypeFromTypeNode(parameter.type); - if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { + if (someType(type, function (t) { return !!(t.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead); } if (!everyType(type, isValidIndexKeyType)) { @@ -88994,7 +89398,7 @@ var ts; checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } function checkGrammarTaggedTemplateChain(node) { - if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + if (node.questionDotToken || node.flags & 32 /* NodeFlags.OptionalChain */) { return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); } return false; @@ -89022,7 +89426,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -89035,7 +89439,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -89051,14 +89455,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -89069,21 +89473,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 221 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 221 /* SyntaxKind.BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 169 /* MethodDeclaration */); - if (node.flags & 16777216 /* Ambient */) { + ts.Debug.assert(node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -89101,7 +89505,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -89112,23 +89516,23 @@ var ts; continue; } var name = prop.name; - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 297 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } - if (name.kind === 80 /* PrivateIdentifier */) { + if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (ts.canHaveModifiers(prop) && prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (ts.isModifier(mod) && (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 169 /* MethodDeclaration */)) { + if (ts.isModifier(mod) && (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */)) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -89149,24 +89553,24 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name.kind === 8 /* NumericLiteral */) { + if (name.kind === 8 /* SyntaxKind.NumericLiteral */) { checkGrammarNumericLiteral(name); } - currentKind = 4 /* PropertyAssignment */; + currentKind = 4 /* DeclarationMeaning.PropertyAssignment */; break; - case 169 /* MethodDeclaration */: - currentKind = 8 /* Method */; + case 169 /* SyntaxKind.MethodDeclaration */: + currentKind = 8 /* DeclarationMeaning.Method */; break; - case 172 /* GetAccessor */: - currentKind = 1 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + currentKind = 1 /* DeclarationMeaning.GetAccessor */; break; - case 173 /* SetAccessor */: - currentKind = 2 /* SetAccessor */; + case 173 /* SyntaxKind.SetAccessor */: + currentKind = 2 /* DeclarationMeaning.SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -89181,14 +89585,14 @@ var ts; seen.set(effectiveName, currentKind); } else { - if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) { + if ((currentKind & 8 /* DeclarationMeaning.Method */) && (existingKind & 8 /* DeclarationMeaning.Method */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) { + else if ((currentKind & 4 /* DeclarationMeaning.PropertyAssignment */) && (existingKind & 4 /* DeclarationMeaning.PropertyAssignment */)) { grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name)); } - else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { - if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* DeclarationMeaning.GetOrSetAccessor */) && (existingKind & 3 /* DeclarationMeaning.GetOrSetAccessor */)) { + if (existingKind !== 3 /* DeclarationMeaning.GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -89208,7 +89612,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 287 /* JsxSpreadAttribute */) { + if (attr.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -89218,7 +89622,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 288 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 288 /* SyntaxKind.JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -89253,8 +89657,8 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 244 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { + if (forInOrOfStatement.kind === 244 /* SyntaxKind.ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { if (!hasParseDiagnostics(sourceFile)) { @@ -89272,7 +89676,7 @@ var ts; case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: case ts.ModuleKind.System: - if (languageVersion >= 4 /* ES2017 */) { + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { break; } // fallthrough @@ -89287,8 +89691,8 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 171 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); + if (func && func.kind !== 171 /* SyntaxKind.Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -89299,12 +89703,12 @@ var ts; return false; } } - if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) && + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */) && ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") { grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async); return false; } - if (forInOrOfStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -89319,20 +89723,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -89342,22 +89746,22 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) { - if (languageVersion < 1 /* ES5 */) { + if (!(accessor.flags & 16777216 /* NodeFlags.Ambient */) && (accessor.parent.kind !== 182 /* SyntaxKind.TypeLiteral */) && (accessor.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */)) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - if (accessor.parent.kind === 182 /* TypeLiteral */ || accessor.parent.kind === 258 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 182 /* SyntaxKind.TypeLiteral */ || accessor.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -89365,11 +89769,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 173 /* SetAccessor */) { + if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -89391,17 +89795,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 154 /* UniqueKeyword */) { - if (node.type.kind !== 151 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SymbolKeyword */)); + if (node.operator === 154 /* SyntaxKind.UniqueKeyword */) { + if (node.type.kind !== 151 /* SyntaxKind.SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -89411,26 +89815,26 @@ var ts; } } switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 79 /* Identifier */) { + if (decl.name.kind !== 79 /* SyntaxKind.Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); } - if (!(decl.parent.flags & 2 /* Const */)) { + if (!(decl.parent.flags & 2 /* NodeFlags.Const */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (!ts.isStatic(parent) || !ts.hasEffectiveReadonlyModifier(parent)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 166 /* PropertySignature */: - if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { + case 166 /* SyntaxKind.PropertySignature */: + if (!ts.hasSyntacticModifier(parent, 64 /* ModifierFlags.Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -89438,9 +89842,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 145 /* ReadonlyKeyword */) { - if (node.type.kind !== 183 /* ArrayType */ && node.type.kind !== 184 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SymbolKeyword */)); + else if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.type.kind !== 183 /* SyntaxKind.ArrayType */ && node.type.kind !== 184 /* SyntaxKind.TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } } } @@ -89453,10 +89857,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 169 /* MethodDeclaration */) { - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) { + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -89474,7 +89878,7 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } // Technically, computed properties in ambient contexts is disallowed @@ -89482,17 +89886,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 169 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 182 /* TypeLiteral */) { + else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -89503,11 +89907,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 245 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 245 /* SyntaxKind.ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -89515,8 +89919,8 @@ var ts; return false; } break; - case 249 /* SwitchStatement */: - if (node.kind === 246 /* BreakStatement */ && !node.label) { + case 249 /* SyntaxKind.SwitchStatement */: + if (node.kind === 246 /* SyntaxKind.BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -89531,13 +89935,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -89561,18 +89965,18 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; } function isBigIntLiteralExpression(expr) { - return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 9 /* BigIntLiteral */; + return expr.kind === 9 /* SyntaxKind.BigIntLiteral */ || + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 9 /* SyntaxKind.BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) { - return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* TypeFlags.EnumLiteral */); } } function checkAmbientInitializer(node) { @@ -89580,7 +89984,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || + initializer.kind === 110 /* SyntaxKind.TrueKeyword */ || initializer.kind === 95 /* SyntaxKind.FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -89591,14 +89995,11 @@ var ts; else { return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } - if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) { - if (node.flags & 16777216 /* Ambient */) { + if (node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */ && node.parent.parent.kind !== 244 /* SyntaxKind.ForOfStatement */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -89610,7 +90011,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 237 /* SyntaxKind.VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* NodeFlags.Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -89619,7 +90020,7 @@ var ts; return grammarErrorOnNode(node.exclamationToken, message); } if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System && - !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* ModifierFlags.Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -89632,7 +90033,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -89649,8 +90050,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 79 /* Identifier */) { - if (name.originalKeywordKind === 119 /* LetKeyword */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { + if (name.originalKeywordKind === 119 /* SyntaxKind.LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -89677,15 +90078,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return false; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -89703,12 +90104,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -89766,7 +90167,7 @@ var ts; } } function checkGrammarProperty(node) { - if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) { + if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) { return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); } if (ts.isClassLike(node.parent)) { @@ -89776,11 +90177,11 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { return true; } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -89800,11 +90201,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { + node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -89826,14 +90227,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 259 /* TypeAliasDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 272 /* ExportDeclaration */ || - node.kind === 271 /* ExportAssignment */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */ | 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -89841,7 +90242,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 237 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 237 /* SyntaxKind.VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -89850,10 +90251,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -89864,7 +90265,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 235 /* Block */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 235 /* SyntaxKind.Block */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -89881,19 +90282,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.numericLiteralFlags & 32 /* Octal */) { + if (node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { var diagnosticMessage = void 0; - if (languageVersion >= 1 /* ES5 */) { + if (languageVersion >= 1 /* ScriptTarget.ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 196 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 196 /* SyntaxKind.LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 299 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 299 /* SyntaxKind.EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* SyntaxKind.MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -89906,7 +90307,7 @@ var ts; // We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "." // e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`. var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1; - var isScientific = node.numericLiteralFlags & 16 /* Scientific */; + var isScientific = node.numericLiteralFlags & 16 /* TokenFlags.Scientific */; // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway if (isFractional || isScientific) { @@ -89927,7 +90328,7 @@ var ts; var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); if (!literalType) { - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { return true; } @@ -89961,7 +90362,7 @@ var ts; if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } - if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* NamedImports */) { + if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* SyntaxKind.NamedImports */) { return checkGrammarNamedImportsOrExports(node.namedBindings); } return false; @@ -89969,7 +90370,7 @@ var ts; function checkGrammarNamedImportsOrExports(namedBindings) { return !!ts.forEach(namedBindings.elements, function (specifier) { if (specifier.isTypeOnly) { - return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* ImportSpecifier */ + return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* SyntaxKind.ImportSpecifier */ ? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement : ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); } @@ -90004,14 +90405,14 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { + if (sourceObjectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */) && unionTarget.flags & 1048576 /* TypeFlags.Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 524288 /* Object */) { + if (target.flags & 524288 /* TypeFlags.Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); - if (overlapObjFlags & 4 /* Reference */) { + if (overlapObjFlags & 4 /* ObjectFlags.Reference */) { return source.target === target.target; } - if (overlapObjFlags & 16 /* Anonymous */) { + if (overlapObjFlags & 16 /* ObjectFlags.Anonymous */) { return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; } } @@ -90020,35 +90421,35 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectFlags.ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } function findBestTypeForInvokable(source, unionTarget) { - var signatureKind = 0 /* Call */; + var signatureKind = 0 /* SignatureKind.Call */; var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 || - (signatureKind = 1 /* Construct */, getSignaturesOfType(source, signatureKind).length > 0); + (signatureKind = 1 /* SignatureKind.Construct */, getSignaturesOfType(source, signatureKind).length > 0); if (hasSignatures) { return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; }); } } function findMostOverlappyType(source, unionTarget) { var bestMatch; - if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(source.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var matchingCount = 0; for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) { var target = _a[_i]; - if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(target.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]); - if (overlap.flags & 4194304 /* Index */) { + if (overlap.flags & 4194304 /* TypeFlags.Index */) { // perfect overlap of keys return target; } - else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) { + else if (isUnitType(overlap) || overlap.flags & 1048576 /* TypeFlags.Union */) { // We only want to account for literal types otherwise. // If we have a union of index types, it seems likely that we // needed to elaborate between two generic mapped types anyway. - var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; + var len = overlap.flags & 1048576 /* TypeFlags.Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; if (len >= matchingCount) { bestMatch = target; matchingCount = len; @@ -90060,9 +90461,9 @@ var ts; return bestMatch; } function filterPrimitivesIfContainsNonPrimitive(type) { - if (maybeTypeOfKind(type, 67108864 /* NonPrimitive */)) { - var result = filterType(type, function (t) { return !(t.flags & 131068 /* Primitive */); }); - if (!(result.flags & 131072 /* Never */)) { + if (maybeTypeOfKind(type, 67108864 /* TypeFlags.NonPrimitive */)) { + var result = filterType(type, function (t) { return !(t.flags & 131068 /* TypeFlags.Primitive */); }); + if (!(result.flags & 131072 /* TypeFlags.Never */)) { return result; } } @@ -90070,7 +90471,7 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { - if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { + if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) { var match = getMatchingUnionConstituentForType(target, source); if (match) { return match; @@ -90092,14 +90493,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 256 /* FunctionDeclaration */ && declaration.kind !== 169 /* MethodDeclaration */) || + return (declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */ && declaration.kind !== 169 /* SyntaxKind.MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -90119,17 +90520,17 @@ var ts; })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { - case 0 /* Yield */: return "yieldType"; - case 1 /* Return */: return "returnType"; - case 2 /* Next */: return "nextType"; + case 0 /* IterationTypeKind.Yield */: return "yieldType"; + case 1 /* IterationTypeKind.Return */: return "returnType"; + case 2 /* IterationTypeKind.Next */: return "nextType"; } } function signatureHasRestParameter(s) { - return !!(s.flags & 1 /* HasRestParameter */); + return !!(s.flags & 1 /* SignatureFlags.HasRestParameter */); } ts.signatureHasRestParameter = signatureHasRestParameter; function signatureHasLiteralTypes(s) { - return !!(s.flags & 2 /* HasLiteralTypes */); + return !!(s.flags & 2 /* SignatureFlags.HasLiteralTypes */); } ts.signatureHasLiteralTypes = signatureHasLiteralTypes; })(ts || (ts = {})); @@ -90269,7 +90670,7 @@ var ts; var updated; context.startLexicalEnvironment(); if (nodes) { - context.setLexicalEnvironmentFlags(1 /* InParameters */, true); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, true); updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression @@ -90277,11 +90678,11 @@ var ts; // exists in a different lexical scope. To address this, we move any binding patterns and initializers // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list // when the emit target is greater than ES2015. - if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ && - ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (context.getLexicalEnvironmentFlags() & 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */ && + ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { updated = addDefaultValueAssignmentsIfNeeded(updated, context); } - context.setLexicalEnvironmentFlags(1 /* InParameters */, false); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, false); } context.suspendLexicalEnvironment(); return updated; @@ -90328,8 +90729,8 @@ var ts; function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { var factory = context.factory; context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ - factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */))); + factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */))); return factory.updateParameterDeclaration(parameter, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, /*initializer*/ undefined); } @@ -90375,446 +90776,446 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 160 /* LastToken */) || kind === 192 /* ThisType */) { + if ((kind > 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */) || kind === 192 /* SyntaxKind.ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: ts.Debug.type(node); return factory.updateParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: ts.Debug.type(node); return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: ts.Debug.type(node); return factory.updateMethodDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: ts.Debug.type(node); context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); return factory.updateClassStaticBlockDeclaration(node, visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: ts.Debug.type(node); return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: ts.Debug.type(node); return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: ts.Debug.type(node); return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: ts.Debug.type(node); return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: ts.Debug.type(node); - return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 295 /* ImportTypeAssertionContainer */: + return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: ts.Debug.type(node); - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 191 /* ParenthesizedType */: + return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); + case 191 /* SyntaxKind.ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: ts.Debug.type(node); return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: ts.Debug.type(node); return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 206 /* PropertyAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName)); } ts.Debug.type(node); return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); - case 207 /* ElementAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 208 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: ts.Debug.type(node); return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: ts.Debug.type(node); - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 211 /* TypeAssertionExpression */: + return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: ts.Debug.type(node); return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: ts.Debug.type(node); return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: ts.Debug.type(node); return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: ts.Debug.type(node); return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 230 /* NonNullExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 230 /* SyntaxKind.NonNullExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: ts.Debug.type(node); return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: ts.Debug.type(node); return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: ts.Debug.type(node); return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: ts.Debug.type(node); return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: ts.Debug.type(node); return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: ts.Debug.type(node); return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: ts.Debug.type(node); return factory.updateFunctionDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: ts.Debug.type(node); return factory.updateModuleDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: ts.Debug.type(node); return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: ts.Debug.type(node); return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode)); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: ts.Debug.type(node); return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: ts.Debug.type(node); return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: ts.Debug.type(node); return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: ts.Debug.type(node); return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.type(node); return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: ts.Debug.type(node); return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -91039,7 +91440,7 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - appendMappingCharCode(59 /* semicolon */); + appendMappingCharCode(59 /* CharacterCodes.semicolon */); lastGeneratedLine++; } while (lastGeneratedLine < pendingGeneratedLine); // Only need to set this once @@ -91049,7 +91450,7 @@ var ts; ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - appendMappingCharCode(44 /* comma */); + appendMappingCharCode(44 /* CharacterCodes.comma */); } } // 1. Relative generated character @@ -91192,14 +91593,14 @@ var ts; next: function () { while (!done && pos < mappings.length) { var ch = mappings.charCodeAt(pos); - if (ch === 59 /* semicolon */) { + if (ch === 59 /* CharacterCodes.semicolon */) { // new line generatedLine++; generatedCharacter = 0; pos++; continue; } - if (ch === 44 /* comma */) { + if (ch === 44 /* CharacterCodes.comma */) { // Next entry is on same line - no action needed pos++; continue; @@ -91276,8 +91677,8 @@ var ts; } function isSourceMappingSegmentEnd() { return (pos === mappings.length || - mappings.charCodeAt(pos) === 44 /* comma */ || - mappings.charCodeAt(pos) === 59 /* semicolon */); + mappings.charCodeAt(pos) === 44 /* CharacterCodes.comma */ || + mappings.charCodeAt(pos) === 59 /* CharacterCodes.semicolon */); } function base64VLQFormatDecode() { var moreDigits = true; @@ -91327,19 +91728,19 @@ var ts; } ts.isSourceMapping = isSourceMapping; function base64FormatEncode(value) { - return value >= 0 && value < 26 ? 65 /* A */ + value : - value >= 26 && value < 52 ? 97 /* a */ + value - 26 : - value >= 52 && value < 62 ? 48 /* _0 */ + value - 52 : - value === 62 ? 43 /* plus */ : - value === 63 ? 47 /* slash */ : - ts.Debug.fail(value + ": not a base64 value"); + return value >= 0 && value < 26 ? 65 /* CharacterCodes.A */ + value : + value >= 26 && value < 52 ? 97 /* CharacterCodes.a */ + value - 26 : + value >= 52 && value < 62 ? 48 /* CharacterCodes._0 */ + value - 52 : + value === 62 ? 43 /* CharacterCodes.plus */ : + value === 63 ? 47 /* CharacterCodes.slash */ : + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ ? ch - 65 /* A */ : - ch >= 97 /* a */ && ch <= 122 /* z */ ? ch - 97 /* a */ + 26 : - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ ? ch - 48 /* _0 */ + 52 : - ch === 43 /* plus */ ? 62 : - ch === 47 /* slash */ ? 63 : + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ ? ch - 65 /* CharacterCodes.A */ : + ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ? ch - 97 /* CharacterCodes.a */ + 26 : + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ ? ch - 48 /* CharacterCodes._0 */ + 52 : + ch === 43 /* CharacterCodes.plus */ ? 62 : + ch === 47 /* CharacterCodes.slash */ ? 63 : -1; } function isSourceMappedPosition(value) { @@ -91407,7 +91808,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -91500,12 +91901,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* InternalSymbolName.Default */; } function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -91556,7 +91957,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -91569,13 +91970,13 @@ var ts; hasImportDefault = true; } break; - case 265 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 277 /* ExternalModuleReference */) { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -91606,23 +92007,23 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 237 /* VariableStatement */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + case 237 /* SyntaxKind.VariableStatement */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames); } } break; - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default function() { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -91640,9 +92041,9 @@ var ts; } } break; - case 257 /* ClassDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default class { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -91723,7 +92124,7 @@ var ts; */ function isSimpleCopiableExpression(expression) { return ts.isStringLiteralLike(expression) || - expression.kind === 8 /* NumericLiteral */ || + expression.kind === 8 /* SyntaxKind.NumericLiteral */ || ts.isKeyword(expression.kind) || ts.isIdentifier(expression); } @@ -91738,27 +92139,27 @@ var ts; } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 64 /* FirstCompoundAssignment */ - && kind <= 78 /* LastCompoundAssignment */; + return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */ + && kind <= 78 /* SyntaxKind.LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 64 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 65 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 68 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 69 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 74 /* BarEqualsToken */: return 51 /* BarToken */; - case 78 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + case 64 /* SyntaxKind.PlusEqualsToken */: return 39 /* SyntaxKind.PlusToken */; + case 65 /* SyntaxKind.MinusEqualsToken */: return 40 /* SyntaxKind.MinusToken */; + case 66 /* SyntaxKind.AsteriskEqualsToken */: return 41 /* SyntaxKind.AsteriskToken */; + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return 42 /* SyntaxKind.AsteriskAsteriskToken */; + case 68 /* SyntaxKind.SlashEqualsToken */: return 43 /* SyntaxKind.SlashToken */; + case 69 /* SyntaxKind.PercentEqualsToken */: return 44 /* SyntaxKind.PercentToken */; + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: return 47 /* SyntaxKind.LessThanLessThanToken */; + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: return 48 /* SyntaxKind.GreaterThanGreaterThanToken */; + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; + case 73 /* SyntaxKind.AmpersandEqualsToken */: return 50 /* SyntaxKind.AmpersandToken */; + case 74 /* SyntaxKind.BarEqualsToken */: return 51 /* SyntaxKind.BarToken */; + case 78 /* SyntaxKind.CaretEqualsToken */: return 52 /* SyntaxKind.CaretToken */; + case 75 /* SyntaxKind.BarBarEqualsToken */: return 56 /* SyntaxKind.BarBarToken */; + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: return 55 /* SyntaxKind.AmpersandAmpersandToken */; + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return 60 /* SyntaxKind.QuestionQuestionToken */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -91820,7 +92221,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 167 /* PropertyDeclaration */ + return member.kind === 167 /* SyntaxKind.PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -91884,12 +92285,12 @@ var ts; */ function getAllDecoratorsOfClassElement(member, parent) { switch (member.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return getAllDecoratorsOfAccessors(member, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -92225,9 +92626,9 @@ var ts; var element = elements[i]; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); - if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */)) + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */ + && !(element.transformFlags & (32768 /* TransformFlags.ContainsRestOrSpread */ | 65536 /* TransformFlags.ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* TransformFlags.ContainsRestOrSpread */ | 65536 /* TransformFlags.ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -92268,14 +92669,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + if (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ && flattenContext.downlevelIteration) { // Read the elements of the iterable into an array value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) ? undefined : numElements), location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + else if (numElements !== 1 && (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ || numElements === 0) || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -92290,10 +92691,10 @@ var ts; var restContainingElements; for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (flattenContext.level >= 1 /* ObjectRest */) { + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -92496,7 +92897,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + var isLast = node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || node.kind === 17 /* SyntaxKind.TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); } // Newline normalization: @@ -92550,8 +92951,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -92571,14 +92972,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -92627,16 +93028,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 262 /* ModuleBlock */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 262 /* SyntaxKind.ModuleBlock */: + case 235 /* SyntaxKind.Block */: currentLexicalScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { break; } // Record these declarations provided that they have a name. @@ -92647,7 +93048,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 257 /* SyntaxKind.ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)); } break; } @@ -92666,7 +93067,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { return visitTypeScript(node); } return node; @@ -92686,10 +93087,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -92702,7 +93103,7 @@ var ts; // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes // We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`, // and will trigger debug failures when debug verbosity is turned up - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { // This node contains TypeScript, so we should visit its children. return ts.visitEachChild(node, visitor, context); } @@ -92710,13 +93111,13 @@ var ts; return node; } switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -92736,15 +93137,15 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 272 /* ExportDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 267 /* ImportClause */ || - (node.kind === 265 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 277 /* ExternalModuleReference */)) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ || + (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && + node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } - else if (node.transformFlags & 1 /* ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* Export */)) { + else if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return visitTypeScript(node); } return node; @@ -92764,27 +93165,27 @@ var ts; */ function classElementVisitorWorker(node, parent) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node, parent); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node, parent); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node, parent); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return ts.visitEachChild(node, visitor, context); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Index signatures are elided return; default: @@ -92796,17 +93197,17 @@ var ts; } function objectLiteralElementVisitorWorker(node, parent) { switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitor(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node, parent); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node, parent); @@ -92817,10 +93218,10 @@ var ts; function modifierVisitor(node) { if (ts.isDecorator(node)) return undefined; - if (ts.modifierToFlag(node.kind) & 116958 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 116958 /* ModifierFlags.TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* SyntaxKind.ExportKeyword */) { return undefined; } return node; @@ -92831,72 +93232,72 @@ var ts; * @param node The node to visit. */ function visitTypeScript(node) { - if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { // TypeScript ambient declarations are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 145 /* ReadonlyKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 185 /* OptionalType */: - case 186 /* RestType */: - case 182 /* TypeLiteral */: - case 177 /* TypePredicate */: - case 163 /* TypeParameter */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 133 /* BooleanKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 143 /* NeverKeyword */: - case 114 /* VoidKeyword */: - case 151 /* SymbolKeyword */: - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 181 /* TypeQuery */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 189 /* ConditionalType */: - case 191 /* ParenthesizedType */: - case 192 /* ThisType */: - case 193 /* TypeOperator */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 196 /* LiteralType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 177 /* SyntaxKind.TypePredicate */: + case 163 /* SyntaxKind.TypeParameter */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 181 /* SyntaxKind.TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 189 /* SyntaxKind.ConditionalType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 192 /* SyntaxKind.ThisType */: + case 193 /* SyntaxKind.TypeOperator */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 196 /* SyntaxKind.LiteralType */: // TypeScript type nodes are elided. // falls through - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // TypeScript index signatures are elided. return undefined; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return factory.createNotEmittedStatement(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -92906,7 +93307,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -92916,34 +93317,34 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors"); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -92953,40 +93354,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -93003,28 +93404,28 @@ var ts; return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement)); } function getClassFacts(node, staticProperties) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; if (ts.some(staticProperties)) - facts |= 1 /* HasStaticInitializedProperties */; + facts |= 1 /* ClassFacts.HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) - facts |= 64 /* IsDerivedClass */; + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */) + facts |= 64 /* ClassFacts.IsDerivedClass */; if (ts.classOrConstructorParameterIsDecorated(node)) - facts |= 2 /* HasConstructorDecorators */; + facts |= 2 /* ClassFacts.HasConstructorDecorators */; if (ts.childIsDecorated(node)) - facts |= 4 /* HasMemberDecorators */; + facts |= 4 /* ClassFacts.HasMemberDecorators */; if (isExportOfNamespace(node)) - facts |= 8 /* IsExportOfNamespace */; + facts |= 8 /* ClassFacts.IsExportOfNamespace */; else if (isDefaultExternalModuleExport(node)) - facts |= 32 /* IsDefaultExternalExport */; + facts |= 32 /* ClassFacts.IsDefaultExternalExport */; else if (isNamedExternalModuleExport(node)) - facts |= 16 /* IsNamedExternalExport */; - if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */)) - facts |= 128 /* UseImmediatelyInvokedFunctionExpression */; + facts |= 16 /* ClassFacts.IsNamedExternalExport */; + if (languageVersion <= 1 /* ScriptTarget.ES5 */ && (facts & 7 /* ClassFacts.MayNeedImmediatelyInvokedFunctionExpression */)) + facts |= 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.hasDecorators(node) @@ -93033,20 +93434,20 @@ var ts; || ts.some(node.members, hasTypeScriptClassSyntax); } function visitClassDeclaration(node) { - if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) { + if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement)); } var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); } - var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); + var name = node.name || (facts & 5 /* ClassFacts.NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); var allDecorators = ts.getAllDecoratorsOfClass(node); var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators); // we do not emit modifiers on the declaration if we are emitting an IIFE - var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */) + var modifiers = !(facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) : ts.elideNodes(factory, node.modifiers); // preserve positions, if available // ${modifiers} class ${name} ${heritageClauses} { @@ -93057,12 +93458,12 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. var emitFlags = ts.getEmitFlags(node); - if (facts & 1 /* HasStaticInitializedProperties */) { - emitFlags |= 32 /* NoTrailingSourceMap */; + if (facts & 1 /* ClassFacts.HasStaticInitializedProperties */) { + emitFlags |= 32 /* EmitFlags.NoTrailingSourceMap */; } ts.setEmitFlags(classStatement, emitFlags); var statements = [classStatement]; - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the // 'es2015' transformer can properly nest static initializers and decorators. The result // looks something like: @@ -93074,20 +93475,20 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); var localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(localName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment()); var iife = factory.createImmediatelyInvokedArrowFunction(statements); - ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); + ts.setEmitFlags(iife, 33554432 /* EmitFlags.TypeScriptClassWrapper */); var varStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), @@ -93103,21 +93504,21 @@ var ts; // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. - if (facts & 8 /* IsExportOfNamespace */) { + if (facts & 8 /* ClassFacts.IsExportOfNamespace */) { addExportMemberAssignment(statements, node); } - else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { - if (facts & 32 /* IsDefaultExternalExport */) { + else if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* ClassFacts.HasConstructorDecorators */) { + if (facts & 32 /* ClassFacts.IsDefaultExternalExport */) { statements.push(factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } - else if (facts & 16 /* IsNamedExternalExport */) { + else if (facts & 16 /* ClassFacts.IsNamedExternalExport */) { statements.push(factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -93188,11 +93589,11 @@ var ts; var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression); var helper = emitHelpers().createParamHelper(expression, parameterOffset); ts.setTextRange(helper, parameterDecorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); var decorator = factory.createDecorator(helper); ts.setSourceMapRange(decorator, parameterDecorator.expression); ts.setCommentRange(decorator, parameterDecorator.expression); - ts.setEmitFlags(decorator, 1536 /* NoComments */); + ts.setEmitFlags(decorator, 1536 /* EmitFlags.NoComments */); decorators.push(decorator); } return decorators; @@ -93230,15 +93631,15 @@ var ts; if (typeSerializer) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); properties = ts.append(properties, typeProperty); } if (shouldAddParamTypesMetadata(node)) { - var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container))); + var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container))); properties = ts.append(properties, paramTypeProperty); } if (shouldAddReturnTypeMetadata(node)) { - var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); properties = ts.append(properties, returnTypeProperty); } if (properties) { @@ -93256,10 +93657,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 167 /* PropertyDeclaration */; + return kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -93269,7 +93670,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -93280,12 +93681,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; } return false; @@ -93347,7 +93748,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 117 /* ImplementsKeyword */) { + if (node.token === 117 /* SyntaxKind.ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -93375,7 +93776,7 @@ var ts; return !ts.nodeIsMissing(node.body); } function visitPropertyDeclaration(node, parent) { - var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */); + var isAmbient = node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); if (isAmbient && !ts.hasDecorators(node)) { return undefined; } @@ -93383,7 +93784,7 @@ var ts; var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators); // Preserve a `declare x` property with decorators to be handled by the decorators transform if (isAmbient) { - return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, factory.createModifiersFromModifierFlags(2 /* Ambient */)), ts.visitNode(node.name, visitor, ts.isPropertyName), + return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, factory.createModifiersFromModifierFlags(2 /* ModifierFlags.Ambient */)), ts.visitNode(node.name, visitor, ts.isPropertyName), /*questionOrExclamationToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); @@ -93435,7 +93836,8 @@ var ts; statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); + var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start)); // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); @@ -93455,14 +93857,14 @@ var ts; } // TODO(rbuckton): Does this need to be parented? var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 48 /* EmitFlags.NoSourceMap */); // TODO(rbuckton): Does this need to be parented? var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(localName, 1536 /* NoComments */); + ts.setEmitFlags(localName, 1536 /* EmitFlags.NoComments */); return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1)))); } function visitMethodDeclaration(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitFunctionLikeDeclaration(node)) { @@ -93482,10 +93884,10 @@ var ts; * @param node The declaration node. */ function shouldEmitAccessorDeclaration(node) { - return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */)); + return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)); } function visitGetAccessor(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitAccessorDeclaration(node)) { @@ -93498,7 +93900,7 @@ var ts; /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([])); } function visitSetAccessor(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitAccessorDeclaration(node)) { @@ -93552,7 +93954,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -93572,7 +93974,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createNamespaceExportExpression); } else { @@ -93590,7 +93992,7 @@ var ts; return updated; } function visitParenthesizedExpression(node) { - var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */); + var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* OuterExpressionKinds.Assertions */); if (ts.isAssertionExpression(innerExpression)) { // Make sure we consider all nested cast expressions, e.g.: // (-A).x; @@ -93667,7 +94069,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. @@ -93675,7 +94077,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the enum. @@ -93683,7 +94085,7 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93749,7 +94151,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* SyntaxKind.StringLiteral */ ? innerAssignment : factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -93837,12 +94239,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 305 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 305 /* SyntaxKind.SourceFile */ ? 0 /* NodeFlags.None */ : 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 260 /* EnumDeclaration */) { + if (node.kind === 260 /* SyntaxKind.EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -93867,7 +94269,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.addEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.addEmitFlags(statement, 1024 /* EmitFlags.NoTrailingComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -93877,7 +94279,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = factory.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* EmitFlags.NoComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -93898,7 +94300,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. @@ -93906,7 +94308,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the namespace. @@ -93914,7 +94316,7 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93967,7 +94369,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 262 /* ModuleBlock */) { + if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -94014,13 +94416,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 262 /* ModuleBlock */) { - ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); + if (!node.body || node.body.kind !== 262 /* SyntaxKind.ModuleBlock */) { + ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* EmitFlags.NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -94043,8 +94445,8 @@ var ts; // Elide the declaration if the import clause was elided. var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause || - compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */ + compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ ? factory.updateImportDeclaration(node, /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) : undefined; @@ -94067,14 +94469,14 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 268 /* NamespaceImport */) { + if (node.kind === 268 /* SyntaxKind.NamespaceImport */) { // Elide a namespace import if it is not referenced. return shouldEmitAliasDeclaration(node) ? node : undefined; } else { // Elide named imports if all of its import specifiers are elided and settings allow. - var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; } @@ -94115,8 +94517,8 @@ var ts; return node; } // Elide the export declaration if all of its named exports are elided. - var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause ? factory.updateExportDeclaration(node, @@ -94175,7 +94577,7 @@ var ts; if (ts.isExternalModuleImportEqualsDeclaration(node)) { var isReferenced = shouldEmitAliasDeclaration(node); // If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'. - if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) { + if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */) { return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration( /*modifiers*/ undefined, /*importClause*/ undefined, node.moduleReference.expression, @@ -94187,7 +94589,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference); - ts.setEmitFlags(moduleReference, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -94208,7 +94610,7 @@ var ts; * @param node The node to test. */ function isExportOfNamespace(node) { - return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is exported from an external module. @@ -94216,7 +94618,7 @@ var ts; * @param node The node to test. */ function isExternalModuleExport(node) { - return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is a named export from an external module. @@ -94225,7 +94627,7 @@ var ts; */ function isNamedExternalModuleExport(node) { return isExternalModuleExport(node) - && !ts.hasSyntacticModifier(node, 512 /* Default */); + && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Gets a value indicating whether the node is the default export of an external module. @@ -94234,7 +94636,7 @@ var ts; */ function isDefaultExternalModuleExport(node) { return isExternalModuleExport(node) - && ts.hasSyntacticModifier(node, 512 /* Default */); + && ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } function addExportMemberAssignment(statements, node) { var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node)); @@ -94268,27 +94670,27 @@ var ts; return factory.getGeneratedNameForNode(node); } function enableSubstitutionForNonQualifiedEnumMembers() { - if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { - enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */) === 0) { + enabledSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } function enableSubstitutionForNamespaceExports() { - if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) { - enabledSubstitutions |= 2 /* NamespaceExports */; + if ((enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) === 0) { + enabledSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(79 /* Identifier */); - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(261 /* ModuleDeclaration */); + context.enableEmitNotification(261 /* SyntaxKind.ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 261 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 260 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 260 /* SyntaxKind.EnumDeclaration */; } /** * Hook for node emit. @@ -94303,11 +94705,11 @@ var ts; if (ts.isSourceFile(node)) { currentSourceFile = node; } - if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { - applicableSubstitutions |= 2 /* NamespaceExports */; + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && isTransformedModuleDeclaration(node)) { + applicableSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; } - if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { - applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; + if (enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { + applicableSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; @@ -94321,7 +94723,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -94330,7 +94732,7 @@ var ts; return node; } function substituteShorthandPropertyAssignment(node) { - if (enabledSubstitutions & 2 /* NamespaceExports */) { + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) { var name = node.name; var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { @@ -94347,11 +94749,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -94366,9 +94768,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 305 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 261 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 260 /* EnumDeclaration */); + if (container && container.kind !== 305 /* SyntaxKind.SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && container.kind === 261 /* SyntaxKind.ModuleDeclaration */) || + (applicableSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && container.kind === 260 /* SyntaxKind.EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -94394,7 +94796,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3 /* SyntaxKind.MultiLineCommentTrivia */, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -94457,13 +94859,13 @@ var ts; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); - var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */; + var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ScriptTarget.ES2022 */; // We need to transform `this` in a static initializer into a reference to the class // when targeting < ES2022 since the assignment will be moved outside of the class body. - var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */; + var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ScriptTarget.ES2022 */; // We don't need to transform `super` property access when targeting ES5, ES3 because // the es2015 transformation handles those. - var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */; + var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ScriptTarget.ES2015 */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -94489,7 +94891,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ES2022 */) { + || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ScriptTarget.ES2022 */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -94497,50 +94899,50 @@ var ts; return visited; } function visitorWorker(node, valueIsDiscarded) { - if (node.transformFlags & 16777216 /* ContainsClassFields */) { + if (node.transformFlags & 16777216 /* TransformFlags.ContainsClassFields */) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassLike(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return visitPrivateIdentifier(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitClassStaticBlockDeclaration(node); } } - if (node.transformFlags & 16777216 /* ContainsClassFields */ || - node.transformFlags & 134217728 /* ContainsLexicalSuper */ && + if (node.transformFlags & 16777216 /* TransformFlags.ContainsClassFields */ || + node.transformFlags & 134217728 /* TransformFlags.ContainsLexicalSuper */ && shouldTransformSuperInStaticInitializers && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; currentStaticPropertyDeclarationOrStaticBlock = undefined; var result = ts.visitEachChild(node, visitor, context); @@ -94559,17 +94961,17 @@ var ts; } function heritageClauseVisitor(node) { switch (node.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return ts.visitEachChild(node, heritageClauseVisitor, context); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitExpressionWithTypeArguments(node); } return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -94599,7 +95001,7 @@ var ts; } var privId = node.left; ts.Debug.assertNode(privId, ts.isPrivateIdentifier); - ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */); + ts.Debug.assert(node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */); var info = accessPrivateIdentifier(privId); if (info) { var receiver = ts.visitNode(node.right, visitor, ts.isExpression); @@ -94615,19 +95017,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return visitor(node); @@ -94676,10 +95078,10 @@ var ts; ts.Debug.assert(ts.isPrivateIdentifier(node.name)); var info = accessPrivateIdentifier(node.name); ts.Debug.assert(info, "Undeclared private name for property declaration."); - if (info.kind === "m" /* Method */) { + if (info.kind === "m" /* PrivateIdentifierKind.Method */) { return info.methodName; } - if (info.kind === "a" /* Accessor */) { + if (info.kind === "a" /* PrivateIdentifierKind.Accessor */) { if (ts.isGetAccessor(node)) { return info.getterName; } @@ -94738,11 +95140,11 @@ var ts; function createPrivateIdentifierAccessHelper(info, receiver) { ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94761,7 +95163,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94780,7 +95182,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94794,16 +95196,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { - if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { + var operand = ts.skipParentheses(node.operand); + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) { var info = void 0; - if (info = accessPrivateIdentifier(node.operand.name)) { - var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); + if (info = accessPrivateIdentifier(operand.name)) { + var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); - expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */); + expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* SyntaxKind.EqualsToken */); ts.setOriginalNode(expression, node); ts.setTextRange(expression, node); if (temp) { @@ -94814,7 +95217,7 @@ var ts; } } else if (shouldTransformSuperInStaticInitializers && - ts.isSuperProperty(node.operand) && + ts.isSuperProperty(operand) && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { // converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)` @@ -94826,32 +95229,32 @@ var ts; // converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)` // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)` var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { - var operand = visitInvalidSuperProperty(node.operand); + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { + var expression = visitInvalidSuperProperty(operand); return ts.isPrefixUnaryExpression(node) ? - factory.updatePrefixUnaryExpression(node, operand) : - factory.updatePostfixUnaryExpression(node, operand); + factory.updatePrefixUnaryExpression(node, expression) : + factory.updatePostfixUnaryExpression(node, expression); } if (classConstructor && superClassReference) { var setterName = void 0; var getterName = void 0; - if (ts.isPropertyAccessExpression(node.operand)) { - if (ts.isIdentifier(node.operand.name)) { - getterName = setterName = factory.createStringLiteralFromNode(node.operand.name); + if (ts.isPropertyAccessExpression(operand)) { + if (ts.isIdentifier(operand.name)) { + getterName = setterName = factory.createStringLiteralFromNode(operand.name); } } else { - if (ts.isSimpleInlineableExpression(node.operand.argumentExpression)) { - getterName = setterName = node.operand.argumentExpression; + if (ts.isSimpleInlineableExpression(operand.argumentExpression)) { + getterName = setterName = operand.argumentExpression; } else { getterName = factory.createTempVariable(hoistVariableDeclaration); - setterName = factory.createAssignment(getterName, ts.visitNode(node.operand.argumentExpression, visitor, ts.isExpression)); + setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression)); } } if (setterName && getterName) { var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor); - ts.setTextRange(expression, node.operand); + ts.setTextRange(expression, operand); var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor); @@ -94942,7 +95345,7 @@ var ts; var iife = factory.createImmediatelyInvokedArrowFunction(statements); ts.setOriginalNode(iife, node); ts.setTextRange(iife, node); - ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(iife, 2 /* EmitFlags.AdviseOnEmitNode */); return iife; } } @@ -94969,7 +95372,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); } if (classConstructor && superClassReference) { @@ -95011,7 +95414,7 @@ var ts; } } } - if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) { + if (node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { return visitPrivateIdentifierInInExpression(node); } return ts.visitEachChild(node, visitor, context); @@ -95026,12 +95429,12 @@ var ts; } ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, /* f */ undefined); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -95071,28 +95474,28 @@ var ts; return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function getClassFacts(node) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; var original = ts.getOriginalNode(node); if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) { - facts |= 1 /* ClassWasDecorated */; + facts |= 1 /* ClassFacts.ClassWasDecorated */; } for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (!ts.isStatic(member)) continue; if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) { - facts |= 2 /* NeedsClassConstructorReference */; + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { - if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) { - facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */; - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */; + if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */) { + facts |= 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */; + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } } - if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) { - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */; + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* TransformFlags.ContainsLexicalSuper */) { + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */ | 4 /* ClassFacts.NeedsClassSuperReference */; } } } @@ -95100,8 +95503,8 @@ var ts; return facts; } function visitExpressionWithTypeArguments(node) { - var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */; - if (facts & 4 /* NeedsClassSuperReference */) { + var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* ClassFacts.None */; + if (facts & 4 /* ClassFacts.NeedsClassSuperReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true); getClassLexicalEnvironment().superClassReference = temp; return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)), @@ -95114,19 +95517,19 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If a class has private static fields, or a static field has a `this` or `super` reference, // then we need to allocate a temp variable to hold on to that reference. var pendingClassReferenceAssignment; - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node)); } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); var statements = [ factory.updateClassDeclaration(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) @@ -95154,7 +95557,7 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If this class expression is a transformation of a decorated class declaration, @@ -95164,19 +95567,19 @@ var ts; // In this case, we use pendingStatements to produce the same output as the // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. - var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */); + var isDecoratedClassDeclaration = !!(facts & 1 /* ClassFacts.ClassWasDecorated */); var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; var temp; function createClassTempVar() { var classCheckFlags = resolver.getNodeCheckFlags(node); - var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; - var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + var isClassWithConstructorReference = classCheckFlags & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); } - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { temp = createClassTempVar(); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } @@ -95205,12 +95608,12 @@ var ts; // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); var alias = factory.cloneNode(temp); - alias.autoGenerateFlags &= ~8 /* ReservedInNestedScopes */; + alias.autoGenerateFlags &= ~8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; classAliases[ts.getOriginalNodeId(node)] = alias; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* EmitFlags.Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression))); // Add any pending expressions leftover from elided or relocated computed property names ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine)); @@ -95263,13 +95666,13 @@ var ts; /*typeArguments*/ undefined, []))); } function isClassElementThatRequiresConstructorStatement(member) { - if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* ModifierFlags.Abstract */)) { return false; } if (useDefineForClassFields) { // If we are using define semantics and targeting ESNext or higher, // then we don't need to transform any class properties. - return languageVersion < 9 /* ES2022 */; + return languageVersion < 9 /* ScriptTarget.ES2022 */; } return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member); } @@ -95458,7 +95861,7 @@ var ts; if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) { // capture the lexical environment for the member ts.setOriginalNode(transformed, property); - ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(transformed, 2 /* EmitFlags.AdviseOnEmitNode */); classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment); } currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; @@ -95477,7 +95880,7 @@ var ts; if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - if (privateIdentifierInfo.kind === "f" /* Field */) { + if (privateIdentifierInfo.kind === "f" /* PrivateIdentifierKind.Field */) { if (!privateIdentifierInfo.isStatic) { return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); } @@ -95497,7 +95900,7 @@ var ts; return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); - if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* ModifierFlags.Abstract */)) { return undefined; } var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero() @@ -95516,32 +95919,32 @@ var ts; } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* ClassPropertySubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForClassStaticThisOrSuperReference() { - if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) { - enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */; + if ((enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */) === 0) { + enabledSubstitutions |= 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */; // substitute `this` in a static field initializer - context.enableSubstitution(108 /* ThisKeyword */); + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); // these push a new lexical environment that is not the class lexical environment - context.enableEmitNotification(256 /* FunctionDeclaration */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // these push a new lexical environment that is not the class lexical environment, except // when they have a computed property name - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(167 /* PropertyDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(167 /* SyntaxKind.PropertyDeclaration */); // class lexical environments are restored when entering a computed property name - context.enableEmitNotification(162 /* ComputedPropertyName */); + context.enableEmitNotification(162 /* SyntaxKind.ComputedPropertyName */); } } /** @@ -95580,13 +95983,13 @@ var ts; } } switch (node.kind) { - case 213 /* FunctionExpression */: - if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { + case 213 /* SyntaxKind.FunctionExpression */: + if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */) { break; } // falls through - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = undefined; @@ -95596,10 +95999,10 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; @@ -95609,7 +96012,7 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 162 /* ComputedPropertyName */: { + case 162 /* SyntaxKind.ComputedPropertyName */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; @@ -95630,24 +96033,24 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisExpression(node); } return node; } function substituteThisExpression(node) { - if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { + if (enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.createParenthesizedExpression(factory.createVoidZero()); } if (classConstructor) { @@ -95660,8 +96063,8 @@ var ts; return trySubstituteClassAlias(node) || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -95694,7 +96097,7 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(generatedName); } else { @@ -95714,7 +96117,7 @@ var ts; } function getClassLexicalEnvironment() { return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = { - facts: 0 /* None */, + facts: 0 /* ClassFacts.None */, classConstructor: undefined, superClassReference: undefined, privateIdentifierEnvironment: undefined, @@ -95747,7 +96150,7 @@ var ts; if (ts.isPropertyDeclaration(node)) { var variableName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, variableName: variableName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95757,7 +96160,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { var functionName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: functionName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95766,12 +96169,12 @@ var ts; } else if (ts.isGetAccessorDeclaration(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: classConstructor, @@ -95782,12 +96185,12 @@ var ts; } else if (ts.isSetAccessorDeclaration(node)) { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: classConstructor, @@ -95803,7 +96206,7 @@ var ts; else if (ts.isPropertyDeclaration(node)) { var weakMapName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, brandCheckIdentifier: weakMapName, isStatic: false, variableName: undefined, @@ -95815,7 +96218,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: createHoistedVariableForPrivateName(text, node), brandCheckIdentifier: weakSetName, isStatic: false, @@ -95826,12 +96229,12 @@ var ts; ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); if (ts.isGetAccessor(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: weakSetName, @@ -95842,12 +96245,12 @@ var ts; } else { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: weakSetName, @@ -95864,9 +96267,9 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16 /* Optimistic */); - if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) { + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */); + if (resolver.getNodeCheckFlags(node) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(identifier); } else { @@ -95908,9 +96311,9 @@ var ts; // differently inside the function. if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); } - return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */)); + return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* SyntaxKind.EqualsToken */)); } function visitArrayAssignmentTarget(node) { var target = ts.getTargetOfBindingOrAssignmentElement(node); @@ -95924,7 +96327,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95964,7 +96367,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -96072,15 +96475,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: return serializeTypeNode(node.type); - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createIdentifier("Function"); default: return ts.factory.createVoidZero(); @@ -96116,7 +96519,7 @@ var ts; return ts.factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 172 /* GetAccessor */) { + if (container && node.kind === 172 /* SyntaxKind.GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -96161,67 +96564,67 @@ var ts; } node = ts.skipTypeParentheses(node); switch (node.kind) { - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return ts.factory.createVoidZero(); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return ts.factory.createIdentifier("Function"); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return ts.factory.createIdentifier("Array"); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? ts.factory.createVoidZero() : ts.factory.createIdentifier("Boolean"); - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return ts.factory.createIdentifier("Boolean"); - case 198 /* TemplateLiteralType */: - case 150 /* StringKeyword */: + case 198 /* SyntaxKind.TemplateLiteralType */: + case 150 /* SyntaxKind.StringKeyword */: return ts.factory.createIdentifier("String"); - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return ts.factory.createIdentifier("Object"); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return serializeLiteralOfLiteralTypeNode(node.literal); - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return ts.factory.createIdentifier("Number"); - case 158 /* BigIntKeyword */: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); - case 151 /* SymbolKeyword */: - return getGlobalConstructor("Symbol", 2 /* ES2015 */); - case 178 /* TypeReference */: + case 158 /* SyntaxKind.BigIntKeyword */: + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); + case 151 /* SyntaxKind.SymbolKeyword */: + return getGlobalConstructor("Symbol", 2 /* ScriptTarget.ES2015 */); + case 178 /* SyntaxKind.TypeReference */: return serializeTypeReferenceNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ true); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ false); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], /*isIntersection*/ false); - case 193 /* TypeOperator */: - if (node.operator === 145 /* ReadonlyKeyword */) { + case 193 /* SyntaxKind.TypeOperator */: + if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 181 /* TypeQuery */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 182 /* TypeLiteral */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 192 /* ThisType */: - case 200 /* ImportType */: + case 181 /* SyntaxKind.TypeQuery */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 200 /* SyntaxKind.ImportType */: break; // handle JSDoc types from an invalid parse - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 317 /* JSDocFunctionType */: - case 318 /* JSDocVariadicType */: - case 319 /* JSDocNamepathType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 318 /* SyntaxKind.JSDocVariadicType */: + case 319 /* SyntaxKind.JSDocNamepathType */: break; - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 316 /* JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -96230,27 +96633,27 @@ var ts; } function serializeLiteralOfLiteralTypeNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.factory.createIdentifier("String"); - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; switch (operand.kind) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return serializeLiteralOfLiteralTypeNode(operand); default: return ts.Debug.failBadSyntaxKind(operand); } } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.factory.createIdentifier("Number"); - case 9 /* BigIntLiteral */: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 9 /* SyntaxKind.BigIntLiteral */: + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return ts.factory.createIdentifier("Boolean"); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return ts.factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node); @@ -96262,20 +96665,20 @@ var ts; for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { var typeNode = types_22[_i]; typeNode = ts.skipTypeParentheses(typeNode); - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { if (isIntersection) return ts.factory.createVoidZero(); // Reduce to `never` in an intersection continue; // Elide `never` in a union } - if (typeNode.kind === 155 /* UnknownKeyword */) { + if (typeNode.kind === 155 /* SyntaxKind.UnknownKeyword */) { if (!isIntersection) return ts.factory.createIdentifier("Object"); // Reduce to `unknown` in a union continue; // Elide `unknown` in an intersection } - if (typeNode.kind === 130 /* AnyKeyword */) { + if (typeNode.kind === 130 /* SyntaxKind.AnyKeyword */) { return ts.factory.createIdentifier("Object"); // Reduce to `any` in a union or intersection } - if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */) || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */) || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedConstituent = serializeTypeNode(typeNode); @@ -96356,7 +96759,7 @@ var ts; case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: return ts.factory.createVoidZero(); case ts.TypeReferenceSerializationKind.BigIntLikeType: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); case ts.TypeReferenceSerializationKind.BooleanType: return ts.factory.createIdentifier("Boolean"); case ts.TypeReferenceSerializationKind.NumberLikeType: @@ -96366,7 +96769,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return ts.factory.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return getGlobalConstructor("Symbol", 2 /* ES2015 */); + return getGlobalConstructor("Symbol", 2 /* ScriptTarget.ES2015 */); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: return ts.factory.createIdentifier("Function"); case ts.TypeReferenceSerializationKind.Promise: @@ -96396,12 +96799,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { // A -> typeof A !== "undefined" && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 79 /* Identifier */) { + if (node.left.kind === 79 /* SyntaxKind.Identifier */) { // A.B -> typeof A !== "undefined" && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -96416,14 +96819,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -96474,28 +96877,28 @@ var ts; return ts.isDecorator(node) ? undefined : node; } function visitor(node) { - if (!(node.transformFlags & 33554432 /* ContainsDecorators */)) { + if (!(node.transformFlags & 33554432 /* TransformFlags.ContainsDecorators */)) { return node; } switch (node.kind) { - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are elided. They will be emitted as part of `visitClassDeclaration`. return undefined; - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructorDeclaration(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitSetAccessorDeclaration(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return visitGetAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameterDeclaration(node); default: return ts.visitEachChild(node, visitor, context); @@ -96504,39 +96907,72 @@ var ts; function visitClassDeclaration(node) { if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node))) return ts.visitEachChild(node, visitor, context); - var classStatement = ts.hasDecorators(node) ? - createClassDeclarationHeadWithDecorators(node, node.name) : - createClassDeclarationHeadWithoutDecorators(node, node.name); - var statements = [classStatement]; - // Write any decorators of the node. - addClassElementDecorationStatements(statements, node, /*isStatic*/ false); - addClassElementDecorationStatements(statements, node, /*isStatic*/ true); - addConstructorDecorationStatement(statements, node); + var statements = ts.hasDecorators(node) ? + transformClassDeclarationWithClassDecorators(node, node.name) : + transformClassDeclarationWithoutClassDecorators(node, node.name); if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } + function decoratorContainsPrivateIdentifierInExpression(decorator) { + return !!(decorator.transformFlags & 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); + } + function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) { + return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression); + } + function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (!ts.canHaveDecorators(member)) + continue; + var allDecorators = ts.getAllDecoratorsOfClassElement(member, node); + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression)) + return true; + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression)) + return true; + } + return false; + } + function transformDecoratorsOfClassElements(node, members) { + var decorationStatements = []; + addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ false); + addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ true); + if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) { + members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [ + factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, /*multiLine*/ true)) + ], false)), members); + decorationStatements = undefined; + } + return { decorationStatements: decorationStatements, members: members }; + } /** * Transforms a non-decorated class declaration. * * @param node A ClassDeclaration node. * @param name The name of the class. */ - function createClassDeclarationHeadWithoutDecorators(node, name) { + function transformClassDeclarationWithoutClassDecorators(node, name) { // ${modifiers} class ${name} ${heritageClauses} { // ${members} // } - return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement)); + var _a; + var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = ts.visitNodes(node.members, visitor, ts.isClassElement); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var updated = factory.updateClassDeclaration(node, modifiers, name, + /*typeParameters*/ undefined, heritageClauses, members); + return ts.addRange([updated], decorationStatements); } /** * Transforms a decorated class declaration and appends the resulting statements. If * the class requires an alias to avoid issues with double-binding, the alias is returned. */ - function createClassDeclarationHeadWithDecorators(node, name) { + function transformClassDeclarationWithClassDecorators(node, name) { // When we emit an ES6 class that has a class decorator, we must tailor the // emit to certain specific cases. // @@ -96622,11 +97058,12 @@ var ts; // | var C_1; // --------------------------------------------------------------------- // + var _a; var location = ts.moveRangePastModifiers(node); var classAlias = getClassAliasIfNeeded(node); // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var declName = languageVersion <= 2 /* ES2015 */ ? + var declName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { @@ -96634,7 +97071,11 @@ var ts; // } var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = ts.visitNodes(node.members, visitor, ts.isClassElement); - var classExpression = factory.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var classExpression = factory.createClassExpression( + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); ts.setTextRange(classExpression, location); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference @@ -96644,11 +97085,14 @@ var ts; factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) - ], 1 /* Let */)); + ], 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); ts.setTextRange(statement, location); ts.setCommentRange(statement, node); - return statement; + var statements = [statement]; + ts.addRange(statements, decorationStatements); + addConstructorDecorationStatement(statements, node); + return statements; } function visitClassExpression(node) { // Legacy decorators were not supported on class expressions @@ -96681,7 +97125,7 @@ var ts; return finishClassElement(factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock)), node); } function visitPropertyDeclaration(node) { - if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { return undefined; } return finishClassElement(factory.updatePropertyDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), @@ -96698,7 +97142,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -96808,9 +97252,9 @@ var ts; // ], C.prototype, "prop"); // var prefix = getClassMemberPrefix(node, member); - var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */)); - var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 167 /* PropertyDeclaration */ + var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* ModifierFlags.Ambient */)); + var descriptor = languageVersion > 0 /* ScriptTarget.ES3 */ + ? member.kind === 167 /* SyntaxKind.PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -96819,7 +97263,7 @@ var ts; : factory.createNull() : undefined; var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member)); return helper; } @@ -96848,12 +97292,12 @@ var ts; var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var localName = languageVersion <= 2 /* ES2015 */ ? + var localName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 1536 /* NoComments */); + ts.setEmitFlags(expression, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node)); return expression; } @@ -96879,7 +97323,7 @@ var ts; var decorator = decorators_1[_i]; var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); ts.setTextRange(helper, decorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); expressions.push(helper); } } @@ -96912,7 +97356,7 @@ var ts; if (!classAliases) { // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } @@ -96923,7 +97367,7 @@ var ts; * double-binding semantics for the class name. */ function getClassAliasIfNeeded(node) { - if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) { + if (resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; @@ -96947,14 +97391,14 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -96965,7 +97409,7 @@ var ts; } function trySubstituteClassAlias(node) { if (classAliases) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -97037,8 +97481,8 @@ var ts; if (node.isDeclarationFile) { return node; } - setContextFlag(1 /* NonTopLevel */, false); - setContextFlag(2 /* HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); + setContextFlag(1 /* ContextFlags.NonTopLevel */, false); + setContextFlag(2 /* ContextFlags.HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -97050,10 +97494,10 @@ var ts; return (contextFlags & flags) !== 0; } function inTopLevelContext() { - return !inContext(1 /* NonTopLevel */); + return !inContext(1 /* ContextFlags.NonTopLevel */); } function inHasLexicalThisContext() { - return inContext(2 /* HasLexicalThis */); + return inContext(2 /* ContextFlags.HasLexicalThis */); } function doWithContext(flags, cb, value) { var contextFlagsToSet = flags & ~contextFlags; @@ -97069,39 +97513,39 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 256 /* TransformFlags.ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 169 /* MethodDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 256 /* FunctionDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 213 /* FunctionExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 214 /* ArrowFunction */: - return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitMethodDeclaration, node); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionDeclaration, node); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionExpression, node); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithContext(1 /* ContextFlags.NonTopLevel */, visitArrowFunction, node); + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -97109,27 +97553,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatementInAsyncBody(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatementInAsyncBody(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClauseInAsyncBody(node); - case 235 /* Block */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 248 /* WithStatement */: - case 250 /* LabeledStatement */: + case 235 /* SyntaxKind.Block */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -97211,7 +97655,7 @@ var ts; return factory.updateMethodDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97226,7 +97670,7 @@ var ts; function visitFunctionDeclaration(node) { return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97241,7 +97685,7 @@ var ts; function visitFunctionExpression(node) { return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97256,7 +97700,7 @@ var ts; function visitArrowFunction(node) { return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97277,7 +97721,7 @@ var ts; function isVariableDeclarationListWithCollidingName(node) { return !!node && ts.isVariableDeclarationList(node) - && !(node.flags & 3 /* BlockScoped */) + && !(node.flags & 3 /* NodeFlags.BlockScoped */) && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { @@ -97331,9 +97775,9 @@ var ts; resumeLexicalEnvironment(); var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 214 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + var promiseConstructor = languageVersion < 2 /* ScriptTarget.ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 214 /* SyntaxKind.ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* NodeCheckFlags.CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -97359,7 +97803,7 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); if (capturedSuperProperties.size) { @@ -97372,10 +97816,10 @@ var ts; ts.setTextRange(block, node.body); if (emitSuperHelpers && hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -97419,21 +97863,21 @@ var ts; return undefined; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -97446,8 +97890,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -97474,30 +97918,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -97517,19 +97961,19 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), location); } } @@ -97539,7 +97983,7 @@ var ts; function createSuperAccessVariableStatement(factory, resolver, node, names) { // Create a variable declaration with a getter/setter (if binding) definition for each name: // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... }); - var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) !== 0; + var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0; var accessors = []; names.forEach(function (_, key) { var name = ts.unescapeLeadingUnderscores(key); @@ -97549,7 +97993,7 @@ var ts; /* typeParameters */ undefined, /* parameters */ [], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */)))); + /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */)))); if (hasBinding) { getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction( /* modifiers */ undefined, @@ -97563,20 +98007,20 @@ var ts; /* initializer */ undefined) ], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */), factory.createIdentifier("v"))))); + /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v"))))); } accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter))); }); return factory.createVariableStatement( /* modifiers */ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), /* typeArguments */ undefined, [ factory.createNull(), factory.createObjectLiteralExpression(accessors, /* multiline */ true) ])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; })(ts || (ts = {})); @@ -97646,7 +98090,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -97678,7 +98122,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 131 /* AsyncKeyword */) { + if (node.kind === 131 /* SyntaxKind.AsyncKeyword */) { return undefined; } return node; @@ -97700,88 +98144,88 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 244 /* ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + return doWithHierarchyFacts(visitDefault, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: - return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 217 /* VoidExpression */: + case 242 /* SyntaxKind.ForStatement */: + return doWithHierarchyFacts(visitForStatement, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); - case 171 /* Constructor */: - return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 169 /* MethodDeclaration */: - return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 172 /* GetAccessor */: - return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 173 /* SetAccessor */: - return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 256 /* FunctionDeclaration */: - return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 213 /* FunctionExpression */: - return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 214 /* ArrowFunction */: - return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 164 /* Parameter */: + case 171 /* SyntaxKind.Constructor */: + return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 172 /* SyntaxKind.GetAccessor */: + return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 173 /* SyntaxKind.SetAccessor */: + return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithHierarchyFacts(visitArrowFunction, node, 2 /* HierarchyFacts.ArrowFunctionExcludes */, 0 /* HierarchyFacts.ArrowFunctionIncludes */); + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithHierarchyFacts(visitDefault, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); } function visitYieldExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { if (node.asteriskToken) { var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression); return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression( @@ -97795,15 +98239,15 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitReturnStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero())); } return ts.visitEachChild(node, visitor, context); } function visitLabeledStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 244 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 244 /* SyntaxKind.ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -97815,7 +98259,7 @@ var ts; var objects = []; for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { var e = elements_5[_i]; - if (e.kind === 298 /* SpreadAssignment */) { + if (e.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -97824,7 +98268,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 296 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 296 /* SyntaxKind.PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -97835,7 +98279,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { // spread elements emit like so: // non-spread elements are chunked together into object literals, and then all are passed to __assign: // { a, ...o, b } => __assign(__assign({a}, o), {b}); @@ -97858,7 +98302,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 205 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -97885,9 +98329,9 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* HierarchyFacts.SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? + 0 /* HierarchyFacts.StrictModeSourceFileIncludes */ : + 1 /* HierarchyFacts.SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -97908,10 +98352,10 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -97939,10 +98383,10 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name); - var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); + var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* FlattenLevel.ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { block = factory.updateBlock(block, __spreadArray([ @@ -97954,7 +98398,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; var visited = ts.visitEachChild(node, visitor, context); @@ -97980,8 +98424,8 @@ var ts; } function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); @@ -97998,8 +98442,8 @@ var ts; * @param node A ForOfStatement. */ function visitForOfStatement(node, outermostLabeledStatement) { - var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + if (node.initializer.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -98027,7 +98471,7 @@ var ts; } return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), + ], 1 /* NodeFlags.Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), /*multiLine*/ true), bodyLocation)); } return node; @@ -98047,10 +98491,10 @@ var ts; statements.push(statement); } return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), - /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function createDownlevelAwait(expression) { - return enclosingFunctionFlags & 1 /* Generator */ + return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(expression)) : factory.createAwaitExpression(expression); } @@ -98069,18 +98513,18 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 2 /* IterationContainer */ ? + var initializer = ancestorFacts & 2 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) : callValues; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), /*incrementor*/ undefined, /*statement*/ convertForOfStatementHead(node, getValue)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setOriginalNode(forStatement, node); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -98088,15 +98532,15 @@ var ts; factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } function parameterVisitor(node) { @@ -98111,7 +98555,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -98128,7 +98572,7 @@ var ts; if (parameters) { parameters.add(parameter); } - else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { parameters = new ts.Set(); } } @@ -98170,13 +98614,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateMethodDeclaration(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateMethodDeclaration(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifierLike) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98188,13 +98632,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionDeclaration(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionDeclaration(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98218,13 +98662,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98241,13 +98685,13 @@ var ts; capturedSuperProperties = new ts.Set(); hasSuperElementAccess = false; var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */))); + /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */))); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties); @@ -98258,10 +98702,10 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.updateBlock(node.body, statements); if (emitSuperHelpers && hasSuperElementAccess) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -98300,11 +98744,11 @@ var ts; // // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts if (parameter.name.elements.length > 0) { - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)); + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98313,7 +98757,7 @@ var ts; var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); var assignment = factory.createAssignment(name, initializer); var statement = factory.createExpressionStatement(assignment); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98329,32 +98773,32 @@ var ts; // } var name = factory.cloneNode(parameter.name); ts.setTextRange(name, parameter.name); - ts.setEmitFlags(name, 48 /* NoSourceMap */); + ts.setEmitFlags(name, 48 /* EmitFlags.NoSourceMap */); var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); - ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */); + ts.addEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | 1536 /* EmitFlags.NoComments */); var assignment = factory.createAssignment(name, initializer); ts.setTextRange(assignment, parameter); - ts.setEmitFlags(assignment, 1536 /* NoComments */); + ts.setEmitFlags(assignment, 1536 /* EmitFlags.NoComments */); var block = factory.createBlock([factory.createExpressionStatement(assignment)]); ts.setTextRange(block, parameter); - ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined"); var statement = factory.createIfStatement(typeCheck, block); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); statements = ts.append(statements, statement); } } - else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { containsPrecedingObjectRestOrSpread = true; - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter), + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* FlattenLevel.ObjectRest */, factory.getGeneratedNameForNode(parameter), /*doNotRecordTempVariablesInLine*/ false, /*skipInitializer*/ true); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98362,21 +98806,21 @@ var ts; return statements; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -98389,8 +98833,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -98417,30 +98861,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -98460,14 +98904,14 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } @@ -98492,11 +98936,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 64 /* TransformFlags.ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -98524,29 +98968,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 32 /* TransformFlags.ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 221 /* BinaryExpression */: - if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98588,7 +99032,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 206 /* PropertyAccessExpression */ + expression = node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -98611,10 +99055,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 208 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 208 /* SyntaxKind.CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -98623,7 +99067,7 @@ var ts; var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false); var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left; - var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */); + var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); if (!ts.isSimpleCopiableExpression(capturedLeft)) { capturedLeft = factory.createTempVariable(hoistVariableDeclaration); leftExpression = factory.createAssignment(capturedLeft, leftExpression); @@ -98633,8 +99077,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -98644,17 +99088,17 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 206 /* PropertyAccessExpression */ + rightExpression = segment.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (i === 0 && leftThisArg) { if (!ts.isGeneratedIdentifier(leftThisArg)) { leftThisArg = factory.cloneNode(leftThisArg); - ts.addEmitFlags(leftThisArg, 1536 /* NoComments */); + ts.addEmitFlags(leftThisArg, 1536 /* EmitFlags.NoComments */); } - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SyntaxKind.SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -98671,7 +99115,7 @@ var ts; return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target; } function createNotNullCondition(left, right, invert) { - return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* BarBarToken */ : 55 /* AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createVoidZero())); + return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* SyntaxKind.BarBarToken */ : 55 /* SyntaxKind.AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createVoidZero())); } function transformNullishCoalescingExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -98705,11 +99149,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) { + if ((node.transformFlags & 16 /* TransformFlags.ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -98759,7 +99203,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 4 /* TransformFlags.ContainsESNext */) === 0) { return node; } switch (node.kind) { @@ -98783,12 +99227,12 @@ var ts; if (currentFileState.filenameDeclaration) { return currentFileState.filenameDeclaration.name; } - var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); + var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); currentFileState.filenameDeclaration = declaration; return currentFileState.filenameDeclaration.name; } function getJsxFactoryCalleePrimitive(isStaticChildren) { - return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; + return compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; } function getJsxFactoryCallee(isStaticChildren) { var type = getJsxFactoryCalleePrimitive(isStaticChildren); @@ -98814,7 +99258,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); + var generatedName = factory.createUniqueName("_".concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */ | 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */); var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -98836,7 +99280,7 @@ var ts; ts.addEmitHelpers(visited, context.readEmitHelpers()); var statements = visited.statements; if (currentFileState.filenameDeclaration) { - statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */))); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* NodeFlags.Const */))); } if (currentFileState.utilizedImplicitRuntimeImports) { for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { @@ -98853,7 +99297,7 @@ var ts; factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); ts.setParentRecursive(requireStatement, /*incremental*/ false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement); } @@ -98869,7 +99313,7 @@ var ts; return visited; } function visitor(node) { - if (node.transformFlags & 2 /* ContainsJsx */) { + if (node.transformFlags & 2 /* TransformFlags.ContainsJsx */) { return visitorWorker(node); } else { @@ -98878,13 +99322,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98892,15 +99336,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return visitJsxText(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -98969,7 +99413,7 @@ var ts; if (keyAttr) { args.push(transformJsxAttributeInitializer(keyAttr.initializer)); } - if (compilerOptions.jsx === 5 /* ReactJSXDev */) { + if (compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */) { var originalFile = ts.getOriginalNode(currentSourceFile); if (originalFile && ts.isSourceFile(originalFile)) { // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature @@ -99034,7 +99478,7 @@ var ts; } function transformJsxAttributesToObjectProps(attrs, children) { var target = ts.getEmitScriptTarget(compilerOptions); - return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : + return target && target >= 5 /* ScriptTarget.ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : transformJsxAttributesToExpression(attrs, children); } function transformJsxAttributesToProps(attrs, children) { @@ -99074,14 +99518,14 @@ var ts; if (node === undefined) { return factory.createTrue(); } - if (node.kind === 10 /* StringLiteral */) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */) { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - if (node.kind === 288 /* JsxExpression */) { + if (node.kind === 288 /* SyntaxKind.JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -99182,7 +99626,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 278 /* JsxElement */) { + if (node.kind === 278 /* SyntaxKind.JsxElement */) { return getTagName(node.openingElement); } else { @@ -99485,11 +99929,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 512 /* TransformFlags.ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -99497,9 +99941,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 67 /* AsteriskAsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -99689,7 +100133,7 @@ var ts; currentSourceFile = undefined; currentText = undefined; taggedTemplateStringDeclarations = undefined; - hierarchyFacts = 0 /* None */; + hierarchyFacts = 0 /* HierarchyFacts.None */; return visited; } /** @@ -99699,7 +100143,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -99710,15 +100154,15 @@ var ts; * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* HierarchyFacts.SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 247 /* ReturnStatement */ + return (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */) !== 0 + && node.kind === 247 /* SyntaxKind.ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -99733,11 +100177,11 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 1024 /* TransformFlags.ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) + || (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) - || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; + || (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) !== 0; } function visitor(node) { return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node; @@ -99749,9 +100193,9 @@ var ts; if (shouldVisitNode(node)) { var original = ts.getOriginalNode(node); if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) { - var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.StaticInitializerExcludes */, 16449 /* HierarchyFacts.StaticInitializerIncludes */); var result = visitorWorker(node, /*expressionResultIsUnused*/ false); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); return result; } return visitorWorker(node, /*expressionResultIsUnused*/ false); @@ -99759,115 +100203,115 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return undefined; // elide static keyword - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitArrowFunction(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return visitIdentifier(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitVariableDeclarationList(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitBreakOrContinueStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return visitTemplateLiteral(node); - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return visitStringLiteral(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return visitNumericLiteral(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitSpreadElement(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return visitThisKeyword(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitMetaProperty(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(8064 /* HierarchyFacts.SourceFileExcludes */, 64 /* HierarchyFacts.SourceFileIncludes */); var prologue = []; var statements = []; startLexicalEnvironment(); @@ -99878,14 +100322,14 @@ var ts; } factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureThisForNodeIfNeeded(prologue, node); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + convertedLoopState.allowedNonLabeledJumps |= 2 /* Jump.Break */; var result = ts.visitEachChild(node, visitor, context); convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; return result; @@ -99893,17 +100337,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCaseBlock(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function returnCapturedThis(node) { - return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)), node); } function visitReturnStatement(node) { if (convertedLoopState) { - convertedLoopState.nonLocalJumps |= 8 /* Return */; + convertedLoopState.nonLocalJumps |= 8 /* Jump.Return */; if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { node = returnCapturedThis(node); } @@ -99919,11 +100363,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } if (convertedLoopState) { - if (hierarchyFacts & 2 /* ArrowFunction */) { + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */) { // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -99950,30 +100394,30 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 246 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 246 /* SyntaxKind.BreakStatement */ ? 2 /* Jump.Break */ : 4 /* Jump.Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 246 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Jump.Break */; labelMarker = "break"; } else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; + convertedLoopState.nonLocalJumps |= 4 /* Jump.Continue */; // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. labelMarker = "continue"; } } else { - if (node.kind === 246 /* BreakStatement */) { - labelMarker = "break-" + label.escapedText; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } @@ -99982,15 +100426,15 @@ var ts; var outParams = convertedLoopState.loopOutParameters; var expr = void 0; for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + var copyExpr = copyOutParameter(outParams[i], 1 /* CopyDirection.ToOutParameter */); if (i === 0) { expr = copyExpr; } else { - expr = factory.createBinaryExpression(expr, 27 /* CommaToken */, copyExpr); + expr = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, copyExpr); } } - returnExpression = factory.createBinaryExpression(expr, 27 /* CommaToken */, returnExpression); + returnExpression = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, returnExpression); } return factory.createReturnStatement(returnExpression); } @@ -100023,18 +100467,18 @@ var ts; ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - var exportStatement = ts.hasSyntacticModifier(node, 512 /* Default */) + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + var exportStatement = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? factory.createExportDefault(factory.getLocalName(node)) : factory.createExternalModuleExport(factory.getLocalName(node)); ts.setOriginalNode(exportStatement, statement); statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -100091,25 +100535,25 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */))] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* Indented */) | 524288 /* ReuseTempVariableScope */); + ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */) | 524288 /* EmitFlags.ReuseTempVariableScope */); // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = factory.createPartiallyEmittedExpression(classFunction); ts.setTextRangeEnd(inner, node.end); - ts.setEmitFlags(inner, 1536 /* NoComments */); + ts.setEmitFlags(inner, 1536 /* EmitFlags.NoComments */); var outer = factory.createPartiallyEmittedExpression(inner); ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos)); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); - ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + ts.addSyntheticLeadingComment(result, 3 /* SyntaxKind.MultiLineCommentTrivia */, "* @class "); return result; } /** @@ -100127,19 +100571,19 @@ var ts; addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(constructorLikeName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -100165,7 +100609,7 @@ var ts; function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); + var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = factory.createFunctionDeclaration( @@ -100175,10 +100619,10 @@ var ts; /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); + ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; } /** @@ -100212,7 +100656,7 @@ var ts; ts.setTextRange(statementsArray, node.members); var block = factory.createBlock(statementsArray, /*multiLine*/ true); ts.setTextRange(block, node); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -100227,7 +100671,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -100271,7 +100715,7 @@ var ts; superCallExpression = visitSuperCallInBody(superCall); } if (superCallExpression) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + hierarchyFacts |= 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */; } // Add parameter defaults at the beginning of the output, with prologue statements addDefaultValueAssignmentsIfNeeded(prologue, constructor); @@ -100281,7 +100725,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) { + if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -100304,7 +100748,7 @@ var ts; var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1)); - ts.setEmitFlags(superCall_1, 1536 /* NoComments */); + ts.setEmitFlags(superCall_1, 1536 /* EmitFlags.NoComments */); statements.push(returnStatement); } else { @@ -100343,7 +100787,7 @@ var ts; } } if (!isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))); } } } @@ -100393,11 +100837,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 247 /* ReturnStatement */) { + if (statement.kind === 247 /* SyntaxKind.ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 239 /* IfStatement */) { + else if (statement.kind === 239 /* SyntaxKind.IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -100405,7 +100849,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 235 /* Block */) { + else if (statement.kind === 235 /* SyntaxKind.Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -100414,10 +100858,10 @@ var ts; return false; } function createActualThis() { - return ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */); + return ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */); } function createDefaultSuperCallOrThis() { - return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); + return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -100504,11 +100948,11 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } else if (initializer) { - ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } return false; @@ -100526,11 +100970,11 @@ var ts; var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment( // TODO(rbuckton): Does this need to be parented? - ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); + ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); ts.insertStatementAfterCustomPrologue(statements, statement); } /** @@ -100561,10 +101005,10 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. // TODO(rbuckton): Does this need to be parented? - var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); - ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); + var declarationName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + ts.setEmitFlags(declarationName, 48 /* EmitFlags.NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -100574,7 +101018,7 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, factory.createArrayLiteralExpression([])) ])), - /*location*/ parameter), 1048576 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* EmitFlags.CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -100586,13 +101030,13 @@ var ts; : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* EmitFlags.CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 79 /* Identifier */) { + if (parameter.name.kind !== 79 /* SyntaxKind.Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, expressionName))), parameter), 1048576 /* EmitFlags.CustomPrologue */)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; @@ -100605,7 +101049,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 214 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* HierarchyFacts.CapturedLexicalThis */ && node.kind !== 214 /* SyntaxKind.ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -100619,7 +101063,7 @@ var ts; */ function insertSuperThisCaptureThisForNode(statements, superExpression) { enableSubstitutionsForCapturedThis(); - var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression)); + var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* SyntaxKind.EqualsToken */, superExpression)); ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression); ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent); } @@ -100627,38 +101071,38 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); ts.setSourceMapRange(captureThisStatement, node); ts.insertStatementAfterCustomPrologue(statements, captureThisStatement); } function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { - if (hierarchyFacts & 32768 /* NewTarget */) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return statements; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. - newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); + newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), - /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"), + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), 102 /* SyntaxKind.InstanceOfKeyword */, factory.getLocalName(node))), + /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"), /*colonToken*/ undefined, factory.createVoidZero()); break; default: @@ -100666,11 +101110,11 @@ var ts; } var captureNewTargetStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, newTarget) ])); - ts.setEmitFlags(captureNewTargetStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureNewTargetStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); if (copyOnWrite) { statements = statements.slice(); } @@ -100689,21 +101133,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -100742,7 +101186,7 @@ var ts; var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, /*location*/ member.name); e = factory.createAssignment(memberName, memberFunction); } - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); + ts.setEmitFlags(memberFunction, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.setTextRange(factory.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); @@ -100750,7 +101194,7 @@ var ts; // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 48 /* NoSourceMap */); + ts.setEmitFlags(statement, 48 /* EmitFlags.NoSourceMap */); return statement; } /** @@ -100764,7 +101208,7 @@ var ts; // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } @@ -100780,20 +101224,20 @@ var ts; // arguments are both mapped contiguously to the accessor name. // TODO(rbuckton): Does this need to be parented? var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(target, 1536 /* EmitFlags.NoComments */ | 32 /* EmitFlags.NoTrailingSourceMap */); ts.setSourceMapRange(target, firstAccessor.name); var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName); if (ts.isPrivateIdentifier(visitedAccessorName)) { return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015."); } var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 16 /* EmitFlags.NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(getterFunction, 512 /* EmitFlags.NoLeadingComments */); var getter = factory.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -100801,7 +101245,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(setterFunction, 512 /* EmitFlags.NoLeadingComments */); var setter = factory.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -100824,12 +101268,12 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (node.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); + var ancestorFacts = enterSubtree(15232 /* HierarchyFacts.ArrowFunctionExcludes */, 66 /* HierarchyFacts.ArrowFunctionIncludes */); var func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -100838,9 +101282,9 @@ var ts; /*type*/ undefined, transformFunctionBody(node)); ts.setTextRange(func, node); ts.setOriginalNode(func, node); - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); // If an arrow function contains - exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.ArrowFunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return func; } @@ -100850,17 +101294,17 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ - ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */ + ? enterSubtree(32662 /* HierarchyFacts.AsyncFunctionBodyExcludes */, 69 /* HierarchyFacts.AsyncFunctionBodyIncludes */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionExpression(node, /*modifiers*/ undefined, node.asteriskToken, name, @@ -100875,13 +101319,13 @@ var ts; function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, /*typeParameters*/ undefined, parameters, @@ -100898,14 +101342,14 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node) - ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + ? enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */ | 8 /* HierarchyFacts.NonStaticClassElement */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ && !name && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, @@ -100948,7 +101392,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 214 /* ArrowFunction */); + ts.Debug.assert(node.kind === 214 /* SyntaxKind.ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -100967,7 +101411,7 @@ var ts; var returnStatement = factory.createReturnStatement(expression); ts.setTextRange(returnStatement, body); ts.moveSyntheticComments(returnStatement, body); - ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1024 /* EmitFlags.NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -100988,10 +101432,10 @@ var ts; var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine); ts.setTextRange(block, node.body); if (!multiLine && singleLine) { - ts.setEmitFlags(block, 1 /* SingleLine */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* SyntaxKind.CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -101001,11 +101445,11 @@ var ts; // A function body is not a block scope. return ts.visitEachChild(node, visitor, context); } - var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ - ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) - : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */); + var ancestorFacts = hierarchyFacts & 256 /* HierarchyFacts.IterationStatement */ + ? enterSubtree(7104 /* HierarchyFacts.IterationStatementBlockExcludes */, 512 /* HierarchyFacts.IterationStatementBlockIncludes */) + : enterSubtree(6976 /* HierarchyFacts.BlockExcludes */, 128 /* HierarchyFacts.BlockIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -101036,9 +101480,9 @@ var ts; function visitBinaryExpression(node, expressionResultIsUnused) { // If we are here it is because this is a destructuring assignment. if (ts.isDestructuringAssignment(node)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -101066,12 +101510,12 @@ var ts; function isVariableStatementOfTypeScriptClassWrapper(node) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer - && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */); + && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* EmitFlags.TypeScriptClassWrapper */); } function visitVariableStatement(node) { - var ancestorFacts = enterSubtree(0 /* None */, ts.hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.None */, ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? 32 /* HierarchyFacts.ExportedVariableStatement */ : 0 /* HierarchyFacts.None */); var updated; - if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { + if (convertedLoopState && (node.declarationList.flags & 3 /* NodeFlags.BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -101080,10 +101524,10 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); + assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* FlattenLevel.All */); } else { - assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -101100,7 +101544,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -101109,11 +101553,11 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) { - if (node.flags & 3 /* BlockScoped */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */ || node.transformFlags & 524288 /* TransformFlags.ContainsBindingPattern */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var declarations = ts.flatMap(node.declarations, node.flags & 1 /* Let */ + var declarations = ts.flatMap(node.declarations, node.flags & 1 /* NodeFlags.Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration); var declarationList = factory.createVariableDeclarationList(declarations); @@ -101122,7 +101566,7 @@ var ts; ts.setCommentRange(declarationList, node); // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. - if (node.transformFlags & 524288 /* ContainsBindingPattern */ + if (node.transformFlags & 524288 /* TransformFlags.ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -101188,18 +101632,18 @@ var ts; // * Why loop initializer is excluded? // - Since we've introduced a fresh name it already will be undefined. var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 262144 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 524288 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 + var isCapturedInFunction = flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + var emittedAsTopLevel = (hierarchyFacts & 64 /* HierarchyFacts.TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); + && (hierarchyFacts & 512 /* HierarchyFacts.IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0 + && (hierarchyFacts & 4096 /* HierarchyFacts.ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0)); + && (hierarchyFacts & (2048 /* HierarchyFacts.ForStatement */ | 4096 /* HierarchyFacts.ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -101226,16 +101670,16 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var ancestorFacts = enterSubtree(32 /* HierarchyFacts.ExportedVariableStatement */, 0 /* HierarchyFacts.None */); var updated; if (ts.isBindingPattern(node.name)) { - updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* FlattenLevel.All */, + /*value*/ undefined, (ancestorFacts & 32 /* HierarchyFacts.ExportedVariableStatement */) !== 0); } else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function recordLabel(node) { @@ -101255,50 +101699,50 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function visitDoOrWhileStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(0 /* HierarchyFacts.DoOrWhileStatementExcludes */, 1280 /* HierarchyFacts.DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } function visitForStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(5056 /* HierarchyFacts.ForStatementExcludes */, 3328 /* HierarchyFacts.ForStatementIncludes */, node, outermostLabeledStatement); } function visitEachChildOfForStatement(node) { return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); } function visitForInStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; var initializer = node.initializer; if (ts.isVariableDeclarationList(initializer)) { - if (node.initializer.flags & 3 /* BlockScoped */) { + if (node.initializer.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* FlattenLevel.All */, boundValue); var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old @@ -101346,7 +101790,7 @@ var ts; } function createSyntheticBlockForConvertedStatements(statements) { return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), - /*multiLine*/ true), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: @@ -101378,18 +101822,18 @@ var ts; var counter = factory.createLoopVariable(); var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); + ts.setEmitFlags(expression, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(expression)); var forStatement = ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(counter, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(factory.createVariableDeclaration(rhsReference, /*exclamationToken*/ undefined, /*type*/ undefined, expression), node.expression) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression), /*incrementor*/ ts.setTextRange(factory.createPostfixIncrement(counter), node.expression), /*statement*/ convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)), /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } @@ -101405,33 +101849,33 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 1024 /* IterationContainer */ + var initializer = ancestorFacts & 1024 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values]) : values; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result, /*exclamationToken*/ undefined, /*type*/ undefined, next) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), /*incrementor*/ factory.createAssignment(result, next), /*statement*/ convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([ factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* EmitFlags.SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } /** @@ -101446,9 +101890,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 1048576 /* ContainsYield */ && - hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) { + if ((property.transformFlags & 1048576 /* TransformFlags.ContainsYield */ && + hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* SyntaxKind.ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -101461,7 +101905,7 @@ var ts; var temp = factory.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* Indented */ : 0)); + var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* EmitFlags.Indented */ : 0)); if (node.multiLine) { ts.startOnNewLine(assignment); } @@ -101473,7 +101917,7 @@ var ts; return factory.inlineExpressions(expressions); } function shouldConvertPartOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 131072 /* ContainsCapturedBlockScopeBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */) !== 0; } function shouldConvertInitializerOfForStatement(node) { return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer); @@ -101489,7 +101933,7 @@ var ts; || shouldConvertInitializerOfForStatement(node); } function shouldConvertBodyOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */) !== 0; } /** * Records constituents of name for the given variable to be hoisted in the outer scope. @@ -101500,7 +101944,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -101520,7 +101964,7 @@ var ts; // we get here if we are trying to emit normal loop loop inside converted loop // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + convertedLoopState.allowedNonLabeledJumps = 2 /* Jump.Break */ | 4 /* Jump.Continue */; } var result = convert ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts) @@ -101564,11 +102008,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 242 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 243 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 244 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 240 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 241 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 242 /* SyntaxKind.ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 243 /* SyntaxKind.ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 244 /* SyntaxKind.ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 240 /* SyntaxKind.DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 241 /* SyntaxKind.WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -101593,11 +102037,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -101606,7 +102050,7 @@ var ts; var loopParameters = []; // variables declared in the loop initializer that will be changed inside the loop var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) { var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) || shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node); @@ -101719,15 +102163,15 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0; - var emitFlags = 0 /* None */; + var containsYield = (node.initializer.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 0 /* EmitFlags.None */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && hierarchyFacts & 4 /* AsyncFunctionBody */) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; var statements = []; statements.push(factory.createVariableStatement(/*modifiers*/ undefined, node.initializer)); - copyOutParameters(currentState.loopOutParameters, 2 /* Initializer */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 2 /* LoopOutParameterFlags.Initializer */, 1 /* CopyDirection.ToOutParameter */, statements); // This transforms the following ES2015 syntax: // // for (let i = (setImmediate(() => console.log(i)), 0); i < 2; i++) { @@ -101753,12 +102197,12 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, ts.visitNode(factory.createBlock(statements, /*multiLine*/ true), visitor, ts.isBlock)), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } @@ -101820,7 +102264,7 @@ var ts; statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue())))); } if (shouldConvertConditionOfForStatement(node)) { - statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); + statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -101829,17 +102273,17 @@ var ts; else { statements.push(statement); } - copyOutParameters(currentState.loopOutParameters, 1 /* Body */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 1 /* CopyDirection.ToOutParameter */, statements); ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment); var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0; - var emitFlags = 524288 /* ReuseTempVariableScope */; + var containsYield = (node.statement.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 524288 /* EmitFlags.ReuseTempVariableScope */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && (hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) !== 0) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; // This transforms the following ES2015 syntax (in addition to other variations): // // for (let i = 0; i < 2; i++) { @@ -101859,18 +102303,18 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); + var source = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.originalName : outParam.outParamName; + return factory.createBinaryExpression(target, 63 /* SyntaxKind.EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -101883,7 +102327,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = factory.createCallExpression(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; return factory.createExpressionStatement(callResult); } @@ -101892,27 +102336,27 @@ var ts; // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop // simple loops are emitted as just 'loop()'; // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Jump.Continue */) && !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = factory.createCallExpression(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; if (isSimpleLoop) { statements.push(factory.createExpressionStatement(callResult)); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); } else { var loopResultName = factory.createUniqueName("state"); var stateVariable = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, /*exclamationToken*/ undefined, /*type*/ undefined, callResult)])); statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Jump.Return */) { var returnStatement = void 0; if (outerState) { - outerState.nonLocalJumps |= 8 /* Return */; + outerState.nonLocalJumps |= 8 /* Jump.Return */; returnStatement = factory.createReturnStatement(loopResultName); } else { @@ -101920,7 +102364,7 @@ var ts; } statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement)); } - if (state.nonLocalJumps & 2 /* Break */) { + if (state.nonLocalJumps & 2 /* Jump.Break */) { statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { @@ -101979,19 +102423,19 @@ var ts; else { loopParameters.push(factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); var checkFlags = resolver.getNodeCheckFlags(decl); - if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { var outParamName = factory.createUniqueName("out_" + ts.idText(name)); var flags = 0; - if (checkFlags & 4194304 /* NeedsLoopOutParameter */) { - flags |= 1 /* Body */; + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */) { + flags |= 1 /* LoopOutParameterFlags.Body */; } if (ts.isForStatement(container)) { if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) { - flags |= 2 /* Initializer */; + flags |= 2 /* LoopOutParameterFlags.Initializer */; } if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) || container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) { - flags |= 1 /* Body */; + flags |= 1 /* LoopOutParameterFlags.Body */; } } loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName }); @@ -102013,20 +102457,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -102081,14 +102525,14 @@ var ts; return expression; } function visitCatchClause(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated; ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = factory.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* FlattenLevel.All */, temp); var list = factory.createVariableDeclarationList(vars); ts.setTextRange(list, node.variableDeclaration); var destructure = factory.createVariableStatement(/*modifiers*/ undefined, list); @@ -102097,7 +102541,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function addStatementToStartOfBlock(block, statement) { @@ -102116,7 +102560,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); - ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 512 /* EmitFlags.NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } @@ -102129,17 +102573,17 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.modifiers, node.name, parameters, node.type, body); } else { updated = factory.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -102182,11 +102626,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { + if (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 106 /* SuperKeyword */ || + if (expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -102259,7 +102703,7 @@ var ts; // }()) // var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); - if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) { + if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression); } // The underlying call (3) is another IIFE that may contain a '_super' argument. @@ -102316,15 +102760,15 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. - if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || - node.expression.kind === 106 /* SuperKeyword */ || + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */ || + node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 106 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + ts.setEmitFlags(thisArg, 4 /* EmitFlags.NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 32768 /* ContainsRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -102338,7 +102782,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -102350,12 +102794,12 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); + resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis - ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) + ? factory.createAssignment(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), initializer) : initializer; } return ts.setOriginalNode(resultingCall, node); @@ -102444,13 +102888,13 @@ var ts; } } var helpers = emitHelpers(); - var startsWithSpread = segments[0].kind !== 0 /* None */; + var startsWithSpread = segments[0].kind !== 0 /* SpreadSegmentKind.None */; var expression = startsWithSpread ? factory.createArrayLiteralExpression() : segments[0].expression; for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) { var segment = segments[i]; // If this is for an argument list, it doesn't matter if the array is packed or sparse - expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList); + expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !isArgumentList); } return expression; } @@ -102466,12 +102910,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); // We don't need to pack already packed array literals, or existing calls to the `__read` helper. var isCallToReadHelper = ts.isCallToHelper(expression, "___read"); - var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */; + var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* SpreadSegmentKind.PackedSpread */ : 1 /* SpreadSegmentKind.UnpackedSpread */; // We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`. - if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { + if (compilerOptions.downlevelIteration && kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { expression = emitHelpers().createReadHelper(expression, /*count*/ undefined); // the `__read` helper returns a packed array, so we don't need to ensure a packed array - kind = 2 /* PackedSpread */; + kind = 2 /* SpreadSegmentKind.PackedSpread */; } return createSpreadSegment(kind, expression); } @@ -102479,7 +102923,7 @@ var ts; var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); // We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to // `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements` - return createSpreadSegment(0 /* None */, expression); + return createSpreadSegment(0 /* SpreadSegmentKind.None */, expression); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -102509,7 +102953,7 @@ var ts; * @param node A string literal. */ function visitNumericLiteral(node) { - if (node.numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) { + if (node.numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { return ts.setTextRange(factory.createNumericLiteral(node.text), node); } return node; @@ -102544,15 +102988,15 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ + return hierarchyFacts & 8 /* HierarchyFacts.NonStaticClassElement */ && !isExpressionOfCall - ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") - : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), "prototype") + : factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { - hierarchyFacts |= 32768 /* NewTarget */; - return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */ && node.name.escapedText === "target") { + hierarchyFacts |= 32768 /* HierarchyFacts.NewTarget */; + return factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } return node; } @@ -102564,13 +103008,13 @@ var ts; * @param emitCallback The callback used to emit the node. */ function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ - ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ - : 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, ts.getEmitFlags(node) & 8 /* EmitFlags.CapturesThis */ + ? 65 /* HierarchyFacts.FunctionIncludes */ | 16 /* HierarchyFacts.CapturesThis */ + : 65 /* HierarchyFacts.FunctionIncludes */); previousOnEmitNode(hint, node, emitCallback); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return; } previousOnEmitNode(hint, node, emitCallback); @@ -102580,9 +103024,9 @@ var ts; * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* ES2015SubstitutionFlags.BlockScopedBindings */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } /** @@ -102590,16 +103034,16 @@ var ts; * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(108 /* ThisKeyword */); - context.enableEmitNotification(171 /* Constructor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(214 /* ArrowFunction */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(256 /* FunctionDeclaration */); + if ((enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* ES2015SubstitutionFlags.CapturedThis */; + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(214 /* SyntaxKind.ArrowFunction */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); } } /** @@ -102610,7 +103054,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -102624,7 +103068,7 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return ts.setTextRange(factory.getGeneratedNameForNode(original), node); @@ -102640,10 +103084,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -102656,9 +103100,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -102669,7 +103113,7 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node); @@ -102706,9 +103150,9 @@ var ts; * @param node The ThisKeyword node. */ function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && hierarchyFacts & 16 /* CapturesThis */) { - return ts.setTextRange(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ + && hierarchyFacts & 16 /* HierarchyFacts.CapturesThis */) { + return ts.setTextRange(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node); } return node; } @@ -102725,19 +103169,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* SyntaxKind.ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SyntaxKind.SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SyntaxKind.SpreadElement */) { return false; } var expression = callArgument.expression; @@ -102760,18 +103204,18 @@ var ts; // enable emit notification only if using --jsx preserve or react-native var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + if (compilerOptions.jsx === 1 /* JsxEmit.Preserve */ || compilerOptions.jsx === 3 /* JsxEmit.ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(280 /* JsxOpeningElement */); - context.enableEmitNotification(281 /* JsxClosingElement */); - context.enableEmitNotification(279 /* JsxSelfClosingElement */); + context.enableEmitNotification(280 /* SyntaxKind.JsxOpeningElement */); + context.enableEmitNotification(281 /* SyntaxKind.JsxClosingElement */); + context.enableEmitNotification(279 /* SyntaxKind.JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(296 /* PropertyAssignment */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(296 /* SyntaxKind.PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -102790,9 +103234,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -102852,7 +103296,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -103032,11 +103476,11 @@ var ts; })(Instruction || (Instruction = {})); function getInstructionName(instruction) { switch (instruction) { - case 2 /* Return */: return "return"; - case 3 /* Break */: return "break"; - case 4 /* Yield */: return "yield"; - case 5 /* YieldStar */: return "yield*"; - case 7 /* Endfinally */: return "endfinally"; + case 2 /* Instruction.Return */: return "return"; + case 3 /* Instruction.Break */: return "break"; + case 4 /* Instruction.Yield */: return "yield"; + case 5 /* Instruction.YieldStar */: return "yield*"; + case 7 /* Instruction.Endfinally */: return "endfinally"; default: return undefined; // TODO: GH#18217 } } @@ -103090,7 +103534,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 2048 /* TransformFlags.ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -103113,7 +103557,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 2048 /* ContainsGenerator */) { + else if (transformFlags & 2048 /* TransformFlags.ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -103127,13 +103571,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -103146,30 +103590,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitBreakStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 1048576 /* ContainsYield */) { + if (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (2048 /* TransformFlags.ContainsGenerator */ | 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -103184,23 +103628,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitConditionalExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -103213,9 +103657,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -103373,13 +103817,13 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 1048576 /* ContainsYield */) { + if (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -103404,9 +103848,9 @@ var ts; function visitBinaryExpression(node) { var assoc = ts.getExpressionAssociativity(node); switch (assoc) { - case 0 /* Left */: + case 0 /* Associativity.Left */: return visitLeftAssociativeBinaryExpression(node); - case 1 /* Right */: + case 1 /* Associativity.Right */: return visitRightAssociativeBinaryExpression(node); default: return ts.Debug.assertNever(assoc); @@ -103422,7 +103866,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // [source] // a.b = yield; // @@ -103434,7 +103878,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // [source] // a[b] = yield; // @@ -103466,7 +103910,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 27 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return visitCommaExpression(node); } // [source] @@ -103500,13 +103944,13 @@ var ts; visit(node.right); return factory.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { visit(node.left); visit(node.right); } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -103523,12 +103967,12 @@ var ts; var pendingExpressions = []; for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var elem = _a[_i]; - if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { pendingExpressions.push(visitCommaExpression(elem)); } else { if (containsYield(elem) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression)); @@ -103573,7 +104017,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -103639,7 +104083,7 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { // NOTE: `expression` must be defined for `yield*`. - var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* EmitFlags.Iterator */) === 0 ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node) : expression; emitYieldStar(iterator, /*location*/ node); @@ -103828,35 +104272,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return transformAndEmitBlock(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return transformAndEmitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return transformAndEmitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return transformAndEmitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return transformAndEmitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return transformAndEmitForInStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return transformAndEmitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return transformAndEmitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return transformAndEmitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return transformAndEmitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return transformAndEmitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -104286,7 +104730,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 290 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -104299,7 +104743,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -104431,7 +104875,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -104444,7 +104888,7 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; @@ -104475,7 +104919,7 @@ var ts; return node; } function cacheExpression(node) { - if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return node; } var temp = factory.createTempVariable(hoistVariableDeclaration); @@ -104521,7 +104965,7 @@ var ts; blockStack = []; } var index = blockActions.length; - blockActions[index] = 0 /* Open */; + blockActions[index] = 0 /* BlockAction.Open */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.push(block); @@ -104535,7 +104979,7 @@ var ts; if (block === undefined) return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; - blockActions[index] = 1 /* Close */; + blockActions[index] = 1 /* BlockAction.Close */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.pop(); @@ -104564,7 +105008,7 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 1 /* With */, + kind: 1 /* CodeBlockKind.With */, expression: expression, startLabel: startLabel, endLabel: endLabel @@ -104574,7 +105018,7 @@ var ts; * Ends a code block for a generated `with` statement. */ function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); + ts.Debug.assert(peekBlockKind() === 1 /* CodeBlockKind.With */); var block = endBlock(); markLabel(block.endLabel); } @@ -104586,8 +105030,8 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, + kind: 0 /* CodeBlockKind.Exception */, + state: 0 /* ExceptionBlockState.Try */, startLabel: startLabel, endLabel: endLabel }); @@ -104600,7 +105044,7 @@ var ts; * @param variable The catch variable. */ function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); // generated identifiers should already be unique within a file var name; if (ts.isGeneratedIdentifier(variable.name)) { @@ -104613,18 +105057,18 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); + ts.Debug.assert(exception.state < 1 /* ExceptionBlockState.Catch */); var endLabel = exception.endLabel; emitBreak(endLabel); var catchLabel = defineLabel(); markLabel(catchLabel); - exception.state = 1 /* Catch */; + exception.state = 1 /* ExceptionBlockState.Catch */; exception.catchVariable = name; exception.catchLabel = catchLabel; emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), /*typeArguments*/ undefined, [])); @@ -104634,24 +105078,24 @@ var ts; * Enters the `finally` block of a generated `try` statement. */ function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); + ts.Debug.assert(exception.state < 2 /* ExceptionBlockState.Finally */); var endLabel = exception.endLabel; emitBreak(endLabel); var finallyLabel = defineLabel(); markLabel(finallyLabel); - exception.state = 2 /* Finally */; + exception.state = 2 /* ExceptionBlockState.Finally */; exception.finallyLabel = finallyLabel; } /** * Ends the code block for a generated `try` statement. */ function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = endBlock(); var state = exception.state; - if (state < 2 /* Finally */) { + if (state < 2 /* ExceptionBlockState.Finally */) { emitBreak(exception.endLabel); } else { @@ -104659,7 +105103,7 @@ var ts; } markLabel(exception.endLabel); emitNop(); - exception.state = 3 /* Done */; + exception.state = 3 /* ExceptionBlockState.Done */; } /** * Begins a code block that supports `break` or `continue` statements that are defined in @@ -104669,7 +105113,7 @@ var ts; */ function beginScriptLoopBlock() { beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: true, breakLabel: -1, continueLabel: -1 @@ -104686,7 +105130,7 @@ var ts; function beginLoopBlock(continueLabel) { var breakLabel = defineLabel(); beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: false, breakLabel: breakLabel, continueLabel: continueLabel, @@ -104698,7 +105142,7 @@ var ts; * generated code or in the source tree. */ function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + ts.Debug.assert(peekBlockKind() === 3 /* CodeBlockKind.Loop */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -104712,7 +105156,7 @@ var ts; */ function beginScriptSwitchBlock() { beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: true, breakLabel: -1 }); @@ -104725,7 +105169,7 @@ var ts; function beginSwitchBlock() { var breakLabel = defineLabel(); beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: false, breakLabel: breakLabel, }); @@ -104735,7 +105179,7 @@ var ts; * Ends a code block that supports `break` statements that are defined in generated code. */ function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + ts.Debug.assert(peekBlockKind() === 2 /* CodeBlockKind.Switch */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -104744,7 +105188,7 @@ var ts; } function beginScriptLabeledBlock(labelText) { beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: true, labelText: labelText, breakLabel: -1 @@ -104753,14 +105197,14 @@ var ts; function beginLabeledBlock(labelText) { var breakLabel = defineLabel(); beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: false, labelText: labelText, breakLabel: breakLabel }); } function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + ts.Debug.assert(peekBlockKind() === 4 /* CodeBlockKind.Labeled */); var block = endBlock(); if (!block.isScript) { markLabel(block.breakLabel); @@ -104772,8 +105216,8 @@ var ts; * @param block A code block. */ function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; + return block.kind === 2 /* CodeBlockKind.Switch */ + || block.kind === 3 /* CodeBlockKind.Loop */; } /** * Indicates whether the provided block supports `break` statements with labels. @@ -104781,7 +105225,7 @@ var ts; * @param block A code block. */ function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; + return block.kind === 4 /* CodeBlockKind.Labeled */; } /** * Indicates whether the provided block supports `continue` statements. @@ -104789,7 +105233,7 @@ var ts; * @param block A code block. */ function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; + return block.kind === 3 /* CodeBlockKind.Loop */; } function hasImmediateContainingLabeledBlock(labelText, start) { for (var j = start; j >= 0; j--) { @@ -104886,7 +105330,7 @@ var ts; */ function createInstruction(instruction) { var literal = factory.createNumericLiteral(instruction); - ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); + ts.addSyntheticTrailingComment(literal, 3 /* SyntaxKind.MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -104898,7 +105342,7 @@ var ts; function createInlineBreak(label, location) { ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) ])), location); } @@ -104910,8 +105354,8 @@ var ts; */ function createInlineReturn(expression, location) { return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), location); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. @@ -104924,7 +105368,7 @@ var ts; * Emits an empty instruction. */ function emitNop() { - emitWorker(0 /* Nop */); + emitWorker(0 /* OpCode.Nop */); } /** * Emits a Statement. @@ -104933,7 +105377,7 @@ var ts; */ function emitStatement(node) { if (node) { - emitWorker(1 /* Statement */, [node]); + emitWorker(1 /* OpCode.Statement */, [node]); } else { emitNop(); @@ -104947,7 +105391,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); + emitWorker(2 /* OpCode.Assign */, [left, right], location); } /** * Emits a Break operation to the specified label. @@ -104956,7 +105400,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); + emitWorker(3 /* OpCode.Break */, [label], location); } /** * Emits a Break operation to the specified label when a condition evaluates to a truthy @@ -104967,7 +105411,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + emitWorker(4 /* OpCode.BreakWhenTrue */, [label, condition], location); } /** * Emits a Break to the specified label when a condition evaluates to a falsey value at @@ -104978,7 +105422,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + emitWorker(5 /* OpCode.BreakWhenFalse */, [label, condition], location); } /** * Emits a YieldStar operation for the provided expression. @@ -104987,7 +105431,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + emitWorker(7 /* OpCode.YieldStar */, [expression], location); } /** * Emits a Yield operation for the provided expression. @@ -104996,7 +105440,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + emitWorker(6 /* OpCode.Yield */, [expression], location); } /** * Emits a Return operation for the provided expression. @@ -105005,7 +105449,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + emitWorker(8 /* OpCode.Return */, [expression], location); } /** * Emits a Throw operation for the provided expression. @@ -105014,13 +105458,13 @@ var ts; * @param location An optional source map location for the assignment. */ function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + emitWorker(9 /* OpCode.Throw */, [expression], location); } /** * Emits an Endfinally operation. This is used to handle `finally` block semantics. */ function emitEndfinally() { - emitWorker(10 /* Endfinally */); + emitWorker(10 /* OpCode.Endfinally */); } /** * Emits an operation. @@ -105064,7 +105508,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, factory.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* EmitFlags.ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -105237,8 +105681,8 @@ var ts; var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; switch (block.kind) { - case 0 /* Exception */: - if (blockAction === 0 /* Open */) { + case 0 /* CodeBlockKind.Exception */: + if (blockAction === 0 /* BlockAction.Open */) { if (!exceptionBlockStack) { exceptionBlockStack = []; } @@ -105248,18 +105692,18 @@ var ts; exceptionBlockStack.push(currentExceptionBlock); currentExceptionBlock = block; } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { currentExceptionBlock = exceptionBlockStack.pop(); } break; - case 1 /* With */: - if (blockAction === 0 /* Open */) { + case 1 /* CodeBlockKind.With */: + if (blockAction === 0 /* BlockAction.Open */) { if (!withBlockStack) { withBlockStack = []; } withBlockStack.push(block); } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { withBlockStack.pop(); } break; @@ -105283,33 +105727,33 @@ var ts; lastOperationWasAbrupt = false; lastOperationWasCompletion = false; var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { + if (opcode === 0 /* OpCode.Nop */) { return; } - else if (opcode === 10 /* Endfinally */) { + else if (opcode === 10 /* OpCode.Endfinally */) { return writeEndfinally(); } var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { + if (opcode === 1 /* OpCode.Statement */) { return writeStatement(args[0]); } var location = operationLocations[operationIndex]; switch (opcode) { - case 2 /* Assign */: + case 2 /* OpCode.Assign */: return writeAssign(args[0], args[1], location); - case 3 /* Break */: + case 3 /* OpCode.Break */: return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: + case 4 /* OpCode.BreakWhenTrue */: return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: + case 5 /* OpCode.BreakWhenFalse */: return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: + case 6 /* OpCode.Yield */: return writeYield(args[0], location); - case 7 /* YieldStar */: + case 7 /* OpCode.YieldStar */: return writeYieldStar(args[0], location); - case 8 /* Return */: + case 8 /* OpCode.Return */: return writeReturn(args[0], location); - case 9 /* Throw */: + case 9 /* OpCode.Throw */: return writeThrow(args[0], location); } } @@ -105359,8 +105803,8 @@ var ts; lastOperationWasAbrupt = true; lastOperationWasCompletion = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -105371,9 +105815,9 @@ var ts; function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -105384,9 +105828,9 @@ var ts; */ function writeBreakWhenTrue(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -105397,9 +105841,9 @@ var ts; */ function writeBreakWhenFalse(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -105410,8 +105854,8 @@ var ts; function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(4 /* Instruction.Yield */), expression] + : [createInstruction(4 /* Instruction.Yield */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -105422,9 +105866,9 @@ var ts; function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(5 /* YieldStar */), + createInstruction(5 /* Instruction.YieldStar */), expression - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -105432,7 +105876,7 @@ var ts; function writeEndfinally() { lastOperationWasAbrupt = true; writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(7 /* Endfinally */) + createInstruction(7 /* Instruction.Endfinally */) ]))); } } @@ -105459,12 +105903,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(208 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(210 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -105480,7 +105924,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 8388608 /* ContainsDynamicImport */ || + node.transformFlags & 8388608 /* TransformFlags.ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -105616,7 +106060,7 @@ var ts; factory.createIdentifier("exports") ])) ]), - ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* EmitFlags.SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ @@ -105701,7 +106145,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } @@ -105770,13 +106214,13 @@ var ts; if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); statements.push(statement); } } @@ -105792,23 +106236,23 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -105817,30 +106261,30 @@ var ts; function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (8388608 /* TransformFlags.ContainsDynamicImport */ | 4096 /* TransformFlags.ContainsDestructuringAssignment */ | 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -105856,24 +106300,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -105899,7 +106343,7 @@ var ts; } function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded, createAllExportExpressions); } return ts.visitEachChild(node, visitor, context); } @@ -105925,7 +106369,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -105968,7 +106412,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -105995,7 +106439,7 @@ var ts; // }); needUMDDynamicImportHelper = true; if (ts.isSimpleCopiableExpression(arg)) { - var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */); + var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* EmitFlags.NoComments */); return factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, @@ -106031,7 +106475,7 @@ var ts; /*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) ]); var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, parameters, @@ -106049,7 +106493,7 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); @@ -106070,7 +106514,7 @@ var ts; requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, @@ -106090,13 +106534,13 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { @@ -106105,7 +106549,7 @@ var ts; return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { @@ -106152,7 +106596,7 @@ var ts; } } statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), /*location*/ node), /*original*/ node)); } @@ -106166,7 +106610,7 @@ var ts; /*type*/ undefined, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) - ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + ], languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */))); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -106200,7 +106644,7 @@ var ts; ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)); } else { @@ -106210,11 +106654,11 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); } } else { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node)); } } @@ -106255,12 +106699,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && - !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && + !(ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); @@ -106311,7 +106755,7 @@ var ts; */ function visitFunctionDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), /*type*/ undefined, ts.visitEachChild(node.body, visitor, context)), @@ -106338,7 +106782,7 @@ var ts; */ function visitClassDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); } @@ -106364,7 +106808,7 @@ var ts; var statements; var variables; var expressions; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var modifiers = void 0; var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. @@ -106422,7 +106866,7 @@ var ts; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. - ts.setEmitFlags(expression, 4 /* NoSubstitution */); + ts.setEmitFlags(expression, 4 /* EmitFlags.NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; @@ -106437,7 +106881,7 @@ var ts; function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), - /*visitor*/ undefined, context, 0 /* All */, + /*visitor*/ undefined, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAllExportExpressions); } else { @@ -106459,7 +106903,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -106471,7 +106915,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -106514,10 +106958,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -106600,8 +107044,8 @@ var ts; if (currentModuleInfo.exportEquals) { return statements; } - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -106646,7 +107090,7 @@ var ts; } function createUnderscoreUnderscoreESModule() { var statement; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())); } else { @@ -106659,7 +107103,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); return statement; } /** @@ -106674,7 +107118,7 @@ var ts; var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -106686,7 +107130,7 @@ var ts; * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { - return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), + return ts.setTextRange(liveBinding && languageVersion !== 0 /* ScriptTarget.ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), @@ -106713,8 +107157,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -106730,7 +107174,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); @@ -106755,7 +107199,7 @@ var ts; if (node.id && noSubstitution[node.id]) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -106790,13 +107234,13 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); } return node; @@ -106805,9 +107249,9 @@ var ts; if (ts.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); noSubstitution[ts.getNodeId(expression)] = true; - if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateCallExpression(node, expression, - /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.arguments), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -106816,9 +107260,9 @@ var ts; if (ts.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); noSubstitution[ts.getNodeId(tag)] = true; - if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, - /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.template), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -106831,16 +107275,16 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } return node; } - else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -106929,11 +107373,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(231 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(231 /* SyntaxKind.MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -106953,7 +107397,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* TransformFlags.ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -107000,7 +107444,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ]), node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* EmitFlags.NoTrailingComments */); if (!ts.outFile(compilerOptions)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -107122,8 +107566,8 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 - var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ? - factory.createModifiersFromModifierFlags(256 /* Async */) : + var modifiers = node.transformFlags & 2097152 /* TransformFlags.ContainsAwait */ ? + factory.createModifiersFromModifierFlags(256 /* ModifierFlags.Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -107157,7 +107601,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 272 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 272 /* SyntaxKind.ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -107222,7 +107666,7 @@ var ts; factory.createForInStatement(factory.createVariableDeclarationList([ factory.createVariableDeclaration(n) ]), m, factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */) ])), factory.createExpressionStatement(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exports])) @@ -107246,19 +107690,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -107317,13 +107761,13 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); default: return topLevelNestedVisitor(node); @@ -107399,7 +107843,7 @@ var ts; * @param node The node to visit. */ function visitFunctionDeclaration(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock))); @@ -107451,7 +107895,7 @@ var ts; return ts.visitNode(node, visitor, ts.isStatement); } var expressions; - var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; @@ -107501,9 +107945,9 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 305 /* SourceFile */ - || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + return (ts.getEmitFlags(node) & 2097152 /* EmitFlags.NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 305 /* SyntaxKind.SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* NodeFlags.BlockScoped */) === 0); } /** * Transform an initialized variable declaration into an expression. @@ -107514,7 +107958,7 @@ var ts; function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAssignment) : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name; } @@ -107566,9 +108010,9 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); - var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* ModifierFlags.Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); } return node; @@ -107579,7 +108023,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -107628,10 +108072,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -107725,8 +108169,8 @@ var ts; return statements; } var excludeName; - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createStringLiteral("default") : decl.name; + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory.getLocalName(decl)); excludeName = ts.getTextOfIdentifierOrLiteral(exportName); } @@ -107786,7 +108230,7 @@ var ts; var statement = factory.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -107798,7 +108242,7 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name; - ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* EmitFlags.NoComments */); return ts.setCommentRange(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // @@ -107811,43 +108255,43 @@ var ts; */ function topLevelNestedVisitor(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ true); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitDefaultClause(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitTryStatement(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -108029,30 +108473,30 @@ var ts; * @param node The node to visit. */ function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4096 /* TransformFlags.ContainsDestructuringAssignment */ | 8388608 /* TransformFlags.ContainsDynamicImport */ | 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node)) { return visitImportCallExpression(node); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -108102,7 +108546,7 @@ var ts; */ function visitDestructuringAssignment(node, valueIsDiscarded) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); } @@ -108132,7 +108576,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 305 /* SourceFile */; + return container !== undefined && container.kind === 305 /* SyntaxKind.SourceFile */; } else { return false; @@ -108148,7 +108592,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -108193,8 +108637,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -108210,7 +108654,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -108245,10 +108689,10 @@ var ts; if (isSubstitutionPrevented(node)) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } - else if (hint === 4 /* Unspecified */) { + else if (hint === 4 /* EmitHint.Unspecified */) { return substituteUnspecified(node); } return node; @@ -108260,7 +108704,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -108295,11 +108739,11 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return substituteMetaProperty(node); } return node; @@ -108311,7 +108755,7 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); @@ -108389,7 +108833,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -108432,8 +108876,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(305 /* SourceFile */); - context.enableSubstitution(79 /* Identifier */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); var helperNameSubstitutions; var currentSourceFile; var importRequireStatements; @@ -108472,14 +108916,14 @@ var ts; } function visitor(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` // is available, just because the output is reasonable for a node-like runtime. return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -108497,23 +108941,23 @@ var ts; args.push(moduleName); } if (!importRequireStatements) { - var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */); + var createRequireName = factory.createUniqueName("_createRequire", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var importStatement = factory.createImportDeclaration( /*modifiers*/ undefined, factory.createImportClause( /*isTypeOnly*/ false, /*name*/ undefined, factory.createNamedImports([ factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName) ])), factory.createStringLiteral("module")); - var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */); + var requireHelperName = factory.createUniqueName("__require", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var requireStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(requireHelperName, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ - factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) + factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) ])) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)); importRequireStatements = [importStatement, requireStatement]; } var name = importRequireStatements[1].declarationList.declarations[0].name; @@ -108534,12 +108978,12 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); statements = appendExportsOfImportEqualsDeclaration(statements, node); return ts.singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, factory.createExportDeclaration( /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))]))); } @@ -108604,7 +109048,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return substituteHelperName(node); } return node; @@ -108613,7 +109057,7 @@ var ts; var name = ts.idText(node); var substitution = helperNameSubstitutions.get(name); if (!substitution) { - helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */)); + helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)); } return substitution; } @@ -108636,8 +109080,8 @@ var ts; var cjsOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(305 /* SourceFile */); - context.enableEmitNotification(305 /* SourceFile */); + context.enableSubstitution(305 /* SyntaxKind.SourceFile */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); var currentSourceFile; return transformSourceFileOrBundle; function onSubstituteNode(hint, node) { @@ -108684,7 +109128,7 @@ var ts; return result; } function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -108739,14 +109183,14 @@ var ts; function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -108768,14 +109212,14 @@ var ts; function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; @@ -108799,7 +109243,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -108817,31 +109261,31 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind)); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(node.kind))); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 167 /* PropertyDeclaration */ || node.kind === 206 /* PropertyAccessExpression */ || node.kind === 166 /* PropertySignature */ || - (node.kind === 164 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 166 /* SyntaxKind.PropertySignature */ || + (node.kind === 164 /* SyntaxKind.Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */ || node.kind === 164 /* Parameter */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 164 /* SyntaxKind.Parameter */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -108864,7 +109308,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.isStatic(node)) { @@ -108881,14 +109325,14 @@ var ts; else { if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1; @@ -108903,36 +109347,36 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; @@ -108944,9 +109388,9 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -108969,40 +109413,40 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; @@ -109013,61 +109457,61 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 256 /* FunctionDeclaration */: - case 179 /* FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind)); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind))); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 179 /* FunctionType */: - case 256 /* FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -109084,7 +109528,7 @@ var ts; // Heritage clause is written by user so it can always be named if (ts.isClassDeclaration(node.parent.parent)) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0; @@ -109133,7 +109577,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 164 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 164 /* SyntaxKind.Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -109152,13 +109596,13 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* NodeBuilderFlags.MultilineObjectLiterals */ | + 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ | + 4096 /* NodeBuilderFlags.UseTypeOfFunction */ | + 8 /* NodeBuilderFlags.UseStructuralFallback */ | + 524288 /* NodeBuilderFlags.AllowEmptyTuple */ | + 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ | + 1 /* NodeBuilderFlags.NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -109218,7 +109662,7 @@ var ts; } function trackReferencedAmbientModule(node, symbol) { // If it is visible via `// `, then we should just use that - var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* SymbolFlags.All */); if (ts.length(directives)) { return recordTypeReferenceDirectivesIfNecessary(directives); } @@ -109227,7 +109671,7 @@ var ts; refs.set(ts.getOriginalNodeId(container), container); } function handleSymbolAccessibilityError(symbolAccessibilityResult) { - if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccessibilityResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { if (!lateMarkedStatements) { @@ -109263,7 +109707,7 @@ var ts; } } function trackSymbol(symbol, enclosingDeclaration, meaning) { - if (symbol.flags & 262144 /* TypeParameter */) + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) return false; var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); @@ -109339,10 +109783,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 305 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 305 /* SyntaxKind.SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -109365,14 +109809,14 @@ var ts; resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([factory.createModifier(135 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -109509,11 +109953,11 @@ var ts; return ret; } function filterBindingPatternInitializersAndRenamings(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return name; } else { - if (name.kind === 202 /* ArrayBindingPattern */) { + if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -109521,7 +109965,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 227 /* OmittedExpression */) { + if (elem.kind === 227 /* SyntaxKind.OmittedExpression */) { return elem; } if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) { @@ -109538,7 +109982,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } - var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* SyntaxKind.QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -109555,7 +109999,7 @@ var ts; return undefined; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { // Private nodes emit no types (except private parameter properties, whose parameter types are actually visible) return; } @@ -109563,19 +110007,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 164 /* Parameter */ && + var shouldUseResolverType = node.kind === 164 /* SyntaxKind.Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return factory.createKeywordTypeNode(130 /* AnyKeyword */); + return factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -109583,12 +110027,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 164 /* Parameter */ - || node.kind === 167 /* PropertyDeclaration */ - || node.kind === 166 /* PropertySignature */) { + if (node.kind === 164 /* SyntaxKind.Parameter */ + || node.kind === 167 /* SyntaxKind.PropertyDeclaration */ + || node.kind === 166 /* SyntaxKind.PropertySignature */) { if (ts.isPropertySignature(node) || !node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -109599,28 +110043,28 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !getBindingNameVisible(node); - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return false; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; } return false; @@ -109647,7 +110091,7 @@ var ts; } } function updateParamsList(node, params, modifierMask) { - if (ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); @@ -109683,7 +110127,7 @@ var ts; return factory.createNodeArray(newParams || ts.emptyArray); } function ensureTypeParams(node, params) { - return ts.hasEffectiveModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); + return ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } function isEnclosingDeclaration(node) { return ts.isSourceFile(node) @@ -109709,7 +110153,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* ModuleDeclaration */ && parent.kind !== 200 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && parent.kind !== 200 /* SyntaxKind.ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -109729,7 +110173,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, decl.modifiers, decl.isTypeOnly, decl.name, factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); @@ -109754,7 +110198,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } - if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; @@ -109799,7 +110243,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.Debug.formatSyntaxKind(i.kind))); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -109857,10 +110301,10 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* TypeLiteral */ || input.kind === 195 /* MappedType */) && input.parent.kind !== 259 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* SyntaxKind.TypeLiteral */ || input.kind === 195 /* SyntaxKind.MappedType */) && input.parent.kind !== 259 /* SyntaxKind.TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { - if (ts.hasEffectiveModifier(input, 8 /* Private */)) { + if (ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload return cleanup(factory.createPropertyDeclaration(ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); @@ -109878,28 +110322,28 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 228 /* ExpressionWithTypeArguments */: { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( - /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* None */), + /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* ModifierFlags.None */), /*body*/ undefined); return cleanup(ctor); } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -109908,44 +110352,44 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 172 /* GetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(factory.updateGetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), + return cleanup(factory.updateGetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 173 /* SetAccessor */: { + case 173 /* SyntaxKind.SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } - return cleanup(factory.updateSetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), + return cleanup(factory.updateSetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), /*body*/ undefined)); } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 176 /* IndexSignature */: { - return cleanup(factory.updateIndexSignature(input, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */))); + case 176 /* SyntaxKind.IndexSignature */: { + return cleanup(factory.updateIndexSignature(input, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */))); } - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -109953,13 +110397,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 163 /* TypeParameter */: { + case 163 /* SyntaxKind.TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 189 /* ConditionalType */: { + case 189 /* SyntaxKind.ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -109971,22 +110415,22 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 179 /* FunctionType */: { + case 179 /* SyntaxKind.FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 180 /* ConstructorType */: { + case 180 /* SyntaxKind.ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 200 /* ImportType */: { + case 200 /* SyntaxKind.ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind)); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(input.kind))); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { - ts.setEmitFlags(input, 1 /* SingleLine */); + ts.setEmitFlags(input, 1 /* EmitFlags.SingleLine */); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { @@ -110009,7 +110453,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 169 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -110019,7 +110463,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 272 /* ExportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -110028,17 +110472,17 @@ var ts; // Rewrite external module names if necessary return factory.updateExportDeclaration(input, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 79 /* Identifier */) { + if (input.expression.kind === 79 /* SyntaxKind.Identifier */) { return input; } else { - var newId = factory.createUniqueName("_default", 16 /* Optimistic */); + var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input @@ -110046,7 +110490,7 @@ var ts; errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); preserveJsDoc(statement, input); ts.removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.modifiers, newId)]; @@ -110059,12 +110503,12 @@ var ts; return input; } function stripExportModifiers(statement) { - if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* Default */) || !ts.canHaveModifiers(statement)) { + if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) { // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (257023 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (257023 /* ModifierFlags.All */ ^ 1 /* ModifierFlags.Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { @@ -110075,10 +110519,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -110099,12 +110543,12 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 258 /* InterfaceDeclaration */: { + case 258 /* SyntaxKind.InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), @@ -110112,7 +110556,7 @@ var ts; if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration - var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace_1, enclosingDeclaration); fakespace_1.locals = ts.createSymbolTable(props); fakespace_1.symbol = props[0].parent; @@ -110131,10 +110575,10 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* SyntaxKind.ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { - declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); + declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* ModifierFlags.None */); }); } else { declarations.push(factory.createExportDeclaration( @@ -110144,11 +110588,11 @@ var ts; return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); })))); } - var namespaceDecl = factory.createModuleDeclaration(ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */); - if (!ts.hasEffectiveModifier(clean, 512 /* Default */)) { + var namespaceDecl = factory.createModuleDeclaration(ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* NodeFlags.Namespace */); + if (!ts.hasEffectiveModifier(clean, 512 /* ModifierFlags.Default */)) { return [clean, namespaceDecl]; } - var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ExportDefault */) | 2 /* Ambient */); + var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ModifierFlags.ExportDefault */) | 2 /* ModifierFlags.Ambient */); var cleanDeclaration = factory.updateFunctionDeclaration(clean, modifiers, /*asteriskToken*/ undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, /*body*/ undefined); @@ -110166,17 +110610,17 @@ var ts; return clean; } } - case 261 /* ModuleDeclaration */: { + case 261 /* SyntaxKind.ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 262 /* ModuleBlock */) { + if (inner && inner.kind === 262 /* SyntaxKind.ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 16777216 /* Ambient */) { + if (input.flags & 16777216 /* NodeFlags.Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -110210,7 +110654,7 @@ var ts; return cleanup(factory.updateModuleDeclaration(input, mods, input.name, body)); } } - case 257 /* ClassDeclaration */: { + case 257 /* SyntaxKind.ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -110220,10 +110664,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ModifierFlags.ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 79 /* Identifier */) { + if (param.name.kind === 79 /* SyntaxKind.Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration(ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } else { @@ -110262,26 +110706,26 @@ var ts; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* SyntaxKind.NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16 /* Optimistic */); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 94 /* ExtendsKeyword */) { + if (clause.token === 94 /* SyntaxKind.ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* SyntaxKind.NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 } @@ -110290,10 +110734,10 @@ var ts; return cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 260 /* EnumDeclaration */: { + case 260 /* SyntaxKind.EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -110304,7 +110748,7 @@ var ts; } } // Anything left unhandled is an error, so this should be unreachable - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind)); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.Debug.formatSyntaxKind(input.kind))); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -110312,7 +110756,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 261 /* ModuleDeclaration */) { + if (input.kind === 261 /* SyntaxKind.ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -110335,7 +110779,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 227 /* OmittedExpression */) { + if (e.kind === 227 /* SyntaxKind.OmittedExpression */) { return; } if (e.name) { @@ -110383,12 +110827,12 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 257023 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files - var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 305 /* SourceFile */; + var mask = 257023 /* ModifierFlags.All */ ^ (4 /* ModifierFlags.Public */ | 256 /* ModifierFlags.Async */ | 16384 /* ModifierFlags.Override */); // No async and override modifiers in declaration files + var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* ModifierFlags.Ambient */ : 0 /* ModifierFlags.None */; + var parentIsFile = node.parent.kind === 305 /* SyntaxKind.SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { - mask ^= 2 /* Ambient */; - additions = 0 /* None */; + mask ^= 2 /* ModifierFlags.Ambient */; + additions = 0 /* ModifierFlags.None */; } return maskModifierFlags(node, mask, additions); } @@ -110408,13 +110852,13 @@ var ts; } function transformHeritageClauses(nodes) { return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* SyntaxKind.ExtendsKeyword */ && t.expression.kind === 104 /* SyntaxKind.NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return true; } return false; @@ -110424,22 +110868,22 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 257023 /* All */ ^ 4 /* Public */; } - if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } + if (modifierMask === void 0) { modifierMask = 257023 /* ModifierFlags.All */ ^ 4 /* ModifierFlags.Public */; } + if (modifierAdditions === void 0) { modifierAdditions = 0 /* ModifierFlags.None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; - if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { + if (flags & 512 /* ModifierFlags.Default */ && !(flags & 1 /* ModifierFlags.Export */)) { // A non-exported default is a nonsequitor - we usually try to remove all export modifiers // from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid - flags ^= 1 /* Export */; + flags ^= 1 /* ModifierFlags.Export */; } - if (flags & 512 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) + if (flags & 512 /* ModifierFlags.Default */ && flags & 2 /* ModifierFlags.Ambient */) { + flags ^= 2 /* ModifierFlags.Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) } return flags; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 172 /* GetAccessor */ + return accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -110448,52 +110892,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return !ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */); + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 237 /* VariableStatement */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 254 /* VariableDeclaration */: - case 163 /* TypeParameter */: - case 228 /* ExpressionWithTypeArguments */: - case 178 /* TypeReference */: - case 189 /* ConditionalType */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 200 /* ImportType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 189 /* SyntaxKind.ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 200 /* SyntaxKind.ImportType */: return true; } return false; @@ -110551,35 +110995,35 @@ var ts; if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); } - if (languageVersion < 99 /* ESNext */) { + if (languageVersion < 99 /* ScriptTarget.ESNext */) { transformers.push(ts.transformESNext); } - if (languageVersion < 8 /* ES2021 */) { + if (languageVersion < 8 /* ScriptTarget.ES2021 */) { transformers.push(ts.transformES2021); } - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { transformers.push(ts.transformES2020); } - if (languageVersion < 6 /* ES2019 */) { + if (languageVersion < 6 /* ScriptTarget.ES2019 */) { transformers.push(ts.transformES2019); } - if (languageVersion < 5 /* ES2018 */) { + if (languageVersion < 5 /* ScriptTarget.ES2018 */) { transformers.push(ts.transformES2018); } - if (languageVersion < 4 /* ES2017 */) { + if (languageVersion < 4 /* ScriptTarget.ES2017 */) { transformers.push(ts.transformES2017); } - if (languageVersion < 3 /* ES2016 */) { + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { transformers.push(ts.transformES2016); } - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { transformers.push(ts.transformES5); } ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory)); @@ -110633,11 +111077,11 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(355 /* Count */); + var enabledSyntaxKindFeatures = new Array(355 /* SyntaxKind.Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; - var lexicalEnvironmentFlags = 0 /* None */; + var lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var lexicalEnvironmentStatementsStack = []; @@ -110650,7 +111094,7 @@ var ts; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; - var state = 0 /* Uninitialized */; + var state = 0 /* TransformationState.Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer // initialization. @@ -110680,13 +111124,13 @@ var ts; isEmitNotificationEnabled: isEmitNotificationEnabled, get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onEmitNode = value; }, @@ -110710,17 +111154,17 @@ var ts; return node; }; // prevent modification of transformation hooks. - state = 1 /* Initialized */; + state = 1 /* TransformationState.Initialized */; // Transform each node. var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 305 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "transformNodes", node.kind === 305 /* SyntaxKind.SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. - state = 2 /* Completed */; + state = 2 /* TransformationState.Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { @@ -110738,15 +111182,15 @@ var ts; * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 1 /* SyntaxKindFeatureFlags.Substitution */; } /** * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 - && (ts.getEmitFlags(node) & 4 /* NoSubstitution */) === 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* SyntaxKindFeatureFlags.Substitution */) !== 0 + && (ts.getEmitFlags(node) & 4 /* EmitFlags.NoSubstitution */) === 0; } /** * Emits a node with possible substitution. @@ -110756,23 +111200,23 @@ var ts; * @param emitCallback The callback used to emit the node or its substitute. */ function substituteNode(hint, node) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot substitute a node after the result is disposed."); return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 2 /* SyntaxKindFeatureFlags.EmitNotifications */; } /** * Determines whether before/after emit notifications should be raised in the pretty * printer when it emits a node. */ function isEmitNotificationEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (ts.getEmitFlags(node) & 2 /* AdviseOnEmitNode */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 2 /* SyntaxKindFeatureFlags.EmitNotifications */) !== 0 + || (ts.getEmitFlags(node) & 2 /* EmitFlags.AdviseOnEmitNode */) !== 0; } /** * Emits a node with possible emit notification. @@ -110782,7 +111226,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { // TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed // (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739) @@ -110798,26 +111242,26 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* NoNestedSourceMaps */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* EmitFlags.NoNestedSourceMaps */); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; } else { lexicalEnvironmentVariableDeclarations.push(decl); } - if (lexicalEnvironmentFlags & 1 /* InParameters */) { - lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */; + if (lexicalEnvironmentFlags & 1 /* LexicalEnvironmentFlags.InParameters */) { + lexicalEnvironmentFlags |= 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */; } } /** * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(func, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(func, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -110829,9 +111273,9 @@ var ts; * Adds an initialization statement to the top of the lexical environment. */ function addInitializationStatement(node) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(node, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(node, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentStatements) { lexicalEnvironmentStatements = [node]; } @@ -110844,8 +111288,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -110859,19 +111303,19 @@ var ts; lexicalEnvironmentVariableDeclarations = undefined; lexicalEnvironmentFunctionDeclarations = undefined; lexicalEnvironmentStatements = undefined; - lexicalEnvironmentFlags = 0 /* None */; + lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -110880,8 +111324,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || @@ -110893,7 +111337,7 @@ var ts; if (lexicalEnvironmentVariableDeclarations) { var statement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); if (!statements) { statements = [statement]; } @@ -110936,8 +111380,8 @@ var ts; * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. */ function startBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot start a block scope after transformation has completed."); blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; blockScopeStackOffset++; blockScopedVariableDeclarations = undefined; @@ -110946,12 +111390,12 @@ var ts; * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. */ function endBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot end a block scope after transformation has completed."); var statements = ts.some(blockScopedVariableDeclarations) ? [ factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* NodeFlags.Let */)) ] : undefined; blockScopeStackOffset--; blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; @@ -110965,8 +111409,8 @@ var ts; (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); } function requestEmitHelper(helper) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); if (helper.dependencies) { for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) { @@ -110977,14 +111421,14 @@ var ts; emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } function dispose() { - if (state < 3 /* Disposed */) { + if (state < 3 /* TransformationState.Disposed */) { // Clean up emit nodes on parse tree for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; @@ -110999,7 +111443,7 @@ var ts; onEmitNode = undefined; emitHelpers = undefined; // Prevent further use of the transformation result. - state = 3 /* Disposed */; + state = 3 /* TransformationState.Disposed */; } } } @@ -111038,7 +111482,7 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ function isBuildInfoFile(file) { - return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + return ts.fileExtensionIs(file, ".tsbuildinfo" /* Extension.TsBuildInfo */); } ts.isBuildInfoFile = isBuildInfoFile; /*@internal*/ @@ -111104,7 +111548,7 @@ var ts; ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : configFileExtensionLess; } - return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + return buildInfoExtensionLess + ".tsbuildinfo" /* Extension.TsBuildInfo */; } ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ @@ -111112,7 +111556,7 @@ var ts; var outPath = ts.outFile(options); var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; @@ -111121,7 +111565,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 306 /* Bundle */) { + if (sourceFile.kind === 306 /* SyntaxKind.Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -111129,7 +111573,7 @@ var ts; var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it var isJsonEmittedToSameLocation = isJsonFile && - ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; @@ -111143,11 +111587,11 @@ var ts; } /* @internal */ function getOutputExtension(fileName, options) { - return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : - options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : - ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : - ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : - ".js" /* Js */; + return ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) ? ".json" /* Extension.Json */ : + options.jsx === 1 /* JsxEmit.Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Extension.Jsx */, ".tsx" /* Extension.Tsx */]) ? ".jsx" /* Extension.Jsx */ : + ts.fileExtensionIsOneOf(fileName, [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ".mjs" /* Extension.Mjs */ : + ts.fileExtensionIsOneOf(fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ".cjs" /* Extension.Cjs */ : + ".js" /* Extension.Js */; } ts.getOutputExtension = getOutputExtension; function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) { @@ -111163,9 +111607,9 @@ var ts; function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { if (configFile.options.emitDeclarationOnly) return undefined; - var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options)); - return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? + return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* Comparison.EqualTo */ ? outputFileName : undefined; } @@ -111194,16 +111638,16 @@ var ts; return; var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -111272,7 +111716,7 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { @@ -111282,7 +111726,7 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) return jsFilePath; - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) continue; if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); @@ -111291,7 +111735,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ @@ -111307,7 +111751,6 @@ var ts; var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit; var bundleBuildInfo; var emitSkipped = false; - var exportedModulesFromDeclarationEmit; // Emit each output file enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile); @@ -111317,7 +111760,6 @@ var ts; diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList, - exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; @@ -111329,13 +111771,13 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { @@ -111380,7 +111822,7 @@ var ts; return; } // Make sure not to write js file and source map file if any of them cannot be written - if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) { + if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) { emitSkipped = true; return; } @@ -111409,7 +111851,7 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); if (bundleBuildInfo) @@ -111445,7 +111887,7 @@ var ts; noEmitHelpers: true, module: compilerOptions.module, target: compilerOptions.target, - sourceMap: compilerOptions.sourceMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, @@ -111465,17 +111907,13 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { - sourceMap: !forceDtsEmit && compilerOptions.declarationMap, + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, { + sourceMap: printerOptions.sourceMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) { - var sourceFile = declarationTransform.transformed[0]; - exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; - } } declarationTransform.dispose(); if (bundleBuildInfo) @@ -111483,7 +111921,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -111494,9 +111932,10 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) { + var sourceFileOrBundle = transform.transformed[0]; + var bundle = sourceFileOrBundle.kind === 306 /* SyntaxKind.Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -111521,14 +111960,14 @@ var ts; if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); sourceMapUrlPos = writer.getTextPos(); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); // Tools can sometimes see this line as a source mapping url comment } // Write the source map if (sourceMapFilePath) { var sourceMap = sourceMapGenerator.toString(); ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles); if (printer.bundleFileInfo) - printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); } } else { @@ -111536,17 +111975,17 @@ var ts; } // Write the output file var text = writer.getText(); - ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); + ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics }); // We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo // This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode if (printer.bundleFileInfo) - printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash)); // Reset state writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 305 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Extension.Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -111577,7 +112016,7 @@ var ts; // Encode the sourceMap into the sourceMap url var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -111670,8 +112109,8 @@ var ts; ts.setParent(literal, statement); return statement; }); - var eofToken = ts.factory.createToken(1 /* EndOfFileToken */); - var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* None */); + var eofToken = ts.factory.createToken(1 /* SyntaxKind.EndOfFileToken */); + var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* NodeFlags.None */); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : ""; ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0); @@ -111705,25 +112144,25 @@ var ts; if (!jsFileText) return jsFilePath; // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it - if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) + if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) return jsFilePath; var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); // error if no source map or for now if inline sourcemap if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) return sourceMapFilePath || "inline sourcemap decoding"; - if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) + if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) return sourceMapFilePath; // read declaration text var declarationText = declarationFilePath && host.readFile(declarationFilePath); if (declarationFilePath && !declarationText) return declarationFilePath; - if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) + if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) return declarationFilePath; var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); // error if no source map or for now if inline sourcemap if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) return declarationMapPath || "inline sourcemap decoding"; - if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) + if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) return declarationMapPath; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, @@ -111763,8 +112202,7 @@ var ts; newBuildInfo.program = buildInfo.program; if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) { // Update the output signature - newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash); - newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime(); + newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData); } // Update sourceFileInfo var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; @@ -111786,7 +112224,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -111839,7 +112277,7 @@ var ts; var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined; var recordInternalSection = printerOptions.recordInternalSection; var sourceFileTextPos = 0; - var sourceFileTextKind = "text" /* Text */; + var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -111879,20 +112317,20 @@ var ts; }; function printNode(hint, node, sourceFile) { switch (hint) { - case 0 /* SourceFile */: + case 0 /* EmitHint.SourceFile */: ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); break; - case 2 /* IdentifierName */: + case 2 /* EmitHint.IdentifierName */: ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); break; - case 1 /* Expression */: + case 1 /* EmitHint.Expression */: ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); break; } switch (node.kind) { - case 305 /* SourceFile */: return printFile(node); - case 306 /* Bundle */: return printBundle(node); - case 307 /* UnparsedSource */: return printUnparsedSource(node); + case 305 /* SyntaxKind.SourceFile */: return printFile(node); + case 306 /* SyntaxKind.Bundle */: return printBundle(node); + case 307 /* SyntaxKind.UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -111948,11 +112386,11 @@ var ts; currentSourceFile && (ts.isDeclaration(node) || ts.isVariableStatement(node)) && ts.isInternalDeclaration(node, currentSourceFile) && - sourceFileTextKind !== "internal" /* Internal */) { + sourceFileTextKind !== "internal" /* BundleFileSectionKind.Internal */) { var prevSourceFileTextKind = sourceFileTextKind; recordBundleFileTextLikeSection(writer.getTextPos()); sourceFileTextPos = getTextPosWithWriteLine(); - sourceFileTextKind = "internal" /* Internal */; + sourceFileTextKind = "internal" /* BundleFileSectionKind.Internal */; return prevSourceFileTextKind; } return undefined; @@ -111987,7 +112425,7 @@ var ts; var savedSections = bundleFileInfo && bundleFileInfo.sections; if (savedSections) bundleFileInfo.sections = []; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, prepend, /*sourceFile*/ undefined); if (bundleFileInfo) { var newSections = bundleFileInfo.sections; bundleFileInfo.sections = savedSections; @@ -111998,7 +112436,7 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), - kind: "prepend" /* Prepend */, + kind: "prepend" /* BundleFileSectionKind.Prepend */, data: relativeToBuildInfo(prepend.fileName), texts: newSections }); @@ -112008,7 +112446,7 @@ var ts; sourceFileTextPos = getTextPosWithWriteLine(); for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { var sourceFile = _e[_d]; - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); } if (bundleFileInfo && bundle.sourceFiles.length) { var end = writer.getTextPos(); @@ -112035,7 +112473,7 @@ var ts; function writeUnparsedSource(unparsed, output) { var previousWriter = writer; setWriter(output, /*_sourceMapGenerator*/ undefined); - print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } @@ -112045,7 +112483,7 @@ var ts; setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; } @@ -112084,7 +112522,7 @@ var ts; autoGeneratedIdToGeneratedName = []; generatedNames = new ts.Set(); tempFlagsStack = []; - tempFlags = 0 /* Auto */; + tempFlags = 0 /* TempFlags.Auto */; reservedNamesStack = []; currentSourceFile = undefined; currentLineMap = undefined; @@ -112098,24 +112536,24 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); + pipelineEmit(4 /* EmitHint.Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) return; - pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); + pipelineEmit(2 /* EmitHint.IdentifierName */, node, /*parenthesizerRule*/ undefined); } function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - pipelineEmit(1 /* Expression */, node, parenthesizerRule); + pipelineEmit(1 /* EmitHint.Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* EmitHint.JsxAttributeValue */ : 4 /* EmitHint.Unspecified */, node); } function beforeEmitNode(node) { - if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* EmitFlags.IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } } @@ -112124,7 +112562,7 @@ var ts; } function pipelineEmit(emitHint, node, parenthesizerRule) { currentParenthesizerRule = parenthesizerRule; - var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, emitHint, node); pipelinePhase(emitHint, node); currentParenthesizerRule = undefined; } @@ -112140,12 +112578,12 @@ var ts; } function getPipelinePhase(phase, emitHint, node) { switch (phase) { - case 0 /* Notification */: + case 0 /* PipelinePhase.Notification */: if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) { return pipelineEmitWithNotification; } // falls through - case 1 /* Substitution */: + case 1 /* PipelinePhase.Substitution */: if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { if (currentParenthesizerRule) { lastSubstitution = currentParenthesizerRule(lastSubstitution); @@ -112153,17 +112591,17 @@ var ts; return pipelineEmitWithSubstitution; } // falls through - case 2 /* Comments */: + case 2 /* PipelinePhase.Comments */: if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through - case 3 /* SourceMaps */: + case 3 /* PipelinePhase.SourceMaps */: if (shouldEmitSourceMaps(node)) { return pipelineEmitWithSourceMaps; } // falls through - case 4 /* Emit */: + case 4 /* PipelinePhase.Emit */: return pipelineEmitWithHint; default: return ts.Debug.assertNever(phase); @@ -112173,7 +112611,7 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); + var pipelinePhase = getNextPipelinePhase(0 /* PipelinePhase.Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { @@ -112199,346 +112637,346 @@ var ts; return emitSnippetNode(hint, node, snippet); } } - if (hint === 0 /* SourceFile */) + if (hint === 0 /* EmitHint.SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); - if (hint === 2 /* IdentifierName */) + if (hint === 2 /* EmitHint.IdentifierName */) return emitIdentifier(ts.cast(node, ts.isIdentifier)); - if (hint === 6 /* JsxAttributeValue */) + if (hint === 6 /* EmitHint.JsxAttributeValue */) return emitLiteral(ts.cast(node, ts.isStringLiteral), /*jsxAttributeEscape*/ true); - if (hint === 3 /* MappedTypeParameter */) + if (hint === 3 /* EmitHint.MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); - if (hint === 5 /* EmbeddedStatement */) { + if (hint === 5 /* EmitHint.EmbeddedStatement */) { ts.Debug.assertNode(node, ts.isEmptyStatement); return emitEmptyStatement(/*isEmbeddedStatement*/ true); } - if (hint === 4 /* Unspecified */) { + if (hint === 4 /* EmitHint.Unspecified */) { switch (node.kind) { // Pseudo-literals - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return emitQualifiedName(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return emitTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return emitParameter(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return emitDecorator(node); // Type members - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return emitPropertySignature(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return emitPropertyDeclaration(node); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return emitMethodSignature(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return emitMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return emitClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return emitConstructor(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return emitAccessorDeclaration(node); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return emitCallSignature(node); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return emitConstructSignature(node); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return emitIndexSignature(node); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return emitTypePredicate(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return emitTypeReference(node); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return emitFunctionType(node); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return emitConstructorType(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return emitTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return emitTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return emitArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return emitTupleType(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return emitUnionType(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return emitIntersectionType(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return emitConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return emitInferType(node); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return emitParenthesizedType(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return emitThisType(); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return emitTypeOperator(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return emitIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return emitMappedType(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return emitLiteralType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return emitNamedTupleMember(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return emitTemplateType(node); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return emitImportTypeNode(node); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return emitBindingElement(node); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return emitTemplateSpan(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return emitBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return emitVariableStatement(node); - case 236 /* EmptyStatement */: + case 236 /* SyntaxKind.EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return emitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return emitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return emitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return emitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return emitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return emitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return emitForOfStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return emitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return emitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return emitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return emitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return emitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return emitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return emitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return emitTryStatement(node); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return emitVariableDeclaration(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return emitVariableDeclarationList(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return emitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return emitClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return emitEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return emitModuleDeclaration(node); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return emitModuleBlock(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return emitCaseBlock(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return emitImportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return emitImportClause(node); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return emitNamespaceImport(node); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return emitNamespaceExport(node); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: return emitNamedImports(node); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return emitImportSpecifier(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return emitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return emitExportDeclaration(node); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: return emitNamedExports(node); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return emitExportSpecifier(node); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return emitAssertClause(node); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return emitAssertEntry(node); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return; // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return emitJsxText(node); - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 281 /* JsxClosingElement */: - case 284 /* JsxClosingFragment */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 284 /* SyntaxKind.JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return emitJsxAttribute(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return emitJsxAttributes(node); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return emitJsxExpression(node); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return emitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return emitDefaultClause(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return emitHeritageClause(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return emitCatchClause(node); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return emitPropertyAssignment(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return emitEnumMember(node); // Unparsed - case 300 /* UnparsedPrologue */: + case 300 /* SyntaxKind.UnparsedPrologue */: return writeUnparsedNode(node); - case 307 /* UnparsedSource */: - case 301 /* UnparsedPrepend */: + case 307 /* SyntaxKind.UnparsedSource */: + case 301 /* SyntaxKind.UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return emitUnparsedTextLike(node); - case 304 /* UnparsedSyntheticReference */: + case 304 /* SyntaxKind.UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return emitSourceFile(node); - case 306 /* Bundle */: + case 306 /* SyntaxKind.Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 308 /* InputFiles */: + case 308 /* SyntaxKind.InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return emitJSDocNameReference(node); - case 312 /* JSDocAllType */: + case 312 /* SyntaxKind.JSDocAllType */: return writePunctuation("*"); - case 313 /* JSDocUnknownType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return writePunctuation("?"); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return emitJSDocNullableType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return emitJSDocOptionalType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return emitJSDocFunctionType(node); - case 186 /* RestType */: - case 318 /* JSDocVariadicType */: + case 186 /* SyntaxKind.RestType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 319 /* JSDocNamepathType */: + case 319 /* SyntaxKind.JSDocNamepathType */: return; - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return emitJSDoc(node); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return emitJSDocSignature(node); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 337 /* JSDocOverrideTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 337 /* SyntaxKind.JSDocOverrideTag */: return emitJSDocSimpleTag(node); - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 330 /* JSDocAuthorTag */: - case 331 /* JSDocDeprecatedTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: return; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 339 /* JSDocEnumTag */: - case 341 /* JSDocReturnTag */: - case 342 /* JSDocThisTag */: - case 343 /* JSDocTypeTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 349 /* NotEmittedStatement */: - case 353 /* EndOfDeclarationMarker */: - case 352 /* MergeDeclarationMarker */: + case 349 /* SyntaxKind.NotEmittedStatement */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { - hint = 1 /* Expression */; + hint = 1 /* EmitHint.Expression */; if (substituteNode !== ts.noEmitSubstitution) { var substitute = substituteNode(hint, node) || node; if (substitute !== node) { @@ -112550,101 +112988,101 @@ var ts; } } } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { switch (node.kind) { // Literals - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return emitNumericOrBigIntLiteral(node); - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Expressions - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return emitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return emitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return emitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return emitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return emitArrowFunction(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return emitDeleteExpression(node); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return emitTypeOfExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return emitVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return emitAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return emitBinaryExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return emitConditionalExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return emitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return emitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return emitSpreadElement(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return emitClassExpression(node); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return emitAsExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return emitNonNullExpression(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return emitMetaProperty(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return emitJsxElement(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 349 /* NotEmittedStatement */: + case 349 /* SyntaxKind.NotEmittedStatement */: return; - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return emitCommaList(node); - case 352 /* MergeDeclarationMarker */: - case 353 /* EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return; - case 354 /* SyntheticReferenceExpression */: + case 354 /* SyntaxKind.SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -112652,7 +113090,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -112662,7 +113100,7 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); + var pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, hint, node); ts.Debug.assertIsDefined(lastSubstitution); node = lastSubstitution; lastSubstitution = undefined; @@ -112692,7 +113130,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 306 /* Bundle */ ? node : undefined; + var bundle = node.kind === 306 /* SyntaxKind.Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -112734,7 +113172,7 @@ var ts; writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* BundleFileSectionKind.EmitHelpers */, data: helper.name }); helpersEmitted = true; } } @@ -112762,7 +113200,7 @@ var ts; function emitLiteral(node, jsxAttributeEscape) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* SyntaxKind.StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -112792,9 +113230,9 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* SyntaxKind.UnparsedText */ ? + "text" /* BundleFileSectionKind.Text */ : + "internal" /* BundleFileSectionKind.Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -112813,25 +113251,25 @@ var ts; // function emitSnippetNode(hint, node, snippet) { switch (snippet.kind) { - case 1 /* Placeholder */: + case 1 /* SnippetKind.Placeholder */: emitPlaceholder(hint, node, snippet); break; - case 0 /* TabStop */: + case 0 /* SnippetKind.TabStop */: emitTabStop(hint, node, snippet); break; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); // `${2:` + nonEscapingWrite("${".concat(snippet.order, ":")); // `${2:` pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` nonEscapingWrite("}"); // `}` // `${2:...}` } function emitTabStop(hint, node, snippet) { // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text. - ts.Debug.assert(node.kind === 236 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); - ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + ts.Debug.assert(node.kind === 236 /* SyntaxKind.EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); + ts.Debug.assert(hint !== 5 /* EmitHint.EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); + nonEscapingWrite("$".concat(snippet.order)); } // // Identifiers @@ -112839,7 +113277,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* ListFormat.TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -112854,7 +113292,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112890,7 +113328,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 317 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -112951,7 +113389,7 @@ var ts; } function emitAccessorDeclaration(node) { emitDecoratorsAndModifiers(node, node.modifiers); - writeKeyword(node.kind === 172 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 172 /* SyntaxKind.GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -113056,8 +113494,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineTypeLiteralMembers */ : 32897 /* ListFormat.MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* ListFormat.NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -113070,16 +113508,16 @@ var ts; emit(node.type); } function emitTupleType(node) { - emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */; - emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); - emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.pos, writePunctuation, node); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 528 /* ListFormat.SingleLineTupleTypeElements */ : 657 /* ListFormat.MultiLineTupleTypeElements */; + emitList(node, node.elements, flags | 524288 /* ListFormat.NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.elements.end, writePunctuation, node); } function emitNamedTupleMember(node) { emit(node.dotDotDotToken); emit(node.name); emit(node.questionToken); - emitTokenWithComment(58 /* ColonToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.name.end, writePunctuation, node); writeSpace(); emit(node.type); } @@ -113088,10 +113526,10 @@ var ts; writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); + emitList(node, node.types, 516 /* ListFormat.UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); + emitList(node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); } function emitConditionalType(node) { emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType); @@ -113124,7 +113562,7 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ? + var parenthesizerRule = node.operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizer.parenthesizeOperandOfReadonlyTypeOperator : parenthesizer.parenthesizeOperandOfTypeOperator; emit(node.type, parenthesizerRule); @@ -113138,7 +113576,7 @@ var ts; function emitMappedType(node) { var emitFlags = ts.getEmitFlags(node); writePunctuation("{"); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { @@ -113147,13 +113585,13 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 145 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* EmitHint.MappedTypeParameter */, node.typeParameter); if (node.nameType) { writeSpace(); writeKeyword("as"); @@ -113163,7 +113601,7 @@ var ts; writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 57 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { writePunctuation("?"); } } @@ -113171,14 +113609,14 @@ var ts; writeSpace(); emit(node.type); writeTrailingSemicolon(); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { writeLine(); decreaseIndent(); } - emitList(node, node.members, 2 /* PreserveLines */); + emitList(node, node.members, 2 /* ListFormat.PreserveLines */); writePunctuation("}"); } function emitLiteralType(node) { @@ -113186,7 +113624,7 @@ var ts; } function emitTemplateType(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitImportTypeNode(node) { if (node.isTypeOf) { @@ -113205,7 +113643,7 @@ var ts; writePunctuation(":"); writeSpace(); var elements = node.assertions.assertClause.elements; - emitList(node.assertions.assertClause, elements, 526226 /* ImportClauseEntries */); + emitList(node.assertions.assertClause, elements, 526226 /* ListFormat.ImportClauseEntries */); writeSpace(); writePunctuation("}"); } @@ -113221,12 +113659,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ListFormat.ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ListFormat.ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -113244,29 +113682,29 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + emitExpressionList(node, elements, 8914 /* ListFormat.ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ScriptTarget.ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* ListFormat.AllowTrailingComma */ : 0 /* ListFormat.None */; + emitList(node, node.properties, 526226 /* ListFormat.ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); } } function emitPropertyAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); - var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos); + var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* SyntaxKind.DotToken */), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + var shouldEmitDotDot = token.kind !== 28 /* SyntaxKind.QuestionDotToken */ && mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); @@ -113292,7 +113730,7 @@ var ts; var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true, /*jsxAttributeEscape*/ false); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* SyntaxKind.DotToken */)); } else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer @@ -113305,12 +113743,12 @@ var ts; function emitElementAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); - emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -113323,17 +113761,17 @@ var ts; } emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* SyntaxKind.NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 18960 /* ListFormat.NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -113355,12 +113793,12 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); - emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -113378,22 +113816,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* SyntaxKind.DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* SyntaxKind.TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* SyntaxKind.VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(132 /* SyntaxKind.AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -113418,9 +113856,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 219 /* PrefixUnaryExpression */ - && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) - || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); + return operand.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ + && ((node.operator === 39 /* SyntaxKind.PlusToken */ && (operand.operator === 39 /* SyntaxKind.PlusToken */ || operand.operator === 45 /* SyntaxKind.PlusPlusToken */)) + || (node.operator === 40 /* SyntaxKind.MinusToken */ && (operand.operator === 40 /* SyntaxKind.MinusToken */ || operand.operator === 46 /* SyntaxKind.MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); @@ -113461,12 +113899,12 @@ var ts; return maybeEmitExpression(next, parent, "left"); } function onOperator(operatorToken, _state, node) { - var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */; + var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken); var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(operatorToken.pos); - writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); } @@ -113497,11 +113935,11 @@ var ts; var parenthesizerRule = side === "left" ? parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, 1 /* EmitHint.Expression */, next); if (pipelinePhase === pipelineEmitWithSubstitution) { ts.Debug.assertIsDefined(lastSubstitution); next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); - pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, 1 /* EmitHint.Expression */, next); lastSubstitution = undefined; } if (pipelinePhase === pipelineEmitWithComments || @@ -113512,7 +113950,7 @@ var ts; } } currentParenthesizerRule = parenthesizerRule; - pipelinePhase(1 /* Expression */, next); + pipelinePhase(1 /* EmitHint.Expression */, next); } } function emitConditionalExpression(node) { @@ -113534,15 +113972,15 @@ var ts; } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* SyntaxKind.YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma); } function emitSpreadElement(node) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { @@ -113585,10 +114023,10 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineBlockStatements */ : 129 /* ListFormat.MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* ListFormat.MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -113614,16 +114052,16 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SyntaxKind.IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 239 /* IfStatement */) { + emitTokenWithComment(91 /* SyntaxKind.ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 239 /* SyntaxKind.IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -113633,14 +114071,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* SyntaxKind.WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* SyntaxKind.DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -113656,45 +114094,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* SyntaxKind.InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(160 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(160 /* SyntaxKind.OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { emit(node); } else { @@ -113703,12 +114141,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* SyntaxKind.ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* SyntaxKind.BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -113731,13 +114169,13 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 288 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function commentWillEmitNewLine(node) { - return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; + return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; } function willEmitLeadingNewLine(node) { if (!currentSourceFile) @@ -113777,40 +114215,40 @@ var ts; return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node)); } function emitReturnStatement(node) { - emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* SyntaxKind.ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* SyntaxKind.WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SyntaxKind.SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* SyntaxKind.ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* SyntaxKind.TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -113819,13 +114257,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* SyntaxKind.FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* SyntaxKind.DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -113841,7 +114279,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 528 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* ListFormat.VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -113858,7 +114296,7 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } @@ -113895,7 +114333,7 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (ts.getEmitFlags(body) & 1 /* SingleLine */) { + if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) { return true; } if (body.multiLine) { @@ -113904,14 +114342,14 @@ var ts; if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (getLeadingLineTerminatorCount(body, ts.firstOrUndefined(body.statements), 2 /* PreserveLines */) - || getClosingLineTerminatorCount(body, ts.lastOrUndefined(body.statements), 2 /* PreserveLines */, body.statements)) { + if (getLeadingLineTerminatorCount(body, ts.firstOrUndefined(body.statements), 2 /* ListFormat.PreserveLines */) + || getClosingLineTerminatorCount(body, ts.lastOrUndefined(body.statements), 2 /* ListFormat.PreserveLines */, body.statements)) { return false; } var previousStatement; for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { var statement = _b[_a]; - if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) { + if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) { return false; } previousStatement = statement; @@ -113928,7 +114366,7 @@ var ts; : emitBlockFunctionBodyWorker; emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); - writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* SyntaxKind.CloseBraceToken */, body.statements.end, writePunctuation, body); onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { @@ -113941,11 +114379,11 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* ListFormat.SingleLineFunctionBodyStatements */); increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); + emitList(body, body.statements, 1 /* ListFormat.MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -113959,15 +114397,15 @@ var ts; writeSpace(); emitIdentifierName(node.name); } - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); + emitList(node, node.heritageClauses, 0 /* ListFormat.ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* ClassMembers */); + emitList(node, node.members, 129 /* ListFormat.ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -113979,10 +114417,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 512 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* ListFormat.HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* InterfaceMembers */); + emitList(node, node.members, 129 /* ListFormat.InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -114004,13 +114442,13 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 145 /* EnumMembers */); + emitList(node, node.members, 145 /* ListFormat.EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 1024 /* GlobalAugmentation */) { - writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); + if (~node.flags & 1024 /* NodeFlags.GlobalAugmentation */) { + writeKeyword(node.flags & 16 /* NodeFlags.Namespace */ ? "namespace" : "module"); writeSpace(); } emit(node.name); @@ -114032,27 +114470,27 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 129 /* CaseBlockClauses */); - emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* ListFormat.CaseBlockClauses */); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -114061,12 +114499,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(156 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -114077,20 +114515,20 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -114101,37 +114539,37 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression, node.isExportEquals ? - parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* SyntaxKind.EqualsToken */) : parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(152 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(156 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -114141,10 +114579,10 @@ var ts; writeTrailingSemicolon(); } function emitAssertClause(node) { - emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(129 /* SyntaxKind.AssertKeyword */, node.pos, writeKeyword, node); writeSpace(); var elements = node.elements; - emitList(node, elements, 526226 /* ImportClauseEntries */); + emitList(node, elements, 526226 /* ListFormat.ImportClauseEntries */); } function emitAssertEntry(node) { emit(node.name); @@ -114152,26 +114590,26 @@ var ts; writeSpace(); var value = node.value; /** @see {emitPropertyAssignment} */ - if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(value) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(value); emitTrailingCommentsOfPosition(commentRange.pos); } emit(value); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(142 /* SyntaxKind.NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); } function emitNamespaceExport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -114183,7 +114621,7 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { @@ -114194,7 +114632,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -114213,7 +114651,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -114226,7 +114664,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -114255,7 +114693,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 262656 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* ListFormat.JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -114286,17 +114724,17 @@ var ts; if (isMultiline) { writer.increaseIndent(); } - var end = emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + var end = emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); emit(node.dotDotDotToken); emitExpression(node.expression); - emitTokenWithComment(19 /* CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); if (isMultiline) { writer.decreaseIndent(); } } } function emitJsxTagName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -114307,13 +114745,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* SyntaxKind.CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -114324,14 +114762,14 @@ var ts; ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 163969 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* ListFormat.CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 128 /* Indented */); + format &= ~(1 /* ListFormat.MultiLine */ | 128 /* ListFormat.Indented */); } else { - emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -114339,15 +114777,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 528 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* ListFormat.HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* SyntaxKind.CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -114367,7 +114805,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(initializer) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -114384,7 +114822,7 @@ var ts; } function emitSpreadAssignment(node) { if (node.expression) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } @@ -114415,12 +114853,12 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 343 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 343 /* SyntaxKind.JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } else { - emitList(node, node.tags, 33 /* JSDocComment */); + emitList(node, node.tags, 33 /* ListFormat.JSDocComment */); } } writeSpace(); @@ -114454,13 +114892,13 @@ var ts; emitJSDocTagName(tag.tagName); emitJSDocTypeExpression(tag.constraint); writeSpace(); - emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitList(tag, tag.typeParameters, 528 /* ListFormat.CommaListElements */); emitJSDocComment(tag.comment); } function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 309 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -114479,7 +114917,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 322 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 322 /* SyntaxKind.JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -114497,14 +114935,14 @@ var ts; emitJSDocComment(tag.comment); } function emitJSDocTypeLiteral(lit) { - emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* ListFormat.JSDocComment */); } function emitJSDocSignature(sig) { if (sig.typeParameters) { - emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* ListFormat.JSDocComment */); } if (sig.parameters) { - emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* ListFormat.JSDocComment */); } if (sig.type) { writeLine(); @@ -114585,21 +115023,21 @@ var ts; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -114607,28 +115045,28 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* BundleFileSectionKind.Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_23 = types; _d < types_23.length; _d++) { var directive = types_23[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* BundleFileSectionKind.Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */ : "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* BundleFileSectionKind.Lib */, data: directive.fileName }); writeLine(); } } @@ -114639,22 +115077,22 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* ListFormat.MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes function emitPartiallyEmittedExpression(node) { var emitFlags = ts.getEmitFlags(node); - if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) { + if (!(emitFlags & 512 /* EmitFlags.NoLeadingComments */) && node.pos !== node.expression.pos) { emitTrailingCommentsOfPosition(node.expression.pos); } emitExpression(node.expression); - if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) { + if (!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */) && node.end !== node.expression.end) { emitLeadingCommentsOfPosition(node.expression.end); } } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); + emitExpressionList(node, node.elements, 528 /* ListFormat.CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -114675,7 +115113,7 @@ var ts; var pos = writer.getTextPos(); emit(statement); if (recordBundleFileSection && bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.add(statement.expression.text); } @@ -114696,7 +115134,7 @@ var ts; var pos = writer.getTextPos(); emit(prologue); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: prologue.data }); if (seenPrologueDirectives) { seenPrologueDirectives.add(prologue.data); } @@ -114820,7 +115258,7 @@ var ts; textRange.pos = modifiers.pos; if (pos === modifiers.length - 1) textRange.end = modifiers.end; - emitNodeListItems(emit, node, modifiers, lastMode === "modifiers" ? 2359808 /* Modifiers */ : 2146305 /* Decorators */, + emitNodeListItems(emit, node, modifiers, lastMode === "modifiers" ? 2359808 /* ListFormat.Modifiers */ : 2146305 /* ListFormat.Decorators */, /*parenthesizerRule*/ undefined, start, pos - start, /*hasTrailingComma*/ false, textRange); start = pos; @@ -114831,7 +115269,7 @@ var ts; } } function emitModifiers(node, modifiers) { - emitList(node, modifiers, 2359808 /* Modifiers */); + emitList(node, modifiers, 2359808 /* ListFormat.Modifiers */); } function emitTypeAnnotation(node) { if (node) { @@ -114843,7 +115281,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node, parenthesizerRule); } @@ -114873,7 +115311,7 @@ var ts; } } function emitEmbeddedStatement(parent, node) { - if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* EmitFlags.SingleLine */) { writeSpace(); emit(node); } @@ -114881,7 +115319,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - pipelineEmit(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmitHint.EmbeddedStatement */, node); } else { emit(node); @@ -114890,19 +115328,19 @@ var ts; } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 2146305 /* Decorators */); + emitList(parentNode, decorators, 2146305 /* ListFormat.Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector); + emitList(parentNode, typeArguments, 53776 /* ListFormat.TypeArguments */, typeArgumentParenthesizerRuleSelector); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures return emitTypeArguments(parentNode, parentNode.typeArguments); } - emitList(parentNode, typeParameters, 53776 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* ListFormat.TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 2576 /* Parameters */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -114921,32 +115359,32 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */ & ~2048 /* ListFormat.Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* ListFormat.IndexSignatureParameters */); } function writeDelimiter(format) { - switch (format & 60 /* DelimitersMask */) { - case 0 /* None */: + switch (format & 60 /* ListFormat.DelimitersMask */) { + case 0 /* ListFormat.None */: break; - case 16 /* CommaDelimited */: + case 16 /* ListFormat.CommaDelimited */: writePunctuation(","); break; - case 4 /* BarDelimited */: + case 4 /* ListFormat.BarDelimited */: writeSpace(); writePunctuation("|"); break; - case 32 /* AsteriskDelimited */: + case 32 /* ListFormat.AsteriskDelimited */: writeSpace(); writePunctuation("*"); writeSpace(); break; - case 8 /* AmpersandDelimited */: + case 8 /* ListFormat.AmpersandDelimited */: writeSpace(); writePunctuation("&"); break; @@ -114962,16 +115400,16 @@ var ts; if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; - if (isUndefined && format & 16384 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* ListFormat.OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 32768 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* ListFormat.OptionalIfEmpty */) { onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); return; } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists @@ -114980,10 +115418,10 @@ var ts; onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { + if (format & 1 /* ListFormat.MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } - else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */ && !(format & 524288 /* ListFormat.NoSpaceIfEmpty */)) { writeSpace(); } } @@ -114991,7 +115429,7 @@ var ts; emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, children.hasTrailingComma, children); } onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } @@ -115005,18 +115443,18 @@ var ts; */ function emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, hasTrailingComma, childrenTextRange) { // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* ListFormat.NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format); if (leadingLineTerminatorCount) { writeLine(leadingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (format & 256 /* SpaceBetweenBraces */) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { increaseIndent(); } var emitListItem = getEmitListItem(emit, parenthesizerRule); @@ -115027,7 +115465,7 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. - if (format & 32 /* AsteriskDelimited */) { + if (format & 32 /* ListFormat.AsteriskDelimited */) { // always write JSDoc in the format "\n *" writeLine(); writeDelimiter(format); @@ -115039,7 +115477,7 @@ var ts; // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + if (format & 60 /* ListFormat.DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -115049,14 +115487,14 @@ var ts; if (separatingLineTerminatorCount > 0) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* ListFormat.LinesMask */ | 128 /* ListFormat.Indented */)) === 0 /* ListFormat.SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(separatingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* ListFormat.SpaceBetweenSiblings */) { writeSpace(); } } @@ -115079,11 +115517,11 @@ var ts; } // Write a trailing comma, if requested. var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; - var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* NoTrailingComments */); - var emitTrailingComma = hasTrailingComma && (format & 64 /* AllowTrailingComma */) && (format & 16 /* CommaDelimited */); + var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */); + var emitTrailingComma = hasTrailingComma && (format & 64 /* ListFormat.AllowTrailingComma */) && (format & 16 /* ListFormat.CommaDelimited */); if (emitTrailingComma) { if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(27 /* CommaToken */, previousSibling.end, writePunctuation, previousSibling); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, previousSibling.end, writePunctuation, previousSibling); } else { writePunctuation(","); @@ -115095,11 +115533,11 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* ListFormat.DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(emitTrailingComma && (childrenTextRange === null || childrenTextRange === void 0 ? void 0 : childrenTextRange.end) ? childrenTextRange.end : previousSibling.end); } // Decrease the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { decreaseIndent(); } recordBundleFileInternalSectionEnd(previousSourceFileTextKind); @@ -115108,7 +115546,7 @@ var ts; if (closingLineTerminatorCount) { writeLine(closingLineTerminatorCount); } - else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) { + else if (format & (2097152 /* ListFormat.SpaceAfterList */ | 256 /* ListFormat.SpaceBetweenBraces */)) { writeSpace(); } } @@ -115190,7 +115628,7 @@ var ts; return pos < 0 ? pos : pos + tokenString.length; } function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) { - if (ts.getEmitFlags(parentNode) & 1 /* SingleLine */) { + if (ts.getEmitFlags(parentNode) & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else if (preserveSourceNewlines) { @@ -115240,8 +115678,8 @@ var ts; } } function getLeadingLineTerminatorCount(parentNode, firstChild, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } if (firstChild === undefined) { @@ -115265,7 +115703,7 @@ var ts; // leading newline to start the modifiers. return 0; } - if (firstChild.kind === 11 /* JsxText */) { + if (firstChild.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } @@ -115282,14 +115720,14 @@ var ts; return 1; } } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { if (previousNode === undefined || nextNode === undefined) { return 0; } - if (nextNode.kind === 11 /* JsxText */) { + if (nextNode.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } @@ -115307,7 +115745,7 @@ var ts; } // If the two nodes are not comparable, add a line terminator based on the format that can indicate // whether new lines are preferred or not. - return format & 65536 /* PreferNewLine */ ? 1 : 0; + return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -115316,11 +115754,11 @@ var ts; else if (ts.getStartsOnNewLine(nextNode)) { return 1; } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getClosingLineTerminatorCount(parentNode, lastChild, format, childrenTextRange) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } if (lastChild === undefined) { @@ -115337,7 +115775,7 @@ var ts; return 1; } } - if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) { + if (format & 1 /* ListFormat.MultiLine */ && !(format & 131072 /* ListFormat.NoTrailingNewLine */)) { return 1; } return 0; @@ -115366,14 +115804,14 @@ var ts; return lines; } function writeLineSeparatorsAndIndentBefore(node, parent) { - var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, 0 /* None */); + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, 0 /* ListFormat.None */); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false); } return !!leadingNewlines; } function writeLineSeparatorsAfter(node, parent) { - var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, 0 /* None */, /*childrenTextRange*/ undefined); + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, 0 /* ListFormat.None */, /*childrenTextRange*/ undefined); if (trailingNewlines) { writeLine(trailingNewlines); } @@ -115382,14 +115820,14 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } function getLinesBetweenNodes(parent, node1, node2) { - if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + if (ts.getEmitFlags(parent) & 131072 /* EmitFlags.NoIndentation */) { return 0; } parent = skipSynthesizedParentheses(parent); @@ -115412,7 +115850,7 @@ var ts; && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node) { - while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -115440,29 +115878,29 @@ var ts; return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) { - if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); } } - var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0) - | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0) - | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0) - | (printerOptions.target && printerOptions.target === 99 /* ESNext */ ? 8 /* AllowNumericSeparator */ : 0); + var flags = (neverAsciiEscape ? 1 /* GetLiteralTextFlags.NeverAsciiEscape */ : 0) + | (jsxAttributeEscape ? 2 /* GetLiteralTextFlags.JsxAttributeEscape */ : 0) + | (printerOptions.terminateUnterminatedLiterals ? 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ : 0) + | (printerOptions.target && printerOptions.target === 99 /* ScriptTarget.ESNext */ ? 8 /* GetLiteralTextFlags.AllowNumericSeparator */ : 0); return ts.getLiteralText(node, currentSourceFile, flags); } /** * Push a new name generation scope. */ function pushNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlagsStack.push(tempFlags); @@ -115473,7 +115911,7 @@ var ts; * Pop the current name generation scope. */ function popNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlags = tempFlagsStack.pop(); @@ -115489,84 +115927,84 @@ var ts; if (!node) return; switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.forEach(node.statements, generateNames); break; - case 250 /* LabeledStatement */: - case 248 /* WithStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: generateNames(node.statement); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: generateNames(node.caseBlock); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: generateNames(node.declarationList); break; - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: generateNameIfNeeded(node.name); - if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: generateNames(node.importClause); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: generateNameIfNeeded(node.name); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: generateNameIfNeeded(node.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.forEach(node.elements, generateNames); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -115575,12 +116013,12 @@ var ts; if (!node) return; switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -115599,7 +116037,7 @@ var ts; * Generate the text for a generated identifier. */ function generateName(name) { - if ((name.autoGenerateFlags & 7 /* KindMask */) === 4 /* Node */) { + if ((name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) === 4 /* GeneratedIdentifierFlags.Node */) { // Node names generate unique names based on their original node // and are cached based on that node's id. return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags); @@ -115638,7 +116076,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */)) { return false; } } @@ -115652,7 +116090,7 @@ var ts; */ function makeTempVariableName(flags, reservedInNestedScopes) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + var name = flags === 268435456 /* TempFlags._i */ ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; if (reservedInNestedScopes) { @@ -115662,12 +116100,12 @@ var ts; } } while (true) { - var count = tempFlags & 268435455 /* CountMask */; + var count = tempFlags & 268435455 /* TempFlags.CountMask */; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { var name = count < 26 - ? "_" + String.fromCharCode(97 /* a */ + count) + ? "_" + String.fromCharCode(97 /* CharacterCodes.a */ + count) : "_" + (count - 26); if (isUniqueName(name)) { if (reservedInNestedScopes) { @@ -115699,7 +116137,7 @@ var ts; } } // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* CharacterCodes._ */) { baseName += "_"; } var i = 1; @@ -115753,48 +116191,48 @@ var ts; if (ts.isIdentifier(node.name)) { return generateNameCached(node.name); } - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } /** * Generates a unique name from a node. */ function generateNameForNode(node, flags) { switch (node.kind) { - case 79 /* Identifier */: - return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: + case 79 /* SyntaxKind.Identifier */: + return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(flags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return generateNameForExportDefault(); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return generateNameForClassExpression(); - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return generateNameForMethodOrAccessor(node); - case 162 /* ComputedPropertyName */: - return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); + case 162 /* SyntaxKind.ComputedPropertyName */: + return makeTempVariableName(0 /* TempFlags.Auto */, /*reserveInNestedScopes*/ true); default: - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } } /** * Generates a unique identifier for a node. */ function makeName(name) { - switch (name.autoGenerateFlags & 7 /* KindMask */) { - case 1 /* Auto */: - return makeTempVariableName(0 /* Auto */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 2 /* Loop */: - return makeTempVariableName(268435456 /* _i */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 3 /* Unique */: - return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); + switch (name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) { + case 1 /* GeneratedIdentifierFlags.Auto */: + return makeTempVariableName(0 /* TempFlags.Auto */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 2 /* GeneratedIdentifierFlags.Loop */: + return makeTempVariableName(268435456 /* TempFlags._i */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 3 /* GeneratedIdentifierFlags.Unique */: + return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* GeneratedIdentifierFlags.FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); } return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -115810,7 +116248,7 @@ var ts; // if "node" is a different generated name (having a different // "autoGenerateId"), use it and stop traversing. if (ts.isIdentifier(node) - && !!(node.autoGenerateFlags & 4 /* Node */) + && !!(node.autoGenerateFlags & 4 /* GeneratedIdentifierFlags.Node */) && node.autoGenerateId !== autoGenerateId) { break; } @@ -115821,7 +116259,7 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var pipelinePhase = getNextPipelinePhase(2 /* PipelinePhase.Comments */, hint, node); var savedContainerPos = containerPos; var savedContainerEnd = containerEnd; var savedDeclarationListContainerEnd = declarationListContainerEnd; @@ -115834,7 +116272,7 @@ var ts; var commentRange = ts.getCommentRange(node); // Emit leading comments emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = true; } } @@ -115842,7 +116280,7 @@ var ts; var emitFlags = ts.getEmitFlags(node); var commentRange = ts.getCommentRange(node); // Emit trailing comments - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = false; } emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); @@ -115856,25 +116294,25 @@ var ts; hasWrittenComment = false; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; // Save current container state on the stack. if ((pos > 0 || end > 0) && pos !== end) { // Emit leading comments if the position is not synthesized and the node // has not opted out from emitting leading comments. if (!skipLeadingComments) { - emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */); } - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. containerPos = pos; } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* NoTrailingComments */) !== 0)) { + if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) { // As above. containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -115884,7 +116322,7 @@ var ts; } function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -115893,18 +116331,18 @@ var ts; declarationListContainerEnd = savedDeclarationListContainerEnd; // Emit trailing comments if the position is not synthesized and the node // has not opted out from emitting leading comments and is an emitted node. - if (!skipTrailingComments && node.kind !== 349 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 349 /* SyntaxKind.NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); } function emitLeadingSynthesizedComment(comment) { - if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasLeadingNewline || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasTrailingNewLine || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } else { @@ -115922,25 +116360,25 @@ var ts; } function writeSynthesizedComment(comment) { var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + var lineMap = comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); } function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; + return comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); var pos = detachedRange.pos, end = detachedRange.end; var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0; + var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0; if (!skipLeadingComments) { emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); } exitComment(); - if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */ && !commentsDisabled) { commentsDisabled = true; emitCallback(node); commentsDisabled = false; @@ -116029,7 +116467,7 @@ var ts; if (hasTrailingNewLine) { writer.writeLine(); } - else if (kind === 3 /* MultiLineCommentTrivia */) { + else if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { writer.writeSpace(" "); } } @@ -116071,7 +116509,7 @@ var ts; emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); - if (kind === 2 /* SingleLineCommentTrivia */) { + if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); // still write a newline for single-line comments, so closing tokens aren't written on the same line } } @@ -116156,7 +116594,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMaps(hint, node) { - var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); + var pipelinePhase = getNextPipelinePhase(3 /* PipelinePhase.SourceMaps */, hint, node); emitSourceMapsBeforeNode(node); pipelinePhase(hint, node); emitSourceMapsAfterNode(node); @@ -116174,12 +116612,12 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 16 /* EmitFlags.NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = true; } } @@ -116189,11 +116627,11 @@ var ts; var sourceMapRange = ts.getSourceMapRange(node); // Emit trailing sourcemap if (!ts.isUnparsedNode(node)) { - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 32 /* EmitFlags.NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } @@ -116246,17 +116684,17 @@ var ts; return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; + var emitFlags = emitNode && emitNode.flags || 0 /* EmitFlags.None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; var source = range && range.source || sourceMapSource; tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 128 /* EmitFlags.NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } tokenPos = emitCallback(token, writer, tokenPos); if (range) tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 256 /* EmitFlags.NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } return tokenPos; @@ -116287,23 +116725,23 @@ var ts; sourceMapSourceIndex = sourceIndex; } function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Extension.Json */); } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[1024 /* Braces */] = ["{", "}"]; - brackets[2048 /* Parenthesis */] = ["(", ")"]; - brackets[4096 /* AngleBrackets */] = ["<", ">"]; - brackets[8192 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* ListFormat.Braces */] = ["{", "}"]; + brackets[2048 /* ListFormat.Parenthesis */] = ["(", ")"]; + brackets[4096 /* ListFormat.AngleBrackets */] = ["<", ">"]; + brackets[8192 /* ListFormat.SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 15360 /* BracketsMask */][0]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 15360 /* BracketsMask */][1]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -116669,7 +117107,7 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; @@ -116678,11 +117116,11 @@ var ts; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) @@ -116704,9 +117142,9 @@ var ts; var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; - if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) || - hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + if (hasSourceFile((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + hasSourceFile((filePathWithoutExtension + ".tsx" /* Extension.Tsx */))) { + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -116739,7 +117177,7 @@ var ts; ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop); var plainInvokeFactory = { watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); }, - watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options); }, + watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* WatchDirectoryFlags.Recursive */) !== 0, options); }, }; var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ? { @@ -116774,36 +117212,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -116813,16 +117251,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -117003,7 +117441,7 @@ var ts; if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output // Cache json or buildInfo - if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { + if (!ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -117014,7 +117452,7 @@ var ts; if (value) return value; var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); - if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */))) { + if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) { sourceFileCache.set(key, sourceFile); } return sourceFile; @@ -117104,12 +117542,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -117197,9 +117635,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -117213,7 +117651,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -117276,7 +117714,7 @@ var ts; var mode = getModeForFileReference(name, containingFileMode); // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -117392,7 +117830,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -117571,22 +118009,33 @@ var ts; * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format */ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { + var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options); + return typeof result === "object" ? result.impliedNodeFormat : result; + } + ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + /*@internal*/ + function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: - return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext : - ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS : - ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : + return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ts.ModuleKind.ESNext : + ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ts.ModuleKind.CommonJS : + ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Extension.Dts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */]) ? lookupFromPackageJson() : undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline default: return undefined; } function lookupFromPackageJson() { - var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options); - return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options); + var packageJsonLocations = []; + state.failedLookupLocations = packageJsonLocations; + state.affectingLocations = packageJsonLocations; + var packageJsonScope = ts.getPackageScopeForPath(fileName, state); + var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope }; } } - ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker; /** @internal */ ts.plainJSErrors = new ts.Set([ // binder errors @@ -117734,7 +118183,7 @@ var ts; var modulesWithElidedImports = new ts.Map(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = new ts.Map(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -117815,16 +118264,16 @@ var ts; forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists; var readFile = host.readFile.bind(host); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structureIsReused; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { @@ -117852,7 +118301,7 @@ var ts; var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); }); for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) { var fileName = _c[_b]; - if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index }); } } @@ -117861,13 +118310,13 @@ var ts; }); } } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferences", { count: typeReferences.length }); // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); @@ -117911,7 +118360,7 @@ var ts; for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { var oldSourceFile = oldSourceFiles_1[_i]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); - if (shouldCreateNewSourceFile || !newFile || + if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || // old file wasn't redirect but new file is (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); @@ -118001,9 +118450,9 @@ var ts; // Add file processingDiagnostics fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) { switch (diagnostic.kind) { - case 1 /* FilePreprocessingFileExplainingDiagnostic */: + case 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */: return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray)); - case 0 /* FilePreprocessingReferencedDiagnostic */: + case 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */: var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end; return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false))); default: @@ -118054,7 +118503,7 @@ var ts; return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); @@ -118069,7 +118518,7 @@ var ts; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode); ts.performance.mark("afterResolveTypeReference"); @@ -118151,7 +118600,7 @@ var ts; return classifiableNames; } function resolveModuleNamesReusingOldState(moduleNames, file) { - if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { + if (structureIsReused === 0 /* StructureIsReused.Not */ && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); @@ -118248,7 +118697,7 @@ var ts; // `result[i]` is either a `ResolvedModuleFull` or a marker. // If it is the former, we can leave it as is. if (result[i] === predictedToResolveToAmbientModuleMarker) { - result[i] = undefined; // TODO: GH#18217 + result[i] = undefined; } } else { @@ -118304,24 +118753,24 @@ var ts; }); } function tryReuseStructureFromOldProgram() { - var _a; + var _a, _b; if (!oldProgram) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); if (ts.changesAffectModuleResolution(oldOptions, options)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // there is an old program, check if we can reuse its structure var oldRootNames = oldProgram.getRootFileNames(); if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); @@ -118329,12 +118778,12 @@ var ts; // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; var modifiedSourceFiles = []; - structureIsReused = 2 /* Completely */; + structureIsReused = 2 /* StructureIsReused.Completely */; // If the missing file paths are now present, it can change the progam structure, // and hence cant reuse the structure. // This is same as how we dont reuse the structure if one of the file from old program is now missing if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } var oldSourceFiles = oldProgram.getSourceFiles(); var SeenPackageName; @@ -118345,12 +118794,15 @@ var ts; var seenPackageNames = new ts.Map(); for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { var oldSourceFile = oldSourceFiles_2[_i]; + var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options); var newSourceFile = host.getSourceFileByPath - ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 + ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat) + : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217 if (!newSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } + newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope; ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; if (oldSourceFile.redirectInfo) { @@ -118358,7 +118810,7 @@ var ts; // This lets us know if the unredirected file has changed. If it has we should break the redirect. if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { // Underlying file has changed. Might not redirect anymore. Must rebuild program. - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; newSourceFile = oldSourceFile; // Use the redirect. @@ -118366,7 +118818,7 @@ var ts; else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) { // If a redirected-to source file changes, the redirect may be broken. if (newSourceFile !== oldSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; } @@ -118383,80 +118835,85 @@ var ts; // If there are 2 different source files for the same package name and at least one of them changes, // they might become redirects. So we must rebuild the program. var prevKind = seenPackageNames.get(packageName); - var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; - if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { - return 0 /* Not */; + var newKind = fileChanged ? 1 /* SeenPackageName.Modified */ : 0 /* SeenPackageName.Exists */; + if ((prevKind !== undefined && newKind === 1 /* SeenPackageName.Modified */) || prevKind === 1 /* SeenPackageName.Modified */) { + return 0 /* StructureIsReused.Not */; } seenPackageNames.set(packageName, newKind); } if (fileChanged) { + if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) { + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } // The `newSourceFile` object was created for the new program. - if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check tripleslash references - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - structureIsReused = 1 /* SafeModules */; - } - // check imports and module augmentations - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { - // imports has changed - structureIsReused = 1 /* SafeModules */; - } - if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { - // moduleAugmentations has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) { - // dynamicImport has changed - structureIsReused = 1 /* SafeModules */; - } - if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { - // 'types' references has changed - structureIsReused = 1 /* SafeModules */; + else { + // check imports and module augmentations + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + // moduleAugmentations has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if ((oldSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */)) { + // dynamicImport has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { + // 'types' references has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else if (hasInvalidatedResolution(oldSourceFile.path)) { // 'module/types' references could have changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; // add file to the modified list so that we will resolve it later modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); - for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) { - var oldFile = oldSourceFiles_3[_b]; + for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) { + var oldFile = oldSourceFiles_3[_c]; if (!ts.contains(modifiedFiles, oldFile)) { - for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) { - var moduleName = _d[_c]; + for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) { + var moduleName = _e[_d]; ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); } } } // try to verify results of module resolution - for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) { - var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile; + for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) { + var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile; var moduleNames = getModuleNames(newSourceFile); var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile); // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions); } else { @@ -118467,24 +118924,24 @@ var ts; // ensure that types resolutions are still correct var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo); if (typeReferenceResolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } - if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { - return 1 /* SafeModules */; + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) { + return 1 /* StructureIsReused.SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length); - for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) { - var newSourceFile = newSourceFiles_1[_g]; + for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) { + var newSourceFile = newSourceFiles_1[_h]; filesByName.set(newSourceFile.path, newSourceFile); } var oldFilesByNameMap = oldProgram.getFilesByNameMap(); @@ -118509,7 +118966,7 @@ var ts; sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules; - return 2 /* Completely */; + return 2 /* StructureIsReused.Completely */; } function getEmitHost(writeFileCallback) { return { @@ -118554,7 +119011,7 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -118606,7 +119063,7 @@ var ts; return typeChecker || (typeChecker = ts.createTypeChecker(program)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -118726,7 +119183,7 @@ var ts; } var typeChecker = getTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); - var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */; + var isJs = sourceFile.scriptKind === 1 /* ScriptKind.JS */ || sourceFile.scriptKind === 2 /* ScriptKind.JSX */; var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options); var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs); var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; @@ -118734,8 +119191,8 @@ var ts; // - plain JS: .js files with no // ts-check and checkJs: undefined // - check JS: .js files with either // ts-check or checkJs: true // - external: files that are added by plugins - var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ - || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* ScriptKind.TS */ || sourceFile.scriptKind === 4 /* ScriptKind.TSX */ + || sourceFile.scriptKind === 5 /* ScriptKind.External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* ScriptKind.Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; if (isPlainJs) { @@ -118814,22 +119271,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 254 /* VariableDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 254 /* SyntaxKind.VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -118837,65 +119294,65 @@ var ts; } } switch (node.kind) { - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type")); return "skip"; } break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: var heritageClause = node; - if (heritageClause.token === 117 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 258 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* SyntaxKind.InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 261 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */); + case 261 /* SyntaxKind.ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* NodeFlags.Namespace */ ? ts.tokenToString(142 /* SyntaxKind.NamespaceKeyword */) : ts.tokenToString(141 /* SyntaxKind.ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 260 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); + case 260 /* SyntaxKind.EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* SyntaxKind.EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -118904,53 +119361,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 237 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 237 /* SyntaxKind.VariableStatement */); return "skip"; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (ts.isModifier(modifier) && modifier.kind !== 124 /* StaticKeyword */) { + if (ts.isModifier(modifier) && modifier.kind !== 124 /* SyntaxKind.StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers && ts.some(nodes, ts.isModifier)) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 210 /* TaggedTemplateExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -118963,27 +119420,27 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 135 /* DeclareKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 124 /* StaticKeyword */: - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: } } } @@ -119053,20 +119510,20 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 79 /* Identifier */ - ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 10 /* StringLiteral */ && a.text === b.text; + return a.kind === 79 /* SyntaxKind.Identifier */ + ? b.kind === 79 /* SyntaxKind.Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* SyntaxKind.StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); var importDecl = ts.factory.createImportDeclaration(/*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); - ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(importDecl, 67108864 /* EmitFlags.NeverApplyImportHelper */); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); // explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them // (which is required to build the dependency graph for incremental emit) - externalHelpersModuleReference.flags &= ~8 /* Synthesized */; - importDecl.flags &= ~8 /* Synthesized */; + externalHelpersModuleReference.flags &= ~8 /* NodeFlags.Synthesized */; + importDecl.flags &= ~8 /* NodeFlags.Synthesized */; return externalHelpersModuleReference; } function collectExternalModuleReferences(file) { @@ -119097,7 +119554,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -119119,7 +119576,7 @@ var ts; } } else if (ts.isModuleDeclaration(node)) { - if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) { node.name.parent = node; var nameText = ts.getTextOfIdentifierOrLiteral(node.name); // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -119174,7 +119631,7 @@ var ts; function getNodeAtPosition(sourceFile, position) { var current = sourceFile; var getContainingChild = function (child) { - if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* EndOfFileToken */)))) { + if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) { return child; } }; @@ -119267,13 +119724,16 @@ var ts; addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]); } } - function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) { + var _a; var redirect = Object.create(redirectTarget); redirect.fileName = fileName; redirect.path = path; redirect.resolvedPath = resolvedPath; redirect.originalFileName = originalFileName; redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + redirect.packageJsonScope = sourceFileOptions.packageJsonScope; sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); Object.defineProperties(redirect, { id: { @@ -119289,7 +119749,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], @@ -119302,14 +119762,14 @@ var ts; // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront. - var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); - return { - languageVersion: ts.getEmitScriptTarget(options), - impliedNodeFormat: impliedNodeFormat, - setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options) - }; + var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); + var languageVersion = ts.getEmitScriptTarget(options); + var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options); + return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) : + { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator }; } function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { + var _a, _b; var path = toPath(fileName); if (useSourceOfProjectReferenceRedirect) { var source = getSourceOfProjectReferenceRedirect(path); @@ -119396,14 +119856,15 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile); + var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options); + var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat)); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. // Instead of creating a duplicate, just redirect to the existing one. - var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217 + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions); redirectTargetsMap.add(fileFromPackageId.path, fileName); addFileToFilesByName(dupFile, path, redirectedPath); addFileIncludeReason(dupFile, reason); @@ -119424,6 +119885,8 @@ var ts; file.path = path; file.resolvedPath = toPath(fileName); file.originalFileName = originalFileName; + file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined; + file.packageJsonScope = sourceFileOptions.packageJsonScope; addFileIncludeReason(file, reason); if (host.useCaseSensitiveFileNames()) { var pathLowerCase = ts.toFileNameLowerCase(path); @@ -119474,7 +119937,7 @@ var ts; } function getProjectReferenceRedirectProject(fileName) { // Ignore dts or any json files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -119484,7 +119947,7 @@ var ts; function getProjectReferenceOutputName(referencedProject, fileName) { var out = ts.outFile(referencedProject.commandLine.options); return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.changeExtension(out, ".d.ts" /* Extension.Dts */) : ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames()); } /** @@ -119517,13 +119980,13 @@ var ts; var out = ts.outFile(resolvedRef.commandLine.options); if (out) { // Dont know which source file it means so return true? - var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + var outputDts = ts.changeExtension(out, ".d.ts" /* Extension.Dts */); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); } else { var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); }); ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -119569,7 +120032,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -119628,7 +120091,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -119648,7 +120111,7 @@ var ts; var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 0 /* FilePreprocessingReferencedDiagnostic */, + kind: 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */, reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }, diagnostic: diagnostic, args: [libName, suggestion] @@ -119695,7 +120158,7 @@ var ts; && index < file.imports.length && !elideImport && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) - && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */)); + && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* NodeFlags.JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -119756,7 +120219,7 @@ var ts; else { // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); - sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + sourceFile = host.getSourceFile(refPath, 100 /* ScriptTarget.JSON */); addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { projectReferenceRedirects.set(sourceFilePath, false); @@ -119896,19 +120359,19 @@ var ts; var languageVersion = ts.getEmitScriptTarget(options); var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ScriptTarget.ES2015 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } if (options.preserveConstEnums === false) { createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules"); } - var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* ScriptKind.JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName))); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ScriptTarget.ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -119947,7 +120410,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + if (options.useDefineForClassFields && languageVersion === 0 /* ScriptTarget.ES3 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !ts.getAllowJSCompilerOption(options)) { @@ -119969,7 +120432,7 @@ var ts; if (options.reactNamespace) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { @@ -119983,7 +120446,7 @@ var ts; if (!options.jsxFactory) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { @@ -119991,12 +120454,12 @@ var ts; } } if (options.reactNamespace) { - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx)); } } if (options.jsxImportSource) { - if (options.jsx === 2 /* React */) { + if (options.jsx === 2 /* JsxEmit.React */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); } } @@ -120054,7 +120517,7 @@ var ts; fileIncludeReasons = undefined; var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason); var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon); - var redirectInfo = file && ts.explainIfFileIsRedirect(file); + var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file); var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false)); return location && isReferenceFileLocation(location) ? ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : @@ -120075,7 +120538,7 @@ var ts; } function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) { (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 1 /* FilePreprocessingFileExplainingDiagnostic */, + kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */, file: file && file.path, fileProcessingReason: fileProcessingReason, diagnostic: diagnostic, @@ -120314,7 +120777,7 @@ var ts; // If options have --outFile or --out just check that var out = ts.outFile(options); if (out) { - return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); + return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Extension.Dts */); } // If declarationDir is specified, return if its a file in that directory if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { @@ -120327,13 +120790,13 @@ var ts; if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || - !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Extension.Tsx */)); } return false; } function isSameFile(file1, file2) { - return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; } function getSymlinkCache() { if (host.getSymlinkCache) { @@ -120434,12 +120897,12 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || // Any parent directory of declaration dir ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || // Any directory inside declaration dir - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -120492,7 +120955,7 @@ var ts; if (isFile && result) { // Store the real path for the file' var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -120588,17 +121051,17 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ".tsx" /* Extension.Tsx */: return needJsx(); - case ".jsx" /* Jsx */: + case ".jsx" /* Extension.Jsx */: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ".js" /* Extension.Js */: return needAllowJs(); - case ".json" /* Json */: + case ".json" /* Extension.Json */: return needResolveJsonModule(); } function needJsx() { @@ -120617,7 +121080,7 @@ var ts; var res = imports.map(function (i) { return i.text; }); for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { var aug = moduleAugmentations_1[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -120632,7 +121095,7 @@ var ts; var augIndex = imports.length; for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) { var aug = moduleAugmentations_2[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { if (index === augIndex) return aug; augIndex++; @@ -120648,8 +121111,8 @@ var ts; (function (ts) { function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit; - return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; + var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics; + return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); } @@ -120873,23 +121336,23 @@ var ts; /** * Gets the files affected by the path from the program */ - function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var _a, _b; - var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash); + var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName); (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear(); (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); return result; } BuilderState.getFilesAffectedBy = getFilesAffectedBy; - function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var sourceFile = programOfThisState.getSourceFileByPath(path); if (!sourceFile) { return ts.emptyArray; } - if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) { + if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) { return [sourceFile]; } - return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash); + return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName); } BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState; function updateSignatureOfFile(state, signature, path) { @@ -120900,7 +121363,7 @@ var ts; /** * Returns if the shape of the signature has changed since last emit */ - function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) { + function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) { var _a; if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; } // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate @@ -120910,18 +121373,16 @@ var ts; var prevSignature = info.signature; var latestSignature; if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) { - var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, - /*emitOnlyDtsFiles*/ true, cancellationToken, - /*customTransformers*/ undefined, - /*forceDtsEmit*/ true); - var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); - if (firstDts_1) { - ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); - latestSignature = computeSignature(firstDts_1.text, computeHash); + programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) { + ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: ".concat(fileName)); + latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data); if (latestSignature !== prevSignature) { - updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit); + updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit); } - } + }, cancellationToken, + /*emitOnlyDtsFiles*/ true, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); } // Default is to use file version as signature if (latestSignature === undefined) { @@ -120944,10 +121405,6 @@ var ts; return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; - function computeSignature(text, computeHash) { - return (computeHash || ts.generateDjb2Hash)(text); - } - BuilderState.computeSignature = computeSignature; /** * Coverts the declaration emit result into exported modules map */ @@ -121097,7 +121554,7 @@ var ts; /** * When program emits modular code, gets the files affected by the sourceFile whose shape has changed */ - function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) { + function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) { if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } @@ -121117,7 +121574,7 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath); seenFileNamesMap.set(currentPath, currentSourceFile); - if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) { + if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) { queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath)); } } @@ -121157,7 +121614,7 @@ var ts; state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature; } state.changedFilesSet = new ts.Set(); - state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined; + state.latestChangedDtsFile = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.latestChangedDtsFile : undefined; var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && @@ -121228,7 +121685,7 @@ var ts; } else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); }); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* BuilderFileEmit.Full */); }); ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } @@ -121281,7 +121738,7 @@ var ts; programEmitComplete: state.programEmitComplete, emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: state.latestChangedDtsFile, hasChangedEmitSignature: state.hasChangedEmitSignature, changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined, }; @@ -121294,7 +121751,7 @@ var ts; state.programEmitComplete = savedEmitState.programEmitComplete; state.emitSignatures = savedEmitState.emitSignatures; state.outSignature = savedEmitState.outSignature; - state.dtsChangeTime = savedEmitState.dtsChangeTime; + state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile; state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature; if (savedEmitState.changedFilesSet) state.changedFilesSet = savedEmitState.changedFilesSet; @@ -121311,7 +121768,7 @@ var ts; * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained */ - function getNextAffectedFile(state, cancellationToken, computeHash, host) { + function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; while (true) { var affectedFiles = state.affectedFiles; @@ -121323,7 +121780,7 @@ var ts; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { // Set the next affected file as seen and remove the cached semantic diagnostics state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); return affectedFile; } affectedFilesIndex++; @@ -121351,7 +121808,7 @@ var ts; return program; } // Get next batch of affected files - state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash); + state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName); state.currentChangedFilePath = nextKey.value; state.affectedFilesIndex = 0; if (!state.seenAffectedFiles) @@ -121402,7 +121859,7 @@ var ts; * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { @@ -121410,18 +121867,18 @@ var ts; // When a change affects the global scope, all files are considered to be affected without updating their signature // That means when affected file is handled, its signature can be out of date // To avoid this, ensure that we update the signature for any affected file in this scenario. - ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash); + ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName); return; } if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) return; - handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); } /** * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, * Also we need to make sure signature is updated for these files */ - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); @@ -121432,10 +121889,10 @@ var ts; // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. - ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); + addToAffectedFilesPendingEmit(state, path, 0 /* BuilderFileEmit.DtsOnly */); } } } @@ -121457,20 +121914,20 @@ var ts; var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } - function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) return false; // Every file needs to be handled ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined) - .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); }); removeDiagnosticsOfLibraryFiles(state); return true; } /** * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit */ - function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit @@ -121488,9 +121945,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host)) return; - handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -121502,11 +121959,11 @@ var ts; // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; var references = state.referencedMap.getKeys(exportedFromPath); return references && ts.forEachKey(references, function (filePath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); }); } @@ -121514,22 +121971,22 @@ var ts; * handle dts and semantic diagnostics on file and iterate on anything that exports this file * return true when all work is done and we can exit handling dts emit and semantic diagnostics */ - function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) return undefined; - if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; - handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host); // If exported modules has path, all files referencing file exported from are affected (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); // Remove diagnostics of files that import this file (without going to exports of referencing files) (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal - state, referencingFilePath, cancellationToken, computeHash, host); + state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host); }); return undefined; } @@ -121608,14 +122065,14 @@ var ts; /** * Gets the program information to be emitted in buildInfo so that we can use it to create new program */ - function getProgramBuildInfo(state, getCanonicalFileName, host) { + function getProgramBuildInfo(state, getCanonicalFileName) { var outFilePath = ts.outFile(state.compilerOptions); if (outFilePath && !state.compilerOptions.composite) return; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - // Update the dtsChange time in buildInfo - state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime; + // Convert the file name to Path here if we set the fileName instead to optimize multiple d.ts file emits and having to compute Canonical path + var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined; if (outFilePath) { var fileNames_1 = []; var fileInfos_1 = []; @@ -121631,7 +122088,7 @@ var ts; fileInfos: fileInfos_1, options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result_15; } @@ -121733,7 +122190,7 @@ var ts; affectedFilesPendingEmit: affectedFilesPendingEmit, changeFileSet: changeFileSet, emitSignatures: emitSignatures, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result; function relativeToBuildInfoEnsuringAbsolutePath(path) { @@ -121848,8 +122305,39 @@ var ts; return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray }; } ts.getBuilderCreationParameters = getBuilderCreationParameters; - function computeSignature(text, data, computeHash) { - return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash); + function getTextHandlingSourceMapForSignature(text, data) { + return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text; + } + function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) { + var _a; + text = getTextHandlingSourceMapForSignature(text, data); + var sourceFileDirectory; + if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) { + text += data.diagnostics.map(function (diagnostic) { + return "".concat(locationInfo(diagnostic)).concat(ts.DiagnosticCategory[diagnostic.category]).concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText)); + }).join("\n"); + } + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text); + function flattenDiagnosticMessageText(diagnostic) { + return ts.isString(diagnostic) ? + diagnostic : + diagnostic === undefined ? + "" : + !diagnostic.next ? + diagnostic.messageText : + diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n"); + } + function locationInfo(diagnostic) { + if (diagnostic.file.resolvedPath === sourceFile.resolvedPath) + return "(".concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + if (sourceFileDirectory === undefined) + sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath); + return "".concat(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)), "(").concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + } + } + ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics; + function computeSignature(text, computeHash, data) { + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data)); } ts.computeSignature = computeSignature; function createBuilderProgram(kind, _a) { @@ -121870,7 +122358,7 @@ var ts; */ var computeHash = ts.maybeBind(host, host.createHash); var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); - newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); }; + newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); }; // To ensure that we arent storing any references to old program or new program without state newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; @@ -121880,6 +122368,7 @@ var ts; builderProgram.getState = getState; builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); }; builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); }; + builderProgram.hasChangedEmitSignature = function () { return !!state.hasChangedEmitSignature; }; builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); }; builderProgram.getSemanticDiagnostics = getSemanticDiagnostics; builderProgram.emit = emit; @@ -121910,8 +122399,8 @@ var ts; * in that order would be used to write the files */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); - var emitKind = 1 /* Full */; + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); + var emitKind = 1 /* BuilderFileEmit.Full */; var isPendingEmitFile = false; if (!affected) { if (!ts.outFile(state.compilerOptions)) { @@ -121924,7 +122413,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* BuilderFileEmit.Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } @@ -121943,36 +122432,39 @@ var ts; // Otherwise just affected file ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ? getWriteFileCallback(writeFile, customTransformers) : - writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } function getWriteFileCallback(writeFile, customTransformers) { return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f, _g; if (ts.isDeclarationFileName(fileName)) { if (!ts.outFile(state.compilerOptions)) { ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); - var newSignature = void 0; + var emitSignature = void 0; if (!customTransformers) { var file = sourceFiles[0]; var info = state.fileInfos.get(file.resolvedPath); if (info.signature === file.version) { - newSignature = computeSignature(text, data, computeHash); - if (newSignature !== file.version) { // Update it + var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data); + // With d.ts diagnostics they are also part of the signature so emitSignature will be different from it since its just hash of d.ts + if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length)) + emitSignature = signature; + if (signature !== file.version) { // Update it if (host.storeFilesChangingSignatureDuringEmit) - (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); if (state.exportedModulesMap) ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit); if (state.affectedFiles) { // Keep old signature so we know what to undo if cancellation happens - var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath); + var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath); if (existing === undefined) - (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); - info.signature = newSignature; + ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); + info.signature = signature; } else { // These are directly commited - info.signature = newSignature; - (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); + info.signature = signature; + (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear(); } } } @@ -121982,20 +122474,24 @@ var ts; // and would need their d.ts change time in --build mode if (state.compilerOptions.composite) { var filePath = sourceFiles[0].resolvedPath; - var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath); - newSignature || (newSignature = computeSignature(text, data, computeHash)); - if (newSignature !== oldSignature) { - (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature); - state.hasChangedEmitSignature = true; - } + var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath); + emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data)); + // Dont write dts files if they didn't change + if (emitSignature === oldSignature) + return; + ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature); + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } else if (state.compilerOptions.composite) { - var newSignature = computeSignature(text, data, computeHash); - if (newSignature !== state.outSignature) { - state.outSignature = newSignature; - state.hasChangedEmitSignature = true; - } + var newSignature = computeSignature(text, computeHash, data); + // Dont write dts files if they didn't change + if (newSignature === state.outSignature) + return; + state.outSignature = newSignature; + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } if (writeFile) @@ -122055,7 +122551,7 @@ var ts; // If every file pending emit is pending on only dts emit || ts.every(state.affectedFilesPendingEmit, function (path, index) { return index < state.affectedFilesPendingEmitIndex || - state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */; + state.affectedFilesPendingEmitKind.get(path) === 0 /* BuilderFileEmit.DtsOnly */; })) { clearAffectedFilesPendingEmit(state); } @@ -122071,7 +122567,7 @@ var ts; */ function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); if (!affected) { // Done return undefined; @@ -122083,7 +122579,7 @@ var ts; // Add file to affected file pending emit to handle for later emit time // Apart for emit builder do this for tsbuildinfo, do this for non emit builder when noEmit is set as tsbuildinfo is written and reused between emitters if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) { - addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* Full */); + addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* BuilderFileEmit.Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -122158,11 +122654,12 @@ var ts; var state; var filePaths; var filePathsSetList; + var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined; if (isProgramBundleEmitBuildInfo(program)) { state = { fileInfos: new ts.Map(), compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, outSignature: program.outSignature, }; } @@ -122195,7 +122692,7 @@ var ts; affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)), - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined, }; } @@ -122222,6 +122719,7 @@ var ts; getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, emitBuildInfo: ts.notImplemented, close: ts.noop, + hasChangedEmitSignature: ts.returnFalse, }; function toPath(path) { return ts.toPath(path, buildInfoDirectory, getCanonicalFileName); @@ -122324,7 +122822,7 @@ var ts; * "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot" * @param dirPath */ - function canWatchDirectory(dirPath) { + function canWatchDirectoryOrFile(dirPath) { var rootLength = ts.getRootLength(dirPath); if (dirPath.length === rootLength) { // Ignore "/", "c:/" @@ -122336,7 +122834,7 @@ var ts; return false; } var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); - var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */; if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart @@ -122361,7 +122859,7 @@ var ts; } return true; } - ts.canWatchDirectory = canWatchDirectory; + ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; var filesWithInvalidatedResolutions; @@ -122370,7 +122868,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolutionsWithOnlyAffectingLocations = []; var resolvedFileToResolution = ts.createMultiMap(); + var impliedFormatPackageJsons = new ts.Map(); var hasChangedAutomaticTypeDirectiveNames = false; + var affectingPathChecksForFile; var affectingPathChecks; var failedLookupChecks; var startsWithPathChecks; @@ -122395,7 +122895,7 @@ var ts; * This helps in not having to comb through all resolutions when files are added/removed * Note that .d.ts file also has .d.ts extension hence will be part of default extensions */ - var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; + var failedLookupDefaultExtensions = [".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); var fileWatchesOfAffectingLocations = new ts.Map(); @@ -122410,7 +122910,7 @@ var ts; finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions, // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) - startCachingPerDirectoryResolution: clearPerDirectoryResolutions, + startCachingPerDirectoryResolution: startCachingPerDirectoryResolution, finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution, resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, @@ -122454,9 +122954,10 @@ var ts; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; affectingPathChecks = undefined; - // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update - // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) - clearPerDirectoryResolutions(); + affectingPathChecksForFile = undefined; + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); + impliedFormatPackageJsons.clear(); hasChangedAutomaticTypeDirectiveNames = false; } function startRecordingFilesWithChangedResolutions() { @@ -122488,15 +122989,44 @@ var ts; return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } - function clearPerDirectoryResolutions() { - moduleResolutionCache.clear(); - typeReferenceDirectiveResolutionCache.clear(); + function startCachingPerDirectoryResolution() { + moduleResolutionCache.clearAllExceptPackageJsonInfoCache(); + typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache(); + // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update + // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } - function finishCachingPerDirectoryResolution() { + function finishCachingPerDirectoryResolution(newProgram, oldProgram) { filesWithInvalidatedNonRelativeUnresolvedImports = undefined; - clearPerDirectoryResolutions(); + nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); + nonRelativeExternalModuleResolutions.clear(); + // Update file watches + if (newProgram !== oldProgram) { + newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) { + var _a, _b, _c; + var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0; + var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray; + for (var i = existing.length; i < expected; i++) { + createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false); + } + if (existing.length > expected) { + for (var i = expected; i < existing.length; i++) { + fileWatchesOfAffectingLocations.get(existing[i]).files--; + } + } + if (expected) + impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations); + else + impliedFormatPackageJsons.delete(newFile.path); + }); + impliedFormatPackageJsons.forEach(function (existing, path) { + if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) { + existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; }); + impliedFormatPackageJsons.delete(path); + } + }); + } directoryWatchesOfFailedLookups.forEach(function (watcher, path) { if (watcher.refCount === 0) { directoryWatchesOfFailedLookups.delete(path); @@ -122504,11 +123034,9 @@ var ts; } }); fileWatchesOfAffectingLocations.forEach(function (watcher, path) { - if (watcher.refCount === 0) { + if (watcher.files === 0 && watcher.resolutions === 0) { fileWatchesOfAffectingLocations.delete(path); watcher.watcher.close(); - // Ensure when watching symlinked package.json, we can close the actual file watcher only once - watcher.watcher = ts.noopFileWatcher; } }); hasChangedAutomaticTypeDirectiveNames = false; @@ -122708,7 +123236,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution return { @@ -122735,7 +123263,7 @@ var ts; } // If the directory is node_modules use it to watch, always watch it recursively if (ts.isNodeModulesDirectory(dirPath)) { - return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; + return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; // Use some ancestor of the root directory @@ -122753,7 +123281,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; + return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -122824,46 +123352,65 @@ var ts; // Watch package json for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) { var affectingLocation = affectingLocations_1[_i]; - createFileWatcherOfAffectingLocation(affectingLocation); + createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true); } } - function createFileWatcherOfAffectingLocation(affectingLocation) { - var path = resolutionHost.toPath(affectingLocation); - var fileWatcher = fileWatchesOfAffectingLocations.get(path); + function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) { + var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation); if (fileWatcher) { - fileWatcher.refCount++; + if (forResolution) + fileWatcher.resolutions++; + else + fileWatcher.files++; return; } var locationToWatch = affectingLocation; - var locationToWatchPath = path; if (resolutionHost.realpath) { locationToWatch = resolutionHost.realpath(affectingLocation); - locationToWatchPath = resolutionHost.toPath(locationToWatch); - if (path !== locationToWatchPath) { - var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath); + if (affectingLocation !== locationToWatch) { + var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch); if (fileWatcher_1) { - fileWatcher_1.refCount++; - fileWatcher_1.paths.add(path); - fileWatchesOfAffectingLocations.set(path, fileWatcher_1); + if (forResolution) + fileWatcher_1.resolutions++; + else + fileWatcher_1.files++; + fileWatcher_1.paths.add(affectingLocation); + fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1); return; } } } var paths = new ts.Set(); - paths.add(locationToWatchPath); - var watcher = { - watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { - cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind); - paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); }); + paths.add(locationToWatch); + var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ? + resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { + cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind); + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + paths.forEach(function (path) { + if (watcher.resolutions) + (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path); + if (watcher.files) + (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path); + packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path)); + }); resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); - }), - refCount: 1, + }) : ts.noopFileWatcher; + var watcher = { + watcher: actualWatcher !== ts.noopFileWatcher ? { + close: function () { + actualWatcher.close(); + // Ensure when watching symlinked package.json, we can close the actual file watcher only once + actualWatcher = ts.noopFileWatcher; + } + } : actualWatcher, + resolutions: forResolution ? 1 : 0, + files: forResolution ? 0 : 1, paths: paths, }; - fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher); - if (path !== locationToWatchPath) { - fileWatchesOfAffectingLocations.set(path, watcher); - paths.add(path); + fileWatchesOfAffectingLocations.set(locationToWatch, watcher); + if (affectingLocation !== locationToWatch) { + fileWatchesOfAffectingLocations.set(affectingLocation, watcher); + paths.add(affectingLocation); } } function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) { @@ -122931,8 +123478,8 @@ var ts; } for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) { var affectingLocation = affectingLocations_2[_a]; - var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation)); - watcher.refCount--; + var watcher = fileWatchesOfAffectingLocations.get(affectingLocation); + watcher.resolutions--; } } function removeDirectoryWatcher(dirPath) { @@ -122948,7 +123495,7 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); - }, nonRecursive ? 0 /* None */ : 1 /* Recursive */); + }, nonRecursive ? 0 /* WatchDirectoryFlags.None */ : 1 /* WatchDirectoryFlags.Recursive */); } function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) { // Deleted file, stop watching failed lookups for all the resolutions in the file @@ -122959,7 +123506,7 @@ var ts; } } function removeResolutionsFromProjectReferenceRedirects(filePath) { - if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) + if (!ts.fileExtensionIs(filePath, ".json" /* Extension.Json */)) return; var program = resolutionHost.getCurrentProgram(); if (!program) @@ -122986,7 +123533,7 @@ var ts; resolution.isInvalidated = invalidated = true; for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) { var containingFilePath = _b[_a]; - (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); // When its a file with inferred types resolution, invalidate type reference directive resolution hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile); } @@ -123053,10 +123600,25 @@ var ts; resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { + var _a; + var invalidated = false; + if (affectingPathChecksForFile) { + (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) { + if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) { + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path); + invalidated = true; + } + }); + affectingPathChecksForFile = undefined; + } if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) { - return false; + return invalidated; + } + invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated; + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) { + packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; }); } - var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); failedLookupChecks = undefined; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; @@ -123069,17 +123631,15 @@ var ts; return true; if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) return false; - return resolution.failedLookupLocations.some(function (location) { - var locationPath = resolutionHost.toPath(location); - return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || - ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || - ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); - }); + return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); }); + } + function isInvalidatedFailedLookup(locationPath) { + return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); } function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) { - return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { - return affectingPathChecks.has(resolutionHost.toPath(location)); - }); + return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); }); } function closeTypeRootsWatch() { ts.clearMap(typeRootsWatches, ts.closeFileWatcher); @@ -123110,7 +123670,7 @@ var ts; if (dirPath) { scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); } - }, 1 /* Recursive */); + }, 1 /* WatchDirectoryFlags.Recursive */); } /** * Watches the types that would get added as part of getAutomaticTypeDirectiveNames @@ -123145,7 +123705,7 @@ var ts; function directoryExistsForTypeRootWatch(nodeTypesDirectory) { var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory)); var dirPath = resolutionHost.toPath(dir); - return dirPath === rootPath || canWatchDirectory(dirPath); + return dirPath === rootPath || canWatchDirectoryOrFile(dirPath); } } ts.createResolutionCache = createResolutionCache; @@ -123178,28 +123738,28 @@ var ts; function getPreferences(host, _a, compilerOptions, importingSourceFile) { var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding; return { - relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : - importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* RelativePreference.Relative */ : + importModuleSpecifierPreference === "non-relative" ? 1 /* RelativePreference.NonRelative */ : + importModuleSpecifierPreference === "project-relative" ? 3 /* RelativePreference.ExternalNonRelative */ : + 2 /* RelativePreference.Shortest */, ending: getEnding(), }; function getEnding() { switch (importModuleSpecifierEnding) { - case "minimal": return 0 /* Minimal */; - case "index": return 1 /* Index */; - case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + case "minimal": return 0 /* Ending.Minimal */; + case "index": return 1 /* Ending.Index */; + case "js": return 2 /* Ending.JsExtension */; + default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* Ending.JsExtension */ + : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) { return { - relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, + relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* RelativePreference.Relative */ : 1 /* RelativePreference.NonRelative */, ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? - 2 /* JsExtension */ : - ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + 2 /* Ending.JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */, }; } function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { @@ -123256,7 +123816,7 @@ var ts; var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || - getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); + getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { if (options === void 0) { options = {}; } @@ -123312,7 +123872,7 @@ var ts; return undefined; var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text; // If the preference is for non relative and the module specifier is relative, ignore it - return preferences.relativePreference !== 1 /* NonRelative */ || !ts.pathIsRelative(specifier) ? + return preferences.relativePreference !== 1 /* RelativePreference.NonRelative */ || !ts.pathIsRelative(specifier) ? specifier : undefined; }); }); @@ -123339,7 +123899,7 @@ var ts; return nodeModulesSpecifiers; } if (!specifier && !modulePath.isRedirect) { - var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences); + var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); if (ts.pathIsBareSpecifier(local)) { pathsSpecifiers = ts.append(pathsSpecifiers, local); } @@ -123367,13 +123927,13 @@ var ts; var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory }; } - function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) { + function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) { var ending = _a.ending, relativePreference = _a.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); - if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { + if (!baseUrl && !paths || relativePreference === 0 /* RelativePreference.Relative */) { return relativePath; } var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); @@ -123381,16 +123941,15 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; + var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions); + var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths; if (!nonRelative) { return relativePath; } - if (relativePreference === 1 /* NonRelative */) { + if (relativePreference === 1 /* RelativePreference.NonRelative */) { return nonRelative; } - if (relativePreference === 3 /* ExternalNonRelative */) { + if (relativePreference === 3 /* RelativePreference.ExternalNonRelative */) { var projectDirectory = compilerOptions.configFilePath ? ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory()); @@ -123424,7 +123983,7 @@ var ts; } return relativePath; } - if (relativePreference !== 2 /* Shortest */) + if (relativePreference !== 2 /* RelativePreference.Shortest */) ts.Debug.assertNever(relativePreference); // Prefer a relative import over a baseUrl import if it has fewer components. return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; @@ -123432,7 +123991,7 @@ var ts; function countPathComponents(path) { var count = 0; for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) { - if (path.charCodeAt(i) === 47 /* slash */) + if (path.charCodeAt(i) === 47 /* CharacterCodes.slash */) count++; } return count; @@ -123536,7 +124095,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_34 = function (directory) { + var _loop_35 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -123560,7 +124119,7 @@ var ts; }; var out_directory_1; for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { - var state_11 = _loop_34(directory); + var state_11 = _loop_35(directory); directory = out_directory_1; if (state_11 === "break") break; @@ -123603,11 +124162,11 @@ var ts; var exportSymbol = checker.getSymbolAtLocation(exportAssignment); if (!exportSymbol) return; - var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; + var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; if (originalExportSymbol === d.symbol) return topNamespace.parent.parent; function getTopNamespace(namespaceDeclaration) { - while (namespaceDeclaration.flags & 4 /* NestedNamespace */) { + while (namespaceDeclaration.flags & 4 /* NodeFlags.NestedNamespace */) { namespaceDeclaration = namespaceDeclaration.parent; } return namespaceDeclaration; @@ -123618,28 +124177,102 @@ var ts; return ambientModuleDeclare.name.text; } } - function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) { + function getAllowedEndings(preferredEnding, compilerOptions, importMode) { + if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) { + return [2 /* Ending.JsExtension */]; + } + switch (preferredEnding) { + case 2 /* Ending.JsExtension */: return [2 /* Ending.JsExtension */, 0 /* Ending.Minimal */, 1 /* Ending.Index */]; + case 1 /* Ending.Index */: return [1 /* Ending.Index */, 0 /* Ending.Minimal */, 2 /* Ending.JsExtension */]; + case 0 /* Ending.Minimal */: return [0 /* Ending.Minimal */, 1 /* Ending.Index */, 2 /* Ending.JsExtension */]; + default: ts.Debug.assertNever(preferredEnding); + } + } + function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) { for (var key in paths) { - for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { - var patternText_1 = _a[_i]; - var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1)); + var _loop_36 = function (patternText_1) { + var pattern = ts.normalizePath(patternText_1); var indexOfStar = pattern.indexOf("*"); + // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly, + // meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution + // causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file + // and matches the '*'. For example: + // + // Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action + // ---------------------->------------------------------->--------------------->--------------------------------------------------------------- + // import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm] + // import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm] + // + // (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516) + // + // The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in + // the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result. + // (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid + // extension for a module specifier.) + // + // Here, this means we need to be careful about whether we generate a match from the target filename (typically with a + // .ts extension) or the possible relative module specifiers representing that file: + // + // Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results + // --------------------<----------------------------------------------<------------------------------<-------------------||---------------------------- + // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none) + // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js + // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none) + // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*"] <- (none) || @app/foo, @app/foo/index, @app/foo/index.js + // dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js + // + // The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of + // relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes + // into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js' + // exists) and (c) that they are ordered by preference. The last row shows that the filename result and module + // specifier results are not mutually exclusive. Note that the filename result is a higher priority in module + // resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result + // in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be + // sorted among the others for a particular value of `importModuleSpecifierEnding`. + var candidates = allowedEndings.map(function (ending) { return ({ + ending: ending, + value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) + }); }); + if (ts.tryGetExtensionFromPath(pattern)) { + candidates.push({ ending: undefined, value: relativeToBaseUrl }); + } if (indexOfStar !== -1) { - var prefix = pattern.substr(0, indexOfStar); - var suffix = pattern.substr(indexOfStar + 1); - if (relativeToBaseUrl.length >= prefix.length + suffix.length && - ts.startsWith(relativeToBaseUrl, prefix) && - ts.endsWith(relativeToBaseUrl, suffix) || - !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); - return key.replace("*", matchedStar); + var prefix = pattern.substring(0, indexOfStar); + var suffix = pattern.substring(indexOfStar + 1); + for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) { + var _c = candidates_3[_b], ending = _c.ending, value = _c.value; + if (value.length >= prefix.length + suffix.length && + ts.startsWith(value, prefix) && + ts.endsWith(value, suffix) && + validateEnding({ ending: ending, value: value })) { + var matchedStar = value.substring(prefix.length, value.length - suffix.length); + return { value: key.replace("*", matchedStar) }; + } } } - else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) { - return key; + else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Ending.Minimal */ && pattern === c.value; }) || + ts.some(candidates, function (c) { return c.ending === 0 /* Ending.Minimal */ && pattern === c.value && validateEnding(c); })) { + return { value: key }; } + }; + for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { + var patternText_1 = _a[_i]; + var state_12 = _loop_36(patternText_1); + if (typeof state_12 === "object") + return state_12.value; } } + function validateEnding(_a) { + var ending = _a.ending, value = _a.value; + // Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename + // is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only + // here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls), + // do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the + // `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is + // that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally + // everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.) + return ending !== 0 /* Ending.Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host); + } } var MatchingMode; (function (MatchingMode) { @@ -123648,23 +124281,23 @@ var ts; MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern"; })(MatchingMode || (MatchingMode = {})); function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { - if (mode === void 0) { mode = 0 /* Exact */; } + if (mode === void 0) { mode = 0 /* MatchingMode.Exact */; } if (typeof exports === "string") { var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined); var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined; switch (mode) { - case 0 /* Exact */: - if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) { + case 0 /* MatchingMode.Exact */: + if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* Comparison.EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* Comparison.EqualTo */)) { return { moduleFileToTry: packageName }; } break; - case 1 /* Directory */: + case 1 /* MatchingMode.Directory */: if (ts.containsPath(pathOrPattern, targetFilePath)) { var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false); return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) }; } break; - case 2 /* Pattern */: + case 2 /* MatchingMode.Pattern */: var starPos = pathOrPattern.indexOf("*"); var leadingSlice = pathOrPattern.slice(0, starPos); var trailingSlice = pathOrPattern.slice(starPos + 1); @@ -123691,9 +124324,9 @@ var ts; // * exact mappings (no *, does not end with /) return ts.forEach(ts.getOwnKeys(exports), function (k) { var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined); - var mode = ts.endsWith(k, "/") ? 1 /* Directory */ - : ts.stringContains(k, "*") ? 2 /* Pattern */ - : 0 /* Exact */; + var mode = ts.endsWith(k, "/") ? 1 /* MatchingMode.Directory */ + : ts.stringContains(k, "*") ? 2 /* MatchingMode.Pattern */ + : 0 /* MatchingMode.Exact */; return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode); }); } @@ -123735,10 +124368,10 @@ var ts; return undefined; } // Simplify the full file path to something that can be resolved by Node. + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { - var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; var moduleFileName = void 0; while (true) { @@ -123787,15 +124420,13 @@ var ts; var packageRootPath = path.substring(0, packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); var moduleFileToTry = path; + var maybeBlockedByTypesVersions = false; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); + var importMode = overrideMode || importingSourceFile.impliedNodeFormat; if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { - // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate - // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is - // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` - // with, so for now we just stick with the mode of the file. - var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"]; + var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"]; var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions) : undefined; @@ -123814,16 +124445,26 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { + var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options); + if (fromPaths === undefined) { + maybeBlockedByTypesVersions = true; + } + else { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } // If the file is the main module, it can be imported by the package name var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; - if (ts.isString(mainFileRelative)) { + if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) { + // The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path + // explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable. + // (The only way this can happen is if some file in a package that's not resolvable from outside the + // package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It + // happens very easily in fourslash tests though, since every test file listed gets included. See + // importNameCodeFix_typesVersions.ts for an example.) var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { + // ^ An arbitrary removal of file extension for this comparison is almost certainly wrong return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry }; } } @@ -123842,7 +124483,7 @@ var ts; if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }])); + var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }])); for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) { var e = extensions_3[_i]; var fullPath = path + e; @@ -123858,15 +124499,15 @@ var ts; }); } function removeExtensionAndIndexPostFix(fileName, ending, options, host) { - if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) + if (ts.fileExtensionIsOneOf(fileName, [".json" /* Extension.Json */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) return fileName; var noExtension = ts.removeFileExtension(fileName); if (fileName === noExtension) return fileName; - if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) + if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { - case 0 /* Minimal */: + case 0 /* Ending.Minimal */: var withoutIndex = ts.removeSuffix(noExtension, "/index"); if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { // Can't remove index if there's a file by the same name as the directory. @@ -123874,9 +124515,9 @@ var ts; return noExtension; } return withoutIndex; - case 1 /* Index */: + case 1 /* Ending.Index */: return noExtension; - case 2 /* JsExtension */: + case 2 /* Ending.JsExtension */: return noExtension + getJSExtensionForFile(fileName, options); default: return ts.Debug.assertNever(ending); @@ -123884,28 +124525,28 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); switch (ext) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: - return ".js" /* Js */; - case ".tsx" /* Tsx */: - return options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; - case ".js" /* Js */: - case ".jsx" /* Jsx */: - case ".json" /* Json */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: + return ".js" /* Extension.Js */; + case ".tsx" /* Extension.Tsx */: + return options.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" /* Extension.Jsx */ : ".js" /* Extension.Js */; + case ".js" /* Extension.Js */: + case ".jsx" /* Extension.Jsx */: + case ".json" /* Extension.Json */: return ext; - case ".d.mts" /* Dmts */: - case ".mts" /* Mts */: - case ".mjs" /* Mjs */: - return ".mjs" /* Mjs */; - case ".d.cts" /* Dcts */: - case ".cts" /* Cts */: - case ".cjs" /* Cjs */: - return ".cjs" /* Cjs */; + case ".d.mts" /* Extension.Dmts */: + case ".mts" /* Extension.Mts */: + case ".mjs" /* Extension.Mjs */: + return ".mjs" /* Extension.Mjs */; + case ".d.cts" /* Extension.Dcts */: + case ".cts" /* Extension.Cts */: + case ".cjs" /* Extension.Cjs */: + return ".cjs" /* Extension.Cjs */; default: return undefined; } @@ -123987,8 +124628,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -123996,8 +124637,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -124020,7 +124661,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -124053,7 +124694,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -124066,7 +124707,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -124089,7 +124730,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -124116,25 +124757,48 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; - function explainIfFileIsRedirect(file, fileNameConvertor) { + function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) { + var _a; var result; if (file.path !== file.resolvedPath) { - (result || (result = [])).push(ts.chainDiagnosticMessages( + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor))); } if (file.redirectInfo) { - (result || (result = [])).push(ts.chainDiagnosticMessages( + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor))); } + if (ts.isExternalOrCommonJsModule(file)) { + switch (file.impliedNodeFormat) { + case ts.ModuleKind.ESNext: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + break; + case ts.ModuleKind.CommonJS: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, file.packageJsonScope.packageJsonContent.type ? + ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module : + ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found)); + } + break; + } + } return result; } - ts.explainIfFileIsRedirect = explainIfFileIsRedirect; + ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat; function getMatchedFileSpec(program, fileName) { var _a; var configFile = program.getCompilerOptions().configFile; @@ -124154,14 +124818,14 @@ var ts; // Return true if its default include spec if (configFile.configFileSpecs.isDefaultIncludeSpec) return true; - var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Extension.Json */); var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames(); return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) { - if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Json */)) + if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Extension.Json */)) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -124170,7 +124834,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -124296,7 +124960,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -124344,6 +125008,7 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", + AffectingFileLocation: "File location affecting resolution", TypeRoots: "Type roots", ConfigFileOfReferencedProject: "Config file of referened project", ExtendedConfigOfReferencedProject: "Extended config file of referenced project", @@ -124404,7 +125069,6 @@ var ts; readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, - now: ts.maybeBind(host, host.now), }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -124562,7 +125226,6 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - host.now = ts.maybeBind(system, system.now); ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -124613,7 +125276,6 @@ var ts; var parsedConfigs; // Parsed commandline and watching cached for referenced projects var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation - var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files @@ -124644,7 +125306,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -124670,7 +125332,7 @@ var ts; compilerHost.getCompilationSettings = function () { return compilerOptions; }; compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect); compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); }; - compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); }; + compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); }; compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); }; compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; }; compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations; @@ -124704,6 +125366,9 @@ var ts; return host.resolveTypeReferenceDirectives.apply(host, args); }) : (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); }); + compilerHost.getModuleResolutionCache = host.resolveModuleNames ? + ts.maybeBind(host, host.getModuleResolutionCache) : + (function () { return resolutionCache.getModuleResolutionCache(); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); synchronizeProgram(); @@ -124766,12 +125431,12 @@ var ts; var program = getCurrentBuilderProgram(); if (hasChangedCompilerOptions) { newLine = updateNewLine(); - if (program && (changesAffectResolution || ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) { + if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) { resolutionCache.clear(); } } // All resolutions are invalid if user provided resolutions - var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution); + var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { @@ -124787,7 +125452,6 @@ var ts; } createNewProgram(hasInvalidatedResolution); } - changesAffectResolution = false; // reset for next sync reportFileChangeDetectedOnCreateProgram = false; if (host.afterProgramCreate && program !== builderProgram) { host.afterProgramCreate(builderProgram); @@ -124797,18 +125461,19 @@ var ts; function createNewProgram(hasInvalidatedResolution) { // Compile the program writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; resolutionCache.startCachingPerDirectoryResolution(); compilerHost.hasInvalidatedResolution = hasInvalidatedResolution; compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames; + var oldProgram = getCurrentProgram(); builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); - resolutionCache.finishCachingPerDirectoryResolution(); + resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram); // Update watches ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath); if (needsUpdateInTypeRootWatch) { @@ -124890,9 +125555,6 @@ var ts; sourceFilesCache.set(path, false); } } - if (sourceFile) { - sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings()); - } return sourceFile; } return hostSourceFile.sourceFile; @@ -124955,7 +125617,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -125016,7 +125678,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -125057,7 +125719,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -125286,7 +125948,7 @@ var ts; UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function resolveConfigFileProjectName(project) { - if (ts.fileExtensionIs(project, ".json" /* Json */)) { + if (ts.fileExtensionIs(project, ".json" /* Extension.Json */)) { return project; } return ts.combinePaths(project, "tsconfig.json"); @@ -125349,8 +126011,8 @@ var ts; */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -125408,6 +126070,7 @@ var ts; compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); + compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache); var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined; if (!compilerHost.resolveModuleNames) { @@ -125890,8 +126553,7 @@ var ts; } // Actual Emit var host = state.host, compilerHost = state.compilerHost; - var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; - var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined; + var resultFlags = ((_d = program.hasChangedEmitSignature) === null || _d === void 0 ? void 0 : _d.call(program)) ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged; var emitterDiagnostics = ts.createDiagnosticCollection(); var emittedOutputs = new ts.Map(); var options = program.getCompilerOptions(); @@ -125899,17 +126561,11 @@ var ts; var outputTimeStampMap; var now; outputFiles.forEach(function (_a) { - var _b, _c; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; var path = toPath(state, name); emittedOutputs.set(toPath(state, name), name); - if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, options); - // Buildinfo has information on when last dts change time - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo === null || existingBuildInfo === void 0 ? void 0 : existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { - resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; - } - } + if (buildInfo) + setBuildInfo(state, buildInfo, projectPath, options, resultFlags); ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); if (!isIncremental && state.watch) { (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host))); @@ -125923,7 +126579,7 @@ var ts; ts.Debug.assert(step === BuildStep.EmitBuildInfo); var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) { if (data === null || data === void 0 ? void 0 : data.buildInfo) - setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions()); + setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions(), BuildResultFlags.DeclarationOutputUnchanged); if (writeFileCallback) writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data); else @@ -125956,7 +126612,6 @@ var ts; state.diagnostics.delete(projectPath); state.projectStatus.set(projectPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath), oldestOutputFileName: oldestOutputFileName }); afterProgramDone(state, program, config); @@ -125998,10 +126653,10 @@ var ts; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; emittedOutputs.set(toPath(state, name), name); if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, config.options); - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { + if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) { resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; } + setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags); } ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); }); @@ -126162,7 +126817,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -126176,7 +126831,7 @@ var ts; } function afterProgramDone(state, program, config) { if (program) { - if (program && state.write) + if (state.write) ts.listFiles(program, state.write); if (state.host.afterProgramEmitAndDiagnostics) { state.host.afterProgramEmitAndDiagnostics(program); @@ -126192,7 +126847,7 @@ var ts; // Since buildinfo has changeset and diagnostics when doing multi file emit, only --out cannot emit buildinfo if it has errors var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -126260,15 +126915,23 @@ var ts; state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map()); return result; } - function setBuildInfo(state, buildInfo, resolvedConfigPath, options) { + function setBuildInfo(state, buildInfo, resolvedConfigPath, options, resultFlags) { var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath); + var modifiedTime = getCurrentTime(state.host); if (existing) { existing.buildInfo = buildInfo; - existing.modifiedTime = getCurrentTime(state.host); + existing.modifiedTime = modifiedTime; + if (!(resultFlags & BuildResultFlags.DeclarationOutputUnchanged)) + existing.latestChangedDtsTime = modifiedTime; } else { - state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) }); + state.buildInfoCache.set(resolvedConfigPath, { + path: toPath(state, buildInfoPath), + buildInfo: buildInfo, + modifiedTime: modifiedTime, + latestChangedDtsTime: resultFlags & BuildResultFlags.DeclarationOutputUnchanged ? undefined : modifiedTime, + }); } } function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) { @@ -126300,7 +126963,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { - var _a, _b, _c; + var _a, _b; // Container if no files are specified in the project if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) { return { @@ -126312,8 +126975,8 @@ var ts; var force = !!state.options.force; if (project.projectReferences) { state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream }); - for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) { - var ref = _d[_i]; + for (var _i = 0, _c = project.projectReferences; _i < _c.length; _i++) { + var ref = _c[_i]; var resolvedRef = ts.resolveProjectReferencePath(ref); var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef); var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath); @@ -126353,7 +127016,6 @@ var ts; var buildInfoTime; var buildInfoProgram; var buildInfoVersionMap; - var newestDeclarationFileContentChangedTime; if (buildInfoPath) { var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath); buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath); @@ -126390,8 +127052,6 @@ var ts; } oldestOutputFileTime = buildInfoTime; oldestOutputFileName = buildInfoPath; - // Get the last dtsChange time from build info - newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; } // Check input files var newestInputFileName = undefined; @@ -126399,13 +127059,13 @@ var ts; /** True if input file has changed timestamp but text is not changed, we can then do only timestamp updates on output to make it look up-to-date later */ var pseudoInputUpToDate = false; // Get timestamps of input files - for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) { - var inputFile = _f[_e]; + for (var _d = 0, _e = project.fileNames; _d < _e.length; _d++) { + var inputFile = _e[_d]; var inputTime = getModifiedTime(state, inputFile); if (inputTime === ts.missingFileModifiedTime) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } // If an buildInfo is older than the newest input, we can stop checking @@ -126441,8 +127101,8 @@ var ts; // Collect the expected outputs of this project var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath); - for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) { - var output = outputs_1[_g]; + for (var _f = 0, outputs_1 = outputs; _f < outputs_1.length; _f++) { + var output = outputs_1[_f]; var path = toPath(state, output); // Output is missing; can stop checking var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path); @@ -126480,8 +127140,8 @@ var ts; var usesPrepend = false; var upstreamChangedProject; if (referenceStatuses) { - for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) { - var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath; + for (var _g = 0, referenceStatuses_1 = referenceStatuses; _g < referenceStatuses_1.length; _g++) { + var _h = referenceStatuses_1[_g], ref = _h.ref, refStatus = _h.refStatus, resolvedConfig = _h.resolvedConfig, resolvedRefPath = _h.resolvedRefPath; usesPrepend = usesPrepend || !!(ref.prepend); // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it @@ -126498,7 +127158,8 @@ var ts; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + var newestDeclarationFileContentChangedTime = getLatestChangedDtsTime(state, resolvedConfig.options, resolvedRefPath); + if (newestDeclarationFileContentChangedTime && newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -126541,7 +127202,6 @@ var ts; pseudoInputUpToDate ? ts.UpToDateStatusType.UpToDateWithInputFileText : ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, newestInputFileTime: newestInputFileTime, newestInputFileName: newestInputFileName, oldestOutputFileName: oldestOutputFileName @@ -126625,13 +127285,17 @@ var ts; outputTimeStampMap.delete(key); }); } - function getDtsChangeTime(state, options, resolvedConfigPath) { - var _a; + function getLatestChangedDtsTime(state, options, resolvedConfigPath) { if (!options.composite) return undefined; - var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); - var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined); - return ((_a = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.program) === null || _a === void 0 ? void 0 : _a.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; + var entry = ts.Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath)); + if (entry.latestChangedDtsTime !== undefined) + return entry.latestChangedDtsTime || undefined; + var latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ? + state.host.getModifiedTime(ts.getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, ts.getDirectoryPath(entry.path))) : + undefined; + entry.latestChangedDtsTime = latestChangedDtsTime || false; + return latestChangedDtsTime; } function updateOutputTimestamps(state, proj, resolvedPath) { if (state.options.dry) { @@ -126640,7 +127304,6 @@ var ts; updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0); state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath), oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames()) }); } @@ -126776,7 +127439,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -127126,7 +127789,7 @@ var ts; function nowString() { // E.g. "12:34:56.789" var d = new Date(); - return ts.padLeft(d.getHours().toString(), 2, "0") + ":" + ts.padLeft(d.getMinutes().toString(), 2, "0") + ":" + ts.padLeft(d.getSeconds().toString(), 2, "0") + "." + ts.padLeft(d.getMilliseconds().toString(), 3, "0"); + return "".concat(ts.padLeft(d.getHours().toString(), 2, "0"), ":").concat(ts.padLeft(d.getMinutes().toString(), 2, "0"), ":").concat(ts.padLeft(d.getSeconds().toString(), 2, "0"), ".").concat(ts.padLeft(d.getMilliseconds().toString(), 3, "0")); } server.nowString = nowString; })(server = ts.server || (ts.server = {})); @@ -127137,7 +127800,7 @@ var ts; var JsTyping; (function (JsTyping) { function isTypingUpToDate(cachedTyping, availableTypingVersions) { - var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); + var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts".concat(ts.versionMajorMinor)) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; @@ -127190,7 +127853,7 @@ var ts; "worker_threads", "zlib" ]; - JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:" + name; }); + JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:".concat(name); }); JsTyping.nodeCoreModuleList = __spreadArray(__spreadArray([], unprefixedNodeCoreModuleList, true), JsTyping.prefixedNodeCoreModuleList, true); JsTyping.nodeCoreModules = new ts.Set(JsTyping.nodeCoreModuleList); function nonRelativeModuleNameForTypingCache(moduleName) { @@ -127265,7 +127928,7 @@ var ts; var excludeTypingName = exclude_1[_i]; var didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) - log("Typing for " + excludeTypingName + " is in exclude list, will be ignored."); + log("Typing for ".concat(excludeTypingName, " is in exclude list, will be ignored.")); } var newTypingNames = []; var cachedTypingPaths = []; @@ -127279,7 +127942,7 @@ var ts; }); var result = { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; if (log) - log("Result: " + JSON.stringify(result)); + log("Result: ".concat(JSON.stringify(result))); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { @@ -127288,7 +127951,7 @@ var ts; } function addInferredTypings(typingNames, message) { if (log) - log(message + ": " + JSON.stringify(typingNames)); + log("".concat(message, ": ").concat(JSON.stringify(typingNames))); ts.forEach(typingNames, addInferredTyping); } /** @@ -127310,7 +127973,7 @@ var ts; filesToWatch.push(manifestPath); manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config; manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys); - addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies"); + addInferredTypings(manifestTypingNames, "Typing names in '".concat(manifestPath, "' dependencies")); } // Now we scan the directories for typing information in // already-installed dependencies (if present). Note that this @@ -127338,7 +128001,7 @@ var ts; // This is #1 described above. ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); }) // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json` - : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) + : host.readDirectory(packagesFolderPath, [".json" /* Extension.Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) .filter(function (manifestPath) { if (ts.getBaseFileName(manifestPath) !== manifestName) { return false; @@ -127354,7 +128017,7 @@ var ts; !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo` }); if (log) - log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames)); + log("Searching for typing names in ".concat(packagesFolderPath, "; all files: ").concat(JSON.stringify(dependencyManifestNames))); // Once we have the names of things to look up, we iterate over // and either collect their included typings, or add them to the // list of typings we need to look up separately. @@ -127373,12 +128036,12 @@ var ts; var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName)); if (host.fileExists(absolutePath)) { if (log) - log(" Package '" + manifest_1.name + "' provides its own types."); + log(" Package '".concat(manifest_1.name, "' provides its own types.")); inferredTypings.set(manifest_1.name, absolutePath); } else { if (log) - log(" Package '" + manifest_1.name + "' provides its own types but they are missing."); + log(" Package '".concat(manifest_1.name, "' provides its own types but they are missing.")); } } else { @@ -127404,7 +128067,7 @@ var ts; if (fromFileNames.length) { addInferredTypings(fromFileNames, "Inferred typings from file names"); } - var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); }); + var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Extension.Jsx */); }); if (hasJsxFile) { if (log) log("Inferred 'react' typings due to presence of '.jsx' extension"); @@ -127432,16 +128095,16 @@ var ts; JsTyping.validatePackageName = validatePackageName; function validatePackageNameWorker(packageName, supportScopedPackage) { if (!packageName) { - return 1 /* EmptyName */; + return 1 /* NameValidationResult.EmptyName */; } if (packageName.length > maxPackageNameLength) { - return 2 /* NameTooLong */; + return 2 /* NameValidationResult.NameTooLong */; } - if (packageName.charCodeAt(0) === 46 /* dot */) { - return 3 /* NameStartsWithDot */; + if (packageName.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + return 3 /* NameValidationResult.NameStartsWithDot */; } - if (packageName.charCodeAt(0) === 95 /* _ */) { - return 4 /* NameStartsWithUnderscore */; + if (packageName.charCodeAt(0) === 95 /* CharacterCodes._ */) { + return 4 /* NameValidationResult.NameStartsWithUnderscore */; } // check if name is scope package like: starts with @ and has one '/' in the middle // scoped packages are not currently supported @@ -127449,20 +128112,20 @@ var ts; var matches = /^@([^/]+)\/([^/]+)$/.exec(packageName); if (matches) { var scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false); - if (scopeResult !== 0 /* Ok */) { + if (scopeResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[1], isScopeName: true, result: scopeResult }; } var packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false); - if (packageResult !== 0 /* Ok */) { + if (packageResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[2], isScopeName: false, result: packageResult }; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } } if (encodeURIComponent(packageName) !== packageName) { - return 5 /* NameContainsNonURISafeCharacters */; + return 5 /* NameValidationResult.NameContainsNonURISafeCharacters */; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } function renderPackageNameValidationFailure(result, typing) { return typeof result === "object" ? @@ -127473,17 +128136,17 @@ var ts; function renderPackageNameValidationFailureWorker(typing, result, name, isScopeName) { var kind = isScopeName ? "Scope" : "Package"; switch (result) { - case 1 /* EmptyName */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot be empty"; - case 2 /* NameTooLong */: - return "'" + typing + "':: " + kind + " name '" + name + "' should be less than " + maxPackageNameLength + " characters"; - case 3 /* NameStartsWithDot */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '.'"; - case 4 /* NameStartsWithUnderscore */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '_'"; - case 5 /* NameContainsNonURISafeCharacters */: - return "'" + typing + "':: " + kind + " name '" + name + "' contains non URI safe characters"; - case 0 /* Ok */: + case 1 /* NameValidationResult.EmptyName */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot be empty"); + case 2 /* NameValidationResult.NameTooLong */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' should be less than ").concat(maxPackageNameLength, " characters"); + case 3 /* NameValidationResult.NameStartsWithDot */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '.'"); + case 4 /* NameValidationResult.NameStartsWithUnderscore */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '_'"); + case 5 /* NameValidationResult.NameContainsNonURISafeCharacters */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' contains non URI safe characters"); + case 0 /* NameValidationResult.Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: throw ts.Debug.assertNever(result); @@ -127855,7 +128518,7 @@ var ts; (function (ts) { // These utilities are common to multiple language service features. //#region - ts.scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); var SemanticMeaning; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -127866,66 +128529,66 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 292 /* CatchClause */: - case 285 /* JsxAttribute */: - return 1 /* Value */; - case 163 /* TypeParameter */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 182 /* TypeLiteral */: - return 2 /* Type */; - case 345 /* JSDocTypedefTag */: + case 254 /* SyntaxKind.VariableDeclaration */: + return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* SemanticMeaning.All */ : 1 /* SemanticMeaning.Value */; + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 292 /* SyntaxKind.CatchClause */: + case 285 /* SyntaxKind.JsxAttribute */: + return 1 /* SemanticMeaning.Value */; + case 163 /* SyntaxKind.TypeParameter */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + return 2 /* SemanticMeaning.Type */; + case 345 /* SyntaxKind.JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. - return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 299 /* EnumMember */: - case 257 /* ClassDeclaration */: - return 1 /* Value */ | 2 /* Type */; - case 261 /* ModuleDeclaration */: + return node.name === undefined ? 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */ : 2 /* SemanticMeaning.Type */; + case 299 /* SyntaxKind.EnumMember */: + case 257 /* SyntaxKind.ClassDeclaration */: + return 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */; + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isAmbientModule(node)) { - return 4 /* Namespace */ | 1 /* Value */; + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { - return 4 /* Namespace */ | 1 /* Value */; + else if (ts.getModuleInstanceState(node) === 1 /* ModuleInstanceState.Instantiated */) { + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } else { - return 4 /* Namespace */; - } - case 260 /* EnumDeclaration */: - case 269 /* NamedImports */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: - return 7 /* All */; + return 4 /* SemanticMeaning.Namespace */; + } + case 260 /* SyntaxKind.EnumDeclaration */: + case 269 /* SyntaxKind.NamedImports */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: + return 7 /* SemanticMeaning.All */; // An external module can be a Value - case 305 /* SourceFile */: - return 4 /* Namespace */ | 1 /* Value */; + case 305 /* SyntaxKind.SourceFile */: + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); var parent = node.parent; - if (node.kind === 305 /* SourceFile */) { - return 1 /* Value */; + if (node.kind === 305 /* SyntaxKind.SourceFile */) { + return 1 /* SemanticMeaning.Value */; } else if (ts.isExportAssignment(parent) || ts.isExportSpecifier(parent) @@ -127933,7 +128596,7 @@ var ts; || ts.isImportSpecifier(parent) || ts.isImportClause(parent) || ts.isImportEqualsDeclaration(parent) && node === parent.name) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { return getMeaningFromRightHandSideOfImportEquals(node); @@ -127942,24 +128605,24 @@ var ts; return getMeaningFromDeclaration(parent); } else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isTypeReference(node)) { - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (isNamespaceReference(node)) { - return 4 /* Namespace */; + return 4 /* SemanticMeaning.Namespace */; } else if (ts.isTypeParameterDeclaration(parent)) { ts.Debug.assert(ts.isJSDocTemplateTag(parent.parent)); // Else would be handled by isDeclarationName - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (ts.isLiteralTypeNode(parent)) { // This might be T["name"], which is actually referencing a property and not a type. So allow both meanings. - return 2 /* Type */ | 1 /* Value */; + return 2 /* SemanticMeaning.Type */ | 1 /* SemanticMeaning.Value */; } else { - return 1 /* Value */; + return 1 /* SemanticMeaning.Value */; } } ts.getMeaningFromLocation = getMeaningFromLocation; @@ -127967,11 +128630,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 161 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 265 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 161 /* SyntaxKind.QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? 7 /* SemanticMeaning.All */ : 4 /* SemanticMeaning.Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -127983,27 +128646,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 161 /* QualifiedName */) { - while (root.parent && root.parent.kind === 161 /* QualifiedName */) { + if (root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + while (root.parent && root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 178 /* TypeReference */ && !isLastClause; + return root.parent.kind === 178 /* SyntaxKind.TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 206 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 206 /* PropertyAccessExpression */) { + if (root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 228 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 257 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || - (decl.kind === 258 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); + return (decl.kind === 257 /* SyntaxKind.ClassDeclaration */ && root.parent.parent.token === 117 /* SyntaxKind.ImplementsKeyword */) || + (decl.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && root.parent.parent.token === 94 /* SyntaxKind.ExtendsKeyword */); } return false; } @@ -128012,17 +128675,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return !ts.isExpressionNode(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return true; } switch (node.parent.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return true; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return !node.parent.isTypeOf; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isPartOfTypeNode(node.parent); } return false; @@ -128089,7 +128752,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 250 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 250 /* SyntaxKind.LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -128150,22 +128813,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 261 /* ModuleDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.parent.argumentExpression === node; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return true; - case 196 /* LiteralType */: - return node.parent.parent.kind === 194 /* IndexedAccessType */; + case 196 /* SyntaxKind.LiteralType */: + return node.parent.parent.kind === 194 /* SyntaxKind.IndexedAccessType */; default: return false; } @@ -128189,17 +128852,17 @@ var ts; return undefined; } switch (node.kind) { - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return node; } } @@ -128207,108 +128870,108 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 305 /* SourceFile */: - return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 261 /* ModuleDeclaration */: - return "module" /* moduleElement */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return "class" /* classElement */; - case 258 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 259 /* TypeAliasDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - return "type" /* typeElement */; - case 260 /* EnumDeclaration */: return "enum" /* enumElement */; - case 254 /* VariableDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + return ts.isExternalModule(node) ? "module" /* ScriptElementKind.moduleElement */ : "script" /* ScriptElementKind.scriptElement */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return "module" /* ScriptElementKind.moduleElement */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return "class" /* ScriptElementKind.classElement */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return "interface" /* ScriptElementKind.interfaceElement */; + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + return "type" /* ScriptElementKind.typeElement */; + case 260 /* SyntaxKind.EnumDeclaration */: return "enum" /* ScriptElementKind.enumElement */; + case 254 /* SyntaxKind.VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - return "function" /* functionElement */; - case 172 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 173 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - return "method" /* memberFunctionElement */; - case 296 /* PropertyAssignment */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + return "function" /* ScriptElementKind.functionElement */; + case 172 /* SyntaxKind.GetAccessor */: return "getter" /* ScriptElementKind.memberGetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: return "setter" /* ScriptElementKind.memberSetAccessorElement */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + return "method" /* ScriptElementKind.memberFunctionElement */; + case 296 /* SyntaxKind.PropertyAssignment */: var initializer = node.initializer; - return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: - return "property" /* memberVariableElement */; - case 176 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 175 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 174 /* CallSignature */: return "call" /* callSignatureElement */; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: - return "constructor" /* constructorImplementationElement */; - case 163 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 299 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 164 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - return "alias" /* alias */; - case 221 /* BinaryExpression */: + return ts.isFunctionLike(initializer) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: + return "property" /* ScriptElementKind.memberVariableElement */; + case 176 /* SyntaxKind.IndexSignature */: return "index" /* ScriptElementKind.indexSignatureElement */; + case 175 /* SyntaxKind.ConstructSignature */: return "construct" /* ScriptElementKind.constructSignatureElement */; + case 174 /* SyntaxKind.CallSignature */: return "call" /* ScriptElementKind.callSignatureElement */; + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + case 163 /* SyntaxKind.TypeParameter */: return "type parameter" /* ScriptElementKind.typeParameterElement */; + case 299 /* SyntaxKind.EnumMember */: return "enum member" /* ScriptElementKind.enumMemberElement */; + case 164 /* SyntaxKind.Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) ? "property" /* ScriptElementKind.memberVariableElement */ : "parameter" /* ScriptElementKind.parameterElement */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + return "alias" /* ScriptElementKind.alias */; + case 221 /* SyntaxKind.BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: - case 0 /* None */: - return "" /* unknown */; - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: + case 0 /* AssignmentDeclarationKind.None */: + return "" /* ScriptElementKind.unknown */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: var rightKind = getNodeKind(right); - return rightKind === "" /* unknown */ ? "const" /* constElement */ : rightKind; - case 3 /* PrototypeProperty */: - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 4 /* ThisProperty */: - return "property" /* memberVariableElement */; // property - case 5 /* Property */: + return rightKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : rightKind; + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 4 /* AssignmentDeclarationKind.ThisProperty */: + return "property" /* ScriptElementKind.memberVariableElement */; // property + case 5 /* AssignmentDeclarationKind.Property */: // static method / property - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 6 /* Prototype */: - return "local class" /* localClassElement */; + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 6 /* AssignmentDeclarationKind.Prototype */: + return "local class" /* ScriptElementKind.localClassElement */; default: { ts.assertType(kind); - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } } - case 79 /* Identifier */: - return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 271 /* ExportAssignment */: + case 79 /* SyntaxKind.Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* ScriptElementKind.alias */ : "" /* ScriptElementKind.unknown */; + case 271 /* SyntaxKind.ExportAssignment */: var scriptKind = getNodeKind(node.expression); // If the expression didn't come back with something (like it does for an identifiers) - return scriptKind === "" /* unknown */ ? "const" /* constElement */ : scriptKind; + return scriptKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : scriptKind; default: - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ + ? "const" /* ScriptElementKind.constElement */ : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "let" /* ScriptElementKind.letElement */ + : "var" /* ScriptElementKind.variableElement */; } } ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* SyntaxKind.Parameter */; default: return false; } @@ -128373,42 +129036,42 @@ var ts; return false; } switch (n.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 201 /* ObjectBindingPattern */: - case 182 /* TypeLiteral */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 263 /* CaseBlock */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: - return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 292 /* CatchClause */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 182 /* SyntaxKind.TypeLiteral */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 263 /* SyntaxKind.CaseBlock */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: + return nodeEndsWith(n, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + case 292 /* SyntaxKind.CatchClause */: return isCompletedNode(n.block, sourceFile); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: if (!n.arguments) { return true; } // falls through - case 208 /* CallExpression */: - case 212 /* ParenthesizedExpression */: - case 191 /* ParenthesizedType */: - return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 208 /* SyntaxKind.CallExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + return nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -128417,66 +129080,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 261 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 261 /* SyntaxKind.ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 204 /* ArrayLiteralExpression */: - case 202 /* ArrayBindingPattern */: - case 207 /* ElementAccessExpression */: - case 162 /* ComputedPropertyName */: - case 184 /* TupleType */: - return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 176 /* IndexSignature */: + hasChildOfKind(n, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 184 /* SyntaxKind.TupleType */: + return nodeEndsWith(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 176 /* SyntaxKind.IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + return hasChildOfKind(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 115 /* SyntaxKind.WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 216 /* TypeOfExpression */: - case 215 /* DeleteExpression */: - case 217 /* VoidExpression */: - case 224 /* YieldExpression */: - case 225 /* SpreadElement */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 225 /* SyntaxKind.SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -128493,7 +129156,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SyntaxKind.SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -128536,13 +129199,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 84 /* ClassKeyword */; + return node.kind === 84 /* SyntaxKind.ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 98 /* FunctionKeyword */; + return node.kind === 98 /* SyntaxKind.FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -128601,13 +129264,13 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return getAdjustedLocationForClass(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return getAdjustedLocationForFunction(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return node; } } @@ -128697,30 +129360,30 @@ var ts; // // NOTE: If the node is a modifier, we don't adjust its location if it is the `default` modifier as that is handled // specially by `getSymbolAtLocation`. - if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? ts.canHaveModifiers(parent) && ts.contains(parent.modifiers, node) : - node.kind === 84 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 98 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 118 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 92 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 152 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 142 /* NamespaceKeyword */ || node.kind === 141 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 136 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 149 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* SyntaxKind.DefaultKeyword */) ? ts.canHaveModifiers(parent) && ts.contains(parent.modifiers, node) : + node.kind === 84 /* SyntaxKind.ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : + node.kind === 98 /* SyntaxKind.FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : + node.kind === 118 /* SyntaxKind.InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : + node.kind === 92 /* SyntaxKind.EnumKeyword */ ? ts.isEnumDeclaration(parent) : + node.kind === 152 /* SyntaxKind.TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 142 /* SyntaxKind.NamespaceKeyword */ || node.kind === 141 /* SyntaxKind.ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 136 /* SyntaxKind.GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 149 /* SyntaxKind.SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && + if ((node.kind === 113 /* SyntaxKind.VarKeyword */ || node.kind === 85 /* SyntaxKind.ConstKeyword */ || node.kind === 119 /* SyntaxKind.LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 152 /* TypeKeyword */) { + if (node.kind === 152 /* SyntaxKind.TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -128746,7 +129409,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 127 /* AsKeyword */) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -128762,13 +129425,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* SyntaxKind.ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 93 /* ExportKeyword */) { + if (node.kind === 93 /* SyntaxKind.ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -128787,12 +129450,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 146 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 146 /* SyntaxKind.RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 156 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 156 /* SyntaxKind.FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -128800,13 +129463,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* SyntaxKind.ExtendsKeyword */ || node.kind === 117 /* SyntaxKind.ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 94 /* ExtendsKeyword */) { + if (node.kind === 94 /* SyntaxKind.ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -128817,20 +129480,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 137 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 137 /* SyntaxKind.InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 140 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* KeyOfKeyword */ && + if (node.kind === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 145 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* ReadonlyKeyword */ && + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -128845,29 +129508,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 132 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* SyntaxKind.NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* SyntaxKind.TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 132 /* SyntaxKind.AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* SyntaxKind.YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* SyntaxKind.DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* SyntaxKind.InKeyword */ || node.kind === 102 /* SyntaxKind.InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 160 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isForInStatement(parent) || + node.kind === 160 /* SyntaxKind.OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -128936,25 +129599,31 @@ var ts; // flag causes us to return the first node whose end position matches the position and which produces and acceptable token // kind. Meanwhile, if includePrecedingTokenAtEndPosition is unset, we look for the first node whose start is <= the // position and whose end is greater than the position. + // There are more sophisticated end tests later, but this one is very fast + // and allows us to skip a bunch of work + var end = children[middle].getEnd(); + if (end < position) { + return -1 /* Comparison.LessThan */; + } var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } // first element whose start position is before the input and whose end position is after or equal to the input - if (nodeContainsPosition(children[middle])) { + if (nodeContainsPosition(children[middle], start, end)) { if (children[middle - 1]) { // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position if (nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // this complex condition makes us left-recur around a zero-length node when includePrecedingTokenAtEndPosition is set, rather than right-recur on it if (includePrecedingTokenAtEndPosition && start === position && children[middle - 1] && children[middle - 1].getEnd() === position && nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (foundToken) { return { value: foundToken }; @@ -128973,14 +129642,17 @@ var ts; case "continue-outer": continue outer; } } - function nodeContainsPosition(node) { - var start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true); + function nodeContainsPosition(node, start, end) { + end !== null && end !== void 0 ? end : (end = node.getEnd()); + if (end < position) { + return false; + } + start !== null && start !== void 0 ? start : (start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true)); if (start > position) { // If this child begins after position, then all subsequent children will as well. return false; } - var end = node.getEnd(); - if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) { + if (position < end || (position === end && (node.kind === 1 /* SyntaxKind.EndOfFileToken */ || includeEndPosition))) { return true; } else if (includePrecedingTokenAtEndPosition && end === position) { @@ -129049,7 +129721,7 @@ var ts; ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; function find(n) { - if (isNonWhitespaceToken(n) && n.kind !== 1 /* EndOfFileToken */) { + if (isNonWhitespaceToken(n) && n.kind !== 1 /* SyntaxKind.EndOfFileToken */) { return n; } var children = n.getChildren(sourceFile); @@ -129061,11 +129733,11 @@ var ts; if (position < children[middle].end) { // first element whose end position is greater than the input position if (!children[middle - 1] || position >= children[middle - 1].end) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (i >= 0 && children[i]) { var child = children[i]; @@ -129090,7 +129762,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SyntaxKind.SourceFile */ || n.kind === 1 /* SyntaxKind.EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -129121,7 +129793,7 @@ var ts; for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 279 /* JsxSelfClosingElement */)) { + if (i === 0 && (parentKind === 11 /* SyntaxKind.JsxText */ || parentKind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); } } @@ -129157,25 +129829,25 @@ var ts; if (!token) { return false; } - if (token.kind === 11 /* JsxText */) { + if (token.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
Hello |
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 281 /* JsxClosingElement */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return true; } return false; @@ -129194,10 +129866,10 @@ var ts; if (ts.isJsxText(token)) { return true; } - if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -129206,17 +129878,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 279 /* JsxSelfClosingElement */ && node.kind <= 288 /* JsxExpression */ - || node.kind === 11 /* JsxText */ - || node.kind === 29 /* LessThanToken */ - || node.kind === 31 /* GreaterThanToken */ - || node.kind === 79 /* Identifier */ - || node.kind === 19 /* CloseBraceToken */ - || node.kind === 18 /* OpenBraceToken */ - || node.kind === 43 /* SlashToken */) { + if (node.kind >= 279 /* SyntaxKind.JsxSelfClosingElement */ && node.kind <= 288 /* SyntaxKind.JsxExpression */ + || node.kind === 11 /* SyntaxKind.JsxText */ + || node.kind === 29 /* SyntaxKind.LessThanToken */ + || node.kind === 31 /* SyntaxKind.GreaterThanToken */ + || node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 19 /* SyntaxKind.CloseBraceToken */ + || node.kind === 18 /* SyntaxKind.OpenBraceToken */ + || node.kind === 43 /* SyntaxKind.SlashToken */) { node = node.parent; } - else if (node.kind === 278 /* JsxElement */) { + else if (node.kind === 278 /* SyntaxKind.JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -129306,10 +129978,10 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); - if (token && token.kind === 28 /* QuestionDotToken */) { + if (token && token.kind === 28 /* SyntaxKind.QuestionDotToken */) { token = findPrecedingToken(token.getFullStart(), sourceFile); } if (!token || !ts.isIdentifier(token)) @@ -129319,56 +129991,56 @@ var ts; } remainingLessThanTokens--; break; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 48 /* GreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: remainingLessThanTokens++; break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* SyntaxKind.OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: nTypeArguments++; break; - case 38 /* EqualsGreaterThanToken */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: // falls through - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: // falls through - case 112 /* TypeOfKeyword */: - case 94 /* ExtendsKeyword */: - case 140 /* KeyOfKeyword */: - case 24 /* DotToken */: - case 51 /* BarToken */: - case 57 /* QuestionToken */: - case 58 /* ColonToken */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 94 /* SyntaxKind.ExtendsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 24 /* SyntaxKind.DotToken */: + case 51 /* SyntaxKind.BarToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 58 /* SyntaxKind.ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -129400,52 +130072,52 @@ var ts; function nodeHasTokens(n, sourceFile) { // If we have a token or node that has a non-zero width, it must have tokens. // Note: getWidth() does not take trivia into account. - return n.kind === 1 /* EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; + return n.kind === 1 /* SyntaxKind.EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node, excludeFlags) { - if (excludeFlags === void 0) { excludeFlags = 0 /* None */; } + if (excludeFlags === void 0) { excludeFlags = 0 /* ModifierFlags.None */; } var result = []; var flags = ts.isDeclaration(node) ? ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(node) & ~excludeFlags - : 0 /* None */; - if (flags & 8 /* Private */) - result.push("private" /* privateMemberModifier */); - if (flags & 16 /* Protected */) - result.push("protected" /* protectedMemberModifier */); - if (flags & 4 /* Public */) - result.push("public" /* publicMemberModifier */); - if (flags & 32 /* Static */ || ts.isClassStaticBlockDeclaration(node)) - result.push("static" /* staticModifier */); - if (flags & 128 /* Abstract */) - result.push("abstract" /* abstractModifier */); - if (flags & 1 /* Export */) - result.push("export" /* exportedModifier */); - if (flags & 8192 /* Deprecated */) - result.push("deprecated" /* deprecatedModifier */); - if (node.flags & 16777216 /* Ambient */) - result.push("declare" /* ambientModifier */); - if (node.kind === 271 /* ExportAssignment */) - result.push("export" /* exportedModifier */); - return result.length > 0 ? result.join(",") : "" /* none */; + : 0 /* ModifierFlags.None */; + if (flags & 8 /* ModifierFlags.Private */) + result.push("private" /* ScriptElementKindModifier.privateMemberModifier */); + if (flags & 16 /* ModifierFlags.Protected */) + result.push("protected" /* ScriptElementKindModifier.protectedMemberModifier */); + if (flags & 4 /* ModifierFlags.Public */) + result.push("public" /* ScriptElementKindModifier.publicMemberModifier */); + if (flags & 32 /* ModifierFlags.Static */ || ts.isClassStaticBlockDeclaration(node)) + result.push("static" /* ScriptElementKindModifier.staticModifier */); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push("abstract" /* ScriptElementKindModifier.abstractModifier */); + if (flags & 1 /* ModifierFlags.Export */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + if (flags & 8192 /* ModifierFlags.Deprecated */) + result.push("deprecated" /* ScriptElementKindModifier.deprecatedModifier */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) + result.push("declare" /* ScriptElementKindModifier.ambientModifier */); + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + return result.length > 0 ? result.join(",") : "" /* ScriptElementKindModifier.none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 178 /* TypeReference */ || node.kind === 208 /* CallExpression */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 208 /* SyntaxKind.CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 257 /* ClassDeclaration */ || node.kind === 258 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isComment(kind) { - return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; + return kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || kind === 3 /* SyntaxKind.MultiLineCommentTrivia */; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 10 /* StringLiteral */ - || kind === 13 /* RegularExpressionLiteral */ + if (kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 13 /* SyntaxKind.RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -129453,7 +130125,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; + return 18 /* SyntaxKind.FirstPunctuation */ <= kind && kind <= 78 /* SyntaxKind.LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -129463,9 +130135,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: return true; } return false; @@ -129478,18 +130150,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 204 /* ArrayLiteralExpression */ || - node.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || + node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 221 /* BinaryExpression */ && + if (node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 63 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 244 /* ForOfStatement */ && + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -129497,7 +130169,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -129520,8 +130192,8 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTextSpanFromStringLiteralLikeContent(contextToken); default: return createTextSpanFromNode(contextToken); @@ -129559,32 +130231,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 130 /* AnyKeyword */, - 128 /* AssertsKeyword */, - 158 /* BigIntKeyword */, - 133 /* BooleanKeyword */, - 95 /* FalseKeyword */, - 137 /* InferKeyword */, - 140 /* KeyOfKeyword */, - 143 /* NeverKeyword */, - 104 /* NullKeyword */, - 147 /* NumberKeyword */, - 148 /* ObjectKeyword */, - 145 /* ReadonlyKeyword */, - 150 /* StringKeyword */, - 151 /* SymbolKeyword */, - 110 /* TrueKeyword */, - 114 /* VoidKeyword */, - 153 /* UndefinedKeyword */, - 154 /* UniqueKeyword */, - 155 /* UnknownKeyword */, + 130 /* SyntaxKind.AnyKeyword */, + 128 /* SyntaxKind.AssertsKeyword */, + 158 /* SyntaxKind.BigIntKeyword */, + 133 /* SyntaxKind.BooleanKeyword */, + 95 /* SyntaxKind.FalseKeyword */, + 137 /* SyntaxKind.InferKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 143 /* SyntaxKind.NeverKeyword */, + 104 /* SyntaxKind.NullKeyword */, + 147 /* SyntaxKind.NumberKeyword */, + 148 /* SyntaxKind.ObjectKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 150 /* SyntaxKind.StringKeyword */, + 151 /* SyntaxKind.SymbolKeyword */, + 110 /* SyntaxKind.TrueKeyword */, + 114 /* SyntaxKind.VoidKeyword */, + 153 /* SyntaxKind.UndefinedKeyword */, + 154 /* SyntaxKind.UniqueKeyword */, + 155 /* SyntaxKind.UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 152 /* TypeKeyword */; + return node.kind === 152 /* SyntaxKind.TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; function isTypeKeywordTokenOrIdentifier(node) { @@ -129593,7 +130265,7 @@ var ts; ts.isTypeKeywordTokenOrIdentifier = isTypeKeywordTokenOrIdentifier; /** True if the symbol is for an external module, as opposed to a namespace. */ function isExternalModuleSymbol(moduleSymbol) { - return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */; + return !!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isExternalModuleSymbol = isExternalModuleSymbol; function nodeSeenTracker() { @@ -129621,7 +130293,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 162 /* ComputedPropertyName */ + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name); @@ -129636,7 +130308,7 @@ var ts; } ts.programContainsEsModules = programContainsEsModules; function compilerOptionsIndicateEsModules(compilerOptions) { - return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit; + return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ || !!compilerOptions.noEmit; } ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules; function createModuleSpecifierResolutionHost(program, host) { @@ -129684,7 +130356,7 @@ var ts; } ts.makeImport = makeImport; function makeStringLiteral(text, quotePreference) { - return ts.factory.createStringLiteral(text, quotePreference === 0 /* Single */); + return ts.factory.createStringLiteral(text, quotePreference === 0 /* QuotePreference.Single */); } ts.makeStringLiteral = makeStringLiteral; var QuotePreference; @@ -129693,25 +130365,25 @@ var ts; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); function quotePreferenceFromString(str, sourceFile) { - return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* QuotePreference.Double */ : 0 /* QuotePreference.Single */; } ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference && preferences.quotePreference !== "auto") { - return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; + return preferences.quotePreference === "single" ? 0 /* QuotePreference.Single */ : 1 /* QuotePreference.Double */; } else { // ignore synthetic import added when importHelpers: true var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, function (n) { return ts.isStringLiteral(n) && !ts.nodeIsSynthesized(n.parent); }); - return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* QuotePreference.Double */; } } ts.getQuotePreference = getQuotePreference; function getQuoteFromPreference(qp) { switch (qp) { - case 0 /* Single */: return "'"; - case 1 /* Double */: return '"'; + case 0 /* QuotePreference.Single */: return "'"; + case 1 /* QuotePreference.Double */: return '"'; default: return ts.Debug.assertNever(qp); } } @@ -129722,12 +130394,12 @@ var ts; } ts.symbolNameNoDefault = symbolNameNoDefault; function symbolEscapedNameNoDefault(symbol) { - if (symbol.escapedName !== "default" /* Default */) { + if (symbol.escapedName !== "default" /* InternalSymbolName.Default */) { return symbol.escapedName; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* SyntaxKind.Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -129771,7 +130443,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 237 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 237 /* SyntaxKind.VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate); var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports]; if (!existingImportStatements.length) { @@ -129984,34 +130656,34 @@ var ts; return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } - if (flags & 4 /* Property */) + if (flags & 4 /* SymbolFlags.Property */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 32768 /* GetAccessor */) + if (flags & 32768 /* SymbolFlags.GetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 65536 /* SetAccessor */) + if (flags & 65536 /* SymbolFlags.SetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 8 /* EnumMember */) + if (flags & 8 /* SymbolFlags.EnumMember */) return ts.SymbolDisplayPartKind.enumMemberName; - if (flags & 16 /* Function */) + if (flags & 16 /* SymbolFlags.Function */) return ts.SymbolDisplayPartKind.functionName; - if (flags & 32 /* Class */) + if (flags & 32 /* SymbolFlags.Class */) return ts.SymbolDisplayPartKind.className; - if (flags & 64 /* Interface */) + if (flags & 64 /* SymbolFlags.Interface */) return ts.SymbolDisplayPartKind.interfaceName; - if (flags & 384 /* Enum */) + if (flags & 384 /* SymbolFlags.Enum */) return ts.SymbolDisplayPartKind.enumName; - if (flags & 1536 /* Module */) + if (flags & 1536 /* SymbolFlags.Module */) return ts.SymbolDisplayPartKind.moduleName; - if (flags & 8192 /* Method */) + if (flags & 8192 /* SymbolFlags.Method */) return ts.SymbolDisplayPartKind.methodName; - if (flags & 262144 /* TypeParameter */) + if (flags & 262144 /* SymbolFlags.TypeParameter */) return ts.SymbolDisplayPartKind.typeParameterName; - if (flags & 524288 /* TypeAlias */) + if (flags & 524288 /* SymbolFlags.TypeAlias */) return ts.SymbolDisplayPartKind.aliasName; - if (flags & 2097152 /* Alias */) + if (flags & 2097152 /* SymbolFlags.Alias */) return ts.SymbolDisplayPartKind.aliasName; return ts.SymbolDisplayPartKind.text; } @@ -130088,7 +130760,7 @@ var ts; var prefix = ts.isJSDocLink(link) ? "link" : ts.isJSDocLinkCode(link) ? "linkcode" : "linkplain"; - var parts = [linkPart("{@" + prefix + " ")]; + var parts = [linkPart("{@".concat(prefix, " "))]; if (!link.name) { if (link.text) { parts.push(linkTextPart(link.text)); @@ -130115,8 +130787,8 @@ var ts; ts.buildLinkParts = buildLinkParts; function skipSeparatorFromLinkText(text) { var pos = 0; - if (text.charCodeAt(pos++) === 124 /* bar */) { - while (pos < text.length && text.charCodeAt(pos) === 32 /* space */) + if (text.charCodeAt(pos++) === 124 /* CharacterCodes.bar */) { + while (pos < text.length && text.charCodeAt(pos) === 32 /* CharacterCodes.space */) pos++; return text.slice(pos); } @@ -130166,22 +130838,22 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* SymbolFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer); + typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } - flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + flags |= 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */ | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */ | 8192 /* TypeFormatFlags.OmitParameterModifiers */; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer); }); @@ -130191,7 +130863,7 @@ var ts; var file = enclosingDeclaration.getSourceFile(); return mapToDisplayParts(function (writer) { var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - printer.writeNode(4 /* Unspecified */, node, file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, node, file, writer); }); } ts.nodeToDisplayParts = nodeToDisplayParts; @@ -130219,10 +130891,10 @@ var ts; } ts.getSymbolTarget = getSymbolTarget; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } function isAliasSymbol(symbol) { - return (symbol.flags & 2097152 /* Alias */) !== 0; + return (symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0; } function getUniqueSymbolId(symbol, checker) { return ts.getSymbolId(ts.skipAlias(symbol, checker)); @@ -130311,14 +130983,14 @@ var ts; * Sets EmitFlags to suppress leading trivia on the node. */ function suppressLeadingTrivia(node) { - addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); + addEmitFlagsRecursively(node, 512 /* EmitFlags.NoLeadingComments */, getFirstChild); } ts.suppressLeadingTrivia = suppressLeadingTrivia; /** * Sets EmitFlags to suppress trailing trivia on the node. */ function suppressTrailingTrivia(node) { - addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); + addEmitFlagsRecursively(node, 1024 /* EmitFlags.NoTrailingComments */, ts.getLastChild); } ts.suppressTrailingTrivia = suppressTrailingTrivia; function copyComments(sourceNode, targetNode) { @@ -130337,7 +131009,7 @@ var ts; var start = node.getFullStart(); var end = node.getStart(); for (var i = start; i < end; i++) { - if (text.charCodeAt(i) === 10 /* lineFeed */) + if (text.charCodeAt(i) === 10 /* CharacterCodes.lineFeed */) return true; } return false; @@ -130354,7 +131026,7 @@ var ts; function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { - nameText = baseName + "_" + i; + nameText = "".concat(baseName, "_").concat(i); } return nameText; } @@ -130373,7 +131045,7 @@ var ts; for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { var change = textChanges_1[_b]; var span = change.span, newText = change.newText; - var index = indexInTextChange(newText, name); + var index = indexInTextChange(newText, ts.escapeString(name)); if (index !== -1) { lastPos = span.start + delta + index; // If the reference comes first, return immediately. @@ -130411,7 +131083,7 @@ var ts; ts.copyTrailingAsLeadingComments = copyTrailingAsLeadingComments; function getAddCommentsFunction(targetNode, sourceFile, commentKind, hasTrailingNewLine, cb) { return function (pos, end, kind, htnl) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // Remove leading /* pos += 2; // Remove trailing */ @@ -130437,7 +131109,7 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || ts.isObjectLiteralExpression(expression) || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } @@ -130445,15 +131117,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checker.getContextualType(parent); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -130464,15 +131136,15 @@ var ts; // Editors can pass in undefined or empty string - we want to infer the preference in those cases. var quotePreference = getQuotePreference(sourceFile, preferences); var quoted = JSON.stringify(text); - return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; + return quotePreference === 0 /* QuotePreference.Single */ ? "'".concat(ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"'), "'") : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: return true; default: return false; @@ -130481,10 +131153,10 @@ var ts; ts.isEqualityOperatorKind = isEqualityOperatorKind; function isStringLiteralOrTemplate(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 210 /* TaggedTemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return true; default: return false; @@ -130504,9 +131176,9 @@ var ts; var checker = program.getTypeChecker(); var typeIsAccessible = true; var notAccessible = function () { return typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { + var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NodeBuilderFlags.NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */; return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, @@ -130518,48 +131190,48 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 174 /* CallSignature */ - || kind === 175 /* ConstructSignature */ - || kind === 176 /* IndexSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */; + return kind === 174 /* SyntaxKind.CallSignature */ + || kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */; } function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 261 /* ModuleDeclaration */; + return kind === 261 /* SyntaxKind.ModuleDeclaration */; } function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 237 /* VariableStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 240 /* DoStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 246 /* BreakStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 167 /* PropertyDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); function nodeIsASICandidate(node, sourceFile) { var lastToken = node.getLastToken(sourceFile); - if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + if (lastToken && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */) { return false; } if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { - if (lastToken && lastToken.kind === 27 /* CommaToken */) { + if (lastToken && lastToken.kind === 27 /* SyntaxKind.CommaToken */) { return false; } } @@ -130579,12 +131251,12 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 240 /* DoStatement */) { + if (node.kind === 240 /* SyntaxKind.DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); var nextToken = findNextToken(node, topNode, sourceFile); - if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + if (!nextToken || nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { return true; } var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; @@ -130608,7 +131280,7 @@ var ts; ts.forEachChild(sourceFile, function visit(node) { if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } else { @@ -130617,10 +131289,10 @@ var ts; } else if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } - else if (lastToken && lastToken.kind !== 27 /* CommaToken */) { + else if (lastToken && lastToken.kind !== 27 /* SyntaxKind.CommaToken */) { var lastTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, lastToken.getStart(sourceFile)).line; var nextTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, ts.getSpanOfTokenAtPosition(sourceFile, lastToken.end).start).line; // Avoid counting missing semicolon in single-line objects: @@ -130744,16 +131416,16 @@ var ts; } } var dependencyGroups = [ - [1 /* Dependencies */, info.dependencies], - [2 /* DevDependencies */, info.devDependencies], - [8 /* OptionalDependencies */, info.optionalDependencies], - [4 /* PeerDependencies */, info.peerDependencies], + [1 /* PackageJsonDependencyGroup.Dependencies */, info.dependencies], + [2 /* PackageJsonDependencyGroup.DevDependencies */, info.devDependencies], + [8 /* PackageJsonDependencyGroup.OptionalDependencies */, info.optionalDependencies], + [4 /* PackageJsonDependencyGroup.PeerDependencies */, info.peerDependencies], ]; return __assign(__assign({}, info), { parseable: !!content, fileName: fileName, get: get, has: function (dependencyName, inGroups) { return !!get(dependencyName, inGroups); } }); function get(dependencyName, inGroups) { - if (inGroups === void 0) { inGroups = 15 /* All */; } + if (inGroups === void 0) { inGroups = 15 /* PackageJsonDependencyGroup.All */; } for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; if (deps && (inGroups & group_1)) { @@ -130848,7 +131520,7 @@ var ts; var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); // Scoped packages if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; + return "".concat(components[0], "/").concat(components[1]); } return components[0]; } @@ -130968,20 +131640,20 @@ var ts; } ts.getNameForExportedSymbol = getNameForExportedSymbol; function needsNameFromDeclaration(symbol) { - return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */); + return !(symbol.flags & 33554432 /* SymbolFlags.Transient */) && (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */ || symbol.escapedName === "default" /* InternalSymbolName.Default */); } function getDefaultLikeExportNameFromDeclaration(symbol) { return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; }); } function getSymbolParentOrFail(symbol) { var _a; - return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " + - ("Declarations: " + ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { + return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: ".concat(ts.Debug.formatSymbolFlags(symbol.flags), ". ") + + "Declarations: ".concat((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { var kind = ts.Debug.formatSyntaxKind(d.kind); var inJS = ts.isInJSFile(d); var expression = d.expression; - return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: " + ts.Debug.formatSyntaxKind(expression.kind) + ")" : ""); - }).join(", ")) + ".")); + return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: ".concat(ts.Debug.formatSyntaxKind(expression.kind), ")") : ""); + }).join(", "), ".")); } /** * Useful to check whether a string contains another string at a specific index @@ -131014,7 +131686,7 @@ var ts; } ts.stringContainsAt = stringContainsAt; function startsWithUnderscore(name) { - return name.charCodeAt(0) === 95 /* _ */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */; } ts.startsWithUnderscore = startsWithUnderscore; function isGlobalDeclaration(declaration) { @@ -131032,7 +131704,7 @@ var ts; } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* ModifierFlags.Deprecated */); } ts.isDeprecatedDeclaration = isDeprecatedDeclaration; function shouldUseUriStyleNodeCoreModules(file, program) { @@ -131045,7 +131717,7 @@ var ts; } ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules; function getNewLineKind(newLineCharacter) { - return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + return newLineCharacter === "\n" ? 1 /* NewLineKind.LineFeed */ : 0 /* NewLineKind.CarriageReturnLineFeed */; } ts.getNewLineKind = getNewLineKind; function diagnosticToString(diag) { @@ -131065,7 +131737,7 @@ var ts; } ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting; function jsxModeNeedsExplicitImport(jsx) { - return jsx === 2 /* React */ || jsx === 3 /* ReactNative */; + return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */; } ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport; // #endregion @@ -131137,7 +131809,7 @@ var ts; } } } - var isDefault = exportKind === 1 /* Default */; + var isDefault = exportKind === 1 /* ExportKind.Default */; var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol; // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`. // 2. A re-export merged with an export from a module augmentation can result in `symbol` @@ -131146,7 +131818,7 @@ var ts; // 3. Otherwise, we have a default/namespace import that can be imported by any name, and // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to // get a better name. - var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol) + var names = exportKind === 0 /* ExportKind.Named */ || ts.isExternalModuleSymbol(namedSymbol) ? ts.unescapeLeadingUnderscores(symbolTableKey) : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined); var symbolName = typeof names === "string" ? names : names[0]; @@ -131154,8 +131826,8 @@ var ts; var moduleName = ts.stripQuotes(moduleSymbol.name); var id = exportInfoId++; var target = ts.skipAlias(symbol, checker); - var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol; - var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol; + var storedSymbol = symbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : symbol; + var storedModuleSymbol = moduleSymbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : moduleSymbol; if (!storedSymbol || !storedModuleSymbol) symbols.set(id, [symbol, moduleSymbol]); exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), { @@ -131244,9 +131916,9 @@ var ts; var moduleSymbol = info.moduleSymbol || cachedModuleSymbol || ts.Debug.checkDefined(info.moduleFile ? checker.getMergedSymbol(info.moduleFile.symbol) : checker.tryFindAmbientModule(info.moduleName)); - var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportEquals */ + var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportKind.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) - : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '" + info.symbolName + "' by key '" + info.symbolTableKey + "' in module " + moduleSymbol.name); + : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '".concat(info.symbolName, "' by key '").concat(info.symbolTableKey, "' in module ").concat(moduleSymbol.name)); symbols.set(id, [symbol, moduleSymbol]); return { symbol: symbol, @@ -131259,7 +131931,7 @@ var ts; } function key(importedName, symbol, ambientModuleName, checker) { var moduleKey = ambientModuleName || ""; - return importedName + "|" + ts.getSymbolId(ts.skipAlias(symbol, checker)) + "|" + moduleKey; + return "".concat(importedName, "|").concat(ts.getSymbolId(ts.skipAlias(symbol, checker)), "|").concat(moduleKey); } function parseKey(key) { var symbolName = key.substring(0, key.indexOf("|")); @@ -131355,7 +132027,7 @@ var ts; if (autoImportProvider) { var start = ts.timestamp(); forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: ".concat(ts.timestamp() - start)); } } ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; @@ -131404,11 +132076,11 @@ var ts; // Note: I think we shouldn't actually see resolved module symbols here, but weird merges // can cause it to happen: see 'completionsImport_mergedReExport.ts' if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { - cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); + cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* ExportKind.Default */ ? "default" /* InternalSymbolName.Default */ : "export=" /* InternalSymbolName.ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); } checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { - cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker); + cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* ExportKind.Named */, isFromPackageJson, checker); } }); }); @@ -131418,7 +132090,7 @@ var ts; cache.clear(); throw err; } - (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in ".concat(ts.timestamp() - start, " ms")); return cache; } ts.getExportInfoMap = getExportInfoMap; @@ -131437,10 +132109,10 @@ var ts; function getDefaultLikeExportWorker(moduleSymbol, checker) { var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) - return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ }; - var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); + return { symbol: exportEquals, exportKind: 2 /* ExportKind.ExportEquals */ }; + var defaultExport = checker.tryGetMemberInModuleExports("default" /* InternalSymbolName.Default */, moduleSymbol); if (defaultExport) - return { symbol: defaultExport, exportKind: 1 /* Default */ }; + return { symbol: defaultExport, exportKind: 1 /* ExportKind.Default */ }; } function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -131449,7 +132121,7 @@ var ts; var name = getNameForExportDefault(defaultExport); if (name !== undefined) return { symbolForMeaning: defaultExport, name: name }; - if (defaultExport.flags & 2097152 /* Alias */) { + if (defaultExport.flags & 2097152 /* SymbolFlags.Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); if (aliased && aliased.parent) { // - `aliased` will be undefined if the module is exporting an unresolvable name, @@ -131459,8 +132131,8 @@ var ts; return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } - if (defaultExport.escapedName !== "default" /* Default */ && - defaultExport.escapedName !== "export=" /* ExportEquals */) { + if (defaultExport.escapedName !== "default" /* InternalSymbolName.Default */ && + defaultExport.escapedName !== "export=" /* InternalSymbolName.ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; @@ -131472,7 +132144,7 @@ var ts; return (_a = ts.tryCast(ts.skipOuterExpressions(declaration.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); + ts.Debug.assert(declaration.name.text === "default" /* InternalSymbolName.Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -131482,15 +132154,15 @@ var ts; (function (ts) { /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { return convertClassificationsToResult(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); } // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var token = 0 /* Unknown */; - var lastNonTriviaToken = 0 /* Unknown */; + var token = 0 /* SyntaxKind.Unknown */; + var lastNonTriviaToken = 0 /* SyntaxKind.Unknown */; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -131516,10 +132188,10 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(15 /* TemplateHead */); + templateStack.push(15 /* SyntaxKind.TemplateHead */); } scanner.setText(text); - var endOfLineState = 0 /* None */; + var endOfLineState = 0 /* EndOfLineState.None */; var spans = []; // We can run into an unfortunate interaction between the lexical and syntactic classifier // when the user is typing something generic. Consider the case where the user types: @@ -131555,68 +132227,68 @@ var ts; endOfLineState = end_1; } } - } while (token !== 1 /* EndOfFileToken */); + } while (token !== 1 /* SyntaxKind.EndOfFileToken */); function handleToken() { switch (token) { - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { - token = 13 /* RegularExpressionLiteral */; + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } break; - case 29 /* LessThanToken */: - if (lastNonTriviaToken === 79 /* Identifier */) { + case 29 /* SyntaxKind.LessThanToken */: + if (lastNonTriviaToken === 79 /* SyntaxKind.Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 130 /* AnyKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: templateStack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 15 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* SyntaxKind.TemplateHead */) { token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 17 /* TemplateTail */) { + if (token === 17 /* SyntaxKind.TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* SyntaxKind.TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* SyntaxKind.OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -131625,15 +132297,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 24 /* DotToken */) { - token = 79 /* Identifier */; + if (lastNonTriviaToken === 24 /* SyntaxKind.DotToken */) { + token = 79 /* SyntaxKind.Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } } } @@ -131647,59 +132319,59 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 79 /* Identifier */, - 10 /* StringLiteral */, - 8 /* NumericLiteral */, - 9 /* BigIntLiteral */, - 13 /* RegularExpressionLiteral */, - 108 /* ThisKeyword */, - 45 /* PlusPlusToken */, - 46 /* MinusMinusToken */, - 21 /* CloseParenToken */, - 23 /* CloseBracketToken */, - 19 /* CloseBraceToken */, - 110 /* TrueKeyword */, - 95 /* FalseKeyword */, + 79 /* SyntaxKind.Identifier */, + 10 /* SyntaxKind.StringLiteral */, + 8 /* SyntaxKind.NumericLiteral */, + 9 /* SyntaxKind.BigIntLiteral */, + 13 /* SyntaxKind.RegularExpressionLiteral */, + 108 /* SyntaxKind.ThisKeyword */, + 45 /* SyntaxKind.PlusPlusToken */, + 46 /* SyntaxKind.MinusMinusToken */, + 21 /* SyntaxKind.CloseParenToken */, + 23 /* SyntaxKind.CloseBracketToken */, + 19 /* SyntaxKind.CloseBraceToken */, + 110 /* SyntaxKind.TrueKeyword */, + 95 /* SyntaxKind.FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 10 /* StringLiteral */: { + case 10 /* SyntaxKind.StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; var tokenText = scanner.getTokenText(); var lastCharIndex = tokenText.length - 1; var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* CharacterCodes.backslash */) { numBackslashes++; } // If we have an odd number of backslashes, then the multiline string is unclosed if ((numBackslashes & 1) === 0) return undefined; - return tokenText.charCodeAt(0) === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + return tokenText.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */ ? 3 /* EndOfLineState.InDoubleQuoteStringLiteral */ : 2 /* EndOfLineState.InSingleQuoteStringLiteral */; } - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Check to see if the multiline comment was unclosed. - return scanner.isUnterminated() ? 1 /* InMultiLineCommentTrivia */ : undefined; + return scanner.isUnterminated() ? 1 /* EndOfLineState.InMultiLineCommentTrivia */ : undefined; default: if (ts.isTemplateLiteralKind(token)) { if (!scanner.isUnterminated()) { return undefined; } switch (token) { - case 17 /* TemplateTail */: - return 5 /* InTemplateMiddleOrTail */; - case 14 /* NoSubstitutionTemplateLiteral */: - return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + case 17 /* SyntaxKind.TemplateTail */: + return 5 /* EndOfLineState.InTemplateMiddleOrTail */; + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + return 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* SyntaxKind.TemplateHead */ ? 6 /* EndOfLineState.InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { - if (classification === 8 /* whiteSpace */) { + if (classification === 8 /* ClassificationType.whiteSpace */) { // Don't bother with whitespace classifications. They're not needed. return; } @@ -131741,23 +132413,23 @@ var ts; } function convertClassification(type) { switch (type) { - case 1 /* comment */: return ts.TokenClass.Comment; - case 3 /* keyword */: return ts.TokenClass.Keyword; - case 4 /* numericLiteral */: return ts.TokenClass.NumberLiteral; - case 25 /* bigintLiteral */: return ts.TokenClass.BigIntLiteral; - case 5 /* operator */: return ts.TokenClass.Operator; - case 6 /* stringLiteral */: return ts.TokenClass.StringLiteral; - case 8 /* whiteSpace */: return ts.TokenClass.Whitespace; - case 10 /* punctuation */: return ts.TokenClass.Punctuation; - case 2 /* identifier */: - case 11 /* className */: - case 12 /* enumName */: - case 13 /* interfaceName */: - case 14 /* moduleName */: - case 15 /* typeParameterName */: - case 16 /* typeAliasName */: - case 9 /* text */: - case 17 /* parameterName */: + case 1 /* ClassificationType.comment */: return ts.TokenClass.Comment; + case 3 /* ClassificationType.keyword */: return ts.TokenClass.Keyword; + case 4 /* ClassificationType.numericLiteral */: return ts.TokenClass.NumberLiteral; + case 25 /* ClassificationType.bigintLiteral */: return ts.TokenClass.BigIntLiteral; + case 5 /* ClassificationType.operator */: return ts.TokenClass.Operator; + case 6 /* ClassificationType.stringLiteral */: return ts.TokenClass.StringLiteral; + case 8 /* ClassificationType.whiteSpace */: return ts.TokenClass.Whitespace; + case 10 /* ClassificationType.punctuation */: return ts.TokenClass.Punctuation; + case 2 /* ClassificationType.identifier */: + case 11 /* ClassificationType.className */: + case 12 /* ClassificationType.enumName */: + case 13 /* ClassificationType.interfaceName */: + case 14 /* ClassificationType.moduleName */: + case 15 /* ClassificationType.typeParameterName */: + case 16 /* ClassificationType.typeAliasName */: + case 9 /* ClassificationType.text */: + case 17 /* ClassificationType.parameterName */: return ts.TokenClass.Identifier; default: return undefined; // TODO: GH#18217 Debug.assertNever(type); @@ -131771,10 +132443,10 @@ var ts; return true; } switch (keyword2) { - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 134 /* ConstructorKeyword */: - case 124 /* StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -131787,19 +132459,19 @@ var ts; // If we're in a multiline comment, then prepend: /* // (and a newline). That way when we lex we'll think we're still in a multiline comment. switch (lexState) { - case 3 /* InDoubleQuoteStringLiteral */: + case 3 /* EndOfLineState.InDoubleQuoteStringLiteral */: return { prefix: "\"\\\n" }; - case 2 /* InSingleQuoteStringLiteral */: + case 2 /* EndOfLineState.InSingleQuoteStringLiteral */: return { prefix: "'\\\n" }; - case 1 /* InMultiLineCommentTrivia */: + case 1 /* EndOfLineState.InMultiLineCommentTrivia */: return { prefix: "/*\n" }; - case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: + case 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */: return { prefix: "`\n" }; - case 5 /* InTemplateMiddleOrTail */: + case 5 /* EndOfLineState.InTemplateMiddleOrTail */: return { prefix: "}\n", pushTemplate: true }; - case 6 /* InTemplateSubstitutionPosition */: + case 6 /* EndOfLineState.InTemplateSubstitutionPosition */: return { prefix: "", pushTemplate: true }; - case 0 /* None */: + case 0 /* EndOfLineState.None */: return { prefix: "" }; default: return ts.Debug.assertNever(lexState); @@ -131807,47 +132479,47 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 50 /* AmpersandToken */: - case 52 /* CaretToken */: - case 51 /* BarToken */: - case 55 /* AmpersandAmpersandToken */: - case 56 /* BarBarToken */: - case 74 /* BarEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 63 /* EqualsToken */: - case 27 /* CommaToken */: - case 60 /* QuestionQuestionToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 52 /* SyntaxKind.CaretToken */: + case 51 /* SyntaxKind.BarToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return true; default: return false; @@ -131855,12 +132527,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: return true; default: return false; @@ -131868,36 +132540,36 @@ var ts; } function classFromKind(token) { if (ts.isKeyword(token)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5 /* operator */; + return 5 /* ClassificationType.operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { - return 10 /* punctuation */; + else if (token >= 18 /* SyntaxKind.FirstPunctuation */ && token <= 78 /* SyntaxKind.LastPunctuation */) { + return 10 /* ClassificationType.punctuation */; } switch (token) { - case 8 /* NumericLiteral */: - return 4 /* numericLiteral */; - case 9 /* BigIntLiteral */: - return 25 /* bigintLiteral */; - case 10 /* StringLiteral */: - return 6 /* stringLiteral */; - case 13 /* RegularExpressionLiteral */: - return 7 /* regularExpressionLiteral */; - case 7 /* ConflictMarkerTrivia */: - case 3 /* MultiLineCommentTrivia */: - case 2 /* SingleLineCommentTrivia */: - return 1 /* comment */; - case 5 /* WhitespaceTrivia */: - case 4 /* NewLineTrivia */: - return 8 /* whiteSpace */; - case 79 /* Identifier */: + case 8 /* SyntaxKind.NumericLiteral */: + return 4 /* ClassificationType.numericLiteral */; + case 9 /* SyntaxKind.BigIntLiteral */: + return 25 /* ClassificationType.bigintLiteral */; + case 10 /* SyntaxKind.StringLiteral */: + return 6 /* ClassificationType.stringLiteral */; + case 13 /* SyntaxKind.RegularExpressionLiteral */: + return 7 /* ClassificationType.regularExpressionLiteral */; + case 7 /* SyntaxKind.ConflictMarkerTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + return 1 /* ClassificationType.comment */; + case 5 /* SyntaxKind.WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + return 8 /* ClassificationType.whiteSpace */; + case 79 /* SyntaxKind.Identifier */: default: if (ts.isTemplateLiteralKind(token)) { - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } /* @internal */ @@ -131917,13 +132589,13 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -131948,10 +132620,10 @@ var ts; } node.forEachChild(cb); }); - return { spans: spans, endOfLineState: 0 /* None */ }; + return { spans: spans, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, end, type) { var length = end - start; - ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); + ts.Debug.assert(length > 0, "Classification had non-positive length of ".concat(length)); spans.push(start); spans.push(length); spans.push(type); @@ -131960,29 +132632,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function classifySymbol(symbol, meaningAtPosition, checker) { var flags = symbol.getFlags(); - if ((flags & 2885600 /* Classifiable */) === 0 /* None */) { + if ((flags & 2885600 /* SymbolFlags.Classifiable */) === 0 /* SymbolFlags.None */) { return undefined; } - else if (flags & 32 /* Class */) { - return 11 /* className */; + else if (flags & 32 /* SymbolFlags.Class */) { + return 11 /* ClassificationType.className */; } - else if (flags & 384 /* Enum */) { - return 12 /* enumName */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 12 /* ClassificationType.enumName */; } - else if (flags & 524288 /* TypeAlias */) { - return 16 /* typeAliasName */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 16 /* ClassificationType.typeAliasName */; } - else if (flags & 1536 /* Module */) { + else if (flags & 1536 /* SymbolFlags.Module */) { // Only classify a module as such if // - It appears in a namespace context. // - There exists a module declaration which actually impacts the value side. - return meaningAtPosition & 4 /* Namespace */ || meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol) ? 14 /* moduleName */ : undefined; + return meaningAtPosition & 4 /* SemanticMeaning.Namespace */ || meaningAtPosition & 1 /* SemanticMeaning.Value */ && hasValueSideModule(symbol) ? 14 /* ClassificationType.moduleName */ : undefined; } - else if (flags & 2097152 /* Alias */) { + else if (flags & 2097152 /* SymbolFlags.Alias */) { return classifySymbol(checker.getAliasedSymbol(symbol), meaningAtPosition, checker); } - else if (meaningAtPosition & 2 /* Type */) { - return flags & 64 /* Interface */ ? 13 /* interfaceName */ : flags & 262144 /* TypeParameter */ ? 15 /* typeParameterName */ : undefined; + else if (meaningAtPosition & 2 /* SemanticMeaning.Type */) { + return flags & 64 /* SymbolFlags.Interface */ ? 13 /* ClassificationType.interfaceName */ : flags & 262144 /* SymbolFlags.TypeParameter */ ? 15 /* ClassificationType.typeParameterName */ : undefined; } else { return undefined; @@ -131991,35 +132663,35 @@ var ts; /** Returns true if there exists a module that introduces entities on the value side. */ function hasValueSideModule(symbol) { return ts.some(symbol.declarations, function (declaration) { - return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; + return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* ModuleInstanceState.Instantiated */; }); } function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return "comment" /* comment */; - case 2 /* identifier */: return "identifier" /* identifier */; - case 3 /* keyword */: return "keyword" /* keyword */; - case 4 /* numericLiteral */: return "number" /* numericLiteral */; - case 25 /* bigintLiteral */: return "bigint" /* bigintLiteral */; - case 5 /* operator */: return "operator" /* operator */; - case 6 /* stringLiteral */: return "string" /* stringLiteral */; - case 8 /* whiteSpace */: return "whitespace" /* whiteSpace */; - case 9 /* text */: return "text" /* text */; - case 10 /* punctuation */: return "punctuation" /* punctuation */; - case 11 /* className */: return "class name" /* className */; - case 12 /* enumName */: return "enum name" /* enumName */; - case 13 /* interfaceName */: return "interface name" /* interfaceName */; - case 14 /* moduleName */: return "module name" /* moduleName */; - case 15 /* typeParameterName */: return "type parameter name" /* typeParameterName */; - case 16 /* typeAliasName */: return "type alias name" /* typeAliasName */; - case 17 /* parameterName */: return "parameter name" /* parameterName */; - case 18 /* docCommentTagName */: return "doc comment tag name" /* docCommentTagName */; - case 19 /* jsxOpenTagName */: return "jsx open tag name" /* jsxOpenTagName */; - case 20 /* jsxCloseTagName */: return "jsx close tag name" /* jsxCloseTagName */; - case 21 /* jsxSelfClosingTagName */: return "jsx self closing tag name" /* jsxSelfClosingTagName */; - case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; - case 23 /* jsxText */: return "jsx text" /* jsxText */; - case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + case 1 /* ClassificationType.comment */: return "comment" /* ClassificationTypeNames.comment */; + case 2 /* ClassificationType.identifier */: return "identifier" /* ClassificationTypeNames.identifier */; + case 3 /* ClassificationType.keyword */: return "keyword" /* ClassificationTypeNames.keyword */; + case 4 /* ClassificationType.numericLiteral */: return "number" /* ClassificationTypeNames.numericLiteral */; + case 25 /* ClassificationType.bigintLiteral */: return "bigint" /* ClassificationTypeNames.bigintLiteral */; + case 5 /* ClassificationType.operator */: return "operator" /* ClassificationTypeNames.operator */; + case 6 /* ClassificationType.stringLiteral */: return "string" /* ClassificationTypeNames.stringLiteral */; + case 8 /* ClassificationType.whiteSpace */: return "whitespace" /* ClassificationTypeNames.whiteSpace */; + case 9 /* ClassificationType.text */: return "text" /* ClassificationTypeNames.text */; + case 10 /* ClassificationType.punctuation */: return "punctuation" /* ClassificationTypeNames.punctuation */; + case 11 /* ClassificationType.className */: return "class name" /* ClassificationTypeNames.className */; + case 12 /* ClassificationType.enumName */: return "enum name" /* ClassificationTypeNames.enumName */; + case 13 /* ClassificationType.interfaceName */: return "interface name" /* ClassificationTypeNames.interfaceName */; + case 14 /* ClassificationType.moduleName */: return "module name" /* ClassificationTypeNames.moduleName */; + case 15 /* ClassificationType.typeParameterName */: return "type parameter name" /* ClassificationTypeNames.typeParameterName */; + case 16 /* ClassificationType.typeAliasName */: return "type alias name" /* ClassificationTypeNames.typeAliasName */; + case 17 /* ClassificationType.parameterName */: return "parameter name" /* ClassificationTypeNames.parameterName */; + case 18 /* ClassificationType.docCommentTagName */: return "doc comment tag name" /* ClassificationTypeNames.docCommentTagName */; + case 19 /* ClassificationType.jsxOpenTagName */: return "jsx open tag name" /* ClassificationTypeNames.jsxOpenTagName */; + case 20 /* ClassificationType.jsxCloseTagName */: return "jsx close tag name" /* ClassificationTypeNames.jsxCloseTagName */; + case 21 /* ClassificationType.jsxSelfClosingTagName */: return "jsx self closing tag name" /* ClassificationTypeNames.jsxSelfClosingTagName */; + case 22 /* ClassificationType.jsxAttribute */: return "jsx attribute" /* ClassificationTypeNames.jsxAttribute */; + case 23 /* ClassificationType.jsxText */: return "jsx text" /* ClassificationTypeNames.jsxText */; + case 24 /* ClassificationType.jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* ClassificationTypeNames.jsxAttributeStringLiteralValue */; default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type); } } @@ -132045,11 +132717,11 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; + return { spans: result, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, length, type) { result.push(start); result.push(length); @@ -132071,12 +132743,12 @@ var ts; return start; } switch (kind) { - case 4 /* NewLineTrivia */: - case 5 /* WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // Don't bother with newlines/whitespace. continue; - case 2 /* SingleLineCommentTrivia */: - case 3 /* MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Only bother with the trivia if it at least intersects the span of interest. classifyComment(token, kind, start, width); // Classifying a comment might cause us to reuse the trivia scanner @@ -132084,21 +132756,21 @@ var ts; // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; - case 7 /* ConflictMarkerTrivia */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { + pushClassification(start, width, 1 /* ClassificationType.comment */); continue; } // for the ||||||| and ======== markers, add a comment for the first line, // and then lex all subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); classifyDisabledMergeCode(text, start, end); break; - case 6 /* ShebangTrivia */: + case 6 /* SyntaxKind.ShebangTrivia */: // TODO: Maybe we should classify these. break; default: @@ -132107,7 +132779,7 @@ var ts; } } function classifyComment(token, kind, start, width) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // See if this is a doc comment. If so, we'll classify certain portions of it // specially. var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); @@ -132118,7 +132790,7 @@ var ts; return; } } - else if (kind === 2 /* SingleLineCommentTrivia */) { + else if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { if (tryClassifyTripleSlashComment(start, width)) { return; } @@ -132127,7 +132799,7 @@ var ts; pushCommentRange(start, width); } function pushCommentRange(start, width) { - pushClassification(start, width, 1 /* comment */); + pushClassification(start, width, 1 /* ClassificationType.comment */); } function classifyJSDocComment(docComment) { var _a, _b, _c, _d, _e, _f, _g; @@ -132140,51 +132812,51 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" + pushClassification(tag.pos, 1, 10 /* ClassificationType.punctuation */); // "@" + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* ClassificationType.docCommentTagName */); // e.g. "param" pos = tag.tagName.end; var commentStart = tag.tagName.end; switch (tag.kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var param = tag; processJSDocParameterTag(param); commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end; break; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var prop = tag; commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; commentStart = tag.typeParameters.end; break; - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: var type = tag; - commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; break; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: commentStart = tag.typeExpression.end; break; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = tag.typeExpression.end; break; - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: commentStart = tag.typeExpression.end; break; - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; break; - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: commentStart = tag.class.end; break; } @@ -132203,7 +132875,7 @@ var ts; function processJSDocParameterTag(tag) { if (tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } if (tag.typeExpression) { @@ -132213,7 +132885,7 @@ var ts; } if (!tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } } @@ -132238,9 +132910,9 @@ var ts; var pos = start; pushCommentRange(pos, match[1].length); // /// pos += match[1].length; - pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pushClassification(pos, match[2].length, 10 /* ClassificationType.punctuation */); // < pos += match[2].length; - pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pushClassification(pos, match[3].length, 21 /* ClassificationType.jsxSelfClosingTagName */); // element name pos += match[3].length; var attrText = match[4]; var attrPos = pos; @@ -132254,19 +132926,19 @@ var ts; pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + pushClassification(attrPos, attrMatch[2].length, 22 /* ClassificationType.jsxAttribute */); // attribute name attrPos += attrMatch[2].length; if (attrMatch[3].length) { pushCommentRange(attrPos, attrMatch[3].length); // whitespace attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + pushClassification(attrPos, attrMatch[4].length, 5 /* ClassificationType.operator */); // = attrPos += attrMatch[4].length; if (attrMatch[5].length) { pushCommentRange(attrPos, attrMatch[5].length); // whitespace attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + pushClassification(attrPos, attrMatch[6].length, 24 /* ClassificationType.jsxAttributeStringLiteralValue */); // attribute value attrPos += attrMatch[6].length; } pos += match[4].length; @@ -132274,7 +132946,7 @@ var ts; pushCommentRange(attrPos, pos - attrPos); } if (match[5]) { - pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pushClassification(pos, match[5].length, 10 /* ClassificationType.punctuation */); // /> pos += match[5].length; } var end = start + width; @@ -132298,7 +132970,7 @@ var ts; break; } } - pushClassification(start, i - start, 1 /* comment */); + pushClassification(start, i - start, 1 /* ClassificationType.comment */); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { classifyDisabledCodeToken(); @@ -132325,10 +132997,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* SyntaxKind.JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* SyntaxKind.JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -132341,24 +133013,24 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: if (token.parent.tagName === token) { - return 19 /* jsxOpenTagName */; + return 19 /* ClassificationType.jsxOpenTagName */; } break; - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: if (token.parent.tagName === token) { - return 20 /* jsxCloseTagName */; + return 20 /* ClassificationType.jsxCloseTagName */; } break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: if (token.parent.tagName === token) { - return 21 /* jsxSelfClosingTagName */; + return 21 /* ClassificationType.jsxSelfClosingTagName */; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: if (token.parent.name === token) { - return 22 /* jsxAttribute */; + return 22 /* ClassificationType.jsxAttribute */; } break; } @@ -132369,97 +133041,97 @@ var ts; // classify based on that instead. function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { + if (tokenKind === 29 /* SyntaxKind.LessThanToken */ || tokenKind === 31 /* SyntaxKind.GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } } if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 63 /* EqualsToken */) { + if (tokenKind === 63 /* SyntaxKind.EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 254 /* VariableDeclaration */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 164 /* Parameter */ || - parent.kind === 285 /* JsxAttribute */) { - return 5 /* operator */; + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 164 /* SyntaxKind.Parameter */ || + parent.kind === 285 /* SyntaxKind.JsxAttribute */) { + return 5 /* ClassificationType.operator */; } } - if (parent.kind === 221 /* BinaryExpression */ || - parent.kind === 219 /* PrefixUnaryExpression */ || - parent.kind === 220 /* PostfixUnaryExpression */ || - parent.kind === 222 /* ConditionalExpression */) { - return 5 /* operator */; + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ || + parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || + parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */ || + parent.kind === 222 /* SyntaxKind.ConditionalExpression */) { + return 5 /* ClassificationType.operator */; } } - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } - else if (tokenKind === 8 /* NumericLiteral */) { - return 4 /* numericLiteral */; + else if (tokenKind === 8 /* SyntaxKind.NumericLiteral */) { + return 4 /* ClassificationType.numericLiteral */; } - else if (tokenKind === 9 /* BigIntLiteral */) { - return 25 /* bigintLiteral */; + else if (tokenKind === 9 /* SyntaxKind.BigIntLiteral */) { + return 25 /* ClassificationType.bigintLiteral */; } - else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 285 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 10 /* SyntaxKind.StringLiteral */) { + return token && token.parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? 24 /* ClassificationType.jsxAttributeStringLiteralValue */ : 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 13 /* RegularExpressionLiteral */) { + else if (tokenKind === 13 /* SyntaxKind.RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } else if (ts.isTemplateLiteralKind(tokenKind)) { // TODO (drosen): we should *also* get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 11 /* JsxText */) { - return 23 /* jsxText */; + else if (tokenKind === 11 /* SyntaxKind.JsxText */) { + return 23 /* ClassificationType.jsxText */; } - else if (tokenKind === 79 /* Identifier */) { + else if (tokenKind === 79 /* SyntaxKind.Identifier */) { if (token) { switch (token.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: if (token.parent.name === token) { - return 11 /* className */; + return 11 /* ClassificationType.className */; } return; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: if (token.parent.name === token) { - return 15 /* typeParameterName */; + return 15 /* ClassificationType.typeParameterName */; } return; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: if (token.parent.name === token) { - return 13 /* interfaceName */; + return 13 /* ClassificationType.interfaceName */; } return; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (token.parent.name === token) { - return 12 /* enumName */; + return 12 /* ClassificationType.enumName */; } return; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (token.parent.name === token) { - return 14 /* moduleName */; + return 14 /* ClassificationType.moduleName */; } return; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (token.parent.name === token) { - return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; + return ts.isThisIdentifier(token) ? 3 /* ClassificationType.keyword */ : 17 /* ClassificationType.parameterName */; } return; } if (ts.isConstTypeReference(token.parent)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } function processElement(element) { @@ -132535,14 +133207,14 @@ var ts; function getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span) { return { spans: getSemanticTokens(program, sourceFile, span, cancellationToken), - endOfLineState: 0 /* None */ + endOfLineState: 0 /* EndOfLineState.None */ }; } v2020.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getSemanticTokens(program, sourceFile, span, cancellationToken) { var resultTokens = []; var collector = function (node, typeIdx, modifierSet) { - resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* typeOffset */) + modifierSet); + resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* TokenEncodingConsts.typeOffset */) + modifierSet); }; if (program && sourceFile) { collectTokens(program, sourceFile, span, collector, cancellationToken); @@ -132554,13 +133226,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -132576,7 +133248,7 @@ var ts; if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node) && !ts.isInfinityOrNaNString(node.escapedText)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } var typeIdx = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -132585,38 +133257,38 @@ var ts; if (node.parent) { var parentIsDeclaration = (ts.isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx); if (parentIsDeclaration && node.parent.name === node) { - modifierSet = 1 << 0 /* declaration */; + modifierSet = 1 << 0 /* TokenModifier.declaration */; } } // property declaration in constructor - if (typeIdx === 6 /* parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { - typeIdx = 9 /* property */; + if (typeIdx === 6 /* TokenType.parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { + typeIdx = 9 /* TokenType.property */; } typeIdx = reclassifyByType(typeChecker, node, typeIdx); var decl = symbol.valueDeclaration; if (decl) { var modifiers = ts.getCombinedModifierFlags(decl); var nodeFlags = ts.getCombinedNodeFlags(decl); - if (modifiers & 32 /* Static */) { - modifierSet |= 1 << 1 /* static */; + if (modifiers & 32 /* ModifierFlags.Static */) { + modifierSet |= 1 << 1 /* TokenModifier.static */; } - if (modifiers & 256 /* Async */) { - modifierSet |= 1 << 2 /* async */; + if (modifiers & 256 /* ModifierFlags.Async */) { + modifierSet |= 1 << 2 /* TokenModifier.async */; } - if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) { - if ((modifiers & 64 /* Readonly */) || (nodeFlags & 2 /* Const */) || (symbol.getFlags() & 8 /* EnumMember */)) { - modifierSet |= 1 << 3 /* readonly */; + if (typeIdx !== 0 /* TokenType.class */ && typeIdx !== 2 /* TokenType.interface */) { + if ((modifiers & 64 /* ModifierFlags.Readonly */) || (nodeFlags & 2 /* NodeFlags.Const */) || (symbol.getFlags() & 8 /* SymbolFlags.EnumMember */)) { + modifierSet |= 1 << 3 /* TokenModifier.readonly */; } } - if ((typeIdx === 7 /* variable */ || typeIdx === 10 /* function */) && isLocalDeclaration(decl, sourceFile)) { - modifierSet |= 1 << 5 /* local */; + if ((typeIdx === 7 /* TokenType.variable */ || typeIdx === 10 /* TokenType.function */) && isLocalDeclaration(decl, sourceFile)) { + modifierSet |= 1 << 5 /* TokenModifier.local */; } if (program.isSourceFileDefaultLibrary(decl.getSourceFile())) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } } else if (symbol.declarations && symbol.declarations.some(function (d) { return program.isSourceFileDefaultLibrary(d.getSourceFile()); })) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } collector(node, typeIdx, modifierSet); } @@ -132629,22 +133301,22 @@ var ts; } function classifySymbol(symbol, meaning) { var flags = symbol.getFlags(); - if (flags & 32 /* Class */) { - return 0 /* class */; + if (flags & 32 /* SymbolFlags.Class */) { + return 0 /* TokenType.class */; } - else if (flags & 384 /* Enum */) { - return 1 /* enum */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 1 /* TokenType.enum */; } - else if (flags & 524288 /* TypeAlias */) { - return 5 /* type */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 5 /* TokenType.type */; } - else if (flags & 64 /* Interface */) { - if (meaning & 2 /* Type */) { - return 2 /* interface */; + else if (flags & 64 /* SymbolFlags.Interface */) { + if (meaning & 2 /* SemanticMeaning.Type */) { + return 2 /* TokenType.interface */; } } - else if (flags & 262144 /* TypeParameter */) { - return 4 /* typeParameter */; + else if (flags & 262144 /* SymbolFlags.TypeParameter */) { + return 4 /* TokenType.typeParameter */; } var decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0]; if (decl && ts.isBindingElement(decl)) { @@ -132654,17 +133326,17 @@ var ts; } function reclassifyByType(typeChecker, node, typeIdx) { // type based classifications - if (typeIdx === 7 /* variable */ || typeIdx === 9 /* property */ || typeIdx === 6 /* parameter */) { + if (typeIdx === 7 /* TokenType.variable */ || typeIdx === 9 /* TokenType.property */ || typeIdx === 6 /* TokenType.parameter */) { var type_1 = typeChecker.getTypeAtLocation(node); if (type_1) { var test = function (condition) { return condition(type_1) || type_1.isUnion() && type_1.types.some(condition); }; - if (typeIdx !== 6 /* parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { - return 0 /* class */; + if (typeIdx !== 6 /* TokenType.parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { + return 0 /* TokenType.class */; } if (test(function (t) { return t.getCallSignatures().length > 0; }) && !test(function (t) { return t.getProperties().length > 0; }) || isExpressionInCallExpression(node)) { - return typeIdx === 9 /* property */ ? 11 /* member */ : 10 /* function */; + return typeIdx === 9 /* TokenType.property */ ? 11 /* TokenType.member */ : 10 /* TokenType.function */; } } } @@ -132706,25 +133378,25 @@ var ts; return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node); } var tokenFromDeclarationMapping = new ts.Map([ - [254 /* VariableDeclaration */, 7 /* variable */], - [164 /* Parameter */, 6 /* parameter */], - [167 /* PropertyDeclaration */, 9 /* property */], - [261 /* ModuleDeclaration */, 3 /* namespace */], - [260 /* EnumDeclaration */, 1 /* enum */], - [299 /* EnumMember */, 8 /* enumMember */], - [257 /* ClassDeclaration */, 0 /* class */], - [169 /* MethodDeclaration */, 11 /* member */], - [256 /* FunctionDeclaration */, 10 /* function */], - [213 /* FunctionExpression */, 10 /* function */], - [168 /* MethodSignature */, 11 /* member */], - [172 /* GetAccessor */, 9 /* property */], - [173 /* SetAccessor */, 9 /* property */], - [166 /* PropertySignature */, 9 /* property */], - [258 /* InterfaceDeclaration */, 2 /* interface */], - [259 /* TypeAliasDeclaration */, 5 /* type */], - [163 /* TypeParameter */, 4 /* typeParameter */], - [296 /* PropertyAssignment */, 9 /* property */], - [297 /* ShorthandPropertyAssignment */, 9 /* property */] + [254 /* SyntaxKind.VariableDeclaration */, 7 /* TokenType.variable */], + [164 /* SyntaxKind.Parameter */, 6 /* TokenType.parameter */], + [167 /* SyntaxKind.PropertyDeclaration */, 9 /* TokenType.property */], + [261 /* SyntaxKind.ModuleDeclaration */, 3 /* TokenType.namespace */], + [260 /* SyntaxKind.EnumDeclaration */, 1 /* TokenType.enum */], + [299 /* SyntaxKind.EnumMember */, 8 /* TokenType.enumMember */], + [257 /* SyntaxKind.ClassDeclaration */, 0 /* TokenType.class */], + [169 /* SyntaxKind.MethodDeclaration */, 11 /* TokenType.member */], + [256 /* SyntaxKind.FunctionDeclaration */, 10 /* TokenType.function */], + [213 /* SyntaxKind.FunctionExpression */, 10 /* TokenType.function */], + [168 /* SyntaxKind.MethodSignature */, 11 /* TokenType.member */], + [172 /* SyntaxKind.GetAccessor */, 9 /* TokenType.property */], + [173 /* SyntaxKind.SetAccessor */, 9 /* TokenType.property */], + [166 /* SyntaxKind.PropertySignature */, 9 /* TokenType.property */], + [258 /* SyntaxKind.InterfaceDeclaration */, 2 /* TokenType.interface */], + [259 /* SyntaxKind.TypeAliasDeclaration */, 5 /* TokenType.type */], + [163 /* SyntaxKind.TypeParameter */, 4 /* TokenType.typeParameter */], + [296 /* SyntaxKind.PropertyAssignment */, 9 /* TokenType.property */], + [297 /* SyntaxKind.ShorthandPropertyAssignment */, 9 /* TokenType.property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -132736,6 +133408,26 @@ var ts; (function (Completions) { var StringCompletions; (function (StringCompletions) { + var _a; + var kindPrecedence = (_a = {}, + _a["directory" /* ScriptElementKind.directory */] = 0, + _a["script" /* ScriptElementKind.scriptElement */] = 1, + _a["external module name" /* ScriptElementKind.externalModuleName */] = 2, + _a); + function createNameAndKindSet() { + var map = new ts.Map(); + function add(value) { + var existing = map.get(value.name); + if (!existing || kindPrecedence[existing.kind] < kindPrecedence[value.kind]) { + map.set(value.name, value); + } + } + return { + add: add, + has: map.has.bind(map), + values: map.values.bind(map), + }; + } function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) { if (ts.isInReferenceComment(sourceFile, position)) { var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host); @@ -132755,19 +133447,19 @@ var ts; } var optionalReplacementSpan = ts.createTextSpanFromStringLiteralLikeContent(contextToken); switch (completion.kind) { - case 0 /* Paths */: + case 0 /* StringLiteralCompletionKind.Paths */: return convertPathCompletions(completion.paths); - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var entries = ts.createSortedArray(); - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options, + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ScriptTarget.ESNext */, log, 4 /* CompletionKind.String */, preferences, options, /*formatContext*/ undefined); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } - case 2 /* Types */: { + case 2 /* StringLiteralCompletionKind.Types */: { var entries = completion.types.map(function (type) { return ({ name: type.value, - kindModifiers: "" /* none */, - kind: "string" /* string */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "string" /* ScriptElementKind.string */, sortText: Completions.SortText.LocationPriority, replacementSpan: ts.getReplacementSpanForContextToken(contextToken) }); }); @@ -132786,16 +133478,16 @@ var ts; StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { switch (completion.kind) { - case 0 /* Paths */: { + case 0 /* StringLiteralCompletionKind.Paths */: { var match = ts.find(completion.paths, function (p) { return p.name === name; }); return match && Completions.createCompletionDetails(name, kindModifiersFromExtension(match.extension), match.kind, [ts.textPart(name)]); } - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var match = ts.find(completion.symbols, function (s) { return s.name === name; }); return match && Completions.createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; + case 2 /* StringLiteralCompletionKind.Types */: + return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, "type" /* ScriptElementKind.typeElement */, [ts.textPart(name)]) : undefined; default: return ts.Debug.assertNever(completion); } @@ -132811,20 +133503,20 @@ var ts; } function kindModifiersFromExtension(extension) { switch (extension) { - case ".d.ts" /* Dts */: return ".d.ts" /* dtsModifier */; - case ".js" /* Js */: return ".js" /* jsModifier */; - case ".json" /* Json */: return ".json" /* jsonModifier */; - case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; - case ".ts" /* Ts */: return ".ts" /* tsModifier */; - case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; - case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */; - case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */; - case ".mts" /* Mts */: return ".mts" /* mtsModifier */; - case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */; - case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */; - case ".cts" /* Cts */: return ".cts" /* ctsModifier */; - case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); - case undefined: return "" /* none */; + case ".d.ts" /* Extension.Dts */: return ".d.ts" /* ScriptElementKindModifier.dtsModifier */; + case ".js" /* Extension.Js */: return ".js" /* ScriptElementKindModifier.jsModifier */; + case ".json" /* Extension.Json */: return ".json" /* ScriptElementKindModifier.jsonModifier */; + case ".jsx" /* Extension.Jsx */: return ".jsx" /* ScriptElementKindModifier.jsxModifier */; + case ".ts" /* Extension.Ts */: return ".ts" /* ScriptElementKindModifier.tsModifier */; + case ".tsx" /* Extension.Tsx */: return ".tsx" /* ScriptElementKindModifier.tsxModifier */; + case ".d.mts" /* Extension.Dmts */: return ".d.mts" /* ScriptElementKindModifier.dmtsModifier */; + case ".mjs" /* Extension.Mjs */: return ".mjs" /* ScriptElementKindModifier.mjsModifier */; + case ".mts" /* Extension.Mts */: return ".mts" /* ScriptElementKindModifier.mtsModifier */; + case ".d.cts" /* Extension.Dcts */: return ".d.cts" /* ScriptElementKindModifier.dctsModifier */; + case ".cjs" /* Extension.Cjs */: return ".cjs" /* ScriptElementKindModifier.cjsModifier */; + case ".cts" /* Extension.Cts */: return ".cts" /* ScriptElementKindModifier.ctsModifier */; + case ".tsbuildinfo" /* Extension.TsBuildInfo */: return ts.Debug.fail("Extension ".concat(".tsbuildinfo" /* Extension.TsBuildInfo */, " is unsupported.")); + case undefined: return "" /* ScriptElementKindModifier.none */; default: return ts.Debug.assertNever(extension); } @@ -132838,44 +133530,44 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 196 /* LiteralType */: { - var grandParent = walkUpParentheses(parent.parent); - switch (grandParent.kind) { - case 178 /* TypeReference */: { - var typeReference_1 = grandParent; - var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); + case 196 /* SyntaxKind.LiteralType */: { + var grandParent_1 = walkUpParentheses(parent.parent); + switch (grandParent_1.kind) { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: { + var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === grandParent_1; }); if (typeArgument) { - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; } return undefined; } - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; // bar: string; // } // let x: Foo["/*completion position*/"] - var _a = grandParent, indexType = _a.indexType, objectType = _a.objectType; + var _a = grandParent_1, indexType = _a.indexType, objectType = _a.objectType; if (!ts.rangeContainsPosition(indexType, position)) { return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 200 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; - case 187 /* UnionType */: { - if (!ts.isTypeReferenceNode(grandParent.parent)) { + case 200 /* SyntaxKind.ImportType */: + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 187 /* SyntaxKind.UnionType */: { + if (!ts.isTypeReferenceNode(grandParent_1.parent)) { return undefined; } - var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent); - var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent_1, parent); + var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent_1)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: false }; } default: return undefined; } } - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -132892,7 +133584,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 207 /* ElementAccessExpression */: { + case 207 /* SyntaxKind.ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -132905,41 +133597,41 @@ var ts; } return undefined; } - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 285 /* JsxAttribute */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 285 /* SyntaxKind.JsxAttribute */: if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? parent.parent : node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `require(""` or `import("")`) - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 277 /* ExternalModuleReference */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 277 /* SyntaxKind.ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } function fromContextualType() { // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" - return { kind: 2 /* Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; } } function walkUpParentheses(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -132966,14 +133658,14 @@ var ts; type = propType; } } - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* TypeFlags.String */); return getStringLiteralTypes(type, uniques); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: isNewIdentifier }; } function stringLiteralCompletionsFromProperties(type) { return type && { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; @@ -132982,10 +133674,10 @@ var ts; var contextualType = checker.getContextualType(objectLiteralExpression); if (!contextualType) return undefined; - var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* Completions */); + var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* ContextFlags.Completions */); var symbols = Completions.getPropertiesForObjectExpression(contextualType, completionsType, objectLiteralExpression, checker); return { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: symbols, hasIndexSignature: ts.hasIndexSignature(contextualType) }; @@ -132996,13 +133688,13 @@ var ts; return ts.emptyArray; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : - type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; + type.isStringLiteral() && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; } function directoryResult(name) { - return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); + return nameAndKind(name, "directory" /* ScriptElementKind.directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); @@ -133017,18 +133709,19 @@ var ts; } function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) { var literalValue = ts.normalizeSlashes(node.text); + var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption()) - : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker); function getIncludeExtensionOption() { var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; - return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */; + return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */ : 0 /* IncludeExtensionsOption.Exclude */; } } function getExtensionOptions(compilerOptions, includeExtensionsOption) { - if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; } + if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* IncludeExtensionsOption.Exclude */; } return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption }; } function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, includeExtensions) { @@ -133037,7 +133730,7 @@ var ts; return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } else { - return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath); + return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values()); } } function isEmitResolutionKindUsingNodeModules(compilerOptions) { @@ -133073,7 +133766,7 @@ var ts; var basePath = compilerOptions.project || host.getCurrentDirectory(); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase); - return ts.flatMap(baseDirectories, function (baseDirectory) { return getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude); }); + return ts.flatMap(baseDirectories, function (baseDirectory) { return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values()); }); } var IncludeExtensionsOption; (function (IncludeExtensionsOption) { @@ -133084,10 +133777,9 @@ var ts; /** * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) { - var _b; - var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption; - if (result === void 0) { result = []; } + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensionOptions, host, exclude, result) { + var _a; + if (result === void 0) { result = createNameAndKindSet(); } if (fragment === undefined) { fragment = ""; } @@ -133111,11 +133803,11 @@ var ts; var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; if (typeof typesVersions === "object") { - var versionPaths = (_b = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _b === void 0 ? void 0 : _b.paths; + var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths; if (versionPaths) { var packageDirectory = ts.getDirectoryPath(packageJsonPath); var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length); - if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) { + if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) { // A true result means one of the `versionPaths` was matched, which will block relative resolution // to files and folders from here. All reachable paths given the pattern match are already added. return result; @@ -133127,39 +133819,17 @@ var ts; if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = new ts.Map(); // maps file to its extension for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var filePath = files_1[_i]; filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* Comparison.EqualTo */) { continue; } - var foundFileName = void 0; - var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings()); - if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) { - foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath)); - foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); - } - else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) { - foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension); - foundFiles.set(foundFileName, outputExtension); - } - else { - foundFileName = ts.getBaseFileName(filePath); - foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); - } + var _b = getFilenameWithExtensionOption(ts.getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _b.name, extension = _b.extension; + result.add(nameAndKind(name, "script" /* ScriptElementKind.scriptElement */, extension)); } - foundFiles.forEach(function (ext, foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); - }); } // If possible, get folder completion as well var directories = ts.tryGetDirectories(host, baseDirectory); @@ -133168,27 +133838,52 @@ var ts; var directory = directories_1[_c]; var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); if (directoryName !== "@types") { - result.push(directoryResult(directoryName)); + result.add(directoryResult(directoryName)); } } } return result; } + function getFilenameWithExtensionOption(name, compilerOptions, includeExtensionsOption) { + var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions); + if (includeExtensionsOption === 0 /* IncludeExtensionsOption.Exclude */ && !ts.fileExtensionIsOneOf(name, [".json" /* Extension.Json */, ".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) { + return { name: ts.removeFileExtension(name), extension: ts.tryGetExtensionFromPath(name) }; + } + else if ((ts.fileExtensionIsOneOf(name, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */]) || includeExtensionsOption === 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */) && outputExtension) { + return { name: ts.changeExtension(name, outputExtension), extension: outputExtension }; + } + else { + return { name: name, extension: ts.tryGetExtensionFromPath(name) }; + } + } /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */ - function addCompletionEntriesFromPaths(result, fragment, baseDirectory, fileExtensions, paths, host) { - var _a; + function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) { + var getPatternsForKey = function (key) { return paths[key]; }; + var comparePaths = function (a, b) { + var patternA = ts.tryParsePattern(a); + var patternB = ts.tryParsePattern(b); + var lengthA = typeof patternA === "object" ? patternA.prefix.length : a.length; + var lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length; + return ts.compareValues(lengthB, lengthA); + }; + return addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, ts.getOwnKeys(paths), getPatternsForKey, comparePaths); + } + /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */ + function addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths) { var pathResults = []; - var matchedPathPrefixLength = -1; - for (var path in paths) { - if (!ts.hasProperty(paths, path)) + var matchedPath; + for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { + var key = keys_1[_i]; + if (key === ".") continue; - var patterns = paths[path]; + var keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./" + var patterns = getPatternsForKey(key); if (patterns) { - var pathPattern = ts.tryParsePattern(path); + var pathPattern = ts.tryParsePattern(keyWithoutLeadingDotSlash); if (!pathPattern) continue; var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment); - var isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength); + var isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === -1 /* Comparison.LessThan */); if (isLongestMatch) { // If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g. // for `import {} from "some-package/|"` with a typesVersions: @@ -133201,13 +133896,13 @@ var ts; // added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both // ./dist/foo and ./foo, when only the latter will actually be resolvable. // See pathCompletionsTypesVersionsWildcard6.ts. - matchedPathPrefixLength = pathPattern.prefix.length; + matchedPath = key; pathResults = pathResults.filter(function (r) { return !r.matchedPattern; }); } - if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) { + if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== 1 /* Comparison.GreaterThan */) { pathResults.push({ matchedPattern: isMatch, - results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host) + results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host) .map(function (_a) { var name = _a.name, kind = _a.kind, extension = _a.extension; return nameAndKind(name, kind, extension); @@ -133216,10 +133911,8 @@ var ts; } } } - var equatePaths = ((_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host)) ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive; - var equateResults = function (a, b) { return equatePaths(a.name, b.name); }; - pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); }); - return matchedPathPrefixLength > -1; + pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (r) { return result.add(r); }); }); + return matchedPath !== undefined; } /** * Check all of the declared modules and those in node modules. Possible sources of modules: @@ -133228,22 +133921,22 @@ var ts; * Modules from node_modules (i.e. those listed in package.json) * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions */ - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) { + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, includeExtensionsOption, typeChecker) { var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result = []; - var extensionOptions = getExtensionOptions(compilerOptions); + var result = createNameAndKindSet(); + var extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption); if (baseUrl) { var projectDir = compilerOptions.project || host.getCurrentDirectory(); var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl)); getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result); if (paths) { - addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host); + addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths); } } var fragmentDirectory = getFragmentDirectory(fragment); for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) { var ambientName = _a[_i]; - result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.add(nameAndKind(ambientName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (isEmitResolutionKindUsingNodeModules(compilerOptions)) { @@ -133251,15 +133944,13 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_3 = function (moduleName) { - if (!result.some(function (entry) { return entry.name === moduleName; })) { - foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); - } - }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { var moduleName = _c[_b]; - _loop_3(moduleName); + var moduleResult = nameAndKind(moduleName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined); + if (!result.has(moduleResult.name)) { + foundGlobal = true; + result.add(moduleResult); + } } } if (!foundGlobal) { @@ -133285,39 +133976,19 @@ var ts; } packagePath = ts.combinePaths(packagePath, subName); } - var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json"); + var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath); + var packageFile = ts.combinePaths(packageDirectory, "package.json"); if (ts.tryFileExists(host, packageFile)) { var packageJson = ts.readJson(packageFile, host); - var exports = packageJson.exports; - if (exports) { - if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null + var exports_1 = packageJson.exports; + if (exports_1) { + if (typeof exports_1 !== "object" || exports_1 === null) { // eslint-disable-line no-null/no-null return; // null exports or entrypoint only, no sub-modules available } - var keys = ts.getOwnKeys(exports); - var fragmentSubpath_1 = components.join("/"); - var processedKeys = ts.mapDefined(keys, function (k) { - if (k === ".") - return undefined; - if (!ts.startsWith(k, "./")) - return undefined; - var subpath = k.substring(2); - if (!ts.startsWith(subpath, fragmentSubpath_1)) - return undefined; - // subpath is a valid export (barring conditions, which we don't currently check here) - if (!ts.stringContains(subpath, "*")) { - return subpath; - } - // pattern export - only return everything up to the `*`, so the user can autocomplete, then - // keep filling in the pattern (we could speculatively return a list of options by hitting disk, - // but conditions will make that somewhat awkward, as each condition may have a different set of possible - // options for the `*`. - return subpath.slice(0, subpath.indexOf("*")); - }); - ts.forEach(processedKeys, function (k) { - if (k) { - result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined)); - } - }); + var keys = ts.getOwnKeys(exports_1); + var fragmentSubpath = components.join("/") + (components.length && ts.hasTrailingDirectorySeparator(fragment) ? "/" : ""); + var conditions_1 = mode === ts.ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"]; + addCompletionEntriesFromPathsOrExports(result, fragmentSubpath, packageDirectory, extensionOptions, host, keys, function (key) { return ts.singleElementArray(getPatternFromFirstMatchingCondition(exports_1[key], conditions_1)); }, ts.comparePatternKeys); return; } } @@ -133327,31 +133998,44 @@ var ts; ts.forEachAncestorDirectory(scriptPath, ancestorLookup); } } - return result; + return ts.arrayFrom(result.values()); + } + function getPatternFromFirstMatchingCondition(target, conditions) { + if (typeof target === "string") { + return target; + } + if (target && typeof target === "object" && !ts.isArray(target)) { + for (var condition in target) { + if (condition === "default" || conditions.indexOf(condition) > -1 || ts.isApplicableVersionedTypesKey(conditions, condition)) { + var pattern = target[condition]; + return getPatternFromFirstMatchingCondition(pattern, conditions); + } + } + } } function getFragmentDirectory(fragment) { return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; } - function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { + function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. - return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray; + return !ts.stringContains(path, "*") ? justPathMappingName(path, "script" /* ScriptElementKind.scriptElement */) : ts.emptyArray; } var pathPrefix = path.slice(0, path.length - 1); var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix); if (remainingFragment === undefined) { var starIsFullPathComponent = path[path.length - 2] === "/"; - return starIsFullPathComponent ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", baseUrl, pattern, fileExtensions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) { + return starIsFullPathComponent ? justPathMappingName(pathPrefix, "directory" /* ScriptElementKind.directory */) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) { var name = _a.name, rest = __rest(_a, ["name"]); return (__assign({ name: pathPrefix + name }, rest)); }); }); } - return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); - function justPathMappingName(name) { - return ts.startsWith(name, fragment) ? [directoryResult(ts.removeTrailingDirectorySeparator(name))] : ts.emptyArray; + return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, host); }); + function justPathMappingName(name, kind) { + return ts.startsWith(name, fragment) ? [{ name: ts.removeTrailingDirectorySeparator(name), kind: kind, extension: undefined }] : ts.emptyArray; } } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, host) { if (!host.readDirectory) { return undefined; } @@ -133370,21 +134054,33 @@ var ts; var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory; var normalizedSuffix = ts.normalizePath(parsed.suffix); // Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b". - var baseDirectory = ts.normalizePath(ts.combinePaths(baseUrl, expandedPrefixDirectory)); + var baseDirectory = ts.normalizePath(ts.combinePaths(packageDirectory, expandedPrefixDirectory)); var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { - var extension = ts.tryGetExtensionFromPath(match); - var name = trimPrefixAndSuffix(match); - return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); - }); - var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { - var name = trimPrefixAndSuffix(dir); - return name === undefined ? undefined : directoryResult(name); + // If we have a suffix, then we read the directory all the way down to avoid returning completions for + // directories that don't contain files that would match the suffix. A previous comment here was concerned + // about the case where `normalizedSuffix` includes a `?` character, which should be interpreted literally, + // but will match any single character as part of the `include` pattern in `tryReadDirectory`. This is not + // a problem, because (in the extremely unusual circumstance where the suffix has a `?` in it) a `?` + // interpreted as "any character" can only return *too many* results as compared to the literal + // interpretation, so we can filter those superfluous results out via `trimPrefixAndSuffix` as we've always + // done. + var includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*"; + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var trimmedWithPattern = trimPrefixAndSuffix(match); + if (trimmedWithPattern) { + if (containsSlash(trimmedWithPattern)) { + return directoryResult(ts.getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]); + } + var _a = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _a.name, extension = _a.extension; + return nameAndKind(name, "script" /* ScriptElementKind.scriptElement */, extension); + } }); + // If we had a suffix, we already recursively searched for all possible files that could match + // it and returned the directories leading to those files. Otherwise, assume any directory could + // have something valid to import. + var directories = normalizedSuffix + ? ts.emptyArray + : ts.mapDefined(ts.tryGetDirectories(host, baseDirectory), function (dir) { return dir === "node_modules" ? undefined : directoryResult(dir); }); return __spreadArray(__spreadArray([], matches, true), directories, true); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); @@ -133424,13 +134120,13 @@ var ts; } var prefix = match[1], kind = match[2], toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path) + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* IncludeExtensionsOption.Include */), host, sourceFile.path) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) : ts.Debug.fail(); - return addReplacementSpans(toComplete, range.pos + prefix.length, names); + return addReplacementSpans(toComplete, range.pos + prefix.length, ts.arrayFrom(names.values())); } function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) { - if (result === void 0) { result = []; } + if (result === void 0) { result = createNameAndKindSet(); } // Check for typings specified in compiler options var seen = new ts.Map(); var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; @@ -133455,7 +134151,7 @@ var ts; continue; if (fragmentDirectory === undefined) { if (!seen.has(packageName)) { - result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.add(nameAndKind(packageName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); seen.set(packageName, true); } } @@ -133497,14 +134193,14 @@ var ts; var offset = index !== -1 ? index + 1 : 0; // If the range is an identifier, span is unnecessary. var length = text.length - offset; - return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); + return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ScriptTarget.ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); } // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* CharacterCodes.dot */ ? 2 : 1; var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + return slashCharCode === 47 /* CharacterCodes.slash */ || slashCharCode === 92 /* CharacterCodes.backslash */; } return false; } @@ -133561,7 +134257,7 @@ var ts; return "z" + sortText; }, ObjectLiteralProperty: function (presetSortText, symbolDisplayName) { - return presetSortText + "\0" + symbolDisplayName + "\0"; + return "".concat(presetSortText, "\0").concat(symbolDisplayName, "\0"); }, SortBelow: function (sortText) { return sortText + "1"; @@ -133603,16 +134299,16 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsThisType(origin) { - return !!(origin.kind & 1 /* ThisType */); + return !!(origin.kind & 1 /* SymbolOriginInfoKind.ThisType */); } function originIsSymbolMember(origin) { - return !!(origin.kind & 2 /* SymbolMember */); + return !!(origin.kind & 2 /* SymbolOriginInfoKind.SymbolMember */); } function originIsExport(origin) { - return !!(origin && origin.kind & 4 /* Export */); + return !!(origin && origin.kind & 4 /* SymbolOriginInfoKind.Export */); } function originIsResolvedExport(origin) { - return !!(origin && origin.kind === 32 /* ResolvedExport */); + return !!(origin && origin.kind === 32 /* SymbolOriginInfoKind.ResolvedExport */); } function originIncludesSymbolName(origin) { return originIsExport(origin) || originIsResolvedExport(origin); @@ -133621,16 +134317,16 @@ var ts; return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { - return !!(origin.kind & 8 /* Promise */); + return !!(origin.kind & 8 /* SymbolOriginInfoKind.Promise */); } function originIsNullableMember(origin) { - return !!(origin.kind & 16 /* Nullable */); + return !!(origin.kind & 16 /* SymbolOriginInfoKind.Nullable */); } function originIsTypeOnlyAlias(origin) { - return !!(origin && origin.kind & 64 /* TypeOnlyAlias */); + return !!(origin && origin.kind & 64 /* SymbolOriginInfoKind.TypeOnlyAlias */); } function originIsObjectLiteralMethod(origin) { - return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */); + return !!(origin && origin.kind & 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */); } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { @@ -133671,10 +134367,10 @@ var ts; resolvedAny: function () { return resolvedCount > 0; }, resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; }, }); - var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : ""; - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, logPrefix + ": resolved " + resolvedCount + " module specifiers, plus " + ambientCount + " ambient and " + resolvedFromCacheCount + " from cache" + hitRateMessage); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (skippedAny ? "incomplete" : "complete")); - (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start)); + var hitRateMessage = cacheAttemptCount ? " (".concat((resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1), "% hit rate)") : ""; + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "".concat(logPrefix, ": resolved ").concat(resolvedCount, " module specifiers, plus ").concat(ambientCount, " ambient and ").concat(resolvedFromCacheCount, " from cache").concat(hitRateMessage)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "".concat(logPrefix, ": response is ").concat(skippedAny ? "incomplete" : "complete")); + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "".concat(logPrefix, ": ").concat(ts.timestamp() - start)); return result; function tryResolve(exportInfo, symbolName, isFromAmbientModule) { if (isFromAmbientModule) { @@ -133717,7 +134413,7 @@ var ts; // we can continue it from the cached previous response. var compilerOptions = program.getCompilerOptions(); var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined; - if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { + if (incompleteCompletionsCache && completionKind === 3 /* CompletionTriggerKind.TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { var incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken); if (incompleteContinuation) { return incompleteContinuation; @@ -133731,7 +134427,7 @@ var ts; return stringCompletions; } if (previousToken && ts.isBreakOrContinueStatement(previousToken.parent) - && (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) { + && (previousToken.kind === 81 /* SyntaxKind.BreakKeyword */ || previousToken.kind === 86 /* SyntaxKind.ContinueKeyword */ || previousToken.kind === 79 /* SyntaxKind.Identifier */)) { return getLabelCompletionAtPosition(previousToken.parent); } var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken); @@ -133739,21 +134435,21 @@ var ts; return undefined; } switch (completionData.kind) { - case 0 /* Data */: + case 0 /* CompletionDataKind.Data */: var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position); if (response === null || response === void 0 ? void 0 : response.isIncomplete) { incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response); } return response; - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: // If the current position is a jsDoc tag name, only tag names should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagNameCompletions()); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: // If the current position is a jsDoc tag, only tags should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); - case 4 /* Keywords */: + case 4 /* CompletionDataKind.Keywords */: return specificKeywordCompletionInfo(completionData.keywordCompletions, completionData.isNewIdentifierLocation); default: return ts.Debug.assertNever(completionData); @@ -133770,16 +134466,16 @@ var ts; function compareCompletionEntries(entryInArray, entryToInsert) { var _a, _b; var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText); - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name); } - if (result === 0 /* EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { + if (result === 0 /* Comparison.EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { // Sort same-named auto-imports by module specifier result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier); } - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { // Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first. - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } return result; } @@ -133810,10 +134506,10 @@ var ts; if (result === "skipped") return entry; if (!result || result === "failed") { - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '" + entry.name + "' from '" + entry.source + "'"); + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '".concat(entry.name, "' from '").concat(entry.source, "'")); return undefined; } - var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); + var newOrigin = __assign(__assign({}, origin), { kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); // Mutating for performance... feels sketchy but nobody else uses the cache, // so why bother allocating a bunch of new objects? entry.data = originToCompletionEntryData(newOrigin); @@ -133827,7 +134523,7 @@ var ts; return entries; }); previousResponse.entries = newEntries; - previousResponse.flags = (previousResponse.flags || 0) | 4 /* IsContinuation */; + previousResponse.flags = (previousResponse.flags || 0) | 4 /* CompletionInfoFlags.IsContinuation */; return previousResponse; } function jsdocCompletionInfo(entries) { @@ -133836,8 +134532,8 @@ var ts; function keywordToCompletionEntry(keyword) { return { name: ts.tokenToString(keyword), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }; } @@ -133851,62 +134547,61 @@ var ts; } function keywordCompletionData(keywordFilters, filterOutTsOnlyKeywords, isNewIdentifierLocation) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: getKeywordCompletions(keywordFilters, filterOutTsOnlyKeywords), isNewIdentifierLocation: isNewIdentifierLocation, }; } function keywordFiltersFromSyntaxKind(keywordCompletion) { switch (keywordCompletion) { - case 152 /* TypeKeyword */: return 8 /* TypeKeyword */; + case 152 /* SyntaxKind.TypeKeyword */: return 8 /* KeywordCompletionFilters.TypeKeyword */; default: ts.Debug.fail("Unknown mapping from SyntaxKind to KeywordCompletionFilters"); } } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) { var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant - if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); if (completionInfo) { return completionInfo; } } var entries = ts.createSortedArray(); - if (isUncheckedFile(sourceFile, compilerOptions)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); - getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); - } - else { - if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { - return undefined; - } - getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); + var isChecked = isCheckedFile(sourceFile, compilerOptions); + if (isChecked && !isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* KeywordCompletionFilters.None */) { + return undefined; } - if (keywordFilters !== 0 /* None */) { - var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; })); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); + if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) { for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) { var keywordEntry = _a[_i]; - if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) { + if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) { + uniqueNames.add(keywordEntry.name); ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } } - var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) { var keywordEntry = _c[_b]; - if (!entryNames.has(keywordEntry.name)) { + if (!uniqueNames.has(keywordEntry.name)) { + uniqueNames.add(keywordEntry.name); ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) { var literal = literals_1[_d]; - ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true); + var literalEntry = createCompletionEntryForLiteral(sourceFile, preferences, literal); + uniqueNames.add(literalEntry.name); + ts.insertSorted(entries, literalEntry, compareCompletionEntries, /*allowDuplicates*/ true); + } + if (!isChecked) { + getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); } return { flags: completionData.flags, @@ -133918,14 +134613,14 @@ var ts; entries: entries, }; } - function isUncheckedFile(sourceFile, compilerOptions) { - return ts.isSourceFileJS(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); + function isCheckedFile(sourceFile, compilerOptions) { + return !ts.isSourceFileJS(sourceFile) || !!ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); } function isMemberCompletionKind(kind) { switch (kind) { - case 0 /* ObjectPropertyDeclaration */: - case 3 /* MemberLike */: - case 2 /* PropertyAccess */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: + case 3 /* CompletionKind.MemberLike */: + case 2 /* CompletionKind.PropertyAccess */: return true; default: return false; @@ -133935,12 +134630,12 @@ var ts; // We wanna walk up the tree till we find a JSX closing element var jsxClosingElement = ts.findAncestor(location, function (node) { switch (node.kind) { - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return true; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return false; default: return "quit"; @@ -133959,14 +134654,14 @@ var ts; // var x = // var y = // the completion list at "1" and "2" will contain "MainComponent.Child" with a replacement span of closing tag name - var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* SyntaxKind.GreaterThanToken */, sourceFile); var tagName = jsxClosingElement.parent.openingElement.tagName; var closingTag = tagName.getText(sourceFile); var fullClosingTag = closingTag + (hasClosingAngleBracket ? "" : ">"); var replacementSpan = ts.createTextSpanFromNode(jsxClosingElement.tagName); var entry = { name: fullClosingTag, - kind: "class" /* classElement */, + kind: "class" /* ScriptElementKind.classElement */, kindModifiers: undefined, sortText: Completions.SortText.LocationPriority, }; @@ -133985,7 +134680,7 @@ var ts; uniqueNames.add(realName); ts.insertSorted(entries, { name: realName, - kind: "warning" /* warning */, + kind: "warning" /* ScriptElementKind.warning */, kindModifiers: "", sortText: Completions.SortText.JavascriptIdentifiers, isFromUncheckedFile: true @@ -133998,7 +134693,7 @@ var ts; ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal); } function createCompletionEntryForLiteral(sourceFile, preferences, literal) { - return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority }; + return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority }; } function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; @@ -134015,18 +134710,18 @@ var ts; var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { insertText = needsConvertPropertyAccess - ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(sourceFile, preferences, name) + "]" - : "this" + (insertQuestionDot ? "?." : ".") + name; + ? "this".concat(insertQuestionDot ? "?." : "", "[").concat(quotePropertyName(sourceFile, preferences, name), "]") + : "this".concat(insertQuestionDot ? "?." : ".").concat(name); } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { - insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(sourceFile, preferences, name) + "]" : "[" + name + "]" : name; + insertText = useBraces ? needsConvertPropertyAccess ? "[".concat(quotePropertyName(sourceFile, preferences, name), "]") : "[".concat(name, "]") : name; if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { - insertText = "?." + insertText; + insertText = "?.".concat(insertText); } - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || - ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* SyntaxKind.DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* SyntaxKind.QuestionDotToken */, sourceFile); if (!dot) { return undefined; } @@ -134037,7 +134732,7 @@ var ts; if (isJsxInitializer) { if (insertText === undefined) insertText = name; - insertText = "{" + insertText + "}"; + insertText = "{".concat(insertText, "}"); if (typeof isJsxInitializer !== "boolean") { replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } @@ -134050,8 +134745,8 @@ var ts; if (precedingToken && ts.positionIsASICandidate(precedingToken.end, precedingToken.parent, sourceFile)) { awaitText = ";"; } - awaitText += "(await " + propertyAccessToConvert.expression.getText() + ")"; - insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + awaitText += "(await ".concat(propertyAccessToConvert.expression.getText(), ")"); + insertText = needsConvertPropertyAccess ? "".concat(awaitText).concat(insertText) : "".concat(awaitText).concat(insertQuestionDot ? "?." : ".").concat(insertText); replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } if (originIsResolvedExport(origin)) { @@ -134061,12 +134756,12 @@ var ts; isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; } } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { hasAction = true; } if (preferences.includeCompletionsWithClassMemberSnippets && preferences.includeCompletionsWithInsertText && - completionKind === 3 /* MemberLike */ && + completionKind === 3 /* CompletionKind.MemberLike */ && isClassLikeMemberCompletion(symbol, location)) { var importAdder = void 0; (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan); @@ -134090,11 +134785,11 @@ var ts; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. if (preferences.jsxAttributeCompletionStyle === "auto" - && !(type.flags & 528 /* BooleanLike */) - && !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) { - if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) { + && !(type.flags & 528 /* TypeFlags.BooleanLike */) + && !(type.flags & 1048576 /* TypeFlags.Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* TypeFlags.BooleanLike */); }))) { + if (type.flags & 402653316 /* TypeFlags.StringLike */ || (type.flags & 1048576 /* TypeFlags.Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* TypeFlags.StringLike */ | 32768 /* TypeFlags.Undefined */)); }))) { // If is string like or undefined use quotes - insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1"); + insertText = "".concat(ts.escapeSnippetText(name), "=").concat(ts.quote(sourceFile, preferences, "$1")); isSnippet = true; } else { @@ -134103,7 +134798,7 @@ var ts; } } if (useBraces_1) { - insertText = ts.escapeSnippetText(name) + "={$1}"; + insertText = "".concat(ts.escapeSnippetText(name), "={$1}"); isSnippet = true; } } @@ -134145,8 +134840,8 @@ var ts; return false; } // Completion symbol must be for a class member. - var memberFlags = 106500 /* ClassMember */ - & 900095 /* EnumMemberExcludes */; + var memberFlags = 106500 /* SymbolFlags.ClassMember */ + & 900095 /* SymbolFlags.EnumMemberExcludes */; /* In `class C { | @@ -134205,16 +134900,16 @@ var ts; // Note: this assumes we won't have more than one body in the completion nodes, which should be the case. var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; // Whether the suggested member should be abstract. // e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`. var _a = getPresentModifiers(contextToken), presentModifiers = _a.modifiers, modifiersSpan = _a.span; - var isAbstract = !!(presentModifiers & 128 /* Abstract */); + var isAbstract = !!(presentModifiers & 128 /* ModifierFlags.Abstract */); var completionNodes = []; ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder, // `addNewNodeForMemberSymbol` calls this callback function for each new member node @@ -134225,13 +134920,13 @@ var ts; // - One node; // - More than one node if the member is overloaded (e.g. a method with overload signatures). function (node) { - var requiredModifiers = 0 /* None */; + var requiredModifiers = 0 /* ModifierFlags.None */; if (isAbstract) { - requiredModifiers |= 128 /* Abstract */; + requiredModifiers |= 128 /* ModifierFlags.Abstract */; } if (ts.isClassElement(node) - && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) { - requiredModifiers |= 16384 /* Override */; + && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* MemberOverrideStatus.NeedsOverride */) { + requiredModifiers |= 16384 /* ModifierFlags.Override */; } if (!completionNodes.length) { // Keep track of added missing required modifiers and modifiers already present. @@ -134242,9 +134937,9 @@ var ts; } node = ts.factory.updateModifiers(node, modifiers); completionNodes.push(node); - }, body, 2 /* Property */, isAbstract); + }, body, 2 /* codefix.PreserveOptionalFlags.Property */, isAbstract); if (completionNodes.length) { - var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */; + var format = 1 /* ListFormat.MultiLine */ | 131072 /* ListFormat.NoTrailingNewLine */; replacementSpan = modifiersSpan; // If we have access to formatting settings, we print the nodes using the emitter, // and then format the printed text. @@ -134259,9 +134954,9 @@ var ts; } function getPresentModifiers(contextToken) { if (!contextToken) { - return { modifiers: 0 /* None */ }; + return { modifiers: 0 /* ModifierFlags.None */ }; } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; var span; var contextMod; /* @@ -134288,7 +134983,7 @@ var ts; span = ts.createTextSpanFromNode(contextToken); } if (ts.isPropertyDeclaration(contextToken.parent)) { - modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers) & 125951 /* Modifier */; + modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers) & 125951 /* ModifierFlags.Modifier */; span = ts.createTextSpanFromNode(contextToken.parent); } return { modifiers: modifiers, span: span }; @@ -134318,10 +135013,10 @@ var ts; newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))), }); if (formatContext) { - insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); + insertText = printer.printAndFormatSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); } else { - insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); + insertText = printer.printSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); } var signaturePrinter = ts.createPrinter({ removeComments: true, @@ -134334,7 +135029,7 @@ var ts; var methodSignature = ts.factory.createMethodSignature( /*modifiers*/ undefined, /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type); - var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) }; + var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) }; return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails }; } ; @@ -134348,18 +135043,18 @@ var ts; var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false); var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + var builderFlags = 33554432 /* NodeBuilderFlags.OmitThisParameter */ | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: { - var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10 - ? checker.getUnionType(type.types, 2 /* Subtype */) + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: { + var effectiveType = type.flags & 1048576 /* TypeFlags.Union */ && type.types.length < 10 + ? checker.getUnionType(type.types, 2 /* UnionReduction.Subtype */) : type; - if (effectiveType.flags & 1048576 /* Union */) { + if (effectiveType.flags & 1048576 /* TypeFlags.Union */) { // Only offer the completion if there's a single function type component. - var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; }); + var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; }); if (functionTypes.length === 1) { effectiveType = functionTypes[0]; } @@ -134367,7 +135062,7 @@ var ts; return undefined; } } - var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */); + var signatures = checker.getSignaturesOfType(effectiveType, 0 /* SignatureKind.Call */); if (signatures.length !== 1) { // We don't support overloads in object literals. return undefined; @@ -134380,7 +135075,7 @@ var ts; if (preferences.includeCompletionsWithSnippetText) { var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); @@ -134480,11 +135175,11 @@ var ts; return unresolvedData; } function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) { - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; var isFromPackageJson = !!data.isPackageJsonImport; if (completionEntryDataIsResolved(data)) { var resolvedOrigin = { - kind: 32 /* ResolvedExport */, + kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, exportName: data.exportName, moduleSpecifier: data.moduleSpecifier, symbolName: completionName, @@ -134496,7 +135191,7 @@ var ts; return resolvedOrigin; } var unresolvedOrigin = { - kind: 4 /* Export */, + kind: 4 /* SymbolOriginInfoKind.Export */, exportName: data.exportName, exportMapKey: data.exportMapKey, symbolName: completionName, @@ -134512,21 +135207,21 @@ var ts; var sourceFile = importCompletionNode.getSourceFile(); var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); - var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ : + origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ : + 0 /* ExportKind.Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true); var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly); var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken); - var topLevelTypeOnlyText = isTopLevelTypeOnly ? " " + ts.tokenToString(152 /* TypeKeyword */) + " " : " "; - var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(152 /* TypeKeyword */) + " " : ""; + var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : " "; + var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : ""; var suffix = useSemicolons ? ";" : ""; switch (importKind) { - case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; - case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix }; - case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix }; - case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix }; + case 3 /* ImportKind.CommonJS */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " = require(").concat(quotedModuleSpecifier, ")").concat(suffix) }; + case 1 /* ImportKind.Default */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 2 /* ImportKind.Namespace */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "* as ").concat(ts.escapeSnippetText(name), " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 0 /* ImportKind.Named */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "{ ").concat(importSpecifierTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " } from ").concat(quotedModuleSpecifier).concat(suffix) }; } } function quotePropertyName(sourceFile, preferences, name) { @@ -134537,7 +135232,7 @@ var ts; } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || - !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; + !!(localSymbol.flags & 1048576 /* SymbolFlags.ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; } function getSourceFromOrigin(origin) { if (originIsExport(origin)) { @@ -134546,10 +135241,10 @@ var ts; if (originIsResolvedExport(origin)) { return origin.moduleSpecifier; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* SymbolOriginInfoKind.ThisType */) { return CompletionSource.ThisProperty; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { return CompletionSource.TypeOnlyAlias; } } @@ -134568,7 +135263,7 @@ var ts; var symbol = symbols[i]; var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); - if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { + if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* CompletionKind.Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; @@ -134621,7 +135316,7 @@ var ts; allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin); // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(allFlags & 1920 /* Namespace */); + return !!(allFlags & 1920 /* SymbolFlags.Namespace */); } if (isTypeOnlyLocation) { // It's a type, but you can reach it by namespace.type as well @@ -134629,7 +135324,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(allFlags & 111551 /* Value */); + return !!(allFlags & 111551 /* SymbolFlags.Value */); } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; @@ -134653,8 +135348,8 @@ var ts; uniques.set(name, true); entries.push({ name: name, - kindModifiers: "" /* none */, - kind: "label" /* label */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "label" /* ScriptElementKind.label */, sortText: Completions.SortText.LocationPriority }); } @@ -134685,7 +135380,7 @@ var ts; if (!completionData) { return { type: "none" }; } - if (completionData.kind !== 0 /* Data */) { + if (completionData.kind !== 0 /* CompletionDataKind.Data */) { return { type: "request", request: completionData }; } var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; @@ -134699,8 +135394,8 @@ var ts; return ts.firstDefined(symbols, function (symbol, index) { var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); - return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ - || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */) + return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* SymbolFlags.ClassMember */ + || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */) || getSourceFromOrigin(origin) === entryId.source) ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; @@ -134720,14 +135415,14 @@ var ts; case "request": { var request = symbolCompletion.request; switch (request.kind) { - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: return ts.JsDoc.getJSDocTagNameCompletionDetails(name); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: return ts.JsDoc.getJSDocTagCompletionDetails(name); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); - case 4 /* Keywords */: - return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + case 4 /* CompletionDataKind.Keywords */: + return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } @@ -134739,22 +135434,22 @@ var ts; } case "literal": { var literal = symbolCompletion.literal; - return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); + return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* ScriptElementKind.string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. - return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: ts.Debug.assertNever(symbolCompletion); } } Completions.getCompletionEntryDetails = getCompletionEntryDetails; function createSimpleDetails(name, kind, kind2) { - return createCompletionDetails(name, "" /* none */, kind, [ts.displayPart(name, kind2)]); + return createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, kind, [ts.displayPart(name, kind2)]); } function createCompletionDetailsForSymbol(symbol, checker, sourceFile, location, cancellationToken, codeActions, sourceDisplay) { var _a = checker.runWithCancellationToken(cancellationToken, function (checker) { - return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* All */); + return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* SemanticMeaning.All */); }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(checker, symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } @@ -134794,7 +135489,7 @@ var ts; var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); var moduleSymbol = origin.moduleSymbol; var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); + var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier); return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -134826,7 +135521,7 @@ var ts; return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { var symbol = type && type.symbol; // Don't include make a recommended completion for an abstract class - return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol)) + return symbol && (symbol.flags & (8 /* SymbolFlags.EnumMember */ | 384 /* SymbolFlags.Enum */ | 32 /* SymbolFlags.Class */) && !ts.isAbstractConstructorSymbol(symbol)) ? getFirstSymbolInChain(symbol, previousToken, checker) : undefined; }); @@ -134834,31 +135529,31 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return checker.getContextualType(parent); - case 82 /* CaseKeyword */: + case 82 /* SyntaxKind.CaseKeyword */: var caseClause = ts.tryCast(parent, ts.isCaseClause); return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? // At `,`, treat this as the next argument after the comma. - checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* SyntaxKind.CommaToken */ ? 1 : 0)) : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side checker.getTypeAtLocation(parent.left) : @@ -134866,18 +135561,18 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* SymbolFlags.All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { var _a; - return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; })); + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SyntaxKind.SourceFile */; })); } function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) { var typeChecker = program.getTypeChecker(); - var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions); + var inCheckedFile = isCheckedFile(sourceFile, compilerOptions); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) @@ -134889,10 +135584,10 @@ var ts; var isInSnippetScope = false; if (insideComment) { if (ts.hasDocComment(sourceFile, position)) { - if (sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + if (sourceFile.text.charCodeAt(position - 1) === 64 /* CharacterCodes.at */) { // The current position is next to the '@' sign, when no tag name being provided yet. // Provide a full list of tag names - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } else { // When completion is requested without "@", we will have check to make sure that @@ -134913,7 +135608,7 @@ var ts; // */ var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) { - return { kind: 2 /* JsDocTag */ }; + return { kind: 2 /* CompletionDataKind.JsDocTag */ }; } } } @@ -134923,21 +135618,21 @@ var ts; var tag = getJsDocTagAtPosition(currentToken, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } var typeExpression = tryGetTypeExpressionFromTag(tag); if (typeExpression) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 347 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 347 /* SyntaxKind.JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression); } } if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) { - return { kind: 3 /* JsDocParameterName */, tag: tag }; + return { kind: 3 /* CompletionDataKind.JsDocParameterName */, tag: tag }; } } if (!insideJsDocTagTypeExpression) { @@ -134968,16 +135663,16 @@ var ts; var isJsxIdentifierExpected = false; var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); - var keywordFilters = 0 /* None */; + var keywordFilters = 0 /* KeywordCompletionFilters.None */; var isNewIdentifierLocation = false; - var flags = 0 /* None */; + var flags = 0 /* CompletionInfoFlags.None */; if (contextToken) { var importStatementCompletion = getImportStatementCompletionInfo(contextToken); isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation; if (importStatementCompletion.keywordCompletion) { if (importStatementCompletion.isKeywordOnlyCompletion) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)], isNewIdentifierLocation: isNewIdentifierLocation, }; @@ -134990,7 +135685,7 @@ var ts; // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients // to opt in with the `includeCompletionsForImportStatements` user preference. importCompletionNode = importStatementCompletion.replacementNode; - flags |= 2 /* IsImportStatementCompletion */; + flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */; } // Bail out if this is a known invalid completion location if (!importCompletionNode && isCompletionListBlocker(contextToken)) { @@ -135000,11 +135695,11 @@ var ts; : undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { - isRightOfDot = contextToken.kind === 24 /* DotToken */; - isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; + if (contextToken.kind === 24 /* SyntaxKind.DotToken */ || contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* SyntaxKind.DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert); @@ -135012,7 +135707,7 @@ var ts; ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && node.end === contextToken.pos && node.getChildCount(sourceFile) && - ts.last(node.getChildren(sourceFile)).kind !== 21 /* CloseParenToken */)) { + ts.last(node.getChildren(sourceFile)).kind !== 21 /* SyntaxKind.CloseParenToken */)) { // This is likely dot from incorrectly parsed expression and user is starting to write spread // eg: Math.min(./**/) // const x = function (./**/) {} @@ -135020,18 +135715,18 @@ var ts; return undefined; } break; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: node = parent.left; break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: node = parent.name; break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: node = parent; break; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: node = parent.getFirstToken(sourceFile); - ts.Debug.assert(node.kind === 100 /* ImportKeyword */ || node.kind === 103 /* NewKeyword */); + ts.Debug.assert(node.kind === 100 /* SyntaxKind.ImportKeyword */ || node.kind === 103 /* SyntaxKind.NewKeyword */); break; default: // There is nothing that precedes the dot, so this likely just a stray character @@ -135039,58 +135734,58 @@ var ts; return undefined; } } - else if (!importCompletionNode && sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) { // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 206 /* PropertyAccessExpression */) { + if (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 278 /* JsxElement */ || currentToken.parent.kind === 280 /* JsxOpeningElement */) { + case 31 /* SyntaxKind.GreaterThanToken */: + if (currentToken.parent.kind === 278 /* SyntaxKind.JsxElement */ || currentToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { location = currentToken; } break; - case 43 /* SlashToken */: - if (currentToken.parent.kind === 279 /* JsxSelfClosingElement */) { + case 43 /* SyntaxKind.SlashToken */: + if (currentToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 281 /* JsxClosingElement */: - if (contextToken.kind === 43 /* SlashToken */) { + case 281 /* SyntaxKind.JsxClosingElement */: + if (contextToken.kind === 43 /* SyntaxKind.SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: isJsxIdentifierExpected = true; - if (contextToken.kind === 29 /* LessThanToken */) { + if (contextToken.kind === 29 /* SyntaxKind.LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` - if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { + if (previousToken.kind === 19 /* SyntaxKind.CloseBraceToken */ && currentToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -135098,16 +135793,16 @@ var ts; break; } switch (previousToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: isJsxInitializer = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: isJsxIdentifierExpected = true; // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* SyntaxKind.EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -135116,7 +135811,7 @@ var ts; } } var semanticStart = ts.timestamp(); - var completionKind = 5 /* None */; + var completionKind = 5 /* CompletionKind.None */; var isNonContextualObjectLiteral = false; var hasUnresolvedAutoImports = false; // This also gets mutated in nested-functions after the return @@ -135136,8 +135831,8 @@ var ts; symbols = typeChecker.getJsxIntrinsicTagNamesAt(location); ts.Debug.assertEachIsDefined(symbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else if (isStartingCloseTag) { var tagName = contextToken.parent.parent.openingElement.tagName; @@ -135145,8 +135840,8 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the @@ -135160,10 +135855,10 @@ var ts; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); var contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker); - var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : undefined; }); + var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* TypeFlags.EnumLiteral */) ? t.value : undefined; }); var recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker); return { - kind: 0 /* Data */, + kind: 0 /* CompletionDataKind.Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, @@ -135188,13 +135883,13 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 345 /* JSDocTypedefTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return true; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return !!tag.constraint; default: return false; @@ -135203,13 +135898,13 @@ var ts; function tryGetTypeExpressionFromTag(tag) { if (isTagWithTypeExpression(tag)) { var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression; - return typeExpression && typeExpression.kind === 309 /* JSDocTypeExpression */ ? typeExpression : undefined; + return typeExpression && typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? typeExpression : undefined; } return undefined; } function getTypeScriptMemberSymbols() { // Right of dot member completion list - completionKind = 2 /* PropertyAccess */; + completionKind = 2 /* CompletionKind.PropertyAccess */; // Since this is qualified name check it's a type node location var isImportType = ts.isLiteralImportTypeNode(node); var isTypeLocation = insideJsDocTagTypeExpression @@ -135224,7 +135919,7 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & (1536 /* Module */ | 384 /* Enum */)) { + if (symbol.flags & (1536 /* SymbolFlags.Module */ | 384 /* SymbolFlags.Enum */)) { // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); @@ -135232,7 +135927,7 @@ var ts; var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); }; var isValidAccess = isNamespaceName // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. - ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } + ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* SymbolFlags.Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -135246,7 +135941,7 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 305 /* SourceFile */ && d.kind !== 261 /* ModuleDeclaration */ && d.kind !== 260 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 305 /* SyntaxKind.SourceFile */ && d.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 260 /* SyntaxKind.EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -135260,7 +135955,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } return; } @@ -135284,7 +135979,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } } function addTypeProperties(type, insertAwait, insertQuestionDot) { @@ -135292,16 +135987,8 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent; - if (inUncheckedFile) { - // In javascript files, for union types, we don't just get the members that - // the individual types have in common, we also include all the members that - // each individual type has. This is because we're going to add all identifiers - // anyways. So we might as well elevate the members that were at least part - // of the individual types to a higher status since we know what they are. - symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); })); - } - else { + var propertyAccess = node.kind === 200 /* SyntaxKind.ImportType */ ? node : node.parent; + if (inCheckedFile) { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { @@ -135309,6 +135996,14 @@ var ts; } } } + else { + // In javascript files, for union types, we don't just get the members that + // the individual types have in common, we also include all the members that + // each individual type has. This is because we're going to add all identifiers + // anyways. So we might as well elevate the members that were at least part + // of the individual types to a higher status since we know what they are. + symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); })); + } if (insertAwait && preferences.includeCompletionsWithInsertText) { var promiseType = typeChecker.getPromisedTypeOfPromise(type); if (promiseType) { @@ -135339,12 +136034,12 @@ var ts; if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) || typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) { - symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolOriginInfoKind.SymbolMemberNoExport */) }; } else { var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined; var moduleSpecifier = ((importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences))).getModuleSpecifierForBestExportInfo([{ - exportKind: 0 /* Named */, + exportKind: 0 /* ExportKind.Named */, moduleFileName: fileName, isFromPackageJson: false, moduleSymbol: moduleSymbol, @@ -135353,7 +136048,7 @@ var ts; }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)) || {}).moduleSpecifier; if (moduleSpecifier) { var origin = { - kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false, symbolName: firstAccessibleSymbol.name, @@ -135384,15 +136079,15 @@ var ts; function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { - symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* SymbolOriginInfoKind.Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* SymbolOriginInfoKind.Nullable */ }; } } } function getNullableSymbolOriginInfoKind(kind) { - return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + return insertQuestionDot ? kind | 16 /* SymbolOriginInfoKind.Nullable */ : kind; } } /** Given 'a.b.c', returns 'a'. */ @@ -135408,44 +136103,44 @@ var ts; || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() - || (getGlobalCompletions(), 1 /* Success */); - return result === 1 /* Success */; + || (getGlobalCompletions(), 1 /* GlobalsSearch.Success */); + return result === 1 /* GlobalsSearch.Success */; } function tryGetConstructorCompletion() { if (!tryGetConstructorLikeCompletionContainer(contextToken)) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // no members, only keywords - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; // Declaring new property/method/accessor isNewIdentifierLocation = true; // Has keywords for constructor parameter - keywordFilters = 4 /* ConstructorParameterKeywords */; - return 1 /* Success */; + keywordFilters = 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */; + return 1 /* GlobalsSearch.Success */; } function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) - return 0 /* Continue */; - var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* Completions */); + return 0 /* GlobalsSearch.Continue */; + var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* ContextFlags.Completions */); symbols = ts.concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties)); setSortTextToOptionalMember(); - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function tryGetImportCompletionSymbols() { if (!importCompletionNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; isNewIdentifierLocation = true; collectAutoImports(); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function getGlobalCompletions() { - keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; + keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */ : 1 /* KeywordCompletionFilters.All */; // Get all entities in the current scope. - completionKind = 1 /* Global */; + completionKind = 1 /* CompletionKind.Global */; isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); @@ -135480,7 +136175,7 @@ var ts; position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); - var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnlyLocation ? 0 /* SymbolFlags.None */ : 111551 /* SymbolFlags.Value */) | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */; var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken); symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings)); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); @@ -135490,21 +136185,21 @@ var ts; !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords; } - if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) { + if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* SymbolFlags.Value */)) { var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); if (typeOnlyAliasDeclaration) { - var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; + var origin = { kind: 64 /* SymbolOriginInfoKind.TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; symbolToOriginInfoMap[i] = origin; } } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SyntaxKind.SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; - symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* SymbolOriginInfoKind.ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers; } @@ -135513,8 +136208,8 @@ var ts; collectAutoImports(); if (isTypeOnlyLocation) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* KeywordCompletionFilters.TypeAssertionKeywords */ + : 7 /* KeywordCompletionFilters.TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -135538,10 +136233,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 305 /* SourceFile */: - case 223 /* TemplateExpression */: - case 288 /* JsxExpression */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 223 /* SyntaxKind.TemplateExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 235 /* SyntaxKind.Block */: return true; default: return ts.isStatement(scopeNode); @@ -135557,29 +136252,29 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - ((contextToken.kind === 112 /* TypeOfKeyword */ && - (contextToken.parent.kind === 181 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || - (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 177 /* TypePredicate */)); + ((contextToken.kind === 112 /* SyntaxKind.TypeOfKeyword */ && + (contextToken.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* SyntaxKind.AssertsKeyword */ && contextToken.parent.kind === 177 /* SyntaxKind.TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 58 /* ColonToken */: - return parentKind === 167 /* PropertyDeclaration */ || - parentKind === 166 /* PropertySignature */ || - parentKind === 164 /* Parameter */ || - parentKind === 254 /* VariableDeclaration */ || + case 58 /* SyntaxKind.ColonToken */: + return parentKind === 167 /* SyntaxKind.PropertyDeclaration */ || + parentKind === 166 /* SyntaxKind.PropertySignature */ || + parentKind === 164 /* SyntaxKind.Parameter */ || + parentKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 63 /* EqualsToken */: - return parentKind === 259 /* TypeAliasDeclaration */; - case 127 /* AsKeyword */: - return parentKind === 229 /* AsExpression */; - case 29 /* LessThanToken */: - return parentKind === 178 /* TypeReference */ || - parentKind === 211 /* TypeAssertionExpression */; - case 94 /* ExtendsKeyword */: - return parentKind === 163 /* TypeParameter */; + case 63 /* SyntaxKind.EqualsToken */: + return parentKind === 259 /* SyntaxKind.TypeAliasDeclaration */; + case 127 /* SyntaxKind.AsKeyword */: + return parentKind === 229 /* SyntaxKind.AsExpression */; + case 29 /* SyntaxKind.LessThanToken */: + return parentKind === 178 /* SyntaxKind.TypeReference */ || + parentKind === 211 /* SyntaxKind.TypeAssertionExpression */; + case 94 /* SyntaxKind.ExtendsKeyword */: + return parentKind === 163 /* SyntaxKind.TypeParameter */; } } return false; @@ -135594,7 +136289,7 @@ var ts; // Asking for completion details for an item that is not an auto-import return; } - flags |= 1 /* MayIncludeAutoImports */; + flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */; // import { type | -> token text should be blank var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken && importCompletionNode @@ -135613,13 +136308,13 @@ var ts; return false; if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return false; - if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */)) + if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */)) return false; - if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */))) + if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */))) return false; // Do not try to auto-import something with a lowercase first letter for a JSX tag var firstChar = symbolName.charCodeAt(0); - if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */)) + if (isRightOfOpenTag && (firstChar < 65 /* CharacterCodes.A */ || firstChar > 90 /* CharacterCodes.Z */)) return false; if (detailsEntryId) return true; @@ -135655,14 +136350,14 @@ var ts; if (result !== "skipped") { (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier); } - var isDefaultExport = exportInfo.exportKind === 1 /* Default */; + var isDefaultExport = exportInfo.exportKind === 1 /* ExportKind.Default */; var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol; pushAutoImportSymbol(symbol, { - kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + kind: moduleSpecifier ? 32 /* SymbolOriginInfoKind.ResolvedExport */ : 4 /* SymbolOriginInfoKind.Export */, moduleSpecifier: moduleSpecifier, symbolName: symbolName, exportMapKey: exportMapKey, - exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name, + exportName: exportInfo.exportKind === 2 /* ExportKind.ExportEquals */ ? "export=" /* InternalSymbolName.ExportEquals */ : exportInfo.symbol.name, fileName: exportInfo.moduleFileName, isDefaultExport: isDefaultExport, moduleSymbol: exportInfo.moduleSymbol, @@ -135670,8 +136365,8 @@ var ts; }); }); hasUnresolvedAutoImports = context.skippedAny(); - flags |= context.resolvedAny() ? 8 /* ResolvedModuleSpecifiers */ : 0; - flags |= context.resolvedBeyondLimit() ? 16 /* ResolvedModuleSpecifiersBeyondLimit */ : 0; + flags |= context.resolvedAny() ? 8 /* CompletionInfoFlags.ResolvedModuleSpecifiers */ : 0; + flags |= context.resolvedBeyondLimit() ? 16 /* CompletionInfoFlags.ResolvedModuleSpecifiersBeyondLimit */ : 0; }); function isImportableExportInfo(info) { var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); @@ -135708,7 +136403,7 @@ var ts; return; } var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions), - /*origin*/ undefined, 0 /* ObjectPropertyDeclaration */, + /*origin*/ undefined, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (!displayName) { return; @@ -135718,8 +136413,8 @@ var ts; if (!entryProps) { return; } - var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps); - flags |= 32 /* MayIncludeMethodSnippets */; + var origin = __assign({ kind: 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */ }, entryProps); + flags |= 32 /* CompletionInfoFlags.MayIncludeMethodSnippets */; symbolToOriginInfoMap[symbols.length] = origin; symbols.push(member); }); @@ -135734,7 +136429,7 @@ var ts; `bar` will have symbol flag `Method`, `foo` will have symbol flag `Property`. */ - if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) { + if (!(symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */))) { return false; } return true; @@ -135761,27 +136456,27 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 11 /* JsxText */) { + if (contextToken.kind === 11 /* SyntaxKind.JsxText */) { return true; } - if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */ && contextToken.parent) { // /**/ /> // /**/ > // - contextToken: GreaterThanToken (before cursor) // - location: JsxSelfClosingElement or JsxOpeningElement // - contextToken.parent === location - if (location === contextToken.parent && (location.kind === 280 /* JsxOpeningElement */ || location.kind === 279 /* JsxSelfClosingElement */)) { + if (location === contextToken.parent && (location.kind === 280 /* SyntaxKind.JsxOpeningElement */ || location.kind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { return false; } - if (contextToken.parent.kind === 280 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { //
/**/ // - contextToken: GreaterThanToken (before cursor) // - location: JSXElement // - different parents (JSXOpeningElement, JSXElement) - return location.parent.kind !== 280 /* JsxOpeningElement */; + return location.parent.kind !== 280 /* SyntaxKind.JsxOpeningElement */; } - if (contextToken.parent.kind === 281 /* JsxClosingElement */ || contextToken.parent.kind === 279 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* JsxElement */; + if (contextToken.parent.kind === 281 /* SyntaxKind.JsxClosingElement */ || contextToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* SyntaxKind.JsxElement */; } } return false; @@ -135792,45 +136487,45 @@ var ts; var tokenKind = keywordForNode(contextToken); // Previous token may have been a keyword that was converted to an identifier. switch (tokenKind) { - case 27 /* CommaToken */: - return containingNodeKind === 208 /* CallExpression */ // func( a, | - || containingNodeKind === 171 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 209 /* NewExpression */ // new C(a, | - || containingNodeKind === 204 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 221 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 179 /* FunctionType */ // var x: (s: string, list| - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { x, | - case 20 /* OpenParenToken */: - return containingNodeKind === 208 /* CallExpression */ // func( | - || containingNodeKind === 171 /* Constructor */ // constructor( | - || containingNodeKind === 209 /* NewExpression */ // new C(a| - || containingNodeKind === 212 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 191 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 22 /* OpenBracketToken */: - return containingNodeKind === 204 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 176 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 162 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 141 /* ModuleKeyword */: // module | - case 142 /* NamespaceKeyword */: // namespace | - case 100 /* ImportKeyword */: // import | + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( a, | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a, | + || containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [a, | + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */ // const x = (a, | + || containingNodeKind === 179 /* SyntaxKind.FunctionType */ // var x: (s: string, list| + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { x, | + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( | + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a| + || containingNodeKind === 212 /* SyntaxKind.ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 191 /* SyntaxKind.ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [ | + || containingNodeKind === 176 /* SyntaxKind.IndexSignature */ // [ | : string ] + || containingNodeKind === 162 /* SyntaxKind.ComputedPropertyName */; // [ | /* this can become an index signature */ + case 141 /* SyntaxKind.ModuleKeyword */: // module | + case 142 /* SyntaxKind.NamespaceKeyword */: // namespace | + case 100 /* SyntaxKind.ImportKeyword */: // import | return true; - case 24 /* DotToken */: - return containingNodeKind === 261 /* ModuleDeclaration */; // module A.| - case 18 /* OpenBraceToken */: - return containingNodeKind === 257 /* ClassDeclaration */ // class A { | - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { | - case 63 /* EqualsToken */: - return containingNodeKind === 254 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 221 /* BinaryExpression */; // x = a| - case 15 /* TemplateHead */: - return containingNodeKind === 223 /* TemplateExpression */; // `aa ${| - case 16 /* TemplateMiddle */: - return containingNodeKind === 233 /* TemplateSpan */; // `aa ${10} dd ${| - case 131 /* AsyncKeyword */: - return containingNodeKind === 169 /* MethodDeclaration */ // const obj = { async c|() - || containingNodeKind === 297 /* ShorthandPropertyAssignment */; // const obj = { async c| - case 41 /* AsteriskToken */: - return containingNodeKind === 169 /* MethodDeclaration */; // const obj = { * c| + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 261 /* SyntaxKind.ModuleDeclaration */; // module A.| + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ // class A { | + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { | + case 63 /* SyntaxKind.EqualsToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ // const x = a| + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */; // x = a| + case 15 /* SyntaxKind.TemplateHead */: + return containingNodeKind === 223 /* SyntaxKind.TemplateExpression */; // `aa ${| + case 16 /* SyntaxKind.TemplateMiddle */: + return containingNodeKind === 233 /* SyntaxKind.TemplateSpan */; // `aa ${10} dd ${| + case 131 /* SyntaxKind.AsyncKeyword */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */ // const obj = { async c|() + || containingNodeKind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; // const obj = { async c| + case 41 /* SyntaxKind.AsteriskToken */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */; // const obj = { * c| } if (isClassMemberCompletionKeyword(tokenKind)) { return true; @@ -135849,21 +136544,21 @@ var ts; function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { var typeLiteralNode = tryGetTypeLiteralNode(contextToken); if (!typeLiteralNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; var containerTypeNode = intersectionTypeNode || typeLiteralNode; var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); if (!containerExpectedType) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var containerActualType = typeChecker.getTypeFromTypeNode(containerTypeNode); var members = getPropertiesForCompletion(containerExpectedType, typeChecker); var existingMembers = getPropertiesForCompletion(containerActualType, typeChecker); var existingMemberEscapedNames = new ts.Set(); existingMembers.forEach(function (s) { return existingMemberEscapedNames.add(s.escapedName); }); symbols = ts.concatenate(symbols, ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); })); - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; isNewIdentifierLocation = true; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. @@ -135875,22 +136570,22 @@ var ts; var symbolsStartIndex = symbols.length; var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); if (!objectLikeContainer) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from contextual/inferred/declared type. - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { - if (objectLikeContainer.flags & 33554432 /* InWithStatement */) { - return 2 /* Fail */; + if (objectLikeContainer.flags & 33554432 /* NodeFlags.InWithStatement */) { + return 2 /* GlobalsSearch.Fail */; } isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } - var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* Completions */); + var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* ContextFlags.Completions */); var hasStringIndexType = (completionsType || instantiatedType).getStringIndexType(); var hasNumberIndextype = (completionsType || instantiatedType).getNumberIndexType(); isNewIdentifierLocation = !!hasStringIndexType || !!hasNumberIndextype; @@ -135900,12 +136595,12 @@ var ts; // Edge case: If NumberIndexType exists if (!hasNumberIndextype) { isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } } } else { - ts.Debug.assert(objectLikeContainer.kind === 201 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 201 /* SyntaxKind.ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -135916,19 +136611,19 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 164 /* SyntaxKind.Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 169 /* MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SyntaxKind.SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } if (canGetType) { var typeForObject_1 = typeChecker.getTypeAtLocation(objectLikeContainer); if (!typeForObject_1) - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; typeMembers = typeChecker.getPropertiesOfType(typeForObject_1).filter(function (propertySymbol) { return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*writing*/ false, typeForObject_1, propertySymbol); }); @@ -135940,14 +136635,14 @@ var ts; var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)); symbols = ts.concatenate(symbols, filteredMembers); setSortTextToOptionalMember(); - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */ + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && preferences.includeCompletionsWithObjectLiteralMethodSnippets && preferences.includeCompletionsWithInsertText) { transformObjectLiteralMembersSortText(symbolsStartIndex); collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer); } } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in import clauses and export clauses @@ -135964,38 +136659,38 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { if (!contextToken) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // `import { |` or `import { a as 0, | }` or `import { type | }` - var namedImportsOrExports = contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : + var namedImportsOrExports = contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : ts.isTypeKeywordTokenOrIdentifier(contextToken) ? ts.tryCast(contextToken.parent.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We can at least offer `type` at `import { |` if (!ts.isTypeKeywordTokenOrIdentifier(contextToken)) { - keywordFilters = 8 /* TypeKeyword */; + keywordFilters = 8 /* KeywordCompletionFilters.TypeKeyword */; } // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 269 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) { isNewIdentifierLocation = true; - return namedImportsOrExports.kind === 269 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? 2 /* GlobalsSearch.Fail */ : 0 /* GlobalsSearch.Continue */; } var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) { isNewIdentifierLocation = true; - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; } - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); var existing = new ts.Set(namedImportsOrExports.elements.filter(function (n) { return !isCurrentlyEditingNode(n); }).map(function (n) { return (n.propertyName || n.name).escapedText; })); - var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); }); + var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* InternalSymbolName.Default */ && !existing.has(e.escapedName); }); symbols = ts.concatenate(symbols, uniques); if (!uniques.length) { // If there's nothing else to import, don't offer `type` either - keywordFilters = 0 /* None */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Adds local declarations for completions in named exports: @@ -136008,14 +136703,14 @@ var ts; */ function tryGetLocalNamedExportCompletionSymbols() { var _a; - var namedExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) + var namedExports = contextToken && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedExports) : undefined; if (!namedExports) { - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } var localsContainer = ts.findAncestor(namedExports, ts.or(ts.isSourceFile, ts.isModuleDeclaration)); - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; isNewIdentifierLocation = false; (_a = localsContainer.locals) === null || _a === void 0 ? void 0 : _a.forEach(function (symbol, name) { var _a, _b; @@ -136024,7 +136719,7 @@ var ts; symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember; } }); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in class declaration @@ -136033,48 +136728,48 @@ var ts; function tryGetClassLikeCompletionSymbols() { var decl = tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position); if (!decl) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from parent type. - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : - ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; + keywordFilters = contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ ? 0 /* KeywordCompletionFilters.None */ : + ts.isClassLike(decl) ? 2 /* KeywordCompletionFilters.ClassElementKeywords */ : 3 /* KeywordCompletionFilters.InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) - return 1 /* Success */; - var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; + return 1 /* GlobalsSearch.Success */; + var classElement = contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* ModifierFlags.None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* SyntaxKind.Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": - classElementModifierFlags = classElementModifierFlags | 8 /* Private */; + classElementModifierFlags = classElementModifierFlags | 8 /* ModifierFlags.Private */; break; case "static": - classElementModifierFlags = classElementModifierFlags | 32 /* Static */; + classElementModifierFlags = classElementModifierFlags | 32 /* ModifierFlags.Static */; break; case "override": - classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + classElementModifierFlags = classElementModifierFlags | 16384 /* ModifierFlags.Override */; break; } } if (ts.isClassStaticBlockDeclaration(classElement)) { - classElementModifierFlags |= 32 /* Static */; + classElementModifierFlags |= 32 /* ModifierFlags.Static */; } // No member list for private methods - if (!(classElementModifierFlags & 8 /* Private */)) { + if (!(classElementModifierFlags & 8 /* ModifierFlags.Private */)) { // List of property symbols of base type that are not private and already implemented - var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* ModifierFlags.Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); var baseSymbols = ts.flatMap(baseTypeNodes, function (baseTypeNode) { var type = typeChecker.getTypeAtLocation(baseTypeNode); - return classElementModifierFlags & 32 /* Static */ ? + return classElementModifierFlags & 32 /* ModifierFlags.Static */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); }); symbols = ts.concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags)); } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function isConstructorParameterCompletion(node) { return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent) @@ -136088,8 +136783,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 20 /* OpenParenToken */: - case 27 /* CommaToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 27 /* SyntaxKind.CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -136119,23 +136814,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 31 /* GreaterThanToken */: // End of a type argument list - case 30 /* LessThanSlashToken */: - case 43 /* SlashToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: - case 286 /* JsxAttributes */: - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 279 /* JsxSelfClosingElement */ || parent.kind === 280 /* JsxOpeningElement */)) { - if (contextToken.kind === 31 /* GreaterThanToken */) { + case 31 /* SyntaxKind.GreaterThanToken */: // End of a type argument list + case 30 /* SyntaxKind.LessThanSlashToken */: + case 43 /* SyntaxKind.SlashToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 286 /* SyntaxKind.JsxAttributes */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + if (parent && (parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || parent.kind === 280 /* SyntaxKind.JsxOpeningElement */)) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SyntaxKind.SlashToken */)) break; } return parent; } - else if (parent.kind === 285 /* JsxAttribute */) { + else if (parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136146,8 +136841,8 @@ var ts; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement - case 10 /* StringLiteral */: - if (parent && ((parent.kind === 285 /* JsxAttribute */) || (parent.kind === 287 /* JsxSpreadAttribute */))) { + case 10 /* SyntaxKind.StringLiteral */: + if (parent && ((parent.kind === 285 /* SyntaxKind.JsxAttribute */) || (parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136155,10 +136850,10 @@ var ts; return parent.parent.parent; } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (parent && - parent.kind === 288 /* JsxExpression */ && - parent.parent && parent.parent.kind === 285 /* JsxAttribute */) { + parent.kind === 288 /* SyntaxKind.JsxExpression */ && + parent.parent && parent.parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136166,7 +136861,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 287 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136185,75 +136880,75 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 27 /* CommaToken */: - return containingNodeKind === 254 /* VariableDeclaration */ || + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 237 /* VariableStatement */ || - containingNodeKind === 260 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 237 /* SyntaxKind.VariableStatement */ || + containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 24 /* DotToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [.| - case 58 /* ColonToken */: - return containingNodeKind === 203 /* BindingElement */; // var {x :html| - case 22 /* OpenBracketToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [x| - case 20 /* OpenParenToken */: - return containingNodeKind === 292 /* CatchClause */ || + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [.| + case 58 /* SyntaxKind.ColonToken */: + return containingNodeKind === 203 /* SyntaxKind.BindingElement */; // var {x :html| + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [x| + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 292 /* SyntaxKind.CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 18 /* OpenBraceToken */: - return containingNodeKind === 260 /* EnumDeclaration */; // enum a { | - case 29 /* LessThanToken */: - return containingNodeKind === 257 /* ClassDeclaration */ || // class A< | - containingNodeKind === 226 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 259 /* TypeAliasDeclaration */ || // type List< | + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */; // enum a { | + case 29 /* SyntaxKind.LessThanToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ || // class A< | + containingNodeKind === 226 /* SyntaxKind.ClassExpression */ || // var C = class D< | + containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A< | + containingNodeKind === 259 /* SyntaxKind.TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 124 /* StaticKeyword */: - return containingNodeKind === 167 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 25 /* DotDotDotToken */: - return containingNodeKind === 164 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 202 /* ArrayBindingPattern */); // var [...z| - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - return containingNodeKind === 164 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 127 /* AsKeyword */: - return containingNodeKind === 270 /* ImportSpecifier */ || - containingNodeKind === 275 /* ExportSpecifier */ || - containingNodeKind === 268 /* NamespaceImport */; - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + return containingNodeKind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* SyntaxKind.DotDotDotToken */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ || + (!!parent.parent && parent.parent.kind === 202 /* SyntaxKind.ArrayBindingPattern */); // var [...z| + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* SyntaxKind.AsKeyword */: + return containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ || + containingNodeKind === 275 /* SyntaxKind.ExportSpecifier */ || + containingNodeKind === 268 /* SyntaxKind.NamespaceImport */; + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 79 /* Identifier */: - if (containingNodeKind === 270 /* ImportSpecifier */ && + case 79 /* SyntaxKind.Identifier */: + if (containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ && contextToken === parent.name && contextToken.text === "type") { // import { type | } return false; } break; - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 118 /* InterfaceKeyword */: - case 98 /* FunctionKeyword */: - case 113 /* VarKeyword */: - case 100 /* ImportKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 137 /* InferKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return true; - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: // import { type foo| } - return containingNodeKind !== 270 /* ImportSpecifier */; - case 41 /* AsteriskToken */: + return containingNodeKind !== 270 /* SyntaxKind.ImportSpecifier */; + case 41 /* SyntaxKind.AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword corresponding to class member completion keyword @@ -136274,21 +136969,21 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 126 /* AbstractKeyword */: - case 84 /* ClassKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 98 /* FunctionKeyword */: - case 118 /* InterfaceKeyword */: - case 119 /* LetKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 124 /* StaticKeyword */: - case 113 /* VarKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return true; - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } // If we are inside a class declaration, and `constructor` is totally not present, @@ -136297,7 +136992,7 @@ var ts; if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { return false; // Don't block completions. } - var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* PropertyDeclaration */); + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* SyntaxKind.PropertyDeclaration */); // If we are inside a class declaration and typing `constructor` after property declaration... if (ancestorPropertyDeclaraion && contextToken !== previousToken @@ -136308,7 +137003,7 @@ var ts; if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { return false; // Don't block completions. } - else if (contextToken.kind !== 63 /* EqualsToken */ + else if (contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ // Should not block: `class C { blah = c/**/ }` // But should block: `class C { blah = somewhat c/**/ }` and `class C { blah: SomeType c/**/ }` && (ts.isInitializedProperty(ancestorPropertyDeclaraion) @@ -136324,22 +137019,22 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isPreviousPropertyDeclarationTerminated(contextToken, position) { - return contextToken.kind !== 63 /* EqualsToken */ && - (contextToken.kind === 26 /* SemicolonToken */ + return contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ && + (contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 171 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 171 /* SyntaxKind.Constructor */; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8 /* NumericLiteral */) { + if (contextToken.kind === 8 /* SyntaxKind.NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -136357,13 +137052,13 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 296 /* PropertyAssignment */ && - m.kind !== 297 /* ShorthandPropertyAssignment */ && - m.kind !== 203 /* BindingElement */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */ && - m.kind !== 298 /* SpreadAssignment */) { + if (m.kind !== 296 /* SyntaxKind.PropertyAssignment */ && + m.kind !== 297 /* SyntaxKind.ShorthandPropertyAssignment */ && + m.kind !== 203 /* SyntaxKind.BindingElement */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */ && + m.kind !== 298 /* SyntaxKind.SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -136376,7 +137071,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 79 /* Identifier */) { + if (m.propertyName.kind === 79 /* SyntaxKind.Identifier */) { existingName = m.propertyName.escapedText; } } @@ -136410,7 +137105,7 @@ var ts; function setSortTextToOptionalMember() { symbols.forEach(function (m) { var _a; - if (m.flags & 16777216 /* Optional */) { + if (m.flags & 16777216 /* SymbolFlags.Optional */) { var symbolId = ts.getSymbolId(m); symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember; } @@ -136435,7 +137130,7 @@ var ts; var symbolId = ts.getSymbolId(symbol); var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var target = ts.getEmitScriptTarget(compilerOptions); - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */, + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (displayName) { var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority; @@ -136454,10 +137149,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 167 /* PropertyDeclaration */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */) { + if (m.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -136465,11 +137160,11 @@ var ts; continue; } // Dont filter member even if the name matches if it is declared private in the list - if (ts.hasEffectiveModifier(m, 8 /* Private */)) { + if (ts.hasEffectiveModifier(m, 8 /* ModifierFlags.Private */)) { continue; } // do not filter it out if the static presence doesnt match - if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { + if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* ModifierFlags.Static */)) { continue; } var existingName = ts.getPropertyNameForPropertyNameNode(m.name); @@ -136480,7 +137175,7 @@ var ts; return baseSymbols.filter(function (propertySymbol) { return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && - !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && + !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* ModifierFlags.Private */) && !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } @@ -136499,7 +137194,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 285 /* JsxAttribute */) { + if (attr.kind === 285 /* SyntaxKind.JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -136522,15 +137217,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 18 /* SyntaxKind.OpenBraceToken */: // const x = { | + case 27 /* SyntaxKind.CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -136553,12 +137248,12 @@ var ts; undefined; if (!moduleSymbol) return undefined; - var symbol = data.exportName === "export=" /* ExportEquals */ + var symbol = data.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); if (!symbol) return undefined; - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) }; } @@ -136567,27 +137262,27 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) + || symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { - case 3 /* MemberLike */: + case 3 /* CompletionKind.MemberLike */: return undefined; - case 0 /* ObjectPropertyDeclaration */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; - case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 2 /* CompletionKind.PropertyAccess */: + case 1 /* CompletionKind.Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 - return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; - case 5 /* None */: - case 4 /* String */: + return name.charCodeAt(0) === 32 /* CharacterCodes.space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; + case 5 /* CompletionKind.None */: + case 4 /* CompletionKind.String */: return validNameResult; default: ts.Debug.assertNever(kind); @@ -136597,11 +137292,11 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 81 /* FirstKeyword */; i <= 160 /* LastKeyword */; i++) { + for (var i = 81 /* SyntaxKind.FirstKeyword */; i <= 160 /* SyntaxKind.LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords }); } @@ -136610,7 +137305,7 @@ var ts; function getKeywordCompletions(keywordFilter, filterOutTsOnlyKeywords) { if (!filterOutTsOnlyKeywords) return getTypescriptKeywordCompletions(keywordFilter); - var index = keywordFilter + 8 /* Last */ + 1; + var index = keywordFilter + 8 /* KeywordCompletionFilters.Last */ + 1; return _keywordCompletions[index] || (_keywordCompletions[index] = getTypescriptKeywordCompletions(keywordFilter) .filter(function (entry) { return !isTypeScriptOnlyKeyword(ts.stringToToken(entry.name)); })); @@ -136619,30 +137314,30 @@ var ts; return _keywordCompletions[keywordFilter] || (_keywordCompletions[keywordFilter] = allKeywordsCompletions().filter(function (entry) { var kind = ts.stringToToken(entry.name); switch (keywordFilter) { - case 0 /* None */: + case 0 /* KeywordCompletionFilters.None */: return false; - case 1 /* All */: + case 1 /* KeywordCompletionFilters.All */: return isFunctionLikeBodyKeyword(kind) - || kind === 135 /* DeclareKeyword */ - || kind === 141 /* ModuleKeyword */ - || kind === 152 /* TypeKeyword */ - || kind === 142 /* NamespaceKeyword */ - || kind === 126 /* AbstractKeyword */ - || ts.isTypeKeyword(kind) && kind !== 153 /* UndefinedKeyword */; - case 5 /* FunctionLikeBodyKeywords */: + || kind === 135 /* SyntaxKind.DeclareKeyword */ + || kind === 141 /* SyntaxKind.ModuleKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ + || kind === 142 /* SyntaxKind.NamespaceKeyword */ + || kind === 126 /* SyntaxKind.AbstractKeyword */ + || ts.isTypeKeyword(kind) && kind !== 153 /* SyntaxKind.UndefinedKeyword */; + case 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); - case 2 /* ClassElementKeywords */: + case 2 /* KeywordCompletionFilters.ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); - case 3 /* InterfaceElementKeywords */: + case 3 /* KeywordCompletionFilters.InterfaceElementKeywords */: return isInterfaceOrTypeLiteralCompletionKeyword(kind); - case 4 /* ConstructorParameterKeywords */: + case 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); - case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; - case 7 /* TypeKeywords */: + case 6 /* KeywordCompletionFilters.TypeAssertionKeywords */: + return ts.isTypeKeyword(kind) || kind === 85 /* SyntaxKind.ConstKeyword */; + case 7 /* KeywordCompletionFilters.TypeKeywords */: return ts.isTypeKeyword(kind); - case 8 /* TypeKeyword */: - return kind === 152 /* TypeKeyword */; + case 8 /* KeywordCompletionFilters.TypeKeyword */: + return kind === 152 /* SyntaxKind.TypeKeyword */; default: return ts.Debug.assertNever(keywordFilter); } @@ -136650,64 +137345,64 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 130 /* AnyKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 157 /* GlobalKeyword */: - case 117 /* ImplementsKeyword */: - case 137 /* InferKeyword */: - case 118 /* InterfaceKeyword */: - case 139 /* IsKeyword */: - case 140 /* KeyOfKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 143 /* NeverKeyword */: - case 147 /* NumberKeyword */: - case 148 /* ObjectKeyword */: - case 159 /* OverrideKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: - case 150 /* StringKeyword */: - case 151 /* SymbolKeyword */: - case 152 /* TypeKeyword */: - case 154 /* UniqueKeyword */: - case 155 /* UnknownKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 117 /* SyntaxKind.ImplementsKeyword */: + case 137 /* SyntaxKind.InferKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 139 /* SyntaxKind.IsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 145 /* ReadonlyKeyword */; + return kind === 145 /* SyntaxKind.ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 134 /* ConstructorKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 131 /* AsyncKeyword */ - || kind === 132 /* AwaitKeyword */ - || kind === 127 /* AsKeyword */ - || kind === 152 /* TypeKeyword */ + return kind === 131 /* SyntaxKind.AsyncKeyword */ + || kind === 132 /* SyntaxKind.AwaitKeyword */ + || kind === 127 /* SyntaxKind.AsKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { - return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; + return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* SyntaxKind.Unknown */ : node.kind; } function getContextualKeywords(contextToken, position) { var entries = []; @@ -136728,9 +137423,9 @@ var ts; && contextToken === parent.moduleSpecifier && tokenLine === currentLine) { entries.push({ - name: ts.tokenToString(129 /* AssertKeyword */), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + name: ts.tokenToString(129 /* SyntaxKind.AssertKeyword */), + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }); } @@ -136746,7 +137441,7 @@ var ts; } function getPropertiesForObjectExpression(contextualType, completionsType, obj, checker) { var hasCompletionsType = completionsType && completionsType !== contextualType; - var type = hasCompletionsType && !(completionsType.flags & 3 /* AnyOrUnknown */) + var type = hasCompletionsType && !(completionsType.flags & 3 /* TypeFlags.AnyOrUnknown */) ? checker.getUnionType([contextualType, completionsType]) : contextualType; var properties = getApparentProperties(type, obj, checker); @@ -136768,7 +137463,7 @@ var ts; if (!type.isUnion()) return type.getApparentProperties(); return checker.getAllPossiblePropertiesOfTypes(ts.filter(type.types, function (memberType) { - return !(memberType.flags & 131068 /* Primitive */ + return !(memberType.flags & 131068 /* TypeFlags.Primitive */ || checker.isArrayLikeType(memberType) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, node) || ts.typeHasCallOrConstructSignatures(memberType, checker) @@ -136776,7 +137471,7 @@ var ts; })); } function containsNonPublicProperties(props) { - return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */); }); + return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */); }); } /** * Gets all properties on a type, but if that type is a union of several types, @@ -136794,15 +137489,19 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile)) { return cls; } break; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { + var originalKeywordKind = location.originalKeywordKind; + if (originalKeywordKind && ts.isKeyword(originalKeywordKind)) { + return undefined; + } // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -136816,22 +137515,22 @@ var ts; if (!contextToken) return undefined; // class C { blah; constructor/**/ } and so on - if (location.kind === 134 /* ConstructorKeyword */ + if (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ // class C { blah \n constructor/**/ } || (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) { return ts.findAncestor(contextToken, ts.isClassLike); } switch (contextToken.kind) { - case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* SyntaxKind.EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; - case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SyntaxKind.SemicolonToken */: // class c {getValue(): number; | } + case 19 /* SyntaxKind.CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* SyntaxKind.OpenBraceToken */: // class c { | + case 27 /* SyntaxKind.CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -136842,7 +137541,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -136851,15 +137550,15 @@ var ts; return undefined; var parent = node.parent; switch (node.kind) { - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.isTypeLiteralNode(parent)) { return parent; } break; - case 26 /* SemicolonToken */: - case 27 /* CommaToken */: - case 79 /* Identifier */: - if (parent.kind === 166 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + case 26 /* SyntaxKind.SemicolonToken */: + case 27 /* SyntaxKind.CommaToken */: + case 79 /* SyntaxKind.Identifier */: + if (parent.kind === 166 /* SyntaxKind.PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { return parent.parent; } break; @@ -136876,11 +137575,11 @@ var ts; if (!t) return undefined; switch (node.kind) { - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); - case 188 /* IntersectionType */: - case 182 /* TypeLiteral */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 187 /* SyntaxKind.UnionType */: return t; } } @@ -136902,13 +137601,13 @@ var ts; return !!contextToken && ts.isPrivateIdentifier(contextToken) && !!ts.getContainingClass(contextToken); case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* SyntaxKind.LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SyntaxKind.SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); case " ": - return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SourceFile */; + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SyntaxKind.SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -136921,22 +137620,22 @@ var ts; function isProbablyGlobalType(type, sourceFile, checker) { // The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in // lib.webworker.d.ts, so checking against `self` is also a check against `window` when it exists. - var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (selfSymbol && checker.getTypeOfSymbolAtLocation(selfSymbol, sourceFile) === type) { return true; } - var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalSymbol && checker.getTypeOfSymbolAtLocation(globalSymbol, sourceFile) === type) { return true; } - var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalThisSymbol && checker.getTypeOfSymbolAtLocation(globalThisSymbol, sourceFile) === type) { return true; } return false; } function isStaticProperty(symbol) { - return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); + return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* ModifierFlags.Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); } function tryGetObjectLiteralContextualType(node, typeChecker) { var type = typeChecker.getContextualType(node); @@ -136944,7 +137643,7 @@ var ts; return type; } var parent = ts.walkUpParenthesizedExpressions(node.parent); - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && node === parent.left) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && node === parent.left) { // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(parent); } @@ -136961,7 +137660,7 @@ var ts; return { isKeywordOnlyCompletion: isKeywordOnlyCompletion, keywordCompletion: keywordCompletion, - isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* TypeKeyword */), + isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* SyntaxKind.TypeKeyword */), replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined @@ -136969,23 +137668,23 @@ var ts; function getCandidate() { var parent = contextToken.parent; if (ts.isImportEqualsDeclaration(parent)) { - keywordCompletion = contextToken.kind === 152 /* TypeKeyword */ ? undefined : 152 /* TypeKeyword */; + keywordCompletion = contextToken.kind === 152 /* SyntaxKind.TypeKeyword */ ? undefined : 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; } if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) { return parent; } if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { - if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* OpenBraceToken */ || - contextToken.kind === 100 /* ImportKeyword */ || - contextToken.kind === 27 /* CommaToken */)) { - keywordCompletion = 152 /* TypeKeyword */; + if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || + contextToken.kind === 100 /* SyntaxKind.ImportKeyword */ || + contextToken.kind === 27 /* SyntaxKind.CommaToken */)) { + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; } if (canCompleteFromNamedBindings(parent)) { // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` - if (contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */) { + if (contextToken.kind === 19 /* SyntaxKind.CloseBraceToken */ || contextToken.kind === 79 /* SyntaxKind.Identifier */) { isKeywordOnlyCompletion = true; - keywordCompletion = 156 /* FromKeyword */; + keywordCompletion = 156 /* SyntaxKind.FromKeyword */; } else { return parent.parent.parent; @@ -136995,12 +137694,12 @@ var ts; } if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { // A lone import keyword with nothing following it does not parse as a statement at all - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return contextToken; } if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { // `import s| from` - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; } return undefined; @@ -137040,8 +137739,8 @@ var ts; // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings. return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker)); function nonAliasCanBeReferencedAtTypeLocation(symbol) { - return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) || - !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && + return !!(symbol.flags & 788968 /* SymbolFlags.Type */) || checker.isUnknownSymbol(symbol) || + !!(symbol.flags & 1536 /* SymbolFlags.Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); } } @@ -137078,8 +137777,8 @@ var ts; var testChar = lowercaseCharacters.charCodeAt(characterIndex); if (strChar === testChar || strChar === toUpperCharCode(testChar)) { matchedFirstCharacter || (matchedFirstCharacter = prevChar === undefined || // Beginning of word - 97 /* a */ <= prevChar && prevChar <= 122 /* z */ && 65 /* A */ <= strChar && strChar <= 90 /* Z */ || // camelCase transition - prevChar === 95 /* _ */ && strChar !== 95 /* _ */); // snake_case transition + 97 /* CharacterCodes.a */ <= prevChar && prevChar <= 122 /* CharacterCodes.z */ && 65 /* CharacterCodes.A */ <= strChar && strChar <= 90 /* CharacterCodes.Z */ || // camelCase transition + prevChar === 95 /* CharacterCodes._ */ && strChar !== 95 /* CharacterCodes._ */); // snake_case transition if (matchedFirstCharacter) { characterIndex++; } @@ -137093,7 +137792,7 @@ var ts; return false; } function toUpperCharCode(charCode) { - if (97 /* a */ <= charCode && charCode <= 122 /* z */) { + if (97 /* CharacterCodes.a */ <= charCode && charCode <= 122 /* CharacterCodes.z */) { return charCode - 32; } return charCode; @@ -137123,7 +137822,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" /* none */ + kind: "none" /* HighlightSpanKind.none */ }; } function getSemanticDocumentHighlights(position, node, program, cancellationToken, sourceFilesToSearch) { @@ -137153,46 +137852,46 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 99 /* IfKeyword */: - case 91 /* ElseKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 105 /* ReturnKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 111 /* TryKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: - var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* SyntaxKind.TryKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: + var tryStatement = node.kind === 83 /* SyntaxKind.CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 82 /* CaseKeyword */: - case 88 /* DefaultKeyword */: { + case 82 /* SyntaxKind.CaseKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 81 /* BreakKeyword */: - case 86 /* ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 97 /* ForKeyword */: - case 115 /* WhileKeyword */: - case 90 /* DoKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 134 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* ConstructorKeyword */]); - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [136 /* GetKeyword */, 149 /* SetKeyword */]); - case 132 /* AwaitKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* SyntaxKind.ConstructorKeyword */]); + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */]); + case 132 /* SyntaxKind.AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 125 /* YieldKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return undefined; default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -137235,7 +137934,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -137267,16 +137966,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 249 /* SwitchStatement */: - if (statement.kind === 245 /* ContinueStatement */) { + case 249 /* SyntaxKind.SwitchStatement */: + if (statement.kind === 245 /* SyntaxKind.ContinueStatement */) { return false; } // falls through - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -137292,41 +137991,41 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { + if (modifierFlag & 128 /* ModifierFlags.Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members, true), [declaration], false); } else { return container.statements; } - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters, true), (ts.isClassLike(container.parent) ? container.parent.members : []), true); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { + if (modifierFlag & (28 /* ModifierFlags.AccessibilityModifier */ | 64 /* ModifierFlags.Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { return __spreadArray(__spreadArray([], nodes, true), constructor.parameters, true); } } - else if (modifierFlag & 128 /* Abstract */) { + else if (modifierFlag & 128 /* ModifierFlags.Abstract */) { return __spreadArray(__spreadArray([], nodes, true), [container], false); } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -137345,12 +138044,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* SyntaxKind.ForKeyword */, 115 /* SyntaxKind.WhileKeyword */, 90 /* SyntaxKind.DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 240 /* DoStatement */) { + if (loopNode.kind === 240 /* SyntaxKind.DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* SyntaxKind.WhileKeyword */)) { break; } } @@ -137358,7 +138057,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */, 86 /* SyntaxKind.ContinueKeyword */); } }); return keywords; @@ -137367,13 +138066,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -137381,13 +138080,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SyntaxKind.SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* SyntaxKind.CaseKeyword */, 88 /* SyntaxKind.DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */); } }); }); @@ -137395,13 +138094,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* SyntaxKind.TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* SyntaxKind.CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* SyntaxKind.FinallyKeyword */); } return keywords; } @@ -137412,13 +138111,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); } return keywords; @@ -137430,11 +138129,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); return keywords; } @@ -137446,13 +138145,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 131 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 131 /* SyntaxKind.AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 132 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 132 /* SyntaxKind.AwaitKeyword */); } }); }); @@ -137467,7 +138166,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* SyntaxKind.YieldKeyword */); } }); }); @@ -137486,7 +138185,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* SyntaxKind.ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -137501,7 +138200,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ }); i++; // skip the next keyword continue; @@ -137521,10 +138220,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 99 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* SyntaxKind.IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* SyntaxKind.ElseKeyword */)) { break; } } @@ -137590,60 +138289,64 @@ var ts; } return settingsOrHost; } - function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings)); - return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); + return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions); } - function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { - return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind); + function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { + return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind, languageVersionOrOptions); } - function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings)); - return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); + return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions); } - function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { - return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); + function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { + return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind, languageVersionOrOptions); } function getDocumentRegistryEntry(bucketEntry, scriptKind) { var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided")); - ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry); + ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:".concat(scriptKind, " and sourceFile.scriptKind: ").concat(entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind, ", !entry: ").concat(!entry)); return entry; } - function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) { + function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind, languageVersionOrOptions) { var _a, _b, _c, _d; scriptKind = ts.ensureScriptKind(fileName, scriptKind); var compilationSettings = getCompilationSettings(compilationSettingsOrHost); var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost; - var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings); - var sourceFileOptions = { - languageVersion: scriptTarget, - impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), - setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings) - }; + var scriptTarget = scriptKind === 6 /* ScriptKind.JSON */ ? 100 /* ScriptTarget.JSON */ : ts.getEmitScriptTarget(compilationSettings); + var sourceFileOptions = typeof languageVersionOrOptions === "object" ? + languageVersionOrOptions : + { + languageVersion: scriptTarget, + impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), + setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings) + }; + sourceFileOptions.languageVersion = scriptTarget; var oldBucketCount = buckets.size; - var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); + var keyWithMode = getDocumentRegistryBucketKeyWithMode(key, sourceFileOptions.impliedNodeFormat); + var bucket = ts.getOrUpdate(buckets, keyWithMode, function () { return new ts.Map(); }); if (ts.tracing) { if (buckets.size > oldBucketCount) { // It is interesting, but not definitively problematic if a build requires multiple document registry buckets - // perhaps they are for two projects that don't have any overlap. // Bonus: these events can help us interpret the more interesting event below. - ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: keyWithMode }); } // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations. // If this occurs unexpectedly, the fix is likely to synchronize the project settings. // Skip .d.ts files to reduce noise (should also cover most of node_modules). var otherBucketKey = !ts.isDeclarationFileName(path) && - ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; }); + ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== keyWithMode && bucket.has(path) && bucketKey; }); if (otherBucketKey) { - ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: keyWithMode }); } } var bucketEntry = bucket.get(path); var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); if (!entry && externalCache) { - var sourceFile = externalCache.getDocument(key, path); + var sourceFile = externalCache.getDocument(keyWithMode, path); if (sourceFile) { ts.Debug.assert(acquiring); entry = { @@ -137657,7 +138360,7 @@ var ts; // Have never seen this file with these settings. Create a new source file for it. var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind); if (externalCache) { - externalCache.setDocument(key, path, sourceFile); + externalCache.setDocument(keyWithMode, path, sourceFile); } entry = { sourceFile: sourceFile, @@ -137672,7 +138375,7 @@ var ts; if (entry.sourceFile.version !== version) { entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217 if (externalCache) { - externalCache.setDocument(key, path, entry.sourceFile); + externalCache.setDocument(keyWithMode, path, entry.sourceFile); } } // If we're acquiring, then this is the first time this LS is asking for this document. @@ -137701,13 +138404,13 @@ var ts; } } } - function releaseDocument(fileName, compilationSettings, scriptKind) { + function releaseDocument(fileName, compilationSettings, scriptKind, impliedNodeFormat) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(compilationSettings); - return releaseDocumentWithKey(path, key, scriptKind); + return releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat); } - function releaseDocumentWithKey(path, key, scriptKind) { - var bucket = ts.Debug.checkDefined(buckets.get(key)); + function releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat) { + var bucket = ts.Debug.checkDefined(buckets.get(getDocumentRegistryBucketKeyWithMode(key, impliedNodeFormat))); var bucketEntry = bucket.get(path); var entry = getDocumentRegistryEntry(bucketEntry, scriptKind); entry.languageServiceRefCount--; @@ -137751,18 +138454,21 @@ var ts; return "" + value; } if (ts.isArray(value)) { - return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]"; + return "[".concat((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(","), "]"); } var str = "{"; for (var key in value) { if (ts.hasProperty(value, key)) { - str += key + ": " + compilerOptionValueToString(value[key]); + str += "".concat(key, ": ").concat(compilerOptionValueToString(value[key])); } } return str + "}"; } function getKeyForCompilationSettings(settings) { - return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined); + return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|".concat(settings.pathsBasePath) : undefined); + } + function getDocumentRegistryBucketKeyWithMode(key, mode) { + return (mode ? "".concat(key, "|").concat(mode) : key); } })(ts || (ts = {})); /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ @@ -137829,43 +138535,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 254 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { var name = parent.name; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { directImports.push(name); break; } } } break; - case 79 /* Identifier */: // for 'const x = require("y"); + case 79 /* SyntaxKind.Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 265 /* ImportEqualsDeclaration */: - handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* ModifierFlags.Export */), /*alreadyAddedDirect*/ false); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); } - else if (direct.exportClause.kind === 274 /* NamespaceExport */) { + else if (direct.exportClause.kind === 274 /* SyntaxKind.NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -137874,7 +138580,7 @@ var ts; directImports.push(direct); } break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -137900,14 +138606,14 @@ var ts; }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { - if (exportKind === 2 /* ExportEquals */) { + if (exportKind === 2 /* ExportKind.ExportEquals */) { // This is a direct import, not import-as-namespace. if (!alreadyAddedDirect) directImports.push(importDeclaration); } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 305 /* SourceFile */ || sourceFileLike.kind === 261 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ || sourceFileLike.kind === 261 /* SyntaxKind.ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -137929,7 +138635,7 @@ var ts; var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); if (!moduleSymbol) return; - ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */)); var directImports = getDirectImports(moduleSymbol); if (directImports) { for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { @@ -137963,33 +138669,33 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 265 /* ImportEqualsDeclaration */) { + if (decl.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 79 /* Identifier */) { + if (decl.kind === 79 /* SyntaxKind.Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 200 /* ImportType */) { + if (decl.kind === 200 /* SyntaxKind.ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(firstIdentifier); } } - else if (exportKind === 2 /* ExportEquals */) { + else if (exportKind === 2 /* ExportKind.ExportEquals */) { singleReferences.push(decl.argument.literal); } return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* SyntaxKind.StringLiteral */) { return; } - if (decl.kind === 272 /* ExportDeclaration */) { + if (decl.kind === 272 /* SyntaxKind.ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -137998,12 +138704,12 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. - if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { + if (exportKind === 0 /* ExportKind.Named */ || exportKind === 1 /* ExportKind.Default */) { searchForNamedImport(namedBindings); } break; @@ -138014,7 +138720,7 @@ var ts; // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals. // If a default import has the same name as the default export, allow to rename it. // Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that. - if (name && (exportKind === 1 /* Default */ || exportKind === 2 /* ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { + if (name && (exportKind === 1 /* ExportKind.Default */ || exportKind === 2 /* ExportKind.ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { var defaultImportAlias = checker.getSymbolAtLocation(name); addSearch(name, defaultImportAlias); } @@ -138026,7 +138732,7 @@ var ts; */ function handleNamespaceImportLike(importName) { // Don't rename an import that already has a different name than the export. - if (exportKind === 2 /* ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } @@ -138051,7 +138757,7 @@ var ts; } } else { - var localSymbol = element.kind === 275 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 275 /* SyntaxKind.ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -138060,7 +138766,7 @@ var ts; } function isNameMatch(name) { // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports - return name === exportSymbol.escapedName || exportKind !== 0 /* Named */ && name === "default" /* Default */; + return name === exportSymbol.escapedName || exportKind !== 0 /* ExportKind.Named */ && name === "default" /* InternalSymbolName.Default */; } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ @@ -138080,7 +138786,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SyntaxKind.SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -138128,7 +138834,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 305 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -138143,15 +138849,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -138176,7 +138882,7 @@ var ts; var parent = node.parent; var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 206 /* PropertyAccessExpression */) { + if (parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) @@ -138189,21 +138895,21 @@ var ts; } else { var exportNode = getExportNode(parent, node); - if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* Export */)) { + if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* ModifierFlags.Export */)) { if (ts.isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) { // We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement. if (comingFromExport) { return undefined; } var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); - return { kind: 0 /* Import */, symbol: lhsSymbol }; + return { kind: 0 /* ImportExport.Import */, symbol: lhsSymbol }; } else { return exportInfo(symbol, getExportKindForDeclaration(exportNode)); } } else if (ts.isNamespaceExport(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } // If we are in `export = a;` or `export default a;`, `parent` is the export assignment. else if (ts.isExportAssignment(parent)) { @@ -138221,24 +138927,24 @@ var ts; return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. if (!ex.symbol.parent) return undefined; - var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; + var exportKind = ex.isExportEquals ? 2 /* ExportKind.ExportEquals */ : 1 /* ExportKind.Default */; + return { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; switch (ts.getAssignmentDeclarationKind(node)) { - case 1 /* ExportsProperty */: - kind = 0 /* Named */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + kind = 0 /* ExportKind.Named */; break; - case 2 /* ModuleExports */: - kind = 2 /* ExportEquals */; + case 2 /* AssignmentDeclarationKind.ModuleExports */: + kind = 2 /* ExportKind.ExportEquals */; break; default: return undefined; @@ -138265,22 +138971,22 @@ var ts; // If `importedName` is undefined, do continue searching as the export is anonymous. // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) var importedName = ts.symbolEscapedNameNoDefault(importedSymbol); - if (importedName === undefined || importedName === "default" /* Default */ || importedName === symbol.escapedName) { - return { kind: 0 /* Import */, symbol: importedSymbol }; + if (importedName === undefined || importedName === "default" /* InternalSymbolName.Default */ || importedName === symbol.escapedName) { + return { kind: 0 /* ImportExport.Import */, symbol: importedSymbol }; } } function exportInfo(symbol, kind) { var exportInfo = getExportInfo(symbol, kind, checker); - return exportInfo && { kind: 1 /* Export */, symbol: symbol, exportInfo: exportInfo }; + return exportInfo && { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: exportInfo }; } // Not meant for use with export specifiers or export assignment. function getExportKindForDeclaration(node) { - return ts.hasSyntacticModifier(node, 512 /* Default */) ? 1 /* Default */ : 0 /* Named */; + return ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; } } FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; function getExportEqualsLocalSymbol(importedSymbol, checker) { - if (importedSymbol.flags & 2097152 /* Alias */) { + if (importedSymbol.flags & 2097152 /* SymbolFlags.Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); @@ -138310,16 +139016,16 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent); default: return false; @@ -138349,7 +139055,7 @@ var ts; } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) - && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) { + && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) { return checker.getExportSpecifierLocalTargetSymbol(declaration.name); } } @@ -138360,21 +139066,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 305 /* SourceFile */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 262 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 262 /* SyntaxKind.ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 277 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* SyntaxKind.StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -138401,7 +139107,7 @@ var ts; EntryKind[EntryKind["SearchedPropertyFoundLocal"] = 4] = "SearchedPropertyFoundLocal"; })(EntryKind = FindAllReferences.EntryKind || (FindAllReferences.EntryKind = {})); function nodeEntry(node, kind) { - if (kind === void 0) { kind = 1 /* Node */; } + if (kind === void 0) { kind = 1 /* EntryKind.Node */; } return { kind: kind, node: node.name || node, @@ -138429,7 +139135,7 @@ var ts; node.parent.parent.left === node.parent ? node.parent.parent : undefined; - if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* None */) { + if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* AssignmentDeclarationKind.None */) { return getContextNode(binaryExpression); } } @@ -138468,7 +139174,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ModifierFlags.ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -138477,7 +139183,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -138485,28 +139191,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextNode(node.parent.parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 267 /* ImportClause */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return { start: node.initializer, end: node.expression }; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -138547,7 +139253,7 @@ var ts; })(FindReferencesUse = FindAllReferences.FindReferencesUse || (FindAllReferences.FindReferencesUse = {})); function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); - var options = { use: 1 /* References */ }; + var options = { use: 1 /* FindReferencesUse.References */ }; var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options); var checker = program.getTypeChecker(); // Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition @@ -138564,33 +139270,33 @@ var ts; } FindAllReferences.findReferencedSymbols = findReferencedSymbols; function isDefinitionForReference(node) { - return node.kind === 88 /* DefaultKeyword */ + return node.kind === 88 /* SyntaxKind.DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 206 /* PropertyAccessExpression */ - || node.parent.kind === 203 /* BindingElement */ - || node.parent.kind === 207 /* ElementAccessExpression */ - || node.kind === 106 /* SuperKeyword */) { + if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || node.parent.kind === 203 /* SyntaxKind.BindingElement */ + || node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries, true); } - else { - var queue = entries && __spreadArray([], entries, true); + else if (entries) { + var queue = ts.createQueue(entries); var seenNodes = new ts.Map(); - while (queue && queue.length) { - var entry = queue.shift(); + while (!queue.isEmpty()) { + var entry = queue.dequeue(); if (!ts.addToSeen(seenNodes, ts.getNodeId(entry.node))) { continue; } referenceEntries = ts.append(referenceEntries, entry); var entries_1 = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, entry.node, entry.node.pos); if (entries_1) { - queue.push.apply(queue, entries_1); + queue.enqueue.apply(queue, entries_1); } } } @@ -138599,18 +139305,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var result_2 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); }); return result_2; } - else if (node.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -138618,7 +139324,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* References */ }); + return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* FindReferencesUse.References */ }); } } function findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, convertEntry) { @@ -138637,7 +139343,7 @@ var ts; function definitionToReferencedSymbolDefinitionInfo(def, checker, originalNode) { var info = (function () { switch (def.type) { - case 0 /* Symbol */: { + case 0 /* DefinitionKind.Symbol */: { var symbol = def.symbol; var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind; var name_1 = displayParts_1.map(function (p) { return p.text; }).join(""); @@ -138645,32 +139351,32 @@ var ts; var node = declaration ? (ts.getNameOfDeclaration(declaration) || declaration) : originalNode; return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_1, kind: kind_1, displayParts: displayParts_1, context: getContextNode(declaration) }); } - case 1 /* Label */: { + case 1 /* DefinitionKind.Label */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* ScriptElementKind.label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); } - case 2 /* Keyword */: { + case 2 /* DefinitionKind.Keyword */: { var node = def.node; var name_2 = ts.tokenToString(node.kind); - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* keyword */, displayParts: [{ text: name_2, kind: "keyword" /* keyword */ }] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* ScriptElementKind.keyword */, displayParts: [{ text: name_2, kind: "keyword" /* ScriptElementKind.keyword */ }] }); } - case 3 /* This */: { + case 3 /* DefinitionKind.This */: { var node = def.node; var symbol = checker.getSymbolAtLocation(node); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node).displayParts || [ts.textPart("this")]; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* variableElement */, displayParts: displayParts_2 }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* ScriptElementKind.variableElement */, displayParts: displayParts_2 }); } - case 4 /* String */: { + case 4 /* DefinitionKind.String */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* ScriptElementKind.variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); } - case 5 /* TripleSlashReference */: { + case 5 /* DefinitionKind.TripleSlashReference */: { return { textSpan: ts.createTextSpanFromRange(def.reference), sourceFile: def.file, name: def.reference.fileName, - kind: "string" /* string */, - displayParts: [ts.displayPart("\"" + def.reference.fileName + "\"", ts.SymbolDisplayPartKind.stringLiteral)] + kind: "string" /* ScriptElementKind.string */, + displayParts: [ts.displayPart("\"".concat(def.reference.fileName, "\""), ts.SymbolDisplayPartKind.stringLiteral)] }; } default: @@ -138678,7 +139384,7 @@ var ts; } })(); var sourceFile = info.sourceFile, textSpan = info.textSpan, name = info.name, kind = info.kind, displayParts = info.displayParts, context = info.context; - return __assign({ containerKind: "" /* unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); + return __assign({ containerKind: "" /* ScriptElementKind.unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); } function getFileAndTextSpanFromNode(node) { var sourceFile = node.getSourceFile(); @@ -138701,19 +139407,19 @@ var ts; var referenceEntry = toReferenceEntry(entry); if (!symbol) return referenceEntry; - return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) }); + return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* EntryKind.Span */ && isDeclarationOfSymbol(entry.node, symbol) }); } function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return __assign(__assign({}, documentSpan), { isWriteAccess: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }); } FindAllReferences.toReferenceEntry = toReferenceEntry; function entryToDocumentSpan(entry) { - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { textSpan: entry.textSpan, fileName: entry.fileName }; } else { @@ -138723,7 +139429,7 @@ var ts; } } function getPrefixAndSuffixText(entry, originalNode, checker) { - if (entry.kind !== 0 /* Span */ && ts.isIdentifier(originalNode)) { + if (entry.kind !== 0 /* EntryKind.Span */ && ts.isIdentifier(originalNode)) { var node = entry.node, kind = entry.kind; var parent = node.parent; var name = originalNode.text; @@ -138731,10 +139437,10 @@ var ts; if (isShorthandAssignment || (ts.isObjectBindingElementWithoutPropertyName(parent) && parent.name === node && parent.dotDotDotToken === undefined)) { var prefixColon = { prefixText: name + ": " }; var suffixColon = { suffixText: ": " + name }; - if (kind === 3 /* SearchedLocalFoundProperty */) { + if (kind === 3 /* EntryKind.SearchedLocalFoundProperty */) { return prefixColon; } - if (kind === 4 /* SearchedPropertyFoundLocal */) { + if (kind === 4 /* EntryKind.SearchedPropertyFoundLocal */) { return suffixColon; } // In `const o = { x }; o.x`, symbolAtLocation at `x` in `{ x }` is the property symbol. @@ -138768,12 +139474,12 @@ var ts; } function toImplementationLocation(entry, checker) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind !== 0 /* Span */) { + if (entry.kind !== 0 /* EntryKind.Span */) { var node = entry.node; return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* ScriptElementKind.unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -138781,16 +139487,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return { - kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "interface" /* ScriptElementKind.interfaceElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } - else if (node.kind === 226 /* ClassExpression */) { + else if (node.kind === 226 /* SyntaxKind.ClassExpression */) { return { - kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "local class" /* ScriptElementKind.localClassElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } else { @@ -138799,17 +139505,17 @@ var ts; } function toHighlightSpan(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { fileName: documentSpan.fileName, span: { textSpan: documentSpan.textSpan, - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ } }; } var writeAccess = isWriteAccessForReference(entry.node); - var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, isInString: entry.kind === 2 /* StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); + var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* HighlightSpanKind.writtenReference */ : "reference" /* HighlightSpanKind.reference */, isInString: entry.kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); return { fileName: documentSpan.fileName, span: span }; } FindAllReferences.toHighlightSpan = toHighlightSpan; @@ -138824,14 +139530,14 @@ var ts; return ts.createTextSpanFromBounds(start, end); } function getTextSpanOfEntry(entry) { - return entry.kind === 0 /* Span */ ? entry.textSpan : + return entry.kind === 0 /* EntryKind.Span */ ? entry.textSpan : getTextSpan(entry.node, entry.node.getSourceFile()); } FindAllReferences.getTextSpanOfEntry = getTextSpanOfEntry; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* SyntaxKind.DefaultKeyword */ || ts.isWriteAccess(node); } /** Whether a reference, `node`, is a definition of the `target` symbol */ function isDeclarationOfSymbol(node, target) { @@ -138839,9 +139545,9 @@ var ts; if (!target) return false; var source = ts.getDeclarationFromName(node) || - (node.kind === 88 /* DefaultKeyword */ ? node.parent + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ ? node.parent : ts.isLiteralComputedPropertyDeclarationName(node) ? node.parent.parent - : node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent + : node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent : undefined); var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined; return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; }))); @@ -138853,50 +139559,50 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 16777216 /* Ambient */)) + if (!!(decl.flags & 16777216 /* NodeFlags.Ambient */)) return true; switch (decl.kind) { - case 221 /* BinaryExpression */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 88 /* DefaultKeyword */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 275 /* ExportSpecifier */: - case 267 /* ImportClause */: // default import - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 258 /* InterfaceDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 285 /* JsxAttribute */: - case 261 /* ModuleDeclaration */: - case 264 /* NamespaceExportDeclaration */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - case 164 /* Parameter */: - case 297 /* ShorthandPropertyAssignment */: - case 259 /* TypeAliasDeclaration */: - case 163 /* TypeParameter */: + case 221 /* SyntaxKind.BinaryExpression */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: // default import + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 285 /* SyntaxKind.JsxAttribute */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + case 164 /* SyntaxKind.Parameter */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return !!decl.body; - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 168 /* MethodSignature */: - case 166 /* PropertySignature */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 168 /* SyntaxKind.MethodSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -138925,7 +139631,7 @@ var ts; return undefined; } return [{ - definition: { type: 5 /* TripleSlashReference */, reference: resolvedRef.reference, file: node }, + definition: { type: 5 /* DefinitionKind.TripleSlashReference */, reference: resolvedRef.reference, file: node }, references: getReferencesForNonModule(resolvedRef.file, fileIncludeReasons, program) || ts.emptyArray }]; } @@ -138947,7 +139653,7 @@ var ts; var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { - return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; + return [{ definition: { type: 4 /* DefinitionKind.String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; } // Fall through to string literal references. This is not very likely to return // anything useful, but I guess it's better than nothing, and there's an existing @@ -138957,11 +139663,11 @@ var ts; } return undefined; } - if (symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); } var moduleReferences = getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet); - if (moduleReferences && !(symbol.flags & 33554432 /* Transient */)) { + if (moduleReferences && !(symbol.flags & 33554432 /* SymbolFlags.Transient */)) { return moduleReferences; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(node, symbol, checker); @@ -138972,10 +139678,10 @@ var ts; } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function getAdjustedNode(node, options) { - if (options.use === 1 /* References */) { + if (options.use === 1 /* FindReferencesUse.References */) { node = ts.getAdjustedReferenceLocation(node); } - else if (options.use === 2 /* Rename */) { + else if (options.use === 2 /* FindReferencesUse.Rename */) { node = ts.getAdjustedRenameLocation(node); } return node; @@ -139003,7 +139709,7 @@ var ts; var location = ts.getReferencedFileLocation(program.getSourceFileByPath, ref); if (ts.isReferenceFileLocation(location)) { entries = ts.append(entries, { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: referencingFile.fileName, textSpan: ts.createTextSpanFromRange(location) }); @@ -139023,10 +139729,10 @@ var ts; return undefined; } function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet) { - var moduleSourceFile = (symbol.flags & 1536 /* Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); + var moduleSourceFile = (symbol.flags & 1536 /* SymbolFlags.Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; - var exportEquals = symbol.exports.get("export=" /* ExportEquals */); + var exportEquals = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. var moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) @@ -139053,14 +139759,14 @@ var ts; result = references; continue; } - var _loop_4 = function (entry) { - if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { + var _loop_3 = function (entry) { + if (!entry.definition || entry.definition.type !== 0 /* DefinitionKind.Symbol */) { result.push(entry); return "continue"; } var symbol = entry.definition.symbol; var refIndex = ts.findIndex(result, function (ref) { return !!ref.definition && - ref.definition.type === 0 /* Symbol */ && + ref.definition.type === 0 /* DefinitionKind.Symbol */ && ref.definition.symbol === symbol; }); if (refIndex === -1) { result.push(entry); @@ -139085,13 +139791,13 @@ var ts; }; for (var _b = 0, references_2 = references; _b < references_2.length; _b++) { var entry = references_2[_b]; - _loop_4(entry); + _loop_3(entry); } } return result; } function getSourceFileIndexOfEntry(program, entry) { - var sourceFile = entry.kind === 0 /* Span */ ? + var sourceFile = entry.kind === 0 /* EntryKind.Span */ ? program.getSourceFile(entry.fileName) : entry.node.getSourceFile(); return program.getSourceFiles().indexOf(sourceFile); @@ -139112,7 +139818,7 @@ var ts; } else { return { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: reference.referencingFile.fileName, textSpan: ts.createTextSpanFromRange(reference.ref), }; @@ -139122,21 +139828,21 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } break; default: // This may be merged with something. - ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); + ts.Debug.assert(!!(symbol.flags & 33554432 /* SymbolFlags.Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } } - var exported = symbol.exports.get("export=" /* ExportEquals */); + var exported = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exported === null || exported === void 0 ? void 0 : exported.declarations) { for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -139144,41 +139850,41 @@ var ts; if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : - ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* SyntaxKind.ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } } } - return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; + return references.length ? [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 145 /* ReadonlyKeyword */ + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 145 /* ReadonlyKeyword */; + && node.parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A void expression (i.e., `void foo()`) is not special, but the `void` type is. - if (node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(node.parent)) { return undefined; } // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 145 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } if (ts.isImportMeta(node.parent) && node.parent.name === node) { return getAllReferencesForImportMeta(sourceFiles, cancellationToken); } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { - return [{ definition: { type: 2 /* Keyword */, node: node }, references: [nodeEntry(node)] }]; + return [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: node }, references: [nodeEntry(node)] }]; } // Labels if (ts.isJumpStatementTarget(node)) { @@ -139194,7 +139900,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -139203,20 +139909,20 @@ var ts; function getReferencedSymbolsForSymbol(originalSymbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options) { var symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, /*useLocalSymbolForExportSpecifier*/ !isForRenameWithPrefixAndSuffixText(options)) || originalSymbol; // Compute the meaning from the location and the symbol it references - var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; + var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* SemanticMeaning.All */; var result = []; - var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); + var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* SpecialSearchKind.None */, checker, cancellationToken, searchMeaning, options, result); var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) || !symbol.declarations ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); if (exportSpecifier) { // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { + else if (node && node.kind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.escapedName === "default" /* InternalSymbolName.Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* ExportKind.Default */ }, state); } else { - var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* FindReferencesUse.Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); getReferencesInContainerOrFiles(symbol, state, search); } return result; @@ -139239,17 +139945,17 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 171 /* Constructor */: - case 134 /* ConstructorKeyword */: - return 1 /* Constructor */; - case 79 /* Identifier */: + case 171 /* SyntaxKind.Constructor */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return 1 /* SpecialSearchKind.Constructor */; + case 79 /* SyntaxKind.Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); - return 2 /* Class */; + return 2 /* SpecialSearchKind.Class */; } // falls through default: - return 0 /* None */; + return 0 /* SpecialSearchKind.None */; } } /** Handle a few special cases relating to export/import specifiers. */ @@ -139262,10 +139968,10 @@ var ts; return ts.firstDefined(symbol.declarations, function (decl) { if (!decl.parent) { // Ignore UMD module and global merge - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return undefined; // Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here. - ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol)); + ts.Debug.fail("Unexpected symbol at ".concat(ts.Debug.formatSyntaxKind(node.kind), ": ").concat(ts.Debug.formatSymbol(symbol))); } return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent) ? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name) @@ -139279,7 +139985,7 @@ var ts; SpecialSearchKind[SpecialSearchKind["Class"] = 2] = "Class"; })(SpecialSearchKind || (SpecialSearchKind = {})); function getNonModuleSymbolOfMergedModuleSymbol(symbol) { - if (!(symbol.flags & (1536 /* Module */ | 33554432 /* Transient */))) + if (!(symbol.flags & (1536 /* SymbolFlags.Module */ | 33554432 /* SymbolFlags.Transient */))) return undefined; var decl = symbol.declarations && ts.find(symbol.declarations, function (d) { return !ts.isSourceFile(d) && !ts.isModuleDeclaration(d); }); return decl && decl.symbol; @@ -139331,7 +140037,7 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* Rename */); + return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* FindReferencesUse.Rename */); }; /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { @@ -139354,7 +140060,7 @@ var ts; var references = this.symbolIdToReferences[symbolId]; if (!references) { references = this.symbolIdToReferences[symbolId] = []; - this.result.push({ definition: { type: 0 /* Symbol */, symbol: searchSymbol }, references: references }); + this.result.push({ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSymbol }, references: references }); } return function (node, kind) { return references.push(nodeEntry(node, kind)); }; }; @@ -139362,7 +140068,7 @@ var ts; State.prototype.addStringOrCommentReference = function (fileName, textSpan) { this.result.push({ definition: undefined, - references: [{ kind: 0 /* Span */, fileName: fileName, textSpan: textSpan }] + references: [{ kind: 0 /* EntryKind.Span */, fileName: fileName, textSpan: textSpan }] }); }; /** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */ @@ -139393,19 +140099,19 @@ var ts; // For each import, find all references to that import in its source file. for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; - getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* Export */), state); + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* ImportExport.Export */), state); } if (indirectUsers.length) { var indirectSearch = void 0; switch (exportInfo.exportKind) { - case 0 /* Named */: - indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* Export */); + case 0 /* ExportKind.Named */: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */); break; - case 1 /* Default */: + case 1 /* ExportKind.Default */: // Search for a property access to '.default'. This can't be renamed. - indirectSearch = state.options.use === 2 /* Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* Export */, { text: "default" }); + indirectSearch = state.options.use === 2 /* FindReferencesUse.Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */, { text: "default" }); break; - case 2 /* ExportEquals */: + case 2 /* ExportKind.ExportEquals */: break; } if (indirectSearch) { @@ -139418,7 +140124,7 @@ var ts; } function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken); - var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { var importLocation = importSearches_2[_i][0]; cb(importLocation); @@ -139446,13 +140152,13 @@ var ts; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; - if (state.options.use !== 2 /* Rename */) + if (state.options.use !== 2 /* FindReferencesUse.Rename */) return true; // Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;` if (!ts.isIdentifier(singleRef)) return false; // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename. - return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* Default */); + return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* InternalSymbolName.Default */); } // Go to the symbol we imported from and find references for it. function searchForImportedSymbol(symbol, state) { @@ -139462,7 +140168,7 @@ var ts; var declaration = _a[_i]; var exportingFile = declaration.getSourceFile(); // Need to search in the file even if it's not in the search-file set, because it might export the symbol. - getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* Import */), state, state.includesSourceFile(exportingFile)); + getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* ImportExport.Import */), state, state.includesSourceFile(exportingFile)); } } /** Search for all occurrences of an identifier in a source file (and filter out the ones that match). */ @@ -139488,17 +140194,17 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 213 /* FunctionExpression */ || valueDeclaration.kind === 226 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 213 /* SyntaxKind.FunctionExpression */ || valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */)) { return valueDeclaration; } if (!declarations) { return undefined; } // If this is private property or method, the scope is the containing class - if (flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); + if (flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)) { + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 257 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 257 /* SyntaxKind.ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -139515,7 +140221,7 @@ var ts; - The parent is an external module: then we should only search in the module (and recurse on the export later). - But if the parent has `export as namespace`, the symbol is globally visible through that namespace. */ - var exposedByParent = parent && !(symbol.flags & 262144 /* TypeParameter */); + var exposedByParent = parent && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */); if (exposedByParent && !(ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { return undefined; } @@ -139527,7 +140233,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -139646,8 +140352,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* ScriptTarget.Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* ScriptTarget.Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -139662,27 +140368,27 @@ var ts; // Only pick labels that are either the target label, or have a target that is the target label return node === targetLabel || (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel) ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 1 /* Label */, node: targetLabel }, references: references }]; + return [{ definition: { type: 1 /* DefinitionKind.Label */, node: targetLabel }, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: if (ts.isJSDocMemberName(node.parent)) { return true; } // falls through I guess - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.text.length === searchSymbolName.length; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && str.text.length === searchSymbolName.length; } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -139698,7 +140404,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { @@ -139709,7 +140415,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getReferencesInSourceFile(sourceFile, search, state, addReferencesHere) { if (addReferencesHere === void 0) { addReferencesHere = true; } @@ -139760,7 +140466,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* SyntaxKind.Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -139770,14 +140476,14 @@ var ts; return; } switch (state.specialSearchKind) { - case 0 /* None */: + case 0 /* SpecialSearchKind.None */: if (addReferencesHere) addReference(referenceLocation, relatedSymbol, state); break; - case 1 /* Constructor */: + case 1 /* SpecialSearchKind.Constructor */: addConstructorReferences(referenceLocation, sourceFile, search, state); break; - case 2 /* Class */: + case 2 /* SpecialSearchKind.Class */: addClassStaticThisReferences(referenceLocation, search, state); break; default: @@ -139785,7 +140491,7 @@ var ts; } // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) - && referenceLocation.parent.kind === 203 /* BindingElement */ + && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In @@ -139805,7 +140511,7 @@ var ts; } if (!propertyName) { // Don't rename at `export { default } from "m";`. (but do continue to search for imports of the re-export) - if (!(state.options.use === 2 /* Rename */ && (name.escapedText === "default" /* Default */))) { + if (!(state.options.use === 2 /* FindReferencesUse.Rename */ && (name.escapedText === "default" /* InternalSymbolName.Default */))) { addRef(); } } @@ -139815,7 +140521,7 @@ var ts; if (!exportDeclaration.moduleSpecifier) { addRef(); } - if (addReferencesHere && state.options.use !== 2 /* Rename */ && state.markSeenReExportRHS(name)) { + if (addReferencesHere && state.options.use !== 2 /* FindReferencesUse.Rename */ && state.markSeenReExportRHS(name)) { addReference(name, ts.Debug.checkDefined(exportSpecifier.symbol), state); } } @@ -139826,9 +140532,9 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; - var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */; + var exportKind = isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); if (exportInfo) { @@ -139836,7 +140542,7 @@ var ts; } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. - if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { + if (search.comingFrom !== 1 /* ImportExport.Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { var imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (imported) searchForImportedSymbol(imported, state); @@ -139863,11 +140569,11 @@ var ts; } } function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { - var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* Export */); + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* ImportExport.Export */); if (!importOrExport) return; var symbol = importOrExport.symbol; - if (importOrExport.kind === 0 /* Import */) { + if (importOrExport.kind === 0 /* ImportExport.Import */) { if (!(isForRenameWithPrefixAndSuffixText(state.options))) { searchForImportedSymbol(symbol, state); } @@ -139887,14 +140593,14 @@ var ts; * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the * position of property accessing, the referenceEntry of such position will be handled in the first case. */ - if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + if (!(flags & 33554432 /* SymbolFlags.Transient */) && name && search.includes(shorthandValueSymbol)) { addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator // if rename symbol from default export anonymous function, for example `export default function() {}`, we do not need to add reference - if (state.options.use === 2 /* Rename */ && referenceLocation.kind === 88 /* DefaultKeyword */) { + if (state.options.use === 2 /* FindReferencesUse.Rename */ && referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */) { return; } var addRef = state.referenceAdder(symbol); @@ -139912,7 +140618,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -139928,7 +140634,7 @@ var ts; function addClassStaticThisReferences(referenceLocation, search, state) { addReference(referenceLocation, search.symbol, state); var classLike = referenceLocation.parent; - if (state.options.use === 2 /* Rename */ || !ts.isClassLike(classLike)) + if (state.options.use === 2 /* FindReferencesUse.Rename */ || !ts.isClassLike(classLike)) return; ts.Debug.assert(classLike.name === referenceLocation); var addRef = state.referenceAdder(search.symbol); @@ -139939,7 +140645,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 108 /* ThisKeyword */) { + if (node.kind === 108 /* SyntaxKind.ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -139958,18 +140664,18 @@ var ts; if (constructorSymbol && constructorSymbol.declarations) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 134 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 171 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 169 /* MethodDeclaration */) { + if (decl && decl.kind === 169 /* SyntaxKind.MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* SyntaxKind.ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -139980,7 +140686,7 @@ var ts; } } function getClassConstructorSymbol(classSymbol) { - return classSymbol.members && classSymbol.members.get("__constructor" /* Constructor */); + return classSymbol.members && classSymbol.members.get("__constructor" /* InternalSymbolName.Constructor */); } /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(classDeclaration, addNode) { @@ -139990,10 +140696,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 171 /* Constructor */); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SyntaxKind.SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -140017,10 +140723,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 79 /* Identifier */) { + if (refNode.kind !== 79 /* SyntaxKind.Identifier */) { return; } - if (refNode.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -140040,7 +140746,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 235 /* Block */) { + if (body.kind === 235 /* SyntaxKind.Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -140068,13 +140774,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 204 /* ArrayLiteralExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; default: return false; @@ -140125,15 +140831,15 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -140142,7 +140848,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 106 /* SuperKeyword */) { + if (node.kind !== 106 /* SyntaxKind.SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -140151,46 +140857,46 @@ var ts; // and has the same static qualifier as the original 'super's owner. return container && ts.isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; + return [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 79 /* Identifier */ && node.parent.kind === 164 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 164 /* SyntaxKind.Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 305 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -140198,26 +140904,26 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 205 /* ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // Make sure the container belongs to the same class/object literals // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag; - case 305 /* SourceFile */: - return container.kind === 305 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 305 /* SyntaxKind.SourceFile */: + return container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); var thisParameter = ts.firstDefined(references, function (r) { return ts.isParameter(r.node.parent) ? r.node : undefined; }); return [{ - definition: { type: 3 /* This */, node: thisParameter || thisOrSuperKeyword }, + definition: { type: 3 /* DefinitionKind.This */, node: thisParameter || thisOrSuperKeyword }, references: references }]; } @@ -140230,18 +140936,18 @@ var ts; if (type) { var refType = ts.getContextualTypeFromParentOrAncestorTypeNode(ref, checker); if (type !== checker.getStringType() && type === refType) { - return nodeEntry(ref, 2 /* StringLiteral */); + return nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } else { return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined : - nodeEntry(ref, 2 /* StringLiteral */); + nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } }); }); return [{ - definition: { type: 4 /* String */, node: node }, + definition: { type: 4 /* DefinitionKind.String */, node: node }, references: references }]; } @@ -140286,30 +140992,30 @@ var ts; var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); // gets the local symbol if (shorthandValueSymbol && isForRenamePopulateSearchSymbolSet) { // When renaming 'x' in `const o = { x }`, just rename the local variable, not the property. - return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); } // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set var contextualType = checker.getContextualType(containingObjectLiteralElement.parent); - var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* SearchedPropertyFoundLocal */); }); + var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* EntryKind.SearchedPropertyFoundLocal */); }); if (res_1) return res_1; // If the location is name of property symbol from object literal destructuring pattern // Search the property symbol // for ( { property: p2 } of elems) { } var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); - var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* SearchedPropertyFoundLocal */); + var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* EntryKind.SearchedPropertyFoundLocal */); if (res1) return res1; - var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); if (res2) return res2; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(location, symbol, checker); if (aliasedSymbol) { // In case of UMD module and global merging, search for global as well - var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_2) return res_2; } @@ -140319,14 +141025,14 @@ var ts; if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); - ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] - return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); + ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* SymbolFlags.FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* SymbolFlags.Property */)); // is [parameter, property] + return fromRoot(symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { - var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_3) return res_3; } @@ -140341,7 +141047,7 @@ var ts; else { bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); } - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } ts.Debug.assert(isForRenamePopulateSearchSymbolSet); // due to the above assert and the arguments at the uses of this function, @@ -140349,7 +141055,7 @@ var ts; var includeOriginalSymbolOfBindingElement = onlyIncludeBindingElementAtReferenceLocation; if (includeOriginalSymbolOfBindingElement) { var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } function fromRoot(sym, kind) { // If this is a union property: @@ -140361,13 +141067,13 @@ var ts; return ts.firstDefined(checker.getRootSymbols(sym), function (rootSymbol) { return cbSymbol(sym, rootSymbol, /*baseSymbol*/ undefined, kind) // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol) + || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) && allowBaseTypes(rootSymbol) ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base, kind); }) : undefined); }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* SyntaxKind.BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -140389,7 +141095,7 @@ var ts; // interface C extends C { // /*findRef*/propName: string; // } - if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + if (!(symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) return; return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { var type = checker.getTypeAtLocation(typeReference); @@ -140403,12 +141109,12 @@ var ts; if (!symbol.valueDeclaration) return false; var modifierFlags = ts.getEffectiveModifierFlags(symbol.valueDeclaration); - return !!(modifierFlags & 32 /* Static */); + return !!(modifierFlags & 32 /* ModifierFlags.Static */); } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, /*isForRenamePopulateSearchSymbolSet*/ false, - /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { + /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* FindReferencesUse.Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { // check whether the symbol used to search itself is just the searched one. if (baseSymbol) { // static method/property and instance method/property might have the same name. Only check static or only check instance. @@ -140418,7 +141124,7 @@ var ts; } return search.includes(baseSymbol || rootSymbol || sym) // For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol. - ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* Synthetic */) ? rootSymbol : sym, kind: kind } + ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* CheckFlags.Synthetic */) ? rootSymbol : sym, kind: kind } : undefined; }, /*allowBaseTypes*/ function (rootSymbol) { @@ -140458,7 +141164,7 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : (ts.isVariableLike(node) ? ts.hasInitializer(node) : ts.isFunctionLikeDeclaration(node) ? !!node.body : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); @@ -140469,7 +141175,7 @@ var ts; if (shorthandSymbol) { for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { + if (ts.getMeaningFromDeclaration(declaration) & 1 /* SemanticMeaning.Value */) { addReference(declaration); } } @@ -140498,12 +141204,12 @@ var ts; var propertyAccessExpression = ts.isRightSideOfPropertyAccess(location) ? location.parent : undefined; var lhsType = propertyAccessExpression && checker.getTypeAtLocation(propertyAccessExpression.expression); var res = ts.mapDefined(lhsType && (lhsType.isUnionOrIntersection() ? lhsType.types : lhsType.symbol === symbol.parent ? undefined : [lhsType]), function (t) { - return t.symbol && t.symbol.flags & (32 /* Class */ | 64 /* Interface */) ? t.symbol : undefined; + return t.symbol && t.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) ? t.symbol : undefined; }); return res.length === 0 ? undefined : res; } function isForRenameWithPrefixAndSuffixText(options) { - return options.use === 2 /* Rename */ && options.providePrefixAndSuffixTextForRename; + return options.use === 2 /* FindReferencesUse.Rename */ && options.providePrefixAndSuffixTextForRename; } })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); @@ -140523,7 +141229,7 @@ var ts; && ts.isVariableDeclaration(node.parent) && node === node.parent.initializer && ts.isIdentifier(node.parent.name) - && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* Const */); + && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* NodeFlags.Const */); } /** * Indicates whether a node could possibly be a call hierarchy declaration. @@ -140572,7 +141278,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -140596,8 +141302,8 @@ var ts; var end = pos + 6; /* "static".length */ var typeChecker = program.getTypeChecker(); var symbol = typeChecker.getSymbolAtLocation(node.parent); - var prefix = symbol ? typeChecker.symbolToString(symbol, node.parent) + " " : ""; - return { text: prefix + "static {}", pos: pos, end: end }; + var prefix = symbol ? "".concat(typeChecker.symbolToString(symbol, node.parent), " ") : ""; + return { text: "".concat(prefix, "static {}"), pos: pos, end: end }; } var declName = isConstNamedExpression(node) ? node.parent.name : ts.Debug.checkDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name"); @@ -140617,7 +141323,7 @@ var ts; if (text === undefined) { // get the text from printing the node on a single line without comments... var printer_1 = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* Unspecified */, node, node.getSourceFile(), writer); }); + text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* EmitHint.Unspecified */, node, node.getSourceFile(), writer); }); } return { text: text, pos: declName.getStart(), end: declName.getEnd() }; } @@ -140630,16 +141336,16 @@ var ts; return; } switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText(); } return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText(); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -140666,8 +141372,8 @@ var ts; var declarations; if (symbol && symbol.declarations) { var indices = ts.indicesOf(symbol.declarations); - var keys_1 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); }); - indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_1[a].file, keys_1[b].file) || keys_1[a].pos - keys_1[b].pos; }); + var keys_2 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); }); + indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_2[a].file, keys_2[b].file) || keys_2[a].pos - keys_2[b].pos; }); var sortedDeclarations = ts.map(indices, function (i) { return symbol.declarations[i]; }); var lastDecl = void 0; for (var _i = 0, sortedDeclarations_1 = sortedDeclarations; _i < sortedDeclarations_1.length; _i++) { @@ -140737,7 +141443,7 @@ var ts; } return undefined; } - if (location.kind === 124 /* StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { + if (location.kind === 124 /* SyntaxKind.StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { location = location.parent; continue; } @@ -140748,7 +141454,7 @@ var ts; if (!followingSymbol) { var symbol = typeChecker.getSymbolAtLocation(location); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } if (symbol.valueDeclaration) { @@ -140778,7 +141484,7 @@ var ts; return x !== undefined; } function convertEntryToCallSite(entry) { - if (entry.kind === 1 /* Node */) { + if (entry.kind === 1 /* FindAllReferences.EntryKind.Node */) { var node = entry.node; if (ts.isCallOrNewExpressionTarget(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) || ts.isTaggedTemplateTag(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) @@ -140808,7 +141514,7 @@ var ts; return []; } var location = getCallHierarchyDeclarationReferenceNode(declaration); - var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* References */ }, convertEntryToCallSite), isDefined); + var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, convertEntryToCallSite), isDefined); return calls ? ts.group(calls, getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToIncomingCall(program, entries); }) : []; } CallHierarchy.getIncomingCalls = getIncomingCalls; @@ -140836,7 +141542,7 @@ var ts; function collect(node) { if (!node) return; - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // do not descend into ambient nodes. return; } @@ -140853,59 +141559,59 @@ var ts; return; } switch (node.kind) { - case 79 /* Identifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 79 /* SyntaxKind.Identifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: recordCallSite(node); return; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: recordCallSite(node); collect(node.expression); return; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -140922,7 +141628,7 @@ var ts; ts.forEach(node.statements, collect); } function collectCallSitesOfModuleDeclaration(node, collect) { - if (!ts.hasSyntacticModifier(node, 2 /* Ambient */) && node.body && ts.isModuleBlock(node.body)) { + if (!ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) && node.body && ts.isModuleBlock(node.body)) { ts.forEach(node.body.statements, collect); } } @@ -140963,25 +141669,25 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: collectCallSitesOfClassStaticBlockDeclaration(node, collect); break; default: @@ -140997,7 +141703,7 @@ var ts; } /** Gets the call sites that call out of the provided call hierarchy declaration. */ function getOutgoingCalls(program, declaration) { - if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) { + if (declaration.flags & 16777216 /* NodeFlags.Ambient */ || ts.isMethodSignature(declaration)) { return []; } return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); }); @@ -141115,7 +141821,7 @@ var ts; } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) { var allFiles = program.getSourceFiles(); - var _loop_5 = function (sourceFile) { + var _loop_4 = function (sourceFile) { var newFromOld = oldToNew(sourceFile.fileName); var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); @@ -141147,7 +141853,7 @@ var ts; }; for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { var sourceFile = allFiles_1[_i]; - _loop_5(sourceFile); + _loop_4(sourceFile); } } function combineNormal(pathA, pathB) { @@ -141252,13 +141958,13 @@ var ts; } var parent = node.parent; var typeChecker = program.getTypeChecker(); - if (node.kind === 159 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { + if (node.kind === 159 /* SyntaxKind.OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray; } // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 + return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { var classDecl = node.parent.parent; @@ -141269,7 +141975,7 @@ var ts; return ts.map(staticBlocks, function (staticBlock) { var pos = ts.moveRangePastModifiers(staticBlock).pos; pos = ts.skipTrivia(sourceFile_1.text, pos); - return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); + return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* ScriptElementKind.constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); }); } var _d = getSymbol(node, typeChecker, stopAtAlias), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution; @@ -141293,7 +141999,7 @@ var ts; fileName: ref.resolvedFileName, containerName: undefined, containerKind: undefined, - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, textSpan: ts.createTextSpan(0, 0), failedAliasResolution: failedAliasResolution, isAmbient: ts.isDeclarationFileName(ref.resolvedFileName), @@ -141320,7 +142026,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); + return node.kind === 106 /* SyntaxKind.SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -141328,7 +142034,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray; return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); @@ -141462,12 +142168,12 @@ var ts; // If a function returns 'void' or some other type with no definition, just return the function definition. var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution); return typeDefinitions.length ? typeDefinitions - : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) + : !(symbol.flags & 111551 /* SymbolFlags.Value */) && symbol.flags & 788968 /* SymbolFlags.Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) : undefined; } GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition; function definitionFromType(type, checker, node, failedAliasResolution) { - return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) { + return ts.flatMap(type.isUnion() && !(type.flags & 32 /* TypeFlags.Enum */) ? type.types : [type], function (t) { return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution); }); } @@ -141511,7 +142217,7 @@ var ts; // import {A, B} from "mod"; // to jump to the implementation directly. var failedAliasResolution = false; - if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* SymbolFlags.Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { return { symbol: aliased }; @@ -141528,13 +142234,13 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 79 /* Identifier */) { + if (node.kind !== 79 /* SyntaxKind.Identifier */) { return false; } if (node.parent === declaration) { return true; } - if (declaration.kind === 268 /* NamespaceImport */) { + if (declaration.kind === 268 /* SyntaxKind.NamespaceImport */) { return false; } return true; @@ -141566,7 +142272,7 @@ var ts; return "quit"; return false; }); - return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */; + return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* AssignmentDeclarationKind.Property */; } function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) { var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; }); @@ -141576,7 +142282,7 @@ var ts; function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* SymbolFlags.Class */ && !(symbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* SyntaxKind.ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -141616,7 +142322,7 @@ var ts; textSpan = ts.createTextSpanFromNode(name, sourceFile); } return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217 - containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* NodeFlags.Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); } function isDefinitionVisible(checker, declaration) { if (checker.isDeclarationVisible(declaration)) @@ -141628,22 +142334,22 @@ var ts; return isDefinitionVisible(checker, declaration.parent); // Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // Private/protected properties/methods are not visible - if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + if (ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) return false; // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: return isDefinitionVisible(checker, declaration.parent); default: return false; @@ -141660,7 +142366,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, name: name, containerName: undefined, containerKind: undefined, @@ -141681,9 +142387,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return true; default: return false; @@ -141789,17 +142495,17 @@ var ts; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var jsdoc = _a[_i]; - var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 327 /* JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); }); + var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 327 /* SyntaxKind.JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); }); // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @typedefs are themselves declarations with associated comments // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation if (jsdoc.comment === undefined && !inheritDoc || ts.isJSDoc(jsdoc) - && declaration.kind !== 345 /* JSDocTypedefTag */ && declaration.kind !== 338 /* JSDocCallbackTag */ + && declaration.kind !== 345 /* SyntaxKind.JSDocTypedefTag */ && declaration.kind !== 338 /* SyntaxKind.JSDocCallbackTag */ && jsdoc.tags - && jsdoc.tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + && jsdoc.tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !jsdoc.tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { continue; } var newparts = jsdoc.comment ? getDisplayPartsFromComment(jsdoc.comment, checker) : []; @@ -141819,11 +142525,11 @@ var ts; } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return [declaration]; - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -141837,8 +142543,8 @@ var ts; // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation - if (tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + if (tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { return; } for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) { @@ -141853,17 +142559,17 @@ var ts; if (typeof comment === "string") { return [ts.textPart(comment)]; } - return ts.flatMap(comment, function (node) { return node.kind === 321 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); + return ts.flatMap(comment, function (node) { return node.kind === 321 /* SyntaxKind.JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); } function getCommentDisplayParts(tag, checker) { var comment = tag.comment, kind = tag.kind; var namePart = getTagNameDisplayPart(kind); switch (kind) { - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return withNode(tag.class); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return withNode(tag.class); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: var templateTag = tag; var displayParts_3 = []; if (templateTag.constraint) { @@ -141877,7 +142583,7 @@ var ts; ts.forEach(templateTag.typeParameters, function (tp) { displayParts_3.push(namePart(tp.getText())); if (lastTypeParameter_1 !== tp) { - displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]); + displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]); } }); } @@ -141885,13 +142591,13 @@ var ts; displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true)); } return displayParts_3; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return withNode(tag.typeExpression); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: - case 346 /* JSDocSeeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: var name = tag.name; return name ? withNode(name) : comment === undefined ? undefined @@ -141918,14 +142624,14 @@ var ts; } function getTagNameDisplayPart(kind) { switch (kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return ts.parameterNamePart; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return ts.propertyNamePart; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return ts.typeParameterNamePart; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return ts.typeAliasNamePart; default: return ts.textPart; @@ -141935,7 +142641,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword" /* keyword */, + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority, }; @@ -141946,8 +142652,8 @@ var ts; function getJSDocTagCompletions() { return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { - name: "@" + tagName, - kind: "keyword" /* keyword */, + name: "@".concat(tagName), + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; @@ -141957,7 +142663,7 @@ var ts; function getJSDocTagCompletionDetails(name) { return { name: name, - kind: "" /* unknown */, + kind: "" /* ScriptElementKind.unknown */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -141983,14 +142689,14 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; + return { name: name, kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; function getJSDocParameterNameCompletionDetails(name) { return { name: name, - kind: "parameter" /* parameterElement */, + kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -142039,8 +142745,12 @@ var ts; return undefined; } var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn; - var commentOwnerJSDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? ts.lastOrUndefined(commentOwner.jsDoc) : undefined; - if (commentOwner.getStart(sourceFile) < position || commentOwnerJSDoc && commentOwnerJSDoc !== existingDocComment) { + var commentOwnerJsDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? commentOwner.jsDoc : undefined; + var lastJsDoc = ts.lastOrUndefined(commentOwnerJsDoc); + if (commentOwner.getStart(sourceFile) < position + || lastJsDoc + && existingDocComment + && lastJsDoc !== existingDocComment) { return undefined; } var indentationStr = getIndentationStringAtPosition(sourceFile, position); @@ -142057,7 +142767,9 @@ var ts; // * if the caret was directly in front of the object, then we add an extra line and indentation. var openComment = "/**"; var closeComment = " */"; - if (tags) { + // If any of the existing jsDoc has tags, ignore adding new ones. + var hasTag = (commentOwnerJsDoc || []).some(function (jsDoc) { return !!jsDoc.tags; }); + if (tags && !hasTag) { var preamble = openComment + newLine + indentationStr + " * "; var endLine = tokenStart === position ? newLine + indentationStr : ""; var result = preamble + newLine + tags + indentationStr + closeComment + endLine; @@ -142077,37 +142789,37 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* SyntaxKind.Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; - return indentationStr + " * @param " + type + paramName + newLine; + return "".concat(indentationStr, " * @param ").concat(type).concat(paramName).concat(newLine); }).join(""); } function returnsDocComment(indentationStr, newLine) { - return indentationStr + " * @returns" + newLine; + return "".concat(indentationStr, " * @returns").concat(newLine); } function getCommentOwnerInfo(tokenAtPos, options) { return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: var host = commentOwner; return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer, options); - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 166 /* PropertySignature */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -142117,25 +142829,25 @@ var ts; ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return "quit"; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 261 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 238 /* ExpressionStatement */: + return commentOwner.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 238 /* SyntaxKind.ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression, options); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var be = commentOwner; - if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { + if (ts.getAssignmentDeclarationKind(be) === 0 /* AssignmentDeclarationKind.None */) { return "quit"; } return ts.isFunctionLike(be.right) ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; @@ -142148,14 +142860,14 @@ var ts; || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 212 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return rightHandSide; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -142171,7 +142883,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_6 = function (sourceFile) { + var _loop_5 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && sourceFile.isDeclarationFile) { return "continue"; @@ -142183,7 +142895,7 @@ var ts; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var sourceFile = sourceFiles_4[_i]; - _loop_6(sourceFile); + _loop_5(sourceFile); } rawItems.sort(compareNavigateToItems); return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); @@ -142214,9 +142926,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -142226,7 +142938,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 162 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -142243,7 +142955,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 162 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -142277,7 +142989,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, + containerKind: containerName ? ts.getNodeKind(container) : "" /* ScriptElementKind.unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -142460,7 +143172,7 @@ var ts; */ function hasNavigationBarName(node) { return !ts.hasDynamicName(node) || - (node.kind !== 221 /* BinaryExpression */ && + (node.kind !== 221 /* SyntaxKind.BinaryExpression */ && ts.isPropertyAccessExpression(node.name.expression) && ts.isIdentifier(node.name.expression.expression) && ts.idText(node.name.expression.expression) === "Symbol"); @@ -142473,7 +143185,7 @@ var ts; return; } switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -142485,25 +143197,25 @@ var ts; } } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 168 /* SyntaxKind.MethodSignature */: if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (hasNavigationBarName(node)) { addNodeWithRecursiveInitializer(node); } break; - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -142515,7 +143227,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -142526,17 +143238,17 @@ var ts; } } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: var expression = node.expression; // Use the expression as the name of the SpreadAssignment, otherwise show as . ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); break; - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: - case 254 /* VariableDeclaration */: { + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: { var child = node; if (ts.isBindingPattern(child.name)) { addChildrenRecursively(child.name); @@ -142546,7 +143258,7 @@ var ts; } break; } - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -142554,11 +143266,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -142568,9 +143280,9 @@ var ts; } endNode(); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -142578,10 +143290,10 @@ var ts; } endNode(); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression_1 = node.expression; var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 : ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined; @@ -142595,27 +143307,27 @@ var ts; } break; } - case 275 /* ExportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 176 /* IndexSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 259 /* TypeAliasDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: addLeafNode(node); break; - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: addNodeWithRecursiveChild(node, node.right); return; - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: { + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; - var prototypeAccess = special === 3 /* PrototypeProperty */ ? + var prototypeAccess = special === 3 /* AssignmentDeclarationKind.PrototypeProperty */ ? assignmentTarget.expression : assignmentTarget; var depth = 0; @@ -142629,7 +143341,7 @@ var ts; else { _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; } - if (special === 6 /* Prototype */) { + if (special === 6 /* AssignmentDeclarationKind.Prototype */) { if (ts.isObjectLiteralExpression(binaryExpression.right)) { if (binaryExpression.right.properties.length > 0) { startNode(binaryExpression, className); @@ -142649,10 +143361,10 @@ var ts; endNestedNodes(depth); return; } - case 7 /* ObjectDefinePropertyValue */: - case 9 /* ObjectDefinePrototypeProperty */: { + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: { var defineCall = node; - var className = special === 7 /* ObjectDefinePropertyValue */ ? + var className = special === 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */ ? defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; @@ -142665,7 +143377,7 @@ var ts; endNestedNodes(depth); return; } - case 5 /* Property */: { + case 5 /* AssignmentDeclarationKind.Property */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; var targetFunction = assignmentTarget.expression; @@ -142683,9 +143395,9 @@ var ts; } break; } - case 4 /* ThisProperty */: - case 0 /* None */: - case 8 /* ObjectDefinePropertyExports */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: break; default: ts.Debug.assertNever(special); @@ -142741,16 +143453,16 @@ var ts; }); } var isEs5ClassMember = (_a = {}, - _a[5 /* Property */] = true, - _a[3 /* PrototypeProperty */] = true, - _a[7 /* ObjectDefinePropertyValue */] = true, - _a[9 /* ObjectDefinePrototypeProperty */] = true, - _a[0 /* None */] = false, - _a[1 /* ExportsProperty */] = false, - _a[2 /* ModuleExports */] = false, - _a[8 /* ObjectDefinePropertyExports */] = false, - _a[6 /* Prototype */] = true, - _a[4 /* ThisProperty */] = false, + _a[5 /* AssignmentDeclarationKind.Property */] = true, + _a[3 /* AssignmentDeclarationKind.PrototypeProperty */] = true, + _a[7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */] = true, + _a[9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */] = true, + _a[0 /* AssignmentDeclarationKind.None */] = false, + _a[1 /* AssignmentDeclarationKind.ExportsProperty */] = false, + _a[2 /* AssignmentDeclarationKind.ModuleExports */] = false, + _a[8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */] = false, + _a[6 /* AssignmentDeclarationKind.Prototype */] = true, + _a[4 /* AssignmentDeclarationKind.ThisProperty */] = false, _a); function tryMergeEs5Class(a, b, bIndex, parent) { function isPossibleConstructor(node) { @@ -142758,10 +143470,10 @@ var ts; } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -142825,7 +143537,7 @@ var ts; } return true; } - return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + return bAssignmentDeclarationKind === 0 /* AssignmentDeclarationKind.None */ ? false : true; } function tryMerge(a, b, bIndex, parent) { // const v = false as boolean; @@ -142844,12 +143556,12 @@ var ts; return false; } switch (a.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.isStatic(a) === ts.isStatic(b); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return areSameModule(a, b) && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: @@ -142857,7 +143569,7 @@ var ts; } } function isSynthesized(node) { - return !!(node.flags & 8 /* Synthesized */); + return !!(node.flags & 8 /* NodeFlags.Synthesized */); } // We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }` // We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };` @@ -142871,7 +143583,7 @@ var ts; if (!a.body || !b.body) { return a.body === b.body; } - return a.body.kind === b.body.kind && (a.body.kind !== 261 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 261 /* SyntaxKind.ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -142901,7 +143613,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -142910,53 +143622,53 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { var text = ts.isIdentifier(name) ? name.text - : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : ts.isElementAccessExpression(name) ? "[".concat(nodeText(name.argumentExpression), "]") : nodeText(name); if (text.length > 0) { return cleanText(text); } } switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" + ? "\"".concat(ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))), "\"") : ""; - case 271 /* ExportAssignment */: - return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + case 271 /* SyntaxKind.ExportAssignment */: + return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } // We may get a string with newlines or other whitespace in the case of an object dereference // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return "new()"; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return "()"; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return "[]"; default: return ""; @@ -142989,19 +143701,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 305 /* SourceFile */: - case 259 /* TypeAliasDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return true; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -143011,10 +143723,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: return true; default: return false; @@ -143076,7 +143788,7 @@ var ts; function getFullyQualifiedModuleName(moduleDeclaration) { // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)]; - while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -143090,13 +143802,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 162 /* ComputedPropertyName */; + return !member.name || member.name.kind === 162 /* SyntaxKind.ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 305 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 254 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -143111,7 +143823,7 @@ var ts; return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -143119,7 +143831,7 @@ var ts; return nodeText(parent.name); } // Default exports are named "default" - else if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + else if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } else if (ts.isClassLike(node)) { @@ -143130,10 +143842,10 @@ var ts; if (name !== undefined) { name = cleanText(name); if (name.length > maxLength) { - return name + " callback"; + return "".concat(name, " callback"); } var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); - return name + "(" + args + ") callback"; + return "".concat(name, "(").concat(args, ") callback"); } } return ""; @@ -143146,7 +143858,7 @@ var ts; else if (ts.isPropertyAccessExpression(expr)) { var left = getCalledExpressionName(expr.expression); var right = expr.name.text; - return left === undefined ? right : left + "." + right; + return left === undefined ? right : "".concat(left, ".").concat(right); } else { return undefined; @@ -143154,9 +143866,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; default: return false; @@ -143270,7 +143982,7 @@ var ts; var numberOfNewLines = 0; while (scanner.getTokenPos() < endPos) { var tokenKind = scanner.scan(); - if (tokenKind === 4 /* NewLineTrivia */) { + if (tokenKind === 4 /* SyntaxKind.NewLineTrivia */) { numberOfNewLines++; if (numberOfNewLines >= 2) { return true; @@ -143288,7 +144000,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); - var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */); + var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* TransformFlags.ContainsJsx */); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -143557,11 +144269,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return declaration.moduleSpecifier; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -143600,19 +144312,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!s1.importClause) return 0; if (s1.importClause.isTypeOnly) return 1; - if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* SyntaxKind.NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return 5; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return 6; } } @@ -143665,7 +144377,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* SyntaxKind.ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* OutliningSpanKind.Imports */)); } } function visitNonImportNode(n) { @@ -143673,7 +144385,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* EndOfFileToken */) { + if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* SyntaxKind.EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (ts.isFunctionLike(n) && ts.isBinaryExpression(n.parent) && ts.isPropertyAccessExpression(n.parent.left)) { @@ -143723,7 +144435,7 @@ var ts; } if (!result[1]) { var span = ts.createTextSpanFromBounds(sourceFile.text.indexOf("//", currentLineStart), lineEnd); - regions.push(createOutliningSpan(span, "region" /* Region */, span, /*autoCollapse*/ false, result[2] || "#region")); + regions.push(createOutliningSpan(span, "region" /* OutliningSpanKind.Region */, span, /*autoCollapse*/ false, result[2] || "#region")); } else { var region = regions.pop(); @@ -143758,7 +144470,7 @@ var ts; var _a = comments_1[_i], kind = _a.kind, pos_1 = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: // never fold region delimiters into single-line comment regions var commentText = sourceText.slice(pos_1, end); if (isRegionDelimiter(commentText)) { @@ -143774,9 +144486,9 @@ var ts; lastSingleLineCommentEnd = end; singleLineCommentCount++; break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: combineAndAddMultipleSingleLineComments(); - out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* OutliningSpanKind.Comment */)); singleLineCommentCount = 0; break; default: @@ -143787,7 +144499,7 @@ var ts; function combineAndAddMultipleSingleLineComments() { // Only outline spans of two or more consecutive single line comments if (singleLineCommentCount > 1) { - out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* OutliningSpanKind.Comment */)); } } } @@ -143801,7 +144513,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -143809,23 +144521,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 240 /* DoStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 292 /* CatchClause */: + case 240 /* SyntaxKind.DoStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 292 /* SyntaxKind.CatchClause */: return spanForNode(n.parent); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -143833,52 +144545,52 @@ var ts; default: // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); + return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* OutliningSpanKind.Code */); } - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanForNode(n.parent); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 263 /* CaseBlock */: - case 182 /* TypeLiteral */: - case 201 /* ObjectBindingPattern */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 263 /* SyntaxKind.CaseBlock */: + case 182 /* SyntaxKind.TypeLiteral */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return spanForNode(n); - case 184 /* TupleType */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 184 /* SyntaxKind.TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return spanForNodeArray(n.statements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 204 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 278 /* JsxElement */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* SyntaxKind.OpenBracketToken */); + case 278 /* SyntaxKind.JsxElement */: return spanForJSXElement(n); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return spanForJSXFragment(n); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 202 /* ArrayBindingPattern */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 214 /* ArrowFunction */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 214 /* SyntaxKind.ArrowFunction */: return spanForArrowFunction(n); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return spanForCallExpression(n); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanForParenthesizedExpression(n); } function spanForCallExpression(node) { if (!node.arguments.length) { return undefined; } - var openToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); - var closeToken = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + var openToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); + var closeToken = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!openToken || !closeToken || ts.positionsAreOnSameLine(openToken.pos, closeToken.pos, sourceFile)) { return undefined; } @@ -143889,33 +144601,33 @@ var ts; return undefined; } var textSpan = ts.createTextSpanFromBounds(node.body.getFullStart(), node.body.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); var tagName = node.openingElement.tagName.getText(sourceFile); var bannerText = "<" + tagName + ">..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXFragment(node) { var textSpan = ts.createTextSpanFromBounds(node.openingFragment.getStart(sourceFile), node.closingFragment.getEnd()); var bannerText = "<>..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXAttributes(node) { if (node.properties.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForTemplateLiteral(node) { - if (node.kind === 14 /* NoSubstitutionTemplateLiteral */ && node.text.length === 0) { + if (node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ && node.text.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 18 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal or call expression, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -143924,32 +144636,32 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open, close) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 18 /* OpenBraceToken */; } - if (close === void 0) { close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } + if (close === void 0) { close = open === 18 /* SyntaxKind.OpenBraceToken */ ? 19 /* SyntaxKind.CloseBraceToken */ : 23 /* SyntaxKind.CloseBracketToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); var closeToken = ts.findChildOfKind(n, close, sourceFile); return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart); } function spanForNodeArray(nodeArray) { - return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* Code */) : undefined; + return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* OutliningSpanKind.Code */) : undefined; } function spanForParenthesizedExpression(node) { if (ts.positionsAreOnSameLine(node.getStart(), node.getEnd(), sourceFile)) return undefined; var textSpan = ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } } function functionSpan(node, body, sourceFile) { var openToken = tryGetFunctionOpenToken(node, body, sourceFile); - var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* ArrowFunction */); + var closeToken = ts.findChildOfKind(body, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* SyntaxKind.ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } var textSpan = ts.createTextSpanFromBounds(useFullStart ? openToken.getFullStart() : openToken.getStart(sourceFile), closeToken.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); } function createOutliningSpan(textSpan, kind, hintSpan, autoCollapse, bannerText) { if (hintSpan === void 0) { hintSpan = textSpan; } @@ -143959,12 +144671,12 @@ var ts; } function tryGetFunctionOpenToken(node, body, sourceFile) { if (ts.isNodeArrayMultiLine(node.parameters, sourceFile)) { - var openParenToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + var openParenToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (openParenToken) { return openParenToken; } } - return ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); + return ts.findChildOfKind(body, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); } })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); })(ts || (ts = {})); @@ -144090,7 +144802,7 @@ var ts; // // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. - if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* space */ && ch !== 42 /* asterisk */; })) { + if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* CharacterCodes.space */ && ch !== 42 /* CharacterCodes.asterisk */; })) { var match = matchTextChunk(candidate, segment.totalTextChunk, stringToWordSpans); if (match) return match; @@ -144142,7 +144854,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ + return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { @@ -144219,10 +144931,10 @@ var ts; } function isUpperCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -144232,10 +144944,10 @@ var ts; } function isLowerCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -144246,13 +144958,13 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_7 = function (start) { + var _loop_6 = function (start) { if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) { return { value: start }; } }; for (var start = 0; start <= n; start++) { - var state_3 = _loop_7(start); + var state_3 = _loop_6(start); if (typeof state_3 === "object") return state_3.value; } @@ -144260,10 +144972,10 @@ var ts; } function toLowerCase(ch) { // Fast convert for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return 97 /* a */ + (ch - 65 /* A */); + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { + return 97 /* CharacterCodes.a */ + (ch - 65 /* CharacterCodes.A */); } - if (ch < 127 /* maxAsciiCharacter */) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */) { return ch; } // TODO: find a way to compute this for any unicode characters in a @@ -144272,10 +144984,10 @@ var ts; } function isDigit(ch) { // TODO(cyrusn): Find a way to support this for unicode digits. - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* CharacterCodes._ */ || ch === 36 /* CharacterCodes.$ */; } function breakPatternIntoTextChunks(pattern) { var result = []; @@ -144344,35 +145056,35 @@ var ts; } function charIsPunctuation(ch) { switch (ch) { - case 33 /* exclamation */: - case 34 /* doubleQuote */: - case 35 /* hash */: - case 37 /* percent */: - case 38 /* ampersand */: - case 39 /* singleQuote */: - case 40 /* openParen */: - case 41 /* closeParen */: - case 42 /* asterisk */: - case 44 /* comma */: - case 45 /* minus */: - case 46 /* dot */: - case 47 /* slash */: - case 58 /* colon */: - case 59 /* semicolon */: - case 63 /* question */: - case 64 /* at */: - case 91 /* openBracket */: - case 92 /* backslash */: - case 93 /* closeBracket */: - case 95 /* _ */: - case 123 /* openBrace */: - case 125 /* closeBrace */: + case 33 /* CharacterCodes.exclamation */: + case 34 /* CharacterCodes.doubleQuote */: + case 35 /* CharacterCodes.hash */: + case 37 /* CharacterCodes.percent */: + case 38 /* CharacterCodes.ampersand */: + case 39 /* CharacterCodes.singleQuote */: + case 40 /* CharacterCodes.openParen */: + case 41 /* CharacterCodes.closeParen */: + case 42 /* CharacterCodes.asterisk */: + case 44 /* CharacterCodes.comma */: + case 45 /* CharacterCodes.minus */: + case 46 /* CharacterCodes.dot */: + case 47 /* CharacterCodes.slash */: + case 58 /* CharacterCodes.colon */: + case 59 /* CharacterCodes.semicolon */: + case 63 /* CharacterCodes.question */: + case 64 /* CharacterCodes.at */: + case 91 /* CharacterCodes.openBracket */: + case 92 /* CharacterCodes.backslash */: + case 93 /* CharacterCodes.closeBracket */: + case 95 /* CharacterCodes._ */: + case 123 /* CharacterCodes.openBrace */: + case 125 /* CharacterCodes.closeBrace */: return true; } return false; } function isAllPunctuation(identifier, start, end) { - return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* _ */; }, start, end); + return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* CharacterCodes._ */; }, start, end); } function transitionFromUpperToLower(identifier, index, wordStart) { // Cases this supports: @@ -144433,7 +145145,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var pragmaContext = { - languageVersion: 1 /* ES5 */, + languageVersion: 1 /* ScriptTarget.ES5 */, pragmas: undefined, checkJsDirective: undefined, referencedFiles: [], @@ -144454,10 +145166,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 18 /* OpenBraceToken */) { + if (currentToken === 18 /* SyntaxKind.OpenBraceToken */) { braceNesting++; } - else if (currentToken === 19 /* CloseBraceToken */) { + else if (currentToken === 19 /* SyntaxKind.CloseBraceToken */) { braceNesting--; } return currentToken; @@ -144487,12 +145199,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 135 /* DeclareKeyword */) { + if (token === 135 /* SyntaxKind.DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 141 /* ModuleKeyword */) { + if (token === 141 /* SyntaxKind.ModuleKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { recordAmbientExternalModule(); } } @@ -144504,54 +145216,54 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 24 /* DotToken */) { + if (lastToken === 24 /* SyntaxKind.DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 100 /* ImportKeyword */) { + if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 10 /* StringLiteral */) { + else if (token === 10 /* SyntaxKind.StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 156 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */ || - token === 79 /* Identifier */ || + return token !== 156 /* SyntaxKind.FromKeyword */ && (token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */ || + token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 63 /* EqualsToken */) { + else if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 27 /* CommaToken */) { + else if (token === 27 /* SyntaxKind.CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -144560,18 +145272,18 @@ var ts; return true; } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -144579,15 +145291,15 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 127 /* AsKeyword */) { + if (token === 127 /* SyntaxKind.AsKeyword */) { token = nextToken(); - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -144603,31 +145315,31 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 93 /* ExportKeyword */) { + if (token === 93 /* SyntaxKind.ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */; + return token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */; }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -144635,31 +145347,31 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 100 /* ImportKeyword */) { + else if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 79 /* Identifier */ || + return token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 63 /* EqualsToken */) { + if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -144673,12 +145385,12 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 146 /* RequireKeyword */) { + if (token === 146 /* SyntaxKind.RequireKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || - allowTemplateLiterals && token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || + allowTemplateLiterals && token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // require("mod"); recordModuleName(); } @@ -144689,16 +145401,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* SyntaxKind.Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 20 /* OpenParenToken */) { + if (token !== 20 /* SyntaxKind.OpenParenToken */) { return true; } token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 27 /* CommaToken */) { + if (token === 27 /* SyntaxKind.CommaToken */) { token = nextToken(); } else { @@ -144707,15 +145419,15 @@ var ts; } } // should be start of dependency list - if (token !== 22 /* OpenBracketToken */) { + if (token !== 22 /* SyntaxKind.OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* SyntaxKind.CloseBracketToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { // record string literals as module names - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { recordModuleName(); } token = nextToken(); @@ -144743,31 +145455,31 @@ var ts; // AnySymbol.import("mod") // AnySymbol.nested.import("mod") while (true) { - if (ts.scanner.getToken() === 1 /* EndOfFileToken */) { + if (ts.scanner.getToken() === 1 /* SyntaxKind.EndOfFileToken */) { break; } - if (ts.scanner.getToken() === 15 /* TemplateHead */) { + if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) { var stack = [ts.scanner.getToken()]; var token = ts.scanner.scan(); loop: while (ts.length(stack)) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: tryConsumeImport(); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: stack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.length(stack)) { stack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (ts.length(stack)) { - if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) { - if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) { + if (ts.lastOrUndefined(stack) === 15 /* SyntaxKind.TemplateHead */) { + if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* SyntaxKind.TemplateTail */) { stack.pop(); } } @@ -144854,13 +145566,13 @@ var ts; if (!symbol) { if (ts.isStringLiteralLike(node)) { var type = ts.getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker); - if (type && ((type.flags & 128 /* StringLiteral */) || ((type.flags & 1048576 /* Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* StringLiteral */); })))) { - return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile); + if (type && ((type.flags & 128 /* TypeFlags.StringLiteral */) || ((type.flags & 1048576 /* TypeFlags.Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); })))) { + return getRenameInfoSuccess(node.text, node.text, "string" /* ScriptElementKind.string */, "", node, sourceFile); } } else if (ts.isLabelName(node)) { var name = ts.getTextOfNode(node); - return getRenameInfoSuccess(name, name, "label" /* label */, "" /* none */, node, sourceFile); + return getRenameInfoSuccess(name, name, "label" /* ScriptElementKind.label */, "" /* ScriptElementKindModifier.none */, node, sourceFile); } return undefined; } @@ -144873,7 +145585,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* SymbolFlags.Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { @@ -144885,7 +145597,7 @@ var ts; return getRenameInfoError(wouldRenameNodeModules); } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -144894,10 +145606,10 @@ var ts; } function isDefinedInLibraryFile(program, declaration) { var sourceFile = declaration.getSourceFile(); - return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Extension.Dts */); } function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) { - if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) { + if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* SymbolFlags.Alias */) { var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); }); if (importSpecifier && !importSpecifier.propertyName) { symbol = checker.getAliasedSymbol(symbol); @@ -144923,7 +145635,7 @@ var ts; if (declPackage) { var length_2 = Math.min(originalPackage.length, declPackage.length); for (var i = 0; i <= length_2; i++) { - if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) { + if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* Comparison.EqualTo */) { return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder; } } @@ -144948,7 +145660,7 @@ var ts; return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); var name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; - var kind = withoutIndex === undefined ? "module" /* moduleElement */ : "directory" /* directory */; + var kind = withoutIndex === undefined ? "module" /* ScriptElementKind.moduleElement */ : "directory" /* ScriptElementKind.directory */; var indexAfterLastSlash = node.text.lastIndexOf("/") + 1; // Span should only be the last component of the path. + 1 to account for the quote character. var triggerSpan = ts.createTextSpan(node.getStart(sourceFile) + 1 + indexAfterLastSlash, node.text.length - indexAfterLastSlash); @@ -144958,7 +145670,7 @@ var ts; kind: kind, displayName: name, fullDisplayName: name, - kindModifiers: "" /* none */, + kindModifiers: "" /* ScriptElementKindModifier.none */, triggerSpan: triggerSpan, }; } @@ -144988,13 +145700,13 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return true; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); default: return false; @@ -145009,7 +145721,7 @@ var ts; var SmartSelectionRange; (function (SmartSelectionRange) { function getSmartSelectionRange(pos, sourceFile) { - var _a; + var _a, _b; var selectionRange = { textSpan: ts.createTextSpanFromBounds(sourceFile.getFullStart(), sourceFile.getEnd()) }; @@ -145026,7 +145738,7 @@ var ts; break outer; } var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); - if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment && comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { pushSelectionCommentRange(comment.pos, comment.end); } if (positionShouldSnapToNode(sourceFile, pos, node)) { @@ -145061,6 +145773,17 @@ var ts; if (ts.hasJSDocNodes(node) && ((_a = node.jsDoc) === null || _a === void 0 ? void 0 : _a.length)) { pushSelectionRange(ts.first(node.jsDoc).getStart(), end); } + // (#39618 & #49807) + // When the node is a SyntaxList and its first child has a JSDoc comment, then the node's + // `start` (which usually is the result of calling `node.getStart()`) points to the first + // token after the JSDoc comment. So, we have to make sure we'd pushed the selection + // covering the JSDoc comment before diving further. + if (ts.isSyntaxList(node)) { + var firstChild = node.getChildren()[0]; + if (firstChild && ts.hasJSDocNodes(firstChild) && ((_b = firstChild.jsDoc) === null || _b === void 0 ? void 0 : _b.length) && firstChild.getStart() !== node.pos) { + start = Math.min(start, ts.first(firstChild.jsDoc).getStart()); + } + } pushSelectionRange(start, end); // String literals should have a stop both inside and outside their quotes. if (ts.isStringLiteral(node) || ts.isTemplateLiteral(node)) { @@ -145094,7 +145817,7 @@ var ts; function pushSelectionCommentRange(start, end) { pushSelectionRange(start, end); var pos = start; - while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + while (sourceFile.text.charCodeAt(pos) === 47 /* CharacterCodes.slash */) { pos++; } pushSelectionRange(pos, end); @@ -145134,6 +145857,7 @@ var ts; * other as well as of other top-level statements and declarations. */ function getSelectionChildren(node) { + var _a; // Group top-level imports if (ts.isSourceFile(node)) { return groupChildren(node.getChildAt(0).getChildren(), isImport); @@ -145149,28 +145873,28 @@ var ts; // because it allows the mapped type to become an object type with a // few keystrokes. if (ts.isMappedTypeNode(node)) { - var _a = node.getChildren(), openBraceToken = _a[0], children = _a.slice(1); + var _b = node.getChildren(), openBraceToken = _b[0], children = _b.slice(1); var closeBraceToken = ts.Debug.checkDefined(children.pop()); - ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */); - ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); + ts.Debug.assertEqual(openBraceToken.kind, 18 /* SyntaxKind.OpenBraceToken */); + ts.Debug.assertEqual(closeBraceToken.kind, 19 /* SyntaxKind.CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 145 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 57 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 145 /* SyntaxKind.ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* SyntaxKind.QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; - return kind === 22 /* OpenBracketToken */ || - kind === 163 /* TypeParameter */ || - kind === 23 /* CloseBracketToken */; + return kind === 22 /* SyntaxKind.OpenBracketToken */ || + kind === 163 /* SyntaxKind.TypeParameter */ || + kind === 23 /* SyntaxKind.CloseBracketToken */; }); return [ openBraceToken, // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; })), closeBraceToken, ]; @@ -145180,10 +145904,13 @@ var ts; var children = groupChildren(node.getChildren(), function (child) { return child === node.name || ts.contains(node.modifiers, child); }); - return splitChildren(children, function (_a) { + var firstJSDocChild = ((_a = children[0]) === null || _a === void 0 ? void 0 : _a.kind) === 320 /* SyntaxKind.JSDoc */ ? children[0] : undefined; + var withJSDocSeparated = firstJSDocChild ? children.slice(1) : children; + var splittedChildren = splitChildren(withJSDocSeparated, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; }); + return firstJSDocChild ? [firstJSDocChild, createSyntaxList(splittedChildren)] : splittedChildren; } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. if (ts.isParameter(node)) { @@ -145195,14 +145922,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } return node.getChildren(); @@ -145258,7 +145985,7 @@ var ts; var leftChildren = children.slice(0, splitTokenIndex); var splitToken = children[splitTokenIndex]; var lastToken = ts.last(children); - var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SemicolonToken */; + var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */; var rightChildren = children.slice(splitTokenIndex + 1, separateLastToken ? children.length - 1 : undefined); var result = ts.compact([ leftChildren.length ? createSyntaxList(leftChildren) : undefined, @@ -145273,25 +146000,25 @@ var ts; } function isListOpener(token) { var kind = token && token.kind; - return kind === 18 /* OpenBraceToken */ - || kind === 22 /* OpenBracketToken */ - || kind === 20 /* OpenParenToken */ - || kind === 280 /* JsxOpeningElement */; + return kind === 18 /* SyntaxKind.OpenBraceToken */ + || kind === 22 /* SyntaxKind.OpenBracketToken */ + || kind === 20 /* SyntaxKind.OpenParenToken */ + || kind === 280 /* SyntaxKind.JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; - return kind === 19 /* CloseBraceToken */ - || kind === 23 /* CloseBracketToken */ - || kind === 21 /* CloseParenToken */ - || kind === 281 /* JsxClosingElement */; + return kind === 19 /* SyntaxKind.CloseBraceToken */ + || kind === 23 /* SyntaxKind.CloseBracketToken */ + || kind === 21 /* SyntaxKind.CloseParenToken */ + || kind === 281 /* SyntaxKind.JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 340 /* JSDocParameterTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 345 /* JSDocTypedefTag */: - case 342 /* JSDocThisTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 342 /* SyntaxKind.JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -145338,7 +146065,7 @@ var ts; return ts.isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined; } return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { - return candidateInfo.kind === 0 /* Candidate */ + return candidateInfo.kind === 0 /* CandidateOrTypeKind.Candidate */ ? createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker) : createTypeHelpItems(candidateInfo.symbol, argumentInfo, sourceFile, typeChecker); }); @@ -145352,27 +146079,27 @@ var ts; function getCandidateOrTypeInfo(_a, checker, sourceFile, startingToken, onlyUseSyntacticOwners) { var invocation = _a.invocation, argumentCount = _a.argumentCount; switch (invocation.kind) { - case 0 /* Call */: { + case 0 /* InvocationKind.Call */: { if (onlyUseSyntacticOwners && !isSyntacticOwner(startingToken, invocation.node, sourceFile)) { return undefined; } var candidates = []; var resolvedSignature = checker.getResolvedSignatureForSignatureHelp(invocation.node, candidates, argumentCount); // TODO: GH#18217 - return candidates.length === 0 ? undefined : { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; + return candidates.length === 0 ? undefined : { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; } - case 1 /* TypeArgs */: { + case 1 /* InvocationKind.TypeArgs */: { var called = invocation.called; if (onlyUseSyntacticOwners && !containsPrecedingToken(startingToken, sourceFile, ts.isIdentifier(called) ? called.parent : called)) { return undefined; } var candidates = ts.getPossibleGenericSignatures(called, argumentCount, checker); if (candidates.length !== 0) - return { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; var symbol = checker.getSymbolAtLocation(called); - return symbol && { kind: 1 /* Type */, symbol: symbol }; + return symbol && { kind: 1 /* CandidateOrTypeKind.Type */, symbol: symbol }; } - case 2 /* Contextual */: - return { kind: 0 /* Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; + case 2 /* InvocationKind.Contextual */: + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; default: return ts.Debug.assertNever(invocation); } @@ -145382,20 +146109,20 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 27 /* CommaToken */: { + case 27 /* SyntaxKind.CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; } } function createJSSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind === 2 /* Contextual */) + if (argumentInfo.invocation.kind === 2 /* InvocationKind.Contextual */) return undefined; // See if we can find some symbol with the call expression name that has call signatures. var expression = getExpressionFromInvocation(argumentInfo.invocation); @@ -145431,7 +146158,7 @@ var ts; } function getArgumentInfoForCompletions(node, position, sourceFile) { var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); - return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? undefined + return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* InvocationKind.Call */ ? undefined : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; } SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; @@ -145448,7 +146175,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* SyntaxKind.LessThanToken */ || node.kind === 20 /* SyntaxKind.OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -145491,7 +146218,7 @@ var ts; return undefined; var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var isTypeParameterList = !!parent.typeArguments && parent.typeArguments.pos === list.pos; - return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* InvocationKind.Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { // Check if we're actually inside the template; @@ -145501,10 +146228,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 223 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 223 /* SyntaxKind.TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -145529,7 +146256,7 @@ var ts; var attributeSpanEnd = ts.skipTrivia(sourceFile.text, parent.attributes.end, /*stopAfterLineBreak*/ false); return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: parent }, + invocation: { kind: 0 /* InvocationKind.Call */, node: parent }, argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), argumentIndex: 0, argumentCount: 1 @@ -145539,7 +146266,7 @@ var ts; var typeArgInfo = ts.getPossibleTypeArgumentsInfo(node, sourceFile); if (typeArgInfo) { var called = typeArgInfo.called, nTypeArguments = typeArgInfo.nTypeArguments; - var invocation = { kind: 1 /* TypeArgs */, called: called }; + var invocation = { kind: 1 /* InvocationKind.TypeArgs */, called: called }; var argumentsSpan = ts.createTextSpanFromBounds(called.getStart(sourceFile), node.end); return { isTypeParameterList: true, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: nTypeArguments, argumentCount: nTypeArguments + 1 }; } @@ -145568,28 +146295,28 @@ var ts; var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures()); if (signature === undefined) return undefined; - var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; + var invocation = { kind: 2 /* InvocationKind.Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) { - if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) + if (startingToken.kind !== 20 /* SyntaxKind.OpenParenToken */ && startingToken.kind !== 27 /* SyntaxKind.CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* SyntaxKind.OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; var argumentCount_1 = countBinaryExpressionParameters(highestBinary); return contextualType_1 && { contextualType: contextualType_1, argumentIndex: argumentIndex_1, argumentCount: argumentCount_1, argumentsSpan: ts.createTextSpanFromNode(parent) }; } @@ -145599,7 +146326,7 @@ var ts; } // The type of a function type node has a symbol at that node, but it's better to use the symbol for a parameter or type alias. function chooseBetterSymbol(s) { - return s.name === "__type" /* Type */ + return s.name === "__type" /* InternalSymbolName.Type */ ? ts.firstDefined(s.declarations, function (d) { return ts.isFunctionTypeNode(d) ? d.parent.symbol : undefined; }) || s : s; } @@ -145621,7 +146348,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 27 /* CommaToken */) { + if (child.kind !== 27 /* SyntaxKind.CommaToken */) { argumentIndex++; } } @@ -145640,8 +146367,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); - if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* SyntaxKind.CommaToken */; }); + if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* SyntaxKind.CommaToken */) { argumentCount++; } return argumentCount; @@ -145679,7 +146406,7 @@ var ts; } return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: tagExpression }, + invocation: { kind: 0 /* InvocationKind.Call */, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -145710,7 +146437,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -145719,17 +146446,17 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) { - var _loop_8 = function (n) { + var _loop_7 = function (n) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. - ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); }); + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: ".concat(ts.Debug.formatSyntaxKind(n.kind), ", parent: ").concat(ts.Debug.formatSyntaxKind(n.parent.kind)); }); var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker); if (argumentInfo) { return { value: argumentInfo }; } }; for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) { - var state_4 = _loop_8(n); + var state_4 = _loop_7(n); if (typeof state_4 === "object") return state_4.value; } @@ -145742,17 +146469,17 @@ var ts; return children[indexOfOpenerToken + 1]; } function getExpressionFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; + return invocation.kind === 0 /* InvocationKind.Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; } function getEnclosingDeclarationFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? invocation.node : invocation.kind === 1 /* TypeArgs */ ? invocation.called : invocation.node; + return invocation.kind === 0 /* InvocationKind.Call */ ? invocation.node : invocation.kind === 1 /* InvocationKind.TypeArgs */ ? invocation.called : invocation.node; } - var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var signatureHelpNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; function createSignatureHelpItems(candidates, resolvedSignature, _a, sourceFile, typeChecker, useFullPrefix) { var _b; var isTypeParameterList = _a.isTypeParameterList, argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; var enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation); - var callTargetSymbol = invocation.kind === 2 /* Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); + var callTargetSymbol = invocation.kind === 2 /* InvocationKind.Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); var callTargetDisplayParts = callTargetSymbol ? ts.symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : ts.emptyArray; var items = ts.map(candidates, function (candidateSignature) { return getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile); }); if (argumentIndex !== 0) { @@ -145809,10 +146536,10 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(checker); - var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* LessThanToken */)], false); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], false); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile); return ts.map(infos, function (_a) { @@ -145845,9 +146572,9 @@ var ts; return checker.getExpandedParameters(candidateSignature).map(function (paramList) { var params = ts.factory.createNodeArray(__spreadArray(__spreadArray([], thisParameter, true), ts.map(paramList, function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }), true)); var parameterParts = ts.mapToDisplayParts(function (writer) { - printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* ListFormat.CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts, true) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], parameterParts, true) }; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { @@ -145855,33 +146582,33 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.factory.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration, signatureHelpNodeBuilderFlags); })); - printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* ListFormat.TypeParameters */, args, sourceFile, writer); } }); var lists = checker.getExpandedParameters(candidateSignature); var isVariadic = !checker.hasEffectiveRestParameter(candidateSignature) ? function (_) { return false; } : lists.length === 1 ? function (_) { return true; } - : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* RestParameter */); }; + : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* CheckFlags.RestParameter */); }; return lists.map(function (parameterList) { return ({ isVariadic: isVariadic(parameterList), parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* OpenParenToken */)], false), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)], false), + suffix: [ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - var isRest = !!(parameter.checkFlags & 32768 /* RestParameter */); + var isRest = !!(parameter.checkFlags & 32768 /* CheckFlags.RestParameter */); return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional, isRest: isRest }; } function createSignatureHelpParameterForTypeParameter(typeParameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } @@ -145894,7 +146621,7 @@ var ts; (function (InlayHints) { var maxHintsLength = 30; var leadingParameterNameCommentRegexFactory = function (name) { - return new RegExp("^\\s?/\\*\\*?\\s?" + name + "\\s?\\*\\/\\s?$"); + return new RegExp("^\\s?/\\*\\*?\\s?".concat(name, "\\s?\\*\\/\\s?$")); }; function shouldShowParameterNameHints(preferences) { return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all"; @@ -145915,14 +146642,14 @@ var ts; return; } switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) { @@ -145958,25 +146685,25 @@ var ts; } function addParameterHints(text, position, isFirstVariadicArgument) { result.push({ - text: "" + (isFirstVariadicArgument ? "..." : "") + truncation(text, maxHintsLength) + ":", + text: "".concat(isFirstVariadicArgument ? "..." : "").concat(truncation(text, maxHintsLength), ":"), position: position, - kind: "Parameter" /* Parameter */, + kind: "Parameter" /* InlayHintKind.Parameter */, whitespaceAfter: true, }); } function addTypeHints(text, position) { result.push({ - text: ": " + truncation(text, maxHintsLength), + text: ": ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Type" /* Type */, + kind: "Type" /* InlayHintKind.Type */, whitespaceBefore: true, }); } function addEnumMemberValueHints(text, position) { result.push({ - text: "= " + truncation(text, maxHintsLength), + text: "= ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Enum" /* Enum */, + kind: "Enum" /* InlayHintKind.Enum */, whitespaceBefore: true, }); } @@ -145990,7 +146717,7 @@ var ts; } } function isModuleReferenceType(type) { - return type.symbol && (type.symbol.flags & 1536 /* Module */); + return type.symbol && (type.symbol.flags & 1536 /* SymbolFlags.Module */); } function visitVariableLikeDeclaration(decl) { if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) { @@ -146066,17 +146793,17 @@ var ts; } function isHintableLiteral(node) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; return ts.isLiteralExpression(operand) || ts.isIdentifier(operand) && ts.isInfinityOrNaNString(operand.escapedText); } - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var name = node.escapedText; return isUndefined(name) || ts.isInfinityOrNaNString(name); } @@ -146085,7 +146812,7 @@ var ts; } function visitFunctionDeclarationLikeForReturnType(decl) { if (ts.isArrowFunction(decl)) { - if (!ts.findChildOfKind(decl, 20 /* OpenParenToken */, file)) { + if (!ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, file)) { return; } } @@ -146108,7 +146835,7 @@ var ts; addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl)); } function getTypeAnnotationPosition(decl) { - var closeParenToken = ts.findChildOfKind(decl, 21 /* CloseParenToken */, file); + var closeParenToken = ts.findChildOfKind(decl, 21 /* SyntaxKind.CloseParenToken */, file); if (closeParenToken) { return closeParenToken.end; } @@ -146153,13 +146880,13 @@ var ts; return text; } function printTypeInSingleLine(type) { - var flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var flags = 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; var options = { removeComments: true }; var printer = ts.createPrinter(options); return ts.usingSingleLineStringWriter(function (writer) { var typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer); ts.Debug.assertIsDefined(typeNode, "should always get typenode"); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ file, writer); }); } function isUndefined(name) { @@ -146228,7 +146955,7 @@ var ts; var options = program.getCompilerOptions(); var outPath = ts.outFile(options); var declarationPath = outPath ? - ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; @@ -146337,7 +147064,7 @@ var ts; program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; var checker = program.getTypeChecker(); - var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]); + var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]); if (!isCommonJSFile && sourceFile.commonJsModuleIndicator && (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) && @@ -146373,7 +147100,7 @@ var ts; else { if (ts.isVariableStatement(node) && node.parent === sourceFile && - node.declarationList.flags & 2 /* Const */ && + node.declarationList.flags & 2 /* NodeFlags.Const */ && node.declarationList.declarations.length === 1) { var init = node.declarationList.declarations[0].initializer; if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { @@ -146395,16 +147122,16 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); var kind = ts.getAssignmentDeclarationKind(expression); - return kind === 1 /* ExportsProperty */ || kind === 2 /* ModuleExports */; + return kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ || kind === 2 /* AssignmentDeclarationKind.ModuleExports */; } default: return false; @@ -146416,12 +147143,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -146491,26 +147218,26 @@ var ts; if (node.arguments.length < maxArguments) return true; return maxArguments === 1 || ts.some(node.arguments, function (arg) { - return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; + return arg.kind === 104 /* SyntaxKind.NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var functionFlags = ts.getFunctionFlags(arg); - if (functionFlags & 1 /* Generator */) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { return false; } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return true; - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: { + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: { var symbol = checker.getSymbolAtLocation(arg); if (!symbol) { return false; @@ -146523,28 +147250,28 @@ var ts; } } function getKeyFromNode(exp) { - return exp.pos.toString() + ":" + exp.end.toString(); + return "".concat(exp.pos.toString(), ":").concat(exp.end.toString()); } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 213 /* FunctionExpression */) { + if (node.kind === 213 /* SyntaxKind.FunctionExpression */) { if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) { return true; } var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false); return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size))); } - if (node.kind === 256 /* FunctionDeclaration */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } function canBeConvertedToAsync(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -146557,32 +147284,32 @@ var ts; (function (ts) { var SymbolDisplay; (function (SymbolDisplay) { - var symbolDisplayNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var symbolDisplayNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(typeChecker, symbol, location) { var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result !== "" /* unknown */) { + if (result !== "" /* ScriptElementKind.unknown */) { return result; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; - } - if (flags & 384 /* Enum */) - return "enum" /* enumElement */; - if (flags & 524288 /* TypeAlias */) - return "type" /* typeElement */; - if (flags & 64 /* Interface */) - return "interface" /* interfaceElement */; - if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; - if (flags & 8 /* EnumMember */) - return "enum member" /* enumMemberElement */; - if (flags & 2097152 /* Alias */) - return "alias" /* alias */; - if (flags & 1536 /* Module */) - return "module" /* moduleElement */; + if (flags & 32 /* SymbolFlags.Class */) { + return ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */) ? + "local class" /* ScriptElementKind.localClassElement */ : "class" /* ScriptElementKind.classElement */; + } + if (flags & 384 /* SymbolFlags.Enum */) + return "enum" /* ScriptElementKind.enumElement */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + return "type" /* ScriptElementKind.typeElement */; + if (flags & 64 /* SymbolFlags.Interface */) + return "interface" /* ScriptElementKind.interfaceElement */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + return "type parameter" /* ScriptElementKind.typeParameterElement */; + if (flags & 8 /* SymbolFlags.EnumMember */) + return "enum member" /* ScriptElementKind.enumMemberElement */; + if (flags & 2097152 /* SymbolFlags.Alias */) + return "alias" /* ScriptElementKind.alias */; + if (flags & 1536 /* SymbolFlags.Module */) + return "module" /* ScriptElementKind.moduleElement */; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; @@ -146590,52 +147317,52 @@ var ts; var roots = typeChecker.getRootSymbols(symbol); // If this is a method from a mapped type, leave as a method so long as it still has a call signature. if (roots.length === 1 - && ts.first(roots).flags & 8192 /* Method */ + && ts.first(roots).flags & 8192 /* SymbolFlags.Method */ // Ensure the mapped version is still a method, as opposed to `{ [K in keyof I]: number }`. && typeChecker.getTypeOfSymbolAtLocation(symbol, location).getNonNullableType().getCallSignatures().length !== 0) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } if (typeChecker.isUndefinedSymbol(symbol)) { - return "var" /* variableElement */; + return "var" /* ScriptElementKind.variableElement */; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var" /* localVariableElement */; + return "local var" /* ScriptElementKind.localVariableElement */; } - if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { - return "parameter" /* parameterElement */; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { + return "parameter" /* ScriptElementKind.parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter" /* parameterElement */; + return "parameter" /* ScriptElementKind.parameterElement */; } else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { - return "const" /* constElement */; + return "const" /* ScriptElementKind.constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let" /* letElement */; + return "let" /* ScriptElementKind.letElement */; } - return isLocalVariableOrFunction(symbol) ? "local var" /* localVariableElement */ : "var" /* variableElement */; + return isLocalVariableOrFunction(symbol) ? "local var" /* ScriptElementKind.localVariableElement */ : "var" /* ScriptElementKind.variableElement */; } - if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */; + if (flags & 16 /* SymbolFlags.Function */) + return isLocalVariableOrFunction(symbol) ? "local function" /* ScriptElementKind.localFunctionElement */ : "function" /* ScriptElementKind.functionElement */; // FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag. // So, even when the location is just on the declaration of setter, this function returns getter. - if (flags & 32768 /* GetAccessor */) - return "getter" /* memberGetAccessorElement */; - if (flags & 65536 /* SetAccessor */) - return "setter" /* memberSetAccessorElement */; - if (flags & 8192 /* Method */) - return "method" /* memberFunctionElement */; - if (flags & 16384 /* Constructor */) - return "constructor" /* constructorImplementationElement */; - if (flags & 4 /* Property */) { - if (flags & 33554432 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { + if (flags & 32768 /* SymbolFlags.GetAccessor */) + return "getter" /* ScriptElementKind.memberGetAccessorElement */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + return "setter" /* ScriptElementKind.memberSetAccessorElement */; + if (flags & 8192 /* SymbolFlags.Method */) + return "method" /* ScriptElementKind.memberFunctionElement */; + if (flags & 16384 /* SymbolFlags.Constructor */) + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + if (flags & 4 /* SymbolFlags.Property */) { + if (flags & 33554432 /* SymbolFlags.Transient */ && symbol.checkFlags & 6 /* CheckFlags.Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return "property" /* memberVariableElement */; + if (rootSymbolFlags & (98308 /* SymbolFlags.PropertyOrAccessor */ | 3 /* SymbolFlags.Variable */)) { + return "property" /* ScriptElementKind.memberVariableElement */; } }); if (!unionPropertyKind) { @@ -146643,23 +147370,23 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } return unionPropertyKind; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getNormalizedSymbolModifiers(symbol) { if (symbol.declarations && symbol.declarations.length) { var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* ModifierFlags.Deprecated */ + : 0 /* ModifierFlags.None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -146669,10 +147396,10 @@ var ts; } function getSymbolModifiers(typeChecker, symbol) { if (!symbol) { - return "" /* none */; + return "" /* ScriptElementKindModifier.none */; } var modifiers = new ts.Set(getNormalizedSymbolModifiers(symbol)); - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); if (resolvedSymbol !== symbol) { ts.forEach(getNormalizedSymbolModifiers(resolvedSymbol), function (modifier) { @@ -146680,10 +147407,10 @@ var ts; }); } } - if (symbol.flags & 16777216 /* Optional */) { - modifiers.add("optional" /* optionalModifier */); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + modifiers.add("optional" /* ScriptElementKindModifier.optionalModifier */); } - return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* none */; + return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* ScriptElementKindModifier.none */; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location @@ -146694,41 +147421,41 @@ var ts; var documentation = []; var tags = []; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; + var symbolKind = semanticMeaning & 1 /* SemanticMeaning.Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* ScriptElementKind.unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); + var isThisExpression = location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* ScriptElementKind.primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */ || symbolFlags & 32 /* SymbolFlags.Class */ || symbolFlags & 2097152 /* SymbolFlags.Alias */) { // If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor - if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) { + if (symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */) { var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; }); if (declaration) { switch (declaration.kind) { - case 172 /* GetAccessor */: - symbolKind = "getter" /* memberGetAccessorElement */; + case 172 /* SyntaxKind.GetAccessor */: + symbolKind = "getter" /* ScriptElementKind.memberGetAccessorElement */; break; - case 173 /* SetAccessor */: - symbolKind = "setter" /* memberSetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: + symbolKind = "setter" /* ScriptElementKind.memberSetAccessorElement */; break; default: ts.Debug.assertNever(declaration); } } else { - symbolKind = "property" /* memberVariableElement */; + symbolKind = "property" /* ScriptElementKind.memberVariableElement */; } } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (location.parent && location.parent.kind === 206 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -146748,7 +147475,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 209 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 209 /* SyntaxKind.NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SyntaxKind.SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -146756,21 +147483,21 @@ var ts; signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + if (useConstructSignatures && (symbolFlags & 32 /* SymbolFlags.Class */)) { // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - else if (symbolFlags & 2097152 /* Alias */) { - symbolKind = "alias" /* alias */; + else if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + symbolKind = "alias" /* ScriptElementKind.alias */; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -146779,29 +147506,29 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: + case "JSX attribute" /* ScriptElementKind.jsxAttribute */: + case "property" /* ScriptElementKind.memberVariableElement */: + case "var" /* ScriptElementKind.variableElement */: + case "const" /* ScriptElementKind.constElement */: + case "let" /* ScriptElementKind.letElement */: + case "parameter" /* ScriptElementKind.parameterElement */: + case "local var" /* ScriptElementKind.localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); - if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); + if (!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* SymbolFormatFlags.AllowAnyNodeKind */ | 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); + addSignatureDisplayParts(signature, allSignatures, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */); break; default: // Just signature @@ -146811,31 +147538,31 @@ var ts; hasMultipleSignatures = allSignatures.length > 1; } } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 134 /* ConstructorKeyword */ && location.parent.kind === 171 /* Constructor */)) { // At constructor keyword of constructor declaration + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* SymbolFlags.Accessor */)) || // name of function declaration + (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ && location.parent.kind === 171 /* SyntaxKind.Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 134 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 171 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 171 /* Constructor */) { + if (functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */) { // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* SyntaxKind.CallSignature */ && + !(type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ || type.symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */) ? type.symbol : symbol, symbolKind); } if (signature) { addSignatureDisplayParts(signature, allSignatures); @@ -146845,63 +147572,63 @@ var ts; } } } - if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { + if (symbolFlags & 32 /* SymbolFlags.Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushSymbolKind("local class" /* localClassElement */); + pushSymbolKind("local class" /* ScriptElementKind.localClassElement */); } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* SyntaxKind.ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 64 /* SymbolFlags.Interface */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* SyntaxKind.InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 524288 /* SymbolFlags.TypeAlias */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* TypeFormatFlags.InTypeAlias */)); } - if (symbolFlags & 384 /* Enum */) { + if (symbolFlags & 384 /* SymbolFlags.Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* SyntaxKind.ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* SyntaxKind.EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if (symbolFlags & 1536 /* Module */ && !isThisExpression) { + if (symbolFlags & 1536 /* SymbolFlags.Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 261 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 142 /* NamespaceKeyword */ : 141 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 261 /* SyntaxKind.ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* SyntaxKind.Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 142 /* SyntaxKind.NamespaceKeyword */ : 141 /* SyntaxKind.ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 262144 /* SymbolFlags.TypeParameter */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -146912,7 +147639,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 163 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -146920,21 +147647,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 175 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + if (declaration.kind === 175 /* SyntaxKind.ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 174 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 174 /* SyntaxKind.CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 259 /* TypeAliasDeclaration */) { + else if (declaration.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -146942,22 +147669,22 @@ var ts; } } } - if (symbolFlags & 8 /* EnumMember */) { - symbolKind = "enum member" /* enumMemberElement */; + if (symbolFlags & 8 /* SymbolFlags.EnumMember */) { + symbolKind = "enum member" /* ScriptElementKind.enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; - if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* EnumMember */) { + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* SyntaxKind.EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } } } // don't use symbolFlags since getAliasedSymbol requires the flag on the symbol itself - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { prefixNextMeaning(); if (!hasAddedSymbolInfo) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); @@ -146966,7 +147693,7 @@ var ts; var declarationName = ts.getNameOfDeclaration(resolvedNode); if (declarationName) { var isExternalModuleDeclaration = ts.isModuleWithStringLiteralName(resolvedNode) && - ts.hasSyntacticModifier(resolvedNode, 2 /* Ambient */); + ts.hasSyntacticModifier(resolvedNode, 2 /* ModifierFlags.Ambient */); var shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration; var resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, resolvedSymbol, ts.getSourceFileOfNode(resolvedNode), resolvedNode, declarationName, semanticMeaning, shouldUseAliasName ? symbol : resolvedSymbol); displayParts.push.apply(displayParts, resolvedInfo.displayParts); @@ -146982,42 +147709,42 @@ var ts; } if (symbol.declarations) { switch (symbol.declarations[0].kind) { - case 264 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(142 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(142 /* SyntaxKind.NamespaceKeyword */)); break; - case 271 /* ExportAssignment */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 271 /* SyntaxKind.ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* SyntaxKind.EqualsToken */ : 88 /* SyntaxKind.DefaultKeyword */)); break; - case 275 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 275 /* SyntaxKind.ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(100 /* SyntaxKind.ImportKeyword */)); } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(146 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(146 /* SyntaxKind.RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -147027,30 +147754,30 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "" /* unknown */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */) { if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === "property" /* memberVariableElement */ || - symbolKind === "getter" /* memberGetAccessorElement */ || - symbolKind === "setter" /* memberSetAccessorElement */ || - symbolKind === "JSX attribute" /* jsxAttribute */ || - symbolFlags & 3 /* Variable */ || - symbolKind === "local var" /* localVariableElement */ || + if (symbolKind === "property" /* ScriptElementKind.memberVariableElement */ || + symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || + symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */ || + symbolKind === "JSX attribute" /* ScriptElementKind.jsxAttribute */ || + symbolFlags & 3 /* SymbolFlags.Variable */ || + symbolKind === "local var" /* ScriptElementKind.localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially - if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + if (type.symbol && type.symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeNode(4 /* EmitHint.Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -147061,17 +147788,17 @@ var ts; var labelDecl = symbol.target.tupleLabelDeclaration; ts.Debug.assertNode(labelDecl.name, ts.isIdentifier); displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart(ts.idText(labelDecl.name))); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } } - else if (symbolFlags & 16 /* Function */ || - symbolFlags & 8192 /* Method */ || - symbolFlags & 16384 /* Constructor */ || - symbolFlags & 131072 /* Signature */ || - symbolFlags & 98304 /* Accessor */ || - symbolKind === "method" /* memberFunctionElement */) { + else if (symbolFlags & 16 /* SymbolFlags.Function */ || + symbolFlags & 8192 /* SymbolFlags.Method */ || + symbolFlags & 16384 /* SymbolFlags.Constructor */ || + symbolFlags & 131072 /* SymbolFlags.Signature */ || + symbolFlags & 98304 /* SymbolFlags.Accessor */ || + symbolKind === "method" /* ScriptElementKind.memberFunctionElement */) { var allSignatures = type.getNonNullableType().getCallSignatures(); if (allSignatures.length) { addSignatureDisplayParts(allSignatures[0], allSignatures); @@ -147087,14 +147814,14 @@ var ts; if (documentation.length === 0 && !hasMultipleSignatures) { documentation = symbol.getContextualDocumentationComment(enclosingDeclaration, typeChecker); } - if (documentation.length === 0 && symbolFlags & 4 /* Property */) { + if (documentation.length === 0 && symbolFlags & 4 /* SymbolFlags.Property */) { // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SourceFile */; })) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SyntaxKind.SourceFile */; })) { for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (!declaration.parent || declaration.parent.kind !== 221 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -147145,23 +147872,23 @@ var ts; } function addAliasPrefixIfNecessary() { if (alias) { - pushSymbolKind("alias" /* alias */); + pushSymbolKind("alias" /* ScriptElementKind.alias */); displayParts.push(ts.spacePart()); } } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(101 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* SyntaxKind.InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { if (alias && symbolToDisplay === symbol) { symbolToDisplay = alias; } - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */ | 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); - if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + displayParts.push(ts.punctuationPart(57 /* SyntaxKind.QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -147176,31 +147903,31 @@ var ts; } function pushSymbolKind(symbolKind) { switch (symbolKind) { - case "var" /* variableElement */: - case "function" /* functionElement */: - case "let" /* letElement */: - case "const" /* constElement */: - case "constructor" /* constructorImplementationElement */: + case "var" /* ScriptElementKind.variableElement */: + case "function" /* ScriptElementKind.functionElement */: + case "let" /* ScriptElementKind.letElement */: + case "const" /* ScriptElementKind.constElement */: + case "constructor" /* ScriptElementKind.constructorImplementationElement */: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); return; } } function addSignatureDisplayParts(signature, allSignatures, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(39 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); + displayParts.push(ts.operatorPart(39 /* SyntaxKind.PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } documentation = signature.getDocumentationComment(typeChecker); tags = signature.getJsDocTags(); @@ -147212,7 +147939,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* ListFormat.TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -147224,16 +147951,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 213 /* FunctionExpression */) { + if (declaration.kind === 213 /* SyntaxKind.FunctionExpression */) { return true; } - if (declaration.kind !== 254 /* VariableDeclaration */ && declaration.kind !== 256 /* FunctionDeclaration */) { + if (declaration.kind !== 254 /* SyntaxKind.VariableDeclaration */ && declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 305 /* SourceFile */ || parent.kind === 262 /* ModuleBlock */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ || parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return false; } } @@ -147342,7 +148069,7 @@ var ts; commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_9 = function (opt) { + var _loop_8 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -147361,7 +148088,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_9(opt); + _loop_8(opt); } return options; } @@ -147438,8 +148165,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* SyntaxKind.OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* SyntaxKind.CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -147457,8 +148184,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); + var jsxScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 1 /* LanguageVariant.JSX */); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -147470,7 +148197,7 @@ var ts; ScanAction[ScanAction["RescanJsxAttributeValue"] = 6] = "RescanJsxAttributeValue"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { - var scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + var scanner = languageVariant === 1 /* LanguageVariant.JSX */ ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -147498,7 +148225,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* SyntaxKind.NewLineTrivia */; } else { scanner.scan(); @@ -147526,11 +148253,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 33 /* GreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return true; } return false; @@ -147538,12 +148265,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 285 /* JsxAttribute */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 285 /* SyntaxKind.JsxAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* SyntaxKind.Identifier */; } } return false; @@ -147552,29 +148279,29 @@ var ts; return ts.isJsxText(node); } function shouldRescanSlashToken(container) { - return container.kind === 13 /* RegularExpressionLiteral */; + return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 16 /* TemplateMiddle */ || - container.kind === 17 /* TemplateTail */; + return container.kind === 16 /* SyntaxKind.TemplateMiddle */ || + container.kind === 17 /* SyntaxKind.TemplateTail */; } function shouldRescanJsxAttributeValue(node) { return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; + return t === 43 /* SyntaxKind.SlashToken */ || t === 68 /* SyntaxKind.SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : - shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : - shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : - shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : - shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* ScanAction.RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* ScanAction.RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* ScanAction.RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* ScanAction.RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* ScanAction.RescanJsxText */ : + shouldRescanJsxAttributeValue(n) ? 6 /* ScanAction.RescanJsxAttributeValue */ : + 0 /* ScanAction.Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -147606,7 +148333,7 @@ var ts; trailingTrivia = []; } trailingTrivia.push(trivia); - if (currentToken === 4 /* NewLineTrivia */) { + if (currentToken === 4 /* SyntaxKind.NewLineTrivia */) { // move past new line scanner.scan(); break; @@ -147617,40 +148344,40 @@ var ts; } function getNextToken(n, expectedScanAction) { var token = scanner.getToken(); - lastScanAction = 0 /* Scan */; + lastScanAction = 0 /* ScanAction.Scan */; switch (expectedScanAction) { - case 1 /* RescanGreaterThanToken */: - if (token === 31 /* GreaterThanToken */) { - lastScanAction = 1 /* RescanGreaterThanToken */; + case 1 /* ScanAction.RescanGreaterThanToken */: + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + lastScanAction = 1 /* ScanAction.RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 2 /* RescanSlashToken */: + case 2 /* ScanAction.RescanSlashToken */: if (startsWithSlashToken(token)) { - lastScanAction = 2 /* RescanSlashToken */; + lastScanAction = 2 /* ScanAction.RescanSlashToken */; var newToken = scanner.reScanSlashToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 3 /* RescanTemplateToken */: - if (token === 19 /* CloseBraceToken */) { - lastScanAction = 3 /* RescanTemplateToken */; + case 3 /* ScanAction.RescanTemplateToken */: + if (token === 19 /* SyntaxKind.CloseBraceToken */) { + lastScanAction = 3 /* ScanAction.RescanTemplateToken */; return scanner.reScanTemplateToken(/* isTaggedTemplate */ false); } break; - case 4 /* RescanJsxIdentifier */: - lastScanAction = 4 /* RescanJsxIdentifier */; + case 4 /* ScanAction.RescanJsxIdentifier */: + lastScanAction = 4 /* ScanAction.RescanJsxIdentifier */; return scanner.scanJsxIdentifier(); - case 5 /* RescanJsxText */: - lastScanAction = 5 /* RescanJsxText */; + case 5 /* ScanAction.RescanJsxText */: + lastScanAction = 5 /* ScanAction.RescanJsxText */; return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); - case 6 /* RescanJsxAttributeValue */: - lastScanAction = 6 /* RescanJsxAttributeValue */; + case 6 /* ScanAction.RescanJsxAttributeValue */: + lastScanAction = 6 /* ScanAction.RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); - case 0 /* Scan */: + case 0 /* ScanAction.Scan */: break; default: ts.Debug.assertNever(expectedScanAction); @@ -147659,15 +148386,15 @@ var ts; } function readEOFTokenRange() { ts.Debug.assert(isOnEOF()); - return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* SyntaxKind.EndOfFileToken */); } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); + return current !== 1 /* SyntaxKind.EndOfFileToken */ && !ts.isTrivia(current); } function isOnEOF() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current === 1 /* EndOfFileToken */; + return current === 1 /* SyntaxKind.EndOfFileToken */; } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, @@ -147734,8 +148461,8 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 160 /* LastToken */; token++) { - if (token !== 1 /* EndOfFileToken */) { + for (var token = 0 /* SyntaxKind.FirstToken */; token <= 160 /* SyntaxKind.LastToken */; token++) { + if (token !== 1 /* SyntaxKind.EndOfFileToken */) { allTokens.push(token); } } @@ -147747,263 +148474,263 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* MultiLineCommentTrivia */], false)); - var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* EndOfFileToken */], false)); - var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 160 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); - var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 160 /* OfKeyword */, 127 /* AsKeyword */, 139 /* IsKeyword */]; - var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* SyntaxKind.MultiLineCommentTrivia */], false)); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* SyntaxKind.EndOfFileToken */], false)); + var keywords = tokenRangeFromRange(81 /* SyntaxKind.FirstKeyword */, 160 /* SyntaxKind.LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* SyntaxKind.FirstBinaryOperator */, 78 /* SyntaxKind.LastBinaryOperator */); + var binaryKeywordOperators = [101 /* SyntaxKind.InKeyword */, 102 /* SyntaxKind.InstanceOfKeyword */, 160 /* SyntaxKind.OfKeyword */, 127 /* SyntaxKind.AsKeyword */, 139 /* SyntaxKind.IsKeyword */]; + var unaryPrefixOperators = [45 /* SyntaxKind.PlusPlusToken */, 46 /* SyntaxKind.MinusMinusToken */, 54 /* SyntaxKind.TildeToken */, 53 /* SyntaxKind.ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ + 8 /* SyntaxKind.NumericLiteral */, 9 /* SyntaxKind.BigIntLiteral */, 79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, + 22 /* SyntaxKind.OpenBracketToken */, 18 /* SyntaxKind.OpenBraceToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */ ]; - var unaryPreincrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostincrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var unaryPredecrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostdecrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords, true); + var unaryPreincrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostincrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPredecrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostdecrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var comments = [2 /* SyntaxKind.SingleLineCommentTrivia */, 3 /* SyntaxKind.MultiLineCommentTrivia */]; + var typeNames = __spreadArray([79 /* SyntaxKind.Identifier */], ts.typeKeywords, true); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* SyntaxKind.Identifier */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 84 /* SyntaxKind.ClassKeyword */, 93 /* SyntaxKind.ExportKeyword */, 100 /* SyntaxKind.ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* SyntaxKind.CloseParenToken */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 90 /* SyntaxKind.DoKeyword */, 111 /* SyntaxKind.TryKeyword */, 96 /* SyntaxKind.FinallyKeyword */, 91 /* SyntaxKind.ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), - rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SyntaxKind.SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* SyntaxKind.ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterColon", 58 /* SyntaxKind.ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* SyntaxKind.QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* RuleAction.InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterQuestionMark", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* SyntaxKind.ImportKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* RuleAction.DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* SyntaxKind.PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* SyntaxKind.MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* SyntaxKind.PlusPlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* SyntaxKind.PlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* SyntaxKind.PlusToken */, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* SyntaxKind.MinusMinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* SyntaxKind.MinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* SyntaxKind.MinusToken */, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, [27 /* SyntaxKind.CommaToken */, 26 /* SyntaxKind.SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* SyntaxKind.CloseBraceToken */, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), + rule("SpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, anyTokenExcept(21 /* SyntaxKind.CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* RuleAction.InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 91 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 115 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* SyntaxKind.CloseBraceToken */, 91 /* SyntaxKind.ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* SyntaxKind.CloseBraceToken */, 115 /* SyntaxKind.WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 79 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 98 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterConditionalClosingParen", 21 /* SyntaxKind.CloseParenToken */, 22 /* SyntaxKind.OpenBracketToken */, [isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* SyntaxKind.AsteriskToken */, 79 /* SyntaxKind.Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 98 /* SyntaxKind.FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [136 /* GetKeyword */, 149 /* SetKeyword */], 79 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 105 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [113 /* VarKeyword */, 109 /* ThrowKeyword */, 103 /* NewKeyword */, 89 /* DeleteKeyword */, 105 /* ReturnKeyword */, 112 /* TypeOfKeyword */, 132 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [119 /* LetKeyword */, 85 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), + rule("SpaceAfterGetSetInMember", [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */], 79 /* SyntaxKind.Identifier */, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 105 /* SyntaxKind.ReturnKeyword */, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterCertainKeywords", [113 /* SyntaxKind.VarKeyword */, 109 /* SyntaxKind.ThrowKeyword */, 103 /* SyntaxKind.NewKeyword */, 89 /* SyntaxKind.DeleteKeyword */, 105 /* SyntaxKind.ReturnKeyword */, 112 /* SyntaxKind.TypeOfKeyword */, 132 /* SyntaxKind.AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [119 /* SyntaxKind.LetKeyword */, 85 /* SyntaxKind.ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* RuleAction.DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* SyntaxKind.VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* RuleAction.InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 131 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 131 /* SyntaxKind.AsyncKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* SyntaxKind.AsyncKeyword */, [98 /* SyntaxKind.FunctionKeyword */, 79 /* SyntaxKind.Identifier */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */], [14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, 15 /* SyntaxKind.TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 79 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeJsxAttribute", anyToken, 79 /* SyntaxKind.Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SyntaxKind.SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SyntaxKind.SlashToken */, 31 /* SyntaxKind.GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* SyntaxKind.EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* SyntaxKind.EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [141 /* ModuleKeyword */, 146 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [141 /* SyntaxKind.ModuleKeyword */, 146 /* SyntaxKind.RequireKeyword */], 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 126 /* AbstractKeyword */, - 84 /* ClassKeyword */, - 135 /* DeclareKeyword */, - 88 /* DefaultKeyword */, - 92 /* EnumKeyword */, - 93 /* ExportKeyword */, - 94 /* ExtendsKeyword */, - 136 /* GetKeyword */, - 117 /* ImplementsKeyword */, - 100 /* ImportKeyword */, - 118 /* InterfaceKeyword */, - 141 /* ModuleKeyword */, - 142 /* NamespaceKeyword */, - 121 /* PrivateKeyword */, - 123 /* PublicKeyword */, - 122 /* ProtectedKeyword */, - 145 /* ReadonlyKeyword */, - 149 /* SetKeyword */, - 124 /* StaticKeyword */, - 152 /* TypeKeyword */, - 156 /* FromKeyword */, - 140 /* KeyOfKeyword */, - 137 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 156 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 135 /* SyntaxKind.DeclareKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 92 /* SyntaxKind.EnumKeyword */, + 93 /* SyntaxKind.ExportKeyword */, + 94 /* SyntaxKind.ExtendsKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 117 /* SyntaxKind.ImplementsKeyword */, + 100 /* SyntaxKind.ImportKeyword */, + 118 /* SyntaxKind.InterfaceKeyword */, + 141 /* SyntaxKind.ModuleKeyword */, + 142 /* SyntaxKind.NamespaceKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 152 /* SyntaxKind.TypeKeyword */, + 156 /* SyntaxKind.FromKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 137 /* SyntaxKind.InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* SyntaxKind.ExtendsKeyword */, 117 /* SyntaxKind.ImplementsKeyword */, 156 /* SyntaxKind.FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterModuleName", 10 /* SyntaxKind.StringLiteral */, 18 /* SyntaxKind.OpenBraceToken */, [isModuleDeclContext], 4 /* RuleAction.InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeArrow", anyToken, 38 /* SyntaxKind.EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterArrow", 38 /* SyntaxKind.EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* SyntaxKind.DotDotDotToken */, 79 /* SyntaxKind.Identifier */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* SyntaxKind.QuestionToken */, [21 /* SyntaxKind.CloseParenToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* RuleAction.DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* SyntaxKind.CloseParenToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* SyntaxKind.LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* SyntaxKind.GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* SyntaxKind.GreaterThanToken */, [20 /* SyntaxKind.OpenParenToken */, 22 /* SyntaxKind.OpenBracketToken */, 31 /* SyntaxKind.GreaterThanToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* RuleAction.DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeAt", [21 /* SyntaxKind.CloseParenToken */, 79 /* SyntaxKind.Identifier */], 59 /* SyntaxKind.AtToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAt", 59 /* SyntaxKind.AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 126 /* AbstractKeyword */, - 79 /* Identifier */, - 93 /* ExportKeyword */, - 88 /* DefaultKeyword */, - 84 /* ClassKeyword */, - 124 /* StaticKeyword */, - 123 /* PublicKeyword */, - 121 /* PrivateKeyword */, - 122 /* ProtectedKeyword */, - 136 /* GetKeyword */, - 149 /* SetKeyword */, - 22 /* OpenBracketToken */, - 41 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 79 /* SyntaxKind.Identifier */, + 93 /* SyntaxKind.ExportKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 22 /* SyntaxKind.OpenBracketToken */, + 41 /* SyntaxKind.AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* SyntaxKind.ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* SyntaxKind.NewKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* SyntaxKind.LessThanToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* RuleAction.DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* SyntaxKind.OpenParenToken */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after opening and before closing empty brace brackets - rule("SpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* DeleteSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* RuleAction.DeleteSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* RuleAction.DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), - rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), - rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), - rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* RuleAction.DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* RuleAction.InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* SyntaxKind.CommaToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* AsyncKeyword */, 82 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* SyntaxKind.AsyncKeyword */, 82 /* SyntaxKind.CaseKeyword */), 22 /* SyntaxKind.OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* SyntaxKind.CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 132 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* SyntaxKind.ForKeyword */, 132 /* SyntaxKind.AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* SyntaxKind.CloseParenToken */, 90 /* SyntaxKind.DoKeyword */, 91 /* SyntaxKind.ElseKeyword */, 82 /* SyntaxKind.CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* RuleAction.InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* SyntaxKind.TryKeyword */, 83 /* SyntaxKind.CatchKeyword */, 96 /* SyntaxKind.FinallyKeyword */], 18 /* SyntaxKind.OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules, true), userConfigurableRules, true), lowPriorityCommonRules, true); } @@ -148021,7 +148748,7 @@ var ts; * @param flags whether the rule deletes a line or not, defaults to no-op */ function rule(debugName, left, right, context, action, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* RuleFlags.None */; } return { leftTokenRange: toTokenRange(left), rightTokenRange: toTokenRange(right), rule: { debugName: debugName, context: context, action: action, flags: flags } }; } function tokenRangeFrom(tokens) { @@ -148062,54 +148789,54 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 242 /* ForStatement */; + return context.contextNode.kind === 242 /* SyntaxKind.ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 221 /* BinaryExpression */: - return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 222 /* ConditionalExpression */: - case 189 /* ConditionalType */: - case 229 /* AsExpression */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 177 /* TypePredicate */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 221 /* SyntaxKind.BinaryExpression */: + return context.contextNode.operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; + case 222 /* SyntaxKind.ConditionalExpression */: + case 189 /* SyntaxKind.ConditionalType */: + case 229 /* SyntaxKind.AsExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 177 /* SyntaxKind.TypePredicate */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // equals in type X = ... // falls through - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // equal in export = 1 // falls through - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // equal in let a = 0 // falls through - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // equal in p = 0 // falls through - case 164 /* Parameter */: - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 164 /* SyntaxKind.Parameter */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // "in" keyword in for (let x in []) { } - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 163 /* TypeParameter */: - return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 163 /* SyntaxKind.TypeParameter */: + return context.currentTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.nextTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 244 /* ForOfStatement */: - return context.currentTokenSpan.kind === 160 /* OfKeyword */ || context.nextTokenSpan.kind === 160 /* OfKeyword */; + case 244 /* SyntaxKind.ForOfStatement */: + return context.currentTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */ || context.nextTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */; } return false; } @@ -148121,22 +148848,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 167 /* PropertyDeclaration */ || - contextKind === 166 /* PropertySignature */ || - contextKind === 164 /* Parameter */ || - contextKind === 254 /* VariableDeclaration */ || + return contextKind === 167 /* SyntaxKind.PropertyDeclaration */ || + contextKind === 166 /* SyntaxKind.PropertySignature */ || + contextKind === 164 /* SyntaxKind.Parameter */ || + contextKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 222 /* ConditionalExpression */ || - context.contextNode.kind === 189 /* ConditionalType */; + return context.contextNode.kind === 222 /* SyntaxKind.ConditionalExpression */ || + context.contextNode.kind === 189 /* SyntaxKind.ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 201 /* ObjectBindingPattern */ || - context.contextNode.kind === 195 /* MappedType */ || + return context.contextNode.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || + context.contextNode.kind === 195 /* SyntaxKind.MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -148162,34 +148889,34 @@ var ts; return true; } switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 205 /* ObjectLiteralExpression */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 262 /* SyntaxKind.ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 174 /* CallSignature */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 258 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 258 /* SyntaxKind.InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -148198,40 +148925,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 256 /* FunctionDeclaration */ || context.contextNode.kind === 213 /* FunctionExpression */; + return context.contextNode.kind === 256 /* SyntaxKind.FunctionDeclaration */ || context.contextNode.kind === 213 /* SyntaxKind.FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 182 /* TypeLiteral */: - case 261 /* ModuleDeclaration */: - case 272 /* ExportDeclaration */: - case 273 /* NamedExports */: - case 266 /* ImportDeclaration */: - case 269 /* NamedImports */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 273 /* SyntaxKind.NamedExports */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 269 /* SyntaxKind.NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 292 /* CatchClause */: - case 262 /* ModuleBlock */: - case 249 /* SwitchStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 292 /* SyntaxKind.CatchClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 249 /* SyntaxKind.SwitchStatement */: return true; - case 235 /* Block */: { + case 235 /* SyntaxKind.Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 214 /* ArrowFunction */ && blockParent.kind !== 213 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 214 /* SyntaxKind.ArrowFunction */ && blockParent.kind !== 213 /* SyntaxKind.FunctionExpression */) { return true; } } @@ -148240,71 +148967,71 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 248 /* WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 248 /* SyntaxKind.WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 205 /* ObjectLiteralExpression */; + return context.contextNode.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 208 /* CallExpression */; + return context.contextNode.kind === 208 /* SyntaxKind.CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 209 /* NewExpression */; + return context.contextNode.kind === 209 /* SyntaxKind.NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 27 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* SyntaxKind.CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* SyntaxKind.CloseBracketToken */; } function isNextTokenNotCloseParen(context) { - return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; + return context.nextTokenSpan.kind !== 21 /* SyntaxKind.CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 214 /* ArrowFunction */; + return context.contextNode.kind === 214 /* SyntaxKind.ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 200 /* ImportType */; + return context.contextNode.kind === 200 /* SyntaxKind.ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxTextContext(context) { - return context.contextNode.kind !== 11 /* JsxText */; + return context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 278 /* JsxElement */ && context.contextNode.kind !== 282 /* JsxFragment */; + return context.contextNode.kind !== 278 /* SyntaxKind.JsxElement */ && context.contextNode.kind !== 282 /* SyntaxKind.JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 288 /* JsxExpression */ || context.contextNode.kind === 287 /* JsxSpreadAttribute */; + return context.contextNode.kind === 288 /* SyntaxKind.JsxExpression */ || context.contextNode.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 285 /* JsxAttribute */; + return context.nextTokenParent.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 285 /* JsxAttribute */; + return context.contextNode.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 279 /* JsxSelfClosingElement */; + return context.contextNode.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -148319,45 +149046,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 255 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { - return context.formattingRequestKind !== 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormattingRequestKind.FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 261 /* ModuleDeclaration */; + return context.contextNode.kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 182 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 182 /* SyntaxKind.TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 175 /* ConstructSignature */; + return context.contextNode.kind === 175 /* SyntaxKind.ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { + if (token.kind !== 29 /* SyntaxKind.LessThanToken */ && token.kind !== 31 /* SyntaxKind.GreaterThanToken */) { return false; } switch (parent.kind) { - case 178 /* TypeReference */: - case 211 /* TypeAssertionExpression */: - case 259 /* TypeAliasDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return true; default: return false; @@ -148368,28 +149095,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 211 /* TypeAssertionExpression */; + return context.contextNode.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 217 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* SyntaxKind.VoidKeyword */ && context.currentTokenParent.kind === 217 /* SyntaxKind.VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 224 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 224 /* SyntaxKind.YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 230 /* NonNullExpression */; + return context.contextNode.kind === 230 /* SyntaxKind.NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; default: return false; @@ -148411,15 +149138,15 @@ var ts; var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; if (startLine === endLine) { - return nextTokenKind === 19 /* CloseBraceToken */ - || nextTokenKind === 1 /* EndOfFileToken */; + return nextTokenKind === 19 /* SyntaxKind.CloseBraceToken */ + || nextTokenKind === 1 /* SyntaxKind.EndOfFileToken */; } - if (nextTokenKind === 234 /* SemicolonClassElement */ || - nextTokenKind === 26 /* SemicolonToken */) { + if (nextTokenKind === 234 /* SyntaxKind.SemicolonClassElement */ || + nextTokenKind === 26 /* SyntaxKind.SemicolonToken */) { return false; } - if (context.contextNode.kind === 258 /* InterfaceDeclaration */ || - context.contextNode.kind === 259 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + context.contextNode.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -148428,25 +149155,25 @@ var ts; // } return !ts.isPropertySignature(context.currentTokenParent) || !!context.currentTokenParent.type - || nextTokenKind !== 20 /* OpenParenToken */; + || nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */; } if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 242 /* ForStatement */ - && context.currentTokenParent.kind !== 236 /* EmptyStatement */ - && context.currentTokenParent.kind !== 234 /* SemicolonClassElement */ - && nextTokenKind !== 22 /* OpenBracketToken */ - && nextTokenKind !== 20 /* OpenParenToken */ - && nextTokenKind !== 39 /* PlusToken */ - && nextTokenKind !== 40 /* MinusToken */ - && nextTokenKind !== 43 /* SlashToken */ - && nextTokenKind !== 13 /* RegularExpressionLiteral */ - && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 223 /* TemplateExpression */ - && nextTokenKind !== 15 /* TemplateHead */ - && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ - && nextTokenKind !== 24 /* DotToken */; + return context.currentTokenParent.kind !== 242 /* SyntaxKind.ForStatement */ + && context.currentTokenParent.kind !== 236 /* SyntaxKind.EmptyStatement */ + && context.currentTokenParent.kind !== 234 /* SyntaxKind.SemicolonClassElement */ + && nextTokenKind !== 22 /* SyntaxKind.OpenBracketToken */ + && nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */ + && nextTokenKind !== 39 /* SyntaxKind.PlusToken */ + && nextTokenKind !== 40 /* SyntaxKind.MinusToken */ + && nextTokenKind !== 43 /* SyntaxKind.SlashToken */ + && nextTokenKind !== 13 /* SyntaxKind.RegularExpressionLiteral */ + && nextTokenKind !== 27 /* SyntaxKind.CommaToken */ + && nextTokenKind !== 223 /* SyntaxKind.TemplateExpression */ + && nextTokenKind !== 15 /* SyntaxKind.TemplateHead */ + && nextTokenKind !== 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* SyntaxKind.DotToken */; } function isSemicolonInsertionContext(context) { return ts.positionIsASICandidate(context.currentTokenSpan.end, context.currentTokenParent, context.sourceFile); @@ -148475,17 +149202,17 @@ var ts; */ function getRuleActionExclusion(ruleAction) { var mask = 0; - if (ruleAction & 1 /* StopProcessingSpaceActions */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 1 /* RuleAction.StopProcessingSpaceActions */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 2 /* StopProcessingTokenActions */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 2 /* RuleAction.StopProcessingTokenActions */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } - if (ruleAction & 28 /* ModifySpaceAction */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 28 /* RuleAction.ModifySpaceAction */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 96 /* ModifyTokenAction */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 96 /* RuleAction.ModifyTokenAction */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } return mask; } @@ -148534,12 +149261,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 160 /* LastKeyword */ && column <= 160 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 160 /* SyntaxKind.LastKeyword */ && column <= 160 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 160 /* LastToken */ + 1; + var mapRowLength = 160 /* SyntaxKind.LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -148565,7 +149292,7 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action & 3 /* StopAction */ ? + var position = rule.action & 3 /* RuleAction.StopAction */ ? specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : rule.context !== formatting.anyContext ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : @@ -148634,16 +149361,16 @@ var ts; // end value is exclusive so add 1 to the result end: endOfFormatSpan + 1 }; - return formatSpan(span, sourceFile, formatContext, 2 /* FormatOnEnter */); + return formatSpan(span, sourceFile, formatContext, 2 /* FormattingRequestKind.FormatOnEnter */); } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormattingRequestKind.FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -148665,12 +149392,12 @@ var ts; pos: ts.getLineStartPositionForPosition(outermostNode.getStart(sourceFile), sourceFile), end: position }; - return formatSpan(textRange, sourceFile, formatContext, 4 /* FormatOnOpeningCurlyBrace */); + return formatSpan(textRange, sourceFile, formatContext, 4 /* FormattingRequestKind.FormatOnOpeningCurlyBrace */); } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormattingRequestKind.FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, formatContext) { @@ -148678,7 +149405,7 @@ var ts; pos: 0, end: sourceFile.text.length }; - return formatSpan(span, sourceFile, formatContext, 0 /* FormatDocument */); + return formatSpan(span, sourceFile, formatContext, 0 /* FormattingRequestKind.FormatDocument */); } formatting.formatDocument = formatDocument; function formatSelection(start, end, sourceFile, formatContext) { @@ -148687,7 +149414,7 @@ var ts; pos: ts.getLineStartPositionForPosition(start, sourceFile), end: end, }; - return formatSpan(span, sourceFile, formatContext, 1 /* FormatSelection */); + return formatSpan(span, sourceFile, formatContext, 1 /* FormattingRequestKind.FormatSelection */); } formatting.formatSelection = formatSelection; /** @@ -148727,17 +149454,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 262 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 305 /* SourceFile */: - case 235 /* Block */: - case 262 /* ModuleBlock */: + return !!body && body.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -148834,11 +149561,11 @@ var ts; * to the initial indentation. */ function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1 /* Unknown */; + var previousLine = -1 /* Constants.Unknown */; var child; while (n) { var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + if (previousLine !== -1 /* Constants.Unknown */ && line !== previousLine) { break; } if (formatting.SmartIndenter.shouldIndentChildNode(options, n, child, sourceFile)) { @@ -148852,7 +149579,7 @@ var ts; } function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: node.pos, end: node.end }; - return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormattingRequestKind.FormatSelection */, function (_) { return false; }, // assume that node does not have any errors sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; @@ -148876,11 +149603,12 @@ var ts; var options = _a.options, getRules = _a.getRules, host = _a.host; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); + var previousRangeTriviaEnd; var previousRange; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine = -1 /* Unknown */; + var indentationOnLastIndentedLine = -1 /* Constants.Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -148904,10 +149632,30 @@ var ts; } } if (previousRange && formattingScanner.getStartPos() >= originalRange.end) { + // Formatting edits happen by looking at pairs of contiguous tokens (see `processPair`), + // typically inserting or deleting whitespace between them. The recursive `processNode` + // logic above bails out as soon as it encounters a token that is beyond the end of the + // range we're supposed to format (or if we reach the end of the file). But this potentially + // leaves out an edit that would occur *inside* the requested range but cannot be discovered + // without looking at one token *beyond* the end of the range: consider the line `x = { }` + // with a selection from the beginning of the line to the space inside the curly braces, + // inclusive. We would expect a format-selection would delete the space (if rules apply), + // but in order to do that, we need to process the pair ["{", "}"], but we stopped processing + // just before getting there. This block handles this trailing edit. var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() : formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token : undefined; - if (tokenInfo) { + if (tokenInfo && tokenInfo.pos === previousRangeTriviaEnd) { + // We need to check that tokenInfo and previousRange are contiguous: the `originalRange` + // may have ended in the middle of a token, which means we will have stopped formatting + // on that token, leaving `previousRange` pointing to the token before it, but already + // having moved the formatting scanner (where we just got `tokenInfo`) to the next token. + // If this happens, our supposed pair [previousRange, tokenInfo] actually straddles the + // token that intersects the end of the range we're supposed to format, so the pair will + // produce bogus edits if we try to `processPair`. Recall that the point of this logic is + // to perform a trailing edit at the end of the selection range: but there can be no valid + // edit in the middle of a token where the range ended, so if we have a non-contiguous + // pair here, we're already done and we can ignore it. var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent; processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent, /*dynamicIndentation*/ undefined); @@ -148925,7 +149673,7 @@ var ts; function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) { - if (inheritedIndentation !== -1 /* Unknown */) { + if (inheritedIndentation !== -1 /* Constants.Unknown */) { return inheritedIndentation; } } @@ -148940,7 +149688,7 @@ var ts; return baseIndentSize > column ? baseIndentSize : column; } } - return -1 /* Unknown */; + return -1 /* Constants.Unknown */; } function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { var delta = formatting.SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize : 0; @@ -148953,8 +149701,8 @@ var ts; delta: Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta) }; } - else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 20 /* OpenParenToken */ && startLine === lastIndentedLine) { + else if (inheritedIndentation === -1 /* Constants.Unknown */) { + if (node.kind === 20 /* SyntaxKind.OpenParenToken */ && startLine === lastIndentedLine) { // the is used for chaining methods formatting // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; @@ -148979,19 +149727,19 @@ var ts; return modifier.kind; } switch (node.kind) { - case 257 /* ClassDeclaration */: return 84 /* ClassKeyword */; - case 258 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; - case 256 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; - case 260 /* EnumDeclaration */: return 260 /* EnumDeclaration */; - case 172 /* GetAccessor */: return 136 /* GetKeyword */; - case 173 /* SetAccessor */: return 149 /* SetKeyword */; - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return 84 /* SyntaxKind.ClassKeyword */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return 118 /* SyntaxKind.InterfaceKeyword */; + case 256 /* SyntaxKind.FunctionDeclaration */: return 98 /* SyntaxKind.FunctionKeyword */; + case 260 /* SyntaxKind.EnumDeclaration */: return 260 /* SyntaxKind.EnumDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: return 136 /* SyntaxKind.GetKeyword */; + case 173 /* SyntaxKind.SetAccessor */: return 149 /* SyntaxKind.SetKeyword */; + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - return 41 /* AsteriskToken */; + return 41 /* SyntaxKind.AsteriskToken */; } // falls through - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -149006,12 +149754,12 @@ var ts; // .. { // // comment // } - case 19 /* CloseBraceToken */: - case 23 /* CloseBracketToken */: - case 21 /* CloseParenToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + case 21 /* SyntaxKind.CloseParenToken */: return indentation + getDelta(container); } - return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; + return tokenIndentation !== -1 /* Constants.Unknown */ ? tokenIndentation : indentation; }, // if list end token is LessThanToken '>' then its delta should be explicitly suppressed // so that LessThanToken as a binary operator can still be indented. @@ -149038,25 +149786,25 @@ var ts; function shouldAddDelta(line, kind, container) { switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 18 /* OpenBraceToken */: - case 19 /* CloseBraceToken */: - case 21 /* CloseParenToken */: - case 91 /* ElseKeyword */: - case 115 /* WhileKeyword */: - case 59 /* AtToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 21 /* SyntaxKind.CloseParenToken */: + case 91 /* SyntaxKind.ElseKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 59 /* SyntaxKind.AtToken */: return false; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: switch (container.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return false; } break; - case 22 /* OpenBracketToken */: - case 23 /* CloseBracketToken */: - if (container.kind !== 195 /* MappedType */) { + case 22 /* SyntaxKind.OpenBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + if (container.kind !== 195 /* SyntaxKind.MappedType */) { return false; } break; @@ -149091,7 +149839,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Constants.Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -149104,6 +149852,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { + ts.Debug.assert(!ts.nodeIsSynthesized(child)); if (ts.nodeIsMissing(child)) { return inheritedIndentation; } @@ -149114,10 +149863,10 @@ var ts; undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; } // if child is a list item - try to get its indentation, only if parent is within the original range. - var childIndentationAmount = -1 /* Unknown */; + var childIndentationAmount = -1 /* Constants.Unknown */; if (isListItem && ts.rangeContainsRange(originalRange, parent)) { childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1 /* Unknown */) { + if (childIndentationAmount !== -1 /* Constants.Unknown */) { inheritedIndentation = childIndentationAmount; } } @@ -149153,23 +149902,24 @@ var ts; // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); // JSX text shouldn't affect indenting - if (child.kind !== 11 /* JsxText */) { + if (child.kind !== 11 /* SyntaxKind.JsxText */) { ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 165 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 165 /* SyntaxKind.Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 204 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && inheritedIndentation === -1 /* Constants.Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; } function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { ts.Debug.assert(ts.isNodeArray(nodes)); + ts.Debug.assert(!ts.nodeIsSynthesized(nodes)); var listStartToken = getOpenTokenForList(parent, nodes); var listDynamicIndentation = parentDynamicIndentation; var startLine = parentStartLine; @@ -149180,7 +149930,7 @@ var ts; } return; } - if (listStartToken !== 0 /* Unknown */) { + if (listStartToken !== 0 /* SyntaxKind.Unknown */) { // introduce a new indentation scope for lists (including list start and end tokens) while (formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); @@ -149193,7 +149943,7 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); var indentationOnListStartToken = void 0; - if (indentationOnLastIndentedLine !== -1 /* Unknown */) { + if (indentationOnLastIndentedLine !== -1 /* Constants.Unknown */) { // scanner just processed list start token so consider last indentation as list indentation // function foo(): { // last indentation was 0, list item will be indented based on this value // foo: number; @@ -149212,15 +149962,15 @@ var ts; } } } - var inheritedIndentation = -1 /* Unknown */; + var inheritedIndentation = -1 /* Constants.Unknown */; for (var i = 0; i < nodes.length; i++) { var child = nodes[i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0); } var listEndToken = getCloseTokenForOpenToken(listStartToken); - if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { + if (listEndToken !== 0 /* SyntaxKind.Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 27 /* CommaToken */) { + if (tokenInfo.token.kind === 27 /* SyntaxKind.CommaToken */) { // consume the comma consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined; @@ -149242,7 +149992,7 @@ var ts; if (currentTokenInfo.leadingTrivia) { processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); } - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); if (isTokenInRange) { @@ -149252,31 +150002,32 @@ var ts; lineAction = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); // do not indent comments\token if token range overlaps with some error if (!rangeHasError) { - if (lineAction === 0 /* None */) { + if (lineAction === 0 /* LineAction.None */) { // indent token only if end line of previous range does not match start line of the token var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; } else { - indentToken = lineAction === 1 /* LineAdded */; + indentToken = lineAction === 1 /* LineAction.LineAdded */; } } } if (currentTokenInfo.trailingTrivia) { + previousRangeTriviaEnd = ts.last(currentTokenInfo.trailingTrivia).end; processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + -1 /* Constants.Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); indentNextTokenOrTrivia = indentTriviaItems(currentTokenInfo.leadingTrivia, commentIndentation_1, indentNextTokenOrTrivia, function (item) { return insertIndentation(item.pos, commentIndentation_1, /*lineAdded*/ false); }); } // indent token only if is it is in target range and does not overlap with any error ranges - if (tokenIndentation !== -1 /* Unknown */ && indentNextTokenOrTrivia) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAdded */); + if (tokenIndentation !== -1 /* Constants.Unknown */ && indentNextTokenOrTrivia) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAction.LineAdded */); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; } @@ -149290,19 +150041,19 @@ var ts; var triviaItem = trivia_1[_i]; var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: if (triviaInRange) { indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: if (indentNextTokenOrTrivia && triviaInRange) { indentSingleLine(triviaItem); } indentNextTokenOrTrivia = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: indentNextTokenOrTrivia = true; break; } @@ -149320,7 +150071,7 @@ var ts; } function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line @@ -149333,6 +150084,7 @@ var ts; } } previousRange = range; + previousRangeTriviaEnd = range.end; previousParent = parent; previousRangeStartLine = rangeStart.line; return lineAction; @@ -149341,7 +150093,7 @@ var ts; formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); var rules = getRules(formattingContext); var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false; - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (rules) { // Apply rules in reverse order so that higher priority rules (which are first in the array) // win in a conflict with lower priority rules. @@ -149349,14 +150101,14 @@ var ts; lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); if (dynamicIndentation) { switch (lineAction) { - case 2 /* LineRemoved */: + case 2 /* LineAction.LineRemoved */: // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode); } break; - case 1 /* LineAdded */: + case 1 /* LineAction.LineAdded */: // Handle the case where token2 is moved to the new line. // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. @@ -149365,15 +150117,15 @@ var ts; } break; default: - ts.Debug.assert(lineAction === 0 /* None */); + ts.Debug.assert(lineAction === 0 /* LineAction.None */); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* RuleAction.DeleteSpace */) && rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */; }); } else { - trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* EndOfFileToken */; + trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* SyntaxKind.EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -149399,7 +150151,7 @@ var ts; function characterToColumn(startLinePosition, characterInLine) { var column = 0; for (var i = 0; i < characterInLine; i++) { - if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* tab */) { + if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* CharacterCodes.tab */) { column += options.tabSize - column % options.tabSize; } else { @@ -149530,48 +150282,48 @@ var ts; function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* StopProcessingSpaceActions */: + case 1 /* RuleAction.StopProcessingSpaceActions */: // no action required - return 0 /* None */; - case 16 /* DeleteSpace */: + return 0 /* LineAction.None */; + case 16 /* RuleAction.DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 32 /* DeleteToken */: + case 32 /* RuleAction.DeleteToken */: recordDelete(previousRange.pos, previousRange.end - previousRange.pos); break; - case 8 /* InsertNewLine */: + case 8 /* RuleAction.InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } // edit should not be applied if we have one line feed between elements var lineDelta = currentStartLine - previousStartLine; if (lineDelta !== 1) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, ts.getNewLineOrDefaultFromHost(host, options)); - return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; + return onLaterLine ? 0 /* LineAction.None */ : 1 /* LineAction.LineAdded */; } break; - case 4 /* InsertSpace */: + case 4 /* RuleAction.InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* CharacterCodes.space */) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 64 /* InsertTrailingSemicolon */: + case 64 /* RuleAction.InsertTrailingSemicolon */: recordInsert(previousRange.end, ";"); } - return 0 /* None */; + return 0 /* LineAction.None */; } } var LineAction; @@ -149613,71 +150365,71 @@ var ts; // // Internally, we represent the end of the comment at the newline and closing '/', respectively. // - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); + position === range.end && (range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.parameters === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.arguments === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 178 /* TypeReference */: - case 210 /* TaggedTemplateExpression */: - case 181 /* TypeQuery */: - case 228 /* ExpressionWithTypeArguments */: - case 200 /* ImportType */: + case 178 /* SyntaxKind.TypeReference */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 181 /* SyntaxKind.TypeQuery */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 200 /* SyntaxKind.ImportType */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 182 /* TypeLiteral */: - return 18 /* OpenBraceToken */; + case 182 /* SyntaxKind.TypeLiteral */: + return 18 /* SyntaxKind.OpenBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 20 /* OpenParenToken */: - return 21 /* CloseParenToken */; - case 29 /* LessThanToken */: - return 31 /* GreaterThanToken */; - case 18 /* OpenBraceToken */: - return 19 /* CloseBraceToken */; + case 20 /* SyntaxKind.OpenParenToken */: + return 21 /* SyntaxKind.CloseParenToken */; + case 29 /* SyntaxKind.LessThanToken */: + return 31 /* SyntaxKind.GreaterThanToken */; + case 18 /* SyntaxKind.OpenBraceToken */: + return 19 /* SyntaxKind.CloseBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } var internedSizes; var internedTabsIndentation; @@ -149763,7 +150515,7 @@ var ts; var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); // eslint-disable-next-line no-null/no-null var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); - if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -149799,21 +150551,21 @@ var ts; // y: undefined, // } // ``` - var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */; + var isObjectLiteral = currentToken.kind === 18 /* SyntaxKind.OpenBraceToken */ && currentToken.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* SyntaxKind.CommaToken */ && precedingToken.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } } var containerList = getListByPosition(position, precedingToken.parent, sourceFile); // use list position if the preceding token is before any list items if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) { - var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; + var useTheSameBaseIndentation = [213 /* SyntaxKind.FunctionExpression */, 214 /* SyntaxKind.ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize; return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217 } @@ -149833,7 +150585,7 @@ var ts; return column; } var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); - return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; + return firstNonWhitespaceCharacterCode === 42 /* CharacterCodes.asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { // move backwards until we find a line with a non-whitespace character, @@ -149858,9 +150610,9 @@ var ts; if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(options, current, previous, sourceFile, /*isNextChild*/ true)) { var currentStart = getStartLineAndCharacterForNode(current, sourceFile); var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); - var indentationDelta = nextTokenKind !== 0 /* Unknown */ + var indentationDelta = nextTokenKind !== 0 /* NextTokenKind.Unknown */ // handle cases when codefix is about to be inserted before the close brace - ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0 + ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* NextTokenKind.CloseBrace */ ? options.indentSize : 0 : lineAtPosition !== currentStart.line ? options.indentSize : 0; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } @@ -149869,7 +150621,7 @@ var ts; // function foo(a // | preceding node 'a' does share line with its parent but indentation is expected var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, /*listIndentsChild*/ true); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } previous = current; @@ -149923,12 +150675,12 @@ var ts; // }) looking at the relationship between the list and *first* list item. var listIndentsChild = !!firstListChild && getStartLineAndCharacterForNode(firstListChild, sourceFile).line > containingListOrParentStart.line; var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, listIndentsChild); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } // try to fetch actual indentation for current node from source text actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } } @@ -149967,7 +150719,7 @@ var ts; } else { // handle broken code gracefully - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } } /* @@ -149978,9 +150730,9 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 305 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 305 /* SyntaxKind.SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } @@ -149993,13 +150745,13 @@ var ts; function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current, sourceFile); if (!nextToken) { - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } - if (nextToken.kind === 18 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* SyntaxKind.OpenBraceToken */) { // open braces are always indented at the parent level - return 1 /* OpenBrace */; + return 1 /* NextTokenKind.OpenBrace */; } - else if (nextToken.kind === 19 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -150009,9 +150761,9 @@ var ts; // class A { // $} var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine ? 2 /* CloseBrace */ : 0 /* Unknown */; + return lineAtPosition === nextTokenStartLine ? 2 /* NextTokenKind.CloseBrace */ : 0 /* NextTokenKind.Unknown */; } - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); @@ -150026,8 +150778,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 239 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); + if (parent.kind === 239 /* SyntaxKind.IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* SyntaxKind.ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -150107,42 +150859,42 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getList(node.typeArguments); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return getList(node.properties); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getList(node.elements); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return getList(node.members); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return getList(node.parameters); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return getList(node.typeParameters); - case 209 /* NewExpression */: - case 208 /* CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return getList(node.declarations); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return getList(node.elements); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -150160,27 +150912,27 @@ var ts; } function getActualIndentationForListStartLine(list, sourceFile, options) { if (!list) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 255 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); - if (result !== -1 /* Unknown */) { + if (result !== -1 /* Value.Unknown */) { return result; } } return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -150189,7 +150941,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 27 /* CommaToken */) { + if (list[i].kind === 27 /* SyntaxKind.CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -150199,7 +150951,7 @@ var ts; } lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); @@ -150220,7 +150972,7 @@ var ts; if (!ts.isWhiteSpaceSingleLine(ch)) { break; } - if (ch === 9 /* tab */) { + if (ch === 9 /* CharacterCodes.tab */) { column += options.tabSize + (column % options.tabSize); } else { @@ -150236,98 +150988,98 @@ var ts; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { - var childKind = child ? child.kind : 0 /* Unknown */; + var childKind = child ? child.kind : 0 /* SyntaxKind.Unknown */; switch (parent.kind) { - case 238 /* ExpressionStatement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 204 /* ArrayLiteralExpression */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 195 /* MappedType */: - case 184 /* TupleType */: - case 263 /* CaseBlock */: - case 290 /* DefaultClause */: - case 289 /* CaseClause */: - case 212 /* ParenthesizedExpression */: - case 206 /* PropertyAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 237 /* VariableStatement */: - case 271 /* ExportAssignment */: - case 247 /* ReturnStatement */: - case 222 /* ConditionalExpression */: - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: - case 279 /* JsxSelfClosingElement */: - case 288 /* JsxExpression */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 164 /* Parameter */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 191 /* ParenthesizedType */: - case 210 /* TaggedTemplateExpression */: - case 218 /* AwaitExpression */: - case 273 /* NamedExports */: - case 269 /* NamedImports */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 167 /* PropertyDeclaration */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 195 /* SyntaxKind.MappedType */: + case 184 /* SyntaxKind.TupleType */: + case 263 /* SyntaxKind.CaseBlock */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 237 /* SyntaxKind.VariableStatement */: + case 271 /* SyntaxKind.ExportAssignment */: + case 247 /* SyntaxKind.ReturnStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 164 /* SyntaxKind.Parameter */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 273 /* SyntaxKind.NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 254 /* VariableDeclaration */: - case 296 /* PropertyAssignment */: - case 221 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 254 /* SyntaxKind.VariableDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind === 221 /* BinaryExpression */ && sourceFile && child && childKind === 278 /* JsxElement */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && sourceFile && child && childKind === 278 /* SyntaxKind.JsxElement */) { var parentStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, parent.pos)).line; var childStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, child.pos)).line; return parentStartLine !== childStartLine; } - if (parent.kind !== 221 /* BinaryExpression */) { + if (parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { return true; } break; - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return childKind !== 235 /* Block */; - case 214 /* ArrowFunction */: - if (sourceFile && childKind === 212 /* ParenthesizedExpression */) { + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return childKind !== 235 /* SyntaxKind.Block */; + case 214 /* SyntaxKind.ArrowFunction */: + if (sourceFile && childKind === 212 /* SyntaxKind.ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 235 /* Block */; - case 272 /* ExportDeclaration */: - return childKind !== 273 /* NamedExports */; - case 266 /* ImportDeclaration */: - return childKind !== 267 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 269 /* NamedImports */); - case 278 /* JsxElement */: - return childKind !== 281 /* JsxClosingElement */; - case 282 /* JsxFragment */: - return childKind !== 284 /* JsxClosingFragment */; - case 188 /* IntersectionType */: - case 187 /* UnionType */: - if (childKind === 182 /* TypeLiteral */ || childKind === 184 /* TupleType */) { + return childKind !== 235 /* SyntaxKind.Block */; + case 272 /* SyntaxKind.ExportDeclaration */: + return childKind !== 273 /* SyntaxKind.NamedExports */; + case 266 /* SyntaxKind.ImportDeclaration */: + return childKind !== 267 /* SyntaxKind.ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 269 /* SyntaxKind.NamedImports */); + case 278 /* SyntaxKind.JsxElement */: + return childKind !== 281 /* SyntaxKind.JsxClosingElement */; + case 282 /* SyntaxKind.JsxFragment */: + return childKind !== 284 /* SyntaxKind.JsxClosingFragment */; + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + if (childKind === 182 /* SyntaxKind.TypeLiteral */ || childKind === 184 /* SyntaxKind.TupleType */) { return false; } break; @@ -150338,11 +151090,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: - return parent.kind !== 235 /* Block */; + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + return parent.kind !== 235 /* SyntaxKind.Block */; default: return false; } @@ -150432,7 +151184,7 @@ var ts; i++; continue; } - return ch === 47 /* slash */; + return ch === 47 /* CharacterCodes.slash */; } return false; } @@ -150516,7 +151268,7 @@ var ts; var comment = comments_2[_i]; // Single line can break the loop as trivia will only be this line. // Comments on subsequest lines are also ignored. - if (comment.kind === 2 /* SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { + if (comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { break; } // Get the end line of the comment and compare against the end line of the node. @@ -150559,7 +151311,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 205 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* SyntaxKind.CommaToken */ || (candidate.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -150665,7 +151417,7 @@ var ts; }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 27 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* SyntaxKind.CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -150729,7 +151481,7 @@ var ts; var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); - var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; + var text = "".concat(insertAtLineStart ? "" : this.newLineCharacter, "//").concat(commentText).concat(this.newLineCharacter).concat(indent); this.insertText(sourceFile, token.getStart(sourceFile), text); }; ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { @@ -150782,7 +151534,7 @@ var ts; var _a; var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return false; // Function missing parentheses, give up @@ -150791,19 +151543,19 @@ var ts; } } else { - endNode = (_a = (node.kind === 254 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { - var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; + var start = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile).getStart(sourceFile) + 1; var suffix = node.parameters.length ? ", " : ""; this.insertNodeAt(sourceFile, start, type, { prefix: "this: ", suffix: suffix }); }; ChangeTracker.prototype.insertTypeParameters = function (sourceFile, node, typeParameters) { // If no `(`, is an arrow function `x => x`, so use the pos of the first parameter - var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">", joiner: ", " }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, inserted, blankLineBetween) { @@ -150944,8 +151696,8 @@ var ts; if (needSemicolonBetween(after, newNode)) { // check if previous statement ends with semicolon // if not - insert semicolon to preserve the code from changing the meaning due to ASI - if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { - this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SemicolonToken */)); + if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* CharacterCodes.semicolon */) { + this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -150953,22 +151705,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n".concat(options.prefix) : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 254 /* VariableDeclaration */: - case 10 /* StringLiteral */: - case 79 /* Identifier */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 10 /* SyntaxKind.StringLiteral */: + case 79 /* SyntaxKind.Identifier */: return { prefix: ", " }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return { prefix: " " }; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -150977,28 +151729,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 214 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + if (node.kind === 214 /* SyntaxKind.ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* SyntaxKind.EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* SyntaxKind.FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` - this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); + this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function ".concat(name, "(")); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } - if (node.body.kind !== 235 /* Block */) { + if (node.body.kind !== 235 /* SyntaxKind.Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(105 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* SyntaxKind.OpenBraceToken */), ts.factory.createToken(105 /* SyntaxKind.ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */), ts.factory.createToken(19 /* SyntaxKind.CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 213 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 213 /* SyntaxKind.FunctionExpression */ ? 98 /* SyntaxKind.FunctionKeyword */ : 84 /* SyntaxKind.ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -151053,7 +151805,7 @@ var ts; var nextNode = containingList[index + 1]; var startPos = skipWhitespacesAndLineBreaks(sourceFile.text, nextNode.getFullStart()); // write separator and leading trivia of the next element as suffix - var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + var suffix = "".concat(ts.tokenToString(nextToken.kind)).concat(sourceFile.text.substring(nextToken.end, startPos)); this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } @@ -151070,12 +151822,12 @@ var ts; // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise // i.e. var x = 1 // this is x // | new element will be inserted at this position - separator = 27 /* CommaToken */; + separator = 27 /* SyntaxKind.CommaToken */; } else { // element has more than one element, pick separator from the list var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); - separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* SyntaxKind.CommaToken */; // determine if list is multiline by checking lines of after element and element that precedes it. var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; @@ -151098,7 +151850,7 @@ var ts; this.replaceRange(sourceFile, ts.createRange(insertPos), newNode, { indentation: indentation, prefix: this.newLineCharacter }); } else { - this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: ts.tokenToString(separator) + " " }); + this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: "".concat(ts.tokenToString(separator), " ") }); } } }; @@ -151126,7 +151878,7 @@ var ts; ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. - var _loop_10 = function (sourceFile, node) { + var _loop_9 = function (sourceFile, node) { if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { if (ts.isArray(node)) { this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node)); @@ -151139,7 +151891,7 @@ var ts; var this_1 = this; for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) { var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node; - _loop_10(sourceFile, node); + _loop_9(sourceFile, node); } deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); @@ -151175,10 +151927,10 @@ var ts; }()); textChanges_3.ChangeTracker = ChangeTracker; function updateJSDocHost(parent) { - if (parent.kind !== 214 /* ArrowFunction */) { + if (parent.kind !== 214 /* SyntaxKind.ArrowFunction */) { return parent; } - var jsDocNode = parent.parent.kind === 167 /* PropertyDeclaration */ ? + var jsDocNode = parent.parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ? parent.parent : parent.parent.parent; jsDocNode.jsDoc = parent.jsDoc; @@ -151190,16 +151942,16 @@ var ts; return undefined; } switch (oldTag.kind) { - case 340 /* JSDocParameterTag */: { + case 340 /* SyntaxKind.JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment) : undefined; } - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -151208,8 +151960,8 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - var open = ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile); - var close = ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile); + var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); + var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); return [open === null || open === void 0 ? void 0 : open.end, close === null || close === void 0 ? void 0 : close.end]; } function getMembersOrProperties(node) { @@ -151227,14 +151979,14 @@ var ts; // order changes by start position // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa. var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); - var _loop_11 = function (i) { + var _loop_10 = function (i) { ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () { - return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range); + return "".concat(JSON.stringify(normalized[i].range), " and ").concat(JSON.stringify(normalized[i + 1].range)); }); }; // verify that change intervals do not overlap, except possibly at end points. for (var i = 0; i < normalized.length - 1; i++) { - _loop_11(i); + _loop_10(i); } var textChanges = ts.mapDefined(normalized, function (c) { var span = ts.createTextSpanFromRange(c.range); @@ -151256,8 +152008,8 @@ var ts; changesToText.newFileChanges = newFileChanges; function newFileChangesWorker(oldFile, scriptKind, statements, newLineCharacter, formatContext) { // TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this - var nonFormattedText = statements.map(function (s) { return s === 4 /* NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); - var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ESNext */, /*setParentNodes*/ true, scriptKind); + var nonFormattedText = statements.map(function (s) { return s === 4 /* SyntaxKind.NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ScriptTarget.ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); return applyChanges(nonFormattedText, changes) + newLineCharacter; } @@ -151312,7 +152064,7 @@ var ts; neverAsciiEscape: true, preserveSourceNewlines: true, terminateUnterminatedLiterals: true - }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + }, writer).writeNode(4 /* EmitHint.Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -151320,7 +152072,7 @@ var ts; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var _a = changes[i], span = _a.span, newText = _a.newText; - text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); + text = "".concat(text.substring(0, span.start)).concat(newText).concat(text.substring(ts.textSpanEnd(span))); } return text; } @@ -151330,7 +152082,7 @@ var ts; } // A transformation context that won't perform parenthesization, as some parenthesization rules // are more aggressive than is strictly necessary. - var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); + var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes @@ -151541,7 +152293,7 @@ var ts; var firstNodeLine; for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { var range = ranges_1[_b]; - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { if (ts.isPinnedComment(text, range.pos)) { lastComment = { range: range, pinnedOrTripleSlash: true }; continue; @@ -151581,7 +152333,7 @@ var ts; var charCode = text.charCodeAt(position); if (ts.isLineBreak(charCode)) { position++; - if (position < text.length && charCode === 13 /* carriageReturn */ && text.charCodeAt(position) === 10 /* lineFeed */) { + if (position < text.length && charCode === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(position) === 10 /* CharacterCodes.lineFeed */) { position++; } } @@ -151593,18 +152345,18 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 164 /* Parameter */: { + case 164 /* SyntaxKind.Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && - !ts.findChildOfKind(oldFunction, 20 /* OpenParenToken */, sourceFile)) { + !ts.findChildOfKind(oldFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile)) { // Lambdas with exactly one parameter are special because, after removal, there // must be an empty parameter list (i.e. `()`) and this won't necessarily be the // case if the parameter is simply removed (e.g. in `x => 1`). @@ -151615,17 +152367,17 @@ var ts; } break; } - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax); // For first import, leave header comment in place, otherwise only delete JSDoc comments deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, }); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 202 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -151633,13 +152385,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -151648,17 +152400,17 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -151687,7 +152439,7 @@ var ts; // import |d,| * as ns from './file' var start = importClause.name.getStart(sourceFile); var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); - if (nextToken && nextToken.kind === 27 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* SyntaxKind.CommaToken */) { // shift first non-whitespace position after comma to the start position of the node var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); changes.deleteRange(sourceFile, { pos: start, end: end }); @@ -151709,15 +152461,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 266 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 266 /* SyntaxKind.ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 292 /* CatchClause */) { + if (parent.kind === 292 /* SyntaxKind.CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* SyntaxKind.OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* SyntaxKind.CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -151726,14 +152478,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -151920,8 +152672,8 @@ var ts; }); function makeChange(changeTracker, sourceFile, assertion) { var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } function getAssertion(sourceFile, pos) { @@ -152005,7 +152757,7 @@ var ts; } } fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.add(ts.getNodeId(insertionSite)); - var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* Async */))); + var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* ModifierFlags.Async */))); changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier); } function getFixableErrorSpanDeclaration(sourceFile, span) { @@ -152142,19 +152894,19 @@ var ts; } var isCompleteFix = identifiers.isCompleteFix; var initializers; - var _loop_12 = function (identifier) { + var _loop_11 = function (identifier) { var symbol = checker.getSymbolAtLocation(identifier); if (!symbol) { return "continue"; } var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 237 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 237 /* SyntaxKind.VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || - ts.hasSyntacticModifier(variableStatement, 1 /* Export */) || + ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { isCompleteFix = false; @@ -152175,7 +152927,7 @@ var ts; }; for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { var identifier = _a[_i]; - _loop_12(identifier); + _loop_11(identifier); } return initializers && { initializers: initializers, @@ -152222,15 +152974,15 @@ var ts; // Promise as an invalid operand. So if the whole binary expression is // typed `any` as a result, there is a strong likelihood that this Promise // is accidentally missing `await`. - checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; + checker.getTypeAtLocation(errorNode).flags & 1 /* TypeFlags.Any */; } function isInsideAwaitableBody(node) { - return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* NodeFlags.AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* FunctionDeclaration */ || - ancestor.parent.kind === 213 /* FunctionExpression */ || - ancestor.parent.kind === 214 /* ArrowFunction */ || - ancestor.parent.kind === 169 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + ancestor.parent.kind === 213 /* SyntaxKind.FunctionExpression */ || + ancestor.parent.kind === 214 /* SyntaxKind.ArrowFunction */ || + ancestor.parent.kind === 169 /* SyntaxKind.MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -152319,7 +153071,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -152343,16 +153095,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* SyntaxKind.ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 79 /* Identifier */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 79 /* SyntaxKind.Identifier */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return true; default: return false; @@ -152366,9 +153118,9 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 79 /* Identifier */: - case 221 /* BinaryExpression */: - case 27 /* CommaToken */: + case 79 /* SyntaxKind.Identifier */: + case 221 /* SyntaxKind.BinaryExpression */: + case 27 /* SyntaxKind.CommaToken */: return true; default: return false; @@ -152378,10 +153130,10 @@ var ts; if (!ts.isBinaryExpression(expression)) { return false; } - if (expression.operatorToken.kind === 27 /* CommaToken */) { + if (expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 63 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -152416,9 +153168,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 167 /* PropertyDeclaration */ && + if (declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 135 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 135 /* SyntaxKind.DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -152532,7 +153284,7 @@ var ts; if (!errorNode) { return undefined; } - else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return { source: errorNode.parent.right, target: errorNode.parent.left }; } else if (ts.isVariableDeclaration(errorNode.parent) && errorNode.parent.initializer) { @@ -152572,7 +153324,7 @@ var ts; var add = toAdd_1[_i]; var d = add.valueDeclaration; if (d && (ts.isPropertySignature(d) || ts.isPropertyDeclaration(d)) && d.type) { - var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* UnionType */ ? d.type.types : [d.type], true), [ + var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* SyntaxKind.UnionType */ ? d.type.types : [d.type], true), [ ts.factory.createTypeReferenceNode("undefined") ], false)); changes.replaceNode(d.getSourceFile(), d.type, t); @@ -152625,9 +153377,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -152637,7 +153389,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -152652,30 +153404,30 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return transformJSDocOptionalType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return transformJSDocType(node.type); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return transformJSDocNullableType(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return transformJSDocVariadicType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return transformJSDocFunctionType(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); - ts.setEmitFlags(visited, 1 /* SingleLine */); + ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */); return visited; } } @@ -152692,13 +153444,13 @@ var ts; var _a; // TODO: This does not properly handle `function(new:C, string)` per https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#the-javascript-type-language // however we do handle it correctly in `serializeTypeForDeclaration` in checker.ts - return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 318 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 318 /* SyntaxKind.JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : node.dotDotDotToken; return ts.factory.createParameterDeclaration(node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -152735,11 +153487,11 @@ var ts; function transformJSDocIndexSignature(node) { var index = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*modifiers*/ undefined, [index], node.typeArguments[1])]); - ts.setEmitFlags(indexSignature, 1 /* SingleLine */); + ts.setEmitFlags(indexSignature, 1 /* EmitFlags.SingleLine */); return indexSignature; } })(codefix = ts.codefix || (ts.codefix = {})); @@ -152766,7 +153518,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */))) { // Bad input return undefined; } @@ -152799,14 +153551,14 @@ var ts; if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements); } } else { - createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)], memberElements); + createClassElement(member, [ts.factory.createToken(124 /* SyntaxKind.StaticKeyword */)], memberElements); } }); } @@ -152857,7 +153609,7 @@ var ts; function createClassElement(symbol, modifiers, members) { // Right now the only thing we can convert are function expressions, which are marked as methods // or { x: y } type prototype assignments, which are marked as ObjectLiteral - if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + if (!(symbol.flags & 8192 /* SymbolFlags.Method */) && !(symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */)) { return; } var memberDeclaration = symbol.valueDeclaration; @@ -152876,7 +153628,7 @@ var ts; return; } // 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 === 238 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -152928,7 +153680,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -152939,14 +153691,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 235 /* Block */) { + if (arrowFunctionBody.kind === 235 /* SyntaxKind.Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -152963,7 +153715,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -152974,7 +153726,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -153001,7 +153753,7 @@ var ts; } if (ts.isStringLiteralLike(propName)) { return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text) - : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */) + : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* QuotePreference.Single */) : propName; } return undefined; @@ -153059,8 +153811,8 @@ var ts; return; } var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos); - changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, { suffix: " " }); - var _loop_13 = function (returnStatement) { + changes.insertModifierAt(sourceFile, pos, 131 /* SyntaxKind.AsyncKeyword */, { suffix: " " }); + var _loop_12 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false); @@ -153082,7 +153834,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var returnStatement = returnStatements_1[_i]; - var state_5 = _loop_13(returnStatement); + var state_5 = _loop_12(returnStatement); if (typeof state_5 === "object") return state_5.value; } @@ -153134,7 +153886,7 @@ var ts; // NOTE: this is a mostly copy of `isReferenceToType` from checker.ts. While this violates DRY, it keeps // `isReferenceToType` in checker local to the checker to avoid the cost of a property lookup on `ts`. function isReferenceToType(type, target) { - return (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + return (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getExplicitPromisedTypeOfPromiseReturningCallExpression(node, callback, checker) { @@ -153197,7 +153949,7 @@ var ts; var ident = (firstParameter === null || firstParameter === void 0 ? void 0 : firstParameter.valueDeclaration) && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) - || ts.factory.createUniqueName("result", 16 /* Optimistic */); + || ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -153278,7 +154030,7 @@ var ts; } function isNullOrUndefined(_a, node) { var checker = _a.checker; - if (node.kind === 104 /* NullKeyword */) + if (node.kind === 104 /* SyntaxKind.NullKeyword */) return true; if (ts.isIdentifier(node) && !ts.isGeneratedIdentifier(node) && ts.idText(node) === "undefined") { var symbol = checker.getSymbolAtLocation(node); @@ -153287,7 +154039,7 @@ var ts; return false; } function createUniqueSynthName(prevArgName) { - var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* Optimistic */); + var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* GeneratedIdentifierFlags.Optimistic */); return createSynthIdentifier(renamedPrevArg); } function getPossibleNameForVarDecl(node, transformer, continuationArgName) { @@ -153307,7 +154059,7 @@ var ts; }); } else { - possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* Optimistic */), continuationArgName.types); + possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */), continuationArgName.types); } // We are about to write a 'let' variable declaration, but `transformExpression` for both // the try block and catch/finally block will assign to this name. Setting this flag indicates @@ -153323,10 +154075,10 @@ var ts; if (possibleNameForVarDecl && !shouldReturn(node, transformer)) { varDeclIdentifier = ts.getSynthesizedDeepClone(declareSynthIdentifier(possibleNameForVarDecl)); var typeArray = possibleNameForVarDecl.types; - var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */); + var unionType = transformer.checker.getUnionType(typeArray, 2 /* UnionReduction.Subtype */); var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); var varDecl = [ts.factory.createVariableDeclaration(varDeclIdentifier, /*exclamationToken*/ undefined, unionTypeNode)]; - var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* Let */)); + var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* NodeFlags.Let */)); statements.push(varDeclList); } statements.push(tryStatement); @@ -153336,7 +154088,7 @@ var ts; ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingPattern(continuationArgName)), /*exclamationToken*/ undefined, /*type*/ undefined, varDeclIdentifier) - ], 2 /* Const */))); + ], 2 /* NodeFlags.Const */))); } return statements; } @@ -153441,12 +154193,12 @@ var ts; /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingName(variableName)), /*exclamationToken*/ undefined, typeAnnotation, rightHandSide) - ], 2 /* Const */)) + ], 2 /* NodeFlags.Const */)) ]; } function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) { if (typeAnnotation && expressionToReturn) { - var name = ts.factory.createUniqueName("result", 16 /* Optimistic */); + var name = ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); return __spreadArray(__spreadArray([], createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), true), [ ts.factory.createReturnStatement(name) ], false); @@ -153462,11 +154214,11 @@ var ts; function transformCallbackArgument(func, hasContinuation, continuationArgName, inputArgName, parent, transformer) { var _a; switch (func.kind) { - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // do not produce a transformed statement for a null argument break; - case 206 /* PropertyAccessExpression */: - case 79 /* Identifier */: // identifier includes undefined + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: // identifier includes undefined if (!inputArgName) { // undefined was argument passed to promise handler break; @@ -153476,7 +154228,7 @@ var ts; return maybeAnnotateAndReturn(synthCall, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker)); } var type = transformer.checker.getTypeAtLocation(func); - var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!callSignatures.length) { // if identifier in handler has no call signatures, it's invalid return silentFail(); @@ -153487,8 +154239,8 @@ var ts; continuationArgName.types.push(transformer.checker.getAwaitedType(returnType) || returnType); } return varDeclOrAssignment; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: { + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_a = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _a === void 0 ? void 0 : _a.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -153590,7 +154342,7 @@ var ts; return !!checker.getPromisedTypeOfPromise(type) ? ts.factory.createAwaitExpression(rightHandSide) : rightHandSide; } function getLastCallSignature(type, checker) { - var callSignatures = checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); return ts.lastOrUndefined(callSignatures); } function removeReturns(stmts, prevArgName, transformer, seenReturnStatement) { @@ -153607,7 +154359,7 @@ var ts; ret.push(ts.factory.createExpressionStatement(ts.factory.createAssignment(referenceSynthIdentifier(prevArgName), possiblyAwaitedExpression))); } else { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* NodeFlags.Const */)))); } } } @@ -153617,7 +154369,7 @@ var ts; } // if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables if (!seenReturnStatement && prevArgName !== undefined) { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* NodeFlags.Const */)))); } return ret; } @@ -153699,12 +154451,12 @@ var ts; } function createSynthIdentifier(identifier, types) { if (types === void 0) { types = []; } - return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; + return { kind: 0 /* SynthBindingNameKind.Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; } function createSynthBindingPattern(bindingPattern, elements, types) { if (elements === void 0) { elements = ts.emptyArray; } if (types === void 0) { types = []; } - return { kind: 1 /* BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; + return { kind: 1 /* SynthBindingNameKind.BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; } function referenceSynthIdentifier(synthId) { synthId.hasBeenReferenced = true; @@ -153725,10 +154477,10 @@ var ts; return synthId.identifier; } function isSynthIdentifier(bindingName) { - return bindingName.kind === 0 /* Identifier */; + return bindingName.kind === 0 /* SynthBindingNameKind.Identifier */; } function isSynthBindingPattern(bindingName) { - return bindingName.kind === 1 /* BindingPattern */; + return bindingName.kind === 1 /* SynthBindingNameKind.BindingPattern */; } function shouldReturn(expression, transformer) { return !!expression.original && transformer.setOfExpressionsToReturn.has(ts.getNodeId(expression.original)); @@ -153766,10 +154518,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -153809,9 +154561,9 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. - res.set(text, makeUniqueName("_" + text, identifiers)); + res.set(text, makeUniqueName("_".concat(text), identifiers)); } }); return res; @@ -153829,29 +154581,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression) && ts.isIdentifier(node.name)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -153898,8 +154650,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -153907,11 +154659,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form ".concat(name.kind)); } } function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) { @@ -153950,19 +154702,19 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return undefined; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 169 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 169 /* SyntaxKind.MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)], prop, useSitesToUnqualify); default: - ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind ".concat(prop.kind)); } }); return statements && [statements, false]; @@ -153991,8 +154743,8 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyMap; - return exports.has("export=" /* ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : - !exports.has("default" /* Default */) ? [[reExportStar(moduleSpecifier)], false] : + return exports.has("export=" /* InternalSymbolName.ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default" /* InternalSymbolName.Default */) ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } @@ -154007,23 +154759,23 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* SyntaxKind.SemicolonToken */, sourceFile); if (semi) changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* SyntaxKind.DotToken */, sourceFile), [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { - var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)]; switch (exported.kind) { - case 213 /* FunctionExpression */: { + case 213 /* SyntaxKind.FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -154031,10 +154783,10 @@ var ts; } } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -154054,7 +154806,7 @@ var ts; : ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode); function replaceNode(original) { // We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions - if (original.kind === 206 /* PropertyAccessExpression */) { + if (original.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var replacement = useSitesToUnqualify.get(original); // Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing useSitesToUnqualify.delete(original); @@ -154069,7 +154821,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -154080,7 +154832,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 202 /* ArrayBindingPattern */: { + case 202 /* SyntaxKind.ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -154091,10 +154843,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind ".concat(name.kind)); } } /** @@ -154151,7 +154903,7 @@ var ts; // Identifiers helpers function makeUniqueName(name, identifiers) { while (identifiers.original.has(name) || identifiers.additional.has(name)) { - name = "_" + name; + name = "_".concat(name); } identifiers.additional.add(name); return name; @@ -154173,11 +154925,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return parent.name !== node; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return parent.propertyName !== node; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -154199,7 +154951,7 @@ var ts; return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName !== undefined && propertyName !== name ? ts.factory.createIdentifier(propertyName) : undefined, ts.factory.createIdentifier(name)); } function makeConst(modifiers, name, init) { - return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* Const */)); + return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* NodeFlags.Const */)); } function makeExportDeclaration(exportSpecifiers, moduleSpecifier) { return ts.factory.createExportDeclaration( @@ -154228,7 +154980,7 @@ var ts; if (!qualifiedName) return undefined; var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, qualifiedName); }); - var newText = qualifiedName.left.text + "[\"" + qualifiedName.right.text + "\"]"; + var newText = "".concat(qualifiedName.left.text, "[\"").concat(qualifiedName.right.text, "\"]"); return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Rewrite_as_the_indexed_access_type_0, newText], fixId, ts.Diagnostics.Rewrite_all_as_indexed_access_types)]; }, fixIds: [fixId], @@ -154288,7 +155040,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 152 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 152 /* SyntaxKind.TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.modifiers, @@ -154455,7 +155207,7 @@ var ts; return ts.Debug.checkDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { - return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* ModifierFlags.Private */); } function addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { var checker = context.program.getTypeChecker(); @@ -154468,10 +155220,10 @@ var ts; var classType = checker.getTypeAtLocation(classDeclaration); var constructor = ts.find(classDeclaration.members, function (m) { return ts.isConstructorDeclaration(m); }); if (!classType.getNumberIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */); + createMissingIndexSignatureDeclaration(implementedType, 1 /* IndexKind.Number */); } if (!classType.getStringIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); + createMissingIndexSignatureDeclaration(implementedType, 0 /* IndexKind.String */); } var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host); codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); }); @@ -154577,20 +155329,20 @@ var ts; var fixes = info.fixes, symbolName = info.symbolName; var fix = ts.first(fixes); switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addToNamespace.push(fix); break; - case 1 /* JsdocTypeImport */: + case 1 /* ImportFixKind.JsdocTypeImport */: importType.push(fix); break; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly; var key = String(ts.getNodeId(importClauseOrBindingPattern)); var entry = addToExisting.get(key); if (!entry) { addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: new ts.Map() }); } - if (importKind === 0 /* Named */) { + if (importKind === 0 /* ImportKind.Named */) { var prevValue = entry === null || entry === void 0 ? void 0 : entry.namedImports.get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); } @@ -154603,32 +155355,32 @@ var ts; } break; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, addAsTypeOnly = fix.addAsTypeOnly; var entry = getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly); ts.Debug.assert(entry.useRequire === useRequire, "(Add new) Tried to add an `import` and a `require` for the same module"); switch (importKind) { - case 1 /* Default */: + case 1 /* ImportKind.Default */: ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport.name === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = { name: symbolName, addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) === null || _b === void 0 ? void 0 : _b.addAsTypeOnly, addAsTypeOnly) }; break; - case 0 /* Named */: + case 0 /* ImportKind.Named */: var prevValue = (entry.namedImports || (entry.namedImports = new ts.Map())).get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); break; - case 3 /* CommonJS */: - case 2 /* Namespace */: + case 3 /* ImportKind.CommonJS */: + case 2 /* ImportKind.Namespace */: ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly }; break; } break; } - case 4 /* PromoteTypeOnly */: + case 4 /* ImportFixKind.PromoteTypeOnly */: // Excluding from fix-all break; default: - ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); + ts.Debug.assertNever(fix, "fix wasn't never - got kind ".concat(fix.kind)); } function reduceAddAsTypeOnlyValues(prevValue, newValue) { // `NotAllowed` overrides `Required` because one addition of a new import might be required to be type-only @@ -154656,13 +155408,13 @@ var ts; namespaceLikeImport: undefined, useRequire: useRequire }; - if (importKind === 1 /* Default */ && addAsTypeOnly === 2 /* Required */) { + if (importKind === 1 /* ImportKind.Default */ && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */) { if (typeOnlyEntry) return typeOnlyEntry; newImports.set(typeOnlyKey, newEntry); return newEntry; } - if (addAsTypeOnly === 1 /* Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { + if (addAsTypeOnly === 1 /* AddAsTypeOnly.Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { return (typeOnlyEntry || nonTypeOnlyEntry); } if (nonTypeOnlyEntry) { @@ -154672,7 +155424,7 @@ var ts; return newEntry; } function newImportsKey(moduleSpecifier, topLevelTypeOnly) { - return (topLevelTypeOnly ? 1 : 0) + "|" + moduleSpecifier; + return "".concat(topLevelTypeOnly ? 1 : 0, "|").concat(moduleSpecifier); } } function writeFixes(changeTracker) { @@ -154762,7 +155514,7 @@ var ts; var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions); var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program); var includeSymbolNameInDescription = symbolName !== symbolToken.text; - return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions)); + return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* QuotePreference.Double */, compilerOptions)); } codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction; function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) { @@ -154790,7 +155542,7 @@ var ts; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; + return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; } } } @@ -154813,7 +155565,7 @@ var ts; for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) { - result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); + result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); } } }); @@ -154865,7 +155617,7 @@ var ts; if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; + return { kind: 0 /* ImportFixKind.UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -154873,11 +155625,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport); return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol); default: @@ -154887,11 +155639,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return declaration.name.text; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text; default: return ts.Debug.assertNever(declaration); @@ -154900,31 +155652,31 @@ var ts; function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, symbol, targetFlags, checker, compilerOptions) { if (!isValidTypeOnlyUseSite) { // Can't use a type-only import if the usage is an emitting position - return 4 /* NotAllowed */; + return 4 /* AddAsTypeOnly.NotAllowed */; } - if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* Error */) { + if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */) { // Not writing a (top-level) type-only import here would create an error because the runtime dependency is unnecessary - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } if (compilerOptions.isolatedModules && compilerOptions.preserveValueImports && - (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { + (!(targetFlags & 111551 /* SymbolFlags.Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { // A type-only import is required for this symbol if under these settings if the symbol will // be erased, which will happen if the target symbol is purely a type or if it was exported/imported // as type-only already somewhere between this import and the target. - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } - return 1 /* Allowed */; + return 1 /* AddAsTypeOnly.Allowed */; } function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - if (importKind === 3 /* CommonJS */ || importKind === 2 /* Namespace */ || declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (importKind === 3 /* ImportKind.CommonJS */ || importKind === 2 /* ImportKind.Namespace */ || declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // These kinds of imports are not combinable with anything return undefined; } - if (declaration.kind === 254 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 201 /* ObjectBindingPattern */ - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } + if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { + return (importKind === 0 /* ImportKind.Named */ || importKind === 1 /* ImportKind.Default */) && declaration.name.kind === 201 /* SyntaxKind.ObjectBindingPattern */ + ? { kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* AddAsTypeOnly.NotAllowed */ } : undefined; } var importClause = declaration.importClause; @@ -154933,22 +155685,22 @@ var ts; var name = importClause.name, namedBindings = importClause.namedBindings; // A type-only import may not have both a default and named imports, so the only way a name can // be added to an existing type-only import is adding a named import to existing named bindings. - if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings)) + if (importClause.isTypeOnly && !(importKind === 0 /* ImportKind.Named */ && namedBindings)) return undefined; // N.B. we don't have to figure out whether to use the main program checker // or the AutoImportProvider checker because we're adding to an existing import; the existence of // the import guarantees the symbol came from the main program. var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ false, symbol, targetFlags, checker, compilerOptions); - if (importKind === 1 /* Default */ && (name || // Cannot add a default import to a declaration that already has one - addAsTypeOnly === 2 /* Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings + if (importKind === 1 /* ImportKind.Default */ && (name || // Cannot add a default import to a declaration that already has one + addAsTypeOnly === 2 /* AddAsTypeOnly.Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings )) return undefined; - if (importKind === 0 /* Named */ && - (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import + if (importKind === 0 /* ImportKind.Named */ && + (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* SyntaxKind.NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import ) return undefined; return { - kind: 2 /* AddToExisting */, + kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, @@ -154967,7 +155719,7 @@ var ts; (importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent); } } - else if (i.kind === 266 /* ImportDeclaration */ || i.kind === 265 /* ImportEqualsDeclaration */) { + else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); if (moduleSymbol) { (importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i); @@ -154978,7 +155730,7 @@ var ts; getImportsForExportInfo: function (_a) { var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol; // Can't use an es6 import for a type in JS. - if (!(targetFlags & 111551 /* Value */) && ts.isSourceFileJS(importingFile)) + if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile)) return ts.emptyArray; var matchingDeclarations = importMap === null || importMap === void 0 ? void 0 : importMap.get(ts.getSymbolId(moduleSymbol)); if (!matchingDeclarations) @@ -155029,15 +155781,15 @@ var ts; var fixes = ts.flatMap(exportInfo, function (exportInfo, i) { var checker = getChecker(exportInfo.isFromPackageJson); var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers; - var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */); + var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* SymbolFlags.Value */); var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions); computedWithoutCacheCount += computedWithoutCache ? 1 : 0; return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) { return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined : // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : + !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* ImportFixKind.JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : { - kind: 3 /* AddNew */, + kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), useRequire: useRequire, @@ -155059,9 +155811,9 @@ var ts; var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (moduleSpecifier) { var addAsTypeOnly = useRequire - ? 4 /* NotAllowed */ + ? 4 /* AddAsTypeOnly.NotAllowed */ : getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, symbol, targetFlags, checker, compilerOptions); - return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; + return { kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; } } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -155092,23 +155844,23 @@ var ts; if (!ts.some(fixes)) return; // These will always be placed first if available, and are better than other kinds - if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) { + if (fixes[0].kind === 0 /* ImportFixKind.UseNamespace */ || fixes[0].kind === 2 /* ImportFixKind.AddToExisting */) { return fixes[0]; } return fixes.reduce(function (best, fix) { // Takes true branch of conditional if `fix` is better than `best` - return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best; + return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* Comparison.LessThan */ ? fix : best; }); } /** @returns `Comparison.LessThan` if `a` is better than `b`. */ function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) { - if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + if (a.kind !== 0 /* ImportFixKind.UseNamespace */ && b.kind !== 0 /* ImportFixKind.UseNamespace */) { return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath)) || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export. // E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`. @@ -155131,10 +155883,10 @@ var ts; } function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) { if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; if (ts.startsWith(b, "node:") && !ts.startsWith(a, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* GreaterThan */ : -1 /* LessThan */; - return 0 /* EqualTo */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* Comparison.GreaterThan */ : -1 /* Comparison.LessThan */; + return 0 /* Comparison.EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var _b; @@ -155145,7 +155897,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; + var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* ExportKind.UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined; var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes; @@ -155159,7 +155911,7 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } /** @@ -155168,10 +155920,10 @@ var ts; */ function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) { switch (exportKind) { - case 0 /* Named */: return 0 /* Named */; - case 1 /* Default */: return 1 /* Default */; - case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); - case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 0 /* ExportKind.Named */: return 0 /* ImportKind.Named */; + case 1 /* ExportKind.Default */: return 1 /* ImportKind.Default */; + case 2 /* ExportKind.ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 3 /* ExportKind.UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); default: return ts.Debug.assertNever(exportKind); } } @@ -155179,7 +155931,7 @@ var ts; function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { - return 1 /* Default */; + return 1 /* ImportKind.Default */; } // When a synthetic `default` is unavailable, use `import..require` if the module kind supports it. var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -155188,9 +155940,9 @@ var ts; case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */; + return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; } - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: case ts.ModuleKind.ES2020: @@ -155198,12 +155950,12 @@ var ts; case ts.ModuleKind.ESNext: case ts.ModuleKind.None: // Fall back to the `import * as ns` style import. - return 2 /* Namespace */; + return 2 /* ImportKind.Namespace */; case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: - return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */; + return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; default: - return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind ".concat(moduleKind)); } } function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { @@ -155212,7 +155964,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, but appears as an identifier. - if (symbolName === "default" /* Default */) { + if (symbolName === "default" /* InternalSymbolName.Default */) { return undefined; } var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken); @@ -155226,13 +155978,13 @@ var ts; } function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) { var checker = program.getTypeChecker(); - var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); if (!symbol) return undefined; var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol); if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile) return undefined; - return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; + return { kind: 4 /* ImportFixKind.PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; } function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; @@ -155247,8 +155999,8 @@ var ts; function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) { if (ts.isIntrinsicJsxName(symbolToken.text)) return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory - var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); - return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */); + var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); + return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* SymbolFlags.Value */); } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) { @@ -155280,7 +156032,7 @@ var ts; // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* ExportKind.Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; @@ -155291,14 +156043,14 @@ var ts; // 1. 'import =' will not work in es2015+ TS files, so the decision is between a default // and a namespace import, based on allowSyntheticDefaultImports/esModuleInterop. if (!isJS && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { - return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */; } // 2. 'import =' will not work in JavaScript, so the decision is between a default import, // a namespace import, and const/require. if (isJS) { return ts.isExternalModule(importingFile) || forceImportKeyword - ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ - : 3 /* CommonJS */; + ? allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */ + : 3 /* ImportKind.CommonJS */; } // 3. At this point the most correct choice is probably 'import =', but people // really hate that, so look to see if the importing file has any precedent @@ -155307,12 +156059,12 @@ var ts; var statement = _a[_i]; // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; } } // 4. We have no precedent to go on, so just use a default import if // allowSyntheticDefaultImports/esModuleInterop is enabled. - return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 3 /* ImportKind.CommonJS */; } function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { var diag; @@ -155323,45 +156075,45 @@ var ts; } function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addNamespaceQualifier(changes, sourceFile, fix); - return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; - case 1 /* JsdocTypeImport */: + return [ts.Diagnostics.Change_0_to_1, symbolName, "".concat(fix.namespacePrefix, ".").concat(symbolName)]; + case 1 /* ImportFixKind.JsdocTypeImport */: addImportType(changes, sourceFile, fix, quotePreference); return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName]; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier; - doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); + doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes] : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes]; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire; var getDeclarations = useRequire ? getNewRequires : getNewImports; - var defaultImport = importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; - var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; - var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var defaultImport = importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var namedImports = importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; + var namespaceLikeImport = importKind === 2 /* ImportKind.Namespace */ || importKind === 3 /* ImportKind.CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier] : [ts.Diagnostics.Add_import_from_0, moduleSpecifier]; } - case 4 /* PromoteTypeOnly */: { + case 4 /* ImportFixKind.PromoteTypeOnly */: { var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration; var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile); - return promotedDeclaration.kind === 270 /* ImportSpecifier */ + return promotedDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)] : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)]; } default: - return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); + return ts.Debug.assertNever(fix, "Unexpected fix kind ".concat(fix.kind)); } } function getModuleSpecifierText(promotedDeclaration) { var _a, _b; - return promotedDeclaration.kind === 265 /* ImportEqualsDeclaration */ + return promotedDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText() : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text; } @@ -155369,7 +156121,7 @@ var ts; // See comment in `doAddExistingFix` on constant with the same name. var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules; switch (aliasDeclaration.kind) { - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: if (aliasDeclaration.isTypeOnly) { if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) { changes.delete(sourceFile, aliasDeclaration); @@ -155387,13 +156139,13 @@ var ts; promoteImportClause(aliasDeclaration.parent.parent); return aliasDeclaration.parent.parent; } - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: promoteImportClause(aliasDeclaration); return aliasDeclaration; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: promoteImportClause(aliasDeclaration.parent); return aliasDeclaration.parent; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1)); return aliasDeclaration; default: @@ -155405,7 +156157,7 @@ var ts; var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports); if (namedImports && namedImports.elements.length > 1) { if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) && - aliasDeclaration.kind === 270 /* ImportSpecifier */ && + aliasDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && namedImports.elements.indexOf(aliasDeclaration) !== 0) { // The import specifier being promoted will be the only non-type-only, // import in the NamedImports, so it should be moved to the front. @@ -155415,7 +156167,7 @@ var ts; for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) { var element = _a[_i]; if (element !== aliasDeclaration && !element.isTypeOnly) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, element); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, element); } } } @@ -155424,7 +156176,7 @@ var ts; } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) { var _a; - if (clause.kind === 201 /* ObjectBindingPattern */) { + if (clause.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport.name, "default"); } @@ -155434,7 +156186,7 @@ var ts; } return; } - var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* NotAllowed */; }); + var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* AddAsTypeOnly.NotAllowed */; }); var existingSpecifiers = clause.namedBindings && ((_a = ts.tryCast(clause.namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements); // If we are promoting from a type-only import and `--isolatedModules` and `--preserveValueImports` // are enabled, we need to make every existing import specifier type-only. It may be possible that @@ -155485,7 +156237,7 @@ var ts; if (convertExistingToTypeOnly && existingSpecifiers) { for (var _d = 0, existingSpecifiers_1 = existingSpecifiers; _d < existingSpecifiers_1.length; _d++) { var specifier = existingSpecifiers_1[_d]; - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, specifier); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, specifier); } } } @@ -155509,11 +156261,11 @@ var ts; } function getImportTypePrefix(moduleSpecifier, quotePreference) { var quote = ts.getQuoteFromPreference(quotePreference); - return "import(" + quote + moduleSpecifier + quote + ")."; + return "import(".concat(quote).concat(moduleSpecifier).concat(quote, ")."); } function needsTypeOnly(_a) { var addAsTypeOnly = _a.addAsTypeOnly; - return addAsTypeOnly === 2 /* Required */; + return addAsTypeOnly === 2 /* AddAsTypeOnly.Required */; } function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport) { var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); @@ -155522,12 +156274,12 @@ var ts; var topLevelTypeOnly_1 = (!defaultImport || needsTypeOnly(defaultImport)) && ts.every(namedImports, needsTypeOnly); statements = ts.combine(statements, ts.makeImport(defaultImport && ts.factory.createIdentifier(defaultImport.name), namedImports === null || namedImports === void 0 ? void 0 : namedImports.map(function (_a) { var addAsTypeOnly = _a.addAsTypeOnly, name = _a.name; - return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* Required */, + return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */, /*propertyName*/ undefined, ts.factory.createIdentifier(name)); }), moduleSpecifier, quotePreference, topLevelTypeOnly_1)); } if (namespaceLikeImport) { - var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ + var declaration = namespaceLikeImport.importKind === 3 /* ImportKind.CommonJS */ ? ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, needsTypeOnly(namespaceLikeImport), ts.factory.createIdentifier(namespaceLikeImport.name), ts.factory.createExternalModuleReference(quotedModuleSpecifier)) : ts.factory.createImportDeclaration( @@ -155566,7 +156318,7 @@ var ts; ts.factory.createVariableDeclaration(typeof name === "string" ? ts.factory.createIdentifier(name) : name, /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createCallExpression(ts.factory.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -155603,7 +156355,7 @@ var ts; lastCharWasValid = isValid; } // Need `|| "_"` to ensure result isn't empty. - return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; + return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_".concat(res); } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; })(codefix = ts.codefix || (ts.codefix = {})); @@ -155629,54 +156381,90 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var sourceFile = context.sourceFile, span = context.span, program = context.program; - var related = getDiagnosticRelatedInfo(program, sourceFile, span); - if (!related) { + var sourceFile = context.sourceFile, span = context.span, program = context.program, preferences = context.preferences, host = context.host; + var info = getInfo(program, sourceFile, span); + if (info === undefined) return; - } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, program, preferences, host, sourceFile, info); }); return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag); - if (!info) - return; - return addMissingConstraint(changes, info); - }); }, + getAllCodeActions: function (context) { + var program = context.program, preferences = context.preferences, host = context.host; + var seen = new ts.Map(); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length)); + if (info) { + if (ts.addToSeen(seen, ts.getNodeId(info.declaration))) { + return addMissingConstraint(changes, program, preferences, host, diag.file, info); + } + } + return undefined; + }); + })); + } }); - function getDiagnosticRelatedInfo(program, sourceFile, span) { + function getInfo(program, sourceFile, span) { var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; }); - if (!diag || !diag.relatedInformation) + if (diag === undefined || diag.relatedInformation === undefined) return; var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; }); - if (!related) + if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined) return; - return related; - } - function addMissingConstraint(changes, related) { - var decl = findAncestorMatchingSpan(related.file, related); - if (!decl) + var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length)); + if (declaration === undefined) return; - if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) { - decl = decl.parent; + if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) { + declaration = declaration.parent; + } + if (ts.isTypeParameterDeclaration(declaration)) { + // should only issue fix on type parameters written using `extends` + if (ts.isMappedTypeNode(declaration.parent)) + return; + var token = ts.getTokenAtPosition(sourceFile, span.start); + var checker = program.getTypeChecker(); + var constraint = tryGetConstraintType(checker, token) || tryGetConstraintFromDiagnosticMessage(related.messageText); + return { constraint: constraint, declaration: declaration, token: token }; + } + return undefined; + } + function addMissingConstraint(changes, program, preferences, host, sourceFile, info) { + var declaration = info.declaration, constraint = info.constraint; + var checker = program.getTypeChecker(); + if (ts.isString(constraint)) { + changes.insertText(sourceFile, declaration.name.end, " extends ".concat(constraint)); + } + else { + var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); + var tracker = codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }); + var importAdder = codefix.createImportAdder(sourceFile, program, preferences, host); + var typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, scriptTarget, /*flags*/ undefined, tracker); + if (typeNode) { + changes.replaceNode(sourceFile, declaration, ts.factory.updateTypeParameterDeclaration(declaration, /*modifiers*/ undefined, declaration.name, typeNode, declaration.default)); + importAdder.writeFixes(changes); + } } - if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent)) - return; // should only issue fix on type parameters written using `extends` - var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/); - if (!newConstraint) - return; - var newConstraintText = newConstraint[1]; - changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText); } function findAncestorMatchingSpan(sourceFile, span) { - var token = ts.getTokenAtPosition(sourceFile, span.start); var end = ts.textSpanEnd(span); + var token = ts.getTokenAtPosition(sourceFile, span.start); while (token.end < end) { token = token.parent; } return token; } + function tryGetConstraintFromDiagnosticMessage(messageText) { + var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1]; + return constraint; + } + function tryGetConstraintType(checker, node) { + if (ts.isTypeNode(node.parent)) { + return checker.getTypeArgumentConstraint(node.parent); + } + var contextualType = ts.isExpression(node) ? checker.getContextualType(node) : undefined; + return contextualType || checker.getTypeAtLocation(node); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -155809,7 +156597,7 @@ var ts; accessibilityModifier ? accessibilityModifier.end : lastDecorator ? ts.skipTrivia(sourceFile.text, lastDecorator.end) : classElement.getStart(sourceFile); var options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " }; - changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* OverrideKeyword */, options); + changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* SyntaxKind.OverrideKeyword */, options); } function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { var classElement = findContainerClassElementLike(sourceFile, pos); @@ -155823,13 +156611,13 @@ var ts; } function isClassElementLikeHasJSDoc(node) { switch (node.kind) { - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.isParameterPropertyDeclaration(node, node.parent); default: return false; @@ -155871,7 +156659,7 @@ var ts; }); function doChange(changes, sourceFile, node, preferences) { var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */); + var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* QuotePreference.Single */); changes.replaceNode(sourceFile, node, ts.isPropertyAccessChain(node) ? ts.factory.createElementAccessChain(node.expression, node.questionDotToken, argumentsExpression) : ts.factory.createElementAccessExpression(node.expression, argumentsExpression)); @@ -155911,7 +156699,7 @@ var ts; if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn)) return undefined; if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function - var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* SyntaxKind.FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -155930,7 +156718,7 @@ var ts; else { // `function f() {}` => `const f = () => {}` // `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`. - changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -155961,7 +156749,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 197 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 197 /* SyntaxKind.NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -155970,16 +156758,16 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 185 /* OptionalType */ || unwrappedType.kind === 186 /* RestType */ || unwrappedType.kind === 191 /* ParenthesizedType */) { - if (unwrappedType.kind === 185 /* OptionalType */) { + while (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */ || unwrappedType.kind === 186 /* SyntaxKind.RestType */ || unwrappedType.kind === 191 /* SyntaxKind.ParenthesizedType */) { + if (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 186 /* RestType */) { + else if (unwrappedType.kind === 186 /* SyntaxKind.RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; } - var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined), unwrappedType); + var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined), unwrappedType); if (updated === namedTupleMember) { return; } @@ -156045,18 +156833,18 @@ var ts; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); - if (parent.flags & 32 /* OptionalChain */) { + if (parent.flags & 32 /* NodeFlags.OptionalChain */) { containingType = checker.getNonNullableType(containingType); } suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType); } - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { var receiverType = checker.getTypeAtLocation(parent.right); suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, receiverType); } else if (ts.isQualifiedName(parent) && parent.right === node) { var symbol = checker.getSymbolAtLocation(parent.left); - if (symbol && symbol.flags & 1536 /* Module */) { + if (symbol && symbol.flags & 1536 /* SymbolFlags.Module */) { suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(parent.right, symbol); } } @@ -156074,7 +156862,7 @@ var ts; var props = checker.getContextualTypeForArgumentAtIndex(tag, 0); suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props); } - else if (ts.hasSyntacticModifier(parent, 16384 /* Override */) && ts.isClassElement(parent) && parent.name === node) { + else if (ts.hasSyntacticModifier(parent, 16384 /* ModifierFlags.Override */) && ts.isClassElement(parent) && parent.name === node) { var baseDeclaration = ts.findAncestor(node, ts.isClassLike); var baseTypeNode = baseDeclaration ? ts.getEffectiveBaseTypeNode(baseDeclaration) : undefined; var baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : undefined; @@ -156107,14 +156895,14 @@ var ts; } function convertSemanticMeaningToSymbolFlags(meaning) { var flags = 0; - if (meaning & 4 /* Namespace */) { - flags |= 1920 /* Namespace */; + if (meaning & 4 /* SemanticMeaning.Namespace */) { + flags |= 1920 /* SymbolFlags.Namespace */; } - if (meaning & 2 /* Type */) { - flags |= 788968 /* Type */; + if (meaning & 2 /* SemanticMeaning.Type */) { + flags |= 788968 /* SymbolFlags.Type */; } - if (meaning & 1 /* Value */) { - flags |= 111551 /* Value */; + if (meaning & 1 /* SemanticMeaning.Value */) { + flags |= 111551 /* SymbolFlags.Value */; } return flags; } @@ -156186,7 +156974,7 @@ var ts; }); }, }); function createObjectTypeFromLabeledExpression(checker, label, expression) { - var member = checker.createSymbol(4 /* Property */, label.escapedText); + var member = checker.createSymbol(4 /* SymbolFlags.Property */, label.escapedText); member.type = checker.getTypeAtLocation(expression); var members = ts.createSymbolTable([member]); return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], []); @@ -156245,7 +157033,7 @@ var ts; if (isFunctionType) { var sig = checker.getSignatureFromDeclaration(declaration); if (sig) { - if (ts.hasSyntacticModifier(declaration, 256 /* Async */)) { + if (ts.hasSyntacticModifier(declaration, 256 /* ModifierFlags.Async */)) { exprType = checker.createPromiseType(exprType); } var newSig = checker.createSignature(declaration, sig.typeParameters, sig.thisParameter, sig.parameters, exprType, @@ -156289,19 +157077,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: return declaration.initializer; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 297 /* ShorthandPropertyAssignment */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return undefined; } } @@ -156363,19 +157151,19 @@ var ts; if (!info) { return undefined; } - if (info.kind === 3 /* ObjectLiteral */) { + if (info.kind === 3 /* InfoKind.ObjectLiteral */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); }); return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)]; } - if (info.kind === 4 /* JsxAttributes */) { + if (info.kind === 4 /* InfoKind.JsxAttributes */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); }); return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)]; } - if (info.kind === 2 /* Function */) { + if (info.kind === 2 /* InfoKind.Function */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); }); return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)]; } - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); }); return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; } @@ -156393,20 +157181,20 @@ var ts; if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { return; } - if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) { + if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* InfoKind.Function */) { addFunctionDeclaration(changes, context, info); } - else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) { + else if (fixId === fixMissingProperties && info.kind === 3 /* InfoKind.ObjectLiteral */) { addObjectLiteralProperties(changes, context, info); } - else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) { + else if (fixId === fixMissingAttributes && info.kind === 4 /* InfoKind.JsxAttributes */) { addJsxAttributes(changes, context, info); } else { - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { addEnumMemberDeclaration(changes, checker, info); } - if (info.kind === 0 /* TypeLikeDeclaration */) { + if (info.kind === 0 /* InfoKind.TypeLikeDeclaration */) { var parentDeclaration = info.parentDeclaration, token_1 = info.token; var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; }); if (!infos.some(function (i) { return i.token.text === token_1.text; })) { @@ -156417,7 +157205,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, declaration) { var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker); - var _loop_14 = function (info) { + var _loop_13 = function (info) { // If some superclass added this property, don't add it again. if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -156430,21 +157218,21 @@ var ts; var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, modifierFlags = info.modifierFlags, token = info.token, call = info.call, isJSFile = info.isJSFile; // Always prefer to add a method declaration if possible. if (call && !ts.isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile); + addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* ModifierFlags.Static */, parentDeclaration, declSourceFile); } else { if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration) && !ts.isTypeLiteralNode(parentDeclaration)) { - addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); + addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); } else { var typeNode = getTypeNode(checker, parentDeclaration, token); - addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */); + addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* ModifierFlags.Static */); } } }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_14(info); + _loop_13(info); } }); })); @@ -156465,12 +157253,12 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, tokenPos); var parent = token.parent; if (errorCode === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) { - if (!(token.kind === 18 /* OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) + if (!(token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) return undefined; var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; }); if (argIndex < 0) return undefined; - var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* Call */)); + var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */)); if (!(signature && signature.declaration && signature.parameters[argIndex])) return undefined; var param = signature.parameters[argIndex].valueDeclaration; @@ -156479,7 +157267,7 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; } if (!ts.isMemberName(token)) return undefined; @@ -156487,17 +157275,17 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; } if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) { var target = ts.getEmitScriptTarget(program.getCompilerOptions()); var attributes = getUnmatchedAttributes(checker, target, token.parent); if (!ts.length(attributes)) return undefined; - return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; + return { kind: 4 /* InfoKind.JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; } - if (ts.isIdentifier(token) && ts.isCallExpression(parent)) { - return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile }; + if (ts.isIdentifier(token) && ts.isCallExpression(parent) && parent.expression === token) { + return { kind: 2 /* InfoKind.Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* ModifierFlags.None */, parentDeclaration: sourceFile }; } if (!ts.isPropertyAccessExpression(parent)) return undefined; @@ -156509,13 +157297,13 @@ var ts; var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration); var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile(); if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration }; } var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile); if (sourceFile.commonJsModuleIndicator) return undefined; if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile }; } } var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); @@ -156529,15 +157317,15 @@ var ts; if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration))) return undefined; var declSourceFile = declaration.getSourceFile(); - var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* None */ : - (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */); + var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* ModifierFlags.None */ : + (makeStatic ? 32 /* ModifierFlags.Static */ : 0 /* ModifierFlags.None */) | (ts.startsWithUnderscore(token.text) ? 8 /* ModifierFlags.Private */ : 0 /* ModifierFlags.None */); var isJSFile = ts.isSourceFileJS(declSourceFile); var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; + return { kind: 0 /* InfoKind.TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; } var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) { - return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration }; + return { kind: 1 /* InfoKind.Enum */, token: token, parentDeclaration: enumDeclaration }; } return undefined; } @@ -156553,18 +157341,18 @@ var ts; if (ts.isInterfaceDeclaration(parentDeclaration) || ts.isTypeLiteralNode(parentDeclaration)) { return undefined; } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); }); if (changes.length === 0) { return undefined; } - var diagnostic = modifierFlags & 32 /* Static */ ? ts.Diagnostics.Initialize_static_property_0 : + var diagnostic = modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Initialize_static_property_0 : ts.isPrivateIdentifier(token) ? ts.Diagnostics.Declare_a_private_field_named_0 : ts.Diagnostics.Initialize_property_0_in_the_constructor; return codefix.createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members); } function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 226 /* ClassExpression */) { + if (classDeclaration.kind === 226 /* SyntaxKind.ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -156600,32 +157388,32 @@ var ts; function createActionsForAddMissingMemberInTypeScriptFile(context, _a) { var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token; var memberName = token.text; - var isStatic = modifierFlags & 32 /* Static */; + var isStatic = modifierFlags & 32 /* ModifierFlags.Static */; var typeNode = getTypeNode(context.program.getTypeChecker(), parentDeclaration, token); var addPropertyDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName, typeNode, modifierFlags); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; if (isStatic || ts.isPrivateIdentifier(token)) { return actions; } - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); } actions.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode)); return actions; } function getTypeNode(checker, node, token) { var typeNode; - if (token.parent.parent.kind === 221 /* BinaryExpression */) { + if (token.parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); - typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NoTruncation */); + typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NodeBuilderFlags.NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NodeBuilderFlags.NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) { var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; @@ -156653,7 +157441,7 @@ var ts; } function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "x", @@ -156676,15 +157464,15 @@ var ts; } var methodName = token.text; var addMethodDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, call, token, modifierFlags, parentDeclaration, declSourceFile); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); + var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); } return actions; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var kind = ts.isClassLike(parentDeclaration) ? 169 /* MethodDeclaration */ : 168 /* MethodSignature */; + var kind = ts.isClassLike(parentDeclaration) ? 169 /* SyntaxKind.MethodDeclaration */ : 168 /* SyntaxKind.MethodSignature */; var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression); if (containingMethodDeclaration) { @@ -156704,7 +157492,7 @@ var ts; */ var hasStringInitializer = ts.some(parentDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 402653316 /* StringLike */); + return !!(type && type.flags & 402653316 /* TypeFlags.StringLike */); }); var enumMember = ts.factory.createEnumMember(token, hasStringInitializer ? ts.factory.createStringLiteral(token.text) : undefined); changes.replaceNode(parentDeclaration.getSourceFile(), parentDeclaration, ts.factory.updateEnumDeclaration(parentDeclaration, parentDeclaration.modifiers, parentDeclaration.name, ts.concatenate(parentDeclaration.members, ts.singleElementArray(enumMember))), { @@ -156714,7 +157502,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* SyntaxKind.FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); importAdder.writeFixes(changes); } @@ -156744,7 +157532,7 @@ var ts; var checker = context.program.getTypeChecker(); var props = ts.map(info.properties, function (prop) { var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop), info.parentDeclaration); - return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer); + return ts.factory.createPropertyAssignment(createPropertyNameFromSymbol(prop, target, quotePreference, checker), initializer); }); var options = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, @@ -156755,42 +157543,42 @@ var ts; importAdder.writeFixes(changes); } function tryGetValueFromType(context, checker, importAdder, quotePreference, type, enclosingDeclaration) { - if (type.flags & 3 /* AnyOrUnknown */) { + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return createUndefined(); } - if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { - return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { return ts.factory.createNumericLiteral(0); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { return ts.factory.createBigIntLiteral("0n"); } - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return ts.factory.createFalse(); } - if (type.flags & 1056 /* EnumLike */) { + if (type.flags & 1056 /* TypeFlags.EnumLike */) { var enumMember = type.symbol.exports ? ts.firstOrUndefined(ts.arrayFrom(type.symbol.exports.values())) : type.symbol; - var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); + var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* SymbolFlags.Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); return enumMember === undefined || name === undefined ? ts.factory.createNumericLiteral(0) : ts.factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { return ts.factory.createNumericLiteral(type.value); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } - if (type.flags & 128 /* StringLiteral */) { - return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & 128 /* TypeFlags.StringLiteral */) { + return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { return ts.factory.createNull(); } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t, enclosingDeclaration); }); return expression !== null && expression !== void 0 ? expression : createUndefined(); } @@ -156804,17 +157592,17 @@ var ts; }); return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */) { + if (ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) { var decl = ts.find(type.symbol.declarations || ts.emptyArray, ts.or(ts.isFunctionTypeNode, ts.isMethodSignature, ts.isMethodDeclaration)); if (decl === undefined) return createUndefined(); - var signature = checker.getSignaturesOfType(type, 0 /* Call */); + var signature = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (signature === undefined) return createUndefined(); - var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder); + var func = codefix.createSignatureDeclarationFromSignature(213 /* SyntaxKind.FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder); return func !== null && func !== void 0 ? func : createUndefined(); } - if (ts.getObjectFlags(type) & 1 /* Class */) { + if (ts.getObjectFlags(type) & 1 /* ObjectFlags.Class */) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (classDeclaration === undefined || ts.hasAbstractModifier(classDeclaration)) return createUndefined(); @@ -156829,8 +157617,8 @@ var ts; return ts.factory.createIdentifier("undefined"); } function isObjectLiteralType(type) { - return (type.flags & 524288 /* Object */) && - ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); + return (type.flags & 524288 /* TypeFlags.Object */) && + ((ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); } function getUnmatchedAttributes(checker, target, source) { var attrsType = checker.getContextualType(source.attributes); @@ -156854,7 +157642,7 @@ var ts; } } return ts.filter(targetProps, function (targetProp) { - return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName)); + return ts.isIdentifierText(targetProp.name, target, 1 /* LanguageVariant.JSX */) && !((targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */) || seenNames.has(targetProp.escapedName)); }); } function tryGetContainingMethodDeclaration(node, callExpression) { @@ -156864,6 +157652,15 @@ var ts; var declaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); }); return declaration && declaration.parent === node ? declaration : undefined; } + function createPropertyNameFromSymbol(symbol, target, quotePreference, checker) { + if (ts.isTransientSymbol(symbol) && symbol.nameType && symbol.nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + var expression = checker.symbolToExpression(symbol.nameType.symbol, 111551 /* SymbolFlags.Value */, symbol.valueDeclaration, 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */); + if (expression) { + return ts.factory.createComputedPropertyName(expression); + } + } + return ts.createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === 0 /* QuotePreference.Single */); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -156939,7 +157736,7 @@ var ts; break; } default: - ts.Debug.fail("Bad fixId: " + context.fixId); + ts.Debug.fail("Bad fixId: ".concat(context.fixId)); } }); }, @@ -157014,7 +157811,7 @@ var ts; // See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files // (now named `codeFixClassExtendAbstractPrivateProperty.ts`) var flags = ts.getSyntacticModifierFlags(ts.first(symbol.getDeclarations())); - return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + return !(flags & 8 /* ModifierFlags.Private */) && !!(flags & 128 /* ModifierFlags.Abstract */); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -157057,7 +157854,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 108 /* ThisKeyword */) + if (token.kind !== 108 /* SyntaxKind.ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -157201,7 +157998,7 @@ var ts; codeFixes.push(codefix.createCodeFixActionWithoutFixAll("fixModuleOption", changes, [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0, "esnext"])); } var target = ts.getEmitScriptTarget(compilerOptions); - var targetOutOfRange = target < 4 /* ES2017 */ || target > 99 /* ESNext */; + var targetOutOfRange = target < 4 /* ScriptTarget.ES2017 */ || target > 99 /* ScriptTarget.ESNext */; if (targetOutOfRange) { var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { var configObject = ts.getTsConfigObjectLiteralExpression(configFile); @@ -157280,17 +158077,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* SyntaxKind.ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* SyntaxKind.ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 94 /* ExtendsKeyword */ && - heritageClauses[1].token === 117 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* SyntaxKind.ExtendsKeyword */ && + heritageClauses[1].token === 117 /* SyntaxKind.ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* SyntaxKind.CommaToken */)); // Rough heuristic: delete trailing whitespace after keyword so that it's not excessive. // (Trailing because leading might be indentation, which is more sensitive.) var text = sourceFile.text; @@ -157387,7 +158184,7 @@ var ts; if (!isValidCharacter(character)) { return; } - var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(sourceFile, preferences, character) + "}"; + var replacement = useHtmlEntity ? htmlEntity[character] : "{".concat(ts.quote(sourceFile, preferences, character), "}"); changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -157494,7 +158291,7 @@ var ts; var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start); if (!importDeclaration) return; - var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); + var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); }); var actions; if (namespaceChanges.length) { @@ -157509,7 +158306,7 @@ var ts; }); function getImportDeclaration(sourceFile, program, start) { var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier); - if (!identifier || identifier.parent.kind !== 178 /* TypeReference */) + if (!identifier || identifier.parent.kind !== 178 /* SyntaxKind.TypeReference */) return; var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(identifier); @@ -157521,11 +158318,11 @@ var ts; // new type-only import declaration, but honestly I doubt anyone will ever use this // codefix at all, so it's probably not worth the lines of code. function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) { - if (importDeclaration.kind === 265 /* ImportEqualsDeclaration */) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importDeclaration.name); + if (importDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importDeclaration.name); return; } - var importClause = importDeclaration.kind === 267 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent; + var importClause = importDeclaration.kind === 267 /* SyntaxKind.ImportClause */ ? importDeclaration : importDeclaration.parent.parent; if (importClause.name && importClause.namedBindings) { // Cannot convert an import with a default import and named bindings to type-only // (it's a grammar error). @@ -157533,7 +158330,7 @@ var ts; } var checker = program.getTypeChecker(); var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) { - if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */) + if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* SymbolFlags.Value */) return true; }); if (importsValue) { @@ -157542,7 +158339,7 @@ var ts; // Don't convert it to type-only. return; } - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importClause); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importClause); } function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) { ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent); @@ -157578,7 +158375,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 29 /* LessThanToken */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -157620,7 +158417,7 @@ var ts; ]; } var result = []; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -157662,13 +158459,13 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 137 /* InferKeyword */ || isImport(token)) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 29 /* LessThanToken */) { + else if (token.kind === 29 /* SyntaxKind.LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (ts.isObjectBindingPattern(token.parent)) { @@ -157691,7 +158488,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -157702,7 +158499,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -157711,18 +158508,18 @@ var ts; changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } function isImport(token) { - return token.kind === 100 /* ImportKeyword */ - || token.kind === 79 /* Identifier */ && (token.parent.kind === 270 /* ImportSpecifier */ || token.parent.kind === 267 /* ImportClause */); + return token.kind === 100 /* SyntaxKind.ImportKeyword */ + || token.kind === 79 /* SyntaxKind.Identifier */ && (token.parent.kind === 270 /* SyntaxKind.ImportSpecifier */ || token.parent.kind === 267 /* SyntaxKind.ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 100 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function canDeleteEntireVariableStatement(sourceFile, token) { return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token; } function deleteEntireVariableStatement(changes, sourceFile, node) { - changes.delete(sourceFile, node.parent.kind === 237 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -157731,15 +158528,15 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { - changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_" + token.text)); + changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_".concat(token.text))); if (ts.isParameter(token.parent)) { ts.getJSDocParameterTags(token.parent).forEach(function (tag) { if (ts.isIdentifier(tag.name)) { - changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_" + tag.name.text)); + changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_".concat(tag.name.text))); } }); } @@ -157747,14 +158544,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return true; } } @@ -157809,8 +158606,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: var index = parent.parameters.indexOf(parameter); var referent = ts.isMethodDeclaration(parent) ? parent.name : parent; var entries = ts.FindAllReferences.Core.getReferencedSymbolsForNode(parent.pos, referent, program, sourceFiles, cancellationToken); @@ -157819,7 +158616,7 @@ var ts; var entry = entries_2[_i]; for (var _a = 0, _b = entry.references; _a < _b.length; _a++) { var reference = _b[_a]; - if (reference.kind === 1 /* Node */) { + if (reference.kind === 1 /* FindAllReferences.EntryKind.Node */) { // argument in super(...) var isSuperCall_1 = ts.isSuperKeyword(reference.node) && ts.isCallExpression(reference.node.parent) @@ -157840,20 +158637,20 @@ var ts; } } return true; - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. return isLastParameter(parent, parameter, isFixAll); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Setter must have a parameter return false; - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Getter cannot have parameters return true; default: @@ -157914,7 +158711,7 @@ var ts; var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -157925,8 +158722,8 @@ var ts; return; } // falls through - case 241 /* WhileStatement */: - case 242 /* ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: changes.delete(sourceFile, container); return; } @@ -157975,7 +158772,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* SyntaxKind.ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -157999,10 +158796,10 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 314 /* JSDocNullableType */) { + if (typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` - actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* TypeFlags.Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -158019,7 +158816,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* TypeFlags.Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -158036,22 +158833,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 229 /* AsExpression */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: - case 172 /* GetAccessor */: - case 176 /* IndexSignature */: - case 195 /* MappedType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 211 /* TypeAssertionExpression */: - case 254 /* VariableDeclaration */: + case 229 /* SyntaxKind.AsExpression */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 176 /* SyntaxKind.IndexSignature */: + case 195 /* SyntaxKind.MappedType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; default: return false; @@ -158086,7 +158883,7 @@ var ts; }); } }); function doChange(changes, sourceFile, name) { - changes.replaceNodeWithText(sourceFile, name, name.text + "()"); + changes.replaceNodeWithText(sourceFile, name, "".concat(name.text, "()")); } function getCallName(sourceFile, start) { var token = ts.getTokenAtPosition(sourceFile, start); @@ -158154,15 +158951,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: insertBefore = containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* SyntaxKind.FunctionKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */; + case 214 /* SyntaxKind.ArrowFunction */: + var kind = containingFunction.typeParameters ? 29 /* SyntaxKind.LessThanToken */ : 20 /* SyntaxKind.OpenParenToken */; insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -158177,11 +158974,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* SyntaxKind.Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 131 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 131 /* SyntaxKind.AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -158343,7 +159140,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* SyntaxKind.Identifier */ && token.kind !== 25 /* SyntaxKind.DotDotDotToken */ && token.kind !== 108 /* SyntaxKind.ThisKeyword */) { return undefined; } var parent = token.parent; @@ -158444,9 +159241,9 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { - var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { @@ -158454,7 +159251,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { @@ -158497,7 +159294,7 @@ var ts; function annotate(changes, importAdder, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* SyntaxKind.PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -158533,7 +159330,7 @@ var ts; var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host); if (typeNode) { var name = ts.factory.cloneNode(param.name); - ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(name, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); return { name: ts.factory.cloneNode(param.name), param: param, isOptional: !!inference.isOptional, typeNode: typeNode }; } }); @@ -158541,9 +159338,9 @@ var ts; return; } if (ts.isArrowFunction(signature) || ts.isFunctionExpression(signature)) { - var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) { - changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); } ts.forEach(inferences, function (_a) { var typeNode = _a.typeNode, param = _a.param; @@ -158552,7 +159349,7 @@ var ts; changes.insertNodeAt(sourceFile, param.getStart(sourceFile), jsDoc, { suffix: " " }); }); if (needParens) { - changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } else { @@ -158566,7 +159363,7 @@ var ts; function getReferences(token, program, cancellationToken) { // Position shouldn't matter since token is not a SourceFile. return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) { - return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; + return entry.kind !== 0 /* FindAllReferences.EntryKind.Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; }); } function inferTypeForVariableFromUsage(token, program, cancellationToken) { @@ -158584,19 +159381,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 171 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 134 /* ConstructorKeyword */, sourceFile); + case 171 /* SyntaxKind.Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: searchToken = containingFunction.name; break; } @@ -158738,24 +159535,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: usage.isNumber = true; break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -158763,20 +159560,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -158800,13 +159597,13 @@ var ts; } function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: usage.isNumber = true; break; - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: @@ -158816,65 +159613,65 @@ var ts; function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: // MultiplicativeOperator // falls through - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: // ShiftOperator // falls through - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator // falls through - case 50 /* AmpersandToken */: - case 51 /* BarToken */: - case 52 /* CaretToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 51 /* SyntaxKind.BarToken */: + case 52 /* SyntaxKind.CaretToken */: // CompoundAssignmentOperator // falls through - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 74 /* BarEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: // AdditiveOperator // falls through - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: // RelationalOperator // falls through - case 29 /* LessThanToken */: - case 32 /* LessThanEqualsToken */: - case 31 /* GreaterThanToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 1056 /* EnumLike */) { + if (operandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, operandType); } else { usage.isNumber = true; } break; - case 64 /* PlusEqualsToken */: - case 39 /* PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 1056 /* EnumLike */) { + if (otherOperandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, otherOperandType); } - else if (otherOperandType.flags & 296 /* NumberLike */) { + else if (otherOperandType.flags & 296 /* TypeFlags.NumberLike */) { usage.isNumber = true; } - else if (otherOperandType.flags & 402653316 /* StringLike */) { + else if (otherOperandType.flags & 402653316 /* TypeFlags.StringLike */) { usage.isString = true; } - else if (otherOperandType.flags & 1 /* Any */) { + else if (otherOperandType.flags & 1 /* TypeFlags.Any */) { // do nothing, maybe we'll learn something elsewhere } else { @@ -158882,31 +159679,31 @@ var ts; } break; // AssignmentOperators - case 63 /* EqualsToken */: - case 34 /* EqualsEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (node === parent.left) { usage.isString = true; } break; // LogicalOperator Or NullishCoalescing - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 254 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: - case 102 /* InstanceOfKeyword */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: // nothing to infer here break; } @@ -158926,7 +159723,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 208 /* CallExpression */) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -158951,7 +159748,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent.argumentExpression); var indexUsage = createEmptyUsage(); calculateUsageOfNode(parent, indexUsage); - if (indexType.flags & 296 /* NumberLike */) { + if (indexType.flags & 296 /* TypeFlags.NumberLike */) { usage.numberIndex = indexUsage; } else { @@ -158998,21 +159795,21 @@ var ts; low: function (t) { return t === stringNumber; } }, { - high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); }, - low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); } + high: function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); }, + low: function (t) { return !!(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); } }, { - high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); }, - low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); } + high: function (t) { return !(t.flags & (98304 /* TypeFlags.Nullable */ | 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) && !(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); }, + low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); } } ]; var good = removeLowPriorityInferences(inferences, priorities); - var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; }); + var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */; }); if (anons.length) { - good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); }); + good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */); }); good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* UnionReduction.Subtype */)); } function combineAnonymousTypes(anons) { if (anons.length === 1) { @@ -159031,22 +159828,22 @@ var ts; var p = _b[_a]; props.add(p.name, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType()); } - calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); - constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); - var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* String */); + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* SignatureKind.Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* SignatureKind.Construct */)); + var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* IndexKind.String */); if (stringIndexInfo) { stringIndices.push(stringIndexInfo.type); stringIndexReadonly = stringIndexReadonly || stringIndexInfo.isReadonly; } - var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* Number */); + var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* IndexKind.Number */); if (numberIndexInfo) { numberIndices.push(numberIndexInfo.type); numberIndexReadonly = numberIndexReadonly || numberIndexInfo.isReadonly; } } var members = ts.mapEntries(props, function (name, types) { - var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0; - var s = checker.createSymbol(4 /* Property */ | isOptional, name); + var isOptional = types.length < anons.length ? 16777216 /* SymbolFlags.Optional */ : 0; + var s = checker.createSymbol(4 /* SymbolFlags.Property */ | isOptional, name); s.type = checker.getUnionType(types); return [name, s]; }); @@ -159078,7 +159875,7 @@ var ts; var candidateTypes = (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); }); var callsType = ((_c = usage.calls) === null || _c === void 0 ? void 0 : _c.length) ? inferStructuralType(usage) : undefined; if (callsType && candidateTypes) { - types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* Subtype */)); + types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* UnionReduction.Subtype */)); } else { if (callsType) { @@ -159095,7 +159892,7 @@ var ts; var members = new ts.Map(); if (usage.properties) { usage.properties.forEach(function (u, name) { - var symbol = checker.createSymbol(4 /* Property */, name); + var symbol = checker.createSymbol(4 /* SymbolFlags.Property */, name); symbol.type = combineFromUsage(u); members.set(name, symbol); }); @@ -159123,7 +159920,7 @@ var ts; return true; } if (propUsage.calls) { - var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + var sigs = checker.getSignaturesOfType(source, 0 /* SignatureKind.Call */); return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); } else { @@ -159137,7 +159934,7 @@ var ts; * 2. inference to/from calls with a single signature */ function inferInstantiationFromUsage(type, usage) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !usage.properties) { return type; } var generic = type.target; @@ -159156,10 +159953,10 @@ var ts; if (genericType === typeParameter) { return [usageType]; } - else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + else if (genericType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); } - else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + else if (ts.getObjectFlags(genericType) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(usageType) & 4 /* ObjectFlags.Reference */) { // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference var genericArgs = checker.getTypeArguments(genericType); var usageArgs = checker.getTypeArguments(usageType); @@ -159173,8 +159970,8 @@ var ts; } return types; } - var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); - var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* SignatureKind.Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* SignatureKind.Call */); if (genericSigs.length === 1 && usageSigs.length === 1) { return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } @@ -159209,27 +160006,27 @@ var ts; function getSignatureFromCalls(calls) { var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); - var _loop_15 = function (i) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + var _loop_14 = function (i) { + var symbol = checker.createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg".concat(i))); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { - symbol.flags |= 16777216 /* Optional */; + symbol.flags |= 16777216 /* SymbolFlags.Optional */; } parameters.push(symbol); }; for (var i = 0; i < length; i++) { - _loop_15(i); + _loop_14(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* SignatureFlags.None */); } function addCandidateType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } function addCandidateThisType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } @@ -159313,7 +160110,7 @@ var ts; codefix.createCodeFixActionWithoutFixAll(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [ ts.createTextChange(sourceFile.checkJsDirective ? ts.createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end) - : ts.createTextSpan(0, 0), "// @ts-nocheck" + newLineCharacter), + : ts.createTextSpan(0, 0), "// @ts-nocheck".concat(newLineCharacter)), ])], ts.Diagnostics.Disable_checking_for_this_file), ]; if (ts.textChanges.isValidLocationToAddComment(sourceFile, span.start)) { @@ -159380,7 +160177,7 @@ var ts; * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub. */ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) { - if (preserveOptional === void 0) { preserveOptional = 3 /* All */; } + if (preserveOptional === void 0) { preserveOptional = 3 /* PreserveOptionalFlags.All */; } if (isAmbient === void 0) { isAmbient = false; } var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { @@ -159393,13 +160190,13 @@ var ts; var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration)); var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); - var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient; + var optional = !!(symbol.flags & 16777216 /* SymbolFlags.Optional */); + var ambient = !!(enclosingDeclaration.flags & 16777216 /* NodeFlags.Ambient */) || isAmbient; var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + var flags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { var importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); @@ -159408,11 +160205,11 @@ var ts; importSymbols(importAdder, importableReference.symbols); } } - addClassElement(ts.factory.createPropertyDeclaration(modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, + addClassElement(ts.factory.createPropertyDeclaration(modifiers, name, optional && (preserveOptional & 2 /* PreserveOptionalFlags.Property */) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -159439,8 +160236,8 @@ var ts; } break; } - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -159448,7 +160245,7 @@ var ts; // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures(); if (!ts.some(signatures)) { break; } @@ -159470,13 +160267,13 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), modifiers, quotePreference, body)); } } break; } function outputMethod(quotePreference, signature, modifiers, name, body) { - var method = createSignatureDeclarationFromSignature(169 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder); + var method = createSignatureDeclarationFromSignature(169 /* SyntaxKind.MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), enclosingDeclaration, importAdder); if (method) addClassElement(method); } @@ -159486,10 +160283,10 @@ var ts; var program = context.program; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); - var flags = 1 /* NoTruncation */ - | 256 /* SuppressAnyReturnType */ - | 524288 /* AllowEmptyTuple */ - | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */); + var flags = 1 /* NodeBuilderFlags.NoTruncation */ + | 256 /* NodeBuilderFlags.SuppressAnyReturnType */ + | 524288 /* NodeBuilderFlags.AllowEmptyTuple */ + | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; @@ -159542,7 +160339,7 @@ var ts; } } } - var questionToken = optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var questionToken = optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var asteriskToken = signatureDeclaration.asteriskToken; if (ts.isFunctionExpression(signatureDeclaration)) { return ts.factory.updateFunctionExpression(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body); @@ -159567,38 +160364,50 @@ var ts; var names = ts.map(args, function (arg) { return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined; }); - var types = isJs ? [] : ts.map(args, function (arg) { - return typeToAutoImportableTypeNode(checker, importAdder, checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, scriptTarget, /*flags*/ undefined, tracker); - }); + var instanceTypes = isJs ? [] : ts.map(args, function (arg) { return checker.getTypeAtLocation(arg); }); + var _a = getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker), argumentTypeNodes = _a.argumentTypeNodes, argumentTypeParameters = _a.argumentTypeParameters; var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; var asteriskToken = ts.isYieldExpression(parent) - ? ts.factory.createToken(41 /* AsteriskToken */) + ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined; - var typeParameters = isJs || typeArguments === undefined - ? undefined - : ts.map(typeArguments, function (_, i) { - return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); - }); - var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs); + var typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments); + var parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs); var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); switch (kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createMethodDeclaration(modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return ts.factory.createMethodSignature(modifiers, name, - /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */) : type); - case 256 /* FunctionDeclaration */: + /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */) : type); + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference)); default: ts.Debug.fail("Unexpected kind"); } } codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression; + function createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments) { + var usedNames = new ts.Set(argumentTypeParameters.map(function (pair) { return pair[0]; })); + var constraintsByName = new ts.Map(argumentTypeParameters); + if (typeArguments) { + var typeArgumentsWithNewTypes = typeArguments.filter(function (typeArgument) { return !argumentTypeParameters.some(function (pair) { var _a; return checker.getTypeAtLocation(typeArgument) === ((_a = pair[1]) === null || _a === void 0 ? void 0 : _a.argumentType); }); }); + var targetSize = usedNames.size + typeArgumentsWithNewTypes.length; + for (var i = 0; usedNames.size < targetSize; i += 1) { + usedNames.add(createTypeParameterName(i)); + } + } + return ts.map(ts.arrayFrom(usedNames.values()), function (usedName) { var _a; return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, usedName, (_a = constraintsByName.get(usedName)) === null || _a === void 0 ? void 0 : _a.constraint); }); + } + function createTypeParameterName(index) { + return 84 /* CharacterCodes.T */ + index <= 90 /* CharacterCodes.Z */ + ? String.fromCharCode(84 /* CharacterCodes.T */ + index) + : "T".concat(index); + } function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) { var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker); if (typeNode && ts.isImportTypeNode(typeNode)) { @@ -159612,15 +160421,107 @@ var ts; return ts.getSynthesizedDeepClone(typeNode); } codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode; + function typeContainsTypeParameter(type) { + if (type.isUnionOrIntersection()) { + return type.types.some(typeContainsTypeParameter); + } + return type.flags & 262144 /* TypeFlags.TypeParameter */; + } + function getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, flags, tracker) { + // Types to be used as the types of the parameters in the new function + // E.g. from this source: + // added("", 0) + // The value will look like: + // [{ typeName: { text: "string" } }, { typeName: { text: "number" }] + // And in the output function will generate: + // function added(a: string, b: number) { ... } + var argumentTypeNodes = []; + // Names of type parameters provided as arguments to the call + // E.g. from this source: + // added(value); + // The value will look like: + // [ + // ["T", { argumentType: { typeName: { text: "T" } } } ], + // ["U", { argumentType: { typeName: { text: "U" } } } ], + // ] + // And in the output function will generate: + // function added() { ... } + var argumentTypeParameters = new ts.Map(); + for (var i = 0; i < instanceTypes.length; i += 1) { + var instanceType = instanceTypes[i]; + // If the instance type contains a deep reference to an existing type parameter, + // instead of copying the full union or intersection, create a new type parameter + // E.g. from this source: + // function existing(value: T | U & string) { + // added/*1*/(value); + // We don't want to output this: + // function added(value: T | U & string) { ... } + // We instead want to output: + // function added(value: T) { ... } + if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) { + var synthesizedTypeParameterName = createTypeParameterName(i); + argumentTypeNodes.push(ts.factory.createTypeReferenceNode(synthesizedTypeParameterName)); + argumentTypeParameters.set(synthesizedTypeParameterName, undefined); + continue; + } + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + var widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType); + var argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker); + if (!argumentTypeNode) { + continue; + } + argumentTypeNodes.push(argumentTypeNode); + var argumentTypeParameter = getFirstTypeParameterName(instanceType); + // If the instance type is a type parameter with a constraint (other than an anonymous object), + // remember that constraint for when we create the new type parameter + // E.g. from this source: + // function existing(value: T) { + // added/*1*/(value); + // We don't want to output this: + // function added(value: T) { ... } + // We instead want to output: + // function added(value: T) { ... } + var instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint) + ? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker) + : undefined; + if (argumentTypeParameter) { + argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint }); + } + } + return { argumentTypeNodes: argumentTypeNodes, argumentTypeParameters: ts.arrayFrom(argumentTypeParameters.entries()) }; + } + codefix.getArgumentTypesAndTypeParameters = getArgumentTypesAndTypeParameters; + function isAnonymousObjectConstraintType(type) { + return (type.flags & 524288 /* TypeFlags.Object */) && type.objectFlags === 16 /* ObjectFlags.Anonymous */; + } + function getFirstTypeParameterName(type) { + var _a; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + for (var _i = 0, _b = type.types; _i < _b.length; _i++) { + var subType = _b[_i]; + var subTypeName = getFirstTypeParameterName(subType); + if (subTypeName) { + return subTypeName; + } + } + } + return type.flags & 262144 /* TypeFlags.TypeParameter */ + ? (_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName() + : undefined; + } function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { var parameters = []; + var parameterNameCounts = new ts.Map(); for (var i = 0; i < argCount; i++) { + var parameterName = (names === null || names === void 0 ? void 0 : names[i]) || "arg".concat(i); + var parameterNameCount = parameterNameCounts.get(parameterName); + parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1); var newParameter = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, - /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), + /*name*/ parameterName + (parameterNameCount || ""), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, + /*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -159649,8 +160550,8 @@ var ts; var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { var restParameter = ts.factory.createParameterDeclaration( - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)), + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)), /*initializer*/ undefined); parameters.push(restParameter); } @@ -159665,7 +160566,7 @@ var ts; } function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) { return ts.factory.createMethodDeclaration(modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); + /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); } function createStubbedMethodBody(quotePreference) { return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference); @@ -159674,16 +160575,16 @@ var ts; return ts.factory.createBlock([ts.factory.createThrowStatement(ts.factory.createNewExpression(ts.factory.createIdentifier("Error"), /*typeArguments*/ undefined, // TODO Handle auto quote preference. - [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* Single */)]))], + [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* QuotePreference.Single */)]))], /*multiline*/ true); } codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { - if (flags & 4 /* Public */) { - return ts.factory.createToken(123 /* PublicKeyword */); + if (flags & 4 /* ModifierFlags.Public */) { + return ts.factory.createToken(123 /* SyntaxKind.PublicKeyword */); } - else if (flags & 16 /* Protected */) { - return ts.factory.createToken(122 /* ProtectedKeyword */); + else if (flags & 16 /* ModifierFlags.Protected */) { + return ts.factory.createToken(122 /* SyntaxKind.ProtectedKeyword */); } return undefined; } @@ -159756,7 +160657,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -159832,17 +160733,17 @@ var ts; return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } function prepareModifierFlagsForAccessor(modifierFlags) { - modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor - modifierFlags &= ~8 /* Private */; - if (!(modifierFlags & 16 /* Protected */)) { - modifierFlags |= 4 /* Public */; + modifierFlags &= ~64 /* ModifierFlags.Readonly */; // avoid Readonly modifier because it will convert to get accessor + modifierFlags &= ~8 /* ModifierFlags.Private */; + if (!(modifierFlags & 16 /* ModifierFlags.Protected */)) { + modifierFlags |= 4 /* ModifierFlags.Public */; } return modifierFlags; } function prepareModifierFlagsForField(modifierFlags) { - modifierFlags &= ~4 /* Public */; - modifierFlags &= ~16 /* Protected */; - modifierFlags |= 8 /* Private */; + modifierFlags &= ~4 /* ModifierFlags.Public */; + modifierFlags &= ~16 /* ModifierFlags.Protected */; + modifierFlags |= 8 /* ModifierFlags.Private */; return modifierFlags; } function getAccessorConvertiblePropertyAtPosition(file, program, start, end, considerEmptySpans) { @@ -159851,7 +160752,7 @@ var ts; var cursorRequest = start === end && considerEmptySpans; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier - var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; + var meaning = 28 /* ModifierFlags.AccessibilityModifier */ | 32 /* ModifierFlags.Static */ | 64 /* ModifierFlags.Readonly */; if (!declaration || (!(ts.nodeOverlapsWithStartEnd(declaration.name, file, start, end) || cursorRequest))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_property_for_which_to_generate_accessor) @@ -159862,20 +160763,20 @@ var ts; error: ts.getLocaleSpecificMessage(ts.Diagnostics.Name_is_not_valid) }; } - if (((ts.getEffectiveModifierFlags(declaration) & 125951 /* Modifier */) | meaning) !== meaning) { + if (((ts.getEffectiveModifierFlags(declaration) & 125951 /* ModifierFlags.Modifier */) | meaning) !== meaning) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_property_with_modifier) }; } var name = declaration.name.text; var startWithUnderscore = ts.startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_".concat(name), file), declaration.name); var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 164 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 164 /* SyntaxKind.Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -159928,13 +160829,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 108 /* ThisKeyword */ && + node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.factory.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -159949,7 +160850,7 @@ var ts; var type = typeChecker.getTypeFromTypeNode(typeNode); if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) { var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode]; - return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)], false)); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)], false)); } } return typeNode; @@ -159961,7 +160862,7 @@ var ts; var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); if (!superSymbol) break; - var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; + var symbol = superSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; @@ -160007,7 +160908,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* CallExpression */ : 209 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* SyntaxKind.CallExpression */ : 209 /* SyntaxKind.NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -160125,7 +161026,7 @@ var ts; } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { ts.suppressLeadingAndTrailingTrivia(propertyDeclaration); - var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* SyntaxKind.ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, info) { @@ -160133,7 +161034,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, sourceFile, info) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode]; var unionTypeNode = ts.factory.createUnionTypeNode(types); if (info.isJs) { @@ -160162,7 +161063,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } else if (type.isStringLiteral()) { @@ -160171,7 +161072,7 @@ var ts; else if (type.isNumberLiteral()) { return ts.factory.createNumericLiteral(type.value); } - else if (type.flags & 2048 /* BigIntLiteral */) { + else if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } else if (type.isUnion()) { @@ -160179,7 +161080,7 @@ var ts; } else if (type.isClass()) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); - if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* Abstract */)) + if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* ModifierFlags.Abstract */)) return undefined; var constructorDeclaration = ts.getFirstConstructorWithBody(classDeclaration); if (constructorDeclaration && constructorDeclaration.parameters.length) @@ -160355,8 +161256,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 200 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* SyntaxKind.ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 200 /* SyntaxKind.ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -160419,7 +161320,7 @@ var ts; var children = []; var current = node; while (true) { - if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { children.push(current.left); if (ts.isJsxChild(current.right)) { children.push(current.right); @@ -160485,7 +161386,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type, /*members*/ undefined); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [ @@ -160543,7 +161444,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* SyntaxKind.AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -160554,7 +161455,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* SyntaxKind.NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -160625,7 +161526,7 @@ var ts; var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.parent, ts.isVariableDeclarationList); if (declaration === undefined) return; - var constToken = ts.findChildOfKind(declaration, 85 /* ConstKeyword */, sourceFile); + var constToken = ts.findChildOfKind(declaration, 85 /* SyntaxKind.ConstKeyword */, sourceFile); if (constToken === undefined) return; return ts.createRange(constToken.pos, constToken.end); @@ -160662,14 +161563,14 @@ var ts; }); function getInfo(sourceFile, pos, _) { var node = ts.getTokenAtPosition(sourceFile, pos); - return (node.kind === 26 /* SemicolonToken */ && + return (node.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent && (ts.isObjectLiteralExpression(node.parent) || ts.isArrayLiteralExpression(node.parent))) ? { node: node } : undefined; } function doChange(changes, sourceFile, _a) { var node = _a.node; - var newNode = ts.factory.createToken(27 /* CommaToken */); + var newNode = ts.factory.createToken(27 /* SyntaxKind.CommaToken */); changes.replaceNode(sourceFile, node, newNode); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -160717,7 +161618,7 @@ var ts; // append ` | void` to type argument var typeArgument = typeArguments[0]; var needsParens = !ts.isUnionTypeNode(typeArgument) && !ts.isParenthesizedTypeNode(typeArgument) && - ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -160729,14 +161630,14 @@ var ts; var parameter = signature === null || signature === void 0 ? void 0 : signature.parameters[0]; var parameterType = parameter && checker.getTypeOfSymbolAtLocation(parameter, decl.parent.parent); if (ts.isInJSFile(decl)) { - if (!parameterType || parameterType.flags & 3 /* AnyOrUnknown */) { + if (!parameterType || parameterType.flags & 3 /* TypeFlags.AnyOrUnknown */) { // give the expression a type changes.insertText(sourceFile, decl.parent.parent.end, ")"); changes.insertText(sourceFile, ts.skipTrivia(sourceFile.text, decl.parent.parent.pos), "/** @type {Promise} */("); } } else { - if (!parameterType || parameterType.flags & 2 /* Unknown */) { + if (!parameterType || parameterType.flags & 2 /* TypeFlags.Unknown */) { // add `void` type argument changes.insertText(sourceFile, decl.parent.parent.expression.end, ""); } @@ -160812,16 +161713,16 @@ var ts; var file = context.file, program = context.program; var span = ts.getRefactorContextSpan(context); var token = ts.getTokenAtPosition(file, span.start); - var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); + var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* ModifierFlags.Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var checker = program.getTypeChecker(); var exportingModuleSymbol = getExportingModuleSymbol(exportNode, checker); - var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); - var wasDefault = !!(flags & 512 /* Default */); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ModifierFlags.ExportDefault */ : 0 /* ModifierFlags.None */); + var wasDefault = !!(flags & 512 /* ModifierFlags.Default */); // If source file already has a default export, don't offer refactor. - if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + if (!(flags & 1 /* ModifierFlags.Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* InternalSymbolName.Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } var noSymbolError = function (id) { @@ -160829,22 +161730,22 @@ var ts; : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; }; switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: { var node = exportNode; if (!node.name) return undefined; return noSymbolError(node.name) || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. - if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { + if (!(vs.declarationList.flags & 2 /* NodeFlags.Const */) || vs.declarationList.declarations.length !== 1) { return undefined; } var decl = ts.first(vs.declarationList.declarations); @@ -160854,7 +161755,7 @@ var ts; return noSymbolError(decl.name) || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var node = exportNode; if (node.isExportEquals) return undefined; @@ -160878,18 +161779,18 @@ var ts; changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports([spec]))); } else { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* SyntaxKind.DefaultKeyword */), "Should find a default keyword in modifier list")); } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* SyntaxKind.ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* SyntaxKind.DefaultKeyword */)); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;` var decl = ts.first(exportNode.declarationList.declarations); if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) { @@ -160898,15 +161799,15 @@ var ts; break; } // falls through - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text))); break; default: - ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind ".concat(exportNode.kind)); } } } @@ -160929,18 +161830,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 267 /* ImportClause */: { + case 267 /* SyntaxKind.ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -160949,10 +161850,10 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 268 /* NamespaceImport */) { + else if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); - var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* QuotePreference.Double */; var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } @@ -160963,7 +161864,7 @@ var ts; } break; } - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: var importTypeNode = parent; changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, importTypeNode.assertions, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf)); break; @@ -160974,11 +161875,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 270 /* ImportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.factory.createIdentifier(parent.name.text); @@ -160991,7 +161892,7 @@ var ts; } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -161000,7 +161901,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); + ts.Debug.assertNever(parent, "Unexpected parent kind ".concat(parent.kind)); } } function makeImportSpecifier(propertyName, name) { @@ -161030,17 +161931,17 @@ var ts; var _a; var refactorName = "Convert import"; var actions = (_a = {}, - _a[0 /* Named */] = { + _a[0 /* ImportKind.Named */] = { name: "Convert namespace import to named imports", description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message, kind: "refactor.rewrite.import.named", }, - _a[2 /* Namespace */] = { + _a[2 /* ImportKind.Namespace */] = { name: "Convert named imports to namespace import", description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message, kind: "refactor.rewrite.import.namespace", }, - _a[1 /* Default */] = { + _a[1 /* ImportKind.Default */] = { name: "Convert named imports to default import", description: ts.Diagnostics.Convert_named_imports_to_default_import.message, kind: "refactor.rewrite.import.default", @@ -161092,13 +161993,13 @@ var ts; if (!importClause.namedBindings) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) }; } - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { - return { convertTo: 0 /* Named */, import: importClause.namedBindings }; + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { + return { convertTo: 0 /* ImportKind.Named */, import: importClause.namedBindings }; } var shouldUseDefault = getShouldUseDefault(context.program, importClause); return shouldUseDefault - ? { convertTo: 1 /* Default */, import: importClause.namedBindings } - : { convertTo: 2 /* Namespace */, import: importClause.namedBindings }; + ? { convertTo: 1 /* ImportKind.Default */, import: importClause.namedBindings } + : { convertTo: 2 /* ImportKind.Namespace */, import: importClause.namedBindings }; } function getShouldUseDefault(program, importClause) { return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()) @@ -161106,11 +162007,11 @@ var ts; } function doChange(sourceFile, program, changes, info) { var checker = program.getTypeChecker(); - if (info.convertTo === 0 /* Named */) { + if (info.convertTo === 0 /* ImportKind.Named */) { doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { - doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */); + doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* ImportKind.Default */); } } function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { @@ -161123,7 +162024,7 @@ var ts; } else { var exportName = getRightOfPropertyAccessOrQualifiedName(id.parent).text; - if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + if (checker.resolveName(exportName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } ts.Debug.assert(getLeftOfPropertyAccessOrQualifiedName(id.parent) === id, "Parent expression should match id"); @@ -161172,14 +162073,14 @@ var ts; toConvertSymbols.add(symbol); } }); - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ESNext */) : "module"; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ScriptTarget.ESNext */) : "module"; function hasNamespaceNameConflict(namedImport) { // We need to check if the preferred namespace name (`preferredName`) we'd like to use in the refactored code will present a name conflict. // A name conflict means that, in a scope where we would like to use the preferred namespace name, there already exists a symbol with that name in that scope. // We are going to use the namespace name in the scopes the named imports being refactored are referenced, // so we look for conflicts by looking at every reference to those named imports. return !!ts.FindAllReferences.Core.eachSymbolReferenceInFile(namedImport.name, checker, sourceFile, function (id) { - var symbol = checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(preferredName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (symbol) { // There already is a symbol with the same name as the preferred namespace name. if (toConvertSymbols.has(symbol)) { // `preferredName` resolves to a symbol for one of the named import references we are going to transform into namespace import references... return ts.isExportSpecifier(id.parent); // ...but if this reference is an export specifier, it will not be transformed, so it is a conflict; otherwise, it will be renamed and is not a conflict. @@ -161194,7 +162095,7 @@ var ts; // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics. // More specifically, those are named imports that appear in named exports in the original code, e.g. `a` in `import { a } from "m"; export { a }`. var neededNamedImports = new ts.Set(); - var _loop_16 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName); @@ -161211,7 +162112,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_16(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, shouldUseDefault ? ts.factory.createIdentifier(namespaceImportName) @@ -161328,7 +162229,7 @@ var ts; } } function getBinaryInfo(expression) { - if (expression.operatorToken.kind !== 55 /* AmpersandAmpersandToken */) { + if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) }; } ; @@ -161344,7 +162245,7 @@ var ts; */ function getOccurrencesInExpression(matchTo, expression) { var occurrences = []; - while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var match = getMatchingStart(ts.skipParentheses(matchTo), ts.skipParentheses(expression.right)); if (!match) { break; @@ -161470,17 +162371,17 @@ var ts; occurrences.pop(); if (ts.isCallExpression(toConvert)) { return isOccurrence ? - ts.factory.createCallChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : + ts.factory.createCallChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : ts.factory.createCallChain(chain, toConvert.questionDotToken, toConvert.typeArguments, toConvert.arguments); } else if (ts.isPropertyAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.name) : + ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.name) : ts.factory.createPropertyAccessChain(chain, toConvert.questionDotToken, toConvert.name); } else if (ts.isElementAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.argumentExpression) : + ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.argumentExpression) : ts.factory.createElementAccessChain(chain, toConvert.questionDotToken, toConvert.argumentExpression); } } @@ -161495,7 +162396,7 @@ var ts; changes.replaceNodeRange(sourceFile, firstOccurrence, finalExpression, convertedChain); } else if (ts.isConditionalExpression(expression)) { - changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* QuestionQuestionToken */), expression.whenFalse)); + changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* SyntaxKind.QuestionQuestionToken */), expression.whenFalse)); } } } @@ -161541,27 +162442,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 175 /* ConstructSignature */: { + case 175 /* SyntaxKind.ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -161582,24 +162483,24 @@ var ts; } return ts.factory.createNodeArray([ ts.factory.createParameterDeclaration( - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), "args", + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), "args", /*questionToken*/ undefined, ts.factory.createUnionTypeNode(ts.map(signatureDeclarations, convertSignatureParametersToTuple))) ]); } function convertSignatureParametersToTuple(decl) { var members = ts.map(decl.parameters, convertParameterToNamedTupleMember); - return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* None */ : 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* EmitFlags.None */ : 1 /* EmitFlags.SingleLine */); } function convertParameterToNamedTupleMember(p) { ts.Debug.assert(ts.isIdentifier(p.name)); // This is checked during refactoring applicability checking - var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); if (newComment.length) { ts.setSyntheticLeadingComments(result, [{ - text: "*\n" + newComment.split("\n").map(function (c) { return " * " + c; }).join("\n") + "\n ", - kind: 3 /* MultiLineCommentTrivia */, + text: "*\n".concat(newComment.split("\n").map(function (c) { return " * ".concat(c); }).join("\n"), "\n "), + kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, pos: -1, end: -1, hasTrailingNewLine: true, @@ -161612,12 +162513,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: return true; } return false; @@ -161628,6 +162529,9 @@ var ts; if (!containingDecl) { return; } + if (ts.isFunctionLikeDeclaration(containingDecl) && containingDecl.body && ts.rangeContainsPosition(containingDecl.body, startPosition)) { + return; + } var checker = program.getTypeChecker(); var signatureSymbol = containingDecl.symbol; if (!signatureSymbol) { @@ -161743,7 +162647,7 @@ var ts; usedFunctionNames.set(description, true); functionActions.push({ description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), kind: extractFunctionAction.kind }); } @@ -161751,7 +162655,7 @@ var ts; else if (!innermostErrorFunctionAction) { innermostErrorFunctionAction = { description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), notApplicableReason: getStringError(functionExtraction.errors), kind: extractFunctionAction.kind }; @@ -161767,7 +162671,7 @@ var ts; usedConstantNames.set(description_1, true); constantActions.push({ description: description_1, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), kind: extractConstantAction.kind }); } @@ -161775,7 +162679,7 @@ var ts; else if (!innermostErrorConstantAction) { innermostErrorConstantAction = { description: description, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), notApplicableReason: getStringError(constantExtraction.errors), kind: extractConstantAction.kind }; @@ -161920,7 +162824,7 @@ var ts; // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - if (start.flags & 8388608 /* JSDoc */) { + if (start.flags & 8388608 /* NodeFlags.JSDoc */) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; } if (start.parent !== end.parent) { @@ -162009,20 +162913,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 167 /* PropertyDeclaration */) { + if (current.kind === 167 /* SyntaxKind.PropertyDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 164 /* Parameter */) { + else if (current.kind === 164 /* SyntaxKind.Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 171 /* Constructor */) { + if (ctorOrMethod.kind === 171 /* SyntaxKind.Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 169 /* MethodDeclaration */) { + else if (current.kind === 169 /* SyntaxKind.MethodDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -162046,7 +162950,7 @@ var ts; if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 16777216 /* Ambient */) { + if (nodeToCheck.flags & 16777216 /* NodeFlags.Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -162055,14 +162959,14 @@ var ts; checkForStaticContext(nodeToCheck, containingClass); } var errors; - var permittedJumps = 4 /* Return */; + var permittedJumps = 4 /* PermittedJumps.Return */; var seenLabels; visit(nodeToCheck); if (rangeFacts & RangeFacts.UsesThis) { var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false); - if (container.kind === 256 /* FunctionDeclaration */ || - (container.kind === 169 /* MethodDeclaration */ && container.parent.kind === 205 /* ObjectLiteralExpression */) || - container.kind === 213 /* FunctionExpression */) { + if (container.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) || + container.kind === 213 /* SyntaxKind.FunctionExpression */) { rangeFacts |= RangeFacts.UsesThisInFunction; } } @@ -162073,8 +162977,8 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 254 /* VariableDeclaration */) ? node.parent.parent : node; - if (ts.hasSyntacticModifier(declaringNode, 1 /* Export */)) { + var declaringNode = (node.kind === 254 /* SyntaxKind.VariableDeclaration */) ? node.parent.parent : node; + if (ts.hasSyntacticModifier(declaringNode, 1 /* ModifierFlags.Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! // Also TODO: GH#19956 @@ -162085,16 +162989,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 208 /* CallExpression */) { + if (node.parent.kind === 208 /* SyntaxKind.CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -162107,7 +163011,7 @@ var ts; thisNode = node; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -162122,64 +163026,64 @@ var ts; } }); // falls through - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); } // falls through - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 239 /* IfStatement */: - permittedJumps = 0 /* None */; + case 239 /* SyntaxKind.IfStatement */: + permittedJumps &= ~4 /* PermittedJumps.Return */; break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // forbid all jumps inside try blocks - permittedJumps = 0 /* None */; + permittedJumps = 0 /* PermittedJumps.None */; break; - case 235 /* Block */: - if (node.parent && node.parent.kind === 252 /* TryStatement */ && node.parent.finallyBlock === node) { + case 235 /* SyntaxKind.Block */: + if (node.parent && node.parent.kind === 252 /* SyntaxKind.TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks - permittedJumps = 4 /* Return */; + permittedJumps = 4 /* PermittedJumps.Return */; } break; - case 290 /* DefaultClause */: - case 289 /* CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: // allow unlabeled break inside case clauses - permittedJumps |= 1 /* Break */; + permittedJumps |= 1 /* PermittedJumps.Break */; break; default: if (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false)) { // allow unlabeled break/continue inside loops - permittedJumps |= 1 /* Break */ | 2 /* Continue */; + permittedJumps |= 1 /* PermittedJumps.Break */ | 2 /* PermittedJumps.Continue */; } break; } switch (node.kind) { - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; thisNode = node; break; - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: { + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -162188,21 +163092,21 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 246 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 246 /* SyntaxKind.BreakStatement */ ? 1 /* PermittedJumps.Break */ : 2 /* PermittedJumps.Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 247 /* ReturnStatement */: - if (permittedJumps & 4 /* Return */) { + case 247 /* SyntaxKind.ReturnStatement */: + if (permittedJumps & 4 /* PermittedJumps.Return */) { rangeFacts |= RangeFacts.HasReturn; } else { @@ -162225,7 +163129,7 @@ var ts; function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { var start = startNode.getStart(sourceFile); var end = endNode.getEnd(); - if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + if (sourceFile.text.charCodeAt(end) === 59 /* CharacterCodes.semicolon */) { end++; } return { start: start, length: end - start }; @@ -162271,7 +163175,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 164 /* Parameter */) { + if (current.kind === 164 /* SyntaxKind.Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -162282,7 +163186,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 305 /* SourceFile */) { + if (current.kind === 305 /* SyntaxKind.SourceFile */) { return scopes; } } @@ -162322,11 +163226,11 @@ var ts; : getDescriptionForModuleLikeDeclaration(scope); var functionDescription; var constantDescription; - if (scopeDescription === 1 /* Global */) { + if (scopeDescription === 1 /* SpecialScope.Global */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "global"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "global"]); } - else if (scopeDescription === 0 /* Module */) { + else if (scopeDescription === 0 /* SpecialScope.Module */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "module"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "module"]); } @@ -162372,34 +163276,34 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return scope.name - ? "function '" + scope.name.text + "'" + ? "function '".concat(scope.name.text, "'") : ts.ANONYMOUS; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return "arrow function"; - case 169 /* MethodDeclaration */: - return "method '" + scope.name.getText() + "'"; - case 172 /* GetAccessor */: - return "'get " + scope.name.getText() + "'"; - case 173 /* SetAccessor */: - return "'set " + scope.name.getText() + "'"; + case 169 /* SyntaxKind.MethodDeclaration */: + return "method '".concat(scope.name.getText(), "'"); + case 172 /* SyntaxKind.GetAccessor */: + return "'get ".concat(scope.name.getText(), "'"); + case 173 /* SyntaxKind.SetAccessor */: + return "'set ".concat(scope.name.getText(), "'"); default: - throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); + throw ts.Debug.assertNever(scope, "Unexpected scope kind ".concat(scope.kind)); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 257 /* ClassDeclaration */ - ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" - : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + return scope.kind === 257 /* SyntaxKind.ClassDeclaration */ + ? scope.name ? "class '".concat(scope.name.text, "'") : "anonymous class declaration" + : scope.name ? "class expression '".concat(scope.name.text, "'") : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 262 /* ModuleBlock */ - ? "namespace '" + scope.parent.name.getText() + "'" - : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; + return scope.kind === 262 /* SyntaxKind.ModuleBlock */ + ? "namespace '".concat(scope.parent.name.getText(), "'") + : scope.externalModuleIndicator ? 0 /* SpecialScope.Module */ : 1 /* SpecialScope.Global */; } var SpecialScope; (function (SpecialScope) { @@ -162430,7 +163334,7 @@ var ts; var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" type = checker.getBaseTypeOfLiteralType(type); - typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NoTruncation */); + typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NodeBuilderFlags.NoTruncation */); } var paramDecl = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, @@ -162438,7 +163342,7 @@ var ts; /*name*/ name, /*questionToken*/ undefined, typeNode); parameters.push(paramDecl); - if (usage.usage === 2 /* Write */) { + if (usage.usage === 2 /* Usage.Write */) { (writes || (writes = [])).push(usage); } callArguments.push(ts.factory.createIdentifier(name)); @@ -162457,7 +163361,7 @@ var ts; // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); - returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217 + returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 } var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; ts.suppressLeadingAndTrailingTrivia(body); @@ -162465,14 +163369,14 @@ var ts; var callThis = !!(range.facts & RangeFacts.UsesThisInFunction); if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(131 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(131 /* SyntaxKind.AsyncKeyword */)); } - newFunction = ts.factory.createMethodDeclaration(modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, + newFunction = ts.factory.createMethodDeclaration(modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { @@ -162481,10 +163385,10 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ "this", - /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NoTruncation */), + /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NodeBuilderFlags.NoTruncation */), /*initializer*/ undefined)); } - newFunction = ts.factory.createFunctionDeclaration(range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + newFunction = ts.factory.createFunctionDeclaration(range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* SyntaxKind.AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -162505,7 +163409,7 @@ var ts; var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call); + call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.factory.createAwaitExpression(call); @@ -162539,7 +163443,7 @@ var ts; /*propertyName*/ undefined, /*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name))); // Being returned through an object literal will have widened the type. - var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */); + var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NodeBuilderFlags.NoTruncation */); typeElements.push(ts.factory.createPropertySignature( /*modifiers*/ undefined, /*name*/ variableDeclaration.symbol.name, @@ -162550,7 +163454,7 @@ var ts; } var typeLiteral = sawExplicitType ? ts.factory.createTypeLiteralNode(typeElements) : undefined; if (typeLiteral) { - ts.setEmitFlags(typeLiteral, 1 /* SingleLine */); + ts.setEmitFlags(typeLiteral, 1 /* EmitFlags.SingleLine */); } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.factory.createObjectBindingPattern(bindingElements), @@ -162565,8 +163469,8 @@ var ts; for (var _c = 0, exposedVariableDeclarations_2 = exposedVariableDeclarations; _c < exposedVariableDeclarations_2.length; _c++) { var variableDeclaration = exposedVariableDeclarations_2[_c]; var flags = variableDeclaration.parent.flags; - if (flags & 2 /* Const */) { - flags = (flags & ~2 /* Const */) | 1 /* Let */; + if (flags & 2 /* NodeFlags.Const */) { + flags = (flags & ~2 /* NodeFlags.Const */) | 1 /* NodeFlags.Let */; } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(variableDeclaration.symbol.name, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(variableDeclaration.type))], flags))); @@ -162575,7 +163479,7 @@ var ts; if (returnValueProperty) { // has both writes and return, need to create variable declaration to hold return value; newNodes.push(ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* Let */))); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* NodeFlags.Let */))); } var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (returnValueProperty) { @@ -162632,9 +163536,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* SyntaxKind.UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } } /** @@ -162647,13 +163551,13 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable var file = scope.getSourceFile(); - var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) + var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) ? node.name.text : ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJSFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined - : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 + : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(ts.skipParentheses(node), substitutions); (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); @@ -162661,11 +163565,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(145 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration(modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); var localReference = ts.factory.createPropertyAccessExpression(rangeFacts & RangeFacts.InStaticRegion @@ -162696,16 +163600,16 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 238 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); changeTracker.replaceNode(context.file, node.parent, newVariableStatement); } else { var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); // Declare var nodeToInsertBefore = getNodeToInsertConstantBefore(node, scope); if (nodeToInsertBefore.pos === 0) { @@ -162715,7 +163619,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -162742,7 +163646,7 @@ var ts; if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) return { variableType: variableType, initializer: initializer }; var functionType = checker.getTypeAtLocation(node); - var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* SignatureKind.Call */)); // If no function signature, maybe there was an error, do nothing if (!functionSignature) return { variableType: variableType, initializer: initializer }; @@ -162761,7 +163665,7 @@ var ts; var paramType = checker.getTypeAtLocation(p); if (paramType === checker.getAnyType()) hasAny = true; - parameters.push(ts.factory.updateParameterDeclaration(p, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + parameters.push(ts.factory.updateParameterDeclaration(p, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NodeBuilderFlags.NoTruncation */), p.initializer)); } } // If a parameter was inferred as any we skip adding function parameters at all. @@ -162771,7 +163675,7 @@ var ts; return { variableType: variableType, initializer: initializer }; variableType = undefined; if (ts.isArrowFunction(initializer)) { - initializer = ts.factory.updateArrowFunction(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + initializer = ts.factory.updateArrowFunction(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); } else { if (functionSignature && !!functionSignature.thisParameter) { @@ -162783,10 +163687,10 @@ var ts; parameters.splice(0, 0, ts.factory.createParameterDeclaration( /* modifiers */ undefined, /* dotDotDotToken */ undefined, "this", - /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NodeBuilderFlags.NoTruncation */))); } } - initializer = ts.factory.updateFunctionExpression(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + initializer = ts.factory.updateFunctionExpression(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.body); } return { variableType: variableType, initializer: initializer }; } @@ -163033,7 +163937,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* TypeFlags.Void */ | 131072 /* TypeFlags.Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -163102,7 +164006,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_17 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -163117,11 +164021,11 @@ var ts; var hasWrite = false; var readonlyClassPropertyWrite; usagesPerScope[i].usages.forEach(function (value) { - if (value.usage === 2 /* Write */) { + if (value.usage === 2 /* Usage.Write */) { hasWrite = true; - if (value.symbol.flags & 106500 /* ClassMember */ && + if (value.symbol.flags & 106500 /* SymbolFlags.ClassMember */ && value.symbol.valueDeclaration && - ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* ModifierFlags.Readonly */)) { readonlyClassPropertyWrite = value.symbol.valueDeclaration; } } @@ -163145,7 +164049,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_17(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -163165,7 +164069,7 @@ var ts; } } function collectUsages(node, valueUsage) { - if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (valueUsage === void 0) { valueUsage = 1 /* Usage.Read */; } if (inGenericContext) { var type = checker.getTypeAtLocation(node); recordTypeParameterUsages(type); @@ -163175,11 +164079,11 @@ var ts; } if (ts.isAssignmentExpression(node)) { // use 'write' as default usage for values - collectUsages(node.left, 2 /* Write */); + collectUsages(node.left, 2 /* Usage.Write */); collectUsages(node.right); } else if (ts.isUnaryExpressionWithWrite(node)) { - collectUsages(node.operand, 2 /* Write */); + collectUsages(node.operand, 2 /* Usage.Write */); } else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { // use 'write' as default usage for values @@ -163253,7 +164157,7 @@ var ts; // declaration is located in range to be extracted - do nothing return undefined; } - if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Write */) { + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Usage.Write */) { // this is write to a reference located outside of the target scope and range is extracted into generator // currently this is unsupported scenario var diag = ts.createDiagnosticForNode(identifier, Messages.cannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators); @@ -163280,7 +164184,7 @@ var ts; else if (isTypeName) { // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument // so there's no problem. - if (!(symbol.flags & 262144 /* TypeParameter */)) { + if (!(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var diag = ts.createDiagnosticForNode(identifier, Messages.typeWillNotBeVisibleInTheNewScope); functionErrorsPerScope[i].push(diag); constantErrorsPerScope[i].push(diag); @@ -163361,30 +164265,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return false; } switch (node.kind) { - case 10 /* StringLiteral */: - return parent.kind !== 266 /* ImportDeclaration */ && - parent.kind !== 270 /* ImportSpecifier */; - case 225 /* SpreadElement */: - case 201 /* ObjectBindingPattern */: - case 203 /* BindingElement */: + case 10 /* SyntaxKind.StringLiteral */: + return parent.kind !== 266 /* SyntaxKind.ImportDeclaration */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */; + case 225 /* SyntaxKind.SpreadElement */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 203 /* SyntaxKind.BindingElement */: return false; - case 79 /* Identifier */: - return parent.kind !== 203 /* BindingElement */ && - parent.kind !== 270 /* ImportSpecifier */ && - parent.kind !== 275 /* ExportSpecifier */; + case 79 /* SyntaxKind.Identifier */: + return parent.kind !== 203 /* SyntaxKind.BindingElement */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */ && + parent.kind !== 275 /* SyntaxKind.ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 235 /* Block */: - case 305 /* SourceFile */: - case 262 /* ModuleBlock */: - case 289 /* CaseClause */: + case 235 /* SyntaxKind.Block */: + case 305 /* SyntaxKind.SourceFile */: + case 262 /* SyntaxKind.ModuleBlock */: + case 289 /* SyntaxKind.CaseClause */: return true; default: return false; @@ -163530,7 +164434,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var typeName = node.typeName; - var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); + var symbol = checker.resolveName(typeName.text, typeName, 262144 /* SymbolFlags.TypeParameter */, /* excludeGlobals */ true); for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) { var decl = _a[_i]; if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) { @@ -163561,7 +164465,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* SymbolFlags.Value */, /* excludeGlobals */ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -163573,7 +164477,7 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.forEachChild(node, visitor); } @@ -163597,7 +164501,7 @@ var ts; } function doTypedefChange(changes, file, name, info) { var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; - ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(selection, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name)); var templates = []; ts.forEach(typeParameters, function (typeParameter) { @@ -163752,7 +164656,7 @@ var ts; var usage = getUsageInfo(oldFile, toMove.all, checker); var currentDirectory = ts.getDirectoryPath(oldFile.fileName); var extension = ts.extensionFromPath(oldFile.fileName); - var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host); + var newModuleName = makeUniqueModuleName(getNewModuleName(usage.oldFileImportsFromNewFile, usage.movedSymbols), extension, currentDirectory, host); var newFileNameWithExtension = newModuleName + extension; // If previous file was global, this is easy. changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences)); @@ -163781,11 +164685,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return true; - case 265 /* ImportEqualsDeclaration */: - return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 237 /* VariableStatement */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return !ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); + case 237 /* SyntaxKind.VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -163825,7 +164729,7 @@ var ts; var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax); if (imports.length && body.length) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [ - 4 /* NewLineTrivia */ + 4 /* SyntaxKind.NewLineTrivia */ ], false), body, true); } return __spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), body, true); @@ -163846,10 +164750,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_18 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_19 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -163871,35 +164775,35 @@ var ts; }; for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) { var statement = _c[_b]; - _loop_19(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_18(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* NamespaceImport */ ? + case 266 /* SyntaxKind.ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { - var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ESNext */); + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ScriptTarget.ESNext */); var needUniqueName = false; var toChange = []; ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { if (!ts.isPropertyAccessExpression(ref.parent)) return; - needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true); + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { toChange.push(ref); } @@ -163917,21 +164821,21 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString, /*assertClause*/ undefined); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function moduleSpecifierFromImport(i) { - return (i.kind === 266 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 265 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 266 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -163957,7 +164861,7 @@ var ts; var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { - if (symbol.escapedName === "default" /* Default */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */) { defaultImport = ts.factory.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217 } else { @@ -163981,7 +164885,7 @@ var ts; } } function makeVariableStatement(name, type, initializer, flags) { - if (flags === void 0) { flags = 2 /* Const */; } + if (flags === void 0) { flags = 2 /* NodeFlags.Const */; } return ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, initializer)], flags)); } function createRequireCall(moduleSpecifier) { @@ -164001,19 +164905,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind ".concat(importDecl.kind)); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -164022,7 +164926,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 268 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -164034,7 +164938,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 269 /* NamedImports */) { + else if (namedBindings.kind === 269 /* SyntaxKind.NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -164047,14 +164951,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: break; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -164096,7 +165000,7 @@ var ts; if (markSeenTop(top)) { addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax); } - if (ts.hasSyntacticModifier(decl, 512 /* Default */)) { + if (ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */)) { oldFileDefault = name; } else { @@ -164113,17 +165017,17 @@ var ts; var name = ts.combinePaths(inDirectory, newModuleName + extension); if (!host.fileExists(name)) return newModuleName; - newModuleName = moduleName + "." + i; + newModuleName = "".concat(moduleName, ".").concat(i); } } - function getNewModuleName(movedSymbols) { - return movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile"; + function getNewModuleName(importsFromNewFile, movedSymbols) { + return importsFromNewFile.forEachEntry(ts.symbolNameNoDefault) || movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile"; } function getUsageInfo(oldFile, toMove, checker) { var movedSymbols = new SymbolSet(); var oldImportsNeededByNewFile = new SymbolSet(); var newFileImportsFromOldFile = new SymbolSet(); - var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* ContainsJsx */); }); + var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */); }); var jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx); if (jsxNamespaceSymbol) { // Might not exist (e.g. in non-compiling code) oldImportsNeededByNewFile.add(jsxNamespaceSymbol); @@ -164157,7 +165061,7 @@ var ts; if (ts.contains(toMove, statement)) continue; // jsxNamespaceSymbol will only be set iff it is in oldImportsNeededByNewFile. - if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) { + if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */)) { unusedImportsFromOldFile.delete(jsxNamespaceSymbol); } forEachReference(statement, checker, function (symbol) { @@ -164175,7 +165079,7 @@ var ts; // Strictly speaking, this could resolve to a symbol other than the JSX namespace. // This will produce erroneous output (probably, an incorrectly copied import) but // is expected to be very rare and easily reversible. - var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* Namespace */, /*excludeGlobals*/ true); + var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* SymbolFlags.Namespace */, /*excludeGlobals*/ true); return !!jsxNamespaceSymbol && ts.some(jsxNamespaceSymbol.declarations, isInImport) ? jsxNamespaceSymbol : undefined; @@ -164184,14 +165088,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: return true; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -164203,7 +165107,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -164213,18 +165117,18 @@ var ts; ? ts.factory.createImportDeclaration(/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined) : undefined; } - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); + return ts.Debug.assertNever(i, "Unexpected import kind ".concat(i.kind)); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -164234,11 +165138,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return keep(name) ? name : undefined; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return name; - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined; @@ -164295,13 +165199,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -164309,19 +165213,19 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return cb(statement); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; - return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ + return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* AssignmentDeclarationKind.ExportsProperty */ ? cb(statement) : undefined; } @@ -164329,13 +165233,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); + return ts.Debug.assertNever(name, "Unexpected name kind ".concat(name.kind)); } } function nameOfTopLevelDeclaration(d) { @@ -164343,9 +165247,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return d.parent.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -164367,7 +165271,7 @@ var ts; function isExported(sourceFile, decl, useEs6Exports, name) { var _a; if (useEs6Exports) { - return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); + return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); } return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); }); } @@ -164375,29 +165279,29 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.canHaveModifiers(d) ? ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], ts.getModifiers(d)) : undefined; + var modifiers = ts.canHaveModifiers(d) ? ts.concatenate([ts.factory.createModifier(93 /* SyntaxKind.ExportKeyword */)], ts.getModifiers(d)) : undefined; switch (d.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var decorators = ts.canHaveDecorators(d) ? ts.getDecorators(d) : undefined; return ts.factory.updateClassDeclaration(d, ts.concatenate(decorators, modifiers), d.name, d.typeParameters, d.heritageClauses, d.members); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, modifiers, d.name, d.body); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, modifiers, d.name, d.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, modifiers, d.name, d.typeParameters, d.type); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); + return ts.Debug.assertNever(d, "Unexpected declaration kind ".concat(d.kind)); } } function addCommonjsExport(decl) { @@ -164405,26 +165309,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.emptyArray; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); + return ts.Debug.assertNever(decl, "Unexpected decl kind ".concat(decl.kind)); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* EqualsToken */, ts.factory.createIdentifier(name))); + return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* SyntaxKind.EqualsToken */, ts.factory.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -164487,14 +165391,14 @@ var ts; if (actionName === addBracesAction.name) { var returnStatement_1 = ts.factory.createReturnStatement(expression); body = ts.factory.createBlock([returnStatement_1], /* multiLine */ true); - ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); + ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); } else if (actionName === removeBracesAction.name && returnStatement) { var actualExpression = expression || ts.factory.createVoidZero(); body = ts.needsParentheses(actualExpression) ? ts.factory.createParenthesizedExpression(actualExpression) : actualExpression; - ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } else { ts.Debug.fail("invalid action"); @@ -164628,7 +165532,7 @@ var ts; var contextualSymbols = ts.map(functionNames, function (name) { return getSymbolForContextualType(name, checker); }); for (var _i = 0, referenceEntries_1 = referenceEntries; _i < referenceEntries_1.length; _i++) { var entry = referenceEntries_1[_i]; - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* FindAllReferences.EntryKind.Span */) { groupedReferences.valid = false; continue; } @@ -164727,7 +165631,7 @@ var ts; if (element) { var contextualType = checker.getContextualTypeForObjectLiteralElement(element); var symbol = contextualType === null || contextualType === void 0 ? void 0 : contextualType.getSymbol(); - if (symbol && !(ts.getCheckFlags(symbol) & 6 /* Synthetic */)) { + if (symbol && !(ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */)) { return symbol; } } @@ -164757,15 +165661,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -164775,7 +165679,7 @@ var ts; } break; // x["foo"](...) - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -164794,14 +165698,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -164813,7 +165717,7 @@ var ts; } function entryToType(entry) { var reference = entry.node; - if (ts.getMeaningFromLocation(reference) === 2 /* Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { + if (ts.getMeaningFromLocation(reference) === 2 /* SemanticMeaning.Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { return reference; } return undefined; @@ -164847,16 +165751,16 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralExpression(functionDeclaration.parent)) { var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker); // don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change return ((_a = contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 && isSingleImplementation(functionDeclaration, checker); } return isSingleImplementation(functionDeclaration, checker); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -164864,8 +165768,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -164875,7 +165779,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* SyntaxKind.DefaultKeyword */); return !!defaultKeyword; } return true; @@ -164979,7 +165883,7 @@ var ts; } function createParameterTypeNode(parameters) { var members = ts.map(parameters, createPropertySignatureFromParameterDeclaration); - var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* SingleLine */); + var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* EmitFlags.SingleLine */); return typeNode; } function createPropertySignatureFromParameterDeclaration(parameterDeclaration) { @@ -164988,7 +165892,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.factory.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType); + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : parameterDeclaration.questionToken, parameterType); ts.suppressLeadingAndTrailingTrivia(propertySignature); ts.copyComments(parameterDeclaration.name, propertySignature.name); if (parameterDeclaration.type && propertySignature.type) { @@ -165013,15 +165917,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -165032,30 +165936,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return [functionDeclaration.name]; - case 171 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 226 /* ClassExpression */) { + case 171 /* SyntaxKind.Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* SyntaxKind.ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 226 /* SyntaxKind.ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return [functionDeclaration.parent.name]; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind ".concat(functionDeclaration.kind)); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -165136,16 +166040,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 63 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return false; - case 223 /* TemplateExpression */: - case 221 /* BinaryExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -165163,7 +166067,7 @@ var ts; if (!(leftHasString || ts.isStringLiteral(current.right) || ts.isTemplateExpression(current.right))) { return { nodes: [current], operators: [], hasString: false, validOperators: true }; } - var currentOperatorValid = current.operatorToken.kind === 39 /* PlusToken */; + var currentOperatorValid = current.operatorToken.kind === 39 /* SyntaxKind.PlusToken */; var validOperators = leftOperatorValid && currentOperatorValid; nodes.push(current.right); operators.push(current.operatorToken); @@ -165176,7 +166080,7 @@ var ts; // "foo" + /* comment */ "bar" var copyTrailingOperatorComments = function (operators, file) { return function (index, targetNode) { if (index < operators.length) { - ts.copyTrailingComments(operators[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(operators[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } }; }; // to copy comments following the string @@ -165185,7 +166089,7 @@ var ts; return function (indexes, targetNode) { while (indexes.length > 0) { var index = indexes.shift(); - ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); copyOperatorComments(index, targetNode); } }; @@ -165239,7 +166143,7 @@ var ts; var templateSpans = []; var templateHead = ts.factory.createTemplateHead(headText, rawHeadText); copyCommentFromStringLiterals(headIndexes, templateHead); - var _loop_20 = function (i) { + var _loop_19 = function (i) { var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]); copyOperatorComments(i, currentNode); var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3]; @@ -165268,7 +166172,7 @@ var ts; }; var out_i_1; for (var i = begin; i < nodes.length; i++) { - _loop_20(i); + _loop_19(i); i = out_i_1; } return ts.factory.createTemplateExpression(templateHead, templateSpans); @@ -165277,8 +166181,8 @@ var ts; // "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar" function copyExpressionComments(node) { var file = node.getSourceFile(); - ts.copyTrailingComments(node, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(node, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } function getExpressionFromParenthesesOrExpression(node) { if (ts.isParenthesizedExpression(node)) { @@ -165473,7 +166377,7 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* ModifierFlags.Export */) | ts.getEffectiveModifierFlags(func); var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); var newNode = ts.factory.createFunctionDeclaration(ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { @@ -165499,7 +166403,7 @@ var ts; else { body = func.body; } - var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* EqualsGreaterThanToken */), body); + var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), body); return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, func, newNode); }); } function canBeConvertedToExpression(body, head) { @@ -165559,13 +166463,13 @@ var ts; return ts.emptyArray; } function doChange(sourceFile, changes, declaration, typeNode) { - var closeParen = ts.findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile); + var closeParen = ts.findChildOfKind(declaration, 21 /* SyntaxKind.CloseParenToken */, sourceFile); var needParens = ts.isArrowFunction(declaration) && closeParen === undefined; var endNode = needParens ? ts.first(declaration.parameters) : closeParen; if (endNode) { if (needParens) { - changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* OpenParenToken */)); - changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); + changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } changes.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); } @@ -165575,7 +166479,7 @@ var ts; return; var token = ts.getTokenAtPosition(context.file, context.startPosition); var declaration = ts.findAncestor(token, function (n) { - return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : + return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : isConvertibleDeclaration(n); }); if (!declaration || !declaration.body || declaration.type) { @@ -165586,17 +166490,17 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); + var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NodeBuilderFlags.NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; } } function isConvertibleDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return true; default: return false; @@ -165623,20 +166527,20 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : - kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : + kind === 79 /* SyntaxKind.Identifier */ ? new IdentifierObject(79 /* SyntaxKind.Identifier */, pos, end) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* SyntaxKind.PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 50720768 /* ContextFlags */; + node.flags = parent.flags & 50720768 /* NodeFlags.ContextFlags */; return node; } var NodeObject = /** @class */ (function () { function NodeObject(kind, pos, end) { this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.kind = kind; } @@ -165698,8 +166602,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 309 /* FirstJSDocNode */ || kid.kind > 347 /* LastJSDocNode */; }); - return child.kind < 161 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 309 /* SyntaxKind.FirstJSDocNode */ || kid.kind > 347 /* SyntaxKind.LastJSDocNode */; }); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -165710,7 +166614,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 161 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -165758,19 +166662,19 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 79 /* Identifier */) { - ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); + if (token === 79 /* SyntaxKind.Identifier */) { + ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia")); } nodes.push(createNode(token, pos, textPos, parent)); } pos = textPos; - if (token === 1 /* EndOfFileToken */) { + if (token === 1 /* SyntaxKind.EndOfFileToken */) { break; } } } function createSyntaxList(nodes, parent) { - var list = createNode(348 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(348 /* SyntaxKind.SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { @@ -165787,9 +166691,9 @@ var ts; // Set properties in same order as NodeObject this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } TokenOrIdentifierObject.prototype.getSourceFile = function () { @@ -165829,7 +166733,7 @@ var ts; return this.getChildren()[index]; }; TokenOrIdentifierObject.prototype.getChildren = function () { - return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; + return this.kind === 1 /* SyntaxKind.EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -165880,20 +166784,25 @@ var ts; return this.documentationComment; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { - switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + if (context) { + if (ts.isGetAccessor(context)) { if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } - return this.contextualGetAccessorDocumentationComment; - case 173 /* SetAccessor */: + if (ts.length(this.contextualGetAccessorDocumentationComment)) { + return this.contextualGetAccessorDocumentationComment; + } + } + if (ts.isSetAccessor(context)) { if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); } - return this.contextualSetAccessorDocumentationComment; - default: - return this.getDocumentationComment(checker); + if (ts.length(this.contextualSetAccessorDocumentationComment)) { + return this.contextualSetAccessorDocumentationComment; + } + } } + return this.getDocumentationComment(checker); }; SymbolObject.prototype.getJsDocTags = function (checker) { if (this.tags === undefined) { @@ -165902,20 +166811,25 @@ var ts; return this.tags; }; SymbolObject.prototype.getContextualJsDocTags = function (context, checker) { - switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + if (context) { + if (ts.isGetAccessor(context)) { if (!this.contextualGetAccessorTags) { this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker); } - return this.contextualGetAccessorTags; - case 173 /* SetAccessor */: + if (ts.length(this.contextualGetAccessorTags)) { + return this.contextualGetAccessorTags; + } + } + if (ts.isSetAccessor(context)) { if (!this.contextualSetAccessorTags) { this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker); } - return this.contextualSetAccessorTags; - default: - return this.getJsDocTags(checker); + if (ts.length(this.contextualSetAccessorTags)) { + return this.contextualSetAccessorTags; + } + } } + return this.getJsDocTags(checker); }; return SymbolObject; }()); @@ -165932,7 +166846,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 79 /* Identifier */; + _this.kind = 79 /* SyntaxKind.Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -165944,7 +166858,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 79 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* SyntaxKind.Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -165959,7 +166873,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* SyntaxKind.PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -165981,16 +166895,16 @@ var ts; return this.checker.getAugmentedPropertiesOfType(this); }; TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0 /* Call */); + return this.checker.getSignaturesOfType(this, 0 /* SignatureKind.Call */); }; TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1 /* Construct */); + return this.checker.getSignaturesOfType(this, 1 /* SignatureKind.Construct */); }; TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0 /* String */); + return this.checker.getIndexTypeOfType(this, 0 /* IndexKind.String */); }; TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1 /* Number */); + return this.checker.getIndexTypeOfType(this, 1 /* IndexKind.Number */); }; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; @@ -166011,41 +166925,41 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 1048576 /* Union */); + return !!(this.flags & 1048576 /* TypeFlags.Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 2097152 /* Intersection */); + return !!(this.flags & 2097152 /* TypeFlags.Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 3145728 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* TypeFlags.UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 384 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* TypeFlags.StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 128 /* StringLiteral */); + return !!(this.flags & 128 /* TypeFlags.StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 256 /* NumberLiteral */); + return !!(this.flags & 256 /* TypeFlags.NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 262144 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeFlags.TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { - return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); + return !!(ts.getObjectFlags(this) & 3 /* ObjectFlags.ClassOrInterface */); }; TypeObject.prototype.isClass = function () { - return !!(ts.getObjectFlags(this) & 1 /* Class */); + return !!(ts.getObjectFlags(this) & 1 /* ObjectFlags.Class */); }; TypeObject.prototype.isIndexType = function () { - return !!(this.flags & 4194304 /* Index */); + return !!(this.flags & 4194304 /* TypeFlags.Index */); }; Object.defineProperty(TypeObject.prototype, "typeArguments", { /** * This polyfills `referenceType.typeArguments` for API consumers */ get: function () { - if (ts.getObjectFlags(this) & 4 /* Reference */) { + if (ts.getObjectFlags(this) & 4 /* ObjectFlags.Reference */) { return this.checker.getTypeArguments(this); } return undefined; @@ -166104,12 +167018,12 @@ var ts; var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker); if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) { var seenSymbols_1 = new ts.Set(); - var _loop_21 = function (declaration) { + var _loop_20 = function (declaration) { var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; if (!seenSymbols_1.has(symbol)) { seenSymbols_1.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualJsDocTags(declaration, checker); } return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; @@ -166121,7 +167035,7 @@ var ts; }; for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { var declaration = declarations_7[_i]; - _loop_21(declaration); + _loop_20(declaration); } } return tags; @@ -166132,11 +167046,11 @@ var ts; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker); if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) { var seenSymbols_2 = new ts.Set(); - var _loop_22 = function (declaration) { + var _loop_21 = function (declaration) { var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { if (!seenSymbols_2.has(symbol)) { seenSymbols_2.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualDocumentationComment(declaration, checker); } return symbol.getDocumentationComment(checker); @@ -166148,14 +167062,14 @@ var ts; }; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - _loop_22(declaration); + _loop_21(declaration); } } return doc; } function findBaseOfDeclaration(checker, declaration, cb) { var _a; - var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ ? declaration.parent.parent : declaration.parent; + var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ ? declaration.parent.parent : declaration.parent; if (!classOrInterfaceDeclaration) return; var isStaticMember = ts.hasStaticModifier(declaration); @@ -166170,7 +167084,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 305 /* SourceFile */; + _this.kind = 305 /* SyntaxKind.SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -166229,10 +167143,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -166252,31 +167166,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 182 /* SyntaxKind.TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { break; } // falls through - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -166287,12 +167201,12 @@ var ts; } } // falls through - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: addDeclaration(node); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -166305,7 +167219,7 @@ var ts; } } break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -166317,7 +167231,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -166326,8 +167240,8 @@ var ts; } } break; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) !== 0 /* AssignmentDeclarationKind.None */) { addDeclaration(node); } // falls through @@ -166396,8 +167310,8 @@ var ts; function getDefaultCompilerOptions() { // Always default to "ScriptTarget.ES5" for the language service return { - target: 1 /* ES5 */, - jsx: 1 /* Preserve */ + target: 1 /* ScriptTarget.ES5 */, + jsx: 1 /* JsxEmit.Preserve */ }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; @@ -166422,7 +167336,7 @@ var ts; if (this.currentFileName !== fileName) { // This is a new file, just parse it var options = { - languageVersion: 99 /* Latest */, + languageVersion: 99 /* ScriptTarget.Latest */, impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(fileName, this.host.getCurrentDirectory(), ((_c = (_b = (_a = this.host).getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getCanonicalFileName) || ts.hostGetCanonicalFileName(this.host)), (_h = (_g = (_f = (_e = (_d = this.host).getCompilerHost) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.getModuleResolutionCache) === null || _g === void 0 ? void 0 : _g.call(_f)) === null || _h === void 0 ? void 0 : _h.getPackageJsonInfoCache(), this.host, this.host.getCompilationSettings()), setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings()) }; @@ -166519,7 +167433,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -166549,7 +167463,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -166639,7 +167553,7 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - var error = new Error("Could not find source file: '" + fileName + "'."); + var error = new Error("Could not find source file: '".concat(fileName, "'.")); // We've been having trouble debugging this, so attach sidecar data for the tsserver log. // See https://github.com/microsoft/TypeScript/issues/30180. error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); @@ -166666,7 +167580,10 @@ var ts; program = undefined; // TODO: GH#18217 lastTypesRootVersion = typeRootsVersion; } - var rootFileNames = host.getScriptFileNames(); + // This array is retained by the program and will be used to determine if the program is up to date, + // so we need to make a copy in case the host mutates the underlying array - otherwise it would look + // like every program always has the host's current list of root files. + var rootFileNames = host.getScriptFileNames().slice(); // Get a fresh cache of the host information var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; @@ -166777,7 +167694,7 @@ var ts; return result; } function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { - var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + var result = getOrCreateSourceFile(configFileName, 100 /* ScriptTarget.JSON */); if (!result) return undefined; result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); @@ -166799,12 +167716,12 @@ var ts; // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat); } - function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { - return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); + function getOrCreateSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) { + return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile); } - function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) { + function getOrCreateSourceFileByPath(fileName, path, languageVersionOrOptions, _onError, shouldCreateNewSourceFile) { ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host."); // The program is asking for this file, check first if the host can locate it. // If the host can not locate the file, then it does not exist. return undefined @@ -166847,17 +167764,17 @@ var ts; // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" if (scriptKind === oldSourceFile.scriptKind) { - return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind); + return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions); } else { // Release old source file and fall through to aquire new file with new script kind - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat); } } // We didn't already have the file. Fall through and acquire it from the registry. } // Could not find this file in the old program, create a new SourceFile for it. - return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind); + return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions); } } // TODO: GH#18217 frequently asserted as defined @@ -166924,7 +167841,7 @@ var ts; if (!sourceFile) return undefined; var rawNode = ts.getTouchingPropertyName(sourceFile, docSpan.textSpan.start); - var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* References */ }); + var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }); return adjustedNode; } } @@ -166936,7 +167853,7 @@ var ts; // Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()); ts.forEach(program.getSourceFiles(), function (f) { - return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind); + return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind, f.impliedNodeFormat); }); program = undefined; // TODO: GH#18217 } @@ -167004,8 +167921,8 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { var type_2 = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined; return type_2 && { - kind: "" /* unknown */, - kindModifiers: "" /* none */, + kind: "" /* ScriptElementKind.unknown */, + kindModifiers: "" /* ScriptElementKindModifier.none */, textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile), displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(nodeForQuickInfo)); }), documentation: type_2.symbol ? type_2.symbol.getDocumentationComment(typeChecker) : undefined, @@ -167038,18 +167955,18 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 106 /* SuperKeyword */: - case 197 /* NamedTupleMember */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 106 /* SyntaxKind.SuperKeyword */: + case 197 /* SyntaxKind.NamedTupleMember */: return true; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return ts.isImportMeta(node); default: return false; @@ -167075,7 +167992,7 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* HighlightSpanKind.writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); @@ -167099,17 +168016,17 @@ var ts; }); } else { - return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); + return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* FindAllReferences.FindReferencesUse.Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); } } function getReferencesAtPosition(fileName, position) { synchronizeHostData(); - return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry); + return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, ts.FindAllReferences.toReferenceEntry); } function getReferencesWorker(node, position, options, cb) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. - var sourceFiles = options && options.use === 2 /* Rename */ + var sourceFiles = options && options.use === 2 /* FindAllReferences.FindReferencesUse.Rename */ ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) : program.getSourceFiles(); return ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, cb); @@ -167156,16 +168073,16 @@ var ts; return undefined; } switch (node.kind) { - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: - case 10 /* StringLiteral */: - case 95 /* FalseKeyword */: - case 110 /* TrueKeyword */: - case 104 /* NullKeyword */: - case 106 /* SuperKeyword */: - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 79 /* Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: + case 10 /* SyntaxKind.StringLiteral */: + case 95 /* SyntaxKind.FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 79 /* SyntaxKind.Identifier */: break; // Cant create the text span default: @@ -167181,7 +168098,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 261 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -167211,8 +168128,8 @@ var ts; } function getSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "2020" /* TwentyTwenty */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "2020" /* SemanticClassificationFormat.TwentyTwenty */) { return ts.classifier.v2020.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); } else { @@ -167221,8 +168138,8 @@ var ts; } function getEncodedSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "original" /* Original */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "original" /* SemanticClassificationFormat.Original */) { return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } else { @@ -167243,10 +168160,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = new ts.Map(ts.getEntries((_a = {}, - _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, - _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, - _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, + _a[18 /* SyntaxKind.OpenBraceToken */] = 19 /* SyntaxKind.CloseBraceToken */, + _a[20 /* SyntaxKind.OpenParenToken */] = 21 /* SyntaxKind.CloseParenToken */, + _a[22 /* SyntaxKind.OpenBracketToken */] = 23 /* SyntaxKind.CloseBracketToken */, + _a[31 /* SyntaxKind.GreaterThanToken */] = 29 /* SyntaxKind.LessThanToken */, _a))); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -167343,7 +168260,7 @@ var ts; // var x = new foo<| ( with class foo{} ) // or // var y = 3 <| - if (openingBrace === 60 /* lessThan */) { + if (openingBrace === 60 /* CharacterCodes.lessThan */) { return false; } var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -167352,15 +168269,15 @@ var ts; return false; } if (ts.isInsideJsxElementOrAttribute(sourceFile, position)) { - return openingBrace === 123 /* openBrace */; + return openingBrace === 123 /* CharacterCodes.openBrace */; } if (ts.isInTemplateString(sourceFile, position)) { return false; } switch (openingBrace) { - case 39 /* singleQuote */: - case 34 /* doubleQuote */: - case 96 /* backtick */: + case 39 /* CharacterCodes.singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 96 /* CharacterCodes.backtick */: return !ts.isInComment(sourceFile, position); } return true; @@ -167370,12 +168287,12 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxElement(token.parent) ? token.parent : undefined; if (element && isUnclosedTag(element)) { - return { newText: "" }; + return { newText: "") }; } - var fragment = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent + var fragment = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxFragment(token.parent) ? token.parent : undefined; if (fragment && isUnclosedFragment(fragment)) { return { newText: "" }; @@ -167472,14 +168389,14 @@ var ts; commentRange.end++; } positions.push(commentRange.pos); - if (commentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (commentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { positions.push(commentRange.end); } hasComment = true; pos = commentRange.end + 1; } else { // If it's not in a comment range, then we need to comment the uncommented portions. - var newPos = text.substring(pos, textRange.end).search("(" + openMultilineRegex + ")|(" + closeMultilineRegex + ")"); + var newPos = text.substring(pos, textRange.end).search("(".concat(openMultilineRegex, ")|(").concat(closeMultilineRegex, ")")); isCommenting = insertComment !== undefined ? insertComment : isCommenting || !ts.isTextWhiteSpaceLike(text, pos, newPos === -1 ? textRange.end : pos + newPos); // If isCommenting is already true we don't need to check whitespace again. @@ -167489,7 +168406,7 @@ var ts; // If it didn't found a comment and isCommenting is false means is only empty space. // We want to insert comment in this scenario. if (isCommenting || !hasComment) { - if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SingleLineCommentTrivia */) { + if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SyntaxKind.SingleLineCommentTrivia */) { ts.insertSorted(positions, textRange.pos, ts.compareValues); } ts.insertSorted(positions, textRange.end, ts.compareValues); @@ -167575,10 +168492,10 @@ var ts; var commentRange = ts.isInComment(sourceFile, i); if (commentRange) { switch (commentRange.kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: textChanges.push.apply(textChanges, toggleLineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); } i = commentRange.end + 1; @@ -167593,12 +168510,12 @@ var ts; } function isUnclosedFragment(_a) { var closingFragment = _a.closingFragment, parent = _a.parent; - return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); + return !!(closingFragment.flags & 131072 /* NodeFlags.ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); - return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; + return range && (!onlyMultiLine || range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -167716,9 +168633,9 @@ var ts; return new RegExp(regExpString, "gim"); } function isLetterOrDigit(char) { - return (char >= 97 /* a */ && char <= 122 /* z */) || - (char >= 65 /* A */ && char <= 90 /* Z */) || - (char >= 48 /* _0 */ && char <= 57 /* _9 */); + return (char >= 97 /* CharacterCodes.a */ && char <= 122 /* CharacterCodes.z */) || + (char >= 65 /* CharacterCodes.A */ && char <= 90 /* CharacterCodes.Z */) || + (char >= 48 /* CharacterCodes._0 */ && char <= 57 /* CharacterCodes._9 */); } function isNodeModulesFile(path) { return ts.stringContains(path, "/node_modules/"); @@ -167853,6 +168770,7 @@ var ts; getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getProgram: getProgram, + getCurrentProgram: function () { return program; }, getAutoImportProvider: getAutoImportProvider, updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols, getApplicableRefactors: getApplicableRefactors, @@ -167875,14 +168793,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidOperationsInPartialSemanticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.PartialSemantic")); }; }); break; case ts.LanguageServiceMode.Syntactic: invalidOperationsInSyntacticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.Syntactic")); }; }); break; @@ -167929,7 +168847,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 277 /* ExternalModuleReference */ || + node.parent.kind === 277 /* SyntaxKind.ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -167944,16 +168862,16 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 162 /* ComputedPropertyName */) { + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 205 /* ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* JsxAttributes */) && + (node.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* SyntaxKind.JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -167995,7 +168913,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 207 /* ElementAccessExpression */ && + node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -168042,7 +168960,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 16777216 /* Ambient */) { + if (tokenAtLocation.flags & 16777216 /* NodeFlags.Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -168088,144 +169006,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return spanInVariableDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return spanInParameterDeclaration(node); - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return spanInFunctionDeclaration(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanInBlock(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInBlock(node.block); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: // span in statement return spanInNode(node.statement); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return spanInForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // span on complete module if it is instantiated - if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 203 /* BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 203 /* SyntaxKind.BindingElement */: // span on complete node return textSpan(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: // span in statement return spanInNode(node.statement); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return spanInNodeArray(parent.modifiers, node, ts.isDecorator); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return undefined; // Tokens: - case 26 /* SemicolonToken */: - case 1 /* EndOfFileToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return spanInPreviousNode(node); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return spanInOpenBraceToken(node); - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: return spanInCloseBraceToken(node); - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: return spanInCloseBracketToken(node); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return spanInOpenParenToken(node); - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: return spanInCloseParenToken(node); - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: return spanInColonToken(node); - case 31 /* GreaterThanToken */: - case 29 /* LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return spanInWhileKeyword(node); - case 91 /* ElseKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return spanInNextNode(node); - case 160 /* OfKeyword */: + case 160 /* SyntaxKind.OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -168237,14 +169155,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 79 /* Identifier */ || - node.kind === 225 /* SpreadElement */ || - node.kind === 296 /* PropertyAssignment */ || - node.kind === 297 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 225 /* SyntaxKind.SpreadElement */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 221 /* BinaryExpression */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -168253,35 +169171,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or // { a = expression, b, c } = someExpression return textSpan(node); } - if (operatorToken.kind === 27 /* CommaToken */) { + if (operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return textSpan(node); - case 221 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 27 /* CommaToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -168290,21 +169208,21 @@ var ts; } } switch (node.parent.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -168312,7 +169230,7 @@ var ts; } break; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -168342,7 +169260,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 243 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -168353,8 +169271,8 @@ var ts; // Breakpoint is possible in variableDeclaration only if there is initialization // or its declaration from 'for of' if ((ts.hasOnlyExpressionInitializer(variableDeclaration) && variableDeclaration.initializer) || - ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 244 /* ForOfStatement */) { + ts.hasSyntacticModifier(variableDeclaration, 1 /* ModifierFlags.Export */) || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -168369,7 +169287,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - ts.hasSyntacticModifier(parameter, 4 /* Public */ | 8 /* Private */); + ts.hasSyntacticModifier(parameter, 4 /* ModifierFlags.Public */ | 8 /* ModifierFlags.Private */); } function spanInParameterDeclaration(parameter) { if (ts.isBindingPattern(parameter.name)) { @@ -168394,8 +169312,8 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 257 /* ClassDeclaration */ && functionDeclaration.kind !== 171 /* Constructor */); + return ts.hasSyntacticModifier(functionDeclaration, 1 /* ModifierFlags.Export */) || + (functionDeclaration.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && functionDeclaration.kind !== 171 /* SyntaxKind.Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -168418,26 +169336,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 261 /* ModuleDeclaration */: - if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { + case 261 /* SyntaxKind.ModuleDeclaration */: + if (ts.getModuleInstanceState(block.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 243 /* ForInStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -168462,21 +169380,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 203 /* BindingElement */) { + if (bindingPattern.parent.kind === 203 /* SyntaxKind.BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 202 /* ArrayBindingPattern */ && node.kind !== 201 /* ObjectBindingPattern */); - var elements = node.kind === 204 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 202 /* SyntaxKind.ArrayBindingPattern */ && node.kind !== 201 /* SyntaxKind.ObjectBindingPattern */); + var elements = node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -168484,18 +169402,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 221 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -168503,25 +169421,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: // If this is not an instantiated module block, no bp span - if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 260 /* EnumDeclaration */: - case 257 /* ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // Span on close brace token return textSpan(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -168529,7 +169447,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -168545,7 +169463,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -168560,12 +169478,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 240 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 208 /* CallExpression */ || - node.parent.kind === 209 /* NewExpression */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 208 /* SyntaxKind.CallExpression */ || + node.parent.kind === 209 /* SyntaxKind.NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 212 /* ParenthesizedExpression */) { + if (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -168574,21 +169492,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 212 /* ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -168598,20 +169516,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ || - node.parent.kind === 164 /* Parameter */) { + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.parent.kind === 164 /* SyntaxKind.Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 211 /* TypeAssertionExpression */) { + if (node.parent.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 240 /* DoStatement */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -168619,7 +169537,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -168787,7 +169705,7 @@ var ts; return this.shimHost.getScriptKind(fileName); // TODO: GH#18217 } else { - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } }; LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { @@ -168877,13 +169795,13 @@ var ts; var result = action(); if (logPerformance) { var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); + logger.log("".concat(actionDescription, " completed in ").concat(end - start, " msec")); if (ts.isString(result)) { var str = result; if (str.length > 128) { str = str.substring(0, 128) + "..."; } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + logger.log(" result.length=".concat(str.length, ", result='").concat(JSON.stringify(str), "'")); } } return result; @@ -168965,7 +169883,7 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + this.forwardJSONCall("refresh(".concat(throwOnError, ")"), function () { return null; } // eslint-disable-line no-null/no-null ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { @@ -168981,43 +169899,43 @@ var ts; }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSyntacticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSemanticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSuggestionDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSuggestionDiagnostics('" + fileName + "')", function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); + return this.forwardJSONCall("getSuggestionDiagnostics('".concat(fileName, "')"), function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); }; LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { var _this = this; @@ -169033,7 +169951,7 @@ var ts; */ LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + return this.forwardJSONCall("getQuickInfoAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); }; /// NAMEORDOTTEDNAMESPAN /** @@ -169042,7 +169960,7 @@ var ts; */ LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + return this.forwardJSONCall("getNameOrDottedNameSpan('".concat(fileName, "', ").concat(startPos, ", ").concat(endPos, ")"), function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); }; /** * STATEMENTSPAN @@ -169050,12 +169968,12 @@ var ts; */ LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + return this.forwardJSONCall("getBreakpointStatementAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); + return this.forwardJSONCall("getSignatureHelpItems('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** @@ -169064,7 +169982,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); }; /** * Computes the definition location and file for the symbol @@ -169072,7 +169990,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAndBoundSpan = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAndBoundSpan('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); + return this.forwardJSONCall("getDefinitionAndBoundSpan('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); }; /// GOTO Type /** @@ -169081,7 +169999,7 @@ var ts; */ LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getTypeDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); }; /// GOTO Implementation /** @@ -169090,37 +170008,37 @@ var ts; */ LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + return this.forwardJSONCall("getImplementationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) { var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); }); + return this.forwardJSONCall("getRenameInfo('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getRenameInfo(fileName, position, preferences); }); }; LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getSmartSelectionRange('" + fileName + "', " + position + ")", function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); + return this.forwardJSONCall("getSmartSelectionRange('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); }; LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename) { var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ", " + providePrefixAndSuffixTextForRename + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); + return this.forwardJSONCall("findRenameLocations('".concat(fileName, "', ").concat(position, ", ").concat(findInStrings, ", ").concat(findInComments, ", ").concat(providePrefixAndSuffixTextForRename, ")"), function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); }; /// GET BRACE MATCHING LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + return this.forwardJSONCall("getBraceMatchingAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(openingBrace, ")"), function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { var _this = this; - return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + return this.forwardJSONCall("getSpanOfEnclosingComment('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getIndentationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); }); @@ -169128,23 +170046,23 @@ var ts; /// GET REFERENCES LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getReferencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + return this.forwardJSONCall("findReferences('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.findReferences(fileName, position); }); }; LanguageServiceShimObject.prototype.getFileReferences = function (fileName) { var _this = this; - return this.forwardJSONCall("getFileReferences('" + fileName + ")", function () { return _this.languageService.getFileReferences(fileName); }); + return this.forwardJSONCall("getFileReferences('".concat(fileName, ")"), function () { return _this.languageService.getFileReferences(fileName); }); }; LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getOccurrencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getDocumentHighlights('".concat(fileName, "', ").concat(position, ")"), function () { var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); // workaround for VS document highlighting issue - keep only items from the initial file var normalizedName = ts.toFileNameLowerCase(ts.normalizeSlashes(fileName)); @@ -169159,108 +170077,108 @@ var ts; */ LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) { var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); + return this.forwardJSONCall("getCompletionsAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(preferences, ", ").concat(formattingSettings, ")"), function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); }; /** Get a string based representation of a completion list entry details */ LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { + return this.forwardJSONCall("getCompletionEntryDetails('".concat(fileName, "', ").concat(position, ", '").concat(entryName, "')"), function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + return this.forwardJSONCall("getFormattingEditsForRange('".concat(fileName, "', ").concat(start, ", ").concat(end, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + return this.forwardJSONCall("getFormattingEditsForDocument('".concat(fileName, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('".concat(fileName, "', ").concat(position, ", '").concat(key, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + return this.forwardJSONCall("getNavigateToItems('".concat(searchValue, "', ").concat(maxResultCount, ", ").concat(fileName, ")"), function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); }; LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + return this.forwardJSONCall("getNavigationBarItems('".concat(fileName, "')"), function () { return _this.languageService.getNavigationBarItems(fileName); }); }; LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + return this.forwardJSONCall("getNavigationTree('".concat(fileName, "')"), function () { return _this.languageService.getNavigationTree(fileName); }); }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + return this.forwardJSONCall("getOutliningSpans('".concat(fileName, "')"), function () { return _this.languageService.getOutliningSpans(fileName); }); }; LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + return this.forwardJSONCall("getTodoComments('".concat(fileName, "')"), function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); }; /// CALL HIERARCHY LanguageServiceShimObject.prototype.prepareCallHierarchy = function (fileName, position) { var _this = this; - return this.forwardJSONCall("prepareCallHierarchy('" + fileName + "', " + position + ")", function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); + return this.forwardJSONCall("prepareCallHierarchy('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyIncomingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyIncomingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyIncomingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyOutgoingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideInlayHints = function (fileName, span, preference) { var _this = this; - return this.forwardJSONCall("provideInlayHints('" + fileName + "', '" + JSON.stringify(span) + "', " + JSON.stringify(preference) + ")", function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); + return this.forwardJSONCall("provideInlayHints('".concat(fileName, "', '").concat(JSON.stringify(span), "', ").concat(JSON.stringify(preference), ")"), function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); }; /// Emit LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + return this.forwardJSONCall("getEmitOutput('".concat(fileName, "')"), function () { var _a = _this.languageService.getEmitOutput(fileName), diagnostics = _a.diagnostics, rest = __rest(_a, ["diagnostics"]); return __assign(__assign({}, rest), { diagnostics: _this.realizeDiagnostics(diagnostics) }); }); }; LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", + return forwardCall(this.logger, "getEmitOutput('".concat(fileName, "')"), /*returnJson*/ false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); }; LanguageServiceShimObject.prototype.toggleLineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleLineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleLineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleLineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleLineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.toggleMultilineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleMultilineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleMultilineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.commentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("commentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.commentSelection(fileName, textRange); }); + return this.forwardJSONCall("commentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.commentSelection(fileName, textRange); }); }; LanguageServiceShimObject.prototype.uncommentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("uncommentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.uncommentSelection(fileName, textRange); }); + return this.forwardJSONCall("uncommentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.uncommentSelection(fileName, textRange); }); }; return LanguageServiceShimObject; }(ShimBase)); @@ -169310,11 +170228,11 @@ var ts; }; CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + return this.forwardJSONCall("resolveModuleName('".concat(fileName, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) { + if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Extension.Ts */ && result.resolvedModule.extension !== ".tsx" /* Extension.Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Extension.Dts */) { resolvedFileName = undefined; } return { @@ -169326,7 +170244,7 @@ var ts; }; CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + return this.forwardJSONCall("resolveTypeReferenceDirective(".concat(fileName, ")"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); return { @@ -169338,7 +170256,7 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getPreProcessedFileInfo('".concat(fileName, "')"), function () { // for now treat files as JavaScript var result = ts.preProcessFile(ts.getSnapshotText(sourceTextSnapshot), /* readImportFiles */ true, /* detectJavaScriptImports */ true); return { @@ -169353,7 +170271,7 @@ var ts; }; CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('".concat(compilerOptionsJson, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); }); @@ -169375,7 +170293,7 @@ var ts; }; CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getTSConfigFileInfo('".concat(fileName, "')"), function () { var result = ts.parseJsonText(fileName, ts.getSnapshotText(sourceTextSnapshot)); var normalizedFileName = ts.normalizeSlashes(fileName); var configFile = ts.parseJsonSourceFileConfigFileContent(result, _this.host, ts.getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName); @@ -169541,7 +170459,7 @@ var ts; for (var _i = 0, _a = Object.keys(deprecations); _i < _a.length; _i++) { var key = _a[_i]; var index = +key; - if (!isNaN(index) && ts.hasProperty(overloads, "" + index)) { + if (!isNaN(index) && ts.hasProperty(overloads, "".concat(index))) { overloads[index] = ts.Debug.deprecate(overloads[index], __assign(__assign({}, deprecations[index]), { name: name })); } } @@ -169564,7 +170482,7 @@ var ts; ts.createOverload = createOverload; function createBinder(overloads, binder) { return function (args) { - for (var i = 0; ts.hasProperty(overloads, "" + i) && ts.hasProperty(binder, "" + i); i++) { + for (var i = 0; ts.hasProperty(overloads, "".concat(i)) && ts.hasProperty(binder, "".concat(i)); i++) { var fn = binder[i]; if (fn(args)) { return i; @@ -170215,11 +171133,11 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic)` or the factory supplied by your transformation context instead. */ ts.createOptimisticUniqueName = ts.Debug.deprecate(function createOptimisticUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */); }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel)` or the factory supplied by your transformation context instead. */ ts.createFileLevelUniqueName = ts.Debug.deprecate(function createFileLevelUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */ | 32 /* FileLevel */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); }, factoryDeprecation); /** @deprecated Use `factory.createIndexSignature` or the factory supplied by your transformation context instead. */ ts.createIndexSignature = ts.Debug.deprecate(function createIndexSignature(decorators, modifiers, parameters, type) { @@ -170266,7 +171184,7 @@ var ts; } else { type = operatorOrType; - operator = 140 /* KeyOfKeyword */; + operator = 140 /* SyntaxKind.KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -170303,7 +171221,7 @@ var ts; /** @deprecated Use `factory.createConditional` or the factory supplied by your transformation context instead. */ ts.createConditional = ts.Debug.deprecate(function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { return arguments.length === 5 ? ts.factory.createConditionalExpression(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) : - arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* ColonToken */), whenTrueOrWhenFalse) : + arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* SyntaxKind.QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* SyntaxKind.ColonToken */), whenTrueOrWhenFalse) : ts.Debug.fail("Argument count mismatch"); }, factoryDeprecation); /** @deprecated Use `factory.createYield` or the factory supplied by your transformation context instead. */ @@ -170444,9 +171362,9 @@ var ts; ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) { if (pos === void 0) { pos = 0; } if (end === void 0) { end = 0; } - return ts.setTextRangePosEnd(kind === 305 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 80 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 305 /* SyntaxKind.SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* SyntaxKind.Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : !ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) : ts.parseBaseNodeFactory.createBaseNode(kind), pos, end); }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." }); @@ -170474,7 +171392,7 @@ var ts; (function (ts) { /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 9d85b5f15a872..04387d6187a1e 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -2096,6 +2096,12 @@ declare namespace ts { * It is _public_ so that (pre)transformers can set this field, * since it switches the builtin `node` module transform. Generally speaking, if unset, * the field is treated as though it is `ModuleKind.CommonJS`. + * + * Note that this field is only set by the module resolution process when + * `moduleResolution` is `Node16` or `NodeNext`, which is implied by the `module` setting + * of `Node16` or `NodeNext`, respectively, but may be overriden (eg, by a `moduleResolution` + * of `node`). If so, this field will be unset and source files will be considered to be + * CommonJS-output-format by the node module transformer and type checker, regardless of extension or context. */ impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; } @@ -2420,6 +2426,7 @@ declare namespace ts { UseAliasDefinedOutsideCurrentScope = 16384, UseSingleQuotesForStringLiteralType = 268435456, NoTypeReduction = 536870912, + OmitThisParameter = 33554432, AllowThisInObjectLiteral = 32768, AllowQualifiedNameInPlaceOfIdentifier = 65536, /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ @@ -2450,6 +2457,7 @@ declare namespace ts { UseAliasDefinedOutsideCurrentScope = 16384, UseSingleQuotesForStringLiteralType = 268435456, NoTypeReduction = 536870912, + OmitThisParameter = 33554432, AllowUniqueESSymbolType = 1048576, AddUndefined = 131072, WriteArrowStyleSignature = 262144, @@ -2458,7 +2466,7 @@ declare namespace ts { InFirstTypeArgument = 4194304, InTypeAlias = 8388608, /** @deprecated */ WriteOwnNameForAnyLike = 0, - NodeBuilderFlagsMask = 814775659 + NodeBuilderFlagsMask = 848330091 } export enum SymbolFormatFlags { None = 0, @@ -4456,6 +4464,12 @@ declare namespace ts { /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. + * + * This does *not* return type parameters from a jsdoc reference to a generic type, eg + * + * type Id = (x: T) => T + * /** @type {Id} / + * function id(x) { return x } */ function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; @@ -5405,6 +5419,10 @@ declare namespace ts { resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[]; /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */ resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[]; + /** + * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + */ + getModuleResolutionCache?(): ModuleResolutionCache | undefined; } interface WatchCompilerHost extends ProgramHost, WatchHost { /** Instead of using output d.ts file from project reference, use its source file */ @@ -6884,8 +6902,8 @@ declare namespace ts { * @param version Current version of the file. Only used if the file was not found * in the registry and a new one was created. */ - acquireDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; - acquireDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; + acquireDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; + acquireDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; /** * Request an updated version of an already existing SourceFile with a given fileName * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile @@ -6901,8 +6919,8 @@ declare namespace ts { * @param scriptSnapshot Text of the file. * @param version Current version of the file. */ - updateDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; - updateDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; + updateDocument(fileName: string, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; + updateDocumentWithKey(fileName: string, path: Path, compilationSettingsOrHost: CompilerOptions | MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind, sourceFileOptions?: CreateSourceFileOptions | ScriptTarget): SourceFile; getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey; /** * Informs the DocumentRegistry that a file is not needed any longer. @@ -6912,9 +6930,10 @@ declare namespace ts { * * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file + * @param scriptKind The script kind of the file to be released */ - /**@deprecated pass scriptKind for correctness */ - releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; + /**@deprecated pass scriptKind and impliedNodeFormat for correctness */ + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind?: ScriptKind): void; /** * Informs the DocumentRegistry that a file is not needed any longer. * @@ -6924,12 +6943,13 @@ declare namespace ts { * @param fileName The name of the file to be released * @param compilationSettings The compilation settings used to acquire the file * @param scriptKind The script kind of the file to be released + * @param impliedNodeFormat The implied source file format of the file to be released */ - releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind): void; + releaseDocument(fileName: string, compilationSettings: CompilerOptions, scriptKind: ScriptKind, impliedNodeFormat: SourceFile["impliedNodeFormat"]): void; /** - * @deprecated pass scriptKind for correctness */ - releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; - releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind): void; + * @deprecated pass scriptKind for and impliedNodeFormat correctness */ + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind?: ScriptKind): void; + releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind, impliedNodeFormat: SourceFile["impliedNodeFormat"]): void; reportStats(): string; } type DocumentRegistryBucketKey = string & { diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 138240e4d1ada..ed8f1cb728ddb 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -21,7 +21,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -294,7 +294,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "4.8.1-rc"; /* @internal */ var Comparison; (function (Comparison) { @@ -341,7 +341,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); /* @internal */ @@ -1041,9 +1041,9 @@ var ts; case true: // relational comparison // falls through - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: continue; - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If `array` is sorted, `next` should **never** be less than `last`. return ts.Debug.fail("Array is unsorted."); } @@ -1079,7 +1079,7 @@ var ts; var prevElement = array[0]; for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) { var element = _a[_i]; - if (comparer(prevElement, element) === 1 /* GreaterThan */) { + if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) { return false; } prevElement = element; @@ -1133,27 +1133,27 @@ var ts; loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) { if (offsetB > 0) { // Ensure `arrayB` is properly sorted. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */); } loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) { if (offsetA > startA) { // Ensure `arrayA` is properly sorted. We only need to perform this check if // `offsetA` has changed since we entered the loop. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */); } switch (comparer(arrayB[offsetB], arrayA[offsetA])) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If B is less than A, B does not exist in arrayA. Add B to the result and // move to the next element in arrayB without changing the current position // in arrayA. result.push(arrayB[offsetB]); continue loopB; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: // If B is equal to A, B exists in arrayA. Move to the next element in // arrayB without adding B to the result or changing the current position // in arrayA. continue loopB; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: // If B is greater than A, we need to keep looking for B in arrayA. Move to // the next element in arrayA and recheck. continue loopA; @@ -1393,12 +1393,12 @@ var ts; var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle], middle); switch (keyComparer(midKey, key)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: low = middle + 1; break; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: return middle; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: high = middle - 1; break; } @@ -1670,6 +1670,43 @@ var ts; return createMultiMap(); } ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap; + function createQueue(items) { + var elements = (items === null || items === void 0 ? void 0 : items.slice()) || []; + var headIndex = 0; + function isEmpty() { + return headIndex === elements.length; + } + function enqueue() { + var items = []; + for (var _i = 0; _i < arguments.length; _i++) { + items[_i] = arguments[_i]; + } + elements.push.apply(elements, items); + } + function dequeue() { + if (isEmpty()) { + throw new Error("Queue is empty"); + } + var result = elements[headIndex]; + elements[headIndex] = undefined; // Don't keep referencing dequeued item + headIndex++; + // If more than half of the queue is empty, copy the remaining elements to the + // front and shrink the array (unless we'd be saving fewer than 100 slots) + if (headIndex > 100 && headIndex > (elements.length >> 1)) { + var newLength = elements.length - headIndex; + elements.copyWithin(/*target*/ 0, /*start*/ headIndex); + elements.length = newLength; + headIndex = 0; + } + return result; + } + return { + enqueue: enqueue, + dequeue: dequeue, + isEmpty: isEmpty, + }; + } + ts.createQueue = createQueue; /** * Creates a Set with custom equality and hash code functionality. This is useful when you * want to use something looser than object identity - e.g. "has the same span". @@ -1852,12 +1889,16 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; /** Does nothing. */ function noop(_) { } ts.noop = noop; + ts.noopPush = { + push: noop, + length: 0 + }; /** Do nothing and return false */ function returnFalse() { return false; @@ -1943,7 +1984,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -2015,11 +2056,11 @@ var ts; } ts.equateStringsCaseSensitive = equateStringsCaseSensitive; function compareComparableValues(a, b) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + a < b ? -1 /* Comparison.LessThan */ : + 1 /* Comparison.GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -2037,7 +2078,7 @@ var ts; } ts.compareTextSpans = compareTextSpans; function min(a, b, compare) { - return compare(a, b) === -1 /* LessThan */ ? a : b; + return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b; } ts.min = min; /** @@ -2054,14 +2095,14 @@ var ts; */ function compareStringsCaseInsensitive(a, b) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; a = a.toUpperCase(); b = b.toUpperCase(); - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive; /** @@ -2092,13 +2133,13 @@ var ts; return createStringComparer; function compareWithCallback(a, b, comparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; var value = comparer(a, b); - return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } function createIntlCollatorStringComparer(locale) { // Intl.Collator.prototype.compare is bound to the collator. See NOTE in @@ -2128,7 +2169,7 @@ var ts; return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b); } function compareStrings(a, b) { - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } } function getStringComparerFactory() { @@ -2189,9 +2230,9 @@ var ts; } ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI; function compareProperties(a, b, key, comparer) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : comparer(a[key], b[key]); } ts.compareProperties = compareProperties; @@ -2213,7 +2254,7 @@ var ts; * and 1 insertion/deletion at 3 characters) */ function getSpellingSuggestion(name, candidates, getName) { - var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34)); + var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34)); var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother. var bestCandidate; for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { @@ -2310,24 +2351,24 @@ var ts; var end = fileName.length; for (var pos = end - 1; pos > 0; pos--) { var ch = fileName.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) { // Match a \d+ segment do { --pos; ch = fileName.charCodeAt(pos); - } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */); } - else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) { // Looking for "min" or "min" // Already matched the 'n' --pos; ch = fileName.charCodeAt(pos); - if (ch !== 105 /* i */ && ch !== 73 /* I */) { + if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) { break; } --pos; ch = fileName.charCodeAt(pos); - if (ch !== 109 /* m */ && ch !== 77 /* M */) { + if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) { break; } --pos; @@ -2337,7 +2378,7 @@ var ts; // This character is not part of either suffix pattern break; } - if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) { break; } end = pos; @@ -2393,7 +2434,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; /** @@ -2494,12 +2535,12 @@ var ts; var newItem = newItems[newIndex]; var oldItem = oldItems[oldIndex]; var compareResult = comparer(newItem, oldItem); - if (compareResult === -1 /* LessThan */) { + if (compareResult === -1 /* Comparison.LessThan */) { inserted(newItem); newIndex++; hasChanges = true; } - else if (compareResult === 1 /* GreaterThan */) { + else if (compareResult === 1 /* Comparison.GreaterThan */) { deleted(oldItem); oldIndex++; hasChanges = true; @@ -2630,7 +2671,7 @@ var ts; (function (Debug) { var typeScriptVersion; /* eslint-disable prefer-const */ - var currentAssertionLevel = 0 /* None */; + var currentAssertionLevel = 0 /* AssertionLevel.None */; Debug.currentLogLevel = LogLevel.Warning; Debug.isDebugging = false; function getTypeScriptVersion() { @@ -2709,7 +2750,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2717,12 +2758,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2732,26 +2773,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2782,42 +2823,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2838,7 +2879,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; /** @@ -2942,6 +2983,22 @@ var ts; return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true); } Debug.formatFlowFlags = formatFlowFlags; + function formatRelationComparisonResult(result) { + return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true); + } + Debug.formatRelationComparisonResult = formatRelationComparisonResult; + function formatCheckMode(mode) { + return formatEnum(mode, ts.CheckMode, /*isFlags*/ true); + } + Debug.formatCheckMode = formatCheckMode; + function formatSignatureCheckMode(mode) { + return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true); + } + Debug.formatSignatureCheckMode = formatSignatureCheckMode; + function formatTypeFacts(facts) { + return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true); + } + Debug.formatTypeFacts = formatTypeFacts; var isDebugInfoEnabled = false; var extendedDebugModule; function extendedDebug() { @@ -2966,20 +3023,20 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" : - this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" : - this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" : - this.flags & 16 /* Assignment */ ? "FlowAssignment" : - this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" : - this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" : - this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" : - this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" : - this.flags & 512 /* Call */ ? "FlowCall" : - this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" : - this.flags & 1 /* Unreachable */ ? "FlowUnreachable" : + var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" : + this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" : + this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" : + this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" : "UnknownFlow"; - var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, @@ -3018,7 +3075,7 @@ var ts; // We don't care, this is debug code that's only enabled with a debugger attached - // we're just taking note of it for anyone checking regex performance in the future. defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -3070,10 +3127,10 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" : + var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" : "Symbol"; - var remainingSymbolFlags = this.flags & ~33554432 /* Transient */; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */; + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -3082,35 +3139,35 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" : - this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 /* BigIntLiteral */ ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : - this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : - this.flags & 32 /* Enum */ ? "EnumType" : - this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType " + this.intrinsicName : - this.flags & 1048576 /* Union */ ? "UnionType" : - this.flags & 2097152 /* Intersection */ ? "IntersectionType" : - this.flags & 4194304 /* Index */ ? "IndexType" : - this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : - this.flags & 16777216 /* Conditional */ ? "ConditionalType" : - this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : - this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : - this.flags & 524288 /* Object */ ? - this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : - this.objectFlags & 4 /* Reference */ ? "TypeReference" : - this.objectFlags & 8 /* Tuple */ ? "TupleType" : - this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : - this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : - this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : + var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" : + this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : + this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" : + this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) : + this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" : + this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" : + this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* TypeFlags.Object */ ? + this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" : + this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" : + this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" : + this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0; + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { // avoid recomputing @@ -3142,11 +3199,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -3178,7 +3235,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -3225,10 +3282,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -3272,6 +3329,48 @@ var ts; return wrapFunction(deprecation, func); } Debug.deprecate = deprecate; + function formatVariance(varianceFlags) { + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; + var result = variance === 0 /* VarianceFlags.Invariant */ ? "in out" : + variance === 3 /* VarianceFlags.Bivariant */ ? "[bivariant]" : + variance === 2 /* VarianceFlags.Contravariant */ ? "in" : + variance === 1 /* VarianceFlags.Covariant */ ? "out" : + variance === 4 /* VarianceFlags.Independent */ ? "[independent]" : ""; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { + result += " (unmeasurable)"; + } + else if (varianceFlags & 16 /* VarianceFlags.Unreliable */) { + result += " (unreliable)"; + } + return result; + } + Debug.formatVariance = formatVariance; + var DebugTypeMapper = /** @class */ (function () { + function DebugTypeMapper() { + } + DebugTypeMapper.prototype.__debugToString = function () { + var _a; + type(this); + switch (this.kind) { + case 3 /* TypeMapKind.Function */: return ((_a = this.debugInfo) === null || _a === void 0 ? void 0 : _a.call(this)) || "(function mapper)"; + case 0 /* TypeMapKind.Simple */: return "".concat(this.source.__debugTypeToString(), " -> ").concat(this.target.__debugTypeToString()); + case 1 /* TypeMapKind.Array */: return ts.zipWith(this.sources, this.targets || ts.map(this.sources, function () { return "any"; }), function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(typeof t === "string" ? t : t.__debugTypeToString()); }).join(", "); + case 2 /* TypeMapKind.Deferred */: return ts.zipWith(this.sources, this.targets, function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(t().__debugTypeToString()); }).join(", "); + case 5 /* TypeMapKind.Merged */: + case 4 /* TypeMapKind.Composite */: return "m1: ".concat(this.mapper1.__debugToString().split("\n").join("\n "), "\nm2: ").concat(this.mapper2.__debugToString().split("\n").join("\n ")); + default: return assertNever(this); + } + }; + return DebugTypeMapper; + }()); + Debug.DebugTypeMapper = DebugTypeMapper; + function attachDebugPrototypeIfDebug(mapper) { + if (Debug.isDebugging) { + return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype); + } + return mapper; + } + Debug.attachDebugPrototypeIfDebug = attachDebugPrototypeIfDebug; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); /* @internal */ @@ -3344,9 +3443,9 @@ var ts; // https://semver.org/#spec-item-11 // > Build metadata does not figure into precedence if (this === other) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (other === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; return ts.compareValues(this.major, other.major) || ts.compareValues(this.minor, other.minor) || ts.compareValues(this.patch, other.patch) @@ -3361,11 +3460,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -3394,11 +3493,11 @@ var ts; // > When major, minor, and patch are equal, a pre-release version has lower precedence // > than a normal version. if (left === right) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (left.length === 0) - return right.length === 0 ? 0 /* EqualTo */ : 1 /* GreaterThan */; + return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */; if (right.length === 0) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; // https://semver.org/#spec-item-11 // > Precedence for two pre-release versions with the same major, minor, and patch version // > MUST be determined by comparing each dot separated identifier from left to right until @@ -3415,7 +3514,7 @@ var ts; // https://semver.org/#spec-item-11 // > Numeric identifiers always have lower precedence than non-numeric identifiers. if (leftIsNumeric !== rightIsNumeric) - return leftIsNumeric ? -1 /* LessThan */ : 1 /* GreaterThan */; + return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; // https://semver.org/#spec-item-11 // > identifiers consisting of only digits are compared numerically var result = ts.compareValues(+leftIdentifier, +rightIdentifier); @@ -3632,7 +3731,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); /*@internal*/ @@ -3930,7 +4029,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3942,11 +4041,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -4013,9 +4112,9 @@ var ts; eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } tracingEnabled.push = push; - function pop() { + function pop(results) { ts.Debug.assert(eventStack.length > 0); - writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); + writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results); eventStack.length--; } tracingEnabled.pop = pop; @@ -4029,27 +4128,28 @@ var ts; tracingEnabled.popAll = popAll; // sample every 10ms var sampleInterval = 1000 * 10; - function writeStackEvent(index, endTime) { + function writeStackEvent(index, endTime, results) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { + ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`"); writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); } // test if [time,endTime) straddles a sampling point else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === "server" && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */) return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -4085,7 +4185,7 @@ var ts; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) var display = void 0; - if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { + if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) { try { display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } @@ -4094,7 +4194,7 @@ var ts; } } var indexedAccessProperties = {}; - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, @@ -4102,7 +4202,7 @@ var ts; }; } var referenceProperties = {}; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { var referenceType = type; referenceProperties = { instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, @@ -4111,7 +4211,7 @@ var ts; }; } var conditionalProperties = {}; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var conditionalType = type; conditionalProperties = { conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, @@ -4121,7 +4221,7 @@ var ts; }; } var substitutionProperties = {}; - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { var substitutionType = type; substitutionProperties = { substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, @@ -4129,7 +4229,7 @@ var ts; }; } var reverseMappedProperties = {}; - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { var reverseMappedType = type; reverseMappedProperties = { reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, @@ -4138,7 +4238,7 @@ var ts; }; } var evolvingArrayProperties = {}; - if (objectFlags & 256 /* EvolvingArray */) { + if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) { var evolvingArrayType = type; evolvingArrayProperties = { evolvingArrayElementType: evolvingArrayType.elementType.id, @@ -4156,7 +4256,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -4877,6 +4977,7 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; @@ -4917,6 +5018,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter"; // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -4928,7 +5030,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; /** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 814775659] = "NodeBuilderFlagsMask"; + TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -5407,9 +5509,10 @@ var ts; (function (TypeMapKind) { TypeMapKind[TypeMapKind["Simple"] = 0] = "Simple"; TypeMapKind[TypeMapKind["Array"] = 1] = "Array"; - TypeMapKind[TypeMapKind["Function"] = 2] = "Function"; - TypeMapKind[TypeMapKind["Composite"] = 3] = "Composite"; - TypeMapKind[TypeMapKind["Merged"] = 4] = "Merged"; + TypeMapKind[TypeMapKind["Deferred"] = 2] = "Deferred"; + TypeMapKind[TypeMapKind["Function"] = 3] = "Function"; + TypeMapKind[TypeMapKind["Composite"] = 4] = "Composite"; + TypeMapKind[TypeMapKind["Merged"] = 5] = "Merged"; })(TypeMapKind = ts.TypeMapKind || (ts.TypeMapKind = {})); var InferencePriority; (function (InferencePriority) { @@ -5804,10 +5907,8 @@ var ts; TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait"; TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper"; TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier"; - // Please leave this as 1 << 29. - // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. - // It is a good reminder of how much room we have left - TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["ContainsPrivateIdentifierInExpression"] = 536870912] = "ContainsPrivateIdentifierInExpression"; + TransformFlags[TransformFlags["HasComputedFlags"] = -2147483648] = "HasComputedFlags"; // Assertions // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript"; @@ -5826,23 +5927,23 @@ var ts; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes"; - TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes"; - TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes"; + TransformFlags[TransformFlags["OuterExpressionExcludes"] = -2147483648] = "OuterExpressionExcludes"; + TransformFlags[TransformFlags["PropertyAccessExcludes"] = -2147483648] = "PropertyAccessExcludes"; + TransformFlags[TransformFlags["NodeExcludes"] = -2147483648] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = -2072174592] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = -1937940480] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = -1937948672] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = -2005057536] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = -2013249536] = "PropertyExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = -2147344384] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = -1941676032] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes"; - TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; - TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes"; - TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = -2147278848] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = -2147450880] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = -2146893824] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = -2147483648] = "ParameterExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = -2147418112] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = -2147450880] = "BindingPatternExcludes"; TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper"; // Propagating flags // - Bitmasks for flags that should propagate from a child @@ -6095,37 +6196,37 @@ var ts; { name: "no-default-lib", optional: true }, { name: "resolution-mode", optional: true } ], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-dependency": { args: [{ name: "path" }, { name: "name", optional: true }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-module": { args: [{ name: "name" }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "ts-check": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "ts-nocheck": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "jsx": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxfrag": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsximportsource": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxruntime": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, }; })(ts || (ts = {})); @@ -6197,7 +6298,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -6414,7 +6515,7 @@ var ts; }; } function createDirectoryWatcher(dirName, dirPath, fallbackOptions) { - var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) { + var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName, modifiedTime) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" if (!ts.isString(relativeFileName)) return; @@ -6642,7 +6743,7 @@ var ts; function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) { // Iterate through existing children and update the watches if needed var parentWatcher = cache.get(dirPath); - if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) { + if (parentWatcher && fileSystemEntryExists(dirName, 1 /* FileSystemEntryKind.Directory */)) { // Schedule the update and postpone invoke for callbacks scheduleUpdateChildWatches(dirName, dirPath, fileName, options); return; @@ -6667,7 +6768,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -6680,7 +6781,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -6696,7 +6797,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -6715,11 +6816,11 @@ var ts; if (!parentWatcher) return false; var newChildWatches; - var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) { + var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* FileSystemEntryKind.Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) { var childFullName = ts.getNormalizedAbsolutePath(child, parentDir); // Filter our the symbolic link directories since those arent included in recursive watch // which is same behaviour when recursive: true is passed to fs.watch - return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : undefined; + return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* Comparison.EqualTo */ ? childFullName : undefined; }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher); parentWatcher.childWatches = newChildWatches || ts.emptyArray; return hasChanges; @@ -6817,7 +6918,7 @@ var ts; case ts.WatchFileKind.FixedChunkSizePolling: return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: - return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime), + return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); case ts.WatchFileKind.UseFsEventsOnParentDirectory: if (!nonPollingWatchFile) { @@ -6872,7 +6973,7 @@ var ts; } function watchDirectory(directoryName, callback, recursive, options) { if (fsSupportsRecursiveFsWatch) { - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); } if (!hostRecursiveDirectoryWatcher) { hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({ @@ -6904,7 +7005,7 @@ var ts; /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchDirectoryKind.UseFsEvents: - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: ts.Debug.assertNever(watchDirectoryKind); } @@ -6943,14 +7044,16 @@ var ts; return { close: function () { // Close the watcher (either existing file system entry watcher or missing file system entry watcher) - watcher.close(); - watcher = undefined; + if (watcher) { + watcher.close(); + watcher = undefined; + } } }; function updateWatcher(createWatcher) { // If watcher is not closed, update it if (watcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); watcher.close(); watcher = createWatcher(); } @@ -6961,7 +7064,7 @@ var ts; */ function watchPresentFileSystemEntry() { if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -6980,7 +7083,7 @@ var ts; // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -7275,7 +7378,7 @@ var ts; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -7284,7 +7387,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -7300,7 +7403,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -7498,8 +7601,8 @@ var ts; return false; } switch (entryKind) { - case 0 /* File */: return stat.isFile(); - case 1 /* Directory */: return stat.isDirectory(); + case 0 /* FileSystemEntryKind.File */: return stat.isFile(); + case 1 /* FileSystemEntryKind.Directory */: return stat.isDirectory(); default: return false; } } @@ -7511,10 +7614,10 @@ var ts; } } function fileExists(path) { - return fileSystemEntryExists(path, 0 /* File */); + return fileSystemEntryExists(path, 0 /* FileSystemEntryKind.File */); } function directoryExists(path) { - return fileSystemEntryExists(path, 1 /* Directory */); + return fileSystemEntryExists(path, 1 /* FileSystemEntryKind.Directory */); } function getDirectories(path) { return getAccessibleFileSystemEntries(path).directories.slice(); @@ -7585,8 +7688,8 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* AssertionLevel.Normal */ + : 0 /* AssertionLevel.None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7609,7 +7712,7 @@ var ts; * Determines whether a charCode corresponds to `/` or `\`. */ function isAnyDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */; } ts.isAnyDirectorySeparator = isAnyDirectorySeparator; /** @@ -7696,16 +7799,16 @@ var ts; ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; //// Path Parsing function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) || + (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */); } function getFileUrlVolumeSeparatorEnd(url, start) { var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) + if (ch0 === 58 /* CharacterCodes.colon */) return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) { var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */) return start + 3; } return -1; @@ -7719,18 +7822,18 @@ var ts; return 0; var ch0 = path.charCodeAt(0); // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) { if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); + var p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); if (p1 < 0) return path.length; // UNC: "//server" or "\\server" return p1 + 1; // UNC: "//server/" or "\\server\" } // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) { var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */) return 3; // DOS: "c:/" or "c:\" if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") @@ -7750,7 +7853,7 @@ var ts; isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) { // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" return ~(volumeSeparatorEnd + 1); } @@ -7827,7 +7930,7 @@ var ts; function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { if (!ts.startsWith(extension, ".")) extension = "." + extension; - if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) { var pathExtension = path.slice(path.length - extension.length); if (stringEqualityComparer(pathExtension, extension)) { return pathExtension; @@ -8111,17 +8214,17 @@ var ts; var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; // NOTE: Performance optimization - shortcut if the root segments differ as there would be no // need to perform path reduction. var aRoot = a.substring(0, getRootLength(a)); var bRoot = b.substring(0, getRootLength(b)); var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { + if (result !== 0 /* Comparison.EqualTo */) { return result; } // NOTE: Performance optimization - shortcut if there are no relative path segments in @@ -8138,7 +8241,7 @@ var ts; var sharedLength = Math.min(aComponents.length, bComponents.length); for (var i = 1; i < sharedLength; i++) { var result_2 = componentComparer(aComponents[i], bComponents[i]); - if (result_2 !== 0 /* EqualTo */) { + if (result_2 !== 0 /* Comparison.EqualTo */) { return result_2; } } @@ -8653,13 +8756,24 @@ var ts; resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."), Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"), + File_is_ECMAScript_module_because_0_has_field_type_with_value_module: diag(1458, ts.DiagnosticCategory.Message, "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458", "File is ECMAScript module because '{0}' has field \"type\" with value \"module\""), + File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module: diag(1459, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459", "File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\""), + File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""), + File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"), The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."), - Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."), + Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead."), catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."), An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), + An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."), + Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."), + The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead: diag(1479, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_reference_1479", "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"{0}\")' call instead."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module: diag(1480, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_packag_1480", "To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1: diag(1481, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Co_1481", "To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'."), + To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0: diag(1482, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0_1482", "To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'."), + To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module: diag(1483, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module_1483", "To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -8873,6 +8987,7 @@ var ts; Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."), Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."), Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."), + A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, ts.DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."), Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."), All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."), Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."), @@ -9160,6 +9275,7 @@ var ts; The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), + Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), 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}'."), @@ -10139,100 +10255,100 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 79 /* Identifier */; + return token >= 79 /* SyntaxKind.Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* SyntaxKind.GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; /** @internal */ ts.textToKeywordObj = (_a = { - abstract: 126 /* AbstractKeyword */, - any: 130 /* AnyKeyword */, - as: 127 /* AsKeyword */, - asserts: 128 /* AssertsKeyword */, - assert: 129 /* AssertKeyword */, - bigint: 158 /* BigIntKeyword */, - boolean: 133 /* BooleanKeyword */, - break: 81 /* BreakKeyword */, - case: 82 /* CaseKeyword */, - catch: 83 /* CatchKeyword */, - class: 84 /* ClassKeyword */, - continue: 86 /* ContinueKeyword */, - const: 85 /* ConstKeyword */ + abstract: 126 /* SyntaxKind.AbstractKeyword */, + any: 130 /* SyntaxKind.AnyKeyword */, + as: 127 /* SyntaxKind.AsKeyword */, + asserts: 128 /* SyntaxKind.AssertsKeyword */, + assert: 129 /* SyntaxKind.AssertKeyword */, + bigint: 158 /* SyntaxKind.BigIntKeyword */, + boolean: 133 /* SyntaxKind.BooleanKeyword */, + break: 81 /* SyntaxKind.BreakKeyword */, + case: 82 /* SyntaxKind.CaseKeyword */, + catch: 83 /* SyntaxKind.CatchKeyword */, + class: 84 /* SyntaxKind.ClassKeyword */, + continue: 86 /* SyntaxKind.ContinueKeyword */, + const: 85 /* SyntaxKind.ConstKeyword */ }, - _a["" + "constructor"] = 134 /* ConstructorKeyword */, - _a.debugger = 87 /* DebuggerKeyword */, - _a.declare = 135 /* DeclareKeyword */, - _a.default = 88 /* DefaultKeyword */, - _a.delete = 89 /* DeleteKeyword */, - _a.do = 90 /* DoKeyword */, - _a.else = 91 /* ElseKeyword */, - _a.enum = 92 /* EnumKeyword */, - _a.export = 93 /* ExportKeyword */, - _a.extends = 94 /* ExtendsKeyword */, - _a.false = 95 /* FalseKeyword */, - _a.finally = 96 /* FinallyKeyword */, - _a.for = 97 /* ForKeyword */, - _a.from = 156 /* FromKeyword */, - _a.function = 98 /* FunctionKeyword */, - _a.get = 136 /* GetKeyword */, - _a.if = 99 /* IfKeyword */, - _a.implements = 117 /* ImplementsKeyword */, - _a.import = 100 /* ImportKeyword */, - _a.in = 101 /* InKeyword */, - _a.infer = 137 /* InferKeyword */, - _a.instanceof = 102 /* InstanceOfKeyword */, - _a.interface = 118 /* InterfaceKeyword */, - _a.intrinsic = 138 /* IntrinsicKeyword */, - _a.is = 139 /* IsKeyword */, - _a.keyof = 140 /* KeyOfKeyword */, - _a.let = 119 /* LetKeyword */, - _a.module = 141 /* ModuleKeyword */, - _a.namespace = 142 /* NamespaceKeyword */, - _a.never = 143 /* NeverKeyword */, - _a.new = 103 /* NewKeyword */, - _a.null = 104 /* NullKeyword */, - _a.number = 147 /* NumberKeyword */, - _a.object = 148 /* ObjectKeyword */, - _a.package = 120 /* PackageKeyword */, - _a.private = 121 /* PrivateKeyword */, - _a.protected = 122 /* ProtectedKeyword */, - _a.public = 123 /* PublicKeyword */, - _a.override = 159 /* OverrideKeyword */, - _a.out = 144 /* OutKeyword */, - _a.readonly = 145 /* ReadonlyKeyword */, - _a.require = 146 /* RequireKeyword */, - _a.global = 157 /* GlobalKeyword */, - _a.return = 105 /* ReturnKeyword */, - _a.set = 149 /* SetKeyword */, - _a.static = 124 /* StaticKeyword */, - _a.string = 150 /* StringKeyword */, - _a.super = 106 /* SuperKeyword */, - _a.switch = 107 /* SwitchKeyword */, - _a.symbol = 151 /* SymbolKeyword */, - _a.this = 108 /* ThisKeyword */, - _a.throw = 109 /* ThrowKeyword */, - _a.true = 110 /* TrueKeyword */, - _a.try = 111 /* TryKeyword */, - _a.type = 152 /* TypeKeyword */, - _a.typeof = 112 /* TypeOfKeyword */, - _a.undefined = 153 /* UndefinedKeyword */, - _a.unique = 154 /* UniqueKeyword */, - _a.unknown = 155 /* UnknownKeyword */, - _a.var = 113 /* VarKeyword */, - _a.void = 114 /* VoidKeyword */, - _a.while = 115 /* WhileKeyword */, - _a.with = 116 /* WithKeyword */, - _a.yield = 125 /* YieldKeyword */, - _a.async = 131 /* AsyncKeyword */, - _a.await = 132 /* AwaitKeyword */, - _a.of = 160 /* OfKeyword */, + _a["" + "constructor"] = 134 /* SyntaxKind.ConstructorKeyword */, + _a.debugger = 87 /* SyntaxKind.DebuggerKeyword */, + _a.declare = 135 /* SyntaxKind.DeclareKeyword */, + _a.default = 88 /* SyntaxKind.DefaultKeyword */, + _a.delete = 89 /* SyntaxKind.DeleteKeyword */, + _a.do = 90 /* SyntaxKind.DoKeyword */, + _a.else = 91 /* SyntaxKind.ElseKeyword */, + _a.enum = 92 /* SyntaxKind.EnumKeyword */, + _a.export = 93 /* SyntaxKind.ExportKeyword */, + _a.extends = 94 /* SyntaxKind.ExtendsKeyword */, + _a.false = 95 /* SyntaxKind.FalseKeyword */, + _a.finally = 96 /* SyntaxKind.FinallyKeyword */, + _a.for = 97 /* SyntaxKind.ForKeyword */, + _a.from = 156 /* SyntaxKind.FromKeyword */, + _a.function = 98 /* SyntaxKind.FunctionKeyword */, + _a.get = 136 /* SyntaxKind.GetKeyword */, + _a.if = 99 /* SyntaxKind.IfKeyword */, + _a.implements = 117 /* SyntaxKind.ImplementsKeyword */, + _a.import = 100 /* SyntaxKind.ImportKeyword */, + _a.in = 101 /* SyntaxKind.InKeyword */, + _a.infer = 137 /* SyntaxKind.InferKeyword */, + _a.instanceof = 102 /* SyntaxKind.InstanceOfKeyword */, + _a.interface = 118 /* SyntaxKind.InterfaceKeyword */, + _a.intrinsic = 138 /* SyntaxKind.IntrinsicKeyword */, + _a.is = 139 /* SyntaxKind.IsKeyword */, + _a.keyof = 140 /* SyntaxKind.KeyOfKeyword */, + _a.let = 119 /* SyntaxKind.LetKeyword */, + _a.module = 141 /* SyntaxKind.ModuleKeyword */, + _a.namespace = 142 /* SyntaxKind.NamespaceKeyword */, + _a.never = 143 /* SyntaxKind.NeverKeyword */, + _a.new = 103 /* SyntaxKind.NewKeyword */, + _a.null = 104 /* SyntaxKind.NullKeyword */, + _a.number = 147 /* SyntaxKind.NumberKeyword */, + _a.object = 148 /* SyntaxKind.ObjectKeyword */, + _a.package = 120 /* SyntaxKind.PackageKeyword */, + _a.private = 121 /* SyntaxKind.PrivateKeyword */, + _a.protected = 122 /* SyntaxKind.ProtectedKeyword */, + _a.public = 123 /* SyntaxKind.PublicKeyword */, + _a.override = 159 /* SyntaxKind.OverrideKeyword */, + _a.out = 144 /* SyntaxKind.OutKeyword */, + _a.readonly = 145 /* SyntaxKind.ReadonlyKeyword */, + _a.require = 146 /* SyntaxKind.RequireKeyword */, + _a.global = 157 /* SyntaxKind.GlobalKeyword */, + _a.return = 105 /* SyntaxKind.ReturnKeyword */, + _a.set = 149 /* SyntaxKind.SetKeyword */, + _a.static = 124 /* SyntaxKind.StaticKeyword */, + _a.string = 150 /* SyntaxKind.StringKeyword */, + _a.super = 106 /* SyntaxKind.SuperKeyword */, + _a.switch = 107 /* SyntaxKind.SwitchKeyword */, + _a.symbol = 151 /* SyntaxKind.SymbolKeyword */, + _a.this = 108 /* SyntaxKind.ThisKeyword */, + _a.throw = 109 /* SyntaxKind.ThrowKeyword */, + _a.true = 110 /* SyntaxKind.TrueKeyword */, + _a.try = 111 /* SyntaxKind.TryKeyword */, + _a.type = 152 /* SyntaxKind.TypeKeyword */, + _a.typeof = 112 /* SyntaxKind.TypeOfKeyword */, + _a.undefined = 153 /* SyntaxKind.UndefinedKeyword */, + _a.unique = 154 /* SyntaxKind.UniqueKeyword */, + _a.unknown = 155 /* SyntaxKind.UnknownKeyword */, + _a.var = 113 /* SyntaxKind.VarKeyword */, + _a.void = 114 /* SyntaxKind.VoidKeyword */, + _a.while = 115 /* SyntaxKind.WhileKeyword */, + _a.with = 116 /* SyntaxKind.WithKeyword */, + _a.yield = 125 /* SyntaxKind.YieldKeyword */, + _a.async = 131 /* SyntaxKind.AsyncKeyword */, + _a.await = 132 /* SyntaxKind.AwaitKeyword */, + _a.of = 160 /* SyntaxKind.OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* SyntaxKind.OpenBraceToken */, "}": 19 /* SyntaxKind.CloseBraceToken */, "(": 20 /* SyntaxKind.OpenParenToken */, ")": 21 /* SyntaxKind.CloseParenToken */, "[": 22 /* SyntaxKind.OpenBracketToken */, "]": 23 /* SyntaxKind.CloseBracketToken */, ".": 24 /* SyntaxKind.DotToken */, "...": 25 /* SyntaxKind.DotDotDotToken */, ";": 26 /* SyntaxKind.SemicolonToken */, ",": 27 /* SyntaxKind.CommaToken */, "<": 29 /* SyntaxKind.LessThanToken */, ">": 31 /* SyntaxKind.GreaterThanToken */, "<=": 32 /* SyntaxKind.LessThanEqualsToken */, ">=": 33 /* SyntaxKind.GreaterThanEqualsToken */, "==": 34 /* SyntaxKind.EqualsEqualsToken */, "!=": 35 /* SyntaxKind.ExclamationEqualsToken */, "===": 36 /* SyntaxKind.EqualsEqualsEqualsToken */, "!==": 37 /* SyntaxKind.ExclamationEqualsEqualsToken */, "=>": 38 /* SyntaxKind.EqualsGreaterThanToken */, "+": 39 /* SyntaxKind.PlusToken */, "-": 40 /* SyntaxKind.MinusToken */, "**": 42 /* SyntaxKind.AsteriskAsteriskToken */, "*": 41 /* SyntaxKind.AsteriskToken */, "/": 43 /* SyntaxKind.SlashToken */, "%": 44 /* SyntaxKind.PercentToken */, "++": 45 /* SyntaxKind.PlusPlusToken */, "--": 46 /* SyntaxKind.MinusMinusToken */, "<<": 47 /* SyntaxKind.LessThanLessThanToken */, ">": 48 /* SyntaxKind.GreaterThanGreaterThanToken */, ">>>": 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* SyntaxKind.AmpersandToken */, "|": 51 /* SyntaxKind.BarToken */, "^": 52 /* SyntaxKind.CaretToken */, "!": 53 /* SyntaxKind.ExclamationToken */, "~": 54 /* SyntaxKind.TildeToken */, "&&": 55 /* SyntaxKind.AmpersandAmpersandToken */, "||": 56 /* SyntaxKind.BarBarToken */, "?": 57 /* SyntaxKind.QuestionToken */, "??": 60 /* SyntaxKind.QuestionQuestionToken */, "?.": 28 /* SyntaxKind.QuestionDotToken */, ":": 58 /* SyntaxKind.ColonToken */, "=": 63 /* SyntaxKind.EqualsToken */, "+=": 64 /* SyntaxKind.PlusEqualsToken */, "-=": 65 /* SyntaxKind.MinusEqualsToken */, "*=": 66 /* SyntaxKind.AsteriskEqualsToken */, "**=": 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */, "/=": 68 /* SyntaxKind.SlashEqualsToken */, "%=": 69 /* SyntaxKind.PercentEqualsToken */, "<<=": 70 /* SyntaxKind.LessThanLessThanEqualsToken */, ">>=": 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* SyntaxKind.AmpersandEqualsToken */, "|=": 74 /* SyntaxKind.BarEqualsToken */, "^=": 78 /* SyntaxKind.CaretEqualsToken */, "||=": 75 /* SyntaxKind.BarBarEqualsToken */, "&&=": 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */, "??=": 77 /* SyntaxKind.QuestionQuestionEqualsToken */, "@": 59 /* SyntaxKind.AtToken */, "#": 62 /* SyntaxKind.HashToken */, "`": 61 /* SyntaxKind.BacktickToken */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -10321,16 +10437,16 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { @@ -10359,17 +10475,17 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: result.push(lineStart); lineStart = pos; break; default: - if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) { result.push(lineStart); lineStart = pos; } @@ -10394,7 +10510,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -10472,18 +10588,18 @@ var ts; function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; + return ch === 32 /* CharacterCodes.space */ || + ch === 9 /* CharacterCodes.tab */ || + ch === 11 /* CharacterCodes.verticalTab */ || + ch === 12 /* CharacterCodes.formFeed */ || + ch === 160 /* CharacterCodes.nonBreakingSpace */ || + ch === 133 /* CharacterCodes.nextLine */ || + ch === 5760 /* CharacterCodes.ogham */ || + ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ || + ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ || + ch === 8287 /* CharacterCodes.mathematicalSpace */ || + ch === 12288 /* CharacterCodes.ideographicSpace */ || + ch === 65279 /* CharacterCodes.byteOrderMark */; } ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; function isLineBreak(ch) { @@ -10497,50 +10613,50 @@ var ts; // \u2029 Paragraph separator // Only the characters in Table 3 are treated as line terminators. Other new line or line // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; + return ch === 10 /* CharacterCodes.lineFeed */ || + ch === 13 /* CharacterCodes.carriageReturn */ || + ch === 8232 /* CharacterCodes.lineSeparator */ || + ch === 8233 /* CharacterCodes.paragraphSeparator */; } ts.isLineBreak = isLineBreak; function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isHexDigit(ch) { - return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */; + return isDigit(ch) || ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */ || ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */; } function isCodePoint(code) { return code <= 0x10FFFF; } /* @internal */ function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 55 /* CharacterCodes._7 */; } ts.isOctalDigit = isOctalDigit; function couldStartTrivia(text, pos) { // Keep in sync with skipTrivia var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: + case 13 /* CharacterCodes.carriageReturn */: + case 10 /* CharacterCodes.lineFeed */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 47 /* CharacterCodes.slash */: // starts of normal trivia // falls through - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: // Starts of conflict marker trivia return true; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: // Only if its the beginning can we have #! trivia return pos === 0; default: - return ch > 127 /* maxAsciiCharacter */; + return ch > 127 /* CharacterCodes.maxAsciiCharacter */; } } ts.couldStartTrivia = couldStartTrivia; @@ -10554,29 +10670,29 @@ var ts; while (true) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (stopAfterLineBreak) { return pos; } canConsumeStar = !!inJSDoc; continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: if (stopAtComments) { break; } - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { @@ -10587,10 +10703,10 @@ var ts; canConsumeStar = false; continue; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10600,24 +10716,24 @@ var ts; continue; } break; - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); canConsumeStar = false; continue; } break; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); canConsumeStar = false; continue; } break; - case 42 /* asterisk */: + case 42 /* CharacterCodes.asterisk */: if (canConsumeStar) { pos++; canConsumeStar = false; @@ -10625,7 +10741,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -10649,8 +10765,8 @@ var ts; return false; } } - return ch === 61 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + return ch === 61 /* CharacterCodes.equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* CharacterCodes.space */; } } return false; @@ -10661,18 +10777,18 @@ var ts; } var ch = text.charCodeAt(pos); var len = text.length; - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { while (pos < len && !isLineBreak(text.charCodeAt(pos))) { pos++; } } else { - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); // Consume everything from the start of a ||||||| or ======= marker to the start // of the next ======= or >>>>>>> marker. while (pos < len) { var currentChar = text.charCodeAt(pos); - if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { + if ((currentChar === 61 /* CharacterCodes.equals */ || currentChar === 62 /* CharacterCodes.greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -10733,12 +10849,12 @@ var ts; scan: while (pos >= 0 && pos < text.length) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (trailing) { break scan; @@ -10748,20 +10864,20 @@ var ts; pendingHasTrailingNewLine = true; } continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: var nextChar = text.charCodeAt(pos + 1); var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + if (nextChar === 47 /* CharacterCodes.slash */ || nextChar === 42 /* CharacterCodes.asterisk */) { + var kind = nextChar === 47 /* CharacterCodes.slash */ ? 2 /* SyntaxKind.SingleLineCommentTrivia */ : 3 /* SyntaxKind.MultiLineCommentTrivia */; var startPos = pos; pos += 2; - if (nextChar === 47 /* slash */) { + if (nextChar === 47 /* CharacterCodes.slash */) { while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { hasTrailingNewLine = true; @@ -10772,7 +10888,7 @@ var ts; } else { while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10797,7 +10913,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -10852,17 +10968,17 @@ var ts; } ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } ts.isIdentifierStart = isIdentifierStart; function isIdentifierPart(ch, languageVersion, identifierVariant) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ || ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || // "-" and ":" are valid in JSX Identifiers - (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + (identifierVariant === 1 /* LanguageVariant.JSX */ ? (ch === 45 /* CharacterCodes.minus */ || ch === 58 /* CharacterCodes.colon */) : false) || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; /* @internal */ @@ -10881,7 +10997,7 @@ var ts; ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + if (languageVariant === void 0) { languageVariant = 0 /* LanguageVariant.Standard */; } var text = textInitial; // Current position (end position of text of current token) var pos; @@ -10904,15 +11020,15 @@ var ts; getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, - hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, - hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, - hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; }, - isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; }, - isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* TokenFlags.UnicodeEscape */) !== 0; }, + hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* TokenFlags.ExtendedUnicodeEscape */) !== 0; }, + hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */) !== 0; }, + hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* TokenFlags.PrecedingJSDocComment */) !== 0; }, + isIdentifier: function () { return token === 79 /* SyntaxKind.Identifier */ || token > 116 /* SyntaxKind.LastReservedWord */; }, + isReservedWord: function () { return token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */; }, + isUnterminated: function () { return (tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, - getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, + getNumericLiteralFlags: function () { return tokenFlags & 1008 /* TokenFlags.NumericLiteralFlags */; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, reScanAsteriskEqualsToken: reScanAsteriskEqualsToken, @@ -10967,8 +11083,8 @@ var ts; var result = ""; while (true) { var ch = text.charCodeAt(pos); - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10992,7 +11108,7 @@ var ts; } break; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return result + text.substring(start, pos); @@ -11002,15 +11118,15 @@ var ts; var mainFragment = scanNumberFragment(); var decimalFragment; var scientificFragment; - if (text.charCodeAt(pos) === 46 /* dot */) { + if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) { pos++; decimalFragment = scanNumberFragment(); } var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) { pos++; - tokenFlags |= 16 /* Scientific */; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + tokenFlags |= 16 /* TokenFlags.Scientific */; + if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos++; var preNumericPart = pos; var finalFragment = scanNumberFragment(); @@ -11023,7 +11139,7 @@ var ts; } } var result; - if (tokenFlags & 512 /* ContainsSeparator */) { + if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) { result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; @@ -11035,10 +11151,10 @@ var ts; else { result = text.substring(start, end); // No need to use all the fragments; no _ removal needed } - if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { - checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* Scientific */)); + if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) { + checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */)); return { - type: 8 /* NumericLiteral */, + type: 8 /* SyntaxKind.NumericLiteral */, value: "" + +result // if value is not an integer, it can be safely coerced to a number }; } @@ -11096,8 +11212,8 @@ var ts; var isPreviousTokenSeparator = false; while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); - if (canHaveSeparators && ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (canHaveSeparators && ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -11112,11 +11228,11 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 65 /* A */ && ch <= 70 /* F */) { - ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase + if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) { + ch += 97 /* CharacterCodes.a */ - 65 /* CharacterCodes.A */; // standardize hex literals to lowercase } - else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || - (ch >= 97 /* a */ && ch <= 102 /* f */))) { + else if (!((ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) || + (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */))) { break; } valueChars.push(ch); @@ -11126,7 +11242,7 @@ var ts; if (valueChars.length < minCount) { valueChars = []; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return String.fromCharCode.apply(String, valueChars); @@ -11140,7 +11256,7 @@ var ts; while (true) { if (pos >= end) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11150,7 +11266,7 @@ var ts; pos++; break; } - if (ch === 92 /* backslash */ && !jsxAttributeString) { + if (ch === 92 /* CharacterCodes.backslash */ && !jsxAttributeString) { result += text.substring(start, pos); result += scanEscapeSequence(); start = pos; @@ -11158,7 +11274,7 @@ var ts; } if (isLineBreak(ch) && !jsxAttributeString) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -11171,7 +11287,7 @@ var ts; * a literal component of a TemplateExpression. */ function scanTemplateAndSetTokenValue(isTaggedTemplate) { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + var startedWithBacktick = text.charCodeAt(pos) === 96 /* CharacterCodes.backtick */; pos++; var start = pos; var contents = ""; @@ -11179,28 +11295,28 @@ var ts; while (true) { if (pos >= end) { contents += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } var currChar = text.charCodeAt(pos); // '`' - if (currChar === 96 /* backtick */) { + if (currChar === 96 /* CharacterCodes.backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } // '${' - if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + if (currChar === 36 /* CharacterCodes.$ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* CharacterCodes.openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* SyntaxKind.TemplateHead */ : 16 /* SyntaxKind.TemplateMiddle */; break; } // Escape character - if (currChar === 92 /* backslash */) { + if (currChar === 92 /* CharacterCodes.backslash */) { contents += text.substring(start, pos); contents += scanEscapeSequence(isTaggedTemplate); start = pos; @@ -11208,10 +11324,10 @@ var ts; } // Speculated ECMAScript 6 Spec 11.8.6.1: // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { + if (currChar === 13 /* CharacterCodes.carriageReturn */) { contents += text.substring(start, pos); pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } contents += "\n"; @@ -11234,47 +11350,47 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 48 /* _0 */: + case 48 /* CharacterCodes._0 */: // '\01' if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } return "\0"; - case 98 /* b */: + case 98 /* CharacterCodes.b */: return "\b"; - case 116 /* t */: + case 116 /* CharacterCodes.t */: return "\t"; - case 110 /* n */: + case 110 /* CharacterCodes.n */: return "\n"; - case 118 /* v */: + case 118 /* CharacterCodes.v */: return "\v"; - case 102 /* f */: + case 102 /* CharacterCodes.f */: return "\f"; - case 114 /* r */: + case 114 /* CharacterCodes.r */: return "\r"; - case 39 /* singleQuote */: + case 39 /* CharacterCodes.singleQuote */: return "\'"; - case 34 /* doubleQuote */: + case 34 /* CharacterCodes.doubleQuote */: return "\""; - case 117 /* u */: + case 117 /* CharacterCodes.u */: if (isTaggedTemplate) { // '\u' or '\u0' or '\u00' or '\u000' for (var escapePos = pos; escapePos < pos + 4; escapePos++) { - if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) { + if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* CharacterCodes.openBrace */) { pos = escapePos; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } } // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + if (pos < end && text.charCodeAt(pos) === 123 /* CharacterCodes.openBrace */) { pos++; // '\u{' if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } if (isTaggedTemplate) { @@ -11282,29 +11398,29 @@ var ts; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; // '\u{Not Code Point' or '\u{CodePoint' - if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* CharacterCodes.closeBrace */) { + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else { pos = savePos; } } - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; return scanExtendedUnicodeEscape(); } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: + case 120 /* CharacterCodes.x */: if (isTaggedTemplate) { if (!isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else if (!isHexDigit(text.charCodeAt(pos + 1))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } @@ -11312,14 +11428,14 @@ var ts; return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: + case 10 /* CharacterCodes.lineFeed */: + case 8232 /* CharacterCodes.lineSeparator */: + case 8233 /* CharacterCodes.paragraphSeparator */: return ""; default: return String.fromCharCode(ch); @@ -11352,7 +11468,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) === 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -11368,7 +11484,7 @@ var ts; // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* CharacterCodes.u */) { var start_1 = pos; pos += 2; var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false); @@ -11378,7 +11494,7 @@ var ts; return -1; } function peekExtendedUnicodeEscape() { - if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) { var start_2 = pos; pos += 3; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); @@ -11396,11 +11512,11 @@ var ts; if (isIdentifierPart(ch, languageVersion)) { pos += charSize(ch); } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { ch = peekExtendedUnicodeEscape(); if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; result += scanExtendedUnicodeEscape(); start = pos; continue; @@ -11409,7 +11525,7 @@ var ts; if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; result += text.substring(start, pos); result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters @@ -11428,14 +11544,14 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 12) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { var keyword = textToKeyword.get(tokenValue); if (keyword !== undefined) { return token = keyword; } } } - return token = 79 /* Identifier */; + return token = 79 /* SyntaxKind.Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -11446,8 +11562,8 @@ var ts; while (true) { var ch = text.charCodeAt(pos); // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (separatorAllowed) { separatorAllowed = false; isPreviousTokenSeparator = true; @@ -11462,101 +11578,101 @@ var ts; continue; } separatorAllowed = true; - if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { + if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) { break; } value += text[pos]; pos++; isPreviousTokenSeparator = false; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return value; } function checkBigIntSuffix() { - if (text.charCodeAt(pos) === 110 /* n */) { + if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) { tokenValue += "n"; // Use base 10 instead of base 2 or base 8 for shorter literals - if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + if (tokenFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; } pos++; - return 9 /* BigIntLiteral */; + return 9 /* SyntaxKind.BigIntLiteral */; } else { // not a bigint, so can convert to number in simplified form // Number() may not support 0b or 0o, so use parseInt() instead - var numericValue = tokenFlags & 128 /* BinarySpecifier */ + var numericValue = tokenFlags & 128 /* TokenFlags.BinarySpecifier */ ? parseInt(tokenValue.slice(2), 2) // skip "0b" - : tokenFlags & 256 /* OctalSpecifier */ + : tokenFlags & 256 /* TokenFlags.OctalSpecifier */ ? parseInt(tokenValue.slice(2), 8) // skip "0o" : +tokenValue; tokenValue = "" + numericValue; - return 8 /* NumericLiteral */; + return 8 /* SyntaxKind.NumericLiteral */; } } function scan() { var _a; startPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + if (ch === 35 /* CharacterCodes.hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { continue; } else { - return token = 6 /* ShebangTrivia */; + return token = 6 /* SyntaxKind.ShebangTrivia */; } } switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - tokenFlags |= 1 /* PrecedingLineBreak */; + case 10 /* CharacterCodes.lineFeed */: + case 13 /* CharacterCodes.carriageReturn */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; if (skipTrivia) { pos++; continue; } else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + if (ch === 13 /* CharacterCodes.carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { // consume both CR and LF pos += 2; } else { pos++; } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 5760 /* ogham */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 8287 /* mathematicalSpace */: - case 12288 /* ideographicSpace */: - case 65279 /* byteOrderMark */: + return token = 4 /* SyntaxKind.NewLineTrivia */; + } + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 160 /* CharacterCodes.nonBreakingSpace */: + case 5760 /* CharacterCodes.ogham */: + case 8192 /* CharacterCodes.enQuad */: + case 8193 /* CharacterCodes.emQuad */: + case 8194 /* CharacterCodes.enSpace */: + case 8195 /* CharacterCodes.emSpace */: + case 8196 /* CharacterCodes.threePerEmSpace */: + case 8197 /* CharacterCodes.fourPerEmSpace */: + case 8198 /* CharacterCodes.sixPerEmSpace */: + case 8199 /* CharacterCodes.figureSpace */: + case 8200 /* CharacterCodes.punctuationSpace */: + case 8201 /* CharacterCodes.thinSpace */: + case 8202 /* CharacterCodes.hairSpace */: + case 8203 /* CharacterCodes.zeroWidthSpace */: + case 8239 /* CharacterCodes.narrowNoBreakSpace */: + case 8287 /* CharacterCodes.mathematicalSpace */: + case 12288 /* CharacterCodes.ideographicSpace */: + case 65279 /* CharacterCodes.byteOrderMark */: if (skipTrivia) { pos++; continue; @@ -11565,98 +11681,98 @@ var ts; while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; + return token = 5 /* SyntaxKind.WhitespaceTrivia */; } - case 33 /* exclamation */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; + case 33 /* CharacterCodes.exclamation */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } - return pos += 2, token = 35 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* SyntaxKind.ExclamationEqualsToken */; } pos++; - return token = 53 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + return token = 53 /* SyntaxKind.ExclamationToken */; + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(); - return token = 10 /* StringLiteral */; - case 96 /* backtick */: + return token = 10 /* SyntaxKind.StringLiteral */; + case 96 /* CharacterCodes.backtick */: return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* PercentEqualsToken */; + case 37 /* CharacterCodes.percent */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 69 /* SyntaxKind.PercentEqualsToken */; } pos++; - return token = 44 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; + return token = 44 /* SyntaxKind.PercentToken */; + case 38 /* CharacterCodes.ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* CharacterCodes.ampersand */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */; } - return pos += 2, token = 55 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* SyntaxKind.AmpersandAmpersandToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* AmpersandEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 73 /* SyntaxKind.AmpersandEqualsToken */; } pos++; - return token = 50 /* AmpersandToken */; - case 40 /* openParen */: + return token = 50 /* SyntaxKind.AmpersandToken */; + case 40 /* CharacterCodes.openParen */: pos++; - return token = 20 /* OpenParenToken */; - case 41 /* closeParen */: + return token = 20 /* SyntaxKind.OpenParenToken */; + case 41 /* CharacterCodes.closeParen */: pos++; - return token = 21 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AsteriskEqualsToken */; + return token = 21 /* SyntaxKind.CloseParenToken */; + case 42 /* CharacterCodes.asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 66 /* SyntaxKind.AsteriskEqualsToken */; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 42 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* SyntaxKind.AsteriskAsteriskToken */; } pos++; - if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { + if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */)) { // decoration at the start of a JSDoc comment line asteriskSeen = true; continue; } - return token = 41 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 45 /* PlusPlusToken */; + return token = 41 /* SyntaxKind.AsteriskToken */; + case 43 /* CharacterCodes.plus */: + if (text.charCodeAt(pos + 1) === 43 /* CharacterCodes.plus */) { + return pos += 2, token = 45 /* SyntaxKind.PlusPlusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PlusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 64 /* SyntaxKind.PlusEqualsToken */; } pos++; - return token = 39 /* PlusToken */; - case 44 /* comma */: + return token = 39 /* SyntaxKind.PlusToken */; + case 44 /* CharacterCodes.comma */: pos++; - return token = 27 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 46 /* MinusMinusToken */; + return token = 27 /* SyntaxKind.CommaToken */; + case 45 /* CharacterCodes.minus */: + if (text.charCodeAt(pos + 1) === 45 /* CharacterCodes.minus */) { + return pos += 2, token = 46 /* SyntaxKind.MinusMinusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* MinusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 65 /* SyntaxKind.MinusEqualsToken */; } pos++; - return token = 40 /* MinusToken */; - case 46 /* dot */: + return token = 40 /* SyntaxKind.MinusToken */; + case 46 /* CharacterCodes.dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; - return token = 8 /* NumericLiteral */; + return token = 8 /* SyntaxKind.NumericLiteral */; } - if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 25 /* DotDotDotToken */; + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && text.charCodeAt(pos + 2) === 46 /* CharacterCodes.dot */) { + return pos += 3, token = 25 /* SyntaxKind.DotDotDotToken */; } pos++; - return token = 24 /* DotToken */; - case 47 /* slash */: + return token = 24 /* SyntaxKind.DotToken */; + case 47 /* CharacterCodes.slash */: // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < end) { if (isLineBreak(text.charCodeAt(pos))) { @@ -11669,20 +11785,20 @@ var ts; continue; } else { - return token = 2 /* SingleLineCommentTrivia */; + return token = 2 /* SyntaxKind.SingleLineCommentTrivia */; } } // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) { - tokenFlags |= 2 /* PrecedingJSDocComment */; + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) !== 47 /* CharacterCodes.slash */) { + tokenFlags |= 2 /* TokenFlags.PrecedingJSDocComment */; } var commentClosed = false; var lastLineStart = tokenPos; while (pos < end) { var ch_1 = text.charCodeAt(pos); - if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (ch_1 === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; commentClosed = true; break; @@ -11690,7 +11806,7 @@ var ts; pos++; if (isLineBreak(ch_1)) { lastLineStart = pos; - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; } } commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart); @@ -11702,18 +11818,18 @@ var ts; } else { if (!commentClosed) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; } - return token = 3 /* MultiLineCommentTrivia */; + return token = 3 /* SyntaxKind.MultiLineCommentTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* SlashEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 68 /* SyntaxKind.SlashEqualsToken */; } pos++; - return token = 43 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + return token = 43 /* SyntaxKind.SlashToken */; + case 48 /* CharacterCodes._0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* CharacterCodes.X */ || text.charCodeAt(pos + 1) === 120 /* CharacterCodes.x */)) { pos += 2; tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); if (!tokenValue) { @@ -11721,10 +11837,10 @@ var ts; tokenValue = "0"; } tokenValue = "0x" + tokenValue; - tokenFlags |= 64 /* HexSpecifier */; + tokenFlags |= 64 /* TokenFlags.HexSpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* CharacterCodes.B */ || text.charCodeAt(pos + 1) === 98 /* CharacterCodes.b */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 2); if (!tokenValue) { @@ -11732,10 +11848,10 @@ var ts; tokenValue = "0"; } tokenValue = "0b" + tokenValue; - tokenFlags |= 128 /* BinarySpecifier */; + tokenFlags |= 128 /* TokenFlags.BinarySpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* CharacterCodes.O */ || text.charCodeAt(pos + 1) === 111 /* CharacterCodes.o */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 8); if (!tokenValue) { @@ -11743,175 +11859,175 @@ var ts; tokenValue = "0"; } tokenValue = "0o" + tokenValue; - tokenFlags |= 256 /* OctalSpecifier */; + tokenFlags |= 256 /* TokenFlags.OctalSpecifier */; return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - tokenFlags |= 32 /* Octal */; - return token = 8 /* NumericLiteral */; + tokenFlags |= 32 /* TokenFlags.Octal */; + return token = 8 /* SyntaxKind.NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). // falls through - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: + case 49 /* CharacterCodes._1 */: + case 50 /* CharacterCodes._2 */: + case 51 /* CharacterCodes._3 */: + case 52 /* CharacterCodes._4 */: + case 53 /* CharacterCodes._5 */: + case 54 /* CharacterCodes._6 */: + case 55 /* CharacterCodes._7 */: + case 56 /* CharacterCodes._8 */: + case 57 /* CharacterCodes._9 */: (_a = scanNumber(), token = _a.type, tokenValue = _a.value); return token; - case 58 /* colon */: + case 58 /* CharacterCodes.colon */: pos++; - return token = 58 /* ColonToken */; - case 59 /* semicolon */: + return token = 58 /* SyntaxKind.ColonToken */; + case 59 /* CharacterCodes.semicolon */: pos++; - return token = 26 /* SemicolonToken */; - case 60 /* lessThan */: + return token = 26 /* SyntaxKind.SemicolonToken */; + case 60 /* CharacterCodes.lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 70 /* SyntaxKind.LessThanLessThanEqualsToken */; } - return pos += 2, token = 47 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* SyntaxKind.LessThanLessThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 32 /* LessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 32 /* SyntaxKind.LessThanEqualsToken */; } - if (languageVariant === 1 /* JSX */ && - text.charCodeAt(pos + 1) === 47 /* slash */ && - text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 30 /* LessThanSlashToken */; + if (languageVariant === 1 /* LanguageVariant.JSX */ && + text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */ && + text.charCodeAt(pos + 2) !== 42 /* CharacterCodes.asterisk */) { + return pos += 2, token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; - case 61 /* equals */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 61 /* CharacterCodes.equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 36 /* SyntaxKind.EqualsEqualsEqualsToken */; } - return pos += 2, token = 34 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* SyntaxKind.EqualsEqualsToken */; } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 38 /* EqualsGreaterThanToken */; + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + return pos += 2, token = 38 /* SyntaxKind.EqualsGreaterThanToken */; } pos++; - return token = 63 /* EqualsToken */; - case 62 /* greaterThan */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } pos++; - return token = 31 /* GreaterThanToken */; - case 63 /* question */: - if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) { - return pos += 2, token = 28 /* QuestionDotToken */; + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 63 /* CharacterCodes.question */: + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && !isDigit(text.charCodeAt(pos + 2))) { + return pos += 2, token = 28 /* SyntaxKind.QuestionDotToken */; } - if (text.charCodeAt(pos + 1) === 63 /* question */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; + if (text.charCodeAt(pos + 1) === 63 /* CharacterCodes.question */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } - return pos += 2, token = 60 /* QuestionQuestionToken */; + return pos += 2, token = 60 /* SyntaxKind.QuestionQuestionToken */; } pos++; - return token = 57 /* QuestionToken */; - case 91 /* openBracket */: + return token = 57 /* SyntaxKind.QuestionToken */; + case 91 /* CharacterCodes.openBracket */: pos++; - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: pos++; - return token = 23 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 78 /* CaretEqualsToken */; + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 94 /* CharacterCodes.caret */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 78 /* SyntaxKind.CaretEqualsToken */; } pos++; - return token = 52 /* CaretToken */; - case 123 /* openBrace */: + return token = 52 /* SyntaxKind.CaretToken */; + case 123 /* CharacterCodes.openBrace */: pos++; - return token = 18 /* OpenBraceToken */; - case 124 /* bar */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 124 /* CharacterCodes.bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 75 /* BarBarEqualsToken */; + if (text.charCodeAt(pos + 1) === 124 /* CharacterCodes.bar */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 75 /* SyntaxKind.BarBarEqualsToken */; } - return pos += 2, token = 56 /* BarBarToken */; + return pos += 2, token = 56 /* SyntaxKind.BarBarToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 74 /* BarEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 74 /* SyntaxKind.BarEqualsToken */; } pos++; - return token = 51 /* BarToken */; - case 125 /* closeBrace */: + return token = 51 /* SyntaxKind.BarToken */; + case 125 /* CharacterCodes.closeBrace */: pos++; - return token = 19 /* CloseBraceToken */; - case 126 /* tilde */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 126 /* CharacterCodes.tilde */: pos++; - return token = 54 /* TildeToken */; - case 64 /* at */: + return token = 54 /* SyntaxKind.TildeToken */; + case 64 /* CharacterCodes.at */: pos++; - return token = 59 /* AtToken */; - case 92 /* backslash */: + return token = 59 /* SyntaxKind.AtToken */; + case 92 /* CharacterCodes.backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } error(ts.Diagnostics.Invalid_character); pos++; - return token = 0 /* Unknown */; - case 35 /* hash */: + return token = 0 /* SyntaxKind.Unknown */; + case 35 /* CharacterCodes.hash */: if (pos !== 0 && text[pos + 1] === "!") { error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file); pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; @@ -11921,7 +12037,7 @@ var ts; tokenValue = String.fromCharCode(codePointAt(text, pos)); error(ts.Diagnostics.Invalid_character, pos++, charSize(ch)); } - return token = 80 /* PrivateIdentifier */; + return token = 80 /* SyntaxKind.PrivateIdentifier */; default: var identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { @@ -11932,23 +12048,23 @@ var ts; continue; } else if (isLineBreak(ch)) { - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; pos += charSize(ch); continue; } var size = charSize(ch); error(ts.Diagnostics.Invalid_character, pos, size); pos += size; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } } function reScanInvalidIdentifier() { - ts.Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); + ts.Debug.assert(token === 0 /* SyntaxKind.Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); pos = tokenPos = startPos; tokenFlags = 0; var ch = codePointAt(text, pos); - var identifierKind = scanIdentifier(ch, 99 /* ESNext */); + var identifierKind = scanIdentifier(ch, 99 /* ScriptTarget.ESNext */); if (identifierKind) { return token = identifierKind; } @@ -11962,41 +12078,41 @@ var ts; while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { + if (ch === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return getIdentifierToken(); } } function reScanGreaterToken() { - if (token === 31 /* GreaterThanToken */) { - if (text.charCodeAt(pos) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + if (text.charCodeAt(pos) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 48 /* GreaterThanGreaterThanToken */; + return token = 48 /* SyntaxKind.GreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos) === 61 /* equals */) { + if (text.charCodeAt(pos) === 61 /* CharacterCodes.equals */) { pos++; - return token = 33 /* GreaterThanEqualsToken */; + return token = 33 /* SyntaxKind.GreaterThanEqualsToken */; } } return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* SyntaxKind.AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 63 /* EqualsToken */; + return token = 63 /* SyntaxKind.EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { + if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -12004,13 +12120,13 @@ var ts; // If we reach the end of a file, or hit a newline, then this is an unterminated // regex. Report error and return what we have so far. if (p >= end) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -12019,19 +12135,19 @@ var ts; // reset the flag and just advance to the next char. inEscape = false; } - else if (ch === 47 /* slash */ && !inCharacterClass) { + else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) { // A slash within a character class is permissible, // but in general it signals the end of the regexp literal. p++; break; } - else if (ch === 91 /* openBracket */) { + else if (ch === 91 /* CharacterCodes.openBracket */) { inCharacterClass = true; } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { inEscape = true; } - else if (ch === 93 /* closeBracket */) { + else if (ch === 93 /* CharacterCodes.closeBracket */) { inCharacterClass = false; } p++; @@ -12041,7 +12157,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 13 /* RegularExpressionLiteral */; + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } return token; } @@ -12062,9 +12178,9 @@ var ts; } switch (match[1]) { case "ts-expect-error": - return 0 /* ExpectError */; + return 0 /* CommentDirectiveType.ExpectError */; case "ts-ignore": - return 1 /* Ignore */; + return 1 /* CommentDirectiveType.Ignore */; } return undefined; } @@ -12072,7 +12188,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken(isTaggedTemplate) { - ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* SyntaxKind.CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(isTaggedTemplate); } @@ -12086,42 +12202,42 @@ var ts; return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { - if (token === 47 /* LessThanLessThanToken */) { + if (token === 47 /* SyntaxKind.LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } return token; } function reScanHashToken() { - if (token === 80 /* PrivateIdentifier */) { + if (token === 80 /* SyntaxKind.PrivateIdentifier */) { pos = tokenPos + 1; - return token = 62 /* HashToken */; + return token = 62 /* SyntaxKind.HashToken */; } return token; } function reScanQuestionToken() { - ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + ts.Debug.assert(token === 60 /* SyntaxKind.QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; - return token = 57 /* QuestionToken */; + return token = 57 /* SyntaxKind.QuestionToken */; } function scanJsxToken(allowMultilineJsxText) { if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (char === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; - return token = 30 /* LessThanSlashToken */; + return token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { pos++; - return token = 18 /* OpenBraceToken */; + return token = 18 /* SyntaxKind.OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -12129,20 +12245,20 @@ var ts; // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { break; } - if (char === 60 /* lessThan */) { + if (char === 60 /* CharacterCodes.lessThan */) { if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } break; } - if (char === 62 /* greaterThan */) { + if (char === 62 /* CharacterCodes.greaterThan */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1); } - if (char === 125 /* closeBrace */) { + if (char === 125 /* CharacterCodes.closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. @@ -12165,7 +12281,7 @@ var ts; pos++; } tokenValue = text.substring(startPos, pos); - return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* SyntaxKind.JsxTextAllWhiteSpaces */ : 11 /* SyntaxKind.JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -12178,16 +12294,16 @@ var ts; var namespaceSeparator = false; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */) { + if (ch === 45 /* CharacterCodes.minus */) { tokenValue += "-"; pos++; continue; } - else if (ch === 58 /* colon */ && !namespaceSeparator) { + else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) { tokenValue += ":"; pos++; namespaceSeparator = true; - token = 79 /* Identifier */; // swap from keyword kind to identifier kind + token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -12208,10 +12324,10 @@ var ts; function scanJsxAttributeValue() { startPos = pos; switch (text.charCodeAt(pos)) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 10 /* StringLiteral */; + return token = 10 /* SyntaxKind.StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -12223,86 +12339,86 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); pos += charSize(ch); switch (ch) { - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; - case 64 /* at */: - return token = 59 /* AtToken */; - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + return token = 5 /* SyntaxKind.WhitespaceTrivia */; + case 64 /* CharacterCodes.at */: + return token = 59 /* SyntaxKind.AtToken */; + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - tokenFlags |= 1 /* PrecedingLineBreak */; - return token = 4 /* NewLineTrivia */; - case 42 /* asterisk */: - return token = 41 /* AsteriskToken */; - case 123 /* openBrace */: - return token = 18 /* OpenBraceToken */; - case 125 /* closeBrace */: - return token = 19 /* CloseBraceToken */; - case 91 /* openBracket */: - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: - return token = 23 /* CloseBracketToken */; - case 60 /* lessThan */: - return token = 29 /* LessThanToken */; - case 62 /* greaterThan */: - return token = 31 /* GreaterThanToken */; - case 61 /* equals */: - return token = 63 /* EqualsToken */; - case 44 /* comma */: - return token = 27 /* CommaToken */; - case 46 /* dot */: - return token = 24 /* DotToken */; - case 96 /* backtick */: - return token = 61 /* BacktickToken */; - case 35 /* hash */: - return token = 62 /* HashToken */; - case 92 /* backslash */: + case 10 /* CharacterCodes.lineFeed */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; + return token = 4 /* SyntaxKind.NewLineTrivia */; + case 42 /* CharacterCodes.asterisk */: + return token = 41 /* SyntaxKind.AsteriskToken */; + case 123 /* CharacterCodes.openBrace */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 125 /* CharacterCodes.closeBrace */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 91 /* CharacterCodes.openBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 60 /* CharacterCodes.lessThan */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 62 /* CharacterCodes.greaterThan */: + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 61 /* CharacterCodes.equals */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 44 /* CharacterCodes.comma */: + return token = 27 /* SyntaxKind.CommaToken */; + case 46 /* CharacterCodes.dot */: + return token = 24 /* SyntaxKind.DotToken */; + case 96 /* CharacterCodes.backtick */: + return token = 61 /* SyntaxKind.BacktickToken */; + case 35 /* CharacterCodes.hash */: + return token = 62 /* SyntaxKind.HashToken */; + case 92 /* CharacterCodes.backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); - if (char === 92 /* backslash */) { + if (char === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return token = getIdentifierToken(); } else { - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } function speculationHelper(callback, isLookahead) { @@ -12377,9 +12493,9 @@ var ts; pos = textPos; startPos = textPos; tokenPos = textPos; - token = 0 /* Unknown */; + token = 0 /* SyntaxKind.Unknown */; tokenValue = undefined; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -12445,23 +12561,23 @@ var ts; ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; function getDefaultLibFileName(options) { switch (ts.getEmitScriptTarget(options)) { - case 99 /* ESNext */: + case 99 /* ScriptTarget.ESNext */: return "lib.esnext.full.d.ts"; - case 9 /* ES2022 */: + case 9 /* ScriptTarget.ES2022 */: return "lib.es2022.full.d.ts"; - case 8 /* ES2021 */: + case 8 /* ScriptTarget.ES2021 */: return "lib.es2021.full.d.ts"; - case 7 /* ES2020 */: + case 7 /* ScriptTarget.ES2020 */: return "lib.es2020.full.d.ts"; - case 6 /* ES2019 */: + case 6 /* ScriptTarget.ES2019 */: return "lib.es2019.full.d.ts"; - case 5 /* ES2018 */: + case 5 /* ScriptTarget.ES2018 */: return "lib.es2018.full.d.ts"; - case 4 /* ES2017 */: + case 4 /* ScriptTarget.ES2017 */: return "lib.es2017.full.d.ts"; - case 3 /* ES2016 */: + case 3 /* ScriptTarget.ES2016 */: return "lib.es2016.full.d.ts"; - case 2 /* ES2015 */: + case 2 /* ScriptTarget.ES2015 */: return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; @@ -12669,9 +12785,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 163 /* TypeParameter */) { + if (d && d.kind === 163 /* SyntaxKind.TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return current; } } @@ -12679,7 +12795,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 171 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) && parent.kind === 171 /* SyntaxKind.Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12709,14 +12825,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 254 /* VariableDeclaration */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 255 /* VariableDeclarationList */) { + if (node && node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 237 /* VariableStatement */) { + if (node && node.kind === 237 /* SyntaxKind.VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12830,7 +12946,7 @@ var ts; * @param node The node to test. */ function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + return (node.flags & 8 /* NodeFlags.Synthesized */) === 0; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { @@ -12848,7 +12964,7 @@ var ts; ts.getParseTreeNode = getParseTreeNode; /** Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' */ function escapeLeadingUnderscores(identifier) { - return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); + return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* CharacterCodes._ */ && identifier.charCodeAt(1) === 95 /* CharacterCodes._ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; /** @@ -12859,7 +12975,7 @@ var ts; */ function unescapeLeadingUnderscores(identifier) { var id = identifier; - return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id; + return id.length >= 3 && id.charCodeAt(0) === 95 /* CharacterCodes._ */ && id.charCodeAt(1) === 95 /* CharacterCodes._ */ && id.charCodeAt(2) === 95 /* CharacterCodes._ */ ? id.substr(1) : id; } ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores; function idText(identifierOrPrivateName) { @@ -12889,30 +13005,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 221 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { + if (expr.kind === 221 /* SyntaxKind.BinaryExpression */ && expr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return expr.name; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12947,42 +13063,42 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return declaration; - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: { + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 161 /* QualifiedName */) { + if (name.kind === 161 /* SyntaxKind.QualifiedName */) { return name.right; } break; } - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { - case 1 /* ExportsProperty */: - case 4 /* ThisProperty */: - case 5 /* Property */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return expr_1.arguments[1]; default: return undefined; } } - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 339 /* JSDocEnumTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -13026,7 +13142,7 @@ var ts; } ts.getDecorators = getDecorators; function getModifiers(node) { - if (ts.hasSyntacticModifier(node, 125951 /* Modifier */)) { + if (ts.hasSyntacticModifier(node, 125951 /* ModifierFlags.Modifier */)) { return ts.filter(node.modifiers, isModifier); } } @@ -13287,27 +13403,33 @@ var ts; /** Gets the text of a jsdoc comment, flattening links to their text. */ function getTextOfJSDocComment(comment) { return typeof comment === "string" ? comment - : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* SyntaxKind.JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; function formatJSDocLink(link) { - var kind = link.kind === 324 /* JSDocLink */ ? "link" - : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" + var kind = link.kind === 324 /* SyntaxKind.JSDocLink */ ? "link" + : link.kind === 325 /* SyntaxKind.JSDocLinkCode */ ? "linkcode" : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. + * + * This does *not* return type parameters from a jsdoc reference to a generic type, eg + * + * type Id = (x: T) => T + * /** @type {Id} / + * function id(x) { return x } */ function getEffectiveTypeParameterDeclarations(node) { if (ts.isJSDocSignature(node)) { return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 320 /* JSDoc */); + ts.Debug.assert(node.parent.kind === 320 /* SyntaxKind.JSDoc */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13337,33 +13459,33 @@ var ts; ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region function isMemberName(node) { - return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; + return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */ || node.kind === 172 /* GetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */ || node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { - return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessChain(node) { - return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isElementAccessChain = isElementAccessChain; function isCallChain(node) { - return ts.isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isCallExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isCallChain = isCallChain; function isOptionalChain(node) { var kind = node.kind; - return !!(node.flags & 32 /* OptionalChain */) && - (kind === 206 /* PropertyAccessExpression */ - || kind === 207 /* ElementAccessExpression */ - || kind === 208 /* CallExpression */ - || kind === 230 /* NonNullExpression */); + return !!(node.flags & 32 /* NodeFlags.OptionalChain */) && + (kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 207 /* SyntaxKind.ElementAccessExpression */ + || kind === 208 /* SyntaxKind.CallExpression */ + || kind === 230 /* SyntaxKind.NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -13398,7 +13520,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -13407,25 +13529,25 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function skipPartiallyEmittedExpressions(node) { - return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */); + return ts.skipOuterExpressions(node, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isNonNullChain(node) { - return ts.isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isNonNullExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 246 /* BreakStatement */ || node.kind === 245 /* ContinueStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */ || node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 274 /* NamespaceExport */ || node.kind === 273 /* NamedExports */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return true; default: return false; @@ -13434,12 +13556,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 300 /* UnparsedPrologue */ || - node.kind === 304 /* UnparsedSyntheticReference */; + node.kind === 300 /* SyntaxKind.UnparsedPrologue */ || + node.kind === 304 /* SyntaxKind.UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 347 /* JSDocPropertyTag */ || node.kind === 340 /* JSDocParameterTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */ || node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -13455,7 +13577,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 161 /* FirstNode */; + return kind >= 161 /* SyntaxKind.FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13464,7 +13586,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 160 /* LastToken */; + return kind >= 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -13485,7 +13607,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; + return 8 /* SyntaxKind.FirstLiteralToken */ <= kind && kind <= 14 /* SyntaxKind.LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13495,11 +13617,11 @@ var ts; /** @internal */ function isLiteralExpressionOfObject(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 13 /* RegularExpressionLiteral */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; } return false; @@ -13508,7 +13630,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; + return 14 /* SyntaxKind.FirstTemplateToken */ <= kind && kind <= 17 /* SyntaxKind.LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13517,8 +13639,8 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 16 /* TemplateMiddle */ - || kind === 17 /* TemplateTail */; + return kind === 16 /* SyntaxKind.TemplateMiddle */ + || kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isImportOrExportSpecifier(node) { @@ -13527,13 +13649,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.isTypeOnly || node.parent.parent.isTypeOnly; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.isTypeOnly; - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -13545,13 +13667,13 @@ var ts; } ts.isAssertionKey = isAssertionKey; function isStringTextContainingNode(node) { - return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* SyntaxKind.StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; + return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) > 0 /* GeneratedIdentifierFlags.None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers @@ -13569,20 +13691,20 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 88 /* DefaultKeyword */: - case 93 /* ExportKeyword */: - case 101 /* InKeyword */: - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 124 /* StaticKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; } return false; @@ -13590,12 +13712,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ModifierFlags.ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 159 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* SyntaxKind.StaticKeyword */ || idToken === 159 /* SyntaxKind.OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13604,24 +13726,24 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 80 /* PrivateIdentifier */ - || kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 162 /* ComputedPropertyName */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 80 /* SyntaxKind.PrivateIdentifier */ + || kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */ + || kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 201 /* ObjectBindingPattern */ - || kind === 202 /* ArrayBindingPattern */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */ + || kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13641,18 +13763,18 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; /* @internal */ function isBooleanLiteral(node) { - return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */; + return node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */; } ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -13661,14 +13783,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 180 /* ConstructorType */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13683,30 +13805,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 234 /* SemicolonClassElement */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */); + return node && (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */); + return node && (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -13720,13 +13842,13 @@ var ts; ts.isModifierLike = isModifierLike; function isTypeElement(node) { var kind = node.kind; - return kind === 175 /* ConstructSignature */ - || kind === 174 /* CallSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */ - || kind === 176 /* IndexSignature */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 174 /* SyntaxKind.CallSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13735,12 +13857,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 298 /* SpreadAssignment */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 298 /* SyntaxKind.SpreadAssignment */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13755,8 +13877,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; } return false; @@ -13767,8 +13889,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 202 /* ArrayBindingPattern */ - || kind === 201 /* ObjectBindingPattern */; + return kind === 202 /* SyntaxKind.ArrayBindingPattern */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */; } return false; } @@ -13776,15 +13898,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 204 /* ArrayLiteralExpression */ - || kind === 205 /* ObjectLiteralExpression */; + return kind === 204 /* SyntaxKind.ArrayLiteralExpression */ + || kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 203 /* BindingElement */ - || kind === 227 /* OmittedExpression */; + return kind === 203 /* SyntaxKind.BindingElement */ + || kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13793,9 +13915,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: return true; } return false; @@ -13816,8 +13938,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return true; } return false; @@ -13826,10 +13948,10 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentElement(node) { switch (node.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: // AssignmentProperty - case 297 /* ShorthandPropertyAssignment */: // AssignmentProperty - case 298 /* SpreadAssignment */: // AssignmentRestProperty + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: // AssignmentProperty + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // AssignmentProperty + case 298 /* SyntaxKind.SpreadAssignment */: // AssignmentRestProperty return true; } return false; @@ -13841,8 +13963,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; } return false; @@ -13851,26 +13973,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */ - || kind === 200 /* ImportType */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 200 /* SyntaxKind.ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: return true; default: return false; @@ -13878,13 +14000,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 208 /* CallExpression */ || node.kind === 209 /* NewExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */ || node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 223 /* TemplateExpression */ - || kind === 14 /* NoSubstitutionTemplateLiteral */; + return kind === 223 /* SyntaxKind.TemplateExpression */ + || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13894,36 +14016,36 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 209 /* NewExpression */: - case 208 /* CallExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 210 /* TaggedTemplateExpression */: - case 204 /* ArrayLiteralExpression */: - case 212 /* ParenthesizedExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression - case 13 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 110 /* TrueKeyword */: - case 106 /* SuperKeyword */: - case 230 /* NonNullExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 231 /* MetaProperty */: - case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 230 /* SyntaxKind.NonNullExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 231 /* SyntaxKind.MetaProperty */: + case 100 /* SyntaxKind.ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13936,13 +14058,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 218 /* AwaitExpression */: - case 211 /* TypeAssertionExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13951,11 +14073,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 45 /* PlusPlusToken */ || - expr.operator === 46 /* MinusMinusToken */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || + expr.operator === 46 /* SyntaxKind.MinusMinusToken */; default: return false; } @@ -13972,15 +14094,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - case 214 /* ArrowFunction */: - case 221 /* BinaryExpression */: - case 225 /* SpreadElement */: - case 229 /* AsExpression */: - case 227 /* OmittedExpression */: - case 351 /* CommaListExpression */: - case 350 /* PartiallyEmittedExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 221 /* SyntaxKind.BinaryExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 229 /* SyntaxKind.AsExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13988,8 +14110,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 211 /* TypeAssertionExpression */ - || kind === 229 /* AsExpression */; + return kind === 211 /* SyntaxKind.TypeAssertionExpression */ + || kind === 229 /* SyntaxKind.AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -14000,13 +14122,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -14024,18 +14146,18 @@ var ts; ts.hasScopeMarker = hasScopeMarker; /* @internal */ function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */) && !ts.isAmbientModule(result); } ts.needsScopeMarker = needsScopeMarker; /* @internal */ function isExternalModuleIndicator(result) { // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* Export */); + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */); } ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 243 /* ForInStatement */ || node.kind === 244 /* ForOfStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */ || node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -14059,115 +14181,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */ - || kind === 79 /* Identifier */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 261 /* ModuleDeclaration */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 269 /* NamedImports */ - || kind === 268 /* NamespaceImport */; + return kind === 269 /* SyntaxKind.NamedImports */ + || kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ || node.kind === 260 /* EnumDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 214 /* ArrowFunction */ - || kind === 203 /* BindingElement */ - || kind === 257 /* ClassDeclaration */ - || kind === 226 /* ClassExpression */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 171 /* Constructor */ - || kind === 260 /* EnumDeclaration */ - || kind === 299 /* EnumMember */ - || kind === 275 /* ExportSpecifier */ - || kind === 256 /* FunctionDeclaration */ - || kind === 213 /* FunctionExpression */ - || kind === 172 /* GetAccessor */ - || kind === 267 /* ImportClause */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 270 /* ImportSpecifier */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 285 /* JsxAttribute */ - || kind === 169 /* MethodDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 261 /* ModuleDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 268 /* NamespaceImport */ - || kind === 274 /* NamespaceExport */ - || kind === 164 /* Parameter */ - || kind === 296 /* PropertyAssignment */ - || kind === 167 /* PropertyDeclaration */ - || kind === 166 /* PropertySignature */ - || kind === 173 /* SetAccessor */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 163 /* TypeParameter */ - || kind === 254 /* VariableDeclaration */ - || kind === 345 /* JSDocTypedefTag */ - || kind === 338 /* JSDocCallbackTag */ - || kind === 347 /* JSDocPropertyTag */; + return kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 203 /* SyntaxKind.BindingElement */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 299 /* SyntaxKind.EnumMember */ + || kind === 275 /* SyntaxKind.ExportSpecifier */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 267 /* SyntaxKind.ImportClause */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 270 /* SyntaxKind.ImportSpecifier */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 268 /* SyntaxKind.NamespaceImport */ + || kind === 274 /* SyntaxKind.NamespaceExport */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 254 /* SyntaxKind.VariableDeclaration */ + || kind === 345 /* SyntaxKind.JSDocTypedefTag */ + || kind === 338 /* SyntaxKind.JSDocCallbackTag */ + || kind === 347 /* SyntaxKind.JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 246 /* BreakStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 240 /* DoStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 236 /* EmptyStatement */ - || kind === 243 /* ForInStatement */ - || kind === 244 /* ForOfStatement */ - || kind === 242 /* ForStatement */ - || kind === 239 /* IfStatement */ - || kind === 250 /* LabeledStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 249 /* SwitchStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 252 /* TryStatement */ - || kind === 237 /* VariableStatement */ - || kind === 241 /* WhileStatement */ - || kind === 248 /* WithStatement */ - || kind === 349 /* NotEmittedStatement */ - || kind === 353 /* EndOfDeclarationMarker */ - || kind === 352 /* MergeDeclarationMarker */; + return kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 236 /* SyntaxKind.EmptyStatement */ + || kind === 243 /* SyntaxKind.ForInStatement */ + || kind === 244 /* SyntaxKind.ForOfStatement */ + || kind === 242 /* SyntaxKind.ForStatement */ + || kind === 239 /* SyntaxKind.IfStatement */ + || kind === 250 /* SyntaxKind.LabeledStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 249 /* SyntaxKind.SwitchStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 252 /* SyntaxKind.TryStatement */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 241 /* SyntaxKind.WhileStatement */ + || kind === 248 /* SyntaxKind.WithStatement */ + || kind === 349 /* SyntaxKind.NotEmittedStatement */ + || kind === 353 /* SyntaxKind.EndOfDeclarationMarker */ + || kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 163 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 344 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { + return (node.parent && node.parent.kind !== 344 /* SyntaxKind.JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -14194,10 +14316,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 235 /* Block */) + if (node.kind !== 235 /* SyntaxKind.Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 252 /* TryStatement */ || node.parent.kind === 292 /* CatchClause */) { + if (node.parent.kind === 252 /* SyntaxKind.TryStatement */ || node.parent.kind === 292 /* SyntaxKind.CatchClause */) { return false; } } @@ -14211,76 +14333,76 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 235 /* Block */; + || kind === 235 /* SyntaxKind.Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 277 /* ExternalModuleReference */ - || kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 277 /* SyntaxKind.ExternalModuleReference */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 108 /* ThisKeyword */ - || kind === 79 /* Identifier */ - || kind === 206 /* PropertyAccessExpression */; + return kind === 108 /* SyntaxKind.ThisKeyword */ + || kind === 79 /* SyntaxKind.Identifier */ + || kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 278 /* JsxElement */ - || kind === 288 /* JsxExpression */ - || kind === 279 /* JsxSelfClosingElement */ - || kind === 11 /* JsxText */ - || kind === 282 /* JsxFragment */; + return kind === 278 /* SyntaxKind.JsxElement */ + || kind === 288 /* SyntaxKind.JsxExpression */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */ + || kind === 11 /* SyntaxKind.JsxText */ + || kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 285 /* JsxAttribute */ - || kind === 287 /* JsxSpreadAttribute */; + return kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 288 /* JsxExpression */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 288 /* SyntaxKind.JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 280 /* JsxOpeningElement */ - || kind === 279 /* JsxSelfClosingElement */; + return kind === 280 /* SyntaxKind.JsxOpeningElement */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 289 /* CaseClause */ - || kind === 290 /* DefaultClause */; + return kind === 289 /* SyntaxKind.CaseClause */ + || kind === 290 /* SyntaxKind.DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 309 /* FirstJSDocNode */ && node.kind <= 347 /* LastJSDocNode */; + return node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 320 /* JSDoc */ - || node.kind === 319 /* JSDocNamepathType */ - || node.kind === 321 /* JSDocText */ + return node.kind === 320 /* SyntaxKind.JSDoc */ + || node.kind === 319 /* SyntaxKind.JSDocNamepathType */ + || node.kind === 321 /* SyntaxKind.JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) @@ -14290,15 +14412,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 327 /* FirstJSDocTagNode */ && node.kind <= 347 /* LastJSDocTagNode */; + return node.kind >= 327 /* SyntaxKind.FirstJSDocTagNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14324,12 +14446,12 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: return true; default: return false; @@ -14337,12 +14459,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 285 /* JsxAttribute */ || node.kind === 287 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 285 /* SyntaxKind.JsxAttribute */ || node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 178 /* TypeReference */ || node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14371,11 +14493,11 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */ || node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; function isJSDocLinkLike(node) { - return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 324 /* SyntaxKind.JSDocLink */ || node.kind === 325 /* SyntaxKind.JSDocLinkCode */ || node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkLike = isJSDocLinkLike; function hasRestParameter(s) { @@ -14385,7 +14507,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isRestParameter = isRestParameter; // #endregion @@ -14426,7 +14548,7 @@ var ts; } ts.createSymbolTable = createSymbolTable; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } ts.isTransientSymbol = isTransientSymbol; var stringWriter = createSingleLineStringWriter(); @@ -14587,11 +14709,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -14622,28 +14744,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 1048576 /* HasAggregatedChildData */)) { + if (!(node.flags & 1048576 /* NodeFlags.HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* NodeFlags.ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 1048576 /* HasAggregatedChildData */; + node.flags |= 1048576 /* NodeFlags.HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 305 /* SourceFile */) { + while (node && node.kind !== 305 /* SyntaxKind.SourceFile */) { node = node.parent; } return node; @@ -14654,16 +14776,16 @@ var ts; } ts.getSourceFileOfModule = getSourceFileOfModule; function isPlainJsFile(file, checkJs) { - return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined; + return !!file && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */) && !file.checkJsDirective && checkJs === undefined; } ts.isPlainJsFile = isPlainJsFile; function isStatementWithLocals(node) { switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return true; } return false; @@ -14678,7 +14800,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -14731,7 +14853,7 @@ var ts; if (node === undefined) { return true; } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -14765,7 +14887,7 @@ var ts; return to; } function isAnyPrologueDirective(node) { - return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } /** * Prepends statements to an array while taking care of prologue directives. @@ -14797,9 +14919,9 @@ var ts; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments - if (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + if (text.charCodeAt(commentPos + 1) === 47 /* CharacterCodes.slash */ && commentPos + 2 < commentEnd && - text.charCodeAt(commentPos + 2) === 47 /* slash */) { + text.charCodeAt(commentPos + 2) === 47 /* CharacterCodes.slash */) { var textSubStr = text.substring(commentPos, commentEnd); return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || @@ -14811,13 +14933,13 @@ var ts; } ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; function isPinnedComment(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 33 /* exclamation */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 33 /* CharacterCodes.exclamation */; } ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -14826,7 +14948,7 @@ var ts; return ts.arrayFrom(directivesByLine.entries()) .filter(function (_a) { var line = _a[0], directive = _a[1]; - return directive.type === 0 /* ExpectError */ && !usedLines.get(line); + return directive.type === 0 /* CommentDirectiveType.ExpectError */ && !usedLines.get(line); }) .map(function (_a) { var _ = _a[0], directive = _a[1]; @@ -14834,10 +14956,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -14848,7 +14970,7 @@ var ts; if (nodeIsMissing(node)) { return node.pos; } - if (ts.isJSDocNode(node) || node.kind === 11 /* JsxText */) { + if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) { // JsxText cannot actually contain comments, even though the scanner will think it sees comments return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } @@ -14859,7 +14981,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 348 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -15027,56 +15149,56 @@ var ts; // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { - case 10 /* StringLiteral */: { - var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : - flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + case 10 /* SyntaxKind.StringLiteral */: { + var escapeText = flags & 2 /* GetLiteralTextFlags.JsxAttributeEscape */ ? escapeJsxAttributeString : + flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; if (node.singleQuote) { - return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + return "'" + escapeText(node.text, 39 /* CharacterCodes.singleQuote */) + "'"; } else { - return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + return '"' + escapeText(node.text, 34 /* CharacterCodes.doubleQuote */) + '"'; } } - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: { // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. - var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; - var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* CharacterCodes.backtick */)); switch (node.kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return "`" + rawText + "${"; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: return "}" + rawText + "${"; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: return "}" + rawText + "`"; } break; } - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return node.text; - case 13 /* RegularExpressionLiteral */: - if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) { - return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/"); + case 13 /* SyntaxKind.RegularExpressionLiteral */: + if (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) { + return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* CharacterCodes.backslash */ ? " /" : "/"); } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { - if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated)) { + if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) { return false; } - if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) { - return !!(flags & 8 /* AllowNumericSeparator */); + if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) { + return !!(flags & 8 /* GetLiteralTextFlags.AllowNumericSeparator */); } return !ts.isBigIntLiteral(node); } @@ -15091,21 +15213,21 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || + return (ts.getCombinedNodeFlags(declaration) & 3 /* NodeFlags.BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* SyntaxKind.StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -15129,16 +15251,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return !!node && node.kind === 261 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 305 /* SourceFile */ || - node.kind === 261 /* ModuleDeclaration */ || + return node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 1024 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* NodeFlags.GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -15150,9 +15272,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return ts.isExternalModule(node.parent); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -15176,10 +15298,10 @@ var ts; function isEffectiveStrictModeSourceFile(node, compilerOptions) { // We can only verify strict mode for JS/TS files switch (node.scriptKind) { - case 1 /* JS */: - case 3 /* TS */: - case 2 /* JSX */: - case 4 /* TSX */: + case 1 /* ScriptKind.JS */: + case 3 /* ScriptKind.TS */: + case 2 /* ScriptKind.JSX */: + case 4 /* ScriptKind.TSX */: break; default: return false; @@ -15209,24 +15331,24 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 292 /* CatchClause */: - case 261 /* ModuleDeclaration */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 167 /* PropertyDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 292 /* SyntaxKind.CatchClause */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); @@ -15236,9 +15358,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 323 /* JSDocSignature */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 323 /* SyntaxKind.JSDocSignature */: return true; default: ts.assertType(node); @@ -15248,25 +15370,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: ts.assertType(node); @@ -15276,8 +15398,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -15290,15 +15412,15 @@ var ts; ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 237 /* VariableStatement */: - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return true; default: return false; @@ -15339,19 +15461,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 162 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function tryGetTextOfPropertyName(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return undefined; @@ -15366,21 +15488,21 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return "this"; - case 80 /* PrivateIdentifier */: - case 79 /* Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); @@ -15470,7 +15592,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 235 /* Block */) { + if (node.body && node.body.kind === 235 /* SyntaxKind.Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -15484,7 +15606,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -15493,29 +15615,29 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 268 /* NamespaceImport */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 268 /* SyntaxKind.NamespaceImport */: errorNode = node.name; break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -15547,36 +15669,36 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isJsonSourceFile(file) { - return file.scriptKind === 6 /* JSON */; + return file.scriptKind === 6 /* ScriptKind.JSON */; } ts.isJsonSourceFile = isJsonSourceFile; function isEnumConst(node) { - return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(ts.getCombinedModifierFlags(node) & 2048 /* ModifierFlags.Const */); } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* ModifierFlags.Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); + return !!(ts.getCombinedNodeFlags(node) & 2 /* NodeFlags.Const */); } ts.isVarConst = isVarConst; function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); + return !!(ts.getCombinedNodeFlags(node) & 1 /* NodeFlags.Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 100 /* ImportKeyword */ + && n.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -15585,12 +15707,12 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 238 /* ExpressionStatement */ - && node.expression.kind === 10 /* StringLiteral */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */ + && node.expression.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isCustomPrologue(node) { - return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } ts.isCustomPrologue = isCustomPrologue; function isHoistedFunction(node) { @@ -15609,24 +15731,24 @@ var ts; } ts.isHoistedVariableStatement = isHoistedVariableStatement; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* SyntaxKind.JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 164 /* Parameter */ || - node.kind === 163 /* TypeParameter */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 214 /* ArrowFunction */ || - node.kind === 212 /* ParenthesizedExpression */ || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 275 /* ExportSpecifier */) ? + var commentRanges = (node.kind === 164 /* SyntaxKind.Parameter */ || + node.kind === 163 /* SyntaxKind.TypeParameter */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 214 /* SyntaxKind.ArrowFunction */ || + node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + return text.charCodeAt(comment.pos + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; @@ -15635,48 +15757,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (177 /* FirstTypeNode */ <= node.kind && node.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= node.kind && node.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return true; - case 114 /* VoidKeyword */: - return node.parent.kind !== 217 /* VoidExpression */; - case 228 /* ExpressionWithTypeArguments */: + case 114 /* SyntaxKind.VoidKeyword */: + return node.parent.kind !== 217 /* SyntaxKind.VoidExpression */; + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 163 /* TypeParameter */: - return node.parent.kind === 195 /* MappedType */ || node.parent.kind === 190 /* InferType */; + case 163 /* SyntaxKind.TypeParameter */: + return node.parent.kind === 195 /* SyntaxKind.MappedType */ || node.parent.kind === 190 /* SyntaxKind.InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */ || node.kind === 206 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: - case 108 /* ThisKeyword */: { + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: { var parent = node.parent; - if (parent.kind === 181 /* TypeQuery */) { + if (parent.kind === 181 /* SyntaxKind.TypeQuery */) { return false; } - if (parent.kind === 200 /* ImportType */) { + if (parent.kind === 200 /* SyntaxKind.ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -15685,40 +15807,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (177 /* FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (parent.kind) { - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return node === parent.constraint; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return node === parent.constraint; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return node === parent.type; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return node === parent.type; - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return node === parent.type; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return node === parent.type; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.contains(parent.typeArguments, node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -15743,23 +15865,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitor(node); - case 263 /* CaseBlock */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 263 /* SyntaxKind.CaseBlock */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return ts.forEachChild(node, traverse); } } @@ -15769,23 +15891,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -15808,10 +15930,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 183 /* ArrayType */) { + if (node && node.kind === 183 /* SyntaxKind.ArrayType */) { return node.elementType; } - else if (node && node.kind === 178 /* TypeReference */) { + else if (node && node.kind === 178 /* SyntaxKind.TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15821,12 +15943,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 182 /* TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 182 /* SyntaxKind.TypeLiteral */: return node.members; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return node.properties; } } @@ -15834,14 +15956,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 203 /* BindingElement */: - case 299 /* EnumMember */: - case 164 /* Parameter */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 299 /* SyntaxKind.EnumMember */: + case 164 /* SyntaxKind.Parameter */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } } @@ -15853,21 +15975,21 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ - && node.parent.parent.kind === 237 /* VariableStatement */; + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ + && node.parent.parent.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isCommonJsExportedExpression(node) { if (!isInJSFile(node)) return false; - return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) || + return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) || isCommonJsExportPropertyAssignment(node.parent); } ts.isCommonJsExportedExpression = isCommonJsExportedExpression; function isCommonJsExportPropertyAssignment(node) { if (!isInJSFile(node)) return false; - return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */); + return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* AssignmentDeclarationKind.ExportsProperty */); } ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment; function isValidESSymbolDeclaration(node) { @@ -15878,13 +16000,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return true; } return false; @@ -15895,7 +16017,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 250 /* LabeledStatement */) { + if (node.statement.kind !== 250 /* SyntaxKind.LabeledStatement */) { return node.statement; } node = node.statement; @@ -15903,30 +16025,30 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 235 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 169 /* MethodDeclaration */ && node.parent.kind === 205 /* ObjectLiteralExpression */; + return node && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethodOrAccessor(node) { - return (node.kind === 169 /* MethodDeclaration */ || node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) && - (node.parent.kind === 205 /* ObjectLiteralExpression */ || - node.parent.kind === 226 /* ClassExpression */); + return (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) && + (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || + node.parent.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor; function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1 /* Identifier */; + return predicate && predicate.kind === 1 /* TypePredicateKind.Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0 /* This */; + return predicate && predicate.kind === 0 /* TypePredicateKind.This */; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 296 /* PropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */) { var propName = tryGetTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15988,14 +16110,14 @@ var ts; } ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 305 /* SourceFile */); + ts.Debug.assert(node.kind !== 305 /* SyntaxKind.SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -16010,9 +16132,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -16023,27 +16145,27 @@ var ts; node = node.parent; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 261 /* ModuleDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 260 /* EnumDeclaration */: - case 305 /* SourceFile */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 305 /* SyntaxKind.SourceFile */: return node; } } @@ -16056,17 +16178,17 @@ var ts; switch (node.kind) { // Arrow functions use the same scope, but may do so in a "delayed" manner // For example, `const getThis = () => this` may be before a super() call in a derived constructor - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 167 /* PropertyDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Object properties can have computed names; only method-like bodies start a new scope return true; default: @@ -16090,9 +16212,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return container; } } @@ -16114,28 +16236,28 @@ var ts; return node; } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: node = node.parent; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return node; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -16151,21 +16273,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 213 /* FunctionExpression */ || func.kind === 214 /* ArrowFunction */) { + if (func.kind === 213 /* SyntaxKind.FunctionExpression */ || func.kind === 214 /* SyntaxKind.ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 212 /* ParenthesizedExpression */) { + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 208 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 106 /* SuperKeyword */ + return node.kind === 106 /* SyntaxKind.SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -16174,8 +16296,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 106 /* SuperKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -16183,34 +16305,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 108 /* ThisKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function isThisInitializedObjectBindingExpression(node) { return !!node && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) && ts.isBinaryExpression(node.parent.parent) - && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */ - && node.parent.parent.right.kind === 108 /* ThisKeyword */; + && node.parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && node.parent.parent.right.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: return node; } return undefined; @@ -16218,10 +16340,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return node.tag; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -16234,25 +16356,25 @@ var ts; return false; } switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // classes are valid targets return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 257 /* ClassDeclaration */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + return parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 257 /* ClassDeclaration */; - case 164 /* Parameter */: + && parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 164 /* SyntaxKind.Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 171 /* Constructor */ - || parent.kind === 169 /* MethodDeclaration */ - || parent.kind === 173 /* SetAccessor */) - && grandparent.kind === 257 /* ClassDeclaration */; + && (parent.kind === 171 /* SyntaxKind.Constructor */ + || parent.kind === 169 /* SyntaxKind.MethodDeclaration */ + || parent.kind === 173 /* SyntaxKind.SetAccessor */) + && grandparent.kind === 257 /* SyntaxKind.ClassDeclaration */; } return false; } @@ -16268,11 +16390,11 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -16288,9 +16410,9 @@ var ts; ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 280 /* JsxOpeningElement */ || - parent.kind === 279 /* JsxSelfClosingElement */ || - parent.kind === 281 /* JsxClosingElement */) { + if (parent.kind === 280 /* SyntaxKind.JsxOpeningElement */ || + parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || + parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return parent.tagName === node; } return false; @@ -16298,66 +16420,66 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 13 /* RegularExpressionLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 229 /* AsExpression */: - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 221 /* BinaryExpression */: - case 222 /* ConditionalExpression */: - case 225 /* SpreadElement */: - case 223 /* TemplateExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 224 /* YieldExpression */: - case 218 /* AwaitExpression */: - case 231 /* MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 223 /* SyntaxKind.TemplateExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 224 /* SyntaxKind.YieldExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 231 /* SyntaxKind.MetaProperty */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return !ts.isHeritageClause(node.parent); - case 161 /* QualifiedName */: - while (node.parent.kind === 161 /* QualifiedName */) { + case 161 /* SyntaxKind.QualifiedName */: + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 311 /* JSDocMemberName */: + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 311 /* SyntaxKind.JSDocMemberName */: while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 80 /* PrivateIdentifier */: - return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */; - case 79 /* Identifier */: - if (node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 80 /* SyntaxKind.PrivateIdentifier */: + return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; + case 79 /* SyntaxKind.Identifier */: + if (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -16367,49 +16489,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: return parent.initializer === node; - case 238 /* ExpressionStatement */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 247 /* ReturnStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 251 /* ThrowStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 251 /* SyntaxKind.ThrowStatement */: return parent.expression === node; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forInStatement.expression === node; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return node === parent.expression; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node === parent.expression; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return node === parent.expression; - case 165 /* Decorator */: - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: - case 298 /* SpreadAssignment */: + case 165 /* SyntaxKind.Decorator */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 298 /* SyntaxKind.SpreadAssignment */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return parent.expression === node && !isPartOfTypeNode(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -16417,10 +16539,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 161 /* QualifiedName */ || node.kind === 79 /* Identifier */) { + while (node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 79 /* SyntaxKind.Identifier */) { node = node.parent; } - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -16428,7 +16550,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -16441,7 +16563,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -16453,11 +16575,11 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 262144 /* JavaScriptFile */); + return !!node && !!(node.flags & 262144 /* NodeFlags.JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 67108864 /* JsonFile */); + return !!node && !!(node.flags & 67108864 /* NodeFlags.JsonFile */); } ts.isInJsonFile = isInJsonFile; function isSourceFileNotJson(file) { @@ -16465,7 +16587,7 @@ var ts; } ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { - return !!node && !!(node.flags & 8388608 /* JSDoc */); + return !!node && !!(node.flags & 8388608 /* NodeFlags.JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -16473,15 +16595,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 150 /* StringKeyword */ || node.typeArguments[0].kind === 147 /* NumberKeyword */); + (node.typeArguments[0].kind === 150 /* SyntaxKind.StringKeyword */ || node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 208 /* CallExpression */) { + if (callExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* SyntaxKind.Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -16518,11 +16640,11 @@ var ts; } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { - return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */; + return charCode === 39 /* CharacterCodes.singleQuote */ || charCode === 34 /* CharacterCodes.doubleQuote */; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isStringDoubleQuoted(str, sourceFile) { - return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; + return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; function isAssignmentDeclaration(decl) { @@ -16533,7 +16655,7 @@ var ts; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && ts.isBinaryExpression(node.initializer) && - (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && + (node.initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -16560,7 +16682,7 @@ var ts; * 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 === 63 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -16586,11 +16708,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 213 /* FunctionExpression */ || e.kind === 214 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 213 /* FunctionExpression */ || - initializer.kind === 226 /* ClassExpression */ || - initializer.kind === 214 /* ArrowFunction */) { + if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ || + initializer.kind === 226 /* SyntaxKind.ClassExpression */ || + initializer.kind === 214 /* SyntaxKind.ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -16608,7 +16730,7 @@ var ts; */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { var e = ts.isBinaryExpression(initializer) - && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && (initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; @@ -16616,7 +16738,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -16624,8 +16746,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -16648,7 +16770,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 108 /* ThisKeyword */ || + (initializer.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -16687,7 +16809,7 @@ var ts; /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); - return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; + return special === 5 /* AssignmentDeclarationKind.Property */ || isInJSFile(expr) ? special : 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; function isBindableObjectDefinePropertyCall(expr) { @@ -16712,14 +16834,14 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; /** Any series of property and element accesses, ending in a literal element access */ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -16738,23 +16860,23 @@ var ts; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } var entityName = expr.arguments[0]; if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { - return 8 /* ObjectDefinePropertyExports */; + return 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */; } if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { - return 9 /* ObjectDefinePrototypeProperty */; + return 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */; } - return 7 /* ObjectDefinePropertyValue */; + return 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { - return 0 /* None */; + if (expr.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + return 0 /* AssignmentDeclarationKind.None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } - return 6 /* Prototype */; + return 6 /* AssignmentDeclarationKind.Prototype */; } return getAssignmentDeclarationPropertyAccessKind(expr.left); } @@ -16791,17 +16913,17 @@ var ts; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 108 /* ThisKeyword */) { - return 4 /* ThisProperty */; + if (lhs.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { + return 4 /* AssignmentDeclarationKind.ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr - return 2 /* ModuleExports */; + return 2 /* AssignmentDeclarationKind.ModuleExports */; } else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr - return 3 /* PrototypeProperty */; + return 3 /* AssignmentDeclarationKind.PrototypeProperty */; } var nextToLast = lhs; while (!ts.isIdentifier(nextToLast.expression)) { @@ -16813,14 +16935,14 @@ var ts; // ExportsProperty does not support binding with computed names isBindableStaticAccessExpression(lhs)) { // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... - return 1 /* ExportsProperty */; + return 1 /* AssignmentDeclarationKind.ExportsProperty */; } if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) { // F.G...x = expr - return 5 /* Property */; + return 5 /* AssignmentDeclarationKind.Property */; } } - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { @@ -16831,12 +16953,12 @@ var ts; } ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression; function isPrototypePropertyAssignment(node) { - return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */; + return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 238 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -16844,7 +16966,7 @@ var ts; function setValueDeclaration(symbol, node) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) && + !(node.flags & 16777216 /* NodeFlags.Ambient */ && !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { // other kinds of value declarations take precedence over modules and assignment declarations @@ -16857,17 +16979,17 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 256 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 256 /* SyntaxKind.FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { var _a, _b; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0]; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike); default: ts.Debug.assertNever(node); @@ -16880,14 +17002,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.parent; - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return node.parent.parent; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16897,17 +17019,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.moduleSpecifier; - case 265 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 277 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 200 /* ImportType */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 200 /* SyntaxKind.ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return node.arguments[0]; - case 261 /* ModuleDeclaration */: - return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; + case 261 /* SyntaxKind.ModuleDeclaration */: + return node.name.kind === 10 /* SyntaxKind.StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -16915,11 +17037,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16927,7 +17049,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 266 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16948,13 +17070,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 164 /* Parameter */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return node.questionToken !== undefined; } } @@ -16968,7 +17090,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 345 /* JSDocTypedefTag */ || node.kind === 338 /* JSDocCallbackTag */ || node.kind === 339 /* JSDocEnumTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || node.kind === 338 /* SyntaxKind.JSDocCallbackTag */ || node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16978,27 +17100,27 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 63 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && + getAssignmentDeclarationKind(node.expression) !== 0 /* AssignmentDeclarationKind.None */ && ts.isBinaryExpression(node.expression.right) && - (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) + (node.expression.right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return node.initializer; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return node.initializer; } } @@ -17010,7 +17132,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 261 /* ModuleDeclaration */ + node.body.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? node.body : undefined; } @@ -17025,11 +17147,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc))); } - if (node.kind === 164 /* Parameter */) { + if (node.kind === 164 /* SyntaxKind.Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 163 /* TypeParameter */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -17058,13 +17180,13 @@ var ts; } function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 296 /* PropertyAssignment */ || - parent.kind === 271 /* ExportAssignment */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 238 /* ExpressionStatement */ && node.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 247 /* ReturnStatement */ || + if (parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + parent.kind === 271 /* SyntaxKind.ExportAssignment */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 247 /* SyntaxKind.ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -17075,7 +17197,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -17099,7 +17221,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* SyntaxKind.Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -17172,41 +17294,41 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + binaryOperator === 63 /* SyntaxKind.EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* AssignmentKind.Definite */ : 2 /* AssignmentKind.Compound */ : + 0 /* AssignmentKind.None */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 212 /* ParenthesizedExpression */: - case 204 /* ArrayLiteralExpression */: - case 225 /* SpreadElement */: - case 230 /* NonNullExpression */: + return unaryOperator === 45 /* SyntaxKind.PlusPlusToken */ || unaryOperator === 46 /* SyntaxKind.MinusMinusToken */ ? 2 /* AssignmentKind.Compound */ : 0 /* AssignmentKind.None */; + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + return parent.initializer === node ? 1 /* AssignmentKind.Definite */ : 0 /* AssignmentKind.None */; + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 230 /* SyntaxKind.NonNullExpression */: node = parent; break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: node = parent.parent; break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (parent.name !== node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (parent.name === node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; default: - return 0 /* None */; + return 0 /* AssignmentKind.None */; } parent = node.parent; } @@ -17217,7 +17339,7 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0 /* None */; + return getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */; } ts.isAssignmentTarget = isAssignmentTarget; /** @@ -17226,22 +17348,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 235 /* Block */: - case 237 /* VariableStatement */: - case 248 /* WithStatement */: - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 235 /* SyntaxKind.Block */: + case 237 /* SyntaxKind.VariableStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return true; } return false; @@ -17258,11 +17380,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 191 /* ParenthesizedType */); + return walkUp(node, 191 /* SyntaxKind.ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 212 /* ParenthesizedExpression */); + return walkUp(node, 212 /* SyntaxKind.ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -17272,7 +17394,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 191 /* ParenthesizedType */) { + while (node && node.kind === 191 /* SyntaxKind.ParenthesizedType */) { child = node; node = node.parent; } @@ -17287,18 +17409,18 @@ var ts; ts.skipTypeParentheses = skipTypeParentheses; function skipParentheses(node, excludeJSDocTypeAssertions) { var flags = excludeJSDocTypeAssertions ? - 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : - 1 /* Parentheses */; + 1 /* OuterExpressionKinds.Parentheses */ | 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ : + 1 /* OuterExpressionKinds.Parentheses */; return ts.skipOuterExpressions(node, flags); } ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 206 /* PropertyAccessExpression */ && node.kind !== 207 /* ElementAccessExpression */) { + if (node.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 207 /* SyntaxKind.ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 215 /* DeleteExpression */; + return node && node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -17319,13 +17441,13 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -17336,13 +17458,13 @@ var ts; else { var binExp = parent.parent; return ts.isBinaryExpression(binExp) && - getAssignmentDeclarationKind(binExp) !== 0 /* None */ && + getAssignmentDeclarationKind(binExp) !== 0 /* AssignmentDeclarationKind.None */ && (binExp.left.symbol || binExp.symbol) && ts.getNameOfDeclaration(binExp) === name ? binExp : undefined; } - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -17351,7 +17473,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 162 /* ComputedPropertyName */ && + node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -17359,29 +17481,29 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 206 /* PropertyAccessExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 203 /* BindingElement */: - case 270 /* ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 275 /* ExportSpecifier */: - case 285 /* JsxAttribute */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 285 /* SyntaxKind.JsxAttribute */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: // Any name in an export specifier or JSX Attribute or Jsx Element return true; } @@ -17404,38 +17526,38 @@ var ts; // const x = require("...").y // const { x } = require("...").y function isAliasSymbolDeclaration(node) { - if (node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - node.kind === 267 /* ImportClause */ && !!node.name || - node.kind === 268 /* NamespaceImport */ || - node.kind === 274 /* NamespaceExport */ || - node.kind === 270 /* ImportSpecifier */ || - node.kind === 275 /* ExportSpecifier */ || - node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) { + if (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name || + node.kind === 268 /* SyntaxKind.NamespaceImport */ || + node.kind === 274 /* SyntaxKind.NamespaceExport */ || + node.kind === 270 /* SyntaxKind.ImportSpecifier */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ && exportAssignmentIsAlias(node)) { return true; } - return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && exportAssignmentIsAlias(node) || ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableExpression(node.parent.right)); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 268 /* NamespaceImport */: - case 275 /* ExportSpecifier */: - case 271 /* ExportAssignment */: - case 265 /* ImportEqualsDeclaration */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 271 /* SyntaxKind.ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 161 /* QualifiedName */); + } while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -17454,7 +17576,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* PropertyAssignment */ ? node.initializer : + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -17471,7 +17593,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -17480,7 +17602,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* SyntaxKind.ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -17493,7 +17615,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -17520,11 +17642,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 81 /* FirstKeyword */ <= token && token <= 160 /* LastKeyword */; + return 81 /* SyntaxKind.FirstKeyword */ <= token && token <= 160 /* SyntaxKind.LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 126 /* FirstContextualKeyword */ <= token && token <= 160 /* LastContextualKeyword */; + return 126 /* SyntaxKind.FirstContextualKeyword */ <= token && token <= 160 /* SyntaxKind.LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -17532,7 +17654,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; + return 117 /* SyntaxKind.FirstFutureReservedWord */ <= token && token <= 125 /* SyntaxKind.LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -17551,7 +17673,7 @@ var ts; } ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + return 2 /* SyntaxKind.FirstTriviaToken */ <= token && token <= 7 /* SyntaxKind.LastTriviaToken */; } ts.isTrivia = isTrivia; var FunctionFlags; @@ -17564,38 +17686,38 @@ var ts; })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { - return 4 /* Invalid */; + return 4 /* FunctionFlags.Invalid */; } - var flags = 0 /* Normal */; + var flags = 0 /* FunctionFlags.Normal */; switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - flags |= 1 /* Generator */; + flags |= 1 /* FunctionFlags.Generator */; } // falls through - case 214 /* ArrowFunction */: - if (hasSyntacticModifier(node, 256 /* Async */)) { - flags |= 2 /* Async */; + case 214 /* SyntaxKind.ArrowFunction */: + if (hasSyntacticModifier(node, 256 /* ModifierFlags.Async */)) { + flags |= 2 /* FunctionFlags.Async */; } break; } if (!node.body) { - flags |= 4 /* Invalid */; + flags |= 4 /* FunctionFlags.Invalid */; } return flags; } ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined - && hasSyntacticModifier(node, 256 /* Async */); + && hasSyntacticModifier(node, 256 /* ModifierFlags.Async */); } return false; } @@ -17605,7 +17727,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* SyntaxKind.PlusToken */ || node.operator === 40 /* SyntaxKind.MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -17622,7 +17744,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) { + if (!(name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || name.kind === 207 /* SyntaxKind.ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -17632,19 +17754,19 @@ var ts; ts.isDynamicName = isDynamicName; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { - if (nameExpression.operator === 40 /* MinusToken */) { + if (nameExpression.operator === 40 /* SyntaxKind.MinusToken */) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } return nameExpression.operand.text; @@ -17657,10 +17779,10 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return true; default: return false; @@ -17676,11 +17798,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -17695,7 +17817,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -17704,11 +17826,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 164 /* Parameter */; + return root.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 203 /* BindingElement */) { + while (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return node; @@ -17716,15 +17838,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 213 /* FunctionExpression */ - || kind === 256 /* FunctionDeclaration */ - || kind === 214 /* ArrowFunction */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 261 /* ModuleDeclaration */ - || kind === 305 /* SourceFile */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 305 /* SyntaxKind.SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -17743,58 +17865,58 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 209 /* NewExpression */: - return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - return 1 /* Right */; - case 221 /* BinaryExpression */: + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 0 /* Associativity.Left */ : 1 /* Associativity.Right */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + return 1 /* Associativity.Right */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operator) { - case 42 /* AsteriskAsteriskToken */: - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 1 /* Right */; - } - } - return 0 /* Left */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 1 /* Associativity.Right */; + } + } + return 0 /* Associativity.Left */; } ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 221 /* BinaryExpression */) { + if (expression.kind === 221 /* SyntaxKind.BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 219 /* PrefixUnaryExpression */ || expression.kind === 220 /* PostfixUnaryExpression */) { + else if (expression.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || expression.kind === 220 /* SyntaxKind.PostfixUnaryExpression */) { return expression.operator; } else { @@ -17973,129 +18095,129 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 351 /* CommaListExpression */: - return 0 /* Comma */; - case 225 /* SpreadElement */: - return 1 /* Spread */; - case 224 /* YieldExpression */: - return 2 /* Yield */; - case 222 /* ConditionalExpression */: - return 4 /* Conditional */; - case 221 /* BinaryExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + return 0 /* OperatorPrecedence.Comma */; + case 225 /* SyntaxKind.SpreadElement */: + return 1 /* OperatorPrecedence.Spread */; + case 224 /* SyntaxKind.YieldExpression */: + return 2 /* OperatorPrecedence.Yield */; + case 222 /* SyntaxKind.ConditionalExpression */: + return 4 /* OperatorPrecedence.Conditional */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operatorKind) { - case 27 /* CommaToken */: - return 0 /* Comma */; - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 3 /* Assignment */; + case 27 /* SyntaxKind.CommaToken */: + return 0 /* OperatorPrecedence.Comma */; + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 3 /* OperatorPrecedence.Assignment */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - return 16 /* Unary */; - case 220 /* PostfixUnaryExpression */: - return 17 /* Update */; - case 208 /* CallExpression */: - return 18 /* LeftHandSide */; - case 209 /* NewExpression */: - return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 210 /* TaggedTemplateExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 231 /* MetaProperty */: - return 19 /* Member */; - case 229 /* AsExpression */: - return 11 /* Relational */; - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 212 /* ParenthesizedExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - return 20 /* Primary */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + return 16 /* OperatorPrecedence.Unary */; + case 220 /* SyntaxKind.PostfixUnaryExpression */: + return 17 /* OperatorPrecedence.Update */; + case 208 /* SyntaxKind.CallExpression */: + return 18 /* OperatorPrecedence.LeftHandSide */; + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 19 /* OperatorPrecedence.Member */ : 18 /* OperatorPrecedence.LeftHandSide */; + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 231 /* SyntaxKind.MetaProperty */: + return 19 /* OperatorPrecedence.Member */; + case 229 /* SyntaxKind.AsExpression */: + return 11 /* OperatorPrecedence.Relational */; + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + return 20 /* OperatorPrecedence.Primary */; default: - return -1 /* Invalid */; + return -1 /* OperatorPrecedence.Invalid */; } } ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 60 /* QuestionQuestionToken */: - return 4 /* Coalesce */; - case 56 /* BarBarToken */: - return 5 /* LogicalOR */; - case 55 /* AmpersandAmpersandToken */: - return 6 /* LogicalAND */; - case 51 /* BarToken */: - return 7 /* BitwiseOR */; - case 52 /* CaretToken */: - return 8 /* BitwiseXOR */; - case 50 /* AmpersandToken */: - return 9 /* BitwiseAND */; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - return 10 /* Equality */; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - return 11 /* Relational */; - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - return 12 /* Shift */; - case 39 /* PlusToken */: - case 40 /* MinusToken */: - return 13 /* Additive */; - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - return 14 /* Multiplicative */; - case 42 /* AsteriskAsteriskToken */: - return 15 /* Exponentiation */; + case 60 /* SyntaxKind.QuestionQuestionToken */: + return 4 /* OperatorPrecedence.Coalesce */; + case 56 /* SyntaxKind.BarBarToken */: + return 5 /* OperatorPrecedence.LogicalOR */; + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + return 6 /* OperatorPrecedence.LogicalAND */; + case 51 /* SyntaxKind.BarToken */: + return 7 /* OperatorPrecedence.BitwiseOR */; + case 52 /* SyntaxKind.CaretToken */: + return 8 /* OperatorPrecedence.BitwiseXOR */; + case 50 /* SyntaxKind.AmpersandToken */: + return 9 /* OperatorPrecedence.BitwiseAND */; + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + return 10 /* OperatorPrecedence.Equality */; + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + return 11 /* OperatorPrecedence.Relational */; + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + return 12 /* OperatorPrecedence.Shift */; + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + return 13 /* OperatorPrecedence.Additive */; + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + return 14 /* OperatorPrecedence.Multiplicative */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + return 15 /* OperatorPrecedence.Exponentiation */; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. @@ -18105,9 +18227,9 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !!i.expression; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return !i.containsOnlyTriviaWhiteSpaces; default: return true; @@ -18222,9 +18344,9 @@ var ts; return "\\u" + paddedHexCode; } function getReplacement(c, offset, input) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); - if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) { + if (lookAhead >= 48 /* CharacterCodes._0 */ && lookAhead <= 57 /* CharacterCodes._9 */) { // If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode) return "\\x00"; } @@ -18239,8 +18361,8 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : - quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 96 /* CharacterCodes.backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* CharacterCodes.singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } @@ -18270,13 +18392,13 @@ var ts; return "&#x" + hexCharCode + ";"; } function getJsxAttributeStringReplacement(c) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { return "�"; } return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0)); } function escapeJsxAttributeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 39 /* CharacterCodes.singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : jsxDoubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement); } @@ -18295,13 +18417,13 @@ var ts; } ts.stripQuotes = stripQuotes; function isQuoteOrBacktick(charCode) { - return charCode === 39 /* singleQuote */ || - charCode === 34 /* doubleQuote */ || - charCode === 96 /* backtick */; + return charCode === 39 /* CharacterCodes.singleQuote */ || + charCode === 34 /* CharacterCodes.doubleQuote */ || + charCode === 96 /* CharacterCodes.backtick */; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); + return (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; var indentStrings = ["", " "]; @@ -18546,20 +18668,20 @@ var ts; } ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker; function getDeclarationEmitExtensionForPath(path) { - return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : - ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : - ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well - ".d.ts" /* Dts */; + return ts.fileExtensionIsOneOf(path, [".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? ".d.mts" /* Extension.Dmts */ : + ts.fileExtensionIsOneOf(path, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? ".d.cts" /* Extension.Dcts */ : + ts.fileExtensionIsOneOf(path, [".json" /* Extension.Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + ".d.ts" /* Extension.Dts */; } ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; /** * This function is an inverse of `getDeclarationEmitExtensionForPath`. */ function getPossibleOriginalInputExtensionForExtension(path) { - return ts.fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : - ts.fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : - ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Json */] : - [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */]; + return ts.fileExtensionIsOneOf(path, [".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */] : + ts.fileExtensionIsOneOf(path, [".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */] : + ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Extension.Json */] : + [".tsx" /* Extension.Tsx */, ".ts" /* Extension.Ts */, ".jsx" /* Extension.Jsx */, ".js" /* Extension.Js */]; } ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension; function outFile(options) { @@ -18687,7 +18809,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* SyntaxKind.Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function isThisInTypeQuery(node) { @@ -18697,11 +18819,11 @@ var ts; while (ts.isQualifiedName(node.parent) && node.parent.left === node) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */; + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 108 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* SyntaxKind.ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -18712,10 +18834,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 173 /* SetAccessor */) { + else if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { setAccessor = accessor; } else { @@ -18735,10 +18857,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 172 /* GetAccessor */ && !getAccessor) { + if (member.kind === 172 /* SyntaxKind.GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 173 /* SetAccessor */ && !setAccessor) { + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -18787,7 +18909,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* SyntaxKind.JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18904,7 +19026,7 @@ var ts; } ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); var lineCount = lineMap.length; var firstCommentLineIndent = void 0; @@ -18979,7 +19101,7 @@ var ts; function calculateIndent(text, pos, end) { var currentLineIndent = 0; for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9 /* tab */) { + if (text.charCodeAt(pos) === 9 /* CharacterCodes.tab */) { // Tabs = TabSize = indent size and go to next tabStop currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } @@ -18991,11 +19113,11 @@ var ts; return currentLineIndent; } function hasEffectiveModifiers(node) { - return getEffectiveModifierFlags(node) !== 0 /* None */; + return getEffectiveModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasEffectiveModifiers = hasEffectiveModifiers; function hasSyntacticModifiers(node) { - return getSyntacticModifierFlags(node) !== 0 /* None */; + return getSyntacticModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasSyntacticModifiers = hasSyntacticModifiers; function hasEffectiveModifier(node, flags) { @@ -19012,27 +19134,27 @@ var ts; } ts.isStatic = isStatic; function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 32 /* ModifierFlags.Static */); } ts.hasStaticModifier = hasStaticModifier; function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16384 /* ModifierFlags.Override */); } ts.hasOverrideModifier = hasOverrideModifier; function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 128 /* Abstract */); + return hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); } ts.hasAbstractModifier = hasAbstractModifier; function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */); } ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 64 /* ModifierFlags.Readonly */); } ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier; function hasDecorators(node) { - return hasSyntacticModifier(node, 131072 /* Decorator */); + return hasSyntacticModifier(node, 131072 /* ModifierFlags.Decorator */); } ts.hasDecorators = hasDecorators; function getSelectedEffectiveModifierFlags(node, flags) { @@ -19044,16 +19166,16 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 160 /* LastToken */) { - return 0 /* None */; + if (node.kind >= 0 /* SyntaxKind.FirstToken */ && node.kind <= 160 /* SyntaxKind.LastToken */) { + return 0 /* ModifierFlags.None */; } - if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { - node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; + if (!(node.modifierFlagsCache & 536870912 /* ModifierFlags.HasComputedFlags */)) { + node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* ModifierFlags.HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* ModifierFlags.HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { + node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* ModifierFlags.HasComputedJSDocModifiers */; } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return node.modifierFlagsCache & ~(536870912 /* ModifierFlags.HasComputedFlags */ | 4096 /* ModifierFlags.HasComputedJSDocModifiers */); } /** * Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance. @@ -19078,22 +19200,22 @@ var ts; } ts.getSyntacticModifierFlags = getSyntacticModifierFlags; function getJSDocModifierFlagsNoCache(node) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (!!node.parent && !ts.isParameter(node)) { if (isInJSFile(node)) { if (ts.getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 4 /* ModifierFlags.Public */; if (ts.getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 8 /* ModifierFlags.Private */; if (ts.getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 16 /* ModifierFlags.Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; if (ts.getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 8192 /* ModifierFlags.Deprecated */; } return flags; } @@ -19112,15 +19234,15 @@ var ts; * NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc. */ function getSyntacticModifierFlagsNoCache(node) { - var flags = ts.canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* None */; - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { - flags |= 1 /* Export */; + var flags = ts.canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* ModifierFlags.None */; + if (node.flags & 4 /* NodeFlags.NestedNamespace */ || (node.kind === 79 /* SyntaxKind.Identifier */ && node.isInJSDocNamespace)) { + flags |= 1 /* ModifierFlags.Export */; } return flags; } ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache; function modifiersToFlags(modifiers) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (modifiers) { for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; @@ -19132,23 +19254,23 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 124 /* StaticKeyword */: return 32 /* Static */; - case 123 /* PublicKeyword */: return 4 /* Public */; - case 122 /* ProtectedKeyword */: return 16 /* Protected */; - case 121 /* PrivateKeyword */: return 8 /* Private */; - case 126 /* AbstractKeyword */: return 128 /* Abstract */; - case 93 /* ExportKeyword */: return 1 /* Export */; - case 135 /* DeclareKeyword */: return 2 /* Ambient */; - case 85 /* ConstKeyword */: return 2048 /* Const */; - case 88 /* DefaultKeyword */: return 512 /* Default */; - case 131 /* AsyncKeyword */: return 256 /* Async */; - case 145 /* ReadonlyKeyword */: return 64 /* Readonly */; - case 159 /* OverrideKeyword */: return 16384 /* Override */; - case 101 /* InKeyword */: return 32768 /* In */; - case 144 /* OutKeyword */: return 65536 /* Out */; - case 165 /* Decorator */: return 131072 /* Decorator */; - } - return 0 /* None */; + case 124 /* SyntaxKind.StaticKeyword */: return 32 /* ModifierFlags.Static */; + case 123 /* SyntaxKind.PublicKeyword */: return 4 /* ModifierFlags.Public */; + case 122 /* SyntaxKind.ProtectedKeyword */: return 16 /* ModifierFlags.Protected */; + case 121 /* SyntaxKind.PrivateKeyword */: return 8 /* ModifierFlags.Private */; + case 126 /* SyntaxKind.AbstractKeyword */: return 128 /* ModifierFlags.Abstract */; + case 93 /* SyntaxKind.ExportKeyword */: return 1 /* ModifierFlags.Export */; + case 135 /* SyntaxKind.DeclareKeyword */: return 2 /* ModifierFlags.Ambient */; + case 85 /* SyntaxKind.ConstKeyword */: return 2048 /* ModifierFlags.Const */; + case 88 /* SyntaxKind.DefaultKeyword */: return 512 /* ModifierFlags.Default */; + case 131 /* SyntaxKind.AsyncKeyword */: return 256 /* ModifierFlags.Async */; + case 145 /* SyntaxKind.ReadonlyKeyword */: return 64 /* ModifierFlags.Readonly */; + case 159 /* SyntaxKind.OverrideKeyword */: return 16384 /* ModifierFlags.Override */; + case 101 /* SyntaxKind.InKeyword */: return 32768 /* ModifierFlags.In */; + case 144 /* SyntaxKind.OutKeyword */: return 65536 /* ModifierFlags.Out */; + case 165 /* SyntaxKind.Decorator */: return 131072 /* ModifierFlags.Decorator */; + } + return 0 /* ModifierFlags.None */; } ts.modifierToFlag = modifierToFlag; function createModifiers(modifierFlags) { @@ -19156,15 +19278,15 @@ var ts; } ts.createModifiers = createModifiers; function isLogicalOperator(token) { - return token === 56 /* BarBarToken */ - || token === 55 /* AmpersandAmpersandToken */ - || token === 53 /* ExclamationToken */; + return token === 56 /* SyntaxKind.BarBarToken */ + || token === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || token === 53 /* SyntaxKind.ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 75 /* BarBarEqualsToken */ - || token === 76 /* AmpersandAmpersandEqualsToken */ - || token === 77 /* QuestionQuestionEqualsToken */; + return token === 75 /* SyntaxKind.BarBarEqualsToken */ + || token === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */ + || token === 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -19172,7 +19294,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; + return token >= 63 /* SyntaxKind.FirstAssignment */ && token <= 78 /* SyntaxKind.LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -19185,14 +19307,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 63 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -19204,8 +19326,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 205 /* ObjectLiteralExpression */ - || kind === 204 /* ArrayLiteralExpression */; + return kind === 205 /* SyntaxKind.ObjectLiteralExpression */ + || kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } return false; } @@ -19215,33 +19337,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* SyntaxKind.Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 79 /* Identifier */ - || node.kind === 108 /* ThisKeyword */ - || node.kind === 106 /* SuperKeyword */ - || node.kind === 231 /* MetaProperty */ - || node.kind === 206 /* PropertyAccessExpression */ && isDottedName(node.expression) - || node.kind === 212 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 108 /* SyntaxKind.ThisKeyword */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */ + || node.kind === 231 /* SyntaxKind.MetaProperty */ + || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -19272,8 +19394,8 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isRightSideOfAccessExpression(node) { @@ -19288,12 +19410,12 @@ var ts; } ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 205 /* ObjectLiteralExpression */ && + return expression.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 204 /* ArrayLiteralExpression */ && + return expression.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -19309,7 +19431,7 @@ var ts; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isExportDefaultSymbol(symbol) { - return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* Default */); + return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* ModifierFlags.Default */); } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTSExtension(fileName) { @@ -19480,9 +19602,9 @@ var ts; var lineFeed = "\n"; function getNewLineCharacter(options, getNewLine) { switch (options.newLine) { - case 0 /* CarriageReturnLineFeed */: + case 0 /* NewLineKind.CarriageReturnLineFeed */: return carriageReturnLineFeed; - case 1 /* LineFeed */: + case 1 /* NewLineKind.LineFeed */: return lineFeed; } return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed; @@ -19627,8 +19749,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -19652,32 +19774,33 @@ var ts; } ts.closeFileWatcher = closeFileWatcher; function getCheckFlags(symbol) { - return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; + return symbol.flags & 33554432 /* SymbolFlags.Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration)) + || (s.flags & 32768 /* SymbolFlags.GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* SymbolFlags.Class */ ? flags : flags & ~28 /* ModifierFlags.AccessibilityModifier */; } - if (getCheckFlags(s) & 6 /* Synthetic */) { + if (getCheckFlags(s) & 6 /* CheckFlags.Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; - var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + var accessModifier = checkFlags & 1024 /* CheckFlags.ContainsPrivate */ ? 8 /* ModifierFlags.Private */ : + checkFlags & 256 /* CheckFlags.ContainsPublic */ ? 4 /* ModifierFlags.Public */ : + 16 /* ModifierFlags.Protected */; + var staticModifier = checkFlags & 2048 /* CheckFlags.ContainsStatic */ ? 32 /* ModifierFlags.Static */ : 0; return accessModifier | staticModifier; } - if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + if (s.flags & 4194304 /* SymbolFlags.Prototype */) { + return 4 /* ModifierFlags.Public */ | 32 /* ModifierFlags.Static */; } return 0; } ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol; function skipAlias(symbol, checker) { - return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol; + return symbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(symbol) : symbol; } ts.skipAlias = skipAlias; /** See comment on `declareModuleMember` in `binder.ts`. */ @@ -19686,11 +19809,11 @@ var ts; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; function isWriteOnlyAccess(node) { - return accessKind(node) === 1 /* Write */; + return accessKind(node) === 1 /* AccessKind.Write */; } ts.isWriteOnlyAccess = isWriteOnlyAccess; function isWriteAccess(node) { - return accessKind(node) !== 0 /* Read */; + return accessKind(node) !== 0 /* AccessKind.Read */; } ts.isWriteAccess = isWriteAccess; var AccessKind; @@ -19705,47 +19828,47 @@ var ts; function accessKind(node) { var parent = node.parent; if (!parent) - return 0 /* Read */; + return 0 /* AccessKind.Read */; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return accessKind(parent); - case 220 /* PostfixUnaryExpression */: - case 219 /* PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var operator = parent.operator; - return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 221 /* BinaryExpression */: + return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? writeOrReadWrite() : 0 /* AccessKind.Read */; + case 221 /* SyntaxKind.BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() - : 0 /* Read */; - case 206 /* PropertyAccessExpression */: - return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 296 /* PropertyAssignment */: { + operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : writeOrReadWrite() + : 0 /* AccessKind.Read */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent); + case 296 /* SyntaxKind.PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. - return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 204 /* ArrayLiteralExpression */: + return node === parent.objectAssignmentInitializer ? 0 /* AccessKind.Read */ : accessKind(parent.parent); + case 204 /* SyntaxKind.ArrayLiteralExpression */: return accessKind(parent); default: - return 0 /* Read */; + return 0 /* AccessKind.Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* SyntaxKind.ExpressionStatement */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */; } } function reverseAccessKind(a) { switch (a) { - case 0 /* Read */: - return 1 /* Write */; - case 1 /* Write */: - return 0 /* Read */; - case 2 /* ReadWrite */: - return 2 /* ReadWrite */; + case 0 /* AccessKind.Read */: + return 1 /* AccessKind.Write */; + case 1 /* AccessKind.Write */: + return 0 /* AccessKind.Read */; + case 2 /* AccessKind.ReadWrite */: + return 2 /* AccessKind.ReadWrite */; default: return ts.Debug.assertNever(a); } @@ -19815,9 +19938,9 @@ var ts; } ts.mutateMap = mutateMap; function isAbstractConstructorSymbol(symbol) { - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 128 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); } return false; } @@ -19828,11 +19951,11 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0; + return type.flags & 3899393 /* TypeFlags.ObjectFlagsType */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { - return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0; + return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length !== 0; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { @@ -19879,44 +20002,44 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) - || kind === 130 /* AnyKeyword */ - || kind === 155 /* UnknownKeyword */ - || kind === 147 /* NumberKeyword */ - || kind === 158 /* BigIntKeyword */ - || kind === 148 /* ObjectKeyword */ - || kind === 133 /* BooleanKeyword */ - || kind === 150 /* StringKeyword */ - || kind === 151 /* SymbolKeyword */ - || kind === 114 /* VoidKeyword */ - || kind === 153 /* UndefinedKeyword */ - || kind === 143 /* NeverKeyword */ - || kind === 228 /* ExpressionWithTypeArguments */ - || kind === 312 /* JSDocAllType */ - || kind === 313 /* JSDocUnknownType */ - || kind === 314 /* JSDocNullableType */ - || kind === 315 /* JSDocNonNullableType */ - || kind === 316 /* JSDocOptionalType */ - || kind === 317 /* JSDocFunctionType */ - || kind === 318 /* JSDocVariadicType */; + return (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) + || kind === 130 /* SyntaxKind.AnyKeyword */ + || kind === 155 /* SyntaxKind.UnknownKeyword */ + || kind === 147 /* SyntaxKind.NumberKeyword */ + || kind === 158 /* SyntaxKind.BigIntKeyword */ + || kind === 148 /* SyntaxKind.ObjectKeyword */ + || kind === 133 /* SyntaxKind.BooleanKeyword */ + || kind === 150 /* SyntaxKind.StringKeyword */ + || kind === 151 /* SyntaxKind.SymbolKeyword */ + || kind === 114 /* SyntaxKind.VoidKeyword */ + || kind === 153 /* SyntaxKind.UndefinedKeyword */ + || kind === 143 /* SyntaxKind.NeverKeyword */ + || kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ + || kind === 312 /* SyntaxKind.JSDocAllType */ + || kind === 313 /* SyntaxKind.JSDocUnknownType */ + || kind === 314 /* SyntaxKind.JSDocNullableType */ + || kind === 315 /* SyntaxKind.JSDocNonNullableType */ + || kind === 316 /* SyntaxKind.JSDocOptionalType */ + || kind === 317 /* SyntaxKind.JSDocFunctionType */ + || kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */ || node.kind === 207 /* ElementAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 206 /* PropertyAccessExpression */) { + if (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 207 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 207 /* SyntaxKind.ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; function isBundleFileTextLike(section) { switch (section.kind) { - case "text" /* Text */: - case "internal" /* Internal */: + case "text" /* BundleFileSectionKind.Text */: + case "internal" /* BundleFileSectionKind.Internal */: return true; default: return false; @@ -19924,7 +20047,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 269 /* NamedImports */ || node.kind === 273 /* NamedExports */; + return node.kind === 269 /* SyntaxKind.NamedImports */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -19939,13 +20062,13 @@ var ts; return walkAccessExpression(name.parent); } function walkAccessExpression(access) { - if (access.kind === 206 /* PropertyAccessExpression */) { + if (access.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var res = action(access.name); if (res !== undefined) { return res; } } - else if (access.kind === 207 /* ElementAccessExpression */) { + else if (access.kind === 207 /* SyntaxKind.ElementAccessExpression */) { if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) { var res = action(access.argumentExpression); if (res !== undefined) { @@ -19972,28 +20095,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: node = node.operand; continue; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: node = node.left; continue; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: node = node.condition; continue; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: node = node.tag; continue; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 229 /* AsExpression */: - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: - case 230 /* NonNullExpression */: - case 350 /* PartiallyEmittedExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: node = node.expression; continue; } @@ -20027,9 +20150,9 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; } @@ -20038,8 +20161,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } function Identifier(kind, pos, end) { @@ -20047,8 +20170,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; this.flowNode = undefined; @@ -20243,7 +20366,7 @@ var ts; function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -20252,43 +20375,43 @@ var ts; ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (d1.relatedInformation && d2.relatedInformation) { return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { var d2i = d2.relatedInformation[index]; return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; + }) || 0 /* Comparison.EqualTo */; } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + return d1.relatedInformation ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; } function compareMessageText(t1, t2) { if (typeof t1 === "string" && typeof t2 === "string") { return ts.compareStringsCaseSensitive(t1, t2); } else if (typeof t1 === "string") { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (typeof t2 === "string") { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); if (res) { return res; } if (!t1.next && !t2.next) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (!t1.next) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } if (!t2.next) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var len = Math.min(t1.next.length, t2.next.length); for (var i = 0; i < len; i++) { @@ -20298,16 +20421,16 @@ var ts; } } if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* ScriptKind.TSX */ || scriptKind === 2 /* ScriptKind.JSX */ || scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 6 /* ScriptKind.JSON */ ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */; } ts.getLanguageVariant = getLanguageVariant; /** @@ -20316,7 +20439,7 @@ var ts; * Unfortunately, there's no `NodeFlag` space to do the same for JSX. */ function walkTreeForJSXTags(node) { - if (!(node.transformFlags & 2 /* ContainsJsx */)) + if (!(node.transformFlags & 2 /* TransformFlags.ContainsJsx */)) return undefined; return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags); } @@ -20333,7 +20456,7 @@ var ts; // Excludes declaration files - they still require an explicit `export {}` or the like // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files // that aren't esm-mode (meaning not in a `type: module` scope). - return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined; + return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]))) && !file.isDeclarationFile ? true : undefined; } function getSetExternalModuleIndicator(options) { // TODO: Should this callback be cached? @@ -20353,13 +20476,10 @@ var ts; // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness var checks = [ts.isFileProbablyExternalModule]; - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { checks.push(isFileModuleFromUsingJSXTag); } - var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { - checks.push(isFileForcedToBeModuleByFormat); - } + checks.push(isFileForcedToBeModuleByFormat); var combined_1 = ts.or.apply(void 0, checks); var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); }; return callback; @@ -20368,15 +20488,15 @@ var ts; ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator; function getEmitScriptTarget(compilerOptions) { return compilerOptions.target || - (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ES2022 */) || - (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) || - 0 /* ES3 */; + (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ScriptTarget.ES2022 */) || + (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ScriptTarget.ESNext */) || + 0 /* ScriptTarget.ES3 */; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function getEmitModuleResolutionKind(compilerOptions) { @@ -20474,7 +20594,7 @@ var ts; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function getUseDefineForClassFields(compilerOptions) { - return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */ : compilerOptions.useDefineForClassFields; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { @@ -20495,14 +20615,14 @@ var ts; ts.getCompilerOptionValue = getCompilerOptionValue; function getJSXTransformEnabled(options) { var jsx = options.jsx; - return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */; + return jsx === 2 /* JsxEmit.React */ || jsx === 4 /* JsxEmit.ReactJSX */ || jsx === 5 /* JsxEmit.ReactJSXDev */; } ts.getJSXTransformEnabled = getJSXTransformEnabled; function getJSXImplicitImportBase(compilerOptions, file) { var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; - return compilerOptions.jsx === 4 /* ReactJSX */ || - compilerOptions.jsx === 5 /* ReactJSXDev */ || + return compilerOptions.jsx === 4 /* JsxEmit.ReactJSX */ || + compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ || compilerOptions.jsxImportSource || jsxImportSourcePragma ? (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : @@ -20510,13 +20630,13 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { + if (str.charCodeAt(i) === 42 /* CharacterCodes.asterisk */) { if (!seenAsterisk) { seenAsterisk = true; } @@ -20615,9 +20735,9 @@ var ts; function escapeRegExpCharacter(match) { return "\\" + match; } - var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; + var wildcardCharCodes = [42 /* CharacterCodes.asterisk */, 63 /* CharacterCodes.question */]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { /** * Matches any single directory segment unless it is the last segment and a .min.js file @@ -20630,7 +20750,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { @@ -20639,7 +20759,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -20657,10 +20777,10 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); // If excluding, match "foo/bar/baz...", but if including, only allow "foo". var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -20682,7 +20802,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -20719,11 +20839,11 @@ var ts; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { + if (component.charCodeAt(0) === 42 /* CharacterCodes.asterisk */) { componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } - else if (component.charCodeAt(0) === 63 /* question */) { + else if (component.charCodeAt(0) === 63 /* CharacterCodes.question */) { componentPattern += "[^./]"; component = component.substr(1); } @@ -20760,7 +20880,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -20885,44 +21005,44 @@ var ts; // If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt // to get the ScriptKind from the file name. If it cannot be resolved // from the file name then the default 'TS' script kind is returned. - return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */; + return scriptKind || getScriptKindFromFileName(fileName) || 3 /* ScriptKind.TS */; } ts.ensureScriptKind = ensureScriptKind; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: - case ".cjs" /* Cjs */: - case ".mjs" /* Mjs */: - return 1 /* JS */; - case ".jsx" /* Jsx */: - return 2 /* JSX */; - case ".ts" /* Ts */: - case ".cts" /* Cts */: - case ".mts" /* Mts */: - return 3 /* TS */; - case ".tsx" /* Tsx */: - return 4 /* TSX */; - case ".json" /* Json */: - return 6 /* JSON */; + case ".js" /* Extension.Js */: + case ".cjs" /* Extension.Cjs */: + case ".mjs" /* Extension.Mjs */: + return 1 /* ScriptKind.JS */; + case ".jsx" /* Extension.Jsx */: + return 2 /* ScriptKind.JSX */; + case ".ts" /* Extension.Ts */: + case ".cts" /* Extension.Cts */: + case ".mts" /* Extension.Mts */: + return 3 /* ScriptKind.TS */; + case ".tsx" /* Extension.Tsx */: + return 4 /* ScriptKind.TSX */; + case ".json" /* Extension.Json */: + return 6 /* ScriptKind.JSON */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } ts.getScriptKindFromFileName = getScriptKindFromFileName; /** * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ - ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]]; + ts.supportedTSExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */]]; ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions); - var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false); + var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Extension.Json */]], false); /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */]; - ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]]; + var supportedTSExtensionsForExtractExtension = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */]; + ts.supportedJSExtensions = [[".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".mjs" /* Extension.Mjs */], [".cjs" /* Extension.Cjs */]]; ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); - var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]]; - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false); - ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]; + var allSupportedExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */]]; + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Extension.Json */]], false); + ts.supportedDeclarationExtensions = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */]; function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { @@ -20930,7 +21050,7 @@ var ts; } var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; var flatBuiltins = ts.flatten(builtins); - var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); + var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* ScriptKind.Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); return extensions; } ts.getSupportedExtensions = getSupportedExtensions; @@ -20941,11 +21061,11 @@ var ts; return allSupportedExtensionsWithJson; if (supportedExtensions === ts.supportedTSExtensions) return supportedTSExtensionsWithJson; - return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false); + return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Extension.Json */]], false); } ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { - return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; + return scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 2 /* ScriptKind.JSX */; } function hasJSFileExtension(fileName) { return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -20976,7 +21096,7 @@ var ts; return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); } ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; - var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; + var extensionsToRemove = [".d.ts" /* Extension.Dts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".ts" /* Extension.Ts */, ".js" /* Extension.Js */, ".tsx" /* Extension.Tsx */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -21029,11 +21149,11 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTS(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */; + return ext === ".ts" /* Extension.Ts */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".d.ts" /* Extension.Dts */ || ext === ".cts" /* Extension.Cts */ || ext === ".mts" /* Extension.Mts */ || ext === ".d.mts" /* Extension.Dmts */ || ext === ".d.cts" /* Extension.Dcts */; } ts.extensionIsTS = extensionIsTS; function resolutionExtensionIsTSOrJson(ext) { - return extensionIsTS(ext) || ext === ".json" /* Json */; + return extensionIsTS(ext) || ext === ".json" /* Extension.Json */; } ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; /** @@ -21042,7 +21162,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -21151,23 +21271,23 @@ var ts; function parsePseudoBigInt(stringValue) { var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" - case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 98 /* CharacterCodes.b */: + case 66 /* CharacterCodes.B */: // 0b or 0B log2Base = 1; break; - case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 111 /* CharacterCodes.o */: + case 79 /* CharacterCodes.O */: // 0o or 0O log2Base = 3; break; - case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 120 /* CharacterCodes.x */: + case 88 /* CharacterCodes.X */: // 0x or 0X log2Base = 4; break; default: // already in decimal; omit trailing "n" var nIndex = stringValue.length - 1; // Skip leading 0s var nonZeroStart = 0; - while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) { + while (stringValue.charCodeAt(nonZeroStart) === 48 /* CharacterCodes._0 */) { nonZeroStart++; } return stringValue.slice(nonZeroStart, nIndex) || "0"; @@ -21183,10 +21303,10 @@ var ts; var segment = bitOffset >>> 4; var digitChar = stringValue.charCodeAt(i); // Find character range: 0-9 < A-F < a-f - var digit = digitChar <= 57 /* _9 */ - ? digitChar - 48 /* _0 */ + var digit = digitChar <= 57 /* CharacterCodes._9 */ + ? digitChar - 48 /* CharacterCodes._0 */ : 10 + digitChar - - (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + (digitChar <= 70 /* CharacterCodes.F */ ? 65 /* CharacterCodes.A */ : 97 /* CharacterCodes.a */); var shiftedDigit = digit << (bitOffset & 15); segments[segment] |= shiftedDigit; var residual = shiftedDigit >>> 16; @@ -21221,7 +21341,7 @@ var ts; } ts.pseudoBigIntToString = pseudoBigIntToString; function isValidTypeOnlyAliasUseSite(useSite) { - return !!(useSite.flags & 16777216 /* Ambient */) + return !!(useSite.flags & 16777216 /* NodeFlags.Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) @@ -21232,34 +21352,34 @@ var ts; return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite; } function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 79 /* Identifier */ || node.kind === 206 /* PropertyAccessExpression */) { + while (node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 258 /* InterfaceDeclaration */ || containerKind === 182 /* TypeLiteral */; + return containerKind === 258 /* SyntaxKind.InterfaceDeclaration */ || containerKind === 182 /* SyntaxKind.TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 79 /* Identifier */) + if (node.kind !== 79 /* SyntaxKind.Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return true; - case 206 /* PropertyAccessExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* SyntaxKind.ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* SyntaxKind.InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -21400,7 +21520,7 @@ var ts; node = parent; continue; } - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // left side of comma is always unused if (node === parent.left) return true; @@ -21420,22 +21540,22 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 190 /* InferType */ ? undefined : parent_1.typeParameters; - case 164 /* Parameter */: + return parent_1.kind === 190 /* SyntaxKind.InferType */ ? undefined : parent_1.typeParameters; + case 164 /* SyntaxKind.Parameter */: return node.parent.parameters; - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node.parent.templateSpans; - case 165 /* Decorator */: { + case 165 /* SyntaxKind.Decorator */: { var parent_2 = node.parent; return ts.canHaveDecorators(parent_2) ? parent_2.modifiers : ts.canHaveIllegalDecorators(parent_2) ? parent_2.decorators : undefined; } - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -21443,45 +21563,45 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 182 /* TypeLiteral */: - case 258 /* InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return parent.types; - case 184 /* TupleType */: - case 204 /* ArrayLiteralExpression */: - case 351 /* CommaListExpression */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 184 /* SyntaxKind.TupleType */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return parent.elements; - case 205 /* ObjectLiteralExpression */: - case 286 /* JsxAttributes */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 286 /* SyntaxKind.JsxAttributes */: return parent.properties; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 278 /* JsxElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 282 /* SyntaxKind.JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: return parent.statements; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return parent.clauses; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return parent.statements; } } @@ -21493,7 +21613,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 214 /* ArrowFunction */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -21511,7 +21631,7 @@ var ts; } ts.isInfinityOrNaNString = isInfinityOrNaNString; function isCatchClauseVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function isParameterOrCatchClauseVariable(symbol) { @@ -21520,7 +21640,7 @@ var ts; } ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable; function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 213 /* FunctionExpression */ || node.kind === 214 /* ArrowFunction */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */ || node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction; function escapeSnippetText(text) { @@ -21559,7 +21679,7 @@ var ts; } ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral; function isThisTypeParameter(type) { - return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); + return !!(type.flags & 262144 /* TypeFlags.TypeParameter */ && type.isThisType); } ts.isThisTypeParameter = isThisTypeParameter; function getNodeModulePathParts(fullPath) { @@ -21579,45 +21699,45 @@ var ts; })(States || (States = {})); var partStart = 0; var partEnd = 0; - var state = 0 /* BeforeNodeModules */; + var state = 0 /* States.BeforeNodeModules */; while (partEnd >= 0) { partStart = partEnd; partEnd = fullPath.indexOf("/", partStart + 1); switch (state) { - case 0 /* BeforeNodeModules */: + case 0 /* States.BeforeNodeModules */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { topLevelNodeModulesIndex = partStart; topLevelPackageNameIndex = partEnd; - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } break; - case 1 /* NodeModules */: - case 2 /* Scope */: - if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { - state = 2 /* Scope */; + case 1 /* States.NodeModules */: + case 2 /* States.Scope */: + if (state === 1 /* States.NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* States.Scope */; } else { packageRootIndex = partEnd; - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; - case 3 /* PackageContent */: + case 3 /* States.PackageContent */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } else { - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; } } fileNameIndex = partStart; - return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; + return state > 1 /* States.NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; } ts.getNodeModulePathParts = getNodeModulePathParts; function getParameterTypeNode(parameter) { var _a; - return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; + return parameter.kind === 340 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; } ts.getParameterTypeNode = getParameterTypeNode; })(ts || (ts = {})); @@ -21742,28 +21862,28 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* SyntaxKind.BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 214 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 214 /* SyntaxKind.ArrowFunction */ && binaryOperatorPrecedence > 3 /* OperatorPrecedence.Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If the operand is the right side of a right-associative binary operation // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 224 /* YieldExpression */) { + && binaryOperatorAssociativity === 1 /* Associativity.Right */ + && operand.kind === 224 /* SyntaxKind.YieldExpression */) { return false; } return true; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: return false; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: if (isLeftSideOfBinary) { // No need to parenthesize the left operand when the binary operator is // left associative: @@ -21774,7 +21894,7 @@ var ts; // right associative: // (a/b)**x -> (a/b)**x // (a**b)**x -> (a**b)**x - return binaryOperatorAssociativity === 1 /* Right */; + return binaryOperatorAssociativity === 1 /* Associativity.Right */; } else { if (ts.isBinaryExpression(emittedOperand) @@ -21794,8 +21914,8 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 39 /* PlusToken */) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; + if (binaryOperator === 39 /* SyntaxKind.PlusToken */) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* SyntaxKind.Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; } @@ -21811,7 +21931,7 @@ var ts; // x/(a*b) -> x/(a*b) // x**(a/b) -> x**(a/b) var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0 /* Left */; + return operandAssociativity === 0 /* Associativity.Left */; } } } @@ -21829,10 +21949,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 41 /* AsteriskToken */ - || binaryOperator === 51 /* BarToken */ - || binaryOperator === 50 /* AmpersandToken */ - || binaryOperator === 52 /* CaretToken */; + return binaryOperator === 41 /* SyntaxKind.AsteriskToken */ + || binaryOperator === 51 /* SyntaxKind.BarToken */ + || binaryOperator === 50 /* SyntaxKind.AmpersandToken */ + || binaryOperator === 52 /* SyntaxKind.CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -21845,7 +21965,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -21853,11 +21973,11 @@ var ts; var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind - : 0 /* Unknown */; + : 0 /* SyntaxKind.Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended @@ -21871,7 +21991,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 212 /* ParenthesizedExpression */) { + if (skipped.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -21888,10 +22008,10 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(222 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(222 /* SyntaxKind.ConditionalExpression */, 57 /* SyntaxKind.QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* Comparison.GreaterThan */) { return factory.createParenthesizedExpression(condition); } return condition; @@ -21921,8 +22041,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: needsParens = true; } } @@ -21935,9 +22055,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return factory.createParenthesizedExpression(expression); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -21948,7 +22068,7 @@ var ts; * Wraps an expression in parentheses if it is needed in order to use the expression for * property or element access. */ - function parenthesizeLeftSideOfAccess(expression) { + function parenthesizeLeftSideOfAccess(expression, optionalChain) { // isLeftHandSideExpression is almost the correct criterion for when it is not necessary // to parenthesize the expression before a dot. The known exception is: // @@ -21957,7 +22077,8 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 /* SyntaxKind.NewExpression */ || emittedExpression.arguments) + && (optionalChain || !ts.isOptionalChain(emittedExpression))) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -21979,7 +22100,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, 27 /* SyntaxKind.CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -21988,21 +22109,21 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 213 /* FunctionExpression */ || kind === 214 /* ArrowFunction */) { + if (kind === 213 /* SyntaxKind.FunctionExpression */ || kind === 214 /* SyntaxKind.ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); - return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); + return factory.restoreOuterExpressions(expression, updated, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 205 /* ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* FunctionExpression */) { + if (leftmostExpressionKind === 205 /* SyntaxKind.ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* SyntaxKind.FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } @@ -22020,16 +22141,16 @@ var ts; // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type function parenthesizeCheckTypeOfConditionalType(checkType) { switch (checkType.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 189 /* ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(checkType); } return checkType; } function parenthesizeExtendsTypeOfConditionalType(extendsType) { switch (extendsType.kind) { - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(extendsType); } return extendsType; @@ -22041,8 +22162,8 @@ var ts; // - A union type constituent has the same precedence as the check type of a conditional type function parenthesizeConstituentTypeOfUnionType(type) { switch (type.kind) { - case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened - case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 187 /* SyntaxKind.UnionType */: // Not strictly necessary, but a union containing a union should have been flattened + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeCheckTypeOfConditionalType(type); @@ -22057,8 +22178,8 @@ var ts; // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized) function parenthesizeConstituentTypeOfIntersectionType(type) { switch (type.kind) { - case 187 /* UnionType */: - case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfUnionType(type); @@ -22075,14 +22196,14 @@ var ts; // function parenthesizeOperandOfTypeOperator(type) { switch (type.kind) { - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfIntersectionType(type); } function parenthesizeOperandOfReadonlyTypeOperator(type) { switch (type.kind) { - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -22102,9 +22223,9 @@ var ts; // function parenthesizeNonArrayTypeOfPostfixType(type) { switch (type.kind) { - case 190 /* InferType */: - case 193 /* TypeOperator */: - case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 190 /* SyntaxKind.InferType */: + case 193 /* SyntaxKind.TypeOperator */: + case 181 /* SyntaxKind.TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -22298,11 +22419,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -22360,10 +22481,10 @@ var ts; */ /* @internal */ function createNodeFactory(flags, baseFactory) { - var update = flags & 8 /* NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; + var update = flags & 8 /* NodeFactoryFlags.NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; // Lazily load the parenthesizer, node converters, and some factory methods until they are used. - var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); - var converters = ts.memoize(function () { return flags & 2 /* NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); + var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NodeFactoryFlags.NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); + var converters = ts.memoize(function () { return flags & 2 /* NodeFactoryFlags.NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); // lazy initializaton of common operator factories var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; }); var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; }); @@ -22494,12 +22615,12 @@ var ts; updateArrayLiteralExpression: updateArrayLiteralExpression, createObjectLiteralExpression: createObjectLiteralExpression, updateObjectLiteralExpression: updateObjectLiteralExpression, - createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* NoIndentation */); } : + createPropertyAccessExpression: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessExpression, updatePropertyAccessExpression: updatePropertyAccessExpression, - createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* NoIndentation */); } : + createPropertyAccessChain: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessChain, updatePropertyAccessChain: updatePropertyAccessChain, createElementAccessExpression: createElementAccessExpression, @@ -22655,18 +22776,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* SyntaxKind.JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* SyntaxKind.JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -22702,30 +22823,30 @@ var ts; createJSDocLinkPlain: createJSDocLinkPlain, updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* JSDocReadonlyTag */); }, - get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* JSDocOverrideTag */); }, - get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* JSDocOverrideTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -22793,38 +22914,38 @@ var ts; updateSyntheticReferenceExpression: updateSyntheticReferenceExpression, cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities - get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, - get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, - get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, - get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, - get createBitwiseXor() { return getBinaryCreateFunction(52 /* CaretToken */); }, - get createBitwiseAnd() { return getBinaryCreateFunction(50 /* AmpersandToken */); }, - get createStrictEquality() { return getBinaryCreateFunction(36 /* EqualsEqualsEqualsToken */); }, - get createStrictInequality() { return getBinaryCreateFunction(37 /* ExclamationEqualsEqualsToken */); }, - get createEquality() { return getBinaryCreateFunction(34 /* EqualsEqualsToken */); }, - get createInequality() { return getBinaryCreateFunction(35 /* ExclamationEqualsToken */); }, - get createLessThan() { return getBinaryCreateFunction(29 /* LessThanToken */); }, - get createLessThanEquals() { return getBinaryCreateFunction(32 /* LessThanEqualsToken */); }, - get createGreaterThan() { return getBinaryCreateFunction(31 /* GreaterThanToken */); }, - get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* GreaterThanEqualsToken */); }, - get createLeftShift() { return getBinaryCreateFunction(47 /* LessThanLessThanToken */); }, - get createRightShift() { return getBinaryCreateFunction(48 /* GreaterThanGreaterThanToken */); }, - get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* GreaterThanGreaterThanGreaterThanToken */); }, - get createAdd() { return getBinaryCreateFunction(39 /* PlusToken */); }, - get createSubtract() { return getBinaryCreateFunction(40 /* MinusToken */); }, - get createMultiply() { return getBinaryCreateFunction(41 /* AsteriskToken */); }, - get createDivide() { return getBinaryCreateFunction(43 /* SlashToken */); }, - get createModulo() { return getBinaryCreateFunction(44 /* PercentToken */); }, - get createExponent() { return getBinaryCreateFunction(42 /* AsteriskAsteriskToken */); }, - get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* PlusToken */); }, - get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* MinusToken */); }, - get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* MinusMinusToken */); }, - get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* TildeToken */); }, - get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* ExclamationToken */); }, - get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* MinusMinusToken */); }, + get createComma() { return getBinaryCreateFunction(27 /* SyntaxKind.CommaToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* SyntaxKind.EqualsToken */); }, + get createLogicalOr() { return getBinaryCreateFunction(56 /* SyntaxKind.BarBarToken */); }, + get createLogicalAnd() { return getBinaryCreateFunction(55 /* SyntaxKind.AmpersandAmpersandToken */); }, + get createBitwiseOr() { return getBinaryCreateFunction(51 /* SyntaxKind.BarToken */); }, + get createBitwiseXor() { return getBinaryCreateFunction(52 /* SyntaxKind.CaretToken */); }, + get createBitwiseAnd() { return getBinaryCreateFunction(50 /* SyntaxKind.AmpersandToken */); }, + get createStrictEquality() { return getBinaryCreateFunction(36 /* SyntaxKind.EqualsEqualsEqualsToken */); }, + get createStrictInequality() { return getBinaryCreateFunction(37 /* SyntaxKind.ExclamationEqualsEqualsToken */); }, + get createEquality() { return getBinaryCreateFunction(34 /* SyntaxKind.EqualsEqualsToken */); }, + get createInequality() { return getBinaryCreateFunction(35 /* SyntaxKind.ExclamationEqualsToken */); }, + get createLessThan() { return getBinaryCreateFunction(29 /* SyntaxKind.LessThanToken */); }, + get createLessThanEquals() { return getBinaryCreateFunction(32 /* SyntaxKind.LessThanEqualsToken */); }, + get createGreaterThan() { return getBinaryCreateFunction(31 /* SyntaxKind.GreaterThanToken */); }, + get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* SyntaxKind.GreaterThanEqualsToken */); }, + get createLeftShift() { return getBinaryCreateFunction(47 /* SyntaxKind.LessThanLessThanToken */); }, + get createRightShift() { return getBinaryCreateFunction(48 /* SyntaxKind.GreaterThanGreaterThanToken */); }, + get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */); }, + get createAdd() { return getBinaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createSubtract() { return getBinaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createMultiply() { return getBinaryCreateFunction(41 /* SyntaxKind.AsteriskToken */); }, + get createDivide() { return getBinaryCreateFunction(43 /* SyntaxKind.SlashToken */); }, + get createModulo() { return getBinaryCreateFunction(44 /* SyntaxKind.PercentToken */); }, + get createExponent() { return getBinaryCreateFunction(42 /* SyntaxKind.AsteriskAsteriskToken */); }, + get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, + get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* SyntaxKind.TildeToken */); }, + get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* SyntaxKind.ExclamationToken */); }, + get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, // Compound nodes createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression, createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction, @@ -22928,11 +23049,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -22950,7 +23071,7 @@ var ts; node.typeParameters = asNodeArray(typeParameters); node.transformFlags |= propagateChildrenFlags(node.typeParameters); if (typeParameters) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type) { @@ -22961,7 +23082,7 @@ var ts; propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used for quick info node.typeArguments = undefined; return node; @@ -22976,9 +23097,9 @@ var ts; function createBaseFunctionLikeDeclaration(kind, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; if (!body) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseInterfaceOrClassLikeDeclaration(kind, modifiers, name, typeParameters, heritageClauses) { @@ -23004,7 +23125,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } // @@ -23017,21 +23138,21 @@ var ts; } // @api function createNumericLiteral(value, numericLiteralFlags) { - if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* None */; } - var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); + if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* TokenFlags.None */; } + var node = createBaseLiteral(8 /* SyntaxKind.NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; - if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 1024 /* ContainsES2015 */; + if (numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api function createBigIntLiteral(value) { - var node = createBaseLiteral(9 /* BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); - node.transformFlags |= 4 /* ContainsESNext */; + var node = createBaseLiteral(9 /* SyntaxKind.BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } function createBaseStringLiteral(text, isSingleQuote) { - var node = createBaseLiteral(10 /* StringLiteral */, text); + var node = createBaseLiteral(10 /* SyntaxKind.StringLiteral */, text); node.singleQuote = isSingleQuote; return node; } @@ -23040,7 +23161,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -23051,19 +23172,19 @@ var ts; } // @api function createRegularExpressionLiteral(text) { - var node = createBaseLiteral(13 /* RegularExpressionLiteral */, text); + var node = createBaseLiteral(13 /* SyntaxKind.RegularExpressionLiteral */, text); return node; } // @api function createLiteralLikeNode(kind, text) { switch (kind) { - case 8 /* NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); - case 9 /* BigIntLiteral */: return createBigIntLiteral(text); - case 10 /* StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); - case 11 /* JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); - case 12 /* JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); - case 13 /* RegularExpressionLiteral */: return createRegularExpressionLiteral(text); - case 14 /* NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); + case 8 /* SyntaxKind.NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); + case 9 /* SyntaxKind.BigIntLiteral */: return createBigIntLiteral(text); + case 10 /* SyntaxKind.StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); + case 11 /* SyntaxKind.JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); + case 13 /* SyntaxKind.RegularExpressionLiteral */: return createRegularExpressionLiteral(text); + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); } } // @@ -23073,10 +23194,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 79 /* Identifier */) { + if (originalKeywordKind === 79 /* SyntaxKind.Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -23095,8 +23216,8 @@ var ts; // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 132 /* AwaitKeyword */) { - node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { + node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; } return node; } @@ -23108,9 +23229,9 @@ var ts; } // @api function createTempVariable(recordTempVariable, reservedInNestedScopes) { - var flags = 1 /* Auto */; + var flags = 1 /* GeneratedIdentifierFlags.Auto */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; var name = createBaseGeneratedIdentifier("", flags); if (recordTempVariable) { recordTempVariable(name); @@ -23120,25 +23241,25 @@ var ts; /** Create a unique temporary variable for use in a loop. */ // @api function createLoopVariable(reservedInNestedScopes) { - var flags = 2 /* Loop */; + var flags = 2 /* GeneratedIdentifierFlags.Loop */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api function createUniqueName(text, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - ts.Debug.assert((flags & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); - return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags); + if (flags === void 0) { flags = 0 /* GeneratedIdentifierFlags.None */; } + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + ts.Debug.assert((flags & (16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)) !== 32 /* GeneratedIdentifierFlags.FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); + return createBaseGeneratedIdentifier(text, 3 /* GeneratedIdentifierFlags.Unique */ | flags); } /** Create a unique name generated for a node. */ // @api function getGeneratedNameForNode(node, flags) { if (flags === void 0) { flags = 0; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* Node */ | flags); + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* GeneratedIdentifierFlags.Node */ | flags); name.original = node; return name; } @@ -23146,9 +23267,9 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 16777216 /* ContainsClassFields */; + node.transformFlags |= 16777216 /* TransformFlags.ContainsClassFields */; return node; } // @@ -23158,51 +23279,51 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 160 /* LastToken */, "Invalid token"); - ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); - ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token >= 0 /* SyntaxKind.FirstToken */ && token <= 160 /* SyntaxKind.LastToken */, "Invalid token"); + ts.Debug.assert(token <= 14 /* SyntaxKind.FirstTemplateToken */ || token >= 17 /* SyntaxKind.LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); + ts.Debug.assert(token <= 8 /* SyntaxKind.FirstLiteralToken */ || token >= 14 /* SyntaxKind.LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); + ts.Debug.assert(token !== 79 /* SyntaxKind.Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); - var transformFlags = 0 /* None */; + var transformFlags = 0 /* TransformFlags.None */; switch (token) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; break; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 126 /* AbstractKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 155 /* UnknownKeyword */: - case 153 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. - transformFlags = 1 /* ContainsTypeScript */; + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + transformFlags = 1 /* TransformFlags.ContainsTypeScript */; break; - case 106 /* SuperKeyword */: - transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */; + case 106 /* SyntaxKind.SuperKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */ | 134217728 /* TransformFlags.ContainsLexicalSuper */; break; - case 124 /* StaticKeyword */: - transformFlags = 1024 /* ContainsES2015 */; + case 124 /* SyntaxKind.StaticKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */; break; - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 16384 /* ContainsLexicalThis */; + transformFlags = 16384 /* TransformFlags.ContainsLexicalThis */; break; } if (transformFlags) { @@ -23215,23 +23336,23 @@ var ts; // // @api function createSuper() { - return createToken(106 /* SuperKeyword */); + return createToken(106 /* SyntaxKind.SuperKeyword */); } // @api function createThis() { - return createToken(108 /* ThisKeyword */); + return createToken(108 /* SyntaxKind.ThisKeyword */); } // @api function createNull() { - return createToken(104 /* NullKeyword */); + return createToken(104 /* SyntaxKind.NullKeyword */); } // @api function createTrue() { - return createToken(110 /* TrueKeyword */); + return createToken(110 /* SyntaxKind.TrueKeyword */); } // @api function createFalse() { - return createToken(95 /* FalseKeyword */); + return createToken(95 /* SyntaxKind.FalseKeyword */); } // // Modifiers @@ -23243,34 +23364,34 @@ var ts; // @api function createModifiersFromModifierFlags(flags) { var result = []; - if (flags & 1 /* Export */) - result.push(createModifier(93 /* ExportKeyword */)); - if (flags & 2 /* Ambient */) - result.push(createModifier(135 /* DeclareKeyword */)); - if (flags & 512 /* Default */) - result.push(createModifier(88 /* DefaultKeyword */)); - if (flags & 2048 /* Const */) - result.push(createModifier(85 /* ConstKeyword */)); - if (flags & 4 /* Public */) - result.push(createModifier(123 /* PublicKeyword */)); - if (flags & 8 /* Private */) - result.push(createModifier(121 /* PrivateKeyword */)); - if (flags & 16 /* Protected */) - result.push(createModifier(122 /* ProtectedKeyword */)); - if (flags & 128 /* Abstract */) - result.push(createModifier(126 /* AbstractKeyword */)); - if (flags & 32 /* Static */) - result.push(createModifier(124 /* StaticKeyword */)); - if (flags & 16384 /* Override */) - result.push(createModifier(159 /* OverrideKeyword */)); - if (flags & 64 /* Readonly */) - result.push(createModifier(145 /* ReadonlyKeyword */)); - if (flags & 256 /* Async */) - result.push(createModifier(131 /* AsyncKeyword */)); - if (flags & 32768 /* In */) - result.push(createModifier(101 /* InKeyword */)); - if (flags & 65536 /* Out */) - result.push(createModifier(144 /* OutKeyword */)); + if (flags & 1 /* ModifierFlags.Export */) + result.push(createModifier(93 /* SyntaxKind.ExportKeyword */)); + if (flags & 2 /* ModifierFlags.Ambient */) + result.push(createModifier(135 /* SyntaxKind.DeclareKeyword */)); + if (flags & 512 /* ModifierFlags.Default */) + result.push(createModifier(88 /* SyntaxKind.DefaultKeyword */)); + if (flags & 2048 /* ModifierFlags.Const */) + result.push(createModifier(85 /* SyntaxKind.ConstKeyword */)); + if (flags & 4 /* ModifierFlags.Public */) + result.push(createModifier(123 /* SyntaxKind.PublicKeyword */)); + if (flags & 8 /* ModifierFlags.Private */) + result.push(createModifier(121 /* SyntaxKind.PrivateKeyword */)); + if (flags & 16 /* ModifierFlags.Protected */) + result.push(createModifier(122 /* SyntaxKind.ProtectedKeyword */)); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push(createModifier(126 /* SyntaxKind.AbstractKeyword */)); + if (flags & 32 /* ModifierFlags.Static */) + result.push(createModifier(124 /* SyntaxKind.StaticKeyword */)); + if (flags & 16384 /* ModifierFlags.Override */) + result.push(createModifier(159 /* SyntaxKind.OverrideKeyword */)); + if (flags & 64 /* ModifierFlags.Readonly */) + result.push(createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); + if (flags & 256 /* ModifierFlags.Async */) + result.push(createModifier(131 /* SyntaxKind.AsyncKeyword */)); + if (flags & 32768 /* ModifierFlags.In */) + result.push(createModifier(101 /* SyntaxKind.InKeyword */)); + if (flags & 65536 /* ModifierFlags.Out */) + result.push(createModifier(144 /* SyntaxKind.OutKeyword */)); return result.length ? result : undefined; } // @@ -23278,7 +23399,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(161 /* QualifiedName */); + var node = createBaseNode(161 /* SyntaxKind.QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -23295,12 +23416,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(162 /* ComputedPropertyName */); + var node = createBaseNode(162 /* SyntaxKind.ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 131072 /* ContainsComputedPropertyName */; + 1024 /* TransformFlags.ContainsES2015 */ | + 131072 /* TransformFlags.ContainsComputedPropertyName */; return node; } // @api @@ -23314,10 +23435,10 @@ var ts; // // @api function createTypeParameterDeclaration(modifiers, name, constraint, defaultType) { - var node = createBaseNamedDeclaration(163 /* TypeParameter */, modifiers, name); + var node = createBaseNamedDeclaration(163 /* SyntaxKind.TypeParameter */, modifiers, name); node.constraint = constraint; node.default = defaultType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23331,22 +23452,22 @@ var ts; } // @api function createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164 /* Parameter */, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(164 /* SyntaxKind.Parameter */, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.questionToken); if (questionToken) - node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) - node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ModifierFlags.ParameterPropertyModifier */) + node.transformFlags |= 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; } return node; } @@ -23363,13 +23484,13 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(165 /* Decorator */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseNode(165 /* SyntaxKind.Decorator */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 8192 /* ContainsTypeScriptClassSyntax */ | - 33554432 /* ContainsDecorators */; + 1 /* TransformFlags.ContainsTypeScript */ | + 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */ | + 33554432 /* TransformFlags.ContainsDecorators */; return node; } // @api @@ -23383,10 +23504,10 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(166 /* PropertySignature */, modifiers, name); + var node = createBaseNamedDeclaration(166 /* SyntaxKind.PropertySignature */, modifiers, name); node.type = type; node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.initializer = undefined; return node; @@ -23409,18 +23530,18 @@ var ts; } // @api function createPropertyDeclaration(modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(167 /* PropertyDeclaration */, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(167 /* SyntaxKind.PropertyDeclaration */, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 16777216 /* ContainsClassFields */; + 16777216 /* TransformFlags.ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */; } - if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23437,9 +23558,9 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168 /* MethodSignature */, modifiers, name, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(168 /* SyntaxKind.MethodSignature */, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23455,26 +23576,26 @@ var ts; } // @api function createMethodDeclaration(modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(169 /* MethodDeclaration */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(169 /* SyntaxKind.MethodDeclaration */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (questionToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } // The following properties are used only to report grammar errors node.exclamationToken = undefined; @@ -23501,12 +23622,12 @@ var ts; } // @api function createClassStaticBlockDeclaration(body) { - var node = createBaseGenericNamedDeclaration(170 /* ClassStaticBlockDeclaration */, + var node = createBaseGenericNamedDeclaration(170 /* SyntaxKind.ClassStaticBlockDeclaration */, /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined); node.body = body; - node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */; + node.transformFlags = propagateChildFlags(body) | 16777216 /* TransformFlags.ContainsClassFields */; // The following properties are used only to report grammar errors node.decorators = undefined; node.modifiers = undefined; @@ -23527,11 +23648,11 @@ var ts; } // @api function createConstructorDeclaration(modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(171 /* Constructor */, modifiers, + var node = createBaseFunctionLikeDeclaration(171 /* SyntaxKind.Constructor */, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; // The following properties are used only to report grammar errors node.decorators = undefined; node.typeParameters = undefined; @@ -23556,7 +23677,7 @@ var ts; } // @api function createGetAccessorDeclaration(modifiers, name, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(172 /* GetAccessor */, modifiers, name, + var node = createBaseFunctionLikeDeclaration(172 /* SyntaxKind.GetAccessor */, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); // The following properties are used only to report grammar errors node.typeParameters = undefined; @@ -23580,7 +23701,7 @@ var ts; } // @api function createSetAccessorDeclaration(modifiers, name, parameters, body) { - var node = createBaseFunctionLikeDeclaration(173 /* SetAccessor */, modifiers, name, + var node = createBaseFunctionLikeDeclaration(173 /* SyntaxKind.SetAccessor */, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); // The following properties are used only to report grammar errors @@ -23606,10 +23727,10 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* CallSignature */, + var node = createBaseSignatureDeclaration(174 /* SyntaxKind.CallSignature */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23622,10 +23743,10 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(175 /* SyntaxKind.ConstructSignature */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23638,10 +23759,10 @@ var ts; } // @api function createIndexSignature(modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(176 /* IndexSignature */, modifiers, + var node = createBaseSignatureDeclaration(176 /* SyntaxKind.IndexSignature */, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23654,10 +23775,10 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(199 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(199 /* SyntaxKind.TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23676,11 +23797,11 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(177 /* TypePredicate */); + var node = createBaseNode(177 /* SyntaxKind.TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23693,10 +23814,10 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(178 /* TypeReference */); + var node = createBaseNode(178 /* SyntaxKind.TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23708,10 +23829,10 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(179 /* FunctionType */, + var node = createBaseSignatureDeclaration(179 /* SyntaxKind.FunctionType */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.modifiers = undefined; return node; @@ -23741,9 +23862,9 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(180 /* ConstructorType */, modifiers, + var node = createBaseSignatureDeclaration(180 /* SyntaxKind.ConstructorType */, modifiers, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } /** @deprecated */ @@ -23774,10 +23895,10 @@ var ts; } // @api function createTypeQueryNode(exprName, typeArguments) { - var node = createBaseNode(181 /* TypeQuery */); + var node = createBaseNode(181 /* SyntaxKind.TypeQuery */); node.exprName = exprName; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23789,9 +23910,9 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(182 /* TypeLiteral */); + var node = createBaseNode(182 /* SyntaxKind.TypeLiteral */); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23802,9 +23923,9 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(183 /* ArrayType */); + var node = createBaseNode(183 /* SyntaxKind.ArrayType */); node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23815,9 +23936,9 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(184 /* TupleType */); + var node = createBaseNode(184 /* SyntaxKind.TupleType */); node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23828,12 +23949,12 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(197 /* NamedTupleMember */); + var node = createBaseNode(197 /* SyntaxKind.NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23847,9 +23968,9 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(185 /* OptionalType */); + var node = createBaseNode(185 /* SyntaxKind.OptionalType */); node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23860,9 +23981,9 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(186 /* RestType */); + var node = createBaseNode(186 /* SyntaxKind.RestType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23874,7 +23995,7 @@ var ts; function createUnionOrIntersectionTypeNode(kind, types, parenthesize) { var node = createBaseNode(kind); node.types = factory.createNodeArray(parenthesize(types)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateUnionOrIntersectionTypeNode(node, types, parenthesize) { @@ -23884,7 +24005,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); + return createUnionOrIntersectionTypeNode(187 /* SyntaxKind.UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); } // @api function updateUnionTypeNode(node, types) { @@ -23892,7 +24013,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); + return createUnionOrIntersectionTypeNode(188 /* SyntaxKind.IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); } // @api function updateIntersectionTypeNode(node, types) { @@ -23900,12 +24021,12 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(189 /* ConditionalType */); + var node = createBaseNode(189 /* SyntaxKind.ConditionalType */); node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType); node.trueType = trueType; node.falseType = falseType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23919,9 +24040,9 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(190 /* InferType */); + var node = createBaseNode(190 /* SyntaxKind.InferType */); node.typeParameter = typeParameter; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23932,10 +24053,10 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(198 /* TemplateLiteralType */); + var node = createBaseNode(198 /* SyntaxKind.TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23948,13 +24069,13 @@ var ts; // @api function createImportTypeNode(argument, assertions, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(200 /* ImportType */); + var node = createBaseNode(200 /* SyntaxKind.ImportType */); node.argument = argument; node.assertions = assertions; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23970,9 +24091,9 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(191 /* ParenthesizedType */); + var node = createBaseNode(191 /* SyntaxKind.ParenthesizedType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23983,18 +24104,18 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(192 /* ThisType */); - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseNode(192 /* SyntaxKind.ThisType */); + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(193 /* TypeOperator */); + var node = createBaseNode(193 /* SyntaxKind.TypeOperator */); node.operator = operator; - node.type = operator === 145 /* ReadonlyKeyword */ ? + node.type = operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) : parenthesizerRules().parenthesizeOperandOfTypeOperator(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24005,10 +24126,10 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(194 /* IndexedAccessType */); + var node = createBaseNode(194 /* SyntaxKind.IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType); node.indexType = indexType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24020,14 +24141,14 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) { - var node = createBaseNode(195 /* MappedType */); + var node = createBaseNode(195 /* SyntaxKind.MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; node.questionToken = questionToken; node.type = type; node.members = members && createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24043,9 +24164,9 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(196 /* LiteralType */); + var node = createBaseNode(196 /* SyntaxKind.LiteralType */); node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24059,16 +24180,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(201 /* ObjectBindingPattern */); + var node = createBaseNode(201 /* SyntaxKind.ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 524288 /* ContainsBindingPattern */; - if (node.transformFlags & 32768 /* ContainsRestOrSpread */) { + 1024 /* TransformFlags.ContainsES2015 */ | + 524288 /* TransformFlags.ContainsBindingPattern */; + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */) { node.transformFlags |= - 128 /* ContainsES2018 */ | - 65536 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 65536 /* TransformFlags.ContainsObjectRestOrSpread */; } return node; } @@ -24080,12 +24201,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(202 /* ArrayBindingPattern */); + var node = createBaseNode(202 /* SyntaxKind.ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 524288 /* ContainsBindingPattern */; + 1024 /* TransformFlags.ContainsES2015 */ | + 524288 /* TransformFlags.ContainsBindingPattern */; return node; } // @api @@ -24096,20 +24217,20 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(203 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(203 /* SyntaxKind.BindingElement */, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 32768 /* ContainsRestOrSpread */; + node.transformFlags |= 32768 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24131,7 +24252,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(204 /* ArrayLiteralExpression */); + var node = createBaseExpression(204 /* SyntaxKind.ArrayLiteralExpression */); // Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that // we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like // a trailing comma. @@ -24150,7 +24271,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(205 /* ObjectLiteralExpression */); + var node = createBaseExpression(205 /* SyntaxKind.ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -24164,20 +24285,20 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.name = asName(name); node.transformFlags = propagateChildFlags(node.expression) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); if (ts.isSuperKeyword(expression)) { // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24193,23 +24314,23 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 32 /* ContainsES2020 */ | + 32 /* TransformFlags.ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); return node; } // @api function updatePropertyAccessChain(node, expression, questionDotToken, name) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -24220,8 +24341,8 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | @@ -24230,8 +24351,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24247,21 +24368,21 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; return node; } // @api function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); // Because we are updating an existing ElementAccessChain we want to inherit its emitFlags // instead of using the default from createElementAccess return node.expression !== expression @@ -24272,8 +24393,8 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); node.transformFlags |= @@ -24281,13 +24402,13 @@ var ts; propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments); if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 8388608 /* ContainsDynamicImport */; + node.transformFlags |= 8388608 /* TransformFlags.ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 16384 /* ContainsLexicalThis */; + node.transformFlags |= 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24304,9 +24425,9 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -24315,18 +24436,18 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 16384 /* ContainsLexicalThis */; + node.transformFlags |= 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } // @api function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); return node.expression !== expression || node.questionDotToken !== questionDotToken || node.typeArguments !== typeArguments @@ -24336,7 +24457,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(209 /* NewExpression */); + var node = createBaseExpression(209 /* SyntaxKind.NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -24344,9 +24465,9 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24360,20 +24481,20 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(210 /* TaggedTemplateExpression */); - node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); + var node = createBaseExpression(210 /* SyntaxKind.TaggedTemplateExpression */); + node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false); node.typeArguments = asNodeArray(typeArguments); node.template = template; node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24387,13 +24508,13 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(211 /* TypeAssertionExpression */); + var node = createBaseExpression(211 /* SyntaxKind.TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24405,7 +24526,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(212 /* ParenthesizedExpression */); + var node = createBaseExpression(212 /* SyntaxKind.ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -24418,22 +24539,22 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(213 /* FunctionExpression */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(213 /* SyntaxKind.FunctionExpression */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -24451,14 +24572,14 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(214 /* ArrowFunction */, modifiers, + var node = createBaseFunctionLikeDeclaration(214 /* SyntaxKind.ArrowFunction */, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); - node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* SyntaxKind.EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 1024 /* ContainsES2015 */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */; + 1024 /* TransformFlags.ContainsES2015 */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */ | 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24475,7 +24596,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(215 /* DeleteExpression */); + var node = createBaseExpression(215 /* SyntaxKind.DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24488,7 +24609,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(216 /* TypeOfExpression */); + var node = createBaseExpression(216 /* SyntaxKind.TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24501,7 +24622,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(217 /* VoidExpression */); + var node = createBaseExpression(217 /* SyntaxKind.VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24514,13 +24635,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(218 /* AwaitExpression */); + var node = createBaseExpression(218 /* SyntaxKind.AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */ | - 2097152 /* ContainsAwait */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 2097152 /* TransformFlags.ContainsAwait */; return node; } // @api @@ -24531,17 +24652,17 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(219 /* PrefixUnaryExpression */); + var node = createBaseExpression(219 /* SyntaxKind.PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); // Only set this flag for non-generated identifiers and non-"local" names. See the // comment in `visitPreOrPostfixUnaryExpression` in module.ts - if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) && + if ((operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24553,7 +24674,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(220 /* PostfixUnaryExpression */); + var node = createBaseExpression(220 /* SyntaxKind.PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -24562,7 +24683,7 @@ var ts; if (ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24574,7 +24695,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(221 /* BinaryExpression */); + var node = createBaseExpression(221 /* SyntaxKind.BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -24584,46 +24705,49 @@ var ts; propagateChildFlags(node.left) | propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); - if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 32 /* ContainsES2020 */; + if (operatorKind === 60 /* SyntaxKind.QuestionQuestionToken */) { + node.transformFlags |= 32 /* TransformFlags.ContainsES2020 */; } - else if (operatorKind === 63 /* EqualsToken */) { + else if (operatorKind === 63 /* SyntaxKind.EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 512 /* ContainsES2016 */; + else if (operatorKind === 42 /* SyntaxKind.AsteriskAsteriskToken */ || operatorKind === 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 512 /* TransformFlags.ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 16 /* ContainsES2021 */; + node.transformFlags |= 16 /* TransformFlags.ContainsES2021 */; + } + if (operatorKind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { + node.transformFlags |= 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) - return 65536 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 128 /* ContainsES2018 */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) + return 65536 /* TransformFlags.ContainsObjectRestOrSpread */; + if (node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' // will not be correctly interpreted by the ES2018 transformer for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return 65536 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return 65536 /* TransformFlags.ContainsObjectRestOrSpread */; } - if (target.transformFlags & 128 /* ContainsES2018 */) { + if (target.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -24631,7 +24755,7 @@ var ts; } } } - return 0 /* None */; + return 0 /* TransformFlags.None */; } // @api function updateBinaryExpression(node, left, operator, right) { @@ -24643,11 +24767,11 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(222 /* ConditionalExpression */); + var node = createBaseExpression(222 /* SyntaxKind.ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); - node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); + node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* SyntaxKind.QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); - node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* ColonToken */); + node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* SyntaxKind.ColonToken */); node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse); node.transformFlags |= propagateChildFlags(node.condition) | @@ -24669,13 +24793,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(223 /* TemplateExpression */); + var node = createBaseExpression(223 /* SyntaxKind.TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24686,8 +24810,8 @@ var ts; : node; } function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) { - if (templateFlags === void 0) { templateFlags = 0 /* None */; } - ts.Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags."); + if (templateFlags === void 0) { templateFlags = 0 /* TokenFlags.None */; } + ts.Debug.assert(!(templateFlags & ~2048 /* TokenFlags.TemplateLiteralLikeFlags */), "Unsupported template flags."); // NOTE: without the assignment to `undefined`, we don't narrow the initial type of `cooked`. // eslint-disable-next-line no-undef-init var cooked = undefined; @@ -24713,41 +24837,41 @@ var ts; var node = createBaseToken(kind); node.text = text; node.rawText = rawText; - node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 1024 /* ContainsES2015 */; + node.templateFlags = templateFlags & 2048 /* TokenFlags.TemplateLiteralLikeFlags */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } // @api function createTemplateHead(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(15 /* TemplateHead */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(15 /* SyntaxKind.TemplateHead */, text, rawText, templateFlags); } // @api function createTemplateMiddle(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(16 /* TemplateMiddle */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(16 /* SyntaxKind.TemplateMiddle */, text, rawText, templateFlags); } // @api function createTemplateTail(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(17 /* TemplateTail */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(17 /* SyntaxKind.TemplateTail */, text, rawText, templateFlags); } // @api function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(14 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); } // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(224 /* YieldExpression */); + var node = createBaseExpression(224 /* SyntaxKind.YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 1048576 /* ContainsYield */; + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 1048576 /* TransformFlags.ContainsYield */; return node; } // @api @@ -24759,12 +24883,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(225 /* SpreadElement */); + var node = createBaseExpression(225 /* SyntaxKind.SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 32768 /* ContainsRestOrSpread */; + 1024 /* TransformFlags.ContainsES2015 */ | + 32768 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24775,8 +24899,8 @@ var ts; } // @api function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(226 /* ClassExpression */, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(226 /* SyntaxKind.ClassExpression */, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24791,17 +24915,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(227 /* OmittedExpression */); + return createBaseExpression(227 /* SyntaxKind.OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(228 /* ExpressionWithTypeArguments */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseNode(228 /* SyntaxKind.ExpressionWithTypeArguments */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24813,13 +24937,13 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(229 /* AsExpression */); + var node = createBaseExpression(229 /* SyntaxKind.AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24831,11 +24955,11 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24849,33 +24973,33 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function updateNonNullChain(node, expression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); return node.expression !== expression ? update(createNonNullChain(expression), node) : node; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(231 /* MetaProperty */); + var node = createBaseExpression(231 /* SyntaxKind.MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 103 /* NewKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 103 /* SyntaxKind.NewKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 100 /* ImportKeyword */: - node.transformFlags |= 4 /* ContainsESNext */; + case 100 /* SyntaxKind.ImportKeyword */: + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; break; default: return ts.Debug.assertNever(keywordToken); @@ -24893,13 +25017,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(233 /* TemplateSpan */); + var node = createBaseNode(233 /* SyntaxKind.TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24911,8 +25035,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(234 /* SemicolonClassElement */); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseNode(234 /* SyntaxKind.SemicolonClassElement */); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @@ -24920,7 +25044,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(235 /* Block */); + var node = createBaseNode(235 /* SyntaxKind.Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -24934,14 +25058,14 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(237 /* VariableStatement */); + var node = createBaseDeclaration(237 /* SyntaxKind.VariableStatement */); node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.declarationList); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24954,11 +25078,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(236 /* EmptyStatement */); + return createBaseNode(236 /* SyntaxKind.EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(238 /* ExpressionStatement */); + var node = createBaseNode(238 /* SyntaxKind.ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24971,7 +25095,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(239 /* IfStatement */); + var node = createBaseNode(239 /* SyntaxKind.IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -24991,7 +25115,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(240 /* DoStatement */); + var node = createBaseNode(240 /* SyntaxKind.DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -25008,7 +25132,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(241 /* WhileStatement */); + var node = createBaseNode(241 /* SyntaxKind.WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -25025,7 +25149,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(242 /* ForStatement */); + var node = createBaseNode(242 /* SyntaxKind.ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -25048,7 +25172,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(243 /* ForInStatement */); + var node = createBaseNode(243 /* SyntaxKind.ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -25068,7 +25192,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(244 /* ForOfStatement */); + var node = createBaseNode(244 /* SyntaxKind.ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -25078,9 +25202,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; return node; } // @api @@ -25094,11 +25218,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(245 /* ContinueStatement */); + var node = createBaseNode(245 /* SyntaxKind.ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -25109,11 +25233,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(246 /* BreakStatement */); + var node = createBaseNode(246 /* SyntaxKind.BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -25124,13 +25248,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(247 /* ReturnStatement */); + var node = createBaseNode(247 /* SyntaxKind.ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 128 /* TransformFlags.ContainsES2018 */ | + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -25141,7 +25265,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(248 /* WithStatement */); + var node = createBaseNode(248 /* SyntaxKind.WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -25158,7 +25282,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(249 /* SwitchStatement */); + var node = createBaseNode(249 /* SyntaxKind.SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -25175,7 +25299,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(250 /* LabeledStatement */); + var node = createBaseNode(250 /* SyntaxKind.LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -25192,7 +25316,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(251 /* ThrowStatement */); + var node = createBaseNode(251 /* SyntaxKind.ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -25205,7 +25329,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(252 /* TryStatement */); + var node = createBaseNode(252 /* SyntaxKind.TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -25225,16 +25349,16 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(253 /* DebuggerStatement */); + return createBaseNode(253 /* SyntaxKind.DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(254 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(254 /* SyntaxKind.VariableDeclaration */, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25249,17 +25373,17 @@ var ts; } // @api function createVariableDeclarationList(declarations, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(255 /* VariableDeclarationList */); - node.flags |= flags & 3 /* BlockScoped */; + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseNode(255 /* SyntaxKind.VariableDeclarationList */); + node.flags |= flags & 3 /* NodeFlags.BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; - if (flags & 3 /* BlockScoped */) { + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (flags & 3 /* NodeFlags.BlockScoped */) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBlockScopedBinding */; + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBlockScopedBinding */; } return node; } @@ -25271,25 +25395,25 @@ var ts; } // @api function createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(256 /* FunctionDeclaration */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(256 /* SyntaxKind.FunctionDeclaration */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; - if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } } // The following properties are used only to report grammar errors @@ -25317,14 +25441,14 @@ var ts; } // @api function createClassDeclaration(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(257 /* ClassDeclaration */, modifiers, name, typeParameters, heritageClauses, members); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseClassLikeDeclaration(257 /* SyntaxKind.ClassDeclaration */, modifiers, name, typeParameters, heritageClauses, members); + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { - node.transformFlags |= 1024 /* ContainsES2015 */; - if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; + if (node.transformFlags & 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } } return node; @@ -25341,9 +25465,9 @@ var ts; } // @api function createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(258 /* InterfaceDeclaration */, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(258 /* SyntaxKind.InterfaceDeclaration */, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25366,9 +25490,9 @@ var ts; } // @api function createTypeAliasDeclaration(modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(259 /* TypeAliasDeclaration */, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(259 /* SyntaxKind.TypeAliasDeclaration */, modifiers, name, typeParameters); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25390,12 +25514,12 @@ var ts; } // @api function createEnumDeclaration(modifiers, name, members) { - var node = createBaseNamedDeclaration(260 /* EnumDeclaration */, modifiers, name); + var node = createBaseNamedDeclaration(260 /* SyntaxKind.EnumDeclaration */, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25416,23 +25540,23 @@ var ts; } // @api function createModuleDeclaration(modifiers, name, body, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(261 /* ModuleDeclaration */); + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseDeclaration(261 /* SyntaxKind.ModuleDeclaration */); node.modifiers = asNodeArray(modifiers); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); + node.flags |= flags & (16 /* NodeFlags.Namespace */ | 4 /* NodeFlags.NestedNamespace */ | 1024 /* NodeFlags.GlobalAugmentation */); node.name = name; node.body = body; - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25453,7 +25577,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(262 /* ModuleBlock */); + var node = createBaseNode(262 /* SyntaxKind.ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -25466,7 +25590,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(263 /* CaseBlock */); + var node = createBaseNode(263 /* SyntaxKind.CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -25479,9 +25603,9 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(264 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(264 /* SyntaxKind.NamespaceExportDeclaration */, /*modifiers*/ undefined, name); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; node.modifiers = undefined; @@ -25502,13 +25626,13 @@ var ts; } // @api function createImportEqualsDeclaration(modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(265 /* ImportEqualsDeclaration */, modifiers, name); + var node = createBaseNamedDeclaration(265 /* SyntaxKind.ImportEqualsDeclaration */, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) - node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25530,7 +25654,7 @@ var ts; } // @api function createImportDeclaration(modifiers, importClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(266 /* ImportDeclaration */); + var node = createBaseDeclaration(266 /* SyntaxKind.ImportDeclaration */); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; @@ -25538,7 +25662,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25560,7 +25684,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(267 /* ImportClause */); + var node = createBaseNode(267 /* SyntaxKind.ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -25568,9 +25692,9 @@ var ts; propagateChildFlags(node.name) | propagateChildFlags(node.namedBindings); if (isTypeOnly) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25583,10 +25707,10 @@ var ts; } // @api function createAssertClause(elements, multiLine) { - var node = createBaseNode(293 /* AssertClause */); + var node = createBaseNode(293 /* SyntaxKind.AssertClause */); node.elements = createNodeArray(elements); node.multiLine = multiLine; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25598,10 +25722,10 @@ var ts; } // @api function createAssertEntry(name, value) { - var node = createBaseNode(294 /* AssertEntry */); + var node = createBaseNode(294 /* SyntaxKind.AssertEntry */); node.name = name; node.value = value; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25613,7 +25737,7 @@ var ts; } // @api function createImportTypeAssertionContainer(clause, multiLine) { - var node = createBaseNode(295 /* ImportTypeAssertionContainer */); + var node = createBaseNode(295 /* SyntaxKind.ImportTypeAssertionContainer */); node.assertClause = clause; node.multiLine = multiLine; return node; @@ -25627,10 +25751,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(268 /* NamespaceImport */); + var node = createBaseNode(268 /* SyntaxKind.NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25641,12 +25765,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(274 /* NamespaceExport */); + var node = createBaseNode(274 /* SyntaxKind.NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | - 4 /* ContainsESNext */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + 4 /* TransformFlags.ContainsESNext */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25657,10 +25781,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(269 /* NamedImports */); + var node = createBaseNode(269 /* SyntaxKind.NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25671,14 +25795,14 @@ var ts; } // @api function createImportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(270 /* ImportSpecifier */); + var node = createBaseNode(270 /* SyntaxKind.ImportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25691,14 +25815,14 @@ var ts; } // @api function createExportAssignment(modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(271 /* ExportAssignment */); + var node = createBaseDeclaration(271 /* SyntaxKind.ExportAssignment */); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* SyntaxKind.EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.expression); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25718,7 +25842,7 @@ var ts; } // @api function createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(272 /* ExportDeclaration */); + var node = createBaseDeclaration(272 /* SyntaxKind.ExportDeclaration */); node.modifiers = asNodeArray(modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; @@ -25728,7 +25852,7 @@ var ts; propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25751,10 +25875,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(273 /* NamedExports */); + var node = createBaseNode(273 /* SyntaxKind.NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25765,14 +25889,14 @@ var ts; } // @api function createExportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(275 /* ExportSpecifier */); + var node = createBaseNode(275 /* SyntaxKind.ExportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25785,7 +25909,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(276 /* MissingDeclaration */); + var node = createBaseDeclaration(276 /* SyntaxKind.MissingDeclaration */); return node; } // @@ -25793,10 +25917,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(277 /* ExternalModuleReference */); + var node = createBaseNode(277 /* SyntaxKind.ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25851,7 +25975,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(317 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(317 /* SyntaxKind.JSDocFunctionType */, /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); @@ -25867,7 +25991,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(322 /* JSDocTypeLiteral */); + var node = createBaseNode(322 /* SyntaxKind.JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -25881,7 +26005,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(309 /* JSDocTypeExpression */); + var node = createBaseNode(309 /* SyntaxKind.JSDocTypeExpression */); node.type = type; return node; } @@ -25893,7 +26017,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(323 /* JSDocSignature */); + var node = createBaseNode(323 /* SyntaxKind.JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -25922,7 +26046,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(344 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(344 /* SyntaxKind.JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -25939,7 +26063,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(345 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(345 /* SyntaxKind.JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25957,7 +26081,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(340 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(340 /* SyntaxKind.JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25978,7 +26102,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(347 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(347 /* SyntaxKind.JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25999,7 +26123,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(338 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(338 /* SyntaxKind.JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -26017,7 +26141,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(328 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(328 /* SyntaxKind.JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -26032,13 +26156,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(329 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(329 /* SyntaxKind.JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(346 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(346 /* SyntaxKind.JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -26052,7 +26176,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(310 /* JSDocNameReference */); + var node = createBaseNode(310 /* SyntaxKind.JSDocNameReference */); node.name = name; return node; } @@ -26064,7 +26188,7 @@ var ts; } // @api function createJSDocMemberName(left, right) { - var node = createBaseNode(311 /* JSDocMemberName */); + var node = createBaseNode(311 /* SyntaxKind.JSDocMemberName */); node.left = left; node.right = right; node.transformFlags |= @@ -26081,7 +26205,7 @@ var ts; } // @api function createJSDocLink(name, text) { - var node = createBaseNode(324 /* JSDocLink */); + var node = createBaseNode(324 /* SyntaxKind.JSDocLink */); node.name = name; node.text = text; return node; @@ -26094,7 +26218,7 @@ var ts; } // @api function createJSDocLinkCode(name, text) { - var node = createBaseNode(325 /* JSDocLinkCode */); + var node = createBaseNode(325 /* SyntaxKind.JSDocLinkCode */); node.name = name; node.text = text; return node; @@ -26107,7 +26231,7 @@ var ts; } // @api function createJSDocLinkPlain(name, text) { - var node = createBaseNode(326 /* JSDocLinkPlain */); + var node = createBaseNode(326 /* SyntaxKind.JSDocLinkPlain */); node.name = name; node.text = text; return node; @@ -26179,7 +26303,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(327 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(327 /* SyntaxKind.JSDocTag */, tagName, comment); return node; } // @api @@ -26191,7 +26315,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(321 /* JSDocText */); + var node = createBaseNode(321 /* SyntaxKind.JSDocText */); node.text = text; return node; } @@ -26203,7 +26327,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(320 /* JSDoc */); + var node = createBaseNode(320 /* SyntaxKind.JSDoc */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -26220,7 +26344,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(278 /* JsxElement */); + var node = createBaseNode(278 /* SyntaxKind.JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -26228,7 +26352,7 @@ var ts; propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26241,7 +26365,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(279 /* JsxSelfClosingElement */); + var node = createBaseNode(279 /* SyntaxKind.JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -26249,9 +26373,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -26265,7 +26389,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(280 /* JsxOpeningElement */); + var node = createBaseNode(280 /* SyntaxKind.JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -26273,9 +26397,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -26289,11 +26413,11 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(281 /* JsxClosingElement */); + var node = createBaseNode(281 /* SyntaxKind.JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26304,7 +26428,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(282 /* JsxFragment */); + var node = createBaseNode(282 /* SyntaxKind.JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -26312,7 +26436,7 @@ var ts; propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26325,10 +26449,10 @@ var ts; } // @api function createJsxText(text, containsOnlyTriviaWhiteSpaces) { - var node = createBaseNode(11 /* JsxText */); + var node = createBaseNode(11 /* SyntaxKind.JsxText */); node.text = text; node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces; - node.transformFlags |= 2 /* ContainsJsx */; + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26340,25 +26464,25 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(283 /* JsxOpeningFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(283 /* SyntaxKind.JsxOpeningFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(284 /* JsxClosingFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(284 /* SyntaxKind.JsxClosingFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(285 /* JsxAttribute */); + var node = createBaseNode(285 /* SyntaxKind.JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26370,11 +26494,11 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(286 /* JsxAttributes */); + var node = createBaseNode(286 /* SyntaxKind.JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26385,11 +26509,11 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(287 /* JsxSpreadAttribute */); + var node = createBaseNode(287 /* SyntaxKind.JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26400,13 +26524,13 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(288 /* JsxExpression */); + var node = createBaseNode(288 /* SyntaxKind.JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26420,7 +26544,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(289 /* CaseClause */); + var node = createBaseNode(289 /* SyntaxKind.CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -26437,7 +26561,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(290 /* DefaultClause */); + var node = createBaseNode(290 /* SyntaxKind.DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -26450,16 +26574,16 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(291 /* HeritageClause */); + var node = createBaseNode(291 /* SyntaxKind.HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 94 /* ExtendsKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 94 /* SyntaxKind.ExtendsKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 117 /* ImplementsKeyword */: - node.transformFlags |= 1 /* ContainsTypeScript */; + case 117 /* SyntaxKind.ImplementsKeyword */: + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; break; default: return ts.Debug.assertNever(token); @@ -26474,7 +26598,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(292 /* CatchClause */); + var node = createBaseNode(292 /* SyntaxKind.CatchClause */); if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) { variableDeclaration = createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, @@ -26487,7 +26611,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 64 /* ContainsES2019 */; + node.transformFlags |= 64 /* TransformFlags.ContainsES2019 */; return node; } // @api @@ -26502,7 +26626,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(296 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(296 /* SyntaxKind.PropertyAssignment */, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -26534,12 +26658,12 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(297 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(297 /* SyntaxKind.ShorthandPropertyAssignment */, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; // The following properties are used only to report grammar errors node.equalsToken = undefined; node.decorators = undefined; @@ -26568,12 +26692,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(298 /* SpreadAssignment */); + var node = createBaseNode(298 /* SyntaxKind.SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 65536 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 65536 /* TransformFlags.ContainsObjectRestOrSpread */; return node; } // @api @@ -26587,13 +26711,13 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(299 /* EnumMember */); + var node = createBaseNode(299 /* SyntaxKind.EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -26608,7 +26732,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -26625,7 +26749,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SourceFile */)); + var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */)); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -26664,7 +26788,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(306 /* Bundle */); + var node = createBaseNode(306 /* SyntaxKind.Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -26679,7 +26803,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(307 /* UnparsedSource */); + var node = createBaseNode(307 /* SyntaxKind.UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -26697,28 +26821,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(300 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(300 /* SyntaxKind.UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(301 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(301 /* SyntaxKind.UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 303 /* UnparsedInternalText */ : 302 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 303 /* SyntaxKind.UnparsedInternalText */ : 302 /* SyntaxKind.UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(304 /* UnparsedSyntheticReference */); + var node = createBaseNode(304 /* SyntaxKind.UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(308 /* InputFiles */); + var node = createBaseNode(308 /* SyntaxKind.InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -26729,7 +26853,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(232 /* SyntheticExpression */); + var node = createBaseNode(232 /* SyntaxKind.SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -26737,7 +26861,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(348 /* SyntaxList */); + var node = createBaseNode(348 /* SyntaxKind.SyntaxList */); node._children = children; return node; } @@ -26752,7 +26876,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(349 /* NotEmittedStatement */); + var node = createBaseNode(349 /* SyntaxKind.NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -26766,12 +26890,12 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(350 /* PartiallyEmittedExpression */); + var node = createBaseNode(350 /* SyntaxKind.PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -26794,7 +26918,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(351 /* CommaListExpression */); + var node = createBaseNode(351 /* SyntaxKind.CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -26811,7 +26935,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(353 /* EndOfDeclarationMarker */); + var node = createBaseNode(353 /* SyntaxKind.EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -26822,14 +26946,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(352 /* MergeDeclarationMarker */); + var node = createBaseNode(352 /* SyntaxKind.MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(354 /* SyntheticReferenceExpression */); + var node = createBaseNode(354 /* SyntaxKind.SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -26851,12 +26975,12 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); - clone.flags |= (node.flags & ~8 /* Synthesized */); + clone.flags |= (node.flags & ~8 /* NodeFlags.Synthesized */); clone.transformFlags = node.transformFlags; setOriginalNode(clone, node); for (var key in node) { @@ -26968,11 +27092,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 212 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 211 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 229 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 230 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 350 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 212 /* SyntaxKind.ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 211 /* SyntaxKind.TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 229 /* SyntaxKind.AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 230 /* SyntaxKind.NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -26998,7 +27122,7 @@ var ts; && !ts.some(ts.getSyntheticTrailingComments(node)); } function restoreOuterExpressions(outerExpression, innerExpression, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression)); } @@ -27019,20 +27143,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cacheIdentifiers; - case 108 /* ThisKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return false; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -27040,7 +27164,7 @@ var ts; } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } - var callee = ts.skipOuterExpressions(expression, 15 /* All */); + var callee = ts.skipOuterExpressions(expression, 15 /* OuterExpressionKinds.All */); var thisArg; var target; if (ts.isSuperProperty(callee)) { @@ -27049,13 +27173,13 @@ var ts; } else if (ts.isSuperKeyword(callee)) { thisArg = createThis(); - target = languageVersion !== undefined && languageVersion < 2 /* ES2015 */ + target = languageVersion !== undefined && languageVersion < 2 /* ScriptTarget.ES2015 */ ? ts.setTextRange(createIdentifier("_super"), callee) : callee; } - else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + else if (ts.getEmitFlags(callee) & 4096 /* EmitFlags.HelperName */) { thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false); } else if (ts.isPropertyAccessExpression(callee)) { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { @@ -27084,7 +27208,7 @@ var ts; else { // for `a()` target is `a` and thisArg is `void 0` thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); } return { target: target, thisArg: thisArg }; } @@ -27118,9 +27242,9 @@ var ts; var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent); emitFlags |= ts.getEmitFlags(nodeName); if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(name, emitFlags); return name; @@ -27139,7 +27263,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getInternalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */ | 32768 /* EmitFlags.InternalName */); } /** * Gets the local name of a declaration. This is primarily used for declarations that can be @@ -27152,7 +27276,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */); } /** * Gets the export name of a declaration. This is primarily used for declarations that can be @@ -27165,7 +27289,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192 /* ExportName */); + return getName(node, allowComments, allowSourceMaps, 8192 /* EmitFlags.ExportName */); } /** * Gets the name of a declaration for use in declarations. @@ -27190,9 +27314,9 @@ var ts; ts.setTextRange(qualifiedName, name); var emitFlags = 0; if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; @@ -27209,7 +27333,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -27267,7 +27391,7 @@ var ts; var numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) { + if (ts.getEmitFlags(statement) & 1048576 /* EmitFlags.CustomPrologue */ && filter(statement)) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -27458,52 +27582,52 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 343 /* JSDocTypeTag */: return "type"; - case 341 /* JSDocReturnTag */: return "returns"; - case 342 /* JSDocThisTag */: return "this"; - case 339 /* JSDocEnumTag */: return "enum"; - case 330 /* JSDocAuthorTag */: return "author"; - case 332 /* JSDocClassTag */: return "class"; - case 333 /* JSDocPublicTag */: return "public"; - case 334 /* JSDocPrivateTag */: return "private"; - case 335 /* JSDocProtectedTag */: return "protected"; - case 336 /* JSDocReadonlyTag */: return "readonly"; - case 337 /* JSDocOverrideTag */: return "override"; - case 344 /* JSDocTemplateTag */: return "template"; - case 345 /* JSDocTypedefTag */: return "typedef"; - case 340 /* JSDocParameterTag */: return "param"; - case 347 /* JSDocPropertyTag */: return "prop"; - case 338 /* JSDocCallbackTag */: return "callback"; - case 328 /* JSDocAugmentsTag */: return "augments"; - case 329 /* JSDocImplementsTag */: return "implements"; + case 343 /* SyntaxKind.JSDocTypeTag */: return "type"; + case 341 /* SyntaxKind.JSDocReturnTag */: return "returns"; + case 342 /* SyntaxKind.JSDocThisTag */: return "this"; + case 339 /* SyntaxKind.JSDocEnumTag */: return "enum"; + case 330 /* SyntaxKind.JSDocAuthorTag */: return "author"; + case 332 /* SyntaxKind.JSDocClassTag */: return "class"; + case 333 /* SyntaxKind.JSDocPublicTag */: return "public"; + case 334 /* SyntaxKind.JSDocPrivateTag */: return "private"; + case 335 /* SyntaxKind.JSDocProtectedTag */: return "protected"; + case 336 /* SyntaxKind.JSDocReadonlyTag */: return "readonly"; + case 337 /* SyntaxKind.JSDocOverrideTag */: return "override"; + case 344 /* SyntaxKind.JSDocTemplateTag */: return "template"; + case 345 /* SyntaxKind.JSDocTypedefTag */: return "typedef"; + case 340 /* SyntaxKind.JSDocParameterTag */: return "param"; + case 347 /* SyntaxKind.JSDocPropertyTag */: return "prop"; + case 338 /* SyntaxKind.JSDocCallbackTag */: return "callback"; + case 328 /* SyntaxKind.JSDocAugmentsTag */: return "augments"; + case 329 /* SyntaxKind.JSDocImplementsTag */: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; var invalidValueSentinel = {}; function getCookedText(kind, rawText) { if (!rawTextScanner) { - rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + rawTextScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); } switch (kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: rawTextScanner.setText("`" + rawText + "`"); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: rawTextScanner.setText("}" + rawText + "`"); break; } var token = rawTextScanner.scan(); - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false); } if (rawTextScanner.isUnterminated()) { @@ -27512,14 +27636,14 @@ var ts; } var tokenValue; switch (token) { - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: tokenValue = rawTextScanner.getTokenValue(); break; } - if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* SyntaxKind.EndOfFileToken */) { rawTextScanner.setText(undefined); return invalidValueSentinel; } @@ -27528,22 +27652,22 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 134234112 /* TransformFlags.PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) - return 0 /* None */; + return 0 /* TransformFlags.None */; var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind); return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags; } function propagateChildrenFlags(children) { - return children ? children.transformFlags : 0 /* None */; + return children ? children.transformFlags : 0 /* TransformFlags.None */; } function aggregateChildrenFlags(children) { - var subtreeFlags = 0 /* None */; + var subtreeFlags = 0 /* TransformFlags.None */; for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { var child = children_2[_i]; subtreeFlags |= propagateChildFlags(child); @@ -27555,78 +27679,78 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) { - return -2 /* TypeExcludes */; + if (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) { + return -2 /* TransformFlags.TypeExcludes */; } switch (kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 204 /* ArrayLiteralExpression */: - return 536903680 /* ArrayLiteralOrCallOrNewExcludes */; - case 261 /* ModuleDeclaration */: - return 742678528 /* ModuleExcludes */; - case 164 /* Parameter */: - return 536870912 /* ParameterExcludes */; - case 214 /* ArrowFunction */: - return 612179968 /* ArrowFunctionExcludes */; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - return 746414080 /* FunctionExcludes */; - case 255 /* VariableDeclarationList */: - return 537460736 /* VariableDeclarationListExcludes */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return 537010176 /* ClassExcludes */; - case 171 /* Constructor */: - return 746405888 /* ConstructorExcludes */; - case 167 /* PropertyDeclaration */: - return 671105024 /* PropertyExcludes */; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return 679297024 /* MethodOrAccessorExcludes */; - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 150 /* StringKeyword */: - case 148 /* ObjectKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 163 /* TypeParameter */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return -2 /* TypeExcludes */; - case 205 /* ObjectLiteralExpression */: - return 537075712 /* ObjectLiteralExcludes */; - case 292 /* CatchClause */: - return 536936448 /* CatchClauseExcludes */; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - return 536903680 /* BindingPatternExcludes */; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - case 350 /* PartiallyEmittedExpression */: - case 212 /* ParenthesizedExpression */: - case 106 /* SuperKeyword */: - return 536870912 /* OuterExpressionExcludes */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - return 536870912 /* PropertyAccessExcludes */; + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return -2147450880 /* TransformFlags.ArrayLiteralOrCallOrNewExcludes */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return -1941676032 /* TransformFlags.ModuleExcludes */; + case 164 /* SyntaxKind.Parameter */: + return -2147483648 /* TransformFlags.ParameterExcludes */; + case 214 /* SyntaxKind.ArrowFunction */: + return -2072174592 /* TransformFlags.ArrowFunctionExcludes */; + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return -1937940480 /* TransformFlags.FunctionExcludes */; + case 255 /* SyntaxKind.VariableDeclarationList */: + return -2146893824 /* TransformFlags.VariableDeclarationListExcludes */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return -2147344384 /* TransformFlags.ClassExcludes */; + case 171 /* SyntaxKind.Constructor */: + return -1937948672 /* TransformFlags.ConstructorExcludes */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return -2013249536 /* TransformFlags.PropertyExcludes */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return -2005057536 /* TransformFlags.MethodOrAccessorExcludes */; + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 163 /* SyntaxKind.TypeParameter */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return -2 /* TransformFlags.TypeExcludes */; + case 205 /* SyntaxKind.ObjectLiteralExpression */: + return -2147278848 /* TransformFlags.ObjectLiteralExcludes */; + case 292 /* SyntaxKind.CatchClause */: + return -2147418112 /* TransformFlags.CatchClauseExcludes */; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return -2147450880 /* TransformFlags.BindingPatternExcludes */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 106 /* SyntaxKind.SuperKeyword */: + return -2147483648 /* TransformFlags.OuterExpressionExcludes */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + return -2147483648 /* TransformFlags.PropertyAccessExcludes */; default: - return 536870912 /* NodeExcludes */; + return -2147483648 /* TransformFlags.NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; var baseFactory = ts.createBaseNodeFactory(); function makeSynthetic(node) { - node.flags |= 8 /* Synthesized */; + node.flags |= 8 /* NodeFlags.Synthesized */; return node; } var syntheticFactory = { @@ -27636,7 +27760,7 @@ var ts; createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); }, createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); }, }; - ts.factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory); + ts.factory = createNodeFactory(4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */, syntheticFactory); function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { var stripInternal; var bundleFileInfo; @@ -27699,50 +27823,50 @@ var ts; for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "prologue" /* Prologue */: + case "prologue" /* BundleFileSectionKind.Prologue */: prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section)); break; - case "emitHelpers" /* EmitHelpers */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data)); break; - case "no-default-lib" /* NoDefaultLib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: hasNoDefaultLib = true; break; - case "reference" /* Reference */: + case "reference" /* BundleFileSectionKind.Reference */: referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data }); break; - case "type" /* Type */: + case "type" /* BundleFileSectionKind.Type */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "type-import" /* TypeResolutionModeImport */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext }); break; - case "type-require" /* TypeResolutionModeRequire */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS }); break; - case "lib" /* Lib */: + case "lib" /* BundleFileSectionKind.Lib */: libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "prepend" /* Prepend */: + case "prepend" /* BundleFileSectionKind.Prepend */: var prependTexts = void 0; for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { var text = _c[_b]; - if (!stripInternal || text.kind !== "internal" /* Internal */) { - prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* Internal */), text)); + if (!stripInternal || text.kind !== "internal" /* BundleFileSectionKind.Internal */) { + prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* BundleFileSectionKind.Internal */), text)); } } prependChildren = ts.addRange(prependChildren, prependTexts); texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray)); break; - case "internal" /* Internal */: + case "internal" /* BundleFileSectionKind.Internal */: if (stripInternal) { if (!texts) texts = []; break; } // falls through - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; default: ts.Debug.assertNever(section); @@ -27770,22 +27894,22 @@ var ts; for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "internal" /* Internal */: - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "internal" /* BundleFileSectionKind.Internal */: + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; - case "no-default-lib" /* NoDefaultLib */: - case "reference" /* Reference */: - case "type" /* Type */: - case "type-import" /* TypeResolutionModeImport */: - case "type-require" /* TypeResolutionModeRequire */: - case "lib" /* Lib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: + case "reference" /* BundleFileSectionKind.Reference */: + case "type" /* BundleFileSectionKind.Type */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: + case "lib" /* BundleFileSectionKind.Lib */: syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section)); break; // Ignore - case "prologue" /* Prologue */: - case "emitHelpers" /* EmitHelpers */: - case "prepend" /* Prepend */: + case "prologue" /* BundleFileSectionKind.Prologue */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: + case "prepend" /* BundleFileSectionKind.Prepend */: break; default: ts.Debug.assertNever(section); @@ -27813,7 +27937,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -27882,7 +28006,7 @@ var ts; if (trailingComments) destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) - destEmitNode.flags = flags & ~268435456 /* Immutable */; + destEmitNode.flags = flags & ~268435456 /* EmitFlags.Immutable */; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) @@ -27924,7 +28048,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -27933,7 +28057,7 @@ var ts; node.emitNode = {}; } else { - ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node."); + ts.Debug.assert(!(node.emitNode.flags & 268435456 /* EmitFlags.Immutable */), "Invalid attempt to mutate an immutable node."); } return node.emitNode; } @@ -27965,7 +28089,7 @@ var ts; */ function removeAllComments(node) { var emitNode = getOrCreateEmitNode(node); - emitNode.flags |= 1536 /* NoComments */; + emitNode.flags |= 1536 /* EmitFlags.NoComments */; emitNode.leadingComments = undefined; emitNode.trailingComments = undefined; return node; @@ -28201,7 +28325,7 @@ var ts; ts.setSnippetElement = setSnippetElement; /* @internal */ function ignoreSourceNewlines(node) { - getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; + getOrCreateEmitNode(node).flags |= 134217728 /* EmitFlags.IgnoreSourceNewlines */; return node; } ts.ignoreSourceNewlines = ignoreSourceNewlines; @@ -28224,8 +28348,8 @@ var ts; (function (ts) { function createEmitHelperFactory(context) { var factory = context.factory; - var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); }); - var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); }); + var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* EmitFlags.Immutable */); }); + var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* EmitFlags.Immutable */); }); return { getUnscopedHelperName: getUnscopedHelperName, // TypeScript Helpers @@ -28266,7 +28390,7 @@ var ts; * Gets an identifier for the name of an *unscoped* emit helper. */ function getUnscopedHelperName(name) { - return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* EmitFlags.HelperName */ | 2 /* EmitFlags.AdviseOnEmitNode */); } // TypeScript Helpers function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) { @@ -28301,7 +28425,7 @@ var ts; } // ES2018 Helpers function createAssignHelper(attributesSegments) { - if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } @@ -28317,7 +28441,7 @@ var ts; context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28371,13 +28495,13 @@ var ts; function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28390,7 +28514,7 @@ var ts; function createExtendsHelper(name) { context.requestEmitHelper(ts.extendsHelper); return factory.createCallExpression(getUnscopedHelperName("__extends"), - /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]); + /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)]); } function createTemplateObjectHelper(cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); @@ -28480,13 +28604,13 @@ var ts; /* @internal */ function compareEmitHelpers(x, y) { if (x === y) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === y.priority) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; if (y.priority === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; @@ -28893,7 +29017,7 @@ var ts; function isCallToHelper(firstSegment, helperName) { return ts.isCallExpression(firstSegment) && ts.isIdentifier(firstSegment.expression) - && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0 + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* EmitFlags.HelperName */) !== 0 && firstSegment.expression.escapedText === helperName; } ts.isCallToHelper = isCallToHelper; @@ -28902,750 +29026,750 @@ var ts; (function (ts) { // Literals function isNumericLiteral(node) { - return node.kind === 8 /* NumericLiteral */; + return node.kind === 8 /* SyntaxKind.NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; function isBigIntLiteral(node) { - return node.kind === 9 /* BigIntLiteral */; + return node.kind === 9 /* SyntaxKind.BigIntLiteral */; } ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 10 /* StringLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 11 /* JsxText */; + return node.kind === 11 /* SyntaxKind.JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 13 /* RegularExpressionLiteral */; + return node.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 15 /* TemplateHead */; + return node.kind === 15 /* SyntaxKind.TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 16 /* TemplateMiddle */; + return node.kind === 16 /* SyntaxKind.TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 17 /* TemplateTail */; + return node.kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateTail = isTemplateTail; // Punctuation function isDotDotDotToken(node) { - return node.kind === 25 /* DotDotDotToken */; + return node.kind === 25 /* SyntaxKind.DotDotDotToken */; } ts.isDotDotDotToken = isDotDotDotToken; /*@internal*/ function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; + return node.kind === 27 /* SyntaxKind.CommaToken */; } ts.isCommaToken = isCommaToken; function isPlusToken(node) { - return node.kind === 39 /* PlusToken */; + return node.kind === 39 /* SyntaxKind.PlusToken */; } ts.isPlusToken = isPlusToken; function isMinusToken(node) { - return node.kind === 40 /* MinusToken */; + return node.kind === 40 /* SyntaxKind.MinusToken */; } ts.isMinusToken = isMinusToken; function isAsteriskToken(node) { - return node.kind === 41 /* AsteriskToken */; + return node.kind === 41 /* SyntaxKind.AsteriskToken */; } ts.isAsteriskToken = isAsteriskToken; /*@internal*/ function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + return node.kind === 53 /* SyntaxKind.ExclamationToken */; } ts.isExclamationToken = isExclamationToken; /*@internal*/ function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + return node.kind === 57 /* SyntaxKind.QuestionToken */; } ts.isQuestionToken = isQuestionToken; /*@internal*/ function isColonToken(node) { - return node.kind === 58 /* ColonToken */; + return node.kind === 58 /* SyntaxKind.ColonToken */; } ts.isColonToken = isColonToken; /*@internal*/ function isQuestionDotToken(node) { - return node.kind === 28 /* QuestionDotToken */; + return node.kind === 28 /* SyntaxKind.QuestionDotToken */; } ts.isQuestionDotToken = isQuestionDotToken; /*@internal*/ function isEqualsGreaterThanToken(node) { - return node.kind === 38 /* EqualsGreaterThanToken */; + return node.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */; } ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 79 /* Identifier */; + return node.kind === 79 /* SyntaxKind.Identifier */; } ts.isIdentifier = isIdentifier; function isPrivateIdentifier(node) { - return node.kind === 80 /* PrivateIdentifier */; + return node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; // Reserved Words /* @internal */ function isExportModifier(node) { - return node.kind === 93 /* ExportKeyword */; + return node.kind === 93 /* SyntaxKind.ExportKeyword */; } ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 131 /* AsyncKeyword */; + return node.kind === 131 /* SyntaxKind.AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ function isAssertsKeyword(node) { - return node.kind === 128 /* AssertsKeyword */; + return node.kind === 128 /* SyntaxKind.AssertsKeyword */; } ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 132 /* AwaitKeyword */; + return node.kind === 132 /* SyntaxKind.AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 145 /* ReadonlyKeyword */; + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ function isStaticModifier(node) { - return node.kind === 124 /* StaticKeyword */; + return node.kind === 124 /* SyntaxKind.StaticKeyword */; } ts.isStaticModifier = isStaticModifier; /* @internal */ function isAbstractModifier(node) { - return node.kind === 126 /* AbstractKeyword */; + return node.kind === 126 /* SyntaxKind.AbstractKeyword */; } ts.isAbstractModifier = isAbstractModifier; /* @internal */ function isOverrideModifier(node) { - return node.kind === 159 /* OverrideKeyword */; + return node.kind === 159 /* SyntaxKind.OverrideKeyword */; } ts.isOverrideModifier = isOverrideModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 106 /* SuperKeyword */; + return node.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 100 /* ImportKeyword */; + return node.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 161 /* QualifiedName */; + return node.kind === 161 /* SyntaxKind.QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 162 /* ComputedPropertyName */; + return node.kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 163 /* TypeParameter */; + return node.kind === 163 /* SyntaxKind.TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 164 /* Parameter */; + return node.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 166 /* PropertySignature */; + return node.kind === 166 /* SyntaxKind.PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 167 /* PropertyDeclaration */; + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 168 /* MethodSignature */; + return node.kind === 168 /* SyntaxKind.MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassStaticBlockDeclaration(node) { - return node.kind === 170 /* ClassStaticBlockDeclaration */; + return node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 171 /* Constructor */; + return node.kind === 171 /* SyntaxKind.Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 174 /* CallSignature */; + return node.kind === 174 /* SyntaxKind.CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 175 /* ConstructSignature */; + return node.kind === 175 /* SyntaxKind.ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 176 /* IndexSignature */; + return node.kind === 176 /* SyntaxKind.IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 177 /* TypePredicate */; + return node.kind === 177 /* SyntaxKind.TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 178 /* TypeReference */; + return node.kind === 178 /* SyntaxKind.TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 179 /* FunctionType */; + return node.kind === 179 /* SyntaxKind.FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 180 /* ConstructorType */; + return node.kind === 180 /* SyntaxKind.ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 182 /* TypeLiteral */; + return node.kind === 182 /* SyntaxKind.TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 183 /* ArrayType */; + return node.kind === 183 /* SyntaxKind.ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 184 /* TupleType */; + return node.kind === 184 /* SyntaxKind.TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 197 /* NamedTupleMember */; + return node.kind === 197 /* SyntaxKind.NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 185 /* OptionalType */; + return node.kind === 185 /* SyntaxKind.OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 186 /* RestType */; + return node.kind === 186 /* SyntaxKind.RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 187 /* UnionType */; + return node.kind === 187 /* SyntaxKind.UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 188 /* IntersectionType */; + return node.kind === 188 /* SyntaxKind.IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 189 /* ConditionalType */; + return node.kind === 189 /* SyntaxKind.ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 190 /* InferType */; + return node.kind === 190 /* SyntaxKind.InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 191 /* ParenthesizedType */; + return node.kind === 191 /* SyntaxKind.ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 192 /* ThisType */; + return node.kind === 192 /* SyntaxKind.ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 193 /* TypeOperator */; + return node.kind === 193 /* SyntaxKind.TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 194 /* IndexedAccessType */; + return node.kind === 194 /* SyntaxKind.IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 195 /* MappedType */; + return node.kind === 195 /* SyntaxKind.MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 196 /* LiteralType */; + return node.kind === 196 /* SyntaxKind.LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 200 /* ImportType */; + return node.kind === 200 /* SyntaxKind.ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 199 /* TemplateLiteralTypeSpan */; + return node.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 198 /* TemplateLiteralType */; + return node.kind === 198 /* SyntaxKind.TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 201 /* ObjectBindingPattern */; + return node.kind === 201 /* SyntaxKind.ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 202 /* ArrayBindingPattern */; + return node.kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 203 /* BindingElement */; + return node.kind === 203 /* SyntaxKind.BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 204 /* ArrayLiteralExpression */; + return node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 205 /* ObjectLiteralExpression */; + return node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 207 /* ElementAccessExpression */; + return node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 208 /* CallExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 209 /* NewExpression */; + return node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 210 /* TaggedTemplateExpression */; + return node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 212 /* ParenthesizedExpression */; + return node.kind === 212 /* SyntaxKind.ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 213 /* FunctionExpression */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 214 /* ArrowFunction */; + return node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 215 /* DeleteExpression */; + return node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 216 /* TypeOfExpression */; + return node.kind === 216 /* SyntaxKind.TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 217 /* VoidExpression */; + return node.kind === 217 /* SyntaxKind.VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 218 /* AwaitExpression */; + return node.kind === 218 /* SyntaxKind.AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 219 /* PrefixUnaryExpression */; + return node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 220 /* PostfixUnaryExpression */; + return node.kind === 220 /* SyntaxKind.PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 221 /* BinaryExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 222 /* ConditionalExpression */; + return node.kind === 222 /* SyntaxKind.ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 223 /* TemplateExpression */; + return node.kind === 223 /* SyntaxKind.TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 224 /* YieldExpression */; + return node.kind === 224 /* SyntaxKind.YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 225 /* SpreadElement */; + return node.kind === 225 /* SyntaxKind.SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 226 /* ClassExpression */; + return node.kind === 226 /* SyntaxKind.ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 227 /* OmittedExpression */; + return node.kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 229 /* AsExpression */; + return node.kind === 229 /* SyntaxKind.AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 230 /* NonNullExpression */; + return node.kind === 230 /* SyntaxKind.NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 231 /* MetaProperty */; + return node.kind === 231 /* SyntaxKind.MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 232 /* SyntheticExpression */; + return node.kind === 232 /* SyntaxKind.SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 350 /* PartiallyEmittedExpression */; + return node.kind === 350 /* SyntaxKind.PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 351 /* CommaListExpression */; + return node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 233 /* TemplateSpan */; + return node.kind === 233 /* SyntaxKind.TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 234 /* SemicolonClassElement */; + return node.kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 235 /* Block */; + return node.kind === 235 /* SyntaxKind.Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 237 /* VariableStatement */; + return node.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 236 /* EmptyStatement */; + return node.kind === 236 /* SyntaxKind.EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 238 /* ExpressionStatement */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 239 /* IfStatement */; + return node.kind === 239 /* SyntaxKind.IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 240 /* DoStatement */; + return node.kind === 240 /* SyntaxKind.DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 241 /* WhileStatement */; + return node.kind === 241 /* SyntaxKind.WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 242 /* ForStatement */; + return node.kind === 242 /* SyntaxKind.ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 243 /* ForInStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 244 /* ForOfStatement */; + return node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 245 /* ContinueStatement */; + return node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 246 /* BreakStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 247 /* ReturnStatement */; + return node.kind === 247 /* SyntaxKind.ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 248 /* WithStatement */; + return node.kind === 248 /* SyntaxKind.WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 249 /* SwitchStatement */; + return node.kind === 249 /* SyntaxKind.SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 250 /* LabeledStatement */; + return node.kind === 250 /* SyntaxKind.LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 251 /* ThrowStatement */; + return node.kind === 251 /* SyntaxKind.ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 252 /* TryStatement */; + return node.kind === 252 /* SyntaxKind.TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 253 /* DebuggerStatement */; + return node.kind === 253 /* SyntaxKind.DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 255 /* VariableDeclarationList */; + return node.kind === 255 /* SyntaxKind.VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 256 /* FunctionDeclaration */; + return node.kind === 256 /* SyntaxKind.FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 257 /* ClassDeclaration */; + return node.kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 258 /* InterfaceDeclaration */; + return node.kind === 258 /* SyntaxKind.InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 259 /* TypeAliasDeclaration */; + return node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 260 /* EnumDeclaration */; + return node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 262 /* ModuleBlock */; + return node.kind === 262 /* SyntaxKind.ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 263 /* CaseBlock */; + return node.kind === 263 /* SyntaxKind.CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 264 /* NamespaceExportDeclaration */; + return node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 266 /* ImportDeclaration */; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 267 /* ImportClause */; + return node.kind === 267 /* SyntaxKind.ImportClause */; } ts.isImportClause = isImportClause; function isImportTypeAssertionContainer(node) { - return node.kind === 295 /* ImportTypeAssertionContainer */; + return node.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */; } ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer; function isAssertClause(node) { - return node.kind === 293 /* AssertClause */; + return node.kind === 293 /* SyntaxKind.AssertClause */; } ts.isAssertClause = isAssertClause; function isAssertEntry(node) { - return node.kind === 294 /* AssertEntry */; + return node.kind === 294 /* SyntaxKind.AssertEntry */; } ts.isAssertEntry = isAssertEntry; function isNamespaceImport(node) { - return node.kind === 268 /* NamespaceImport */; + return node.kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 274 /* NamespaceExport */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 269 /* NamedImports */; + return node.kind === 269 /* SyntaxKind.NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 270 /* ImportSpecifier */; + return node.kind === 270 /* SyntaxKind.ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 271 /* ExportAssignment */; + return node.kind === 271 /* SyntaxKind.ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 272 /* ExportDeclaration */; + return node.kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 273 /* NamedExports */; + return node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 275 /* ExportSpecifier */; + return node.kind === 275 /* SyntaxKind.ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 276 /* MissingDeclaration */; + return node.kind === 276 /* SyntaxKind.MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 349 /* NotEmittedStatement */; + return node.kind === 349 /* SyntaxKind.NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 354 /* SyntheticReferenceExpression */; + return node.kind === 354 /* SyntaxKind.SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 352 /* MergeDeclarationMarker */; + return node.kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 353 /* EndOfDeclarationMarker */; + return node.kind === 353 /* SyntaxKind.EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 277 /* ExternalModuleReference */; + return node.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 278 /* JsxElement */; + return node.kind === 278 /* SyntaxKind.JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 279 /* JsxSelfClosingElement */; + return node.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 280 /* JsxOpeningElement */; + return node.kind === 280 /* SyntaxKind.JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 281 /* JsxClosingElement */; + return node.kind === 281 /* SyntaxKind.JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 282 /* JsxFragment */; + return node.kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 283 /* JsxOpeningFragment */; + return node.kind === 283 /* SyntaxKind.JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 284 /* JsxClosingFragment */; + return node.kind === 284 /* SyntaxKind.JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 285 /* JsxAttribute */; + return node.kind === 285 /* SyntaxKind.JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 286 /* JsxAttributes */; + return node.kind === 286 /* SyntaxKind.JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 287 /* JsxSpreadAttribute */; + return node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 288 /* JsxExpression */; + return node.kind === 288 /* SyntaxKind.JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 289 /* CaseClause */; + return node.kind === 289 /* SyntaxKind.CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 290 /* DefaultClause */; + return node.kind === 290 /* SyntaxKind.DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 291 /* HeritageClause */; + return node.kind === 291 /* SyntaxKind.HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 292 /* CatchClause */; + return node.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 296 /* PropertyAssignment */; + return node.kind === 296 /* SyntaxKind.PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */; + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 298 /* SpreadAssignment */; + return node.kind === 298 /* SyntaxKind.SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 301 /* UnparsedPrepend */; + return node.kind === 301 /* SyntaxKind.UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -29653,176 +29777,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 305 /* SourceFile */; + return node.kind === 305 /* SyntaxKind.SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 306 /* Bundle */; + return node.kind === 306 /* SyntaxKind.Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 307 /* UnparsedSource */; + return node.kind === 307 /* SyntaxKind.UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 309 /* JSDocTypeExpression */; + return node.kind === 309 /* SyntaxKind.JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 310 /* JSDocNameReference */; + return node.kind === 310 /* SyntaxKind.JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; function isJSDocMemberName(node) { - return node.kind === 311 /* JSDocMemberName */; + return node.kind === 311 /* SyntaxKind.JSDocMemberName */; } ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 324 /* JSDocLink */; + return node.kind === 324 /* SyntaxKind.JSDocLink */; } ts.isJSDocLink = isJSDocLink; function isJSDocLinkCode(node) { - return node.kind === 325 /* JSDocLinkCode */; + return node.kind === 325 /* SyntaxKind.JSDocLinkCode */; } ts.isJSDocLinkCode = isJSDocLinkCode; function isJSDocLinkPlain(node) { - return node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 312 /* JSDocAllType */; + return node.kind === 312 /* SyntaxKind.JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 313 /* JSDocUnknownType */; + return node.kind === 313 /* SyntaxKind.JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 314 /* JSDocNullableType */; + return node.kind === 314 /* SyntaxKind.JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 315 /* JSDocNonNullableType */; + return node.kind === 315 /* SyntaxKind.JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 316 /* JSDocOptionalType */; + return node.kind === 316 /* SyntaxKind.JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 317 /* JSDocFunctionType */; + return node.kind === 317 /* SyntaxKind.JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 318 /* JSDocVariadicType */; + return node.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 319 /* JSDocNamepathType */; + return node.kind === 319 /* SyntaxKind.JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 320 /* JSDoc */; + return node.kind === 320 /* SyntaxKind.JSDoc */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 322 /* JSDocTypeLiteral */; + return node.kind === 322 /* SyntaxKind.JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 323 /* JSDocSignature */; + return node.kind === 323 /* SyntaxKind.JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 328 /* JSDocAugmentsTag */; + return node.kind === 328 /* SyntaxKind.JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 330 /* JSDocAuthorTag */; + return node.kind === 330 /* SyntaxKind.JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 332 /* JSDocClassTag */; + return node.kind === 332 /* SyntaxKind.JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 338 /* JSDocCallbackTag */; + return node.kind === 338 /* SyntaxKind.JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 333 /* JSDocPublicTag */; + return node.kind === 333 /* SyntaxKind.JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 334 /* JSDocPrivateTag */; + return node.kind === 334 /* SyntaxKind.JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 335 /* JSDocProtectedTag */; + return node.kind === 335 /* SyntaxKind.JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 336 /* JSDocReadonlyTag */; + return node.kind === 336 /* SyntaxKind.JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 337 /* JSDocOverrideTag */; + return node.kind === 337 /* SyntaxKind.JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 331 /* JSDocDeprecatedTag */; + return node.kind === 331 /* SyntaxKind.JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 346 /* JSDocSeeTag */; + return node.kind === 346 /* SyntaxKind.JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 339 /* JSDocEnumTag */; + return node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 340 /* JSDocParameterTag */; + return node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 341 /* JSDocReturnTag */; + return node.kind === 341 /* SyntaxKind.JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 342 /* JSDocThisTag */; + return node.kind === 342 /* SyntaxKind.JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 343 /* JSDocTypeTag */; + return node.kind === 343 /* SyntaxKind.JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 344 /* JSDocTemplateTag */; + return node.kind === 344 /* SyntaxKind.JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 345 /* JSDocTypedefTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 327 /* JSDocTag */; + return node.kind === 327 /* SyntaxKind.JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 347 /* JSDocPropertyTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 329 /* JSDocImplementsTag */; + return node.kind === 329 /* SyntaxKind.JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 348 /* SyntaxList */; + return n.kind === 348 /* SyntaxKind.SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -29842,7 +29966,7 @@ var ts; var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); - ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; + ts.getOrCreateEmitNode(expression).flags |= 64 /* EmitFlags.NoNestedSourceMaps */; return expression; } } @@ -30021,14 +30145,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -30067,7 +30191,7 @@ var ts; */ function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) { var operator = node.operator; - ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); + ts.Debug.assert(operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); var temp = factory.createTempVariable(recordTempVariable); expression = factory.createAssignment(temp, expression); ts.setTextRange(expression, node.operand); @@ -30092,14 +30216,14 @@ var ts; * Gets whether an identifier should only be referred to by its internal name. */ function isInternalName(node) { - return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + return (ts.getEmitFlags(node) & 32768 /* EmitFlags.InternalName */) !== 0; } ts.isInternalName = isInternalName; /** * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* EmitFlags.LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -30107,7 +30231,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* EmitFlags.ExportName */) !== 0; } ts.isExportName = isExportName; function isUseStrictPrologue(node) { @@ -30136,8 +30260,8 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 351 /* CommaListExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || + node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isJSDocTypeAssertion(node) { @@ -30153,26 +30277,26 @@ var ts; } ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType; function isOuterExpression(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } switch (node.kind) { - case 212 /* ParenthesizedExpression */: - if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { + case 212 /* SyntaxKind.ParenthesizedExpression */: + if (kinds & 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { return false; } - return (kinds & 1 /* Parentheses */) !== 0; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - return (kinds & 2 /* TypeAssertions */) !== 0; - case 230 /* NonNullExpression */: - return (kinds & 4 /* NonNullAssertions */) !== 0; - case 350 /* PartiallyEmittedExpression */: - return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; + return (kinds & 1 /* OuterExpressionKinds.Parentheses */) !== 0; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + return (kinds & 2 /* OuterExpressionKinds.TypeAssertions */) !== 0; + case 230 /* SyntaxKind.NonNullExpression */: + return (kinds & 4 /* OuterExpressionKinds.NonNullAssertions */) !== 0; + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + return (kinds & 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */) !== 0; } return false; } ts.isOuterExpression = isOuterExpression; function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } while (isOuterExpression(node, kinds)) { node = node.expression; } @@ -30180,7 +30304,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - return skipOuterExpressions(node, 6 /* Assertions */); + return skipOuterExpressions(node, 6 /* OuterExpressionKinds.Assertions */); } ts.skipAssertions = skipAssertions; function startOnNewLine(node) { @@ -30241,7 +30365,7 @@ var ts; var externalHelpersImportDeclaration = nodeFactory.createImportDeclaration( /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), /*assertClause*/ undefined); - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* EmitFlags.NeverApplyImportHelper */); return externalHelpersImportDeclaration; } } @@ -30286,10 +30410,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 266 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 266 /* SyntaxKind.ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 272 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -30408,7 +30532,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -30420,11 +30544,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -30456,12 +30580,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 225 /* SpreadElement */: - case 298 /* SpreadAssignment */: + case 225 /* SyntaxKind.SpreadElement */: + case 298 /* SyntaxKind.SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -30479,7 +30603,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -30494,7 +30618,7 @@ var ts; : propertyName; } break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -30509,7 +30633,7 @@ var ts; : propertyName; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -30524,21 +30648,21 @@ var ts; ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */; } /** * Gets the elements of a BindingOrAssignmentPattern */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -30559,86 +30683,86 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveIllegalType(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 173 /* SetAccessor */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.canHaveIllegalType = canHaveIllegalType; function canHaveIllegalTypeParameters(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.canHaveIllegalTypeParameters = canHaveIllegalTypeParameters; function canHaveDecorators(node) { var kind = node.kind; - return kind === 164 /* Parameter */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 226 /* ClassExpression */ - || kind === 257 /* ClassDeclaration */; + return kind === 164 /* SyntaxKind.Parameter */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.canHaveDecorators = canHaveDecorators; function canHaveIllegalDecorators(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 237 /* VariableStatement */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.canHaveIllegalDecorators = canHaveIllegalDecorators; function canHaveModifiers(node) { var kind = node.kind; - return kind === 163 /* TypeParameter */ - || kind === 164 /* Parameter */ - || kind === 166 /* PropertySignature */ - || kind === 167 /* PropertyDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 169 /* MethodDeclaration */ - || kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 180 /* ConstructorType */ - || kind === 213 /* FunctionExpression */ - || kind === 214 /* ArrowFunction */ - || kind === 226 /* ClassExpression */ - || kind === 237 /* VariableStatement */ - || kind === 256 /* FunctionDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 272 /* ExportDeclaration */; + return kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 180 /* SyntaxKind.ConstructorType */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; function canHaveIllegalModifiers(node) { var kind = node.kind; - return kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 179 /* FunctionType */ - || kind === 276 /* MissingDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 179 /* SyntaxKind.FunctionType */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.canHaveIllegalModifiers = canHaveIllegalModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -30649,68 +30773,68 @@ var ts; ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); function isLiteralTypeLikeExpression(node) { var kind = node.kind; - return kind === 104 /* NullKeyword */ - || kind === 110 /* TrueKeyword */ - || kind === 95 /* FalseKeyword */ + return kind === 104 /* SyntaxKind.NullKeyword */ + || kind === 110 /* SyntaxKind.TrueKeyword */ + || kind === 95 /* SyntaxKind.FalseKeyword */ || ts.isLiteralExpression(node) || ts.isPrefixUnaryExpression(node); } ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; function isExponentiationOperator(kind) { - return kind === 42 /* AsteriskAsteriskToken */; + return kind === 42 /* SyntaxKind.AsteriskAsteriskToken */; } function isMultiplicativeOperator(kind) { - return kind === 41 /* AsteriskToken */ - || kind === 43 /* SlashToken */ - || kind === 44 /* PercentToken */; + return kind === 41 /* SyntaxKind.AsteriskToken */ + || kind === 43 /* SyntaxKind.SlashToken */ + || kind === 44 /* SyntaxKind.PercentToken */; } function isMultiplicativeOperatorOrHigher(kind) { return isExponentiationOperator(kind) || isMultiplicativeOperator(kind); } function isAdditiveOperator(kind) { - return kind === 39 /* PlusToken */ - || kind === 40 /* MinusToken */; + return kind === 39 /* SyntaxKind.PlusToken */ + || kind === 40 /* SyntaxKind.MinusToken */; } function isAdditiveOperatorOrHigher(kind) { return isAdditiveOperator(kind) || isMultiplicativeOperatorOrHigher(kind); } function isShiftOperator(kind) { - return kind === 47 /* LessThanLessThanToken */ - || kind === 48 /* GreaterThanGreaterThanToken */ - || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */; + return kind === 47 /* SyntaxKind.LessThanLessThanToken */ + || kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ + || kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } function isShiftOperatorOrHigher(kind) { return isShiftOperator(kind) || isAdditiveOperatorOrHigher(kind); } function isRelationalOperator(kind) { - return kind === 29 /* LessThanToken */ - || kind === 32 /* LessThanEqualsToken */ - || kind === 31 /* GreaterThanToken */ - || kind === 33 /* GreaterThanEqualsToken */ - || kind === 102 /* InstanceOfKeyword */ - || kind === 101 /* InKeyword */; + return kind === 29 /* SyntaxKind.LessThanToken */ + || kind === 32 /* SyntaxKind.LessThanEqualsToken */ + || kind === 31 /* SyntaxKind.GreaterThanToken */ + || kind === 33 /* SyntaxKind.GreaterThanEqualsToken */ + || kind === 102 /* SyntaxKind.InstanceOfKeyword */ + || kind === 101 /* SyntaxKind.InKeyword */; } function isRelationalOperatorOrHigher(kind) { return isRelationalOperator(kind) || isShiftOperatorOrHigher(kind); } function isEqualityOperator(kind) { - return kind === 34 /* EqualsEqualsToken */ - || kind === 36 /* EqualsEqualsEqualsToken */ - || kind === 35 /* ExclamationEqualsToken */ - || kind === 37 /* ExclamationEqualsEqualsToken */; + return kind === 34 /* SyntaxKind.EqualsEqualsToken */ + || kind === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ + || kind === 35 /* SyntaxKind.ExclamationEqualsToken */ + || kind === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } function isEqualityOperatorOrHigher(kind) { return isEqualityOperator(kind) || isRelationalOperatorOrHigher(kind); } function isBitwiseOperator(kind) { - return kind === 50 /* AmpersandToken */ - || kind === 51 /* BarToken */ - || kind === 52 /* CaretToken */; + return kind === 50 /* SyntaxKind.AmpersandToken */ + || kind === 51 /* SyntaxKind.BarToken */ + || kind === 52 /* SyntaxKind.CaretToken */; } function isBitwiseOperatorOrHigher(kind) { return isBitwiseOperator(kind) @@ -30718,21 +30842,21 @@ var ts; } // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. function isLogicalOperator(kind) { - return kind === 55 /* AmpersandAmpersandToken */ - || kind === 56 /* BarBarToken */; + return kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || kind === 56 /* SyntaxKind.BarBarToken */; } function isLogicalOperatorOrHigher(kind) { return isLogicalOperator(kind) || isBitwiseOperatorOrHigher(kind); } function isAssignmentOperatorOrHigher(kind) { - return kind === 60 /* QuestionQuestionToken */ + return kind === 60 /* SyntaxKind.QuestionQuestionToken */ || isLogicalOperatorOrHigher(kind) || ts.isAssignmentOperator(kind); } function isBinaryOperator(kind) { return isAssignmentOperatorOrHigher(kind) - || kind === 27 /* CommaToken */; + || kind === 27 /* SyntaxKind.CommaToken */; } function isBinaryOperatorToken(node) { return isBinaryOperator(node.kind); @@ -30865,7 +30989,7 @@ var ts; return stackIndex; } function checkCircularity(stackIndex, nodeStack, node) { - if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + if (ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */)) { while (stackIndex >= 0) { ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); stackIndex--; @@ -30954,7 +31078,7 @@ var ts; createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); }, }; /* @internal */ - ts.parseNodeFactory = ts.createNodeFactory(1 /* NoParenthesizerRules */, ts.parseBaseNodeFactory); + ts.parseNodeFactory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.parseBaseNodeFactory); function visitNode(cbNode, node) { return node && cbNode(node); } @@ -30974,9 +31098,9 @@ var ts; } /*@internal*/ function isJSDocLikeText(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 42 /* asterisk */ && - text.charCodeAt(start + 3) !== 47 /* slash */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 3) !== 47 /* CharacterCodes.slash */; } ts.isJSDocLikeText = isJSDocLikeText; /*@internal*/ @@ -30988,14 +31112,14 @@ var ts; } ts.isFileProbablyExternalModule = isFileProbablyExternalModule; function isAnExternalModuleIndicatorNode(node) { - return ts.canHaveModifiers(node) && hasModifierOfKind(node, 93 /* ExportKeyword */) + return ts.canHaveModifiers(node) && hasModifierOfKind(node, 93 /* SyntaxKind.ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) || ts.isExportDeclaration(node) ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */ ? walkTreeForImportMeta(sourceFile) : undefined; } @@ -31007,7 +31131,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && node.name.escapedText === "meta"; } /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes @@ -31023,20 +31147,20 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 160 /* LastToken */) { + if (!node || node.kind <= 160 /* SyntaxKind.LastToken */) { return; } switch (node.kind) { - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -31044,67 +31168,67 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitNode(cbNode, node.expression); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.initializer); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || @@ -31114,14 +31238,14 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -31129,21 +31253,21 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -31152,7 +31276,7 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || @@ -31160,357 +31284,357 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return visitNode(cbNode, node.exprName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return visitNode(cbNode, node.elementType); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return visitNode(cbNode, node.typeParameter); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.assertions) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: return visitNode(cbNode, node.assertClause); - case 191 /* ParenthesizedType */: - case 193 /* TypeOperator */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 193 /* SyntaxKind.TypeOperator */: return visitNode(cbNode, node.type); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNodes(cbNode, cbNodes, node.members); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return visitNode(cbNode, node.literal); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitNode(cbNode, node.expression); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return visitNode(cbNode, node.expression); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitNode(cbNode, node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitNode(cbNode, node.expression); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return visitNode(cbNode, node.expression); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitNode(cbNode, node.name); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitNode(cbNode, node.expression); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitNode(cbNode, node.expression); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitNode(cbNode, node.label); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitNode(cbNode, node.expression); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return visitNode(cbNode, node.expression); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return visitNode(cbNode, node.expression); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return visitNodes(cbNode, cbNodes, node.elements); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.value); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNode(cbNode, node.name); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return visitNode(cbNode, node.name); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return visitNode(cbNode, node.name); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 185 /* OptionalType */: - case 186 /* RestType */: - case 309 /* JSDocTypeExpression */: - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 316 /* JSDocOptionalType */: - case 318 /* JSDocVariadicType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return visitNode(cbNode, node.type); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return visitNode(cbNode, node.name); - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || @@ -31519,64 +31643,64 @@ var ts; : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 330 /* JSDocAuthorTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 309 /* JSDocTypeExpression */ + node.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: - case 331 /* JSDocDeprecatedTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -31625,7 +31749,7 @@ var ts; continue; return res; } - if (current.kind >= 161 /* FirstNode */) { + if (current.kind >= 161 /* SyntaxKind.FirstNode */) { // add children in reverse order to the queue, so popping gives the first child for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { var child = _a[_i]; @@ -31650,13 +31774,13 @@ var ts; } function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat; - if (languageVersion === 100 /* JSON */) { - result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop); + if (languageVersion === 100 /* ScriptTarget.JSON */) { + result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* ScriptKind.JSON */, ts.noop); } else { var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) { @@ -31704,7 +31828,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -31732,8 +31856,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks // tslint:disable variable-name var NodeConstructor; @@ -31755,7 +31879,7 @@ var ts; createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)); }, createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); } }; - var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory); + var factory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */ | 2 /* NodeFactoryFlags.NoNodeConverters */ | 8 /* NodeFactoryFlags.NoOriginalNode */, baseNodeFactory); var fileName; var sourceFlags; var sourceText; @@ -31853,7 +31977,7 @@ var ts; var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); - if (scriptKind === 6 /* JSON */) { + if (scriptKind === 6 /* ScriptKind.JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); result_3.referencedFiles = ts.emptyArray; @@ -31872,25 +31996,25 @@ var ts; Parser.parseSourceFile = parseSourceFile; function parseIsolatedEntityName(content, languageVersion) { // Choice of `isDeclarationFile` should be arbitrary - initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* ScriptKind.JS */); // Prime the scanner. nextToken(); var entityName = parseEntityName(/*allowReservedWords*/ true); - var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + var isInvalid = token() === 1 /* SyntaxKind.EndOfFileToken */ && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; } Parser.parseIsolatedEntityName = parseIsolatedEntityName; function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { - if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; } + if (languageVersion === void 0) { languageVersion = 2 /* ScriptTarget.ES2015 */; } if (setParentNodes === void 0) { setParentNodes = false; } - initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* JSON */); + initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* ScriptKind.JSON */); sourceFlags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); var statements, endOfFileToken; - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { statements = createNodeArray([], pos, pos); endOfFileToken = parseTokenNode(); } @@ -31898,28 +32022,28 @@ var ts; // Loop and synthesize an ArrayLiteralExpression if there are more than // one top-level expressions to ensure all input text is consumed. var expressions = void 0; - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var expression_1 = void 0; switch (token()) { - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: expression_1 = parseArrayLiteralExpression(); break; - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: expression_1 = parseTokenNode(); break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + case 40 /* SyntaxKind.MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* SyntaxKind.NumericLiteral */ && nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parsePrefixUnaryExpression(); } else { expression_1 = parseObjectLiteralExpression(); } break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parseLiteralNode(); break; } @@ -31937,7 +32061,7 @@ var ts; } else { expressions = expression_1; - if (token() !== 1 /* EndOfFileToken */) { + if (token() !== 1 /* SyntaxKind.EndOfFileToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } } @@ -31946,10 +32070,10 @@ var ts; var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); - endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token); + endOfFileToken = parseExpectedToken(1 /* SyntaxKind.EndOfFileToken */, ts.Diagnostics.Unexpected_token); } // Set source file so that errors will be reported with this file name - var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); + var sourceFile = createSourceFile(fileName, 2 /* ScriptTarget.ES2015 */, 6 /* ScriptKind.JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); if (setParentNodes) { fixupParentReferences(sourceFile); } @@ -31986,15 +32110,15 @@ var ts; sourceFlags = 0; topLevel = true; switch (scriptKind) { - case 1 /* JS */: - case 2 /* JSX */: - contextFlags = 262144 /* JavaScriptFile */; + case 1 /* ScriptKind.JS */: + case 2 /* ScriptKind.JSX */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */; break; - case 6 /* JSON */: - contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */; + case 6 /* ScriptKind.JSON */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */ | 67108864 /* NodeFlags.JsonFile */; break; default: - contextFlags = 0 /* None */; + contextFlags = 0 /* NodeFlags.None */; break; } parseErrorBeforeNextFinishedNode = false; @@ -32026,13 +32150,13 @@ var ts; function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 16777216 /* Ambient */; + contextFlags |= 16777216 /* NodeFlags.Ambient */; } sourceFlags = contextFlags; // Prime the scanner. nextToken(); - var statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token() === 1 /* EndOfFileToken */); + var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement); + ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */); var endOfFileToken = addJSDocComment(parseTokenNode()); var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator); // A member of ReadonlyArray isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future @@ -32065,7 +32189,7 @@ var ts; node.jsDoc = jsDoc; if (hasDeprecatedTag) { hasDeprecatedTag = false; - node.flags |= 268435456 /* Deprecated */; + node.flags |= 268435456 /* NodeFlags.Deprecated */; } return node; } @@ -32093,12 +32217,12 @@ var ts; // reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones. speculationHelper(function () { var savedContextFlags = contextFlags; - contextFlags |= 32768 /* AwaitContext */; + contextFlags |= 32768 /* NodeFlags.AwaitContext */; scanner.setTextPos(nextStatement.pos); nextToken(); - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var startPos = scanner.getStartPos(); - var statement = parseListElement(0 /* SourceElements */, parseStatement); + var statement = parseListElement(0 /* ParsingContext.SourceElements */, parseStatement); statements.push(statement); if (startPos === scanner.getStartPos()) { nextToken(); @@ -32116,7 +32240,7 @@ var ts; } } contextFlags = savedContextFlags; - }, 2 /* Reparse */); + }, 2 /* SpeculationKind.Reparse */); // find the next statement containing an `await` start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1; }; @@ -32136,8 +32260,8 @@ var ts; syntaxCursor = savedSyntaxCursor; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { - return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */); + return !(node.flags & 32768 /* NodeFlags.AwaitContext */) + && !!(node.transformFlags & 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -32178,7 +32302,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setFields(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); setFields(sourceFile); } @@ -32205,16 +32329,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 4096 /* DisallowInContext */); + setContextFlag(val, 4096 /* NodeFlags.DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 8192 /* YieldContext */); + setContextFlag(val, 8192 /* NodeFlags.YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 16384 /* DecoratorContext */); + setContextFlag(val, 16384 /* NodeFlags.DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 32768 /* AwaitContext */); + setContextFlag(val, 32768 /* NodeFlags.AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -32255,52 +32379,52 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(4096 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(4096 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function allowConditionalTypesAnd(func) { - return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doOutsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function disallowConditionalTypesAnd(func) { - return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doInsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(8192 /* YieldContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(16384 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* NodeFlags.DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(32768 /* AwaitContext */, func); + return doInsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(32768 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(8192 /* YieldContext */); + return inContext(8192 /* NodeFlags.YieldContext */); } function inDisallowInContext() { - return inContext(4096 /* DisallowInContext */); + return inContext(4096 /* NodeFlags.DisallowInContext */); } function inDisallowConditionalTypesContext() { - return inContext(65536 /* DisallowConditionalTypesContext */); + return inContext(65536 /* NodeFlags.DisallowConditionalTypesContext */); } function inDecoratorContext() { - return inContext(16384 /* DecoratorContext */); + return inContext(16384 /* NodeFlags.DecoratorContext */); } function inAwaitContext() { - return inContext(32768 /* AwaitContext */); + return inContext(32768 /* NodeFlags.AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -32401,15 +32525,15 @@ var ts; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the // same. - var result = speculationKind !== 0 /* TryParse */ + var result = speculationKind !== 0 /* SpeculationKind.TryParse */ ? scanner.lookAhead(callback) : scanner.tryScan(callback); ts.Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. - if (!result || speculationKind !== 0 /* TryParse */) { + if (!result || speculationKind !== 0 /* SpeculationKind.TryParse */) { currentToken = saveToken; - if (speculationKind !== 2 /* Reparse */) { + if (speculationKind !== 2 /* SpeculationKind.Reparse */) { parseDiagnostics.length = saveParseDiagnosticsLength; } parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -32421,7 +32545,7 @@ var ts; * is returned from this function. */ function lookAhead(callback) { - return speculationHelper(callback, 1 /* Lookahead */); + return speculationHelper(callback, 1 /* SpeculationKind.Lookahead */); } /** Invokes the provided callback. If the callback returns something falsy, then it restores * the parser to the state it was in immediately prior to invoking the callback. If the @@ -32429,31 +32553,31 @@ var ts; * of invoking the callback is returned from this function. */ function tryParse(callback) { - return speculationHelper(callback, 0 /* TryParse */); + return speculationHelper(callback, 0 /* SpeculationKind.TryParse */); } function isBindingIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder. - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 125 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* SyntaxKind.YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -32491,7 +32615,7 @@ var ts; // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined; if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } var pos = ts.skipTrivia(sourceText, node.pos); @@ -32506,17 +32630,17 @@ var ts; // If a declared node failed to parse, it would have emitted a diagnostic already. return; case "interface": - parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "is": parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; case "module": case "namespace": - parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "type": - parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */); + parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* SyntaxKind.EqualsToken */); return; } // The user alternatively might have misspelled or forgotten to add a space after a common keyword. @@ -32526,7 +32650,7 @@ var ts; return; } // Unknown tokens are handled with their own errors in the scanner - if (token() === 0 /* Unknown */) { + if (token() === 0 /* SyntaxKind.Unknown */) { return; } // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. @@ -32551,24 +32675,24 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; } function parseSemicolonAfterPropertyName(name, type, initializer) { - if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 59 /* SyntaxKind.AtToken */ && !scanner.hasPrecedingLineBreak()) { parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); return; } - if (token() === 20 /* OpenParenToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); nextToken(); return; } if (type && !canParseSemicolon()) { if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); } else { parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer); @@ -32579,7 +32703,7 @@ var ts; return; } if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } parseErrorForMissingSemicolonAfter(name); @@ -32646,24 +32770,24 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 1 /* SyntaxKind.EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function tryParseSemicolon() { if (!canParseSemicolon()) { return false; } - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } function parseSemicolon() { - return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */); + return tryParseSemicolon() || parseExpected(26 /* SyntaxKind.SemicolonToken */); } function createNodeArray(elements, pos, end, hasTrailingComma) { var array = factory.createNodeArray(elements, hasTrailingComma); @@ -32680,7 +32804,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 131072 /* ThisNodeHasError */; + node.flags |= 131072 /* NodeFlags.ThisNodeHasError */; } return node; } @@ -32692,11 +32816,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* SyntaxKind.Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 276 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : + kind === 276 /* SyntaxKind.MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -32720,23 +32844,23 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(/*isIdentifier*/ true); } - if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) { + if (token() === 0 /* SyntaxKind.Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* SyntaxKind.Identifier */; })) { // Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser. return createIdentifier(/*isIdentifier*/ true); } identifierCount++; // Only for end of file because the error gets reported incorrectly on embedded script tags. - var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + var reportAtCurrentPosition = token() === 1 /* SyntaxKind.EndOfFileToken */; var isReservedWord = scanner.isReservedWord(); var msgArg = scanner.getTokenText(); var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* SyntaxKind.Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -32749,23 +32873,23 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */; } function isAssertionKey() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ || token() === 8 /* SyntaxKind.NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -32778,12 +32902,12 @@ var ts; // LiteralPropertyName // ComputedPropertyName[?Yield] var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. var expression = allowInAnd(parseExpression); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createComputedPropertyName(expression), pos); } function internPrivateIdentifier(text) { @@ -32811,23 +32935,23 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 92 /* EnumKeyword */; - case 93 /* ExportKeyword */: + return nextToken() === 92 /* SyntaxKind.EnumKeyword */; + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); - if (token() === 88 /* DefaultKeyword */) { + if (token() === 88 /* SyntaxKind.DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 152 /* TypeKeyword */) { + if (token() === 152 /* SyntaxKind.TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 124 /* StaticKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -32835,9 +32959,9 @@ var ts; } } function canFollowExportModifier() { - return token() !== 41 /* AsteriskToken */ - && token() !== 127 /* AsKeyword */ - && token() !== 18 /* OpenBraceToken */ + return token() !== 41 /* SyntaxKind.AsteriskToken */ + && token() !== 127 /* SyntaxKind.AsKeyword */ + && token() !== 18 /* SyntaxKind.OpenBraceToken */ && canFollowModifier(); } function nextTokenCanFollowExportModifier() { @@ -32848,18 +32972,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 22 /* OpenBracketToken */ - || token() === 18 /* OpenBraceToken */ - || token() === 41 /* AsteriskToken */ - || token() === 25 /* DotDotDotToken */ + return token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 41 /* SyntaxKind.AsteriskToken */ + || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || - token() === 118 /* InterfaceKeyword */ || - (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* SyntaxKind.ClassKeyword */ || token() === 98 /* SyntaxKind.FunctionKeyword */ || + token() === 118 /* SyntaxKind.InterfaceKeyword */ || + (token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -32868,50 +32992,50 @@ var ts; return true; } switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 2 /* SwitchClauses */: - return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 4 /* TypeMembers */: + return !(token() === 26 /* SyntaxKind.SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + case 2 /* ParsingContext.SwitchClauses */: + return token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 4 /* ParsingContext.TypeMembers */: return lookAhead(isTypeMemberStart); - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); - case 6 /* EnumMembers */: + return lookAhead(isClassMemberStart) || (token() === 26 /* SyntaxKind.SemicolonToken */ && !inErrorRecovery); + case 6 /* ParsingContext.EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); - case 12 /* ObjectLiteralMembers */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || isLiteralPropertyName(); + case 12 /* ParsingContext.ObjectLiteralMembers */: switch (token()) { - case 22 /* OpenBracketToken */: - case 41 /* AsteriskToken */: - case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* SyntaxKind.OpenBracketToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 24 /* SyntaxKind.DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; default: return isLiteralPropertyName(); } - case 18 /* RestProperties */: + case 18 /* ParsingContext.RestProperties */: return isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); - case 24 /* AssertEntries */: + case 9 /* ParsingContext.ObjectBindingElements */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); + case 24 /* ParsingContext.AssertEntries */: return isAssertionKey(); - case 7 /* HeritageClauseElement */: + case 7 /* ParsingContext.HeritageClauseElement */: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -32923,42 +33047,42 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 19 /* TypeParameters */: - return token() === 101 /* InKeyword */ || isIdentifier(); - case 15 /* ArrayLiteralMembers */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); + case 19 /* ParsingContext.TypeParameters */: + return token() === 101 /* SyntaxKind.InKeyword */ || isIdentifier(); + case 15 /* ParsingContext.ArrayLiteralMembers */: switch (token()) { - case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 27 /* SyntaxKind.CommaToken */: + case 24 /* SyntaxKind.DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) return true; } // falls through - case 11 /* ArgumentExpressions */: - return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: + case 11 /* ParsingContext.ArgumentExpressions */: + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isStartOfExpression(); + case 16 /* ParsingContext.Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); - case 17 /* JSDocParameters */: + case 17 /* ParsingContext.JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); - case 20 /* TypeArguments */: - case 21 /* TupleElementTypes */: - return token() === 27 /* CommaToken */ || isStartOfType(); - case 22 /* HeritageClauses */: + case 20 /* ParsingContext.TypeArguments */: + case 21 /* ParsingContext.TupleElementTypes */: + return token() === 27 /* SyntaxKind.CommaToken */ || isStartOfType(); + case 22 /* ParsingContext.HeritageClauses */: return isHeritageClause(); - case 23 /* ImportOrExportSpecifiers */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; - case 14 /* JsxChildren */: + case 13 /* ParsingContext.JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* SyntaxKind.OpenBraceToken */; + case 14 /* ParsingContext.JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 18 /* OpenBraceToken */); - if (nextToken() === 19 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* SyntaxKind.OpenBraceToken */); + if (nextToken() === 19 /* SyntaxKind.CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -32967,7 +33091,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; + return next === 27 /* SyntaxKind.CommaToken */ || next === 18 /* SyntaxKind.OpenBraceToken */ || next === 94 /* SyntaxKind.ExtendsKeyword */ || next === 117 /* SyntaxKind.ImplementsKeyword */; } return true; } @@ -32984,8 +33108,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 117 /* ImplementsKeyword */ || - token() === 94 /* ExtendsKeyword */) { + if (token() === 117 /* SyntaxKind.ImplementsKeyword */ || + token() === 94 /* SyntaxKind.ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -33000,51 +33124,51 @@ var ts; } // True if positioned at a list terminator function isListTerminator(kind) { - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { // Being at the end of the file ends all lists. return true; } switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 23 /* ImportOrExportSpecifiers */: - case 24 /* AssertEntries */: - return token() === 19 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: + case 2 /* ParsingContext.SwitchClauses */: + case 4 /* ParsingContext.TypeMembers */: + case 5 /* ParsingContext.ClassMembers */: + case 6 /* ParsingContext.EnumMembers */: + case 12 /* ParsingContext.ObjectLiteralMembers */: + case 9 /* ParsingContext.ObjectBindingElements */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: + case 24 /* ParsingContext.AssertEntries */: + return token() === 19 /* SyntaxKind.CloseBraceToken */; + case 3 /* ParsingContext.SwitchClauseStatements */: + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 7 /* ParsingContext.HeritageClauseElement */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 8 /* ParsingContext.VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 19 /* TypeParameters */: + case 19 /* ParsingContext.TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 11 /* ParsingContext.ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 21 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token() === 23 /* CloseBracketToken */; - case 17 /* JSDocParameters */: - case 16 /* Parameters */: - case 18 /* RestProperties */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 26 /* SyntaxKind.SemicolonToken */; + case 15 /* ParsingContext.ArrayLiteralMembers */: + case 21 /* ParsingContext.TupleElementTypes */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 23 /* SyntaxKind.CloseBracketToken */; + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: + case 18 /* ParsingContext.RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 20 /* TypeArguments */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + case 20 /* ParsingContext.TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 27 /* CommaToken */; - case 22 /* HeritageClauses */: - return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; - case 14 /* JsxChildren */: - return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() !== 27 /* SyntaxKind.CommaToken */; + case 22 /* ParsingContext.HeritageClauses */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 19 /* SyntaxKind.CloseBraceToken */; + case 13 /* ParsingContext.JsxAttributes */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 43 /* SyntaxKind.SlashToken */; + case 14 /* ParsingContext.JsxChildren */: + return token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -33064,7 +33188,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -33072,7 +33196,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 25 /* ParsingContext.Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -33106,7 +33230,7 @@ var ts; } return parseElement(); } - function currentNode(parsingContext) { + function currentNode(parsingContext, pos) { // If we don't have a cursor or the parsing context isn't reusable, there's nothing to reuse. // // If there is an outstanding parse error that we've encountered, but not attached to @@ -33119,7 +33243,7 @@ var ts; if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) { return undefined; } - var node = syntaxCursor.currentNode(scanner.getStartPos()); + var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos()); // Can't reuse a missing node. // Can't reuse a node that intersected the change range. // Can't reuse a node that contains a parse error. This is necessary so that we @@ -33138,7 +33262,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 50720768 /* ContextFlags */; + var nodeContextFlags = node.flags & 50720768 /* NodeFlags.ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -33161,38 +33285,38 @@ var ts; } function isReusableParsingContext(parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: - case 2 /* SwitchClauses */: - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - case 6 /* EnumMembers */: - case 4 /* TypeMembers */: - case 8 /* VariableDeclarations */: - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 5 /* ParsingContext.ClassMembers */: + case 2 /* ParsingContext.SwitchClauses */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: + case 6 /* ParsingContext.EnumMembers */: + case 4 /* ParsingContext.TypeMembers */: + case 8 /* ParsingContext.VariableDeclarations */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return true; } return false; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: return isReusableClassMember(node); - case 2 /* SwitchClauses */: + case 2 /* ParsingContext.SwitchClauses */: return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: return isReusableStatement(node); - case 6 /* EnumMembers */: + case 6 /* ParsingContext.EnumMembers */: return isReusableEnumMember(node); - case 4 /* TypeMembers */: + case 4 /* ParsingContext.TypeMembers */: return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isReusableVariableDeclaration(node); - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative @@ -33239,20 +33363,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 171 /* Constructor */: - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 234 /* SemicolonClassElement */: + case 171 /* SyntaxKind.Constructor */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 234 /* SyntaxKind.SemicolonClassElement */: return true; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ && + methodDeclaration.name.originalKeywordKind === 134 /* SyntaxKind.ConstructorKeyword */; return !nameIsConstructor; } } @@ -33261,8 +33385,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return true; } } @@ -33271,58 +33395,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 237 /* VariableStatement */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 238 /* ExpressionStatement */: - case 251 /* ThrowStatement */: - case 247 /* ReturnStatement */: - case 249 /* SwitchStatement */: - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 236 /* EmptyStatement */: - case 252 /* TryStatement */: - case 250 /* LabeledStatement */: - case 240 /* DoStatement */: - case 253 /* DebuggerStatement */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 166 /* PropertySignature */: - case 174 /* CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 174 /* SyntaxKind.CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 254 /* VariableDeclaration */) { + if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -33343,7 +33467,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 164 /* Parameter */) { + if (node.kind !== 164 /* SyntaxKind.Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -33361,40 +33485,42 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return token() === 88 /* DefaultKeyword */ - ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */)) + case 0 /* ParsingContext.SourceElements */: + return token() === 88 /* SyntaxKind.DefaultKeyword */ + ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* SyntaxKind.ExportKeyword */)) : parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); - case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); - case 18 /* RestProperties */: // fallthrough - case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); - case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); - case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); - case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 2 /* ParsingContext.SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); + case 3 /* ParsingContext.SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); + case 18 /* ParsingContext.RestProperties */: // fallthrough + case 4 /* ParsingContext.TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); + case 5 /* ParsingContext.ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case 6 /* ParsingContext.EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); + case 7 /* ParsingContext.HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); + case 8 /* ParsingContext.VariableDeclarations */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected); - case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); - case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); - case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); - case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); - case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); - case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 16 /* Parameters */: + case 9 /* ParsingContext.ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); + case 10 /* ParsingContext.ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); + case 11 /* ParsingContext.ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); + case 12 /* ParsingContext.ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); + case 15 /* ParsingContext.ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); + case 17 /* ParsingContext.JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* ParsingContext.Parameters */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); - case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); - case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); - case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); - case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);` + case 19 /* ParsingContext.TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); + case 20 /* ParsingContext.TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); + case 21 /* ParsingContext.TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); + case 22 /* ParsingContext.HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 13 /* ParsingContext.JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 14 /* ParsingContext.JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 24 /* ParsingContext.AssertEntries */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); // AssertionKey. + case 25 /* ParsingContext.Count */: return ts.Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker. + default: ts.Debug.assertNever(context); } } function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { @@ -33413,7 +33539,7 @@ var ts; } list.push(result); commaStart = scanner.getTokenPos(); - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -33423,13 +33549,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); + parseExpected(27 /* SyntaxKind.CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SyntaxKind.SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -33458,7 +33584,7 @@ var ts; return createNodeArray(list, listPos, /*end*/ undefined, commaStart >= 0); } function getExpectedCommaDiagnostic(kind) { - return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + return kind === 6 /* ParsingContext.EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; } function createMissingList() { var list = createNodeArray([], getNodePos()); @@ -33480,8 +33606,8 @@ var ts; var pos = getNodePos(); var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = getNodePos(); - while (parseOptional(24 /* DotToken */)) { - if (token() === 29 /* LessThanToken */) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -33520,12 +33646,12 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -33536,7 +33662,7 @@ var ts; do { node = parseTemplateSpan(isTaggedTemplate); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateExpression(isTaggedTemplate) { @@ -33554,7 +33680,7 @@ var ts; do { node = parseTemplateTypeSpan(); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateTypeSpan() { @@ -33562,13 +33688,13 @@ var ts; return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos); } function parseLiteralOfTemplateSpan(isTaggedTemplate) { - if (token() === 19 /* CloseBraceToken */) { + if (token() === 19 /* SyntaxKind.CloseBraceToken */) { reScanTemplateToken(isTaggedTemplate); return parseTemplateMiddleOrTemplateTail(); } else { // TODO(rbuckton): Do we need to call `parseExpectedToken` or can we just call `createMissingNode` directly? - return parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); + return parseExpectedToken(17 /* SyntaxKind.TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* SyntaxKind.CloseBraceToken */)); } } function parseTemplateSpan(isTaggedTemplate) { @@ -33583,30 +33709,30 @@ var ts; reScanTemplateHeadOrNoSubstitutionTemplate(); } var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* SyntaxKind.TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* SyntaxKind.TemplateMiddle */ || fragment.kind === 17 /* SyntaxKind.TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function getTemplateLiteralRawText(kind) { - var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var isLast = kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || kind === 17 /* SyntaxKind.TemplateTail */; var tokenText = scanner.getTokenText(); return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); } function parseLiteralLikeNode(kind) { var pos = getNodePos(); - var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : + var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TokenFlags.TemplateLiteralLikeFlags */) : // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal. But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) : ts.Debug.fail(); if (scanner.hasExtendedUnicodeEscape()) { @@ -33623,8 +33749,8 @@ var ts; return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { - return parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function parseTypeReference() { @@ -33634,14 +33760,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return ts.nodeIsMissing(node.typeName); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: { + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -33679,12 +33805,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 27 /* CommaToken */ || - token() === 19 /* CloseBraceToken */ || - token() === 21 /* CloseParenToken */ || - token() === 31 /* GreaterThanToken */ || - token() === 63 /* EqualsToken */ || - token() === 51 /* BarToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */ || + token() === 19 /* SyntaxKind.CloseBraceToken */ || + token() === 21 /* SyntaxKind.CloseParenToken */ || + token() === 31 /* SyntaxKind.GreaterThanToken */ || + token() === 63 /* SyntaxKind.EqualsToken */ || + token() === 51 /* SyntaxKind.BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } else { @@ -33696,8 +33822,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); if (lookAhead(nextTokenIsOpenParen)) { nextToken(); - var parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */ | 32 /* SignatureFlags.JSDoc */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc); } return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), /*typeArguments*/ undefined), pos); @@ -33705,9 +33831,9 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */ || token() === 103 /* SyntaxKind.NewKeyword */) { name = parseIdentifierName(); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); } return finishNode(factory.createParameterDeclaration( /*modifiers*/ undefined, @@ -33720,15 +33846,15 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(141 /* ModuleKeyword */)) { + if (parseOptional(141 /* SyntaxKind.ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { switch (token()) { - case 19 /* CloseBraceToken */: - case 1 /* EndOfFileToken */: - case 27 /* CommaToken */: - case 5 /* WhitespaceTrivia */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 1 /* SyntaxKind.EndOfFileToken */: + case 27 /* SyntaxKind.CommaToken */: + case 5 /* SyntaxKind.WhitespaceTrivia */: break terminate; default: nextTokenJSDoc(); @@ -33737,13 +33863,13 @@ var ts; scanner.setInJSDocType(false); return finishNode(moduleTag, pos); } - var hasDotDotDot = parseOptional(25 /* DotDotDotToken */); + var hasDotDotDot = parseOptional(25 /* SyntaxKind.DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -33751,7 +33877,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(112 /* TypeOfKeyword */); + parseExpected(112 /* SyntaxKind.TypeOfKeyword */); var entityName = parseEntityName(/*allowReservedWords*/ true); // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression. var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; @@ -33763,7 +33889,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -33782,21 +33908,21 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); } function parseTypeParameters() { - if (token() === 29 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (token() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function isStartOfParameter(isJSDocParameter) { - return token() === 25 /* DotDotDotToken */ || + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 59 /* AtToken */ || + token() === 59 /* SyntaxKind.AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseNameOfParameter(modifiers) { @@ -33820,7 +33946,7 @@ var ts; // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later // complaining about the use of the keywords. - return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */; + return isBindingIdentifier() || token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function parseParameter(inOuterAwaitContext) { return parseParameterWorker(inOuterAwaitContext); @@ -33835,8 +33961,8 @@ var ts; // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. - var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); - if (token() === 108 /* ThisKeyword */) { + var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators); + if (token() === 108 /* SyntaxKind.ThisKeyword */) { var node_1 = factory.createParameterDeclaration(decorators, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, parseTypeAnnotation(), @@ -33849,11 +33975,11 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var modifiers = combineDecoratorsAndModifiers(decorators, parseModifiers()); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); if (!allowAmbiguity && !isParameterNameStart()) { return undefined; } - var node = withJSDoc(finishNode(factory.createParameterDeclaration(modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createParameterDeclaration(modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* SyntaxKind.QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); topLevel = savedTopLevel; return node; } @@ -33863,16 +33989,16 @@ var ts; } } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 38 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* SyntaxKind.EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(58 /* ColonToken */)) { + else if (parseOptional(58 /* SyntaxKind.ColonToken */)) { return true; } - else if (isType && token() === 38 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */)); nextToken(); return true; } @@ -33894,11 +34020,11 @@ var ts; // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); - setYieldContext(!!(flags & 1 /* Yield */)); - setAwaitContext(!!(flags & 2 /* Await */)); - var parameters = flags & 32 /* JSDoc */ ? - parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) : - parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); + var parameters = flags & 32 /* SignatureFlags.JSDoc */ ? + parseDelimitedList(17 /* ParsingContext.JSDocParameters */, parseJSDocParameter) : + parseDelimitedList(16 /* ParsingContext.Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); return parameters; @@ -33917,17 +34043,17 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { return createMissingList(); } var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return parameters; } function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -33936,20 +34062,20 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 175 /* ConstructSignature */) { - parseExpected(103 /* NewKeyword */); + if (kind === 175 /* SyntaxKind.ConstructSignature */) { + parseExpected(103 /* SyntaxKind.NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 174 /* CallSignature */ + var node = kind === 174 /* SyntaxKind.CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); } function isIndexSignature() { - return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* SyntaxKind.OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -33969,7 +34095,7 @@ var ts; // [] // nextToken(); - if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -33988,21 +34114,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 57 /* QuestionToken */) { + if (token() !== 57 /* SyntaxKind.QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */; } function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) { - var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); + var parameters = parseBracketedList(16 /* ParsingContext.Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */); var type = parseTypeAnnotation(); parseTypeMemberSemicolon(); var node = factory.createIndexSignature(modifiers, parameters, type); @@ -34011,14 +34137,14 @@ var ts; } function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); var node; - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type); } else { @@ -34027,7 +34153,7 @@ var ts; // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === 63 /* EqualsToken */) + if (token() === 63 /* SyntaxKind.EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -34035,10 +34161,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 136 /* GetKeyword */ || - token() === 149 /* SetKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 136 /* SyntaxKind.GetKeyword */ || + token() === 149 /* SyntaxKind.SetKeyword */) { return true; } var idToken = false; @@ -34048,7 +34174,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -34059,30 +34185,30 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 57 /* QuestionToken */ || - token() === 58 /* ColonToken */ || - token() === 27 /* CommaToken */ || + return token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || + token() === 58 /* SyntaxKind.ColonToken */ || + token() === 27 /* SyntaxKind.CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(174 /* CallSignature */); + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { + return parseSignatureMember(174 /* SyntaxKind.CallSignature */); } - if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(175 /* ConstructSignature */); + if (token() === 103 /* SyntaxKind.NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(175 /* SyntaxKind.ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SyntaxKind.GetAccessor */, 4 /* SignatureFlags.Type */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SyntaxKind.SetAccessor */, 4 /* SignatureFlags.Type */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -34091,16 +34217,16 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; + return token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 24 /* DotToken */; + return nextToken() === 24 /* SyntaxKind.DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 20 /* OpenParenToken */: - case 29 /* LessThanToken */: - case 24 /* DotToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 24 /* SyntaxKind.DotToken */: return true; } return false; @@ -34111,9 +34237,9 @@ var ts; } function parseObjectTypeMembers() { var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -34122,51 +34248,51 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 145 /* ReadonlyKeyword */; + if (token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { + return nextToken() === 145 /* SyntaxKind.ReadonlyKeyword */; } - if (token() === 145 /* ReadonlyKeyword */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; + return token() === 22 /* SyntaxKind.OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* SyntaxKind.InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(101 /* InKeyword */); + parseExpected(101 /* SyntaxKind.InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos); } function parseMappedType() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var readonlyToken; - if (token() === 145 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 145 /* ReadonlyKeyword */) { - parseExpected(145 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + parseExpected(145 /* SyntaxKind.ReadonlyKeyword */); } } - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; - parseExpected(23 /* CloseBracketToken */); + var nameType = parseOptional(127 /* SyntaxKind.AsKeyword */) ? parseType() : undefined; + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var questionToken; - if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 57 /* SyntaxKind.QuestionToken */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { questionToken = parseTokenNode(); - if (questionToken.kind !== 57 /* QuestionToken */) { - parseExpected(57 /* QuestionToken */); + if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { + parseExpected(57 /* SyntaxKind.QuestionToken */); } } var type = parseTypeAnnotation(); parseSemicolon(); - var members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + var members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(25 /* DotDotDotToken */)) { + if (parseOptional(25 /* SyntaxKind.DotDotDotToken */)) { return finishNode(factory.createRestTypeNode(parseType()), pos); } var type = parseType(); @@ -34179,10 +34305,10 @@ var ts; return type; } function isNextTokenColonOrQuestionColon() { - return nextToken() === 58 /* ColonToken */ || (token() === 57 /* QuestionToken */ && nextToken() === 58 /* ColonToken */); + return nextToken() === 58 /* SyntaxKind.ColonToken */ || (token() === 57 /* SyntaxKind.QuestionToken */ && nextToken() === 58 /* SyntaxKind.ColonToken */); } function isTupleElementName() { - if (token() === 25 /* DotDotDotToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */) { return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon(); } return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon(); @@ -34191,10 +34317,10 @@ var ts; if (lookAhead(isTupleElementName)) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); - parseExpected(58 /* ColonToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var type = parseTupleElementType(); var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -34203,21 +34329,21 @@ var ts; } function parseTupleType() { var pos = getNodePos(); - return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */)), pos); + return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* ParsingContext.TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */)), pos); } function parseParenthesizedType() { var pos = getNodePos(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createParenthesizedType(type), pos); } function parseModifiersForConstructorType() { var modifiers; - if (token() === 126 /* AbstractKeyword */) { + if (token() === 126 /* SyntaxKind.AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* SyntaxKind.AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -34226,10 +34352,10 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(103 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* SyntaxKind.NewKeyword */); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(38 /* SyntaxKind.EqualsGreaterThanToken */, /*isType*/ false); var node = isConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory.createFunctionTypeNode(typeParameters, parameters, type); @@ -34239,34 +34365,34 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 24 /* DotToken */ ? undefined : node; + return token() === 24 /* SyntaxKind.DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { var pos = getNodePos(); if (negative) { nextToken(); } - var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? + var expression = token() === 110 /* SyntaxKind.TrueKeyword */ || token() === 95 /* SyntaxKind.FalseKeyword */ || token() === 104 /* SyntaxKind.NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { - expression = finishNode(factory.createPrefixUnaryExpression(40 /* MinusToken */, expression), pos); + expression = finishNode(factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, expression), pos); } return finishNode(factory.createLiteralTypeNode(expression), pos); } function isStartOfTypeOfImportType() { nextToken(); - return token() === 100 /* ImportKeyword */; + return token() === 100 /* SyntaxKind.ImportKeyword */; } function parseImportTypeAssertions() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - parseExpected(129 /* AssertKeyword */); - parseExpected(58 /* ColonToken */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); var clause = parseAssertClause(/*skipAssertKeyword*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -34275,89 +34401,89 @@ var ts; return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos); } function parseImportType() { - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(112 /* TypeOfKeyword */); - parseExpected(100 /* ImportKeyword */); - parseExpected(20 /* OpenParenToken */); + var isTypeOf = parseOptional(112 /* SyntaxKind.TypeOfKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); var assertions; - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { assertions = parseImportTypeAssertions(); } - parseExpected(21 /* CloseParenToken */); - var qualifier = parseOptional(24 /* DotToken */) ? parseEntityNameOfTypeReference() : undefined; + parseExpected(21 /* SyntaxKind.CloseParenToken */); + var qualifier = parseOptional(24 /* SyntaxKind.DotToken */) ? parseEntityNameOfTypeReference() : undefined; var typeArguments = parseTypeArgumentsOfTypeReference(); return finishNode(factory.createImportTypeNode(type, assertions, qualifier, typeArguments, isTypeOf), pos); } function nextTokenIsNumericOrBigIntLiteral() { nextToken(); - return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; + return token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 151 /* SymbolKeyword */: - case 133 /* BooleanKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 66 /* AsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return parseJSDocAllType(); - case 60 /* QuestionQuestionToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // If there is '??', treat it as prefix-'?' in JSDoc type. scanner.reScanQuestionToken(); // falls through - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseJSDocFunctionType(); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return parseLiteralTypeNode(); - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseTokenNode(); - case 108 /* ThisKeyword */: { + case 108 /* SyntaxKind.ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseTupleType(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedType(); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportType(); - case 128 /* AssertsKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateType(); default: return parseTypeReference(); @@ -34365,48 +34491,48 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 145 /* ReadonlyKeyword */: - case 151 /* SymbolKeyword */: - case 154 /* UniqueKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 112 /* TypeOfKeyword */: - case 143 /* NeverKeyword */: - case 18 /* OpenBraceToken */: - case 22 /* OpenBracketToken */: - case 29 /* LessThanToken */: - case 51 /* BarToken */: - case 50 /* AmpersandToken */: - case 103 /* NewKeyword */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 148 /* ObjectKeyword */: - case 41 /* AsteriskToken */: - case 57 /* QuestionToken */: - case 53 /* ExclamationToken */: - case 25 /* DotDotDotToken */: - case 137 /* InferKeyword */: - case 100 /* ImportKeyword */: - case 128 /* AssertsKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 51 /* SyntaxKind.BarToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 103 /* SyntaxKind.NewKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 41 /* SyntaxKind.AsteriskToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 137 /* SyntaxKind.InferKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: return true; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return !inStartOfParameter; - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -34416,18 +34542,18 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* SyntaxKind.CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var pos = getNodePos(); var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: nextToken(); type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos); break; - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: // If next token is start of a type we have a conditional type if (lookAhead(nextTokenIsStartOfType)) { return type; @@ -34435,15 +34561,15 @@ var ts; nextToken(); type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos); break; - case 22 /* OpenBracketToken */: - parseExpected(22 /* OpenBracketToken */); + case 22 /* SyntaxKind.OpenBracketToken */: + parseExpected(22 /* SyntaxKind.OpenBracketToken */); if (isStartOfType()) { var indexType = parseType(); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos); } else { - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createArrayTypeNode(type), pos); } break; @@ -34459,9 +34585,9 @@ var ts; return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos); } function tryParseConstraintOfInferType() { - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { var constraint = disallowConditionalTypesAnd(parseType); - if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) { + if (inDisallowConditionalTypesContext() || token() !== 57 /* SyntaxKind.QuestionToken */) { return constraint; } } @@ -34475,17 +34601,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(137 /* InferKeyword */); + parseExpected(137 /* SyntaxKind.InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 140 /* KeyOfKeyword */: - case 154 /* UniqueKeyword */: - case 145 /* ReadonlyKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: return parseTypeOperator(operator); - case 137 /* InferKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return parseInferType(); } return allowConditionalTypesAnd(parsePostfixTypeOrHigher); @@ -34514,7 +34640,7 @@ var ts; } function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) { var pos = getNodePos(); - var isUnionType = operator === 51 /* BarToken */; + var isUnionType = operator === 51 /* SyntaxKind.BarToken */; var hasLeadingOperator = parseOptional(operator); var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType(); @@ -34528,35 +34654,35 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(50 /* AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); + return parseUnionOrIntersectionType(50 /* SyntaxKind.AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(51 /* BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); + return parseUnionOrIntersectionType(51 /* SyntaxKind.BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); } function nextTokenIsNewKeyword() { nextToken(); - return token() === 103 /* NewKeyword */; + return token() === 103 /* SyntaxKind.NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return true; } - if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 103 /* NewKeyword */ || - token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* SyntaxKind.NewKeyword */ || + token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 108 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* SyntaxKind.ThisKeyword */) { nextToken(); return true; } - if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -34566,7 +34692,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */) { // ( ) // ( ... return true; @@ -34574,17 +34700,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || token() === 63 /* SyntaxKind.EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 21 /* CloseParenToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */) { nextToken(); - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -34605,65 +34731,65 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); - var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* SyntaxKind.AssertsKeyword */); + var parameterName = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(139 /* SyntaxKind.IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { - if (contextFlags & 40960 /* TypeExcludesFlags */) { - return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType); + if (contextFlags & 40960 /* NodeFlags.TypeExcludesFlags */) { + return doOutsideOfContext(40960 /* NodeFlags.TypeExcludesFlags */, parseType); } if (isStartOfFunctionTypeOrConstructorType()) { return parseFunctionOrConstructorType(); } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { + if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = disallowConditionalTypesAnd(parseType); - parseExpected(57 /* QuestionToken */); + parseExpected(57 /* SyntaxKind.QuestionToken */); var trueType = allowConditionalTypesAnd(parseType); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var falseType = allowConditionalTypesAnd(parseType); return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos); } return type; } function parseTypeAnnotation() { - return parseOptional(58 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* SyntaxKind.ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 20 /* OpenParenToken */: - case 22 /* OpenBracketToken */: - case 18 /* OpenBraceToken */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 103 /* NewKeyword */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 79 /* Identifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 20 /* SyntaxKind.OpenParenToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 103 /* SyntaxKind.NewKeyword */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 79 /* SyntaxKind.Identifier */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -34674,19 +34800,19 @@ var ts; return true; } switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 29 /* LessThanToken */: - case 132 /* AwaitKeyword */: - case 125 /* YieldKeyword */: - case 80 /* PrivateIdentifier */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 132 /* SyntaxKind.AwaitKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: + case 80 /* SyntaxKind.PrivateIdentifier */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -34704,10 +34830,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 18 /* OpenBraceToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && - token() !== 59 /* AtToken */ && + return token() !== 18 /* SyntaxKind.OpenBraceToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && + token() !== 59 /* SyntaxKind.AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -34722,7 +34848,7 @@ var ts; var pos = getNodePos(); var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); var operatorToken; - while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(27 /* SyntaxKind.CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos); } if (saveDecoratorContext) { @@ -34731,7 +34857,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined; + return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined; } function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) { // AssignmentExpression[in,yield]: @@ -34773,11 +34899,11 @@ var ts; // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. var pos = getNodePos(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -34793,7 +34919,7 @@ var ts; return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction); } function isYieldExpression() { - if (token() === 125 /* YieldKeyword */) { + if (token() === 125 /* SyntaxKind.YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -34829,8 +34955,8 @@ var ts; // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos); + (token() === 41 /* SyntaxKind.AsteriskToken */ || isStartOfExpression())) { + return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* SyntaxKind.AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos); } else { // if the next token is not on the same line as yield. or we don't have an '*' or @@ -34839,7 +34965,7 @@ var ts; } } function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) { - ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* SyntaxKind.EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var parameter = factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, identifier, @@ -34848,14 +34974,14 @@ var ts; /*initializer*/ undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction); var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { + if (triState === 0 /* Tristate.False */) { // It's definitely not a parenthesized arrow function expression. return undefined; } @@ -34863,7 +34989,7 @@ var ts; // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. - return triState === 1 /* True */ ? + return triState === 1 /* Tristate.True */ ? parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) : tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); }); } @@ -34872,44 +34998,44 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */ || token() === 131 /* SyntaxKind.AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. - return 1 /* True */; + return 1 /* Tristate.True */; } // Definitely not a parenthesized arrow function. - return 0 /* False */; + return 0 /* Tristate.False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; + return 0 /* Tristate.False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { - return 0 /* False */; + if (token() !== 20 /* SyntaxKind.OpenParenToken */ && token() !== 29 /* SyntaxKind.LessThanToken */) { + return 0 /* Tristate.False */; } } var first = token(); var second = nextToken(); - if (first === 20 /* OpenParenToken */) { - if (second === 21 /* CloseParenToken */) { + if (first === 20 /* SyntaxKind.OpenParenToken */) { + if (second === 21 /* SyntaxKind.CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 38 /* EqualsGreaterThanToken */: - case 58 /* ColonToken */: - case 18 /* OpenBraceToken */: - return 1 /* True */; + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 58 /* SyntaxKind.ColonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + return 1 /* Tristate.True */; default: - return 0 /* False */; + return 0 /* Tristate.False */; } } // If encounter "([" or "({", this could be the start of a binding pattern. @@ -34918,85 +35044,85 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { - return 2 /* Unknown */; + if (second === 22 /* SyntaxKind.OpenBracketToken */ || second === 18 /* SyntaxKind.OpenBraceToken */) { + return 2 /* Tristate.Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 25 /* DotDotDotToken */) { - return 1 /* True */; + if (second === 25 /* SyntaxKind.DotDotDotToken */) { + return 1 /* Tristate.True */; } // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { - if (nextToken() === 127 /* AsKeyword */) { + if (ts.isModifierKind(second) && second !== 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (nextToken() === 127 /* SyntaxKind.AsKeyword */) { // https://github.com/microsoft/TypeScript/issues/44466 - return 0 /* False */; + return 0 /* Tristate.False */; } - return 1 /* True */; + return 1 /* Tristate.True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 108 /* ThisKeyword */) { - return 0 /* False */; + if (!isIdentifier() && second !== 108 /* SyntaxKind.ThisKeyword */) { + return 0 /* Tristate.False */; } switch (nextToken()) { - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - return 1 /* True */; - case 57 /* QuestionToken */: + return 1 /* Tristate.True */; + case 57 /* SyntaxKind.QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { - return 1 /* True */; + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 63 /* SyntaxKind.EqualsToken */ || token() === 21 /* SyntaxKind.CloseParenToken */) { + return 1 /* Tristate.True */; } // Otherwise it is definitely not a lambda. - return 0 /* False */; - case 27 /* CommaToken */: - case 63 /* EqualsToken */: - case 21 /* CloseParenToken */: + return 0 /* Tristate.False */; + case 27 /* SyntaxKind.CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 21 /* SyntaxKind.CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } // It is definitely not an arrow function - return 0 /* False */; + return 0 /* Tristate.False */; } else { - ts.Debug.assert(first === 29 /* LessThanToken */); + ts.Debug.assert(first === 29 /* SyntaxKind.LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { - return 0 /* False */; + return 0 /* Tristate.False */; } // JSX overrides - if (languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* LanguageVariant.JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 94 /* ExtendsKeyword */) { + if (third === 94 /* SyntaxKind.ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 63 /* EqualsToken */: - case 31 /* GreaterThanToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: return false; default: return true; } } - else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) { + else if (third === 27 /* SyntaxKind.CommaToken */ || third === 63 /* SyntaxKind.EqualsToken */) { return true; } return false; }); if (isArrowFunctionInJsx) { - return 1 /* True */; + return 1 /* Tristate.True */; } - return 0 /* False */; + return 0 /* Tristate.False */; } // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } } function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { @@ -35012,11 +35138,11 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 131 /* AsyncKeyword */) { - if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* Tristate.True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier); } } @@ -35026,26 +35152,26 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { - return 0 /* False */; + if (scanner.hasPrecedingLineBreak() || token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 0 /* Tristate.False */; } // Check for un-parenthesized AsyncArrowFunction - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return 1 /* True */; + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 1 /* Tristate.True */; } } - return 0 /* False */; + return 0 /* Tristate.False */; } function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -35055,7 +35181,7 @@ var ts; // close paren. var typeParameters = parseTypeParameters(); var parameters; - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { if (!allowAmbiguity) { return undefined; } @@ -35072,12 +35198,12 @@ var ts; else { parameters = parseParametersWorker(isAsync, allowAmbiguity); } - if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) { + if (!parseExpected(21 /* SyntaxKind.CloseParenToken */) && !allowAmbiguity) { return undefined; } } - var hasReturnColon = token() === 58 /* ColonToken */; - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var hasReturnColon = token() === 58 /* SyntaxKind.ColonToken */; + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; } @@ -35092,19 +35218,19 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var unwrappedType = type; - while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* ParenthesizedType */) { + while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* SyntaxKind.ParenthesizedType */) { unwrappedType = unwrappedType.type; // Skip parens if need be } var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType); - if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* SyntaxKind.EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* SyntaxKind.OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = (lastToken === 38 /* SyntaxKind.EqualsGreaterThanToken */ || lastToken === 18 /* SyntaxKind.OpenBraceToken */) ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction) : parseIdentifier(); // Given: @@ -35128,7 +35254,7 @@ var ts; // Then allow the arrow function, and treat the second colon as terminating // the conditional expression. It's okay to do this because this code would // be a syntax error in JavaScript (as the second colon shouldn't be there). - if (token() !== 58 /* ColonToken */) { + if (token() !== 58 /* SyntaxKind.ColonToken */) { return undefined; } } @@ -35136,12 +35262,12 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) { - if (token() === 18 /* OpenBraceToken */) { - return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { + return parseFunctionBlock(isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */); } - if (token() !== 26 /* SemicolonToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && + if (token() !== 26 /* SyntaxKind.SemicolonToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -35158,7 +35284,7 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error. - return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */)); + return parseFunctionBlock(16 /* SignatureFlags.IgnoreMissingOpenBrace */ | (isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */)); } var savedTopLevel = topLevel; topLevel = false; @@ -35170,16 +35296,16 @@ var ts; } function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* SyntaxKind.ColonToken */), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) - : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -35187,7 +35313,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 101 /* InKeyword */ || t === 160 /* OfKeyword */; + return t === 101 /* SyntaxKind.InKeyword */ || t === 160 /* SyntaxKind.OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -35216,16 +35342,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 101 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* SyntaxKind.InKeyword */ && inDisallowInContext()) { break; } - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -35246,7 +35372,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 101 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* SyntaxKind.InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -35274,7 +35400,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 132 /* AwaitKeyword */) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -35307,7 +35433,7 @@ var ts; if (isUpdateExpression()) { var pos = getNodePos(); var updateExpression = parseUpdateExpression(); - return token() === 42 /* AsteriskAsteriskToken */ ? + return token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) : updateExpression; } @@ -35324,10 +35450,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 42 /* AsteriskAsteriskToken */) { + if (token() === 42 /* SyntaxKind.AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 211 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -35352,23 +35478,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parsePrefixUnaryExpression(); - case 89 /* DeleteKeyword */: + case 89 /* SyntaxKind.DeleteKeyword */: return parseDeleteExpression(); - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return parseTypeOfExpression(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseVoidExpression(); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 132 /* AwaitKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -35391,18 +35517,18 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 132 /* AwaitKeyword */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: return false; - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (languageVariant !== 1 /* JSX */) { + if (languageVariant !== 1 /* LanguageVariant.JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. @@ -35423,17 +35549,17 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + if (token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) { var pos = getNodePos(); return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos); } - else if (languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (languageVariant === 1 /* LanguageVariant.JSX */ && token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { var operator = token(); nextToken(); return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos); @@ -35474,29 +35600,29 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 100 /* ImportKeyword */) { + if (token() === 100 /* SyntaxKind.ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); - sourceFlags |= 4194304 /* PossiblyContainsImportMeta */; + expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos); + sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression or OptionalExpression. As such, we need to consume the rest @@ -35558,19 +35684,22 @@ var ts; function parseSuperExpression() { var pos = getNodePos(); var expression = parseTokenNode(); - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); + if (!isTemplateStartOfTaggedTemplate()) { + expression = factory.createExpressionWithTypeArguments(expression, typeArguments); + } } } - if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 24 /* SyntaxKind.DotToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* SyntaxKind.DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); // private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } @@ -35578,11 +35707,11 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 280 /* JsxOpeningElement */) { + if (opening.kind === 280 /* SyntaxKind.JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = void 0; var lastChild = children[children.length - 1]; - if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* JsxElement */ + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, @@ -35608,11 +35737,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 283 /* JsxOpeningFragment */) { + else if (opening.kind === 283 /* SyntaxKind.JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 279 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 279 /* SyntaxKind.JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -35623,11 +35752,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 29 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* SyntaxKind.LessThanToken */) { var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos_1); }); if (invalidElement) { - var operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false); + var operatorToken = createMissingNode(27 /* SyntaxKind.CommaToken */, /*reportAtCurrentPosition*/ false); ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0); parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element); return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos); @@ -35637,13 +35766,13 @@ var ts; } function parseJsxText() { var pos = getNodePos(); - var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* JsxTextAllWhiteSpaces */); + var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* SyntaxKind.JsxTextAllWhiteSpaces */); currentToken = scanner.scanJsxToken(); return finishNode(node, pos); } function parseJsxChild(openingTag, token) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // If we hit EOF, issue the error at the tag that lacks the closing element // rather than at the end of the file (which is useless) if (ts.isJsxOpeningFragment(openingTag)) { @@ -35657,15 +35786,15 @@ var ts; parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 30 /* LessThanSlashToken */: - case 7 /* ConflictMarkerTrivia */: + case 30 /* SyntaxKind.LessThanSlashToken */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: return undefined; - case 11 /* JsxText */: - case 12 /* JsxTextAllWhiteSpaces */: + case 11 /* SyntaxKind.JsxText */: + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return parseJsxText(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); @@ -35675,14 +35804,14 @@ var ts; var list = []; var listPos = getNodePos(); var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; + parsingContext |= 1 << 14 /* ParsingContext.JsxChildren */; while (true) { var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken()); if (!child) break; list.push(child); if (ts.isJsxOpeningElement(openingTag) - && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* JsxElement */ + && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { // stop after parsing a mismatched child like
...(
) in order to reattach the
higher @@ -35694,21 +35823,21 @@ var ts; } function parseJsxAttributes() { var pos = getNodePos(); - return finishNode(factory.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos); + return finishNode(factory.createJsxAttributes(parseList(13 /* ParsingContext.JsxAttributes */, parseJsxAttribute)), pos); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); - if (token() === 31 /* GreaterThanToken */) { + parseExpected(29 /* SyntaxKind.LessThanToken */); + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // See below for explanation of scanJsxText scanJsxText(); return finishNode(factory.createJsxOpeningFragment(), pos); } var tagName = parseJsxElementName(); - var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; + var typeArguments = (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; var attributes = parseJsxAttributes(); var node; - if (token() === 31 /* GreaterThanToken */) { + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors @@ -35716,8 +35845,8 @@ var ts; node = factory.createJsxOpeningElement(tagName, typeArguments, attributes); } else { - parseExpected(43 /* SlashToken */); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + parseExpected(43 /* SyntaxKind.SlashToken */); + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35738,39 +35867,39 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 108 /* ThisKeyword */ ? + var expression = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); } return expression; } function parseJsxExpression(inExpressionContext) { var pos = getNodePos(); - if (!parseExpected(18 /* OpenBraceToken */)) { + if (!parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { return undefined; } var dotDotDotToken; var expression; - if (token() !== 19 /* CloseBraceToken */) { - dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + if (token() !== 19 /* SyntaxKind.CloseBraceToken */) { + dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); // Only an AssignmentExpression is valid here per the JSX spec, // but we can unambiguously parse a comma sequence and provide // a better error message in grammar checking. expression = parseExpression(); } if (inExpressionContext) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { - if (parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(19 /* SyntaxKind.CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { scanJsxText(); } } return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos); } function parseJsxAttribute() { - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); @@ -35778,14 +35907,14 @@ var ts; return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos); } function parseJsxAttributeValue() { - if (token() === 63 /* EqualsToken */) { - if (scanJsxAttributeValue() === 10 /* StringLiteral */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { + if (scanJsxAttributeValue() === 10 /* SyntaxKind.StringLiteral */) { return parseLiteralNode(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxExpression(/*inExpressionContext*/ true); } - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } parseErrorAtCurrentToken(ts.Diagnostics.or_JSX_element_expected); @@ -35794,17 +35923,17 @@ var ts; } function parseJsxSpreadAttribute() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - parseExpected(25 /* DotDotDotToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseExpression(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); var tagName = parseJsxElementName(); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { nextToken(); @@ -35817,11 +35946,11 @@ var ts; } function parseJsxClosingFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35834,36 +35963,36 @@ var ts; } function parseTypeAssertion() { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); + parseExpected(29 /* SyntaxKind.LessThanToken */); var type = parseType(); - parseExpected(31 /* GreaterThanToken */); + parseExpected(31 /* SyntaxKind.GreaterThanToken */); var expression = parseSimpleUnaryExpression(); return finishNode(factory.createTypeAssertion(type, expression), pos); } function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) - || token() === 22 /* OpenBracketToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ || isTemplateStartOfTaggedTemplate(); } function isStartOfOptionalPropertyOrElementAccessChain() { - return token() === 28 /* QuestionDotToken */ + return token() === 28 /* SyntaxKind.QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); } function tryReparseOptionalChain(node) { - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { return true; } // check for an optional chain in a non-null expression if (ts.isNonNullExpression(node)) { var expr = node.expression; - while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) { + while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* NodeFlags.OptionalChain */)) { expr = expr.expression; } - if (expr.flags & 32 /* OptionalChain */) { + if (expr.flags & 32 /* NodeFlags.OptionalChain */) { // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. while (ts.isNonNullExpression(node)) { - node.flags |= 32 /* OptionalChain */; + node.flags |= 32 /* NodeFlags.OptionalChain */; node = node.expression; } return true; @@ -35880,12 +36009,17 @@ var ts; if (isOptionalChain && ts.isPrivateIdentifier(propertyAccess.name)) { parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers); } + if (ts.isExpressionWithTypeArguments(expression) && expression.typeArguments) { + var pos_2 = expression.typeArguments.pos - 1; + var end = ts.skipTrivia(sourceText, expression.typeArguments.end) + 1; + parseErrorAt(pos_2, end, ts.Diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access); + } return finishNode(propertyAccess, pos); } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; - if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* SyntaxKind.CloseBracketToken */) { + argumentExpression = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -35894,7 +36028,7 @@ var ts; } argumentExpression = argument; } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ? factory.createElementAccessChain(expression, questionDotToken, argumentExpression) : factory.createElementAccessExpression(expression, argumentExpression); @@ -35905,30 +36039,30 @@ var ts; var questionDotToken = void 0; var isPropertyAccess = false; if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { - questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + questionDotToken = parseExpectedToken(28 /* SyntaxKind.QuestionDotToken */); isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); } else { - isPropertyAccess = parseOptional(24 /* DotToken */); + isPropertyAccess = parseOptional(24 /* SyntaxKind.DotToken */); } if (isPropertyAccess) { expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { expression = parseElementAccessExpressionRest(pos, expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments - expression = !questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */ ? + expression = !questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) : parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined); continue; } if (!questionDotToken) { - if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); expression = finishNode(factory.createNonNullExpression(expression), pos); continue; @@ -35943,14 +36077,14 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; + return token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || token() === 15 /* SyntaxKind.TemplateHead */; } function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) { - var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* NoSubstitutionTemplateLiteral */ ? + var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(/*isTaggedTemplate*/ true)); - if (questionDotToken || tag.flags & 32 /* OptionalChain */) { - tagExpression.flags |= 32 /* OptionalChain */; + if (questionDotToken || tag.flags & 32 /* NodeFlags.OptionalChain */) { + tagExpression.flags |= 32 /* NodeFlags.OptionalChain */; } tagExpression.questionDotToken = questionDotToken; return finishNode(tagExpression, pos); @@ -35959,7 +36093,7 @@ var ts; while (true) { expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true); var typeArguments = void 0; - var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); + var questionDotToken = parseOptionalToken(28 /* SyntaxKind.QuestionDotToken */); if (questionDotToken) { typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { @@ -35967,9 +36101,9 @@ var ts; continue; } } - if (typeArguments || token() === 20 /* OpenParenToken */) { + if (typeArguments || token() === 20 /* SyntaxKind.OpenParenToken */) { // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments - if (!questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (!questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } @@ -35982,7 +36116,7 @@ var ts; } if (questionDotToken) { // We parsed `?.` but then failed to parse anything, so report a missing identifier here. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -35990,22 +36124,22 @@ var ts; return expression; } function parseArgumentList() { - parseExpected(20 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); + var result = parseDelimitedList(11 /* ParsingContext.ArgumentExpressions */, parseArgumentExpression); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) { + if ((contextFlags & 262144 /* NodeFlags.JavaScriptFile */) !== 0) { // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators. return undefined; } - if (reScanLessThanToken() !== 29 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* SyntaxKind.LessThanToken */) { return undefined; } nextToken(); - var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (reScanGreaterToken() !== 31 /* GreaterThanToken */) { + var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType); + if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -36019,17 +36153,17 @@ var ts; function canFollowTypeArgumentsInExpression() { switch (token()) { // These tokens can follow a type argument list in a call expression. - case 20 /* OpenParenToken */: // foo( - case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 15 /* TemplateHead */: // foo `...${100}...` + case 20 /* SyntaxKind.OpenParenToken */: // foo( + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* SyntaxKind.TemplateHead */: // foo `...${100}...` return true; // A type argument list followed by `<` never makes sense, and a type argument list followed // by `>` is ambiguous with a (re-scanned) `>>` operator, so we disqualify both. Also, in // this context, `+` and `-` are unary operators, not binary operators. - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: return false; } // We favor the type argument list interpretation when it is immediately followed by @@ -36038,24 +36172,24 @@ var ts; } function parsePrimaryExpression() { switch (token()) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return parseTokenNode(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedExpression(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseArrayLiteralExpression(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseObjectLiteralExpression(); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -36063,21 +36197,21 @@ var ts; break; } return parseFunctionExpression(); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassExpression(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionExpression(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateExpression(/* isTaggedTemplate */ false); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return parsePrivateIdentifier(); } return parseIdentifier(ts.Diagnostics.Expression_expected); @@ -36085,20 +36219,20 @@ var ts; function parseParenthesizedExpression() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc); } function parseSpreadElement() { var pos = getNodePos(); - parseExpected(25 /* DotDotDotToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { - return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : + return token() === 25 /* SyntaxKind.DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* SyntaxKind.CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); } function parseArgumentExpression() { @@ -36107,34 +36241,34 @@ var ts; function parseArrayLiteralExpression() { var pos = getNodePos(); var openBracketPosition = scanner.getTokenPos(); - var openBracketParsed = parseExpected(22 /* OpenBracketToken */); + var openBracketParsed = parseExpected(22 /* SyntaxKind.OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition); + var elements = parseDelimitedList(15 /* ParsingContext.ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpectedMatchingBrackets(22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, openBracketParsed, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (parseOptionalToken(25 /* DotDotDotToken */)) { + if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) { var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */, 0 /* SignatureFlags.None */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */, 0 /* SignatureFlags.None */); } - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - var exclamationToken = parseOptionalToken(53 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken); } // check if it is short-hand property assignment or normal property assignment @@ -36143,9 +36277,9 @@ var ts; // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var node; - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(63 /* EqualsToken */); + var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */); var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. @@ -36153,7 +36287,7 @@ var ts; node.equalsToken = equalsToken; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }); node = factory.createPropertyAssignment(name, initializer); } @@ -36167,10 +36301,10 @@ var ts; function parseObjectLiteralExpression() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var properties = parseDelimitedList(12 /* ParsingContext.ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -36184,17 +36318,17 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : parseOptionalBindingIdentifier(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlock(isGenerator | isAsync); setDecoratorContext(savedDecoratorContext); var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -36205,23 +36339,23 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(103 /* NewKeyword */); - if (parseOptional(24 /* DotToken */)) { + parseExpected(103 /* SyntaxKind.NewKeyword */); + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* SyntaxKind.NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false); var typeArguments; // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } - if (token() === 28 /* QuestionDotToken */) { + if (token() === 28 /* SyntaxKind.QuestionDotToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, ts.getTextOfNodeFromSourceText(sourceText, expression)); } - var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined; + var argumentList = token() === 20 /* SyntaxKind.OpenParenToken */ ? parseArgumentList() : undefined; return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos); } // STATEMENTS @@ -36229,13 +36363,13 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */, diagnosticMessage); if (openBraceParsed || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); - var statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); nextToken(); } @@ -36248,9 +36382,9 @@ var ts; } function parseFunctionBlock(flags, diagnosticMessage) { var savedYieldContext = inYieldContext(); - setYieldContext(!!(flags & 1 /* Yield */)); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); var savedAwaitContext = inAwaitContext(); - setAwaitContext(!!(flags & 2 /* Await */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); var savedTopLevel = topLevel; topLevel = false; // We may be in a [Decorator] context when parsing a function expression or @@ -36259,7 +36393,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage); + var block = parseBlock(!!(flags & 16 /* SignatureFlags.IgnoreMissingOpenBrace */), diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -36271,58 +36405,58 @@ var ts; function parseEmptyStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(26 /* SemicolonToken */); + parseExpected(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(99 /* IfKeyword */); + parseExpected(99 /* SyntaxKind.IfKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var thenStatement = parseStatement(); - var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + var elseStatement = parseOptional(91 /* SyntaxKind.ElseKeyword */) ? parseStatement() : undefined; return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(90 /* DoKeyword */); + parseExpected(90 /* SyntaxKind.DoKeyword */); var statement = parseStatement(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(26 /* SemicolonToken */); + parseOptional(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var statement = parseStatement(); return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(97 /* ForKeyword */); - var awaitToken = parseOptionalToken(132 /* AwaitKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(97 /* SyntaxKind.ForKeyword */); + var awaitToken = parseOptionalToken(132 /* SyntaxKind.AwaitKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var initializer; - if (token() !== 26 /* SemicolonToken */) { - if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { + if (token() !== 26 /* SyntaxKind.SemicolonToken */) { + if (token() === 113 /* SyntaxKind.VarKeyword */ || token() === 119 /* SyntaxKind.LetKeyword */ || token() === 85 /* SyntaxKind.ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -36330,26 +36464,26 @@ var ts; } } var node; - if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) { + if (awaitToken ? parseExpected(160 /* SyntaxKind.OfKeyword */) : parseOptional(160 /* SyntaxKind.OfKeyword */)) { var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(101 /* InKeyword */)) { + else if (parseOptional(101 /* SyntaxKind.InKeyword */)) { var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); } else { - parseExpected(26 /* SemicolonToken */); - var condition = token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var condition = token() !== 26 /* SyntaxKind.SemicolonToken */ && token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(26 /* SemicolonToken */); - var incrementor = token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var incrementor = token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36357,10 +36491,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 246 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); + parseExpected(kind === 246 /* SyntaxKind.BreakStatement */ ? 81 /* SyntaxKind.BreakKeyword */ : 86 /* SyntaxKind.ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 246 /* BreakStatement */ + var node = kind === 246 /* SyntaxKind.BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36368,7 +36502,7 @@ var ts; function parseReturnStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(105 /* ReturnKeyword */); + parseExpected(105 /* SyntaxKind.ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); @@ -36376,47 +36510,47 @@ var ts; function parseWithStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(116 /* WithKeyword */); + parseExpected(116 /* SyntaxKind.WithKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); - var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); + var statement = doInsideOfContext(33554432 /* NodeFlags.InWithStatement */, parseStatement); return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(82 /* CaseKeyword */); + parseExpected(82 /* SyntaxKind.CaseKeyword */); var expression = allowInAnd(parseExpression); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc); } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(88 /* DefaultKeyword */); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* SyntaxKind.CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var clauses = parseList(2 /* ParsingContext.SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createCaseBlock(clauses), pos); } function parseSwitchStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(107 /* SwitchKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(107 /* SyntaxKind.SwitchKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); var caseBlock = parseCaseBlock(); return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } @@ -36425,7 +36559,7 @@ var ts; // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(109 /* ThrowKeyword */); + parseExpected(109 /* SyntaxKind.ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' // directly as that might consume an expression on the following line. @@ -36445,25 +36579,25 @@ var ts; function parseTryStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(111 /* TryKeyword */); + parseExpected(111 /* SyntaxKind.TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 83 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* SyntaxKind.CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. var finallyBlock; - if (!catchClause || token() === 96 /* FinallyKeyword */) { - parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); + if (!catchClause || token() === 96 /* SyntaxKind.FinallyKeyword */) { + parseExpected(96 /* SyntaxKind.FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(83 /* CatchKeyword */); + parseExpected(83 /* SyntaxKind.CatchKeyword */); var variableDeclaration; - if (parseOptional(20 /* OpenParenToken */)) { + if (parseOptional(20 /* SyntaxKind.OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -36475,7 +36609,7 @@ var ts; function parseDebuggerStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(87 /* DebuggerKeyword */); + parseExpected(87 /* SyntaxKind.DebuggerKeyword */); parseSemicolon(); return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } @@ -36486,9 +36620,9 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var node; - var hasParen = token() === 20 /* OpenParenToken */; + var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */; var expression = allowInAnd(parseExpression); - if (ts.isIdentifier(expression) && parseOptional(58 /* ColonToken */)) { + if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) { node = factory.createLabeledStatement(expression, parseStatement()); } else { @@ -36509,25 +36643,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* SyntaxKind.ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* SyntaxKind.FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */ || token() === 10 /* SyntaxKind.StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -36550,44 +36684,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 157 /* GlobalKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; - case 100 /* ImportKeyword */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 79 /* SyntaxKind.Identifier */ || token() === 93 /* SyntaxKind.ExportKeyword */; + case 100 /* SyntaxKind.ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 93 /* ExportKeyword */: + return token() === 10 /* SyntaxKind.StringLiteral */ || token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 18 /* SyntaxKind.OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 93 /* SyntaxKind.ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 152 /* TypeKeyword */) { + if (currentToken_1 === 152 /* SyntaxKind.TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || - currentToken_1 === 127 /* AsKeyword */) { + if (currentToken_1 === 63 /* SyntaxKind.EqualsToken */ || currentToken_1 === 41 /* SyntaxKind.AsteriskToken */ || + currentToken_1 === 18 /* SyntaxKind.OpenBraceToken */ || currentToken_1 === 88 /* SyntaxKind.DefaultKeyword */ || + currentToken_1 === 127 /* SyntaxKind.AsKeyword */) { return true; } continue; - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: nextToken(); continue; default: @@ -36600,51 +36734,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 59 /* AtToken */: - case 26 /* SemicolonToken */: - case 18 /* OpenBraceToken */: - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 99 /* IfKeyword */: - case 90 /* DoKeyword */: - case 115 /* WhileKeyword */: - case 97 /* ForKeyword */: - case 86 /* ContinueKeyword */: - case 81 /* BreakKeyword */: - case 105 /* ReturnKeyword */: - case 116 /* WithKeyword */: - case 107 /* SwitchKeyword */: - case 109 /* ThrowKeyword */: - case 111 /* TryKeyword */: - case 87 /* DebuggerKeyword */: + case 59 /* SyntaxKind.AtToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 90 /* SyntaxKind.DoKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: + case 116 /* SyntaxKind.WithKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: + case 111 /* SyntaxKind.TryKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 85 /* ConstKeyword */: - case 93 /* ExportKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return isStartOfDeclaration(); - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 118 /* InterfaceKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 152 /* TypeKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -36654,7 +36788,7 @@ var ts; } function nextTokenIsBindingIdentifierOrStartOfDestructuring() { nextToken(); - return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; + return isBindingIdentifier() || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -36663,68 +36797,68 @@ var ts; } function parseStatement() { switch (token()) { - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: return parseEmptyStatement(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 119 /* LetKeyword */: + case 119 /* SyntaxKind.LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 99 /* IfKeyword */: + case 99 /* SyntaxKind.IfKeyword */: return parseIfStatement(); - case 90 /* DoKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return parseDoStatement(); - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return parseWhileStatement(); - case 97 /* ForKeyword */: + case 97 /* SyntaxKind.ForKeyword */: return parseForOrForInOrForOfStatement(); - case 86 /* ContinueKeyword */: - return parseBreakOrContinueStatement(245 /* ContinueStatement */); - case 81 /* BreakKeyword */: - return parseBreakOrContinueStatement(246 /* BreakStatement */); - case 105 /* ReturnKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + return parseBreakOrContinueStatement(245 /* SyntaxKind.ContinueStatement */); + case 81 /* SyntaxKind.BreakKeyword */: + return parseBreakOrContinueStatement(246 /* SyntaxKind.BreakStatement */); + case 105 /* SyntaxKind.ReturnKeyword */: return parseReturnStatement(); - case 116 /* WithKeyword */: + case 116 /* SyntaxKind.WithKeyword */: return parseWithStatement(); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return parseSwitchStatement(); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return parseThrowStatement(); - case 111 /* TryKeyword */: + case 111 /* SyntaxKind.TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return parseTryStatement(); - case 87 /* DebuggerKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: return parseDebuggerStatement(); - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: return parseDeclaration(); - case 131 /* AsyncKeyword */: - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 92 /* EnumKeyword */: - case 93 /* ExportKeyword */: - case 100 /* ImportKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 126 /* AbstractKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -36733,40 +36867,35 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 135 /* DeclareKeyword */; + return modifier.kind === 135 /* SyntaxKind.DeclareKeyword */; } function parseDeclaration() { - // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner - // if we can't reuse the declaration, so that we don't do this work twice? - // // `parseListElement` attempted to get the reused node at this position, // but the ambient context flag was not yet set, so the node appeared // not reusable in that context. - var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier); - if (isAmbient) { - var node = tryReuseAmbientDeclaration(); - if (node) { - return node; - } - } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(); + var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { + var node = tryReuseAmbientDeclaration(pos); + if (node) { + return node; + } for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); } else { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } - function tryReuseAmbientDeclaration() { - return doInsideOfContext(16777216 /* Ambient */, function () { - var node = currentNode(parsingContext); + function tryReuseAmbientDeclaration(pos) { + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { + var node = currentNode(parsingContext, pos); if (node) { return consumeNode(node); } @@ -36774,33 +36903,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 118 /* InterfaceKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* EnumKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 157 /* GlobalKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); switch (token()) { - case 88 /* DefaultKeyword */: - case 63 /* EqualsToken */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 63 /* SyntaxKind.EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 127 /* AsKeyword */: + case 127 /* SyntaxKind.AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36809,7 +36938,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(276 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -36820,38 +36949,44 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { - parseSemicolon(); - return; + if (token() !== 18 /* SyntaxKind.OpenBraceToken */) { + if (flags & 4 /* SignatureFlags.Type */) { + parseTypeMemberSemicolon(); + return; + } + if (canParseSemicolon()) { + parseSemicolon(); + return; + } } return parseFunctionBlock(flags, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { var pos = getNodePos(); - if (token() === 27 /* CommaToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */) { return finishNode(factory.createOmittedExpression(), pos); } - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierOrPattern(); var initializer = parseInitializer(); return finishNode(factory.createBindingElement(dotDotDotToken, /*propertyName*/ undefined, name, initializer), pos); } function parseObjectBindingElement() { var pos = getNodePos(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var tokenIsIdentifier = isBindingIdentifier(); var propertyName = parsePropertyName(); var name; - if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* SyntaxKind.ColonToken */) { name = propertyName; propertyName = undefined; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); name = parseIdentifierOrPattern(); } var initializer = parseInitializer(); @@ -36859,29 +36994,29 @@ var ts; } function parseObjectBindingPattern() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var elements = parseDelimitedList(9 /* ParsingContext.ObjectBindingElements */, parseObjectBindingElement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createObjectBindingPattern(elements), pos); } function parseArrayBindingPattern() { var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); - var elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(23 /* CloseBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); + var elements = parseDelimitedList(10 /* ParsingContext.ArrayBindingElements */, parseArrayBindingElement); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createArrayBindingPattern(elements), pos); } function isBindingIdentifierOrPrivateIdentifierOrPattern() { - return token() === 18 /* OpenBraceToken */ - || token() === 22 /* OpenBracketToken */ - || token() === 80 /* PrivateIdentifier */ + return token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 80 /* SyntaxKind.PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseObjectBindingPattern(); } return parseBindingIdentifier(privateIdentifierDiagnosticMessage); @@ -36894,8 +37029,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 79 /* Identifier */ && - token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && name.kind === 79 /* SyntaxKind.Identifier */ && + token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); @@ -36907,13 +37042,13 @@ var ts; var pos = getNodePos(); var flags = 0; switch (token()) { - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: break; - case 119 /* LetKeyword */: - flags |= 1 /* Let */; + case 119 /* SyntaxKind.LetKeyword */: + flags |= 1 /* NodeFlags.Let */; break; - case 85 /* ConstKeyword */: - flags |= 2 /* Const */; + case 85 /* SyntaxKind.ConstKeyword */: + flags |= 2 /* NodeFlags.Const */; break; default: ts.Debug.fail(); @@ -36929,19 +37064,19 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 160 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 160 /* SyntaxKind.OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); + declarations = parseDelimitedList(8 /* ParsingContext.VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); setDisallowInContext(savedDisallowIn); } return finishNode(factory.createVariableDeclarationList(declarations, flags), pos); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* SyntaxKind.CloseParenToken */; } function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) { var declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -36954,17 +37089,17 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. - var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */; + var name = modifierFlags & 512 /* ModifierFlags.Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = modifierFlags & 256 /* ModifierFlags.Async */ ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 1 /* ModifierFlags.Export */) setAwaitContext(/*value*/ true); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); setAwaitContext(savedAwaitContext); var node = factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -36972,10 +37107,10 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 134 /* ConstructorKeyword */) { - return parseExpected(134 /* ConstructorKeyword */); + if (token() === 134 /* SyntaxKind.ConstructorKeyword */) { + return parseExpected(134 /* SyntaxKind.ConstructorKeyword */); } - if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ && lookAhead(nextToken) === 20 /* SyntaxKind.OpenParenToken */) { return tryParse(function () { var literalNode = parseLiteralNode(); return literalNode.text === "constructor" ? literalNode : undefined; @@ -36986,9 +37121,9 @@ var ts; return tryParse(function () { if (parseConstructorName()) { var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */, ts.Diagnostics.or_expected); var node = factory.createConstructorDeclaration(modifiers, parameters, body); // Attach invalid nodes if they exist so that we can report them in the grammar checker. node.decorators = decorators; @@ -36999,11 +37134,11 @@ var ts; }); } function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) { - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); var node = factory.createMethodDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body); // An exclamation token on a method is invalid syntax and will be handled by the grammar checker @@ -37011,31 +37146,31 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) { - var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined; + var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* SyntaxKind.ExclamationToken */) : undefined; var type = parseTypeAnnotation(); - var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer); + var initializer = doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */ | 4096 /* NodeFlags.DisallowInContext */, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); var node = factory.createPropertyDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) { - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, /*exclamationToken*/ undefined, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); } - function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { + function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 172 /* GetAccessor */ + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(flags); + var node = kind === 172 /* SyntaxKind.GetAccessor */ ? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body) : factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors @@ -37046,7 +37181,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 59 /* AtToken */) { + if (token() === 59 /* SyntaxKind.AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -37063,7 +37198,7 @@ var ts; } nextToken(); } - if (token() === 41 /* AsteriskToken */) { + if (token() === 41 /* SyntaxKind.AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -37073,24 +37208,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 149 /* SetKeyword */ || idToken === 136 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 149 /* SyntaxKind.SetKeyword */ || idToken === 136 /* SyntaxKind.GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 20 /* OpenParenToken */: // Method declaration - case 29 /* LessThanToken */: // Generic Method declaration - case 53 /* ExclamationToken */: // Non-null assertion on property name - case 58 /* ColonToken */: // Type Annotation for declaration - case 63 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* SyntaxKind.OpenParenToken */: // Method declaration + case 29 /* SyntaxKind.LessThanToken */: // Generic Method declaration + case 53 /* SyntaxKind.ExclamationToken */: // Non-null assertion on property name + case 58 /* SyntaxKind.ColonToken */: // Type Annotation for declaration + case 63 /* SyntaxKind.EqualsToken */: // Initializer for declaration + case 57 /* SyntaxKind.QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -37104,7 +37239,7 @@ var ts; return false; } function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpectedToken(124 /* StaticKeyword */); + parseExpectedToken(124 /* SyntaxKind.StaticKeyword */); var body = parseClassStaticBlockBody(); var node = withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(body), pos), hasJSDoc); node.decorators = decorators; @@ -37122,7 +37257,7 @@ var ts; return body; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 132 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 132 /* SyntaxKind.AwaitKeyword */) { // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails // This simply parses the missing identifier and moves on. var pos = getNodePos(); @@ -37135,7 +37270,7 @@ var ts; } function tryParseDecorator() { var pos = getNodePos(); - if (!parseOptional(59 /* AtToken */)) { + if (!parseOptional(59 /* SyntaxKind.AtToken */)) { return undefined; } var expression = doInDecoratorContext(parseDecoratorExpression); @@ -37152,17 +37287,17 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } } - else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return undefined; } - else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) { + else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) { return undefined; } else { @@ -37192,7 +37327,7 @@ var ts; var pos = getNodePos(); var list, modifier, hasSeenStatic = false; while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) { - if (modifier.kind === 124 /* StaticKeyword */) + if (modifier.kind === 124 /* SyntaxKind.StaticKeyword */) hasSeenStatic = true; list = ts.append(list, modifier); } @@ -37200,33 +37335,33 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(131 /* SyntaxKind.AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; } function parseClassElement() { var pos = getNodePos(); - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { nextToken(); return finishNode(factory.createSemicolonClassElement(), pos); } var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true); - if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */, 0 /* SignatureFlags.None */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */, 0 /* SignatureFlags.None */); } - if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -37238,17 +37373,17 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */ || - token() === 41 /* AsteriskToken */ || - token() === 22 /* OpenBracketToken */) { + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */ || + token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 22 /* SyntaxKind.OpenBracketToken */) { var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); } else { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -37256,21 +37391,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* SyntaxKind.ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(84 /* ClassKeyword */); + parseExpected(84 /* SyntaxKind.ClassKeyword */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); @@ -37278,17 +37413,17 @@ var ts; setAwaitContext(/*value*/ true); var heritageClauses = parseHeritageClauses(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } members = parseClassMembers(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 257 /* ClassDeclaration */ + var node = kind === 257 /* SyntaxKind.ClassDeclaration */ ? factory.createClassDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members) : factory.createClassExpression(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -37304,45 +37439,45 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* SyntaxKind.ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(22 /* HeritageClauses */, parseHeritageClause); + return parseList(22 /* ParsingContext.HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* SyntaxKind.ExtendsKeyword */ || tok === 117 /* SyntaxKind.ImplementsKeyword */); // isListElement() should ensure this. nextToken(); - var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + var types = parseDelimitedList(7 /* ParsingContext.HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); } function parseExpressionWithTypeArguments() { var pos = getNodePos(); var expression = parseLeftHandSideExpressionOrHigher(); - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { return expression; } var typeArguments = tryParseTypeArguments(); return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos); } function tryParseTypeArguments() { - return token() === 29 /* LessThanToken */ ? - parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; + return token() === 29 /* SyntaxKind.LessThanToken */ ? + parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; + return token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; } function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); + return parseList(5 /* ParsingContext.ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(118 /* InterfaceKeyword */); + parseExpected(118 /* SyntaxKind.InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -37352,11 +37487,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(152 /* TypeKeyword */); + parseExpected(152 /* SyntaxKind.TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(63 /* EqualsToken */); - var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* SyntaxKind.EqualsToken */); + var type = token() === 138 /* SyntaxKind.IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(modifiers, name, typeParameters, type); node.decorators = decorators; @@ -37374,12 +37509,12 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(92 /* EnumKeyword */); + parseExpected(92 /* SyntaxKind.EnumKeyword */); var name = parseIdentifier(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* EnumMembers */, parseEnumMember); }); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* ParsingContext.EnumMembers */, parseEnumMember); }); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -37391,9 +37526,9 @@ var ts; function parseModuleBlock() { var pos = getNodePos(); var statements; - if (parseExpected(18 /* OpenBraceToken */)) { - statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { statements = createMissingList(); @@ -37403,10 +37538,10 @@ var ts; function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) { // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 16 /* Namespace */; + var namespaceFlag = flags & 16 /* NodeFlags.Namespace */; var name = parseIdentifier(); - var body = parseOptional(24 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) + var body = parseOptional(24 /* SyntaxKind.DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NodeFlags.NestedNamespace */ | namespaceFlag) : parseModuleBlock(); var node = factory.createModuleDeclaration(modifiers, name, body, flags); node.decorators = decorators; @@ -37415,17 +37550,17 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); - flags |= 1024 /* GlobalAugmentation */; + flags |= 1024 /* NodeFlags.GlobalAugmentation */; } else { name = parseLiteralNode(); name.text = internIdentifier(name.text); } var body; - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { body = parseModuleBlock(); } else { @@ -37437,37 +37572,37 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(142 /* NamespaceKeyword */)) { - flags |= 16 /* Namespace */; + else if (parseOptional(142 /* SyntaxKind.NamespaceKeyword */)) { + flags |= 16 /* NodeFlags.Namespace */; } else { - parseExpected(141 /* ModuleKeyword */); - if (token() === 10 /* StringLiteral */) { + parseExpected(141 /* SyntaxKind.ModuleKeyword */); + if (token() === 10 /* SyntaxKind.StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 146 /* RequireKeyword */ && + return token() === 146 /* SyntaxKind.RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 20 /* OpenParenToken */; + return nextToken() === 20 /* SyntaxKind.OpenParenToken */; } function nextTokenIsOpenBrace() { - return nextToken() === 18 /* OpenBraceToken */; + return nextToken() === 18 /* SyntaxKind.OpenBraceToken */; } function nextTokenIsSlash() { - return nextToken() === 43 /* SlashToken */; + return nextToken() === 43 /* SyntaxKind.SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(127 /* AsKeyword */); - parseExpected(142 /* NamespaceKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); + parseExpected(142 /* SyntaxKind.NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -37477,7 +37612,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(100 /* ImportKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); var afterImportPos = scanner.getStartPos(); // We don't parse the identifier here in await context, instead we will report a grammar error in the checker. var identifier; @@ -37485,7 +37620,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 156 /* FromKeyword */ && + if (token() !== 156 /* SyntaxKind.FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -37499,15 +37634,15 @@ var ts; // import ModuleSpecifier; var importClause; if (identifier || // import id - token() === 41 /* AsteriskToken */ || // import * - token() === 18 /* OpenBraceToken */ // import { + token() === 41 /* SyntaxKind.AsteriskToken */ || // import * + token() === 18 /* SyntaxKind.OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); var assertClause; - if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37517,21 +37652,21 @@ var ts; } function parseAssertEntry() { var pos = getNodePos(); - var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */); - parseExpected(58 /* ColonToken */); + var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* SyntaxKind.StringLiteral */); + parseExpected(58 /* SyntaxKind.ColonToken */); var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { var pos = getNodePos(); if (!skipAssertKeyword) { - parseExpected(129 /* AssertKeyword */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); } var openBracePosition = scanner.getTokenPos(); - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + var elements = parseDelimitedList(24 /* ParsingContext.AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -37545,15 +37680,15 @@ var ts; } } function tokenAfterImportDefinitelyProducesImportDeclaration() { - return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */; + return token() === 41 /* SyntaxKind.AsteriskToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 156 /* FromKeyword */; + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 156 /* SyntaxKind.FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(63 /* EqualsToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(modifiers, isTypeOnly, identifier, moduleReference); @@ -37572,8 +37707,8 @@ var ts; // parse namespace or named imports var namedBindings; if (!identifier || - parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* NamedImports */); + parseOptional(27 /* SyntaxKind.CommaToken */)) { + namedBindings = token() === 41 /* SyntaxKind.AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* SyntaxKind.NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -37584,14 +37719,14 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(146 /* RequireKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(146 /* SyntaxKind.RequireKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = parseModuleSpecifier(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createExternalModuleReference(expression), pos); } function parseModuleSpecifier() { - if (token() === 10 /* StringLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -37607,8 +37742,8 @@ var ts; // NameSpaceImport: // * as ImportedBinding var pos = getNodePos(); - parseExpected(41 /* AsteriskToken */); - parseExpected(127 /* AsKeyword */); + parseExpected(41 /* SyntaxKind.AsteriskToken */); + parseExpected(127 /* SyntaxKind.AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -37621,17 +37756,17 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 269 /* NamedImports */ - ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) - : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); + var node = kind === 269 /* SyntaxKind.NamedImports */ + ? factory.createNamedImports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)) + : factory.createNamedExports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { var hasJSDoc = hasPrecedingJSDocComment(); - return withJSDoc(parseImportOrExportSpecifier(275 /* ExportSpecifier */), hasJSDoc); + return withJSDoc(parseImportOrExportSpecifier(275 /* SyntaxKind.ExportSpecifier */), hasJSDoc); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(270 /* ImportSpecifier */); + return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -37656,10 +37791,10 @@ var ts; // import { type as } from "mod"; - isTypeOnly: true, name: as // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as ...? } var firstAs = parseIdentifierName(); - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as as ...? } var secondAs = parseIdentifierName(); if (ts.tokenIsIdentifierOrKeyword(token())) { @@ -37694,15 +37829,15 @@ var ts; name = parseNameWithKeywordCheck(); } } - if (canParseAsKeyword && token() === 127 /* AsKeyword */) { + if (canParseAsKeyword && token() === 127 /* SyntaxKind.AsKeyword */) { propertyName = name; - parseExpected(127 /* AsKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); name = parseNameWithKeywordCheck(); } - if (kind === 270 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 270 /* SyntaxKind.ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 270 /* ImportSpecifier */ + var node = kind === 270 /* SyntaxKind.ImportSpecifier */ ? factory.createImportSpecifier(isTypeOnly, propertyName, name) : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); @@ -37722,26 +37857,26 @@ var ts; var exportClause; var moduleSpecifier; var assertClause; - var isTypeOnly = parseOptional(152 /* TypeKeyword */); + var isTypeOnly = parseOptional(152 /* SyntaxKind.TypeKeyword */); var namespaceExportPos = getNodePos(); - if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(127 /* AsKeyword */)) { + if (parseOptional(41 /* SyntaxKind.AsteriskToken */)) { + if (parseOptional(127 /* SyntaxKind.AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(273 /* NamedExports */); + exportClause = parseNamedImportsOrExports(273 /* SyntaxKind.NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 156 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(156 /* FromKeyword */); + if (token() === 156 /* SyntaxKind.FromKeyword */ || (token() === 10 /* SyntaxKind.StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } - if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (moduleSpecifier && token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37754,11 +37889,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(63 /* EqualsToken */)) { + if (parseOptional(63 /* SyntaxKind.EqualsToken */)) { isExportEquals = true; } else { - parseExpected(88 /* DefaultKeyword */); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); } var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); parseSemicolon(); @@ -37805,11 +37940,11 @@ var ts; var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState("file.js", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); - var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop); + var sourceFile = createSourceFile("file.js", 99 /* ScriptTarget.Latest */, 1 /* ScriptKind.JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* SyntaxKind.EndOfFileToken */), 0 /* NodeFlags.None */, ts.noop); var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); if (jsDocDiagnostics) { sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile); @@ -37821,10 +37956,10 @@ var ts; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { var pos = getNodePos(); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* SyntaxKind.OpenBraceToken */); + var type = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocTypeExpression(type); fixupParentReferences(result); @@ -37833,16 +37968,16 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocNameReference() { var pos = getNodePos(); - var hasBrace = parseOptional(18 /* OpenBraceToken */); + var hasBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var p2 = getNodePos(); var entityName = parseEntityName(/* allowReservedWords*/ false); - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); } if (hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocNameReference(entityName); fixupParentReferences(result); @@ -37850,9 +37985,9 @@ var ts; } JSDocParser.parseJSDocNameReference = parseJSDocNameReference; function parseIsolatedJSDocComment(content, start, length) { - initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); - var sourceFile = { languageVariant: 0 /* Standard */, text: content }; + initializeState("", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); + var jsDoc = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var sourceFile = { languageVariant: 0 /* LanguageVariant.Standard */, text: content }; var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -37862,9 +37997,9 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); ts.setParent(comment, parent); - if (contextFlags & 262144 /* JavaScriptFile */) { + if (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) { if (!jsDocDiagnostics) { jsDocDiagnostics = []; } @@ -37912,7 +38047,7 @@ var ts; return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. - var state = 1 /* SawAsterisk */; + var state = 1 /* JSDocState.SawAsterisk */; var margin; // + 4 for leading '/** ' // + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character @@ -37925,16 +38060,16 @@ var ts; indent += text.length; } nextTokenJSDoc(); - while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + while (parseOptionalJsdoc(5 /* SyntaxKind.WhitespaceTrivia */)) ; - if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { - state = 0 /* BeginningOfLine */; + if (parseOptionalJsdoc(4 /* SyntaxKind.NewLineTrivia */)) { + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; } loop: while (true) { switch (token()) { - case 59 /* AtToken */: - if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { + case 59 /* SyntaxKind.AtToken */: + if (state === 0 /* JSDocState.BeginningOfLine */ || state === 1 /* JSDocState.SawAsterisk */) { removeTrailingWhitespace(comments); if (!commentsPos) commentsPos = getNodePos(); @@ -37942,35 +38077,35 @@ var ts; // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning // for malformed examples like `/** @param {string} x @returns {number} the length */` - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; margin = undefined; } else { pushComment(scanner.getTokenText()); } break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: comments.push(scanner.getTokenText()); - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: var asterisk = scanner.getTokenText(); - if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { + if (state === 1 /* JSDocState.SawAsterisk */ || state === 2 /* JSDocState.SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(asterisk); } else { // Ignore the first asterisk on a line - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += asterisk.length; } break; - case 5 /* WhitespaceTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // only collect whitespace if we're already saving comments or have just crossed the comment indent margin var whitespace = scanner.getTokenText(); - if (state === 2 /* SavingComments */) { + if (state === 2 /* JSDocState.SavingComments */) { comments.push(whitespace); } else if (margin !== undefined && indent + whitespace.length > margin) { @@ -37978,10 +38113,10 @@ var ts; } indent += whitespace.length; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -38000,7 +38135,7 @@ var ts; // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(scanner.getTokenText()); break; } @@ -38029,26 +38164,26 @@ var ts; // We must use infinite lookahead, as there could be any number of newlines :( while (true) { nextTokenJSDoc(); - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { return true; } - if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) { + if (!(token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */)) { return false; } } } function skipWhitespace() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } } - while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { nextTokenJSDoc(); } } function skipWhitespaceOrAsterisk() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return ""; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } @@ -38056,14 +38191,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* SyntaxKind.AsteriskToken */) || token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { indentText += scanner.getTokenText(); - if (token() === 4 /* NewLineTrivia */) { + if (token() === 4 /* SyntaxKind.NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 41 /* AsteriskToken */) { + else if (token() === 41 /* SyntaxKind.AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -38071,7 +38206,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -38120,7 +38255,7 @@ var ts; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, margin); + return parseParameterOrPropertyTag(start, tagName, 2 /* PropertyLikeParse.Parameter */, margin); case "return": case "returns": tag = parseReturnTag(start, tagName, margin, indentText); @@ -38158,7 +38293,7 @@ var ts; var comments = []; var parts = []; var linkEnd; - var state = 0 /* BeginningOfLine */; + var state = 0 /* JSDocState.BeginningOfLine */; var previousWhitespace = true; var margin; function pushComment(text) { @@ -38173,31 +38308,31 @@ var ts; if (initialMargin !== "") { pushComment(initialMargin); } - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; } var tok = token(); loop: while (true) { switch (tok) { - case 4 /* NewLineTrivia */: - state = 0 /* BeginningOfLine */; + case 4 /* SyntaxKind.NewLineTrivia */: + state = 0 /* JSDocState.BeginningOfLine */; // don't use pushComment here because we want to keep the margin unchanged comments.push(scanner.getTokenText()); indent = 0; break; - case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */ - || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { + case 59 /* SyntaxKind.AtToken */: + if (state === 3 /* JSDocState.SavingBackticks */ + || state === 2 /* JSDocState.SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace comments.push(scanner.getTokenText()); break; } scanner.setTextPos(scanner.getTextPos() - 1); // falls through - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // Done break loop; - case 5 /* WhitespaceTrivia */: - if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) { + case 5 /* SyntaxKind.WhitespaceTrivia */: + if (state === 2 /* JSDocState.SavingComments */ || state === 3 /* JSDocState.SavingBackticks */) { pushComment(scanner.getTokenText()); } else { @@ -38209,8 +38344,8 @@ var ts; indent += whitespace.length; } break; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -38224,32 +38359,32 @@ var ts; pushComment(scanner.getTokenText()); } break; - case 61 /* BacktickToken */: - if (state === 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; + case 61 /* SyntaxKind.BacktickToken */: + if (state === 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; } else { - state = 3 /* SavingBackticks */; + state = 3 /* JSDocState.SavingBackticks */; } pushComment(scanner.getTokenText()); break; - case 41 /* AsteriskToken */: - if (state === 0 /* BeginningOfLine */) { + case 41 /* SyntaxKind.AsteriskToken */: + if (state === 0 /* JSDocState.BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += 1; break; } // record the * as a comment // falls through default: - if (state !== 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; // leading identifiers start recording as well + if (state !== 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; // leading identifiers start recording as well } pushComment(scanner.getTokenText()); break; } - previousWhitespace = token() === 5 /* WhitespaceTrivia */; + previousWhitespace = token() === 5 /* SyntaxKind.WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); @@ -38266,7 +38401,7 @@ var ts; } function isNextJSDocTokenWhitespace() { var next = nextTokenJSDoc(); - return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + return next === 5 /* SyntaxKind.WhitespaceTrivia */ || next === 4 /* SyntaxKind.NewLineTrivia */; } function parseJSDocLink(start) { var linkType = tryParse(parseJSDocLinkPrefix); @@ -38281,14 +38416,14 @@ var ts; ? parseEntityName(/*allowReservedWords*/ true) : undefined; if (name) { - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); } } var text = []; - while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 19 /* SyntaxKind.CloseBraceToken */ && token() !== 4 /* SyntaxKind.NewLineTrivia */ && token() !== 1 /* SyntaxKind.EndOfFileToken */) { text.push(scanner.getTokenText()); nextTokenJSDoc(); } @@ -38299,8 +38434,8 @@ var ts; } function parseJSDocLinkPrefix() { skipWhitespaceOrAsterisk(); - if (token() === 18 /* OpenBraceToken */ - && nextTokenJSDoc() === 59 /* AtToken */ + if (token() === 18 /* SyntaxKind.OpenBraceToken */ + && nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { var kind = scanner.getTokenValue(); if (isJSDocLinkTag(kind)) @@ -38328,35 +38463,35 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* SyntaxKind.BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(61 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* SyntaxKind.BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(63 /* EqualsToken */)) { + if (parseOptionalToken(63 /* SyntaxKind.EqualsToken */)) { parseExpression(); } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -38372,12 +38507,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); - var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); + var nestedTypeLiteral = target !== 4 /* PropertyLikeParse.CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - var result = target === 1 /* Property */ + var result = target === 1 /* PropertyLikeParse.Property */ ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment); return finishNode(result, start); @@ -38388,12 +38523,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) { + if (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -38414,8 +38549,8 @@ var ts; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */ - || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); + var isMarkdownOrJSDocLink = token() === 22 /* SyntaxKind.OpenBracketToken */ + || lookAhead(function () { return nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference(); var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); @@ -38437,14 +38572,14 @@ var ts; var comments = []; var inEmail = false; var token = scanner.getToken(); - while (token !== 1 /* EndOfFileToken */ && token !== 4 /* NewLineTrivia */) { - if (token === 29 /* LessThanToken */) { + while (token !== 1 /* SyntaxKind.EndOfFileToken */ && token !== 4 /* SyntaxKind.NewLineTrivia */) { + if (token === 29 /* SyntaxKind.LessThanToken */) { inEmail = true; } - else if (token === 59 /* AtToken */ && !inEmail) { + else if (token === 59 /* SyntaxKind.AtToken */ && !inEmail) { break; } - else if (token === 31 /* GreaterThanToken */ && inEmail) { + else if (token === 31 /* SyntaxKind.GreaterThanToken */ && inEmail) { comments.push(scanner.getTokenText()); scanner.setTextPos(scanner.getTokenPos() + 1); break; @@ -38463,21 +38598,21 @@ var ts; return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(18 /* OpenBraceToken */); + var usedBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var pos = getNodePos(); var expression = parsePropertyAccessEntityNameExpression(); var typeArguments = tryParseTypeArguments(); var node = factory.createExpressionWithTypeArguments(expression, typeArguments); var res = finishNode(node, pos); if (usedBrace) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var pos = getNodePos(); var node = parseJSDocIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); node = finishNode(factory.createPropertyAccessExpression(node, name), pos); } @@ -38511,7 +38646,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 343 /* JSDocTypeTag */) { + if (child.kind === 343 /* SyntaxKind.JSDocTypeTag */) { if (childTypeTag) { var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { @@ -38528,7 +38663,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 183 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -38552,10 +38687,10 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(24 /* DotToken */)) { + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var body = parseJSDocTypeNameWithNamespace(/*nested*/ true); var jsDocNamespaceNode = factory.createModuleDeclaration( - /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NestedNamespace */ : undefined); + /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NodeFlags.NestedNamespace */ : undefined); return finishNode(jsDocNamespaceNode, pos); } if (nested) { @@ -38567,7 +38702,7 @@ var ts; var pos = getNodePos(); var child; var parameters; - while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { + while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* PropertyLikeParse.CallbackParameter */, indent); })) { parameters = ts.append(parameters, child); } return createNodeArray(parameters || [], pos); @@ -38578,9 +38713,9 @@ var ts; var comment = parseTagComments(indent); var parameters = parseCallbackTagParameters(indent); var returnTag = tryParse(function () { - if (parseOptionalJsdoc(59 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 341 /* JSDocReturnTag */) { + if (tag && tag.kind === 341 /* SyntaxKind.JSDocReturnTag */) { return tag; } } @@ -38605,18 +38740,18 @@ var ts; return a.escapedText === b.escapedText; } function parseChildPropertyTag(indent) { - return parseChildParameterOrPropertyTag(1 /* Property */, indent); + return parseChildParameterOrPropertyTag(1 /* PropertyLikeParse.Property */, indent); } function parseChildParameterOrPropertyTag(target, indent, name) { var canParseTag = true; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) && - target !== 4 /* CallbackParameter */ && + if (child && (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) && + target !== 4 /* PropertyLikeParse.CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -38624,26 +38759,26 @@ var ts; } seenAsterisk = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: canParseTag = true; seenAsterisk = false; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: canParseTag = false; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return false; } } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -38651,15 +38786,15 @@ var ts; var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(start, tagName); + return target === 1 /* PropertyLikeParse.Property */ && parseTypeTag(start, tagName); case "prop": case "property": - t = 1 /* Property */; + t = 1 /* PropertyLikeParse.Property */; break; case "arg": case "argument": case "param": - t = 2 /* Parameter */ | 4 /* CallbackParameter */; + t = 2 /* PropertyLikeParse.Parameter */ | 4 /* PropertyLikeParse.CallbackParameter */; break; default: return false; @@ -38671,7 +38806,7 @@ var ts; } function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } @@ -38679,9 +38814,9 @@ var ts; var defaultType; if (isBracketed) { skipWhitespace(); - parseExpected(63 /* EqualsToken */); - defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); - parseExpected(23 /* CloseBracketToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); + defaultType = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } if (ts.nodeIsMissing(name)) { return undefined; @@ -38698,7 +38833,7 @@ var ts; typeParameters.push(node); } skipWhitespaceOrAsterisk(); - } while (parseOptionalJsdoc(27 /* CommaToken */)); + } while (parseOptionalJsdoc(27 /* SyntaxKind.CommaToken */)); return createNodeArray(typeParameters, pos); } function parseTemplateTag(start, tagName, indent, indentText) { @@ -38713,7 +38848,7 @@ var ts; // TODO: Determine whether we should enforce this in the checker. // TODO: Consider moving the `constraint` to the first type parameter as we could then remove `getEffectiveConstraintOfTypeParameter`. // TODO: Consider only parsing a single type parameter if there is a constraint. - var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + var constraint = token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } @@ -38726,16 +38861,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); // Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking. // Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}> // but it's not worth it to enforce that restriction. } - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -38743,7 +38878,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -38760,7 +38895,7 @@ var ts; var IncrementalParser; (function (IncrementalParser) { function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */); checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); if (ts.textChangeRangeIsUnchanged(textChangeRange)) { // if the text didn't change, then we can just return our current source file as-is. @@ -38915,9 +39050,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 79 /* Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: return true; } return false; @@ -38991,10 +39126,10 @@ var ts; } function checkNodePositions(node, aggressiveChecks) { if (aggressiveChecks) { - var pos_2 = node.pos; + var pos_3 = node.pos; var visitNode_1 = function (child) { - ts.Debug.assert(child.pos >= pos_2); - pos_2 = child.end; + ts.Debug.assert(child.pos >= pos_3); + pos_3 = child.end; }; if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -39003,7 +39138,7 @@ var ts; } } forEachChild(node, visitNode_1); - ts.Debug.assert(pos_2 <= node.end); + ts.Debug.assert(pos_3 <= node.end); } } function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { @@ -39172,7 +39307,7 @@ var ts; var oldText = sourceFile.text; if (textChangeRange) { ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* AssertionLevel.VeryAggressive */)) { var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); var newTextPrefix = newText.substr(0, textChangeRange.span.start); ts.Debug.assert(oldTextPrefix === newTextPrefix); @@ -39187,7 +39322,7 @@ var ts; var currentArrayIndex = 0; ts.Debug.assert(currentArrayIndex < currentArray.length); var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; + var lastQueriedPosition = -1 /* InvalidPosition.Value */; return { currentNode: function (position) { // Only compute the current node if the position is different than the last time @@ -39225,7 +39360,7 @@ var ts; function findHighestListElementThatStartsAtPosition(position) { // Clear out any cached state about the last node we found. currentArray = undefined; - currentArrayIndex = -1 /* Value */; + currentArrayIndex = -1 /* InvalidPosition.Value */; current = undefined; // Recurse into the source file to find the highest node at this position. forEachChild(sourceFile, visitNode, visitArray); @@ -39405,18 +39540,18 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im; var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im; function extractPragmas(pragmas, range, text) { - var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); + var tripleSlash = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); if (tripleSlash) { var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks var pragma = ts.commentPragmas[name]; - if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) { + if (!pragma || !(pragma.kind & 1 /* PragmaKindFlags.TripleSlashXML */)) { return; } if (pragma.args) { @@ -39450,15 +39585,15 @@ var ts; } return; } - var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); + var singleLine = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); if (singleLine) { - return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); + return addPragmaForMatch(pragmas, range, 2 /* PragmaKindFlags.SingleLine */, singleLine); } - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { - addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch); + addPragmaForMatch(pragmas, range, 4 /* PragmaKindFlags.MultiLine */, multiLineMatch); } } } @@ -39501,10 +39636,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 79 /* Identifier */) { + if (lhs.kind === 79 /* SyntaxKind.Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 108 /* ThisKeyword */) { + if (lhs.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -39524,11 +39659,11 @@ var ts; defaultValueDescription: false, }; var jsxOptionMap = new ts.Map(ts.getEntries({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */, - "react-jsx": 4 /* ReactJSX */, - "react-jsxdev": 5 /* ReactJSXDev */, + "preserve": 1 /* JsxEmit.Preserve */, + "react-native": 3 /* JsxEmit.ReactNative */, + "react": 2 /* JsxEmit.React */, + "react-jsx": 4 /* JsxEmit.ReactJSX */, + "react-jsxdev": 5 /* JsxEmit.ReactJSXDev */, })); /* @internal */ ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) { @@ -39834,18 +39969,18 @@ var ts; name: "target", shortName: "t", type: new ts.Map(ts.getEntries({ - es3: 0 /* ES3 */, - es5: 1 /* ES5 */, - es6: 2 /* ES2015 */, - es2015: 2 /* ES2015 */, - es2016: 3 /* ES2016 */, - es2017: 4 /* ES2017 */, - es2018: 5 /* ES2018 */, - es2019: 6 /* ES2019 */, - es2020: 7 /* ES2020 */, - es2021: 8 /* ES2021 */, - es2022: 9 /* ES2022 */, - esnext: 99 /* ESNext */, + es3: 0 /* ScriptTarget.ES3 */, + es5: 1 /* ScriptTarget.ES5 */, + es6: 2 /* ScriptTarget.ES2015 */, + es2015: 2 /* ScriptTarget.ES2015 */, + es2016: 3 /* ScriptTarget.ES2016 */, + es2017: 4 /* ScriptTarget.ES2017 */, + es2018: 5 /* ScriptTarget.ES2018 */, + es2019: 6 /* ScriptTarget.ES2019 */, + es2020: 7 /* ScriptTarget.ES2020 */, + es2021: 8 /* ScriptTarget.ES2021 */, + es2022: 9 /* ScriptTarget.ES2022 */, + esnext: 99 /* ScriptTarget.ESNext */, })), affectsSourceFile: true, affectsModuleResolution: true, @@ -39855,7 +39990,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, - defaultValueDescription: 0 /* ES3 */, + defaultValueDescription: 0 /* ScriptTarget.ES3 */, }; /*@internal*/ ts.moduleOptionDeclaration = { @@ -40135,16 +40270,16 @@ var ts; { name: "importsNotUsedAsValues", type: new ts.Map(ts.getEntries({ - remove: 0 /* Remove */, - preserve: 1 /* Preserve */, - error: 2 /* Error */, + remove: 0 /* ImportsNotUsedAsValues.Remove */, + preserve: 1 /* ImportsNotUsedAsValues.Preserve */, + error: 2 /* ImportsNotUsedAsValues.Error */, })), affectsEmit: true, affectsSemanticDiagnostics: true, affectsMultiFileEmitBuildInfo: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, - defaultValueDescription: 0 /* Remove */, + defaultValueDescription: 0 /* ImportsNotUsedAsValues.Remove */, }, { name: "downlevelIteration", @@ -40599,8 +40734,8 @@ var ts; { name: "newLine", type: new ts.Map(ts.getEntries({ - crlf: 0 /* CarriageReturnLineFeed */, - lf: 1 /* LineFeed */ + crlf: 0 /* NewLineKind.CarriageReturnLineFeed */, + lf: 1 /* NewLineKind.LineFeed */ })), affectsEmit: true, affectsMultiFileEmitBuildInfo: true, @@ -40973,7 +41108,7 @@ var ts; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, - target: 3 /* ES2016 */, + target: 3 /* ScriptTarget.ES2016 */, strict: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, @@ -40998,8 +41133,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } /* @internal */ function parseCustomTypeOption(opt, value, errors) { @@ -41058,11 +41193,11 @@ var ts; while (i < args.length) { var s = args[i]; i++; - if (s.charCodeAt(0) === 64 /* at */) { + if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) { parseResponseFile(s.slice(1)); } - else if (s.charCodeAt(0) === 45 /* minus */) { - var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1); + else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) { + var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1); var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true); if (opt) { i = parseOptionValue(args, i, diagnostics, opt, options, errors); @@ -41091,14 +41226,14 @@ var ts; var args = []; var pos = 0; while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) + while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */) pos++; if (pos >= text.length) break; var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { + if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) { pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */) pos++; if (pos < text.length) { args.push(text.substring(start + 1, pos)); @@ -41109,7 +41244,7 @@ var ts; } } else { - while (text.charCodeAt(pos) > 32 /* space */) + while (text.charCodeAt(pos) > 32 /* CharacterCodes.space */) pos++; args.push(text.substring(start, pos)); } @@ -41444,7 +41579,7 @@ var ts; var _a; var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; - if (rootExpression && rootExpression.kind !== 205 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json")); // Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that @@ -41484,7 +41619,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 296 /* PropertyAssignment */) { + if (element.kind !== 296 /* SyntaxKind.PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -41551,16 +41686,16 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -41575,16 +41710,16 @@ var ts; } } return validateValue(text); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 219 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* SyntaxKind.MinusToken */ || valueExpression.operand.kind !== 8 /* SyntaxKind.NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -41601,7 +41736,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -41795,10 +41930,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -41849,19 +41984,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -41870,25 +42005,25 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); // Print out each row, aligning all the descriptions on the same column. for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -41943,7 +42078,7 @@ var ts; * file to. e.g. outDir */ function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -42293,8 +42428,8 @@ var ts; extendedConfig = ts.normalizeSlashes(extendedConfig); if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Extension.Json */)) { + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -42535,11 +42670,11 @@ var ts; var jsonOnlyIncludeRegexes; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { var _loop_6 = function (file) { - if (ts.fileExtensionIs(file, ".json" /* Json */)) { + if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { - var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Json */); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -42683,7 +42818,7 @@ var ts; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; - if (flags === 1 /* Recursive */) { + if (flags === 1 /* WatchDirectoryFlags.Recursive */) { recursiveKeys.push(key); } } @@ -42717,13 +42852,13 @@ var ts; key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) - ? 1 /* Recursive */ : 0 /* None */ + ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */ }; } if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) { return { key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)), - flags: 1 /* Recursive */ + flags: 1 /* WatchDirectoryFlags.Recursive */ }; } return undefined; @@ -42746,7 +42881,7 @@ var ts; } var higherPriorityPath = keyMapper(ts.changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { - if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) { + if (ext === ".d.ts" /* Extension.Dts */ && (ts.fileExtensionIs(file, ".js" /* Extension.Js */) || ts.fileExtensionIs(file, ".jsx" /* Extension.Jsx */))) { // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to // prevent breakage. @@ -42824,7 +42959,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -42980,7 +43115,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -43043,7 +43178,7 @@ var ts; var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); function arePathsEqual(path1, path2, host) { var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames; - return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */; + return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* Comparison.EqualTo */; } /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -43211,18 +43346,7 @@ var ts; * Does not try `@types/${packageName}` - use a second pass if needed. */ function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) { - var moduleResolutionState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ts.emptyArray, - features: NodeResolutionFeatures.None, - requestContainingDirectory: containingDirectory, - reportDiagnostic: ts.noop - }; + var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules"); @@ -43264,7 +43388,7 @@ var ts; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); // At this stage, skip results with leading dot. - if (baseFileName.charCodeAt(0) !== 46 /* dot */) { + if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) { // Return just the type directive names result.push(baseFileName); } @@ -43319,7 +43443,7 @@ var ts; ts.createCacheWithRedirects = createCacheWithRedirects; function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { var cache; - return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries }; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap }; function getPackageJsonInfo(packageJsonPath) { return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); } @@ -43333,6 +43457,9 @@ var ts; var iter = cache === null || cache === void 0 ? void 0 : cache.entries(); return iter ? ts.arrayFrom(iter) : []; } + function getInternalMap() { + return cache; + } } function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); @@ -43415,7 +43542,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -43436,21 +43563,24 @@ var ts; } ts.zipToModeAwareCache = zipToModeAwareCache; function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options)); var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); - moduleNameToDirectoryMap.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + } function update(options) { updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -43520,13 +43650,16 @@ var ts; } ts.createModuleResolutionCache = createModuleResolutionCache; function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + } } ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) { @@ -43597,10 +43730,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -43803,7 +43936,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -43952,7 +44085,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -44019,7 +44152,7 @@ var ts; } var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length; var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules); - if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) { + if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) { indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName); } return path.slice(0, indexAfterPackageName); @@ -44038,7 +44171,7 @@ var ts; */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { - var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); + var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Extension.Json */); var extension = extensionLess ? candidate.substring(extensionLess.length) : ""; return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } @@ -44055,7 +44188,7 @@ var ts; function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) { + if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Extension.Json */) && state.compilerOptions.resolveJsonModule)) { var extensionless = ts.removeFileExtension(candidate); var extension = candidate.substring(extensionless.length); if (state.traceEnabled) { @@ -44083,55 +44216,55 @@ var ts; switch (extensions) { case Extensions.DtsOnly: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); - default: return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".d.mts" /* Extension.Dmts */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".d.cts" /* Extension.Dcts */); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return tryExtension(".d.ts" /* Extension.Dts */); + default: return tryExtension(".d.ts" /* Extension.Dts */); } case Extensions.TypeScript: case Extensions.TsOnly: var useDts = extensions === Extensions.TypeScript; switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return useDts ? tryExtension(".d.ts" /* Dts */) : undefined; + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mts" /* Extension.Mts */) || (useDts ? tryExtension(".d.mts" /* Extension.Dmts */) : undefined); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cts" /* Extension.Cts */) || (useDts ? tryExtension(".d.cts" /* Extension.Dcts */) : undefined); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined; default: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined); + return tryExtension(".ts" /* Extension.Ts */) || tryExtension(".tsx" /* Extension.Tsx */) || (useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined); } case Extensions.JavaScript: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mjs" /* Mjs */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cjs" /* Cjs */); - case ".json" /* Json */: - return tryExtension(".json" /* Json */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mjs" /* Extension.Mjs */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cjs" /* Extension.Cjs */); + case ".json" /* Extension.Json */: + return tryExtension(".json" /* Extension.Json */); default: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js" /* Extension.Js */) || tryExtension(".jsx" /* Extension.Jsx */); } case Extensions.TSConfig: case Extensions.Json: - return tryExtension(".json" /* Json */); + return tryExtension(".json" /* Extension.Json */); } function tryExtension(ext) { var path = tryFile(candidate + ext, onlyRecordFailures, state); @@ -44182,18 +44315,9 @@ var ts; var entrypoints; var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript; var features = getDefaultNodeResolutionFeatures(options); - var requireState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ["node", "require", "types"], - features: features, - requestContainingDirectory: packageJsonInfo.packageDirectory, - reportDiagnostic: ts.noop - }; + var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); + requireState.conditions = ["node", "require", "types"]; + requireState.requestContainingDirectory = packageJsonInfo.packageDirectory; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path); @@ -44266,23 +44390,27 @@ var ts; } } } - /** - * A function for locating the package.json scope for a given path - */ /*@internal*/ - function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) { - var state = { + function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) { + return { host: host, compilerOptions: options, traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], + failedLookupLocations: ts.noopPush, + affectingLocations: ts.noopPush, packageJsonInfoCache: packageJsonInfoCache, - features: 0, - conditions: [], + features: NodeResolutionFeatures.None, + conditions: ts.emptyArray, requestContainingDirectory: undefined, reportDiagnostic: ts.noop }; + } + ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState; + /** + * A function for locating the package.json scope for a given path + */ + /*@internal*/ + function getPackageScopeForPath(fileName, state) { var parts = ts.getPathComponents(fileName); parts.pop(); while (parts.length > 0) { @@ -44420,16 +44548,16 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */; + return extension === ".js" /* Extension.Js */ || extension === ".jsx" /* Extension.Jsx */ || extension === ".mjs" /* Extension.Mjs */ || extension === ".cjs" /* Extension.Cjs */; case Extensions.TSConfig: case Extensions.Json: - return extension === ".json" /* Json */; + return extension === ".json" /* Extension.Json */; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */ || extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */ || extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; case Extensions.TsOnly: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */; + return extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; } } /* @internal */ @@ -44453,7 +44581,7 @@ var ts; var _a, _b; var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope || !scope.packageJsonContent.exports) { return undefined; } @@ -44466,7 +44594,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -44512,7 +44640,7 @@ var ts; } var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath); @@ -44535,6 +44663,7 @@ var ts; return toSearchResult(/*value*/ undefined); } /** + * @internal * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 - * "longest" has some nuance as to what "longest" means in the presence of pattern trailers */ @@ -44557,6 +44686,7 @@ var ts; return 1; return 0; } + ts.comparePatternKeys = comparePatternKeys; function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) { var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports); if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) { @@ -44764,7 +44894,7 @@ var ts; // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment); - var jsAndDtsExtensions = [".mjs" /* Mjs */, ".cjs" /* Cjs */, ".js" /* Js */, ".json" /* Json */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".d.ts" /* Dts */]; + var jsAndDtsExtensions = [".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */, ".js" /* Extension.Js */, ".json" /* Extension.Json */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".d.ts" /* Extension.Dts */]; for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) { var ext = jsAndDtsExtensions_1[_f]; if (ts.fileExtensionIs(possibleInputBase, ext)) { @@ -44949,7 +45079,7 @@ var ts; } /* @internal */ function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; /* @internal */ @@ -45095,14 +45225,14 @@ var ts; ts.setParent(node.body, node); ts.setParentRecursive(node.body, /*incremental*/ false); } - return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* ModuleInstanceState.Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateCached(node, visited) { if (visited === void 0) { visited = new ts.Map(); } var nodeId = ts.getNodeId(node); if (visited.has(nodeId)) { - return visited.get(nodeId) || 0 /* NonInstantiated */; + return visited.get(nodeId) || 0 /* ModuleInstanceState.NonInstantiated */; } visited.set(nodeId, undefined); var result = getModuleInstanceStateWorker(node, visited); @@ -45113,34 +45243,34 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return 0 /* NonInstantiated */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return 0 /* ModuleInstanceState.NonInstantiated */; // 2. const enum declarations - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (ts.isEnumConst(node)) { - return 2 /* ConstEnumOnly */; + return 2 /* ModuleInstanceState.ConstEnumOnly */; } break; // 3. non-exported import declarations - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { - return 0 /* NonInstantiated */; + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (!(ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { + return 0 /* ModuleInstanceState.NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* NamedExports */) { - var state = 0 /* NonInstantiated */; + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* SyntaxKind.NamedExports */) { + var state = 0 /* ModuleInstanceState.NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); if (specifierState > state) { state = specifierState; } - if (state === 1 /* Instantiated */) { + if (state === 1 /* ModuleInstanceState.Instantiated */) { return state; } } @@ -45148,21 +45278,21 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 262 /* ModuleBlock */: { - var state_1 = 0 /* NonInstantiated */; + case 262 /* SyntaxKind.ModuleBlock */: { + var state_1 = 0 /* ModuleInstanceState.NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); switch (childState) { - case 0 /* NonInstantiated */: + case 0 /* ModuleInstanceState.NonInstantiated */: // child is non-instantiated - continue searching return; - case 2 /* ConstEnumOnly */: + case 2 /* ModuleInstanceState.ConstEnumOnly */: // child is const enum only - record state and continue searching - state_1 = 2 /* ConstEnumOnly */; + state_1 = 2 /* ModuleInstanceState.ConstEnumOnly */; return; - case 1 /* Instantiated */: + case 1 /* ModuleInstanceState.Instantiated */: // child is instantiated - record state and stop - state_1 = 1 /* Instantiated */; + state_1 = 1 /* ModuleInstanceState.Instantiated */; return true; default: ts.Debug.assertNever(childState); @@ -45170,16 +45300,16 @@ var ts; }); return state_1; } - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { - return 0 /* NonInstantiated */; + return 0 /* ModuleInstanceState.NonInstantiated */; } } - return 1 /* Instantiated */; + return 1 /* ModuleInstanceState.Instantiated */; } function getModuleInstanceStateForAliasTarget(specifier, visited) { var name = specifier.propertyName || specifier.name; @@ -45199,7 +45329,7 @@ var ts; if (found === undefined || state > found) { found = state; } - if (found === 1 /* Instantiated */) { + if (found === 1 /* ModuleInstanceState.Instantiated */) { return found; } } @@ -45210,7 +45340,7 @@ var ts; } p = p.parent; } - return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + return 1 /* ModuleInstanceState.Instantiated */; // Couldn't locate, assume could refer to a value } var ContainerFlags; (function (ContainerFlags) { @@ -45284,8 +45414,8 @@ var ts; var symbolCount = 0; var Symbol; var classifiableNames; - var unreachableFlow = { flags: 1 /* Unreachable */ }; - var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; + var unreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; + var reportedUnreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); /** * Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file) @@ -45307,7 +45437,7 @@ var ts; ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* tracing.Phase.Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); bind(file); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); file.symbolCount = symbolCount; @@ -45334,7 +45464,7 @@ var ts; activeLabelList = undefined; hasExplicitReturn = false; inAssignmentPattern = false; - emitFlags = 0 /* None */; + emitFlags = 0 /* NodeFlags.None */; } return bindSourceFile; function bindInStrictMode(file, opts) { @@ -45354,33 +45484,33 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; symbol.declarations = ts.appendIfUnique(symbol.declarations, node); - if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } - if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && !symbol.members) { symbol.members = ts.createSymbolTable(); } // On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate) - if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { + if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { ts.setValueDeclaration(symbol, node); } } // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 271 /* ExportAssignment */) { - return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) { + return node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; } var name = ts.getNameOfDeclaration(node); if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -45406,36 +45536,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 171 /* Constructor */: - return "__constructor" /* Constructor */; - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - return "__call" /* Call */; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: - return "__new" /* New */; - case 176 /* IndexSignature */: - return "__index" /* Index */; - case 272 /* ExportDeclaration */: - return "__export" /* ExportStar */; - case 305 /* SourceFile */: + case 171 /* SyntaxKind.Constructor */: + return "__constructor" /* InternalSymbolName.Constructor */; + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + return "__call" /* InternalSymbolName.Call */; + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + return "__new" /* InternalSymbolName.New */; + case 176 /* SyntaxKind.IndexSignature */: + return "__index" /* InternalSymbolName.Index */; + case 272 /* SyntaxKind.ExportDeclaration */: + return "__export" /* InternalSymbolName.ExportStar */; + case 305 /* SyntaxKind.SourceFile */: // json file should behave as // module.exports = ... - return "export=" /* ExportEquals */; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { + return "export=" /* InternalSymbolName.ExportEquals */; + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */) { // module.exports = ... - return "export=" /* ExportEquals */; + return "export=" /* InternalSymbolName.ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 317 /* JSDocFunctionType */: - return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 164 /* Parameter */: + case 317 /* SyntaxKind.JSDocFunctionType */: + return (ts.isJSDocConstructSignature(node) ? "__new" /* InternalSymbolName.New */ : "__call" /* InternalSymbolName.Call */); + case 164 /* SyntaxKind.Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind), ", expected JSDocFunctionType"); }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -45454,14 +45584,14 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) { ts.Debug.assert(isComputedName || !ts.hasDynamicName(node)); - var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; + var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" - var name = isComputedName ? "__computed" /* Computed */ - : isDefaultExport && parent ? "default" /* Default */ + var name = isComputedName ? "__computed" /* InternalSymbolName.Computed */ + : isDefaultExport && parent ? "default" /* InternalSymbolName.Default */ : getDeclarationName(node); var symbol; if (name === undefined) { - symbol = createSymbol(0 /* None */, "__missing" /* Missing */); + symbol = createSymbol(0 /* SymbolFlags.None */, "__missing" /* InternalSymbolName.Missing */); } else { // Check and see if the symbol table already has a symbol with this name. If not, @@ -45488,11 +45618,11 @@ var ts; // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. symbol = symbolTable.get(name); - if (includes & 2885600 /* Classifiable */) { + if (includes & 2885600 /* SymbolFlags.Classifiable */) { classifiableNames.add(name); } if (!symbol) { - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); if (isReplaceableByMethod) symbol.isReplaceableByMethod = true; } @@ -45504,20 +45634,20 @@ var ts; if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); } - else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) { + else if (!(includes & 3 /* SymbolFlags.Variable */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { // Assignment declarations are allowed to merge with variables, no matter what other flags they have. if (ts.isNamedDeclaration(node)) { ts.setParent(node.name, node); } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message_1 = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; var messageNeedsName_1 = true; - if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ || includes & 384 /* SymbolFlags.Enum */) { message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; messageNeedsName_1 = false; } @@ -45537,7 +45667,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 271 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 271 /* SyntaxKind.ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -45545,9 +45675,9 @@ var ts; } } var relatedInformation_1 = []; - if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) && symbol.flags & (2097152 /* SymbolFlags.Alias */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { // export type T; - may have meant export type { T }? - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -45560,7 +45690,7 @@ var ts; }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false))); - symbol = createSymbol(0 /* None */, name); + symbol = createSymbol(0 /* SymbolFlags.None */, name); } } } @@ -45574,9 +45704,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); - if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 275 /* ExportSpecifier */ || (node.kind === 265 /* ImportEqualsDeclaration */ && hasExportModifier)) { + var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node); + if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -45600,11 +45730,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) { - if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) { + if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -45631,7 +45761,7 @@ var ts; return false; if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* ModifierFlags.Export */) return true; // This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should // already have calculated and branched on most of this. @@ -45664,21 +45794,21 @@ var ts; // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. - if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 214 /* ArrowFunction */) { + if (containerFlags & 1 /* ContainerFlags.IsContainer */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; - if (containerFlags & 32 /* HasLocals */) { + if (containerFlags & 32 /* ContainerFlags.HasLocals */) { container.locals = ts.createSymbolTable(); } addToContainerChain(container); } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { + else if (containerFlags & 2 /* ContainerFlags.IsBlockScopedContainer */) { blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (containerFlags & 4 /* IsControlFlowContainer */) { + if (containerFlags & 4 /* ContainerFlags.IsControlFlowContainer */) { var saveCurrentFlow = currentFlow; var saveBreakTarget = currentBreakTarget; var saveContinueTarget = currentContinueTarget; @@ -45686,22 +45816,22 @@ var ts; var saveExceptionTarget = currentExceptionTarget; var saveActiveLabelList = activeLabelList; var saveHasExplicitReturn = hasExplicitReturn; - var isImmediatelyInvoked = (containerFlags & 16 /* IsFunctionExpression */ && - !ts.hasSyntacticModifier(node, 256 /* Async */) && + var isImmediatelyInvoked = (containerFlags & 16 /* ContainerFlags.IsFunctionExpression */ && + !ts.hasSyntacticModifier(node, 256 /* ModifierFlags.Async */) && !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node)) || - node.kind === 170 /* ClassStaticBlockDeclaration */; + node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isImmediatelyInvoked) { - currentFlow = initFlowNode({ flags: 2 /* Start */ }); - if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); + if (containerFlags & (16 /* ContainerFlags.IsFunctionExpression */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { currentFlow.node = node; } } // 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 = isImmediatelyInvoked || node.kind === 171 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* SyntaxKind.Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -45709,21 +45839,21 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~2816 /* ReachabilityAndEmitFlags */; - if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 256 /* HasImplicitReturn */; + node.flags &= ~2816 /* NodeFlags.ReachabilityAndEmitFlags */; + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && containerFlags & 8 /* ContainerFlags.IsFunctionLike */ && ts.nodeIsPresent(node.body)) { + node.flags |= 256 /* NodeFlags.HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 512 /* HasExplicitReturn */; + node.flags |= 512 /* NodeFlags.HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 171 /* Constructor */ || node.kind === 170 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */))) { + if (node.kind === 171 /* SyntaxKind.Constructor */ || node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -45737,10 +45867,10 @@ var ts; activeLabelList = saveActiveLabelList; hasExplicitReturn = saveHasExplicitReturn; } - else if (containerFlags & 64 /* IsInterface */) { + else if (containerFlags & 64 /* ContainerFlags.IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* NodeFlags.ContainsThis */ : node.flags & ~128 /* NodeFlags.ContainsThis */; } else { bindChildren(node); @@ -45750,8 +45880,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -45774,59 +45904,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 237 /* FirstStatement */ && node.kind <= 253 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 237 /* SyntaxKind.FirstStatement */ && node.kind <= 253 /* SyntaxKind.LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: bindWhileStatement(node); break; - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: bindDoStatement(node); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: bindForStatement(node); break; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: bindForInOrForOfStatement(node); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: bindIfStatement(node); break; - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: bindReturnOrThrow(node); break; - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: bindTryStatement(node); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: bindSwitchStatement(node); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: bindCaseBlock(node); break; - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: bindCaseClause(node); break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: bindExpressionStatement(node); break; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: bindLabeledStatement(node); break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -45836,47 +45966,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bindCallExpressionFlow(node); break; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 305 /* SourceFile */: { + case 305 /* SyntaxKind.SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: bindBindingElementFlow(node); break; - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 296 /* PropertyAssignment */: - case 225 /* SpreadElement */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 225 /* SyntaxKind.SpreadElement */: // Carry over whether we are in an assignment pattern of Object and Array literals // as well as their children that are valid assignment targets. inAssignmentPattern = saveInAssignmentPattern; @@ -45890,22 +46020,22 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 108 /* ThisKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return containsNarrowableReference(expr); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return hasNarrowableArgument(expr); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isNarrowingExpression(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 219 /* PrefixUnaryExpression */: - return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 216 /* TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand); + case 216 /* SyntaxKind.TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -45913,7 +46043,7 @@ var ts; function isNarrowableReference(expr) { return ts.isDottedName(expr) || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) - || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(expr.right) || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } @@ -45929,7 +46059,7 @@ var ts; } } } - if (expr.expression.kind === 206 /* PropertyAccessExpression */ && + if (expr.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -45940,68 +46070,68 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return isNarrowingExpression(expr.right); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: return isNarrowableOperand(expr.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowableOperand(expr.right); } } return containsNarrowableReference(expr); } function createBranchLabel() { - return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); + return initFlowNode({ flags: 4 /* FlowFlags.BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); + return initFlowNode({ flags: 8 /* FlowFlags.LoopLabel */, antecedents: undefined }); } function createReduceLabel(target, antecedents, antecedent) { - return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); + return initFlowNode({ flags: 1024 /* FlowFlags.ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */; + flow.flags |= flow.flags & 2048 /* FlowFlags.Referenced */ ? 4096 /* FlowFlags.Shared */ : 2048 /* FlowFlags.Referenced */; } function addAntecedent(label, antecedent) { - if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { + if (!(antecedent.flags & 1 /* FlowFlags.Unreachable */) && !ts.contains(label.antecedents, antecedent)) { (label.antecedents || (label.antecedents = [])).push(antecedent); setFlowNodeReferenced(antecedent); } } function createFlowCondition(flags, antecedent, expression) { - if (antecedent.flags & 1 /* Unreachable */) { + if (antecedent.flags & 1 /* FlowFlags.Unreachable */) { return antecedent; } if (!expression) { - return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; + return flags & 32 /* FlowFlags.TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* SyntaxKind.TrueKeyword */ && flags & 64 /* FlowFlags.FalseCondition */ || + expression.kind === 95 /* SyntaxKind.FalseKeyword */ && flags & 32 /* FlowFlags.TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -46013,7 +46143,7 @@ var ts; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); + return initFlowNode({ flags: 128 /* FlowFlags.SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowMutation(flags, antecedent, node) { setFlowNodeReferenced(antecedent); @@ -46025,7 +46155,7 @@ var ts; } function createFlowCall(antecedent, node) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + return initFlowNode({ flags: 512 /* FlowFlags.Call */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -46040,28 +46170,28 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return parent.expression === node; - case 242 /* ForStatement */: - case 222 /* ConditionalExpression */: + case 242 /* SyntaxKind.ForStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 212 /* ParenthesizedExpression */) { + if (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 219 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && node.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.operand; } else { - return node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 56 /* BarBarToken */ || - node.operatorToken.kind === 60 /* QuestionQuestionToken */); + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || + node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */); } } } @@ -46071,7 +46201,7 @@ var ts; } function isTopLevelLogicalExpression(node) { while (ts.isParenthesizedExpression(node.parent) || - ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && @@ -46090,8 +46220,8 @@ var ts; function bindCondition(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindIterativeStatement(node, breakTarget, continueTarget) { @@ -46105,7 +46235,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 250 /* LabeledStatement */) { + while (label && node.parent.kind === 250 /* SyntaxKind.LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -46156,12 +46286,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 244 /* ForOfStatement */) { + if (node.kind === 244 /* SyntaxKind.ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 255 /* VariableDeclarationList */) { + if (node.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -46183,7 +46313,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 247 /* ReturnStatement */) { + if (node.kind === 247 /* SyntaxKind.ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -46200,7 +46330,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 246 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 246 /* SyntaxKind.BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -46271,7 +46401,7 @@ var ts; finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents); currentFlow = finallyLabel; bind(node.finallyBlock); - if (currentFlow.flags & 1 /* Unreachable */) { + if (currentFlow.flags & 1 /* FlowFlags.Unreachable */) { // If the end of the finally block is unreachable, the end of the entire try statement is unreachable. currentFlow = unreachableFlow; } @@ -46305,7 +46435,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* SyntaxKind.DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -46334,7 +46464,7 @@ var ts; var clause = clauses[i]; bind(clause); fallthroughFlow = currentFlow; - if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { clause.fallthroughFlowNode = currentFlow; } } @@ -46353,9 +46483,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { var call = node; - if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { + if (call.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -46379,7 +46509,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -46388,12 +46518,12 @@ var ts; } function bindAssignmentTargetFlow(node) { if (isNarrowableReference(node)) { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } - else if (node.kind === 204 /* ArrayLiteralExpression */) { + else if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 225 /* SpreadElement */) { + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -46401,16 +46531,16 @@ var ts; } } } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 296 /* PropertyAssignment */) { + if (p.kind === 296 /* SyntaxKind.PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 297 /* ShorthandPropertyAssignment */) { + else if (p.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 298 /* SpreadAssignment */) { + else if (p.kind === 298 /* SyntaxKind.SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -46418,7 +46548,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -46429,15 +46559,15 @@ var ts; if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) { doWithConditionalBranches(bind, node.right, trueTarget, falseTarget); bindAssignmentTargetFlow(node.left); - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } else { bindCondition(node.right, trueTarget, falseTarget); } } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 53 /* ExclamationToken */) { + if (node.operator === 53 /* SyntaxKind.ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -46447,14 +46577,14 @@ var ts; } else { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -46503,9 +46633,9 @@ var ts; // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too // For now, though, since the common cases are chained `+`, leaving it recursive is fine var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || - operator === 56 /* BarBarToken */ || - operator === 60 /* QuestionQuestionToken */ || + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + operator === 56 /* SyntaxKind.BarBarToken */ || + operator === 60 /* SyntaxKind.QuestionQuestionToken */ || ts.isLogicalOrCoalescingAssignmentOperator(operator)) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); @@ -46522,7 +46652,7 @@ var ts; function onLeft(left, state, node) { if (!state.skip) { var maybeBound = maybeBind(left); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(left); } return maybeBound; @@ -46536,7 +46666,7 @@ var ts; function onRight(right, state, node) { if (!state.skip) { var maybeBound = maybeBind(right); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(right); } return maybeBound; @@ -46547,10 +46677,10 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 63 /* EqualsToken */ && node.left.kind === 207 /* ElementAccessExpression */) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && node.left.kind === 207 /* SyntaxKind.ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } @@ -46575,7 +46705,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -46603,7 +46733,7 @@ var ts; } } else { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } } function bindVariableDeclarationFlow(node) { @@ -46630,7 +46760,7 @@ var ts; } function bindJSDocTypeAlias(node) { bind(node.tagName); - if (node.kind !== 339 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 339 /* SyntaxKind.JSDocEnumTag */ && node.fullName) { // don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); @@ -46642,28 +46772,28 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 169 /* MethodDeclaration */) { - addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + if (host && host.kind !== 169 /* SyntaxKind.MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* SymbolFlags.Class */); } } function bindOptionalExpression(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainRest(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -46689,8 +46819,8 @@ var ts; } doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); if (ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainFlow(node) { @@ -46728,76 +46858,76 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 213 /* FunctionExpression */ || expr.kind === 214 /* ArrowFunction */) { + if (expr.kind === 213 /* SyntaxKind.FunctionExpression */ || expr.kind === 214 /* SyntaxKind.ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } function getContainerFlags(node) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 286 /* JsxAttributes */: - return 1 /* IsContainer */; - case 258 /* InterfaceDeclaration */: - return 1 /* IsContainer */ | 64 /* IsInterface */; - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: - case 176 /* IndexSignature */: - return 1 /* IsContainer */ | 32 /* HasLocals */; - case 305 /* SourceFile */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 286 /* SyntaxKind.JsxAttributes */: + return 1 /* ContainerFlags.IsContainer */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */; + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: + case 176 /* SyntaxKind.IndexSignature */: + return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */; + case 305 /* SyntaxKind.SourceFile */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */; + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */; } // falls through - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 317 /* JSDocFunctionType */: - case 179 /* FunctionType */: - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: - case 170 /* ClassStaticBlockDeclaration */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 262 /* ModuleBlock */: - return 4 /* IsControlFlowContainer */; - case 167 /* PropertyDeclaration */: - return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 292 /* CatchClause */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 263 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 235 /* Block */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 179 /* SyntaxKind.FunctionType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */; + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 16 /* ContainerFlags.IsFunctionExpression */; + case 262 /* SyntaxKind.ModuleBlock */: + return 4 /* ContainerFlags.IsControlFlowContainer */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return node.initializer ? 4 /* ContainerFlags.IsControlFlowContainer */ : 0; + case 292 /* SyntaxKind.CatchClause */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 263 /* SyntaxKind.CaseBlock */: + return 2 /* ContainerFlags.IsBlockScopedContainer */; + case 235 /* SyntaxKind.Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -46814,9 +46944,9 @@ var ts; // By not creating a new block-scoped-container here, we ensure that both 'var x' // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. - return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* ContainerFlags.None */ : 2 /* ContainerFlags.IsBlockScopedContainer */; } - return 0 /* None */; + return 0 /* ContainerFlags.None */; } function addToContainerChain(next) { if (lastContainer) { @@ -46830,46 +46960,46 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 205 /* ObjectLiteralExpression */: - case 258 /* InterfaceDeclaration */: - case 286 /* JsxAttributes */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 286 /* SyntaxKind.JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 323 /* JSDocSignature */: - case 176 /* IndexSignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 317 /* JSDocFunctionType */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 170 /* ClassStaticBlockDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -46896,17 +47026,17 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 64 /* ExportContext */; + if (node.flags & 16777216 /* NodeFlags.Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* NodeFlags.ExportContext */; } else { - node.flags &= ~64 /* ExportContext */; + node.flags &= ~64 /* NodeFlags.ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isModuleAugmentationExternal(node)) { @@ -46914,25 +47044,25 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 10 /* StringLiteral */) { + if (node.name.kind === 10 /* SyntaxKind.StringLiteral */) { var text = node.name.text; pattern = ts.tryParsePattern(text); if (pattern === undefined) { errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); } } - var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */); + var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* SymbolFlags.ValueModule */, 110735 /* SymbolFlags.ValueModuleExcludes */); file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { var state = declareModuleSymbol(node); - if (state !== 0 /* NonInstantiated */) { + if (state !== 0 /* ModuleInstanceState.NonInstantiated */) { var symbol = node.symbol; // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only - symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) + symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) // Current must be `const enum` only - && state === 2 /* ConstEnumOnly */ + && state === 2 /* ModuleInstanceState.ConstEnumOnly */ // Can't have been set to 'false' in a previous merged symbol. ('undefined' OK) && symbol.constEnumOnlyModule !== false; } @@ -46940,8 +47070,8 @@ var ts; } function declareModuleSymbol(node) { var state = getModuleInstanceState(node); - var instantiated = state !== 0 /* NonInstantiated */; - declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + var instantiated = state !== 0 /* ModuleInstanceState.NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* SymbolFlags.ValueModule */ : 1024 /* SymbolFlags.NamespaceModule */, instantiated ? 110735 /* SymbolFlags.ValueModuleExcludes */ : 0 /* SymbolFlags.NamespaceModuleExcludes */); return state; } function bindFunctionOrConstructorType(node) { @@ -46951,56 +47081,25 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + var symbol = createSymbol(131072 /* SymbolFlags.Signature */, getDeclarationName(node)); // TODO: GH#18217 + addDeclarationToSymbol(symbol, node, 131072 /* SymbolFlags.Signature */); + var typeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* SymbolFlags.TypeLiteral */); typeLiteralSymbol.members = ts.createSymbolTable(); typeLiteralSymbol.members.set(symbol.escapedName, symbol); } function bindObjectLiteralExpression(node) { - var ElementKind; - (function (ElementKind) { - ElementKind[ElementKind["Property"] = 1] = "Property"; - ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; - })(ElementKind || (ElementKind = {})); - if (inStrictMode && !ts.isAssignmentTarget(node)) { - var seen = new ts.Map(); - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { - continue; - } - var identifier = prop.name; - // ECMA-262 11.1.5 Object Initializer - // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true - // a.This production is contained in strict code and IsDataDescriptor(previous) is true and - // IsDataDescriptor(propId.descriptor) is true. - // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. - // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. - // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true - // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; - var existingKind = seen.get(identifier.escapedText); - if (!existingKind) { - seen.set(identifier.escapedText, currentKind); - continue; - } - } - } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__object" /* InternalSymbolName.Object */); } function bindJsxAttributes(node) { - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__jsxAttributes" /* InternalSymbolName.JSXAttributes */); } function bindJsxAttribute(node, symbolFlags, symbolExcludes) { return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); - if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) { + if (symbolFlags & (8 /* SymbolFlags.EnumMember */ | 106500 /* SymbolFlags.ClassMember */)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); @@ -47008,10 +47107,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -47037,9 +47136,9 @@ var ts; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; var host = typeAlias.parent.parent; - container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* ContainerFlags.IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = initFlowNode({ flags: 2 /* Start */ }); + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -47050,8 +47149,8 @@ var ts; bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: if (!ts.isExternalOrCommonJsModule(file)) { container = undefined; } @@ -47059,29 +47158,29 @@ var ts; container = file; } break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: container = declName.parent.expression; break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: container = declName.parent.expression.name; break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } if (container) { - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + declareModuleMember(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* SyntaxKind.Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -47099,24 +47198,24 @@ var ts; function checkContextualIdentifier(node) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length && - !(node.flags & 16777216 /* Ambient */) && - !(node.flags & 8388608 /* JSDoc */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && + !(node.flags & 8388608 /* NodeFlags.JSDoc */) && !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 132 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); } - else if (node.flags & 32768 /* AwaitContext */) { + else if (node.flags & 32768 /* NodeFlags.AwaitContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } - else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -47158,7 +47257,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 79 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* SyntaxKind.Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -47169,7 +47268,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 79 /* Identifier */) { + if (name && name.kind === 79 /* SyntaxKind.Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -47208,10 +47307,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 305 /* SourceFile */ && - blockScopeContainer.kind !== 261 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ && + blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -47221,7 +47320,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -47237,7 +47336,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -47250,7 +47349,7 @@ var ts; } function checkStrictModeLabeledStatement(node) { // Grammar checking for labeledStatement - if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) { + if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ScriptTarget.ES2015 */) { if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) { errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here); } @@ -47308,11 +47407,11 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 160 /* LastToken */) { + if (node.kind > 160 /* SyntaxKind.LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); - if (containerFlags === 0 /* None */) { + if (containerFlags === 0 /* ContainerFlags.None */) { bindChildren(node); } else { @@ -47322,7 +47421,7 @@ var ts; } else { var saveParent = parent; - if (node.kind === 1 /* EndOfFileToken */) + if (node.kind === 1 /* SyntaxKind.EndOfFileToken */) parent = node; bindJSDoc(node); parent = saveParent; @@ -47370,7 +47469,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -47379,28 +47478,28 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); break; } // falls through - case 108 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* ShorthandPropertyAssignment */)) { + case 108 /* SyntaxKind.ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 231 /* MetaProperty */: - case 106 /* SuperKeyword */: + case 231 /* SyntaxKind.MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: node.flowNode = currentFlow; break; - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifier(node); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -47412,28 +47511,28 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForName(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* SymbolFlags.FunctionScopedVariable */ | 134217728 /* SymbolFlags.ModuleExports */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { - case 1 /* ExportsProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: bindExportsPropertyAssignment(node); break; - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: bindModuleExportsAssignment(node); break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: bindPrototypePropertyAssignment(node.left, node); break; - case 6 /* Prototype */: + case 6 /* AssignmentDeclarationKind.Prototype */: bindPrototypeAssignment(node); break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: bindThisPropertyAssignment(node); break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: var expression = node.left.expression; if (ts.isInJSFile(node) && ts.isIdentifier(expression)) { var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText); @@ -47444,94 +47543,94 @@ var ts; } bindSpecialPropertyAssignment(node); break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: // Nothing to do break; default: ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return checkStrictModeCatchClause(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkStrictModeWithStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: seenThisKeyword = true; return; - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: break; // Binding the children will handle everything - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return bindTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return bindParameter(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return bindPropertyWorker(node); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 299 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); + case 299 /* SyntaxKind.EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */); + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */); + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 256 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), ts.isObjectLiteralMethod(node) ? 0 /* SymbolFlags.PropertyExcludes */ : 103359 /* SymbolFlags.MethodExcludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: return bindFunctionDeclaration(node); - case 171 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 172 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 173 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: - case 180 /* ConstructorType */: + case 171 /* SyntaxKind.Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, /*symbolExcludes:*/ 0 /* SymbolFlags.None */); + case 172 /* SyntaxKind.GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46015 /* SymbolFlags.GetAccessorExcludes */); + case 173 /* SyntaxKind.SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78783 /* SymbolFlags.SetAccessorExcludes */); + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: + case 180 /* SyntaxKind.ConstructorType */: return bindFunctionOrConstructorType(node); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 195 /* MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 195 /* SyntaxKind.MappedType */: return bindAnonymousTypeWorker(node); - case 332 /* JSDocClassTag */: + case 332 /* SyntaxKind.JSDocClassTag */: return bindJSDocClassTag(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return bindFunctionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { - case 7 /* ObjectDefinePropertyValue */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: return bindObjectDefinePropertyAssignment(node); - case 8 /* ObjectDefinePropertyExports */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: return bindObjectDefinePropertyExport(node); - case 9 /* ObjectDefinePrototypeProperty */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return bindObjectDefinePrototypeProperty(node); - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: break; // Nothing to do default: return ts.Debug.fail("Unknown call expression assignment declaration kind"); @@ -47541,73 +47640,73 @@ var ts; } break; // Members of classes, interfaces, and modules - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 258 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 259 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 260 /* EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */); + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); + case 260 /* SyntaxKind.EnumDeclaration */: return bindEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return bindJsxAttributes(node); - case 285 /* JsxAttribute */: - return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); + case 285 /* SyntaxKind.JsxAttribute */: + return bindJsxAttribute(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); // Imports and exports - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 264 /* NamespaceExportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return bindImportClause(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return bindExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return bindExportAssignment(node); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 340 /* JSDocParameterTag */: - if (node.parent.kind === 323 /* JSDocSignature */) { + case 340 /* SyntaxKind.JSDocParameterTag */: + if (node.parent.kind === 323 /* SyntaxKind.JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 322 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 322 /* SyntaxKind.JSDocTypeLiteral */) { break; } // falls through - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; - return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ ? + 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */ : + 4 /* SymbolFlags.Property */; + return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* SymbolFlags.PropertyExcludes */); + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } function bindPropertyWorker(node) { - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } function bindAnonymousTypeWorker(node) { - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */); + return bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); } function bindSourceFileIfExternalModule() { setExportContextFlag(file); @@ -47618,27 +47717,27 @@ var ts; bindSourceFileAsExternalModule(); // Create symbol equivalent for the module.exports = {} var originalSymbol = file.symbol; - declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */); + declareSymbol(file.symbol.exports, file.symbol, file, 4 /* SymbolFlags.Property */, 67108863 /* SymbolFlags.All */); file.symbol = originalSymbol; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512 /* SymbolFlags.ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { // Incorrect export assignment in some sort of block construct - bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 111551 /* SymbolFlags.Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ + ? 2097152 /* SymbolFlags.Alias */ // An export default clause with any other expression exports a value - : 4 /* Property */; + : 4 /* SymbolFlags.Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) - var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); + var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* SymbolFlags.All */); if (node.isExportEquals) { // Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set. ts.setValueDeclaration(symbol, node); @@ -47658,28 +47757,28 @@ var ts; } else { file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable(); - declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 8388608 /* SymbolFlags.ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */); } else if (ts.isNamespaceExport(node.exportClause)) { // declareSymbol walks up parents to find name text, parent _must_ be set // but won't be set by the normal binder walk until `bindChildren` later on. ts.setParent(node.exportClause, node); - declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindImportClause(node) { if (node.name) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function setCommonJsModuleIndicator(node) { @@ -47700,13 +47799,13 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { - var flags = 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + var flags = 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* SymbolFlags.None */); } } function bindExportsPropertyAssignment(node) { @@ -47717,15 +47816,15 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression)); - var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */; + var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; ts.setParent(node.left, node); - declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */); } } function bindModuleExportsAssignment(node) { @@ -47746,13 +47845,13 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + ? 2097152 /* SymbolFlags.Alias */ + : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */ | 512 /* SymbolFlags.ValueModule */; + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); ts.setValueDeclaration(symbol, node); } function bindExportAssignedObjectMemberAlias(node) { - declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); @@ -47764,11 +47863,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -47782,17 +47881,17 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); } else { - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */); } - addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } break; - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -47801,19 +47900,19 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); } else { - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true); } break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; } else if (thisContainer.commonJsModuleIndicator) { - declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); + declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; default: @@ -47821,7 +47920,7 @@ var ts; } } function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) { - declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); + declareSymbol(symbolTable, symbol, node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); addLateBoundAssignmentDeclarationToSymbol(node, symbol); } function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { @@ -47830,10 +47929,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 108 /* ThisKeyword */) { + if (node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -47852,7 +47951,7 @@ var ts; var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); if (namespaceSymbol && namespaceSymbol.valueDeclaration) { // Ensure the namespace symbol becomes class-like - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } @@ -47873,7 +47972,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 305 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -47885,7 +47984,7 @@ var ts; return; } var rootExpr = ts.getLeftmostAccessExpression(node.left); - if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) { + if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* SymbolFlags.Alias */) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them @@ -47898,7 +47997,7 @@ var ts; bindExportsPropertyAssignment(node); } else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + bindAnonymousDeclaration(node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, "__computed" /* InternalSymbolName.Computed */); var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); addLateBoundAssignmentDeclarationToSymbol(node, sym); } @@ -47916,13 +48015,13 @@ var ts; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { - if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) { + if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* SymbolFlags.Alias */) { return namespaceSymbol; } if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers - var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */; - var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; + var flags_2 = 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */; + var excludeFlags_1 = 110735 /* SymbolFlags.ValueModuleExcludes */ & ~67108864 /* SymbolFlags.Assignment */; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_2); @@ -47936,7 +48035,7 @@ var ts; }); } if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } return namespaceSymbol; } @@ -47948,12 +48047,12 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var includes = 0 /* None */; - var excludes = 0 /* None */; + var includes = 0 /* SymbolFlags.None */; + var excludes = 0 /* SymbolFlags.None */; // Method-like if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { - includes = 8192 /* Method */; - excludes = 103359 /* MethodExcludes */; + includes = 8192 /* SymbolFlags.Method */; + excludes = 103359 /* SymbolFlags.MethodExcludes */; } // Maybe accessor-like else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { @@ -47963,27 +48062,27 @@ var ts; })) { // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) - includes |= 65536 /* SetAccessor */ | 4 /* Property */; - excludes |= 78783 /* SetAccessorExcludes */; + includes |= 65536 /* SymbolFlags.SetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 78783 /* SymbolFlags.SetAccessorExcludes */; } if (ts.some(declaration.arguments[2].properties, function (p) { var id = ts.getNameOfDeclaration(p); return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; })) { - includes |= 32768 /* GetAccessor */ | 4 /* Property */; - excludes |= 46015 /* GetAccessorExcludes */; + includes |= 32768 /* SymbolFlags.GetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 46015 /* SymbolFlags.GetAccessorExcludes */; } } - if (includes === 0 /* None */) { - includes = 4 /* Property */; - excludes = 0 /* PropertyExcludes */; + if (includes === 0 /* SymbolFlags.None */) { + includes = 4 /* SymbolFlags.Property */; + excludes = 0 /* SymbolFlags.PropertyExcludes */; } - declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* SymbolFlags.Assignment */, excludes & ~67108864 /* SymbolFlags.Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SourceFile */ - : propertyAccess.parent.parent.kind === 305 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SyntaxKind.SourceFile */ + : propertyAccess.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -48002,7 +48101,7 @@ var ts; * - with non-empty object literals if assigned to the prototype property */ function isExpandoSymbol(symbol) { - if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 1024 /* SymbolFlags.NamespaceModule */)) { return true; } var node = symbol.valueDeclaration; @@ -48017,7 +48116,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || init.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -48062,12 +48161,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 257 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); + if (node.kind === 257 /* SyntaxKind.ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */); } else { - var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__class" /* InternalSymbolName.Class */; + bindAnonymousDeclaration(node, 32 /* SymbolFlags.Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { classifiableNames.add(node.name.escapedText); @@ -48083,7 +48182,7 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype"); + var prototypeSymbol = createSymbol(4 /* SymbolFlags.Property */ | 4194304 /* SymbolFlags.Prototype */, "prototype"); var symbolExport = symbol.exports.get(prototypeSymbol.escapedName); if (symbolExport) { if (node.name) { @@ -48096,23 +48195,23 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent; + var possibleVariableDecl = node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node : node.parent.parent; if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !ts.getJSDocTypeTag(node) && - !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) { + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); + bindBlockScopedDeclaration(node, 2 /* SymbolFlags.BlockScopedVariable */, 111551 /* SymbolFlags.BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -48124,72 +48223,72 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) { + if (node.kind === 340 /* SyntaxKind.JSDocParameterTag */ && container.kind !== 323 /* SyntaxKind.JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) { + if (inStrictMode && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); + bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } if (currentFlow) { node.flowNode = currentFlow; } checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.escapedText : "__function" /* Function */; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__function" /* InternalSymbolName.Function */; + return bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { node.flowNode = currentFlow; } return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* InternalSymbolName.Computed */) : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function getInferTypeContainer(node) { @@ -48203,45 +48302,45 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } - else if (node.parent.kind === 190 /* InferType */) { + else if (node.parent.kind === 190 /* SyntaxKind.InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 + bindAnonymousDeclaration(node, 262144 /* SymbolFlags.TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); + return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { - if (!(currentFlow.flags & 1 /* Unreachable */)) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) { return false; } if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) || // report error on class declarations - node.kind === 257 /* ClassDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 261 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -48255,9 +48354,9 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 16777216 /* Ambient */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && (!ts.isVariableStatement(node) || - !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); }); } @@ -48281,27 +48380,28 @@ var ts; // Don't remove statements that can validly be used before they appear. return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) && // `var x;` may declare a variable used above - !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); + !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* NodeFlags.Let */ | 2 /* NodeFlags.Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 261 /* ModuleDeclaration */: - return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 260 /* EnumDeclaration */: - return ts.hasSyntacticModifier(s, 2048 /* Const */); + case 261 /* SyntaxKind.ModuleDeclaration */: + return getModuleInstanceState(s) !== 1 /* ModuleInstanceState.Instantiated */; + case 260 /* SyntaxKind.EnumDeclaration */: + return ts.hasSyntacticModifier(s, 2048 /* ModifierFlags.Const */); default: return false; } } function isExportsOrModuleExportsOrAlias(sourceFile, node) { var i = 0; - var q = [node]; - while (q.length && i < 100) { + var q = ts.createQueue(); + q.enqueue(node); + while (!q.isEmpty() && i < 100) { i++; - node = q.shift(); + node = q.dequeue(); if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } @@ -48309,10 +48409,10 @@ var ts; var symbol = lookupSymbolForName(sourceFile, node.escapedText); if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) { var init = symbol.valueDeclaration.initializer; - q.push(init); + q.enqueue(init); if (ts.isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) { - q.push(init.left); - q.push(init.right); + q.enqueue(init.left); + q.enqueue(init.right); } } } @@ -48376,32 +48476,32 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var objectType = type; var objectFlags = objectType.objectFlags; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { visitTypeReference(type); } - if (objectFlags & 32 /* Mapped */) { + if (objectFlags & 32 /* ObjectFlags.Mapped */) { visitMappedType(type); } - if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + if (objectFlags & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { visitInterfaceType(type); } - if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + if (objectFlags & (8 /* ObjectFlags.Tuple */ | 16 /* ObjectFlags.Anonymous */)) { visitObjectType(objectType); } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { visitIndexType(type); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { visitIndexedAccessType(type); } } @@ -48490,7 +48590,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 181 /* TypeQuery */) { + if (d.type && d.type.kind === 181 /* SyntaxKind.TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -48627,16 +48727,16 @@ var ts; // Masks TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask"; TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask"; - })(TypeFacts || (TypeFacts = {})); + })(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {})); var typeofNEFacts = new ts.Map(ts.getEntries({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ + string: 256 /* TypeFacts.TypeofNEString */, + number: 512 /* TypeFacts.TypeofNENumber */, + bigint: 1024 /* TypeFacts.TypeofNEBigInt */, + boolean: 2048 /* TypeFacts.TypeofNEBoolean */, + symbol: 4096 /* TypeFacts.TypeofNESymbol */, + undefined: 524288 /* TypeFacts.NEUndefined */, + object: 8192 /* TypeFacts.TypeofNEObject */, + function: 16384 /* TypeFacts.TypeofNEFunction */ })); var TypeSystemPropertyName; (function (TypeSystemPropertyName) { @@ -48662,7 +48762,7 @@ var ts; CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement"; // e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`, // we need to preserve generic types instead of substituting them for constraints - })(CheckMode || (CheckMode = {})); + })(CheckMode = ts.CheckMode || (ts.CheckMode = {})); var SignatureCheckMode; (function (SignatureCheckMode) { SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback"; @@ -48670,7 +48770,7 @@ var ts; SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes"; SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity"; SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback"; - })(SignatureCheckMode || (SignatureCheckMode = {})); + })(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {})); var IntersectionState; (function (IntersectionState) { IntersectionState[IntersectionState["None"] = 0] = "None"; @@ -48742,10 +48842,10 @@ var ts; IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize"; })(IntrinsicTypeKind || (IntrinsicTypeKind = {})); var intrinsicTypeKinds = new ts.Map(ts.getEntries({ - Uppercase: 0 /* Uppercase */, - Lowercase: 1 /* Lowercase */, - Capitalize: 2 /* Capitalize */, - Uncapitalize: 3 /* Uncapitalize */ + Uppercase: 0 /* IntrinsicTypeKind.Uppercase */, + Lowercase: 1 /* IntrinsicTypeKind.Lowercase */, + Capitalize: 2 /* IntrinsicTypeKind.Capitalize */, + Uncapitalize: 3 /* IntrinsicTypeKind.Uncapitalize */ })); function SymbolLinks() { } @@ -48770,8 +48870,8 @@ var ts; ts.getSymbolId = getSymbolId; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + return moduleState === 1 /* ModuleInstanceState.Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ModuleInstanceState.ConstEnumOnly */); } ts.isInstantiatedModule = isInstantiatedModule; function createTypeChecker(host) { @@ -48786,7 +48886,7 @@ var ts; return; sf.resolvedModules.forEach(function (r) { if (r && r.packageId) - map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name)); + map.set(r.packageId.name, r.extension === ".d.ts" /* Extension.Dts */ || !!map.get(r.packageId.name)); }); }); return map; @@ -48820,7 +48920,7 @@ var ts; var currentNode; var varianceTypeParameter; var emptySymbols = ts.createSymbolTable(); - var arrayVariances = [1 /* Covariant */]; + var arrayVariances = [1 /* VarianceFlags.Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -48834,20 +48934,20 @@ var ts; var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* ObjectFlags.FreshLiteral */; var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); - var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); + var undefinedSymbol = createSymbol(4 /* SymbolFlags.Property */, "undefined"); undefinedSymbol.declarations = []; - var globalThisSymbol = createSymbol(1536 /* Module */, "globalThis", 8 /* Readonly */); + var globalThisSymbol = createSymbol(1536 /* SymbolFlags.Module */, "globalThis", 8 /* CheckFlags.Readonly */); globalThisSymbol.exports = globals; globalThisSymbol.declarations = []; globals.set(globalThisSymbol.escapedName, globalThisSymbol); - var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); - var requireSymbol = createSymbol(4 /* Property */, "require"); + var argumentsSymbol = createSymbol(4 /* SymbolFlags.Property */, "arguments"); + var requireSymbol = createSymbol(4 /* SymbolFlags.Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; // for public members that accept a Node or one of its subtypes, we must guard against @@ -48899,10 +48999,10 @@ var ts; return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined; }, getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, - getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexInfosOfType: getIndexInfosOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexType: function (type) { return getIndexType(type); }, getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, @@ -48997,14 +49097,14 @@ var ts; if (!node) { return undefined; } - if (contextFlags & 4 /* Completions */) { + if (contextFlags & 4 /* ContextFlags.Completions */) { return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); }); } return getContextualType(node, contextFlags); }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); - return node ? getContextualTypeForObjectLiteralElement(node) : undefined; + return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined; }, getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); @@ -49012,19 +49112,19 @@ var ts; }, getContextualTypeForJsxAttribute: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); - return node && getContextualTypeForJsxAttribute(node); + return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined); }, isContextSensitive: isContextSensitive, getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* CheckMode.Normal */); }, getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) { - return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument); + return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* CheckMode.IsForStringLiteralArgumentCompletions */, editingArgument); }, getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* CheckMode.IsForSignatureHelp */); }, getExpandedParameters: getExpandedParameters, hasEffectiveRestParameter: hasEffectiveRestParameter, @@ -49110,7 +49210,7 @@ var ts; getSuggestionForNonexistentExport: getSuggestionForNonexistentExport, getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeFlags.TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -49147,10 +49247,10 @@ var ts; cancellationToken = ct; // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused checkSourceFileWithEagerDiagnostics(file); - ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* NodeCheckFlags.TypeChecked */)); diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); @@ -49218,35 +49318,35 @@ var ts; var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); var subtypeReductionCache = new ts.Map(); + var cachedTypes = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); - var unknownSymbol = createSymbol(4 /* Property */, "unknown"); - var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */); + var unknownSymbol = createSymbol(4 /* SymbolFlags.Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__" /* InternalSymbolName.Resolving */); var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var autoType = createIntrinsicType(1 /* Any */, "any"); - var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var errorType = createIntrinsicType(1 /* Any */, "error"); - var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */); - var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); - var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */); - var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; - var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */); - var stringType = createIntrinsicType(4 /* String */, "string"); - var numberType = createIntrinsicType(8 /* Number */, "number"); - var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); - var falseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); + var anyType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var autoType = createIntrinsicType(1 /* TypeFlags.Any */, "any", 262144 /* ObjectFlags.NonInferrableType */); + var wildcardType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var errorType = createIntrinsicType(1 /* TypeFlags.Any */, "error"); + var unresolvedType = createIntrinsicType(1 /* TypeFlags.Any */, "unresolved"); + var intrinsicMarkerType = createIntrinsicType(1 /* TypeFlags.Any */, "intrinsic"); + var unknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var nonNullUnknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var undefinedType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined", 65536 /* ObjectFlags.ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined") : undefinedType; + var nullType = createIntrinsicType(65536 /* TypeFlags.Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* TypeFlags.Null */, "null", 65536 /* ObjectFlags.ContainsWideningType */); + var stringType = createIntrinsicType(4 /* TypeFlags.String */, "string"); + var numberType = createIntrinsicType(8 /* TypeFlags.Number */, "number"); + var bigintType = createIntrinsicType(64 /* TypeFlags.BigInt */, "bigint"); + var falseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var regularFalseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var trueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); + var regularTrueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); trueType.regularType = regularTrueType; trueType.freshType = trueType; regularTrueType.regularType = regularTrueType; @@ -49256,28 +49356,40 @@ var ts; regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = getUnionType([regularFalseType, regularTrueType]); - var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16384 /* Void */, "void"); - var neverType = createIntrinsicType(131072 /* Never */, "never"); - var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */); - var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); - var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(4096 /* TypeFlags.ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16384 /* TypeFlags.Void */, "void"); + var neverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var silentNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never", 262144 /* ObjectFlags.NonInferrableType */); + var implicitNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* TypeFlags.NonPrimitive */, "object"); var stringOrNumberType = getUnionType([stringType, numberType]); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); - var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }, function () { return "(restrictive mapper)"; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? wildcardType : t; }, function () { return "(permissive mapper)"; }); + var uniqueLiteralType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? uniqueLiteralType : t; }, function () { return "(unique literal mapper)"; }); // replace all type parameters with the unique literal type (disregarding constraints) + var outofbandVarianceMarkerHandler; + var reportUnreliableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true); + } + return t; + }, function () { return "(unmeasurable reporter)"; }); + var reportUnmeasurableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false); + } + return t; + }, function () { return "(unreliable reporter)"; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); - emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + emptyJsxObjectType.objectFlags |= 2048 /* ObjectFlags.JsxAttributes */; + var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType; @@ -49286,7 +49398,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 262144 /* NonInferrableType */; + anyFunctionType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -49294,11 +49406,14 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var markerSuperTypeForCheck = createTypeParameter(); + var markerSubTypeForCheck = createTypeParameter(); + markerSubTypeForCheck.constraint = markerSuperTypeForCheck; + var noTypePredicate = createTypePredicate(1 /* TypePredicateKind.Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true); var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances var noIterationTypes = { @@ -49430,7 +49545,6 @@ var ts; var typeofType = createTypeofType(); var _jsxNamespace; var _jsxFactoryEntity; - var outofbandVarianceMarkerHandler; var subtypeRelation = new ts.Map(); var strictSubtypeRelation = new ts.Map(); var assignableRelation = new ts.Map(); @@ -49450,12 +49564,20 @@ var ts; [".mjs", ".mjs"], [".js", ".js"], [".cjs", ".cjs"], - [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"], + [".tsx", compilerOptions.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" : ".js"], [".jsx", ".jsx"], [".json", ".json"], ]; initializeTypeChecker(); return checker; + function getCachedType(key) { + return key ? cachedTypes.get(key) : undefined; + } + function setCachedType(key, type) { + if (key) + cachedTypes.set(key, type); + return type; + } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -49596,7 +49718,7 @@ var ts; return diagnostic; } function isDeprecatedSymbol(symbol) { - return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */); + return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* NodeFlags.Deprecated */); } function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); @@ -49610,44 +49732,44 @@ var ts; } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = new Symbol(flags | 33554432 /* Transient */, name); + var symbol = new Symbol(flags | 33554432 /* SymbolFlags.Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 111551 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 111550 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 0 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 900095 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 110991 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899503 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 788872 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 110735 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 103359 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 46015 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 78783 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 526824 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 788968 /* TypeAliasExcludes */; - if (flags & 2097152 /* Alias */) - result |= 2097152 /* AliasExcludes */; + if (flags & 2 /* SymbolFlags.BlockScopedVariable */) + result |= 111551 /* SymbolFlags.BlockScopedVariableExcludes */; + if (flags & 1 /* SymbolFlags.FunctionScopedVariable */) + result |= 111550 /* SymbolFlags.FunctionScopedVariableExcludes */; + if (flags & 4 /* SymbolFlags.Property */) + result |= 0 /* SymbolFlags.PropertyExcludes */; + if (flags & 8 /* SymbolFlags.EnumMember */) + result |= 900095 /* SymbolFlags.EnumMemberExcludes */; + if (flags & 16 /* SymbolFlags.Function */) + result |= 110991 /* SymbolFlags.FunctionExcludes */; + if (flags & 32 /* SymbolFlags.Class */) + result |= 899503 /* SymbolFlags.ClassExcludes */; + if (flags & 64 /* SymbolFlags.Interface */) + result |= 788872 /* SymbolFlags.InterfaceExcludes */; + if (flags & 256 /* SymbolFlags.RegularEnum */) + result |= 899327 /* SymbolFlags.RegularEnumExcludes */; + if (flags & 128 /* SymbolFlags.ConstEnum */) + result |= 899967 /* SymbolFlags.ConstEnumExcludes */; + if (flags & 512 /* SymbolFlags.ValueModule */) + result |= 110735 /* SymbolFlags.ValueModuleExcludes */; + if (flags & 8192 /* SymbolFlags.Method */) + result |= 103359 /* SymbolFlags.MethodExcludes */; + if (flags & 32768 /* SymbolFlags.GetAccessor */) + result |= 46015 /* SymbolFlags.GetAccessorExcludes */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + result |= 78783 /* SymbolFlags.SetAccessorExcludes */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + result |= 526824 /* SymbolFlags.TypeParameterExcludes */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + result |= 788968 /* SymbolFlags.TypeAliasExcludes */; + if (flags & 2097152 /* SymbolFlags.Alias */) + result |= 2097152 /* SymbolFlags.AliasExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -49679,13 +49801,13 @@ var ts; function mergeSymbol(target, source, unidirectional) { if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || - (source.flags | target.flags) & 67108864 /* Assignment */) { + (source.flags | target.flags) & 67108864 /* SymbolFlags.Assignment */) { if (source === target) { // This can happen when an export assigned namespace exports something also erroneously exported at the top level // See `declarationFileNoCrashOnExtraExportModifier` for an example return target; } - if (!(target.flags & 33554432 /* Transient */)) { + if (!(target.flags & 33554432 /* SymbolFlags.Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { return source; @@ -49693,7 +49815,7 @@ var ts; target = cloneSymbol(resolvedTarget); } // Javascript static-property-assignment declarations always merge, even though they are also values - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + if (source.flags & 512 /* SymbolFlags.ValueModule */ && target.flags & 512 /* SymbolFlags.ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums target.constEnumOnlyModule = false; } @@ -49716,7 +49838,7 @@ var ts; recordMergedSymbol(target, source); } } - else if (target.flags & 1024 /* NamespaceModule */) { + else if (target.flags & 1024 /* SymbolFlags.NamespaceModule */) { // Do not report an error when merging `var globalThis` with the built-in `globalThis`, // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. @@ -49725,8 +49847,8 @@ var ts; } } else { // error - var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); - var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var isEitherEnum = !!(target.flags & 384 /* SymbolFlags.Enum */ || source.flags & 384 /* SymbolFlags.Enum */); + var isEitherBlockScoped_1 = !!(target.flags & 2 /* SymbolFlags.BlockScopedVariable */ || source.flags & 2 /* SymbolFlags.BlockScopedVariable */); var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -49737,9 +49859,9 @@ var ts; var symbolName_1 = symbolToString(source); // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { - var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile; + var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* Comparison.LessThan */ ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -49782,7 +49904,7 @@ var ts; err.relatedInformation = err.relatedInformation || []; var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName); var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here); - if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; })) + if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* Comparison.EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* Comparison.EqualTo */; })) return "continue"; ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage); }; @@ -49824,7 +49946,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -49833,7 +49955,7 @@ var ts; } // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); - if (mainModule_1.flags & 1920 /* Namespace */) { + if (mainModule_1.flags & 1920 /* SymbolFlags.Namespace */) { // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you @@ -49848,9 +49970,9 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { // We may need to merge the module augmentation's exports into the target symbols of the resolved exports - var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); + var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */); for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) { var _e = _d[_i], key = _e[0], value = _e[1]; if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { @@ -49883,7 +50005,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks()); @@ -49893,17 +50015,17 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { var symbol = getMergedSymbol(symbols.get(name)); if (symbol) { - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors if (target === unknownSymbol || target.flags & meaning) { @@ -49923,8 +50045,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* SymbolFlags.Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* SymbolFlags.Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -49938,7 +50060,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!ts.outFile(compilerOptions)) || isInTypeQuery(usage) || - declaration.flags & 16777216 /* Ambient */) { + declaration.flags & 16777216 /* NodeFlags.Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -49952,17 +50074,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 203 /* BindingElement */) { + if (declaration.kind === 203 /* SyntaxKind.BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 203 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 203 /* SyntaxKind.BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* SyntaxKind.VariableDeclaration */), usage); } - else if (declaration.kind === 254 /* VariableDeclaration */) { + else if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -49976,7 +50098,7 @@ var ts; } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -49992,19 +50114,19 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 275 /* ExportSpecifier */ || (usage.parent.kind === 271 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 275 /* SyntaxKind.ExportSpecifier */ || (usage.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.isExportEquals) { return true; } - if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { + if (!!(usage.flags & 8388608 /* NodeFlags.JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -50019,9 +50141,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 237 /* VariableStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 237 /* SyntaxKind.VariableStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -50049,7 +50171,7 @@ var ts; var initializerOfProperty = propertyDeclaration.initializer === current; if (initializerOfProperty) { if (ts.isStatic(current.parent)) { - if (declaration.kind === 169 /* MethodDeclaration */) { + if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) { return true; } if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { @@ -50064,7 +50186,7 @@ var ts; } } else { - var isDeclarationInstanceProperty = declaration.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(declaration); + var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -50087,19 +50209,19 @@ var ts; return "quit"; } switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 172 /* GetAccessor */: - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -50124,7 +50246,7 @@ var ts; // - optional chaining pre-es2020 // - nullish coalesce pre-es2020 // - spread assignment in binding pattern pre-es2017 - if (target >= 2 /* ES2015 */) { + if (target >= 2 /* ScriptTarget.ES2015 */) { var links = getNodeLinks(functionLocation); if (links.declarationRequiresScopeChange === undefined) { links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false; @@ -50139,30 +50261,30 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: // do not descend into these return false; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !useDefineForClassFields; + return target < 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: // null coalesce and optional chain pre-es2020 produce temporary variables if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) { - return target < 7 /* ES2020 */; + return target < 7 /* ScriptTarget.ES2020 */; } if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) { - return target < 4 /* ES2017 */; + return target < 4 /* ScriptTarget.ES2017 */; } if (ts.isTypeNode(node)) return false; @@ -50215,35 +50337,35 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) { - useResult = result.flags & 262144 /* TypeParameter */ + if (meaning & result.flags & 788968 /* SymbolFlags.Type */ && lastLocation.kind !== 320 /* SyntaxKind.JSDoc */) { + useResult = result.flags & 262144 /* SymbolFlags.TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 164 /* Parameter */ || - lastLocation.kind === 340 /* JSDocParameterTag */ || - lastLocation.kind === 341 /* JSDocReturnTag */ || - lastLocation.kind === 163 /* TypeParameter */ + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || + lastLocation.kind === 340 /* SyntaxKind.JSDocParameterTag */ || + lastLocation.kind === 341 /* SyntaxKind.JSDocReturnTag */ || + lastLocation.kind === 163 /* SyntaxKind.TypeParameter */ // local types not visible outside the function body : false; } - if (meaning & result.flags & 3 /* Variable */) { + if (meaning & result.flags & 3 /* SymbolFlags.Variable */) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } - else if (result.flags & 1 /* FunctionScopedVariable */) { + else if (result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { // parameters are visible only inside function body, parameter list and return type // technically for parameter list case here we might mix parameters and variables declared in function, // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 164 /* Parameter */ || + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 189 /* ConditionalType */) { + else if (location.kind === 189 /* SyntaxKind.ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -50258,17 +50380,17 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols; - if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 305 /* SyntaxKind.SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports.get("default" /* Default */)) { + if (result = moduleExports.get("default" /* InternalSymbolName.Default */)) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { break loop; @@ -50288,13 +50410,13 @@ var ts; // which is not the desired behavior. var moduleExport = moduleExports.get(name); if (moduleExport && - moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 275 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* NamespaceExport */))) { + moduleExport.flags === 2097152 /* SymbolFlags.Alias */ && + (ts.getDeclarationOfKind(moduleExport, 275 /* SyntaxKind.ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* SyntaxKind.NamespaceExport */))) { break; } } // ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs) - if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) { + if (name !== "default" /* InternalSymbolName.Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */))) { if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) { result = undefined; } @@ -50303,12 +50425,12 @@ var ts; } } break; - case 260 /* EnumDeclaration */: - if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) { + case 260 /* SyntaxKind.EnumDeclaration */: + if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* SymbolFlags.EnumMember */)) { break loop; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -50318,20 +50440,21 @@ var ts; if (!ts.isStatic(location)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* SymbolFlags.Value */)) { // Remember the property node, it will be used later to report appropriate error + ts.Debug.assertNode(location, ts.isPropertyDeclaration); propertyWithInvalidInitializer = location; } } } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* SymbolFlags.Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -50346,7 +50469,7 @@ var ts; } break loop; } - if (location.kind === 226 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 226 /* SyntaxKind.ClassExpression */ && meaning & 32 /* SymbolFlags.Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -50354,11 +50477,11 @@ var ts; } } break; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* SyntaxKind.ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* SymbolFlags.Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -50374,39 +50497,39 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error - if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */) { break; } // falls through - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 213 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 213 /* SyntaxKind.FunctionExpression */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } - if (meaning & 16 /* Function */) { + if (meaning & 16 /* SymbolFlags.Function */) { var functionName = location.name; if (functionName && name === functionName.escapedText) { result = location.symbol; @@ -50414,7 +50537,7 @@ var ts; } } break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -50423,7 +50546,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 164 /* Parameter */) { + if (location.parent && location.parent.kind === 164 /* SyntaxKind.Parameter */) { location = location.parent; } // @@ -50438,20 +50561,20 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* SyntaxKind.ClassDeclaration */)) { location = location.parent; } break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -50459,7 +50582,7 @@ var ts; } } break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -50467,8 +50590,8 @@ var ts; } } break; - case 190 /* InferType */: - if (meaning & 262144 /* TypeParameter */) { + case 190 /* SyntaxKind.InferType */: + if (meaning & 262144 /* SymbolFlags.TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { result = location.typeParameter.symbol; @@ -50493,7 +50616,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 305 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 305 /* SyntaxKind.SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -50509,11 +50632,27 @@ var ts; } } } + // The invalid initializer error is needed in two situation: + // 1. When result is undefined, after checking for a missing "this." + // 2. When result is defined + function checkAndReportErrorForInvalidInitializer() { + if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */)) { + // We have a match, but the reference occurred within a property initializer and the identifier also binds + // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed + // with ESNext+useDefineForClassFields because the scope semantics are different. + error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos) + ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor + : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg)); + return true; + } + return false; + } if (!result) { if (nameNotFoundMessage) { addLazyDiagnostic(function () { if (!errorLocation || !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217 + !checkAndReportErrorForInvalidInitializer() && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) && @@ -50521,7 +50660,16 @@ var ts; !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { var suggestion = void 0; - if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { + var suggestedLib = void 0; + // Report missing lib first + if (nameArg) { + suggestedLib = getSuggestedLibForNonExistentName(nameArg); + if (suggestedLib) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib); + } + } + // then spelling suggestions + if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); if (isGlobalScopeAugmentationDeclaration) { @@ -50530,7 +50678,7 @@ var ts; if (suggestion) { var suggestionName = symbolToString(suggestion); var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false); - var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 + var message = meaning === 1920 /* SymbolFlags.Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1; var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName); @@ -50540,16 +50688,9 @@ var ts; } } } - if (!suggestion) { - if (nameArg) { - var lib = getSuggestedLibForNonExistentName(nameArg); - if (lib) { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib); - } - else { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); - } - } + // And then fall back to unspecified "not found" + if (!suggestion && !suggestedLib && nameArg) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); } suggestionCount++; } @@ -50557,12 +50698,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) { - // We have a match, but the reference occurred within a property initializer and the identifier also binds - // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed - // with ESNext+useDefineForClassFields because the scope semantics are different. - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg)); + else if (checkAndReportErrorForInvalidInitializer()) { return undefined; } // Perform extra checks only if error reporting was requested @@ -50580,22 +50716,22 @@ var ts; // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped if (errorLocation && - (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { + (meaning & 2 /* SymbolFlags.BlockScopedVariable */ || + ((meaning & 32 /* SymbolFlags.Class */ || meaning & 384 /* SymbolFlags.Enum */) && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { + if (exportOrLocalSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* SymbolFlags.Class */ || exportOrLocalSymbol.flags & 384 /* SymbolFlags.Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */ && !(originalLocation.flags & 8388608 /* NodeFlags.JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -50607,10 +50743,10 @@ var ts; error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation)); } } - if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { + if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ + var message = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -50624,31 +50760,31 @@ var ts; function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) { if (!typeOnlyDeclaration) return diagnostic; - return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); + return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 214 /* ArrowFunction */ && location.kind !== 213 /* FunctionExpression */) { + if (location.kind !== 214 /* SyntaxKind.ArrowFunction */ && location.kind !== 213 /* SyntaxKind.FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; } // generator functions and async functions are not inlined in control flow when immediately invoked - if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* Async */)) { + if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* ModifierFlags.Async */)) { return true; } return !ts.getImmediatelyInvokedFunctionExpression(location); } function isSelfReferenceLocation(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: // For `namespace N { N; }` + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -50661,7 +50797,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 163 /* TypeParameter */) { + if (decl.kind === 163 /* SyntaxKind.TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); @@ -50705,7 +50841,7 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { + if (expression && resolveEntityName(expression, 64 /* SymbolFlags.Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); return true; } @@ -50717,10 +50853,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -50730,9 +50866,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* SymbolFlags.Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -50751,9 +50887,9 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1920 /* Namespace */)) { + if (meaning & (788968 /* SymbolFlags.Type */ & ~1920 /* SymbolFlags.Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1920 /* SymbolFlags.Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name)); return true; } @@ -50764,14 +50900,14 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) { if (isPrimitiveTypeName(name)) { if (isExtendedByInterface(errorLocation)) { error(errorLocation, ts.Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, ts.unescapeLeadingUnderscores(name)); @@ -50781,8 +50917,8 @@ var ts; } return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) { var rawName = ts.unescapeLeadingUnderscores(name); if (isES2015OrLaterConstructorName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); @@ -50802,7 +50938,7 @@ var ts; var grandparent = node.parent.parent; var parentOfGrandparent = grandparent.parent; if (grandparent && parentOfGrandparent) { - var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* ExtendsKeyword */; + var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* SyntaxKind.ExtendsKeyword */; var isInterface = ts.isInterfaceDeclaration(parentOfGrandparent); return isExtending && isInterface; } @@ -50814,7 +50950,7 @@ var ts; }); if (container && container.members.length === 1) { var type = getDeclaredTypeOfSymbol(symbol); - return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true); + return !!(type.flags & 1048576 /* TypeFlags.Union */) && allTypesAssignableToKind(type, 384 /* TypeFlags.StringOrNumberLiteral */, /*strict*/ true); } return false; } @@ -50831,15 +50967,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -50849,29 +50985,29 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { var _a; - ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); - if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */)); + if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); - if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); - if (result.flags & 2 /* BlockScopedVariable */) { + if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } - else if (result.flags & 32 /* Class */) { + else if (result.flags & 32 /* SymbolFlags.Class */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } - else if (result.flags & 256 /* RegularEnum */) { + else if (result.flags & 256 /* SymbolFlags.RegularEnum */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } else { - ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */)); if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } @@ -50892,13 +51028,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.parent; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -50923,24 +51059,24 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ - || node.kind === 264 /* NamespaceExportDeclaration */ - || node.kind === 267 /* ImportClause */ && !!node.name - || node.kind === 268 /* NamespaceImport */ - || node.kind === 274 /* NamespaceExport */ - || node.kind === 270 /* ImportSpecifier */ - || node.kind === 275 /* ExportSpecifier */ - || node.kind === 271 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) - || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name + || node.kind === 268 /* SyntaxKind.NamespaceImport */ + || node.kind === 274 /* SyntaxKind.NamespaceExport */ + || node.kind === 270 /* SyntaxKind.ImportSpecifier */ + || node.kind === 275 /* SyntaxKind.ExportSpecifier */ + || node.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.exportAssignmentIsAlias(node) + || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 297 /* ShorthandPropertyAssignment */ - || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) - || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent); + || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) + || node.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -50953,7 +51089,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -50966,7 +51102,7 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var isExport = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */; + var isExport = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */; var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; @@ -50978,14 +51114,14 @@ var ts; } } function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) { - var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportValue = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node)); } function getUsageModeForExpression(usage) { return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined; @@ -50995,7 +51131,7 @@ var ts; } function isOnlyImportedAsDefault(usage) { var usageMode = getUsageModeForExpression(usage); - return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */); + return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Extension.Json */); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) { var usageMode = file && getUsageModeForExpression(usage); @@ -51012,7 +51148,7 @@ var ts; // Declaration files (and ambient modules) if (!file || file.isDeclarationFile) { // Definitely cannot have a synthetic default if they have a syntactic default member specified - var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration + var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) { return false; } @@ -51044,7 +51180,7 @@ var ts; exportDefaultSymbol = moduleSymbol; } else { - exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); + exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias); } var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier); @@ -51052,7 +51188,7 @@ var ts; if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) { if (hasExportAssignmentSymbol(moduleSymbol)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; - var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportAssignment = exportEqualsSymbol.valueDeclaration; var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName); if (exportAssignment) { @@ -51080,12 +51216,12 @@ var ts; } else { var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); + var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */); if (exportStar) { var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) { var _a, _b; return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && - ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); + ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */))); }); if (defaultExport) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default)); @@ -51129,7 +51265,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -51144,7 +51280,7 @@ var ts; return result; } function getExportOfModule(symbol, name, specifier, dontResolveAlias) { - if (symbol.flags & 1536 /* Module */) { + if (symbol.flags & 1536 /* SymbolFlags.Module */) { var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); @@ -51152,7 +51288,7 @@ var ts; } } function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); @@ -51168,7 +51304,7 @@ var ts; if (!ts.isIdentifier(name)) { return undefined; } - var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); + var suppressInteropError = name.escapedText === "default" /* InternalSymbolName.Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -51177,7 +51313,7 @@ var ts; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true); } else { @@ -51186,7 +51322,7 @@ var ts; // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); - if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { + if (symbolFromModule === undefined && name.escapedText === "default" /* InternalSymbolName.Default */) { var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -51207,7 +51343,7 @@ var ts; } } else { - if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)) { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { @@ -51224,7 +51360,7 @@ var ts; var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { - var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); + var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportedEqualsSymbol) { getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); @@ -51304,19 +51440,15 @@ var ts; if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { return undefined; } - var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } - function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { - var expression = node.initializer; - return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); - } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -51324,31 +51456,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: - case 254 /* VariableDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 270 /* ImportSpecifier */: - case 203 /* BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 275 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, dontRecursivelyResolve); + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 297 /* ShorthandPropertyAssignment */: - return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 296 /* PropertyAssignment */: - return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 296 /* SyntaxKind.PropertyAssignment */: + return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve); + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -51359,16 +51491,16 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); + return (symbol.flags & (2097152 /* SymbolFlags.Alias */ | excludes)) === 2097152 /* SymbolFlags.Alias */ || !!(symbol.flags & 2097152 /* SymbolFlags.Alias */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */); } function resolveSymbol(symbol, dontResolveAlias) { return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.aliasTarget) { links.aliasTarget = resolvingSymbol; @@ -51433,7 +51565,7 @@ var ts; function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) { var _a, _b, _c; if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) { - var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */)) !== null && _b !== void 0 ? _b : target; + var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)) !== null && _b !== void 0 ? _b : target; var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false; } @@ -51441,7 +51573,7 @@ var ts; } /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */ function getTypeOnlyAliasDeclaration(symbol) { - if (!(symbol.flags & 2097152 /* Alias */)) { + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) { return undefined; } var links = getSymbolLinks(symbol); @@ -51452,7 +51584,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); + ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -51473,7 +51605,7 @@ var ts; // position. if (ts.isInternalModuleImportEqualsDeclaration(node)) { var target = resolveSymbol(symbol); - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // import foo = checkExpressionCached(node.moduleReference); } @@ -51496,22 +51628,22 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* SyntaxKind.Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 161 /* QualifiedName */) { - return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + if (entityName.kind === 79 /* SyntaxKind.Identifier */ || entityName.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + return resolveEntityName(entityName, 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 265 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { - return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */); + return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); } function getContainingQualifiedNameNode(node) { while (ts.isQualifiedName(node.parent)) { @@ -51521,7 +51653,7 @@ var ts; } function tryGetQualifiedNameAsValue(node) { var left = ts.getFirstIdentifier(node); - var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true); + var symbol = resolveName(left, left.escapedText, 111551 /* SymbolFlags.Value */, undefined, left, /*isUse*/ true); if (!symbol) { return undefined; } @@ -51542,9 +51674,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* SymbolFlags.Value */ : 0); var symbol; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false)); @@ -51552,9 +51684,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 161 /* QualifiedName */ || name.kind === 206 /* PropertyAccessExpression */) { - var left = name.kind === 161 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 161 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 161 /* SyntaxKind.QualifiedName */ || name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var left = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.left : name.expression; + var right = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -51588,7 +51720,7 @@ var ts; } var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name); var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet - && (meaning & 788968 /* Type */) + && (meaning & 788968 /* SymbolFlags.Type */) && containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName); @@ -51596,8 +51728,8 @@ var ts; error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName)); return undefined; } - if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) { - var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */)); + if (meaning & 1920 /* SymbolFlags.Namespace */ && ts.isQualifiedName(name.parent)) { + var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* SymbolFlags.Type */)); if (exportedTypeSymbol) { error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText)); return undefined; @@ -51611,8 +51743,8 @@ var ts; else { throw ts.Debug.assertNever(name, "Unknown entity name kind."); } - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 271 /* ExportAssignment */)) { + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* SymbolFlags.Alias */ || name.parent.kind === 271 /* SyntaxKind.ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -51632,7 +51764,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* NodeFlags.JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -51653,7 +51785,7 @@ var ts; } if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) && ts.isBinaryExpression(host.parent.parent) && - ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { // X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration var symbol = getSymbolOfNode(host.parent.parent.left); if (symbol) { @@ -51684,7 +51816,7 @@ var ts; */ function getExpandoSymbol(symbol) { var decl = symbol.valueDeclaration; - if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* SymbolFlags.TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { return undefined; } var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); @@ -51751,7 +51883,40 @@ var ts; // An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of // normal mode restrictions if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { - error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); + if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) { + // ImportEquals in a ESM file resolving to another ESM file + error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference); + } + else { + // CJS file resolving to an ESM file + var diagnosticDetails = void 0; + var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName); + if (ext === ".ts" /* Extension.Ts */ || ext === ".js" /* Extension.Js */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".jsx" /* Extension.Jsx */) { + var scope = currentSourceFile.packageJsonScope; + var targetExt = ext === ".ts" /* Extension.Ts */ ? ".mts" /* Extension.Mts */ : ext === ".js" /* Extension.Js */ ? ".mjs" /* Extension.Mjs */ : undefined; + if (scope && !scope.packageJsonContent.type) { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, targetExt, ts.combinePaths(scope.packageDirectory, "package.json")); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0, ts.combinePaths(scope.packageDirectory, "package.json")); + } + } + else { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, targetExt); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module); + } + } + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, ts.chainDiagnosticMessages(diagnosticDetails, ts.Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference))); + } } } // merged symbol is module declaration symbol combined with all augmentations @@ -51816,12 +51981,12 @@ var ts; * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (moduleKind >= ts.ModuleKind.ES2015) { - replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js"; + replacedImportSource += tsExtension === ".mts" /* Extension.Mts */ ? ".mjs" : tsExtension === ".cts" /* Extension.Cts */ ? ".cjs" : ".js"; } error(errorNode, diag, tsExtension, replacedImportSource); } else if (!compilerOptions.resolveJsonModule && - ts.fileExtensionIs(moduleReference, ".json" /* Json */) && + ts.fileExtensionIs(moduleReference, ".json" /* Extension.Json */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); @@ -51868,27 +52033,27 @@ var ts; } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { - var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */), dontResolveAlias); var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* SymbolFlags.Alias */) { return exported; } var links = getSymbolLinks(exported); if (links.cjsExportMerged) { return links.cjsExportMerged; } - var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); - merged.flags = merged.flags | 512 /* ValueModule */; + var merged = exported.flags & 33554432 /* SymbolFlags.Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* SymbolFlags.ValueModule */; if (merged.exports === undefined) { merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { - if (name === "export=" /* ExportEquals */) + if (name === "export=" /* InternalSymbolName.ExportEquals */) return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); @@ -51902,7 +52067,7 @@ var ts; var _a; var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -51921,12 +52086,12 @@ var ts; var targetFile = (_a = moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat); if (ts.getESModuleInterop(compilerOptions) || isEsmCjsRef) { - var sigs = getSignaturesOfStructuredType(type, 0 /* Call */); + var sigs = getSignaturesOfStructuredType(type, 0 /* SignatureKind.Call */); if (!sigs || !sigs.length) { - sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); + sigs = getSignaturesOfStructuredType(type, 1 /* SignatureKind.Construct */); } if ((sigs && sigs.length) || - getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true) || + getPropertyOfType(type, "default" /* InternalSymbolName.Default */, /*skipObjectFunctionPropertyAugment*/ true) || isEsmCjsRef) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); @@ -51958,7 +52123,7 @@ var ts; return result; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; + return moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -52010,15 +52175,15 @@ var ts; return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; } function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { - return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || - ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ || + return !(resolvedExternalModuleType.flags & 131068 /* TypeFlags.Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* ObjectFlags.Class */ || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path isArrayType(resolvedExternalModuleType) || isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : - symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { @@ -52033,7 +52198,7 @@ var ts; if (!source) return; source.forEach(function (sourceSymbol, id) { - if (id === "default" /* Default */) + if (id === "default" /* InternalSymbolName.Default */) return; var targetSymbol = target.get(id); if (!targetSymbol) { @@ -52068,7 +52233,7 @@ var ts; } var symbols = new ts.Map(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports.get("__export" /* ExportStar */); + var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */); if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); @@ -52157,21 +52322,21 @@ var ts; function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) { var container = getParentOfSymbol(symbol); // Type parameters end up in the `members` lists but are not externally visible - if (container && !(symbol.flags & 262144 /* TypeParameter */)) { + if (container && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && - getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */, /*externalOnly*/ false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope } // we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type // which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`) var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) - && container.flags & 788968 /* Type */ - && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ - && meaning === 111551 /* Value */ + && container.flags & 788968 /* SymbolFlags.Type */ + && getDeclaredTypeOfSymbol(container).flags & 524288 /* TypeFlags.Object */ + && meaning === 111551 /* SymbolFlags.Value */ ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { return ts.forEachEntry(t, function (s) { if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { @@ -52195,7 +52360,7 @@ var ts; return getSymbolOfNode(d.parent.parent); } } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { return getSymbolOfNode(ts.getSourceFileOfNode(d)); } @@ -52216,7 +52381,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations); - if (meaning & 111551 /* Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { + if (meaning & 111551 /* SymbolFlags.Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) { return getSymbolOfNode(firstDecl.parent); } @@ -52224,7 +52389,7 @@ var ts; } function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) { var fileSymbol = getExternalModuleContainer(d); - var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); + var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } function getAliasForSymbolInContainer(container, symbol) { @@ -52234,7 +52399,7 @@ var ts; } // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return // the container itself as the alias for the symbol - var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + var exportEquals = container.exports && container.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { return container; } @@ -52258,17 +52423,17 @@ var ts; } } function getExportSymbolOfValueSymbolIfExported(symbol) { - return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 && symbol.exportSymbol || symbol); + return getMergedSymbol(symbol && (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol, includeTypeOnlyMembers) { - return !!(symbol.flags & 111551 /* Value */ || - symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); + return !!(symbol.flags & 111551 /* SymbolFlags.Value */ || + symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 171 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -52291,7 +52456,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(524288 /* Object */); + var type = createType(524288 /* TypeFlags.Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -52305,7 +52470,7 @@ var ts; return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { - var type = createType(262144 /* TypeParameter */); + var type = createType(262144 /* TypeFlags.TypeParameter */); if (symbol) type.symbol = symbol; return type; @@ -52315,11 +52480,11 @@ var ts; // with at least two underscores. The @ character indicates that the name is denoted by a well known ES // Symbol instance and the # character indicates that the name is a PrivateIdentifier. function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */ && - name.charCodeAt(2) !== 35 /* hash */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 64 /* CharacterCodes.at */ && + name.charCodeAt(2) !== 35 /* CharacterCodes.hash */; } function getNamedMembers(members) { var result; @@ -52351,14 +52516,14 @@ var ts; return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) { - return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); + return setStructuredTypeMembers(createObjectType(16 /* ObjectFlags.Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); } function getResolvedTypeWithoutAbstractConstructSignatures(type) { if (type.constructSignatures.length === 0) return type; if (type.objectTypeWithoutAbstractConstructSignatures) return type.objectTypeWithoutAbstractConstructSignatures; - var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); }); + var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (type.constructSignatures === constructSignatures) return type; var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos); @@ -52376,12 +52541,12 @@ var ts; } } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred @@ -52390,9 +52555,9 @@ var ts; return { value: result }; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -52403,7 +52568,7 @@ var ts; var table_1; // TODO: Should this filtered table be cached in some way? (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { - if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) { (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); @@ -52422,7 +52587,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); } @@ -52433,7 +52598,7 @@ var ts; var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -52477,9 +52642,9 @@ var ts; } // Check if symbol is any of the aliases in scope var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" /* ExportEquals */ - && symbolFromSymbolTable.escapedName !== "default" /* Default */ + if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ + && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */ && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) @@ -52487,7 +52652,7 @@ var ts; && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -52531,7 +52696,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -52546,10 +52711,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: continue; default: return false; @@ -52560,16 +52725,16 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* SymbolFlags.Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* SymbolFlags.Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) { var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ false); - return access.accessibility === 0 /* Accessible */; + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) { if (!ts.length(symbols)) @@ -52599,7 +52764,7 @@ var ts; } // Any meaning of a module symbol is always accessible via an `import` type return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } } @@ -52623,14 +52788,14 @@ var ts; } if (earlyModuleBail) { return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } if (hadAccessibleChain) { return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined, + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */) : undefined, }; } } @@ -52659,7 +52824,7 @@ var ts; if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { - accessibility: 2 /* CannotBeNamed */, + accessibility: 2 /* SymbolAccessibility.CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule), errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, @@ -52668,28 +52833,28 @@ var ts; } // Just a local name that is not accessible return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } - return { accessibility: 0 /* Accessible */ }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } function getExternalModuleContainer(declaration) { var node = ts.findAncestor(declaration, hasExternalModuleSymbol); return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* SyntaxKind.Identifier */; }), getIsDeclarationVisible)) { return undefined; } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { var _a, _b; if (!isDeclarationVisible(declaration)) { @@ -52697,27 +52862,39 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !ts.hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + !ts.hasSyntacticModifier(anyImportSyntax, 1 /* ModifierFlags.Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); } else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) && - !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* ModifierFlags.Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); } else if (ts.isLateVisibilityPaintedStatement(declaration) // unexported top-level statement - && !ts.hasSyntacticModifier(declaration, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration, 1 /* ModifierFlags.Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement - && ts.isVariableDeclaration(declaration.parent.parent) - && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) - && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) - && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { - return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + else if (ts.isBindingElement(declaration)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement + && ts.isVariableDeclaration(declaration.parent.parent) + && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* ModifierFlags.Export */) + && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) + && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + } + else if (symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement); + if (ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */)) { + return true; + } + if (!isDeclarationVisible(variableStatement.parent)) { + return false; + } + return addVisibleAlias(declaration, variableStatement); + } } // Declaration is not visible return false; @@ -52738,86 +52915,86 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 181 /* TypeQuery */ || - entityName.parent.kind === 228 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || - entityName.parent.kind === 162 /* ComputedPropertyName */) { + if (entityName.parent.kind === 181 /* SyntaxKind.TypeQuery */ || + entityName.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || + entityName.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Typeof value - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } - else if (entityName.kind === 161 /* QualifiedName */ || entityName.kind === 206 /* PropertyAccessExpression */ || - entityName.parent.kind === 265 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 161 /* SyntaxKind.QualifiedName */ || entityName.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 788968 /* Type */; + meaning = 788968 /* SymbolFlags.Type */; } var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); - if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) { - return { accessibility: 0 /* Accessible */ }; + if (symbol && symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && meaning & 788968 /* SymbolFlags.Type */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } - if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) { - return { accessibility: 0 /* Accessible */ }; + if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) { - if (flags === void 0) { flags = 4 /* AllowAnyNodeKind */; } - var nodeFlags = 70221824 /* IgnoreErrors */; - if (flags & 2 /* UseOnlyExternalAliasing */) { - nodeFlags |= 128 /* UseOnlyExternalAliasing */; + if (flags === void 0) { flags = 4 /* SymbolFormatFlags.AllowAnyNodeKind */; } + var nodeFlags = 70221824 /* NodeBuilderFlags.IgnoreErrors */; + if (flags & 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */) { + nodeFlags |= 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */; } - if (flags & 1 /* WriteTypeParametersOrArguments */) { - nodeFlags |= 512 /* WriteTypeParametersInQualifiedName */; + if (flags & 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */) { + nodeFlags |= 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; } - if (flags & 8 /* UseAliasDefinedOutsideCurrentScope */) { - nodeFlags |= 16384 /* UseAliasDefinedOutsideCurrentScope */; + if (flags & 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */) { + nodeFlags |= 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; } - if (flags & 16 /* DoNotIncludeSymbolChain */) { - nodeFlags |= 134217728 /* DoNotIncludeSymbolChain */; + if (flags & 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */) { + nodeFlags |= 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */; } - var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; + var builder = flags & 4 /* SymbolFormatFlags.AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SyntaxKind.SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; - if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructorType */ : 179 /* FunctionType */; + if (flags & 262144 /* TypeFormatFlags.WriteArrowStyleSignature */) { + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 180 /* SyntaxKind.ConstructorType */ : 179 /* SyntaxKind.FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructSignature */ : 174 /* CallSignature */; + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 175 /* SyntaxKind.ConstructSignature */ : 174 /* SyntaxKind.CallSignature */; } - var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); + var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* EmitHint.Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } - var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */; - var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer); + var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* TypeFormatFlags.NoTruncation */; + var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | (noTruncation ? 1 /* NodeBuilderFlags.NoTruncation */ : 0), writer); if (typeNode === undefined) return ts.Debug.fail("should always get typenode"); // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. @@ -52825,7 +53002,7 @@ var ts; var options = { removeComments: type !== unresolvedType }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { @@ -52843,17 +53020,17 @@ var ts; return [leftStr, rightStr]; } function getTypeNameForErrorDisplay(type) { - return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); + return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { - if (flags === void 0) { flags = 0 /* None */; } - return flags & 814775659 /* NodeBuilderFlagsMask */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + return flags & 848330091 /* TypeFormatFlags.NodeBuilderFlagsMask */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); + return !!type.symbol && !!(type.symbol.flags & 32 /* SymbolFlags.Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* TypeFlags.Object */) && !!(ts.getObjectFlags(type) & 16777216 /* ObjectFlags.IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -52887,12 +53064,12 @@ var ts; }; function withContext(enclosingDeclaration, flags, tracker, cb) { var _a, _b; - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0); var context = { enclosingDeclaration: enclosingDeclaration, - flags: flags || 0 /* None */, + flags: flags || 0 /* NodeBuilderFlags.None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache), @@ -52914,7 +53091,7 @@ var ts; }; context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); - if (context.truncating && context.flags & 1 /* NoTruncation */) { + if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) { (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); } return context.encounteredError ? undefined : resultingNode; @@ -52949,62 +53126,68 @@ var ts; function checkTruncationLength(context) { if (context.truncating) return context.truncating; - return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); + return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { + var savedFlags = context.flags; + var typeNode = typeToTypeNodeWorker(type, context); + context.flags = savedFlags; + return typeNode; + } + function typeToTypeNodeWorker(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } - var inTypeAlias = context.flags & 8388608 /* InTypeAlias */; - context.flags &= ~8388608 /* InTypeAlias */; + var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */; + context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */; if (!type) { - if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (!(context.flags & 536870912 /* NoTypeReduction */)) { + if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) { type = getReducedType(type); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { if (type.aliasSymbol) { return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); } if (type === unresolvedType) { - return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved"); + return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved"); } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */); } - if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + if (type.flags & 2 /* TypeFlags.Unknown */) { + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } - if (type.flags & 4 /* String */) { + if (type.flags & 4 /* TypeFlags.String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(158 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */); } - if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { + if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */); } - if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { + if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */); if (getDeclaredTypeOfSymbol(parentSymbol) === type) { return parentName; } var memberName = ts.symbolName(type.symbol); - if (ts.isIdentifierText(memberName, 0 /* ES3 */)) { + if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) { return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); } if (ts.isImportTypeNode(parentName)) { @@ -53018,66 +53201,66 @@ var ts; return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + if (type.flags & 1056 /* TypeFlags.EnumLike */) { + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - if (type.flags & 128 /* StringLiteral */) { + if (type.flags & 128 /* TypeFlags.StringLiteral */) { context.approximateLength += (type.value.length + 2); - return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */)); + return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */)), 16777216 /* EmitFlags.NoAsciiEscaping */)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); + return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value))); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse()); } - if (type.flags & 8192 /* UniqueESSymbol */) { - if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + if (!(context.flags & 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 111551 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* SymbolFlags.Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(154 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(154 /* SyntaxKind.UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */)); } - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */); } - if (type.flags & 32768 /* Undefined */) { + if (type.flags & 32768 /* TypeFlags.Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { context.approximateLength += 4; return ts.factory.createLiteralTypeNode(ts.factory.createNull()); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */); } - if (type.flags & 4096 /* ESSymbol */) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */); } - if (type.flags & 67108864 /* NonPrimitive */) { + if (type.flags & 67108864 /* TypeFlags.NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(148 /* SyntaxKind.ObjectKeyword */); } if (ts.isThisTypeParameter(type)) { - if (context.flags & 4194304 /* InObjectTypeLiteral */) { - if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { + if (context.flags & 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */) { + if (!context.encounteredError && !(context.flags & 32768 /* NodeBuilderFlags.AllowThisInObjectLiteral */)) { context.encounteredError = true; } if (context.tracker.reportInaccessibleThisError) { @@ -53087,22 +53270,22 @@ var ts; context.approximateLength += 4; return ts.factory.createThisTypeNode(); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* SymbolFlags.Class */)) return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes); if (ts.length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) { return ts.factory.createArrayTypeNode(typeArgumentNodes[0]); } - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); } var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & 4 /* ObjectFlags.Reference */) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } - if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ || objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); var constraintNode = void 0; var constraint = getConstraintOfTypeParameter(type); @@ -53119,8 +53302,8 @@ var ts; } return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode)); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 262144 /* TypeParameter */ && + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name_2 = typeParameterToName(type, context); context.approximateLength += ts.idText(name_2).length; @@ -53128,43 +53311,43 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? - (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; + var name = (type === markerSuperTypeForCheck || type === markerSubTypeForCheck) && varianceTypeParameter && varianceTypeParameter.symbol ? + (type === markerSubTypeForCheck ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined); } - if (type.flags & 1048576 /* Union */ && type.origin) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.origin) { type = type.origin; } - if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { - var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + var types = type.flags & 1048576 /* TypeFlags.Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - return type.flags & 1048576 /* Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); } else { - if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!context.encounteredError && !(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } return undefined; // TODO: GH#18217 } } - if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, indexTypeNode); } - if (type.flags & 134217728 /* TemplateLiteral */) { + if (type.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts_1 = type.texts; var types_1 = type.types; var templateHead = ts.factory.createTemplateHead(texts_1[0]); @@ -53172,32 +53355,32 @@ var ts; context.approximateLength += 2; return ts.factory.createTemplateLiteralType(templateHead, templateSpans); } - if (type.flags & 268435456 /* StringMapping */) { + if (type.flags & 268435456 /* TypeFlags.StringMapping */) { var typeNode = typeToTypeNodeHelper(type.type, context); - return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, [typeNode]); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); }); } - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return typeToTypeNodeHelper(type.baseType, context); } return ts.Debug.fail("Should be unreachable."); function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); context.approximateLength += 15; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeFlags.TypeParameter */)) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); var newTypeVariable = ts.factory.createTypeReferenceNode(name); context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type - var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.mapper); var saveInferTypeParameters_1 = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); @@ -53214,7 +53397,7 @@ var ts; // On the other hand, // checkType extends infer T extends checkType ? T extends extendsType ? trueType : falseType : never; // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS. - return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -53226,9 +53409,9 @@ var ts; } function typeToTypeNodeOrCircularityElision(type) { var _a, _b, _c; - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) { - if (!(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + if (!(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b); } @@ -53238,8 +53421,12 @@ var ts; } return typeToTypeNodeHelper(type, context); } + function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) { + return isMappedTypeWithKeyofConstraintDeclaration(type) + && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */); + } function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -53247,27 +53434,28 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); } - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; - var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined); context.approximateLength += 10; - var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + var result = ts.setEmitFlags(mappedTypeNode, 1 /* EmitFlags.SingleLine */); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { // homomorphic mapped type with a non-homomorphic naive inlining // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting // type stays homomorphic - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName), originalConstraint.flags & 2 /* TypeFlags.Unknown */ ? undefined : typeToTypeNodeHelper(originalConstraint, context))), result, ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } return result; } @@ -53276,16 +53464,16 @@ var ts; var typeId = type.id; var symbol = type.symbol; if (symbol) { - var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = isClassInstanceSide(type) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */; if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ + else if (symbol.flags & 32 /* SymbolFlags.Class */ && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* Accessible */)) || - symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */)) || + symbol.flags & (384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); } @@ -53294,7 +53482,7 @@ var ts; var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 788968 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* SymbolFlags.Type */); } else { return createElidedInformationPlaceholder(context); @@ -53310,26 +53498,26 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var _a; - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* SymbolFlags.Method */) && // typeof static method ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); }); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* SymbolFlags.Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 305 /* SourceFile */ || declaration.parent.kind === 262 /* ModuleBlock */; + return declaration.parent.kind === 305 /* SyntaxKind.SourceFile */ || declaration.parent.kind === 262 /* SyntaxKind.ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + return (!!(context.flags & 4096 /* NodeBuilderFlags.UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively + (!(context.flags & 8 /* NodeBuilderFlags.UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } function visitAndTransformType(type, transform) { var _a, _b; var typeId = type.id; - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : - type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) : + var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */; + var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) : type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : undefined; // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead @@ -53341,7 +53529,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -53400,20 +53588,20 @@ var ts; if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { context.approximateLength += 2; - return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* EmitFlags.SingleLine */); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* SyntaxKind.FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* SyntaxKind.ConstructorType */, context); return signatureNode; } } - var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); }); + var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (ts.some(abstractSignatures)) { var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature); // count the number of type elements excluding abstract constructors @@ -53422,8 +53610,8 @@ var ts; resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per // the logic in `createTypeNodesFromResolvedType`. - (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? - ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* Prototype */); }) : + (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ ? + ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */); }) : ts.length(resolved.properties)); // don't include an empty object literal if there were no other static-side // properties to write, i.e. `abstract class C { }` becomes `abstract new () => {}` @@ -53435,27 +53623,27 @@ var ts; return typeToTypeNodeHelper(getIntersectionType(types), context); } var savedFlags = context.flags; - context.flags |= 4194304 /* InObjectTypeLiteral */; + context.flags |= 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */; var members = createTypeNodesFromResolvedType(resolved); context.flags = savedFlags; var typeLiteralNode = ts.factory.createTypeLiteralNode(members); context.approximateLength += 2; - ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); + ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* NodeBuilderFlags.MultilineObjectLiterals */) ? 0 : 1 /* EmitFlags.SingleLine */); return typeLiteralNode; } function typeReferenceToTypeNode(type) { var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { - if (context.flags & 2 /* WriteArrayAsGenericType */) { + if (context.flags & 2 /* NodeBuilderFlags.WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]); } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, arrayType); } - else if (type.target.objectFlags & 8 /* Tuple */) { - typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); }); + else if (type.target.objectFlags & 8 /* ObjectFlags.Tuple */) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* ElementFlags.Optional */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -53463,7 +53651,7 @@ var ts; if (type.target.labeledElementDeclarations) { for (var i = 0; i < tupleConstituentNodes.length; i++) { var flags = type.target.elementFlags[i]; - tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* Variable */ ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : + tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* ElementFlags.Variable */ ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* ElementFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]); } } @@ -53471,23 +53659,23 @@ var ts; for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) { var flags = type.target.elementFlags[i]; tupleConstituentNodes[i] = - flags & 12 /* Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : - flags & 2 /* Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : + flags & 12 /* ElementFlags.Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : + flags & 2 /* ElementFlags.Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]; } } - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } - if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + if (context.encounteredError || (context.flags & 524288 /* NodeBuilderFlags.AllowEmptyTuple */)) { + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 } - else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && + else if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { @@ -53511,8 +53699,8 @@ var ts; if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_3 = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var ref = symbolToTypeNode(parent, context, 788968 /* SymbolFlags.Type */, typeArgumentSlice); context.flags = flags_3; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -53524,8 +53712,8 @@ var ts; typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); } var flags = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -53589,17 +53777,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* SyntaxKind.CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - if (signature.flags & 4 /* Abstract */) + if (signature.flags & 4 /* SignatureFlags.Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* SyntaxKind.ConstructSignature */, context)); } for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { var info = _e[_d]; - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); } var properties = resolvedType.properties; if (!properties) { @@ -53609,16 +53797,16 @@ var ts; for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) { var propertySymbol = properties_1[_f]; i++; - if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) { - if (propertySymbol.flags & 4194304 /* Prototype */) { + if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) { + if (propertySymbol.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } - if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName)); } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... " + (properties.length - i) + " more ...", /*questionToken*/ undefined, /*type*/ undefined)); + typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... ".concat(properties.length - i, " more ..."), /*questionToken*/ undefined, /*type*/ undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -53629,10 +53817,10 @@ var ts; } function createElidedInformationPlaceholder(context) { context.approximateLength += 3; - if (!(context.flags & 1 /* NoTruncation */)) { + if (!(context.flags & 1 /* NodeBuilderFlags.NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -53642,14 +53830,14 @@ var ts; // Since anonymous types usually come from expressions, this allows us to preserve the output // for deep mappings which likely come from expressions, while truncating those parts which // come from mappings over library functions. - return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) + return !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */) && (ts.contains(context.reverseMappedStack, propertySymbol) || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) - && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* ObjectFlags.Anonymous */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { var _a, _b; - var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); + var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */); var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; @@ -53677,12 +53865,12 @@ var ts; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined; - if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { - var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); + var optionalToken = propertySymbol.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { + var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* TypeFlags.Undefined */); }), 0 /* SignatureKind.Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* SyntaxKind.MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -53696,12 +53884,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -53710,11 +53898,11 @@ var ts; } function preserveCommentsOn(node) { var _a; - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* JSDocPropertyTag */; })) { - var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; }); var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { - ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } } else if (propertySymbol.valueDeclaration) { @@ -53733,12 +53921,12 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", /*typeArguments*/ undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), /*typeArguments*/ undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } } - var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); + var mayHaveNameCollisions = !(context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */); /** Map from type reference identifier text to [type, index in `result` where the type node is] */ var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; var result_5 = []; @@ -53747,7 +53935,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -53772,7 +53960,7 @@ var ts; // type node for each entry by that name with the // `UseFullyQualifiedType` flag enabled. var saveContextFlags = context.flags; - context.flags |= 64 /* UseFullyQualifiedType */; + context.flags |= 64 /* NodeBuilderFlags.UseFullyQualifiedType */; seenNames.forEach(function (types) { if (!ts.arrayIsHomogeneous(types, function (_a, _b) { var a = _a[0]; @@ -53806,21 +53994,21 @@ var ts; if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); } - if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { + if (!indexInfo.type && !(context.flags & 2097152 /* NodeBuilderFlags.AllowEmptyIndexInfoType */)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); - return ts.factory.createIndexSignature(indexInfo.isReadonly ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + return ts.factory.createIndexSignature(indexInfo.isReadonly ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; - var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; + var suppressAny = context.flags & 256 /* NodeBuilderFlags.SuppressAnyReturnType */; if (suppressAny) - context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s + context.flags &= ~256 /* NodeBuilderFlags.SuppressAnyReturnType */; // suppress only toplevel `any`s context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum var typeParameters; var typeArguments; - if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { + if (context.flags & 32 /* NodeBuilderFlags.WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); }); } else { @@ -53828,19 +54016,19 @@ var ts; } var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; // If the expanded parameter list had a variadic in a non-trailing position, don't expand it - var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); - var thisParameter = tryGetThisParameterDeclaration(signature, context); + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* CheckFlags.RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* SyntaxKind.Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var thisParameter = context.flags & 33554432 /* NodeBuilderFlags.OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); } var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(128 /* AssertsKeyword */) : + var assertsModifier = typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined; - var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : + var parameterName = typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* EmitFlags.NoAsciiEscaping */) : ts.factory.createThisTypeNode(); var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode); @@ -53851,28 +54039,28 @@ var ts; returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); } else if (!suppressAny) { - returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 180 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 180 /* SyntaxKind.ConstructorType */) && signature.flags & 4 /* SignatureFlags.Abstract */) { var flags = ts.modifiersToFlags(modifiers); - modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); - } - var node = kind === 174 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 175 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 168 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 169 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 171 /* Constructor */ ? ts.factory.createConstructorDeclaration(modifiers, parameters, /*body*/ undefined) : - kind === 172 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 173 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 176 /* IndexSignature */ ? ts.factory.createIndexSignature(modifiers, parameters, returnTypeNode) : - kind === 317 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 179 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 180 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 256 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 213 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 214 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* ModifierFlags.Abstract */); + } + var node = kind === 174 /* SyntaxKind.CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 175 /* SyntaxKind.ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 168 /* SyntaxKind.MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 169 /* SyntaxKind.MethodDeclaration */ ? ts.factory.createMethodDeclaration(modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 171 /* SyntaxKind.Constructor */ ? ts.factory.createConstructorDeclaration(modifiers, parameters, /*body*/ undefined) : + kind === 172 /* SyntaxKind.GetAccessor */ ? ts.factory.createGetAccessorDeclaration(modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 173 /* SyntaxKind.SetAccessor */ ? ts.factory.createSetAccessorDeclaration(modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 176 /* SyntaxKind.IndexSignature */ ? ts.factory.createIndexSignature(modifiers, parameters, returnTypeNode) : + kind === 317 /* SyntaxKind.JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 179 /* SyntaxKind.FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 180 /* SyntaxKind.ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 213 /* SyntaxKind.FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 214 /* SyntaxKind.ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -53895,7 +54083,7 @@ var ts; } function typeParameterToDeclarationWithConstraint(type, context, constraintNode) { var savedContextFlags = context.flags; - context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic + context.flags &= ~512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic var modifiers = ts.factory.createModifiersFromModifierFlags(getVarianceModifiers(type)); var name = typeParameterToName(type, context); var defaultParameter = getDefaultFromTypeParameter(type); @@ -53909,26 +54097,26 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* SyntaxKind.Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* SyntaxKind.JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && ts.canHaveModifiers(parameterDeclaration) ? ts.map(ts.getModifiers(parameterDeclaration), ts.factory.cloneNode) : undefined; - var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; - var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; + var modifiers = !(context.flags & 8192 /* NodeBuilderFlags.OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && ts.canHaveModifiers(parameterDeclaration) ? ts.map(ts.getModifiers(parameterDeclaration), ts.factory.cloneNode) : undefined; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* CheckFlags.RestParameter */; + var dotDotDotToken = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 161 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* EmitFlags.NoAsciiEscaping */) : + parameterDeclaration.name.kind === 161 /* SyntaxKind.QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* EmitFlags.NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* CheckFlags.OptionalParameter */; + var questionToken = isOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var parameterNode = ts.factory.createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); context.approximateLength += ts.symbolName(parameterSymbol).length + 3; @@ -53954,7 +54142,7 @@ var ts; if (!ts.nodeIsSynthesized(visited)) { visited = ts.factory.cloneNode(visited); } - return ts.setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); + return ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */ | 16777216 /* EmitFlags.NoAsciiEscaping */); } } } @@ -53963,9 +54151,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = ts.getFirstIdentifier(accessExpression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* SymbolFlags.Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -53975,8 +54163,8 @@ var ts; function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) { + var isTypeParameter = symbol.flags & 262144 /* SymbolFlags.TypeParameter */; + if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */) && !(context.flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */)) { chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } @@ -53986,7 +54174,7 @@ var ts; return chain; /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol, meaning, endOfChain) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */)); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */)); var parentSpecifiers; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -54005,8 +54193,8 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { - if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && - getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + if (parent.exports && parent.exports.get("export=" /* InternalSymbolName.ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* InternalSymbolName.ExportEquals */), symbol)) { // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent // No need to lookup an alias for the symbol in itself accessibleSymbolChain = parentChain; @@ -54025,7 +54213,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */))) { // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return; @@ -54055,7 +54243,7 @@ var ts; function typeParametersToTypeParameterDeclarations(symbol, context) { var typeParameterNodes; var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + if (targetSymbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 524288 /* SymbolFlags.TypeAlias */)) { typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); })); } return typeParameterNodes; @@ -54070,11 +54258,11 @@ var ts; } (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId); var typeParameterNodes; - if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { + if (context.flags & 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { var parentSymbol = symbol; var nextSymbol_1 = chain[index + 1]; - if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) { - var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol); + if (ts.getCheckFlags(nextSymbol_1) & 1 /* CheckFlags.Instantiated */) { + var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(parentSymbol) : parentSymbol); typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context); } else { @@ -54094,11 +54282,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context, overrideImportMode) { var _a; - var file = ts.getDeclarationOfKind(symbol, 305 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SyntaxKind.SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -54150,7 +54338,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -54159,8 +54347,8 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var _a, _b, _c, _d; - var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 111551 /* Value */; + var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module + var isTypeOf = meaning === 111551 /* SymbolFlags.Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -54182,7 +54370,7 @@ var ts; if (!specifier) { specifier = getSpecifierForModuleSymbol(chain[0], context); } - if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & 67108864 /* NodeBuilderFlags.AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { var oldSpecifier = specifier; if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set @@ -54244,16 +54432,16 @@ var ts; var parent = chain[index - 1]; var symbolName; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; symbolName = getNameOfSymbolAsWritten(symbol, context); context.approximateLength += (symbolName ? symbolName.length : 0) + 1; - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } else { if (parent && getExportsOfSymbol(parent)) { var exports_2 = getExportsOfSymbol(parent); ts.forEachEntry(exports_2, function (ex, name) { - if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* InternalSymbolName.ExportEquals */) { symbolName = ts.unescapeLeadingUnderscores(name); return true; } @@ -54272,7 +54460,7 @@ var ts; symbolName = getNameOfSymbolAsWritten(symbol, context); } context.approximateLength += symbolName.length + 1; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + if (!(context.flags & 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access @@ -54284,7 +54472,7 @@ var ts; return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName))); } } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; if (index > stopper) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); @@ -54297,9 +54485,9 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context, type) { - var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* SymbolFlags.Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); if (result) { - if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) { + if (result.flags & 262144 /* SymbolFlags.TypeParameter */ && result === type.symbol) { return false; } return true; @@ -54308,23 +54496,23 @@ var ts; } function typeParameterToName(type, context) { var _a, _b; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { return cached; } } - var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 79 /* Identifier */)) { + var result = symbolToName(type.symbol, context, 788968 /* SymbolFlags.Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 79 /* SyntaxKind.Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -54341,7 +54529,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* NodeBuilderFlags.AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -54349,13 +54537,13 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -54367,38 +54555,38 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); } - var canUsePropertyAccess = firstChar === 35 /* hash */ ? + var canUsePropertyAccess = firstChar === 35 /* CharacterCodes.hash */ ? symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) : ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier; } else { - if (firstChar === 91 /* openBracket */) { + if (firstChar === 91 /* CharacterCodes.openBracket */) { symbolName = symbolName.substring(1, symbolName.length - 1); firstChar = symbolName.charCodeAt(0); } var expression = void 0; - if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) { - expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */); + if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* SymbolFlags.EnumMember */)) { + expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* CharacterCodes.singleQuote */); } else if (("" + +symbolName) === symbolName) { expression = ts.factory.createNumericLiteral(+symbolName); } if (!expression) { - expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); expression.symbol = symbol; } return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression); @@ -54427,7 +54615,7 @@ var ts; function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { return ts.factory.createStringLiteral(name, !!singleQuote); @@ -54437,8 +54625,8 @@ var ts; } return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions)); } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* SymbolFlags.Value */)); } } } @@ -54472,7 +54660,7 @@ var ts; 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); + return !(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag @@ -54493,9 +54681,9 @@ var ts; } } var oldFlags = context.flags; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { - context.flags |= 1048576 /* AllowUniqueESSymbolType */; + context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } var result = typeToTypeNodeHelper(type, context); context.flags = oldFlags; @@ -54507,7 +54695,7 @@ var ts; return true; } if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { - return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode; + return getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */) === typeFromTypeNode; } return false; } @@ -54516,7 +54704,7 @@ var ts; var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { var annotated = getTypeFromTypeNode(annotation); - var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + var thisInstantiated = annotated.flags & 262144 /* TypeFlags.TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { @@ -54535,20 +54723,20 @@ var ts; introducesError = true; return { introducesError: introducesError, node: node }; } - var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + var sym = resolveEntityName(leftmost, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); if (sym) { - if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) { + if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */) { introducesError = true; } else { - (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */); + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */); includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym); } if (ts.isIdentifier(node)) { var type = getDeclaredTypeOfSymbol(sym); - var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); + var name = sym.flags & 262144 /* SymbolFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); name.symbol = sym; // for quickinfo, which uses identifier symbol information - return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) }; + return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* EmitFlags.NoAsciiEscaping */) }; } } return { introducesError: introducesError, node: node }; @@ -54566,17 +54754,17 @@ var ts; return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 319 /* SyntaxKind.JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -54590,11 +54778,11 @@ var ts; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; return ts.factory.createPropertySignature( - /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -54609,15 +54797,15 @@ var ts; return ts.factory.createConstructorTypeNode( /*modifiers*/ undefined, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration( /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) { + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } if (ts.isLiteralImportTypeNode(node)) { @@ -54626,7 +54814,7 @@ var ts; nodeSymbol && ( // The import type resolved using jsdoc fallback logic - (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */)) || + (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* SymbolFlags.Type */)) || // The import type had type arguments autofilled by js fallback logic !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); @@ -54641,17 +54829,17 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); function getEffectiveDotDotDotForParameter(p) { - return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined); + return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined); } /** Note that `new:T` parameters are not handled, but should be before calling this function. */ function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -54682,8 +54870,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* SyntaxKind.MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* SyntaxKind.MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -54696,10 +54884,10 @@ var ts; var oldcontext = context; context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); - if (accessibleResult.accessibility === 0 /* Accessible */) { + if (accessibleResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Lookup the root symbol of the chain of refs we'll use to access it and serialize it var chain = lookupSymbolChainWorker(sym, context, meaning); - if (!(sym.flags & 4 /* Property */)) { + if (!(sym.flags & 4 /* SymbolFlags.Property */)) { includePrivateSymbol(chain[0]); } } @@ -54714,16 +54902,16 @@ var ts; void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` }); var addingDeclare = !bundled; - var exportEquals = symbolTable.get("export=" /* ExportEquals */); - if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + var exportEquals = symbolTable.get("export=" /* InternalSymbolName.ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* SymbolFlags.Alias */) { symbolTable = ts.createSymbolTable(); // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) - symbolTable.set("export=" /* ExportEquals */, exportEquals); + symbolTable.set("export=" /* InternalSymbolName.ExportEquals */, exportEquals); } visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 79 /* Identifier */; + return !!node && node.kind === 79 /* SyntaxKind.Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -54740,7 +54928,7 @@ var ts; ns.body && ts.isModuleBlock(ns.body)) { // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments - var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* Export */); }); + var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* ModifierFlags.Export */); }); var name_3 = ns.name; var body = ns.body; if (ts.length(excessExports)) { @@ -54755,9 +54943,9 @@ var ts; results = []; // If the namespace contains no export assignments or declarations, and no declarations flagged with `export`, then _everything_ is exported - // to respect this as the top level, we need to add an `export` modifier to everything - var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); + var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* ModifierFlags.Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); ts.forEach(body.statements, function (s) { - addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + addResult(s, mixinExportFlag_1 ? 1 /* ModifierFlags.Export */ : 0 /* ModifierFlags.None */); // Recalculates the ambient (and export, if applicable from above) flag }); statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true); } @@ -54851,11 +55039,11 @@ var ts; isTypeDeclaration(node); } function addExportModifier(node) { - var flags = (ts.getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; + var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */; return ts.factory.updateModifiers(node, flags); } function removeExportModifier(node) { - var flags = ts.getEffectiveModifierFlags(node) & ~1 /* Export */; + var flags = ts.getEffectiveModifierFlags(node) & ~1 /* ModifierFlags.Export */; return ts.factory.updateModifiers(node, flags); } function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { @@ -54888,12 +55076,11 @@ var ts; if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { var oldContext = context; context = cloneNodeBuilderContext(context); - var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); if (context.reportedDiagnostic) { oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context } context = oldContext; - return result; } } // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias @@ -54908,37 +55095,37 @@ var ts; function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { var _a, _b, _c, _d; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isDefault = symbol.escapedName === "default" /* Default */; - if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */; + if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( context.encounteredError = true; // TODO: Issue error via symbol tracker? return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name } - var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ - || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault; // `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); - var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && - symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && - symbol.escapedName !== "export=" /* ExportEquals */; + var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ && + symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) && + symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); - if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { serializeTypeAlias(symbol, symbolName, modifierFlags); } // Need to skip over export= symbols below - json source files get a single `Property` flagged // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. - if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) - && symbol.escapedName !== "export=" /* ExportEquals */ - && !(symbol.flags & 4194304 /* Prototype */) - && !(symbol.flags & 32 /* Class */) + if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) + && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */) + && !(symbol.flags & 32 /* SymbolFlags.Class */) && !isConstMergedWithNSPrintableAsSignatureMerge) { if (propertyAsAlias) { var createdExport = serializeMaybeAliasAssignment(symbol); @@ -54950,21 +55137,21 @@ var ts; else { var type = getTypeOfSymbol(symbol); var localName = getInternalSymbolName(symbol, symbolName); - if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); } else { // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` - var flags = !(symbol.flags & 2 /* BlockScopedVariable */) + var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) - ? 2 /* Const */ + ? 2 /* NodeFlags.Const */ : undefined : isConstVariable(symbol) - ? 2 /* Const */ - : 1 /* Let */; - var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + ? 2 /* NodeFlags.Const */ + : 1 /* NodeFlags.Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* SymbolFlags.Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; @@ -54975,14 +55162,14 @@ var ts; var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */); - context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* ModifierFlags.None */); + context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* SymbolFlags.Value */); } else { var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~1 /* ModifierFlags.Export */ : modifierFlags); if (name !== localName && !isPrivate) { // We rename the variable declaration we generate for Property symbols since they may have a name which // conflicts with a local declaration. For example, given input: @@ -55007,7 +55194,7 @@ var ts; // To create an export named `g` that does _not_ shadow the local `g` addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* ModifierFlags.None */); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -55015,11 +55202,11 @@ var ts; } } } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { serializeEnum(symbol, symbolName, modifierFlags); } - if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ + if (symbol.flags & 32 /* SymbolFlags.Class */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { @@ -55032,20 +55219,20 @@ var ts; serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } } - if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + if ((symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeModule(symbol, symbolName, modifierFlags); } // The class meaning serialization should handle serializing all interface members - if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) { + if (symbol.flags & 64 /* SymbolFlags.Interface */ && !(symbol.flags & 32 /* SymbolFlags.Class */)) { serializeInterface(symbol, symbolName, modifierFlags); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } - if (symbol.flags & 8388608 /* ExportStar */) { + if (symbol.flags & 8388608 /* SymbolFlags.ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration if (symbol.declarations) { @@ -55054,17 +55241,17 @@ var ts; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); if (!resolvedModule) continue; - addResult(ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + addResult(ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* ModifierFlags.None */); } } } if (needsPostExportDefault) { - addResult(ts.factory.createExportAssignment(/*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + addResult(ts.factory.createExportAssignment(/*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* ModifierFlags.None */); } else if (needsExportDeclaration) { addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* ModifierFlags.None */); } } function includePrivateSymbol(symbol) { @@ -55077,7 +55264,7 @@ var ts; // will throw a wrench in this, since those may have been nested, but we'll need to synthesize them in the outer scope // anyway, as that's the only place the import they translate to is valid. In such a case, we might need to use a unique name // for the moved import; which hopefully the above `getUnusedName` call should produce. - var isExternalImportAlias = !!(symbol.flags & 2097152 /* Alias */) && !ts.some(symbol.declarations, function (d) { + var isExternalImportAlias = !!(symbol.flags & 2097152 /* SymbolFlags.Alias */) && !ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, ts.isExportDeclaration) || ts.isNamespaceExport(d) || (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference)); @@ -55091,23 +55278,23 @@ var ts; // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { - var newModifierFlags = 0 /* None */; + var newModifierFlags = 0 /* ModifierFlags.None */; var enclosingDeclaration_1 = context.enclosingDeclaration && (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && + if (additionalModifierFlags & 1 /* ModifierFlags.Export */ && enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) && canHaveExportModifier(node)) { // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private - newModifierFlags |= 1 /* Export */; + newModifierFlags |= 1 /* ModifierFlags.Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) && + if (addingDeclare && !(newModifierFlags & 1 /* ModifierFlags.Export */) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* NodeFlags.Ambient */)) && (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope - newModifierFlags |= 2 /* Ambient */; + newModifierFlags |= 2 /* ModifierFlags.Ambient */; } - if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { - newModifierFlags |= 512 /* Default */; + if ((additionalModifierFlags & 512 /* ModifierFlags.Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* ModifierFlags.Default */; } if (newModifierFlags) { node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node)); @@ -55123,14 +55310,14 @@ var ts; var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias); var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined); var oldFlags = context.flags; - context.flags |= 8388608 /* InTypeAlias */; + context.flags |= 8388608 /* NodeBuilderFlags.InTypeAlias */; var oldEnclosingDecl = context.enclosingDeclaration; context.enclosingDeclaration = jsdocAliasDecl; var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); - addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; context.enclosingDeclaration = oldEnclosingDecl; } @@ -55141,10 +55328,10 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 174 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 175 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* SignatureKind.Call */, interfaceType, baseType, 174 /* SyntaxKind.CallSignature */); + var constructSignatures = serializeSignatures(1 /* SignatureKind.Construct */, interfaceType, baseType, 175 /* SyntaxKind.ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* SymbolFlags.Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); } @@ -55152,7 +55339,7 @@ var ts; return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); } function isTypeOnlyNamespace(symbol) { - return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); }); } function serializeModule(symbol, symbolName, modifierFlags) { var members = getNamespaceMembersForSerialization(symbol); @@ -55165,14 +55352,14 @@ var ts; // so we don't even have placeholders to fill in. if (ts.length(realMembers)) { var localName = getInternalSymbolName(symbol, symbolName); - serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* SymbolFlags.Function */ | 67108864 /* SymbolFlags.Assignment */))); } if (ts.length(mergedMembers)) { var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); var localName = getInternalSymbolName(symbol, symbolName); var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; }), function (s) { var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); @@ -55187,11 +55374,11 @@ var ts; return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name === targetName ? undefined : targetName, name); })))]); addResult(ts.factory.createModuleDeclaration( - /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* NodeFlags.Namespace */), 0 /* ModifierFlags.None */); } } function serializeEnum(symbol, symbolName, modifierFlags) { - addResult(ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + addResult(ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* ModifierFlags.Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* SymbolFlags.EnumMember */); }), function (p) { // TODO: Handle computed names // I hate that to get the initialized value we need to walk back to the declarations here; but there's no // other way to get the possible const value of an enum member that I'm aware of, as the value is cached @@ -55203,22 +55390,22 @@ var ts; })), modifierFlags); } function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 256 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 256 /* SyntaxKind.FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports - if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + if (!(symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } function getSignatureTextRangeLocation(signature) { if (signature.declaration && signature.declaration.parent) { - if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* AssignmentDeclarationKind.Property */) { return signature.declaration.parent; } // for expressions assigned to `var`s, use the `var` as the text range @@ -55252,7 +55439,7 @@ var ts; // emit akin to the above would be needed. // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace, enclosingDeclaration); fakespace.locals = ts.createSymbolTable(props); fakespace.symbol = props[0].parent; @@ -55272,15 +55459,15 @@ var ts; // replace namespace with synthetic version var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); - var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* InternalSymbolName.Default */))])) : d; }); + var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* ModifierFlags.Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); // namespaces can never be default exported } } function isNamespaceMember(p) { - return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); + return !!(p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */)) || + !(p.flags & 4194304 /* SymbolFlags.Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); } function sanitizeJSDocImplements(clauses) { var result = ts.mapDefined(clauses, function (e) { @@ -55329,7 +55516,7 @@ var ts; var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* SyntaxKind.ImplementsKeyword */, implementsExpressions)], true); var symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from @@ -55355,17 +55542,17 @@ var ts; ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); // When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether // the value is ever initialized with a class or function-like value. For cases where `X` could never be // created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable. var isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && ts.isInJSFile(symbol.valueDeclaration) && - !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); + !ts.some(getSignaturesOfType(staticType, 1 /* SignatureKind.Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? - [ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 171 /* Constructor */); + [ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(8 /* ModifierFlags.Private */), [], /*body*/ undefined)] : + serializeSignatures(1 /* SignatureKind.Construct */, staticType, staticBaseType, 171 /* SyntaxKind.Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -55407,34 +55594,34 @@ var ts; // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === "export=" /* InternalSymbolName.ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match - verbatimTargetName = "default" /* Default */; + verbatimTargetName = "default" /* InternalSymbolName.Default */; } var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 203 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* VariableDeclaration */) { + case 203 /* SyntaxKind.BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* SyntaxKind.VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier( /*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), - /*importClause*/ undefined), 0 /* None */); + /*importClause*/ undefined), 0 /* ModifierFlags.None */); break; } // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 297 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* BinaryExpression */) { + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* SyntaxKind.BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -55444,7 +55631,7 @@ var ts; // import _x = require('y'); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */); + /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* ModifierFlags.None */); // import x = _x.z addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, @@ -55452,48 +55639,48 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // This _specifically_ only exists to handle json declarations - where we make aliases, but since // we emit no declarations for the json document, must not refer to it in the declarations - if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { + if (target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { serializeMaybeAliasAssignment(symbol); break; } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node); + var isLocalImport = !(target.flags & 512 /* SymbolFlags.ValueModule */) && !ts.isVariableDeclaration(node); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createIdentifier(localName), isLocalImport - ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) - : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); + ? symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false) + : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* ModifierFlags.None */); break; - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse - addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* ModifierFlags.None */); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* ModifierFlags.None */); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause( /*isTypeOnly*/ false, @@ -55501,9 +55688,9 @@ var ts; ts.factory.createImportSpecifier( /*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -55511,16 +55698,16 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 221 /* BinaryExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier - if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */ || symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } else { @@ -55534,18 +55721,18 @@ var ts; function serializeExportSpecifier(localName, targetName, specifier) { addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* ModifierFlags.None */); } /** * Returns `true` if an export assignment or declaration was produced for the symbol */ function serializeMaybeAliasAssignment(symbol) { - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return false; } var name = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isExportEquals = name === "export=" /* ExportEquals */; - var isDefault = name === "default" /* Default */; + var isExportEquals = name === "export=" /* InternalSymbolName.ExportEquals */; + var isDefault = name === "default" /* InternalSymbolName.Default */; var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault; // synthesize export = ref // ref should refer to either be a locally scoped symbol which we need to emit, or @@ -55560,7 +55747,7 @@ var ts; // Technically, this is all that's required in the case where the assignment is an entity name expression var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl)); var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; - var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); if (referenced || target) { includePrivateSymbol(referenced || target); } @@ -55573,7 +55760,7 @@ var ts; context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( - /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* SymbolFlags.All */))); } else { if (first_1 === expr && first_1) { @@ -55588,7 +55775,7 @@ var ts; var varName = getUnusedName(name, symbol); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)), 0 /* ModifierFlags.None */); serializeExportSpecifier(name, varName); } } @@ -55603,17 +55790,17 @@ var ts; var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* ModifierFlags.None */ : 1 /* ModifierFlags.Export */); } else { var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* SymbolFlags.Property */ && target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ModifierFlags.Ambient */ + : name === varName ? 1 /* ModifierFlags.Export */ + : 0 /* ModifierFlags.None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -55632,11 +55819,11 @@ var ts; // context source file, and whose property names are all valid identifiers and not late-bound, _and_ // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); - return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + return ts.getObjectFlags(typeToSerialize) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */) && !ts.length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class - !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && - !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* SignatureKind.Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* SignatureKind.Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && @@ -55647,33 +55834,33 @@ var ts; return function serializePropertySymbol(p, isStatic, baseType) { var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); - var isPrivate = !!(modifierFlags & 8 /* Private */); - if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + var isPrivate = !!(modifierFlags & 8 /* ModifierFlags.Private */); + if (isStatic && (p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members return []; } - if (p.flags & 4194304 /* Prototype */ || + if (p.flags & 4194304 /* SymbolFlags.Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) - && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && (p.flags & 16777216 /* SymbolFlags.Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* SymbolFlags.Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* ModifierFlags.Async */) | (isStatic ? 32 /* ModifierFlags.Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); - if (p.flags & 98304 /* Accessor */ && useAccessors) { + if (p.flags & 98304 /* SymbolFlags.Accessor */ && useAccessors) { var result = []; - if (p.flags & 65536 /* SetAccessor */) { + if (p.flags & 65536 /* SymbolFlags.SetAccessor */) { result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], /*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } - if (p.flags & 32768 /* GetAccessor */) { - var isPrivate_1 = modifierFlags & 8 /* Private */; + if (p.flags & 32768 /* SymbolFlags.GetAccessor */) { + var isPrivate_1 = modifierFlags & 8 /* ModifierFlags.Private */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } @@ -55681,17 +55868,17 @@ var ts; } // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints - else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { - return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), + else if (p.flags & (4 /* SymbolFlags.Property */ | 3 /* SymbolFlags.Variable */ | 98304 /* SymbolFlags.Accessor */)) { + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } - if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + if (p.flags & (8192 /* SymbolFlags.Method */ | 16 /* SymbolFlags.Function */)) { var type = getTypeOfSymbol(p); - var signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { - return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); + if (flag & 8 /* ModifierFlags.Private */) { + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, /*type*/ undefined, /*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } @@ -55701,7 +55888,7 @@ var ts; // Each overload becomes a separate method declaration, in order var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, { name: name, - questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + questionToken: p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; @@ -55710,7 +55897,7 @@ var ts; return results_1; } // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -55718,13 +55905,13 @@ var ts; } function serializeSignatures(kind, input, baseType, outputKind) { var signatures = getSignaturesOfType(input, kind); - if (kind === 1 /* Construct */) { + if (kind === 1 /* SignatureKind.Construct */) { if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // No base type, every constructor is empty - elide the extraneous `constructor()` } if (baseType) { // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations - var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + var baseSigs = getSignaturesOfType(baseType, 1 /* SignatureKind.Construct */); if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list } @@ -55745,7 +55932,7 @@ var ts; for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { var s = signatures_4[_i]; if (s.declaration) { - privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */); } } if (privateProtected) { @@ -55780,15 +55967,15 @@ var ts; return results; } function serializeBaseType(t, staticType, rootName) { - var ref = trySerializeAsTypeReference(t, 111551 /* Value */); + var ref = trySerializeAsTypeReference(t, 111551 /* SymbolFlags.Value */); if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context)) - ], 2 /* Const */)); - addResult(statement, 0 /* None */); + ], 2 /* NodeFlags.Const */)); + addResult(statement, 0 /* ModifierFlags.None */); return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), /*typeArgs*/ undefined); } function trySerializeAsTypeReference(t, flags) { @@ -55798,22 +55985,22 @@ var ts; // which we can't write out in a syntactically valid way as an expression if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) { typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); - reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.target.symbol, context, 788968 /* SymbolFlags.Type */); } else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) { - reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */); } if (reference) { return ts.factory.createExpressionWithTypeArguments(reference, typeArgs); } } function serializeImplementedType(t) { - var ref = trySerializeAsTypeReference(t, 788968 /* Type */); + var ref = trySerializeAsTypeReference(t, 788968 /* SymbolFlags.Type */); if (ref) { return ref; } if (t.symbol) { - return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* Type */), /*typeArgs*/ undefined); + return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */), /*typeArgs*/ undefined); } } function getUnusedName(input, symbol) { @@ -55831,7 +56018,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -55840,17 +56027,17 @@ var ts; return input; } function getNameCandidateWorker(symbol, localName) { - if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + if (localName === "default" /* InternalSymbolName.Default */ || localName === "__class" /* InternalSymbolName.Class */ || localName === "__function" /* InternalSymbolName.Function */) { var flags = context.flags; - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; var nameCandidate = getNameOfSymbolAsWritten(symbol, context); context.flags = flags; localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; } - if (localName === "default" /* Default */) { + if (localName === "default" /* InternalSymbolName.Default */) { localName = "_default"; } - else if (localName === "export=" /* ExportEquals */) { + else if (localName === "export=" /* InternalSymbolName.ExportEquals */) { localName = "_exports"; } localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); @@ -55869,14 +56056,14 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined, typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */) // TODO: GH#18217 ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); return writer; } } @@ -55886,10 +56073,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 98304 /* Nullable */)) { - if (t.flags & (512 /* BooleanLiteral */ | 1024 /* EnumLiteral */)) { - var baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 1048576 /* Union */) { + if (!(t.flags & 98304 /* TypeFlags.Nullable */)) { + if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) { + var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 1048576 /* TypeFlags.Union */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -55901,25 +56088,25 @@ var ts; result.push(t); } } - if (flags & 65536 /* Null */) + if (flags & 65536 /* TypeFlags.Null */) result.push(nullType); - if (flags & 32768 /* Undefined */) + if (flags & 32768 /* TypeFlags.Undefined */) result.push(undefinedType); return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 8 /* ModifierFlags.Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 16 /* ModifierFlags.Protected */) { return "protected"; } return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { + if (type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 259 /* TypeAliasDeclaration */) { + if (node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -55927,27 +56114,27 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 262 /* ModuleBlock */ && + node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 305 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 305 /* SyntaxKind.SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\""; + return "\"".concat(ts.escapeString(name, 34 /* CharacterCodes.doubleQuote */), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -55959,9 +56146,9 @@ var ts; * It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`. */ function getNameOfSymbolAsWritten(symbol, context) { - if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && + if (context && symbol.escapedName === "default" /* InternalSymbolName.Default */ && !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default` - (!(context.flags & 16777216 /* InInitialEntityName */) || + (!(context.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default` !symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default` @@ -55975,9 +56162,9 @@ var ts; if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } - if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* Late */)) { + if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */)) { var nameType = getSymbolLinks(symbol).nameType; - if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType && nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { // Computed property name isn't late bound, but has a well-known name type - use name type to generate a symbol name var result = getNameOfSymbolFromNameType(symbol, context); if (result !== undefined) { @@ -55990,17 +56177,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 254 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 226 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 226 /* SyntaxKind.ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -56017,84 +56204,84 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return isDeclarationVisible(node.parent.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 256 /* FunctionDeclaration */: - case 260 /* EnumDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) { + if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) && + !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 164 /* Parameter */: - case 262 /* ModuleBlock */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 178 /* TypeReference */: - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 164 /* SyntaxKind.Parameter */: + case 262 /* SyntaxKind.ModuleBlock */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 178 /* SyntaxKind.TypeReference */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: return false; // Type parameters are always visible - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: // Source file and namespace export are always visible // falls through - case 305 /* SourceFile */: - case 264 /* NamespaceExportDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return false; default: return false; @@ -56103,11 +56290,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 271 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 275 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } var result; var visited; @@ -56131,7 +56318,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol && visited) { if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) { buildVisibleNodeList(importSymbol.declarations); @@ -56180,23 +56367,23 @@ var ts; } function hasType(target, propertyName) { switch (propertyName) { - case 0 /* Type */: + case 0 /* TypeSystemPropertyName.Type */: return !!getSymbolLinks(target).type; - case 5 /* EnumTagType */: + case 5 /* TypeSystemPropertyName.EnumTagType */: return !!(getNodeLinks(target).resolvedEnumType); - case 2 /* DeclaredType */: + case 2 /* TypeSystemPropertyName.DeclaredType */: return !!getSymbolLinks(target).declaredType; - case 1 /* ResolvedBaseConstructorType */: + case 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */: return !!target.resolvedBaseConstructorType; - case 3 /* ResolvedReturnType */: + case 3 /* TypeSystemPropertyName.ResolvedReturnType */: return !!target.resolvedReturnType; - case 4 /* ImmediateBaseConstraint */: + case 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */: return !!target.immediateBaseConstraint; - case 6 /* ResolvedTypeArguments */: + case 6 /* TypeSystemPropertyName.ResolvedTypeArguments */: return !!target.resolvedTypeArguments; - case 7 /* ResolvedBaseTypes */: + case 7 /* TypeSystemPropertyName.ResolvedBaseTypes */: return !!target.baseTypesResolved; - case 8 /* WriteType */: + case 8 /* TypeSystemPropertyName.WriteType */: return !!getSymbolLinks(target).writeType; } return ts.Debug.assertNever(propertyName); @@ -56213,12 +56400,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 255 /* VariableDeclarationList */: - case 270 /* ImportSpecifier */: - case 269 /* NamedImports */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 255 /* SyntaxKind.VariableDeclarationList */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 269 /* SyntaxKind.NamedImports */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: return false; default: return true; @@ -56243,28 +56430,28 @@ var ts; return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType; } function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; + return type && (type.flags & 1 /* TypeFlags.Any */) !== 0; } function isErrorType(type) { // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for // a reference to an unresolved symbol. We want those to behave like the errorType. - return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol); + return type === errorType || !!(type.flags & 1 /* TypeFlags.Any */ && type.aliasSymbol); } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node, checkMode) { - if (checkMode !== 0 /* Normal */) { + if (checkMode !== 0 /* CheckMode.Normal */) { return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (source.flags & 131072 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); + if (source.flags & 131072 /* TypeFlags.Never */) { return emptyObjectType; } - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); @@ -56272,9 +56459,9 @@ var ts; var unspreadableToRestKeys = []; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); + var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) - && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) + && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } @@ -56289,7 +56476,7 @@ var ts; // they are explicitly omitted, as they would in the non-generic case. omitKeyType = getUnionType(__spreadArray([omitKeyType], unspreadableToRestKeys, true)); } - if (omitKeyType.flags & 131072 /* Never */) { + if (omitKeyType.flags & 131072 /* TypeFlags.Never */) { return source; } var omitTypeAlias = getGlobalOmitSymbol(); @@ -56304,15 +56491,15 @@ var ts; members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false)); } var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source)); - result.objectFlags |= 4194304 /* ObjectRestType */; + result.objectFlags |= 4194304 /* ObjectFlags.ObjectRestType */; return result; } function isGenericTypeWithUndefinedConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* TypeFlags.Undefined */); } function getNonUndefinedType(type) { - var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; - return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */); + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288 /* TypeFacts.NEUndefined */); } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: @@ -56348,34 +56535,34 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ancestor.initializer; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 203 /* BindingElement */ && parent.kind === 201 /* ObjectBindingPattern */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */ && parent.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 296 /* PropertyAssignment */ || node.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.kind === 296 /* SyntaxKind.PropertyAssignment */ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); } function getLiteralPropertyNameText(name) { var type = getLiteralTypeFromPropertyName(name); - return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : undefined; + return type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */) ? "" + type.value : undefined; } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { - var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var checkMode = declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode); return parentType && getBindingElementTypeFromParentType(declaration, parentType); } @@ -56386,18 +56573,18 @@ var ts; } var pattern = declaration.parent; // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 16777216 /* NodeFlags.Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` - else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) { - parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* TypeFacts.EQUndefined */)) { + parentType = getTypeWithFacts(parentType, 524288 /* TypeFacts.NEUndefined */); } var type; - if (pattern.kind === 201 /* ObjectBindingPattern */) { + if (pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); - if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* TypeFlags.Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return errorType; } @@ -56414,7 +56601,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* AccessFlags.ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -56422,7 +56609,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern); + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* IterationUse.PossiblyOutOfBounds */), parentType, undefinedType, pattern); var index_2 = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { // If the parent is a tuple type, the rest element has a tuple type of the @@ -56434,7 +56621,7 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getNumberLiteralType(index_2); - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } @@ -56448,9 +56635,9 @@ var ts; if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type; + return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)) & 16777216 /* TypeFacts.IsUndefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)], 2 /* UnionReduction.Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -56461,11 +56648,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* SyntaxKind.NullKeyword */ || expr.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 204 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, isProperty, isOptional) { if (isProperty === void 0) { isProperty = false; } @@ -56476,11 +56663,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode))); - return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -56502,11 +56689,11 @@ var ts; } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) { + !(ts.getCombinedModifierFlags(declaration) & 1 /* ModifierFlags.Export */) && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. - if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array @@ -56518,8 +56705,8 @@ var ts; if (ts.isParameter(declaration)) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 173 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* GetAccessor */); + if (func.kind === 173 /* SyntaxKind.SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* SyntaxKind.GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -56537,7 +56724,7 @@ var ts; return type_1; } // Use contextual parameter type if one is available - var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); + var type = declaration.symbol.escapedName === "this" /* InternalSymbolName.This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { return addOptionality(type, /*isProperty*/ false, isOptional); } @@ -56560,14 +56747,14 @@ var ts; if (!ts.hasStaticModifier(declaration)) { var constructor = findConstructorDeclaration(declaration.parent); var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } else { var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } @@ -56596,7 +56783,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 207 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 207 /* SyntaxKind.ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -56618,7 +56805,7 @@ var ts; 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 === 171 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(container))) { return container; } } @@ -56678,7 +56865,7 @@ var ts; } function getFlowTypeOfProperty(reference, prop) { var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) - && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* ModifierFlags.Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); @@ -56717,7 +56904,7 @@ var ts; var kind = ts.isAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } @@ -56747,12 +56934,12 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes); } } var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); - if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -56776,7 +56963,7 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - type.objectFlags |= 4096 /* JSLiteral */; + type.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { @@ -56832,13 +57019,13 @@ var ts; if (containsSameNamedThisProperty(expression.left, expression.right)) { return anyType; } - var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); + var isDirectExport = kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right)) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 524288 /* Object */ && - kind === 2 /* ModuleExports */ && - symbol.escapedName === "export=" /* ExportEquals */) { + if (type.flags & 524288 /* TypeFlags.Object */ && + kind === 2 /* AssignmentDeclarationKind.ModuleExports */ && + symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); ts.copyEntries(exportedType.members, members_4); @@ -56849,8 +57036,8 @@ var ts; (resolvedSymbol || symbol).exports.forEach(function (s, name) { var _a; var exportedMember = members_4.get(name); - if (exportedMember && exportedMember !== s) { - if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) { + if (exportedMember && exportedMember !== s && !(s.flags & 2097152 /* SymbolFlags.Alias */)) { + if (s.flags & 111551 /* SymbolFlags.Value */ && exportedMember.flags & 111551 /* SymbolFlags.Value */) { // If the member has an additional value-like declaration, union the types from the two declarations, // but issue an error if they occurred in two different files. The purpose is to support a JS file with // a pattern like: @@ -56888,15 +57075,15 @@ var ts; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = type.aliasTypeArguments; } - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { result.aliasSymbol = type.symbol; var args = getTypeArguments(type); result.aliasTypeArguments = ts.length(args) ? args : undefined; } } - result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag - if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */); // Propagate JSLiteral flag + if (result.symbol && result.symbol.flags & 32 /* SymbolFlags.Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { + result.objectFlags |= 16777216 /* ObjectFlags.IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -56908,16 +57095,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 108 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 171 /* Constructor */ || - thisContainer.kind === 256 /* FunctionDeclaration */ || - (thisContainer.kind === 213 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 171 /* SyntaxKind.Constructor */ || + thisContainer.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (thisContainer.kind === 213 /* SyntaxKind.FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -56937,7 +57124,7 @@ var ts; // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType))); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -56945,17 +57132,13 @@ var ts; if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAny(element, anyType); } - // When we're including the pattern in the type (an indication we're obtaining a contextual type), we - // use the non-inferrable any type. Inference will never directly infer this type, but it is possible - // to infer a type that contains it, e.g. for a binding pattern like [foo] or { foo }. In such cases, - // widening of the binding pattern type substitutes a regular any for the non-inferrable any. - return includePatternInType ? nonInferrableAnyType : anyType; + return anyType; } // Return the type implied by an object binding pattern function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -56965,11 +57148,11 @@ var ts; var exprType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(exprType)) { // do not include computed properties in the implied type - objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; return; } var text = getPropertyNameFromType(exprType); - var flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0); + var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; @@ -56979,7 +57162,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56987,18 +57170,18 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 203 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { - return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1; - var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* Rest */ : i >= minLength ? 2 /* Optional */ : 1 /* Required */; }); + var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; }); var result = createTupleType(elementTypes, elementFlags); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -57012,7 +57195,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 201 /* ObjectBindingPattern */ + return pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -57026,7 +57209,7 @@ var ts; // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors); + return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* CheckMode.Normal */), declaration, reportErrors); } function isGlobalSymbolConstructor(node) { var symbol = getSymbolOfNode(node); @@ -57036,14 +57219,14 @@ var ts; function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol` - if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { type = getESSymbolLikeTypeForNode(declaration); } if (reportErrors) { reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -57060,7 +57243,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 164 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(node) { @@ -57084,14 +57267,14 @@ var ts; } function getTypeOfVariableOrParameterOrPropertyWorker(symbol) { // Handle prototype property - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return getTypeOfPrototypeProperty(symbol); } // CommonsJS require and module both have type any. if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { + if (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); var result = createSymbol(fileSymbol.flags, "exports"); result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; @@ -57132,15 +57315,15 @@ var ts; return getTypeOfAccessors(symbol); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 271 /* ExportAssignment */) { + if (declaration.kind === 271 /* SyntaxKind.ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -57159,7 +57342,7 @@ var ts; || ts.isMethodSignature(declaration) || ts.isSourceFile(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } type = ts.isBinaryExpression(declaration.parent) ? @@ -57173,10 +57356,10 @@ var ts; type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration); } else if (ts.isShorthandPropertyAssignment(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* CheckMode.Normal */); } else if (ts.isObjectLiteralMethod(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* CheckMode.Normal */); } else if (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration) @@ -57199,7 +57382,7 @@ var ts; } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -57208,7 +57391,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -57233,11 +57416,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); // We try to resolve a getter type annotation, a setter type annotation, or a getter function // body return type inference, in that order. var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || @@ -57272,10 +57455,10 @@ var ts; function getWriteTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.writeType) { - if (!pushTypeResolution(symbol, 8 /* WriteType */)) { + if (!pushTypeResolution(symbol, 8 /* TypeSystemPropertyName.WriteType */)) { return errorType; } - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); var writeType = getAnnotatedAccessorType(setter); if (!popTypeResolution()) { if (getAnnotatedAccessorTypeNode(setter)) { @@ -57290,8 +57473,8 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : - baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + return baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeFlags.TypeVariable */); }) : undefined; } function getTypeOfFuncClassEnumModule(symbol) { @@ -57312,21 +57495,21 @@ var ts; } function getTypeOfFuncClassEnumModuleWorker(symbol) { var declaration = symbol.valueDeclaration; - if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 221 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 221 /* BinaryExpression */)) { + declaration.parent.kind === 221 /* SyntaxKind.BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } - else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { + else if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { var resolvedModule = resolveExternalModuleSymbol(symbol); if (resolvedModule !== symbol) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */)); + var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)); var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule); if (!popTypeResolution()) { return reportCircularityError(symbol); @@ -57334,13 +57517,13 @@ var ts; return type_3; } } - var type = createObjectType(16 /* Anonymous */, symbol); - if (symbol.flags & 32 /* Class */) { + var type = createObjectType(16 /* ObjectFlags.Anonymous */, symbol); + if (symbol.flags & 32 /* SymbolFlags.Class */) { var baseTypeVariable = getBaseTypeVariableOfClass(symbol); return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type; + return strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ ? getOptionalType(type) : type; } } function getTypeOfEnumMember(symbol) { @@ -57361,7 +57544,7 @@ var ts; links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType - : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } return links.type; @@ -57382,7 +57565,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 164 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 164 /* SyntaxKind.Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -57395,7 +57578,7 @@ var ts; if (!links.type) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); } return links.type; } @@ -57404,7 +57587,7 @@ var ts; if (!links.writeType && links.deferralWriteConstituents) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); + links.writeType = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); } return links.writeType; } @@ -57415,15 +57598,15 @@ var ts; */ function getWriteTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (symbol.flags & 4 /* Property */) { - return checkFlags & 2 /* SyntheticProperty */ ? - checkFlags & 65536 /* DeferredType */ ? + if (symbol.flags & 4 /* SymbolFlags.Property */) { + return checkFlags & 2 /* CheckFlags.SyntheticProperty */ ? + checkFlags & 65536 /* CheckFlags.DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : symbol.writeType || symbol.type : getTypeOfSymbol(symbol); } - if (symbol.flags & 98304 /* Accessor */) { - return checkFlags & 1 /* Instantiated */ ? + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { + return checkFlags & 1 /* CheckFlags.Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol); } @@ -57431,56 +57614,56 @@ var ts; } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (checkFlags & 65536 /* DeferredType */) { + if (checkFlags & 65536 /* CheckFlags.DeferredType */) { return getTypeOfSymbolWithDeferredType(symbol); } - if (checkFlags & 1 /* Instantiated */) { + if (checkFlags & 1 /* CheckFlags.Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (checkFlags & 262144 /* Mapped */) { + if (checkFlags & 262144 /* CheckFlags.Mapped */) { return getTypeOfMappedSymbol(symbol); } - if (checkFlags & 8192 /* ReverseMapped */) { + if (checkFlags & 8192 /* CheckFlags.ReverseMapped */) { return getTypeOfReverseMappedSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & 98304 /* Accessor */) { + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getTypeOfAlias(symbol); } return errorType; } function getNonMissingTypeOfSymbol(symbol) { - return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* SymbolFlags.Optional */)); } function isReferenceToType(type, target) { return type !== undefined && target !== undefined - && (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + && (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getTargetType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target : type; } // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { - if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, check); } return false; @@ -57503,7 +57686,7 @@ var ts; if (node && ts.isBinaryExpression(node)) { // prototype assignments get the outer type parameters of their constructor function var assignmentKind = ts.getAssignmentDeclarationKind(node); - if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { var symbol = getSymbolOfNode(node.left); if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { node = symbol.parent.valueDeclaration; @@ -57514,46 +57697,46 @@ var ts; return undefined; } switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: - case 338 /* JSDocCallbackTag */: - case 195 /* MappedType */: - case 189 /* ConditionalType */: { + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 195 /* SyntaxKind.MappedType */: + case 189 /* SyntaxKind.ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 195 /* MappedType */) { + if (node.kind === 195 /* SyntaxKind.MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 189 /* ConditionalType */) { + else if (node.kind === 189 /* SyntaxKind.ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */ || node.kind === 258 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 320 /* JSDoc */: { + case 320 /* SyntaxKind.JSDoc */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -57564,7 +57747,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* SymbolFlags.Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -57577,9 +57760,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 257 /* ClassDeclaration */ || - node.kind === 226 /* ClassExpression */ || + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || + node.kind === 226 /* SyntaxKind.ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -57596,7 +57779,7 @@ var ts; // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single // rest parameter of type any[]. function isMixinConstructorType(type) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length === 1) { var s = signatures[0]; if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) { @@ -57607,10 +57790,10 @@ var ts; return false; } function isConstructorType(type) { - if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length > 0) { return true; } - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isMixinConstructorType(constraint); } @@ -57623,7 +57806,7 @@ var ts; function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); var isJavascript = ts.isInJSFile(location); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); + return ts.filter(getSignaturesOfType(type, 1 /* SignatureKind.Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); @@ -57646,7 +57829,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + if (!pushTypeResolution(type, 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */)) { return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -57654,7 +57837,7 @@ var ts; ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -57663,13 +57846,13 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = errorType; } - if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* TypeFlags.Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - if (baseConstructorType.flags & 262144 /* TypeParameter */) { + if (baseConstructorType.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(baseConstructorType); var ctorReturn = unknownType; if (constraint) { - var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + var ctorSig = getSignaturesOfType(constraint, 1 /* SignatureKind.Construct */); if (ctorSig[0]) { ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } @@ -57709,19 +57892,19 @@ var ts; return resolvedImplementsTypes; } function reportCircularBaseType(node, type) { - error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); } function getBaseTypes(type) { if (!type.baseTypesResolved) { - if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) { - if (type.objectFlags & 8 /* Tuple */) { + if (pushTypeResolution(type, 7 /* TypeSystemPropertyName.ResolvedBaseTypes */)) { + if (type.objectFlags & 8 /* ObjectFlags.Tuple */) { type.resolvedBaseTypes = [getTupleBaseType(type)]; } - else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (type.symbol.flags & 32 /* Class */) { + else if (type.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { + if (type.symbol.flags & 32 /* SymbolFlags.Class */) { resolveBaseTypesOfClass(type); } - if (type.symbol.flags & 64 /* Interface */) { + if (type.symbol.flags & 64 /* SymbolFlags.Interface */) { resolveBaseTypesOfInterface(type); } } @@ -57731,7 +57914,7 @@ var ts; if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 257 /* ClassDeclaration */ || declaration.kind === 258 /* InterfaceDeclaration */) { + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -57742,26 +57925,26 @@ var ts; return type.resolvedBaseTypes; } function getTupleBaseType(type) { - var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; }); + var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; }); return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly); } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); var baseType; var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; - if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && + if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } - else if (baseConstructorType.flags & 1 /* Any */) { + else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) { baseType = baseConstructorType; } else { @@ -57786,7 +57969,7 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); return type.resolvedBaseTypes = ts.emptyArray; } if (type.resolvedBaseTypes === ts.resolvingEmptyArray) { @@ -57811,7 +57994,7 @@ var ts; } // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getBaseConstraintOfType(type); if (constraint) { return isValidBaseType(constraint); @@ -57819,15 +58002,15 @@ var ts; } // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? // There's no reason a `T` should be allowed while a `Readonly` should not. - return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType)); + return !!(type.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 1 /* TypeFlags.Any */) && !isGenericMappedType(type) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isValidBaseType)); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; if (type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -57867,8 +58050,8 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */) { - if (declaration.flags & 128 /* ContainsThis */) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { + if (declaration.flags & 128 /* NodeFlags.ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -57876,8 +58059,8 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + var baseSymbol = resolveEntityName(node.expression, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* SymbolFlags.Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } } @@ -57891,7 +58074,7 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; + var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */; var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol @@ -57905,8 +58088,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isThislessInterface(symbol)) { - type.objectFlags |= 4 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) { + type.objectFlags |= 4 /* ObjectFlags.Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -57927,7 +58110,7 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + if (!pushTypeResolution(symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { return errorType; } var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found"); @@ -57946,11 +58129,11 @@ var ts; } else { type = errorType; - if (declaration.kind === 339 /* JSDocEnumTag */) { + if (declaration.kind === 339 /* SyntaxKind.JSDocEnumTag */) { error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } } links.declaredType = type; @@ -57961,7 +58144,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 221 /* BinaryExpression */) { + else if (expr.kind === 221 /* SyntaxKind.BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -57969,19 +58152,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 16777216 /* Ambient */); + return !(member.flags & 16777216 /* NodeFlags.Ambient */); } switch (expr.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; - case 79 /* Identifier */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; + case 79 /* SyntaxKind.Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -57996,11 +58179,11 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { - return links.enumKind = 1 /* Literal */; + return links.enumKind = 1 /* EnumKind.Literal */; } if (!isLiteralEnumMember(member)) { hasNonLiteralMember = true; @@ -58009,23 +58192,23 @@ var ts; } } } - return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; + return links.enumKind = hasNonLiteralMember ? 0 /* EnumKind.Numeric */ : 1 /* EnumKind.Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (links.declaredType) { return links.declaredType; } - if (getEnumKind(symbol) === 1 /* Literal */) { + if (getEnumKind(symbol) === 1 /* EnumKind.Literal */) { enumCount++; var memberTypeList = []; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -58037,15 +58220,15 @@ var ts; } } if (memberTypeList.length) { - var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 1048576 /* Union */) { - enumType_1.flags |= 1024 /* EnumLiteral */; + var enumType_1 = getUnionType(memberTypeList, 1 /* UnionReduction.Literal */, symbol, /*aliasTypeArguments*/ undefined); + if (enumType_1.flags & 1048576 /* TypeFlags.Union */) { + enumType_1.flags |= 1024 /* TypeFlags.EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(32 /* Enum */); + var enumType = createType(32 /* TypeFlags.Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -58071,22 +58254,22 @@ var ts; return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getDeclaredTypeOfEnumMember(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getDeclaredTypeOfAlias(symbol); } return undefined; @@ -58098,22 +58281,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 196 /* LiteralType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 196 /* SyntaxKind.LiteralType */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isThislessType(node.elementType); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -58139,7 +58322,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 171 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 171 /* SyntaxKind.Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -58155,14 +58338,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -58199,8 +58382,8 @@ var ts; type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; type.declaredIndexInfos = ts.emptyArray; - type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); - type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); + type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* InternalSymbolName.Call */)); + type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* InternalSymbolName.New */)); type.declaredIndexInfos = getIndexInfosOfSymbol(symbol); } return type; @@ -58209,7 +58392,7 @@ var ts; * Indicates whether a type can be used as a property name. */ function isTypeUsableAsPropertyName(type) { - return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -58228,9 +58411,9 @@ var ts; && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) === 64 /* at */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) === 64 /* CharacterCodes.at */; } /** * Indicates whether a declaration has a late-bindable dynamic name. @@ -58255,10 +58438,10 @@ var ts; * Gets the symbolic name for a member from its type. */ function getPropertyNameFromType(type) { - if (type.flags & 8192 /* UniqueESSymbol */) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { return type.escapedName; } - if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -58269,7 +58452,7 @@ var ts; * members. */ function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { - ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol."); + ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { @@ -58278,7 +58461,7 @@ var ts; else if (!member.symbol.isReplaceableByMethod) { symbol.declarations.push(member); } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -58327,7 +58510,7 @@ var ts; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. var lateSymbol = lateSymbols.get(memberName); if (!lateSymbol) - lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */)); + lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. @@ -58336,10 +58519,10 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_5 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); + var name_5 = !(type.flags & 8192 /* TypeFlags.UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_5); }); error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_5); - lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); + lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */); } lateSymbol.nameType = type; addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); @@ -58357,9 +58540,9 @@ var ts; function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) { var links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */; + var isStatic_1 = resolutionKind === "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */; var earlySymbols = !isStatic_1 ? symbol.members : - symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModuleWorker(symbol) : symbol.exports; // In the event we recursively resolve the members/exports of the symbol, we // set the initial value of resolvedMembers/resolvedExports to the early-bound @@ -58385,10 +58568,10 @@ var ts; for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { var member = decls_1[_c]; var assignmentKind = ts.getAssignmentDeclarationKind(member); - var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + var isInstanceMember = assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */ || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) - || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ - || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + || assignmentKind === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */; // A straight `Prototype` assignment probably can never have a computed name if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } @@ -58404,8 +58587,8 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ - ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ + ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* MembersOrExportsResolutionKind.resolvedMembers */) : symbol.members || emptySymbols; } /** @@ -58415,7 +58598,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol) { - if (symbol.flags & 106500 /* ClassMember */ && symbol.escapedName === "__computed" /* Computed */) { + if (symbol.flags & 106500 /* SymbolFlags.ClassMember */ && symbol.escapedName === "__computed" /* InternalSymbolName.Computed */) { var links = getSymbolLinks(symbol); if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol @@ -58432,7 +58615,7 @@ var ts; return symbol; } function getTypeWithThisArgument(type, thisArgument, needApparentType) { - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { var target = type.target; var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { @@ -58440,7 +58623,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }); return types !== type.types ? getIntersectionType(types) : type; } @@ -58476,8 +58659,8 @@ var ts; var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* SignatureKind.Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* SignatureKind.Construct */)); var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)]; indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); })); } @@ -58512,7 +58695,7 @@ var ts; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; result.compositeSignatures = sig.compositeSignatures; @@ -58522,24 +58705,24 @@ var ts; function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); result.compositeSignatures = unionSignatures; - result.compositeKind = 1048576 /* Union */; + result.compositeKind = 1048576 /* TypeFlags.Union */; result.target = undefined; result.mapper = undefined; return result; } function getOptionalCallSignature(signature, callChainFlags) { - if ((signature.flags & 24 /* CallChainFlags */) === callChainFlags) { + if ((signature.flags & 24 /* SignatureFlags.CallChainFlags */) === callChainFlags) { return signature; } if (!signature.optionalCallSignatureCache) { signature.optionalCallSignatureCache = {}; } - var key = callChainFlags === 8 /* IsInnerCallChain */ ? "inner" : "outer"; + var key = callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ ? "inner" : "outer"; return signature.optionalCallSignatureCache[key] || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags)); } function createOptionalCallSignature(signature, callChainFlags) { - ts.Debug.assert(callChainFlags === 8 /* IsInnerCallChain */ || callChainFlags === 16 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); + ts.Debug.assert(callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ || callChainFlags === 16 /* SignatureFlags.IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); var result = cloneSignature(signature); result.flags |= callChainFlags; return result; @@ -58551,7 +58734,7 @@ var ts; if (isTupleType(restType)) { return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)]; } - else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && ts.every(restType.types, isTupleType)) { + else if (!skipUnionExpanding && restType.flags & 1048576 /* TypeFlags.Union */ && ts.every(restType.types, isTupleType)) { return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); }); } } @@ -58564,10 +58747,10 @@ var ts; var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]); var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType); var flags = restType.target.elementFlags[i]; - var checkFlags = flags & 12 /* Variable */ ? 32768 /* RestParameter */ : - flags & 2 /* Optional */ ? 16384 /* OptionalParameter */ : 0; - var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); - symbol.type = flags & 4 /* Rest */ ? createArrayType(t) : t; + var checkFlags = flags & 12 /* ElementFlags.Variable */ ? 32768 /* CheckFlags.RestParameter */ : + flags & 2 /* ElementFlags.Optional */ ? 16384 /* CheckFlags.OptionalParameter */ : 0; + var symbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, name, checkFlags); + symbol.type = flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t; return symbol; }); return ts.concatenate(sig.parameters.slice(0, restIndex), restParams); @@ -58575,11 +58758,11 @@ var ts; } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol); - var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* Abstract */); + var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* Abstract */ : 0 /* None */)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* SignatureFlags.Abstract */ : 0 /* SignatureFlags.None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -58594,7 +58777,7 @@ var ts; var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; - sig.flags = isAbstract ? sig.flags | 4 /* Abstract */ : sig.flags & ~4 /* Abstract */; + sig.flags = isAbstract ? sig.flags | 4 /* SignatureFlags.Abstract */ : sig.flags & ~4 /* SignatureFlags.Abstract */; result.push(sig); } } @@ -58757,12 +58940,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -58784,11 +58967,11 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 1048576 /* Union */; - result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 1048576 /* TypeFlags.Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -58813,8 +58996,8 @@ var ts; function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); })); - var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* SignatureKind.Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */); })); var indexInfos = getUnionIndexInfos(type.types); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos); } @@ -58822,7 +59005,7 @@ var ts; return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } function findMixins(types) { - var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; }); + var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */).length > 0; }); var mixinFlags = ts.map(types, isMixinConstructorType); if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) { var firstMixinIndex = mixinFlags.indexOf(/*searchElement*/ true); @@ -58837,7 +59020,7 @@ var ts; mixedTypes.push(type); } else if (mixinFlags[i]) { - mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* SignatureKind.Construct */)[0])); } } return getIntersectionType(mixedTypes); @@ -58859,7 +59042,7 @@ var ts; // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature // 'new(s: string) => A & B'. if (!mixinFlags[i]) { - var signatures = getSignaturesOfType(t, 1 /* Construct */); + var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */); if (signatures.length && mixinCount > 0) { signatures = ts.map(signatures, function (s) { var clone = cloneSignature(s); @@ -58869,7 +59052,7 @@ var ts; } constructSignatures = appendSignatures(constructSignatures, signatures); } - callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */)); indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos); }; for (var i = 0; i < types.length; i++) { @@ -58908,18 +59091,18 @@ var ts; if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); - var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* SignatureKind.Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* SignatureKind.Construct */), type.mapper); var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper); setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1); return; } var symbol = getMergedSymbol(type.symbol); - if (symbol.flags & 2048 /* TypeLiteral */) { + if (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_7 = getMembersOfSymbol(symbol); - var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */)); - var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */)); + var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* InternalSymbolName.Call */)); + var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* InternalSymbolName.New */)); var indexInfos_2 = getIndexInfosOfSymbol(symbol); setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2); return; @@ -58933,7 +59116,7 @@ var ts; var varsOnly_1 = new ts.Map(); members.forEach(function (p) { var _a; - if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { + if (!(p.flags & 418 /* SymbolFlags.BlockScoped */) && !(p.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { varsOnly_1.set(p.escapedName, p); } }); @@ -58942,10 +59125,10 @@ var ts; } var baseConstructorIndexInfo; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 8650752 /* TypeFlags.TypeVariable */)) { members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -58961,8 +59144,8 @@ var ts; if (baseConstructorIndexInfo) { indexInfos = ts.append(indexInfos, baseConstructorIndexInfo); } - if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* TypeFlags.Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* TypeFlags.NumberLike */); }))) { indexInfos = ts.append(indexInfos, enumNumberIndexInfo); } } @@ -58971,16 +59154,16 @@ var ts; // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list // will never be observed because a qualified name can't reference signatures. - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } // And likewise for construct signatures for classes - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; - if (symbol.flags & 16 /* Function */) { + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* InternalSymbolName.Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* SymbolFlags.Function */) { constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? - createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) : + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */) : undefined; })); } if (!constructSignatures.length) { @@ -58998,20 +59181,20 @@ var ts; function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, stringType); var modifiers = getMappedTypeModifiers(type.mappedType); - var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; - var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; + var readonlyMask = modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? false : true; + var optionalMask = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 0 : 16777216 /* SymbolFlags.Optional */; var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; - var checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0); - var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); + var checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* CheckFlags.Readonly */ : 0); + var inferredProp = createSymbol(4 /* SymbolFlags.Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ - && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ - && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) { + if (type.constraintType.type.flags & 8388608 /* TypeFlags.IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeFlags.TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* TypeFlags.TypeParameter */) { // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of // type identities produced, we simplify such indexed access occurences @@ -59032,11 +59215,11 @@ var ts; // bound includes those keys that are known to always be present, for example because // because of constraints on type parameters (e.g. 'keyof T' for a constrained T). function getLowerBoundOfKeyType(type) { - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var t = getApparentType(type.type); return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { if (type.root.isDistributive) { var checkType = type.checkType; var constraint = getLowerBoundOfKeyType(checkType); @@ -59046,29 +59229,29 @@ var ts; } return type; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getLowerBoundOfKeyType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType)); } return type; } function getIsLateCheckFlag(s) { - return ts.getCheckFlags(s) & 4096 /* Late */; + return ts.getCheckFlags(s) & 4096 /* CheckFlags.Late */; } function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; cb(getLiteralTypeFromProperty(prop, include)); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { cb(stringType); } else { for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) { var info = _c[_b]; - if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + if (!stringsOnly || info.keyType.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { cb(info.keyType); } } @@ -59088,7 +59271,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* TypeFlags.StringLiteral */ : 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType); @@ -59116,13 +59299,13 @@ var ts; } else { var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined; - var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || - !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); - var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || - !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); - var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; + var isOptional = !!(templateModifiers & 4 /* MappedTypeModifiers.IncludeOptional */ || + !(templateModifiers & 8 /* MappedTypeModifiers.ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */); + var isReadonly = !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ || + !(templateModifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); + var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */; var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0; - var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, lateFlag | 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); + var prop = createSymbol(4 /* SymbolFlags.Property */ | (isOptional ? 16777216 /* SymbolFlags.Optional */ : 0), propName, lateFlag | 262144 /* CheckFlags.Mapped */ | (isReadonly ? 8 /* CheckFlags.Readonly */ : 0) | (stripOptional ? 524288 /* CheckFlags.StripOptional */ : 0)); prop.mappedType = type; prop.nameType = propNameType; prop.keyType = keyType; @@ -59135,12 +59318,12 @@ var ts; members.set(propName, prop); } } - else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) { - var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : - propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : + else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* TypeFlags.Any */ | 32 /* TypeFlags.Enum */)) { + var indexKeyType = propNameType.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */) ? stringType : + propNameType.flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */) ? numberType : propNameType; var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); - var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */)); indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true); } } @@ -59148,7 +59331,7 @@ var ts; function getTypeOfMappedSymbol(symbol) { if (!symbol.type) { var mappedType = symbol.mappedType; - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { mappedType.containsError = true; return errorType; } @@ -59158,8 +59341,8 @@ var ts; // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. - var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : + var type = strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + symbol.checkFlags & 524288 /* CheckFlags.StripOptional */ ? removeMissingOrUndefinedType(propType) : propType; if (!popTypeResolution()) { error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); @@ -59185,7 +59368,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -59193,8 +59376,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 193 /* TypeOperator */ && - constraintDeclaration.operator === 140 /* KeyOfKeyword */; + return constraintDeclaration.kind === 193 /* SyntaxKind.TypeOperator */ && + constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -59210,20 +59393,20 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* SyntaxKind.MinusToken */ ? 8 /* MappedTypeModifiers.ExcludeOptional */ : 4 /* MappedTypeModifiers.IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); - return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0; + return modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? -1 : modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 1 : 0; } function getCombinedMappedTypeOptionality(type) { var optionality = getMappedTypeOptionality(type); @@ -59231,42 +59414,48 @@ var ts; return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0); } function isPartialMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */); } function isGenericMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 524288 /* Object */) { - if (type.objectFlags & 4 /* Reference */) { + if (type.flags & 524288 /* TypeFlags.Object */) { + if (type.objectFlags & 4 /* ObjectFlags.Reference */) { resolveTypeReferenceMembers(type); } - else if (type.objectFlags & 3 /* ClassOrInterface */) { + else if (type.objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 1024 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { resolveReverseMappedTypeMembers(type); } - else if (type.objectFlags & 16 /* Anonymous */) { + else if (type.objectFlags & 16 /* ObjectFlags.Anonymous */) { resolveAnonymousTypeMembers(type); } - else if (type.objectFlags & 32 /* Mapped */) { + else if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { resolveMappedTypeMembers(type); } + else { + ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags)); + } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { resolveIntersectionTypeMembers(type); } + else { + ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags)); + } } return type; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -59275,7 +59464,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -59299,7 +59488,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type without index signature - if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) { + if (type.flags & 1048576 /* TypeFlags.Union */ && getIndexInfosOfType(current).length === 0) { break; } } @@ -59309,13 +59498,13 @@ var ts; } function getPropertiesOfType(type) { type = getReducedApparentType(type); - return type.flags & 3145728 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function forEachPropertyOfType(type, action) { type = getReducedApparentType(type); - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) { if (isNamedMember(symbol, escapedName)) { action(symbol, escapedName); @@ -59334,7 +59523,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 1048576 /* Union */)) { + if (!(unionType.flags & 1048576 /* TypeFlags.Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -59353,9 +59542,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -59416,7 +59605,7 @@ var ts; var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint && constraint !== type.checkType) { var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); - if (!(instantiated.flags & 131072 /* Never */)) { + if (!(instantiated.flags & 131072 /* TypeFlags.Never */)) { return instantiated; } } @@ -59434,11 +59623,11 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { var t = types_5[_i]; - if (t.flags & 465829888 /* Instantiable */) { + if (t.flags & 465829888 /* TypeFlags.Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { @@ -59448,7 +59637,7 @@ var ts; } } } - else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) { + else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */ || isEmptyAnonymousObjectType(t)) { hasDisjointDomainType = true; } } @@ -59460,21 +59649,22 @@ var ts; // intersection operation to reduce the union constraints. for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { var t = types_6[_a]; - if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) { + if (t.flags & 469892092 /* TypeFlags.DisjointDomains */ || isEmptyAnonymousObjectType(t)) { constraints = ts.append(constraints, t); } } } - return getIntersectionType(constraints); + // The source types were normalized; ensure the result is normalized too. + return getNormalizedType(getIntersectionType(constraints), /*writing*/ false); } return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { + if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -59499,7 +59689,7 @@ var ts; return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t) { if (!t.immediateBaseConstraint) { - if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) { + if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) { return circularConstraintType; } var result = void 0; @@ -59516,7 +59706,7 @@ var ts; stack.pop(); } if (!popTypeResolution()) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var errorNode = getConstraintDeclaration(t); if (errorNode) { var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t)); @@ -59536,13 +59726,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 3145728 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = t.types; var baseTypes = []; var different = false; @@ -59562,23 +59752,23 @@ var ts; if (!different) { return t; } - return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* TypeFlags.Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* TypeFlags.Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 4194304 /* Index */) { + if (t.flags & 4194304 /* TypeFlags.Index */) { return keyofConstraintType; } - if (t.flags & 134217728 /* TemplateLiteral */) { + if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var types = t.types; var constraints = ts.mapDefined(types, getBaseConstraint); return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType; } - if (t.flags & 268435456 /* StringMapping */) { + if (t.flags & 268435456 /* TypeFlags.StringMapping */) { var constraint = getBaseConstraint(t.type); return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType; } - if (t.flags & 8388608 /* IndexedAccess */) { + if (t.flags & 8388608 /* TypeFlags.IndexedAccess */) { if (isMappedTypeGenericIndexedAccess(t)) { // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic, // we substitute an instantiation of E where P is replaced with X. @@ -59589,11 +59779,11 @@ var ts; var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } - if (t.flags & 16777216 /* Conditional */) { + if (t.flags & 16777216 /* TypeFlags.Conditional */) { var constraint = getConstraintFromConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 33554432 /* Substitution */) { + if (t.flags & 33554432 /* TypeFlags.Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -59660,9 +59850,9 @@ var ts; } function isMappedTypeGenericIndexedAccess(type) { var objectType; - return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && + return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && - !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType); + !(getMappedTypeModifiers(objectType) & 8 /* MappedTypeModifiers.ExcludeOptional */) && !objectType.declaration.nameType); } /** * For a type parameter, return the base constraint of the type parameter. For the string, number, @@ -59670,17 +59860,17 @@ var ts; * type itself. */ function getApparentType(type) { - var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; - return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 402653316 /* StringLike */ ? globalStringType : - t.flags & 296 /* NumberLike */ ? globalNumberType : - t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : - t.flags & 528 /* BooleanLike */ ? globalBooleanType : - t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : - t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : - t.flags & 4194304 /* Index */ ? keyofConstraintType : - t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : + var t = !(type.flags & 465829888 /* TypeFlags.Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; + return ts.getObjectFlags(t) & 32 /* ObjectFlags.Mapped */ ? getApparentTypeOfMappedType(t) : + t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType : + t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType : + t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType() : + t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType : + t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType() : + t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType : + t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : + t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType : t; } function getReducedApparentType(type) { @@ -59695,21 +59885,21 @@ var ts; var singleProp; var propSet; var indexTypes; - var isUnion = containingType.flags & 1048576 /* Union */; + var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */; // Flags we want to propagate to the result if they exist in all source symbols - var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; - var syntheticFlag = 4 /* SyntheticMethod */; - var checkFlags = isUnion ? 0 : 8 /* Readonly */; + var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */; + var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */; + var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */; var mergedInstantiations = false; for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { var current = _c[_i]; var type = getApparentType(current); - if (!(isErrorType(type) || type.flags & 131072 /* Never */)) { + if (!(isErrorType(type) || type.flags & 131072 /* TypeFlags.Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop) { if (isUnion) { - optionalFlag |= (prop.flags & 16777216 /* Optional */); + optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */); } else { optionalFlag &= prop.flags; @@ -59722,7 +59912,7 @@ var ts; // If the symbols are instances of one another with identical types - consider the symbols // equivalent and just use the first one, which thus allows us to avoid eliding private // members when intersecting a (this-)instantiations of a class with it's raw base or another instance - if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) { + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) { // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` @@ -59740,41 +59930,41 @@ var ts; } } if (isUnion && isReadonlySymbol(prop)) { - checkFlags |= 8 /* Readonly */; + checkFlags |= 8 /* CheckFlags.Readonly */; } else if (!isUnion && !isReadonlySymbol(prop)) { - checkFlags &= ~8 /* Readonly */; + checkFlags &= ~8 /* CheckFlags.Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) ? 256 /* CheckFlags.ContainsPublic */ : 0) | + (modifiers & 16 /* ModifierFlags.Protected */ ? 512 /* CheckFlags.ContainsProtected */ : 0) | + (modifiers & 8 /* ModifierFlags.Private */ ? 1024 /* CheckFlags.ContainsPrivate */ : 0) | + (modifiers & 32 /* ModifierFlags.Static */ ? 2048 /* CheckFlags.ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { - syntheticFlag = 2 /* SyntheticProperty */; + syntheticFlag = 2 /* CheckFlags.SyntheticProperty */; } } else if (isUnion) { var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name); if (indexInfo) { - checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); + checkFlags |= 32 /* CheckFlags.WritePartial */ | (indexInfo.isReadonly ? 8 /* CheckFlags.Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ContainsSpread */)) { - checkFlags |= 32 /* WritePartial */; + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ObjectFlags.ContainsSpread */)) { + checkFlags |= 32 /* CheckFlags.WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } else { - checkFlags |= 16 /* ReadPartial */; + checkFlags |= 16 /* CheckFlags.ReadPartial */; } } } } - if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) { + if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) { // No property was found, or, in a union, a property has a private or protected declaration in one // constituent, but is missing or has a different declaration in another constituent. return undefined; } - if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { + if (!propSet && !(checkFlags & 16 /* CheckFlags.ReadPartial */) && !indexTypes) { if (mergedInstantiations) { // No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents) // Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!) @@ -59816,18 +60006,18 @@ var ts; writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType); } else if (type !== firstType) { - checkFlags |= 64 /* HasNonUniformType */; + checkFlags |= 64 /* CheckFlags.HasNonUniformType */; } if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) { - checkFlags |= 128 /* HasLiteralType */; + checkFlags |= 128 /* CheckFlags.HasLiteralType */; } - if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) { - checkFlags |= 131072 /* HasNeverType */; + if (type.flags & 131072 /* TypeFlags.Never */ && type !== uniqueLiteralType) { + checkFlags |= 131072 /* CheckFlags.HasNeverType */; } propTypes.push(type); } ts.addRange(propTypes, indexTypes); - var result = createSymbol(4 /* Property */ | optionalFlag, name, syntheticFlag | checkFlags); + var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags); result.containingType = containingType; if (!hasNonUniformValueDeclaration && firstValueDeclaration) { result.valueDeclaration = firstValueDeclaration; @@ -59840,7 +60030,7 @@ var ts; result.nameType = nameType; if (propTypes.length > 2) { // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed - result.checkFlags |= 65536 /* DeferredType */; + result.checkFlags |= 65536 /* CheckFlags.DeferredType */; result.deferralParent = containingType; result.deferralConstituents = propTypes; result.deferralWriteConstituents = writeTypes; @@ -59874,7 +60064,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) { var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment); // We need to filter out partial properties in union types - return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined; + return property && !(ts.getCheckFlags(property) & 16 /* CheckFlags.ReadPartial */) ? property : undefined; } /** * Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. @@ -59883,15 +60073,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 16777216 /* ContainsIntersections */) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } - else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 16777216 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 16777216 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* IsNeverIntersection */ : 0); + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { + if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) { + type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0); } - return type.objectFlags & 33554432 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type; } return type; } @@ -59901,7 +60091,7 @@ var ts; return unionType; } var reduced = getUnionType(reducedTypes); - if (reduced.flags & 1048576 /* Union */) { + if (reduced.flags & 1048576 /* TypeFlags.Union */) { reduced.resolvedReducedType = reduced; } return reduced; @@ -59912,23 +60102,23 @@ var ts; function isDiscriminantWithNeverType(prop) { // Return true for a synthetic non-optional property with non-uniform types, where at least one is // a literal type and none is never, that reduces to never. - return !(prop.flags & 16777216 /* Optional */) && - (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ && - !!(getTypeOfSymbol(prop).flags & 131072 /* Never */); + return !(prop.flags & 16777216 /* SymbolFlags.Optional */) && + (ts.getCheckFlags(prop) & (192 /* CheckFlags.Discriminant */ | 131072 /* CheckFlags.HasNeverType */)) === 192 /* CheckFlags.Discriminant */ && + !!(getTypeOfSymbol(prop).flags & 131072 /* TypeFlags.Never */); } function isConflictingPrivateProperty(prop) { // Return true for a synthetic property with multiple declarations, at least one of which is private. - return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); + return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* CheckFlags.ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 33554432 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(neverProp)); } var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty); if (privateProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(privateProp)); } } return errorInfo; @@ -59943,7 +60133,7 @@ var ts; */ function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment, includeTypeOnlyMembers) { type = getReducedApparentType(type); - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol, includeTypeOnlyMembers)) { @@ -59963,15 +60153,15 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + return kind === 0 /* SignatureKind.Call */ ? resolved.callSignatures : resolved.constructSignatures; } return ts.emptyArray; } @@ -60017,10 +60207,10 @@ var ts; // signature applies to types assignable to 'number', `${number}` and numeric string literal types. return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value)); + target === numberType && (source === numericStringType || !!(source.flags & 128 /* TypeFlags.StringLiteral */) && ts.isNumericLiteralName(source.value)); } function getIndexInfosOfStructuredType(type) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return resolved.indexInfos; } @@ -60052,12 +60242,15 @@ var ts; // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(declaration) { + var _a; var result; - for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) { - var node = _a[_i]; + for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) { + var node = _b[_i]; result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol)); } - return result; + return (result === null || result === void 0 ? void 0 : result.length) ? result + : ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters + : undefined; } function symbolsToArray(symbols) { var result = []; @@ -60071,17 +60264,17 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 316 /* JSDocOptionalType */ + node.type && node.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* SymbolFlags.ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -60096,7 +60289,7 @@ var ts; // Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used // in grammar checks and checking for `void` too early results in parameter types widening too early // and causes some noImplicitAny errors to be lost. - return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */); + return parameterIndex >= getMinArgumentCount(signature, 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */ | 2 /* MinArgumentCountFlags.VoidIsNonOptional */); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -60114,7 +60307,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -60163,7 +60356,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -60175,7 +60368,7 @@ var ts; !ts.hasJSDocParameterTags(declaration) && !ts.getJSDocType(declaration); if (isUntypedSignatureInJSFile) { - flags |= 32 /* IsUntypedSignatureInJSFile */; + flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */; } // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -60185,19 +60378,19 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature - if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); + if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) { + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } - if (i === 0 && paramSymbol.escapedName === "this" /* This */) { + if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) { hasThisParameter = true; thisParameter = param.symbol; } else { parameters.push(paramSymbol); } - if (type && type.kind === 196 /* LiteralType */) { - flags |= 2 /* HasLiteralTypes */; + if (type && type.kind === 196 /* SyntaxKind.LiteralType */) { + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || @@ -60209,25 +60402,25 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) && + if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 171 /* Constructor */ ? + var classType = declaration.kind === 171 /* SyntaxKind.Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } - if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* Abstract */) || - ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* Abstract */)) { - flags |= 4 /* Abstract */; + if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */) || + ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* ModifierFlags.Abstract */)) { + flags |= 4 /* SignatureFlags.Abstract */; } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); @@ -60249,7 +60442,7 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */); + var syntheticArgsSymbol = createSymbol(3 /* SymbolFlags.Variable */, "args", 32768 /* CheckFlags.RestParameter */); if (lastParamVariadicType) { // Parameter has effective annotation, lock in type syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)); @@ -60258,7 +60451,7 @@ var ts; // Parameter has no annotation // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been // cached by `getTypeOfSymbol` yet. - syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */; + syntheticArgsSymbol.checkFlags |= 65536 /* CheckFlags.DeferredType */; syntheticArgsSymbol.deferralParent = neverType; syntheticArgsSymbol.deferralConstituents = [anyArrayType]; syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType]; @@ -60291,7 +60484,7 @@ var ts; function containsArgumentsReference(declaration) { var links = getNodeLinks(declaration); if (links.containsArgumentsReference === undefined) { - if (links.flags & 8192 /* CaptureArguments */) { + if (links.flags & 8192 /* NodeCheckFlags.CaptureArguments */) { links.containsArgumentsReference = true; } else { @@ -60303,18 +60496,18 @@ var ts; if (!node) return false; switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return node.name.kind === 162 /* ComputedPropertyName */ + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && traverse(node.name); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return traverse(node.expression); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return traverse(node.initializer); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -60386,26 +60579,26 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 192 /* ThisType */ ? - createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : - createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); + return parameterName.kind === 192 /* SyntaxKind.ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* TypePredicateKind.AssertsThis */ : 0 /* TypePredicateKind.This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* TypePredicateKind.AssertsIdentifier */ : 1 /* TypePredicateKind.Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getUnionOrIntersectionType(types, kind, unionReduction) { - return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + return kind !== 2097152 /* TypeFlags.Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + if (!pushTypeResolution(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* UnionReduction.Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); - if (signature.flags & 8 /* IsInnerCallChain */) { + if (signature.flags & 8 /* SignatureFlags.IsInnerCallChain */) { type = addOptionalTypeMarker(type); } - else if (signature.flags & 16 /* IsOuterCallChain */) { + else if (signature.flags & 16 /* SignatureFlags.IsOuterCallChain */) { type = getOptionalType(type); } if (!popTypeResolution()) { @@ -60432,7 +60625,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 171 /* Constructor */) { + if (declaration.kind === 171 /* SyntaxKind.Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -60442,12 +60635,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 172 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SyntaxKind.SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -60456,7 +60649,7 @@ var ts; return getReturnTypeOfTypeTag(declaration); } function isResolvingReturnTypeOfSignature(signature) { - return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { return tryGetRestTypeOfSignature(signature) || anyType; @@ -60550,8 +60743,8 @@ var ts; if (!signature.isolatedSignatureType) { var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind; // If declaration is undefined, it is likely to be the signature of the default constructor. - var isConstructor = kind === undefined || kind === 171 /* Constructor */ || kind === 175 /* ConstructSignature */ || kind === 180 /* ConstructorType */; - var type = createObjectType(16 /* Anonymous */); + var isConstructor = kind === undefined || kind === 171 /* SyntaxKind.Constructor */ || kind === 175 /* SyntaxKind.ConstructSignature */ || kind === 180 /* SyntaxKind.ConstructorType */; + var type = createObjectType(16 /* ObjectFlags.Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; type.callSignatures = !isConstructor ? [signature] : ts.emptyArray; @@ -60565,7 +60758,7 @@ var ts; return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; } function getIndexSymbolFromSymbolTable(symbolTable) { - return symbolTable.get("__index" /* Index */); + return symbolTable.get("__index" /* InternalSymbolName.Index */); } function createIndexInfo(keyType, type, isReadonly, declaration) { return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration }; @@ -60583,7 +60776,7 @@ var ts; if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), function (keyType) { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) { - indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* ModifierFlags.Readonly */), declaration)); } }); } @@ -60598,8 +60791,8 @@ var ts; return ts.emptyArray; } function isValidIndexKeyType(type) { - return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || - !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); + return !!(type.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 4096 /* TypeFlags.ESSymbol */)) || isPatternLiteralType(type) || + !!(type.flags & 2097152 /* TypeFlags.Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -60608,21 +60801,20 @@ var ts; var _a; var inferences; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { - for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { - var declaration = _b[_i]; - if (declaration.parent.kind === 190 /* InferType */) { + var _loop_15 = function (declaration) { + if (declaration.parent.kind === 190 /* SyntaxKind.InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; - if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) { - var typeReference = grandParent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(childTypeParameter); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (grandParent.kind === 178 /* SyntaxKind.TypeReference */ && !omitTypeReferences) { + var typeReference_1 = grandParent; + var typeParameters_1 = getTypeParametersForTypeReference(typeReference_1); + if (typeParameters_1) { + var index = typeReference_1.typeArguments.indexOf(childTypeParameter); + if (index < typeParameters_1.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters_1[index]); if (declaredConstraint) { // Type parameter constraints can reference other type parameters so // constraints need to be instantiated. If instantiation produces the @@ -60630,7 +60822,9 @@ var ts; // type Foo = [T, U]; // type Bar = T extends Foo ? Foo : T; // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var mapper = makeDeferredTypeMapper(typeParameters_1, typeParameters_1.map(function (_, index) { return function () { + return getEffectiveTypeArgumentAtIndex(typeReference_1, typeParameters_1, index); + }; })); var constraint = instantiateType(declaredConstraint, mapper); if (constraint !== typeParameter) { inferences = ts.append(inferences, constraint); @@ -60641,33 +60835,37 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 164 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 186 /* RestType */ || - grandParent.kind === 197 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 164 /* SyntaxKind.Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 186 /* SyntaxKind.RestType */ || + grandParent.kind === 197 /* SyntaxKind.NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' // constraint. - else if (grandParent.kind === 199 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */) { inferences = ts.append(inferences, stringType); } // When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any' // constraint. - else if (grandParent.kind === 163 /* TypeParameter */ && grandParent.parent.kind === 195 /* MappedType */) { + else if (grandParent.kind === 163 /* SyntaxKind.TypeParameter */ && grandParent.parent.kind === 195 /* SyntaxKind.MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template // of the check type's mapped type - else if (grandParent.kind === 195 /* MappedType */ && grandParent.type && - ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* ConditionalType */ && - grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* MappedType */ && + else if (grandParent.kind === 195 /* SyntaxKind.MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* SyntaxKind.ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* SyntaxKind.MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); inferences = ts.append(inferences, instantiateType(nodeType, makeUnaryTypeMapper(getDeclaredTypeOfTypeParameter(getSymbolOfNode(checkMappedType_1.typeParameter)), checkMappedType_1.typeParameter.constraint ? getTypeFromTypeNode(checkMappedType_1.typeParameter.constraint) : keyofConstraintType))); } } + }; + for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + _loop_15(declaration); } } return inferences && getIntersectionType(inferences); @@ -60686,10 +60884,10 @@ var ts; } else { var type = getTypeFromTypeNode(constraintDeclaration); - if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed + if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 195 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -60698,7 +60896,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -60726,29 +60924,29 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type - // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // of an object literal or a non-inferrable type. This is because there are operations in the type checker // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - if (!(type.flags & excludeKinds)) { + if (excludeKinds === undefined || !(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } } - return result & 458752 /* PropagatingFlags */; + return result & 458752 /* ObjectFlags.PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations.get(id); if (!type) { - type = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); target.instantiations.set(id, type); - type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; + type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0; type.target = target; type.resolvedTypeArguments = typeArguments; } @@ -60768,7 +60966,7 @@ var ts; var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; } - var type = createObjectType(4 /* Reference */, target.symbol); + var type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; @@ -60779,13 +60977,13 @@ var ts; function getTypeArguments(type) { var _a, _b; if (!type.resolvedTypeArguments) { - if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) { + if (!pushTypeResolution(type, 6 /* TypeSystemPropertyName.ResolvedTypeArguments */)) { return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 178 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 178 /* SyntaxKind.TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -60820,14 +61018,14 @@ var ts; missingAugmentsTag ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; - var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); + var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) return errorType; } } - if (node.kind === 178 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -60858,12 +61056,12 @@ var ts; * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ function getTypeFromTypeAliasReference(node, symbol) { - if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) { + if (ts.getCheckFlags(symbol) & 1048576 /* CheckFlags.Unresolved */) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); var id = getAliasId(symbol, typeArguments); var errorType_1 = errorTypes.get(id); if (!errorType_1) { - errorType_1 = createIntrinsicType(1 /* Any */, "error"); + errorType_1 = createIntrinsicType(1 /* TypeFlags.Any */, "error"); errorType_1.aliasSymbol = symbol; errorType_1.aliasTypeArguments = typeArguments; errorTypes.set(id, errorType_1); @@ -60898,9 +61096,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -60912,21 +61110,21 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { - var identifier = name.kind === 161 /* QualifiedName */ ? name.right : - name.kind === 206 /* PropertyAccessExpression */ ? name.name : + var identifier = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? name.name : name; var text = identifier.escapedText; if (text) { - var parentSymbol = name.kind === 161 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : - name.kind === 206 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : + var parentSymbol = name.kind === 161 /* SyntaxKind.QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { - unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */)); + unresolvedSymbols.set(path, result = createSymbol(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */)); result.parent = parentSymbol; result.declaredType = unresolvedType; } @@ -60948,10 +61146,10 @@ var ts; return errorType; } symbol = getExpandoSymbol(symbol) || symbol; - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getTypeFromClassOrInterfaceReference(node, symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) @@ -60959,14 +61157,14 @@ var ts; if (res) { return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType; } - if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + if (symbol.flags & 111551 /* SymbolFlags.Value */ && isJSDocTypeReference(node)) { var jsdocType = getTypeFromJSDocValueReference(node, symbol); if (jsdocType) { return jsdocType; } else { // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(node, 788968 /* Type */); + resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */); return getTypeOfSymbol(symbol); } } @@ -60982,7 +61180,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 200 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 200 /* SyntaxKind.ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); @@ -60993,22 +61191,22 @@ var ts; return links.resolvedJSDocType; } function getSubstitutionType(baseType, substitute) { - if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) { + if (substitute.flags & 3 /* TypeFlags.AnyOrUnknown */ || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; } - var result = createType(33554432 /* Substitution */); + var result = createType(33554432 /* TypeFlags.Substitution */); result.baseType = baseType; result.substitute = substitute; substitutionTypes.set(id, result); return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 184 /* TupleType */ && node.elements.length === 1; + return node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -61018,16 +61216,16 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 320 /* JSDoc */) { + while (node && !ts.isStatement(node) && node.kind !== 320 /* SyntaxKind.JSDoc */) { var parent = node.parent; // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax - if (parent.kind === 164 /* Parameter */) { + if (parent.kind === 164 /* SyntaxKind.Parameter */) { covariant = !covariant; } // Always substitute on type parameters, regardless of variance, since even // in contravariant positions, they may rely on substituted constraints to be valid - if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 189 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeFlags.TypeVariable */) && parent.kind === 189 /* SyntaxKind.ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -61035,7 +61233,7 @@ var ts; } // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the // template type XXX, K has an added constraint of number | `${number}`. - else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 195 /* MappedType */ && node === parent.type) { + else if (type.flags & 262144 /* TypeFlags.TypeParameter */ && parent.kind === 195 /* SyntaxKind.MappedType */ && node === parent.type) { var mappedType = getTypeFromTypeNode(parent); if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { var typeParameter = getHomomorphicTypeVariable(mappedType); @@ -61052,7 +61250,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */); + return !!(node.flags & 8388608 /* NodeFlags.JSDoc */) && (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 200 /* SyntaxKind.ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -61108,7 +61306,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -61120,13 +61318,13 @@ var ts; } var symbol = void 0; var type = void 0; - var meaning = 788968 /* Type */; + var meaning = 788968 /* SymbolFlags.Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); if (!type) { symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true); if (symbol === unknownSymbol) { - symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */); + symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */); } else { resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any @@ -61167,9 +61365,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declaration; } } @@ -61179,7 +61377,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 524288 /* Object */)) { + if (!(type.flags & 524288 /* TypeFlags.Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -61190,13 +61388,13 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* SymbolFlags.Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalTypeAliasSymbol(name, arity, reportErrors) { - var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); if (symbol) { // Resolve the declared type of the symbol. This resolves type parameters for the type // alias so that we can check arity. @@ -61232,9 +61430,9 @@ var ts; function getGlobalImportMetaExpressionType() { if (!deferredGlobalImportMetaExpressionType) { // Create a synthetic type `ImportMetaExpression { meta: MetaProperty }` - var symbol = createSymbol(0 /* None */, "ImportMetaExpression"); + var symbol = createSymbol(0 /* SymbolFlags.None */, "ImportMetaExpression"); var importMetaType = getGlobalImportMetaType(); - var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */); + var metaPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "meta", 8 /* CheckFlags.Readonly */); metaPropertySymbol.parent = symbol; metaPropertySymbol.type = importMetaType; var members = ts.createSymbolTable([metaPropertySymbol]); @@ -61299,7 +61497,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -61337,20 +61535,20 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 185 /* OptionalType */: - return 2 /* Optional */; - case 186 /* RestType */: + case 185 /* SyntaxKind.OptionalType */: + return 2 /* ElementFlags.Optional */; + case 186 /* SyntaxKind.RestType */: return getRestTypeElementFlags(node); - case 197 /* NamedTupleMember */: - return node.questionToken ? 2 /* Optional */ : + case 197 /* SyntaxKind.NamedTupleMember */: + return node.questionToken ? 2 /* ElementFlags.Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + 1 /* ElementFlags.Required */; default: - return 1 /* Required */; + return 1 /* ElementFlags.Required */; } } function getRestTypeElementFlags(node) { - return getArrayElementTypeNode(node.type) ? 4 /* Rest */ : 8 /* Variadic */; + return getArrayElementTypeNode(node.type) ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */; } function getArrayOrTupleTargetType(node) { var readonly = isReadonlyTypeOperator(node.parent); @@ -61359,14 +61557,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* SyntaxKind.NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 184 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* SyntaxKind.ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 184 /* SyntaxKind.TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -61375,18 +61573,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 194 /* IndexedAccessType */: - case 189 /* ConditionalType */: - case 193 /* TypeOperator */: - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 189 /* SyntaxKind.ConditionalType */: + case 193 /* SyntaxKind.TypeOperator */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return isResolvedByTypeAlias(parent); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } return false; @@ -61395,28 +61593,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 178 /* TypeReference */: - return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 181 /* TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */).flags & 524288 /* SymbolFlags.TypeAlias */); + case 181 /* SyntaxKind.TypeQuery */: return true; - case 193 /* TypeOperator */: - return node.operator !== 154 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 197 /* NamedTupleMember */: - case 316 /* JSDocOptionalType */: - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 193 /* SyntaxKind.TypeOperator */: + return node.operator !== 154 /* SyntaxKind.UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 186 /* RestType */: - return node.type.kind !== 183 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 186 /* SyntaxKind.RestType */: + return node.type.kind !== 183 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -61429,33 +61627,33 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 184 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 184 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 184 /* SyntaxKind.TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* ElementFlags.Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 145 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } - var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* Required */; }), readonly, namedMemberDeclarations); + var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* ElementFlags.Required */; }), readonly, namedMemberDeclarations); return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget; } function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { - if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) { + if (elementFlags.length === 1 && elementFlags[0] & 4 /* ElementFlags.Rest */) { // [...X[]] is equivalent to just X[] return readonly ? globalReadonlyArrayType : globalArrayType; } - var key = ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*"; }).join() + + var key = ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? "#" : f & 2 /* ElementFlags.Optional */ ? "?" : f & 4 /* ElementFlags.Rest */ ? "." : "*"; }).join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : ""); var type = tupleTypes.get(key); @@ -61473,7 +61671,7 @@ var ts; // is true for each of the synthesized type parameters. function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { var arity = elementFlags.length; - var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* Required */ | 8 /* Variadic */)); }); + var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* ElementFlags.Required */ | 8 /* ElementFlags.Variadic */)); }); var typeParameters; var properties = []; var combinedFlags = 0; @@ -61483,8 +61681,8 @@ var ts; var typeParameter = typeParameters[i] = createTypeParameter(); var flags = elementFlags[i]; combinedFlags |= flags; - if (!(combinedFlags & 12 /* Variable */)) { - var property = createSymbol(4 /* Property */ | (flags & 2 /* Optional */ ? 16777216 /* Optional */ : 0), "" + i, readonly ? 8 /* Readonly */ : 0); + if (!(combinedFlags & 12 /* ElementFlags.Variable */)) { + var property = createSymbol(4 /* SymbolFlags.Property */ | (flags & 2 /* ElementFlags.Optional */ ? 16777216 /* SymbolFlags.Optional */ : 0), "" + i, readonly ? 8 /* CheckFlags.Readonly */ : 0); property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i]; property.type = typeParameter; properties.push(property); @@ -61492,8 +61690,8 @@ var ts; } } var fixedLength = properties.length; - var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0); - if (combinedFlags & 12 /* Variable */) { + var lengthSymbol = createSymbol(4 /* SymbolFlags.Property */, "length", readonly ? 8 /* CheckFlags.Readonly */ : 0); + if (combinedFlags & 12 /* ElementFlags.Variable */) { lengthSymbol.type = numberType; } else { @@ -61503,7 +61701,7 @@ var ts; lengthSymbol.type = getUnionType(literalTypes); } properties.push(lengthSymbol); - var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); + var type = createObjectType(8 /* ObjectFlags.Tuple */ | 4 /* ObjectFlags.Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -61521,26 +61719,26 @@ var ts; type.elementFlags = elementFlags; type.minLength = minLength; type.fixedLength = fixedLength; - type.hasRestElement = !!(combinedFlags & 12 /* Variable */); + type.hasRestElement = !!(combinedFlags & 12 /* ElementFlags.Variable */); type.combinedFlags = combinedFlags; type.readonly = readonly; type.labeledElementDeclarations = namedMemberDeclarations; return type; } function createNormalizedTypeReference(target, typeArguments) { - return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); + return target.objectFlags & 8 /* ObjectFlags.Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); } function createNormalizedTupleType(target, elementTypes) { var _a, _b, _c; - if (!(target.combinedFlags & 14 /* NonRequired */)) { + if (!(target.combinedFlags & 14 /* ElementFlags.NonRequired */)) { // No need to normalize when we only have regular required elements return createTypeReference(target, elementTypes); } - if (target.combinedFlags & 8 /* Variadic */) { + if (target.combinedFlags & 8 /* ElementFlags.Variadic */) { // Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z] - var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* ElementFlags.Variadic */ && t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex_1 >= 0) { - return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ? + return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : unknownType; })) ? mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) : errorType; } @@ -61556,13 +61754,13 @@ var ts; var lastRequiredIndex = -1; var firstRestIndex = -1; var lastOptionalOrRestIndex = -1; - var _loop_15 = function (i) { + var _loop_16 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; - if (flags & 8 /* Variadic */) { - if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) { + if (flags & 8 /* ElementFlags.Variadic */) { + if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type)) { // Generic variadic elements stay as they are. - addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + addElement(type, 8 /* ElementFlags.Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { var elements = getTypeArguments(type); @@ -61577,7 +61775,7 @@ var ts; } else { // Treat everything else as an array type and create a rest element. - addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); + addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* ElementFlags.Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); } } else { @@ -61586,18 +61784,18 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - var state_4 = _loop_15(i); + var state_4 = _loop_16(i); if (typeof state_4 === "object") return state_4.value; } // Turn optional elements preceding the last required element into required elements for (var i = 0; i < lastRequiredIndex; i++) { - if (expandedFlags[i] & 2 /* Optional */) - expandedFlags[i] = 1 /* Required */; + if (expandedFlags[i] & 2 /* ElementFlags.Optional */) + expandedFlags[i] = 1 /* ElementFlags.Required */; } if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) { // Turn elements between first rest and last optional/rest into a single rest element - expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; })); + expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; })); expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); @@ -61607,13 +61805,13 @@ var ts; expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget; function addElement(type, flags, declaration) { - if (flags & 1 /* Required */) { + if (flags & 1 /* ElementFlags.Required */) { lastRequiredIndex = expandedFlags.length; } - if (flags & 4 /* Rest */ && firstRestIndex < 0) { + if (flags & 4 /* ElementFlags.Rest */ && firstRestIndex < 0) { firstRestIndex = expandedFlags.length; } - if (flags & (2 /* Optional */ | 4 /* Rest */)) { + if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) { lastOptionalOrRestIndex = expandedFlags.length; } expandedTypes.push(type); @@ -61665,19 +61863,19 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 1048576 /* Union */) { - return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* Union */ : 0), type.types); + if (flags & 1048576 /* TypeFlags.Union */) { + return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* TypeFlags.Union */ : 0), type.types); } // We ignore 'never' types in unions - if (!(flags & 131072 /* Never */)) { - includes |= flags & 205258751 /* IncludesMask */; - if (flags & 465829888 /* Instantiable */) - includes |= 33554432 /* IncludesInstantiable */; + if (!(flags & 131072 /* TypeFlags.Never */)) { + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; + if (flags & 465829888 /* TypeFlags.Instantiable */) + includes |= 33554432 /* TypeFlags.IncludesInstantiable */; if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; - if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 65536 /* ContainsWideningType */)) - includes |= 4194304 /* IncludesNonWideningType */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; + if (!strictNullChecks && flags & 98304 /* TypeFlags.Nullable */) { + if (!(ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */)) + includes |= 4194304 /* TypeFlags.IncludesNonWideningType */; } else { var len = typeSet.length; @@ -61711,18 +61909,18 @@ var ts; // We assume that redundant primitive types have already been removed from the types array and that there // are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty // object types, and if none of those are present we can exclude primitive types from the subtype check. - var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); + var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); var len = types.length; var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (hasEmptyObject || source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { // Find the first property with a unit type, if any. When constituents have a property by the same name // but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype // reduction of large discriminated union types. - var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? + var keyProperty = source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : undefined; var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); @@ -61736,20 +61934,20 @@ var ts; // caps union types at 1000 unique object types. var estimatedCount = (count / (len - i)) * len; if (estimatedCount > 1000000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return undefined; } } count++; - if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (keyProperty && target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { continue; } } - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || + if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* ObjectFlags.Class */) || + !(ts.getObjectFlags(getTargetType(target)) & 1 /* ObjectFlags.Class */) || isTypeDerivedFrom(source, target))) { ts.orderedRemoveItemAt(types, i); break; @@ -61767,11 +61965,11 @@ var ts; i--; var t = types[i]; var flags = t.flags; - var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || - flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ || + flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ || + flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ || + flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ || + reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -61782,30 +61980,30 @@ var ts; var templates = ts.filter(types, isPatternLiteralType); if (templates.length) { var i = types.length; - var _loop_16 = function () { + var _loop_17 = function () { i--; var t = types[i]; - if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { + if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { ts.orderedRemoveItemAt(types, i); } }; while (i > 0) { - _loop_16(); + _loop_17(); } } } function isNamedUnionType(type) { - return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin)); + return !!(type.flags & 1048576 /* TypeFlags.Union */ && (type.aliasSymbol || type.origin)); } function addNamedUnions(namedUnions, types) { for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { var t = types_11[_i]; - if (t.flags & 1048576 /* Union */) { + if (t.flags & 1048576 /* TypeFlags.Union */) { var origin = t.origin; - if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { + if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* TypeFlags.Union */)) { ts.pushIfUnique(namedUnions, t); } - else if (origin && origin.flags & 1048576 /* Union */) { + else if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { addNamedUnions(namedUnions, origin.types); } } @@ -61824,7 +62022,7 @@ var ts; // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) { - if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } + if (unionReduction === void 0) { unionReduction = 1 /* UnionReduction.Literal */; } if (types.length === 0) { return neverType; } @@ -61833,48 +62031,48 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (unionReduction !== 0 /* None */) { - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? - includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : - includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; + if (unionReduction !== 0 /* UnionReduction.None */) { + if (includes & 3 /* TypeFlags.AnyOrUnknown */) { + return includes & 1 /* TypeFlags.Any */ ? + includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType : + includes & 65536 /* TypeFlags.Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; } - if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { + if (exactOptionalPropertyTypes && includes & 32768 /* TypeFlags.Undefined */) { var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { ts.orderedRemoveItemAt(typeSet, missingIndex); } } - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + if (includes & (2944 /* TypeFlags.Literal */ | 8192 /* TypeFlags.UniqueESSymbol */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* UnionReduction.Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* TypeFlags.StringLiteral */ && includes & 134217728 /* TypeFlags.TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (unionReduction === 2 /* Subtype */) { - typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (unionReduction === 2 /* UnionReduction.Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* TypeFlags.Object */)); if (!typeSet) { return errorType; } } if (typeSet.length === 0) { - return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : - includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 65536 /* TypeFlags.Null */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* TypeFlags.Undefined */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType; } } - if (!origin && includes & 1048576 /* Union */) { + if (!origin && includes & 1048576 /* TypeFlags.Union */) { var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; - var _loop_17 = function (t) { + var _loop_18 = function (t) { if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) { reducedTypes.push(t); } }; for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) { var t = typeSet_1[_i]; - _loop_17(t); + _loop_18(t); } if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) { return namedUnions[0]; @@ -61887,11 +62085,11 @@ var ts; var t = namedUnions_1[_a]; insertType(reducedTypes, t); } - origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); + origin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, reducedTypes); } } - var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 36323363 /* TypeFlags.NotPrimitiveUnion */ ? 0 : 32768 /* ObjectFlags.PrimitiveUnion */) | + (includes & 2097152 /* TypeFlags.Intersection */ ? 16777216 /* ObjectFlags.ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } function getUnionOrIntersectionTypePredicate(signatures, kind) { @@ -61900,8 +62098,8 @@ var ts; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { - if (kind !== 2097152 /* Intersection */) { + if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { + if (kind !== 2097152 /* TypeFlags.Intersection */) { continue; } else { @@ -61938,20 +62136,20 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving + origin.flags & 1048576 /* TypeFlags.Union */ ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 /* TypeFlags.Intersection */ ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { - type = createType(1048576 /* Union */); - type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* TypeFlags.Union */); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); type.types = types; type.origin = origin; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) { - type.flags |= 16 /* Boolean */; + if (types.length === 2 && types[0].flags & 512 /* TypeFlags.BooleanLiteral */ && types[1].flags & 512 /* TypeFlags.BooleanLiteral */) { + type.flags |= 16 /* TypeFlags.Boolean */; type.intrinsicName = "boolean"; } unionTypes.set(id, type); @@ -61962,41 +62160,41 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* UnionReduction.Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & 16777216 /* IncludesEmptyObject */)) { - includes |= 16777216 /* IncludesEmptyObject */; + if (!(includes & 16777216 /* TypeFlags.IncludesEmptyObject */)) { + includes |= 16777216 /* TypeFlags.IncludesEmptyObject */; typeSet.set(type.id.toString(), type); } } else { - if (flags & 3 /* AnyOrUnknown */) { + if (flags & 3 /* TypeFlags.AnyOrUnknown */) { if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; } - else if (strictNullChecks || !(flags & 98304 /* Nullable */)) { + else if (strictNullChecks || !(flags & 98304 /* TypeFlags.Nullable */)) { if (exactOptionalPropertyTypes && type === missingType) { - includes |= 262144 /* IncludesMissingType */; + includes |= 262144 /* TypeFlags.IncludesMissingType */; type = undefinedType; } if (!typeSet.has(type.id.toString())) { - if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { + if (type.flags & 109440 /* TypeFlags.Unit */ && includes & 109440 /* TypeFlags.Unit */) { // We have seen two distinct unit types which means we should reduce to an // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. - includes |= 67108864 /* NonPrimitive */; + includes |= 67108864 /* TypeFlags.NonPrimitive */; } typeSet.set(type.id.toString(), type); } } - includes |= flags & 205258751 /* IncludesMask */; + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; } return includes; } @@ -62014,12 +62212,12 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || - t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || - t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ || - isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */; + var remove = t.flags & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + t.flags & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + t.flags & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + t.flags & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */ || + t.flags & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */ || + isEmptyAnonymousObjectType(t) && includes & 470302716 /* TypeFlags.DefinitelyNonNullable */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -62032,10 +62230,10 @@ var ts; for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) { var u = unionTypes_1[_i]; if (!containsType(u.types, type)) { - var primitive = type.flags & 128 /* StringLiteral */ ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + var primitive = type.flags & 128 /* TypeFlags.StringLiteral */ ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : undefined; if (!primitive || !containsType(u.types, primitive)) { return false; @@ -62049,11 +62247,11 @@ var ts; */ function extractRedundantTemplateLiterals(types) { var i = types.length; - var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); }); + var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); }); while (i > 0) { i--; var t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */)) continue; for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) { var t2 = literals_1[_i]; @@ -62070,7 +62268,7 @@ var ts; return false; } function eachIsUnionContaining(types, flag) { - return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); + return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); } function removeFromEach(types, flag) { for (var i = 0; i < types.length; i++) { @@ -62082,7 +62280,7 @@ var ts; // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); }); if (index < 0) { return false; } @@ -62091,7 +62289,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -62120,12 +62318,12 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { - var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + var result = createType(2097152 /* TypeFlags.Intersection */); + result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -62154,37 +62352,37 @@ var ts; // a symbol-like type and a type known to be non-symbol-like, or // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. - if (includes & 131072 /* Never */) { + if (includes & 131072 /* TypeFlags.Never */) { return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; } - if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || - includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || - includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || - includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || - includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || - includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || - includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) || + includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) || + includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) || + includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) || + includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) || + includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) || + includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } - if (includes & 1 /* Any */) { - return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType; + if (includes & 1 /* TypeFlags.Any */) { + return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 98304 /* Nullable */) { - return includes & 32768 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) { + return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || - includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || - includes & 16384 /* Void */ && includes & 32768 /* Undefined */ || - includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) { + if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */ || + includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */ || + includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 470302716 /* TypeFlags.DefinitelyNonNullable */) { if (!noSupertypeReduction) removeRedundantSupertypes(typeSet, includes); } - if (includes & 262144 /* IncludesMissingType */) { + if (includes & 262144 /* TypeFlags.IncludesMissingType */) { typeSet[typeSet.indexOf(undefinedType)] = missingType; } if (typeSet.length === 0) { @@ -62196,21 +62394,21 @@ var ts; var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { - if (includes & 1048576 /* Union */) { + if (includes & 1048576 /* TypeFlags.Union */) { if (intersectUnionsOfPrimitiveTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) { + else if (eachIsUnionContaining(typeSet, 32768 /* TypeFlags.Undefined */)) { var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType; - removeFromEach(typeSet, 32768 /* Undefined */); - result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + removeFromEach(typeSet, 32768 /* TypeFlags.Undefined */); + result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) { - removeFromEach(typeSet, 65536 /* Null */); - result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + else if (eachIsUnionContaining(typeSet, 65536 /* TypeFlags.Null */)) { + removeFromEach(typeSet, 65536 /* TypeFlags.Null */); + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } else { // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of @@ -62223,8 +62421,8 @@ var ts; // We attach a denormalized origin type when at least one constituent of the cross-product union is an // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and // the denormalized origin has fewer constituents than the union itself. - var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined; - result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin); + var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* TypeFlags.Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* TypeFlags.Intersection */, typeSet) : undefined; + result = getUnionType(constituents, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments, origin); } } else { @@ -62235,12 +62433,12 @@ var ts; return result; } function getCrossProductUnionSize(types) { - return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* Union */ ? n * t.types.length : t.flags & 131072 /* Never */ ? 0 : n; }, 1); + return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* TypeFlags.Union */ ? n * t.types.length : t.flags & 131072 /* TypeFlags.Never */ ? 0 : n; }, 1); } function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return false; } @@ -62253,7 +62451,7 @@ var ts; var constituents = types.slice(); var n = i; for (var j = types.length - 1; j >= 0; j--) { - if (types[j].flags & 1048576 /* Union */) { + if (types[j].flags & 1048576 /* TypeFlags.Union */) { var sourceTypes = types[j].types; var length_5 = sourceTypes.length; constituents[j] = sourceTypes[n % length_5]; @@ -62261,14 +62459,14 @@ var ts; } } var t = getIntersectionType(constituents); - if (!(t.flags & 131072 /* Never */)) + if (!(t.flags & 131072 /* TypeFlags.Never */)) intersections.push(t); } return intersections; } function getConstituentCount(type) { - return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 : - type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) : + return !(type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) || type.aliasSymbol ? 1 : + type.flags & 1048576 /* TypeFlags.Union */ && type.origin ? getConstituentCount(type.origin) : getConstituentCountOfTypes(type.types); } function getConstituentCountOfTypes(types) { @@ -62279,19 +62477,19 @@ var ts; if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); var types = ts.map(node.types, getTypeFromTypeNode); - var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType; + var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) && types[1] === emptyTypeLiteralType; links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction); } return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(4194304 /* Index */); + var result = createType(4194304 /* TypeFlags.Index */); result.type = type; result.stringsOnly = stringsOnly; return result; } function createOriginIndexType(type) { - var result = createOriginType(4194304 /* Index */); + var result = createOriginType(4194304 /* TypeFlags.Index */); result.type = type; return result; } @@ -62323,7 +62521,7 @@ var ts; // so we only eagerly manifest the keys if the constraint is nongeneric if (!isGenericIndexType(constraintType)) { var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); } else { // we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later @@ -62339,8 +62537,8 @@ var ts; } // we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType, // so we can return the union that preserves aliases/origin data if possible - var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes); - if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { + var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)); }) : getUnionType(keyTypes); + if (result.flags & 1048576 /* TypeFlags.Union */ && constraintType.flags & 1048576 /* TypeFlags.Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { return constraintType; } return result; @@ -62360,12 +62558,12 @@ var ts; var typeVariable = getTypeParameterFromMappedType(mappedType); return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); function isDistributive(type) { - return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true : - type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) : - type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : - type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) : - type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) : + return type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */ | 262144 /* TypeFlags.TypeParameter */ | 524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */) ? true : + type.flags & 16777216 /* TypeFlags.Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? isDistributive(type.substitute) : + type.flags & 268435456 /* TypeFlags.StringMapping */ ? isDistributive(type.type) : false; } } @@ -62377,11 +62575,11 @@ var ts; getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); - type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") : + type = prop.escapedName === "default" /* InternalSymbolName.Default */ ? getStringLiteralType("default") : name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined); } if (type && type.flags & include) { @@ -62391,14 +62589,14 @@ var ts; return neverType; } function isKeyTypeIncluded(keyType, include) { - return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); + return !!(keyType.flags & include || keyType.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); } function getLiteralTypeFromProperties(type, include, includeOrigin) { - var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; + var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); }); var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? - info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); - return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, + info.keyType === stringType && include & 8 /* TypeFlags.Number */ ? stringOrNumberType : info.keyType : neverType; }); + return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* UnionReduction.Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); } /** @@ -62408,24 +62606,27 @@ var ts; * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible). */ function isPossiblyReducibleByInstantiation(type) { - return ts.some(type.types, function (t) { - var uniqueFilled = getUniqueLiteralFilledInstantiation(t); - return getReducedType(uniqueFilled) !== uniqueFilled; - }); + var uniqueFilled = getUniqueLiteralFilledInstantiation(type); + return getReducedType(uniqueFilled) !== uniqueFilled; + } + function shouldDeferIndexType(type) { + return !!(type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || + isGenericTupleType(type) || + isGenericMappedType(type) && !hasDistributiveNameType(type) || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) || + type.flags & 2097152 /* TypeFlags.Intersection */ && maybeTypeOfKind(type, 465829888 /* TypeFlags.Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType)); } function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type) - ? getIndexTypeForGenericType(type, stringsOnly) - : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : + return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 1048576 /* TypeFlags.Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : - type.flags & 2 /* Unknown */ ? neverType : - type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : - getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); + type.flags & 2 /* TypeFlags.Unknown */ ? neverType : + type.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */) ? keyofConstraintType : + getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* TypeFlags.StringLiteral */ : 402653316 /* TypeFlags.StringLike */) | (stringsOnly ? 0 : 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -62436,21 +62637,21 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 131072 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* TypeFlags.Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 140 /* KeyOfKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 154 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 151 /* SymbolKeyword */ + case 154 /* SyntaxKind.UniqueKeyword */: + links.resolvedType = node.type.kind === 151 /* SyntaxKind.SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 145 /* ReadonlyKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -62467,7 +62668,7 @@ var ts; return links.resolvedType; } function getTemplateLiteralType(texts, types) { - var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex >= 0) { return checkCrossProductUnion(types) ? mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : @@ -62486,10 +62687,10 @@ var ts; return getStringLiteralType(text); } newTexts.push(text); - if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) { + if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -62500,13 +62701,13 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; var addText = isTextsArray ? texts[i + 1] : texts; - if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) { + if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) { text += getTemplateStringForType(t) || ""; text += addText; if (!isTextsArray) return true; } - else if (t.flags & 134217728 /* TemplateLiteral */) { + else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { text += t.texts[0]; if (!addSpans(t.texts, t.types)) return false; @@ -62519,7 +62720,7 @@ var ts; newTexts.push(text); text = addText; } - else if (t.flags & 2097152 /* Intersection */) { + else if (t.flags & 2097152 /* TypeFlags.Intersection */) { var added = addSpans(texts[i + 1], t.types); if (!added) return false; @@ -62532,47 +62733,47 @@ var ts; } } function getTemplateStringForType(type) { - return type.flags & 128 /* StringLiteral */ ? type.value : - type.flags & 256 /* NumberLiteral */ ? "" + type.value : - type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : - type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? "" + type.value : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : + type.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) ? type.intrinsicName : undefined; } function createTemplateLiteralType(texts, types) { - var type = createType(134217728 /* TemplateLiteral */); + var type = createType(134217728 /* TypeFlags.TemplateLiteral */); type.texts = texts; type.types = types; return type; } function getStringMappingType(symbol, type) { - return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : + return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : // Mapping> === Mapping - type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : - isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) : - type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : - type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) : + type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type : + isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* TypeFlags.StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) : type; } function applyStringMapping(symbol, str) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return str.toUpperCase(); - case 1 /* Lowercase */: return str.toLowerCase(); - case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); - case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); + case 0 /* IntrinsicTypeKind.Uppercase */: return str.toUpperCase(); + case 1 /* IntrinsicTypeKind.Lowercase */: return str.toLowerCase(); + case 2 /* IntrinsicTypeKind.Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); + case 3 /* IntrinsicTypeKind.Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); } return str; } function applyTemplateStringMapping(symbol, texts, types) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; - case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; - case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; - case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + case 0 /* IntrinsicTypeKind.Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 1 /* IntrinsicTypeKind.Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 2 /* IntrinsicTypeKind.Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + case 3 /* IntrinsicTypeKind.Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; } return [texts, types]; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -62580,13 +62781,13 @@ var ts; return result; } function createStringMappingType(symbol, type) { - var result = createType(268435456 /* StringMapping */); + var result = createType(268435456 /* TypeFlags.StringMapping */); result.symbol = symbol; result.type = type; return result; } function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { - var type = createType(8388608 /* IndexedAccess */); + var type = createType(8388608 /* TypeFlags.IndexedAccess */); type.objectType = objectType; type.indexType = indexType; type.accessFlags = accessFlags; @@ -62607,16 +62808,16 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 4096 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) { return true; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getResolvedBaseConstraint(type); return constraint !== type && isJSLiteralType(constraint); } @@ -62631,26 +62832,26 @@ var ts; undefined; } function isUncalledFunctionReference(node, symbol) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent; if (ts.isCallLikeExpression(parent)) { return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node); } - return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } return true; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { - if (accessFlags & 256 /* Contextual */) { + if (accessFlags & 256 /* AccessFlags.Contextual */) { return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* AccessFlags.ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } @@ -62660,7 +62861,7 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 8 /* CacheSymbol */) { + if (accessFlags & 8 /* AccessFlags.CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -62668,50 +62869,57 @@ var ts; } } var propType = getTypeOfSymbol(prop); - return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? + return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* AssignmentKind.Definite */ ? getFlowTypeOfReference(accessExpression, propType) : propType; } - if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { + if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) { + var index = +propName; + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* AccessFlags.NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { + if (index < 0) { + error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value); + return undefinedType; + } error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); } else { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } } - errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); - return mapType(objectType, function (t) { - var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; - }); + if (index >= 0) { + errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); + return mapType(objectType, function (t) { + var restType = getRestTypeOfTupleType(t) || undefinedType; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; + }); + } } } - if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { + if (!(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */)) { + if (objectType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) { return objectType; } // If no index signature is applicable, we default to the string index signature. In effect, this means the string // index signature applies even when accessing with a symbol-like type. var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType); if (indexInfo) { - if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { + if (accessFlags & 2 /* AccessFlags.NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } return undefined; } - if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } - if (indexType.flags & 131072 /* Never */) { + if (indexType.flags & 131072 /* TypeFlags.Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -62719,21 +62927,21 @@ var ts; } if (accessExpression && !isConstEnumObjectType(objectType)) { if (isObjectLiteralType(objectType)) { - if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (noImplicitAny && indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType))); return undefinedType; } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { var types = ts.map(objectType.properties, function (property) { return getTypeOfSymbol(property); }); return getUnionType(ts.append(types, undefinedType)); } } - if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* SymbolFlags.BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* AccessFlags.SuppressNoImplicitAnyError */)) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { var typeName = typeToString(objectType); error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]"); @@ -62755,20 +62963,20 @@ var ts; } else { var errorInfo = void 0; - if (indexType.flags & 1024 /* EnumLiteral */) { + if (indexType.flags & 1024 /* TypeFlags.EnumLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType)); } - else if (indexType.flags & 8192 /* UniqueESSymbol */) { + else if (indexType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression); errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType)); } - else if (indexType.flags & 128 /* StringLiteral */) { + else if (indexType.flags & 128 /* TypeFlags.StringLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & 256 /* NumberLiteral */) { + else if (indexType.flags & 256 /* TypeFlags.NumberLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType)); } errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType)); @@ -62785,10 +62993,10 @@ var ts; } if (accessNode) { var indexNode = getIndexNodeForAccessExpression(accessNode); - if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { + else if (indexType.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { @@ -62806,62 +63014,62 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 194 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 162 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 194 /* SyntaxKind.IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type)); + return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */ && isPatternLiteralPlaceholderType(type.type)); } function isPatternLiteralType(type) { - return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); + return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); } function isGenericType(type) { return !!getGenericObjectFlags(type); } function isGenericObjectType(type) { - return !!(getGenericObjectFlags(type) & 4194304 /* IsGenericObjectType */); + return !!(getGenericObjectFlags(type) & 4194304 /* ObjectFlags.IsGenericObjectType */); } function isGenericIndexType(type) { - return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */); + return !!(getGenericObjectFlags(type) & 8388608 /* ObjectFlags.IsGenericIndexType */); } function getGenericObjectFlags(type) { - if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 33554432 /* TypeFlags.Substitution */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | - (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0); + return (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* ObjectFlags.IsGenericObjectType */ : 0) | + (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* ObjectFlags.IsGenericIndexType */ : 0); } function getSimplifiedType(type, writing) { - return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : - type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : + return type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getSimplifiedConditionalType(type, writing) : type; } function distributeIndexOverObjectType(objectType, indexType, writing) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 3145728 /* UnionOrIntersection */) { + if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); }); - return objectType.flags & 2097152 /* Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); + return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); } } function distributeObjectOverIndexType(objectType, indexType, writing) { // T[A | B] -> T[A] | T[B] (reading) // T[A | B] -> T[A] & T[B] (writing) - if (indexType.flags & 1048576 /* Union */) { + if (indexType.flags & 1048576 /* TypeFlags.Union */) { var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); }); return writing ? getIntersectionType(types) : getUnionType(types); } @@ -62886,7 +63094,7 @@ var ts; return type[cache] = distributedOverIndex; } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 465829888 /* Instantiable */)) { + if (!(indexType.flags & 465829888 /* TypeFlags.Instantiable */)) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] @@ -62900,8 +63108,8 @@ var ts; // A generic tuple type indexed by a number exists only when the index type doesn't select a // fixed element. We simplify to either the combined type of all elements (when the index type // the actual number type) or to the combined type of all non-fixed elements. - if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) { - var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); + if (isGenericTupleType(objectType) && indexType.flags & 296 /* TypeFlags.NumberLike */) { + var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* TypeFlags.Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); if (elementType) { return type[cache] = elementType; } @@ -62923,19 +63131,19 @@ var ts; var trueType = getTrueTypeFromConditionalType(type); var falseType = getFalseTypeFromConditionalType(type); // Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`. - if (falseType.flags & 131072 /* Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { - if (checkType.flags & 1 /* Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + if (falseType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { + if (checkType.flags & 1 /* TypeFlags.Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return getSimplifiedType(trueType, writing); } else if (isIntersectionEmpty(checkType, extendsType)) { // Always false return neverType; } } - else if (trueType.flags & 131072 /* Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { - if (!(checkType.flags & 1 /* Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + else if (trueType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { + if (!(checkType.flags & 1 /* TypeFlags.Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return neverType; } - else if (checkType.flags & 1 /* Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false + else if (checkType.flags & 1 /* TypeFlags.Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false return getSimplifiedType(falseType, writing); } } @@ -62945,7 +63153,7 @@ var ts; * Invokes union simplification logic to determine if an intersection is considered empty as a union constituent */ function isIntersectionEmpty(type1, type2) { - return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* Never */); + return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* TypeFlags.Never */); } function substituteIndexedMappedType(objectType, index) { var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); @@ -62953,12 +63161,12 @@ var ts; return instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper); } function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { - if (t.flags & 384 /* StringOrNumberLiteral */) { + if (t.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var propName = getPropertyNameFromType(t); if (ts.isNumericLiteralName(propName)) { var index = +propName; @@ -62969,33 +63177,33 @@ var ts; }); } function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. - if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { indexType = stringType; } // In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to // an index signature have 'undefined' included in their type. - if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) - accessFlags |= 1 /* IncludeUndefined */; + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* AccessFlags.ExpressionPosition */) + accessFlags |= 1 /* AccessFlags.IncludeUndefined */; // If the index type is generic, or if the object type is generic and doesn't originate in an expression and // the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing // a higher-order index access where we cannot meaningfully access the properties of the object type. Note that // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* SyntaxKind.IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { - if (objectType.flags & 3 /* AnyOrUnknown */) { + if (objectType.flags & 3 /* TypeFlags.AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var persistentAccessFlags = accessFlags & 1 /* AccessFlags.Persistent */; var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { @@ -63007,12 +63215,12 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getReducedApparentType(objectType); - if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* TypeFlags.Union */ && !(indexType.flags & 16 /* TypeFlags.Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* AccessFlags.SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -63028,11 +63236,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 4 /* Writing */ + return accessFlags & 4 /* AccessFlags.Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) - : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); + : getUnionType(propTypes, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* AccessFlags.CacheSymbol */ | 64 /* AccessFlags.ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -63040,8 +63248,8 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); - links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && + var resolved = getIndexedAccessType(objectType, indexType, 0 /* AccessFlags.None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + links.resolvedType = resolved.flags & 8388608 /* TypeFlags.IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConditionalFlowTypeOfType(resolved, node) : resolved; @@ -63051,7 +63259,7 @@ var ts; function getTypeFromMappedTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(32 /* Mapped */, node.symbol); + var type = createObjectType(32 /* ObjectFlags.Mapped */, node.symbol); type.declaration = node; type.aliasSymbol = getAliasSymbolForTypeNode(node); type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol); @@ -63063,11 +63271,11 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return type.baseType; } - if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ || - type.indexType.flags & 33554432 /* Substitution */)) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */ && (type.objectType.flags & 33554432 /* TypeFlags.Substitution */ || + type.indexType.flags & 33554432 /* TypeFlags.Substitution */)) { return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType)); } return type; @@ -63098,7 +63306,7 @@ var ts; var result; var extraTypes; var tailCount = 0; - var _loop_18 = function () { + var _loop_19 = function () { if (tailCount === 1000) { error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); result = errorType; @@ -63132,7 +63340,7 @@ var ts; // * The mapper that maps the clone to its inference result (`context.mapper`) var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter); var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined; - var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */); + var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */); if (freshMapper) { var freshCombinedMapper = combineTypeMappers(mapper, freshMapper); for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) { @@ -63150,7 +63358,7 @@ var ts; // We don't want inferences from constraints as they may cause us to eagerly resolve the // conditional type instead of deferring resolution. Also, we always want strict function // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); } var innerMapper = combineTypeMappers(freshMapper, context.mapper); // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the @@ -63166,15 +63374,15 @@ var ts; // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, // then no instantiations will be and we can just return the false branch type. - if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */ && !isUnwrapped) { + if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) { (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } // If falseType is an immediately nested conditional type that isn't distributive or has an // identical checkType, switch to that type and loop. var falseType_1 = getTypeFromTypeNode(root.node.falseType); - if (falseType_1.flags & 16777216 /* Conditional */) { + if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) { var newRoot = falseType_1.root; if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { root = newRoot; @@ -63192,7 +63400,7 @@ var ts; // that has no constraint. This ensures that, for example, the type // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. - if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { + if (inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { var trueType_1 = getTypeFromTypeNode(root.node.trueType); var trueMapper = combinedMapper || mapper; if (canTailRecurse(trueType_1, trueMapper)) { @@ -63203,7 +63411,7 @@ var ts; } } // Return a deferred type for a check that is neither definitely true nor definitely false - result = createType(16777216 /* Conditional */); + result = createType(16777216 /* TypeFlags.Conditional */); result.root = root; result.checkType = instantiateType(root.checkType, mapper); result.extendsType = instantiateType(root.extendsType, mapper); @@ -63219,7 +63427,7 @@ var ts; // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive // cases we increment the tail recursion counter and stop after 1000 iterations. while (true) { - var state_5 = _loop_18(); + var state_5 = _loop_19(); if (typeof state_5 === "object") return state_5.value; if (state_5 === "break") @@ -63231,14 +63439,14 @@ var ts; // type. Note that recursion is possible only through aliased conditional types, so we only increment the tail // recursion counter for those. function canTailRecurse(newType, newMapper) { - if (newType.flags & 16777216 /* Conditional */ && newMapper) { + if (newType.flags & 16777216 /* TypeFlags.Conditional */ && newMapper) { var newRoot = newType.root; if (newRoot.outerTypeParameters) { var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper); var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); }); var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments); var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined; - if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) { + if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */))) { root = newRoot; mapper = newRootMapper; aliasSymbol = undefined; @@ -63266,7 +63474,7 @@ var ts; var result; if (node.locals) { node.locals.forEach(function (symbol) { - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { result = ts.append(result, getDeclaredTypeOfSymbol(symbol)); } }); @@ -63289,7 +63497,7 @@ var ts; node: node, checkType: checkType, extendsType: getTypeFromTypeNode(node.extendsType), - isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeFlags.TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -63320,6 +63528,7 @@ var ts; } } function getTypeFromImportTypeNode(node) { + var _a; var links = getNodeLinks(node); if (!links.resolvedType) { if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments @@ -63332,27 +63541,30 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* SymbolFlags.Value */ : node.flags & 8388608 /* NodeFlags.JSDoc */ ? 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ : 788968 /* SymbolFlags.Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } + var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)); var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); if (!ts.nodeIsMissing(node.qualifier)) { var nameStack = getIdentifierChain(node.qualifier); var currentNamespace = moduleSymbol; var current = void 0; while (current = nameStack.shift()) { - var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning; + var meaning = nameStack.length ? 1920 /* SymbolFlags.Namespace */ : targetMeaning; // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from // the `exports` lookup process that only looks up namespace members which is used for most type references var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace)); - var next = node.isTypeOf + var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true) - : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + : undefined; + var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable; if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); return links.resolvedType = errorType; @@ -63368,7 +63580,7 @@ var ts; links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 111551 /* Value */ + var errorMessage = targetMeaning === 111551 /* SymbolFlags.Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -63382,7 +63594,7 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 111551 /* Value */) { + if (meaning === 111551 /* SymbolFlags.Value */) { return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { @@ -63398,7 +63610,7 @@ var ts; links.resolvedType = emptyTypeLiteralType; } else { - var type = createObjectType(16 /* Anonymous */, node.symbol); + var type = createObjectType(16 /* ObjectFlags.Anonymous */, node.symbol); type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); if (ts.isJSDocTypeLiteral(node) && node.isArrayType) { @@ -63411,7 +63623,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -63420,13 +63632,13 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function isNonGenericObjectType(type) { - return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + return !!(type.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(type); } function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) { - return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); + return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return type; } if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { @@ -63446,13 +63658,13 @@ var ts; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // do nothing, skip privates } else if (isSpreadableProperty(prop)) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - var flags = 4 /* Property */ | 16777216 /* Optional */; - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */; + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -63461,7 +63673,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return spread; } } @@ -63471,31 +63683,31 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, symbol, objectFlags, readonly) { - if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + if (left.flags & 1 /* TypeFlags.Any */ || right.flags & 1 /* TypeFlags.Any */) { return anyType; } - if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + if (left.flags & 2 /* TypeFlags.Unknown */ || right.flags & 2 /* TypeFlags.Unknown */) { return unknownType; } - if (left.flags & 131072 /* Never */) { + if (left.flags & 131072 /* TypeFlags.Never */) { return right; } - if (right.flags & 131072 /* Never */) { + if (right.flags & 131072 /* TypeFlags.Never */) { return left; } left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); - if (left.flags & 1048576 /* Union */) { + if (left.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) : errorType; } right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); - if (right.flags & 1048576 /* Union */) { + if (right.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) : errorType; } - if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { + if (right.flags & (528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)) { return left; } if (isGenericObjectType(left) || isGenericObjectType(right)) { @@ -63505,7 +63717,7 @@ var ts; // When the left type is an intersection, we may need to merge the last constituent of the // intersection with the right type. For example when the left type is 'T & { a: string }' // and the right type is '{ b: string }' we produce 'T & { a: string, b: string }'. - if (left.flags & 2097152 /* Intersection */) { + if (left.flags & 2097152 /* TypeFlags.Intersection */) { var types = left.types; var lastLeft = types[types.length - 1]; if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { @@ -63519,7 +63731,7 @@ var ts; var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { @@ -63534,11 +63746,11 @@ var ts; if (members.has(leftProp.escapedName)) { var rightProp = members.get(leftProp.escapedName); var rightType = getTypeOfSymbol(rightProp); - if (rightProp.flags & 16777216 /* Optional */) { + if (rightProp.flags & 16777216 /* SymbolFlags.Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); + var flags = 4 /* SymbolFlags.Property */ | (leftProp.flags & 16777216 /* SymbolFlags.Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */); + result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* UnionReduction.Subtype */); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -63551,23 +63763,23 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); })); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */ | 2097152 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 2097152 /* ObjectFlags.ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { var _a; return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && - (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + (!(prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) || !((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); }))); } function getSpreadSymbol(prop, readonly) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) { return prop; } - var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var flags = 4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */); + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -63585,7 +63797,7 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 2944 /* Literal */) { + if (type.flags & 2944 /* TypeFlags.Literal */) { if (!type.freshType) { var freshType = createLiteralType(type.flags, type.value, type.symbol, type); freshType.freshType = freshType; @@ -63596,39 +63808,39 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 2944 /* Literal */ ? type.regularType : - type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : + return type.flags & 2944 /* TypeFlags.Literal */ ? type.regularType : + type.flags & 1048576 /* TypeFlags.Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + return !!(type.flags & 2944 /* TypeFlags.Literal */) && type.freshType === type; } function getStringLiteralType(value) { var type; return stringLiteralTypes.get(value) || - (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type); + (stringLiteralTypes.set(value, type = createLiteralType(128 /* TypeFlags.StringLiteral */, value)), type); } function getNumberLiteralType(value) { var type; return numberLiteralTypes.get(value) || - (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type); + (numberLiteralTypes.set(value, type = createLiteralType(256 /* TypeFlags.NumberLiteral */, value)), type); } function getBigIntLiteralType(value) { var type; var key = ts.pseudoBigIntToString(value); return bigIntLiteralTypes.get(key) || - (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type); + (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* TypeFlags.BigIntLiteral */, value)), type); } function getEnumLiteralType(value, enumId, symbol) { var type; var qualifier = typeof value === "string" ? "@" : "#"; var key = enumId + qualifier + value; - var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */); + var flags = 1024 /* TypeFlags.EnumLiteral */ | (typeof value === "string" ? 128 /* TypeFlags.StringLiteral */ : 256 /* TypeFlags.NumberLiteral */); return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type); } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 104 /* NullKeyword */) { + if (node.literal.kind === 104 /* SyntaxKind.NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -63638,9 +63850,9 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(8192 /* UniqueESSymbol */); + var type = createType(8192 /* TypeFlags.UniqueESSymbol */); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -63656,20 +63868,20 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) { if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } // inside x.prototype = { ... } - if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; } // /** @return {this} */ // x.prototype.m = function() { ... } - var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; - if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; } // inside constructor function C() { ... } @@ -63691,17 +63903,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 186 /* RestType */ || node.kind === 197 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 186 /* SyntaxKind.RestType */ || node.kind === 197 /* SyntaxKind.NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return node.elementType; } return undefined; @@ -63717,99 +63929,99 @@ var ts; } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return anyType; - case 155 /* UnknownKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return unknownType; - case 150 /* StringKeyword */: + case 150 /* SyntaxKind.StringKeyword */: return stringType; - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return numberType; - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return bigintType; - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return booleanType; - case 151 /* SymbolKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: return esSymbolType; - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return voidType; - case 153 /* UndefinedKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: return undefinedType; - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 143 /* NeverKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return neverType; - case 148 /* ObjectKeyword */: - return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 138 /* IntrinsicKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + return node.flags & 262144 /* NodeFlags.JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; + case 138 /* SyntaxKind.IntrinsicKeyword */: return intrinsicMarkerType; - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return getTypeFromLiteralTypeNode(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getTypeFromTypeReference(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return getTypeFromTypeQueryNode(node); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return getTypeFromOptionalTypeNode(node); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return getTypeFromUnionTypeNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 191 /* ParenthesizedType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: return getTypeFromRestTypeNode(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return getTypeFromMappedTypeNode(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return getTypeFromInferTypeNode(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -63847,9 +64059,9 @@ var ts; } function getMappedType(type, mapper) { switch (mapper.kind) { - case 0 /* Simple */: + case 0 /* TypeMapKind.Simple */: return type === mapper.source ? mapper.target : type; - case 1 /* Array */: + case 1 /* TypeMapKind.Array */: { var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -63858,25 +64070,39 @@ var ts; } } return type; - case 2 /* Function */: + } + case 2 /* TypeMapKind.Deferred */: { + var sources = mapper.sources; + var targets = mapper.targets; + for (var i = 0; i < sources.length; i++) { + if (type === sources[i]) { + return targets[i](); + } + } + return type; + } + case 3 /* TypeMapKind.Function */: return mapper.func(type); - case 3 /* Composite */: - case 4 /* Merged */: + case 4 /* TypeMapKind.Composite */: + case 5 /* TypeMapKind.Merged */: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 4 /* TypeMapKind.Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0 /* Simple */, source: source, target: target }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 0 /* TypeMapKind.Simple */, source: source, target: target }); } function makeArrayTypeMapper(sources, targets) { - return { kind: 1 /* Array */, sources: sources, targets: targets }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 1 /* TypeMapKind.Array */, sources: sources, targets: targets }); + } + function makeFunctionTypeMapper(func, debugInfo) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 3 /* TypeMapKind.Function */, func: func, debugInfo: ts.Debug.isDebugging ? debugInfo : undefined }); } - function makeFunctionTypeMapper(func) { - return { kind: 2 /* Function */, func: func }; + function makeDeferredTypeMapper(sources, targets) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 2 /* TypeMapKind.Deferred */, sources: sources, targets: targets }); } function makeCompositeTypeMapper(kind, mapper1, mapper2) { - return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: kind, mapper1: mapper1, mapper2: mapper2 }); } function createTypeEraser(sources) { return createTypeMapper(sources, /*targets*/ undefined); @@ -63886,19 +64112,20 @@ var ts; * This is used during inference when instantiating type parameter defaults. */ function createBackreferenceMapper(context, index) { - return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); + var forwardInferences = context.inferences.slice(index); + return createTypeMapper(ts.map(forwardInferences, function (i) { return i.typeParameter; }), ts.map(forwardInferences, function () { return unknownType; })); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4 /* TypeMapKind.Composite */, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -63931,7 +64158,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -63943,7 +64170,7 @@ var ts; // be affected by instantiation, simply return the symbol itself. return symbol; } - if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + if (ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) { // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -63952,7 +64179,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (8 /* Readonly */ | 4096 /* Late */ | 16384 /* OptionalParameter */ | 32768 /* RestParameter */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* CheckFlags.Instantiated */ | ts.getCheckFlags(symbol) & (8 /* CheckFlags.Readonly */ | 4096 /* CheckFlags.Late */ | 16384 /* CheckFlags.OptionalParameter */ | 32768 /* CheckFlags.RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -63966,12 +64193,12 @@ var ts; return result; } function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { - var declaration = type.objectFlags & 4 /* Reference */ ? type.node : - type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : + var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node : + type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); - var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : - type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType : + type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type; var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type @@ -63984,8 +64211,8 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; - typeParameters = (target.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -64006,8 +64233,8 @@ var ts; var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } @@ -64016,8 +64243,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.parent.kind === 178 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 200 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -64026,7 +64253,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 235 /* Block */ || n.kind === 189 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -64035,15 +64262,15 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return !!tp.isThisType; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return true; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return !node.type && !!node.body || ts.some(node.typeParameters, containsReference) || ts.some(node.parameters, containsReference) || @@ -64054,9 +64281,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { var typeVariable = getActualTypeVariable(constraintType.type); - if (typeVariable.flags & 262144 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeFlags.TypeParameter */) { return typeVariable; } } @@ -64078,10 +64305,10 @@ var ts; var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) { + if (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && t !== wildcardType && !isErrorType(t)) { if (!type.declaration.nameType) { var constraint = void 0; - if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && + if (isArrayType(t) || t.flags & 1 /* TypeFlags.Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } @@ -64102,7 +64329,7 @@ var ts; return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments); } function getModifiedReadonlyState(state, modifiers) { - return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state; + return modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? true : modifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */ ? false : state; } function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) { // When a tuple type is generic (i.e. when it contains variadic elements), we want to eagerly map the @@ -64111,14 +64338,14 @@ var ts; // normalization to resolve the non-generic parts of the resulting tuple. var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) { - var singleton = elementFlags[i] & 8 /* Variadic */ ? t : - elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : + var singleton = elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : + elementFlags[i] & 4 /* ElementFlags.Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]); // The singleton is never a generic tuple type, so it is safe to recurse here. return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper)); }); var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType)); - return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* Variadic */; }), newReadonly); + return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* ElementFlags.Variadic */; }), newReadonly); } function instantiateMappedArrayType(arrayType, mappedType, mapper) { var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper); @@ -64128,11 +64355,11 @@ var ts; function instantiateMappedTupleType(tupleType, mappedType, mapper) { var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { - return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); + return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* ElementFlags.Optional */), mapper); }); var modifiers = getMappedTypeModifiers(mappedType); - var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) : - modifiers & 8 /* ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var newTupleModifiers = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? 2 /* ElementFlags.Optional */ : f; }) : + modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : elementFlags; var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers); return ts.contains(elementTypes, errorType) ? errorType : @@ -64142,13 +64369,13 @@ var ts; var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + return strictNullChecks && modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + strictNullChecks && modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { - var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); - if (type.objectFlags & 32 /* Mapped */) { + var result = createObjectType(type.objectFlags | 64 /* ObjectFlags.Instantiated */, type.symbol); + if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { result.declaration = type.declaration; // C.f. instantiateSignature var origTypeParameter = getTypeParameterFromMappedType(type); @@ -64157,13 +64384,14 @@ var ts; mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper); freshTypeParameter.mapper = mapper; } - if (type.objectFlags & 8388608 /* InstantiationExpressionType */) { + if (type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */) { result.node = type.node; } result.target = type; result.mapper = mapper; result.aliasSymbol = aliasSymbol || type.aliasSymbol; result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0; return result; } function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { @@ -64182,7 +64410,7 @@ var ts; // Distributive conditional types are distributed over union types. For example, when the // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the // result is (A extends U ? X : Y) | (B extends U ? X : Y). - result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? + result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); @@ -64202,7 +64430,7 @@ var ts; // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } @@ -64215,62 +64443,62 @@ var ts; } function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; - if (flags & 262144 /* TypeParameter */) { + if (flags & 262144 /* TypeFlags.TypeParameter */) { return getMappedType(type, mapper); } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { var objectFlags = type.objectFlags; - if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !type.node) { + if (objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + if (objectFlags & 4 /* ObjectFlags.Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { return instantiateReverseMappedType(type, mapper); } return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } - if (flags & 3145728 /* UnionOrIntersection */) { - var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; - var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; + if (flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + var origin = type.flags & 1048576 /* TypeFlags.Union */ ? type.origin : undefined; + var types = origin && origin.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); if (newTypes === types && aliasSymbol === type.aliasSymbol) { return type; } var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); - return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? + return flags & 2097152 /* TypeFlags.Intersection */ || origin && origin.flags & 2097152 /* TypeFlags.Intersection */ ? getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : - getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); + getUnionType(newTypes, 1 /* UnionReduction.Literal */, newAliasSymbol, newAliasTypeArguments); } - if (flags & 4194304 /* Index */) { + if (flags & 4194304 /* TypeFlags.Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 134217728 /* TemplateLiteral */) { + if (flags & 134217728 /* TypeFlags.TemplateLiteral */) { return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper)); } - if (flags & 268435456 /* StringMapping */) { + if (flags & 268435456 /* TypeFlags.StringMapping */) { return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } - if (flags & 8388608 /* IndexedAccess */) { + if (flags & 8388608 /* TypeFlags.IndexedAccess */) { var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); } - if (flags & 16777216 /* Conditional */) { + if (flags & 16777216 /* TypeFlags.Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } - if (flags & 33554432 /* Substitution */) { + if (flags & 33554432 /* TypeFlags.Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); - if (maybeVariable.flags & 8650752 /* TypeVariable */) { + if (maybeVariable.flags & 8650752 /* TypeFlags.TypeVariable */) { return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper)); } else { var sub = instantiateType(type.substitute, mapper); - if (sub.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { + if (sub.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { return maybeVariable; } return sub; @@ -64280,11 +64508,11 @@ var ts; } function instantiateReverseMappedType(type, mapper) { var innerMappedType = instantiateType(type.mappedType, mapper); - if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + if (!(ts.getObjectFlags(innerMappedType) & 32 /* ObjectFlags.Mapped */)) { return type; } var innerIndexType = instantiateType(type.constraintType, mapper); - if (!(innerIndexType.flags & 4194304 /* Index */)) { + if (!(innerIndexType.flags & 4194304 /* TypeFlags.Index */)) { return type; } var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); @@ -64294,15 +64522,15 @@ var ts; return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable } function getUniqueLiteralFilledInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper)); } function getPermissiveInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); } function getRestrictiveInstantiation(type) { - if (type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */)) { + if (type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) { return type; } if (type.restrictiveInstantiation) { @@ -64323,35 +64551,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 221 /* BinaryExpression */: - return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && + case 221 /* SyntaxKind.BinaryExpression */: + return (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return isContextSensitive(node.initializer); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isContextSensitive(node.expression); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 285 /* JsxAttribute */: { + case 285 /* SyntaxKind.JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 288 /* JsxExpression */: { + case 288 /* SyntaxKind.JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -64365,17 +64593,17 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* SyntaxKind.Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { - var result = createObjectType(16 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* ObjectFlags.Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = ts.emptyArray; @@ -64384,7 +64612,7 @@ var ts; return result; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -64394,13 +64622,13 @@ var ts; return isTypeRelatedTo(source, target, identityRelation); } function compareTypesIdentical(source, target) { - return isTypeRelatedTo(source, target, identityRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, identityRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesAssignable(source, target) { - return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesSubtypeOf(source, target) { - return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); @@ -64417,11 +64645,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 1048576 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : - target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 1048576 /* TypeFlags.Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* TypeFlags.Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType)); } /** @@ -64459,7 +64687,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* TypeFlags.Conditional */ || (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { if (!node || isOrHasGenericConditional(target)) @@ -64469,35 +64697,35 @@ var ts; return true; } switch (node.kind) { - case 288 /* JsxExpression */: - case 212 /* ParenthesizedExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 27 /* CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; } function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { - var callSignatures = getSignaturesOfType(source, 0 /* Call */); - var constructSignatures = getSignaturesOfType(source, 1 /* Construct */); + var callSignatures = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructSignatures = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) { var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = errorOutputContainer || {}; checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj); @@ -64521,7 +64749,7 @@ var ts; if (!sourceSig) { return false; } - var targetSignatures = getSignaturesOfType(target, 0 /* Call */); + var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */); if (!ts.length(targetSignatures)) { return false; } @@ -64539,7 +64767,7 @@ var ts; if (target.symbol && ts.length(target.symbol.declarations)) { ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); } - if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0 + if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 // exclude cases where source itself is promisy - this way we don't make a suggestion when relating // an IPromise and a Promise that are slightly different && !getTypeOfPropertyOfType(sourceReturn, "then") @@ -64556,7 +64784,7 @@ var ts; if (idx) { return idx; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { var best = getBestMatchingType(source, target); if (best) { return getIndexedAccessTypeOrUndefined(best, nameType); @@ -64566,7 +64794,7 @@ var ts; function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) { next.contextualType = sourcePropType; try { - return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType); + return checkExpressionForMutableLocation(next, 1 /* CheckMode.Contextual */, sourcePropType); } finally { next.contextualType = undefined; @@ -64583,7 +64811,7 @@ var ts; for (var status = iterator.next(); !status.done; status = iterator.next()) { var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType); - if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) + if (!targetPropType || targetPropType.flags & 8388608 /* TypeFlags.IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); if (!sourcePropType) @@ -64603,8 +64831,8 @@ var ts; resultObj.errors = [diag]; } else { - var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); - var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); targetPropType = removeMissingType(targetPropType, targetIsOptional); sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); @@ -64628,7 +64856,7 @@ var ts; if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) { var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0]; if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) { - ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); } } } @@ -64694,18 +64922,18 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: if (child.containsOnlyTriviaWhiteSpaces) { break; // Whitespace only jsx text isn't real jsx text } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -64730,7 +64958,7 @@ var ts; var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); }); if (moreThanOneRealChildren) { if (arrayLikeTargetParts !== neverType) { - var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */)); + var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */)); var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic); result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result; } @@ -64812,7 +65040,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & (131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -64822,7 +65050,7 @@ var ts; var oldContext = node.contextualType; node.contextualType = target; try { - var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); + var tupleizedType = checkArrayLiteral(node, 1 /* CheckMode.Contextual */, /*forceTuple*/ true); node.contextualType = oldContext; if (isTupleLikeType(tupleizedType)) { return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); @@ -64847,17 +65075,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 131072 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* TypeFlags.Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 173 /* SetAccessor */: return [3 /*break*/, 2]; - case 172 /* GetAccessor */: return [3 /*break*/, 2]; - case 169 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 297 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 296 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 173 /* SyntaxKind.SetAccessor */: return [3 /*break*/, 2]; + case 172 /* SyntaxKind.GetAccessor */: return [3 /*break*/, 2]; + case 169 /* SyntaxKind.MethodDeclaration */: return [3 /*break*/, 2]; + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 296 /* SyntaxKind.PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -64879,7 +65107,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & (131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -64891,8 +65119,8 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* IgnoreReturnTypes */ : 0, /*reportErrors*/ false, - /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* False */; + return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* SignatureCheckMode.IgnoreReturnTypes */ : 0, /*reportErrors*/ false, + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* Ternary.False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -64908,16 +65136,16 @@ var ts; function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isAnySignature(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var targetCount = getParameterCount(target); var sourceHasMoreParameters = !hasEffectiveRestParameter(target) && - (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); + (checkMode & 8 /* SignatureCheckMode.StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); if (sourceHasMoreParameters) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); @@ -64929,10 +65157,10 @@ var ts; if (sourceRestType || targetRestType) { void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers); } - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 169 /* MethodDeclaration */ && - kind !== 168 /* MethodSignature */ && kind !== 171 /* Constructor */; - var result = -1 /* True */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + var strictVariance = !(checkMode & 3 /* SignatureCheckMode.Callback */) && strictFunctionTypes && kind !== 169 /* SyntaxKind.MethodDeclaration */ && + kind !== 168 /* SyntaxKind.MethodSignature */ && kind !== 171 /* SyntaxKind.Constructor */; + var result = -1 /* Ternary.True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { var targetThisType = getThisTypeOfSignature(target); @@ -64944,7 +65172,7 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64963,27 +65191,27 @@ var ts; // similar to return values, callback parameters are output positions. This means that a Promise, // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) // with respect to T. - var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); - var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); + var sourceSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getTypeFacts(sourceType) & 50331648 /* IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* IsUndefinedOrNull */); + (getTypeFacts(sourceType) & 50331648 /* TypeFacts.IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* TypeFacts.IsUndefinedOrNull */); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : - !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* SignatureCheckMode.StrictArity */) | (strictVariance ? 2 /* SignatureCheckMode.StrictCallback */ : 1 /* SignatureCheckMode.BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : + !(checkMode & 3 /* SignatureCheckMode.Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { - related = 0 /* False */; + if (related && checkMode & 8 /* SignatureCheckMode.StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + related = 0 /* Ternary.False */; } if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } } - if (!(checkMode & 4 /* IgnoreReturnTypes */)) { + if (!(checkMode & 4 /* SignatureCheckMode.IgnoreReturnTypes */)) { // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType @@ -65006,14 +65234,14 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } else { // When relating callback signatures, we still need to relate return types bi-variantly as otherwise // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } // wouldn't be co-variant for T without this rule. - result &= checkMode & 1 /* BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + result &= checkMode & 1 /* SignatureCheckMode.BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); if (!result && reportErrors && incompatibleErrorReporter) { incompatibleErrorReporter(sourceReturnType, targetReturnType); @@ -65028,21 +65256,21 @@ var ts; errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { + if (source.kind === 1 /* TypePredicateKind.Identifier */ || source.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var related = source.type === target.type ? -1 /* True */ : + var related = source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; - if (related === 0 /* False */ && reportErrors) { + 0 /* Ternary.False */; + if (related === 0 /* Ternary.False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return related; @@ -65068,33 +65296,33 @@ var ts; t.indexInfos.length === 0; } function isEmptyObjectType(type) { - return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 67108864 /* NonPrimitive */ ? true : - type.flags & 1048576 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* TypeFlags.Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 67108864 /* TypeFlags.NonPrimitive */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isEmptyObjectType) : false; } function isEmptyAnonymousObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) || - type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && (type.members && isEmptyResolvedType(type) || + type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); } function isUnknownLikeUnionType(type) { - if (strictNullChecks && type.flags & 1048576 /* Union */) { - if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) { + if (strictNullChecks && type.flags & 1048576 /* TypeFlags.Union */) { + if (!(type.objectFlags & 33554432 /* ObjectFlags.IsUnknownLikeUnionComputed */)) { var types = type.types; - type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ && - types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0); + type.objectFlags |= 33554432 /* ObjectFlags.IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* TypeFlags.Undefined */ && + types[1].flags & 65536 /* TypeFlags.Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* ObjectFlags.IsUnknownLikeUnion */ : 0); } - return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */); + return !!(type.objectFlags & 67108864 /* ObjectFlags.IsUnknownLikeUnion */); } return false; } function containsUndefinedType(type) { - return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */); + return !!((type.flags & 1048576 /* TypeFlags.Union */ ? type.types[0] : type).flags & 32768 /* TypeFlags.Undefined */); } function isStringIndexSignatureOnlyType(type) { - return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || - type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || + return type.flags & 524288 /* TypeFlags.Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -65103,83 +65331,83 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var entry = enumRelation.get(id); - if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { - return !!(entry & 1 /* Succeeded */); + if (entry !== undefined && !(!(entry & 4 /* RelationComparisonResult.Reported */) && entry & 2 /* RelationComparisonResult.Failed */ && errorReporter)) { + return !!(entry & 1 /* RelationComparisonResult.Succeeded */); } - if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* SymbolFlags.RegularEnum */) || !(targetSymbol.flags & 256 /* SymbolFlags.RegularEnum */)) { + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) { var property = _a[_i]; - if (property.flags & 8 /* EnumMember */) { + if (property.flags & 8 /* SymbolFlags.EnumMember */) { var targetProperty = getPropertyOfType(targetEnumType, property.escapedName); - if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { + if (!targetProperty || !(targetProperty.flags & 8 /* SymbolFlags.EnumMember */)) { if (errorReporter) { - errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */)); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); } else { - enumRelation.set(id, 2 /* Failed */); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */); } return false; } } } - enumRelation.set(id, 1 /* Succeeded */); + enumRelation.set(id, 1 /* RelationComparisonResult.Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) + if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType) return true; - if (t & 131072 /* Never */) + if (t & 131072 /* TypeFlags.Never */) return false; - if (s & 402653316 /* StringLike */ && t & 4 /* String */) + if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */) return true; - if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && - t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 296 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */) return true; - if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && - t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) + if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */) return true; - if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */) return true; - if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) + if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */) return true; - if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { - if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) { + if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && + if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`. // Since unions and intersections may reduce to `never`, we exclude them here. - if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) + if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */))) return true; - if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) + if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */)) return true; - if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */))) + if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */))) return true; if (relation === assignableRelation || relation === comparableRelation) { - if (s & 1 /* Any */) + if (s & 1 /* TypeFlags.Any */) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any // numeric enum literal type. This rule exists for backwards compatibility reasons because // bit-flag enum types sometimes look like literal enum types with numeric literal values. - if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */)) return true; // Anything is assignable to a union containing undefined, null, and {} if (isUnknownLikeUnionType(target)) @@ -65198,38 +65426,38 @@ var ts; return true; } if (relation !== identityRelation) { - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { return true; } } - else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) { + else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) { // We have excluded types that may simplify to other forms, so types must have identical flags if (source.flags !== target.flags) return false; - if (source.flags & 67358815 /* Singleton */) + if (source.flags & 67358815 /* TypeFlags.Singleton */) return true; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false)); + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { + var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false)); if (related !== undefined) { - return !!(related & 1 /* Succeeded */); + return !!(related & 1 /* RelationComparisonResult.Succeeded */); } } - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { var t = isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type : - type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) : - type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : - type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : + ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type : + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? writing ? type.baseType : type.substitute : + type.flags & 25165824 /* TypeFlags.Simplifiable */ ? getSimplifiedType(type, writing) : type; if (t === type) return t; @@ -65241,7 +65469,7 @@ var ts; if (reduced !== type) { return reduced; } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); }); if (normalizedTypes !== type.types) { return getIntersectionType(normalizedTypes); @@ -65269,19 +65497,19 @@ var ts; var maybeCount = 0; var sourceDepth = 0; var targetDepth = 0; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; var overflow = false; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid var lastSkippedInfo; var incompatibleStack; var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage); + var result = isRelatedTo(source, target, 3 /* RecursionFlags.Both */, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack) { reportIncompatibleStack(); } if (overflow) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -65319,10 +65547,10 @@ var ts; diagnostics.add(diag); } } - if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) { + if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* Ternary.False */) { ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } - return result !== 0 /* False */; + return result !== 0 /* Ternary.False */; function resetErrorInfo(saved) { errorInfo = saved.errorInfo; lastSkippedInfo = saved.lastSkippedInfo; @@ -65367,24 +65595,24 @@ var ts; case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { // Parenthesize a `new` if there is one if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; // If leading, just print back the arg (irrespective of if it's a valid identifier) if (path.length === 0) { - path = "" + str; + path = "".concat(str); } // Otherwise write a dotted name if possible else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } // Failing that, check if the name is already a computed name else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } // And finally write out a computed name as a last resort else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -65413,7 +65641,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -65426,7 +65654,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -65478,7 +65706,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 /* TypeFlags.TypeParameter */ && target !== markerSuperTypeForCheck && target !== markerSubTypeForCheck) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -65500,7 +65728,7 @@ var ts; message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; } else { - if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */ && target.flags & 1048576 /* TypeFlags.Union */) { var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target); if (suggestedType) { reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType)); @@ -65562,7 +65790,7 @@ var ts; return true; } function isRelatedToWorker(source, target, reportErrors) { - return isRelatedTo(source, target, 3 /* Both */, reportErrors); + return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors); } /** * Compare two types and return @@ -65571,19 +65799,19 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) { - if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; } + if (recursionFlags === void 0) { recursionFlags = 3 /* RecursionFlags.Both */; } if (reportErrors === void 0) { reportErrors = false; } - if (intersectionState === void 0) { intersectionState = 0 /* None */; } + if (intersectionState === void 0) { intersectionState = 0 /* IntersectionState.None */; } // Before normalization: if `source` is type an object type, and `target` is primitive, // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result - if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) { + if (originalSource.flags & 524288 /* TypeFlags.Object */ && originalTarget.flags & 131068 /* TypeFlags.Primitive */) { if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (reportErrors) { reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and @@ -65592,73 +65820,73 @@ var ts; var source = getNormalizedType(originalSource, /*writing*/ false); var target = getNormalizedType(originalTarget, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; if (relation === identityRelation) { if (source.flags !== target.flags) - return 0 /* False */; - if (source.flags & 67358815 /* Singleton */) - return -1 /* True */; + return 0 /* Ternary.False */; + if (source.flags & 67358815 /* TypeFlags.Singleton */) + return -1 /* Ternary.True */; traceUnionsOrIntersectionsTooLarge(source, target); - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* IntersectionState.None */, recursionFlags); } // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, // as we break down the _target_ union first, _then_ get the source constraint - so for every // member of the target, we attempt to find a match in the source. This avoids that in cases where // the target is exactly the constraint. - if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) { - return -1 /* True */; + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && getConstraintOfType(source) === target) { + return -1 /* Ternary.True */; } // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined // plus a single non-nullable type. If so, remove null and/or undefined from the target type. - if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) { + if (source.flags & 470302716 /* TypeFlags.DefinitelyNonNullable */ && target.flags & 1048576 /* TypeFlags.Union */) { var types = target.types; - var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : - types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : + var candidate = types.length === 2 && types[0].flags & 98304 /* TypeFlags.Nullable */ ? types[1] : + types.length === 3 && types[0].flags & 98304 /* TypeFlags.Nullable */ && types[1].flags & 98304 /* TypeFlags.Nullable */ ? types[2] : undefined; - if (candidate && !(candidate.flags & 98304 /* Nullable */)) { + if (candidate && !(candidate.flags & 98304 /* TypeFlags.Nullable */)) { target = getNormalizedType(candidate, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) - return -1 /* True */; - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* FreshLiteral */); + return -1 /* Ternary.True */; + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* IntersectionState.Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) && - source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && - target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* IntersectionState.Target */) && + source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType && + target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source); var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target); - var calls = getSignaturesOfType(source, 0 /* Call */); - var constructs = getSignaturesOfType(source, 1 /* Construct */); - if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) || - constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) { + var calls = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructs = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString); } else { reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString); } } - return 0 /* False */; + return 0 /* Ternary.False */; } traceUnionsOrIntersectionsTooLarge(source, target); - var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) || - target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */); + var skipCaching = source.flags & 1048576 /* TypeFlags.Union */ && source.types.length < 4 && !(target.flags & 1048576 /* TypeFlags.Union */) || + target.flags & 1048576 /* TypeFlags.Union */ && target.types.length < 4 && !(source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */); var result_7 = skipCaching ? unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) : recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags); @@ -65677,10 +65905,10 @@ 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_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) { + if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) { inPropertyCheck = true; - result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags); + result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags); inPropertyCheck = false; } if (result_7) { @@ -65690,7 +65918,7 @@ var ts; if (reportErrors) { reportErrorResults(originalSource, originalTarget, source, target, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { var _a, _b; @@ -65702,20 +65930,20 @@ var ts; if (maybeSuppress) { overrideNextErrorInfo--; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true); if (errorInfo !== currentError) { maybeSuppress = !!errorInfo; } } - if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 131068 /* TypeFlags.Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* TypeFlags.Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } - else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) { + else if (ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && target.flags & 2097152 /* TypeFlags.Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -65734,7 +65962,7 @@ var ts; return; } reportRelationError(headMessage, source, target); - if (source.flags & 262144 /* TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) { + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) { var syntheticParam = cloneTypeParameter(source); syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam)); if (hasNonCircularBaseConstraint(syntheticParam)) { @@ -65747,17 +65975,17 @@ var ts; if (!ts.tracing) { return; } - if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { + if ((source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) && (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* ObjectFlags.PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } var sourceSize = sourceUnionOrIntersection.types.length; var targetSize = targetUnionOrIntersection.types.length; if (sourceSize * targetSize > 1E6) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { + ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { sourceId: source.id, sourceSize: sourceSize, targetId: target.id, @@ -65772,7 +66000,7 @@ var ts; var appendPropType = function (propTypes, type) { var _a; type = getApparentType(type); - var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); + var prop = type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType; return ts.append(propTypes, propType); }; @@ -65780,21 +66008,21 @@ var ts; } function hasExcessProperties(source, target, reportErrors) { var _a; - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* JSLiteral */) { + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* ObjectFlags.JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; } var reducedTarget = target; var checkTypes; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); - checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; + checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget]; } - var _loop_19 = function (prop) { + var _loop_20 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { @@ -65847,7 +66075,7 @@ var ts; } return { value: true }; } - if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) { + if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* RecursionFlags.Both */, reportErrors)) { if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop)); } @@ -65857,7 +66085,7 @@ var ts; }; for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { var prop = _b[_i]; - var state_6 = _loop_19(prop); + var state_6 = _loop_20(prop); if (typeof state_6 === "object") return state_6.value; } @@ -65870,28 +66098,28 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState); } - if (target.flags & 1048576 /* Union */) { - return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); + if (target.flags & 1048576 /* TypeFlags.Union */) { + return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */) && !(target.flags & 131068 /* TypeFlags.Primitive */)); } - if (target.flags & 2097152 /* Intersection */) { - return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */); + if (target.flags & 2097152 /* TypeFlags.Intersection */) { + return typeRelatedToEachType(source, target, reportErrors, 2 /* IntersectionState.Target */); } // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the // constraints of all non-primitive types in the source into a new intersection. We do this because the // intersection may further constrain the constraints of the non-primitive types. For example, given a type // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't // appear to be comparable to '2'. - if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { + if (relation === comparableRelation && target.flags & 131068 /* TypeFlags.Primitive */) { var constraints = ts.sameMap(source.types, getBaseConstraintOrType); if (constraints !== source.types) { source = getIntersectionType(constraints); - if (!(source.flags & 2097152 /* Intersection */)) { - return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false); + if (!(source.flags & 2097152 /* TypeFlags.Intersection */)) { + return isRelatedTo(source, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false); } } } @@ -65899,16 +66127,16 @@ var ts; // Don't report errors though. Elaborating on whether a source constituent is related to the target is // not actually useful and leads to some confusing error messages. Instead, we rely on the caller // checking whether the full intersection viewed as an object is related to the target. - return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */); + return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* IntersectionState.Source */); } function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65916,13 +66144,13 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { if (containsType(targetTypes, source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var match = getMatchingUnionConstituentForType(target, source); if (match) { - var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65930,7 +66158,7 @@ var ts; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; - var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65939,19 +66167,19 @@ var ts; // Elaborate only if we can find a best matching type in the target union var bestMatchingType = getBestMatchingType(source, target, isRelatedTo); if (bestMatchingType) { - isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true); + isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true); } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToEachType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var targetTypes = target.types; for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { var targetType = targetTypes_2[_i]; - var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(source, targetType, 2 /* RecursionFlags.Target */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65959,50 +66187,50 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors, intersectionState) { var sourceTypes = source.types; - if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { - return -1 /* True */; + if (source.flags & 1048576 /* TypeFlags.Union */ && containsType(sourceTypes, target)) { + return -1 /* Ternary.True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceTypes[i], target, 1 /* RecursionFlags.Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); if (related) { return related; } } - return 0 /* False */; + return 0 /* Ternary.False */; } function getUndefinedStrippedTargetIfNeeded(source, target) { // As a builtin type, `undefined` is a very low type ID - making it almsot always first, making this a very fast check to see // if we need to strip `undefined` from the target - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && - !(source.types[0].flags & 32768 /* Undefined */) && target.types[0].flags & 32768 /* Undefined */) { - return extractTypesOfKind(target, ~32768 /* Undefined */); + if (source.flags & 1048576 /* TypeFlags.Union */ && target.flags & 1048576 /* TypeFlags.Union */ && + !(source.types[0].flags & 32768 /* TypeFlags.Undefined */) && target.types[0].flags & 32768 /* TypeFlags.Undefined */) { + return extractTypesOfKind(target, ~32768 /* TypeFlags.Undefined */); } return target; } function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; // We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath // since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target); for (var i = 0; i < sourceTypes.length; i++) { var sourceType = sourceTypes[i]; - if (undefinedStrippedTarget.flags & 1048576 /* Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { + if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison // such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union - var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); if (related_1) { result &= related_1; continue; } } - var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66013,54 +66241,54 @@ var ts; if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; + return 0 /* Ternary.False */; } var length = sources.length <= targets.length ? sources.length : targets.length; - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < length; i++) { // When variance information isn't available we default to covariance. This happens // in the process of computing variance information for recursive types and when // comparing 'this' type arguments. - var varianceFlags = i < variances.length ? variances[i] : 1 /* Covariant */; - var variance = varianceFlags & 7 /* VarianceMask */; + var varianceFlags = i < variances.length ? variances[i] : 1 /* VarianceFlags.Covariant */; + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; // We ignore arguments for independent type parameters (because they're never witnessed). - if (variance !== 4 /* Independent */) { + if (variance !== 4 /* VarianceFlags.Independent */) { var s = sources[i]; var t = targets[i]; - var related = -1 /* True */; - if (varianceFlags & 8 /* Unmeasurable */) { + var related = -1 /* Ternary.True */; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_. // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be) - related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); + related = relation === identityRelation ? isRelatedTo(s, t, 3 /* RecursionFlags.Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); } - else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 1 /* VarianceFlags.Covariant */) { + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 2 /* VarianceFlags.Contravariant */) { + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 3 /* Bivariant */) { + else if (variance === 3 /* VarianceFlags.Bivariant */) { // In the bivariant case we first compare contravariantly without reporting // errors. Then, if that doesn't succeed, we compare covariantly with error // reporting. Thus, error elaboration will be based on the the covariant check, // which is generally easier to reason about. - related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false); + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (related) { - related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related &= isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66074,28 +66302,28 @@ var ts; // and issue an error. Otherwise, actually compare the structure of the two types. function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) { if (overflow) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0); + var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0); var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false); var entry = relation.get(id); if (entry !== undefined) { - if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { + if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - var saved = entry & 24 /* ReportsMask */; - if (saved & 8 /* ReportsUnmeasurable */) { - instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); + var saved = entry & 24 /* RelationComparisonResult.ReportsMask */; + if (saved & 8 /* RelationComparisonResult.ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMapper); } - if (saved & 16 /* ReportsUnreliable */) { - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + if (saved & 16 /* RelationComparisonResult.ReportsUnreliable */) { + instantiateType(source, reportUnreliableMapper); } } - return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* RelationComparisonResult.Succeeded */ ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } } if (!maybeKeys) { @@ -66111,42 +66339,42 @@ var ts; for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) { - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } } if (sourceDepth === 100 || targetDepth === 100) { overflow = true; - return 0 /* False */; + return 0 /* Ternary.False */; } } var maybeStart = maybeCount; maybeKeys[maybeCount] = id; maybeCount++; var saveExpandingFlags = expandingFlags; - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceStack[sourceDepth] = source; sourceDepth++; - if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) - expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 1 /* ExpandingFlags.Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) + expandingFlags |= 1 /* ExpandingFlags.Source */; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetStack[targetDepth] = target; targetDepth++; - if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) - expandingFlags |= 2 /* Target */; + if (!(expandingFlags & 2 /* ExpandingFlags.Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) + expandingFlags |= 2 /* ExpandingFlags.Target */; } var originalHandler; var propagatingVarianceFlags = 0; if (outofbandVarianceMarkerHandler) { originalHandler = outofbandVarianceMarkerHandler; outofbandVarianceMarkerHandler = function (onlyUnreliable) { - propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + propagatingVarianceFlags |= onlyUnreliable ? 16 /* RelationComparisonResult.ReportsUnreliable */ : 8 /* RelationComparisonResult.ReportsUnmeasurable */; return originalHandler(onlyUnreliable); }; } var result; - if (expandingFlags === 3 /* Both */) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + if (expandingFlags === 3 /* ExpandingFlags.Both */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -66154,30 +66382,30 @@ var ts; depth: sourceDepth, targetDepth: targetDepth }); - result = 3 /* Maybe */; + result = 3 /* Ternary.Maybe */; } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceDepth--; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetDepth--; } expandingFlags = saveExpandingFlags; if (result) { - if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) { - if (result === -1 /* True */ || result === 3 /* Maybe */) { + if (result === -1 /* Ternary.True */ || (sourceDepth === 0 && targetDepth === 0)) { + if (result === -1 /* Ternary.True */ || result === 3 /* Ternary.Maybe */) { // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + relation.set(maybeKeys[i], 1 /* RelationComparisonResult.Succeeded */ | propagatingVarianceFlags); } } maybeCount = maybeStart; @@ -66186,46 +66414,73 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); + relation.set(id, (reportErrors ? 4 /* RelationComparisonResult.Reported */ : 0) | 2 /* RelationComparisonResult.Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - if (intersectionState & 4 /* PropertyCheck */) { - return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); + var saveErrorInfo = captureErrorCalculationState(); + var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo); + if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) { + // The combined constraint of an intersection type is the intersection of the constraints of + // the constituents. When an intersection type contains instantiable types with union type + // constraints, there are situations where we need to examine the combined constraint. One is + // when the target is a union type. Another is when the intersection contains types belonging + // to one of the disjoint domains. For example, given type variables T and U, each with the + // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and + // we need to check this constraint against a union on the target side. Also, given a type + // variable V constrained to 'string | number', 'V & number' has a combined constraint of + // 'string & number | number & number' which reduces to just 'number'. + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */)); + if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + } + } + if (result) { + resetErrorInfo(saveErrorInfo); + } + return result; + } + function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) { + if (intersectionState & 4 /* IntersectionState.PropertyCheck */) { + return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */); } var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = captureErrorCalculationState(); var sourceFlags = source.flags; var targetFlags = target.flags; if (relation === identityRelation) { // We've already checked that source.flags and target.flags are identical - if (sourceFlags & 3145728 /* UnionOrIntersection */) { + if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { var result_8 = eachTypeRelatedToSomeType(source, target); if (result_8) { result_8 &= eachTypeRelatedToSomeType(target, source); } return result_8; } - if (sourceFlags & 4194304 /* Index */) { - return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (sourceFlags & 8388608 /* IndexedAccess */) { - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } } - if (sourceFlags & 16777216 /* Conditional */) { + if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { + if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } @@ -66233,60 +66488,37 @@ var ts; } } } - if (sourceFlags & 33554432 /* Substitution */) { - return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 33554432 /* TypeFlags.Substitution */) { + return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (!(sourceFlags & 524288 /* Object */)) { - return 0 /* False */; + if (!(sourceFlags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } } - else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) { + else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) { - // The combined constraint of an intersection type is the intersection of the constraints of - // the constituents. When an intersection type contains instantiable types with union type - // constraints, there are situations where we need to examine the combined constraint. One is - // when the target is a union type. Another is when the intersection contains types belonging - // to one of the disjoint domains. For example, given type variables T and U, each with the - // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and - // we need to check this constraint against a union on the target side. Also, given a type - // variable V constrained to 'string | number', 'V & number' has a combined constraint of - // 'string & number | number & number' which reduces to just 'number'. - // This also handles type parameters, as a type parameter with a union constraint compared against a union - // needs to have its constraint hoisted into an intersection with said type parameter, this way - // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) - // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); - if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself - // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); - return result; - } - } - } // The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle: // Source is instantiable (e.g. source has union or intersection constraint). // Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }). // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }). - if (!(sourceFlags & 465829888 /* Instantiable */ || - sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ || - sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) { - return 0 /* False */; + if (!(sourceFlags & 465829888 /* TypeFlags.Instantiable */ || + sourceFlags & 524288 /* TypeFlags.Object */ && targetFlags & 1048576 /* TypeFlags.Union */ || + sourceFlags & 2097152 /* TypeFlags.Intersection */ && targetFlags & (524288 /* TypeFlags.Object */ | 1048576 /* TypeFlags.Union */ | 465829888 /* TypeFlags.Instantiable */))) { + return 0 /* Ternary.False */; } } // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. - if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && source.aliasTypeArguments && + if (sourceFlags & (524288 /* TypeFlags.Object */ | 16777216 /* TypeFlags.Conditional */) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) { var variances = getAliasVariances(source.aliasSymbol); if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState); if (varianceResult !== undefined) { @@ -66295,48 +66527,48 @@ var ts; } // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T], // and U is assignable to [...T] when U is constrained to a mutable array or tuple type. - if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) || - isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) { + if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* RecursionFlags.Source */)) || + isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* RecursionFlags.Target */))) { return result; } - if (targetFlags & 262144 /* TypeParameter */) { + if (targetFlags & 262144 /* TypeFlags.TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) { - if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { + if (ts.getObjectFlags(source) & 32 /* ObjectFlags.Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* RecursionFlags.Both */)) { + if (!(getMappedTypeModifiers(source) & 4 /* MappedTypeModifiers.IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(templateType, indexedAccessType, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } } - if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) { + if (relation === comparableRelation && sourceFlags & 262144 /* TypeFlags.TypeParameter */) { // This is a carve-out in comparability to essentially forbid comparing a type parameter // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!) var constraint = getConstraintOfTypeParameter(source); if (constraint && hasNonCircularBaseConstraint(source)) { - while (constraint && constraint.flags & 262144 /* TypeParameter */) { - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) { + while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) { + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { return result; } constraint = getConstraintOfTypeParameter(constraint); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetFlags & 4194304 /* Index */) { + else if (targetFlags & 4194304 /* TypeFlags.Index */) { var targetType_1 = target.type; // A keyof S is related to a keyof T if T is related to S. - if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(targetType_1, source.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } if (isTupleType(targetType_1)) { // An index type can have a tuple type target when the tuple type contains variadic elements. // Check if the source is related to the known keys of the tuple type. - if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -66349,8 +66581,8 @@ var ts; // false positives. For example, given 'T extends { [K in keyof T]: string }', // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when // related to other types. - if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } else if (isGenericMappedType(targetType_1)) { @@ -66365,7 +66597,7 @@ var ts; // missing from the `constraintType` which will otherwise be mapped in the object var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1)); var mappedKeys_1 = []; - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); }); // We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side) targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false)); @@ -66373,21 +66605,20 @@ var ts; else { targetKeys = nameType_1 || constraintType; } - if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, targetKeys, 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } } } - else if (targetFlags & 8388608 /* IndexedAccess */) { - if (sourceFlags & 8388608 /* IndexedAccess */) { + else if (targetFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { // Relate components directly before falling back to constraint relationships // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors); + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } if (reportErrors) { @@ -66402,14 +66633,14 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0); + var accessFlags = 4 /* AccessFlags.Writing */ | (baseObjectType !== objectType ? 2 /* AccessFlags.NoIndexSignatures */ : 0); var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); if (constraint) { if (reportErrors && originalErrorInfo) { // create a new chain for the constraint error resetErrorInfo(saveErrorInfo); } - if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, constraint, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain @@ -66428,12 +66659,12 @@ var ts; var keysRemapped = !!target.declaration.nameType; var templateType = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); - if (!(modifiers & 8 /* ExcludeOptional */)) { + if (!(modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */)) { // If the mapped type has shape `{ [P in Q]: T[P] }`, // source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`. - if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source && + if (!keysRemapped && templateType.flags & 8388608 /* TypeFlags.IndexedAccess */ && templateType.objectType === source && templateType.indexType === getTypeParameterFromMappedType(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!isGenericMappedType(source)) { // If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`. @@ -66441,22 +66672,22 @@ var ts; var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target); // Type of the keys of source type `S`, i.e. `keyof S`. var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true); - var includeOptional = modifiers & 4 /* IncludeOptional */; + var includeOptional = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */; var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined; // A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T. // A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`. if (includeOptional - ? !(filteredByApplicability.flags & 131072 /* Never */) - : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) { + ? !(filteredByApplicability.flags & 131072 /* TypeFlags.Never */) + : isRelatedTo(targetKeys, sourceKeys, 3 /* RecursionFlags.Both */)) { var templateType_1 = getTemplateTypeFromMappedType(target); var typeParameter = getTypeParameterFromMappedType(target); // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj` // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`. - var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */); - if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { - if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) { + var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* TypeFlags.Nullable */); + if (!keysRemapped && nonNullComponent.flags & 8388608 /* TypeFlags.IndexedAccess */ && nonNullComponent.indexType === typeParameter) { + if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -66476,7 +66707,7 @@ var ts; : typeParameter; var indexedAccessType = getIndexedAccessType(source, indexingType); // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type. - if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } @@ -66486,12 +66717,11 @@ var ts; } } } - else if (targetFlags & 16777216 /* Conditional */) { + else if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { - resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } var c = target; // We check for a relationship to a conditional type target only when the conditional type has no @@ -66502,47 +66732,44 @@ var ts; var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType)); // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) - if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) { - result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false); + if (result = skipTrue ? -1 /* Ternary.True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false)) { + result &= skipFalse ? -1 /* Ternary.True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (result) { - resetErrorInfo(saveErrorInfo); return result; } } } } - else if (targetFlags & 134217728 /* TemplateLiteral */) { - if (sourceFlags & 134217728 /* TemplateLiteral */) { + else if (targetFlags & 134217728 /* TypeFlags.TemplateLiteral */) { + if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */) { if (relation === comparableRelation) { - return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */; + return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* Ternary.False */ : -1 /* Ternary.True */; } // Report unreliable variance for type variables referenced in template literal type placeholders. // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + instantiateType(source, reportUnreliableMapper); } if (isTypeMatchedByTemplateLiteralType(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } - else if (target.flags & 268435456 /* StringMapping */) { - if (!(source.flags & 268435456 /* StringMapping */)) { + else if (target.flags & 268435456 /* TypeFlags.StringMapping */) { + if (!(source.flags & 268435456 /* TypeFlags.StringMapping */)) { if (isMemberOfStringMapping(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } } - if (sourceFlags & 8650752 /* TypeVariable */) { + if (sourceFlags & 8650752 /* TypeFlags.TypeVariable */) { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch - if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) { + if (!(sourceFlags & 8388608 /* TypeFlags.IndexedAccess */ && targetFlags & 8388608 /* TypeFlags.IndexedAccess */)) { var constraint = getConstraintOfType(source) || unknownType; // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* RecursionFlags.Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeFlags.TypeParameter */), /*headMessage*/ undefined, intersectionState)) { return result; } if (isMappedTypeGenericIndexedAccess(source)) { @@ -66550,55 +66777,49 @@ var ts; // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X. var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { - if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } } } } - else if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + else if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(keyofConstraintType, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } - else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) { - if (!(targetFlags & 134217728 /* TemplateLiteral */)) { + else if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */ && !(targetFlags & 524288 /* TypeFlags.Object */)) { + if (!(targetFlags & 134217728 /* TypeFlags.TemplateLiteral */)) { var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { - resetErrorInfo(saveErrorInfo); + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { return result; } } } - else if (sourceFlags & 268435456 /* StringMapping */) { - if (targetFlags & 268435456 /* StringMapping */) { + else if (sourceFlags & 268435456 /* TypeFlags.StringMapping */) { + if (targetFlags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol !== target.symbol) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } else { var constraint = getBaseConstraintOfType(source); - if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { - resetErrorInfo(saveErrorInfo); + if (constraint && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { return result; } } } - else if (sourceFlags & 16777216 /* Conditional */) { + else if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { - resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } - if (targetFlags & 16777216 /* Conditional */) { + if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -66607,18 +66828,17 @@ var ts; var mapper = void 0; if (sourceParams) { // If the source has infer type parameters, we instantiate them in the context of the target - var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* InferenceFlags.None */, isRelatedToWorker); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } if (isTypeIdenticalTo(sourceExtends, target.extendsType) && - (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) { - if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors); + (isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* RecursionFlags.Both */))) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -66628,8 +66848,7 @@ var ts; // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { - if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(distributiveConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } @@ -66638,8 +66857,7 @@ var ts; // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!). var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(defaultConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } @@ -66647,31 +66865,30 @@ var ts; else { // An empty object type is related to any mapped type that includes a '?' modifier. if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } - return 0 /* False */; + return 0 /* Ternary.False */; } - var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */); + var sourceIsPrimitive = !!(sourceFlags & 131068 /* TypeFlags.Primitive */); if (relation !== identityRelation) { source = getApparentType(source); sourceFlags = source.flags; } else if (isGenericMappedType(source)) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && source.target === target.target && !isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) { // When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType, // and an empty array literal wouldn't be assignable to a `never[]` without this check. if (isEmptyArrayLiteralType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance @@ -66681,7 +66898,7 @@ var ts; // effectively means we measure variance only from type parameter occurrences that aren't nested in // recursive instantiations of the generic type. if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState); if (varianceResult !== undefined) { @@ -66690,32 +66907,32 @@ var ts; } else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { - return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* RecursionFlags.Both */, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple // or `target` is an array and source is a tuple - in both cases the types cannot be identical, by construction - return 0 /* False */; + return 0 /* Ternary.False */; } } // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` // and not `{} <- fresh({}) <- {[idx: string]: any}` - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source)) { - return 0 /* False */; + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* ObjectFlags.FreshLiteral */ && !isEmptyObjectType(source)) { + return 0 /* Ternary.False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 524288 /* TypeFlags.Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState); if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 0 /* SignatureKind.Call */, reportStructuralErrors); if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 1 /* SignatureKind.Construct */, reportStructuralErrors); if (result) { result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState); } @@ -66732,9 +66949,9 @@ var ts; // there exists a constituent of T for every combination of the discriminants of S // with respect to T. We do not report errors here, as we will use the existing // error result from checking each constituent of the union. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) { - var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); - if (objectOnlyTarget.flags & 1048576 /* Union */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 1048576 /* TypeFlags.Union */) { + var objectOnlyTarget = extractTypesOfKind(target, 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 33554432 /* TypeFlags.Substitution */); + if (objectOnlyTarget.flags & 1048576 /* TypeFlags.Union */) { var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); if (result_9) { return result_9; @@ -66742,7 +66959,7 @@ var ts; } } } - return 0 /* False */; + return 0 /* Ternary.False */; function countMessageChainBreadth(info) { if (!info) return 0; @@ -66752,7 +66969,7 @@ var ts; if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; } - if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { + if (ts.some(variances, function (v) { return !!(v & 24 /* VarianceFlags.AllowsStructuralFallback */); })) { // If some type parameter was `Unmeasurable` or `Unreliable`, and we couldn't pass by assuming it was identical, then we // have to allow a structural fallback check // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially @@ -66779,8 +66996,8 @@ var ts; // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceMask */) === 0 /* Invariant */; }))) { - return 0 /* False */; + if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceFlags.VarianceMask */) === 0 /* VarianceFlags.Invariant */; }))) { + return 0 /* Ternary.False */; } // We remember the original error information so we can restore it in case the structural // comparison unexpectedly succeeds. This can happen when the structural comparison result @@ -66790,18 +67007,6 @@ var ts; } } } - function reportUnmeasurableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false); - } - return p; - } - function reportUnreliableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true); - } - return p; - } // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice // that S and T are contra-variant whereas X and Y are co-variant. @@ -66811,15 +67016,15 @@ var ts; if (modifiersRelated) { var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); - var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) { + var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMapper : reportUnreliableMapper); + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors); + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors); } } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToDiscriminatedType(source, target) { // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. @@ -66834,7 +67039,7 @@ var ts; var sourceProperties = getPropertiesOfType(source); var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); if (!sourcePropertiesFiltered) - return 0 /* False */; + return 0 /* Ternary.False */; // Though we could compute the number of combinations as we generate // the matrix, this would incur additional memory overhead due to // array allocations. To reduce this overhead, we first compute @@ -66846,8 +67051,8 @@ var ts; numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); - return 0 /* False */; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + return 0 /* Ternary.False */; } } // Compute the set of types for each discriminant property. @@ -66856,7 +67061,7 @@ var ts; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); - sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ + sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* TypeFlags.Union */ ? sourcePropertyType.types : [sourcePropertyType]; excludedProperties.add(sourceProperty.escapedName); @@ -66865,11 +67070,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_20 = function (combination) { + var _loop_21 = function (combination) { var hasMatch = false; outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) { var type = _d[_c]; - var _loop_21 = function (i) { + var _loop_22 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfType(type, sourceProperty.escapedName); if (!targetProperty) @@ -66877,7 +67082,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* IntersectionState.None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -66885,7 +67090,7 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_8 = _loop_21(i); + var state_8 = _loop_22(i); switch (state_8) { case "continue-outer": continue outer; } @@ -66894,30 +67099,30 @@ var ts; hasMatch = true; } if (!hasMatch) { - return { value: 0 /* False */ }; + return { value: 0 /* Ternary.False */ }; } }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_7 = _loop_20(combination); + var state_7 = _loop_21(combination); if (typeof state_7 === "object") return state_7.value; } // Compare the remaining non-discriminant properties of each match. - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* None */); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* IntersectionState.None */); if (result) { - result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 0 /* SignatureKind.Call */, /*reportStructuralErrors*/ false); if (result) { - result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 1 /* SignatureKind.Construct */, /*reportStructuralErrors*/ false); if (result && !(isTupleType(source) && isTupleType(type))) { // Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the // element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems // with index type assignability as the types for the excluded discriminants are still included // in the index type. - result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); + result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* IntersectionState.None */); } } } @@ -66944,40 +67149,40 @@ var ts; return result || properties; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { - var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */); var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); var effectiveSource = getTypeOfSourceProperty(sourceProp); - return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source)); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetPropFlags & 16 /* Protected */) { + else if (targetPropFlags & 16 /* ModifierFlags.Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (sourcePropFlags & 16 /* Protected */) { + else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Ensure {readonly a: whatever} is not a subtype of {a: whatever}, // while {a: whatever} is a subtype of {readonly a: whatever}. @@ -66987,7 +67192,7 @@ var ts; // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction if (relation === strictSubtypeRelation && isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // If the target comes from a partial union prop, allow `undefined` in the target type var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState); @@ -66995,10 +67200,10 @@ var ts; if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // When checking for comparability, be more lenient with optional properties. - if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { + if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -67009,7 +67214,7 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } return related; } @@ -67020,7 +67225,7 @@ var ts; && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) && source.symbol - && source.symbol.flags & 32 /* Class */) { + && source.symbol.flags & 32 /* SymbolFlags.Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) { @@ -67062,29 +67267,29 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (isTupleType(target)) { if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); - var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* Rest */ : 4 /* Rest */; - var targetRestFlag = target.target.combinedFlags & 4 /* Rest */; + var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */; + var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */; var sourceMinLength = isTupleType(source) ? source.target.minLength : 0; var targetMinLength = target.target.minLength; if (!sourceRestFlag && sourceArity < targetMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && targetArity < sourceMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { @@ -67095,38 +67300,38 @@ var ts; reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity); } } - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceTypeArguments = getTypeArguments(source); var targetTypeArguments = getTypeArguments(target); - var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* NonRest */) : 0, getStartElementCount(target.target, 11 /* NonRest */)); - var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* NonRest */) : 0); + var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */)); + var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0); var canExcludeDiscriminants = !!excludedProperties; for (var i = 0; i < targetArity; i++) { var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity; - var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* Rest */; + var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */; var targetFlags = target.target.elementFlags[i]; - if (targetFlags & 8 /* Variadic */ && !(sourceFlags & 8 /* Variadic */)) { + if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (sourceFlags & 8 /* Variadic */ && !(targetFlags & 12 /* Variable */)) { + if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) { if (reportErrors) { reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (targetFlags & 1 /* Required */ && !(sourceFlags & 1 /* Required */)) { + if (targetFlags & 1 /* ElementFlags.Required */ && !(sourceFlags & 1 /* ElementFlags.Required */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } // We can only exclude discriminant properties if we have not yet encountered a variable-length element. if (canExcludeDiscriminants) { - if (sourceFlags & 12 /* Variable */ || targetFlags & 12 /* Variable */) { + if (sourceFlags & 12 /* ElementFlags.Variable */ || targetFlags & 12 /* ElementFlags.Variable */) { canExcludeDiscriminants = false; } if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) { @@ -67134,12 +67339,12 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* ElementFlags.Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : - removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); - var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + var targetCheckType = sourceFlags & 8 /* ElementFlags.Variadic */ && targetFlags & 4 /* ElementFlags.Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* ElementFlags.Optional */)); + var related = isRelatedTo(sourceType, targetCheckType, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { @@ -67149,14 +67354,14 @@ var ts; reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i); } } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } - if (target.target.combinedFlags & 12 /* Variable */) { - return 0 /* False */; + if (target.target.combinedFlags & 12 /* ElementFlags.Variable */) { + return 0 /* Ternary.False */; } } var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); @@ -67165,18 +67370,18 @@ var ts; if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) { reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (isObjectLiteralType(target)) { for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) { var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType.flags & 32768 /* Undefined */)) { + if (!(sourceType.flags & 32768 /* TypeFlags.Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } } @@ -67188,12 +67393,12 @@ var ts; for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; var name = targetProp.escapedName; - if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { + if (!(targetProp.flags & 4194304 /* SymbolFlags.Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67202,24 +67407,24 @@ var ts; return result; } function propertiesIdenticalTo(source, target, excludedProperties) { - if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { - return 0 /* False */; + if (!(source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName); if (!targetProp) { - return 0 /* False */; + return 0 /* Ternary.False */; } var related = compareProperties(sourceProp, targetProp, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67231,17 +67436,17 @@ var ts; return signaturesIdenticalTo(source, target, kind); } if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; + return -1 /* Ternary.True */; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { - var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); - var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) { + var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */); + var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */); if (sourceIsAbstract && !targetIsAbstract) { // An abstract constructor type is not assignable to a non-abstract constructor type // as it would otherwise be possible to new an abstract class. Note that the assignability @@ -67250,18 +67455,18 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } - var result = -1 /* True */; - var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; + var result = -1 /* Ternary.True */; + var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; var sourceObjectFlags = ts.getObjectFlags(source); var targetObjectFlags = ts.getObjectFlags(target); - if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol || - sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) { + if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol || + sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters @@ -67269,7 +67474,7 @@ var ts; for (var i = 0; i < targetSignatures.length; i++) { var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67284,10 +67489,10 @@ var ts; var sourceSignature = ts.first(sourceSignatures); var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); - if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* Constructor */)) { + if (!result && reportErrors && kind === 1 /* SignatureKind.Construct */ && (sourceObjectFlags & targetObjectFlags) && + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* SyntaxKind.Constructor */)) { var constructSignatureToString = function (signature) { - return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); + return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */, kind); }; reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature)); reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible); @@ -67313,18 +67518,18 @@ var ts; if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } return result; } function shouldReportUnmatchedPropertyError(source, target) { - var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* Call */); - var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* Construct */); + var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* SignatureKind.Call */); + var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* SignatureKind.Construct */); var typeProperties = getPropertiesOfObjectType(source); if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) { - if ((getSignaturesOfType(target, 0 /* Call */).length && typeCallSignatures.length) || - (getSignaturesOfType(target, 1 /* Construct */).length && typeConstructSignatures.length)) { + if ((getSignaturesOfType(target, 0 /* SignatureKind.Call */).length && typeCallSignatures.length) || + (getSignaturesOfType(target, 1 /* SignatureKind.Construct */).length && typeConstructSignatures.length)) { return true; // target has similar signature kinds to source, still focus on the unmatched property } return false; @@ -67347,45 +67552,45 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* SignatureCheckMode.StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, reportUnreliableMapper); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } function membersRelatedToIndexInfo(source, targetInfo, reportErrors) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var keyType = targetInfo.keyType; - var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); + var props = source.flags & 2097152 /* TypeFlags.Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { var prop = props_2[_i]; // Skip over ignored JSX and symbol-named members if (isIgnoredJsxProperty(source, prop)) { continue; } - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), keyType)) { var propType = getNonMissingTypeOfSymbol(prop); - var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) + var type = exactOptionalPropertyTypes || propType.flags & 32768 /* TypeFlags.Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* SymbolFlags.Optional */) ? propType - : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors); + : getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */); + var related = isRelatedTo(type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67395,7 +67600,7 @@ var ts; if (isApplicableIndexType(info.keyType, keyType)) { var related = indexInfoRelatedTo(info, targetInfo, reportErrors); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67403,7 +67608,7 @@ var ts; return result; } function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { - var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors); + var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related && reportErrors) { if (sourceInfo.keyType === targetInfo.keyType) { reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); @@ -67420,14 +67625,14 @@ var ts; } var indexInfos = getIndexInfosOfType(target); var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; }); - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) { var targetInfo = indexInfos_5[_i]; - var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : - isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) : + var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* TypeFlags.Any */ ? -1 /* Ternary.True */ : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors) : typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67438,46 +67643,46 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } - if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) { + if (!(intersectionState & 1 /* IntersectionState.Source */) && isObjectTypeWithInferableIndex(source)) { // Intersection constituents are never considered to have an inferred index signature return membersRelatedToIndexInfo(source, targetInfo, reportErrors); } if (reportErrors) { reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } function indexSignaturesIdenticalTo(source, target) { var sourceInfos = getIndexInfosOfType(source); var targetInfos = getIndexInfosOfType(target); if (sourceInfos.length !== targetInfos.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) { var targetInfo = targetInfos_1[_i]; var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType); - if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { - return 0 /* False */; + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { + return 0 /* Ternary.False */; } } - return -1 /* True */; + return -1 /* Ternary.True */; } function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. - if (targetAccessibility === 8 /* Private */) { + if (targetAccessibility === 8 /* ModifierFlags.Private */) { return true; } // A public and protected signature is assignable to a protected signature. - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 16 /* ModifierFlags.Protected */ && sourceAccessibility !== 8 /* ModifierFlags.Private */) { return true; } // Only a public signature is assignable to public signature. - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 16 /* ModifierFlags.Protected */ && !sourceAccessibility) { return true; } if (reportErrors) { @@ -67490,19 +67695,19 @@ var ts; // Okay, yes, 'boolean' is a union of 'true | false', but that's not useful // in error reporting scenarios. If you need to use this function but that detail matters, // feel free to add a flag. - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return false; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getConstraintOfType(type); if (constraint && constraint !== type) { return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */); + return isUnitType(type) || !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */); } function getExactOptionalUnassignableProperties(source, target) { if (isTupleType(source) && isTupleType(target)) @@ -67511,7 +67716,7 @@ var ts; .filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); }); } function isExactOptionalPropertyMismatch(source, target) { - return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target); + return !!source && !!target && maybeTypeOfKind(source, 32768 /* TypeFlags.Undefined */) && !!containsMissingType(target); } function getExactOptionalProperties(type) { return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); }); @@ -67531,7 +67736,7 @@ var ts; for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; var targetProp = getUnionOrIntersectionProperty(target, propertyName); - if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) { + if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* CheckFlags.ReadPartial */) { continue; } var i = 0; @@ -67566,12 +67771,12 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && - resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); + resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* SymbolFlags.Optional */); }); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -67587,7 +67792,7 @@ var ts; } function getVariances(type) { // Arrays and tuples are known to be covariant, no need to spend time computing this. - return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */ ? + return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* ObjectFlags.Tuple */ ? arrayVariances : getVariancesWorker(type.symbol, type.typeParameters); } @@ -67603,14 +67808,14 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var links = getSymbolLinks(symbol); if (!links.variances) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; - var _loop_22 = function (tp) { + var _loop_23 = function (tp) { var modifiers = getVarianceModifiers(tp); - var variance = modifiers & 65536 /* Out */ ? - modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : - modifiers & 32768 /* In */ ? 2 /* Contravariant */ : undefined; + var variance = modifiers & 65536 /* ModifierFlags.Out */ ? + modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ : + modifiers & 32768 /* ModifierFlags.In */ ? 2 /* VarianceFlags.Contravariant */ : undefined; if (variance === undefined) { var unmeasurable_1 = false; var unreliable_1 = false; @@ -67621,33 +67826,33 @@ var ts; // invariance, covariance, contravariance or bivariance. var typeWithSuper = createMarkerType(symbol, tp, markerSuperType); var typeWithSub = createMarkerType(symbol, tp, markerSubType); - variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* Covariant */ : 0) | - (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* Contravariant */ : 0); + variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* VarianceFlags.Covariant */ : 0) | + (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* VarianceFlags.Contravariant */ : 0); // If the instantiations appear to be related bivariantly it may be because the // type parameter is independent (i.e. it isn't witnessed anywhere in the generic // type). To determine this we compare instantiations where the type parameter is // replaced with marker types that are known to be unrelated. - if (variance === 3 /* Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; + if (variance === 3 /* VarianceFlags.Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { + variance = 4 /* VarianceFlags.Independent */; } outofbandVarianceMarkerHandler = oldHandler; if (unmeasurable_1 || unreliable_1) { if (unmeasurable_1) { - variance |= 8 /* Unmeasurable */; + variance |= 8 /* VarianceFlags.Unmeasurable */; } if (unreliable_1) { - variance |= 16 /* Unreliable */; + variance |= 16 /* VarianceFlags.Unreliable */; } } } variances.push(variance); }; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - _loop_22(tp); + for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { + var tp = typeParameters_2[_i]; + _loop_23(tp); } links.variances = variances; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) }); } return links.variances; } @@ -67657,7 +67862,7 @@ var ts; if (isErrorType(type)) { return type; } - var result = symbol.flags & 524288 /* TypeAlias */ ? + var result = symbol.flags & 524288 /* SymbolFlags.TypeAlias */ ? getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) : createTypeReference(type, instantiateTypes(type.typeParameters, mapper)); markerTypes.add(getTypeId(result)); @@ -67668,34 +67873,34 @@ var ts; } function getVarianceModifiers(tp) { var _a, _b; - return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* In */); }) ? 32768 /* In */ : 0) | - (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* Out */); }) ? 65536 /* Out */ : 0); + return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* ModifierFlags.In */); }) ? 32768 /* ModifierFlags.In */ : 0) | + (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* ModifierFlags.Out */); }) ? 65536 /* ModifierFlags.Out */ : 0); } // Return true if the given type reference has a 'void' type argument for a covariant type parameter. // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(typeArguments, variances) { for (var i = 0; i < variances.length; i++) { - if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) { + if ((variances[i] & 7 /* VarianceFlags.VarianceMask */) === 1 /* VarianceFlags.Covariant */ && typeArguments[i].flags & 16384 /* TypeFlags.Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeFlags.TypeParameter */ && !getConstraintOfTypeParameter(type); } function isNonDeferredTypeReference(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeFlags.TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) { var typeParameters = []; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); // getTypeReferenceId(A) returns "111=0-12=1" // where A.id=111 and number.id=12 function getTypeReferenceId(type, depth) { @@ -67703,7 +67908,7 @@ var ts; var result = "" + type.target.id; for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { if (ignoreConstraints || isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); if (index < 0) { @@ -67739,12 +67944,12 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (ts.getCheckFlags(prop) & 6 /* Synthetic */) { + if (ts.getCheckFlags(prop) & 6 /* CheckFlags.Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.escapedName); @@ -67759,7 +67964,7 @@ var ts; } // Return the declaring class type of a property or undefined if property not declared in class function getDeclaringClass(prop) { - return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + return prop.parent && prop.parent.flags & 32 /* SymbolFlags.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) { @@ -67777,13 +67982,13 @@ var ts; } // Return true if source property is a valid override of protected parts of target property. function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* ModifierFlags.Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); } // Return true if the given class derives from each of the declaring classes of the protected // constituents of the given property. function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* ModifierFlags.Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons @@ -67829,14 +68034,14 @@ var ts; // reference the type have a recursion identity that differs from the object identity. function getRecursionIdentity(type) { // Object and array literals are known not to contain recursive references and don't need a recursion identity. - if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { - if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { + if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) { + if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) { // Deferred type references are tracked through their associated AST node. This gives us finer // granularity than using their associated target because each manifest type reference has a // unique AST node. return type.node; } - if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) { // We track all object types that have an associated symbol (representing the origin of the type), but // exclude the static side of classes from this check since it shares its symbol with the instance side. return type.symbol; @@ -67846,49 +68051,49 @@ var ts; return type.target; } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { return type.symbol; } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { type = type.objectType; - } while (type.flags & 8388608 /* IndexedAccess */); + } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */); return type; } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { // The root object represents the origin of the conditional type return type.root; } return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; + return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */; } function compareProperties(sourceProp, targetProp, compareTypes) { // Two members are considered identical when // - they are public properties with identical names, optionality, and types, // - they are private or protected properties originating in the same declaration and having identical types if (sourceProp === targetProp) { - return -1 /* True */; + return -1 /* Ternary.True */; } - var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; + var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (sourcePropAccessibility) { if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } else { - if ((sourceProp.flags & 16777216 /* Optional */) !== (targetProp.flags & 16777216 /* Optional */)) { - return 0 /* False */; + if ((sourceProp.flags & 16777216 /* SymbolFlags.Optional */) !== (targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { + return 0 /* Ternary.False */; } } if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -67919,14 +68124,14 @@ var ts; function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!(isMatchingSignature(source, target, partialMatch))) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that the two signatures have the same number of type parameters. if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that type parameter constraints and defaults match. If they do, instantiate the source // signature with the type parameters of the target signature and continue the comparison. @@ -67937,12 +68142,12 @@ var ts; var t = target.typeParameters[i]; if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) { - return 0 /* False */; + return 0 /* Ternary.False */; } } source = instantiateSignature(source, mapper, /*eraseTypeParameters*/ true); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (!ignoreThisTypes) { var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType) { @@ -67950,7 +68155,7 @@ var ts; if (targetThisType) { var related = compareTypes(sourceThisType, targetThisType); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67962,7 +68167,7 @@ var ts; var t = getTypeAtPosition(target, i); var related = compareTypes(t, s); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67976,56 +68181,52 @@ var ts; return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : - source.type === target.type ? -1 /* True */ : + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* Ternary.False */ : + source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + 0 /* Ternary.False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - var baseType = getBaseTypeOfLiteralType(t); - if (!commonBaseType) { - commonBaseType = baseType; - } - if (baseType === t || baseType !== commonBaseType) { - return false; + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + var baseType = getBaseTypeOfLiteralType(t); + commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType); + if (baseType === t || baseType !== commonBaseType) { + return false; + } } } return true; } - // When the candidate types are all literal types with the same base type, return a union - // of those literal types. Otherwise, return the leftmost type for which no type to the - // right is a supertype. - function getSupertypeOrUnion(types) { - if (types.length === 1) { - return types[0]; - } - return literalTypesWithSameBaseType(types) ? - getUnionType(types) : - ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + function getCombinedTypeFlags(types) { + return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 /* TypeFlags.Union */ ? getCombinedTypeFlags(t.types) : t.flags); }, 0); } function getCommonSupertype(types) { - if (!strictNullChecks) { - return getSupertypeOrUnion(types); - } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (primaryTypes.length) { - var supertypeOrUnion = getSupertypeOrUnion(primaryTypes); - return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true)); + if (types.length === 1) { + return types[0]; } - return getUnionType(types, 2 /* Subtype */); + // Remove nullable types from each of the candidates. + var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304 /* TypeFlags.Nullable */); }); }) : types; + // When the candidate types are all literal types with the same base type, return a union + // of those literal types. Otherwise, return the leftmost type for which no type to the + // right is a supertype. + var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? + getUnionType(primaryTypes) : + ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + // Add any nullable types that occurred in the candidates back to the result. + return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* TypeFlags.Nullable */); } // Return the leftmost type for which no type to the right is a subtype. function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); } function isReadonlyArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && type.target === globalReadonlyArrayType; } function isArrayOrTupleType(type) { return isArrayType(type) || isTupleType(type); @@ -68039,22 +68240,22 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || !(type.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function getSingleBaseForNonAugmentingSubtype(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ObjectFlags.ClassOrInterface */)) { return undefined; } - if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { - return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + if (ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* ObjectFlags.IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; } - type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + type.objectFlags |= 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */; var target = type.target; - if (ts.getObjectFlags(target) & 1 /* Class */) { + if (ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { var baseTypeNode = getBaseTypeNodeOfClass(target); // A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only // check for base types specified as simple qualified names. - if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 206 /* PropertyAccessExpression */) { + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* SyntaxKind.Identifier */ && baseTypeNode.expression.kind !== 206 /* SyntaxKind.PropertyAccessExpression */) { return undefined; } } @@ -68069,7 +68270,7 @@ var ts; if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); } - type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + type.objectFlags |= 67108864 /* ObjectFlags.IdenticalBaseTypeExists */; return type.cachedEquivalentBaseType = instantiatedBase; } function isEmptyLiteralType(type) { @@ -68096,44 +68297,49 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); + return !(type.flags & (109440 /* TypeFlags.Unit */ | 131072 /* TypeFlags.Never */)); } function isUnitType(type) { - return !!(type.flags & 109440 /* Unit */); + return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : - !!(type.flags & 109440 /* Unit */); + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* TypeFlags.Unit */); } function extractUnitType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type; + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; } function isLiteralType(type) { - return type.flags & 16 /* Boolean */ ? true : - type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + return type.flags & 16 /* TypeFlags.Boolean */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? type.flags & 1024 /* TypeFlags.EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 512 /* BooleanLiteral */ ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? getBaseTypeOfLiteralTypeUnion(type) : type; } + function getBaseTypeOfLiteralTypeUnion(type) { + var _a; + var key = "B".concat(getTypeId(type)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType)); + } function getWidenedLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : - type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : - type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : - type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* TypeFlags.StringLiteral */ && isFreshLiteralType(type) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ && isFreshLiteralType(type) ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedLiteralType) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -68164,10 +68370,10 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required. */ function isTupleType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target.objectFlags & 8 /* ObjectFlags.Tuple */); } function isGenericTupleType(type) { - return isTupleType(type) && !!(type.target.combinedFlags & 8 /* Variadic */); + return isTupleType(type) && !!(type.target.combinedFlags & 8 /* ElementFlags.Variadic */); } function isSingleElementGenericTupleType(type) { return isGenericTupleType(type) && type.target.elementFlags.length === 1; @@ -68188,7 +68394,7 @@ var ts; var elementTypes = []; for (var i = index; i < length; i++) { var t = typeArguments[i]; - elementTypes.push(type.target.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t); + elementTypes.push(type.target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t); } return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes); } @@ -68196,28 +68402,28 @@ var ts; } function isTupleTypeStructureMatching(t1, t2) { return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && - ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */); }); + ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* ElementFlags.Variable */) === (t2.target.elementFlags[i] & 12 /* ElementFlags.Variable */); }); } function isZeroBigInt(_a) { var value = _a.value; return value.base10Value === "0"; } function removeDefinitelyFalsyTypes(type) { - return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* Truthy */); }); + return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* TypeFacts.Truthy */); }); } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 4 /* String */ ? emptyStringType : - type.flags & 8 /* Number */ ? zeroType : - type.flags & 64 /* BigInt */ ? zeroBigIntType : + return type.flags & 4 /* TypeFlags.String */ ? emptyStringType : + type.flags & 8 /* TypeFlags.Number */ ? zeroType : + type.flags & 64 /* TypeFlags.BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || - type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || - type.flags & 128 /* StringLiteral */ && type.value === "" || - type.flags & 256 /* NumberLiteral */ && type.value === 0 || - type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + type.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */ | 3 /* TypeFlags.AnyOrUnknown */) || + type.flags & 128 /* TypeFlags.StringLiteral */ && type.value === "" || + type.flags & 256 /* TypeFlags.NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isZeroBigInt(type) ? type : neverType; } /** @@ -68226,27 +68432,27 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */); return missing === 0 ? type : - missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 65536 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* TypeFlags.Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* TypeFlags.Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type, isProperty) { if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); + return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { - deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; + deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* SymbolFlags.TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) : getIntersectionType([type, emptyObjectType]); } function getNonNullableType(type) { - return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function addOptionalTypeMarker(type) { return strictNullChecks ? getUnionType([type, optionalType]) : type; @@ -68266,10 +68472,10 @@ var ts; return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type; } function containsMissingType(type) { - return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, missingType)); } function removeMissingOrUndefinedType(type) { - return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */); + return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */); } /** * Is source potentially coercible to target type under `==`. @@ -68292,8 +68498,8 @@ var ts; * @param target */ function isCoercibleUnderDoubleEquals(source, target) { - return ((source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0) - && ((target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0); + return ((source.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 512 /* TypeFlags.BooleanLiteral */)) !== 0) + && ((target.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 16 /* TypeFlags.Boolean */)) !== 0); } /** * Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module @@ -68301,15 +68507,15 @@ var ts; */ function isObjectTypeWithInferableIndex(type) { var objectFlags = ts.getObjectFlags(type); - return type.flags & 2097152 /* Intersection */ + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol - && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 - && !(type.symbol.flags & 32 /* Class */) - && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + && (type.symbol.flags & (4096 /* SymbolFlags.ObjectLiteral */ | 2048 /* SymbolFlags.TypeLiteral */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !== 0 + && !(type.symbol.flags & 32 /* SymbolFlags.Class */) + && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectFlags.ObjectRestType */) || !!(objectFlags & 1024 /* ObjectFlags.ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { - var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); + var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* CheckFlags.Readonly */); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -68339,7 +68545,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* ObjectFlags.FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -68350,7 +68556,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~8192 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~8192 /* ObjectFlags.FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -68380,7 +68586,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) { var t = _a[_i]; - if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ObjectFlags.ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -68392,7 +68598,7 @@ var ts; return context.resolvedProperties; } function getWidenedProperty(prop, context) { - if (!(prop.flags & 4 /* Property */)) { + if (!(prop.flags & 4 /* SymbolFlags.Property */)) { // Since get accessors already widen their return value there is no need to // widen accessor based properties here. return prop; @@ -68408,7 +68614,7 @@ var ts; return cached; } var result = createSymbolWithType(prop, missingType); - result.flags |= 16777216 /* Optional */; + result.flags |= 16777216 /* SymbolFlags.Optional */; undefinedProperties.set(prop.escapedName, result); return result; } @@ -68427,33 +68633,33 @@ var ts; } } var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); })); - result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* JSLiteral */ | 262144 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */)); // Retain js literal flag through widening return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 196608 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } var result = void 0; - if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) { + if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) { result = anyType; } else if (isObjectLiteralType(type)) { result = getWidenedTypeOfObjectLiteral(type, context); } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayOrTupleType(type)) { @@ -68479,8 +68685,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 65536 /* ContainsWideningType */) { - if (type.flags & 1048576 /* Union */) { + if (ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -68505,7 +68711,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (ts.getObjectFlags(t) & 65536 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 65536 /* ObjectFlags.ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -68524,17 +68730,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 221 /* BinaryExpression */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 221 /* SyntaxKind.BinaryExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* SymbolFlags.Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : ""); @@ -68545,25 +68751,25 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (noImplicitAny && !declaration.name) { - if (wideningKind === 3 /* GeneratorYield */) { + if (wideningKind === 3 /* WideningKind.GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); } else { @@ -68572,10 +68778,10 @@ var ts; return; } diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage : - wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : + wideningKind === 3 /* WideningKind.GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -68587,7 +68793,7 @@ var ts; } function reportErrorsFromWidening(declaration, type, wideningKind) { addLazyDiagnostic(function () { - if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -68639,27 +68845,29 @@ var ts; signature: signature, flags: flags, compareTypes: compareTypes, - mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ true); }), - nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ false); }), + mapper: reportUnmeasurableMapper, + nonFixingMapper: reportUnmeasurableMapper, }; + context.mapper = makeFixingMapperForContext(context); + context.nonFixingMapper = makeNonFixingMapperForContext(context); return context; } - function mapToInferredType(context, t, fix) { - var inferences = context.inferences; - for (var i = 0; i < inferences.length; i++) { - var inference = inferences[i]; - if (t === inference.typeParameter) { - if (fix && !inference.isFixed) { - // Before we commit to a particular inference (and thus lock out any further inferences), - // we infer from any intra-expression inference sites we have collected. - inferFromIntraExpressionSites(context); - clearCachedInferences(inferences); - inference.isFixed = true; - } - return getInferredType(context, i); + function makeFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (inference, i) { return function () { + if (!inference.isFixed) { + // Before we commit to a particular inference (and thus lock out any further inferences), + // we infer from any intra-expression inference sites we have collected. + inferFromIntraExpressionSites(context); + clearCachedInferences(context.inferences); + inference.isFixed = true; } - } - return t; + return getInferredType(context, i); + }; })); + } + function makeNonFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (_, i) { return function () { + return getInferredType(context, i); + }; })); } function clearCachedInferences(inferences) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { @@ -68690,9 +68898,9 @@ var ts; if (context.intraExpressionInferenceSites) { for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) { var _b = _a[_i], node = _b.node, type = _b.type; - var contextualType = node.kind === 169 /* MethodDeclaration */ ? - getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : - getContextualType(node, 2 /* NoConstraints */); + var contextualType = node.kind === 169 /* SyntaxKind.MethodDeclaration */ ? + getContextualTypeForObjectLiteralMethod(node, 2 /* ContextFlags.NoConstraints */) : + getContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { inferTypes(context.inferences, type, contextualType); } @@ -68738,40 +68946,40 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 1048576 /* CouldContainTypeVariables */); + if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */); } - var result = !!(type.flags & 465829888 /* Instantiable */ || - 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 */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); - if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0); + var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ || + type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); + if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) { + type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SourceFile */ ? true : n.kind === 261 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SyntaxKind.SourceFile */ ? true : n.kind === 261 /* SyntaxKind.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); }) || - type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || + type.flags & 16777216 /* TypeFlags.Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 128 /* StringLiteral */)) { + if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); - var literalProp = createSymbol(4 /* Property */, name); + var literalProp = createSymbol(4 /* SymbolFlags.Property */, name); literalProp.type = anyType; if (t.symbol) { literalProp.declarations = t.symbol.declarations; @@ -68779,7 +68987,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; + var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos); } /** @@ -68807,7 +69015,7 @@ var ts; // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 262144 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 262144 /* ObjectFlags.NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -68824,14 +69032,14 @@ var ts; } if (isTupleType(source)) { var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); - var elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? - ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var elementFlags = getMappedTypeModifiers(target) & 4 /* MappedTypeModifiers.IncludeOptional */ ? + ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : source.target.elementFlags; return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations); } // For all other object types we infer a new object type where the reverse mapping has been // applied to the type of each property. - var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ObjectFlags.ReverseMapped */ | 16 /* ObjectFlags.Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; @@ -68866,7 +69074,7 @@ var ts; if (isStaticPrivateIdentifierProperty(targetProp)) { return [3 /*break*/, 5]; } - if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */))) return [3 /*break*/, 5]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */))) return [3 /*break*/, 5]; sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!!sourceProp) return [3 /*break*/, 3]; return [4 /*yield*/, targetProp]; @@ -68876,9 +69084,9 @@ var ts; case 3: if (!matchDiscriminantProperties) return [3 /*break*/, 5]; targetType = getTypeOfSymbol(targetProp); - if (!(targetType.flags & 109440 /* Unit */)) return [3 /*break*/, 5]; + if (!(targetType.flags & 109440 /* TypeFlags.Unit */)) return [3 /*break*/, 5]; sourceType = getTypeOfSymbol(sourceProp); - if (!!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; + if (!!(sourceType.flags & 1 /* TypeFlags.Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; return [4 /*yield*/, targetProp]; case 4: _a.sent(); @@ -68896,7 +69104,7 @@ var ts; return result.value; } function tupleTypesDefinitelyUnrelated(source, target) { - return !(target.target.combinedFlags & 8 /* Variadic */) && target.target.minLength > source.target.minLength || + return !(target.target.combinedFlags & 8 /* ElementFlags.Variadic */) && target.target.minLength > source.target.minLength || !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength); } function typesDefinitelyUnrelated(source, target) { @@ -68907,7 +69115,7 @@ var ts; !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false); } function getTypeFromInference(inference) { - return inference.candidates ? getUnionType(inference.candidates, 2 /* Subtype */) : + return inference.candidates ? getUnionType(inference.candidates, 2 /* UnionReduction.Subtype */) : inference.contraCandidates ? getIntersectionType(inference.contraCandidates) : undefined; } @@ -68944,7 +69152,7 @@ var ts; */ function parseBigIntLiteralType(text) { var negative = text.startsWith("-"); - var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n"); + var base10Value = ts.parsePseudoBigInt("".concat(negative ? text.slice(1) : text, "n")); return getBigIntLiteralType({ negative: negative, base10Value: base10Value }); } /** @@ -68955,12 +69163,12 @@ var ts; function isValidBigIntString(s, roundTripOnly) { if (s === "") return false; - var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.ESNext */, /*skipTrivia*/ false); var success = true; scanner.setOnError(function () { return success = false; }); scanner.setText(s + "n"); var result = scanner.scan(); - var negative = result === 40 /* MinusToken */; + var negative = result === 40 /* SyntaxKind.MinusToken */; if (negative) { result = scanner.scan(); } @@ -68970,17 +69178,17 @@ var ts; // * a bigint can be scanned, and that when it is scanned, it is // * the full length of the input string (so the scanner is one character beyond the augmented input length) // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) - return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */) + return success && result === 9 /* SyntaxKind.BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* TokenFlags.ContainsSeparator */) && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) })); } function isMemberOfStringMapping(source, target) { - if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) { + if (target.flags & (4 /* TypeFlags.String */ | 3 /* TypeFlags.AnyOrUnknown */)) { return true; } - if (target.flags & 134217728 /* TemplateLiteral */) { + if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { return isTypeAssignableTo(source, target); } - if (target.flags & 268435456 /* StringMapping */) { + if (target.flags & 268435456 /* TypeFlags.StringMapping */) { // We need to see whether applying the same mappings of the target // onto the source would produce an identical type *and* that // it's compatible with the inner-most non-string-mapped type. @@ -68989,7 +69197,7 @@ var ts; // and the source is compatible with the unmapped target, then they must // still reside in the same domain. var mappingStack = []; - while (target.flags & 268435456 /* StringMapping */) { + while (target.flags & 268435456 /* TypeFlags.StringMapping */) { mappingStack.unshift(target.symbol); target = target.type; } @@ -68999,25 +69207,25 @@ var ts; return false; } function isValidTypeForTemplateLiteralPlaceholder(source, target) { - if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + if (source === target || target.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)) { return true; } - if (source.flags & 128 /* StringLiteral */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */) { var value = source.value; - return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) || - target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) || - target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName || - target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target)); + return !!(target.flags & 8 /* TypeFlags.Number */ && isValidNumberString(value, /*roundTripOnly*/ false) || + target.flags & 64 /* TypeFlags.BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) || + target.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) && value === target.intrinsicName || + target.flags & 268435456 /* TypeFlags.StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target)); } - if (source.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts = source.texts; return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target); } return isTypeAssignableTo(source, target); } function inferTypesFromTemplateLiteralType(source, target) { - return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : - source.flags & 134217728 /* TemplateLiteral */ ? + return source.flags & 128 /* TypeFlags.StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : undefined; @@ -69027,7 +69235,7 @@ var ts; return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); }); } function getStringLikeTypeForType(type) { - return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); + return type.flags & (1 /* TypeFlags.Any */ | 402653316 /* TypeFlags.StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); } // This function infers from the text parts and type parts of a source literal to a target template literal. The number // of text parts is always one more than the number of type parts, and a source string literal is treated as a source @@ -69109,12 +69317,12 @@ var ts; if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 2048 /* MaxValue */; + var inferencePriority = 2048 /* InferencePriority.MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; var targetStack; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { if (!couldContainTypeVariables(target)) { @@ -69130,13 +69338,16 @@ var ts; propagationType = savePropagationType; return; } - if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - // Source and target are types originating in the same generic type alias declaration. - // Simply infer from source type arguments to target type arguments. - inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) { + if (source.aliasTypeArguments) { + // Source and target are types originating in the same generic type alias declaration. + // Simply infer from source type arguments to target type arguments. + inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + } + // And if there weren't any type arguments, there's no reason to run inference as the types must be the same. return; } - if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + if (source === target && source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { // When source and target are the same union or intersection type, just relate each constituent // type to itself. for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -69145,10 +69356,10 @@ var ts; } return; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { // First, infer between identically matching source and target constituents and remove the // matching types. - var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _b = inferFromMatchingTypes(source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; // Next, infer between closely matching source and target constituents and remove // the matching types. Types closely match when they are instantiations of the same // object type or instantiations of the same type alias. @@ -69163,21 +69374,21 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - inferWithPriority(source, target, 1 /* NakedTypeVariable */); + inferWithPriority(source, target, 1 /* InferencePriority.NakedTypeVariable */); return; } source = getUnionType(sources); } - else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + else if (target.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { // We reduce intersection types only when they contain naked type parameters. For example, when // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the // string[] on the source side and infer string for T. // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" // in such scenarios. - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { // Infer between identically matching source and target constituents and remove the matching types. - var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + var _d = inferFromMatchingTypes(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; if (sources.length === 0 || targets.length === 0) { return; } @@ -69185,23 +69396,31 @@ var ts; target = getIntersectionType(targets); } } - else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { + else if (target.flags & (8388608 /* TypeFlags.IndexedAccess */ | 33554432 /* TypeFlags.Substitution */)) { target = getActualTypeVariable(target); } - if (target.flags & 8650752 /* TypeVariable */) { - // If target is a type parameter, make an inference, unless the source type contains - // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). - // Because the anyFunctionType is internal, it should not be exposed to the user by adding - // it as an inference candidate. Hopefully, a better candidate will come along that does - // not contain anyFunctionType when we come back to this argument for its second round - // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard - // when constructing types from type parameters that had no inference candidates). - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (target.flags & 8650752 /* TypeFlags.TypeVariable */) { + // Skip inference if the source is "blocked", which is used by the language service to + // prevent inference on nodes currently being edited. + if (isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); if (inference) { - if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) { + // If target is a type parameter, make an inference, unless the source type contains + // a "non-inferrable" type. Types with this flag set are markers used to prevent inference. + // + // For example: + // - anyFunctionType is a wildcard type that's used to avoid contextually typing functions; + // it's internal, so should not be exposed to the user by adding it as a candidate. + // - autoType (and autoArrayType) is a special "any" used in control flow; like anyFunctionType, + // it's internal and should not be observable. + // - silentNeverType is returned by getInferredType when instantiating a generic function for + // inference (and a type variable has no mapping). + // + // This flag is infectious; if we produce Box (where never is silentNeverType), Box is + // also non-inferrable. + if (ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */) { return; } if (!inference.isFixed) { @@ -69226,7 +69445,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* InferencePriority.ReturnType */) && target.flags & 262144 /* TypeFlags.TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -69239,11 +69458,11 @@ var ts; if (simplified !== target) { inferFromTypes(source, simplified); } - else if (target.flags & 8388608 /* IndexedAccess */) { + else if (target.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexType = getSimplifiedType(target.indexType, /*writing*/ false); // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can. - if (indexType.flags & 465829888 /* Instantiable */) { + if (indexType.flags & 465829888 /* TypeFlags.Instantiable */) { var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false); if (simplified_1 && simplified_1 !== target) { inferFromTypes(source, simplified_1); @@ -69251,45 +69470,38 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } - else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { - contravariant = !contravariant; - inferFromTypes(source.type, target.type); - contravariant = !contravariant; + else if (source.flags & 4194304 /* TypeFlags.Index */ && target.flags & 4194304 /* TypeFlags.Index */) { + inferFromContravariantTypes(source.type, target.type); } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* TypeFlags.String */) && target.flags & 4194304 /* TypeFlags.Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); - contravariant = !contravariant; - inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); - contravariant = !contravariant; + inferFromContravariantTypesWithPriority(empty, target.type, 256 /* InferencePriority.LiteralKeyof */); } - else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { + else if (source.flags & 8388608 /* TypeFlags.IndexedAccess */ && target.flags & 8388608 /* TypeFlags.IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) { + else if (source.flags & 268435456 /* TypeFlags.StringMapping */ && target.flags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol === target.symbol) { inferFromTypes(source.type, target.type); } } - else if (source.flags & 33554432 /* Substitution */) { + else if (source.flags & 33554432 /* TypeFlags.Substitution */) { inferFromTypes(source.baseType, target); - var oldPriority = priority; - priority |= 4 /* SubstituteSource */; - inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority - priority = oldPriority; + inferWithPriority(source.substitute, target, 4 /* InferencePriority.SubstituteSource */); // Make substitute inference at a lower priority } - else if (target.flags & 16777216 /* Conditional */) { + else if (target.flags & 16777216 /* TypeFlags.Conditional */) { invokeOnce(source, target, inferToConditionalType); } - else if (target.flags & 3145728 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } - else if (source.flags & 1048576 /* Union */) { + else if (source.flags & 1048576 /* TypeFlags.Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) { @@ -69297,17 +69509,17 @@ var ts; inferFromTypes(sourceType, target); } } - else if (target.flags & 134217728 /* TemplateLiteral */) { + else if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { inferToTemplateLiteralType(source, target); } else { source = getReducedType(source); - if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* InferencePriority.NoConstraints */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` // with the simplified source. - if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */))) { // TODO: The `allowComplexConstraintInference` flag is a hack! This forbids inference from complex constraints within constraints! // This isn't required algorithmically, but rather is used to lower the memory burden caused by performing inference // that is _too good_ in projects with complicated constraints (eg, fp-ts). In such cases, if we did not limit ourselves @@ -69320,7 +69532,7 @@ var ts; } source = apparentSource; } - if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { invokeOnce(source, target, inferFromObjectTypes); } } @@ -69331,6 +69543,18 @@ var ts; inferFromTypes(source, target); priority = savePriority; } + function inferFromContravariantTypesWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromContravariantTypes(source, target); + priority = savePriority; + } + function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferToMultipleTypes(source, targets, targetFlags); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -69338,19 +69562,19 @@ var ts; inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); + (visited || (visited = new ts.Map())).set(key, -1 /* InferencePriority.Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. var saveExpandingFlags = expandingFlags; var sourceIdentity = getRecursionIdentity(source); var targetIdentity = getRecursionIdentity(target); if (ts.contains(sourceStack, sourceIdentity)) - expandingFlags |= 1 /* Source */; + expandingFlags |= 1 /* ExpandingFlags.Source */; if (ts.contains(targetStack, targetIdentity)) - expandingFlags |= 2 /* Target */; - if (expandingFlags !== 3 /* Both */) { + expandingFlags |= 2 /* ExpandingFlags.Target */; + if (expandingFlags !== 3 /* ExpandingFlags.Both */) { (sourceStack || (sourceStack = [])).push(sourceIdentity); (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); @@ -69358,7 +69582,7 @@ var ts; sourceStack.pop(); } else { - inferencePriority = -1 /* Circularity */; + inferencePriority = -1 /* InferencePriority.Circularity */; } expandingFlags = saveExpandingFlags; visited.set(key, inferencePriority); @@ -69386,7 +69610,7 @@ var ts; function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; for (var i = 0; i < count; i++) { - if (i < variances.length && (variances[i] & 7 /* VarianceMask */) === 2 /* Contravariant */) { + if (i < variances.length && (variances[i] & 7 /* VarianceFlags.VarianceMask */) === 2 /* VarianceFlags.Contravariant */) { inferFromContravariantTypes(sourceTypes[i], targetTypes[i]); } else { @@ -69395,17 +69619,20 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { - contravariant = !contravariant; - inferFromTypes(source, target); - contravariant = !contravariant; + contravariant = !contravariant; + inferFromTypes(source, target); + contravariant = !contravariant; + } + function inferFromContravariantTypesIfStrictFunctionTypes(source, target) { + if (strictFunctionTypes || priority & 1024 /* InferencePriority.AlwaysStrict */) { + inferFromContravariantTypes(source, target); } else { inferFromTypes(source, target); } } function getInferenceInfoForType(type) { - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) { var inference = inferences_2[_i]; if (type === inference.typeParameter) { @@ -69419,7 +69646,7 @@ var ts; var typeVariable; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var type = types_14[_i]; - var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + var t = type.flags & 2097152 /* TypeFlags.Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; } @@ -69429,9 +69656,9 @@ var ts; } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; - if (targetFlags & 1048576 /* Union */) { + if (targetFlags & 1048576 /* TypeFlags.Union */) { var nakedTypeVariable = void 0; - var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; + var sources = source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we @@ -69447,11 +69674,11 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; - inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* InferencePriority.Circularity */; inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } @@ -69462,7 +69689,7 @@ var ts; // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); if (intersectionTypeVariable) { - inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + inferWithPriority(source, intersectionTypeVariable, 1 /* InferencePriority.NakedTypeVariable */); } return; } @@ -69496,17 +69723,17 @@ var ts; // less specific. For example, when inferring from Promise to T | Promise, // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. - if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { + if (targetFlags & 2097152 /* TypeFlags.Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferWithPriority(source, t, 1 /* NakedTypeVariable */); + inferWithPriority(source, t, 1 /* InferencePriority.NakedTypeVariable */); } } } } function inferToMappedType(source, target, constraintType) { - if (constraintType.flags & 1048576 /* Union */) { + if (constraintType.flags & 1048576 /* TypeFlags.Union */) { var result = false; for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { var type = _a[_i]; @@ -69514,7 +69741,7 @@ var ts; } return result; } - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -69526,17 +69753,17 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* NonInferrableType */ ? - 16 /* PartialHomomorphicMappedType */ : - 8 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */ ? + 16 /* InferencePriority.PartialHomomorphicMappedType */ : + 8 /* InferencePriority.HomomorphicMappedType */); } } return true; } - if (constraintType.flags & 262144 /* TypeParameter */) { + if (constraintType.flags & 262144 /* TypeFlags.TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* InferencePriority.MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -69555,18 +69782,15 @@ var ts; return false; } function inferToConditionalType(source, target) { - if (source.flags & 16777216 /* Conditional */) { + if (source.flags & 16777216 /* TypeFlags.Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } else { - var savePriority = priority; - priority |= contravariant ? 64 /* ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; - inferToMultipleTypes(source, targetTypes, target.flags); - priority = savePriority; + inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 /* InferencePriority.ContravariantConditional */ : 0); } } function inferToTemplateLiteralType(source, target) { @@ -69579,47 +69803,47 @@ var ts; // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might // succeed. That would be a pointless and confusing outcome. if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) { - var _loop_23 = function (i) { + var _loop_24 = function (i) { var source_1 = matches ? matches[i] : neverType; var target_3 = types[i]; // If we are inferring from a string literal type to a type variable whose constraint includes one of the // allowed template literal placeholder types, infer from a literal type corresponding to the constraint. - if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) { + if (source_1.flags & 128 /* TypeFlags.StringLiteral */ && target_3.flags & 8650752 /* TypeFlags.TypeVariable */) { var inferenceContext = getInferenceInfoForType(target_3); var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined; if (constraint && !isTypeAny(constraint)) { - var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint]; + var constraintTypes = constraint.flags & 1048576 /* TypeFlags.Union */ ? constraint.types : [constraint]; var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0); // If the constraint contains `string`, we don't need to look for a more preferred type - if (!(allTypeFlags_1 & 4 /* String */)) { + if (!(allTypeFlags_1 & 4 /* TypeFlags.String */)) { var str_1 = source_1.value; // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers - if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) { - allTypeFlags_1 &= ~296 /* NumberLike */; + if (allTypeFlags_1 & 296 /* TypeFlags.NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) { + allTypeFlags_1 &= ~296 /* TypeFlags.NumberLike */; } // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints - if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) { - allTypeFlags_1 &= ~2112 /* BigIntLike */; + if (allTypeFlags_1 & 2112 /* TypeFlags.BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) { + allTypeFlags_1 &= ~2112 /* TypeFlags.BigIntLike */; } // for each type in the constraint, find the highest priority matching type var matchingType = ts.reduceLeft(constraintTypes, function (left, right) { return !(right.flags & allTypeFlags_1) ? left : - left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 : - left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 : - left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 : - left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right : - left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) : - left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) : - left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right : - left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) : - left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right : - left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType : - left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right : - left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right : - left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right : + left.flags & 4 /* TypeFlags.String */ ? left : right.flags & 4 /* TypeFlags.String */ ? source_1 : + left.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? left : right.flags & 134217728 /* TypeFlags.TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 : + left.flags & 268435456 /* TypeFlags.StringMapping */ ? left : right.flags & 268435456 /* TypeFlags.StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 : + left.flags & 128 /* TypeFlags.StringLiteral */ ? left : right.flags & 128 /* TypeFlags.StringLiteral */ && right.value === str_1 ? right : + left.flags & 8 /* TypeFlags.Number */ ? left : right.flags & 8 /* TypeFlags.Number */ ? getNumberLiteralType(+str_1) : + left.flags & 32 /* TypeFlags.Enum */ ? left : right.flags & 32 /* TypeFlags.Enum */ ? getNumberLiteralType(+str_1) : + left.flags & 256 /* TypeFlags.NumberLiteral */ ? left : right.flags & 256 /* TypeFlags.NumberLiteral */ && right.value === +str_1 ? right : + left.flags & 64 /* TypeFlags.BigInt */ ? left : right.flags & 64 /* TypeFlags.BigInt */ ? parseBigIntLiteralType(str_1) : + left.flags & 2048 /* TypeFlags.BigIntLiteral */ ? left : right.flags & 2048 /* TypeFlags.BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right : + left.flags & 16 /* TypeFlags.Boolean */ ? left : right.flags & 16 /* TypeFlags.Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType : + left.flags & 512 /* TypeFlags.BooleanLiteral */ ? left : right.flags & 512 /* TypeFlags.BooleanLiteral */ && right.intrinsicName === str_1 ? right : + left.flags & 32768 /* TypeFlags.Undefined */ ? left : right.flags & 32768 /* TypeFlags.Undefined */ && right.intrinsicName === str_1 ? right : + left.flags & 65536 /* TypeFlags.Null */ ? left : right.flags & 65536 /* TypeFlags.Null */ && right.intrinsicName === str_1 ? right : left; }, neverType); - if (!(matchingType.flags & 131072 /* Never */)) { + if (!(matchingType.flags & 131072 /* TypeFlags.Never */)) { inferFromTypes(matchingType, target_3); return "continue"; } @@ -69629,12 +69853,12 @@ var ts; inferFromTypes(source_1, target_3); }; for (var i = 0; i < types.length; i++) { - _loop_23(i); + _loop_24(i); } } } function inferFromObjectTypes(source, target) { - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); return; @@ -69649,7 +69873,7 @@ var ts; if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType); } - if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) { + if (ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */ && !target.declaration.nameType) { var constraintType = getConstraintTypeFromMappedType(target); if (inferToMappedType(source, target, constraintType)) { return; @@ -69672,21 +69896,21 @@ var ts; return; } var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0; - var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* Fixed */) : 0); + var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* ElementFlags.Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* ElementFlags.Fixed */) : 0); // Infer between starting fixed elements. for (var i = 0; i < startLength; i++) { inferFromTypes(getTypeArguments(source)[i], elementTypes[i]); } - if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* Rest */) { + if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Single rest element remains in source, infer from that to every element in target var restType = getTypeArguments(source)[startLength]; for (var i = startLength; i < targetArity - endLength; i++) { - inferFromTypes(elementFlags[i] & 8 /* Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); + inferFromTypes(elementFlags[i] & 8 /* ElementFlags.Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); } } else { var middleLength = targetArity - startLength - endLength; - if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* Variadic */ && isTupleType(source)) { + if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* ElementFlags.Variadic */ && isTupleType(source)) { // Middle of target is [...T, ...U] and source is tuple type var targetInfo = getInferenceInfoForType(elementTypes[startLength]); if (targetInfo && targetInfo.impliedArity !== undefined) { @@ -69695,14 +69919,14 @@ var ts; inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]); } } - else if (middleLength === 1 && elementFlags[startLength] & 8 /* Variadic */) { + else if (middleLength === 1 && elementFlags[startLength] & 8 /* ElementFlags.Variadic */) { // Middle of target is exactly one variadic element. Infer the slice between the fixed parts in the source. // If target ends in optional element(s), make a lower priority a speculative inference. - var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* Optional */; + var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* ElementFlags.Optional */; var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]); - inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* SpeculativeTuple */ : 0); + inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* InferencePriority.SpeculativeTuple */ : 0); } - else if (middleLength === 1 && elementFlags[startLength] & 4 /* Rest */) { + else if (middleLength === 1 && elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Middle of target is exactly one rest element. If middle of source is not empty, infer union of middle element types. var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0]; if (restType) { @@ -69722,8 +69946,8 @@ var ts; } } inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); + inferFromSignatures(source, target, 0 /* SignatureKind.Call */); + inferFromSignatures(source, target, 1 /* SignatureKind.Construct */); inferFromIndexTypes(source, target); } } @@ -69743,25 +69967,22 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */); for (var i = 0; i < len; i++) { - inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); + inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); } } - function inferFromSignature(source, target, skipParameters) { - if (!skipParameters) { - var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */; - applyToParameterTypes(source, target, inferFromContravariantTypes); - bivariant = saveBivariant; - } + function inferFromSignature(source, target) { + var saveBivariant = bivariant; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + // Once we descend into a bivariant signature we remain bivariant for all nested inferences + bivariant = bivariant || kind === 169 /* SyntaxKind.MethodDeclaration */ || kind === 168 /* SyntaxKind.MethodSignature */ || kind === 171 /* SyntaxKind.Constructor */; + applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes); + bivariant = saveBivariant; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables - var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */) ? 8 /* InferencePriority.HomomorphicMappedType */ : 0; var indexInfos = getIndexInfosOfType(target); if (isObjectTypeWithInferableIndex(source)) { for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) { @@ -69769,9 +69990,9 @@ var ts; var propTypes = []; for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { var propType = getTypeOfSymbol(prop); - propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType); + propTypes.push(prop.flags & 16777216 /* SymbolFlags.Optional */ ? removeMissingOrUndefinedType(propType) : propType); } } for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) { @@ -69796,34 +70017,34 @@ var ts; } function isTypeOrBaseIdenticalTo(s, t) { return exactOptionalPropertyTypes && t === missingType ? s === t : - (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */)); + (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* TypeFlags.String */ && s.flags & 128 /* TypeFlags.StringLiteral */ || t.flags & 8 /* TypeFlags.Number */ && s.flags & 256 /* TypeFlags.NumberLiteral */)); } function isTypeCloselyMatchedBy(s, t) { - return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + return !!(s.flags & 524288 /* TypeFlags.Object */ && t.flags & 524288 /* TypeFlags.Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* TypeFlags.Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); } function isObjectLiteralType(type) { - return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); + return !!(ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 16384 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectFlags.ObjectLiteral */ | 16384 /* ObjectFlags.ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType); if (objectLiterals.length) { - var literalsType = getUnionType(objectLiterals, 2 /* Subtype */); + var literalsType = getUnionType(objectLiterals, 2 /* UnionReduction.Subtype */); return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]); } } return candidates; } function getContravariantInference(inference) { - return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { // Extract all object and array literal types and replace them with a single widened and normalized type. @@ -69840,8 +70061,8 @@ var ts; candidates; // If all inferences were made from a position that implies a combined result, infer a union type. // Otherwise, infer a common supertype. - var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? - getUnionType(baseCandidates, 2 /* Subtype */) : + var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? + getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); } @@ -69855,14 +70076,14 @@ var ts; if (inference.contraCandidates) { // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'. - inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) && + inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* TypeFlags.Never */) && ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ? inferredCovariantType_1 : getContravariantInference(inference); } else if (inferredCovariantType_1) { inferredType = inferredCovariantType_1; } - else if (context.flags & 1 /* NoDefault */) { + else if (context.flags & 1 /* InferenceFlags.NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. inferredType = silentNeverType; } @@ -69883,7 +70104,7 @@ var ts; else { inferredType = getTypeFromInference(inference); } - inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* AnyDefault */)); + inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* InferenceFlags.AnyDefault */)); var constraint = getConstraintOfTypeParameter(inference.typeParameter); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper); @@ -69953,7 +70174,7 @@ var ts; } // falls through default: - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -69965,7 +70186,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false) || unknownSymbol; } return links.resolvedSymbol; @@ -69974,7 +70195,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 161 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* SyntaxKind.TypeQuery */ ? true : n.kind === 79 /* SyntaxKind.Identifier */ || n.kind === 161 /* SyntaxKind.QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -69982,70 +70203,79 @@ var ts; // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } // falls through - case 108 /* ThisKeyword */: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); return left && left + "." + node.right.escapedText; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); return key && key + "." + propName; } + break; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + // Handle pseudo-references originating in getNarrowedTypeOfSymbol. + return "".concat(getNodeId(node), "#").concat(getTypeId(declaredType)); } return undefined; } function isMatchingReference(source, target) { switch (target.kind) { - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isMatchingReference(source, target.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || - (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); + (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 231 /* MetaProperty */: - return target.kind === 231 /* MetaProperty */ + case 231 /* SyntaxKind.MetaProperty */: + return target.kind === 231 /* SyntaxKind.MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isThisInTypeQuery(source) ? - target.kind === 108 /* ThisKeyword */ : - target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 254 /* VariableDeclaration */ || target.kind === 203 /* BindingElement */) && + target.kind === 108 /* SyntaxKind.ThisKeyword */ : + target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 108 /* ThisKeyword */: - return target.kind === 108 /* ThisKeyword */; - case 106 /* SuperKeyword */: - return target.kind === 106 /* SuperKeyword */; - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return target.kind === 108 /* SyntaxKind.ThisKeyword */; + case 106 /* SyntaxKind.SuperKeyword */: + return target.kind === 106 /* SyntaxKind.SuperKeyword */; + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var sourcePropertyName = getAccessedPropertyName(source); var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined; return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName && isMatchingReference(source.expression, target.expression); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 221 /* BinaryExpression */: - return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); + case 221 /* SyntaxKind.BinaryExpression */: + return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target)); } return false; } @@ -70066,15 +70296,15 @@ var ts; return undefined; } function tryGetNameFromType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : - type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? type.escapedName : + type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; } function tryGetElementAccessExpressionName(node) { if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) { return ts.escapeLeadingUnderscores(node.argumentExpression.text); } if (ts.isEntityNameExpression(node.argumentExpression)) { - var symbol = resolveEntityName(node.argumentExpression, 111551 /* Value */, /*ignoreErrors*/ true); + var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); if (!symbol || !isConstVariable(symbol)) return undefined; var declaration = symbol.valueDeclaration; @@ -70113,12 +70343,12 @@ var ts; return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 1048576 /* Union */) { + if (type && type.flags & 1048576 /* TypeFlags.Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (prop && ts.getCheckFlags(prop) & 2 /* CheckFlags.SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = - (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && + (prop.checkFlags & 192 /* CheckFlags.Discriminant */) === 192 /* CheckFlags.Discriminant */ && !isGenericType(getTypeOfSymbol(prop)); } return !!prop.isDiscriminantProperty; @@ -70147,8 +70377,8 @@ var ts; function mapTypesByKeyProperty(types, name) { var map = new ts.Map(); var count = 0; - var _loop_24 = function (type) { - if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var _loop_25 = function (type) { + if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { if (!isLiteralType(discriminant)) { @@ -70173,7 +70403,7 @@ var ts; }; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var type = types_15[_i]; - var state_9 = _loop_24(type); + var state_9 = _loop_25(type); if (typeof state_9 === "object") return state_9.value; } @@ -70184,15 +70414,15 @@ var ts; function getKeyPropertyName(unionType) { var types = unionType.types; // We only construct maps for unions with many non-primitive constituents. - if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* PrimitiveUnion */ || - ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) { + if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* ObjectFlags.PrimitiveUnion */ || + ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)); }) < 10) { return undefined; } if (unionType.keyPropertyName === undefined) { // The candidate key property name is the name of the first property with a unit type in one of the // constituent types. var keyPropertyName = ts.forEach(types, function (t) { - return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ? + return t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : undefined; }); @@ -70216,7 +70446,7 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); @@ -70233,7 +70463,7 @@ var ts; } } } - if (expression.expression.kind === 206 /* PropertyAccessExpression */ && + if (expression.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -70247,7 +70477,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -70262,23 +70492,25 @@ var ts; // For example, when a variable of type number | string | boolean is assigned a value of type number | boolean, // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { - if (declaredType !== assignedType) { - if (assignedType.flags & 131072 /* Never */) { - return assignedType; - } - var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) { - reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types - } - // Our crude heuristic produces an invalid result in some cases: see GH#26130. - // For now, when that happens, we give up and don't narrow at all. (This also - // means we'll never narrow for erroneous assignments where the assigned type - // is not assignable to the declared type.) - if (isTypeAssignableTo(assignedType, reducedType)) { - return reducedType; - } + var _a; + if (declaredType === assignedType) { + return declaredType; } - return declaredType; + if (assignedType.flags & 131072 /* TypeFlags.Never */) { + return assignedType; + } + var key = "A".concat(getTypeId(declaredType), ",").concat(getTypeId(assignedType)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType)); + } + function getAssignmentReducedTypeWorker(declaredType, assignedType) { + var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); + // Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type. + var reducedType = assignedType.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType; + // Our crude heuristic produces an invalid result in some cases: see GH#26130. + // For now, when that happens, we give up and don't narrow at all. (This also + // means we'll never narrow for erroneous assignments where the assigned type + // is not assignable to the declared type.) + return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType; } function isFunctionObjectType(type) { // We do a quick check for a "bind" property before performing the more expensive subtype @@ -70288,95 +70520,95 @@ var ts; resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { - if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) { + if (type.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */)) { type = getBaseConstraintOfType(type) || unknownType; } var flags = type.flags; - if (flags & (4 /* String */ | 268435456 /* StringMapping */)) { - return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; + if (flags & (4 /* TypeFlags.String */ | 268435456 /* TypeFlags.StringMapping */)) { + return strictNullChecks ? 16317953 /* TypeFacts.StringStrictFacts */ : 16776705 /* TypeFacts.StringFacts */; } - if (flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) { - var isEmpty = flags & 128 /* StringLiteral */ && type.value === ""; + if (flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + var isEmpty = flags & 128 /* TypeFlags.StringLiteral */ && type.value === ""; return strictNullChecks ? - isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : - isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* TypeFacts.EmptyStringStrictFacts */ : 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* TypeFacts.EmptyStringFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; + if (flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */)) { + return strictNullChecks ? 16317698 /* TypeFacts.NumberStrictFacts */ : 16776450 /* TypeFacts.NumberFacts */; } - if (flags & 256 /* NumberLiteral */) { + if (flags & 256 /* TypeFlags.NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : - isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + isZero ? 12123394 /* TypeFacts.ZeroNumberStrictFacts */ : 7929090 /* TypeFacts.NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* TypeFacts.ZeroNumberFacts */ : 16776450 /* TypeFacts.NonZeroNumberFacts */; } - if (flags & 64 /* BigInt */) { - return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + if (flags & 64 /* TypeFlags.BigInt */) { + return strictNullChecks ? 16317188 /* TypeFacts.BigIntStrictFacts */ : 16775940 /* TypeFacts.BigIntFacts */; } - if (flags & 2048 /* BigIntLiteral */) { + if (flags & 2048 /* TypeFlags.BigIntLiteral */) { var isZero = isZeroBigInt(type); return strictNullChecks ? - isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : - isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; + isZero ? 12122884 /* TypeFacts.ZeroBigIntStrictFacts */ : 7928580 /* TypeFacts.NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* TypeFacts.ZeroBigIntFacts */ : 16775940 /* TypeFacts.NonZeroBigIntFacts */; } - if (flags & 16 /* Boolean */) { - return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; + if (flags & 16 /* TypeFlags.Boolean */) { + return strictNullChecks ? 16316168 /* TypeFacts.BooleanStrictFacts */ : 16774920 /* TypeFacts.BooleanFacts */; } - if (flags & 528 /* BooleanLike */) { + if (flags & 528 /* TypeFlags.BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* TypeFacts.FalseStrictFacts */ : 7927560 /* TypeFacts.TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* TypeFacts.FalseFacts */ : 16774920 /* TypeFacts.TrueFacts */; } - if (flags & 524288 /* Object */) { - return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : + if (flags & 524288 /* TypeFlags.Object */) { + return ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && isEmptyObjectType(type) ? + strictNullChecks ? 83427327 /* TypeFacts.EmptyObjectStrictFacts */ : 83886079 /* TypeFacts.EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : - strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + strictNullChecks ? 7880640 /* TypeFacts.FunctionStrictFacts */ : 16728000 /* TypeFacts.FunctionFacts */ : + strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 16384 /* Void */) { - return 9830144 /* VoidFacts */; + if (flags & 16384 /* TypeFlags.Void */) { + return 9830144 /* TypeFacts.VoidFacts */; } - if (flags & 32768 /* Undefined */) { - return 26607360 /* UndefinedFacts */; + if (flags & 32768 /* TypeFlags.Undefined */) { + return 26607360 /* TypeFacts.UndefinedFacts */; } - if (flags & 65536 /* Null */) { - return 42917664 /* NullFacts */; + if (flags & 65536 /* TypeFlags.Null */) { + return 42917664 /* TypeFacts.NullFacts */; } - if (flags & 12288 /* ESSymbolLike */) { - return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; + if (flags & 12288 /* TypeFlags.ESSymbolLike */) { + return strictNullChecks ? 7925520 /* TypeFacts.SymbolStrictFacts */ : 16772880 /* TypeFacts.SymbolFacts */; } - if (flags & 67108864 /* NonPrimitive */) { - return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + if (flags & 67108864 /* TypeFlags.NonPrimitive */) { + return strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 131072 /* Never */) { - return 0 /* None */; + if (flags & 131072 /* TypeFlags.Never */) { + return 0 /* TypeFacts.None */; } - if (flags & 1048576 /* Union */) { - return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* None */); + if (flags & 1048576 /* TypeFlags.Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* TypeFacts.None */); } - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionTypeFacts(type); } - return 83886079 /* UnknownFacts */; + return 83886079 /* TypeFacts.UnknownFacts */; } function getIntersectionTypeFacts(type) { // When an intersection contains a primitive type we ignore object type constituents as they are // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type. - var ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */); + var ignoreObjects = maybeTypeOfKind(type, 131068 /* TypeFlags.Primitive */); // When computing the type facts of an intersection type, certain type facts are computed as `and` // and others are computed as `or`. - var oredFacts = 0 /* None */; - var andedFacts = 134217727 /* All */; + var oredFacts = 0 /* TypeFacts.None */; + var andedFacts = 134217727 /* TypeFacts.All */; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (!(ignoreObjects && t.flags & 524288 /* Object */)) { + if (!(ignoreObjects && t.flags & 524288 /* TypeFlags.Object */)) { var f = getTypeFacts(t); oredFacts |= f; andedFacts &= f; } } - return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */; + return oredFacts & 8256 /* TypeFacts.OrFactsMask */ | andedFacts & 134209471 /* TypeFacts.AndFactsMask */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -70385,16 +70617,16 @@ var ts; // unknown with the union {} | null | undefined (and reduces that accordingly), and it intersects remaining // instantiable types with {}, {} | null, or {} | undefined in order to remove null and/or undefined. function getAdjustedTypeWithFacts(type, facts) { - var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts)); + var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */ ? unknownUnionType : type, facts)); if (strictNullChecks) { switch (facts) { - case 524288 /* NEUndefined */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; }); - case 1048576 /* NENull */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; }); - case 2097152 /* NEUndefinedOrNull */: - case 4194304 /* Truthy */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; }); + case 524288 /* TypeFacts.NEUndefined */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* TypeFacts.EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* TypeFacts.EQNull */ && !maybeTypeOfKind(reduced, 65536 /* TypeFlags.Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; }); + case 1048576 /* TypeFacts.NENull */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* TypeFacts.EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* TypeFacts.EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* TypeFlags.Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; }); + case 2097152 /* TypeFacts.NEUndefinedOrNull */: + case 4194304 /* TypeFacts.Truthy */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; }); } } return reduced; @@ -70417,7 +70649,7 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || - includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || + includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || errorType; } function includeUndefinedInIndexSignature(type) { @@ -70428,18 +70660,18 @@ var ts; type; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); + return createArrayType(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 204 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 221 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 244 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -70456,21 +70688,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return stringType; - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return undefinedType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -70478,7 +70710,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 201 /* ObjectBindingPattern */ ? + var type = pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -70496,37 +70728,37 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 243 /* ForInStatement */) { + if (node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 254 /* VariableDeclaration */ ? + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 254 /* VariableDeclaration */ && node.initializer && + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 203 /* BindingElement */ && node.parent.kind === 221 /* BinaryExpression */ && + node.kind !== 203 /* SyntaxKind.BindingElement */ && node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return getReferenceCandidate(node.right); } } @@ -70534,13 +70766,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 212 /* ParenthesizedExpression */ || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.left === node || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -70559,25 +70791,25 @@ var ts; // Get the type names from all cases in a switch on `typeof`. The default clause and/or duplicate type names are // represented as undefined. Return undefined if one or more case clause expressions are not string literals. function getSwitchClauseTypeOfWitnesses(switchStatement) { - if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) { + if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* SyntaxKind.CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) { return undefined; } var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - var text = clause.kind === 289 /* CaseClause */ ? clause.expression.text : undefined; + var text = clause.kind === 289 /* SyntaxKind.CaseClause */ ? clause.expression.text : undefined; witnesses.push(text && !ts.contains(witnesses, text) ? text : undefined); } return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 1048576 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* TypeFlags.Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* TypeFlags.Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -70586,25 +70818,25 @@ var ts; } return true; } - if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* TypeFlags.EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.forEach(type.types, f) : f(type); } function someType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.every(type.types, f) : f(type); } function everyContainedType(type, f) { - return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var types = type.types; var filtered = ts.filter(types, f); if (filtered === types) { @@ -70612,45 +70844,45 @@ var ts; } var origin = type.origin; var newOrigin = void 0; - if (origin && origin.flags & 1048576 /* Union */) { + if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { // If the origin type is a (denormalized) union type, filter its non-union constituents. If that ends // up removing a smaller number of types than in the normalized constituent set (meaning some of the // filtered types are within nested unions in the origin), then we can't construct a new origin type. // Otherwise, if we have exactly one type left in the origin set, return that as the filtered type. // Otherwise, construct a new filtered origin type. var originTypes = origin.types; - var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* Union */) || f(t); }); + var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) || f(t); }); if (originTypes.length - originFiltered.length === types.length - filtered.length) { if (originFiltered.length === 1) { return originFiltered[0]; } - newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + newOrigin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, originFiltered); } } return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } - return type.flags & 131072 /* Never */ || f(type) ? type : neverType; + return type.flags & 131072 /* TypeFlags.Never */ || f(type) ? type : neverType; } function removeType(type, targetType) { return filterType(type, function (t) { return t !== targetType; }); } function countTypes(type) { - return type.flags & 1048576 /* Union */ ? type.types.length : 1; + return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1; } function mapType(type, mapper, noReductions) { - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return type; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return mapper(type); } var origin = type.origin; - var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types; + var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? origin.types : type.types; var mappedTypes; var changed = false; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; - var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t); + var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { if (!mappedTypes) { @@ -70661,11 +70893,11 @@ var ts; } } } - return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; + return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type; } function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { - return type.flags & 1048576 /* Union */ && aliasSymbol ? - getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper); } function extractTypesOfKind(type, kind) { @@ -70677,13 +70909,13 @@ var ts; // true intersection because it is more costly and, when applied to union types, generates a large number of // types we don't actually care about. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && - maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) { + if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) && + maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : - isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; + return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) : + isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) : + t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) : + t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -70695,14 +70927,14 @@ var ts; return flowType.flags === 0 ? flowType.type : flowType; } function createFlowType(type, incomplete) { - return incomplete ? { flags: 0, type: type.flags & 131072 /* Never */ ? silentNeverType : type } : type; + return incomplete ? { flags: 0, type: type.flags & 131072 /* TypeFlags.Never */ ? silentNeverType : type } : type; } // An evolving array type tracks the element types that have so far been seen in an // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(256 /* EvolvingArray */); + var result = createObjectType(256 /* ObjectFlags.EvolvingArray */); result.elementType = elementType; return result; } @@ -70717,10 +70949,10 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 131072 /* Never */ ? + return elementType.flags & 131072 /* TypeFlags.Never */ ? autoArrayType : - createArrayType(elementType.flags & 1048576 /* Union */ ? - getUnionType(elementType.types, 2 /* Subtype */) : + createArrayType(elementType.flags & 1048576 /* TypeFlags.Union */ ? + getUnionType(elementType.types, 2 /* UnionReduction.Subtype */) : elementType); } // We perform subtype reduction upon obtaining the final array type from an evolving array type. @@ -70728,17 +70960,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { var t = types_17[_i]; - if (!(t.flags & 131072 /* Never */)) { - if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + if (!(ts.getObjectFlags(t) & 256 /* ObjectFlags.EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -70752,16 +70984,16 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 208 /* CallExpression */ + parent.parent.kind === 208 /* SyntaxKind.CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 207 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 221 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 63 /* EqualsToken */ && + parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* TypeFlags.NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(node) { @@ -70770,11 +71002,11 @@ var ts; ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer)); } function getExplicitTypeOfSymbol(symbol, diagnostic) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { + if (ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */) { var origin = symbol.syntheticOrigin; if (origin && getExplicitTypeOfSymbol(origin)) { return getTypeOfSymbol(symbol); @@ -70785,11 +71017,11 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); } } @@ -70804,16 +71036,16 @@ var ts; // parameter symbols with declarations that have explicit type annotations. Such references are // resolvable with no possibility of triggering circularities in control flow analysis. function getTypeOfDottedName(node, diagnostic) { - if (!(node.flags & 33554432 /* InWithStatement */)) { + if (!(node.flags & 33554432 /* NodeFlags.InWithStatement */)) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); - return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 108 /* ThisKeyword */: + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 108 /* SyntaxKind.ThisKeyword */: return getExplicitThisType(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 206 /* PropertyAccessExpression */: { + case 206 /* SyntaxKind.PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -70831,7 +71063,7 @@ var ts; } return undefined; } - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -70845,10 +71077,10 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 106 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -70856,7 +71088,7 @@ var ts; funcType = checkNonNullExpression(node.expression); } } - var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* SignatureKind.Call */); var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : undefined; @@ -70866,10 +71098,10 @@ var ts; } function hasTypePredicateOrNeverReturnType(signature) { return !!(getTypePredicateOfSignature(signature) || - signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* TypeFlags.Never */); } function getTypePredicateArgument(predicate, callExpression) { - if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + if (predicate.kind === 1 /* TypePredicateKind.Identifier */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { return callExpression.arguments[predicate.parameterIndex]; } var invokedExpression = ts.skipParentheses(callExpression.expression); @@ -70889,8 +71121,8 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 95 /* FalseKeyword */ || node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || - node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + return node.kind === 95 /* SyntaxKind.FalseKeyword */ || node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { while (true) { @@ -70898,7 +71130,7 @@ var ts; return lastFlowNodeReachable; } var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var reachable = flowNodeReachable[id]; @@ -70906,30 +71138,30 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && predicate.kind === 3 /* AssertsIdentifier */ && !predicate.type) { + if (predicate && predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && !predicate.type) { var predicateArgument = flow.node.arguments[predicate.parameterIndex]; if (predicateArgument && isFalseExpression(predicateArgument)) { return false; } } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return false; } } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is reachable if any branch is reachable. return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { var antecedents = flow.antecedents; if (antecedents === undefined || antecedents.length === 0) { return false; @@ -70937,7 +71169,7 @@ var ts; // A loop is reachable if the control flow path that leads to the top is reachable. flow = antecedents[0]; } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { // The control flow path representing an unmatched value in a switch statement with // no default clause is unreachable if the switch statement is exhaustive. if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { @@ -70945,7 +71177,7 @@ var ts; } flow = flow.antecedent; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { // Cache is unreliable once we start adjusting labels lastFlowNode = undefined; var target = flow.target; @@ -70956,7 +71188,7 @@ var ts; return result; } else { - return !(flags & 1 /* Unreachable */); + return !(flags & 1 /* FlowFlags.Unreachable */); } } } @@ -70965,7 +71197,7 @@ var ts; function isPostSuperFlowNode(flow, noCacheCheck) { while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var postSuper = flowNodePostSuper[id]; @@ -70973,24 +71205,24 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 128 /* SwitchClause */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */ | 128 /* FlowFlags.SwitchClause */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 106 /* SuperKeyword */) { + else if (flags & 512 /* FlowFlags.Call */) { + if (flow.node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return true; } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is post-super if every branch is post-super. return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { // A loop is post-super if the control flow path that leads to the top is post-super. flow = flow.antecedents[0]; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; @@ -71000,18 +71232,18 @@ var ts; } else { // Unreachable nodes are considered post-super to silence errors - return !!(flags & 1 /* Unreachable */); + return !!(flags & 1 /* FlowFlags.Unreachable */); } } } function isConstantReference(node) { switch (node.kind) { - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var symbol = getResolvedSymbol(node); return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); } @@ -71037,8 +71269,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* ObjectFlags.EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* SyntaxKind.NonNullExpression */ && !(resultType.flags & 131072 /* TypeFlags.Never */) && getTypeWithFacts(resultType, 2097152 /* TypeFacts.NEUndefinedOrNull */).flags & 131072 /* TypeFlags.Never */) { return declaredType; } // The non-null unknown type should never escape control flow analysis. @@ -71054,7 +71286,7 @@ var ts; if (flowDepth === 2000) { // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error // and disable further control flow analysis in the containing function or module body. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -71063,7 +71295,7 @@ var ts; var sharedFlow; while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -71076,56 +71308,56 @@ var ts; sharedFlow = flow; } var type = void 0; - if (flags & 16 /* Assignment */) { + if (flags & 16 /* FlowFlags.Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { type = getTypeAtFlowCall(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 96 /* Condition */) { + else if (flags & 96 /* FlowFlags.Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flags & 12 /* Label */) { + else if (flags & 12 /* FlowFlags.Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flags & 4 /* BranchLabel */ ? + type = flags & 4 /* FlowFlags.BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* FlowFlags.ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; type = getTypeAtFlowNode(flow.antecedent); target.antecedents = saveAntecedents; } - else if (flags & 2 /* Start */) { + else if (flags & 2 /* FlowFlags.Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 206 /* PropertyAccessExpression */ && - reference.kind !== 207 /* ElementAccessExpression */ && - reference.kind !== 108 /* ThisKeyword */) { + reference.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && + reference.kind !== 207 /* SyntaxKind.ElementAccessExpression */ && + reference.kind !== 108 /* SyntaxKind.ThisKeyword */) { flow = container.flowNode; continue; } @@ -71149,7 +71381,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -71161,7 +71393,7 @@ var ts; if (!isReachableFlowNode(flow)) { return unreachableNeverType; } - if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { + if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -71172,7 +71404,7 @@ var ts; var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* TypeFlags.Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; @@ -71189,29 +71421,29 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 213 /* FunctionExpression */ || init.kind === 214 /* ArrowFunction */)) { + if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { - return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)))); } // Assignment doesn't affect reference return undefined; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - if (node.kind === 95 /* FalseKeyword */) { + if (node.kind === 95 /* SyntaxKind.FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 221 /* BinaryExpression */) { - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } - if (node.operatorToken.kind === 56 /* BarBarToken */) { + if (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); } } @@ -71221,15 +71453,15 @@ var ts; var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + if (predicate && (predicate.kind === 2 /* TypePredicateKind.AssertsThis */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = finalizeEvolvingArrayType(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]) : + predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return unreachableNeverType; } } @@ -71238,15 +71470,15 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 208 /* CallExpression */ ? + var expr = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { + if (ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -71255,7 +71487,7 @@ var ts; else { // We must get the context free expression type so as to not recur in an uncached fashion on the LHS (which causes exponential blowup in compile time) var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -71269,7 +71501,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -71279,7 +71511,7 @@ var ts; // have the complete type. We proceed by switching to the silent never type which // doesn't report errors when operators are applied to it. Note that this is the // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { @@ -71294,16 +71526,16 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 216 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* TypeFlags.Undefined */ | 131072 /* TypeFlags.Never */)); }); } - else if (expr.kind === 216 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* TypeFlags.Never */ || t.flags & 128 /* TypeFlags.StringLiteral */ && t.value === "undefined"); }); } } var access = getDiscriminantPropertyAccess(expr, type); @@ -71320,7 +71552,7 @@ var ts; var bypassFlow; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { + if (!bypassFlow && antecedent.flags & 128 /* FlowFlags.SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { // The antecedent is the bypass branch of a potentially exhaustive switch statement. bypassFlow = antecedent; continue; @@ -71364,7 +71596,7 @@ var ts; } } } - return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -71390,7 +71622,7 @@ var ts; // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { - return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* Literal */), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* UnionReduction.Literal */), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -71443,7 +71675,7 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } @@ -71458,7 +71690,7 @@ var ts; return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))); } var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction)); - if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) { + if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* TypeFlags.Union */ && ts.arraysEqual(result.types, declaredType.types)) { return declaredType; } return result; @@ -71504,8 +71736,8 @@ var ts; return undefined; } function getDiscriminantPropertyAccess(expr, computedType) { - var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + var type = declaredType.flags & 1048576 /* TypeFlags.Union */ ? declaredType : computedType; + if (type.flags & 1048576 /* TypeFlags.Union */) { var access = getCandidateDiscriminantPropertyAccess(expr); if (access) { var name = getAccessedPropertyName(access); @@ -71521,8 +71753,8 @@ var ts; if (propName === undefined) { return type; } - var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); - var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* TypeFlags.Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } @@ -71530,16 +71762,16 @@ var ts; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); - return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType); + return !(narrowedPropType.flags & 131072 /* TypeFlags.Never */) && isTypeComparableTo(narrowedPropType, discriminantType); }); } function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { - if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + if ((operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* TypeFlags.Union */) { var keyPropertyName = getKeyPropertyName(type); if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); if (candidate) { - return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate : + return operator === (assumeTrue ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) ? candidate : isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) : type; } @@ -71548,7 +71780,7 @@ var ts; return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); }); } function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) { - if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { + if (clauseStart < clauseEnd && type.flags & 1048576 /* TypeFlags.Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); if (candidate !== unknownType) { @@ -71559,51 +71791,51 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); + return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { - type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + type = getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); }); } return type; } function isTypePresencePossible(type, propName, assumeTrue) { var prop = getPropertyOfType(type, propName); if (prop) { - return prop.flags & 16777216 /* Optional */ ? true : assumeTrue; + return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue; } return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue; } function narrowByInKeyword(type, name, assumeTrue) { - if (type.flags & 1048576 /* Union */ - || type.flags & 524288 /* Object */ && declaredType !== type + if (type.flags & 1048576 /* TypeFlags.Union */ + || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type || ts.isThisTypeParameter(type) - || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { + || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); }); } return type; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -71635,35 +71867,35 @@ var ts; return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (ts.isPrivateIdentifier(expr.left)) { return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue); } var target = getReferenceCandidate(expr.right); var leftType = getTypeOfNode(expr.left); - if (leftType.flags & 128 /* StringLiteral */) { + if (leftType.flags & 128 /* TypeFlags.StringLiteral */) { var name = ts.escapeLeadingUnderscores(leftType.value); if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && getAccessedPropertyName(reference) === name) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } if (isMatchingReference(reference, target)) { return narrowByInKeyword(type, name, assumeTrue); } } break; - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return narrowType(type, expr.right, assumeTrue); // Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those // expressions down to individual conditional control flows. However, we may encounter them when analyzing // aliased conditional expressions. - case 55 /* AmpersandAmpersandToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: return assumeTrue ? narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) : getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]); - case 56 /* BarBarToken */: + case 56 /* SyntaxKind.BarBarToken */: return assumeTrue ? getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) : narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); @@ -71684,7 +71916,7 @@ var ts; var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true); } function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { // We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows: @@ -71696,45 +71928,45 @@ var ts; // When operator is !== and type of value is undefined, null and undefined is removed from type of obj in true branch. // When operator is == and type of value is null or undefined, null and undefined is removed from type of obj in false branch. // When operator is != and type of value is null or undefined, null and undefined is removed from type of obj in true branch. - var equalsOperator = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; - var nullableFlags = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */; + var equalsOperator = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; + var nullableFlags = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? 98304 /* TypeFlags.Nullable */ : 32768 /* TypeFlags.Undefined */; var valueType = getTypeOfExpression(value); // Note that we include any and unknown in the exclusion test because their domain includes null and undefined. var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) || - equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); }); - return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* TypeFlags.AnyOrUnknown */ | nullableFlags)); }); + return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeByEquality(type, operator, value, assumeTrue) { - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { return type; } - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { - if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && assumeTrue && (operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { + if (valueType.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { return valueType; } - if (valueType.flags & 524288 /* Object */) { + if (valueType.flags & 524288 /* TypeFlags.Object */) { return nonPrimitiveType; } return type; } - if (valueType.flags & 98304 /* Nullable */) { + if (valueType.flags & 98304 /* TypeFlags.Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : - valueType.flags & 65536 /* Null */ ? - assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : - assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; + assumeTrue ? 262144 /* TypeFacts.EQUndefinedOrNull */ : 2097152 /* TypeFacts.NEUndefinedOrNull */ : + valueType.flags & 65536 /* TypeFlags.Null */ ? + assumeTrue ? 131072 /* TypeFacts.EQNull */ : 1048576 /* TypeFacts.NENull */ : + assumeTrue ? 65536 /* TypeFacts.EQUndefined */ : 524288 /* TypeFacts.NEUndefined */; return getAdjustedTypeWithFacts(type, facts); } if (assumeTrue) { - var filterFn = operator === 34 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); @@ -71746,23 +71978,23 @@ var ts; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { - return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } return assumeTrue ? narrowTypeByTypeName(type, literal.text) : - getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */); + getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeFacts.TypeofNEHostObject */); } function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); - return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify @@ -71775,16 +72007,16 @@ var ts; } var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); - if ((type.flags & 2 /* Unknown */) && !hasDefaultClause) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && !hasDefaultClause) { var groundClauseTypes = void 0; for (var i = 0; i < clauseTypes.length; i += 1) { var t = clauseTypes[i]; - if (t.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if (t.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { if (groundClauseTypes !== undefined) { groundClauseTypes.push(t); } } - else if (t.flags & 524288 /* Object */) { + else if (t.flags & 524288 /* TypeFlags.Object */) { if (groundClauseTypes === undefined) { groundClauseTypes = clauseTypes.slice(0, i); } @@ -71797,26 +72029,26 @@ var ts; return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes); } var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* TypeFlags.Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); - return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]); } function narrowTypeByTypeName(type, typeName) { switch (typeName) { - case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeofEQString */); - case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeofEQNumber */); - case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeofEQBigInt */); - case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeofEQBoolean */); - case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeofEQSymbol */); - case "object": return type.flags & 1 /* Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* EQNull */)]); - case "function": return type.flags & 1 /* Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeofEQFunction */); - case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* EQUndefined */); + case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeFacts.TypeofEQString */); + case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeFacts.TypeofEQNumber */); + case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeFacts.TypeofEQBigInt */); + case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeFacts.TypeofEQBoolean */); + case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeFacts.TypeofEQSymbol */); + case "object": return type.flags & 1 /* TypeFlags.Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeFacts.TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* TypeFacts.EQNull */)]); + case "function": return type.flags & 1 /* TypeFlags.Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeFacts.TypeofEQFunction */); + case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* TypeFacts.EQUndefined */); } - return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */); + return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeFacts.TypeofEQHostObject */); } function narrowTypeByTypeFacts(type, impliedType, facts) { return mapType(type, function (t) { @@ -71841,7 +72073,7 @@ var ts; return type; } // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause. - var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* DefaultClause */; }); + var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* SyntaxKind.DefaultClause */; }); var hasDefaultClause = clauseStart === clauseEnd || (defaultIndex >= clauseStart && defaultIndex < clauseEnd); if (hasDefaultClause) { // In the default clause we filter constituents down to those that are not-equal to all handled cases. @@ -71859,7 +72091,7 @@ var ts; } function narrowTypeByConstructor(type, operator, identifier, assumeTrue) { // Do not narrow when checking inequality. - if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) { + if (assumeTrue ? (operator !== 34 /* SyntaxKind.EqualsEqualsToken */ && operator !== 36 /* SyntaxKind.EqualsEqualsEqualsToken */) : (operator !== 35 /* SyntaxKind.ExclamationEqualsToken */ && operator !== 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { return type; } // Get the type of the constructor identifier expression, if it is not a function then do not narrow. @@ -71889,8 +72121,8 @@ var ts; // This is because you may have a class `A` that defines some set of properties, and another class `B` // that defines the same set of properties as class `A`, in that case they are structurally the same // type, but when you do something like `instanceOfA.constructor === B` it will return false. - if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ || - target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) { + if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ || + target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { return source.symbol === target.symbol; } // For all other types just check that the `source` type is a subtype of the `target` type. @@ -71901,7 +72133,7 @@ var ts; var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { - return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } @@ -71924,46 +72156,65 @@ var ts; return type; } if (!targetType) { - var constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(rightType, 1 /* SignatureKind.Construct */); targetType = constructSignatures.length ? getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) : emptyObjectType; } // We can't narrow a union based off instanceof without negated types see #31576 for more info - if (!assumeTrue && rightType.flags & 1048576 /* Union */) { + if (!assumeTrue && rightType.flags & 1048576 /* TypeFlags.Union */) { var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); }); if (!nonConstructorTypeInUnion) return type; } - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true); } - function getNarrowedType(type, candidate, assumeTrue, isRelated) { + function getNarrowedType(type, candidate, assumeTrue, checkDerived) { + var _a; + var key = type.flags & 1048576 /* TypeFlags.Union */ ? "N".concat(getTypeId(type), ",").concat(getTypeId(candidate), ",").concat((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined; + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived)); + } + function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) { + var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf; if (!assumeTrue) { return filterType(type, function (t) { return !isRelated(t, candidate); }); } - // If the current type is a union type, remove all constituents that couldn't be instances of - // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 1048576 /* Union */) { - var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072 /* Never */)) { - return assignableType; - } + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { + return candidate; } - // If the candidate type is a subtype of the target type, narrow to the candidate type. - // Otherwise, if the target type is assignable to the candidate type, keep the target type. - // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate - // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the - // two types. - return isTypeSubtypeOf(candidate, type) ? candidate : - isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, type) ? candidate : - getIntersectionType([type, candidate]); + // We first attempt to filter the current type, narrowing constituents as appropriate and removing + // constituents that are unrelated to the candidate. + var keyPropertyName = type.flags & 1048576 /* TypeFlags.Union */ ? getKeyPropertyName(type) : undefined; + var narrowedType = mapType(candidate, function (c) { + // If a discriminant property is available, use that to reduce the type. + var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName); + var matching = discriminant && getConstituentTypeForKeyType(type, discriminant); + // For each constituent t in the current type, if t and and c are directly related, pick the most + // specific of the two. When t and c are related in both directions, we prefer c for type predicates + // because that is the asserted type, but t for `instanceof` because generics aren't reflected in + // prototype object types. + var directlyRelated = mapType(matching || type, checkDerived ? + function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } : + function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; }); + // If no constituents are directly related, create intersections for any generic constituents that + // are related by constraint. + return directlyRelated.flags & 131072 /* TypeFlags.Never */ ? + mapType(type, function (t) { return maybeTypeOfKind(t, 465829888 /* TypeFlags.Instantiable */) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType; }) : + directlyRelated; + }); + // If filtering produced a non-empty type, return that. Otherwise, pick the most specific of the two + // based on assignability, or as a last resort produce an intersection. + return !(narrowedType.flags & 131072 /* TypeFlags.Never */) ? narrowedType : + isTypeSubtypeOf(candidate, type) ? candidate : + isTypeAssignableTo(type, candidate) ? type : + isTypeAssignableTo(candidate, type) ? candidate : + getIntersectionType([type, candidate]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; var predicate = signature && getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + if (predicate && (predicate.kind === 0 /* TypePredicateKind.This */ || predicate.kind === 1 /* TypePredicateKind.Identifier */)) { return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } @@ -71973,7 +72224,7 @@ var ts; ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) { var argument = callExpression.arguments[0]; if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } } } @@ -71985,15 +72236,15 @@ var ts; var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && - !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { - type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + !(getTypeFacts(predicate.type) & 65536 /* TypeFacts.EQUndefined */)) { + type = getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); }); } } } @@ -72004,11 +72255,11 @@ var ts; function narrowType(type, expr, assumeTrue) { // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` if (ts.isExpressionOfOptionalChainRoot(expr) || - ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */ && expr.parent.left === expr) { return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline // up to five levels of aliased conditional expressions that are themselves declared as const variables. if (!isMatchingReference(reference, expr) && inlineLevel < 5) { @@ -72024,20 +72275,20 @@ var ts; } } // falls through - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 219 /* PrefixUnaryExpression */: - if (expr.operator === 53 /* ExclamationToken */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (expr.operator === 53 /* SyntaxKind.ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -72046,11 +72297,11 @@ var ts; } function narrowTypeByOptionality(type, expr, assumePresent) { if (isMatchingReference(reference, expr)) { - return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); }); } return type; } @@ -72061,7 +72312,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { + if (location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -72085,9 +72336,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 262 /* ModuleBlock */ || - node.kind === 305 /* SourceFile */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 262 /* SyntaxKind.ModuleBlock */ || + node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; }); } // Check if a parameter or catch variable is assigned anywhere @@ -72097,8 +72348,8 @@ var ts; } var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(parent); - if (!(links.flags & 8388608 /* AssignmentsMarked */)) { - links.flags |= 8388608 /* AssignmentsMarked */; + if (!(links.flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */)) { + links.flags |= 8388608 /* NodeCheckFlags.AssignmentsMarked */; if (!hasParentWithAssignmentsMarked(parent)) { markNodeAssignments(parent); } @@ -72107,11 +72358,11 @@ var ts; } function hasParentWithAssignmentsMarked(node) { return !!ts.findAncestor(node.parent, function (node) { - return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); + return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */); }); } function markNodeAssignments(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); if (ts.isParameterOrCatchClauseVariable(symbol)) { @@ -72124,18 +72375,18 @@ var ts; } } function isConstVariable(symbol) { - return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0; + return symbol.flags & 3 /* SymbolFlags.Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */) !== 0; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { - if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { + if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 164 /* Parameter */ && + declaration.kind === 164 /* SyntaxKind.Parameter */ && declaration.initializer && - getTypeFacts(declaredType) & 16777216 /* IsUndefined */ && - !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* IsUndefined */); + getTypeFacts(declaredType) & 16777216 /* TypeFacts.IsUndefined */ && + !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* TypeFacts.IsUndefined */); popTypeResolution(); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType; } else { reportCircularityError(declaration.symbol); @@ -72147,19 +72398,19 @@ var ts; // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of // a generic type without a nullable constraint and x is a generic type. This is because when both obj // and x are of generic types T and K, we want the resulting type to be T[K]. - return parent.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 161 /* QualifiedName */ || - parent.kind === 208 /* CallExpression */ && parent.expression === node || - parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node && + return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 161 /* SyntaxKind.QualifiedName */ || + parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node || + parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { - return type.flags & 2097152 /* Intersection */ ? + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isGenericTypeWithUnionConstraint) : - !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */)); } function isGenericTypeWithoutNullableConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* TypeFlags.Nullable */)); } function hasContextualTypeWithNoGenericTypes(node, checkMode) { // Computing the contextual type for a child of a JSX element involves resolving the type of the @@ -72168,9 +72419,9 @@ var ts; // as we want the type of a rest element to be generic when possible. var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && - (checkMode && checkMode & 64 /* RestBindingElement */ ? - getContextualType(node, 8 /* SkipBindingPatterns */) - : getContextualType(node)); + (checkMode && checkMode & 64 /* CheckMode.RestBindingElement */ ? + getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) + : getContextualType(node, /*contextFlags*/ undefined)); return contextualType && !isGenericType(contextualType); } function getNarrowableTypeForReference(type, reference, checkMode) { @@ -72181,7 +72432,7 @@ var ts; // control flow analysis an opportunity to narrow it further. For example, for a reference of a type // parameter type 'T extends string | undefined' with a contextual type 'string', we substitute // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. - var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && + var substituteConstraints = !(checkMode && checkMode & 2 /* CheckMode.Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode)); return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type; @@ -72202,9 +72453,9 @@ var ts; }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled // (because the const enum value will not be inlined), or if (2) the alias is an export // of a const enum declaration that will be preserved. @@ -72247,16 +72498,16 @@ var ts; // destructuring from the narrowed parent type. if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { var parent = declaration.parent.parent; - if (parent.kind === 254 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 164 /* Parameter */) { + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || parent.kind === 164 /* SyntaxKind.Parameter */) { var links = getNodeLinks(parent); - if (!(links.flags & 268435456 /* InCheckIdentifier */)) { - links.flags |= 268435456 /* InCheckIdentifier */; - var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */); - links.flags &= ~268435456 /* InCheckIdentifier */; - if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 164 /* Parameter */ && isSymbolAssigned(symbol))) { + if (!(links.flags & 268435456 /* NodeCheckFlags.InCheckIdentifier */)) { + links.flags |= 268435456 /* NodeCheckFlags.InCheckIdentifier */; + var parentType = getTypeForBindingElementParent(parent, 0 /* CheckMode.Normal */); + links.flags &= ~268435456 /* NodeCheckFlags.InCheckIdentifier */; + if (parentType && parentType.flags & 1048576 /* TypeFlags.Union */ && !(parent.kind === 164 /* SyntaxKind.Parameter */ && isSymbolAssigned(symbol))) { var pattern = declaration.parent; var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode); - if (narrowedType.flags & 131072 /* Never */) { + if (narrowedType.flags & 131072 /* TypeFlags.Never */) { return neverType; } return getBindingElementTypeFromParentType(declaration, narrowedType); @@ -72290,7 +72541,7 @@ var ts; var contextualSignature = getContextualSignature(func); if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) { var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0])); - if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { + if (restType.flags & 1048576 /* TypeFlags.Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode); var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0); return getIndexedAccessType(narrowedType, getNumberLiteralType(index)); @@ -72321,20 +72572,18 @@ var ts; return errorType; } var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 214 /* ArrowFunction */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } - else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { + else if (ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; + getNodeLinks(container).flags |= 8192 /* NodeCheckFlags.CaptureArguments */; return getTypeOfSymbol(symbol); } - // We should only mark aliases as referenced if there isn't a local value declaration - // for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that - if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) { + if (shouldMarkIdentifierAliasReferenced(node)) { markAliasReferenced(symbol, node); } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); @@ -72343,32 +72592,32 @@ var ts; addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (declaration && localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 257 /* ClassDeclaration */ + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { if (container === declaration && container.name !== node) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; break; } container = ts.getContainingClass(container); } } - else if (declaration.kind === 226 /* ClassExpression */) { + else if (declaration.kind === 226 /* SyntaxKind.ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 305 /* SourceFile */) { + while (container.kind !== 305 /* SyntaxKind.SourceFile */) { if (container.parent === declaration) { if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; } break; } @@ -72380,19 +72629,19 @@ var ts; var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { - if (!(localOrExportSymbol.flags & 3 /* Variable */) && - !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum - : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class - : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace - : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function - : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import + if (!(localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) && + !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* SymbolFlags.ValueModule */)) { + var assignmentError = localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 /* SymbolFlags.Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { - if (localOrExportSymbol.flags & 3 /* Variable */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol)); } else { @@ -72401,11 +72650,11 @@ var ts; return errorType; } } - var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; + var isAlias = localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */; // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (localOrExportSymbol.flags & 3 /* Variable */) { - if (assignmentKind === 1 /* Definite */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { + if (assignmentKind === 1 /* AssignmentKind.Definite */) { return type; } } @@ -72422,17 +72671,17 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* SyntaxKind.Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - var isModuleExports = symbol.flags & 134217728 /* ModuleExports */; + var isModuleExports = symbol.flags & 134217728 /* SymbolFlags.ModuleExports */; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* FunctionExpression */ || - flowContainer.kind === 214 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* SyntaxKind.FunctionExpression */ || + flowContainer.kind === 214 /* SyntaxKind.ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -72440,11 +72689,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) || - node.parent.kind === 230 /* NonNullExpression */ || - declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 16777216 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) || + node.parent.kind === 230 /* SyntaxKind.NonNullExpression */ || + declaration.kind === 254 /* SyntaxKind.VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 16777216 /* NodeFlags.Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -72468,6 +72717,25 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function shouldMarkIdentifierAliasReferenced(node) { + var _a; + var parent = node.parent; + if (parent) { + // A property access expression LHS? checkPropertyAccessExpression will handle that. + if (ts.isPropertyAccessExpression(parent) && parent.expression === node) { + return false; + } + // Next two check for an identifier inside a type only export. + if (ts.isExportSpecifier(parent) && parent.isTypeOnly) { + return false; + } + var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent; + if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) { + return false; + } + } + return true; + } function isInsideFunctionOrInstancePropertyInitializer(node, threshold) { return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); }); } @@ -72478,11 +72746,11 @@ var ts; return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); }); } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES2015 */ || - (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || + (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 32 /* SymbolFlags.Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 292 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 292 /* SyntaxKind.CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -72497,12 +72765,12 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); - links.flags |= 131072 /* ContainsCapturedBlockScopeBinding */; + links.flags |= 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */; var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []); ts.pushIfUnique(capturedBindings, symbol); if (part === container.initializer) { @@ -72512,22 +72780,22 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { - getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; + getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */; } } // set 'declared inside loop' bit on the block-scoped binding - getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } if (isCaptured) { - getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; } } function isBindingCapturedByNode(node, decl) { @@ -72537,7 +72805,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 212 /* ParenthesizedExpression */) { + while (current.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -72545,9 +72813,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 219 /* PrefixUnaryExpression */ || current.parent.kind === 220 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || current.parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || expr.operator === 46 /* SyntaxKind.MinusMinusToken */; } if (!isAssigned) { return false; @@ -72557,13 +72825,13 @@ var ts; return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 167 /* PropertyDeclaration */ || container.kind === 171 /* Constructor */) { + getNodeLinks(node).flags |= 2 /* NodeCheckFlags.LexicalThis */; + if (container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || container.kind === 171 /* SyntaxKind.Constructor */) { var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + getNodeLinks(classNode).flags |= 4 /* NodeCheckFlags.CaptureThis */; } else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; + getNodeLinks(container).flags |= 4 /* NodeCheckFlags.CaptureThis */; } } function findFirstSuperCall(node) { @@ -72605,36 +72873,36 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 171 /* Constructor */) { + if (container.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 214 /* ArrowFunction */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } // When targeting es6, mark that we'll need to capture `this` in its lexically bound scope. - if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { + if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ScriptTarget.ES2015 */) { captureLexicalThis(node, container); } var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); @@ -72669,7 +72937,7 @@ var ts; var className = getClassNameFromPrototypeMethod(container); if (isInJS && className) { var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* SymbolFlags.Function */)) { thisType = getDeclaredTypeOfSymbol(classSymbol).thisType; } } @@ -72717,9 +72985,9 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 213 /* FunctionExpression */ && + if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isBinaryExpression(container.parent) && - ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' return container.parent // x.prototype.y = container .left // x.prototype.y @@ -72727,31 +72995,31 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 169 /* MethodDeclaration */ && - container.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && + container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 213 /* FunctionExpression */ && - container.parent.kind === 296 /* PropertyAssignment */ && - container.parent.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && + container.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && + container.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.parent.left.expression; } // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 213 /* FunctionExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && ts.isObjectLiteralExpression(container.parent.parent) && ts.isCallExpression(container.parent.parent.parent) && container.parent.parent.parent.arguments[2] === container.parent.parent && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.parent.arguments[0].expression; } // Object.defineProperty(x, "method", { value() { } }); @@ -72763,17 +73031,17 @@ var ts; ts.isObjectLiteralExpression(container.parent) && ts.isCallExpression(container.parent.parent) && container.parent.parent.arguments[2] === container.parent && - ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.arguments[0].expression; } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 317 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 317 /* SyntaxKind.JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && - jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) { + jsDocFunctionType.parameters[0].name.escapedText === "this" /* InternalSymbolName.This */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -72783,18 +73051,18 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* SyntaxKind.Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 208 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 208 /* SyntaxKind.CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 214 /* ArrowFunction */) { + while (container && container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; + needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -72805,14 +73073,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* ComputedPropertyName */; }); - if (current && current.kind === 162 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* SyntaxKind.ComputedPropertyName */; }); + if (current && current.kind === 162 /* SyntaxKind.ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -72820,26 +73088,26 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 171 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.isStatic(container) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; + nodeCheckFlag = 512 /* NodeCheckFlags.SuperStatic */; if (!isCallExpression && - languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && + languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && (ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) { // for `super.x` or `super[x]` in a static initializer, mark all enclosing // block scope containers so that we can report potential collisions with // `Reflect`. ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) { if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) { - getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */; + getNodeLinks(current).flags |= 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */; } }); } } else { - nodeCheckFlag = 256 /* SuperInstance */; + nodeCheckFlag = 256 /* NodeCheckFlags.SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. @@ -72901,12 +73169,12 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 169 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { - getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */; } else { - getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */; } } if (needToCaptureLexicalThis) { @@ -72915,8 +73183,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 205 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES2015 */) { + if (container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; } @@ -72936,12 +73204,12 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 171 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 171 /* SyntaxKind.Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } - return nodeCheckFlag === 512 /* SuperStatic */ + return nodeCheckFlag === 512 /* NodeCheckFlags.SuperStatic */ ? getBaseConstructorTypeOfClass(classType) : getTypeWithThisArgument(baseClassType, classType.thisType); function isLegalUsageOfSuperExpression(container) { @@ -72951,7 +73219,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 171 /* Constructor */; + return container.kind === 171 /* SyntaxKind.Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -72959,23 +73227,23 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { if (ts.isStatic(container)) { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 170 /* ClassStaticBlockDeclaration */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } else { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 166 /* PropertySignature */ || - container.kind === 171 /* Constructor */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 166 /* SyntaxKind.PropertySignature */ || + container.kind === 171 /* SyntaxKind.Constructor */; } } } @@ -72983,22 +73251,22 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 169 /* MethodDeclaration */ || - func.kind === 172 /* GetAccessor */ || - func.kind === 173 /* SetAccessor */) && func.parent.kind === 205 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 213 /* FunctionExpression */ && func.parent.kind === 296 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ || + func.kind === 172 /* SyntaxKind.GetAccessor */ || + func.kind === 173 /* SyntaxKind.SetAccessor */) && func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ? func.parent : + func.kind === 213 /* SyntaxKind.FunctionExpression */ && func.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -73017,7 +73285,7 @@ var ts; // We have an object literal method. Check if the containing object literal has a contextual type // that includes a ThisType. If so, T is the contextual type for 'this'. We continue looking in // any directly enclosing object literals. - var contextualType = getApparentTypeOfContextualType(containingLiteral); + var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined); var literal = containingLiteral; var type = contextualType; while (type) { @@ -73025,11 +73293,11 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 296 /* PropertyAssignment */) { + if (literal.parent.kind !== 296 /* SyntaxKind.PropertyAssignment */) { break; } literal = literal.parent.parent; - type = getApparentTypeOfContextualType(literal); + type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined); } // There was no contextual ThisType for the containing object literal, so the contextual type // for 'this' is the non-null form of the contextual type for the containing object literal or @@ -73039,7 +73307,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -73067,7 +73335,7 @@ var ts; var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* Normal */); + return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; @@ -73086,31 +73354,31 @@ var ts; tryGetTypeAtPosition(contextualSignature, index); } } - function getContextualTypeForVariableLikeDeclaration(declaration) { + function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) { var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); if (typeNode) { return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return getContextuallyTypedParameterType(declaration); - case 203 /* BindingElement */: - return getContextualTypeForBindingElement(declaration); - case 167 /* PropertyDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + return getContextualTypeForBindingElement(declaration, contextFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isStatic(declaration)) { - return getContextualTypeForStaticPropertyDeclaration(declaration); + return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags); } // By default, do nothing and return undefined - only the above cases have context implied by a parent } } - function getContextualTypeForBindingElement(declaration) { + function getContextualTypeForBindingElement(declaration, contextFlags) { var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */); + var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || + parent.kind !== 203 /* SyntaxKind.BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 202 /* ArrayBindingPattern */) { + if (parent.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -73122,8 +73390,8 @@ var ts; return getTypeOfPropertyOfType(parentType, text); } } - function getContextualTypeForStaticPropertyDeclaration(declaration) { - var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent); + function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) { + var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags); if (!parentType) return undefined; return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName); @@ -73139,32 +73407,35 @@ var ts; function getContextualTypeForInitializerExpression(node, contextFlags) { var declaration = node.parent; if (ts.hasInitializer(declaration) && node === declaration.initializer) { - var result = getContextualTypeForVariableLikeDeclaration(declaration); + var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags); if (result) { return result; } - if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) { + if (!(contextFlags & 8 /* ContextFlags.SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) { return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } } return undefined; } - function getContextualTypeForReturnExpression(node) { + function getContextualTypeForReturnExpression(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); - if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function - var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; - var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined); - if (!iterationTypes) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { // Generator or AsyncGenerator function + var isAsyncGenerator_1 = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + if (contextualReturnType.flags & 1048576 /* TypeFlags.Union */) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, type, isAsyncGenerator_1); }); + } + var iterationReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, contextualReturnType, (functionFlags & 2 /* FunctionFlags.Async */) !== 0); + if (!iterationReturnType) { return undefined; } - contextualReturnType = iterationTypes.returnType; + contextualReturnType = iterationReturnType; // falls through to unwrap Promise for AsyncGenerators } - if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function + if (functionFlags & 2 /* FunctionFlags.Async */) { // Async function or AsyncGenerator function // Get the awaited type without the `Awaited` alias var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); @@ -73182,15 +73453,19 @@ var ts; } return undefined; } - function getContextualTypeForYieldOperand(node) { + function getContextualTypeForYieldOperand(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { var functionFlags = ts.getFunctionFlags(func); - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { + var isAsyncGenerator_2 = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + if (!node.asteriskToken && contextualReturnType.flags & 1048576 /* TypeFlags.Union */) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, type, isAsyncGenerator_2); }); + } return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, contextualReturnType, isAsyncGenerator_2); } } return undefined; @@ -73209,15 +73484,15 @@ var ts; return false; } function getContextualIterationType(kind, functionDecl) { - var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); - var contextualReturnType = getContextualReturnType(functionDecl); + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* FunctionFlags.Async */); + var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) || undefined; } return undefined; } - function getContextualReturnType(functionDecl) { + function getContextualReturnType(functionDecl, contextFlags) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed var returnType = getReturnTypeFromAnnotation(functionDecl); @@ -73232,7 +73507,7 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl); if (iife) { - return getContextualType(iife); + return getContextualType(iife, contextFlags); } return undefined; } @@ -73256,11 +73531,11 @@ var ts; } var restIndex = signature.parameters.length - 1; return signatureHasRestParameter(signature) && argIndex >= restIndex ? - getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) : getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 210 /* TaggedTemplateExpression */) { + if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -73269,13 +73544,13 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 63 /* EqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -73284,8 +73559,8 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: return undefined; @@ -73306,6 +73581,14 @@ var ts; var lhsType = getTypeOfExpression(e.expression); return ts.isPrivateIdentifier(e.name) ? tryGetPrivateIdentifierPropertyOfType(lhsType, e.name) : getPropertyOfType(lhsType, e.name.escapedText); } + if (ts.isElementAccessExpression(e)) { + var propType = checkExpressionCached(e.argumentExpression); + if (!isTypeUsableAsPropertyName(propType)) { + return undefined; + } + var lhsType = getTypeOfExpression(e.expression); + return getPropertyOfType(lhsType, getPropertyNameFromType(propType)); + } return undefined; function tryGetPrivateIdentifierPropertyOfType(type, id) { var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(id.escapedText, id); @@ -73318,8 +73601,8 @@ var ts; var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { - case 0 /* None */: - case 4 /* ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var lhsSymbol = getSymbolForExpression(binaryExpression.left); var decl = lhsSymbol && lhsSymbol.valueDeclaration; // Unannotated, uninitialized property declarations have a type implied by their usage in the constructor. @@ -73329,11 +73612,11 @@ var ts; return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || (ts.isPropertyDeclaration(decl) ? decl.initializer && getTypeOfExpression(binaryExpression.left) : undefined); } - if (kind === 0 /* None */) { + if (kind === 0 /* AssignmentDeclarationKind.None */) { return getTypeOfExpression(binaryExpression.left); } return getContextualTypeForThisPropertyAssignment(binaryExpression); - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { return getContextualTypeForThisPropertyAssignment(binaryExpression); } @@ -73354,7 +73637,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* SymbolFlags.Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated_1) { @@ -73368,18 +73651,18 @@ var ts; } return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left); } - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; // falls through - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration); var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration); return annotated ? getTypeFromTypeNode(annotated) : undefined; - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); @@ -73387,14 +73670,14 @@ var ts; } function isPossiblyAliasedThisProperty(declaration, kind) { if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); } - if (kind === 4 /* ThisProperty */) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */) { return true; } - if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) { + if (!ts.isInJSFile(declaration) || kind !== 5 /* AssignmentDeclarationKind.Property */ || !ts.isIdentifier(declaration.left.expression)) { return false; } var name = declaration.left.expression.escapedText; - var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); + var symbol = resolveName(declaration.left, name, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } function getContextualTypeForThisPropertyAssignment(binaryExpression) { @@ -73418,11 +73701,11 @@ var ts; return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined; } function isCircularMappedProperty(symbol) { - return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0); + return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0); } function getTypeOfPropertyOfContextualType(type, name, nameType) { return mapType(type, function (t) { - if (t.flags & 2097152 /* Intersection */) { + if (t.flags & 2097152 /* TypeFlags.Intersection */) { var intersection = t; var newTypes = ts.mapDefined(intersection.types, getTypeOfConcretePropertyOfContextualType); if (newTypes.length > 0) { @@ -73450,7 +73733,7 @@ var ts; } return undefined; } - if (t.flags & 3670016 /* StructuredType */) { + if (t.flags & 3670016 /* TypeFlags.StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop); @@ -73466,7 +73749,7 @@ var ts; } function getTypeOfApplicableIndexInfoOfContextualType(t) { var _a; - if (!(t.flags & 3670016 /* StructuredType */)) { + if (!(t.flags & 3670016 /* TypeFlags.StructuredType */)) { return undefined; } return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type; @@ -73477,7 +73760,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -73485,7 +73768,7 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; - var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags); if (propertyAssignmentType) { return propertyAssignmentType; } @@ -73512,7 +73795,7 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, + || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* IterationUse.Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, /*noReductions*/ true)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -73520,8 +73803,8 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined; } - function getContextualTypeForChildJsxExpression(node, child) { - var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName); + function getContextualTypeForChildJsxExpression(node, child, contextFlags) { + var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags); // JSX expression is in children of JSX Element, we will look for an "children" attribute (we get the name from JSX.ElementAttributesProperty) var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) { @@ -73539,27 +73822,27 @@ var ts; } }, /*noReductions*/ true)); } - function getContextualTypeForJsxExpression(node) { + function getContextualTypeForJsxExpression(node, contextFlags) { var exprParent = node.parent; return ts.isJsxAttributeLike(exprParent) - ? getContextualType(node) + ? getContextualType(node, contextFlags) : ts.isJsxElement(exprParent) - ? getContextualTypeForChildJsxExpression(exprParent, node) + ? getContextualTypeForChildJsxExpression(exprParent, node, contextFlags) : undefined; } - function getContextualTypeForJsxAttribute(attribute) { + function getContextualTypeForJsxAttribute(attribute, contextFlags) { // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type // which is a type of the parameter of the signature we are trying out. // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName if (ts.isJsxAttribute(attribute)) { - var attributesType = getApparentTypeOfContextualType(attribute.parent); + var attributesType = getApparentTypeOfContextualType(attribute.parent, contextFlags); if (!attributesType || isTypeAny(attributesType)) { return undefined; } return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { - return getContextualType(attribute.parent); + return getContextualType(attribute.parent, contextFlags); } } // Return true if the given expression is possibly a discriminant value. We limit the kinds of @@ -73567,29 +73850,29 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 79 /* Identifier */: - case 153 /* UndefinedKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 153 /* SyntaxKind.UndefinedKeyword */: return true; - case 206 /* PropertyAccessExpression */: - case 212 /* ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* SyntaxKind.JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -73598,21 +73881,21 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* ContextFlags.NoConstraints */ && instantiatedType.flags & 8650752 /* TypeFlags.TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : - apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + return apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing // return type inferences is available, instantiate those types using that mapper. function instantiateContextualType(contextualType, node, contextFlags) { - if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) { + if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) { var inferenceContext = getInferenceContext(node); // If no inferences have been made, nothing is gained from instantiating as type parameters // would just be replaced with their defaults similar to the apparent type. - if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { + if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { // For contextual signatures we incorporate all inferences made so far, e.g. from return // types as well as arguments to the left in a function call. return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); @@ -73623,7 +73906,7 @@ var ts; // the 'boolean' type from the contextual type such that contextually typed boolean // literals actually end up widening to 'boolean' (see #48363). var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); - return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? + return type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : type; } @@ -73634,13 +73917,13 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { return instantiateType(type, mapper); } - if (type.flags & 1048576 /* Union */) { - return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* None */); + if (type.flags & 1048576 /* TypeFlags.Union */) { + return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* UnionReduction.None */); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); })); } return type; @@ -73663,7 +73946,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -73672,65 +73955,65 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 214 /* ArrowFunction */: - case 247 /* ReturnStatement */: - return getContextualTypeForReturnExpression(node); - case 224 /* YieldExpression */: - return getContextualTypeForYieldOperand(parent); - case 218 /* AwaitExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 247 /* SyntaxKind.ReturnStatement */: + return getContextualTypeForReturnExpression(node, contextFlags); + case 224 /* SyntaxKind.YieldExpression */: + return getContextualTypeForYieldOperand(parent, contextFlags); + case 218 /* SyntaxKind.AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return getContextualTypeForArgument(parent, node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 204 /* ArrayLiteralExpression */: { + case 204 /* SyntaxKind.ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 233 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 223 /* TemplateExpression */); + case 233 /* SyntaxKind.TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 223 /* SyntaxKind.TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return !tag ? getContextualType(parent, contextFlags) : ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(tag.typeExpression.type); } - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return getContextualType(parent, contextFlags); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return tryGetTypeFromEffectiveTypeNode(parent); - case 288 /* JsxExpression */: - return getContextualTypeForJsxExpression(parent); - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - return getContextualTypeForJsxAttribute(parent); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + return getContextualTypeForJsxExpression(parent, contextFlags); + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + return getContextualTypeForJsxAttribute(parent, contextFlags); + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; function tryFindWhenConstTypeReference(node) { - return getContextualType(node); + return getContextualType(node, contextFlags); } } function getInferenceContext(node) { @@ -73738,7 +74021,7 @@ var ts; return ancestor && ancestor.inferenceContext; } function getContextualJsxElementAttributesType(node, contextFlags) { - if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) { + if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* ContextFlags.Completions */) { // Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit // _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type // (as below) instead! @@ -73747,7 +74030,7 @@ var ts; return getContextualTypeForArgumentAtIndex(node, 0); } function getEffectiveFirstArgumentForJsxSignature(signature, node) { - return getJsxReferenceKind(node) !== 0 /* Component */ + return getJsxReferenceKind(node) !== 0 /* JsxReferenceKind.Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } @@ -73792,7 +74075,7 @@ var ts; return getOrCreateTypeFromSignature(fakeSignature); } var tagType = checkExpressionCached(context.tagName); - if (tagType.flags & 128 /* StringLiteral */) { + if (tagType.flags & 128 /* TypeFlags.StringLiteral */) { var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); if (!result) { return errorType; @@ -73807,7 +74090,7 @@ var ts; if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); - if (managedSym.flags & 524288 /* TypeAlias */) { + if (managedSym.flags & 524288 /* SymbolFlags.TypeAlias */) { var params = getSymbolLinks(managedSym).typeParameters; if (ts.length(params) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); @@ -73908,12 +74191,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -73935,18 +74218,18 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 2097152 /* Intersection */; - result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 2097152 /* TypeFlags.Intersection */; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. function getContextualCallSignature(type, node) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } @@ -73976,16 +74259,16 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */); if (!type) { return undefined; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -74014,38 +74297,38 @@ var ts; } } function checkSpreadExpression(node, checkMode) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); + return checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, arrayOrIterableType, undefinedType, node.expression); } function checkSyntheticExpression(node) { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 203 /* BindingElement */ && !!node.initializer) || - (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); + return (node.kind === 203 /* SyntaxKind.BindingElement */ && !!node.initializer) || + (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; var elementCount = elements.length; var elementTypes = []; var elementFlags = []; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined); var inDestructuringPattern = ts.isAssignmentTarget(node); var inConstContext = isConstContext(node); var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 225 /* SpreadElement */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var spreadType = checkExpression(e.expression, checkMode, forceTuple); if (isArrayLikeType(spreadType)) { elementTypes.push(spreadType); - elementFlags.push(8 /* Variadic */); + elementFlags.push(8 /* ElementFlags.Variadic */); } else if (inDestructuringPattern) { // Given the following situation: @@ -74061,27 +74344,27 @@ var ts; // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. var restElementType = getIndexTypeOfType(spreadType, numberType) || - getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || + getIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || unknownType; elementTypes.push(restElementType); - elementFlags.push(4 /* Rest */); + elementFlags.push(4 /* ElementFlags.Rest */); } else { - elementTypes.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, e.expression)); - elementFlags.push(4 /* Rest */); + elementTypes.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, e.expression)); + elementFlags.push(4 /* ElementFlags.Rest */); } } - else if (exactOptionalPropertyTypes && e.kind === 227 /* OmittedExpression */) { + else if (exactOptionalPropertyTypes && e.kind === 227 /* SyntaxKind.OmittedExpression */) { hasOmittedExpression = true; elementTypes.push(missingType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); - elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); - if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) { + elementFlags.push(hasOmittedExpression ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */); + if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && isContextSensitive(e)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context addIntraExpressionInferenceSite(inferenceContext, e, type); @@ -74095,28 +74378,28 @@ var ts; return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? - getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* Subtype */) : + getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* UnionReduction.Subtype */) : strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext)); } function createArrayLiteralType(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */)) { return type; } var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 16384 /* ArrayLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 16384 /* ObjectFlags.ArrayLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return isNumericComputedName(name); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isNumericLiteralName(name.escapedText); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return ts.isNumericLiteralName(name.text); default: return false; @@ -74125,14 +74408,14 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* TypeFlags.NumberLike */); } function checkComputedPropertyName(node) { var links = getNodeLinks(node.expression); if (!links.resolvedType) { if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent)) - && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */ - && node.parent.kind !== 172 /* GetAccessor */ && node.parent.kind !== 173 /* SetAccessor */) { + && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ + && node.parent.kind !== 172 /* SyntaxKind.GetAccessor */ && node.parent.kind !== 173 /* SyntaxKind.SetAccessor */) { return links.resolvedType = errorType; } links.resolvedType = checkExpression(node.expression); @@ -74143,17 +74426,17 @@ var ts; var enclosingIterationStatement = getEnclosingIterationStatement(container); if (enclosingIterationStatement) { // The computed field name will use a block scoped binding which can be unique for each iteration of the loop. - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; // The generated variable which stores the computed field name must be block-scoped. - getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; // The generated variable which stores the class must be block-scoped. - getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node.parent.parent).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } } // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 98304 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* TypeFlags.Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -74169,7 +74452,7 @@ var ts; var _a; var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) && - isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */)); + isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* TypeFlags.ESSymbol */)); } function getObjectLiteralIndexInfo(node, offset, properties, keyType) { var propTypes = []; @@ -74181,11 +74464,11 @@ var ts; propTypes.push(getTypeOfSymbol(properties[i])); } } - var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType; + var unionType = propTypes.length ? getUnionType(propTypes, 2 /* UnionReduction.Subtype */) : undefinedType; return createIndexInfo(keyType, unionType, isConstContext(node)); } function getImmediateAliasedSymbol(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); @@ -74203,11 +74486,11 @@ var ts; var propertiesTable = ts.createSymbolTable(); var propertiesArray = []; var spread = emptyObjectType; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* SyntaxKind.ObjectLiteralExpression */); var inConstContext = isConstContext(node); - var checkFlags = inConstContext ? 8 /* Readonly */ : 0; + var checkFlags = inConstContext ? 8 /* CheckFlags.Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -74229,16 +74512,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 296 /* PropertyAssignment */ || - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 296 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -74250,29 +74533,29 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 458752 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 458752 /* ObjectFlags.PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? - createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : - createSymbol(4 /* Property */ | member.flags, member.escapedName, checkFlags); + createSymbol(4 /* SymbolFlags.Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* CheckFlags.Late */) : + createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName, checkFlags); if (nameType) { prop.nameType = nameType; } if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 296 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 297 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 16777216 /* Optional */; + prop.flags |= 16777216 /* SymbolFlags.Optional */; } } - else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.escapedName); if (impliedProp) { - prop.flags |= impliedProp.flags & 16777216 /* Optional */; + prop.flags |= impliedProp.flags & 16777216 /* SymbolFlags.Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -74287,17 +74570,17 @@ var ts; prop.target = member; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); - if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && - (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) { + if (contextualType && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && + (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || memberDecl.kind === 169 /* SyntaxKind.MethodDeclaration */) && isContextSensitive(memberDecl)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context - var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl; + var inferenceNode = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? memberDecl.initializer : memberDecl; addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type); } } - else if (memberDecl.kind === 298 /* SpreadAssignment */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + else if (memberDecl.kind === 298 /* SyntaxKind.SpreadAssignment */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(memberDecl, 2 /* ExternalEmitHelpers.Assign */); } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -74331,10 +74614,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 172 /* GetAccessor */ || memberDecl.kind === 173 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 172 /* SyntaxKind.GetAccessor */ || memberDecl.kind === 173 /* SyntaxKind.SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -74359,11 +74642,11 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 298 /* SyntaxKind.SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { - if (!(prop.flags & 16777216 /* Optional */)) { + if (!(prop.flags & 16777216 /* SymbolFlags.Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } propertiesTable.set(prop.escapedName, prop); @@ -74395,12 +74678,12 @@ var ts; if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType)); var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 4096 /* JSLiteral */; + result.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; } if (patternWithComputedProperties) { - result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; } if (inDestructuringPattern) { result.pattern = node; @@ -74410,8 +74693,8 @@ var ts; } function isValidSpreadType(type) { var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType)); - return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || - t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); + return !!(t.flags & (1 /* TypeFlags.Any */ | 67108864 /* TypeFlags.NonPrimitive */ | 524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + t.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); @@ -74457,7 +74740,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* SyntaxKind.Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -74481,15 +74764,15 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 2048 /* JsxAttributes */; + var objectFlags = 2048 /* ObjectFlags.JsxAttributes */; var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { var attributeDecl = _a[_i]; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); - objectFlags |= ts.getObjectFlags(exprType) & 458752 /* PropagatingFlags */; - var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); + objectFlags |= ts.getObjectFlags(exprType) & 458752 /* ObjectFlags.PropagatingFlags */; + var attributeSymbol = createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; if (member.valueDeclaration) { @@ -74504,7 +74787,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 287 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 287 /* SyntaxKind.JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -74531,7 +74814,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 278 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 278 /* SyntaxKind.JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -74542,10 +74825,10 @@ var ts; if (explicitlySpecifyChildrenAttribute) { error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName)); } - var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); + var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process - var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); + var childrenPropSymbol = createSymbol(4 /* SymbolFlags.Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); @@ -74573,7 +74856,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return result; } } @@ -74583,12 +74866,12 @@ var ts; var child = _a[_i]; // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that // because then type of children property will have constituent of string type. - if (child.kind === 11 /* JsxText */) { + if (child.kind === 11 /* SyntaxKind.JsxText */) { if (!child.containsOnlyTriviaWhiteSpaces) { childrenTypes.push(stringType); } } - else if (child.kind === 288 /* JsxExpression */ && !child.expression) { + else if (child.kind === 288 /* SyntaxKind.JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -74600,7 +74883,7 @@ var ts; function checkSpreadPropOverrides(type, props, spread) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var right = _a[_i]; - if (!(right.flags & 16777216 /* Optional */)) { + if (!(right.flags & 16777216 /* SymbolFlags.Optional */)) { var left = props.get(right.escapedName); if (left) { var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); @@ -74620,7 +74903,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* SymbolFlags.Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -74639,13 +74922,13 @@ var ts; return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; + links.jsxFlags |= 1 /* JsxFlags.IntrinsicNamedElement */; return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + links.jsxFlags |= 2 /* JsxFlags.IntrinsicIndexedElement */; return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found @@ -74694,10 +74977,10 @@ var ts; var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location); if (!resolvedNamespace || resolvedNamespace === unknownSymbol) { var namespaceName = getJsxNamespace(location); - resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + resolvedNamespace = resolveName(location, namespaceName, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); } if (resolvedNamespace) { - var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */)); + var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* SymbolFlags.Namespace */)); if (candidate && candidate !== unknownSymbol) { if (links) { links.jsxNamespace = candidate; @@ -74710,7 +74993,7 @@ var ts; } } // JSX global fallback - var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined)); + var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined)); if (s === unknownSymbol) { return undefined; // TODO: GH#18217 } @@ -74725,7 +75008,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* SymbolFlags.Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -74749,7 +75032,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* SymbolFlags.Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -74763,10 +75046,10 @@ var ts; return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } function getUninstantiatedJsxSignaturesOfType(elementType, caller) { - if (elementType.flags & 4 /* String */) { + if (elementType.flags & 4 /* TypeFlags.String */) { return [anySignature]; } - else if (elementType.flags & 128 /* StringLiteral */) { + else if (elementType.flags & 128 /* TypeFlags.StringLiteral */) { var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller); if (!intrinsicType) { error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements); @@ -74779,12 +75062,12 @@ var ts; } var apparentElemType = getApparentType(elementType); // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(apparentElemType, 1 /* Construct */); + var signatures = getSignaturesOfType(apparentElemType, 1 /* SignatureKind.Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures - signatures = getSignaturesOfType(apparentElemType, 0 /* Call */); + signatures = getSignaturesOfType(apparentElemType, 0 /* SignatureKind.Call */); } - if (signatures.length === 0 && apparentElemType.flags & 1048576 /* Union */) { + if (signatures.length === 0 && apparentElemType.flags & 1048576 /* TypeFlags.Union */) { // If each member has some combination of new/call signatures; make a union signature list for those signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); })); } @@ -74812,13 +75095,13 @@ var ts; return anyType; } function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { - if (refKind === 1 /* Function */) { + if (refKind === 1 /* JsxReferenceKind.Function */) { var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); if (sfcReturnConstraint) { checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } - else if (refKind === 0 /* Component */) { + else if (refKind === 0 /* JsxReferenceKind.Component */) { var classConstraint = getJsxElementClassTypeAt(openingLikeElement); if (classConstraint) { // Issue an error if this return type isn't assignable to JSX.ElementClass, failing that @@ -74849,10 +75132,10 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + if (links.jsxFlags & 1 /* JsxFlags.IntrinsicNamedElement */) { return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + else if (links.jsxFlags & 2 /* JsxFlags.IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType; } @@ -74886,7 +75169,7 @@ var ts; } function checkJsxPreconditions(errorNode) { // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + if ((compilerOptions.jsx || 0 /* JsxEmit.None */) === 0 /* JsxEmit.None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } if (getJsxElementTypeAt(errorNode) === undefined) { @@ -74904,20 +75187,20 @@ var ts; if (!getJsxNamespaceContainerForImplicitImport(node)) { // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; + var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* JsxEmit.React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var jsxFactoryNamespace = getJsxNamespace(node); var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; // allow null as jsxFragmentFactory var jsxFactorySym = void 0; if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); + jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); } if (jsxFactorySym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not jsxFactory as there wont be error being emitted - jsxFactorySym.isReferenced = 67108863 /* All */; + jsxFactorySym.isReferenced = 67108863 /* SymbolFlags.All */; // If react/jsxFactory symbol is alias, mark it as refereced - if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { + if (jsxFactorySym.flags & 2097152 /* SymbolFlags.Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { markAliasSymbolAsReferenced(jsxFactorySym); } } @@ -74926,7 +75209,7 @@ var ts; var file = ts.getSourceFileOfNode(node); var localJsxNamespace = getLocalJsxNamespace(file); if (localJsxNamespace) { - resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); + resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); } } } @@ -74951,7 +75234,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 524288 /* Object */) { + if (targetType.flags & 524288 /* TypeFlags.Object */) { // For backwards compatibility a symbol-named property is satisfied by a string index signature. This // is incorrect and inconsistent with element access expressions, where it is an error, so eventually // we should remove this exception. @@ -74963,7 +75246,7 @@ var ts; return true; } } - else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { + else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -74974,10 +75257,10 @@ var ts; return false; } function isExcessPropertyCheckTarget(type) { - return !!(type.flags & 524288 /* Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || - type.flags & 67108864 /* NonPrimitive */ || - type.flags & 1048576 /* Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); + return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) || + type.flags & 67108864 /* TypeFlags.NonPrimitive */ || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); } function checkJsxExpression(node, checkMode) { checkGrammarJsxExpression(node); @@ -75000,13 +75283,13 @@ var ts; * Note that this is not tracked well within the compiler, so the answer may be incorrect. */ function isPrototypeProperty(symbol) { - if (symbol.flags & 8192 /* Method */ || ts.getCheckFlags(symbol) & 4 /* SyntheticMethod */) { + if (symbol.flags & 8192 /* SymbolFlags.Method */ || ts.getCheckFlags(symbol) & 4 /* CheckFlags.SyntheticMethod */) { return true; } if (ts.isInJSFile(symbol.valueDeclaration)) { var parent = symbol.valueDeclaration.parent; return parent && ts.isBinaryExpression(parent) && - ts.getAssignmentDeclarationKind(parent) === 3 /* PrototypeProperty */; + ts.getAssignmentDeclarationKind(parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } } /** @@ -75020,9 +75303,9 @@ var ts; function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } var errorNode = !reportError ? undefined : - node.kind === 161 /* QualifiedName */ ? node.right : - node.kind === 200 /* ImportType */ ? node : - node.kind === 203 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + node.kind === 161 /* SyntaxKind.QualifiedName */ ? node.right : + node.kind === 200 /* SyntaxKind.ImportType */ ? node : + node.kind === 203 /* SyntaxKind.BindingElement */ && node.propertyName ? node.propertyName : node.name; return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode); } /** @@ -75045,7 +75328,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { if (errorNode) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -75053,7 +75336,7 @@ var ts; return false; } } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -75065,7 +75348,7 @@ var ts; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + if ((flags & 128 /* ModifierFlags.Abstract */) && symbolHasNonMethodDeclaration(prop) && (ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { @@ -75076,12 +75359,12 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { return true; } // Property is known to be private or protected at this point // Private property is accessible if the property is within the declaring class - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -75108,7 +75391,7 @@ var ts; // static member access is disallowed enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 32 /* ModifierFlags.Static */ || !enclosingClass) { if (errorNode) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } @@ -75116,10 +75399,10 @@ var ts; } } // No further restrictions for static properties - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return true; } - if (containingType.flags & 262144 /* TypeParameter */) { + if (containingType.flags & 262144 /* TypeFlags.TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -75134,10 +75417,10 @@ var ts; function getEnclosingClassFromThisParameter(node) { var thisParameter = getThisParameterFromNodeContext(node); var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type); - if (thisType && thisType.flags & 262144 /* TypeParameter */) { + if (thisType && thisType.flags & 262144 /* TypeFlags.TypeParameter */) { thisType = getConstraintOfTypeParameter(thisType); } - if (thisType && ts.getObjectFlags(thisType) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (thisType && ts.getObjectFlags(thisType) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { return getTargetType(thisType); } return undefined; @@ -75147,39 +75430,39 @@ var ts; return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined; } function symbolHasNonMethodDeclaration(symbol) { - return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); + return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* SymbolFlags.Method */); }); } function checkNonNullExpression(node) { return checkNonNullType(checkExpression(node), node); } function isNullableType(type) { - return !!(getTypeFacts(type) & 50331648 /* IsUndefinedOrNull */); + return !!(getTypeFacts(type) & 50331648 /* TypeFacts.IsUndefinedOrNull */); } function getNonNullableTypeIfNeeded(type) { return isNullableType(type) ? getNonNullableType(type) : type; } function reportObjectPossiblyNullOrUndefinedError(node, facts) { - error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? + error(node, facts & 16777216 /* TypeFacts.IsUndefined */ ? facts & 33554432 /* TypeFacts.IsNull */ ? ts.Diagnostics.Object_is_possibly_null_or_undefined : ts.Diagnostics.Object_is_possibly_undefined : ts.Diagnostics.Object_is_possibly_null); } function reportCannotInvokePossiblyNullOrUndefinedError(node, facts) { - error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? + error(node, facts & 16777216 /* TypeFacts.IsUndefined */ ? facts & 33554432 /* TypeFacts.IsNull */ ? ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); } function checkNonNullTypeWithReporter(type, node, reportError) { - if (strictNullChecks && type.flags & 2 /* Unknown */) { + if (strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } var facts = getTypeFacts(type); - if (facts & 50331648 /* IsUndefinedOrNull */) { + if (facts & 50331648 /* TypeFacts.IsUndefinedOrNull */) { reportError(node, facts); var t = getNonNullableType(type); - return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; + return t.flags & (98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */) ? errorType : t; } return type; } @@ -75188,13 +75471,13 @@ var ts; } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); - if (nonNullType.flags & 16384 /* Void */) { + if (nonNullType.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.Object_is_possibly_undefined); } return nonNullType; } function checkPropertyAccessExpression(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } function checkPropertyAccessChain(node, checkMode) { @@ -75207,7 +75490,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 212 /* ParenthesizedExpression */) { + while (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -75231,7 +75514,7 @@ var ts; if (!ts.isExpressionNode(privId)) { return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression); } - var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* InKeyword */; + var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) { return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId)); } @@ -75303,16 +75586,16 @@ var ts; function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); - var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); + var apparentType = getApparentType(assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { - if (languageVersion < 99 /* ESNext */) { - if (assignmentKind !== 0 /* None */) { - checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + if (assignmentKind !== 0 /* AssignmentKind.None */) { + checkExternalEmitHelpers(node, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } - if (assignmentKind !== 1 /* Definite */) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + if (assignmentKind !== 1 /* AssignmentKind.Definite */) { + checkExternalEmitHelpers(node, 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */); } } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); @@ -75334,8 +75617,8 @@ var ts; return errorType; } else { - var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* AssignmentKind.Definite */) { error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); } } @@ -75347,7 +75630,7 @@ var ts; } return isErrorType(apparentType) ? errorType : apparentType; } - prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === 161 /* QualifiedName */); + prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === 161 /* SyntaxKind.QualifiedName */); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined @@ -75357,13 +75640,13 @@ var ts; // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`. if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || - !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && node.parent.kind === 299 /* EnumMember */)) || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* SymbolFlags.EnumMember */ && node.parent.kind === 299 /* SyntaxKind.EnumMember */)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; if (!prop) { - var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? + var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined; if (!(indexInfo && indexInfo.type)) { var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true); @@ -75371,7 +75654,7 @@ var ts; return anyType; } if (leftType.symbol === globalThisSymbol) { - if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */)) { + if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* SymbolFlags.BlockScoped */)) { error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); } else if (noImplicitAny) { @@ -75391,7 +75674,7 @@ var ts; if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) { error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText)); } - if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) { + if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* NodeFlags.Deprecated */) { addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText); } } @@ -75403,7 +75686,7 @@ var ts; markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; var writing = ts.isWriteAccess(node); - checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 106 /* SyntaxKind.SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; @@ -75422,11 +75705,11 @@ var ts; function isUncheckedJSSuggestion(node, suggestion, excludeClasses) { var file = ts.getSourceFileOfNode(node); if (file) { - if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) { + if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */)) { var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode); return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) - && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */) - && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */); + && !(excludeClasses && suggestion && suggestion.flags & 32 /* SymbolFlags.Class */) + && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */); } } return false; @@ -75436,12 +75719,12 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (assignmentKind === 1 /* Definite */) { - return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + if (assignmentKind === 1 /* AssignmentKind.Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* SymbolFlags.Optional */)); } if (prop && - !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) - && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + !(prop.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */ | 98304 /* SymbolFlags.Accessor */)) + && !(prop.flags & 8192 /* SymbolFlags.Method */ && propType.flags & 1048576 /* TypeFlags.Union */) && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } @@ -75454,12 +75737,12 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isPropertyWithoutInitializer(declaration)) { if (!ts.isStatic(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) { + if (flowContainer.kind === 171 /* SyntaxKind.Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { assumeUninitialized = true; } } @@ -75490,13 +75773,13 @@ var ts; && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* Static */) + && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* ModifierFlags.Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 257 /* ClassDeclaration */ && - node.parent.kind !== 178 /* TypeReference */ && - !(valueDeclaration.flags & 16777216 /* Ambient */) && + else if (valueDeclaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && + node.parent.kind !== 178 /* SyntaxKind.TypeReference */ && + !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -75507,25 +75790,25 @@ var ts; function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 296 /* PropertyAssignment */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 298 /* SpreadAssignment */: - case 162 /* ComputedPropertyName */: - case 233 /* TemplateSpan */: - case 288 /* JsxExpression */: - case 285 /* JsxAttribute */: - case 286 /* JsxAttributes */: - case 287 /* JsxSpreadAttribute */: - case 280 /* JsxOpeningElement */: - case 228 /* ExpressionWithTypeArguments */: - case 291 /* HeritageClause */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 298 /* SyntaxKind.SpreadAssignment */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 233 /* SyntaxKind.TemplateSpan */: + case 288 /* SyntaxKind.JsxExpression */: + case 285 /* SyntaxKind.JsxAttribute */: + case 286 /* SyntaxKind.JsxAttributes */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 291 /* SyntaxKind.HeritageClause */: return false; - case 214 /* ArrowFunction */: - case 238 /* ExpressionStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -75537,7 +75820,7 @@ var ts; * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. */ function isPropertyDeclaredInAncestorClass(prop) { - if (!(prop.parent.flags & 32 /* Class */)) { + if (!(prop.parent.flags & 32 /* SymbolFlags.Class */)) { return false; } var classType = getTypeOfSymbol(prop.parent); @@ -75562,7 +75845,7 @@ var ts; function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { var errorInfo; var relatedInfo; - if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { + if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* TypeFlags.Union */ && !(containingType.flags & 131068 /* TypeFlags.Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) { @@ -75650,7 +75933,7 @@ var ts; } } function getSuggestedSymbolForNonexistentClassMember(name, baseType) { - return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */); + return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* SymbolFlags.ClassMember */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); @@ -75661,7 +75944,7 @@ var ts; } name = ts.idText(name); } - return getSpellingSuggestionForName(name, props, 111551 /* Value */); + return getSpellingSuggestionForName(name, props, 111551 /* SymbolFlags.Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -75669,7 +75952,7 @@ var ts; var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; }) : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; }) : undefined; - return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* Value */); + return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* SymbolFlags.Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -75688,7 +75971,7 @@ var ts; var candidates; if (symbols === globals) { var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1))) - ? createSymbol(524288 /* TypeAlias */, s) + ? createSymbol(524288 /* SymbolFlags.TypeAlias */, s) : undefined; }); candidates = primitives.concat(ts.arrayFrom(symbols.values())); } @@ -75704,7 +75987,7 @@ var ts; return symbolResult && ts.symbolName(symbolResult); } function getSuggestedSymbolForNonexistentModule(name, targetModule) { - return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */); + return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* SymbolFlags.ModuleMember */); } function getSuggestionForNonexistentExport(name, targetModule) { var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule); @@ -75735,7 +76018,7 @@ var ts; return suggestion; } function getSuggestedTypeForNonexistentStringLiteralType(source, target) { - var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); }); + var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); }); return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; }); } /** @@ -75763,7 +76046,7 @@ var ts; if (candidate.flags & meaning) { return candidateName; } - if (candidate.flags & 2097152 /* Alias */) { + if (candidate.flags & 2097152 /* SymbolFlags.Alias */) { var alias = tryResolveAlias(candidate); if (alias && alias.flags & meaning) { return candidateName; @@ -75773,16 +76056,16 @@ var ts; } } function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { - var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; + var valueDeclaration = prop && (prop.flags & 106500 /* SymbolFlags.ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } - var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); + var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* ModifierFlags.Private */); var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } - if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { + if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SymbolFlags.SetAccessor */)) { return; } if (isSelfTypeAccess) { @@ -75792,19 +76075,19 @@ var ts; return; } } - (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; + (ts.getCheckFlags(prop) & 1 /* CheckFlags.Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* SymbolFlags.All */; } function isSelfTypeAccess(name, parent) { - return name.kind === 108 /* ThisKeyword */ + return name.kind === 108 /* SyntaxKind.ThisKeyword */ || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 161 /* SyntaxKind.QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } @@ -75819,7 +76102,7 @@ var ts; * @param property the accessed property's symbol. */ function isValidPropertyAccessForCompletions(node, type, property) { - return isPropertyAccessible(node, node.kind === 206 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, + return isPropertyAccessible(node, node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, /* isWrite */ false, type, property); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } @@ -75859,13 +76142,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 79 /* Identifier */) { + else if (initializer.kind === 79 /* SyntaxKind.Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -75882,13 +76165,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 79 /* Identifier */) { + if (e.kind === 79 /* SyntaxKind.Identifier */) { var symbol = getResolvedSymbol(e); - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 243 /* ForInStatement */ && + if (node.kind === 243 /* SyntaxKind.ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -75902,7 +76185,7 @@ var ts; return false; } function checkIndexedAccess(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkElementAccessChain(node, checkMode) : checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } function checkElementAccessChain(node, checkMode) { @@ -75911,7 +76194,7 @@ var ts; return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } function checkElementAccessExpression(node, exprType, checkMode) { - var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; + var objectType = ts.getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); if (isErrorType(objectType) || objectType === silentNeverType) { @@ -75923,8 +76206,8 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : - 32 /* ExpressionPosition */; + 4 /* AccessFlags.Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* AccessFlags.NoIndexSignatures */ : 0) : + 32 /* AccessFlags.ExpressionPosition */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -75937,13 +76220,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 165 /* Decorator */) { + else if (node.kind !== 165 /* SyntaxKind.Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -76007,16 +76290,16 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 225 /* SpreadElement */ || arg.kind === 232 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } function acceptsVoid(t) { - return !!(t.flags & 16384 /* Void */); + return !!(t.flags & 16384 /* TypeFlags.Void */); } function acceptsVoidUndefinedUnknownOrAny(t) { - return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */)); + return !!(t.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 2 /* TypeFlags.Unknown */ | 1 /* TypeFlags.Any */)); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -76024,9 +76307,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 223 /* TemplateExpression */) { + if (node.template.kind === 223 /* SyntaxKind.TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -76037,11 +76320,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = node.template; - ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 165 /* Decorator */) { + else if (node.kind === 165 /* SyntaxKind.Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -76055,7 +76338,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 209 /* NewExpression */); + ts.Debug.assert(node.kind === 209 /* SyntaxKind.NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -76079,7 +76362,7 @@ var ts; } for (var i = argCount; i < effectiveMinimumArguments; i++) { var type = getTypeAtPosition(signature, i); - if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* TypeFlags.Never */) { return false; } } @@ -76095,20 +76378,20 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false); } function getSingleCallOrConstructSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false) || - getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false) || + getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ false); } function getSingleSignature(type, kind, allowMembers) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) { - if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + if (kind === 0 /* SignatureKind.Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { return resolved.callSignatures[0]; } - if (kind === 1 /* Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + if (kind === 1 /* SignatureKind.Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { return resolved.constructSignatures[0]; } } @@ -76117,12 +76400,12 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) { - var context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes); + var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes); // We clone the inferenceContext to avoid fixing. For example, when the source signature is (x: T) => T[] and // the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any') // for T but leave it possible to later infer '[any]' back to A. var restType = getEffectiveRestType(contextualSignature); - var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); + var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; applyToParameterTypes(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -76130,7 +76413,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 128 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -76158,14 +76441,14 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 165 /* Decorator */) { + if (node.kind !== 165 /* SyntaxKind.Decorator */) { var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }); - var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */); + var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */); if (contextualType) { var inferenceTargetType = getReturnTypeOfSignature(signature); if (couldContainTypeVariables(inferenceTargetType)) { var outerContext = getInferenceContext(node); - var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType; + var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) !== contextualType; // A return type inference from a binding pattern can be used in instantiating the contextual // type of an argument later in inference, but cannot stand on its own as the final return type. // It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`, @@ -76180,7 +76463,7 @@ var ts; // We clone the inference context to avoid disturbing a resolution in progress for an // outer call expression. Effectively we just want a snapshot of whatever has been // inferred for any outer call expression so far. - var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */)); + var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* InferenceFlags.NoDefault */)); var instantiatedType = instantiateType(contextualType, outerMapper); // If the contextual type is a generic function type with a single call signature, we // instantiate the type with its own type parameters and type arguments. This ensures that @@ -76194,7 +76477,7 @@ var ts; getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */); } // Create a type mapper for instantiating generic contextual types using the inferences made // from the return type. We need a separate inference pass here because (a) instantiation of @@ -76209,7 +76492,7 @@ var ts; } var restType = getNonArrayRestType(signature); var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; }); if (info) { info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined; @@ -76222,7 +76505,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */ && !(checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { var paramType = getTypeAtPosition(signature, i); if (couldContainTypeVariables(paramType)) { var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); @@ -76237,10 +76520,10 @@ var ts; return getInferredTypes(context); } function getMutableArrayOrTupleType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : - type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getMutableArrayOrTupleType) : + type.flags & 1 /* TypeFlags.Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, /*readonly*/ false, type.target.labeledElementDeclarations) : - createTupleType([type], [8 /* Variadic */]); + createTupleType([type], [8 /* ElementFlags.Variadic */]); } function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) { if (index >= argCount - 1) { @@ -76248,7 +76531,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 232 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -76258,24 +76541,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 232 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 225 /* SpreadElement */ ? arg.expression : arg)); - flags.push(4 /* Rest */); + types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg)); + flags.push(4 /* ElementFlags.Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */); + var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); - flags.push(1 /* Required */); + flags.push(1 /* ElementFlags.Required */); } - if (arg.kind === 232 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -76305,16 +76588,16 @@ var ts; } function getJsxReferenceKind(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } var tagType = getApparentType(checkExpression(node.tagName)); - if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { - return 0 /* Component */; + if (ts.length(getSignaturesOfType(tagType, 1 /* SignatureKind.Construct */))) { + return 0 /* JsxReferenceKind.Component */; } - if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { - return 1 /* Function */; + if (ts.length(getSignaturesOfType(tagType, 0 /* SignatureKind.Call */))) { + return 1 /* JsxReferenceKind.Function */; } - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. @@ -76339,7 +76622,7 @@ var ts; if (!tagType) { return true; } - var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */); + var tagCallSignatures = getSignaturesOfType(tagType, 0 /* SignatureKind.Call */); if (!ts.length(tagCallSignatures)) { return true; } @@ -76347,12 +76630,12 @@ var ts; if (!factory) { return true; } - var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); + var factorySymbol = resolveEntityName(factory, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); if (!factorySymbol) { return true; } var factoryType = getTypeOfSymbol(factorySymbol); - var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */); + var callSignatures = getSignaturesOfType(factoryType, 0 /* SignatureKind.Call */); if (!ts.length(callSignatures)) { return true; } @@ -76362,7 +76645,7 @@ var ts; for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) { var sig = callSignatures_1[_i]; var firstparam = getTypeAtPosition(sig, 0); - var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */); + var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* SignatureKind.Call */); if (!ts.length(signaturesOfParam)) continue; for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) { @@ -76419,7 +76702,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 209 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -76437,13 +76720,13 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; + var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); @@ -76482,8 +76765,8 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - var expression = node.kind === 208 /* CallExpression */ ? node.expression : - node.kind === 210 /* TaggedTemplateExpression */ ? node.tag : undefined; + var expression = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression : + node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */ ? node.tag : undefined; if (expression) { var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { @@ -76501,17 +76784,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 165 /* Decorator */) { + if (node.kind === 165 /* SyntaxKind.Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -76522,15 +76805,15 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_25 = function (i) { + var _loop_26 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 225 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; var flags = spreadType.target.elementFlags[i]; - var syntheticArg = createSyntheticExpression(arg, flags & 4 /* Rest */ ? createArrayType(t) : t, !!(flags & 12 /* Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + var syntheticArg = createSyntheticExpression(arg, flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t, !!(flags & 12 /* ElementFlags.Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); effectiveArgs_1.push(syntheticArg); }); } @@ -76539,7 +76822,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_25(i); + _loop_26(i); } return effectiveArgs_1; } @@ -76552,30 +76835,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 171 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 171 /* SyntaxKind.Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 167 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && languageVersion !== 0 /* ScriptTarget.ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -76589,17 +76872,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return 1; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return 2; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments - return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 164 /* Parameter */: + return languageVersion === 0 /* ScriptTarget.ES3 */ || signature.parameters.length <= 2 ? 2 : 3; + case 164 /* SyntaxKind.Parameter */: return 3; default: return ts.Debug.fail(); @@ -76633,7 +76916,7 @@ var ts; function isPromiseResolveArityError(node) { if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression)) return false; - var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); + var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, undefined, undefined, false); var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { return false; @@ -76741,15 +77024,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 210 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 165 /* Decorator */; + var isTaggedTemplate = node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; + var isDecorator = node.kind === 165 /* SyntaxKind.Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; - if (!isDecorator) { + if (!isDecorator && !ts.isSuperCall(node)) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -76776,8 +77059,8 @@ var ts; // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; - var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */; - argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */; + var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* CheckMode.SkipContextSensitive */ : 0 /* CheckMode.Normal */; + argCheckMode |= checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; // The following variables are captured and modified by calls to chooseOverload. // If overload resolution or type argument inference fails, we want to report the // best error possible. The best error is one which says that an argument was not @@ -76805,7 +77088,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 208 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* CheckMode.IsForSignatureHelp */) && node.kind === 208 /* SyntaxKind.CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -76825,6 +77108,15 @@ var ts; if (result) { return result; } + result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + // Preemptively cache the result; getResolvedSignature will do this after we return, but + // we need to ensure that the result is present for the error checks below so that if + // this signature is encountered again, we handle the circularity (rather than producing a + // different result which may produce no errors and assert). Callers of getResolvedSignature + // don't hit this issue because they only observe this result after it's had a chance to + // be cached, but the error reporting code below executes before getResolvedSignature sets + // resolvedSignature. + getNodeLinks(node).resolvedSignature = result; // No signatures were applicable. Now report errors based on the last applicable signature with // no arguments excluded from assignability checks. // If candidate is undefined, it means that no candidates had a suitable arity. In that case, @@ -76838,7 +77130,7 @@ var ts; chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error); chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call); } - var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, function () { return chain_1; }); + var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, function () { return chain_1; }); if (diags) { for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) { var d = diags_1[_i]; @@ -76859,9 +77151,9 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_26 = function (c) { + var _loop_27 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { if (diags_2.length <= min_3) { min_3 = diags_2.length; @@ -76877,7 +77169,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_26(c); + _loop_27(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -76916,7 +77208,7 @@ var ts; } } } - return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + return result; function addImplementationSuccessElaboration(failed, diagnostic) { var _a, _b; var oldCandidatesForArgumentError = candidatesForArgumentError; @@ -76946,7 +77238,7 @@ var ts; if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { return undefined; } - if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { + if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { candidatesForArgumentError = [candidate]; return undefined; } @@ -76969,9 +77261,9 @@ var ts; } } else { - inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext); - argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */; + inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); + argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */; } checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a @@ -76993,10 +77285,10 @@ var ts; // If one or more context sensitive arguments were excluded, we start including // them now (and keeping do so for any subsequent candidates) and perform a second // round of type inference and applicability checking for this particular candidate. - argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */; + argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); - checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); + checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a // signature with different arity and we need to perform another arity check. if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) { @@ -77035,7 +77327,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_27 = function (i) { + var _loop_28 = function (i) { var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : i < s.parameters.length ? s.parameters[i] : undefined; }); @@ -77043,17 +77335,17 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_27(i); + _loop_28(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; if (restParameterSymbols.length !== 0) { - var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); + var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* UnionReduction.Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } if (candidates.some(signatureHasLiteralTypes)) { - flags |= 2 /* HasLiteralTypes */; + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. @@ -77066,7 +77358,7 @@ var ts; return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { - return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); + return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* UnionReduction.Subtype */)); } function createCombinedSymbolForOverloadFailure(sources, type) { // This function is currently only used for erroneous overloads, so it's good enough to just use the first source. @@ -77103,8 +77395,8 @@ var ts; return typeArguments; } function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) { - var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext); + var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* CheckMode.SkipContextSensitive */ | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); return createSignatureInstantiation(candidate, typeArgumentTypes); } function getLongestCandidateIndex(candidates, argsCount) { @@ -77124,7 +77416,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -77139,7 +77431,7 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } } return resolveUntypedCall(node); @@ -77148,13 +77440,13 @@ var ts; var funcType = checkExpression(node.expression); if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); - callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + callChainFlags = nonOptionalType === funcType ? 0 /* SignatureFlags.None */ : + ts.isOutermostOptionalChain(node) ? 16 /* SignatureFlags.IsOuterCallChain */ : + 8 /* SignatureFlags.IsInnerCallChain */; funcType = nonOptionalType; } else { - callChainFlags = 0 /* None */; + callChainFlags = 0 /* SignatureFlags.None */; } funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { @@ -77169,8 +77461,8 @@ var ts; // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; // TS 1.0 Spec: 4.12 // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. @@ -77197,7 +77489,7 @@ var ts; relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation); + invocationError(node.expression, apparentType, 0 /* SignatureKind.Call */, relatedInformation); } return resolveErrorCall(node); } @@ -77211,9 +77503,9 @@ var ts; // returns a function type, we choose to defer processing. This narrowly permits function composition // operators to flow inferences through return types, but otherwise processes calls right away. We // use the resolvingSignature singleton to indicate that we deferred processing. This result will be - // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and + // propagated out and eventually turned into silentNeverType (a type that is assignable to anything and // from which we never make inferences). - if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { skippedGenericFunction(node, checkMode); return resolvingSignature; } @@ -77234,11 +77526,11 @@ var ts; */ function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have no common signatures. - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeFlags.TypeParameter */) || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* TypeFlags.Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { - if (node.arguments && languageVersion < 1 /* ES5 */) { + if (node.arguments && languageVersion < 1 /* ScriptTarget.ES5 */) { var spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); @@ -77271,7 +77563,7 @@ var ts; // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(expressionType, 1 /* SignatureKind.Construct */); if (constructSignatures.length) { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); @@ -77280,24 +77572,24 @@ var ts; // then it cannot be instantiated. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); })) { + if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); })) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* Abstract */)) { + if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* ModifierFlags.Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. It is an error to have a Void this type. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + var callSignatures = getSignaturesOfType(expressionType, 0 /* SignatureKind.Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -77308,14 +77600,14 @@ var ts; } return signature; } - invocationError(node.expression, expressionType, 1 /* Construct */); + invocationError(node.expression, expressionType, 1 /* SignatureKind.Construct */); return resolveErrorCall(node); } function someSignature(signatures, f) { if (ts.isArray(signatures)) { return ts.some(signatures, function (signature) { return someSignature(signature, f); }); } - return signatures.compositeKind === 1048576 /* Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); + return signatures.compositeKind === 1048576 /* TypeFlags.Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); } function typeHasProtectedAccessibleBase(target, type) { var baseTypes = getBaseTypes(type); @@ -77323,7 +77615,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 2097152 /* Intersection */) { + if (firstBase.flags & 2097152 /* TypeFlags.Intersection */) { var types = firstBase.types; var mixinFlags = findMixins(types); var i = 0; @@ -77331,7 +77623,7 @@ var ts; var intersectionMember = _a[_i]; // We want to ignore mixin ctors if (!mixinFlags[i]) { - if (ts.getObjectFlags(intersectionMember) & (1 /* Class */ | 2 /* Interface */)) { + if (ts.getObjectFlags(intersectionMember) & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { if (intersectionMember.symbol === target) { return true; } @@ -77354,9 +77646,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 171 /* Constructor */) { + if (!modifiers || declaration.kind !== 171 /* SyntaxKind.Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -77364,16 +77656,16 @@ var ts; // A private or protected constructor can only be instantiated within its own class (or a subclass, for protected) if (!isNodeWithinClass(node, declaringClassDeclaration)) { var containingClass = ts.getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 16 /* ModifierFlags.Protected */) { var containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 8 /* ModifierFlags.Private */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 16 /* ModifierFlags.Protected */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -77382,10 +77674,10 @@ var ts; } function invocationErrorDetails(errorTarget, apparentType, kind) { var errorInfo; - var isCall = kind === 0 /* Call */; + var isCall = kind === 0 /* SignatureKind.Call */; var awaitedType = getAwaitedType(apparentType); var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0; - if (apparentType.flags & 1048576 /* Union */) { + if (apparentType.flags & 1048576 /* TypeFlags.Union */) { var types = apparentType.types; var hasSignatures = false; for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { @@ -77435,7 +77727,7 @@ var ts; // Diagnose get accessors incorrectly called as functions if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol; - if (resolvedSymbol && resolvedSymbol.flags & 32768 /* GetAccessor */) { + if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) { headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } @@ -77479,8 +77771,8 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -77490,26 +77782,26 @@ var ts; diagnostics.add(diagnostic); return resolveErrorCall(node); } - invocationError(node.tag, apparentType, 0 /* Call */); + invocationError(node.tag, apparentType, 0 /* SignatureKind.Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -77524,8 +77816,8 @@ var ts; if (isErrorType(apparentType)) { return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -77536,38 +77828,38 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* Call */); + var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* SignatureKind.Call */); var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage); var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage)); } diagnostics.add(diag); - invocationErrorRecovery(apparentType, 0 /* Call */, diag); + invocationErrorRecovery(apparentType, 0 /* SignatureKind.Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); - var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* SymbolFlags.Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* SymbolFlags.Type */, node); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, 0 /* None */); + /*returnTypePredicate*/ undefined, 1, 0 /* SignatureFlags.None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); var fakeSignature = createSignatureForJSXIntrinsic(node, result); - checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* CheckMode.Normal */), result, node.tagName, node.attributes); if (ts.length(node.typeArguments)) { ts.forEach(node.typeArguments, checkSourceElement); diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments))); @@ -77588,7 +77880,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -77604,16 +77896,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -77636,7 +77928,7 @@ var ts; return cached; } links.resolvedSignature = resolvingSignature; - var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */); + var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* CheckMode.Normal */); // When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call // resolution should be deferred. if (result !== resolvingSignature) { @@ -77677,7 +77969,7 @@ var ts; var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target); inferred.exports = inferred.exports || ts.createSymbolTable(); inferred.members = inferred.members || ts.createSymbolTable(); - inferred.flags |= source.flags & 32 /* Class */; + inferred.flags |= source.flags & 32 /* SymbolFlags.Class */; if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) { mergeSymbolTable(inferred.exports, source.exports); } @@ -77713,16 +78005,16 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } - else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + else if (parentNodeOperator === 56 /* SyntaxKind.BarBarToken */ || parentNodeOperator === 60 /* SyntaxKind.QuestionQuestionToken */) { if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -77745,10 +78037,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 206 /* PropertyAccessExpression */) { + while (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -77764,19 +78056,19 @@ var ts; var signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode); if (signature === resolvingSignature) { // CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that - // returns a function type. We defer checking and return nonInferrableType. - return nonInferrableType; + // returns a function type. We defer checking and return silentNeverType. + return silentNeverType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return voidType; } - if (node.kind === 209 /* NewExpression */) { + if (node.kind === 209 /* SyntaxKind.NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 171 /* Constructor */ && - declaration.kind !== 175 /* ConstructSignature */ && - declaration.kind !== 180 /* ConstructorType */ && + declaration.kind !== 171 /* SyntaxKind.Constructor */ && + declaration.kind !== 175 /* SyntaxKind.ConstructSignature */ && + declaration.kind !== 180 /* SyntaxKind.ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -77793,11 +78085,11 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* TypeFlags.ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 208 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* ExpressionStatement */ && - returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (node.kind === 208 /* SyntaxKind.CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && + returnType.flags & 16384 /* TypeFlags.Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); } @@ -77810,14 +78102,14 @@ var ts; var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - jsAssignmentType.objectFlags |= 4096 /* JSLiteral */; + jsAssignmentType.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } return returnType; } function checkDeprecatedSignature(signature, node) { - if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) { + if (signature.declaration && signature.declaration.flags & 268435456 /* NodeFlags.Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); @@ -77826,20 +78118,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 208 /* CallExpression */: - case 165 /* Decorator */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 165 /* SyntaxKind.Decorator */: + case 209 /* SyntaxKind.NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.argumentExpression; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -77861,7 +78153,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -77876,13 +78168,13 @@ var ts; for (var i = 2; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* TypeFlags.Undefined */ || specifierType.flags & 65536 /* TypeFlags.Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } if (optionsType) { var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true); if (importCallOptionsType !== emptyObjectType) { - checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]); + checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* TypeFlags.Undefined */), node.arguments[1]); } } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -77898,11 +78190,11 @@ var ts; } function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) { var memberTable = ts.createSymbolTable(); - var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + var newSymbol = createSymbol(2097152 /* SymbolFlags.Alias */, "default" /* InternalSymbolName.Default */); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); newSymbol.aliasTarget = resolveSymbol(symbol); - memberTable.set("default" /* Default */, newSymbol); + memberTable.set("default" /* InternalSymbolName.Default */, newSymbol); return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); } function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) { @@ -77925,7 +78217,7 @@ var ts; var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier); if (hasSyntheticDefault) { - var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var anonymousSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; @@ -77945,40 +78237,40 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } // project includes symbol named 'require' - make sure that it is ambient and local non-alias - if (resolvedRequire.flags & 2097152 /* Alias */) { + if (resolvedRequire.flags & 2097152 /* SymbolFlags.Alias */) { return false; } - var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 256 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 254 /* VariableDeclaration */ - : 0 /* Unknown */; - if (targetDeclarationKind !== 0 /* Unknown */) { + var targetDeclarationKind = resolvedRequire.flags & 16 /* SymbolFlags.Function */ + ? 256 /* SyntaxKind.FunctionDeclaration */ + : resolvedRequire.flags & 3 /* SymbolFlags.Variable */ + ? 254 /* SyntaxKind.VariableDeclaration */ + : 0 /* SyntaxKind.Unknown */; + if (targetDeclarationKind !== 0 /* SyntaxKind.Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 16777216 /* Ambient */); + return !!decl && !!(decl.flags & 16777216 /* NodeFlags.Ambient */); } return false; } function checkTaggedTemplateExpression(node) { if (!checkGrammarTaggedTemplateChain(node)) checkGrammarTypeArguments(node, node.typeArguments); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 262144 /* ExternalEmitHelpers.MakeTemplateObject */); } var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); return getReturnTypeOfSignature(signature); } function checkAssertion(node) { - if (node.kind === 211 /* TypeAssertionExpression */) { + if (node.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { var file = ts.getSourceFileOfNode(node); - if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */])) { grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } @@ -77986,31 +78278,31 @@ var ts; } function isValidConstAssertionArgument(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 223 /* TemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) || + op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node.expression; var symbol = getTypeOfNode(expr).symbol; - if (symbol && symbol.flags & 2097152 /* Alias */) { + if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = resolveAlias(symbol); } - return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); + return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */); } return false; } @@ -78041,12 +78333,12 @@ var ts; return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType); } function checkNonNullAssertion(node) { - return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkNonNullChain(node) : getNonNullableType(checkExpression(node.expression)); } function checkExpressionWithTypeArguments(node) { checkGrammarExpressionWithTypeArguments(node); - var exprType = node.kind === 228 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : + var exprType = node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? checkExpression(node.expression) : ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName); var typeArguments = node.typeArguments; @@ -78071,7 +78363,7 @@ var ts; } return result; function getInstantiatedTypePart(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var callSignatures = getInstantiatedSignatures(resolved.callSignatures); var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures); @@ -78079,12 +78371,12 @@ var ts; hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0); if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) { var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos); - result_11.objectFlags |= 8388608 /* InstantiationExpressionType */; + result_11.objectFlags |= 8388608 /* ObjectFlags.InstantiationExpressionType */; result_11.node = node; return result_11; } } - else if (type.flags & 58982400 /* InstantiableNonPrimitive */) { + else if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { var constraint = getBaseConstraintOfType(type); if (constraint) { var instantiated = getInstantiatedTypePart(constraint); @@ -78093,10 +78385,10 @@ var ts; } } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getInstantiatedType); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart)); } return type; @@ -78112,19 +78404,19 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 103 /* NewKeyword */) { + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 100 /* ImportKeyword */) { + if (node.keywordToken === 100 /* SyntaxKind.ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); } function checkMetaPropertyKeyword(node) { switch (node.keywordToken) { - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return getGlobalImportMetaExpressionType(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: var type = checkNewTargetMetaProperty(node); return isErrorType(type) ? errorType : createNewTargetExpressionType(type); default: @@ -78137,7 +78429,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -78156,7 +78448,7 @@ var ts; error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { @@ -78189,7 +78481,7 @@ var ts; } function getParameterIdentifierNameAtPosition(signature, pos) { var _a; - if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* JSDocFunctionType */) { + if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* SyntaxKind.JSDocFunctionType */) { return undefined; } var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -78221,7 +78513,7 @@ var ts; return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); } function isValidDeclarationForTupleLabel(d) { - return d.kind === 197 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 197 /* SyntaxKind.NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -78271,11 +78563,11 @@ var ts; for (var i = pos; i < parameterCount; i++) { if (!restType || i < parameterCount - 1) { types.push(getTypeAtPosition(source, i)); - flags.push(i < minArgumentCount ? 1 /* Required */ : 2 /* Optional */); + flags.push(i < minArgumentCount ? 1 /* ElementFlags.Required */ : 2 /* ElementFlags.Optional */); } else { types.push(restType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } var name = getNameableDeclarationAtPosition(source, i); if (name) { @@ -78299,14 +78591,14 @@ var ts; return length; } function getMinArgumentCount(signature, flags) { - var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */; - var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */; + var strongArityForUntypedJS = flags & 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */; + var voidIsNonOptional = flags & 2 /* MinArgumentCountFlags.VoidIsNonOptional */; if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) { var minArgumentCount = void 0; if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { - var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); + var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* ElementFlags.Required */); }); var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; if (requiredCount > 0) { minArgumentCount = signature.parameters.length - 1 + requiredCount; @@ -78314,7 +78606,7 @@ var ts; } } if (minArgumentCount === undefined) { - if (!strongArityForUntypedJS && signature.flags & 32 /* IsUntypedSignatureInJSFile */) { + if (!strongArityForUntypedJS && signature.flags & 32 /* SignatureFlags.IsUntypedSignatureInJSFile */) { return 0; } minArgumentCount = signature.minArgumentCount; @@ -78324,7 +78616,7 @@ var ts; } for (var i = minArgumentCount - 1; i >= 0; i--) { var type = getTypeAtPosition(signature, i); - if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, acceptsVoid).flags & 131072 /* TypeFlags.Never */) { break; } minArgumentCount = i; @@ -78354,7 +78646,7 @@ var ts; } function getNonArrayRestType(signature) { var restType = getEffectiveRestType(signature); - return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined; + return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* TypeFlags.Never */) === 0 ? restType : undefined; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -78373,17 +78665,6 @@ var ts; } } } - var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144 /* TypeParameter */) { - // The contextual signature has a generic rest parameter. We first instantiate the contextual - // signature (without fixing type parameters) and assign types to contextually typed parameters. - var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); - assignContextualParameterTypes(signature, instantiatedContext); - // We then infer from a tuple type representing the parameters that correspond to the contextual - // rest parameter. - var restPos = getParameterCount(context) - 1; - inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType); - } } function assignContextualParameterTypes(signature, context) { if (context.typeParameters) { @@ -78418,7 +78699,7 @@ var ts; ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration) // a declarationless parameter may still have a `.type` already set by its construction logic // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type - : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) { + : !!(ts.getCheckFlags(parameter) & 65536 /* CheckFlags.DeferredType */)) { var contextualParameterType = getRestTypeAtPosition(context, len); assignParameterType(parameter, contextualParameterType); } @@ -78438,7 +78719,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter)); - if (declaration && declaration.name.kind !== 79 /* Identifier */) { + if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); @@ -78457,7 +78738,7 @@ var ts; var element = _a[_i]; if (!ts.isOmittedExpression(element)) { var type = getBindingElementTypeFromParentType(element, parentType); - if (element.name.kind === 79 /* Identifier */) { + if (element.name.kind === 79 /* SyntaxKind.Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = type; } else { @@ -78505,8 +78786,8 @@ var ts; } function createNewTargetExpressionType(targetType) { // Create a synthetic type `NewTargetExpression { target: TargetType; }` - var symbol = createSymbol(0 /* None */, "NewTargetExpression"); - var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */); + var symbol = createSymbol(0 /* SymbolFlags.None */, "NewTargetExpression"); + var targetPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "target", 8 /* CheckFlags.Readonly */); targetPropertySymbol.parent = symbol; targetPropertySymbol.type = targetType; var members = ts.createSymbolTable([targetPropertySymbol]); @@ -78518,14 +78799,14 @@ var ts; return errorType; } var functionFlags = ts.getFunctionFlags(func); - var isAsync = (functionFlags & 2 /* Async */) !== 0; - var isGenerator = (functionFlags & 1 /* Generator */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + var isGenerator = (functionFlags & 1 /* FunctionFlags.Generator */) !== 0; var returnType; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 235 /* Block */) { // Async or normal arrow function - returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); + if (func.body.kind !== 235 /* SyntaxKind.Block */) { // Async or normal arrow function + returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -78540,47 +78821,47 @@ var ts; fallbackReturnType = neverType; } else if (returnTypes.length > 0) { - returnType = getUnionType(returnTypes, 2 /* Subtype */); + returnType = getUnionType(returnTypes, 2 /* UnionReduction.Subtype */); } var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes; - yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* Subtype */) : undefined; + yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* UnionReduction.Subtype */) : undefined; nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined; } else { // Async or normal function var types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, voidType) // Async function : voidType; // Normal function } // Return a union of the return expression types. - returnType = getUnionType(types, 2 /* Subtype */); + returnType = getUnionType(types, 2 /* UnionReduction.Subtype */); } if (returnType || yieldType || nextType) { if (yieldType) - reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */); + reportErrorsFromWidening(func, yieldType, 3 /* WideningKind.GeneratorYield */); if (returnType) - reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */); + reportErrorsFromWidening(func, returnType, 1 /* WideningKind.FunctionReturn */); if (nextType) - reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */); + reportErrorsFromWidening(func, nextType, 2 /* WideningKind.GeneratorNext */); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); var contextualType = !contextualSignature ? undefined : contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : - instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); + instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined); if (isGenerator) { - yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync); - returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync); - nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* Next */, isAsync); + yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* IterationTypeKind.Yield */, isAsync); + returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* IterationTypeKind.Return */, isAsync); + nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* IterationTypeKind.Next */, isAsync); } else { returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync); @@ -78594,7 +78875,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* IterationTypeKind.Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -78637,17 +78918,17 @@ var ts; function checkAndAggregateYieldOperandTypes(func, checkMode) { var yieldTypes = []; var nextTypes = []; - var isAsync = (ts.getFunctionFlags(func) & 2 /* Async */) !== 0; + var isAsync = (ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) !== 0; ts.forEachYieldExpression(func.body, function (yieldExpression) { var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType; ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync)); var nextType; if (yieldExpression.asteriskToken) { - var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, yieldExpression.expression); + var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, yieldExpression.expression); nextType = iterationTypes && iterationTypes.nextType; } else { - nextType = getContextualType(yieldExpression); + nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined); } if (nextType) ts.pushIfUnique(nextTypes, nextType); @@ -78657,17 +78938,17 @@ var ts; function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) { var errorNode = node.expression || node; // A `yield*` expression effectively yields everything that its operand yields - var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, expressionType, sentType, errorNode) : expressionType; + var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, expressionType, sentType, errorNode) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } // Return the combined not-equal type facts for all cases except those between the start and end indices. function getNotEqualFactsFromTypeofSwitch(start, end, witnesses) { - var facts = 0 /* None */; + var facts = 0 /* TypeFacts.None */; for (var i = 0; i < witnesses.length; i++) { var witness = i < start || i >= end ? witnesses[i] : undefined; - facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeofNEHostObject */ : 0; + facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeFacts.TypeofNEHostObject */ : 0; } return facts; } @@ -78676,7 +78957,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 216 /* TypeOfExpression */) { + if (node.expression.kind === 216 /* SyntaxKind.TypeOfExpression */) { var witnesses = getSwitchClauseTypeOfWitnesses(node); if (!witnesses) { return false; @@ -78684,9 +78965,9 @@ var ts; var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression)); // Get the not-equal flags for all handled cases. var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses); - if (operandConstraint.flags & 3 /* AnyOrUnknown */) { + if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) { // We special case the top types to be exhaustive when all cases are handled. - return (556800 /* AllTypeofNE */ & notEqualFacts_2) === 556800 /* AllTypeofNE */; + return (556800 /* TypeFacts.AllTypeofNE */ & notEqualFacts_2) === 556800 /* TypeFacts.AllTypeofNE */; } // A missing not-equal flag indicates that the type wasn't handled by some case. return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; }); @@ -78713,15 +78994,15 @@ var ts; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */); - if (functionFlags & 2 /* Async */) { + var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); + if (functionFlags & 2 /* FunctionFlags.Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -78742,11 +79023,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 169 /* MethodDeclaration */: - return func.parent.kind === 205 /* ObjectLiteralExpression */; + case 169 /* SyntaxKind.MethodDeclaration */: + return func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; default: return false; } @@ -78767,17 +79048,17 @@ var ts; var functionFlags = ts.getFunctionFlags(func); var type = returnType && unwrapReturnType(returnType, functionFlags); // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) { + if (type && maybeTypeOfKind(type, 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 168 /* SyntaxKind.MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* SyntaxKind.Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* NodeFlags.HasExplicitReturn */; var errorNode = ts.getEffectiveReturnTypeNode(func) || func; - if (type && type.flags & 131072 /* Never */) { + if (type && type.flags & 131072 /* TypeFlags.Never */) { error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { @@ -78806,13 +79087,13 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (ts.isFunctionExpression(node)) { checkCollisionsForDeclarationName(node, node.name); } // The identityMapper object is used to indicate that function expressions are wildcards - if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { + if (checkMode && checkMode & 4 /* CheckMode.SkipContextSensitive */ && isContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type @@ -78823,9 +79104,9 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray); - returnOnlyType.objectFlags |= 262144 /* NonInferrableType */; + returnOnlyType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -78833,7 +79114,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 213 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 213 /* SyntaxKind.FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -78842,25 +79123,30 @@ var ts; function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) { var links = getNodeLinks(node); // Check if function expression is contextually typed and assign parameter types if so. - if (!(links.flags & 1024 /* ContextChecked */)) { + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { - links.flags |= 1024 /* ContextChecked */; - var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* Call */)); + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { + links.flags |= 1024 /* NodeCheckFlags.ContextChecked */; + var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* SignatureKind.Call */)); if (!signature) { return; } if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); - if (checkMode && checkMode & 2 /* Inferential */) { + var instantiatedContextualSignature = void 0; + if (checkMode && checkMode & 2 /* CheckMode.Inferential */) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); + var restType = getEffectiveRestType(contextualSignature); + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { + instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper); + } } - var instantiatedContextualSignature = inferenceContext ? - instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature; + instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ? + instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature); assignContextualParameterTypes(signature, instantiatedContextualSignature); } else { @@ -78879,7 +79165,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -78892,7 +79178,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 235 /* Block */) { + if (node.body.kind === 235 /* SyntaxKind.Block */) { checkSourceElement(node.body); } else { @@ -78904,7 +79190,7 @@ var ts; var exprType = checkExpression(node.body); var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { // Async function var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } @@ -78962,27 +79248,27 @@ var ts; // Enum members // Object.defineProperty assignments with writable false or no setter // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(ts.getCheckFlags(symbol) & 8 /* Readonly */ || - symbol.flags & 4 /* Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || - symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || - symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - symbol.flags & 8 /* EnumMember */ || + return !!(ts.getCheckFlags(symbol) & 8 /* CheckFlags.Readonly */ || + symbol.flags & 4 /* SymbolFlags.Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* ModifierFlags.Readonly */ || + symbol.flags & 3 /* SymbolFlags.Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */ || + symbol.flags & 98304 /* SymbolFlags.Accessor */ && !(symbol.flags & 65536 /* SymbolFlags.SetAccessor */) || + symbol.flags & 8 /* SymbolFlags.EnumMember */ || ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; - if (assignmentKind === 0 /* None */) { + if (assignmentKind === 0 /* AssignmentKind.None */) { // no assigment means it doesn't matter whether the entity is readonly return false; } if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. - if (symbol.flags & 4 /* Property */ && + if (symbol.flags & 4 /* SymbolFlags.Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 108 /* ThisKeyword */) { + expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 171 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -79003,11 +79289,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; - if (symbol_2.flags & 2097152 /* Alias */) { + if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 268 /* NamespaceImport */; + return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */; } } } @@ -79015,12 +79301,12 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { + var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */); + if (node.kind !== 79 /* SyntaxKind.Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { error(expr, invalidOptionalChainMessage); return false; } @@ -79049,8 +79335,8 @@ var ts; function checkDeleteExpressionMustBeOptional(expr, symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks && - !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && - !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) { + !(type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) && + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* SymbolFlags.Optional */ : getTypeFacts(type) & 16777216 /* TypeFacts.IsUndefined */)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -79068,7 +79354,7 @@ var ts; if (container && ts.isClassStaticBlockDeclaration(container)) { error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); } - else if (!(node.flags & 32768 /* AwaitContext */)) { + else if (!(node.flags & 32768 /* NodeFlags.AwaitContext */)) { if (ts.isInTopLevelContext(node)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -79090,7 +79376,7 @@ var ts; case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: case ts.ModuleKind.System: - if (languageVersion >= 4 /* ES2017 */) { + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { break; } // fallthrough @@ -79107,7 +79393,7 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); - if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + if (container && container.kind !== 171 /* SyntaxKind.Constructor */ && (ts.getFunctionFlags(container) & 2 /* FunctionFlags.Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -79123,7 +79409,7 @@ var ts; addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); }); var operandType = checkExpression(node.expression); var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) { + if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* TypeFlags.AnyOrUnknown */)) { addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); } return awaitedType; @@ -79134,16 +79420,16 @@ var ts; return silentNeverType; } switch (node.operand.kind) { - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: switch (node.operator) { - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text)); - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text)); } break; - case 9 /* BigIntLiteral */: - if (node.operator === 40 /* MinusToken */) { + case 9 /* SyntaxKind.BigIntLiteral */: + if (node.operator === 40 /* SyntaxKind.MinusToken */) { return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -79151,28 +79437,28 @@ var ts; } } switch (node.operator) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* TypeFlags.ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 39 /* PlusToken */) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + if (node.operator === 39 /* SyntaxKind.PlusToken */) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* TypeFlags.BigIntLike */)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); - return facts === 4194304 /* Truthy */ ? falseType : - facts === 8388608 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* TypeFacts.Truthy */ | 8388608 /* TypeFacts.Falsy */); + return facts === 4194304 /* TypeFacts.Truthy */ ? falseType : + facts === 8388608 /* TypeFacts.Falsy */ ? trueType : booleanType; - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -79195,8 +79481,8 @@ var ts; return getUnaryResultType(operandType); } function getUnaryResultType(operandType) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* TypeFlags.AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* TypeFlags.NumberLike */) ? numberOrBigIntType : bigintType; } @@ -79216,7 +79502,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { var t = types_20[_i]; @@ -79231,30 +79517,30 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { + if (strict && source.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */)) { return false; } - return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || - !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* TypeFlags.NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 402653316 /* TypeFlags.StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 528 /* TypeFlags.BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 16384 /* TypeFlags.Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 65536 /* TypeFlags.Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 32768 /* TypeFlags.Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 4096 /* TypeFlags.ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 67108864 /* TypeFlags.NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 1048576 /* Union */ ? + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; + return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { if (leftType === silentNeverType || rightType === silentNeverType) { @@ -79266,7 +79552,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 131068 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -79280,8 +79566,8 @@ var ts; return silentNeverType; } if (ts.isPrivateIdentifier(left)) { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(left, 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */); } // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors @@ -79294,8 +79580,8 @@ var ts; leftType = checkNonNullType(leftType, left); // TypeScript 1.0 spec (April 2014): 4.15.5 // Require the left operand to be of type Any, the String primitive type, or the Number primitive type. - if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { + if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol); } } @@ -79320,9 +79606,9 @@ var ts; // // The result is always of the Boolean primitive type. var rightTypeConstraint = getConstraintOfType(rightType); - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - !maybeTypeOfKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */))) { + if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; @@ -79342,7 +79628,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 296 /* PropertyAssignment */ || property.kind === 297 /* ShorthandPropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */ || property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -79353,17 +79639,17 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* AccessFlags.ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 297 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 298 /* SpreadAssignment */) { + else if (property.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(property, 4 /* Rest */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(property, 4 /* ExternalEmitHelpers.Rest */); } var nonRestNames = []; if (allProperties) { @@ -79385,18 +79671,18 @@ var ts; } function checkArrayLiteralAssignment(node, sourceType, checkMode) { var elements = node.elements; - if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; + var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | 128 /* IterationUse.PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 225 /* SpreadElement */) { - type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); + if (node.elements[i].kind === 225 /* SyntaxKind.SpreadElement */) { + type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); } @@ -79405,15 +79691,15 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 227 /* OmittedExpression */) { - if (element.kind !== 225 /* SpreadElement */) { + if (element.kind !== 227 /* SyntaxKind.OmittedExpression */) { + if (element.kind !== 225 /* SyntaxKind.SpreadElement */) { var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; - var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; + var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* TypeFacts.NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); } @@ -79424,7 +79710,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 221 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { + if (restExpression.kind === 221 /* SyntaxKind.BinaryExpression */ && restExpression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -79440,14 +79726,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 297 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* IsUndefined */)) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* TypeFacts.IsUndefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -79456,35 +79742,35 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { + if (target.kind === 221 /* SyntaxKind.BinaryExpression */ && target.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; // A default value is specified, so remove undefined from the final type. if (strictNullChecks) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } } - if (target.kind === 205 /* ObjectLiteralExpression */) { + if (target.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 204 /* ArrayLiteralExpression */) { + if (target.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 298 /* SpreadAssignment */ ? + var error = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 298 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { - checkExternalEmitHelpers(target.parent, 1048576 /* ClassPrivateFieldSet */); + checkExternalEmitHelpers(target.parent, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } return sourceType; } @@ -79499,59 +79785,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 210 /* TaggedTemplateExpression */: - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 153 /* UndefinedKeyword */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 216 /* TypeOfExpression */: - case 230 /* NonNullExpression */: - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: return true; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 53 /* ExclamationToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: return true; } return false; // Some forms listed here for clarity - case 217 /* VoidExpression */: // Explicit opt-out - case 211 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 229 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 217 /* SyntaxKind.VoidExpression */: // Explicit opt-out + case 211 /* SyntaxKind.TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 229 /* SyntaxKind.AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* TypeFlags.Nullable */) !== 0 || isTypeComparableTo(source, target); } function createCheckBinaryExpression() { var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); @@ -79582,9 +79868,9 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (node.left.kind === 205 /* ObjectLiteralExpression */ || node.left.kind === 204 /* ArrayLiteralExpression */)) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && (node.left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { state.skip = true; - setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* SyntaxKind.ThisKeyword */)); return state; } return state; @@ -79601,9 +79887,13 @@ var ts; setLeftType(state, leftType); setLastResult(state, /*type*/ undefined); var operator = operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */) { + var parent = node.parent; + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ + || ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */)) { + parent = parent.parent; + } checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } checkTruthinessOfType(leftType, node.left); @@ -79662,11 +79952,11 @@ var ts; } function checkGrammarNullishCoalesceWithLogicalExpression(node) { var left = node.left, operatorToken = node.operatorToken, right = node.right; - if (operatorToken.kind === 60 /* QuestionQuestionToken */) { - if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || left.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } - if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || right.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } } @@ -79675,11 +79965,11 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (left.kind === 205 /* ObjectLiteralExpression */ || left.kind === 204 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); + if (operator === 63 /* SyntaxKind.EqualsToken */ && (left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* SyntaxKind.ThisKeyword */); } var leftType; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -79691,28 +79981,28 @@ var ts; function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) { var operator = operatorToken.kind; switch (operator) { - case 41 /* AsteriskToken */: - case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 44 /* PercentToken */: - case 69 /* PercentEqualsToken */: - case 40 /* MinusToken */: - case 65 /* MinusEqualsToken */: - case 47 /* LessThanLessThanToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 44 /* SyntaxKind.PercentToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 40 /* SyntaxKind.MinusToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -79721,8 +80011,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 528 /* BooleanLike */) && - (rightType.flags & 528 /* BooleanLike */) && + if ((leftType.flags & 528 /* TypeFlags.BooleanLike */) && + (rightType.flags & 528 /* TypeFlags.BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); return numberType; @@ -79733,21 +80023,21 @@ var ts; var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, /*isAwaitValid*/ true); var resultType_1; // If both are any or unknown, allow operation; assume it will resolve to number - if ((isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */)) || + if ((isTypeAssignableToKind(leftType, 3 /* TypeFlags.AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* TypeFlags.AnyOrUnknown */)) || // Or, if neither could be bigint, implicit coercion results in a number result - !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + !(maybeTypeOfKind(leftType, 2112 /* TypeFlags.BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* TypeFlags.BigIntLike */))) { resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; - case 42 /* AsteriskAsteriskToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - if (languageVersion < 3 /* ES2016 */) { + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } } @@ -79763,26 +80053,26 @@ var ts; } return resultType_1; } - case 39 /* PlusToken */: - case 64 /* PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* TypeFlags.NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* TypeFlags.NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true)) { // If both operands are of the BigInt primitive type, the result is of the BigInt primitive type. resultType = bigintType; } - else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -79800,21 +80090,21 @@ var ts; // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. - var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */; + var closeEnoughKind_1 = 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 3 /* TypeFlags.AnyOrUnknown */; reportOperatorError(function (left, right) { return isTypeAssignableToKind(left, closeEnoughKind_1) && isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 64 /* PlusEqualsToken */) { + if (operator === 64 /* SyntaxKind.PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -79823,60 +80113,60 @@ var ts; }); } return booleanType; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: if (ts.isLiteralExpressionOfObject(left) || ts.isLiteralExpressionOfObject(right)) { - var eqType = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; + var eqType = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true"); } reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 55 /* AmpersandAmpersandToken */: - case 76 /* AmpersandAmpersandEqualsToken */: { - var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: { + var resultType_2 = getTypeFacts(leftType) & 4194304 /* TypeFacts.Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 76 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } - case 56 /* BarBarToken */: - case 75 /* BarBarEqualsToken */: { - var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? - getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : + case 56 /* SyntaxKind.BarBarToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: { + var resultType_3 = getTypeFacts(leftType) & 8388608 /* TypeFacts.Falsy */ ? + getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 75 /* BarBarEqualsToken */) { + if (operator === 75 /* SyntaxKind.BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } - case 60 /* QuestionQuestionToken */: - case 77 /* QuestionQuestionEqualsToken */: { - var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? - getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: { + var resultType_4 = getTypeFacts(leftType) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 77 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* SyntaxKind.QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 63 /* EqualsToken */: - var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; + case 63 /* SyntaxKind.EqualsToken */: + var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* AssignmentDeclarationKind.None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { - if (!(rightType.flags & 524288 /* Object */) || - declKind !== 2 /* ModuleExports */ && - declKind !== 6 /* Prototype */ && + if (!(rightType.flags & 524288 /* TypeFlags.Object */) || + declKind !== 2 /* AssignmentDeclarationKind.ModuleExports */ && + declKind !== 6 /* AssignmentDeclarationKind.Prototype */ && !isEmptyObjectType(rightType) && !isFunctionObjectType(rightType) && - !(ts.getObjectFlags(rightType) & 1 /* Class */)) { + !(ts.getObjectFlags(rightType) & 1 /* ObjectFlags.Class */)) { // don't check assignability of module.exports=, C.prototype=, or expando types because they will necessarily be incomplete checkAssignmentOperator(rightType); } @@ -79886,7 +80176,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { var sf = ts.getSourceFileOfNode(left); var sourceText = sf.text; @@ -79904,16 +80194,16 @@ var ts; return ts.Debug.fail(); } function bothAreBigIntLike(left, right) { - return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + return isTypeAssignableToKind(left, 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableToKind(right, 2112 /* TypeFlags.BigIntLike */); } function checkAssignmentDeclaration(kind, rightType) { - if (kind === 2 /* ModuleExports */) { + if (kind === 2 /* AssignmentDeclarationKind.ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { var prop = _a[_i]; var propType = getTypeOfSymbol(prop); - if (propType.symbol && propType.symbol.flags & 32 /* Class */) { + if (propType.symbol && propType.symbol.flags & 32 /* SymbolFlags.Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* SymbolFlags.Type */, undefined, name, /*isUse*/ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) { addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); @@ -79923,12 +80213,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : - maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* TypeFlags.ESSymbolLike */) ? left : + maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* TypeFlags.ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -79938,15 +80228,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - return 56 /* BarBarToken */; - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - return 37 /* ExclamationEqualsEqualsToken */; - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: - return 55 /* AmpersandAmpersandToken */; + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + return 56 /* SyntaxKind.BarBarToken */; + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + return 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + return 55 /* SyntaxKind.AmpersandAmpersandToken */; default: return undefined; } @@ -79965,7 +80255,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { var headMessage = void 0; - if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) { + if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* TypeFlags.Undefined */)) { var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText); if (isExactOptionalPropertyMismatch(valueType, target)) { headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target; @@ -79979,13 +80269,13 @@ var ts; function isAssignmentDeclaration(kind) { var _a; switch (kind) { - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: return true; - case 1 /* ExportsProperty */: - case 5 /* Property */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: - case 4 /* ThisProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var symbol = getSymbolOfNode(left); var init = ts.getAssignedExpandoInitializer(right); return !!init && ts.isObjectLiteralExpression(init) && @@ -80028,12 +80318,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: typeName = "false"; break; - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -80059,20 +80349,20 @@ var ts; if (!func) return anyType; var functionFlags = ts.getFunctionFlags(func); - if (!(functionFlags & 1 /* Generator */)) { + if (!(functionFlags & 1 /* FunctionFlags.Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; } - var isAsync = (functionFlags & 2 /* Async */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; if (node.asteriskToken) { // Async generator functions prior to ESNext require the __await, __asyncDelegator, // and __asyncValues helpers - if (isAsync && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */); + if (isAsync && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 26624 /* ExternalEmitHelpers.AsyncDelegatorIncludes */); } // Generator functions prior to ES2015 require the __values helper - if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 256 /* Values */); + if (!isAsync && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.Values */); } } // There is no point in doing an assignability check if the function @@ -80089,20 +80379,20 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression); } if (node.asteriskToken) { - var use = isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */; - return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression) + var use = isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */; + return getIterationTypeOfIterable(use, 1 /* IterationTypeKind.Return */, yieldExpressionType, node.expression) || anyType; } else if (returnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) + return getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, isAsync) || anyType; } - var type = getContextualIterationType(2 /* Next */, func); + var type = getContextualIterationType(2 /* IterationTypeKind.Next */, func); if (!type) { type = anyType; addLazyDiagnostic(function () { if (noImplicitAny && !ts.expressionResultIsUnused(node)) { - var contextualType = getContextualType(node); + var contextualType = getContextualType(node, /*contextFlags*/ undefined); if (!contextualType || isTypeAny(contextualType)) { error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation); } @@ -80111,7 +80401,7 @@ var ts; } return type; function checkYieldExpressionGrammar() { - if (!(node.flags & 8192 /* YieldContext */)) { + if (!(node.flags & 8192 /* NodeFlags.YieldContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -80124,7 +80414,7 @@ var ts; checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); - return getUnionType([type1, type2], 2 /* Subtype */); + return getUnionType([type1, type2], 2 /* UnionReduction.Subtype */); } function isTemplateLiteralContext(node) { var parent = node.parent; @@ -80137,20 +80427,20 @@ var ts; for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { var span = _a[_i]; var type = checkExpression(span.expression); - if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) { error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; + return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { - return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || - type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); + return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) || + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */)); } function getContextNode(node) { - if (node.kind === 286 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 286 /* SyntaxKind.JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -80162,7 +80452,7 @@ var ts; try { context.contextualType = contextualType; context.inferenceContext = inferenceContext; - var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0)); + var type = checkExpression(node, checkMode | 1 /* CheckMode.Contextual */ | (inferenceContext ? 2 /* CheckMode.Inferential */ : 0)); // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type // parameters. This information is no longer needed after the call to checkExpression. if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { @@ -80171,7 +80461,7 @@ var ts; // We strip literal freshness when an appropriate contextual type is present such that contextually typed // literals always preserve their literal types (otherwise they might widen during type inference). An alternative // here would be to not mark contextually typed literals as fresh in the first place. - var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* TypeFlags.Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -80184,7 +80474,7 @@ var ts; } } function checkExpressionCached(node, checkMode) { - if (checkMode && checkMode !== 0 /* Normal */) { + if (checkMode && checkMode !== 0 /* CheckMode.Normal */) { return checkExpression(node, checkMode); } var links = getNodeLinks(node); @@ -80204,17 +80494,17 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 211 /* TypeAssertionExpression */ || - node.kind === 229 /* AsExpression */ || + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */ || + node.kind === 229 /* SyntaxKind.AsExpression */ || ts.isJSDocTypeAssertion(node); } function checkDeclarationInitializer(declaration, checkMode, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? - checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */) + checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* CheckMode.Normal */) : checkExpressionCached(initializer, checkMode)); - return ts.isParameter(declaration) && declaration.name.kind === 202 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -80224,9 +80514,9 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 203 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 203 /* SyntaxKind.BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); } @@ -80235,7 +80525,7 @@ var ts; return createTupleType(elementTypes, elementFlags, type.target.readonly); } function widenTypeInferredFromInitializer(declaration, type) { - var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); + var widened = ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); @@ -80250,28 +80540,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 3145728 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || unknownType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* TypeFlags.String */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* TypeFlags.Number */) && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + maybeTypeOfKind(constraint, 64 /* TypeFlags.BigInt */) && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + maybeTypeOfKind(constraint, 4096 /* TypeFlags.ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || - contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* TypeFlags.StringLiteral */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + contextualType.flags & 256 /* TypeFlags.NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + contextualType.flags & 2048 /* TypeFlags.BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + contextualType.flags & 512 /* TypeFlags.BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* TypeFlags.BooleanLiteral */) || + contextualType.flags & 8192 /* TypeFlags.UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */)); } return false; } @@ -80286,13 +80576,13 @@ var ts; var type = checkExpression(node, checkMode, forceTuple); return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) : isTypeAssertion(node) ? type : - getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node)); + getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined)); } function checkPropertyAssignment(node, checkMode) { // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -80303,23 +80593,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { - if (checkMode && checkMode & (2 /* Inferential */ | 8 /* SkipGenericFunctions */)) { - var callSignature = getSingleSignature(type, 0 /* Call */, /*allowMembers*/ true); - var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); + if (checkMode && checkMode & (2 /* CheckMode.Inferential */ | 8 /* CheckMode.SkipGenericFunctions */)) { + var callSignature = getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ true); + var constructSignature = getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + var contextualType = getApparentTypeOfContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { - var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); + var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { - if (checkMode & 8 /* SkipGenericFunctions */) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */) { skippedGenericFunction(node, checkMode); return anyFunctionType; } @@ -80367,11 +80657,11 @@ var ts; return type; } function skippedGenericFunction(node, checkMode) { - if (checkMode & 2 /* Inferential */) { + if (checkMode & 2 /* CheckMode.Inferential */) { // We have skipped a generic function during inferential typing. Obtain the inference context and // indicate this has occurred such that we know a second pass of inference is be needed. var context = getInferenceContext(node); - context.flags |= 4 /* SkippedGenericFunction */; + context.flags |= 4 /* InferenceFlags.SkippedGenericFunction */; } } function hasInferenceCandidates(info) { @@ -80396,12 +80686,12 @@ var ts; var result = []; var oldTypeParameters; var newTypeParameters; - for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { - var tp = typeParameters_2[_i]; + for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { + var tp = typeParameters_3[_i]; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); - var symbol = createSymbol(262144 /* TypeParameter */, newName); + var symbol = createSymbol(262144 /* SymbolFlags.TypeParameter */, newName); var newTypeParameter = createTypeParameter(symbol); newTypeParameter.target = tp; oldTypeParameters = ts.append(oldTypeParameters, tp); @@ -80426,7 +80716,7 @@ var ts; } function getUniqueTypeParameterName(typeParameters, baseName) { var len = baseName.length; - while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* _0 */ && baseName.charCodeAt(len - 1) <= 57 /* _9 */) + while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* CharacterCodes._0 */ && baseName.charCodeAt(len - 1) <= 57 /* CharacterCodes._9 */) len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { @@ -80459,7 +80749,7 @@ var ts; return quickType; } // If a type has been cached for the node, return it. - if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) { + if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) { var cachedType = flowTypeCache[getNodeId(node)]; if (cachedType) { return cachedType; @@ -80471,7 +80761,7 @@ var ts; if (flowInvocationCount !== startInvocationCount) { var cache = flowTypeCache || (flowTypeCache = []); cache[getNodeId(node)] = type; - ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */); + ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */); } return type; } @@ -80486,7 +80776,7 @@ var ts; expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -80496,8 +80786,8 @@ var ts; else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { return getTypeFromTypeNode(expr.type); } - else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { + else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ || + node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) { return checkExpression(node); } return undefined; @@ -80517,7 +80807,7 @@ var ts; var saveContextualType = node.contextualType; node.contextualType = anyType; try { - var type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */); + var type = links.contextFreeType = checkExpression(node, 4 /* CheckMode.SkipContextSensitive */); return type; } finally { @@ -80528,7 +80818,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -80546,18 +80836,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 207 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 181 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 275 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { - ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 16777216 /* Ambient */) { + if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -80575,113 +80865,113 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return checkIdentifier(node, checkMode); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifierExpression(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return checkThisExpression(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return nullWideningType; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getFreshTypeOfLiteralType(getStringLiteralType(node.text)); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text)); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: false, base10Value: ts.parsePseudoBigInt(node.text) })); - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: return trueType; - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return falseType; - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return checkTemplateExpression(node); - case 13 /* RegularExpressionLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: return globalRegExpType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return checkQualifiedName(node, checkMode); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 208 /* CallExpression */: - if (node.expression.kind === 100 /* ImportKeyword */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.expression.kind === 100 /* SyntaxKind.ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checkCallExpression(node, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return checkClassExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return checkTypeOfExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return checkAssertion(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return checkNonNullAssertion(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return checkExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkMetaProperty(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkDeleteExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return checkVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return checkAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return checkSpreadExpression(node, checkMode); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return undefinedWideningType; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return checkYieldExpression(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return checkSyntheticExpression(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return checkJsxExpression(node, checkMode); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return checkJsxElement(node, checkMode); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return checkJsxFragment(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -80715,16 +81005,18 @@ var ts; var modifiers = getVarianceModifiers(typeParameter); if (modifiers) { var symbol = getSymbolOfNode(node.parent); - if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) { + if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */))) { error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); } - else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType); + else if (modifiers === 32768 /* ModifierFlags.In */ || modifiers === 65536 /* ModifierFlags.Out */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) }); + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck); var saveVarianceTypeParameter = typeParameter; varianceTypeParameter = typeParameter; checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); varianceTypeParameter = saveVarianceTypeParameter; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } } } @@ -80737,28 +81029,28 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 171 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { + if (!(func.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 171 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 171 /* SyntaxKind.Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } - if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { + if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) { error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); } if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) { if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 171 /* Constructor */ || func.kind === 175 /* ConstructSignature */ || func.kind === 180 /* ConstructorType */) { + if (func.kind === 171 /* SyntaxKind.Constructor */ || func.kind === 175 /* SyntaxKind.ConstructSignature */ || func.kind === 180 /* SyntaxKind.ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 172 /* GetAccessor */ || func.kind === 173 /* SetAccessor */) { + if (func.kind === 172 /* SyntaxKind.GetAccessor */ || func.kind === 173 /* SyntaxKind.SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -80782,7 +81074,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { + if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -80816,13 +81108,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 179 /* FunctionType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 179 /* SyntaxKind.FunctionType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -80836,11 +81128,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* SyntaxKind.Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 202 /* ArrayBindingPattern */ || name.kind === 201 /* ObjectBindingPattern */) { + else if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -80849,29 +81141,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 176 /* IndexSignature */) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 179 /* FunctionType */ || node.kind === 256 /* FunctionDeclaration */ || node.kind === 180 /* ConstructorType */ || - node.kind === 174 /* CallSignature */ || node.kind === 171 /* Constructor */ || - node.kind === 175 /* ConstructSignature */) { + else if (node.kind === 179 /* SyntaxKind.FunctionType */ || node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 180 /* SyntaxKind.ConstructorType */ || + node.kind === 174 /* SyntaxKind.CallSignature */ || node.kind === 171 /* SyntaxKind.Constructor */ || + node.kind === 175 /* SyntaxKind.ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); - if (!(functionFlags & 4 /* Invalid */)) { + if (!(functionFlags & 4 /* FunctionFlags.Invalid */)) { // Async generators prior to ESNext require the __await and __asyncGenerator helpers - if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 3 /* FunctionFlags.AsyncGenerator */ && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 6144 /* ExternalEmitHelpers.AsyncGeneratorIncludes */); } // Async functions prior to ES2017 require the __awaiter helper - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { - checkExternalEmitHelpers(node, 64 /* Awaiter */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */ && languageVersion < 4 /* ScriptTarget.ES2017 */) { + checkExternalEmitHelpers(node, 64 /* ExternalEmitHelpers.Awaiter */); } // Generator functions, Async functions, and Async Generator functions prior to // ES2015 require the __generator helper - if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 128 /* Generator */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) !== 0 /* FunctionFlags.Normal */ && languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 128 /* ExternalEmitHelpers.Generator */); } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); @@ -80887,17 +81179,17 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (returnTypeNode) { var functionFlags_1 = ts.getFunctionFlags(node); - if ((functionFlags_1 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) { + if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) { var returnType = getTypeFromTypeNode(returnTypeNode); if (returnType === voidType) { error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -80909,18 +81201,18 @@ var ts; // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; - var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || generatorYieldType; - var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || unknownType; - var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* Async */)); + var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType; + var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType; + var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType; + var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */)); checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode); } } - else if ((functionFlags_1 & 3 /* AsyncGenerator */) === 2 /* Async */) { + else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 176 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) { + if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -80932,11 +81224,11 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 171 /* Constructor */) { + if (member.kind === 171 /* SyntaxKind.Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); + addName(instanceNames, param.name, param.name.escapedText, 3 /* DeclarationMeaning.GetOrSetAccessor */); } } } @@ -80947,24 +81239,24 @@ var ts; continue; } var isPrivate = ts.isPrivateIdentifier(name); - var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0; + var privateStaticFlags = isPrivate && isStaticMember ? 16 /* DeclarationMeaning.PrivateStatic */ : 0; var names = isPrivate ? privateIdentifiers : isStaticMember ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 172 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); + case 172 /* SyntaxKind.GetAccessor */: + addName(names, name, memberName, 1 /* DeclarationMeaning.GetAccessor */ | privateStaticFlags); break; - case 173 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); + case 173 /* SyntaxKind.SetAccessor */: + addName(names, name, memberName, 2 /* DeclarationMeaning.SetAccessor */ | privateStaticFlags); break; - case 167 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: + addName(names, name, memberName, 3 /* DeclarationMeaning.GetOrSetAccessor */ | privateStaticFlags); break; - case 169 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); + case 169 /* SyntaxKind.MethodDeclaration */: + addName(names, name, memberName, 8 /* DeclarationMeaning.Method */ | privateStaticFlags); break; } } @@ -80974,19 +81266,19 @@ var ts; var prev = names.get(name); if (prev) { // For private identifiers, do not allow mixing of static and instance members with the same name - if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + if ((prev & 16 /* DeclarationMeaning.PrivateStatic */) !== (meaning & 16 /* DeclarationMeaning.PrivateStatic */)) { error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - var prevIsMethod = !!(prev & 8 /* Method */); - var isMethod = !!(meaning & 8 /* Method */); + var prevIsMethod = !!(prev & 8 /* DeclarationMeaning.Method */); + var isMethod = !!(meaning & 8 /* DeclarationMeaning.Method */); if (prevIsMethod || isMethod) { if (prevIsMethod !== isMethod) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered } - else if (prev & meaning & ~16 /* PrivateStatic */) { + else if (prev & meaning & ~16 /* DeclarationMeaning.PrivateStatic */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { @@ -81035,15 +81327,15 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 166 /* PropertySignature */) { + if (member.kind === 166 /* SyntaxKind.PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: memberName = name.text; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: memberName = ts.idText(name); break; default: @@ -81060,7 +81352,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -81074,7 +81366,7 @@ var ts; var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var indexSignatureMap_1 = new ts.Map(); - var _loop_28 = function (declaration) { + var _loop_29 = function (declaration) { if (declaration.parameters.length === 1 && declaration.parameters[0].type) { forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) { var entry = indexSignatureMap_1.get(getTypeId(type)); @@ -81089,7 +81381,7 @@ var ts; }; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - _loop_28(declaration); + _loop_29(declaration); } indexSignatureMap_1.forEach(function (entry) { if (entry.declarations.length > 1) { @@ -81108,7 +81400,7 @@ var ts; checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); // property signatures already report "initializer not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* PropertyDeclaration */ && node.initializer) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && node.initializer) { error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -81128,7 +81420,7 @@ var ts; // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // method signatures already report "implementation not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 169 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } // Private named methods are only allowed in class declarations @@ -81138,9 +81430,9 @@ var ts; setNodeLinksForPrivateIdentifierScope(node); } function setNodeLinksForPrivateIdentifierScope(node) { - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ScriptTarget.ESNext */) { for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; + getNodeLinks(lexicalScope).flags |= 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */; } // If this is a private element in a class expression inside the body of a loop, // then we must use a block-scoped binding to store the additional variables required @@ -81148,8 +81440,8 @@ var ts; if (ts.isClassExpression(node.parent)) { var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); if (enclosingIterationStatement) { - getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(node.name).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } } @@ -81181,7 +81473,7 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 167 /* PropertyDeclaration */ && + return n.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(n) && !!n.initializer; } @@ -81202,9 +81494,9 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && + var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ModifierFlags.ParameterPropertyModifier */); })); if (superCallShouldBeRootLevel) { // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional // See GH #8277 @@ -81243,7 +81535,7 @@ var ts; return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body; } function nodeImmediatelyReferencesSuperOrThis(node) { - if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || node.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } if (ts.isThisContainerOrFunctionBlock(node)) { @@ -81264,9 +81556,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 172 /* GetAccessor */) { - if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { - if (!(node.flags & 512 /* HasExplicitReturn */)) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* NodeFlags.HasImplicitReturn */)) { + if (!(node.flags & 512 /* NodeFlags.HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -81274,25 +81566,25 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var symbol = getSymbolOfNode(node); - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); - if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { - getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* NodeCheckFlags.TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* NodeCheckFlags.TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); var setterFlags = ts.getEffectiveModifierFlags(setter); - if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) { + if ((getterFlags & 128 /* ModifierFlags.Abstract */) !== (setterFlags & 128 /* ModifierFlags.Abstract */)) { error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) || - ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) { + if (((getterFlags & 16 /* ModifierFlags.Protected */) && !(setterFlags & (16 /* ModifierFlags.Protected */ | 8 /* ModifierFlags.Private */))) || + ((getterFlags & 8 /* ModifierFlags.Private */) && !(setterFlags & 8 /* ModifierFlags.Private */))) { error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -81304,7 +81596,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -81312,6 +81604,12 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function getEffectiveTypeArgumentAtIndex(node, typeParameters, index) { + if (index < typeParameters.length) { + return getTypeFromTypeNode(node.typeArguments[index]); + } + return getEffectiveTypeArguments(node, typeParameters)[index]; + } function getEffectiveTypeArguments(node, typeParameters) { return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node)); } @@ -81336,15 +81634,15 @@ var ts; if (!isErrorType(type)) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || - (ts.getObjectFlags(type) & 4 /* Reference */ ? type.target.localTypeParameters : undefined); + return symbol.flags & 524288 /* SymbolFlags.TypeAlias */ && getSymbolLinks(symbol).typeParameters || + (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target.localTypeParameters : undefined); } } return undefined; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 178 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -81360,10 +81658,10 @@ var ts; } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) { + if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) { addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } - if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -81402,29 +81700,29 @@ var ts; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) { var e = elementTypes_1[_i]; - if (e.kind !== 197 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 197 /* SyntaxKind.NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } var flags = getTupleElementFlags(e); - if (flags & 8 /* Variadic */) { + if (flags & 8 /* ElementFlags.Variadic */) { var type = getTypeFromTypeNode(e.type); if (!isArrayLikeType(type)) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); break; } - if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) { + if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* ElementFlags.Rest */) { seenRestElement = true; } } - else if (flags & 4 /* Rest */) { + else if (flags & 4 /* ElementFlags.Rest */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element); break; } seenRestElement = true; } - else if (flags & 2 /* Optional */) { + else if (flags & 2 /* ElementFlags.Optional */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element); break; @@ -81444,15 +81742,15 @@ var ts; getTypeFromTypeNode(node); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 8388608 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* TypeFlags.IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 207 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && - ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { + if (accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + ts.getObjectFlags(objectType) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; @@ -81460,14 +81758,14 @@ var ts; // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. var apparentObjectType = getApparentType(objectType); - if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { return type; } if (isGenericObjectType(objectType)) { var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode); if (propertyName_1) { var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); }); - if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) { error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1)); return errorType; } @@ -81516,7 +81814,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* SyntaxKind.ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -81526,7 +81824,7 @@ var ts; if (!links.typeParametersChecked) { links.typeParametersChecked = true; var typeParameter = getDeclaredTypeOfTypeParameter(symbol); - var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */); + var declarations = ts.getDeclarationsOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); @@ -81567,31 +81865,31 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 185 /* OptionalType */) { + if (node.type.kind === 185 /* SyntaxKind.OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 186 /* RestType */) { + if (node.type.kind === 186 /* SyntaxKind.RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* NodeFlags.Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 258 /* InterfaceDeclaration */ && - n.parent.kind !== 257 /* ClassDeclaration */ && - n.parent.kind !== 226 /* ClassExpression */ && - n.flags & 16777216 /* Ambient */) { - if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { + if (n.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */ && + n.parent.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + n.parent.kind !== 226 /* SyntaxKind.ClassExpression */ && + n.flags & 16777216 /* NodeFlags.Ambient */) { + if (!(flags & 2 /* ModifierFlags.Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; } return flags & flagsToCheck; } @@ -81616,16 +81914,16 @@ var ts; var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; - if (deviation & 1 /* Export */) { + if (deviation & 1 /* ModifierFlags.Export */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 2 /* ModifierFlags.Ambient */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 128 /* Abstract */) { + else if (deviation & 128 /* ModifierFlags.Abstract */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -81642,8 +81940,8 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; - var someNodeFlags = 0 /* None */; + var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */; + var someNodeFlags = 0 /* ModifierFlags.None */; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; var allHaveQuestionToken = true; @@ -81652,7 +81950,7 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0; function reportImplementationExpectedError(node) { if (node.name && ts.nodeIsMissing(node.name)) { return; @@ -81681,7 +81979,7 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */) && + var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) && ts.isStatic(node) !== ts.isStatic(subsequentNode); // we can get here in two cases // 1. mixed static and instance class members @@ -81706,7 +82004,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -81722,8 +82020,8 @@ var ts; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var current = declarations_5[_i]; var node = current; - var inAmbientContext = node.flags & 16777216 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -81734,10 +82032,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 256 /* FunctionDeclaration */ || node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */ || node.kind === 171 /* Constructor */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */ || node.kind === 171 /* SyntaxKind.Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -81781,13 +82079,13 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { - var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* ClassDeclaration */; }) + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* SymbolFlags.Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* SyntaxKind.ClassDeclaration */; }) .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - var diagnostic = declaration.kind === 257 /* ClassDeclaration */ + var diagnostic = declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 - : declaration.kind === 256 /* FunctionDeclaration */ + : declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : undefined; if (diagnostic) { @@ -81797,7 +82095,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* ModifierFlags.Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -81837,15 +82135,15 @@ var ts; if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; + var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 512 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */); + if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) { + if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -81878,56 +82176,56 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: - return 2 /* ExportType */; - case 261 /* ModuleDeclaration */: - return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4 /* ExportNamespace */ | 1 /* ExportValue */ - : 4 /* ExportNamespace */; - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - return 2 /* ExportType */ | 1 /* ExportValue */; - case 305 /* SourceFile */: - return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + return 2 /* DeclarationSpaces.ExportType */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* ModuleInstanceState.NonInstantiated */ + ? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */ + : 4 /* DeclarationSpaces.ExportNamespace */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */; + case 305 /* SyntaxKind.SourceFile */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */; + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: var node_2 = d; var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(expression)) { - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; } d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: - var result_12 = 0 /* None */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + var result_12 = 0 /* DeclarationSpaces.None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 256 /* FunctionDeclaration */: - case 270 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* SyntaxKind.Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) // or SyntaxKind.PropertyAccessExpression - `thing.aField = 42;` // all of which are pretty much always values, or at least imply a value meaning. // It may be apprpriate to treat these as aliases in the future. - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); } @@ -81963,14 +82261,14 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } // primitives with a `{ then() }` won't be unwrapped/adopted. - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { return undefined; } var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : ts.emptyArray; + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* SignatureKind.Call */) : ts.emptyArray; if (thenSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); @@ -81999,18 +82297,18 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* TypeFacts.NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* SignatureKind.Call */); if (onfulfilledParameterSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); } return undefined; } - return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* Subtype */); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* UnionReduction.Subtype */); } /** * Gets the "awaited type" of a type. @@ -82030,16 +82328,16 @@ var ts; * Determines whether a type is an object with a callable `then` member. */ function isThenableType(type) { - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { // primitive types cannot be considered "thenable" since they are not objects. return false; } var thenFunction = getTypeOfPropertyOfType(type, "then"); - return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; + return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* TypeFacts.NEUndefinedOrNull */), 0 /* SignatureKind.Call */).length > 0; } function isAwaitedTypeInstantiation(type) { var _a; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false); return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1; } @@ -82049,10 +82347,38 @@ var ts; * For a generic `Awaited`, gets `T`. */ function unwrapAwaitedType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, unwrapAwaitedType) : isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } + function isAwaitedTypeNeeded(type) { + // If this is already an `Awaited`, we shouldn't wrap it. This helps to avoid `Awaited>` in higher-order. + if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) { + return false; + } + // We only need `Awaited` if `T` contains possibly non-primitive types. + if (isGenericObjectType(type)) { + var baseConstraint = getBaseConstraintOfType(type); + // We only need `Awaited` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, + // or is promise-like. + if (baseConstraint ? + baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) : + maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) { + return true; + } + } + return false; + } + function tryCreateAwaitedType(type) { + // Nothing to do if `Awaited` doesn't exist + var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); + if (awaitedSymbol) { + // Unwrap unions that may contain `Awaited`, otherwise its possible to manufacture an `Awaited | U>` where + // an `Awaited` would suffice. + return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); + } + return undefined; + } function createAwaitedTypeIfNeeded(type) { // We wrap type `T` in `Awaited` based on the following conditions: // - `T` is not already an `Awaited`, and @@ -82061,26 +82387,10 @@ var ts; // - `T` has no base constraint, or // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or // - The base constraint of `T` is an object type with a callable `then` method. - if (isTypeAny(type)) { - return type; - } - // If this is already an `Awaited`, just return it. This helps to avoid `Awaited>` in higher-order. - if (isAwaitedTypeInstantiation(type)) { - return type; - } - // Only instantiate `Awaited` if `T` contains possibly non-primitive types. - if (isGenericObjectType(type)) { - var baseConstraint = getBaseConstraintOfType(type); - // Only instantiate `Awaited` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, - // or is promise-like. - if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { - // Nothing to do if `Awaited` doesn't exist - var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); - if (awaitedSymbol) { - // Unwrap unions that may contain `Awaited`, otherwise its possible to manufacture an `Awaited | U>` where - // an `Awaited` would suffice. - return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); - } + if (isAwaitedTypeNeeded(type)) { + var awaitedType = tryCreateAwaitedType(type); + if (awaitedType) { + return awaitedType; } } ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like."); @@ -82119,9 +82429,22 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } // For a union, get a union of the awaited types of each constituent. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { + if (awaitedTypeStack.lastIndexOf(type.id) >= 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; - return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); + awaitedTypeStack.push(type.id); + var mapped = mapType(type, mapper); + awaitedTypeStack.pop(); + return typeAsAwaitable.awaitedTypeOfType = mapped; + } + // If `type` is generic and should be wrapped in `Awaited`, return it. + if (isAwaitedTypeNeeded(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; } var thisTypeForErrorOut = { value: undefined }; var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut); @@ -82242,7 +82565,7 @@ var ts; // } // var returnType = getTypeFromTypeNode(returnTypeNode); - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { if (isErrorType(returnType)) { return; } @@ -82265,10 +82588,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (isErrorType(promiseConstructorType)) { - if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* SyntaxKind.Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -82288,7 +82611,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* SymbolFlags.Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -82301,26 +82624,26 @@ var ts; var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { + if (returnType.flags & 1 /* TypeFlags.Any */) { return; } var headMessage; var expectedReturnType; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any; expectedReturnType = voidType; break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); @@ -82342,9 +82665,9 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* SyntaxKind.Identifier */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */) | 2097152 /* SymbolFlags.Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true); - if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) { + if (rootSymbol && rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) { if (symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) { @@ -82379,15 +82702,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; } } @@ -82396,13 +82719,13 @@ var ts; var commonEntityName; for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { var typeNode = types_21[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */ || typeNode.kind === 197 /* SyntaxKind.NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -82447,15 +82770,15 @@ var ts; if (!firstDecorator) { return; } - checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 164 /* Parameter */) { - checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + checkExternalEmitHelpers(firstDecorator, 8 /* ExternalEmitHelpers.Decorate */); + if (node.kind === 164 /* SyntaxKind.Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* ExternalEmitHelpers.Param */); } if (compilerOptions.emitDecoratorMetadata) { - checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); + checkExternalEmitHelpers(firstDecorator, 16 /* ExternalEmitHelpers.Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -82464,23 +82787,23 @@ var ts; } } break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - var otherKind = node.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + var otherKind = node.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -82580,9 +82903,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; default: return undefined; @@ -82596,7 +82919,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -82612,7 +82935,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find( // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* NodeFlags.JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -82622,7 +82945,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 168 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 168 /* SyntaxKind.MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics); @@ -82640,7 +82963,7 @@ var ts; if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { reportImplicitAny(node, anyType); } - if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) { + if (functionFlags & 1 /* FunctionFlags.Generator */ && ts.nodeIsPresent(body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -82668,42 +82991,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 305 /* SourceFile */: - case 261 /* ModuleDeclaration */: - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 305 /* SyntaxKind.SourceFile */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -82714,41 +83037,41 @@ var ts; function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(declaration, 0 /* Local */, ts.createDiagnosticForNode(node, message, name)); + addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name)); } function isIdentifierThatStartsWithUnderscore(node) { - return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; + return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* CharacterCodes._ */; } function checkUnusedClassMembers(node, addDiagnostic) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - if (member.kind === 173 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && member.symbol.flags & 32768 /* SymbolFlags.GetAccessor */) { // Already would have reported an error on the getter. break; } var symbol = getSymbolOfNode(member); if (!symbol.isReferenced - && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) - && !(member.flags & 16777216 /* Ambient */)) { - addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); + && (ts.hasEffectiveModifier(member, 8 /* ModifierFlags.Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) + && !(member.flags & 16777216 /* NodeFlags.Ambient */)) { + addDiagnostic(member, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { - addDiagnostic(parameter, 0 /* Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); + if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* ModifierFlags.Private */)) { + addDiagnostic(parameter, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); } } break; - case 176 /* IndexSignature */: - case 234 /* SemicolonClassElement */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 234 /* SyntaxKind.SemicolonClassElement */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Can't be private break; default: @@ -82759,7 +83082,7 @@ var ts; function checkUnusedInferTypeParameter(node, addDiagnostic) { var typeParameter = node.typeParameter; if (isTypeParameterUnused(typeParameter)) { - addDiagnostic(node, 1 /* Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); + addDiagnostic(node, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); } } function checkUnusedTypeParameters(node, addDiagnostic) { @@ -82770,13 +83093,13 @@ var ts; return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); - for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { - var typeParameter = typeParameters_3[_i]; + for (var _i = 0, typeParameters_4 = typeParameters; _i < typeParameters_4.length; _i++) { + var typeParameter = typeParameters_4[_i]; if (!isTypeParameterUnused(typeParameter)) continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 190 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 190 /* SyntaxKind.InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -82788,17 +83111,17 @@ var ts; //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); } } else { //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); } } } function isTypeParameterUnused(typeParameter) { - return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); + return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* SymbolFlags.TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); } function addToGroup(map, key, value, getKey) { var keyString = String(getKey(key)); @@ -82835,7 +83158,7 @@ var ts; nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. - if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { + if (local.flags & 262144 /* SymbolFlags.TypeParameter */ ? !(local.flags & 3 /* SymbolFlags.Variable */ && !(local.isReferenced & 3 /* SymbolFlags.Variable */)) : local.isReferenced || local.exportSymbol) { return; } if (local.declarations) { @@ -82866,7 +83189,7 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } else { - addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + addDiagnostic(parameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } } @@ -82882,10 +83205,10 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 268 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { - addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 + addDiagnostic(importDecl, 0 /* UnusedKind.Local */, unuseds.length === 1 ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); } @@ -82898,9 +83221,9 @@ var ts; }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; - var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; + var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -82919,14 +83242,14 @@ var ts; unusedVariables.forEach(function (_a) { var declarationList = _a[0], declarations = _a[1]; if (declarationList.declarations.length === declarations.length) { - addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 + addDiagnostic(declarationList, 0 /* UnusedKind.Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { var decl = declarations_6[_i]; - addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); + addDiagnostic(decl, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); } } }); @@ -82949,24 +83272,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.idText(name); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 267 /* ImportClause */ || node.kind === 270 /* ImportSpecifier */ || node.kind === 268 /* NamespaceImport */; + return node.kind === 267 /* SyntaxKind.ImportClause */ || node.kind === 270 /* SyntaxKind.ImportSpecifier */ || node.kind === 268 /* SyntaxKind.NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 267 /* ImportClause */ ? decl : decl.kind === 268 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 267 /* SyntaxKind.ImportClause */ ? decl : decl.kind === 268 /* SyntaxKind.NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 235 /* Block */) { + if (node.kind === 235 /* SyntaxKind.Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -82983,7 +83306,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* NodeFlags.Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -83001,17 +83324,17 @@ var ts; if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - if (node.kind === 167 /* PropertyDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 169 /* MethodDeclaration */ || - node.kind === 168 /* MethodSignature */ || - node.kind === 172 /* GetAccessor */ || - node.kind === 173 /* SetAccessor */ || - node.kind === 296 /* PropertyAssignment */) { + if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */ || + node.kind === 168 /* SyntaxKind.MethodSignature */ || + node.kind === 172 /* SyntaxKind.GetAccessor */ || + node.kind === 173 /* SyntaxKind.SetAccessor */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */) { // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // ambient context - no codegen impact return false; } @@ -83031,8 +83354,8 @@ var ts; // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 4 /* NodeCheckFlags.CaptureThis */) { + var isDeclaration_1 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -83046,8 +83369,8 @@ var ts; } function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 8 /* NodeCheckFlags.CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -83068,46 +83391,46 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { + if (!name || languageVersion >= 4 /* ScriptTarget.ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* NodeFlags.HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) { - if (languageVersion <= 8 /* ES2021 */ + if (languageVersion <= 8 /* ScriptTarget.ES2021 */ && (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) { potentialWeakMapSetCollisions.push(node); } } function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); - if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { + if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */) { ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); } } function recordPotentialCollisionWithReflectInGeneratedCode(node, name) { - if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ + if (name && languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && needCollisionCheckForIdentifier(node, name, "Reflect")) { potentialReflectCollisions.push(node); } @@ -83118,7 +83441,7 @@ var ts; // ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(member) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; break; } @@ -83126,13 +83449,13 @@ var ts; } else if (ts.isFunctionExpression(node)) { // FunctionExpression names don't contribute to their containers, but do matter for their contents - if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(node) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } else { var container = ts.getEnclosingBlockScopeContainer(node); - if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (container && getNodeCheckFlags(container) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } @@ -83150,7 +83473,7 @@ var ts; recordPotentialCollisionWithReflectInGeneratedCode(node, name); if (ts.isClassLike(node)) { checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0); - if (!(node.flags & 16777216 /* Ambient */)) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */)) { checkClassNameCollisionWithObject(name); } } @@ -83182,35 +83505,35 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3 /* NodeFlags.BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 254 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { + if (symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) return ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* SymbolFlags.Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 237 /* VariableStatement */ && varDeclList.parent.parent + localDeclarationSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* NodeFlags.BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); + var container = varDeclList.parent.kind === 237 /* SyntaxKind.VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 235 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 262 /* ModuleBlock */ || - container.kind === 261 /* ModuleDeclaration */ || - container.kind === 305 /* SourceFile */); + (container.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(container.parent) || + container.kind === 262 /* SyntaxKind.ModuleBlock */ || + container.kind === 261 /* SyntaxKind.ModuleDeclaration */ || + container.kind === 305 /* SyntaxKind.SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -83241,7 +83564,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { checkExpressionCached(node.initializer); @@ -83259,16 +83582,16 @@ var ts; potentialUnusedRenamedBindingElementsInTypes.push(node); return; } - if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { - checkExternalEmitHelpers(node, 4 /* Rest */); + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ScriptTarget.ES2018 */) { + checkExternalEmitHelpers(node, 4 /* ExternalEmitHelpers.Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 162 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access var parent = node.parent.parent; - var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var parentCheckMode = node.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(parent, parentCheckMode); var name = node.propertyName || node.name; if (parentType && !ts.isBindingPattern(name)) { @@ -83278,15 +83601,15 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SyntaxKind.SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 202 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (node.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } ts.forEach(node.name.elements, checkSourceElement); } @@ -83297,7 +83620,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = ts.hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */; + var needCheckInitializer = ts.hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */; var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression)); if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -83314,7 +83637,7 @@ var ts; // check the binding pattern with empty elements if (needCheckWidenedType) { if (ts.isArrayBindingPattern(node.name)) { - checkIteratedTypeOrElementType(65 /* Destructuring */, widenedType, undefinedType, node); + checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, widenedType, undefinedType, node); } else if (strictNullChecks) { checkNonNullNonVoidType(widenedType, node); @@ -83325,7 +83648,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* SyntaxKind.BindingElement */ ? node.parent.parent : node)) { checkAliasSymbol(node); return; } @@ -83339,7 +83662,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -83355,7 +83678,7 @@ var ts; var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (!isErrorType(type) && !isErrorType(declarationType) && !isTypeIdenticalTo(type, declarationType) && - !(symbol.flags & 67108864 /* Assignment */)) { + !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { @@ -83365,10 +83688,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */) { + if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionsForDeclarationName(node, node.name); @@ -83376,7 +83699,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 167 /* PropertyDeclaration */ || nextDeclaration.kind === 166 /* PropertySignature */ + var message = nextDeclaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 166 /* SyntaxKind.PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -83386,24 +83709,24 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 164 /* Parameter */ && right.kind === 254 /* VariableDeclaration */) || - (left.kind === 254 /* VariableDeclaration */ && right.kind === 164 /* Parameter */)) { + if ((left.kind === 164 /* SyntaxKind.Parameter */ && right.kind === 254 /* SyntaxKind.VariableDeclaration */) || + (left.kind === 254 /* SyntaxKind.VariableDeclaration */ && right.kind === 164 /* SyntaxKind.Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* ModifierFlags.Private */ | + 16 /* ModifierFlags.Protected */ | + 256 /* ModifierFlags.Async */ | + 128 /* ModifierFlags.Abstract */ | + 64 /* ModifierFlags.Readonly */ | + 32 /* ModifierFlags.Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -83429,7 +83752,7 @@ var ts; checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 236 /* EmptyStatement */) { + if (node.thenStatement.kind === 236 /* SyntaxKind.EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -83438,27 +83761,27 @@ var ts; if (!strictNullChecks) return; helper(condExpr, body); - while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) { + while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { condExpr = condExpr.left; helper(condExpr, body); } function helper(condExpr, body) { var location = ts.isBinaryExpression(condExpr) && - (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */) + (condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || condExpr.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) ? condExpr.right : condExpr; if (ts.isModuleExportsAccessExpression(location)) return; var type = checkTruthinessExpression(location); var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression); - if (!(getTypeFacts(type) & 4194304 /* Truthy */) || isPropertyExpressionCast) + if (!(getTypeFacts(type) & 4194304 /* TypeFacts.Truthy */) || isPropertyExpressionCast) return; // While it technically should be invalid for any known-truthy value // to be tested, we de-scope to functions and Promises unreferenced in // the block as a heuristic to identify the most common bugs. There // are too many false positives for values sourced from type // definitions without strictNullChecks otherwise. - var callSignatures = getSignaturesOfType(type, 0 /* Call */); + var callSignatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var isPromise = !!getAwaitedTypeOfPromise(type); if (callSignatures.length === 0 && !isPromise) { return; @@ -83498,7 +83821,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { + testedExpression.kind === 108 /* SyntaxKind.ThisKeyword */ && childExpression.kind === 108 /* SyntaxKind.ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -83522,7 +83845,7 @@ var ts; }); } function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { - while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { var symbol = getSymbolAtLocation(child); @@ -83552,7 +83875,7 @@ var ts; checkSourceElement(node.statement); } function checkTruthinessOfType(type, node) { - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -83563,12 +83886,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -83593,29 +83916,29 @@ var ts; } else { var functionFlags = ts.getFunctionFlags(container); - if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { + if ((functionFlags & (4 /* FunctionFlags.Invalid */ | 2 /* FunctionFlags.Async */)) === 2 /* FunctionFlags.Async */ && languageVersion < 99 /* ScriptTarget.ESNext */) { // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper - checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + checkExternalEmitHelpers(node, 16384 /* ExternalEmitHelpers.ForAwaitOfIncludes */); } } } - else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) { + else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ScriptTarget.ES2015 */) { // for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled - checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.ForOfIncludes */); } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -83647,7 +83970,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -83661,7 +83984,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -83674,7 +83997,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -83691,7 +84014,7 @@ var ts; } } function checkRightHandSideOfForOf(statement) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) { @@ -83706,14 +84029,14 @@ var ts; * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) { - var allowAsyncIterables = (use & 2 /* AllowsAsyncIterablesFlag */) !== 0; + var allowAsyncIterables = (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) !== 0; if (inputType === neverType) { reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } - var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var uplevelIteration = languageVersion >= 2 /* ScriptTarget.ES2015 */; var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; - var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */); + var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* IterationUse.PossiblyOutOfBounds */); // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. @@ -83722,10 +84045,10 @@ var ts; var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined); if (checkAssignability) { if (iterationTypes) { - var diagnostic = use & 8 /* ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : - use & 32 /* SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : - use & 64 /* DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : - use & 16 /* YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : + var diagnostic = use & 8 /* IterationUse.ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : + use & 32 /* IterationUse.SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : + use & 64 /* IterationUse.DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : + use & 16 /* IterationUse.YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : undefined; if (diagnostic) { checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic); @@ -83742,22 +84065,22 @@ var ts; // If strings are permitted, remove any string-like constituents from the array type. // This allows us to find other non-string element types from an array unioned with // a string. - if (use & 4 /* AllowsStringInputFlag */) { - if (arrayType.flags & 1048576 /* Union */) { + if (use & 4 /* IterationUse.AllowsStringInputFlag */) { + if (arrayType.flags & 1048576 /* TypeFlags.Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* TypeFlags.StringLike */); }); if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, 2 /* Subtype */); + arrayType = getUnionType(filteredTypes, 2 /* UnionReduction.Subtype */); } } - else if (arrayType.flags & 402653316 /* StringLike */) { + else if (arrayType.flags & 402653316 /* TypeFlags.StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { if (errorNode) { error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); reportedError = true; @@ -83765,7 +84088,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 131072 /* Never */) { + if (arrayType.flags & 131072 /* TypeFlags.Never */) { return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType; } } @@ -83777,7 +84100,7 @@ var ts; // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var allowsStrings = !!(use & 4 /* IterationUse.AllowsStringInputFlag */) && !hasStringConstituent; var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } @@ -83786,12 +84109,12 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, numberType); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { + if (arrayElementType.flags & 402653316 /* TypeFlags.StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } - return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); + return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* UnionReduction.Subtype */); } - return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + return (use & 128 /* IterationUse.PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { var _a; if (downlevelIteration) { @@ -83799,7 +84122,7 @@ var ts; ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] : [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]; } - var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); + var yieldType = getIterationTypeOfIterable(use, 0 /* IterationTypeKind.Yield */, inputType, /*errorNode*/ undefined); if (yieldType) { return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } @@ -83848,9 +84171,9 @@ var ts; // more frequently created (i.e. `Iterator`). Iteration types // are also cached on the type they are requested for, so we shouldn't need to maintain // the cache for less-frequently used types. - if (yieldType.flags & 67359327 /* Intrinsic */ && - returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && - nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) { + if (yieldType.flags & 67359327 /* TypeFlags.Intrinsic */ && + returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */) && + nextType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { var id = getTypeListId([yieldType, returnType, nextType]); var iterationTypes = iterationTypesCache.get(id); if (!iterationTypes) { @@ -83917,37 +84240,56 @@ var ts; * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method. */ function getIterationTypesOfIterable(type, use, errorNode) { + var _a, _b; if (isTypeAny(type)) { return anyIterationTypes; } - if (!(type.flags & 1048576 /* Union */)) { - var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } return undefined; } + else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) { + for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) { + var diag = _c[_i]; + diagnostics.add(diag); + } + } return iterationTypes_1; } - var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; + var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; var cachedTypes = getCachedIterationTypes(type, cacheKey); if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; var allIterationTypes; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituent = _a[_i]; - var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); + for (var _d = 0, _e = type.types; _d < _e.length; _d++) { + var constituent = _e[_d]; + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; } - else { - allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); + else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) { + for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) { + var diag = _g[_f]; + diagnostics.add(diag); + } } + allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); } var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes; setCachedIterationTypes(type, cacheKey, iterationTypes); @@ -83975,47 +84317,62 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterable` instead. */ - function getIterationTypesOfIterableWorker(type, use, errorNode) { + function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) { if (isTypeAny(type)) { return anyIterationTypes; } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + // If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached. + // In addition, we should not cache any new results for this call. + var noCache = false; + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 /* ForOfFlag */ ? - getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : - iterationTypes; + if (iterationTypes === noIterationTypes && errorNode) { + // ignore the cached value + noCache = true; + } + else { + return use & 8 /* IterationUse.ForOfFlag */ ? + getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : + iterationTypes; + } } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { - // for a sync iterable in an async context, only use the cached types if they are valid. - if (iterationTypes !== noIterationTypes) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); - } + if (iterationTypes === noIterationTypes && errorNode) { + // ignore the cached value + noCache = true; } else { - return iterationTypes; + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + // for a sync iterable in an async context, only use the cached types if they are valid. + if (iterationTypes !== noIterationTypes) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); + } + } + else { + return iterationTypes; + } } } } - if (use & 2 /* AllowsAsyncIterablesFlag */) { - var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { - var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { + var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes - ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) - : noIterationTypes); + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); } else { return iterationTypes; @@ -84036,7 +84393,7 @@ var ts; } function getIterationTypesOfGlobalIterableType(globalType, resolver) { var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) || - getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined); + getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false); return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes; } /** @@ -84078,7 +84435,7 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like @@ -84090,26 +84447,26 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterable` instead. */ - function getIterationTypesOfIterableSlow(type, resolver, errorNode) { + function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); - var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; + var methodType = method && !(method.flags & 16777216 /* SymbolFlags.Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); + return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } - var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : undefined; if (!ts.some(signatures)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); + return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature)); - var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes; - return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); + var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes; + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); } function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) { var message = allowAsyncIterables ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator; - errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); + return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); } /** * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type. @@ -84117,13 +84474,29 @@ var ts; * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` * record is returned. Otherwise, `undefined` is returned. */ - function getIterationTypesOfIterator(type, resolver, errorNode) { + function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) { + return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false); + } + /** + * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type. + * + * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` + * record is returned. Otherwise, `undefined` is returned. + * + * NOTE: You probably don't want to call this directly and should be calling + * `getIterationTypesOfIterator` instead. + */ + function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) { if (isTypeAny(type)) { return anyIterationTypes; } var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) || - getIterationTypesOfIteratorFast(type, resolver) || - getIterationTypesOfIteratorSlow(type, resolver, errorNode); + getIterationTypesOfIteratorFast(type, resolver); + if (iterationTypes === noIterationTypes && errorNode) { + iterationTypes = undefined; + noCache = true; + } + iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache)); return iterationTypes === noIterationTypes ? undefined : iterationTypes; } /** @@ -84161,7 +84534,7 @@ var ts; // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || - getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined); + getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false); var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType; return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType)); } @@ -84177,13 +84550,13 @@ var ts; // > If the end was not reached `done` is `false` and a value is available. // > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`. var doneType = getTypeOfPropertyOfType(type, "done") || falseType; - return isTypeAssignableTo(kind === 0 /* Yield */ ? falseType : trueType, doneType); + return isTypeAssignableTo(kind === 0 /* IterationTypeKind.Yield */ ? falseType : trueType, doneType); } function isYieldIteratorResult(type) { - return isIteratorResult(type, 0 /* Yield */); + return isIteratorResult(type, 0 /* IterationTypeKind.Yield */); } function isReturnIteratorResult(type) { - return isIteratorResult(type, 1 /* Return */); + return isIteratorResult(type, 1 /* IterationTypeKind.Return */); } /** * Gets the *yield* and *return* types of an `IteratorResult`-like type. @@ -84231,30 +84604,36 @@ var ts; * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` * record is returned. Otherwise, we return `undefined`. */ - function getIterationTypesOfMethod(type, resolver, methodName, errorNode) { - var _a, _b, _c, _d; + function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) { + var _a, _b, _c, _d, _e, _f; var method = getPropertyOfType(type, methodName); // Ignore 'return' or 'throw' if they are missing. if (!method && methodName !== "next") { return undefined; } - var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* Optional */)) - ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */) + var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* SymbolFlags.Optional */)) + ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* TypeFacts.NEUndefinedOrNull */) : undefined; if (isTypeAny(methodType)) { // `return()` and `throw()` don't provide a *next* type. return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext; } // Both async and non-async iterators *must* have a `next` method. - var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : ts.emptyArray; + var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : ts.emptyArray; if (methodSignatures.length === 0) { if (errorNode) { var diagnostic = methodName === "next" ? resolver.mustHaveANextMethodDiagnostic : resolver.mustBeAMethodDiagnostic; - error(errorNode, diagnostic, methodName); + if (errorOutputContainer) { + (_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName)); + } + else { + error(errorNode, diagnostic, methodName); + } } - return methodName === "next" ? anyIterationTypes : undefined; + return methodName === "next" ? noIterationTypes : undefined; } // If the method signature comes exclusively from the global iterator or generator type, // create iteration types from its type arguments like `getIterationTypesOfIteratorFast` @@ -84266,8 +84645,8 @@ var ts; if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) { var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false); var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false); - var isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get(methodName)) === methodType.symbol; - var isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) === null || _c === void 0 ? void 0 : _c.members) === null || _d === void 0 ? void 0 : _d.get(methodName)) === methodType.symbol; + var isGeneratorMethod = ((_c = (_b = globalGeneratorType.symbol) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.get(methodName)) === methodType.symbol; + var isIteratorMethod = !isGeneratorMethod && ((_e = (_d = globalIteratorType.symbol) === null || _d === void 0 ? void 0 : _d.members) === null || _e === void 0 ? void 0 : _e.get(methodName)) === methodType.symbol; if (isGeneratorMethod || isIteratorMethod) { var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType; var mapper = methodType.mapper; @@ -84307,7 +84686,13 @@ var ts; var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType); if (iterationTypes === noIterationTypes) { if (errorNode) { - error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + if (errorOutputContainer) { + (_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName)); + } + else { + error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + } } yieldType = anyType; returnTypes = ts.append(returnTypes, anyType); @@ -84328,13 +84713,13 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterator` instead. */ - function getIterationTypesOfIteratorSlow(type, resolver, errorNode) { + function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var iterationTypes = combineIterationTypes([ - getIterationTypesOfMethod(type, resolver, "next", errorNode), - getIterationTypesOfMethod(type, resolver, "return", errorNode), - getIterationTypesOfMethod(type, resolver, "throw", errorNode), + getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer), ]); - return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); } /** * Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like, @@ -84352,10 +84737,10 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + var use = isAsyncGenerator ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) || - getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined); + getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined); } function checkBreakOrContinueStatement(node) { // Grammar checking @@ -84364,15 +84749,20 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { - var isGenerator = !!(functionFlags & 1 /* Generator */); - var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : - isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : - returnType; + var isGenerator = !!(functionFlags & 1 /* FunctionFlags.Generator */); + var isAsync = !!(functionFlags & 2 /* FunctionFlags.Async */); + if (isGenerator) { + var returnIterationType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, isAsync); + if (!returnIterationType) { + return errorType; + } + return isAsync ? getAwaitedTypeNoAlias(unwrapAwaitedType(returnIterationType)) : returnIterationType; + } + return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* TypeFlags.Void */ | 3 /* TypeFlags.AnyOrUnknown */); } function checkReturnStatement(node) { var _a; @@ -84392,21 +84782,21 @@ var ts; var signature = getSignatureFromDeclaration(container); var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(container); - if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* TypeFlags.Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (container.kind === 173 /* SetAccessor */) { + if (container.kind === 173 /* SyntaxKind.SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (getReturnTypeFromAnnotation(container)) { var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; - var unwrappedExprType = functionFlags & 2 /* Async */ + var unwrappedExprType = functionFlags & 2 /* FunctionFlags.Async */ ? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; if (unwrappedReturnType) { @@ -84417,7 +84807,7 @@ var ts; } } } - else if (container.kind !== 171 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { + else if (container.kind !== 171 /* SyntaxKind.Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -84425,7 +84815,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 32768 /* AwaitContext */) { + if (node.flags & 32768 /* NodeFlags.AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -84446,7 +84836,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 290 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -84455,7 +84845,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause)); } ts.forEach(clause.statements, checkSourceElement); @@ -84492,7 +84882,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 250 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 250 /* SyntaxKind.LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -84524,8 +84914,8 @@ var ts; var declaration = catchClause.variableDeclaration; var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); if (typeNode) { - var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */); - if (type && !(type.flags & 3 /* AnyOrUnknown */)) { + var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */); + if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) { grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } @@ -84537,7 +84927,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -84557,8 +84947,8 @@ var ts; } for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) { - checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); + if (!(isStaticIndex && prop.flags & 4194304 /* SymbolFlags.Prototype */)) { + checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); } } var typeDeclaration = symbol.valueDeclaration; @@ -84587,10 +84977,11 @@ var ts; return; } var indexInfos = getApplicableIndexInfos(type, propNameType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ || - name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; - var _loop_29 = function (info) { + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; + var propDeclaration = declaration && declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || + name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined; + var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var _loop_30 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and @@ -84598,20 +84989,24 @@ var ts; var errorNode = localPropDeclaration || localIndexDeclaration || (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined); if (errorNode && !isTypeAssignableTo(propType, info.type)) { - error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + if (propDeclaration && errorNode !== propDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop))); + } + diagnostics.add(diagnostic); } }; for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) { var info = indexInfos_9[_i]; - _loop_29(info); + _loop_30(info); } } function checkIndexConstraintForIndexSignature(type, checkInfo) { var declaration = checkInfo.declaration; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; - var _loop_30 = function (info) { + var _loop_31 = function (info) { if (info === checkInfo) return "continue"; var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; @@ -84626,7 +85021,7 @@ var ts; }; for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) { var info = indexInfos_10[_i]; - _loop_30(info); + _loop_31(info); } } function checkTypeNameIsReserved(name, message) { @@ -84650,7 +85045,7 @@ var ts; * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name) { - if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" + if (languageVersion >= 1 /* ScriptTarget.ES5 */ && name.escapedText === "Object" && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) { error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } @@ -84729,9 +85124,9 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 178 /* TypeReference */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */) { var type = getTypeFromTypeReference(node); - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { if (type.symbol === getSymbolOfNode(typeParameters[i])) { error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters); @@ -84819,7 +85214,7 @@ var ts; if (firstDecorator && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { grammarErrorOnNode(firstDecorator, ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) { + if (!node.name && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -84840,15 +85235,15 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */); } // check both @extends and extends if both are specified. var extendsNode = ts.getClassExtendsHeritageElement(node); @@ -84880,18 +85275,18 @@ var ts; // Report static side error only when instance type is assignable checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); } - if (baseConstructorType.flags & 8650752 /* TypeVariable */) { + if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) { if (!isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { - var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); + if (constructSignatures.some(function (signature) { return signature.flags & 4 /* SignatureFlags.Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* SymbolFlags.Class */) && !(baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); @@ -84926,7 +85321,7 @@ var ts; var t = getReducedType(getTypeFromTypeNode(typeRefNode)); if (!isErrorType(t)) { if (isValidBaseType(t)) { - var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? + var genericDiag = t.symbol && t.symbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : ts.Diagnostics.Class_0_incorrectly_implements_interface_1; var baseWithThis = getTypeWithThisArgument(t, type.thisType); @@ -84946,7 +85341,7 @@ var ts; var baseTypes = baseTypeNode && getBaseTypes(type); var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined; var baseStaticType = getBaseConstructorTypeOfClass(type); - var _loop_31 = function (member) { + var _loop_32 = function (member) { if (ts.hasAmbientModifier(member)) { return "continue"; } @@ -84963,7 +85358,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_31(member); + _loop_32(member); } } /** @@ -84976,7 +85371,7 @@ var ts; && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); if (!declaredProp) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined); } @@ -84990,7 +85385,7 @@ var ts; */ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) { var isJs = ts.isInJSFile(node); - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { var memberEscapedName = ts.escapeLeadingUnderscores(memberName); var thisType = memberIsStatic ? staticType : typeWithThis; @@ -85009,12 +85404,12 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier); if (memberHasOverrideModifier) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } if (!baseHasAbstract) { if (errorNode) { @@ -85027,13 +85422,13 @@ var ts; ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; error(errorNode, diag, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } else if (memberHasAbstractModifier && baseHasAbstract) { if (errorNode) { error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } } } @@ -85044,14 +85439,14 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_32 = function (member) { + var _loop_33 = function (member) { if (ts.isStatic(member)) { return "continue"; } @@ -85070,7 +85465,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_32(member); + _loop_33(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -85078,10 +85473,10 @@ var ts; } } function checkBaseTypeAccessibility(type, node) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) { var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -85097,7 +85492,7 @@ var ts; */ function getMemberOverrideModifierStatus(node, member) { if (!member.name) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -85109,7 +85504,7 @@ var ts; var baseStaticType = getBaseConstructorTypeOfClass(type); var memberHasOverrideModifier = member.parent ? ts.hasOverrideModifier(member) - : ts.hasSyntacticModifier(member, 16384 /* Override */); + : ts.hasSyntacticModifier(member, 16384 /* ModifierFlags.Override */); var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member), /* memberIsParameterProperty */ false, memberName); @@ -85117,11 +85512,11 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return ts.getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; + return ts.getCheckFlags(s) & 1 /* CheckFlags.Instantiated */ ? s.target : s; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 257 /* ClassDeclaration */ || d.kind === 258 /* InterfaceDeclaration */; + return d.kind === 257 /* SyntaxKind.ClassDeclaration */ || d.kind === 258 /* SyntaxKind.InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -85141,9 +85536,9 @@ var ts; var _a, _b, _c, _d; // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - var _loop_33 = function (baseProperty) { + var _loop_34 = function (baseProperty) { var base = getTargetSymbol(baseProperty); - if (base.flags & 4194304 /* Prototype */) { + if (base.flags & 4194304 /* SymbolFlags.Prototype */) { return "continue"; } var baseSymbol = getPropertyOfObjectType(type, base.escapedName); @@ -85162,7 +85557,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* ModifierFlags.Abstract */))) { // Searches other base types for a declaration that would satisfy the inherited abstract member. // (The class may have more than one base type via declaration merging with an interface with the // same name.) @@ -85176,7 +85571,7 @@ var ts; return "continue-basePropertyCheck"; } } - if (derivedClassDecl.kind === 226 /* ClassExpression */) { + if (derivedClassDecl.kind === 226 /* SyntaxKind.ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -85187,23 +85582,23 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 8 /* ModifierFlags.Private */ || derivedDeclarationFlags & 8 /* ModifierFlags.Private */) { return "continue"; } var errorMessage = void 0; - var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; - var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + var basePropertyFlags = base.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor - if ((ts.getCheckFlags(base) & 6 /* Synthetic */ + if ((ts.getCheckFlags(base) & 6 /* CheckFlags.Synthetic */ ? (_a = base.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); }) : (_b = base.declarations) === null || _b === void 0 ? void 0 : _b.every(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); })) - || ts.getCheckFlags(base) & 262144 /* Mapped */ + || ts.getCheckFlags(base) & 262144 /* CheckFlags.Mapped */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { return "continue"; } - var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */; - var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */; + var overriddenInstanceProperty = basePropertyFlags !== 4 /* SymbolFlags.Property */ && derivedPropertyFlags === 4 /* SymbolFlags.Property */; + var overriddenInstanceAccessor = basePropertyFlags === 4 /* SymbolFlags.Property */ && derivedPropertyFlags !== 4 /* SymbolFlags.Property */; if (overriddenInstanceProperty || overriddenInstanceAccessor) { var errorMessage_1 = overriddenInstanceProperty ? ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property : @@ -85211,12 +85606,12 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !d.initializer; }); if (uninitialized - && !(derived.flags & 33554432 /* Transient */) - && !(baseDeclarationFlags & 128 /* Abstract */) - && !(derivedDeclarationFlags & 128 /* Abstract */) - && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) { + && !(derived.flags & 33554432 /* SymbolFlags.Transient */) + && !(baseDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !(derivedDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* NodeFlags.Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -85232,15 +85627,15 @@ var ts; return "continue"; } else if (isPrototypeProperty(base)) { - if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* SymbolFlags.Property */) { return "continue"; } else { - ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + ts.Debug.assert(!!(derived.flags & 98304 /* SymbolFlags.Accessor */)); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } - else if (base.flags & 98304 /* Accessor */) { + else if (base.flags & 98304 /* SymbolFlags.Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } else { @@ -85251,14 +85646,14 @@ var ts; }; basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; - var state_10 = _loop_33(baseProperty); + var state_10 = _loop_34(baseProperty); switch (state_10) { case "continue-basePropertyCheck": continue basePropertyCheck; } } } function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) { - return baseDeclarationFlags & 128 /* Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer) + return baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer) || ts.isInterfaceDeclaration(declaration.parent); } function getNonInheritedProperties(type, baseTypes, properties) { @@ -85317,20 +85712,20 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) { continue; } if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || containsUndefinedType(type))) { + if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || containsUndefinedType(type))) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -85340,7 +85735,7 @@ var ts; } } function isPropertyWithoutInitializer(node) { - return node.kind === 167 /* PropertyDeclaration */ && + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; @@ -85383,7 +85778,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -85416,7 +85811,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 138 /* IntrinsicKeyword */) { + if (node.type.kind === 138 /* SyntaxKind.IntrinsicKeyword */) { if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); } @@ -85428,8 +85823,8 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { - nodeLinks.flags |= 16384 /* EnumValuesComputed */; + if (!(nodeLinks.flags & 16384 /* NodeCheckFlags.EnumValuesComputed */)) { + nodeLinks.flags |= 16384 /* NodeCheckFlags.EnumValuesComputed */; var autoValue = 0; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -85454,7 +85849,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -85471,7 +85866,7 @@ var ts; var enumKind = getEnumKind(getSymbolOfNode(member.parent)); var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; - var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); + var value = enumKind === 1 /* EnumKind.Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { if (isConstEnum && typeof value === "number" && !isFinite(value)) { error(initializer, isNaN(value) ? @@ -85479,20 +85874,20 @@ var ts; ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); } } - else if (enumKind === 1 /* Literal */) { + else if (enumKind === 1 /* EnumKind.Literal */) { error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members); return 0; } else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 16777216 /* Ambient */) { + else if (member.parent.flags & 16777216 /* NodeFlags.Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { // Only here do we need to check that the initializer is assignable to the enum type. var source = checkExpression(initializer); - if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) { + if (!isTypeAssignableToKind(source, 296 /* TypeFlags.NumberLike */)) { error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); } else { @@ -85502,60 +85897,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 39 /* PlusToken */: return value_2; - case 40 /* MinusToken */: return -value_2; - case 54 /* TildeToken */: return ~value_2; + case 39 /* SyntaxKind.PlusToken */: return value_2; + case 40 /* SyntaxKind.MinusToken */: return -value_2; + case 54 /* SyntaxKind.TildeToken */: return ~value_2; } } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 51 /* BarToken */: return left | right; - case 50 /* AmpersandToken */: return left & right; - case 48 /* GreaterThanGreaterThanToken */: return left >> right; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 47 /* LessThanLessThanToken */: return left << right; - case 52 /* CaretToken */: return left ^ right; - case 41 /* AsteriskToken */: return left * right; - case 43 /* SlashToken */: return left / right; - case 39 /* PlusToken */: return left + right; - case 40 /* MinusToken */: return left - right; - case 44 /* PercentToken */: return left % right; - case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); - } - } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { + case 51 /* SyntaxKind.BarToken */: return left | right; + case 50 /* SyntaxKind.AmpersandToken */: return left & right; + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return left >> right; + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* SyntaxKind.LessThanLessThanToken */: return left << right; + case 52 /* SyntaxKind.CaretToken */: return left ^ right; + case 41 /* SyntaxKind.AsteriskToken */: return left * right; + case 43 /* SyntaxKind.SlashToken */: return left / right; + case 39 /* SyntaxKind.PlusToken */: return left + right; + case 40 /* SyntaxKind.MinusToken */: return left - right; + case 44 /* SyntaxKind.PercentToken */: return left % right; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { return left + right; } break; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return expr.text; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return evaluate(expr.expression); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var identifier = expr; if (ts.isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (isConstantMemberAccess(expr)) { var type = getTypeOfExpression(expr.expression); - if (type.symbol && type.symbol.flags & 384 /* Enum */) { + if (type.symbol && type.symbol.flags & 384 /* SymbolFlags.Enum */) { var name = void 0; - if (expr.kind === 206 /* PropertyAccessExpression */) { + if (expr.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { name = expr.name.escapedText; } else { @@ -85591,9 +85986,9 @@ var ts; if (type === errorType) { return false; } - return node.kind === 79 /* Identifier */ || - node.kind === 206 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 207 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 207 /* SyntaxKind.ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -85627,7 +86022,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 260 /* EnumDeclaration */) { + if (declaration.kind !== 260 /* SyntaxKind.EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -85656,9 +86051,9 @@ var ts; if (declarations) { for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { var declaration = declarations_9[_i]; - if ((declaration.kind === 257 /* ClassDeclaration */ || - (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 16777216 /* Ambient */)) { + if ((declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || + (declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { return declaration; } } @@ -85689,7 +86084,7 @@ var ts; function checkModuleDeclarationDiagnostics() { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 16777216 /* Ambient */; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -85702,7 +86097,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* SyntaxKind.StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -85712,7 +86107,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !inAmbientContext && symbol.declarations && symbol.declarations.length > 1 @@ -85728,10 +86123,10 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* SyntaxKind.ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* NodeCheckFlags.LexicalModuleMergesWithClass */; } } if (isAmbientExternalModule) { @@ -85741,7 +86136,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Transient */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* SymbolFlags.Transient */); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -85773,23 +86168,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -85800,12 +86195,12 @@ var ts; break; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 256 /* FunctionDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -85815,7 +86210,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Transient */); + var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -85826,20 +86221,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } @@ -85853,9 +86248,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 272 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -85898,12 +86293,12 @@ var ts; // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). symbol = getMergedSymbol(symbol.exportSymbol || symbol); // A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within - if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) { + if (ts.isInJSFile(node) && !(target.flags & 111551 /* SymbolFlags.Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) { var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name : ts.isNamedDeclaration(node) ? node.name : node; - ts.Debug.assert(node.kind !== 274 /* NamespaceExport */); - if (node.kind === 275 /* ExportSpecifier */) { + ts.Debug.assert(node.kind !== 274 /* SyntaxKind.NamespaceExport */); + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */) { var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files); var alreadyExportedSymbol = (_b = (_a = ts.getSourceFileOfNode(node).symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.get((node.propertyName || node.name).escapedText); if (alreadyExportedSymbol === target) { @@ -85914,47 +86309,47 @@ var ts; } } else { - ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */); + ts.Debug.assert(node.kind !== 254 /* SyntaxKind.VariableDeclaration */); var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)); var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "..."; var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName); - error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"" + moduleSpecifier + "\")." + importedIdentifier); + error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"".concat(moduleSpecifier, "\").").concat(importedIdentifier)); } return; } - var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | - (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | - (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) | + (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) | + (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 275 /* ExportSpecifier */ ? + var message = node.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } if (compilerOptions.isolatedModules && !ts.isTypeOnlyImportOrExportDeclaration(node) - && !(node.flags & 16777216 /* Ambient */)) { + && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol); - var isType = !(target.flags & 111551 /* Value */); + var isType = !(target.flags & 111551 /* SymbolFlags.Value */); if (isType || typeOnlyAlias) { switch (node.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: { + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { if (compilerOptions.preserveValueImports) { ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name"); var message = isType ? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled; - var name = ts.idText(node.kind === 270 /* ImportSpecifier */ ? node.propertyName || node.name : node.name); + var name = ts.idText(node.kind === 270 /* SyntaxKind.ImportSpecifier */ ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); } - if (isType && node.kind === 265 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* ModifierFlags.Export */)) { error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided); } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // Don't allow re-exporting an export that will be elided when `--isolatedModules` is set. // The exception is that `import type { A } from './a'; export { A }` is allowed // because single-file analysis can determine that the export should be dropped. @@ -85979,15 +86374,15 @@ var ts; } } function isDeprecatedAliasedSymbol(symbol) { - return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } function checkDeprecatedAliasedSymbol(symbol, location) { - if (!(symbol.flags & 2097152 /* Alias */)) + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) return symbol; var targetSymbol = resolveAlias(symbol); if (targetSymbol === unknownSymbol) return targetSymbol; - while (symbol.flags & 2097152 /* Alias */) { + while (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = getImmediateAliasedSymbol(symbol); if (target) { if (target === targetSymbol) @@ -86013,11 +86408,11 @@ var ts; function checkImportBinding(node) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 270 /* ImportSpecifier */ && + if (node.kind === 270 /* SyntaxKind.ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && ts.getESModuleInterop(compilerOptions) && moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } function checkAssertClause(declaration) { @@ -86063,11 +86458,11 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { @@ -86089,20 +86484,20 @@ var ts; checkGrammarDecoratorsAndModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 277 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = ts.getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 788968 /* Type */) { + if (target.flags & 788968 /* SymbolFlags.Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -86111,7 +86506,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -86126,8 +86521,8 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } - if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { - checkExternalEmitHelpers(node, 4194304 /* CreateBinding */); + if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) { + checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */); } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -86135,10 +86530,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 16777216 /* Ambient */; - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && + !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */; + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -86158,12 +86553,12 @@ var ts; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop if (ts.getESModuleInterop(compilerOptions)) { - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { // export * from "foo" - checkExternalEmitHelpers(node, 32768 /* ExportStar */); + checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */); } } } @@ -86173,7 +86568,7 @@ var ts; function checkGrammarExportDeclaration(node) { var _a; if (node.isTypeOnly) { - if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* NamedExports */) { + if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* SyntaxKind.NamedExports */) { return checkGrammarNamedImportsOrExports(node.exportClause); } else { @@ -86183,7 +86578,7 @@ var ts; return false; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 305 /* SourceFile */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 261 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 305 /* SyntaxKind.SourceFile */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -86231,15 +86626,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { - markExportAsReferenced(node); - var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); - if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) { + markExportAsReferenced(node); + } + var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { checkExpressionCached(node.propertyName || node.name); } } @@ -86249,7 +86646,7 @@ var ts; moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.idText(node.propertyName || node.name) === "default") { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } } @@ -86261,8 +86658,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -86279,14 +86676,14 @@ var ts; if (typeAnnotationNode) { checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression); } - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { var id = node.expression; - var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + var sym = resolveEntityName(id, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { markAliasReferenced(sym, id); // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) - var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // However if it is a value, we need to check it's being used correctly checkExpressionCached(node.expression); } @@ -86302,10 +86699,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 16777216 /* NodeFlags.Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -86340,11 +86737,11 @@ var ts; } // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (flags & (1920 /* Namespace */ | 384 /* Enum */)) { + if (flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) { return; } var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration))); - if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + if (flags & 524288 /* SymbolFlags.TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) return; @@ -86394,181 +86791,181 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 237 /* FirstStatement */ && kind <= 253 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 237 /* SyntaxKind.FirstStatement */ && kind <= 253 /* SyntaxKind.LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return checkTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return checkParameter(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return checkPropertyDeclaration(node); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checkPropertySignature(node); - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return checkSignatureDeclaration(node); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return checkMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return checkClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return checkConstructorDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return checkAccessorDeclaration(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return checkTypeReferenceNode(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return checkTypePredicate(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return checkTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return checkTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return checkArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return checkTupleType(node); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return checkUnionOrIntersectionType(node); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 186 /* RestType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: return checkSourceElement(node.type); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return checkThisType(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return checkTypeOperator(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return checkConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return checkInferType(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return checkTemplateLiteralType(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return checkImportType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return checkNamedTupleMember(node); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return checkJSDocTypeTag(node); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return checkJSDocLinkLikeTag(node); - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return checkJSDocParameterTag(node); - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 322 /* JSDocTypeLiteral */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return checkSourceElement(node.type); - case 333 /* JSDocPublicTag */: - case 335 /* JSDocProtectedTag */: - case 334 /* JSDocPrivateTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: return checkJSDocAccessibilityModifiers(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return checkIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return checkMappedType(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return checkFunctionDeclaration(node); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return checkBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return checkVariableStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return checkExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return checkIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return checkDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return checkWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return checkForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return checkForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkForOfStatement(node); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return checkBreakOrContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return checkReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return checkSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return checkThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return checkTryStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checkVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return checkBindingElement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return checkClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return checkEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return checkModuleDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return checkImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return checkExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return checkExportAssignment(node); - case 236 /* EmptyStatement */: - case 253 /* DebuggerStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -86658,7 +87055,7 @@ var ts; function checkNodeDeferred(node) { var enclosingFile = ts.getSourceFileOfNode(node); var links = getNodeLinks(enclosingFile); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { links.deferredNodes || (links.deferredNodes = new ts.Set()); links.deferredNodes.add(node); } @@ -86670,41 +87067,41 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: - case 280 /* JsxOpeningElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: checkAccessorDeclaration(node); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: checkClassExpressionDeferred(node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: checkTypeParameterDeferred(node); break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: checkJsxElementDeferred(node); break; } @@ -86712,7 +87109,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); @@ -86724,9 +87121,9 @@ var ts; return false; } switch (kind) { - case 0 /* Local */: + case 0 /* UnusedKind.Local */: return !!compilerOptions.noUnusedLocals; - case 1 /* Parameter */: + case 1 /* UnusedKind.Parameter */: return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); @@ -86738,7 +87135,7 @@ var ts; // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node) { var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } @@ -86759,7 +87156,7 @@ var ts; // This relies on the results of other lazy diagnostics, so must be computed after them if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { diagnostics.add(diag); } }); @@ -86768,7 +87165,7 @@ var ts; checkPotentialUncheckedRenamedBindingElementsInTypes(); } }); - if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && + if (compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ && !node.isDeclarationFile && ts.isExternalModule(node)) { checkImportsForTypeOnlyConversion(node); @@ -86792,7 +87189,7 @@ var ts; ts.forEach(potentialReflectCollisions, checkReflectCollision); ts.clear(potentialReflectCollisions); } - links.flags |= 1 /* TypeChecked */; + links.flags |= 1 /* NodeCheckFlags.TypeChecked */; } } function getDiagnostics(sourceFile, ct) { @@ -86862,14 +87259,14 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 33554432 /* InWithStatement */) { + if (location.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } var symbols = ts.createSymbolTable(); var isStaticSymbol = false; populateSymbols(); - symbols.delete("this" /* This */); // Not a symbol, a keyword + symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -86877,17 +87274,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 261 /* ModuleDeclaration */: - copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 261 /* SyntaxKind.ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */); break; - case 260 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + case 260 /* SyntaxKind.EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -86895,17 +87292,17 @@ var ts; // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. // falls through - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStaticSymbol) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */); } break; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -86949,7 +87346,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* SyntaxKind.NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -86957,25 +87354,25 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 79 /* Identifier */ && + return name.kind === 79 /* SyntaxKind.Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 163 /* TypeParameter */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 163 /* SyntaxKind.TypeParameter */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return true; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.isTypeOnly; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -86983,16 +87380,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 178 /* TypeReference */; + return node.parent.kind === 178 /* SyntaxKind.TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 206 /* PropertyAccessExpression */) { + while (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 228 /* ExpressionWithTypeArguments */; + return node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -87020,13 +87417,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 161 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 161 /* SyntaxKind.QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 265 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 271 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -87037,12 +87434,12 @@ var ts; function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { - case 1 /* ExportsProperty */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return getSymbolOfNode(entityName.parent); - case 4 /* ThisProperty */: - case 2 /* ModuleExports */: - case 5 /* Property */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: + case 5 /* AssignmentDeclarationKind.Property */: return getSymbolOfNode(entityName.parent.parent); } } @@ -87052,7 +87449,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 200 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 200 /* SyntaxKind.ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -87062,7 +87459,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 206 /* PropertyAccessExpression */ && + name.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { @@ -87072,17 +87469,17 @@ var ts; } } } - if (name.parent.kind === 271 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, - /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 265 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 265 /* SyntaxKind.ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -87098,28 +87495,28 @@ var ts; name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { - var meaning = 0 /* None */; + var meaning = 0 /* SymbolFlags.None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 228 /* ExpressionWithTypeArguments */) { - meaning = 788968 /* Type */; + if (name.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { + meaning = 788968 /* SymbolFlags.Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { - meaning |= 111551 /* Value */; + meaning |= 111551 /* SymbolFlags.Value */; } } else { - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } - meaning |= 2097152 /* Alias */; + meaning |= 2097152 /* SymbolFlags.Alias */; var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined; if (entityNameSymbol) { return entityNameSymbol; } } - if (name.parent.kind === 340 /* JSDocParameterTag */) { + if (name.parent.kind === 340 /* SyntaxKind.JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 163 /* TypeParameter */ && name.parent.parent.kind === 344 /* JSDocTemplateTag */) { + if (name.parent.kind === 163 /* SyntaxKind.TypeParameter */ && name.parent.parent.kind === 344 /* SyntaxKind.JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -87130,8 +87527,8 @@ var ts; return undefined; } var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); - var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */; - if (name.kind === 79 /* Identifier */) { + var meaning = isJSDoc_1 ? 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */ : 111551 /* SymbolFlags.Value */; + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; @@ -87148,16 +87545,16 @@ var ts; else if (ts.isPrivateIdentifier(name)) { return getSymbolForPrivateIdentifierExpression(name); } - else if (name.kind === 206 /* PropertyAccessExpression */ || name.kind === 161 /* QualifiedName */) { + else if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 161 /* SyntaxKind.QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 206 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name, 0 /* Normal */); + if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* CheckMode.Normal */); } else { - checkQualifiedName(name, 0 /* Normal */); + checkQualifiedName(name, 0 /* CheckMode.Normal */); } if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { return resolveJSDocMemberName(name); @@ -87169,12 +87566,12 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 178 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 178 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } - if (name.parent.kind === 177 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + if (name.parent.kind === 177 /* SyntaxKind.TypePredicate */) { + return resolveEntityName(name, /*meaning*/ 1 /* SymbolFlags.FunctionScopedVariable */); } return undefined; } @@ -87189,7 +87586,7 @@ var ts; function resolveJSDocMemberName(name, ignoreErrors, container) { if (ts.isEntityName(name)) { // resolve static values first - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */; var symbol = resolveEntityName(name, meaning, ignoreErrors, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); if (!symbol && ts.isIdentifier(name) && container) { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); @@ -87201,18 +87598,18 @@ var ts; var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left, ignoreErrors, container); var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; if (left) { - var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var proto = left.flags & 111551 /* SymbolFlags.Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); return getPropertyOfType(t, right); } } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -87226,12 +87623,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 203 /* BindingElement */ && - grandParent.kind === 201 /* ObjectBindingPattern */ && + else if (parent.kind === 203 /* SyntaxKind.BindingElement */ && + grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -87240,7 +87637,7 @@ var ts; } } else if (ts.isMetaProperty(parent) && parent.name === node) { - if (parent.keywordToken === 103 /* NewKeyword */ && ts.idText(node) === "target") { + if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") { // `target` in `new.target` return checkNewTargetMetaProperty(parent).symbol; } @@ -87248,7 +87645,7 @@ var ts; // we have a fake expression type made for other reasons already, whose transient `meta` // member should more exactly be the kind of (declarationless) symbol we want. // (See #44364 and #45031 for relevant implementation PRs) - if (parent.keywordToken === 100 /* ImportKeyword */ && ts.idText(node) === "meta") { + if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") { return getGlobalImportMetaExpressionType().members.get("meta"); } // no other meta properties are valid syntax, thus no others should have symbols @@ -87256,15 +87653,15 @@ var ts; } } switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: if (!ts.isThisInTypeQuery(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } // falls through - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -87276,25 +87673,25 @@ var ts; return checkExpression(node).symbol; } // falls through - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkExpression(node).symbol; - case 134 /* ConstructorKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 171 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 171 /* SyntaxKind.Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // 1). import x = require("./mo/*gotToDefinitionHere*/d") // 2). External module name in an import declaration // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 266 /* ImportDeclaration */ || node.parent.kind === 272 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.parent.kind === 272 /* SyntaxKind.ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -87303,7 +87700,7 @@ var ts; return getSymbolOfNode(parent); } // falls through - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: // index access var objectType = ts.isElementAccessExpression(parent) ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined @@ -87311,19 +87708,19 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 88 /* DefaultKeyword */: - case 98 /* FunctionKeyword */: - case 38 /* EqualsGreaterThanToken */: - case 84 /* ClassKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 84 /* SyntaxKind.ClassKeyword */: return getSymbolOfNode(node.parent); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; - case 100 /* ImportKeyword */: - case 103 /* NewKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkExpression(node).symbol; default: return undefined; @@ -87333,14 +87730,14 @@ var ts; if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { var keyType_1 = getLiteralTypeFromPropertyName(node); var objectType = getTypeOfExpression(node.parent.expression); - var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType]; + var objectTypes = objectType.flags & 1048576 /* TypeFlags.Union */ ? objectType.types : [objectType]; return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); }); } return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 297 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */); } return undefined; } @@ -87349,17 +87746,17 @@ var ts; if (ts.isExportSpecifier(node)) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } else { - return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + return resolveEntityName(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } } function getTypeOfNode(node) { if (ts.isSourceFile(node) && !ts.isExternalModule(node)) { return errorType; } - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -87400,7 +87797,7 @@ var ts; return errorType; } if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType; + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType; } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolAtLocation(node); @@ -87421,23 +87818,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 205 /* ObjectLiteralExpression */ || expr.kind === 204 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 244 /* ForOfStatement */) { + if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 221 /* BinaryExpression */) { + if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 296 /* PropertyAssignment */) { + if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) { var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); @@ -87447,7 +87844,7 @@ var ts; var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -87480,14 +87877,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return getStringLiteralType(ts.idText(name)); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getStringLiteralType(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* TypeFlags.ESSymbolLike */) ? nameType : stringType; default: return ts.Debug.fail("Unsupported property name."); } @@ -87497,8 +87894,8 @@ var ts; function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = ts.createSymbolTable(getPropertiesOfType(type)); - var functionType = getSignaturesOfType(type, 0 /* Call */).length ? globalCallableFunctionType : - getSignaturesOfType(type, 1 /* Construct */).length ? globalNewableFunctionType : + var functionType = getSignaturesOfType(type, 0 /* SignatureKind.Call */).length ? globalCallableFunctionType : + getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length ? globalNewableFunctionType : undefined; if (functionType) { ts.forEach(getPropertiesOfType(functionType), function (p) { @@ -87517,10 +87914,10 @@ var ts; return roots ? ts.flatMap(roots, getRootSymbols) : [symbol]; } function getImmediateRootSymbols(symbol) { - if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { + if (ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */) { return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); }); } - else if (symbol.flags & 33554432 /* Transient */) { + else if (symbol.flags & 33554432 /* SymbolFlags.Transient */) { var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin; return leftSpread ? [leftSpread, rightSpread] : syntheticOrigin ? [syntheticOrigin] @@ -87567,13 +87964,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 111551 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* SymbolFlags.Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 111551 /* Value */); + return s && !!(s.flags & 111551 /* SymbolFlags.Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -87591,19 +87988,19 @@ var ts; // declaration if it contains an exported member with the same name. var symbol = getReferencedValueSymbol(node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node)); if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { + if (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) { // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (!prefixLocals && exportSymbol.flags & 944 /* ExportHasLocal */ && !(exportSymbol.flags & 3 /* Variable */)) { + if (!prefixLocals && exportSymbol.flags & 944 /* SymbolFlags.ExportHasLocal */ && !(exportSymbol.flags & 3 /* SymbolFlags.Variable */)) { return undefined; } symbol = exportSymbol; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SyntaxKind.SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -87626,7 +88023,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -87635,20 +88032,20 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* SyntaxKind.CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* SymbolFlags.BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } - else if (nodeLinks_1.flags & 262144 /* CapturedBlockScopedBinding */) { + else if (nodeLinks_1.flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */) { // binding is captured in the function // should be renamed if: // - binding is not top level - top level bindings never collide with anything @@ -87664,9 +88061,9 @@ var ts; // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything - var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; + var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 235 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 235 /* SyntaxKind.Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -87707,20 +88104,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: var symbol = getSymbolOfNode(node); return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 271 /* ExportAssignment */: - return node.expression && node.expression.kind === 79 /* Identifier */ ? + case 271 /* SyntaxKind.ExportAssignment */: + return node.expression && node.expression.kind === 79 /* SyntaxKind.Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } @@ -87728,7 +88125,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 305 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -87745,7 +88142,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 111551 /* Value */) && + return !!(target.flags & 111551 /* SymbolFlags.Value */) && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -87759,8 +88156,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217 - if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && - target.flags & 111551 /* Value */ && + if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ && + target.flags & 111551 /* SymbolFlags.Value */ && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; @@ -87798,13 +88195,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -87812,10 +88209,10 @@ var ts; return false; } var symbol = getSymbolOfNode(declaration); - if (!symbol || !(symbol.flags & 16 /* Function */)) { + if (!symbol || !(symbol.flags & 16 /* SymbolFlags.Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* SymbolFlags.Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -87838,19 +88235,19 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 299 /* EnumMember */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 299 /* SyntaxKind.EnumMember */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 299 /* EnumMember */) { + if (node.kind === 299 /* SyntaxKind.EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { + if (symbol && (symbol.flags & 8 /* SymbolFlags.EnumMember */)) { // inline property\index accesses only for const enums var member = symbol.valueDeclaration; if (ts.isEnumConst(member.parent)) { @@ -87860,7 +88257,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* TypeFlags.Object */) && getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { var _a, _b; @@ -87876,14 +88273,14 @@ var ts; // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var isTypeOnly = false; if (ts.isQualifiedName(typeName)) { - var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)); } - var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); - var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol; + var valueSymbol = resolveEntityName(typeName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(valueSymbol) : valueSymbol; isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration))); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (resolvedSymbol && resolvedSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) { @@ -87902,28 +88299,28 @@ var ts; if (isErrorType(type)) { return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 3 /* AnyOrUnknown */) { + else if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* TypeFlags.Void */ | 98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* TypeFlags.BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* TypeFlags.NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* TypeFlags.BigIntLike */)) { return ts.TypeReferenceSerializationKind.BigIntLikeType; } - else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 402653316 /* TypeFlags.StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* TypeFlags.ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -87939,37 +88336,37 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + var type = symbol && !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 131072 /* SymbolFlags.Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol) { - flags |= 1048576 /* AllowUniqueESSymbolType */; + flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } if (addUndefined) { type = getOptionalType(type); } - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); - return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function hasGlobalName(name) { return globals.has(ts.escapeLeadingUnderscores(name)); @@ -87988,7 +88385,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -88009,7 +88406,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* TypeFlags.EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* SymbolFlags.Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse(); if (enumResult) return enumResult; @@ -88117,18 +88514,18 @@ var ts; isLateBound: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); - return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */); + return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */); }, getJsxFactoryEntity: getJsxFactoryEntity, getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 173 /* SetAccessor */ ? 172 /* GetAccessor */ : 173 /* SetAccessor */; + var otherKind = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? 172 /* SyntaxKind.GetAccessor */ : 173 /* SyntaxKind.SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 173 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 172 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -88144,7 +88541,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 305 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 305 /* SyntaxKind.SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -88181,7 +88578,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 228 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* HeritageClause */; + return node.parent && node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -88189,12 +88586,19 @@ var ts; if (!fileToDirective) { return undefined; } + // computed property name should use node as value // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + var meaning; + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; + } + else { + meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; + if ((node.kind === 79 /* SyntaxKind.Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; + } } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -88241,7 +88645,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -88269,12 +88673,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 261 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 305 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -88345,7 +88749,7 @@ var ts; getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; - getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* Anonymous */, globalThisSymbol); + getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* ObjectFlags.Anonymous */, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -88407,28 +88811,28 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* NodeFlags.Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* ExternalEmitHelpers.FirstEmitHelper */; helper <= 4194304 /* ExternalEmitHelpers.LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* SymbolFlags.Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } - else if (helper & 524288 /* ClassPrivateFieldGet */) { + else if (helper & 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4); } } - else if (helper & 1048576 /* ClassPrivateFieldSet */) { + else if (helper & 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); } } - else if (helper & 1024 /* SpreadArray */) { + else if (helper & 1024 /* ExternalEmitHelpers.SpreadArray */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3); } @@ -88442,29 +88846,29 @@ var ts; } function getHelperName(helper) { switch (helper) { - case 1 /* Extends */: return "__extends"; - case 2 /* Assign */: return "__assign"; - case 4 /* Rest */: return "__rest"; - case 8 /* Decorate */: return "__decorate"; - case 16 /* Metadata */: return "__metadata"; - case 32 /* Param */: return "__param"; - case 64 /* Awaiter */: return "__awaiter"; - case 128 /* Generator */: return "__generator"; - case 256 /* Values */: return "__values"; - case 512 /* Read */: return "__read"; - case 1024 /* SpreadArray */: return "__spreadArray"; - case 2048 /* Await */: return "__await"; - case 4096 /* AsyncGenerator */: return "__asyncGenerator"; - case 8192 /* AsyncDelegator */: return "__asyncDelegator"; - case 16384 /* AsyncValues */: return "__asyncValues"; - case 32768 /* ExportStar */: return "__exportStar"; - case 65536 /* ImportStar */: return "__importStar"; - case 131072 /* ImportDefault */: return "__importDefault"; - case 262144 /* MakeTemplateObject */: return "__makeTemplateObject"; - case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; - case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; - case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn"; - case 4194304 /* CreateBinding */: return "__createBinding"; + case 1 /* ExternalEmitHelpers.Extends */: return "__extends"; + case 2 /* ExternalEmitHelpers.Assign */: return "__assign"; + case 4 /* ExternalEmitHelpers.Rest */: return "__rest"; + case 8 /* ExternalEmitHelpers.Decorate */: return "__decorate"; + case 16 /* ExternalEmitHelpers.Metadata */: return "__metadata"; + case 32 /* ExternalEmitHelpers.Param */: return "__param"; + case 64 /* ExternalEmitHelpers.Awaiter */: return "__awaiter"; + case 128 /* ExternalEmitHelpers.Generator */: return "__generator"; + case 256 /* ExternalEmitHelpers.Values */: return "__values"; + case 512 /* ExternalEmitHelpers.Read */: return "__read"; + case 1024 /* ExternalEmitHelpers.SpreadArray */: return "__spreadArray"; + case 2048 /* ExternalEmitHelpers.Await */: return "__await"; + case 4096 /* ExternalEmitHelpers.AsyncGenerator */: return "__asyncGenerator"; + case 8192 /* ExternalEmitHelpers.AsyncDelegator */: return "__asyncDelegator"; + case 16384 /* ExternalEmitHelpers.AsyncValues */: return "__asyncValues"; + case 32768 /* ExternalEmitHelpers.ExportStar */: return "__exportStar"; + case 65536 /* ExternalEmitHelpers.ImportStar */: return "__importStar"; + case 131072 /* ExternalEmitHelpers.ImportDefault */: return "__importDefault"; + case 262144 /* ExternalEmitHelpers.MakeTemplateObject */: return "__makeTemplateObject"; + case 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */: return "__classPrivateFieldGet"; + case 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */: return "__classPrivateFieldSet"; + case 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */: return "__classPrivateFieldIn"; + case 4194304 /* ExternalEmitHelpers.CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -88486,14 +88890,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 169 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) { + else if (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (ts.hasDecorators(accessors.firstAccessor) && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -88507,71 +88911,71 @@ var ts; return quickResult; } var lastStatic, lastDeclare, lastAsync, lastOverride; - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (ts.isDecorator(modifier)) continue; - if (modifier.kind !== 145 /* ReadonlyKeyword */) { - if (node.kind === 166 /* PropertySignature */ || node.kind === 168 /* MethodSignature */) { + if (modifier.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.kind === 166 /* SyntaxKind.PropertySignature */ || node.kind === 168 /* SyntaxKind.MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 176 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */ && (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } - if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 144 /* OutKeyword */) { - if (node.kind === 163 /* TypeParameter */) { + if (modifier.kind !== 101 /* SyntaxKind.InKeyword */ && modifier.kind !== 144 /* SyntaxKind.OutKeyword */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 85 /* ConstKeyword */: - if (node.kind !== 260 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); + case 85 /* SyntaxKind.ConstKeyword */: + if (node.kind !== 260 /* SyntaxKind.EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* SyntaxKind.ConstKeyword */)); } break; - case 159 /* OverrideKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; lastOverride = modifier; break; - case 123 /* PublicKeyword */: - case 122 /* ProtectedKeyword */: - case 121 /* PrivateKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 28 /* ModifierFlags.AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); } - else if (flags & 32 /* Static */) { + else if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } - else if (flags & 128 /* Abstract */) { - if (modifier.kind === 121 /* PrivateKeyword */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { + if (modifier.kind === 121 /* SyntaxKind.PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -88583,185 +88987,185 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 124 /* StaticKeyword */: - if (flags & 32 /* Static */) { + case 124 /* SyntaxKind.StaticKeyword */: + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 32 /* ModifierFlags.Static */; lastStatic = modifier; break; - case 145 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + case 145 /* SyntaxKind.ReadonlyKeyword */: + if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */ && node.kind !== 176 /* IndexSignature */ && node.kind !== 164 /* Parameter */) { + else if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */ && node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 164 /* SyntaxKind.Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; break; - case 93 /* ExportKeyword */: - if (flags & 1 /* Export */) { + case 93 /* SyntaxKind.ExportKeyword */: + if (flags & 1 /* ModifierFlags.Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; break; - case 88 /* DefaultKeyword */: - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* SyntaxKind.DefaultKeyword */: + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } - else if (!(flags & 1 /* Export */)) { + else if (!(flags & 1 /* ModifierFlags.Export */)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } - flags |= 512 /* Default */; + flags |= 512 /* ModifierFlags.Default */; break; - case 135 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + case 135 /* SyntaxKind.DeclareKeyword */: + if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) { + else if ((node.parent.flags & 16777216 /* NodeFlags.Ambient */) && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; lastDeclare = modifier; break; - case 126 /* AbstractKeyword */: - if (flags & 128 /* Abstract */) { + case 126 /* SyntaxKind.AbstractKeyword */: + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 257 /* ClassDeclaration */ && - node.kind !== 180 /* ConstructorType */) { - if (node.kind !== 169 /* MethodDeclaration */ && - node.kind !== 167 /* PropertyDeclaration */ && - node.kind !== 172 /* GetAccessor */ && - node.kind !== 173 /* SetAccessor */) { + if (node.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + node.kind !== 180 /* SyntaxKind.ConstructorType */) { + if (node.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + node.kind !== 172 /* SyntaxKind.GetAccessor */ && + node.kind !== 173 /* SyntaxKind.SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 257 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 256 /* Async */ && lastAsync) { + if (flags & 256 /* ModifierFlags.Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } } - if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 128 /* Abstract */; + flags |= 128 /* ModifierFlags.Abstract */; break; - case 131 /* AsyncKeyword */: - if (flags & 256 /* Async */) { + case 131 /* SyntaxKind.AsyncKeyword */: + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */ || node.parent.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 256 /* Async */; + flags |= 256 /* ModifierFlags.Async */; lastAsync = modifier; break; - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; - var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out"; - if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + var inOutFlag = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? 32768 /* ModifierFlags.In */ : 65536 /* ModifierFlags.Out */; + var inOutText = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? "in" : "out"; + if (node.kind !== 163 /* SyntaxKind.TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 32768 /* ModifierFlags.In */ && flags & 65536 /* ModifierFlags.Out */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; break; } } - if (node.kind === 171 /* Constructor */) { - if (flags & 32 /* Static */) { + if (node.kind === 171 /* SyntaxKind.Constructor */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; } - else if ((node.kind === 266 /* ImportDeclaration */ || node.kind === 265 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) && flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -88779,48 +89183,48 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 261 /* ModuleDeclaration */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return false; - case 170 /* ClassStaticBlockDeclaration */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 264 /* NamespaceExportDeclaration */: - case 179 /* FunctionType */: - case 276 /* MissingDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 276 /* SyntaxKind.MissingDeclaration */: return true; default: - if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return false; } switch (node.kind) { - case 256 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */); - case 257 /* ClassDeclaration */: - case 180 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 237 /* VariableStatement */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 131 /* SyntaxKind.AsyncKeyword */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 180 /* SyntaxKind.ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* SyntaxKind.AbstractKeyword */); + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 260 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); + case 260 /* SyntaxKind.EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* SyntaxKind.ConstKeyword */); default: ts.Debug.assertNever(node); } @@ -88837,10 +89241,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -88869,7 +89273,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 16777216 /* NodeFlags.Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -88894,7 +89298,7 @@ var ts; return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); }); } function checkGrammarForUseStrictSimpleParameterList(node) { - if (languageVersion >= 3 /* ES2016 */) { + if (languageVersion >= 3 /* ScriptTarget.ES2016 */) { var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements); if (useStrictDirective_1) { var nonSimpleParameters = getNonSimpleParameters(node.parameters); @@ -88929,7 +89333,7 @@ var ts; return false; } if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { - if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */])) { grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } @@ -88965,7 +89369,7 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } var type = getTypeFromTypeNode(parameter.type); - if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { + if (someType(type, function (t) { return !!(t.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead); } if (!everyType(type, isValidIndexKeyType)) { @@ -88994,7 +89398,7 @@ var ts; checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } function checkGrammarTaggedTemplateChain(node) { - if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + if (node.questionDotToken || node.flags & 32 /* NodeFlags.OptionalChain */) { return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); } return false; @@ -89022,7 +89426,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -89035,7 +89439,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -89051,14 +89455,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -89069,21 +89473,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 221 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 221 /* SyntaxKind.BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 169 /* MethodDeclaration */); - if (node.flags & 16777216 /* Ambient */) { + ts.Debug.assert(node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -89101,7 +89505,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -89112,23 +89516,23 @@ var ts; continue; } var name = prop.name; - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 297 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } - if (name.kind === 80 /* PrivateIdentifier */) { + if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (ts.canHaveModifiers(prop) && prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (ts.isModifier(mod) && (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 169 /* MethodDeclaration */)) { + if (ts.isModifier(mod) && (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */)) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -89149,24 +89553,24 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name.kind === 8 /* NumericLiteral */) { + if (name.kind === 8 /* SyntaxKind.NumericLiteral */) { checkGrammarNumericLiteral(name); } - currentKind = 4 /* PropertyAssignment */; + currentKind = 4 /* DeclarationMeaning.PropertyAssignment */; break; - case 169 /* MethodDeclaration */: - currentKind = 8 /* Method */; + case 169 /* SyntaxKind.MethodDeclaration */: + currentKind = 8 /* DeclarationMeaning.Method */; break; - case 172 /* GetAccessor */: - currentKind = 1 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + currentKind = 1 /* DeclarationMeaning.GetAccessor */; break; - case 173 /* SetAccessor */: - currentKind = 2 /* SetAccessor */; + case 173 /* SyntaxKind.SetAccessor */: + currentKind = 2 /* DeclarationMeaning.SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -89181,14 +89585,14 @@ var ts; seen.set(effectiveName, currentKind); } else { - if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) { + if ((currentKind & 8 /* DeclarationMeaning.Method */) && (existingKind & 8 /* DeclarationMeaning.Method */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) { + else if ((currentKind & 4 /* DeclarationMeaning.PropertyAssignment */) && (existingKind & 4 /* DeclarationMeaning.PropertyAssignment */)) { grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name)); } - else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { - if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* DeclarationMeaning.GetOrSetAccessor */) && (existingKind & 3 /* DeclarationMeaning.GetOrSetAccessor */)) { + if (existingKind !== 3 /* DeclarationMeaning.GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -89208,7 +89612,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 287 /* JsxSpreadAttribute */) { + if (attr.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -89218,7 +89622,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 288 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 288 /* SyntaxKind.JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -89253,8 +89657,8 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 244 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { + if (forInOrOfStatement.kind === 244 /* SyntaxKind.ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { if (!hasParseDiagnostics(sourceFile)) { @@ -89272,7 +89676,7 @@ var ts; case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: case ts.ModuleKind.System: - if (languageVersion >= 4 /* ES2017 */) { + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { break; } // fallthrough @@ -89287,8 +89691,8 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 171 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); + if (func && func.kind !== 171 /* SyntaxKind.Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -89299,12 +89703,12 @@ var ts; return false; } } - if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) && + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */) && ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") { grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async); return false; } - if (forInOrOfStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -89319,20 +89723,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -89342,22 +89746,22 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) { - if (languageVersion < 1 /* ES5 */) { + if (!(accessor.flags & 16777216 /* NodeFlags.Ambient */) && (accessor.parent.kind !== 182 /* SyntaxKind.TypeLiteral */) && (accessor.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */)) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - if (accessor.parent.kind === 182 /* TypeLiteral */ || accessor.parent.kind === 258 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 182 /* SyntaxKind.TypeLiteral */ || accessor.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -89365,11 +89769,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 173 /* SetAccessor */) { + if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -89391,17 +89795,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 154 /* UniqueKeyword */) { - if (node.type.kind !== 151 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SymbolKeyword */)); + if (node.operator === 154 /* SyntaxKind.UniqueKeyword */) { + if (node.type.kind !== 151 /* SyntaxKind.SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -89411,26 +89815,26 @@ var ts; } } switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 79 /* Identifier */) { + if (decl.name.kind !== 79 /* SyntaxKind.Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); } - if (!(decl.parent.flags & 2 /* Const */)) { + if (!(decl.parent.flags & 2 /* NodeFlags.Const */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (!ts.isStatic(parent) || !ts.hasEffectiveReadonlyModifier(parent)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 166 /* PropertySignature */: - if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { + case 166 /* SyntaxKind.PropertySignature */: + if (!ts.hasSyntacticModifier(parent, 64 /* ModifierFlags.Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -89438,9 +89842,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 145 /* ReadonlyKeyword */) { - if (node.type.kind !== 183 /* ArrayType */ && node.type.kind !== 184 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SymbolKeyword */)); + else if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.type.kind !== 183 /* SyntaxKind.ArrayType */ && node.type.kind !== 184 /* SyntaxKind.TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } } } @@ -89453,10 +89857,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 169 /* MethodDeclaration */) { - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) { + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -89474,7 +89878,7 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } // Technically, computed properties in ambient contexts is disallowed @@ -89482,17 +89886,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 169 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 182 /* TypeLiteral */) { + else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -89503,11 +89907,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 245 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 245 /* SyntaxKind.ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -89515,8 +89919,8 @@ var ts; return false; } break; - case 249 /* SwitchStatement */: - if (node.kind === 246 /* BreakStatement */ && !node.label) { + case 249 /* SyntaxKind.SwitchStatement */: + if (node.kind === 246 /* SyntaxKind.BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -89531,13 +89935,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -89561,18 +89965,18 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; } function isBigIntLiteralExpression(expr) { - return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 9 /* BigIntLiteral */; + return expr.kind === 9 /* SyntaxKind.BigIntLiteral */ || + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 9 /* SyntaxKind.BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) { - return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* TypeFlags.EnumLiteral */); } } function checkAmbientInitializer(node) { @@ -89580,7 +89984,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || + initializer.kind === 110 /* SyntaxKind.TrueKeyword */ || initializer.kind === 95 /* SyntaxKind.FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -89591,14 +89995,11 @@ var ts; else { return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } - if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) { - if (node.flags & 16777216 /* Ambient */) { + if (node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */ && node.parent.parent.kind !== 244 /* SyntaxKind.ForOfStatement */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -89610,7 +90011,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 237 /* SyntaxKind.VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* NodeFlags.Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -89619,7 +90020,7 @@ var ts; return grammarErrorOnNode(node.exclamationToken, message); } if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System && - !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* ModifierFlags.Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -89632,7 +90033,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -89649,8 +90050,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 79 /* Identifier */) { - if (name.originalKeywordKind === 119 /* LetKeyword */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { + if (name.originalKeywordKind === 119 /* SyntaxKind.LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -89677,15 +90078,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return false; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -89703,12 +90104,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -89766,7 +90167,7 @@ var ts; } } function checkGrammarProperty(node) { - if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) { + if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) { return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); } if (ts.isClassLike(node.parent)) { @@ -89776,11 +90177,11 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { return true; } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -89800,11 +90201,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { + node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -89826,14 +90227,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 259 /* TypeAliasDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 272 /* ExportDeclaration */ || - node.kind === 271 /* ExportAssignment */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */ | 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -89841,7 +90242,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 237 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 237 /* SyntaxKind.VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -89850,10 +90251,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -89864,7 +90265,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 235 /* Block */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 235 /* SyntaxKind.Block */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -89881,19 +90282,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.numericLiteralFlags & 32 /* Octal */) { + if (node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { var diagnosticMessage = void 0; - if (languageVersion >= 1 /* ES5 */) { + if (languageVersion >= 1 /* ScriptTarget.ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 196 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 196 /* SyntaxKind.LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 299 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 299 /* SyntaxKind.EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* SyntaxKind.MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -89906,7 +90307,7 @@ var ts; // We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "." // e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`. var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1; - var isScientific = node.numericLiteralFlags & 16 /* Scientific */; + var isScientific = node.numericLiteralFlags & 16 /* TokenFlags.Scientific */; // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway if (isFractional || isScientific) { @@ -89927,7 +90328,7 @@ var ts; var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); if (!literalType) { - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { return true; } @@ -89961,7 +90362,7 @@ var ts; if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } - if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* NamedImports */) { + if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* SyntaxKind.NamedImports */) { return checkGrammarNamedImportsOrExports(node.namedBindings); } return false; @@ -89969,7 +90370,7 @@ var ts; function checkGrammarNamedImportsOrExports(namedBindings) { return !!ts.forEach(namedBindings.elements, function (specifier) { if (specifier.isTypeOnly) { - return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* ImportSpecifier */ + return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* SyntaxKind.ImportSpecifier */ ? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement : ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); } @@ -90004,14 +90405,14 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { + if (sourceObjectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */) && unionTarget.flags & 1048576 /* TypeFlags.Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 524288 /* Object */) { + if (target.flags & 524288 /* TypeFlags.Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); - if (overlapObjFlags & 4 /* Reference */) { + if (overlapObjFlags & 4 /* ObjectFlags.Reference */) { return source.target === target.target; } - if (overlapObjFlags & 16 /* Anonymous */) { + if (overlapObjFlags & 16 /* ObjectFlags.Anonymous */) { return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; } } @@ -90020,35 +90421,35 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectFlags.ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } function findBestTypeForInvokable(source, unionTarget) { - var signatureKind = 0 /* Call */; + var signatureKind = 0 /* SignatureKind.Call */; var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 || - (signatureKind = 1 /* Construct */, getSignaturesOfType(source, signatureKind).length > 0); + (signatureKind = 1 /* SignatureKind.Construct */, getSignaturesOfType(source, signatureKind).length > 0); if (hasSignatures) { return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; }); } } function findMostOverlappyType(source, unionTarget) { var bestMatch; - if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(source.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var matchingCount = 0; for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) { var target = _a[_i]; - if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(target.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]); - if (overlap.flags & 4194304 /* Index */) { + if (overlap.flags & 4194304 /* TypeFlags.Index */) { // perfect overlap of keys return target; } - else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) { + else if (isUnitType(overlap) || overlap.flags & 1048576 /* TypeFlags.Union */) { // We only want to account for literal types otherwise. // If we have a union of index types, it seems likely that we // needed to elaborate between two generic mapped types anyway. - var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; + var len = overlap.flags & 1048576 /* TypeFlags.Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; if (len >= matchingCount) { bestMatch = target; matchingCount = len; @@ -90060,9 +90461,9 @@ var ts; return bestMatch; } function filterPrimitivesIfContainsNonPrimitive(type) { - if (maybeTypeOfKind(type, 67108864 /* NonPrimitive */)) { - var result = filterType(type, function (t) { return !(t.flags & 131068 /* Primitive */); }); - if (!(result.flags & 131072 /* Never */)) { + if (maybeTypeOfKind(type, 67108864 /* TypeFlags.NonPrimitive */)) { + var result = filterType(type, function (t) { return !(t.flags & 131068 /* TypeFlags.Primitive */); }); + if (!(result.flags & 131072 /* TypeFlags.Never */)) { return result; } } @@ -90070,7 +90471,7 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { - if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { + if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) { var match = getMatchingUnionConstituentForType(target, source); if (match) { return match; @@ -90092,14 +90493,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 256 /* FunctionDeclaration */ && declaration.kind !== 169 /* MethodDeclaration */) || + return (declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */ && declaration.kind !== 169 /* SyntaxKind.MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -90119,17 +90520,17 @@ var ts; })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { - case 0 /* Yield */: return "yieldType"; - case 1 /* Return */: return "returnType"; - case 2 /* Next */: return "nextType"; + case 0 /* IterationTypeKind.Yield */: return "yieldType"; + case 1 /* IterationTypeKind.Return */: return "returnType"; + case 2 /* IterationTypeKind.Next */: return "nextType"; } } function signatureHasRestParameter(s) { - return !!(s.flags & 1 /* HasRestParameter */); + return !!(s.flags & 1 /* SignatureFlags.HasRestParameter */); } ts.signatureHasRestParameter = signatureHasRestParameter; function signatureHasLiteralTypes(s) { - return !!(s.flags & 2 /* HasLiteralTypes */); + return !!(s.flags & 2 /* SignatureFlags.HasLiteralTypes */); } ts.signatureHasLiteralTypes = signatureHasLiteralTypes; })(ts || (ts = {})); @@ -90269,7 +90670,7 @@ var ts; var updated; context.startLexicalEnvironment(); if (nodes) { - context.setLexicalEnvironmentFlags(1 /* InParameters */, true); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, true); updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression @@ -90277,11 +90678,11 @@ var ts; // exists in a different lexical scope. To address this, we move any binding patterns and initializers // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list // when the emit target is greater than ES2015. - if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ && - ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (context.getLexicalEnvironmentFlags() & 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */ && + ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { updated = addDefaultValueAssignmentsIfNeeded(updated, context); } - context.setLexicalEnvironmentFlags(1 /* InParameters */, false); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, false); } context.suspendLexicalEnvironment(); return updated; @@ -90328,8 +90729,8 @@ var ts; function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { var factory = context.factory; context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ - factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */))); + factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */))); return factory.updateParameterDeclaration(parameter, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, /*initializer*/ undefined); } @@ -90375,446 +90776,446 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 160 /* LastToken */) || kind === 192 /* ThisType */) { + if ((kind > 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */) || kind === 192 /* SyntaxKind.ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: ts.Debug.type(node); return factory.updateParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: ts.Debug.type(node); return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: ts.Debug.type(node); return factory.updateMethodDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: ts.Debug.type(node); context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); return factory.updateClassStaticBlockDeclaration(node, visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: ts.Debug.type(node); return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: ts.Debug.type(node); return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: ts.Debug.type(node); return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: ts.Debug.type(node); return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: ts.Debug.type(node); - return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 295 /* ImportTypeAssertionContainer */: + return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: ts.Debug.type(node); - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 191 /* ParenthesizedType */: + return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); + case 191 /* SyntaxKind.ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: ts.Debug.type(node); return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: ts.Debug.type(node); return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 206 /* PropertyAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName)); } ts.Debug.type(node); return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); - case 207 /* ElementAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 208 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: ts.Debug.type(node); return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: ts.Debug.type(node); - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 211 /* TypeAssertionExpression */: + return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: ts.Debug.type(node); return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: ts.Debug.type(node); return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: ts.Debug.type(node); return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: ts.Debug.type(node); return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 230 /* NonNullExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 230 /* SyntaxKind.NonNullExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: ts.Debug.type(node); return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: ts.Debug.type(node); return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: ts.Debug.type(node); return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: ts.Debug.type(node); return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: ts.Debug.type(node); return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: ts.Debug.type(node); return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: ts.Debug.type(node); return factory.updateFunctionDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: ts.Debug.type(node); return factory.updateModuleDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: ts.Debug.type(node); return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: ts.Debug.type(node); return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode)); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: ts.Debug.type(node); return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: ts.Debug.type(node); return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: ts.Debug.type(node); return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: ts.Debug.type(node); return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.type(node); return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: ts.Debug.type(node); return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -91039,7 +91440,7 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - appendMappingCharCode(59 /* semicolon */); + appendMappingCharCode(59 /* CharacterCodes.semicolon */); lastGeneratedLine++; } while (lastGeneratedLine < pendingGeneratedLine); // Only need to set this once @@ -91049,7 +91450,7 @@ var ts; ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - appendMappingCharCode(44 /* comma */); + appendMappingCharCode(44 /* CharacterCodes.comma */); } } // 1. Relative generated character @@ -91192,14 +91593,14 @@ var ts; next: function () { while (!done && pos < mappings.length) { var ch = mappings.charCodeAt(pos); - if (ch === 59 /* semicolon */) { + if (ch === 59 /* CharacterCodes.semicolon */) { // new line generatedLine++; generatedCharacter = 0; pos++; continue; } - if (ch === 44 /* comma */) { + if (ch === 44 /* CharacterCodes.comma */) { // Next entry is on same line - no action needed pos++; continue; @@ -91276,8 +91677,8 @@ var ts; } function isSourceMappingSegmentEnd() { return (pos === mappings.length || - mappings.charCodeAt(pos) === 44 /* comma */ || - mappings.charCodeAt(pos) === 59 /* semicolon */); + mappings.charCodeAt(pos) === 44 /* CharacterCodes.comma */ || + mappings.charCodeAt(pos) === 59 /* CharacterCodes.semicolon */); } function base64VLQFormatDecode() { var moreDigits = true; @@ -91327,19 +91728,19 @@ var ts; } ts.isSourceMapping = isSourceMapping; function base64FormatEncode(value) { - return value >= 0 && value < 26 ? 65 /* A */ + value : - value >= 26 && value < 52 ? 97 /* a */ + value - 26 : - value >= 52 && value < 62 ? 48 /* _0 */ + value - 52 : - value === 62 ? 43 /* plus */ : - value === 63 ? 47 /* slash */ : - ts.Debug.fail(value + ": not a base64 value"); + return value >= 0 && value < 26 ? 65 /* CharacterCodes.A */ + value : + value >= 26 && value < 52 ? 97 /* CharacterCodes.a */ + value - 26 : + value >= 52 && value < 62 ? 48 /* CharacterCodes._0 */ + value - 52 : + value === 62 ? 43 /* CharacterCodes.plus */ : + value === 63 ? 47 /* CharacterCodes.slash */ : + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ ? ch - 65 /* A */ : - ch >= 97 /* a */ && ch <= 122 /* z */ ? ch - 97 /* a */ + 26 : - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ ? ch - 48 /* _0 */ + 52 : - ch === 43 /* plus */ ? 62 : - ch === 47 /* slash */ ? 63 : + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ ? ch - 65 /* CharacterCodes.A */ : + ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ? ch - 97 /* CharacterCodes.a */ + 26 : + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ ? ch - 48 /* CharacterCodes._0 */ + 52 : + ch === 43 /* CharacterCodes.plus */ ? 62 : + ch === 47 /* CharacterCodes.slash */ ? 63 : -1; } function isSourceMappedPosition(value) { @@ -91407,7 +91808,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -91500,12 +91901,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* InternalSymbolName.Default */; } function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -91556,7 +91957,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -91569,13 +91970,13 @@ var ts; hasImportDefault = true; } break; - case 265 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 277 /* ExternalModuleReference */) { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -91606,23 +92007,23 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 237 /* VariableStatement */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + case 237 /* SyntaxKind.VariableStatement */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames); } } break; - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default function() { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -91640,9 +92041,9 @@ var ts; } } break; - case 257 /* ClassDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default class { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -91723,7 +92124,7 @@ var ts; */ function isSimpleCopiableExpression(expression) { return ts.isStringLiteralLike(expression) || - expression.kind === 8 /* NumericLiteral */ || + expression.kind === 8 /* SyntaxKind.NumericLiteral */ || ts.isKeyword(expression.kind) || ts.isIdentifier(expression); } @@ -91738,27 +92139,27 @@ var ts; } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 64 /* FirstCompoundAssignment */ - && kind <= 78 /* LastCompoundAssignment */; + return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */ + && kind <= 78 /* SyntaxKind.LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 64 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 65 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 68 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 69 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 74 /* BarEqualsToken */: return 51 /* BarToken */; - case 78 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + case 64 /* SyntaxKind.PlusEqualsToken */: return 39 /* SyntaxKind.PlusToken */; + case 65 /* SyntaxKind.MinusEqualsToken */: return 40 /* SyntaxKind.MinusToken */; + case 66 /* SyntaxKind.AsteriskEqualsToken */: return 41 /* SyntaxKind.AsteriskToken */; + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return 42 /* SyntaxKind.AsteriskAsteriskToken */; + case 68 /* SyntaxKind.SlashEqualsToken */: return 43 /* SyntaxKind.SlashToken */; + case 69 /* SyntaxKind.PercentEqualsToken */: return 44 /* SyntaxKind.PercentToken */; + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: return 47 /* SyntaxKind.LessThanLessThanToken */; + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: return 48 /* SyntaxKind.GreaterThanGreaterThanToken */; + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; + case 73 /* SyntaxKind.AmpersandEqualsToken */: return 50 /* SyntaxKind.AmpersandToken */; + case 74 /* SyntaxKind.BarEqualsToken */: return 51 /* SyntaxKind.BarToken */; + case 78 /* SyntaxKind.CaretEqualsToken */: return 52 /* SyntaxKind.CaretToken */; + case 75 /* SyntaxKind.BarBarEqualsToken */: return 56 /* SyntaxKind.BarBarToken */; + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: return 55 /* SyntaxKind.AmpersandAmpersandToken */; + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return 60 /* SyntaxKind.QuestionQuestionToken */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -91820,7 +92221,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 167 /* PropertyDeclaration */ + return member.kind === 167 /* SyntaxKind.PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -91884,12 +92285,12 @@ var ts; */ function getAllDecoratorsOfClassElement(member, parent) { switch (member.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return getAllDecoratorsOfAccessors(member, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -92225,9 +92626,9 @@ var ts; var element = elements[i]; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); - if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */)) + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */ + && !(element.transformFlags & (32768 /* TransformFlags.ContainsRestOrSpread */ | 65536 /* TransformFlags.ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* TransformFlags.ContainsRestOrSpread */ | 65536 /* TransformFlags.ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -92268,14 +92669,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + if (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ && flattenContext.downlevelIteration) { // Read the elements of the iterable into an array value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) ? undefined : numElements), location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + else if (numElements !== 1 && (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ || numElements === 0) || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -92290,10 +92691,10 @@ var ts; var restContainingElements; for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (flattenContext.level >= 1 /* ObjectRest */) { + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -92496,7 +92897,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + var isLast = node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || node.kind === 17 /* SyntaxKind.TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); } // Newline normalization: @@ -92550,8 +92951,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -92571,14 +92972,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -92627,16 +93028,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 262 /* ModuleBlock */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 262 /* SyntaxKind.ModuleBlock */: + case 235 /* SyntaxKind.Block */: currentLexicalScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { break; } // Record these declarations provided that they have a name. @@ -92647,7 +93048,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 257 /* SyntaxKind.ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)); } break; } @@ -92666,7 +93067,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { return visitTypeScript(node); } return node; @@ -92686,10 +93087,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -92702,7 +93103,7 @@ var ts; // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes // We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`, // and will trigger debug failures when debug verbosity is turned up - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { // This node contains TypeScript, so we should visit its children. return ts.visitEachChild(node, visitor, context); } @@ -92710,13 +93111,13 @@ var ts; return node; } switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -92736,15 +93137,15 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 272 /* ExportDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 267 /* ImportClause */ || - (node.kind === 265 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 277 /* ExternalModuleReference */)) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ || + (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && + node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } - else if (node.transformFlags & 1 /* ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* Export */)) { + else if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return visitTypeScript(node); } return node; @@ -92764,27 +93165,27 @@ var ts; */ function classElementVisitorWorker(node, parent) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node, parent); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node, parent); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node, parent); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return ts.visitEachChild(node, visitor, context); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Index signatures are elided return; default: @@ -92796,17 +93197,17 @@ var ts; } function objectLiteralElementVisitorWorker(node, parent) { switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitor(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node, parent); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node, parent); @@ -92817,10 +93218,10 @@ var ts; function modifierVisitor(node) { if (ts.isDecorator(node)) return undefined; - if (ts.modifierToFlag(node.kind) & 116958 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 116958 /* ModifierFlags.TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* SyntaxKind.ExportKeyword */) { return undefined; } return node; @@ -92831,72 +93232,72 @@ var ts; * @param node The node to visit. */ function visitTypeScript(node) { - if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { // TypeScript ambient declarations are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 145 /* ReadonlyKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 185 /* OptionalType */: - case 186 /* RestType */: - case 182 /* TypeLiteral */: - case 177 /* TypePredicate */: - case 163 /* TypeParameter */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 133 /* BooleanKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 143 /* NeverKeyword */: - case 114 /* VoidKeyword */: - case 151 /* SymbolKeyword */: - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 181 /* TypeQuery */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 189 /* ConditionalType */: - case 191 /* ParenthesizedType */: - case 192 /* ThisType */: - case 193 /* TypeOperator */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 196 /* LiteralType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 177 /* SyntaxKind.TypePredicate */: + case 163 /* SyntaxKind.TypeParameter */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 181 /* SyntaxKind.TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 189 /* SyntaxKind.ConditionalType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 192 /* SyntaxKind.ThisType */: + case 193 /* SyntaxKind.TypeOperator */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 196 /* SyntaxKind.LiteralType */: // TypeScript type nodes are elided. // falls through - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // TypeScript index signatures are elided. return undefined; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return factory.createNotEmittedStatement(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -92906,7 +93307,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -92916,34 +93317,34 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors"); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -92953,40 +93354,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -93003,28 +93404,28 @@ var ts; return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement)); } function getClassFacts(node, staticProperties) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; if (ts.some(staticProperties)) - facts |= 1 /* HasStaticInitializedProperties */; + facts |= 1 /* ClassFacts.HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) - facts |= 64 /* IsDerivedClass */; + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */) + facts |= 64 /* ClassFacts.IsDerivedClass */; if (ts.classOrConstructorParameterIsDecorated(node)) - facts |= 2 /* HasConstructorDecorators */; + facts |= 2 /* ClassFacts.HasConstructorDecorators */; if (ts.childIsDecorated(node)) - facts |= 4 /* HasMemberDecorators */; + facts |= 4 /* ClassFacts.HasMemberDecorators */; if (isExportOfNamespace(node)) - facts |= 8 /* IsExportOfNamespace */; + facts |= 8 /* ClassFacts.IsExportOfNamespace */; else if (isDefaultExternalModuleExport(node)) - facts |= 32 /* IsDefaultExternalExport */; + facts |= 32 /* ClassFacts.IsDefaultExternalExport */; else if (isNamedExternalModuleExport(node)) - facts |= 16 /* IsNamedExternalExport */; - if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */)) - facts |= 128 /* UseImmediatelyInvokedFunctionExpression */; + facts |= 16 /* ClassFacts.IsNamedExternalExport */; + if (languageVersion <= 1 /* ScriptTarget.ES5 */ && (facts & 7 /* ClassFacts.MayNeedImmediatelyInvokedFunctionExpression */)) + facts |= 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.hasDecorators(node) @@ -93033,20 +93434,20 @@ var ts; || ts.some(node.members, hasTypeScriptClassSyntax); } function visitClassDeclaration(node) { - if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) { + if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement)); } var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); } - var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); + var name = node.name || (facts & 5 /* ClassFacts.NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); var allDecorators = ts.getAllDecoratorsOfClass(node); var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators); // we do not emit modifiers on the declaration if we are emitting an IIFE - var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */) + var modifiers = !(facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) : ts.elideNodes(factory, node.modifiers); // preserve positions, if available // ${modifiers} class ${name} ${heritageClauses} { @@ -93057,12 +93458,12 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. var emitFlags = ts.getEmitFlags(node); - if (facts & 1 /* HasStaticInitializedProperties */) { - emitFlags |= 32 /* NoTrailingSourceMap */; + if (facts & 1 /* ClassFacts.HasStaticInitializedProperties */) { + emitFlags |= 32 /* EmitFlags.NoTrailingSourceMap */; } ts.setEmitFlags(classStatement, emitFlags); var statements = [classStatement]; - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the // 'es2015' transformer can properly nest static initializers and decorators. The result // looks something like: @@ -93074,20 +93475,20 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); var localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(localName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment()); var iife = factory.createImmediatelyInvokedArrowFunction(statements); - ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); + ts.setEmitFlags(iife, 33554432 /* EmitFlags.TypeScriptClassWrapper */); var varStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), @@ -93103,21 +93504,21 @@ var ts; // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. - if (facts & 8 /* IsExportOfNamespace */) { + if (facts & 8 /* ClassFacts.IsExportOfNamespace */) { addExportMemberAssignment(statements, node); } - else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { - if (facts & 32 /* IsDefaultExternalExport */) { + else if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* ClassFacts.HasConstructorDecorators */) { + if (facts & 32 /* ClassFacts.IsDefaultExternalExport */) { statements.push(factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } - else if (facts & 16 /* IsNamedExternalExport */) { + else if (facts & 16 /* ClassFacts.IsNamedExternalExport */) { statements.push(factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -93188,11 +93589,11 @@ var ts; var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression); var helper = emitHelpers().createParamHelper(expression, parameterOffset); ts.setTextRange(helper, parameterDecorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); var decorator = factory.createDecorator(helper); ts.setSourceMapRange(decorator, parameterDecorator.expression); ts.setCommentRange(decorator, parameterDecorator.expression); - ts.setEmitFlags(decorator, 1536 /* NoComments */); + ts.setEmitFlags(decorator, 1536 /* EmitFlags.NoComments */); decorators.push(decorator); } return decorators; @@ -93230,15 +93631,15 @@ var ts; if (typeSerializer) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); properties = ts.append(properties, typeProperty); } if (shouldAddParamTypesMetadata(node)) { - var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container))); + var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container))); properties = ts.append(properties, paramTypeProperty); } if (shouldAddReturnTypeMetadata(node)) { - var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); properties = ts.append(properties, returnTypeProperty); } if (properties) { @@ -93256,10 +93657,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 167 /* PropertyDeclaration */; + return kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -93269,7 +93670,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -93280,12 +93681,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; } return false; @@ -93347,7 +93748,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 117 /* ImplementsKeyword */) { + if (node.token === 117 /* SyntaxKind.ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -93375,7 +93776,7 @@ var ts; return !ts.nodeIsMissing(node.body); } function visitPropertyDeclaration(node, parent) { - var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */); + var isAmbient = node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); if (isAmbient && !ts.hasDecorators(node)) { return undefined; } @@ -93383,7 +93784,7 @@ var ts; var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators); // Preserve a `declare x` property with decorators to be handled by the decorators transform if (isAmbient) { - return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, factory.createModifiersFromModifierFlags(2 /* Ambient */)), ts.visitNode(node.name, visitor, ts.isPropertyName), + return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, factory.createModifiersFromModifierFlags(2 /* ModifierFlags.Ambient */)), ts.visitNode(node.name, visitor, ts.isPropertyName), /*questionOrExclamationToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); @@ -93435,7 +93836,8 @@ var ts; statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); + var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start)); // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); @@ -93455,14 +93857,14 @@ var ts; } // TODO(rbuckton): Does this need to be parented? var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 48 /* EmitFlags.NoSourceMap */); // TODO(rbuckton): Does this need to be parented? var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(localName, 1536 /* NoComments */); + ts.setEmitFlags(localName, 1536 /* EmitFlags.NoComments */); return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1)))); } function visitMethodDeclaration(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitFunctionLikeDeclaration(node)) { @@ -93482,10 +93884,10 @@ var ts; * @param node The declaration node. */ function shouldEmitAccessorDeclaration(node) { - return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */)); + return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)); } function visitGetAccessor(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitAccessorDeclaration(node)) { @@ -93498,7 +93900,7 @@ var ts; /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([])); } function visitSetAccessor(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitAccessorDeclaration(node)) { @@ -93552,7 +93954,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -93572,7 +93974,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createNamespaceExportExpression); } else { @@ -93590,7 +93992,7 @@ var ts; return updated; } function visitParenthesizedExpression(node) { - var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */); + var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* OuterExpressionKinds.Assertions */); if (ts.isAssertionExpression(innerExpression)) { // Make sure we consider all nested cast expressions, e.g.: // (-A).x; @@ -93667,7 +94069,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. @@ -93675,7 +94077,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the enum. @@ -93683,7 +94085,7 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93749,7 +94151,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* SyntaxKind.StringLiteral */ ? innerAssignment : factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -93837,12 +94239,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 305 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 305 /* SyntaxKind.SourceFile */ ? 0 /* NodeFlags.None */ : 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 260 /* EnumDeclaration */) { + if (node.kind === 260 /* SyntaxKind.EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -93867,7 +94269,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.addEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.addEmitFlags(statement, 1024 /* EmitFlags.NoTrailingComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -93877,7 +94279,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = factory.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* EmitFlags.NoComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -93898,7 +94300,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. @@ -93906,7 +94308,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the namespace. @@ -93914,7 +94316,7 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93967,7 +94369,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 262 /* ModuleBlock */) { + if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -94014,13 +94416,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 262 /* ModuleBlock */) { - ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); + if (!node.body || node.body.kind !== 262 /* SyntaxKind.ModuleBlock */) { + ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* EmitFlags.NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -94043,8 +94445,8 @@ var ts; // Elide the declaration if the import clause was elided. var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause || - compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */ + compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ ? factory.updateImportDeclaration(node, /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) : undefined; @@ -94067,14 +94469,14 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 268 /* NamespaceImport */) { + if (node.kind === 268 /* SyntaxKind.NamespaceImport */) { // Elide a namespace import if it is not referenced. return shouldEmitAliasDeclaration(node) ? node : undefined; } else { // Elide named imports if all of its import specifiers are elided and settings allow. - var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; } @@ -94115,8 +94517,8 @@ var ts; return node; } // Elide the export declaration if all of its named exports are elided. - var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause ? factory.updateExportDeclaration(node, @@ -94175,7 +94577,7 @@ var ts; if (ts.isExternalModuleImportEqualsDeclaration(node)) { var isReferenced = shouldEmitAliasDeclaration(node); // If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'. - if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) { + if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */) { return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration( /*modifiers*/ undefined, /*importClause*/ undefined, node.moduleReference.expression, @@ -94187,7 +94589,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference); - ts.setEmitFlags(moduleReference, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -94208,7 +94610,7 @@ var ts; * @param node The node to test. */ function isExportOfNamespace(node) { - return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is exported from an external module. @@ -94216,7 +94618,7 @@ var ts; * @param node The node to test. */ function isExternalModuleExport(node) { - return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is a named export from an external module. @@ -94225,7 +94627,7 @@ var ts; */ function isNamedExternalModuleExport(node) { return isExternalModuleExport(node) - && !ts.hasSyntacticModifier(node, 512 /* Default */); + && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Gets a value indicating whether the node is the default export of an external module. @@ -94234,7 +94636,7 @@ var ts; */ function isDefaultExternalModuleExport(node) { return isExternalModuleExport(node) - && ts.hasSyntacticModifier(node, 512 /* Default */); + && ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } function addExportMemberAssignment(statements, node) { var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node)); @@ -94268,27 +94670,27 @@ var ts; return factory.getGeneratedNameForNode(node); } function enableSubstitutionForNonQualifiedEnumMembers() { - if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { - enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */) === 0) { + enabledSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } function enableSubstitutionForNamespaceExports() { - if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) { - enabledSubstitutions |= 2 /* NamespaceExports */; + if ((enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) === 0) { + enabledSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(79 /* Identifier */); - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(261 /* ModuleDeclaration */); + context.enableEmitNotification(261 /* SyntaxKind.ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 261 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 260 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 260 /* SyntaxKind.EnumDeclaration */; } /** * Hook for node emit. @@ -94303,11 +94705,11 @@ var ts; if (ts.isSourceFile(node)) { currentSourceFile = node; } - if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { - applicableSubstitutions |= 2 /* NamespaceExports */; + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && isTransformedModuleDeclaration(node)) { + applicableSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; } - if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { - applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; + if (enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { + applicableSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; @@ -94321,7 +94723,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -94330,7 +94732,7 @@ var ts; return node; } function substituteShorthandPropertyAssignment(node) { - if (enabledSubstitutions & 2 /* NamespaceExports */) { + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) { var name = node.name; var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { @@ -94347,11 +94749,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -94366,9 +94768,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 305 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 261 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 260 /* EnumDeclaration */); + if (container && container.kind !== 305 /* SyntaxKind.SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && container.kind === 261 /* SyntaxKind.ModuleDeclaration */) || + (applicableSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && container.kind === 260 /* SyntaxKind.EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -94394,7 +94796,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3 /* SyntaxKind.MultiLineCommentTrivia */, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -94457,13 +94859,13 @@ var ts; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); - var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */; + var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ScriptTarget.ES2022 */; // We need to transform `this` in a static initializer into a reference to the class // when targeting < ES2022 since the assignment will be moved outside of the class body. - var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */; + var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ScriptTarget.ES2022 */; // We don't need to transform `super` property access when targeting ES5, ES3 because // the es2015 transformation handles those. - var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */; + var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ScriptTarget.ES2015 */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -94489,7 +94891,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ES2022 */) { + || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ScriptTarget.ES2022 */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -94497,50 +94899,50 @@ var ts; return visited; } function visitorWorker(node, valueIsDiscarded) { - if (node.transformFlags & 16777216 /* ContainsClassFields */) { + if (node.transformFlags & 16777216 /* TransformFlags.ContainsClassFields */) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassLike(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return visitPrivateIdentifier(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitClassStaticBlockDeclaration(node); } } - if (node.transformFlags & 16777216 /* ContainsClassFields */ || - node.transformFlags & 134217728 /* ContainsLexicalSuper */ && + if (node.transformFlags & 16777216 /* TransformFlags.ContainsClassFields */ || + node.transformFlags & 134217728 /* TransformFlags.ContainsLexicalSuper */ && shouldTransformSuperInStaticInitializers && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; currentStaticPropertyDeclarationOrStaticBlock = undefined; var result = ts.visitEachChild(node, visitor, context); @@ -94559,17 +94961,17 @@ var ts; } function heritageClauseVisitor(node) { switch (node.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return ts.visitEachChild(node, heritageClauseVisitor, context); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitExpressionWithTypeArguments(node); } return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -94599,7 +95001,7 @@ var ts; } var privId = node.left; ts.Debug.assertNode(privId, ts.isPrivateIdentifier); - ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */); + ts.Debug.assert(node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */); var info = accessPrivateIdentifier(privId); if (info) { var receiver = ts.visitNode(node.right, visitor, ts.isExpression); @@ -94615,19 +95017,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return visitor(node); @@ -94676,10 +95078,10 @@ var ts; ts.Debug.assert(ts.isPrivateIdentifier(node.name)); var info = accessPrivateIdentifier(node.name); ts.Debug.assert(info, "Undeclared private name for property declaration."); - if (info.kind === "m" /* Method */) { + if (info.kind === "m" /* PrivateIdentifierKind.Method */) { return info.methodName; } - if (info.kind === "a" /* Accessor */) { + if (info.kind === "a" /* PrivateIdentifierKind.Accessor */) { if (ts.isGetAccessor(node)) { return info.getterName; } @@ -94738,11 +95140,11 @@ var ts; function createPrivateIdentifierAccessHelper(info, receiver) { ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94761,7 +95163,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94780,7 +95182,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94794,16 +95196,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { - if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { + var operand = ts.skipParentheses(node.operand); + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) { var info = void 0; - if (info = accessPrivateIdentifier(node.operand.name)) { - var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); + if (info = accessPrivateIdentifier(operand.name)) { + var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); - expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */); + expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* SyntaxKind.EqualsToken */); ts.setOriginalNode(expression, node); ts.setTextRange(expression, node); if (temp) { @@ -94814,7 +95217,7 @@ var ts; } } else if (shouldTransformSuperInStaticInitializers && - ts.isSuperProperty(node.operand) && + ts.isSuperProperty(operand) && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { // converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)` @@ -94826,32 +95229,32 @@ var ts; // converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)` // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)` var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { - var operand = visitInvalidSuperProperty(node.operand); + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { + var expression = visitInvalidSuperProperty(operand); return ts.isPrefixUnaryExpression(node) ? - factory.updatePrefixUnaryExpression(node, operand) : - factory.updatePostfixUnaryExpression(node, operand); + factory.updatePrefixUnaryExpression(node, expression) : + factory.updatePostfixUnaryExpression(node, expression); } if (classConstructor && superClassReference) { var setterName = void 0; var getterName = void 0; - if (ts.isPropertyAccessExpression(node.operand)) { - if (ts.isIdentifier(node.operand.name)) { - getterName = setterName = factory.createStringLiteralFromNode(node.operand.name); + if (ts.isPropertyAccessExpression(operand)) { + if (ts.isIdentifier(operand.name)) { + getterName = setterName = factory.createStringLiteralFromNode(operand.name); } } else { - if (ts.isSimpleInlineableExpression(node.operand.argumentExpression)) { - getterName = setterName = node.operand.argumentExpression; + if (ts.isSimpleInlineableExpression(operand.argumentExpression)) { + getterName = setterName = operand.argumentExpression; } else { getterName = factory.createTempVariable(hoistVariableDeclaration); - setterName = factory.createAssignment(getterName, ts.visitNode(node.operand.argumentExpression, visitor, ts.isExpression)); + setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression)); } } if (setterName && getterName) { var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor); - ts.setTextRange(expression, node.operand); + ts.setTextRange(expression, operand); var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor); @@ -94942,7 +95345,7 @@ var ts; var iife = factory.createImmediatelyInvokedArrowFunction(statements); ts.setOriginalNode(iife, node); ts.setTextRange(iife, node); - ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(iife, 2 /* EmitFlags.AdviseOnEmitNode */); return iife; } } @@ -94969,7 +95372,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); } if (classConstructor && superClassReference) { @@ -95011,7 +95414,7 @@ var ts; } } } - if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) { + if (node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { return visitPrivateIdentifierInInExpression(node); } return ts.visitEachChild(node, visitor, context); @@ -95026,12 +95429,12 @@ var ts; } ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, /* f */ undefined); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -95071,28 +95474,28 @@ var ts; return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function getClassFacts(node) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; var original = ts.getOriginalNode(node); if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) { - facts |= 1 /* ClassWasDecorated */; + facts |= 1 /* ClassFacts.ClassWasDecorated */; } for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (!ts.isStatic(member)) continue; if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) { - facts |= 2 /* NeedsClassConstructorReference */; + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { - if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) { - facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */; - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */; + if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */) { + facts |= 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */; + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } } - if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) { - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */; + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* TransformFlags.ContainsLexicalSuper */) { + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */ | 4 /* ClassFacts.NeedsClassSuperReference */; } } } @@ -95100,8 +95503,8 @@ var ts; return facts; } function visitExpressionWithTypeArguments(node) { - var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */; - if (facts & 4 /* NeedsClassSuperReference */) { + var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* ClassFacts.None */; + if (facts & 4 /* ClassFacts.NeedsClassSuperReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true); getClassLexicalEnvironment().superClassReference = temp; return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)), @@ -95114,19 +95517,19 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If a class has private static fields, or a static field has a `this` or `super` reference, // then we need to allocate a temp variable to hold on to that reference. var pendingClassReferenceAssignment; - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node)); } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); var statements = [ factory.updateClassDeclaration(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) @@ -95154,7 +95557,7 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If this class expression is a transformation of a decorated class declaration, @@ -95164,19 +95567,19 @@ var ts; // In this case, we use pendingStatements to produce the same output as the // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. - var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */); + var isDecoratedClassDeclaration = !!(facts & 1 /* ClassFacts.ClassWasDecorated */); var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; var temp; function createClassTempVar() { var classCheckFlags = resolver.getNodeCheckFlags(node); - var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; - var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + var isClassWithConstructorReference = classCheckFlags & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); } - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { temp = createClassTempVar(); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } @@ -95205,12 +95608,12 @@ var ts; // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); var alias = factory.cloneNode(temp); - alias.autoGenerateFlags &= ~8 /* ReservedInNestedScopes */; + alias.autoGenerateFlags &= ~8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; classAliases[ts.getOriginalNodeId(node)] = alias; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* EmitFlags.Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression))); // Add any pending expressions leftover from elided or relocated computed property names ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine)); @@ -95263,13 +95666,13 @@ var ts; /*typeArguments*/ undefined, []))); } function isClassElementThatRequiresConstructorStatement(member) { - if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* ModifierFlags.Abstract */)) { return false; } if (useDefineForClassFields) { // If we are using define semantics and targeting ESNext or higher, // then we don't need to transform any class properties. - return languageVersion < 9 /* ES2022 */; + return languageVersion < 9 /* ScriptTarget.ES2022 */; } return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member); } @@ -95458,7 +95861,7 @@ var ts; if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) { // capture the lexical environment for the member ts.setOriginalNode(transformed, property); - ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(transformed, 2 /* EmitFlags.AdviseOnEmitNode */); classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment); } currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; @@ -95477,7 +95880,7 @@ var ts; if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - if (privateIdentifierInfo.kind === "f" /* Field */) { + if (privateIdentifierInfo.kind === "f" /* PrivateIdentifierKind.Field */) { if (!privateIdentifierInfo.isStatic) { return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); } @@ -95497,7 +95900,7 @@ var ts; return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); - if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* ModifierFlags.Abstract */)) { return undefined; } var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero() @@ -95516,32 +95919,32 @@ var ts; } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* ClassPropertySubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForClassStaticThisOrSuperReference() { - if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) { - enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */; + if ((enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */) === 0) { + enabledSubstitutions |= 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */; // substitute `this` in a static field initializer - context.enableSubstitution(108 /* ThisKeyword */); + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); // these push a new lexical environment that is not the class lexical environment - context.enableEmitNotification(256 /* FunctionDeclaration */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // these push a new lexical environment that is not the class lexical environment, except // when they have a computed property name - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(167 /* PropertyDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(167 /* SyntaxKind.PropertyDeclaration */); // class lexical environments are restored when entering a computed property name - context.enableEmitNotification(162 /* ComputedPropertyName */); + context.enableEmitNotification(162 /* SyntaxKind.ComputedPropertyName */); } } /** @@ -95580,13 +95983,13 @@ var ts; } } switch (node.kind) { - case 213 /* FunctionExpression */: - if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { + case 213 /* SyntaxKind.FunctionExpression */: + if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */) { break; } // falls through - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = undefined; @@ -95596,10 +95999,10 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; @@ -95609,7 +96012,7 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 162 /* ComputedPropertyName */: { + case 162 /* SyntaxKind.ComputedPropertyName */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; @@ -95630,24 +96033,24 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisExpression(node); } return node; } function substituteThisExpression(node) { - if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { + if (enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.createParenthesizedExpression(factory.createVoidZero()); } if (classConstructor) { @@ -95660,8 +96063,8 @@ var ts; return trySubstituteClassAlias(node) || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -95694,7 +96097,7 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(generatedName); } else { @@ -95714,7 +96117,7 @@ var ts; } function getClassLexicalEnvironment() { return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = { - facts: 0 /* None */, + facts: 0 /* ClassFacts.None */, classConstructor: undefined, superClassReference: undefined, privateIdentifierEnvironment: undefined, @@ -95747,7 +96150,7 @@ var ts; if (ts.isPropertyDeclaration(node)) { var variableName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, variableName: variableName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95757,7 +96160,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { var functionName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: functionName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95766,12 +96169,12 @@ var ts; } else if (ts.isGetAccessorDeclaration(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: classConstructor, @@ -95782,12 +96185,12 @@ var ts; } else if (ts.isSetAccessorDeclaration(node)) { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: classConstructor, @@ -95803,7 +96206,7 @@ var ts; else if (ts.isPropertyDeclaration(node)) { var weakMapName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, brandCheckIdentifier: weakMapName, isStatic: false, variableName: undefined, @@ -95815,7 +96218,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: createHoistedVariableForPrivateName(text, node), brandCheckIdentifier: weakSetName, isStatic: false, @@ -95826,12 +96229,12 @@ var ts; ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); if (ts.isGetAccessor(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: weakSetName, @@ -95842,12 +96245,12 @@ var ts; } else { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: weakSetName, @@ -95864,9 +96267,9 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16 /* Optimistic */); - if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) { + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */); + if (resolver.getNodeCheckFlags(node) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(identifier); } else { @@ -95908,9 +96311,9 @@ var ts; // differently inside the function. if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); } - return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */)); + return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* SyntaxKind.EqualsToken */)); } function visitArrayAssignmentTarget(node) { var target = ts.getTargetOfBindingOrAssignmentElement(node); @@ -95924,7 +96327,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95964,7 +96367,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -96072,15 +96475,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: return serializeTypeNode(node.type); - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createIdentifier("Function"); default: return ts.factory.createVoidZero(); @@ -96116,7 +96519,7 @@ var ts; return ts.factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 172 /* GetAccessor */) { + if (container && node.kind === 172 /* SyntaxKind.GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -96161,67 +96564,67 @@ var ts; } node = ts.skipTypeParentheses(node); switch (node.kind) { - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return ts.factory.createVoidZero(); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return ts.factory.createIdentifier("Function"); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return ts.factory.createIdentifier("Array"); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? ts.factory.createVoidZero() : ts.factory.createIdentifier("Boolean"); - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return ts.factory.createIdentifier("Boolean"); - case 198 /* TemplateLiteralType */: - case 150 /* StringKeyword */: + case 198 /* SyntaxKind.TemplateLiteralType */: + case 150 /* SyntaxKind.StringKeyword */: return ts.factory.createIdentifier("String"); - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return ts.factory.createIdentifier("Object"); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return serializeLiteralOfLiteralTypeNode(node.literal); - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return ts.factory.createIdentifier("Number"); - case 158 /* BigIntKeyword */: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); - case 151 /* SymbolKeyword */: - return getGlobalConstructor("Symbol", 2 /* ES2015 */); - case 178 /* TypeReference */: + case 158 /* SyntaxKind.BigIntKeyword */: + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); + case 151 /* SyntaxKind.SymbolKeyword */: + return getGlobalConstructor("Symbol", 2 /* ScriptTarget.ES2015 */); + case 178 /* SyntaxKind.TypeReference */: return serializeTypeReferenceNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ true); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ false); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], /*isIntersection*/ false); - case 193 /* TypeOperator */: - if (node.operator === 145 /* ReadonlyKeyword */) { + case 193 /* SyntaxKind.TypeOperator */: + if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 181 /* TypeQuery */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 182 /* TypeLiteral */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 192 /* ThisType */: - case 200 /* ImportType */: + case 181 /* SyntaxKind.TypeQuery */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 200 /* SyntaxKind.ImportType */: break; // handle JSDoc types from an invalid parse - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 317 /* JSDocFunctionType */: - case 318 /* JSDocVariadicType */: - case 319 /* JSDocNamepathType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 318 /* SyntaxKind.JSDocVariadicType */: + case 319 /* SyntaxKind.JSDocNamepathType */: break; - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 316 /* JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -96230,27 +96633,27 @@ var ts; } function serializeLiteralOfLiteralTypeNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.factory.createIdentifier("String"); - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; switch (operand.kind) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return serializeLiteralOfLiteralTypeNode(operand); default: return ts.Debug.failBadSyntaxKind(operand); } } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.factory.createIdentifier("Number"); - case 9 /* BigIntLiteral */: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 9 /* SyntaxKind.BigIntLiteral */: + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return ts.factory.createIdentifier("Boolean"); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return ts.factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node); @@ -96262,20 +96665,20 @@ var ts; for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { var typeNode = types_22[_i]; typeNode = ts.skipTypeParentheses(typeNode); - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { if (isIntersection) return ts.factory.createVoidZero(); // Reduce to `never` in an intersection continue; // Elide `never` in a union } - if (typeNode.kind === 155 /* UnknownKeyword */) { + if (typeNode.kind === 155 /* SyntaxKind.UnknownKeyword */) { if (!isIntersection) return ts.factory.createIdentifier("Object"); // Reduce to `unknown` in a union continue; // Elide `unknown` in an intersection } - if (typeNode.kind === 130 /* AnyKeyword */) { + if (typeNode.kind === 130 /* SyntaxKind.AnyKeyword */) { return ts.factory.createIdentifier("Object"); // Reduce to `any` in a union or intersection } - if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */) || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */) || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedConstituent = serializeTypeNode(typeNode); @@ -96356,7 +96759,7 @@ var ts; case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: return ts.factory.createVoidZero(); case ts.TypeReferenceSerializationKind.BigIntLikeType: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); case ts.TypeReferenceSerializationKind.BooleanType: return ts.factory.createIdentifier("Boolean"); case ts.TypeReferenceSerializationKind.NumberLikeType: @@ -96366,7 +96769,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return ts.factory.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return getGlobalConstructor("Symbol", 2 /* ES2015 */); + return getGlobalConstructor("Symbol", 2 /* ScriptTarget.ES2015 */); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: return ts.factory.createIdentifier("Function"); case ts.TypeReferenceSerializationKind.Promise: @@ -96396,12 +96799,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { // A -> typeof A !== "undefined" && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 79 /* Identifier */) { + if (node.left.kind === 79 /* SyntaxKind.Identifier */) { // A.B -> typeof A !== "undefined" && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -96416,14 +96819,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -96474,28 +96877,28 @@ var ts; return ts.isDecorator(node) ? undefined : node; } function visitor(node) { - if (!(node.transformFlags & 33554432 /* ContainsDecorators */)) { + if (!(node.transformFlags & 33554432 /* TransformFlags.ContainsDecorators */)) { return node; } switch (node.kind) { - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are elided. They will be emitted as part of `visitClassDeclaration`. return undefined; - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructorDeclaration(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitSetAccessorDeclaration(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return visitGetAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameterDeclaration(node); default: return ts.visitEachChild(node, visitor, context); @@ -96504,39 +96907,72 @@ var ts; function visitClassDeclaration(node) { if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node))) return ts.visitEachChild(node, visitor, context); - var classStatement = ts.hasDecorators(node) ? - createClassDeclarationHeadWithDecorators(node, node.name) : - createClassDeclarationHeadWithoutDecorators(node, node.name); - var statements = [classStatement]; - // Write any decorators of the node. - addClassElementDecorationStatements(statements, node, /*isStatic*/ false); - addClassElementDecorationStatements(statements, node, /*isStatic*/ true); - addConstructorDecorationStatement(statements, node); + var statements = ts.hasDecorators(node) ? + transformClassDeclarationWithClassDecorators(node, node.name) : + transformClassDeclarationWithoutClassDecorators(node, node.name); if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } + function decoratorContainsPrivateIdentifierInExpression(decorator) { + return !!(decorator.transformFlags & 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); + } + function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) { + return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression); + } + function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (!ts.canHaveDecorators(member)) + continue; + var allDecorators = ts.getAllDecoratorsOfClassElement(member, node); + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression)) + return true; + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression)) + return true; + } + return false; + } + function transformDecoratorsOfClassElements(node, members) { + var decorationStatements = []; + addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ false); + addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ true); + if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) { + members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [ + factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, /*multiLine*/ true)) + ], false)), members); + decorationStatements = undefined; + } + return { decorationStatements: decorationStatements, members: members }; + } /** * Transforms a non-decorated class declaration. * * @param node A ClassDeclaration node. * @param name The name of the class. */ - function createClassDeclarationHeadWithoutDecorators(node, name) { + function transformClassDeclarationWithoutClassDecorators(node, name) { // ${modifiers} class ${name} ${heritageClauses} { // ${members} // } - return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement)); + var _a; + var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = ts.visitNodes(node.members, visitor, ts.isClassElement); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var updated = factory.updateClassDeclaration(node, modifiers, name, + /*typeParameters*/ undefined, heritageClauses, members); + return ts.addRange([updated], decorationStatements); } /** * Transforms a decorated class declaration and appends the resulting statements. If * the class requires an alias to avoid issues with double-binding, the alias is returned. */ - function createClassDeclarationHeadWithDecorators(node, name) { + function transformClassDeclarationWithClassDecorators(node, name) { // When we emit an ES6 class that has a class decorator, we must tailor the // emit to certain specific cases. // @@ -96622,11 +97058,12 @@ var ts; // | var C_1; // --------------------------------------------------------------------- // + var _a; var location = ts.moveRangePastModifiers(node); var classAlias = getClassAliasIfNeeded(node); // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var declName = languageVersion <= 2 /* ES2015 */ ? + var declName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { @@ -96634,7 +97071,11 @@ var ts; // } var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = ts.visitNodes(node.members, visitor, ts.isClassElement); - var classExpression = factory.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var classExpression = factory.createClassExpression( + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); ts.setTextRange(classExpression, location); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference @@ -96644,11 +97085,14 @@ var ts; factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) - ], 1 /* Let */)); + ], 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); ts.setTextRange(statement, location); ts.setCommentRange(statement, node); - return statement; + var statements = [statement]; + ts.addRange(statements, decorationStatements); + addConstructorDecorationStatement(statements, node); + return statements; } function visitClassExpression(node) { // Legacy decorators were not supported on class expressions @@ -96681,7 +97125,7 @@ var ts; return finishClassElement(factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock)), node); } function visitPropertyDeclaration(node) { - if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { return undefined; } return finishClassElement(factory.updatePropertyDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), @@ -96698,7 +97142,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -96808,9 +97252,9 @@ var ts; // ], C.prototype, "prop"); // var prefix = getClassMemberPrefix(node, member); - var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */)); - var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 167 /* PropertyDeclaration */ + var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* ModifierFlags.Ambient */)); + var descriptor = languageVersion > 0 /* ScriptTarget.ES3 */ + ? member.kind === 167 /* SyntaxKind.PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -96819,7 +97263,7 @@ var ts; : factory.createNull() : undefined; var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member)); return helper; } @@ -96848,12 +97292,12 @@ var ts; var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var localName = languageVersion <= 2 /* ES2015 */ ? + var localName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 1536 /* NoComments */); + ts.setEmitFlags(expression, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node)); return expression; } @@ -96879,7 +97323,7 @@ var ts; var decorator = decorators_1[_i]; var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); ts.setTextRange(helper, decorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); expressions.push(helper); } } @@ -96912,7 +97356,7 @@ var ts; if (!classAliases) { // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } @@ -96923,7 +97367,7 @@ var ts; * double-binding semantics for the class name. */ function getClassAliasIfNeeded(node) { - if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) { + if (resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; @@ -96947,14 +97391,14 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -96965,7 +97409,7 @@ var ts; } function trySubstituteClassAlias(node) { if (classAliases) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -97037,8 +97481,8 @@ var ts; if (node.isDeclarationFile) { return node; } - setContextFlag(1 /* NonTopLevel */, false); - setContextFlag(2 /* HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); + setContextFlag(1 /* ContextFlags.NonTopLevel */, false); + setContextFlag(2 /* ContextFlags.HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -97050,10 +97494,10 @@ var ts; return (contextFlags & flags) !== 0; } function inTopLevelContext() { - return !inContext(1 /* NonTopLevel */); + return !inContext(1 /* ContextFlags.NonTopLevel */); } function inHasLexicalThisContext() { - return inContext(2 /* HasLexicalThis */); + return inContext(2 /* ContextFlags.HasLexicalThis */); } function doWithContext(flags, cb, value) { var contextFlagsToSet = flags & ~contextFlags; @@ -97069,39 +97513,39 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 256 /* TransformFlags.ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 169 /* MethodDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 256 /* FunctionDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 213 /* FunctionExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 214 /* ArrowFunction */: - return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitMethodDeclaration, node); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionDeclaration, node); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionExpression, node); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithContext(1 /* ContextFlags.NonTopLevel */, visitArrowFunction, node); + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -97109,27 +97553,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatementInAsyncBody(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatementInAsyncBody(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClauseInAsyncBody(node); - case 235 /* Block */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 248 /* WithStatement */: - case 250 /* LabeledStatement */: + case 235 /* SyntaxKind.Block */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -97211,7 +97655,7 @@ var ts; return factory.updateMethodDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97226,7 +97670,7 @@ var ts; function visitFunctionDeclaration(node) { return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97241,7 +97685,7 @@ var ts; function visitFunctionExpression(node) { return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97256,7 +97700,7 @@ var ts; function visitArrowFunction(node) { return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97277,7 +97721,7 @@ var ts; function isVariableDeclarationListWithCollidingName(node) { return !!node && ts.isVariableDeclarationList(node) - && !(node.flags & 3 /* BlockScoped */) + && !(node.flags & 3 /* NodeFlags.BlockScoped */) && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { @@ -97331,9 +97775,9 @@ var ts; resumeLexicalEnvironment(); var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 214 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + var promiseConstructor = languageVersion < 2 /* ScriptTarget.ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 214 /* SyntaxKind.ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* NodeCheckFlags.CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -97359,7 +97803,7 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); if (capturedSuperProperties.size) { @@ -97372,10 +97816,10 @@ var ts; ts.setTextRange(block, node.body); if (emitSuperHelpers && hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -97419,21 +97863,21 @@ var ts; return undefined; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -97446,8 +97890,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -97474,30 +97918,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -97517,19 +97961,19 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), location); } } @@ -97539,7 +97983,7 @@ var ts; function createSuperAccessVariableStatement(factory, resolver, node, names) { // Create a variable declaration with a getter/setter (if binding) definition for each name: // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... }); - var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) !== 0; + var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0; var accessors = []; names.forEach(function (_, key) { var name = ts.unescapeLeadingUnderscores(key); @@ -97549,7 +97993,7 @@ var ts; /* typeParameters */ undefined, /* parameters */ [], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */)))); + /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */)))); if (hasBinding) { getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction( /* modifiers */ undefined, @@ -97563,20 +98007,20 @@ var ts; /* initializer */ undefined) ], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */), factory.createIdentifier("v"))))); + /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v"))))); } accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter))); }); return factory.createVariableStatement( /* modifiers */ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), /* typeArguments */ undefined, [ factory.createNull(), factory.createObjectLiteralExpression(accessors, /* multiline */ true) ])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; })(ts || (ts = {})); @@ -97646,7 +98090,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -97678,7 +98122,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 131 /* AsyncKeyword */) { + if (node.kind === 131 /* SyntaxKind.AsyncKeyword */) { return undefined; } return node; @@ -97700,88 +98144,88 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 244 /* ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + return doWithHierarchyFacts(visitDefault, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: - return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 217 /* VoidExpression */: + case 242 /* SyntaxKind.ForStatement */: + return doWithHierarchyFacts(visitForStatement, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); - case 171 /* Constructor */: - return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 169 /* MethodDeclaration */: - return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 172 /* GetAccessor */: - return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 173 /* SetAccessor */: - return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 256 /* FunctionDeclaration */: - return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 213 /* FunctionExpression */: - return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 214 /* ArrowFunction */: - return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 164 /* Parameter */: + case 171 /* SyntaxKind.Constructor */: + return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 172 /* SyntaxKind.GetAccessor */: + return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 173 /* SyntaxKind.SetAccessor */: + return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithHierarchyFacts(visitArrowFunction, node, 2 /* HierarchyFacts.ArrowFunctionExcludes */, 0 /* HierarchyFacts.ArrowFunctionIncludes */); + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithHierarchyFacts(visitDefault, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); } function visitYieldExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { if (node.asteriskToken) { var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression); return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression( @@ -97795,15 +98239,15 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitReturnStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero())); } return ts.visitEachChild(node, visitor, context); } function visitLabeledStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 244 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 244 /* SyntaxKind.ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -97815,7 +98259,7 @@ var ts; var objects = []; for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { var e = elements_5[_i]; - if (e.kind === 298 /* SpreadAssignment */) { + if (e.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -97824,7 +98268,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 296 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 296 /* SyntaxKind.PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -97835,7 +98279,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { // spread elements emit like so: // non-spread elements are chunked together into object literals, and then all are passed to __assign: // { a, ...o, b } => __assign(__assign({a}, o), {b}); @@ -97858,7 +98302,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 205 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -97885,9 +98329,9 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* HierarchyFacts.SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? + 0 /* HierarchyFacts.StrictModeSourceFileIncludes */ : + 1 /* HierarchyFacts.SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -97908,10 +98352,10 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -97939,10 +98383,10 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name); - var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); + var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* FlattenLevel.ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { block = factory.updateBlock(block, __spreadArray([ @@ -97954,7 +98398,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; var visited = ts.visitEachChild(node, visitor, context); @@ -97980,8 +98424,8 @@ var ts; } function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); @@ -97998,8 +98442,8 @@ var ts; * @param node A ForOfStatement. */ function visitForOfStatement(node, outermostLabeledStatement) { - var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + if (node.initializer.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -98027,7 +98471,7 @@ var ts; } return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), + ], 1 /* NodeFlags.Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), /*multiLine*/ true), bodyLocation)); } return node; @@ -98047,10 +98491,10 @@ var ts; statements.push(statement); } return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), - /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function createDownlevelAwait(expression) { - return enclosingFunctionFlags & 1 /* Generator */ + return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(expression)) : factory.createAwaitExpression(expression); } @@ -98069,18 +98513,18 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 2 /* IterationContainer */ ? + var initializer = ancestorFacts & 2 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) : callValues; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), /*incrementor*/ undefined, /*statement*/ convertForOfStatementHead(node, getValue)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setOriginalNode(forStatement, node); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -98088,15 +98532,15 @@ var ts; factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } function parameterVisitor(node) { @@ -98111,7 +98555,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -98128,7 +98572,7 @@ var ts; if (parameters) { parameters.add(parameter); } - else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { parameters = new ts.Set(); } } @@ -98170,13 +98614,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateMethodDeclaration(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateMethodDeclaration(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifierLike) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98188,13 +98632,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionDeclaration(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionDeclaration(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98218,13 +98662,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98241,13 +98685,13 @@ var ts; capturedSuperProperties = new ts.Set(); hasSuperElementAccess = false; var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */))); + /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */))); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties); @@ -98258,10 +98702,10 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.updateBlock(node.body, statements); if (emitSuperHelpers && hasSuperElementAccess) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -98300,11 +98744,11 @@ var ts; // // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts if (parameter.name.elements.length > 0) { - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)); + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98313,7 +98757,7 @@ var ts; var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); var assignment = factory.createAssignment(name, initializer); var statement = factory.createExpressionStatement(assignment); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98329,32 +98773,32 @@ var ts; // } var name = factory.cloneNode(parameter.name); ts.setTextRange(name, parameter.name); - ts.setEmitFlags(name, 48 /* NoSourceMap */); + ts.setEmitFlags(name, 48 /* EmitFlags.NoSourceMap */); var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); - ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */); + ts.addEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | 1536 /* EmitFlags.NoComments */); var assignment = factory.createAssignment(name, initializer); ts.setTextRange(assignment, parameter); - ts.setEmitFlags(assignment, 1536 /* NoComments */); + ts.setEmitFlags(assignment, 1536 /* EmitFlags.NoComments */); var block = factory.createBlock([factory.createExpressionStatement(assignment)]); ts.setTextRange(block, parameter); - ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined"); var statement = factory.createIfStatement(typeCheck, block); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); statements = ts.append(statements, statement); } } - else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { containsPrecedingObjectRestOrSpread = true; - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter), + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* FlattenLevel.ObjectRest */, factory.getGeneratedNameForNode(parameter), /*doNotRecordTempVariablesInLine*/ false, /*skipInitializer*/ true); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98362,21 +98806,21 @@ var ts; return statements; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -98389,8 +98833,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -98417,30 +98861,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -98460,14 +98904,14 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } @@ -98492,11 +98936,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 64 /* TransformFlags.ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -98524,29 +98968,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 32 /* TransformFlags.ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 221 /* BinaryExpression */: - if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98588,7 +99032,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 206 /* PropertyAccessExpression */ + expression = node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -98611,10 +99055,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 208 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 208 /* SyntaxKind.CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -98623,7 +99067,7 @@ var ts; var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false); var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left; - var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */); + var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); if (!ts.isSimpleCopiableExpression(capturedLeft)) { capturedLeft = factory.createTempVariable(hoistVariableDeclaration); leftExpression = factory.createAssignment(capturedLeft, leftExpression); @@ -98633,8 +99077,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -98644,17 +99088,17 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 206 /* PropertyAccessExpression */ + rightExpression = segment.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (i === 0 && leftThisArg) { if (!ts.isGeneratedIdentifier(leftThisArg)) { leftThisArg = factory.cloneNode(leftThisArg); - ts.addEmitFlags(leftThisArg, 1536 /* NoComments */); + ts.addEmitFlags(leftThisArg, 1536 /* EmitFlags.NoComments */); } - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SyntaxKind.SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -98671,7 +99115,7 @@ var ts; return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target; } function createNotNullCondition(left, right, invert) { - return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* BarBarToken */ : 55 /* AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createVoidZero())); + return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* SyntaxKind.BarBarToken */ : 55 /* SyntaxKind.AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createVoidZero())); } function transformNullishCoalescingExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -98705,11 +99149,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) { + if ((node.transformFlags & 16 /* TransformFlags.ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -98759,7 +99203,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 4 /* TransformFlags.ContainsESNext */) === 0) { return node; } switch (node.kind) { @@ -98783,12 +99227,12 @@ var ts; if (currentFileState.filenameDeclaration) { return currentFileState.filenameDeclaration.name; } - var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); + var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); currentFileState.filenameDeclaration = declaration; return currentFileState.filenameDeclaration.name; } function getJsxFactoryCalleePrimitive(isStaticChildren) { - return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; + return compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; } function getJsxFactoryCallee(isStaticChildren) { var type = getJsxFactoryCalleePrimitive(isStaticChildren); @@ -98814,7 +99258,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); + var generatedName = factory.createUniqueName("_".concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */ | 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */); var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -98836,7 +99280,7 @@ var ts; ts.addEmitHelpers(visited, context.readEmitHelpers()); var statements = visited.statements; if (currentFileState.filenameDeclaration) { - statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */))); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* NodeFlags.Const */))); } if (currentFileState.utilizedImplicitRuntimeImports) { for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { @@ -98853,7 +99297,7 @@ var ts; factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); ts.setParentRecursive(requireStatement, /*incremental*/ false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement); } @@ -98869,7 +99313,7 @@ var ts; return visited; } function visitor(node) { - if (node.transformFlags & 2 /* ContainsJsx */) { + if (node.transformFlags & 2 /* TransformFlags.ContainsJsx */) { return visitorWorker(node); } else { @@ -98878,13 +99322,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98892,15 +99336,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return visitJsxText(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -98969,7 +99413,7 @@ var ts; if (keyAttr) { args.push(transformJsxAttributeInitializer(keyAttr.initializer)); } - if (compilerOptions.jsx === 5 /* ReactJSXDev */) { + if (compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */) { var originalFile = ts.getOriginalNode(currentSourceFile); if (originalFile && ts.isSourceFile(originalFile)) { // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature @@ -99034,7 +99478,7 @@ var ts; } function transformJsxAttributesToObjectProps(attrs, children) { var target = ts.getEmitScriptTarget(compilerOptions); - return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : + return target && target >= 5 /* ScriptTarget.ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : transformJsxAttributesToExpression(attrs, children); } function transformJsxAttributesToProps(attrs, children) { @@ -99074,14 +99518,14 @@ var ts; if (node === undefined) { return factory.createTrue(); } - if (node.kind === 10 /* StringLiteral */) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */) { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - if (node.kind === 288 /* JsxExpression */) { + if (node.kind === 288 /* SyntaxKind.JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -99182,7 +99626,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 278 /* JsxElement */) { + if (node.kind === 278 /* SyntaxKind.JsxElement */) { return getTagName(node.openingElement); } else { @@ -99485,11 +99929,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 512 /* TransformFlags.ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -99497,9 +99941,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 67 /* AsteriskAsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -99689,7 +100133,7 @@ var ts; currentSourceFile = undefined; currentText = undefined; taggedTemplateStringDeclarations = undefined; - hierarchyFacts = 0 /* None */; + hierarchyFacts = 0 /* HierarchyFacts.None */; return visited; } /** @@ -99699,7 +100143,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -99710,15 +100154,15 @@ var ts; * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* HierarchyFacts.SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 247 /* ReturnStatement */ + return (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */) !== 0 + && node.kind === 247 /* SyntaxKind.ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -99733,11 +100177,11 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 1024 /* TransformFlags.ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) + || (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) - || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; + || (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) !== 0; } function visitor(node) { return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node; @@ -99749,9 +100193,9 @@ var ts; if (shouldVisitNode(node)) { var original = ts.getOriginalNode(node); if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) { - var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.StaticInitializerExcludes */, 16449 /* HierarchyFacts.StaticInitializerIncludes */); var result = visitorWorker(node, /*expressionResultIsUnused*/ false); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); return result; } return visitorWorker(node, /*expressionResultIsUnused*/ false); @@ -99759,115 +100203,115 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return undefined; // elide static keyword - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitArrowFunction(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return visitIdentifier(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitVariableDeclarationList(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitBreakOrContinueStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return visitTemplateLiteral(node); - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return visitStringLiteral(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return visitNumericLiteral(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitSpreadElement(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return visitThisKeyword(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitMetaProperty(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(8064 /* HierarchyFacts.SourceFileExcludes */, 64 /* HierarchyFacts.SourceFileIncludes */); var prologue = []; var statements = []; startLexicalEnvironment(); @@ -99878,14 +100322,14 @@ var ts; } factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureThisForNodeIfNeeded(prologue, node); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + convertedLoopState.allowedNonLabeledJumps |= 2 /* Jump.Break */; var result = ts.visitEachChild(node, visitor, context); convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; return result; @@ -99893,17 +100337,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCaseBlock(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function returnCapturedThis(node) { - return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)), node); } function visitReturnStatement(node) { if (convertedLoopState) { - convertedLoopState.nonLocalJumps |= 8 /* Return */; + convertedLoopState.nonLocalJumps |= 8 /* Jump.Return */; if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { node = returnCapturedThis(node); } @@ -99919,11 +100363,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } if (convertedLoopState) { - if (hierarchyFacts & 2 /* ArrowFunction */) { + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */) { // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -99950,30 +100394,30 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 246 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 246 /* SyntaxKind.BreakStatement */ ? 2 /* Jump.Break */ : 4 /* Jump.Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 246 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Jump.Break */; labelMarker = "break"; } else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; + convertedLoopState.nonLocalJumps |= 4 /* Jump.Continue */; // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. labelMarker = "continue"; } } else { - if (node.kind === 246 /* BreakStatement */) { - labelMarker = "break-" + label.escapedText; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } @@ -99982,15 +100426,15 @@ var ts; var outParams = convertedLoopState.loopOutParameters; var expr = void 0; for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + var copyExpr = copyOutParameter(outParams[i], 1 /* CopyDirection.ToOutParameter */); if (i === 0) { expr = copyExpr; } else { - expr = factory.createBinaryExpression(expr, 27 /* CommaToken */, copyExpr); + expr = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, copyExpr); } } - returnExpression = factory.createBinaryExpression(expr, 27 /* CommaToken */, returnExpression); + returnExpression = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, returnExpression); } return factory.createReturnStatement(returnExpression); } @@ -100023,18 +100467,18 @@ var ts; ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - var exportStatement = ts.hasSyntacticModifier(node, 512 /* Default */) + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + var exportStatement = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? factory.createExportDefault(factory.getLocalName(node)) : factory.createExternalModuleExport(factory.getLocalName(node)); ts.setOriginalNode(exportStatement, statement); statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -100091,25 +100535,25 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */))] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* Indented */) | 524288 /* ReuseTempVariableScope */); + ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */) | 524288 /* EmitFlags.ReuseTempVariableScope */); // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = factory.createPartiallyEmittedExpression(classFunction); ts.setTextRangeEnd(inner, node.end); - ts.setEmitFlags(inner, 1536 /* NoComments */); + ts.setEmitFlags(inner, 1536 /* EmitFlags.NoComments */); var outer = factory.createPartiallyEmittedExpression(inner); ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos)); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); - ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + ts.addSyntheticLeadingComment(result, 3 /* SyntaxKind.MultiLineCommentTrivia */, "* @class "); return result; } /** @@ -100127,19 +100571,19 @@ var ts; addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(constructorLikeName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -100165,7 +100609,7 @@ var ts; function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); + var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = factory.createFunctionDeclaration( @@ -100175,10 +100619,10 @@ var ts; /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); + ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; } /** @@ -100212,7 +100656,7 @@ var ts; ts.setTextRange(statementsArray, node.members); var block = factory.createBlock(statementsArray, /*multiLine*/ true); ts.setTextRange(block, node); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -100227,7 +100671,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -100271,7 +100715,7 @@ var ts; superCallExpression = visitSuperCallInBody(superCall); } if (superCallExpression) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + hierarchyFacts |= 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */; } // Add parameter defaults at the beginning of the output, with prologue statements addDefaultValueAssignmentsIfNeeded(prologue, constructor); @@ -100281,7 +100725,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) { + if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -100304,7 +100748,7 @@ var ts; var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1)); - ts.setEmitFlags(superCall_1, 1536 /* NoComments */); + ts.setEmitFlags(superCall_1, 1536 /* EmitFlags.NoComments */); statements.push(returnStatement); } else { @@ -100343,7 +100787,7 @@ var ts; } } if (!isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))); } } } @@ -100393,11 +100837,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 247 /* ReturnStatement */) { + if (statement.kind === 247 /* SyntaxKind.ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 239 /* IfStatement */) { + else if (statement.kind === 239 /* SyntaxKind.IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -100405,7 +100849,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 235 /* Block */) { + else if (statement.kind === 235 /* SyntaxKind.Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -100414,10 +100858,10 @@ var ts; return false; } function createActualThis() { - return ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */); + return ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */); } function createDefaultSuperCallOrThis() { - return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); + return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -100504,11 +100948,11 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } else if (initializer) { - ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } return false; @@ -100526,11 +100970,11 @@ var ts; var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment( // TODO(rbuckton): Does this need to be parented? - ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); + ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); ts.insertStatementAfterCustomPrologue(statements, statement); } /** @@ -100561,10 +101005,10 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. // TODO(rbuckton): Does this need to be parented? - var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); - ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); + var declarationName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + ts.setEmitFlags(declarationName, 48 /* EmitFlags.NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -100574,7 +101018,7 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, factory.createArrayLiteralExpression([])) ])), - /*location*/ parameter), 1048576 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* EmitFlags.CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -100586,13 +101030,13 @@ var ts; : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* EmitFlags.CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 79 /* Identifier */) { + if (parameter.name.kind !== 79 /* SyntaxKind.Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, expressionName))), parameter), 1048576 /* EmitFlags.CustomPrologue */)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; @@ -100605,7 +101049,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 214 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* HierarchyFacts.CapturedLexicalThis */ && node.kind !== 214 /* SyntaxKind.ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -100619,7 +101063,7 @@ var ts; */ function insertSuperThisCaptureThisForNode(statements, superExpression) { enableSubstitutionsForCapturedThis(); - var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression)); + var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* SyntaxKind.EqualsToken */, superExpression)); ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression); ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent); } @@ -100627,38 +101071,38 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); ts.setSourceMapRange(captureThisStatement, node); ts.insertStatementAfterCustomPrologue(statements, captureThisStatement); } function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { - if (hierarchyFacts & 32768 /* NewTarget */) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return statements; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. - newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); + newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), - /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"), + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), 102 /* SyntaxKind.InstanceOfKeyword */, factory.getLocalName(node))), + /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"), /*colonToken*/ undefined, factory.createVoidZero()); break; default: @@ -100666,11 +101110,11 @@ var ts; } var captureNewTargetStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, newTarget) ])); - ts.setEmitFlags(captureNewTargetStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureNewTargetStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); if (copyOnWrite) { statements = statements.slice(); } @@ -100689,21 +101133,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -100742,7 +101186,7 @@ var ts; var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, /*location*/ member.name); e = factory.createAssignment(memberName, memberFunction); } - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); + ts.setEmitFlags(memberFunction, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.setTextRange(factory.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); @@ -100750,7 +101194,7 @@ var ts; // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 48 /* NoSourceMap */); + ts.setEmitFlags(statement, 48 /* EmitFlags.NoSourceMap */); return statement; } /** @@ -100764,7 +101208,7 @@ var ts; // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } @@ -100780,20 +101224,20 @@ var ts; // arguments are both mapped contiguously to the accessor name. // TODO(rbuckton): Does this need to be parented? var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(target, 1536 /* EmitFlags.NoComments */ | 32 /* EmitFlags.NoTrailingSourceMap */); ts.setSourceMapRange(target, firstAccessor.name); var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName); if (ts.isPrivateIdentifier(visitedAccessorName)) { return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015."); } var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 16 /* EmitFlags.NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(getterFunction, 512 /* EmitFlags.NoLeadingComments */); var getter = factory.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -100801,7 +101245,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(setterFunction, 512 /* EmitFlags.NoLeadingComments */); var setter = factory.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -100824,12 +101268,12 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (node.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); + var ancestorFacts = enterSubtree(15232 /* HierarchyFacts.ArrowFunctionExcludes */, 66 /* HierarchyFacts.ArrowFunctionIncludes */); var func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -100838,9 +101282,9 @@ var ts; /*type*/ undefined, transformFunctionBody(node)); ts.setTextRange(func, node); ts.setOriginalNode(func, node); - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); // If an arrow function contains - exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.ArrowFunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return func; } @@ -100850,17 +101294,17 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ - ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */ + ? enterSubtree(32662 /* HierarchyFacts.AsyncFunctionBodyExcludes */, 69 /* HierarchyFacts.AsyncFunctionBodyIncludes */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionExpression(node, /*modifiers*/ undefined, node.asteriskToken, name, @@ -100875,13 +101319,13 @@ var ts; function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, /*typeParameters*/ undefined, parameters, @@ -100898,14 +101342,14 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node) - ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + ? enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */ | 8 /* HierarchyFacts.NonStaticClassElement */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ && !name && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, @@ -100948,7 +101392,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 214 /* ArrowFunction */); + ts.Debug.assert(node.kind === 214 /* SyntaxKind.ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -100967,7 +101411,7 @@ var ts; var returnStatement = factory.createReturnStatement(expression); ts.setTextRange(returnStatement, body); ts.moveSyntheticComments(returnStatement, body); - ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1024 /* EmitFlags.NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -100988,10 +101432,10 @@ var ts; var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine); ts.setTextRange(block, node.body); if (!multiLine && singleLine) { - ts.setEmitFlags(block, 1 /* SingleLine */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* SyntaxKind.CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -101001,11 +101445,11 @@ var ts; // A function body is not a block scope. return ts.visitEachChild(node, visitor, context); } - var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ - ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) - : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */); + var ancestorFacts = hierarchyFacts & 256 /* HierarchyFacts.IterationStatement */ + ? enterSubtree(7104 /* HierarchyFacts.IterationStatementBlockExcludes */, 512 /* HierarchyFacts.IterationStatementBlockIncludes */) + : enterSubtree(6976 /* HierarchyFacts.BlockExcludes */, 128 /* HierarchyFacts.BlockIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -101036,9 +101480,9 @@ var ts; function visitBinaryExpression(node, expressionResultIsUnused) { // If we are here it is because this is a destructuring assignment. if (ts.isDestructuringAssignment(node)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -101066,12 +101510,12 @@ var ts; function isVariableStatementOfTypeScriptClassWrapper(node) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer - && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */); + && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* EmitFlags.TypeScriptClassWrapper */); } function visitVariableStatement(node) { - var ancestorFacts = enterSubtree(0 /* None */, ts.hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.None */, ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? 32 /* HierarchyFacts.ExportedVariableStatement */ : 0 /* HierarchyFacts.None */); var updated; - if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { + if (convertedLoopState && (node.declarationList.flags & 3 /* NodeFlags.BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -101080,10 +101524,10 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); + assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* FlattenLevel.All */); } else { - assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -101100,7 +101544,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -101109,11 +101553,11 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) { - if (node.flags & 3 /* BlockScoped */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */ || node.transformFlags & 524288 /* TransformFlags.ContainsBindingPattern */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var declarations = ts.flatMap(node.declarations, node.flags & 1 /* Let */ + var declarations = ts.flatMap(node.declarations, node.flags & 1 /* NodeFlags.Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration); var declarationList = factory.createVariableDeclarationList(declarations); @@ -101122,7 +101566,7 @@ var ts; ts.setCommentRange(declarationList, node); // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. - if (node.transformFlags & 524288 /* ContainsBindingPattern */ + if (node.transformFlags & 524288 /* TransformFlags.ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -101188,18 +101632,18 @@ var ts; // * Why loop initializer is excluded? // - Since we've introduced a fresh name it already will be undefined. var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 262144 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 524288 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 + var isCapturedInFunction = flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + var emittedAsTopLevel = (hierarchyFacts & 64 /* HierarchyFacts.TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); + && (hierarchyFacts & 512 /* HierarchyFacts.IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0 + && (hierarchyFacts & 4096 /* HierarchyFacts.ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0)); + && (hierarchyFacts & (2048 /* HierarchyFacts.ForStatement */ | 4096 /* HierarchyFacts.ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -101226,16 +101670,16 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var ancestorFacts = enterSubtree(32 /* HierarchyFacts.ExportedVariableStatement */, 0 /* HierarchyFacts.None */); var updated; if (ts.isBindingPattern(node.name)) { - updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* FlattenLevel.All */, + /*value*/ undefined, (ancestorFacts & 32 /* HierarchyFacts.ExportedVariableStatement */) !== 0); } else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function recordLabel(node) { @@ -101255,50 +101699,50 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function visitDoOrWhileStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(0 /* HierarchyFacts.DoOrWhileStatementExcludes */, 1280 /* HierarchyFacts.DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } function visitForStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(5056 /* HierarchyFacts.ForStatementExcludes */, 3328 /* HierarchyFacts.ForStatementIncludes */, node, outermostLabeledStatement); } function visitEachChildOfForStatement(node) { return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); } function visitForInStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; var initializer = node.initializer; if (ts.isVariableDeclarationList(initializer)) { - if (node.initializer.flags & 3 /* BlockScoped */) { + if (node.initializer.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* FlattenLevel.All */, boundValue); var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old @@ -101346,7 +101790,7 @@ var ts; } function createSyntheticBlockForConvertedStatements(statements) { return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), - /*multiLine*/ true), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: @@ -101378,18 +101822,18 @@ var ts; var counter = factory.createLoopVariable(); var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); + ts.setEmitFlags(expression, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(expression)); var forStatement = ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(counter, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(factory.createVariableDeclaration(rhsReference, /*exclamationToken*/ undefined, /*type*/ undefined, expression), node.expression) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression), /*incrementor*/ ts.setTextRange(factory.createPostfixIncrement(counter), node.expression), /*statement*/ convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)), /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } @@ -101405,33 +101849,33 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 1024 /* IterationContainer */ + var initializer = ancestorFacts & 1024 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values]) : values; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result, /*exclamationToken*/ undefined, /*type*/ undefined, next) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), /*incrementor*/ factory.createAssignment(result, next), /*statement*/ convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([ factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* EmitFlags.SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } /** @@ -101446,9 +101890,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 1048576 /* ContainsYield */ && - hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) { + if ((property.transformFlags & 1048576 /* TransformFlags.ContainsYield */ && + hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* SyntaxKind.ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -101461,7 +101905,7 @@ var ts; var temp = factory.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* Indented */ : 0)); + var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* EmitFlags.Indented */ : 0)); if (node.multiLine) { ts.startOnNewLine(assignment); } @@ -101473,7 +101917,7 @@ var ts; return factory.inlineExpressions(expressions); } function shouldConvertPartOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 131072 /* ContainsCapturedBlockScopeBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */) !== 0; } function shouldConvertInitializerOfForStatement(node) { return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer); @@ -101489,7 +101933,7 @@ var ts; || shouldConvertInitializerOfForStatement(node); } function shouldConvertBodyOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */) !== 0; } /** * Records constituents of name for the given variable to be hoisted in the outer scope. @@ -101500,7 +101944,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -101520,7 +101964,7 @@ var ts; // we get here if we are trying to emit normal loop loop inside converted loop // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + convertedLoopState.allowedNonLabeledJumps = 2 /* Jump.Break */ | 4 /* Jump.Continue */; } var result = convert ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts) @@ -101564,11 +102008,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 242 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 243 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 244 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 240 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 241 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 242 /* SyntaxKind.ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 243 /* SyntaxKind.ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 244 /* SyntaxKind.ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 240 /* SyntaxKind.DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 241 /* SyntaxKind.WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -101593,11 +102037,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -101606,7 +102050,7 @@ var ts; var loopParameters = []; // variables declared in the loop initializer that will be changed inside the loop var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) { var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) || shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node); @@ -101719,15 +102163,15 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0; - var emitFlags = 0 /* None */; + var containsYield = (node.initializer.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 0 /* EmitFlags.None */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && hierarchyFacts & 4 /* AsyncFunctionBody */) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; var statements = []; statements.push(factory.createVariableStatement(/*modifiers*/ undefined, node.initializer)); - copyOutParameters(currentState.loopOutParameters, 2 /* Initializer */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 2 /* LoopOutParameterFlags.Initializer */, 1 /* CopyDirection.ToOutParameter */, statements); // This transforms the following ES2015 syntax: // // for (let i = (setImmediate(() => console.log(i)), 0); i < 2; i++) { @@ -101753,12 +102197,12 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, ts.visitNode(factory.createBlock(statements, /*multiLine*/ true), visitor, ts.isBlock)), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } @@ -101820,7 +102264,7 @@ var ts; statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue())))); } if (shouldConvertConditionOfForStatement(node)) { - statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); + statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -101829,17 +102273,17 @@ var ts; else { statements.push(statement); } - copyOutParameters(currentState.loopOutParameters, 1 /* Body */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 1 /* CopyDirection.ToOutParameter */, statements); ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment); var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0; - var emitFlags = 524288 /* ReuseTempVariableScope */; + var containsYield = (node.statement.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 524288 /* EmitFlags.ReuseTempVariableScope */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && (hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) !== 0) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; // This transforms the following ES2015 syntax (in addition to other variations): // // for (let i = 0; i < 2; i++) { @@ -101859,18 +102303,18 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); + var source = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.originalName : outParam.outParamName; + return factory.createBinaryExpression(target, 63 /* SyntaxKind.EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -101883,7 +102327,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = factory.createCallExpression(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; return factory.createExpressionStatement(callResult); } @@ -101892,27 +102336,27 @@ var ts; // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop // simple loops are emitted as just 'loop()'; // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Jump.Continue */) && !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = factory.createCallExpression(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; if (isSimpleLoop) { statements.push(factory.createExpressionStatement(callResult)); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); } else { var loopResultName = factory.createUniqueName("state"); var stateVariable = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, /*exclamationToken*/ undefined, /*type*/ undefined, callResult)])); statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Jump.Return */) { var returnStatement = void 0; if (outerState) { - outerState.nonLocalJumps |= 8 /* Return */; + outerState.nonLocalJumps |= 8 /* Jump.Return */; returnStatement = factory.createReturnStatement(loopResultName); } else { @@ -101920,7 +102364,7 @@ var ts; } statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement)); } - if (state.nonLocalJumps & 2 /* Break */) { + if (state.nonLocalJumps & 2 /* Jump.Break */) { statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { @@ -101979,19 +102423,19 @@ var ts; else { loopParameters.push(factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); var checkFlags = resolver.getNodeCheckFlags(decl); - if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { var outParamName = factory.createUniqueName("out_" + ts.idText(name)); var flags = 0; - if (checkFlags & 4194304 /* NeedsLoopOutParameter */) { - flags |= 1 /* Body */; + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */) { + flags |= 1 /* LoopOutParameterFlags.Body */; } if (ts.isForStatement(container)) { if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) { - flags |= 2 /* Initializer */; + flags |= 2 /* LoopOutParameterFlags.Initializer */; } if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) || container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) { - flags |= 1 /* Body */; + flags |= 1 /* LoopOutParameterFlags.Body */; } } loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName }); @@ -102013,20 +102457,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -102081,14 +102525,14 @@ var ts; return expression; } function visitCatchClause(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated; ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = factory.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* FlattenLevel.All */, temp); var list = factory.createVariableDeclarationList(vars); ts.setTextRange(list, node.variableDeclaration); var destructure = factory.createVariableStatement(/*modifiers*/ undefined, list); @@ -102097,7 +102541,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function addStatementToStartOfBlock(block, statement) { @@ -102116,7 +102560,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); - ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 512 /* EmitFlags.NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } @@ -102129,17 +102573,17 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.modifiers, node.name, parameters, node.type, body); } else { updated = factory.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -102182,11 +102626,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { + if (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 106 /* SuperKeyword */ || + if (expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -102259,7 +102703,7 @@ var ts; // }()) // var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); - if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) { + if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression); } // The underlying call (3) is another IIFE that may contain a '_super' argument. @@ -102316,15 +102760,15 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. - if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || - node.expression.kind === 106 /* SuperKeyword */ || + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */ || + node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 106 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + ts.setEmitFlags(thisArg, 4 /* EmitFlags.NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 32768 /* ContainsRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -102338,7 +102782,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -102350,12 +102794,12 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); + resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis - ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) + ? factory.createAssignment(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), initializer) : initializer; } return ts.setOriginalNode(resultingCall, node); @@ -102444,13 +102888,13 @@ var ts; } } var helpers = emitHelpers(); - var startsWithSpread = segments[0].kind !== 0 /* None */; + var startsWithSpread = segments[0].kind !== 0 /* SpreadSegmentKind.None */; var expression = startsWithSpread ? factory.createArrayLiteralExpression() : segments[0].expression; for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) { var segment = segments[i]; // If this is for an argument list, it doesn't matter if the array is packed or sparse - expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList); + expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !isArgumentList); } return expression; } @@ -102466,12 +102910,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); // We don't need to pack already packed array literals, or existing calls to the `__read` helper. var isCallToReadHelper = ts.isCallToHelper(expression, "___read"); - var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */; + var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* SpreadSegmentKind.PackedSpread */ : 1 /* SpreadSegmentKind.UnpackedSpread */; // We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`. - if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { + if (compilerOptions.downlevelIteration && kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { expression = emitHelpers().createReadHelper(expression, /*count*/ undefined); // the `__read` helper returns a packed array, so we don't need to ensure a packed array - kind = 2 /* PackedSpread */; + kind = 2 /* SpreadSegmentKind.PackedSpread */; } return createSpreadSegment(kind, expression); } @@ -102479,7 +102923,7 @@ var ts; var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); // We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to // `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements` - return createSpreadSegment(0 /* None */, expression); + return createSpreadSegment(0 /* SpreadSegmentKind.None */, expression); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -102509,7 +102953,7 @@ var ts; * @param node A string literal. */ function visitNumericLiteral(node) { - if (node.numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) { + if (node.numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { return ts.setTextRange(factory.createNumericLiteral(node.text), node); } return node; @@ -102544,15 +102988,15 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ + return hierarchyFacts & 8 /* HierarchyFacts.NonStaticClassElement */ && !isExpressionOfCall - ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") - : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), "prototype") + : factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { - hierarchyFacts |= 32768 /* NewTarget */; - return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */ && node.name.escapedText === "target") { + hierarchyFacts |= 32768 /* HierarchyFacts.NewTarget */; + return factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } return node; } @@ -102564,13 +103008,13 @@ var ts; * @param emitCallback The callback used to emit the node. */ function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ - ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ - : 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, ts.getEmitFlags(node) & 8 /* EmitFlags.CapturesThis */ + ? 65 /* HierarchyFacts.FunctionIncludes */ | 16 /* HierarchyFacts.CapturesThis */ + : 65 /* HierarchyFacts.FunctionIncludes */); previousOnEmitNode(hint, node, emitCallback); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return; } previousOnEmitNode(hint, node, emitCallback); @@ -102580,9 +103024,9 @@ var ts; * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* ES2015SubstitutionFlags.BlockScopedBindings */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } /** @@ -102590,16 +103034,16 @@ var ts; * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(108 /* ThisKeyword */); - context.enableEmitNotification(171 /* Constructor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(214 /* ArrowFunction */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(256 /* FunctionDeclaration */); + if ((enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* ES2015SubstitutionFlags.CapturedThis */; + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(214 /* SyntaxKind.ArrowFunction */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); } } /** @@ -102610,7 +103054,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -102624,7 +103068,7 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return ts.setTextRange(factory.getGeneratedNameForNode(original), node); @@ -102640,10 +103084,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -102656,9 +103100,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -102669,7 +103113,7 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node); @@ -102706,9 +103150,9 @@ var ts; * @param node The ThisKeyword node. */ function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && hierarchyFacts & 16 /* CapturesThis */) { - return ts.setTextRange(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ + && hierarchyFacts & 16 /* HierarchyFacts.CapturesThis */) { + return ts.setTextRange(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node); } return node; } @@ -102725,19 +103169,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* SyntaxKind.ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SyntaxKind.SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SyntaxKind.SpreadElement */) { return false; } var expression = callArgument.expression; @@ -102760,18 +103204,18 @@ var ts; // enable emit notification only if using --jsx preserve or react-native var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + if (compilerOptions.jsx === 1 /* JsxEmit.Preserve */ || compilerOptions.jsx === 3 /* JsxEmit.ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(280 /* JsxOpeningElement */); - context.enableEmitNotification(281 /* JsxClosingElement */); - context.enableEmitNotification(279 /* JsxSelfClosingElement */); + context.enableEmitNotification(280 /* SyntaxKind.JsxOpeningElement */); + context.enableEmitNotification(281 /* SyntaxKind.JsxClosingElement */); + context.enableEmitNotification(279 /* SyntaxKind.JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(296 /* PropertyAssignment */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(296 /* SyntaxKind.PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -102790,9 +103234,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -102852,7 +103296,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -103032,11 +103476,11 @@ var ts; })(Instruction || (Instruction = {})); function getInstructionName(instruction) { switch (instruction) { - case 2 /* Return */: return "return"; - case 3 /* Break */: return "break"; - case 4 /* Yield */: return "yield"; - case 5 /* YieldStar */: return "yield*"; - case 7 /* Endfinally */: return "endfinally"; + case 2 /* Instruction.Return */: return "return"; + case 3 /* Instruction.Break */: return "break"; + case 4 /* Instruction.Yield */: return "yield"; + case 5 /* Instruction.YieldStar */: return "yield*"; + case 7 /* Instruction.Endfinally */: return "endfinally"; default: return undefined; // TODO: GH#18217 } } @@ -103090,7 +103534,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 2048 /* TransformFlags.ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -103113,7 +103557,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 2048 /* ContainsGenerator */) { + else if (transformFlags & 2048 /* TransformFlags.ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -103127,13 +103571,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -103146,30 +103590,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitBreakStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 1048576 /* ContainsYield */) { + if (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (2048 /* TransformFlags.ContainsGenerator */ | 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -103184,23 +103628,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitConditionalExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -103213,9 +103657,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -103373,13 +103817,13 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 1048576 /* ContainsYield */) { + if (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -103404,9 +103848,9 @@ var ts; function visitBinaryExpression(node) { var assoc = ts.getExpressionAssociativity(node); switch (assoc) { - case 0 /* Left */: + case 0 /* Associativity.Left */: return visitLeftAssociativeBinaryExpression(node); - case 1 /* Right */: + case 1 /* Associativity.Right */: return visitRightAssociativeBinaryExpression(node); default: return ts.Debug.assertNever(assoc); @@ -103422,7 +103866,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // [source] // a.b = yield; // @@ -103434,7 +103878,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // [source] // a[b] = yield; // @@ -103466,7 +103910,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 27 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return visitCommaExpression(node); } // [source] @@ -103500,13 +103944,13 @@ var ts; visit(node.right); return factory.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { visit(node.left); visit(node.right); } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -103523,12 +103967,12 @@ var ts; var pendingExpressions = []; for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var elem = _a[_i]; - if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { pendingExpressions.push(visitCommaExpression(elem)); } else { if (containsYield(elem) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression)); @@ -103573,7 +104017,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -103639,7 +104083,7 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { // NOTE: `expression` must be defined for `yield*`. - var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* EmitFlags.Iterator */) === 0 ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node) : expression; emitYieldStar(iterator, /*location*/ node); @@ -103828,35 +104272,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return transformAndEmitBlock(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return transformAndEmitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return transformAndEmitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return transformAndEmitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return transformAndEmitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return transformAndEmitForInStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return transformAndEmitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return transformAndEmitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return transformAndEmitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return transformAndEmitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return transformAndEmitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -104286,7 +104730,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 290 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -104299,7 +104743,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -104431,7 +104875,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -104444,7 +104888,7 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; @@ -104475,7 +104919,7 @@ var ts; return node; } function cacheExpression(node) { - if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return node; } var temp = factory.createTempVariable(hoistVariableDeclaration); @@ -104521,7 +104965,7 @@ var ts; blockStack = []; } var index = blockActions.length; - blockActions[index] = 0 /* Open */; + blockActions[index] = 0 /* BlockAction.Open */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.push(block); @@ -104535,7 +104979,7 @@ var ts; if (block === undefined) return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; - blockActions[index] = 1 /* Close */; + blockActions[index] = 1 /* BlockAction.Close */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.pop(); @@ -104564,7 +105008,7 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 1 /* With */, + kind: 1 /* CodeBlockKind.With */, expression: expression, startLabel: startLabel, endLabel: endLabel @@ -104574,7 +105018,7 @@ var ts; * Ends a code block for a generated `with` statement. */ function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); + ts.Debug.assert(peekBlockKind() === 1 /* CodeBlockKind.With */); var block = endBlock(); markLabel(block.endLabel); } @@ -104586,8 +105030,8 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, + kind: 0 /* CodeBlockKind.Exception */, + state: 0 /* ExceptionBlockState.Try */, startLabel: startLabel, endLabel: endLabel }); @@ -104600,7 +105044,7 @@ var ts; * @param variable The catch variable. */ function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); // generated identifiers should already be unique within a file var name; if (ts.isGeneratedIdentifier(variable.name)) { @@ -104613,18 +105057,18 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); + ts.Debug.assert(exception.state < 1 /* ExceptionBlockState.Catch */); var endLabel = exception.endLabel; emitBreak(endLabel); var catchLabel = defineLabel(); markLabel(catchLabel); - exception.state = 1 /* Catch */; + exception.state = 1 /* ExceptionBlockState.Catch */; exception.catchVariable = name; exception.catchLabel = catchLabel; emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), /*typeArguments*/ undefined, [])); @@ -104634,24 +105078,24 @@ var ts; * Enters the `finally` block of a generated `try` statement. */ function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); + ts.Debug.assert(exception.state < 2 /* ExceptionBlockState.Finally */); var endLabel = exception.endLabel; emitBreak(endLabel); var finallyLabel = defineLabel(); markLabel(finallyLabel); - exception.state = 2 /* Finally */; + exception.state = 2 /* ExceptionBlockState.Finally */; exception.finallyLabel = finallyLabel; } /** * Ends the code block for a generated `try` statement. */ function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = endBlock(); var state = exception.state; - if (state < 2 /* Finally */) { + if (state < 2 /* ExceptionBlockState.Finally */) { emitBreak(exception.endLabel); } else { @@ -104659,7 +105103,7 @@ var ts; } markLabel(exception.endLabel); emitNop(); - exception.state = 3 /* Done */; + exception.state = 3 /* ExceptionBlockState.Done */; } /** * Begins a code block that supports `break` or `continue` statements that are defined in @@ -104669,7 +105113,7 @@ var ts; */ function beginScriptLoopBlock() { beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: true, breakLabel: -1, continueLabel: -1 @@ -104686,7 +105130,7 @@ var ts; function beginLoopBlock(continueLabel) { var breakLabel = defineLabel(); beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: false, breakLabel: breakLabel, continueLabel: continueLabel, @@ -104698,7 +105142,7 @@ var ts; * generated code or in the source tree. */ function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + ts.Debug.assert(peekBlockKind() === 3 /* CodeBlockKind.Loop */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -104712,7 +105156,7 @@ var ts; */ function beginScriptSwitchBlock() { beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: true, breakLabel: -1 }); @@ -104725,7 +105169,7 @@ var ts; function beginSwitchBlock() { var breakLabel = defineLabel(); beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: false, breakLabel: breakLabel, }); @@ -104735,7 +105179,7 @@ var ts; * Ends a code block that supports `break` statements that are defined in generated code. */ function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + ts.Debug.assert(peekBlockKind() === 2 /* CodeBlockKind.Switch */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -104744,7 +105188,7 @@ var ts; } function beginScriptLabeledBlock(labelText) { beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: true, labelText: labelText, breakLabel: -1 @@ -104753,14 +105197,14 @@ var ts; function beginLabeledBlock(labelText) { var breakLabel = defineLabel(); beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: false, labelText: labelText, breakLabel: breakLabel }); } function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + ts.Debug.assert(peekBlockKind() === 4 /* CodeBlockKind.Labeled */); var block = endBlock(); if (!block.isScript) { markLabel(block.breakLabel); @@ -104772,8 +105216,8 @@ var ts; * @param block A code block. */ function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; + return block.kind === 2 /* CodeBlockKind.Switch */ + || block.kind === 3 /* CodeBlockKind.Loop */; } /** * Indicates whether the provided block supports `break` statements with labels. @@ -104781,7 +105225,7 @@ var ts; * @param block A code block. */ function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; + return block.kind === 4 /* CodeBlockKind.Labeled */; } /** * Indicates whether the provided block supports `continue` statements. @@ -104789,7 +105233,7 @@ var ts; * @param block A code block. */ function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; + return block.kind === 3 /* CodeBlockKind.Loop */; } function hasImmediateContainingLabeledBlock(labelText, start) { for (var j = start; j >= 0; j--) { @@ -104886,7 +105330,7 @@ var ts; */ function createInstruction(instruction) { var literal = factory.createNumericLiteral(instruction); - ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); + ts.addSyntheticTrailingComment(literal, 3 /* SyntaxKind.MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -104898,7 +105342,7 @@ var ts; function createInlineBreak(label, location) { ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) ])), location); } @@ -104910,8 +105354,8 @@ var ts; */ function createInlineReturn(expression, location) { return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), location); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. @@ -104924,7 +105368,7 @@ var ts; * Emits an empty instruction. */ function emitNop() { - emitWorker(0 /* Nop */); + emitWorker(0 /* OpCode.Nop */); } /** * Emits a Statement. @@ -104933,7 +105377,7 @@ var ts; */ function emitStatement(node) { if (node) { - emitWorker(1 /* Statement */, [node]); + emitWorker(1 /* OpCode.Statement */, [node]); } else { emitNop(); @@ -104947,7 +105391,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); + emitWorker(2 /* OpCode.Assign */, [left, right], location); } /** * Emits a Break operation to the specified label. @@ -104956,7 +105400,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); + emitWorker(3 /* OpCode.Break */, [label], location); } /** * Emits a Break operation to the specified label when a condition evaluates to a truthy @@ -104967,7 +105411,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + emitWorker(4 /* OpCode.BreakWhenTrue */, [label, condition], location); } /** * Emits a Break to the specified label when a condition evaluates to a falsey value at @@ -104978,7 +105422,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + emitWorker(5 /* OpCode.BreakWhenFalse */, [label, condition], location); } /** * Emits a YieldStar operation for the provided expression. @@ -104987,7 +105431,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + emitWorker(7 /* OpCode.YieldStar */, [expression], location); } /** * Emits a Yield operation for the provided expression. @@ -104996,7 +105440,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + emitWorker(6 /* OpCode.Yield */, [expression], location); } /** * Emits a Return operation for the provided expression. @@ -105005,7 +105449,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + emitWorker(8 /* OpCode.Return */, [expression], location); } /** * Emits a Throw operation for the provided expression. @@ -105014,13 +105458,13 @@ var ts; * @param location An optional source map location for the assignment. */ function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + emitWorker(9 /* OpCode.Throw */, [expression], location); } /** * Emits an Endfinally operation. This is used to handle `finally` block semantics. */ function emitEndfinally() { - emitWorker(10 /* Endfinally */); + emitWorker(10 /* OpCode.Endfinally */); } /** * Emits an operation. @@ -105064,7 +105508,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, factory.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* EmitFlags.ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -105237,8 +105681,8 @@ var ts; var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; switch (block.kind) { - case 0 /* Exception */: - if (blockAction === 0 /* Open */) { + case 0 /* CodeBlockKind.Exception */: + if (blockAction === 0 /* BlockAction.Open */) { if (!exceptionBlockStack) { exceptionBlockStack = []; } @@ -105248,18 +105692,18 @@ var ts; exceptionBlockStack.push(currentExceptionBlock); currentExceptionBlock = block; } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { currentExceptionBlock = exceptionBlockStack.pop(); } break; - case 1 /* With */: - if (blockAction === 0 /* Open */) { + case 1 /* CodeBlockKind.With */: + if (blockAction === 0 /* BlockAction.Open */) { if (!withBlockStack) { withBlockStack = []; } withBlockStack.push(block); } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { withBlockStack.pop(); } break; @@ -105283,33 +105727,33 @@ var ts; lastOperationWasAbrupt = false; lastOperationWasCompletion = false; var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { + if (opcode === 0 /* OpCode.Nop */) { return; } - else if (opcode === 10 /* Endfinally */) { + else if (opcode === 10 /* OpCode.Endfinally */) { return writeEndfinally(); } var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { + if (opcode === 1 /* OpCode.Statement */) { return writeStatement(args[0]); } var location = operationLocations[operationIndex]; switch (opcode) { - case 2 /* Assign */: + case 2 /* OpCode.Assign */: return writeAssign(args[0], args[1], location); - case 3 /* Break */: + case 3 /* OpCode.Break */: return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: + case 4 /* OpCode.BreakWhenTrue */: return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: + case 5 /* OpCode.BreakWhenFalse */: return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: + case 6 /* OpCode.Yield */: return writeYield(args[0], location); - case 7 /* YieldStar */: + case 7 /* OpCode.YieldStar */: return writeYieldStar(args[0], location); - case 8 /* Return */: + case 8 /* OpCode.Return */: return writeReturn(args[0], location); - case 9 /* Throw */: + case 9 /* OpCode.Throw */: return writeThrow(args[0], location); } } @@ -105359,8 +105803,8 @@ var ts; lastOperationWasAbrupt = true; lastOperationWasCompletion = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -105371,9 +105815,9 @@ var ts; function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -105384,9 +105828,9 @@ var ts; */ function writeBreakWhenTrue(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -105397,9 +105841,9 @@ var ts; */ function writeBreakWhenFalse(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -105410,8 +105854,8 @@ var ts; function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(4 /* Instruction.Yield */), expression] + : [createInstruction(4 /* Instruction.Yield */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -105422,9 +105866,9 @@ var ts; function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(5 /* YieldStar */), + createInstruction(5 /* Instruction.YieldStar */), expression - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -105432,7 +105876,7 @@ var ts; function writeEndfinally() { lastOperationWasAbrupt = true; writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(7 /* Endfinally */) + createInstruction(7 /* Instruction.Endfinally */) ]))); } } @@ -105459,12 +105903,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(208 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(210 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -105480,7 +105924,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 8388608 /* ContainsDynamicImport */ || + node.transformFlags & 8388608 /* TransformFlags.ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -105616,7 +106060,7 @@ var ts; factory.createIdentifier("exports") ])) ]), - ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* EmitFlags.SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ @@ -105701,7 +106145,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } @@ -105770,13 +106214,13 @@ var ts; if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); statements.push(statement); } } @@ -105792,23 +106236,23 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -105817,30 +106261,30 @@ var ts; function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (8388608 /* TransformFlags.ContainsDynamicImport */ | 4096 /* TransformFlags.ContainsDestructuringAssignment */ | 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -105856,24 +106300,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -105899,7 +106343,7 @@ var ts; } function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded, createAllExportExpressions); } return ts.visitEachChild(node, visitor, context); } @@ -105925,7 +106369,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -105968,7 +106412,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -105995,7 +106439,7 @@ var ts; // }); needUMDDynamicImportHelper = true; if (ts.isSimpleCopiableExpression(arg)) { - var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */); + var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* EmitFlags.NoComments */); return factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, @@ -106031,7 +106475,7 @@ var ts; /*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) ]); var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, parameters, @@ -106049,7 +106493,7 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); @@ -106070,7 +106514,7 @@ var ts; requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, @@ -106090,13 +106534,13 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { @@ -106105,7 +106549,7 @@ var ts; return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { @@ -106152,7 +106596,7 @@ var ts; } } statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), /*location*/ node), /*original*/ node)); } @@ -106166,7 +106610,7 @@ var ts; /*type*/ undefined, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) - ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + ], languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */))); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -106200,7 +106644,7 @@ var ts; ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)); } else { @@ -106210,11 +106654,11 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); } } else { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node)); } } @@ -106255,12 +106699,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && - !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && + !(ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); @@ -106311,7 +106755,7 @@ var ts; */ function visitFunctionDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), /*type*/ undefined, ts.visitEachChild(node.body, visitor, context)), @@ -106338,7 +106782,7 @@ var ts; */ function visitClassDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); } @@ -106364,7 +106808,7 @@ var ts; var statements; var variables; var expressions; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var modifiers = void 0; var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. @@ -106422,7 +106866,7 @@ var ts; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. - ts.setEmitFlags(expression, 4 /* NoSubstitution */); + ts.setEmitFlags(expression, 4 /* EmitFlags.NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; @@ -106437,7 +106881,7 @@ var ts; function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), - /*visitor*/ undefined, context, 0 /* All */, + /*visitor*/ undefined, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAllExportExpressions); } else { @@ -106459,7 +106903,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -106471,7 +106915,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -106514,10 +106958,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -106600,8 +107044,8 @@ var ts; if (currentModuleInfo.exportEquals) { return statements; } - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -106646,7 +107090,7 @@ var ts; } function createUnderscoreUnderscoreESModule() { var statement; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())); } else { @@ -106659,7 +107103,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); return statement; } /** @@ -106674,7 +107118,7 @@ var ts; var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -106686,7 +107130,7 @@ var ts; * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { - return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), + return ts.setTextRange(liveBinding && languageVersion !== 0 /* ScriptTarget.ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), @@ -106713,8 +107157,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -106730,7 +107174,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); @@ -106755,7 +107199,7 @@ var ts; if (node.id && noSubstitution[node.id]) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -106790,13 +107234,13 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); } return node; @@ -106805,9 +107249,9 @@ var ts; if (ts.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); noSubstitution[ts.getNodeId(expression)] = true; - if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateCallExpression(node, expression, - /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.arguments), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -106816,9 +107260,9 @@ var ts; if (ts.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); noSubstitution[ts.getNodeId(tag)] = true; - if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, - /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.template), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -106831,16 +107275,16 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } return node; } - else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -106929,11 +107373,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(231 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(231 /* SyntaxKind.MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -106953,7 +107397,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* TransformFlags.ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -107000,7 +107444,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ]), node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* EmitFlags.NoTrailingComments */); if (!ts.outFile(compilerOptions)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -107122,8 +107566,8 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 - var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ? - factory.createModifiersFromModifierFlags(256 /* Async */) : + var modifiers = node.transformFlags & 2097152 /* TransformFlags.ContainsAwait */ ? + factory.createModifiersFromModifierFlags(256 /* ModifierFlags.Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -107157,7 +107601,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 272 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 272 /* SyntaxKind.ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -107222,7 +107666,7 @@ var ts; factory.createForInStatement(factory.createVariableDeclarationList([ factory.createVariableDeclaration(n) ]), m, factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */) ])), factory.createExpressionStatement(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exports])) @@ -107246,19 +107690,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -107317,13 +107761,13 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); default: return topLevelNestedVisitor(node); @@ -107399,7 +107843,7 @@ var ts; * @param node The node to visit. */ function visitFunctionDeclaration(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock))); @@ -107451,7 +107895,7 @@ var ts; return ts.visitNode(node, visitor, ts.isStatement); } var expressions; - var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; @@ -107501,9 +107945,9 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 305 /* SourceFile */ - || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + return (ts.getEmitFlags(node) & 2097152 /* EmitFlags.NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 305 /* SyntaxKind.SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* NodeFlags.BlockScoped */) === 0); } /** * Transform an initialized variable declaration into an expression. @@ -107514,7 +107958,7 @@ var ts; function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAssignment) : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name; } @@ -107566,9 +108010,9 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); - var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* ModifierFlags.Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); } return node; @@ -107579,7 +108023,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -107628,10 +108072,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -107725,8 +108169,8 @@ var ts; return statements; } var excludeName; - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createStringLiteral("default") : decl.name; + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory.getLocalName(decl)); excludeName = ts.getTextOfIdentifierOrLiteral(exportName); } @@ -107786,7 +108230,7 @@ var ts; var statement = factory.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -107798,7 +108242,7 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name; - ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* EmitFlags.NoComments */); return ts.setCommentRange(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // @@ -107811,43 +108255,43 @@ var ts; */ function topLevelNestedVisitor(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ true); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitDefaultClause(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitTryStatement(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -108029,30 +108473,30 @@ var ts; * @param node The node to visit. */ function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4096 /* TransformFlags.ContainsDestructuringAssignment */ | 8388608 /* TransformFlags.ContainsDynamicImport */ | 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node)) { return visitImportCallExpression(node); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -108102,7 +108546,7 @@ var ts; */ function visitDestructuringAssignment(node, valueIsDiscarded) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); } @@ -108132,7 +108576,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 305 /* SourceFile */; + return container !== undefined && container.kind === 305 /* SyntaxKind.SourceFile */; } else { return false; @@ -108148,7 +108592,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -108193,8 +108637,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -108210,7 +108654,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -108245,10 +108689,10 @@ var ts; if (isSubstitutionPrevented(node)) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } - else if (hint === 4 /* Unspecified */) { + else if (hint === 4 /* EmitHint.Unspecified */) { return substituteUnspecified(node); } return node; @@ -108260,7 +108704,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -108295,11 +108739,11 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return substituteMetaProperty(node); } return node; @@ -108311,7 +108755,7 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); @@ -108389,7 +108833,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -108432,8 +108876,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(305 /* SourceFile */); - context.enableSubstitution(79 /* Identifier */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); var helperNameSubstitutions; var currentSourceFile; var importRequireStatements; @@ -108472,14 +108916,14 @@ var ts; } function visitor(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` // is available, just because the output is reasonable for a node-like runtime. return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -108497,23 +108941,23 @@ var ts; args.push(moduleName); } if (!importRequireStatements) { - var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */); + var createRequireName = factory.createUniqueName("_createRequire", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var importStatement = factory.createImportDeclaration( /*modifiers*/ undefined, factory.createImportClause( /*isTypeOnly*/ false, /*name*/ undefined, factory.createNamedImports([ factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName) ])), factory.createStringLiteral("module")); - var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */); + var requireHelperName = factory.createUniqueName("__require", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var requireStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(requireHelperName, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ - factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) + factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) ])) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)); importRequireStatements = [importStatement, requireStatement]; } var name = importRequireStatements[1].declarationList.declarations[0].name; @@ -108534,12 +108978,12 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); statements = appendExportsOfImportEqualsDeclaration(statements, node); return ts.singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, factory.createExportDeclaration( /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))]))); } @@ -108604,7 +109048,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return substituteHelperName(node); } return node; @@ -108613,7 +109057,7 @@ var ts; var name = ts.idText(node); var substitution = helperNameSubstitutions.get(name); if (!substitution) { - helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */)); + helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)); } return substitution; } @@ -108636,8 +109080,8 @@ var ts; var cjsOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(305 /* SourceFile */); - context.enableEmitNotification(305 /* SourceFile */); + context.enableSubstitution(305 /* SyntaxKind.SourceFile */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); var currentSourceFile; return transformSourceFileOrBundle; function onSubstituteNode(hint, node) { @@ -108684,7 +109128,7 @@ var ts; return result; } function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -108739,14 +109183,14 @@ var ts; function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -108768,14 +109212,14 @@ var ts; function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; @@ -108799,7 +109243,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -108817,31 +109261,31 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind)); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(node.kind))); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 167 /* PropertyDeclaration */ || node.kind === 206 /* PropertyAccessExpression */ || node.kind === 166 /* PropertySignature */ || - (node.kind === 164 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 166 /* SyntaxKind.PropertySignature */ || + (node.kind === 164 /* SyntaxKind.Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */ || node.kind === 164 /* Parameter */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 164 /* SyntaxKind.Parameter */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -108864,7 +109308,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.isStatic(node)) { @@ -108881,14 +109325,14 @@ var ts; else { if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1; @@ -108903,36 +109347,36 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; @@ -108944,9 +109388,9 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -108969,40 +109413,40 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; @@ -109013,61 +109457,61 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 256 /* FunctionDeclaration */: - case 179 /* FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind)); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind))); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 179 /* FunctionType */: - case 256 /* FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -109084,7 +109528,7 @@ var ts; // Heritage clause is written by user so it can always be named if (ts.isClassDeclaration(node.parent.parent)) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0; @@ -109133,7 +109577,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 164 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 164 /* SyntaxKind.Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -109152,13 +109596,13 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* NodeBuilderFlags.MultilineObjectLiterals */ | + 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ | + 4096 /* NodeBuilderFlags.UseTypeOfFunction */ | + 8 /* NodeBuilderFlags.UseStructuralFallback */ | + 524288 /* NodeBuilderFlags.AllowEmptyTuple */ | + 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ | + 1 /* NodeBuilderFlags.NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -109218,7 +109662,7 @@ var ts; } function trackReferencedAmbientModule(node, symbol) { // If it is visible via `// `, then we should just use that - var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* SymbolFlags.All */); if (ts.length(directives)) { return recordTypeReferenceDirectivesIfNecessary(directives); } @@ -109227,7 +109671,7 @@ var ts; refs.set(ts.getOriginalNodeId(container), container); } function handleSymbolAccessibilityError(symbolAccessibilityResult) { - if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccessibilityResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { if (!lateMarkedStatements) { @@ -109263,7 +109707,7 @@ var ts; } } function trackSymbol(symbol, enclosingDeclaration, meaning) { - if (symbol.flags & 262144 /* TypeParameter */) + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) return false; var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); @@ -109339,10 +109783,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 305 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 305 /* SyntaxKind.SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -109365,14 +109809,14 @@ var ts; resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([factory.createModifier(135 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -109509,11 +109953,11 @@ var ts; return ret; } function filterBindingPatternInitializersAndRenamings(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return name; } else { - if (name.kind === 202 /* ArrayBindingPattern */) { + if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -109521,7 +109965,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 227 /* OmittedExpression */) { + if (elem.kind === 227 /* SyntaxKind.OmittedExpression */) { return elem; } if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) { @@ -109538,7 +109982,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } - var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* SyntaxKind.QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -109555,7 +109999,7 @@ var ts; return undefined; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { // Private nodes emit no types (except private parameter properties, whose parameter types are actually visible) return; } @@ -109563,19 +110007,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 164 /* Parameter */ && + var shouldUseResolverType = node.kind === 164 /* SyntaxKind.Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return factory.createKeywordTypeNode(130 /* AnyKeyword */); + return factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -109583,12 +110027,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 164 /* Parameter */ - || node.kind === 167 /* PropertyDeclaration */ - || node.kind === 166 /* PropertySignature */) { + if (node.kind === 164 /* SyntaxKind.Parameter */ + || node.kind === 167 /* SyntaxKind.PropertyDeclaration */ + || node.kind === 166 /* SyntaxKind.PropertySignature */) { if (ts.isPropertySignature(node) || !node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -109599,28 +110043,28 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !getBindingNameVisible(node); - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return false; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; } return false; @@ -109647,7 +110091,7 @@ var ts; } } function updateParamsList(node, params, modifierMask) { - if (ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); @@ -109683,7 +110127,7 @@ var ts; return factory.createNodeArray(newParams || ts.emptyArray); } function ensureTypeParams(node, params) { - return ts.hasEffectiveModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); + return ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } function isEnclosingDeclaration(node) { return ts.isSourceFile(node) @@ -109709,7 +110153,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* ModuleDeclaration */ && parent.kind !== 200 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && parent.kind !== 200 /* SyntaxKind.ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -109729,7 +110173,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, decl.modifiers, decl.isTypeOnly, decl.name, factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); @@ -109754,7 +110198,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } - if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; @@ -109799,7 +110243,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.Debug.formatSyntaxKind(i.kind))); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -109857,10 +110301,10 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* TypeLiteral */ || input.kind === 195 /* MappedType */) && input.parent.kind !== 259 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* SyntaxKind.TypeLiteral */ || input.kind === 195 /* SyntaxKind.MappedType */) && input.parent.kind !== 259 /* SyntaxKind.TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { - if (ts.hasEffectiveModifier(input, 8 /* Private */)) { + if (ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload return cleanup(factory.createPropertyDeclaration(ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); @@ -109878,28 +110322,28 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 228 /* ExpressionWithTypeArguments */: { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( - /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* None */), + /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* ModifierFlags.None */), /*body*/ undefined); return cleanup(ctor); } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -109908,44 +110352,44 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 172 /* GetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(factory.updateGetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), + return cleanup(factory.updateGetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 173 /* SetAccessor */: { + case 173 /* SyntaxKind.SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } - return cleanup(factory.updateSetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), + return cleanup(factory.updateSetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), /*body*/ undefined)); } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 176 /* IndexSignature */: { - return cleanup(factory.updateIndexSignature(input, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */))); + case 176 /* SyntaxKind.IndexSignature */: { + return cleanup(factory.updateIndexSignature(input, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */))); } - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -109953,13 +110397,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 163 /* TypeParameter */: { + case 163 /* SyntaxKind.TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 189 /* ConditionalType */: { + case 189 /* SyntaxKind.ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -109971,22 +110415,22 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 179 /* FunctionType */: { + case 179 /* SyntaxKind.FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 180 /* ConstructorType */: { + case 180 /* SyntaxKind.ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 200 /* ImportType */: { + case 200 /* SyntaxKind.ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind)); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(input.kind))); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { - ts.setEmitFlags(input, 1 /* SingleLine */); + ts.setEmitFlags(input, 1 /* EmitFlags.SingleLine */); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { @@ -110009,7 +110453,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 169 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -110019,7 +110463,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 272 /* ExportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -110028,17 +110472,17 @@ var ts; // Rewrite external module names if necessary return factory.updateExportDeclaration(input, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 79 /* Identifier */) { + if (input.expression.kind === 79 /* SyntaxKind.Identifier */) { return input; } else { - var newId = factory.createUniqueName("_default", 16 /* Optimistic */); + var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input @@ -110046,7 +110490,7 @@ var ts; errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); preserveJsDoc(statement, input); ts.removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.modifiers, newId)]; @@ -110059,12 +110503,12 @@ var ts; return input; } function stripExportModifiers(statement) { - if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* Default */) || !ts.canHaveModifiers(statement)) { + if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) { // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (257023 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (257023 /* ModifierFlags.All */ ^ 1 /* ModifierFlags.Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { @@ -110075,10 +110519,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -110099,12 +110543,12 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 258 /* InterfaceDeclaration */: { + case 258 /* SyntaxKind.InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), @@ -110112,7 +110556,7 @@ var ts; if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration - var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace_1, enclosingDeclaration); fakespace_1.locals = ts.createSymbolTable(props); fakespace_1.symbol = props[0].parent; @@ -110131,10 +110575,10 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* SyntaxKind.ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { - declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); + declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* ModifierFlags.None */); }); } else { declarations.push(factory.createExportDeclaration( @@ -110144,11 +110588,11 @@ var ts; return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); })))); } - var namespaceDecl = factory.createModuleDeclaration(ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */); - if (!ts.hasEffectiveModifier(clean, 512 /* Default */)) { + var namespaceDecl = factory.createModuleDeclaration(ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* NodeFlags.Namespace */); + if (!ts.hasEffectiveModifier(clean, 512 /* ModifierFlags.Default */)) { return [clean, namespaceDecl]; } - var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ExportDefault */) | 2 /* Ambient */); + var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ModifierFlags.ExportDefault */) | 2 /* ModifierFlags.Ambient */); var cleanDeclaration = factory.updateFunctionDeclaration(clean, modifiers, /*asteriskToken*/ undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, /*body*/ undefined); @@ -110166,17 +110610,17 @@ var ts; return clean; } } - case 261 /* ModuleDeclaration */: { + case 261 /* SyntaxKind.ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 262 /* ModuleBlock */) { + if (inner && inner.kind === 262 /* SyntaxKind.ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 16777216 /* Ambient */) { + if (input.flags & 16777216 /* NodeFlags.Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -110210,7 +110654,7 @@ var ts; return cleanup(factory.updateModuleDeclaration(input, mods, input.name, body)); } } - case 257 /* ClassDeclaration */: { + case 257 /* SyntaxKind.ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -110220,10 +110664,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ModifierFlags.ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 79 /* Identifier */) { + if (param.name.kind === 79 /* SyntaxKind.Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration(ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } else { @@ -110262,26 +110706,26 @@ var ts; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* SyntaxKind.NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16 /* Optimistic */); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 94 /* ExtendsKeyword */) { + if (clause.token === 94 /* SyntaxKind.ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* SyntaxKind.NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 } @@ -110290,10 +110734,10 @@ var ts; return cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 260 /* EnumDeclaration */: { + case 260 /* SyntaxKind.EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -110304,7 +110748,7 @@ var ts; } } // Anything left unhandled is an error, so this should be unreachable - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind)); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.Debug.formatSyntaxKind(input.kind))); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -110312,7 +110756,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 261 /* ModuleDeclaration */) { + if (input.kind === 261 /* SyntaxKind.ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -110335,7 +110779,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 227 /* OmittedExpression */) { + if (e.kind === 227 /* SyntaxKind.OmittedExpression */) { return; } if (e.name) { @@ -110383,12 +110827,12 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 257023 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files - var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 305 /* SourceFile */; + var mask = 257023 /* ModifierFlags.All */ ^ (4 /* ModifierFlags.Public */ | 256 /* ModifierFlags.Async */ | 16384 /* ModifierFlags.Override */); // No async and override modifiers in declaration files + var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* ModifierFlags.Ambient */ : 0 /* ModifierFlags.None */; + var parentIsFile = node.parent.kind === 305 /* SyntaxKind.SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { - mask ^= 2 /* Ambient */; - additions = 0 /* None */; + mask ^= 2 /* ModifierFlags.Ambient */; + additions = 0 /* ModifierFlags.None */; } return maskModifierFlags(node, mask, additions); } @@ -110408,13 +110852,13 @@ var ts; } function transformHeritageClauses(nodes) { return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* SyntaxKind.ExtendsKeyword */ && t.expression.kind === 104 /* SyntaxKind.NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return true; } return false; @@ -110424,22 +110868,22 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 257023 /* All */ ^ 4 /* Public */; } - if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } + if (modifierMask === void 0) { modifierMask = 257023 /* ModifierFlags.All */ ^ 4 /* ModifierFlags.Public */; } + if (modifierAdditions === void 0) { modifierAdditions = 0 /* ModifierFlags.None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; - if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { + if (flags & 512 /* ModifierFlags.Default */ && !(flags & 1 /* ModifierFlags.Export */)) { // A non-exported default is a nonsequitor - we usually try to remove all export modifiers // from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid - flags ^= 1 /* Export */; + flags ^= 1 /* ModifierFlags.Export */; } - if (flags & 512 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) + if (flags & 512 /* ModifierFlags.Default */ && flags & 2 /* ModifierFlags.Ambient */) { + flags ^= 2 /* ModifierFlags.Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) } return flags; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 172 /* GetAccessor */ + return accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -110448,52 +110892,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return !ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */); + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 237 /* VariableStatement */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 254 /* VariableDeclaration */: - case 163 /* TypeParameter */: - case 228 /* ExpressionWithTypeArguments */: - case 178 /* TypeReference */: - case 189 /* ConditionalType */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 200 /* ImportType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 189 /* SyntaxKind.ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 200 /* SyntaxKind.ImportType */: return true; } return false; @@ -110551,35 +110995,35 @@ var ts; if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); } - if (languageVersion < 99 /* ESNext */) { + if (languageVersion < 99 /* ScriptTarget.ESNext */) { transformers.push(ts.transformESNext); } - if (languageVersion < 8 /* ES2021 */) { + if (languageVersion < 8 /* ScriptTarget.ES2021 */) { transformers.push(ts.transformES2021); } - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { transformers.push(ts.transformES2020); } - if (languageVersion < 6 /* ES2019 */) { + if (languageVersion < 6 /* ScriptTarget.ES2019 */) { transformers.push(ts.transformES2019); } - if (languageVersion < 5 /* ES2018 */) { + if (languageVersion < 5 /* ScriptTarget.ES2018 */) { transformers.push(ts.transformES2018); } - if (languageVersion < 4 /* ES2017 */) { + if (languageVersion < 4 /* ScriptTarget.ES2017 */) { transformers.push(ts.transformES2017); } - if (languageVersion < 3 /* ES2016 */) { + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { transformers.push(ts.transformES2016); } - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { transformers.push(ts.transformES5); } ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory)); @@ -110633,11 +111077,11 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(355 /* Count */); + var enabledSyntaxKindFeatures = new Array(355 /* SyntaxKind.Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; - var lexicalEnvironmentFlags = 0 /* None */; + var lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var lexicalEnvironmentStatementsStack = []; @@ -110650,7 +111094,7 @@ var ts; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; - var state = 0 /* Uninitialized */; + var state = 0 /* TransformationState.Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer // initialization. @@ -110680,13 +111124,13 @@ var ts; isEmitNotificationEnabled: isEmitNotificationEnabled, get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onEmitNode = value; }, @@ -110710,17 +111154,17 @@ var ts; return node; }; // prevent modification of transformation hooks. - state = 1 /* Initialized */; + state = 1 /* TransformationState.Initialized */; // Transform each node. var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 305 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "transformNodes", node.kind === 305 /* SyntaxKind.SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. - state = 2 /* Completed */; + state = 2 /* TransformationState.Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { @@ -110738,15 +111182,15 @@ var ts; * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 1 /* SyntaxKindFeatureFlags.Substitution */; } /** * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 - && (ts.getEmitFlags(node) & 4 /* NoSubstitution */) === 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* SyntaxKindFeatureFlags.Substitution */) !== 0 + && (ts.getEmitFlags(node) & 4 /* EmitFlags.NoSubstitution */) === 0; } /** * Emits a node with possible substitution. @@ -110756,23 +111200,23 @@ var ts; * @param emitCallback The callback used to emit the node or its substitute. */ function substituteNode(hint, node) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot substitute a node after the result is disposed."); return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 2 /* SyntaxKindFeatureFlags.EmitNotifications */; } /** * Determines whether before/after emit notifications should be raised in the pretty * printer when it emits a node. */ function isEmitNotificationEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (ts.getEmitFlags(node) & 2 /* AdviseOnEmitNode */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 2 /* SyntaxKindFeatureFlags.EmitNotifications */) !== 0 + || (ts.getEmitFlags(node) & 2 /* EmitFlags.AdviseOnEmitNode */) !== 0; } /** * Emits a node with possible emit notification. @@ -110782,7 +111226,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { // TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed // (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739) @@ -110798,26 +111242,26 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* NoNestedSourceMaps */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* EmitFlags.NoNestedSourceMaps */); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; } else { lexicalEnvironmentVariableDeclarations.push(decl); } - if (lexicalEnvironmentFlags & 1 /* InParameters */) { - lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */; + if (lexicalEnvironmentFlags & 1 /* LexicalEnvironmentFlags.InParameters */) { + lexicalEnvironmentFlags |= 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */; } } /** * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(func, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(func, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -110829,9 +111273,9 @@ var ts; * Adds an initialization statement to the top of the lexical environment. */ function addInitializationStatement(node) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(node, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(node, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentStatements) { lexicalEnvironmentStatements = [node]; } @@ -110844,8 +111288,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -110859,19 +111303,19 @@ var ts; lexicalEnvironmentVariableDeclarations = undefined; lexicalEnvironmentFunctionDeclarations = undefined; lexicalEnvironmentStatements = undefined; - lexicalEnvironmentFlags = 0 /* None */; + lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -110880,8 +111324,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || @@ -110893,7 +111337,7 @@ var ts; if (lexicalEnvironmentVariableDeclarations) { var statement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); if (!statements) { statements = [statement]; } @@ -110936,8 +111380,8 @@ var ts; * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. */ function startBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot start a block scope after transformation has completed."); blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; blockScopeStackOffset++; blockScopedVariableDeclarations = undefined; @@ -110946,12 +111390,12 @@ var ts; * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. */ function endBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot end a block scope after transformation has completed."); var statements = ts.some(blockScopedVariableDeclarations) ? [ factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* NodeFlags.Let */)) ] : undefined; blockScopeStackOffset--; blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; @@ -110965,8 +111409,8 @@ var ts; (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); } function requestEmitHelper(helper) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); if (helper.dependencies) { for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) { @@ -110977,14 +111421,14 @@ var ts; emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } function dispose() { - if (state < 3 /* Disposed */) { + if (state < 3 /* TransformationState.Disposed */) { // Clean up emit nodes on parse tree for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; @@ -110999,7 +111443,7 @@ var ts; onEmitNode = undefined; emitHelpers = undefined; // Prevent further use of the transformation result. - state = 3 /* Disposed */; + state = 3 /* TransformationState.Disposed */; } } } @@ -111038,7 +111482,7 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ function isBuildInfoFile(file) { - return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + return ts.fileExtensionIs(file, ".tsbuildinfo" /* Extension.TsBuildInfo */); } ts.isBuildInfoFile = isBuildInfoFile; /*@internal*/ @@ -111104,7 +111548,7 @@ var ts; ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : configFileExtensionLess; } - return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + return buildInfoExtensionLess + ".tsbuildinfo" /* Extension.TsBuildInfo */; } ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ @@ -111112,7 +111556,7 @@ var ts; var outPath = ts.outFile(options); var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; @@ -111121,7 +111565,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 306 /* Bundle */) { + if (sourceFile.kind === 306 /* SyntaxKind.Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -111129,7 +111573,7 @@ var ts; var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it var isJsonEmittedToSameLocation = isJsonFile && - ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; @@ -111143,11 +111587,11 @@ var ts; } /* @internal */ function getOutputExtension(fileName, options) { - return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : - options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : - ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : - ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : - ".js" /* Js */; + return ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) ? ".json" /* Extension.Json */ : + options.jsx === 1 /* JsxEmit.Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Extension.Jsx */, ".tsx" /* Extension.Tsx */]) ? ".jsx" /* Extension.Jsx */ : + ts.fileExtensionIsOneOf(fileName, [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ".mjs" /* Extension.Mjs */ : + ts.fileExtensionIsOneOf(fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ".cjs" /* Extension.Cjs */ : + ".js" /* Extension.Js */; } ts.getOutputExtension = getOutputExtension; function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) { @@ -111163,9 +111607,9 @@ var ts; function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { if (configFile.options.emitDeclarationOnly) return undefined; - var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options)); - return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? + return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* Comparison.EqualTo */ ? outputFileName : undefined; } @@ -111194,16 +111638,16 @@ var ts; return; var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -111272,7 +111716,7 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { @@ -111282,7 +111726,7 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) return jsFilePath; - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) continue; if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); @@ -111291,7 +111735,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ @@ -111307,7 +111751,6 @@ var ts; var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit; var bundleBuildInfo; var emitSkipped = false; - var exportedModulesFromDeclarationEmit; // Emit each output file enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile); @@ -111317,7 +111760,6 @@ var ts; diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList, - exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; @@ -111329,13 +111771,13 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { @@ -111380,7 +111822,7 @@ var ts; return; } // Make sure not to write js file and source map file if any of them cannot be written - if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) { + if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) { emitSkipped = true; return; } @@ -111409,7 +111851,7 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); if (bundleBuildInfo) @@ -111445,7 +111887,7 @@ var ts; noEmitHelpers: true, module: compilerOptions.module, target: compilerOptions.target, - sourceMap: compilerOptions.sourceMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, @@ -111465,17 +111907,13 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { - sourceMap: !forceDtsEmit && compilerOptions.declarationMap, + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, { + sourceMap: printerOptions.sourceMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) { - var sourceFile = declarationTransform.transformed[0]; - exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; - } } declarationTransform.dispose(); if (bundleBuildInfo) @@ -111483,7 +111921,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -111494,9 +111932,10 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) { + var sourceFileOrBundle = transform.transformed[0]; + var bundle = sourceFileOrBundle.kind === 306 /* SyntaxKind.Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -111521,14 +111960,14 @@ var ts; if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); sourceMapUrlPos = writer.getTextPos(); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); // Tools can sometimes see this line as a source mapping url comment } // Write the source map if (sourceMapFilePath) { var sourceMap = sourceMapGenerator.toString(); ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles); if (printer.bundleFileInfo) - printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); } } else { @@ -111536,17 +111975,17 @@ var ts; } // Write the output file var text = writer.getText(); - ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); + ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics }); // We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo // This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode if (printer.bundleFileInfo) - printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash)); // Reset state writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 305 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Extension.Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -111577,7 +112016,7 @@ var ts; // Encode the sourceMap into the sourceMap url var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -111670,8 +112109,8 @@ var ts; ts.setParent(literal, statement); return statement; }); - var eofToken = ts.factory.createToken(1 /* EndOfFileToken */); - var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* None */); + var eofToken = ts.factory.createToken(1 /* SyntaxKind.EndOfFileToken */); + var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* NodeFlags.None */); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : ""; ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0); @@ -111705,25 +112144,25 @@ var ts; if (!jsFileText) return jsFilePath; // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it - if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) + if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) return jsFilePath; var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); // error if no source map or for now if inline sourcemap if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) return sourceMapFilePath || "inline sourcemap decoding"; - if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) + if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) return sourceMapFilePath; // read declaration text var declarationText = declarationFilePath && host.readFile(declarationFilePath); if (declarationFilePath && !declarationText) return declarationFilePath; - if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) + if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) return declarationFilePath; var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); // error if no source map or for now if inline sourcemap if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) return declarationMapPath || "inline sourcemap decoding"; - if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) + if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) return declarationMapPath; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, @@ -111763,8 +112202,7 @@ var ts; newBuildInfo.program = buildInfo.program; if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) { // Update the output signature - newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash); - newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime(); + newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData); } // Update sourceFileInfo var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; @@ -111786,7 +112224,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -111839,7 +112277,7 @@ var ts; var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined; var recordInternalSection = printerOptions.recordInternalSection; var sourceFileTextPos = 0; - var sourceFileTextKind = "text" /* Text */; + var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -111879,20 +112317,20 @@ var ts; }; function printNode(hint, node, sourceFile) { switch (hint) { - case 0 /* SourceFile */: + case 0 /* EmitHint.SourceFile */: ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); break; - case 2 /* IdentifierName */: + case 2 /* EmitHint.IdentifierName */: ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); break; - case 1 /* Expression */: + case 1 /* EmitHint.Expression */: ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); break; } switch (node.kind) { - case 305 /* SourceFile */: return printFile(node); - case 306 /* Bundle */: return printBundle(node); - case 307 /* UnparsedSource */: return printUnparsedSource(node); + case 305 /* SyntaxKind.SourceFile */: return printFile(node); + case 306 /* SyntaxKind.Bundle */: return printBundle(node); + case 307 /* SyntaxKind.UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -111948,11 +112386,11 @@ var ts; currentSourceFile && (ts.isDeclaration(node) || ts.isVariableStatement(node)) && ts.isInternalDeclaration(node, currentSourceFile) && - sourceFileTextKind !== "internal" /* Internal */) { + sourceFileTextKind !== "internal" /* BundleFileSectionKind.Internal */) { var prevSourceFileTextKind = sourceFileTextKind; recordBundleFileTextLikeSection(writer.getTextPos()); sourceFileTextPos = getTextPosWithWriteLine(); - sourceFileTextKind = "internal" /* Internal */; + sourceFileTextKind = "internal" /* BundleFileSectionKind.Internal */; return prevSourceFileTextKind; } return undefined; @@ -111987,7 +112425,7 @@ var ts; var savedSections = bundleFileInfo && bundleFileInfo.sections; if (savedSections) bundleFileInfo.sections = []; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, prepend, /*sourceFile*/ undefined); if (bundleFileInfo) { var newSections = bundleFileInfo.sections; bundleFileInfo.sections = savedSections; @@ -111998,7 +112436,7 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), - kind: "prepend" /* Prepend */, + kind: "prepend" /* BundleFileSectionKind.Prepend */, data: relativeToBuildInfo(prepend.fileName), texts: newSections }); @@ -112008,7 +112446,7 @@ var ts; sourceFileTextPos = getTextPosWithWriteLine(); for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { var sourceFile = _e[_d]; - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); } if (bundleFileInfo && bundle.sourceFiles.length) { var end = writer.getTextPos(); @@ -112035,7 +112473,7 @@ var ts; function writeUnparsedSource(unparsed, output) { var previousWriter = writer; setWriter(output, /*_sourceMapGenerator*/ undefined); - print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } @@ -112045,7 +112483,7 @@ var ts; setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; } @@ -112084,7 +112522,7 @@ var ts; autoGeneratedIdToGeneratedName = []; generatedNames = new ts.Set(); tempFlagsStack = []; - tempFlags = 0 /* Auto */; + tempFlags = 0 /* TempFlags.Auto */; reservedNamesStack = []; currentSourceFile = undefined; currentLineMap = undefined; @@ -112098,24 +112536,24 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); + pipelineEmit(4 /* EmitHint.Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) return; - pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); + pipelineEmit(2 /* EmitHint.IdentifierName */, node, /*parenthesizerRule*/ undefined); } function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - pipelineEmit(1 /* Expression */, node, parenthesizerRule); + pipelineEmit(1 /* EmitHint.Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* EmitHint.JsxAttributeValue */ : 4 /* EmitHint.Unspecified */, node); } function beforeEmitNode(node) { - if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* EmitFlags.IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } } @@ -112124,7 +112562,7 @@ var ts; } function pipelineEmit(emitHint, node, parenthesizerRule) { currentParenthesizerRule = parenthesizerRule; - var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, emitHint, node); pipelinePhase(emitHint, node); currentParenthesizerRule = undefined; } @@ -112140,12 +112578,12 @@ var ts; } function getPipelinePhase(phase, emitHint, node) { switch (phase) { - case 0 /* Notification */: + case 0 /* PipelinePhase.Notification */: if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) { return pipelineEmitWithNotification; } // falls through - case 1 /* Substitution */: + case 1 /* PipelinePhase.Substitution */: if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { if (currentParenthesizerRule) { lastSubstitution = currentParenthesizerRule(lastSubstitution); @@ -112153,17 +112591,17 @@ var ts; return pipelineEmitWithSubstitution; } // falls through - case 2 /* Comments */: + case 2 /* PipelinePhase.Comments */: if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through - case 3 /* SourceMaps */: + case 3 /* PipelinePhase.SourceMaps */: if (shouldEmitSourceMaps(node)) { return pipelineEmitWithSourceMaps; } // falls through - case 4 /* Emit */: + case 4 /* PipelinePhase.Emit */: return pipelineEmitWithHint; default: return ts.Debug.assertNever(phase); @@ -112173,7 +112611,7 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); + var pipelinePhase = getNextPipelinePhase(0 /* PipelinePhase.Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { @@ -112199,346 +112637,346 @@ var ts; return emitSnippetNode(hint, node, snippet); } } - if (hint === 0 /* SourceFile */) + if (hint === 0 /* EmitHint.SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); - if (hint === 2 /* IdentifierName */) + if (hint === 2 /* EmitHint.IdentifierName */) return emitIdentifier(ts.cast(node, ts.isIdentifier)); - if (hint === 6 /* JsxAttributeValue */) + if (hint === 6 /* EmitHint.JsxAttributeValue */) return emitLiteral(ts.cast(node, ts.isStringLiteral), /*jsxAttributeEscape*/ true); - if (hint === 3 /* MappedTypeParameter */) + if (hint === 3 /* EmitHint.MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); - if (hint === 5 /* EmbeddedStatement */) { + if (hint === 5 /* EmitHint.EmbeddedStatement */) { ts.Debug.assertNode(node, ts.isEmptyStatement); return emitEmptyStatement(/*isEmbeddedStatement*/ true); } - if (hint === 4 /* Unspecified */) { + if (hint === 4 /* EmitHint.Unspecified */) { switch (node.kind) { // Pseudo-literals - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return emitQualifiedName(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return emitTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return emitParameter(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return emitDecorator(node); // Type members - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return emitPropertySignature(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return emitPropertyDeclaration(node); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return emitMethodSignature(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return emitMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return emitClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return emitConstructor(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return emitAccessorDeclaration(node); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return emitCallSignature(node); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return emitConstructSignature(node); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return emitIndexSignature(node); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return emitTypePredicate(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return emitTypeReference(node); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return emitFunctionType(node); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return emitConstructorType(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return emitTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return emitTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return emitArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return emitTupleType(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return emitUnionType(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return emitIntersectionType(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return emitConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return emitInferType(node); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return emitParenthesizedType(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return emitThisType(); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return emitTypeOperator(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return emitIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return emitMappedType(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return emitLiteralType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return emitNamedTupleMember(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return emitTemplateType(node); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return emitImportTypeNode(node); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return emitBindingElement(node); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return emitTemplateSpan(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return emitBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return emitVariableStatement(node); - case 236 /* EmptyStatement */: + case 236 /* SyntaxKind.EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return emitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return emitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return emitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return emitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return emitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return emitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return emitForOfStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return emitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return emitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return emitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return emitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return emitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return emitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return emitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return emitTryStatement(node); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return emitVariableDeclaration(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return emitVariableDeclarationList(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return emitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return emitClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return emitEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return emitModuleDeclaration(node); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return emitModuleBlock(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return emitCaseBlock(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return emitImportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return emitImportClause(node); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return emitNamespaceImport(node); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return emitNamespaceExport(node); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: return emitNamedImports(node); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return emitImportSpecifier(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return emitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return emitExportDeclaration(node); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: return emitNamedExports(node); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return emitExportSpecifier(node); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return emitAssertClause(node); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return emitAssertEntry(node); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return; // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return emitJsxText(node); - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 281 /* JsxClosingElement */: - case 284 /* JsxClosingFragment */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 284 /* SyntaxKind.JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return emitJsxAttribute(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return emitJsxAttributes(node); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return emitJsxExpression(node); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return emitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return emitDefaultClause(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return emitHeritageClause(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return emitCatchClause(node); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return emitPropertyAssignment(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return emitEnumMember(node); // Unparsed - case 300 /* UnparsedPrologue */: + case 300 /* SyntaxKind.UnparsedPrologue */: return writeUnparsedNode(node); - case 307 /* UnparsedSource */: - case 301 /* UnparsedPrepend */: + case 307 /* SyntaxKind.UnparsedSource */: + case 301 /* SyntaxKind.UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return emitUnparsedTextLike(node); - case 304 /* UnparsedSyntheticReference */: + case 304 /* SyntaxKind.UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return emitSourceFile(node); - case 306 /* Bundle */: + case 306 /* SyntaxKind.Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 308 /* InputFiles */: + case 308 /* SyntaxKind.InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return emitJSDocNameReference(node); - case 312 /* JSDocAllType */: + case 312 /* SyntaxKind.JSDocAllType */: return writePunctuation("*"); - case 313 /* JSDocUnknownType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return writePunctuation("?"); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return emitJSDocNullableType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return emitJSDocOptionalType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return emitJSDocFunctionType(node); - case 186 /* RestType */: - case 318 /* JSDocVariadicType */: + case 186 /* SyntaxKind.RestType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 319 /* JSDocNamepathType */: + case 319 /* SyntaxKind.JSDocNamepathType */: return; - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return emitJSDoc(node); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return emitJSDocSignature(node); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 337 /* JSDocOverrideTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 337 /* SyntaxKind.JSDocOverrideTag */: return emitJSDocSimpleTag(node); - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 330 /* JSDocAuthorTag */: - case 331 /* JSDocDeprecatedTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: return; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 339 /* JSDocEnumTag */: - case 341 /* JSDocReturnTag */: - case 342 /* JSDocThisTag */: - case 343 /* JSDocTypeTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 349 /* NotEmittedStatement */: - case 353 /* EndOfDeclarationMarker */: - case 352 /* MergeDeclarationMarker */: + case 349 /* SyntaxKind.NotEmittedStatement */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { - hint = 1 /* Expression */; + hint = 1 /* EmitHint.Expression */; if (substituteNode !== ts.noEmitSubstitution) { var substitute = substituteNode(hint, node) || node; if (substitute !== node) { @@ -112550,101 +112988,101 @@ var ts; } } } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { switch (node.kind) { // Literals - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return emitNumericOrBigIntLiteral(node); - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Expressions - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return emitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return emitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return emitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return emitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return emitArrowFunction(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return emitDeleteExpression(node); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return emitTypeOfExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return emitVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return emitAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return emitBinaryExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return emitConditionalExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return emitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return emitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return emitSpreadElement(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return emitClassExpression(node); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return emitAsExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return emitNonNullExpression(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return emitMetaProperty(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return emitJsxElement(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 349 /* NotEmittedStatement */: + case 349 /* SyntaxKind.NotEmittedStatement */: return; - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return emitCommaList(node); - case 352 /* MergeDeclarationMarker */: - case 353 /* EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return; - case 354 /* SyntheticReferenceExpression */: + case 354 /* SyntaxKind.SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -112652,7 +113090,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -112662,7 +113100,7 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); + var pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, hint, node); ts.Debug.assertIsDefined(lastSubstitution); node = lastSubstitution; lastSubstitution = undefined; @@ -112692,7 +113130,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 306 /* Bundle */ ? node : undefined; + var bundle = node.kind === 306 /* SyntaxKind.Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -112734,7 +113172,7 @@ var ts; writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* BundleFileSectionKind.EmitHelpers */, data: helper.name }); helpersEmitted = true; } } @@ -112762,7 +113200,7 @@ var ts; function emitLiteral(node, jsxAttributeEscape) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* SyntaxKind.StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -112792,9 +113230,9 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* SyntaxKind.UnparsedText */ ? + "text" /* BundleFileSectionKind.Text */ : + "internal" /* BundleFileSectionKind.Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -112813,25 +113251,25 @@ var ts; // function emitSnippetNode(hint, node, snippet) { switch (snippet.kind) { - case 1 /* Placeholder */: + case 1 /* SnippetKind.Placeholder */: emitPlaceholder(hint, node, snippet); break; - case 0 /* TabStop */: + case 0 /* SnippetKind.TabStop */: emitTabStop(hint, node, snippet); break; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); // `${2:` + nonEscapingWrite("${".concat(snippet.order, ":")); // `${2:` pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` nonEscapingWrite("}"); // `}` // `${2:...}` } function emitTabStop(hint, node, snippet) { // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text. - ts.Debug.assert(node.kind === 236 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); - ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + ts.Debug.assert(node.kind === 236 /* SyntaxKind.EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); + ts.Debug.assert(hint !== 5 /* EmitHint.EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); + nonEscapingWrite("$".concat(snippet.order)); } // // Identifiers @@ -112839,7 +113277,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* ListFormat.TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -112854,7 +113292,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112890,7 +113328,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 317 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -112951,7 +113389,7 @@ var ts; } function emitAccessorDeclaration(node) { emitDecoratorsAndModifiers(node, node.modifiers); - writeKeyword(node.kind === 172 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 172 /* SyntaxKind.GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -113056,8 +113494,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineTypeLiteralMembers */ : 32897 /* ListFormat.MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* ListFormat.NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -113070,16 +113508,16 @@ var ts; emit(node.type); } function emitTupleType(node) { - emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */; - emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); - emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.pos, writePunctuation, node); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 528 /* ListFormat.SingleLineTupleTypeElements */ : 657 /* ListFormat.MultiLineTupleTypeElements */; + emitList(node, node.elements, flags | 524288 /* ListFormat.NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.elements.end, writePunctuation, node); } function emitNamedTupleMember(node) { emit(node.dotDotDotToken); emit(node.name); emit(node.questionToken); - emitTokenWithComment(58 /* ColonToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.name.end, writePunctuation, node); writeSpace(); emit(node.type); } @@ -113088,10 +113526,10 @@ var ts; writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); + emitList(node, node.types, 516 /* ListFormat.UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); + emitList(node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); } function emitConditionalType(node) { emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType); @@ -113124,7 +113562,7 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ? + var parenthesizerRule = node.operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizer.parenthesizeOperandOfReadonlyTypeOperator : parenthesizer.parenthesizeOperandOfTypeOperator; emit(node.type, parenthesizerRule); @@ -113138,7 +113576,7 @@ var ts; function emitMappedType(node) { var emitFlags = ts.getEmitFlags(node); writePunctuation("{"); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { @@ -113147,13 +113585,13 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 145 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* EmitHint.MappedTypeParameter */, node.typeParameter); if (node.nameType) { writeSpace(); writeKeyword("as"); @@ -113163,7 +113601,7 @@ var ts; writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 57 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { writePunctuation("?"); } } @@ -113171,14 +113609,14 @@ var ts; writeSpace(); emit(node.type); writeTrailingSemicolon(); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { writeLine(); decreaseIndent(); } - emitList(node, node.members, 2 /* PreserveLines */); + emitList(node, node.members, 2 /* ListFormat.PreserveLines */); writePunctuation("}"); } function emitLiteralType(node) { @@ -113186,7 +113624,7 @@ var ts; } function emitTemplateType(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitImportTypeNode(node) { if (node.isTypeOf) { @@ -113205,7 +113643,7 @@ var ts; writePunctuation(":"); writeSpace(); var elements = node.assertions.assertClause.elements; - emitList(node.assertions.assertClause, elements, 526226 /* ImportClauseEntries */); + emitList(node.assertions.assertClause, elements, 526226 /* ListFormat.ImportClauseEntries */); writeSpace(); writePunctuation("}"); } @@ -113221,12 +113659,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ListFormat.ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ListFormat.ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -113244,29 +113682,29 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + emitExpressionList(node, elements, 8914 /* ListFormat.ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ScriptTarget.ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* ListFormat.AllowTrailingComma */ : 0 /* ListFormat.None */; + emitList(node, node.properties, 526226 /* ListFormat.ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); } } function emitPropertyAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); - var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos); + var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* SyntaxKind.DotToken */), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + var shouldEmitDotDot = token.kind !== 28 /* SyntaxKind.QuestionDotToken */ && mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); @@ -113292,7 +113730,7 @@ var ts; var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true, /*jsxAttributeEscape*/ false); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* SyntaxKind.DotToken */)); } else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer @@ -113305,12 +113743,12 @@ var ts; function emitElementAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); - emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -113323,17 +113761,17 @@ var ts; } emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* SyntaxKind.NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 18960 /* ListFormat.NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -113355,12 +113793,12 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); - emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -113378,22 +113816,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* SyntaxKind.DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* SyntaxKind.TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* SyntaxKind.VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(132 /* SyntaxKind.AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -113418,9 +113856,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 219 /* PrefixUnaryExpression */ - && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) - || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); + return operand.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ + && ((node.operator === 39 /* SyntaxKind.PlusToken */ && (operand.operator === 39 /* SyntaxKind.PlusToken */ || operand.operator === 45 /* SyntaxKind.PlusPlusToken */)) + || (node.operator === 40 /* SyntaxKind.MinusToken */ && (operand.operator === 40 /* SyntaxKind.MinusToken */ || operand.operator === 46 /* SyntaxKind.MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); @@ -113461,12 +113899,12 @@ var ts; return maybeEmitExpression(next, parent, "left"); } function onOperator(operatorToken, _state, node) { - var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */; + var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken); var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(operatorToken.pos); - writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); } @@ -113497,11 +113935,11 @@ var ts; var parenthesizerRule = side === "left" ? parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, 1 /* EmitHint.Expression */, next); if (pipelinePhase === pipelineEmitWithSubstitution) { ts.Debug.assertIsDefined(lastSubstitution); next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); - pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, 1 /* EmitHint.Expression */, next); lastSubstitution = undefined; } if (pipelinePhase === pipelineEmitWithComments || @@ -113512,7 +113950,7 @@ var ts; } } currentParenthesizerRule = parenthesizerRule; - pipelinePhase(1 /* Expression */, next); + pipelinePhase(1 /* EmitHint.Expression */, next); } } function emitConditionalExpression(node) { @@ -113534,15 +113972,15 @@ var ts; } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* SyntaxKind.YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma); } function emitSpreadElement(node) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { @@ -113585,10 +114023,10 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineBlockStatements */ : 129 /* ListFormat.MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* ListFormat.MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -113614,16 +114052,16 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SyntaxKind.IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 239 /* IfStatement */) { + emitTokenWithComment(91 /* SyntaxKind.ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 239 /* SyntaxKind.IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -113633,14 +114071,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* SyntaxKind.WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* SyntaxKind.DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -113656,45 +114094,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* SyntaxKind.InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(160 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(160 /* SyntaxKind.OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { emit(node); } else { @@ -113703,12 +114141,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* SyntaxKind.ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* SyntaxKind.BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -113731,13 +114169,13 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 288 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function commentWillEmitNewLine(node) { - return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; + return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; } function willEmitLeadingNewLine(node) { if (!currentSourceFile) @@ -113777,40 +114215,40 @@ var ts; return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node)); } function emitReturnStatement(node) { - emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* SyntaxKind.ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* SyntaxKind.WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SyntaxKind.SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* SyntaxKind.ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* SyntaxKind.TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -113819,13 +114257,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* SyntaxKind.FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* SyntaxKind.DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -113841,7 +114279,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 528 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* ListFormat.VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -113858,7 +114296,7 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } @@ -113895,7 +114333,7 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (ts.getEmitFlags(body) & 1 /* SingleLine */) { + if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) { return true; } if (body.multiLine) { @@ -113904,14 +114342,14 @@ var ts; if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (getLeadingLineTerminatorCount(body, ts.firstOrUndefined(body.statements), 2 /* PreserveLines */) - || getClosingLineTerminatorCount(body, ts.lastOrUndefined(body.statements), 2 /* PreserveLines */, body.statements)) { + if (getLeadingLineTerminatorCount(body, ts.firstOrUndefined(body.statements), 2 /* ListFormat.PreserveLines */) + || getClosingLineTerminatorCount(body, ts.lastOrUndefined(body.statements), 2 /* ListFormat.PreserveLines */, body.statements)) { return false; } var previousStatement; for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { var statement = _b[_a]; - if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) { + if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) { return false; } previousStatement = statement; @@ -113928,7 +114366,7 @@ var ts; : emitBlockFunctionBodyWorker; emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); - writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* SyntaxKind.CloseBraceToken */, body.statements.end, writePunctuation, body); onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { @@ -113941,11 +114379,11 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* ListFormat.SingleLineFunctionBodyStatements */); increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); + emitList(body, body.statements, 1 /* ListFormat.MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -113959,15 +114397,15 @@ var ts; writeSpace(); emitIdentifierName(node.name); } - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); + emitList(node, node.heritageClauses, 0 /* ListFormat.ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* ClassMembers */); + emitList(node, node.members, 129 /* ListFormat.ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -113979,10 +114417,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 512 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* ListFormat.HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* InterfaceMembers */); + emitList(node, node.members, 129 /* ListFormat.InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -114004,13 +114442,13 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 145 /* EnumMembers */); + emitList(node, node.members, 145 /* ListFormat.EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 1024 /* GlobalAugmentation */) { - writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); + if (~node.flags & 1024 /* NodeFlags.GlobalAugmentation */) { + writeKeyword(node.flags & 16 /* NodeFlags.Namespace */ ? "namespace" : "module"); writeSpace(); } emit(node.name); @@ -114032,27 +114470,27 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 129 /* CaseBlockClauses */); - emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* ListFormat.CaseBlockClauses */); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -114061,12 +114499,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(156 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -114077,20 +114515,20 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -114101,37 +114539,37 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression, node.isExportEquals ? - parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* SyntaxKind.EqualsToken */) : parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(152 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(156 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -114141,10 +114579,10 @@ var ts; writeTrailingSemicolon(); } function emitAssertClause(node) { - emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(129 /* SyntaxKind.AssertKeyword */, node.pos, writeKeyword, node); writeSpace(); var elements = node.elements; - emitList(node, elements, 526226 /* ImportClauseEntries */); + emitList(node, elements, 526226 /* ListFormat.ImportClauseEntries */); } function emitAssertEntry(node) { emit(node.name); @@ -114152,26 +114590,26 @@ var ts; writeSpace(); var value = node.value; /** @see {emitPropertyAssignment} */ - if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(value) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(value); emitTrailingCommentsOfPosition(commentRange.pos); } emit(value); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(142 /* SyntaxKind.NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); } function emitNamespaceExport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -114183,7 +114621,7 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { @@ -114194,7 +114632,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -114213,7 +114651,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -114226,7 +114664,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -114255,7 +114693,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 262656 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* ListFormat.JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -114286,17 +114724,17 @@ var ts; if (isMultiline) { writer.increaseIndent(); } - var end = emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + var end = emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); emit(node.dotDotDotToken); emitExpression(node.expression); - emitTokenWithComment(19 /* CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); if (isMultiline) { writer.decreaseIndent(); } } } function emitJsxTagName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -114307,13 +114745,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* SyntaxKind.CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -114324,14 +114762,14 @@ var ts; ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 163969 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* ListFormat.CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 128 /* Indented */); + format &= ~(1 /* ListFormat.MultiLine */ | 128 /* ListFormat.Indented */); } else { - emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -114339,15 +114777,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 528 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* ListFormat.HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* SyntaxKind.CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -114367,7 +114805,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(initializer) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -114384,7 +114822,7 @@ var ts; } function emitSpreadAssignment(node) { if (node.expression) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } @@ -114415,12 +114853,12 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 343 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 343 /* SyntaxKind.JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } else { - emitList(node, node.tags, 33 /* JSDocComment */); + emitList(node, node.tags, 33 /* ListFormat.JSDocComment */); } } writeSpace(); @@ -114454,13 +114892,13 @@ var ts; emitJSDocTagName(tag.tagName); emitJSDocTypeExpression(tag.constraint); writeSpace(); - emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitList(tag, tag.typeParameters, 528 /* ListFormat.CommaListElements */); emitJSDocComment(tag.comment); } function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 309 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -114479,7 +114917,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 322 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 322 /* SyntaxKind.JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -114497,14 +114935,14 @@ var ts; emitJSDocComment(tag.comment); } function emitJSDocTypeLiteral(lit) { - emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* ListFormat.JSDocComment */); } function emitJSDocSignature(sig) { if (sig.typeParameters) { - emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* ListFormat.JSDocComment */); } if (sig.parameters) { - emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* ListFormat.JSDocComment */); } if (sig.type) { writeLine(); @@ -114585,21 +115023,21 @@ var ts; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -114607,28 +115045,28 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* BundleFileSectionKind.Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_23 = types; _d < types_23.length; _d++) { var directive = types_23[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* BundleFileSectionKind.Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */ : "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* BundleFileSectionKind.Lib */, data: directive.fileName }); writeLine(); } } @@ -114639,22 +115077,22 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* ListFormat.MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes function emitPartiallyEmittedExpression(node) { var emitFlags = ts.getEmitFlags(node); - if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) { + if (!(emitFlags & 512 /* EmitFlags.NoLeadingComments */) && node.pos !== node.expression.pos) { emitTrailingCommentsOfPosition(node.expression.pos); } emitExpression(node.expression); - if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) { + if (!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */) && node.end !== node.expression.end) { emitLeadingCommentsOfPosition(node.expression.end); } } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); + emitExpressionList(node, node.elements, 528 /* ListFormat.CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -114675,7 +115113,7 @@ var ts; var pos = writer.getTextPos(); emit(statement); if (recordBundleFileSection && bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.add(statement.expression.text); } @@ -114696,7 +115134,7 @@ var ts; var pos = writer.getTextPos(); emit(prologue); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: prologue.data }); if (seenPrologueDirectives) { seenPrologueDirectives.add(prologue.data); } @@ -114820,7 +115258,7 @@ var ts; textRange.pos = modifiers.pos; if (pos === modifiers.length - 1) textRange.end = modifiers.end; - emitNodeListItems(emit, node, modifiers, lastMode === "modifiers" ? 2359808 /* Modifiers */ : 2146305 /* Decorators */, + emitNodeListItems(emit, node, modifiers, lastMode === "modifiers" ? 2359808 /* ListFormat.Modifiers */ : 2146305 /* ListFormat.Decorators */, /*parenthesizerRule*/ undefined, start, pos - start, /*hasTrailingComma*/ false, textRange); start = pos; @@ -114831,7 +115269,7 @@ var ts; } } function emitModifiers(node, modifiers) { - emitList(node, modifiers, 2359808 /* Modifiers */); + emitList(node, modifiers, 2359808 /* ListFormat.Modifiers */); } function emitTypeAnnotation(node) { if (node) { @@ -114843,7 +115281,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node, parenthesizerRule); } @@ -114873,7 +115311,7 @@ var ts; } } function emitEmbeddedStatement(parent, node) { - if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* EmitFlags.SingleLine */) { writeSpace(); emit(node); } @@ -114881,7 +115319,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - pipelineEmit(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmitHint.EmbeddedStatement */, node); } else { emit(node); @@ -114890,19 +115328,19 @@ var ts; } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 2146305 /* Decorators */); + emitList(parentNode, decorators, 2146305 /* ListFormat.Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector); + emitList(parentNode, typeArguments, 53776 /* ListFormat.TypeArguments */, typeArgumentParenthesizerRuleSelector); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures return emitTypeArguments(parentNode, parentNode.typeArguments); } - emitList(parentNode, typeParameters, 53776 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* ListFormat.TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 2576 /* Parameters */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -114921,32 +115359,32 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */ & ~2048 /* ListFormat.Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* ListFormat.IndexSignatureParameters */); } function writeDelimiter(format) { - switch (format & 60 /* DelimitersMask */) { - case 0 /* None */: + switch (format & 60 /* ListFormat.DelimitersMask */) { + case 0 /* ListFormat.None */: break; - case 16 /* CommaDelimited */: + case 16 /* ListFormat.CommaDelimited */: writePunctuation(","); break; - case 4 /* BarDelimited */: + case 4 /* ListFormat.BarDelimited */: writeSpace(); writePunctuation("|"); break; - case 32 /* AsteriskDelimited */: + case 32 /* ListFormat.AsteriskDelimited */: writeSpace(); writePunctuation("*"); writeSpace(); break; - case 8 /* AmpersandDelimited */: + case 8 /* ListFormat.AmpersandDelimited */: writeSpace(); writePunctuation("&"); break; @@ -114962,16 +115400,16 @@ var ts; if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; - if (isUndefined && format & 16384 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* ListFormat.OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 32768 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* ListFormat.OptionalIfEmpty */) { onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); return; } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists @@ -114980,10 +115418,10 @@ var ts; onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { + if (format & 1 /* ListFormat.MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } - else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */ && !(format & 524288 /* ListFormat.NoSpaceIfEmpty */)) { writeSpace(); } } @@ -114991,7 +115429,7 @@ var ts; emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, children.hasTrailingComma, children); } onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } @@ -115005,18 +115443,18 @@ var ts; */ function emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, hasTrailingComma, childrenTextRange) { // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* ListFormat.NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format); if (leadingLineTerminatorCount) { writeLine(leadingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (format & 256 /* SpaceBetweenBraces */) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { increaseIndent(); } var emitListItem = getEmitListItem(emit, parenthesizerRule); @@ -115027,7 +115465,7 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. - if (format & 32 /* AsteriskDelimited */) { + if (format & 32 /* ListFormat.AsteriskDelimited */) { // always write JSDoc in the format "\n *" writeLine(); writeDelimiter(format); @@ -115039,7 +115477,7 @@ var ts; // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + if (format & 60 /* ListFormat.DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -115049,14 +115487,14 @@ var ts; if (separatingLineTerminatorCount > 0) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* ListFormat.LinesMask */ | 128 /* ListFormat.Indented */)) === 0 /* ListFormat.SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(separatingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* ListFormat.SpaceBetweenSiblings */) { writeSpace(); } } @@ -115079,11 +115517,11 @@ var ts; } // Write a trailing comma, if requested. var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; - var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* NoTrailingComments */); - var emitTrailingComma = hasTrailingComma && (format & 64 /* AllowTrailingComma */) && (format & 16 /* CommaDelimited */); + var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */); + var emitTrailingComma = hasTrailingComma && (format & 64 /* ListFormat.AllowTrailingComma */) && (format & 16 /* ListFormat.CommaDelimited */); if (emitTrailingComma) { if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(27 /* CommaToken */, previousSibling.end, writePunctuation, previousSibling); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, previousSibling.end, writePunctuation, previousSibling); } else { writePunctuation(","); @@ -115095,11 +115533,11 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* ListFormat.DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(emitTrailingComma && (childrenTextRange === null || childrenTextRange === void 0 ? void 0 : childrenTextRange.end) ? childrenTextRange.end : previousSibling.end); } // Decrease the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { decreaseIndent(); } recordBundleFileInternalSectionEnd(previousSourceFileTextKind); @@ -115108,7 +115546,7 @@ var ts; if (closingLineTerminatorCount) { writeLine(closingLineTerminatorCount); } - else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) { + else if (format & (2097152 /* ListFormat.SpaceAfterList */ | 256 /* ListFormat.SpaceBetweenBraces */)) { writeSpace(); } } @@ -115190,7 +115628,7 @@ var ts; return pos < 0 ? pos : pos + tokenString.length; } function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) { - if (ts.getEmitFlags(parentNode) & 1 /* SingleLine */) { + if (ts.getEmitFlags(parentNode) & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else if (preserveSourceNewlines) { @@ -115240,8 +115678,8 @@ var ts; } } function getLeadingLineTerminatorCount(parentNode, firstChild, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } if (firstChild === undefined) { @@ -115265,7 +115703,7 @@ var ts; // leading newline to start the modifiers. return 0; } - if (firstChild.kind === 11 /* JsxText */) { + if (firstChild.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } @@ -115282,14 +115720,14 @@ var ts; return 1; } } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { if (previousNode === undefined || nextNode === undefined) { return 0; } - if (nextNode.kind === 11 /* JsxText */) { + if (nextNode.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } @@ -115307,7 +115745,7 @@ var ts; } // If the two nodes are not comparable, add a line terminator based on the format that can indicate // whether new lines are preferred or not. - return format & 65536 /* PreferNewLine */ ? 1 : 0; + return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -115316,11 +115754,11 @@ var ts; else if (ts.getStartsOnNewLine(nextNode)) { return 1; } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getClosingLineTerminatorCount(parentNode, lastChild, format, childrenTextRange) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } if (lastChild === undefined) { @@ -115337,7 +115775,7 @@ var ts; return 1; } } - if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) { + if (format & 1 /* ListFormat.MultiLine */ && !(format & 131072 /* ListFormat.NoTrailingNewLine */)) { return 1; } return 0; @@ -115366,14 +115804,14 @@ var ts; return lines; } function writeLineSeparatorsAndIndentBefore(node, parent) { - var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, 0 /* None */); + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, 0 /* ListFormat.None */); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false); } return !!leadingNewlines; } function writeLineSeparatorsAfter(node, parent) { - var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, 0 /* None */, /*childrenTextRange*/ undefined); + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, 0 /* ListFormat.None */, /*childrenTextRange*/ undefined); if (trailingNewlines) { writeLine(trailingNewlines); } @@ -115382,14 +115820,14 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } function getLinesBetweenNodes(parent, node1, node2) { - if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + if (ts.getEmitFlags(parent) & 131072 /* EmitFlags.NoIndentation */) { return 0; } parent = skipSynthesizedParentheses(parent); @@ -115412,7 +115850,7 @@ var ts; && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node) { - while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -115440,29 +115878,29 @@ var ts; return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) { - if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); } } - var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0) - | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0) - | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0) - | (printerOptions.target && printerOptions.target === 99 /* ESNext */ ? 8 /* AllowNumericSeparator */ : 0); + var flags = (neverAsciiEscape ? 1 /* GetLiteralTextFlags.NeverAsciiEscape */ : 0) + | (jsxAttributeEscape ? 2 /* GetLiteralTextFlags.JsxAttributeEscape */ : 0) + | (printerOptions.terminateUnterminatedLiterals ? 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ : 0) + | (printerOptions.target && printerOptions.target === 99 /* ScriptTarget.ESNext */ ? 8 /* GetLiteralTextFlags.AllowNumericSeparator */ : 0); return ts.getLiteralText(node, currentSourceFile, flags); } /** * Push a new name generation scope. */ function pushNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlagsStack.push(tempFlags); @@ -115473,7 +115911,7 @@ var ts; * Pop the current name generation scope. */ function popNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlags = tempFlagsStack.pop(); @@ -115489,84 +115927,84 @@ var ts; if (!node) return; switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.forEach(node.statements, generateNames); break; - case 250 /* LabeledStatement */: - case 248 /* WithStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: generateNames(node.statement); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: generateNames(node.caseBlock); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: generateNames(node.declarationList); break; - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: generateNameIfNeeded(node.name); - if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: generateNames(node.importClause); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: generateNameIfNeeded(node.name); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: generateNameIfNeeded(node.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.forEach(node.elements, generateNames); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -115575,12 +116013,12 @@ var ts; if (!node) return; switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -115599,7 +116037,7 @@ var ts; * Generate the text for a generated identifier. */ function generateName(name) { - if ((name.autoGenerateFlags & 7 /* KindMask */) === 4 /* Node */) { + if ((name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) === 4 /* GeneratedIdentifierFlags.Node */) { // Node names generate unique names based on their original node // and are cached based on that node's id. return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags); @@ -115638,7 +116076,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */)) { return false; } } @@ -115652,7 +116090,7 @@ var ts; */ function makeTempVariableName(flags, reservedInNestedScopes) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + var name = flags === 268435456 /* TempFlags._i */ ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; if (reservedInNestedScopes) { @@ -115662,12 +116100,12 @@ var ts; } } while (true) { - var count = tempFlags & 268435455 /* CountMask */; + var count = tempFlags & 268435455 /* TempFlags.CountMask */; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { var name = count < 26 - ? "_" + String.fromCharCode(97 /* a */ + count) + ? "_" + String.fromCharCode(97 /* CharacterCodes.a */ + count) : "_" + (count - 26); if (isUniqueName(name)) { if (reservedInNestedScopes) { @@ -115699,7 +116137,7 @@ var ts; } } // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* CharacterCodes._ */) { baseName += "_"; } var i = 1; @@ -115753,48 +116191,48 @@ var ts; if (ts.isIdentifier(node.name)) { return generateNameCached(node.name); } - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } /** * Generates a unique name from a node. */ function generateNameForNode(node, flags) { switch (node.kind) { - case 79 /* Identifier */: - return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: + case 79 /* SyntaxKind.Identifier */: + return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(flags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return generateNameForExportDefault(); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return generateNameForClassExpression(); - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return generateNameForMethodOrAccessor(node); - case 162 /* ComputedPropertyName */: - return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); + case 162 /* SyntaxKind.ComputedPropertyName */: + return makeTempVariableName(0 /* TempFlags.Auto */, /*reserveInNestedScopes*/ true); default: - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } } /** * Generates a unique identifier for a node. */ function makeName(name) { - switch (name.autoGenerateFlags & 7 /* KindMask */) { - case 1 /* Auto */: - return makeTempVariableName(0 /* Auto */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 2 /* Loop */: - return makeTempVariableName(268435456 /* _i */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 3 /* Unique */: - return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); + switch (name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) { + case 1 /* GeneratedIdentifierFlags.Auto */: + return makeTempVariableName(0 /* TempFlags.Auto */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 2 /* GeneratedIdentifierFlags.Loop */: + return makeTempVariableName(268435456 /* TempFlags._i */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 3 /* GeneratedIdentifierFlags.Unique */: + return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* GeneratedIdentifierFlags.FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); } return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -115810,7 +116248,7 @@ var ts; // if "node" is a different generated name (having a different // "autoGenerateId"), use it and stop traversing. if (ts.isIdentifier(node) - && !!(node.autoGenerateFlags & 4 /* Node */) + && !!(node.autoGenerateFlags & 4 /* GeneratedIdentifierFlags.Node */) && node.autoGenerateId !== autoGenerateId) { break; } @@ -115821,7 +116259,7 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var pipelinePhase = getNextPipelinePhase(2 /* PipelinePhase.Comments */, hint, node); var savedContainerPos = containerPos; var savedContainerEnd = containerEnd; var savedDeclarationListContainerEnd = declarationListContainerEnd; @@ -115834,7 +116272,7 @@ var ts; var commentRange = ts.getCommentRange(node); // Emit leading comments emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = true; } } @@ -115842,7 +116280,7 @@ var ts; var emitFlags = ts.getEmitFlags(node); var commentRange = ts.getCommentRange(node); // Emit trailing comments - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = false; } emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); @@ -115856,25 +116294,25 @@ var ts; hasWrittenComment = false; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; // Save current container state on the stack. if ((pos > 0 || end > 0) && pos !== end) { // Emit leading comments if the position is not synthesized and the node // has not opted out from emitting leading comments. if (!skipLeadingComments) { - emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */); } - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. containerPos = pos; } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* NoTrailingComments */) !== 0)) { + if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) { // As above. containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -115884,7 +116322,7 @@ var ts; } function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -115893,18 +116331,18 @@ var ts; declarationListContainerEnd = savedDeclarationListContainerEnd; // Emit trailing comments if the position is not synthesized and the node // has not opted out from emitting leading comments and is an emitted node. - if (!skipTrailingComments && node.kind !== 349 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 349 /* SyntaxKind.NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); } function emitLeadingSynthesizedComment(comment) { - if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasLeadingNewline || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasTrailingNewLine || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } else { @@ -115922,25 +116360,25 @@ var ts; } function writeSynthesizedComment(comment) { var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + var lineMap = comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); } function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; + return comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); var pos = detachedRange.pos, end = detachedRange.end; var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0; + var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0; if (!skipLeadingComments) { emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); } exitComment(); - if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */ && !commentsDisabled) { commentsDisabled = true; emitCallback(node); commentsDisabled = false; @@ -116029,7 +116467,7 @@ var ts; if (hasTrailingNewLine) { writer.writeLine(); } - else if (kind === 3 /* MultiLineCommentTrivia */) { + else if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { writer.writeSpace(" "); } } @@ -116071,7 +116509,7 @@ var ts; emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); - if (kind === 2 /* SingleLineCommentTrivia */) { + if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); // still write a newline for single-line comments, so closing tokens aren't written on the same line } } @@ -116156,7 +116594,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMaps(hint, node) { - var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); + var pipelinePhase = getNextPipelinePhase(3 /* PipelinePhase.SourceMaps */, hint, node); emitSourceMapsBeforeNode(node); pipelinePhase(hint, node); emitSourceMapsAfterNode(node); @@ -116174,12 +116612,12 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 16 /* EmitFlags.NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = true; } } @@ -116189,11 +116627,11 @@ var ts; var sourceMapRange = ts.getSourceMapRange(node); // Emit trailing sourcemap if (!ts.isUnparsedNode(node)) { - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 32 /* EmitFlags.NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } @@ -116246,17 +116684,17 @@ var ts; return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; + var emitFlags = emitNode && emitNode.flags || 0 /* EmitFlags.None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; var source = range && range.source || sourceMapSource; tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 128 /* EmitFlags.NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } tokenPos = emitCallback(token, writer, tokenPos); if (range) tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 256 /* EmitFlags.NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } return tokenPos; @@ -116287,23 +116725,23 @@ var ts; sourceMapSourceIndex = sourceIndex; } function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Extension.Json */); } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[1024 /* Braces */] = ["{", "}"]; - brackets[2048 /* Parenthesis */] = ["(", ")"]; - brackets[4096 /* AngleBrackets */] = ["<", ">"]; - brackets[8192 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* ListFormat.Braces */] = ["{", "}"]; + brackets[2048 /* ListFormat.Parenthesis */] = ["(", ")"]; + brackets[4096 /* ListFormat.AngleBrackets */] = ["<", ">"]; + brackets[8192 /* ListFormat.SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 15360 /* BracketsMask */][0]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 15360 /* BracketsMask */][1]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -116669,7 +117107,7 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; @@ -116678,11 +117116,11 @@ var ts; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) @@ -116704,9 +117142,9 @@ var ts; var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; - if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) || - hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + if (hasSourceFile((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + hasSourceFile((filePathWithoutExtension + ".tsx" /* Extension.Tsx */))) { + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -116739,7 +117177,7 @@ var ts; ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop); var plainInvokeFactory = { watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); }, - watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options); }, + watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* WatchDirectoryFlags.Recursive */) !== 0, options); }, }; var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ? { @@ -116774,36 +117212,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -116813,16 +117251,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -117003,7 +117441,7 @@ var ts; if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output // Cache json or buildInfo - if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { + if (!ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -117014,7 +117452,7 @@ var ts; if (value) return value; var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); - if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */))) { + if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) { sourceFileCache.set(key, sourceFile); } return sourceFile; @@ -117104,12 +117542,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -117197,9 +117635,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -117213,7 +117651,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -117276,7 +117714,7 @@ var ts; var mode = getModeForFileReference(name, containingFileMode); // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -117392,7 +117830,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -117571,22 +118009,33 @@ var ts; * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format */ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { + var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options); + return typeof result === "object" ? result.impliedNodeFormat : result; + } + ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + /*@internal*/ + function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: - return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext : - ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS : - ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : + return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ts.ModuleKind.ESNext : + ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ts.ModuleKind.CommonJS : + ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Extension.Dts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */]) ? lookupFromPackageJson() : undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline default: return undefined; } function lookupFromPackageJson() { - var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options); - return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options); + var packageJsonLocations = []; + state.failedLookupLocations = packageJsonLocations; + state.affectingLocations = packageJsonLocations; + var packageJsonScope = ts.getPackageScopeForPath(fileName, state); + var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope }; } } - ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker; /** @internal */ ts.plainJSErrors = new ts.Set([ // binder errors @@ -117734,7 +118183,7 @@ var ts; var modulesWithElidedImports = new ts.Map(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = new ts.Map(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -117815,16 +118264,16 @@ var ts; forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists; var readFile = host.readFile.bind(host); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structureIsReused; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { @@ -117852,7 +118301,7 @@ var ts; var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); }); for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) { var fileName = _c[_b]; - if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index }); } } @@ -117861,13 +118310,13 @@ var ts; }); } } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferences", { count: typeReferences.length }); // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); @@ -117911,7 +118360,7 @@ var ts; for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { var oldSourceFile = oldSourceFiles_1[_i]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); - if (shouldCreateNewSourceFile || !newFile || + if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || // old file wasn't redirect but new file is (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); @@ -118001,9 +118450,9 @@ var ts; // Add file processingDiagnostics fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) { switch (diagnostic.kind) { - case 1 /* FilePreprocessingFileExplainingDiagnostic */: + case 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */: return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray)); - case 0 /* FilePreprocessingReferencedDiagnostic */: + case 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */: var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end; return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false))); default: @@ -118054,7 +118503,7 @@ var ts; return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); @@ -118069,7 +118518,7 @@ var ts; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode); ts.performance.mark("afterResolveTypeReference"); @@ -118151,7 +118600,7 @@ var ts; return classifiableNames; } function resolveModuleNamesReusingOldState(moduleNames, file) { - if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { + if (structureIsReused === 0 /* StructureIsReused.Not */ && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); @@ -118248,7 +118697,7 @@ var ts; // `result[i]` is either a `ResolvedModuleFull` or a marker. // If it is the former, we can leave it as is. if (result[i] === predictedToResolveToAmbientModuleMarker) { - result[i] = undefined; // TODO: GH#18217 + result[i] = undefined; } } else { @@ -118304,24 +118753,24 @@ var ts; }); } function tryReuseStructureFromOldProgram() { - var _a; + var _a, _b; if (!oldProgram) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); if (ts.changesAffectModuleResolution(oldOptions, options)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // there is an old program, check if we can reuse its structure var oldRootNames = oldProgram.getRootFileNames(); if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); @@ -118329,12 +118778,12 @@ var ts; // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; var modifiedSourceFiles = []; - structureIsReused = 2 /* Completely */; + structureIsReused = 2 /* StructureIsReused.Completely */; // If the missing file paths are now present, it can change the progam structure, // and hence cant reuse the structure. // This is same as how we dont reuse the structure if one of the file from old program is now missing if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } var oldSourceFiles = oldProgram.getSourceFiles(); var SeenPackageName; @@ -118345,12 +118794,15 @@ var ts; var seenPackageNames = new ts.Map(); for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { var oldSourceFile = oldSourceFiles_2[_i]; + var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options); var newSourceFile = host.getSourceFileByPath - ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 + ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat) + : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217 if (!newSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } + newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope; ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; if (oldSourceFile.redirectInfo) { @@ -118358,7 +118810,7 @@ var ts; // This lets us know if the unredirected file has changed. If it has we should break the redirect. if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { // Underlying file has changed. Might not redirect anymore. Must rebuild program. - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; newSourceFile = oldSourceFile; // Use the redirect. @@ -118366,7 +118818,7 @@ var ts; else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) { // If a redirected-to source file changes, the redirect may be broken. if (newSourceFile !== oldSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; } @@ -118383,80 +118835,85 @@ var ts; // If there are 2 different source files for the same package name and at least one of them changes, // they might become redirects. So we must rebuild the program. var prevKind = seenPackageNames.get(packageName); - var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; - if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { - return 0 /* Not */; + var newKind = fileChanged ? 1 /* SeenPackageName.Modified */ : 0 /* SeenPackageName.Exists */; + if ((prevKind !== undefined && newKind === 1 /* SeenPackageName.Modified */) || prevKind === 1 /* SeenPackageName.Modified */) { + return 0 /* StructureIsReused.Not */; } seenPackageNames.set(packageName, newKind); } if (fileChanged) { + if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) { + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } // The `newSourceFile` object was created for the new program. - if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check tripleslash references - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - structureIsReused = 1 /* SafeModules */; - } - // check imports and module augmentations - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { - // imports has changed - structureIsReused = 1 /* SafeModules */; - } - if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { - // moduleAugmentations has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) { - // dynamicImport has changed - structureIsReused = 1 /* SafeModules */; - } - if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { - // 'types' references has changed - structureIsReused = 1 /* SafeModules */; + else { + // check imports and module augmentations + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + // moduleAugmentations has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if ((oldSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */)) { + // dynamicImport has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { + // 'types' references has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else if (hasInvalidatedResolution(oldSourceFile.path)) { // 'module/types' references could have changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; // add file to the modified list so that we will resolve it later modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); - for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) { - var oldFile = oldSourceFiles_3[_b]; + for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) { + var oldFile = oldSourceFiles_3[_c]; if (!ts.contains(modifiedFiles, oldFile)) { - for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) { - var moduleName = _d[_c]; + for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) { + var moduleName = _e[_d]; ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); } } } // try to verify results of module resolution - for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) { - var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile; + for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) { + var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile; var moduleNames = getModuleNames(newSourceFile); var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile); // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions); } else { @@ -118467,24 +118924,24 @@ var ts; // ensure that types resolutions are still correct var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo); if (typeReferenceResolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } - if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { - return 1 /* SafeModules */; + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) { + return 1 /* StructureIsReused.SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length); - for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) { - var newSourceFile = newSourceFiles_1[_g]; + for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) { + var newSourceFile = newSourceFiles_1[_h]; filesByName.set(newSourceFile.path, newSourceFile); } var oldFilesByNameMap = oldProgram.getFilesByNameMap(); @@ -118509,7 +118966,7 @@ var ts; sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules; - return 2 /* Completely */; + return 2 /* StructureIsReused.Completely */; } function getEmitHost(writeFileCallback) { return { @@ -118554,7 +119011,7 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -118606,7 +119063,7 @@ var ts; return typeChecker || (typeChecker = ts.createTypeChecker(program)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -118726,7 +119183,7 @@ var ts; } var typeChecker = getTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); - var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */; + var isJs = sourceFile.scriptKind === 1 /* ScriptKind.JS */ || sourceFile.scriptKind === 2 /* ScriptKind.JSX */; var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options); var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs); var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; @@ -118734,8 +119191,8 @@ var ts; // - plain JS: .js files with no // ts-check and checkJs: undefined // - check JS: .js files with either // ts-check or checkJs: true // - external: files that are added by plugins - var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ - || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* ScriptKind.TS */ || sourceFile.scriptKind === 4 /* ScriptKind.TSX */ + || sourceFile.scriptKind === 5 /* ScriptKind.External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* ScriptKind.Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; if (isPlainJs) { @@ -118814,22 +119271,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 254 /* VariableDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 254 /* SyntaxKind.VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -118837,65 +119294,65 @@ var ts; } } switch (node.kind) { - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type")); return "skip"; } break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: var heritageClause = node; - if (heritageClause.token === 117 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 258 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* SyntaxKind.InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 261 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */); + case 261 /* SyntaxKind.ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* NodeFlags.Namespace */ ? ts.tokenToString(142 /* SyntaxKind.NamespaceKeyword */) : ts.tokenToString(141 /* SyntaxKind.ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 260 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); + case 260 /* SyntaxKind.EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* SyntaxKind.EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -118904,53 +119361,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 237 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 237 /* SyntaxKind.VariableStatement */); return "skip"; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (ts.isModifier(modifier) && modifier.kind !== 124 /* StaticKeyword */) { + if (ts.isModifier(modifier) && modifier.kind !== 124 /* SyntaxKind.StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers && ts.some(nodes, ts.isModifier)) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 210 /* TaggedTemplateExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -118963,27 +119420,27 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 135 /* DeclareKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 124 /* StaticKeyword */: - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: } } } @@ -119053,20 +119510,20 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 79 /* Identifier */ - ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 10 /* StringLiteral */ && a.text === b.text; + return a.kind === 79 /* SyntaxKind.Identifier */ + ? b.kind === 79 /* SyntaxKind.Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* SyntaxKind.StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); var importDecl = ts.factory.createImportDeclaration(/*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); - ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(importDecl, 67108864 /* EmitFlags.NeverApplyImportHelper */); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); // explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them // (which is required to build the dependency graph for incremental emit) - externalHelpersModuleReference.flags &= ~8 /* Synthesized */; - importDecl.flags &= ~8 /* Synthesized */; + externalHelpersModuleReference.flags &= ~8 /* NodeFlags.Synthesized */; + importDecl.flags &= ~8 /* NodeFlags.Synthesized */; return externalHelpersModuleReference; } function collectExternalModuleReferences(file) { @@ -119097,7 +119554,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -119119,7 +119576,7 @@ var ts; } } else if (ts.isModuleDeclaration(node)) { - if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) { node.name.parent = node; var nameText = ts.getTextOfIdentifierOrLiteral(node.name); // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -119174,7 +119631,7 @@ var ts; function getNodeAtPosition(sourceFile, position) { var current = sourceFile; var getContainingChild = function (child) { - if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* EndOfFileToken */)))) { + if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) { return child; } }; @@ -119267,13 +119724,16 @@ var ts; addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]); } } - function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) { + var _a; var redirect = Object.create(redirectTarget); redirect.fileName = fileName; redirect.path = path; redirect.resolvedPath = resolvedPath; redirect.originalFileName = originalFileName; redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + redirect.packageJsonScope = sourceFileOptions.packageJsonScope; sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); Object.defineProperties(redirect, { id: { @@ -119289,7 +119749,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], @@ -119302,14 +119762,14 @@ var ts; // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront. - var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); - return { - languageVersion: ts.getEmitScriptTarget(options), - impliedNodeFormat: impliedNodeFormat, - setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options) - }; + var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); + var languageVersion = ts.getEmitScriptTarget(options); + var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options); + return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) : + { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator }; } function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { + var _a, _b; var path = toPath(fileName); if (useSourceOfProjectReferenceRedirect) { var source = getSourceOfProjectReferenceRedirect(path); @@ -119396,14 +119856,15 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile); + var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options); + var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat)); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. // Instead of creating a duplicate, just redirect to the existing one. - var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217 + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions); redirectTargetsMap.add(fileFromPackageId.path, fileName); addFileToFilesByName(dupFile, path, redirectedPath); addFileIncludeReason(dupFile, reason); @@ -119424,6 +119885,8 @@ var ts; file.path = path; file.resolvedPath = toPath(fileName); file.originalFileName = originalFileName; + file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined; + file.packageJsonScope = sourceFileOptions.packageJsonScope; addFileIncludeReason(file, reason); if (host.useCaseSensitiveFileNames()) { var pathLowerCase = ts.toFileNameLowerCase(path); @@ -119474,7 +119937,7 @@ var ts; } function getProjectReferenceRedirectProject(fileName) { // Ignore dts or any json files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -119484,7 +119947,7 @@ var ts; function getProjectReferenceOutputName(referencedProject, fileName) { var out = ts.outFile(referencedProject.commandLine.options); return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.changeExtension(out, ".d.ts" /* Extension.Dts */) : ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames()); } /** @@ -119517,13 +119980,13 @@ var ts; var out = ts.outFile(resolvedRef.commandLine.options); if (out) { // Dont know which source file it means so return true? - var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + var outputDts = ts.changeExtension(out, ".d.ts" /* Extension.Dts */); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); } else { var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); }); ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -119569,7 +120032,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -119628,7 +120091,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -119648,7 +120111,7 @@ var ts; var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 0 /* FilePreprocessingReferencedDiagnostic */, + kind: 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */, reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }, diagnostic: diagnostic, args: [libName, suggestion] @@ -119695,7 +120158,7 @@ var ts; && index < file.imports.length && !elideImport && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) - && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */)); + && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* NodeFlags.JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -119756,7 +120219,7 @@ var ts; else { // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); - sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + sourceFile = host.getSourceFile(refPath, 100 /* ScriptTarget.JSON */); addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { projectReferenceRedirects.set(sourceFilePath, false); @@ -119896,19 +120359,19 @@ var ts; var languageVersion = ts.getEmitScriptTarget(options); var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ScriptTarget.ES2015 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } if (options.preserveConstEnums === false) { createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules"); } - var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* ScriptKind.JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName))); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ScriptTarget.ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -119947,7 +120410,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + if (options.useDefineForClassFields && languageVersion === 0 /* ScriptTarget.ES3 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !ts.getAllowJSCompilerOption(options)) { @@ -119969,7 +120432,7 @@ var ts; if (options.reactNamespace) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { @@ -119983,7 +120446,7 @@ var ts; if (!options.jsxFactory) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { @@ -119991,12 +120454,12 @@ var ts; } } if (options.reactNamespace) { - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx)); } } if (options.jsxImportSource) { - if (options.jsx === 2 /* React */) { + if (options.jsx === 2 /* JsxEmit.React */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); } } @@ -120054,7 +120517,7 @@ var ts; fileIncludeReasons = undefined; var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason); var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon); - var redirectInfo = file && ts.explainIfFileIsRedirect(file); + var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file); var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false)); return location && isReferenceFileLocation(location) ? ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : @@ -120075,7 +120538,7 @@ var ts; } function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) { (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 1 /* FilePreprocessingFileExplainingDiagnostic */, + kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */, file: file && file.path, fileProcessingReason: fileProcessingReason, diagnostic: diagnostic, @@ -120314,7 +120777,7 @@ var ts; // If options have --outFile or --out just check that var out = ts.outFile(options); if (out) { - return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); + return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Extension.Dts */); } // If declarationDir is specified, return if its a file in that directory if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { @@ -120327,13 +120790,13 @@ var ts; if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || - !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Extension.Tsx */)); } return false; } function isSameFile(file1, file2) { - return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; } function getSymlinkCache() { if (host.getSymlinkCache) { @@ -120434,12 +120897,12 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || // Any parent directory of declaration dir ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || // Any directory inside declaration dir - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -120492,7 +120955,7 @@ var ts; if (isFile && result) { // Store the real path for the file' var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -120588,17 +121051,17 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ".tsx" /* Extension.Tsx */: return needJsx(); - case ".jsx" /* Jsx */: + case ".jsx" /* Extension.Jsx */: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ".js" /* Extension.Js */: return needAllowJs(); - case ".json" /* Json */: + case ".json" /* Extension.Json */: return needResolveJsonModule(); } function needJsx() { @@ -120617,7 +121080,7 @@ var ts; var res = imports.map(function (i) { return i.text; }); for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { var aug = moduleAugmentations_1[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -120632,7 +121095,7 @@ var ts; var augIndex = imports.length; for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) { var aug = moduleAugmentations_2[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { if (index === augIndex) return aug; augIndex++; @@ -120648,8 +121111,8 @@ var ts; (function (ts) { function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit; - return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; + var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics; + return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); } @@ -120873,23 +121336,23 @@ var ts; /** * Gets the files affected by the path from the program */ - function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var _a, _b; - var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash); + var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName); (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear(); (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); return result; } BuilderState.getFilesAffectedBy = getFilesAffectedBy; - function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var sourceFile = programOfThisState.getSourceFileByPath(path); if (!sourceFile) { return ts.emptyArray; } - if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) { + if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) { return [sourceFile]; } - return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash); + return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName); } BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState; function updateSignatureOfFile(state, signature, path) { @@ -120900,7 +121363,7 @@ var ts; /** * Returns if the shape of the signature has changed since last emit */ - function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) { + function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) { var _a; if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; } // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate @@ -120910,18 +121373,16 @@ var ts; var prevSignature = info.signature; var latestSignature; if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) { - var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, - /*emitOnlyDtsFiles*/ true, cancellationToken, - /*customTransformers*/ undefined, - /*forceDtsEmit*/ true); - var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); - if (firstDts_1) { - ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); - latestSignature = computeSignature(firstDts_1.text, computeHash); + programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) { + ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: ".concat(fileName)); + latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data); if (latestSignature !== prevSignature) { - updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit); + updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit); } - } + }, cancellationToken, + /*emitOnlyDtsFiles*/ true, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); } // Default is to use file version as signature if (latestSignature === undefined) { @@ -120944,10 +121405,6 @@ var ts; return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; - function computeSignature(text, computeHash) { - return (computeHash || ts.generateDjb2Hash)(text); - } - BuilderState.computeSignature = computeSignature; /** * Coverts the declaration emit result into exported modules map */ @@ -121097,7 +121554,7 @@ var ts; /** * When program emits modular code, gets the files affected by the sourceFile whose shape has changed */ - function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) { + function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) { if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } @@ -121117,7 +121574,7 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath); seenFileNamesMap.set(currentPath, currentSourceFile); - if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) { + if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) { queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath)); } } @@ -121157,7 +121614,7 @@ var ts; state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature; } state.changedFilesSet = new ts.Set(); - state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined; + state.latestChangedDtsFile = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.latestChangedDtsFile : undefined; var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && @@ -121228,7 +121685,7 @@ var ts; } else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); }); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* BuilderFileEmit.Full */); }); ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } @@ -121281,7 +121738,7 @@ var ts; programEmitComplete: state.programEmitComplete, emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: state.latestChangedDtsFile, hasChangedEmitSignature: state.hasChangedEmitSignature, changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined, }; @@ -121294,7 +121751,7 @@ var ts; state.programEmitComplete = savedEmitState.programEmitComplete; state.emitSignatures = savedEmitState.emitSignatures; state.outSignature = savedEmitState.outSignature; - state.dtsChangeTime = savedEmitState.dtsChangeTime; + state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile; state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature; if (savedEmitState.changedFilesSet) state.changedFilesSet = savedEmitState.changedFilesSet; @@ -121311,7 +121768,7 @@ var ts; * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained */ - function getNextAffectedFile(state, cancellationToken, computeHash, host) { + function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; while (true) { var affectedFiles = state.affectedFiles; @@ -121323,7 +121780,7 @@ var ts; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { // Set the next affected file as seen and remove the cached semantic diagnostics state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); return affectedFile; } affectedFilesIndex++; @@ -121351,7 +121808,7 @@ var ts; return program; } // Get next batch of affected files - state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash); + state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName); state.currentChangedFilePath = nextKey.value; state.affectedFilesIndex = 0; if (!state.seenAffectedFiles) @@ -121402,7 +121859,7 @@ var ts; * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { @@ -121410,18 +121867,18 @@ var ts; // When a change affects the global scope, all files are considered to be affected without updating their signature // That means when affected file is handled, its signature can be out of date // To avoid this, ensure that we update the signature for any affected file in this scenario. - ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash); + ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName); return; } if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) return; - handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); } /** * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, * Also we need to make sure signature is updated for these files */ - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); @@ -121432,10 +121889,10 @@ var ts; // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. - ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); + addToAffectedFilesPendingEmit(state, path, 0 /* BuilderFileEmit.DtsOnly */); } } } @@ -121457,20 +121914,20 @@ var ts; var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } - function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) return false; // Every file needs to be handled ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined) - .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); }); removeDiagnosticsOfLibraryFiles(state); return true; } /** * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit */ - function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit @@ -121488,9 +121945,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host)) return; - handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -121502,11 +121959,11 @@ var ts; // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; var references = state.referencedMap.getKeys(exportedFromPath); return references && ts.forEachKey(references, function (filePath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); }); } @@ -121514,22 +121971,22 @@ var ts; * handle dts and semantic diagnostics on file and iterate on anything that exports this file * return true when all work is done and we can exit handling dts emit and semantic diagnostics */ - function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) return undefined; - if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; - handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host); // If exported modules has path, all files referencing file exported from are affected (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); // Remove diagnostics of files that import this file (without going to exports of referencing files) (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal - state, referencingFilePath, cancellationToken, computeHash, host); + state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host); }); return undefined; } @@ -121608,14 +122065,14 @@ var ts; /** * Gets the program information to be emitted in buildInfo so that we can use it to create new program */ - function getProgramBuildInfo(state, getCanonicalFileName, host) { + function getProgramBuildInfo(state, getCanonicalFileName) { var outFilePath = ts.outFile(state.compilerOptions); if (outFilePath && !state.compilerOptions.composite) return; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - // Update the dtsChange time in buildInfo - state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime; + // Convert the file name to Path here if we set the fileName instead to optimize multiple d.ts file emits and having to compute Canonical path + var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined; if (outFilePath) { var fileNames_1 = []; var fileInfos_1 = []; @@ -121631,7 +122088,7 @@ var ts; fileInfos: fileInfos_1, options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result_15; } @@ -121733,7 +122190,7 @@ var ts; affectedFilesPendingEmit: affectedFilesPendingEmit, changeFileSet: changeFileSet, emitSignatures: emitSignatures, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result; function relativeToBuildInfoEnsuringAbsolutePath(path) { @@ -121848,8 +122305,39 @@ var ts; return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray }; } ts.getBuilderCreationParameters = getBuilderCreationParameters; - function computeSignature(text, data, computeHash) { - return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash); + function getTextHandlingSourceMapForSignature(text, data) { + return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text; + } + function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) { + var _a; + text = getTextHandlingSourceMapForSignature(text, data); + var sourceFileDirectory; + if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) { + text += data.diagnostics.map(function (diagnostic) { + return "".concat(locationInfo(diagnostic)).concat(ts.DiagnosticCategory[diagnostic.category]).concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText)); + }).join("\n"); + } + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text); + function flattenDiagnosticMessageText(diagnostic) { + return ts.isString(diagnostic) ? + diagnostic : + diagnostic === undefined ? + "" : + !diagnostic.next ? + diagnostic.messageText : + diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n"); + } + function locationInfo(diagnostic) { + if (diagnostic.file.resolvedPath === sourceFile.resolvedPath) + return "(".concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + if (sourceFileDirectory === undefined) + sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath); + return "".concat(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)), "(").concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + } + } + ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics; + function computeSignature(text, computeHash, data) { + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data)); } ts.computeSignature = computeSignature; function createBuilderProgram(kind, _a) { @@ -121870,7 +122358,7 @@ var ts; */ var computeHash = ts.maybeBind(host, host.createHash); var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); - newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); }; + newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); }; // To ensure that we arent storing any references to old program or new program without state newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; @@ -121880,6 +122368,7 @@ var ts; builderProgram.getState = getState; builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); }; builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); }; + builderProgram.hasChangedEmitSignature = function () { return !!state.hasChangedEmitSignature; }; builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); }; builderProgram.getSemanticDiagnostics = getSemanticDiagnostics; builderProgram.emit = emit; @@ -121910,8 +122399,8 @@ var ts; * in that order would be used to write the files */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); - var emitKind = 1 /* Full */; + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); + var emitKind = 1 /* BuilderFileEmit.Full */; var isPendingEmitFile = false; if (!affected) { if (!ts.outFile(state.compilerOptions)) { @@ -121924,7 +122413,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* BuilderFileEmit.Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } @@ -121943,36 +122432,39 @@ var ts; // Otherwise just affected file ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ? getWriteFileCallback(writeFile, customTransformers) : - writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } function getWriteFileCallback(writeFile, customTransformers) { return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f, _g; if (ts.isDeclarationFileName(fileName)) { if (!ts.outFile(state.compilerOptions)) { ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); - var newSignature = void 0; + var emitSignature = void 0; if (!customTransformers) { var file = sourceFiles[0]; var info = state.fileInfos.get(file.resolvedPath); if (info.signature === file.version) { - newSignature = computeSignature(text, data, computeHash); - if (newSignature !== file.version) { // Update it + var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data); + // With d.ts diagnostics they are also part of the signature so emitSignature will be different from it since its just hash of d.ts + if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length)) + emitSignature = signature; + if (signature !== file.version) { // Update it if (host.storeFilesChangingSignatureDuringEmit) - (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); if (state.exportedModulesMap) ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit); if (state.affectedFiles) { // Keep old signature so we know what to undo if cancellation happens - var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath); + var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath); if (existing === undefined) - (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); - info.signature = newSignature; + ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); + info.signature = signature; } else { // These are directly commited - info.signature = newSignature; - (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); + info.signature = signature; + (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear(); } } } @@ -121982,20 +122474,24 @@ var ts; // and would need their d.ts change time in --build mode if (state.compilerOptions.composite) { var filePath = sourceFiles[0].resolvedPath; - var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath); - newSignature || (newSignature = computeSignature(text, data, computeHash)); - if (newSignature !== oldSignature) { - (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature); - state.hasChangedEmitSignature = true; - } + var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath); + emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data)); + // Dont write dts files if they didn't change + if (emitSignature === oldSignature) + return; + ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature); + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } else if (state.compilerOptions.composite) { - var newSignature = computeSignature(text, data, computeHash); - if (newSignature !== state.outSignature) { - state.outSignature = newSignature; - state.hasChangedEmitSignature = true; - } + var newSignature = computeSignature(text, computeHash, data); + // Dont write dts files if they didn't change + if (newSignature === state.outSignature) + return; + state.outSignature = newSignature; + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } if (writeFile) @@ -122055,7 +122551,7 @@ var ts; // If every file pending emit is pending on only dts emit || ts.every(state.affectedFilesPendingEmit, function (path, index) { return index < state.affectedFilesPendingEmitIndex || - state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */; + state.affectedFilesPendingEmitKind.get(path) === 0 /* BuilderFileEmit.DtsOnly */; })) { clearAffectedFilesPendingEmit(state); } @@ -122071,7 +122567,7 @@ var ts; */ function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); if (!affected) { // Done return undefined; @@ -122083,7 +122579,7 @@ var ts; // Add file to affected file pending emit to handle for later emit time // Apart for emit builder do this for tsbuildinfo, do this for non emit builder when noEmit is set as tsbuildinfo is written and reused between emitters if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) { - addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* Full */); + addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* BuilderFileEmit.Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -122158,11 +122654,12 @@ var ts; var state; var filePaths; var filePathsSetList; + var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined; if (isProgramBundleEmitBuildInfo(program)) { state = { fileInfos: new ts.Map(), compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, outSignature: program.outSignature, }; } @@ -122195,7 +122692,7 @@ var ts; affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)), - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined, }; } @@ -122222,6 +122719,7 @@ var ts; getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, emitBuildInfo: ts.notImplemented, close: ts.noop, + hasChangedEmitSignature: ts.returnFalse, }; function toPath(path) { return ts.toPath(path, buildInfoDirectory, getCanonicalFileName); @@ -122324,7 +122822,7 @@ var ts; * "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot" * @param dirPath */ - function canWatchDirectory(dirPath) { + function canWatchDirectoryOrFile(dirPath) { var rootLength = ts.getRootLength(dirPath); if (dirPath.length === rootLength) { // Ignore "/", "c:/" @@ -122336,7 +122834,7 @@ var ts; return false; } var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); - var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */; if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart @@ -122361,7 +122859,7 @@ var ts; } return true; } - ts.canWatchDirectory = canWatchDirectory; + ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; var filesWithInvalidatedResolutions; @@ -122370,7 +122868,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolutionsWithOnlyAffectingLocations = []; var resolvedFileToResolution = ts.createMultiMap(); + var impliedFormatPackageJsons = new ts.Map(); var hasChangedAutomaticTypeDirectiveNames = false; + var affectingPathChecksForFile; var affectingPathChecks; var failedLookupChecks; var startsWithPathChecks; @@ -122395,7 +122895,7 @@ var ts; * This helps in not having to comb through all resolutions when files are added/removed * Note that .d.ts file also has .d.ts extension hence will be part of default extensions */ - var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; + var failedLookupDefaultExtensions = [".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); var fileWatchesOfAffectingLocations = new ts.Map(); @@ -122410,7 +122910,7 @@ var ts; finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions, // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) - startCachingPerDirectoryResolution: clearPerDirectoryResolutions, + startCachingPerDirectoryResolution: startCachingPerDirectoryResolution, finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution, resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, @@ -122454,9 +122954,10 @@ var ts; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; affectingPathChecks = undefined; - // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update - // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) - clearPerDirectoryResolutions(); + affectingPathChecksForFile = undefined; + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); + impliedFormatPackageJsons.clear(); hasChangedAutomaticTypeDirectiveNames = false; } function startRecordingFilesWithChangedResolutions() { @@ -122488,15 +122989,44 @@ var ts; return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } - function clearPerDirectoryResolutions() { - moduleResolutionCache.clear(); - typeReferenceDirectiveResolutionCache.clear(); + function startCachingPerDirectoryResolution() { + moduleResolutionCache.clearAllExceptPackageJsonInfoCache(); + typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache(); + // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update + // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } - function finishCachingPerDirectoryResolution() { + function finishCachingPerDirectoryResolution(newProgram, oldProgram) { filesWithInvalidatedNonRelativeUnresolvedImports = undefined; - clearPerDirectoryResolutions(); + nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); + nonRelativeExternalModuleResolutions.clear(); + // Update file watches + if (newProgram !== oldProgram) { + newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) { + var _a, _b, _c; + var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0; + var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray; + for (var i = existing.length; i < expected; i++) { + createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false); + } + if (existing.length > expected) { + for (var i = expected; i < existing.length; i++) { + fileWatchesOfAffectingLocations.get(existing[i]).files--; + } + } + if (expected) + impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations); + else + impliedFormatPackageJsons.delete(newFile.path); + }); + impliedFormatPackageJsons.forEach(function (existing, path) { + if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) { + existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; }); + impliedFormatPackageJsons.delete(path); + } + }); + } directoryWatchesOfFailedLookups.forEach(function (watcher, path) { if (watcher.refCount === 0) { directoryWatchesOfFailedLookups.delete(path); @@ -122504,11 +123034,9 @@ var ts; } }); fileWatchesOfAffectingLocations.forEach(function (watcher, path) { - if (watcher.refCount === 0) { + if (watcher.files === 0 && watcher.resolutions === 0) { fileWatchesOfAffectingLocations.delete(path); watcher.watcher.close(); - // Ensure when watching symlinked package.json, we can close the actual file watcher only once - watcher.watcher = ts.noopFileWatcher; } }); hasChangedAutomaticTypeDirectiveNames = false; @@ -122708,7 +123236,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution return { @@ -122735,7 +123263,7 @@ var ts; } // If the directory is node_modules use it to watch, always watch it recursively if (ts.isNodeModulesDirectory(dirPath)) { - return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; + return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; // Use some ancestor of the root directory @@ -122753,7 +123281,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; + return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -122824,46 +123352,65 @@ var ts; // Watch package json for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) { var affectingLocation = affectingLocations_1[_i]; - createFileWatcherOfAffectingLocation(affectingLocation); + createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true); } } - function createFileWatcherOfAffectingLocation(affectingLocation) { - var path = resolutionHost.toPath(affectingLocation); - var fileWatcher = fileWatchesOfAffectingLocations.get(path); + function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) { + var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation); if (fileWatcher) { - fileWatcher.refCount++; + if (forResolution) + fileWatcher.resolutions++; + else + fileWatcher.files++; return; } var locationToWatch = affectingLocation; - var locationToWatchPath = path; if (resolutionHost.realpath) { locationToWatch = resolutionHost.realpath(affectingLocation); - locationToWatchPath = resolutionHost.toPath(locationToWatch); - if (path !== locationToWatchPath) { - var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath); + if (affectingLocation !== locationToWatch) { + var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch); if (fileWatcher_1) { - fileWatcher_1.refCount++; - fileWatcher_1.paths.add(path); - fileWatchesOfAffectingLocations.set(path, fileWatcher_1); + if (forResolution) + fileWatcher_1.resolutions++; + else + fileWatcher_1.files++; + fileWatcher_1.paths.add(affectingLocation); + fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1); return; } } } var paths = new ts.Set(); - paths.add(locationToWatchPath); - var watcher = { - watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { - cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind); - paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); }); + paths.add(locationToWatch); + var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ? + resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { + cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind); + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + paths.forEach(function (path) { + if (watcher.resolutions) + (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path); + if (watcher.files) + (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path); + packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path)); + }); resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); - }), - refCount: 1, + }) : ts.noopFileWatcher; + var watcher = { + watcher: actualWatcher !== ts.noopFileWatcher ? { + close: function () { + actualWatcher.close(); + // Ensure when watching symlinked package.json, we can close the actual file watcher only once + actualWatcher = ts.noopFileWatcher; + } + } : actualWatcher, + resolutions: forResolution ? 1 : 0, + files: forResolution ? 0 : 1, paths: paths, }; - fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher); - if (path !== locationToWatchPath) { - fileWatchesOfAffectingLocations.set(path, watcher); - paths.add(path); + fileWatchesOfAffectingLocations.set(locationToWatch, watcher); + if (affectingLocation !== locationToWatch) { + fileWatchesOfAffectingLocations.set(affectingLocation, watcher); + paths.add(affectingLocation); } } function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) { @@ -122931,8 +123478,8 @@ var ts; } for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) { var affectingLocation = affectingLocations_2[_a]; - var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation)); - watcher.refCount--; + var watcher = fileWatchesOfAffectingLocations.get(affectingLocation); + watcher.resolutions--; } } function removeDirectoryWatcher(dirPath) { @@ -122948,7 +123495,7 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); - }, nonRecursive ? 0 /* None */ : 1 /* Recursive */); + }, nonRecursive ? 0 /* WatchDirectoryFlags.None */ : 1 /* WatchDirectoryFlags.Recursive */); } function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) { // Deleted file, stop watching failed lookups for all the resolutions in the file @@ -122959,7 +123506,7 @@ var ts; } } function removeResolutionsFromProjectReferenceRedirects(filePath) { - if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) + if (!ts.fileExtensionIs(filePath, ".json" /* Extension.Json */)) return; var program = resolutionHost.getCurrentProgram(); if (!program) @@ -122986,7 +123533,7 @@ var ts; resolution.isInvalidated = invalidated = true; for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) { var containingFilePath = _b[_a]; - (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); // When its a file with inferred types resolution, invalidate type reference directive resolution hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile); } @@ -123053,10 +123600,25 @@ var ts; resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { + var _a; + var invalidated = false; + if (affectingPathChecksForFile) { + (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) { + if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) { + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path); + invalidated = true; + } + }); + affectingPathChecksForFile = undefined; + } if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) { - return false; + return invalidated; + } + invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated; + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) { + packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; }); } - var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); failedLookupChecks = undefined; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; @@ -123069,17 +123631,15 @@ var ts; return true; if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) return false; - return resolution.failedLookupLocations.some(function (location) { - var locationPath = resolutionHost.toPath(location); - return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || - ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || - ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); - }); + return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); }); + } + function isInvalidatedFailedLookup(locationPath) { + return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); } function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) { - return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { - return affectingPathChecks.has(resolutionHost.toPath(location)); - }); + return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); }); } function closeTypeRootsWatch() { ts.clearMap(typeRootsWatches, ts.closeFileWatcher); @@ -123110,7 +123670,7 @@ var ts; if (dirPath) { scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); } - }, 1 /* Recursive */); + }, 1 /* WatchDirectoryFlags.Recursive */); } /** * Watches the types that would get added as part of getAutomaticTypeDirectiveNames @@ -123145,7 +123705,7 @@ var ts; function directoryExistsForTypeRootWatch(nodeTypesDirectory) { var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory)); var dirPath = resolutionHost.toPath(dir); - return dirPath === rootPath || canWatchDirectory(dirPath); + return dirPath === rootPath || canWatchDirectoryOrFile(dirPath); } } ts.createResolutionCache = createResolutionCache; @@ -123178,28 +123738,28 @@ var ts; function getPreferences(host, _a, compilerOptions, importingSourceFile) { var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding; return { - relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : - importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* RelativePreference.Relative */ : + importModuleSpecifierPreference === "non-relative" ? 1 /* RelativePreference.NonRelative */ : + importModuleSpecifierPreference === "project-relative" ? 3 /* RelativePreference.ExternalNonRelative */ : + 2 /* RelativePreference.Shortest */, ending: getEnding(), }; function getEnding() { switch (importModuleSpecifierEnding) { - case "minimal": return 0 /* Minimal */; - case "index": return 1 /* Index */; - case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + case "minimal": return 0 /* Ending.Minimal */; + case "index": return 1 /* Ending.Index */; + case "js": return 2 /* Ending.JsExtension */; + default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* Ending.JsExtension */ + : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) { return { - relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, + relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* RelativePreference.Relative */ : 1 /* RelativePreference.NonRelative */, ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? - 2 /* JsExtension */ : - ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + 2 /* Ending.JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */, }; } function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { @@ -123256,7 +123816,7 @@ var ts; var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || - getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); + getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { if (options === void 0) { options = {}; } @@ -123312,7 +123872,7 @@ var ts; return undefined; var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text; // If the preference is for non relative and the module specifier is relative, ignore it - return preferences.relativePreference !== 1 /* NonRelative */ || !ts.pathIsRelative(specifier) ? + return preferences.relativePreference !== 1 /* RelativePreference.NonRelative */ || !ts.pathIsRelative(specifier) ? specifier : undefined; }); }); @@ -123339,7 +123899,7 @@ var ts; return nodeModulesSpecifiers; } if (!specifier && !modulePath.isRedirect) { - var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences); + var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); if (ts.pathIsBareSpecifier(local)) { pathsSpecifiers = ts.append(pathsSpecifiers, local); } @@ -123367,13 +123927,13 @@ var ts; var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory }; } - function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) { + function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) { var ending = _a.ending, relativePreference = _a.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); - if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { + if (!baseUrl && !paths || relativePreference === 0 /* RelativePreference.Relative */) { return relativePath; } var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); @@ -123381,16 +123941,15 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; + var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions); + var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths; if (!nonRelative) { return relativePath; } - if (relativePreference === 1 /* NonRelative */) { + if (relativePreference === 1 /* RelativePreference.NonRelative */) { return nonRelative; } - if (relativePreference === 3 /* ExternalNonRelative */) { + if (relativePreference === 3 /* RelativePreference.ExternalNonRelative */) { var projectDirectory = compilerOptions.configFilePath ? ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory()); @@ -123424,7 +123983,7 @@ var ts; } return relativePath; } - if (relativePreference !== 2 /* Shortest */) + if (relativePreference !== 2 /* RelativePreference.Shortest */) ts.Debug.assertNever(relativePreference); // Prefer a relative import over a baseUrl import if it has fewer components. return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; @@ -123432,7 +123991,7 @@ var ts; function countPathComponents(path) { var count = 0; for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) { - if (path.charCodeAt(i) === 47 /* slash */) + if (path.charCodeAt(i) === 47 /* CharacterCodes.slash */) count++; } return count; @@ -123536,7 +124095,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_34 = function (directory) { + var _loop_35 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -123560,7 +124119,7 @@ var ts; }; var out_directory_1; for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { - var state_11 = _loop_34(directory); + var state_11 = _loop_35(directory); directory = out_directory_1; if (state_11 === "break") break; @@ -123603,11 +124162,11 @@ var ts; var exportSymbol = checker.getSymbolAtLocation(exportAssignment); if (!exportSymbol) return; - var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; + var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; if (originalExportSymbol === d.symbol) return topNamespace.parent.parent; function getTopNamespace(namespaceDeclaration) { - while (namespaceDeclaration.flags & 4 /* NestedNamespace */) { + while (namespaceDeclaration.flags & 4 /* NodeFlags.NestedNamespace */) { namespaceDeclaration = namespaceDeclaration.parent; } return namespaceDeclaration; @@ -123618,28 +124177,102 @@ var ts; return ambientModuleDeclare.name.text; } } - function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) { + function getAllowedEndings(preferredEnding, compilerOptions, importMode) { + if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) { + return [2 /* Ending.JsExtension */]; + } + switch (preferredEnding) { + case 2 /* Ending.JsExtension */: return [2 /* Ending.JsExtension */, 0 /* Ending.Minimal */, 1 /* Ending.Index */]; + case 1 /* Ending.Index */: return [1 /* Ending.Index */, 0 /* Ending.Minimal */, 2 /* Ending.JsExtension */]; + case 0 /* Ending.Minimal */: return [0 /* Ending.Minimal */, 1 /* Ending.Index */, 2 /* Ending.JsExtension */]; + default: ts.Debug.assertNever(preferredEnding); + } + } + function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) { for (var key in paths) { - for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { - var patternText_1 = _a[_i]; - var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1)); + var _loop_36 = function (patternText_1) { + var pattern = ts.normalizePath(patternText_1); var indexOfStar = pattern.indexOf("*"); + // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly, + // meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution + // causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file + // and matches the '*'. For example: + // + // Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action + // ---------------------->------------------------------->--------------------->--------------------------------------------------------------- + // import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm] + // import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm] + // + // (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516) + // + // The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in + // the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result. + // (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid + // extension for a module specifier.) + // + // Here, this means we need to be careful about whether we generate a match from the target filename (typically with a + // .ts extension) or the possible relative module specifiers representing that file: + // + // Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results + // --------------------<----------------------------------------------<------------------------------<-------------------||---------------------------- + // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none) + // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js + // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none) + // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*"] <- (none) || @app/foo, @app/foo/index, @app/foo/index.js + // dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js + // + // The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of + // relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes + // into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js' + // exists) and (c) that they are ordered by preference. The last row shows that the filename result and module + // specifier results are not mutually exclusive. Note that the filename result is a higher priority in module + // resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result + // in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be + // sorted among the others for a particular value of `importModuleSpecifierEnding`. + var candidates = allowedEndings.map(function (ending) { return ({ + ending: ending, + value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) + }); }); + if (ts.tryGetExtensionFromPath(pattern)) { + candidates.push({ ending: undefined, value: relativeToBaseUrl }); + } if (indexOfStar !== -1) { - var prefix = pattern.substr(0, indexOfStar); - var suffix = pattern.substr(indexOfStar + 1); - if (relativeToBaseUrl.length >= prefix.length + suffix.length && - ts.startsWith(relativeToBaseUrl, prefix) && - ts.endsWith(relativeToBaseUrl, suffix) || - !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); - return key.replace("*", matchedStar); + var prefix = pattern.substring(0, indexOfStar); + var suffix = pattern.substring(indexOfStar + 1); + for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) { + var _c = candidates_3[_b], ending = _c.ending, value = _c.value; + if (value.length >= prefix.length + suffix.length && + ts.startsWith(value, prefix) && + ts.endsWith(value, suffix) && + validateEnding({ ending: ending, value: value })) { + var matchedStar = value.substring(prefix.length, value.length - suffix.length); + return { value: key.replace("*", matchedStar) }; + } } } - else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) { - return key; + else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Ending.Minimal */ && pattern === c.value; }) || + ts.some(candidates, function (c) { return c.ending === 0 /* Ending.Minimal */ && pattern === c.value && validateEnding(c); })) { + return { value: key }; } + }; + for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { + var patternText_1 = _a[_i]; + var state_12 = _loop_36(patternText_1); + if (typeof state_12 === "object") + return state_12.value; } } + function validateEnding(_a) { + var ending = _a.ending, value = _a.value; + // Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename + // is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only + // here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls), + // do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the + // `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is + // that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally + // everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.) + return ending !== 0 /* Ending.Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host); + } } var MatchingMode; (function (MatchingMode) { @@ -123648,23 +124281,23 @@ var ts; MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern"; })(MatchingMode || (MatchingMode = {})); function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { - if (mode === void 0) { mode = 0 /* Exact */; } + if (mode === void 0) { mode = 0 /* MatchingMode.Exact */; } if (typeof exports === "string") { var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined); var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined; switch (mode) { - case 0 /* Exact */: - if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) { + case 0 /* MatchingMode.Exact */: + if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* Comparison.EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* Comparison.EqualTo */)) { return { moduleFileToTry: packageName }; } break; - case 1 /* Directory */: + case 1 /* MatchingMode.Directory */: if (ts.containsPath(pathOrPattern, targetFilePath)) { var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false); return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) }; } break; - case 2 /* Pattern */: + case 2 /* MatchingMode.Pattern */: var starPos = pathOrPattern.indexOf("*"); var leadingSlice = pathOrPattern.slice(0, starPos); var trailingSlice = pathOrPattern.slice(starPos + 1); @@ -123691,9 +124324,9 @@ var ts; // * exact mappings (no *, does not end with /) return ts.forEach(ts.getOwnKeys(exports), function (k) { var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined); - var mode = ts.endsWith(k, "/") ? 1 /* Directory */ - : ts.stringContains(k, "*") ? 2 /* Pattern */ - : 0 /* Exact */; + var mode = ts.endsWith(k, "/") ? 1 /* MatchingMode.Directory */ + : ts.stringContains(k, "*") ? 2 /* MatchingMode.Pattern */ + : 0 /* MatchingMode.Exact */; return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode); }); } @@ -123735,10 +124368,10 @@ var ts; return undefined; } // Simplify the full file path to something that can be resolved by Node. + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { - var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; var moduleFileName = void 0; while (true) { @@ -123787,15 +124420,13 @@ var ts; var packageRootPath = path.substring(0, packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); var moduleFileToTry = path; + var maybeBlockedByTypesVersions = false; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); + var importMode = overrideMode || importingSourceFile.impliedNodeFormat; if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { - // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate - // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is - // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` - // with, so for now we just stick with the mode of the file. - var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"]; + var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"]; var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions) : undefined; @@ -123814,16 +124445,26 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { + var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options); + if (fromPaths === undefined) { + maybeBlockedByTypesVersions = true; + } + else { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } // If the file is the main module, it can be imported by the package name var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; - if (ts.isString(mainFileRelative)) { + if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) { + // The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path + // explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable. + // (The only way this can happen is if some file in a package that's not resolvable from outside the + // package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It + // happens very easily in fourslash tests though, since every test file listed gets included. See + // importNameCodeFix_typesVersions.ts for an example.) var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { + // ^ An arbitrary removal of file extension for this comparison is almost certainly wrong return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry }; } } @@ -123842,7 +124483,7 @@ var ts; if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }])); + var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }])); for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) { var e = extensions_3[_i]; var fullPath = path + e; @@ -123858,15 +124499,15 @@ var ts; }); } function removeExtensionAndIndexPostFix(fileName, ending, options, host) { - if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) + if (ts.fileExtensionIsOneOf(fileName, [".json" /* Extension.Json */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) return fileName; var noExtension = ts.removeFileExtension(fileName); if (fileName === noExtension) return fileName; - if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) + if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { - case 0 /* Minimal */: + case 0 /* Ending.Minimal */: var withoutIndex = ts.removeSuffix(noExtension, "/index"); if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { // Can't remove index if there's a file by the same name as the directory. @@ -123874,9 +124515,9 @@ var ts; return noExtension; } return withoutIndex; - case 1 /* Index */: + case 1 /* Ending.Index */: return noExtension; - case 2 /* JsExtension */: + case 2 /* Ending.JsExtension */: return noExtension + getJSExtensionForFile(fileName, options); default: return ts.Debug.assertNever(ending); @@ -123884,28 +124525,28 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); switch (ext) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: - return ".js" /* Js */; - case ".tsx" /* Tsx */: - return options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; - case ".js" /* Js */: - case ".jsx" /* Jsx */: - case ".json" /* Json */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: + return ".js" /* Extension.Js */; + case ".tsx" /* Extension.Tsx */: + return options.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" /* Extension.Jsx */ : ".js" /* Extension.Js */; + case ".js" /* Extension.Js */: + case ".jsx" /* Extension.Jsx */: + case ".json" /* Extension.Json */: return ext; - case ".d.mts" /* Dmts */: - case ".mts" /* Mts */: - case ".mjs" /* Mjs */: - return ".mjs" /* Mjs */; - case ".d.cts" /* Dcts */: - case ".cts" /* Cts */: - case ".cjs" /* Cjs */: - return ".cjs" /* Cjs */; + case ".d.mts" /* Extension.Dmts */: + case ".mts" /* Extension.Mts */: + case ".mjs" /* Extension.Mjs */: + return ".mjs" /* Extension.Mjs */; + case ".d.cts" /* Extension.Dcts */: + case ".cts" /* Extension.Cts */: + case ".cjs" /* Extension.Cjs */: + return ".cjs" /* Extension.Cjs */; default: return undefined; } @@ -123987,8 +124628,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -123996,8 +124637,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -124020,7 +124661,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -124053,7 +124694,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -124066,7 +124707,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -124089,7 +124730,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -124116,25 +124757,48 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; - function explainIfFileIsRedirect(file, fileNameConvertor) { + function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) { + var _a; var result; if (file.path !== file.resolvedPath) { - (result || (result = [])).push(ts.chainDiagnosticMessages( + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor))); } if (file.redirectInfo) { - (result || (result = [])).push(ts.chainDiagnosticMessages( + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor))); } + if (ts.isExternalOrCommonJsModule(file)) { + switch (file.impliedNodeFormat) { + case ts.ModuleKind.ESNext: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + break; + case ts.ModuleKind.CommonJS: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, file.packageJsonScope.packageJsonContent.type ? + ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module : + ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found)); + } + break; + } + } return result; } - ts.explainIfFileIsRedirect = explainIfFileIsRedirect; + ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat; function getMatchedFileSpec(program, fileName) { var _a; var configFile = program.getCompilerOptions().configFile; @@ -124154,14 +124818,14 @@ var ts; // Return true if its default include spec if (configFile.configFileSpecs.isDefaultIncludeSpec) return true; - var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Extension.Json */); var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames(); return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) { - if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Json */)) + if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Extension.Json */)) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -124170,7 +124834,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -124296,7 +124960,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -124344,6 +125008,7 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", + AffectingFileLocation: "File location affecting resolution", TypeRoots: "Type roots", ConfigFileOfReferencedProject: "Config file of referened project", ExtendedConfigOfReferencedProject: "Extended config file of referenced project", @@ -124404,7 +125069,6 @@ var ts; readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, - now: ts.maybeBind(host, host.now), }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -124562,7 +125226,6 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - host.now = ts.maybeBind(system, system.now); ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -124613,7 +125276,6 @@ var ts; var parsedConfigs; // Parsed commandline and watching cached for referenced projects var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation - var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files @@ -124644,7 +125306,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -124670,7 +125332,7 @@ var ts; compilerHost.getCompilationSettings = function () { return compilerOptions; }; compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect); compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); }; - compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); }; + compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); }; compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); }; compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; }; compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations; @@ -124704,6 +125366,9 @@ var ts; return host.resolveTypeReferenceDirectives.apply(host, args); }) : (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); }); + compilerHost.getModuleResolutionCache = host.resolveModuleNames ? + ts.maybeBind(host, host.getModuleResolutionCache) : + (function () { return resolutionCache.getModuleResolutionCache(); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); synchronizeProgram(); @@ -124766,12 +125431,12 @@ var ts; var program = getCurrentBuilderProgram(); if (hasChangedCompilerOptions) { newLine = updateNewLine(); - if (program && (changesAffectResolution || ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) { + if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) { resolutionCache.clear(); } } // All resolutions are invalid if user provided resolutions - var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution); + var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { @@ -124787,7 +125452,6 @@ var ts; } createNewProgram(hasInvalidatedResolution); } - changesAffectResolution = false; // reset for next sync reportFileChangeDetectedOnCreateProgram = false; if (host.afterProgramCreate && program !== builderProgram) { host.afterProgramCreate(builderProgram); @@ -124797,18 +125461,19 @@ var ts; function createNewProgram(hasInvalidatedResolution) { // Compile the program writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; resolutionCache.startCachingPerDirectoryResolution(); compilerHost.hasInvalidatedResolution = hasInvalidatedResolution; compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames; + var oldProgram = getCurrentProgram(); builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); - resolutionCache.finishCachingPerDirectoryResolution(); + resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram); // Update watches ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath); if (needsUpdateInTypeRootWatch) { @@ -124890,9 +125555,6 @@ var ts; sourceFilesCache.set(path, false); } } - if (sourceFile) { - sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings()); - } return sourceFile; } return hostSourceFile.sourceFile; @@ -124955,7 +125617,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -125016,7 +125678,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -125057,7 +125719,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -125286,7 +125948,7 @@ var ts; UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function resolveConfigFileProjectName(project) { - if (ts.fileExtensionIs(project, ".json" /* Json */)) { + if (ts.fileExtensionIs(project, ".json" /* Extension.Json */)) { return project; } return ts.combinePaths(project, "tsconfig.json"); @@ -125349,8 +126011,8 @@ var ts; */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -125408,6 +126070,7 @@ var ts; compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); + compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache); var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined; if (!compilerHost.resolveModuleNames) { @@ -125890,8 +126553,7 @@ var ts; } // Actual Emit var host = state.host, compilerHost = state.compilerHost; - var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; - var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined; + var resultFlags = ((_d = program.hasChangedEmitSignature) === null || _d === void 0 ? void 0 : _d.call(program)) ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged; var emitterDiagnostics = ts.createDiagnosticCollection(); var emittedOutputs = new ts.Map(); var options = program.getCompilerOptions(); @@ -125899,17 +126561,11 @@ var ts; var outputTimeStampMap; var now; outputFiles.forEach(function (_a) { - var _b, _c; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; var path = toPath(state, name); emittedOutputs.set(toPath(state, name), name); - if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, options); - // Buildinfo has information on when last dts change time - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo === null || existingBuildInfo === void 0 ? void 0 : existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { - resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; - } - } + if (buildInfo) + setBuildInfo(state, buildInfo, projectPath, options, resultFlags); ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); if (!isIncremental && state.watch) { (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host))); @@ -125923,7 +126579,7 @@ var ts; ts.Debug.assert(step === BuildStep.EmitBuildInfo); var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) { if (data === null || data === void 0 ? void 0 : data.buildInfo) - setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions()); + setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions(), BuildResultFlags.DeclarationOutputUnchanged); if (writeFileCallback) writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data); else @@ -125956,7 +126612,6 @@ var ts; state.diagnostics.delete(projectPath); state.projectStatus.set(projectPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath), oldestOutputFileName: oldestOutputFileName }); afterProgramDone(state, program, config); @@ -125998,10 +126653,10 @@ var ts; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; emittedOutputs.set(toPath(state, name), name); if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, config.options); - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { + if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) { resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; } + setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags); } ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); }); @@ -126162,7 +126817,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -126176,7 +126831,7 @@ var ts; } function afterProgramDone(state, program, config) { if (program) { - if (program && state.write) + if (state.write) ts.listFiles(program, state.write); if (state.host.afterProgramEmitAndDiagnostics) { state.host.afterProgramEmitAndDiagnostics(program); @@ -126192,7 +126847,7 @@ var ts; // Since buildinfo has changeset and diagnostics when doing multi file emit, only --out cannot emit buildinfo if it has errors var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -126260,15 +126915,23 @@ var ts; state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map()); return result; } - function setBuildInfo(state, buildInfo, resolvedConfigPath, options) { + function setBuildInfo(state, buildInfo, resolvedConfigPath, options, resultFlags) { var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath); + var modifiedTime = getCurrentTime(state.host); if (existing) { existing.buildInfo = buildInfo; - existing.modifiedTime = getCurrentTime(state.host); + existing.modifiedTime = modifiedTime; + if (!(resultFlags & BuildResultFlags.DeclarationOutputUnchanged)) + existing.latestChangedDtsTime = modifiedTime; } else { - state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) }); + state.buildInfoCache.set(resolvedConfigPath, { + path: toPath(state, buildInfoPath), + buildInfo: buildInfo, + modifiedTime: modifiedTime, + latestChangedDtsTime: resultFlags & BuildResultFlags.DeclarationOutputUnchanged ? undefined : modifiedTime, + }); } } function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) { @@ -126300,7 +126963,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { - var _a, _b, _c; + var _a, _b; // Container if no files are specified in the project if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) { return { @@ -126312,8 +126975,8 @@ var ts; var force = !!state.options.force; if (project.projectReferences) { state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream }); - for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) { - var ref = _d[_i]; + for (var _i = 0, _c = project.projectReferences; _i < _c.length; _i++) { + var ref = _c[_i]; var resolvedRef = ts.resolveProjectReferencePath(ref); var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef); var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath); @@ -126353,7 +127016,6 @@ var ts; var buildInfoTime; var buildInfoProgram; var buildInfoVersionMap; - var newestDeclarationFileContentChangedTime; if (buildInfoPath) { var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath); buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath); @@ -126390,8 +127052,6 @@ var ts; } oldestOutputFileTime = buildInfoTime; oldestOutputFileName = buildInfoPath; - // Get the last dtsChange time from build info - newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; } // Check input files var newestInputFileName = undefined; @@ -126399,13 +127059,13 @@ var ts; /** True if input file has changed timestamp but text is not changed, we can then do only timestamp updates on output to make it look up-to-date later */ var pseudoInputUpToDate = false; // Get timestamps of input files - for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) { - var inputFile = _f[_e]; + for (var _d = 0, _e = project.fileNames; _d < _e.length; _d++) { + var inputFile = _e[_d]; var inputTime = getModifiedTime(state, inputFile); if (inputTime === ts.missingFileModifiedTime) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } // If an buildInfo is older than the newest input, we can stop checking @@ -126441,8 +127101,8 @@ var ts; // Collect the expected outputs of this project var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath); - for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) { - var output = outputs_1[_g]; + for (var _f = 0, outputs_1 = outputs; _f < outputs_1.length; _f++) { + var output = outputs_1[_f]; var path = toPath(state, output); // Output is missing; can stop checking var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path); @@ -126480,8 +127140,8 @@ var ts; var usesPrepend = false; var upstreamChangedProject; if (referenceStatuses) { - for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) { - var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath; + for (var _g = 0, referenceStatuses_1 = referenceStatuses; _g < referenceStatuses_1.length; _g++) { + var _h = referenceStatuses_1[_g], ref = _h.ref, refStatus = _h.refStatus, resolvedConfig = _h.resolvedConfig, resolvedRefPath = _h.resolvedRefPath; usesPrepend = usesPrepend || !!(ref.prepend); // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it @@ -126498,7 +127158,8 @@ var ts; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + var newestDeclarationFileContentChangedTime = getLatestChangedDtsTime(state, resolvedConfig.options, resolvedRefPath); + if (newestDeclarationFileContentChangedTime && newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -126541,7 +127202,6 @@ var ts; pseudoInputUpToDate ? ts.UpToDateStatusType.UpToDateWithInputFileText : ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, newestInputFileTime: newestInputFileTime, newestInputFileName: newestInputFileName, oldestOutputFileName: oldestOutputFileName @@ -126625,13 +127285,17 @@ var ts; outputTimeStampMap.delete(key); }); } - function getDtsChangeTime(state, options, resolvedConfigPath) { - var _a; + function getLatestChangedDtsTime(state, options, resolvedConfigPath) { if (!options.composite) return undefined; - var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); - var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined); - return ((_a = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.program) === null || _a === void 0 ? void 0 : _a.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; + var entry = ts.Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath)); + if (entry.latestChangedDtsTime !== undefined) + return entry.latestChangedDtsTime || undefined; + var latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ? + state.host.getModifiedTime(ts.getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, ts.getDirectoryPath(entry.path))) : + undefined; + entry.latestChangedDtsTime = latestChangedDtsTime || false; + return latestChangedDtsTime; } function updateOutputTimestamps(state, proj, resolvedPath) { if (state.options.dry) { @@ -126640,7 +127304,6 @@ var ts; updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0); state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath), oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames()) }); } @@ -126776,7 +127439,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -127126,7 +127789,7 @@ var ts; function nowString() { // E.g. "12:34:56.789" var d = new Date(); - return ts.padLeft(d.getHours().toString(), 2, "0") + ":" + ts.padLeft(d.getMinutes().toString(), 2, "0") + ":" + ts.padLeft(d.getSeconds().toString(), 2, "0") + "." + ts.padLeft(d.getMilliseconds().toString(), 3, "0"); + return "".concat(ts.padLeft(d.getHours().toString(), 2, "0"), ":").concat(ts.padLeft(d.getMinutes().toString(), 2, "0"), ":").concat(ts.padLeft(d.getSeconds().toString(), 2, "0"), ".").concat(ts.padLeft(d.getMilliseconds().toString(), 3, "0")); } server.nowString = nowString; })(server = ts.server || (ts.server = {})); @@ -127137,7 +127800,7 @@ var ts; var JsTyping; (function (JsTyping) { function isTypingUpToDate(cachedTyping, availableTypingVersions) { - var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); + var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts".concat(ts.versionMajorMinor)) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; @@ -127190,7 +127853,7 @@ var ts; "worker_threads", "zlib" ]; - JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:" + name; }); + JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:".concat(name); }); JsTyping.nodeCoreModuleList = __spreadArray(__spreadArray([], unprefixedNodeCoreModuleList, true), JsTyping.prefixedNodeCoreModuleList, true); JsTyping.nodeCoreModules = new ts.Set(JsTyping.nodeCoreModuleList); function nonRelativeModuleNameForTypingCache(moduleName) { @@ -127265,7 +127928,7 @@ var ts; var excludeTypingName = exclude_1[_i]; var didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) - log("Typing for " + excludeTypingName + " is in exclude list, will be ignored."); + log("Typing for ".concat(excludeTypingName, " is in exclude list, will be ignored.")); } var newTypingNames = []; var cachedTypingPaths = []; @@ -127279,7 +127942,7 @@ var ts; }); var result = { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; if (log) - log("Result: " + JSON.stringify(result)); + log("Result: ".concat(JSON.stringify(result))); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { @@ -127288,7 +127951,7 @@ var ts; } function addInferredTypings(typingNames, message) { if (log) - log(message + ": " + JSON.stringify(typingNames)); + log("".concat(message, ": ").concat(JSON.stringify(typingNames))); ts.forEach(typingNames, addInferredTyping); } /** @@ -127310,7 +127973,7 @@ var ts; filesToWatch.push(manifestPath); manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config; manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys); - addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies"); + addInferredTypings(manifestTypingNames, "Typing names in '".concat(manifestPath, "' dependencies")); } // Now we scan the directories for typing information in // already-installed dependencies (if present). Note that this @@ -127338,7 +128001,7 @@ var ts; // This is #1 described above. ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); }) // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json` - : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) + : host.readDirectory(packagesFolderPath, [".json" /* Extension.Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) .filter(function (manifestPath) { if (ts.getBaseFileName(manifestPath) !== manifestName) { return false; @@ -127354,7 +128017,7 @@ var ts; !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo` }); if (log) - log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames)); + log("Searching for typing names in ".concat(packagesFolderPath, "; all files: ").concat(JSON.stringify(dependencyManifestNames))); // Once we have the names of things to look up, we iterate over // and either collect their included typings, or add them to the // list of typings we need to look up separately. @@ -127373,12 +128036,12 @@ var ts; var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName)); if (host.fileExists(absolutePath)) { if (log) - log(" Package '" + manifest_1.name + "' provides its own types."); + log(" Package '".concat(manifest_1.name, "' provides its own types.")); inferredTypings.set(manifest_1.name, absolutePath); } else { if (log) - log(" Package '" + manifest_1.name + "' provides its own types but they are missing."); + log(" Package '".concat(manifest_1.name, "' provides its own types but they are missing.")); } } else { @@ -127404,7 +128067,7 @@ var ts; if (fromFileNames.length) { addInferredTypings(fromFileNames, "Inferred typings from file names"); } - var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); }); + var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Extension.Jsx */); }); if (hasJsxFile) { if (log) log("Inferred 'react' typings due to presence of '.jsx' extension"); @@ -127432,16 +128095,16 @@ var ts; JsTyping.validatePackageName = validatePackageName; function validatePackageNameWorker(packageName, supportScopedPackage) { if (!packageName) { - return 1 /* EmptyName */; + return 1 /* NameValidationResult.EmptyName */; } if (packageName.length > maxPackageNameLength) { - return 2 /* NameTooLong */; + return 2 /* NameValidationResult.NameTooLong */; } - if (packageName.charCodeAt(0) === 46 /* dot */) { - return 3 /* NameStartsWithDot */; + if (packageName.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + return 3 /* NameValidationResult.NameStartsWithDot */; } - if (packageName.charCodeAt(0) === 95 /* _ */) { - return 4 /* NameStartsWithUnderscore */; + if (packageName.charCodeAt(0) === 95 /* CharacterCodes._ */) { + return 4 /* NameValidationResult.NameStartsWithUnderscore */; } // check if name is scope package like: starts with @ and has one '/' in the middle // scoped packages are not currently supported @@ -127449,20 +128112,20 @@ var ts; var matches = /^@([^/]+)\/([^/]+)$/.exec(packageName); if (matches) { var scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false); - if (scopeResult !== 0 /* Ok */) { + if (scopeResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[1], isScopeName: true, result: scopeResult }; } var packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false); - if (packageResult !== 0 /* Ok */) { + if (packageResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[2], isScopeName: false, result: packageResult }; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } } if (encodeURIComponent(packageName) !== packageName) { - return 5 /* NameContainsNonURISafeCharacters */; + return 5 /* NameValidationResult.NameContainsNonURISafeCharacters */; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } function renderPackageNameValidationFailure(result, typing) { return typeof result === "object" ? @@ -127473,17 +128136,17 @@ var ts; function renderPackageNameValidationFailureWorker(typing, result, name, isScopeName) { var kind = isScopeName ? "Scope" : "Package"; switch (result) { - case 1 /* EmptyName */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot be empty"; - case 2 /* NameTooLong */: - return "'" + typing + "':: " + kind + " name '" + name + "' should be less than " + maxPackageNameLength + " characters"; - case 3 /* NameStartsWithDot */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '.'"; - case 4 /* NameStartsWithUnderscore */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '_'"; - case 5 /* NameContainsNonURISafeCharacters */: - return "'" + typing + "':: " + kind + " name '" + name + "' contains non URI safe characters"; - case 0 /* Ok */: + case 1 /* NameValidationResult.EmptyName */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot be empty"); + case 2 /* NameValidationResult.NameTooLong */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' should be less than ").concat(maxPackageNameLength, " characters"); + case 3 /* NameValidationResult.NameStartsWithDot */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '.'"); + case 4 /* NameValidationResult.NameStartsWithUnderscore */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '_'"); + case 5 /* NameValidationResult.NameContainsNonURISafeCharacters */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' contains non URI safe characters"); + case 0 /* NameValidationResult.Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: throw ts.Debug.assertNever(result); @@ -127855,7 +128518,7 @@ var ts; (function (ts) { // These utilities are common to multiple language service features. //#region - ts.scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); + ts.scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); var SemanticMeaning; (function (SemanticMeaning) { SemanticMeaning[SemanticMeaning["None"] = 0] = "None"; @@ -127866,66 +128529,66 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 292 /* CatchClause */: - case 285 /* JsxAttribute */: - return 1 /* Value */; - case 163 /* TypeParameter */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 182 /* TypeLiteral */: - return 2 /* Type */; - case 345 /* JSDocTypedefTag */: + case 254 /* SyntaxKind.VariableDeclaration */: + return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* SemanticMeaning.All */ : 1 /* SemanticMeaning.Value */; + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 292 /* SyntaxKind.CatchClause */: + case 285 /* SyntaxKind.JsxAttribute */: + return 1 /* SemanticMeaning.Value */; + case 163 /* SyntaxKind.TypeParameter */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + return 2 /* SemanticMeaning.Type */; + case 345 /* SyntaxKind.JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. - return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 299 /* EnumMember */: - case 257 /* ClassDeclaration */: - return 1 /* Value */ | 2 /* Type */; - case 261 /* ModuleDeclaration */: + return node.name === undefined ? 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */ : 2 /* SemanticMeaning.Type */; + case 299 /* SyntaxKind.EnumMember */: + case 257 /* SyntaxKind.ClassDeclaration */: + return 1 /* SemanticMeaning.Value */ | 2 /* SemanticMeaning.Type */; + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isAmbientModule(node)) { - return 4 /* Namespace */ | 1 /* Value */; + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { - return 4 /* Namespace */ | 1 /* Value */; + else if (ts.getModuleInstanceState(node) === 1 /* ModuleInstanceState.Instantiated */) { + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } else { - return 4 /* Namespace */; - } - case 260 /* EnumDeclaration */: - case 269 /* NamedImports */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: - return 7 /* All */; + return 4 /* SemanticMeaning.Namespace */; + } + case 260 /* SyntaxKind.EnumDeclaration */: + case 269 /* SyntaxKind.NamedImports */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: + return 7 /* SemanticMeaning.All */; // An external module can be a Value - case 305 /* SourceFile */: - return 4 /* Namespace */ | 1 /* Value */; + case 305 /* SyntaxKind.SourceFile */: + return 4 /* SemanticMeaning.Namespace */ | 1 /* SemanticMeaning.Value */; } - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { node = getAdjustedReferenceLocation(node); var parent = node.parent; - if (node.kind === 305 /* SourceFile */) { - return 1 /* Value */; + if (node.kind === 305 /* SyntaxKind.SourceFile */) { + return 1 /* SemanticMeaning.Value */; } else if (ts.isExportAssignment(parent) || ts.isExportSpecifier(parent) @@ -127933,7 +128596,7 @@ var ts; || ts.isImportSpecifier(parent) || ts.isImportClause(parent) || ts.isImportEqualsDeclaration(parent) && node === parent.name) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { return getMeaningFromRightHandSideOfImportEquals(node); @@ -127942,24 +128605,24 @@ var ts; return getMeaningFromDeclaration(parent); } else if (ts.isEntityName(node) && ts.findAncestor(node, ts.or(ts.isJSDocNameReference, ts.isJSDocLinkLike, ts.isJSDocMemberName))) { - return 7 /* All */; + return 7 /* SemanticMeaning.All */; } else if (isTypeReference(node)) { - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (isNamespaceReference(node)) { - return 4 /* Namespace */; + return 4 /* SemanticMeaning.Namespace */; } else if (ts.isTypeParameterDeclaration(parent)) { ts.Debug.assert(ts.isJSDocTemplateTag(parent.parent)); // Else would be handled by isDeclarationName - return 2 /* Type */; + return 2 /* SemanticMeaning.Type */; } else if (ts.isLiteralTypeNode(parent)) { // This might be T["name"], which is actually referencing a property and not a type. So allow both meanings. - return 2 /* Type */ | 1 /* Value */; + return 2 /* SemanticMeaning.Type */ | 1 /* SemanticMeaning.Value */; } else { - return 1 /* Value */; + return 1 /* SemanticMeaning.Value */; } } ts.getMeaningFromLocation = getMeaningFromLocation; @@ -127967,11 +128630,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 161 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 265 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 161 /* SyntaxKind.QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? 7 /* SemanticMeaning.All */ : 4 /* SemanticMeaning.Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -127983,27 +128646,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 161 /* QualifiedName */) { - while (root.parent && root.parent.kind === 161 /* QualifiedName */) { + if (root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + while (root.parent && root.parent.kind === 161 /* SyntaxKind.QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 178 /* TypeReference */ && !isLastClause; + return root.parent.kind === 178 /* SyntaxKind.TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 206 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 206 /* PropertyAccessExpression */) { + if (root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 228 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && root.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 257 /* ClassDeclaration */ && root.parent.parent.token === 117 /* ImplementsKeyword */) || - (decl.kind === 258 /* InterfaceDeclaration */ && root.parent.parent.token === 94 /* ExtendsKeyword */); + return (decl.kind === 257 /* SyntaxKind.ClassDeclaration */ && root.parent.parent.token === 117 /* SyntaxKind.ImplementsKeyword */) || + (decl.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && root.parent.parent.token === 94 /* SyntaxKind.ExtendsKeyword */); } return false; } @@ -128012,17 +128675,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return !ts.isExpressionNode(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return true; } switch (node.parent.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return true; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return !node.parent.isTypeOf; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isPartOfTypeNode(node.parent); } return false; @@ -128089,7 +128752,7 @@ var ts; ts.climbPastPropertyOrElementAccess = climbPastPropertyOrElementAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 250 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 250 /* SyntaxKind.LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -128150,22 +128813,22 @@ var ts; ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 261 /* ModuleDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.parent.argumentExpression === node; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return true; - case 196 /* LiteralType */: - return node.parent.parent.kind === 194 /* IndexedAccessType */; + case 196 /* SyntaxKind.LiteralType */: + return node.parent.parent.kind === 194 /* SyntaxKind.IndexedAccessType */; default: return false; } @@ -128189,17 +128852,17 @@ var ts; return undefined; } switch (node.kind) { - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return node; } } @@ -128207,108 +128870,108 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 305 /* SourceFile */: - return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 261 /* ModuleDeclaration */: - return "module" /* moduleElement */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return "class" /* classElement */; - case 258 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 259 /* TypeAliasDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - return "type" /* typeElement */; - case 260 /* EnumDeclaration */: return "enum" /* enumElement */; - case 254 /* VariableDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + return ts.isExternalModule(node) ? "module" /* ScriptElementKind.moduleElement */ : "script" /* ScriptElementKind.scriptElement */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return "module" /* ScriptElementKind.moduleElement */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return "class" /* ScriptElementKind.classElement */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return "interface" /* ScriptElementKind.interfaceElement */; + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + return "type" /* ScriptElementKind.typeElement */; + case 260 /* SyntaxKind.EnumDeclaration */: return "enum" /* ScriptElementKind.enumElement */; + case 254 /* SyntaxKind.VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - return "function" /* functionElement */; - case 172 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 173 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - return "method" /* memberFunctionElement */; - case 296 /* PropertyAssignment */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + return "function" /* ScriptElementKind.functionElement */; + case 172 /* SyntaxKind.GetAccessor */: return "getter" /* ScriptElementKind.memberGetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: return "setter" /* ScriptElementKind.memberSetAccessorElement */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + return "method" /* ScriptElementKind.memberFunctionElement */; + case 296 /* SyntaxKind.PropertyAssignment */: var initializer = node.initializer; - return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: - return "property" /* memberVariableElement */; - case 176 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 175 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 174 /* CallSignature */: return "call" /* callSignatureElement */; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: - return "constructor" /* constructorImplementationElement */; - case 163 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 299 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 164 /* Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - return "alias" /* alias */; - case 221 /* BinaryExpression */: + return ts.isFunctionLike(initializer) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: + return "property" /* ScriptElementKind.memberVariableElement */; + case 176 /* SyntaxKind.IndexSignature */: return "index" /* ScriptElementKind.indexSignatureElement */; + case 175 /* SyntaxKind.ConstructSignature */: return "construct" /* ScriptElementKind.constructSignatureElement */; + case 174 /* SyntaxKind.CallSignature */: return "call" /* ScriptElementKind.callSignatureElement */; + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + case 163 /* SyntaxKind.TypeParameter */: return "type parameter" /* ScriptElementKind.typeParameterElement */; + case 299 /* SyntaxKind.EnumMember */: return "enum member" /* ScriptElementKind.enumMemberElement */; + case 164 /* SyntaxKind.Parameter */: return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) ? "property" /* ScriptElementKind.memberVariableElement */ : "parameter" /* ScriptElementKind.parameterElement */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + return "alias" /* ScriptElementKind.alias */; + case 221 /* SyntaxKind.BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: - case 0 /* None */: - return "" /* unknown */; - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: + case 0 /* AssignmentDeclarationKind.None */: + return "" /* ScriptElementKind.unknown */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: var rightKind = getNodeKind(right); - return rightKind === "" /* unknown */ ? "const" /* constElement */ : rightKind; - case 3 /* PrototypeProperty */: - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 4 /* ThisProperty */: - return "property" /* memberVariableElement */; // property - case 5 /* Property */: + return rightKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : rightKind; + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 4 /* AssignmentDeclarationKind.ThisProperty */: + return "property" /* ScriptElementKind.memberVariableElement */; // property + case 5 /* AssignmentDeclarationKind.Property */: // static method / property - return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; - case 6 /* Prototype */: - return "local class" /* localClassElement */; + return ts.isFunctionExpression(right) ? "method" /* ScriptElementKind.memberFunctionElement */ : "property" /* ScriptElementKind.memberVariableElement */; + case 6 /* AssignmentDeclarationKind.Prototype */: + return "local class" /* ScriptElementKind.localClassElement */; default: { ts.assertType(kind); - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } } - case 79 /* Identifier */: - return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; - case 271 /* ExportAssignment */: + case 79 /* SyntaxKind.Identifier */: + return ts.isImportClause(node.parent) ? "alias" /* ScriptElementKind.alias */ : "" /* ScriptElementKind.unknown */; + case 271 /* SyntaxKind.ExportAssignment */: var scriptKind = getNodeKind(node.expression); // If the expression didn't come back with something (like it does for an identifiers) - return scriptKind === "" /* unknown */ ? "const" /* constElement */ : scriptKind; + return scriptKind === "" /* ScriptElementKind.unknown */ ? "const" /* ScriptElementKind.constElement */ : scriptKind; default: - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getKindOfVariableDeclaration(v) { return ts.isVarConst(v) - ? "const" /* constElement */ + ? "const" /* ScriptElementKind.constElement */ : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? "let" /* ScriptElementKind.letElement */ + : "var" /* ScriptElementKind.variableElement */; } } ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 164 /* SyntaxKind.Parameter */; default: return false; } @@ -128373,42 +129036,42 @@ var ts; return false; } switch (n.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 201 /* ObjectBindingPattern */: - case 182 /* TypeLiteral */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 263 /* CaseBlock */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: - return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 292 /* CatchClause */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 182 /* SyntaxKind.TypeLiteral */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 263 /* SyntaxKind.CaseBlock */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: + return nodeEndsWith(n, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + case 292 /* SyntaxKind.CatchClause */: return isCompletedNode(n.block, sourceFile); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: if (!n.arguments) { return true; } // falls through - case 208 /* CallExpression */: - case 212 /* ParenthesizedExpression */: - case 191 /* ParenthesizedType */: - return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 208 /* SyntaxKind.CallExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + return nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 214 /* ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 214 /* SyntaxKind.ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -128417,66 +129080,66 @@ var ts; } // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. - return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 261 /* ModuleDeclaration */: + return hasChildOfKind(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile); + case 261 /* SyntaxKind.ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || - hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 204 /* ArrayLiteralExpression */: - case 202 /* ArrayBindingPattern */: - case 207 /* ElementAccessExpression */: - case 162 /* ComputedPropertyName */: - case 184 /* TupleType */: - return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 176 /* IndexSignature */: + hasChildOfKind(n, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 184 /* SyntaxKind.TupleType */: + return nodeEndsWith(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 176 /* SyntaxKind.IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } - return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + return hasChildOfKind(n, 23 /* SyntaxKind.CloseBracketToken */, sourceFile); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 115 /* WhileKeyword */, sourceFile) - ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) + return hasChildOfKind(n, 115 /* SyntaxKind.WhileKeyword */, sourceFile) + ? nodeEndsWith(n, 21 /* SyntaxKind.CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 216 /* TypeOfExpression */: - case 215 /* DeleteExpression */: - case 217 /* VoidExpression */: - case 224 /* YieldExpression */: - case 225 /* SpreadElement */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 225 /* SyntaxKind.SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -128493,7 +129156,7 @@ var ts; if (lastChild.kind === expectedLastToken) { return true; } - else if (lastChild.kind === 26 /* SemicolonToken */ && children.length !== 1) { + else if (lastChild.kind === 26 /* SyntaxKind.SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -128536,13 +129199,13 @@ var ts; } ts.findContainingList = findContainingList; function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } function isClassKeyword(node) { - return node.kind === 84 /* ClassKeyword */; + return node.kind === 84 /* SyntaxKind.ClassKeyword */; } function isFunctionKeyword(node) { - return node.kind === 98 /* FunctionKeyword */; + return node.kind === 98 /* SyntaxKind.FunctionKeyword */; } function getAdjustedLocationForClass(node) { if (ts.isNamedDeclaration(node)) { @@ -128601,13 +129264,13 @@ var ts; function getAdjustedLocationForDeclaration(node, forRename) { if (!forRename) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return getAdjustedLocationForClass(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return getAdjustedLocationForFunction(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return node; } } @@ -128697,30 +129360,30 @@ var ts; // // NOTE: If the node is a modifier, we don't adjust its location if it is the `default` modifier as that is handled // specially by `getSymbolAtLocation`. - if (ts.isModifier(node) && (forRename || node.kind !== 88 /* DefaultKeyword */) ? ts.canHaveModifiers(parent) && ts.contains(parent.modifiers, node) : - node.kind === 84 /* ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : - node.kind === 98 /* FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : - node.kind === 118 /* InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : - node.kind === 92 /* EnumKeyword */ ? ts.isEnumDeclaration(parent) : - node.kind === 152 /* TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : - node.kind === 142 /* NamespaceKeyword */ || node.kind === 141 /* ModuleKeyword */ ? ts.isModuleDeclaration(parent) : - node.kind === 100 /* ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : - node.kind === 136 /* GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : - node.kind === 149 /* SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { + if (ts.isModifier(node) && (forRename || node.kind !== 88 /* SyntaxKind.DefaultKeyword */) ? ts.canHaveModifiers(parent) && ts.contains(parent.modifiers, node) : + node.kind === 84 /* SyntaxKind.ClassKeyword */ ? ts.isClassDeclaration(parent) || ts.isClassExpression(node) : + node.kind === 98 /* SyntaxKind.FunctionKeyword */ ? ts.isFunctionDeclaration(parent) || ts.isFunctionExpression(node) : + node.kind === 118 /* SyntaxKind.InterfaceKeyword */ ? ts.isInterfaceDeclaration(parent) : + node.kind === 92 /* SyntaxKind.EnumKeyword */ ? ts.isEnumDeclaration(parent) : + node.kind === 152 /* SyntaxKind.TypeKeyword */ ? ts.isTypeAliasDeclaration(parent) : + node.kind === 142 /* SyntaxKind.NamespaceKeyword */ || node.kind === 141 /* SyntaxKind.ModuleKeyword */ ? ts.isModuleDeclaration(parent) : + node.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.isImportEqualsDeclaration(parent) : + node.kind === 136 /* SyntaxKind.GetKeyword */ ? ts.isGetAccessorDeclaration(parent) : + node.kind === 149 /* SyntaxKind.SetKeyword */ && ts.isSetAccessorDeclaration(parent)) { var location = getAdjustedLocationForDeclaration(parent, forRename); if (location) { return location; } } // /**/ [|name|] ... - if ((node.kind === 113 /* VarKeyword */ || node.kind === 85 /* ConstKeyword */ || node.kind === 119 /* LetKeyword */) && + if ((node.kind === 113 /* SyntaxKind.VarKeyword */ || node.kind === 85 /* SyntaxKind.ConstKeyword */ || node.kind === 119 /* SyntaxKind.LetKeyword */) && ts.isVariableDeclarationList(parent) && parent.declarations.length === 1) { var decl = parent.declarations[0]; if (ts.isIdentifier(decl.name)) { return decl.name; } } - if (node.kind === 152 /* TypeKeyword */) { + if (node.kind === 152 /* SyntaxKind.TypeKeyword */) { // import /**/type [|name|] from ...; // import /**/type { [|name|] } from ...; // import /**/type { propertyName as [|name|] } from ...; @@ -128746,7 +129409,7 @@ var ts; // import * /**/as [|name|] ... // export { propertyName /**/as [|name|] } ... // export * /**/as [|name|] ... - if (node.kind === 127 /* AsKeyword */) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */) { if (ts.isImportSpecifier(parent) && parent.propertyName || ts.isExportSpecifier(parent) && parent.propertyName || ts.isNamespaceImport(parent) || @@ -128762,13 +129425,13 @@ var ts; // /**/import { propertyName as [|name|] } from ...; // /**/import ... from "[|module|]"; // /**/import "[|module|]"; - if (node.kind === 100 /* ImportKeyword */ && ts.isImportDeclaration(parent)) { + if (node.kind === 100 /* SyntaxKind.ImportKeyword */ && ts.isImportDeclaration(parent)) { var location = getAdjustedLocationForImportDeclaration(parent, forRename); if (location) { return location; } } - if (node.kind === 93 /* ExportKeyword */) { + if (node.kind === 93 /* SyntaxKind.ExportKeyword */) { // /**/export { [|name|] } ...; // /**/export { propertyName as [|name|] } ...; // /**/export * from "[|module|]"; @@ -128787,12 +129450,12 @@ var ts; } } // import name = /**/require("[|module|]"); - if (node.kind === 146 /* RequireKeyword */ && ts.isExternalModuleReference(parent)) { + if (node.kind === 146 /* SyntaxKind.RequireKeyword */ && ts.isExternalModuleReference(parent)) { return parent.expression; } // import ... /**/from "[|module|]"; // export ... /**/from "[|module|]"; - if (node.kind === 156 /* FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { + if (node.kind === 156 /* SyntaxKind.FromKeyword */ && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent)) && parent.moduleSpecifier) { return parent.moduleSpecifier; } // class ... /**/extends [|name|] ... @@ -128800,13 +129463,13 @@ var ts; // class ... /**/implements name1, name2 ... // interface ... /**/extends [|name|] ... // interface ... /**/extends name1, name2 ... - if ((node.kind === 94 /* ExtendsKeyword */ || node.kind === 117 /* ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { + if ((node.kind === 94 /* SyntaxKind.ExtendsKeyword */ || node.kind === 117 /* SyntaxKind.ImplementsKeyword */) && ts.isHeritageClause(parent) && parent.token === node.kind) { var location = getAdjustedLocationForHeritageClause(parent); if (location) { return location; } } - if (node.kind === 94 /* ExtendsKeyword */) { + if (node.kind === 94 /* SyntaxKind.ExtendsKeyword */) { // ... ... if (ts.isTypeParameterDeclaration(parent) && parent.constraint && ts.isTypeReferenceNode(parent.constraint)) { return parent.constraint.typeName; @@ -128817,20 +129480,20 @@ var ts; } } // ... T extends /**/infer [|U|] ? ... - if (node.kind === 137 /* InferKeyword */ && ts.isInferTypeNode(parent)) { + if (node.kind === 137 /* SyntaxKind.InferKeyword */ && ts.isInferTypeNode(parent)) { return parent.typeParameter.name; } // { [ [|K|] /**/in keyof T]: ... } - if (node.kind === 101 /* InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isTypeParameterDeclaration(parent) && ts.isMappedTypeNode(parent.parent)) { return parent.name; } // /**/keyof [|T|] - if (node.kind === 140 /* KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* KeyOfKeyword */ && + if (node.kind === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 140 /* SyntaxKind.KeyOfKeyword */ && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // /**/readonly [|name|][] - if (node.kind === 145 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* ReadonlyKeyword */ && + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(parent) && parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isArrayTypeNode(parent.type) && ts.isTypeReferenceNode(parent.type.elementType)) { return parent.type.elementType.typeName; } @@ -128845,29 +129508,29 @@ var ts; // /**/yield [|name|] // /**/yield obj.[|name|] // /**/delete obj.[|name|] - if (node.kind === 103 /* NewKeyword */ && ts.isNewExpression(parent) || - node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(parent) || - node.kind === 112 /* TypeOfKeyword */ && ts.isTypeOfExpression(parent) || - node.kind === 132 /* AwaitKeyword */ && ts.isAwaitExpression(parent) || - node.kind === 125 /* YieldKeyword */ && ts.isYieldExpression(parent) || - node.kind === 89 /* DeleteKeyword */ && ts.isDeleteExpression(parent)) { + if (node.kind === 103 /* SyntaxKind.NewKeyword */ && ts.isNewExpression(parent) || + node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(parent) || + node.kind === 112 /* SyntaxKind.TypeOfKeyword */ && ts.isTypeOfExpression(parent) || + node.kind === 132 /* SyntaxKind.AwaitKeyword */ && ts.isAwaitExpression(parent) || + node.kind === 125 /* SyntaxKind.YieldKeyword */ && ts.isYieldExpression(parent) || + node.kind === 89 /* SyntaxKind.DeleteKeyword */ && ts.isDeleteExpression(parent)) { if (parent.expression) { return ts.skipOuterExpressions(parent.expression); } } // left /**/in [|name|] // left /**/instanceof [|name|] - if ((node.kind === 101 /* InKeyword */ || node.kind === 102 /* InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { + if ((node.kind === 101 /* SyntaxKind.InKeyword */ || node.kind === 102 /* SyntaxKind.InstanceOfKeyword */) && ts.isBinaryExpression(parent) && parent.operatorToken === node) { return ts.skipOuterExpressions(parent.right); } // left /**/as [|name|] - if (node.kind === 127 /* AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { + if (node.kind === 127 /* SyntaxKind.AsKeyword */ && ts.isAsExpression(parent) && ts.isTypeReferenceNode(parent.type)) { return parent.type.typeName; } // for (... /**/in [|name|]) // for (... /**/of [|name|]) - if (node.kind === 101 /* InKeyword */ && ts.isForInStatement(parent) || - node.kind === 160 /* OfKeyword */ && ts.isForOfStatement(parent)) { + if (node.kind === 101 /* SyntaxKind.InKeyword */ && ts.isForInStatement(parent) || + node.kind === 160 /* SyntaxKind.OfKeyword */ && ts.isForOfStatement(parent)) { return ts.skipOuterExpressions(parent.expression); } } @@ -128936,25 +129599,31 @@ var ts; // flag causes us to return the first node whose end position matches the position and which produces and acceptable token // kind. Meanwhile, if includePrecedingTokenAtEndPosition is unset, we look for the first node whose start is <= the // position and whose end is greater than the position. + // There are more sophisticated end tests later, but this one is very fast + // and allows us to skip a bunch of work + var end = children[middle].getEnd(); + if (end < position) { + return -1 /* Comparison.LessThan */; + } var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true); if (start > position) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } // first element whose start position is before the input and whose end position is after or equal to the input - if (nodeContainsPosition(children[middle])) { + if (nodeContainsPosition(children[middle], start, end)) { if (children[middle - 1]) { // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position if (nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // this complex condition makes us left-recur around a zero-length node when includePrecedingTokenAtEndPosition is set, rather than right-recur on it if (includePrecedingTokenAtEndPosition && start === position && children[middle - 1] && children[middle - 1].getEnd() === position && nodeContainsPosition(children[middle - 1])) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (foundToken) { return { value: foundToken }; @@ -128973,14 +129642,17 @@ var ts; case "continue-outer": continue outer; } } - function nodeContainsPosition(node) { - var start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true); + function nodeContainsPosition(node, start, end) { + end !== null && end !== void 0 ? end : (end = node.getEnd()); + if (end < position) { + return false; + } + start !== null && start !== void 0 ? start : (start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true)); if (start > position) { // If this child begins after position, then all subsequent children will as well. return false; } - var end = node.getEnd(); - if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) { + if (position < end || (position === end && (node.kind === 1 /* SyntaxKind.EndOfFileToken */ || includeEndPosition))) { return true; } else if (includePrecedingTokenAtEndPosition && end === position) { @@ -129049,7 +129721,7 @@ var ts; ts.Debug.assert(!(result && isWhiteSpaceOnlyJsxText(result))); return result; function find(n) { - if (isNonWhitespaceToken(n) && n.kind !== 1 /* EndOfFileToken */) { + if (isNonWhitespaceToken(n) && n.kind !== 1 /* SyntaxKind.EndOfFileToken */) { return n; } var children = n.getChildren(sourceFile); @@ -129061,11 +129733,11 @@ var ts; if (position < children[middle].end) { // first element whose end position is greater than the input position if (!children[middle - 1] || position >= children[middle - 1].end) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; }); if (i >= 0 && children[i]) { var child = children[i]; @@ -129090,7 +129762,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 305 /* SyntaxKind.SourceFile */ || n.kind === 1 /* SyntaxKind.EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -129121,7 +129793,7 @@ var ts; for (var i = exclusiveStartPosition - 1; i >= 0; i--) { var child = children[i]; if (isWhiteSpaceOnlyJsxText(child)) { - if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 279 /* JsxSelfClosingElement */)) { + if (i === 0 && (parentKind === 11 /* SyntaxKind.JsxText */ || parentKind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`"); } } @@ -129157,25 +129829,25 @@ var ts; if (!token) { return false; } - if (token.kind === 11 /* JsxText */) { + if (token.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
Hello |
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 11 /* SyntaxKind.JsxText */) { return true; } //
{ |
or
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 288 /* JsxExpression */) { + if (token && token.kind === 19 /* SyntaxKind.CloseBraceToken */ && token.parent.kind === 288 /* SyntaxKind.JsxExpression */) { return true; } //
|
- if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 281 /* JsxClosingElement */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && token.parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return true; } return false; @@ -129194,10 +129866,10 @@ var ts; if (ts.isJsxText(token)) { return true; } - if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -129206,17 +129878,17 @@ var ts; function isInsideJsxElement(sourceFile, position) { function isInsideJsxElementTraversal(node) { while (node) { - if (node.kind >= 279 /* JsxSelfClosingElement */ && node.kind <= 288 /* JsxExpression */ - || node.kind === 11 /* JsxText */ - || node.kind === 29 /* LessThanToken */ - || node.kind === 31 /* GreaterThanToken */ - || node.kind === 79 /* Identifier */ - || node.kind === 19 /* CloseBraceToken */ - || node.kind === 18 /* OpenBraceToken */ - || node.kind === 43 /* SlashToken */) { + if (node.kind >= 279 /* SyntaxKind.JsxSelfClosingElement */ && node.kind <= 288 /* SyntaxKind.JsxExpression */ + || node.kind === 11 /* SyntaxKind.JsxText */ + || node.kind === 29 /* SyntaxKind.LessThanToken */ + || node.kind === 31 /* SyntaxKind.GreaterThanToken */ + || node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 19 /* SyntaxKind.CloseBraceToken */ + || node.kind === 18 /* SyntaxKind.OpenBraceToken */ + || node.kind === 43 /* SyntaxKind.SlashToken */) { node = node.parent; } - else if (node.kind === 278 /* JsxElement */) { + else if (node.kind === 278 /* SyntaxKind.JsxElement */) { if (position > node.getStart(sourceFile)) return true; node = node.parent; @@ -129306,10 +129978,10 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); - if (token && token.kind === 28 /* QuestionDotToken */) { + if (token && token.kind === 28 /* SyntaxKind.QuestionDotToken */) { token = findPrecedingToken(token.getFullStart(), sourceFile); } if (!token || !ts.isIdentifier(token)) @@ -129319,56 +129991,56 @@ var ts; } remainingLessThanTokens--; break; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 48 /* GreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: remainingLessThanTokens++; break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 18 /* OpenBraceToken */, sourceFile); + token = findPrecedingMatchingToken(token, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!token) return undefined; break; - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 20 /* OpenParenToken */, sourceFile); + token = findPrecedingMatchingToken(token, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (!token) return undefined; break; - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: // This can be object type, skip until we find the matching open brace token // Skip until the matching open brace token - token = findPrecedingMatchingToken(token, 22 /* OpenBracketToken */, sourceFile); + token = findPrecedingMatchingToken(token, 22 /* SyntaxKind.OpenBracketToken */, sourceFile); if (!token) return undefined; break; // Valid tokens in a type name. Skip. - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: nTypeArguments++; break; - case 38 /* EqualsGreaterThanToken */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: // falls through - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: // falls through - case 112 /* TypeOfKeyword */: - case 94 /* ExtendsKeyword */: - case 140 /* KeyOfKeyword */: - case 24 /* DotToken */: - case 51 /* BarToken */: - case 57 /* QuestionToken */: - case 58 /* ColonToken */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 94 /* SyntaxKind.ExtendsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 24 /* SyntaxKind.DotToken */: + case 51 /* SyntaxKind.BarToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 58 /* SyntaxKind.ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -129400,52 +130072,52 @@ var ts; function nodeHasTokens(n, sourceFile) { // If we have a token or node that has a non-zero width, it must have tokens. // Note: getWidth() does not take trivia into account. - return n.kind === 1 /* EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; + return n.kind === 1 /* SyntaxKind.EndOfFileToken */ ? !!n.jsDoc : n.getWidth(sourceFile) !== 0; } function getNodeModifiers(node, excludeFlags) { - if (excludeFlags === void 0) { excludeFlags = 0 /* None */; } + if (excludeFlags === void 0) { excludeFlags = 0 /* ModifierFlags.None */; } var result = []; var flags = ts.isDeclaration(node) ? ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(node) & ~excludeFlags - : 0 /* None */; - if (flags & 8 /* Private */) - result.push("private" /* privateMemberModifier */); - if (flags & 16 /* Protected */) - result.push("protected" /* protectedMemberModifier */); - if (flags & 4 /* Public */) - result.push("public" /* publicMemberModifier */); - if (flags & 32 /* Static */ || ts.isClassStaticBlockDeclaration(node)) - result.push("static" /* staticModifier */); - if (flags & 128 /* Abstract */) - result.push("abstract" /* abstractModifier */); - if (flags & 1 /* Export */) - result.push("export" /* exportedModifier */); - if (flags & 8192 /* Deprecated */) - result.push("deprecated" /* deprecatedModifier */); - if (node.flags & 16777216 /* Ambient */) - result.push("declare" /* ambientModifier */); - if (node.kind === 271 /* ExportAssignment */) - result.push("export" /* exportedModifier */); - return result.length > 0 ? result.join(",") : "" /* none */; + : 0 /* ModifierFlags.None */; + if (flags & 8 /* ModifierFlags.Private */) + result.push("private" /* ScriptElementKindModifier.privateMemberModifier */); + if (flags & 16 /* ModifierFlags.Protected */) + result.push("protected" /* ScriptElementKindModifier.protectedMemberModifier */); + if (flags & 4 /* ModifierFlags.Public */) + result.push("public" /* ScriptElementKindModifier.publicMemberModifier */); + if (flags & 32 /* ModifierFlags.Static */ || ts.isClassStaticBlockDeclaration(node)) + result.push("static" /* ScriptElementKindModifier.staticModifier */); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push("abstract" /* ScriptElementKindModifier.abstractModifier */); + if (flags & 1 /* ModifierFlags.Export */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + if (flags & 8192 /* ModifierFlags.Deprecated */) + result.push("deprecated" /* ScriptElementKindModifier.deprecatedModifier */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) + result.push("declare" /* ScriptElementKindModifier.ambientModifier */); + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) + result.push("export" /* ScriptElementKindModifier.exportedModifier */); + return result.length > 0 ? result.join(",") : "" /* ScriptElementKindModifier.none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 178 /* TypeReference */ || node.kind === 208 /* CallExpression */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 208 /* SyntaxKind.CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 257 /* ClassDeclaration */ || node.kind === 258 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isComment(kind) { - return kind === 2 /* SingleLineCommentTrivia */ || kind === 3 /* MultiLineCommentTrivia */; + return kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || kind === 3 /* SyntaxKind.MultiLineCommentTrivia */; } ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { - if (kind === 10 /* StringLiteral */ - || kind === 13 /* RegularExpressionLiteral */ + if (kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 13 /* SyntaxKind.RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -129453,7 +130125,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 78 /* LastPunctuation */; + return 18 /* SyntaxKind.FirstPunctuation */ <= kind && kind <= 78 /* SyntaxKind.LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -129463,9 +130135,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: return true; } return false; @@ -129478,18 +130150,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 204 /* ArrayLiteralExpression */ || - node.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || + node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 221 /* BinaryExpression */ && + if (node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 63 /* EqualsToken */) { + node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 244 /* ForOfStatement */ && + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -129497,7 +130169,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -129520,8 +130192,8 @@ var ts; if (!contextToken) return undefined; switch (contextToken.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTextSpanFromStringLiteralLikeContent(contextToken); default: return createTextSpanFromNode(contextToken); @@ -129559,32 +130231,32 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 130 /* AnyKeyword */, - 128 /* AssertsKeyword */, - 158 /* BigIntKeyword */, - 133 /* BooleanKeyword */, - 95 /* FalseKeyword */, - 137 /* InferKeyword */, - 140 /* KeyOfKeyword */, - 143 /* NeverKeyword */, - 104 /* NullKeyword */, - 147 /* NumberKeyword */, - 148 /* ObjectKeyword */, - 145 /* ReadonlyKeyword */, - 150 /* StringKeyword */, - 151 /* SymbolKeyword */, - 110 /* TrueKeyword */, - 114 /* VoidKeyword */, - 153 /* UndefinedKeyword */, - 154 /* UniqueKeyword */, - 155 /* UnknownKeyword */, + 130 /* SyntaxKind.AnyKeyword */, + 128 /* SyntaxKind.AssertsKeyword */, + 158 /* SyntaxKind.BigIntKeyword */, + 133 /* SyntaxKind.BooleanKeyword */, + 95 /* SyntaxKind.FalseKeyword */, + 137 /* SyntaxKind.InferKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 143 /* SyntaxKind.NeverKeyword */, + 104 /* SyntaxKind.NullKeyword */, + 147 /* SyntaxKind.NumberKeyword */, + 148 /* SyntaxKind.ObjectKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 150 /* SyntaxKind.StringKeyword */, + 151 /* SyntaxKind.SymbolKeyword */, + 110 /* SyntaxKind.TrueKeyword */, + 114 /* SyntaxKind.VoidKeyword */, + 153 /* SyntaxKind.UndefinedKeyword */, + 154 /* SyntaxKind.UniqueKeyword */, + 155 /* SyntaxKind.UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); } ts.isTypeKeyword = isTypeKeyword; function isTypeKeywordToken(node) { - return node.kind === 152 /* TypeKeyword */; + return node.kind === 152 /* SyntaxKind.TypeKeyword */; } ts.isTypeKeywordToken = isTypeKeywordToken; function isTypeKeywordTokenOrIdentifier(node) { @@ -129593,7 +130265,7 @@ var ts; ts.isTypeKeywordTokenOrIdentifier = isTypeKeywordTokenOrIdentifier; /** True if the symbol is for an external module, as opposed to a namespace. */ function isExternalModuleSymbol(moduleSymbol) { - return !!(moduleSymbol.flags & 1536 /* Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */; + return !!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */) && moduleSymbol.name.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isExternalModuleSymbol = isExternalModuleSymbol; function nodeSeenTracker() { @@ -129621,7 +130293,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 162 /* ComputedPropertyName */ + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name); @@ -129636,7 +130308,7 @@ var ts; } ts.programContainsEsModules = programContainsEsModules; function compilerOptionsIndicateEsModules(compilerOptions) { - return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ || !!compilerOptions.noEmit; + return !!compilerOptions.module || ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ || !!compilerOptions.noEmit; } ts.compilerOptionsIndicateEsModules = compilerOptionsIndicateEsModules; function createModuleSpecifierResolutionHost(program, host) { @@ -129684,7 +130356,7 @@ var ts; } ts.makeImport = makeImport; function makeStringLiteral(text, quotePreference) { - return ts.factory.createStringLiteral(text, quotePreference === 0 /* Single */); + return ts.factory.createStringLiteral(text, quotePreference === 0 /* QuotePreference.Single */); } ts.makeStringLiteral = makeStringLiteral; var QuotePreference; @@ -129693,25 +130365,25 @@ var ts; QuotePreference[QuotePreference["Double"] = 1] = "Double"; })(QuotePreference = ts.QuotePreference || (ts.QuotePreference = {})); function quotePreferenceFromString(str, sourceFile) { - return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* Double */ : 0 /* Single */; + return ts.isStringDoubleQuoted(str, sourceFile) ? 1 /* QuotePreference.Double */ : 0 /* QuotePreference.Single */; } ts.quotePreferenceFromString = quotePreferenceFromString; function getQuotePreference(sourceFile, preferences) { if (preferences.quotePreference && preferences.quotePreference !== "auto") { - return preferences.quotePreference === "single" ? 0 /* Single */ : 1 /* Double */; + return preferences.quotePreference === "single" ? 0 /* QuotePreference.Single */ : 1 /* QuotePreference.Double */; } else { // ignore synthetic import added when importHelpers: true var firstModuleSpecifier = sourceFile.imports && ts.find(sourceFile.imports, function (n) { return ts.isStringLiteral(n) && !ts.nodeIsSynthesized(n.parent); }); - return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* Double */; + return firstModuleSpecifier ? quotePreferenceFromString(firstModuleSpecifier, sourceFile) : 1 /* QuotePreference.Double */; } } ts.getQuotePreference = getQuotePreference; function getQuoteFromPreference(qp) { switch (qp) { - case 0 /* Single */: return "'"; - case 1 /* Double */: return '"'; + case 0 /* QuotePreference.Single */: return "'"; + case 1 /* QuotePreference.Double */: return '"'; default: return ts.Debug.assertNever(qp); } } @@ -129722,12 +130394,12 @@ var ts; } ts.symbolNameNoDefault = symbolNameNoDefault; function symbolEscapedNameNoDefault(symbol) { - if (symbol.escapedName !== "default" /* Default */) { + if (symbol.escapedName !== "default" /* InternalSymbolName.Default */) { return symbol.escapedName; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 79 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 79 /* SyntaxKind.Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -129771,7 +130443,7 @@ var ts; ts.findModifier = findModifier; function insertImports(changes, sourceFile, imports, blankLineBetween) { var decl = ts.isArray(imports) ? imports[0] : imports; - var importKindPredicate = decl.kind === 237 /* VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; + var importKindPredicate = decl.kind === 237 /* SyntaxKind.VariableStatement */ ? ts.isRequireVariableStatement : ts.isAnyImportSyntax; var existingImportStatements = ts.filter(sourceFile.statements, importKindPredicate); var sortedNewImports = ts.isArray(imports) ? ts.stableSort(imports, ts.OrganizeImports.compareImportsOrRequireStatements) : [imports]; if (!existingImportStatements.length) { @@ -129984,34 +130656,34 @@ var ts; return displayPart(text, displayPartKind(symbol)); function displayPartKind(symbol) { var flags = symbol.flags; - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { return isFirstDeclarationOfSymbolParameter(symbol) ? ts.SymbolDisplayPartKind.parameterName : ts.SymbolDisplayPartKind.localName; } - if (flags & 4 /* Property */) + if (flags & 4 /* SymbolFlags.Property */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 32768 /* GetAccessor */) + if (flags & 32768 /* SymbolFlags.GetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 65536 /* SetAccessor */) + if (flags & 65536 /* SymbolFlags.SetAccessor */) return ts.SymbolDisplayPartKind.propertyName; - if (flags & 8 /* EnumMember */) + if (flags & 8 /* SymbolFlags.EnumMember */) return ts.SymbolDisplayPartKind.enumMemberName; - if (flags & 16 /* Function */) + if (flags & 16 /* SymbolFlags.Function */) return ts.SymbolDisplayPartKind.functionName; - if (flags & 32 /* Class */) + if (flags & 32 /* SymbolFlags.Class */) return ts.SymbolDisplayPartKind.className; - if (flags & 64 /* Interface */) + if (flags & 64 /* SymbolFlags.Interface */) return ts.SymbolDisplayPartKind.interfaceName; - if (flags & 384 /* Enum */) + if (flags & 384 /* SymbolFlags.Enum */) return ts.SymbolDisplayPartKind.enumName; - if (flags & 1536 /* Module */) + if (flags & 1536 /* SymbolFlags.Module */) return ts.SymbolDisplayPartKind.moduleName; - if (flags & 8192 /* Method */) + if (flags & 8192 /* SymbolFlags.Method */) return ts.SymbolDisplayPartKind.methodName; - if (flags & 262144 /* TypeParameter */) + if (flags & 262144 /* SymbolFlags.TypeParameter */) return ts.SymbolDisplayPartKind.typeParameterName; - if (flags & 524288 /* TypeAlias */) + if (flags & 524288 /* SymbolFlags.TypeAlias */) return ts.SymbolDisplayPartKind.aliasName; - if (flags & 2097152 /* Alias */) + if (flags & 2097152 /* SymbolFlags.Alias */) return ts.SymbolDisplayPartKind.aliasName; return ts.SymbolDisplayPartKind.text; } @@ -130088,7 +130760,7 @@ var ts; var prefix = ts.isJSDocLink(link) ? "link" : ts.isJSDocLinkCode(link) ? "linkcode" : "linkplain"; - var parts = [linkPart("{@" + prefix + " ")]; + var parts = [linkPart("{@".concat(prefix, " "))]; if (!link.name) { if (link.text) { parts.push(linkTextPart(link.text)); @@ -130115,8 +130787,8 @@ var ts; ts.buildLinkParts = buildLinkParts; function skipSeparatorFromLinkText(text) { var pos = 0; - if (text.charCodeAt(pos++) === 124 /* bar */) { - while (pos < text.length && text.charCodeAt(pos) === 32 /* space */) + if (text.charCodeAt(pos++) === 124 /* CharacterCodes.bar */) { + while (pos < text.length && text.charCodeAt(pos) === 32 /* CharacterCodes.space */) pos++; return text.slice(pos); } @@ -130166,22 +130838,22 @@ var ts; } ts.mapToDisplayParts = mapToDisplayParts; function typeToDisplayParts(typechecker, type, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer); + typechecker.writeType(type, enclosingDeclaration, flags | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.typeToDisplayParts = typeToDisplayParts; function symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration, meaning, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* SymbolFormatFlags.None */; } return mapToDisplayParts(function (writer) { - typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* UseAliasDefinedOutsideCurrentScope */, writer); + typeChecker.writeSymbol(symbol, enclosingDeclaration, meaning, flags | 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */, writer); }); } ts.symbolToDisplayParts = symbolToDisplayParts; function signatureToDisplayParts(typechecker, signature, enclosingDeclaration, flags) { - if (flags === void 0) { flags = 0 /* None */; } - flags |= 16384 /* UseAliasDefinedOutsideCurrentScope */ | 1024 /* MultilineObjectLiterals */ | 32 /* WriteTypeArgumentsOfSignature */ | 8192 /* OmitParameterModifiers */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + flags |= 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */ | 1024 /* TypeFormatFlags.MultilineObjectLiterals */ | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */ | 8192 /* TypeFormatFlags.OmitParameterModifiers */; return mapToDisplayParts(function (writer) { typechecker.writeSignature(signature, enclosingDeclaration, flags, /*signatureKind*/ undefined, writer); }); @@ -130191,7 +130863,7 @@ var ts; var file = enclosingDeclaration.getSourceFile(); return mapToDisplayParts(function (writer) { var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - printer.writeNode(4 /* Unspecified */, node, file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, node, file, writer); }); } ts.nodeToDisplayParts = nodeToDisplayParts; @@ -130219,10 +130891,10 @@ var ts; } ts.getSymbolTarget = getSymbolTarget; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } function isAliasSymbol(symbol) { - return (symbol.flags & 2097152 /* Alias */) !== 0; + return (symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0; } function getUniqueSymbolId(symbol, checker) { return ts.getSymbolId(ts.skipAlias(symbol, checker)); @@ -130311,14 +130983,14 @@ var ts; * Sets EmitFlags to suppress leading trivia on the node. */ function suppressLeadingTrivia(node) { - addEmitFlagsRecursively(node, 512 /* NoLeadingComments */, getFirstChild); + addEmitFlagsRecursively(node, 512 /* EmitFlags.NoLeadingComments */, getFirstChild); } ts.suppressLeadingTrivia = suppressLeadingTrivia; /** * Sets EmitFlags to suppress trailing trivia on the node. */ function suppressTrailingTrivia(node) { - addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); + addEmitFlagsRecursively(node, 1024 /* EmitFlags.NoTrailingComments */, ts.getLastChild); } ts.suppressTrailingTrivia = suppressTrailingTrivia; function copyComments(sourceNode, targetNode) { @@ -130337,7 +131009,7 @@ var ts; var start = node.getFullStart(); var end = node.getStart(); for (var i = start; i < end; i++) { - if (text.charCodeAt(i) === 10 /* lineFeed */) + if (text.charCodeAt(i) === 10 /* CharacterCodes.lineFeed */) return true; } return false; @@ -130354,7 +131026,7 @@ var ts; function getUniqueName(baseName, sourceFile) { var nameText = baseName; for (var i = 1; !ts.isFileLevelUniqueName(sourceFile, nameText); i++) { - nameText = baseName + "_" + i; + nameText = "".concat(baseName, "_").concat(i); } return nameText; } @@ -130373,7 +131045,7 @@ var ts; for (var _b = 0, textChanges_1 = textChanges_2; _b < textChanges_1.length; _b++) { var change = textChanges_1[_b]; var span = change.span, newText = change.newText; - var index = indexInTextChange(newText, name); + var index = indexInTextChange(newText, ts.escapeString(name)); if (index !== -1) { lastPos = span.start + delta + index; // If the reference comes first, return immediately. @@ -130411,7 +131083,7 @@ var ts; ts.copyTrailingAsLeadingComments = copyTrailingAsLeadingComments; function getAddCommentsFunction(targetNode, sourceFile, commentKind, hasTrailingNewLine, cb) { return function (pos, end, kind, htnl) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // Remove leading /* pos += 2; // Remove trailing */ @@ -130437,7 +131109,7 @@ var ts; } /* @internal */ function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || ts.isObjectLiteralExpression(expression) || ts.isAsExpression(expression) && ts.isObjectLiteralExpression(expression.expression); } @@ -130445,15 +131117,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checker.getContextualType(parent); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -130464,15 +131136,15 @@ var ts; // Editors can pass in undefined or empty string - we want to infer the preference in those cases. var quotePreference = getQuotePreference(sourceFile, preferences); var quoted = JSON.stringify(text); - return quotePreference === 0 /* Single */ ? "'" + ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"') + "'" : quoted; + return quotePreference === 0 /* QuotePreference.Single */ ? "'".concat(ts.stripQuotes(quoted).replace(/'/g, "\\'").replace(/\\"/g, '"'), "'") : quoted; } ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: return true; default: return false; @@ -130481,10 +131153,10 @@ var ts; ts.isEqualityOperatorKind = isEqualityOperatorKind; function isStringLiteralOrTemplate(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 210 /* TaggedTemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return true; default: return false; @@ -130504,9 +131176,9 @@ var ts; var checker = program.getTypeChecker(); var typeIsAccessible = true; var notAccessible = function () { return typeIsAccessible = false; }; - var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NoTruncation */, { + var res = checker.typeToTypeNode(type, enclosingScope, 1 /* NodeBuilderFlags.NoTruncation */, { trackSymbol: function (symbol, declaration, meaning) { - typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; + typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */; return !typeIsAccessible; }, reportInaccessibleThisError: notAccessible, @@ -130518,48 +131190,48 @@ var ts; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { - return kind === 174 /* CallSignature */ - || kind === 175 /* ConstructSignature */ - || kind === 176 /* IndexSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */; + return kind === 174 /* SyntaxKind.CallSignature */ + || kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */; } function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { - return kind === 261 /* ModuleDeclaration */; + return kind === 261 /* SyntaxKind.ModuleDeclaration */; } function syntaxRequiresTrailingSemicolonOrASI(kind) { - return kind === 237 /* VariableStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 240 /* DoStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 246 /* BreakStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 167 /* PropertyDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); function nodeIsASICandidate(node, sourceFile) { var lastToken = node.getLastToken(sourceFile); - if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + if (lastToken && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */) { return false; } if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { - if (lastToken && lastToken.kind === 27 /* CommaToken */) { + if (lastToken && lastToken.kind === 27 /* SyntaxKind.CommaToken */) { return false; } } @@ -130579,12 +131251,12 @@ var ts; return false; } // See comment in parser’s `parseDoStatement` - if (node.kind === 240 /* DoStatement */) { + if (node.kind === 240 /* SyntaxKind.DoStatement */) { return true; } var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); var nextToken = findNextToken(node, topNode, sourceFile); - if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + if (!nextToken || nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { return true; } var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; @@ -130608,7 +131280,7 @@ var ts; ts.forEachChild(sourceFile, function visit(node) { if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } else { @@ -130617,10 +131289,10 @@ var ts; } else if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); - if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SemicolonToken */) { + if ((lastToken === null || lastToken === void 0 ? void 0 : lastToken.kind) === 26 /* SyntaxKind.SemicolonToken */) { withSemicolon++; } - else if (lastToken && lastToken.kind !== 27 /* CommaToken */) { + else if (lastToken && lastToken.kind !== 27 /* SyntaxKind.CommaToken */) { var lastTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, lastToken.getStart(sourceFile)).line; var nextTokenLine = ts.getLineAndCharacterOfPosition(sourceFile, ts.getSpanOfTokenAtPosition(sourceFile, lastToken.end).start).line; // Avoid counting missing semicolon in single-line objects: @@ -130744,16 +131416,16 @@ var ts; } } var dependencyGroups = [ - [1 /* Dependencies */, info.dependencies], - [2 /* DevDependencies */, info.devDependencies], - [8 /* OptionalDependencies */, info.optionalDependencies], - [4 /* PeerDependencies */, info.peerDependencies], + [1 /* PackageJsonDependencyGroup.Dependencies */, info.dependencies], + [2 /* PackageJsonDependencyGroup.DevDependencies */, info.devDependencies], + [8 /* PackageJsonDependencyGroup.OptionalDependencies */, info.optionalDependencies], + [4 /* PackageJsonDependencyGroup.PeerDependencies */, info.peerDependencies], ]; return __assign(__assign({}, info), { parseable: !!content, fileName: fileName, get: get, has: function (dependencyName, inGroups) { return !!get(dependencyName, inGroups); } }); function get(dependencyName, inGroups) { - if (inGroups === void 0) { inGroups = 15 /* All */; } + if (inGroups === void 0) { inGroups = 15 /* PackageJsonDependencyGroup.All */; } for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; if (deps && (inGroups & group_1)) { @@ -130848,7 +131520,7 @@ var ts; var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); // Scoped packages if (ts.startsWith(components[0], "@")) { - return components[0] + "/" + components[1]; + return "".concat(components[0], "/").concat(components[1]); } return components[0]; } @@ -130968,20 +131640,20 @@ var ts; } ts.getNameForExportedSymbol = getNameForExportedSymbol; function needsNameFromDeclaration(symbol) { - return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */); + return !(symbol.flags & 33554432 /* SymbolFlags.Transient */) && (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */ || symbol.escapedName === "default" /* InternalSymbolName.Default */); } function getDefaultLikeExportNameFromDeclaration(symbol) { return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; }); } function getSymbolParentOrFail(symbol) { var _a; - return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " + - ("Declarations: " + ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { + return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: ".concat(ts.Debug.formatSymbolFlags(symbol.flags), ". ") + + "Declarations: ".concat((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.map(function (d) { var kind = ts.Debug.formatSyntaxKind(d.kind); var inJS = ts.isInJSFile(d); var expression = d.expression; - return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: " + ts.Debug.formatSyntaxKind(expression.kind) + ")" : ""); - }).join(", ")) + ".")); + return (inJS ? "[JS]" : "") + kind + (expression ? " (expression: ".concat(ts.Debug.formatSyntaxKind(expression.kind), ")") : ""); + }).join(", "), ".")); } /** * Useful to check whether a string contains another string at a specific index @@ -131014,7 +131686,7 @@ var ts; } ts.stringContainsAt = stringContainsAt; function startsWithUnderscore(name) { - return name.charCodeAt(0) === 95 /* _ */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */; } ts.startsWithUnderscore = startsWithUnderscore; function isGlobalDeclaration(declaration) { @@ -131032,7 +131704,7 @@ var ts; } ts.isNonGlobalDeclaration = isNonGlobalDeclaration; function isDeprecatedDeclaration(decl) { - return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* Deprecated */); + return !!(ts.getCombinedNodeFlagsAlwaysIncludeJSDoc(decl) & 8192 /* ModifierFlags.Deprecated */); } ts.isDeprecatedDeclaration = isDeprecatedDeclaration; function shouldUseUriStyleNodeCoreModules(file, program) { @@ -131045,7 +131717,7 @@ var ts; } ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules; function getNewLineKind(newLineCharacter) { - return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; + return newLineCharacter === "\n" ? 1 /* NewLineKind.LineFeed */ : 0 /* NewLineKind.CarriageReturnLineFeed */; } ts.getNewLineKind = getNewLineKind; function diagnosticToString(diag) { @@ -131065,7 +131737,7 @@ var ts; } ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting; function jsxModeNeedsExplicitImport(jsx) { - return jsx === 2 /* React */ || jsx === 3 /* ReactNative */; + return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */; } ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport; // #endregion @@ -131137,7 +131809,7 @@ var ts; } } } - var isDefault = exportKind === 1 /* Default */; + var isDefault = exportKind === 1 /* ExportKind.Default */; var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol; // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`. // 2. A re-export merged with an export from a module augmentation can result in `symbol` @@ -131146,7 +131818,7 @@ var ts; // 3. Otherwise, we have a default/namespace import that can be imported by any name, and // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to // get a better name. - var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol) + var names = exportKind === 0 /* ExportKind.Named */ || ts.isExternalModuleSymbol(namedSymbol) ? ts.unescapeLeadingUnderscores(symbolTableKey) : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined); var symbolName = typeof names === "string" ? names : names[0]; @@ -131154,8 +131826,8 @@ var ts; var moduleName = ts.stripQuotes(moduleSymbol.name); var id = exportInfoId++; var target = ts.skipAlias(symbol, checker); - var storedSymbol = symbol.flags & 33554432 /* Transient */ ? undefined : symbol; - var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol; + var storedSymbol = symbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : symbol; + var storedModuleSymbol = moduleSymbol.flags & 33554432 /* SymbolFlags.Transient */ ? undefined : moduleSymbol; if (!storedSymbol || !storedModuleSymbol) symbols.set(id, [symbol, moduleSymbol]); exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), { @@ -131244,9 +131916,9 @@ var ts; var moduleSymbol = info.moduleSymbol || cachedModuleSymbol || ts.Debug.checkDefined(info.moduleFile ? checker.getMergedSymbol(info.moduleFile.symbol) : checker.tryFindAmbientModule(info.moduleName)); - var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportEquals */ + var symbol = info.symbol || cachedSymbol || ts.Debug.checkDefined(exportKind === 2 /* ExportKind.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) - : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '" + info.symbolName + "' by key '" + info.symbolTableKey + "' in module " + moduleSymbol.name); + : checker.tryGetMemberInModuleExportsAndProperties(ts.unescapeLeadingUnderscores(info.symbolTableKey), moduleSymbol), "Could not find symbol '".concat(info.symbolName, "' by key '").concat(info.symbolTableKey, "' in module ").concat(moduleSymbol.name)); symbols.set(id, [symbol, moduleSymbol]); return { symbol: symbol, @@ -131259,7 +131931,7 @@ var ts; } function key(importedName, symbol, ambientModuleName, checker) { var moduleKey = ambientModuleName || ""; - return importedName + "|" + ts.getSymbolId(ts.skipAlias(symbol, checker)) + "|" + moduleKey; + return "".concat(importedName, "|").concat(ts.getSymbolId(ts.skipAlias(symbol, checker)), "|").concat(moduleKey); } function parseKey(key) { var symbolName = key.substring(0, key.indexOf("|")); @@ -131355,7 +132027,7 @@ var ts; if (autoImportProvider) { var start = ts.timestamp(); forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), excludePatterns, function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); }); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: ".concat(ts.timestamp() - start)); } } ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; @@ -131404,11 +132076,11 @@ var ts; // Note: I think we shouldn't actually see resolved module symbols here, but weird merges // can cause it to happen: see 'completionsImport_mergedReExport.ts' if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) { - cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); + cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* ExportKind.Default */ ? "default" /* InternalSymbolName.Default */ : "export=" /* InternalSymbolName.ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker); } checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) { if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) { - cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker); + cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* ExportKind.Named */, isFromPackageJson, checker); } }); }); @@ -131418,7 +132090,7 @@ var ts; cache.clear(); throw err; } - (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in " + (ts.timestamp() - start) + " ms"); + (_e = host.log) === null || _e === void 0 ? void 0 : _e.call(host, "getExportInfoMap: done in ".concat(ts.timestamp() - start, " ms")); return cache; } ts.getExportInfoMap = getExportInfoMap; @@ -131437,10 +132109,10 @@ var ts; function getDefaultLikeExportWorker(moduleSymbol, checker) { var exportEquals = checker.resolveExternalModuleSymbol(moduleSymbol); if (exportEquals !== moduleSymbol) - return { symbol: exportEquals, exportKind: 2 /* ExportEquals */ }; - var defaultExport = checker.tryGetMemberInModuleExports("default" /* Default */, moduleSymbol); + return { symbol: exportEquals, exportKind: 2 /* ExportKind.ExportEquals */ }; + var defaultExport = checker.tryGetMemberInModuleExports("default" /* InternalSymbolName.Default */, moduleSymbol); if (defaultExport) - return { symbol: defaultExport, exportKind: 1 /* Default */ }; + return { symbol: defaultExport, exportKind: 1 /* ExportKind.Default */ }; } function getDefaultExportInfoWorker(defaultExport, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -131449,7 +132121,7 @@ var ts; var name = getNameForExportDefault(defaultExport); if (name !== undefined) return { symbolForMeaning: defaultExport, name: name }; - if (defaultExport.flags & 2097152 /* Alias */) { + if (defaultExport.flags & 2097152 /* SymbolFlags.Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); if (aliased && aliased.parent) { // - `aliased` will be undefined if the module is exporting an unresolvable name, @@ -131459,8 +132131,8 @@ var ts; return getDefaultExportInfoWorker(aliased, checker, compilerOptions); } } - if (defaultExport.escapedName !== "default" /* Default */ && - defaultExport.escapedName !== "export=" /* ExportEquals */) { + if (defaultExport.escapedName !== "default" /* InternalSymbolName.Default */ && + defaultExport.escapedName !== "export=" /* InternalSymbolName.ExportEquals */) { return { symbolForMeaning: defaultExport, name: defaultExport.getName() }; } return { symbolForMeaning: defaultExport, name: ts.getNameForExportedSymbol(defaultExport, compilerOptions.target) }; @@ -131472,7 +132144,7 @@ var ts; return (_a = ts.tryCast(ts.skipOuterExpressions(declaration.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); + ts.Debug.assert(declaration.name.text === "default" /* InternalSymbolName.Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -131482,15 +132154,15 @@ var ts; (function (ts) { /** The classifier is used for syntactic highlighting in editors via the TSServer */ function createClassifier() { - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false); function getClassificationsForLine(text, lexState, syntacticClassifierAbsent) { return convertClassificationsToResult(getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent), text); } // If there is a syntactic classifier ('syntacticClassifierAbsent' is false), // we will be more conservative in order to avoid conflicting with the syntactic classifier. function getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent) { - var token = 0 /* Unknown */; - var lastNonTriviaToken = 0 /* Unknown */; + var token = 0 /* SyntaxKind.Unknown */; + var lastNonTriviaToken = 0 /* SyntaxKind.Unknown */; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -131516,10 +132188,10 @@ var ts; text = prefix + text; var offset = prefix.length; if (pushTemplate) { - templateStack.push(15 /* TemplateHead */); + templateStack.push(15 /* SyntaxKind.TemplateHead */); } scanner.setText(text); - var endOfLineState = 0 /* None */; + var endOfLineState = 0 /* EndOfLineState.None */; var spans = []; // We can run into an unfortunate interaction between the lexical and syntactic classifier // when the user is typing something generic. Consider the case where the user types: @@ -131555,68 +132227,68 @@ var ts; endOfLineState = end_1; } } - } while (token !== 1 /* EndOfFileToken */); + } while (token !== 1 /* SyntaxKind.EndOfFileToken */); function handleToken() { switch (token) { - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { - token = 13 /* RegularExpressionLiteral */; + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } break; - case 29 /* LessThanToken */: - if (lastNonTriviaToken === 79 /* Identifier */) { + case 29 /* SyntaxKind.LessThanToken */: + if (lastNonTriviaToken === 79 /* SyntaxKind.Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 31 /* GreaterThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 130 /* AnyKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: templateStack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 15 /* TemplateHead */) { + if (lastTemplateStackToken === 15 /* SyntaxKind.TemplateHead */) { token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 17 /* TemplateTail */) { + if (token === 17 /* SyntaxKind.TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assertEqual(token, 16 /* TemplateMiddle */, "Should have been a template middle."); + ts.Debug.assertEqual(token, 16 /* SyntaxKind.TemplateMiddle */, "Should have been a template middle."); } } else { - ts.Debug.assertEqual(lastTemplateStackToken, 18 /* OpenBraceToken */, "Should have been an open brace"); + ts.Debug.assertEqual(lastTemplateStackToken, 18 /* SyntaxKind.OpenBraceToken */, "Should have been an open brace"); templateStack.pop(); } } @@ -131625,15 +132297,15 @@ var ts; if (!ts.isKeyword(token)) { break; } - if (lastNonTriviaToken === 24 /* DotToken */) { - token = 79 /* Identifier */; + if (lastNonTriviaToken === 24 /* SyntaxKind.DotToken */) { + token = 79 /* SyntaxKind.Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 79 /* Identifier */; + token = 79 /* SyntaxKind.Identifier */; } } } @@ -131647,59 +132319,59 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 79 /* Identifier */, - 10 /* StringLiteral */, - 8 /* NumericLiteral */, - 9 /* BigIntLiteral */, - 13 /* RegularExpressionLiteral */, - 108 /* ThisKeyword */, - 45 /* PlusPlusToken */, - 46 /* MinusMinusToken */, - 21 /* CloseParenToken */, - 23 /* CloseBracketToken */, - 19 /* CloseBraceToken */, - 110 /* TrueKeyword */, - 95 /* FalseKeyword */, + 79 /* SyntaxKind.Identifier */, + 10 /* SyntaxKind.StringLiteral */, + 8 /* SyntaxKind.NumericLiteral */, + 9 /* SyntaxKind.BigIntLiteral */, + 13 /* SyntaxKind.RegularExpressionLiteral */, + 108 /* SyntaxKind.ThisKeyword */, + 45 /* SyntaxKind.PlusPlusToken */, + 46 /* SyntaxKind.MinusMinusToken */, + 21 /* SyntaxKind.CloseParenToken */, + 23 /* SyntaxKind.CloseBracketToken */, + 19 /* SyntaxKind.CloseBraceToken */, + 110 /* SyntaxKind.TrueKeyword */, + 95 /* SyntaxKind.FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { - case 10 /* StringLiteral */: { + case 10 /* SyntaxKind.StringLiteral */: { // Check to see if we finished up on a multiline string literal. if (!scanner.isUnterminated()) return undefined; var tokenText = scanner.getTokenText(); var lastCharIndex = tokenText.length - 1; var numBackslashes = 0; - while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* backslash */) { + while (tokenText.charCodeAt(lastCharIndex - numBackslashes) === 92 /* CharacterCodes.backslash */) { numBackslashes++; } // If we have an odd number of backslashes, then the multiline string is unclosed if ((numBackslashes & 1) === 0) return undefined; - return tokenText.charCodeAt(0) === 34 /* doubleQuote */ ? 3 /* InDoubleQuoteStringLiteral */ : 2 /* InSingleQuoteStringLiteral */; + return tokenText.charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */ ? 3 /* EndOfLineState.InDoubleQuoteStringLiteral */ : 2 /* EndOfLineState.InSingleQuoteStringLiteral */; } - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Check to see if the multiline comment was unclosed. - return scanner.isUnterminated() ? 1 /* InMultiLineCommentTrivia */ : undefined; + return scanner.isUnterminated() ? 1 /* EndOfLineState.InMultiLineCommentTrivia */ : undefined; default: if (ts.isTemplateLiteralKind(token)) { if (!scanner.isUnterminated()) { return undefined; } switch (token) { - case 17 /* TemplateTail */: - return 5 /* InTemplateMiddleOrTail */; - case 14 /* NoSubstitutionTemplateLiteral */: - return 4 /* InTemplateHeadOrNoSubstitutionTemplate */; + case 17 /* SyntaxKind.TemplateTail */: + return 5 /* EndOfLineState.InTemplateMiddleOrTail */; + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + return 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */; default: return ts.Debug.fail("Only 'NoSubstitutionTemplateLiteral's and 'TemplateTail's can be unterminated; got SyntaxKind #" + token); } } - return lastOnTemplateStack === 15 /* TemplateHead */ ? 6 /* InTemplateSubstitutionPosition */ : undefined; + return lastOnTemplateStack === 15 /* SyntaxKind.TemplateHead */ ? 6 /* EndOfLineState.InTemplateSubstitutionPosition */ : undefined; } } function pushEncodedClassification(start, end, offset, classification, result) { - if (classification === 8 /* whiteSpace */) { + if (classification === 8 /* ClassificationType.whiteSpace */) { // Don't bother with whitespace classifications. They're not needed. return; } @@ -131741,23 +132413,23 @@ var ts; } function convertClassification(type) { switch (type) { - case 1 /* comment */: return ts.TokenClass.Comment; - case 3 /* keyword */: return ts.TokenClass.Keyword; - case 4 /* numericLiteral */: return ts.TokenClass.NumberLiteral; - case 25 /* bigintLiteral */: return ts.TokenClass.BigIntLiteral; - case 5 /* operator */: return ts.TokenClass.Operator; - case 6 /* stringLiteral */: return ts.TokenClass.StringLiteral; - case 8 /* whiteSpace */: return ts.TokenClass.Whitespace; - case 10 /* punctuation */: return ts.TokenClass.Punctuation; - case 2 /* identifier */: - case 11 /* className */: - case 12 /* enumName */: - case 13 /* interfaceName */: - case 14 /* moduleName */: - case 15 /* typeParameterName */: - case 16 /* typeAliasName */: - case 9 /* text */: - case 17 /* parameterName */: + case 1 /* ClassificationType.comment */: return ts.TokenClass.Comment; + case 3 /* ClassificationType.keyword */: return ts.TokenClass.Keyword; + case 4 /* ClassificationType.numericLiteral */: return ts.TokenClass.NumberLiteral; + case 25 /* ClassificationType.bigintLiteral */: return ts.TokenClass.BigIntLiteral; + case 5 /* ClassificationType.operator */: return ts.TokenClass.Operator; + case 6 /* ClassificationType.stringLiteral */: return ts.TokenClass.StringLiteral; + case 8 /* ClassificationType.whiteSpace */: return ts.TokenClass.Whitespace; + case 10 /* ClassificationType.punctuation */: return ts.TokenClass.Punctuation; + case 2 /* ClassificationType.identifier */: + case 11 /* ClassificationType.className */: + case 12 /* ClassificationType.enumName */: + case 13 /* ClassificationType.interfaceName */: + case 14 /* ClassificationType.moduleName */: + case 15 /* ClassificationType.typeParameterName */: + case 16 /* ClassificationType.typeAliasName */: + case 9 /* ClassificationType.text */: + case 17 /* ClassificationType.parameterName */: return ts.TokenClass.Identifier; default: return undefined; // TODO: GH#18217 Debug.assertNever(type); @@ -131771,10 +132443,10 @@ var ts; return true; } switch (keyword2) { - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 134 /* ConstructorKeyword */: - case 124 /* StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -131787,19 +132459,19 @@ var ts; // If we're in a multiline comment, then prepend: /* // (and a newline). That way when we lex we'll think we're still in a multiline comment. switch (lexState) { - case 3 /* InDoubleQuoteStringLiteral */: + case 3 /* EndOfLineState.InDoubleQuoteStringLiteral */: return { prefix: "\"\\\n" }; - case 2 /* InSingleQuoteStringLiteral */: + case 2 /* EndOfLineState.InSingleQuoteStringLiteral */: return { prefix: "'\\\n" }; - case 1 /* InMultiLineCommentTrivia */: + case 1 /* EndOfLineState.InMultiLineCommentTrivia */: return { prefix: "/*\n" }; - case 4 /* InTemplateHeadOrNoSubstitutionTemplate */: + case 4 /* EndOfLineState.InTemplateHeadOrNoSubstitutionTemplate */: return { prefix: "`\n" }; - case 5 /* InTemplateMiddleOrTail */: + case 5 /* EndOfLineState.InTemplateMiddleOrTail */: return { prefix: "}\n", pushTemplate: true }; - case 6 /* InTemplateSubstitutionPosition */: + case 6 /* EndOfLineState.InTemplateSubstitutionPosition */: return { prefix: "", pushTemplate: true }; - case 0 /* None */: + case 0 /* EndOfLineState.None */: return { prefix: "" }; default: return ts.Debug.assertNever(lexState); @@ -131807,47 +132479,47 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 50 /* AmpersandToken */: - case 52 /* CaretToken */: - case 51 /* BarToken */: - case 55 /* AmpersandAmpersandToken */: - case 56 /* BarBarToken */: - case 74 /* BarEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 63 /* EqualsToken */: - case 27 /* CommaToken */: - case 60 /* QuestionQuestionToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 52 /* SyntaxKind.CaretToken */: + case 51 /* SyntaxKind.BarToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return true; default: return false; @@ -131855,12 +132527,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: return true; default: return false; @@ -131868,36 +132540,36 @@ var ts; } function classFromKind(token) { if (ts.isKeyword(token)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { - return 5 /* operator */; + return 5 /* ClassificationType.operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 78 /* LastPunctuation */) { - return 10 /* punctuation */; + else if (token >= 18 /* SyntaxKind.FirstPunctuation */ && token <= 78 /* SyntaxKind.LastPunctuation */) { + return 10 /* ClassificationType.punctuation */; } switch (token) { - case 8 /* NumericLiteral */: - return 4 /* numericLiteral */; - case 9 /* BigIntLiteral */: - return 25 /* bigintLiteral */; - case 10 /* StringLiteral */: - return 6 /* stringLiteral */; - case 13 /* RegularExpressionLiteral */: - return 7 /* regularExpressionLiteral */; - case 7 /* ConflictMarkerTrivia */: - case 3 /* MultiLineCommentTrivia */: - case 2 /* SingleLineCommentTrivia */: - return 1 /* comment */; - case 5 /* WhitespaceTrivia */: - case 4 /* NewLineTrivia */: - return 8 /* whiteSpace */; - case 79 /* Identifier */: + case 8 /* SyntaxKind.NumericLiteral */: + return 4 /* ClassificationType.numericLiteral */; + case 9 /* SyntaxKind.BigIntLiteral */: + return 25 /* ClassificationType.bigintLiteral */; + case 10 /* SyntaxKind.StringLiteral */: + return 6 /* ClassificationType.stringLiteral */; + case 13 /* SyntaxKind.RegularExpressionLiteral */: + return 7 /* ClassificationType.regularExpressionLiteral */; + case 7 /* SyntaxKind.ConflictMarkerTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + return 1 /* ClassificationType.comment */; + case 5 /* SyntaxKind.WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + return 8 /* ClassificationType.whiteSpace */; + case 79 /* SyntaxKind.Identifier */: default: if (ts.isTemplateLiteralKind(token)) { - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } /* @internal */ @@ -131917,13 +132589,13 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } @@ -131948,10 +132620,10 @@ var ts; } node.forEachChild(cb); }); - return { spans: spans, endOfLineState: 0 /* None */ }; + return { spans: spans, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, end, type) { var length = end - start; - ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); + ts.Debug.assert(length > 0, "Classification had non-positive length of ".concat(length)); spans.push(start); spans.push(length); spans.push(type); @@ -131960,29 +132632,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function classifySymbol(symbol, meaningAtPosition, checker) { var flags = symbol.getFlags(); - if ((flags & 2885600 /* Classifiable */) === 0 /* None */) { + if ((flags & 2885600 /* SymbolFlags.Classifiable */) === 0 /* SymbolFlags.None */) { return undefined; } - else if (flags & 32 /* Class */) { - return 11 /* className */; + else if (flags & 32 /* SymbolFlags.Class */) { + return 11 /* ClassificationType.className */; } - else if (flags & 384 /* Enum */) { - return 12 /* enumName */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 12 /* ClassificationType.enumName */; } - else if (flags & 524288 /* TypeAlias */) { - return 16 /* typeAliasName */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 16 /* ClassificationType.typeAliasName */; } - else if (flags & 1536 /* Module */) { + else if (flags & 1536 /* SymbolFlags.Module */) { // Only classify a module as such if // - It appears in a namespace context. // - There exists a module declaration which actually impacts the value side. - return meaningAtPosition & 4 /* Namespace */ || meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol) ? 14 /* moduleName */ : undefined; + return meaningAtPosition & 4 /* SemanticMeaning.Namespace */ || meaningAtPosition & 1 /* SemanticMeaning.Value */ && hasValueSideModule(symbol) ? 14 /* ClassificationType.moduleName */ : undefined; } - else if (flags & 2097152 /* Alias */) { + else if (flags & 2097152 /* SymbolFlags.Alias */) { return classifySymbol(checker.getAliasedSymbol(symbol), meaningAtPosition, checker); } - else if (meaningAtPosition & 2 /* Type */) { - return flags & 64 /* Interface */ ? 13 /* interfaceName */ : flags & 262144 /* TypeParameter */ ? 15 /* typeParameterName */ : undefined; + else if (meaningAtPosition & 2 /* SemanticMeaning.Type */) { + return flags & 64 /* SymbolFlags.Interface */ ? 13 /* ClassificationType.interfaceName */ : flags & 262144 /* SymbolFlags.TypeParameter */ ? 15 /* ClassificationType.typeParameterName */ : undefined; } else { return undefined; @@ -131991,35 +132663,35 @@ var ts; /** Returns true if there exists a module that introduces entities on the value side. */ function hasValueSideModule(symbol) { return ts.some(symbol.declarations, function (declaration) { - return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; + return ts.isModuleDeclaration(declaration) && ts.getModuleInstanceState(declaration) === 1 /* ModuleInstanceState.Instantiated */; }); } function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return "comment" /* comment */; - case 2 /* identifier */: return "identifier" /* identifier */; - case 3 /* keyword */: return "keyword" /* keyword */; - case 4 /* numericLiteral */: return "number" /* numericLiteral */; - case 25 /* bigintLiteral */: return "bigint" /* bigintLiteral */; - case 5 /* operator */: return "operator" /* operator */; - case 6 /* stringLiteral */: return "string" /* stringLiteral */; - case 8 /* whiteSpace */: return "whitespace" /* whiteSpace */; - case 9 /* text */: return "text" /* text */; - case 10 /* punctuation */: return "punctuation" /* punctuation */; - case 11 /* className */: return "class name" /* className */; - case 12 /* enumName */: return "enum name" /* enumName */; - case 13 /* interfaceName */: return "interface name" /* interfaceName */; - case 14 /* moduleName */: return "module name" /* moduleName */; - case 15 /* typeParameterName */: return "type parameter name" /* typeParameterName */; - case 16 /* typeAliasName */: return "type alias name" /* typeAliasName */; - case 17 /* parameterName */: return "parameter name" /* parameterName */; - case 18 /* docCommentTagName */: return "doc comment tag name" /* docCommentTagName */; - case 19 /* jsxOpenTagName */: return "jsx open tag name" /* jsxOpenTagName */; - case 20 /* jsxCloseTagName */: return "jsx close tag name" /* jsxCloseTagName */; - case 21 /* jsxSelfClosingTagName */: return "jsx self closing tag name" /* jsxSelfClosingTagName */; - case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; - case 23 /* jsxText */: return "jsx text" /* jsxText */; - case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + case 1 /* ClassificationType.comment */: return "comment" /* ClassificationTypeNames.comment */; + case 2 /* ClassificationType.identifier */: return "identifier" /* ClassificationTypeNames.identifier */; + case 3 /* ClassificationType.keyword */: return "keyword" /* ClassificationTypeNames.keyword */; + case 4 /* ClassificationType.numericLiteral */: return "number" /* ClassificationTypeNames.numericLiteral */; + case 25 /* ClassificationType.bigintLiteral */: return "bigint" /* ClassificationTypeNames.bigintLiteral */; + case 5 /* ClassificationType.operator */: return "operator" /* ClassificationTypeNames.operator */; + case 6 /* ClassificationType.stringLiteral */: return "string" /* ClassificationTypeNames.stringLiteral */; + case 8 /* ClassificationType.whiteSpace */: return "whitespace" /* ClassificationTypeNames.whiteSpace */; + case 9 /* ClassificationType.text */: return "text" /* ClassificationTypeNames.text */; + case 10 /* ClassificationType.punctuation */: return "punctuation" /* ClassificationTypeNames.punctuation */; + case 11 /* ClassificationType.className */: return "class name" /* ClassificationTypeNames.className */; + case 12 /* ClassificationType.enumName */: return "enum name" /* ClassificationTypeNames.enumName */; + case 13 /* ClassificationType.interfaceName */: return "interface name" /* ClassificationTypeNames.interfaceName */; + case 14 /* ClassificationType.moduleName */: return "module name" /* ClassificationTypeNames.moduleName */; + case 15 /* ClassificationType.typeParameterName */: return "type parameter name" /* ClassificationTypeNames.typeParameterName */; + case 16 /* ClassificationType.typeAliasName */: return "type alias name" /* ClassificationTypeNames.typeAliasName */; + case 17 /* ClassificationType.parameterName */: return "parameter name" /* ClassificationTypeNames.parameterName */; + case 18 /* ClassificationType.docCommentTagName */: return "doc comment tag name" /* ClassificationTypeNames.docCommentTagName */; + case 19 /* ClassificationType.jsxOpenTagName */: return "jsx open tag name" /* ClassificationTypeNames.jsxOpenTagName */; + case 20 /* ClassificationType.jsxCloseTagName */: return "jsx close tag name" /* ClassificationTypeNames.jsxCloseTagName */; + case 21 /* ClassificationType.jsxSelfClosingTagName */: return "jsx self closing tag name" /* ClassificationTypeNames.jsxSelfClosingTagName */; + case 22 /* ClassificationType.jsxAttribute */: return "jsx attribute" /* ClassificationTypeNames.jsxAttribute */; + case 23 /* ClassificationType.jsxText */: return "jsx text" /* ClassificationTypeNames.jsxText */; + case 24 /* ClassificationType.jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* ClassificationTypeNames.jsxAttributeStringLiteralValue */; default: return undefined; // TODO: GH#18217 throw Debug.assertNever(type); } } @@ -132045,11 +132717,11 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); - var mergeConflictScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var triviaScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); - return { spans: result, endOfLineState: 0 /* None */ }; + return { spans: result, endOfLineState: 0 /* EndOfLineState.None */ }; function pushClassification(start, length, type) { result.push(start); result.push(length); @@ -132071,12 +132743,12 @@ var ts; return start; } switch (kind) { - case 4 /* NewLineTrivia */: - case 5 /* WhitespaceTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // Don't bother with newlines/whitespace. continue; - case 2 /* SingleLineCommentTrivia */: - case 3 /* MultiLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: // Only bother with the trivia if it at least intersects the span of interest. classifyComment(token, kind, start, width); // Classifying a comment might cause us to reuse the trivia scanner @@ -132084,21 +132756,21 @@ var ts; // sure we set the scanner position back to where it needs to be. triviaScanner.setTextPos(end); continue; - case 7 /* ConflictMarkerTrivia */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: var text = sourceFile.text; var ch = text.charCodeAt(start); // for the <<<<<<< and >>>>>>> markers, we just add them in as comments // in the classification stream. - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { - pushClassification(start, width, 1 /* comment */); + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { + pushClassification(start, width, 1 /* ClassificationType.comment */); continue; } // for the ||||||| and ======== markers, add a comment for the first line, // and then lex all subsequent lines up until the end of the conflict marker. - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); classifyDisabledMergeCode(text, start, end); break; - case 6 /* ShebangTrivia */: + case 6 /* SyntaxKind.ShebangTrivia */: // TODO: Maybe we should classify these. break; default: @@ -132107,7 +132779,7 @@ var ts; } } function classifyComment(token, kind, start, width) { - if (kind === 3 /* MultiLineCommentTrivia */) { + if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { // See if this is a doc comment. If so, we'll classify certain portions of it // specially. var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); @@ -132118,7 +132790,7 @@ var ts; return; } } - else if (kind === 2 /* SingleLineCommentTrivia */) { + else if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { if (tryClassifyTripleSlashComment(start, width)) { return; } @@ -132127,7 +132799,7 @@ var ts; pushCommentRange(start, width); } function pushCommentRange(start, width) { - pushClassification(start, width, 1 /* comment */); + pushClassification(start, width, 1 /* ClassificationType.comment */); } function classifyJSDocComment(docComment) { var _a, _b, _c, _d, _e, _f, _g; @@ -132140,51 +132812,51 @@ var ts; if (tag.pos !== pos) { pushCommentRange(pos, tag.pos - pos); } - pushClassification(tag.pos, 1, 10 /* punctuation */); // "@" - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" + pushClassification(tag.pos, 1, 10 /* ClassificationType.punctuation */); // "@" + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* ClassificationType.docCommentTagName */); // e.g. "param" pos = tag.tagName.end; var commentStart = tag.tagName.end; switch (tag.kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var param = tag; processJSDocParameterTag(param); commentStart = param.isNameFirst && ((_a = param.typeExpression) === null || _a === void 0 ? void 0 : _a.end) || param.name.end; break; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var prop = tag; commentStart = prop.isNameFirst && ((_b = prop.typeExpression) === null || _b === void 0 ? void 0 : _b.end) || prop.name.end; break; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; commentStart = tag.typeParameters.end; break; - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: var type = tag; - commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; + commentStart = ((_c = type.typeExpression) === null || _c === void 0 ? void 0 : _c.kind) === 309 /* SyntaxKind.JSDocTypeExpression */ && ((_d = type.fullName) === null || _d === void 0 ? void 0 : _d.end) || ((_e = type.typeExpression) === null || _e === void 0 ? void 0 : _e.end) || commentStart; break; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: commentStart = tag.typeExpression.end; break; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = tag.typeExpression.end; break; - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: commentStart = tag.typeExpression.end; break; - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; commentStart = ((_f = tag.typeExpression) === null || _f === void 0 ? void 0 : _f.end) || commentStart; break; - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: commentStart = ((_g = tag.name) === null || _g === void 0 ? void 0 : _g.end) || commentStart; break; - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: commentStart = tag.class.end; break; } @@ -132203,7 +132875,7 @@ var ts; function processJSDocParameterTag(tag) { if (tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } if (tag.typeExpression) { @@ -132213,7 +132885,7 @@ var ts; } if (!tag.isNameFirst) { pushCommentRange(pos, tag.name.pos - pos); - pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* parameterName */); + pushClassification(tag.name.pos, tag.name.end - tag.name.pos, 17 /* ClassificationType.parameterName */); pos = tag.name.end; } } @@ -132238,9 +132910,9 @@ var ts; var pos = start; pushCommentRange(pos, match[1].length); // /// pos += match[1].length; - pushClassification(pos, match[2].length, 10 /* punctuation */); // < + pushClassification(pos, match[2].length, 10 /* ClassificationType.punctuation */); // < pos += match[2].length; - pushClassification(pos, match[3].length, 21 /* jsxSelfClosingTagName */); // element name + pushClassification(pos, match[3].length, 21 /* ClassificationType.jsxSelfClosingTagName */); // element name pos += match[3].length; var attrText = match[4]; var attrPos = pos; @@ -132254,19 +132926,19 @@ var ts; pushCommentRange(attrPos, newAttrPos - attrPos); attrPos = newAttrPos; } - pushClassification(attrPos, attrMatch[2].length, 22 /* jsxAttribute */); // attribute name + pushClassification(attrPos, attrMatch[2].length, 22 /* ClassificationType.jsxAttribute */); // attribute name attrPos += attrMatch[2].length; if (attrMatch[3].length) { pushCommentRange(attrPos, attrMatch[3].length); // whitespace attrPos += attrMatch[3].length; } - pushClassification(attrPos, attrMatch[4].length, 5 /* operator */); // = + pushClassification(attrPos, attrMatch[4].length, 5 /* ClassificationType.operator */); // = attrPos += attrMatch[4].length; if (attrMatch[5].length) { pushCommentRange(attrPos, attrMatch[5].length); // whitespace attrPos += attrMatch[5].length; } - pushClassification(attrPos, attrMatch[6].length, 24 /* jsxAttributeStringLiteralValue */); // attribute value + pushClassification(attrPos, attrMatch[6].length, 24 /* ClassificationType.jsxAttributeStringLiteralValue */); // attribute value attrPos += attrMatch[6].length; } pos += match[4].length; @@ -132274,7 +132946,7 @@ var ts; pushCommentRange(attrPos, pos - attrPos); } if (match[5]) { - pushClassification(pos, match[5].length, 10 /* punctuation */); // /> + pushClassification(pos, match[5].length, 10 /* ClassificationType.punctuation */); // /> pos += match[5].length; } var end = start + width; @@ -132298,7 +132970,7 @@ var ts; break; } } - pushClassification(start, i - start, 1 /* comment */); + pushClassification(start, i - start, 1 /* ClassificationType.comment */); mergeConflictScanner.setTextPos(i); while (mergeConflictScanner.getTextPos() < end) { classifyDisabledCodeToken(); @@ -132325,10 +132997,10 @@ var ts; return true; } var classifiedElementName = tryClassifyJsxElementName(node); - if (!ts.isToken(node) && node.kind !== 11 /* JsxText */ && classifiedElementName === undefined) { + if (!ts.isToken(node) && node.kind !== 11 /* SyntaxKind.JsxText */ && classifiedElementName === undefined) { return false; } - var tokenStart = node.kind === 11 /* JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); + var tokenStart = node.kind === 11 /* SyntaxKind.JsxText */ ? node.pos : classifyLeadingTriviaAndGetTokenStart(node); var tokenWidth = node.end - tokenStart; ts.Debug.assert(tokenWidth >= 0); if (tokenWidth > 0) { @@ -132341,24 +133013,24 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: if (token.parent.tagName === token) { - return 19 /* jsxOpenTagName */; + return 19 /* ClassificationType.jsxOpenTagName */; } break; - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: if (token.parent.tagName === token) { - return 20 /* jsxCloseTagName */; + return 20 /* ClassificationType.jsxCloseTagName */; } break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: if (token.parent.tagName === token) { - return 21 /* jsxSelfClosingTagName */; + return 21 /* ClassificationType.jsxSelfClosingTagName */; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: if (token.parent.name === token) { - return 22 /* jsxAttribute */; + return 22 /* ClassificationType.jsxAttribute */; } break; } @@ -132369,97 +133041,97 @@ var ts; // classify based on that instead. function classifyTokenType(tokenKind, token) { if (ts.isKeyword(tokenKind)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { + if (tokenKind === 29 /* SyntaxKind.LessThanToken */ || tokenKind === 31 /* SyntaxKind.GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } } if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 63 /* EqualsToken */) { + if (tokenKind === 63 /* SyntaxKind.EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 254 /* VariableDeclaration */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 164 /* Parameter */ || - parent.kind === 285 /* JsxAttribute */) { - return 5 /* operator */; + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 164 /* SyntaxKind.Parameter */ || + parent.kind === 285 /* SyntaxKind.JsxAttribute */) { + return 5 /* ClassificationType.operator */; } } - if (parent.kind === 221 /* BinaryExpression */ || - parent.kind === 219 /* PrefixUnaryExpression */ || - parent.kind === 220 /* PostfixUnaryExpression */ || - parent.kind === 222 /* ConditionalExpression */) { - return 5 /* operator */; + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ || + parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || + parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */ || + parent.kind === 222 /* SyntaxKind.ConditionalExpression */) { + return 5 /* ClassificationType.operator */; } } - return 10 /* punctuation */; + return 10 /* ClassificationType.punctuation */; } - else if (tokenKind === 8 /* NumericLiteral */) { - return 4 /* numericLiteral */; + else if (tokenKind === 8 /* SyntaxKind.NumericLiteral */) { + return 4 /* ClassificationType.numericLiteral */; } - else if (tokenKind === 9 /* BigIntLiteral */) { - return 25 /* bigintLiteral */; + else if (tokenKind === 9 /* SyntaxKind.BigIntLiteral */) { + return 25 /* ClassificationType.bigintLiteral */; } - else if (tokenKind === 10 /* StringLiteral */) { - return token && token.parent.kind === 285 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + else if (tokenKind === 10 /* SyntaxKind.StringLiteral */) { + return token && token.parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? 24 /* ClassificationType.jsxAttributeStringLiteralValue */ : 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 13 /* RegularExpressionLiteral */) { + else if (tokenKind === 13 /* SyntaxKind.RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } else if (ts.isTemplateLiteralKind(tokenKind)) { // TODO (drosen): we should *also* get another classification type for these literals. - return 6 /* stringLiteral */; + return 6 /* ClassificationType.stringLiteral */; } - else if (tokenKind === 11 /* JsxText */) { - return 23 /* jsxText */; + else if (tokenKind === 11 /* SyntaxKind.JsxText */) { + return 23 /* ClassificationType.jsxText */; } - else if (tokenKind === 79 /* Identifier */) { + else if (tokenKind === 79 /* SyntaxKind.Identifier */) { if (token) { switch (token.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: if (token.parent.name === token) { - return 11 /* className */; + return 11 /* ClassificationType.className */; } return; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: if (token.parent.name === token) { - return 15 /* typeParameterName */; + return 15 /* ClassificationType.typeParameterName */; } return; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: if (token.parent.name === token) { - return 13 /* interfaceName */; + return 13 /* ClassificationType.interfaceName */; } return; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (token.parent.name === token) { - return 12 /* enumName */; + return 12 /* ClassificationType.enumName */; } return; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (token.parent.name === token) { - return 14 /* moduleName */; + return 14 /* ClassificationType.moduleName */; } return; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (token.parent.name === token) { - return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; + return ts.isThisIdentifier(token) ? 3 /* ClassificationType.keyword */ : 17 /* ClassificationType.parameterName */; } return; } if (ts.isConstTypeReference(token.parent)) { - return 3 /* keyword */; + return 3 /* ClassificationType.keyword */; } } - return 2 /* identifier */; + return 2 /* ClassificationType.identifier */; } } function processElement(element) { @@ -132535,14 +133207,14 @@ var ts; function getEncodedSemanticClassifications(program, cancellationToken, sourceFile, span) { return { spans: getSemanticTokens(program, sourceFile, span, cancellationToken), - endOfLineState: 0 /* None */ + endOfLineState: 0 /* EndOfLineState.None */ }; } v2020.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getSemanticTokens(program, sourceFile, span, cancellationToken) { var resultTokens = []; var collector = function (node, typeIdx, modifierSet) { - resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* typeOffset */) + modifierSet); + resultTokens.push(node.getStart(sourceFile), node.getWidth(sourceFile), ((typeIdx + 1) << 8 /* TokenEncodingConsts.typeOffset */) + modifierSet); }; if (program && sourceFile) { collectTokens(program, sourceFile, span, collector, cancellationToken); @@ -132554,13 +133226,13 @@ var ts; var inJSXElement = false; function visit(node) { switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!node || !ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth()) || node.getFullWidth() === 0) { @@ -132576,7 +133248,7 @@ var ts; if (ts.isIdentifier(node) && !inJSXElement && !inImportClause(node) && !ts.isInfinityOrNaNString(node.escapedText)) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } var typeIdx = classifySymbol(symbol, ts.getMeaningFromLocation(node)); @@ -132585,38 +133257,38 @@ var ts; if (node.parent) { var parentIsDeclaration = (ts.isBindingElement(node.parent) || tokenFromDeclarationMapping.get(node.parent.kind) === typeIdx); if (parentIsDeclaration && node.parent.name === node) { - modifierSet = 1 << 0 /* declaration */; + modifierSet = 1 << 0 /* TokenModifier.declaration */; } } // property declaration in constructor - if (typeIdx === 6 /* parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { - typeIdx = 9 /* property */; + if (typeIdx === 6 /* TokenType.parameter */ && isRightSideOfQualifiedNameOrPropertyAccess(node)) { + typeIdx = 9 /* TokenType.property */; } typeIdx = reclassifyByType(typeChecker, node, typeIdx); var decl = symbol.valueDeclaration; if (decl) { var modifiers = ts.getCombinedModifierFlags(decl); var nodeFlags = ts.getCombinedNodeFlags(decl); - if (modifiers & 32 /* Static */) { - modifierSet |= 1 << 1 /* static */; + if (modifiers & 32 /* ModifierFlags.Static */) { + modifierSet |= 1 << 1 /* TokenModifier.static */; } - if (modifiers & 256 /* Async */) { - modifierSet |= 1 << 2 /* async */; + if (modifiers & 256 /* ModifierFlags.Async */) { + modifierSet |= 1 << 2 /* TokenModifier.async */; } - if (typeIdx !== 0 /* class */ && typeIdx !== 2 /* interface */) { - if ((modifiers & 64 /* Readonly */) || (nodeFlags & 2 /* Const */) || (symbol.getFlags() & 8 /* EnumMember */)) { - modifierSet |= 1 << 3 /* readonly */; + if (typeIdx !== 0 /* TokenType.class */ && typeIdx !== 2 /* TokenType.interface */) { + if ((modifiers & 64 /* ModifierFlags.Readonly */) || (nodeFlags & 2 /* NodeFlags.Const */) || (symbol.getFlags() & 8 /* SymbolFlags.EnumMember */)) { + modifierSet |= 1 << 3 /* TokenModifier.readonly */; } } - if ((typeIdx === 7 /* variable */ || typeIdx === 10 /* function */) && isLocalDeclaration(decl, sourceFile)) { - modifierSet |= 1 << 5 /* local */; + if ((typeIdx === 7 /* TokenType.variable */ || typeIdx === 10 /* TokenType.function */) && isLocalDeclaration(decl, sourceFile)) { + modifierSet |= 1 << 5 /* TokenModifier.local */; } if (program.isSourceFileDefaultLibrary(decl.getSourceFile())) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } } else if (symbol.declarations && symbol.declarations.some(function (d) { return program.isSourceFileDefaultLibrary(d.getSourceFile()); })) { - modifierSet |= 1 << 4 /* defaultLibrary */; + modifierSet |= 1 << 4 /* TokenModifier.defaultLibrary */; } collector(node, typeIdx, modifierSet); } @@ -132629,22 +133301,22 @@ var ts; } function classifySymbol(symbol, meaning) { var flags = symbol.getFlags(); - if (flags & 32 /* Class */) { - return 0 /* class */; + if (flags & 32 /* SymbolFlags.Class */) { + return 0 /* TokenType.class */; } - else if (flags & 384 /* Enum */) { - return 1 /* enum */; + else if (flags & 384 /* SymbolFlags.Enum */) { + return 1 /* TokenType.enum */; } - else if (flags & 524288 /* TypeAlias */) { - return 5 /* type */; + else if (flags & 524288 /* SymbolFlags.TypeAlias */) { + return 5 /* TokenType.type */; } - else if (flags & 64 /* Interface */) { - if (meaning & 2 /* Type */) { - return 2 /* interface */; + else if (flags & 64 /* SymbolFlags.Interface */) { + if (meaning & 2 /* SemanticMeaning.Type */) { + return 2 /* TokenType.interface */; } } - else if (flags & 262144 /* TypeParameter */) { - return 4 /* typeParameter */; + else if (flags & 262144 /* SymbolFlags.TypeParameter */) { + return 4 /* TokenType.typeParameter */; } var decl = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0]; if (decl && ts.isBindingElement(decl)) { @@ -132654,17 +133326,17 @@ var ts; } function reclassifyByType(typeChecker, node, typeIdx) { // type based classifications - if (typeIdx === 7 /* variable */ || typeIdx === 9 /* property */ || typeIdx === 6 /* parameter */) { + if (typeIdx === 7 /* TokenType.variable */ || typeIdx === 9 /* TokenType.property */ || typeIdx === 6 /* TokenType.parameter */) { var type_1 = typeChecker.getTypeAtLocation(node); if (type_1) { var test = function (condition) { return condition(type_1) || type_1.isUnion() && type_1.types.some(condition); }; - if (typeIdx !== 6 /* parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { - return 0 /* class */; + if (typeIdx !== 6 /* TokenType.parameter */ && test(function (t) { return t.getConstructSignatures().length > 0; })) { + return 0 /* TokenType.class */; } if (test(function (t) { return t.getCallSignatures().length > 0; }) && !test(function (t) { return t.getProperties().length > 0; }) || isExpressionInCallExpression(node)) { - return typeIdx === 9 /* property */ ? 11 /* member */ : 10 /* function */; + return typeIdx === 9 /* TokenType.property */ ? 11 /* TokenType.member */ : 10 /* TokenType.function */; } } } @@ -132706,25 +133378,25 @@ var ts; return (ts.isQualifiedName(node.parent) && node.parent.right === node) || (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node); } var tokenFromDeclarationMapping = new ts.Map([ - [254 /* VariableDeclaration */, 7 /* variable */], - [164 /* Parameter */, 6 /* parameter */], - [167 /* PropertyDeclaration */, 9 /* property */], - [261 /* ModuleDeclaration */, 3 /* namespace */], - [260 /* EnumDeclaration */, 1 /* enum */], - [299 /* EnumMember */, 8 /* enumMember */], - [257 /* ClassDeclaration */, 0 /* class */], - [169 /* MethodDeclaration */, 11 /* member */], - [256 /* FunctionDeclaration */, 10 /* function */], - [213 /* FunctionExpression */, 10 /* function */], - [168 /* MethodSignature */, 11 /* member */], - [172 /* GetAccessor */, 9 /* property */], - [173 /* SetAccessor */, 9 /* property */], - [166 /* PropertySignature */, 9 /* property */], - [258 /* InterfaceDeclaration */, 2 /* interface */], - [259 /* TypeAliasDeclaration */, 5 /* type */], - [163 /* TypeParameter */, 4 /* typeParameter */], - [296 /* PropertyAssignment */, 9 /* property */], - [297 /* ShorthandPropertyAssignment */, 9 /* property */] + [254 /* SyntaxKind.VariableDeclaration */, 7 /* TokenType.variable */], + [164 /* SyntaxKind.Parameter */, 6 /* TokenType.parameter */], + [167 /* SyntaxKind.PropertyDeclaration */, 9 /* TokenType.property */], + [261 /* SyntaxKind.ModuleDeclaration */, 3 /* TokenType.namespace */], + [260 /* SyntaxKind.EnumDeclaration */, 1 /* TokenType.enum */], + [299 /* SyntaxKind.EnumMember */, 8 /* TokenType.enumMember */], + [257 /* SyntaxKind.ClassDeclaration */, 0 /* TokenType.class */], + [169 /* SyntaxKind.MethodDeclaration */, 11 /* TokenType.member */], + [256 /* SyntaxKind.FunctionDeclaration */, 10 /* TokenType.function */], + [213 /* SyntaxKind.FunctionExpression */, 10 /* TokenType.function */], + [168 /* SyntaxKind.MethodSignature */, 11 /* TokenType.member */], + [172 /* SyntaxKind.GetAccessor */, 9 /* TokenType.property */], + [173 /* SyntaxKind.SetAccessor */, 9 /* TokenType.property */], + [166 /* SyntaxKind.PropertySignature */, 9 /* TokenType.property */], + [258 /* SyntaxKind.InterfaceDeclaration */, 2 /* TokenType.interface */], + [259 /* SyntaxKind.TypeAliasDeclaration */, 5 /* TokenType.type */], + [163 /* SyntaxKind.TypeParameter */, 4 /* TokenType.typeParameter */], + [296 /* SyntaxKind.PropertyAssignment */, 9 /* TokenType.property */], + [297 /* SyntaxKind.ShorthandPropertyAssignment */, 9 /* TokenType.property */] ]); })(v2020 = classifier.v2020 || (classifier.v2020 = {})); })(classifier = ts.classifier || (ts.classifier = {})); @@ -132736,6 +133408,26 @@ var ts; (function (Completions) { var StringCompletions; (function (StringCompletions) { + var _a; + var kindPrecedence = (_a = {}, + _a["directory" /* ScriptElementKind.directory */] = 0, + _a["script" /* ScriptElementKind.scriptElement */] = 1, + _a["external module name" /* ScriptElementKind.externalModuleName */] = 2, + _a); + function createNameAndKindSet() { + var map = new ts.Map(); + function add(value) { + var existing = map.get(value.name); + if (!existing || kindPrecedence[existing.kind] < kindPrecedence[value.kind]) { + map.set(value.name, value); + } + } + return { + add: add, + has: map.has.bind(map), + values: map.values.bind(map), + }; + } function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) { if (ts.isInReferenceComment(sourceFile, position)) { var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host); @@ -132755,19 +133447,19 @@ var ts; } var optionalReplacementSpan = ts.createTextSpanFromStringLiteralLikeContent(contextToken); switch (completion.kind) { - case 0 /* Paths */: + case 0 /* StringLiteralCompletionKind.Paths */: return convertPathCompletions(completion.paths); - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var entries = ts.createSortedArray(); - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options, + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ScriptTarget.ESNext */, log, 4 /* CompletionKind.String */, preferences, options, /*formatContext*/ undefined); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries }; } - case 2 /* Types */: { + case 2 /* StringLiteralCompletionKind.Types */: { var entries = completion.types.map(function (type) { return ({ name: type.value, - kindModifiers: "" /* none */, - kind: "string" /* string */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "string" /* ScriptElementKind.string */, sortText: Completions.SortText.LocationPriority, replacementSpan: ts.getReplacementSpanForContextToken(contextToken) }); }); @@ -132786,16 +133478,16 @@ var ts; StringCompletions.getStringLiteralCompletionDetails = getStringLiteralCompletionDetails; function stringLiteralCompletionDetails(name, location, completion, sourceFile, checker, cancellationToken) { switch (completion.kind) { - case 0 /* Paths */: { + case 0 /* StringLiteralCompletionKind.Paths */: { var match = ts.find(completion.paths, function (p) { return p.name === name; }); return match && Completions.createCompletionDetails(name, kindModifiersFromExtension(match.extension), match.kind, [ts.textPart(name)]); } - case 1 /* Properties */: { + case 1 /* StringLiteralCompletionKind.Properties */: { var match = ts.find(completion.symbols, function (s) { return s.name === name; }); return match && Completions.createCompletionDetailsForSymbol(match, checker, sourceFile, location, cancellationToken); } - case 2 /* Types */: - return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* none */, "type" /* typeElement */, [ts.textPart(name)]) : undefined; + case 2 /* StringLiteralCompletionKind.Types */: + return ts.find(completion.types, function (t) { return t.value === name; }) ? Completions.createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, "type" /* ScriptElementKind.typeElement */, [ts.textPart(name)]) : undefined; default: return ts.Debug.assertNever(completion); } @@ -132811,20 +133503,20 @@ var ts; } function kindModifiersFromExtension(extension) { switch (extension) { - case ".d.ts" /* Dts */: return ".d.ts" /* dtsModifier */; - case ".js" /* Js */: return ".js" /* jsModifier */; - case ".json" /* Json */: return ".json" /* jsonModifier */; - case ".jsx" /* Jsx */: return ".jsx" /* jsxModifier */; - case ".ts" /* Ts */: return ".ts" /* tsModifier */; - case ".tsx" /* Tsx */: return ".tsx" /* tsxModifier */; - case ".d.mts" /* Dmts */: return ".d.mts" /* dmtsModifier */; - case ".mjs" /* Mjs */: return ".mjs" /* mjsModifier */; - case ".mts" /* Mts */: return ".mts" /* mtsModifier */; - case ".d.cts" /* Dcts */: return ".d.cts" /* dctsModifier */; - case ".cjs" /* Cjs */: return ".cjs" /* cjsModifier */; - case ".cts" /* Cts */: return ".cts" /* ctsModifier */; - case ".tsbuildinfo" /* TsBuildInfo */: return ts.Debug.fail("Extension " + ".tsbuildinfo" /* TsBuildInfo */ + " is unsupported."); - case undefined: return "" /* none */; + case ".d.ts" /* Extension.Dts */: return ".d.ts" /* ScriptElementKindModifier.dtsModifier */; + case ".js" /* Extension.Js */: return ".js" /* ScriptElementKindModifier.jsModifier */; + case ".json" /* Extension.Json */: return ".json" /* ScriptElementKindModifier.jsonModifier */; + case ".jsx" /* Extension.Jsx */: return ".jsx" /* ScriptElementKindModifier.jsxModifier */; + case ".ts" /* Extension.Ts */: return ".ts" /* ScriptElementKindModifier.tsModifier */; + case ".tsx" /* Extension.Tsx */: return ".tsx" /* ScriptElementKindModifier.tsxModifier */; + case ".d.mts" /* Extension.Dmts */: return ".d.mts" /* ScriptElementKindModifier.dmtsModifier */; + case ".mjs" /* Extension.Mjs */: return ".mjs" /* ScriptElementKindModifier.mjsModifier */; + case ".mts" /* Extension.Mts */: return ".mts" /* ScriptElementKindModifier.mtsModifier */; + case ".d.cts" /* Extension.Dcts */: return ".d.cts" /* ScriptElementKindModifier.dctsModifier */; + case ".cjs" /* Extension.Cjs */: return ".cjs" /* ScriptElementKindModifier.cjsModifier */; + case ".cts" /* Extension.Cts */: return ".cts" /* ScriptElementKindModifier.ctsModifier */; + case ".tsbuildinfo" /* Extension.TsBuildInfo */: return ts.Debug.fail("Extension ".concat(".tsbuildinfo" /* Extension.TsBuildInfo */, " is unsupported.")); + case undefined: return "" /* ScriptElementKindModifier.none */; default: return ts.Debug.assertNever(extension); } @@ -132838,44 +133530,44 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host, preferences) { var parent = walkUpParentheses(node.parent); switch (parent.kind) { - case 196 /* LiteralType */: { - var grandParent = walkUpParentheses(parent.parent); - switch (grandParent.kind) { - case 178 /* TypeReference */: { - var typeReference_1 = grandParent; - var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === typeReference_1; }); + case 196 /* SyntaxKind.LiteralType */: { + var grandParent_1 = walkUpParentheses(parent.parent); + switch (grandParent_1.kind) { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: { + var typeArgument = ts.findAncestor(parent, function (n) { return n.parent === grandParent_1; }); if (typeArgument) { - return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(typeArgument)), isNewIdentifier: false }; } return undefined; } - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; // bar: string; // } // let x: Foo["/*completion position*/"] - var _a = grandParent, indexType = _a.indexType, objectType = _a.objectType; + var _a = grandParent_1, indexType = _a.indexType, objectType = _a.objectType; if (!ts.rangeContainsPosition(indexType, position)) { return undefined; } return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(objectType)); - case 200 /* ImportType */: - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; - case 187 /* UnionType */: { - if (!ts.isTypeReferenceNode(grandParent.parent)) { + case 200 /* SyntaxKind.ImportType */: + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + case 187 /* SyntaxKind.UnionType */: { + if (!ts.isTypeReferenceNode(grandParent_1.parent)) { return undefined; } - var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent, parent); - var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: false }; + var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(grandParent_1, parent); + var types = getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(grandParent_1)).filter(function (t) { return !ts.contains(alreadyUsedTypes_1, t.value); }); + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: false }; } default: return undefined; } } - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -132892,7 +133584,7 @@ var ts; return stringLiteralCompletionsForObjectLiteral(typeChecker, parent.parent); } return fromContextualType(); - case 207 /* ElementAccessExpression */: { + case 207 /* SyntaxKind.ElementAccessExpression */: { var _b = parent, expression = _b.expression, argumentExpression = _b.argumentExpression; if (node === ts.skipParentheses(argumentExpression)) { // Get all names of properties on the expression @@ -132905,41 +133597,41 @@ var ts; } return undefined; } - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 285 /* JsxAttribute */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 285 /* SyntaxKind.JsxAttribute */: if (!isRequireCallArgument(node) && !ts.isImportCall(parent)) { - var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* JsxAttribute */ ? parent.parent : node, position, sourceFile); + var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(parent.kind === 285 /* SyntaxKind.JsxAttribute */ ? parent.parent : node, position, sourceFile); // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo.invocation, node, argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `require(""` or `import("")`) - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 277 /* ExternalModuleReference */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 277 /* SyntaxKind.ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); // export * from "/*completion position*/"; - return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; + return { kind: 0 /* StringLiteralCompletionKind.Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker, preferences) }; default: return fromContextualType(); } function fromContextualType() { // Get completion for string literal from string literal type // i.e. var x: "hi" | "hello" = "/*completion position*/" - return { kind: 2 /* Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: getStringLiteralTypes(ts.getContextualTypeFromParent(node, typeChecker)), isNewIdentifier: false }; } } function walkUpParentheses(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return ts.walkUpParenthesizedTypes(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return ts.walkUpParenthesizedExpressions(node); default: return node; @@ -132966,14 +133658,14 @@ var ts; type = propType; } } - isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); + isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* TypeFlags.String */); return getStringLiteralTypes(type, uniques); }); - return { kind: 2 /* Types */, types: types, isNewIdentifier: isNewIdentifier }; + return { kind: 2 /* StringLiteralCompletionKind.Types */, types: types, isNewIdentifier: isNewIdentifier }; } function stringLiteralCompletionsFromProperties(type) { return type && { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: ts.filter(type.getApparentProperties(), function (prop) { return !(prop.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(prop.valueDeclaration)); }), hasIndexSignature: ts.hasIndexSignature(type) }; @@ -132982,10 +133674,10 @@ var ts; var contextualType = checker.getContextualType(objectLiteralExpression); if (!contextualType) return undefined; - var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* Completions */); + var completionsType = checker.getContextualType(objectLiteralExpression, 4 /* ContextFlags.Completions */); var symbols = Completions.getPropertiesForObjectExpression(contextualType, completionsType, objectLiteralExpression, checker); return { - kind: 1 /* Properties */, + kind: 1 /* StringLiteralCompletionKind.Properties */, symbols: symbols, hasIndexSignature: ts.hasIndexSignature(contextualType) }; @@ -132996,13 +133688,13 @@ var ts; return ts.emptyArray; type = ts.skipConstraint(type); return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : - type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; + type.isStringLiteral() && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; } function directoryResult(name) { - return nameAndKind(name, "directory" /* directory */, /*extension*/ undefined); + return nameAndKind(name, "directory" /* ScriptElementKind.directory */, /*extension*/ undefined); } function addReplacementSpans(text, textStart, names) { var span = getDirectoryFragmentTextSpan(text, textStart); @@ -133017,18 +133709,19 @@ var ts; } function getStringLiteralCompletionsFromModuleNamesWorker(sourceFile, node, compilerOptions, host, typeChecker, preferences) { var literalValue = ts.normalizeSlashes(node.text); + var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; var scriptPath = sourceFile.path; var scriptDirectory = ts.getDirectoryPath(scriptPath); return isPathRelativeToScript(literalValue) || !compilerOptions.baseUrl && (ts.isRootedDiskPath(literalValue) || ts.isUrl(literalValue)) ? getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, getIncludeExtensionOption()) - : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, compilerOptions, host, typeChecker); + : getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, mode, compilerOptions, host, getIncludeExtensionOption(), typeChecker); function getIncludeExtensionOption() { var mode = ts.isStringLiteralLike(node) ? ts.getModeForUsageLocation(sourceFile, node) : undefined; - return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* ModuleSpecifierCompletion */ : 0 /* Exclude */; + return preferences.importModuleSpecifierEnding === "js" || mode === ts.ModuleKind.ESNext ? 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */ : 0 /* IncludeExtensionsOption.Exclude */; } } function getExtensionOptions(compilerOptions, includeExtensionsOption) { - if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* Exclude */; } + if (includeExtensionsOption === void 0) { includeExtensionsOption = 0 /* IncludeExtensionsOption.Exclude */; } return { extensions: ts.flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption: includeExtensionsOption }; } function getCompletionEntriesForRelativeModules(literalValue, scriptDirectory, compilerOptions, host, scriptPath, includeExtensions) { @@ -133037,7 +133730,7 @@ var ts; return getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensionOptions, compilerOptions, host, scriptPath); } else { - return getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath); + return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensionOptions, host, scriptPath).values()); } } function isEmitResolutionKindUsingNodeModules(compilerOptions) { @@ -133073,7 +133766,7 @@ var ts; var basePath = compilerOptions.project || host.getCurrentDirectory(); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptDirectory, ignoreCase); - return ts.flatMap(baseDirectories, function (baseDirectory) { return getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude); }); + return ts.flatMap(baseDirectories, function (baseDirectory) { return ts.arrayFrom(getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensionOptions, host, exclude).values()); }); } var IncludeExtensionsOption; (function (IncludeExtensionsOption) { @@ -133084,10 +133777,9 @@ var ts; /** * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, _a, host, exclude, result) { - var _b; - var extensions = _a.extensions, includeExtensionsOption = _a.includeExtensionsOption; - if (result === void 0) { result = []; } + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensionOptions, host, exclude, result) { + var _a; + if (result === void 0) { result = createNameAndKindSet(); } if (fragment === undefined) { fragment = ""; } @@ -133111,11 +133803,11 @@ var ts; var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; if (typeof typesVersions === "object") { - var versionPaths = (_b = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _b === void 0 ? void 0 : _b.paths; + var versionPaths = (_a = ts.getPackageJsonTypesVersionsPaths(typesVersions)) === null || _a === void 0 ? void 0 : _a.paths; if (versionPaths) { var packageDirectory = ts.getDirectoryPath(packageJsonPath); var pathInPackage = absolutePath.slice(ts.ensureTrailingDirectorySeparator(packageDirectory).length); - if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensions, versionPaths, host)) { + if (addCompletionEntriesFromPaths(result, pathInPackage, packageDirectory, extensionOptions, host, versionPaths)) { // A true result means one of the `versionPaths` was matched, which will block relative resolution // to files and folders from here. All reachable paths given the pattern match are already added. return result; @@ -133127,39 +133819,17 @@ var ts; if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensionsOption === includeExtensionsOption.Exclude) so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = new ts.Map(); // maps file to its extension for (var _i = 0, files_1 = files; _i < files_1.length; _i++) { var filePath = files_1[_i]; filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* Comparison.EqualTo */) { continue; } - var foundFileName = void 0; - var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(filePath, host.getCompilationSettings()); - if (includeExtensionsOption === 0 /* Exclude */ && !ts.fileExtensionIsOneOf(filePath, [".json" /* Json */, ".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) { - foundFileName = ts.removeFileExtension(ts.getBaseFileName(filePath)); - foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); - } - else if ((ts.fileExtensionIsOneOf(filePath, [".mts" /* Mts */, ".cts" /* Cts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]) || includeExtensionsOption === 2 /* ModuleSpecifierCompletion */) && outputExtension) { - foundFileName = ts.changeExtension(ts.getBaseFileName(filePath), outputExtension); - foundFiles.set(foundFileName, outputExtension); - } - else { - foundFileName = ts.getBaseFileName(filePath); - foundFiles.set(foundFileName, ts.tryGetExtensionFromPath(filePath)); - } + var _b = getFilenameWithExtensionOption(ts.getBaseFileName(filePath), host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _b.name, extension = _b.extension; + result.add(nameAndKind(name, "script" /* ScriptElementKind.scriptElement */, extension)); } - foundFiles.forEach(function (ext, foundFile) { - result.push(nameAndKind(foundFile, "script" /* scriptElement */, ext)); - }); } // If possible, get folder completion as well var directories = ts.tryGetDirectories(host, baseDirectory); @@ -133168,27 +133838,52 @@ var ts; var directory = directories_1[_c]; var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); if (directoryName !== "@types") { - result.push(directoryResult(directoryName)); + result.add(directoryResult(directoryName)); } } } return result; } + function getFilenameWithExtensionOption(name, compilerOptions, includeExtensionsOption) { + var outputExtension = ts.moduleSpecifiers.tryGetJSExtensionForFile(name, compilerOptions); + if (includeExtensionsOption === 0 /* IncludeExtensionsOption.Exclude */ && !ts.fileExtensionIsOneOf(name, [".json" /* Extension.Json */, ".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) { + return { name: ts.removeFileExtension(name), extension: ts.tryGetExtensionFromPath(name) }; + } + else if ((ts.fileExtensionIsOneOf(name, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */]) || includeExtensionsOption === 2 /* IncludeExtensionsOption.ModuleSpecifierCompletion */) && outputExtension) { + return { name: ts.changeExtension(name, outputExtension), extension: outputExtension }; + } + else { + return { name: name, extension: ts.tryGetExtensionFromPath(name) }; + } + } /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */ - function addCompletionEntriesFromPaths(result, fragment, baseDirectory, fileExtensions, paths, host) { - var _a; + function addCompletionEntriesFromPaths(result, fragment, baseDirectory, extensionOptions, host, paths) { + var getPatternsForKey = function (key) { return paths[key]; }; + var comparePaths = function (a, b) { + var patternA = ts.tryParsePattern(a); + var patternB = ts.tryParsePattern(b); + var lengthA = typeof patternA === "object" ? patternA.prefix.length : a.length; + var lengthB = typeof patternB === "object" ? patternB.prefix.length : b.length; + return ts.compareValues(lengthB, lengthA); + }; + return addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, ts.getOwnKeys(paths), getPatternsForKey, comparePaths); + } + /** @returns whether `fragment` was a match for any `paths` (which should indicate whether any other path completions should be offered) */ + function addCompletionEntriesFromPathsOrExports(result, fragment, baseDirectory, extensionOptions, host, keys, getPatternsForKey, comparePaths) { var pathResults = []; - var matchedPathPrefixLength = -1; - for (var path in paths) { - if (!ts.hasProperty(paths, path)) + var matchedPath; + for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { + var key = keys_1[_i]; + if (key === ".") continue; - var patterns = paths[path]; + var keyWithoutLeadingDotSlash = key.replace(/^\.\//, ""); // remove leading "./" + var patterns = getPatternsForKey(key); if (patterns) { - var pathPattern = ts.tryParsePattern(path); + var pathPattern = ts.tryParsePattern(keyWithoutLeadingDotSlash); if (!pathPattern) continue; var isMatch = typeof pathPattern === "object" && ts.isPatternMatch(pathPattern, fragment); - var isLongestMatch = isMatch && (matchedPathPrefixLength === undefined || pathPattern.prefix.length > matchedPathPrefixLength); + var isLongestMatch = isMatch && (matchedPath === undefined || comparePaths(key, matchedPath) === -1 /* Comparison.LessThan */); if (isLongestMatch) { // If this is a higher priority match than anything we've seen so far, previous results from matches are invalid, e.g. // for `import {} from "some-package/|"` with a typesVersions: @@ -133201,13 +133896,13 @@ var ts; // added by the '*' match, after typing `"some-package/foo/|"` we would get file results from both // ./dist/foo and ./foo, when only the latter will actually be resolvable. // See pathCompletionsTypesVersionsWildcard6.ts. - matchedPathPrefixLength = pathPattern.prefix.length; + matchedPath = key; pathResults = pathResults.filter(function (r) { return !r.matchedPattern; }); } - if (typeof pathPattern === "string" || matchedPathPrefixLength === undefined || pathPattern.prefix.length >= matchedPathPrefixLength) { + if (typeof pathPattern === "string" || matchedPath === undefined || comparePaths(key, matchedPath) !== 1 /* Comparison.GreaterThan */) { pathResults.push({ matchedPattern: isMatch, - results: getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host) + results: getCompletionsForPathMapping(keyWithoutLeadingDotSlash, patterns, fragment, baseDirectory, extensionOptions, host) .map(function (_a) { var name = _a.name, kind = _a.kind, extension = _a.extension; return nameAndKind(name, kind, extension); @@ -133216,10 +133911,8 @@ var ts; } } } - var equatePaths = ((_a = host.useCaseSensitiveFileNames) === null || _a === void 0 ? void 0 : _a.call(host)) ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive; - var equateResults = function (a, b) { return equatePaths(a.name, b.name); }; - pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (pathResult) { return ts.pushIfUnique(result, pathResult, equateResults); }); }); - return matchedPathPrefixLength > -1; + pathResults.forEach(function (pathResult) { return pathResult.results.forEach(function (r) { return result.add(r); }); }); + return matchedPath !== undefined; } /** * Check all of the declared modules and those in node modules. Possible sources of modules: @@ -133228,22 +133921,22 @@ var ts; * Modules from node_modules (i.e. those listed in package.json) * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions */ - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, compilerOptions, host, typeChecker) { + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, mode, compilerOptions, host, includeExtensionsOption, typeChecker) { var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result = []; - var extensionOptions = getExtensionOptions(compilerOptions); + var result = createNameAndKindSet(); + var extensionOptions = getExtensionOptions(compilerOptions, includeExtensionsOption); if (baseUrl) { var projectDir = compilerOptions.project || host.getCurrentDirectory(); var absolute = ts.normalizePath(ts.combinePaths(projectDir, baseUrl)); getCompletionEntriesForDirectoryFragment(fragment, absolute, extensionOptions, host, /*exclude*/ undefined, result); if (paths) { - addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions.extensions, paths, host); + addCompletionEntriesFromPaths(result, fragment, absolute, extensionOptions, host, paths); } } var fragmentDirectory = getFragmentDirectory(fragment); for (var _i = 0, _a = getAmbientModuleCompletions(fragment, fragmentDirectory, typeChecker); _i < _a.length; _i++) { var ambientName = _a[_i]; - result.push(nameAndKind(ambientName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.add(nameAndKind(ambientName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); } getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, fragmentDirectory, extensionOptions, result); if (isEmitResolutionKindUsingNodeModules(compilerOptions)) { @@ -133251,15 +133944,13 @@ var ts; // (But do if we didn't find anything, e.g. 'package.json' missing.) var foundGlobal = false; if (fragmentDirectory === undefined) { - var _loop_3 = function (moduleName) { - if (!result.some(function (entry) { return entry.name === moduleName; })) { - foundGlobal = true; - result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined)); - } - }; for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) { var moduleName = _c[_b]; - _loop_3(moduleName); + var moduleResult = nameAndKind(moduleName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined); + if (!result.has(moduleResult.name)) { + foundGlobal = true; + result.add(moduleResult); + } } } if (!foundGlobal) { @@ -133285,39 +133976,19 @@ var ts; } packagePath = ts.combinePaths(packagePath, subName); } - var packageFile = ts.combinePaths(ancestor, "node_modules", packagePath, "package.json"); + var packageDirectory = ts.combinePaths(ancestor, "node_modules", packagePath); + var packageFile = ts.combinePaths(packageDirectory, "package.json"); if (ts.tryFileExists(host, packageFile)) { var packageJson = ts.readJson(packageFile, host); - var exports = packageJson.exports; - if (exports) { - if (typeof exports !== "object" || exports === null) { // eslint-disable-line no-null/no-null + var exports_1 = packageJson.exports; + if (exports_1) { + if (typeof exports_1 !== "object" || exports_1 === null) { // eslint-disable-line no-null/no-null return; // null exports or entrypoint only, no sub-modules available } - var keys = ts.getOwnKeys(exports); - var fragmentSubpath_1 = components.join("/"); - var processedKeys = ts.mapDefined(keys, function (k) { - if (k === ".") - return undefined; - if (!ts.startsWith(k, "./")) - return undefined; - var subpath = k.substring(2); - if (!ts.startsWith(subpath, fragmentSubpath_1)) - return undefined; - // subpath is a valid export (barring conditions, which we don't currently check here) - if (!ts.stringContains(subpath, "*")) { - return subpath; - } - // pattern export - only return everything up to the `*`, so the user can autocomplete, then - // keep filling in the pattern (we could speculatively return a list of options by hitting disk, - // but conditions will make that somewhat awkward, as each condition may have a different set of possible - // options for the `*`. - return subpath.slice(0, subpath.indexOf("*")); - }); - ts.forEach(processedKeys, function (k) { - if (k) { - result.push(nameAndKind(k, "external module name" /* externalModuleName */, /*extension*/ undefined)); - } - }); + var keys = ts.getOwnKeys(exports_1); + var fragmentSubpath = components.join("/") + (components.length && ts.hasTrailingDirectorySeparator(fragment) ? "/" : ""); + var conditions_1 = mode === ts.ModuleKind.ESNext ? ["node", "import", "types"] : ["node", "require", "types"]; + addCompletionEntriesFromPathsOrExports(result, fragmentSubpath, packageDirectory, extensionOptions, host, keys, function (key) { return ts.singleElementArray(getPatternFromFirstMatchingCondition(exports_1[key], conditions_1)); }, ts.comparePatternKeys); return; } } @@ -133327,31 +133998,44 @@ var ts; ts.forEachAncestorDirectory(scriptPath, ancestorLookup); } } - return result; + return ts.arrayFrom(result.values()); + } + function getPatternFromFirstMatchingCondition(target, conditions) { + if (typeof target === "string") { + return target; + } + if (target && typeof target === "object" && !ts.isArray(target)) { + for (var condition in target) { + if (condition === "default" || conditions.indexOf(condition) > -1 || ts.isApplicableVersionedTypesKey(conditions, condition)) { + var pattern = target[condition]; + return getPatternFromFirstMatchingCondition(pattern, conditions); + } + } + } } function getFragmentDirectory(fragment) { return containsSlash(fragment) ? ts.hasTrailingDirectorySeparator(fragment) ? fragment : ts.getDirectoryPath(fragment) : undefined; } - function getCompletionsForPathMapping(path, patterns, fragment, baseUrl, fileExtensions, host) { + function getCompletionsForPathMapping(path, patterns, fragment, packageDirectory, extensionOptions, host) { if (!ts.endsWith(path, "*")) { // For a path mapping "foo": ["/x/y/z.ts"], add "foo" itself as a completion. - return !ts.stringContains(path, "*") ? justPathMappingName(path) : ts.emptyArray; + return !ts.stringContains(path, "*") ? justPathMappingName(path, "script" /* ScriptElementKind.scriptElement */) : ts.emptyArray; } var pathPrefix = path.slice(0, path.length - 1); var remainingFragment = ts.tryRemovePrefix(fragment, pathPrefix); if (remainingFragment === undefined) { var starIsFullPathComponent = path[path.length - 2] === "/"; - return starIsFullPathComponent ? justPathMappingName(pathPrefix) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", baseUrl, pattern, fileExtensions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) { + return starIsFullPathComponent ? justPathMappingName(pathPrefix, "directory" /* ScriptElementKind.directory */) : ts.flatMap(patterns, function (pattern) { var _a; return (_a = getModulesForPathsPattern("", packageDirectory, pattern, extensionOptions, host)) === null || _a === void 0 ? void 0 : _a.map(function (_a) { var name = _a.name, rest = __rest(_a, ["name"]); return (__assign({ name: pathPrefix + name }, rest)); }); }); } - return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, baseUrl, pattern, fileExtensions, host); }); - function justPathMappingName(name) { - return ts.startsWith(name, fragment) ? [directoryResult(ts.removeTrailingDirectorySeparator(name))] : ts.emptyArray; + return ts.flatMap(patterns, function (pattern) { return getModulesForPathsPattern(remainingFragment, packageDirectory, pattern, extensionOptions, host); }); + function justPathMappingName(name, kind) { + return ts.startsWith(name, fragment) ? [{ name: ts.removeTrailingDirectorySeparator(name), kind: kind, extension: undefined }] : ts.emptyArray; } } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + function getModulesForPathsPattern(fragment, packageDirectory, pattern, extensionOptions, host) { if (!host.readDirectory) { return undefined; } @@ -133370,21 +134054,33 @@ var ts; var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + fragmentDirectory) : normalizedPrefixDirectory; var normalizedSuffix = ts.normalizePath(parsed.suffix); // Need to normalize after combining: If we combinePaths("a", "../b"), we want "b" and not "a/../b". - var baseDirectory = ts.normalizePath(ts.combinePaths(baseUrl, expandedPrefixDirectory)); + var baseDirectory = ts.normalizePath(ts.combinePaths(packageDirectory, expandedPrefixDirectory)); var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { - var extension = ts.tryGetExtensionFromPath(match); - var name = trimPrefixAndSuffix(match); - return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); - }); - var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { - var name = trimPrefixAndSuffix(dir); - return name === undefined ? undefined : directoryResult(name); + // If we have a suffix, then we read the directory all the way down to avoid returning completions for + // directories that don't contain files that would match the suffix. A previous comment here was concerned + // about the case where `normalizedSuffix` includes a `?` character, which should be interpreted literally, + // but will match any single character as part of the `include` pattern in `tryReadDirectory`. This is not + // a problem, because (in the extremely unusual circumstance where the suffix has a `?` in it) a `?` + // interpreted as "any character" can only return *too many* results as compared to the literal + // interpretation, so we can filter those superfluous results out via `trimPrefixAndSuffix` as we've always + // done. + var includeGlob = normalizedSuffix ? "**/*" + normalizedSuffix : "./*"; + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, extensionOptions.extensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var trimmedWithPattern = trimPrefixAndSuffix(match); + if (trimmedWithPattern) { + if (containsSlash(trimmedWithPattern)) { + return directoryResult(ts.getPathComponents(removeLeadingDirectorySeparator(trimmedWithPattern))[1]); + } + var _a = getFilenameWithExtensionOption(trimmedWithPattern, host.getCompilationSettings(), extensionOptions.includeExtensionsOption), name = _a.name, extension = _a.extension; + return nameAndKind(name, "script" /* ScriptElementKind.scriptElement */, extension); + } }); + // If we had a suffix, we already recursively searched for all possible files that could match + // it and returned the directories leading to those files. Otherwise, assume any directory could + // have something valid to import. + var directories = normalizedSuffix + ? ts.emptyArray + : ts.mapDefined(ts.tryGetDirectories(host, baseDirectory), function (dir) { return dir === "node_modules" ? undefined : directoryResult(dir); }); return __spreadArray(__spreadArray([], matches, true), directories, true); function trimPrefixAndSuffix(path) { var inner = withoutStartAndEnd(ts.normalizePath(path), completePrefix, normalizedSuffix); @@ -133424,13 +134120,13 @@ var ts; } var prefix = match[1], kind = match[2], toComplete = match[3]; var scriptPath = ts.getDirectoryPath(sourceFile.path); - var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* Include */), host, sourceFile.path) + var names = kind === "path" ? getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getExtensionOptions(compilerOptions, 1 /* IncludeExtensionsOption.Include */), host, sourceFile.path) : kind === "types" ? getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, getFragmentDirectory(toComplete), getExtensionOptions(compilerOptions)) : ts.Debug.fail(); - return addReplacementSpans(toComplete, range.pos + prefix.length, names); + return addReplacementSpans(toComplete, range.pos + prefix.length, ts.arrayFrom(names.values())); } function getCompletionEntriesFromTypings(host, options, scriptPath, fragmentDirectory, extensionOptions, result) { - if (result === void 0) { result = []; } + if (result === void 0) { result = createNameAndKindSet(); } // Check for typings specified in compiler options var seen = new ts.Map(); var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; @@ -133455,7 +134151,7 @@ var ts; continue; if (fragmentDirectory === undefined) { if (!seen.has(packageName)) { - result.push(nameAndKind(packageName, "external module name" /* externalModuleName */, /*extension*/ undefined)); + result.add(nameAndKind(packageName, "external module name" /* ScriptElementKind.externalModuleName */, /*extension*/ undefined)); seen.set(packageName, true); } } @@ -133497,14 +134193,14 @@ var ts; var offset = index !== -1 ? index + 1 : 0; // If the range is an identifier, span is unnecessary. var length = text.length - offset; - return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); + return length === 0 || ts.isIdentifierText(text.substr(offset, length), 99 /* ScriptTarget.ESNext */) ? undefined : ts.createTextSpan(textStart + offset, length); } // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* CharacterCodes.dot */ ? 2 : 1; var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + return slashCharCode === 47 /* CharacterCodes.slash */ || slashCharCode === 92 /* CharacterCodes.backslash */; } return false; } @@ -133561,7 +134257,7 @@ var ts; return "z" + sortText; }, ObjectLiteralProperty: function (presetSortText, symbolDisplayName) { - return presetSortText + "\0" + symbolDisplayName + "\0"; + return "".concat(presetSortText, "\0").concat(symbolDisplayName, "\0"); }, SortBelow: function (sortText) { return sortText + "1"; @@ -133603,16 +134299,16 @@ var ts; SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport"; })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {})); function originIsThisType(origin) { - return !!(origin.kind & 1 /* ThisType */); + return !!(origin.kind & 1 /* SymbolOriginInfoKind.ThisType */); } function originIsSymbolMember(origin) { - return !!(origin.kind & 2 /* SymbolMember */); + return !!(origin.kind & 2 /* SymbolOriginInfoKind.SymbolMember */); } function originIsExport(origin) { - return !!(origin && origin.kind & 4 /* Export */); + return !!(origin && origin.kind & 4 /* SymbolOriginInfoKind.Export */); } function originIsResolvedExport(origin) { - return !!(origin && origin.kind === 32 /* ResolvedExport */); + return !!(origin && origin.kind === 32 /* SymbolOriginInfoKind.ResolvedExport */); } function originIncludesSymbolName(origin) { return originIsExport(origin) || originIsResolvedExport(origin); @@ -133621,16 +134317,16 @@ var ts; return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson; } function originIsPromise(origin) { - return !!(origin.kind & 8 /* Promise */); + return !!(origin.kind & 8 /* SymbolOriginInfoKind.Promise */); } function originIsNullableMember(origin) { - return !!(origin.kind & 16 /* Nullable */); + return !!(origin.kind & 16 /* SymbolOriginInfoKind.Nullable */); } function originIsTypeOnlyAlias(origin) { - return !!(origin && origin.kind & 64 /* TypeOnlyAlias */); + return !!(origin && origin.kind & 64 /* SymbolOriginInfoKind.TypeOnlyAlias */); } function originIsObjectLiteralMethod(origin) { - return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */); + return !!(origin && origin.kind & 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */); } var KeywordCompletionFilters; (function (KeywordCompletionFilters) { @@ -133671,10 +134367,10 @@ var ts; resolvedAny: function () { return resolvedCount > 0; }, resolvedBeyondLimit: function () { return resolvedCount > Completions.moduleSpecifierResolutionLimit; }, }); - var hitRateMessage = cacheAttemptCount ? " (" + (resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1) + "% hit rate)" : ""; - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, logPrefix + ": resolved " + resolvedCount + " module specifiers, plus " + ambientCount + " ambient and " + resolvedFromCacheCount + " from cache" + hitRateMessage); - (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (skippedAny ? "incomplete" : "complete")); - (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start)); + var hitRateMessage = cacheAttemptCount ? " (".concat((resolvedFromCacheCount / cacheAttemptCount * 100).toFixed(1), "% hit rate)") : ""; + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "".concat(logPrefix, ": resolved ").concat(resolvedCount, " module specifiers, plus ").concat(ambientCount, " ambient and ").concat(resolvedFromCacheCount, " from cache").concat(hitRateMessage)); + (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "".concat(logPrefix, ": response is ").concat(skippedAny ? "incomplete" : "complete")); + (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "".concat(logPrefix, ": ").concat(ts.timestamp() - start)); return result; function tryResolve(exportInfo, symbolName, isFromAmbientModule) { if (isFromAmbientModule) { @@ -133717,7 +134413,7 @@ var ts; // we can continue it from the cached previous response. var compilerOptions = program.getCompilerOptions(); var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined; - if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { + if (incompleteCompletionsCache && completionKind === 3 /* CompletionTriggerKind.TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) { var incompleteContinuation = continuePreviousIncompleteResponse(incompleteCompletionsCache, sourceFile, previousToken, program, host, preferences, cancellationToken); if (incompleteContinuation) { return incompleteContinuation; @@ -133731,7 +134427,7 @@ var ts; return stringCompletions; } if (previousToken && ts.isBreakOrContinueStatement(previousToken.parent) - && (previousToken.kind === 81 /* BreakKeyword */ || previousToken.kind === 86 /* ContinueKeyword */ || previousToken.kind === 79 /* Identifier */)) { + && (previousToken.kind === 81 /* SyntaxKind.BreakKeyword */ || previousToken.kind === 86 /* SyntaxKind.ContinueKeyword */ || previousToken.kind === 79 /* SyntaxKind.Identifier */)) { return getLabelCompletionAtPosition(previousToken.parent); } var completionData = getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, /*detailsEntryId*/ undefined, host, formatContext, cancellationToken); @@ -133739,21 +134435,21 @@ var ts; return undefined; } switch (completionData.kind) { - case 0 /* Data */: + case 0 /* CompletionDataKind.Data */: var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position); if (response === null || response === void 0 ? void 0 : response.isIncomplete) { incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response); } return response; - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: // If the current position is a jsDoc tag name, only tag names should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagNameCompletions()); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: // If the current position is a jsDoc tag, only tags should be provided for completion return jsdocCompletionInfo(ts.JsDoc.getJSDocTagCompletions()); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return jsdocCompletionInfo(ts.JsDoc.getJSDocParameterNameCompletions(completionData.tag)); - case 4 /* Keywords */: + case 4 /* CompletionDataKind.Keywords */: return specificKeywordCompletionInfo(completionData.keywordCompletions, completionData.isNewIdentifierLocation); default: return ts.Debug.assertNever(completionData); @@ -133770,16 +134466,16 @@ var ts; function compareCompletionEntries(entryInArray, entryToInsert) { var _a, _b; var result = ts.compareStringsCaseSensitiveUI(entryInArray.sortText, entryToInsert.sortText); - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { result = ts.compareStringsCaseSensitiveUI(entryInArray.name, entryToInsert.name); } - if (result === 0 /* EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { + if (result === 0 /* Comparison.EqualTo */ && ((_a = entryInArray.data) === null || _a === void 0 ? void 0 : _a.moduleSpecifier) && ((_b = entryToInsert.data) === null || _b === void 0 ? void 0 : _b.moduleSpecifier)) { // Sort same-named auto-imports by module specifier result = ts.compareNumberOfDirectorySeparators(entryInArray.data.moduleSpecifier, entryToInsert.data.moduleSpecifier); } - if (result === 0 /* EqualTo */) { + if (result === 0 /* Comparison.EqualTo */) { // Fall back to symbol order - if we return `EqualTo`, `insertSorted` will put later symbols first. - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } return result; } @@ -133810,10 +134506,10 @@ var ts; if (result === "skipped") return entry; if (!result || result === "failed") { - (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '" + entry.name + "' from '" + entry.source + "'"); + (_a = host.log) === null || _a === void 0 ? void 0 : _a.call(host, "Unexpected failure resolving auto import for '".concat(entry.name, "' from '").concat(entry.source, "'")); return undefined; } - var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); + var newOrigin = __assign(__assign({}, origin), { kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, moduleSpecifier: result.moduleSpecifier }); // Mutating for performance... feels sketchy but nobody else uses the cache, // so why bother allocating a bunch of new objects? entry.data = originToCompletionEntryData(newOrigin); @@ -133827,7 +134523,7 @@ var ts; return entries; }); previousResponse.entries = newEntries; - previousResponse.flags = (previousResponse.flags || 0) | 4 /* IsContinuation */; + previousResponse.flags = (previousResponse.flags || 0) | 4 /* CompletionInfoFlags.IsContinuation */; return previousResponse; } function jsdocCompletionInfo(entries) { @@ -133836,8 +134532,8 @@ var ts; function keywordToCompletionEntry(keyword) { return { name: ts.tokenToString(keyword), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }; } @@ -133851,62 +134547,61 @@ var ts; } function keywordCompletionData(keywordFilters, filterOutTsOnlyKeywords, isNewIdentifierLocation) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: getKeywordCompletions(keywordFilters, filterOutTsOnlyKeywords), isNewIdentifierLocation: isNewIdentifierLocation, }; } function keywordFiltersFromSyntaxKind(keywordCompletion) { switch (keywordCompletion) { - case 152 /* TypeKeyword */: return 8 /* TypeKeyword */; + case 152 /* SyntaxKind.TypeKeyword */: return 8 /* KeywordCompletionFilters.TypeKeyword */; default: ts.Debug.fail("Unknown mapping from SyntaxKind to KeywordCompletionFilters"); } } function getOptionalReplacementSpan(location) { // StringLiteralLike locations are handled separately in stringCompletions.ts - return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined; + return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* SyntaxKind.Identifier */ ? ts.createTextSpanFromNode(location) : undefined; } function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) { var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextMap = completionData.symbolToSortTextMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports; // Verify if the file is JSX language variant - if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) { + if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* LanguageVariant.JSX */) { var completionInfo = getJsxClosingTagCompletion(location, sourceFile); if (completionInfo) { return completionInfo; } } var entries = ts.createSortedArray(); - if (isUncheckedFile(sourceFile, compilerOptions)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); - getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); - } - else { - if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { - return undefined; - } - getCompletionEntriesFromSymbols(symbols, entries, - /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); + var isChecked = isCheckedFile(sourceFile, compilerOptions); + if (isChecked && !isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* KeywordCompletionFilters.None */) { + return undefined; } - if (keywordFilters !== 0 /* None */) { - var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; })); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, + /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag); + if (keywordFilters !== 0 /* KeywordCompletionFilters.None */) { for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) { var keywordEntry = _a[_i]; - if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) { + if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) { + uniqueNames.add(keywordEntry.name); ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } } - var entryNames = new ts.Set(entries.map(function (e) { return e.name; })); for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) { var keywordEntry = _c[_b]; - if (!entryNames.has(keywordEntry.name)) { + if (!uniqueNames.has(keywordEntry.name)) { + uniqueNames.add(keywordEntry.name); ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true); } } for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) { var literal = literals_1[_d]; - ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true); + var literalEntry = createCompletionEntryForLiteral(sourceFile, preferences, literal); + uniqueNames.add(literalEntry.name); + ts.insertSorted(entries, literalEntry, compareCompletionEntries, /*allowDuplicates*/ true); + } + if (!isChecked) { + getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); } return { flags: completionData.flags, @@ -133918,14 +134613,14 @@ var ts; entries: entries, }; } - function isUncheckedFile(sourceFile, compilerOptions) { - return ts.isSourceFileJS(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); + function isCheckedFile(sourceFile, compilerOptions) { + return !ts.isSourceFileJS(sourceFile) || !!ts.isCheckJsEnabledForFile(sourceFile, compilerOptions); } function isMemberCompletionKind(kind) { switch (kind) { - case 0 /* ObjectPropertyDeclaration */: - case 3 /* MemberLike */: - case 2 /* PropertyAccess */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: + case 3 /* CompletionKind.MemberLike */: + case 2 /* CompletionKind.PropertyAccess */: return true; default: return false; @@ -133935,12 +134630,12 @@ var ts; // We wanna walk up the tree till we find a JSX closing element var jsxClosingElement = ts.findAncestor(location, function (node) { switch (node.kind) { - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return true; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return false; default: return "quit"; @@ -133959,14 +134654,14 @@ var ts; // var x = // var y = // the completion list at "1" and "2" will contain "MainComponent.Child" with a replacement span of closing tag name - var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(jsxClosingElement, 31 /* SyntaxKind.GreaterThanToken */, sourceFile); var tagName = jsxClosingElement.parent.openingElement.tagName; var closingTag = tagName.getText(sourceFile); var fullClosingTag = closingTag + (hasClosingAngleBracket ? "" : ">"); var replacementSpan = ts.createTextSpanFromNode(jsxClosingElement.tagName); var entry = { name: fullClosingTag, - kind: "class" /* classElement */, + kind: "class" /* ScriptElementKind.classElement */, kindModifiers: undefined, sortText: Completions.SortText.LocationPriority, }; @@ -133985,7 +134680,7 @@ var ts; uniqueNames.add(realName); ts.insertSorted(entries, { name: realName, - kind: "warning" /* warning */, + kind: "warning" /* ScriptElementKind.warning */, kindModifiers: "", sortText: Completions.SortText.JavascriptIdentifiers, isFromUncheckedFile: true @@ -133998,7 +134693,7 @@ var ts; ts.isString(literal) ? ts.quote(sourceFile, preferences, literal) : JSON.stringify(literal); } function createCompletionEntryForLiteral(sourceFile, preferences, literal) { - return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: Completions.SortText.LocationPriority }; + return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* ScriptElementKind.string */, kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.LocationPriority }; } function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) { var _a, _b; @@ -134015,18 +134710,18 @@ var ts; var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { insertText = needsConvertPropertyAccess - ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(sourceFile, preferences, name) + "]" - : "this" + (insertQuestionDot ? "?." : ".") + name; + ? "this".concat(insertQuestionDot ? "?." : "", "[").concat(quotePropertyName(sourceFile, preferences, name), "]") + : "this".concat(insertQuestionDot ? "?." : ".").concat(name); } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { - insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(sourceFile, preferences, name) + "]" : "[" + name + "]" : name; + insertText = useBraces ? needsConvertPropertyAccess ? "[".concat(quotePropertyName(sourceFile, preferences, name), "]") : "[".concat(name, "]") : name; if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { - insertText = "?." + insertText; + insertText = "?.".concat(insertText); } - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || - ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* SyntaxKind.DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* SyntaxKind.QuestionDotToken */, sourceFile); if (!dot) { return undefined; } @@ -134037,7 +134732,7 @@ var ts; if (isJsxInitializer) { if (insertText === undefined) insertText = name; - insertText = "{" + insertText + "}"; + insertText = "{".concat(insertText, "}"); if (typeof isJsxInitializer !== "boolean") { replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } @@ -134050,8 +134745,8 @@ var ts; if (precedingToken && ts.positionIsASICandidate(precedingToken.end, precedingToken.parent, sourceFile)) { awaitText = ";"; } - awaitText += "(await " + propertyAccessToConvert.expression.getText() + ")"; - insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + awaitText += "(await ".concat(propertyAccessToConvert.expression.getText(), ")"); + insertText = needsConvertPropertyAccess ? "".concat(awaitText).concat(insertText) : "".concat(awaitText).concat(insertQuestionDot ? "?." : ".").concat(insertText); replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); } if (originIsResolvedExport(origin)) { @@ -134061,12 +134756,12 @@ var ts; isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined; } } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { hasAction = true; } if (preferences.includeCompletionsWithClassMemberSnippets && preferences.includeCompletionsWithInsertText && - completionKind === 3 /* MemberLike */ && + completionKind === 3 /* CompletionKind.MemberLike */ && isClassLikeMemberCompletion(symbol, location)) { var importAdder = void 0; (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan); @@ -134090,11 +134785,11 @@ var ts; var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); // If is boolean like or undefined, don't return a snippet we want just to return the completion. if (preferences.jsxAttributeCompletionStyle === "auto" - && !(type.flags & 528 /* BooleanLike */) - && !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) { - if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) { + && !(type.flags & 528 /* TypeFlags.BooleanLike */) + && !(type.flags & 1048576 /* TypeFlags.Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* TypeFlags.BooleanLike */); }))) { + if (type.flags & 402653316 /* TypeFlags.StringLike */ || (type.flags & 1048576 /* TypeFlags.Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* TypeFlags.StringLike */ | 32768 /* TypeFlags.Undefined */)); }))) { // If is string like or undefined use quotes - insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1"); + insertText = "".concat(ts.escapeSnippetText(name), "=").concat(ts.quote(sourceFile, preferences, "$1")); isSnippet = true; } else { @@ -134103,7 +134798,7 @@ var ts; } } if (useBraces_1) { - insertText = ts.escapeSnippetText(name) + "={$1}"; + insertText = "".concat(ts.escapeSnippetText(name), "={$1}"); isSnippet = true; } } @@ -134145,8 +134840,8 @@ var ts; return false; } // Completion symbol must be for a class member. - var memberFlags = 106500 /* ClassMember */ - & 900095 /* EnumMemberExcludes */; + var memberFlags = 106500 /* SymbolFlags.ClassMember */ + & 900095 /* SymbolFlags.EnumMemberExcludes */; /* In `class C { | @@ -134205,16 +134900,16 @@ var ts; // Note: this assumes we won't have more than one body in the completion nodes, which should be the case. var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; // Whether the suggested member should be abstract. // e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`. var _a = getPresentModifiers(contextToken), presentModifiers = _a.modifiers, modifiersSpan = _a.span; - var isAbstract = !!(presentModifiers & 128 /* Abstract */); + var isAbstract = !!(presentModifiers & 128 /* ModifierFlags.Abstract */); var completionNodes = []; ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder, // `addNewNodeForMemberSymbol` calls this callback function for each new member node @@ -134225,13 +134920,13 @@ var ts; // - One node; // - More than one node if the member is overloaded (e.g. a method with overload signatures). function (node) { - var requiredModifiers = 0 /* None */; + var requiredModifiers = 0 /* ModifierFlags.None */; if (isAbstract) { - requiredModifiers |= 128 /* Abstract */; + requiredModifiers |= 128 /* ModifierFlags.Abstract */; } if (ts.isClassElement(node) - && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) { - requiredModifiers |= 16384 /* Override */; + && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* MemberOverrideStatus.NeedsOverride */) { + requiredModifiers |= 16384 /* ModifierFlags.Override */; } if (!completionNodes.length) { // Keep track of added missing required modifiers and modifiers already present. @@ -134242,9 +134937,9 @@ var ts; } node = ts.factory.updateModifiers(node, modifiers); completionNodes.push(node); - }, body, 2 /* Property */, isAbstract); + }, body, 2 /* codefix.PreserveOptionalFlags.Property */, isAbstract); if (completionNodes.length) { - var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */; + var format = 1 /* ListFormat.MultiLine */ | 131072 /* ListFormat.NoTrailingNewLine */; replacementSpan = modifiersSpan; // If we have access to formatting settings, we print the nodes using the emitter, // and then format the printed text. @@ -134259,9 +134954,9 @@ var ts; } function getPresentModifiers(contextToken) { if (!contextToken) { - return { modifiers: 0 /* None */ }; + return { modifiers: 0 /* ModifierFlags.None */ }; } - var modifiers = 0 /* None */; + var modifiers = 0 /* ModifierFlags.None */; var span; var contextMod; /* @@ -134288,7 +134983,7 @@ var ts; span = ts.createTextSpanFromNode(contextToken); } if (ts.isPropertyDeclaration(contextToken.parent)) { - modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers) & 125951 /* Modifier */; + modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers) & 125951 /* ModifierFlags.Modifier */; span = ts.createTextSpanFromNode(contextToken.parent); } return { modifiers: modifiers, span: span }; @@ -134318,10 +135013,10 @@ var ts; newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))), }); if (formatContext) { - insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); + insertText = printer.printAndFormatSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext); } else { - insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); + insertText = printer.printSnippetList(16 /* ListFormat.CommaDelimited */ | 64 /* ListFormat.AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile); } var signaturePrinter = ts.createPrinter({ removeComments: true, @@ -134334,7 +135029,7 @@ var ts; var methodSignature = ts.factory.createMethodSignature( /*modifiers*/ undefined, /*name*/ "", method.questionToken, method.typeParameters, method.parameters, method.type); - var labelDetails = { detail: signaturePrinter.printNode(4 /* Unspecified */, methodSignature, sourceFile) }; + var labelDetails = { detail: signaturePrinter.printNode(4 /* EmitHint.Unspecified */, methodSignature, sourceFile) }; return { isSnippet: isSnippet, insertText: insertText, labelDetails: labelDetails }; } ; @@ -134348,18 +135043,18 @@ var ts; var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false); var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + var builderFlags = 33554432 /* NodeBuilderFlags.OmitThisParameter */ | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: { - var effectiveType = type.flags & 1048576 /* Union */ && type.types.length < 10 - ? checker.getUnionType(type.types, 2 /* Subtype */) + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: { + var effectiveType = type.flags & 1048576 /* TypeFlags.Union */ && type.types.length < 10 + ? checker.getUnionType(type.types, 2 /* UnionReduction.Subtype */) : type; - if (effectiveType.flags & 1048576 /* Union */) { + if (effectiveType.flags & 1048576 /* TypeFlags.Union */) { // Only offer the completion if there's a single function type component. - var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* Call */).length > 0; }); + var functionTypes = ts.filter(effectiveType.types, function (type) { return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; }); if (functionTypes.length === 1) { effectiveType = functionTypes[0]; } @@ -134367,7 +135062,7 @@ var ts; return undefined; } } - var signatures = checker.getSignaturesOfType(effectiveType, 0 /* Call */); + var signatures = checker.getSignaturesOfType(effectiveType, 0 /* SignatureKind.Call */); if (signatures.length !== 1) { // We don't support overloads in object literals. return undefined; @@ -134380,7 +135075,7 @@ var ts; if (preferences.includeCompletionsWithSnippetText) { var emptyStmt = ts.factory.createEmptyStatement(); body = ts.factory.createBlock([emptyStmt], /* multiline */ true); - ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 }); + ts.setSnippetElement(emptyStmt, { kind: 0 /* SnippetKind.TabStop */, order: 0 }); } else { body = ts.factory.createBlock([], /* multiline */ true); @@ -134480,11 +135175,11 @@ var ts; return unresolvedData; } function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) { - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; var isFromPackageJson = !!data.isPackageJsonImport; if (completionEntryDataIsResolved(data)) { var resolvedOrigin = { - kind: 32 /* ResolvedExport */, + kind: 32 /* SymbolOriginInfoKind.ResolvedExport */, exportName: data.exportName, moduleSpecifier: data.moduleSpecifier, symbolName: completionName, @@ -134496,7 +135191,7 @@ var ts; return resolvedOrigin; } var unresolvedOrigin = { - kind: 4 /* Export */, + kind: 4 /* SymbolOriginInfoKind.Export */, exportName: data.exportName, exportMapKey: data.exportMapKey, symbolName: completionName, @@ -134512,21 +135207,21 @@ var ts; var sourceFile = importCompletionNode.getSourceFile(); var replacementSpan = ts.createTextSpanFromNode(ts.findAncestor(importCompletionNode, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)) || importCompletionNode, sourceFile); var quotedModuleSpecifier = ts.quote(sourceFile, preferences, origin.moduleSpecifier); - var exportKind = origin.isDefaultExport ? 1 /* Default */ : - origin.exportName === "export=" /* ExportEquals */ ? 2 /* ExportEquals */ : - 0 /* Named */; + var exportKind = origin.isDefaultExport ? 1 /* ExportKind.Default */ : + origin.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ExportKind.ExportEquals */ : + 0 /* ExportKind.Named */; var tabStop = preferences.includeCompletionsWithSnippetText ? "$1" : ""; var importKind = ts.codefix.getImportKind(sourceFile, exportKind, options, /*forceImportKeyword*/ true); var isTopLevelTypeOnly = ((_b = (_a = ts.tryCast(importCompletionNode, ts.isImportDeclaration)) === null || _a === void 0 ? void 0 : _a.importClause) === null || _b === void 0 ? void 0 : _b.isTypeOnly) || ((_c = ts.tryCast(importCompletionNode, ts.isImportEqualsDeclaration)) === null || _c === void 0 ? void 0 : _c.isTypeOnly); var isImportSpecifierTypeOnly = couldBeTypeOnlyImportSpecifier(importCompletionNode, contextToken); - var topLevelTypeOnlyText = isTopLevelTypeOnly ? " " + ts.tokenToString(152 /* TypeKeyword */) + " " : " "; - var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(152 /* TypeKeyword */) + " " : ""; + var topLevelTypeOnlyText = isTopLevelTypeOnly ? " ".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : " "; + var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? "".concat(ts.tokenToString(152 /* SyntaxKind.TypeKeyword */), " ") : ""; var suffix = useSemicolons ? ";" : ""; switch (importKind) { - case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix }; - case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix }; - case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix }; - case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix }; + case 3 /* ImportKind.CommonJS */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " = require(").concat(quotedModuleSpecifier, ")").concat(suffix) }; + case 1 /* ImportKind.Default */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 2 /* ImportKind.Namespace */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "* as ").concat(ts.escapeSnippetText(name), " from ").concat(quotedModuleSpecifier).concat(suffix) }; + case 0 /* ImportKind.Named */: return { replacementSpan: replacementSpan, insertText: "import".concat(topLevelTypeOnlyText, "{ ").concat(importSpecifierTypeOnlyText).concat(ts.escapeSnippetText(name)).concat(tabStop, " } from ").concat(quotedModuleSpecifier).concat(suffix) }; } } function quotePropertyName(sourceFile, preferences, name) { @@ -134537,7 +135232,7 @@ var ts; } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || - !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; + !!(localSymbol.flags & 1048576 /* SymbolFlags.ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; } function getSourceFromOrigin(origin) { if (originIsExport(origin)) { @@ -134546,10 +135241,10 @@ var ts; if (originIsResolvedExport(origin)) { return origin.moduleSpecifier; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* SymbolOriginInfoKind.ThisType */) { return CompletionSource.ThisProperty; } - if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) { + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* SymbolOriginInfoKind.TypeOnlyAlias */) { return CompletionSource.TypeOnlyAlias; } } @@ -134568,7 +135263,7 @@ var ts; var symbol = symbols[i]; var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); - if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { + if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* CompletionKind.Global */ && symbolToSortTextMap && !shouldIncludeSymbol(symbol, symbolToSortTextMap)) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; @@ -134621,7 +135316,7 @@ var ts; allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin); // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace) if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) { - return !!(allFlags & 1920 /* Namespace */); + return !!(allFlags & 1920 /* SymbolFlags.Namespace */); } if (isTypeOnlyLocation) { // It's a type, but you can reach it by namespace.type as well @@ -134629,7 +135324,7 @@ var ts; } } // expressions are value space (which includes the value namespaces) - return !!(allFlags & 111551 /* Value */); + return !!(allFlags & 111551 /* SymbolFlags.Value */); } } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; @@ -134653,8 +135348,8 @@ var ts; uniques.set(name, true); entries.push({ name: name, - kindModifiers: "" /* none */, - kind: "label" /* label */, + kindModifiers: "" /* ScriptElementKindModifier.none */, + kind: "label" /* ScriptElementKind.label */, sortText: Completions.SortText.LocationPriority }); } @@ -134685,7 +135380,7 @@ var ts; if (!completionData) { return { type: "none" }; } - if (completionData.kind !== 0 /* Data */) { + if (completionData.kind !== 0 /* CompletionDataKind.Data */) { return { type: "request", request: completionData }; } var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; @@ -134699,8 +135394,8 @@ var ts; return ts.firstDefined(symbols, function (symbol, index) { var origin = symbolToOriginInfoMap[index]; var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); - return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ - || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */) + return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* SymbolFlags.ClassMember */ + || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */) || getSourceFromOrigin(origin) === entryId.source) ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; @@ -134720,14 +135415,14 @@ var ts; case "request": { var request = symbolCompletion.request; switch (request.kind) { - case 1 /* JsDocTagName */: + case 1 /* CompletionDataKind.JsDocTagName */: return ts.JsDoc.getJSDocTagNameCompletionDetails(name); - case 2 /* JsDocTag */: + case 2 /* CompletionDataKind.JsDocTag */: return ts.JsDoc.getJSDocTagCompletionDetails(name); - case 3 /* JsDocParameterName */: + case 3 /* CompletionDataKind.JsDocParameterName */: return ts.JsDoc.getJSDocParameterNameCompletionDetails(name); - case 4 /* Keywords */: - return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + case 4 /* CompletionDataKind.Keywords */: + return ts.some(request.keywordCompletions, function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: return ts.Debug.assertNever(request); } @@ -134739,22 +135434,22 @@ var ts; } case "literal": { var literal = symbolCompletion.literal; - return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); + return createSimpleDetails(completionNameForLiteral(sourceFile, preferences, literal), "string" /* ScriptElementKind.string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. - return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; + return allKeywordsCompletions().some(function (c) { return c.name === name; }) ? createSimpleDetails(name, "keyword" /* ScriptElementKind.keyword */, ts.SymbolDisplayPartKind.keyword) : undefined; default: ts.Debug.assertNever(symbolCompletion); } } Completions.getCompletionEntryDetails = getCompletionEntryDetails; function createSimpleDetails(name, kind, kind2) { - return createCompletionDetails(name, "" /* none */, kind, [ts.displayPart(name, kind2)]); + return createCompletionDetails(name, "" /* ScriptElementKindModifier.none */, kind, [ts.displayPart(name, kind2)]); } function createCompletionDetailsForSymbol(symbol, checker, sourceFile, location, cancellationToken, codeActions, sourceDisplay) { var _a = checker.runWithCancellationToken(cancellationToken, function (checker) { - return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* All */); + return ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, sourceFile, location, location, 7 /* SemanticMeaning.All */); }), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return createCompletionDetails(symbol.name, ts.SymbolDisplay.getSymbolModifiers(checker, symbol), symbolKind, displayParts, documentation, tags, codeActions, sourceDisplay); } @@ -134794,7 +135489,7 @@ var ts; var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); var moduleSymbol = origin.moduleSymbol; var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); + var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* SyntaxKind.LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent); var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier); return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; @@ -134826,7 +135521,7 @@ var ts; return ts.firstDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (type) { var symbol = type && type.symbol; // Don't include make a recommended completion for an abstract class - return symbol && (symbol.flags & (8 /* EnumMember */ | 384 /* Enum */ | 32 /* Class */) && !ts.isAbstractConstructorSymbol(symbol)) + return symbol && (symbol.flags & (8 /* SymbolFlags.EnumMember */ | 384 /* SymbolFlags.Enum */ | 32 /* SymbolFlags.Class */) && !ts.isAbstractConstructorSymbol(symbol)) ? getFirstSymbolInChain(symbol, previousToken, checker) : undefined; }); @@ -134834,31 +135529,31 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return checker.getContextualType(parent); - case 82 /* CaseKeyword */: + case 82 /* SyntaxKind.CaseKeyword */: var caseClause = ts.tryCast(parent, ts.isCaseClause); return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); return argInfo ? // At `,`, treat this as the next argument after the comma. - checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* SyntaxKind.CommaToken */ ? 1 : 0)) : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side checker.getTypeAtLocation(parent.left) : @@ -134866,18 +135561,18 @@ var ts; } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { - var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* All */, /*useOnlyExternalAliasing*/ false); + var chain = checker.getAccessibleSymbolChain(symbol, enclosingDeclaration, /*meaning*/ 67108863 /* SymbolFlags.All */, /*useOnlyExternalAliasing*/ false); if (chain) return ts.first(chain); return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { var _a; - return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SourceFile */; })); + return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SyntaxKind.SourceFile */; })); } function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) { var typeChecker = program.getTypeChecker(); - var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions); + var inCheckedFile = isCheckedFile(sourceFile, compilerOptions); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) @@ -134889,10 +135584,10 @@ var ts; var isInSnippetScope = false; if (insideComment) { if (ts.hasDocComment(sourceFile, position)) { - if (sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + if (sourceFile.text.charCodeAt(position - 1) === 64 /* CharacterCodes.at */) { // The current position is next to the '@' sign, when no tag name being provided yet. // Provide a full list of tag names - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } else { // When completion is requested without "@", we will have check to make sure that @@ -134913,7 +135608,7 @@ var ts; // */ var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) { - return { kind: 2 /* JsDocTag */ }; + return { kind: 2 /* CompletionDataKind.JsDocTag */ }; } } } @@ -134923,21 +135618,21 @@ var ts; var tag = getJsDocTagAtPosition(currentToken, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - return { kind: 1 /* JsDocTagName */ }; + return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; } var typeExpression = tryGetTypeExpressionFromTag(tag); if (typeExpression) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 347 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 347 /* SyntaxKind.JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(typeExpression); } } if (!insideJsDocTagTypeExpression && ts.isJSDocParameterTag(tag) && (ts.nodeIsMissing(tag.name) || tag.name.pos <= position && position <= tag.name.end)) { - return { kind: 3 /* JsDocParameterName */, tag: tag }; + return { kind: 3 /* CompletionDataKind.JsDocParameterName */, tag: tag }; } } if (!insideJsDocTagTypeExpression) { @@ -134968,16 +135663,16 @@ var ts; var isJsxIdentifierExpected = false; var importCompletionNode; var location = ts.getTouchingPropertyName(sourceFile, position); - var keywordFilters = 0 /* None */; + var keywordFilters = 0 /* KeywordCompletionFilters.None */; var isNewIdentifierLocation = false; - var flags = 0 /* None */; + var flags = 0 /* CompletionInfoFlags.None */; if (contextToken) { var importStatementCompletion = getImportStatementCompletionInfo(contextToken); isNewIdentifierLocation = importStatementCompletion.isNewIdentifierLocation; if (importStatementCompletion.keywordCompletion) { if (importStatementCompletion.isKeywordOnlyCompletion) { return { - kind: 4 /* Keywords */, + kind: 4 /* CompletionDataKind.Keywords */, keywordCompletions: [keywordToCompletionEntry(importStatementCompletion.keywordCompletion)], isNewIdentifierLocation: isNewIdentifierLocation, }; @@ -134990,7 +135685,7 @@ var ts; // is not backward compatible with older clients, the language service defaults to disabling it, allowing newer clients // to opt in with the `includeCompletionsForImportStatements` user preference. importCompletionNode = importStatementCompletion.replacementNode; - flags |= 2 /* IsImportStatementCompletion */; + flags |= 2 /* CompletionInfoFlags.IsImportStatementCompletion */; } // Bail out if this is a known invalid completion location if (!importCompletionNode && isCompletionListBlocker(contextToken)) { @@ -135000,11 +135695,11 @@ var ts; : undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { - isRightOfDot = contextToken.kind === 24 /* DotToken */; - isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; + if (contextToken.kind === 24 /* SyntaxKind.DotToken */ || contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* SyntaxKind.DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* SyntaxKind.QuestionDotToken */; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; var leftmostAccessExpression = ts.getLeftmostAccessExpression(propertyAccessToConvert); @@ -135012,7 +135707,7 @@ var ts; ((ts.isCallExpression(node) || ts.isFunctionLike(node)) && node.end === contextToken.pos && node.getChildCount(sourceFile) && - ts.last(node.getChildren(sourceFile)).kind !== 21 /* CloseParenToken */)) { + ts.last(node.getChildren(sourceFile)).kind !== 21 /* SyntaxKind.CloseParenToken */)) { // This is likely dot from incorrectly parsed expression and user is starting to write spread // eg: Math.min(./**/) // const x = function (./**/) {} @@ -135020,18 +135715,18 @@ var ts; return undefined; } break; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: node = parent.left; break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: node = parent.name; break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: node = parent; break; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: node = parent.getFirstToken(sourceFile); - ts.Debug.assert(node.kind === 100 /* ImportKeyword */ || node.kind === 103 /* NewKeyword */); + ts.Debug.assert(node.kind === 100 /* SyntaxKind.ImportKeyword */ || node.kind === 103 /* SyntaxKind.NewKeyword */); break; default: // There is nothing that precedes the dot, so this likely just a stray character @@ -135039,58 +135734,58 @@ var ts; return undefined; } } - else if (!importCompletionNode && sourceFile.languageVariant === 1 /* JSX */) { + else if (!importCompletionNode && sourceFile.languageVariant === 1 /* LanguageVariant.JSX */) { // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 206 /* PropertyAccessExpression */) { + if (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 31 /* GreaterThanToken */: - if (currentToken.parent.kind === 278 /* JsxElement */ || currentToken.parent.kind === 280 /* JsxOpeningElement */) { + case 31 /* SyntaxKind.GreaterThanToken */: + if (currentToken.parent.kind === 278 /* SyntaxKind.JsxElement */ || currentToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { location = currentToken; } break; - case 43 /* SlashToken */: - if (currentToken.parent.kind === 279 /* JsxSelfClosingElement */) { + case 43 /* SyntaxKind.SlashToken */: + if (currentToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 281 /* JsxClosingElement */: - if (contextToken.kind === 43 /* SlashToken */) { + case 281 /* SyntaxKind.JsxClosingElement */: + if (contextToken.kind === 43 /* SyntaxKind.SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: isJsxIdentifierExpected = true; - if (contextToken.kind === 29 /* LessThanToken */) { + if (contextToken.kind === 29 /* SyntaxKind.LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: // For `
`, `parent` will be `{true}` and `previousToken` will be `}` - if (previousToken.kind === 19 /* CloseBraceToken */ && currentToken.kind === 31 /* GreaterThanToken */) { + if (previousToken.kind === 19 /* SyntaxKind.CloseBraceToken */ && currentToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { isJsxIdentifierExpected = true; } break; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: // For `
`, `parent` will be JsxAttribute and `previousToken` will be its initializer if (parent.initializer === previousToken && previousToken.end < position) { @@ -135098,16 +135793,16 @@ var ts; break; } switch (previousToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: isJsxInitializer = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: isJsxIdentifierExpected = true; // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 63 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 63 /* SyntaxKind.EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -135116,7 +135811,7 @@ var ts; } } var semanticStart = ts.timestamp(); - var completionKind = 5 /* None */; + var completionKind = 5 /* CompletionKind.None */; var isNonContextualObjectLiteral = false; var hasUnresolvedAutoImports = false; // This also gets mutated in nested-functions after the return @@ -135136,8 +135831,8 @@ var ts; symbols = typeChecker.getJsxIntrinsicTagNamesAt(location); ts.Debug.assertEachIsDefined(symbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else if (isStartingCloseTag) { var tagName = contextToken.parent.parent.openingElement.tagName; @@ -135145,8 +135840,8 @@ var ts; if (tagSymbol) { symbols = [tagSymbol]; } - completionKind = 1 /* Global */; - keywordFilters = 0 /* None */; + completionKind = 1 /* CompletionKind.Global */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the @@ -135160,10 +135855,10 @@ var ts; } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); var contextualType = previousToken && getContextualType(previousToken, position, sourceFile, typeChecker); - var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* EnumLiteral */) ? t.value : undefined; }); + var literals = ts.mapDefined(contextualType && (contextualType.isUnion() ? contextualType.types : [contextualType]), function (t) { return t.isLiteral() && !(t.flags & 1024 /* TypeFlags.EnumLiteral */) ? t.value : undefined; }); var recommendedCompletion = previousToken && contextualType && getRecommendedCompletion(previousToken, contextualType, typeChecker); return { - kind: 0 /* Data */, + kind: 0 /* CompletionDataKind.Data */, symbols: symbols, completionKind: completionKind, isInSnippetScope: isInSnippetScope, @@ -135188,13 +135883,13 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 345 /* JSDocTypedefTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return true; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return !!tag.constraint; default: return false; @@ -135203,13 +135898,13 @@ var ts; function tryGetTypeExpressionFromTag(tag) { if (isTagWithTypeExpression(tag)) { var typeExpression = ts.isJSDocTemplateTag(tag) ? tag.constraint : tag.typeExpression; - return typeExpression && typeExpression.kind === 309 /* JSDocTypeExpression */ ? typeExpression : undefined; + return typeExpression && typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? typeExpression : undefined; } return undefined; } function getTypeScriptMemberSymbols() { // Right of dot member completion list - completionKind = 2 /* PropertyAccess */; + completionKind = 2 /* CompletionKind.PropertyAccess */; // Since this is qualified name check it's a type node location var isImportType = ts.isLiteralImportTypeNode(node); var isTypeLocation = insideJsDocTagTypeExpression @@ -135224,7 +135919,7 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { symbol = ts.skipAlias(symbol, typeChecker); - if (symbol.flags & (1536 /* Module */ | 384 /* Enum */)) { + if (symbol.flags & (1536 /* SymbolFlags.Module */ | 384 /* SymbolFlags.Enum */)) { // Extract module or enum members var exportedSymbols = typeChecker.getExportsOfModule(symbol); ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); @@ -135232,7 +135927,7 @@ var ts; var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol, typeChecker); }; var isValidAccess = isNamespaceName // At `namespace N.M/**/`, if this is the only declaration of `M`, don't include `M` as a completion. - ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } + ? function (symbol) { var _a; return !!(symbol.flags & 1920 /* SymbolFlags.Namespace */) && !((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return d.parent === node.parent; })); } : isRhsOfImportDeclaration ? // Any kind is allowed when dotting off namespace in internal import equals declaration function (symbol) { return isValidTypeAccess_1(symbol) || isValidValueAccess_1(symbol); } : @@ -135246,7 +135941,7 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 305 /* SourceFile */ && d.kind !== 261 /* ModuleDeclaration */ && d.kind !== 260 /* EnumDeclaration */; })) { + symbol.declarations.some(function (d) { return d.kind !== 305 /* SyntaxKind.SourceFile */ && d.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && d.kind !== 260 /* SyntaxKind.EnumDeclaration */; })) { var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); var insertQuestionDot = false; if (type.isNullableType()) { @@ -135260,7 +135955,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } return; } @@ -135284,7 +135979,7 @@ var ts; } } } - addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); + addTypeProperties(type, !!(node.flags & 32768 /* NodeFlags.AwaitContext */), insertQuestionDot); } } function addTypeProperties(type, insertAwait, insertQuestionDot) { @@ -135292,16 +135987,8 @@ var ts; if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { isNewIdentifierLocation = true; } - var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent; - if (inUncheckedFile) { - // In javascript files, for union types, we don't just get the members that - // the individual types have in common, we also include all the members that - // each individual type has. This is because we're going to add all identifiers - // anyways. So we might as well elevate the members that were at least part - // of the individual types to a higher status since we know what they are. - symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); })); - } - else { + var propertyAccess = node.kind === 200 /* SyntaxKind.ImportType */ ? node : node.parent; + if (inCheckedFile) { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { @@ -135309,6 +135996,14 @@ var ts; } } } + else { + // In javascript files, for union types, we don't just get the members that + // the individual types have in common, we also include all the members that + // each individual type has. This is because we're going to add all identifiers + // anyways. So we might as well elevate the members that were at least part + // of the individual types to a higher status since we know what they are. + symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); })); + } if (insertAwait && preferences.includeCompletionsWithInsertText) { var promiseType = typeChecker.getPromisedTypeOfPromise(type); if (promiseType) { @@ -135339,12 +136034,12 @@ var ts; if (!moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) || typeChecker.tryGetMemberInModuleExportsAndProperties(firstAccessibleSymbol.name, moduleSymbol) !== firstAccessibleSymbol) { - symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) }; + symbolToOriginInfoMap[index] = { kind: getNullableSymbolOriginInfoKind(2 /* SymbolOriginInfoKind.SymbolMemberNoExport */) }; } else { var fileName = ts.isExternalModuleNameRelative(ts.stripQuotes(moduleSymbol.name)) ? (_a = ts.getSourceFileOfModule(moduleSymbol)) === null || _a === void 0 ? void 0 : _a.fileName : undefined; var moduleSpecifier = ((importSpecifierResolver || (importSpecifierResolver = ts.codefix.createImportSpecifierResolver(sourceFile, program, host, preferences))).getModuleSpecifierForBestExportInfo([{ - exportKind: 0 /* Named */, + exportKind: 0 /* ExportKind.Named */, moduleFileName: fileName, isFromPackageJson: false, moduleSymbol: moduleSymbol, @@ -135353,7 +136048,7 @@ var ts; }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location)) || {}).moduleSpecifier; if (moduleSpecifier) { var origin = { - kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), + kind: getNullableSymbolOriginInfoKind(6 /* SymbolOriginInfoKind.SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false, symbolName: firstAccessibleSymbol.name, @@ -135384,15 +136079,15 @@ var ts; function addSymbolOriginInfo(symbol) { if (preferences.includeCompletionsWithInsertText) { if (insertAwait && ts.addToSeen(seenPropertySymbols, ts.getSymbolId(symbol))) { - symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + symbolToOriginInfoMap[symbols.length] = { kind: getNullableSymbolOriginInfoKind(8 /* SymbolOriginInfoKind.Promise */) }; } else if (insertQuestionDot) { - symbolToOriginInfoMap[symbols.length] = { kind: 16 /* Nullable */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 16 /* SymbolOriginInfoKind.Nullable */ }; } } } function getNullableSymbolOriginInfoKind(kind) { - return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + return insertQuestionDot ? kind | 16 /* SymbolOriginInfoKind.Nullable */ : kind; } } /** Given 'a.b.c', returns 'a'. */ @@ -135408,44 +136103,44 @@ var ts; || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() - || (getGlobalCompletions(), 1 /* Success */); - return result === 1 /* Success */; + || (getGlobalCompletions(), 1 /* GlobalsSearch.Success */); + return result === 1 /* GlobalsSearch.Success */; } function tryGetConstructorCompletion() { if (!tryGetConstructorLikeCompletionContainer(contextToken)) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // no members, only keywords - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; // Declaring new property/method/accessor isNewIdentifierLocation = true; // Has keywords for constructor parameter - keywordFilters = 4 /* ConstructorParameterKeywords */; - return 1 /* Success */; + keywordFilters = 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */; + return 1 /* GlobalsSearch.Success */; } function tryGetJsxCompletionSymbols() { var jsxContainer = tryGetContainingJsxElement(contextToken); // Cursor is inside a JSX self-closing element or opening element var attrsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes); if (!attrsType) - return 0 /* Continue */; - var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* Completions */); + return 0 /* GlobalsSearch.Continue */; + var completionsType = jsxContainer && typeChecker.getContextualType(jsxContainer.attributes, 4 /* ContextFlags.Completions */); symbols = ts.concatenate(symbols, filterJsxAttributes(getPropertiesForObjectExpression(attrsType, completionsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties)); setSortTextToOptionalMember(); - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function tryGetImportCompletionSymbols() { if (!importCompletionNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; isNewIdentifierLocation = true; collectAutoImports(); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function getGlobalCompletions() { - keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* FunctionLikeBodyKeywords */ : 1 /* All */; + keywordFilters = tryGetFunctionLikeBodyCompletionContainer(contextToken) ? 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */ : 1 /* KeywordCompletionFilters.All */; // Get all entities in the current scope. - completionKind = 1 /* Global */; + completionKind = 1 /* CompletionKind.Global */; isNewIdentifierLocation = isNewIdentifierDefinitionLocation(); if (previousToken !== contextToken) { ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); @@ -135480,7 +136175,7 @@ var ts; position; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); - var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; + var symbolMeanings = (isTypeOnlyLocation ? 0 /* SymbolFlags.None */ : 111551 /* SymbolFlags.Value */) | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */; var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken); symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings)); ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); @@ -135490,21 +136185,21 @@ var ts; !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) { symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.GlobalsOrKeywords; } - if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) { + if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* SymbolFlags.Value */)) { var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); if (typeOnlyAliasDeclaration) { - var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; + var origin = { kind: 64 /* SymbolOriginInfoKind.TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration }; symbolToOriginInfoMap[i] = origin; } } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SyntaxKind.SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined); if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) { var symbol = _a[_i]; - symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ }; + symbolToOriginInfoMap[symbols.length] = { kind: 1 /* SymbolOriginInfoKind.ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.SuggestedClassMembers; } @@ -135513,8 +136208,8 @@ var ts; collectAutoImports(); if (isTypeOnlyLocation) { keywordFilters = contextToken && ts.isAssertionExpression(contextToken.parent) - ? 6 /* TypeAssertionKeywords */ - : 7 /* TypeKeywords */; + ? 6 /* KeywordCompletionFilters.TypeAssertionKeywords */ + : 7 /* KeywordCompletionFilters.TypeKeywords */; } } function shouldOfferImportCompletions() { @@ -135538,10 +136233,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 305 /* SourceFile */: - case 223 /* TemplateExpression */: - case 288 /* JsxExpression */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 223 /* SyntaxKind.TemplateExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 235 /* SyntaxKind.Block */: return true; default: return ts.isStatement(scopeNode); @@ -135557,29 +136252,29 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - ((contextToken.kind === 112 /* TypeOfKeyword */ && - (contextToken.parent.kind === 181 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || - (contextToken.kind === 128 /* AssertsKeyword */ && contextToken.parent.kind === 177 /* TypePredicate */)); + ((contextToken.kind === 112 /* SyntaxKind.TypeOfKeyword */ && + (contextToken.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isTypeOfExpression(contextToken.parent))) || + (contextToken.kind === 128 /* SyntaxKind.AssertsKeyword */ && contextToken.parent.kind === 177 /* SyntaxKind.TypePredicate */)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 58 /* ColonToken */: - return parentKind === 167 /* PropertyDeclaration */ || - parentKind === 166 /* PropertySignature */ || - parentKind === 164 /* Parameter */ || - parentKind === 254 /* VariableDeclaration */ || + case 58 /* SyntaxKind.ColonToken */: + return parentKind === 167 /* SyntaxKind.PropertyDeclaration */ || + parentKind === 166 /* SyntaxKind.PropertySignature */ || + parentKind === 164 /* SyntaxKind.Parameter */ || + parentKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 63 /* EqualsToken */: - return parentKind === 259 /* TypeAliasDeclaration */; - case 127 /* AsKeyword */: - return parentKind === 229 /* AsExpression */; - case 29 /* LessThanToken */: - return parentKind === 178 /* TypeReference */ || - parentKind === 211 /* TypeAssertionExpression */; - case 94 /* ExtendsKeyword */: - return parentKind === 163 /* TypeParameter */; + case 63 /* SyntaxKind.EqualsToken */: + return parentKind === 259 /* SyntaxKind.TypeAliasDeclaration */; + case 127 /* SyntaxKind.AsKeyword */: + return parentKind === 229 /* SyntaxKind.AsExpression */; + case 29 /* SyntaxKind.LessThanToken */: + return parentKind === 178 /* SyntaxKind.TypeReference */ || + parentKind === 211 /* SyntaxKind.TypeAssertionExpression */; + case 94 /* SyntaxKind.ExtendsKeyword */: + return parentKind === 163 /* SyntaxKind.TypeParameter */; } } return false; @@ -135594,7 +136289,7 @@ var ts; // Asking for completion details for an item that is not an auto-import return; } - flags |= 1 /* MayIncludeAutoImports */; + flags |= 1 /* CompletionInfoFlags.MayIncludeAutoImports */; // import { type | -> token text should be blank var isAfterTypeOnlyImportSpecifierModifier = previousToken === contextToken && importCompletionNode @@ -135613,13 +136308,13 @@ var ts; return false; if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName)) return false; - if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */)) + if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* SymbolFlags.Value */)) return false; - if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */))) + if (isTypeOnlyLocation && !(targetFlags & (1536 /* SymbolFlags.Module */ | 788968 /* SymbolFlags.Type */))) return false; // Do not try to auto-import something with a lowercase first letter for a JSX tag var firstChar = symbolName.charCodeAt(0); - if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */)) + if (isRightOfOpenTag && (firstChar < 65 /* CharacterCodes.A */ || firstChar > 90 /* CharacterCodes.Z */)) return false; if (detailsEntryId) return true; @@ -135655,14 +136350,14 @@ var ts; if (result !== "skipped") { (_a = result.exportInfo, exportInfo = _a === void 0 ? firstImportableExportInfo : _a, moduleSpecifier = result.moduleSpecifier); } - var isDefaultExport = exportInfo.exportKind === 1 /* Default */; + var isDefaultExport = exportInfo.exportKind === 1 /* ExportKind.Default */; var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol; pushAutoImportSymbol(symbol, { - kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */, + kind: moduleSpecifier ? 32 /* SymbolOriginInfoKind.ResolvedExport */ : 4 /* SymbolOriginInfoKind.Export */, moduleSpecifier: moduleSpecifier, symbolName: symbolName, exportMapKey: exportMapKey, - exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name, + exportName: exportInfo.exportKind === 2 /* ExportKind.ExportEquals */ ? "export=" /* InternalSymbolName.ExportEquals */ : exportInfo.symbol.name, fileName: exportInfo.moduleFileName, isDefaultExport: isDefaultExport, moduleSymbol: exportInfo.moduleSymbol, @@ -135670,8 +136365,8 @@ var ts; }); }); hasUnresolvedAutoImports = context.skippedAny(); - flags |= context.resolvedAny() ? 8 /* ResolvedModuleSpecifiers */ : 0; - flags |= context.resolvedBeyondLimit() ? 16 /* ResolvedModuleSpecifiersBeyondLimit */ : 0; + flags |= context.resolvedAny() ? 8 /* CompletionInfoFlags.ResolvedModuleSpecifiers */ : 0; + flags |= context.resolvedBeyondLimit() ? 16 /* CompletionInfoFlags.ResolvedModuleSpecifiersBeyondLimit */ : 0; }); function isImportableExportInfo(info) { var moduleFile = ts.tryCast(info.moduleSymbol.valueDeclaration, ts.isSourceFile); @@ -135708,7 +136403,7 @@ var ts; return; } var displayName = getCompletionEntryDisplayNameForSymbol(member, ts.getEmitScriptTarget(compilerOptions), - /*origin*/ undefined, 0 /* ObjectPropertyDeclaration */, + /*origin*/ undefined, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (!displayName) { return; @@ -135718,8 +136413,8 @@ var ts; if (!entryProps) { return; } - var origin = __assign({ kind: 128 /* ObjectLiteralMethod */ }, entryProps); - flags |= 32 /* MayIncludeMethodSnippets */; + var origin = __assign({ kind: 128 /* SymbolOriginInfoKind.ObjectLiteralMethod */ }, entryProps); + flags |= 32 /* CompletionInfoFlags.MayIncludeMethodSnippets */; symbolToOriginInfoMap[symbols.length] = origin; symbols.push(member); }); @@ -135734,7 +136429,7 @@ var ts; `bar` will have symbol flag `Method`, `foo` will have symbol flag `Property`. */ - if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) { + if (!(symbol.flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */))) { return false; } return true; @@ -135761,27 +136456,27 @@ var ts; return result; } function isInJsxText(contextToken) { - if (contextToken.kind === 11 /* JsxText */) { + if (contextToken.kind === 11 /* SyntaxKind.JsxText */) { return true; } - if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */ && contextToken.parent) { // /**/ /> // /**/ > // - contextToken: GreaterThanToken (before cursor) // - location: JsxSelfClosingElement or JsxOpeningElement // - contextToken.parent === location - if (location === contextToken.parent && (location.kind === 280 /* JsxOpeningElement */ || location.kind === 279 /* JsxSelfClosingElement */)) { + if (location === contextToken.parent && (location.kind === 280 /* SyntaxKind.JsxOpeningElement */ || location.kind === 279 /* SyntaxKind.JsxSelfClosingElement */)) { return false; } - if (contextToken.parent.kind === 280 /* JsxOpeningElement */) { + if (contextToken.parent.kind === 280 /* SyntaxKind.JsxOpeningElement */) { //
/**/ // - contextToken: GreaterThanToken (before cursor) // - location: JSXElement // - different parents (JSXOpeningElement, JSXElement) - return location.parent.kind !== 280 /* JsxOpeningElement */; + return location.parent.kind !== 280 /* SyntaxKind.JsxOpeningElement */; } - if (contextToken.parent.kind === 281 /* JsxClosingElement */ || contextToken.parent.kind === 279 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* JsxElement */; + if (contextToken.parent.kind === 281 /* SyntaxKind.JsxClosingElement */ || contextToken.parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 278 /* SyntaxKind.JsxElement */; } } return false; @@ -135792,45 +136487,45 @@ var ts; var tokenKind = keywordForNode(contextToken); // Previous token may have been a keyword that was converted to an identifier. switch (tokenKind) { - case 27 /* CommaToken */: - return containingNodeKind === 208 /* CallExpression */ // func( a, | - || containingNodeKind === 171 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 209 /* NewExpression */ // new C(a, | - || containingNodeKind === 204 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 221 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 179 /* FunctionType */ // var x: (s: string, list| - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { x, | - case 20 /* OpenParenToken */: - return containingNodeKind === 208 /* CallExpression */ // func( | - || containingNodeKind === 171 /* Constructor */ // constructor( | - || containingNodeKind === 209 /* NewExpression */ // new C(a| - || containingNodeKind === 212 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 191 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 22 /* OpenBracketToken */: - return containingNodeKind === 204 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 176 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 162 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 141 /* ModuleKeyword */: // module | - case 142 /* NamespaceKeyword */: // namespace | - case 100 /* ImportKeyword */: // import | + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( a, | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a, | + || containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [a, | + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */ // const x = (a, | + || containingNodeKind === 179 /* SyntaxKind.FunctionType */ // var x: (s: string, list| + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { x, | + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 208 /* SyntaxKind.CallExpression */ // func( | + || containingNodeKind === 171 /* SyntaxKind.Constructor */ // constructor( | + || containingNodeKind === 209 /* SyntaxKind.NewExpression */ // new C(a| + || containingNodeKind === 212 /* SyntaxKind.ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 191 /* SyntaxKind.ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 204 /* SyntaxKind.ArrayLiteralExpression */ // [ | + || containingNodeKind === 176 /* SyntaxKind.IndexSignature */ // [ | : string ] + || containingNodeKind === 162 /* SyntaxKind.ComputedPropertyName */; // [ | /* this can become an index signature */ + case 141 /* SyntaxKind.ModuleKeyword */: // module | + case 142 /* SyntaxKind.NamespaceKeyword */: // namespace | + case 100 /* SyntaxKind.ImportKeyword */: // import | return true; - case 24 /* DotToken */: - return containingNodeKind === 261 /* ModuleDeclaration */; // module A.| - case 18 /* OpenBraceToken */: - return containingNodeKind === 257 /* ClassDeclaration */ // class A { | - || containingNodeKind === 205 /* ObjectLiteralExpression */; // const obj = { | - case 63 /* EqualsToken */: - return containingNodeKind === 254 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 221 /* BinaryExpression */; // x = a| - case 15 /* TemplateHead */: - return containingNodeKind === 223 /* TemplateExpression */; // `aa ${| - case 16 /* TemplateMiddle */: - return containingNodeKind === 233 /* TemplateSpan */; // `aa ${10} dd ${| - case 131 /* AsyncKeyword */: - return containingNodeKind === 169 /* MethodDeclaration */ // const obj = { async c|() - || containingNodeKind === 297 /* ShorthandPropertyAssignment */; // const obj = { async c| - case 41 /* AsteriskToken */: - return containingNodeKind === 169 /* MethodDeclaration */; // const obj = { * c| + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 261 /* SyntaxKind.ModuleDeclaration */; // module A.| + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ // class A { | + || containingNodeKind === 205 /* SyntaxKind.ObjectLiteralExpression */; // const obj = { | + case 63 /* SyntaxKind.EqualsToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ // const x = a| + || containingNodeKind === 221 /* SyntaxKind.BinaryExpression */; // x = a| + case 15 /* SyntaxKind.TemplateHead */: + return containingNodeKind === 223 /* SyntaxKind.TemplateExpression */; // `aa ${| + case 16 /* SyntaxKind.TemplateMiddle */: + return containingNodeKind === 233 /* SyntaxKind.TemplateSpan */; // `aa ${10} dd ${| + case 131 /* SyntaxKind.AsyncKeyword */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */ // const obj = { async c|() + || containingNodeKind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; // const obj = { async c| + case 41 /* SyntaxKind.AsteriskToken */: + return containingNodeKind === 169 /* SyntaxKind.MethodDeclaration */; // const obj = { * c| } if (isClassMemberCompletionKeyword(tokenKind)) { return true; @@ -135849,21 +136544,21 @@ var ts; function tryGetObjectTypeLiteralInTypeArgumentCompletionSymbols() { var typeLiteralNode = tryGetTypeLiteralNode(contextToken); if (!typeLiteralNode) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var intersectionTypeNode = ts.isIntersectionTypeNode(typeLiteralNode.parent) ? typeLiteralNode.parent : undefined; var containerTypeNode = intersectionTypeNode || typeLiteralNode; var containerExpectedType = getConstraintOfTypeArgumentProperty(containerTypeNode, typeChecker); if (!containerExpectedType) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; var containerActualType = typeChecker.getTypeFromTypeNode(containerTypeNode); var members = getPropertiesForCompletion(containerExpectedType, typeChecker); var existingMembers = getPropertiesForCompletion(containerActualType, typeChecker); var existingMemberEscapedNames = new ts.Set(); existingMembers.forEach(function (s) { return existingMemberEscapedNames.add(s.escapedName); }); symbols = ts.concatenate(symbols, ts.filter(members, function (s) { return !existingMemberEscapedNames.has(s.escapedName); })); - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; isNewIdentifierLocation = true; - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in object literals and object binding patterns. @@ -135875,22 +136570,22 @@ var ts; var symbolsStartIndex = symbols.length; var objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken); if (!objectLikeContainer) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from contextual/inferred/declared type. - completionKind = 0 /* ObjectPropertyDeclaration */; + completionKind = 0 /* CompletionKind.ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker); // Check completions for Object property value shorthand if (instantiatedType === undefined) { - if (objectLikeContainer.flags & 33554432 /* InWithStatement */) { - return 2 /* Fail */; + if (objectLikeContainer.flags & 33554432 /* NodeFlags.InWithStatement */) { + return 2 /* GlobalsSearch.Fail */; } isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } - var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* Completions */); + var completionsType = typeChecker.getContextualType(objectLikeContainer, 4 /* ContextFlags.Completions */); var hasStringIndexType = (completionsType || instantiatedType).getStringIndexType(); var hasNumberIndextype = (completionsType || instantiatedType).getNumberIndexType(); isNewIdentifierLocation = !!hasStringIndexType || !!hasNumberIndextype; @@ -135900,12 +136595,12 @@ var ts; // Edge case: If NumberIndexType exists if (!hasNumberIndextype) { isNonContextualObjectLiteral = true; - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } } } else { - ts.Debug.assert(objectLikeContainer.kind === 201 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 201 /* SyntaxKind.ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -135916,19 +136611,19 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 164 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || !!ts.getEffectiveTypeAnnotationNode(rootDeclaration) || rootDeclaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 164 /* SyntaxKind.Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 169 /* MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ || rootDeclaration.parent.kind === 173 /* SyntaxKind.SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } if (canGetType) { var typeForObject_1 = typeChecker.getTypeAtLocation(objectLikeContainer); if (!typeForObject_1) - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; typeMembers = typeChecker.getPropertiesOfType(typeForObject_1).filter(function (propertySymbol) { return typeChecker.isPropertyAccessible(objectLikeContainer, /*isSuper*/ false, /*writing*/ false, typeForObject_1, propertySymbol); }); @@ -135940,14 +136635,14 @@ var ts; var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)); symbols = ts.concatenate(symbols, filteredMembers); setSortTextToOptionalMember(); - if (objectLikeContainer.kind === 205 /* ObjectLiteralExpression */ + if (objectLikeContainer.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && preferences.includeCompletionsWithObjectLiteralMethodSnippets && preferences.includeCompletionsWithInsertText) { transformObjectLiteralMembersSortText(symbolsStartIndex); collectObjectLiteralMethodSymbols(filteredMembers, objectLikeContainer); } } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in import clauses and export clauses @@ -135964,38 +136659,38 @@ var ts; */ function tryGetImportOrExportClauseCompletionSymbols() { if (!contextToken) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // `import { |` or `import { a as 0, | }` or `import { type | }` - var namedImportsOrExports = contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : + var namedImportsOrExports = contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */ ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : ts.isTypeKeywordTokenOrIdentifier(contextToken) ? ts.tryCast(contextToken.parent.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We can at least offer `type` at `import { |` if (!ts.isTypeKeywordTokenOrIdentifier(contextToken)) { - keywordFilters = 8 /* TypeKeyword */; + keywordFilters = 8 /* KeywordCompletionFilters.TypeKeyword */; } // try to show exported member for imported/re-exported module - var moduleSpecifier = (namedImportsOrExports.kind === 269 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; if (!moduleSpecifier) { isNewIdentifierLocation = true; - return namedImportsOrExports.kind === 269 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; + return namedImportsOrExports.kind === 269 /* SyntaxKind.NamedImports */ ? 2 /* GlobalsSearch.Fail */ : 0 /* GlobalsSearch.Continue */; } var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) { isNewIdentifierLocation = true; - return 2 /* Fail */; + return 2 /* GlobalsSearch.Fail */; } - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; isNewIdentifierLocation = false; var exports = typeChecker.getExportsAndPropertiesOfModule(moduleSpecifierSymbol); var existing = new ts.Set(namedImportsOrExports.elements.filter(function (n) { return !isCurrentlyEditingNode(n); }).map(function (n) { return (n.propertyName || n.name).escapedText; })); - var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.has(e.escapedName); }); + var uniques = exports.filter(function (e) { return e.escapedName !== "default" /* InternalSymbolName.Default */ && !existing.has(e.escapedName); }); symbols = ts.concatenate(symbols, uniques); if (!uniques.length) { // If there's nothing else to import, don't offer `type` either - keywordFilters = 0 /* None */; + keywordFilters = 0 /* KeywordCompletionFilters.None */; } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Adds local declarations for completions in named exports: @@ -136008,14 +136703,14 @@ var ts; */ function tryGetLocalNamedExportCompletionSymbols() { var _a; - var namedExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) + var namedExports = contextToken && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || contextToken.kind === 27 /* SyntaxKind.CommaToken */) ? ts.tryCast(contextToken.parent, ts.isNamedExports) : undefined; if (!namedExports) { - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; } var localsContainer = ts.findAncestor(namedExports, ts.or(ts.isSourceFile, ts.isModuleDeclaration)); - completionKind = 5 /* None */; + completionKind = 5 /* CompletionKind.None */; isNewIdentifierLocation = false; (_a = localsContainer.locals) === null || _a === void 0 ? void 0 : _a.forEach(function (symbol, name) { var _a, _b; @@ -136024,7 +136719,7 @@ var ts; symbolToSortTextMap[ts.getSymbolId(symbol)] = Completions.SortText.OptionalMember; } }); - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } /** * Aggregates relevant symbols for completion in class declaration @@ -136033,48 +136728,48 @@ var ts; function tryGetClassLikeCompletionSymbols() { var decl = tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position); if (!decl) - return 0 /* Continue */; + return 0 /* GlobalsSearch.Continue */; // We're looking up possible property names from parent type. - completionKind = 3 /* MemberLike */; + completionKind = 3 /* CompletionKind.MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : - ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; + keywordFilters = contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ ? 0 /* KeywordCompletionFilters.None */ : + ts.isClassLike(decl) ? 2 /* KeywordCompletionFilters.ClassElementKeywords */ : 3 /* KeywordCompletionFilters.InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) - return 1 /* Success */; - var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; - var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* None */; + return 1 /* GlobalsSearch.Success */; + var classElement = contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; + var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getEffectiveModifierFlags(classElement) : 0 /* ModifierFlags.None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 79 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 79 /* SyntaxKind.Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": - classElementModifierFlags = classElementModifierFlags | 8 /* Private */; + classElementModifierFlags = classElementModifierFlags | 8 /* ModifierFlags.Private */; break; case "static": - classElementModifierFlags = classElementModifierFlags | 32 /* Static */; + classElementModifierFlags = classElementModifierFlags | 32 /* ModifierFlags.Static */; break; case "override": - classElementModifierFlags = classElementModifierFlags | 16384 /* Override */; + classElementModifierFlags = classElementModifierFlags | 16384 /* ModifierFlags.Override */; break; } } if (ts.isClassStaticBlockDeclaration(classElement)) { - classElementModifierFlags |= 32 /* Static */; + classElementModifierFlags |= 32 /* ModifierFlags.Static */; } // No member list for private methods - if (!(classElementModifierFlags & 8 /* Private */)) { + if (!(classElementModifierFlags & 8 /* ModifierFlags.Private */)) { // List of property symbols of base type that are not private and already implemented - var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); + var baseTypeNodes = ts.isClassLike(decl) && classElementModifierFlags & 16384 /* ModifierFlags.Override */ ? ts.singleElementArray(ts.getEffectiveBaseTypeNode(decl)) : ts.getAllSuperTypeNodes(decl); var baseSymbols = ts.flatMap(baseTypeNodes, function (baseTypeNode) { var type = typeChecker.getTypeAtLocation(baseTypeNode); - return classElementModifierFlags & 32 /* Static */ ? + return classElementModifierFlags & 32 /* ModifierFlags.Static */ ? (type === null || type === void 0 ? void 0 : type.symbol) && typeChecker.getPropertiesOfType(typeChecker.getTypeOfSymbolAtLocation(type.symbol, decl)) : type && typeChecker.getPropertiesOfType(type); }); symbols = ts.concatenate(symbols, filterClassMembersList(baseSymbols, decl.members, classElementModifierFlags)); } - return 1 /* Success */; + return 1 /* GlobalsSearch.Success */; } function isConstructorParameterCompletion(node) { return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent) @@ -136088,8 +136783,8 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 20 /* OpenParenToken */: - case 27 /* CommaToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 27 /* SyntaxKind.CommaToken */: return ts.isConstructorDeclaration(contextToken.parent) ? contextToken.parent : undefined; default: if (isConstructorParameterCompletion(contextToken)) { @@ -136119,23 +136814,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 31 /* GreaterThanToken */: // End of a type argument list - case 30 /* LessThanSlashToken */: - case 43 /* SlashToken */: - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: - case 286 /* JsxAttributes */: - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 279 /* JsxSelfClosingElement */ || parent.kind === 280 /* JsxOpeningElement */)) { - if (contextToken.kind === 31 /* GreaterThanToken */) { + case 31 /* SyntaxKind.GreaterThanToken */: // End of a type argument list + case 30 /* SyntaxKind.LessThanSlashToken */: + case 43 /* SyntaxKind.SlashToken */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 286 /* SyntaxKind.JsxAttributes */: + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + if (parent && (parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || parent.kind === 280 /* SyntaxKind.JsxOpeningElement */)) { + if (contextToken.kind === 31 /* SyntaxKind.GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SyntaxKind.SlashToken */)) break; } return parent; } - else if (parent.kind === 285 /* JsxAttribute */) { + else if (parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136146,8 +136841,8 @@ var ts; // The context token is the closing } or " of an attribute, which means // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement - case 10 /* StringLiteral */: - if (parent && ((parent.kind === 285 /* JsxAttribute */) || (parent.kind === 287 /* JsxSpreadAttribute */))) { + case 10 /* SyntaxKind.StringLiteral */: + if (parent && ((parent.kind === 285 /* SyntaxKind.JsxAttribute */) || (parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136155,10 +136850,10 @@ var ts; return parent.parent.parent; } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (parent && - parent.kind === 288 /* JsxExpression */ && - parent.parent && parent.parent.kind === 285 /* JsxAttribute */) { + parent.kind === 288 /* SyntaxKind.JsxExpression */ && + parent.parent && parent.parent.kind === 285 /* SyntaxKind.JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136166,7 +136861,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 287 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -136185,75 +136880,75 @@ var ts; var parent = contextToken.parent; var containingNodeKind = parent.kind; switch (contextToken.kind) { - case 27 /* CommaToken */: - return containingNodeKind === 254 /* VariableDeclaration */ || + case 27 /* SyntaxKind.CommaToken */: + return containingNodeKind === 254 /* SyntaxKind.VariableDeclaration */ || isVariableDeclarationListButNotTypeArgument(contextToken) || - containingNodeKind === 237 /* VariableStatement */ || - containingNodeKind === 260 /* EnumDeclaration */ || // enum a { foo, | + containingNodeKind === 237 /* SyntaxKind.VariableStatement */ || + containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A= contextToken.pos); - case 24 /* DotToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [.| - case 58 /* ColonToken */: - return containingNodeKind === 203 /* BindingElement */; // var {x :html| - case 22 /* OpenBracketToken */: - return containingNodeKind === 202 /* ArrayBindingPattern */; // var [x| - case 20 /* OpenParenToken */: - return containingNodeKind === 292 /* CatchClause */ || + case 24 /* SyntaxKind.DotToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [.| + case 58 /* SyntaxKind.ColonToken */: + return containingNodeKind === 203 /* SyntaxKind.BindingElement */; // var {x :html| + case 22 /* SyntaxKind.OpenBracketToken */: + return containingNodeKind === 202 /* SyntaxKind.ArrayBindingPattern */; // var [x| + case 20 /* SyntaxKind.OpenParenToken */: + return containingNodeKind === 292 /* SyntaxKind.CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); - case 18 /* OpenBraceToken */: - return containingNodeKind === 260 /* EnumDeclaration */; // enum a { | - case 29 /* LessThanToken */: - return containingNodeKind === 257 /* ClassDeclaration */ || // class A< | - containingNodeKind === 226 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 258 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 259 /* TypeAliasDeclaration */ || // type List< | + case 18 /* SyntaxKind.OpenBraceToken */: + return containingNodeKind === 260 /* SyntaxKind.EnumDeclaration */; // enum a { | + case 29 /* SyntaxKind.LessThanToken */: + return containingNodeKind === 257 /* SyntaxKind.ClassDeclaration */ || // class A< | + containingNodeKind === 226 /* SyntaxKind.ClassExpression */ || // var C = class D< | + containingNodeKind === 258 /* SyntaxKind.InterfaceDeclaration */ || // interface A< | + containingNodeKind === 259 /* SyntaxKind.TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 124 /* StaticKeyword */: - return containingNodeKind === 167 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); - case 25 /* DotDotDotToken */: - return containingNodeKind === 164 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 202 /* ArrayBindingPattern */); // var [...z| - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - return containingNodeKind === 164 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 127 /* AsKeyword */: - return containingNodeKind === 270 /* ImportSpecifier */ || - containingNodeKind === 275 /* ExportSpecifier */ || - containingNodeKind === 268 /* NamespaceImport */; - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + return containingNodeKind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 25 /* SyntaxKind.DotDotDotToken */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ || + (!!parent.parent && parent.parent.kind === 202 /* SyntaxKind.ArrayBindingPattern */); // var [...z| + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + return containingNodeKind === 164 /* SyntaxKind.Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 127 /* SyntaxKind.AsKeyword */: + return containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ || + containingNodeKind === 275 /* SyntaxKind.ExportSpecifier */ || + containingNodeKind === 268 /* SyntaxKind.NamespaceImport */; + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 79 /* Identifier */: - if (containingNodeKind === 270 /* ImportSpecifier */ && + case 79 /* SyntaxKind.Identifier */: + if (containingNodeKind === 270 /* SyntaxKind.ImportSpecifier */ && contextToken === parent.name && contextToken.text === "type") { // import { type | } return false; } break; - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 118 /* InterfaceKeyword */: - case 98 /* FunctionKeyword */: - case 113 /* VarKeyword */: - case 100 /* ImportKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 137 /* InferKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return true; - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: // import { type foo| } - return containingNodeKind !== 270 /* ImportSpecifier */; - case 41 /* AsteriskToken */: + return containingNodeKind !== 270 /* SyntaxKind.ImportSpecifier */; + case 41 /* SyntaxKind.AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword corresponding to class member completion keyword @@ -136274,21 +136969,21 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 126 /* AbstractKeyword */: - case 84 /* ClassKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 98 /* FunctionKeyword */: - case 118 /* InterfaceKeyword */: - case 119 /* LetKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 124 /* StaticKeyword */: - case 113 /* VarKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return true; - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } // If we are inside a class declaration, and `constructor` is totally not present, @@ -136297,7 +136992,7 @@ var ts; if (ancestorClassLike && contextToken === previousToken && isPreviousPropertyDeclarationTerminated(contextToken, position)) { return false; // Don't block completions. } - var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* PropertyDeclaration */); + var ancestorPropertyDeclaraion = ts.getAncestor(contextToken.parent, 167 /* SyntaxKind.PropertyDeclaration */); // If we are inside a class declaration and typing `constructor` after property declaration... if (ancestorPropertyDeclaraion && contextToken !== previousToken @@ -136308,7 +137003,7 @@ var ts; if (isPreviousPropertyDeclarationTerminated(contextToken, previousToken.end)) { return false; // Don't block completions. } - else if (contextToken.kind !== 63 /* EqualsToken */ + else if (contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ // Should not block: `class C { blah = c/**/ }` // But should block: `class C { blah = somewhat c/**/ }` and `class C { blah: SomeType c/**/ }` && (ts.isInitializedProperty(ancestorPropertyDeclaraion) @@ -136324,22 +137019,22 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isPreviousPropertyDeclarationTerminated(contextToken, position) { - return contextToken.kind !== 63 /* EqualsToken */ && - (contextToken.kind === 26 /* SemicolonToken */ + return contextToken.kind !== 63 /* SyntaxKind.EqualsToken */ && + (contextToken.kind === 26 /* SyntaxKind.SemicolonToken */ || !ts.positionsAreOnSameLine(contextToken.end, position, sourceFile)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 171 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 171 /* SyntaxKind.Constructor */; } function isDotOfNumericLiteral(contextToken) { - if (contextToken.kind === 8 /* NumericLiteral */) { + if (contextToken.kind === 8 /* SyntaxKind.NumericLiteral */) { var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } return false; } function isVariableDeclarationListButNotTypeArgument(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && !ts.isPossiblyTypeArgumentPosition(node, sourceFile, typeChecker); } /** @@ -136357,13 +137052,13 @@ var ts; for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 296 /* PropertyAssignment */ && - m.kind !== 297 /* ShorthandPropertyAssignment */ && - m.kind !== 203 /* BindingElement */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */ && - m.kind !== 298 /* SpreadAssignment */) { + if (m.kind !== 296 /* SyntaxKind.PropertyAssignment */ && + m.kind !== 297 /* SyntaxKind.ShorthandPropertyAssignment */ && + m.kind !== 203 /* SyntaxKind.BindingElement */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */ && + m.kind !== 298 /* SyntaxKind.SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -136376,7 +137071,7 @@ var ts; } else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 79 /* Identifier */) { + if (m.propertyName.kind === 79 /* SyntaxKind.Identifier */) { existingName = m.propertyName.escapedText; } } @@ -136410,7 +137105,7 @@ var ts; function setSortTextToOptionalMember() { symbols.forEach(function (m) { var _a; - if (m.flags & 16777216 /* Optional */) { + if (m.flags & 16777216 /* SymbolFlags.Optional */) { var symbolId = ts.getSymbolId(m); symbolToSortTextMap[symbolId] = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.OptionalMember; } @@ -136435,7 +137130,7 @@ var ts; var symbolId = ts.getSymbolId(symbol); var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i]; var target = ts.getEmitScriptTarget(compilerOptions); - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* ObjectPropertyDeclaration */, + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, 0 /* CompletionKind.ObjectPropertyDeclaration */, /*jsxIdentifierExpected*/ false); if (displayName) { var originalSortText = (_a = symbolToSortTextMap[symbolId]) !== null && _a !== void 0 ? _a : Completions.SortText.LocationPriority; @@ -136454,10 +137149,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 167 /* PropertyDeclaration */ && - m.kind !== 169 /* MethodDeclaration */ && - m.kind !== 172 /* GetAccessor */ && - m.kind !== 173 /* SetAccessor */) { + if (m.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + m.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + m.kind !== 172 /* SyntaxKind.GetAccessor */ && + m.kind !== 173 /* SyntaxKind.SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -136465,11 +137160,11 @@ var ts; continue; } // Dont filter member even if the name matches if it is declared private in the list - if (ts.hasEffectiveModifier(m, 8 /* Private */)) { + if (ts.hasEffectiveModifier(m, 8 /* ModifierFlags.Private */)) { continue; } // do not filter it out if the static presence doesnt match - if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* Static */)) { + if (ts.isStatic(m) !== !!(currentClassElementModifierFlags & 32 /* ModifierFlags.Static */)) { continue; } var existingName = ts.getPropertyNameForPropertyNameNode(m.name); @@ -136480,7 +137175,7 @@ var ts; return baseSymbols.filter(function (propertySymbol) { return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && - !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && + !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* ModifierFlags.Private */) && !(propertySymbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(propertySymbol.valueDeclaration)); }); } @@ -136499,7 +137194,7 @@ var ts; if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 285 /* JsxAttribute */) { + if (attr.kind === 285 /* SyntaxKind.JsxAttribute */) { seenNames.add(attr.name.escapedText); } else if (ts.isJsxSpreadAttribute(attr)) { @@ -136522,15 +137217,15 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 18 /* OpenBraceToken */: // const x = { | - case 27 /* CommaToken */: // const x = { a: 0, | + case 18 /* SyntaxKind.OpenBraceToken */: // const x = { | + case 27 /* SyntaxKind.CommaToken */: // const x = { a: 0, | if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) { return parent; } break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -136553,12 +137248,12 @@ var ts; undefined; if (!moduleSymbol) return undefined; - var symbol = data.exportName === "export=" /* ExportEquals */ + var symbol = data.exportName === "export=" /* InternalSymbolName.ExportEquals */ ? checker.resolveExternalModuleSymbol(moduleSymbol) : checker.tryGetMemberInModuleExportsAndProperties(data.exportName, moduleSymbol); if (!symbol) return undefined; - var isDefaultExport = data.exportName === "default" /* Default */; + var isDefaultExport = data.exportName === "default" /* InternalSymbolName.Default */; symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(symbol) || symbol; return { symbol: symbol, origin: completionEntryDataToSymbolOriginInfo(data, name, moduleSymbol) }; } @@ -136567,27 +137262,27 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) + || symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierClassElementDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { - case 3 /* MemberLike */: + case 3 /* CompletionKind.MemberLike */: return undefined; - case 0 /* ObjectPropertyDeclaration */: + case 0 /* CompletionKind.ObjectPropertyDeclaration */: // TODO: GH#18169 return { name: JSON.stringify(name), needsConvertPropertyAccess: false }; - case 2 /* PropertyAccess */: - case 1 /* Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. + case 2 /* CompletionKind.PropertyAccess */: + case 1 /* CompletionKind.Global */: // For a 'this.' completion it will be in a global context, but may have a non-identifier name. // Don't add a completion for a name starting with a space. See https://github.com/Microsoft/TypeScript/pull/20547 - return name.charCodeAt(0) === 32 /* space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; - case 5 /* None */: - case 4 /* String */: + return name.charCodeAt(0) === 32 /* CharacterCodes.space */ ? undefined : { name: name, needsConvertPropertyAccess: true }; + case 5 /* CompletionKind.None */: + case 4 /* CompletionKind.String */: return validNameResult; default: ts.Debug.assertNever(kind); @@ -136597,11 +137292,11 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 81 /* FirstKeyword */; i <= 160 /* LastKeyword */; i++) { + for (var i = 81 /* SyntaxKind.FirstKeyword */; i <= 160 /* SyntaxKind.LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords }); } @@ -136610,7 +137305,7 @@ var ts; function getKeywordCompletions(keywordFilter, filterOutTsOnlyKeywords) { if (!filterOutTsOnlyKeywords) return getTypescriptKeywordCompletions(keywordFilter); - var index = keywordFilter + 8 /* Last */ + 1; + var index = keywordFilter + 8 /* KeywordCompletionFilters.Last */ + 1; return _keywordCompletions[index] || (_keywordCompletions[index] = getTypescriptKeywordCompletions(keywordFilter) .filter(function (entry) { return !isTypeScriptOnlyKeyword(ts.stringToToken(entry.name)); })); @@ -136619,30 +137314,30 @@ var ts; return _keywordCompletions[keywordFilter] || (_keywordCompletions[keywordFilter] = allKeywordsCompletions().filter(function (entry) { var kind = ts.stringToToken(entry.name); switch (keywordFilter) { - case 0 /* None */: + case 0 /* KeywordCompletionFilters.None */: return false; - case 1 /* All */: + case 1 /* KeywordCompletionFilters.All */: return isFunctionLikeBodyKeyword(kind) - || kind === 135 /* DeclareKeyword */ - || kind === 141 /* ModuleKeyword */ - || kind === 152 /* TypeKeyword */ - || kind === 142 /* NamespaceKeyword */ - || kind === 126 /* AbstractKeyword */ - || ts.isTypeKeyword(kind) && kind !== 153 /* UndefinedKeyword */; - case 5 /* FunctionLikeBodyKeywords */: + || kind === 135 /* SyntaxKind.DeclareKeyword */ + || kind === 141 /* SyntaxKind.ModuleKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ + || kind === 142 /* SyntaxKind.NamespaceKeyword */ + || kind === 126 /* SyntaxKind.AbstractKeyword */ + || ts.isTypeKeyword(kind) && kind !== 153 /* SyntaxKind.UndefinedKeyword */; + case 5 /* KeywordCompletionFilters.FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); - case 2 /* ClassElementKeywords */: + case 2 /* KeywordCompletionFilters.ClassElementKeywords */: return isClassMemberCompletionKeyword(kind); - case 3 /* InterfaceElementKeywords */: + case 3 /* KeywordCompletionFilters.InterfaceElementKeywords */: return isInterfaceOrTypeLiteralCompletionKeyword(kind); - case 4 /* ConstructorParameterKeywords */: + case 4 /* KeywordCompletionFilters.ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); - case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 85 /* ConstKeyword */; - case 7 /* TypeKeywords */: + case 6 /* KeywordCompletionFilters.TypeAssertionKeywords */: + return ts.isTypeKeyword(kind) || kind === 85 /* SyntaxKind.ConstKeyword */; + case 7 /* KeywordCompletionFilters.TypeKeywords */: return ts.isTypeKeyword(kind); - case 8 /* TypeKeyword */: - return kind === 152 /* TypeKeyword */; + case 8 /* KeywordCompletionFilters.TypeKeyword */: + return kind === 152 /* SyntaxKind.TypeKeyword */; default: return ts.Debug.assertNever(keywordFilter); } @@ -136650,64 +137345,64 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 130 /* AnyKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 135 /* DeclareKeyword */: - case 92 /* EnumKeyword */: - case 157 /* GlobalKeyword */: - case 117 /* ImplementsKeyword */: - case 137 /* InferKeyword */: - case 118 /* InterfaceKeyword */: - case 139 /* IsKeyword */: - case 140 /* KeyOfKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 143 /* NeverKeyword */: - case 147 /* NumberKeyword */: - case 148 /* ObjectKeyword */: - case 159 /* OverrideKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: - case 150 /* StringKeyword */: - case 151 /* SymbolKeyword */: - case 152 /* TypeKeyword */: - case 154 /* UniqueKeyword */: - case 155 /* UnknownKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 117 /* SyntaxKind.ImplementsKeyword */: + case 137 /* SyntaxKind.InferKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 139 /* SyntaxKind.IsKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 145 /* ReadonlyKeyword */; + return kind === 145 /* SyntaxKind.ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 126 /* AbstractKeyword */: - case 134 /* ConstructorKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 131 /* AsyncKeyword */ - || kind === 132 /* AwaitKeyword */ - || kind === 127 /* AsKeyword */ - || kind === 152 /* TypeKeyword */ + return kind === 131 /* SyntaxKind.AsyncKeyword */ + || kind === 132 /* SyntaxKind.AwaitKeyword */ + || kind === 127 /* SyntaxKind.AsKeyword */ + || kind === 152 /* SyntaxKind.TypeKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { - return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind; + return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* SyntaxKind.Unknown */ : node.kind; } function getContextualKeywords(contextToken, position) { var entries = []; @@ -136728,9 +137423,9 @@ var ts; && contextToken === parent.moduleSpecifier && tokenLine === currentLine) { entries.push({ - name: ts.tokenToString(129 /* AssertKeyword */), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + name: ts.tokenToString(129 /* SyntaxKind.AssertKeyword */), + kind: "keyword" /* ScriptElementKind.keyword */, + kindModifiers: "" /* ScriptElementKindModifier.none */, sortText: Completions.SortText.GlobalsOrKeywords, }); } @@ -136746,7 +137441,7 @@ var ts; } function getPropertiesForObjectExpression(contextualType, completionsType, obj, checker) { var hasCompletionsType = completionsType && completionsType !== contextualType; - var type = hasCompletionsType && !(completionsType.flags & 3 /* AnyOrUnknown */) + var type = hasCompletionsType && !(completionsType.flags & 3 /* TypeFlags.AnyOrUnknown */) ? checker.getUnionType([contextualType, completionsType]) : contextualType; var properties = getApparentProperties(type, obj, checker); @@ -136768,7 +137463,7 @@ var ts; if (!type.isUnion()) return type.getApparentProperties(); return checker.getAllPossiblePropertiesOfTypes(ts.filter(type.types, function (memberType) { - return !(memberType.flags & 131068 /* Primitive */ + return !(memberType.flags & 131068 /* TypeFlags.Primitive */ || checker.isArrayLikeType(memberType) || checker.isTypeInvalidDueToUnionDiscriminant(memberType, node) || ts.typeHasCallOrConstructSignatures(memberType, checker) @@ -136776,7 +137471,7 @@ var ts; })); } function containsNonPublicProperties(props) { - return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* NonPublicAccessibilityModifier */); }); + return ts.some(props, function (p) { return !!(ts.getDeclarationModifierFlagsFromSymbol(p) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */); }); } /** * Gets all properties on a type, but if that type is a union of several types, @@ -136794,15 +137489,19 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); - if (cls && !ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile)) { + if (cls && !ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile)) { return cls; } break; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { + var originalKeywordKind = location.originalKeywordKind; + if (originalKeywordKind && ts.isKeyword(originalKeywordKind)) { + return undefined; + } // class c { public prop = c| } if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { return undefined; @@ -136816,22 +137515,22 @@ var ts; if (!contextToken) return undefined; // class C { blah; constructor/**/ } and so on - if (location.kind === 134 /* ConstructorKeyword */ + if (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ // class C { blah \n constructor/**/ } || (ts.isIdentifier(contextToken) && ts.isPropertyDeclaration(contextToken.parent) && ts.isClassLike(location))) { return ts.findAncestor(contextToken, ts.isClassLike); } switch (contextToken.kind) { - case 63 /* EqualsToken */: // class c { public prop = | /* global completions */ } + case 63 /* SyntaxKind.EqualsToken */: // class c { public prop = | /* global completions */ } return undefined; - case 26 /* SemicolonToken */: // class c {getValue(): number; | } - case 19 /* CloseBraceToken */: // class c { method() { } | } + case 26 /* SyntaxKind.SemicolonToken */: // class c {getValue(): number; | } + case 19 /* SyntaxKind.CloseBraceToken */: // class c { method() { } | } // class c { method() { } b| } return isFromObjectTypeDeclaration(location) && location.parent.name === location ? location.parent.parent : ts.tryCast(location, ts.isObjectTypeDeclaration); - case 18 /* OpenBraceToken */: // class c { | - case 27 /* CommaToken */: // class c {getValue(): number, | } + case 18 /* SyntaxKind.OpenBraceToken */: // class c { | + case 27 /* SyntaxKind.CommaToken */: // class c {getValue(): number, | } return ts.tryCast(contextToken.parent, ts.isObjectTypeDeclaration); default: if (!isFromObjectTypeDeclaration(contextToken)) { @@ -136842,7 +137541,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* SyntaxKind.AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -136851,15 +137550,15 @@ var ts; return undefined; var parent = node.parent; switch (node.kind) { - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.isTypeLiteralNode(parent)) { return parent; } break; - case 26 /* SemicolonToken */: - case 27 /* CommaToken */: - case 79 /* Identifier */: - if (parent.kind === 166 /* PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { + case 26 /* SyntaxKind.SemicolonToken */: + case 27 /* SyntaxKind.CommaToken */: + case 79 /* SyntaxKind.Identifier */: + if (parent.kind === 166 /* SyntaxKind.PropertySignature */ && ts.isTypeLiteralNode(parent.parent)) { return parent.parent; } break; @@ -136876,11 +137575,11 @@ var ts; if (!t) return undefined; switch (node.kind) { - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checker.getTypeOfPropertyOfContextualType(t, node.symbol.escapedName); - case 188 /* IntersectionType */: - case 182 /* TypeLiteral */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 187 /* SyntaxKind.UnionType */: return t; } } @@ -136902,13 +137601,13 @@ var ts; return !!contextToken && ts.isPrivateIdentifier(contextToken) && !!ts.getContainingClass(contextToken); case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* SyntaxKind.LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SyntaxKind.SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); case " ": - return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SourceFile */; + return !!contextToken && ts.isImportKeyword(contextToken) && contextToken.parent.kind === 305 /* SyntaxKind.SourceFile */; default: return ts.Debug.assertNever(triggerCharacter); } @@ -136921,22 +137620,22 @@ var ts; function isProbablyGlobalType(type, sourceFile, checker) { // The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in // lib.webworker.d.ts, so checking against `self` is also a check against `window` when it exists. - var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (selfSymbol && checker.getTypeOfSymbolAtLocation(selfSymbol, sourceFile) === type) { return true; } - var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalSymbol && checker.getTypeOfSymbolAtLocation(globalSymbol, sourceFile) === type) { return true; } - var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false); if (globalThisSymbol && checker.getTypeOfSymbolAtLocation(globalThisSymbol, sourceFile) === type) { return true; } return false; } function isStaticProperty(symbol) { - return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); + return !!(symbol.valueDeclaration && ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 32 /* ModifierFlags.Static */ && ts.isClassLike(symbol.valueDeclaration.parent)); } function tryGetObjectLiteralContextualType(node, typeChecker) { var type = typeChecker.getContextualType(node); @@ -136944,7 +137643,7 @@ var ts; return type; } var parent = ts.walkUpParenthesizedExpressions(node.parent); - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && node === parent.left) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && node === parent.left) { // Object literal is assignment pattern: ({ | } = x) return typeChecker.getTypeAtLocation(parent); } @@ -136961,7 +137660,7 @@ var ts; return { isKeywordOnlyCompletion: isKeywordOnlyCompletion, keywordCompletion: keywordCompletion, - isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* TypeKeyword */), + isNewIdentifierLocation: !!(candidate || keywordCompletion === 152 /* SyntaxKind.TypeKeyword */), replacementNode: candidate && ts.rangeIsOnSingleLine(candidate, candidate.getSourceFile()) ? candidate : undefined @@ -136969,23 +137668,23 @@ var ts; function getCandidate() { var parent = contextToken.parent; if (ts.isImportEqualsDeclaration(parent)) { - keywordCompletion = contextToken.kind === 152 /* TypeKeyword */ ? undefined : 152 /* TypeKeyword */; + keywordCompletion = contextToken.kind === 152 /* SyntaxKind.TypeKeyword */ ? undefined : 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleReference) ? parent : undefined; } if (couldBeTypeOnlyImportSpecifier(parent, contextToken) && canCompleteFromNamedBindings(parent.parent)) { return parent; } if (ts.isNamedImports(parent) || ts.isNamespaceImport(parent)) { - if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* OpenBraceToken */ || - contextToken.kind === 100 /* ImportKeyword */ || - contextToken.kind === 27 /* CommaToken */)) { - keywordCompletion = 152 /* TypeKeyword */; + if (!parent.parent.isTypeOnly && (contextToken.kind === 18 /* SyntaxKind.OpenBraceToken */ || + contextToken.kind === 100 /* SyntaxKind.ImportKeyword */ || + contextToken.kind === 27 /* SyntaxKind.CommaToken */)) { + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; } if (canCompleteFromNamedBindings(parent)) { // At `import { ... } |` or `import * as Foo |`, the only possible completion is `from` - if (contextToken.kind === 19 /* CloseBraceToken */ || contextToken.kind === 79 /* Identifier */) { + if (contextToken.kind === 19 /* SyntaxKind.CloseBraceToken */ || contextToken.kind === 79 /* SyntaxKind.Identifier */) { isKeywordOnlyCompletion = true; - keywordCompletion = 156 /* FromKeyword */; + keywordCompletion = 156 /* SyntaxKind.FromKeyword */; } else { return parent.parent.parent; @@ -136995,12 +137694,12 @@ var ts; } if (ts.isImportKeyword(contextToken) && ts.isSourceFile(parent)) { // A lone import keyword with nothing following it does not parse as a statement at all - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return contextToken; } if (ts.isImportKeyword(contextToken) && ts.isImportDeclaration(parent)) { // `import s| from` - keywordCompletion = 152 /* TypeKeyword */; + keywordCompletion = 152 /* SyntaxKind.TypeKeyword */; return isModuleSpecifierMissingOrEmpty(parent.moduleSpecifier) ? parent : undefined; } return undefined; @@ -137040,8 +137739,8 @@ var ts; // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings. return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker)); function nonAliasCanBeReferencedAtTypeLocation(symbol) { - return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) || - !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && + return !!(symbol.flags & 788968 /* SymbolFlags.Type */) || checker.isUnknownSymbol(symbol) || + !!(symbol.flags & 1536 /* SymbolFlags.Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) && checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); }); } } @@ -137078,8 +137777,8 @@ var ts; var testChar = lowercaseCharacters.charCodeAt(characterIndex); if (strChar === testChar || strChar === toUpperCharCode(testChar)) { matchedFirstCharacter || (matchedFirstCharacter = prevChar === undefined || // Beginning of word - 97 /* a */ <= prevChar && prevChar <= 122 /* z */ && 65 /* A */ <= strChar && strChar <= 90 /* Z */ || // camelCase transition - prevChar === 95 /* _ */ && strChar !== 95 /* _ */); // snake_case transition + 97 /* CharacterCodes.a */ <= prevChar && prevChar <= 122 /* CharacterCodes.z */ && 65 /* CharacterCodes.A */ <= strChar && strChar <= 90 /* CharacterCodes.Z */ || // camelCase transition + prevChar === 95 /* CharacterCodes._ */ && strChar !== 95 /* CharacterCodes._ */); // snake_case transition if (matchedFirstCharacter) { characterIndex++; } @@ -137093,7 +137792,7 @@ var ts; return false; } function toUpperCharCode(charCode) { - if (97 /* a */ <= charCode && charCode <= 122 /* z */) { + if (97 /* CharacterCodes.a */ <= charCode && charCode <= 122 /* CharacterCodes.z */) { return charCode - 32; } return charCode; @@ -137123,7 +137822,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" /* none */ + kind: "none" /* HighlightSpanKind.none */ }; } function getSemanticDocumentHighlights(position, node, program, cancellationToken, sourceFilesToSearch) { @@ -137153,46 +137852,46 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 99 /* IfKeyword */: - case 91 /* ElseKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 105 /* ReturnKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 111 /* TryKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: - var tryStatement = node.kind === 83 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 111 /* SyntaxKind.TryKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: + var tryStatement = node.kind === 83 /* SyntaxKind.CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 82 /* CaseKeyword */: - case 88 /* DefaultKeyword */: { + case 82 /* SyntaxKind.CaseKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: { if (ts.isDefaultClause(node.parent) || ts.isCaseClause(node.parent)) { return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); } return undefined; } - case 81 /* BreakKeyword */: - case 86 /* ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 97 /* ForKeyword */: - case 115 /* WhileKeyword */: - case 90 /* DoKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 134 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* ConstructorKeyword */]); - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [136 /* GetKeyword */, 149 /* SetKeyword */]); - case 132 /* AwaitKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [134 /* SyntaxKind.ConstructorKeyword */]); + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */]); + case 132 /* SyntaxKind.AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 125 /* YieldKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return undefined; default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -137235,7 +137934,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -137267,16 +137966,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 249 /* SwitchStatement */: - if (statement.kind === 245 /* ContinueStatement */) { + case 249 /* SyntaxKind.SwitchStatement */: + if (statement.kind === 245 /* SyntaxKind.ContinueStatement */) { return false; } // falls through - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -137292,41 +137991,41 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration - if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { + if (modifierFlag & 128 /* ModifierFlags.Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArray(__spreadArray([], declaration.members, true), [declaration], false); } else { return container.statements; } - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return __spreadArray(__spreadArray([], container.parameters, true), (ts.isClassLike(container.parent) ? container.parent.members : []), true); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. - if (modifierFlag & (28 /* AccessibilityModifier */ | 64 /* Readonly */)) { + if (modifierFlag & (28 /* ModifierFlags.AccessibilityModifier */ | 64 /* ModifierFlags.Readonly */)) { var constructor = ts.find(container.members, ts.isConstructorDeclaration); if (constructor) { return __spreadArray(__spreadArray([], nodes, true), constructor.parameters, true); } } - else if (modifierFlag & 128 /* Abstract */) { + else if (modifierFlag & 128 /* ModifierFlags.Abstract */) { return __spreadArray(__spreadArray([], nodes, true), [container], false); } return nodes; // Syntactically invalid positions that the parser might produce anyway - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return undefined; default: ts.Debug.assertNever(container, "Invalid container kind."); @@ -137345,12 +138044,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* ForKeyword */, 115 /* WhileKeyword */, 90 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 97 /* SyntaxKind.ForKeyword */, 115 /* SyntaxKind.WhileKeyword */, 90 /* SyntaxKind.DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 240 /* DoStatement */) { + if (loopNode.kind === 240 /* SyntaxKind.DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 115 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 115 /* SyntaxKind.WhileKeyword */)) { break; } } @@ -137358,7 +138057,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */, 86 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */, 86 /* SyntaxKind.ContinueKeyword */); } }); return keywords; @@ -137367,13 +138066,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -137381,13 +138080,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 107 /* SyntaxKind.SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 82 /* CaseKeyword */, 88 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 82 /* SyntaxKind.CaseKeyword */, 88 /* SyntaxKind.DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 81 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 81 /* SyntaxKind.BreakKeyword */); } }); }); @@ -137395,13 +138094,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 111 /* SyntaxKind.TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 83 /* SyntaxKind.CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 96 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 96 /* SyntaxKind.FinallyKeyword */); } return keywords; } @@ -137412,13 +138111,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); } return keywords; @@ -137430,11 +138129,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 105 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 105 /* SyntaxKind.ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 109 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 109 /* SyntaxKind.ThrowKeyword */, sourceFile)); }); return keywords; } @@ -137446,13 +138145,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 131 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 131 /* SyntaxKind.AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 132 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 132 /* SyntaxKind.AwaitKeyword */); } }); }); @@ -137467,7 +138166,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 125 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 125 /* SyntaxKind.YieldKeyword */); } }); }); @@ -137486,7 +138185,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 91 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 91 /* SyntaxKind.ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -137501,7 +138200,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ }); i++; // skip the next keyword continue; @@ -137521,10 +138220,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 99 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 99 /* SyntaxKind.IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 91 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 91 /* SyntaxKind.ElseKeyword */)) { break; } } @@ -137590,60 +138289,64 @@ var ts; } return settingsOrHost; } - function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings)); - return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); + return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions); } - function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { - return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind); + function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { + return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ true, scriptKind, languageVersionOrOptions); } - function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) { + function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings)); - return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind); + return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions); } - function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) { - return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind); + function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind, languageVersionOrOptions) { + return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind, languageVersionOrOptions); } function getDocumentRegistryEntry(bucketEntry, scriptKind) { var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided")); - ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry); + ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:".concat(scriptKind, " and sourceFile.scriptKind: ").concat(entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind, ", !entry: ").concat(!entry)); return entry; } - function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) { + function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind, languageVersionOrOptions) { var _a, _b, _c, _d; scriptKind = ts.ensureScriptKind(fileName, scriptKind); var compilationSettings = getCompilationSettings(compilationSettingsOrHost); var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost; - var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings); - var sourceFileOptions = { - languageVersion: scriptTarget, - impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), - setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings) - }; + var scriptTarget = scriptKind === 6 /* ScriptKind.JSON */ ? 100 /* ScriptTarget.JSON */ : ts.getEmitScriptTarget(compilationSettings); + var sourceFileOptions = typeof languageVersionOrOptions === "object" ? + languageVersionOrOptions : + { + languageVersion: scriptTarget, + impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings), + setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings) + }; + sourceFileOptions.languageVersion = scriptTarget; var oldBucketCount = buckets.size; - var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); }); + var keyWithMode = getDocumentRegistryBucketKeyWithMode(key, sourceFileOptions.impliedNodeFormat); + var bucket = ts.getOrUpdate(buckets, keyWithMode, function () { return new ts.Map(); }); if (ts.tracing) { if (buckets.size > oldBucketCount) { // It is interesting, but not definitively problematic if a build requires multiple document registry buckets - // perhaps they are for two projects that don't have any overlap. // Bonus: these events can help us interpret the more interesting event below. - ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: keyWithMode }); } // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations. // If this occurs unexpectedly, the fix is likely to synchronize the project settings. // Skip .d.ts files to reduce noise (should also cover most of node_modules). var otherBucketKey = !ts.isDeclarationFileName(path) && - ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; }); + ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== keyWithMode && bucket.has(path) && bucketKey; }); if (otherBucketKey) { - ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key }); + ts.tracing.instant("session" /* tracing.Phase.Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: keyWithMode }); } } var bucketEntry = bucket.get(path); var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); if (!entry && externalCache) { - var sourceFile = externalCache.getDocument(key, path); + var sourceFile = externalCache.getDocument(keyWithMode, path); if (sourceFile) { ts.Debug.assert(acquiring); entry = { @@ -137657,7 +138360,7 @@ var ts; // Have never seen this file with these settings. Create a new source file for it. var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind); if (externalCache) { - externalCache.setDocument(key, path, sourceFile); + externalCache.setDocument(keyWithMode, path, sourceFile); } entry = { sourceFile: sourceFile, @@ -137672,7 +138375,7 @@ var ts; if (entry.sourceFile.version !== version) { entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); // TODO: GH#18217 if (externalCache) { - externalCache.setDocument(key, path, entry.sourceFile); + externalCache.setDocument(keyWithMode, path, entry.sourceFile); } } // If we're acquiring, then this is the first time this LS is asking for this document. @@ -137701,13 +138404,13 @@ var ts; } } } - function releaseDocument(fileName, compilationSettings, scriptKind) { + function releaseDocument(fileName, compilationSettings, scriptKind, impliedNodeFormat) { var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName); var key = getKeyForCompilationSettings(compilationSettings); - return releaseDocumentWithKey(path, key, scriptKind); + return releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat); } - function releaseDocumentWithKey(path, key, scriptKind) { - var bucket = ts.Debug.checkDefined(buckets.get(key)); + function releaseDocumentWithKey(path, key, scriptKind, impliedNodeFormat) { + var bucket = ts.Debug.checkDefined(buckets.get(getDocumentRegistryBucketKeyWithMode(key, impliedNodeFormat))); var bucketEntry = bucket.get(path); var entry = getDocumentRegistryEntry(bucketEntry, scriptKind); entry.languageServiceRefCount--; @@ -137751,18 +138454,21 @@ var ts; return "" + value; } if (ts.isArray(value)) { - return "[" + ((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(",")) + "]"; + return "[".concat((_a = ts.map(value, function (e) { return compilerOptionValueToString(e); })) === null || _a === void 0 ? void 0 : _a.join(","), "]"); } var str = "{"; for (var key in value) { if (ts.hasProperty(value, key)) { - str += key + ": " + compilerOptionValueToString(value[key]); + str += "".concat(key, ": ").concat(compilerOptionValueToString(value[key])); } } return str + "}"; } function getKeyForCompilationSettings(settings) { - return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|" + settings.pathsBasePath : undefined); + return ts.sourceFileAffectingCompilerOptions.map(function (option) { return compilerOptionValueToString(ts.getCompilerOptionValue(settings, option)); }).join("|") + (settings.pathsBasePath ? "|".concat(settings.pathsBasePath) : undefined); + } + function getDocumentRegistryBucketKeyWithMode(key, mode) { + return (mode ? "".concat(key, "|").concat(mode) : key); } })(ts || (ts = {})); /* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ @@ -137829,43 +138535,43 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(direct)) { handleImportCall(direct); break; } if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 254 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { var name = parent.name; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { directImports.push(name); break; } } } break; - case 79 /* Identifier */: // for 'const x = require("y"); + case 79 /* SyntaxKind.Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 265 /* ImportEqualsDeclaration */: - handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + handleNamespaceImport(direct, direct.name, ts.hasSyntacticModifier(direct, 1 /* ModifierFlags.Export */), /*alreadyAddedDirect*/ false); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); } - else if (direct.exportClause.kind === 274 /* NamespaceExport */) { + else if (direct.exportClause.kind === 274 /* SyntaxKind.NamespaceExport */) { // `export * as foo from "foo"` add to indirect uses addIndirectUser(getSourceFileLikeForImportDeclaration(direct), /** addTransitiveDependencies */ true); } @@ -137874,7 +138580,7 @@ var ts; directImports.push(direct); } break; - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: // Only check for typeof import('xyz') if (direct.isTypeOf && !direct.qualifier && isExported(direct)) { addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true); @@ -137900,14 +138606,14 @@ var ts; }); } function handleNamespaceImport(importDeclaration, name, isReExport, alreadyAddedDirect) { - if (exportKind === 2 /* ExportEquals */) { + if (exportKind === 2 /* ExportKind.ExportEquals */) { // This is a direct import, not import-as-namespace. if (!alreadyAddedDirect) directImports.push(importDeclaration); } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 305 /* SourceFile */ || sourceFileLike.kind === 261 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ || sourceFileLike.kind === 261 /* SyntaxKind.ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUser(sourceFileLike, /** addTransitiveDependencies */ true); } @@ -137929,7 +138635,7 @@ var ts; var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); if (!moduleSymbol) return; - ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* SymbolFlags.Module */)); var directImports = getDirectImports(moduleSymbol); if (directImports) { for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { @@ -137963,33 +138669,33 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 265 /* ImportEqualsDeclaration */) { + if (decl.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 79 /* Identifier */) { + if (decl.kind === 79 /* SyntaxKind.Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 200 /* ImportType */) { + if (decl.kind === 200 /* SyntaxKind.ImportType */) { if (decl.qualifier) { var firstIdentifier = ts.getFirstIdentifier(decl.qualifier); if (firstIdentifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(firstIdentifier); } } - else if (exportKind === 2 /* ExportEquals */) { + else if (exportKind === 2 /* ExportKind.ExportEquals */) { singleReferences.push(decl.argument.literal); } return; } // Ignore if there's a grammar error - if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { + if (decl.moduleSpecifier.kind !== 10 /* SyntaxKind.StringLiteral */) { return; } - if (decl.kind === 272 /* ExportDeclaration */) { + if (decl.kind === 272 /* SyntaxKind.ExportDeclaration */) { if (decl.exportClause && ts.isNamedExports(decl.exportClause)) { searchForNamedImport(decl.exportClause); } @@ -137998,12 +138704,12 @@ var ts; var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. - if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { + if (exportKind === 0 /* ExportKind.Named */ || exportKind === 1 /* ExportKind.Default */) { searchForNamedImport(namedBindings); } break; @@ -138014,7 +138720,7 @@ var ts; // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals. // If a default import has the same name as the default export, allow to rename it. // Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that. - if (name && (exportKind === 1 /* Default */ || exportKind === 2 /* ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { + if (name && (exportKind === 1 /* ExportKind.Default */ || exportKind === 2 /* ExportKind.ExportEquals */) && (!isForRename || name.escapedText === ts.symbolEscapedNameNoDefault(exportSymbol))) { var defaultImportAlias = checker.getSymbolAtLocation(name); addSearch(name, defaultImportAlias); } @@ -138026,7 +138732,7 @@ var ts; */ function handleNamespaceImportLike(importName) { // Don't rename an import that already has a different name than the export. - if (exportKind === 2 /* ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { + if (exportKind === 2 /* ExportKind.ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } @@ -138051,7 +138757,7 @@ var ts; } } else { - var localSymbol = element.kind === 275 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 275 /* SyntaxKind.ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -138060,7 +138766,7 @@ var ts; } function isNameMatch(name) { // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports - return name === exportSymbol.escapedName || exportKind !== 0 /* Named */ && name === "default" /* Default */; + return name === exportSymbol.escapedName || exportKind !== 0 /* ExportKind.Named */ && name === "default" /* InternalSymbolName.Default */; } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ @@ -138080,7 +138786,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SourceFile */) { + if ((searchSourceFile === null || searchSourceFile === void 0 ? void 0 : searchSourceFile.kind) === 305 /* SyntaxKind.SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -138128,7 +138834,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 305 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -138143,15 +138849,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 272 /* ExportDeclaration */: - case 266 /* ImportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -138176,7 +138882,7 @@ var ts; var parent = node.parent; var grandparent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 206 /* PropertyAccessExpression */) { + if (parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === parent; })) && ts.isBinaryExpression(grandparent) @@ -138189,21 +138895,21 @@ var ts; } else { var exportNode = getExportNode(parent, node); - if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* Export */)) { + if (exportNode && ts.hasSyntacticModifier(exportNode, 1 /* ModifierFlags.Export */)) { if (ts.isImportEqualsDeclaration(exportNode) && exportNode.moduleReference === node) { // We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement. if (comingFromExport) { return undefined; } var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); - return { kind: 0 /* Import */, symbol: lhsSymbol }; + return { kind: 0 /* ImportExport.Import */, symbol: lhsSymbol }; } else { return exportInfo(symbol, getExportKindForDeclaration(exportNode)); } } else if (ts.isNamespaceExport(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } // If we are in `export = a;` or `export default a;`, `parent` is the export assignment. else if (ts.isExportAssignment(parent)) { @@ -138221,24 +138927,24 @@ var ts; return getSpecialPropertyExport(grandparent, /*useLhsSymbol*/ true); } else if (ts.isJSDocTypedefTag(parent)) { - return exportInfo(symbol, 0 /* Named */); + return exportInfo(symbol, 0 /* ExportKind.Named */); } } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. if (!ex.symbol.parent) return undefined; - var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; + var exportKind = ex.isExportEquals ? 2 /* ExportKind.ExportEquals */ : 1 /* ExportKind.Default */; + return { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: ex.symbol.parent, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; switch (ts.getAssignmentDeclarationKind(node)) { - case 1 /* ExportsProperty */: - kind = 0 /* Named */; + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + kind = 0 /* ExportKind.Named */; break; - case 2 /* ModuleExports */: - kind = 2 /* ExportEquals */; + case 2 /* AssignmentDeclarationKind.ModuleExports */: + kind = 2 /* ExportKind.ExportEquals */; break; default: return undefined; @@ -138265,22 +138971,22 @@ var ts; // If `importedName` is undefined, do continue searching as the export is anonymous. // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) var importedName = ts.symbolEscapedNameNoDefault(importedSymbol); - if (importedName === undefined || importedName === "default" /* Default */ || importedName === symbol.escapedName) { - return { kind: 0 /* Import */, symbol: importedSymbol }; + if (importedName === undefined || importedName === "default" /* InternalSymbolName.Default */ || importedName === symbol.escapedName) { + return { kind: 0 /* ImportExport.Import */, symbol: importedSymbol }; } } function exportInfo(symbol, kind) { var exportInfo = getExportInfo(symbol, kind, checker); - return exportInfo && { kind: 1 /* Export */, symbol: symbol, exportInfo: exportInfo }; + return exportInfo && { kind: 1 /* ImportExport.Export */, symbol: symbol, exportInfo: exportInfo }; } // Not meant for use with export specifiers or export assignment. function getExportKindForDeclaration(node) { - return ts.hasSyntacticModifier(node, 512 /* Default */) ? 1 /* Default */ : 0 /* Named */; + return ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; } } FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; function getExportEqualsLocalSymbol(importedSymbol, checker) { - if (importedSymbol.flags & 2097152 /* Alias */) { + if (importedSymbol.flags & 2097152 /* SymbolFlags.Alias */) { return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } var decl = ts.Debug.checkDefined(importedSymbol.valueDeclaration); @@ -138310,16 +139016,16 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.assert(parent.name === node); return true; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent.parent.parent); default: return false; @@ -138349,7 +139055,7 @@ var ts; } else if (ts.isShorthandPropertyAssignment(declaration) && ts.isBinaryExpression(declaration.parent.parent) - && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* ModuleExports */) { + && ts.getAssignmentDeclarationKind(declaration.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) { return checker.getExportSpecifierLocalTargetSymbol(declaration.name); } } @@ -138360,21 +139066,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 305 /* SourceFile */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 262 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 262 /* SyntaxKind.ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 277 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* SyntaxKind.StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -138401,7 +139107,7 @@ var ts; EntryKind[EntryKind["SearchedPropertyFoundLocal"] = 4] = "SearchedPropertyFoundLocal"; })(EntryKind = FindAllReferences.EntryKind || (FindAllReferences.EntryKind = {})); function nodeEntry(node, kind) { - if (kind === void 0) { kind = 1 /* Node */; } + if (kind === void 0) { kind = 1 /* EntryKind.Node */; } return { kind: kind, node: node.name || node, @@ -138429,7 +139135,7 @@ var ts; node.parent.parent.left === node.parent ? node.parent.parent : undefined; - if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* None */) { + if (binaryExpression && ts.getAssignmentDeclarationKind(binaryExpression) !== 0 /* AssignmentDeclarationKind.None */) { return getContextNode(binaryExpression); } } @@ -138468,7 +139174,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 88 /* DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ && ts.hasSyntacticModifier(node.parent, 513 /* ModifierFlags.ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -138477,7 +139183,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -138485,28 +139191,28 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getContextNode(node.parent.parent); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; - case 275 /* ExportSpecifier */: - case 268 /* NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 267 /* ImportClause */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return { start: node.initializer, end: node.expression }; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -138547,7 +139253,7 @@ var ts; })(FindReferencesUse = FindAllReferences.FindReferencesUse || (FindAllReferences.FindReferencesUse = {})); function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); - var options = { use: 1 /* References */ }; + var options = { use: 1 /* FindReferencesUse.References */ }; var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options); var checker = program.getTypeChecker(); // Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition @@ -138564,33 +139270,33 @@ var ts; } FindAllReferences.findReferencedSymbols = findReferencedSymbols; function isDefinitionForReference(node) { - return node.kind === 88 /* DefaultKeyword */ + return node.kind === 88 /* SyntaxKind.DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - || (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); + || (node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent)); } function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); var referenceEntries; var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); - if (node.parent.kind === 206 /* PropertyAccessExpression */ - || node.parent.kind === 203 /* BindingElement */ - || node.parent.kind === 207 /* ElementAccessExpression */ - || node.kind === 106 /* SuperKeyword */) { + if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || node.parent.kind === 203 /* SyntaxKind.BindingElement */ + || node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */) { referenceEntries = entries && __spreadArray([], entries, true); } - else { - var queue = entries && __spreadArray([], entries, true); + else if (entries) { + var queue = ts.createQueue(entries); var seenNodes = new ts.Map(); - while (queue && queue.length) { - var entry = queue.shift(); + while (!queue.isEmpty()) { + var entry = queue.dequeue(); if (!ts.addToSeen(seenNodes, ts.getNodeId(entry.node))) { continue; } referenceEntries = ts.append(referenceEntries, entry); var entries_1 = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, entry.node, entry.node.pos); if (entries_1) { - queue.push.apply(queue, entries_1); + queue.enqueue.apply(queue, entries_1); } } } @@ -138599,18 +139305,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var result_2 = []; Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_2.push(nodeEntry(node)); }); return result_2; } - else if (node.kind === 106 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -138618,7 +139324,7 @@ var ts; } else { // Perform "Find all References" and retrieve only those that are implementations - return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* References */ }); + return getReferenceEntriesForNode(position, node, program, sourceFiles, cancellationToken, { implementations: true, use: 1 /* FindReferencesUse.References */ }); } } function findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, convertEntry) { @@ -138637,7 +139343,7 @@ var ts; function definitionToReferencedSymbolDefinitionInfo(def, checker, originalNode) { var info = (function () { switch (def.type) { - case 0 /* Symbol */: { + case 0 /* DefinitionKind.Symbol */: { var symbol = def.symbol; var _a = getDefinitionKindAndDisplayParts(symbol, checker, originalNode), displayParts_1 = _a.displayParts, kind_1 = _a.kind; var name_1 = displayParts_1.map(function (p) { return p.text; }).join(""); @@ -138645,32 +139351,32 @@ var ts; var node = declaration ? (ts.getNameOfDeclaration(declaration) || declaration) : originalNode; return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_1, kind: kind_1, displayParts: displayParts_1, context: getContextNode(declaration) }); } - case 1 /* Label */: { + case 1 /* DefinitionKind.Label */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "label" /* ScriptElementKind.label */, displayParts: [ts.displayPart(node.text, ts.SymbolDisplayPartKind.text)] }); } - case 2 /* Keyword */: { + case 2 /* DefinitionKind.Keyword */: { var node = def.node; var name_2 = ts.tokenToString(node.kind); - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* keyword */, displayParts: [{ text: name_2, kind: "keyword" /* keyword */ }] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: name_2, kind: "keyword" /* ScriptElementKind.keyword */, displayParts: [{ text: name_2, kind: "keyword" /* ScriptElementKind.keyword */ }] }); } - case 3 /* This */: { + case 3 /* DefinitionKind.This */: { var node = def.node; var symbol = checker.getSymbolAtLocation(node); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node).displayParts || [ts.textPart("this")]; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* variableElement */, displayParts: displayParts_2 }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: "this", kind: "var" /* ScriptElementKind.variableElement */, displayParts: displayParts_2 }); } - case 4 /* String */: { + case 4 /* DefinitionKind.String */: { var node = def.node; - return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); + return __assign(__assign({}, getFileAndTextSpanFromNode(node)), { name: node.text, kind: "var" /* ScriptElementKind.variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] }); } - case 5 /* TripleSlashReference */: { + case 5 /* DefinitionKind.TripleSlashReference */: { return { textSpan: ts.createTextSpanFromRange(def.reference), sourceFile: def.file, name: def.reference.fileName, - kind: "string" /* string */, - displayParts: [ts.displayPart("\"" + def.reference.fileName + "\"", ts.SymbolDisplayPartKind.stringLiteral)] + kind: "string" /* ScriptElementKind.string */, + displayParts: [ts.displayPart("\"".concat(def.reference.fileName, "\""), ts.SymbolDisplayPartKind.stringLiteral)] }; } default: @@ -138678,7 +139384,7 @@ var ts; } })(); var sourceFile = info.sourceFile, textSpan = info.textSpan, name = info.name, kind = info.kind, displayParts = info.displayParts, context = info.context; - return __assign({ containerKind: "" /* unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); + return __assign({ containerKind: "" /* ScriptElementKind.unknown */, containerName: "", fileName: sourceFile.fileName, kind: kind, name: name, textSpan: textSpan, displayParts: displayParts }, toContextSpan(textSpan, sourceFile, context)); } function getFileAndTextSpanFromNode(node) { var sourceFile = node.getSourceFile(); @@ -138701,19 +139407,19 @@ var ts; var referenceEntry = toReferenceEntry(entry); if (!symbol) return referenceEntry; - return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) }); + return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* EntryKind.Span */ && isDeclarationOfSymbol(entry.node, symbol) }); } function toReferenceEntry(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return __assign(__assign({}, documentSpan), { isWriteAccess: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }); } FindAllReferences.toReferenceEntry = toReferenceEntry; function entryToDocumentSpan(entry) { - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { textSpan: entry.textSpan, fileName: entry.fileName }; } else { @@ -138723,7 +139429,7 @@ var ts; } } function getPrefixAndSuffixText(entry, originalNode, checker) { - if (entry.kind !== 0 /* Span */ && ts.isIdentifier(originalNode)) { + if (entry.kind !== 0 /* EntryKind.Span */ && ts.isIdentifier(originalNode)) { var node = entry.node, kind = entry.kind; var parent = node.parent; var name = originalNode.text; @@ -138731,10 +139437,10 @@ var ts; if (isShorthandAssignment || (ts.isObjectBindingElementWithoutPropertyName(parent) && parent.name === node && parent.dotDotDotToken === undefined)) { var prefixColon = { prefixText: name + ": " }; var suffixColon = { suffixText: ": " + name }; - if (kind === 3 /* SearchedLocalFoundProperty */) { + if (kind === 3 /* EntryKind.SearchedLocalFoundProperty */) { return prefixColon; } - if (kind === 4 /* SearchedPropertyFoundLocal */) { + if (kind === 4 /* EntryKind.SearchedPropertyFoundLocal */) { return suffixColon; } // In `const o = { x }; o.x`, symbolAtLocation at `x` in `{ x }` is the property symbol. @@ -138768,12 +139474,12 @@ var ts; } function toImplementationLocation(entry, checker) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind !== 0 /* Span */) { + if (entry.kind !== 0 /* EntryKind.Span */) { var node = entry.node; return __assign(__assign({}, documentSpan), implementationKindDisplayParts(node, checker)); } else { - return __assign(__assign({}, documentSpan), { kind: "" /* unknown */, displayParts: [] }); + return __assign(__assign({}, documentSpan), { kind: "" /* ScriptElementKind.unknown */, displayParts: [] }); } } function implementationKindDisplayParts(node, checker) { @@ -138781,16 +139487,16 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return { - kind: "interface" /* interfaceElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "interface" /* ScriptElementKind.interfaceElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } - else if (node.kind === 226 /* ClassExpression */) { + else if (node.kind === 226 /* SyntaxKind.ClassExpression */) { return { - kind: "local class" /* localClassElement */, - displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] + kind: "local class" /* ScriptElementKind.localClassElement */, + displayParts: [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }; } else { @@ -138799,17 +139505,17 @@ var ts; } function toHighlightSpan(entry) { var documentSpan = entryToDocumentSpan(entry); - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* EntryKind.Span */) { return { fileName: documentSpan.fileName, span: { textSpan: documentSpan.textSpan, - kind: "reference" /* reference */ + kind: "reference" /* HighlightSpanKind.reference */ } }; } var writeAccess = isWriteAccessForReference(entry.node); - var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, isInString: entry.kind === 2 /* StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); + var span = __assign({ textSpan: documentSpan.textSpan, kind: writeAccess ? "writtenReference" /* HighlightSpanKind.writtenReference */ : "reference" /* HighlightSpanKind.reference */, isInString: entry.kind === 2 /* EntryKind.StringLiteral */ ? true : undefined }, documentSpan.contextSpan && { contextSpan: documentSpan.contextSpan }); return { fileName: documentSpan.fileName, span: span }; } FindAllReferences.toHighlightSpan = toHighlightSpan; @@ -138824,14 +139530,14 @@ var ts; return ts.createTextSpanFromBounds(start, end); } function getTextSpanOfEntry(entry) { - return entry.kind === 0 /* Span */ ? entry.textSpan : + return entry.kind === 0 /* EntryKind.Span */ ? entry.textSpan : getTextSpan(entry.node, entry.node.getSourceFile()); } FindAllReferences.getTextSpanOfEntry = getTextSpanOfEntry; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 88 /* SyntaxKind.DefaultKeyword */ || ts.isWriteAccess(node); } /** Whether a reference, `node`, is a definition of the `target` symbol */ function isDeclarationOfSymbol(node, target) { @@ -138839,9 +139545,9 @@ var ts; if (!target) return false; var source = ts.getDeclarationFromName(node) || - (node.kind === 88 /* DefaultKeyword */ ? node.parent + (node.kind === 88 /* SyntaxKind.DefaultKeyword */ ? node.parent : ts.isLiteralComputedPropertyDeclarationName(node) ? node.parent.parent - : node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent + : node.kind === 134 /* SyntaxKind.ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent) ? node.parent.parent : undefined); var commonjsSource = source && ts.isBinaryExpression(source) ? source.left : undefined; return !!(source && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d === source || d === commonjsSource; }))); @@ -138853,50 +139559,50 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 16777216 /* Ambient */)) + if (!!(decl.flags & 16777216 /* NodeFlags.Ambient */)) return true; switch (decl.kind) { - case 221 /* BinaryExpression */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 88 /* DefaultKeyword */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 275 /* ExportSpecifier */: - case 267 /* ImportClause */: // default import - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 258 /* InterfaceDeclaration */: - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 285 /* JsxAttribute */: - case 261 /* ModuleDeclaration */: - case 264 /* NamespaceExportDeclaration */: - case 268 /* NamespaceImport */: - case 274 /* NamespaceExport */: - case 164 /* Parameter */: - case 297 /* ShorthandPropertyAssignment */: - case 259 /* TypeAliasDeclaration */: - case 163 /* TypeParameter */: + case 221 /* SyntaxKind.BinaryExpression */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: // default import + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 285 /* SyntaxKind.JsxAttribute */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 274 /* SyntaxKind.NamespaceExport */: + case 164 /* SyntaxKind.Parameter */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return !!decl.body; - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 168 /* MethodSignature */: - case 166 /* PropertySignature */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 168 /* SyntaxKind.MethodSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -138925,7 +139631,7 @@ var ts; return undefined; } return [{ - definition: { type: 5 /* TripleSlashReference */, reference: resolvedRef.reference, file: node }, + definition: { type: 5 /* DefinitionKind.TripleSlashReference */, reference: resolvedRef.reference, file: node }, references: getReferencesForNonModule(resolvedRef.file, fileIncludeReasons, program) || ts.emptyArray }]; } @@ -138947,7 +139653,7 @@ var ts; var referencedFileName = (_b = (_a = node.getSourceFile().resolvedModules) === null || _a === void 0 ? void 0 : _a.get(node.text, ts.getModeForUsageLocation(node.getSourceFile(), node))) === null || _b === void 0 ? void 0 : _b.resolvedFileName; var referencedFile = referencedFileName ? program.getSourceFile(referencedFileName) : undefined; if (referencedFile) { - return [{ definition: { type: 4 /* String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; + return [{ definition: { type: 4 /* DefinitionKind.String */, node: node }, references: getReferencesForNonModule(referencedFile, fileIncludeReasons, program) || ts.emptyArray }]; } // Fall through to string literal references. This is not very likely to return // anything useful, but I guess it's better than nothing, and there's an existing @@ -138957,11 +139663,11 @@ var ts; } return undefined; } - if (symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { return getReferencedSymbolsForModule(program, symbol.parent, /*excludeImportTypeOfExportEquals*/ false, sourceFiles, sourceFilesSet); } var moduleReferences = getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet); - if (moduleReferences && !(symbol.flags & 33554432 /* Transient */)) { + if (moduleReferences && !(symbol.flags & 33554432 /* SymbolFlags.Transient */)) { return moduleReferences; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(node, symbol, checker); @@ -138972,10 +139678,10 @@ var ts; } Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; function getAdjustedNode(node, options) { - if (options.use === 1 /* References */) { + if (options.use === 1 /* FindReferencesUse.References */) { node = ts.getAdjustedReferenceLocation(node); } - else if (options.use === 2 /* Rename */) { + else if (options.use === 2 /* FindReferencesUse.Rename */) { node = ts.getAdjustedRenameLocation(node); } return node; @@ -139003,7 +139709,7 @@ var ts; var location = ts.getReferencedFileLocation(program.getSourceFileByPath, ref); if (ts.isReferenceFileLocation(location)) { entries = ts.append(entries, { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: referencingFile.fileName, textSpan: ts.createTextSpanFromRange(location) }); @@ -139023,10 +139729,10 @@ var ts; return undefined; } function getReferencedSymbolsForModuleIfDeclaredBySourceFile(symbol, program, sourceFiles, cancellationToken, options, sourceFilesSet) { - var moduleSourceFile = (symbol.flags & 1536 /* Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); + var moduleSourceFile = (symbol.flags & 1536 /* SymbolFlags.Module */) && symbol.declarations && ts.find(symbol.declarations, ts.isSourceFile); if (!moduleSourceFile) return undefined; - var exportEquals = symbol.exports.get("export=" /* ExportEquals */); + var exportEquals = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); // If !!exportEquals, we're about to add references to `import("mod")` anyway, so don't double-count them. var moduleReferences = getReferencedSymbolsForModule(program, symbol, !!exportEquals, sourceFiles, sourceFilesSet); if (!exportEquals || !sourceFilesSet.has(moduleSourceFile.fileName)) @@ -139053,14 +139759,14 @@ var ts; result = references; continue; } - var _loop_4 = function (entry) { - if (!entry.definition || entry.definition.type !== 0 /* Symbol */) { + var _loop_3 = function (entry) { + if (!entry.definition || entry.definition.type !== 0 /* DefinitionKind.Symbol */) { result.push(entry); return "continue"; } var symbol = entry.definition.symbol; var refIndex = ts.findIndex(result, function (ref) { return !!ref.definition && - ref.definition.type === 0 /* Symbol */ && + ref.definition.type === 0 /* DefinitionKind.Symbol */ && ref.definition.symbol === symbol; }); if (refIndex === -1) { result.push(entry); @@ -139085,13 +139791,13 @@ var ts; }; for (var _b = 0, references_2 = references; _b < references_2.length; _b++) { var entry = references_2[_b]; - _loop_4(entry); + _loop_3(entry); } } return result; } function getSourceFileIndexOfEntry(program, entry) { - var sourceFile = entry.kind === 0 /* Span */ ? + var sourceFile = entry.kind === 0 /* EntryKind.Span */ ? program.getSourceFile(entry.fileName) : entry.node.getSourceFile(); return program.getSourceFiles().indexOf(sourceFile); @@ -139112,7 +139818,7 @@ var ts; } else { return { - kind: 0 /* Span */, + kind: 0 /* EntryKind.Span */, fileName: reference.referencingFile.fileName, textSpan: ts.createTextSpanFromRange(reference.ref), }; @@ -139122,21 +139828,21 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(nodeEntry(decl.name)); } break; default: // This may be merged with something. - ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); + ts.Debug.assert(!!(symbol.flags & 33554432 /* SymbolFlags.Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); } } } - var exported = symbol.exports.get("export=" /* ExportEquals */); + var exported = symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exported === null || exported === void 0 ? void 0 : exported.declarations) { for (var _b = 0, _c = exported.declarations; _b < _c.length; _b++) { var decl = _c[_b]; @@ -139144,41 +139850,41 @@ var ts; if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : - ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 93 /* SyntaxKind.ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } } } - return references.length ? [{ definition: { type: 0 /* Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; + return references.length ? [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: symbol }, references: references }] : ts.emptyArray; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 145 /* ReadonlyKeyword */ + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 145 /* ReadonlyKeyword */; + && node.parent.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A void expression (i.e., `void foo()`) is not special, but the `void` type is. - if (node.kind === 114 /* VoidKeyword */ && ts.isVoidExpression(node.parent)) { + if (node.kind === 114 /* SyntaxKind.VoidKeyword */ && ts.isVoidExpression(node.parent)) { return undefined; } // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 145 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 145 /* SyntaxKind.ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } if (ts.isImportMeta(node.parent) && node.parent.name === node) { return getAllReferencesForImportMeta(sourceFiles, cancellationToken); } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { - return [{ definition: { type: 2 /* Keyword */, node: node }, references: [nodeEntry(node)] }]; + return [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: node }, references: [nodeEntry(node)] }]; } // Labels if (ts.isJumpStatementTarget(node)) { @@ -139194,7 +139900,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -139203,20 +139909,20 @@ var ts; function getReferencedSymbolsForSymbol(originalSymbol, node, sourceFiles, sourceFilesSet, checker, cancellationToken, options) { var symbol = node && skipPastExportOrImportSpecifierOrUnion(originalSymbol, node, checker, /*useLocalSymbolForExportSpecifier*/ !isForRenameWithPrefixAndSuffixText(options)) || originalSymbol; // Compute the meaning from the location and the symbol it references - var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* All */; + var searchMeaning = node ? getIntersectingMeaningFromDeclarations(node, symbol) : 7 /* SemanticMeaning.All */; var result = []; - var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* None */, checker, cancellationToken, searchMeaning, options, result); + var state = new State(sourceFiles, sourceFilesSet, node ? getSpecialSearchKind(node) : 0 /* SpecialSearchKind.None */, checker, cancellationToken, searchMeaning, options, result); var exportSpecifier = !isForRenameWithPrefixAndSuffixText(options) || !symbol.declarations ? undefined : ts.find(symbol.declarations, ts.isExportSpecifier); if (exportSpecifier) { // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 88 /* DefaultKeyword */ && symbol.escapedName === "default" /* Default */ && symbol.parent) { + else if (node && node.kind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.escapedName === "default" /* InternalSymbolName.Default */ && symbol.parent) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: symbol.parent, exportKind: 1 /* ExportKind.Default */ }, state); } else { - var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* FindReferencesUse.Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); getReferencesInContainerOrFiles(symbol, state, search); } return result; @@ -139239,17 +139945,17 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 171 /* Constructor */: - case 134 /* ConstructorKeyword */: - return 1 /* Constructor */; - case 79 /* Identifier */: + case 171 /* SyntaxKind.Constructor */: + case 134 /* SyntaxKind.ConstructorKeyword */: + return 1 /* SpecialSearchKind.Constructor */; + case 79 /* SyntaxKind.Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); - return 2 /* Class */; + return 2 /* SpecialSearchKind.Class */; } // falls through default: - return 0 /* None */; + return 0 /* SpecialSearchKind.None */; } } /** Handle a few special cases relating to export/import specifiers. */ @@ -139262,10 +139968,10 @@ var ts; return ts.firstDefined(symbol.declarations, function (decl) { if (!decl.parent) { // Ignore UMD module and global merge - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return undefined; // Assertions for GH#21814. We should be handling SourceFile symbols in `getReferencedSymbolsForModule` instead of getting here. - ts.Debug.fail("Unexpected symbol at " + ts.Debug.formatSyntaxKind(node.kind) + ": " + ts.Debug.formatSymbol(symbol)); + ts.Debug.fail("Unexpected symbol at ".concat(ts.Debug.formatSyntaxKind(node.kind), ": ").concat(ts.Debug.formatSymbol(symbol))); } return ts.isTypeLiteralNode(decl.parent) && ts.isUnionTypeNode(decl.parent.parent) ? checker.getPropertyOfType(checker.getTypeFromTypeNode(decl.parent.parent), symbol.name) @@ -139279,7 +139985,7 @@ var ts; SpecialSearchKind[SpecialSearchKind["Class"] = 2] = "Class"; })(SpecialSearchKind || (SpecialSearchKind = {})); function getNonModuleSymbolOfMergedModuleSymbol(symbol) { - if (!(symbol.flags & (1536 /* Module */ | 33554432 /* Transient */))) + if (!(symbol.flags & (1536 /* SymbolFlags.Module */ | 33554432 /* SymbolFlags.Transient */))) return undefined; var decl = symbol.declarations && ts.find(symbol.declarations, function (d) { return !ts.isSourceFile(d) && !ts.isModuleDeclaration(d); }); return decl && decl.symbol; @@ -139331,7 +140037,7 @@ var ts; State.prototype.getImportSearches = function (exportSymbol, exportInfo) { if (!this.importTracker) this.importTracker = FindAllReferences.createImportTracker(this.sourceFiles, this.sourceFilesSet, this.checker, this.cancellationToken); - return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* Rename */); + return this.importTracker(exportSymbol, exportInfo, this.options.use === 2 /* FindReferencesUse.Rename */); }; /** @param allSearchSymbols set of additional symbols for use by `includes`. */ State.prototype.createSearch = function (location, symbol, comingFrom, searchOptions) { @@ -139354,7 +140060,7 @@ var ts; var references = this.symbolIdToReferences[symbolId]; if (!references) { references = this.symbolIdToReferences[symbolId] = []; - this.result.push({ definition: { type: 0 /* Symbol */, symbol: searchSymbol }, references: references }); + this.result.push({ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSymbol }, references: references }); } return function (node, kind) { return references.push(nodeEntry(node, kind)); }; }; @@ -139362,7 +140068,7 @@ var ts; State.prototype.addStringOrCommentReference = function (fileName, textSpan) { this.result.push({ definition: undefined, - references: [{ kind: 0 /* Span */, fileName: fileName, textSpan: textSpan }] + references: [{ kind: 0 /* EntryKind.Span */, fileName: fileName, textSpan: textSpan }] }); }; /** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */ @@ -139393,19 +140099,19 @@ var ts; // For each import, find all references to that import in its source file. for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; - getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* Export */), state); + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* ImportExport.Export */), state); } if (indirectUsers.length) { var indirectSearch = void 0; switch (exportInfo.exportKind) { - case 0 /* Named */: - indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* Export */); + case 0 /* ExportKind.Named */: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */); break; - case 1 /* Default */: + case 1 /* ExportKind.Default */: // Search for a property access to '.default'. This can't be renamed. - indirectSearch = state.options.use === 2 /* Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* Export */, { text: "default" }); + indirectSearch = state.options.use === 2 /* FindReferencesUse.Rename */ ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* ImportExport.Export */, { text: "default" }); break; - case 2 /* ExportEquals */: + case 2 /* ExportKind.ExportEquals */: break; } if (indirectSearch) { @@ -139418,7 +140124,7 @@ var ts; } function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) { var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken); - var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; + var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences; for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) { var importLocation = importSearches_2[_i][0]; cb(importLocation); @@ -139446,13 +140152,13 @@ var ts; function shouldAddSingleReference(singleRef, state) { if (!hasMatchingMeaning(singleRef, state)) return false; - if (state.options.use !== 2 /* Rename */) + if (state.options.use !== 2 /* FindReferencesUse.Rename */) return true; // Don't rename an import type `import("./module-name")` when renaming `name` in `export = name;` if (!ts.isIdentifier(singleRef)) return false; // At `default` in `import { default as x }` or `export { default as x }`, do add a reference, but do not rename. - return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* Default */); + return !(ts.isImportOrExportSpecifier(singleRef.parent) && singleRef.escapedText === "default" /* InternalSymbolName.Default */); } // Go to the symbol we imported from and find references for it. function searchForImportedSymbol(symbol, state) { @@ -139462,7 +140168,7 @@ var ts; var declaration = _a[_i]; var exportingFile = declaration.getSourceFile(); // Need to search in the file even if it's not in the search-file set, because it might export the symbol. - getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* Import */), state, state.includesSourceFile(exportingFile)); + getReferencesInSourceFile(exportingFile, state.createSearch(declaration, symbol, 0 /* ImportExport.Import */), state, state.includesSourceFile(exportingFile)); } } /** Search for all occurrences of an identifier in a source file (and filter out the ones that match). */ @@ -139488,17 +140194,17 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 213 /* FunctionExpression */ || valueDeclaration.kind === 226 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 213 /* SyntaxKind.FunctionExpression */ || valueDeclaration.kind === 226 /* SyntaxKind.ClassExpression */)) { return valueDeclaration; } if (!declarations) { return undefined; } // If this is private property or method, the scope is the containing class - if (flags & (4 /* Property */ | 8192 /* Method */)) { - var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); + if (flags & (4 /* SymbolFlags.Property */ | 8192 /* SymbolFlags.Method */)) { + var privateDeclaration = ts.find(declarations, function (d) { return ts.hasEffectiveModifier(d, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(d); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 257 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 257 /* SyntaxKind.ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -139515,7 +140221,7 @@ var ts; - The parent is an external module: then we should only search in the module (and recurse on the export later). - But if the parent has `export as namespace`, the symbol is globally visible through that namespace. */ - var exposedByParent = parent && !(symbol.flags & 262144 /* TypeParameter */); + var exposedByParent = parent && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */); if (exposedByParent && !(ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { return undefined; } @@ -139527,7 +140233,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -139646,8 +140352,8 @@ var ts; // We found a match. Make sure it's not part of a larger word (i.e. the char // before and after it have to be a non-identifier char). var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* Latest */))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 99 /* ScriptTarget.Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 99 /* ScriptTarget.Latest */))) { // Found a real match. Keep searching. positions.push(position); } @@ -139662,27 +140368,27 @@ var ts; // Only pick labels that are either the target label, or have a target that is the target label return node === targetLabel || (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel) ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 1 /* Label */, node: targetLabel }, references: references }]; + return [{ definition: { type: 1 /* DefinitionKind.Label */, node: targetLabel }, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: if (ts.isJSDocMemberName(node.parent)) { return true; } // falls through I guess - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.text.length === searchSymbolName.length; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && str.text.length === searchSymbolName.length; } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -139698,7 +140404,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken, filter) { var references = ts.flatMap(sourceFiles, function (sourceFile) { @@ -139709,7 +140415,7 @@ var ts; } }); }); - return references.length ? [{ definition: { type: 2 /* Keyword */, node: references[0].node }, references: references }] : undefined; + return references.length ? [{ definition: { type: 2 /* DefinitionKind.Keyword */, node: references[0].node }, references: references }] : undefined; } function getReferencesInSourceFile(sourceFile, search, state, addReferencesHere) { if (addReferencesHere === void 0) { addReferencesHere = true; } @@ -139760,7 +140466,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 79 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 79 /* SyntaxKind.Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -139770,14 +140476,14 @@ var ts; return; } switch (state.specialSearchKind) { - case 0 /* None */: + case 0 /* SpecialSearchKind.None */: if (addReferencesHere) addReference(referenceLocation, relatedSymbol, state); break; - case 1 /* Constructor */: + case 1 /* SpecialSearchKind.Constructor */: addConstructorReferences(referenceLocation, sourceFile, search, state); break; - case 2 /* Class */: + case 2 /* SpecialSearchKind.Class */: addClassStaticThisReferences(referenceLocation, search, state); break; default: @@ -139785,7 +140491,7 @@ var ts; } // Use the parent symbol if the location is commonjs require syntax on javascript files only. if (ts.isInJSFile(referenceLocation) - && referenceLocation.parent.kind === 203 /* BindingElement */ + && referenceLocation.parent.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent.parent.parent)) { referenceSymbol = referenceLocation.parent.symbol; // The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In @@ -139805,7 +140511,7 @@ var ts; } if (!propertyName) { // Don't rename at `export { default } from "m";`. (but do continue to search for imports of the re-export) - if (!(state.options.use === 2 /* Rename */ && (name.escapedText === "default" /* Default */))) { + if (!(state.options.use === 2 /* FindReferencesUse.Rename */ && (name.escapedText === "default" /* InternalSymbolName.Default */))) { addRef(); } } @@ -139815,7 +140521,7 @@ var ts; if (!exportDeclaration.moduleSpecifier) { addRef(); } - if (addReferencesHere && state.options.use !== 2 /* Rename */ && state.markSeenReExportRHS(name)) { + if (addReferencesHere && state.options.use !== 2 /* FindReferencesUse.Rename */ && state.markSeenReExportRHS(name)) { addReference(name, ts.Debug.checkDefined(exportSpecifier.symbol), state); } } @@ -139826,9 +140532,9 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 88 /* DefaultKeyword */; - var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; + var isDefaultExport = referenceLocation.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */; + var exportKind = isDefaultExport ? 1 /* ExportKind.Default */ : 0 /* ExportKind.Named */; var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); if (exportInfo) { @@ -139836,7 +140542,7 @@ var ts; } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. - if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { + if (search.comingFrom !== 1 /* ImportExport.Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { var imported = state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (imported) searchForImportedSymbol(imported, state); @@ -139863,11 +140569,11 @@ var ts; } } function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { - var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* Export */); + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* ImportExport.Export */); if (!importOrExport) return; var symbol = importOrExport.symbol; - if (importOrExport.kind === 0 /* Import */) { + if (importOrExport.kind === 0 /* ImportExport.Import */) { if (!(isForRenameWithPrefixAndSuffixText(state.options))) { searchForImportedSymbol(symbol, state); } @@ -139887,14 +140593,14 @@ var ts; * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the * position of property accessing, the referenceEntry of such position will be handled in the first case. */ - if (!(flags & 33554432 /* Transient */) && name && search.includes(shorthandValueSymbol)) { + if (!(flags & 33554432 /* SymbolFlags.Transient */) && name && search.includes(shorthandValueSymbol)) { addReference(name, shorthandValueSymbol, state); } } function addReference(referenceLocation, relatedSymbol, state) { var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator // if rename symbol from default export anonymous function, for example `export default function() {}`, we do not need to add reference - if (state.options.use === 2 /* Rename */ && referenceLocation.kind === 88 /* DefaultKeyword */) { + if (state.options.use === 2 /* FindReferencesUse.Rename */ && referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */) { return; } var addRef = state.referenceAdder(symbol); @@ -139912,7 +140618,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 88 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 88 /* SyntaxKind.DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -139928,7 +140634,7 @@ var ts; function addClassStaticThisReferences(referenceLocation, search, state) { addReference(referenceLocation, search.symbol, state); var classLike = referenceLocation.parent; - if (state.options.use === 2 /* Rename */ || !ts.isClassLike(classLike)) + if (state.options.use === 2 /* FindReferencesUse.Rename */ || !ts.isClassLike(classLike)) return; ts.Debug.assert(classLike.name === referenceLocation); var addRef = state.referenceAdder(search.symbol); @@ -139939,7 +140645,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 108 /* ThisKeyword */) { + if (node.kind === 108 /* SyntaxKind.ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -139958,18 +140664,18 @@ var ts; if (constructorSymbol && constructorSymbol.declarations) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 134 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 171 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 169 /* MethodDeclaration */) { + if (decl && decl.kind === 169 /* SyntaxKind.MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 108 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 108 /* SyntaxKind.ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -139980,7 +140686,7 @@ var ts; } } function getClassConstructorSymbol(classSymbol) { - return classSymbol.members && classSymbol.members.get("__constructor" /* Constructor */); + return classSymbol.members && classSymbol.members.get("__constructor" /* InternalSymbolName.Constructor */); } /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(classDeclaration, addNode) { @@ -139990,10 +140696,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 171 /* Constructor */); + ts.Debug.assert(decl.kind === 171 /* SyntaxKind.Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 106 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 106 /* SyntaxKind.SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -140017,10 +140723,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 79 /* Identifier */) { + if (refNode.kind !== 79 /* SyntaxKind.Identifier */) { return; } - if (refNode.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -140040,7 +140746,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 235 /* Block */) { + if (body.kind === 235 /* SyntaxKind.Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -140068,13 +140774,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 204 /* ArrayLiteralExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; default: return false; @@ -140125,15 +140831,15 @@ var ts; return undefined; } // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -140142,7 +140848,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 106 /* SuperKeyword */) { + if (node.kind !== 106 /* SyntaxKind.SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -140151,46 +140857,46 @@ var ts; // and has the same static qualifier as the original 'super's owner. return container && ts.isStatic(container) === !!staticFlag && container.parent.symbol === searchSpaceNode.symbol ? nodeEntry(node) : undefined; }); - return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; + return [{ definition: { type: 0 /* DefinitionKind.Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 79 /* Identifier */ && node.parent.kind === 164 /* Parameter */ && node.parent.name === node; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.parent.kind === 164 /* SyntaxKind.Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; + var staticFlag = 32 /* ModifierFlags.Static */; switch (searchSpaceNode.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning object literals break; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: staticFlag &= ts.getSyntacticModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 305 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -140198,26 +140904,26 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 205 /* ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // Make sure the container belongs to the same class/object literals // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && ts.isStatic(container) === !!staticFlag; - case 305 /* SourceFile */: - return container.kind === 305 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 305 /* SyntaxKind.SourceFile */: + return container.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return nodeEntry(n); }); var thisParameter = ts.firstDefined(references, function (r) { return ts.isParameter(r.node.parent) ? r.node : undefined; }); return [{ - definition: { type: 3 /* This */, node: thisParameter || thisOrSuperKeyword }, + definition: { type: 3 /* DefinitionKind.This */, node: thisParameter || thisOrSuperKeyword }, references: references }]; } @@ -140230,18 +140936,18 @@ var ts; if (type) { var refType = ts.getContextualTypeFromParentOrAncestorTypeNode(ref, checker); if (type !== checker.getStringType() && type === refType) { - return nodeEntry(ref, 2 /* StringLiteral */); + return nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } else { return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined : - nodeEntry(ref, 2 /* StringLiteral */); + nodeEntry(ref, 2 /* EntryKind.StringLiteral */); } } }); }); return [{ - definition: { type: 4 /* String */, node: node }, + definition: { type: 4 /* DefinitionKind.String */, node: node }, references: references }]; } @@ -140286,30 +140992,30 @@ var ts; var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); // gets the local symbol if (shorthandValueSymbol && isForRenamePopulateSearchSymbolSet) { // When renaming 'x' in `const o = { x }`, just rename the local variable, not the property. - return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + return cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); } // If the location is in a context sensitive location (i.e. in an object literal) try // to get a contextual type for it, and add the property symbol from the contextual // type to the search set var contextualType = checker.getContextualType(containingObjectLiteralElement.parent); - var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* SearchedPropertyFoundLocal */); }); + var res_1 = contextualType && ts.firstDefined(ts.getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker, contextualType, /*unionSymbolOk*/ true), function (sym) { return fromRoot(sym, 4 /* EntryKind.SearchedPropertyFoundLocal */); }); if (res_1) return res_1; // If the location is name of property symbol from object literal destructuring pattern // Search the property symbol // for ( { property: p2 } of elems) { } var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); - var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* SearchedPropertyFoundLocal */); + var res1 = propertySymbol && cbSymbol(propertySymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 4 /* EntryKind.SearchedPropertyFoundLocal */); if (res1) return res1; - var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* SearchedLocalFoundProperty */); + var res2 = shorthandValueSymbol && cbSymbol(shorthandValueSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 3 /* EntryKind.SearchedLocalFoundProperty */); if (res2) return res2; } var aliasedSymbol = getMergedAliasedSymbolOfNamespaceExportDeclaration(location, symbol, checker); if (aliasedSymbol) { // In case of UMD module and global merging, search for global as well - var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_2 = cbSymbol(aliasedSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_2) return res_2; } @@ -140319,14 +141025,14 @@ var ts; if (symbol.valueDeclaration && ts.isParameterPropertyDeclaration(symbol.valueDeclaration, symbol.valueDeclaration.parent)) { // For a parameter property, now try on the other symbol (property if this was a parameter, parameter if this was a property). var paramProps = checker.getSymbolsOfParameterPropertyDeclaration(ts.cast(symbol.valueDeclaration, ts.isParameter), symbol.name); - ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* Property */)); // is [parameter, property] - return fromRoot(symbol.flags & 1 /* FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); + ts.Debug.assert(paramProps.length === 2 && !!(paramProps[0].flags & 1 /* SymbolFlags.FunctionScopedVariable */) && !!(paramProps[1].flags & 4 /* SymbolFlags.Property */)); // is [parameter, property] + return fromRoot(symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */ ? paramProps[1] : paramProps[0]); } - var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */); + var exportSpecifier = ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */); if (!isForRenamePopulateSearchSymbolSet || exportSpecifier && !exportSpecifier.propertyName) { var localSymbol = exportSpecifier && checker.getExportSpecifierLocalTargetSymbol(exportSpecifier); if (localSymbol) { - var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* Node */); + var res_3 = cbSymbol(localSymbol, /*rootSymbol*/ undefined, /*baseSymbol*/ undefined, 1 /* EntryKind.Node */); if (res_3) return res_3; } @@ -140341,7 +141047,7 @@ var ts; else { bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); } - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } ts.Debug.assert(isForRenamePopulateSearchSymbolSet); // due to the above assert and the arguments at the uses of this function, @@ -140349,7 +141055,7 @@ var ts; var includeOriginalSymbolOfBindingElement = onlyIncludeBindingElementAtReferenceLocation; if (includeOriginalSymbolOfBindingElement) { var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); - return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* SearchedPropertyFoundLocal */); + return bindingElementPropertySymbol && fromRoot(bindingElementPropertySymbol, 4 /* EntryKind.SearchedPropertyFoundLocal */); } function fromRoot(sym, kind) { // If this is a union property: @@ -140361,13 +141067,13 @@ var ts; return ts.firstDefined(checker.getRootSymbols(sym), function (rootSymbol) { return cbSymbol(sym, rootSymbol, /*baseSymbol*/ undefined, kind) // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */) && allowBaseTypes(rootSymbol) + || (rootSymbol.parent && rootSymbol.parent.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) && allowBaseTypes(rootSymbol) ? getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, checker, function (base) { return cbSymbol(sym, rootSymbol, base, kind); }) : undefined); }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 203 /* SyntaxKind.BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -140389,7 +141095,7 @@ var ts; // interface C extends C { // /*findRef*/propName: string; // } - if (!(symbol.flags & (32 /* Class */ | 64 /* Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) + if (!(symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) || !ts.addToSeen(seen, ts.getSymbolId(symbol))) return; return ts.firstDefined(symbol.declarations, function (declaration) { return ts.firstDefined(ts.getAllSuperTypeNodes(declaration), function (typeReference) { var type = checker.getTypeAtLocation(typeReference); @@ -140403,12 +141109,12 @@ var ts; if (!symbol.valueDeclaration) return false; var modifierFlags = ts.getEffectiveModifierFlags(symbol.valueDeclaration); - return !!(modifierFlags & 32 /* Static */); + return !!(modifierFlags & 32 /* ModifierFlags.Static */); } function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { var checker = state.checker; return forEachRelatedSymbol(referenceSymbol, referenceLocation, checker, /*isForRenamePopulateSearchSymbolSet*/ false, - /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { + /*onlyIncludeBindingElementAtReferenceLocation*/ state.options.use !== 2 /* FindReferencesUse.Rename */ || !!state.options.providePrefixAndSuffixTextForRename, function (sym, rootSymbol, baseSymbol, kind) { // check whether the symbol used to search itself is just the searched one. if (baseSymbol) { // static method/property and instance method/property might have the same name. Only check static or only check instance. @@ -140418,7 +141124,7 @@ var ts; } return search.includes(baseSymbol || rootSymbol || sym) // For a base type, use the symbol for the derived type. For a synthetic (e.g. union) property, use the union symbol. - ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* Synthetic */) ? rootSymbol : sym, kind: kind } + ? { symbol: rootSymbol && !(ts.getCheckFlags(sym) & 6 /* CheckFlags.Synthetic */) ? rootSymbol : sym, kind: kind } : undefined; }, /*allowBaseTypes*/ function (rootSymbol) { @@ -140458,7 +141164,7 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : (ts.isVariableLike(node) ? ts.hasInitializer(node) : ts.isFunctionLikeDeclaration(node) ? !!node.body : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); @@ -140469,7 +141175,7 @@ var ts; if (shorthandSymbol) { for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { + if (ts.getMeaningFromDeclaration(declaration) & 1 /* SemanticMeaning.Value */) { addReference(declaration); } } @@ -140498,12 +141204,12 @@ var ts; var propertyAccessExpression = ts.isRightSideOfPropertyAccess(location) ? location.parent : undefined; var lhsType = propertyAccessExpression && checker.getTypeAtLocation(propertyAccessExpression.expression); var res = ts.mapDefined(lhsType && (lhsType.isUnionOrIntersection() ? lhsType.types : lhsType.symbol === symbol.parent ? undefined : [lhsType]), function (t) { - return t.symbol && t.symbol.flags & (32 /* Class */ | 64 /* Interface */) ? t.symbol : undefined; + return t.symbol && t.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */) ? t.symbol : undefined; }); return res.length === 0 ? undefined : res; } function isForRenameWithPrefixAndSuffixText(options) { - return options.use === 2 /* Rename */ && options.providePrefixAndSuffixTextForRename; + return options.use === 2 /* FindReferencesUse.Rename */ && options.providePrefixAndSuffixTextForRename; } })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); @@ -140523,7 +141229,7 @@ var ts; && ts.isVariableDeclaration(node.parent) && node === node.parent.initializer && ts.isIdentifier(node.parent.name) - && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* Const */); + && !!(ts.getCombinedNodeFlags(node.parent) & 2 /* NodeFlags.Const */); } /** * Indicates whether a node could possibly be a call hierarchy declaration. @@ -140572,7 +141278,7 @@ var ts; return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { - return node.kind === 88 /* DefaultKeyword */; + return node.kind === 88 /* SyntaxKind.DefaultKeyword */; } /** Gets the symbol for a call hierarchy declaration. */ function getSymbolOfCallHierarchyDeclaration(typeChecker, node) { @@ -140596,8 +141302,8 @@ var ts; var end = pos + 6; /* "static".length */ var typeChecker = program.getTypeChecker(); var symbol = typeChecker.getSymbolAtLocation(node.parent); - var prefix = symbol ? typeChecker.symbolToString(symbol, node.parent) + " " : ""; - return { text: prefix + "static {}", pos: pos, end: end }; + var prefix = symbol ? "".concat(typeChecker.symbolToString(symbol, node.parent), " ") : ""; + return { text: "".concat(prefix, "static {}"), pos: pos, end: end }; } var declName = isConstNamedExpression(node) ? node.parent.name : ts.Debug.checkDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name"); @@ -140617,7 +141323,7 @@ var ts; if (text === undefined) { // get the text from printing the node on a single line without comments... var printer_1 = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); - text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* Unspecified */, node, node.getSourceFile(), writer); }); + text = ts.usingSingleLineStringWriter(function (writer) { return printer_1.writeNode(4 /* EmitHint.Unspecified */, node, node.getSourceFile(), writer); }); } return { text: text, pos: declName.getStart(), end: declName.getEnd() }; } @@ -140630,16 +141336,16 @@ var ts; return; } switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return (_a = ts.getAssignedName(node.parent)) === null || _a === void 0 ? void 0 : _a.getText(); } return (_b = ts.getNameOfDeclaration(node.parent)) === null || _b === void 0 ? void 0 : _b.getText(); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: if (ts.isModuleBlock(node.parent) && ts.isIdentifier(node.parent.parent.name)) { return node.parent.parent.name.getText(); } @@ -140666,8 +141372,8 @@ var ts; var declarations; if (symbol && symbol.declarations) { var indices = ts.indicesOf(symbol.declarations); - var keys_1 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); }); - indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_1[a].file, keys_1[b].file) || keys_1[a].pos - keys_1[b].pos; }); + var keys_2 = ts.map(symbol.declarations, function (decl) { return ({ file: decl.getSourceFile().fileName, pos: decl.pos }); }); + indices.sort(function (a, b) { return ts.compareStringsCaseSensitive(keys_2[a].file, keys_2[b].file) || keys_2[a].pos - keys_2[b].pos; }); var sortedDeclarations = ts.map(indices, function (i) { return symbol.declarations[i]; }); var lastDecl = void 0; for (var _i = 0, sortedDeclarations_1 = sortedDeclarations; _i < sortedDeclarations_1.length; _i++) { @@ -140737,7 +141443,7 @@ var ts; } return undefined; } - if (location.kind === 124 /* StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { + if (location.kind === 124 /* SyntaxKind.StaticKeyword */ && ts.isClassStaticBlockDeclaration(location.parent)) { location = location.parent; continue; } @@ -140748,7 +141454,7 @@ var ts; if (!followingSymbol) { var symbol = typeChecker.getSymbolAtLocation(location); if (symbol) { - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = typeChecker.getAliasedSymbol(symbol); } if (symbol.valueDeclaration) { @@ -140778,7 +141484,7 @@ var ts; return x !== undefined; } function convertEntryToCallSite(entry) { - if (entry.kind === 1 /* Node */) { + if (entry.kind === 1 /* FindAllReferences.EntryKind.Node */) { var node = entry.node; if (ts.isCallOrNewExpressionTarget(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) || ts.isTaggedTemplateTag(node, /*includeElementAccess*/ true, /*skipPastOuterExpressions*/ true) @@ -140808,7 +141514,7 @@ var ts; return []; } var location = getCallHierarchyDeclarationReferenceNode(declaration); - var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* References */ }, convertEntryToCallSite), isDefined); + var calls = ts.filter(ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, program.getSourceFiles(), location, /*position*/ 0, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, convertEntryToCallSite), isDefined); return calls ? ts.group(calls, getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToIncomingCall(program, entries); }) : []; } CallHierarchy.getIncomingCalls = getIncomingCalls; @@ -140836,7 +141542,7 @@ var ts; function collect(node) { if (!node) return; - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // do not descend into ambient nodes. return; } @@ -140853,59 +141559,59 @@ var ts; return; } switch (node.kind) { - case 79 /* Identifier */: - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 79 /* SyntaxKind.Identifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // do not descend into nodes that cannot contain callable nodes return; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: recordCallSite(node); return; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // do not descend into the type side of an assertion collect(node.expression); return; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: // do not descend into the type of a variable or parameter declaration collect(node.name); collect(node.initializer); return; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: // do not descend into the type arguments of a call expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: // do not descend into the type arguments of a new expression recordCallSite(node); collect(node.expression); ts.forEach(node.arguments, collect); return; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // do not descend into the type arguments of a tagged template expression recordCallSite(node); collect(node.tag); collect(node.template); return; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // do not descend into the type arguments of a JsxOpeningLikeElement recordCallSite(node); collect(node.tagName); collect(node.attributes); return; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: recordCallSite(node); collect(node.expression); return; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: recordCallSite(node); ts.forEachChild(node, collect); break; @@ -140922,7 +141628,7 @@ var ts; ts.forEach(node.statements, collect); } function collectCallSitesOfModuleDeclaration(node, collect) { - if (!ts.hasSyntacticModifier(node, 2 /* Ambient */) && node.body && ts.isModuleBlock(node.body)) { + if (!ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) && node.body && ts.isModuleBlock(node.body)) { ts.forEach(node.body.statements, collect); } } @@ -140963,25 +141669,25 @@ var ts; var callSites = []; var collect = createCallSiteCollector(program, callSites); switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: collectCallSitesOfSourceFile(node, collect); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: collectCallSitesOfModuleDeclaration(node, collect); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: collectCallSitesOfFunctionLikeDeclaration(program.getTypeChecker(), node, collect); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: collectCallSitesOfClassLikeDeclaration(node, collect); break; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: collectCallSitesOfClassStaticBlockDeclaration(node, collect); break; default: @@ -140997,7 +141703,7 @@ var ts; } /** Gets the call sites that call out of the provided call hierarchy declaration. */ function getOutgoingCalls(program, declaration) { - if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) { + if (declaration.flags & 16777216 /* NodeFlags.Ambient */ || ts.isMethodSignature(declaration)) { return []; } return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); }); @@ -141115,7 +141821,7 @@ var ts; } function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) { var allFiles = program.getSourceFiles(); - var _loop_5 = function (sourceFile) { + var _loop_4 = function (sourceFile) { var newFromOld = oldToNew(sourceFile.fileName); var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName; var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath); @@ -141147,7 +141853,7 @@ var ts; }; for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) { var sourceFile = allFiles_1[_i]; - _loop_5(sourceFile); + _loop_4(sourceFile); } } function combineNormal(pathA, pathB) { @@ -141252,13 +141958,13 @@ var ts; } var parent = node.parent; var typeChecker = program.getTypeChecker(); - if (node.kind === 159 /* OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { + if (node.kind === 159 /* SyntaxKind.OverrideKeyword */ || (ts.isJSDocOverrideTag(node) && ts.rangeContainsPosition(node.tagName, position))) { return getDefinitionFromOverriddenMember(typeChecker, node) || ts.emptyArray; } // Labels if (ts.isJumpStatementTarget(node)) { var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 + return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217 } if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) { var classDecl = node.parent.parent; @@ -141269,7 +141975,7 @@ var ts; return ts.map(staticBlocks, function (staticBlock) { var pos = ts.moveRangePastModifiers(staticBlock).pos; pos = ts.skipTrivia(sourceFile_1.text, pos); - return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); + return createDefinitionInfoFromName(typeChecker, staticBlock, "constructor" /* ScriptElementKind.constructorImplementationElement */, "static {}", containerName_1, /*unverified*/ false, failedAliasResolution_1, { start: pos, length: "static".length }); }); } var _d = getSymbol(node, typeChecker, stopAtAlias), symbol = _d.symbol, failedAliasResolution = _d.failedAliasResolution; @@ -141293,7 +141999,7 @@ var ts; fileName: ref.resolvedFileName, containerName: undefined, containerKind: undefined, - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, textSpan: ts.createTextSpan(0, 0), failedAliasResolution: failedAliasResolution, isAmbient: ts.isDeclarationFileName(ref.resolvedFileName), @@ -141320,7 +142026,7 @@ var ts; else { var defs = getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 106 /* SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); + return node.kind === 106 /* SyntaxKind.SuperKeyword */ ? __spreadArray([sigInfo], defs, true) : __spreadArray(__spreadArray([], defs, true), [sigInfo], false); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -141328,7 +142034,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); var definitions = (shorthandSymbol_1 === null || shorthandSymbol_1 === void 0 ? void 0 : shorthandSymbol_1.declarations) ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node, /*unverified*/ false, failedAliasResolution); }) : ts.emptyArray; return ts.concatenate(definitions, getDefinitionFromObjectLiteralElement(typeChecker, node) || ts.emptyArray); @@ -141462,12 +142168,12 @@ var ts; // If a function returns 'void' or some other type with no definition, just return the function definition. var typeDefinitions = fromReturnType && fromReturnType.length !== 0 ? fromReturnType : definitionFromType(typeAtLocation, typeChecker, node, failedAliasResolution); return typeDefinitions.length ? typeDefinitions - : !(symbol.flags & 111551 /* Value */) && symbol.flags & 788968 /* Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) + : !(symbol.flags & 111551 /* SymbolFlags.Value */) && symbol.flags & 788968 /* SymbolFlags.Type */ ? getDefinitionFromSymbol(typeChecker, ts.skipAlias(symbol, typeChecker), node, failedAliasResolution) : undefined; } GoToDefinition.getTypeDefinitionAtPosition = getTypeDefinitionAtPosition; function definitionFromType(type, checker, node, failedAliasResolution) { - return ts.flatMap(type.isUnion() && !(type.flags & 32 /* Enum */) ? type.types : [type], function (t) { + return ts.flatMap(type.isUnion() && !(type.flags & 32 /* TypeFlags.Enum */) ? type.types : [type], function (t) { return t.symbol && getDefinitionFromSymbol(checker, t.symbol, node, failedAliasResolution); }); } @@ -141511,7 +142217,7 @@ var ts; // import {A, B} from "mod"; // to jump to the implementation directly. var failedAliasResolution = false; - if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { + if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.flags & 2097152 /* SymbolFlags.Alias */ && !stopAtAlias && shouldSkipAlias(node, symbol.declarations[0])) { var aliased = checker.getAliasedSymbol(symbol); if (aliased.declarations) { return { symbol: aliased }; @@ -141528,13 +142234,13 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 79 /* Identifier */) { + if (node.kind !== 79 /* SyntaxKind.Identifier */) { return false; } if (node.parent === declaration) { return true; } - if (declaration.kind === 268 /* NamespaceImport */) { + if (declaration.kind === 268 /* SyntaxKind.NamespaceImport */) { return false; } return true; @@ -141566,7 +142272,7 @@ var ts; return "quit"; return false; }); - return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* Property */; + return !!containingAssignment && ts.getAssignmentDeclarationKind(containingAssignment) === 5 /* AssignmentDeclarationKind.Property */; } function getDefinitionFromSymbol(typeChecker, symbol, node, failedAliasResolution, excludeDeclaration) { var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== excludeDeclaration; }); @@ -141576,7 +142282,7 @@ var ts; function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* SymbolFlags.Class */ && !(symbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 134 /* SyntaxKind.ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -141616,7 +142322,7 @@ var ts; textSpan = ts.createTextSpanFromNode(name, sourceFile); } return __assign(__assign({ fileName: sourceFile.fileName, textSpan: textSpan, kind: symbolKind, name: symbolName, containerKind: undefined, // TODO: GH#18217 - containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); + containerName: containerName }, ts.FindAllReferences.toContextSpan(textSpan, sourceFile, ts.FindAllReferences.getContextNode(declaration))), { isLocal: !isDefinitionVisible(checker, declaration), isAmbient: !!(declaration.flags & 16777216 /* NodeFlags.Ambient */), unverified: unverified, failedAliasResolution: failedAliasResolution }); } function isDefinitionVisible(checker, declaration) { if (checker.isDeclarationVisible(declaration)) @@ -141628,22 +142334,22 @@ var ts; return isDefinitionVisible(checker, declaration.parent); // Handle some exceptions here like arrow function, members of class and object literal expression which are technically not visible but we want the definition to be determined by its parent switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // Private/protected properties/methods are not visible - if (ts.hasEffectiveModifier(declaration, 8 /* Private */)) + if (ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) return false; // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: return isDefinitionVisible(checker, declaration.parent); default: return false; @@ -141660,7 +142366,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script" /* scriptElement */, + kind: "script" /* ScriptElementKind.scriptElement */, name: name, containerName: undefined, containerKind: undefined, @@ -141681,9 +142387,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return true; default: return false; @@ -141789,17 +142495,17 @@ var ts; ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var jsdoc = _a[_i]; - var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 327 /* JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); }); + var inheritDoc = ts.isJSDoc(jsdoc) && jsdoc.tags && ts.find(jsdoc.tags, function (t) { return t.kind === 327 /* SyntaxKind.JSDocTag */ && (t.tagName.escapedText === "inheritDoc" || t.tagName.escapedText === "inheritdoc"); }); // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @typedefs are themselves declarations with associated comments // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation if (jsdoc.comment === undefined && !inheritDoc || ts.isJSDoc(jsdoc) - && declaration.kind !== 345 /* JSDocTypedefTag */ && declaration.kind !== 338 /* JSDocCallbackTag */ + && declaration.kind !== 345 /* SyntaxKind.JSDocTypedefTag */ && declaration.kind !== 338 /* SyntaxKind.JSDocCallbackTag */ && jsdoc.tags - && jsdoc.tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !jsdoc.tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + && jsdoc.tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !jsdoc.tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { continue; } var newparts = jsdoc.comment ? getDisplayPartsFromComment(jsdoc.comment, checker) : []; @@ -141819,11 +142525,11 @@ var ts; } function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return [declaration]; - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -141837,8 +142543,8 @@ var ts; // skip comments containing @typedefs since they're not associated with particular declarations // Exceptions: // - @param or @return indicate that the author thinks of it as a 'local' @typedef that's part of the function documentation - if (tags.some(function (t) { return t.kind === 345 /* JSDocTypedefTag */ || t.kind === 338 /* JSDocCallbackTag */; }) - && !tags.some(function (t) { return t.kind === 340 /* JSDocParameterTag */ || t.kind === 341 /* JSDocReturnTag */; })) { + if (tags.some(function (t) { return t.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || t.kind === 338 /* SyntaxKind.JSDocCallbackTag */; }) + && !tags.some(function (t) { return t.kind === 340 /* SyntaxKind.JSDocParameterTag */ || t.kind === 341 /* SyntaxKind.JSDocReturnTag */; })) { return; } for (var _i = 0, tags_1 = tags; _i < tags_1.length; _i++) { @@ -141853,17 +142559,17 @@ var ts; if (typeof comment === "string") { return [ts.textPart(comment)]; } - return ts.flatMap(comment, function (node) { return node.kind === 321 /* JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); + return ts.flatMap(comment, function (node) { return node.kind === 321 /* SyntaxKind.JSDocText */ ? [ts.textPart(node.text)] : ts.buildLinkParts(node, checker); }); } function getCommentDisplayParts(tag, checker) { var comment = tag.comment, kind = tag.kind; var namePart = getTagNameDisplayPart(kind); switch (kind) { - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return withNode(tag.class); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return withNode(tag.class); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: var templateTag = tag; var displayParts_3 = []; if (templateTag.constraint) { @@ -141877,7 +142583,7 @@ var ts; ts.forEach(templateTag.typeParameters, function (tp) { displayParts_3.push(namePart(tp.getText())); if (lastTypeParameter_1 !== tp) { - displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]); + displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]); } }); } @@ -141885,13 +142591,13 @@ var ts; displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true)); } return displayParts_3; - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return withNode(tag.typeExpression); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: - case 346 /* JSDocSeeTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: var name = tag.name; return name ? withNode(name) : comment === undefined ? undefined @@ -141918,14 +142624,14 @@ var ts; } function getTagNameDisplayPart(kind) { switch (kind) { - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return ts.parameterNamePart; - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return ts.propertyNamePart; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return ts.typeParameterNamePart; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return ts.typeAliasNamePart; default: return ts.textPart; @@ -141935,7 +142641,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword" /* keyword */, + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority, }; @@ -141946,8 +142652,8 @@ var ts; function getJSDocTagCompletions() { return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { - name: "@" + tagName, - kind: "keyword" /* keyword */, + name: "@".concat(tagName), + kind: "keyword" /* ScriptElementKind.keyword */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; @@ -141957,7 +142663,7 @@ var ts; function getJSDocTagCompletionDetails(name) { return { name: name, - kind: "" /* unknown */, + kind: "" /* ScriptElementKind.unknown */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -141983,14 +142689,14 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; + return { name: name, kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", sortText: ts.Completions.SortText.LocationPriority }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; function getJSDocParameterNameCompletionDetails(name) { return { name: name, - kind: "parameter" /* parameterElement */, + kind: "parameter" /* ScriptElementKind.parameterElement */, kindModifiers: "", displayParts: [ts.textPart(name)], documentation: ts.emptyArray, @@ -142039,8 +142745,12 @@ var ts; return undefined; } var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters, hasReturn = commentOwnerInfo.hasReturn; - var commentOwnerJSDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? ts.lastOrUndefined(commentOwner.jsDoc) : undefined; - if (commentOwner.getStart(sourceFile) < position || commentOwnerJSDoc && commentOwnerJSDoc !== existingDocComment) { + var commentOwnerJsDoc = ts.hasJSDocNodes(commentOwner) && commentOwner.jsDoc ? commentOwner.jsDoc : undefined; + var lastJsDoc = ts.lastOrUndefined(commentOwnerJsDoc); + if (commentOwner.getStart(sourceFile) < position + || lastJsDoc + && existingDocComment + && lastJsDoc !== existingDocComment) { return undefined; } var indentationStr = getIndentationStringAtPosition(sourceFile, position); @@ -142057,7 +142767,9 @@ var ts; // * if the caret was directly in front of the object, then we add an extra line and indentation. var openComment = "/**"; var closeComment = " */"; - if (tags) { + // If any of the existing jsDoc has tags, ignore adding new ones. + var hasTag = (commentOwnerJsDoc || []).some(function (jsDoc) { return !!jsDoc.tags; }); + if (tags && !hasTag) { var preamble = openComment + newLine + indentationStr + " * "; var endLine = tokenStart === position ? newLine + indentationStr : ""; var result = preamble + newLine + tags + indentationStr + closeComment + endLine; @@ -142077,37 +142789,37 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 79 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 79 /* SyntaxKind.Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; - return indentationStr + " * @param " + type + paramName + newLine; + return "".concat(indentationStr, " * @param ").concat(type).concat(paramName).concat(newLine); }).join(""); } function returnsDocComment(indentationStr, newLine) { - return indentationStr + " * @returns" + newLine; + return "".concat(indentationStr, " * @returns").concat(newLine); } function getCommentOwnerInfo(tokenAtPos, options) { return ts.forEachAncestor(tokenAtPos, function (n) { return getCommentOwnerInfoWorker(n, options); }); } function getCommentOwnerInfoWorker(commentOwner, options) { switch (commentOwner.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: var host = commentOwner; return { commentOwner: commentOwner, parameters: host.parameters, hasReturn: hasReturn(host, options) }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer, options); - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 166 /* PropertySignature */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var host_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -142117,25 +142829,25 @@ var ts; ? { commentOwner: commentOwner, parameters: host_1.parameters, hasReturn: hasReturn(host_1, options) } : { commentOwner: commentOwner }; } - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return "quit"; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 261 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 238 /* ExpressionStatement */: + return commentOwner.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 238 /* SyntaxKind.ExpressionStatement */: return getCommentOwnerInfoWorker(commentOwner.expression, options); - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var be = commentOwner; - if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { + if (ts.getAssignmentDeclarationKind(be) === 0 /* AssignmentDeclarationKind.None */) { return "quit"; } return ts.isFunctionLike(be.right) ? { commentOwner: commentOwner, parameters: be.right.parameters, hasReturn: hasReturn(be.right, options) } : { commentOwner: commentOwner }; } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: var init = commentOwner.initializer; if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { return { commentOwner: commentOwner, parameters: init.parameters, hasReturn: hasReturn(init, options) }; @@ -142148,14 +142860,14 @@ var ts; || ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; })); } function getRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 212 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return rightHandSide; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return ts.find(rightHandSide.members, ts.isConstructorDeclaration); } } @@ -142171,7 +142883,7 @@ var ts; if (!patternMatcher) return ts.emptyArray; var rawItems = []; - var _loop_6 = function (sourceFile) { + var _loop_5 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); if (excludeDtsFiles && sourceFile.isDeclarationFile) { return "continue"; @@ -142183,7 +142895,7 @@ var ts; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { var sourceFile = sourceFiles_4[_i]; - _loop_6(sourceFile); + _loop_5(sourceFile); } rawItems.sort(compareNavigateToItems); return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); @@ -142214,9 +142926,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -142226,7 +142938,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 162 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -142243,7 +142955,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 162 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -142277,7 +142989,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */, + containerKind: containerName ? ts.getNodeKind(container) : "" /* ScriptElementKind.unknown */, }; } })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); @@ -142460,7 +143172,7 @@ var ts; */ function hasNavigationBarName(node) { return !ts.hasDynamicName(node) || - (node.kind !== 221 /* BinaryExpression */ && + (node.kind !== 221 /* SyntaxKind.BinaryExpression */ && ts.isPropertyAccessExpression(node.name.expression) && ts.isIdentifier(node.name.expression.expression) && ts.idText(node.name.expression.expression) === "Symbol"); @@ -142473,7 +143185,7 @@ var ts; return; } switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -142485,25 +143197,25 @@ var ts; } } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 168 /* SyntaxKind.MethodSignature */: if (hasNavigationBarName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (hasNavigationBarName(node)) { addNodeWithRecursiveInitializer(node); } break; - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (hasNavigationBarName(node)) { addLeafNode(node); } break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -142515,7 +143227,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -142526,17 +143238,17 @@ var ts; } } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: addNodeWithRecursiveChild(node, node.name); break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: var expression = node.expression; // Use the expression as the name of the SpreadAssignment, otherwise show as . ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); break; - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: - case 254 /* VariableDeclaration */: { + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: { var child = node; if (ts.isBindingPattern(child.name)) { addChildrenRecursively(child.name); @@ -142546,7 +143258,7 @@ var ts; } break; } - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: var nameNode = node.name; // If we see a function declaration track as a possible ES5 class if (nameNode && ts.isIdentifier(nameNode)) { @@ -142554,11 +143266,11 @@ var ts; } addNodeWithRecursiveChild(node, node.body); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: startNode(node); for (var _e = 0, _f = node.members; _e < _f.length; _e++) { var member = _f[_e]; @@ -142568,9 +143280,9 @@ var ts; } endNode(); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: startNode(node); for (var _g = 0, _h = node.members; _g < _h.length; _g++) { var member = _h[_g]; @@ -142578,10 +143290,10 @@ var ts; } endNode(); break; - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression_1 = node.expression; var child = ts.isObjectLiteralExpression(expression_1) || ts.isCallExpression(expression_1) ? expression_1 : ts.isArrowFunction(expression_1) || ts.isFunctionExpression(expression_1) ? expression_1.body : undefined; @@ -142595,27 +143307,27 @@ var ts; } break; } - case 275 /* ExportSpecifier */: - case 265 /* ImportEqualsDeclaration */: - case 176 /* IndexSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 259 /* TypeAliasDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: addLeafNode(node); break; - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: addNodeWithRecursiveChild(node, node.right); return; - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: { + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; - var prototypeAccess = special === 3 /* PrototypeProperty */ ? + var prototypeAccess = special === 3 /* AssignmentDeclarationKind.PrototypeProperty */ ? assignmentTarget.expression : assignmentTarget; var depth = 0; @@ -142629,7 +143341,7 @@ var ts; else { _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; } - if (special === 6 /* Prototype */) { + if (special === 6 /* AssignmentDeclarationKind.Prototype */) { if (ts.isObjectLiteralExpression(binaryExpression.right)) { if (binaryExpression.right.properties.length > 0) { startNode(binaryExpression, className); @@ -142649,10 +143361,10 @@ var ts; endNestedNodes(depth); return; } - case 7 /* ObjectDefinePropertyValue */: - case 9 /* ObjectDefinePrototypeProperty */: { + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: { var defineCall = node; - var className = special === 7 /* ObjectDefinePropertyValue */ ? + var className = special === 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */ ? defineCall.arguments[0] : defineCall.arguments[0].expression; var memberName = defineCall.arguments[1]; @@ -142665,7 +143377,7 @@ var ts; endNestedNodes(depth); return; } - case 5 /* Property */: { + case 5 /* AssignmentDeclarationKind.Property */: { var binaryExpression = node; var assignmentTarget = binaryExpression.left; var targetFunction = assignmentTarget.expression; @@ -142683,9 +143395,9 @@ var ts; } break; } - case 4 /* ThisProperty */: - case 0 /* None */: - case 8 /* ObjectDefinePropertyExports */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: break; default: ts.Debug.assertNever(special); @@ -142741,16 +143453,16 @@ var ts; }); } var isEs5ClassMember = (_a = {}, - _a[5 /* Property */] = true, - _a[3 /* PrototypeProperty */] = true, - _a[7 /* ObjectDefinePropertyValue */] = true, - _a[9 /* ObjectDefinePrototypeProperty */] = true, - _a[0 /* None */] = false, - _a[1 /* ExportsProperty */] = false, - _a[2 /* ModuleExports */] = false, - _a[8 /* ObjectDefinePropertyExports */] = false, - _a[6 /* Prototype */] = true, - _a[4 /* ThisProperty */] = false, + _a[5 /* AssignmentDeclarationKind.Property */] = true, + _a[3 /* AssignmentDeclarationKind.PrototypeProperty */] = true, + _a[7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */] = true, + _a[9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */] = true, + _a[0 /* AssignmentDeclarationKind.None */] = false, + _a[1 /* AssignmentDeclarationKind.ExportsProperty */] = false, + _a[2 /* AssignmentDeclarationKind.ModuleExports */] = false, + _a[8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */] = false, + _a[6 /* AssignmentDeclarationKind.Prototype */] = true, + _a[4 /* AssignmentDeclarationKind.ThisProperty */] = false, _a); function tryMergeEs5Class(a, b, bIndex, parent) { function isPossibleConstructor(node) { @@ -142758,10 +143470,10 @@ var ts; } var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? ts.getAssignmentDeclarationKind(b.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? ts.getAssignmentDeclarationKind(a.node) : - 0 /* None */; + 0 /* AssignmentDeclarationKind.None */; // We treat this as an es5 class and merge the nodes in in one of several cases if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member @@ -142825,7 +143537,7 @@ var ts; } return true; } - return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + return bAssignmentDeclarationKind === 0 /* AssignmentDeclarationKind.None */ ? false : true; } function tryMerge(a, b, bIndex, parent) { // const v = false as boolean; @@ -142844,12 +143556,12 @@ var ts; return false; } switch (a.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.isStatic(a) === ts.isStatic(b); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return areSameModule(a, b) && getFullyQualifiedModuleName(a) === getFullyQualifiedModuleName(b); default: @@ -142857,7 +143569,7 @@ var ts; } } function isSynthesized(node) { - return !!(node.flags & 8 /* Synthesized */); + return !!(node.flags & 8 /* NodeFlags.Synthesized */); } // We want to merge own children like `I` in in `module A { interface I {} } module A { interface I {} }` // We don't want to merge unrelated children like `m` in `const o = { a: { m() {} }, b: { m() {} } };` @@ -142871,7 +143583,7 @@ var ts; if (!a.body || !b.body) { return a.body === b.body; } - return a.body.kind === b.body.kind && (a.body.kind !== 261 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 261 /* SyntaxKind.ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -142901,7 +143613,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); @@ -142910,53 +143622,53 @@ var ts; return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 261 /* ModuleDeclaration */) { + if (node.kind === 261 /* SyntaxKind.ModuleDeclaration */) { return cleanText(getModuleName(node)); } if (name) { var text = ts.isIdentifier(name) ? name.text - : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : ts.isElementAccessExpression(name) ? "[".concat(nodeText(name.argumentExpression), "]") : nodeText(name); if (text.length > 0) { return cleanText(text); } } switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) - ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" + ? "\"".concat(ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))), "\"") : ""; - case 271 /* ExportAssignment */: - return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + case 271 /* SyntaxKind.ExportAssignment */: + return ts.isExportAssignment(node) && node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } // We may get a string with newlines or other whitespace in the case of an object dereference // (eg: "app\n.onactivated"), so we should remove the whitespace for readability in the // navigation bar. return getFunctionOrClassName(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return "new()"; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return "()"; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return "[]"; default: return ""; @@ -142989,19 +143701,19 @@ var ts; } // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 305 /* SourceFile */: - case 259 /* TypeAliasDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return true; - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -143011,10 +143723,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 262 /* ModuleBlock */: - case 305 /* SourceFile */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 262 /* SyntaxKind.ModuleBlock */: + case 305 /* SyntaxKind.SourceFile */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: return true; default: return false; @@ -143076,7 +143788,7 @@ var ts; function getFullyQualifiedModuleName(moduleDeclaration) { // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = [ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)]; - while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -143090,13 +143802,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 162 /* ComputedPropertyName */; + return !member.name || member.name.kind === 162 /* SyntaxKind.ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 305 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 254 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -143111,7 +143823,7 @@ var ts; return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -143119,7 +143831,7 @@ var ts; return nodeText(parent.name); } // Default exports are named "default" - else if (ts.getSyntacticModifierFlags(node) & 512 /* Default */) { + else if (ts.getSyntacticModifierFlags(node) & 512 /* ModifierFlags.Default */) { return "default"; } else if (ts.isClassLike(node)) { @@ -143130,10 +143842,10 @@ var ts; if (name !== undefined) { name = cleanText(name); if (name.length > maxLength) { - return name + " callback"; + return "".concat(name, " callback"); } var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); - return name + "(" + args + ") callback"; + return "".concat(name, "(").concat(args, ") callback"); } } return ""; @@ -143146,7 +143858,7 @@ var ts; else if (ts.isPropertyAccessExpression(expr)) { var left = getCalledExpressionName(expr.expression); var right = expr.name.text; - return left === undefined ? right : left + "." + right; + return left === undefined ? right : "".concat(left, ".").concat(right); } else { return undefined; @@ -143154,9 +143866,9 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; default: return false; @@ -143270,7 +143982,7 @@ var ts; var numberOfNewLines = 0; while (scanner.getTokenPos() < endPos) { var tokenKind = scanner.scan(); - if (tokenKind === 4 /* NewLineTrivia */) { + if (tokenKind === 4 /* SyntaxKind.NewLineTrivia */) { numberOfNewLines++; if (numberOfNewLines >= 2) { return true; @@ -143288,7 +144000,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var jsxNamespace = typeChecker.getJsxNamespace(sourceFile); var jsxFragmentFactory = typeChecker.getJsxFragmentFactory(sourceFile); - var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* ContainsJsx */); + var jsxElementsPresent = !!(sourceFile.transformFlags & 2 /* TransformFlags.ContainsJsx */); var usedImports = []; for (var _i = 0, oldImports_1 = oldImports; _i < oldImports_1.length; _i++) { var importDecl = oldImports_1[_i]; @@ -143557,11 +144269,11 @@ var ts; function getModuleSpecifierExpression(declaration) { var _a; switch (declaration.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return (_a = ts.tryCast(declaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return declaration.moduleSpecifier; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return declaration.declarationList.declarations[0].initializer.arguments[0]; } } @@ -143600,19 +144312,19 @@ var ts; function getImportKindOrder(s1) { var _a; switch (s1.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!s1.importClause) return 0; if (s1.importClause.isTypeOnly) return 1; - if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* NamespaceImport */) + if (((_a = s1.importClause.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 268 /* SyntaxKind.NamespaceImport */) return 2; if (s1.importClause.name) return 3; return 4; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return 5; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return 6; } } @@ -143665,7 +144377,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 100 /* SyntaxKind.ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* OutliningSpanKind.Imports */)); } } function visitNonImportNode(n) { @@ -143673,7 +144385,7 @@ var ts; if (depthRemaining === 0) return; cancellationToken.throwIfCancellationRequested(); - if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* EndOfFileToken */) { + if (ts.isDeclaration(n) || ts.isVariableStatement(n) || ts.isReturnStatement(n) || ts.isCallOrNewExpression(n) || n.kind === 1 /* SyntaxKind.EndOfFileToken */) { addOutliningForLeadingCommentsForNode(n, sourceFile, cancellationToken, out); } if (ts.isFunctionLike(n) && ts.isBinaryExpression(n.parent) && ts.isPropertyAccessExpression(n.parent.left)) { @@ -143723,7 +144435,7 @@ var ts; } if (!result[1]) { var span = ts.createTextSpanFromBounds(sourceFile.text.indexOf("//", currentLineStart), lineEnd); - regions.push(createOutliningSpan(span, "region" /* Region */, span, /*autoCollapse*/ false, result[2] || "#region")); + regions.push(createOutliningSpan(span, "region" /* OutliningSpanKind.Region */, span, /*autoCollapse*/ false, result[2] || "#region")); } else { var region = regions.pop(); @@ -143758,7 +144470,7 @@ var ts; var _a = comments_1[_i], kind = _a.kind, pos_1 = _a.pos, end = _a.end; cancellationToken.throwIfCancellationRequested(); switch (kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: // never fold region delimiters into single-line comment regions var commentText = sourceText.slice(pos_1, end); if (isRegionDelimiter(commentText)) { @@ -143774,9 +144486,9 @@ var ts; lastSingleLineCommentEnd = end; singleLineCommentCount++; break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: combineAndAddMultipleSingleLineComments(); - out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(pos_1, end, "comment" /* OutliningSpanKind.Comment */)); singleLineCommentCount = 0; break; default: @@ -143787,7 +144499,7 @@ var ts; function combineAndAddMultipleSingleLineComments() { // Only outline spans of two or more consecutive single line comments if (singleLineCommentCount > 1) { - out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* Comment */)); + out.push(createOutliningSpanFromBounds(firstSingleLineCommentStart, lastSingleLineCommentEnd, "comment" /* OutliningSpanKind.Comment */)); } } } @@ -143801,7 +144513,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -143809,23 +144521,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 240 /* DoStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 292 /* CatchClause */: + case 240 /* SyntaxKind.DoStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 292 /* SyntaxKind.CatchClause */: return spanForNode(n.parent); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - var node = ts.findChildOfKind(tryStatement, 96 /* FinallyKeyword */, sourceFile); + var node = ts.findChildOfKind(tryStatement, 96 /* SyntaxKind.FinallyKeyword */, sourceFile); if (node) return spanForNode(node); } @@ -143833,52 +144545,52 @@ var ts; default: // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); + return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* OutliningSpanKind.Code */); } - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanForNode(n.parent); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 263 /* CaseBlock */: - case 182 /* TypeLiteral */: - case 201 /* ObjectBindingPattern */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 263 /* SyntaxKind.CaseBlock */: + case 182 /* SyntaxKind.TypeLiteral */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return spanForNode(n); - case 184 /* TupleType */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* OpenBracketToken */); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 184 /* SyntaxKind.TupleType */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isTupleTypeNode(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return spanForNodeArray(n.statements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 204 /* ArrayLiteralExpression */: - return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 278 /* JsxElement */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return spanForObjectOrArrayLiteral(n, 22 /* SyntaxKind.OpenBracketToken */); + case 278 /* SyntaxKind.JsxElement */: return spanForJSXElement(n); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return spanForJSXFragment(n); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return spanForJSXAttributes(n.attributes); - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return spanForTemplateLiteral(n); - case 202 /* ArrayBindingPattern */: - return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* OpenBracketToken */); - case 214 /* ArrowFunction */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return spanForNode(n, /*autoCollapse*/ false, /*useFullStart*/ !ts.isBindingElement(n.parent), 22 /* SyntaxKind.OpenBracketToken */); + case 214 /* SyntaxKind.ArrowFunction */: return spanForArrowFunction(n); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return spanForCallExpression(n); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanForParenthesizedExpression(n); } function spanForCallExpression(node) { if (!node.arguments.length) { return undefined; } - var openToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); - var closeToken = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + var openToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); + var closeToken = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!openToken || !closeToken || ts.positionsAreOnSameLine(openToken.pos, closeToken.pos, sourceFile)) { return undefined; } @@ -143889,33 +144601,33 @@ var ts; return undefined; } var textSpan = ts.createTextSpanFromBounds(node.body.getFullStart(), node.body.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } function spanForJSXElement(node) { var textSpan = ts.createTextSpanFromBounds(node.openingElement.getStart(sourceFile), node.closingElement.getEnd()); var tagName = node.openingElement.tagName.getText(sourceFile); var bannerText = "<" + tagName + ">..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXFragment(node) { var textSpan = ts.createTextSpanFromBounds(node.openingFragment.getStart(sourceFile), node.closingFragment.getEnd()); var bannerText = "<>..."; - return createOutliningSpan(textSpan, "code" /* Code */, textSpan, /*autoCollapse*/ false, bannerText); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, textSpan, /*autoCollapse*/ false, bannerText); } function spanForJSXAttributes(node) { if (node.properties.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForTemplateLiteral(node) { - if (node.kind === 14 /* NoSubstitutionTemplateLiteral */ && node.text.length === 0) { + if (node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ && node.text.length === 0) { return undefined; } - return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* Code */); + return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), "code" /* OutliningSpanKind.Code */); } function spanForObjectOrArrayLiteral(node, open) { - if (open === void 0) { open = 18 /* OpenBraceToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } // If the block has no leading keywords and is inside an array literal or call expression, // we only want to collapse the span of the block. // Otherwise, the collapsed section will include the end of the previous line. @@ -143924,32 +144636,32 @@ var ts; function spanForNode(hintSpanNode, autoCollapse, useFullStart, open, close) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } - if (open === void 0) { open = 18 /* OpenBraceToken */; } - if (close === void 0) { close = open === 18 /* OpenBraceToken */ ? 19 /* CloseBraceToken */ : 23 /* CloseBracketToken */; } + if (open === void 0) { open = 18 /* SyntaxKind.OpenBraceToken */; } + if (close === void 0) { close = open === 18 /* SyntaxKind.OpenBraceToken */ ? 19 /* SyntaxKind.CloseBraceToken */ : 23 /* SyntaxKind.CloseBracketToken */; } var openToken = ts.findChildOfKind(n, open, sourceFile); var closeToken = ts.findChildOfKind(n, close, sourceFile); return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart); } function spanForNodeArray(nodeArray) { - return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* Code */) : undefined; + return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* OutliningSpanKind.Code */) : undefined; } function spanForParenthesizedExpression(node) { if (ts.positionsAreOnSameLine(node.getStart(), node.getEnd(), sourceFile)) return undefined; var textSpan = ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(node)); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(node)); } } function functionSpan(node, body, sourceFile) { var openToken = tryGetFunctionOpenToken(node, body, sourceFile); - var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* ArrowFunction */); + var closeToken = ts.findChildOfKind(body, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 214 /* SyntaxKind.ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } if (useFullStart === void 0) { useFullStart = true; } var textSpan = ts.createTextSpanFromBounds(useFullStart ? openToken.getFullStart() : openToken.getStart(sourceFile), closeToken.getEnd()); - return createOutliningSpan(textSpan, "code" /* Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); + return createOutliningSpan(textSpan, "code" /* OutliningSpanKind.Code */, ts.createTextSpanFromNode(hintSpanNode, sourceFile), autoCollapse); } function createOutliningSpan(textSpan, kind, hintSpan, autoCollapse, bannerText) { if (hintSpan === void 0) { hintSpan = textSpan; } @@ -143959,12 +144671,12 @@ var ts; } function tryGetFunctionOpenToken(node, body, sourceFile) { if (ts.isNodeArrayMultiLine(node.parameters, sourceFile)) { - var openParenToken = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + var openParenToken = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (openParenToken) { return openParenToken; } } - return ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); + return ts.findChildOfKind(body, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); } })(OutliningElementsCollector = ts.OutliningElementsCollector || (ts.OutliningElementsCollector = {})); })(ts || (ts = {})); @@ -144090,7 +144802,7 @@ var ts; // // Note: if the segment contains a space or an asterisk then we must assume that it's a // multi-word segment. - if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* space */ && ch !== 42 /* asterisk */; })) { + if (every(segment.totalTextChunk.text, function (ch) { return ch !== 32 /* CharacterCodes.space */ && ch !== 42 /* CharacterCodes.asterisk */; })) { var match = matchTextChunk(candidate, segment.totalTextChunk, stringToWordSpans); if (match) return match; @@ -144142,7 +144854,7 @@ var ts; return ts.min(a, b, compareMatches); } function compareMatches(a, b) { - return a === undefined ? 1 /* GreaterThan */ : b === undefined ? -1 /* LessThan */ + return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */ : ts.compareValues(a.kind, b.kind) || ts.compareBooleans(!a.isCaseSensitive, !b.isCaseSensitive); } function partStartsWith(candidate, candidateSpan, pattern, ignoreCase, patternSpan) { @@ -144219,10 +144931,10 @@ var ts; } function isUpperCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -144232,10 +144944,10 @@ var ts; } function isLowerCaseLetter(ch) { // Fast check for the ascii range. - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { return true; } - if (ch < 127 /* maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* Latest */)) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */ || !ts.isUnicodeIdentifierStart(ch, 99 /* ScriptTarget.Latest */)) { return false; } // TODO: find a way to determine this for any unicode characters in a @@ -144246,13 +144958,13 @@ var ts; // Assumes 'value' is already lowercase. function indexOfIgnoringCase(str, value) { var n = str.length - value.length; - var _loop_7 = function (start) { + var _loop_6 = function (start) { if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) { return { value: start }; } }; for (var start = 0; start <= n; start++) { - var state_3 = _loop_7(start); + var state_3 = _loop_6(start); if (typeof state_3 === "object") return state_3.value; } @@ -144260,10 +144972,10 @@ var ts; } function toLowerCase(ch) { // Fast convert for the ascii range. - if (ch >= 65 /* A */ && ch <= 90 /* Z */) { - return 97 /* a */ + (ch - 65 /* A */); + if (ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */) { + return 97 /* CharacterCodes.a */ + (ch - 65 /* CharacterCodes.A */); } - if (ch < 127 /* maxAsciiCharacter */) { + if (ch < 127 /* CharacterCodes.maxAsciiCharacter */) { return ch; } // TODO: find a way to compute this for any unicode characters in a @@ -144272,10 +144984,10 @@ var ts; } function isDigit(ch) { // TODO(cyrusn): Find a way to support this for unicode digits. - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isWordChar(ch) { - return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* _ */ || ch === 36 /* $ */; + return isUpperCaseLetter(ch) || isLowerCaseLetter(ch) || isDigit(ch) || ch === 95 /* CharacterCodes._ */ || ch === 36 /* CharacterCodes.$ */; } function breakPatternIntoTextChunks(pattern) { var result = []; @@ -144344,35 +145056,35 @@ var ts; } function charIsPunctuation(ch) { switch (ch) { - case 33 /* exclamation */: - case 34 /* doubleQuote */: - case 35 /* hash */: - case 37 /* percent */: - case 38 /* ampersand */: - case 39 /* singleQuote */: - case 40 /* openParen */: - case 41 /* closeParen */: - case 42 /* asterisk */: - case 44 /* comma */: - case 45 /* minus */: - case 46 /* dot */: - case 47 /* slash */: - case 58 /* colon */: - case 59 /* semicolon */: - case 63 /* question */: - case 64 /* at */: - case 91 /* openBracket */: - case 92 /* backslash */: - case 93 /* closeBracket */: - case 95 /* _ */: - case 123 /* openBrace */: - case 125 /* closeBrace */: + case 33 /* CharacterCodes.exclamation */: + case 34 /* CharacterCodes.doubleQuote */: + case 35 /* CharacterCodes.hash */: + case 37 /* CharacterCodes.percent */: + case 38 /* CharacterCodes.ampersand */: + case 39 /* CharacterCodes.singleQuote */: + case 40 /* CharacterCodes.openParen */: + case 41 /* CharacterCodes.closeParen */: + case 42 /* CharacterCodes.asterisk */: + case 44 /* CharacterCodes.comma */: + case 45 /* CharacterCodes.minus */: + case 46 /* CharacterCodes.dot */: + case 47 /* CharacterCodes.slash */: + case 58 /* CharacterCodes.colon */: + case 59 /* CharacterCodes.semicolon */: + case 63 /* CharacterCodes.question */: + case 64 /* CharacterCodes.at */: + case 91 /* CharacterCodes.openBracket */: + case 92 /* CharacterCodes.backslash */: + case 93 /* CharacterCodes.closeBracket */: + case 95 /* CharacterCodes._ */: + case 123 /* CharacterCodes.openBrace */: + case 125 /* CharacterCodes.closeBrace */: return true; } return false; } function isAllPunctuation(identifier, start, end) { - return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* _ */; }, start, end); + return every(identifier, function (ch) { return charIsPunctuation(ch) && ch !== 95 /* CharacterCodes._ */; }, start, end); } function transitionFromUpperToLower(identifier, index, wordStart) { // Cases this supports: @@ -144433,7 +145145,7 @@ var ts; if (readImportFiles === void 0) { readImportFiles = true; } if (detectJavaScriptImports === void 0) { detectJavaScriptImports = false; } var pragmaContext = { - languageVersion: 1 /* ES5 */, + languageVersion: 1 /* ScriptTarget.ES5 */, pragmas: undefined, checkJsDirective: undefined, referencedFiles: [], @@ -144454,10 +145166,10 @@ var ts; function nextToken() { lastToken = currentToken; currentToken = ts.scanner.scan(); - if (currentToken === 18 /* OpenBraceToken */) { + if (currentToken === 18 /* SyntaxKind.OpenBraceToken */) { braceNesting++; } - else if (currentToken === 19 /* CloseBraceToken */) { + else if (currentToken === 19 /* SyntaxKind.CloseBraceToken */) { braceNesting--; } return currentToken; @@ -144487,12 +145199,12 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 135 /* DeclareKeyword */) { + if (token === 135 /* SyntaxKind.DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 141 /* ModuleKeyword */) { + if (token === 141 /* SyntaxKind.ModuleKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { recordAmbientExternalModule(); } } @@ -144504,54 +145216,54 @@ var ts; * Returns true if at least one token was consumed from the stream */ function tryConsumeImport() { - if (lastToken === 24 /* DotToken */) { + if (lastToken === 24 /* SyntaxKind.DotToken */) { return false; } var token = ts.scanner.getToken(); - if (token === 100 /* ImportKeyword */) { + if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // import("mod"); recordModuleName(); return true; } } - else if (token === 10 /* StringLiteral */) { + else if (token === 10 /* SyntaxKind.StringLiteral */) { // import "mod"; recordModuleName(); return true; } else { - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token !== 156 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */ || - token === 79 /* Identifier */ || + return token !== 156 /* SyntaxKind.FromKeyword */ && (token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */ || + token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import d from "mod"; recordModuleName(); return true; } } - else if (token === 63 /* EqualsToken */) { + else if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 27 /* CommaToken */) { + else if (token === 27 /* SyntaxKind.CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -144560,18 +145272,18 @@ var ts; return true; } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import {a as A} from "mod"; // import d, {a, b as B} from "mod" recordModuleName(); @@ -144579,15 +145291,15 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 127 /* AsKeyword */) { + if (token === 127 /* SyntaxKind.AsKeyword */) { token = nextToken(); - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // import * as NS from "mod" // import d, * as NS from "mod" recordModuleName(); @@ -144603,31 +145315,31 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 93 /* ExportKeyword */) { + if (token === 93 /* SyntaxKind.ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 41 /* AsteriskToken */ || - token === 18 /* OpenBraceToken */; + return token === 41 /* SyntaxKind.AsteriskToken */ || + token === 18 /* SyntaxKind.OpenBraceToken */; }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 18 /* OpenBraceToken */) { + if (token === 18 /* SyntaxKind.OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 19 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 19 /* SyntaxKind.CloseBraceToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { token = nextToken(); } - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export {a as A} from "mod"; // export {a, b as B} from "mod" recordModuleName(); @@ -144635,31 +145347,31 @@ var ts; } } } - else if (token === 41 /* AsteriskToken */) { + else if (token === 41 /* SyntaxKind.AsteriskToken */) { token = nextToken(); - if (token === 156 /* FromKeyword */) { + if (token === 156 /* SyntaxKind.FromKeyword */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */) { // export * from "mod" recordModuleName(); } } } - else if (token === 100 /* ImportKeyword */) { + else if (token === 100 /* SyntaxKind.ImportKeyword */) { token = nextToken(); - if (token === 152 /* TypeKeyword */) { + if (token === 152 /* SyntaxKind.TypeKeyword */) { var skipTypeKeyword = ts.scanner.lookAhead(function () { var token = ts.scanner.scan(); - return token === 79 /* Identifier */ || + return token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token); }); if (skipTypeKeyword) { token = nextToken(); } } - if (token === 79 /* Identifier */ || ts.isKeyword(token)) { + if (token === 79 /* SyntaxKind.Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 63 /* EqualsToken */) { + if (token === 63 /* SyntaxKind.EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -144673,12 +145385,12 @@ var ts; function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 146 /* RequireKeyword */) { + if (token === 146 /* SyntaxKind.RequireKeyword */) { token = nextToken(); - if (token === 20 /* OpenParenToken */) { + if (token === 20 /* SyntaxKind.OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */ || - allowTemplateLiterals && token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || + allowTemplateLiterals && token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // require("mod"); recordModuleName(); } @@ -144689,16 +145401,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 79 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 79 /* SyntaxKind.Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 20 /* OpenParenToken */) { + if (token !== 20 /* SyntaxKind.OpenParenToken */) { return true; } token = nextToken(); - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 27 /* CommaToken */) { + if (token === 27 /* SyntaxKind.CommaToken */) { token = nextToken(); } else { @@ -144707,15 +145419,15 @@ var ts; } } // should be start of dependency list - if (token !== 22 /* OpenBracketToken */) { + if (token !== 22 /* SyntaxKind.OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); // scan until ']' or EOF - while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 23 /* SyntaxKind.CloseBracketToken */ && token !== 1 /* SyntaxKind.EndOfFileToken */) { // record string literals as module names - if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { + if (token === 10 /* SyntaxKind.StringLiteral */ || token === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */) { recordModuleName(); } token = nextToken(); @@ -144743,31 +145455,31 @@ var ts; // AnySymbol.import("mod") // AnySymbol.nested.import("mod") while (true) { - if (ts.scanner.getToken() === 1 /* EndOfFileToken */) { + if (ts.scanner.getToken() === 1 /* SyntaxKind.EndOfFileToken */) { break; } - if (ts.scanner.getToken() === 15 /* TemplateHead */) { + if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) { var stack = [ts.scanner.getToken()]; var token = ts.scanner.scan(); loop: while (ts.length(stack)) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: tryConsumeImport(); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: stack.push(token); break; - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: if (ts.length(stack)) { stack.push(token); } break; - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: if (ts.length(stack)) { - if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) { - if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) { + if (ts.lastOrUndefined(stack) === 15 /* SyntaxKind.TemplateHead */) { + if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* SyntaxKind.TemplateTail */) { stack.pop(); } } @@ -144854,13 +145566,13 @@ var ts; if (!symbol) { if (ts.isStringLiteralLike(node)) { var type = ts.getContextualTypeFromParentOrAncestorTypeNode(node, typeChecker); - if (type && ((type.flags & 128 /* StringLiteral */) || ((type.flags & 1048576 /* Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* StringLiteral */); })))) { - return getRenameInfoSuccess(node.text, node.text, "string" /* string */, "", node, sourceFile); + if (type && ((type.flags & 128 /* TypeFlags.StringLiteral */) || ((type.flags & 1048576 /* TypeFlags.Union */) && ts.every(type.types, function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); })))) { + return getRenameInfoSuccess(node.text, node.text, "string" /* ScriptElementKind.string */, "", node, sourceFile); } } else if (ts.isLabelName(node)) { var name = ts.getTextOfNode(node); - return getRenameInfoSuccess(name, name, "label" /* label */, "" /* none */, node, sourceFile); + return getRenameInfoSuccess(name, name, "label" /* ScriptElementKind.label */, "" /* ScriptElementKindModifier.none */, node, sourceFile); } return undefined; } @@ -144873,7 +145585,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 88 /* SyntaxKind.DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* SymbolFlags.Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { @@ -144885,7 +145597,7 @@ var ts; return getRenameInfoError(wouldRenameNodeModules); } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -144894,10 +145606,10 @@ var ts; } function isDefinedInLibraryFile(program, declaration) { var sourceFile = declaration.getSourceFile(); - return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Extension.Dts */); } function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) { - if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) { + if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* SymbolFlags.Alias */) { var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); }); if (importSpecifier && !importSpecifier.propertyName) { symbol = checker.getAliasedSymbol(symbol); @@ -144923,7 +145635,7 @@ var ts; if (declPackage) { var length_2 = Math.min(originalPackage.length, declPackage.length); for (var i = 0; i <= length_2; i++) { - if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) { + if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* Comparison.EqualTo */) { return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder; } } @@ -144948,7 +145660,7 @@ var ts; return undefined; var withoutIndex = ts.endsWith(node.text, "/index") || ts.endsWith(node.text, "/index.js") ? undefined : ts.tryRemoveSuffix(ts.removeFileExtension(moduleSourceFile.fileName), "/index"); var name = withoutIndex === undefined ? moduleSourceFile.fileName : withoutIndex; - var kind = withoutIndex === undefined ? "module" /* moduleElement */ : "directory" /* directory */; + var kind = withoutIndex === undefined ? "module" /* ScriptElementKind.moduleElement */ : "directory" /* ScriptElementKind.directory */; var indexAfterLastSlash = node.text.lastIndexOf("/") + 1; // Span should only be the last component of the path. + 1 to account for the quote character. var triggerSpan = ts.createTextSpan(node.getStart(sourceFile) + 1 + indexAfterLastSlash, node.text.length - indexAfterLastSlash); @@ -144958,7 +145670,7 @@ var ts; kind: kind, displayName: name, fullDisplayName: name, - kindModifiers: "" /* none */, + kindModifiers: "" /* ScriptElementKindModifier.none */, triggerSpan: triggerSpan, }; } @@ -144988,13 +145700,13 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return true; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); default: return false; @@ -145009,7 +145721,7 @@ var ts; var SmartSelectionRange; (function (SmartSelectionRange) { function getSmartSelectionRange(pos, sourceFile) { - var _a; + var _a, _b; var selectionRange = { textSpan: ts.createTextSpanFromBounds(sourceFile.getFullStart(), sourceFile.getEnd()) }; @@ -145026,7 +145738,7 @@ var ts; break outer; } var comment = ts.singleOrUndefined(ts.getTrailingCommentRanges(sourceFile.text, node.end)); - if (comment && comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment && comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { pushSelectionCommentRange(comment.pos, comment.end); } if (positionShouldSnapToNode(sourceFile, pos, node)) { @@ -145061,6 +145773,17 @@ var ts; if (ts.hasJSDocNodes(node) && ((_a = node.jsDoc) === null || _a === void 0 ? void 0 : _a.length)) { pushSelectionRange(ts.first(node.jsDoc).getStart(), end); } + // (#39618 & #49807) + // When the node is a SyntaxList and its first child has a JSDoc comment, then the node's + // `start` (which usually is the result of calling `node.getStart()`) points to the first + // token after the JSDoc comment. So, we have to make sure we'd pushed the selection + // covering the JSDoc comment before diving further. + if (ts.isSyntaxList(node)) { + var firstChild = node.getChildren()[0]; + if (firstChild && ts.hasJSDocNodes(firstChild) && ((_b = firstChild.jsDoc) === null || _b === void 0 ? void 0 : _b.length) && firstChild.getStart() !== node.pos) { + start = Math.min(start, ts.first(firstChild.jsDoc).getStart()); + } + } pushSelectionRange(start, end); // String literals should have a stop both inside and outside their quotes. if (ts.isStringLiteral(node) || ts.isTemplateLiteral(node)) { @@ -145094,7 +145817,7 @@ var ts; function pushSelectionCommentRange(start, end) { pushSelectionRange(start, end); var pos = start; - while (sourceFile.text.charCodeAt(pos) === 47 /* slash */) { + while (sourceFile.text.charCodeAt(pos) === 47 /* CharacterCodes.slash */) { pos++; } pushSelectionRange(pos, end); @@ -145134,6 +145857,7 @@ var ts; * other as well as of other top-level statements and declarations. */ function getSelectionChildren(node) { + var _a; // Group top-level imports if (ts.isSourceFile(node)) { return groupChildren(node.getChildAt(0).getChildren(), isImport); @@ -145149,28 +145873,28 @@ var ts; // because it allows the mapped type to become an object type with a // few keystrokes. if (ts.isMappedTypeNode(node)) { - var _a = node.getChildren(), openBraceToken = _a[0], children = _a.slice(1); + var _b = node.getChildren(), openBraceToken = _b[0], children = _b.slice(1); var closeBraceToken = ts.Debug.checkDefined(children.pop()); - ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */); - ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); + ts.Debug.assertEqual(openBraceToken.kind, 18 /* SyntaxKind.OpenBraceToken */); + ts.Debug.assertEqual(closeBraceToken.kind, 19 /* SyntaxKind.CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 145 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 57 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 145 /* SyntaxKind.ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* SyntaxKind.QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; - return kind === 22 /* OpenBracketToken */ || - kind === 163 /* TypeParameter */ || - kind === 23 /* CloseBracketToken */; + return kind === 22 /* SyntaxKind.OpenBracketToken */ || + kind === 163 /* SyntaxKind.TypeParameter */ || + kind === 23 /* SyntaxKind.CloseBracketToken */; }); return [ openBraceToken, // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; })), closeBraceToken, ]; @@ -145180,10 +145904,13 @@ var ts; var children = groupChildren(node.getChildren(), function (child) { return child === node.name || ts.contains(node.modifiers, child); }); - return splitChildren(children, function (_a) { + var firstJSDocChild = ((_a = children[0]) === null || _a === void 0 ? void 0 : _a.kind) === 320 /* SyntaxKind.JSDoc */ ? children[0] : undefined; + var withJSDocSeparated = firstJSDocChild ? children.slice(1) : children; + var splittedChildren = splitChildren(withJSDocSeparated, function (_a) { var kind = _a.kind; - return kind === 58 /* ColonToken */; + return kind === 58 /* SyntaxKind.ColonToken */; }); + return firstJSDocChild ? [firstJSDocChild, createSyntaxList(splittedChildren)] : splittedChildren; } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. if (ts.isParameter(node)) { @@ -145195,14 +145922,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 63 /* EqualsToken */; + return kind === 63 /* SyntaxKind.EqualsToken */; }); } return node.getChildren(); @@ -145258,7 +145985,7 @@ var ts; var leftChildren = children.slice(0, splitTokenIndex); var splitToken = children[splitTokenIndex]; var lastToken = ts.last(children); - var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SemicolonToken */; + var separateLastToken = separateTrailingSemicolon && lastToken.kind === 26 /* SyntaxKind.SemicolonToken */; var rightChildren = children.slice(splitTokenIndex + 1, separateLastToken ? children.length - 1 : undefined); var result = ts.compact([ leftChildren.length ? createSyntaxList(leftChildren) : undefined, @@ -145273,25 +146000,25 @@ var ts; } function isListOpener(token) { var kind = token && token.kind; - return kind === 18 /* OpenBraceToken */ - || kind === 22 /* OpenBracketToken */ - || kind === 20 /* OpenParenToken */ - || kind === 280 /* JsxOpeningElement */; + return kind === 18 /* SyntaxKind.OpenBraceToken */ + || kind === 22 /* SyntaxKind.OpenBracketToken */ + || kind === 20 /* SyntaxKind.OpenParenToken */ + || kind === 280 /* SyntaxKind.JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; - return kind === 19 /* CloseBraceToken */ - || kind === 23 /* CloseBracketToken */ - || kind === 21 /* CloseParenToken */ - || kind === 281 /* JsxClosingElement */; + return kind === 19 /* SyntaxKind.CloseBraceToken */ + || kind === 23 /* SyntaxKind.CloseBracketToken */ + || kind === 21 /* SyntaxKind.CloseParenToken */ + || kind === 281 /* SyntaxKind.JsxClosingElement */; } function getEndPos(sourceFile, node) { switch (node.kind) { - case 340 /* JSDocParameterTag */: - case 338 /* JSDocCallbackTag */: - case 347 /* JSDocPropertyTag */: - case 345 /* JSDocTypedefTag */: - case 342 /* JSDocThisTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 342 /* SyntaxKind.JSDocThisTag */: return sourceFile.getLineEndOfPosition(node.getStart()); default: return node.getEnd(); @@ -145338,7 +146065,7 @@ var ts; return ts.isSourceFileJS(sourceFile) ? createJSSignatureHelpItems(argumentInfo, program, cancellationToken) : undefined; } return typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { - return candidateInfo.kind === 0 /* Candidate */ + return candidateInfo.kind === 0 /* CandidateOrTypeKind.Candidate */ ? createSignatureHelpItems(candidateInfo.candidates, candidateInfo.resolvedSignature, argumentInfo, sourceFile, typeChecker) : createTypeHelpItems(candidateInfo.symbol, argumentInfo, sourceFile, typeChecker); }); @@ -145352,27 +146079,27 @@ var ts; function getCandidateOrTypeInfo(_a, checker, sourceFile, startingToken, onlyUseSyntacticOwners) { var invocation = _a.invocation, argumentCount = _a.argumentCount; switch (invocation.kind) { - case 0 /* Call */: { + case 0 /* InvocationKind.Call */: { if (onlyUseSyntacticOwners && !isSyntacticOwner(startingToken, invocation.node, sourceFile)) { return undefined; } var candidates = []; var resolvedSignature = checker.getResolvedSignatureForSignatureHelp(invocation.node, candidates, argumentCount); // TODO: GH#18217 - return candidates.length === 0 ? undefined : { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; + return candidates.length === 0 ? undefined : { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: resolvedSignature }; } - case 1 /* TypeArgs */: { + case 1 /* InvocationKind.TypeArgs */: { var called = invocation.called; if (onlyUseSyntacticOwners && !containsPrecedingToken(startingToken, sourceFile, ts.isIdentifier(called) ? called.parent : called)) { return undefined; } var candidates = ts.getPossibleGenericSignatures(called, argumentCount, checker); if (candidates.length !== 0) - return { kind: 0 /* Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: candidates, resolvedSignature: ts.first(candidates) }; var symbol = checker.getSymbolAtLocation(called); - return symbol && { kind: 1 /* Type */, symbol: symbol }; + return symbol && { kind: 1 /* CandidateOrTypeKind.Type */, symbol: symbol }; } - case 2 /* Contextual */: - return { kind: 0 /* Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; + case 2 /* InvocationKind.Contextual */: + return { kind: 0 /* CandidateOrTypeKind.Candidate */, candidates: [invocation.signature], resolvedSignature: invocation.signature }; default: return ts.Debug.assertNever(invocation); } @@ -145382,20 +146109,20 @@ var ts; return false; var invocationChildren = node.getChildren(sourceFile); switch (startingToken.kind) { - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return ts.contains(invocationChildren, startingToken); - case 27 /* CommaToken */: { + case 27 /* SyntaxKind.CommaToken */: { var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; } } function createJSSignatureHelpItems(argumentInfo, program, cancellationToken) { - if (argumentInfo.invocation.kind === 2 /* Contextual */) + if (argumentInfo.invocation.kind === 2 /* InvocationKind.Contextual */) return undefined; // See if we can find some symbol with the call expression name that has call signatures. var expression = getExpressionFromInvocation(argumentInfo.invocation); @@ -145431,7 +146158,7 @@ var ts; } function getArgumentInfoForCompletions(node, position, sourceFile) { var info = getImmediatelyContainingArgumentInfo(node, position, sourceFile); - return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* Call */ ? undefined + return !info || info.isTypeParameterList || info.invocation.kind !== 0 /* InvocationKind.Call */ ? undefined : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex }; } SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions; @@ -145448,7 +146175,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* SyntaxKind.LessThanToken */ || node.kind === 20 /* SyntaxKind.OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -145491,7 +146218,7 @@ var ts; return undefined; var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var isTypeParameterList = !!parent.typeArguments && parent.typeArguments.pos === list.pos; - return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; + return { isTypeParameterList: isTypeParameterList, invocation: { kind: 0 /* InvocationKind.Call */, node: invocation }, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } else if (ts.isNoSubstitutionTemplateLiteral(node) && ts.isTaggedTemplateExpression(parent)) { // Check if we're actually inside the template; @@ -145501,10 +146228,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 223 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 223 /* SyntaxKind.TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -145529,7 +146256,7 @@ var ts; var attributeSpanEnd = ts.skipTrivia(sourceFile.text, parent.attributes.end, /*stopAfterLineBreak*/ false); return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: parent }, + invocation: { kind: 0 /* InvocationKind.Call */, node: parent }, argumentsSpan: ts.createTextSpan(attributeSpanStart, attributeSpanEnd - attributeSpanStart), argumentIndex: 0, argumentCount: 1 @@ -145539,7 +146266,7 @@ var ts; var typeArgInfo = ts.getPossibleTypeArgumentsInfo(node, sourceFile); if (typeArgInfo) { var called = typeArgInfo.called, nTypeArguments = typeArgInfo.nTypeArguments; - var invocation = { kind: 1 /* TypeArgs */, called: called }; + var invocation = { kind: 1 /* InvocationKind.TypeArgs */, called: called }; var argumentsSpan = ts.createTextSpanFromBounds(called.getStart(sourceFile), node.end); return { isTypeParameterList: true, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: nTypeArguments, argumentCount: nTypeArguments + 1 }; } @@ -145568,28 +146295,28 @@ var ts; var signature = ts.lastOrUndefined(nonNullableContextualType.getCallSignatures()); if (signature === undefined) return undefined; - var invocation = { kind: 2 /* Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; + var invocation = { kind: 2 /* InvocationKind.Contextual */, signature: signature, node: startingToken, symbol: chooseBetterSymbol(symbol) }; return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount }; } function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) { - if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */) + if (startingToken.kind !== 20 /* SyntaxKind.OpenParenToken */ && startingToken.kind !== 27 /* SyntaxKind.CommaToken */) return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); - var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; + var argumentIndex_1 = startingToken.kind === 20 /* SyntaxKind.OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; var argumentCount_1 = countBinaryExpressionParameters(highestBinary); return contextualType_1 && { contextualType: contextualType_1, argumentIndex: argumentIndex_1, argumentCount: argumentCount_1, argumentsSpan: ts.createTextSpanFromNode(parent) }; } @@ -145599,7 +146326,7 @@ var ts; } // The type of a function type node has a symbol at that node, but it's better to use the symbol for a parameter or type alias. function chooseBetterSymbol(s) { - return s.name === "__type" /* Type */ + return s.name === "__type" /* InternalSymbolName.Type */ ? ts.firstDefined(s.declarations, function (d) { return ts.isFunctionTypeNode(d) ? d.parent.symbol : undefined; }) || s : s; } @@ -145621,7 +146348,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 27 /* CommaToken */) { + if (child.kind !== 27 /* SyntaxKind.CommaToken */) { argumentIndex++; } } @@ -145640,8 +146367,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; }); - if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* SyntaxKind.CommaToken */; }); + if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* SyntaxKind.CommaToken */) { argumentCount++; } return argumentCount; @@ -145679,7 +146406,7 @@ var ts; } return { isTypeParameterList: false, - invocation: { kind: 0 /* Call */, node: tagExpression }, + invocation: { kind: 0 /* InvocationKind.Call */, node: tagExpression }, argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression, sourceFile), argumentIndex: argumentIndex, argumentCount: argumentCount @@ -145710,7 +146437,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -145719,17 +146446,17 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) { - var _loop_8 = function (n) { + var _loop_7 = function (n) { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. - ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); }); + ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: ".concat(ts.Debug.formatSyntaxKind(n.kind), ", parent: ").concat(ts.Debug.formatSyntaxKind(n.parent.kind)); }); var argumentInfo = getImmediatelyContainingArgumentOrContextualParameterInfo(n, position, sourceFile, checker); if (argumentInfo) { return { value: argumentInfo }; } }; for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) { - var state_4 = _loop_8(n); + var state_4 = _loop_7(n); if (typeof state_4 === "object") return state_4.value; } @@ -145742,17 +146469,17 @@ var ts; return children[indexOfOpenerToken + 1]; } function getExpressionFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; + return invocation.kind === 0 /* InvocationKind.Call */ ? ts.getInvokedExpression(invocation.node) : invocation.called; } function getEnclosingDeclarationFromInvocation(invocation) { - return invocation.kind === 0 /* Call */ ? invocation.node : invocation.kind === 1 /* TypeArgs */ ? invocation.called : invocation.node; + return invocation.kind === 0 /* InvocationKind.Call */ ? invocation.node : invocation.kind === 1 /* InvocationKind.TypeArgs */ ? invocation.called : invocation.node; } - var signatureHelpNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var signatureHelpNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; function createSignatureHelpItems(candidates, resolvedSignature, _a, sourceFile, typeChecker, useFullPrefix) { var _b; var isTypeParameterList = _a.isTypeParameterList, argumentCount = _a.argumentCount, applicableSpan = _a.argumentsSpan, invocation = _a.invocation, argumentIndex = _a.argumentIndex; var enclosingDeclaration = getEnclosingDeclarationFromInvocation(invocation); - var callTargetSymbol = invocation.kind === 2 /* Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); + var callTargetSymbol = invocation.kind === 2 /* InvocationKind.Contextual */ ? invocation.symbol : (typeChecker.getSymbolAtLocation(getExpressionFromInvocation(invocation)) || useFullPrefix && ((_b = resolvedSignature.declaration) === null || _b === void 0 ? void 0 : _b.symbol)); var callTargetDisplayParts = callTargetSymbol ? ts.symbolToDisplayParts(typeChecker, callTargetSymbol, useFullPrefix ? sourceFile : undefined, /*meaning*/ undefined) : ts.emptyArray; var items = ts.map(candidates, function (candidateSignature) { return getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, typeChecker, enclosingDeclaration, sourceFile); }); if (argumentIndex !== 0) { @@ -145809,10 +146536,10 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(checker); - var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* LessThanToken */)], false); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArray(__spreadArray([], typeSymbolDisplay, true), [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], false); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } - var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; + var separatorDisplayParts = [ts.punctuationPart(27 /* SyntaxKind.CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { var infos = (isTypeParameterList ? itemInfoForTypeParameters : itemInfoForParameters)(candidateSignature, checker, enclosingDeclaration, sourceFile); return ts.map(infos, function (_a) { @@ -145845,9 +146572,9 @@ var ts; return checker.getExpandedParameters(candidateSignature).map(function (paramList) { var params = ts.factory.createNodeArray(__spreadArray(__spreadArray([], thisParameter, true), ts.map(paramList, function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }), true)); var parameterParts = ts.mapToDisplayParts(function (writer) { - printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); + printer.writeList(2576 /* ListFormat.CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts, true) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* SyntaxKind.LessThanToken */)], suffix: __spreadArray([ts.punctuationPart(31 /* SyntaxKind.GreaterThanToken */)], parameterParts, true) }; }); } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { @@ -145855,33 +146582,33 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { var args = ts.factory.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration, signatureHelpNodeBuilderFlags); })); - printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); + printer.writeList(53776 /* ListFormat.TypeParameters */, args, sourceFile, writer); } }); var lists = checker.getExpandedParameters(candidateSignature); var isVariadic = !checker.hasEffectiveRestParameter(candidateSignature) ? function (_) { return false; } : lists.length === 1 ? function (_) { return true; } - : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* RestParameter */); }; + : function (pList) { return !!(pList.length && pList[pList.length - 1].checkFlags & 32768 /* CheckFlags.RestParameter */); }; return lists.map(function (parameterList) { return ({ isVariadic: isVariadic(parameterList), parameters: parameterList.map(function (p) { return createSignatureHelpParameterForParameter(p, checker, enclosingDeclaration, sourceFile, printer); }), - prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* OpenParenToken */)], false), - suffix: [ts.punctuationPart(21 /* CloseParenToken */)] + prefix: __spreadArray(__spreadArray([], typeParameterParts, true), [ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)], false), + suffix: [ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)] }); }); } function createSignatureHelpParameterForParameter(parameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.symbolToParameterDeclaration(parameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); var isOptional = checker.isOptionalParameter(parameter.valueDeclaration); - var isRest = !!(parameter.checkFlags & 32768 /* RestParameter */); + var isRest = !!(parameter.checkFlags & 32768 /* CheckFlags.RestParameter */); return { name: parameter.name, documentation: parameter.getDocumentationComment(checker), displayParts: displayParts, isOptional: isOptional, isRest: isRest }; } function createSignatureHelpParameterForTypeParameter(typeParameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); - printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false, isRest: false }; } @@ -145894,7 +146621,7 @@ var ts; (function (InlayHints) { var maxHintsLength = 30; var leadingParameterNameCommentRegexFactory = function (name) { - return new RegExp("^\\s?/\\*\\*?\\s?" + name + "\\s?\\*\\/\\s?$"); + return new RegExp("^\\s?/\\*\\*?\\s?".concat(name, "\\s?\\*\\/\\s?$")); }; function shouldShowParameterNameHints(preferences) { return preferences.includeInlayParameterNameHints === "literals" || preferences.includeInlayParameterNameHints === "all"; @@ -145915,14 +146642,14 @@ var ts; return; } switch (node.kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 214 /* ArrowFunction */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } if (!ts.textSpanIntersectsWith(span, node.pos, node.getFullWidth())) { @@ -145958,25 +146685,25 @@ var ts; } function addParameterHints(text, position, isFirstVariadicArgument) { result.push({ - text: "" + (isFirstVariadicArgument ? "..." : "") + truncation(text, maxHintsLength) + ":", + text: "".concat(isFirstVariadicArgument ? "..." : "").concat(truncation(text, maxHintsLength), ":"), position: position, - kind: "Parameter" /* Parameter */, + kind: "Parameter" /* InlayHintKind.Parameter */, whitespaceAfter: true, }); } function addTypeHints(text, position) { result.push({ - text: ": " + truncation(text, maxHintsLength), + text: ": ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Type" /* Type */, + kind: "Type" /* InlayHintKind.Type */, whitespaceBefore: true, }); } function addEnumMemberValueHints(text, position) { result.push({ - text: "= " + truncation(text, maxHintsLength), + text: "= ".concat(truncation(text, maxHintsLength)), position: position, - kind: "Enum" /* Enum */, + kind: "Enum" /* InlayHintKind.Enum */, whitespaceBefore: true, }); } @@ -145990,7 +146717,7 @@ var ts; } } function isModuleReferenceType(type) { - return type.symbol && (type.symbol.flags & 1536 /* Module */); + return type.symbol && (type.symbol.flags & 1536 /* SymbolFlags.Module */); } function visitVariableLikeDeclaration(decl) { if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) { @@ -146066,17 +146793,17 @@ var ts; } function isHintableLiteral(node) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; return ts.isLiteralExpression(operand) || ts.isIdentifier(operand) && ts.isInfinityOrNaNString(operand.escapedText); } - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var name = node.escapedText; return isUndefined(name) || ts.isInfinityOrNaNString(name); } @@ -146085,7 +146812,7 @@ var ts; } function visitFunctionDeclarationLikeForReturnType(decl) { if (ts.isArrowFunction(decl)) { - if (!ts.findChildOfKind(decl, 20 /* OpenParenToken */, file)) { + if (!ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, file)) { return; } } @@ -146108,7 +146835,7 @@ var ts; addTypeHints(typeDisplayString, getTypeAnnotationPosition(decl)); } function getTypeAnnotationPosition(decl) { - var closeParenToken = ts.findChildOfKind(decl, 21 /* CloseParenToken */, file); + var closeParenToken = ts.findChildOfKind(decl, 21 /* SyntaxKind.CloseParenToken */, file); if (closeParenToken) { return closeParenToken.end; } @@ -146153,13 +146880,13 @@ var ts; return text; } function printTypeInSingleLine(type) { - var flags = 70221824 /* IgnoreErrors */ | 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var flags = 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; var options = { removeComments: true }; var printer = ts.createPrinter(options); return ts.usingSingleLineStringWriter(function (writer) { var typeNode = checker.typeToTypeNode(type, /*enclosingDeclaration*/ undefined, flags, writer); ts.Debug.assertIsDefined(typeNode, "should always get typenode"); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ file, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ file, writer); }); } function isUndefined(name) { @@ -146228,7 +146955,7 @@ var ts; var options = program.getCompilerOptions(); var outPath = ts.outFile(options); var declarationPath = outPath ? - ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : + ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : ts.getDeclarationEmitOutputFilePathWorker(info.fileName, program.getCompilerOptions(), currentDirectory, program.getCommonSourceDirectory(), getCanonicalFileName); if (declarationPath === undefined) return undefined; @@ -146337,7 +147064,7 @@ var ts; program.getSemanticDiagnostics(sourceFile, cancellationToken); var diags = []; var checker = program.getTypeChecker(); - var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]); + var isCommonJSFile = sourceFile.impliedNodeFormat === ts.ModuleKind.CommonJS || ts.fileExtensionIsOneOf(sourceFile.fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]); if (!isCommonJSFile && sourceFile.commonJsModuleIndicator && (ts.programContainsEsModules(program) || ts.compilerOptionsIndicateEsModules(program.getCompilerOptions())) && @@ -146373,7 +147100,7 @@ var ts; else { if (ts.isVariableStatement(node) && node.parent === sourceFile && - node.declarationList.flags & 2 /* Const */ && + node.declarationList.flags & 2 /* NodeFlags.Const */ && node.declarationList.declarations.length === 1) { var init = node.declarationList.declarations[0].initializer; if (init && ts.isRequireCall(init, /*checkArgumentIsStringLiteralLike*/ true)) { @@ -146395,16 +147122,16 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); var kind = ts.getAssignmentDeclarationKind(expression); - return kind === 1 /* ExportsProperty */ || kind === 2 /* ModuleExports */; + return kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ || kind === 2 /* AssignmentDeclarationKind.ModuleExports */; } default: return false; @@ -146416,12 +147143,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -146491,26 +147218,26 @@ var ts; if (node.arguments.length < maxArguments) return true; return maxArguments === 1 || ts.some(node.arguments, function (arg) { - return arg.kind === 104 /* NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; + return arg.kind === 104 /* SyntaxKind.NullKeyword */ || ts.isIdentifier(arg) && arg.text === "undefined"; }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg, checker) { switch (arg.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var functionFlags = ts.getFunctionFlags(arg); - if (functionFlags & 1 /* Generator */) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { return false; } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); // falls through - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return true; - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: { + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: { var symbol = checker.getSymbolAtLocation(arg); if (!symbol) { return false; @@ -146523,28 +147250,28 @@ var ts; } } function getKeyFromNode(exp) { - return exp.pos.toString() + ":" + exp.end.toString(); + return "".concat(exp.pos.toString(), ":").concat(exp.end.toString()); } function canBeConvertedToClass(node, checker) { var _a, _b, _c, _d; - if (node.kind === 213 /* FunctionExpression */) { + if (node.kind === 213 /* SyntaxKind.FunctionExpression */) { if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) { return true; } var symbol = checker.getSymbolOfExpando(node, /*allowDeclaration*/ false); return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size))); } - if (node.kind === 256 /* FunctionDeclaration */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */) { return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); } return false; } function canBeConvertedToAsync(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -146557,32 +147284,32 @@ var ts; (function (ts) { var SymbolDisplay; (function (SymbolDisplay) { - var symbolDisplayNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; + var symbolDisplayNodeBuilderFlags = 8192 /* NodeBuilderFlags.OmitParameterModifiers */ | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(typeChecker, symbol, location) { var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result !== "" /* unknown */) { + if (result !== "" /* ScriptElementKind.unknown */) { return result; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; - } - if (flags & 384 /* Enum */) - return "enum" /* enumElement */; - if (flags & 524288 /* TypeAlias */) - return "type" /* typeElement */; - if (flags & 64 /* Interface */) - return "interface" /* interfaceElement */; - if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; - if (flags & 8 /* EnumMember */) - return "enum member" /* enumMemberElement */; - if (flags & 2097152 /* Alias */) - return "alias" /* alias */; - if (flags & 1536 /* Module */) - return "module" /* moduleElement */; + if (flags & 32 /* SymbolFlags.Class */) { + return ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */) ? + "local class" /* ScriptElementKind.localClassElement */ : "class" /* ScriptElementKind.classElement */; + } + if (flags & 384 /* SymbolFlags.Enum */) + return "enum" /* ScriptElementKind.enumElement */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + return "type" /* ScriptElementKind.typeElement */; + if (flags & 64 /* SymbolFlags.Interface */) + return "interface" /* ScriptElementKind.interfaceElement */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + return "type parameter" /* ScriptElementKind.typeParameterElement */; + if (flags & 8 /* SymbolFlags.EnumMember */) + return "enum member" /* ScriptElementKind.enumMemberElement */; + if (flags & 2097152 /* SymbolFlags.Alias */) + return "alias" /* ScriptElementKind.alias */; + if (flags & 1536 /* SymbolFlags.Module */) + return "module" /* ScriptElementKind.moduleElement */; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; @@ -146590,52 +147317,52 @@ var ts; var roots = typeChecker.getRootSymbols(symbol); // If this is a method from a mapped type, leave as a method so long as it still has a call signature. if (roots.length === 1 - && ts.first(roots).flags & 8192 /* Method */ + && ts.first(roots).flags & 8192 /* SymbolFlags.Method */ // Ensure the mapped version is still a method, as opposed to `{ [K in keyof I]: number }`. && typeChecker.getTypeOfSymbolAtLocation(symbol, location).getNonNullableType().getCallSignatures().length !== 0) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } if (typeChecker.isUndefinedSymbol(symbol)) { - return "var" /* variableElement */; + return "var" /* ScriptElementKind.variableElement */; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var" /* localVariableElement */; + return "local var" /* ScriptElementKind.localVariableElement */; } - if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { - return "parameter" /* parameterElement */; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) { + return "parameter" /* ScriptElementKind.parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - if (flags & 3 /* Variable */) { + if (flags & 3 /* SymbolFlags.Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter" /* parameterElement */; + return "parameter" /* ScriptElementKind.parameterElement */; } else if (symbol.valueDeclaration && ts.isVarConst(symbol.valueDeclaration)) { - return "const" /* constElement */; + return "const" /* ScriptElementKind.constElement */; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let" /* letElement */; + return "let" /* ScriptElementKind.letElement */; } - return isLocalVariableOrFunction(symbol) ? "local var" /* localVariableElement */ : "var" /* variableElement */; + return isLocalVariableOrFunction(symbol) ? "local var" /* ScriptElementKind.localVariableElement */ : "var" /* ScriptElementKind.variableElement */; } - if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */; + if (flags & 16 /* SymbolFlags.Function */) + return isLocalVariableOrFunction(symbol) ? "local function" /* ScriptElementKind.localFunctionElement */ : "function" /* ScriptElementKind.functionElement */; // FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag. // So, even when the location is just on the declaration of setter, this function returns getter. - if (flags & 32768 /* GetAccessor */) - return "getter" /* memberGetAccessorElement */; - if (flags & 65536 /* SetAccessor */) - return "setter" /* memberSetAccessorElement */; - if (flags & 8192 /* Method */) - return "method" /* memberFunctionElement */; - if (flags & 16384 /* Constructor */) - return "constructor" /* constructorImplementationElement */; - if (flags & 4 /* Property */) { - if (flags & 33554432 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { + if (flags & 32768 /* SymbolFlags.GetAccessor */) + return "getter" /* ScriptElementKind.memberGetAccessorElement */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + return "setter" /* ScriptElementKind.memberSetAccessorElement */; + if (flags & 8192 /* SymbolFlags.Method */) + return "method" /* ScriptElementKind.memberFunctionElement */; + if (flags & 16384 /* SymbolFlags.Constructor */) + return "constructor" /* ScriptElementKind.constructorImplementationElement */; + if (flags & 4 /* SymbolFlags.Property */) { + if (flags & 33554432 /* SymbolFlags.Transient */ && symbol.checkFlags & 6 /* CheckFlags.Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); - if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return "property" /* memberVariableElement */; + if (rootSymbolFlags & (98308 /* SymbolFlags.PropertyOrAccessor */ | 3 /* SymbolFlags.Variable */)) { + return "property" /* ScriptElementKind.memberVariableElement */; } }); if (!unionPropertyKind) { @@ -146643,23 +147370,23 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method" /* memberFunctionElement */; + return "method" /* ScriptElementKind.memberFunctionElement */; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } return unionPropertyKind; } - return "property" /* memberVariableElement */; + return "property" /* ScriptElementKind.memberVariableElement */; } - return "" /* unknown */; + return "" /* ScriptElementKind.unknown */; } function getNormalizedSymbolModifiers(symbol) { if (symbol.declarations && symbol.declarations.length) { var _a = symbol.declarations, declaration = _a[0], declarations = _a.slice(1); // omit deprecated flag if some declarations are not deprecated var excludeFlags = ts.length(declarations) && ts.isDeprecatedDeclaration(declaration) && ts.some(declarations, function (d) { return !ts.isDeprecatedDeclaration(d); }) - ? 8192 /* Deprecated */ - : 0 /* None */; + ? 8192 /* ModifierFlags.Deprecated */ + : 0 /* ModifierFlags.None */; var modifiers = ts.getNodeModifiers(declaration, excludeFlags); if (modifiers) { return modifiers.split(","); @@ -146669,10 +147396,10 @@ var ts; } function getSymbolModifiers(typeChecker, symbol) { if (!symbol) { - return "" /* none */; + return "" /* ScriptElementKindModifier.none */; } var modifiers = new ts.Set(getNormalizedSymbolModifiers(symbol)); - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); if (resolvedSymbol !== symbol) { ts.forEach(getNormalizedSymbolModifiers(resolvedSymbol), function (modifier) { @@ -146680,10 +147407,10 @@ var ts; }); } } - if (symbol.flags & 16777216 /* Optional */) { - modifiers.add("optional" /* optionalModifier */); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + modifiers.add("optional" /* ScriptElementKindModifier.optionalModifier */); } - return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* none */; + return modifiers.size > 0 ? ts.arrayFrom(modifiers.values()).join(",") : "" /* ScriptElementKindModifier.none */; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location @@ -146694,41 +147421,41 @@ var ts; var documentation = []; var tags = []; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); - var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; + var symbolKind = semanticMeaning & 1 /* SemanticMeaning.Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* ScriptElementKind.unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); + var isThisExpression = location.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; var hasMultipleSignatures = false; - if (location.kind === 108 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(108 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 108 /* SyntaxKind.ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* ScriptElementKind.primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */ || symbolFlags & 32 /* SymbolFlags.Class */ || symbolFlags & 2097152 /* SymbolFlags.Alias */) { // If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor - if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) { + if (symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */) { var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; }); if (declaration) { switch (declaration.kind) { - case 172 /* GetAccessor */: - symbolKind = "getter" /* memberGetAccessorElement */; + case 172 /* SyntaxKind.GetAccessor */: + symbolKind = "getter" /* ScriptElementKind.memberGetAccessorElement */; break; - case 173 /* SetAccessor */: - symbolKind = "setter" /* memberSetAccessorElement */; + case 173 /* SyntaxKind.SetAccessor */: + symbolKind = "setter" /* ScriptElementKind.memberSetAccessorElement */; break; default: ts.Debug.assertNever(declaration); } } else { - symbolKind = "property" /* memberVariableElement */; + symbolKind = "property" /* ScriptElementKind.memberVariableElement */; } } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); - if (location.parent && location.parent.kind === 206 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -146748,7 +147475,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 209 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 209 /* SyntaxKind.NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 106 /* SyntaxKind.SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (signature && !ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -146756,21 +147483,21 @@ var ts; signature = allSignatures.length ? allSignatures[0] : undefined; } if (signature) { - if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { + if (useConstructSignatures && (symbolFlags & 32 /* SymbolFlags.Class */)) { // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - else if (symbolFlags & 2097152 /* Alias */) { - symbolKind = "alias" /* alias */; + else if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + symbolKind = "alias" /* ScriptElementKind.alias */; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -146779,29 +147506,29 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: + case "JSX attribute" /* ScriptElementKind.jsxAttribute */: + case "property" /* ScriptElementKind.memberVariableElement */: + case "var" /* ScriptElementKind.variableElement */: + case "const" /* ScriptElementKind.constElement */: + case "let" /* ScriptElementKind.letElement */: + case "parameter" /* ScriptElementKind.parameterElement */: + case "local var" /* ScriptElementKind.localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); - if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { - ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); + if (!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && type.symbol) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* SymbolFormatFlags.AllowAnyNodeKind */ | 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - if (signature.flags & 4 /* Abstract */) { - displayParts.push(ts.keywordPart(126 /* AbstractKeyword */)); + if (signature.flags & 4 /* SignatureFlags.Abstract */) { + displayParts.push(ts.keywordPart(126 /* SyntaxKind.AbstractKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); + addSignatureDisplayParts(signature, allSignatures, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */); break; default: // Just signature @@ -146811,31 +147538,31 @@ var ts; hasMultipleSignatures = allSignatures.length > 1; } } - else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 134 /* ConstructorKeyword */ && location.parent.kind === 171 /* Constructor */)) { // At constructor keyword of constructor declaration + else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* SymbolFlags.Accessor */)) || // name of function declaration + (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ && location.parent.kind === 171 /* SyntaxKind.Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 134 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + return declaration === (location.kind === 134 /* SyntaxKind.ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 171 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 171 /* Constructor */) { + if (functionDeclaration_1.kind === 171 /* SyntaxKind.Constructor */) { // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = "constructor" /* ScriptElementKind.constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* CallSignature */ && - !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 174 /* SyntaxKind.CallSignature */ && + !(type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ || type.symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */) ? type.symbol : symbol, symbolKind); } if (signature) { addSignatureDisplayParts(signature, allSignatures); @@ -146845,63 +147572,63 @@ var ts; } } } - if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { + if (symbolFlags & 32 /* SymbolFlags.Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 226 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 226 /* SyntaxKind.ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushSymbolKind("local class" /* localClassElement */); + pushSymbolKind("local class" /* ScriptElementKind.localClassElement */); } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(84 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(84 /* SyntaxKind.ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 64 /* SymbolFlags.Interface */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(118 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(118 /* SyntaxKind.InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 524288 /* SymbolFlags.TypeAlias */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, ts.isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* TypeFormatFlags.InTypeAlias */)); } - if (symbolFlags & 384 /* Enum */) { + if (symbolFlags & 384 /* SymbolFlags.Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(85 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(85 /* SyntaxKind.ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(92 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(92 /* SyntaxKind.EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if (symbolFlags & 1536 /* Module */ && !isThisExpression) { + if (symbolFlags & 1536 /* SymbolFlags.Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 261 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 142 /* NamespaceKeyword */ : 141 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 261 /* SyntaxKind.ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 79 /* SyntaxKind.Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 142 /* SyntaxKind.NamespaceKeyword */ : 141 /* SyntaxKind.ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } - if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 262144 /* SymbolFlags.TypeParameter */) && (semanticMeaning & 2 /* SemanticMeaning.Type */)) { prefixNextMeaning(); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -146912,7 +147639,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 163 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -146920,21 +147647,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 175 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(103 /* NewKeyword */)); + if (declaration.kind === 175 /* SyntaxKind.ConstructSignature */) { + displayParts.push(ts.keywordPart(103 /* SyntaxKind.NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 174 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 174 /* SyntaxKind.CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 259 /* TypeAliasDeclaration */) { + else if (declaration.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(152 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(152 /* SyntaxKind.TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -146942,22 +147669,22 @@ var ts; } } } - if (symbolFlags & 8 /* EnumMember */) { - symbolKind = "enum member" /* enumMemberElement */; + if (symbolFlags & 8 /* SymbolFlags.EnumMember */) { + symbolKind = "enum member" /* ScriptElementKind.enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; - if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* EnumMember */) { + if ((declaration === null || declaration === void 0 ? void 0 : declaration.kind) === 299 /* SyntaxKind.EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } } } // don't use symbolFlags since getAliasedSymbol requires the flag on the symbol itself - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { prefixNextMeaning(); if (!hasAddedSymbolInfo) { var resolvedSymbol = typeChecker.getAliasedSymbol(symbol); @@ -146966,7 +147693,7 @@ var ts; var declarationName = ts.getNameOfDeclaration(resolvedNode); if (declarationName) { var isExternalModuleDeclaration = ts.isModuleWithStringLiteralName(resolvedNode) && - ts.hasSyntacticModifier(resolvedNode, 2 /* Ambient */); + ts.hasSyntacticModifier(resolvedNode, 2 /* ModifierFlags.Ambient */); var shouldUseAliasName = symbol.name !== "default" && !isExternalModuleDeclaration; var resolvedInfo = getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, resolvedSymbol, ts.getSourceFileOfNode(resolvedNode), resolvedNode, declarationName, semanticMeaning, shouldUseAliasName ? symbol : resolvedSymbol); displayParts.push.apply(displayParts, resolvedInfo.displayParts); @@ -146982,42 +147709,42 @@ var ts; } if (symbol.declarations) { switch (symbol.declarations[0].kind) { - case 264 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(142 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(142 /* SyntaxKind.NamespaceKeyword */)); break; - case 271 /* ExportAssignment */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 271 /* SyntaxKind.ExportAssignment */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* EqualsToken */ : 88 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 63 /* SyntaxKind.EqualsToken */ : 88 /* SyntaxKind.DefaultKeyword */)); break; - case 275 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(93 /* ExportKeyword */)); + case 275 /* SyntaxKind.ExportSpecifier */: + displayParts.push(ts.keywordPart(93 /* SyntaxKind.ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(100 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(100 /* SyntaxKind.ImportKeyword */)); } } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(146 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(146 /* SyntaxKind.RequireKeyword */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(63 /* EqualsToken */)); + displayParts.push(ts.operatorPart(63 /* SyntaxKind.EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -147027,30 +147754,30 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "" /* unknown */) { + if (symbolKind !== "" /* ScriptElementKind.unknown */) { if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(108 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(108 /* SyntaxKind.ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === "property" /* memberVariableElement */ || - symbolKind === "getter" /* memberGetAccessorElement */ || - symbolKind === "setter" /* memberSetAccessorElement */ || - symbolKind === "JSX attribute" /* jsxAttribute */ || - symbolFlags & 3 /* Variable */ || - symbolKind === "local var" /* localVariableElement */ || + if (symbolKind === "property" /* ScriptElementKind.memberVariableElement */ || + symbolKind === "getter" /* ScriptElementKind.memberGetAccessorElement */ || + symbolKind === "setter" /* ScriptElementKind.memberSetAccessorElement */ || + symbolKind === "JSX attribute" /* ScriptElementKind.jsxAttribute */ || + symbolFlags & 3 /* SymbolFlags.Variable */ || + symbolKind === "local var" /* ScriptElementKind.localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(58 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* SyntaxKind.ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially - if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { + if (type.symbol && type.symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeNode(4 /* EmitHint.Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -147061,17 +147788,17 @@ var ts; var labelDecl = symbol.target.tupleLabelDeclaration; ts.Debug.assertNode(labelDecl.name, ts.isIdentifier); displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textPart(ts.idText(labelDecl.name))); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } } - else if (symbolFlags & 16 /* Function */ || - symbolFlags & 8192 /* Method */ || - symbolFlags & 16384 /* Constructor */ || - symbolFlags & 131072 /* Signature */ || - symbolFlags & 98304 /* Accessor */ || - symbolKind === "method" /* memberFunctionElement */) { + else if (symbolFlags & 16 /* SymbolFlags.Function */ || + symbolFlags & 8192 /* SymbolFlags.Method */ || + symbolFlags & 16384 /* SymbolFlags.Constructor */ || + symbolFlags & 131072 /* SymbolFlags.Signature */ || + symbolFlags & 98304 /* SymbolFlags.Accessor */ || + symbolKind === "method" /* ScriptElementKind.memberFunctionElement */) { var allSignatures = type.getNonNullableType().getCallSignatures(); if (allSignatures.length) { addSignatureDisplayParts(allSignatures[0], allSignatures); @@ -147087,14 +147814,14 @@ var ts; if (documentation.length === 0 && !hasMultipleSignatures) { documentation = symbol.getContextualDocumentationComment(enclosingDeclaration, typeChecker); } - if (documentation.length === 0 && symbolFlags & 4 /* Property */) { + if (documentation.length === 0 && symbolFlags & 4 /* SymbolFlags.Property */) { // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SourceFile */; })) { + if (symbol.parent && symbol.declarations && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 305 /* SyntaxKind.SourceFile */; })) { for (var _i = 0, _b = symbol.declarations; _i < _b.length; _i++) { var declaration = _b[_i]; - if (!declaration.parent || declaration.parent.kind !== 221 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -147145,23 +147872,23 @@ var ts; } function addAliasPrefixIfNecessary() { if (alias) { - pushSymbolKind("alias" /* alias */); + pushSymbolKind("alias" /* ScriptElementKind.alias */); displayParts.push(ts.spacePart()); } } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(101 /* InKeyword */)); + displayParts.push(ts.keywordPart(101 /* SyntaxKind.InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { if (alias && symbolToDisplay === symbol) { symbolToDisplay = alias; } - var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); + var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */ | 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); - if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); + if (symbol.flags & 16777216 /* SymbolFlags.Optional */) { + displayParts.push(ts.punctuationPart(57 /* SyntaxKind.QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -147176,31 +147903,31 @@ var ts; } function pushSymbolKind(symbolKind) { switch (symbolKind) { - case "var" /* variableElement */: - case "function" /* functionElement */: - case "let" /* letElement */: - case "const" /* constElement */: - case "constructor" /* constructorImplementationElement */: + case "var" /* ScriptElementKind.variableElement */: + case "function" /* ScriptElementKind.functionElement */: + case "let" /* ScriptElementKind.letElement */: + case "const" /* ScriptElementKind.constElement */: + case "constructor" /* ScriptElementKind.constructorImplementationElement */: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); return; } } function addSignatureDisplayParts(signature, allSignatures, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* TypeFormatFlags.WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(39 /* PlusToken */)); + displayParts.push(ts.punctuationPart(20 /* SyntaxKind.OpenParenToken */)); + displayParts.push(ts.operatorPart(39 /* SyntaxKind.PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(21 /* SyntaxKind.CloseParenToken */)); } documentation = signature.getDocumentationComment(typeChecker); tags = signature.getJsDocTags(); @@ -147212,7 +147939,7 @@ var ts; function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration, symbolDisplayNodeBuilderFlags); - getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); + getPrinter().writeList(53776 /* ListFormat.TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); } @@ -147224,16 +147951,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 213 /* FunctionExpression */) { + if (declaration.kind === 213 /* SyntaxKind.FunctionExpression */) { return true; } - if (declaration.kind !== 254 /* VariableDeclaration */ && declaration.kind !== 256 /* FunctionDeclaration */) { + if (declaration.kind !== 254 /* SyntaxKind.VariableDeclaration */ && declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 305 /* SourceFile */ || parent.kind === 262 /* ModuleBlock */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ || parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return false; } } @@ -147342,7 +148069,7 @@ var ts; commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); }); options = ts.cloneCompilerOptions(options); - var _loop_9 = function (opt) { + var _loop_8 = function (opt) { if (!ts.hasProperty(options, opt.name)) { return "continue"; } @@ -147361,7 +148088,7 @@ var ts; }; for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) { var opt = commandLineOptionsStringToEnum_1[_i]; - _loop_9(opt); + _loop_8(opt); } return options; } @@ -147438,8 +148165,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 18 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 19 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 18 /* SyntaxKind.OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 19 /* SyntaxKind.CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -147457,8 +148184,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - var standardScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); - var jsxScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); + var standardScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); + var jsxScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 1 /* LanguageVariant.JSX */); var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -147470,7 +148197,7 @@ var ts; ScanAction[ScanAction["RescanJsxAttributeValue"] = 6] = "RescanJsxAttributeValue"; })(ScanAction || (ScanAction = {})); function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { - var scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + var scanner = languageVariant === 1 /* LanguageVariant.JSX */ ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -147498,7 +148225,7 @@ var ts; lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* NewLineTrivia */; + wasNewLine = !!trailingTrivia && ts.last(trailingTrivia).kind === 4 /* SyntaxKind.NewLineTrivia */; } else { scanner.scan(); @@ -147526,11 +148253,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 33 /* GreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return true; } return false; @@ -147538,12 +148265,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 285 /* JsxAttribute */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 285 /* SyntaxKind.JsxAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 79 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 79 /* SyntaxKind.Identifier */; } } return false; @@ -147552,29 +148279,29 @@ var ts; return ts.isJsxText(node); } function shouldRescanSlashToken(container) { - return container.kind === 13 /* RegularExpressionLiteral */; + return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 16 /* TemplateMiddle */ || - container.kind === 17 /* TemplateTail */; + return container.kind === 16 /* SyntaxKind.TemplateMiddle */ || + container.kind === 17 /* SyntaxKind.TemplateTail */; } function shouldRescanJsxAttributeValue(node) { return node.parent && ts.isJsxAttribute(node.parent) && node.parent.initializer === node; } function startsWithSlashToken(t) { - return t === 43 /* SlashToken */ || t === 68 /* SlashEqualsToken */; + return t === 43 /* SyntaxKind.SlashToken */ || t === 68 /* SyntaxKind.SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : - shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : - shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : - shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : - shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : - shouldRescanJsxAttributeValue(n) ? 6 /* RescanJsxAttributeValue */ : - 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* ScanAction.RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* ScanAction.RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* ScanAction.RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* ScanAction.RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* ScanAction.RescanJsxText */ : + shouldRescanJsxAttributeValue(n) ? 6 /* ScanAction.RescanJsxAttributeValue */ : + 0 /* ScanAction.Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -147606,7 +148333,7 @@ var ts; trailingTrivia = []; } trailingTrivia.push(trivia); - if (currentToken === 4 /* NewLineTrivia */) { + if (currentToken === 4 /* SyntaxKind.NewLineTrivia */) { // move past new line scanner.scan(); break; @@ -147617,40 +148344,40 @@ var ts; } function getNextToken(n, expectedScanAction) { var token = scanner.getToken(); - lastScanAction = 0 /* Scan */; + lastScanAction = 0 /* ScanAction.Scan */; switch (expectedScanAction) { - case 1 /* RescanGreaterThanToken */: - if (token === 31 /* GreaterThanToken */) { - lastScanAction = 1 /* RescanGreaterThanToken */; + case 1 /* ScanAction.RescanGreaterThanToken */: + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + lastScanAction = 1 /* ScanAction.RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 2 /* RescanSlashToken */: + case 2 /* ScanAction.RescanSlashToken */: if (startsWithSlashToken(token)) { - lastScanAction = 2 /* RescanSlashToken */; + lastScanAction = 2 /* ScanAction.RescanSlashToken */; var newToken = scanner.reScanSlashToken(); ts.Debug.assert(n.kind === newToken); return newToken; } break; - case 3 /* RescanTemplateToken */: - if (token === 19 /* CloseBraceToken */) { - lastScanAction = 3 /* RescanTemplateToken */; + case 3 /* ScanAction.RescanTemplateToken */: + if (token === 19 /* SyntaxKind.CloseBraceToken */) { + lastScanAction = 3 /* ScanAction.RescanTemplateToken */; return scanner.reScanTemplateToken(/* isTaggedTemplate */ false); } break; - case 4 /* RescanJsxIdentifier */: - lastScanAction = 4 /* RescanJsxIdentifier */; + case 4 /* ScanAction.RescanJsxIdentifier */: + lastScanAction = 4 /* ScanAction.RescanJsxIdentifier */; return scanner.scanJsxIdentifier(); - case 5 /* RescanJsxText */: - lastScanAction = 5 /* RescanJsxText */; + case 5 /* ScanAction.RescanJsxText */: + lastScanAction = 5 /* ScanAction.RescanJsxText */; return scanner.reScanJsxToken(/* allowMultilineJsxText */ false); - case 6 /* RescanJsxAttributeValue */: - lastScanAction = 6 /* RescanJsxAttributeValue */; + case 6 /* ScanAction.RescanJsxAttributeValue */: + lastScanAction = 6 /* ScanAction.RescanJsxAttributeValue */; return scanner.reScanJsxAttributeValue(); - case 0 /* Scan */: + case 0 /* ScanAction.Scan */: break; default: ts.Debug.assertNever(expectedScanAction); @@ -147659,15 +148386,15 @@ var ts; } function readEOFTokenRange() { ts.Debug.assert(isOnEOF()); - return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* SyntaxKind.EndOfFileToken */); } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); + return current !== 1 /* SyntaxKind.EndOfFileToken */ && !ts.isTrivia(current); } function isOnEOF() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); - return current === 1 /* EndOfFileToken */; + return current === 1 /* SyntaxKind.EndOfFileToken */; } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, @@ -147734,8 +148461,8 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 160 /* LastToken */; token++) { - if (token !== 1 /* EndOfFileToken */) { + for (var token = 0 /* SyntaxKind.FirstToken */; token <= 160 /* SyntaxKind.LastToken */; token++) { + if (token !== 1 /* SyntaxKind.EndOfFileToken */) { allTokens.push(token); } } @@ -147747,263 +148474,263 @@ var ts; return { tokens: allTokens.filter(function (t) { return !tokens.some(function (t2) { return t2 === t; }); }), isSpecific: false }; } var anyToken = { tokens: allTokens, isSpecific: false }; - var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* MultiLineCommentTrivia */], false)); - var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* EndOfFileToken */], false)); - var keywords = tokenRangeFromRange(81 /* FirstKeyword */, 160 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 78 /* LastBinaryOperator */); - var binaryKeywordOperators = [101 /* InKeyword */, 102 /* InstanceOfKeyword */, 160 /* OfKeyword */, 127 /* AsKeyword */, 139 /* IsKeyword */]; - var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; + var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [3 /* SyntaxKind.MultiLineCommentTrivia */], false)); + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArray(__spreadArray([], allTokens, true), [1 /* SyntaxKind.EndOfFileToken */], false)); + var keywords = tokenRangeFromRange(81 /* SyntaxKind.FirstKeyword */, 160 /* SyntaxKind.LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* SyntaxKind.FirstBinaryOperator */, 78 /* SyntaxKind.LastBinaryOperator */); + var binaryKeywordOperators = [101 /* SyntaxKind.InKeyword */, 102 /* SyntaxKind.InstanceOfKeyword */, 160 /* SyntaxKind.OfKeyword */, 127 /* SyntaxKind.AsKeyword */, 139 /* SyntaxKind.IsKeyword */]; + var unaryPrefixOperators = [45 /* SyntaxKind.PlusPlusToken */, 46 /* SyntaxKind.MinusMinusToken */, 54 /* SyntaxKind.TildeToken */, 53 /* SyntaxKind.ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 79 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */ + 8 /* SyntaxKind.NumericLiteral */, 9 /* SyntaxKind.BigIntLiteral */, 79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, + 22 /* SyntaxKind.OpenBracketToken */, 18 /* SyntaxKind.OpenBraceToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */ ]; - var unaryPreincrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostincrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var unaryPredecrementExpressions = [79 /* Identifier */, 20 /* OpenParenToken */, 108 /* ThisKeyword */, 103 /* NewKeyword */]; - var unaryPostdecrementExpressions = [79 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 103 /* NewKeyword */]; - var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArray([79 /* Identifier */], ts.typeKeywords, true); + var unaryPreincrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostincrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPredecrementExpressions = [79 /* SyntaxKind.Identifier */, 20 /* SyntaxKind.OpenParenToken */, 108 /* SyntaxKind.ThisKeyword */, 103 /* SyntaxKind.NewKeyword */]; + var unaryPostdecrementExpressions = [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */, 23 /* SyntaxKind.CloseBracketToken */, 103 /* SyntaxKind.NewKeyword */]; + var comments = [2 /* SyntaxKind.SingleLineCommentTrivia */, 3 /* SyntaxKind.MultiLineCommentTrivia */]; + var typeNames = __spreadArray([79 /* SyntaxKind.Identifier */], ts.typeKeywords, true); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* Identifier */, 3 /* MultiLineCommentTrivia */, 84 /* ClassKeyword */, 93 /* ExportKeyword */, 100 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([79 /* SyntaxKind.Identifier */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 84 /* SyntaxKind.ClassKeyword */, 93 /* SyntaxKind.ExportKeyword */, 100 /* SyntaxKind.ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 90 /* DoKeyword */, 111 /* TryKeyword */, 96 /* FinallyKeyword */, 91 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* SyntaxKind.CloseParenToken */, 3 /* SyntaxKind.MultiLineCommentTrivia */, 90 /* SyntaxKind.DoKeyword */, 111 /* SyntaxKind.TryKeyword */, 96 /* SyntaxKind.FinallyKeyword */, 91 /* SyntaxKind.ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), - rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), - rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SyntaxKind.SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* RuleAction.StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* SyntaxKind.ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterColon", 58 /* SyntaxKind.ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* SyntaxKind.QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* RuleAction.InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenImportParenInImportType", 100 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterQuestionMark", 57 /* SyntaxKind.QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* SyntaxKind.DotToken */, 28 /* SyntaxKind.QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 100 /* SyntaxKind.ImportKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* RuleAction.DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* SyntaxKind.PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* SyntaxKind.MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isNotStatementConditionContext], 16 /* RuleAction.DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* SyntaxKind.PlusPlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* SyntaxKind.PlusToken */, 39 /* SyntaxKind.PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* SyntaxKind.PlusToken */, 45 /* SyntaxKind.PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* SyntaxKind.MinusMinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* SyntaxKind.MinusToken */, 40 /* SyntaxKind.MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* SyntaxKind.MinusToken */, 46 /* SyntaxKind.MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, [27 /* SyntaxKind.CommaToken */, 26 /* SyntaxKind.SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* SyntaxKind.CloseBraceToken */, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), + rule("SpaceAfterCloseBrace", 19 /* SyntaxKind.CloseBraceToken */, anyTokenExcept(21 /* SyntaxKind.CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* RuleAction.InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 91 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 115 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* SyntaxKind.CloseBraceToken */, 91 /* SyntaxKind.ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* SyntaxKind.CloseBraceToken */, 115 /* SyntaxKind.WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), - rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 79 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), - rule("SpaceAfterFunctionInFuncDecl", 98 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterConditionalClosingParen", 21 /* SyntaxKind.CloseParenToken */, 22 /* SyntaxKind.OpenBracketToken */, [isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* SyntaxKind.AsteriskToken */, 79 /* SyntaxKind.Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 98 /* SyntaxKind.FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* RuleAction.InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [136 /* GetKeyword */, 149 /* SetKeyword */], 79 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), - rule("NoSpaceBetweenReturnAndSemicolon", 105 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterCertainKeywords", [113 /* VarKeyword */, 109 /* ThrowKeyword */, 103 /* NewKeyword */, 89 /* DeleteKeyword */, 105 /* ReturnKeyword */, 112 /* TypeOfKeyword */, 132 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterLetConstInVariableDeclaration", [119 /* LetKeyword */, 85 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), + rule("SpaceAfterGetSetInMember", [136 /* SyntaxKind.GetKeyword */, 149 /* SyntaxKind.SetKeyword */], 79 /* SyntaxKind.Identifier */, [isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [125 /* SyntaxKind.YieldKeyword */, 41 /* SyntaxKind.AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 105 /* SyntaxKind.ReturnKeyword */, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterCertainKeywords", [113 /* SyntaxKind.VarKeyword */, 109 /* SyntaxKind.ThrowKeyword */, 103 /* SyntaxKind.NewKeyword */, 89 /* SyntaxKind.DeleteKeyword */, 105 /* SyntaxKind.ReturnKeyword */, 112 /* SyntaxKind.TypeOfKeyword */, 132 /* SyntaxKind.AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [119 /* SyntaxKind.LetKeyword */, 85 /* SyntaxKind.ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* RuleAction.DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterVoidOperator", 114 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterVoidOperator", 114 /* SyntaxKind.VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* RuleAction.InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 131 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* AsyncKeyword */, [98 /* FunctionKeyword */, 79 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndOpenParen", 131 /* SyntaxKind.AsyncKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 131 /* SyntaxKind.AsyncKeyword */, [98 /* SyntaxKind.FunctionKeyword */, 79 /* SyntaxKind.Identifier */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [79 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenTagAndTemplateString", [79 /* SyntaxKind.Identifier */, 21 /* SyntaxKind.CloseParenToken */], [14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, 15 /* SyntaxKind.TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 79 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterEqualInJsxAttribute", 63 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeJsxAttribute", anyToken, 79 /* SyntaxKind.Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SyntaxKind.SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SyntaxKind.SlashToken */, 31 /* SyntaxKind.GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 63 /* SyntaxKind.EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 63 /* SyntaxKind.EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [141 /* ModuleKeyword */, 146 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterModuleImport", [141 /* SyntaxKind.ModuleKeyword */, 146 /* SyntaxKind.RequireKeyword */], 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 126 /* AbstractKeyword */, - 84 /* ClassKeyword */, - 135 /* DeclareKeyword */, - 88 /* DefaultKeyword */, - 92 /* EnumKeyword */, - 93 /* ExportKeyword */, - 94 /* ExtendsKeyword */, - 136 /* GetKeyword */, - 117 /* ImplementsKeyword */, - 100 /* ImportKeyword */, - 118 /* InterfaceKeyword */, - 141 /* ModuleKeyword */, - 142 /* NamespaceKeyword */, - 121 /* PrivateKeyword */, - 123 /* PublicKeyword */, - 122 /* ProtectedKeyword */, - 145 /* ReadonlyKeyword */, - 149 /* SetKeyword */, - 124 /* StaticKeyword */, - 152 /* TypeKeyword */, - 156 /* FromKeyword */, - 140 /* KeyOfKeyword */, - 137 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* ExtendsKeyword */, 117 /* ImplementsKeyword */, 156 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 135 /* SyntaxKind.DeclareKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 92 /* SyntaxKind.EnumKeyword */, + 93 /* SyntaxKind.ExportKeyword */, + 94 /* SyntaxKind.ExtendsKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 117 /* SyntaxKind.ImplementsKeyword */, + 100 /* SyntaxKind.ImportKeyword */, + 118 /* SyntaxKind.InterfaceKeyword */, + 141 /* SyntaxKind.ModuleKeyword */, + 142 /* SyntaxKind.NamespaceKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 145 /* SyntaxKind.ReadonlyKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 152 /* SyntaxKind.TypeKeyword */, + 156 /* SyntaxKind.FromKeyword */, + 140 /* SyntaxKind.KeyOfKeyword */, + 137 /* SyntaxKind.InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [94 /* SyntaxKind.ExtendsKeyword */, 117 /* SyntaxKind.ImplementsKeyword */, 156 /* SyntaxKind.FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), + rule("SpaceAfterModuleName", 10 /* SyntaxKind.StringLiteral */, 18 /* SyntaxKind.OpenBraceToken */, [isModuleDeclContext], 4 /* RuleAction.InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeArrow", anyToken, 38 /* SyntaxKind.EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterArrow", 38 /* SyntaxKind.EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 79 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEllipsis", 25 /* SyntaxKind.DotDotDotToken */, 79 /* SyntaxKind.Identifier */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* SyntaxKind.QuestionToken */, [21 /* SyntaxKind.CloseParenToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* RuleAction.DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* RuleAction.DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* SyntaxKind.CloseParenToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* SyntaxKind.LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* SyntaxKind.GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* SyntaxKind.GreaterThanToken */, [20 /* SyntaxKind.OpenParenToken */, 22 /* SyntaxKind.OpenBracketToken */, 31 /* SyntaxKind.GreaterThanToken */, 27 /* SyntaxKind.CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* RuleAction.DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 79 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeAt", [21 /* SyntaxKind.CloseParenToken */, 79 /* SyntaxKind.Identifier */], 59 /* SyntaxKind.AtToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAt", 59 /* SyntaxKind.AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 126 /* AbstractKeyword */, - 79 /* Identifier */, - 93 /* ExportKeyword */, - 88 /* DefaultKeyword */, - 84 /* ClassKeyword */, - 124 /* StaticKeyword */, - 123 /* PublicKeyword */, - 121 /* PrivateKeyword */, - 122 /* ProtectedKeyword */, - 136 /* GetKeyword */, - 149 /* SetKeyword */, - 22 /* OpenBracketToken */, - 41 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + 126 /* SyntaxKind.AbstractKeyword */, + 79 /* SyntaxKind.Identifier */, + 93 /* SyntaxKind.ExportKeyword */, + 88 /* SyntaxKind.DefaultKeyword */, + 84 /* SyntaxKind.ClassKeyword */, + 124 /* SyntaxKind.StaticKeyword */, + 123 /* SyntaxKind.PublicKeyword */, + 121 /* SyntaxKind.PrivateKeyword */, + 122 /* SyntaxKind.ProtectedKeyword */, + 136 /* SyntaxKind.GetKeyword */, + 149 /* SyntaxKind.SetKeyword */, + 22 /* SyntaxKind.OpenBracketToken */, + 41 /* SyntaxKind.AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* SyntaxKind.ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 103 /* SyntaxKind.NewKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* SyntaxKind.LessThanToken */, 29 /* SyntaxKind.LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterConstructor", 134 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), + rule("SpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterConstructor", 134 /* SyntaxKind.ConstructorKeyword */, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterComma", 27 /* SyntaxKind.CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* RuleAction.DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [98 /* SyntaxKind.FunctionKeyword */, 41 /* SyntaxKind.AsteriskToken */], 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* SyntaxKind.OpenParenToken */, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* SyntaxKind.OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* SyntaxKind.CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* SyntaxKind.OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* SyntaxKind.CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert a space after opening and before closing empty brace brackets - rule("SpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* InsertSpace */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* DeleteSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* SyntaxKind.TemplateHead */, 16 /* SyntaxKind.TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxTextContext], 16 /* RuleAction.DeleteSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* SyntaxKind.TemplateMiddle */, 17 /* SyntaxKind.TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* SyntaxKind.OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* SyntaxKind.CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* RuleAction.DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* RuleAction.DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* SyntaxKind.OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* RuleAction.DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), - rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), - rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* QuestionToken */, 58 /* ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), - rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), - rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* RuleAction.InsertNewLine */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* SyntaxKind.GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* RuleAction.InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, [57 /* SyntaxKind.QuestionToken */, 58 /* SyntaxKind.ColonToken */], [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* RuleAction.DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* RuleAction.DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* RuleAction.InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SyntaxKind.SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* SyntaxKind.OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* RuleAction.InsertSpace */, 1 /* RuleFlags.CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* SyntaxKind.CommaToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* AsyncKeyword */, 82 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(131 /* SyntaxKind.AsyncKeyword */, 82 /* SyntaxKind.CaseKeyword */), 22 /* SyntaxKind.OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* RuleAction.DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* SyntaxKind.CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* RuleAction.DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SyntaxKind.SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 97 /* ForKeyword */, 132 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenForAndAwaitKeyword", 97 /* SyntaxKind.ForKeyword */, 132 /* SyntaxKind.AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 90 /* DoKeyword */, 91 /* ElseKeyword */, 82 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), + rule("SpaceBetweenStatements", [21 /* SyntaxKind.CloseParenToken */, 90 /* SyntaxKind.DoKeyword */, 91 /* SyntaxKind.ElseKeyword */, 82 /* SyntaxKind.CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* RuleAction.InsertSpace */), // This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryCatchFinally", [111 /* TryKeyword */, 83 /* CatchKeyword */, 96 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterTryCatchFinally", [111 /* SyntaxKind.TryKeyword */, 83 /* SyntaxKind.CatchKeyword */, 96 /* SyntaxKind.FinallyKeyword */], 18 /* SyntaxKind.OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* RuleAction.InsertSpace */), ]; return __spreadArray(__spreadArray(__spreadArray([], highPriorityCommonRules, true), userConfigurableRules, true), lowPriorityCommonRules, true); } @@ -148021,7 +148748,7 @@ var ts; * @param flags whether the rule deletes a line or not, defaults to no-op */ function rule(debugName, left, right, context, action, flags) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* RuleFlags.None */; } return { leftTokenRange: toTokenRange(left), rightTokenRange: toTokenRange(right), rule: { debugName: debugName, context: context, action: action, flags: flags } }; } function tokenRangeFrom(tokens) { @@ -148062,54 +148789,54 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 242 /* ForStatement */; + return context.contextNode.kind === 242 /* SyntaxKind.ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 221 /* BinaryExpression */: - return context.contextNode.operatorToken.kind !== 27 /* CommaToken */; - case 222 /* ConditionalExpression */: - case 189 /* ConditionalType */: - case 229 /* AsExpression */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 177 /* TypePredicate */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 221 /* SyntaxKind.BinaryExpression */: + return context.contextNode.operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; + case 222 /* SyntaxKind.ConditionalExpression */: + case 189 /* SyntaxKind.ConditionalType */: + case 229 /* SyntaxKind.AsExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 177 /* SyntaxKind.TypePredicate */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // equals in type X = ... // falls through - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // equal in import a = module('a'); // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // equal in export = 1 // falls through - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // equal in let a = 0 // falls through - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // equal in p = 0 // falls through - case 164 /* Parameter */: - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 164 /* SyntaxKind.Parameter */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // "in" keyword in for (let x in []) { } - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // "in" keyword in [P in keyof T]: T[P] // falls through - case 163 /* TypeParameter */: - return context.currentTokenSpan.kind === 101 /* InKeyword */ || context.nextTokenSpan.kind === 101 /* InKeyword */ || context.currentTokenSpan.kind === 63 /* EqualsToken */ || context.nextTokenSpan.kind === 63 /* EqualsToken */; + case 163 /* SyntaxKind.TypeParameter */: + return context.currentTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.nextTokenSpan.kind === 101 /* SyntaxKind.InKeyword */ || context.currentTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */ || context.nextTokenSpan.kind === 63 /* SyntaxKind.EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 244 /* ForOfStatement */: - return context.currentTokenSpan.kind === 160 /* OfKeyword */ || context.nextTokenSpan.kind === 160 /* OfKeyword */; + case 244 /* SyntaxKind.ForOfStatement */: + return context.currentTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */ || context.nextTokenSpan.kind === 160 /* SyntaxKind.OfKeyword */; } return false; } @@ -148121,22 +148848,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 167 /* PropertyDeclaration */ || - contextKind === 166 /* PropertySignature */ || - contextKind === 164 /* Parameter */ || - contextKind === 254 /* VariableDeclaration */ || + return contextKind === 167 /* SyntaxKind.PropertyDeclaration */ || + contextKind === 166 /* SyntaxKind.PropertySignature */ || + contextKind === 164 /* SyntaxKind.Parameter */ || + contextKind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 222 /* ConditionalExpression */ || - context.contextNode.kind === 189 /* ConditionalType */; + return context.contextNode.kind === 222 /* SyntaxKind.ConditionalExpression */ || + context.contextNode.kind === 189 /* SyntaxKind.ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 201 /* ObjectBindingPattern */ || - context.contextNode.kind === 195 /* MappedType */ || + return context.contextNode.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || + context.contextNode.kind === 195 /* SyntaxKind.MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -148162,34 +148889,34 @@ var ts; return true; } switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 205 /* ObjectLiteralExpression */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 262 /* SyntaxKind.ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: // falls through - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // case SyntaxKind.MethodSignature: // falls through - case 174 /* CallSignature */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: // falls through - case 258 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + case 258 /* SyntaxKind.InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -148198,40 +148925,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 256 /* FunctionDeclaration */ || context.contextNode.kind === 213 /* FunctionExpression */; + return context.contextNode.kind === 256 /* SyntaxKind.FunctionDeclaration */ || context.contextNode.kind === 213 /* SyntaxKind.FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 182 /* TypeLiteral */: - case 261 /* ModuleDeclaration */: - case 272 /* ExportDeclaration */: - case 273 /* NamedExports */: - case 266 /* ImportDeclaration */: - case 269 /* NamedImports */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 273 /* SyntaxKind.NamedExports */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 269 /* SyntaxKind.NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 292 /* CatchClause */: - case 262 /* ModuleBlock */: - case 249 /* SwitchStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 292 /* SyntaxKind.CatchClause */: + case 262 /* SyntaxKind.ModuleBlock */: + case 249 /* SyntaxKind.SwitchStatement */: return true; - case 235 /* Block */: { + case 235 /* SyntaxKind.Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 214 /* ArrowFunction */ && blockParent.kind !== 213 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 214 /* SyntaxKind.ArrowFunction */ && blockParent.kind !== 213 /* SyntaxKind.FunctionExpression */) { return true; } } @@ -148240,71 +148967,71 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 248 /* WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 248 /* SyntaxKind.WithStatement */: // TODO // case SyntaxKind.ElseClause: // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 205 /* ObjectLiteralExpression */; + return context.contextNode.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 208 /* CallExpression */; + return context.contextNode.kind === 208 /* SyntaxKind.CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 209 /* NewExpression */; + return context.contextNode.kind === 209 /* SyntaxKind.NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); } function isPreviousTokenNotComma(context) { - return context.currentTokenSpan.kind !== 27 /* CommaToken */; + return context.currentTokenSpan.kind !== 27 /* SyntaxKind.CommaToken */; } function isNextTokenNotCloseBracket(context) { - return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 23 /* SyntaxKind.CloseBracketToken */; } function isNextTokenNotCloseParen(context) { - return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; + return context.nextTokenSpan.kind !== 21 /* SyntaxKind.CloseParenToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 214 /* ArrowFunction */; + return context.contextNode.kind === 214 /* SyntaxKind.ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 200 /* ImportType */; + return context.contextNode.kind === 200 /* SyntaxKind.ImportType */; } function isNonJsxSameLineTokenContext(context) { - return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; + return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxTextContext(context) { - return context.contextNode.kind !== 11 /* JsxText */; + return context.contextNode.kind !== 11 /* SyntaxKind.JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 278 /* JsxElement */ && context.contextNode.kind !== 282 /* JsxFragment */; + return context.contextNode.kind !== 278 /* SyntaxKind.JsxElement */ && context.contextNode.kind !== 282 /* SyntaxKind.JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 288 /* JsxExpression */ || context.contextNode.kind === 287 /* JsxSpreadAttribute */; + return context.contextNode.kind === 288 /* SyntaxKind.JsxExpression */ || context.contextNode.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 285 /* JsxAttribute */; + return context.nextTokenParent.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 285 /* JsxAttribute */; + return context.contextNode.kind === 285 /* SyntaxKind.JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 279 /* JsxSelfClosingElement */; + return context.contextNode.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -148319,45 +149046,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 255 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 255 /* SyntaxKind.VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { - return context.formattingRequestKind !== 2 /* FormatOnEnter */; + return context.formattingRequestKind !== 2 /* FormattingRequestKind.FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 261 /* ModuleDeclaration */; + return context.contextNode.kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 182 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 182 /* SyntaxKind.TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 175 /* ConstructSignature */; + return context.contextNode.kind === 175 /* SyntaxKind.ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { + if (token.kind !== 29 /* SyntaxKind.LessThanToken */ && token.kind !== 31 /* SyntaxKind.GreaterThanToken */) { return false; } switch (parent.kind) { - case 178 /* TypeReference */: - case 211 /* TypeAssertionExpression */: - case 259 /* TypeAliasDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return true; default: return false; @@ -148368,28 +149095,28 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 211 /* TypeAssertionExpression */; + return context.contextNode.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 114 /* VoidKeyword */ && context.currentTokenParent.kind === 217 /* VoidExpression */; + return context.currentTokenSpan.kind === 114 /* SyntaxKind.VoidKeyword */ && context.currentTokenParent.kind === 217 /* SyntaxKind.VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 224 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 224 /* SyntaxKind.YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 230 /* NonNullExpression */; + return context.contextNode.kind === 230 /* SyntaxKind.NonNullExpression */; } function isNotStatementConditionContext(context) { return !isStatementConditionContext(context); } function isStatementConditionContext(context) { switch (context.contextNode.kind) { - case 239 /* IfStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; default: return false; @@ -148411,15 +149138,15 @@ var ts; var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; if (startLine === endLine) { - return nextTokenKind === 19 /* CloseBraceToken */ - || nextTokenKind === 1 /* EndOfFileToken */; + return nextTokenKind === 19 /* SyntaxKind.CloseBraceToken */ + || nextTokenKind === 1 /* SyntaxKind.EndOfFileToken */; } - if (nextTokenKind === 234 /* SemicolonClassElement */ || - nextTokenKind === 26 /* SemicolonToken */) { + if (nextTokenKind === 234 /* SyntaxKind.SemicolonClassElement */ || + nextTokenKind === 26 /* SyntaxKind.SemicolonToken */) { return false; } - if (context.contextNode.kind === 258 /* InterfaceDeclaration */ || - context.contextNode.kind === 259 /* TypeAliasDeclaration */) { + if (context.contextNode.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + context.contextNode.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { // Can’t remove semicolon after `foo`; it would parse as a method declaration: // // interface I { @@ -148428,25 +149155,25 @@ var ts; // } return !ts.isPropertySignature(context.currentTokenParent) || !!context.currentTokenParent.type - || nextTokenKind !== 20 /* OpenParenToken */; + || nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */; } if (ts.isPropertyDeclaration(context.currentTokenParent)) { return !context.currentTokenParent.initializer; } - return context.currentTokenParent.kind !== 242 /* ForStatement */ - && context.currentTokenParent.kind !== 236 /* EmptyStatement */ - && context.currentTokenParent.kind !== 234 /* SemicolonClassElement */ - && nextTokenKind !== 22 /* OpenBracketToken */ - && nextTokenKind !== 20 /* OpenParenToken */ - && nextTokenKind !== 39 /* PlusToken */ - && nextTokenKind !== 40 /* MinusToken */ - && nextTokenKind !== 43 /* SlashToken */ - && nextTokenKind !== 13 /* RegularExpressionLiteral */ - && nextTokenKind !== 27 /* CommaToken */ - && nextTokenKind !== 223 /* TemplateExpression */ - && nextTokenKind !== 15 /* TemplateHead */ - && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ - && nextTokenKind !== 24 /* DotToken */; + return context.currentTokenParent.kind !== 242 /* SyntaxKind.ForStatement */ + && context.currentTokenParent.kind !== 236 /* SyntaxKind.EmptyStatement */ + && context.currentTokenParent.kind !== 234 /* SyntaxKind.SemicolonClassElement */ + && nextTokenKind !== 22 /* SyntaxKind.OpenBracketToken */ + && nextTokenKind !== 20 /* SyntaxKind.OpenParenToken */ + && nextTokenKind !== 39 /* SyntaxKind.PlusToken */ + && nextTokenKind !== 40 /* SyntaxKind.MinusToken */ + && nextTokenKind !== 43 /* SyntaxKind.SlashToken */ + && nextTokenKind !== 13 /* SyntaxKind.RegularExpressionLiteral */ + && nextTokenKind !== 27 /* SyntaxKind.CommaToken */ + && nextTokenKind !== 223 /* SyntaxKind.TemplateExpression */ + && nextTokenKind !== 15 /* SyntaxKind.TemplateHead */ + && nextTokenKind !== 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* SyntaxKind.DotToken */; } function isSemicolonInsertionContext(context) { return ts.positionIsASICandidate(context.currentTokenSpan.end, context.currentTokenParent, context.sourceFile); @@ -148475,17 +149202,17 @@ var ts; */ function getRuleActionExclusion(ruleAction) { var mask = 0; - if (ruleAction & 1 /* StopProcessingSpaceActions */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 1 /* RuleAction.StopProcessingSpaceActions */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 2 /* StopProcessingTokenActions */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 2 /* RuleAction.StopProcessingTokenActions */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } - if (ruleAction & 28 /* ModifySpaceAction */) { - mask |= 28 /* ModifySpaceAction */; + if (ruleAction & 28 /* RuleAction.ModifySpaceAction */) { + mask |= 28 /* RuleAction.ModifySpaceAction */; } - if (ruleAction & 96 /* ModifyTokenAction */) { - mask |= 96 /* ModifyTokenAction */; + if (ruleAction & 96 /* RuleAction.ModifyTokenAction */) { + mask |= 96 /* RuleAction.ModifyTokenAction */; } return mask; } @@ -148534,12 +149261,12 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 160 /* LastKeyword */ && column <= 160 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 160 /* SyntaxKind.LastKeyword */ && column <= 160 /* SyntaxKind.LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 160 /* LastToken */ + 1; + var mapRowLength = 160 /* SyntaxKind.LastToken */ + 1; var RulesPosition; (function (RulesPosition) { RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; @@ -148565,7 +149292,7 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action & 3 /* StopAction */ ? + var position = rule.action & 3 /* RuleAction.StopAction */ ? specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : rule.context !== formatting.anyContext ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : @@ -148634,16 +149361,16 @@ var ts; // end value is exclusive so add 1 to the result end: endOfFormatSpan + 1 }; - return formatSpan(span, sourceFile, formatContext, 2 /* FormatOnEnter */); + return formatSpan(span, sourceFile, formatContext, 2 /* FormattingRequestKind.FormatOnEnter */); } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, formatContext) { - var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SemicolonToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormatOnSemicolon */); + var semicolon = findImmediatelyPrecedingTokenOfKind(position, 26 /* SyntaxKind.SemicolonToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(semicolon), sourceFile, formatContext, 3 /* FormattingRequestKind.FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnOpeningCurly(position, sourceFile, formatContext) { - var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* OpenBraceToken */, sourceFile); + var openingCurly = findImmediatelyPrecedingTokenOfKind(position, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); if (!openingCurly) { return []; } @@ -148665,12 +149392,12 @@ var ts; pos: ts.getLineStartPositionForPosition(outermostNode.getStart(sourceFile), sourceFile), end: position }; - return formatSpan(textRange, sourceFile, formatContext, 4 /* FormatOnOpeningCurlyBrace */); + return formatSpan(textRange, sourceFile, formatContext, 4 /* FormattingRequestKind.FormatOnOpeningCurlyBrace */); } formatting.formatOnOpeningCurly = formatOnOpeningCurly; function formatOnClosingCurly(position, sourceFile, formatContext) { - var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* CloseBraceToken */, sourceFile); - return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormatOnClosingCurlyBrace */); + var precedingToken = findImmediatelyPrecedingTokenOfKind(position, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); + return formatNodeLines(findOutermostNodeWithinListLevel(precedingToken), sourceFile, formatContext, 5 /* FormattingRequestKind.FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, formatContext) { @@ -148678,7 +149405,7 @@ var ts; pos: 0, end: sourceFile.text.length }; - return formatSpan(span, sourceFile, formatContext, 0 /* FormatDocument */); + return formatSpan(span, sourceFile, formatContext, 0 /* FormattingRequestKind.FormatDocument */); } formatting.formatDocument = formatDocument; function formatSelection(start, end, sourceFile, formatContext) { @@ -148687,7 +149414,7 @@ var ts; pos: ts.getLineStartPositionForPosition(start, sourceFile), end: end, }; - return formatSpan(span, sourceFile, formatContext, 1 /* FormatSelection */); + return formatSpan(span, sourceFile, formatContext, 1 /* FormattingRequestKind.FormatSelection */); } formatting.formatSelection = formatSelection; /** @@ -148727,17 +149454,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 262 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 305 /* SourceFile */: - case 235 /* Block */: - case 262 /* ModuleBlock */: + return !!body && body.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 305 /* SyntaxKind.SourceFile */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -148834,11 +149561,11 @@ var ts; * to the initial indentation. */ function getOwnOrInheritedDelta(n, options, sourceFile) { - var previousLine = -1 /* Unknown */; + var previousLine = -1 /* Constants.Unknown */; var child; while (n) { var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line; - if (previousLine !== -1 /* Unknown */ && line !== previousLine) { + if (previousLine !== -1 /* Constants.Unknown */ && line !== previousLine) { break; } if (formatting.SmartIndenter.shouldIndentChildNode(options, n, child, sourceFile)) { @@ -148852,7 +149579,7 @@ var ts; } function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, formatContext) { var range = { pos: node.pos, end: node.end }; - return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, formatContext, 1 /* FormattingRequestKind.FormatSelection */, function (_) { return false; }, // assume that node does not have any errors sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; @@ -148876,11 +149603,12 @@ var ts; var options = _a.options, getRules = _a.getRules, host = _a.host; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); + var previousRangeTriviaEnd; var previousRange; var previousParent; var previousRangeStartLine; var lastIndentedLine; - var indentationOnLastIndentedLine = -1 /* Unknown */; + var indentationOnLastIndentedLine = -1 /* Constants.Unknown */; var edits = []; formattingScanner.advance(); if (formattingScanner.isOnToken()) { @@ -148904,10 +149632,30 @@ var ts; } } if (previousRange && formattingScanner.getStartPos() >= originalRange.end) { + // Formatting edits happen by looking at pairs of contiguous tokens (see `processPair`), + // typically inserting or deleting whitespace between them. The recursive `processNode` + // logic above bails out as soon as it encounters a token that is beyond the end of the + // range we're supposed to format (or if we reach the end of the file). But this potentially + // leaves out an edit that would occur *inside* the requested range but cannot be discovered + // without looking at one token *beyond* the end of the range: consider the line `x = { }` + // with a selection from the beginning of the line to the space inside the curly braces, + // inclusive. We would expect a format-selection would delete the space (if rules apply), + // but in order to do that, we need to process the pair ["{", "}"], but we stopped processing + // just before getting there. This block handles this trailing edit. var tokenInfo = formattingScanner.isOnEOF() ? formattingScanner.readEOFTokenRange() : formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(enclosingNode).token : undefined; - if (tokenInfo) { + if (tokenInfo && tokenInfo.pos === previousRangeTriviaEnd) { + // We need to check that tokenInfo and previousRange are contiguous: the `originalRange` + // may have ended in the middle of a token, which means we will have stopped formatting + // on that token, leaving `previousRange` pointing to the token before it, but already + // having moved the formatting scanner (where we just got `tokenInfo`) to the next token. + // If this happens, our supposed pair [previousRange, tokenInfo] actually straddles the + // token that intersects the end of the range we're supposed to format, so the pair will + // produce bogus edits if we try to `processPair`. Recall that the point of this logic is + // to perform a trailing edit at the end of the selection range: but there can be no valid + // edit in the middle of a token where the range ended, so if we have a non-contiguous + // pair here, we're already done and we can ignore it. var parent = ((_b = ts.findPrecedingToken(tokenInfo.end, sourceFile, enclosingNode)) === null || _b === void 0 ? void 0 : _b.parent) || previousParent; processPair(tokenInfo, sourceFile.getLineAndCharacterOfPosition(tokenInfo.pos).line, parent, previousRange, previousRangeStartLine, previousParent, parent, /*dynamicIndentation*/ undefined); @@ -148925,7 +149673,7 @@ var ts; function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) { - if (inheritedIndentation !== -1 /* Unknown */) { + if (inheritedIndentation !== -1 /* Constants.Unknown */) { return inheritedIndentation; } } @@ -148940,7 +149688,7 @@ var ts; return baseIndentSize > column ? baseIndentSize : column; } } - return -1 /* Unknown */; + return -1 /* Constants.Unknown */; } function computeIndentation(node, startLine, inheritedIndentation, parent, parentDynamicIndentation, effectiveParentStartLine) { var delta = formatting.SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize : 0; @@ -148953,8 +149701,8 @@ var ts; delta: Math.min(options.indentSize, parentDynamicIndentation.getDelta(node) + delta) }; } - else if (inheritedIndentation === -1 /* Unknown */) { - if (node.kind === 20 /* OpenParenToken */ && startLine === lastIndentedLine) { + else if (inheritedIndentation === -1 /* Constants.Unknown */) { + if (node.kind === 20 /* SyntaxKind.OpenParenToken */ && startLine === lastIndentedLine) { // the is used for chaining methods formatting // - we need to get the indentation on last line and the delta of parent return { indentation: indentationOnLastIndentedLine, delta: parentDynamicIndentation.getDelta(node) }; @@ -148979,19 +149727,19 @@ var ts; return modifier.kind; } switch (node.kind) { - case 257 /* ClassDeclaration */: return 84 /* ClassKeyword */; - case 258 /* InterfaceDeclaration */: return 118 /* InterfaceKeyword */; - case 256 /* FunctionDeclaration */: return 98 /* FunctionKeyword */; - case 260 /* EnumDeclaration */: return 260 /* EnumDeclaration */; - case 172 /* GetAccessor */: return 136 /* GetKeyword */; - case 173 /* SetAccessor */: return 149 /* SetKeyword */; - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return 84 /* SyntaxKind.ClassKeyword */; + case 258 /* SyntaxKind.InterfaceDeclaration */: return 118 /* SyntaxKind.InterfaceKeyword */; + case 256 /* SyntaxKind.FunctionDeclaration */: return 98 /* SyntaxKind.FunctionKeyword */; + case 260 /* SyntaxKind.EnumDeclaration */: return 260 /* SyntaxKind.EnumDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: return 136 /* SyntaxKind.GetKeyword */; + case 173 /* SyntaxKind.SetAccessor */: return 149 /* SyntaxKind.SetKeyword */; + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - return 41 /* AsteriskToken */; + return 41 /* SyntaxKind.AsteriskToken */; } // falls through - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -149006,12 +149754,12 @@ var ts; // .. { // // comment // } - case 19 /* CloseBraceToken */: - case 23 /* CloseBracketToken */: - case 21 /* CloseParenToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + case 21 /* SyntaxKind.CloseParenToken */: return indentation + getDelta(container); } - return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; + return tokenIndentation !== -1 /* Constants.Unknown */ ? tokenIndentation : indentation; }, // if list end token is LessThanToken '>' then its delta should be explicitly suppressed // so that LessThanToken as a binary operator can still be indented. @@ -149038,25 +149786,25 @@ var ts; function shouldAddDelta(line, kind, container) { switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 18 /* OpenBraceToken */: - case 19 /* CloseBraceToken */: - case 21 /* CloseParenToken */: - case 91 /* ElseKeyword */: - case 115 /* WhileKeyword */: - case 59 /* AtToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 21 /* SyntaxKind.CloseParenToken */: + case 91 /* SyntaxKind.ElseKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 59 /* SyntaxKind.AtToken */: return false; - case 43 /* SlashToken */: - case 31 /* GreaterThanToken */: + case 43 /* SyntaxKind.SlashToken */: + case 31 /* SyntaxKind.GreaterThanToken */: switch (container.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return false; } break; - case 22 /* OpenBracketToken */: - case 23 /* CloseBracketToken */: - if (container.kind !== 195 /* MappedType */) { + case 22 /* SyntaxKind.OpenBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: + if (container.kind !== 195 /* SyntaxKind.MappedType */) { return false; } break; @@ -149091,7 +149839,7 @@ var ts; // if there are any tokens that logically belong to node and interleave child nodes // such tokens will be consumed in processChildNode for the child that follows them ts.forEachChild(node, function (child) { - processChildNode(child, /*inheritedIndentation*/ -1 /* Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); + processChildNode(child, /*inheritedIndentation*/ -1 /* Constants.Unknown */, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListItem*/ false); }, function (nodes) { processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation); }); @@ -149104,6 +149852,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { + ts.Debug.assert(!ts.nodeIsSynthesized(child)); if (ts.nodeIsMissing(child)) { return inheritedIndentation; } @@ -149114,10 +149863,10 @@ var ts; undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(child, sourceFile)).line; } // if child is a list item - try to get its indentation, only if parent is within the original range. - var childIndentationAmount = -1 /* Unknown */; + var childIndentationAmount = -1 /* Constants.Unknown */; if (isListItem && ts.rangeContainsRange(originalRange, parent)) { childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); - if (childIndentationAmount !== -1 /* Unknown */) { + if (childIndentationAmount !== -1 /* Constants.Unknown */) { inheritedIndentation = childIndentationAmount; } } @@ -149153,23 +149902,24 @@ var ts; // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules var tokenInfo = formattingScanner.readTokenInfo(child); // JSX text shouldn't affect indenting - if (child.kind !== 11 /* JsxText */) { + if (child.kind !== 11 /* SyntaxKind.JsxText */) { ts.Debug.assert(tokenInfo.token.end === child.end, "Token end is child end"); consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } } - var effectiveParentStartLine = child.kind === 165 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 165 /* SyntaxKind.Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 204 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && inheritedIndentation === -1 /* Constants.Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; } function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { ts.Debug.assert(ts.isNodeArray(nodes)); + ts.Debug.assert(!ts.nodeIsSynthesized(nodes)); var listStartToken = getOpenTokenForList(parent, nodes); var listDynamicIndentation = parentDynamicIndentation; var startLine = parentStartLine; @@ -149180,7 +149930,7 @@ var ts; } return; } - if (listStartToken !== 0 /* Unknown */) { + if (listStartToken !== 0 /* SyntaxKind.Unknown */) { // introduce a new indentation scope for lists (including list start and end tokens) while (formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); @@ -149193,7 +149943,7 @@ var ts; startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; consumeTokenAndAdvanceScanner(tokenInfo, parent, parentDynamicIndentation, parent); var indentationOnListStartToken = void 0; - if (indentationOnLastIndentedLine !== -1 /* Unknown */) { + if (indentationOnLastIndentedLine !== -1 /* Constants.Unknown */) { // scanner just processed list start token so consider last indentation as list indentation // function foo(): { // last indentation was 0, list item will be indented based on this value // foo: number; @@ -149212,15 +149962,15 @@ var ts; } } } - var inheritedIndentation = -1 /* Unknown */; + var inheritedIndentation = -1 /* Constants.Unknown */; for (var i = 0; i < nodes.length; i++) { var child = nodes[i]; inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListItem*/ true, /*isFirstListItem*/ i === 0); } var listEndToken = getCloseTokenForOpenToken(listStartToken); - if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { + if (listEndToken !== 0 /* SyntaxKind.Unknown */ && formattingScanner.isOnToken() && formattingScanner.getStartPos() < originalRange.end) { var tokenInfo = formattingScanner.readTokenInfo(parent); - if (tokenInfo.token.kind === 27 /* CommaToken */) { + if (tokenInfo.token.kind === 27 /* SyntaxKind.CommaToken */) { // consume the comma consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation, parent); tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined; @@ -149242,7 +149992,7 @@ var ts; if (currentTokenInfo.leadingTrivia) { processTrivia(currentTokenInfo.leadingTrivia, parent, childContextNode, dynamicIndentation); } - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; var isTokenInRange = ts.rangeContainsRange(originalRange, currentTokenInfo.token); var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos); if (isTokenInRange) { @@ -149252,31 +150002,32 @@ var ts; lineAction = processRange(currentTokenInfo.token, tokenStart, parent, childContextNode, dynamicIndentation); // do not indent comments\token if token range overlaps with some error if (!rangeHasError) { - if (lineAction === 0 /* None */) { + if (lineAction === 0 /* LineAction.None */) { // indent token only if end line of previous range does not match start line of the token var prevEndLine = savePreviousRange && sourceFile.getLineAndCharacterOfPosition(savePreviousRange.end).line; indentToken = lastTriviaWasNewLine && tokenStart.line !== prevEndLine; } else { - indentToken = lineAction === 1 /* LineAdded */; + indentToken = lineAction === 1 /* LineAction.LineAdded */; } } } if (currentTokenInfo.trailingTrivia) { + previousRangeTriviaEnd = ts.last(currentTokenInfo.trailingTrivia).end; processTrivia(currentTokenInfo.trailingTrivia, parent, childContextNode, dynamicIndentation); } if (indentToken) { var tokenIndentation = (isTokenInRange && !rangeContainsError(currentTokenInfo.token)) ? dynamicIndentation.getIndentationForToken(tokenStart.line, currentTokenInfo.token.kind, container, !!isListEndToken) : - -1 /* Unknown */; + -1 /* Constants.Unknown */; var indentNextTokenOrTrivia = true; if (currentTokenInfo.leadingTrivia) { var commentIndentation_1 = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind, tokenIndentation, container); indentNextTokenOrTrivia = indentTriviaItems(currentTokenInfo.leadingTrivia, commentIndentation_1, indentNextTokenOrTrivia, function (item) { return insertIndentation(item.pos, commentIndentation_1, /*lineAdded*/ false); }); } // indent token only if is it is in target range and does not overlap with any error ranges - if (tokenIndentation !== -1 /* Unknown */ && indentNextTokenOrTrivia) { - insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAdded */); + if (tokenIndentation !== -1 /* Constants.Unknown */ && indentNextTokenOrTrivia) { + insertIndentation(currentTokenInfo.token.pos, tokenIndentation, lineAction === 1 /* LineAction.LineAdded */); lastIndentedLine = tokenStart.line; indentationOnLastIndentedLine = tokenIndentation; } @@ -149290,19 +150041,19 @@ var ts; var triviaItem = trivia_1[_i]; var triviaInRange = ts.rangeContainsRange(originalRange, triviaItem); switch (triviaItem.kind) { - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: if (triviaInRange) { indentMultilineComment(triviaItem, commentIndentation, /*firstLineIsIndented*/ !indentNextTokenOrTrivia); } indentNextTokenOrTrivia = false; break; - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: if (indentNextTokenOrTrivia && triviaInRange) { indentSingleLine(triviaItem); } indentNextTokenOrTrivia = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: indentNextTokenOrTrivia = true; break; } @@ -149320,7 +150071,7 @@ var ts; } function processRange(range, rangeStart, parent, contextNode, dynamicIndentation) { var rangeHasError = rangeContainsError(range); - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (!rangeHasError) { if (!previousRange) { // trim whitespaces starting from the beginning of the span up to the current line @@ -149333,6 +150084,7 @@ var ts; } } previousRange = range; + previousRangeTriviaEnd = range.end; previousParent = parent; previousRangeStartLine = rangeStart.line; return lineAction; @@ -149341,7 +150093,7 @@ var ts; formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); var rules = getRules(formattingContext); var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false; - var lineAction = 0 /* None */; + var lineAction = 0 /* LineAction.None */; if (rules) { // Apply rules in reverse order so that higher priority rules (which are first in the array) // win in a conflict with lower priority rules. @@ -149349,14 +150101,14 @@ var ts; lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); if (dynamicIndentation) { switch (lineAction) { - case 2 /* LineRemoved */: + case 2 /* LineAction.LineRemoved */: // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode); } break; - case 1 /* LineAdded */: + case 1 /* LineAction.LineAdded */: // Handle the case where token2 is moved to the new line. // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. @@ -149365,15 +150117,15 @@ var ts; } break; default: - ts.Debug.assert(lineAction === 0 /* None */); + ts.Debug.assert(lineAction === 0 /* LineAction.None */); } } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* RuleAction.DeleteSpace */) && rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */; }); } else { - trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* EndOfFileToken */; + trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* SyntaxKind.EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -149399,7 +150151,7 @@ var ts; function characterToColumn(startLinePosition, characterInLine) { var column = 0; for (var i = 0; i < characterInLine; i++) { - if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* tab */) { + if (sourceFile.text.charCodeAt(startLinePosition + i) === 9 /* CharacterCodes.tab */) { column += options.tabSize - column % options.tabSize; } else { @@ -149530,48 +150282,48 @@ var ts; function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* StopProcessingSpaceActions */: + case 1 /* RuleAction.StopProcessingSpaceActions */: // no action required - return 0 /* None */; - case 16 /* DeleteSpace */: + return 0 /* LineAction.None */; + case 16 /* RuleAction.DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 32 /* DeleteToken */: + case 32 /* RuleAction.DeleteToken */: recordDelete(previousRange.pos, previousRange.end - previousRange.pos); break; - case 8 /* InsertNewLine */: + case 8 /* RuleAction.InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } // edit should not be applied if we have one line feed between elements var lineDelta = currentStartLine - previousStartLine; if (lineDelta !== 1) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, ts.getNewLineOrDefaultFromHost(host, options)); - return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; + return onLaterLine ? 0 /* LineAction.None */ : 1 /* LineAction.LineAdded */; } break; - case 4 /* InsertSpace */: + case 4 /* RuleAction.InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines - if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { - return 0 /* None */; + if (rule.flags !== 1 /* RuleFlags.CanDeleteNewLines */ && previousStartLine !== currentStartLine) { + return 0 /* LineAction.None */; } var posDelta = currentRange.pos - previousRange.end; - if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* space */) { + if (posDelta !== 1 || sourceFile.text.charCodeAt(previousRange.end) !== 32 /* CharacterCodes.space */) { recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); - return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; + return onLaterLine ? 2 /* LineAction.LineRemoved */ : 0 /* LineAction.None */; } break; - case 64 /* InsertTrailingSemicolon */: + case 64 /* RuleAction.InsertTrailingSemicolon */: recordInsert(previousRange.end, ";"); } - return 0 /* None */; + return 0 /* LineAction.None */; } } var LineAction; @@ -149613,71 +150365,71 @@ var ts; // // Internally, we represent the end of the comment at the newline and closing '/', respectively. // - position === range.end && (range.kind === 2 /* SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); + position === range.end && (range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || position === sourceFile.getFullWidth()); }); } formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.parameters === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } else if (node.arguments === list) { - return 20 /* OpenParenToken */; + return 20 /* SyntaxKind.OpenParenToken */; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (node.typeParameters === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 178 /* TypeReference */: - case 210 /* TaggedTemplateExpression */: - case 181 /* TypeQuery */: - case 228 /* ExpressionWithTypeArguments */: - case 200 /* ImportType */: + case 178 /* SyntaxKind.TypeReference */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 181 /* SyntaxKind.TypeQuery */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 200 /* SyntaxKind.ImportType */: if (node.typeArguments === list) { - return 29 /* LessThanToken */; + return 29 /* SyntaxKind.LessThanToken */; } break; - case 182 /* TypeLiteral */: - return 18 /* OpenBraceToken */; + case 182 /* SyntaxKind.TypeLiteral */: + return 18 /* SyntaxKind.OpenBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 20 /* OpenParenToken */: - return 21 /* CloseParenToken */; - case 29 /* LessThanToken */: - return 31 /* GreaterThanToken */; - case 18 /* OpenBraceToken */: - return 19 /* CloseBraceToken */; + case 20 /* SyntaxKind.OpenParenToken */: + return 21 /* SyntaxKind.CloseParenToken */; + case 29 /* SyntaxKind.LessThanToken */: + return 31 /* SyntaxKind.GreaterThanToken */; + case 18 /* SyntaxKind.OpenBraceToken */: + return 19 /* SyntaxKind.CloseBraceToken */; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } var internedSizes; var internedTabsIndentation; @@ -149763,7 +150515,7 @@ var ts; var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); // eslint-disable-next-line no-null/no-null var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); - if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } if (!precedingToken) { @@ -149799,21 +150551,21 @@ var ts; // y: undefined, // } // ``` - var isObjectLiteral = currentToken.kind === 18 /* OpenBraceToken */ && currentToken.parent.kind === 205 /* ObjectLiteralExpression */; + var isObjectLiteral = currentToken.kind === 18 /* SyntaxKind.OpenBraceToken */ && currentToken.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; if (options.indentStyle === ts.IndentStyle.Block || isObjectLiteral) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 221 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* SyntaxKind.CommaToken */ && precedingToken.parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } } var containerList = getListByPosition(position, precedingToken.parent, sourceFile); // use list position if the preceding token is before any list items if (containerList && !ts.rangeContainsRange(containerList, precedingToken)) { - var useTheSameBaseIndentation = [213 /* FunctionExpression */, 214 /* ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; + var useTheSameBaseIndentation = [213 /* SyntaxKind.FunctionExpression */, 214 /* SyntaxKind.ArrowFunction */].indexOf(currentToken.parent.kind) !== -1; var indentSize = useTheSameBaseIndentation ? 0 : options.indentSize; return getActualIndentationForListStartLine(containerList, sourceFile, options) + indentSize; // TODO: GH#18217 } @@ -149833,7 +150585,7 @@ var ts; return column; } var firstNonWhitespaceCharacterCode = sourceFile.text.charCodeAt(startPositionOfLine + character); - return firstNonWhitespaceCharacterCode === 42 /* asterisk */ ? column - 1 : column; + return firstNonWhitespaceCharacterCode === 42 /* CharacterCodes.asterisk */ ? column - 1 : column; } function getBlockIndent(sourceFile, position, options) { // move backwards until we find a line with a non-whitespace character, @@ -149858,9 +150610,9 @@ var ts; if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(options, current, previous, sourceFile, /*isNextChild*/ true)) { var currentStart = getStartLineAndCharacterForNode(current, sourceFile); var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); - var indentationDelta = nextTokenKind !== 0 /* Unknown */ + var indentationDelta = nextTokenKind !== 0 /* NextTokenKind.Unknown */ // handle cases when codefix is about to be inserted before the close brace - ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0 + ? assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* NextTokenKind.CloseBrace */ ? options.indentSize : 0 : lineAtPosition !== currentStart.line ? options.indentSize : 0; return getIndentationForNodeWorker(current, currentStart, /*ignoreActualIndentationRange*/ undefined, indentationDelta, sourceFile, /*isNextChild*/ true, options); // TODO: GH#18217 } @@ -149869,7 +150621,7 @@ var ts; // function foo(a // | preceding node 'a' does share line with its parent but indentation is expected var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, /*listIndentsChild*/ true); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation; } previous = current; @@ -149923,12 +150675,12 @@ var ts; // }) looking at the relationship between the list and *first* list item. var listIndentsChild = !!firstListChild && getStartLineAndCharacterForNode(firstListChild, sourceFile).line > containingListOrParentStart.line; var actualIndentation = getActualIndentationForListItem(current, sourceFile, options, listIndentsChild); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } // try to fetch actual indentation for current node from source text actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options); - if (actualIndentation !== -1 /* Unknown */) { + if (actualIndentation !== -1 /* Value.Unknown */) { return actualIndentation + indentationDelta; } } @@ -149967,7 +150719,7 @@ var ts; } else { // handle broken code gracefully - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } } /* @@ -149978,9 +150730,9 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 305 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 305 /* SyntaxKind.SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } @@ -149993,13 +150745,13 @@ var ts; function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current, sourceFile); if (!nextToken) { - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } - if (nextToken.kind === 18 /* OpenBraceToken */) { + if (nextToken.kind === 18 /* SyntaxKind.OpenBraceToken */) { // open braces are always indented at the parent level - return 1 /* OpenBrace */; + return 1 /* NextTokenKind.OpenBrace */; } - else if (nextToken.kind === 19 /* CloseBraceToken */) { + else if (nextToken.kind === 19 /* SyntaxKind.CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -150009,9 +150761,9 @@ var ts; // class A { // $} var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine ? 2 /* CloseBrace */ : 0 /* Unknown */; + return lineAtPosition === nextTokenStartLine ? 2 /* NextTokenKind.CloseBrace */ : 0 /* NextTokenKind.Unknown */; } - return 0 /* Unknown */; + return 0 /* NextTokenKind.Unknown */; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); @@ -150026,8 +150778,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 239 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 91 /* ElseKeyword */, sourceFile); + if (parent.kind === 239 /* SyntaxKind.IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 91 /* SyntaxKind.ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -150107,42 +150859,42 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getList(node.typeArguments); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return getList(node.properties); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getList(node.elements); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return getList(node.members); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return getList(node.parameters); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return getList(node.typeParameters); - case 209 /* NewExpression */: - case 208 /* CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return getList(node.declarations); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return getList(node.elements); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -150160,27 +150912,27 @@ var ts; } function getActualIndentationForListStartLine(list, sourceFile, options) { if (!list) { - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 255 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } var containingList = getContainingList(node, sourceFile); if (containingList) { var index = containingList.indexOf(node); if (index !== -1) { var result = deriveActualIndentationFromList(containingList, index, sourceFile, options); - if (result !== -1 /* Unknown */) { + if (result !== -1 /* Value.Unknown */) { return result; } } return getActualIndentationForListStartLine(containingList, sourceFile, options) + (listIndentsChild ? options.indentSize : 0); // TODO: GH#18217 } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function deriveActualIndentationFromList(list, index, sourceFile, options) { ts.Debug.assert(index >= 0 && index < list.length); @@ -150189,7 +150941,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 27 /* CommaToken */) { + if (list[i].kind === 27 /* SyntaxKind.CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -150199,7 +150951,7 @@ var ts; } lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile); } - return -1 /* Unknown */; + return -1 /* Value.Unknown */; } function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options) { var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0); @@ -150220,7 +150972,7 @@ var ts; if (!ts.isWhiteSpaceSingleLine(ch)) { break; } - if (ch === 9 /* tab */) { + if (ch === 9 /* CharacterCodes.tab */) { column += options.tabSize + (column % options.tabSize); } else { @@ -150236,98 +150988,98 @@ var ts; } SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { - var childKind = child ? child.kind : 0 /* Unknown */; + var childKind = child ? child.kind : 0 /* SyntaxKind.Unknown */; switch (parent.kind) { - case 238 /* ExpressionStatement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 204 /* ArrayLiteralExpression */: - case 235 /* Block */: - case 262 /* ModuleBlock */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 195 /* MappedType */: - case 184 /* TupleType */: - case 263 /* CaseBlock */: - case 290 /* DefaultClause */: - case 289 /* CaseClause */: - case 212 /* ParenthesizedExpression */: - case 206 /* PropertyAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 237 /* VariableStatement */: - case 271 /* ExportAssignment */: - case 247 /* ReturnStatement */: - case 222 /* ConditionalExpression */: - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: - case 279 /* JsxSelfClosingElement */: - case 288 /* JsxExpression */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 164 /* Parameter */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 191 /* ParenthesizedType */: - case 210 /* TaggedTemplateExpression */: - case 218 /* AwaitExpression */: - case 273 /* NamedExports */: - case 269 /* NamedImports */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 167 /* PropertyDeclaration */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 195 /* SyntaxKind.MappedType */: + case 184 /* SyntaxKind.TupleType */: + case 263 /* SyntaxKind.CaseBlock */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 237 /* SyntaxKind.VariableStatement */: + case 271 /* SyntaxKind.ExportAssignment */: + case 247 /* SyntaxKind.ReturnStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 164 /* SyntaxKind.Parameter */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 273 /* SyntaxKind.NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 254 /* VariableDeclaration */: - case 296 /* PropertyAssignment */: - case 221 /* BinaryExpression */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 254 /* SyntaxKind.VariableDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - if (parent.kind === 221 /* BinaryExpression */ && sourceFile && child && childKind === 278 /* JsxElement */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && sourceFile && child && childKind === 278 /* SyntaxKind.JsxElement */) { var parentStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, parent.pos)).line; var childStartLine = sourceFile.getLineAndCharacterOfPosition(ts.skipTrivia(sourceFile.text, child.pos)).line; return parentStartLine !== childStartLine; } - if (parent.kind !== 221 /* BinaryExpression */) { + if (parent.kind !== 221 /* SyntaxKind.BinaryExpression */) { return true; } break; - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 239 /* IfStatement */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return childKind !== 235 /* Block */; - case 214 /* ArrowFunction */: - if (sourceFile && childKind === 212 /* ParenthesizedExpression */) { + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return childKind !== 235 /* SyntaxKind.Block */; + case 214 /* SyntaxKind.ArrowFunction */: + if (sourceFile && childKind === 212 /* SyntaxKind.ParenthesizedExpression */) { return rangeIsOnOneLine(sourceFile, child); } - return childKind !== 235 /* Block */; - case 272 /* ExportDeclaration */: - return childKind !== 273 /* NamedExports */; - case 266 /* ImportDeclaration */: - return childKind !== 267 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 269 /* NamedImports */); - case 278 /* JsxElement */: - return childKind !== 281 /* JsxClosingElement */; - case 282 /* JsxFragment */: - return childKind !== 284 /* JsxClosingFragment */; - case 188 /* IntersectionType */: - case 187 /* UnionType */: - if (childKind === 182 /* TypeLiteral */ || childKind === 184 /* TupleType */) { + return childKind !== 235 /* SyntaxKind.Block */; + case 272 /* SyntaxKind.ExportDeclaration */: + return childKind !== 273 /* SyntaxKind.NamedExports */; + case 266 /* SyntaxKind.ImportDeclaration */: + return childKind !== 267 /* SyntaxKind.ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 269 /* SyntaxKind.NamedImports */); + case 278 /* SyntaxKind.JsxElement */: + return childKind !== 281 /* SyntaxKind.JsxClosingElement */; + case 282 /* SyntaxKind.JsxFragment */: + return childKind !== 284 /* SyntaxKind.JsxClosingFragment */; + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + if (childKind === 182 /* SyntaxKind.TypeLiteral */ || childKind === 184 /* SyntaxKind.TupleType */) { return false; } break; @@ -150338,11 +151090,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: - return parent.kind !== 235 /* Block */; + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + return parent.kind !== 235 /* SyntaxKind.Block */; default: return false; } @@ -150432,7 +151184,7 @@ var ts; i++; continue; } - return ch === 47 /* slash */; + return ch === 47 /* CharacterCodes.slash */; } return false; } @@ -150516,7 +151268,7 @@ var ts; var comment = comments_2[_i]; // Single line can break the loop as trivia will only be this line. // Comments on subsequest lines are also ignored. - if (comment.kind === 2 /* SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { + if (comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || ts.getLineOfLocalPosition(sourceFile, comment.pos) > nodeEndLine) { break; } // Get the end line of the comment and compare against the end line of the node. @@ -150559,7 +151311,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 205 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* SyntaxKind.CommaToken */ || (candidate.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)); } function isThisTypeAnnotatable(containingFunction) { return ts.isFunctionExpression(containingFunction) || ts.isFunctionDeclaration(containingFunction); @@ -150665,7 +151417,7 @@ var ts; }; ChangeTracker.prototype.nextCommaToken = function (sourceFile, node) { var next = ts.findNextToken(node, node.parent, sourceFile); - return next && next.kind === 27 /* CommaToken */ ? next : undefined; + return next && next.kind === 27 /* SyntaxKind.CommaToken */ ? next : undefined; }; ChangeTracker.prototype.replacePropertyAssignment = function (sourceFile, oldNode, newNode) { var suffix = this.nextCommaToken(sourceFile, oldNode) ? "" : ("," + this.newLineCharacter); @@ -150729,7 +151481,7 @@ var ts; var insertAtLineStart = isValidLocationToAddComment(sourceFile, startPosition); var token = ts.getTouchingToken(sourceFile, insertAtLineStart ? startPosition : position); var indent = sourceFile.text.slice(lineStartPosition, startPosition); - var text = (insertAtLineStart ? "" : this.newLineCharacter) + "//" + commentText + this.newLineCharacter + indent; + var text = "".concat(insertAtLineStart ? "" : this.newLineCharacter, "//").concat(commentText).concat(this.newLineCharacter).concat(indent); this.insertText(sourceFile, token.getStart(sourceFile), text); }; ChangeTracker.prototype.insertJsdocCommentBefore = function (sourceFile, node, tag) { @@ -150782,7 +151534,7 @@ var ts; var _a; var endNode; if (ts.isFunctionLike(node)) { - endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); + endNode = ts.findChildOfKind(node, 21 /* SyntaxKind.CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) return false; // Function missing parentheses, give up @@ -150791,19 +151543,19 @@ var ts; } } else { - endNode = (_a = (node.kind === 254 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; + endNode = (_a = (node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { - var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; + var start = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile).getStart(sourceFile) + 1; var suffix = node.parameters.length ? ", " : ""; this.insertNodeAt(sourceFile, start, type, { prefix: "this: ", suffix: suffix }); }; ChangeTracker.prototype.insertTypeParameters = function (sourceFile, node, typeParameters) { // If no `(`, is an arrow function `x => x`, so use the pos of the first parameter - var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); + var start = (ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">", joiner: ", " }); }; ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, inserted, blankLineBetween) { @@ -150944,8 +151696,8 @@ var ts; if (needSemicolonBetween(after, newNode)) { // check if previous statement ends with semicolon // if not - insert semicolon to preserve the code from changing the meaning due to ASI - if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { - this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SemicolonToken */)); + if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* CharacterCodes.semicolon */) { + this.replaceRange(sourceFile, ts.createRange(after.end), ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */)); } } var endPosition = getAdjustedEndPosition(sourceFile, after, {}); @@ -150953,22 +151705,22 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptions = function (sourceFile, after) { var options = this.getInsertNodeAfterOptionsWorker(after); - return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n" + options.prefix : "\n") : options.prefix }); + return __assign(__assign({}, options), { prefix: after.end === sourceFile.end && ts.isStatement(after) ? (options.prefix ? "\n".concat(options.prefix) : "\n") : options.prefix }); }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 254 /* VariableDeclaration */: - case 10 /* StringLiteral */: - case 79 /* Identifier */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 10 /* SyntaxKind.StringLiteral */: + case 79 /* SyntaxKind.Identifier */: return { prefix: ", " }; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return { prefix: " " }; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -150977,28 +151729,28 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 214 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); - var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); + if (node.kind === 214 /* SyntaxKind.ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* SyntaxKind.EqualsGreaterThanToken */, sourceFile); + var lparen = ts.findChildOfKind(node, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.factory.createToken(98 /* SyntaxKind.FunctionKeyword */), ts.factory.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { // `x => {}` -> `function f(x) {}` - this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function " + name + "("); + this.insertText(sourceFile, ts.first(node.parameters).getStart(sourceFile), "function ".concat(name, "(")); // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` - this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* CloseParenToken */)); + this.replaceRange(sourceFile, arrow, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } - if (node.body.kind !== 235 /* Block */) { + if (node.body.kind !== 235 /* SyntaxKind.Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* OpenBraceToken */), ts.factory.createToken(105 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); - this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SemicolonToken */), ts.factory.createToken(19 /* CloseBraceToken */)], { joiner: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.factory.createToken(18 /* SyntaxKind.OpenBraceToken */), ts.factory.createToken(105 /* SyntaxKind.ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.end, [ts.factory.createToken(26 /* SyntaxKind.SemicolonToken */), ts.factory.createToken(19 /* SyntaxKind.CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 213 /* FunctionExpression */ ? 98 /* FunctionKeyword */ : 84 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 213 /* SyntaxKind.FunctionExpression */ ? 98 /* SyntaxKind.FunctionKeyword */ : 84 /* SyntaxKind.ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.factory.createIdentifier(name), { prefix: " " }); } }; @@ -151053,7 +151805,7 @@ var ts; var nextNode = containingList[index + 1]; var startPos = skipWhitespacesAndLineBreaks(sourceFile.text, nextNode.getFullStart()); // write separator and leading trivia of the next element as suffix - var suffix = "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, startPos); + var suffix = "".concat(ts.tokenToString(nextToken.kind)).concat(sourceFile.text.substring(nextToken.end, startPos)); this.insertNodesAt(sourceFile, startPos, [newNode], { suffix: suffix }); } } @@ -151070,12 +151822,12 @@ var ts; // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise // i.e. var x = 1 // this is x // | new element will be inserted at this position - separator = 27 /* CommaToken */; + separator = 27 /* SyntaxKind.CommaToken */; } else { // element has more than one element, pick separator from the list var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); - separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* CommaToken */; + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 27 /* SyntaxKind.CommaToken */; // determine if list is multiline by checking lines of after element and element that precedes it. var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; @@ -151098,7 +151850,7 @@ var ts; this.replaceRange(sourceFile, ts.createRange(insertPos), newNode, { indentation: indentation, prefix: this.newLineCharacter }); } else { - this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: ts.tokenToString(separator) + " " }); + this.replaceRange(sourceFile, ts.createRange(end), newNode, { prefix: "".concat(ts.tokenToString(separator), " ") }); } } }; @@ -151126,7 +151878,7 @@ var ts; ChangeTracker.prototype.finishDeleteDeclarations = function () { var _this = this; var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`. - var _loop_10 = function (sourceFile, node) { + var _loop_9 = function (sourceFile, node) { if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) { if (ts.isArray(node)) { this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node)); @@ -151139,7 +151891,7 @@ var ts; var this_1 = this; for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) { var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node; - _loop_10(sourceFile, node); + _loop_9(sourceFile, node); } deletedNodesInLists.forEach(function (node) { var sourceFile = node.getSourceFile(); @@ -151175,10 +151927,10 @@ var ts; }()); textChanges_3.ChangeTracker = ChangeTracker; function updateJSDocHost(parent) { - if (parent.kind !== 214 /* ArrowFunction */) { + if (parent.kind !== 214 /* SyntaxKind.ArrowFunction */) { return parent; } - var jsDocNode = parent.parent.kind === 167 /* PropertyDeclaration */ ? + var jsDocNode = parent.parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ ? parent.parent : parent.parent.parent; jsDocNode.jsDoc = parent.jsDoc; @@ -151190,16 +151942,16 @@ var ts; return undefined; } switch (oldTag.kind) { - case 340 /* JSDocParameterTag */: { + case 340 /* SyntaxKind.JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.factory.createJSDocParameterTag(/*tagName*/ undefined, newParam.name, /*isBracketed*/ false, newParam.typeExpression, newParam.isNameFirst, oldParam.comment) : undefined; } - case 341 /* JSDocReturnTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment); } } @@ -151208,8 +151960,8 @@ var ts; return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } function getClassOrObjectBraceEnds(cls, sourceFile) { - var open = ts.findChildOfKind(cls, 18 /* OpenBraceToken */, sourceFile); - var close = ts.findChildOfKind(cls, 19 /* CloseBraceToken */, sourceFile); + var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile); + var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile); return [open === null || open === void 0 ? void 0 : open.end, close === null || close === void 0 ? void 0 : close.end]; } function getMembersOrProperties(node) { @@ -151227,14 +151979,14 @@ var ts; // order changes by start position // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa. var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); }); - var _loop_11 = function (i) { + var _loop_10 = function (i) { ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () { - return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range); + return "".concat(JSON.stringify(normalized[i].range), " and ").concat(JSON.stringify(normalized[i + 1].range)); }); }; // verify that change intervals do not overlap, except possibly at end points. for (var i = 0; i < normalized.length - 1; i++) { - _loop_11(i); + _loop_10(i); } var textChanges = ts.mapDefined(normalized, function (c) { var span = ts.createTextSpanFromRange(c.range); @@ -151256,8 +152008,8 @@ var ts; changesToText.newFileChanges = newFileChanges; function newFileChangesWorker(oldFile, scriptKind, statements, newLineCharacter, formatContext) { // TODO: this emits the file, parses it back, then formats it that -- may be a less roundabout way to do this - var nonFormattedText = statements.map(function (s) { return s === 4 /* NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); - var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ESNext */, /*setParentNodes*/ true, scriptKind); + var nonFormattedText = statements.map(function (s) { return s === 4 /* SyntaxKind.NewLineTrivia */ ? "" : getNonformattedText(s, oldFile, newLineCharacter).text; }).join(newLineCharacter); + var sourceFile = ts.createSourceFile("any file name", nonFormattedText, 99 /* ScriptTarget.ESNext */, /*setParentNodes*/ true, scriptKind); var changes = ts.formatting.formatDocument(sourceFile, formatContext); return applyChanges(nonFormattedText, changes) + newLineCharacter; } @@ -151312,7 +152064,7 @@ var ts; neverAsciiEscape: true, preserveSourceNewlines: true, terminateUnterminatedLiterals: true - }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + }, writer).writeNode(4 /* EmitHint.Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -151320,7 +152072,7 @@ var ts; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var _a = changes[i], span = _a.span, newText = _a.newText; - text = "" + text.substring(0, span.start) + newText + text.substring(ts.textSpanEnd(span)); + text = "".concat(text.substring(0, span.start)).concat(newText).concat(text.substring(ts.textSpanEnd(span))); } return text; } @@ -151330,7 +152082,7 @@ var ts; } // A transformation context that won't perform parenthesization, as some parenthesization rules // are more aggressive than is strictly necessary. - var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); + var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) }); function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes @@ -151541,7 +152293,7 @@ var ts; var firstNodeLine; for (var _b = 0, ranges_1 = ranges; _b < ranges_1.length; _b++) { var range = ranges_1[_b]; - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { if (ts.isPinnedComment(text, range.pos)) { lastComment = { range: range, pinnedOrTripleSlash: true }; continue; @@ -151581,7 +152333,7 @@ var ts; var charCode = text.charCodeAt(position); if (ts.isLineBreak(charCode)) { position++; - if (position < text.length && charCode === 13 /* carriageReturn */ && text.charCodeAt(position) === 10 /* lineFeed */) { + if (position < text.length && charCode === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(position) === 10 /* CharacterCodes.lineFeed */) { position++; } } @@ -151593,18 +152345,18 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 164 /* Parameter */: { + case 164 /* SyntaxKind.Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && - !ts.findChildOfKind(oldFunction, 20 /* OpenParenToken */, sourceFile)) { + !ts.findChildOfKind(oldFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile)) { // Lambdas with exactly one parameter are special because, after removal, there // must be an empty parameter list (i.e. `()`) and this won't necessarily be the // case if the parameter is simply removed (e.g. in `x => 1`). @@ -151615,17 +152367,17 @@ var ts; } break; } - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax); // For first import, leave header comment in place, otherwise only delete JSDoc comments deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine, }); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 202 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -151633,13 +152385,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -151648,17 +152400,17 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -151687,7 +152439,7 @@ var ts; // import |d,| * as ns from './file' var start = importClause.name.getStart(sourceFile); var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); - if (nextToken && nextToken.kind === 27 /* CommaToken */) { + if (nextToken && nextToken.kind === 27 /* SyntaxKind.CommaToken */) { // shift first non-whitespace position after comma to the start position of the node var end = ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true); changes.deleteRange(sourceFile, { pos: start, end: end }); @@ -151709,15 +152461,15 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 266 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 266 /* SyntaxKind.ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 292 /* CatchClause */) { + if (parent.kind === 292 /* SyntaxKind.CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion - changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); + changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* SyntaxKind.OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* SyntaxKind.CloseParenToken */, sourceFile)); return; } if (parent.declarations.length !== 1) { @@ -151726,14 +152478,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: changes.replaceNode(sourceFile, node, ts.factory.createObjectLiteralExpression()); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: @@ -151920,8 +152672,8 @@ var ts; }); function makeChange(changeTracker, sourceFile, assertion) { var replacement = ts.isAsExpression(assertion) - ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)) - : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), assertion.expression); + ? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)) + : ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } function getAssertion(sourceFile, pos) { @@ -152005,7 +152757,7 @@ var ts; } } fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.add(ts.getNodeId(insertionSite)); - var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* Async */))); + var cloneWithModifier = ts.factory.updateModifiers(ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true), ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(ts.getSyntacticModifierFlags(insertionSite) | 256 /* ModifierFlags.Async */))); changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier); } function getFixableErrorSpanDeclaration(sourceFile, span) { @@ -152142,19 +152894,19 @@ var ts; } var isCompleteFix = identifiers.isCompleteFix; var initializers; - var _loop_12 = function (identifier) { + var _loop_11 = function (identifier) { var symbol = checker.getSymbolAtLocation(identifier); if (!symbol) { return "continue"; } var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 237 /* VariableStatement */); + var variableStatement = ts.getAncestor(declaration, 237 /* SyntaxKind.VariableStatement */); if (!declaration || !variableStatement || declaration.type || !declaration.initializer || variableStatement.getSourceFile() !== sourceFile || - ts.hasSyntacticModifier(variableStatement, 1 /* Export */) || + ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */) || !variableName || !isInsideAwaitableBody(declaration.initializer)) { isCompleteFix = false; @@ -152175,7 +152927,7 @@ var ts; }; for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { var identifier = _a[_i]; - _loop_12(identifier); + _loop_11(identifier); } return initializers && { initializers: initializers, @@ -152222,15 +152974,15 @@ var ts; // Promise as an invalid operand. So if the whole binary expression is // typed `any` as a result, there is a strong likelihood that this Promise // is accidentally missing `await`. - checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; + checker.getTypeAtLocation(errorNode).flags & 1 /* TypeFlags.Any */; } function isInsideAwaitableBody(node) { - return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* NodeFlags.AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* FunctionDeclaration */ || - ancestor.parent.kind === 213 /* FunctionExpression */ || - ancestor.parent.kind === 214 /* ArrowFunction */ || - ancestor.parent.kind === 169 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + ancestor.parent.kind === 213 /* SyntaxKind.FunctionExpression */ || + ancestor.parent.kind === 214 /* SyntaxKind.ArrowFunction */ || + ancestor.parent.kind === 169 /* SyntaxKind.MethodDeclaration */); }); } function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { @@ -152319,7 +153071,7 @@ var ts; if (forInitializer) return applyChange(changeTracker, forInitializer, sourceFile, fixedNodes); var parent = token.parent; - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isExpressionStatement(parent.parent)) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isExpressionStatement(parent.parent)) { return applyChange(changeTracker, token, sourceFile, fixedNodes); } if (ts.isArrayLiteralExpression(parent)) { @@ -152343,16 +153095,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || ts.tryAddToSet(fixedNodes, initializer)) { - changeTracker.insertModifierBefore(sourceFile, 85 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 85 /* SyntaxKind.ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 79 /* Identifier */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 79 /* SyntaxKind.Identifier */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return true; default: return false; @@ -152366,9 +153118,9 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 79 /* Identifier */: - case 221 /* BinaryExpression */: - case 27 /* CommaToken */: + case 79 /* SyntaxKind.Identifier */: + case 221 /* SyntaxKind.BinaryExpression */: + case 27 /* SyntaxKind.CommaToken */: return true; default: return false; @@ -152378,10 +153130,10 @@ var ts; if (!ts.isBinaryExpression(expression)) { return false; } - if (expression.operatorToken.kind === 27 /* CommaToken */) { + if (expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return ts.every([expression.left, expression.right], function (expression) { return expressionCouldBeVariableDeclaration(expression, checker); }); } - return expression.operatorToken.kind === 63 /* EqualsToken */ + return expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(expression.left) && !checker.getSymbolAtLocation(expression.left); } @@ -152416,9 +153168,9 @@ var ts; return; } var declaration = token.parent; - if (declaration.kind === 167 /* PropertyDeclaration */ && + if (declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && (!fixedNodes || ts.tryAddToSet(fixedNodes, declaration))) { - changeTracker.insertModifierBefore(sourceFile, 135 /* DeclareKeyword */, declaration); + changeTracker.insertModifierBefore(sourceFile, 135 /* SyntaxKind.DeclareKeyword */, declaration); } } })(codefix = ts.codefix || (ts.codefix = {})); @@ -152532,7 +153284,7 @@ var ts; if (!errorNode) { return undefined; } - else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* EqualsToken */) { + else if (ts.isBinaryExpression(errorNode.parent) && errorNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return { source: errorNode.parent.right, target: errorNode.parent.left }; } else if (ts.isVariableDeclaration(errorNode.parent) && errorNode.parent.initializer) { @@ -152572,7 +153324,7 @@ var ts; var add = toAdd_1[_i]; var d = add.valueDeclaration; if (d && (ts.isPropertySignature(d) || ts.isPropertyDeclaration(d)) && d.type) { - var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* UnionType */ ? d.type.types : [d.type], true), [ + var t = ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], d.type.kind === 187 /* SyntaxKind.UnionType */ ? d.type.types : [d.type], true), [ ts.factory.createTypeReferenceNode("undefined") ], false)); changes.replaceNode(d.getSourceFile(), d.type, t); @@ -152625,9 +153377,9 @@ var ts; if (typeParameters.length) changes.insertTypeParameters(sourceFile, decl, typeParameters); } - var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(decl) && !ts.findChildOfKind(decl, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(decl.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, _a = decl.parameters; _i < _a.length; _i++) { var param = _a[_i]; if (!param.type) { @@ -152637,7 +153389,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(decl.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); if (!decl.type) { var returnType = ts.getJSDocReturnType(decl); if (returnType) @@ -152652,30 +153404,30 @@ var ts; } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return ts.factory.createTypeReferenceNode("any", ts.emptyArray); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return transformJSDocOptionalType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return transformJSDocType(node.type); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return transformJSDocNullableType(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return transformJSDocVariadicType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return transformJSDocFunctionType(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, ts.nullTransformationContext); - ts.setEmitFlags(visited, 1 /* SingleLine */); + ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */); return visited; } } @@ -152692,13 +153444,13 @@ var ts; var _a; // TODO: This does not properly handle `function(new:C, string)` per https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System#the-javascript-type-language // however we do handle it correctly in `serializeTypeForDeclaration` in checker.ts - return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + return ts.factory.createFunctionTypeNode(ts.emptyArray, node.parameters.map(transformJSDocParameter), (_a = node.type) !== null && _a !== void 0 ? _a : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 318 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 318 /* SyntaxKind.JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); - var dotdotdot = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; + var dotdotdot = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : node.dotDotDotToken; return ts.factory.createParameterDeclaration(node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node) { @@ -152735,11 +153487,11 @@ var ts; function transformJSDocIndexSignature(node) { var index = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.factory.createTypeReferenceNode(node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature(/*modifiers*/ undefined, [index], node.typeArguments[1])]); - ts.setEmitFlags(indexSignature, 1 /* SingleLine */); + ts.setEmitFlags(indexSignature, 1 /* EmitFlags.SingleLine */); return indexSignature; } })(codefix = ts.codefix || (ts.codefix = {})); @@ -152766,7 +153518,7 @@ var ts; }); function doChange(changes, sourceFile, position, checker, preferences, compilerOptions) { var ctorSymbol = checker.getSymbolAtLocation(ts.getTokenAtPosition(sourceFile, position)); - if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* Function */ | 3 /* Variable */))) { + if (!ctorSymbol || !ctorSymbol.valueDeclaration || !(ctorSymbol.flags & (16 /* SymbolFlags.Function */ | 3 /* SymbolFlags.Variable */))) { // Bad input return undefined; } @@ -152799,14 +153551,14 @@ var ts; if (member.declarations.length === 1 && ts.isPropertyAccessExpression(firstDeclaration) && ts.isBinaryExpression(firstDeclaration.parent) && - firstDeclaration.parent.operatorToken.kind === 63 /* EqualsToken */ && + firstDeclaration.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isObjectLiteralExpression(firstDeclaration.parent.right)) { var prototypes = firstDeclaration.parent.right; createClassElement(prototypes.symbol, /** modifiers */ undefined, memberElements); } } else { - createClassElement(member, [ts.factory.createToken(124 /* StaticKeyword */)], memberElements); + createClassElement(member, [ts.factory.createToken(124 /* SyntaxKind.StaticKeyword */)], memberElements); } }); } @@ -152857,7 +153609,7 @@ var ts; function createClassElement(symbol, modifiers, members) { // Right now the only thing we can convert are function expressions, which are marked as methods // or { x: y } type prototype assignments, which are marked as ObjectLiteral - if (!(symbol.flags & 8192 /* Method */) && !(symbol.flags & 4096 /* ObjectLiteral */)) { + if (!(symbol.flags & 8192 /* SymbolFlags.Method */) && !(symbol.flags & 4096 /* SymbolFlags.ObjectLiteral */)) { return; } var memberDeclaration = symbol.valueDeclaration; @@ -152876,7 +153628,7 @@ var ts; return; } // 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 === 238 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { @@ -152928,7 +153680,7 @@ var ts; return createArrowFunctionExpressionMember(members, expression, name); } function createFunctionExpressionMember(members, functionExpression, name) { - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -152939,14 +153691,14 @@ var ts; var arrowFunctionBody = arrowFunction.body; var bodyBlock; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 235 /* Block */) { + if (arrowFunctionBody.kind === 235 /* SyntaxKind.Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.factory.createBlock([ts.factory.createReturnStatement(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 131 /* SyntaxKind.AsyncKeyword */)); var method = ts.factory.createMethodDeclaration(fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -152963,7 +153715,7 @@ var ts; if (initializer.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node.parent.parent, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -152974,7 +153726,7 @@ var ts; if (node.body) { memberElements.unshift(ts.factory.createConstructorDeclaration(/*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 93 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 93 /* SyntaxKind.ExportKeyword */); var cls = ts.factory.createClassDeclaration(modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -153001,7 +153753,7 @@ var ts; } if (ts.isStringLiteralLike(propName)) { return ts.isIdentifierText(propName.text, ts.getEmitScriptTarget(compilerOptions)) ? ts.factory.createIdentifier(propName.text) - : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* Single */) + : ts.isNoSubstitutionTemplateLiteral(propName) ? ts.factory.createStringLiteral(propName.text, quotePreference === 0 /* QuotePreference.Single */) : propName; } return undefined; @@ -153059,8 +153811,8 @@ var ts; return; } var pos = ts.skipTrivia(sourceFile.text, ts.moveRangePastModifiers(functionToConvert).pos); - changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, { suffix: " " }); - var _loop_13 = function (returnStatement) { + changes.insertModifierAt(sourceFile, pos, 131 /* SyntaxKind.AsyncKeyword */, { suffix: " " }); + var _loop_12 = function (returnStatement) { ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false); @@ -153082,7 +153834,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var returnStatement = returnStatements_1[_i]; - var state_5 = _loop_13(returnStatement); + var state_5 = _loop_12(returnStatement); if (typeof state_5 === "object") return state_5.value; } @@ -153134,7 +153886,7 @@ var ts; // NOTE: this is a mostly copy of `isReferenceToType` from checker.ts. While this violates DRY, it keeps // `isReferenceToType` in checker local to the checker to avoid the cost of a property lookup on `ts`. function isReferenceToType(type, target) { - return (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + return (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getExplicitPromisedTypeOfPromiseReturningCallExpression(node, callback, checker) { @@ -153197,7 +153949,7 @@ var ts; var ident = (firstParameter === null || firstParameter === void 0 ? void 0 : firstParameter.valueDeclaration) && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) - || ts.factory.createUniqueName("result", 16 /* Optimistic */); + || ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); collidingSymbolMap.add(ident.text, symbol); @@ -153278,7 +154030,7 @@ var ts; } function isNullOrUndefined(_a, node) { var checker = _a.checker; - if (node.kind === 104 /* NullKeyword */) + if (node.kind === 104 /* SyntaxKind.NullKeyword */) return true; if (ts.isIdentifier(node) && !ts.isGeneratedIdentifier(node) && ts.idText(node) === "undefined") { var symbol = checker.getSymbolAtLocation(node); @@ -153287,7 +154039,7 @@ var ts; return false; } function createUniqueSynthName(prevArgName) { - var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* Optimistic */); + var renamedPrevArg = ts.factory.createUniqueName(prevArgName.identifier.text, 16 /* GeneratedIdentifierFlags.Optimistic */); return createSynthIdentifier(renamedPrevArg); } function getPossibleNameForVarDecl(node, transformer, continuationArgName) { @@ -153307,7 +154059,7 @@ var ts; }); } else { - possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* Optimistic */), continuationArgName.types); + possibleNameForVarDecl = createSynthIdentifier(ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */), continuationArgName.types); } // We are about to write a 'let' variable declaration, but `transformExpression` for both // the try block and catch/finally block will assign to this name. Setting this flag indicates @@ -153323,10 +154075,10 @@ var ts; if (possibleNameForVarDecl && !shouldReturn(node, transformer)) { varDeclIdentifier = ts.getSynthesizedDeepClone(declareSynthIdentifier(possibleNameForVarDecl)); var typeArray = possibleNameForVarDecl.types; - var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */); + var unionType = transformer.checker.getUnionType(typeArray, 2 /* UnionReduction.Subtype */); var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); var varDecl = [ts.factory.createVariableDeclaration(varDeclIdentifier, /*exclamationToken*/ undefined, unionTypeNode)]; - var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* Let */)); + var varDeclList = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList(varDecl, 1 /* NodeFlags.Let */)); statements.push(varDeclList); } statements.push(tryStatement); @@ -153336,7 +154088,7 @@ var ts; ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingPattern(continuationArgName)), /*exclamationToken*/ undefined, /*type*/ undefined, varDeclIdentifier) - ], 2 /* Const */))); + ], 2 /* NodeFlags.Const */))); } return statements; } @@ -153441,12 +154193,12 @@ var ts; /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(ts.getSynthesizedDeepClone(declareSynthBindingName(variableName)), /*exclamationToken*/ undefined, typeAnnotation, rightHandSide) - ], 2 /* Const */)) + ], 2 /* NodeFlags.Const */)) ]; } function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) { if (typeAnnotation && expressionToReturn) { - var name = ts.factory.createUniqueName("result", 16 /* Optimistic */); + var name = ts.factory.createUniqueName("result", 16 /* GeneratedIdentifierFlags.Optimistic */); return __spreadArray(__spreadArray([], createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), true), [ ts.factory.createReturnStatement(name) ], false); @@ -153462,11 +154214,11 @@ var ts; function transformCallbackArgument(func, hasContinuation, continuationArgName, inputArgName, parent, transformer) { var _a; switch (func.kind) { - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // do not produce a transformed statement for a null argument break; - case 206 /* PropertyAccessExpression */: - case 79 /* Identifier */: // identifier includes undefined + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: // identifier includes undefined if (!inputArgName) { // undefined was argument passed to promise handler break; @@ -153476,7 +154228,7 @@ var ts; return maybeAnnotateAndReturn(synthCall, getExplicitPromisedTypeOfPromiseReturningCallExpression(parent, func, transformer.checker)); } var type = transformer.checker.getTypeAtLocation(func); - var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (!callSignatures.length) { // if identifier in handler has no call signatures, it's invalid return silentFail(); @@ -153487,8 +154239,8 @@ var ts; continuationArgName.types.push(transformer.checker.getAwaitedType(returnType) || returnType); } return varDeclOrAssignment; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: { + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: { var funcBody = func.body; var returnType_1 = (_a = getLastCallSignature(transformer.checker.getTypeAtLocation(func), transformer.checker)) === null || _a === void 0 ? void 0 : _a.getReturnType(); // Arrow functions with block bodies { } will enter this control flow @@ -153590,7 +154342,7 @@ var ts; return !!checker.getPromisedTypeOfPromise(type) ? ts.factory.createAwaitExpression(rightHandSide) : rightHandSide; } function getLastCallSignature(type, checker) { - var callSignatures = checker.getSignaturesOfType(type, 0 /* Call */); + var callSignatures = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); return ts.lastOrUndefined(callSignatures); } function removeReturns(stmts, prevArgName, transformer, seenReturnStatement) { @@ -153607,7 +154359,7 @@ var ts; ret.push(ts.factory.createExpressionStatement(ts.factory.createAssignment(referenceSynthIdentifier(prevArgName), possiblyAwaitedExpression))); } else { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, possiblyAwaitedExpression)], 2 /* NodeFlags.Const */)))); } } } @@ -153617,7 +154369,7 @@ var ts; } // if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables if (!seenReturnStatement && prevArgName !== undefined) { - ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* Const */)))); + ret.push(ts.factory.createVariableStatement(/*modifiers*/ undefined, (ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(declareSynthBindingName(prevArgName), /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createIdentifier("undefined"))], 2 /* NodeFlags.Const */)))); } return ret; } @@ -153699,12 +154451,12 @@ var ts; } function createSynthIdentifier(identifier, types) { if (types === void 0) { types = []; } - return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; + return { kind: 0 /* SynthBindingNameKind.Identifier */, identifier: identifier, types: types, hasBeenDeclared: false, hasBeenReferenced: false }; } function createSynthBindingPattern(bindingPattern, elements, types) { if (elements === void 0) { elements = ts.emptyArray; } if (types === void 0) { types = []; } - return { kind: 1 /* BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; + return { kind: 1 /* SynthBindingNameKind.BindingPattern */, bindingPattern: bindingPattern, elements: elements, types: types }; } function referenceSynthIdentifier(synthId) { synthId.hasBeenReferenced = true; @@ -153725,10 +154477,10 @@ var ts; return synthId.identifier; } function isSynthIdentifier(bindingName) { - return bindingName.kind === 0 /* Identifier */; + return bindingName.kind === 0 /* SynthBindingNameKind.Identifier */; } function isSynthBindingPattern(bindingName) { - return bindingName.kind === 1 /* BindingPattern */; + return bindingName.kind === 1 /* SynthBindingNameKind.BindingPattern */; } function shouldReturn(expression, transformer) { return !!expression.original && transformer.setOfExpressionsToReturn.has(ts.getNodeId(expression.original)); @@ -153766,10 +154518,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.factory.createPropertyAccessExpression(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -153809,9 +154561,9 @@ var ts; forEachExportReference(sourceFile, function (node) { var _a = node.name, text = _a.text, originalKeywordKind = _a.originalKeywordKind; if (!res.has(text) && (originalKeywordKind !== undefined && ts.isNonContextualKeyword(originalKeywordKind) - || checker.resolveName(text, node, 111551 /* Value */, /*excludeGlobals*/ true))) { + || checker.resolveName(text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true))) { // Unconditionally add an underscore in case `text` is a keyword. - res.set(text, makeUniqueName("_" + text, identifiers)); + res.set(text, makeUniqueName("_".concat(text), identifiers)); } }); return res; @@ -153829,29 +154581,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression) && ts.isIdentifier(node.name)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, useSitesToUnqualify, quotePreference) { switch (statement.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 63 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); + return operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports, useSitesToUnqualify); } } } @@ -153898,8 +154650,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return convertedImports([ @@ -153907,11 +154659,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return convertedImports([makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid syntax form ".concat(name.kind)); } } function convertAssignment(sourceFile, checker, assignment, changes, exports, useSitesToUnqualify) { @@ -153950,19 +154702,19 @@ var ts; function tryChangeModuleExportsObject(object, useSitesToUnqualify) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. // falls through - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return undefined; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer, useSitesToUnqualify); - case 169 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* ExportKeyword */)], prop, useSitesToUnqualify); + case 169 /* SyntaxKind.MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)], prop, useSitesToUnqualify); default: - ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind ".concat(prop.kind)); } }); return statements && [statements, false]; @@ -153991,8 +154743,8 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyMap; - return exports.has("export=" /* ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : - !exports.has("default" /* Default */) ? [[reExportStar(moduleSpecifier)], false] : + return exports.has("export=" /* InternalSymbolName.ExportEquals */) ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default" /* InternalSymbolName.Default */) ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } @@ -154007,23 +154759,23 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); - var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); + var semi = ts.findChildOfKind(parent, 26 /* SyntaxKind.SemicolonToken */, sourceFile); if (semi) changes.delete(sourceFile, semi); } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.factory.createToken(93 /* ExportKeyword */), ts.factory.createToken(85 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* SyntaxKind.DotToken */, sourceFile), [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */), ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported, useSitesToUnqualify) { - var modifiers = [ts.factory.createToken(93 /* ExportKeyword */)]; + var modifiers = [ts.factory.createToken(93 /* SyntaxKind.ExportKeyword */)]; switch (exported.kind) { - case 213 /* FunctionExpression */: { + case 213 /* SyntaxKind.FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -154031,10 +154783,10 @@ var ts; } } // falls through - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported, useSitesToUnqualify); default: @@ -154054,7 +154806,7 @@ var ts; : ts.getSynthesizedDeepCloneWithReplacements(nodeOrNodes, /*includeTrivia*/ true, replaceNode); function replaceNode(original) { // We are replacing `mod.SomeExport` wih `SomeExport`, so we only need to look at PropertyAccessExpressions - if (original.kind === 206 /* PropertyAccessExpression */) { + if (original.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var replacement = useSitesToUnqualify.get(original); // Remove entry from `useSitesToUnqualify` so the refactor knows it's taken care of by the parent statement we're replacing useSitesToUnqualify.delete(original); @@ -154069,7 +154821,7 @@ var ts; */ function convertSingleImport(name, moduleSpecifier, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined @@ -154080,7 +154832,7 @@ var ts; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 202 /* ArrayBindingPattern */: { + case 202 /* SyntaxKind.ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -154091,10 +154843,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.factory.createIdentifier(tmp)), ]); } - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return convertSingleIdentifierImport(name, moduleSpecifier, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind " + name.kind); + return ts.Debug.assertNever(name, "Convert to ES module got invalid name kind ".concat(name.kind)); } } /** @@ -154151,7 +154903,7 @@ var ts; // Identifiers helpers function makeUniqueName(name, identifiers) { while (identifiers.original.has(name) || identifiers.additional.has(name)) { - name = "_" + name; + name = "_".concat(name); } identifiers.additional.add(name); return name; @@ -154173,11 +154925,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return parent.name !== node; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return parent.propertyName !== node; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -154199,7 +154951,7 @@ var ts; return ts.factory.createImportSpecifier(/*isTypeOnly*/ false, propertyName !== undefined && propertyName !== name ? ts.factory.createIdentifier(propertyName) : undefined, ts.factory.createIdentifier(name)); } function makeConst(modifiers, name, init) { - return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* Const */)); + return ts.factory.createVariableStatement(modifiers, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, /*type*/ undefined, init)], 2 /* NodeFlags.Const */)); } function makeExportDeclaration(exportSpecifiers, moduleSpecifier) { return ts.factory.createExportDeclaration( @@ -154228,7 +154980,7 @@ var ts; if (!qualifiedName) return undefined; var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, qualifiedName); }); - var newText = qualifiedName.left.text + "[\"" + qualifiedName.right.text + "\"]"; + var newText = "".concat(qualifiedName.left.text, "[\"").concat(qualifiedName.right.text, "\"]"); return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Rewrite_as_the_indexed_access_type_0, newText], fixId, ts.Diagnostics.Rewrite_all_as_indexed_access_types)]; }, fixIds: [fixId], @@ -154288,7 +155040,7 @@ var ts; var exportDeclaration = exportClause.parent; var typeExportSpecifiers = getTypeExportSpecifiers(exportSpecifier, context); if (typeExportSpecifiers.length === exportClause.elements.length) { - changes.insertModifierBefore(context.sourceFile, 152 /* TypeKeyword */, exportClause); + changes.insertModifierBefore(context.sourceFile, 152 /* SyntaxKind.TypeKeyword */, exportClause); } else { var valueExportDeclaration = ts.factory.updateExportDeclaration(exportDeclaration, exportDeclaration.modifiers, @@ -154455,7 +155207,7 @@ var ts; return ts.Debug.checkDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { - return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* Private */); + return !symbol.valueDeclaration || !(ts.getEffectiveModifierFlags(symbol.valueDeclaration) & 8 /* ModifierFlags.Private */); } function addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, changeTracker, preferences) { var checker = context.program.getTypeChecker(); @@ -154468,10 +155220,10 @@ var ts; var classType = checker.getTypeAtLocation(classDeclaration); var constructor = ts.find(classDeclaration.members, function (m) { return ts.isConstructorDeclaration(m); }); if (!classType.getNumberIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 1 /* Number */); + createMissingIndexSignatureDeclaration(implementedType, 1 /* IndexKind.Number */); } if (!classType.getStringIndexType()) { - createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); + createMissingIndexSignatureDeclaration(implementedType, 0 /* IndexKind.String */); } var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host); codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, sourceFile, context, preferences, importAdder, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); }); @@ -154577,20 +155329,20 @@ var ts; var fixes = info.fixes, symbolName = info.symbolName; var fix = ts.first(fixes); switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addToNamespace.push(fix); break; - case 1 /* JsdocTypeImport */: + case 1 /* ImportFixKind.JsdocTypeImport */: importType.push(fix); break; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly; var key = String(ts.getNodeId(importClauseOrBindingPattern)); var entry = addToExisting.get(key); if (!entry) { addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: new ts.Map() }); } - if (importKind === 0 /* Named */) { + if (importKind === 0 /* ImportKind.Named */) { var prevValue = entry === null || entry === void 0 ? void 0 : entry.namedImports.get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); } @@ -154603,32 +155355,32 @@ var ts; } break; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, addAsTypeOnly = fix.addAsTypeOnly; var entry = getNewImportEntry(moduleSpecifier, importKind, useRequire, addAsTypeOnly); ts.Debug.assert(entry.useRequire === useRequire, "(Add new) Tried to add an `import` and a `require` for the same module"); switch (importKind) { - case 1 /* Default */: + case 1 /* ImportKind.Default */: ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport.name === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = { name: symbolName, addAsTypeOnly: reduceAddAsTypeOnlyValues((_b = entry.defaultImport) === null || _b === void 0 ? void 0 : _b.addAsTypeOnly, addAsTypeOnly) }; break; - case 0 /* Named */: + case 0 /* ImportKind.Named */: var prevValue = (entry.namedImports || (entry.namedImports = new ts.Map())).get(symbolName); entry.namedImports.set(symbolName, reduceAddAsTypeOnlyValues(prevValue, addAsTypeOnly)); break; - case 3 /* CommonJS */: - case 2 /* Namespace */: + case 3 /* ImportKind.CommonJS */: + case 2 /* ImportKind.Namespace */: ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly }; break; } break; } - case 4 /* PromoteTypeOnly */: + case 4 /* ImportFixKind.PromoteTypeOnly */: // Excluding from fix-all break; default: - ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); + ts.Debug.assertNever(fix, "fix wasn't never - got kind ".concat(fix.kind)); } function reduceAddAsTypeOnlyValues(prevValue, newValue) { // `NotAllowed` overrides `Required` because one addition of a new import might be required to be type-only @@ -154656,13 +155408,13 @@ var ts; namespaceLikeImport: undefined, useRequire: useRequire }; - if (importKind === 1 /* Default */ && addAsTypeOnly === 2 /* Required */) { + if (importKind === 1 /* ImportKind.Default */ && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */) { if (typeOnlyEntry) return typeOnlyEntry; newImports.set(typeOnlyKey, newEntry); return newEntry; } - if (addAsTypeOnly === 1 /* Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { + if (addAsTypeOnly === 1 /* AddAsTypeOnly.Allowed */ && (typeOnlyEntry || nonTypeOnlyEntry)) { return (typeOnlyEntry || nonTypeOnlyEntry); } if (nonTypeOnlyEntry) { @@ -154672,7 +155424,7 @@ var ts; return newEntry; } function newImportsKey(moduleSpecifier, topLevelTypeOnly) { - return (topLevelTypeOnly ? 1 : 0) + "|" + moduleSpecifier; + return "".concat(topLevelTypeOnly ? 1 : 0, "|").concat(moduleSpecifier); } } function writeFixes(changeTracker) { @@ -154762,7 +155514,7 @@ var ts; var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions); var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program); var includeSymbolNameInDescription = symbolName !== symbolToken.text; - return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions)); + return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* QuotePreference.Double */, compilerOptions)); } codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction; function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) { @@ -154790,7 +155542,7 @@ var ts; } var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol); if (named && ts.skipAlias(named, checker) === symbol) { - return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; + return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson }; } } } @@ -154813,7 +155565,7 @@ var ts; for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) { - result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); + result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* ExportKind.Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson }); } } }); @@ -154865,7 +155617,7 @@ var ts; if (namespacePrefix && moduleSpecifier) { var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; + return { kind: 0 /* ImportFixKind.UseNamespace */, namespacePrefix: namespacePrefix, position: position, moduleSpecifier: moduleSpecifier }; } } }); @@ -154873,11 +155625,11 @@ var ts; function getTargetModuleFromNamespaceLikeImport(declaration, checker) { var _a; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checker.getAliasedSymbol(declaration.symbol); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport); return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol); default: @@ -154887,11 +155639,11 @@ var ts; function getNamespaceLikeImportText(declaration) { var _a, _b, _c; switch (declaration.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return declaration.name.text; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text; default: return ts.Debug.assertNever(declaration); @@ -154900,31 +155652,31 @@ var ts; function getAddAsTypeOnly(isValidTypeOnlyUseSite, isForNewImportDeclaration, symbol, targetFlags, checker, compilerOptions) { if (!isValidTypeOnlyUseSite) { // Can't use a type-only import if the usage is an emitting position - return 4 /* NotAllowed */; + return 4 /* AddAsTypeOnly.NotAllowed */; } - if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* Error */) { + if (isForNewImportDeclaration && compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */) { // Not writing a (top-level) type-only import here would create an error because the runtime dependency is unnecessary - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } if (compilerOptions.isolatedModules && compilerOptions.preserveValueImports && - (!(targetFlags & 111551 /* Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { + (!(targetFlags & 111551 /* SymbolFlags.Value */) || !!checker.getTypeOnlyAliasDeclaration(symbol))) { // A type-only import is required for this symbol if under these settings if the symbol will // be erased, which will happen if the target symbol is purely a type or if it was exported/imported // as type-only already somewhere between this import and the target. - return 2 /* Required */; + return 2 /* AddAsTypeOnly.Required */; } - return 1 /* Allowed */; + return 1 /* AddAsTypeOnly.Allowed */; } function tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, compilerOptions) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind, symbol = _a.symbol, targetFlags = _a.targetFlags; - if (importKind === 3 /* CommonJS */ || importKind === 2 /* Namespace */ || declaration.kind === 265 /* ImportEqualsDeclaration */) { + if (importKind === 3 /* ImportKind.CommonJS */ || importKind === 2 /* ImportKind.Namespace */ || declaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // These kinds of imports are not combinable with anything return undefined; } - if (declaration.kind === 254 /* VariableDeclaration */) { - return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 201 /* ObjectBindingPattern */ - ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* NotAllowed */ } + if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { + return (importKind === 0 /* ImportKind.Named */ || importKind === 1 /* ImportKind.Default */) && declaration.name.kind === 201 /* SyntaxKind.ObjectBindingPattern */ + ? { kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, addAsTypeOnly: 4 /* AddAsTypeOnly.NotAllowed */ } : undefined; } var importClause = declaration.importClause; @@ -154933,22 +155685,22 @@ var ts; var name = importClause.name, namedBindings = importClause.namedBindings; // A type-only import may not have both a default and named imports, so the only way a name can // be added to an existing type-only import is adding a named import to existing named bindings. - if (importClause.isTypeOnly && !(importKind === 0 /* Named */ && namedBindings)) + if (importClause.isTypeOnly && !(importKind === 0 /* ImportKind.Named */ && namedBindings)) return undefined; // N.B. we don't have to figure out whether to use the main program checker // or the AutoImportProvider checker because we're adding to an existing import; the existence of // the import guarantees the symbol came from the main program. var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ false, symbol, targetFlags, checker, compilerOptions); - if (importKind === 1 /* Default */ && (name || // Cannot add a default import to a declaration that already has one - addAsTypeOnly === 2 /* Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings + if (importKind === 1 /* ImportKind.Default */ && (name || // Cannot add a default import to a declaration that already has one + addAsTypeOnly === 2 /* AddAsTypeOnly.Required */ && namedBindings // Cannot add a default import as type-only if the import already has named bindings )) return undefined; - if (importKind === 0 /* Named */ && - (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import + if (importKind === 0 /* ImportKind.Named */ && + (namedBindings === null || namedBindings === void 0 ? void 0 : namedBindings.kind) === 268 /* SyntaxKind.NamespaceImport */ // Cannot add a named import to a declaration that has a namespace import ) return undefined; return { - kind: 2 /* AddToExisting */, + kind: 2 /* ImportFixKind.AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.text, @@ -154967,7 +155719,7 @@ var ts; (importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i.parent); } } - else if (i.kind === 266 /* ImportDeclaration */ || i.kind === 265 /* ImportEqualsDeclaration */) { + else if (i.kind === 266 /* SyntaxKind.ImportDeclaration */ || i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); if (moduleSymbol) { (importMap || (importMap = ts.createMultiMap())).add(ts.getSymbolId(moduleSymbol), i); @@ -154978,7 +155730,7 @@ var ts; getImportsForExportInfo: function (_a) { var moduleSymbol = _a.moduleSymbol, exportKind = _a.exportKind, targetFlags = _a.targetFlags, symbol = _a.symbol; // Can't use an es6 import for a type in JS. - if (!(targetFlags & 111551 /* Value */) && ts.isSourceFileJS(importingFile)) + if (!(targetFlags & 111551 /* SymbolFlags.Value */) && ts.isSourceFileJS(importingFile)) return ts.emptyArray; var matchingDeclarations = importMap === null || importMap === void 0 ? void 0 : importMap.get(ts.getSymbolId(moduleSymbol)); if (!matchingDeclarations) @@ -155029,15 +155781,15 @@ var ts; var fixes = ts.flatMap(exportInfo, function (exportInfo, i) { var checker = getChecker(exportInfo.isFromPackageJson); var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers; - var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */); + var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* SymbolFlags.Value */); var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions); computedWithoutCacheCount += computedWithoutCache ? 1 : 0; return ts.mapDefined(moduleSpecifiers, function (moduleSpecifier) { return rejectNodeModulesRelativePaths && ts.pathContainsNodeModules(moduleSpecifier) ? undefined : // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : + !importedSymbolHasValueMeaning && isJs && position !== undefined ? { kind: 1 /* ImportFixKind.JsdocTypeImport */, moduleSpecifier: moduleSpecifier, position: position, exportInfo: exportInfo, isReExport: i > 0 } : { - kind: 3 /* AddNew */, + kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: getImportKind(sourceFile, exportInfo.exportKind, compilerOptions), useRequire: useRequire, @@ -155059,9 +155811,9 @@ var ts; var moduleSpecifier = (_b = ts.tryGetModuleSpecifierFromDeclaration(declaration)) === null || _b === void 0 ? void 0 : _b.text; if (moduleSpecifier) { var addAsTypeOnly = useRequire - ? 4 /* NotAllowed */ + ? 4 /* AddAsTypeOnly.NotAllowed */ : getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, symbol, targetFlags, checker, compilerOptions); - return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; + return { kind: 3 /* ImportFixKind.AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire }; } } function getFixesInfo(context, errorCode, pos, useAutoImportProvider) { @@ -155092,23 +155844,23 @@ var ts; if (!ts.some(fixes)) return; // These will always be placed first if available, and are better than other kinds - if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) { + if (fixes[0].kind === 0 /* ImportFixKind.UseNamespace */ || fixes[0].kind === 2 /* ImportFixKind.AddToExisting */) { return fixes[0]; } return fixes.reduce(function (best, fix) { // Takes true branch of conditional if `fix` is better than `best` - return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* LessThan */ ? fix : best; + return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), ts.hostGetCanonicalFileName(host)); }) === -1 /* Comparison.LessThan */ ? fix : best; }); } /** @returns `Comparison.LessThan` if `a` is better than `b`. */ function compareModuleSpecifiers(a, b, importingFile, program, allowsImportingSpecifier, toPath) { - if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) { + if (a.kind !== 0 /* ImportFixKind.UseNamespace */ && b.kind !== 0 /* ImportFixKind.UseNamespace */) { return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier)) || compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program) || ts.compareBooleans(isFixPossiblyReExportingImportingFile(a, importingFile, program.getCompilerOptions(), toPath), isFixPossiblyReExportingImportingFile(b, importingFile, program.getCompilerOptions(), toPath)) || ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier); } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } // This is a simple heuristic to try to avoid creating an import cycle with a barrel re-export. // E.g., do not `import { Foo } from ".."` when you could `import { Foo } from "../Foo"`. @@ -155131,10 +155883,10 @@ var ts; } function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) { if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; if (ts.startsWith(b, "node:") && !ts.startsWith(a, "node:")) - return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* GreaterThan */ : -1 /* LessThan */; - return 0 /* EqualTo */; + return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? 1 /* Comparison.GreaterThan */ : -1 /* Comparison.LessThan */; + return 0 /* Comparison.EqualTo */; } function getFixesInfoForUMDImport(_a, token) { var _b; @@ -155145,7 +155897,7 @@ var ts; return undefined; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; - var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; + var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* ExportKind.UMD */, targetFlags: symbol.flags, isFromPackageJson: false }]; var useRequire = shouldUseRequire(sourceFile, program); var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined; var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes; @@ -155159,7 +155911,7 @@ var ts; // The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`. var parent = token.parent; return (ts.isJsxOpeningLikeElement(parent) && parent.tagName === token) || ts.isJsxOpeningFragment(parent) - ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) + ? ts.tryCast(checker.resolveName(checker.getJsxNamespace(parent), ts.isJsxOpeningLikeElement(parent) ? token : parent, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false), ts.isUMDExportSymbol) : undefined; } /** @@ -155168,10 +155920,10 @@ var ts; */ function getImportKind(importingFile, exportKind, compilerOptions, forceImportKeyword) { switch (exportKind) { - case 0 /* Named */: return 0 /* Named */; - case 1 /* Default */: return 1 /* Default */; - case 2 /* ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); - case 3 /* UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 0 /* ExportKind.Named */: return 0 /* ImportKind.Named */; + case 1 /* ExportKind.Default */: return 1 /* ImportKind.Default */; + case 2 /* ExportKind.ExportEquals */: return getExportEqualsImportKind(importingFile, compilerOptions, !!forceImportKeyword); + case 3 /* ExportKind.UMD */: return getUmdImportKind(importingFile, compilerOptions, !!forceImportKeyword); default: return ts.Debug.assertNever(exportKind); } } @@ -155179,7 +155931,7 @@ var ts; function getUmdImportKind(importingFile, compilerOptions, forceImportKeyword) { // Import a synthetic `default` if enabled. if (ts.getAllowSyntheticDefaultImports(compilerOptions)) { - return 1 /* Default */; + return 1 /* ImportKind.Default */; } // When a synthetic `default` is unavailable, use `import..require` if the module kind supports it. var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -155188,9 +155940,9 @@ var ts; case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* Namespace */ : 3 /* CommonJS */; + return ts.isExternalModule(importingFile) || forceImportKeyword ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; } - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: case ts.ModuleKind.ES2020: @@ -155198,12 +155950,12 @@ var ts; case ts.ModuleKind.ESNext: case ts.ModuleKind.None: // Fall back to the `import * as ns` style import. - return 2 /* Namespace */; + return 2 /* ImportKind.Namespace */; case ts.ModuleKind.Node16: case ts.ModuleKind.NodeNext: - return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* Namespace */ : 3 /* CommonJS */; + return importingFile.impliedNodeFormat === ts.ModuleKind.ESNext ? 2 /* ImportKind.Namespace */ : 3 /* ImportKind.CommonJS */; default: - return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind ".concat(moduleKind)); } } function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) { @@ -155212,7 +155964,7 @@ var ts; var compilerOptions = program.getCompilerOptions(); var symbolName = getSymbolName(sourceFile, checker, symbolToken, compilerOptions); // "default" is a keyword and not a legal identifier for the import, but appears as an identifier. - if (symbolName === "default" /* Default */) { + if (symbolName === "default" /* InternalSymbolName.Default */) { return undefined; } var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken); @@ -155226,13 +155978,13 @@ var ts; } function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) { var checker = program.getTypeChecker(); - var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); if (!symbol) return undefined; var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol); if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile) return undefined; - return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; + return { kind: 4 /* ImportFixKind.PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration }; } function getSymbolName(sourceFile, checker, symbolToken, compilerOptions) { var parent = symbolToken.parent; @@ -155247,8 +155999,8 @@ var ts; function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) { if (ts.isIntrinsicJsxName(symbolToken.text)) return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory - var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true); - return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */); + var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ true); + return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* SymbolFlags.Value */); } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) { @@ -155280,7 +156032,7 @@ var ts; // check exports with the same name var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol); if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson); + addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* ExportKind.Named */, program, isFromPackageJson); } }); return originalSymbolToExportInfos; @@ -155291,14 +156043,14 @@ var ts; // 1. 'import =' will not work in es2015+ TS files, so the decision is between a default // and a namespace import, based on allowSyntheticDefaultImports/esModuleInterop. if (!isJS && ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) { - return allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */; } // 2. 'import =' will not work in JavaScript, so the decision is between a default import, // a namespace import, and const/require. if (isJS) { return ts.isExternalModule(importingFile) || forceImportKeyword - ? allowSyntheticDefaults ? 1 /* Default */ : 2 /* Namespace */ - : 3 /* CommonJS */; + ? allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 2 /* ImportKind.Namespace */ + : 3 /* ImportKind.CommonJS */; } // 3. At this point the most correct choice is probably 'import =', but people // really hate that, so look to see if the importing file has any precedent @@ -155307,12 +156059,12 @@ var ts; var statement = _a[_i]; // `import foo` parses as an ImportEqualsDeclaration even though it could be an ImportDeclaration if (ts.isImportEqualsDeclaration(statement) && !ts.nodeIsMissing(statement.moduleReference)) { - return 3 /* CommonJS */; + return 3 /* ImportKind.CommonJS */; } } // 4. We have no precedent to go on, so just use a default import if // allowSyntheticDefaultImports/esModuleInterop is enabled. - return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; + return allowSyntheticDefaults ? 1 /* ImportKind.Default */ : 3 /* ImportKind.CommonJS */; } function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { var diag; @@ -155323,45 +156075,45 @@ var ts; } function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) { switch (fix.kind) { - case 0 /* UseNamespace */: + case 0 /* ImportFixKind.UseNamespace */: addNamespaceQualifier(changes, sourceFile, fix); - return [ts.Diagnostics.Change_0_to_1, symbolName, fix.namespacePrefix + "." + symbolName]; - case 1 /* JsdocTypeImport */: + return [ts.Diagnostics.Change_0_to_1, symbolName, "".concat(fix.namespacePrefix, ".").concat(symbolName)]; + case 1 /* ImportFixKind.JsdocTypeImport */: addImportType(changes, sourceFile, fix, quotePreference); return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName]; - case 2 /* AddToExisting */: { + case 2 /* ImportFixKind.AddToExisting */: { var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier; - doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); + doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes] : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes]; } - case 3 /* AddNew */: { + case 3 /* ImportFixKind.AddNew */: { var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire; var getDeclarations = useRequire ? getNewRequires : getNewImports; - var defaultImport = importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; - var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; - var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var defaultImport = importKind === 1 /* ImportKind.Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; + var namedImports = importKind === 0 /* ImportKind.Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined; + var namespaceLikeImport = importKind === 2 /* ImportKind.Namespace */ || importKind === 3 /* ImportKind.CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined; ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true); return includeSymbolNameInDescription ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier] : [ts.Diagnostics.Add_import_from_0, moduleSpecifier]; } - case 4 /* PromoteTypeOnly */: { + case 4 /* ImportFixKind.PromoteTypeOnly */: { var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration; var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile); - return promotedDeclaration.kind === 270 /* ImportSpecifier */ + return promotedDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)] : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)]; } default: - return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); + return ts.Debug.assertNever(fix, "Unexpected fix kind ".concat(fix.kind)); } } function getModuleSpecifierText(promotedDeclaration) { var _a, _b; - return promotedDeclaration.kind === 265 /* ImportEqualsDeclaration */ + return promotedDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText() : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text; } @@ -155369,7 +156121,7 @@ var ts; // See comment in `doAddExistingFix` on constant with the same name. var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules; switch (aliasDeclaration.kind) { - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: if (aliasDeclaration.isTypeOnly) { if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) { changes.delete(sourceFile, aliasDeclaration); @@ -155387,13 +156139,13 @@ var ts; promoteImportClause(aliasDeclaration.parent.parent); return aliasDeclaration.parent.parent; } - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: promoteImportClause(aliasDeclaration); return aliasDeclaration; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: promoteImportClause(aliasDeclaration.parent); return aliasDeclaration.parent; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1)); return aliasDeclaration; default: @@ -155405,7 +156157,7 @@ var ts; var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports); if (namedImports && namedImports.elements.length > 1) { if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) && - aliasDeclaration.kind === 270 /* ImportSpecifier */ && + aliasDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && namedImports.elements.indexOf(aliasDeclaration) !== 0) { // The import specifier being promoted will be the only non-type-only, // import in the NamedImports, so it should be moved to the front. @@ -155415,7 +156167,7 @@ var ts; for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) { var element = _a[_i]; if (element !== aliasDeclaration && !element.isTypeOnly) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, element); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, element); } } } @@ -155424,7 +156176,7 @@ var ts; } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) { var _a; - if (clause.kind === 201 /* ObjectBindingPattern */) { + if (clause.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (defaultImport) { addElementToBindingPattern(clause, defaultImport.name, "default"); } @@ -155434,7 +156186,7 @@ var ts; } return; } - var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* NotAllowed */; }); + var promoteFromTypeOnly = clause.isTypeOnly && ts.some(__spreadArray([defaultImport], namedImports, true), function (i) { return (i === null || i === void 0 ? void 0 : i.addAsTypeOnly) === 4 /* AddAsTypeOnly.NotAllowed */; }); var existingSpecifiers = clause.namedBindings && ((_a = ts.tryCast(clause.namedBindings, ts.isNamedImports)) === null || _a === void 0 ? void 0 : _a.elements); // If we are promoting from a type-only import and `--isolatedModules` and `--preserveValueImports` // are enabled, we need to make every existing import specifier type-only. It may be possible that @@ -155485,7 +156237,7 @@ var ts; if (convertExistingToTypeOnly && existingSpecifiers) { for (var _d = 0, existingSpecifiers_1 = existingSpecifiers; _d < existingSpecifiers_1.length; _d++) { var specifier = existingSpecifiers_1[_d]; - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, specifier); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, specifier); } } } @@ -155509,11 +156261,11 @@ var ts; } function getImportTypePrefix(moduleSpecifier, quotePreference) { var quote = ts.getQuoteFromPreference(quotePreference); - return "import(" + quote + moduleSpecifier + quote + ")."; + return "import(".concat(quote).concat(moduleSpecifier).concat(quote, ")."); } function needsTypeOnly(_a) { var addAsTypeOnly = _a.addAsTypeOnly; - return addAsTypeOnly === 2 /* Required */; + return addAsTypeOnly === 2 /* AddAsTypeOnly.Required */; } function getNewImports(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport) { var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); @@ -155522,12 +156274,12 @@ var ts; var topLevelTypeOnly_1 = (!defaultImport || needsTypeOnly(defaultImport)) && ts.every(namedImports, needsTypeOnly); statements = ts.combine(statements, ts.makeImport(defaultImport && ts.factory.createIdentifier(defaultImport.name), namedImports === null || namedImports === void 0 ? void 0 : namedImports.map(function (_a) { var addAsTypeOnly = _a.addAsTypeOnly, name = _a.name; - return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* Required */, + return ts.factory.createImportSpecifier(!topLevelTypeOnly_1 && addAsTypeOnly === 2 /* AddAsTypeOnly.Required */, /*propertyName*/ undefined, ts.factory.createIdentifier(name)); }), moduleSpecifier, quotePreference, topLevelTypeOnly_1)); } if (namespaceLikeImport) { - var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ + var declaration = namespaceLikeImport.importKind === 3 /* ImportKind.CommonJS */ ? ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, needsTypeOnly(namespaceLikeImport), ts.factory.createIdentifier(namespaceLikeImport.name), ts.factory.createExternalModuleReference(quotedModuleSpecifier)) : ts.factory.createImportDeclaration( @@ -155566,7 +156318,7 @@ var ts; ts.factory.createVariableDeclaration(typeof name === "string" ? ts.factory.createIdentifier(name) : name, /*exclamationToken*/ undefined, /*type*/ undefined, ts.factory.createCallExpression(ts.factory.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } function symbolHasMeaning(_a, meaning) { var declarations = _a.declarations; @@ -155603,7 +156355,7 @@ var ts; lastCharWasValid = isValid; } // Need `|| "_"` to ensure result isn't empty. - return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; + return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_".concat(res); } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; })(codefix = ts.codefix || (ts.codefix = {})); @@ -155629,54 +156381,90 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var sourceFile = context.sourceFile, span = context.span, program = context.program; - var related = getDiagnosticRelatedInfo(program, sourceFile, span); - if (!related) { + var sourceFile = context.sourceFile, span = context.span, program = context.program, preferences = context.preferences, host = context.host; + var info = getInfo(program, sourceFile, span); + if (info === undefined) return; - } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, program, preferences, host, sourceFile, info); }); return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag); - if (!info) - return; - return addMissingConstraint(changes, info); - }); }, + getAllCodeActions: function (context) { + var program = context.program, preferences = context.preferences, host = context.host; + var seen = new ts.Map(); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { + codefix.eachDiagnostic(context, errorCodes, function (diag) { + var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length)); + if (info) { + if (ts.addToSeen(seen, ts.getNodeId(info.declaration))) { + return addMissingConstraint(changes, program, preferences, host, diag.file, info); + } + } + return undefined; + }); + })); + } }); - function getDiagnosticRelatedInfo(program, sourceFile, span) { + function getInfo(program, sourceFile, span) { var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; }); - if (!diag || !diag.relatedInformation) + if (diag === undefined || diag.relatedInformation === undefined) return; var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; }); - if (!related) + if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined) return; - return related; - } - function addMissingConstraint(changes, related) { - var decl = findAncestorMatchingSpan(related.file, related); - if (!decl) + var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length)); + if (declaration === undefined) return; - if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) { - decl = decl.parent; + if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) { + declaration = declaration.parent; + } + if (ts.isTypeParameterDeclaration(declaration)) { + // should only issue fix on type parameters written using `extends` + if (ts.isMappedTypeNode(declaration.parent)) + return; + var token = ts.getTokenAtPosition(sourceFile, span.start); + var checker = program.getTypeChecker(); + var constraint = tryGetConstraintType(checker, token) || tryGetConstraintFromDiagnosticMessage(related.messageText); + return { constraint: constraint, declaration: declaration, token: token }; + } + return undefined; + } + function addMissingConstraint(changes, program, preferences, host, sourceFile, info) { + var declaration = info.declaration, constraint = info.constraint; + var checker = program.getTypeChecker(); + if (ts.isString(constraint)) { + changes.insertText(sourceFile, declaration.name.end, " extends ".concat(constraint)); + } + else { + var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); + var tracker = codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }); + var importAdder = codefix.createImportAdder(sourceFile, program, preferences, host); + var typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, scriptTarget, /*flags*/ undefined, tracker); + if (typeNode) { + changes.replaceNode(sourceFile, declaration, ts.factory.updateTypeParameterDeclaration(declaration, /*modifiers*/ undefined, declaration.name, typeNode, declaration.default)); + importAdder.writeFixes(changes); + } } - if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent)) - return; // should only issue fix on type parameters written using `extends` - var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/); - if (!newConstraint) - return; - var newConstraintText = newConstraint[1]; - changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText); } function findAncestorMatchingSpan(sourceFile, span) { - var token = ts.getTokenAtPosition(sourceFile, span.start); var end = ts.textSpanEnd(span); + var token = ts.getTokenAtPosition(sourceFile, span.start); while (token.end < end) { token = token.parent; } return token; } + function tryGetConstraintFromDiagnosticMessage(messageText) { + var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1]; + return constraint; + } + function tryGetConstraintType(checker, node) { + if (ts.isTypeNode(node.parent)) { + return checker.getTypeArgumentConstraint(node.parent); + } + var contextualType = ts.isExpression(node) ? checker.getContextualType(node) : undefined; + return contextualType || checker.getTypeAtLocation(node); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -155809,7 +156597,7 @@ var ts; accessibilityModifier ? accessibilityModifier.end : lastDecorator ? ts.skipTrivia(sourceFile.text, lastDecorator.end) : classElement.getStart(sourceFile); var options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " }; - changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* OverrideKeyword */, options); + changeTracker.insertModifierAt(sourceFile, modifierPos, 159 /* SyntaxKind.OverrideKeyword */, options); } function doRemoveOverrideModifierChange(changeTracker, sourceFile, pos) { var classElement = findContainerClassElementLike(sourceFile, pos); @@ -155823,13 +156611,13 @@ var ts; } function isClassElementLikeHasJSDoc(node) { switch (node.kind) { - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.isParameterPropertyDeclaration(node, node.parent); default: return false; @@ -155871,7 +156659,7 @@ var ts; }); function doChange(changes, sourceFile, node, preferences) { var quotePreference = ts.getQuotePreference(sourceFile, preferences); - var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* Single */); + var argumentsExpression = ts.factory.createStringLiteral(node.name.text, quotePreference === 0 /* QuotePreference.Single */); changes.replaceNode(sourceFile, node, ts.isPropertyAccessChain(node) ? ts.factory.createElementAccessChain(node.expression, node.questionDotToken, argumentsExpression) : ts.factory.createElementAccessExpression(node.expression, argumentsExpression)); @@ -155911,7 +156699,7 @@ var ts; if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn)) return undefined; if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function - var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* FunctionKeyword */, sourceFile)); + var fnKeyword = ts.Debug.checkDefined(ts.findChildOfKind(fn, 98 /* SyntaxKind.FunctionKeyword */, sourceFile)); var name = fn.name; var body = ts.Debug.checkDefined(fn.body); // Should be defined because the function contained a 'this' expression if (ts.isFunctionExpression(fn)) { @@ -155930,7 +156718,7 @@ var ts; else { // `function f() {}` => `const f = () => {}` // `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`. - changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* ConstKeyword */)); + changes.replaceNode(sourceFile, fnKeyword, ts.factory.createToken(85 /* SyntaxKind.ConstKeyword */)); changes.insertText(sourceFile, name.end, " = "); changes.insertText(sourceFile, body.pos, " =>"); return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; @@ -155961,7 +156749,7 @@ var ts; }); function getNamedTupleMember(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - return ts.findAncestor(token, function (t) { return t.kind === 197 /* NamedTupleMember */; }); + return ts.findAncestor(token, function (t) { return t.kind === 197 /* SyntaxKind.NamedTupleMember */; }); } function doChange(changes, sourceFile, namedTupleMember) { if (!namedTupleMember) { @@ -155970,16 +156758,16 @@ var ts; var unwrappedType = namedTupleMember.type; var sawOptional = false; var sawRest = false; - while (unwrappedType.kind === 185 /* OptionalType */ || unwrappedType.kind === 186 /* RestType */ || unwrappedType.kind === 191 /* ParenthesizedType */) { - if (unwrappedType.kind === 185 /* OptionalType */) { + while (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */ || unwrappedType.kind === 186 /* SyntaxKind.RestType */ || unwrappedType.kind === 191 /* SyntaxKind.ParenthesizedType */) { + if (unwrappedType.kind === 185 /* SyntaxKind.OptionalType */) { sawOptional = true; } - else if (unwrappedType.kind === 186 /* RestType */) { + else if (unwrappedType.kind === 186 /* SyntaxKind.RestType */) { sawRest = true; } unwrappedType = unwrappedType.type; } - var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined), unwrappedType); + var updated = ts.factory.updateNamedTupleMember(namedTupleMember, namedTupleMember.dotDotDotToken || (sawRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined), namedTupleMember.name, namedTupleMember.questionToken || (sawOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined), unwrappedType); if (updated === namedTupleMember) { return; } @@ -156045,18 +156833,18 @@ var ts; if (ts.isPropertyAccessExpression(parent) && parent.name === node) { ts.Debug.assert(ts.isMemberName(node), "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(parent.expression); - if (parent.flags & 32 /* OptionalChain */) { + if (parent.flags & 32 /* NodeFlags.OptionalChain */) { containingType = checker.getNonNullableType(containingType); } suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType); } - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && parent.left === node && ts.isPrivateIdentifier(node)) { var receiverType = checker.getTypeAtLocation(parent.right); suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, receiverType); } else if (ts.isQualifiedName(parent) && parent.right === node) { var symbol = checker.getSymbolAtLocation(parent.left); - if (symbol && symbol.flags & 1536 /* Module */) { + if (symbol && symbol.flags & 1536 /* SymbolFlags.Module */) { suggestedSymbol = checker.getSuggestedSymbolForNonexistentModule(parent.right, symbol); } } @@ -156074,7 +156862,7 @@ var ts; var props = checker.getContextualTypeForArgumentAtIndex(tag, 0); suggestedSymbol = checker.getSuggestedSymbolForNonexistentJSXAttribute(node, props); } - else if (ts.hasSyntacticModifier(parent, 16384 /* Override */) && ts.isClassElement(parent) && parent.name === node) { + else if (ts.hasSyntacticModifier(parent, 16384 /* ModifierFlags.Override */) && ts.isClassElement(parent) && parent.name === node) { var baseDeclaration = ts.findAncestor(node, ts.isClassLike); var baseTypeNode = baseDeclaration ? ts.getEffectiveBaseTypeNode(baseDeclaration) : undefined; var baseType = baseTypeNode ? checker.getTypeAtLocation(baseTypeNode) : undefined; @@ -156107,14 +156895,14 @@ var ts; } function convertSemanticMeaningToSymbolFlags(meaning) { var flags = 0; - if (meaning & 4 /* Namespace */) { - flags |= 1920 /* Namespace */; + if (meaning & 4 /* SemanticMeaning.Namespace */) { + flags |= 1920 /* SymbolFlags.Namespace */; } - if (meaning & 2 /* Type */) { - flags |= 788968 /* Type */; + if (meaning & 2 /* SemanticMeaning.Type */) { + flags |= 788968 /* SymbolFlags.Type */; } - if (meaning & 1 /* Value */) { - flags |= 111551 /* Value */; + if (meaning & 1 /* SemanticMeaning.Value */) { + flags |= 111551 /* SymbolFlags.Value */; } return flags; } @@ -156186,7 +156974,7 @@ var ts; }); }, }); function createObjectTypeFromLabeledExpression(checker, label, expression) { - var member = checker.createSymbol(4 /* Property */, label.escapedText); + var member = checker.createSymbol(4 /* SymbolFlags.Property */, label.escapedText); member.type = checker.getTypeAtLocation(expression); var members = ts.createSymbolTable([member]); return checker.createAnonymousType(/*symbol*/ undefined, members, [], [], []); @@ -156245,7 +157033,7 @@ var ts; if (isFunctionType) { var sig = checker.getSignatureFromDeclaration(declaration); if (sig) { - if (ts.hasSyntacticModifier(declaration, 256 /* Async */)) { + if (ts.hasSyntacticModifier(declaration, 256 /* ModifierFlags.Async */)) { exprType = checker.createPromiseType(exprType); } var newSig = checker.createSignature(declaration, sig.typeParameters, sig.thisParameter, sig.parameters, exprType, @@ -156289,19 +157077,19 @@ var ts; } function getVariableLikeInitializer(declaration) { switch (declaration.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: return declaration.initializer; - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); - case 297 /* ShorthandPropertyAssignment */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return undefined; } } @@ -156363,19 +157151,19 @@ var ts; if (!info) { return undefined; } - if (info.kind === 3 /* ObjectLiteral */) { + if (info.kind === 3 /* InfoKind.ObjectLiteral */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addObjectLiteralProperties(t, context, info); }); return [codefix.createCodeFixAction(fixMissingProperties, changes, ts.Diagnostics.Add_missing_properties, fixMissingProperties, ts.Diagnostics.Add_all_missing_properties)]; } - if (info.kind === 4 /* JsxAttributes */) { + if (info.kind === 4 /* InfoKind.JsxAttributes */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addJsxAttributes(t, context, info); }); return [codefix.createCodeFixAction(fixMissingAttributes, changes, ts.Diagnostics.Add_missing_attributes, fixMissingAttributes, ts.Diagnostics.Add_all_missing_attributes)]; } - if (info.kind === 2 /* Function */) { + if (info.kind === 2 /* InfoKind.Function */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addFunctionDeclaration(t, context, info); }); return [codefix.createCodeFixAction(fixMissingFunctionDeclaration, changes, [ts.Diagnostics.Add_missing_function_declaration_0, info.token.text], fixMissingFunctionDeclaration, ts.Diagnostics.Add_all_missing_function_declarations)]; } - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addEnumMemberDeclaration(t, context.program.getTypeChecker(), info); }); return [codefix.createCodeFixAction(fixMissingMember, changes, [ts.Diagnostics.Add_missing_enum_member_0, info.token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; } @@ -156393,20 +157181,20 @@ var ts; if (!info || !ts.addToSeen(seen, ts.getNodeId(info.parentDeclaration) + "#" + info.token.text)) { return; } - if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* Function */) { + if (fixId === fixMissingFunctionDeclaration && info.kind === 2 /* InfoKind.Function */) { addFunctionDeclaration(changes, context, info); } - else if (fixId === fixMissingProperties && info.kind === 3 /* ObjectLiteral */) { + else if (fixId === fixMissingProperties && info.kind === 3 /* InfoKind.ObjectLiteral */) { addObjectLiteralProperties(changes, context, info); } - else if (fixId === fixMissingAttributes && info.kind === 4 /* JsxAttributes */) { + else if (fixId === fixMissingAttributes && info.kind === 4 /* InfoKind.JsxAttributes */) { addJsxAttributes(changes, context, info); } else { - if (info.kind === 1 /* Enum */) { + if (info.kind === 1 /* InfoKind.Enum */) { addEnumMemberDeclaration(changes, checker, info); } - if (info.kind === 0 /* TypeLikeDeclaration */) { + if (info.kind === 0 /* InfoKind.TypeLikeDeclaration */) { var parentDeclaration = info.parentDeclaration, token_1 = info.token; var infos = ts.getOrUpdate(typeDeclToMembers, parentDeclaration, function () { return []; }); if (!infos.some(function (i) { return i.token.text === token_1.text; })) { @@ -156417,7 +157205,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, declaration) { var supers = ts.isTypeLiteralNode(declaration) ? undefined : codefix.getAllSupers(declaration, checker); - var _loop_14 = function (info) { + var _loop_13 = function (info) { // If some superclass added this property, don't add it again. if (supers === null || supers === void 0 ? void 0 : supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -156430,21 +157218,21 @@ var ts; var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, modifierFlags = info.modifierFlags, token = info.token, call = info.call, isJSFile = info.isJSFile; // Always prefer to add a method declaration if possible. if (call && !ts.isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* Static */, parentDeclaration, declSourceFile); + addMethodDeclaration(context, changes, call, token, modifierFlags & 32 /* ModifierFlags.Static */, parentDeclaration, declSourceFile); } else { if (isJSFile && !ts.isInterfaceDeclaration(parentDeclaration) && !ts.isTypeLiteralNode(parentDeclaration)) { - addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); + addMissingMemberInJs(changes, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); } else { var typeNode = getTypeNode(checker, parentDeclaration, token); - addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* Static */); + addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, modifierFlags & 32 /* ModifierFlags.Static */); } } }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_14(info); + _loop_13(info); } }); })); @@ -156465,12 +157253,12 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, tokenPos); var parent = token.parent; if (errorCode === ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code) { - if (!(token.kind === 18 /* OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) + if (!(token.kind === 18 /* SyntaxKind.OpenBraceToken */ && ts.isObjectLiteralExpression(parent) && ts.isCallExpression(parent.parent))) return undefined; var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; }); if (argIndex < 0) return undefined; - var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* Call */)); + var signature = ts.singleOrUndefined(checker.getSignaturesOfType(checker.getTypeAtLocation(parent.parent.expression), 0 /* SignatureKind.Call */)); if (!(signature && signature.declaration && signature.parameters[argIndex])) return undefined; var param = signature.parameters[argIndex].valueDeclaration; @@ -156479,7 +157267,7 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent), checker.getParameterType(signature, argIndex), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: param.name, properties: properties, parentDeclaration: parent }; } if (!ts.isMemberName(token)) return undefined; @@ -156487,17 +157275,17 @@ var ts; var properties = ts.arrayFrom(checker.getUnmatchedProperties(checker.getTypeAtLocation(parent.initializer), checker.getTypeAtLocation(token), /* requireOptionalProperties */ false, /* matchDiscriminantProperties */ false)); if (!ts.length(properties)) return undefined; - return { kind: 3 /* ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; + return { kind: 3 /* InfoKind.ObjectLiteral */, token: token, properties: properties, parentDeclaration: parent.initializer }; } if (ts.isIdentifier(token) && ts.isJsxOpeningLikeElement(token.parent)) { var target = ts.getEmitScriptTarget(program.getCompilerOptions()); var attributes = getUnmatchedAttributes(checker, target, token.parent); if (!ts.length(attributes)) return undefined; - return { kind: 4 /* JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; + return { kind: 4 /* InfoKind.JsxAttributes */, token: token, attributes: attributes, parentDeclaration: token.parent }; } - if (ts.isIdentifier(token) && ts.isCallExpression(parent)) { - return { kind: 2 /* Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* None */, parentDeclaration: sourceFile }; + if (ts.isIdentifier(token) && ts.isCallExpression(parent) && parent.expression === token) { + return { kind: 2 /* InfoKind.Function */, token: token, call: parent, sourceFile: sourceFile, modifierFlags: 0 /* ModifierFlags.None */, parentDeclaration: sourceFile }; } if (!ts.isPropertyAccessExpression(parent)) return undefined; @@ -156509,13 +157297,13 @@ var ts; var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration); var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile(); if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleDeclaration }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration }; } var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile); if (sourceFile.commonJsModuleIndicator) return undefined; if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) { - return { kind: 2 /* Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* Export */, parentDeclaration: moduleSourceFile }; + return { kind: 2 /* InfoKind.Function */, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile }; } } var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); @@ -156529,15 +157317,15 @@ var ts; if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration))) return undefined; var declSourceFile = declaration.getSourceFile(); - var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* None */ : - (makeStatic ? 32 /* Static */ : 0 /* None */) | (ts.startsWithUnderscore(token.text) ? 8 /* Private */ : 0 /* None */); + var modifierFlags = ts.isTypeLiteralNode(declaration) ? 0 /* ModifierFlags.None */ : + (makeStatic ? 32 /* ModifierFlags.Static */ : 0 /* ModifierFlags.None */) | (ts.startsWithUnderscore(token.text) ? 8 /* ModifierFlags.Private */ : 0 /* ModifierFlags.None */); var isJSFile = ts.isSourceFileJS(declSourceFile); var call = ts.tryCast(parent.parent, ts.isCallExpression); - return { kind: 0 /* TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; + return { kind: 0 /* InfoKind.TypeLikeDeclaration */, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile }; } var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration); if (enumDeclaration && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) { - return { kind: 1 /* Enum */, token: token, parentDeclaration: enumDeclaration }; + return { kind: 1 /* InfoKind.Enum */, token: token, parentDeclaration: enumDeclaration }; } return undefined; } @@ -156553,18 +157341,18 @@ var ts; if (ts.isInterfaceDeclaration(parentDeclaration) || ts.isTypeLiteralNode(parentDeclaration)) { return undefined; } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* Static */)); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingMemberInJs(t, declSourceFile, parentDeclaration, token, !!(modifierFlags & 32 /* ModifierFlags.Static */)); }); if (changes.length === 0) { return undefined; } - var diagnostic = modifierFlags & 32 /* Static */ ? ts.Diagnostics.Initialize_static_property_0 : + var diagnostic = modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Initialize_static_property_0 : ts.isPrivateIdentifier(token) ? ts.Diagnostics.Declare_a_private_field_named_0 : ts.Diagnostics.Initialize_property_0_in_the_constructor; return codefix.createCodeFixAction(fixMissingMember, changes, [diagnostic, token.text], fixMissingMember, ts.Diagnostics.Add_all_missing_members); } function addMissingMemberInJs(changeTracker, sourceFile, classDeclaration, token, makeStatic) { var tokenName = token.text; if (makeStatic) { - if (classDeclaration.kind === 226 /* ClassExpression */) { + if (classDeclaration.kind === 226 /* SyntaxKind.ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -156600,32 +157388,32 @@ var ts; function createActionsForAddMissingMemberInTypeScriptFile(context, _a) { var parentDeclaration = _a.parentDeclaration, declSourceFile = _a.declSourceFile, modifierFlags = _a.modifierFlags, token = _a.token; var memberName = token.text; - var isStatic = modifierFlags & 32 /* Static */; + var isStatic = modifierFlags & 32 /* ModifierFlags.Static */; var typeNode = getTypeNode(context.program.getTypeChecker(), parentDeclaration, token); var addPropertyDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, parentDeclaration, memberName, typeNode, modifierFlags); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + var actions = [codefix.createCodeFixAction(fixMissingMember, addPropertyDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [isStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, memberName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; if (isStatic || ts.isPrivateIdentifier(token)) { return actions; } - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addPropertyDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_property_0, memberName])); } actions.push(createAddIndexSignatureAction(context, declSourceFile, parentDeclaration, token.text, typeNode)); return actions; } function getTypeNode(checker, node, token) { var typeNode; - if (token.parent.parent.kind === 221 /* BinaryExpression */) { + if (token.parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); - typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NoTruncation */); + typeNode = checker.typeToTypeNode(widenedType, node, 1 /* NodeBuilderFlags.NoTruncation */); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NoTruncation */) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, 1 /* NodeBuilderFlags.NoTruncation */) : undefined; } - return typeNode || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return typeNode || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function addPropertyDeclaration(changeTracker, sourceFile, node, tokenName, typeNode, modifierFlags) { var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; @@ -156653,7 +157441,7 @@ var ts; } function createAddIndexSignatureAction(context, sourceFile, node, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + var stringTypeNode = ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); var indexingParameter = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "x", @@ -156676,15 +157464,15 @@ var ts; } var methodName = token.text; var addMethodDeclarationChanges = function (modifierFlags) { return ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, call, token, modifierFlags, parentDeclaration, declSourceFile); }); }; - var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* Static */), [modifierFlags & 32 /* Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; - if (modifierFlags & 8 /* Private */) { - actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); + var actions = [codefix.createCodeFixAction(fixMissingMember, addMethodDeclarationChanges(modifierFlags & 32 /* ModifierFlags.Static */), [modifierFlags & 32 /* ModifierFlags.Static */ ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, methodName], fixMissingMember, ts.Diagnostics.Add_all_missing_members)]; + if (modifierFlags & 8 /* ModifierFlags.Private */) { + actions.unshift(codefix.createCodeFixActionWithoutFixAll(fixMissingMember, addMethodDeclarationChanges(8 /* ModifierFlags.Private */), [ts.Diagnostics.Declare_private_method_0, methodName])); } return actions; } function addMethodDeclaration(context, changes, callExpression, name, modifierFlags, parentDeclaration, sourceFile) { var importAdder = codefix.createImportAdder(sourceFile, context.program, context.preferences, context.host); - var kind = ts.isClassLike(parentDeclaration) ? 169 /* MethodDeclaration */ : 168 /* MethodSignature */; + var kind = ts.isClassLike(parentDeclaration) ? 169 /* SyntaxKind.MethodDeclaration */ : 168 /* SyntaxKind.MethodSignature */; var signatureDeclaration = codefix.createSignatureDeclarationFromCallExpression(kind, context, importAdder, callExpression, name, modifierFlags, parentDeclaration); var containingMethodDeclaration = tryGetContainingMethodDeclaration(parentDeclaration, callExpression); if (containingMethodDeclaration) { @@ -156704,7 +157492,7 @@ var ts; */ var hasStringInitializer = ts.some(parentDeclaration.members, function (member) { var type = checker.getTypeAtLocation(member); - return !!(type && type.flags & 402653316 /* StringLike */); + return !!(type && type.flags & 402653316 /* TypeFlags.StringLike */); }); var enumMember = ts.factory.createEnumMember(token, hasStringInitializer ? ts.factory.createStringLiteral(token.text) : undefined); changes.replaceNode(parentDeclaration.getSourceFile(), parentDeclaration, ts.factory.updateEnumDeclaration(parentDeclaration, parentDeclaration.modifiers, parentDeclaration.name, ts.concatenate(parentDeclaration.members, ts.singleElementArray(enumMember))), { @@ -156714,7 +157502,7 @@ var ts; } function addFunctionDeclaration(changes, context, info) { var importAdder = codefix.createImportAdder(context.sourceFile, context.program, context.preferences, context.host); - var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); + var functionDeclaration = codefix.createSignatureDeclarationFromCallExpression(256 /* SyntaxKind.FunctionDeclaration */, context, importAdder, info.call, ts.idText(info.token), info.modifierFlags, info.parentDeclaration); changes.insertNodeAtEndOfScope(info.sourceFile, info.parentDeclaration, functionDeclaration); importAdder.writeFixes(changes); } @@ -156744,7 +157532,7 @@ var ts; var checker = context.program.getTypeChecker(); var props = ts.map(info.properties, function (prop) { var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop), info.parentDeclaration); - return ts.factory.createPropertyAssignment(ts.createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === 0 /* Single */), initializer); + return ts.factory.createPropertyAssignment(createPropertyNameFromSymbol(prop, target, quotePreference, checker), initializer); }); var options = { leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, @@ -156755,42 +157543,42 @@ var ts; importAdder.writeFixes(changes); } function tryGetValueFromType(context, checker, importAdder, quotePreference, type, enclosingDeclaration) { - if (type.flags & 3 /* AnyOrUnknown */) { + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return createUndefined(); } - if (type.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { - return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + return ts.factory.createStringLiteral("", /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { return ts.factory.createNumericLiteral(0); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { return ts.factory.createBigIntLiteral("0n"); } - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return ts.factory.createFalse(); } - if (type.flags & 1056 /* EnumLike */) { + if (type.flags & 1056 /* TypeFlags.EnumLike */) { var enumMember = type.symbol.exports ? ts.firstOrUndefined(ts.arrayFrom(type.symbol.exports.values())) : type.symbol; - var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); + var name = checker.symbolToExpression(type.symbol.parent ? type.symbol.parent : type.symbol, 111551 /* SymbolFlags.Value */, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); return enumMember === undefined || name === undefined ? ts.factory.createNumericLiteral(0) : ts.factory.createPropertyAccessExpression(name, checker.symbolToString(enumMember)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { return ts.factory.createNumericLiteral(type.value); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } - if (type.flags & 128 /* StringLiteral */) { - return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* Single */); + if (type.flags & 128 /* TypeFlags.StringLiteral */) { + return ts.factory.createStringLiteral(type.value, /* isSingleQuote */ quotePreference === 0 /* QuotePreference.Single */); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { return ts.factory.createNull(); } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var expression = ts.firstDefined(type.types, function (t) { return tryGetValueFromType(context, checker, importAdder, quotePreference, t, enclosingDeclaration); }); return expression !== null && expression !== void 0 ? expression : createUndefined(); } @@ -156804,17 +157592,17 @@ var ts; }); return ts.factory.createObjectLiteralExpression(props, /*multiLine*/ true); } - if (ts.getObjectFlags(type) & 16 /* Anonymous */) { + if (ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) { var decl = ts.find(type.symbol.declarations || ts.emptyArray, ts.or(ts.isFunctionTypeNode, ts.isMethodSignature, ts.isMethodDeclaration)); if (decl === undefined) return createUndefined(); - var signature = checker.getSignaturesOfType(type, 0 /* Call */); + var signature = checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */); if (signature === undefined) return createUndefined(); - var func = codefix.createSignatureDeclarationFromSignature(213 /* FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder); + var func = codefix.createSignatureDeclarationFromSignature(213 /* SyntaxKind.FunctionExpression */, context, quotePreference, signature[0], codefix.createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference), /*name*/ undefined, /*modifiers*/ undefined, /*optional*/ undefined, /*enclosingDeclaration*/ enclosingDeclaration, importAdder); return func !== null && func !== void 0 ? func : createUndefined(); } - if (ts.getObjectFlags(type) & 1 /* Class */) { + if (ts.getObjectFlags(type) & 1 /* ObjectFlags.Class */) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (classDeclaration === undefined || ts.hasAbstractModifier(classDeclaration)) return createUndefined(); @@ -156829,8 +157617,8 @@ var ts; return ts.factory.createIdentifier("undefined"); } function isObjectLiteralType(type) { - return (type.flags & 524288 /* Object */) && - ((ts.getObjectFlags(type) & 128 /* ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); + return (type.flags & 524288 /* TypeFlags.Object */) && + ((ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */) || (type.symbol && ts.tryCast(ts.singleOrUndefined(type.symbol.declarations), ts.isTypeLiteralNode))); } function getUnmatchedAttributes(checker, target, source) { var attrsType = checker.getContextualType(source.attributes); @@ -156854,7 +157642,7 @@ var ts; } } return ts.filter(targetProps, function (targetProp) { - return ts.isIdentifierText(targetProp.name, target, 1 /* JSX */) && !((targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */) || seenNames.has(targetProp.escapedName)); + return ts.isIdentifierText(targetProp.name, target, 1 /* LanguageVariant.JSX */) && !((targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */) || seenNames.has(targetProp.escapedName)); }); } function tryGetContainingMethodDeclaration(node, callExpression) { @@ -156864,6 +157652,15 @@ var ts; var declaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); }); return declaration && declaration.parent === node ? declaration : undefined; } + function createPropertyNameFromSymbol(symbol, target, quotePreference, checker) { + if (ts.isTransientSymbol(symbol) && symbol.nameType && symbol.nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + var expression = checker.symbolToExpression(symbol.nameType.symbol, 111551 /* SymbolFlags.Value */, symbol.valueDeclaration, 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */); + if (expression) { + return ts.factory.createComputedPropertyName(expression); + } + } + return ts.createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === 0 /* QuotePreference.Single */); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -156939,7 +157736,7 @@ var ts; break; } default: - ts.Debug.fail("Bad fixId: " + context.fixId); + ts.Debug.fail("Bad fixId: ".concat(context.fixId)); } }); }, @@ -157014,7 +157811,7 @@ var ts; // See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files // (now named `codeFixClassExtendAbstractPrivateProperty.ts`) var flags = ts.getSyntacticModifierFlags(ts.first(symbol.getDeclarations())); - return !(flags & 8 /* Private */) && !!(flags & 128 /* Abstract */); + return !(flags & 8 /* ModifierFlags.Private */) && !!(flags & 128 /* ModifierFlags.Abstract */); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -157057,7 +157854,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 108 /* ThisKeyword */) + if (token.kind !== 108 /* SyntaxKind.ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -157201,7 +157998,7 @@ var ts; codeFixes.push(codefix.createCodeFixActionWithoutFixAll("fixModuleOption", changes, [ts.Diagnostics.Set_the_module_option_in_your_configuration_file_to_0, "esnext"])); } var target = ts.getEmitScriptTarget(compilerOptions); - var targetOutOfRange = target < 4 /* ES2017 */ || target > 99 /* ESNext */; + var targetOutOfRange = target < 4 /* ScriptTarget.ES2017 */ || target > 99 /* ScriptTarget.ESNext */; if (targetOutOfRange) { var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) { var configObject = ts.getTsConfigObjectLiteralExpression(configFile); @@ -157280,17 +158077,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 94 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 94 /* SyntaxKind.ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.factory.createToken(117 /* SyntaxKind.ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 94 /* ExtendsKeyword */ && - heritageClauses[1].token === 117 /* ImplementsKeyword */) { + heritageClauses[0].token === 94 /* SyntaxKind.ExtendsKeyword */ && + heritageClauses[1].token === 117 /* SyntaxKind.ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); - changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* CommaToken */)); + changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.factory.createToken(27 /* SyntaxKind.CommaToken */)); // Rough heuristic: delete trailing whitespace after keyword so that it's not excessive. // (Trailing because leading might be indentation, which is more sensitive.) var text = sourceFile.text; @@ -157387,7 +158184,7 @@ var ts; if (!isValidCharacter(character)) { return; } - var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(sourceFile, preferences, character) + "}"; + var replacement = useHtmlEntity ? htmlEntity[character] : "{".concat(ts.quote(sourceFile, preferences, character), "}"); changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -157494,7 +158291,7 @@ var ts; var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start); if (!importDeclaration) return; - var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); + var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 270 /* SyntaxKind.ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); }); var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); }); var actions; if (namespaceChanges.length) { @@ -157509,7 +158306,7 @@ var ts; }); function getImportDeclaration(sourceFile, program, start) { var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier); - if (!identifier || identifier.parent.kind !== 178 /* TypeReference */) + if (!identifier || identifier.parent.kind !== 178 /* SyntaxKind.TypeReference */) return; var checker = program.getTypeChecker(); var symbol = checker.getSymbolAtLocation(identifier); @@ -157521,11 +158318,11 @@ var ts; // new type-only import declaration, but honestly I doubt anyone will ever use this // codefix at all, so it's probably not worth the lines of code. function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) { - if (importDeclaration.kind === 265 /* ImportEqualsDeclaration */) { - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importDeclaration.name); + if (importDeclaration.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importDeclaration.name); return; } - var importClause = importDeclaration.kind === 267 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent; + var importClause = importDeclaration.kind === 267 /* SyntaxKind.ImportClause */ ? importDeclaration : importDeclaration.parent.parent; if (importClause.name && importClause.namedBindings) { // Cannot convert an import with a default import and named bindings to type-only // (it's a grammar error). @@ -157533,7 +158330,7 @@ var ts; } var checker = program.getTypeChecker(); var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) { - if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */) + if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* SymbolFlags.Value */) return true; }); if (importsValue) { @@ -157542,7 +158339,7 @@ var ts; // Don't convert it to type-only. return; } - changes.insertModifierBefore(sourceFile, 152 /* TypeKeyword */, importClause); + changes.insertModifierBefore(sourceFile, 152 /* SyntaxKind.TypeKeyword */, importClause); } function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) { ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent); @@ -157578,7 +158375,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 29 /* LessThanToken */) { + if (token.kind === 29 /* SyntaxKind.LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -157620,7 +158417,7 @@ var ts; ]; } var result = []; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -157662,13 +158459,13 @@ var ts; break; } case fixIdDelete: { - if (token.kind === 137 /* InferKeyword */ || isImport(token)) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */ || isImport(token)) { break; // Can't delete } else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 29 /* LessThanToken */) { + else if (token.kind === 29 /* SyntaxKind.LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (ts.isObjectBindingPattern(token.parent)) { @@ -157691,7 +158488,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -157702,7 +158499,7 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); @@ -157711,18 +158508,18 @@ var ts; changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } function isImport(token) { - return token.kind === 100 /* ImportKeyword */ - || token.kind === 79 /* Identifier */ && (token.parent.kind === 270 /* ImportSpecifier */ || token.parent.kind === 267 /* ImportClause */); + return token.kind === 100 /* SyntaxKind.ImportKeyword */ + || token.kind === 79 /* SyntaxKind.Identifier */ && (token.parent.kind === 270 /* SyntaxKind.ImportSpecifier */ || token.parent.kind === 267 /* SyntaxKind.ImportClause */); } /** Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. */ function tryGetFullImport(token) { - return token.kind === 100 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 100 /* SyntaxKind.ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function canDeleteEntireVariableStatement(sourceFile, token) { return ts.isVariableDeclarationList(token.parent) && ts.first(token.parent.getChildren(sourceFile)) === token; } function deleteEntireVariableStatement(changes, sourceFile, node) { - changes.delete(sourceFile, node.parent.kind === 237 /* VariableStatement */ ? node.parent : node); + changes.delete(sourceFile, node.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? node.parent : node); } function deleteDestructuringElements(changes, sourceFile, node) { ts.forEach(node.elements, function (n) { return changes.delete(sourceFile, n); }); @@ -157731,15 +158528,15 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 137 /* InferKeyword */) { + if (token.kind === 137 /* SyntaxKind.InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { - changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_" + token.text)); + changes.replaceNode(sourceFile, token, ts.factory.createIdentifier("_".concat(token.text))); if (ts.isParameter(token.parent)) { ts.getJSDocParameterTags(token.parent).forEach(function (tag) { if (ts.isIdentifier(tag.name)) { - changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_" + tag.name.text)); + changes.replaceNode(sourceFile, tag.name, ts.factory.createIdentifier("_".concat(tag.name.text))); } }); } @@ -157747,14 +158544,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return true; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return true; } } @@ -157809,8 +158606,8 @@ var ts; function mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll) { var parent = parameter.parent; switch (parent.kind) { - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: var index = parent.parameters.indexOf(parameter); var referent = ts.isMethodDeclaration(parent) ? parent.name : parent; var entries = ts.FindAllReferences.Core.getReferencedSymbolsForNode(parent.pos, referent, program, sourceFiles, cancellationToken); @@ -157819,7 +158616,7 @@ var ts; var entry = entries_2[_i]; for (var _a = 0, _b = entry.references; _a < _b.length; _a++) { var reference = _b[_a]; - if (reference.kind === 1 /* Node */) { + if (reference.kind === 1 /* FindAllReferences.EntryKind.Node */) { // argument in super(...) var isSuperCall_1 = ts.isSuperKeyword(reference.node) && ts.isCallExpression(reference.node.parent) @@ -157840,20 +158637,20 @@ var ts; } } return true; - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { if (parent.name && isCallbackLike(checker, sourceFile, parent.name)) { return isLastParameter(parent, parameter, isFixAll); } return true; } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. return isLastParameter(parent, parameter, isFixAll); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Setter must have a parameter return false; - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Getter cannot have parameters return true; default: @@ -157914,7 +158711,7 @@ var ts; var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -157925,8 +158722,8 @@ var ts; return; } // falls through - case 241 /* WhileStatement */: - case 242 /* ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: changes.delete(sourceFile, container); return; } @@ -157975,7 +158772,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* SyntaxKind.ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -157999,10 +158796,10 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 314 /* JSDocNullableType */) { + if (typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` - actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); + actions.push(fix(checker.getNullableType(type, 32768 /* TypeFlags.Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); } return actions; function fix(type, fixId, fixAllDescription) { @@ -158019,7 +158816,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 314 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 314 /* SyntaxKind.JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* TypeFlags.Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -158036,22 +158833,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 229 /* AsExpression */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: - case 172 /* GetAccessor */: - case 176 /* IndexSignature */: - case 195 /* MappedType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 211 /* TypeAssertionExpression */: - case 254 /* VariableDeclaration */: + case 229 /* SyntaxKind.AsExpression */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 176 /* SyntaxKind.IndexSignature */: + case 195 /* SyntaxKind.MappedType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; default: return false; @@ -158086,7 +158883,7 @@ var ts; }); } }); function doChange(changes, sourceFile, name) { - changes.replaceNodeWithText(sourceFile, name, name.text + "()"); + changes.replaceNodeWithText(sourceFile, name, "".concat(name.text, "()")); } function getCallName(sourceFile, start) { var token = ts.getTokenAtPosition(sourceFile, start); @@ -158154,15 +158951,15 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: insertBefore = containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 98 /* FunctionKeyword */, sourceFile); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 98 /* SyntaxKind.FunctionKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - var kind = containingFunction.typeParameters ? 29 /* LessThanToken */ : 20 /* OpenParenToken */; + case 214 /* SyntaxKind.ArrowFunction */: + var kind = containingFunction.typeParameters ? 29 /* SyntaxKind.LessThanToken */ : 20 /* SyntaxKind.OpenParenToken */; insertBefore = ts.findChildOfKind(containingFunction, kind, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -158177,11 +158974,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 79 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 79 /* SyntaxKind.Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.factory.createTypeReferenceNode("Promise", ts.factory.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 131 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 131 /* SyntaxKind.AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -158343,7 +159140,7 @@ var ts; return errorCode; } function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 108 /* ThisKeyword */) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 79 /* SyntaxKind.Identifier */ && token.kind !== 25 /* SyntaxKind.DotDotDotToken */ && token.kind !== 108 /* SyntaxKind.ThisKeyword */) { return undefined; } var parent = token.parent; @@ -158444,9 +159241,9 @@ var ts; annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } else { - var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { @@ -158454,7 +159251,7 @@ var ts; } } if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { @@ -158497,7 +159294,7 @@ var ts; function annotate(changes, importAdder, sourceFile, declaration, type, program, host) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 166 /* SyntaxKind.PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -158533,7 +159330,7 @@ var ts; var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host); if (typeNode) { var name = ts.factory.cloneNode(param.name); - ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(name, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); return { name: ts.factory.cloneNode(param.name), param: param, isOptional: !!inference.isOptional, typeNode: typeNode }; } }); @@ -158541,9 +159338,9 @@ var ts; return; } if (ts.isArrowFunction(signature) || ts.isFunctionExpression(signature)) { - var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* OpenParenToken */, sourceFile); + var needParens = ts.isArrowFunction(signature) && !ts.findChildOfKind(signature, 20 /* SyntaxKind.OpenParenToken */, sourceFile); if (needParens) { - changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* OpenParenToken */)); + changes.insertNodeBefore(sourceFile, ts.first(signature.parameters), ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); } ts.forEach(inferences, function (_a) { var typeNode = _a.typeNode, param = _a.param; @@ -158552,7 +159349,7 @@ var ts; changes.insertNodeAt(sourceFile, param.getStart(sourceFile), jsDoc, { suffix: " " }); }); if (needParens) { - changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeAfter(sourceFile, ts.last(signature.parameters), ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } } else { @@ -158566,7 +159363,7 @@ var ts; function getReferences(token, program, cancellationToken) { // Position shouldn't matter since token is not a SourceFile. return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) { - return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; + return entry.kind !== 0 /* FindAllReferences.EntryKind.Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; }); } function inferTypeForVariableFromUsage(token, program, cancellationToken) { @@ -158584,19 +159381,19 @@ var ts; function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 171 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 134 /* ConstructorKeyword */, sourceFile); + case 171 /* SyntaxKind.Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 134 /* SyntaxKind.ConstructorKeyword */, sourceFile); break; - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: var parent = containingFunction.parent; searchToken = (ts.isVariableDeclaration(parent) || ts.isPropertyDeclaration(parent)) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: searchToken = containingFunction.name; break; } @@ -158738,24 +159535,24 @@ var ts; node = node.parent; } switch (node.parent.kind) { - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: inferTypeFromExpressionStatement(node, usage); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: usage.isNumber = true; break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: if (node.parent.expression === node) { inferTypeFromCallExpression(node.parent, usage); } @@ -158763,20 +159560,20 @@ var ts; inferTypeFromContextualType(node, usage); } break; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: inferTypeFromPropertyAssignment(node.parent, usage); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. @@ -158800,13 +159597,13 @@ var ts; } function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: usage.isNumber = true; break; - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: @@ -158816,65 +159613,65 @@ var ts; function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: // MultiplicativeOperator // falls through - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: // ShiftOperator // falls through - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator // falls through - case 50 /* AmpersandToken */: - case 51 /* BarToken */: - case 52 /* CaretToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 51 /* SyntaxKind.BarToken */: + case 52 /* SyntaxKind.CaretToken */: // CompoundAssignmentOperator // falls through - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 74 /* BarEqualsToken */: - case 78 /* CaretEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: // AdditiveOperator // falls through - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: // RelationalOperator // falls through - case 29 /* LessThanToken */: - case 32 /* LessThanEqualsToken */: - case 31 /* GreaterThanToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 1056 /* EnumLike */) { + if (operandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, operandType); } else { usage.isNumber = true; } break; - case 64 /* PlusEqualsToken */: - case 39 /* PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 1056 /* EnumLike */) { + if (otherOperandType.flags & 1056 /* TypeFlags.EnumLike */) { addCandidateType(usage, otherOperandType); } - else if (otherOperandType.flags & 296 /* NumberLike */) { + else if (otherOperandType.flags & 296 /* TypeFlags.NumberLike */) { usage.isNumber = true; } - else if (otherOperandType.flags & 402653316 /* StringLike */) { + else if (otherOperandType.flags & 402653316 /* TypeFlags.StringLike */) { usage.isString = true; } - else if (otherOperandType.flags & 1 /* Any */) { + else if (otherOperandType.flags & 1 /* TypeFlags.Any */) { // do nothing, maybe we'll learn something elsewhere } else { @@ -158882,31 +159679,31 @@ var ts; } break; // AssignmentOperators - case 63 /* EqualsToken */: - case 34 /* EqualsEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (node === parent.left) { usage.isString = true; } break; // LogicalOperator Or NullishCoalescing - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 254 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: - case 102 /* InstanceOfKeyword */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: // nothing to infer here break; } @@ -158926,7 +159723,7 @@ var ts; } } calculateUsageOfNode(parent, call.return_); - if (parent.kind === 208 /* CallExpression */) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */) { (usage.calls || (usage.calls = [])).push(call); } else { @@ -158951,7 +159748,7 @@ var ts; var indexType = checker.getTypeAtLocation(parent.argumentExpression); var indexUsage = createEmptyUsage(); calculateUsageOfNode(parent, indexUsage); - if (indexType.flags & 296 /* NumberLike */) { + if (indexType.flags & 296 /* TypeFlags.NumberLike */) { usage.numberIndex = indexUsage; } else { @@ -158998,21 +159795,21 @@ var ts; low: function (t) { return t === stringNumber; } }, { - high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); }, - low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); } + high: function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); }, + low: function (t) { return !!(t.flags & (1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)); } }, { - high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); }, - low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); } + high: function (t) { return !(t.flags & (98304 /* TypeFlags.Nullable */ | 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) && !(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); }, + low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* ObjectFlags.Anonymous */); } } ]; var good = removeLowPriorityInferences(inferences, priorities); - var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; }); + var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */; }); if (anons.length) { - good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); }); + good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* ObjectFlags.Anonymous */); }); good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* UnionReduction.Subtype */)); } function combineAnonymousTypes(anons) { if (anons.length === 1) { @@ -159031,22 +159828,22 @@ var ts; var p = _b[_a]; props.add(p.name, p.valueDeclaration ? checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration) : checker.getAnyType()); } - calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); - constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); - var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* String */); + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* SignatureKind.Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* SignatureKind.Construct */)); + var stringIndexInfo = checker.getIndexInfoOfType(anon, 0 /* IndexKind.String */); if (stringIndexInfo) { stringIndices.push(stringIndexInfo.type); stringIndexReadonly = stringIndexReadonly || stringIndexInfo.isReadonly; } - var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* Number */); + var numberIndexInfo = checker.getIndexInfoOfType(anon, 1 /* IndexKind.Number */); if (numberIndexInfo) { numberIndices.push(numberIndexInfo.type); numberIndexReadonly = numberIndexReadonly || numberIndexInfo.isReadonly; } } var members = ts.mapEntries(props, function (name, types) { - var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0; - var s = checker.createSymbol(4 /* Property */ | isOptional, name); + var isOptional = types.length < anons.length ? 16777216 /* SymbolFlags.Optional */ : 0; + var s = checker.createSymbol(4 /* SymbolFlags.Property */ | isOptional, name); s.type = checker.getUnionType(types); return [name, s]; }); @@ -159078,7 +159875,7 @@ var ts; var candidateTypes = (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); }); var callsType = ((_c = usage.calls) === null || _c === void 0 ? void 0 : _c.length) ? inferStructuralType(usage) : undefined; if (callsType && candidateTypes) { - types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* Subtype */)); + types.push(checker.getUnionType(__spreadArray([callsType], candidateTypes, true), 2 /* UnionReduction.Subtype */)); } else { if (callsType) { @@ -159095,7 +159892,7 @@ var ts; var members = new ts.Map(); if (usage.properties) { usage.properties.forEach(function (u, name) { - var symbol = checker.createSymbol(4 /* Property */, name); + var symbol = checker.createSymbol(4 /* SymbolFlags.Property */, name); symbol.type = combineFromUsage(u); members.set(name, symbol); }); @@ -159123,7 +159920,7 @@ var ts; return true; } if (propUsage.calls) { - var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + var sigs = checker.getSignaturesOfType(source, 0 /* SignatureKind.Call */); return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); } else { @@ -159137,7 +159934,7 @@ var ts; * 2. inference to/from calls with a single signature */ function inferInstantiationFromUsage(type, usage) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !usage.properties) { return type; } var generic = type.target; @@ -159156,10 +159953,10 @@ var ts; if (genericType === typeParameter) { return [usageType]; } - else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + else if (genericType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); } - else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + else if (ts.getObjectFlags(genericType) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(usageType) & 4 /* ObjectFlags.Reference */) { // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference var genericArgs = checker.getTypeArguments(genericType); var usageArgs = checker.getTypeArguments(usageType); @@ -159173,8 +159970,8 @@ var ts; } return types; } - var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); - var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* SignatureKind.Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* SignatureKind.Call */); if (genericSigs.length === 1 && usageSigs.length === 1) { return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } @@ -159209,27 +160006,27 @@ var ts; function getSignatureFromCalls(calls) { var parameters = []; var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); - var _loop_15 = function (i) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + var _loop_14 = function (i) { + var symbol = checker.createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg".concat(i))); symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { - symbol.flags |= 16777216 /* Optional */; + symbol.flags |= 16777216 /* SymbolFlags.Optional */; } parameters.push(symbol); }; for (var i = 0; i < length; i++) { - _loop_15(i); + _loop_14(i); } var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* SignatureFlags.None */); } function addCandidateType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } function addCandidateThisType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + if (type && !(type.flags & 1 /* TypeFlags.Any */) && !(type.flags & 131072 /* TypeFlags.Never */)) { (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } @@ -159313,7 +160110,7 @@ var ts; codefix.createCodeFixActionWithoutFixAll(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [ ts.createTextChange(sourceFile.checkJsDirective ? ts.createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end) - : ts.createTextSpan(0, 0), "// @ts-nocheck" + newLineCharacter), + : ts.createTextSpan(0, 0), "// @ts-nocheck".concat(newLineCharacter)), ])], ts.Diagnostics.Disable_checking_for_this_file), ]; if (ts.textChanges.isValidLocationToAddComment(sourceFile, span.start)) { @@ -159380,7 +160177,7 @@ var ts; * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub. */ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, preserveOptional, isAmbient) { - if (preserveOptional === void 0) { preserveOptional = 3 /* All */; } + if (preserveOptional === void 0) { preserveOptional = 3 /* PreserveOptionalFlags.All */; } if (isAmbient === void 0) { isAmbient = false; } var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { @@ -159393,13 +160190,13 @@ var ts; var visibilityModifier = createVisibilityModifier(ts.getEffectiveModifierFlags(declaration)); var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); - var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient; + var optional = !!(symbol.flags & 16777216 /* SymbolFlags.Optional */); + var ambient = !!(enclosingDeclaration.flags & 16777216 /* NodeFlags.Ambient */) || isAmbient; var quotePreference = ts.getQuotePreference(sourceFile, preferences); switch (declaration.kind) { - case 166 /* PropertySignature */: - case 167 /* PropertyDeclaration */: - var flags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; + case 166 /* SyntaxKind.PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + var flags = quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (importAdder) { var importableReference = tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget); @@ -159408,11 +160205,11 @@ var ts; importSymbols(importAdder, importableReference.symbols); } } - addClassElement(ts.factory.createPropertyDeclaration(modifiers, name, optional && (preserveOptional & 2 /* Property */) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeNode, + addClassElement(ts.factory.createPropertyDeclaration(modifiers, name, optional && (preserveOptional & 2 /* PreserveOptionalFlags.Property */) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor @@ -159439,8 +160236,8 @@ var ts; } break; } - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -159448,7 +160245,7 @@ var ts; // If there is more than one overload but no implementation signature // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. - var signatures = checker.getSignaturesOfType(type, 0 /* Call */); + var signatures = type.isUnion() ? ts.flatMap(type.types, function (t) { return t.getCallSignatures(); }) : type.getCallSignatures(); if (!ts.some(signatures)) { break; } @@ -159470,13 +160267,13 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* Method */), modifiers, quotePreference, body)); + addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), modifiers, quotePreference, body)); } } break; } function outputMethod(quotePreference, signature, modifiers, name, body) { - var method = createSignatureDeclarationFromSignature(169 /* MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* Method */), enclosingDeclaration, importAdder); + var method = createSignatureDeclarationFromSignature(169 /* SyntaxKind.MethodDeclaration */, context, quotePreference, signature, body, name, modifiers, optional && !!(preserveOptional & 1 /* PreserveOptionalFlags.Method */), enclosingDeclaration, importAdder); if (method) addClassElement(method); } @@ -159486,10 +160283,10 @@ var ts; var program = context.program; var checker = program.getTypeChecker(); var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); - var flags = 1 /* NoTruncation */ - | 256 /* SuppressAnyReturnType */ - | 524288 /* AllowEmptyTuple */ - | (quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : 0 /* None */); + var flags = 1 /* NodeBuilderFlags.NoTruncation */ + | 256 /* NodeBuilderFlags.SuppressAnyReturnType */ + | 524288 /* NodeBuilderFlags.AllowEmptyTuple */ + | (quotePreference === 0 /* QuotePreference.Single */ ? 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */ : 0 /* NodeBuilderFlags.None */); var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, kind, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; @@ -159542,7 +160339,7 @@ var ts; } } } - var questionToken = optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var questionToken = optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var asteriskToken = signatureDeclaration.asteriskToken; if (ts.isFunctionExpression(signatureDeclaration)) { return ts.factory.updateFunctionExpression(signatureDeclaration, modifiers, signatureDeclaration.asteriskToken, ts.tryCast(name, ts.isIdentifier), typeParameters, parameters, type, body !== null && body !== void 0 ? body : signatureDeclaration.body); @@ -159567,38 +160364,50 @@ var ts; var names = ts.map(args, function (arg) { return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined; }); - var types = isJs ? [] : ts.map(args, function (arg) { - return typeToAutoImportableTypeNode(checker, importAdder, checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, scriptTarget, /*flags*/ undefined, tracker); - }); + var instanceTypes = isJs ? [] : ts.map(args, function (arg) { return checker.getTypeAtLocation(arg); }); + var _a = getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, /*flags*/ undefined, tracker), argumentTypeNodes = _a.argumentTypeNodes, argumentTypeParameters = _a.argumentTypeParameters; var modifiers = modifierFlags ? ts.factory.createNodeArray(ts.factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; var asteriskToken = ts.isYieldExpression(parent) - ? ts.factory.createToken(41 /* AsteriskToken */) + ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined; - var typeParameters = isJs || typeArguments === undefined - ? undefined - : ts.map(typeArguments, function (_, i) { - return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, 84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); - }); - var parameters = createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, isJs); + var typeParameters = isJs ? undefined : createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments); + var parameters = createDummyParameters(args.length, names, argumentTypeNodes, /*minArgumentCount*/ undefined, isJs); var type = isJs || contextualType === undefined ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); switch (kind) { - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createMethodDeclaration(modifiers, asteriskToken, name, /*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return ts.factory.createMethodSignature(modifiers, name, - /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */) : type); - case 256 /* FunctionDeclaration */: + /*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */) : type); + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference)); default: ts.Debug.fail("Unexpected kind"); } } codefix.createSignatureDeclarationFromCallExpression = createSignatureDeclarationFromCallExpression; + function createTypeParametersForArguments(checker, argumentTypeParameters, typeArguments) { + var usedNames = new ts.Set(argumentTypeParameters.map(function (pair) { return pair[0]; })); + var constraintsByName = new ts.Map(argumentTypeParameters); + if (typeArguments) { + var typeArgumentsWithNewTypes = typeArguments.filter(function (typeArgument) { return !argumentTypeParameters.some(function (pair) { var _a; return checker.getTypeAtLocation(typeArgument) === ((_a = pair[1]) === null || _a === void 0 ? void 0 : _a.argumentType); }); }); + var targetSize = usedNames.size + typeArgumentsWithNewTypes.length; + for (var i = 0; usedNames.size < targetSize; i += 1) { + usedNames.add(createTypeParameterName(i)); + } + } + return ts.map(ts.arrayFrom(usedNames.values()), function (usedName) { var _a; return ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, usedName, (_a = constraintsByName.get(usedName)) === null || _a === void 0 ? void 0 : _a.constraint); }); + } + function createTypeParameterName(index) { + return 84 /* CharacterCodes.T */ + index <= 90 /* CharacterCodes.Z */ + ? String.fromCharCode(84 /* CharacterCodes.T */ + index) + : "T".concat(index); + } function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) { var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker); if (typeNode && ts.isImportTypeNode(typeNode)) { @@ -159612,15 +160421,107 @@ var ts; return ts.getSynthesizedDeepClone(typeNode); } codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode; + function typeContainsTypeParameter(type) { + if (type.isUnionOrIntersection()) { + return type.types.some(typeContainsTypeParameter); + } + return type.flags & 262144 /* TypeFlags.TypeParameter */; + } + function getArgumentTypesAndTypeParameters(checker, importAdder, instanceTypes, contextNode, scriptTarget, flags, tracker) { + // Types to be used as the types of the parameters in the new function + // E.g. from this source: + // added("", 0) + // The value will look like: + // [{ typeName: { text: "string" } }, { typeName: { text: "number" }] + // And in the output function will generate: + // function added(a: string, b: number) { ... } + var argumentTypeNodes = []; + // Names of type parameters provided as arguments to the call + // E.g. from this source: + // added(value); + // The value will look like: + // [ + // ["T", { argumentType: { typeName: { text: "T" } } } ], + // ["U", { argumentType: { typeName: { text: "U" } } } ], + // ] + // And in the output function will generate: + // function added() { ... } + var argumentTypeParameters = new ts.Map(); + for (var i = 0; i < instanceTypes.length; i += 1) { + var instanceType = instanceTypes[i]; + // If the instance type contains a deep reference to an existing type parameter, + // instead of copying the full union or intersection, create a new type parameter + // E.g. from this source: + // function existing(value: T | U & string) { + // added/*1*/(value); + // We don't want to output this: + // function added(value: T | U & string) { ... } + // We instead want to output: + // function added(value: T) { ... } + if (instanceType.isUnionOrIntersection() && instanceType.types.some(typeContainsTypeParameter)) { + var synthesizedTypeParameterName = createTypeParameterName(i); + argumentTypeNodes.push(ts.factory.createTypeReferenceNode(synthesizedTypeParameterName)); + argumentTypeParameters.set(synthesizedTypeParameterName, undefined); + continue; + } + // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" + var widenedInstanceType = checker.getBaseTypeOfLiteralType(instanceType); + var argumentTypeNode = typeToAutoImportableTypeNode(checker, importAdder, widenedInstanceType, contextNode, scriptTarget, flags, tracker); + if (!argumentTypeNode) { + continue; + } + argumentTypeNodes.push(argumentTypeNode); + var argumentTypeParameter = getFirstTypeParameterName(instanceType); + // If the instance type is a type parameter with a constraint (other than an anonymous object), + // remember that constraint for when we create the new type parameter + // E.g. from this source: + // function existing(value: T) { + // added/*1*/(value); + // We don't want to output this: + // function added(value: T) { ... } + // We instead want to output: + // function added(value: T) { ... } + var instanceTypeConstraint = instanceType.isTypeParameter() && instanceType.constraint && !isAnonymousObjectConstraintType(instanceType.constraint) + ? typeToAutoImportableTypeNode(checker, importAdder, instanceType.constraint, contextNode, scriptTarget, flags, tracker) + : undefined; + if (argumentTypeParameter) { + argumentTypeParameters.set(argumentTypeParameter, { argumentType: instanceType, constraint: instanceTypeConstraint }); + } + } + return { argumentTypeNodes: argumentTypeNodes, argumentTypeParameters: ts.arrayFrom(argumentTypeParameters.entries()) }; + } + codefix.getArgumentTypesAndTypeParameters = getArgumentTypesAndTypeParameters; + function isAnonymousObjectConstraintType(type) { + return (type.flags & 524288 /* TypeFlags.Object */) && type.objectFlags === 16 /* ObjectFlags.Anonymous */; + } + function getFirstTypeParameterName(type) { + var _a; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + for (var _i = 0, _b = type.types; _i < _b.length; _i++) { + var subType = _b[_i]; + var subTypeName = getFirstTypeParameterName(subType); + if (subTypeName) { + return subTypeName; + } + } + } + return type.flags & 262144 /* TypeFlags.TypeParameter */ + ? (_a = type.getSymbol()) === null || _a === void 0 ? void 0 : _a.getName() + : undefined; + } function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { var parameters = []; + var parameterNameCounts = new ts.Map(); for (var i = 0; i < argCount; i++) { + var parameterName = (names === null || names === void 0 ? void 0 : names[i]) || "arg".concat(i); + var parameterNameCount = parameterNameCounts.get(parameterName); + parameterNameCounts.set(parameterName, (parameterNameCount || 0) + 1); var newParameter = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, - /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */), + /*name*/ parameterName + (parameterNameCount || ""), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, + /*type*/ inJs ? undefined : (types === null || types === void 0 ? void 0 : types[i]) || ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -159649,8 +160550,8 @@ var ts; var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { var restParameter = ts.factory.createParameterDeclaration( - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */)), + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */)), /*initializer*/ undefined); parameters.push(restParameter); } @@ -159665,7 +160566,7 @@ var ts; } function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) { return ts.factory.createMethodDeclaration(modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); + /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference)); } function createStubbedMethodBody(quotePreference) { return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference); @@ -159674,16 +160575,16 @@ var ts; return ts.factory.createBlock([ts.factory.createThrowStatement(ts.factory.createNewExpression(ts.factory.createIdentifier("Error"), /*typeArguments*/ undefined, // TODO Handle auto quote preference. - [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* Single */)]))], + [ts.factory.createStringLiteral(text, /*isSingleQuote*/ quotePreference === 0 /* QuotePreference.Single */)]))], /*multiline*/ true); } codefix.createStubbedBody = createStubbedBody; function createVisibilityModifier(flags) { - if (flags & 4 /* Public */) { - return ts.factory.createToken(123 /* PublicKeyword */); + if (flags & 4 /* ModifierFlags.Public */) { + return ts.factory.createToken(123 /* SyntaxKind.PublicKeyword */); } - else if (flags & 16 /* Protected */) { - return ts.factory.createToken(122 /* ProtectedKeyword */); + else if (flags & 16 /* ModifierFlags.Protected */) { + return ts.factory.createToken(122 /* SyntaxKind.ProtectedKeyword */); } return undefined; } @@ -159756,7 +160657,7 @@ var ts; } codefix.tryGetAutoImportableReferenceFromTypeNode = tryGetAutoImportableReferenceFromTypeNode; function replaceFirstIdentifierOfEntityName(name, newIdentifier) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return newIdentifier; } return ts.factory.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); @@ -159832,17 +160733,17 @@ var ts; return ts.isIdentifier(fieldName) ? ts.factory.createPropertyAccessExpression(leftHead, fieldName) : ts.factory.createElementAccessExpression(leftHead, ts.factory.createStringLiteralFromNode(fieldName)); } function prepareModifierFlagsForAccessor(modifierFlags) { - modifierFlags &= ~64 /* Readonly */; // avoid Readonly modifier because it will convert to get accessor - modifierFlags &= ~8 /* Private */; - if (!(modifierFlags & 16 /* Protected */)) { - modifierFlags |= 4 /* Public */; + modifierFlags &= ~64 /* ModifierFlags.Readonly */; // avoid Readonly modifier because it will convert to get accessor + modifierFlags &= ~8 /* ModifierFlags.Private */; + if (!(modifierFlags & 16 /* ModifierFlags.Protected */)) { + modifierFlags |= 4 /* ModifierFlags.Public */; } return modifierFlags; } function prepareModifierFlagsForField(modifierFlags) { - modifierFlags &= ~4 /* Public */; - modifierFlags &= ~16 /* Protected */; - modifierFlags |= 8 /* Private */; + modifierFlags &= ~4 /* ModifierFlags.Public */; + modifierFlags &= ~16 /* ModifierFlags.Protected */; + modifierFlags |= 8 /* ModifierFlags.Private */; return modifierFlags; } function getAccessorConvertiblePropertyAtPosition(file, program, start, end, considerEmptySpans) { @@ -159851,7 +160752,7 @@ var ts; var cursorRequest = start === end && considerEmptySpans; var declaration = ts.findAncestor(node.parent, isAcceptedDeclaration); // make sure declaration have AccessibilityModifier or Static Modifier or Readonly Modifier - var meaning = 28 /* AccessibilityModifier */ | 32 /* Static */ | 64 /* Readonly */; + var meaning = 28 /* ModifierFlags.AccessibilityModifier */ | 32 /* ModifierFlags.Static */ | 64 /* ModifierFlags.Readonly */; if (!declaration || (!(ts.nodeOverlapsWithStartEnd(declaration.name, file, start, end) || cursorRequest))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_property_for_which_to_generate_accessor) @@ -159862,20 +160763,20 @@ var ts; error: ts.getLocaleSpecificMessage(ts.Diagnostics.Name_is_not_valid) }; } - if (((ts.getEffectiveModifierFlags(declaration) & 125951 /* Modifier */) | meaning) !== meaning) { + if (((ts.getEffectiveModifierFlags(declaration) & 125951 /* ModifierFlags.Modifier */) | meaning) !== meaning) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_property_with_modifier) }; } var name = declaration.name.text; var startWithUnderscore = ts.startsWithUnderscore(name); - var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); + var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_".concat(name), file), declaration.name); var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasEffectiveReadonlyModifier(declaration), type: getDeclarationType(declaration, program), - container: declaration.kind === 164 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 164 /* SyntaxKind.Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -159928,13 +160829,13 @@ var ts; return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 108 /* ThisKeyword */ && + node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.factory.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.factory.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -159949,7 +160850,7 @@ var ts; var type = typeChecker.getTypeFromTypeNode(typeNode); if (!typeChecker.isTypeAssignableTo(typeChecker.getUndefinedType(), type)) { var types = ts.isUnionTypeNode(typeNode) ? typeNode.types : [typeNode]; - return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)], false)); + return ts.factory.createUnionTypeNode(__spreadArray(__spreadArray([], types, true), [ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)], false)); } } return typeNode; @@ -159961,7 +160862,7 @@ var ts; var superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); if (!superSymbol) break; - var symbol = superSymbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; + var symbol = superSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(superSymbol) : superSymbol; var superDecl = symbol.declarations && ts.find(symbol.declarations, ts.isClassLike); if (!superDecl) break; @@ -160007,7 +160908,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* CallExpression */ : 209 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 208 /* SyntaxKind.CallExpression */ : 209 /* SyntaxKind.NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -160125,7 +161026,7 @@ var ts; } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { ts.suppressLeadingAndTrailingTrivia(propertyDeclaration); - var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* SyntaxKind.ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, info) { @@ -160133,7 +161034,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, sourceFile, info) { - var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + var undefinedTypeNode = ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode]; var unionTypeNode = ts.factory.createUnionTypeNode(types); if (info.isJs) { @@ -160162,7 +161063,7 @@ var ts; return getDefaultValueFromType(checker, checker.getTypeFromTypeNode(propertyDeclaration.type)); // TODO: GH#18217 } function getDefaultValueFromType(checker, type) { - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { return (type === checker.getFalseType() || type === checker.getFalseType(/*fresh*/ true)) ? ts.factory.createFalse() : ts.factory.createTrue(); } else if (type.isStringLiteral()) { @@ -160171,7 +161072,7 @@ var ts; else if (type.isNumberLiteral()) { return ts.factory.createNumericLiteral(type.value); } - else if (type.flags & 2048 /* BigIntLiteral */) { + else if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { return ts.factory.createBigIntLiteral(type.value); } else if (type.isUnion()) { @@ -160179,7 +161080,7 @@ var ts; } else if (type.isClass()) { var classDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); - if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* Abstract */)) + if (!classDeclaration || ts.hasSyntacticModifier(classDeclaration, 128 /* ModifierFlags.Abstract */)) return undefined; var constructorDeclaration = ts.getFirstConstructorWithBody(classDeclaration); if (constructorDeclaration && constructorDeclaration.parameters.length) @@ -160355,8 +161256,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 100 /* ImportKeyword */, "This token should be an ImportKeyword"); - ts.Debug.assert(token.parent.kind === 200 /* ImportType */, "Token parent should be an ImportType"); + ts.Debug.assert(token.kind === 100 /* SyntaxKind.ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 200 /* SyntaxKind.ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -160419,7 +161320,7 @@ var ts; var children = []; var current = node; while (true) { - if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(current) && ts.nodeIsMissing(current.operatorToken) && current.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { children.push(current.left); if (ts.isJsxChild(current.right)) { children.push(current.right); @@ -160485,7 +161386,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, + var mappedIntersectionType = ts.factory.createMappedTypeNode(ts.hasEffectiveReadonlyModifier(indexSignature) ? ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */) : undefined, mappedTypeParameter, /*nameType*/ undefined, indexSignature.questionToken, indexSignature.type, /*members*/ undefined); var intersectionType = ts.factory.createIntersectionTypeNode(__spreadArray(__spreadArray(__spreadArray([], ts.getAllSuperTypeNodes(container), true), [ @@ -160543,7 +161444,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 132 /* SyntaxKind.AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -160554,7 +161455,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 103 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 103 /* SyntaxKind.NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -160625,7 +161526,7 @@ var ts; var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.parent, ts.isVariableDeclarationList); if (declaration === undefined) return; - var constToken = ts.findChildOfKind(declaration, 85 /* ConstKeyword */, sourceFile); + var constToken = ts.findChildOfKind(declaration, 85 /* SyntaxKind.ConstKeyword */, sourceFile); if (constToken === undefined) return; return ts.createRange(constToken.pos, constToken.end); @@ -160662,14 +161563,14 @@ var ts; }); function getInfo(sourceFile, pos, _) { var node = ts.getTokenAtPosition(sourceFile, pos); - return (node.kind === 26 /* SemicolonToken */ && + return (node.kind === 26 /* SyntaxKind.SemicolonToken */ && node.parent && (ts.isObjectLiteralExpression(node.parent) || ts.isArrayLiteralExpression(node.parent))) ? { node: node } : undefined; } function doChange(changes, sourceFile, _a) { var node = _a.node; - var newNode = ts.factory.createToken(27 /* CommaToken */); + var newNode = ts.factory.createToken(27 /* SyntaxKind.CommaToken */); changes.replaceNode(sourceFile, node, newNode); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -160717,7 +161618,7 @@ var ts; // append ` | void` to type argument var typeArgument = typeArguments[0]; var needsParens = !ts.isUnionTypeNode(typeArgument) && !ts.isParenthesizedTypeNode(typeArgument) && - ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* VoidKeyword */)]).types[0]); + ts.isParenthesizedTypeNode(ts.factory.createUnionTypeNode([typeArgument, ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */)]).types[0]); if (needsParens) { changes.insertText(sourceFile, typeArgument.pos, "("); } @@ -160729,14 +161630,14 @@ var ts; var parameter = signature === null || signature === void 0 ? void 0 : signature.parameters[0]; var parameterType = parameter && checker.getTypeOfSymbolAtLocation(parameter, decl.parent.parent); if (ts.isInJSFile(decl)) { - if (!parameterType || parameterType.flags & 3 /* AnyOrUnknown */) { + if (!parameterType || parameterType.flags & 3 /* TypeFlags.AnyOrUnknown */) { // give the expression a type changes.insertText(sourceFile, decl.parent.parent.end, ")"); changes.insertText(sourceFile, ts.skipTrivia(sourceFile.text, decl.parent.parent.pos), "/** @type {Promise} */("); } } else { - if (!parameterType || parameterType.flags & 2 /* Unknown */) { + if (!parameterType || parameterType.flags & 2 /* TypeFlags.Unknown */) { // add `void` type argument changes.insertText(sourceFile, decl.parent.parent.expression.end, ""); } @@ -160812,16 +161713,16 @@ var ts; var file = context.file, program = context.program; var span = ts.getRefactorContextSpan(context); var token = ts.getTokenAtPosition(file, span.start); - var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); + var exportNode = !!(token.parent && ts.getSyntacticModifierFlags(token.parent) & 1 /* ModifierFlags.Export */) && considerPartialSpans ? token.parent : ts.getParentNodeInSpan(token, file, span); if (!exportNode || (!ts.isSourceFile(exportNode.parent) && !(ts.isModuleBlock(exportNode.parent) && ts.isAmbientModule(exportNode.parent.parent)))) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_export_statement) }; } var checker = program.getTypeChecker(); var exportingModuleSymbol = getExportingModuleSymbol(exportNode, checker); - var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ExportDefault */ : 0 /* None */); - var wasDefault = !!(flags & 512 /* Default */); + var flags = ts.getSyntacticModifierFlags(exportNode) || ((ts.isExportAssignment(exportNode) && !exportNode.isExportEquals) ? 513 /* ModifierFlags.ExportDefault */ : 0 /* ModifierFlags.None */); + var wasDefault = !!(flags & 512 /* ModifierFlags.Default */); // If source file already has a default export, don't offer refactor. - if (!(flags & 1 /* Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* Default */)) { + if (!(flags & 1 /* ModifierFlags.Export */) || !wasDefault && exportingModuleSymbol.exports.has("default" /* InternalSymbolName.Default */)) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.This_file_already_has_a_default_export) }; } var noSymbolError = function (id) { @@ -160829,22 +161730,22 @@ var ts; : { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_named_export) }; }; switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: { var node = exportNode; if (!node.name) return undefined; return noSymbolError(node.name) || { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. - if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { + if (!(vs.declarationList.flags & 2 /* NodeFlags.Const */) || vs.declarationList.declarations.length !== 1) { return undefined; } var decl = ts.first(vs.declarationList.declarations); @@ -160854,7 +161755,7 @@ var ts; return noSymbolError(decl.name) || { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol }; } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var node = exportNode; if (node.isExportEquals) return undefined; @@ -160878,18 +161779,18 @@ var ts; changes.replaceNode(exportingSourceFile, exportNode, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports([spec]))); } else { - changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 88 /* SyntaxKind.DefaultKeyword */), "Should find a default keyword in modifier list")); } } else { - var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 93 /* SyntaxKind.ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* DefaultKeyword */)); + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.factory.createToken(88 /* SyntaxKind.DefaultKeyword */)); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // If 'x' isn't used in this file and doesn't have type definition, `export const x = 0;` --> `export default 0;` var decl = ts.first(exportNode.declarationList.declarations); if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile) && !decl.type) { @@ -160898,15 +161799,15 @@ var ts; break; } // falls through - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.factory.createExportDefault(ts.factory.createIdentifier(exportName.text))); break; default: - ts.Debug.fail("Unexpected exportNode kind " + exportNode.kind); + ts.Debug.fail("Unexpected exportNode kind ".concat(exportNode.kind)); } } } @@ -160929,18 +161830,18 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier(exportName)); break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 267 /* ImportClause */: { + case 267 /* SyntaxKind.ImportClause */: { var clause = parent; ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); @@ -160949,10 +161850,10 @@ var ts; // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.factory.createNamedImports([spec])); } - else if (namedBindings.kind === 268 /* NamespaceImport */) { + else if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); - var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; + var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* QuotePreference.Double */; var newImport = ts.makeImport(/*default*/ undefined, [makeImportSpecifier(exportName, ref.text)], clause.parent.moduleSpecifier, quotePreference); changes.insertNodeAfter(importingSourceFile, clause.parent, newImport); } @@ -160963,7 +161864,7 @@ var ts; } break; } - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: var importTypeNode = parent; changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, importTypeNode.assertions, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf)); break; @@ -160974,11 +161875,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.factory.createIdentifier("default")); break; - case 270 /* ImportSpecifier */: { + case 270 /* SyntaxKind.ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.factory.createIdentifier(parent.name.text); @@ -160991,7 +161892,7 @@ var ts; } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -161000,7 +161901,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); + ts.Debug.assertNever(parent, "Unexpected parent kind ".concat(parent.kind)); } } function makeImportSpecifier(propertyName, name) { @@ -161030,17 +161931,17 @@ var ts; var _a; var refactorName = "Convert import"; var actions = (_a = {}, - _a[0 /* Named */] = { + _a[0 /* ImportKind.Named */] = { name: "Convert namespace import to named imports", description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message, kind: "refactor.rewrite.import.named", }, - _a[2 /* Namespace */] = { + _a[2 /* ImportKind.Namespace */] = { name: "Convert named imports to namespace import", description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message, kind: "refactor.rewrite.import.namespace", }, - _a[1 /* Default */] = { + _a[1 /* ImportKind.Default */] = { name: "Convert named imports to default import", description: ts.Diagnostics.Convert_named_imports_to_default_import.message, kind: "refactor.rewrite.import.default", @@ -161092,13 +161993,13 @@ var ts; if (!importClause.namedBindings) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) }; } - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { - return { convertTo: 0 /* Named */, import: importClause.namedBindings }; + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { + return { convertTo: 0 /* ImportKind.Named */, import: importClause.namedBindings }; } var shouldUseDefault = getShouldUseDefault(context.program, importClause); return shouldUseDefault - ? { convertTo: 1 /* Default */, import: importClause.namedBindings } - : { convertTo: 2 /* Namespace */, import: importClause.namedBindings }; + ? { convertTo: 1 /* ImportKind.Default */, import: importClause.namedBindings } + : { convertTo: 2 /* ImportKind.Namespace */, import: importClause.namedBindings }; } function getShouldUseDefault(program, importClause) { return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()) @@ -161106,11 +162007,11 @@ var ts; } function doChange(sourceFile, program, changes, info) { var checker = program.getTypeChecker(); - if (info.convertTo === 0 /* Named */) { + if (info.convertTo === 0 /* ImportKind.Named */) { doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { - doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */); + doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* ImportKind.Default */); } } function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) { @@ -161123,7 +162024,7 @@ var ts; } else { var exportName = getRightOfPropertyAccessOrQualifiedName(id.parent).text; - if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { + if (checker.resolveName(exportName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } ts.Debug.assert(getLeftOfPropertyAccessOrQualifiedName(id.parent) === id, "Parent expression should match id"); @@ -161172,14 +162073,14 @@ var ts; toConvertSymbols.add(symbol); } }); - var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ESNext */) : "module"; + var preferredName = moduleSpecifier && ts.isStringLiteral(moduleSpecifier) ? ts.codefix.moduleSpecifierToValidIdentifier(moduleSpecifier.text, 99 /* ScriptTarget.ESNext */) : "module"; function hasNamespaceNameConflict(namedImport) { // We need to check if the preferred namespace name (`preferredName`) we'd like to use in the refactored code will present a name conflict. // A name conflict means that, in a scope where we would like to use the preferred namespace name, there already exists a symbol with that name in that scope. // We are going to use the namespace name in the scopes the named imports being refactored are referenced, // so we look for conflicts by looking at every reference to those named imports. return !!ts.FindAllReferences.Core.eachSymbolReferenceInFile(namedImport.name, checker, sourceFile, function (id) { - var symbol = checker.resolveName(preferredName, id, 67108863 /* All */, /*excludeGlobals*/ true); + var symbol = checker.resolveName(preferredName, id, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (symbol) { // There already is a symbol with the same name as the preferred namespace name. if (toConvertSymbols.has(symbol)) { // `preferredName` resolves to a symbol for one of the named import references we are going to transform into namespace import references... return ts.isExportSpecifier(id.parent); // ...but if this reference is an export specifier, it will not be transformed, so it is a conflict; otherwise, it will be renamed and is not a conflict. @@ -161194,7 +162095,7 @@ var ts; // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics. // More specifically, those are named imports that appear in named exports in the original code, e.g. `a` in `import { a } from "m"; export { a }`. var neededNamedImports = new ts.Set(); - var _loop_16 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName); @@ -161211,7 +162112,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_16(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, shouldUseDefault ? ts.factory.createIdentifier(namespaceImportName) @@ -161328,7 +162229,7 @@ var ts; } } function getBinaryInfo(expression) { - if (expression.operatorToken.kind !== 55 /* AmpersandAmpersandToken */) { + if (expression.operatorToken.kind !== 55 /* SyntaxKind.AmpersandAmpersandToken */) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Can_only_convert_logical_AND_access_chains) }; } ; @@ -161344,7 +162245,7 @@ var ts; */ function getOccurrencesInExpression(matchTo, expression) { var occurrences = []; - while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(expression) && expression.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var match = getMatchingStart(ts.skipParentheses(matchTo), ts.skipParentheses(expression.right)); if (!match) { break; @@ -161470,17 +162371,17 @@ var ts; occurrences.pop(); if (ts.isCallExpression(toConvert)) { return isOccurrence ? - ts.factory.createCallChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : + ts.factory.createCallChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.typeArguments, toConvert.arguments) : ts.factory.createCallChain(chain, toConvert.questionDotToken, toConvert.typeArguments, toConvert.arguments); } else if (ts.isPropertyAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.name) : + ts.factory.createPropertyAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.name) : ts.factory.createPropertyAccessChain(chain, toConvert.questionDotToken, toConvert.name); } else if (ts.isElementAccessExpression(toConvert)) { return isOccurrence ? - ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* QuestionDotToken */), toConvert.argumentExpression) : + ts.factory.createElementAccessChain(chain, ts.factory.createToken(28 /* SyntaxKind.QuestionDotToken */), toConvert.argumentExpression) : ts.factory.createElementAccessChain(chain, toConvert.questionDotToken, toConvert.argumentExpression); } } @@ -161495,7 +162396,7 @@ var ts; changes.replaceNodeRange(sourceFile, firstOccurrence, finalExpression, convertedChain); } else if (ts.isConditionalExpression(expression)) { - changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* QuestionQuestionToken */), expression.whenFalse)); + changes.replaceNode(sourceFile, expression, ts.factory.createBinaryExpression(convertedChain, ts.factory.createToken(60 /* SyntaxKind.QuestionQuestionToken */), expression.whenFalse)); } } } @@ -161541,27 +162442,27 @@ var ts; var lastDeclaration = signatureDecls[signatureDecls.length - 1]; var updated = lastDeclaration; switch (lastDeclaration.kind) { - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { updated = ts.factory.updateMethodSignature(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { updated = ts.factory.updateMethodDeclaration(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.questionToken, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { updated = ts.factory.updateCallSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { updated = ts.factory.updateConstructorDeclaration(lastDeclaration, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body); break; } - case 175 /* ConstructSignature */: { + case 175 /* SyntaxKind.ConstructSignature */: { updated = ts.factory.updateConstructSignature(lastDeclaration, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type); break; } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { updated = ts.factory.updateFunctionDeclaration(lastDeclaration, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, lastDeclaration.typeParameters, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.type, lastDeclaration.body); break; } @@ -161582,24 +162483,24 @@ var ts; } return ts.factory.createNodeArray([ ts.factory.createParameterDeclaration( - /*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), "args", + /*modifiers*/ undefined, ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */), "args", /*questionToken*/ undefined, ts.factory.createUnionTypeNode(ts.map(signatureDeclarations, convertSignatureParametersToTuple))) ]); } function convertSignatureParametersToTuple(decl) { var members = ts.map(decl.parameters, convertParameterToNamedTupleMember); - return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* None */ : 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTupleTypeNode(members), ts.some(members, function (m) { return !!ts.length(ts.getSyntheticLeadingComments(m)); }) ? 0 /* EmitFlags.None */ : 1 /* EmitFlags.SingleLine */); } function convertParameterToNamedTupleMember(p) { ts.Debug.assert(ts.isIdentifier(p.name)); // This is checked during refactoring applicability checking - var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)), p); + var result = ts.setTextRange(ts.factory.createNamedTupleMember(p.dotDotDotToken, p.name, p.questionToken, p.type || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)), p); var parameterDocComment = p.symbol && p.symbol.getDocumentationComment(checker); if (parameterDocComment) { var newComment = ts.displayPartsToString(parameterDocComment); if (newComment.length) { ts.setSyntheticLeadingComments(result, [{ - text: "*\n" + newComment.split("\n").map(function (c) { return " * " + c; }).join("\n") + "\n ", - kind: 3 /* MultiLineCommentTrivia */, + text: "*\n".concat(newComment.split("\n").map(function (c) { return " * ".concat(c); }).join("\n"), "\n "), + kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, pos: -1, end: -1, hasTrailingNewLine: true, @@ -161612,12 +162513,12 @@ var ts; } function isConvertableSignatureDeclaration(d) { switch (d.kind) { - case 168 /* MethodSignature */: - case 169 /* MethodDeclaration */: - case 174 /* CallSignature */: - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 256 /* FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: return true; } return false; @@ -161628,6 +162529,9 @@ var ts; if (!containingDecl) { return; } + if (ts.isFunctionLikeDeclaration(containingDecl) && containingDecl.body && ts.rangeContainsPosition(containingDecl.body, startPosition)) { + return; + } var checker = program.getTypeChecker(); var signatureSymbol = containingDecl.symbol; if (!signatureSymbol) { @@ -161743,7 +162647,7 @@ var ts; usedFunctionNames.set(description, true); functionActions.push({ description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), kind: extractFunctionAction.kind }); } @@ -161751,7 +162655,7 @@ var ts; else if (!innermostErrorFunctionAction) { innermostErrorFunctionAction = { description: description, - name: "function_scope_" + i, + name: "function_scope_".concat(i), notApplicableReason: getStringError(functionExtraction.errors), kind: extractFunctionAction.kind }; @@ -161767,7 +162671,7 @@ var ts; usedConstantNames.set(description_1, true); constantActions.push({ description: description_1, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), kind: extractConstantAction.kind }); } @@ -161775,7 +162679,7 @@ var ts; else if (!innermostErrorConstantAction) { innermostErrorConstantAction = { description: description, - name: "constant_scope_" + i, + name: "constant_scope_".concat(i), notApplicableReason: getStringError(constantExtraction.errors), kind: extractConstantAction.kind }; @@ -161920,7 +162824,7 @@ var ts; // cannot find either start or end node return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - if (start.flags & 8388608 /* JSDoc */) { + if (start.flags & 8388608 /* NodeFlags.JSDoc */) { return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; } if (start.parent !== end.parent) { @@ -162009,20 +162913,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 167 /* PropertyDeclaration */) { + if (current.kind === 167 /* SyntaxKind.PropertyDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 164 /* Parameter */) { + else if (current.kind === 164 /* SyntaxKind.Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 171 /* Constructor */) { + if (ctorOrMethod.kind === 171 /* SyntaxKind.Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 169 /* MethodDeclaration */) { + else if (current.kind === 169 /* SyntaxKind.MethodDeclaration */) { if (ts.isStatic(current)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -162046,7 +162950,7 @@ var ts; if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 16777216 /* Ambient */) { + if (nodeToCheck.flags & 16777216 /* NodeFlags.Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -162055,14 +162959,14 @@ var ts; checkForStaticContext(nodeToCheck, containingClass); } var errors; - var permittedJumps = 4 /* Return */; + var permittedJumps = 4 /* PermittedJumps.Return */; var seenLabels; visit(nodeToCheck); if (rangeFacts & RangeFacts.UsesThis) { var container = ts.getThisContainer(nodeToCheck, /** includeArrowFunctions */ false); - if (container.kind === 256 /* FunctionDeclaration */ || - (container.kind === 169 /* MethodDeclaration */ && container.parent.kind === 205 /* ObjectLiteralExpression */) || - container.kind === 213 /* FunctionExpression */) { + if (container.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) || + container.kind === 213 /* SyntaxKind.FunctionExpression */) { rangeFacts |= RangeFacts.UsesThisInFunction; } } @@ -162073,8 +162977,8 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 254 /* VariableDeclaration */) ? node.parent.parent : node; - if (ts.hasSyntacticModifier(declaringNode, 1 /* Export */)) { + var declaringNode = (node.kind === 254 /* SyntaxKind.VariableDeclaration */) ? node.parent.parent : node; + if (ts.hasSyntacticModifier(declaringNode, 1 /* ModifierFlags.Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! // Also TODO: GH#19956 @@ -162085,16 +162989,16 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity)); return true; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 208 /* CallExpression */) { + if (node.parent.kind === 208 /* SyntaxKind.CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -162107,7 +163011,7 @@ var ts; thisNode = node; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // check if arrow function uses this ts.forEachChild(node, function check(n) { if (ts.isThis(n)) { @@ -162122,64 +163026,64 @@ var ts; } }); // falls through - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); } // falls through - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // do not dive into functions or classes return false; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 239 /* IfStatement */: - permittedJumps = 0 /* None */; + case 239 /* SyntaxKind.IfStatement */: + permittedJumps &= ~4 /* PermittedJumps.Return */; break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // forbid all jumps inside try blocks - permittedJumps = 0 /* None */; + permittedJumps = 0 /* PermittedJumps.None */; break; - case 235 /* Block */: - if (node.parent && node.parent.kind === 252 /* TryStatement */ && node.parent.finallyBlock === node) { + case 235 /* SyntaxKind.Block */: + if (node.parent && node.parent.kind === 252 /* SyntaxKind.TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks - permittedJumps = 4 /* Return */; + permittedJumps = 4 /* PermittedJumps.Return */; } break; - case 290 /* DefaultClause */: - case 289 /* CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: // allow unlabeled break inside case clauses - permittedJumps |= 1 /* Break */; + permittedJumps |= 1 /* PermittedJumps.Break */; break; default: if (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false)) { // allow unlabeled break/continue inside loops - permittedJumps |= 1 /* Break */ | 2 /* Continue */; + permittedJumps |= 1 /* PermittedJumps.Break */ | 2 /* PermittedJumps.Continue */; } break; } switch (node.kind) { - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; thisNode = node; break; - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: { + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -162188,21 +163092,21 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 246 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 246 /* SyntaxKind.BreakStatement */ ? 1 /* PermittedJumps.Break */ : 2 /* PermittedJumps.Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 247 /* ReturnStatement */: - if (permittedJumps & 4 /* Return */) { + case 247 /* SyntaxKind.ReturnStatement */: + if (permittedJumps & 4 /* PermittedJumps.Return */) { rangeFacts |= RangeFacts.HasReturn; } else { @@ -162225,7 +163129,7 @@ var ts; function getAdjustedSpanFromNodes(startNode, endNode, sourceFile) { var start = startNode.getStart(sourceFile); var end = endNode.getEnd(); - if (sourceFile.text.charCodeAt(end) === 59 /* semicolon */) { + if (sourceFile.text.charCodeAt(end) === 59 /* CharacterCodes.semicolon */) { end++; } return { start: start, length: end - start }; @@ -162271,7 +163175,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 164 /* Parameter */) { + if (current.kind === 164 /* SyntaxKind.Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -162282,7 +163186,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 305 /* SourceFile */) { + if (current.kind === 305 /* SyntaxKind.SourceFile */) { return scopes; } } @@ -162322,11 +163226,11 @@ var ts; : getDescriptionForModuleLikeDeclaration(scope); var functionDescription; var constantDescription; - if (scopeDescription === 1 /* Global */) { + if (scopeDescription === 1 /* SpecialScope.Global */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "global"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "global"]); } - else if (scopeDescription === 0 /* Module */) { + else if (scopeDescription === 0 /* SpecialScope.Module */) { functionDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [functionDescriptionPart, "module"]); constantDescription = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_0_in_1_scope), [constantDescriptionPart, "module"]); } @@ -162372,34 +163276,34 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return "constructor"; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: return scope.name - ? "function '" + scope.name.text + "'" + ? "function '".concat(scope.name.text, "'") : ts.ANONYMOUS; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return "arrow function"; - case 169 /* MethodDeclaration */: - return "method '" + scope.name.getText() + "'"; - case 172 /* GetAccessor */: - return "'get " + scope.name.getText() + "'"; - case 173 /* SetAccessor */: - return "'set " + scope.name.getText() + "'"; + case 169 /* SyntaxKind.MethodDeclaration */: + return "method '".concat(scope.name.getText(), "'"); + case 172 /* SyntaxKind.GetAccessor */: + return "'get ".concat(scope.name.getText(), "'"); + case 173 /* SyntaxKind.SetAccessor */: + return "'set ".concat(scope.name.getText(), "'"); default: - throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); + throw ts.Debug.assertNever(scope, "Unexpected scope kind ".concat(scope.kind)); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 257 /* ClassDeclaration */ - ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" - : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + return scope.kind === 257 /* SyntaxKind.ClassDeclaration */ + ? scope.name ? "class '".concat(scope.name.text, "'") : "anonymous class declaration" + : scope.name ? "class expression '".concat(scope.name.text, "'") : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 262 /* ModuleBlock */ - ? "namespace '" + scope.parent.name.getText() + "'" - : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; + return scope.kind === 262 /* SyntaxKind.ModuleBlock */ + ? "namespace '".concat(scope.parent.name.getText(), "'") + : scope.externalModuleIndicator ? 0 /* SpecialScope.Module */ : 1 /* SpecialScope.Global */; } var SpecialScope; (function (SpecialScope) { @@ -162430,7 +163334,7 @@ var ts; var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" type = checker.getBaseTypeOfLiteralType(type); - typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NoTruncation */); + typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NodeBuilderFlags.NoTruncation */); } var paramDecl = ts.factory.createParameterDeclaration( /*modifiers*/ undefined, @@ -162438,7 +163342,7 @@ var ts; /*name*/ name, /*questionToken*/ undefined, typeNode); parameters.push(paramDecl); - if (usage.usage === 2 /* Write */) { + if (usage.usage === 2 /* Usage.Write */) { (writes || (writes = [])).push(usage); } callArguments.push(ts.factory.createIdentifier(name)); @@ -162457,7 +163361,7 @@ var ts; // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); - returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NoTruncation */); // TODO: GH#18217 + returnType = checker.typeToTypeNode(contextualType, scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 } var _b = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; ts.suppressLeadingAndTrailingTrivia(body); @@ -162465,14 +163369,14 @@ var ts; var callThis = !!(range.facts & RangeFacts.UsesThisInFunction); if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.factory.createModifier(131 /* AsyncKeyword */)); + modifiers.push(ts.factory.createModifier(131 /* SyntaxKind.AsyncKeyword */)); } - newFunction = ts.factory.createMethodDeclaration(modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, + newFunction = ts.factory.createMethodDeclaration(modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { @@ -162481,10 +163385,10 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ "this", - /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NoTruncation */), + /*questionToken*/ undefined, checker.typeToTypeNode(checker.getTypeAtLocation(range.thisNode), scope, 1 /* NodeBuilderFlags.NoTruncation */), /*initializer*/ undefined)); } - newFunction = ts.factory.createFunctionDeclaration(range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + newFunction = ts.factory.createFunctionDeclaration(range.facts & RangeFacts.IsAsyncFunction ? [ts.factory.createToken(131 /* SyntaxKind.AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -162505,7 +163409,7 @@ var ts; var call = ts.factory.createCallExpression(callThis ? ts.factory.createPropertyAccessExpression(called, "call") : called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* AsteriskToken */), call); + call = ts.factory.createYieldExpression(ts.factory.createToken(41 /* SyntaxKind.AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.factory.createAwaitExpression(call); @@ -162539,7 +163443,7 @@ var ts; /*propertyName*/ undefined, /*name*/ ts.getSynthesizedDeepClone(variableDeclaration.name))); // Being returned through an object literal will have widened the type. - var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NoTruncation */); + var variableType = checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(variableDeclaration)), scope, 1 /* NodeBuilderFlags.NoTruncation */); typeElements.push(ts.factory.createPropertySignature( /*modifiers*/ undefined, /*name*/ variableDeclaration.symbol.name, @@ -162550,7 +163454,7 @@ var ts; } var typeLiteral = sawExplicitType ? ts.factory.createTypeLiteralNode(typeElements) : undefined; if (typeLiteral) { - ts.setEmitFlags(typeLiteral, 1 /* SingleLine */); + ts.setEmitFlags(typeLiteral, 1 /* EmitFlags.SingleLine */); } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(ts.factory.createObjectBindingPattern(bindingElements), @@ -162565,8 +163469,8 @@ var ts; for (var _c = 0, exposedVariableDeclarations_2 = exposedVariableDeclarations; _c < exposedVariableDeclarations_2.length; _c++) { var variableDeclaration = exposedVariableDeclarations_2[_c]; var flags = variableDeclaration.parent.flags; - if (flags & 2 /* Const */) { - flags = (flags & ~2 /* Const */) | 1 /* Let */; + if (flags & 2 /* NodeFlags.Const */) { + flags = (flags & ~2 /* NodeFlags.Const */) | 1 /* NodeFlags.Let */; } newNodes.push(ts.factory.createVariableStatement( /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(variableDeclaration.symbol.name, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(variableDeclaration.type))], flags))); @@ -162575,7 +163479,7 @@ var ts; if (returnValueProperty) { // has both writes and return, need to create variable declaration to hold return value; newNodes.push(ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* Let */))); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(returnValueProperty, /*exclamationToken*/ undefined, getTypeDeepCloneUnionUndefined(returnType))], 1 /* NodeFlags.Let */))); } var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (returnValueProperty) { @@ -162632,9 +163536,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 153 /* SyntaxKind.UndefinedKeyword */; }) ? clone - : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + : ts.factory.createUnionTypeNode([clone, ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } } /** @@ -162647,13 +163551,13 @@ var ts; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable var file = scope.getSourceFile(); - var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) + var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* SymbolFlags.Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind) ? node.name.text : ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file); var isJS = ts.isInJSFile(scope); var variableType = isJS || !checker.isContextSensitive(node) ? undefined - : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 + : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NodeBuilderFlags.NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(ts.skipParentheses(node), substitutions); (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); @@ -162661,11 +163565,11 @@ var ts; if (ts.isClassLike(scope)) { ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.factory.createModifier(121 /* PrivateKeyword */)); + modifiers.push(ts.factory.createModifier(121 /* SyntaxKind.PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.factory.createModifier(124 /* StaticKeyword */)); + modifiers.push(ts.factory.createModifier(124 /* SyntaxKind.StaticKeyword */)); } - modifiers.push(ts.factory.createModifier(145 /* ReadonlyKeyword */)); + modifiers.push(ts.factory.createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); var newVariable = ts.factory.createPropertyDeclaration(modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); var localReference = ts.factory.createPropertyAccessExpression(rangeFacts & RangeFacts.InStaticRegion @@ -162696,16 +163600,16 @@ var ts; var localReference = ts.factory.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 238 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); changeTracker.replaceNode(context.file, node.parent, newVariableStatement); } else { var newVariableStatement = ts.factory.createVariableStatement( - /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* Const */)); + /*modifiers*/ undefined, ts.factory.createVariableDeclarationList([newVariableDeclaration], 2 /* NodeFlags.Const */)); // Declare var nodeToInsertBefore = getNodeToInsertConstantBefore(node, scope); if (nodeToInsertBefore.pos === 0) { @@ -162715,7 +163619,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -162742,7 +163646,7 @@ var ts; if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) return { variableType: variableType, initializer: initializer }; var functionType = checker.getTypeAtLocation(node); - var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* SignatureKind.Call */)); // If no function signature, maybe there was an error, do nothing if (!functionSignature) return { variableType: variableType, initializer: initializer }; @@ -162761,7 +163665,7 @@ var ts; var paramType = checker.getTypeAtLocation(p); if (paramType === checker.getAnyType()) hasAny = true; - parameters.push(ts.factory.updateParameterDeclaration(p, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + parameters.push(ts.factory.updateParameterDeclaration(p, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NodeBuilderFlags.NoTruncation */), p.initializer)); } } // If a parameter was inferred as any we skip adding function parameters at all. @@ -162771,7 +163675,7 @@ var ts; return { variableType: variableType, initializer: initializer }; variableType = undefined; if (ts.isArrowFunction(initializer)) { - initializer = ts.factory.updateArrowFunction(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + initializer = ts.factory.updateArrowFunction(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); } else { if (functionSignature && !!functionSignature.thisParameter) { @@ -162783,10 +163687,10 @@ var ts; parameters.splice(0, 0, ts.factory.createParameterDeclaration( /* modifiers */ undefined, /* dotDotDotToken */ undefined, "this", - /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NodeBuilderFlags.NoTruncation */))); } } - initializer = ts.factory.updateFunctionExpression(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + initializer = ts.factory.updateFunctionExpression(initializer, ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NodeBuilderFlags.NoTruncation */), initializer.body); } return { variableType: variableType, initializer: initializer }; } @@ -163033,7 +163937,7 @@ var ts; var end = ts.last(statements).end; expressionDiagnostic = ts.createFileDiagnostic(sourceFile, start, end - start, Messages.expressionExpected); } - else if (checker.getTypeAtLocation(expression).flags & (16384 /* Void */ | 131072 /* Never */)) { + else if (checker.getTypeAtLocation(expression).flags & (16384 /* TypeFlags.Void */ | 131072 /* TypeFlags.Never */)) { expressionDiagnostic = ts.createDiagnosticForNode(expression, Messages.uselessConstantType); } // initialize results @@ -163102,7 +164006,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_17 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -163117,11 +164021,11 @@ var ts; var hasWrite = false; var readonlyClassPropertyWrite; usagesPerScope[i].usages.forEach(function (value) { - if (value.usage === 2 /* Write */) { + if (value.usage === 2 /* Usage.Write */) { hasWrite = true; - if (value.symbol.flags & 106500 /* ClassMember */ && + if (value.symbol.flags & 106500 /* SymbolFlags.ClassMember */ && value.symbol.valueDeclaration && - ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* Readonly */)) { + ts.hasEffectiveModifier(value.symbol.valueDeclaration, 64 /* ModifierFlags.Readonly */)) { readonlyClassPropertyWrite = value.symbol.valueDeclaration; } } @@ -163145,7 +164049,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_17(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -163165,7 +164069,7 @@ var ts; } } function collectUsages(node, valueUsage) { - if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (valueUsage === void 0) { valueUsage = 1 /* Usage.Read */; } if (inGenericContext) { var type = checker.getTypeAtLocation(node); recordTypeParameterUsages(type); @@ -163175,11 +164079,11 @@ var ts; } if (ts.isAssignmentExpression(node)) { // use 'write' as default usage for values - collectUsages(node.left, 2 /* Write */); + collectUsages(node.left, 2 /* Usage.Write */); collectUsages(node.right); } else if (ts.isUnaryExpressionWithWrite(node)) { - collectUsages(node.operand, 2 /* Write */); + collectUsages(node.operand, 2 /* Usage.Write */); } else if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) { // use 'write' as default usage for values @@ -163253,7 +164157,7 @@ var ts; // declaration is located in range to be extracted - do nothing return undefined; } - if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Write */) { + if (targetRange.facts & RangeFacts.IsGenerator && usage === 2 /* Usage.Write */) { // this is write to a reference located outside of the target scope and range is extracted into generator // currently this is unsupported scenario var diag = ts.createDiagnosticForNode(identifier, Messages.cannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators); @@ -163280,7 +164184,7 @@ var ts; else if (isTypeName) { // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument // so there's no problem. - if (!(symbol.flags & 262144 /* TypeParameter */)) { + if (!(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var diag = ts.createDiagnosticForNode(identifier, Messages.typeWillNotBeVisibleInTheNewScope); functionErrorsPerScope[i].push(diag); constantErrorsPerScope[i].push(diag); @@ -163361,30 +164265,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return false; } switch (node.kind) { - case 10 /* StringLiteral */: - return parent.kind !== 266 /* ImportDeclaration */ && - parent.kind !== 270 /* ImportSpecifier */; - case 225 /* SpreadElement */: - case 201 /* ObjectBindingPattern */: - case 203 /* BindingElement */: + case 10 /* SyntaxKind.StringLiteral */: + return parent.kind !== 266 /* SyntaxKind.ImportDeclaration */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */; + case 225 /* SyntaxKind.SpreadElement */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 203 /* SyntaxKind.BindingElement */: return false; - case 79 /* Identifier */: - return parent.kind !== 203 /* BindingElement */ && - parent.kind !== 270 /* ImportSpecifier */ && - parent.kind !== 275 /* ExportSpecifier */; + case 79 /* SyntaxKind.Identifier */: + return parent.kind !== 203 /* SyntaxKind.BindingElement */ && + parent.kind !== 270 /* SyntaxKind.ImportSpecifier */ && + parent.kind !== 275 /* SyntaxKind.ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 235 /* Block */: - case 305 /* SourceFile */: - case 262 /* ModuleBlock */: - case 289 /* CaseClause */: + case 235 /* SyntaxKind.Block */: + case 305 /* SyntaxKind.SourceFile */: + case 262 /* SyntaxKind.ModuleBlock */: + case 289 /* SyntaxKind.CaseClause */: return true; default: return false; @@ -163530,7 +164434,7 @@ var ts; if (ts.isTypeReferenceNode(node)) { if (ts.isIdentifier(node.typeName)) { var typeName = node.typeName; - var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true); + var symbol = checker.resolveName(typeName.text, typeName, 262144 /* SymbolFlags.TypeParameter */, /* excludeGlobals */ true); for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) { var decl = _a[_i]; if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) { @@ -163561,7 +164465,7 @@ var ts; } else if (ts.isTypeQueryNode(node)) { if (ts.isIdentifier(node.exprName)) { - var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* Value */, /* excludeGlobals */ false); + var symbol = checker.resolveName(node.exprName.text, node.exprName, 111551 /* SymbolFlags.Value */, /* excludeGlobals */ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) && rangeContainsSkipTrivia(statement, symbol.valueDeclaration, file) && !rangeContainsSkipTrivia(selection, symbol.valueDeclaration, file)) { return true; } @@ -163573,7 +164477,7 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.forEachChild(node, visitor); } @@ -163597,7 +164501,7 @@ var ts; } function doTypedefChange(changes, file, name, info) { var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; - ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(selection, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name)); var templates = []; ts.forEach(typeParameters, function (typeParameter) { @@ -163752,7 +164656,7 @@ var ts; var usage = getUsageInfo(oldFile, toMove.all, checker); var currentDirectory = ts.getDirectoryPath(oldFile.fileName); var extension = ts.extensionFromPath(oldFile.fileName); - var newModuleName = makeUniqueModuleName(getNewModuleName(usage.movedSymbols), extension, currentDirectory, host); + var newModuleName = makeUniqueModuleName(getNewModuleName(usage.oldFileImportsFromNewFile, usage.movedSymbols), extension, currentDirectory, host); var newFileNameWithExtension = newModuleName + extension; // If previous file was global, this is easy. changes.createNewFile(oldFile, ts.combinePaths(currentDirectory, newFileNameWithExtension), getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences)); @@ -163781,11 +164685,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return true; - case 265 /* ImportEqualsDeclaration */: - return !ts.hasSyntacticModifier(node, 1 /* Export */); - case 237 /* VariableStatement */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return !ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); + case 237 /* SyntaxKind.VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -163825,7 +164729,7 @@ var ts; var body = addExports(oldFile, toMove.all, usage.oldFileImportsFromNewFile, useEsModuleSyntax); if (imports.length && body.length) { return __spreadArray(__spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), [ - 4 /* NewLineTrivia */ + 4 /* SyntaxKind.NewLineTrivia */ ], false), body, true); } return __spreadArray(__spreadArray(__spreadArray([], prologueDirectives, true), imports, true), body, true); @@ -163846,10 +164750,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_18 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_19 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -163871,35 +164775,35 @@ var ts; }; for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) { var statement = _c[_b]; - _loop_19(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_18(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* NamespaceImport */ ? + case 266 /* SyntaxKind.ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.name; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { - var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ESNext */); + var preferredNewNamespaceName = ts.codefix.moduleSpecifierToValidIdentifier(newModuleName, 99 /* ScriptTarget.ESNext */); var needUniqueName = false; var toChange = []; ts.FindAllReferences.Core.eachSymbolReferenceInFile(oldImportId, checker, sourceFile, function (ref) { if (!ts.isPropertyAccessExpression(ref.parent)) return; - needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* All */, /*excludeGlobals*/ true); + needUniqueName = needUniqueName || !!checker.resolveName(preferredNewNamespaceName, ref, 67108863 /* SymbolFlags.All */, /*excludeGlobals*/ true); if (movedSymbols.has(checker.getSymbolAtLocation(ref.parent.name))) { toChange.push(ref); } @@ -163917,21 +164821,21 @@ var ts; var newNamespaceId = ts.factory.createIdentifier(newNamespaceName); var newModuleString = ts.factory.createStringLiteral(newModuleSpecifier); switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamespaceImport(newNamespaceId)), newModuleString, /*assertClause*/ undefined); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.createImportEqualsDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, ts.factory.createExternalModuleReference(newModuleString)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ts.factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); + return ts.Debug.assertNever(node, "Unexpected node kind ".concat(node.kind)); } } function moduleSpecifierFromImport(i) { - return (i.kind === 266 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 265 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 266 /* SyntaxKind.ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -163957,7 +164861,7 @@ var ts; var defaultImport; var imports = []; newFileNeedExport.forEach(function (symbol) { - if (symbol.escapedName === "default" /* Default */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */) { defaultImport = ts.factory.createIdentifier(ts.symbolNameNoDefault(symbol)); // TODO: GH#18217 } else { @@ -163981,7 +164885,7 @@ var ts; } } function makeVariableStatement(name, type, initializer, flags) { - if (flags === void 0) { flags = 2 /* Const */; } + if (flags === void 0) { flags = 2 /* NodeFlags.Const */; } return ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, initializer)], flags)); } function createRequireCall(moduleSpecifier) { @@ -164001,19 +164905,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind ".concat(importDecl.kind)); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -164022,7 +164926,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 268 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -164034,7 +164938,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.factory.updateImportClause(importDecl.importClause, importDecl.importClause.isTypeOnly, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 269 /* NamedImports */) { + else if (namedBindings.kind === 269 /* SyntaxKind.NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -164047,14 +164951,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: break; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -164096,7 +165000,7 @@ var ts; if (markSeenTop(top)) { addExportToChanges(oldFile, top, name, changes, useEsModuleSyntax); } - if (ts.hasSyntacticModifier(decl, 512 /* Default */)) { + if (ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */)) { oldFileDefault = name; } else { @@ -164113,17 +165017,17 @@ var ts; var name = ts.combinePaths(inDirectory, newModuleName + extension); if (!host.fileExists(name)) return newModuleName; - newModuleName = moduleName + "." + i; + newModuleName = "".concat(moduleName, ".").concat(i); } } - function getNewModuleName(movedSymbols) { - return movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile"; + function getNewModuleName(importsFromNewFile, movedSymbols) { + return importsFromNewFile.forEachEntry(ts.symbolNameNoDefault) || movedSymbols.forEachEntry(ts.symbolNameNoDefault) || "newFile"; } function getUsageInfo(oldFile, toMove, checker) { var movedSymbols = new SymbolSet(); var oldImportsNeededByNewFile = new SymbolSet(); var newFileImportsFromOldFile = new SymbolSet(); - var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* ContainsJsx */); }); + var containsJsx = ts.find(toMove, function (statement) { return !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */); }); var jsxNamespaceSymbol = getJsxNamespaceSymbol(containsJsx); if (jsxNamespaceSymbol) { // Might not exist (e.g. in non-compiling code) oldImportsNeededByNewFile.add(jsxNamespaceSymbol); @@ -164157,7 +165061,7 @@ var ts; if (ts.contains(toMove, statement)) continue; // jsxNamespaceSymbol will only be set iff it is in oldImportsNeededByNewFile. - if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* ContainsJsx */)) { + if (jsxNamespaceSymbol && !!(statement.transformFlags & 2 /* TransformFlags.ContainsJsx */)) { unusedImportsFromOldFile.delete(jsxNamespaceSymbol); } forEachReference(statement, checker, function (symbol) { @@ -164175,7 +165079,7 @@ var ts; // Strictly speaking, this could resolve to a symbol other than the JSX namespace. // This will produce erroneous output (probably, an incorrectly copied import) but // is expected to be very rare and easily reversible. - var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* Namespace */, /*excludeGlobals*/ true); + var jsxNamespaceSymbol = checker.resolveName(jsxNamespace, containsJsx, 1920 /* SymbolFlags.Namespace */, /*excludeGlobals*/ true); return !!jsxNamespaceSymbol && ts.some(jsxNamespaceSymbol.declarations, isInImport) ? jsxNamespaceSymbol : undefined; @@ -164184,14 +165088,14 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 265 /* ImportEqualsDeclaration */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: return true; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -164203,7 +165107,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -164213,18 +165117,18 @@ var ts; ? ts.factory.createImportDeclaration(/*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined) : undefined; } - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); + return ts.Debug.assertNever(i, "Unexpected import kind ".concat(i.kind)); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 268 /* NamespaceImport */) { + if (namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -164234,11 +165138,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return keep(name) ? name : undefined; - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return name; - case 201 /* ObjectBindingPattern */: { + case 201 /* SyntaxKind.ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.factory.createObjectBindingPattern(newElements) : undefined; @@ -164295,13 +165199,13 @@ var ts; } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -164309,19 +165213,19 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return cb(statement); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 238 /* ExpressionStatement */: { + case 238 /* SyntaxKind.ExpressionStatement */: { var expression = statement.expression; - return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ + return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* AssignmentDeclarationKind.ExportsProperty */ ? cb(statement) : undefined; } @@ -164329,13 +165233,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); + return ts.Debug.assertNever(name, "Unexpected name kind ".concat(name.kind)); } } function nameOfTopLevelDeclaration(d) { @@ -164343,9 +165247,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return d.parent.parent; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -164367,7 +165271,7 @@ var ts; function isExported(sourceFile, decl, useEs6Exports, name) { var _a; if (useEs6Exports) { - return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); + return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText))); } return getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); }); } @@ -164375,29 +165279,29 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.canHaveModifiers(d) ? ts.concatenate([ts.factory.createModifier(93 /* ExportKeyword */)], ts.getModifiers(d)) : undefined; + var modifiers = ts.canHaveModifiers(d) ? ts.concatenate([ts.factory.createModifier(93 /* SyntaxKind.ExportKeyword */)], ts.getModifiers(d)) : undefined; switch (d.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return ts.factory.updateFunctionDeclaration(d, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var decorators = ts.canHaveDecorators(d) ? ts.getDecorators(d) : undefined; return ts.factory.updateClassDeclaration(d, ts.concatenate(decorators, modifiers), d.name, d.typeParameters, d.heritageClauses, d.members); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.factory.updateVariableStatement(d, modifiers, d.declarationList); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return ts.factory.updateModuleDeclaration(d, modifiers, d.name, d.body); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.factory.updateEnumDeclaration(d, modifiers, d.name, d.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return ts.factory.updateTypeAliasDeclaration(d, modifiers, d.name, d.typeParameters, d.type); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.factory.updateInterfaceDeclaration(d, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.factory.updateImportEqualsDeclaration(d, modifiers, d.isTypeOnly, d.name, d.moduleReference); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); + return ts.Debug.assertNever(d, "Unexpected declaration kind ".concat(d.kind)); } } function addCommonjsExport(decl) { @@ -164405,26 +165309,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.emptyArray; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); + return ts.Debug.assertNever(decl, "Unexpected decl kind ".concat(decl.kind)); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* EqualsToken */, ts.factory.createIdentifier(name))); + return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("exports"), ts.factory.createIdentifier(name)), 63 /* SyntaxKind.EqualsToken */, ts.factory.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -164487,14 +165391,14 @@ var ts; if (actionName === addBracesAction.name) { var returnStatement_1 = ts.factory.createReturnStatement(expression); body = ts.factory.createBlock([returnStatement_1], /* multiLine */ true); - ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); + ts.copyLeadingComments(expression, returnStatement_1, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ true); } else if (actionName === removeBracesAction.name && returnStatement) { var actualExpression = expression || ts.factory.createVoidZero(); body = ts.needsParentheses(actualExpression) ? ts.factory.createParenthesizedExpression(actualExpression) : actualExpression; - ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyLeadingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(returnStatement, body, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } else { ts.Debug.fail("invalid action"); @@ -164628,7 +165532,7 @@ var ts; var contextualSymbols = ts.map(functionNames, function (name) { return getSymbolForContextualType(name, checker); }); for (var _i = 0, referenceEntries_1 = referenceEntries; _i < referenceEntries_1.length; _i++) { var entry = referenceEntries_1[_i]; - if (entry.kind === 0 /* Span */) { + if (entry.kind === 0 /* FindAllReferences.EntryKind.Span */) { groupedReferences.valid = false; continue; } @@ -164727,7 +165631,7 @@ var ts; if (element) { var contextualType = checker.getContextualTypeForObjectLiteralElement(element); var symbol = contextualType === null || contextualType === void 0 ? void 0 : contextualType.getSymbol(); - if (symbol && !(ts.getCheckFlags(symbol) & 6 /* Synthetic */)) { + if (symbol && !(ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */)) { return symbol; } } @@ -164757,15 +165661,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -164775,7 +165679,7 @@ var ts; } break; // x["foo"](...) - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -164794,14 +165698,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -164813,7 +165717,7 @@ var ts; } function entryToType(entry) { var reference = entry.node; - if (ts.getMeaningFromLocation(reference) === 2 /* Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { + if (ts.getMeaningFromLocation(reference) === 2 /* SemanticMeaning.Type */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(reference.parent)) { return reference; } return undefined; @@ -164847,16 +165751,16 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralExpression(functionDeclaration.parent)) { var contextualSymbol = getSymbolForContextualType(functionDeclaration.name, checker); // don't offer the refactor when there are multiple signatures since we won't know which ones the user wants to change return ((_a = contextualSymbol === null || contextualSymbol === void 0 ? void 0 : contextualSymbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 && isSingleImplementation(functionDeclaration, checker); } return isSingleImplementation(functionDeclaration, checker); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -164864,8 +165768,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -164875,7 +165779,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 88 /* SyntaxKind.DefaultKeyword */); return !!defaultKeyword; } return true; @@ -164979,7 +165883,7 @@ var ts; } function createParameterTypeNode(parameters) { var members = ts.map(parameters, createPropertySignatureFromParameterDeclaration); - var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* SingleLine */); + var typeNode = ts.addEmitFlags(ts.factory.createTypeLiteralNode(members), 1 /* EmitFlags.SingleLine */); return typeNode; } function createPropertySignatureFromParameterDeclaration(parameterDeclaration) { @@ -164988,7 +165892,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.factory.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType); + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : parameterDeclaration.questionToken, parameterType); ts.suppressLeadingAndTrailingTrivia(propertySignature); ts.copyComments(parameterDeclaration.name, propertySignature.name); if (parameterDeclaration.type && propertySignature.type) { @@ -165013,15 +165917,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -165032,30 +165936,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 88 /* SyntaxKind.DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return [functionDeclaration.name]; - case 171 /* Constructor */: - var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 226 /* ClassExpression */) { + case 171 /* SyntaxKind.Constructor */: + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 134 /* SyntaxKind.ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 226 /* SyntaxKind.ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return [functionDeclaration.parent.name]; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind ".concat(functionDeclaration.kind)); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -165136,16 +166040,16 @@ var ts; } } function isNotEqualsOperator(node) { - return node.operatorToken.kind !== 63 /* EqualsToken */; + return node.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */; } function getParentBinaryExpression(expr) { var container = ts.findAncestor(expr.parent, function (n) { switch (n.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return false; - case 223 /* TemplateExpression */: - case 221 /* BinaryExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return !(ts.isBinaryExpression(n.parent) && isNotEqualsOperator(n.parent)); default: return "quit"; @@ -165163,7 +166067,7 @@ var ts; if (!(leftHasString || ts.isStringLiteral(current.right) || ts.isTemplateExpression(current.right))) { return { nodes: [current], operators: [], hasString: false, validOperators: true }; } - var currentOperatorValid = current.operatorToken.kind === 39 /* PlusToken */; + var currentOperatorValid = current.operatorToken.kind === 39 /* SyntaxKind.PlusToken */; var validOperators = leftOperatorValid && currentOperatorValid; nodes.push(current.right); operators.push(current.operatorToken); @@ -165176,7 +166080,7 @@ var ts; // "foo" + /* comment */ "bar" var copyTrailingOperatorComments = function (operators, file) { return function (index, targetNode) { if (index < operators.length) { - ts.copyTrailingComments(operators[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(operators[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } }; }; // to copy comments following the string @@ -165185,7 +166089,7 @@ var ts; return function (indexes, targetNode) { while (indexes.length > 0) { var index = indexes.shift(); - ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(nodes[index], targetNode, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); copyOperatorComments(index, targetNode); } }; @@ -165239,7 +166143,7 @@ var ts; var templateSpans = []; var templateHead = ts.factory.createTemplateHead(headText, rawHeadText); copyCommentFromStringLiterals(headIndexes, templateHead); - var _loop_20 = function (i) { + var _loop_19 = function (i) { var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]); copyOperatorComments(i, currentNode); var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3]; @@ -165268,7 +166172,7 @@ var ts; }; var out_i_1; for (var i = begin; i < nodes.length; i++) { - _loop_20(i); + _loop_19(i); i = out_i_1; } return ts.factory.createTemplateExpression(templateHead, templateSpans); @@ -165277,8 +166181,8 @@ var ts; // "foo" + ( /* comment */ 5 + 5 ) /* comment */ + "bar" function copyExpressionComments(node) { var file = node.getSourceFile(); - ts.copyTrailingComments(node, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); - ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(node, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingAsLeadingComments(node.expression, node.expression, file, 3 /* SyntaxKind.MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } function getExpressionFromParenthesesOrExpression(node) { if (ts.isParenthesizedExpression(node)) { @@ -165473,7 +166377,7 @@ var ts; var body = convertToBlock(func.body); var variableDeclaration = variableInfo.variableDeclaration, variableDeclarationList = variableInfo.variableDeclarationList, statement = variableInfo.statement, name = variableInfo.name; ts.suppressLeadingTrivia(statement); - var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* Export */) | ts.getEffectiveModifierFlags(func); + var modifiersFlags = (ts.getCombinedModifierFlags(variableDeclaration) & 1 /* ModifierFlags.Export */) | ts.getEffectiveModifierFlags(func); var modifiers = ts.factory.createModifiersFromModifierFlags(modifiersFlags); var newNode = ts.factory.createFunctionDeclaration(ts.length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { @@ -165499,7 +166403,7 @@ var ts; else { body = func.body; } - var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* EqualsGreaterThanToken */), body); + var newNode = ts.factory.createArrowFunction(func.modifiers, func.typeParameters, func.parameters, func.type, ts.factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), body); return ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, func, newNode); }); } function canBeConvertedToExpression(body, head) { @@ -165559,13 +166463,13 @@ var ts; return ts.emptyArray; } function doChange(sourceFile, changes, declaration, typeNode) { - var closeParen = ts.findChildOfKind(declaration, 21 /* CloseParenToken */, sourceFile); + var closeParen = ts.findChildOfKind(declaration, 21 /* SyntaxKind.CloseParenToken */, sourceFile); var needParens = ts.isArrowFunction(declaration) && closeParen === undefined; var endNode = needParens ? ts.first(declaration.parameters) : closeParen; if (endNode) { if (needParens) { - changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* OpenParenToken */)); - changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* CloseParenToken */)); + changes.insertNodeBefore(sourceFile, endNode, ts.factory.createToken(20 /* SyntaxKind.OpenParenToken */)); + changes.insertNodeAfter(sourceFile, endNode, ts.factory.createToken(21 /* SyntaxKind.CloseParenToken */)); } changes.insertNodeAt(sourceFile, endNode.end, typeNode, { prefix: ": " }); } @@ -165575,7 +166479,7 @@ var ts; return; var token = ts.getTokenAtPosition(context.file, context.startPosition); var declaration = ts.findAncestor(token, function (n) { - return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : + return ts.isBlock(n) || n.parent && ts.isArrowFunction(n.parent) && (n.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */ || n.parent.body === n) ? "quit" : isConvertibleDeclaration(n); }); if (!declaration || !declaration.body || declaration.type) { @@ -165586,17 +166490,17 @@ var ts; if (!returnType) { return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_determine_function_return_type) }; } - var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NoTruncation */); + var returnTypeNode = typeChecker.typeToTypeNode(returnType, declaration, 1 /* NodeBuilderFlags.NoTruncation */); if (returnTypeNode) { return { declaration: declaration, returnTypeNode: returnTypeNode }; } } function isConvertibleDeclaration(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return true; default: return false; @@ -165623,20 +166527,20 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 79 /* Identifier */ ? new IdentifierObject(79 /* Identifier */, pos, end) : - kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) : + kind === 79 /* SyntaxKind.Identifier */ ? new IdentifierObject(79 /* SyntaxKind.Identifier */, pos, end) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* SyntaxKind.PrivateIdentifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 50720768 /* ContextFlags */; + node.flags = parent.flags & 50720768 /* NodeFlags.ContextFlags */; return node; } var NodeObject = /** @class */ (function () { function NodeObject(kind, pos, end) { this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.kind = kind; } @@ -165698,8 +166602,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 309 /* FirstJSDocNode */ || kid.kind > 347 /* LastJSDocNode */; }); - return child.kind < 161 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 309 /* SyntaxKind.FirstJSDocNode */ || kid.kind > 347 /* SyntaxKind.LastJSDocNode */; }); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -165710,7 +166614,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 161 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 161 /* SyntaxKind.FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -165758,19 +166662,19 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 79 /* Identifier */) { - ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); + if (token === 79 /* SyntaxKind.Identifier */) { + ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia")); } nodes.push(createNode(token, pos, textPos, parent)); } pos = textPos; - if (token === 1 /* EndOfFileToken */) { + if (token === 1 /* SyntaxKind.EndOfFileToken */) { break; } } } function createSyntaxList(nodes, parent) { - var list = createNode(348 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(348 /* SyntaxKind.SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { @@ -165787,9 +166691,9 @@ var ts; // Set properties in same order as NodeObject this.pos = pos; this.end = end; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } TokenOrIdentifierObject.prototype.getSourceFile = function () { @@ -165829,7 +166733,7 @@ var ts; return this.getChildren()[index]; }; TokenOrIdentifierObject.prototype.getChildren = function () { - return this.kind === 1 /* EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; + return this.kind === 1 /* SyntaxKind.EndOfFileToken */ ? this.jsDoc || ts.emptyArray : ts.emptyArray; }; TokenOrIdentifierObject.prototype.getFirstToken = function () { return undefined; @@ -165880,20 +166784,25 @@ var ts; return this.documentationComment; }; SymbolObject.prototype.getContextualDocumentationComment = function (context, checker) { - switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + if (context) { + if (ts.isGetAccessor(context)) { if (!this.contextualGetAccessorDocumentationComment) { this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker); } - return this.contextualGetAccessorDocumentationComment; - case 173 /* SetAccessor */: + if (ts.length(this.contextualGetAccessorDocumentationComment)) { + return this.contextualGetAccessorDocumentationComment; + } + } + if (ts.isSetAccessor(context)) { if (!this.contextualSetAccessorDocumentationComment) { this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker); } - return this.contextualSetAccessorDocumentationComment; - default: - return this.getDocumentationComment(checker); + if (ts.length(this.contextualSetAccessorDocumentationComment)) { + return this.contextualSetAccessorDocumentationComment; + } + } } + return this.getDocumentationComment(checker); }; SymbolObject.prototype.getJsDocTags = function (checker) { if (this.tags === undefined) { @@ -165902,20 +166811,25 @@ var ts; return this.tags; }; SymbolObject.prototype.getContextualJsDocTags = function (context, checker) { - switch (context === null || context === void 0 ? void 0 : context.kind) { - case 172 /* GetAccessor */: + if (context) { + if (ts.isGetAccessor(context)) { if (!this.contextualGetAccessorTags) { this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker); } - return this.contextualGetAccessorTags; - case 173 /* SetAccessor */: + if (ts.length(this.contextualGetAccessorTags)) { + return this.contextualGetAccessorTags; + } + } + if (ts.isSetAccessor(context)) { if (!this.contextualSetAccessorTags) { this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker); } - return this.contextualSetAccessorTags; - default: - return this.getJsDocTags(checker); + if (ts.length(this.contextualSetAccessorTags)) { + return this.contextualSetAccessorTags; + } + } } + return this.getJsDocTags(checker); }; return SymbolObject; }()); @@ -165932,7 +166846,7 @@ var ts; __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { var _this = _super.call(this, pos, end) || this; - _this.kind = 79 /* Identifier */; + _this.kind = 79 /* SyntaxKind.Identifier */; return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { @@ -165944,7 +166858,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 79 /* Identifier */; + IdentifierObject.prototype.kind = 79 /* SyntaxKind.Identifier */; var PrivateIdentifierObject = /** @class */ (function (_super) { __extends(PrivateIdentifierObject, _super); function PrivateIdentifierObject(_kind, pos, end) { @@ -165959,7 +166873,7 @@ var ts; }); return PrivateIdentifierObject; }(TokenOrIdentifierObject)); - PrivateIdentifierObject.prototype.kind = 80 /* PrivateIdentifier */; + PrivateIdentifierObject.prototype.kind = 80 /* SyntaxKind.PrivateIdentifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -165981,16 +166895,16 @@ var ts; return this.checker.getAugmentedPropertiesOfType(this); }; TypeObject.prototype.getCallSignatures = function () { - return this.checker.getSignaturesOfType(this, 0 /* Call */); + return this.checker.getSignaturesOfType(this, 0 /* SignatureKind.Call */); }; TypeObject.prototype.getConstructSignatures = function () { - return this.checker.getSignaturesOfType(this, 1 /* Construct */); + return this.checker.getSignaturesOfType(this, 1 /* SignatureKind.Construct */); }; TypeObject.prototype.getStringIndexType = function () { - return this.checker.getIndexTypeOfType(this, 0 /* String */); + return this.checker.getIndexTypeOfType(this, 0 /* IndexKind.String */); }; TypeObject.prototype.getNumberIndexType = function () { - return this.checker.getIndexTypeOfType(this, 1 /* Number */); + return this.checker.getIndexTypeOfType(this, 1 /* IndexKind.Number */); }; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; @@ -166011,41 +166925,41 @@ var ts; return this.checker.getDefaultFromTypeParameter(this); }; TypeObject.prototype.isUnion = function () { - return !!(this.flags & 1048576 /* Union */); + return !!(this.flags & 1048576 /* TypeFlags.Union */); }; TypeObject.prototype.isIntersection = function () { - return !!(this.flags & 2097152 /* Intersection */); + return !!(this.flags & 2097152 /* TypeFlags.Intersection */); }; TypeObject.prototype.isUnionOrIntersection = function () { - return !!(this.flags & 3145728 /* UnionOrIntersection */); + return !!(this.flags & 3145728 /* TypeFlags.UnionOrIntersection */); }; TypeObject.prototype.isLiteral = function () { - return !!(this.flags & 384 /* StringOrNumberLiteral */); + return !!(this.flags & 384 /* TypeFlags.StringOrNumberLiteral */); }; TypeObject.prototype.isStringLiteral = function () { - return !!(this.flags & 128 /* StringLiteral */); + return !!(this.flags & 128 /* TypeFlags.StringLiteral */); }; TypeObject.prototype.isNumberLiteral = function () { - return !!(this.flags & 256 /* NumberLiteral */); + return !!(this.flags & 256 /* TypeFlags.NumberLiteral */); }; TypeObject.prototype.isTypeParameter = function () { - return !!(this.flags & 262144 /* TypeParameter */); + return !!(this.flags & 262144 /* TypeFlags.TypeParameter */); }; TypeObject.prototype.isClassOrInterface = function () { - return !!(ts.getObjectFlags(this) & 3 /* ClassOrInterface */); + return !!(ts.getObjectFlags(this) & 3 /* ObjectFlags.ClassOrInterface */); }; TypeObject.prototype.isClass = function () { - return !!(ts.getObjectFlags(this) & 1 /* Class */); + return !!(ts.getObjectFlags(this) & 1 /* ObjectFlags.Class */); }; TypeObject.prototype.isIndexType = function () { - return !!(this.flags & 4194304 /* Index */); + return !!(this.flags & 4194304 /* TypeFlags.Index */); }; Object.defineProperty(TypeObject.prototype, "typeArguments", { /** * This polyfills `referenceType.typeArguments` for API consumers */ get: function () { - if (ts.getObjectFlags(this) & 4 /* Reference */) { + if (ts.getObjectFlags(this) & 4 /* ObjectFlags.Reference */) { return this.checker.getTypeArguments(this); } return undefined; @@ -166104,12 +167018,12 @@ var ts; var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker); if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) { var seenSymbols_1 = new ts.Set(); - var _loop_21 = function (declaration) { + var _loop_20 = function (declaration) { var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; if (!seenSymbols_1.has(symbol)) { seenSymbols_1.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualJsDocTags(declaration, checker); } return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; @@ -166121,7 +167035,7 @@ var ts; }; for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) { var declaration = declarations_7[_i]; - _loop_21(declaration); + _loop_20(declaration); } } return tags; @@ -166132,11 +167046,11 @@ var ts; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker); if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) { var seenSymbols_2 = new ts.Set(); - var _loop_22 = function (declaration) { + var _loop_21 = function (declaration) { var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) { if (!seenSymbols_2.has(symbol)) { seenSymbols_2.add(symbol); - if (declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) { return symbol.getContextualDocumentationComment(declaration, checker); } return symbol.getDocumentationComment(checker); @@ -166148,14 +167062,14 @@ var ts; }; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - _loop_22(declaration); + _loop_21(declaration); } } return doc; } function findBaseOfDeclaration(checker, declaration, cb) { var _a; - var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ ? declaration.parent.parent : declaration.parent; + var classOrInterfaceDeclaration = ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ ? declaration.parent.parent : declaration.parent; if (!classOrInterfaceDeclaration) return; var isStaticMember = ts.hasStaticModifier(declaration); @@ -166170,7 +167084,7 @@ var ts; __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { var _this = _super.call(this, kind, pos, end) || this; - _this.kind = 305 /* SourceFile */; + _this.kind = 305 /* SyntaxKind.SourceFile */; return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { @@ -166229,10 +167143,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -166252,31 +167166,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 275 /* ExportSpecifier */: - case 270 /* ImportSpecifier */: - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 182 /* TypeLiteral */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 182 /* SyntaxKind.TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Only consider parameter properties - if (!ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { + if (!ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { break; } // falls through - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -166287,12 +167201,12 @@ var ts; } } // falls through - case 299 /* EnumMember */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: addDeclaration(node); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; var exportDeclaration = node; @@ -166305,7 +167219,7 @@ var ts; } } break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -166317,7 +167231,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -166326,8 +167240,8 @@ var ts; } } break; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) !== 0 /* AssignmentDeclarationKind.None */) { addDeclaration(node); } // falls through @@ -166396,8 +167310,8 @@ var ts; function getDefaultCompilerOptions() { // Always default to "ScriptTarget.ES5" for the language service return { - target: 1 /* ES5 */, - jsx: 1 /* Preserve */ + target: 1 /* ScriptTarget.ES5 */, + jsx: 1 /* JsxEmit.Preserve */ }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; @@ -166422,7 +167336,7 @@ var ts; if (this.currentFileName !== fileName) { // This is a new file, just parse it var options = { - languageVersion: 99 /* Latest */, + languageVersion: 99 /* ScriptTarget.Latest */, impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(fileName, this.host.getCurrentDirectory(), ((_c = (_b = (_a = this.host).getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getCanonicalFileName) || ts.hostGetCanonicalFileName(this.host)), (_h = (_g = (_f = (_e = (_d = this.host).getCompilerHost) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.getModuleResolutionCache) === null || _g === void 0 ? void 0 : _g.call(_f)) === null || _h === void 0 ? void 0 : _h.getPackageJsonInfoCache(), this.host, this.host.getCompilationSettings()), setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings()) }; @@ -166519,7 +167433,7 @@ var ts; }; CancellationTokenObject.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "CancellationTokenObject" }); throw new ts.OperationCanceledException(); } }; @@ -166549,7 +167463,7 @@ var ts; }; ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { if (this.isCancellationRequested()) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* tracing.Phase.Session */, "cancellationThrown", { kind: "ThrottledCancellationToken" }); throw new ts.OperationCanceledException(); } }; @@ -166639,7 +167553,7 @@ var ts; function getValidSourceFile(fileName) { var sourceFile = program.getSourceFile(fileName); if (!sourceFile) { - var error = new Error("Could not find source file: '" + fileName + "'."); + var error = new Error("Could not find source file: '".concat(fileName, "'.")); // We've been having trouble debugging this, so attach sidecar data for the tsserver log. // See https://github.com/microsoft/TypeScript/issues/30180. error.ProgramFiles = program.getSourceFiles().map(function (f) { return f.fileName; }); @@ -166666,7 +167580,10 @@ var ts; program = undefined; // TODO: GH#18217 lastTypesRootVersion = typeRootsVersion; } - var rootFileNames = host.getScriptFileNames(); + // This array is retained by the program and will be used to determine if the program is up to date, + // so we need to make a copy in case the host mutates the underlying array - otherwise it would look + // like every program always has the host's current list of root files. + var rootFileNames = host.getScriptFileNames().slice(); // Get a fresh cache of the host information var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; @@ -166777,7 +167694,7 @@ var ts; return result; } function getParsedCommandLineOfConfigFileUsingSourceFile(configFileName) { - var result = getOrCreateSourceFile(configFileName, 100 /* JSON */); + var result = getOrCreateSourceFile(configFileName, 100 /* ScriptTarget.JSON */); if (!result) return undefined; result.path = ts.toPath(configFileName, currentDirectory, getCanonicalFileName); @@ -166799,12 +167716,12 @@ var ts; // not part of the new program. function onReleaseOldSourceFile(oldSourceFile, oldOptions) { var oldSettingsKey = documentRegistry.getKeyForCompilationSettings(oldOptions); - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, oldSettingsKey, oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat); } - function getOrCreateSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) { - return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersion, onError, shouldCreateNewSourceFile); + function getOrCreateSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) { + return getOrCreateSourceFileByPath(fileName, ts.toPath(fileName, currentDirectory, getCanonicalFileName), languageVersionOrOptions, onError, shouldCreateNewSourceFile); } - function getOrCreateSourceFileByPath(fileName, path, _languageVersion, _onError, shouldCreateNewSourceFile) { + function getOrCreateSourceFileByPath(fileName, path, languageVersionOrOptions, _onError, shouldCreateNewSourceFile) { ts.Debug.assert(compilerHost, "getOrCreateSourceFileByPath called after typical CompilerHost lifetime, check the callstack something with a reference to an old host."); // The program is asking for this file, check first if the host can locate it. // If the host can not locate the file, then it does not exist. return undefined @@ -166847,17 +167764,17 @@ var ts; // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" if (scriptKind === oldSourceFile.scriptKind) { - return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind); + return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions); } else { // Release old source file and fall through to aquire new file with new script kind - documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind); + documentRegistry.releaseDocumentWithKey(oldSourceFile.resolvedPath, documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()), oldSourceFile.scriptKind, oldSourceFile.impliedNodeFormat); } } // We didn't already have the file. Fall through and acquire it from the registry. } // Could not find this file in the old program, create a new SourceFile for it. - return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind); + return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, scriptSnapshot, scriptVersion, scriptKind, languageVersionOrOptions); } } // TODO: GH#18217 frequently asserted as defined @@ -166924,7 +167841,7 @@ var ts; if (!sourceFile) return undefined; var rawNode = ts.getTouchingPropertyName(sourceFile, docSpan.textSpan.start); - var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* References */ }); + var adjustedNode = ts.FindAllReferences.Core.getAdjustedNode(rawNode, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }); return adjustedNode; } } @@ -166936,7 +167853,7 @@ var ts; // Use paths to ensure we are using correct key and paths as document registry could be created with different current directory than host var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()); ts.forEach(program.getSourceFiles(), function (f) { - return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind); + return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1, f.scriptKind, f.impliedNodeFormat); }); program = undefined; // TODO: GH#18217 } @@ -167004,8 +167921,8 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { var type_2 = shouldGetType(sourceFile, nodeForQuickInfo, position) ? typeChecker.getTypeAtLocation(nodeForQuickInfo) : undefined; return type_2 && { - kind: "" /* unknown */, - kindModifiers: "" /* none */, + kind: "" /* ScriptElementKind.unknown */, + kindModifiers: "" /* ScriptElementKindModifier.none */, textSpan: ts.createTextSpanFromNode(nodeForQuickInfo, sourceFile), displayParts: typeChecker.runWithCancellationToken(cancellationToken, function (typeChecker) { return ts.typeToDisplayParts(typeChecker, type_2, ts.getContainerNode(nodeForQuickInfo)); }), documentation: type_2.symbol ? type_2.symbol.getDocumentationComment(typeChecker) : undefined, @@ -167038,18 +167955,18 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node) && !ts.isConstTypeReference(node.parent); - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 106 /* SuperKeyword */: - case 197 /* NamedTupleMember */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 106 /* SyntaxKind.SuperKeyword */: + case 197 /* SyntaxKind.NamedTupleMember */: return true; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return ts.isImportMeta(node); default: return false; @@ -167075,7 +167992,7 @@ var ts; } /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { - return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); + return ts.flatMap(getDocumentHighlights(fileName, position, [fileName]), function (entry) { return entry.highlightSpans.map(function (highlightSpan) { return (__assign(__assign({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === "writtenReference" /* HighlightSpanKind.writtenReference */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); }); } function getDocumentHighlights(fileName, position, filesToSearch) { var normalizedFileName = ts.normalizePath(fileName); @@ -167099,17 +168016,17 @@ var ts; }); } else { - return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); + return getReferencesWorker(node, position, { findInStrings: findInStrings, findInComments: findInComments, providePrefixAndSuffixTextForRename: providePrefixAndSuffixTextForRename, use: 2 /* FindAllReferences.FindReferencesUse.Rename */ }, function (entry, originalNode, checker) { return ts.FindAllReferences.toRenameLocation(entry, originalNode, checker, providePrefixAndSuffixTextForRename || false); }); } } function getReferencesAtPosition(fileName, position) { synchronizeHostData(); - return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry); + return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* FindAllReferences.FindReferencesUse.References */ }, ts.FindAllReferences.toReferenceEntry); } function getReferencesWorker(node, position, options, cb) { synchronizeHostData(); // Exclude default library when renaming as commonly user don't want to change that file. - var sourceFiles = options && options.use === 2 /* Rename */ + var sourceFiles = options && options.use === 2 /* FindAllReferences.FindReferencesUse.Rename */ ? program.getSourceFiles().filter(function (sourceFile) { return !program.isSourceFileDefaultLibrary(sourceFile); }) : program.getSourceFiles(); return ts.FindAllReferences.findReferenceOrRenameEntries(program, cancellationToken, sourceFiles, node, position, options, cb); @@ -167156,16 +168073,16 @@ var ts; return undefined; } switch (node.kind) { - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: - case 10 /* StringLiteral */: - case 95 /* FalseKeyword */: - case 110 /* TrueKeyword */: - case 104 /* NullKeyword */: - case 106 /* SuperKeyword */: - case 108 /* ThisKeyword */: - case 192 /* ThisType */: - case 79 /* Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: + case 10 /* SyntaxKind.StringLiteral */: + case 95 /* SyntaxKind.FalseKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 79 /* SyntaxKind.Identifier */: break; // Cant create the text span default: @@ -167181,7 +168098,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 261 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -167211,8 +168128,8 @@ var ts; } function getSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "2020" /* TwentyTwenty */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "2020" /* SemanticClassificationFormat.TwentyTwenty */) { return ts.classifier.v2020.getSemanticClassifications(program, cancellationToken, getValidSourceFile(fileName), span); } else { @@ -167221,8 +168138,8 @@ var ts; } function getEncodedSemanticClassifications(fileName, span, format) { synchronizeHostData(); - var responseFormat = format || "original" /* Original */; - if (responseFormat === "original" /* Original */) { + var responseFormat = format || "original" /* SemanticClassificationFormat.Original */; + if (responseFormat === "original" /* SemanticClassificationFormat.Original */) { return ts.getEncodedSemanticClassifications(program.getTypeChecker(), cancellationToken, getValidSourceFile(fileName), program.getClassifiableNames(), span); } else { @@ -167243,10 +168160,10 @@ var ts; return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } var braceMatching = new ts.Map(ts.getEntries((_a = {}, - _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, - _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, - _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, + _a[18 /* SyntaxKind.OpenBraceToken */] = 19 /* SyntaxKind.CloseBraceToken */, + _a[20 /* SyntaxKind.OpenParenToken */] = 21 /* SyntaxKind.CloseParenToken */, + _a[22 /* SyntaxKind.OpenBracketToken */] = 23 /* SyntaxKind.CloseBracketToken */, + _a[31 /* SyntaxKind.GreaterThanToken */] = 29 /* SyntaxKind.LessThanToken */, _a))); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -167343,7 +168260,7 @@ var ts; // var x = new foo<| ( with class foo{} ) // or // var y = 3 <| - if (openingBrace === 60 /* lessThan */) { + if (openingBrace === 60 /* CharacterCodes.lessThan */) { return false; } var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -167352,15 +168269,15 @@ var ts; return false; } if (ts.isInsideJsxElementOrAttribute(sourceFile, position)) { - return openingBrace === 123 /* openBrace */; + return openingBrace === 123 /* CharacterCodes.openBrace */; } if (ts.isInTemplateString(sourceFile, position)) { return false; } switch (openingBrace) { - case 39 /* singleQuote */: - case 34 /* doubleQuote */: - case 96 /* backtick */: + case 39 /* CharacterCodes.singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 96 /* CharacterCodes.backtick */: return !ts.isInComment(sourceFile, position); } return true; @@ -167370,12 +168287,12 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxElement(token.parent) ? token.parent : undefined; if (element && isUnclosedTag(element)) { - return { newText: "" }; + return { newText: "") }; } - var fragment = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent + var fragment = token.kind === 31 /* SyntaxKind.GreaterThanToken */ && ts.isJsxOpeningFragment(token.parent) ? token.parent.parent : ts.isJsxText(token) && ts.isJsxFragment(token.parent) ? token.parent : undefined; if (fragment && isUnclosedFragment(fragment)) { return { newText: "" }; @@ -167472,14 +168389,14 @@ var ts; commentRange.end++; } positions.push(commentRange.pos); - if (commentRange.kind === 3 /* MultiLineCommentTrivia */) { + if (commentRange.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { positions.push(commentRange.end); } hasComment = true; pos = commentRange.end + 1; } else { // If it's not in a comment range, then we need to comment the uncommented portions. - var newPos = text.substring(pos, textRange.end).search("(" + openMultilineRegex + ")|(" + closeMultilineRegex + ")"); + var newPos = text.substring(pos, textRange.end).search("(".concat(openMultilineRegex, ")|(").concat(closeMultilineRegex, ")")); isCommenting = insertComment !== undefined ? insertComment : isCommenting || !ts.isTextWhiteSpaceLike(text, pos, newPos === -1 ? textRange.end : pos + newPos); // If isCommenting is already true we don't need to check whitespace again. @@ -167489,7 +168406,7 @@ var ts; // If it didn't found a comment and isCommenting is false means is only empty space. // We want to insert comment in this scenario. if (isCommenting || !hasComment) { - if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SingleLineCommentTrivia */) { + if (((_a = ts.isInComment(sourceFile, textRange.pos)) === null || _a === void 0 ? void 0 : _a.kind) !== 2 /* SyntaxKind.SingleLineCommentTrivia */) { ts.insertSorted(positions, textRange.pos, ts.compareValues); } ts.insertSorted(positions, textRange.end, ts.compareValues); @@ -167575,10 +168492,10 @@ var ts; var commentRange = ts.isInComment(sourceFile, i); if (commentRange) { switch (commentRange.kind) { - case 2 /* SingleLineCommentTrivia */: + case 2 /* SyntaxKind.SingleLineCommentTrivia */: textChanges.push.apply(textChanges, toggleLineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); break; - case 3 /* MultiLineCommentTrivia */: + case 3 /* SyntaxKind.MultiLineCommentTrivia */: textChanges.push.apply(textChanges, toggleMultilineComment(fileName, { end: commentRange.end, pos: commentRange.pos + 1 }, /*insertComment*/ false)); } i = commentRange.end + 1; @@ -167593,12 +168510,12 @@ var ts; } function isUnclosedFragment(_a) { var closingFragment = _a.closingFragment, parent = _a.parent; - return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); + return !!(closingFragment.flags & 131072 /* NodeFlags.ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent)); } function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var range = ts.formatting.getRangeOfEnclosingComment(sourceFile, position); - return range && (!onlyMultiLine || range.kind === 3 /* MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; + return range && (!onlyMultiLine || range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) ? ts.createTextSpanFromRange(range) : undefined; } function getTodoComments(fileName, descriptors) { // Note: while getting todo comments seems like a syntactic operation, we actually @@ -167716,9 +168633,9 @@ var ts; return new RegExp(regExpString, "gim"); } function isLetterOrDigit(char) { - return (char >= 97 /* a */ && char <= 122 /* z */) || - (char >= 65 /* A */ && char <= 90 /* Z */) || - (char >= 48 /* _0 */ && char <= 57 /* _9 */); + return (char >= 97 /* CharacterCodes.a */ && char <= 122 /* CharacterCodes.z */) || + (char >= 65 /* CharacterCodes.A */ && char <= 90 /* CharacterCodes.Z */) || + (char >= 48 /* CharacterCodes._0 */ && char <= 57 /* CharacterCodes._9 */); } function isNodeModulesFile(path) { return ts.stringContains(path, "/node_modules/"); @@ -167853,6 +168770,7 @@ var ts; getEmitOutput: getEmitOutput, getNonBoundSourceFile: getNonBoundSourceFile, getProgram: getProgram, + getCurrentProgram: function () { return program; }, getAutoImportProvider: getAutoImportProvider, updateIsDefinitionOfReferencedSymbols: updateIsDefinitionOfReferencedSymbols, getApplicableRefactors: getApplicableRefactors, @@ -167875,14 +168793,14 @@ var ts; case ts.LanguageServiceMode.PartialSemantic: invalidOperationsInPartialSemanticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.PartialSemantic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.PartialSemantic")); }; }); break; case ts.LanguageServiceMode.Syntactic: invalidOperationsInSyntacticMode.forEach(function (key) { return ls[key] = function () { - throw new Error("LanguageService Operation: " + key + " not allowed in LanguageServiceMode.Syntactic"); + throw new Error("LanguageService Operation: ".concat(key, " not allowed in LanguageServiceMode.Syntactic")); }; }); break; @@ -167929,7 +168847,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 277 /* ExternalModuleReference */ || + node.parent.kind === 277 /* SyntaxKind.ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -167944,16 +168862,16 @@ var ts; ts.getContainingObjectLiteralElement = getContainingObjectLiteralElement; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - if (node.parent.kind === 162 /* ComputedPropertyName */) { + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 205 /* ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* JsxAttributes */) && + (node.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.parent.parent.kind === 286 /* SyntaxKind.JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -167995,7 +168913,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 207 /* ElementAccessExpression */ && + node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -168042,7 +168960,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 16777216 /* Ambient */) { + if (tokenAtLocation.flags & 16777216 /* NodeFlags.Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -168088,144 +169006,144 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 254 /* VariableDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return spanInVariableDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return spanInParameterDeclaration(node); - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return spanInFunctionDeclaration(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return spanInBlock(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInBlock(node.block); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: // span in statement return spanInNode(node.statement); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return spanInForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // span on complete module if it is instantiated - if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 203 /* BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 203 /* SyntaxKind.BindingElement */: // span on complete node return textSpan(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: // span in statement return spanInNode(node.statement); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return spanInNodeArray(parent.modifiers, node, ts.isDecorator); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return undefined; // Tokens: - case 26 /* SemicolonToken */: - case 1 /* EndOfFileToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return spanInPreviousNode(node); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return spanInOpenBraceToken(node); - case 19 /* CloseBraceToken */: + case 19 /* SyntaxKind.CloseBraceToken */: return spanInCloseBraceToken(node); - case 23 /* CloseBracketToken */: + case 23 /* SyntaxKind.CloseBracketToken */: return spanInCloseBracketToken(node); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return spanInOpenParenToken(node); - case 21 /* CloseParenToken */: + case 21 /* SyntaxKind.CloseParenToken */: return spanInCloseParenToken(node); - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: return spanInColonToken(node); - case 31 /* GreaterThanToken */: - case 29 /* LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return spanInWhileKeyword(node); - case 91 /* ElseKeyword */: - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 91 /* SyntaxKind.ElseKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return spanInNextNode(node); - case 160 /* OfKeyword */: + case 160 /* SyntaxKind.OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -168237,14 +169155,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 79 /* Identifier */ || - node.kind === 225 /* SpreadElement */ || - node.kind === 296 /* PropertyAssignment */ || - node.kind === 297 /* ShorthandPropertyAssignment */) && + if ((node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 225 /* SyntaxKind.SpreadElement */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 221 /* BinaryExpression */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -168253,35 +169171,35 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 63 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or // { a = expression, b, c } = someExpression return textSpan(node); } - if (operatorToken.kind === 27 /* CommaToken */) { + if (operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return spanInNode(left); } } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return textSpan(node); - case 221 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 27 /* CommaToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -168290,21 +169208,21 @@ var ts; } } switch (node.parent.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: { + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -168312,7 +169230,7 @@ var ts; } break; } - case 221 /* BinaryExpression */: { + case 221 /* SyntaxKind.BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -168342,7 +169260,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 243 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -168353,8 +169271,8 @@ var ts; // Breakpoint is possible in variableDeclaration only if there is initialization // or its declaration from 'for of' if ((ts.hasOnlyExpressionInitializer(variableDeclaration) && variableDeclaration.initializer) || - ts.hasSyntacticModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 244 /* ForOfStatement */) { + ts.hasSyntacticModifier(variableDeclaration, 1 /* ModifierFlags.Export */) || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -168369,7 +169287,7 @@ var ts; function canHaveSpanInParameterDeclaration(parameter) { // Breakpoint is possible on parameter only if it has initializer, is a rest parameter, or has public or private modifier return !!parameter.initializer || parameter.dotDotDotToken !== undefined || - ts.hasSyntacticModifier(parameter, 4 /* Public */ | 8 /* Private */); + ts.hasSyntacticModifier(parameter, 4 /* ModifierFlags.Public */ | 8 /* ModifierFlags.Private */); } function spanInParameterDeclaration(parameter) { if (ts.isBindingPattern(parameter.name)) { @@ -168394,8 +169312,8 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return ts.hasSyntacticModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 257 /* ClassDeclaration */ && functionDeclaration.kind !== 171 /* Constructor */); + return ts.hasSyntacticModifier(functionDeclaration, 1 /* ModifierFlags.Export */) || + (functionDeclaration.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && functionDeclaration.kind !== 171 /* SyntaxKind.Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -168418,26 +169336,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 261 /* ModuleDeclaration */: - if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { + case 261 /* SyntaxKind.ModuleDeclaration */: + if (ts.getModuleInstanceState(block.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement // falls through - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 243 /* ForInStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 243 /* SyntaxKind.ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -168462,21 +169380,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 203 /* BindingElement */) { + if (bindingPattern.parent.kind === 203 /* SyntaxKind.BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 202 /* ArrayBindingPattern */ && node.kind !== 201 /* ObjectBindingPattern */); - var elements = node.kind === 204 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 202 /* SyntaxKind.ArrayBindingPattern */ && node.kind !== 201 /* SyntaxKind.ObjectBindingPattern */); + var elements = node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 227 /* SyntaxKind.OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -168484,18 +169402,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 221 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -168503,25 +169421,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: // If this is not an instantiated module block, no bp span - if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { + if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* ModuleInstanceState.Instantiated */) { return undefined; } // falls through - case 260 /* EnumDeclaration */: - case 257 /* ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // Span on close brace token return textSpan(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -168529,7 +169447,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -168545,7 +169463,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -168560,12 +169478,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 240 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 208 /* CallExpression */ || - node.parent.kind === 209 /* NewExpression */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 208 /* SyntaxKind.CallExpression */ || + node.parent.kind === 209 /* SyntaxKind.NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 212 /* ParenthesizedExpression */) { + if (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -168574,21 +169492,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 212 /* ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -168598,20 +169516,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ || - node.parent.kind === 164 /* Parameter */) { + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + node.parent.kind === 164 /* SyntaxKind.Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 211 /* TypeAssertionExpression */) { + if (node.parent.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 240 /* DoStatement */) { + if (node.parent.kind === 240 /* SyntaxKind.DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -168619,7 +169537,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -168787,7 +169705,7 @@ var ts; return this.shimHost.getScriptKind(fileName); // TODO: GH#18217 } else { - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } }; LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { @@ -168877,13 +169795,13 @@ var ts; var result = action(); if (logPerformance) { var end = ts.timestamp(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); + logger.log("".concat(actionDescription, " completed in ").concat(end - start, " msec")); if (ts.isString(result)) { var str = result; if (str.length > 128) { str = str.substring(0, 128) + "..."; } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + logger.log(" result.length=".concat(str.length, ", result='").concat(JSON.stringify(str), "'")); } } return result; @@ -168965,7 +169883,7 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + this.forwardJSONCall("refresh(".concat(throwOnError, ")"), function () { return null; } // eslint-disable-line no-null/no-null ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { @@ -168981,43 +169899,43 @@ var ts; }; LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); + return this.forwardJSONCall("getSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), function () { return _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); }); }; LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSyntacticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { var _this = this; - return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", + return this.forwardJSONCall("getEncodedSemanticClassifications('".concat(fileName, "', ").concat(start, ", ").concat(length, ")"), // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. function () { return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); }); }; LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSyntacticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + return this.forwardJSONCall("getSemanticDiagnostics('".concat(fileName, "')"), function () { var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); return _this.realizeDiagnostics(diagnostics); }); }; LanguageServiceShimObject.prototype.getSuggestionDiagnostics = function (fileName) { var _this = this; - return this.forwardJSONCall("getSuggestionDiagnostics('" + fileName + "')", function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); + return this.forwardJSONCall("getSuggestionDiagnostics('".concat(fileName, "')"), function () { return _this.realizeDiagnostics(_this.languageService.getSuggestionDiagnostics(fileName)); }); }; LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { var _this = this; @@ -169033,7 +169951,7 @@ var ts; */ LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); + return this.forwardJSONCall("getQuickInfoAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getQuickInfoAtPosition(fileName, position); }); }; /// NAMEORDOTTEDNAMESPAN /** @@ -169042,7 +169960,7 @@ var ts; */ LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { var _this = this; - return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); + return this.forwardJSONCall("getNameOrDottedNameSpan('".concat(fileName, "', ").concat(startPos, ", ").concat(endPos, ")"), function () { return _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); }); }; /** * STATEMENTSPAN @@ -169050,12 +169968,12 @@ var ts; */ LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); + return this.forwardJSONCall("getBreakpointStatementAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBreakpointStatementAtPosition(fileName, position); }); }; /// SIGNATUREHELP LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); + return this.forwardJSONCall("getSignatureHelpItems('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSignatureHelpItems(fileName, position, options); }); }; /// GOTO DEFINITION /** @@ -169064,7 +169982,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAtPosition(fileName, position); }); }; /** * Computes the definition location and file for the symbol @@ -169072,7 +169990,7 @@ var ts; */ LanguageServiceShimObject.prototype.getDefinitionAndBoundSpan = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getDefinitionAndBoundSpan('" + fileName + "', " + position + ")", function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); + return this.forwardJSONCall("getDefinitionAndBoundSpan('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDefinitionAndBoundSpan(fileName, position); }); }; /// GOTO Type /** @@ -169081,7 +169999,7 @@ var ts; */ LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); + return this.forwardJSONCall("getTypeDefinitionAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getTypeDefinitionAtPosition(fileName, position); }); }; /// GOTO Implementation /** @@ -169090,37 +170008,37 @@ var ts; */ LanguageServiceShimObject.prototype.getImplementationAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); + return this.forwardJSONCall("getImplementationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getImplementationAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) { var _this = this; - return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); }); + return this.forwardJSONCall("getRenameInfo('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getRenameInfo(fileName, position, preferences); }); }; LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getSmartSelectionRange('" + fileName + "', " + position + ")", function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); + return this.forwardJSONCall("getSmartSelectionRange('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSmartSelectionRange(fileName, position); }); }; LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename) { var _this = this; - return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ", " + providePrefixAndSuffixTextForRename + ")", function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); + return this.forwardJSONCall("findRenameLocations('".concat(fileName, "', ").concat(position, ", ").concat(findInStrings, ", ").concat(findInComments, ", ").concat(providePrefixAndSuffixTextForRename, ")"), function () { return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments, providePrefixAndSuffixTextForRename); }); }; /// GET BRACE MATCHING LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); + return this.forwardJSONCall("getBraceMatchingAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getBraceMatchingAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.isValidBraceCompletionAtPosition = function (fileName, position, openingBrace) { var _this = this; - return this.forwardJSONCall("isValidBraceCompletionAtPosition('" + fileName + "', " + position + ", " + openingBrace + ")", function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); + return this.forwardJSONCall("isValidBraceCompletionAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(openingBrace, ")"), function () { return _this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace); }); }; LanguageServiceShimObject.prototype.getSpanOfEnclosingComment = function (fileName, position, onlyMultiLine) { var _this = this; - return this.forwardJSONCall("getSpanOfEnclosingComment('" + fileName + "', " + position + ")", function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); + return this.forwardJSONCall("getSpanOfEnclosingComment('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getSpanOfEnclosingComment(fileName, position, onlyMultiLine); }); }; /// GET SMART INDENT LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options /*Services.EditorOptions*/) { var _this = this; - return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getIndentationAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); }); @@ -169128,23 +170046,23 @@ var ts; /// GET REFERENCES LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getReferencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getReferencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { var _this = this; - return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { return _this.languageService.findReferences(fileName, position); }); + return this.forwardJSONCall("findReferences('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.findReferences(fileName, position); }); }; LanguageServiceShimObject.prototype.getFileReferences = function (fileName) { var _this = this; - return this.forwardJSONCall("getFileReferences('" + fileName + ")", function () { return _this.languageService.getFileReferences(fileName); }); + return this.forwardJSONCall("getFileReferences('".concat(fileName, ")"), function () { return _this.languageService.getFileReferences(fileName); }); }; LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { var _this = this; - return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); + return this.forwardJSONCall("getOccurrencesAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getOccurrencesAtPosition(fileName, position); }); }; LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { var _this = this; - return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + return this.forwardJSONCall("getDocumentHighlights('".concat(fileName, "', ").concat(position, ")"), function () { var results = _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); // workaround for VS document highlighting issue - keep only items from the initial file var normalizedName = ts.toFileNameLowerCase(ts.normalizeSlashes(fileName)); @@ -169159,108 +170077,108 @@ var ts; */ LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position, preferences, formattingSettings) { var _this = this; - return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ", " + preferences + ", " + formattingSettings + ")", function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); + return this.forwardJSONCall("getCompletionsAtPosition('".concat(fileName, "', ").concat(position, ", ").concat(preferences, ", ").concat(formattingSettings, ")"), function () { return _this.languageService.getCompletionsAtPosition(fileName, position, preferences, formattingSettings); }); }; /** Get a string based representation of a completion list entry details */ LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName, formatOptions, source, preferences, data) { var _this = this; - return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", '" + entryName + "')", function () { + return this.forwardJSONCall("getCompletionEntryDetails('".concat(fileName, "', ").concat(position, ", '").concat(entryName, "')"), function () { var localOptions = formatOptions === undefined ? undefined : JSON.parse(formatOptions); return _this.languageService.getCompletionEntryDetails(fileName, position, entryName, localOptions, source, preferences, data); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + return this.forwardJSONCall("getFormattingEditsForRange('".concat(fileName, "', ").concat(start, ", ").concat(end, ")"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + return this.forwardJSONCall("getFormattingEditsForDocument('".concat(fileName, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsForDocument(fileName, localOptions); }); }; LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options /*Services.FormatCodeOptions*/) { var _this = this; - return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('".concat(fileName, "', ").concat(position, ", '").concat(key, "')"), function () { var localOptions = JSON.parse(options); return _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); }; LanguageServiceShimObject.prototype.getDocCommentTemplateAtPosition = function (fileName, position, options) { var _this = this; - return this.forwardJSONCall("getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); + return this.forwardJSONCall("getDocCommentTemplateAtPosition('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.getDocCommentTemplateAtPosition(fileName, position, options); }); }; /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount, fileName) { var _this = this; - return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ", " + fileName + ")", function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); + return this.forwardJSONCall("getNavigateToItems('".concat(searchValue, "', ").concat(maxResultCount, ", ").concat(fileName, ")"), function () { return _this.languageService.getNavigateToItems(searchValue, maxResultCount, fileName); }); }; LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { return _this.languageService.getNavigationBarItems(fileName); }); + return this.forwardJSONCall("getNavigationBarItems('".concat(fileName, "')"), function () { return _this.languageService.getNavigationBarItems(fileName); }); }; LanguageServiceShimObject.prototype.getNavigationTree = function (fileName) { var _this = this; - return this.forwardJSONCall("getNavigationTree('" + fileName + "')", function () { return _this.languageService.getNavigationTree(fileName); }); + return this.forwardJSONCall("getNavigationTree('".concat(fileName, "')"), function () { return _this.languageService.getNavigationTree(fileName); }); }; LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { var _this = this; - return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { return _this.languageService.getOutliningSpans(fileName); }); + return this.forwardJSONCall("getOutliningSpans('".concat(fileName, "')"), function () { return _this.languageService.getOutliningSpans(fileName); }); }; LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { var _this = this; - return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); + return this.forwardJSONCall("getTodoComments('".concat(fileName, "')"), function () { return _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); }); }; /// CALL HIERARCHY LanguageServiceShimObject.prototype.prepareCallHierarchy = function (fileName, position) { var _this = this; - return this.forwardJSONCall("prepareCallHierarchy('" + fileName + "', " + position + ")", function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); + return this.forwardJSONCall("prepareCallHierarchy('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.prepareCallHierarchy(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyIncomingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyIncomingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyIncomingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyIncomingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideCallHierarchyOutgoingCalls = function (fileName, position) { var _this = this; - return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('" + fileName + "', " + position + ")", function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); + return this.forwardJSONCall("provideCallHierarchyOutgoingCalls('".concat(fileName, "', ").concat(position, ")"), function () { return _this.languageService.provideCallHierarchyOutgoingCalls(fileName, position); }); }; LanguageServiceShimObject.prototype.provideInlayHints = function (fileName, span, preference) { var _this = this; - return this.forwardJSONCall("provideInlayHints('" + fileName + "', '" + JSON.stringify(span) + "', " + JSON.stringify(preference) + ")", function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); + return this.forwardJSONCall("provideInlayHints('".concat(fileName, "', '").concat(JSON.stringify(span), "', ").concat(JSON.stringify(preference), ")"), function () { return _this.languageService.provideInlayHints(fileName, span, preference); }); }; /// Emit LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + return this.forwardJSONCall("getEmitOutput('".concat(fileName, "')"), function () { var _a = _this.languageService.getEmitOutput(fileName), diagnostics = _a.diagnostics, rest = __rest(_a, ["diagnostics"]); return __assign(__assign({}, rest), { diagnostics: _this.realizeDiagnostics(diagnostics) }); }); }; LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { var _this = this; - return forwardCall(this.logger, "getEmitOutput('" + fileName + "')", + return forwardCall(this.logger, "getEmitOutput('".concat(fileName, "')"), /*returnJson*/ false, function () { return _this.languageService.getEmitOutput(fileName); }, this.logPerformance); }; LanguageServiceShimObject.prototype.toggleLineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleLineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleLineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleLineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleLineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.toggleMultilineComment = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("toggleMultilineComment('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); + return this.forwardJSONCall("toggleMultilineComment('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.toggleMultilineComment(fileName, textRange); }); }; LanguageServiceShimObject.prototype.commentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("commentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.commentSelection(fileName, textRange); }); + return this.forwardJSONCall("commentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.commentSelection(fileName, textRange); }); }; LanguageServiceShimObject.prototype.uncommentSelection = function (fileName, textRange) { var _this = this; - return this.forwardJSONCall("uncommentSelection('" + fileName + "', '" + JSON.stringify(textRange) + "')", function () { return _this.languageService.uncommentSelection(fileName, textRange); }); + return this.forwardJSONCall("uncommentSelection('".concat(fileName, "', '").concat(JSON.stringify(textRange), "')"), function () { return _this.languageService.uncommentSelection(fileName, textRange); }); }; return LanguageServiceShimObject; }(ShimBase)); @@ -169310,11 +170228,11 @@ var ts; }; CoreServicesShimObject.prototype.resolveModuleName = function (fileName, moduleName, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveModuleName('" + fileName + "')", function () { + return this.forwardJSONCall("resolveModuleName('".concat(fileName, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) { + if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Extension.Ts */ && result.resolvedModule.extension !== ".tsx" /* Extension.Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Extension.Dts */) { resolvedFileName = undefined; } return { @@ -169326,7 +170244,7 @@ var ts; }; CoreServicesShimObject.prototype.resolveTypeReferenceDirective = function (fileName, typeReferenceDirective, compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("resolveTypeReferenceDirective(" + fileName + ")", function () { + return this.forwardJSONCall("resolveTypeReferenceDirective(".concat(fileName, ")"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveTypeReferenceDirective(typeReferenceDirective, ts.normalizeSlashes(fileName), compilerOptions, _this.host); return { @@ -169338,7 +170256,7 @@ var ts; }; CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getPreProcessedFileInfo('".concat(fileName, "')"), function () { // for now treat files as JavaScript var result = ts.preProcessFile(ts.getSnapshotText(sourceTextSnapshot), /* readImportFiles */ true, /* detectJavaScriptImports */ true); return { @@ -169353,7 +170271,7 @@ var ts; }; CoreServicesShimObject.prototype.getAutomaticTypeDirectiveNames = function (compilerOptionsJson) { var _this = this; - return this.forwardJSONCall("getAutomaticTypeDirectiveNames('" + compilerOptionsJson + "')", function () { + return this.forwardJSONCall("getAutomaticTypeDirectiveNames('".concat(compilerOptionsJson, "')"), function () { var compilerOptions = JSON.parse(compilerOptionsJson); return ts.getAutomaticTypeDirectiveNames(compilerOptions, _this.host); }); @@ -169375,7 +170293,7 @@ var ts; }; CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { var _this = this; - return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + return this.forwardJSONCall("getTSConfigFileInfo('".concat(fileName, "')"), function () { var result = ts.parseJsonText(fileName, ts.getSnapshotText(sourceTextSnapshot)); var normalizedFileName = ts.normalizeSlashes(fileName); var configFile = ts.parseJsonSourceFileConfigFileContent(result, _this.host, ts.getDirectoryPath(normalizedFileName), /*existingOptions*/ {}, normalizedFileName); @@ -169541,7 +170459,7 @@ var ts; for (var _i = 0, _a = Object.keys(deprecations); _i < _a.length; _i++) { var key = _a[_i]; var index = +key; - if (!isNaN(index) && ts.hasProperty(overloads, "" + index)) { + if (!isNaN(index) && ts.hasProperty(overloads, "".concat(index))) { overloads[index] = ts.Debug.deprecate(overloads[index], __assign(__assign({}, deprecations[index]), { name: name })); } } @@ -169564,7 +170482,7 @@ var ts; ts.createOverload = createOverload; function createBinder(overloads, binder) { return function (args) { - for (var i = 0; ts.hasProperty(overloads, "" + i) && ts.hasProperty(binder, "" + i); i++) { + for (var i = 0; ts.hasProperty(overloads, "".concat(i)) && ts.hasProperty(binder, "".concat(i)); i++) { var fn = binder[i]; if (fn(args)) { return i; @@ -170215,11 +171133,11 @@ var ts; }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic)` or the factory supplied by your transformation context instead. */ ts.createOptimisticUniqueName = ts.Debug.deprecate(function createOptimisticUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */); }, factoryDeprecation); /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel)` or the factory supplied by your transformation context instead. */ ts.createFileLevelUniqueName = ts.Debug.deprecate(function createFileLevelUniqueName(text) { - return ts.factory.createUniqueName(text, 16 /* Optimistic */ | 32 /* FileLevel */); + return ts.factory.createUniqueName(text, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); }, factoryDeprecation); /** @deprecated Use `factory.createIndexSignature` or the factory supplied by your transformation context instead. */ ts.createIndexSignature = ts.Debug.deprecate(function createIndexSignature(decorators, modifiers, parameters, type) { @@ -170266,7 +171184,7 @@ var ts; } else { type = operatorOrType; - operator = 140 /* KeyOfKeyword */; + operator = 140 /* SyntaxKind.KeyOfKeyword */; } return ts.factory.createTypeOperatorNode(operator, type); }, factoryDeprecation); @@ -170303,7 +171221,7 @@ var ts; /** @deprecated Use `factory.createConditional` or the factory supplied by your transformation context instead. */ ts.createConditional = ts.Debug.deprecate(function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { return arguments.length === 5 ? ts.factory.createConditionalExpression(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) : - arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* ColonToken */), whenTrueOrWhenFalse) : + arguments.length === 3 ? ts.factory.createConditionalExpression(condition, ts.factory.createToken(57 /* SyntaxKind.QuestionToken */), questionTokenOrWhenTrue, ts.factory.createToken(58 /* SyntaxKind.ColonToken */), whenTrueOrWhenFalse) : ts.Debug.fail("Argument count mismatch"); }, factoryDeprecation); /** @deprecated Use `factory.createYield` or the factory supplied by your transformation context instead. */ @@ -170444,9 +171362,9 @@ var ts; ts.createNode = ts.Debug.deprecate(function createNode(kind, pos, end) { if (pos === void 0) { pos = 0; } if (end === void 0) { end = 0; } - return ts.setTextRangePosEnd(kind === 305 /* SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === 79 /* Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === 80 /* PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + return ts.setTextRangePosEnd(kind === 305 /* SyntaxKind.SourceFile */ ? ts.parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === 79 /* SyntaxKind.Identifier */ ? ts.parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === 80 /* SyntaxKind.PrivateIdentifier */ ? ts.parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : !ts.isNodeKind(kind) ? ts.parseBaseNodeFactory.createBaseTokenNode(kind) : ts.parseBaseNodeFactory.createBaseNode(kind), pos, end); }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." }); @@ -170474,7 +171392,7 @@ var ts; (function (ts) { /** @deprecated Use `isTypeAssertionExpression` instead. */ ts.isTypeAssertion = ts.Debug.deprecate(function isTypeAssertion(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; }, { since: "4.0", warnAfter: "4.1", diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 9dd046a4098fc..881dba5f44635 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -22,7 +22,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { ar[i] = from[i]; } } - return to.concat(ar || from); + return to.concat(ar || Array.prototype.slice.call(from)); }; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { @@ -89,7 +89,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = ts.versionMajorMinor + ".0-beta"; + ts.version = "4.8.1-rc"; /* @internal */ var Comparison; (function (Comparison) { @@ -136,7 +136,7 @@ var ts; var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); if (constructor) return constructor; - throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation."); + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); } })(ts || (ts = {})); /* @internal */ @@ -836,9 +836,9 @@ var ts; case true: // relational comparison // falls through - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: continue; - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If `array` is sorted, `next` should **never** be less than `last`. return ts.Debug.fail("Array is unsorted."); } @@ -874,7 +874,7 @@ var ts; var prevElement = array[0]; for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) { var element = _a[_i]; - if (comparer(prevElement, element) === 1 /* GreaterThan */) { + if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) { return false; } prevElement = element; @@ -928,27 +928,27 @@ var ts; loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) { if (offsetB > 0) { // Ensure `arrayB` is properly sorted. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */); } loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) { if (offsetA > startA) { // Ensure `arrayA` is properly sorted. We only need to perform this check if // `offsetA` has changed since we entered the loop. - ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */); + ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */); } switch (comparer(arrayB[offsetB], arrayA[offsetA])) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If B is less than A, B does not exist in arrayA. Add B to the result and // move to the next element in arrayB without changing the current position // in arrayA. result.push(arrayB[offsetB]); continue loopB; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: // If B is equal to A, B exists in arrayA. Move to the next element in // arrayB without adding B to the result or changing the current position // in arrayA. continue loopB; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: // If B is greater than A, we need to keep looking for B in arrayA. Move to // the next element in arrayA and recheck. continue loopA; @@ -1188,12 +1188,12 @@ var ts; var middle = low + ((high - low) >> 1); var midKey = keySelector(array[middle], middle); switch (keyComparer(midKey, key)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: low = middle + 1; break; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: return middle; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: high = middle - 1; break; } @@ -1465,6 +1465,43 @@ var ts; return createMultiMap(); } ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap; + function createQueue(items) { + var elements = (items === null || items === void 0 ? void 0 : items.slice()) || []; + var headIndex = 0; + function isEmpty() { + return headIndex === elements.length; + } + function enqueue() { + var items = []; + for (var _i = 0; _i < arguments.length; _i++) { + items[_i] = arguments[_i]; + } + elements.push.apply(elements, items); + } + function dequeue() { + if (isEmpty()) { + throw new Error("Queue is empty"); + } + var result = elements[headIndex]; + elements[headIndex] = undefined; // Don't keep referencing dequeued item + headIndex++; + // If more than half of the queue is empty, copy the remaining elements to the + // front and shrink the array (unless we'd be saving fewer than 100 slots) + if (headIndex > 100 && headIndex > (elements.length >> 1)) { + var newLength = elements.length - headIndex; + elements.copyWithin(/*target*/ 0, /*start*/ headIndex); + elements.length = newLength; + headIndex = 0; + } + return result; + } + return { + enqueue: enqueue, + dequeue: dequeue, + isEmpty: isEmpty, + }; + } + ts.createQueue = createQueue; /** * Creates a Set with custom equality and hash code functionality. This is useful when you * want to use something looser than object identity - e.g. "has the same span". @@ -1647,12 +1684,16 @@ var ts; function cast(value, test) { if (value !== undefined && test(value)) return value; - return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'."); + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); } ts.cast = cast; /** Does nothing. */ function noop(_) { } ts.noop = noop; + ts.noopPush = { + push: noop, + length: 0 + }; /** Do nothing and return false */ function returnFalse() { return false; @@ -1738,7 +1779,7 @@ var ts; function memoizeOne(callback) { var map = new ts.Map(); return function (arg) { - var key = typeof arg + ":" + arg; + var key = "".concat(typeof arg, ":").concat(arg); var value = map.get(key); if (value === undefined && !map.has(key)) { value = callback(arg); @@ -1810,11 +1851,11 @@ var ts; } ts.equateStringsCaseSensitive = equateStringsCaseSensitive; function compareComparableValues(a, b) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : - a < b ? -1 /* LessThan */ : - 1 /* GreaterThan */; + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + a < b ? -1 /* Comparison.LessThan */ : + 1 /* Comparison.GreaterThan */; } /** * Compare two numeric values for their order relative to each other. @@ -1832,7 +1873,7 @@ var ts; } ts.compareTextSpans = compareTextSpans; function min(a, b, compare) { - return compare(a, b) === -1 /* LessThan */ ? a : b; + return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b; } ts.min = min; /** @@ -1849,14 +1890,14 @@ var ts; */ function compareStringsCaseInsensitive(a, b) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; a = a.toUpperCase(); b = b.toUpperCase(); - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive; /** @@ -1887,13 +1928,13 @@ var ts; return createStringComparer; function compareWithCallback(a, b, comparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; var value = comparer(a, b); - return value < 0 ? -1 /* LessThan */ : value > 0 ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } function createIntlCollatorStringComparer(locale) { // Intl.Collator.prototype.compare is bound to the collator. See NOTE in @@ -1923,7 +1964,7 @@ var ts; return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b); } function compareStrings(a, b) { - return a < b ? -1 /* LessThan */ : a > b ? 1 /* GreaterThan */ : 0 /* EqualTo */; + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; } } function getStringComparerFactory() { @@ -1984,9 +2025,9 @@ var ts; } ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI; function compareProperties(a, b, key, comparer) { - return a === b ? 0 /* EqualTo */ : - a === undefined ? -1 /* LessThan */ : - b === undefined ? 1 /* GreaterThan */ : + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : comparer(a[key], b[key]); } ts.compareProperties = compareProperties; @@ -2008,7 +2049,7 @@ var ts; * and 1 insertion/deletion at 3 characters) */ function getSpellingSuggestion(name, candidates, getName) { - var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34)); + var maximumLengthDifference = Math.max(2, Math.floor(name.length * 0.34)); var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother. var bestCandidate; for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { @@ -2105,24 +2146,24 @@ var ts; var end = fileName.length; for (var pos = end - 1; pos > 0; pos--) { var ch = fileName.charCodeAt(pos); - if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { + if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) { // Match a \d+ segment do { --pos; ch = fileName.charCodeAt(pos); - } while (pos > 0 && ch >= 48 /* _0 */ && ch <= 57 /* _9 */); + } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */); } - else if (pos > 4 && (ch === 110 /* n */ || ch === 78 /* N */)) { + else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) { // Looking for "min" or "min" // Already matched the 'n' --pos; ch = fileName.charCodeAt(pos); - if (ch !== 105 /* i */ && ch !== 73 /* I */) { + if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) { break; } --pos; ch = fileName.charCodeAt(pos); - if (ch !== 109 /* m */ && ch !== 77 /* M */) { + if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) { break; } --pos; @@ -2132,7 +2173,7 @@ var ts; // This character is not part of either suffix pattern break; } - if (ch !== 45 /* minus */ && ch !== 46 /* dot */) { + if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) { break; } end = pos; @@ -2188,7 +2229,7 @@ var ts; ts.createGetCanonicalFileName = createGetCanonicalFileName; function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; - return prefix + "*" + suffix; + return "".concat(prefix, "*").concat(suffix); } ts.patternText = patternText; /** @@ -2289,12 +2330,12 @@ var ts; var newItem = newItems[newIndex]; var oldItem = oldItems[oldIndex]; var compareResult = comparer(newItem, oldItem); - if (compareResult === -1 /* LessThan */) { + if (compareResult === -1 /* Comparison.LessThan */) { inserted(newItem); newIndex++; hasChanges = true; } - else if (compareResult === 1 /* GreaterThan */) { + else if (compareResult === 1 /* Comparison.GreaterThan */) { deleted(oldItem); oldIndex++; hasChanges = true; @@ -2425,7 +2466,7 @@ var ts; (function (Debug) { var typeScriptVersion; /* eslint-disable prefer-const */ - var currentAssertionLevel = 0 /* None */; + var currentAssertionLevel = 0 /* AssertionLevel.None */; Debug.currentLogLevel = LogLevel.Warning; Debug.isDebugging = false; function getTypeScriptVersion() { @@ -2504,7 +2545,7 @@ var ts; } function fail(message, stackCrawlMark) { debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); if (Error.captureStackTrace) { Error.captureStackTrace(e, stackCrawlMark || fail); } @@ -2512,12 +2553,12 @@ var ts; } Debug.fail = fail; function failBadSyntaxKind(node, message, stackCrawlMark) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); } Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { - message = message ? "False expression: " + message : "False expression."; + message = message ? "False expression: ".concat(message) : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } @@ -2527,26 +2568,26 @@ var ts; Debug.assert = assert; function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { - var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; @@ -2577,42 +2618,42 @@ var ts; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); - return fail(message + " " + detail, stackCrawlMark || assertNever); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); } Debug.assertNever = assertNever; function assertEachNode(nodes, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) { - assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); } } Debug.assertEachNode = assertEachNode; function assertNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNode")) { - assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); } } Debug.assertNode = assertNode; function assertNotNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) { - assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); } } Debug.assertNotNode = assertNotNode; function assertOptionalNode(node, test, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { - assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); } } Debug.assertOptionalNode = assertOptionalNode; function assertOptionalToken(node, kind, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { - assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); } } Debug.assertOptionalToken = assertOptionalToken; function assertMissingNode(node, message, stackCrawlMark) { - if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) { - assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); } } Debug.assertMissingNode = assertMissingNode; @@ -2633,7 +2674,7 @@ var ts; } Debug.getFunctionName = getFunctionName; function formatSymbol(symbol) { - return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }"; + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); } Debug.formatSymbol = formatSymbol; /** @@ -2737,6 +2778,22 @@ var ts; return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true); } Debug.formatFlowFlags = formatFlowFlags; + function formatRelationComparisonResult(result) { + return formatEnum(result, ts.RelationComparisonResult, /*isFlags*/ true); + } + Debug.formatRelationComparisonResult = formatRelationComparisonResult; + function formatCheckMode(mode) { + return formatEnum(mode, ts.CheckMode, /*isFlags*/ true); + } + Debug.formatCheckMode = formatCheckMode; + function formatSignatureCheckMode(mode) { + return formatEnum(mode, ts.SignatureCheckMode, /*isFlags*/ true); + } + Debug.formatSignatureCheckMode = formatSignatureCheckMode; + function formatTypeFacts(facts) { + return formatEnum(facts, ts.TypeFacts, /*isFlags*/ true); + } + Debug.formatTypeFacts = formatTypeFacts; var isDebugInfoEnabled = false; var extendedDebugModule; function extendedDebug() { @@ -2761,20 +2818,20 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var flowHeader = this.flags & 2 /* Start */ ? "FlowStart" : - this.flags & 4 /* BranchLabel */ ? "FlowBranchLabel" : - this.flags & 8 /* LoopLabel */ ? "FlowLoopLabel" : - this.flags & 16 /* Assignment */ ? "FlowAssignment" : - this.flags & 32 /* TrueCondition */ ? "FlowTrueCondition" : - this.flags & 64 /* FalseCondition */ ? "FlowFalseCondition" : - this.flags & 128 /* SwitchClause */ ? "FlowSwitchClause" : - this.flags & 256 /* ArrayMutation */ ? "FlowArrayMutation" : - this.flags & 512 /* Call */ ? "FlowCall" : - this.flags & 1024 /* ReduceLabel */ ? "FlowReduceLabel" : - this.flags & 1 /* Unreachable */ ? "FlowUnreachable" : + var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" : + this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" : + this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" : + this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" : "UnknownFlow"; - var remainingFlags = this.flags & ~(2048 /* Referenced */ - 1); - return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : ""); + var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); } }, __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, @@ -2813,7 +2870,7 @@ var ts; // We don't care, this is debug code that's only enabled with a debugger attached - // we're just taking note of it for anyone checking regex performance in the future. defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); - return "NodeArray " + defaultValue; + return "NodeArray ".concat(defaultValue); } } }); @@ -2865,10 +2922,10 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var symbolHeader = this.flags & 33554432 /* Transient */ ? "TransientSymbol" : + var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" : "Symbol"; - var remainingSymbolFlags = this.flags & ~33554432 /* Transient */; - return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : ""); + var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */; + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } @@ -2877,35 +2934,35 @@ var ts; // for use with vscode-js-debug's new customDescriptionGenerator in launch.json __tsDebuggerDisplay: { value: function () { - var typeHeader = this.flags & 98304 /* Nullable */ ? "NullableType" : - this.flags & 384 /* StringOrNumberLiteral */ ? "LiteralType " + JSON.stringify(this.value) : - this.flags & 2048 /* BigIntLiteral */ ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" : - this.flags & 8192 /* UniqueESSymbol */ ? "UniqueESSymbolType" : - this.flags & 32 /* Enum */ ? "EnumType" : - this.flags & 67359327 /* Intrinsic */ ? "IntrinsicType " + this.intrinsicName : - this.flags & 1048576 /* Union */ ? "UnionType" : - this.flags & 2097152 /* Intersection */ ? "IntersectionType" : - this.flags & 4194304 /* Index */ ? "IndexType" : - this.flags & 8388608 /* IndexedAccess */ ? "IndexedAccessType" : - this.flags & 16777216 /* Conditional */ ? "ConditionalType" : - this.flags & 33554432 /* Substitution */ ? "SubstitutionType" : - this.flags & 262144 /* TypeParameter */ ? "TypeParameter" : - this.flags & 524288 /* Object */ ? - this.objectFlags & 3 /* ClassOrInterface */ ? "InterfaceType" : - this.objectFlags & 4 /* Reference */ ? "TypeReference" : - this.objectFlags & 8 /* Tuple */ ? "TupleType" : - this.objectFlags & 16 /* Anonymous */ ? "AnonymousType" : - this.objectFlags & 32 /* Mapped */ ? "MappedType" : - this.objectFlags & 1024 /* ReverseMapped */ ? "ReverseMappedType" : - this.objectFlags & 256 /* EvolvingArray */ ? "EvolvingArrayType" : + var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" : + this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : + this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" : + this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) : + this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" : + this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" : + this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* TypeFlags.Object */ ? + this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" : + this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" : + this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" : + this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" : "ObjectType" : "Type"; - var remainingObjectFlags = this.flags & 524288 /* Object */ ? this.objectFlags & ~1343 /* ObjectTypeKindMask */ : 0; - return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : ""); + var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0; + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); } }, __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, - __debugObjectFlags: { get: function () { return this.flags & 524288 /* Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, __debugTypeToString: { value: function () { // avoid recomputing @@ -2937,11 +2994,11 @@ var ts; __tsDebuggerDisplay: { value: function () { var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : - ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" : - ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" : - ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") : - ts.isNumericLiteral(this) ? "NumericLiteral " + this.text : - ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : ts.isParameter(this) ? "ParameterDeclaration" : ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : @@ -2973,7 +3030,7 @@ var ts; ts.isNamedTupleMember(this) ? "NamedTupleMember" : ts.isImportTypeNode(this) ? "ImportTypeNode" : formatSyntaxKind(this.kind); - return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : ""); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); } }, __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, @@ -3020,10 +3077,10 @@ var ts; Debug.enableDebugInfo = enableDebugInfo; function formatDeprecationMessage(name, error, errorAfter, since, message) { var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; - deprecationMessage += "'" + name + "' "; - deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated"; - deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : "."; - deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : ""; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; return deprecationMessage; } function createErrorDeprecation(name, errorAfter, since, message) { @@ -3067,6 +3124,48 @@ var ts; return wrapFunction(deprecation, func); } Debug.deprecate = deprecate; + function formatVariance(varianceFlags) { + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; + var result = variance === 0 /* VarianceFlags.Invariant */ ? "in out" : + variance === 3 /* VarianceFlags.Bivariant */ ? "[bivariant]" : + variance === 2 /* VarianceFlags.Contravariant */ ? "in" : + variance === 1 /* VarianceFlags.Covariant */ ? "out" : + variance === 4 /* VarianceFlags.Independent */ ? "[independent]" : ""; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { + result += " (unmeasurable)"; + } + else if (varianceFlags & 16 /* VarianceFlags.Unreliable */) { + result += " (unreliable)"; + } + return result; + } + Debug.formatVariance = formatVariance; + var DebugTypeMapper = /** @class */ (function () { + function DebugTypeMapper() { + } + DebugTypeMapper.prototype.__debugToString = function () { + var _a; + type(this); + switch (this.kind) { + case 3 /* TypeMapKind.Function */: return ((_a = this.debugInfo) === null || _a === void 0 ? void 0 : _a.call(this)) || "(function mapper)"; + case 0 /* TypeMapKind.Simple */: return "".concat(this.source.__debugTypeToString(), " -> ").concat(this.target.__debugTypeToString()); + case 1 /* TypeMapKind.Array */: return ts.zipWith(this.sources, this.targets || ts.map(this.sources, function () { return "any"; }), function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(typeof t === "string" ? t : t.__debugTypeToString()); }).join(", "); + case 2 /* TypeMapKind.Deferred */: return ts.zipWith(this.sources, this.targets, function (s, t) { return "".concat(s.__debugTypeToString(), " -> ").concat(t().__debugTypeToString()); }).join(", "); + case 5 /* TypeMapKind.Merged */: + case 4 /* TypeMapKind.Composite */: return "m1: ".concat(this.mapper1.__debugToString().split("\n").join("\n "), "\nm2: ").concat(this.mapper2.__debugToString().split("\n").join("\n ")); + default: return assertNever(this); + } + }; + return DebugTypeMapper; + }()); + Debug.DebugTypeMapper = DebugTypeMapper; + function attachDebugPrototypeIfDebug(mapper) { + if (Debug.isDebugging) { + return Object.setPrototypeOf(mapper, DebugTypeMapper.prototype); + } + return mapper; + } + Debug.attachDebugPrototypeIfDebug = attachDebugPrototypeIfDebug; })(Debug = ts.Debug || (ts.Debug = {})); })(ts || (ts = {})); /* @internal */ @@ -3139,9 +3238,9 @@ var ts; // https://semver.org/#spec-item-11 // > Build metadata does not figure into precedence if (this === other) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (other === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; return ts.compareValues(this.major, other.major) || ts.compareValues(this.minor, other.minor) || ts.compareValues(this.patch, other.patch) @@ -3156,11 +3255,11 @@ var ts; } }; Version.prototype.toString = function () { - var result = this.major + "." + this.minor + "." + this.patch; + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); if (ts.some(this.prerelease)) - result += "-" + this.prerelease.join("."); + result += "-".concat(this.prerelease.join(".")); if (ts.some(this.build)) - result += "+" + this.build.join("."); + result += "+".concat(this.build.join(".")); return result; }; Version.zero = new Version(0, 0, 0); @@ -3189,11 +3288,11 @@ var ts; // > When major, minor, and patch are equal, a pre-release version has lower precedence // > than a normal version. if (left === right) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (left.length === 0) - return right.length === 0 ? 0 /* EqualTo */ : 1 /* GreaterThan */; + return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */; if (right.length === 0) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; // https://semver.org/#spec-item-11 // > Precedence for two pre-release versions with the same major, minor, and patch version // > MUST be determined by comparing each dot separated identifier from left to right until @@ -3210,7 +3309,7 @@ var ts; // https://semver.org/#spec-item-11 // > Numeric identifiers always have lower precedence than non-numeric identifiers. if (leftIsNumeric !== rightIsNumeric) - return leftIsNumeric ? -1 /* LessThan */ : 1 /* GreaterThan */; + return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; // https://semver.org/#spec-item-11 // > identifiers consisting of only digits are compared numerically var result = ts.compareValues(+leftIdentifier, +rightIdentifier); @@ -3427,7 +3526,7 @@ var ts; return ts.map(comparators, formatComparator).join(" "); } function formatComparator(comparator) { - return "" + comparator.operator + comparator.operand; + return "".concat(comparator.operator).concat(comparator.operand); } })(ts || (ts = {})); /*@internal*/ @@ -3725,7 +3824,7 @@ var ts; fs = require("fs"); } catch (e) { - throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")"); + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); } } mode = tracingMode; @@ -3737,11 +3836,11 @@ var ts; if (!fs.existsSync(traceDir)) { fs.mkdirSync(traceDir, { recursive: true }); } - var countPart = mode === "build" ? "." + process.pid + "-" + ++traceCount - : mode === "server" ? "." + process.pid + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) : ""; - var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json"); - var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json"); + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); legend.push({ configFilePath: configFilePath, tracePath: tracePath, @@ -3808,9 +3907,9 @@ var ts; eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); } tracingEnabled.push = push; - function pop() { + function pop(results) { ts.Debug.assert(eventStack.length > 0); - writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); + writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results); eventStack.length--; } tracingEnabled.pop = pop; @@ -3824,27 +3923,28 @@ var ts; tracingEnabled.popAll = popAll; // sample every 10ms var sampleInterval = 1000 * 10; - function writeStackEvent(index, endTime) { + function writeStackEvent(index, endTime, results) { var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; if (separateBeginAndEnd) { + ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`"); writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); } // test if [time,endTime) straddles a sampling point else if (sampleInterval - (time % sampleInterval) <= endTime - time) { - writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time); + writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":".concat(endTime - time), time); } } function writeEvent(eventType, phase, name, args, extras, time) { if (time === void 0) { time = 1000 * ts.timestamp(); } // In server mode, there's no easy way to dump type information, so we drop events that would require it. - if (mode === "server" && phase === "checkTypes" /* CheckTypes */) + if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */) return; ts.performance.mark("beginTracing"); - fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\""); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); if (extras) - fs.writeSync(traceFd, "," + extras); + fs.writeSync(traceFd, ",".concat(extras)); if (args) - fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args)); + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); fs.writeSync(traceFd, "}"); ts.performance.mark("endTracing"); ts.performance.measure("Tracing", "beginTracing", "endTracing"); @@ -3880,7 +3980,7 @@ var ts; var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) var display = void 0; - if ((objectFlags & 16 /* Anonymous */) | (type.flags & 2944 /* Literal */)) { + if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) { try { display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); } @@ -3889,7 +3989,7 @@ var ts; } } var indexedAccessProperties = {}; - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexedAccessType = type; indexedAccessProperties = { indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, @@ -3897,7 +3997,7 @@ var ts; }; } var referenceProperties = {}; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { var referenceType = type; referenceProperties = { instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, @@ -3906,7 +4006,7 @@ var ts; }; } var conditionalProperties = {}; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var conditionalType = type; conditionalProperties = { conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, @@ -3916,7 +4016,7 @@ var ts; }; } var substitutionProperties = {}; - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { var substitutionType = type; substitutionProperties = { substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, @@ -3924,7 +4024,7 @@ var ts; }; } var reverseMappedProperties = {}; - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { var reverseMappedType = type; reverseMappedProperties = { reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, @@ -3933,7 +4033,7 @@ var ts; }; } var evolvingArrayProperties = {}; - if (objectFlags & 256 /* EvolvingArray */) { + if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) { var evolvingArrayType = type; evolvingArrayProperties = { evolvingArrayElementType: evolvingArrayType.elementType.id, @@ -3951,7 +4051,7 @@ var ts; recursionIdentityMap.set(recursionIdentity, recursionToken); } } - var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + var descriptor = __assign(__assign(__assign(__assign(__assign(__assign(__assign({ id: type.id, intrinsicName: type.intrinsicName, symbolName: (symbol === null || symbol === void 0 ? void 0 : symbol.escapedName) && ts.unescapeLeadingUnderscores(symbol.escapedName), recursionId: recursionToken, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); fs.writeSync(typesFd, JSON.stringify(descriptor)); if (i < numTypes - 1) { fs.writeSync(typesFd, ",\n"); @@ -4672,6 +4772,7 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + NodeBuilderFlags[NodeBuilderFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; @@ -4712,6 +4813,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + TypeFormatFlags[TypeFormatFlags["OmitThisParameter"] = 33554432] = "OmitThisParameter"; // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -4723,7 +4825,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; /** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 814775659] = "NodeBuilderFlagsMask"; + TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 848330091] = "NodeBuilderFlagsMask"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -5202,9 +5304,10 @@ var ts; (function (TypeMapKind) { TypeMapKind[TypeMapKind["Simple"] = 0] = "Simple"; TypeMapKind[TypeMapKind["Array"] = 1] = "Array"; - TypeMapKind[TypeMapKind["Function"] = 2] = "Function"; - TypeMapKind[TypeMapKind["Composite"] = 3] = "Composite"; - TypeMapKind[TypeMapKind["Merged"] = 4] = "Merged"; + TypeMapKind[TypeMapKind["Deferred"] = 2] = "Deferred"; + TypeMapKind[TypeMapKind["Function"] = 3] = "Function"; + TypeMapKind[TypeMapKind["Composite"] = 4] = "Composite"; + TypeMapKind[TypeMapKind["Merged"] = 5] = "Merged"; })(TypeMapKind = ts.TypeMapKind || (ts.TypeMapKind = {})); var InferencePriority; (function (InferencePriority) { @@ -5599,10 +5702,8 @@ var ts; TransformFlags[TransformFlags["ContainsPossibleTopLevelAwait"] = 67108864] = "ContainsPossibleTopLevelAwait"; TransformFlags[TransformFlags["ContainsLexicalSuper"] = 134217728] = "ContainsLexicalSuper"; TransformFlags[TransformFlags["ContainsUpdateExpressionForIdentifier"] = 268435456] = "ContainsUpdateExpressionForIdentifier"; - // Please leave this as 1 << 29. - // It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system. - // It is a good reminder of how much room we have left - TransformFlags[TransformFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + TransformFlags[TransformFlags["ContainsPrivateIdentifierInExpression"] = 536870912] = "ContainsPrivateIdentifierInExpression"; + TransformFlags[TransformFlags["HasComputedFlags"] = -2147483648] = "HasComputedFlags"; // Assertions // - Bitmasks that are used to assert facts about the syntax of a node and its subtree. TransformFlags[TransformFlags["AssertTypeScript"] = 1] = "AssertTypeScript"; @@ -5621,23 +5722,23 @@ var ts; // Scope Exclusions // - Bitmasks that exclude flags from propagating out of a specific context // into the subtree flags of their container. - TransformFlags[TransformFlags["OuterExpressionExcludes"] = 536870912] = "OuterExpressionExcludes"; - TransformFlags[TransformFlags["PropertyAccessExcludes"] = 536870912] = "PropertyAccessExcludes"; - TransformFlags[TransformFlags["NodeExcludes"] = 536870912] = "NodeExcludes"; - TransformFlags[TransformFlags["ArrowFunctionExcludes"] = 612179968] = "ArrowFunctionExcludes"; - TransformFlags[TransformFlags["FunctionExcludes"] = 746414080] = "FunctionExcludes"; - TransformFlags[TransformFlags["ConstructorExcludes"] = 746405888] = "ConstructorExcludes"; - TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = 679297024] = "MethodOrAccessorExcludes"; - TransformFlags[TransformFlags["PropertyExcludes"] = 671105024] = "PropertyExcludes"; - TransformFlags[TransformFlags["ClassExcludes"] = 537010176] = "ClassExcludes"; - TransformFlags[TransformFlags["ModuleExcludes"] = 742678528] = "ModuleExcludes"; + TransformFlags[TransformFlags["OuterExpressionExcludes"] = -2147483648] = "OuterExpressionExcludes"; + TransformFlags[TransformFlags["PropertyAccessExcludes"] = -2147483648] = "PropertyAccessExcludes"; + TransformFlags[TransformFlags["NodeExcludes"] = -2147483648] = "NodeExcludes"; + TransformFlags[TransformFlags["ArrowFunctionExcludes"] = -2072174592] = "ArrowFunctionExcludes"; + TransformFlags[TransformFlags["FunctionExcludes"] = -1937940480] = "FunctionExcludes"; + TransformFlags[TransformFlags["ConstructorExcludes"] = -1937948672] = "ConstructorExcludes"; + TransformFlags[TransformFlags["MethodOrAccessorExcludes"] = -2005057536] = "MethodOrAccessorExcludes"; + TransformFlags[TransformFlags["PropertyExcludes"] = -2013249536] = "PropertyExcludes"; + TransformFlags[TransformFlags["ClassExcludes"] = -2147344384] = "ClassExcludes"; + TransformFlags[TransformFlags["ModuleExcludes"] = -1941676032] = "ModuleExcludes"; TransformFlags[TransformFlags["TypeExcludes"] = -2] = "TypeExcludes"; - TransformFlags[TransformFlags["ObjectLiteralExcludes"] = 537075712] = "ObjectLiteralExcludes"; - TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = 536903680] = "ArrayLiteralOrCallOrNewExcludes"; - TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = 537460736] = "VariableDeclarationListExcludes"; - TransformFlags[TransformFlags["ParameterExcludes"] = 536870912] = "ParameterExcludes"; - TransformFlags[TransformFlags["CatchClauseExcludes"] = 536936448] = "CatchClauseExcludes"; - TransformFlags[TransformFlags["BindingPatternExcludes"] = 536903680] = "BindingPatternExcludes"; + TransformFlags[TransformFlags["ObjectLiteralExcludes"] = -2147278848] = "ObjectLiteralExcludes"; + TransformFlags[TransformFlags["ArrayLiteralOrCallOrNewExcludes"] = -2147450880] = "ArrayLiteralOrCallOrNewExcludes"; + TransformFlags[TransformFlags["VariableDeclarationListExcludes"] = -2146893824] = "VariableDeclarationListExcludes"; + TransformFlags[TransformFlags["ParameterExcludes"] = -2147483648] = "ParameterExcludes"; + TransformFlags[TransformFlags["CatchClauseExcludes"] = -2147418112] = "CatchClauseExcludes"; + TransformFlags[TransformFlags["BindingPatternExcludes"] = -2147450880] = "BindingPatternExcludes"; TransformFlags[TransformFlags["ContainsLexicalThisOrSuper"] = 134234112] = "ContainsLexicalThisOrSuper"; // Propagating flags // - Bitmasks for flags that should propagate from a child @@ -5890,37 +5991,37 @@ var ts; { name: "no-default-lib", optional: true }, { name: "resolution-mode", optional: true } ], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-dependency": { args: [{ name: "path" }, { name: "name", optional: true }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "amd-module": { args: [{ name: "name" }], - kind: 1 /* TripleSlashXML */ + kind: 1 /* PragmaKindFlags.TripleSlashXML */ }, "ts-check": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "ts-nocheck": { - kind: 2 /* SingleLine */ + kind: 2 /* PragmaKindFlags.SingleLine */ }, "jsx": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxfrag": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsximportsource": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, "jsxruntime": { args: [{ name: "factory" }], - kind: 4 /* MultiLine */ + kind: 4 /* PragmaKindFlags.MultiLine */ }, }; })(ts || (ts = {})); @@ -5992,7 +6093,7 @@ var ts; pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize; ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds; function getLevel(envVar, level) { - return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase()); + return system.getEnvironmentVariable("".concat(envVar, "_").concat(level.toUpperCase())); } function getCustomLevels(baseVariable) { var customLevels; @@ -6209,7 +6310,7 @@ var ts; }; } function createDirectoryWatcher(dirName, dirPath, fallbackOptions) { - var watcher = fsWatch(dirName, 1 /* Directory */, function (_eventName, relativeFileName, modifiedTime) { + var watcher = fsWatch(dirName, 1 /* FileSystemEntryKind.Directory */, function (_eventName, relativeFileName, modifiedTime) { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" if (!ts.isString(relativeFileName)) return; @@ -6437,7 +6538,7 @@ var ts; function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) { // Iterate through existing children and update the watches if needed var parentWatcher = cache.get(dirPath); - if (parentWatcher && fileSystemEntryExists(dirName, 1 /* Directory */)) { + if (parentWatcher && fileSystemEntryExists(dirName, 1 /* FileSystemEntryKind.Directory */)) { // Schedule the update and postpone invoke for callbacks scheduleUpdateChildWatches(dirName, dirPath, fileName, options); return; @@ -6462,7 +6563,7 @@ var ts; } function onTimerToUpdateChildWatches() { timerToUpdateChildWatches = undefined; - sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: onTimerToUpdateChildWatches:: ".concat(cacheToUpdateChildWatches.size)); var start = ts.timestamp(); var invokeMap = new ts.Map(); while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) { @@ -6475,7 +6576,7 @@ var ts; var hasChanges = updateChildWatches(dirName, dirPath, options); invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames); } - sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size); + sysLog("sysLog:: invokingWatchers:: Elapsed:: ".concat(ts.timestamp() - start, "ms:: ").concat(cacheToUpdateChildWatches.size)); callbackCache.forEach(function (callbacks, rootDirName) { var existing = invokeMap.get(rootDirName); if (existing) { @@ -6491,7 +6592,7 @@ var ts; } }); var elapsed = ts.timestamp() - start; - sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches); + sysLog("sysLog:: Elapsed:: ".concat(elapsed, "ms:: onTimerToUpdateChildWatches:: ").concat(cacheToUpdateChildWatches.size, " ").concat(timerToUpdateChildWatches)); } function removeChildWatches(parentWatcher) { if (!parentWatcher) @@ -6510,11 +6611,11 @@ var ts; if (!parentWatcher) return false; var newChildWatches; - var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) { + var hasChanges = ts.enumerateInsertsAndDeletes(fileSystemEntryExists(parentDir, 1 /* FileSystemEntryKind.Directory */) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) { var childFullName = ts.getNormalizedAbsolutePath(child, parentDir); // Filter our the symbolic link directories since those arent included in recursive watch // which is same behaviour when recursive: true is passed to fs.watch - return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* EqualTo */ ? childFullName : undefined; + return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 /* Comparison.EqualTo */ ? childFullName : undefined; }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher); parentWatcher.childWatches = newChildWatches || ts.emptyArray; return hasChanges; @@ -6612,7 +6713,7 @@ var ts; case ts.WatchFileKind.FixedChunkSizePolling: return ensureFixedChunkSizePollingWatchFile()(fileName, callback, /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchFileKind.UseFsEvents: - return fsWatch(fileName, 0 /* File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime), + return fsWatch(fileName, 0 /* FileSystemEntryKind.File */, createFsWatchCallbackForFileWatcherCallback(fileName, callback, getModifiedTime), /*recursive*/ false, pollingInterval, ts.getFallbackOptions(options)); case ts.WatchFileKind.UseFsEventsOnParentDirectory: if (!nonPollingWatchFile) { @@ -6667,7 +6768,7 @@ var ts; } function watchDirectory(directoryName, callback, recursive, options) { if (fsSupportsRecursiveFsWatch) { - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options)); } if (!hostRecursiveDirectoryWatcher) { hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({ @@ -6699,7 +6800,7 @@ var ts; /* pollingInterval */ undefined, /*options*/ undefined); case ts.WatchDirectoryKind.UseFsEvents: - return fsWatch(directoryName, 1 /* Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); + return fsWatch(directoryName, 1 /* FileSystemEntryKind.Directory */, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions)); default: ts.Debug.assertNever(watchDirectoryKind); } @@ -6738,14 +6839,16 @@ var ts; return { close: function () { // Close the watcher (either existing file system entry watcher or missing file system entry watcher) - watcher.close(); - watcher = undefined; + if (watcher) { + watcher.close(); + watcher = undefined; + } } }; function updateWatcher(createWatcher) { // If watcher is not closed, update it if (watcher) { - sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing watcher to ").concat(createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing", "FileSystemEntryWatcher")); watcher.close(); watcher = createWatcher(); } @@ -6756,7 +6859,7 @@ var ts; */ function watchPresentFileSystemEntry() { if (hitSystemWatcherLimit) { - sysLog("sysLog:: " + fileOrDirectory + ":: Defaulting to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Defaulting to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } try { @@ -6775,7 +6878,7 @@ var ts; // Eg. on linux the number of watches are limited and one could easily exhaust watches and the exception ENOSPC is thrown when creating watcher at that point // so instead of throwing error, use fs.watchFile hitSystemWatcherLimit || (hitSystemWatcherLimit = e.code === "ENOSPC"); - sysLog("sysLog:: " + fileOrDirectory + ":: Changing to watchFile"); + sysLog("sysLog:: ".concat(fileOrDirectory, ":: Changing to watchFile")); return watchPresentFileSystemEntryWithFsWatchFile(); } } @@ -7070,7 +7173,7 @@ var ts; var remappedPaths = new ts.Map(); var normalizedDir = ts.normalizeSlashes(__dirname); // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls - var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + var fileUrlRoot = "file://".concat(ts.getRootLength(normalizedDir) === 1 ? "" : "/").concat(normalizedDir); for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { var node = _a[_i]; if (node.callFrame.url) { @@ -7079,7 +7182,7 @@ var ts; node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); } else if (!nativePattern.test(url)) { - node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external".concat(externalFileCounter, ".js"))).get(url); externalFileCounter++; } } @@ -7095,7 +7198,7 @@ var ts; if (!err) { try { if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) { - profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + profilePath = _path.join(profilePath, "".concat((new Date()).toISOString().replace(/:/g, "-"), "+P").concat(process.pid, ".cpuprofile")); } } catch (_c) { @@ -7293,8 +7396,8 @@ var ts; return false; } switch (entryKind) { - case 0 /* File */: return stat.isFile(); - case 1 /* Directory */: return stat.isDirectory(); + case 0 /* FileSystemEntryKind.File */: return stat.isFile(); + case 1 /* FileSystemEntryKind.Directory */: return stat.isDirectory(); default: return false; } } @@ -7306,10 +7409,10 @@ var ts; } } function fileExists(path) { - return fileSystemEntryExists(path, 0 /* File */); + return fileSystemEntryExists(path, 0 /* FileSystemEntryKind.File */); } function directoryExists(path) { - return fileSystemEntryExists(path, 1 /* Directory */); + return fileSystemEntryExists(path, 1 /* FileSystemEntryKind.Directory */); } function getDirectories(path) { return getAccessibleFileSystemEntries(path).directories.slice(); @@ -7380,8 +7483,8 @@ var ts; if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) - ? 1 /* Normal */ - : 0 /* None */); + ? 1 /* AssertionLevel.Normal */ + : 0 /* AssertionLevel.None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -7404,7 +7507,7 @@ var ts; * Determines whether a charCode corresponds to `/` or `\`. */ function isAnyDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + return charCode === 47 /* CharacterCodes.slash */ || charCode === 92 /* CharacterCodes.backslash */; } ts.isAnyDirectorySeparator = isAnyDirectorySeparator; /** @@ -7491,16 +7594,16 @@ var ts; ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; //// Path Parsing function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + return (charCode >= 97 /* CharacterCodes.a */ && charCode <= 122 /* CharacterCodes.z */) || + (charCode >= 65 /* CharacterCodes.A */ && charCode <= 90 /* CharacterCodes.Z */); } function getFileUrlVolumeSeparatorEnd(url, start) { var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) + if (ch0 === 58 /* CharacterCodes.colon */) return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + if (ch0 === 37 /* CharacterCodes.percent */ && url.charCodeAt(start + 1) === 51 /* CharacterCodes._3 */) { var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + if (ch2 === 97 /* CharacterCodes.a */ || ch2 === 65 /* CharacterCodes.A */) return start + 3; } return -1; @@ -7514,18 +7617,18 @@ var ts; return 0; var ch0 = path.charCodeAt(0); // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (ch0 === 47 /* CharacterCodes.slash */ || ch0 === 92 /* CharacterCodes.backslash */) { if (path.charCodeAt(1) !== ch0) return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); + var p1 = path.indexOf(ch0 === 47 /* CharacterCodes.slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2); if (p1 < 0) return path.length; // UNC: "//server" or "\\server" return p1 + 1; // UNC: "//server/" or "\\server\" } // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* CharacterCodes.colon */) { var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + if (ch2 === 47 /* CharacterCodes.slash */ || ch2 === 92 /* CharacterCodes.backslash */) return 3; // DOS: "c:/" or "c:\" if (path.length === 2) return 2; // DOS: "c:" (but not "c:d") @@ -7545,7 +7648,7 @@ var ts; isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* CharacterCodes.slash */) { // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" return ~(volumeSeparatorEnd + 1); } @@ -7622,7 +7725,7 @@ var ts; function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { if (!ts.startsWith(extension, ".")) extension = "." + extension; - if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* CharacterCodes.dot */) { var pathExtension = path.slice(path.length - extension.length); if (stringEqualityComparer(pathExtension, extension)) { return pathExtension; @@ -7906,17 +8009,17 @@ var ts; var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/; function comparePathsWorker(a, b, componentComparer) { if (a === b) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (a === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; if (b === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; // NOTE: Performance optimization - shortcut if the root segments differ as there would be no // need to perform path reduction. var aRoot = a.substring(0, getRootLength(a)); var bRoot = b.substring(0, getRootLength(b)); var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { + if (result !== 0 /* Comparison.EqualTo */) { return result; } // NOTE: Performance optimization - shortcut if there are no relative path segments in @@ -7933,7 +8036,7 @@ var ts; var sharedLength = Math.min(aComponents.length, bComponents.length); for (var i = 1; i < sharedLength; i++) { var result_2 = componentComparer(aComponents[i], bComponents[i]); - if (result_2 !== 0 /* EqualTo */) { + if (result_2 !== 0 /* Comparison.EqualTo */) { return result_2; } } @@ -8448,13 +8551,24 @@ var ts; resolution_mode_is_the_only_valid_key_for_type_import_assertions: diag(1455, ts.DiagnosticCategory.Error, "resolution_mode_is_the_only_valid_key_for_type_import_assertions_1455", "`resolution-mode` is the only valid key for type import assertions."), Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require: diag(1456, ts.DiagnosticCategory.Error, "Type_import_assertions_should_have_exactly_one_key_resolution_mode_with_value_import_or_require_1456", "Type import assertions should have exactly one key - `resolution-mode` - with value `import` or `require`."), Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk: diag(1457, ts.DiagnosticCategory.Message, "Matched_by_default_include_pattern_Asterisk_Asterisk_Slash_Asterisk_1457", "Matched by default include pattern '**/*'"), + File_is_ECMAScript_module_because_0_has_field_type_with_value_module: diag(1458, ts.DiagnosticCategory.Message, "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458", "File is ECMAScript module because '{0}' has field \"type\" with value \"module\""), + File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module: diag(1459, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459", "File is CommonJS module because '{0}' has field \"type\" whose value is not \"module\""), + File_is_CommonJS_module_because_0_does_not_have_field_type: diag(1460, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_0_does_not_have_field_type_1460", "File is CommonJS module because '{0}' does not have field \"type\""), + File_is_CommonJS_module_because_package_json_was_not_found: diag(1461, ts.DiagnosticCategory.Message, "File_is_CommonJS_module_because_package_json_was_not_found_1461", "File is CommonJS module because 'package.json' was not found"), The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output: diag(1470, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output_1470", "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output."), - Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead."), + Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead: diag(1471, ts.DiagnosticCategory.Error, "Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_c_1471", "Module '{0}' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported with 'require'. Use an ECMAScript import instead."), catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."), An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."), An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."), Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."), auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node16_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules."), + An_instantiation_expression_cannot_be_followed_by_a_property_access: diag(1477, ts.DiagnosticCategory.Error, "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477", "An instantiation expression cannot be followed by a property access."), + Identifier_or_string_literal_expected: diag(1478, ts.DiagnosticCategory.Error, "Identifier_or_string_literal_expected_1478", "Identifier or string literal expected."), + The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead: diag(1479, ts.DiagnosticCategory.Error, "The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_reference_1479", "The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import(\"{0}\")' call instead."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module: diag(1480, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_packag_1480", "To convert this file to an ECMAScript module, change its file extension to '{0}' or create a local package.json file with `{ \"type\": \"module\" }`."), + To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1: diag(1481, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Co_1481", "To convert this file to an ECMAScript module, change its file extension to '{0}', or add the field `\"type\": \"module\"` to '{1}'."), + To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0: diag(1482, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0_1482", "To convert this file to an ECMAScript module, add the field `\"type\": \"module\"` to '{0}'."), + To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module: diag(1483, ts.DiagnosticCategory.Message, "To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module_1483", "To convert this file to an ECMAScript module, create a local package.json file with `{ \"type\": \"module\" }`."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -8668,6 +8782,7 @@ var ts; Cannot_create_an_instance_of_an_abstract_class: diag(2511, ts.DiagnosticCategory.Error, "Cannot_create_an_instance_of_an_abstract_class_2511", "Cannot create an instance of an abstract class."), Overload_signatures_must_all_be_abstract_or_non_abstract: diag(2512, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_abstract_or_non_abstract_2512", "Overload signatures must all be abstract or non-abstract."), Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: diag(2513, ts.DiagnosticCategory.Error, "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513", "Abstract method '{0}' in class '{1}' cannot be accessed via super expression."), + A_tuple_type_cannot_be_indexed_with_a_negative_value: diag(2514, ts.DiagnosticCategory.Error, "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514", "A tuple type cannot be indexed with a negative value."), Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: diag(2515, ts.DiagnosticCategory.Error, "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515", "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'."), All_declarations_of_an_abstract_method_must_be_consecutive: diag(2516, ts.DiagnosticCategory.Error, "All_declarations_of_an_abstract_method_must_be_consecutive_2516", "All declarations of an abstract method must be consecutive."), Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: diag(2517, ts.DiagnosticCategory.Error, "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", "Cannot assign an abstract constructor type to a non-abstract constructor type."), @@ -8955,6 +9070,7 @@ var ts; The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."), _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"), We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."), + Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, ts.DiagnosticCategory.Error, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), 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}'."), @@ -9934,100 +10050,100 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 79 /* Identifier */; + return token >= 79 /* SyntaxKind.Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* SyntaxKind.GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; /** @internal */ ts.textToKeywordObj = (_a = { - abstract: 126 /* AbstractKeyword */, - any: 130 /* AnyKeyword */, - as: 127 /* AsKeyword */, - asserts: 128 /* AssertsKeyword */, - assert: 129 /* AssertKeyword */, - bigint: 158 /* BigIntKeyword */, - boolean: 133 /* BooleanKeyword */, - break: 81 /* BreakKeyword */, - case: 82 /* CaseKeyword */, - catch: 83 /* CatchKeyword */, - class: 84 /* ClassKeyword */, - continue: 86 /* ContinueKeyword */, - const: 85 /* ConstKeyword */ + abstract: 126 /* SyntaxKind.AbstractKeyword */, + any: 130 /* SyntaxKind.AnyKeyword */, + as: 127 /* SyntaxKind.AsKeyword */, + asserts: 128 /* SyntaxKind.AssertsKeyword */, + assert: 129 /* SyntaxKind.AssertKeyword */, + bigint: 158 /* SyntaxKind.BigIntKeyword */, + boolean: 133 /* SyntaxKind.BooleanKeyword */, + break: 81 /* SyntaxKind.BreakKeyword */, + case: 82 /* SyntaxKind.CaseKeyword */, + catch: 83 /* SyntaxKind.CatchKeyword */, + class: 84 /* SyntaxKind.ClassKeyword */, + continue: 86 /* SyntaxKind.ContinueKeyword */, + const: 85 /* SyntaxKind.ConstKeyword */ }, - _a["" + "constructor"] = 134 /* ConstructorKeyword */, - _a.debugger = 87 /* DebuggerKeyword */, - _a.declare = 135 /* DeclareKeyword */, - _a.default = 88 /* DefaultKeyword */, - _a.delete = 89 /* DeleteKeyword */, - _a.do = 90 /* DoKeyword */, - _a.else = 91 /* ElseKeyword */, - _a.enum = 92 /* EnumKeyword */, - _a.export = 93 /* ExportKeyword */, - _a.extends = 94 /* ExtendsKeyword */, - _a.false = 95 /* FalseKeyword */, - _a.finally = 96 /* FinallyKeyword */, - _a.for = 97 /* ForKeyword */, - _a.from = 156 /* FromKeyword */, - _a.function = 98 /* FunctionKeyword */, - _a.get = 136 /* GetKeyword */, - _a.if = 99 /* IfKeyword */, - _a.implements = 117 /* ImplementsKeyword */, - _a.import = 100 /* ImportKeyword */, - _a.in = 101 /* InKeyword */, - _a.infer = 137 /* InferKeyword */, - _a.instanceof = 102 /* InstanceOfKeyword */, - _a.interface = 118 /* InterfaceKeyword */, - _a.intrinsic = 138 /* IntrinsicKeyword */, - _a.is = 139 /* IsKeyword */, - _a.keyof = 140 /* KeyOfKeyword */, - _a.let = 119 /* LetKeyword */, - _a.module = 141 /* ModuleKeyword */, - _a.namespace = 142 /* NamespaceKeyword */, - _a.never = 143 /* NeverKeyword */, - _a.new = 103 /* NewKeyword */, - _a.null = 104 /* NullKeyword */, - _a.number = 147 /* NumberKeyword */, - _a.object = 148 /* ObjectKeyword */, - _a.package = 120 /* PackageKeyword */, - _a.private = 121 /* PrivateKeyword */, - _a.protected = 122 /* ProtectedKeyword */, - _a.public = 123 /* PublicKeyword */, - _a.override = 159 /* OverrideKeyword */, - _a.out = 144 /* OutKeyword */, - _a.readonly = 145 /* ReadonlyKeyword */, - _a.require = 146 /* RequireKeyword */, - _a.global = 157 /* GlobalKeyword */, - _a.return = 105 /* ReturnKeyword */, - _a.set = 149 /* SetKeyword */, - _a.static = 124 /* StaticKeyword */, - _a.string = 150 /* StringKeyword */, - _a.super = 106 /* SuperKeyword */, - _a.switch = 107 /* SwitchKeyword */, - _a.symbol = 151 /* SymbolKeyword */, - _a.this = 108 /* ThisKeyword */, - _a.throw = 109 /* ThrowKeyword */, - _a.true = 110 /* TrueKeyword */, - _a.try = 111 /* TryKeyword */, - _a.type = 152 /* TypeKeyword */, - _a.typeof = 112 /* TypeOfKeyword */, - _a.undefined = 153 /* UndefinedKeyword */, - _a.unique = 154 /* UniqueKeyword */, - _a.unknown = 155 /* UnknownKeyword */, - _a.var = 113 /* VarKeyword */, - _a.void = 114 /* VoidKeyword */, - _a.while = 115 /* WhileKeyword */, - _a.with = 116 /* WithKeyword */, - _a.yield = 125 /* YieldKeyword */, - _a.async = 131 /* AsyncKeyword */, - _a.await = 132 /* AwaitKeyword */, - _a.of = 160 /* OfKeyword */, + _a["" + "constructor"] = 134 /* SyntaxKind.ConstructorKeyword */, + _a.debugger = 87 /* SyntaxKind.DebuggerKeyword */, + _a.declare = 135 /* SyntaxKind.DeclareKeyword */, + _a.default = 88 /* SyntaxKind.DefaultKeyword */, + _a.delete = 89 /* SyntaxKind.DeleteKeyword */, + _a.do = 90 /* SyntaxKind.DoKeyword */, + _a.else = 91 /* SyntaxKind.ElseKeyword */, + _a.enum = 92 /* SyntaxKind.EnumKeyword */, + _a.export = 93 /* SyntaxKind.ExportKeyword */, + _a.extends = 94 /* SyntaxKind.ExtendsKeyword */, + _a.false = 95 /* SyntaxKind.FalseKeyword */, + _a.finally = 96 /* SyntaxKind.FinallyKeyword */, + _a.for = 97 /* SyntaxKind.ForKeyword */, + _a.from = 156 /* SyntaxKind.FromKeyword */, + _a.function = 98 /* SyntaxKind.FunctionKeyword */, + _a.get = 136 /* SyntaxKind.GetKeyword */, + _a.if = 99 /* SyntaxKind.IfKeyword */, + _a.implements = 117 /* SyntaxKind.ImplementsKeyword */, + _a.import = 100 /* SyntaxKind.ImportKeyword */, + _a.in = 101 /* SyntaxKind.InKeyword */, + _a.infer = 137 /* SyntaxKind.InferKeyword */, + _a.instanceof = 102 /* SyntaxKind.InstanceOfKeyword */, + _a.interface = 118 /* SyntaxKind.InterfaceKeyword */, + _a.intrinsic = 138 /* SyntaxKind.IntrinsicKeyword */, + _a.is = 139 /* SyntaxKind.IsKeyword */, + _a.keyof = 140 /* SyntaxKind.KeyOfKeyword */, + _a.let = 119 /* SyntaxKind.LetKeyword */, + _a.module = 141 /* SyntaxKind.ModuleKeyword */, + _a.namespace = 142 /* SyntaxKind.NamespaceKeyword */, + _a.never = 143 /* SyntaxKind.NeverKeyword */, + _a.new = 103 /* SyntaxKind.NewKeyword */, + _a.null = 104 /* SyntaxKind.NullKeyword */, + _a.number = 147 /* SyntaxKind.NumberKeyword */, + _a.object = 148 /* SyntaxKind.ObjectKeyword */, + _a.package = 120 /* SyntaxKind.PackageKeyword */, + _a.private = 121 /* SyntaxKind.PrivateKeyword */, + _a.protected = 122 /* SyntaxKind.ProtectedKeyword */, + _a.public = 123 /* SyntaxKind.PublicKeyword */, + _a.override = 159 /* SyntaxKind.OverrideKeyword */, + _a.out = 144 /* SyntaxKind.OutKeyword */, + _a.readonly = 145 /* SyntaxKind.ReadonlyKeyword */, + _a.require = 146 /* SyntaxKind.RequireKeyword */, + _a.global = 157 /* SyntaxKind.GlobalKeyword */, + _a.return = 105 /* SyntaxKind.ReturnKeyword */, + _a.set = 149 /* SyntaxKind.SetKeyword */, + _a.static = 124 /* SyntaxKind.StaticKeyword */, + _a.string = 150 /* SyntaxKind.StringKeyword */, + _a.super = 106 /* SyntaxKind.SuperKeyword */, + _a.switch = 107 /* SyntaxKind.SwitchKeyword */, + _a.symbol = 151 /* SyntaxKind.SymbolKeyword */, + _a.this = 108 /* SyntaxKind.ThisKeyword */, + _a.throw = 109 /* SyntaxKind.ThrowKeyword */, + _a.true = 110 /* SyntaxKind.TrueKeyword */, + _a.try = 111 /* SyntaxKind.TryKeyword */, + _a.type = 152 /* SyntaxKind.TypeKeyword */, + _a.typeof = 112 /* SyntaxKind.TypeOfKeyword */, + _a.undefined = 153 /* SyntaxKind.UndefinedKeyword */, + _a.unique = 154 /* SyntaxKind.UniqueKeyword */, + _a.unknown = 155 /* SyntaxKind.UnknownKeyword */, + _a.var = 113 /* SyntaxKind.VarKeyword */, + _a.void = 114 /* SyntaxKind.VoidKeyword */, + _a.while = 115 /* SyntaxKind.WhileKeyword */, + _a.with = 116 /* SyntaxKind.WithKeyword */, + _a.yield = 125 /* SyntaxKind.YieldKeyword */, + _a.async = 131 /* SyntaxKind.AsyncKeyword */, + _a.await = 132 /* SyntaxKind.AwaitKeyword */, + _a.of = 160 /* SyntaxKind.OfKeyword */, _a); var textToKeyword = new ts.Map(ts.getEntries(ts.textToKeywordObj)); - var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 63 /* EqualsToken */, "+=": 64 /* PlusEqualsToken */, "-=": 65 /* MinusEqualsToken */, "*=": 66 /* AsteriskEqualsToken */, "**=": 67 /* AsteriskAsteriskEqualsToken */, "/=": 68 /* SlashEqualsToken */, "%=": 69 /* PercentEqualsToken */, "<<=": 70 /* LessThanLessThanEqualsToken */, ">>=": 71 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* AmpersandEqualsToken */, "|=": 74 /* BarEqualsToken */, "^=": 78 /* CaretEqualsToken */, "||=": 75 /* BarBarEqualsToken */, "&&=": 76 /* AmpersandAmpersandEqualsToken */, "??=": 77 /* QuestionQuestionEqualsToken */, "@": 59 /* AtToken */, "#": 62 /* HashToken */, "`": 61 /* BacktickToken */ }))); + var textToToken = new ts.Map(ts.getEntries(__assign(__assign({}, ts.textToKeywordObj), { "{": 18 /* SyntaxKind.OpenBraceToken */, "}": 19 /* SyntaxKind.CloseBraceToken */, "(": 20 /* SyntaxKind.OpenParenToken */, ")": 21 /* SyntaxKind.CloseParenToken */, "[": 22 /* SyntaxKind.OpenBracketToken */, "]": 23 /* SyntaxKind.CloseBracketToken */, ".": 24 /* SyntaxKind.DotToken */, "...": 25 /* SyntaxKind.DotDotDotToken */, ";": 26 /* SyntaxKind.SemicolonToken */, ",": 27 /* SyntaxKind.CommaToken */, "<": 29 /* SyntaxKind.LessThanToken */, ">": 31 /* SyntaxKind.GreaterThanToken */, "<=": 32 /* SyntaxKind.LessThanEqualsToken */, ">=": 33 /* SyntaxKind.GreaterThanEqualsToken */, "==": 34 /* SyntaxKind.EqualsEqualsToken */, "!=": 35 /* SyntaxKind.ExclamationEqualsToken */, "===": 36 /* SyntaxKind.EqualsEqualsEqualsToken */, "!==": 37 /* SyntaxKind.ExclamationEqualsEqualsToken */, "=>": 38 /* SyntaxKind.EqualsGreaterThanToken */, "+": 39 /* SyntaxKind.PlusToken */, "-": 40 /* SyntaxKind.MinusToken */, "**": 42 /* SyntaxKind.AsteriskAsteriskToken */, "*": 41 /* SyntaxKind.AsteriskToken */, "/": 43 /* SyntaxKind.SlashToken */, "%": 44 /* SyntaxKind.PercentToken */, "++": 45 /* SyntaxKind.PlusPlusToken */, "--": 46 /* SyntaxKind.MinusMinusToken */, "<<": 47 /* SyntaxKind.LessThanLessThanToken */, ">": 48 /* SyntaxKind.GreaterThanGreaterThanToken */, ">>>": 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* SyntaxKind.AmpersandToken */, "|": 51 /* SyntaxKind.BarToken */, "^": 52 /* SyntaxKind.CaretToken */, "!": 53 /* SyntaxKind.ExclamationToken */, "~": 54 /* SyntaxKind.TildeToken */, "&&": 55 /* SyntaxKind.AmpersandAmpersandToken */, "||": 56 /* SyntaxKind.BarBarToken */, "?": 57 /* SyntaxKind.QuestionToken */, "??": 60 /* SyntaxKind.QuestionQuestionToken */, "?.": 28 /* SyntaxKind.QuestionDotToken */, ":": 58 /* SyntaxKind.ColonToken */, "=": 63 /* SyntaxKind.EqualsToken */, "+=": 64 /* SyntaxKind.PlusEqualsToken */, "-=": 65 /* SyntaxKind.MinusEqualsToken */, "*=": 66 /* SyntaxKind.AsteriskEqualsToken */, "**=": 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */, "/=": 68 /* SyntaxKind.SlashEqualsToken */, "%=": 69 /* SyntaxKind.PercentEqualsToken */, "<<=": 70 /* SyntaxKind.LessThanLessThanEqualsToken */, ">>=": 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */, ">>>=": 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 73 /* SyntaxKind.AmpersandEqualsToken */, "|=": 74 /* SyntaxKind.BarEqualsToken */, "^=": 78 /* SyntaxKind.CaretEqualsToken */, "||=": 75 /* SyntaxKind.BarBarEqualsToken */, "&&=": 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */, "??=": 77 /* SyntaxKind.QuestionQuestionEqualsToken */, "@": 59 /* SyntaxKind.AtToken */, "#": 62 /* SyntaxKind.HashToken */, "`": 61 /* SyntaxKind.BacktickToken */ }))); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -10116,16 +10232,16 @@ var ts; return false; } /* @internal */ function isUnicodeIdentifierStart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierStart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) : lookupInUnicodeMap(code, unicodeES3IdentifierStart); } ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart; function isUnicodeIdentifierPart(code, languageVersion) { - return languageVersion >= 2 /* ES2015 */ ? + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? lookupInUnicodeMap(code, unicodeESNextIdentifierPart) : - languageVersion === 1 /* ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : + languageVersion === 1 /* ScriptTarget.ES5 */ ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) : lookupInUnicodeMap(code, unicodeES3IdentifierPart); } function makeReverseMap(source) { @@ -10154,17 +10270,17 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: result.push(lineStart); lineStart = pos; break; default: - if (ch > 127 /* maxAsciiCharacter */ && isLineBreak(ch)) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isLineBreak(ch)) { result.push(lineStart); lineStart = pos; } @@ -10189,7 +10305,7 @@ var ts; line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line; } else { - ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); + ts.Debug.fail("Bad line number. Line: ".concat(line, ", lineStarts.length: ").concat(lineStarts.length, " , line map is correct? ").concat(debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown")); } } var res = lineStarts[line] + character; @@ -10267,18 +10383,18 @@ var ts; function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. // It is explicitly not a line-break as it isn't in the exact set specified by EcmaScript. - return ch === 32 /* space */ || - ch === 9 /* tab */ || - ch === 11 /* verticalTab */ || - ch === 12 /* formFeed */ || - ch === 160 /* nonBreakingSpace */ || - ch === 133 /* nextLine */ || - ch === 5760 /* ogham */ || - ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ || - ch === 8239 /* narrowNoBreakSpace */ || - ch === 8287 /* mathematicalSpace */ || - ch === 12288 /* ideographicSpace */ || - ch === 65279 /* byteOrderMark */; + return ch === 32 /* CharacterCodes.space */ || + ch === 9 /* CharacterCodes.tab */ || + ch === 11 /* CharacterCodes.verticalTab */ || + ch === 12 /* CharacterCodes.formFeed */ || + ch === 160 /* CharacterCodes.nonBreakingSpace */ || + ch === 133 /* CharacterCodes.nextLine */ || + ch === 5760 /* CharacterCodes.ogham */ || + ch >= 8192 /* CharacterCodes.enQuad */ && ch <= 8203 /* CharacterCodes.zeroWidthSpace */ || + ch === 8239 /* CharacterCodes.narrowNoBreakSpace */ || + ch === 8287 /* CharacterCodes.mathematicalSpace */ || + ch === 12288 /* CharacterCodes.ideographicSpace */ || + ch === 65279 /* CharacterCodes.byteOrderMark */; } ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine; function isLineBreak(ch) { @@ -10292,50 +10408,50 @@ var ts; // \u2029 Paragraph separator // Only the characters in Table 3 are treated as line terminators. Other new line or line // breaking characters are treated as white space but not as line terminators. - return ch === 10 /* lineFeed */ || - ch === 13 /* carriageReturn */ || - ch === 8232 /* lineSeparator */ || - ch === 8233 /* paragraphSeparator */; + return ch === 10 /* CharacterCodes.lineFeed */ || + ch === 13 /* CharacterCodes.carriageReturn */ || + ch === 8232 /* CharacterCodes.lineSeparator */ || + ch === 8233 /* CharacterCodes.paragraphSeparator */; } ts.isLineBreak = isLineBreak; function isDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */; } function isHexDigit(ch) { - return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */; + return isDigit(ch) || ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */ || ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */; } function isCodePoint(code) { return code <= 0x10FFFF; } /* @internal */ function isOctalDigit(ch) { - return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; + return ch >= 48 /* CharacterCodes._0 */ && ch <= 55 /* CharacterCodes._7 */; } ts.isOctalDigit = isOctalDigit; function couldStartTrivia(text, pos) { // Keep in sync with skipTrivia var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - case 10 /* lineFeed */: - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 47 /* slash */: + case 13 /* CharacterCodes.carriageReturn */: + case 10 /* CharacterCodes.lineFeed */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 47 /* CharacterCodes.slash */: // starts of normal trivia // falls through - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: // Starts of conflict marker trivia return true; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: // Only if its the beginning can we have #! trivia return pos === 0; default: - return ch > 127 /* maxAsciiCharacter */; + return ch > 127 /* CharacterCodes.maxAsciiCharacter */; } } ts.couldStartTrivia = couldStartTrivia; @@ -10349,29 +10465,29 @@ var ts; while (true) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (stopAfterLineBreak) { return pos; } canConsumeStar = !!inJSDoc; continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: if (stopAtComments) { break; } - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { @@ -10382,10 +10498,10 @@ var ts; canConsumeStar = false; continue; } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10395,24 +10511,24 @@ var ts; continue; } break; - case 60 /* lessThan */: - case 124 /* bar */: - case 61 /* equals */: - case 62 /* greaterThan */: + case 60 /* CharacterCodes.lessThan */: + case 124 /* CharacterCodes.bar */: + case 61 /* CharacterCodes.equals */: + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos); canConsumeStar = false; continue; } break; - case 35 /* hash */: + case 35 /* CharacterCodes.hash */: if (pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); canConsumeStar = false; continue; } break; - case 42 /* asterisk */: + case 42 /* CharacterCodes.asterisk */: if (canConsumeStar) { pos++; canConsumeStar = false; @@ -10420,7 +10536,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -10444,8 +10560,8 @@ var ts; return false; } } - return ch === 61 /* equals */ || - text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* space */; + return ch === 61 /* CharacterCodes.equals */ || + text.charCodeAt(pos + mergeConflictMarkerLength) === 32 /* CharacterCodes.space */; } } return false; @@ -10456,18 +10572,18 @@ var ts; } var ch = text.charCodeAt(pos); var len = text.length; - if (ch === 60 /* lessThan */ || ch === 62 /* greaterThan */) { + if (ch === 60 /* CharacterCodes.lessThan */ || ch === 62 /* CharacterCodes.greaterThan */) { while (pos < len && !isLineBreak(text.charCodeAt(pos))) { pos++; } } else { - ts.Debug.assert(ch === 124 /* bar */ || ch === 61 /* equals */); + ts.Debug.assert(ch === 124 /* CharacterCodes.bar */ || ch === 61 /* CharacterCodes.equals */); // Consume everything from the start of a ||||||| or ======= marker to the start // of the next ======= or >>>>>>> marker. while (pos < len) { var currentChar = text.charCodeAt(pos); - if ((currentChar === 61 /* equals */ || currentChar === 62 /* greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { + if ((currentChar === 61 /* CharacterCodes.equals */ || currentChar === 62 /* CharacterCodes.greaterThan */) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) { break; } pos++; @@ -10528,12 +10644,12 @@ var ts; scan: while (pos >= 0 && pos < text.length) { var ch = text.charCodeAt(pos); switch (ch) { - case 13 /* carriageReturn */: - if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: + case 10 /* CharacterCodes.lineFeed */: pos++; if (trailing) { break scan; @@ -10543,20 +10659,20 @@ var ts; pendingHasTrailingNewLine = true; } continue; - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: pos++; continue; - case 47 /* slash */: + case 47 /* CharacterCodes.slash */: var nextChar = text.charCodeAt(pos + 1); var hasTrailingNewLine = false; - if (nextChar === 47 /* slash */ || nextChar === 42 /* asterisk */) { - var kind = nextChar === 47 /* slash */ ? 2 /* SingleLineCommentTrivia */ : 3 /* MultiLineCommentTrivia */; + if (nextChar === 47 /* CharacterCodes.slash */ || nextChar === 42 /* CharacterCodes.asterisk */) { + var kind = nextChar === 47 /* CharacterCodes.slash */ ? 2 /* SyntaxKind.SingleLineCommentTrivia */ : 3 /* SyntaxKind.MultiLineCommentTrivia */; var startPos = pos; pos += 2; - if (nextChar === 47 /* slash */) { + if (nextChar === 47 /* CharacterCodes.slash */) { while (pos < text.length) { if (isLineBreak(text.charCodeAt(pos))) { hasTrailingNewLine = true; @@ -10567,7 +10683,7 @@ var ts; } else { while (pos < text.length) { - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; break; } @@ -10592,7 +10708,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { + if (ch > 127 /* CharacterCodes.maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -10647,17 +10763,17 @@ var ts; } ts.getShebang = getShebang; function isIdentifierStart(ch, languageVersion) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch === 36 /* $ */ || ch === 95 /* _ */ || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } ts.isIdentifierStart = isIdentifierStart; function isIdentifierPart(ch, languageVersion, identifierVariant) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ || ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ || + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ || ch === 36 /* CharacterCodes.$ */ || ch === 95 /* CharacterCodes._ */ || // "-" and ":" are valid in JSX Identifiers - (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) || - ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); + (identifierVariant === 1 /* LanguageVariant.JSX */ ? (ch === 45 /* CharacterCodes.minus */ || ch === 58 /* CharacterCodes.colon */) : false) || + ch > 127 /* CharacterCodes.maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; /* @internal */ @@ -10676,7 +10792,7 @@ var ts; ts.isIdentifierText = isIdentifierText; // Creates a scanner over a (possibly unspecified) range of a piece of text. function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) { - if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } + if (languageVariant === void 0) { languageVariant = 0 /* LanguageVariant.Standard */; } var text = textInitial; // Current position (end position of text of current token) var pos; @@ -10699,15 +10815,15 @@ var ts; getTokenPos: function () { return tokenPos; }, getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, - hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, - hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, - hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* PrecedingJSDocComment */) !== 0; }, - isIdentifier: function () { return token === 79 /* Identifier */ || token > 116 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */; }, - isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, + hasUnicodeEscape: function () { return (tokenFlags & 1024 /* TokenFlags.UnicodeEscape */) !== 0; }, + hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* TokenFlags.ExtendedUnicodeEscape */) !== 0; }, + hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */) !== 0; }, + hasPrecedingJSDocComment: function () { return (tokenFlags & 2 /* TokenFlags.PrecedingJSDocComment */) !== 0; }, + isIdentifier: function () { return token === 79 /* SyntaxKind.Identifier */ || token > 116 /* SyntaxKind.LastReservedWord */; }, + isReservedWord: function () { return token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */; }, + isUnterminated: function () { return (tokenFlags & 4 /* TokenFlags.Unterminated */) !== 0; }, getCommentDirectives: function () { return commentDirectives; }, - getNumericLiteralFlags: function () { return tokenFlags & 1008 /* NumericLiteralFlags */; }, + getNumericLiteralFlags: function () { return tokenFlags & 1008 /* TokenFlags.NumericLiteralFlags */; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, reScanAsteriskEqualsToken: reScanAsteriskEqualsToken, @@ -10762,8 +10878,8 @@ var ts; var result = ""; while (true) { var ch = text.charCodeAt(pos); - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10787,7 +10903,7 @@ var ts; } break; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return result + text.substring(start, pos); @@ -10797,15 +10913,15 @@ var ts; var mainFragment = scanNumberFragment(); var decimalFragment; var scientificFragment; - if (text.charCodeAt(pos) === 46 /* dot */) { + if (text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) { pos++; decimalFragment = scanNumberFragment(); } var end = pos; - if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { + if (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */) { pos++; - tokenFlags |= 16 /* Scientific */; - if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) + tokenFlags |= 16 /* TokenFlags.Scientific */; + if (text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos++; var preNumericPart = pos; var finalFragment = scanNumberFragment(); @@ -10818,7 +10934,7 @@ var ts; } } var result; - if (tokenFlags & 512 /* ContainsSeparator */) { + if (tokenFlags & 512 /* TokenFlags.ContainsSeparator */) { result = mainFragment; if (decimalFragment) { result += "." + decimalFragment; @@ -10830,10 +10946,10 @@ var ts; else { result = text.substring(start, end); // No need to use all the fragments; no _ removal needed } - if (decimalFragment !== undefined || tokenFlags & 16 /* Scientific */) { - checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* Scientific */)); + if (decimalFragment !== undefined || tokenFlags & 16 /* TokenFlags.Scientific */) { + checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16 /* TokenFlags.Scientific */)); return { - type: 8 /* NumericLiteral */, + type: 8 /* SyntaxKind.NumericLiteral */, value: "" + +result // if value is not an integer, it can be safely coerced to a number }; } @@ -10891,8 +11007,8 @@ var ts; var isPreviousTokenSeparator = false; while (valueChars.length < minCount || scanAsManyAsPossible) { var ch = text.charCodeAt(pos); - if (canHaveSeparators && ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (canHaveSeparators && ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (allowSeparator) { allowSeparator = false; isPreviousTokenSeparator = true; @@ -10907,11 +11023,11 @@ var ts; continue; } allowSeparator = canHaveSeparators; - if (ch >= 65 /* A */ && ch <= 70 /* F */) { - ch += 97 /* a */ - 65 /* A */; // standardize hex literals to lowercase + if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) { + ch += 97 /* CharacterCodes.a */ - 65 /* CharacterCodes.A */; // standardize hex literals to lowercase } - else if (!((ch >= 48 /* _0 */ && ch <= 57 /* _9 */) || - (ch >= 97 /* a */ && ch <= 102 /* f */))) { + else if (!((ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) || + (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */))) { break; } valueChars.push(ch); @@ -10921,7 +11037,7 @@ var ts; if (valueChars.length < minCount) { valueChars = []; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return String.fromCharCode.apply(String, valueChars); @@ -10935,7 +11051,7 @@ var ts; while (true) { if (pos >= end) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -10945,7 +11061,7 @@ var ts; pos++; break; } - if (ch === 92 /* backslash */ && !jsxAttributeString) { + if (ch === 92 /* CharacterCodes.backslash */ && !jsxAttributeString) { result += text.substring(start, pos); result += scanEscapeSequence(); start = pos; @@ -10953,7 +11069,7 @@ var ts; } if (isLineBreak(ch) && !jsxAttributeString) { result += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_string_literal); break; } @@ -10966,7 +11082,7 @@ var ts; * a literal component of a TemplateExpression. */ function scanTemplateAndSetTokenValue(isTaggedTemplate) { - var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + var startedWithBacktick = text.charCodeAt(pos) === 96 /* CharacterCodes.backtick */; pos++; var start = pos; var contents = ""; @@ -10974,28 +11090,28 @@ var ts; while (true) { if (pos >= end) { contents += text.substring(start, pos); - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } var currChar = text.charCodeAt(pos); // '`' - if (currChar === 96 /* backtick */) { + if (currChar === 96 /* CharacterCodes.backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 14 /* NoSubstitutionTemplateLiteral */ : 17 /* TemplateTail */; + resultingToken = startedWithBacktick ? 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ : 17 /* SyntaxKind.TemplateTail */; break; } // '${' - if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + if (currChar === 36 /* CharacterCodes.$ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* CharacterCodes.openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 15 /* TemplateHead */ : 16 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 15 /* SyntaxKind.TemplateHead */ : 16 /* SyntaxKind.TemplateMiddle */; break; } // Escape character - if (currChar === 92 /* backslash */) { + if (currChar === 92 /* CharacterCodes.backslash */) { contents += text.substring(start, pos); contents += scanEscapeSequence(isTaggedTemplate); start = pos; @@ -11003,10 +11119,10 @@ var ts; } // Speculated ECMAScript 6 Spec 11.8.6.1: // and LineTerminatorSequences are normalized to for Template Values - if (currChar === 13 /* carriageReturn */) { + if (currChar === 13 /* CharacterCodes.carriageReturn */) { contents += text.substring(start, pos); pos++; - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } contents += "\n"; @@ -11029,47 +11145,47 @@ var ts; var ch = text.charCodeAt(pos); pos++; switch (ch) { - case 48 /* _0 */: + case 48 /* CharacterCodes._0 */: // '\01' if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } return "\0"; - case 98 /* b */: + case 98 /* CharacterCodes.b */: return "\b"; - case 116 /* t */: + case 116 /* CharacterCodes.t */: return "\t"; - case 110 /* n */: + case 110 /* CharacterCodes.n */: return "\n"; - case 118 /* v */: + case 118 /* CharacterCodes.v */: return "\v"; - case 102 /* f */: + case 102 /* CharacterCodes.f */: return "\f"; - case 114 /* r */: + case 114 /* CharacterCodes.r */: return "\r"; - case 39 /* singleQuote */: + case 39 /* CharacterCodes.singleQuote */: return "\'"; - case 34 /* doubleQuote */: + case 34 /* CharacterCodes.doubleQuote */: return "\""; - case 117 /* u */: + case 117 /* CharacterCodes.u */: if (isTaggedTemplate) { // '\u' or '\u0' or '\u00' or '\u000' for (var escapePos = pos; escapePos < pos + 4; escapePos++) { - if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) { + if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* CharacterCodes.openBrace */) { pos = escapePos; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } } // '\u{DDDDDDDD}' - if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { + if (pos < end && text.charCodeAt(pos) === 123 /* CharacterCodes.openBrace */) { pos++; // '\u{' if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } if (isTaggedTemplate) { @@ -11077,29 +11193,29 @@ var ts; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; // '\u{Not Code Point' or '\u{CodePoint' - if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* CharacterCodes.closeBrace */) { + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else { pos = savePos; } } - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; return scanExtendedUnicodeEscape(); } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); - case 120 /* x */: + case 120 /* CharacterCodes.x */: if (isTaggedTemplate) { if (!isHexDigit(text.charCodeAt(pos))) { - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } else if (!isHexDigit(text.charCodeAt(pos + 1))) { pos++; - tokenFlags |= 2048 /* ContainsInvalidEscape */; + tokenFlags |= 2048 /* TokenFlags.ContainsInvalidEscape */; return text.substring(start, pos); } } @@ -11107,14 +11223,14 @@ var ts; return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), // the line terminator is interpreted to be "the empty code unit sequence". - case 13 /* carriageReturn */: - if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { + case 13 /* CharacterCodes.carriageReturn */: + if (pos < end && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: + case 10 /* CharacterCodes.lineFeed */: + case 8232 /* CharacterCodes.lineSeparator */: + case 8233 /* CharacterCodes.paragraphSeparator */: return ""; default: return String.fromCharCode(ch); @@ -11147,7 +11263,7 @@ var ts; error(ts.Diagnostics.Unexpected_end_of_text); isInvalidExtendedEscape = true; } - else if (text.charCodeAt(pos) === 125 /* closeBrace */) { + else if (text.charCodeAt(pos) === 125 /* CharacterCodes.closeBrace */) { // Only swallow the following character up if it's a '}'. pos++; } @@ -11163,7 +11279,7 @@ var ts; // Current character is known to be a backslash. Check for Unicode escape of the form '\uXXXX' // and return code point value if valid Unicode escape is found. Otherwise return -1. function peekUnicodeEscape() { - if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* u */) { + if (pos + 5 < end && text.charCodeAt(pos + 1) === 117 /* CharacterCodes.u */) { var start_1 = pos; pos += 2; var value = scanExactNumberOfHexDigits(4, /*canHaveSeparators*/ false); @@ -11173,7 +11289,7 @@ var ts; return -1; } function peekExtendedUnicodeEscape() { - if (languageVersion >= 2 /* ES2015 */ && codePointAt(text, pos + 1) === 117 /* u */ && codePointAt(text, pos + 2) === 123 /* openBrace */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) { var start_2 = pos; pos += 3; var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); @@ -11191,11 +11307,11 @@ var ts; if (isIdentifierPart(ch, languageVersion)) { pos += charSize(ch); } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { ch = peekExtendedUnicodeEscape(); if (ch >= 0 && isIdentifierPart(ch, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; result += scanExtendedUnicodeEscape(); start = pos; continue; @@ -11204,7 +11320,7 @@ var ts; if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) { break; } - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; result += text.substring(start, pos); result += utf16EncodeAsString(ch); // Valid Unicode escape is always six characters @@ -11223,14 +11339,14 @@ var ts; var len = tokenValue.length; if (len >= 2 && len <= 12) { var ch = tokenValue.charCodeAt(0); - if (ch >= 97 /* a */ && ch <= 122 /* z */) { + if (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) { var keyword = textToKeyword.get(tokenValue); if (keyword !== undefined) { return token = keyword; } } } - return token = 79 /* Identifier */; + return token = 79 /* SyntaxKind.Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -11241,8 +11357,8 @@ var ts; while (true) { var ch = text.charCodeAt(pos); // Numeric separators are allowed anywhere within a numeric literal, except not at the beginning, or following another separator - if (ch === 95 /* _ */) { - tokenFlags |= 512 /* ContainsSeparator */; + if (ch === 95 /* CharacterCodes._ */) { + tokenFlags |= 512 /* TokenFlags.ContainsSeparator */; if (separatorAllowed) { separatorAllowed = false; isPreviousTokenSeparator = true; @@ -11257,101 +11373,101 @@ var ts; continue; } separatorAllowed = true; - if (!isDigit(ch) || ch - 48 /* _0 */ >= base) { + if (!isDigit(ch) || ch - 48 /* CharacterCodes._0 */ >= base) { break; } value += text[pos]; pos++; isPreviousTokenSeparator = false; } - if (text.charCodeAt(pos - 1) === 95 /* _ */) { + if (text.charCodeAt(pos - 1) === 95 /* CharacterCodes._ */) { // Literal ends with underscore - not allowed error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1); } return value; } function checkBigIntSuffix() { - if (text.charCodeAt(pos) === 110 /* n */) { + if (text.charCodeAt(pos) === 110 /* CharacterCodes.n */) { tokenValue += "n"; // Use base 10 instead of base 2 or base 8 for shorter literals - if (tokenFlags & 384 /* BinaryOrOctalSpecifier */) { + if (tokenFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { tokenValue = ts.parsePseudoBigInt(tokenValue) + "n"; } pos++; - return 9 /* BigIntLiteral */; + return 9 /* SyntaxKind.BigIntLiteral */; } else { // not a bigint, so can convert to number in simplified form // Number() may not support 0b or 0o, so use parseInt() instead - var numericValue = tokenFlags & 128 /* BinarySpecifier */ + var numericValue = tokenFlags & 128 /* TokenFlags.BinarySpecifier */ ? parseInt(tokenValue.slice(2), 2) // skip "0b" - : tokenFlags & 256 /* OctalSpecifier */ + : tokenFlags & 256 /* TokenFlags.OctalSpecifier */ ? parseInt(tokenValue.slice(2), 8) // skip "0o" : +tokenValue; tokenValue = "" + numericValue; - return 8 /* NumericLiteral */; + return 8 /* SyntaxKind.NumericLiteral */; } } function scan() { var _a; startPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; var asteriskSeen = false; while (true) { tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); // Special handling for shebang - if (ch === 35 /* hash */ && pos === 0 && isShebangTrivia(text, pos)) { + if (ch === 35 /* CharacterCodes.hash */ && pos === 0 && isShebangTrivia(text, pos)) { pos = scanShebangTrivia(text, pos); if (skipTrivia) { continue; } else { - return token = 6 /* ShebangTrivia */; + return token = 6 /* SyntaxKind.ShebangTrivia */; } } switch (ch) { - case 10 /* lineFeed */: - case 13 /* carriageReturn */: - tokenFlags |= 1 /* PrecedingLineBreak */; + case 10 /* CharacterCodes.lineFeed */: + case 13 /* CharacterCodes.carriageReturn */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; if (skipTrivia) { pos++; continue; } else { - if (ch === 13 /* carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + if (ch === 13 /* CharacterCodes.carriageReturn */ && pos + 1 < end && text.charCodeAt(pos + 1) === 10 /* CharacterCodes.lineFeed */) { // consume both CR and LF pos += 2; } else { pos++; } - return token = 4 /* NewLineTrivia */; - } - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: - case 160 /* nonBreakingSpace */: - case 5760 /* ogham */: - case 8192 /* enQuad */: - case 8193 /* emQuad */: - case 8194 /* enSpace */: - case 8195 /* emSpace */: - case 8196 /* threePerEmSpace */: - case 8197 /* fourPerEmSpace */: - case 8198 /* sixPerEmSpace */: - case 8199 /* figureSpace */: - case 8200 /* punctuationSpace */: - case 8201 /* thinSpace */: - case 8202 /* hairSpace */: - case 8203 /* zeroWidthSpace */: - case 8239 /* narrowNoBreakSpace */: - case 8287 /* mathematicalSpace */: - case 12288 /* ideographicSpace */: - case 65279 /* byteOrderMark */: + return token = 4 /* SyntaxKind.NewLineTrivia */; + } + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: + case 160 /* CharacterCodes.nonBreakingSpace */: + case 5760 /* CharacterCodes.ogham */: + case 8192 /* CharacterCodes.enQuad */: + case 8193 /* CharacterCodes.emQuad */: + case 8194 /* CharacterCodes.enSpace */: + case 8195 /* CharacterCodes.emSpace */: + case 8196 /* CharacterCodes.threePerEmSpace */: + case 8197 /* CharacterCodes.fourPerEmSpace */: + case 8198 /* CharacterCodes.sixPerEmSpace */: + case 8199 /* CharacterCodes.figureSpace */: + case 8200 /* CharacterCodes.punctuationSpace */: + case 8201 /* CharacterCodes.thinSpace */: + case 8202 /* CharacterCodes.hairSpace */: + case 8203 /* CharacterCodes.zeroWidthSpace */: + case 8239 /* CharacterCodes.narrowNoBreakSpace */: + case 8287 /* CharacterCodes.mathematicalSpace */: + case 12288 /* CharacterCodes.ideographicSpace */: + case 65279 /* CharacterCodes.byteOrderMark */: if (skipTrivia) { pos++; continue; @@ -11360,98 +11476,98 @@ var ts; while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; + return token = 5 /* SyntaxKind.WhitespaceTrivia */; } - case 33 /* exclamation */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; + case 33 /* CharacterCodes.exclamation */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } - return pos += 2, token = 35 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* SyntaxKind.ExclamationEqualsToken */; } pos++; - return token = 53 /* ExclamationToken */; - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + return token = 53 /* SyntaxKind.ExclamationToken */; + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(); - return token = 10 /* StringLiteral */; - case 96 /* backtick */: + return token = 10 /* SyntaxKind.StringLiteral */; + case 96 /* CharacterCodes.backtick */: return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); - case 37 /* percent */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* PercentEqualsToken */; + case 37 /* CharacterCodes.percent */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 69 /* SyntaxKind.PercentEqualsToken */; } pos++; - return token = 44 /* PercentToken */; - case 38 /* ampersand */: - if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 76 /* AmpersandAmpersandEqualsToken */; + return token = 44 /* SyntaxKind.PercentToken */; + case 38 /* CharacterCodes.ampersand */: + if (text.charCodeAt(pos + 1) === 38 /* CharacterCodes.ampersand */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */; } - return pos += 2, token = 55 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* SyntaxKind.AmpersandAmpersandToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 73 /* AmpersandEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 73 /* SyntaxKind.AmpersandEqualsToken */; } pos++; - return token = 50 /* AmpersandToken */; - case 40 /* openParen */: + return token = 50 /* SyntaxKind.AmpersandToken */; + case 40 /* CharacterCodes.openParen */: pos++; - return token = 20 /* OpenParenToken */; - case 41 /* closeParen */: + return token = 20 /* SyntaxKind.OpenParenToken */; + case 41 /* CharacterCodes.closeParen */: pos++; - return token = 21 /* CloseParenToken */; - case 42 /* asterisk */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* AsteriskEqualsToken */; - } - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* AsteriskAsteriskEqualsToken */; + return token = 21 /* SyntaxKind.CloseParenToken */; + case 42 /* CharacterCodes.asterisk */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 66 /* SyntaxKind.AsteriskEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 42 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* SyntaxKind.AsteriskAsteriskToken */; } pos++; - if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { + if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* TokenFlags.PrecedingLineBreak */)) { // decoration at the start of a JSDoc comment line asteriskSeen = true; continue; } - return token = 41 /* AsteriskToken */; - case 43 /* plus */: - if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 45 /* PlusPlusToken */; + return token = 41 /* SyntaxKind.AsteriskToken */; + case 43 /* CharacterCodes.plus */: + if (text.charCodeAt(pos + 1) === 43 /* CharacterCodes.plus */) { + return pos += 2, token = 45 /* SyntaxKind.PlusPlusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* PlusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 64 /* SyntaxKind.PlusEqualsToken */; } pos++; - return token = 39 /* PlusToken */; - case 44 /* comma */: + return token = 39 /* SyntaxKind.PlusToken */; + case 44 /* CharacterCodes.comma */: pos++; - return token = 27 /* CommaToken */; - case 45 /* minus */: - if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 46 /* MinusMinusToken */; + return token = 27 /* SyntaxKind.CommaToken */; + case 45 /* CharacterCodes.minus */: + if (text.charCodeAt(pos + 1) === 45 /* CharacterCodes.minus */) { + return pos += 2, token = 46 /* SyntaxKind.MinusMinusToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* MinusEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 65 /* SyntaxKind.MinusEqualsToken */; } pos++; - return token = 40 /* MinusToken */; - case 46 /* dot */: + return token = 40 /* SyntaxKind.MinusToken */; + case 46 /* CharacterCodes.dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; - return token = 8 /* NumericLiteral */; + return token = 8 /* SyntaxKind.NumericLiteral */; } - if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 25 /* DotDotDotToken */; + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && text.charCodeAt(pos + 2) === 46 /* CharacterCodes.dot */) { + return pos += 3, token = 25 /* SyntaxKind.DotDotDotToken */; } pos++; - return token = 24 /* DotToken */; - case 47 /* slash */: + return token = 24 /* SyntaxKind.DotToken */; + case 47 /* CharacterCodes.slash */: // Single-line comment - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; while (pos < end) { if (isLineBreak(text.charCodeAt(pos))) { @@ -11464,20 +11580,20 @@ var ts; continue; } else { - return token = 2 /* SingleLineCommentTrivia */; + return token = 2 /* SyntaxKind.SingleLineCommentTrivia */; } } // Multi-line comment - if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) { pos += 2; - if (text.charCodeAt(pos) === 42 /* asterisk */ && text.charCodeAt(pos + 1) !== 47 /* slash */) { - tokenFlags |= 2 /* PrecedingJSDocComment */; + if (text.charCodeAt(pos) === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) !== 47 /* CharacterCodes.slash */) { + tokenFlags |= 2 /* TokenFlags.PrecedingJSDocComment */; } var commentClosed = false; var lastLineStart = tokenPos; while (pos < end) { var ch_1 = text.charCodeAt(pos); - if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { + if (ch_1 === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; commentClosed = true; break; @@ -11485,7 +11601,7 @@ var ts; pos++; if (isLineBreak(ch_1)) { lastLineStart = pos; - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; } } commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart); @@ -11497,18 +11613,18 @@ var ts; } else { if (!commentClosed) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; } - return token = 3 /* MultiLineCommentTrivia */; + return token = 3 /* SyntaxKind.MultiLineCommentTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* SlashEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 68 /* SyntaxKind.SlashEqualsToken */; } pos++; - return token = 43 /* SlashToken */; - case 48 /* _0 */: - if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { + return token = 43 /* SyntaxKind.SlashToken */; + case 48 /* CharacterCodes._0 */: + if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* CharacterCodes.X */ || text.charCodeAt(pos + 1) === 120 /* CharacterCodes.x */)) { pos += 2; tokenValue = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ true); if (!tokenValue) { @@ -11516,10 +11632,10 @@ var ts; tokenValue = "0"; } tokenValue = "0x" + tokenValue; - tokenFlags |= 64 /* HexSpecifier */; + tokenFlags |= 64 /* TokenFlags.HexSpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* CharacterCodes.B */ || text.charCodeAt(pos + 1) === 98 /* CharacterCodes.b */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 2); if (!tokenValue) { @@ -11527,10 +11643,10 @@ var ts; tokenValue = "0"; } tokenValue = "0b" + tokenValue; - tokenFlags |= 128 /* BinarySpecifier */; + tokenFlags |= 128 /* TokenFlags.BinarySpecifier */; return token = checkBigIntSuffix(); } - else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { + else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* CharacterCodes.O */ || text.charCodeAt(pos + 1) === 111 /* CharacterCodes.o */)) { pos += 2; tokenValue = scanBinaryOrOctalDigits(/* base */ 8); if (!tokenValue) { @@ -11538,175 +11654,175 @@ var ts; tokenValue = "0"; } tokenValue = "0o" + tokenValue; - tokenFlags |= 256 /* OctalSpecifier */; + tokenFlags |= 256 /* TokenFlags.OctalSpecifier */; return token = checkBigIntSuffix(); } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); - tokenFlags |= 32 /* Octal */; - return token = 8 /* NumericLiteral */; + tokenFlags |= 32 /* TokenFlags.Octal */; + return token = 8 /* SyntaxKind.NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). // falls through - case 49 /* _1 */: - case 50 /* _2 */: - case 51 /* _3 */: - case 52 /* _4 */: - case 53 /* _5 */: - case 54 /* _6 */: - case 55 /* _7 */: - case 56 /* _8 */: - case 57 /* _9 */: + case 49 /* CharacterCodes._1 */: + case 50 /* CharacterCodes._2 */: + case 51 /* CharacterCodes._3 */: + case 52 /* CharacterCodes._4 */: + case 53 /* CharacterCodes._5 */: + case 54 /* CharacterCodes._6 */: + case 55 /* CharacterCodes._7 */: + case 56 /* CharacterCodes._8 */: + case 57 /* CharacterCodes._9 */: (_a = scanNumber(), token = _a.type, tokenValue = _a.value); return token; - case 58 /* colon */: + case 58 /* CharacterCodes.colon */: pos++; - return token = 58 /* ColonToken */; - case 59 /* semicolon */: + return token = 58 /* SyntaxKind.ColonToken */; + case 59 /* CharacterCodes.semicolon */: pos++; - return token = 26 /* SemicolonToken */; - case 60 /* lessThan */: + return token = 26 /* SyntaxKind.SemicolonToken */; + case 60 /* CharacterCodes.lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 70 /* LessThanLessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 70 /* SyntaxKind.LessThanLessThanEqualsToken */; } - return pos += 2, token = 47 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* SyntaxKind.LessThanLessThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 32 /* LessThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 32 /* SyntaxKind.LessThanEqualsToken */; } - if (languageVariant === 1 /* JSX */ && - text.charCodeAt(pos + 1) === 47 /* slash */ && - text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 30 /* LessThanSlashToken */; + if (languageVariant === 1 /* LanguageVariant.JSX */ && + text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */ && + text.charCodeAt(pos + 2) !== 42 /* CharacterCodes.asterisk */) { + return pos += 2, token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; - case 61 /* equals */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 61 /* CharacterCodes.equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 36 /* SyntaxKind.EqualsEqualsEqualsToken */; } - return pos += 2, token = 34 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* SyntaxKind.EqualsEqualsToken */; } - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 38 /* EqualsGreaterThanToken */; + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + return pos += 2, token = 38 /* SyntaxKind.EqualsGreaterThanToken */; } pos++; - return token = 63 /* EqualsToken */; - case 62 /* greaterThan */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 62 /* CharacterCodes.greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } pos++; - return token = 31 /* GreaterThanToken */; - case 63 /* question */: - if (text.charCodeAt(pos + 1) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 2))) { - return pos += 2, token = 28 /* QuestionDotToken */; - } - if (text.charCodeAt(pos + 1) === 63 /* question */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 77 /* QuestionQuestionEqualsToken */; + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 63 /* CharacterCodes.question */: + if (text.charCodeAt(pos + 1) === 46 /* CharacterCodes.dot */ && !isDigit(text.charCodeAt(pos + 2))) { + return pos += 2, token = 28 /* SyntaxKind.QuestionDotToken */; + } + if (text.charCodeAt(pos + 1) === 63 /* CharacterCodes.question */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } - return pos += 2, token = 60 /* QuestionQuestionToken */; + return pos += 2, token = 60 /* SyntaxKind.QuestionQuestionToken */; } pos++; - return token = 57 /* QuestionToken */; - case 91 /* openBracket */: + return token = 57 /* SyntaxKind.QuestionToken */; + case 91 /* CharacterCodes.openBracket */: pos++; - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: pos++; - return token = 23 /* CloseBracketToken */; - case 94 /* caret */: - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 78 /* CaretEqualsToken */; + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 94 /* CharacterCodes.caret */: + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 78 /* SyntaxKind.CaretEqualsToken */; } pos++; - return token = 52 /* CaretToken */; - case 123 /* openBrace */: + return token = 52 /* SyntaxKind.CaretToken */; + case 123 /* CharacterCodes.openBrace */: pos++; - return token = 18 /* OpenBraceToken */; - case 124 /* bar */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 124 /* CharacterCodes.bar */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); if (skipTrivia) { continue; } else { - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } } - if (text.charCodeAt(pos + 1) === 124 /* bar */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 75 /* BarBarEqualsToken */; + if (text.charCodeAt(pos + 1) === 124 /* CharacterCodes.bar */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 75 /* SyntaxKind.BarBarEqualsToken */; } - return pos += 2, token = 56 /* BarBarToken */; + return pos += 2, token = 56 /* SyntaxKind.BarBarToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 74 /* BarEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 74 /* SyntaxKind.BarEqualsToken */; } pos++; - return token = 51 /* BarToken */; - case 125 /* closeBrace */: + return token = 51 /* SyntaxKind.BarToken */; + case 125 /* CharacterCodes.closeBrace */: pos++; - return token = 19 /* CloseBraceToken */; - case 126 /* tilde */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 126 /* CharacterCodes.tilde */: pos++; - return token = 54 /* TildeToken */; - case 64 /* at */: + return token = 54 /* SyntaxKind.TildeToken */; + case 64 /* CharacterCodes.at */: pos++; - return token = 59 /* AtToken */; - case 92 /* backslash */: + return token = 59 /* SyntaxKind.AtToken */; + case 92 /* CharacterCodes.backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } error(ts.Diagnostics.Invalid_character); pos++; - return token = 0 /* Unknown */; - case 35 /* hash */: + return token = 0 /* SyntaxKind.Unknown */; + case 35 /* CharacterCodes.hash */: if (pos !== 0 && text[pos + 1] === "!") { error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file); pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(codePointAt(text, pos + 1), languageVersion)) { pos++; @@ -11716,7 +11832,7 @@ var ts; tokenValue = String.fromCharCode(codePointAt(text, pos)); error(ts.Diagnostics.Invalid_character, pos++, charSize(ch)); } - return token = 80 /* PrivateIdentifier */; + return token = 80 /* SyntaxKind.PrivateIdentifier */; default: var identifierKind = scanIdentifier(ch, languageVersion); if (identifierKind) { @@ -11727,23 +11843,23 @@ var ts; continue; } else if (isLineBreak(ch)) { - tokenFlags |= 1 /* PrecedingLineBreak */; + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; pos += charSize(ch); continue; } var size = charSize(ch); error(ts.Diagnostics.Invalid_character, pos, size); pos += size; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } } function reScanInvalidIdentifier() { - ts.Debug.assert(token === 0 /* Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); + ts.Debug.assert(token === 0 /* SyntaxKind.Unknown */, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'."); pos = tokenPos = startPos; tokenFlags = 0; var ch = codePointAt(text, pos); - var identifierKind = scanIdentifier(ch, 99 /* ESNext */); + var identifierKind = scanIdentifier(ch, 99 /* ScriptTarget.ESNext */); if (identifierKind) { return token = identifierKind; } @@ -11757,41 +11873,41 @@ var ts; while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion)) pos += charSize(ch); tokenValue = text.substring(tokenPos, pos); - if (ch === 92 /* backslash */) { + if (ch === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return getIdentifierToken(); } } function reScanGreaterToken() { - if (token === 31 /* GreaterThanToken */) { - if (text.charCodeAt(pos) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + if (token === 31 /* SyntaxKind.GreaterThanToken */) { + if (text.charCodeAt(pos) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 1) === 62 /* CharacterCodes.greaterThan */) { + if (text.charCodeAt(pos + 2) === 61 /* CharacterCodes.equals */) { + return pos += 3, token = 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* GreaterThanGreaterThanEqualsToken */; + if (text.charCodeAt(pos + 1) === 61 /* CharacterCodes.equals */) { + return pos += 2, token = 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 48 /* GreaterThanGreaterThanToken */; + return token = 48 /* SyntaxKind.GreaterThanGreaterThanToken */; } - if (text.charCodeAt(pos) === 61 /* equals */) { + if (text.charCodeAt(pos) === 61 /* CharacterCodes.equals */) { pos++; - return token = 33 /* GreaterThanEqualsToken */; + return token = 33 /* SyntaxKind.GreaterThanEqualsToken */; } } return token; } function reScanAsteriskEqualsToken() { - ts.Debug.assert(token === 66 /* AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); + ts.Debug.assert(token === 66 /* SyntaxKind.AsteriskEqualsToken */, "'reScanAsteriskEqualsToken' should only be called on a '*='"); pos = tokenPos + 1; - return token = 63 /* EqualsToken */; + return token = 63 /* SyntaxKind.EqualsToken */; } function reScanSlashToken() { - if (token === 43 /* SlashToken */ || token === 68 /* SlashEqualsToken */) { + if (token === 43 /* SyntaxKind.SlashToken */ || token === 68 /* SyntaxKind.SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -11799,13 +11915,13 @@ var ts; // If we reach the end of a file, or hit a newline, then this is an unterminated // regex. Report error and return what we have so far. if (p >= end) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } var ch = text.charCodeAt(p); if (isLineBreak(ch)) { - tokenFlags |= 4 /* Unterminated */; + tokenFlags |= 4 /* TokenFlags.Unterminated */; error(ts.Diagnostics.Unterminated_regular_expression_literal); break; } @@ -11814,19 +11930,19 @@ var ts; // reset the flag and just advance to the next char. inEscape = false; } - else if (ch === 47 /* slash */ && !inCharacterClass) { + else if (ch === 47 /* CharacterCodes.slash */ && !inCharacterClass) { // A slash within a character class is permissible, // but in general it signals the end of the regexp literal. p++; break; } - else if (ch === 91 /* openBracket */) { + else if (ch === 91 /* CharacterCodes.openBracket */) { inCharacterClass = true; } - else if (ch === 92 /* backslash */) { + else if (ch === 92 /* CharacterCodes.backslash */) { inEscape = true; } - else if (ch === 93 /* closeBracket */) { + else if (ch === 93 /* CharacterCodes.closeBracket */) { inCharacterClass = false; } p++; @@ -11836,7 +11952,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 13 /* RegularExpressionLiteral */; + token = 13 /* SyntaxKind.RegularExpressionLiteral */; } return token; } @@ -11857,9 +11973,9 @@ var ts; } switch (match[1]) { case "ts-expect-error": - return 0 /* ExpectError */; + return 0 /* CommentDirectiveType.ExpectError */; case "ts-ignore": - return 1 /* Ignore */; + return 1 /* CommentDirectiveType.Ignore */; } return undefined; } @@ -11867,7 +11983,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken(isTaggedTemplate) { - ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 19 /* SyntaxKind.CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(isTaggedTemplate); } @@ -11881,42 +11997,42 @@ var ts; return token = scanJsxToken(allowMultilineJsxText); } function reScanLessThanToken() { - if (token === 47 /* LessThanLessThanToken */) { + if (token === 47 /* SyntaxKind.LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } return token; } function reScanHashToken() { - if (token === 80 /* PrivateIdentifier */) { + if (token === 80 /* SyntaxKind.PrivateIdentifier */) { pos = tokenPos + 1; - return token = 62 /* HashToken */; + return token = 62 /* SyntaxKind.HashToken */; } return token; } function reScanQuestionToken() { - ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + ts.Debug.assert(token === 60 /* SyntaxKind.QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); pos = tokenPos + 1; - return token = 57 /* QuestionToken */; + return token = 57 /* SyntaxKind.QuestionToken */; } function scanJsxToken(allowMultilineJsxText) { if (allowMultilineJsxText === void 0) { allowMultilineJsxText = true; } startPos = tokenPos = pos; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var char = text.charCodeAt(pos); - if (char === 60 /* lessThan */) { - if (text.charCodeAt(pos + 1) === 47 /* slash */) { + if (char === 60 /* CharacterCodes.lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) { pos += 2; - return token = 30 /* LessThanSlashToken */; + return token = 30 /* SyntaxKind.LessThanSlashToken */; } pos++; - return token = 29 /* LessThanToken */; + return token = 29 /* SyntaxKind.LessThanToken */; } - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { pos++; - return token = 18 /* OpenBraceToken */; + return token = 18 /* SyntaxKind.OpenBraceToken */; } // First non-whitespace character on this line. var firstNonWhitespace = 0; @@ -11924,20 +12040,20 @@ var ts; // firstNonWhitespace = 0 to indicate that we want leading whitespace, while (pos < end) { char = text.charCodeAt(pos); - if (char === 123 /* openBrace */) { + if (char === 123 /* CharacterCodes.openBrace */) { break; } - if (char === 60 /* lessThan */) { + if (char === 60 /* CharacterCodes.lessThan */) { if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); - return token = 7 /* ConflictMarkerTrivia */; + return token = 7 /* SyntaxKind.ConflictMarkerTrivia */; } break; } - if (char === 62 /* greaterThan */) { + if (char === 62 /* CharacterCodes.greaterThan */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1); } - if (char === 125 /* closeBrace */) { + if (char === 125 /* CharacterCodes.closeBrace */) { error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); } // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. @@ -11960,7 +12076,7 @@ var ts; pos++; } tokenValue = text.substring(startPos, pos); - return firstNonWhitespace === -1 ? 12 /* JsxTextAllWhiteSpaces */ : 11 /* JsxText */; + return firstNonWhitespace === -1 ? 12 /* SyntaxKind.JsxTextAllWhiteSpaces */ : 11 /* SyntaxKind.JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -11973,16 +12089,16 @@ var ts; var namespaceSeparator = false; while (pos < end) { var ch = text.charCodeAt(pos); - if (ch === 45 /* minus */) { + if (ch === 45 /* CharacterCodes.minus */) { tokenValue += "-"; pos++; continue; } - else if (ch === 58 /* colon */ && !namespaceSeparator) { + else if (ch === 58 /* CharacterCodes.colon */ && !namespaceSeparator) { tokenValue += ":"; pos++; namespaceSeparator = true; - token = 79 /* Identifier */; // swap from keyword kind to identifier kind + token = 79 /* SyntaxKind.Identifier */; // swap from keyword kind to identifier kind continue; } var oldPos = pos; @@ -12003,10 +12119,10 @@ var ts; function scanJsxAttributeValue() { startPos = pos; switch (text.charCodeAt(pos)) { - case 34 /* doubleQuote */: - case 39 /* singleQuote */: + case 34 /* CharacterCodes.doubleQuote */: + case 39 /* CharacterCodes.singleQuote */: tokenValue = scanString(/*jsxAttributeString*/ true); - return token = 10 /* StringLiteral */; + return token = 10 /* SyntaxKind.StringLiteral */; default: // If this scans anything other than `{`, it's a parse error. return scan(); @@ -12018,86 +12134,86 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; if (pos >= end) { - return token = 1 /* EndOfFileToken */; + return token = 1 /* SyntaxKind.EndOfFileToken */; } var ch = codePointAt(text, pos); pos += charSize(ch); switch (ch) { - case 9 /* tab */: - case 11 /* verticalTab */: - case 12 /* formFeed */: - case 32 /* space */: + case 9 /* CharacterCodes.tab */: + case 11 /* CharacterCodes.verticalTab */: + case 12 /* CharacterCodes.formFeed */: + case 32 /* CharacterCodes.space */: while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { pos++; } - return token = 5 /* WhitespaceTrivia */; - case 64 /* at */: - return token = 59 /* AtToken */; - case 13 /* carriageReturn */: - if (text.charCodeAt(pos) === 10 /* lineFeed */) { + return token = 5 /* SyntaxKind.WhitespaceTrivia */; + case 64 /* CharacterCodes.at */: + return token = 59 /* SyntaxKind.AtToken */; + case 13 /* CharacterCodes.carriageReturn */: + if (text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) { pos++; } // falls through - case 10 /* lineFeed */: - tokenFlags |= 1 /* PrecedingLineBreak */; - return token = 4 /* NewLineTrivia */; - case 42 /* asterisk */: - return token = 41 /* AsteriskToken */; - case 123 /* openBrace */: - return token = 18 /* OpenBraceToken */; - case 125 /* closeBrace */: - return token = 19 /* CloseBraceToken */; - case 91 /* openBracket */: - return token = 22 /* OpenBracketToken */; - case 93 /* closeBracket */: - return token = 23 /* CloseBracketToken */; - case 60 /* lessThan */: - return token = 29 /* LessThanToken */; - case 62 /* greaterThan */: - return token = 31 /* GreaterThanToken */; - case 61 /* equals */: - return token = 63 /* EqualsToken */; - case 44 /* comma */: - return token = 27 /* CommaToken */; - case 46 /* dot */: - return token = 24 /* DotToken */; - case 96 /* backtick */: - return token = 61 /* BacktickToken */; - case 35 /* hash */: - return token = 62 /* HashToken */; - case 92 /* backslash */: + case 10 /* CharacterCodes.lineFeed */: + tokenFlags |= 1 /* TokenFlags.PrecedingLineBreak */; + return token = 4 /* SyntaxKind.NewLineTrivia */; + case 42 /* CharacterCodes.asterisk */: + return token = 41 /* SyntaxKind.AsteriskToken */; + case 123 /* CharacterCodes.openBrace */: + return token = 18 /* SyntaxKind.OpenBraceToken */; + case 125 /* CharacterCodes.closeBrace */: + return token = 19 /* SyntaxKind.CloseBraceToken */; + case 91 /* CharacterCodes.openBracket */: + return token = 22 /* SyntaxKind.OpenBracketToken */; + case 93 /* CharacterCodes.closeBracket */: + return token = 23 /* SyntaxKind.CloseBracketToken */; + case 60 /* CharacterCodes.lessThan */: + return token = 29 /* SyntaxKind.LessThanToken */; + case 62 /* CharacterCodes.greaterThan */: + return token = 31 /* SyntaxKind.GreaterThanToken */; + case 61 /* CharacterCodes.equals */: + return token = 63 /* SyntaxKind.EqualsToken */; + case 44 /* CharacterCodes.comma */: + return token = 27 /* SyntaxKind.CommaToken */; + case 46 /* CharacterCodes.dot */: + return token = 24 /* SyntaxKind.DotToken */; + case 96 /* CharacterCodes.backtick */: + return token = 61 /* SyntaxKind.BacktickToken */; + case 35 /* CharacterCodes.hash */: + return token = 62 /* SyntaxKind.HashToken */; + case 92 /* CharacterCodes.backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { pos += 3; - tokenFlags |= 8 /* ExtendedUnicodeEscape */; + tokenFlags |= 8 /* TokenFlags.ExtendedUnicodeEscape */; tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts(); return token = getIdentifierToken(); } var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { pos += 6; - tokenFlags |= 1024 /* UnicodeEscape */; + tokenFlags |= 1024 /* TokenFlags.UnicodeEscape */; tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts(); return token = getIdentifierToken(); } pos++; - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); - if (char === 92 /* backslash */) { + if (char === 92 /* CharacterCodes.backslash */) { tokenValue += scanIdentifierParts(); } return token = getIdentifierToken(); } else { - return token = 0 /* Unknown */; + return token = 0 /* SyntaxKind.Unknown */; } } function speculationHelper(callback, isLookahead) { @@ -12172,9 +12288,9 @@ var ts; pos = textPos; startPos = textPos; tokenPos = textPos; - token = 0 /* Unknown */; + token = 0 /* SyntaxKind.Unknown */; tokenValue = undefined; - tokenFlags = 0 /* None */; + tokenFlags = 0 /* TokenFlags.None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -12240,23 +12356,23 @@ var ts; ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics; function getDefaultLibFileName(options) { switch (ts.getEmitScriptTarget(options)) { - case 99 /* ESNext */: + case 99 /* ScriptTarget.ESNext */: return "lib.esnext.full.d.ts"; - case 9 /* ES2022 */: + case 9 /* ScriptTarget.ES2022 */: return "lib.es2022.full.d.ts"; - case 8 /* ES2021 */: + case 8 /* ScriptTarget.ES2021 */: return "lib.es2021.full.d.ts"; - case 7 /* ES2020 */: + case 7 /* ScriptTarget.ES2020 */: return "lib.es2020.full.d.ts"; - case 6 /* ES2019 */: + case 6 /* ScriptTarget.ES2019 */: return "lib.es2019.full.d.ts"; - case 5 /* ES2018 */: + case 5 /* ScriptTarget.ES2018 */: return "lib.es2018.full.d.ts"; - case 4 /* ES2017 */: + case 4 /* ScriptTarget.ES2017 */: return "lib.es2017.full.d.ts"; - case 3 /* ES2016 */: + case 3 /* ScriptTarget.ES2016 */: return "lib.es2016.full.d.ts"; - case 2 /* ES2015 */: + case 2 /* ScriptTarget.ES2015 */: return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; @@ -12464,9 +12580,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 163 /* TypeParameter */) { + if (d && d.kind === 163 /* SyntaxKind.TypeParameter */) { for (var current = d; current; current = current.parent) { - if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* InterfaceDeclaration */) { + if (isFunctionLike(current) || isClassLike(current) || current.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return current; } } @@ -12474,7 +12590,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */) && parent.kind === 171 /* Constructor */; + return ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */) && parent.kind === 171 /* SyntaxKind.Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -12504,14 +12620,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 254 /* VariableDeclaration */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 255 /* VariableDeclarationList */) { + if (node && node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 237 /* VariableStatement */) { + if (node && node.kind === 237 /* SyntaxKind.VariableStatement */) { flags |= getFlags(node); } return flags; @@ -12625,7 +12741,7 @@ var ts; * @param node The node to test. */ function isParseTreeNode(node) { - return (node.flags & 8 /* Synthesized */) === 0; + return (node.flags & 8 /* NodeFlags.Synthesized */) === 0; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { @@ -12643,7 +12759,7 @@ var ts; ts.getParseTreeNode = getParseTreeNode; /** Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' */ function escapeLeadingUnderscores(identifier) { - return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* _ */ && identifier.charCodeAt(1) === 95 /* _ */ ? "_" + identifier : identifier); + return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 /* CharacterCodes._ */ && identifier.charCodeAt(1) === 95 /* CharacterCodes._ */ ? "_" + identifier : identifier); } ts.escapeLeadingUnderscores = escapeLeadingUnderscores; /** @@ -12654,7 +12770,7 @@ var ts; */ function unescapeLeadingUnderscores(identifier) { var id = identifier; - return id.length >= 3 && id.charCodeAt(0) === 95 /* _ */ && id.charCodeAt(1) === 95 /* _ */ && id.charCodeAt(2) === 95 /* _ */ ? id.substr(1) : id; + return id.length >= 3 && id.charCodeAt(0) === 95 /* CharacterCodes._ */ && id.charCodeAt(1) === 95 /* CharacterCodes._ */ && id.charCodeAt(2) === 95 /* CharacterCodes._ */ ? id.substr(1) : id; } ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores; function idText(identifierOrPrivateName) { @@ -12684,30 +12800,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 221 /* BinaryExpression */ && expr.operatorToken.kind === 63 /* EqualsToken */) { + if (expr.kind === 221 /* SyntaxKind.BinaryExpression */ && expr.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return expr.name; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 250 /* LabeledStatement */: { + case 250 /* SyntaxKind.LabeledStatement */: { if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -12742,42 +12858,42 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return declaration; - case 347 /* JSDocPropertyTag */: - case 340 /* JSDocParameterTag */: { + case 347 /* SyntaxKind.JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 161 /* QualifiedName */) { + if (name.kind === 161 /* SyntaxKind.QualifiedName */) { return name.right; } break; } - case 208 /* CallExpression */: - case 221 /* BinaryExpression */: { + case 208 /* SyntaxKind.CallExpression */: + case 221 /* SyntaxKind.BinaryExpression */: { var expr_1 = declaration; switch (ts.getAssignmentDeclarationKind(expr_1)) { - case 1 /* ExportsProperty */: - case 4 /* ThisProperty */: - case 5 /* Property */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return expr_1.arguments[1]; default: return undefined; } } - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 339 /* JSDocEnumTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = declaration; if (ts.isBindableStaticElementAccessExpression(expr)) { return expr.argumentExpression; @@ -12821,7 +12937,7 @@ var ts; } ts.getDecorators = getDecorators; function getModifiers(node) { - if (ts.hasSyntacticModifier(node, 125951 /* Modifier */)) { + if (ts.hasSyntacticModifier(node, 125951 /* ModifierFlags.Modifier */)) { return ts.filter(node.modifiers, isModifier); } } @@ -13082,27 +13198,33 @@ var ts; /** Gets the text of a jsdoc comment, flattening links to their text. */ function getTextOfJSDocComment(comment) { return typeof comment === "string" ? comment - : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); + : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 321 /* SyntaxKind.JSDocText */ ? c.text : formatJSDocLink(c); }).join(""); } ts.getTextOfJSDocComment = getTextOfJSDocComment; function formatJSDocLink(link) { - var kind = link.kind === 324 /* JSDocLink */ ? "link" - : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" + var kind = link.kind === 324 /* SyntaxKind.JSDocLink */ ? "link" + : link.kind === 325 /* SyntaxKind.JSDocLinkCode */ ? "linkcode" : "linkplain"; var name = link.name ? ts.entityNameToString(link.name) : ""; var space = link.name && link.text.startsWith("://") ? "" : " "; - return "{@" + kind + " " + name + space + link.text + "}"; + return "{@".concat(kind, " ").concat(name).concat(space).concat(link.text, "}"); } /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. + * + * This does *not* return type parameters from a jsdoc reference to a generic type, eg + * + * type Id = (x: T) => T + * /** @type {Id} / + * function id(x) { return x } */ function getEffectiveTypeParameterDeclarations(node) { if (ts.isJSDocSignature(node)) { return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 320 /* JSDoc */); + ts.Debug.assert(node.parent.kind === 320 /* SyntaxKind.JSDoc */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13132,33 +13254,33 @@ var ts; ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; // #region function isMemberName(node) { - return node.kind === 79 /* Identifier */ || node.kind === 80 /* PrivateIdentifier */; + return node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isMemberName = isMemberName; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */ || node.kind === 172 /* GetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */ || node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isPropertyAccessChain(node) { - return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isPropertyAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessChain(node) { - return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isElementAccessExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isElementAccessChain = isElementAccessChain; function isCallChain(node) { - return ts.isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isCallExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isCallChain = isCallChain; function isOptionalChain(node) { var kind = node.kind; - return !!(node.flags & 32 /* OptionalChain */) && - (kind === 206 /* PropertyAccessExpression */ - || kind === 207 /* ElementAccessExpression */ - || kind === 208 /* CallExpression */ - || kind === 230 /* NonNullExpression */); + return !!(node.flags & 32 /* NodeFlags.OptionalChain */) && + (kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 207 /* SyntaxKind.ElementAccessExpression */ + || kind === 208 /* SyntaxKind.CallExpression */ + || kind === 230 /* SyntaxKind.NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ @@ -13193,7 +13315,7 @@ var ts; } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */; } ts.isNullishCoalesce = isNullishCoalesce; function isConstTypeReference(node) { @@ -13202,25 +13324,25 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function skipPartiallyEmittedExpressions(node) { - return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */); + return ts.skipOuterExpressions(node, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isNonNullChain(node) { - return ts.isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */); + return ts.isNonNullExpression(node) && !!(node.flags & 32 /* NodeFlags.OptionalChain */); } ts.isNonNullChain = isNonNullChain; function isBreakOrContinueStatement(node) { - return node.kind === 246 /* BreakStatement */ || node.kind === 245 /* ContinueStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */ || node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isNamedExportBindings(node) { - return node.kind === 274 /* NamespaceExport */ || node.kind === 273 /* NamedExports */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExportBindings = isNamedExportBindings; function isUnparsedTextLike(node) { switch (node.kind) { - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return true; default: return false; @@ -13229,12 +13351,12 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 300 /* UnparsedPrologue */ || - node.kind === 304 /* UnparsedSyntheticReference */; + node.kind === 300 /* SyntaxKind.UnparsedPrologue */ || + node.kind === 304 /* SyntaxKind.UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; function isJSDocPropertyLikeTag(node) { - return node.kind === 347 /* JSDocPropertyTag */ || node.kind === 340 /* JSDocParameterTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */ || node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; // #endregion @@ -13250,7 +13372,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 161 /* FirstNode */; + return kind >= 161 /* SyntaxKind.FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -13259,7 +13381,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isTokenKind(kind) { - return kind >= 0 /* FirstToken */ && kind <= 160 /* LastToken */; + return kind >= 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */; } ts.isTokenKind = isTokenKind; /** @@ -13280,7 +13402,7 @@ var ts; // Literals /* @internal */ function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 14 /* LastLiteralToken */; + return 8 /* SyntaxKind.FirstLiteralToken */ <= kind && kind <= 14 /* SyntaxKind.LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isLiteralExpression(node) { @@ -13290,11 +13412,11 @@ var ts; /** @internal */ function isLiteralExpressionOfObject(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 13 /* RegularExpressionLiteral */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: return true; } return false; @@ -13303,7 +13425,7 @@ var ts; // Pseudo-literals /* @internal */ function isTemplateLiteralKind(kind) { - return 14 /* FirstTemplateToken */ <= kind && kind <= 17 /* LastTemplateToken */; + return 14 /* SyntaxKind.FirstTemplateToken */ <= kind && kind <= 17 /* SyntaxKind.LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateLiteralToken(node) { @@ -13312,8 +13434,8 @@ var ts; ts.isTemplateLiteralToken = isTemplateLiteralToken; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 16 /* TemplateMiddle */ - || kind === 17 /* TemplateTail */; + return kind === 16 /* SyntaxKind.TemplateMiddle */ + || kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isImportOrExportSpecifier(node) { @@ -13322,13 +13444,13 @@ var ts; ts.isImportOrExportSpecifier = isImportOrExportSpecifier; function isTypeOnlyImportOrExportDeclaration(node) { switch (node.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.isTypeOnly || node.parent.parent.isTypeOnly; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.isTypeOnly; - case 267 /* ImportClause */: - case 265 /* ImportEqualsDeclaration */: + case 267 /* SyntaxKind.ImportClause */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node.isTypeOnly; default: return false; @@ -13340,13 +13462,13 @@ var ts; } ts.isAssertionKey = isAssertionKey; function isStringTextContainingNode(node) { - return node.kind === 10 /* StringLiteral */ || isTemplateLiteralKind(node.kind); + return node.kind === 10 /* SyntaxKind.StringLiteral */ || isTemplateLiteralKind(node.kind); } ts.isStringTextContainingNode = isStringTextContainingNode; // Identifiers /* @internal */ function isGeneratedIdentifier(node) { - return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* KindMask */) > 0 /* None */; + return ts.isIdentifier(node) && (node.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) > 0 /* GeneratedIdentifierFlags.None */; } ts.isGeneratedIdentifier = isGeneratedIdentifier; // Private Identifiers @@ -13364,20 +13486,20 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 88 /* DefaultKeyword */: - case 93 /* ExportKeyword */: - case 101 /* InKeyword */: - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 124 /* StaticKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: return true; } return false; @@ -13385,12 +13507,12 @@ var ts; ts.isModifierKind = isModifierKind; /* @internal */ function isParameterPropertyModifier(kind) { - return !!(ts.modifierToFlag(kind) & 16476 /* ParameterPropertyModifier */); + return !!(ts.modifierToFlag(kind) & 16476 /* ModifierFlags.ParameterPropertyModifier */); } ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 124 /* StaticKeyword */ || idToken === 159 /* OverrideKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 124 /* SyntaxKind.StaticKeyword */ || idToken === 159 /* SyntaxKind.OverrideKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -13399,24 +13521,24 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 80 /* PrivateIdentifier */ - || kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 162 /* ComputedPropertyName */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 80 /* SyntaxKind.PrivateIdentifier */ + || kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */ + || kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 201 /* ObjectBindingPattern */ - || kind === 202 /* ArrayBindingPattern */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */ + || kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -13436,18 +13558,18 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; /* @internal */ function isBooleanLiteral(node) { - return node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */; + return node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */; } ts.isBooleanLiteral = isBooleanLiteral; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: return false; @@ -13456,14 +13578,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 180 /* ConstructorType */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -13478,30 +13600,30 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 234 /* SemicolonClassElement */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */); + return node && (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */); + return node && (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -13515,13 +13637,13 @@ var ts; ts.isModifierLike = isModifierLike; function isTypeElement(node) { var kind = node.kind; - return kind === 175 /* ConstructSignature */ - || kind === 174 /* CallSignature */ - || kind === 166 /* PropertySignature */ - || kind === 168 /* MethodSignature */ - || kind === 176 /* IndexSignature */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 175 /* SyntaxKind.ConstructSignature */ + || kind === 174 /* SyntaxKind.CallSignature */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -13530,12 +13652,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 298 /* SpreadAssignment */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 298 /* SyntaxKind.SpreadAssignment */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -13550,8 +13672,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return true; } return false; @@ -13562,8 +13684,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 202 /* ArrayBindingPattern */ - || kind === 201 /* ObjectBindingPattern */; + return kind === 202 /* SyntaxKind.ArrayBindingPattern */ + || kind === 201 /* SyntaxKind.ObjectBindingPattern */; } return false; } @@ -13571,15 +13693,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 204 /* ArrayLiteralExpression */ - || kind === 205 /* ObjectLiteralExpression */; + return kind === 204 /* SyntaxKind.ArrayLiteralExpression */ + || kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 203 /* BindingElement */ - || kind === 227 /* OmittedExpression */; + return kind === 203 /* SyntaxKind.BindingElement */ + || kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -13588,9 +13710,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: return true; } return false; @@ -13611,8 +13733,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return true; } return false; @@ -13621,10 +13743,10 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentElement(node) { switch (node.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: // AssignmentProperty - case 297 /* ShorthandPropertyAssignment */: // AssignmentProperty - case 298 /* SpreadAssignment */: // AssignmentRestProperty + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: // AssignmentProperty + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // AssignmentProperty + case 298 /* SyntaxKind.SpreadAssignment */: // AssignmentRestProperty return true; } return false; @@ -13636,8 +13758,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return true; } return false; @@ -13646,26 +13768,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */ - || kind === 200 /* ImportType */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 200 /* SyntaxKind.ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 206 /* PropertyAccessExpression */ - || kind === 161 /* QualifiedName */; + return kind === 206 /* SyntaxKind.PropertyAccessExpression */ + || kind === 161 /* SyntaxKind.QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: return true; default: return false; @@ -13673,13 +13795,13 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 208 /* CallExpression */ || node.kind === 209 /* NewExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */ || node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 223 /* TemplateExpression */ - || kind === 14 /* NoSubstitutionTemplateLiteral */; + return kind === 223 /* SyntaxKind.TemplateExpression */ + || kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; /* @internal */ @@ -13689,36 +13811,36 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 209 /* NewExpression */: - case 208 /* CallExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 210 /* TaggedTemplateExpression */: - case 204 /* ArrayLiteralExpression */: - case 212 /* ParenthesizedExpression */: - case 205 /* ObjectLiteralExpression */: - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression - case 13 /* RegularExpressionLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 110 /* TrueKeyword */: - case 106 /* SuperKeyword */: - case 230 /* NonNullExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 231 /* MetaProperty */: - case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: // technically this is only an Expression if it's in a `#field in expr` BinaryExpression + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 230 /* SyntaxKind.NonNullExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 231 /* SyntaxKind.MetaProperty */: + case 100 /* SyntaxKind.ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -13731,13 +13853,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 218 /* AwaitExpression */: - case 211 /* TypeAssertionExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -13746,11 +13868,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 45 /* PlusPlusToken */ || - expr.operator === 46 /* MinusMinusToken */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || + expr.operator === 46 /* SyntaxKind.MinusMinusToken */; default: return false; } @@ -13767,15 +13889,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - case 214 /* ArrowFunction */: - case 221 /* BinaryExpression */: - case 225 /* SpreadElement */: - case 229 /* AsExpression */: - case 227 /* OmittedExpression */: - case 351 /* CommaListExpression */: - case 350 /* PartiallyEmittedExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 221 /* SyntaxKind.BinaryExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 229 /* SyntaxKind.AsExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -13783,8 +13905,8 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 211 /* TypeAssertionExpression */ - || kind === 229 /* AsExpression */; + return kind === 211 /* SyntaxKind.TypeAssertionExpression */ + || kind === 229 /* SyntaxKind.AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ @@ -13795,13 +13917,13 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return true; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -13819,18 +13941,18 @@ var ts; ts.hasScopeMarker = hasScopeMarker; /* @internal */ function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */) && !ts.isAmbientModule(result); } ts.needsScopeMarker = needsScopeMarker; /* @internal */ function isExternalModuleIndicator(result) { // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* Export */); + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1 /* ModifierFlags.Export */); } ts.isExternalModuleIndicator = isExternalModuleIndicator; /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 243 /* ForInStatement */ || node.kind === 244 /* ForOfStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */ || node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -13854,115 +13976,115 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */ - || kind === 79 /* Identifier */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 262 /* ModuleBlock */ - || kind === 261 /* ModuleDeclaration */; + return kind === 262 /* SyntaxKind.ModuleBlock */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 79 /* Identifier */ - || kind === 261 /* ModuleDeclaration */; + return kind === 79 /* SyntaxKind.Identifier */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 269 /* NamedImports */ - || kind === 268 /* NamespaceImport */; + return kind === 269 /* SyntaxKind.NamedImports */ + || kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */ || node.kind === 260 /* EnumDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 214 /* ArrowFunction */ - || kind === 203 /* BindingElement */ - || kind === 257 /* ClassDeclaration */ - || kind === 226 /* ClassExpression */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 171 /* Constructor */ - || kind === 260 /* EnumDeclaration */ - || kind === 299 /* EnumMember */ - || kind === 275 /* ExportSpecifier */ - || kind === 256 /* FunctionDeclaration */ - || kind === 213 /* FunctionExpression */ - || kind === 172 /* GetAccessor */ - || kind === 267 /* ImportClause */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 270 /* ImportSpecifier */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 285 /* JsxAttribute */ - || kind === 169 /* MethodDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 261 /* ModuleDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 268 /* NamespaceImport */ - || kind === 274 /* NamespaceExport */ - || kind === 164 /* Parameter */ - || kind === 296 /* PropertyAssignment */ - || kind === 167 /* PropertyDeclaration */ - || kind === 166 /* PropertySignature */ - || kind === 173 /* SetAccessor */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 163 /* TypeParameter */ - || kind === 254 /* VariableDeclaration */ - || kind === 345 /* JSDocTypedefTag */ - || kind === 338 /* JSDocCallbackTag */ - || kind === 347 /* JSDocPropertyTag */; + return kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 203 /* SyntaxKind.BindingElement */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 299 /* SyntaxKind.EnumMember */ + || kind === 275 /* SyntaxKind.ExportSpecifier */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 267 /* SyntaxKind.ImportClause */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 270 /* SyntaxKind.ImportSpecifier */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 268 /* SyntaxKind.NamespaceImport */ + || kind === 274 /* SyntaxKind.NamespaceExport */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 254 /* SyntaxKind.VariableDeclaration */ + || kind === 345 /* SyntaxKind.JSDocTypedefTag */ + || kind === 338 /* SyntaxKind.JSDocCallbackTag */ + || kind === 347 /* SyntaxKind.JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 256 /* FunctionDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 246 /* BreakStatement */ - || kind === 245 /* ContinueStatement */ - || kind === 253 /* DebuggerStatement */ - || kind === 240 /* DoStatement */ - || kind === 238 /* ExpressionStatement */ - || kind === 236 /* EmptyStatement */ - || kind === 243 /* ForInStatement */ - || kind === 244 /* ForOfStatement */ - || kind === 242 /* ForStatement */ - || kind === 239 /* IfStatement */ - || kind === 250 /* LabeledStatement */ - || kind === 247 /* ReturnStatement */ - || kind === 249 /* SwitchStatement */ - || kind === 251 /* ThrowStatement */ - || kind === 252 /* TryStatement */ - || kind === 237 /* VariableStatement */ - || kind === 241 /* WhileStatement */ - || kind === 248 /* WithStatement */ - || kind === 349 /* NotEmittedStatement */ - || kind === 353 /* EndOfDeclarationMarker */ - || kind === 352 /* MergeDeclarationMarker */; + return kind === 246 /* SyntaxKind.BreakStatement */ + || kind === 245 /* SyntaxKind.ContinueStatement */ + || kind === 253 /* SyntaxKind.DebuggerStatement */ + || kind === 240 /* SyntaxKind.DoStatement */ + || kind === 238 /* SyntaxKind.ExpressionStatement */ + || kind === 236 /* SyntaxKind.EmptyStatement */ + || kind === 243 /* SyntaxKind.ForInStatement */ + || kind === 244 /* SyntaxKind.ForOfStatement */ + || kind === 242 /* SyntaxKind.ForStatement */ + || kind === 239 /* SyntaxKind.IfStatement */ + || kind === 250 /* SyntaxKind.LabeledStatement */ + || kind === 247 /* SyntaxKind.ReturnStatement */ + || kind === 249 /* SyntaxKind.SwitchStatement */ + || kind === 251 /* SyntaxKind.ThrowStatement */ + || kind === 252 /* SyntaxKind.TryStatement */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 241 /* SyntaxKind.WhileStatement */ + || kind === 248 /* SyntaxKind.WithStatement */ + || kind === 349 /* SyntaxKind.NotEmittedStatement */ + || kind === 353 /* SyntaxKind.EndOfDeclarationMarker */ + || kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 163 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 344 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { + return (node.parent && node.parent.kind !== 344 /* SyntaxKind.JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -13989,10 +14111,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 235 /* Block */) + if (node.kind !== 235 /* SyntaxKind.Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 252 /* TryStatement */ || node.parent.kind === 292 /* CatchClause */) { + if (node.parent.kind === 252 /* SyntaxKind.TryStatement */ || node.parent.kind === 292 /* SyntaxKind.CatchClause */) { return false; } } @@ -14006,76 +14128,76 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 235 /* Block */; + || kind === 235 /* SyntaxKind.Block */; } ts.isStatementOrBlock = isStatementOrBlock; // Module references /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 277 /* ExternalModuleReference */ - || kind === 161 /* QualifiedName */ - || kind === 79 /* Identifier */; + return kind === 277 /* SyntaxKind.ExternalModuleReference */ + || kind === 161 /* SyntaxKind.QualifiedName */ + || kind === 79 /* SyntaxKind.Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 108 /* ThisKeyword */ - || kind === 79 /* Identifier */ - || kind === 206 /* PropertyAccessExpression */; + return kind === 108 /* SyntaxKind.ThisKeyword */ + || kind === 79 /* SyntaxKind.Identifier */ + || kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 278 /* JsxElement */ - || kind === 288 /* JsxExpression */ - || kind === 279 /* JsxSelfClosingElement */ - || kind === 11 /* JsxText */ - || kind === 282 /* JsxFragment */; + return kind === 278 /* SyntaxKind.JsxElement */ + || kind === 288 /* SyntaxKind.JsxExpression */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */ + || kind === 11 /* SyntaxKind.JsxText */ + || kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 285 /* JsxAttribute */ - || kind === 287 /* JsxSpreadAttribute */; + return kind === 285 /* SyntaxKind.JsxAttribute */ + || kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 288 /* JsxExpression */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 288 /* SyntaxKind.JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 280 /* JsxOpeningElement */ - || kind === 279 /* JsxSelfClosingElement */; + return kind === 280 /* SyntaxKind.JsxOpeningElement */ + || kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 289 /* CaseClause */ - || kind === 290 /* DefaultClause */; + return kind === 289 /* SyntaxKind.CaseClause */ + || kind === 290 /* SyntaxKind.DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 309 /* FirstJSDocNode */ && node.kind <= 347 /* LastJSDocNode */; + return node.kind >= 309 /* SyntaxKind.FirstJSDocNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 320 /* JSDoc */ - || node.kind === 319 /* JSDocNamepathType */ - || node.kind === 321 /* JSDocText */ + return node.kind === 320 /* SyntaxKind.JSDoc */ + || node.kind === 319 /* SyntaxKind.JSDocNamepathType */ + || node.kind === 321 /* SyntaxKind.JSDocText */ || isJSDocLinkLike(node) || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) @@ -14085,15 +14207,15 @@ var ts; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 327 /* FirstJSDocTagNode */ && node.kind <= 347 /* LastJSDocTagNode */; + return node.kind >= 327 /* SyntaxKind.FirstJSDocTagNode */ && node.kind <= 347 /* SyntaxKind.LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessor = isGetAccessor; /** True if has jsdoc nodes attached to it. */ @@ -14119,12 +14241,12 @@ var ts; /** True if has initializer node attached to it. */ function hasOnlyExpressionInitializer(node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: - case 299 /* EnumMember */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 299 /* SyntaxKind.EnumMember */: return true; default: return false; @@ -14132,12 +14254,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 285 /* JsxAttribute */ || node.kind === 287 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 285 /* SyntaxKind.JsxAttribute */ || node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 178 /* TypeReference */ || node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -14166,11 +14288,11 @@ var ts; } ts.guessIndentation = guessIndentation; function isStringLiteralLike(node) { - return node.kind === 10 /* StringLiteral */ || node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */ || node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isStringLiteralLike = isStringLiteralLike; function isJSDocLinkLike(node) { - return node.kind === 324 /* JSDocLink */ || node.kind === 325 /* JSDocLinkCode */ || node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 324 /* SyntaxKind.JSDocLink */ || node.kind === 325 /* SyntaxKind.JSDocLinkCode */ || node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkLike = isJSDocLinkLike; function hasRestParameter(s) { @@ -14180,7 +14302,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isRestParameter = isRestParameter; // #endregion @@ -14221,7 +14343,7 @@ var ts; } ts.createSymbolTable = createSymbolTable; function isTransientSymbol(symbol) { - return (symbol.flags & 33554432 /* Transient */) !== 0; + return (symbol.flags & 33554432 /* SymbolFlags.Transient */) !== 0; } ts.isTransientSymbol = isTransientSymbol; var stringWriter = createSingleLineStringWriter(); @@ -14382,11 +14504,11 @@ var ts; } function packageIdToPackageName(_a) { var name = _a.name, subModuleName = _a.subModuleName; - return subModuleName ? name + "/" + subModuleName : name; + return subModuleName ? "".concat(name, "/").concat(subModuleName) : name; } ts.packageIdToPackageName = packageIdToPackageName; function packageIdToString(packageId) { - return packageIdToPackageName(packageId) + "@" + packageId.version; + return "".concat(packageIdToPackageName(packageId), "@").concat(packageId.version); } ts.packageIdToString = packageIdToString; function typeDirectiveIsEqualTo(oldResolution, newResolution) { @@ -14417,28 +14539,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 1048576 /* HasAggregatedChildData */)) { + if (!(node.flags & 1048576 /* NodeFlags.HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* NodeFlags.ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 524288 /* NodeFlags.ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 1048576 /* HasAggregatedChildData */; + node.flags |= 1048576 /* NodeFlags.HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 305 /* SourceFile */) { + while (node && node.kind !== 305 /* SyntaxKind.SourceFile */) { node = node.parent; } return node; @@ -14449,16 +14571,16 @@ var ts; } ts.getSourceFileOfModule = getSourceFileOfModule; function isPlainJsFile(file, checkJs) { - return !!file && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */) && !file.checkJsDirective && checkJs === undefined; + return !!file && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */) && !file.checkJsDirective && checkJs === undefined; } ts.isPlainJsFile = isPlainJsFile; function isStatementWithLocals(node) { switch (node.kind) { - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return true; } return false; @@ -14473,7 +14595,7 @@ var ts; function nodePosToString(node) { var file = getSourceFileOfNode(node); var loc = ts.getLineAndCharacterOfPosition(file, node.pos); - return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")"; + return "".concat(file.fileName, "(").concat(loc.line + 1, ",").concat(loc.character + 1, ")"); } ts.nodePosToString = nodePosToString; function getEndLinePosition(line, sourceFile) { @@ -14526,7 +14648,7 @@ var ts; if (node === undefined) { return true; } - return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* SyntaxKind.EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -14560,7 +14682,7 @@ var ts; return to; } function isAnyPrologueDirective(node) { - return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } /** * Prepends statements to an array while taking care of prologue directives. @@ -14592,9 +14714,9 @@ var ts; function isRecognizedTripleSlashComment(text, commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments - if (text.charCodeAt(commentPos + 1) === 47 /* slash */ && + if (text.charCodeAt(commentPos + 1) === 47 /* CharacterCodes.slash */ && commentPos + 2 < commentEnd && - text.charCodeAt(commentPos + 2) === 47 /* slash */) { + text.charCodeAt(commentPos + 2) === 47 /* CharacterCodes.slash */) { var textSubStr = text.substring(commentPos, commentEnd); return ts.fullTripleSlashReferencePathRegEx.test(textSubStr) || ts.fullTripleSlashAMDReferencePathRegEx.test(textSubStr) || @@ -14606,13 +14728,13 @@ var ts; } ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment; function isPinnedComment(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 33 /* exclamation */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 33 /* CharacterCodes.exclamation */; } ts.isPinnedComment = isPinnedComment; function createCommentDirectivesMap(sourceFile, commentDirectives) { var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([ - "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + "".concat(ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line), commentDirective, ]); })); var usedLines = new ts.Map(); @@ -14621,7 +14743,7 @@ var ts; return ts.arrayFrom(directivesByLine.entries()) .filter(function (_a) { var line = _a[0], directive = _a[1]; - return directive.type === 0 /* ExpectError */ && !usedLines.get(line); + return directive.type === 0 /* CommentDirectiveType.ExpectError */ && !usedLines.get(line); }) .map(function (_a) { var _ = _a[0], directive = _a[1]; @@ -14629,10 +14751,10 @@ var ts; }); } function markUsed(line) { - if (!directivesByLine.has("" + line)) { + if (!directivesByLine.has("".concat(line))) { return false; } - usedLines.set("" + line, true); + usedLines.set("".concat(line), true); return true; } } @@ -14643,7 +14765,7 @@ var ts; if (nodeIsMissing(node)) { return node.pos; } - if (ts.isJSDocNode(node) || node.kind === 11 /* JsxText */) { + if (ts.isJSDocNode(node) || node.kind === 11 /* SyntaxKind.JsxText */) { // JsxText cannot actually contain comments, even though the scanner will think it sees comments return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } @@ -14654,7 +14776,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 348 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 348 /* SyntaxKind.SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, @@ -14822,56 +14944,56 @@ var ts; // If we can't reach the original source text, use the canonical form if it's a number, // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { - case 10 /* StringLiteral */: { - var escapeText = flags & 2 /* JsxAttributeEscape */ ? escapeJsxAttributeString : - flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + case 10 /* SyntaxKind.StringLiteral */: { + var escapeText = flags & 2 /* GetLiteralTextFlags.JsxAttributeEscape */ ? escapeJsxAttributeString : + flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; if (node.singleQuote) { - return "'" + escapeText(node.text, 39 /* singleQuote */) + "'"; + return "'" + escapeText(node.text, 39 /* CharacterCodes.singleQuote */) + "'"; } else { - return '"' + escapeText(node.text, 34 /* doubleQuote */) + '"'; + return '"' + escapeText(node.text, 34 /* CharacterCodes.doubleQuote */) + '"'; } } - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: { + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: { // If a NoSubstitutionTemplateLiteral appears to have a substitution in it, the original text // had to include a backslash: `not \${a} substitution`. - var escapeText = flags & 1 /* NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? escapeString : + var escapeText = flags & 1 /* GetLiteralTextFlags.NeverAsciiEscape */ || (getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? escapeString : escapeNonAsciiString; - var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* backtick */)); + var rawText = (_a = node.rawText) !== null && _a !== void 0 ? _a : escapeTemplateSubstitution(escapeText(node.text, 96 /* CharacterCodes.backtick */)); switch (node.kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return "`" + rawText + "${"; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: return "}" + rawText + "${"; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: return "}" + rawText + "`"; } break; } - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return node.text; - case 13 /* RegularExpressionLiteral */: - if (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated) { - return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* backslash */ ? " /" : "/"); + case 13 /* SyntaxKind.RegularExpressionLiteral */: + if (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated) { + return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 /* CharacterCodes.backslash */ ? " /" : "/"); } return node.text; } - return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); + return ts.Debug.fail("Literal kind '".concat(node.kind, "' not accounted for.")); } ts.getLiteralText = getLiteralText; function canUseOriginalText(node, flags) { - if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* TerminateUnterminatedLiterals */ && node.isUnterminated)) { + if (nodeIsSynthesized(node) || !node.parent || (flags & 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ && node.isUnterminated)) { return false; } - if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* ContainsSeparator */) { - return !!(flags & 8 /* AllowNumericSeparator */); + if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512 /* TokenFlags.ContainsSeparator */) { + return !!(flags & 8 /* GetLiteralTextFlags.AllowNumericSeparator */); } return !ts.isBigIntLiteral(node); } @@ -14886,21 +15008,21 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (ts.getCombinedNodeFlags(declaration) & 3 /* BlockScoped */) !== 0 || + return (ts.getCombinedNodeFlags(declaration) & 3 /* NodeFlags.BlockScoped */) !== 0 || isCatchClauseVariableDeclarationOrBindingElement(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* StringLiteral */ || isGlobalScopeAugmentation(node)); + return ts.isModuleDeclaration(node) && (node.name.kind === 10 /* SyntaxKind.StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; function isModuleWithStringLiteralName(node) { - return ts.isModuleDeclaration(node) && node.name.kind === 10 /* StringLiteral */; + return ts.isModuleDeclaration(node) && node.name.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName; function isNonGlobalAmbientModule(node) { @@ -14924,16 +15046,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return !!node && node.kind === 261 /* ModuleDeclaration */ && (!node.body); + return !!node && node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 305 /* SourceFile */ || - node.kind === 261 /* ModuleDeclaration */ || + return node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 261 /* SyntaxKind.ModuleDeclaration */ || ts.isFunctionLikeOrClassStaticBlockDeclaration(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 1024 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* NodeFlags.GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -14945,9 +15067,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return ts.isExternalModule(node.parent); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -14971,10 +15093,10 @@ var ts; function isEffectiveStrictModeSourceFile(node, compilerOptions) { // We can only verify strict mode for JS/TS files switch (node.scriptKind) { - case 1 /* JS */: - case 3 /* TS */: - case 2 /* JSX */: - case 4 /* TSX */: + case 1 /* ScriptKind.JS */: + case 3 /* ScriptKind.TS */: + case 2 /* ScriptKind.JSX */: + case 4 /* ScriptKind.TSX */: break; default: return false; @@ -15004,24 +15126,24 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 292 /* CatchClause */: - case 261 /* ModuleDeclaration */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 167 /* PropertyDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 292 /* SyntaxKind.CatchClause */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLikeOrClassStaticBlockDeclaration(parentNode); @@ -15031,9 +15153,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 323 /* JSDocSignature */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 323 /* SyntaxKind.JSDocSignature */: return true; default: ts.assertType(node); @@ -15043,25 +15165,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; default: ts.assertType(node); @@ -15071,8 +15193,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return true; default: return false; @@ -15085,15 +15207,15 @@ var ts; ts.isAnyImportOrBareOrAccessedRequire = isAnyImportOrBareOrAccessedRequire; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 237 /* VariableStatement */: - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return true; default: return false; @@ -15134,19 +15256,19 @@ var ts; } ts.getNameFromIndexInfo = getNameFromIndexInfo; function isComputedNonLiteralName(name) { - return name.kind === 162 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + return name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); } ts.isComputedNonLiteralName = isComputedNonLiteralName; function tryGetTextOfPropertyName(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return undefined; @@ -15161,21 +15283,21 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return "this"; - case 80 /* PrivateIdentifier */: - case 79 /* Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { return ts.Debug.assertNever(name.name); } - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return entityNameToString(name.left) + entityNameToString(name.right); default: return ts.Debug.assertNever(name); @@ -15265,7 +15387,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 235 /* Block */) { + if (node.body && node.body.kind === 235 /* SyntaxKind.Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -15279,7 +15401,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -15288,29 +15410,29 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 259 /* TypeAliasDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 268 /* NamespaceImport */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 268 /* SyntaxKind.NamespaceImport */: errorNode = node.name; break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: var start = ts.skipTrivia(sourceFile.text, node.pos); var end = node.statements.length > 0 ? node.statements[0].pos : node.end; return ts.createTextSpanFromBounds(start, end); @@ -15342,36 +15464,36 @@ var ts; } ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule; function isJsonSourceFile(file) { - return file.scriptKind === 6 /* JSON */; + return file.scriptKind === 6 /* ScriptKind.JSON */; } ts.isJsonSourceFile = isJsonSourceFile; function isEnumConst(node) { - return !!(ts.getCombinedModifierFlags(node) & 2048 /* Const */); + return !!(ts.getCombinedModifierFlags(node) & 2048 /* ModifierFlags.Const */); } ts.isEnumConst = isEnumConst; function isDeclarationReadonly(declaration) { - return !!(ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); + return !!(ts.getCombinedModifierFlags(declaration) & 64 /* ModifierFlags.Readonly */ && !ts.isParameterPropertyDeclaration(declaration, declaration.parent)); } ts.isDeclarationReadonly = isDeclarationReadonly; function isVarConst(node) { - return !!(ts.getCombinedNodeFlags(node) & 2 /* Const */); + return !!(ts.getCombinedNodeFlags(node) & 2 /* NodeFlags.Const */); } ts.isVarConst = isVarConst; function isLet(node) { - return !!(ts.getCombinedNodeFlags(node) & 1 /* Let */); + return !!(ts.getCombinedNodeFlags(node) & 1 /* NodeFlags.Let */); } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 106 /* SuperKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 208 /* CallExpression */ && n.expression.kind === 100 /* ImportKeyword */; + return n.kind === 208 /* SyntaxKind.CallExpression */ && n.expression.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 100 /* ImportKeyword */ + && n.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -15380,12 +15502,12 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 238 /* ExpressionStatement */ - && node.expression.kind === 10 /* StringLiteral */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */ + && node.expression.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isCustomPrologue(node) { - return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + return !!(getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */); } ts.isCustomPrologue = isCustomPrologue; function isHoistedFunction(node) { @@ -15404,24 +15526,24 @@ var ts; } ts.isHoistedVariableStatement = isHoistedVariableStatement; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; + return node.kind !== 11 /* SyntaxKind.JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 164 /* Parameter */ || - node.kind === 163 /* TypeParameter */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 214 /* ArrowFunction */ || - node.kind === 212 /* ParenthesizedExpression */ || - node.kind === 254 /* VariableDeclaration */ || - node.kind === 275 /* ExportSpecifier */) ? + var commentRanges = (node.kind === 164 /* SyntaxKind.Parameter */ || + node.kind === 163 /* SyntaxKind.TypeParameter */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 214 /* SyntaxKind.ArrowFunction */ || + node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + node.kind === 254 /* SyntaxKind.VariableDeclaration */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' return ts.filter(commentRanges, function (comment) { - return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 2) === 42 /* asterisk */ && - text.charCodeAt(comment.pos + 3) !== 47 /* slash */; + return text.charCodeAt(comment.pos + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(comment.pos + 3) !== 47 /* CharacterCodes.slash */; }); } ts.getJSDocCommentRanges = getJSDocCommentRanges; @@ -15430,48 +15552,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (177 /* FirstTypeNode */ <= node.kind && node.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= node.kind && node.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return true; - case 114 /* VoidKeyword */: - return node.parent.kind !== 217 /* VoidExpression */; - case 228 /* ExpressionWithTypeArguments */: + case 114 /* SyntaxKind.VoidKeyword */: + return node.parent.kind !== 217 /* SyntaxKind.VoidExpression */; + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 163 /* TypeParameter */: - return node.parent.kind === 195 /* MappedType */ || node.parent.kind === 190 /* InferType */; + case 163 /* SyntaxKind.TypeParameter */: + return node.parent.kind === 195 /* SyntaxKind.MappedType */ || node.parent.kind === 190 /* SyntaxKind.InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */ || node.kind === 206 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: - case 108 /* ThisKeyword */: { + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: { var parent = node.parent; - if (parent.kind === 181 /* TypeQuery */) { + if (parent.kind === 181 /* SyntaxKind.TypeQuery */) { return false; } - if (parent.kind === 200 /* ImportType */) { + if (parent.kind === 200 /* SyntaxKind.ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -15480,40 +15602,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (177 /* FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* LastTypeNode */) { + if (177 /* SyntaxKind.FirstTypeNode */ <= parent.kind && parent.kind <= 200 /* SyntaxKind.LastTypeNode */) { return true; } switch (parent.kind) { - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return node === parent.constraint; - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return node === parent.constraint; - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return node === parent.type; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return node === parent.type; - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return node === parent.type; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return node === parent.type; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.contains(parent.typeArguments, node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -15538,23 +15660,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitor(node); - case 263 /* CaseBlock */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 263 /* SyntaxKind.CaseBlock */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return ts.forEachChild(node, traverse); } } @@ -15564,23 +15686,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 260 /* EnumDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, skip them to avoid the work. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -15603,10 +15725,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 183 /* ArrayType */) { + if (node && node.kind === 183 /* SyntaxKind.ArrayType */) { return node.elementType; } - else if (node && node.kind === 178 /* TypeReference */) { + else if (node && node.kind === 178 /* SyntaxKind.TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -15616,12 +15738,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 182 /* TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 182 /* SyntaxKind.TypeLiteral */: return node.members; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return node.properties; } } @@ -15629,14 +15751,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 203 /* BindingElement */: - case 299 /* EnumMember */: - case 164 /* Parameter */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 297 /* ShorthandPropertyAssignment */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 299 /* SyntaxKind.EnumMember */: + case 164 /* SyntaxKind.Parameter */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } } @@ -15648,21 +15770,21 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 255 /* VariableDeclarationList */ - && node.parent.parent.kind === 237 /* VariableStatement */; + return node.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */ + && node.parent.parent.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isCommonJsExportedExpression(node) { if (!isInJSFile(node)) return false; - return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* ModuleExports */) || + return (ts.isObjectLiteralExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && getAssignmentDeclarationKind(node.parent.parent) === 2 /* AssignmentDeclarationKind.ModuleExports */) || isCommonJsExportPropertyAssignment(node.parent); } ts.isCommonJsExportedExpression = isCommonJsExportedExpression; function isCommonJsExportPropertyAssignment(node) { if (!isInJSFile(node)) return false; - return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* ExportsProperty */); + return (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 1 /* AssignmentDeclarationKind.ExportsProperty */); } ts.isCommonJsExportPropertyAssignment = isCommonJsExportPropertyAssignment; function isValidESSymbolDeclaration(node) { @@ -15673,13 +15795,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return true; } return false; @@ -15690,7 +15812,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 250 /* LabeledStatement */) { + if (node.statement.kind !== 250 /* SyntaxKind.LabeledStatement */) { return node.statement; } node = node.statement; @@ -15698,30 +15820,30 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 235 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 169 /* MethodDeclaration */ && node.parent.kind === 205 /* ObjectLiteralExpression */; + return node && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethodOrAccessor(node) { - return (node.kind === 169 /* MethodDeclaration */ || node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) && - (node.parent.kind === 205 /* ObjectLiteralExpression */ || - node.parent.kind === 226 /* ClassExpression */); + return (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) && + (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || + node.parent.kind === 226 /* SyntaxKind.ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethodOrAccessor = isObjectLiteralOrClassExpressionMethodOrAccessor; function isIdentifierTypePredicate(predicate) { - return predicate && predicate.kind === 1 /* Identifier */; + return predicate && predicate.kind === 1 /* TypePredicateKind.Identifier */; } ts.isIdentifierTypePredicate = isIdentifierTypePredicate; function isThisTypePredicate(predicate) { - return predicate && predicate.kind === 0 /* This */; + return predicate && predicate.kind === 0 /* TypePredicateKind.This */; } ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 296 /* PropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */) { var propName = tryGetTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -15783,14 +15905,14 @@ var ts; } ts.getContainingFunctionOrClassStaticBlock = getContainingFunctionOrClassStaticBlock; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 305 /* SourceFile */); + ts.Debug.assert(node.kind !== 305 /* SyntaxKind.SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -15805,9 +15927,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -15818,27 +15940,27 @@ var ts; node = node.parent; } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 261 /* ModuleDeclaration */: - case 170 /* ClassStaticBlockDeclaration */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 260 /* EnumDeclaration */: - case 305 /* SourceFile */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 305 /* SyntaxKind.SourceFile */: return node; } } @@ -15851,17 +15973,17 @@ var ts; switch (node.kind) { // Arrow functions use the same scope, but may do so in a "delayed" manner // For example, `const getThis = () => this` may be before a super() call in a derived constructor - case 214 /* ArrowFunction */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 167 /* PropertyDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Object properties can have computed names; only method-like bodies start a new scope return true; default: @@ -15885,9 +16007,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: return container; } } @@ -15909,28 +16031,28 @@ var ts; return node; } switch (node.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: node = node.parent; break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return node; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 164 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 164 /* SyntaxKind.Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -15946,21 +16068,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 213 /* FunctionExpression */ || func.kind === 214 /* ArrowFunction */) { + if (func.kind === 213 /* SyntaxKind.FunctionExpression */ || func.kind === 214 /* SyntaxKind.ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 212 /* ParenthesizedExpression */) { + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 208 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 106 /* SuperKeyword */ + return node.kind === 106 /* SyntaxKind.SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -15969,8 +16091,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 106 /* SuperKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -15978,34 +16100,34 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 206 /* PropertyAccessExpression */ || kind === 207 /* ElementAccessExpression */) - && node.expression.kind === 108 /* ThisKeyword */; + return (kind === 206 /* SyntaxKind.PropertyAccessExpression */ || kind === 207 /* SyntaxKind.ElementAccessExpression */) + && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisProperty = isThisProperty; function isThisInitializedDeclaration(node) { var _a; - return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* ThisKeyword */; + return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedDeclaration = isThisInitializedDeclaration; function isThisInitializedObjectBindingExpression(node) { return !!node && (ts.isShorthandPropertyAssignment(node) || ts.isPropertyAssignment(node)) && ts.isBinaryExpression(node.parent.parent) - && node.parent.parent.operatorToken.kind === 63 /* EqualsToken */ - && node.parent.parent.right.kind === 108 /* ThisKeyword */; + && node.parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ + && node.parent.parent.right.kind === 108 /* SyntaxKind.ThisKeyword */; } ts.isThisInitializedObjectBindingExpression = isThisInitializedObjectBindingExpression; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: return node; } return undefined; @@ -16013,10 +16135,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return node.tag; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -16029,25 +16151,25 @@ var ts; return false; } switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // classes are valid targets return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 257 /* ClassDeclaration */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + return parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 257 /* ClassDeclaration */; - case 164 /* Parameter */: + && parent.kind === 257 /* SyntaxKind.ClassDeclaration */; + case 164 /* SyntaxKind.Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 171 /* Constructor */ - || parent.kind === 169 /* MethodDeclaration */ - || parent.kind === 173 /* SetAccessor */) - && grandparent.kind === 257 /* ClassDeclaration */; + && (parent.kind === 171 /* SyntaxKind.Constructor */ + || parent.kind === 169 /* SyntaxKind.MethodDeclaration */ + || parent.kind === 173 /* SyntaxKind.SetAccessor */) + && grandparent.kind === 257 /* SyntaxKind.ClassDeclaration */; } return false; } @@ -16063,11 +16185,11 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -16083,9 +16205,9 @@ var ts; ts.classOrConstructorParameterIsDecorated = classOrConstructorParameterIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 280 /* JsxOpeningElement */ || - parent.kind === 279 /* JsxSelfClosingElement */ || - parent.kind === 281 /* JsxClosingElement */) { + if (parent.kind === 280 /* SyntaxKind.JsxOpeningElement */ || + parent.kind === 279 /* SyntaxKind.JsxSelfClosingElement */ || + parent.kind === 281 /* SyntaxKind.JsxClosingElement */) { return parent.tagName === node; } return false; @@ -16093,66 +16215,66 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 13 /* RegularExpressionLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 229 /* AsExpression */: - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 216 /* TypeOfExpression */: - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: - case 221 /* BinaryExpression */: - case 222 /* ConditionalExpression */: - case 225 /* SpreadElement */: - case 223 /* TemplateExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - case 224 /* YieldExpression */: - case 218 /* AwaitExpression */: - case 231 /* MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 223 /* SyntaxKind.TemplateExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + case 224 /* SyntaxKind.YieldExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 231 /* SyntaxKind.MetaProperty */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return !ts.isHeritageClause(node.parent); - case 161 /* QualifiedName */: - while (node.parent.kind === 161 /* QualifiedName */) { + case 161 /* SyntaxKind.QualifiedName */: + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 311 /* JSDocMemberName */: + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 311 /* SyntaxKind.JSDocMemberName */: while (ts.isJSDocMemberName(node.parent)) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); - case 80 /* PrivateIdentifier */: - return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* InKeyword */; - case 79 /* Identifier */: - if (node.parent.kind === 181 /* TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node); + case 80 /* SyntaxKind.PrivateIdentifier */: + return ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; + case 79 /* SyntaxKind.Identifier */: + if (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ || ts.isJSDocLinkLike(node.parent) || ts.isJSDocNameReference(node.parent) || ts.isJSDocMemberName(node.parent) || isJSXTagName(node)) { return true; } // falls through - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 108 /* ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -16162,49 +16284,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: return parent.initializer === node; - case 238 /* ExpressionStatement */: - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 247 /* ReturnStatement */: - case 248 /* WithStatement */: - case 249 /* SwitchStatement */: - case 289 /* CaseClause */: - case 251 /* ThrowStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 289 /* SyntaxKind.CaseClause */: + case 251 /* SyntaxKind.ThrowStatement */: return parent.expression === node; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) || forInStatement.expression === node; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return node === parent.expression; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node === parent.expression; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return node === parent.expression; - case 165 /* Decorator */: - case 288 /* JsxExpression */: - case 287 /* JsxSpreadAttribute */: - case 298 /* SpreadAssignment */: + case 165 /* SyntaxKind.Decorator */: + case 288 /* SyntaxKind.JsxExpression */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 298 /* SyntaxKind.SpreadAssignment */: return true; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return parent.expression === node && !isPartOfTypeNode(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -16212,10 +16334,10 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isPartOfTypeQuery(node) { - while (node.kind === 161 /* QualifiedName */ || node.kind === 79 /* Identifier */) { + while (node.kind === 161 /* SyntaxKind.QualifiedName */ || node.kind === 79 /* SyntaxKind.Identifier */) { node = node.parent; } - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isPartOfTypeQuery = isPartOfTypeQuery; function isNamespaceReexportDeclaration(node) { @@ -16223,7 +16345,7 @@ var ts; } ts.isNamespaceReexportDeclaration = isNamespaceReexportDeclaration; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -16236,7 +16358,7 @@ var ts; } ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* ExternalModuleReference */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -16248,11 +16370,11 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 262144 /* JavaScriptFile */); + return !!node && !!(node.flags & 262144 /* NodeFlags.JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 67108864 /* JsonFile */); + return !!node && !!(node.flags & 67108864 /* NodeFlags.JsonFile */); } ts.isInJsonFile = isInJsonFile; function isSourceFileNotJson(file) { @@ -16260,7 +16382,7 @@ var ts; } ts.isSourceFileNotJson = isSourceFileNotJson; function isInJSDoc(node) { - return !!node && !!(node.flags & 8388608 /* JSDoc */); + return !!node && !!(node.flags & 8388608 /* NodeFlags.JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -16268,15 +16390,15 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 150 /* StringKeyword */ || node.typeArguments[0].kind === 147 /* NumberKeyword */); + (node.typeArguments[0].kind === 150 /* SyntaxKind.StringKeyword */ || node.typeArguments[0].kind === 147 /* SyntaxKind.NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; function isRequireCall(callExpression, requireStringLiteralLikeArgument) { - if (callExpression.kind !== 208 /* CallExpression */) { + if (callExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 79 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 79 /* SyntaxKind.Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { @@ -16313,11 +16435,11 @@ var ts; } ts.isRequireVariableStatement = isRequireVariableStatement; function isSingleOrDoubleQuote(charCode) { - return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */; + return charCode === 39 /* CharacterCodes.singleQuote */ || charCode === 34 /* CharacterCodes.doubleQuote */; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; function isStringDoubleQuoted(str, sourceFile) { - return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* doubleQuote */; + return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34 /* CharacterCodes.doubleQuote */; } ts.isStringDoubleQuoted = isStringDoubleQuoted; function isAssignmentDeclaration(decl) { @@ -16328,7 +16450,7 @@ var ts; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && ts.isBinaryExpression(node.initializer) && - (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && + (node.initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -16355,7 +16477,7 @@ var ts; * 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 === 63 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -16381,11 +16503,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 213 /* FunctionExpression */ || e.kind === 214 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 213 /* SyntaxKind.FunctionExpression */ || e.kind === 214 /* SyntaxKind.ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 213 /* FunctionExpression */ || - initializer.kind === 226 /* ClassExpression */ || - initializer.kind === 214 /* ArrowFunction */) { + if (initializer.kind === 213 /* SyntaxKind.FunctionExpression */ || + initializer.kind === 226 /* SyntaxKind.ClassExpression */ || + initializer.kind === 214 /* SyntaxKind.ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -16403,7 +16525,7 @@ var ts; */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { var e = ts.isBinaryExpression(initializer) - && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && (initializer.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || initializer.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; @@ -16411,7 +16533,7 @@ var ts; } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -16419,8 +16541,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -16443,7 +16565,7 @@ var ts; return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer); } if (ts.isMemberName(name) && isLiteralLikeAccess(initializer) && - (initializer.expression.kind === 108 /* ThisKeyword */ || + (initializer.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || @@ -16482,7 +16604,7 @@ var ts; /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); - return special === 5 /* Property */ || isInJSFile(expr) ? special : 0 /* None */; + return special === 5 /* AssignmentDeclarationKind.Property */ || isInJSFile(expr) ? special : 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind; function isBindableObjectDefinePropertyCall(expr) { @@ -16507,14 +16629,14 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; /** Any series of property and element accesses, ending in a literal element access */ function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { return isLiteralLikeElementAccess(node) - && ((!excludeThisKeyword && node.expression.kind === 108 /* ThisKeyword */) || + && ((!excludeThisKeyword && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) || isEntityNameExpression(node.expression) || isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); } @@ -16533,23 +16655,23 @@ var ts; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } var entityName = expr.arguments[0]; if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { - return 8 /* ObjectDefinePropertyExports */; + return 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */; } if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { - return 9 /* ObjectDefinePrototypeProperty */; + return 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */; } - return 7 /* ObjectDefinePropertyValue */; + return 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 63 /* EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { - return 0 /* None */; + if (expr.operatorToken.kind !== 63 /* SyntaxKind.EqualsToken */ || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) { + return 0 /* AssignmentDeclarationKind.None */; } if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } - return 6 /* Prototype */; + return 6 /* AssignmentDeclarationKind.Prototype */; } return getAssignmentDeclarationPropertyAccessKind(expr.left); } @@ -16586,17 +16708,17 @@ var ts; } ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 108 /* ThisKeyword */) { - return 4 /* ThisProperty */; + if (lhs.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { + return 4 /* AssignmentDeclarationKind.ThisProperty */; } else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr - return 2 /* ModuleExports */; + return 2 /* AssignmentDeclarationKind.ModuleExports */; } else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr - return 3 /* PrototypeProperty */; + return 3 /* AssignmentDeclarationKind.PrototypeProperty */; } var nextToLast = lhs; while (!ts.isIdentifier(nextToLast.expression)) { @@ -16608,14 +16730,14 @@ var ts; // ExportsProperty does not support binding with computed names isBindableStaticAccessExpression(lhs)) { // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... - return 1 /* ExportsProperty */; + return 1 /* AssignmentDeclarationKind.ExportsProperty */; } if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) { // F.G...x = expr - return 5 /* Property */; + return 5 /* AssignmentDeclarationKind.Property */; } } - return 0 /* None */; + return 0 /* AssignmentDeclarationKind.None */; } ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind; function getInitializerOfBinaryExpression(expr) { @@ -16626,12 +16748,12 @@ var ts; } ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression; function isPrototypePropertyAssignment(node) { - return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* PrototypeProperty */; + return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 238 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } @@ -16639,7 +16761,7 @@ var ts; function setValueDeclaration(symbol, node) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - !(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) && + !(node.flags & 16777216 /* NodeFlags.Ambient */ && !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */)) && (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { // other kinds of value declarations take precedence over modules and assignment declarations @@ -16652,17 +16774,17 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 256 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 256 /* SyntaxKind.FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function tryGetModuleSpecifierFromDeclaration(node) { var _a, _b; switch (node.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return (_a = ts.findAncestor(node.initializer, function (node) { return isRequireCall(node, /*requireStringLiteralLikeArgument*/ true); })) === null || _a === void 0 ? void 0 : _a.arguments[0]; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return ts.tryCast(node.moduleSpecifier, ts.isStringLiteralLike); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return ts.tryCast((_b = ts.tryCast(node.moduleReference, ts.isExternalModuleReference)) === null || _b === void 0 ? void 0 : _b.expression, ts.isStringLiteralLike); default: ts.Debug.assertNever(node); @@ -16675,14 +16797,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.parent; - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return node.parent.parent; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -16692,17 +16814,17 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.moduleSpecifier; - case 265 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 277 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 200 /* ImportType */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + return node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 200 /* SyntaxKind.ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return node.arguments[0]; - case 261 /* ModuleDeclaration */: - return node.name.kind === 10 /* StringLiteral */ ? node.name : undefined; + case 261 /* SyntaxKind.ModuleDeclaration */: + return node.name.kind === 10 /* SyntaxKind.StringLiteral */ ? node.name : undefined; default: return ts.Debug.assertNever(node); } @@ -16710,11 +16832,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport); default: return ts.Debug.assertNever(node); @@ -16722,7 +16844,7 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 266 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function forEachImportClauseDeclaration(node, action) { @@ -16743,13 +16865,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 164 /* Parameter */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 164 /* SyntaxKind.Parameter */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return node.questionToken !== undefined; } } @@ -16763,7 +16885,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 345 /* JSDocTypedefTag */ || node.kind === 338 /* JSDocCallbackTag */ || node.kind === 339 /* JSDocEnumTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */ || node.kind === 338 /* SyntaxKind.JSDocCallbackTag */ || node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -16773,27 +16895,27 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 63 /* EqualsToken */ + node.expression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? getRightMostAssignedExpression(node.expression) : undefined; } function getSourceOfDefaultedAssignment(node) { return ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression) && - getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && + getAssignmentDeclarationKind(node.expression) !== 0 /* AssignmentDeclarationKind.None */ && ts.isBinaryExpression(node.expression.right) && - (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) + (node.expression.right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return node.initializer; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return node.initializer; } } @@ -16805,7 +16927,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 261 /* ModuleDeclaration */ + node.body.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? node.body : undefined; } @@ -16820,11 +16942,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.addRange(result, filterOwnedJSDocTags(hostNode, ts.last(node.jsDoc))); } - if (node.kind === 164 /* Parameter */) { + if (node.kind === 164 /* SyntaxKind.Parameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node)); break; } - if (node.kind === 163 /* TypeParameter */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node)); break; } @@ -16853,13 +16975,13 @@ var ts; } function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 296 /* PropertyAssignment */ || - parent.kind === 271 /* ExportAssignment */ || - parent.kind === 167 /* PropertyDeclaration */ || - parent.kind === 238 /* ExpressionStatement */ && node.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 247 /* ReturnStatement */ || + if (parent.kind === 296 /* SyntaxKind.PropertyAssignment */ || + parent.kind === 271 /* SyntaxKind.ExportAssignment */ || + parent.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 247 /* SyntaxKind.ReturnStatement */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -16870,7 +16992,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -16894,7 +17016,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 79 /* SyntaxKind.Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -16967,41 +17089,41 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 63 /* EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* Definite */ : 2 /* Compound */ : - 0 /* None */; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + binaryOperator === 63 /* SyntaxKind.EqualsToken */ || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 /* AssignmentKind.Definite */ : 2 /* AssignmentKind.Compound */ : + 0 /* AssignmentKind.None */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 212 /* ParenthesizedExpression */: - case 204 /* ArrayLiteralExpression */: - case 225 /* SpreadElement */: - case 230 /* NonNullExpression */: + return unaryOperator === 45 /* SyntaxKind.PlusPlusToken */ || unaryOperator === 46 /* SyntaxKind.MinusMinusToken */ ? 2 /* AssignmentKind.Compound */ : 0 /* AssignmentKind.None */; + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + return parent.initializer === node ? 1 /* AssignmentKind.Definite */ : 0 /* AssignmentKind.None */; + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 225 /* SyntaxKind.SpreadElement */: + case 230 /* SyntaxKind.NonNullExpression */: node = parent; break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: node = parent.parent; break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (parent.name !== node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (parent.name === node) { - return 0 /* None */; + return 0 /* AssignmentKind.None */; } node = parent.parent; break; default: - return 0 /* None */; + return 0 /* AssignmentKind.None */; } parent = node.parent; } @@ -17012,7 +17134,7 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ a }] = xxx'. // (Note that `p` is not a target in the above examples, only `a`.) function isAssignmentTarget(node) { - return getAssignmentTargetKind(node) !== 0 /* None */; + return getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */; } ts.isAssignmentTarget = isAssignmentTarget; /** @@ -17021,22 +17143,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 235 /* Block */: - case 237 /* VariableStatement */: - case 248 /* WithStatement */: - case 239 /* IfStatement */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 250 /* LabeledStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 252 /* TryStatement */: - case 292 /* CatchClause */: + case 235 /* SyntaxKind.Block */: + case 237 /* SyntaxKind.VariableStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 250 /* SyntaxKind.LabeledStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 292 /* SyntaxKind.CatchClause */: return true; } return false; @@ -17053,11 +17175,11 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 191 /* ParenthesizedType */); + return walkUp(node, 191 /* SyntaxKind.ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 212 /* ParenthesizedExpression */); + return walkUp(node, 212 /* SyntaxKind.ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; /** @@ -17067,7 +17189,7 @@ var ts; */ function walkUpParenthesizedTypesAndGetParentAndChild(node) { var child; - while (node && node.kind === 191 /* ParenthesizedType */) { + while (node && node.kind === 191 /* SyntaxKind.ParenthesizedType */) { child = node; node = node.parent; } @@ -17082,18 +17204,18 @@ var ts; ts.skipTypeParentheses = skipTypeParentheses; function skipParentheses(node, excludeJSDocTypeAssertions) { var flags = excludeJSDocTypeAssertions ? - 1 /* Parentheses */ | 16 /* ExcludeJSDocTypeAssertion */ : - 1 /* Parentheses */; + 1 /* OuterExpressionKinds.Parentheses */ | 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ : + 1 /* OuterExpressionKinds.Parentheses */; return ts.skipOuterExpressions(node, flags); } ts.skipParentheses = skipParentheses; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 206 /* PropertyAccessExpression */ && node.kind !== 207 /* ElementAccessExpression */) { + if (node.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && node.kind !== 207 /* SyntaxKind.ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 215 /* DeleteExpression */; + return node && node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -17114,13 +17236,13 @@ var ts; function getDeclarationFromName(name) { var parent = name.parent; switch (name.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -17131,13 +17253,13 @@ var ts; else { var binExp = parent.parent; return ts.isBinaryExpression(binExp) && - getAssignmentDeclarationKind(binExp) !== 0 /* None */ && + getAssignmentDeclarationKind(binExp) !== 0 /* AssignmentDeclarationKind.None */ && (binExp.left.symbol || binExp.symbol) && ts.getNameOfDeclaration(binExp) === name ? binExp : undefined; } - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isDeclaration(parent) && parent.name === name ? parent : undefined; default: return undefined; @@ -17146,7 +17268,7 @@ var ts; ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { return isStringOrNumericLiteralLike(node) && - node.parent.kind === 162 /* ComputedPropertyName */ && + node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -17154,29 +17276,29 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 299 /* EnumMember */: - case 296 /* PropertyAssignment */: - case 206 /* PropertyAccessExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 299 /* SyntaxKind.EnumMember */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: // Name on right hand side of dot in a type query or type reference return parent.right === node; - case 203 /* BindingElement */: - case 270 /* ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 275 /* ExportSpecifier */: - case 285 /* JsxAttribute */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 285 /* SyntaxKind.JsxAttribute */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: // Any name in an export specifier or JSX Attribute or Jsx Element return true; } @@ -17199,38 +17321,38 @@ var ts; // const x = require("...").y // const { x } = require("...").y function isAliasSymbolDeclaration(node) { - if (node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - node.kind === 267 /* ImportClause */ && !!node.name || - node.kind === 268 /* NamespaceImport */ || - node.kind === 274 /* NamespaceExport */ || - node.kind === 270 /* ImportSpecifier */ || - node.kind === 275 /* ExportSpecifier */ || - node.kind === 271 /* ExportAssignment */ && exportAssignmentIsAlias(node)) { + if (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name || + node.kind === 268 /* SyntaxKind.NamespaceImport */ || + node.kind === 274 /* SyntaxKind.NamespaceExport */ || + node.kind === 270 /* SyntaxKind.ImportSpecifier */ || + node.kind === 275 /* SyntaxKind.ExportSpecifier */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ && exportAssignmentIsAlias(node)) { return true; } - return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + return isInJSFile(node) && (ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && exportAssignmentIsAlias(node) || ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableExpression(node.parent.right)); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getAliasDeclarationFromName(node) { switch (node.parent.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 268 /* NamespaceImport */: - case 275 /* ExportSpecifier */: - case 271 /* ExportAssignment */: - case 265 /* ImportEqualsDeclaration */: - case 274 /* NamespaceExport */: + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 268 /* SyntaxKind.NamespaceImport */: + case 275 /* SyntaxKind.ExportSpecifier */: + case 271 /* SyntaxKind.ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 274 /* SyntaxKind.NamespaceExport */: return node.parent; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.parent; - } while (node.parent.kind === 161 /* QualifiedName */); + } while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */); return getAliasDeclarationFromName(node); } } @@ -17249,7 +17371,7 @@ var ts; } ts.getExportAssignmentExpression = getExportAssignmentExpression; function getPropertyAssignmentAliasLikeExpression(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* PropertyAssignment */ ? node.initializer : + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? node.name : node.kind === 296 /* SyntaxKind.PropertyAssignment */ ? node.initializer : node.parent.right; } ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; @@ -17266,7 +17388,7 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; @@ -17275,7 +17397,7 @@ var ts; return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); } else { - var heritageClause = getHeritageClause(node.heritageClauses, 117 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 117 /* SyntaxKind.ImplementsKeyword */); return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; } } @@ -17288,7 +17410,7 @@ var ts; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 94 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 94 /* SyntaxKind.ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -17315,11 +17437,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 81 /* FirstKeyword */ <= token && token <= 160 /* LastKeyword */; + return 81 /* SyntaxKind.FirstKeyword */ <= token && token <= 160 /* SyntaxKind.LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 126 /* FirstContextualKeyword */ <= token && token <= 160 /* LastContextualKeyword */; + return 126 /* SyntaxKind.FirstContextualKeyword */ <= token && token <= 160 /* SyntaxKind.LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -17327,7 +17449,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 117 /* FirstFutureReservedWord */ <= token && token <= 125 /* LastFutureReservedWord */; + return 117 /* SyntaxKind.FirstFutureReservedWord */ <= token && token <= 125 /* SyntaxKind.LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -17346,7 +17468,7 @@ var ts; } ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword; function isTrivia(token) { - return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; + return 2 /* SyntaxKind.FirstTriviaToken */ <= token && token <= 7 /* SyntaxKind.LastTriviaToken */; } ts.isTrivia = isTrivia; var FunctionFlags; @@ -17359,38 +17481,38 @@ var ts; })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); function getFunctionFlags(node) { if (!node) { - return 4 /* Invalid */; + return 4 /* FunctionFlags.Invalid */; } - var flags = 0 /* Normal */; + var flags = 0 /* FunctionFlags.Normal */; switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: if (node.asteriskToken) { - flags |= 1 /* Generator */; + flags |= 1 /* FunctionFlags.Generator */; } // falls through - case 214 /* ArrowFunction */: - if (hasSyntacticModifier(node, 256 /* Async */)) { - flags |= 2 /* Async */; + case 214 /* SyntaxKind.ArrowFunction */: + if (hasSyntacticModifier(node, 256 /* ModifierFlags.Async */)) { + flags |= 2 /* FunctionFlags.Async */; } break; } if (!node.body) { - flags |= 4 /* Invalid */; + flags |= 4 /* FunctionFlags.Invalid */; } return flags; } ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined - && hasSyntacticModifier(node, 256 /* Async */); + && hasSyntacticModifier(node, 256 /* ModifierFlags.Async */); } return false; } @@ -17400,7 +17522,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* SyntaxKind.PlusToken */ || node.operator === 40 /* SyntaxKind.MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -17417,7 +17539,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) { + if (!(name.kind === 162 /* SyntaxKind.ComputedPropertyName */ || name.kind === 207 /* SyntaxKind.ElementAccessExpression */)) { return false; } var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression; @@ -17427,19 +17549,19 @@ var ts; ts.isDynamicName = isDynamicName; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return name.escapedText; - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameExpression = name.expression; if (isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); } else if (isSignedNumericLiteral(nameExpression)) { - if (nameExpression.operator === 40 /* MinusToken */) { + if (nameExpression.operator === 40 /* SyntaxKind.MinusToken */) { return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text; } return nameExpression.operand.text; @@ -17452,10 +17574,10 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return true; default: return false; @@ -17471,11 +17593,11 @@ var ts; } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForUniqueESSymbol(symbol) { - return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName; + return "__@".concat(ts.getSymbolId(symbol), "@").concat(symbol.escapedName); } ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol; function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) { - return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description; + return "__#".concat(ts.getSymbolId(containingClassSymbol), "@").concat(description); } ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier; function isKnownSymbol(symbol) { @@ -17490,7 +17612,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -17499,11 +17621,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 164 /* Parameter */; + return root.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 203 /* BindingElement */) { + while (node.kind === 203 /* SyntaxKind.BindingElement */) { node = node.parent.parent; } return node; @@ -17511,15 +17633,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 213 /* FunctionExpression */ - || kind === 256 /* FunctionDeclaration */ - || kind === 214 /* ArrowFunction */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 261 /* ModuleDeclaration */ - || kind === 305 /* SourceFile */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 305 /* SyntaxKind.SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -17538,58 +17660,58 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 209 /* NewExpression */: - return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - case 222 /* ConditionalExpression */: - case 224 /* YieldExpression */: - return 1 /* Right */; - case 221 /* BinaryExpression */: + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 0 /* Associativity.Left */ : 1 /* Associativity.Right */; + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: + case 224 /* SyntaxKind.YieldExpression */: + return 1 /* Associativity.Right */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operator) { - case 42 /* AsteriskAsteriskToken */: - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 1 /* Right */; - } - } - return 0 /* Left */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 1 /* Associativity.Right */; + } + } + return 0 /* Associativity.Left */; } ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 209 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 209 /* SyntaxKind.NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 221 /* BinaryExpression */) { + if (expression.kind === 221 /* SyntaxKind.BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 219 /* PrefixUnaryExpression */ || expression.kind === 220 /* PostfixUnaryExpression */) { + else if (expression.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || expression.kind === 220 /* SyntaxKind.PostfixUnaryExpression */) { return expression.operator; } else { @@ -17768,129 +17890,129 @@ var ts; })(OperatorPrecedence = ts.OperatorPrecedence || (ts.OperatorPrecedence = {})); function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 351 /* CommaListExpression */: - return 0 /* Comma */; - case 225 /* SpreadElement */: - return 1 /* Spread */; - case 224 /* YieldExpression */: - return 2 /* Yield */; - case 222 /* ConditionalExpression */: - return 4 /* Conditional */; - case 221 /* BinaryExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + return 0 /* OperatorPrecedence.Comma */; + case 225 /* SyntaxKind.SpreadElement */: + return 1 /* OperatorPrecedence.Spread */; + case 224 /* SyntaxKind.YieldExpression */: + return 2 /* OperatorPrecedence.Yield */; + case 222 /* SyntaxKind.ConditionalExpression */: + return 4 /* OperatorPrecedence.Conditional */; + case 221 /* SyntaxKind.BinaryExpression */: switch (operatorKind) { - case 27 /* CommaToken */: - return 0 /* Comma */; - case 63 /* EqualsToken */: - case 64 /* PlusEqualsToken */: - case 65 /* MinusEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 66 /* AsteriskEqualsToken */: - case 68 /* SlashEqualsToken */: - case 69 /* PercentEqualsToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 73 /* AmpersandEqualsToken */: - case 78 /* CaretEqualsToken */: - case 74 /* BarEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: - return 3 /* Assignment */; + case 27 /* SyntaxKind.CommaToken */: + return 0 /* OperatorPrecedence.Comma */; + case 63 /* SyntaxKind.EqualsToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: + return 3 /* OperatorPrecedence.Assignment */; default: return getBinaryOperatorPrecedence(operatorKind); } // TODO: Should prefix `++` and `--` be moved to the `Update` precedence? - case 211 /* TypeAssertionExpression */: - case 230 /* NonNullExpression */: - case 219 /* PrefixUnaryExpression */: - case 216 /* TypeOfExpression */: - case 217 /* VoidExpression */: - case 215 /* DeleteExpression */: - case 218 /* AwaitExpression */: - return 16 /* Unary */; - case 220 /* PostfixUnaryExpression */: - return 17 /* Update */; - case 208 /* CallExpression */: - return 18 /* LeftHandSide */; - case 209 /* NewExpression */: - return hasArguments ? 19 /* Member */ : 18 /* LeftHandSide */; - case 210 /* TaggedTemplateExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - case 231 /* MetaProperty */: - return 19 /* Member */; - case 229 /* AsExpression */: - return 11 /* Relational */; - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 226 /* ClassExpression */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 223 /* TemplateExpression */: - case 212 /* ParenthesizedExpression */: - case 227 /* OmittedExpression */: - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: - return 20 /* Primary */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 217 /* SyntaxKind.VoidExpression */: + case 215 /* SyntaxKind.DeleteExpression */: + case 218 /* SyntaxKind.AwaitExpression */: + return 16 /* OperatorPrecedence.Unary */; + case 220 /* SyntaxKind.PostfixUnaryExpression */: + return 17 /* OperatorPrecedence.Update */; + case 208 /* SyntaxKind.CallExpression */: + return 18 /* OperatorPrecedence.LeftHandSide */; + case 209 /* SyntaxKind.NewExpression */: + return hasArguments ? 19 /* OperatorPrecedence.Member */ : 18 /* OperatorPrecedence.LeftHandSide */; + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 231 /* SyntaxKind.MetaProperty */: + return 19 /* OperatorPrecedence.Member */; + case 229 /* SyntaxKind.AsExpression */: + return 11 /* OperatorPrecedence.Relational */; + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 223 /* SyntaxKind.TemplateExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: + return 20 /* OperatorPrecedence.Primary */; default: - return -1 /* Invalid */; + return -1 /* OperatorPrecedence.Invalid */; } } ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 60 /* QuestionQuestionToken */: - return 4 /* Coalesce */; - case 56 /* BarBarToken */: - return 5 /* LogicalOR */; - case 55 /* AmpersandAmpersandToken */: - return 6 /* LogicalAND */; - case 51 /* BarToken */: - return 7 /* BitwiseOR */; - case 52 /* CaretToken */: - return 8 /* BitwiseXOR */; - case 50 /* AmpersandToken */: - return 9 /* BitwiseAND */; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - return 10 /* Equality */; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: - case 102 /* InstanceOfKeyword */: - case 101 /* InKeyword */: - case 127 /* AsKeyword */: - return 11 /* Relational */; - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - return 12 /* Shift */; - case 39 /* PlusToken */: - case 40 /* MinusToken */: - return 13 /* Additive */; - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - return 14 /* Multiplicative */; - case 42 /* AsteriskAsteriskToken */: - return 15 /* Exponentiation */; + case 60 /* SyntaxKind.QuestionQuestionToken */: + return 4 /* OperatorPrecedence.Coalesce */; + case 56 /* SyntaxKind.BarBarToken */: + return 5 /* OperatorPrecedence.LogicalOR */; + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + return 6 /* OperatorPrecedence.LogicalAND */; + case 51 /* SyntaxKind.BarToken */: + return 7 /* OperatorPrecedence.BitwiseOR */; + case 52 /* SyntaxKind.CaretToken */: + return 8 /* OperatorPrecedence.BitwiseXOR */; + case 50 /* SyntaxKind.AmpersandToken */: + return 9 /* OperatorPrecedence.BitwiseAND */; + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + return 10 /* OperatorPrecedence.Equality */; + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: + case 102 /* SyntaxKind.InstanceOfKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 127 /* SyntaxKind.AsKeyword */: + return 11 /* OperatorPrecedence.Relational */; + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + return 12 /* OperatorPrecedence.Shift */; + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + return 13 /* OperatorPrecedence.Additive */; + case 41 /* SyntaxKind.AsteriskToken */: + case 43 /* SyntaxKind.SlashToken */: + case 44 /* SyntaxKind.PercentToken */: + return 14 /* OperatorPrecedence.Multiplicative */; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + return 15 /* OperatorPrecedence.Exponentiation */; } // -1 is lower than all other precedences. Returning it will cause binary expression // parsing to stop. @@ -17900,9 +18022,9 @@ var ts; function getSemanticJsxChildren(children) { return ts.filter(children, function (i) { switch (i.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !!i.expression; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return !i.containsOnlyTriviaWhiteSpaces; default: return true; @@ -18017,9 +18139,9 @@ var ts; return "\\u" + paddedHexCode; } function getReplacement(c, offset, input) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); - if (lookAhead >= 48 /* _0 */ && lookAhead <= 57 /* _9 */) { + if (lookAhead >= 48 /* CharacterCodes._0 */ && lookAhead <= 57 /* CharacterCodes._9 */) { // If the null character is followed by digits, print as a hex escape to prevent the result from parsing as an octal (which is forbidden in strict mode) return "\\x00"; } @@ -18034,8 +18156,8 @@ var ts; * Note that this doesn't actually wrap the input in double quotes. */ function escapeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : - quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 96 /* CharacterCodes.backtick */ ? backtickQuoteEscapedCharsRegExp : + quoteChar === 39 /* CharacterCodes.singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getReplacement); } @@ -18065,13 +18187,13 @@ var ts; return "&#x" + hexCharCode + ";"; } function getJsxAttributeStringReplacement(c) { - if (c.charCodeAt(0) === 0 /* nullCharacter */) { + if (c.charCodeAt(0) === 0 /* CharacterCodes.nullCharacter */) { return "�"; } return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0)); } function escapeJsxAttributeString(s, quoteChar) { - var escapedCharsRegExp = quoteChar === 39 /* singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : + var escapedCharsRegExp = quoteChar === 39 /* CharacterCodes.singleQuote */ ? jsxSingleQuoteEscapedCharsRegExp : jsxDoubleQuoteEscapedCharsRegExp; return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement); } @@ -18090,13 +18212,13 @@ var ts; } ts.stripQuotes = stripQuotes; function isQuoteOrBacktick(charCode) { - return charCode === 39 /* singleQuote */ || - charCode === 34 /* doubleQuote */ || - charCode === 96 /* backtick */; + return charCode === 39 /* CharacterCodes.singleQuote */ || + charCode === 34 /* CharacterCodes.doubleQuote */ || + charCode === 96 /* CharacterCodes.backtick */; } function isIntrinsicJsxName(name) { var ch = name.charCodeAt(0); - return (ch >= 97 /* a */ && ch <= 122 /* z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); + return (ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */) || ts.stringContains(name, "-") || ts.stringContains(name, ":"); } ts.isIntrinsicJsxName = isIntrinsicJsxName; var indentStrings = ["", " "]; @@ -18341,20 +18463,20 @@ var ts; } ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker; function getDeclarationEmitExtensionForPath(path) { - return ts.fileExtensionIsOneOf(path, [".mjs" /* Mjs */, ".mts" /* Mts */]) ? ".d.mts" /* Dmts */ : - ts.fileExtensionIsOneOf(path, [".cjs" /* Cjs */, ".cts" /* Cts */]) ? ".d.cts" /* Dcts */ : - ts.fileExtensionIsOneOf(path, [".json" /* Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well - ".d.ts" /* Dts */; + return ts.fileExtensionIsOneOf(path, [".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? ".d.mts" /* Extension.Dmts */ : + ts.fileExtensionIsOneOf(path, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? ".d.cts" /* Extension.Dcts */ : + ts.fileExtensionIsOneOf(path, [".json" /* Extension.Json */]) ? ".json.d.ts" : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + ".d.ts" /* Extension.Dts */; } ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath; /** * This function is an inverse of `getDeclarationEmitExtensionForPath`. */ function getPossibleOriginalInputExtensionForExtension(path) { - return ts.fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] : - ts.fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] : - ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Json */] : - [".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */]; + return ts.fileExtensionIsOneOf(path, [".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]) ? [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */] : + ts.fileExtensionIsOneOf(path, [".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */]) ? [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */] : + ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Extension.Json */] : + [".tsx" /* Extension.Tsx */, ".ts" /* Extension.Ts */, ".jsx" /* Extension.Jsx */, ".js" /* Extension.Js */]; } ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension; function outFile(options) { @@ -18482,7 +18604,7 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 79 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 79 /* SyntaxKind.Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function isThisInTypeQuery(node) { @@ -18492,11 +18614,11 @@ var ts; while (ts.isQualifiedName(node.parent) && node.parent.left === node) { node = node.parent; } - return node.parent.kind === 181 /* TypeQuery */; + return node.parent.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isThisInTypeQuery = isThisInTypeQuery; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 108 /* ThisKeyword */; + return id.originalKeywordKind === 108 /* SyntaxKind.ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -18507,10 +18629,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 173 /* SetAccessor */) { + else if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { setAccessor = accessor; } else { @@ -18530,10 +18652,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 172 /* GetAccessor */ && !getAccessor) { + if (member.kind === 172 /* SyntaxKind.GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 173 /* SetAccessor */ && !setAccessor) { + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -18582,7 +18704,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 320 /* SyntaxKind.JSDoc */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -18699,7 +18821,7 @@ var ts; } ts.emitDetachedComments = emitDetachedComments; function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) { - if (text.charCodeAt(commentPos + 1) === 42 /* asterisk */) { + if (text.charCodeAt(commentPos + 1) === 42 /* CharacterCodes.asterisk */) { var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos); var lineCount = lineMap.length; var firstCommentLineIndent = void 0; @@ -18774,7 +18896,7 @@ var ts; function calculateIndent(text, pos, end) { var currentLineIndent = 0; for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) { - if (text.charCodeAt(pos) === 9 /* tab */) { + if (text.charCodeAt(pos) === 9 /* CharacterCodes.tab */) { // Tabs = TabSize = indent size and go to next tabStop currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize()); } @@ -18786,11 +18908,11 @@ var ts; return currentLineIndent; } function hasEffectiveModifiers(node) { - return getEffectiveModifierFlags(node) !== 0 /* None */; + return getEffectiveModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasEffectiveModifiers = hasEffectiveModifiers; function hasSyntacticModifiers(node) { - return getSyntacticModifierFlags(node) !== 0 /* None */; + return getSyntacticModifierFlags(node) !== 0 /* ModifierFlags.None */; } ts.hasSyntacticModifiers = hasSyntacticModifiers; function hasEffectiveModifier(node, flags) { @@ -18807,27 +18929,27 @@ var ts; } ts.isStatic = isStatic; function hasStaticModifier(node) { - return hasSyntacticModifier(node, 32 /* Static */); + return hasSyntacticModifier(node, 32 /* ModifierFlags.Static */); } ts.hasStaticModifier = hasStaticModifier; function hasOverrideModifier(node) { - return hasEffectiveModifier(node, 16384 /* Override */); + return hasEffectiveModifier(node, 16384 /* ModifierFlags.Override */); } ts.hasOverrideModifier = hasOverrideModifier; function hasAbstractModifier(node) { - return hasSyntacticModifier(node, 128 /* Abstract */); + return hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); } ts.hasAbstractModifier = hasAbstractModifier; function hasAmbientModifier(node) { - return hasSyntacticModifier(node, 2 /* Ambient */); + return hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */); } ts.hasAmbientModifier = hasAmbientModifier; function hasEffectiveReadonlyModifier(node) { - return hasEffectiveModifier(node, 64 /* Readonly */); + return hasEffectiveModifier(node, 64 /* ModifierFlags.Readonly */); } ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier; function hasDecorators(node) { - return hasSyntacticModifier(node, 131072 /* Decorator */); + return hasSyntacticModifier(node, 131072 /* ModifierFlags.Decorator */); } ts.hasDecorators = hasDecorators; function getSelectedEffectiveModifierFlags(node, flags) { @@ -18839,16 +18961,16 @@ var ts; } ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags; function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) { - if (node.kind >= 0 /* FirstToken */ && node.kind <= 160 /* LastToken */) { - return 0 /* None */; + if (node.kind >= 0 /* SyntaxKind.FirstToken */ && node.kind <= 160 /* SyntaxKind.LastToken */) { + return 0 /* ModifierFlags.None */; } - if (!(node.modifierFlagsCache & 536870912 /* HasComputedFlags */)) { - node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* HasComputedFlags */; + if (!(node.modifierFlagsCache & 536870912 /* ModifierFlags.HasComputedFlags */)) { + node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912 /* ModifierFlags.HasComputedFlags */; } - if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { - node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* HasComputedJSDocModifiers */; + if (includeJSDoc && !(node.modifierFlagsCache & 4096 /* ModifierFlags.HasComputedJSDocModifiers */) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) { + node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096 /* ModifierFlags.HasComputedJSDocModifiers */; } - return node.modifierFlagsCache & ~(536870912 /* HasComputedFlags */ | 4096 /* HasComputedJSDocModifiers */); + return node.modifierFlagsCache & ~(536870912 /* ModifierFlags.HasComputedFlags */ | 4096 /* ModifierFlags.HasComputedJSDocModifiers */); } /** * Gets the effective ModifierFlags for the provided node, including JSDoc modifiers. The modifiers will be cached on the node to improve performance. @@ -18873,22 +18995,22 @@ var ts; } ts.getSyntacticModifierFlags = getSyntacticModifierFlags; function getJSDocModifierFlagsNoCache(node) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (!!node.parent && !ts.isParameter(node)) { if (isInJSFile(node)) { if (ts.getJSDocPublicTagNoCache(node)) - flags |= 4 /* Public */; + flags |= 4 /* ModifierFlags.Public */; if (ts.getJSDocPrivateTagNoCache(node)) - flags |= 8 /* Private */; + flags |= 8 /* ModifierFlags.Private */; if (ts.getJSDocProtectedTagNoCache(node)) - flags |= 16 /* Protected */; + flags |= 16 /* ModifierFlags.Protected */; if (ts.getJSDocReadonlyTagNoCache(node)) - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; if (ts.getJSDocOverrideTagNoCache(node)) - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; } if (ts.getJSDocDeprecatedTagNoCache(node)) - flags |= 8192 /* Deprecated */; + flags |= 8192 /* ModifierFlags.Deprecated */; } return flags; } @@ -18907,15 +19029,15 @@ var ts; * NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc. */ function getSyntacticModifierFlagsNoCache(node) { - var flags = ts.canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* None */; - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 79 /* Identifier */ && node.isInJSDocNamespace)) { - flags |= 1 /* Export */; + var flags = ts.canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : 0 /* ModifierFlags.None */; + if (node.flags & 4 /* NodeFlags.NestedNamespace */ || (node.kind === 79 /* SyntaxKind.Identifier */ && node.isInJSDocNamespace)) { + flags |= 1 /* ModifierFlags.Export */; } return flags; } ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache; function modifiersToFlags(modifiers) { - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; if (modifiers) { for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; @@ -18927,23 +19049,23 @@ var ts; ts.modifiersToFlags = modifiersToFlags; function modifierToFlag(token) { switch (token) { - case 124 /* StaticKeyword */: return 32 /* Static */; - case 123 /* PublicKeyword */: return 4 /* Public */; - case 122 /* ProtectedKeyword */: return 16 /* Protected */; - case 121 /* PrivateKeyword */: return 8 /* Private */; - case 126 /* AbstractKeyword */: return 128 /* Abstract */; - case 93 /* ExportKeyword */: return 1 /* Export */; - case 135 /* DeclareKeyword */: return 2 /* Ambient */; - case 85 /* ConstKeyword */: return 2048 /* Const */; - case 88 /* DefaultKeyword */: return 512 /* Default */; - case 131 /* AsyncKeyword */: return 256 /* Async */; - case 145 /* ReadonlyKeyword */: return 64 /* Readonly */; - case 159 /* OverrideKeyword */: return 16384 /* Override */; - case 101 /* InKeyword */: return 32768 /* In */; - case 144 /* OutKeyword */: return 65536 /* Out */; - case 165 /* Decorator */: return 131072 /* Decorator */; - } - return 0 /* None */; + case 124 /* SyntaxKind.StaticKeyword */: return 32 /* ModifierFlags.Static */; + case 123 /* SyntaxKind.PublicKeyword */: return 4 /* ModifierFlags.Public */; + case 122 /* SyntaxKind.ProtectedKeyword */: return 16 /* ModifierFlags.Protected */; + case 121 /* SyntaxKind.PrivateKeyword */: return 8 /* ModifierFlags.Private */; + case 126 /* SyntaxKind.AbstractKeyword */: return 128 /* ModifierFlags.Abstract */; + case 93 /* SyntaxKind.ExportKeyword */: return 1 /* ModifierFlags.Export */; + case 135 /* SyntaxKind.DeclareKeyword */: return 2 /* ModifierFlags.Ambient */; + case 85 /* SyntaxKind.ConstKeyword */: return 2048 /* ModifierFlags.Const */; + case 88 /* SyntaxKind.DefaultKeyword */: return 512 /* ModifierFlags.Default */; + case 131 /* SyntaxKind.AsyncKeyword */: return 256 /* ModifierFlags.Async */; + case 145 /* SyntaxKind.ReadonlyKeyword */: return 64 /* ModifierFlags.Readonly */; + case 159 /* SyntaxKind.OverrideKeyword */: return 16384 /* ModifierFlags.Override */; + case 101 /* SyntaxKind.InKeyword */: return 32768 /* ModifierFlags.In */; + case 144 /* SyntaxKind.OutKeyword */: return 65536 /* ModifierFlags.Out */; + case 165 /* SyntaxKind.Decorator */: return 131072 /* ModifierFlags.Decorator */; + } + return 0 /* ModifierFlags.None */; } ts.modifierToFlag = modifierToFlag; function createModifiers(modifierFlags) { @@ -18951,15 +19073,15 @@ var ts; } ts.createModifiers = createModifiers; function isLogicalOperator(token) { - return token === 56 /* BarBarToken */ - || token === 55 /* AmpersandAmpersandToken */ - || token === 53 /* ExclamationToken */; + return token === 56 /* SyntaxKind.BarBarToken */ + || token === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || token === 53 /* SyntaxKind.ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isLogicalOrCoalescingAssignmentOperator(token) { - return token === 75 /* BarBarEqualsToken */ - || token === 76 /* AmpersandAmpersandEqualsToken */ - || token === 77 /* QuestionQuestionEqualsToken */; + return token === 75 /* SyntaxKind.BarBarEqualsToken */ + || token === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */ + || token === 77 /* SyntaxKind.QuestionQuestionEqualsToken */; } ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator; function isLogicalOrCoalescingAssignmentExpression(expr) { @@ -18967,7 +19089,7 @@ var ts; } ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression; function isAssignmentOperator(token) { - return token >= 63 /* FirstAssignment */ && token <= 78 /* LastAssignment */; + return token >= 63 /* SyntaxKind.FirstAssignment */ && token <= 78 /* SyntaxKind.LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -18980,14 +19102,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 63 /* EqualsToken */ + ? node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -18999,8 +19121,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 205 /* ObjectLiteralExpression */ - || kind === 204 /* ArrayLiteralExpression */; + return kind === 205 /* SyntaxKind.ObjectLiteralExpression */ + || kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } return false; } @@ -19010,33 +19132,33 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 79 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 79 /* SyntaxKind.Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; function getFirstIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } ts.getFirstIdentifier = getFirstIdentifier; function isDottedName(node) { - return node.kind === 79 /* Identifier */ - || node.kind === 108 /* ThisKeyword */ - || node.kind === 106 /* SuperKeyword */ - || node.kind === 231 /* MetaProperty */ - || node.kind === 206 /* PropertyAccessExpression */ && isDottedName(node.expression) - || node.kind === 212 /* ParenthesizedExpression */ && isDottedName(node.expression); + return node.kind === 79 /* SyntaxKind.Identifier */ + || node.kind === 108 /* SyntaxKind.ThisKeyword */ + || node.kind === 106 /* SyntaxKind.SuperKeyword */ + || node.kind === 231 /* SyntaxKind.MetaProperty */ + || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isDottedName(node.expression) + || node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && isDottedName(node.expression); } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { @@ -19067,8 +19189,8 @@ var ts; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 161 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 161 /* SyntaxKind.QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isRightSideOfAccessExpression(node) { @@ -19083,12 +19205,12 @@ var ts; } ts.isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName = isRightSideOfQualifiedNameOrPropertyAccessOrJSDocMemberName; function isEmptyObjectLiteral(expression) { - return expression.kind === 205 /* ObjectLiteralExpression */ && + return expression.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 204 /* ArrayLiteralExpression */ && + return expression.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -19104,7 +19226,7 @@ var ts; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isExportDefaultSymbol(symbol) { - return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* Default */); + return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512 /* ModifierFlags.Default */); } /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTSExtension(fileName) { @@ -19275,9 +19397,9 @@ var ts; var lineFeed = "\n"; function getNewLineCharacter(options, getNewLine) { switch (options.newLine) { - case 0 /* CarriageReturnLineFeed */: + case 0 /* NewLineKind.CarriageReturnLineFeed */: return carriageReturnLineFeed; - case 1 /* LineFeed */: + case 1 /* NewLineKind.LineFeed */: return lineFeed; } return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed; @@ -19422,8 +19544,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 260 /* EnumDeclaration */: - case 261 /* ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -19447,32 +19569,33 @@ var ts; } ts.closeFileWatcher = closeFileWatcher; function getCheckFlags(symbol) { - return symbol.flags & 33554432 /* Transient */ ? symbol.checkFlags : 0; + return symbol.flags & 33554432 /* SymbolFlags.Transient */ ? symbol.checkFlags : 0; } ts.getCheckFlags = getCheckFlags; function getDeclarationModifierFlagsFromSymbol(s, isWrite) { if (isWrite === void 0) { isWrite = false; } if (s.valueDeclaration) { - var declaration = (isWrite && s.declarations && ts.find(s.declarations, function (d) { return d.kind === 173 /* SetAccessor */; })) || s.valueDeclaration; + var declaration = (isWrite && s.declarations && ts.find(s.declarations, ts.isSetAccessorDeclaration)) + || (s.flags & 32768 /* SymbolFlags.GetAccessor */ && ts.find(s.declarations, ts.isGetAccessorDeclaration)) || s.valueDeclaration; var flags = ts.getCombinedModifierFlags(declaration); - return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; + return s.parent && s.parent.flags & 32 /* SymbolFlags.Class */ ? flags : flags & ~28 /* ModifierFlags.AccessibilityModifier */; } - if (getCheckFlags(s) & 6 /* Synthetic */) { + if (getCheckFlags(s) & 6 /* CheckFlags.Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 1024 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 256 /* ContainsPublic */ ? 4 /* Public */ : - 16 /* Protected */; - var staticModifier = checkFlags & 2048 /* ContainsStatic */ ? 32 /* Static */ : 0; + var accessModifier = checkFlags & 1024 /* CheckFlags.ContainsPrivate */ ? 8 /* ModifierFlags.Private */ : + checkFlags & 256 /* CheckFlags.ContainsPublic */ ? 4 /* ModifierFlags.Public */ : + 16 /* ModifierFlags.Protected */; + var staticModifier = checkFlags & 2048 /* CheckFlags.ContainsStatic */ ? 32 /* ModifierFlags.Static */ : 0; return accessModifier | staticModifier; } - if (s.flags & 4194304 /* Prototype */) { - return 4 /* Public */ | 32 /* Static */; + if (s.flags & 4194304 /* SymbolFlags.Prototype */) { + return 4 /* ModifierFlags.Public */ | 32 /* ModifierFlags.Static */; } return 0; } ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol; function skipAlias(symbol, checker) { - return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol; + return symbol.flags & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(symbol) : symbol; } ts.skipAlias = skipAlias; /** See comment on `declareModuleMember` in `binder.ts`. */ @@ -19481,11 +19604,11 @@ var ts; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; function isWriteOnlyAccess(node) { - return accessKind(node) === 1 /* Write */; + return accessKind(node) === 1 /* AccessKind.Write */; } ts.isWriteOnlyAccess = isWriteOnlyAccess; function isWriteAccess(node) { - return accessKind(node) !== 0 /* Read */; + return accessKind(node) !== 0 /* AccessKind.Read */; } ts.isWriteAccess = isWriteAccess; var AccessKind; @@ -19500,47 +19623,47 @@ var ts; function accessKind(node) { var parent = node.parent; if (!parent) - return 0 /* Read */; + return 0 /* AccessKind.Read */; switch (parent.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return accessKind(parent); - case 220 /* PostfixUnaryExpression */: - case 219 /* PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var operator = parent.operator; - return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 221 /* BinaryExpression */: + return operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */ ? writeOrReadWrite() : 0 /* AccessKind.Read */; + case 221 /* SyntaxKind.BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 63 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() - : 0 /* Read */; - case 206 /* PropertyAccessExpression */: - return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 296 /* PropertyAssignment */: { + operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ ? 1 /* AccessKind.Write */ : writeOrReadWrite() + : 0 /* AccessKind.Read */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + return parent.name !== node ? 0 /* AccessKind.Read */ : accessKind(parent); + case 296 /* SyntaxKind.PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. - return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 204 /* ArrayLiteralExpression */: + return node === parent.objectAssignmentInitializer ? 0 /* AccessKind.Read */ : accessKind(parent.parent); + case 204 /* SyntaxKind.ArrayLiteralExpression */: return accessKind(parent); default: - return 0 /* Read */; + return 0 /* AccessKind.Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && walkUpParenthesizedExpressions(parent.parent).kind === 238 /* SyntaxKind.ExpressionStatement */ ? 1 /* AccessKind.Write */ : 2 /* AccessKind.ReadWrite */; } } function reverseAccessKind(a) { switch (a) { - case 0 /* Read */: - return 1 /* Write */; - case 1 /* Write */: - return 0 /* Read */; - case 2 /* ReadWrite */: - return 2 /* ReadWrite */; + case 0 /* AccessKind.Read */: + return 1 /* AccessKind.Write */; + case 1 /* AccessKind.Write */: + return 0 /* AccessKind.Read */; + case 2 /* AccessKind.ReadWrite */: + return 2 /* AccessKind.ReadWrite */; default: return ts.Debug.assertNever(a); } @@ -19610,9 +19733,9 @@ var ts; } ts.mutateMap = mutateMap; function isAbstractConstructorSymbol(symbol) { - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var declaration = getClassLikeDeclarationOfSymbol(symbol); - return !!declaration && hasSyntacticModifier(declaration, 128 /* Abstract */); + return !!declaration && hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); } return false; } @@ -19623,11 +19746,11 @@ var ts; } ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol; function getObjectFlags(type) { - return type.flags & 3899393 /* ObjectFlagsType */ ? type.objectFlags : 0; + return type.flags & 3899393 /* TypeFlags.ObjectFlagsType */ ? type.objectFlags : 0; } ts.getObjectFlags = getObjectFlags; function typeHasCallOrConstructSignatures(type, checker) { - return checker.getSignaturesOfType(type, 0 /* Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* Construct */).length !== 0; + return checker.getSignaturesOfType(type, 0 /* SignatureKind.Call */).length !== 0 || checker.getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length !== 0; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { @@ -19674,44 +19797,44 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) - || kind === 130 /* AnyKeyword */ - || kind === 155 /* UnknownKeyword */ - || kind === 147 /* NumberKeyword */ - || kind === 158 /* BigIntKeyword */ - || kind === 148 /* ObjectKeyword */ - || kind === 133 /* BooleanKeyword */ - || kind === 150 /* StringKeyword */ - || kind === 151 /* SymbolKeyword */ - || kind === 114 /* VoidKeyword */ - || kind === 153 /* UndefinedKeyword */ - || kind === 143 /* NeverKeyword */ - || kind === 228 /* ExpressionWithTypeArguments */ - || kind === 312 /* JSDocAllType */ - || kind === 313 /* JSDocUnknownType */ - || kind === 314 /* JSDocNullableType */ - || kind === 315 /* JSDocNonNullableType */ - || kind === 316 /* JSDocOptionalType */ - || kind === 317 /* JSDocFunctionType */ - || kind === 318 /* JSDocVariadicType */; + return (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) + || kind === 130 /* SyntaxKind.AnyKeyword */ + || kind === 155 /* SyntaxKind.UnknownKeyword */ + || kind === 147 /* SyntaxKind.NumberKeyword */ + || kind === 158 /* SyntaxKind.BigIntKeyword */ + || kind === 148 /* SyntaxKind.ObjectKeyword */ + || kind === 133 /* SyntaxKind.BooleanKeyword */ + || kind === 150 /* SyntaxKind.StringKeyword */ + || kind === 151 /* SyntaxKind.SymbolKeyword */ + || kind === 114 /* SyntaxKind.VoidKeyword */ + || kind === 153 /* SyntaxKind.UndefinedKeyword */ + || kind === 143 /* SyntaxKind.NeverKeyword */ + || kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ + || kind === 312 /* SyntaxKind.JSDocAllType */ + || kind === 313 /* SyntaxKind.JSDocUnknownType */ + || kind === 314 /* SyntaxKind.JSDocNullableType */ + || kind === 315 /* SyntaxKind.JSDocNonNullableType */ + || kind === 316 /* SyntaxKind.JSDocOptionalType */ + || kind === 317 /* SyntaxKind.JSDocFunctionType */ + || kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */ || node.kind === 207 /* ElementAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function getNameOfAccessExpression(node) { - if (node.kind === 206 /* PropertyAccessExpression */) { + if (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { return node.name; } - ts.Debug.assert(node.kind === 207 /* ElementAccessExpression */); + ts.Debug.assert(node.kind === 207 /* SyntaxKind.ElementAccessExpression */); return node.argumentExpression; } ts.getNameOfAccessExpression = getNameOfAccessExpression; function isBundleFileTextLike(section) { switch (section.kind) { - case "text" /* Text */: - case "internal" /* Internal */: + case "text" /* BundleFileSectionKind.Text */: + case "internal" /* BundleFileSectionKind.Internal */: return true; default: return false; @@ -19719,7 +19842,7 @@ var ts; } ts.isBundleFileTextLike = isBundleFileTextLike; function isNamedImportsOrExports(node) { - return node.kind === 269 /* NamedImports */ || node.kind === 273 /* NamedExports */; + return node.kind === 269 /* SyntaxKind.NamedImports */ || node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function getLeftmostAccessExpression(expr) { @@ -19734,13 +19857,13 @@ var ts; return walkAccessExpression(name.parent); } function walkAccessExpression(access) { - if (access.kind === 206 /* PropertyAccessExpression */) { + if (access.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var res = action(access.name); if (res !== undefined) { return res; } } - else if (access.kind === 207 /* ElementAccessExpression */) { + else if (access.kind === 207 /* SyntaxKind.ElementAccessExpression */) { if (ts.isIdentifier(access.argumentExpression) || ts.isStringLiteralLike(access.argumentExpression)) { var res = action(access.argumentExpression); if (res !== undefined) { @@ -19767,28 +19890,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: node = node.operand; continue; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: node = node.left; continue; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: node = node.condition; continue; - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: node = node.tag; continue; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 229 /* AsExpression */: - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: - case 230 /* NonNullExpression */: - case 350 /* PartiallyEmittedExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: node = node.expression; continue; } @@ -19822,9 +19945,9 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.modifierFlagsCache = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.modifierFlagsCache = 0 /* ModifierFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; } @@ -19833,8 +19956,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; } function Identifier(kind, pos, end) { @@ -19842,8 +19965,8 @@ var ts; this.end = end; this.kind = kind; this.id = 0; - this.flags = 0 /* None */; - this.transformFlags = 0 /* None */; + this.flags = 0 /* NodeFlags.None */; + this.transformFlags = 0 /* TransformFlags.None */; this.parent = undefined; this.original = undefined; this.flowNode = undefined; @@ -20038,7 +20161,7 @@ var ts; function compareDiagnostics(d1, d2) { return compareDiagnosticsSkipRelatedInformation(d1, d2) || compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnostics = compareDiagnostics; function compareDiagnosticsSkipRelatedInformation(d1, d2) { @@ -20047,43 +20170,43 @@ var ts; ts.compareValues(d1.length, d2.length) || ts.compareValues(d1.code, d2.code) || compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; + 0 /* Comparison.EqualTo */; } ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; function compareRelatedInformation(d1, d2) { if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (d1.relatedInformation && d2.relatedInformation) { return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { var d2i = d2.relatedInformation[index]; return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; + }) || 0 /* Comparison.EqualTo */; } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; + return d1.relatedInformation ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; } function compareMessageText(t1, t2) { if (typeof t1 === "string" && typeof t2 === "string") { return ts.compareStringsCaseSensitive(t1, t2); } else if (typeof t1 === "string") { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (typeof t2 === "string") { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); if (res) { return res; } if (!t1.next && !t2.next) { - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } if (!t1.next) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } if (!t2.next) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } var len = Math.min(t1.next.length, t2.next.length); for (var i = 0; i < len; i++) { @@ -20093,16 +20216,16 @@ var ts; } } if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; } else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; } - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; } function getLanguageVariant(scriptKind) { // .tsx and .jsx files are treated as jsx language variant. - return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */; + return scriptKind === 4 /* ScriptKind.TSX */ || scriptKind === 2 /* ScriptKind.JSX */ || scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 6 /* ScriptKind.JSON */ ? 1 /* LanguageVariant.JSX */ : 0 /* LanguageVariant.Standard */; } ts.getLanguageVariant = getLanguageVariant; /** @@ -20111,7 +20234,7 @@ var ts; * Unfortunately, there's no `NodeFlag` space to do the same for JSX. */ function walkTreeForJSXTags(node) { - if (!(node.transformFlags & 2 /* ContainsJsx */)) + if (!(node.transformFlags & 2 /* TransformFlags.ContainsJsx */)) return undefined; return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags); } @@ -20128,7 +20251,7 @@ var ts; // Excludes declaration files - they still require an explicit `export {}` or the like // for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files // that aren't esm-mode (meaning not in a `type: module` scope). - return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Cjs */, ".cts" /* Cts */]))) && !file.isDeclarationFile ? true : undefined; + return (file.impliedNodeFormat === ts.ModuleKind.ESNext || (ts.fileExtensionIsOneOf(file.fileName, [".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */]))) && !file.isDeclarationFile ? true : undefined; } function getSetExternalModuleIndicator(options) { // TODO: Should this callback be cached? @@ -20148,13 +20271,10 @@ var ts; // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness // otherwise, the presence of import or export statments (or import.meta) implies module-ness var checks = [ts.isFileProbablyExternalModule]; - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { checks.push(isFileModuleFromUsingJSXTag); } - var moduleKind = getEmitModuleKind(options); - if (moduleKind === ts.ModuleKind.Node16 || moduleKind === ts.ModuleKind.NodeNext) { - checks.push(isFileForcedToBeModuleByFormat); - } + checks.push(isFileForcedToBeModuleByFormat); var combined_1 = ts.or.apply(void 0, checks); var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); }; return callback; @@ -20163,15 +20283,15 @@ var ts; ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator; function getEmitScriptTarget(compilerOptions) { return compilerOptions.target || - (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ES2022 */) || - (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ESNext */) || - 0 /* ES3 */; + (compilerOptions.module === ts.ModuleKind.Node16 && 9 /* ScriptTarget.ES2022 */) || + (compilerOptions.module === ts.ModuleKind.NodeNext && 99 /* ScriptTarget.ESNext */) || + 0 /* ScriptTarget.ES3 */; } ts.getEmitScriptTarget = getEmitScriptTarget; function getEmitModuleKind(compilerOptions) { return typeof compilerOptions.module === "number" ? compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; + getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } ts.getEmitModuleKind = getEmitModuleKind; function getEmitModuleResolutionKind(compilerOptions) { @@ -20269,7 +20389,7 @@ var ts; } ts.getAllowJSCompilerOption = getAllowJSCompilerOption; function getUseDefineForClassFields(compilerOptions) { - return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */ : compilerOptions.useDefineForClassFields; } ts.getUseDefineForClassFields = getUseDefineForClassFields; function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { @@ -20290,14 +20410,14 @@ var ts; ts.getCompilerOptionValue = getCompilerOptionValue; function getJSXTransformEnabled(options) { var jsx = options.jsx; - return jsx === 2 /* React */ || jsx === 4 /* ReactJSX */ || jsx === 5 /* ReactJSXDev */; + return jsx === 2 /* JsxEmit.React */ || jsx === 4 /* JsxEmit.ReactJSX */ || jsx === 5 /* JsxEmit.ReactJSXDev */; } ts.getJSXTransformEnabled = getJSXTransformEnabled; function getJSXImplicitImportBase(compilerOptions, file) { var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource"); var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[jsxImportSourcePragmas.length - 1] : jsxImportSourcePragmas; - return compilerOptions.jsx === 4 /* ReactJSX */ || - compilerOptions.jsx === 5 /* ReactJSXDev */ || + return compilerOptions.jsx === 4 /* JsxEmit.ReactJSX */ || + compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ || compilerOptions.jsxImportSource || jsxImportSourcePragma ? (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" : @@ -20305,13 +20425,13 @@ var ts; } ts.getJSXImplicitImportBase = getJSXImplicitImportBase; function getJSXRuntimeImport(base, options) { - return base ? base + "/" + (options.jsx === 5 /* ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; + return base ? "".concat(base, "/").concat(options.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsx-dev-runtime" : "jsx-runtime") : undefined; } ts.getJSXRuntimeImport = getJSXRuntimeImport; function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { + if (str.charCodeAt(i) === 42 /* CharacterCodes.asterisk */) { if (!seenAsterisk) { seenAsterisk = true; } @@ -20410,9 +20530,9 @@ var ts; function escapeRegExpCharacter(match) { return "\\" + match; } - var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; + var wildcardCharCodes = [42 /* CharacterCodes.asterisk */, 63 /* CharacterCodes.question */]; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; - var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; + var implicitExcludePathRegexPattern = "(?!(".concat(ts.commonPackageFolders.join("|"), ")(/|$))"); var filesMatcher = { /** * Matches any single directory segment unless it is the last segment and a .min.js file @@ -20425,7 +20545,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); } }; var directoriesMatcher = { @@ -20434,7 +20554,7 @@ var ts; * Regex for the ** wildcard. Matches any number of subdirectories. When used for including * files or directories, does not match subdirectories that start with a . character */ - doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?", + doubleAsteriskRegexFragment: "(/".concat(implicitExcludePathRegexPattern, "[^/.][^/]*)*?"), replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); } }; var excludeMatcher = { @@ -20452,10 +20572,10 @@ var ts; if (!patterns || !patterns.length) { return undefined; } - var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|"); + var pattern = patterns.map(function (pattern) { return "(".concat(pattern, ")"); }).join("|"); // If excluding, match "foo/bar/baz...", but if including, only allow "foo". var terminator = usage === "exclude" ? "($|/)" : "$"; - return "^(" + pattern + ")" + terminator; + return "^(".concat(pattern, ")").concat(terminator); } ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard; function getRegularExpressionsForWildcards(specs, basePath, usage) { @@ -20477,7 +20597,7 @@ var ts; ts.isImplicitGlob = isImplicitGlob; function getPatternFromSpec(spec, basePath, usage) { var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]); - return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$"); + return pattern && "^(".concat(pattern, ")").concat(usage === "exclude" ? "($|/)" : "$"); } ts.getPatternFromSpec = getPatternFromSpec; function getSubPatternFromSpec(spec, basePath, usage, _a) { @@ -20514,11 +20634,11 @@ var ts; // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* - if (component.charCodeAt(0) === 42 /* asterisk */) { + if (component.charCodeAt(0) === 42 /* CharacterCodes.asterisk */) { componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } - else if (component.charCodeAt(0) === 63 /* question */) { + else if (component.charCodeAt(0) === 63 /* CharacterCodes.question */) { componentPattern += "[^./]"; component = component.substr(1); } @@ -20555,7 +20675,7 @@ var ts; currentDirectory = ts.normalizePath(currentDirectory); var absolutePath = ts.combinePaths(currentDirectory, path); return { - includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), + includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"), excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"), @@ -20680,44 +20800,44 @@ var ts; // If the 'scriptKind' is 'undefined' or 'Unknown' then we attempt // to get the ScriptKind from the file name. If it cannot be resolved // from the file name then the default 'TS' script kind is returned. - return scriptKind || getScriptKindFromFileName(fileName) || 3 /* TS */; + return scriptKind || getScriptKindFromFileName(fileName) || 3 /* ScriptKind.TS */; } ts.ensureScriptKind = ensureScriptKind; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: - case ".cjs" /* Cjs */: - case ".mjs" /* Mjs */: - return 1 /* JS */; - case ".jsx" /* Jsx */: - return 2 /* JSX */; - case ".ts" /* Ts */: - case ".cts" /* Cts */: - case ".mts" /* Mts */: - return 3 /* TS */; - case ".tsx" /* Tsx */: - return 4 /* TSX */; - case ".json" /* Json */: - return 6 /* JSON */; + case ".js" /* Extension.Js */: + case ".cjs" /* Extension.Cjs */: + case ".mjs" /* Extension.Mjs */: + return 1 /* ScriptKind.JS */; + case ".jsx" /* Extension.Jsx */: + return 2 /* ScriptKind.JSX */; + case ".ts" /* Extension.Ts */: + case ".cts" /* Extension.Cts */: + case ".mts" /* Extension.Mts */: + return 3 /* ScriptKind.TS */; + case ".tsx" /* Extension.Tsx */: + return 4 /* ScriptKind.TSX */; + case ".json" /* Extension.Json */: + return 6 /* ScriptKind.JSON */; default: - return 0 /* Unknown */; + return 0 /* ScriptKind.Unknown */; } } ts.getScriptKindFromFileName = getScriptKindFromFileName; /** * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ - ts.supportedTSExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */], [".cts" /* Cts */, ".d.cts" /* Dcts */], [".mts" /* Mts */, ".d.mts" /* Dmts */]]; + ts.supportedTSExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */]]; ts.supportedTSExtensionsFlat = ts.flatten(ts.supportedTSExtensions); - var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Json */]], false); + var supportedTSExtensionsWithJson = __spreadArray(__spreadArray([], ts.supportedTSExtensions, true), [[".json" /* Extension.Json */]], false); /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - var supportedTSExtensionsForExtractExtension = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */, ".cts" /* Cts */, ".mts" /* Mts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".cts" /* Cts */, ".mts" /* Mts */]; - ts.supportedJSExtensions = [[".js" /* Js */, ".jsx" /* Jsx */], [".mjs" /* Mjs */], [".cjs" /* Cjs */]]; + var supportedTSExtensionsForExtractExtension = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */]; + ts.supportedJSExtensions = [[".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".mjs" /* Extension.Mjs */], [".cjs" /* Extension.Cjs */]]; ts.supportedJSExtensionsFlat = ts.flatten(ts.supportedJSExtensions); - var allSupportedExtensions = [[".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */, ".js" /* Js */, ".jsx" /* Jsx */], [".cts" /* Cts */, ".d.cts" /* Dcts */, ".cjs" /* Cjs */], [".mts" /* Mts */, ".d.mts" /* Dmts */, ".mjs" /* Mjs */]]; - var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Json */]], false); - ts.supportedDeclarationExtensions = [".d.ts" /* Dts */, ".d.cts" /* Dcts */, ".d.mts" /* Dmts */]; + var allSupportedExtensions = [[".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".d.ts" /* Extension.Dts */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */], [".cts" /* Extension.Cts */, ".d.cts" /* Extension.Dcts */, ".cjs" /* Extension.Cjs */], [".mts" /* Extension.Mts */, ".d.mts" /* Extension.Dmts */, ".mjs" /* Extension.Mjs */]]; + var allSupportedExtensionsWithJson = __spreadArray(__spreadArray([], allSupportedExtensions, true), [[".json" /* Extension.Json */]], false); + ts.supportedDeclarationExtensions = [".d.ts" /* Extension.Dts */, ".d.cts" /* Extension.Dcts */, ".d.mts" /* Extension.Dmts */]; function getSupportedExtensions(options, extraFileExtensions) { var needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { @@ -20725,7 +20845,7 @@ var ts; } var builtins = needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions; var flatBuiltins = ts.flatten(builtins); - var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); + var extensions = __spreadArray(__spreadArray([], builtins, true), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 /* ScriptKind.Deferred */ || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension) === -1 ? [x.extension] : undefined; }), true); return extensions; } ts.getSupportedExtensions = getSupportedExtensions; @@ -20736,11 +20856,11 @@ var ts; return allSupportedExtensionsWithJson; if (supportedExtensions === ts.supportedTSExtensions) return supportedTSExtensionsWithJson; - return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Json */]], false); + return __spreadArray(__spreadArray([], supportedExtensions, true), [[".json" /* Extension.Json */]], false); } ts.getSupportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule; function isJSLike(scriptKind) { - return scriptKind === 1 /* JS */ || scriptKind === 2 /* JSX */; + return scriptKind === 1 /* ScriptKind.JS */ || scriptKind === 2 /* ScriptKind.JSX */; } function hasJSFileExtension(fileName) { return ts.some(ts.supportedJSExtensionsFlat, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -20771,7 +20891,7 @@ var ts; return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2)); } ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators; - var extensionsToRemove = [".d.ts" /* Dts */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".mjs" /* Mjs */, ".mts" /* Mts */, ".cjs" /* Cjs */, ".cts" /* Cts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */, ".json" /* Json */]; + var extensionsToRemove = [".d.ts" /* Extension.Dts */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".mjs" /* Extension.Mjs */, ".mts" /* Extension.Mts */, ".cjs" /* Extension.Cjs */, ".cts" /* Extension.Cts */, ".ts" /* Extension.Ts */, ".js" /* Extension.Js */, ".tsx" /* Extension.Tsx */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -20824,11 +20944,11 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTS(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */ || ext === ".cts" /* Cts */ || ext === ".mts" /* Mts */ || ext === ".d.mts" /* Dmts */ || ext === ".d.cts" /* Dcts */; + return ext === ".ts" /* Extension.Ts */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".d.ts" /* Extension.Dts */ || ext === ".cts" /* Extension.Cts */ || ext === ".mts" /* Extension.Mts */ || ext === ".d.mts" /* Extension.Dmts */ || ext === ".d.cts" /* Extension.Dcts */; } ts.extensionIsTS = extensionIsTS; function resolutionExtensionIsTSOrJson(ext) { - return extensionIsTS(ext) || ext === ".json" /* Json */; + return extensionIsTS(ext) || ext === ".json" /* Extension.Json */; } ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson; /** @@ -20837,7 +20957,7 @@ var ts; */ function extensionFromPath(path) { var ext = tryGetExtensionFromPath(path); - return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension."); + return ext !== undefined ? ext : ts.Debug.fail("File ".concat(path, " has unknown extension.")); } ts.extensionFromPath = extensionFromPath; function isAnySupportedFileExtension(path) { @@ -20946,23 +21066,23 @@ var ts; function parsePseudoBigInt(stringValue) { var log2Base; switch (stringValue.charCodeAt(1)) { // "x" in "0x123" - case 98 /* b */: - case 66 /* B */: // 0b or 0B + case 98 /* CharacterCodes.b */: + case 66 /* CharacterCodes.B */: // 0b or 0B log2Base = 1; break; - case 111 /* o */: - case 79 /* O */: // 0o or 0O + case 111 /* CharacterCodes.o */: + case 79 /* CharacterCodes.O */: // 0o or 0O log2Base = 3; break; - case 120 /* x */: - case 88 /* X */: // 0x or 0X + case 120 /* CharacterCodes.x */: + case 88 /* CharacterCodes.X */: // 0x or 0X log2Base = 4; break; default: // already in decimal; omit trailing "n" var nIndex = stringValue.length - 1; // Skip leading 0s var nonZeroStart = 0; - while (stringValue.charCodeAt(nonZeroStart) === 48 /* _0 */) { + while (stringValue.charCodeAt(nonZeroStart) === 48 /* CharacterCodes._0 */) { nonZeroStart++; } return stringValue.slice(nonZeroStart, nIndex) || "0"; @@ -20978,10 +21098,10 @@ var ts; var segment = bitOffset >>> 4; var digitChar = stringValue.charCodeAt(i); // Find character range: 0-9 < A-F < a-f - var digit = digitChar <= 57 /* _9 */ - ? digitChar - 48 /* _0 */ + var digit = digitChar <= 57 /* CharacterCodes._9 */ + ? digitChar - 48 /* CharacterCodes._0 */ : 10 + digitChar - - (digitChar <= 70 /* F */ ? 65 /* A */ : 97 /* a */); + (digitChar <= 70 /* CharacterCodes.F */ ? 65 /* CharacterCodes.A */ : 97 /* CharacterCodes.a */); var shiftedDigit = digit << (bitOffset & 15); segments[segment] |= shiftedDigit; var residual = shiftedDigit >>> 16; @@ -21016,7 +21136,7 @@ var ts; } ts.pseudoBigIntToString = pseudoBigIntToString; function isValidTypeOnlyAliasUseSite(useSite) { - return !!(useSite.flags & 16777216 /* Ambient */) + return !!(useSite.flags & 16777216 /* NodeFlags.Ambient */) || isPartOfTypeQuery(useSite) || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) @@ -21027,34 +21147,34 @@ var ts; return ts.isIdentifier(useSite) && ts.isShorthandPropertyAssignment(useSite.parent) && useSite.parent.name === useSite; } function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) { - while (node.kind === 79 /* Identifier */ || node.kind === 206 /* PropertyAccessExpression */) { + while (node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } - if (hasSyntacticModifier(node.parent, 128 /* Abstract */)) { + if (hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */)) { return true; } var containerKind = node.parent.parent.kind; - return containerKind === 258 /* InterfaceDeclaration */ || containerKind === 182 /* TypeLiteral */; + return containerKind === 258 /* SyntaxKind.InterfaceDeclaration */ || containerKind === 182 /* SyntaxKind.TypeLiteral */; } /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ function isIdentifierInNonEmittingHeritageClause(node) { - if (node.kind !== 79 /* Identifier */) + if (node.kind !== 79 /* SyntaxKind.Identifier */) return false; var heritageClause = ts.findAncestor(node.parent, function (parent) { switch (parent.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return true; - case 206 /* PropertyAccessExpression */: - case 228 /* ExpressionWithTypeArguments */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return false; default: return "quit"; } }); - return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* InterfaceDeclaration */; + return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 117 /* SyntaxKind.ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 258 /* SyntaxKind.InterfaceDeclaration */; } function isIdentifierTypeReference(node) { return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); @@ -21195,7 +21315,7 @@ var ts; node = parent; continue; } - if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { // left side of comma is always unused if (node === parent.left) return true; @@ -21215,22 +21335,22 @@ var ts; if (!node.parent) return undefined; switch (node.kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: var parent_1 = node.parent; - return parent_1.kind === 190 /* InferType */ ? undefined : parent_1.typeParameters; - case 164 /* Parameter */: + return parent_1.kind === 190 /* SyntaxKind.InferType */ ? undefined : parent_1.typeParameters; + case 164 /* SyntaxKind.Parameter */: return node.parent.parameters; - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return node.parent.templateSpans; - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return node.parent.templateSpans; - case 165 /* Decorator */: { + case 165 /* SyntaxKind.Decorator */: { var parent_2 = node.parent; return ts.canHaveDecorators(parent_2) ? parent_2.modifiers : ts.canHaveIllegalDecorators(parent_2) ? parent_2.decorators : undefined; } - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return node.parent.heritageClauses; } var parent = node.parent; @@ -21238,45 +21358,45 @@ var ts; return ts.isJSDocTypeLiteral(node.parent) ? undefined : node.parent.tags; } switch (parent.kind) { - case 182 /* TypeLiteral */: - case 258 /* InterfaceDeclaration */: + case 182 /* SyntaxKind.TypeLiteral */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return ts.isTypeElement(node) ? parent.members : undefined; - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return parent.types; - case 184 /* TupleType */: - case 204 /* ArrayLiteralExpression */: - case 351 /* CommaListExpression */: - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 184 /* SyntaxKind.TupleType */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 351 /* SyntaxKind.CommaListExpression */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return parent.elements; - case 205 /* ObjectLiteralExpression */: - case 286 /* JsxAttributes */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 286 /* SyntaxKind.JsxAttributes */: return parent.properties; - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return ts.isTypeNode(node) ? parent.typeArguments : parent.expression === node ? undefined : parent.arguments; - case 278 /* JsxElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 282 /* SyntaxKind.JsxFragment */: return ts.isJsxChild(node) ? parent.children : undefined; - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return ts.isTypeNode(node) ? parent.typeArguments : undefined; - case 235 /* Block */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 262 /* SyntaxKind.ModuleBlock */: return parent.statements; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return parent.clauses; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.isClassElement(node) ? parent.members : undefined; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return ts.isEnumMember(node) ? parent.members : undefined; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return parent.statements; } } @@ -21288,7 +21408,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 214 /* ArrowFunction */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -21306,7 +21426,7 @@ var ts; } ts.isInfinityOrNaNString = isInfinityOrNaNString; function isCatchClauseVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */ && node.parent.kind === 292 /* CatchClause */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.parent.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function isParameterOrCatchClauseVariable(symbol) { @@ -21315,7 +21435,7 @@ var ts; } ts.isParameterOrCatchClauseVariable = isParameterOrCatchClauseVariable; function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 213 /* FunctionExpression */ || node.kind === 214 /* ArrowFunction */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */ || node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction; function escapeSnippetText(text) { @@ -21354,7 +21474,7 @@ var ts; } ts.createPropertyNameNodeForIdentifierOrLiteral = createPropertyNameNodeForIdentifierOrLiteral; function isThisTypeParameter(type) { - return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); + return !!(type.flags & 262144 /* TypeFlags.TypeParameter */ && type.isThisType); } ts.isThisTypeParameter = isThisTypeParameter; function getNodeModulePathParts(fullPath) { @@ -21374,45 +21494,45 @@ var ts; })(States || (States = {})); var partStart = 0; var partEnd = 0; - var state = 0 /* BeforeNodeModules */; + var state = 0 /* States.BeforeNodeModules */; while (partEnd >= 0) { partStart = partEnd; partEnd = fullPath.indexOf("/", partStart + 1); switch (state) { - case 0 /* BeforeNodeModules */: + case 0 /* States.BeforeNodeModules */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { topLevelNodeModulesIndex = partStart; topLevelPackageNameIndex = partEnd; - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } break; - case 1 /* NodeModules */: - case 2 /* Scope */: - if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") { - state = 2 /* Scope */; + case 1 /* States.NodeModules */: + case 2 /* States.Scope */: + if (state === 1 /* States.NodeModules */ && fullPath.charAt(partStart + 1) === "@") { + state = 2 /* States.Scope */; } else { packageRootIndex = partEnd; - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; - case 3 /* PackageContent */: + case 3 /* States.PackageContent */: if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) { - state = 1 /* NodeModules */; + state = 1 /* States.NodeModules */; } else { - state = 3 /* PackageContent */; + state = 3 /* States.PackageContent */; } break; } } fileNameIndex = partStart; - return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; + return state > 1 /* States.NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined; } ts.getNodeModulePathParts = getNodeModulePathParts; function getParameterTypeNode(parameter) { var _a; - return parameter.kind === 340 /* JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; + return parameter.kind === 340 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type; } ts.getParameterTypeNode = getParameterTypeNode; })(ts || (ts = {})); @@ -21537,28 +21657,28 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(221 /* SyntaxKind.BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 214 /* ArrowFunction */ && binaryOperatorPrecedence > 3 /* Assignment */) { + if (!isLeftSideOfBinary && operand.kind === 214 /* SyntaxKind.ArrowFunction */ && binaryOperatorPrecedence > 3 /* OperatorPrecedence.Assignment */) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { - case -1 /* LessThan */: + case -1 /* Comparison.LessThan */: // If the operand is the right side of a right-associative binary operation // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary - && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 224 /* YieldExpression */) { + && binaryOperatorAssociativity === 1 /* Associativity.Right */ + && operand.kind === 224 /* SyntaxKind.YieldExpression */) { return false; } return true; - case 1 /* GreaterThan */: + case 1 /* Comparison.GreaterThan */: return false; - case 0 /* EqualTo */: + case 0 /* Comparison.EqualTo */: if (isLeftSideOfBinary) { // No need to parenthesize the left operand when the binary operator is // left associative: @@ -21569,7 +21689,7 @@ var ts; // right associative: // (a/b)**x -> (a/b)**x // (a**b)**x -> (a**b)**x - return binaryOperatorAssociativity === 1 /* Right */; + return binaryOperatorAssociativity === 1 /* Associativity.Right */; } else { if (ts.isBinaryExpression(emittedOperand) @@ -21589,8 +21709,8 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 39 /* PlusToken */) { - var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; + if (binaryOperator === 39 /* SyntaxKind.PlusToken */) { + var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* SyntaxKind.Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; } @@ -21606,7 +21726,7 @@ var ts; // x/(a*b) -> x/(a*b) // x**(a/b) -> x**(a/b) var operandAssociativity = ts.getExpressionAssociativity(emittedOperand); - return operandAssociativity === 0 /* Left */; + return operandAssociativity === 0 /* Associativity.Left */; } } } @@ -21624,10 +21744,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 41 /* AsteriskToken */ - || binaryOperator === 51 /* BarToken */ - || binaryOperator === 50 /* AmpersandToken */ - || binaryOperator === 52 /* CaretToken */; + return binaryOperator === 41 /* SyntaxKind.AsteriskToken */ + || binaryOperator === 51 /* SyntaxKind.BarToken */ + || binaryOperator === 50 /* SyntaxKind.AmpersandToken */ + || binaryOperator === 52 /* SyntaxKind.CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -21640,7 +21760,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -21648,11 +21768,11 @@ var ts; var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind - : 0 /* Unknown */; + : 0 /* SyntaxKind.Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } - return 0 /* Unknown */; + return 0 /* SyntaxKind.Unknown */; } /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended @@ -21666,7 +21786,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 212 /* ParenthesizedExpression */) { + if (skipped.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -21683,10 +21803,10 @@ var ts; return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression; } function parenthesizeConditionOfConditionalExpression(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(222 /* ConditionalExpression */, 57 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(222 /* SyntaxKind.ConditionalExpression */, 57 /* SyntaxKind.QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* Comparison.GreaterThan */) { return factory.createParenthesizedExpression(condition); } return condition; @@ -21716,8 +21836,8 @@ var ts; var needsParens = ts.isCommaSequence(check); if (!needsParens) { switch (ts.getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: needsParens = true; } } @@ -21730,9 +21850,9 @@ var ts; function parenthesizeExpressionOfNew(expression) { var leftmostExpr = ts.getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return factory.createParenthesizedExpression(expression); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return !leftmostExpr.arguments ? factory.createParenthesizedExpression(expression) : expression; // TODO(rbuckton): Verify this assertion holds @@ -21743,7 +21863,7 @@ var ts; * Wraps an expression in parentheses if it is needed in order to use the expression for * property or element access. */ - function parenthesizeLeftSideOfAccess(expression) { + function parenthesizeLeftSideOfAccess(expression, optionalChain) { // isLeftHandSideExpression is almost the correct criterion for when it is not necessary // to parenthesize the expression before a dot. The known exception is: // @@ -21752,7 +21872,8 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 209 /* SyntaxKind.NewExpression */ || emittedExpression.arguments) + && (optionalChain || !ts.isOptionalChain(emittedExpression))) { // TODO(rbuckton): Verify whether this assertion holds. return expression; } @@ -21774,7 +21895,7 @@ var ts; function parenthesizeExpressionForDisallowedComma(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(221 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(221 /* SyntaxKind.BinaryExpression */, 27 /* SyntaxKind.CommaToken */); // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } @@ -21783,21 +21904,21 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 213 /* FunctionExpression */ || kind === 214 /* ArrowFunction */) { + if (kind === 213 /* SyntaxKind.FunctionExpression */ || kind === 214 /* SyntaxKind.ArrowFunction */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments); - return factory.restoreOuterExpressions(expression, updated, 8 /* PartiallyEmittedExpressions */); + return factory.restoreOuterExpressions(expression, updated, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); } } var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 205 /* ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* FunctionExpression */) { + if (leftmostExpressionKind === 205 /* SyntaxKind.ObjectLiteralExpression */ || leftmostExpressionKind === 213 /* SyntaxKind.FunctionExpression */) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(expression), expression); } return expression; } function parenthesizeConciseBodyOfArrowFunction(body) { - if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { // TODO(rbuckton): Verifiy whether `setTextRange` is needed. return ts.setTextRange(factory.createParenthesizedExpression(body), body); } @@ -21815,16 +21936,16 @@ var ts; // - The true and false branch types (the second and third `Type` non-terminals, above) allow any type function parenthesizeCheckTypeOfConditionalType(checkType) { switch (checkType.kind) { - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 189 /* ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(checkType); } return checkType; } function parenthesizeExtendsTypeOfConditionalType(extendsType) { switch (extendsType.kind) { - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return factory.createParenthesizedType(extendsType); } return extendsType; @@ -21836,8 +21957,8 @@ var ts; // - A union type constituent has the same precedence as the check type of a conditional type function parenthesizeConstituentTypeOfUnionType(type) { switch (type.kind) { - case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened - case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 187 /* SyntaxKind.UnionType */: // Not strictly necessary, but a union containing a union should have been flattened + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeCheckTypeOfConditionalType(type); @@ -21852,8 +21973,8 @@ var ts; // - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized) function parenthesizeConstituentTypeOfIntersectionType(type) { switch (type.kind) { - case 187 /* UnionType */: - case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfUnionType(type); @@ -21870,14 +21991,14 @@ var ts; // function parenthesizeOperandOfTypeOperator(type) { switch (type.kind) { - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return factory.createParenthesizedType(type); } return parenthesizeConstituentTypeOfIntersectionType(type); } function parenthesizeOperandOfReadonlyTypeOperator(type) { switch (type.kind) { - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -21897,9 +22018,9 @@ var ts; // function parenthesizeNonArrayTypeOfPostfixType(type) { switch (type.kind) { - case 190 /* InferType */: - case 193 /* TypeOperator */: - case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests + case 190 /* SyntaxKind.InferType */: + case 193 /* SyntaxKind.TypeOperator */: + case 181 /* SyntaxKind.TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests return factory.createParenthesizedType(type); } return parenthesizeOperandOfTypeOperator(type); @@ -22093,11 +22214,11 @@ var ts; } function convertToAssignmentPattern(node) { switch (node.kind) { - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 201 /* ObjectBindingPattern */: - case 205 /* ObjectLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -22155,10 +22276,10 @@ var ts; */ /* @internal */ function createNodeFactory(flags, baseFactory) { - var update = flags & 8 /* NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; + var update = flags & 8 /* NodeFactoryFlags.NoOriginalNode */ ? updateWithoutOriginal : updateWithOriginal; // Lazily load the parenthesizer, node converters, and some factory methods until they are used. - var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); - var converters = ts.memoize(function () { return flags & 2 /* NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); + var parenthesizerRules = ts.memoize(function () { return flags & 1 /* NodeFactoryFlags.NoParenthesizerRules */ ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); }); + var converters = ts.memoize(function () { return flags & 2 /* NodeFactoryFlags.NoNodeConverters */ ? ts.nullNodeConverters : ts.createNodeConverters(factory); }); // lazy initializaton of common operator factories var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; }); var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; }); @@ -22289,12 +22410,12 @@ var ts; updateArrayLiteralExpression: updateArrayLiteralExpression, createObjectLiteralExpression: createObjectLiteralExpression, updateObjectLiteralExpression: updateObjectLiteralExpression, - createPropertyAccessExpression: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* NoIndentation */); } : + createPropertyAccessExpression: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessExpression, updatePropertyAccessExpression: updatePropertyAccessExpression, - createPropertyAccessChain: flags & 4 /* NoIndentationOnFreshPropertyAccess */ ? - function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* NoIndentation */); } : + createPropertyAccessChain: flags & 4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */ ? + function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072 /* EmitFlags.NoIndentation */); } : createPropertyAccessChain, updatePropertyAccessChain: updatePropertyAccessChain, createElementAccessExpression: createElementAccessExpression, @@ -22450,18 +22571,18 @@ var ts; createExternalModuleReference: createExternalModuleReference, updateExternalModuleReference: updateExternalModuleReference, // lazily load factory members for JSDoc types with similar structure - get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); }, - get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); }, - get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); }, - get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); }, - get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); }, - get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); }, - get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); }, - get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); }, - get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); }, - get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* JSDocVariadicType */); }, - get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* JSDocNamepathType */); }, - get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* JSDocNamepathType */); }, + get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* SyntaxKind.JSDocAllType */); }, + get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* SyntaxKind.JSDocUnknownType */); }, + get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* SyntaxKind.JSDocNonNullableType */); }, + get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* SyntaxKind.JSDocNullableType */); }, + get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* SyntaxKind.JSDocOptionalType */); }, + get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(318 /* SyntaxKind.JSDocVariadicType */); }, + get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, + get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(319 /* SyntaxKind.JSDocNamepathType */); }, createJSDocFunctionType: createJSDocFunctionType, updateJSDocFunctionType: updateJSDocFunctionType, createJSDocTypeLiteral: createJSDocTypeLiteral, @@ -22497,30 +22618,30 @@ var ts; createJSDocLinkPlain: createJSDocLinkPlain, updateJSDocLinkPlain: updateJSDocLinkPlain, // lazily load factory members for JSDoc tags with similar structure - get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* JSDocTypeTag */); }, - get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* JSDocTypeTag */); }, - get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* JSDocReturnTag */); }, - get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* JSDocReturnTag */); }, - get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* JSDocThisTag */); }, - get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* JSDocThisTag */); }, - get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* JSDocEnumTag */); }, - get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* JSDocEnumTag */); }, - get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* JSDocAuthorTag */); }, - get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* JSDocAuthorTag */); }, - get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* JSDocClassTag */); }, - get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* JSDocClassTag */); }, - get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* JSDocPublicTag */); }, - get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* JSDocPublicTag */); }, - get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* JSDocPrivateTag */); }, - get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* JSDocPrivateTag */); }, - get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* JSDocProtectedTag */); }, - get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* JSDocProtectedTag */); }, - get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* JSDocReadonlyTag */); }, - get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* JSDocReadonlyTag */); }, - get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* JSDocOverrideTag */); }, - get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* JSDocOverrideTag */); }, - get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* JSDocDeprecatedTag */); }, - get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* JSDocDeprecatedTag */); }, + get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(343 /* SyntaxKind.JSDocTypeTag */); }, + get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(341 /* SyntaxKind.JSDocReturnTag */); }, + get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(342 /* SyntaxKind.JSDocThisTag */); }, + get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(339 /* SyntaxKind.JSDocEnumTag */); }, + get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(330 /* SyntaxKind.JSDocAuthorTag */); }, + get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(332 /* SyntaxKind.JSDocClassTag */); }, + get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(333 /* SyntaxKind.JSDocPublicTag */); }, + get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(334 /* SyntaxKind.JSDocPrivateTag */); }, + get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(335 /* SyntaxKind.JSDocProtectedTag */); }, + get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(336 /* SyntaxKind.JSDocReadonlyTag */); }, + get createJSDocOverrideTag() { return getJSDocSimpleTagCreateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get updateJSDocOverrideTag() { return getJSDocSimpleTagUpdateFunction(337 /* SyntaxKind.JSDocOverrideTag */); }, + get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, + get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(331 /* SyntaxKind.JSDocDeprecatedTag */); }, createJSDocUnknownTag: createJSDocUnknownTag, updateJSDocUnknownTag: updateJSDocUnknownTag, createJSDocText: createJSDocText, @@ -22588,38 +22709,38 @@ var ts; updateSyntheticReferenceExpression: updateSyntheticReferenceExpression, cloneNode: cloneNode, // Lazily load factory methods for common operator factories and utilities - get createComma() { return getBinaryCreateFunction(27 /* CommaToken */); }, - get createAssignment() { return getBinaryCreateFunction(63 /* EqualsToken */); }, - get createLogicalOr() { return getBinaryCreateFunction(56 /* BarBarToken */); }, - get createLogicalAnd() { return getBinaryCreateFunction(55 /* AmpersandAmpersandToken */); }, - get createBitwiseOr() { return getBinaryCreateFunction(51 /* BarToken */); }, - get createBitwiseXor() { return getBinaryCreateFunction(52 /* CaretToken */); }, - get createBitwiseAnd() { return getBinaryCreateFunction(50 /* AmpersandToken */); }, - get createStrictEquality() { return getBinaryCreateFunction(36 /* EqualsEqualsEqualsToken */); }, - get createStrictInequality() { return getBinaryCreateFunction(37 /* ExclamationEqualsEqualsToken */); }, - get createEquality() { return getBinaryCreateFunction(34 /* EqualsEqualsToken */); }, - get createInequality() { return getBinaryCreateFunction(35 /* ExclamationEqualsToken */); }, - get createLessThan() { return getBinaryCreateFunction(29 /* LessThanToken */); }, - get createLessThanEquals() { return getBinaryCreateFunction(32 /* LessThanEqualsToken */); }, - get createGreaterThan() { return getBinaryCreateFunction(31 /* GreaterThanToken */); }, - get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* GreaterThanEqualsToken */); }, - get createLeftShift() { return getBinaryCreateFunction(47 /* LessThanLessThanToken */); }, - get createRightShift() { return getBinaryCreateFunction(48 /* GreaterThanGreaterThanToken */); }, - get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* GreaterThanGreaterThanGreaterThanToken */); }, - get createAdd() { return getBinaryCreateFunction(39 /* PlusToken */); }, - get createSubtract() { return getBinaryCreateFunction(40 /* MinusToken */); }, - get createMultiply() { return getBinaryCreateFunction(41 /* AsteriskToken */); }, - get createDivide() { return getBinaryCreateFunction(43 /* SlashToken */); }, - get createModulo() { return getBinaryCreateFunction(44 /* PercentToken */); }, - get createExponent() { return getBinaryCreateFunction(42 /* AsteriskAsteriskToken */); }, - get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* PlusToken */); }, - get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* MinusToken */); }, - get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* MinusMinusToken */); }, - get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* TildeToken */); }, - get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* ExclamationToken */); }, - get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* PlusPlusToken */); }, - get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* MinusMinusToken */); }, + get createComma() { return getBinaryCreateFunction(27 /* SyntaxKind.CommaToken */); }, + get createAssignment() { return getBinaryCreateFunction(63 /* SyntaxKind.EqualsToken */); }, + get createLogicalOr() { return getBinaryCreateFunction(56 /* SyntaxKind.BarBarToken */); }, + get createLogicalAnd() { return getBinaryCreateFunction(55 /* SyntaxKind.AmpersandAmpersandToken */); }, + get createBitwiseOr() { return getBinaryCreateFunction(51 /* SyntaxKind.BarToken */); }, + get createBitwiseXor() { return getBinaryCreateFunction(52 /* SyntaxKind.CaretToken */); }, + get createBitwiseAnd() { return getBinaryCreateFunction(50 /* SyntaxKind.AmpersandToken */); }, + get createStrictEquality() { return getBinaryCreateFunction(36 /* SyntaxKind.EqualsEqualsEqualsToken */); }, + get createStrictInequality() { return getBinaryCreateFunction(37 /* SyntaxKind.ExclamationEqualsEqualsToken */); }, + get createEquality() { return getBinaryCreateFunction(34 /* SyntaxKind.EqualsEqualsToken */); }, + get createInequality() { return getBinaryCreateFunction(35 /* SyntaxKind.ExclamationEqualsToken */); }, + get createLessThan() { return getBinaryCreateFunction(29 /* SyntaxKind.LessThanToken */); }, + get createLessThanEquals() { return getBinaryCreateFunction(32 /* SyntaxKind.LessThanEqualsToken */); }, + get createGreaterThan() { return getBinaryCreateFunction(31 /* SyntaxKind.GreaterThanToken */); }, + get createGreaterThanEquals() { return getBinaryCreateFunction(33 /* SyntaxKind.GreaterThanEqualsToken */); }, + get createLeftShift() { return getBinaryCreateFunction(47 /* SyntaxKind.LessThanLessThanToken */); }, + get createRightShift() { return getBinaryCreateFunction(48 /* SyntaxKind.GreaterThanGreaterThanToken */); }, + get createUnsignedRightShift() { return getBinaryCreateFunction(49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */); }, + get createAdd() { return getBinaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createSubtract() { return getBinaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createMultiply() { return getBinaryCreateFunction(41 /* SyntaxKind.AsteriskToken */); }, + get createDivide() { return getBinaryCreateFunction(43 /* SyntaxKind.SlashToken */); }, + get createModulo() { return getBinaryCreateFunction(44 /* SyntaxKind.PercentToken */); }, + get createExponent() { return getBinaryCreateFunction(42 /* SyntaxKind.AsteriskAsteriskToken */); }, + get createPrefixPlus() { return getPrefixUnaryCreateFunction(39 /* SyntaxKind.PlusToken */); }, + get createPrefixMinus() { return getPrefixUnaryCreateFunction(40 /* SyntaxKind.MinusToken */); }, + get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, + get createBitwiseNot() { return getPrefixUnaryCreateFunction(54 /* SyntaxKind.TildeToken */); }, + get createLogicalNot() { return getPrefixUnaryCreateFunction(53 /* SyntaxKind.ExclamationToken */); }, + get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45 /* SyntaxKind.PlusPlusToken */); }, + get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46 /* SyntaxKind.MinusMinusToken */); }, // Compound nodes createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression, createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction, @@ -22723,11 +22844,11 @@ var ts; // don't propagate child flags. if (name) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: if (ts.isIdentifier(name)) { node.transformFlags |= propagateIdentifierNameFlags(name); break; @@ -22745,7 +22866,7 @@ var ts; node.typeParameters = asNodeArray(typeParameters); node.transformFlags |= propagateChildrenFlags(node.typeParameters); if (typeParameters) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type) { @@ -22756,7 +22877,7 @@ var ts; propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used for quick info node.typeArguments = undefined; return node; @@ -22771,9 +22892,9 @@ var ts; function createBaseFunctionLikeDeclaration(kind, modifiers, name, typeParameters, parameters, type, body) { var node = createBaseSignatureDeclaration(kind, modifiers, name, typeParameters, parameters, type); node.body = body; - node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* ContainsPossibleTopLevelAwait */; + node.transformFlags |= propagateChildFlags(node.body) & ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; if (!body) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } function createBaseInterfaceOrClassLikeDeclaration(kind, modifiers, name, typeParameters, heritageClauses) { @@ -22799,7 +22920,7 @@ var ts; node.type = type; node.transformFlags |= propagateChildFlags(type); if (type) - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; return node; } // @@ -22812,21 +22933,21 @@ var ts; } // @api function createNumericLiteral(value, numericLiteralFlags) { - if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* None */; } - var node = createBaseLiteral(8 /* NumericLiteral */, typeof value === "number" ? value + "" : value); + if (numericLiteralFlags === void 0) { numericLiteralFlags = 0 /* TokenFlags.None */; } + var node = createBaseLiteral(8 /* SyntaxKind.NumericLiteral */, typeof value === "number" ? value + "" : value); node.numericLiteralFlags = numericLiteralFlags; - if (numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) - node.transformFlags |= 1024 /* ContainsES2015 */; + if (numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api function createBigIntLiteral(value) { - var node = createBaseLiteral(9 /* BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); - node.transformFlags |= 4 /* ContainsESNext */; + var node = createBaseLiteral(9 /* SyntaxKind.BigIntLiteral */, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n"); + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } function createBaseStringLiteral(text, isSingleQuote) { - var node = createBaseLiteral(10 /* StringLiteral */, text); + var node = createBaseLiteral(10 /* SyntaxKind.StringLiteral */, text); node.singleQuote = isSingleQuote; return node; } @@ -22835,7 +22956,7 @@ var ts; var node = createBaseStringLiteral(text, isSingleQuote); node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape; if (hasExtendedUnicodeEscape) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -22846,19 +22967,19 @@ var ts; } // @api function createRegularExpressionLiteral(text) { - var node = createBaseLiteral(13 /* RegularExpressionLiteral */, text); + var node = createBaseLiteral(13 /* SyntaxKind.RegularExpressionLiteral */, text); return node; } // @api function createLiteralLikeNode(kind, text) { switch (kind) { - case 8 /* NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); - case 9 /* BigIntLiteral */: return createBigIntLiteral(text); - case 10 /* StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); - case 11 /* JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); - case 12 /* JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); - case 13 /* RegularExpressionLiteral */: return createRegularExpressionLiteral(text); - case 14 /* NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); + case 8 /* SyntaxKind.NumericLiteral */: return createNumericLiteral(text, /*numericLiteralFlags*/ 0); + case 9 /* SyntaxKind.BigIntLiteral */: return createBigIntLiteral(text); + case 10 /* SyntaxKind.StringLiteral */: return createStringLiteral(text, /*isSingleQuote*/ undefined); + case 11 /* SyntaxKind.JsxText */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ false); + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return createJsxText(text, /*containsOnlyTriviaWhiteSpaces*/ true); + case 13 /* SyntaxKind.RegularExpressionLiteral */: return createRegularExpressionLiteral(text); + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return createTemplateLiteralLikeNode(kind, text, /*rawText*/ undefined, /*templateFlags*/ 0); } } // @@ -22868,10 +22989,10 @@ var ts; if (originalKeywordKind === undefined && text) { originalKeywordKind = ts.stringToToken(text); } - if (originalKeywordKind === 79 /* Identifier */) { + if (originalKeywordKind === 79 /* SyntaxKind.Identifier */) { originalKeywordKind = undefined; } - var node = baseFactory.createBaseIdentifierNode(79 /* Identifier */); + var node = baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */); node.originalKeywordKind = originalKeywordKind; node.escapedText = ts.escapeLeadingUnderscores(text); return node; @@ -22890,8 +23011,8 @@ var ts; // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations node.typeArguments = createNodeArray(typeArguments); } - if (node.originalKeywordKind === 132 /* AwaitKeyword */) { - node.transformFlags |= 67108864 /* ContainsPossibleTopLevelAwait */; + if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { + node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; } return node; } @@ -22903,9 +23024,9 @@ var ts; } // @api function createTempVariable(recordTempVariable, reservedInNestedScopes) { - var flags = 1 /* Auto */; + var flags = 1 /* GeneratedIdentifierFlags.Auto */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; var name = createBaseGeneratedIdentifier("", flags); if (recordTempVariable) { recordTempVariable(name); @@ -22915,25 +23036,25 @@ var ts; /** Create a unique temporary variable for use in a loop. */ // @api function createLoopVariable(reservedInNestedScopes) { - var flags = 2 /* Loop */; + var flags = 2 /* GeneratedIdentifierFlags.Loop */; if (reservedInNestedScopes) - flags |= 8 /* ReservedInNestedScopes */; + flags |= 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; return createBaseGeneratedIdentifier("", flags); } /** Create a unique name based on the supplied text. */ // @api function createUniqueName(text, flags) { - if (flags === void 0) { flags = 0 /* None */; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - ts.Debug.assert((flags & (16 /* Optimistic */ | 32 /* FileLevel */)) !== 32 /* FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); - return createBaseGeneratedIdentifier(text, 3 /* Unique */ | flags); + if (flags === void 0) { flags = 0 /* GeneratedIdentifierFlags.None */; } + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + ts.Debug.assert((flags & (16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)) !== 32 /* GeneratedIdentifierFlags.FileLevel */, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic"); + return createBaseGeneratedIdentifier(text, 3 /* GeneratedIdentifierFlags.Unique */ | flags); } /** Create a unique name generated for a node. */ // @api function getGeneratedNameForNode(node, flags) { if (flags === void 0) { flags = 0; } - ts.Debug.assert(!(flags & 7 /* KindMask */), "Argument out of range: flags"); - var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* Node */ | flags); + ts.Debug.assert(!(flags & 7 /* GeneratedIdentifierFlags.KindMask */), "Argument out of range: flags"); + var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 /* GeneratedIdentifierFlags.Node */ | flags); name.original = node; return name; } @@ -22941,9 +23062,9 @@ var ts; function createPrivateIdentifier(text) { if (!ts.startsWith(text, "#")) ts.Debug.fail("First character of private identifier must be #: " + text); - var node = baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */); + var node = baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */); node.escapedText = ts.escapeLeadingUnderscores(text); - node.transformFlags |= 16777216 /* ContainsClassFields */; + node.transformFlags |= 16777216 /* TransformFlags.ContainsClassFields */; return node; } // @@ -22953,51 +23074,51 @@ var ts; return baseFactory.createBaseTokenNode(kind); } function createToken(token) { - ts.Debug.assert(token >= 0 /* FirstToken */ && token <= 160 /* LastToken */, "Invalid token"); - ts.Debug.assert(token <= 14 /* FirstTemplateToken */ || token >= 17 /* LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); - ts.Debug.assert(token <= 8 /* FirstLiteralToken */ || token >= 14 /* LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); - ts.Debug.assert(token !== 79 /* Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); + ts.Debug.assert(token >= 0 /* SyntaxKind.FirstToken */ && token <= 160 /* SyntaxKind.LastToken */, "Invalid token"); + ts.Debug.assert(token <= 14 /* SyntaxKind.FirstTemplateToken */ || token >= 17 /* SyntaxKind.LastTemplateToken */, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals."); + ts.Debug.assert(token <= 8 /* SyntaxKind.FirstLiteralToken */ || token >= 14 /* SyntaxKind.LastLiteralToken */, "Invalid token. Use 'createLiteralLikeNode' to create literals."); + ts.Debug.assert(token !== 79 /* SyntaxKind.Identifier */, "Invalid token. Use 'createIdentifier' to create identifiers"); var node = createBaseToken(token); - var transformFlags = 0 /* None */; + var transformFlags = 0 /* TransformFlags.None */; switch (token) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // 'async' modifier is ES2017 (async functions) or ES2018 (async generators) transformFlags = - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; break; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 126 /* AbstractKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - case 159 /* OverrideKeyword */: - case 150 /* StringKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 155 /* UnknownKeyword */: - case 153 /* UndefinedKeyword */: // `undefined` is an Identifier in the expression case. - transformFlags = 1 /* ContainsTypeScript */; + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: // `undefined` is an Identifier in the expression case. + transformFlags = 1 /* TransformFlags.ContainsTypeScript */; break; - case 106 /* SuperKeyword */: - transformFlags = 1024 /* ContainsES2015 */ | 134217728 /* ContainsLexicalSuper */; + case 106 /* SyntaxKind.SuperKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */ | 134217728 /* TransformFlags.ContainsLexicalSuper */; break; - case 124 /* StaticKeyword */: - transformFlags = 1024 /* ContainsES2015 */; + case 124 /* SyntaxKind.StaticKeyword */: + transformFlags = 1024 /* TransformFlags.ContainsES2015 */; break; - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: // 'this' indicates a lexical 'this' - transformFlags = 16384 /* ContainsLexicalThis */; + transformFlags = 16384 /* TransformFlags.ContainsLexicalThis */; break; } if (transformFlags) { @@ -23010,23 +23131,23 @@ var ts; // // @api function createSuper() { - return createToken(106 /* SuperKeyword */); + return createToken(106 /* SyntaxKind.SuperKeyword */); } // @api function createThis() { - return createToken(108 /* ThisKeyword */); + return createToken(108 /* SyntaxKind.ThisKeyword */); } // @api function createNull() { - return createToken(104 /* NullKeyword */); + return createToken(104 /* SyntaxKind.NullKeyword */); } // @api function createTrue() { - return createToken(110 /* TrueKeyword */); + return createToken(110 /* SyntaxKind.TrueKeyword */); } // @api function createFalse() { - return createToken(95 /* FalseKeyword */); + return createToken(95 /* SyntaxKind.FalseKeyword */); } // // Modifiers @@ -23038,34 +23159,34 @@ var ts; // @api function createModifiersFromModifierFlags(flags) { var result = []; - if (flags & 1 /* Export */) - result.push(createModifier(93 /* ExportKeyword */)); - if (flags & 2 /* Ambient */) - result.push(createModifier(135 /* DeclareKeyword */)); - if (flags & 512 /* Default */) - result.push(createModifier(88 /* DefaultKeyword */)); - if (flags & 2048 /* Const */) - result.push(createModifier(85 /* ConstKeyword */)); - if (flags & 4 /* Public */) - result.push(createModifier(123 /* PublicKeyword */)); - if (flags & 8 /* Private */) - result.push(createModifier(121 /* PrivateKeyword */)); - if (flags & 16 /* Protected */) - result.push(createModifier(122 /* ProtectedKeyword */)); - if (flags & 128 /* Abstract */) - result.push(createModifier(126 /* AbstractKeyword */)); - if (flags & 32 /* Static */) - result.push(createModifier(124 /* StaticKeyword */)); - if (flags & 16384 /* Override */) - result.push(createModifier(159 /* OverrideKeyword */)); - if (flags & 64 /* Readonly */) - result.push(createModifier(145 /* ReadonlyKeyword */)); - if (flags & 256 /* Async */) - result.push(createModifier(131 /* AsyncKeyword */)); - if (flags & 32768 /* In */) - result.push(createModifier(101 /* InKeyword */)); - if (flags & 65536 /* Out */) - result.push(createModifier(144 /* OutKeyword */)); + if (flags & 1 /* ModifierFlags.Export */) + result.push(createModifier(93 /* SyntaxKind.ExportKeyword */)); + if (flags & 2 /* ModifierFlags.Ambient */) + result.push(createModifier(135 /* SyntaxKind.DeclareKeyword */)); + if (flags & 512 /* ModifierFlags.Default */) + result.push(createModifier(88 /* SyntaxKind.DefaultKeyword */)); + if (flags & 2048 /* ModifierFlags.Const */) + result.push(createModifier(85 /* SyntaxKind.ConstKeyword */)); + if (flags & 4 /* ModifierFlags.Public */) + result.push(createModifier(123 /* SyntaxKind.PublicKeyword */)); + if (flags & 8 /* ModifierFlags.Private */) + result.push(createModifier(121 /* SyntaxKind.PrivateKeyword */)); + if (flags & 16 /* ModifierFlags.Protected */) + result.push(createModifier(122 /* SyntaxKind.ProtectedKeyword */)); + if (flags & 128 /* ModifierFlags.Abstract */) + result.push(createModifier(126 /* SyntaxKind.AbstractKeyword */)); + if (flags & 32 /* ModifierFlags.Static */) + result.push(createModifier(124 /* SyntaxKind.StaticKeyword */)); + if (flags & 16384 /* ModifierFlags.Override */) + result.push(createModifier(159 /* SyntaxKind.OverrideKeyword */)); + if (flags & 64 /* ModifierFlags.Readonly */) + result.push(createModifier(145 /* SyntaxKind.ReadonlyKeyword */)); + if (flags & 256 /* ModifierFlags.Async */) + result.push(createModifier(131 /* SyntaxKind.AsyncKeyword */)); + if (flags & 32768 /* ModifierFlags.In */) + result.push(createModifier(101 /* SyntaxKind.InKeyword */)); + if (flags & 65536 /* ModifierFlags.Out */) + result.push(createModifier(144 /* SyntaxKind.OutKeyword */)); return result.length ? result : undefined; } // @@ -23073,7 +23194,7 @@ var ts; // // @api function createQualifiedName(left, right) { - var node = createBaseNode(161 /* QualifiedName */); + var node = createBaseNode(161 /* SyntaxKind.QualifiedName */); node.left = left; node.right = asName(right); node.transformFlags |= @@ -23090,12 +23211,12 @@ var ts; } // @api function createComputedPropertyName(expression) { - var node = createBaseNode(162 /* ComputedPropertyName */); + var node = createBaseNode(162 /* SyntaxKind.ComputedPropertyName */); node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 131072 /* ContainsComputedPropertyName */; + 1024 /* TransformFlags.ContainsES2015 */ | + 131072 /* TransformFlags.ContainsComputedPropertyName */; return node; } // @api @@ -23109,10 +23230,10 @@ var ts; // // @api function createTypeParameterDeclaration(modifiers, name, constraint, defaultType) { - var node = createBaseNamedDeclaration(163 /* TypeParameter */, modifiers, name); + var node = createBaseNamedDeclaration(163 /* SyntaxKind.TypeParameter */, modifiers, name); node.constraint = constraint; node.default = defaultType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23126,22 +23247,22 @@ var ts; } // @api function createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(164 /* Parameter */, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); + var node = createBaseVariableLikeDeclaration(164 /* SyntaxKind.Parameter */, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.dotDotDotToken = dotDotDotToken; node.questionToken = questionToken; if (ts.isThisIdentifier(node.name)) { - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.questionToken); if (questionToken) - node.transformFlags |= 1 /* ContainsTypeScript */; - if (ts.modifiersToFlags(node.modifiers) & 16476 /* ParameterPropertyModifier */) - node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 16476 /* ModifierFlags.ParameterPropertyModifier */) + node.transformFlags |= 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */; if (initializer || dotDotDotToken) - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; } return node; } @@ -23158,13 +23279,13 @@ var ts; } // @api function createDecorator(expression) { - var node = createBaseNode(165 /* Decorator */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseNode(165 /* SyntaxKind.Decorator */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */ | - 8192 /* ContainsTypeScriptClassSyntax */ | - 33554432 /* ContainsDecorators */; + 1 /* TransformFlags.ContainsTypeScript */ | + 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */ | + 33554432 /* TransformFlags.ContainsDecorators */; return node; } // @api @@ -23178,10 +23299,10 @@ var ts; // // @api function createPropertySignature(modifiers, name, questionToken, type) { - var node = createBaseNamedDeclaration(166 /* PropertySignature */, modifiers, name); + var node = createBaseNamedDeclaration(166 /* SyntaxKind.PropertySignature */, modifiers, name); node.type = type; node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.initializer = undefined; return node; @@ -23204,18 +23325,18 @@ var ts; } // @api function createPropertyDeclaration(modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(167 /* PropertyDeclaration */, modifiers, name, type, initializer); + var node = createBaseVariableLikeDeclaration(167 /* SyntaxKind.PropertyDeclaration */, modifiers, name, type, initializer); node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined; node.transformFlags |= propagateChildFlags(node.questionToken) | propagateChildFlags(node.exclamationToken) | - 16777216 /* ContainsClassFields */; + 16777216 /* TransformFlags.ContainsClassFields */; if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) { - node.transformFlags |= 8192 /* ContainsTypeScriptClassSyntax */; + node.transformFlags |= 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */; } - if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -23232,9 +23353,9 @@ var ts; } // @api function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(168 /* MethodSignature */, modifiers, name, typeParameters, parameters, type); + var node = createBaseSignatureDeclaration(168 /* SyntaxKind.MethodSignature */, modifiers, name, typeParameters, parameters, type); node.questionToken = questionToken; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23250,26 +23371,26 @@ var ts; } // @api function createMethodDeclaration(modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(169 /* MethodDeclaration */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(169 /* SyntaxKind.MethodDeclaration */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.questionToken = questionToken; node.transformFlags |= propagateChildFlags(node.asteriskToken) | propagateChildFlags(node.questionToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (questionToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } // The following properties are used only to report grammar errors node.exclamationToken = undefined; @@ -23296,12 +23417,12 @@ var ts; } // @api function createClassStaticBlockDeclaration(body) { - var node = createBaseGenericNamedDeclaration(170 /* ClassStaticBlockDeclaration */, + var node = createBaseGenericNamedDeclaration(170 /* SyntaxKind.ClassStaticBlockDeclaration */, /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined); node.body = body; - node.transformFlags = propagateChildFlags(body) | 16777216 /* ContainsClassFields */; + node.transformFlags = propagateChildFlags(body) | 16777216 /* TransformFlags.ContainsClassFields */; // The following properties are used only to report grammar errors node.decorators = undefined; node.modifiers = undefined; @@ -23322,11 +23443,11 @@ var ts; } // @api function createConstructorDeclaration(modifiers, parameters, body) { - var node = createBaseFunctionLikeDeclaration(171 /* Constructor */, modifiers, + var node = createBaseFunctionLikeDeclaration(171 /* SyntaxKind.Constructor */, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); - node.transformFlags |= 1024 /* ContainsES2015 */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; // The following properties are used only to report grammar errors node.decorators = undefined; node.typeParameters = undefined; @@ -23351,7 +23472,7 @@ var ts; } // @api function createGetAccessorDeclaration(modifiers, name, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(172 /* GetAccessor */, modifiers, name, + var node = createBaseFunctionLikeDeclaration(172 /* SyntaxKind.GetAccessor */, modifiers, name, /*typeParameters*/ undefined, parameters, type, body); // The following properties are used only to report grammar errors node.typeParameters = undefined; @@ -23375,7 +23496,7 @@ var ts; } // @api function createSetAccessorDeclaration(modifiers, name, parameters, body) { - var node = createBaseFunctionLikeDeclaration(173 /* SetAccessor */, modifiers, name, + var node = createBaseFunctionLikeDeclaration(173 /* SyntaxKind.SetAccessor */, modifiers, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); // The following properties are used only to report grammar errors @@ -23401,10 +23522,10 @@ var ts; } // @api function createCallSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(174 /* CallSignature */, + var node = createBaseSignatureDeclaration(174 /* SyntaxKind.CallSignature */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23417,10 +23538,10 @@ var ts; } // @api function createConstructSignature(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(175 /* ConstructSignature */, + var node = createBaseSignatureDeclaration(175 /* SyntaxKind.ConstructSignature */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23433,10 +23554,10 @@ var ts; } // @api function createIndexSignature(modifiers, parameters, type) { - var node = createBaseSignatureDeclaration(176 /* IndexSignature */, modifiers, + var node = createBaseSignatureDeclaration(176 /* SyntaxKind.IndexSignature */, modifiers, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23449,10 +23570,10 @@ var ts; } // @api function createTemplateLiteralTypeSpan(type, literal) { - var node = createBaseNode(199 /* TemplateLiteralTypeSpan */); + var node = createBaseNode(199 /* SyntaxKind.TemplateLiteralTypeSpan */); node.type = type; node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23471,11 +23592,11 @@ var ts; } // @api function createTypePredicateNode(assertsModifier, parameterName, type) { - var node = createBaseNode(177 /* TypePredicate */); + var node = createBaseNode(177 /* SyntaxKind.TypePredicate */); node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23488,10 +23609,10 @@ var ts; } // @api function createTypeReferenceNode(typeName, typeArguments) { - var node = createBaseNode(178 /* TypeReference */); + var node = createBaseNode(178 /* SyntaxKind.TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23503,10 +23624,10 @@ var ts; } // @api function createFunctionTypeNode(typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(179 /* FunctionType */, + var node = createBaseSignatureDeclaration(179 /* SyntaxKind.FunctionType */, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.modifiers = undefined; return node; @@ -23536,9 +23657,9 @@ var ts; ts.Debug.fail("Incorrect number of arguments specified."); } function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) { - var node = createBaseSignatureDeclaration(180 /* ConstructorType */, modifiers, + var node = createBaseSignatureDeclaration(180 /* SyntaxKind.ConstructorType */, modifiers, /*name*/ undefined, typeParameters, parameters, type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } /** @deprecated */ @@ -23569,10 +23690,10 @@ var ts; } // @api function createTypeQueryNode(exprName, typeArguments) { - var node = createBaseNode(181 /* TypeQuery */); + var node = createBaseNode(181 /* SyntaxKind.TypeQuery */); node.exprName = exprName; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23584,9 +23705,9 @@ var ts; } // @api function createTypeLiteralNode(members) { - var node = createBaseNode(182 /* TypeLiteral */); + var node = createBaseNode(182 /* SyntaxKind.TypeLiteral */); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23597,9 +23718,9 @@ var ts; } // @api function createArrayTypeNode(elementType) { - var node = createBaseNode(183 /* ArrayType */); + var node = createBaseNode(183 /* SyntaxKind.ArrayType */); node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23610,9 +23731,9 @@ var ts; } // @api function createTupleTypeNode(elements) { - var node = createBaseNode(184 /* TupleType */); + var node = createBaseNode(184 /* SyntaxKind.TupleType */); node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23623,12 +23744,12 @@ var ts; } // @api function createNamedTupleMember(dotDotDotToken, name, questionToken, type) { - var node = createBaseNode(197 /* NamedTupleMember */); + var node = createBaseNode(197 /* SyntaxKind.NamedTupleMember */); node.dotDotDotToken = dotDotDotToken; node.name = name; node.questionToken = questionToken; node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23642,9 +23763,9 @@ var ts; } // @api function createOptionalTypeNode(type) { - var node = createBaseNode(185 /* OptionalType */); + var node = createBaseNode(185 /* SyntaxKind.OptionalType */); node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23655,9 +23776,9 @@ var ts; } // @api function createRestTypeNode(type) { - var node = createBaseNode(186 /* RestType */); + var node = createBaseNode(186 /* SyntaxKind.RestType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23669,7 +23790,7 @@ var ts; function createUnionOrIntersectionTypeNode(kind, types, parenthesize) { var node = createBaseNode(kind); node.types = factory.createNodeArray(parenthesize(types)); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } function updateUnionOrIntersectionTypeNode(node, types, parenthesize) { @@ -23679,7 +23800,7 @@ var ts; } // @api function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); + return createUnionOrIntersectionTypeNode(187 /* SyntaxKind.UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType); } // @api function updateUnionTypeNode(node, types) { @@ -23687,7 +23808,7 @@ var ts; } // @api function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); + return createUnionOrIntersectionTypeNode(188 /* SyntaxKind.IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType); } // @api function updateIntersectionTypeNode(node, types) { @@ -23695,12 +23816,12 @@ var ts; } // @api function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createBaseNode(189 /* ConditionalType */); + var node = createBaseNode(189 /* SyntaxKind.ConditionalType */); node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType); node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType); node.trueType = trueType; node.falseType = falseType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23714,9 +23835,9 @@ var ts; } // @api function createInferTypeNode(typeParameter) { - var node = createBaseNode(190 /* InferType */); + var node = createBaseNode(190 /* SyntaxKind.InferType */); node.typeParameter = typeParameter; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23727,10 +23848,10 @@ var ts; } // @api function createTemplateLiteralType(head, templateSpans) { - var node = createBaseNode(198 /* TemplateLiteralType */); + var node = createBaseNode(198 /* SyntaxKind.TemplateLiteralType */); node.head = head; node.templateSpans = createNodeArray(templateSpans); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23743,13 +23864,13 @@ var ts; // @api function createImportTypeNode(argument, assertions, qualifier, typeArguments, isTypeOf) { if (isTypeOf === void 0) { isTypeOf = false; } - var node = createBaseNode(200 /* ImportType */); + var node = createBaseNode(200 /* SyntaxKind.ImportType */); node.argument = argument; node.assertions = assertions; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23765,9 +23886,9 @@ var ts; } // @api function createParenthesizedType(type) { - var node = createBaseNode(191 /* ParenthesizedType */); + var node = createBaseNode(191 /* SyntaxKind.ParenthesizedType */); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23778,18 +23899,18 @@ var ts; } // @api function createThisTypeNode() { - var node = createBaseNode(192 /* ThisType */); - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseNode(192 /* SyntaxKind.ThisType */); + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function createTypeOperatorNode(operator, type) { - var node = createBaseNode(193 /* TypeOperator */); + var node = createBaseNode(193 /* SyntaxKind.TypeOperator */); node.operator = operator; - node.type = operator === 145 /* ReadonlyKeyword */ ? + node.type = operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) : parenthesizerRules().parenthesizeOperandOfTypeOperator(type); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23800,10 +23921,10 @@ var ts; } // @api function createIndexedAccessTypeNode(objectType, indexType) { - var node = createBaseNode(194 /* IndexedAccessType */); + var node = createBaseNode(194 /* SyntaxKind.IndexedAccessType */); node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType); node.indexType = indexType; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23815,14 +23936,14 @@ var ts; } // @api function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members) { - var node = createBaseNode(195 /* MappedType */); + var node = createBaseNode(195 /* SyntaxKind.MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.nameType = nameType; node.questionToken = questionToken; node.type = type; node.members = members && createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23838,9 +23959,9 @@ var ts; } // @api function createLiteralTypeNode(literal) { - var node = createBaseNode(196 /* LiteralType */); + var node = createBaseNode(196 /* SyntaxKind.LiteralType */); node.literal = literal; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -23854,16 +23975,16 @@ var ts; // // @api function createObjectBindingPattern(elements) { - var node = createBaseNode(201 /* ObjectBindingPattern */); + var node = createBaseNode(201 /* SyntaxKind.ObjectBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 524288 /* ContainsBindingPattern */; - if (node.transformFlags & 32768 /* ContainsRestOrSpread */) { + 1024 /* TransformFlags.ContainsES2015 */ | + 524288 /* TransformFlags.ContainsBindingPattern */; + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */) { node.transformFlags |= - 128 /* ContainsES2018 */ | - 65536 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 65536 /* TransformFlags.ContainsObjectRestOrSpread */; } return node; } @@ -23875,12 +23996,12 @@ var ts; } // @api function createArrayBindingPattern(elements) { - var node = createBaseNode(202 /* ArrayBindingPattern */); + var node = createBaseNode(202 /* SyntaxKind.ArrayBindingPattern */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements) | - 1024 /* ContainsES2015 */ | - 524288 /* ContainsBindingPattern */; + 1024 /* TransformFlags.ContainsES2015 */ | + 524288 /* TransformFlags.ContainsBindingPattern */; return node; } // @api @@ -23891,20 +24012,20 @@ var ts; } // @api function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createBaseBindingLikeDeclaration(203 /* BindingElement */, + var node = createBaseBindingLikeDeclaration(203 /* SyntaxKind.BindingElement */, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.propertyName = asName(propertyName); node.dotDotDotToken = dotDotDotToken; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.propertyName) { node.transformFlags |= ts.isIdentifier(node.propertyName) ? propagateIdentifierNameFlags(node.propertyName) : propagateChildFlags(node.propertyName); } if (dotDotDotToken) - node.transformFlags |= 32768 /* ContainsRestOrSpread */; + node.transformFlags |= 32768 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -23926,7 +24047,7 @@ var ts; } // @api function createArrayLiteralExpression(elements, multiLine) { - var node = createBaseExpression(204 /* ArrayLiteralExpression */); + var node = createBaseExpression(204 /* SyntaxKind.ArrayLiteralExpression */); // Ensure we add a trailing comma for something like `[NumericLiteral(1), NumericLiteral(2), OmittedExpresion]` so that // we end up with `[1, 2, ,]` instead of `[1, 2, ]` otherwise the `OmittedExpression` will just end up being treated like // a trailing comma. @@ -23945,7 +24066,7 @@ var ts; } // @api function createObjectLiteralExpression(properties, multiLine) { - var node = createBaseExpression(205 /* ObjectLiteralExpression */); + var node = createBaseExpression(205 /* SyntaxKind.ObjectLiteralExpression */); node.properties = createNodeArray(properties); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.properties); @@ -23959,20 +24080,20 @@ var ts; } // @api function createPropertyAccessExpression(expression, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.name = asName(name); node.transformFlags = propagateChildFlags(node.expression) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); if (ts.isSuperKeyword(expression)) { // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -23988,23 +24109,23 @@ var ts; } // @api function createPropertyAccessChain(expression, questionDotToken, name) { - var node = createBaseExpression(206 /* PropertyAccessExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(206 /* SyntaxKind.PropertyAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.name = asName(name); node.transformFlags |= - 32 /* ContainsES2020 */ | + 32 /* TransformFlags.ContainsES2020 */ | propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | (ts.isIdentifier(node.name) ? propagateIdentifierNameFlags(node.name) : - propagateChildFlags(node.name)); + propagateChildFlags(node.name) | 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); return node; } // @api function updatePropertyAccessChain(node, expression, questionDotToken, name) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -24015,8 +24136,8 @@ var ts; } // @api function createElementAccessExpression(expression, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | @@ -24025,8 +24146,8 @@ var ts; // super method calls require a lexical 'this' // super method calls require 'super' hoisting in ES2017 and ES2018 async functions and async generators node.transformFlags |= - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24042,21 +24163,21 @@ var ts; } // @api function createElementAccessChain(expression, questionDotToken, index) { - var node = createBaseExpression(207 /* ElementAccessExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(207 /* SyntaxKind.ElementAccessExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.argumentExpression = asExpression(index); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.questionDotToken) | propagateChildFlags(node.argumentExpression) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; return node; } // @api function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); // Because we are updating an existing ElementAccessChain we want to inherit its emitFlags // instead of using the default from createElementAccess return node.expression !== expression @@ -24067,8 +24188,8 @@ var ts; } // @api function createCallExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); node.transformFlags |= @@ -24076,13 +24197,13 @@ var ts; propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments); if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isImportKeyword(node.expression)) { - node.transformFlags |= 8388608 /* ContainsDynamicImport */; + node.transformFlags |= 8388608 /* TransformFlags.ContainsDynamicImport */; } else if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 16384 /* ContainsLexicalThis */; + node.transformFlags |= 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24099,9 +24220,9 @@ var ts; } // @api function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { - var node = createBaseExpression(208 /* CallExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(208 /* SyntaxKind.CallExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.questionDotToken = questionDotToken; node.typeArguments = asNodeArray(typeArguments); node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray)); @@ -24110,18 +24231,18 @@ var ts; propagateChildFlags(node.questionDotToken) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.isSuperProperty(node.expression)) { - node.transformFlags |= 16384 /* ContainsLexicalThis */; + node.transformFlags |= 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } // @api function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); return node.expression !== expression || node.questionDotToken !== questionDotToken || node.typeArguments !== typeArguments @@ -24131,7 +24252,7 @@ var ts; } // @api function createNewExpression(expression, typeArguments, argumentsArray) { - var node = createBaseExpression(209 /* NewExpression */); + var node = createBaseExpression(209 /* SyntaxKind.NewExpression */); node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined; @@ -24139,9 +24260,9 @@ var ts; propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | propagateChildrenFlags(node.arguments) | - 32 /* ContainsES2020 */; + 32 /* TransformFlags.ContainsES2020 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24155,20 +24276,20 @@ var ts; } // @api function createTaggedTemplateExpression(tag, typeArguments, template) { - var node = createBaseExpression(210 /* TaggedTemplateExpression */); - node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag); + var node = createBaseExpression(210 /* SyntaxKind.TaggedTemplateExpression */); + node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false); node.typeArguments = asNodeArray(typeArguments); node.template = template; node.transformFlags |= propagateChildFlags(node.tag) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.template) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } if (ts.hasInvalidEscape(node.template)) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } @@ -24182,13 +24303,13 @@ var ts; } // @api function createTypeAssertion(type, expression) { - var node = createBaseExpression(211 /* TypeAssertionExpression */); + var node = createBaseExpression(211 /* SyntaxKind.TypeAssertionExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24200,7 +24321,7 @@ var ts; } // @api function createParenthesizedExpression(expression) { - var node = createBaseExpression(212 /* ParenthesizedExpression */); + var node = createBaseExpression(212 /* SyntaxKind.ParenthesizedExpression */); node.expression = expression; node.transformFlags = propagateChildFlags(node.expression); return node; @@ -24213,22 +24334,22 @@ var ts; } // @api function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(213 /* FunctionExpression */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(213 /* SyntaxKind.FunctionExpression */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.asteriskToken); if (node.typeParameters) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } return node; } @@ -24246,14 +24367,14 @@ var ts; } // @api function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createBaseFunctionLikeDeclaration(214 /* ArrowFunction */, modifiers, + var node = createBaseFunctionLikeDeclaration(214 /* SyntaxKind.ArrowFunction */, modifiers, /*name*/ undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body)); - node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38 /* SyntaxKind.EqualsGreaterThanToken */); node.transformFlags |= propagateChildFlags(node.equalsGreaterThanToken) | - 1024 /* ContainsES2015 */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { - node.transformFlags |= 256 /* ContainsES2017 */ | 16384 /* ContainsLexicalThis */; + 1024 /* TransformFlags.ContainsES2015 */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */ | 16384 /* TransformFlags.ContainsLexicalThis */; } return node; } @@ -24270,7 +24391,7 @@ var ts; } // @api function createDeleteExpression(expression) { - var node = createBaseExpression(215 /* DeleteExpression */); + var node = createBaseExpression(215 /* SyntaxKind.DeleteExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24283,7 +24404,7 @@ var ts; } // @api function createTypeOfExpression(expression) { - var node = createBaseExpression(216 /* TypeOfExpression */); + var node = createBaseExpression(216 /* SyntaxKind.TypeOfExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24296,7 +24417,7 @@ var ts; } // @api function createVoidExpression(expression) { - var node = createBaseExpression(217 /* VoidExpression */); + var node = createBaseExpression(217 /* SyntaxKind.VoidExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24309,13 +24430,13 @@ var ts; } // @api function createAwaitExpression(expression) { - var node = createBaseExpression(218 /* AwaitExpression */); + var node = createBaseExpression(218 /* SyntaxKind.AwaitExpression */); node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 256 /* ContainsES2017 */ | - 128 /* ContainsES2018 */ | - 2097152 /* ContainsAwait */; + 256 /* TransformFlags.ContainsES2017 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 2097152 /* TransformFlags.ContainsAwait */; return node; } // @api @@ -24326,17 +24447,17 @@ var ts; } // @api function createPrefixUnaryExpression(operator, operand) { - var node = createBaseExpression(219 /* PrefixUnaryExpression */); + var node = createBaseExpression(219 /* SyntaxKind.PrefixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); // Only set this flag for non-generated identifiers and non-"local" names. See the // comment in `visitPreOrPostfixUnaryExpression` in module.ts - if ((operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */) && + if ((operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24348,7 +24469,7 @@ var ts; } // @api function createPostfixUnaryExpression(operand, operator) { - var node = createBaseExpression(220 /* PostfixUnaryExpression */); + var node = createBaseExpression(220 /* SyntaxKind.PostfixUnaryExpression */); node.operator = operator; node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand); node.transformFlags |= propagateChildFlags(node.operand); @@ -24357,7 +24478,7 @@ var ts; if (ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand)) { - node.transformFlags |= 268435456 /* ContainsUpdateExpressionForIdentifier */; + node.transformFlags |= 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */; } return node; } @@ -24369,7 +24490,7 @@ var ts; } // @api function createBinaryExpression(left, operator, right) { - var node = createBaseExpression(221 /* BinaryExpression */); + var node = createBaseExpression(221 /* SyntaxKind.BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left); @@ -24379,46 +24500,49 @@ var ts; propagateChildFlags(node.left) | propagateChildFlags(node.operatorToken) | propagateChildFlags(node.right); - if (operatorKind === 60 /* QuestionQuestionToken */) { - node.transformFlags |= 32 /* ContainsES2020 */; + if (operatorKind === 60 /* SyntaxKind.QuestionQuestionToken */) { + node.transformFlags |= 32 /* TransformFlags.ContainsES2020 */; } - else if (operatorKind === 63 /* EqualsToken */) { + else if (operatorKind === 63 /* SyntaxKind.EqualsToken */) { if (ts.isObjectLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } else if (ts.isArrayLiteralExpression(node.left)) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 4096 /* ContainsDestructuringAssignment */ | + 1024 /* TransformFlags.ContainsES2015 */ | + 4096 /* TransformFlags.ContainsDestructuringAssignment */ | propagateAssignmentPatternFlags(node.left); } } - else if (operatorKind === 42 /* AsteriskAsteriskToken */ || operatorKind === 67 /* AsteriskAsteriskEqualsToken */) { - node.transformFlags |= 512 /* ContainsES2016 */; + else if (operatorKind === 42 /* SyntaxKind.AsteriskAsteriskToken */ || operatorKind === 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */) { + node.transformFlags |= 512 /* TransformFlags.ContainsES2016 */; } else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) { - node.transformFlags |= 16 /* ContainsES2021 */; + node.transformFlags |= 16 /* TransformFlags.ContainsES2021 */; + } + if (operatorKind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { + node.transformFlags |= 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */; } return node; } function propagateAssignmentPatternFlags(node) { - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) - return 65536 /* ContainsObjectRestOrSpread */; - if (node.transformFlags & 128 /* ContainsES2018 */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) + return 65536 /* TransformFlags.ContainsObjectRestOrSpread */; + if (node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { // check for nested spread assignments, otherwise '{ x: { a, ...b } = foo } = c' // will not be correctly interpreted by the ES2018 transformer for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) { var element = _a[_i]; var target = ts.getTargetOfBindingOrAssignmentElement(element); if (target && ts.isAssignmentPattern(target)) { - if (target.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return 65536 /* ContainsObjectRestOrSpread */; + if (target.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return 65536 /* TransformFlags.ContainsObjectRestOrSpread */; } - if (target.transformFlags & 128 /* ContainsES2018 */) { + if (target.transformFlags & 128 /* TransformFlags.ContainsES2018 */) { var flags_1 = propagateAssignmentPatternFlags(target); if (flags_1) return flags_1; @@ -24426,7 +24550,7 @@ var ts; } } } - return 0 /* None */; + return 0 /* TransformFlags.None */; } // @api function updateBinaryExpression(node, left, operator, right) { @@ -24438,11 +24562,11 @@ var ts; } // @api function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) { - var node = createBaseExpression(222 /* ConditionalExpression */); + var node = createBaseExpression(222 /* SyntaxKind.ConditionalExpression */); node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition); - node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* QuestionToken */); + node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57 /* SyntaxKind.QuestionToken */); node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue); - node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* ColonToken */); + node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58 /* SyntaxKind.ColonToken */); node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse); node.transformFlags |= propagateChildFlags(node.condition) | @@ -24464,13 +24588,13 @@ var ts; } // @api function createTemplateExpression(head, templateSpans) { - var node = createBaseExpression(223 /* TemplateExpression */); + var node = createBaseExpression(223 /* SyntaxKind.TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); node.transformFlags |= propagateChildFlags(node.head) | propagateChildrenFlags(node.templateSpans) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24481,8 +24605,8 @@ var ts; : node; } function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) { - if (templateFlags === void 0) { templateFlags = 0 /* None */; } - ts.Debug.assert(!(templateFlags & ~2048 /* TemplateLiteralLikeFlags */), "Unsupported template flags."); + if (templateFlags === void 0) { templateFlags = 0 /* TokenFlags.None */; } + ts.Debug.assert(!(templateFlags & ~2048 /* TokenFlags.TemplateLiteralLikeFlags */), "Unsupported template flags."); // NOTE: without the assignment to `undefined`, we don't narrow the initial type of `cooked`. // eslint-disable-next-line no-undef-init var cooked = undefined; @@ -24508,41 +24632,41 @@ var ts; var node = createBaseToken(kind); node.text = text; node.rawText = rawText; - node.templateFlags = templateFlags & 2048 /* TemplateLiteralLikeFlags */; - node.transformFlags |= 1024 /* ContainsES2015 */; + node.templateFlags = templateFlags & 2048 /* TokenFlags.TemplateLiteralLikeFlags */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; if (node.templateFlags) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } return node; } // @api function createTemplateHead(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(15 /* TemplateHead */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(15 /* SyntaxKind.TemplateHead */, text, rawText, templateFlags); } // @api function createTemplateMiddle(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(16 /* TemplateMiddle */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(16 /* SyntaxKind.TemplateMiddle */, text, rawText, templateFlags); } // @api function createTemplateTail(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(17 /* TemplateTail */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(17 /* SyntaxKind.TemplateTail */, text, rawText, templateFlags); } // @api function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) { - return createTemplateLiteralLikeNodeChecked(14 /* NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); + return createTemplateLiteralLikeNodeChecked(14 /* SyntaxKind.NoSubstitutionTemplateLiteral */, text, rawText, templateFlags); } // @api function createYieldExpression(asteriskToken, expression) { ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression."); - var node = createBaseExpression(224 /* YieldExpression */); + var node = createBaseExpression(224 /* SyntaxKind.YieldExpression */); node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.asteriskToken = asteriskToken; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.asteriskToken) | - 1024 /* ContainsES2015 */ | - 128 /* ContainsES2018 */ | - 1048576 /* ContainsYield */; + 1024 /* TransformFlags.ContainsES2015 */ | + 128 /* TransformFlags.ContainsES2018 */ | + 1048576 /* TransformFlags.ContainsYield */; return node; } // @api @@ -24554,12 +24678,12 @@ var ts; } // @api function createSpreadElement(expression) { - var node = createBaseExpression(225 /* SpreadElement */); + var node = createBaseExpression(225 /* SyntaxKind.SpreadElement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 1024 /* ContainsES2015 */ | - 32768 /* ContainsRestOrSpread */; + 1024 /* TransformFlags.ContainsES2015 */ | + 32768 /* TransformFlags.ContainsRestOrSpread */; return node; } // @api @@ -24570,8 +24694,8 @@ var ts; } // @api function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(226 /* ClassExpression */, modifiers, name, typeParameters, heritageClauses, members); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseClassLikeDeclaration(226 /* SyntaxKind.ClassExpression */, modifiers, name, typeParameters, heritageClauses, members); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24586,17 +24710,17 @@ var ts; } // @api function createOmittedExpression() { - return createBaseExpression(227 /* OmittedExpression */); + return createBaseExpression(227 /* SyntaxKind.OmittedExpression */); } // @api function createExpressionWithTypeArguments(expression, typeArguments) { - var node = createBaseNode(228 /* ExpressionWithTypeArguments */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseNode(228 /* SyntaxKind.ExpressionWithTypeArguments */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.transformFlags |= propagateChildFlags(node.expression) | propagateChildrenFlags(node.typeArguments) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24608,13 +24732,13 @@ var ts; } // @api function createAsExpression(expression, type) { - var node = createBaseExpression(229 /* AsExpression */); + var node = createBaseExpression(229 /* SyntaxKind.AsExpression */); node.expression = expression; node.type = type; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.type) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24626,11 +24750,11 @@ var ts; } // @api function createNonNullExpression(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -24644,33 +24768,33 @@ var ts; } // @api function createNonNullChain(expression) { - var node = createBaseExpression(230 /* NonNullExpression */); - node.flags |= 32 /* OptionalChain */; - node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + var node = createBaseExpression(230 /* SyntaxKind.NonNullExpression */); + node.flags |= 32 /* NodeFlags.OptionalChain */; + node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true); node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api function updateNonNullChain(node, expression) { - ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); + ts.Debug.assert(!!(node.flags & 32 /* NodeFlags.OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); return node.expression !== expression ? update(createNonNullChain(expression), node) : node; } // @api function createMetaProperty(keywordToken, name) { - var node = createBaseExpression(231 /* MetaProperty */); + var node = createBaseExpression(231 /* SyntaxKind.MetaProperty */); node.keywordToken = keywordToken; node.name = name; node.transformFlags |= propagateChildFlags(node.name); switch (keywordToken) { - case 103 /* NewKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 103 /* SyntaxKind.NewKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 100 /* ImportKeyword */: - node.transformFlags |= 4 /* ContainsESNext */; + case 100 /* SyntaxKind.ImportKeyword */: + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; break; default: return ts.Debug.assertNever(keywordToken); @@ -24688,13 +24812,13 @@ var ts; // // @api function createTemplateSpan(expression, literal) { - var node = createBaseNode(233 /* TemplateSpan */); + var node = createBaseNode(233 /* SyntaxKind.TemplateSpan */); node.expression = expression; node.literal = literal; node.transformFlags |= propagateChildFlags(node.expression) | propagateChildFlags(node.literal) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; return node; } // @api @@ -24706,8 +24830,8 @@ var ts; } // @api function createSemicolonClassElement() { - var node = createBaseNode(234 /* SemicolonClassElement */); - node.transformFlags |= 1024 /* ContainsES2015 */; + var node = createBaseNode(234 /* SyntaxKind.SemicolonClassElement */); + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; return node; } // @@ -24715,7 +24839,7 @@ var ts; // // @api function createBlock(statements, multiLine) { - var node = createBaseNode(235 /* Block */); + var node = createBaseNode(235 /* SyntaxKind.Block */); node.statements = createNodeArray(statements); node.multiLine = multiLine; node.transformFlags |= propagateChildrenFlags(node.statements); @@ -24729,14 +24853,14 @@ var ts; } // @api function createVariableStatement(modifiers, declarationList) { - var node = createBaseDeclaration(237 /* VariableStatement */); + var node = createBaseDeclaration(237 /* SyntaxKind.VariableStatement */); node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.declarationList); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -24749,11 +24873,11 @@ var ts; } // @api function createEmptyStatement() { - return createBaseNode(236 /* EmptyStatement */); + return createBaseNode(236 /* SyntaxKind.EmptyStatement */); } // @api function createExpressionStatement(expression) { - var node = createBaseNode(238 /* ExpressionStatement */); + var node = createBaseNode(238 /* SyntaxKind.ExpressionStatement */); node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression); node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -24766,7 +24890,7 @@ var ts; } // @api function createIfStatement(expression, thenStatement, elseStatement) { - var node = createBaseNode(239 /* IfStatement */); + var node = createBaseNode(239 /* SyntaxKind.IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -24786,7 +24910,7 @@ var ts; } // @api function createDoStatement(statement, expression) { - var node = createBaseNode(240 /* DoStatement */); + var node = createBaseNode(240 /* SyntaxKind.DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; node.transformFlags |= @@ -24803,7 +24927,7 @@ var ts; } // @api function createWhileStatement(expression, statement) { - var node = createBaseNode(241 /* WhileStatement */); + var node = createBaseNode(241 /* SyntaxKind.WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24820,7 +24944,7 @@ var ts; } // @api function createForStatement(initializer, condition, incrementor, statement) { - var node = createBaseNode(242 /* ForStatement */); + var node = createBaseNode(242 /* SyntaxKind.ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -24843,7 +24967,7 @@ var ts; } // @api function createForInStatement(initializer, expression, statement) { - var node = createBaseNode(243 /* ForInStatement */); + var node = createBaseNode(243 /* SyntaxKind.ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -24863,7 +24987,7 @@ var ts; } // @api function createForOfStatement(awaitModifier, initializer, expression, statement) { - var node = createBaseNode(244 /* ForOfStatement */); + var node = createBaseNode(244 /* SyntaxKind.ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); @@ -24873,9 +24997,9 @@ var ts; propagateChildFlags(node.initializer) | propagateChildFlags(node.expression) | propagateChildFlags(node.statement) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; if (awaitModifier) - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; return node; } // @api @@ -24889,11 +25013,11 @@ var ts; } // @api function createContinueStatement(label) { - var node = createBaseNode(245 /* ContinueStatement */); + var node = createBaseNode(245 /* SyntaxKind.ContinueStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24904,11 +25028,11 @@ var ts; } // @api function createBreakStatement(label) { - var node = createBaseNode(246 /* BreakStatement */); + var node = createBaseNode(246 /* SyntaxKind.BreakStatement */); node.label = asName(label); node.transformFlags |= propagateChildFlags(node.label) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24919,13 +25043,13 @@ var ts; } // @api function createReturnStatement(expression) { - var node = createBaseNode(247 /* ReturnStatement */); + var node = createBaseNode(247 /* SyntaxKind.ReturnStatement */); node.expression = expression; // return in an ES2018 async generator must be awaited node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; + 128 /* TransformFlags.ContainsES2018 */ | + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; return node; } // @api @@ -24936,7 +25060,7 @@ var ts; } // @api function createWithStatement(expression, statement) { - var node = createBaseNode(248 /* WithStatement */); + var node = createBaseNode(248 /* SyntaxKind.WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24953,7 +25077,7 @@ var ts; } // @api function createSwitchStatement(expression, caseBlock) { - var node = createBaseNode(249 /* SwitchStatement */); + var node = createBaseNode(249 /* SyntaxKind.SwitchStatement */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.caseBlock = caseBlock; node.transformFlags |= @@ -24970,7 +25094,7 @@ var ts; } // @api function createLabeledStatement(label, statement) { - var node = createBaseNode(250 /* LabeledStatement */); + var node = createBaseNode(250 /* SyntaxKind.LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); node.transformFlags |= @@ -24987,7 +25111,7 @@ var ts; } // @api function createThrowStatement(expression) { - var node = createBaseNode(251 /* ThrowStatement */); + var node = createBaseNode(251 /* SyntaxKind.ThrowStatement */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); return node; @@ -25000,7 +25124,7 @@ var ts; } // @api function createTryStatement(tryBlock, catchClause, finallyBlock) { - var node = createBaseNode(252 /* TryStatement */); + var node = createBaseNode(252 /* SyntaxKind.TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -25020,16 +25144,16 @@ var ts; } // @api function createDebuggerStatement() { - return createBaseNode(253 /* DebuggerStatement */); + return createBaseNode(253 /* SyntaxKind.DebuggerStatement */); } // @api function createVariableDeclaration(name, exclamationToken, type, initializer) { - var node = createBaseVariableLikeDeclaration(254 /* VariableDeclaration */, + var node = createBaseVariableLikeDeclaration(254 /* SyntaxKind.VariableDeclaration */, /*modifiers*/ undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer)); node.exclamationToken = exclamationToken; node.transformFlags |= propagateChildFlags(node.exclamationToken); if (exclamationToken) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -25044,17 +25168,17 @@ var ts; } // @api function createVariableDeclarationList(declarations, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseNode(255 /* VariableDeclarationList */); - node.flags |= flags & 3 /* BlockScoped */; + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseNode(255 /* SyntaxKind.VariableDeclarationList */); + node.flags |= flags & 3 /* NodeFlags.BlockScoped */; node.declarations = createNodeArray(declarations); node.transformFlags |= propagateChildrenFlags(node.declarations) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; - if (flags & 3 /* BlockScoped */) { + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (flags & 3 /* NodeFlags.BlockScoped */) { node.transformFlags |= - 1024 /* ContainsES2015 */ | - 262144 /* ContainsBlockScopedBinding */; + 1024 /* TransformFlags.ContainsES2015 */ | + 262144 /* TransformFlags.ContainsBlockScopedBinding */; } return node; } @@ -25066,25 +25190,25 @@ var ts; } // @api function createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createBaseFunctionLikeDeclaration(256 /* FunctionDeclaration */, modifiers, name, typeParameters, parameters, type, body); + var node = createBaseFunctionLikeDeclaration(256 /* SyntaxKind.FunctionDeclaration */, modifiers, name, typeParameters, parameters, type, body); node.asteriskToken = asteriskToken; - if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (!node.body || ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildFlags(node.asteriskToken) | - 4194304 /* ContainsHoistedDeclarationOrCompletion */; - if (ts.modifiersToFlags(node.modifiers) & 256 /* Async */) { + 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */; + if (ts.modifiersToFlags(node.modifiers) & 256 /* ModifierFlags.Async */) { if (node.asteriskToken) { - node.transformFlags |= 128 /* ContainsES2018 */; + node.transformFlags |= 128 /* TransformFlags.ContainsES2018 */; } else { - node.transformFlags |= 256 /* ContainsES2017 */; + node.transformFlags |= 256 /* TransformFlags.ContainsES2017 */; } } else if (node.asteriskToken) { - node.transformFlags |= 2048 /* ContainsGenerator */; + node.transformFlags |= 2048 /* TransformFlags.ContainsGenerator */; } } // The following properties are used only to report grammar errors @@ -25112,14 +25236,14 @@ var ts; } // @api function createClassDeclaration(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseClassLikeDeclaration(257 /* ClassDeclaration */, modifiers, name, typeParameters, heritageClauses, members); - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + var node = createBaseClassLikeDeclaration(257 /* SyntaxKind.ClassDeclaration */, modifiers, name, typeParameters, heritageClauses, members); + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { - node.transformFlags |= 1024 /* ContainsES2015 */; - if (node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; + if (node.transformFlags & 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */) { + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } } return node; @@ -25136,9 +25260,9 @@ var ts; } // @api function createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members) { - var node = createBaseInterfaceOrClassLikeDeclaration(258 /* InterfaceDeclaration */, modifiers, name, typeParameters, heritageClauses); + var node = createBaseInterfaceOrClassLikeDeclaration(258 /* SyntaxKind.InterfaceDeclaration */, modifiers, name, typeParameters, heritageClauses); node.members = createNodeArray(members); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25161,9 +25285,9 @@ var ts; } // @api function createTypeAliasDeclaration(modifiers, name, typeParameters, type) { - var node = createBaseGenericNamedDeclaration(259 /* TypeAliasDeclaration */, modifiers, name, typeParameters); + var node = createBaseGenericNamedDeclaration(259 /* SyntaxKind.TypeAliasDeclaration */, modifiers, name, typeParameters); node.type = type; - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25185,12 +25309,12 @@ var ts; } // @api function createEnumDeclaration(modifiers, name, members) { - var node = createBaseNamedDeclaration(260 /* EnumDeclaration */, modifiers, name); + var node = createBaseNamedDeclaration(260 /* SyntaxKind.EnumDeclaration */, modifiers, name); node.members = createNodeArray(members); node.transformFlags |= propagateChildrenFlags(node.members) | - 1 /* ContainsTypeScript */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` + 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Enum declarations cannot contain `await` // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25211,23 +25335,23 @@ var ts; } // @api function createModuleDeclaration(modifiers, name, body, flags) { - if (flags === void 0) { flags = 0 /* None */; } - var node = createBaseDeclaration(261 /* ModuleDeclaration */); + if (flags === void 0) { flags = 0 /* NodeFlags.None */; } + var node = createBaseDeclaration(261 /* SyntaxKind.ModuleDeclaration */); node.modifiers = asNodeArray(modifiers); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); + node.flags |= flags & (16 /* NodeFlags.Namespace */ | 4 /* NodeFlags.NestedNamespace */ | 1024 /* NodeFlags.GlobalAugmentation */); node.name = name; node.body = body; - if (ts.modifiersToFlags(node.modifiers) & 2 /* Ambient */) { - node.transformFlags = 1 /* ContainsTypeScript */; + if (ts.modifiersToFlags(node.modifiers) & 2 /* ModifierFlags.Ambient */) { + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; } else { node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildFlags(node.body) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Module declarations cannot contain `await`. // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25248,7 +25372,7 @@ var ts; } // @api function createModuleBlock(statements) { - var node = createBaseNode(262 /* ModuleBlock */); + var node = createBaseNode(262 /* SyntaxKind.ModuleBlock */); node.statements = createNodeArray(statements); node.transformFlags |= propagateChildrenFlags(node.statements); return node; @@ -25261,7 +25385,7 @@ var ts; } // @api function createCaseBlock(clauses) { - var node = createBaseNode(263 /* CaseBlock */); + var node = createBaseNode(263 /* SyntaxKind.CaseBlock */); node.clauses = createNodeArray(clauses); node.transformFlags |= propagateChildrenFlags(node.clauses); return node; @@ -25274,9 +25398,9 @@ var ts; } // @api function createNamespaceExportDeclaration(name) { - var node = createBaseNamedDeclaration(264 /* NamespaceExportDeclaration */, + var node = createBaseNamedDeclaration(264 /* SyntaxKind.NamespaceExportDeclaration */, /*modifiers*/ undefined, name); - node.transformFlags = 1 /* ContainsTypeScript */; + node.transformFlags = 1 /* TransformFlags.ContainsTypeScript */; // The following properties are used only to report grammar errors node.decorators = undefined; node.modifiers = undefined; @@ -25297,13 +25421,13 @@ var ts; } // @api function createImportEqualsDeclaration(modifiers, isTypeOnly, name, moduleReference) { - var node = createBaseNamedDeclaration(265 /* ImportEqualsDeclaration */, modifiers, name); + var node = createBaseNamedDeclaration(265 /* SyntaxKind.ImportEqualsDeclaration */, modifiers, name); node.isTypeOnly = isTypeOnly; node.moduleReference = moduleReference; node.transformFlags |= propagateChildFlags(node.moduleReference); if (!ts.isExternalModuleReference(node.moduleReference)) - node.transformFlags |= 1 /* ContainsTypeScript */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // Import= declaration is always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25325,7 +25449,7 @@ var ts; } // @api function createImportDeclaration(modifiers, importClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(266 /* ImportDeclaration */); + var node = createBaseDeclaration(266 /* SyntaxKind.ImportDeclaration */); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; @@ -25333,7 +25457,7 @@ var ts; node.transformFlags |= propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25355,7 +25479,7 @@ var ts; } // @api function createImportClause(isTypeOnly, name, namedBindings) { - var node = createBaseNode(267 /* ImportClause */); + var node = createBaseNode(267 /* SyntaxKind.ImportClause */); node.isTypeOnly = isTypeOnly; node.name = name; node.namedBindings = namedBindings; @@ -25363,9 +25487,9 @@ var ts; propagateChildFlags(node.name) | propagateChildFlags(node.namedBindings); if (isTypeOnly) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25378,10 +25502,10 @@ var ts; } // @api function createAssertClause(elements, multiLine) { - var node = createBaseNode(293 /* AssertClause */); + var node = createBaseNode(293 /* SyntaxKind.AssertClause */); node.elements = createNodeArray(elements); node.multiLine = multiLine; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25393,10 +25517,10 @@ var ts; } // @api function createAssertEntry(name, value) { - var node = createBaseNode(294 /* AssertEntry */); + var node = createBaseNode(294 /* SyntaxKind.AssertEntry */); node.name = name; node.value = value; - node.transformFlags |= 4 /* ContainsESNext */; + node.transformFlags |= 4 /* TransformFlags.ContainsESNext */; return node; } // @api @@ -25408,7 +25532,7 @@ var ts; } // @api function createImportTypeAssertionContainer(clause, multiLine) { - var node = createBaseNode(295 /* ImportTypeAssertionContainer */); + var node = createBaseNode(295 /* SyntaxKind.ImportTypeAssertionContainer */); node.assertClause = clause; node.multiLine = multiLine; return node; @@ -25422,10 +25546,10 @@ var ts; } // @api function createNamespaceImport(name) { - var node = createBaseNode(268 /* NamespaceImport */); + var node = createBaseNode(268 /* SyntaxKind.NamespaceImport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25436,12 +25560,12 @@ var ts; } // @api function createNamespaceExport(name) { - var node = createBaseNode(274 /* NamespaceExport */); + var node = createBaseNode(274 /* SyntaxKind.NamespaceExport */); node.name = name; node.transformFlags |= propagateChildFlags(node.name) | - 4 /* ContainsESNext */; - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + 4 /* TransformFlags.ContainsESNext */; + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25452,10 +25576,10 @@ var ts; } // @api function createNamedImports(elements) { - var node = createBaseNode(269 /* NamedImports */); + var node = createBaseNode(269 /* SyntaxKind.NamedImports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25466,14 +25590,14 @@ var ts; } // @api function createImportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(270 /* ImportSpecifier */); + var node = createBaseNode(270 /* SyntaxKind.ImportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = propertyName; node.name = name; node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25486,14 +25610,14 @@ var ts; } // @api function createExportAssignment(modifiers, isExportEquals, expression) { - var node = createBaseDeclaration(271 /* ExportAssignment */); + var node = createBaseDeclaration(271 /* SyntaxKind.ExportAssignment */); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals - ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* EqualsToken */, /*leftSide*/ undefined, expression) + ? parenthesizerRules().parenthesizeRightSideOfBinary(63 /* SyntaxKind.EqualsToken */, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.expression); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25513,7 +25637,7 @@ var ts; } // @api function createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause) { - var node = createBaseDeclaration(272 /* ExportDeclaration */); + var node = createBaseDeclaration(272 /* SyntaxKind.ExportDeclaration */); node.modifiers = asNodeArray(modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; @@ -25523,7 +25647,7 @@ var ts; propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context // The following properties are used only to report grammar errors node.decorators = undefined; return node; @@ -25546,10 +25670,10 @@ var ts; } // @api function createNamedExports(elements) { - var node = createBaseNode(273 /* NamedExports */); + var node = createBaseNode(273 /* SyntaxKind.NamedExports */); node.elements = createNodeArray(elements); node.transformFlags |= propagateChildrenFlags(node.elements); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25560,14 +25684,14 @@ var ts; } // @api function createExportSpecifier(isTypeOnly, propertyName, name) { - var node = createBaseNode(275 /* ExportSpecifier */); + var node = createBaseNode(275 /* SyntaxKind.ExportSpecifier */); node.isTypeOnly = isTypeOnly; node.propertyName = asName(propertyName); node.name = asName(name); node.transformFlags |= propagateChildFlags(node.propertyName) | propagateChildFlags(node.name); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25580,7 +25704,7 @@ var ts; } // @api function createMissingDeclaration() { - var node = createBaseDeclaration(276 /* MissingDeclaration */); + var node = createBaseDeclaration(276 /* SyntaxKind.MissingDeclaration */); return node; } // @@ -25588,10 +25712,10 @@ var ts; // // @api function createExternalModuleReference(expression) { - var node = createBaseNode(277 /* ExternalModuleReference */); + var node = createBaseNode(277 /* SyntaxKind.ExternalModuleReference */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression); - node.transformFlags &= ~67108864 /* ContainsPossibleTopLevelAwait */; // always parsed in an Await context + node.transformFlags &= ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; // always parsed in an Await context return node; } // @api @@ -25646,7 +25770,7 @@ var ts; } // @api function createJSDocFunctionType(parameters, type) { - var node = createBaseSignatureDeclaration(317 /* JSDocFunctionType */, + var node = createBaseSignatureDeclaration(317 /* SyntaxKind.JSDocFunctionType */, /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, parameters, type); @@ -25662,7 +25786,7 @@ var ts; // @api function createJSDocTypeLiteral(propertyTags, isArrayType) { if (isArrayType === void 0) { isArrayType = false; } - var node = createBaseNode(322 /* JSDocTypeLiteral */); + var node = createBaseNode(322 /* SyntaxKind.JSDocTypeLiteral */); node.jsDocPropertyTags = asNodeArray(propertyTags); node.isArrayType = isArrayType; return node; @@ -25676,7 +25800,7 @@ var ts; } // @api function createJSDocTypeExpression(type) { - var node = createBaseNode(309 /* JSDocTypeExpression */); + var node = createBaseNode(309 /* SyntaxKind.JSDocTypeExpression */); node.type = type; return node; } @@ -25688,7 +25812,7 @@ var ts; } // @api function createJSDocSignature(typeParameters, parameters, type) { - var node = createBaseNode(323 /* JSDocSignature */); + var node = createBaseNode(323 /* SyntaxKind.JSDocSignature */); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; @@ -25717,7 +25841,7 @@ var ts; } // @api function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) { - var node = createBaseJSDocTag(344 /* JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); + var node = createBaseJSDocTag(344 /* SyntaxKind.JSDocTemplateTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment); node.constraint = constraint; node.typeParameters = createNodeArray(typeParameters); return node; @@ -25734,7 +25858,7 @@ var ts; } // @api function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(345 /* JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); + var node = createBaseJSDocTag(345 /* SyntaxKind.JSDocTypedefTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25752,7 +25876,7 @@ var ts; } // @api function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(340 /* JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); + var node = createBaseJSDocTag(340 /* SyntaxKind.JSDocParameterTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25773,7 +25897,7 @@ var ts; } // @api function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) { - var node = createBaseJSDocTag(347 /* JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); + var node = createBaseJSDocTag(347 /* SyntaxKind.JSDocPropertyTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment); node.typeExpression = typeExpression; node.name = name; node.isNameFirst = !!isNameFirst; @@ -25794,7 +25918,7 @@ var ts; } // @api function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) { - var node = createBaseJSDocTag(338 /* JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); + var node = createBaseJSDocTag(338 /* SyntaxKind.JSDocCallbackTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment); node.typeExpression = typeExpression; node.fullName = fullName; node.name = ts.getJSDocTypeAliasName(fullName); @@ -25812,7 +25936,7 @@ var ts; } // @api function createJSDocAugmentsTag(tagName, className, comment) { - var node = createBaseJSDocTag(328 /* JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); + var node = createBaseJSDocTag(328 /* SyntaxKind.JSDocAugmentsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment); node.class = className; return node; } @@ -25827,13 +25951,13 @@ var ts; } // @api function createJSDocImplementsTag(tagName, className, comment) { - var node = createBaseJSDocTag(329 /* JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); + var node = createBaseJSDocTag(329 /* SyntaxKind.JSDocImplementsTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment); node.class = className; return node; } // @api function createJSDocSeeTag(tagName, name, comment) { - var node = createBaseJSDocTag(346 /* JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); + var node = createBaseJSDocTag(346 /* SyntaxKind.JSDocSeeTag */, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment); node.name = name; return node; } @@ -25847,7 +25971,7 @@ var ts; } // @api function createJSDocNameReference(name) { - var node = createBaseNode(310 /* JSDocNameReference */); + var node = createBaseNode(310 /* SyntaxKind.JSDocNameReference */); node.name = name; return node; } @@ -25859,7 +25983,7 @@ var ts; } // @api function createJSDocMemberName(left, right) { - var node = createBaseNode(311 /* JSDocMemberName */); + var node = createBaseNode(311 /* SyntaxKind.JSDocMemberName */); node.left = left; node.right = right; node.transformFlags |= @@ -25876,7 +26000,7 @@ var ts; } // @api function createJSDocLink(name, text) { - var node = createBaseNode(324 /* JSDocLink */); + var node = createBaseNode(324 /* SyntaxKind.JSDocLink */); node.name = name; node.text = text; return node; @@ -25889,7 +26013,7 @@ var ts; } // @api function createJSDocLinkCode(name, text) { - var node = createBaseNode(325 /* JSDocLinkCode */); + var node = createBaseNode(325 /* SyntaxKind.JSDocLinkCode */); node.name = name; node.text = text; return node; @@ -25902,7 +26026,7 @@ var ts; } // @api function createJSDocLinkPlain(name, text) { - var node = createBaseNode(326 /* JSDocLinkPlain */); + var node = createBaseNode(326 /* SyntaxKind.JSDocLinkPlain */); node.name = name; node.text = text; return node; @@ -25974,7 +26098,7 @@ var ts; } // @api function createJSDocUnknownTag(tagName, comment) { - var node = createBaseJSDocTag(327 /* JSDocTag */, tagName, comment); + var node = createBaseJSDocTag(327 /* SyntaxKind.JSDocTag */, tagName, comment); return node; } // @api @@ -25986,7 +26110,7 @@ var ts; } // @api function createJSDocText(text) { - var node = createBaseNode(321 /* JSDocText */); + var node = createBaseNode(321 /* SyntaxKind.JSDocText */); node.text = text; return node; } @@ -25998,7 +26122,7 @@ var ts; } // @api function createJSDocComment(comment, tags) { - var node = createBaseNode(320 /* JSDoc */); + var node = createBaseNode(320 /* SyntaxKind.JSDoc */); node.comment = comment; node.tags = asNodeArray(tags); return node; @@ -26015,7 +26139,7 @@ var ts; // // @api function createJsxElement(openingElement, children, closingElement) { - var node = createBaseNode(278 /* JsxElement */); + var node = createBaseNode(278 /* SyntaxKind.JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -26023,7 +26147,7 @@ var ts; propagateChildFlags(node.openingElement) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingElement) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26036,7 +26160,7 @@ var ts; } // @api function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createBaseNode(279 /* JsxSelfClosingElement */); + var node = createBaseNode(279 /* SyntaxKind.JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -26044,9 +26168,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (node.typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -26060,7 +26184,7 @@ var ts; } // @api function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createBaseNode(280 /* JsxOpeningElement */); + var node = createBaseNode(280 /* SyntaxKind.JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -26068,9 +26192,9 @@ var ts; propagateChildFlags(node.tagName) | propagateChildrenFlags(node.typeArguments) | propagateChildFlags(node.attributes) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; if (typeArguments) { - node.transformFlags |= 1 /* ContainsTypeScript */; + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; } return node; } @@ -26084,11 +26208,11 @@ var ts; } // @api function createJsxClosingElement(tagName) { - var node = createBaseNode(281 /* JsxClosingElement */); + var node = createBaseNode(281 /* SyntaxKind.JsxClosingElement */); node.tagName = tagName; node.transformFlags |= propagateChildFlags(node.tagName) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26099,7 +26223,7 @@ var ts; } // @api function createJsxFragment(openingFragment, children, closingFragment) { - var node = createBaseNode(282 /* JsxFragment */); + var node = createBaseNode(282 /* SyntaxKind.JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -26107,7 +26231,7 @@ var ts; propagateChildFlags(node.openingFragment) | propagateChildrenFlags(node.children) | propagateChildFlags(node.closingFragment) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26120,10 +26244,10 @@ var ts; } // @api function createJsxText(text, containsOnlyTriviaWhiteSpaces) { - var node = createBaseNode(11 /* JsxText */); + var node = createBaseNode(11 /* SyntaxKind.JsxText */); node.text = text; node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces; - node.transformFlags |= 2 /* ContainsJsx */; + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26135,25 +26259,25 @@ var ts; } // @api function createJsxOpeningFragment() { - var node = createBaseNode(283 /* JsxOpeningFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(283 /* SyntaxKind.JsxOpeningFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxJsxClosingFragment() { - var node = createBaseNode(284 /* JsxClosingFragment */); - node.transformFlags |= 2 /* ContainsJsx */; + var node = createBaseNode(284 /* SyntaxKind.JsxClosingFragment */); + node.transformFlags |= 2 /* TransformFlags.ContainsJsx */; return node; } // @api function createJsxAttribute(name, initializer) { - var node = createBaseNode(285 /* JsxAttribute */); + var node = createBaseNode(285 /* SyntaxKind.JsxAttribute */); node.name = name; node.initializer = initializer; node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26165,11 +26289,11 @@ var ts; } // @api function createJsxAttributes(properties) { - var node = createBaseNode(286 /* JsxAttributes */); + var node = createBaseNode(286 /* SyntaxKind.JsxAttributes */); node.properties = createNodeArray(properties); node.transformFlags |= propagateChildrenFlags(node.properties) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26180,11 +26304,11 @@ var ts; } // @api function createJsxSpreadAttribute(expression) { - var node = createBaseNode(287 /* JsxSpreadAttribute */); + var node = createBaseNode(287 /* SyntaxKind.JsxSpreadAttribute */); node.expression = expression; node.transformFlags |= propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26195,13 +26319,13 @@ var ts; } // @api function createJsxExpression(dotDotDotToken, expression) { - var node = createBaseNode(288 /* JsxExpression */); + var node = createBaseNode(288 /* SyntaxKind.JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; node.transformFlags |= propagateChildFlags(node.dotDotDotToken) | propagateChildFlags(node.expression) | - 2 /* ContainsJsx */; + 2 /* TransformFlags.ContainsJsx */; return node; } // @api @@ -26215,7 +26339,7 @@ var ts; // // @api function createCaseClause(expression, statements) { - var node = createBaseNode(289 /* CaseClause */); + var node = createBaseNode(289 /* SyntaxKind.CaseClause */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.statements = createNodeArray(statements); node.transformFlags |= @@ -26232,7 +26356,7 @@ var ts; } // @api function createDefaultClause(statements) { - var node = createBaseNode(290 /* DefaultClause */); + var node = createBaseNode(290 /* SyntaxKind.DefaultClause */); node.statements = createNodeArray(statements); node.transformFlags = propagateChildrenFlags(node.statements); return node; @@ -26245,16 +26369,16 @@ var ts; } // @api function createHeritageClause(token, types) { - var node = createBaseNode(291 /* HeritageClause */); + var node = createBaseNode(291 /* SyntaxKind.HeritageClause */); node.token = token; node.types = createNodeArray(types); node.transformFlags |= propagateChildrenFlags(node.types); switch (token) { - case 94 /* ExtendsKeyword */: - node.transformFlags |= 1024 /* ContainsES2015 */; + case 94 /* SyntaxKind.ExtendsKeyword */: + node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */; break; - case 117 /* ImplementsKeyword */: - node.transformFlags |= 1 /* ContainsTypeScript */; + case 117 /* SyntaxKind.ImplementsKeyword */: + node.transformFlags |= 1 /* TransformFlags.ContainsTypeScript */; break; default: return ts.Debug.assertNever(token); @@ -26269,7 +26393,7 @@ var ts; } // @api function createCatchClause(variableDeclaration, block) { - var node = createBaseNode(292 /* CatchClause */); + var node = createBaseNode(292 /* SyntaxKind.CatchClause */); if (typeof variableDeclaration === "string" || variableDeclaration && !ts.isVariableDeclaration(variableDeclaration)) { variableDeclaration = createVariableDeclaration(variableDeclaration, /*exclamationToken*/ undefined, @@ -26282,7 +26406,7 @@ var ts; propagateChildFlags(node.variableDeclaration) | propagateChildFlags(node.block); if (!variableDeclaration) - node.transformFlags |= 64 /* ContainsES2019 */; + node.transformFlags |= 64 /* TransformFlags.ContainsES2019 */; return node; } // @api @@ -26297,7 +26421,7 @@ var ts; // // @api function createPropertyAssignment(name, initializer) { - var node = createBaseNamedDeclaration(296 /* PropertyAssignment */, + var node = createBaseNamedDeclaration(296 /* SyntaxKind.PropertyAssignment */, /*modifiers*/ undefined, name); node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= @@ -26329,12 +26453,12 @@ var ts; } // @api function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createBaseNamedDeclaration(297 /* ShorthandPropertyAssignment */, + var node = createBaseNamedDeclaration(297 /* SyntaxKind.ShorthandPropertyAssignment */, /*modifiers*/ undefined, name); node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer); node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | - 1024 /* ContainsES2015 */; + 1024 /* TransformFlags.ContainsES2015 */; // The following properties are used only to report grammar errors node.equalsToken = undefined; node.decorators = undefined; @@ -26363,12 +26487,12 @@ var ts; } // @api function createSpreadAssignment(expression) { - var node = createBaseNode(298 /* SpreadAssignment */); + var node = createBaseNode(298 /* SyntaxKind.SpreadAssignment */); node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression); node.transformFlags |= propagateChildFlags(node.expression) | - 128 /* ContainsES2018 */ | - 65536 /* ContainsObjectRestOrSpread */; + 128 /* TransformFlags.ContainsES2018 */ | + 65536 /* TransformFlags.ContainsObjectRestOrSpread */; return node; } // @api @@ -26382,13 +26506,13 @@ var ts; // // @api function createEnumMember(name, initializer) { - var node = createBaseNode(299 /* EnumMember */); + var node = createBaseNode(299 /* SyntaxKind.EnumMember */); node.name = asName(name); node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer); node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; return node; } // @api @@ -26403,7 +26527,7 @@ var ts; // // @api function createSourceFile(statements, endOfFileToken, flags) { - var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */); + var node = baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */); node.statements = createNodeArray(statements); node.endOfFileToken = endOfFileToken; node.flags |= flags; @@ -26420,7 +26544,7 @@ var ts; return node; } function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) { - var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SourceFile */)); + var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */)); for (var p in source) { if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p)) continue; @@ -26459,7 +26583,7 @@ var ts; // @api function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = createBaseNode(306 /* Bundle */); + var node = createBaseNode(306 /* SyntaxKind.Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -26474,7 +26598,7 @@ var ts; } // @api function createUnparsedSource(prologues, syntheticReferences, texts) { - var node = createBaseNode(307 /* UnparsedSource */); + var node = createBaseNode(307 /* SyntaxKind.UnparsedSource */); node.prologues = prologues; node.syntheticReferences = syntheticReferences; node.texts = texts; @@ -26492,28 +26616,28 @@ var ts; } // @api function createUnparsedPrologue(data) { - return createBaseUnparsedNode(300 /* UnparsedPrologue */, data); + return createBaseUnparsedNode(300 /* SyntaxKind.UnparsedPrologue */, data); } // @api function createUnparsedPrepend(data, texts) { - var node = createBaseUnparsedNode(301 /* UnparsedPrepend */, data); + var node = createBaseUnparsedNode(301 /* SyntaxKind.UnparsedPrepend */, data); node.texts = texts; return node; } // @api function createUnparsedTextLike(data, internal) { - return createBaseUnparsedNode(internal ? 303 /* UnparsedInternalText */ : 302 /* UnparsedText */, data); + return createBaseUnparsedNode(internal ? 303 /* SyntaxKind.UnparsedInternalText */ : 302 /* SyntaxKind.UnparsedText */, data); } // @api function createUnparsedSyntheticReference(section) { - var node = createBaseNode(304 /* UnparsedSyntheticReference */); + var node = createBaseNode(304 /* SyntaxKind.UnparsedSyntheticReference */); node.data = section.data; node.section = section; return node; } // @api function createInputFiles() { - var node = createBaseNode(308 /* InputFiles */); + var node = createBaseNode(308 /* SyntaxKind.InputFiles */); node.javascriptText = ""; node.declarationText = ""; return node; @@ -26524,7 +26648,7 @@ var ts; // @api function createSyntheticExpression(type, isSpread, tupleNameSource) { if (isSpread === void 0) { isSpread = false; } - var node = createBaseNode(232 /* SyntheticExpression */); + var node = createBaseNode(232 /* SyntaxKind.SyntheticExpression */); node.type = type; node.isSpread = isSpread; node.tupleNameSource = tupleNameSource; @@ -26532,7 +26656,7 @@ var ts; } // @api function createSyntaxList(children) { - var node = createBaseNode(348 /* SyntaxList */); + var node = createBaseNode(348 /* SyntaxKind.SyntaxList */); node._children = children; return node; } @@ -26547,7 +26671,7 @@ var ts; */ // @api function createNotEmittedStatement(original) { - var node = createBaseNode(349 /* NotEmittedStatement */); + var node = createBaseNode(349 /* SyntaxKind.NotEmittedStatement */); node.original = original; ts.setTextRange(node, original); return node; @@ -26561,12 +26685,12 @@ var ts; */ // @api function createPartiallyEmittedExpression(expression, original) { - var node = createBaseNode(350 /* PartiallyEmittedExpression */); + var node = createBaseNode(350 /* SyntaxKind.PartiallyEmittedExpression */); node.expression = expression; node.original = original; node.transformFlags |= propagateChildFlags(node.expression) | - 1 /* ContainsTypeScript */; + 1 /* TransformFlags.ContainsTypeScript */; ts.setTextRange(node, original); return node; } @@ -26589,7 +26713,7 @@ var ts; } // @api function createCommaListExpression(elements) { - var node = createBaseNode(351 /* CommaListExpression */); + var node = createBaseNode(351 /* SyntaxKind.CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); node.transformFlags |= propagateChildrenFlags(node.elements); return node; @@ -26606,7 +26730,7 @@ var ts; */ // @api function createEndOfDeclarationMarker(original) { - var node = createBaseNode(353 /* EndOfDeclarationMarker */); + var node = createBaseNode(353 /* SyntaxKind.EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -26617,14 +26741,14 @@ var ts; */ // @api function createMergeDeclarationMarker(original) { - var node = createBaseNode(352 /* MergeDeclarationMarker */); + var node = createBaseNode(352 /* SyntaxKind.MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; } // @api function createSyntheticReferenceExpression(expression, thisArg) { - var node = createBaseNode(354 /* SyntheticReferenceExpression */); + var node = createBaseNode(354 /* SyntaxKind.SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; node.transformFlags |= @@ -26646,12 +26770,12 @@ var ts; if (node === undefined) { return node; } - var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SourceFile */) : - ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* Identifier */) : - ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* PrivateIdentifier */) : + var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(305 /* SyntaxKind.SourceFile */) : + ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(79 /* SyntaxKind.Identifier */) : + ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(80 /* SyntaxKind.PrivateIdentifier */) : !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) : baseFactory.createBaseNode(node.kind); - clone.flags |= (node.flags & ~8 /* Synthesized */); + clone.flags |= (node.flags & ~8 /* NodeFlags.Synthesized */); clone.transformFlags = node.transformFlags; setOriginalNode(clone, node); for (var key in node) { @@ -26763,11 +26887,11 @@ var ts; } function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 212 /* ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); - case 211 /* TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 229 /* AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); - case 230 /* NonNullExpression */: return updateNonNullExpression(outerExpression, expression); - case 350 /* PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); + case 212 /* SyntaxKind.ParenthesizedExpression */: return updateParenthesizedExpression(outerExpression, expression); + case 211 /* SyntaxKind.TypeAssertionExpression */: return updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 229 /* SyntaxKind.AsExpression */: return updateAsExpression(outerExpression, expression, outerExpression.type); + case 230 /* SyntaxKind.NonNullExpression */: return updateNonNullExpression(outerExpression, expression); + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -26793,7 +26917,7 @@ var ts; && !ts.some(ts.getSyntheticTrailingComments(node)); } function restoreOuterExpressions(outerExpression, innerExpression, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression)); } @@ -26814,20 +26938,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return cacheIdentifiers; - case 108 /* ThisKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: + case 108 /* SyntaxKind.ThisKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return false; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -26835,7 +26959,7 @@ var ts; } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } - var callee = ts.skipOuterExpressions(expression, 15 /* All */); + var callee = ts.skipOuterExpressions(expression, 15 /* OuterExpressionKinds.All */); var thisArg; var target; if (ts.isSuperProperty(callee)) { @@ -26844,13 +26968,13 @@ var ts; } else if (ts.isSuperKeyword(callee)) { thisArg = createThis(); - target = languageVersion !== undefined && languageVersion < 2 /* ES2015 */ + target = languageVersion !== undefined && languageVersion < 2 /* ScriptTarget.ES2015 */ ? ts.setTextRange(createIdentifier("_super"), callee) : callee; } - else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + else if (ts.getEmitFlags(callee) & 4096 /* EmitFlags.HelperName */) { thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false); } else if (ts.isPropertyAccessExpression(callee)) { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { @@ -26879,7 +27003,7 @@ var ts; else { // for `a()` target is `a` and thisArg is `void 0` thisArg = createVoidZero(); - target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression); + target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false); } return { target: target, thisArg: thisArg }; } @@ -26913,9 +27037,9 @@ var ts; var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent); emitFlags |= ts.getEmitFlags(nodeName); if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(name, emitFlags); return name; @@ -26934,7 +27058,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getInternalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */ | 32768 /* EmitFlags.InternalName */); } /** * Gets the local name of a declaration. This is primarily used for declarations that can be @@ -26947,7 +27071,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getLocalName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */); + return getName(node, allowComments, allowSourceMaps, 16384 /* EmitFlags.LocalName */); } /** * Gets the export name of a declaration. This is primarily used for declarations that can be @@ -26960,7 +27084,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExportName(node, allowComments, allowSourceMaps) { - return getName(node, allowComments, allowSourceMaps, 8192 /* ExportName */); + return getName(node, allowComments, allowSourceMaps, 8192 /* EmitFlags.ExportName */); } /** * Gets the name of a declaration for use in declarations. @@ -26985,9 +27109,9 @@ var ts; ts.setTextRange(qualifiedName, name); var emitFlags = 0; if (!allowSourceMaps) - emitFlags |= 48 /* NoSourceMap */; + emitFlags |= 48 /* EmitFlags.NoSourceMap */; if (!allowComments) - emitFlags |= 1536 /* NoComments */; + emitFlags |= 1536 /* EmitFlags.NoComments */; if (emitFlags) ts.setEmitFlags(qualifiedName, emitFlags); return qualifiedName; @@ -27004,7 +27128,7 @@ var ts; * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. */ function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) { - if (ns && ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ns && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps); } return getExportName(node, allowComments, allowSourceMaps); @@ -27062,7 +27186,7 @@ var ts; var numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) { + if (ts.getEmitFlags(statement) & 1048576 /* EmitFlags.CustomPrologue */ && filter(statement)) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -27253,52 +27377,52 @@ var ts; } function getDefaultTagNameForKind(kind) { switch (kind) { - case 343 /* JSDocTypeTag */: return "type"; - case 341 /* JSDocReturnTag */: return "returns"; - case 342 /* JSDocThisTag */: return "this"; - case 339 /* JSDocEnumTag */: return "enum"; - case 330 /* JSDocAuthorTag */: return "author"; - case 332 /* JSDocClassTag */: return "class"; - case 333 /* JSDocPublicTag */: return "public"; - case 334 /* JSDocPrivateTag */: return "private"; - case 335 /* JSDocProtectedTag */: return "protected"; - case 336 /* JSDocReadonlyTag */: return "readonly"; - case 337 /* JSDocOverrideTag */: return "override"; - case 344 /* JSDocTemplateTag */: return "template"; - case 345 /* JSDocTypedefTag */: return "typedef"; - case 340 /* JSDocParameterTag */: return "param"; - case 347 /* JSDocPropertyTag */: return "prop"; - case 338 /* JSDocCallbackTag */: return "callback"; - case 328 /* JSDocAugmentsTag */: return "augments"; - case 329 /* JSDocImplementsTag */: return "implements"; + case 343 /* SyntaxKind.JSDocTypeTag */: return "type"; + case 341 /* SyntaxKind.JSDocReturnTag */: return "returns"; + case 342 /* SyntaxKind.JSDocThisTag */: return "this"; + case 339 /* SyntaxKind.JSDocEnumTag */: return "enum"; + case 330 /* SyntaxKind.JSDocAuthorTag */: return "author"; + case 332 /* SyntaxKind.JSDocClassTag */: return "class"; + case 333 /* SyntaxKind.JSDocPublicTag */: return "public"; + case 334 /* SyntaxKind.JSDocPrivateTag */: return "private"; + case 335 /* SyntaxKind.JSDocProtectedTag */: return "protected"; + case 336 /* SyntaxKind.JSDocReadonlyTag */: return "readonly"; + case 337 /* SyntaxKind.JSDocOverrideTag */: return "override"; + case 344 /* SyntaxKind.JSDocTemplateTag */: return "template"; + case 345 /* SyntaxKind.JSDocTypedefTag */: return "typedef"; + case 340 /* SyntaxKind.JSDocParameterTag */: return "param"; + case 347 /* SyntaxKind.JSDocPropertyTag */: return "prop"; + case 338 /* SyntaxKind.JSDocCallbackTag */: return "callback"; + case 328 /* SyntaxKind.JSDocAugmentsTag */: return "augments"; + case 329 /* SyntaxKind.JSDocImplementsTag */: return "implements"; default: - return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind)); + return ts.Debug.fail("Unsupported kind: ".concat(ts.Debug.formatSyntaxKind(kind))); } } var rawTextScanner; var invalidValueSentinel = {}; function getCookedText(kind, rawText) { if (!rawTextScanner) { - rawTextScanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); + rawTextScanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ false, 0 /* LanguageVariant.Standard */); } switch (kind) { - case 14 /* NoSubstitutionTemplateLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: rawTextScanner.setText("`" + rawText + "`"); break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; - case 16 /* TemplateMiddle */: + case 16 /* SyntaxKind.TemplateMiddle */: // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; - case 17 /* TemplateTail */: + case 17 /* SyntaxKind.TemplateTail */: rawTextScanner.setText("}" + rawText + "`"); break; } var token = rawTextScanner.scan(); - if (token === 19 /* CloseBraceToken */) { + if (token === 19 /* SyntaxKind.CloseBraceToken */) { token = rawTextScanner.reScanTemplateToken(/*isTaggedTemplate*/ false); } if (rawTextScanner.isUnterminated()) { @@ -27307,14 +27431,14 @@ var ts; } var tokenValue; switch (token) { - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: tokenValue = rawTextScanner.getTokenValue(); break; } - if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* EndOfFileToken */) { + if (tokenValue === undefined || rawTextScanner.scan() !== 1 /* SyntaxKind.EndOfFileToken */) { rawTextScanner.setText(undefined); return invalidValueSentinel; } @@ -27323,22 +27447,22 @@ var ts; } function propagateIdentifierNameFlags(node) { // An IdentifierName is allowed to be `await` - return propagateChildFlags(node) & ~67108864 /* ContainsPossibleTopLevelAwait */; + return propagateChildFlags(node) & ~67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */; } function propagatePropertyNameFlagsOfChild(node, transformFlags) { - return transformFlags | (node.transformFlags & 134234112 /* PropertyNamePropagatingFlags */); + return transformFlags | (node.transformFlags & 134234112 /* TransformFlags.PropertyNamePropagatingFlags */); } function propagateChildFlags(child) { if (!child) - return 0 /* None */; + return 0 /* TransformFlags.None */; var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind); return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags; } function propagateChildrenFlags(children) { - return children ? children.transformFlags : 0 /* None */; + return children ? children.transformFlags : 0 /* TransformFlags.None */; } function aggregateChildrenFlags(children) { - var subtreeFlags = 0 /* None */; + var subtreeFlags = 0 /* TransformFlags.None */; for (var _i = 0, children_2 = children; _i < children_2.length; _i++) { var child = children_2[_i]; subtreeFlags |= propagateChildFlags(child); @@ -27350,78 +27474,78 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 177 /* FirstTypeNode */ && kind <= 200 /* LastTypeNode */) { - return -2 /* TypeExcludes */; + if (kind >= 177 /* SyntaxKind.FirstTypeNode */ && kind <= 200 /* SyntaxKind.LastTypeNode */) { + return -2 /* TransformFlags.TypeExcludes */; } switch (kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 204 /* ArrayLiteralExpression */: - return 536903680 /* ArrayLiteralOrCallOrNewExcludes */; - case 261 /* ModuleDeclaration */: - return 742678528 /* ModuleExcludes */; - case 164 /* Parameter */: - return 536870912 /* ParameterExcludes */; - case 214 /* ArrowFunction */: - return 612179968 /* ArrowFunctionExcludes */; - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - return 746414080 /* FunctionExcludes */; - case 255 /* VariableDeclarationList */: - return 537460736 /* VariableDeclarationListExcludes */; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return 537010176 /* ClassExcludes */; - case 171 /* Constructor */: - return 746405888 /* ConstructorExcludes */; - case 167 /* PropertyDeclaration */: - return 671105024 /* PropertyExcludes */; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return 679297024 /* MethodOrAccessorExcludes */; - case 130 /* AnyKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 143 /* NeverKeyword */: - case 150 /* StringKeyword */: - case 148 /* ObjectKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 114 /* VoidKeyword */: - case 163 /* TypeParameter */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return -2 /* TypeExcludes */; - case 205 /* ObjectLiteralExpression */: - return 537075712 /* ObjectLiteralExcludes */; - case 292 /* CatchClause */: - return 536936448 /* CatchClauseExcludes */; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - return 536903680 /* BindingPatternExcludes */; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - case 350 /* PartiallyEmittedExpression */: - case 212 /* ParenthesizedExpression */: - case 106 /* SuperKeyword */: - return 536870912 /* OuterExpressionExcludes */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: - return 536870912 /* PropertyAccessExcludes */; + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + return -2147450880 /* TransformFlags.ArrayLiteralOrCallOrNewExcludes */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return -1941676032 /* TransformFlags.ModuleExcludes */; + case 164 /* SyntaxKind.Parameter */: + return -2147483648 /* TransformFlags.ParameterExcludes */; + case 214 /* SyntaxKind.ArrowFunction */: + return -2072174592 /* TransformFlags.ArrowFunctionExcludes */; + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return -1937940480 /* TransformFlags.FunctionExcludes */; + case 255 /* SyntaxKind.VariableDeclarationList */: + return -2146893824 /* TransformFlags.VariableDeclarationListExcludes */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return -2147344384 /* TransformFlags.ClassExcludes */; + case 171 /* SyntaxKind.Constructor */: + return -1937948672 /* TransformFlags.ConstructorExcludes */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return -2013249536 /* TransformFlags.PropertyExcludes */; + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return -2005057536 /* TransformFlags.MethodOrAccessorExcludes */; + case 130 /* SyntaxKind.AnyKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 163 /* SyntaxKind.TypeParameter */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return -2 /* TransformFlags.TypeExcludes */; + case 205 /* SyntaxKind.ObjectLiteralExpression */: + return -2147278848 /* TransformFlags.ObjectLiteralExcludes */; + case 292 /* SyntaxKind.CatchClause */: + return -2147418112 /* TransformFlags.CatchClauseExcludes */; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + return -2147450880 /* TransformFlags.BindingPatternExcludes */; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 106 /* SyntaxKind.SuperKeyword */: + return -2147483648 /* TransformFlags.OuterExpressionExcludes */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + return -2147483648 /* TransformFlags.PropertyAccessExcludes */; default: - return 536870912 /* NodeExcludes */; + return -2147483648 /* TransformFlags.NodeExcludes */; } } ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions; var baseFactory = ts.createBaseNodeFactory(); function makeSynthetic(node) { - node.flags |= 8 /* Synthesized */; + node.flags |= 8 /* NodeFlags.Synthesized */; return node; } var syntheticFactory = { @@ -27431,7 +27555,7 @@ var ts; createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); }, createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); }, }; - ts.factory = createNodeFactory(4 /* NoIndentationOnFreshPropertyAccess */, syntheticFactory); + ts.factory = createNodeFactory(4 /* NodeFactoryFlags.NoIndentationOnFreshPropertyAccess */, syntheticFactory); function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) { var stripInternal; var bundleFileInfo; @@ -27494,50 +27618,50 @@ var ts; for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "prologue" /* Prologue */: + case "prologue" /* BundleFileSectionKind.Prologue */: prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section)); break; - case "emitHelpers" /* EmitHelpers */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data)); break; - case "no-default-lib" /* NoDefaultLib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: hasNoDefaultLib = true; break; - case "reference" /* Reference */: + case "reference" /* BundleFileSectionKind.Reference */: referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data }); break; - case "type" /* Type */: + case "type" /* BundleFileSectionKind.Type */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "type-import" /* TypeResolutionModeImport */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.ESNext }); break; - case "type-require" /* TypeResolutionModeRequire */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: typeReferenceDirectives = ts.append(typeReferenceDirectives, { pos: -1, end: -1, fileName: section.data, resolutionMode: ts.ModuleKind.CommonJS }); break; - case "lib" /* Lib */: + case "lib" /* BundleFileSectionKind.Lib */: libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data }); break; - case "prepend" /* Prepend */: + case "prepend" /* BundleFileSectionKind.Prepend */: var prependTexts = void 0; for (var _b = 0, _c = section.texts; _b < _c.length; _b++) { var text = _c[_b]; - if (!stripInternal || text.kind !== "internal" /* Internal */) { - prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* Internal */), text)); + if (!stripInternal || text.kind !== "internal" /* BundleFileSectionKind.Internal */) { + prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal" /* BundleFileSectionKind.Internal */), text)); } } prependChildren = ts.addRange(prependChildren, prependTexts); texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray)); break; - case "internal" /* Internal */: + case "internal" /* BundleFileSectionKind.Internal */: if (stripInternal) { if (!texts) texts = []; break; } // falls through - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; default: ts.Debug.assertNever(section); @@ -27565,22 +27689,22 @@ var ts; for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) { var section = _a[_i]; switch (section.kind) { - case "internal" /* Internal */: - case "text" /* Text */: - texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* Internal */), section)); + case "internal" /* BundleFileSectionKind.Internal */: + case "text" /* BundleFileSectionKind.Text */: + texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal" /* BundleFileSectionKind.Internal */), section)); break; - case "no-default-lib" /* NoDefaultLib */: - case "reference" /* Reference */: - case "type" /* Type */: - case "type-import" /* TypeResolutionModeImport */: - case "type-require" /* TypeResolutionModeRequire */: - case "lib" /* Lib */: + case "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */: + case "reference" /* BundleFileSectionKind.Reference */: + case "type" /* BundleFileSectionKind.Type */: + case "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */: + case "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */: + case "lib" /* BundleFileSectionKind.Lib */: syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section)); break; // Ignore - case "prologue" /* Prologue */: - case "emitHelpers" /* EmitHelpers */: - case "prepend" /* Prepend */: + case "prologue" /* BundleFileSectionKind.Prologue */: + case "emitHelpers" /* BundleFileSectionKind.EmitHelpers */: + case "prepend" /* BundleFileSectionKind.Prepend */: break; default: ts.Debug.assertNever(section); @@ -27608,7 +27732,7 @@ var ts; }; var definedTextGetter_1 = function (path) { var result = textGetter_1(path); - return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n"; + return result !== undefined ? result : "/* Input file ".concat(path, " was missing */\r\n"); }; var buildInfo_1; var getAndCacheBuildInfo_1 = function (getText) { @@ -27677,7 +27801,7 @@ var ts; if (trailingComments) destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) - destEmitNode.flags = flags & ~268435456 /* Immutable */; + destEmitNode.flags = flags & ~268435456 /* EmitFlags.Immutable */; if (commentRange) destEmitNode.commentRange = commentRange; if (sourceMapRange) @@ -27719,7 +27843,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file."); @@ -27728,7 +27852,7 @@ var ts; node.emitNode = {}; } else { - ts.Debug.assert(!(node.emitNode.flags & 268435456 /* Immutable */), "Invalid attempt to mutate an immutable node."); + ts.Debug.assert(!(node.emitNode.flags & 268435456 /* EmitFlags.Immutable */), "Invalid attempt to mutate an immutable node."); } return node.emitNode; } @@ -27760,7 +27884,7 @@ var ts; */ function removeAllComments(node) { var emitNode = getOrCreateEmitNode(node); - emitNode.flags |= 1536 /* NoComments */; + emitNode.flags |= 1536 /* EmitFlags.NoComments */; emitNode.leadingComments = undefined; emitNode.trailingComments = undefined; return node; @@ -27996,7 +28120,7 @@ var ts; ts.setSnippetElement = setSnippetElement; /* @internal */ function ignoreSourceNewlines(node) { - getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; + getOrCreateEmitNode(node).flags |= 134217728 /* EmitFlags.IgnoreSourceNewlines */; return node; } ts.ignoreSourceNewlines = ignoreSourceNewlines; @@ -28019,8 +28143,8 @@ var ts; (function (ts) { function createEmitHelperFactory(context) { var factory = context.factory; - var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* Immutable */); }); - var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* Immutable */); }); + var immutableTrue = ts.memoize(function () { return ts.setEmitFlags(factory.createTrue(), 268435456 /* EmitFlags.Immutable */); }); + var immutableFalse = ts.memoize(function () { return ts.setEmitFlags(factory.createFalse(), 268435456 /* EmitFlags.Immutable */); }); return { getUnscopedHelperName: getUnscopedHelperName, // TypeScript Helpers @@ -28061,7 +28185,7 @@ var ts; * Gets an identifier for the name of an *unscoped* emit helper. */ function getUnscopedHelperName(name) { - return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); + return ts.setEmitFlags(factory.createIdentifier(name), 4096 /* EmitFlags.HelperName */ | 2 /* EmitFlags.AdviseOnEmitNode */); } // TypeScript Helpers function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) { @@ -28096,7 +28220,7 @@ var ts; } // ES2018 Helpers function createAssignHelper(attributesSegments) { - if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } @@ -28112,7 +28236,7 @@ var ts; context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28166,13 +28290,13 @@ var ts; function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, body); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* EmitFlags.AsyncFunctionBody */ | 524288 /* EmitFlags.ReuseTempVariableScope */; return factory.createCallExpression(getUnscopedHelperName("__awaiter"), /*typeArguments*/ undefined, [ hasLexicalThis ? factory.createThis() : factory.createVoidZero(), @@ -28185,7 +28309,7 @@ var ts; function createExtendsHelper(name) { context.requestEmitHelper(ts.extendsHelper); return factory.createCallExpression(getUnscopedHelperName("__extends"), - /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */)]); + /*typeArguments*/ undefined, [name, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)]); } function createTemplateObjectHelper(cooked, raw) { context.requestEmitHelper(ts.templateObjectHelper); @@ -28275,13 +28399,13 @@ var ts; /* @internal */ function compareEmitHelpers(x, y) { if (x === y) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === y.priority) - return 0 /* EqualTo */; + return 0 /* Comparison.EqualTo */; if (x.priority === undefined) - return 1 /* GreaterThan */; + return 1 /* Comparison.GreaterThan */; if (y.priority === undefined) - return -1 /* LessThan */; + return -1 /* Comparison.LessThan */; return ts.compareValues(x.priority, y.priority); } ts.compareEmitHelpers = compareEmitHelpers; @@ -28688,7 +28812,7 @@ var ts; function isCallToHelper(firstSegment, helperName) { return ts.isCallExpression(firstSegment) && ts.isIdentifier(firstSegment.expression) - && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) !== 0 + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* EmitFlags.HelperName */) !== 0 && firstSegment.expression.escapedText === helperName; } ts.isCallToHelper = isCallToHelper; @@ -28697,750 +28821,750 @@ var ts; (function (ts) { // Literals function isNumericLiteral(node) { - return node.kind === 8 /* NumericLiteral */; + return node.kind === 8 /* SyntaxKind.NumericLiteral */; } ts.isNumericLiteral = isNumericLiteral; function isBigIntLiteral(node) { - return node.kind === 9 /* BigIntLiteral */; + return node.kind === 9 /* SyntaxKind.BigIntLiteral */; } ts.isBigIntLiteral = isBigIntLiteral; function isStringLiteral(node) { - return node.kind === 10 /* StringLiteral */; + return node.kind === 10 /* SyntaxKind.StringLiteral */; } ts.isStringLiteral = isStringLiteral; function isJsxText(node) { - return node.kind === 11 /* JsxText */; + return node.kind === 11 /* SyntaxKind.JsxText */; } ts.isJsxText = isJsxText; function isRegularExpressionLiteral(node) { - return node.kind === 13 /* RegularExpressionLiteral */; + return node.kind === 13 /* SyntaxKind.RegularExpressionLiteral */; } ts.isRegularExpressionLiteral = isRegularExpressionLiteral; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 14 /* NoSubstitutionTemplateLiteral */; + return node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; // Pseudo-literals function isTemplateHead(node) { - return node.kind === 15 /* TemplateHead */; + return node.kind === 15 /* SyntaxKind.TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddle(node) { - return node.kind === 16 /* TemplateMiddle */; + return node.kind === 16 /* SyntaxKind.TemplateMiddle */; } ts.isTemplateMiddle = isTemplateMiddle; function isTemplateTail(node) { - return node.kind === 17 /* TemplateTail */; + return node.kind === 17 /* SyntaxKind.TemplateTail */; } ts.isTemplateTail = isTemplateTail; // Punctuation function isDotDotDotToken(node) { - return node.kind === 25 /* DotDotDotToken */; + return node.kind === 25 /* SyntaxKind.DotDotDotToken */; } ts.isDotDotDotToken = isDotDotDotToken; /*@internal*/ function isCommaToken(node) { - return node.kind === 27 /* CommaToken */; + return node.kind === 27 /* SyntaxKind.CommaToken */; } ts.isCommaToken = isCommaToken; function isPlusToken(node) { - return node.kind === 39 /* PlusToken */; + return node.kind === 39 /* SyntaxKind.PlusToken */; } ts.isPlusToken = isPlusToken; function isMinusToken(node) { - return node.kind === 40 /* MinusToken */; + return node.kind === 40 /* SyntaxKind.MinusToken */; } ts.isMinusToken = isMinusToken; function isAsteriskToken(node) { - return node.kind === 41 /* AsteriskToken */; + return node.kind === 41 /* SyntaxKind.AsteriskToken */; } ts.isAsteriskToken = isAsteriskToken; /*@internal*/ function isExclamationToken(node) { - return node.kind === 53 /* ExclamationToken */; + return node.kind === 53 /* SyntaxKind.ExclamationToken */; } ts.isExclamationToken = isExclamationToken; /*@internal*/ function isQuestionToken(node) { - return node.kind === 57 /* QuestionToken */; + return node.kind === 57 /* SyntaxKind.QuestionToken */; } ts.isQuestionToken = isQuestionToken; /*@internal*/ function isColonToken(node) { - return node.kind === 58 /* ColonToken */; + return node.kind === 58 /* SyntaxKind.ColonToken */; } ts.isColonToken = isColonToken; /*@internal*/ function isQuestionDotToken(node) { - return node.kind === 28 /* QuestionDotToken */; + return node.kind === 28 /* SyntaxKind.QuestionDotToken */; } ts.isQuestionDotToken = isQuestionDotToken; /*@internal*/ function isEqualsGreaterThanToken(node) { - return node.kind === 38 /* EqualsGreaterThanToken */; + return node.kind === 38 /* SyntaxKind.EqualsGreaterThanToken */; } ts.isEqualsGreaterThanToken = isEqualsGreaterThanToken; // Identifiers function isIdentifier(node) { - return node.kind === 79 /* Identifier */; + return node.kind === 79 /* SyntaxKind.Identifier */; } ts.isIdentifier = isIdentifier; function isPrivateIdentifier(node) { - return node.kind === 80 /* PrivateIdentifier */; + return node.kind === 80 /* SyntaxKind.PrivateIdentifier */; } ts.isPrivateIdentifier = isPrivateIdentifier; // Reserved Words /* @internal */ function isExportModifier(node) { - return node.kind === 93 /* ExportKeyword */; + return node.kind === 93 /* SyntaxKind.ExportKeyword */; } ts.isExportModifier = isExportModifier; /* @internal */ function isAsyncModifier(node) { - return node.kind === 131 /* AsyncKeyword */; + return node.kind === 131 /* SyntaxKind.AsyncKeyword */; } ts.isAsyncModifier = isAsyncModifier; /* @internal */ function isAssertsKeyword(node) { - return node.kind === 128 /* AssertsKeyword */; + return node.kind === 128 /* SyntaxKind.AssertsKeyword */; } ts.isAssertsKeyword = isAssertsKeyword; /* @internal */ function isAwaitKeyword(node) { - return node.kind === 132 /* AwaitKeyword */; + return node.kind === 132 /* SyntaxKind.AwaitKeyword */; } ts.isAwaitKeyword = isAwaitKeyword; /* @internal */ function isReadonlyKeyword(node) { - return node.kind === 145 /* ReadonlyKeyword */; + return node.kind === 145 /* SyntaxKind.ReadonlyKeyword */; } ts.isReadonlyKeyword = isReadonlyKeyword; /* @internal */ function isStaticModifier(node) { - return node.kind === 124 /* StaticKeyword */; + return node.kind === 124 /* SyntaxKind.StaticKeyword */; } ts.isStaticModifier = isStaticModifier; /* @internal */ function isAbstractModifier(node) { - return node.kind === 126 /* AbstractKeyword */; + return node.kind === 126 /* SyntaxKind.AbstractKeyword */; } ts.isAbstractModifier = isAbstractModifier; /* @internal */ function isOverrideModifier(node) { - return node.kind === 159 /* OverrideKeyword */; + return node.kind === 159 /* SyntaxKind.OverrideKeyword */; } ts.isOverrideModifier = isOverrideModifier; /*@internal*/ function isSuperKeyword(node) { - return node.kind === 106 /* SuperKeyword */; + return node.kind === 106 /* SyntaxKind.SuperKeyword */; } ts.isSuperKeyword = isSuperKeyword; /*@internal*/ function isImportKeyword(node) { - return node.kind === 100 /* ImportKeyword */; + return node.kind === 100 /* SyntaxKind.ImportKeyword */; } ts.isImportKeyword = isImportKeyword; // Names function isQualifiedName(node) { - return node.kind === 161 /* QualifiedName */; + return node.kind === 161 /* SyntaxKind.QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 162 /* ComputedPropertyName */; + return node.kind === 162 /* SyntaxKind.ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 163 /* TypeParameter */; + return node.kind === 163 /* SyntaxKind.TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; // TODO(rbuckton): Rename to 'isParameterDeclaration' function isParameter(node) { - return node.kind === 164 /* Parameter */; + return node.kind === 164 /* SyntaxKind.Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 165 /* Decorator */; + return node.kind === 165 /* SyntaxKind.Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 166 /* PropertySignature */; + return node.kind === 166 /* SyntaxKind.PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 167 /* PropertyDeclaration */; + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 168 /* MethodSignature */; + return node.kind === 168 /* SyntaxKind.MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassStaticBlockDeclaration(node) { - return node.kind === 170 /* ClassStaticBlockDeclaration */; + return node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } ts.isClassStaticBlockDeclaration = isClassStaticBlockDeclaration; function isConstructorDeclaration(node) { - return node.kind === 171 /* Constructor */; + return node.kind === 171 /* SyntaxKind.Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 172 /* GetAccessor */; + return node.kind === 172 /* SyntaxKind.GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 173 /* SetAccessor */; + return node.kind === 173 /* SyntaxKind.SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 174 /* CallSignature */; + return node.kind === 174 /* SyntaxKind.CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 175 /* ConstructSignature */; + return node.kind === 175 /* SyntaxKind.ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 176 /* IndexSignature */; + return node.kind === 176 /* SyntaxKind.IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 177 /* TypePredicate */; + return node.kind === 177 /* SyntaxKind.TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 178 /* TypeReference */; + return node.kind === 178 /* SyntaxKind.TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 179 /* FunctionType */; + return node.kind === 179 /* SyntaxKind.FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 180 /* ConstructorType */; + return node.kind === 180 /* SyntaxKind.ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 181 /* TypeQuery */; + return node.kind === 181 /* SyntaxKind.TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 182 /* TypeLiteral */; + return node.kind === 182 /* SyntaxKind.TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 183 /* ArrayType */; + return node.kind === 183 /* SyntaxKind.ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 184 /* TupleType */; + return node.kind === 184 /* SyntaxKind.TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isNamedTupleMember(node) { - return node.kind === 197 /* NamedTupleMember */; + return node.kind === 197 /* SyntaxKind.NamedTupleMember */; } ts.isNamedTupleMember = isNamedTupleMember; function isOptionalTypeNode(node) { - return node.kind === 185 /* OptionalType */; + return node.kind === 185 /* SyntaxKind.OptionalType */; } ts.isOptionalTypeNode = isOptionalTypeNode; function isRestTypeNode(node) { - return node.kind === 186 /* RestType */; + return node.kind === 186 /* SyntaxKind.RestType */; } ts.isRestTypeNode = isRestTypeNode; function isUnionTypeNode(node) { - return node.kind === 187 /* UnionType */; + return node.kind === 187 /* SyntaxKind.UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 188 /* IntersectionType */; + return node.kind === 188 /* SyntaxKind.IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 189 /* ConditionalType */; + return node.kind === 189 /* SyntaxKind.ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 190 /* InferType */; + return node.kind === 190 /* SyntaxKind.InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 191 /* ParenthesizedType */; + return node.kind === 191 /* SyntaxKind.ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 192 /* ThisType */; + return node.kind === 192 /* SyntaxKind.ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 193 /* TypeOperator */; + return node.kind === 193 /* SyntaxKind.TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 194 /* IndexedAccessType */; + return node.kind === 194 /* SyntaxKind.IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 195 /* MappedType */; + return node.kind === 195 /* SyntaxKind.MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 196 /* LiteralType */; + return node.kind === 196 /* SyntaxKind.LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 200 /* ImportType */; + return node.kind === 200 /* SyntaxKind.ImportType */; } ts.isImportTypeNode = isImportTypeNode; function isTemplateLiteralTypeSpan(node) { - return node.kind === 199 /* TemplateLiteralTypeSpan */; + return node.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */; } ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan; function isTemplateLiteralTypeNode(node) { - return node.kind === 198 /* TemplateLiteralType */; + return node.kind === 198 /* SyntaxKind.TemplateLiteralType */; } ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 201 /* ObjectBindingPattern */; + return node.kind === 201 /* SyntaxKind.ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 202 /* ArrayBindingPattern */; + return node.kind === 202 /* SyntaxKind.ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 203 /* BindingElement */; + return node.kind === 203 /* SyntaxKind.BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 204 /* ArrayLiteralExpression */; + return node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 205 /* ObjectLiteralExpression */; + return node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 206 /* PropertyAccessExpression */; + return node.kind === 206 /* SyntaxKind.PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; function isElementAccessExpression(node) { - return node.kind === 207 /* ElementAccessExpression */; + return node.kind === 207 /* SyntaxKind.ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isCallExpression(node) { - return node.kind === 208 /* CallExpression */; + return node.kind === 208 /* SyntaxKind.CallExpression */; } ts.isCallExpression = isCallExpression; function isNewExpression(node) { - return node.kind === 209 /* NewExpression */; + return node.kind === 209 /* SyntaxKind.NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 210 /* TaggedTemplateExpression */; + return node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertionExpression(node) { - return node.kind === 211 /* TypeAssertionExpression */; + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */; } ts.isTypeAssertionExpression = isTypeAssertionExpression; function isParenthesizedExpression(node) { - return node.kind === 212 /* ParenthesizedExpression */; + return node.kind === 212 /* SyntaxKind.ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function isFunctionExpression(node) { - return node.kind === 213 /* FunctionExpression */; + return node.kind === 213 /* SyntaxKind.FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 214 /* ArrowFunction */; + return node.kind === 214 /* SyntaxKind.ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 215 /* DeleteExpression */; + return node.kind === 215 /* SyntaxKind.DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 216 /* TypeOfExpression */; + return node.kind === 216 /* SyntaxKind.TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 217 /* VoidExpression */; + return node.kind === 217 /* SyntaxKind.VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 218 /* AwaitExpression */; + return node.kind === 218 /* SyntaxKind.AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 219 /* PrefixUnaryExpression */; + return node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 220 /* PostfixUnaryExpression */; + return node.kind === 220 /* SyntaxKind.PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 221 /* BinaryExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 222 /* ConditionalExpression */; + return node.kind === 222 /* SyntaxKind.ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 223 /* TemplateExpression */; + return node.kind === 223 /* SyntaxKind.TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 224 /* YieldExpression */; + return node.kind === 224 /* SyntaxKind.YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 225 /* SpreadElement */; + return node.kind === 225 /* SyntaxKind.SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 226 /* ClassExpression */; + return node.kind === 226 /* SyntaxKind.ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 227 /* OmittedExpression */; + return node.kind === 227 /* SyntaxKind.OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 228 /* ExpressionWithTypeArguments */; + return node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 229 /* AsExpression */; + return node.kind === 229 /* SyntaxKind.AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 230 /* NonNullExpression */; + return node.kind === 230 /* SyntaxKind.NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 231 /* MetaProperty */; + return node.kind === 231 /* SyntaxKind.MetaProperty */; } ts.isMetaProperty = isMetaProperty; function isSyntheticExpression(node) { - return node.kind === 232 /* SyntheticExpression */; + return node.kind === 232 /* SyntaxKind.SyntheticExpression */; } ts.isSyntheticExpression = isSyntheticExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 350 /* PartiallyEmittedExpression */; + return node.kind === 350 /* SyntaxKind.PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isCommaListExpression(node) { - return node.kind === 351 /* CommaListExpression */; + return node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaListExpression = isCommaListExpression; // Misc function isTemplateSpan(node) { - return node.kind === 233 /* TemplateSpan */; + return node.kind === 233 /* SyntaxKind.TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 234 /* SemicolonClassElement */; + return node.kind === 234 /* SyntaxKind.SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Elements function isBlock(node) { - return node.kind === 235 /* Block */; + return node.kind === 235 /* SyntaxKind.Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 237 /* VariableStatement */; + return node.kind === 237 /* SyntaxKind.VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 236 /* EmptyStatement */; + return node.kind === 236 /* SyntaxKind.EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 238 /* ExpressionStatement */; + return node.kind === 238 /* SyntaxKind.ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 239 /* IfStatement */; + return node.kind === 239 /* SyntaxKind.IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 240 /* DoStatement */; + return node.kind === 240 /* SyntaxKind.DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 241 /* WhileStatement */; + return node.kind === 241 /* SyntaxKind.WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 242 /* ForStatement */; + return node.kind === 242 /* SyntaxKind.ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 243 /* ForInStatement */; + return node.kind === 243 /* SyntaxKind.ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 244 /* ForOfStatement */; + return node.kind === 244 /* SyntaxKind.ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 245 /* ContinueStatement */; + return node.kind === 245 /* SyntaxKind.ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 246 /* BreakStatement */; + return node.kind === 246 /* SyntaxKind.BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isReturnStatement(node) { - return node.kind === 247 /* ReturnStatement */; + return node.kind === 247 /* SyntaxKind.ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 248 /* WithStatement */; + return node.kind === 248 /* SyntaxKind.WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 249 /* SwitchStatement */; + return node.kind === 249 /* SyntaxKind.SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 250 /* LabeledStatement */; + return node.kind === 250 /* SyntaxKind.LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 251 /* ThrowStatement */; + return node.kind === 251 /* SyntaxKind.ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 252 /* TryStatement */; + return node.kind === 252 /* SyntaxKind.TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 253 /* DebuggerStatement */; + return node.kind === 253 /* SyntaxKind.DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 254 /* VariableDeclaration */; + return node.kind === 254 /* SyntaxKind.VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 255 /* VariableDeclarationList */; + return node.kind === 255 /* SyntaxKind.VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 256 /* FunctionDeclaration */; + return node.kind === 256 /* SyntaxKind.FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 257 /* ClassDeclaration */; + return node.kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 258 /* InterfaceDeclaration */; + return node.kind === 258 /* SyntaxKind.InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 259 /* TypeAliasDeclaration */; + return node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 260 /* EnumDeclaration */; + return node.kind === 260 /* SyntaxKind.EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 261 /* ModuleDeclaration */; + return node.kind === 261 /* SyntaxKind.ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 262 /* ModuleBlock */; + return node.kind === 262 /* SyntaxKind.ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 263 /* CaseBlock */; + return node.kind === 263 /* SyntaxKind.CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 264 /* NamespaceExportDeclaration */; + return node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */; + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 266 /* ImportDeclaration */; + return node.kind === 266 /* SyntaxKind.ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 267 /* ImportClause */; + return node.kind === 267 /* SyntaxKind.ImportClause */; } ts.isImportClause = isImportClause; function isImportTypeAssertionContainer(node) { - return node.kind === 295 /* ImportTypeAssertionContainer */; + return node.kind === 295 /* SyntaxKind.ImportTypeAssertionContainer */; } ts.isImportTypeAssertionContainer = isImportTypeAssertionContainer; function isAssertClause(node) { - return node.kind === 293 /* AssertClause */; + return node.kind === 293 /* SyntaxKind.AssertClause */; } ts.isAssertClause = isAssertClause; function isAssertEntry(node) { - return node.kind === 294 /* AssertEntry */; + return node.kind === 294 /* SyntaxKind.AssertEntry */; } ts.isAssertEntry = isAssertEntry; function isNamespaceImport(node) { - return node.kind === 268 /* NamespaceImport */; + return node.kind === 268 /* SyntaxKind.NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamespaceExport(node) { - return node.kind === 274 /* NamespaceExport */; + return node.kind === 274 /* SyntaxKind.NamespaceExport */; } ts.isNamespaceExport = isNamespaceExport; function isNamedImports(node) { - return node.kind === 269 /* NamedImports */; + return node.kind === 269 /* SyntaxKind.NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 270 /* ImportSpecifier */; + return node.kind === 270 /* SyntaxKind.ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 271 /* ExportAssignment */; + return node.kind === 271 /* SyntaxKind.ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 272 /* ExportDeclaration */; + return node.kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 273 /* NamedExports */; + return node.kind === 273 /* SyntaxKind.NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 275 /* ExportSpecifier */; + return node.kind === 275 /* SyntaxKind.ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 276 /* MissingDeclaration */; + return node.kind === 276 /* SyntaxKind.MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; function isNotEmittedStatement(node) { - return node.kind === 349 /* NotEmittedStatement */; + return node.kind === 349 /* SyntaxKind.NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 354 /* SyntheticReferenceExpression */; + return node.kind === 354 /* SyntaxKind.SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ function isMergeDeclarationMarker(node) { - return node.kind === 352 /* MergeDeclarationMarker */; + return node.kind === 352 /* SyntaxKind.MergeDeclarationMarker */; } ts.isMergeDeclarationMarker = isMergeDeclarationMarker; /* @internal */ function isEndOfDeclarationMarker(node) { - return node.kind === 353 /* EndOfDeclarationMarker */; + return node.kind === 353 /* SyntaxKind.EndOfDeclarationMarker */; } ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker; // Module References function isExternalModuleReference(node) { - return node.kind === 277 /* ExternalModuleReference */; + return node.kind === 277 /* SyntaxKind.ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 278 /* JsxElement */; + return node.kind === 278 /* SyntaxKind.JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 279 /* JsxSelfClosingElement */; + return node.kind === 279 /* SyntaxKind.JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 280 /* JsxOpeningElement */; + return node.kind === 280 /* SyntaxKind.JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 281 /* JsxClosingElement */; + return node.kind === 281 /* SyntaxKind.JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 282 /* JsxFragment */; + return node.kind === 282 /* SyntaxKind.JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 283 /* JsxOpeningFragment */; + return node.kind === 283 /* SyntaxKind.JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 284 /* JsxClosingFragment */; + return node.kind === 284 /* SyntaxKind.JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 285 /* JsxAttribute */; + return node.kind === 285 /* SyntaxKind.JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 286 /* JsxAttributes */; + return node.kind === 286 /* SyntaxKind.JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 287 /* JsxSpreadAttribute */; + return node.kind === 287 /* SyntaxKind.JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 288 /* JsxExpression */; + return node.kind === 288 /* SyntaxKind.JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 289 /* CaseClause */; + return node.kind === 289 /* SyntaxKind.CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 290 /* DefaultClause */; + return node.kind === 290 /* SyntaxKind.DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 291 /* HeritageClause */; + return node.kind === 291 /* SyntaxKind.HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 292 /* CatchClause */; + return node.kind === 292 /* SyntaxKind.CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 296 /* PropertyAssignment */; + return node.kind === 296 /* SyntaxKind.PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 297 /* ShorthandPropertyAssignment */; + return node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 298 /* SpreadAssignment */; + return node.kind === 298 /* SyntaxKind.SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } ts.isEnumMember = isEnumMember; // Unparsed // TODO(rbuckton): isUnparsedPrologue function isUnparsedPrepend(node) { - return node.kind === 301 /* UnparsedPrepend */; + return node.kind === 301 /* SyntaxKind.UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; // TODO(rbuckton): isUnparsedText @@ -29448,176 +29572,176 @@ var ts; // TODO(rbuckton): isUnparsedSyntheticReference // Top-level nodes function isSourceFile(node) { - return node.kind === 305 /* SourceFile */; + return node.kind === 305 /* SyntaxKind.SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 306 /* Bundle */; + return node.kind === 306 /* SyntaxKind.Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 307 /* UnparsedSource */; + return node.kind === 307 /* SyntaxKind.UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; // TODO(rbuckton): isInputFiles // JSDoc Elements function isJSDocTypeExpression(node) { - return node.kind === 309 /* JSDocTypeExpression */; + return node.kind === 309 /* SyntaxKind.JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocNameReference(node) { - return node.kind === 310 /* JSDocNameReference */; + return node.kind === 310 /* SyntaxKind.JSDocNameReference */; } ts.isJSDocNameReference = isJSDocNameReference; function isJSDocMemberName(node) { - return node.kind === 311 /* JSDocMemberName */; + return node.kind === 311 /* SyntaxKind.JSDocMemberName */; } ts.isJSDocMemberName = isJSDocMemberName; function isJSDocLink(node) { - return node.kind === 324 /* JSDocLink */; + return node.kind === 324 /* SyntaxKind.JSDocLink */; } ts.isJSDocLink = isJSDocLink; function isJSDocLinkCode(node) { - return node.kind === 325 /* JSDocLinkCode */; + return node.kind === 325 /* SyntaxKind.JSDocLinkCode */; } ts.isJSDocLinkCode = isJSDocLinkCode; function isJSDocLinkPlain(node) { - return node.kind === 326 /* JSDocLinkPlain */; + return node.kind === 326 /* SyntaxKind.JSDocLinkPlain */; } ts.isJSDocLinkPlain = isJSDocLinkPlain; function isJSDocAllType(node) { - return node.kind === 312 /* JSDocAllType */; + return node.kind === 312 /* SyntaxKind.JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 313 /* JSDocUnknownType */; + return node.kind === 313 /* SyntaxKind.JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 314 /* JSDocNullableType */; + return node.kind === 314 /* SyntaxKind.JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 315 /* JSDocNonNullableType */; + return node.kind === 315 /* SyntaxKind.JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 316 /* JSDocOptionalType */; + return node.kind === 316 /* SyntaxKind.JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 317 /* JSDocFunctionType */; + return node.kind === 317 /* SyntaxKind.JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 318 /* JSDocVariadicType */; + return node.kind === 318 /* SyntaxKind.JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDocNamepathType(node) { - return node.kind === 319 /* JSDocNamepathType */; + return node.kind === 319 /* SyntaxKind.JSDocNamepathType */; } ts.isJSDocNamepathType = isJSDocNamepathType; function isJSDoc(node) { - return node.kind === 320 /* JSDoc */; + return node.kind === 320 /* SyntaxKind.JSDoc */; } ts.isJSDoc = isJSDoc; function isJSDocTypeLiteral(node) { - return node.kind === 322 /* JSDocTypeLiteral */; + return node.kind === 322 /* SyntaxKind.JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocSignature(node) { - return node.kind === 323 /* JSDocSignature */; + return node.kind === 323 /* SyntaxKind.JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; // JSDoc Tags function isJSDocAugmentsTag(node) { - return node.kind === 328 /* JSDocAugmentsTag */; + return node.kind === 328 /* SyntaxKind.JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocAuthorTag(node) { - return node.kind === 330 /* JSDocAuthorTag */; + return node.kind === 330 /* SyntaxKind.JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocClassTag(node) { - return node.kind === 332 /* JSDocClassTag */; + return node.kind === 332 /* SyntaxKind.JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocCallbackTag(node) { - return node.kind === 338 /* JSDocCallbackTag */; + return node.kind === 338 /* SyntaxKind.JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocPublicTag(node) { - return node.kind === 333 /* JSDocPublicTag */; + return node.kind === 333 /* SyntaxKind.JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 334 /* JSDocPrivateTag */; + return node.kind === 334 /* SyntaxKind.JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 335 /* JSDocProtectedTag */; + return node.kind === 335 /* SyntaxKind.JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 336 /* JSDocReadonlyTag */; + return node.kind === 336 /* SyntaxKind.JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocOverrideTag(node) { - return node.kind === 337 /* JSDocOverrideTag */; + return node.kind === 337 /* SyntaxKind.JSDocOverrideTag */; } ts.isJSDocOverrideTag = isJSDocOverrideTag; function isJSDocDeprecatedTag(node) { - return node.kind === 331 /* JSDocDeprecatedTag */; + return node.kind === 331 /* SyntaxKind.JSDocDeprecatedTag */; } ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag; function isJSDocSeeTag(node) { - return node.kind === 346 /* JSDocSeeTag */; + return node.kind === 346 /* SyntaxKind.JSDocSeeTag */; } ts.isJSDocSeeTag = isJSDocSeeTag; function isJSDocEnumTag(node) { - return node.kind === 339 /* JSDocEnumTag */; + return node.kind === 339 /* SyntaxKind.JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocParameterTag(node) { - return node.kind === 340 /* JSDocParameterTag */; + return node.kind === 340 /* SyntaxKind.JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 341 /* JSDocReturnTag */; + return node.kind === 341 /* SyntaxKind.JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocThisTag(node) { - return node.kind === 342 /* JSDocThisTag */; + return node.kind === 342 /* SyntaxKind.JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocTypeTag(node) { - return node.kind === 343 /* JSDocTypeTag */; + return node.kind === 343 /* SyntaxKind.JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 344 /* JSDocTemplateTag */; + return node.kind === 344 /* SyntaxKind.JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 345 /* JSDocTypedefTag */; + return node.kind === 345 /* SyntaxKind.JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocUnknownTag(node) { - return node.kind === 327 /* JSDocTag */; + return node.kind === 327 /* SyntaxKind.JSDocTag */; } ts.isJSDocUnknownTag = isJSDocUnknownTag; function isJSDocPropertyTag(node) { - return node.kind === 347 /* JSDocPropertyTag */; + return node.kind === 347 /* SyntaxKind.JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocImplementsTag(node) { - return node.kind === 329 /* JSDocImplementsTag */; + return node.kind === 329 /* SyntaxKind.JSDocImplementsTag */; } ts.isJSDocImplementsTag = isJSDocImplementsTag; // Synthesized list /* @internal */ function isSyntaxList(n) { - return n.kind === 348 /* SyntaxList */; + return n.kind === 348 /* SyntaxKind.SyntaxList */; } ts.isSyntaxList = isSyntaxList; })(ts || (ts = {})); @@ -29637,7 +29761,7 @@ var ts; var expression = ts.setTextRange(ts.isMemberName(memberName) ? factory.createPropertyAccessExpression(target, memberName) : factory.createElementAccessExpression(target, memberName), memberName); - ts.getOrCreateEmitNode(expression).flags |= 64 /* NoNestedSourceMaps */; + ts.getOrCreateEmitNode(expression).flags |= 64 /* EmitFlags.NoNestedSourceMaps */; return expression; } } @@ -29816,14 +29940,14 @@ var ts; ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals."); } switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return createExpressionForPropertyAssignment(factory, property, receiver); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(factory, property, receiver); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return createExpressionForMethodDeclaration(factory, property, receiver); } } @@ -29862,7 +29986,7 @@ var ts; */ function expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, recordTempVariable, resultVariable) { var operator = node.operator; - ts.Debug.assert(operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); + ts.Debug.assert(operator === 45 /* SyntaxKind.PlusPlusToken */ || operator === 46 /* SyntaxKind.MinusMinusToken */, "Expected 'node' to be a pre- or post-increment or pre- or post-decrement expression"); var temp = factory.createTempVariable(recordTempVariable); expression = factory.createAssignment(temp, expression); ts.setTextRange(expression, node.operand); @@ -29887,14 +30011,14 @@ var ts; * Gets whether an identifier should only be referred to by its internal name. */ function isInternalName(node) { - return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + return (ts.getEmitFlags(node) & 32768 /* EmitFlags.InternalName */) !== 0; } ts.isInternalName = isInternalName; /** * Gets whether an identifier should only be referred to by its local name. */ function isLocalName(node) { - return (ts.getEmitFlags(node) & 16384 /* LocalName */) !== 0; + return (ts.getEmitFlags(node) & 16384 /* EmitFlags.LocalName */) !== 0; } ts.isLocalName = isLocalName; /** @@ -29902,7 +30026,7 @@ var ts; * name points to an exported symbol. */ function isExportName(node) { - return (ts.getEmitFlags(node) & 8192 /* ExportName */) !== 0; + return (ts.getEmitFlags(node) & 8192 /* EmitFlags.ExportName */) !== 0; } ts.isExportName = isExportName; function isUseStrictPrologue(node) { @@ -29931,8 +30055,8 @@ var ts; } ts.startsWithUseStrict = startsWithUseStrict; function isCommaSequence(node) { - return node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 351 /* CommaListExpression */; + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ || + node.kind === 351 /* SyntaxKind.CommaListExpression */; } ts.isCommaSequence = isCommaSequence; function isJSDocTypeAssertion(node) { @@ -29948,26 +30072,26 @@ var ts; } ts.getJSDocTypeAssertionType = getJSDocTypeAssertionType; function isOuterExpression(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } switch (node.kind) { - case 212 /* ParenthesizedExpression */: - if (kinds & 16 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { + case 212 /* SyntaxKind.ParenthesizedExpression */: + if (kinds & 16 /* OuterExpressionKinds.ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) { return false; } - return (kinds & 1 /* Parentheses */) !== 0; - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: - return (kinds & 2 /* TypeAssertions */) !== 0; - case 230 /* NonNullExpression */: - return (kinds & 4 /* NonNullAssertions */) !== 0; - case 350 /* PartiallyEmittedExpression */: - return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; + return (kinds & 1 /* OuterExpressionKinds.Parentheses */) !== 0; + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: + return (kinds & 2 /* OuterExpressionKinds.TypeAssertions */) !== 0; + case 230 /* SyntaxKind.NonNullExpression */: + return (kinds & 4 /* OuterExpressionKinds.NonNullAssertions */) !== 0; + case 350 /* SyntaxKind.PartiallyEmittedExpression */: + return (kinds & 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */) !== 0; } return false; } ts.isOuterExpression = isOuterExpression; function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 15 /* All */; } + if (kinds === void 0) { kinds = 15 /* OuterExpressionKinds.All */; } while (isOuterExpression(node, kinds)) { node = node.expression; } @@ -29975,7 +30099,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - return skipOuterExpressions(node, 6 /* Assertions */); + return skipOuterExpressions(node, 6 /* OuterExpressionKinds.Assertions */); } ts.skipAssertions = skipAssertions; function startOnNewLine(node) { @@ -30036,7 +30160,7 @@ var ts; var externalHelpersImportDeclaration = nodeFactory.createImportDeclaration( /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText), /*assertClause*/ undefined); - ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(externalHelpersImportDeclaration, 67108864 /* EmitFlags.NeverApplyImportHelper */); return externalHelpersImportDeclaration; } } @@ -30081,10 +30205,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 266 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 266 /* SyntaxKind.ImportDeclaration */ && node.importClause) { return factory.getGeneratedNameForNode(node); } - if (node.kind === 272 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ && node.moduleSpecifier) { return factory.getGeneratedNameForNode(node); } return undefined; @@ -30203,7 +30327,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -30215,11 +30339,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -30251,12 +30375,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 164 /* Parameter */: - case 203 /* BindingElement */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 225 /* SpreadElement */: - case 298 /* SpreadAssignment */: + case 225 /* SyntaxKind.SpreadElement */: + case 298 /* SyntaxKind.SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -30274,7 +30398,7 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -30289,7 +30413,7 @@ var ts; : propertyName; } break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -30304,7 +30428,7 @@ var ts; : propertyName; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: // `a` in `({ ...a } = ...)` if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) { return ts.Debug.failBadSyntaxKind(bindingElement.name); @@ -30319,21 +30443,21 @@ var ts; ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement; function isStringOrNumericLiteral(node) { var kind = node.kind; - return kind === 10 /* StringLiteral */ - || kind === 8 /* NumericLiteral */; + return kind === 10 /* SyntaxKind.StringLiteral */ + || kind === 8 /* SyntaxKind.NumericLiteral */; } /** * Gets the elements of a BindingOrAssignmentPattern */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: - case 204 /* ArrayLiteralExpression */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -30354,86 +30478,86 @@ var ts; ts.getJSDocTypeAliasName = getJSDocTypeAliasName; function canHaveIllegalType(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 173 /* SetAccessor */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.canHaveIllegalType = canHaveIllegalType; function canHaveIllegalTypeParameters(node) { var kind = node.kind; - return kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } ts.canHaveIllegalTypeParameters = canHaveIllegalTypeParameters; function canHaveDecorators(node) { var kind = node.kind; - return kind === 164 /* Parameter */ - || kind === 167 /* PropertyDeclaration */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 226 /* ClassExpression */ - || kind === 257 /* ClassDeclaration */; + return kind === 164 /* SyntaxKind.Parameter */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 257 /* SyntaxKind.ClassDeclaration */; } ts.canHaveDecorators = canHaveDecorators; function canHaveIllegalDecorators(node) { var kind = node.kind; - return kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 256 /* FunctionDeclaration */ - || kind === 171 /* Constructor */ - || kind === 176 /* IndexSignature */ - || kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 276 /* MissingDeclaration */ - || kind === 237 /* VariableStatement */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */ - || kind === 272 /* ExportDeclaration */ - || kind === 271 /* ExportAssignment */; + return kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || kind === 272 /* SyntaxKind.ExportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */; } ts.canHaveIllegalDecorators = canHaveIllegalDecorators; function canHaveModifiers(node) { var kind = node.kind; - return kind === 163 /* TypeParameter */ - || kind === 164 /* Parameter */ - || kind === 166 /* PropertySignature */ - || kind === 167 /* PropertyDeclaration */ - || kind === 168 /* MethodSignature */ - || kind === 169 /* MethodDeclaration */ - || kind === 171 /* Constructor */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 176 /* IndexSignature */ - || kind === 180 /* ConstructorType */ - || kind === 213 /* FunctionExpression */ - || kind === 214 /* ArrowFunction */ - || kind === 226 /* ClassExpression */ - || kind === 237 /* VariableStatement */ - || kind === 256 /* FunctionDeclaration */ - || kind === 257 /* ClassDeclaration */ - || kind === 258 /* InterfaceDeclaration */ - || kind === 259 /* TypeAliasDeclaration */ - || kind === 260 /* EnumDeclaration */ - || kind === 261 /* ModuleDeclaration */ - || kind === 265 /* ImportEqualsDeclaration */ - || kind === 266 /* ImportDeclaration */ - || kind === 271 /* ExportAssignment */ - || kind === 272 /* ExportDeclaration */; + return kind === 163 /* SyntaxKind.TypeParameter */ + || kind === 164 /* SyntaxKind.Parameter */ + || kind === 166 /* SyntaxKind.PropertySignature */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */ + || kind === 168 /* SyntaxKind.MethodSignature */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 176 /* SyntaxKind.IndexSignature */ + || kind === 180 /* SyntaxKind.ConstructorType */ + || kind === 213 /* SyntaxKind.FunctionExpression */ + || kind === 214 /* SyntaxKind.ArrowFunction */ + || kind === 226 /* SyntaxKind.ClassExpression */ + || kind === 237 /* SyntaxKind.VariableStatement */ + || kind === 256 /* SyntaxKind.FunctionDeclaration */ + || kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 258 /* SyntaxKind.InterfaceDeclaration */ + || kind === 259 /* SyntaxKind.TypeAliasDeclaration */ + || kind === 260 /* SyntaxKind.EnumDeclaration */ + || kind === 261 /* SyntaxKind.ModuleDeclaration */ + || kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || kind === 266 /* SyntaxKind.ImportDeclaration */ + || kind === 271 /* SyntaxKind.ExportAssignment */ + || kind === 272 /* SyntaxKind.ExportDeclaration */; } ts.canHaveModifiers = canHaveModifiers; function canHaveIllegalModifiers(node) { var kind = node.kind; - return kind === 170 /* ClassStaticBlockDeclaration */ - || kind === 296 /* PropertyAssignment */ - || kind === 297 /* ShorthandPropertyAssignment */ - || kind === 179 /* FunctionType */ - || kind === 276 /* MissingDeclaration */ - || kind === 264 /* NamespaceExportDeclaration */; + return kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ + || kind === 296 /* SyntaxKind.PropertyAssignment */ + || kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || kind === 179 /* SyntaxKind.FunctionType */ + || kind === 276 /* SyntaxKind.MissingDeclaration */ + || kind === 264 /* SyntaxKind.NamespaceExportDeclaration */; } ts.canHaveIllegalModifiers = canHaveIllegalModifiers; ts.isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration); @@ -30444,68 +30568,68 @@ var ts; ts.isModuleName = ts.or(ts.isIdentifier, ts.isStringLiteral); function isLiteralTypeLikeExpression(node) { var kind = node.kind; - return kind === 104 /* NullKeyword */ - || kind === 110 /* TrueKeyword */ - || kind === 95 /* FalseKeyword */ + return kind === 104 /* SyntaxKind.NullKeyword */ + || kind === 110 /* SyntaxKind.TrueKeyword */ + || kind === 95 /* SyntaxKind.FalseKeyword */ || ts.isLiteralExpression(node) || ts.isPrefixUnaryExpression(node); } ts.isLiteralTypeLikeExpression = isLiteralTypeLikeExpression; function isExponentiationOperator(kind) { - return kind === 42 /* AsteriskAsteriskToken */; + return kind === 42 /* SyntaxKind.AsteriskAsteriskToken */; } function isMultiplicativeOperator(kind) { - return kind === 41 /* AsteriskToken */ - || kind === 43 /* SlashToken */ - || kind === 44 /* PercentToken */; + return kind === 41 /* SyntaxKind.AsteriskToken */ + || kind === 43 /* SyntaxKind.SlashToken */ + || kind === 44 /* SyntaxKind.PercentToken */; } function isMultiplicativeOperatorOrHigher(kind) { return isExponentiationOperator(kind) || isMultiplicativeOperator(kind); } function isAdditiveOperator(kind) { - return kind === 39 /* PlusToken */ - || kind === 40 /* MinusToken */; + return kind === 39 /* SyntaxKind.PlusToken */ + || kind === 40 /* SyntaxKind.MinusToken */; } function isAdditiveOperatorOrHigher(kind) { return isAdditiveOperator(kind) || isMultiplicativeOperatorOrHigher(kind); } function isShiftOperator(kind) { - return kind === 47 /* LessThanLessThanToken */ - || kind === 48 /* GreaterThanGreaterThanToken */ - || kind === 49 /* GreaterThanGreaterThanGreaterThanToken */; + return kind === 47 /* SyntaxKind.LessThanLessThanToken */ + || kind === 48 /* SyntaxKind.GreaterThanGreaterThanToken */ + || kind === 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; } function isShiftOperatorOrHigher(kind) { return isShiftOperator(kind) || isAdditiveOperatorOrHigher(kind); } function isRelationalOperator(kind) { - return kind === 29 /* LessThanToken */ - || kind === 32 /* LessThanEqualsToken */ - || kind === 31 /* GreaterThanToken */ - || kind === 33 /* GreaterThanEqualsToken */ - || kind === 102 /* InstanceOfKeyword */ - || kind === 101 /* InKeyword */; + return kind === 29 /* SyntaxKind.LessThanToken */ + || kind === 32 /* SyntaxKind.LessThanEqualsToken */ + || kind === 31 /* SyntaxKind.GreaterThanToken */ + || kind === 33 /* SyntaxKind.GreaterThanEqualsToken */ + || kind === 102 /* SyntaxKind.InstanceOfKeyword */ + || kind === 101 /* SyntaxKind.InKeyword */; } function isRelationalOperatorOrHigher(kind) { return isRelationalOperator(kind) || isShiftOperatorOrHigher(kind); } function isEqualityOperator(kind) { - return kind === 34 /* EqualsEqualsToken */ - || kind === 36 /* EqualsEqualsEqualsToken */ - || kind === 35 /* ExclamationEqualsToken */ - || kind === 37 /* ExclamationEqualsEqualsToken */; + return kind === 34 /* SyntaxKind.EqualsEqualsToken */ + || kind === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ + || kind === 35 /* SyntaxKind.ExclamationEqualsToken */ + || kind === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; } function isEqualityOperatorOrHigher(kind) { return isEqualityOperator(kind) || isRelationalOperatorOrHigher(kind); } function isBitwiseOperator(kind) { - return kind === 50 /* AmpersandToken */ - || kind === 51 /* BarToken */ - || kind === 52 /* CaretToken */; + return kind === 50 /* SyntaxKind.AmpersandToken */ + || kind === 51 /* SyntaxKind.BarToken */ + || kind === 52 /* SyntaxKind.CaretToken */; } function isBitwiseOperatorOrHigher(kind) { return isBitwiseOperator(kind) @@ -30513,21 +30637,21 @@ var ts; } // NOTE: The version in utilities includes ExclamationToken, which is not a binary operator. function isLogicalOperator(kind) { - return kind === 55 /* AmpersandAmpersandToken */ - || kind === 56 /* BarBarToken */; + return kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ + || kind === 56 /* SyntaxKind.BarBarToken */; } function isLogicalOperatorOrHigher(kind) { return isLogicalOperator(kind) || isBitwiseOperatorOrHigher(kind); } function isAssignmentOperatorOrHigher(kind) { - return kind === 60 /* QuestionQuestionToken */ + return kind === 60 /* SyntaxKind.QuestionQuestionToken */ || isLogicalOperatorOrHigher(kind) || ts.isAssignmentOperator(kind); } function isBinaryOperator(kind) { return isAssignmentOperatorOrHigher(kind) - || kind === 27 /* CommaToken */; + || kind === 27 /* SyntaxKind.CommaToken */; } function isBinaryOperatorToken(node) { return isBinaryOperator(node.kind); @@ -30660,7 +30784,7 @@ var ts; return stackIndex; } function checkCircularity(stackIndex, nodeStack, node) { - if (ts.Debug.shouldAssert(2 /* Aggressive */)) { + if (ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */)) { while (stackIndex >= 0) { ts.Debug.assert(nodeStack[stackIndex] !== node, "Circular traversal detected."); stackIndex--; @@ -30749,7 +30873,7 @@ var ts; createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); }, }; /* @internal */ - ts.parseNodeFactory = ts.createNodeFactory(1 /* NoParenthesizerRules */, ts.parseBaseNodeFactory); + ts.parseNodeFactory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */, ts.parseBaseNodeFactory); function visitNode(cbNode, node) { return node && cbNode(node); } @@ -30769,9 +30893,9 @@ var ts; } /*@internal*/ function isJSDocLikeText(text, start) { - return text.charCodeAt(start + 1) === 42 /* asterisk */ && - text.charCodeAt(start + 2) === 42 /* asterisk */ && - text.charCodeAt(start + 3) !== 47 /* slash */; + return text.charCodeAt(start + 1) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 2) === 42 /* CharacterCodes.asterisk */ && + text.charCodeAt(start + 3) !== 47 /* CharacterCodes.slash */; } ts.isJSDocLikeText = isJSDocLikeText; /*@internal*/ @@ -30783,14 +30907,14 @@ var ts; } ts.isFileProbablyExternalModule = isFileProbablyExternalModule; function isAnExternalModuleIndicatorNode(node) { - return ts.canHaveModifiers(node) && hasModifierOfKind(node, 93 /* ExportKeyword */) + return ts.canHaveModifiers(node) && hasModifierOfKind(node, 93 /* SyntaxKind.ExportKeyword */) || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference) || ts.isImportDeclaration(node) || ts.isExportAssignment(node) || ts.isExportDeclaration(node) ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */ ? walkTreeForImportMeta(sourceFile) : undefined; } @@ -30802,7 +30926,7 @@ var ts; return ts.some(node.modifiers, function (m) { return m.kind === kind; }); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && node.name.escapedText === "meta"; } /** * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes @@ -30818,20 +30942,20 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 160 /* LastToken */) { + if (!node || node.kind <= 160 /* SyntaxKind.LastToken */) { return; } switch (node.kind) { - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30839,67 +30963,67 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitNode(cbNode, node.expression); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.initializer); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || @@ -30909,14 +31033,14 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -30924,21 +31048,21 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -30947,7 +31071,7 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.name) || @@ -30955,357 +31079,357 @@ var ts; visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.body); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.body); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return visitNode(cbNode, node.assertsModifier) || visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return visitNode(cbNode, node.exprName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return visitNode(cbNode, node.elementType); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return visitNodes(cbNode, cbNodes, node.elements); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return visitNode(cbNode, node.typeParameter); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.assertions) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 295 /* ImportTypeAssertionContainer */: + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: return visitNode(cbNode, node.assertClause); - case 191 /* ParenthesizedType */: - case 193 /* TypeOperator */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 193 /* SyntaxKind.TypeOperator */: return visitNode(cbNode, node.type); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.nameType) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNodes(cbNode, cbNodes, node.members); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return visitNode(cbNode, node.literal); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitNode(cbNode, node.expression); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return visitNode(cbNode, node.expression); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitNode(cbNode, node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitNode(cbNode, node.expression); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return visitNode(cbNode, node.expression); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitNode(cbNode, node.name); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitNode(cbNode, node.expression); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitNode(cbNode, node.expression); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitNode(cbNode, node.label); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitNode(cbNode, node.expression); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return visitNode(cbNode, node.expression); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return visitNode(cbNode, node.expression); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return visitNodes(cbNode, cbNodes, node.elements); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.value); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNode(cbNode, node.name); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return visitNode(cbNode, node.name); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return visitNode(cbNode, node.name); - case 269 /* NamedImports */: - case 273 /* NamedExports */: + case 269 /* SyntaxKind.NamedImports */: + case 273 /* SyntaxKind.NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier) || visitNode(cbNode, node.assertClause); - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 185 /* OptionalType */: - case 186 /* RestType */: - case 309 /* JSDocTypeExpression */: - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 316 /* JSDocOptionalType */: - case 318 /* JSDocVariadicType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return visitNode(cbNode, node.type); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) || visitNodes(cbNode, cbNodes, node.tags); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return visitNode(cbNode, node.name); - case 311 /* JSDocMemberName */: + case 311 /* SyntaxKind.JSDocMemberName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || @@ -31314,64 +31438,64 @@ var ts; : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 330 /* JSDocAuthorTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 309 /* JSDocTypeExpression */ + node.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 341 /* JSDocReturnTag */: - case 343 /* JSDocTypeTag */: - case 342 /* JSDocThisTag */: - case 339 /* JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return visitNode(cbNode, node.name); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: - case 331 /* JSDocDeprecatedTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -31420,7 +31544,7 @@ var ts; continue; return res; } - if (current.kind >= 161 /* FirstNode */) { + if (current.kind >= 161 /* SyntaxKind.FirstNode */) { // add children in reverse order to the queue, so popping gives the first child for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) { var child = _a[_i]; @@ -31445,13 +31569,13 @@ var ts; } function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeParse"); var result; ts.perfLogger.logStartParseSourceFile(fileName); var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat; - if (languageVersion === 100 /* JSON */) { - result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop); + if (languageVersion === 100 /* ScriptTarget.JSON */) { + result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* ScriptKind.JSON */, ts.noop); } else { var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) { @@ -31499,7 +31623,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -31527,8 +31651,8 @@ var ts; (function (Parser) { // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. - var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; + var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true); + var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks // tslint:disable variable-name var NodeConstructor; @@ -31550,7 +31674,7 @@ var ts; createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, /*pos*/ 0, /*end*/ 0)); }, createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, /*pos*/ 0, /*end*/ 0)); } }; - var factory = ts.createNodeFactory(1 /* NoParenthesizerRules */ | 2 /* NoNodeConverters */ | 8 /* NoOriginalNode */, baseNodeFactory); + var factory = ts.createNodeFactory(1 /* NodeFactoryFlags.NoParenthesizerRules */ | 2 /* NodeFactoryFlags.NoNodeConverters */ | 8 /* NodeFactoryFlags.NoOriginalNode */, baseNodeFactory); var fileName; var sourceFlags; var sourceText; @@ -31648,7 +31772,7 @@ var ts; var _a; if (setParentNodes === void 0) { setParentNodes = false; } scriptKind = ts.ensureScriptKind(fileName, scriptKind); - if (scriptKind === 6 /* JSON */) { + if (scriptKind === 6 /* ScriptKind.JSON */) { var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes); ts.convertToObjectWorker(result_3, (_a = result_3.statements[0]) === null || _a === void 0 ? void 0 : _a.expression, result_3.parseDiagnostics, /*returnValue*/ false, /*knownRootOptions*/ undefined, /*jsonConversionNotifier*/ undefined); result_3.referencedFiles = ts.emptyArray; @@ -31667,25 +31791,25 @@ var ts; Parser.parseSourceFile = parseSourceFile; function parseIsolatedEntityName(content, languageVersion) { // Choice of `isDeclarationFile` should be arbitrary - initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */); + initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* ScriptKind.JS */); // Prime the scanner. nextToken(); var entityName = parseEntityName(/*allowReservedWords*/ true); - var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length; + var isInvalid = token() === 1 /* SyntaxKind.EndOfFileToken */ && !parseDiagnostics.length; clearState(); return isInvalid ? entityName : undefined; } Parser.parseIsolatedEntityName = parseIsolatedEntityName; function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) { - if (languageVersion === void 0) { languageVersion = 2 /* ES2015 */; } + if (languageVersion === void 0) { languageVersion = 2 /* ScriptTarget.ES2015 */; } if (setParentNodes === void 0) { setParentNodes = false; } - initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* JSON */); + initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6 /* ScriptKind.JSON */); sourceFlags = contextFlags; // Prime the scanner. nextToken(); var pos = getNodePos(); var statements, endOfFileToken; - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { statements = createNodeArray([], pos, pos); endOfFileToken = parseTokenNode(); } @@ -31693,28 +31817,28 @@ var ts; // Loop and synthesize an ArrayLiteralExpression if there are more than // one top-level expressions to ensure all input text is consumed. var expressions = void 0; - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var expression_1 = void 0; switch (token()) { - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: expression_1 = parseArrayLiteralExpression(); break; - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: expression_1 = parseTokenNode(); break; - case 40 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { + case 40 /* SyntaxKind.MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* SyntaxKind.NumericLiteral */ && nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parsePrefixUnaryExpression(); } else { expression_1 = parseObjectLiteralExpression(); } break; - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + if (lookAhead(function () { return nextToken() !== 58 /* SyntaxKind.ColonToken */; })) { expression_1 = parseLiteralNode(); break; } @@ -31732,7 +31856,7 @@ var ts; } else { expressions = expression_1; - if (token() !== 1 /* EndOfFileToken */) { + if (token() !== 1 /* SyntaxKind.EndOfFileToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token); } } @@ -31741,10 +31865,10 @@ var ts; var statement = factory.createExpressionStatement(expression); finishNode(statement, pos); statements = createNodeArray([statement], pos); - endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token); + endOfFileToken = parseExpectedToken(1 /* SyntaxKind.EndOfFileToken */, ts.Diagnostics.Unexpected_token); } // Set source file so that errors will be reported with this file name - var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); + var sourceFile = createSourceFile(fileName, 2 /* ScriptTarget.ES2015 */, 6 /* ScriptKind.JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop); if (setParentNodes) { fixupParentReferences(sourceFile); } @@ -31781,15 +31905,15 @@ var ts; sourceFlags = 0; topLevel = true; switch (scriptKind) { - case 1 /* JS */: - case 2 /* JSX */: - contextFlags = 262144 /* JavaScriptFile */; + case 1 /* ScriptKind.JS */: + case 2 /* ScriptKind.JSX */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */; break; - case 6 /* JSON */: - contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */; + case 6 /* ScriptKind.JSON */: + contextFlags = 262144 /* NodeFlags.JavaScriptFile */ | 67108864 /* NodeFlags.JsonFile */; break; default: - contextFlags = 0 /* None */; + contextFlags = 0 /* NodeFlags.None */; break; } parseErrorBeforeNextFinishedNode = false; @@ -31821,13 +31945,13 @@ var ts; function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 16777216 /* Ambient */; + contextFlags |= 16777216 /* NodeFlags.Ambient */; } sourceFlags = contextFlags; // Prime the scanner. nextToken(); - var statements = parseList(0 /* SourceElements */, parseStatement); - ts.Debug.assert(token() === 1 /* EndOfFileToken */); + var statements = parseList(0 /* ParsingContext.SourceElements */, parseStatement); + ts.Debug.assert(token() === 1 /* SyntaxKind.EndOfFileToken */); var endOfFileToken = addJSDocComment(parseTokenNode()); var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator); // A member of ReadonlyArray isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future @@ -31860,7 +31984,7 @@ var ts; node.jsDoc = jsDoc; if (hasDeprecatedTag) { hasDeprecatedTag = false; - node.flags |= 268435456 /* Deprecated */; + node.flags |= 268435456 /* NodeFlags.Deprecated */; } return node; } @@ -31888,12 +32012,12 @@ var ts; // reparse all statements between start and pos. We skip existing diagnostics for the same range and allow the parser to generate new ones. speculationHelper(function () { var savedContextFlags = contextFlags; - contextFlags |= 32768 /* AwaitContext */; + contextFlags |= 32768 /* NodeFlags.AwaitContext */; scanner.setTextPos(nextStatement.pos); nextToken(); - while (token() !== 1 /* EndOfFileToken */) { + while (token() !== 1 /* SyntaxKind.EndOfFileToken */) { var startPos = scanner.getStartPos(); - var statement = parseListElement(0 /* SourceElements */, parseStatement); + var statement = parseListElement(0 /* ParsingContext.SourceElements */, parseStatement); statements.push(statement); if (startPos === scanner.getStartPos()) { nextToken(); @@ -31911,7 +32035,7 @@ var ts; } } contextFlags = savedContextFlags; - }, 2 /* Reparse */); + }, 2 /* SpeculationKind.Reparse */); // find the next statement containing an `await` start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1; }; @@ -31931,8 +32055,8 @@ var ts; syntaxCursor = savedSyntaxCursor; return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements)); function containsPossibleTopLevelAwait(node) { - return !(node.flags & 32768 /* AwaitContext */) - && !!(node.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */); + return !(node.flags & 32768 /* NodeFlags.AwaitContext */) + && !!(node.transformFlags & 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */); } function findNextStatementWithAwait(statements, start) { for (var i = start; i < statements.length; i++) { @@ -31973,7 +32097,7 @@ var ts; ts.setTextRangePosWidth(sourceFile, 0, sourceText.length); setFields(sourceFile); // If we parsed this as an external module, it may contain top-level await - if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* ContainsPossibleTopLevelAwait */) { + if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */) { sourceFile = reparseTopLevelAwait(sourceFile); setFields(sourceFile); } @@ -32000,16 +32124,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 4096 /* DisallowInContext */); + setContextFlag(val, 4096 /* NodeFlags.DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 8192 /* YieldContext */); + setContextFlag(val, 8192 /* NodeFlags.YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 16384 /* DecoratorContext */); + setContextFlag(val, 16384 /* NodeFlags.DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 32768 /* AwaitContext */); + setContextFlag(val, 32768 /* NodeFlags.AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -32050,52 +32174,52 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(4096 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(4096 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* NodeFlags.DisallowInContext */, func); } function allowConditionalTypesAnd(func) { - return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doOutsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function disallowConditionalTypesAnd(func) { - return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func); + return doInsideOfContext(65536 /* NodeFlags.DisallowConditionalTypesContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(8192 /* YieldContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(16384 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* NodeFlags.DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(32768 /* AwaitContext */, func); + return doInsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(32768 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* NodeFlags.AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doInsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function doOutsideOfYieldAndAwaitContext(func) { - return doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); + return doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(8192 /* YieldContext */); + return inContext(8192 /* NodeFlags.YieldContext */); } function inDisallowInContext() { - return inContext(4096 /* DisallowInContext */); + return inContext(4096 /* NodeFlags.DisallowInContext */); } function inDisallowConditionalTypesContext() { - return inContext(65536 /* DisallowConditionalTypesContext */); + return inContext(65536 /* NodeFlags.DisallowConditionalTypesContext */); } function inDecoratorContext() { - return inContext(16384 /* DecoratorContext */); + return inContext(16384 /* NodeFlags.DecoratorContext */); } function inAwaitContext() { - return inContext(32768 /* AwaitContext */); + return inContext(32768 /* NodeFlags.AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -32196,15 +32320,15 @@ var ts; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the // same. - var result = speculationKind !== 0 /* TryParse */ + var result = speculationKind !== 0 /* SpeculationKind.TryParse */ ? scanner.lookAhead(callback) : scanner.tryScan(callback); ts.Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. - if (!result || speculationKind !== 0 /* TryParse */) { + if (!result || speculationKind !== 0 /* SpeculationKind.TryParse */) { currentToken = saveToken; - if (speculationKind !== 2 /* Reparse */) { + if (speculationKind !== 2 /* SpeculationKind.Reparse */) { parseDiagnostics.length = saveParseDiagnosticsLength; } parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode; @@ -32216,7 +32340,7 @@ var ts; * is returned from this function. */ function lookAhead(callback) { - return speculationHelper(callback, 1 /* Lookahead */); + return speculationHelper(callback, 1 /* SpeculationKind.Lookahead */); } /** Invokes the provided callback. If the callback returns something falsy, then it restores * the parser to the state it was in immediately prior to invoking the callback. If the @@ -32224,31 +32348,31 @@ var ts; * of invoking the callback is returned from this function. */ function tryParse(callback) { - return speculationHelper(callback, 0 /* TryParse */); + return speculationHelper(callback, 0 /* SpeculationKind.TryParse */); } function isBindingIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // `let await`/`let yield` in [Yield] or [Await] are allowed here and disallowed in the binder. - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 79 /* Identifier */) { + if (token() === 79 /* SyntaxKind.Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 125 /* YieldKeyword */ && inYieldContext()) { + if (token() === 125 /* SyntaxKind.YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 132 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 116 /* LastReservedWord */; + return token() > 116 /* SyntaxKind.LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -32286,7 +32410,7 @@ var ts; // Otherwise, if this isn't a well-known keyword-like identifier, give the generic fallback message. var expressionText = ts.isIdentifier(node) ? ts.idText(node) : undefined; if (!expressionText || !ts.isIdentifierText(expressionText, languageVersion)) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } var pos = ts.skipTrivia(sourceText, node.pos); @@ -32301,17 +32425,17 @@ var ts; // If a declared node failed to parse, it would have emitted a diagnostic already. return; case "interface": - parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Interface_name_cannot_be_0, ts.Diagnostics.Interface_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "is": parseErrorAt(pos, scanner.getTextPos(), ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods); return; case "module": case "namespace": - parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* OpenBraceToken */); + parseErrorForInvalidName(ts.Diagnostics.Namespace_name_cannot_be_0, ts.Diagnostics.Namespace_must_be_given_a_name, 18 /* SyntaxKind.OpenBraceToken */); return; case "type": - parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* EqualsToken */); + parseErrorForInvalidName(ts.Diagnostics.Type_alias_name_cannot_be_0, ts.Diagnostics.Type_alias_must_be_given_a_name, 63 /* SyntaxKind.EqualsToken */); return; } // The user alternatively might have misspelled or forgotten to add a space after a common keyword. @@ -32321,7 +32445,7 @@ var ts; return; } // Unknown tokens are handled with their own errors in the scanner - if (token() === 0 /* Unknown */) { + if (token() === 0 /* SyntaxKind.Unknown */) { return; } // Otherwise, we know this some kind of unknown word, not just a missing expected semicolon. @@ -32346,24 +32470,24 @@ var ts; for (var _i = 0, viableKeywordSuggestions_1 = viableKeywordSuggestions; _i < viableKeywordSuggestions_1.length; _i++) { var keyword = viableKeywordSuggestions_1[_i]; if (expressionText.length > keyword.length + 2 && ts.startsWith(expressionText, keyword)) { - return keyword + " " + expressionText.slice(keyword.length); + return "".concat(keyword, " ").concat(expressionText.slice(keyword.length)); } } return undefined; } function parseSemicolonAfterPropertyName(name, type, initializer) { - if (token() === 59 /* AtToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 59 /* SyntaxKind.AtToken */ && !scanner.hasPrecedingLineBreak()) { parseErrorAtCurrentToken(ts.Diagnostics.Decorators_must_precede_the_name_and_all_keywords_of_property_declarations); return; } - if (token() === 20 /* OpenParenToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Cannot_start_a_function_call_in_a_type_annotation); nextToken(); return; } if (type && !canParseSemicolon()) { if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); } else { parseErrorAtCurrentToken(ts.Diagnostics.Expected_for_property_initializer); @@ -32374,7 +32498,7 @@ var ts; return; } if (initializer) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SemicolonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(26 /* SyntaxKind.SemicolonToken */)); return; } parseErrorForMissingSemicolonAfter(name); @@ -32441,24 +32565,24 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 19 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 1 /* SyntaxKind.EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function tryParseSemicolon() { if (!canParseSemicolon()) { return false; } - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } function parseSemicolon() { - return tryParseSemicolon() || parseExpected(26 /* SemicolonToken */); + return tryParseSemicolon() || parseExpected(26 /* SyntaxKind.SemicolonToken */); } function createNodeArray(elements, pos, end, hasTrailingComma) { var array = factory.createNodeArray(elements, hasTrailingComma); @@ -32475,7 +32599,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 131072 /* ThisNodeHasError */; + node.flags |= 131072 /* NodeFlags.ThisNodeHasError */; } return node; } @@ -32487,11 +32611,11 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var pos = getNodePos(); - var result = kind === 79 /* Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : + var result = kind === 79 /* SyntaxKind.Identifier */ ? factory.createIdentifier("", /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined) : ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", /*templateFlags*/ undefined) : - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : - kind === 276 /* MissingDeclaration */ ? factory.createMissingDeclaration() : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral("", /*numericLiteralFlags*/ undefined) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral("", /*isSingleQuote*/ undefined) : + kind === 276 /* SyntaxKind.MissingDeclaration */ ? factory.createMissingDeclaration() : factory.createToken(kind); return finishNode(result, pos); } @@ -32515,23 +32639,23 @@ var ts; nextTokenWithoutCheck(); return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); return createIdentifier(/*isIdentifier*/ true); } - if (token() === 0 /* Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* Identifier */; })) { + if (token() === 0 /* SyntaxKind.Unknown */ && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 79 /* SyntaxKind.Identifier */; })) { // Scanner has already recorded an 'Invalid character' error, so no need to add another from the parser. return createIdentifier(/*isIdentifier*/ true); } identifierCount++; // Only for end of file because the error gets reported incorrectly on embedded script tags. - var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + var reportAtCurrentPosition = token() === 1 /* SyntaxKind.EndOfFileToken */; var isReservedWord = scanner.isReservedWord(); var msgArg = scanner.getTokenText(); var defaultMessage = isReservedWord ? ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : ts.Diagnostics.Identifier_expected; - return createMissingNode(79 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); + return createMissingNode(79 /* SyntaxKind.Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseBindingIdentifier(privateIdentifierDiagnosticMessage) { return createIdentifier(isBindingIdentifier(), /*diagnosticMessage*/ undefined, privateIdentifierDiagnosticMessage); @@ -32544,23 +32668,23 @@ var ts; } function isLiteralPropertyName() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */; } function isAssertionKey() { return ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */; + token() === 10 /* SyntaxKind.StringLiteral */; } function parsePropertyNameWorker(allowComputedPropertyNames) { - if (token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ || token() === 8 /* SyntaxKind.NumericLiteral */) { var node = parseLiteralNode(); node.text = internIdentifier(node.text); return node; } - if (allowComputedPropertyNames && token() === 22 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseComputedPropertyName(); } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { return parsePrivateIdentifier(); } return parseIdentifierName(); @@ -32573,12 +32697,12 @@ var ts; // LiteralPropertyName // ComputedPropertyName[?Yield] var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. var expression = allowInAnd(parseExpression); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createComputedPropertyName(expression), pos); } function internPrivateIdentifier(text) { @@ -32606,23 +32730,23 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 92 /* EnumKeyword */; - case 93 /* ExportKeyword */: + return nextToken() === 92 /* SyntaxKind.EnumKeyword */; + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); - if (token() === 88 /* DefaultKeyword */) { + if (token() === 88 /* SyntaxKind.DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - if (token() === 152 /* TypeKeyword */) { + if (token() === 152 /* SyntaxKind.TypeKeyword */) { return lookAhead(nextTokenCanFollowExportModifier); } return canFollowExportModifier(); - case 88 /* DefaultKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 124 /* StaticKeyword */: - case 136 /* GetKeyword */: - case 149 /* SetKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 136 /* SyntaxKind.GetKeyword */: + case 149 /* SyntaxKind.SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -32630,9 +32754,9 @@ var ts; } } function canFollowExportModifier() { - return token() !== 41 /* AsteriskToken */ - && token() !== 127 /* AsKeyword */ - && token() !== 18 /* OpenBraceToken */ + return token() !== 41 /* SyntaxKind.AsteriskToken */ + && token() !== 127 /* SyntaxKind.AsKeyword */ + && token() !== 18 /* SyntaxKind.OpenBraceToken */ && canFollowModifier(); } function nextTokenCanFollowExportModifier() { @@ -32643,18 +32767,18 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 22 /* OpenBracketToken */ - || token() === 18 /* OpenBraceToken */ - || token() === 41 /* AsteriskToken */ - || token() === 25 /* DotDotDotToken */ + return token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 41 /* SyntaxKind.AsteriskToken */ + || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 84 /* ClassKeyword */ || token() === 98 /* FunctionKeyword */ || - token() === 118 /* InterfaceKeyword */ || - (token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 131 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 84 /* SyntaxKind.ClassKeyword */ || token() === 98 /* SyntaxKind.FunctionKeyword */ || + token() === 118 /* SyntaxKind.InterfaceKeyword */ || + (token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -32663,50 +32787,50 @@ var ts; return true; } switch (parsingContext) { - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: // If we're in error recovery, then we don't want to treat ';' as an empty statement. // The problem is that ';' can show up in far too many contexts, and if we see one // and assume it's a statement, then we may bail out inappropriately from whatever // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); - case 2 /* SwitchClauses */: - return token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 4 /* TypeMembers */: + return !(token() === 26 /* SyntaxKind.SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + case 2 /* ParsingContext.SwitchClauses */: + return token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 4 /* ParsingContext.TypeMembers */: return lookAhead(isTypeMemberStart); - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: // We allow semicolons as class elements (as specified by ES6) as long as we're // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 26 /* SemicolonToken */ && !inErrorRecovery); - case 6 /* EnumMembers */: + return lookAhead(isClassMemberStart) || (token() === 26 /* SyntaxKind.SemicolonToken */ && !inErrorRecovery); + case 6 /* ParsingContext.EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 22 /* OpenBracketToken */ || isLiteralPropertyName(); - case 12 /* ObjectLiteralMembers */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || isLiteralPropertyName(); + case 12 /* ParsingContext.ObjectLiteralMembers */: switch (token()) { - case 22 /* OpenBracketToken */: - case 41 /* AsteriskToken */: - case 25 /* DotDotDotToken */: - case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) + case 22 /* SyntaxKind.OpenBracketToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 24 /* SyntaxKind.DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; default: return isLiteralPropertyName(); } - case 18 /* RestProperties */: + case 18 /* ParsingContext.RestProperties */: return isLiteralPropertyName(); - case 9 /* ObjectBindingElements */: - return token() === 22 /* OpenBracketToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); - case 24 /* AssertEntries */: + case 9 /* ParsingContext.ObjectBindingElements */: + return token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isLiteralPropertyName(); + case 24 /* ParsingContext.AssertEntries */: return isAssertionKey(); - case 7 /* HeritageClauseElement */: + case 7 /* ParsingContext.HeritageClauseElement */: // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -32718,42 +32842,42 @@ var ts; // element during recovery. return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword(); } - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 10 /* ArrayBindingElements */: - return token() === 27 /* CommaToken */ || token() === 25 /* DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); - case 19 /* TypeParameters */: - return token() === 101 /* InKeyword */ || isIdentifier(); - case 15 /* ArrayLiteralMembers */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern(); + case 19 /* ParsingContext.TypeParameters */: + return token() === 101 /* SyntaxKind.InKeyword */ || isIdentifier(); + case 15 /* ParsingContext.ArrayLiteralMembers */: switch (token()) { - case 27 /* CommaToken */: - case 24 /* DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) + case 27 /* SyntaxKind.CommaToken */: + case 24 /* SyntaxKind.DotToken */: // Not an array literal member, but don't want to close the array (see `tests/cases/fourslash/completionsDotInArrayLiteralInObjectLiteral.ts`) return true; } // falls through - case 11 /* ArgumentExpressions */: - return token() === 25 /* DotDotDotToken */ || isStartOfExpression(); - case 16 /* Parameters */: + case 11 /* ParsingContext.ArgumentExpressions */: + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isStartOfExpression(); + case 16 /* ParsingContext.Parameters */: return isStartOfParameter(/*isJSDocParameter*/ false); - case 17 /* JSDocParameters */: + case 17 /* ParsingContext.JSDocParameters */: return isStartOfParameter(/*isJSDocParameter*/ true); - case 20 /* TypeArguments */: - case 21 /* TupleElementTypes */: - return token() === 27 /* CommaToken */ || isStartOfType(); - case 22 /* HeritageClauses */: + case 20 /* ParsingContext.TypeArguments */: + case 21 /* ParsingContext.TupleElementTypes */: + return token() === 27 /* SyntaxKind.CommaToken */ || isStartOfType(); + case 22 /* ParsingContext.HeritageClauses */: return isHeritageClause(); - case 23 /* ImportOrExportSpecifiers */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); - case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* OpenBraceToken */; - case 14 /* JsxChildren */: + case 13 /* ParsingContext.JsxAttributes */: + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18 /* SyntaxKind.OpenBraceToken */; + case 14 /* ParsingContext.JsxChildren */: return true; } return ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 18 /* OpenBraceToken */); - if (nextToken() === 19 /* CloseBraceToken */) { + ts.Debug.assert(token() === 18 /* SyntaxKind.OpenBraceToken */); + if (nextToken() === 19 /* SyntaxKind.CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -32762,7 +32886,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 94 /* ExtendsKeyword */ || next === 117 /* ImplementsKeyword */; + return next === 27 /* SyntaxKind.CommaToken */ || next === 18 /* SyntaxKind.OpenBraceToken */ || next === 94 /* SyntaxKind.ExtendsKeyword */ || next === 117 /* SyntaxKind.ImplementsKeyword */; } return true; } @@ -32779,8 +32903,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 117 /* ImplementsKeyword */ || - token() === 94 /* ExtendsKeyword */) { + if (token() === 117 /* SyntaxKind.ImplementsKeyword */ || + token() === 94 /* SyntaxKind.ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -32795,51 +32919,51 @@ var ts; } // True if positioned at a list terminator function isListTerminator(kind) { - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { // Being at the end of the file ends all lists. return true; } switch (kind) { - case 1 /* BlockStatements */: - case 2 /* SwitchClauses */: - case 4 /* TypeMembers */: - case 5 /* ClassMembers */: - case 6 /* EnumMembers */: - case 12 /* ObjectLiteralMembers */: - case 9 /* ObjectBindingElements */: - case 23 /* ImportOrExportSpecifiers */: - case 24 /* AssertEntries */: - return token() === 19 /* CloseBraceToken */; - case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 82 /* CaseKeyword */ || token() === 88 /* DefaultKeyword */; - case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: + case 2 /* ParsingContext.SwitchClauses */: + case 4 /* ParsingContext.TypeMembers */: + case 5 /* ParsingContext.ClassMembers */: + case 6 /* ParsingContext.EnumMembers */: + case 12 /* ParsingContext.ObjectLiteralMembers */: + case 9 /* ParsingContext.ObjectBindingElements */: + case 23 /* ParsingContext.ImportOrExportSpecifiers */: + case 24 /* ParsingContext.AssertEntries */: + return token() === 19 /* SyntaxKind.CloseBraceToken */; + case 3 /* ParsingContext.SwitchClauseStatements */: + return token() === 19 /* SyntaxKind.CloseBraceToken */ || token() === 82 /* SyntaxKind.CaseKeyword */ || token() === 88 /* SyntaxKind.DefaultKeyword */; + case 7 /* ParsingContext.HeritageClauseElement */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 8 /* ParsingContext.VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 19 /* TypeParameters */: + case 19 /* ParsingContext.TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; - case 11 /* ArgumentExpressions */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; + case 11 /* ParsingContext.ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; - case 15 /* ArrayLiteralMembers */: - case 21 /* TupleElementTypes */: - case 10 /* ArrayBindingElements */: - return token() === 23 /* CloseBracketToken */; - case 17 /* JSDocParameters */: - case 16 /* Parameters */: - case 18 /* RestProperties */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 26 /* SyntaxKind.SemicolonToken */; + case 15 /* ParsingContext.ArrayLiteralMembers */: + case 21 /* ParsingContext.TupleElementTypes */: + case 10 /* ParsingContext.ArrayBindingElements */: + return token() === 23 /* SyntaxKind.CloseBracketToken */; + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: + case 18 /* ParsingContext.RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 21 /* CloseParenToken */ || token() === 23 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 20 /* TypeArguments */: + return token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + case 20 /* ParsingContext.TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 27 /* CommaToken */; - case 22 /* HeritageClauses */: - return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; - case 13 /* JsxAttributes */: - return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; - case 14 /* JsxChildren */: - return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() !== 27 /* SyntaxKind.CommaToken */; + case 22 /* ParsingContext.HeritageClauses */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 19 /* SyntaxKind.CloseBraceToken */; + case 13 /* ParsingContext.JsxAttributes */: + return token() === 31 /* SyntaxKind.GreaterThanToken */ || token() === 43 /* SyntaxKind.SlashToken */; + case 14 /* ParsingContext.JsxChildren */: + return token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -32859,7 +32983,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -32867,7 +32991,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 25 /* Count */; kind++) { + for (var kind = 0; kind < 25 /* ParsingContext.Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, /*inErrorRecovery*/ true) || isListTerminator(kind)) { return true; @@ -32901,7 +33025,7 @@ var ts; } return parseElement(); } - function currentNode(parsingContext) { + function currentNode(parsingContext, pos) { // If we don't have a cursor or the parsing context isn't reusable, there's nothing to reuse. // // If there is an outstanding parse error that we've encountered, but not attached to @@ -32914,7 +33038,7 @@ var ts; if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) { return undefined; } - var node = syntaxCursor.currentNode(scanner.getStartPos()); + var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos()); // Can't reuse a missing node. // Can't reuse a node that intersected the change range. // Can't reuse a node that contains a parse error. This is necessary so that we @@ -32933,7 +33057,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 50720768 /* ContextFlags */; + var nodeContextFlags = node.flags & 50720768 /* NodeFlags.ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -32956,38 +33080,38 @@ var ts; } function isReusableParsingContext(parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: - case 2 /* SwitchClauses */: - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: - case 6 /* EnumMembers */: - case 4 /* TypeMembers */: - case 8 /* VariableDeclarations */: - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 5 /* ParsingContext.ClassMembers */: + case 2 /* ParsingContext.SwitchClauses */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: + case 6 /* ParsingContext.EnumMembers */: + case 4 /* ParsingContext.TypeMembers */: + case 8 /* ParsingContext.VariableDeclarations */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return true; } return false; } function canReuseNode(node, parsingContext) { switch (parsingContext) { - case 5 /* ClassMembers */: + case 5 /* ParsingContext.ClassMembers */: return isReusableClassMember(node); - case 2 /* SwitchClauses */: + case 2 /* ParsingContext.SwitchClauses */: return isReusableSwitchClause(node); - case 0 /* SourceElements */: - case 1 /* BlockStatements */: - case 3 /* SwitchClauseStatements */: + case 0 /* ParsingContext.SourceElements */: + case 1 /* ParsingContext.BlockStatements */: + case 3 /* ParsingContext.SwitchClauseStatements */: return isReusableStatement(node); - case 6 /* EnumMembers */: + case 6 /* ParsingContext.EnumMembers */: return isReusableEnumMember(node); - case 4 /* TypeMembers */: + case 4 /* ParsingContext.TypeMembers */: return isReusableTypeMember(node); - case 8 /* VariableDeclarations */: + case 8 /* ParsingContext.VariableDeclarations */: return isReusableVariableDeclaration(node); - case 17 /* JSDocParameters */: - case 16 /* Parameters */: + case 17 /* ParsingContext.JSDocParameters */: + case 16 /* ParsingContext.Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative @@ -33034,20 +33158,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 171 /* Constructor */: - case 176 /* IndexSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 234 /* SemicolonClassElement */: + case 171 /* SyntaxKind.Constructor */: + case 176 /* SyntaxKind.IndexSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 234 /* SyntaxKind.SemicolonClassElement */: return true; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 79 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 134 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ && + methodDeclaration.name.originalKeywordKind === 134 /* SyntaxKind.ConstructorKeyword */; return !nameIsConstructor; } } @@ -33056,8 +33180,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: return true; } } @@ -33066,58 +33190,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 237 /* VariableStatement */: - case 235 /* Block */: - case 239 /* IfStatement */: - case 238 /* ExpressionStatement */: - case 251 /* ThrowStatement */: - case 247 /* ReturnStatement */: - case 249 /* SwitchStatement */: - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 242 /* ForStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 236 /* EmptyStatement */: - case 252 /* TryStatement */: - case 250 /* LabeledStatement */: - case 240 /* DoStatement */: - case 253 /* DebuggerStatement */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 235 /* SyntaxKind.Block */: + case 239 /* SyntaxKind.IfStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: + case 251 /* SyntaxKind.ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 249 /* SyntaxKind.SwitchStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 252 /* SyntaxKind.TryStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 299 /* EnumMember */; + return node.kind === 299 /* SyntaxKind.EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 166 /* PropertySignature */: - case 174 /* CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 166 /* SyntaxKind.PropertySignature */: + case 174 /* SyntaxKind.CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 254 /* VariableDeclaration */) { + if (node.kind !== 254 /* SyntaxKind.VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -33138,7 +33262,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 164 /* Parameter */) { + if (node.kind !== 164 /* SyntaxKind.Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -33156,40 +33280,42 @@ var ts; } function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return token() === 88 /* DefaultKeyword */ - ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* ExportKeyword */)) + case 0 /* ParsingContext.SourceElements */: + return token() === 88 /* SyntaxKind.DefaultKeyword */ + ? parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(93 /* SyntaxKind.ExportKeyword */)) : parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 1 /* BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); - case 2 /* SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); - case 3 /* SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); - case 18 /* RestProperties */: // fallthrough - case 4 /* TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); - case 5 /* ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); - case 6 /* EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); - case 7 /* HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); - case 8 /* VariableDeclarations */: + case 1 /* ParsingContext.BlockStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected); + case 2 /* ParsingContext.SwitchClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected); + case 3 /* ParsingContext.SwitchClauseStatements */: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected); + case 18 /* ParsingContext.RestProperties */: // fallthrough + case 4 /* ParsingContext.TypeMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected); + case 5 /* ParsingContext.ClassMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected); + case 6 /* ParsingContext.EnumMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected); + case 7 /* ParsingContext.HeritageClauseElement */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected); + case 8 /* ParsingContext.VariableDeclarations */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected); - case 9 /* ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); - case 10 /* ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); - case 11 /* ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); - case 12 /* ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); - case 15 /* ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); - case 17 /* JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 16 /* Parameters */: + case 9 /* ParsingContext.ObjectBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected); + case 10 /* ParsingContext.ArrayBindingElements */: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected); + case 11 /* ParsingContext.ArgumentExpressions */: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected); + case 12 /* ParsingContext.ObjectLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected); + case 15 /* ParsingContext.ArrayLiteralMembers */: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected); + case 17 /* ParsingContext.JSDocParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); + case 16 /* ParsingContext.Parameters */: return ts.isKeyword(token()) ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_parameter_name, ts.tokenToString(token())) : parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected); - case 19 /* TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); - case 20 /* TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); - case 21 /* TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); - case 22 /* HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); - case 23 /* ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 13 /* JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - case 14 /* JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); - default: return [undefined]; // TODO: GH#18217 `default: Debug.assertNever(context);` + case 19 /* ParsingContext.TypeParameters */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected); + case 20 /* ParsingContext.TypeArguments */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected); + case 21 /* ParsingContext.TupleElementTypes */: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected); + case 22 /* ParsingContext.HeritageClauses */: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected); + case 23 /* ParsingContext.ImportOrExportSpecifiers */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 13 /* ParsingContext.JsxAttributes */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 14 /* ParsingContext.JsxChildren */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected); + case 24 /* ParsingContext.AssertEntries */: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_or_string_literal_expected); // AssertionKey. + case 25 /* ParsingContext.Count */: return ts.Debug.fail("ParsingContext.Count used as a context"); // Not a real context, only a marker. + default: ts.Debug.assertNever(context); } } function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { @@ -33208,7 +33334,7 @@ var ts; } list.push(result); commaStart = scanner.getTokenPos(); - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma continue; } @@ -33218,13 +33344,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); + parseExpected(27 /* SyntaxKind.CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 26 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 26 /* SyntaxKind.SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } if (startPos === scanner.getStartPos()) { @@ -33253,7 +33379,7 @@ var ts; return createNodeArray(list, listPos, /*end*/ undefined, commaStart >= 0); } function getExpectedCommaDiagnostic(kind) { - return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + return kind === 6 /* ParsingContext.EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; } function createMissingList() { var list = createNodeArray([], getNodePos()); @@ -33275,8 +33401,8 @@ var ts; var pos = getNodePos(); var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = getNodePos(); - while (parseOptional(24 /* DotToken */)) { - if (token() === 29 /* LessThanToken */) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -33315,12 +33441,12 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } - if (token() === 80 /* PrivateIdentifier */) { + if (token() === 80 /* SyntaxKind.PrivateIdentifier */) { var node = parsePrivateIdentifier(); - return allowPrivateIdentifiers ? node : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return allowPrivateIdentifiers ? node : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } @@ -33331,7 +33457,7 @@ var ts; do { node = parseTemplateSpan(isTaggedTemplate); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateExpression(isTaggedTemplate) { @@ -33349,7 +33475,7 @@ var ts; do { node = parseTemplateTypeSpan(); list.push(node); - } while (node.literal.kind === 16 /* TemplateMiddle */); + } while (node.literal.kind === 16 /* SyntaxKind.TemplateMiddle */); return createNodeArray(list, pos); } function parseTemplateTypeSpan() { @@ -33357,13 +33483,13 @@ var ts; return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(/*isTaggedTemplate*/ false)), pos); } function parseLiteralOfTemplateSpan(isTaggedTemplate) { - if (token() === 19 /* CloseBraceToken */) { + if (token() === 19 /* SyntaxKind.CloseBraceToken */) { reScanTemplateToken(isTaggedTemplate); return parseTemplateMiddleOrTemplateTail(); } else { // TODO(rbuckton): Do we need to call `parseExpectedToken` or can we just call `createMissingNode` directly? - return parseExpectedToken(17 /* TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* CloseBraceToken */)); + return parseExpectedToken(17 /* SyntaxKind.TemplateTail */, ts.Diagnostics._0_expected, ts.tokenToString(19 /* SyntaxKind.CloseBraceToken */)); } } function parseTemplateSpan(isTaggedTemplate) { @@ -33378,30 +33504,30 @@ var ts; reScanTemplateHeadOrNoSubstitutionTemplate(); } var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* SyntaxKind.TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token()); - ts.Debug.assert(fragment.kind === 16 /* TemplateMiddle */ || fragment.kind === 17 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 16 /* SyntaxKind.TemplateMiddle */ || fragment.kind === 17 /* SyntaxKind.TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function getTemplateLiteralRawText(kind) { - var isLast = kind === 14 /* NoSubstitutionTemplateLiteral */ || kind === 17 /* TemplateTail */; + var isLast = kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || kind === 17 /* SyntaxKind.TemplateTail */; var tokenText = scanner.getTokenText(); return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2)); } function parseLiteralLikeNode(kind) { var pos = getNodePos(); - var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TemplateLiteralLikeFlags */) : + var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048 /* TokenFlags.TemplateLiteralLikeFlags */) : // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal. But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - kind === 8 /* NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : - kind === 10 /* StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : + kind === 8 /* SyntaxKind.NumericLiteral */ ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) : + kind === 10 /* SyntaxKind.StringLiteral */ ? factory.createStringLiteral(scanner.getTokenValue(), /*isSingleQuote*/ undefined, scanner.hasExtendedUnicodeEscape()) : ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) : ts.Debug.fail(); if (scanner.hasExtendedUnicodeEscape()) { @@ -33418,8 +33544,8 @@ var ts; return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } function parseTypeArgumentsOfTypeReference() { - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { - return parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function parseTypeReference() { @@ -33429,14 +33555,14 @@ var ts; // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return ts.nodeIsMissing(node.typeName); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: { + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -33474,12 +33600,12 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 27 /* CommaToken */ || - token() === 19 /* CloseBraceToken */ || - token() === 21 /* CloseParenToken */ || - token() === 31 /* GreaterThanToken */ || - token() === 63 /* EqualsToken */ || - token() === 51 /* BarToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */ || + token() === 19 /* SyntaxKind.CloseBraceToken */ || + token() === 21 /* SyntaxKind.CloseParenToken */ || + token() === 31 /* SyntaxKind.GreaterThanToken */ || + token() === 63 /* SyntaxKind.EqualsToken */ || + token() === 51 /* SyntaxKind.BarToken */) { return finishNode(factory.createJSDocUnknownType(), pos); } else { @@ -33491,8 +33617,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); if (lookAhead(nextTokenIsOpenParen)) { nextToken(); - var parameters = parseParameters(4 /* Type */ | 32 /* JSDoc */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */ | 32 /* SignatureFlags.JSDoc */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc); } return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), /*typeArguments*/ undefined), pos); @@ -33500,9 +33626,9 @@ var ts; function parseJSDocParameter() { var pos = getNodePos(); var name; - if (token() === 108 /* ThisKeyword */ || token() === 103 /* NewKeyword */) { + if (token() === 108 /* SyntaxKind.ThisKeyword */ || token() === 103 /* SyntaxKind.NewKeyword */) { name = parseIdentifierName(); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); } return finishNode(factory.createParameterDeclaration( /*modifiers*/ undefined, @@ -33515,15 +33641,15 @@ var ts; function parseJSDocType() { scanner.setInJSDocType(true); var pos = getNodePos(); - if (parseOptional(141 /* ModuleKeyword */)) { + if (parseOptional(141 /* SyntaxKind.ModuleKeyword */)) { // TODO(rbuckton): We never set the type for a JSDocNamepathType. What should we put here? var moduleTag = factory.createJSDocNamepathType(/*type*/ undefined); terminate: while (true) { switch (token()) { - case 19 /* CloseBraceToken */: - case 1 /* EndOfFileToken */: - case 27 /* CommaToken */: - case 5 /* WhitespaceTrivia */: + case 19 /* SyntaxKind.CloseBraceToken */: + case 1 /* SyntaxKind.EndOfFileToken */: + case 27 /* SyntaxKind.CommaToken */: + case 5 /* SyntaxKind.WhitespaceTrivia */: break terminate; default: nextTokenJSDoc(); @@ -33532,13 +33658,13 @@ var ts; scanner.setInJSDocType(false); return finishNode(moduleTag, pos); } - var hasDotDotDot = parseOptional(25 /* DotDotDotToken */); + var hasDotDotDot = parseOptional(25 /* SyntaxKind.DotDotDotToken */); var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (hasDotDotDot) { type = finishNode(factory.createJSDocVariadicType(type), pos); } - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { nextToken(); return finishNode(factory.createJSDocOptionalType(type), pos); } @@ -33546,7 +33672,7 @@ var ts; } function parseTypeQuery() { var pos = getNodePos(); - parseExpected(112 /* TypeOfKeyword */); + parseExpected(112 /* SyntaxKind.TypeOfKeyword */); var entityName = parseEntityName(/*allowReservedWords*/ true); // Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression. var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined; @@ -33558,7 +33684,7 @@ var ts; var name = parseIdentifier(); var constraint; var expression; - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -33577,21 +33703,21 @@ var ts; expression = parseUnaryExpressionOrHigher(); } } - var defaultType = parseOptional(63 /* EqualsToken */) ? parseType() : undefined; + var defaultType = parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseType() : undefined; var node = factory.createTypeParameterDeclaration(modifiers, name, constraint, defaultType); node.expression = expression; return finishNode(node, pos); } function parseTypeParameters() { - if (token() === 29 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); + if (token() === 29 /* SyntaxKind.LessThanToken */) { + return parseBracketedList(19 /* ParsingContext.TypeParameters */, parseTypeParameter, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */); } } function isStartOfParameter(isJSDocParameter) { - return token() === 25 /* DotDotDotToken */ || + return token() === 25 /* SyntaxKind.DotDotDotToken */ || isBindingIdentifierOrPrivateIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 59 /* AtToken */ || + token() === 59 /* SyntaxKind.AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseNameOfParameter(modifiers) { @@ -33615,7 +33741,7 @@ var ts; // Be permissive about await and yield by calling isBindingIdentifier instead of isIdentifier; disallowing // them during a speculative parse leads to many more follow-on errors than allowing the function to parse then later // complaining about the use of the keywords. - return isBindingIdentifier() || token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */; + return isBindingIdentifier() || token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function parseParameter(inOuterAwaitContext) { return parseParameterWorker(inOuterAwaitContext); @@ -33630,8 +33756,8 @@ var ts; // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] // Decorators are parsed in the outer [Await] context, the rest of the parameter is parsed in the function's [Await] context. - var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators(); - if (token() === 108 /* ThisKeyword */) { + var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : doOutsideOfAwaitContext(parseDecorators); + if (token() === 108 /* SyntaxKind.ThisKeyword */) { var node_1 = factory.createParameterDeclaration(decorators, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, parseTypeAnnotation(), @@ -33644,11 +33770,11 @@ var ts; var savedTopLevel = topLevel; topLevel = false; var modifiers = combineDecoratorsAndModifiers(decorators, parseModifiers()); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); if (!allowAmbiguity && !isParameterNameStart()) { return undefined; } - var node = withJSDoc(finishNode(factory.createParameterDeclaration(modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); + var node = withJSDoc(finishNode(factory.createParameterDeclaration(modifiers, dotDotDotToken, parseNameOfParameter(modifiers), parseOptionalToken(57 /* SyntaxKind.QuestionToken */), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc); topLevel = savedTopLevel; return node; } @@ -33658,16 +33784,16 @@ var ts; } } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 38 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* SyntaxKind.EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(58 /* ColonToken */)) { + else if (parseOptional(58 /* SyntaxKind.ColonToken */)) { return true; } - else if (isType && token() === 38 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */)); nextToken(); return true; } @@ -33689,11 +33815,11 @@ var ts; // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); - setYieldContext(!!(flags & 1 /* Yield */)); - setAwaitContext(!!(flags & 2 /* Await */)); - var parameters = flags & 32 /* JSDoc */ ? - parseDelimitedList(17 /* JSDocParameters */, parseJSDocParameter) : - parseDelimitedList(16 /* Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); + var parameters = flags & 32 /* SignatureFlags.JSDoc */ ? + parseDelimitedList(17 /* ParsingContext.JSDocParameters */, parseJSDocParameter) : + parseDelimitedList(16 /* ParsingContext.Parameters */, function () { return allowAmbiguity ? parseParameter(savedAwaitContext) : parseParameterForSpeculation(savedAwaitContext); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); return parameters; @@ -33712,17 +33838,17 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { return createMissingList(); } var parameters = parseParametersWorker(flags, /*allowAmbiguity*/ true); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return parameters; } function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -33731,20 +33857,20 @@ var ts; function parseSignatureMember(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (kind === 175 /* ConstructSignature */) { - parseExpected(103 /* NewKeyword */); + if (kind === 175 /* SyntaxKind.ConstructSignature */) { + parseExpected(103 /* SyntaxKind.NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); parseTypeMemberSemicolon(); - var node = kind === 174 /* CallSignature */ + var node = kind === 174 /* SyntaxKind.CallSignature */ ? factory.createCallSignature(typeParameters, parameters, type) : factory.createConstructSignature(typeParameters, parameters, type); return withJSDoc(finishNode(node, pos), hasJSDoc); } function isIndexSignature() { - return token() === 22 /* OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); + return token() === 22 /* SyntaxKind.OpenBracketToken */ && lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { // The only allowed sequence is: @@ -33764,7 +33890,7 @@ var ts; // [] // nextToken(); - if (token() === 25 /* DotDotDotToken */ || token() === 23 /* CloseBracketToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -33783,21 +33909,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 57 /* QuestionToken */) { + if (token() !== 57 /* SyntaxKind.QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 23 /* SyntaxKind.CloseBracketToken */; } function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) { - var parameters = parseBracketedList(16 /* Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); + var parameters = parseBracketedList(16 /* ParsingContext.Parameters */, function () { return parseParameter(/*inOuterAwaitContext*/ false); }, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */); var type = parseTypeAnnotation(); parseTypeMemberSemicolon(); var node = factory.createIndexSignature(modifiers, parameters, type); @@ -33806,14 +33932,14 @@ var ts; } function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); var node; - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ true); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ true); node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type); } else { @@ -33822,7 +33948,7 @@ var ts; // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === 63 /* EqualsToken */) + if (token() === 63 /* SyntaxKind.EqualsToken */) node.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -33830,10 +33956,10 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 136 /* GetKeyword */ || - token() === 149 /* SetKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 136 /* SyntaxKind.GetKeyword */ || + token() === 149 /* SyntaxKind.SetKeyword */) { return true; } var idToken = false; @@ -33843,7 +33969,7 @@ var ts; nextToken(); } // Index signatures and computed property names are type members - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers @@ -33854,30 +33980,30 @@ var ts; // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 20 /* OpenParenToken */ || - token() === 29 /* LessThanToken */ || - token() === 57 /* QuestionToken */ || - token() === 58 /* ColonToken */ || - token() === 27 /* CommaToken */ || + return token() === 20 /* SyntaxKind.OpenParenToken */ || + token() === 29 /* SyntaxKind.LessThanToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || + token() === 58 /* SyntaxKind.ColonToken */ || + token() === 27 /* SyntaxKind.CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { - return parseSignatureMember(174 /* CallSignature */); + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { + return parseSignatureMember(174 /* SyntaxKind.CallSignature */); } - if (token() === 103 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(175 /* ConstructSignature */); + if (token() === 103 /* SyntaxKind.NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(175 /* SyntaxKind.ConstructSignature */); } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 172 /* SyntaxKind.GetAccessor */, 4 /* SignatureFlags.Type */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers, 173 /* SyntaxKind.SetAccessor */, 4 /* SignatureFlags.Type */); } if (isIndexSignature()) { return parseIndexSignatureDeclaration(pos, hasJSDoc, /*decorators*/ undefined, modifiers); @@ -33886,16 +34012,16 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; + return token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */; } function nextTokenIsDot() { - return nextToken() === 24 /* DotToken */; + return nextToken() === 24 /* SyntaxKind.DotToken */; } function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { - case 20 /* OpenParenToken */: - case 29 /* LessThanToken */: - case 24 /* DotToken */: + case 20 /* SyntaxKind.OpenParenToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 24 /* SyntaxKind.DotToken */: return true; } return false; @@ -33906,9 +34032,9 @@ var ts; } function parseObjectTypeMembers() { var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -33917,51 +34043,51 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { - return nextToken() === 145 /* ReadonlyKeyword */; + if (token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { + return nextToken() === 145 /* SyntaxKind.ReadonlyKeyword */; } - if (token() === 145 /* ReadonlyKeyword */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* InKeyword */; + return token() === 22 /* SyntaxKind.OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 101 /* SyntaxKind.InKeyword */; } function parseMappedTypeParameter() { var pos = getNodePos(); var name = parseIdentifierName(); - parseExpected(101 /* InKeyword */); + parseExpected(101 /* SyntaxKind.InKeyword */); var type = parseType(); return finishNode(factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, type, /*defaultType*/ undefined), pos); } function parseMappedType() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var readonlyToken; - if (token() === 145 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 145 /* SyntaxKind.ReadonlyKeyword */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { readonlyToken = parseTokenNode(); - if (readonlyToken.kind !== 145 /* ReadonlyKeyword */) { - parseExpected(145 /* ReadonlyKeyword */); + if (readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + parseExpected(145 /* SyntaxKind.ReadonlyKeyword */); } } - parseExpected(22 /* OpenBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); var typeParameter = parseMappedTypeParameter(); - var nameType = parseOptional(127 /* AsKeyword */) ? parseType() : undefined; - parseExpected(23 /* CloseBracketToken */); + var nameType = parseOptional(127 /* SyntaxKind.AsKeyword */) ? parseType() : undefined; + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var questionToken; - if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + if (token() === 57 /* SyntaxKind.QuestionToken */ || token() === 39 /* SyntaxKind.PlusToken */ || token() === 40 /* SyntaxKind.MinusToken */) { questionToken = parseTokenNode(); - if (questionToken.kind !== 57 /* QuestionToken */) { - parseExpected(57 /* QuestionToken */); + if (questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { + parseExpected(57 /* SyntaxKind.QuestionToken */); } } var type = parseTypeAnnotation(); parseSemicolon(); - var members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(19 /* CloseBraceToken */); + var members = parseList(4 /* ParsingContext.TypeMembers */, parseTypeMember); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type, members), pos); } function parseTupleElementType() { var pos = getNodePos(); - if (parseOptional(25 /* DotDotDotToken */)) { + if (parseOptional(25 /* SyntaxKind.DotDotDotToken */)) { return finishNode(factory.createRestTypeNode(parseType()), pos); } var type = parseType(); @@ -33974,10 +34100,10 @@ var ts; return type; } function isNextTokenColonOrQuestionColon() { - return nextToken() === 58 /* ColonToken */ || (token() === 57 /* QuestionToken */ && nextToken() === 58 /* ColonToken */); + return nextToken() === 58 /* SyntaxKind.ColonToken */ || (token() === 57 /* SyntaxKind.QuestionToken */ && nextToken() === 58 /* SyntaxKind.ColonToken */); } function isTupleElementName() { - if (token() === 25 /* DotDotDotToken */) { + if (token() === 25 /* SyntaxKind.DotDotDotToken */) { return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon(); } return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon(); @@ -33986,10 +34112,10 @@ var ts; if (lookAhead(isTupleElementName)) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierName(); - var questionToken = parseOptionalToken(57 /* QuestionToken */); - parseExpected(58 /* ColonToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var type = parseTupleElementType(); var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -33998,21 +34124,21 @@ var ts; } function parseTupleType() { var pos = getNodePos(); - return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */)), pos); + return finishNode(factory.createTupleTypeNode(parseBracketedList(21 /* ParsingContext.TupleElementTypes */, parseTupleElementNameOrTupleElementType, 22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */)), pos); } function parseParenthesizedType() { var pos = getNodePos(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createParenthesizedType(type), pos); } function parseModifiersForConstructorType() { var modifiers; - if (token() === 126 /* AbstractKeyword */) { + if (token() === 126 /* SyntaxKind.AbstractKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(126 /* AbstractKeyword */), pos); + var modifier = finishNode(factory.createToken(126 /* SyntaxKind.AbstractKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; @@ -34021,10 +34147,10 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForConstructorType(); - var isConstructorType = parseOptional(103 /* NewKeyword */); + var isConstructorType = parseOptional(103 /* SyntaxKind.NewKeyword */); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(4 /* Type */); - var type = parseReturnType(38 /* EqualsGreaterThanToken */, /*isType*/ false); + var parameters = parseParameters(4 /* SignatureFlags.Type */); + var type = parseReturnType(38 /* SyntaxKind.EqualsGreaterThanToken */, /*isType*/ false); var node = isConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory.createFunctionTypeNode(typeParameters, parameters, type); @@ -34034,34 +34160,34 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 24 /* DotToken */ ? undefined : node; + return token() === 24 /* SyntaxKind.DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { var pos = getNodePos(); if (negative) { nextToken(); } - var expression = token() === 110 /* TrueKeyword */ || token() === 95 /* FalseKeyword */ || token() === 104 /* NullKeyword */ ? + var expression = token() === 110 /* SyntaxKind.TrueKeyword */ || token() === 95 /* SyntaxKind.FalseKeyword */ || token() === 104 /* SyntaxKind.NullKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { - expression = finishNode(factory.createPrefixUnaryExpression(40 /* MinusToken */, expression), pos); + expression = finishNode(factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, expression), pos); } return finishNode(factory.createLiteralTypeNode(expression), pos); } function isStartOfTypeOfImportType() { nextToken(); - return token() === 100 /* ImportKeyword */; + return token() === 100 /* SyntaxKind.ImportKeyword */; } function parseImportTypeAssertions() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - parseExpected(18 /* OpenBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - parseExpected(129 /* AssertKeyword */); - parseExpected(58 /* ColonToken */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); var clause = parseAssertClause(/*skipAssertKeyword*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -34070,89 +34196,89 @@ var ts; return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos); } function parseImportType() { - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; var pos = getNodePos(); - var isTypeOf = parseOptional(112 /* TypeOfKeyword */); - parseExpected(100 /* ImportKeyword */); - parseExpected(20 /* OpenParenToken */); + var isTypeOf = parseOptional(112 /* SyntaxKind.TypeOfKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var type = parseType(); var assertions; - if (parseOptional(27 /* CommaToken */)) { + if (parseOptional(27 /* SyntaxKind.CommaToken */)) { assertions = parseImportTypeAssertions(); } - parseExpected(21 /* CloseParenToken */); - var qualifier = parseOptional(24 /* DotToken */) ? parseEntityNameOfTypeReference() : undefined; + parseExpected(21 /* SyntaxKind.CloseParenToken */); + var qualifier = parseOptional(24 /* SyntaxKind.DotToken */) ? parseEntityNameOfTypeReference() : undefined; var typeArguments = parseTypeArgumentsOfTypeReference(); return finishNode(factory.createImportTypeNode(type, assertions, qualifier, typeArguments, isTypeOf), pos); } function nextTokenIsNumericOrBigIntLiteral() { nextToken(); - return token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */; + return token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */; } function parseNonArrayType() { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 151 /* SymbolKeyword */: - case 133 /* BooleanKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 148 /* ObjectKeyword */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 66 /* AsteriskEqualsToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: // If there is '*=', treat it as * followed by postfix = scanner.reScanAsteriskEqualsToken(); // falls through - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: return parseJSDocAllType(); - case 60 /* QuestionQuestionToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // If there is '??', treat it as prefix-'?' in JSDoc type. scanner.reScanQuestionToken(); // falls through - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseJSDocFunctionType(); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parseJSDocNonNullableType(); - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return parseLiteralTypeNode(); - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseTokenNode(); - case 108 /* ThisKeyword */: { + case 108 /* SyntaxKind.ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseTupleType(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedType(); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportType(); - case 128 /* AssertsKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateType(); default: return parseTypeReference(); @@ -34160,48 +34286,48 @@ var ts; } function isStartOfType(inStartOfParameter) { switch (token()) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 145 /* ReadonlyKeyword */: - case 151 /* SymbolKeyword */: - case 154 /* UniqueKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 104 /* NullKeyword */: - case 108 /* ThisKeyword */: - case 112 /* TypeOfKeyword */: - case 143 /* NeverKeyword */: - case 18 /* OpenBraceToken */: - case 22 /* OpenBracketToken */: - case 29 /* LessThanToken */: - case 51 /* BarToken */: - case 50 /* AmpersandToken */: - case 103 /* NewKeyword */: - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 148 /* ObjectKeyword */: - case 41 /* AsteriskToken */: - case 57 /* QuestionToken */: - case 53 /* ExclamationToken */: - case 25 /* DotDotDotToken */: - case 137 /* InferKeyword */: - case 100 /* ImportKeyword */: - case 128 /* AssertsKeyword */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 51 /* SyntaxKind.BarToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 103 /* SyntaxKind.NewKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 41 /* SyntaxKind.AsteriskToken */: + case 57 /* SyntaxKind.QuestionToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 25 /* SyntaxKind.DotDotDotToken */: + case 137 /* SyntaxKind.InferKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 128 /* SyntaxKind.AssertsKeyword */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: return true; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return !inStartOfParameter; - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -34211,18 +34337,18 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 21 /* CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); + return token() === 21 /* SyntaxKind.CloseParenToken */ || isStartOfParameter(/*isJSDocParameter*/ false) || isStartOfType(); } function parsePostfixTypeOrHigher() { var pos = getNodePos(); var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: nextToken(); type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos); break; - case 57 /* QuestionToken */: + case 57 /* SyntaxKind.QuestionToken */: // If next token is start of a type we have a conditional type if (lookAhead(nextTokenIsStartOfType)) { return type; @@ -34230,15 +34356,15 @@ var ts; nextToken(); type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos); break; - case 22 /* OpenBracketToken */: - parseExpected(22 /* OpenBracketToken */); + case 22 /* SyntaxKind.OpenBracketToken */: + parseExpected(22 /* SyntaxKind.OpenBracketToken */); if (isStartOfType()) { var indexType = parseType(); - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos); } else { - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); type = finishNode(factory.createArrayTypeNode(type), pos); } break; @@ -34254,9 +34380,9 @@ var ts; return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos); } function tryParseConstraintOfInferType() { - if (parseOptional(94 /* ExtendsKeyword */)) { + if (parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { var constraint = disallowConditionalTypesAnd(parseType); - if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) { + if (inDisallowConditionalTypesContext() || token() !== 57 /* SyntaxKind.QuestionToken */) { return constraint; } } @@ -34270,17 +34396,17 @@ var ts; } function parseInferType() { var pos = getNodePos(); - parseExpected(137 /* InferKeyword */); + parseExpected(137 /* SyntaxKind.InferKeyword */); return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos); } function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 140 /* KeyOfKeyword */: - case 154 /* UniqueKeyword */: - case 145 /* ReadonlyKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: + case 154 /* SyntaxKind.UniqueKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: return parseTypeOperator(operator); - case 137 /* InferKeyword */: + case 137 /* SyntaxKind.InferKeyword */: return parseInferType(); } return allowConditionalTypesAnd(parsePostfixTypeOrHigher); @@ -34309,7 +34435,7 @@ var ts; } function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) { var pos = getNodePos(); - var isUnionType = operator === 51 /* BarToken */; + var isUnionType = operator === 51 /* SyntaxKind.BarToken */; var hasLeadingOperator = parseOptional(operator); var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType(); @@ -34323,35 +34449,35 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(50 /* AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); + return parseUnionOrIntersectionType(50 /* SyntaxKind.AmpersandToken */, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(51 /* BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); + return parseUnionOrIntersectionType(51 /* SyntaxKind.BarToken */, parseIntersectionTypeOrHigher, factory.createUnionTypeNode); } function nextTokenIsNewKeyword() { nextToken(); - return token() === 103 /* NewKeyword */; + return token() === 103 /* SyntaxKind.NewKeyword */; } function isStartOfFunctionTypeOrConstructorType() { - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return true; } - if (token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType)) { return true; } - return token() === 103 /* NewKeyword */ || - token() === 126 /* AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); + return token() === 103 /* SyntaxKind.NewKeyword */ || + token() === 126 /* SyntaxKind.AbstractKeyword */ && lookAhead(nextTokenIsNewKeyword); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 108 /* ThisKeyword */) { + if (isIdentifier() || token() === 108 /* SyntaxKind.ThisKeyword */) { nextToken(); return true; } - if (token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -34361,7 +34487,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 21 /* CloseParenToken */ || token() === 25 /* DotDotDotToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */ || token() === 25 /* SyntaxKind.DotDotDotToken */) { // ( ) // ( ... return true; @@ -34369,17 +34495,17 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 57 /* QuestionToken */ || token() === 63 /* EqualsToken */) { + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || + token() === 57 /* SyntaxKind.QuestionToken */ || token() === 63 /* SyntaxKind.EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 21 /* CloseParenToken */) { + if (token() === 21 /* SyntaxKind.CloseParenToken */) { nextToken(); - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -34400,65 +34526,65 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 139 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 139 /* SyntaxKind.IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } function parseAssertsTypePredicate() { var pos = getNodePos(); - var assertsModifier = parseExpectedToken(128 /* AssertsKeyword */); - var parameterName = token() === 108 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); - var type = parseOptional(139 /* IsKeyword */) ? parseType() : undefined; + var assertsModifier = parseExpectedToken(128 /* SyntaxKind.AssertsKeyword */); + var parameterName = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + var type = parseOptional(139 /* SyntaxKind.IsKeyword */) ? parseType() : undefined; return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos); } function parseType() { - if (contextFlags & 40960 /* TypeExcludesFlags */) { - return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType); + if (contextFlags & 40960 /* NodeFlags.TypeExcludesFlags */) { + return doOutsideOfContext(40960 /* NodeFlags.TypeExcludesFlags */, parseType); } if (isStartOfFunctionTypeOrConstructorType()) { return parseFunctionOrConstructorType(); } var pos = getNodePos(); var type = parseUnionTypeOrHigher(); - if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) { + if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* SyntaxKind.ExtendsKeyword */)) { // The type following 'extends' is not permitted to be another conditional type var extendsType = disallowConditionalTypesAnd(parseType); - parseExpected(57 /* QuestionToken */); + parseExpected(57 /* SyntaxKind.QuestionToken */); var trueType = allowConditionalTypesAnd(parseType); - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var falseType = allowConditionalTypesAnd(parseType); return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos); } return type; } function parseTypeAnnotation() { - return parseOptional(58 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* SyntaxKind.ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 20 /* OpenParenToken */: - case 22 /* OpenBracketToken */: - case 18 /* OpenBraceToken */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 103 /* NewKeyword */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 79 /* Identifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 20 /* SyntaxKind.OpenParenToken */: + case 22 /* SyntaxKind.OpenBracketToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 103 /* SyntaxKind.NewKeyword */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 79 /* SyntaxKind.Identifier */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -34469,19 +34595,19 @@ var ts; return true; } switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 29 /* LessThanToken */: - case 132 /* AwaitKeyword */: - case 125 /* YieldKeyword */: - case 80 /* PrivateIdentifier */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 132 /* SyntaxKind.AwaitKeyword */: + case 125 /* SyntaxKind.YieldKeyword */: + case 80 /* SyntaxKind.PrivateIdentifier */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -34499,10 +34625,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 18 /* OpenBraceToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && - token() !== 59 /* AtToken */ && + return token() !== 18 /* SyntaxKind.OpenBraceToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && + token() !== 59 /* SyntaxKind.AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -34517,7 +34643,7 @@ var ts; var pos = getNodePos(); var expr = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); var operatorToken; - while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(27 /* SyntaxKind.CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true), pos); } if (saveDecoratorContext) { @@ -34526,7 +34652,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined; + return parseOptional(63 /* SyntaxKind.EqualsToken */) ? parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true) : undefined; } function parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) { // AssignmentExpression[in,yield]: @@ -34568,11 +34694,11 @@ var ts; // binary expression here, so we pass in the 'lowest' precedence here so that it matches // and consumes anything. var pos = getNodePos(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { + if (expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, /*asyncModifier*/ undefined); } // Now see if we might be in cases '2' or '3'. @@ -34588,7 +34714,7 @@ var ts; return parseConditionalExpressionRest(expr, pos, allowReturnTypeInArrowFunction); } function isYieldExpression() { - if (token() === 125 /* YieldKeyword */) { + if (token() === 125 /* SyntaxKind.YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -34624,8 +34750,8 @@ var ts; // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { - return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos); + (token() === 41 /* SyntaxKind.AsteriskToken */ || isStartOfExpression())) { + return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* SyntaxKind.AsteriskToken */), parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true)), pos); } else { // if the next token is not on the same line as yield. or we don't have an '*' or @@ -34634,7 +34760,7 @@ var ts; } } function parseSimpleArrowFunctionExpression(pos, identifier, allowReturnTypeInArrowFunction, asyncModifier) { - ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* SyntaxKind.EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var parameter = factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, identifier, @@ -34643,14 +34769,14 @@ var ts; /*initializer*/ undefined); finishNode(parameter, identifier.pos); var parameters = createNodeArray([parameter], parameter.pos, parameter.end); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, allowReturnTypeInArrowFunction); var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body); return addJSDocComment(finishNode(node, pos)); } function tryParseParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { var triState = isParenthesizedArrowFunctionExpression(); - if (triState === 0 /* False */) { + if (triState === 0 /* Tristate.False */) { // It's definitely not a parenthesized arrow function expression. return undefined; } @@ -34658,7 +34784,7 @@ var ts; // following => or { token. Otherwise, we *might* have an arrow function. Try to parse // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. - return triState === 1 /* True */ ? + return triState === 1 /* Tristate.True */ ? parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*allowReturnTypeInArrowFunction*/ true) : tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction); }); } @@ -34667,44 +34793,44 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */ || token() === 131 /* SyntaxKind.AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 38 /* EqualsGreaterThanToken */) { + if (token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. - return 1 /* True */; + return 1 /* Tristate.True */; } // Definitely not a parenthesized arrow function. - return 0 /* False */; + return 0 /* Tristate.False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { - return 0 /* False */; + return 0 /* Tristate.False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { - return 0 /* False */; + if (token() !== 20 /* SyntaxKind.OpenParenToken */ && token() !== 29 /* SyntaxKind.LessThanToken */) { + return 0 /* Tristate.False */; } } var first = token(); var second = nextToken(); - if (first === 20 /* OpenParenToken */) { - if (second === 21 /* CloseParenToken */) { + if (first === 20 /* SyntaxKind.OpenParenToken */) { + if (second === 21 /* SyntaxKind.CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 38 /* EqualsGreaterThanToken */: - case 58 /* ColonToken */: - case 18 /* OpenBraceToken */: - return 1 /* True */; + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 58 /* SyntaxKind.ColonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + return 1 /* Tristate.True */; default: - return 0 /* False */; + return 0 /* Tristate.False */; } } // If encounter "([" or "({", this could be the start of a binding pattern. @@ -34713,85 +34839,85 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 22 /* OpenBracketToken */ || second === 18 /* OpenBraceToken */) { - return 2 /* Unknown */; + if (second === 22 /* SyntaxKind.OpenBracketToken */ || second === 18 /* SyntaxKind.OpenBraceToken */) { + return 2 /* Tristate.Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 25 /* DotDotDotToken */) { - return 1 /* True */; + if (second === 25 /* SyntaxKind.DotDotDotToken */) { + return 1 /* Tristate.True */; } // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 131 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { - if (nextToken() === 127 /* AsKeyword */) { + if (ts.isModifierKind(second) && second !== 131 /* SyntaxKind.AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (nextToken() === 127 /* SyntaxKind.AsKeyword */) { // https://github.com/microsoft/TypeScript/issues/44466 - return 0 /* False */; + return 0 /* Tristate.False */; } - return 1 /* True */; + return 1 /* Tristate.True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 108 /* ThisKeyword */) { - return 0 /* False */; + if (!isIdentifier() && second !== 108 /* SyntaxKind.ThisKeyword */) { + return 0 /* Tristate.False */; } switch (nextToken()) { - case 58 /* ColonToken */: + case 58 /* SyntaxKind.ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - return 1 /* True */; - case 57 /* QuestionToken */: + return 1 /* Tristate.True */; + case 57 /* SyntaxKind.QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 63 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { - return 1 /* True */; + if (token() === 58 /* SyntaxKind.ColonToken */ || token() === 27 /* SyntaxKind.CommaToken */ || token() === 63 /* SyntaxKind.EqualsToken */ || token() === 21 /* SyntaxKind.CloseParenToken */) { + return 1 /* Tristate.True */; } // Otherwise it is definitely not a lambda. - return 0 /* False */; - case 27 /* CommaToken */: - case 63 /* EqualsToken */: - case 21 /* CloseParenToken */: + return 0 /* Tristate.False */; + case 27 /* SyntaxKind.CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 21 /* SyntaxKind.CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } // It is definitely not an arrow function - return 0 /* False */; + return 0 /* Tristate.False */; } else { - ts.Debug.assert(first === 29 /* LessThanToken */); + ts.Debug.assert(first === 29 /* SyntaxKind.LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { - return 0 /* False */; + return 0 /* Tristate.False */; } // JSX overrides - if (languageVariant === 1 /* JSX */) { + if (languageVariant === 1 /* LanguageVariant.JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 94 /* ExtendsKeyword */) { + if (third === 94 /* SyntaxKind.ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 63 /* EqualsToken */: - case 31 /* GreaterThanToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 31 /* SyntaxKind.GreaterThanToken */: return false; default: return true; } } - else if (third === 27 /* CommaToken */ || third === 63 /* EqualsToken */) { + else if (third === 27 /* SyntaxKind.CommaToken */ || third === 63 /* SyntaxKind.EqualsToken */) { return true; } return false; }); if (isArrowFunctionInJsx) { - return 1 /* True */; + return 1 /* Tristate.True */; } - return 0 /* False */; + return 0 /* Tristate.False */; } // This *could* be a parenthesized arrow function. - return 2 /* Unknown */; + return 2 /* Tristate.Unknown */; } } function parsePossibleParenthesizedArrowFunctionExpression(allowReturnTypeInArrowFunction) { @@ -34807,11 +34933,11 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression(allowReturnTypeInArrowFunction) { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 131 /* AsyncKeyword */) { - if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* Tristate.True */) { var pos = getNodePos(); var asyncModifier = parseModifiersForArrowFunction(); - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); return parseSimpleArrowFunctionExpression(pos, expr, allowReturnTypeInArrowFunction, asyncModifier); } } @@ -34821,26 +34947,26 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { - return 0 /* False */; + if (scanner.hasPrecedingLineBreak() || token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 0 /* Tristate.False */; } // Check for un-parenthesized AsyncArrowFunction - var expr = parseBinaryExpressionOrHigher(0 /* Lowest */); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { - return 1 /* True */; + var expr = parseBinaryExpressionOrHigher(0 /* OperatorPrecedence.Lowest */); + if (!scanner.hasPrecedingLineBreak() && expr.kind === 79 /* SyntaxKind.Identifier */ && token() === 38 /* SyntaxKind.EqualsGreaterThanToken */) { + return 1 /* Tristate.True */; } } - return 0 /* False */; + return 0 /* Tristate.False */; } function parseParenthesizedArrowFunctionExpression(allowAmbiguity, allowReturnTypeInArrowFunction) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiersForArrowFunction(); - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -34850,7 +34976,7 @@ var ts; // close paren. var typeParameters = parseTypeParameters(); var parameters; - if (!parseExpected(20 /* OpenParenToken */)) { + if (!parseExpected(20 /* SyntaxKind.OpenParenToken */)) { if (!allowAmbiguity) { return undefined; } @@ -34867,12 +34993,12 @@ var ts; else { parameters = parseParametersWorker(isAsync, allowAmbiguity); } - if (!parseExpected(21 /* CloseParenToken */) && !allowAmbiguity) { + if (!parseExpected(21 /* SyntaxKind.CloseParenToken */) && !allowAmbiguity) { return undefined; } } - var hasReturnColon = token() === 58 /* ColonToken */; - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var hasReturnColon = token() === 58 /* SyntaxKind.ColonToken */; + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) { return undefined; } @@ -34887,19 +35013,19 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var unwrappedType = type; - while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* ParenthesizedType */) { + while ((unwrappedType === null || unwrappedType === void 0 ? void 0 : unwrappedType.kind) === 191 /* SyntaxKind.ParenthesizedType */) { unwrappedType = unwrappedType.type; // Skip parens if need be } var hasJSDocFunctionType = unwrappedType && ts.isJSDocFunctionType(unwrappedType); - if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* SyntaxKind.EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* SyntaxKind.OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); - var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + var equalsGreaterThanToken = parseExpectedToken(38 /* SyntaxKind.EqualsGreaterThanToken */); + var body = (lastToken === 38 /* SyntaxKind.EqualsGreaterThanToken */ || lastToken === 18 /* SyntaxKind.OpenBraceToken */) ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier), allowReturnTypeInArrowFunction) : parseIdentifier(); // Given: @@ -34923,7 +35049,7 @@ var ts; // Then allow the arrow function, and treat the second colon as terminating // the conditional expression. It's okay to do this because this code would // be a syntax error in JavaScript (as the second colon shouldn't be there). - if (token() !== 58 /* ColonToken */) { + if (token() !== 58 /* SyntaxKind.ColonToken */) { return undefined; } } @@ -34931,12 +35057,12 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseArrowFunctionExpressionBody(isAsync, allowReturnTypeInArrowFunction) { - if (token() === 18 /* OpenBraceToken */) { - return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { + return parseFunctionBlock(isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */); } - if (token() !== 26 /* SemicolonToken */ && - token() !== 98 /* FunctionKeyword */ && - token() !== 84 /* ClassKeyword */ && + if (token() !== 26 /* SyntaxKind.SemicolonToken */ && + token() !== 98 /* SyntaxKind.FunctionKeyword */ && + token() !== 84 /* SyntaxKind.ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -34953,7 +35079,7 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'IgnoreMissingOpenBrace' is passed, parseBody will still error. - return parseFunctionBlock(16 /* IgnoreMissingOpenBrace */ | (isAsync ? 2 /* Await */ : 0 /* None */)); + return parseFunctionBlock(16 /* SignatureFlags.IgnoreMissingOpenBrace */ | (isAsync ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */)); } var savedTopLevel = topLevel; topLevel = false; @@ -34965,16 +35091,16 @@ var ts; } function parseConditionalExpressionRest(leftOperand, pos, allowReturnTypeInArrowFunction) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(57 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. var colonToken; - return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken) + return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ false); }), colonToken = parseExpectedToken(58 /* SyntaxKind.ColonToken */), ts.nodeIsPresent(colonToken) ? parseAssignmentExpressionOrHigher(allowReturnTypeInArrowFunction) - : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos); + : createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* SyntaxKind.ColonToken */))), pos); } function parseBinaryExpressionOrHigher(precedence) { var pos = getNodePos(); @@ -34982,7 +35108,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand, pos); } function isInOrOfKeyword(t) { - return t === 101 /* InKeyword */ || t === 160 /* OfKeyword */; + return t === 101 /* SyntaxKind.InKeyword */ || t === 160 /* SyntaxKind.OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand, pos) { while (true) { @@ -35011,16 +35137,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 101 /* InKeyword */ && inDisallowInContext()) { + if (token() === 101 /* SyntaxKind.InKeyword */ && inDisallowInContext()) { break; } - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -35041,7 +35167,7 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 101 /* InKeyword */) { + if (inDisallowInContext() && token() === 101 /* SyntaxKind.InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; @@ -35069,7 +35195,7 @@ var ts; return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos); } function isAwaitExpression() { - if (token() === 132 /* AwaitKeyword */) { + if (token() === 132 /* SyntaxKind.AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -35102,7 +35228,7 @@ var ts; if (isUpdateExpression()) { var pos = getNodePos(); var updateExpression = parseUpdateExpression(); - return token() === 42 /* AsteriskAsteriskToken */ ? + return token() === 42 /* SyntaxKind.AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) : updateExpression; } @@ -35119,10 +35245,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 42 /* AsteriskAsteriskToken */) { + if (token() === 42 /* SyntaxKind.AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 211 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -35147,23 +35273,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: return parsePrefixUnaryExpression(); - case 89 /* DeleteKeyword */: + case 89 /* SyntaxKind.DeleteKeyword */: return parseDeleteExpression(); - case 112 /* TypeOfKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: return parseTypeOfExpression(); - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return parseVoidExpression(); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 132 /* AwaitKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -35186,18 +35312,18 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - case 53 /* ExclamationToken */: - case 89 /* DeleteKeyword */: - case 112 /* TypeOfKeyword */: - case 114 /* VoidKeyword */: - case 132 /* AwaitKeyword */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 89 /* SyntaxKind.DeleteKeyword */: + case 112 /* SyntaxKind.TypeOfKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 132 /* SyntaxKind.AwaitKeyword */: return false; - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression - if (languageVariant !== 1 /* JSX */) { + if (languageVariant !== 1 /* LanguageVariant.JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. @@ -35218,17 +35344,17 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + if (token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) { var pos = getNodePos(); return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos); } - else if (languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (languageVariant === 1 /* LanguageVariant.JSX */ && token() === 29 /* SyntaxKind.LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token() === 45 /* SyntaxKind.PlusPlusToken */ || token() === 46 /* SyntaxKind.MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { var operator = token(); nextToken(); return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos); @@ -35269,29 +35395,29 @@ var ts; // or starts the beginning of the first four CallExpression productions. var pos = getNodePos(); var expression; - if (token() === 100 /* ImportKeyword */) { + if (token() === 100 /* SyntaxKind.ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */; + sourceFlags |= 2097152 /* NodeFlags.PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { // This is an 'import.*' metaproperty (i.e. 'import.meta') nextToken(); // advance past the 'import' nextToken(); // advance past the dot - expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos); - sourceFlags |= 4194304 /* PossiblyContainsImportMeta */; + expression = finishNode(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, parseIdentifierName()), pos); + sourceFlags |= 4194304 /* NodeFlags.PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 106 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 106 /* SyntaxKind.SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a // CallExpression or OptionalExpression. As such, we need to consume the rest @@ -35353,19 +35479,22 @@ var ts; function parseSuperExpression() { var pos = getNodePos(); var expression = parseTokenNode(); - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments); + if (!isTemplateStartOfTaggedTemplate()) { + expression = factory.createExpressionWithTypeArguments(expression, typeArguments); + } } } - if (token() === 20 /* OpenParenToken */ || token() === 24 /* DotToken */ || token() === 22 /* OpenBracketToken */) { + if (token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 24 /* SyntaxKind.DotToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(24 /* SyntaxKind.DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); // private names will never work with `super` (`super.#foo`), but that's a semantic error, not syntactic return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true)), pos); } @@ -35373,11 +35502,11 @@ var ts; var pos = getNodePos(); var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 280 /* JsxOpeningElement */) { + if (opening.kind === 280 /* SyntaxKind.JsxOpeningElement */) { var children = parseJsxChildren(opening); var closingElement = void 0; var lastChild = children[children.length - 1]; - if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* JsxElement */ + if ((lastChild === null || lastChild === void 0 ? void 0 : lastChild.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(lastChild.openingElement.tagName, lastChild.closingElement.tagName) && tagNamesAreEquivalent(opening.tagName, lastChild.closingElement.tagName)) { // when an unclosed JsxOpeningElement incorrectly parses its parent's JsxClosingElement, @@ -35403,11 +35532,11 @@ var ts; } result = finishNode(factory.createJsxElement(opening, children, closingElement), pos); } - else if (opening.kind === 283 /* JsxOpeningFragment */) { + else if (opening.kind === 283 /* SyntaxKind.JsxOpeningFragment */) { result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos); } else { - ts.Debug.assert(opening.kind === 279 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 279 /* SyntaxKind.JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -35418,11 +35547,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 29 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* SyntaxKind.LessThanToken */) { var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition; var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true, topBadPos_1); }); if (invalidElement) { - var operatorToken = createMissingNode(27 /* CommaToken */, /*reportAtCurrentPosition*/ false); + var operatorToken = createMissingNode(27 /* SyntaxKind.CommaToken */, /*reportAtCurrentPosition*/ false); ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0); parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element); return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos); @@ -35432,13 +35561,13 @@ var ts; } function parseJsxText() { var pos = getNodePos(); - var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* JsxTextAllWhiteSpaces */); + var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12 /* SyntaxKind.JsxTextAllWhiteSpaces */); currentToken = scanner.scanJsxToken(); return finishNode(node, pos); } function parseJsxChild(openingTag, token) { switch (token) { - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // If we hit EOF, issue the error at the tag that lacks the closing element // rather than at the end of the file (which is useless) if (ts.isJsxOpeningFragment(openingTag)) { @@ -35452,15 +35581,15 @@ var ts; parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 30 /* LessThanSlashToken */: - case 7 /* ConflictMarkerTrivia */: + case 30 /* SyntaxKind.LessThanSlashToken */: + case 7 /* SyntaxKind.ConflictMarkerTrivia */: return undefined; - case 11 /* JsxText */: - case 12 /* JsxTextAllWhiteSpaces */: + case 11 /* SyntaxKind.JsxText */: + case 12 /* SyntaxKind.JsxTextAllWhiteSpaces */: return parseJsxText(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 29 /* LessThanToken */: + case 29 /* SyntaxKind.LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false, /*topInvalidNodePosition*/ undefined, openingTag); default: return ts.Debug.assertNever(token); @@ -35470,14 +35599,14 @@ var ts; var list = []; var listPos = getNodePos(); var saveParsingContext = parsingContext; - parsingContext |= 1 << 14 /* JsxChildren */; + parsingContext |= 1 << 14 /* ParsingContext.JsxChildren */; while (true) { var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken()); if (!child) break; list.push(child); if (ts.isJsxOpeningElement(openingTag) - && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* JsxElement */ + && (child === null || child === void 0 ? void 0 : child.kind) === 278 /* SyntaxKind.JsxElement */ && !tagNamesAreEquivalent(child.openingElement.tagName, child.closingElement.tagName) && tagNamesAreEquivalent(openingTag.tagName, child.closingElement.tagName)) { // stop after parsing a mismatched child like
...(
) in order to reattach the
higher @@ -35489,21 +35618,21 @@ var ts; } function parseJsxAttributes() { var pos = getNodePos(); - return finishNode(factory.createJsxAttributes(parseList(13 /* JsxAttributes */, parseJsxAttribute)), pos); + return finishNode(factory.createJsxAttributes(parseList(13 /* ParsingContext.JsxAttributes */, parseJsxAttribute)), pos); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); - if (token() === 31 /* GreaterThanToken */) { + parseExpected(29 /* SyntaxKind.LessThanToken */); + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // See below for explanation of scanJsxText scanJsxText(); return finishNode(factory.createJsxOpeningFragment(), pos); } var tagName = parseJsxElementName(); - var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; + var typeArguments = (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined; var attributes = parseJsxAttributes(); var node; - if (token() === 31 /* GreaterThanToken */) { + if (token() === 31 /* SyntaxKind.GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors @@ -35511,8 +35640,8 @@ var ts; node = factory.createJsxOpeningElement(tagName, typeArguments, attributes); } else { - parseExpected(43 /* SlashToken */); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + parseExpected(43 /* SyntaxKind.SlashToken */); + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35533,39 +35662,39 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 108 /* ThisKeyword */ ? + var expression = token() === 108 /* SyntaxKind.ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ false)), pos); } return expression; } function parseJsxExpression(inExpressionContext) { var pos = getNodePos(); - if (!parseExpected(18 /* OpenBraceToken */)) { + if (!parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { return undefined; } var dotDotDotToken; var expression; - if (token() !== 19 /* CloseBraceToken */) { - dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + if (token() !== 19 /* SyntaxKind.CloseBraceToken */) { + dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); // Only an AssignmentExpression is valid here per the JSX spec, // but we can unambiguously parse a comma sequence and provide // a better error message in grammar checking. expression = parseExpression(); } if (inExpressionContext) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { - if (parseExpected(19 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(19 /* SyntaxKind.CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false)) { scanJsxText(); } } return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos); } function parseJsxAttribute() { - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); @@ -35573,14 +35702,14 @@ var ts; return finishNode(factory.createJsxAttribute(parseIdentifierName(), parseJsxAttributeValue()), pos); } function parseJsxAttributeValue() { - if (token() === 63 /* EqualsToken */) { - if (scanJsxAttributeValue() === 10 /* StringLiteral */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { + if (scanJsxAttributeValue() === 10 /* SyntaxKind.StringLiteral */) { return parseLiteralNode(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseJsxExpression(/*inExpressionContext*/ true); } - if (token() === 29 /* LessThanToken */) { + if (token() === 29 /* SyntaxKind.LessThanToken */) { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } parseErrorAtCurrentToken(ts.Diagnostics.or_JSX_element_expected); @@ -35589,17 +35718,17 @@ var ts; } function parseJsxSpreadAttribute() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - parseExpected(25 /* DotDotDotToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseExpression(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createJsxSpreadAttribute(expression), pos); } function parseJsxClosingElement(open, inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); var tagName = parseJsxElementName(); - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext || !tagNamesAreEquivalent(open.tagName, tagName)) { nextToken(); @@ -35612,11 +35741,11 @@ var ts; } function parseJsxClosingFragment(inExpressionContext) { var pos = getNodePos(); - parseExpected(30 /* LessThanSlashToken */); + parseExpected(30 /* SyntaxKind.LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } - if (parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { + if (parseExpected(31 /* SyntaxKind.GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false)) { // manually advance the scanner in order to look for jsx text inside jsx if (inExpressionContext) { nextToken(); @@ -35629,36 +35758,36 @@ var ts; } function parseTypeAssertion() { var pos = getNodePos(); - parseExpected(29 /* LessThanToken */); + parseExpected(29 /* SyntaxKind.LessThanToken */); var type = parseType(); - parseExpected(31 /* GreaterThanToken */); + parseExpected(31 /* SyntaxKind.GreaterThanToken */); var expression = parseSimpleUnaryExpression(); return finishNode(factory.createTypeAssertion(type, expression), pos); } function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) - || token() === 22 /* OpenBracketToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ || isTemplateStartOfTaggedTemplate(); } function isStartOfOptionalPropertyOrElementAccessChain() { - return token() === 28 /* QuestionDotToken */ + return token() === 28 /* SyntaxKind.QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); } function tryReparseOptionalChain(node) { - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { return true; } // check for an optional chain in a non-null expression if (ts.isNonNullExpression(node)) { var expr = node.expression; - while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) { + while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* NodeFlags.OptionalChain */)) { expr = expr.expression; } - if (expr.flags & 32 /* OptionalChain */) { + if (expr.flags & 32 /* NodeFlags.OptionalChain */) { // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. while (ts.isNonNullExpression(node)) { - node.flags |= 32 /* OptionalChain */; + node.flags |= 32 /* NodeFlags.OptionalChain */; node = node.expression; } return true; @@ -35675,12 +35804,17 @@ var ts; if (isOptionalChain && ts.isPrivateIdentifier(propertyAccess.name)) { parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers); } + if (ts.isExpressionWithTypeArguments(expression) && expression.typeArguments) { + var pos_2 = expression.typeArguments.pos - 1; + var end = ts.skipTrivia(sourceText, expression.typeArguments.end) + 1; + parseErrorAt(pos_2, end, ts.Diagnostics.An_instantiation_expression_cannot_be_followed_by_a_property_access); + } return finishNode(propertyAccess, pos); } function parseElementAccessExpressionRest(pos, expression, questionDotToken) { var argumentExpression; - if (token() === 23 /* CloseBracketToken */) { - argumentExpression = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + if (token() === 23 /* SyntaxKind.CloseBracketToken */) { + argumentExpression = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); } else { var argument = allowInAnd(parseExpression); @@ -35689,7 +35823,7 @@ var ts; } argumentExpression = argument; } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ? factory.createElementAccessChain(expression, questionDotToken, argumentExpression) : factory.createElementAccessExpression(expression, argumentExpression); @@ -35700,30 +35834,30 @@ var ts; var questionDotToken = void 0; var isPropertyAccess = false; if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { - questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + questionDotToken = parseExpectedToken(28 /* SyntaxKind.QuestionDotToken */); isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); } else { - isPropertyAccess = parseOptional(24 /* DotToken */); + isPropertyAccess = parseOptional(24 /* SyntaxKind.DotToken */); } if (isPropertyAccess) { expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { expression = parseElementAccessExpressionRest(pos, expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments - expression = !questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */ ? + expression = !questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) : parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined); continue; } if (!questionDotToken) { - if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); expression = finishNode(factory.createNonNullExpression(expression), pos); continue; @@ -35738,14 +35872,14 @@ var ts; } } function isTemplateStartOfTaggedTemplate() { - return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; + return token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || token() === 15 /* SyntaxKind.TemplateHead */; } function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) { - var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* NoSubstitutionTemplateLiteral */ ? + var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) : parseTemplateExpression(/*isTaggedTemplate*/ true)); - if (questionDotToken || tag.flags & 32 /* OptionalChain */) { - tagExpression.flags |= 32 /* OptionalChain */; + if (questionDotToken || tag.flags & 32 /* NodeFlags.OptionalChain */) { + tagExpression.flags |= 32 /* NodeFlags.OptionalChain */; } tagExpression.questionDotToken = questionDotToken; return finishNode(tagExpression, pos); @@ -35754,7 +35888,7 @@ var ts; while (true) { expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true); var typeArguments = void 0; - var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); + var questionDotToken = parseOptionalToken(28 /* SyntaxKind.QuestionDotToken */); if (questionDotToken) { typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { @@ -35762,9 +35896,9 @@ var ts; continue; } } - if (typeArguments || token() === 20 /* OpenParenToken */) { + if (typeArguments || token() === 20 /* SyntaxKind.OpenParenToken */) { // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments - if (!questionDotToken && expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (!questionDotToken && expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } @@ -35777,7 +35911,7 @@ var ts; } if (questionDotToken) { // We parsed `?.` but then failed to parse anything, so report a missing identifier here. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos); } break; @@ -35785,22 +35919,22 @@ var ts; return expression; } function parseArgumentList() { - parseExpected(20 /* OpenParenToken */); - var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); + var result = parseDelimitedList(11 /* ParsingContext.ArgumentExpressions */, parseArgumentExpression); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) { + if ((contextFlags & 262144 /* NodeFlags.JavaScriptFile */) !== 0) { // TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators. return undefined; } - if (reScanLessThanToken() !== 29 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* SyntaxKind.LessThanToken */) { return undefined; } nextToken(); - var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (reScanGreaterToken() !== 31 /* GreaterThanToken */) { + var typeArguments = parseDelimitedList(20 /* ParsingContext.TypeArguments */, parseType); + if (reScanGreaterToken() !== 31 /* SyntaxKind.GreaterThanToken */) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -35814,17 +35948,17 @@ var ts; function canFollowTypeArgumentsInExpression() { switch (token()) { // These tokens can follow a type argument list in a call expression. - case 20 /* OpenParenToken */: // foo( - case 14 /* NoSubstitutionTemplateLiteral */: // foo `...` - case 15 /* TemplateHead */: // foo `...${100}...` + case 20 /* SyntaxKind.OpenParenToken */: // foo( + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // foo `...` + case 15 /* SyntaxKind.TemplateHead */: // foo `...${100}...` return true; // A type argument list followed by `<` never makes sense, and a type argument list followed // by `>` is ambiguous with a (re-scanned) `>>` operator, so we disqualify both. Also, in // this context, `+` and `-` are unary operators, not binary operators. - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: return false; } // We favor the type argument list interpretation when it is immediately followed by @@ -35833,24 +35967,24 @@ var ts; } function parsePrimaryExpression() { switch (token()) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 104 /* NullKeyword */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return parseTokenNode(); - case 20 /* OpenParenToken */: + case 20 /* SyntaxKind.OpenParenToken */: return parseParenthesizedExpression(); - case 22 /* OpenBracketToken */: + case 22 /* SyntaxKind.OpenBracketToken */: return parseArrayLiteralExpression(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseObjectLiteralExpression(); - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -35858,21 +35992,21 @@ var ts; break; } return parseFunctionExpression(); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassExpression(); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionExpression(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + if (reScanSlashToken() === 13 /* SyntaxKind.RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 15 /* TemplateHead */: + case 15 /* SyntaxKind.TemplateHead */: return parseTemplateExpression(/* isTaggedTemplate */ false); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return parsePrivateIdentifier(); } return parseIdentifier(ts.Diagnostics.Expression_expected); @@ -35880,20 +36014,20 @@ var ts; function parseParenthesizedExpression() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(20 /* OpenParenToken */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc); } function parseSpreadElement() { var pos = getNodePos(); - parseExpected(25 /* DotDotDotToken */); + parseExpected(25 /* SyntaxKind.DotDotDotToken */); var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return finishNode(factory.createSpreadElement(expression), pos); } function parseArgumentOrArrayLiteralElement() { - return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : + return token() === 25 /* SyntaxKind.DotDotDotToken */ ? parseSpreadElement() : + token() === 27 /* SyntaxKind.CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) : parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); } function parseArgumentExpression() { @@ -35902,34 +36036,34 @@ var ts; function parseArrayLiteralExpression() { var pos = getNodePos(); var openBracketPosition = scanner.getTokenPos(); - var openBracketParsed = parseExpected(22 /* OpenBracketToken */); + var openBracketParsed = parseExpected(22 /* SyntaxKind.OpenBracketToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition); + var elements = parseDelimitedList(15 /* ParsingContext.ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + parseExpectedMatchingBrackets(22 /* SyntaxKind.OpenBracketToken */, 23 /* SyntaxKind.CloseBracketToken */, openBracketParsed, openBracketPosition); return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos); } function parseObjectLiteralElement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - if (parseOptionalToken(25 /* DotDotDotToken */)) { + if (parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */)) { var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc); } var decorators = parseDecorators(); var modifiers = parseModifiers(); - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */, 0 /* SignatureFlags.None */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */, 0 /* SignatureFlags.None */); } - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - var exclamationToken = parseOptionalToken(53 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + var exclamationToken = parseOptionalToken(53 /* SyntaxKind.ExclamationToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken); } // check if it is short-hand property assignment or normal property assignment @@ -35938,9 +36072,9 @@ var ts; // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern var node; - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* SyntaxKind.ColonToken */); if (isShorthandPropertyAssignment) { - var equalsToken = parseOptionalToken(63 /* EqualsToken */); + var equalsToken = parseOptionalToken(63 /* SyntaxKind.EqualsToken */); var objectAssignmentInitializer = equalsToken ? allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }) : undefined; node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer); // Save equals token for error reporting. @@ -35948,7 +36082,7 @@ var ts; node.equalsToken = equalsToken; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); var initializer = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }); node = factory.createPropertyAssignment(name, initializer); } @@ -35962,10 +36096,10 @@ var ts; function parseObjectLiteralExpression() { var pos = getNodePos(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */); var multiLine = scanner.hasPrecedingLineBreak(); - var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var properties = parseDelimitedList(12 /* ParsingContext.ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos); } function parseFunctionExpression() { @@ -35979,17 +36113,17 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var modifiers = parseModifiers(); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) : isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) : isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) : parseOptionalBindingIdentifier(); var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlock(isGenerator | isAsync); setDecoratorContext(savedDecoratorContext); var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -36000,23 +36134,23 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var pos = getNodePos(); - parseExpected(103 /* NewKeyword */); - if (parseOptional(24 /* DotToken */)) { + parseExpected(103 /* SyntaxKind.NewKeyword */); + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseIdentifierName(); - return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos); + return finishNode(factory.createMetaProperty(103 /* SyntaxKind.NewKeyword */, name), pos); } var expressionPos = getNodePos(); var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false); var typeArguments; // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { typeArguments = expression.typeArguments; expression = expression.expression; } - if (token() === 28 /* QuestionDotToken */) { + if (token() === 28 /* SyntaxKind.QuestionDotToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Invalid_optional_chain_from_new_expression_Did_you_mean_to_call_0, ts.getTextOfNodeFromSourceText(sourceText, expression)); } - var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined; + var argumentList = token() === 20 /* SyntaxKind.OpenParenToken */ ? parseArgumentList() : undefined; return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos); } // STATEMENTS @@ -36024,13 +36158,13 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var openBracePosition = scanner.getTokenPos(); - var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage); + var openBraceParsed = parseExpected(18 /* SyntaxKind.OpenBraceToken */, diagnosticMessage); if (openBraceParsed || ignoreMissingOpenBrace) { var multiLine = scanner.hasPrecedingLineBreak(); - var statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition); + var statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpectedMatchingBrackets(18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */, openBraceParsed, openBracePosition); var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc); - if (token() === 63 /* EqualsToken */) { + if (token() === 63 /* SyntaxKind.EqualsToken */) { parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses); nextToken(); } @@ -36043,9 +36177,9 @@ var ts; } function parseFunctionBlock(flags, diagnosticMessage) { var savedYieldContext = inYieldContext(); - setYieldContext(!!(flags & 1 /* Yield */)); + setYieldContext(!!(flags & 1 /* SignatureFlags.Yield */)); var savedAwaitContext = inAwaitContext(); - setAwaitContext(!!(flags & 2 /* Await */)); + setAwaitContext(!!(flags & 2 /* SignatureFlags.Await */)); var savedTopLevel = topLevel; topLevel = false; // We may be in a [Decorator] context when parsing a function expression or @@ -36054,7 +36188,7 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var block = parseBlock(!!(flags & 16 /* IgnoreMissingOpenBrace */), diagnosticMessage); + var block = parseBlock(!!(flags & 16 /* SignatureFlags.IgnoreMissingOpenBrace */), diagnosticMessage); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -36066,58 +36200,58 @@ var ts; function parseEmptyStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(26 /* SemicolonToken */); + parseExpected(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createEmptyStatement(), pos), hasJSDoc); } function parseIfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(99 /* IfKeyword */); + parseExpected(99 /* SyntaxKind.IfKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var thenStatement = parseStatement(); - var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined; + var elseStatement = parseOptional(91 /* SyntaxKind.ElseKeyword */) ? parseStatement() : undefined; return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc); } function parseDoStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(90 /* DoKeyword */); + parseExpected(90 /* SyntaxKind.DoKeyword */); var statement = parseStatement(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(26 /* SemicolonToken */); + parseOptional(26 /* SyntaxKind.SemicolonToken */); return withJSDoc(finishNode(factory.createDoStatement(statement, expression), pos), hasJSDoc); } function parseWhileStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(115 /* WhileKeyword */); + parseExpected(115 /* SyntaxKind.WhileKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); var statement = parseStatement(); return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(97 /* ForKeyword */); - var awaitToken = parseOptionalToken(132 /* AwaitKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(97 /* SyntaxKind.ForKeyword */); + var awaitToken = parseOptionalToken(132 /* SyntaxKind.AwaitKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var initializer; - if (token() !== 26 /* SemicolonToken */) { - if (token() === 113 /* VarKeyword */ || token() === 119 /* LetKeyword */ || token() === 85 /* ConstKeyword */) { + if (token() !== 26 /* SyntaxKind.SemicolonToken */) { + if (token() === 113 /* SyntaxKind.VarKeyword */ || token() === 119 /* SyntaxKind.LetKeyword */ || token() === 85 /* SyntaxKind.ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -36125,26 +36259,26 @@ var ts; } } var node; - if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) { + if (awaitToken ? parseExpected(160 /* SyntaxKind.OfKeyword */) : parseOptional(160 /* SyntaxKind.OfKeyword */)) { var expression = allowInAnd(function () { return parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); }); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement()); } - else if (parseOptional(101 /* InKeyword */)) { + else if (parseOptional(101 /* SyntaxKind.InKeyword */)) { var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForInStatement(initializer, expression, parseStatement()); } else { - parseExpected(26 /* SemicolonToken */); - var condition = token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var condition = token() !== 26 /* SyntaxKind.SemicolonToken */ && token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(26 /* SemicolonToken */); - var incrementor = token() !== 21 /* CloseParenToken */ + parseExpected(26 /* SyntaxKind.SemicolonToken */); + var incrementor = token() !== 21 /* SyntaxKind.CloseParenToken */ ? allowInAnd(parseExpression) : undefined; - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); node = factory.createForStatement(initializer, condition, incrementor, parseStatement()); } return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36152,10 +36286,10 @@ var ts; function parseBreakOrContinueStatement(kind) { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(kind === 246 /* BreakStatement */ ? 81 /* BreakKeyword */ : 86 /* ContinueKeyword */); + parseExpected(kind === 246 /* SyntaxKind.BreakStatement */ ? 81 /* SyntaxKind.BreakKeyword */ : 86 /* SyntaxKind.ContinueKeyword */); var label = canParseSemicolon() ? undefined : parseIdentifier(); parseSemicolon(); - var node = kind === 246 /* BreakStatement */ + var node = kind === 246 /* SyntaxKind.BreakStatement */ ? factory.createBreakStatement(label) : factory.createContinueStatement(label); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -36163,7 +36297,7 @@ var ts; function parseReturnStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(105 /* ReturnKeyword */); + parseExpected(105 /* SyntaxKind.ReturnKeyword */); var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return withJSDoc(finishNode(factory.createReturnStatement(expression), pos), hasJSDoc); @@ -36171,47 +36305,47 @@ var ts; function parseWithStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(116 /* WithKeyword */); + parseExpected(116 /* SyntaxKind.WithKeyword */); var openParenPosition = scanner.getTokenPos(); - var openParenParsed = parseExpected(20 /* OpenParenToken */); + var openParenParsed = parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition); - var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement); + parseExpectedMatchingBrackets(20 /* SyntaxKind.OpenParenToken */, 21 /* SyntaxKind.CloseParenToken */, openParenParsed, openParenPosition); + var statement = doInsideOfContext(33554432 /* NodeFlags.InWithStatement */, parseStatement); return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc); } function parseCaseClause() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(82 /* CaseKeyword */); + parseExpected(82 /* SyntaxKind.CaseKeyword */); var expression = allowInAnd(parseExpression); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return withJSDoc(finishNode(factory.createCaseClause(expression, statements), pos), hasJSDoc); } function parseDefaultClause() { var pos = getNodePos(); - parseExpected(88 /* DefaultKeyword */); - parseExpected(58 /* ColonToken */); - var statements = parseList(3 /* SwitchClauseStatements */, parseStatement); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); + parseExpected(58 /* SyntaxKind.ColonToken */); + var statements = parseList(3 /* ParsingContext.SwitchClauseStatements */, parseStatement); return finishNode(factory.createDefaultClause(statements), pos); } function parseCaseOrDefaultClause() { - return token() === 82 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 82 /* SyntaxKind.CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseCaseBlock() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var clauses = parseList(2 /* ParsingContext.SwitchClauses */, parseCaseOrDefaultClause); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createCaseBlock(clauses), pos); } function parseSwitchStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(107 /* SwitchKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(107 /* SyntaxKind.SwitchKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); var caseBlock = parseCaseBlock(); return withJSDoc(finishNode(factory.createSwitchStatement(expression, caseBlock), pos), hasJSDoc); } @@ -36220,7 +36354,7 @@ var ts; // throw [no LineTerminator here]Expression[In, ?Yield]; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(109 /* ThrowKeyword */); + parseExpected(109 /* SyntaxKind.ThrowKeyword */); // Because of automatic semicolon insertion, we need to report error if this // throw could be terminated with a semicolon. Note: we can't call 'parseExpression' // directly as that might consume an expression on the following line. @@ -36240,25 +36374,25 @@ var ts; function parseTryStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(111 /* TryKeyword */); + parseExpected(111 /* SyntaxKind.TryKeyword */); var tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - var catchClause = token() === 83 /* CatchKeyword */ ? parseCatchClause() : undefined; + var catchClause = token() === 83 /* SyntaxKind.CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. var finallyBlock; - if (!catchClause || token() === 96 /* FinallyKeyword */) { - parseExpected(96 /* FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); + if (!catchClause || token() === 96 /* SyntaxKind.FinallyKeyword */) { + parseExpected(96 /* SyntaxKind.FinallyKeyword */, ts.Diagnostics.catch_or_finally_expected); finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return withJSDoc(finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos), hasJSDoc); } function parseCatchClause() { var pos = getNodePos(); - parseExpected(83 /* CatchKeyword */); + parseExpected(83 /* SyntaxKind.CatchKeyword */); var variableDeclaration; - if (parseOptional(20 /* OpenParenToken */)) { + if (parseOptional(20 /* SyntaxKind.OpenParenToken */)) { variableDeclaration = parseVariableDeclaration(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); } else { // Keep shape of node to avoid degrading performance. @@ -36270,7 +36404,7 @@ var ts; function parseDebuggerStatement() { var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); - parseExpected(87 /* DebuggerKeyword */); + parseExpected(87 /* SyntaxKind.DebuggerKeyword */); parseSemicolon(); return withJSDoc(finishNode(factory.createDebuggerStatement(), pos), hasJSDoc); } @@ -36281,9 +36415,9 @@ var ts; var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var node; - var hasParen = token() === 20 /* OpenParenToken */; + var hasParen = token() === 20 /* SyntaxKind.OpenParenToken */; var expression = allowInAnd(parseExpression); - if (ts.isIdentifier(expression) && parseOptional(58 /* ColonToken */)) { + if (ts.isIdentifier(expression) && parseOptional(58 /* SyntaxKind.ColonToken */)) { node = factory.createLabeledStatement(expression, parseStatement()); } else { @@ -36304,25 +36438,25 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 84 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 84 /* SyntaxKind.ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 98 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 98 /* SyntaxKind.FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); - return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* NumericLiteral */ || token() === 9 /* BigIntLiteral */ || token() === 10 /* StringLiteral */) && !scanner.hasPrecedingLineBreak(); + return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 /* SyntaxKind.NumericLiteral */ || token() === 9 /* SyntaxKind.BigIntLiteral */ || token() === 10 /* SyntaxKind.StringLiteral */) && !scanner.hasPrecedingLineBreak(); } function isDeclaration() { while (true) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -36345,44 +36479,44 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 126 /* AbstractKeyword */: - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 145 /* ReadonlyKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 157 /* GlobalKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 79 /* Identifier */ || token() === 93 /* ExportKeyword */; - case 100 /* ImportKeyword */: + return token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 79 /* SyntaxKind.Identifier */ || token() === 93 /* SyntaxKind.ExportKeyword */; + case 100 /* SyntaxKind.ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 93 /* ExportKeyword */: + return token() === 10 /* SyntaxKind.StringLiteral */ || token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 18 /* SyntaxKind.OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 93 /* SyntaxKind.ExportKeyword */: var currentToken_1 = nextToken(); - if (currentToken_1 === 152 /* TypeKeyword */) { + if (currentToken_1 === 152 /* SyntaxKind.TypeKeyword */) { currentToken_1 = lookAhead(nextToken); } - if (currentToken_1 === 63 /* EqualsToken */ || currentToken_1 === 41 /* AsteriskToken */ || - currentToken_1 === 18 /* OpenBraceToken */ || currentToken_1 === 88 /* DefaultKeyword */ || - currentToken_1 === 127 /* AsKeyword */) { + if (currentToken_1 === 63 /* SyntaxKind.EqualsToken */ || currentToken_1 === 41 /* SyntaxKind.AsteriskToken */ || + currentToken_1 === 18 /* SyntaxKind.OpenBraceToken */ || currentToken_1 === 88 /* SyntaxKind.DefaultKeyword */ || + currentToken_1 === 127 /* SyntaxKind.AsKeyword */) { return true; } continue; - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: nextToken(); continue; default: @@ -36395,51 +36529,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 59 /* AtToken */: - case 26 /* SemicolonToken */: - case 18 /* OpenBraceToken */: - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 98 /* FunctionKeyword */: - case 84 /* ClassKeyword */: - case 92 /* EnumKeyword */: - case 99 /* IfKeyword */: - case 90 /* DoKeyword */: - case 115 /* WhileKeyword */: - case 97 /* ForKeyword */: - case 86 /* ContinueKeyword */: - case 81 /* BreakKeyword */: - case 105 /* ReturnKeyword */: - case 116 /* WithKeyword */: - case 107 /* SwitchKeyword */: - case 109 /* ThrowKeyword */: - case 111 /* TryKeyword */: - case 87 /* DebuggerKeyword */: + case 59 /* SyntaxKind.AtToken */: + case 26 /* SyntaxKind.SemicolonToken */: + case 18 /* SyntaxKind.OpenBraceToken */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 99 /* SyntaxKind.IfKeyword */: + case 90 /* SyntaxKind.DoKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: + case 97 /* SyntaxKind.ForKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + case 81 /* SyntaxKind.BreakKeyword */: + case 105 /* SyntaxKind.ReturnKeyword */: + case 116 /* SyntaxKind.WithKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: + case 111 /* SyntaxKind.TryKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return true; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 85 /* ConstKeyword */: - case 93 /* ExportKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return isStartOfDeclaration(); - case 131 /* AsyncKeyword */: - case 135 /* DeclareKeyword */: - case 118 /* InterfaceKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 152 /* TypeKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -36449,7 +36583,7 @@ var ts; } function nextTokenIsBindingIdentifierOrStartOfDestructuring() { nextToken(); - return isBindingIdentifier() || token() === 18 /* OpenBraceToken */ || token() === 22 /* OpenBracketToken */; + return isBindingIdentifier() || token() === 18 /* SyntaxKind.OpenBraceToken */ || token() === 22 /* SyntaxKind.OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -36458,68 +36592,68 @@ var ts; } function parseStatement() { switch (token()) { - case 26 /* SemicolonToken */: + case 26 /* SyntaxKind.SemicolonToken */: return parseEmptyStatement(); - case 18 /* OpenBraceToken */: + case 18 /* SyntaxKind.OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 119 /* LetKeyword */: + case 119 /* SyntaxKind.LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 99 /* IfKeyword */: + case 99 /* SyntaxKind.IfKeyword */: return parseIfStatement(); - case 90 /* DoKeyword */: + case 90 /* SyntaxKind.DoKeyword */: return parseDoStatement(); - case 115 /* WhileKeyword */: + case 115 /* SyntaxKind.WhileKeyword */: return parseWhileStatement(); - case 97 /* ForKeyword */: + case 97 /* SyntaxKind.ForKeyword */: return parseForOrForInOrForOfStatement(); - case 86 /* ContinueKeyword */: - return parseBreakOrContinueStatement(245 /* ContinueStatement */); - case 81 /* BreakKeyword */: - return parseBreakOrContinueStatement(246 /* BreakStatement */); - case 105 /* ReturnKeyword */: + case 86 /* SyntaxKind.ContinueKeyword */: + return parseBreakOrContinueStatement(245 /* SyntaxKind.ContinueStatement */); + case 81 /* SyntaxKind.BreakKeyword */: + return parseBreakOrContinueStatement(246 /* SyntaxKind.BreakStatement */); + case 105 /* SyntaxKind.ReturnKeyword */: return parseReturnStatement(); - case 116 /* WithKeyword */: + case 116 /* SyntaxKind.WithKeyword */: return parseWithStatement(); - case 107 /* SwitchKeyword */: + case 107 /* SyntaxKind.SwitchKeyword */: return parseSwitchStatement(); - case 109 /* ThrowKeyword */: + case 109 /* SyntaxKind.ThrowKeyword */: return parseThrowStatement(); - case 111 /* TryKeyword */: + case 111 /* SyntaxKind.TryKeyword */: // Include 'catch' and 'finally' for error recovery. // falls through - case 83 /* CatchKeyword */: - case 96 /* FinallyKeyword */: + case 83 /* SyntaxKind.CatchKeyword */: + case 96 /* SyntaxKind.FinallyKeyword */: return parseTryStatement(); - case 87 /* DebuggerKeyword */: + case 87 /* SyntaxKind.DebuggerKeyword */: return parseDebuggerStatement(); - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: return parseDeclaration(); - case 131 /* AsyncKeyword */: - case 118 /* InterfaceKeyword */: - case 152 /* TypeKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: - case 135 /* DeclareKeyword */: - case 85 /* ConstKeyword */: - case 92 /* EnumKeyword */: - case 93 /* ExportKeyword */: - case 100 /* ImportKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 123 /* PublicKeyword */: - case 126 /* AbstractKeyword */: - case 124 /* StaticKeyword */: - case 145 /* ReadonlyKeyword */: - case 157 /* GlobalKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -36528,40 +36662,35 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 135 /* DeclareKeyword */; + return modifier.kind === 135 /* SyntaxKind.DeclareKeyword */; } function parseDeclaration() { - // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner - // if we can't reuse the declaration, so that we don't do this work twice? - // // `parseListElement` attempted to get the reused node at this position, // but the ambient context flag was not yet set, so the node appeared // not reusable in that context. - var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier); - if (isAmbient) { - var node = tryReuseAmbientDeclaration(); - if (node) { - return node; - } - } var pos = getNodePos(); var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(); + var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { + var node = tryReuseAmbientDeclaration(pos); + if (node) { + return node; + } for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); }); } else { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); } } - function tryReuseAmbientDeclaration() { - return doInsideOfContext(16777216 /* Ambient */, function () { - var node = currentNode(parsingContext); + function tryReuseAmbientDeclaration(pos) { + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { + var node = currentNode(parsingContext, pos); if (node) { return consumeNode(node); } @@ -36569,33 +36698,33 @@ var ts; } function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) { switch (token()) { - case 113 /* VarKeyword */: - case 119 /* LetKeyword */: - case 85 /* ConstKeyword */: + case 113 /* SyntaxKind.VarKeyword */: + case 119 /* SyntaxKind.LetKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: return parseVariableStatement(pos, hasJSDoc, decorators, modifiers); - case 98 /* FunctionKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers); - case 84 /* ClassKeyword */: + case 84 /* SyntaxKind.ClassKeyword */: return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers); - case 118 /* InterfaceKeyword */: + case 118 /* SyntaxKind.InterfaceKeyword */: return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers); - case 152 /* TypeKeyword */: + case 152 /* SyntaxKind.TypeKeyword */: return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers); - case 92 /* EnumKeyword */: + case 92 /* SyntaxKind.EnumKeyword */: return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers); - case 157 /* GlobalKeyword */: - case 141 /* ModuleKeyword */: - case 142 /* NamespaceKeyword */: + case 157 /* SyntaxKind.GlobalKeyword */: + case 141 /* SyntaxKind.ModuleKeyword */: + case 142 /* SyntaxKind.NamespaceKeyword */: return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers); - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers); - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: nextToken(); switch (token()) { - case 88 /* DefaultKeyword */: - case 63 /* EqualsToken */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 63 /* SyntaxKind.EqualsToken */: return parseExportAssignment(pos, hasJSDoc, decorators, modifiers); - case 127 /* AsKeyword */: + case 127 /* SyntaxKind.AsKeyword */: return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers); default: return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -36604,7 +36733,7 @@ var ts; if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(276 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(276 /* SyntaxKind.MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); ts.setTextRangePos(missing, pos); missing.decorators = decorators; missing.modifiers = modifiers; @@ -36615,38 +36744,44 @@ var ts; } function nextTokenIsIdentifierOrStringLiteralOnSameLine() { nextToken(); - return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* StringLiteral */); + return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10 /* SyntaxKind.StringLiteral */); } function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) { - if (token() !== 18 /* OpenBraceToken */ && canParseSemicolon()) { - parseSemicolon(); - return; + if (token() !== 18 /* SyntaxKind.OpenBraceToken */) { + if (flags & 4 /* SignatureFlags.Type */) { + parseTypeMemberSemicolon(); + return; + } + if (canParseSemicolon()) { + parseSemicolon(); + return; + } } return parseFunctionBlock(flags, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { var pos = getNodePos(); - if (token() === 27 /* CommaToken */) { + if (token() === 27 /* SyntaxKind.CommaToken */) { return finishNode(factory.createOmittedExpression(), pos); } - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var name = parseIdentifierOrPattern(); var initializer = parseInitializer(); return finishNode(factory.createBindingElement(dotDotDotToken, /*propertyName*/ undefined, name, initializer), pos); } function parseObjectBindingElement() { var pos = getNodePos(); - var dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(25 /* SyntaxKind.DotDotDotToken */); var tokenIsIdentifier = isBindingIdentifier(); var propertyName = parsePropertyName(); var name; - if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* SyntaxKind.ColonToken */) { name = propertyName; propertyName = undefined; } else { - parseExpected(58 /* ColonToken */); + parseExpected(58 /* SyntaxKind.ColonToken */); name = parseIdentifierOrPattern(); } var initializer = parseInitializer(); @@ -36654,29 +36789,29 @@ var ts; } function parseObjectBindingPattern() { var pos = getNodePos(); - parseExpected(18 /* OpenBraceToken */); - var elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(19 /* CloseBraceToken */); + parseExpected(18 /* SyntaxKind.OpenBraceToken */); + var elements = parseDelimitedList(9 /* ParsingContext.ObjectBindingElements */, parseObjectBindingElement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); return finishNode(factory.createObjectBindingPattern(elements), pos); } function parseArrayBindingPattern() { var pos = getNodePos(); - parseExpected(22 /* OpenBracketToken */); - var elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(23 /* CloseBracketToken */); + parseExpected(22 /* SyntaxKind.OpenBracketToken */); + var elements = parseDelimitedList(10 /* ParsingContext.ArrayBindingElements */, parseArrayBindingElement); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); return finishNode(factory.createArrayBindingPattern(elements), pos); } function isBindingIdentifierOrPrivateIdentifierOrPattern() { - return token() === 18 /* OpenBraceToken */ - || token() === 22 /* OpenBracketToken */ - || token() === 80 /* PrivateIdentifier */ + return token() === 18 /* SyntaxKind.OpenBraceToken */ + || token() === 22 /* SyntaxKind.OpenBracketToken */ + || token() === 80 /* SyntaxKind.PrivateIdentifier */ || isBindingIdentifier(); } function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) { - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { return parseObjectBindingPattern(); } return parseBindingIdentifier(privateIdentifierDiagnosticMessage); @@ -36689,8 +36824,8 @@ var ts; var hasJSDoc = hasPrecedingJSDocComment(); var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations); var exclamationToken; - if (allowExclamation && name.kind === 79 /* Identifier */ && - token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && name.kind === 79 /* SyntaxKind.Identifier */ && + token() === 53 /* SyntaxKind.ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { exclamationToken = parseTokenNode(); } var type = parseTypeAnnotation(); @@ -36702,13 +36837,13 @@ var ts; var pos = getNodePos(); var flags = 0; switch (token()) { - case 113 /* VarKeyword */: + case 113 /* SyntaxKind.VarKeyword */: break; - case 119 /* LetKeyword */: - flags |= 1 /* Let */; + case 119 /* SyntaxKind.LetKeyword */: + flags |= 1 /* NodeFlags.Let */; break; - case 85 /* ConstKeyword */: - flags |= 2 /* Const */; + case 85 /* SyntaxKind.ConstKeyword */: + flags |= 2 /* NodeFlags.Const */; break; default: ts.Debug.fail(); @@ -36724,19 +36859,19 @@ var ts; // this context. // The checker will then give an error that there is an empty declaration list. var declarations; - if (token() === 160 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 160 /* SyntaxKind.OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { declarations = createMissingList(); } else { var savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - declarations = parseDelimitedList(8 /* VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); + declarations = parseDelimitedList(8 /* ParsingContext.VariableDeclarations */, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation); setDisallowInContext(savedDisallowIn); } return finishNode(factory.createVariableDeclarationList(declarations, flags), pos); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 21 /* SyntaxKind.CloseParenToken */; } function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) { var declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -36749,17 +36884,17 @@ var ts; function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) { var savedAwaitContext = inAwaitContext(); var modifierFlags = ts.modifiersToFlags(modifiers); - parseExpected(98 /* FunctionKeyword */); - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + parseExpected(98 /* SyntaxKind.FunctionKeyword */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. - var name = modifierFlags & 512 /* Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = modifierFlags & 256 /* Async */ ? 2 /* Await */ : 0 /* None */; + var name = modifierFlags & 512 /* ModifierFlags.Default */ ? parseOptionalBindingIdentifier() : parseBindingIdentifier(); + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = modifierFlags & 256 /* ModifierFlags.Async */ ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); - if (modifierFlags & 1 /* Export */) + if (modifierFlags & 1 /* ModifierFlags.Export */) setAwaitContext(/*value*/ true); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); setAwaitContext(savedAwaitContext); var node = factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body); @@ -36767,10 +36902,10 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseConstructorName() { - if (token() === 134 /* ConstructorKeyword */) { - return parseExpected(134 /* ConstructorKeyword */); + if (token() === 134 /* SyntaxKind.ConstructorKeyword */) { + return parseExpected(134 /* SyntaxKind.ConstructorKeyword */); } - if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { + if (token() === 10 /* SyntaxKind.StringLiteral */ && lookAhead(nextToken) === 20 /* SyntaxKind.OpenParenToken */) { return tryParse(function () { var literalNode = parseLiteralNode(); return literalNode.text === "constructor" ? literalNode : undefined; @@ -36781,9 +36916,9 @@ var ts; return tryParse(function () { if (parseConstructorName()) { var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(0 /* SignatureFlags.None */, ts.Diagnostics.or_expected); var node = factory.createConstructorDeclaration(modifiers, parameters, body); // Attach invalid nodes if they exist so that we can report them in the grammar checker. node.decorators = decorators; @@ -36794,11 +36929,11 @@ var ts; }); } function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) { - var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; - var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* Await */ : 0 /* None */; + var isGenerator = asteriskToken ? 1 /* SignatureFlags.Yield */ : 0 /* SignatureFlags.None */; + var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 /* SignatureFlags.Await */ : 0 /* SignatureFlags.None */; var typeParameters = parseTypeParameters(); var parameters = parseParameters(isGenerator | isAsync); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); var node = factory.createMethodDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body); // An exclamation token on a method is invalid syntax and will be handled by the grammar checker @@ -36806,31 +36941,31 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) { - var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* ExclamationToken */) : undefined; + var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53 /* SyntaxKind.ExclamationToken */) : undefined; var type = parseTypeAnnotation(); - var initializer = doOutsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */ | 4096 /* DisallowInContext */, parseInitializer); + var initializer = doOutsideOfContext(8192 /* NodeFlags.YieldContext */ | 32768 /* NodeFlags.AwaitContext */ | 4096 /* NodeFlags.DisallowInContext */, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); var node = factory.createPropertyDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, questionToken || exclamationToken, type, initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) { - var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* SyntaxKind.AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(57 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + var questionToken = parseOptionalToken(57 /* SyntaxKind.QuestionToken */); + if (asteriskToken || token() === 20 /* SyntaxKind.OpenParenToken */ || token() === 29 /* SyntaxKind.LessThanToken */) { return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, /*exclamationToken*/ undefined, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken); } - function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) { + function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind, flags) { var name = parsePropertyName(); var typeParameters = parseTypeParameters(); - var parameters = parseParameters(0 /* None */); - var type = parseReturnType(58 /* ColonToken */, /*isType*/ false); - var body = parseFunctionBlockOrSemicolon(0 /* None */); - var node = kind === 172 /* GetAccessor */ + var parameters = parseParameters(0 /* SignatureFlags.None */); + var type = parseReturnType(58 /* SyntaxKind.ColonToken */, /*isType*/ false); + var body = parseFunctionBlockOrSemicolon(flags); + var node = kind === 172 /* SyntaxKind.GetAccessor */ ? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body) : factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors @@ -36841,7 +36976,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 59 /* AtToken */) { + if (token() === 59 /* SyntaxKind.AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -36858,7 +36993,7 @@ var ts; } nextToken(); } - if (token() === 41 /* AsteriskToken */) { + if (token() === 41 /* SyntaxKind.AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -36868,24 +37003,24 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 22 /* OpenBracketToken */) { + if (token() === 22 /* SyntaxKind.OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 149 /* SetKeyword */ || idToken === 136 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 149 /* SyntaxKind.SetKeyword */ || idToken === 136 /* SyntaxKind.GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 20 /* OpenParenToken */: // Method declaration - case 29 /* LessThanToken */: // Generic Method declaration - case 53 /* ExclamationToken */: // Non-null assertion on property name - case 58 /* ColonToken */: // Type Annotation for declaration - case 63 /* EqualsToken */: // Initializer for declaration - case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 20 /* SyntaxKind.OpenParenToken */: // Method declaration + case 29 /* SyntaxKind.LessThanToken */: // Generic Method declaration + case 53 /* SyntaxKind.ExclamationToken */: // Non-null assertion on property name + case 58 /* SyntaxKind.ColonToken */: // Type Annotation for declaration + case 63 /* SyntaxKind.EqualsToken */: // Initializer for declaration + case 57 /* SyntaxKind.QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -36899,7 +37034,7 @@ var ts; return false; } function parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpectedToken(124 /* StaticKeyword */); + parseExpectedToken(124 /* SyntaxKind.StaticKeyword */); var body = parseClassStaticBlockBody(); var node = withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(body), pos), hasJSDoc); node.decorators = decorators; @@ -36917,7 +37052,7 @@ var ts; return body; } function parseDecoratorExpression() { - if (inAwaitContext() && token() === 132 /* AwaitKeyword */) { + if (inAwaitContext() && token() === 132 /* SyntaxKind.AwaitKeyword */) { // `@await` is is disallowed in an [Await] context, but can cause parsing to go off the rails // This simply parses the missing identifier and moves on. var pos = getNodePos(); @@ -36930,7 +37065,7 @@ var ts; } function tryParseDecorator() { var pos = getNodePos(); - if (!parseOptional(59 /* AtToken */)) { + if (!parseOptional(59 /* SyntaxKind.AtToken */)) { return undefined; } var expression = doInDecoratorContext(parseDecoratorExpression); @@ -36947,17 +37082,17 @@ var ts; function tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStaticModifier) { var pos = getNodePos(); var kind = token(); - if (token() === 85 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 85 /* SyntaxKind.ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { return undefined; } } - else if (stopOnStartOfClassStaticBlock && token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + else if (stopOnStartOfClassStaticBlock && token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return undefined; } - else if (hasSeenStaticModifier && token() === 124 /* StaticKeyword */) { + else if (hasSeenStaticModifier && token() === 124 /* SyntaxKind.StaticKeyword */) { return undefined; } else { @@ -36987,7 +37122,7 @@ var ts; var pos = getNodePos(); var list, modifier, hasSeenStatic = false; while (modifier = tryParseModifier(permitInvalidConstAsModifier, stopOnStartOfClassStaticBlock, hasSeenStatic)) { - if (modifier.kind === 124 /* StaticKeyword */) + if (modifier.kind === 124 /* SyntaxKind.StaticKeyword */) hasSeenStatic = true; list = ts.append(list, modifier); } @@ -36995,33 +37130,33 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 131 /* AsyncKeyword */) { + if (token() === 131 /* SyntaxKind.AsyncKeyword */) { var pos = getNodePos(); nextToken(); - var modifier = finishNode(factory.createToken(131 /* AsyncKeyword */), pos); + var modifier = finishNode(factory.createToken(131 /* SyntaxKind.AsyncKeyword */), pos); modifiers = createNodeArray([modifier], pos); } return modifiers; } function parseClassElement() { var pos = getNodePos(); - if (token() === 26 /* SemicolonToken */) { + if (token() === 26 /* SyntaxKind.SemicolonToken */) { nextToken(); return finishNode(factory.createSemicolonClassElement(), pos); } var hasJSDoc = hasPrecedingJSDocComment(); var decorators = parseDecorators(); var modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true, /*stopOnStartOfClassStaticBlock*/ true); - if (token() === 124 /* StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { + if (token() === 124 /* SyntaxKind.StaticKeyword */ && lookAhead(nextTokenIsOpenBrace)) { return parseClassStaticBlockDeclaration(pos, hasJSDoc, decorators, modifiers); } - if (parseContextualModifier(136 /* GetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* GetAccessor */); + if (parseContextualModifier(136 /* SyntaxKind.GetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 172 /* SyntaxKind.GetAccessor */, 0 /* SignatureFlags.None */); } - if (parseContextualModifier(149 /* SetKeyword */)) { - return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SetAccessor */); + if (parseContextualModifier(149 /* SyntaxKind.SetKeyword */)) { + return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 173 /* SyntaxKind.SetAccessor */, 0 /* SignatureFlags.None */); } - if (token() === 134 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 134 /* SyntaxKind.ConstructorKeyword */ || token() === 10 /* SyntaxKind.StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers); if (constructorDeclaration) { return constructorDeclaration; @@ -37033,17 +37168,17 @@ var ts; // It is very important that we check this *after* checking indexers because // the [ token can start an index signature or a computed property name if (ts.tokenIsIdentifierOrKeyword(token()) || - token() === 10 /* StringLiteral */ || - token() === 8 /* NumericLiteral */ || - token() === 41 /* AsteriskToken */ || - token() === 22 /* OpenBracketToken */) { + token() === 10 /* SyntaxKind.StringLiteral */ || + token() === 8 /* SyntaxKind.NumericLiteral */ || + token() === 41 /* SyntaxKind.AsteriskToken */ || + token() === 22 /* SyntaxKind.OpenBracketToken */) { var isAmbient = ts.some(modifiers, isDeclareModifier); if (isAmbient) { for (var _i = 0, _a = modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 16777216 /* Ambient */; + m.flags |= 16777216 /* NodeFlags.Ambient */; } - return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); + return doInsideOfContext(16777216 /* NodeFlags.Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); }); } else { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); @@ -37051,21 +37186,21 @@ var ts; } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* ClassExpression */); + return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), /*decorators*/ undefined, /*modifiers*/ undefined, 226 /* SyntaxKind.ClassExpression */); } function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) { - return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 257 /* SyntaxKind.ClassDeclaration */); } function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) { var savedAwaitContext = inAwaitContext(); - parseExpected(84 /* ClassKeyword */); + parseExpected(84 /* SyntaxKind.ClassKeyword */); // We don't parse the name here in await context, instead we will report a grammar error in the checker. var name = parseNameOfClassDeclarationOrExpression(); var typeParameters = parseTypeParameters(); @@ -37073,17 +37208,17 @@ var ts; setAwaitContext(/*value*/ true); var heritageClauses = parseHeritageClauses(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } members = parseClassMembers(); - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); } setAwaitContext(savedAwaitContext); - var node = kind === 257 /* ClassDeclaration */ + var node = kind === 257 /* SyntaxKind.ClassDeclaration */ ? factory.createClassDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members) : factory.createClassExpression(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -37099,45 +37234,45 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 117 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 117 /* SyntaxKind.ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return parseList(22 /* HeritageClauses */, parseHeritageClause); + return parseList(22 /* ParsingContext.HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClause() { var pos = getNodePos(); var tok = token(); - ts.Debug.assert(tok === 94 /* ExtendsKeyword */ || tok === 117 /* ImplementsKeyword */); // isListElement() should ensure this. + ts.Debug.assert(tok === 94 /* SyntaxKind.ExtendsKeyword */ || tok === 117 /* SyntaxKind.ImplementsKeyword */); // isListElement() should ensure this. nextToken(); - var types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); + var types = parseDelimitedList(7 /* ParsingContext.HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(factory.createHeritageClause(tok, types), pos); } function parseExpressionWithTypeArguments() { var pos = getNodePos(); var expression = parseLeftHandSideExpressionOrHigher(); - if (expression.kind === 228 /* ExpressionWithTypeArguments */) { + if (expression.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { return expression; } var typeArguments = tryParseTypeArguments(); return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos); } function tryParseTypeArguments() { - return token() === 29 /* LessThanToken */ ? - parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; + return token() === 29 /* SyntaxKind.LessThanToken */ ? + parseBracketedList(20 /* ParsingContext.TypeArguments */, parseType, 29 /* SyntaxKind.LessThanToken */, 31 /* SyntaxKind.GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 94 /* ExtendsKeyword */ || token() === 117 /* ImplementsKeyword */; + return token() === 94 /* SyntaxKind.ExtendsKeyword */ || token() === 117 /* SyntaxKind.ImplementsKeyword */; } function parseClassMembers() { - return parseList(5 /* ClassMembers */, parseClassElement); + return parseList(5 /* ParsingContext.ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(118 /* InterfaceKeyword */); + parseExpected(118 /* SyntaxKind.InterfaceKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); var heritageClauses = parseHeritageClauses(); @@ -37147,11 +37282,11 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(152 /* TypeKeyword */); + parseExpected(152 /* SyntaxKind.TypeKeyword */); var name = parseIdentifier(); var typeParameters = parseTypeParameters(); - parseExpected(63 /* EqualsToken */); - var type = token() === 138 /* IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); + parseExpected(63 /* SyntaxKind.EqualsToken */); + var type = token() === 138 /* SyntaxKind.IntrinsicKeyword */ && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); var node = factory.createTypeAliasDeclaration(modifiers, name, typeParameters, type); node.decorators = decorators; @@ -37169,12 +37304,12 @@ var ts; return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc); } function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(92 /* EnumKeyword */); + parseExpected(92 /* SyntaxKind.EnumKeyword */); var name = parseIdentifier(); var members; - if (parseExpected(18 /* OpenBraceToken */)) { - members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* EnumMembers */, parseEnumMember); }); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6 /* ParsingContext.EnumMembers */, parseEnumMember); }); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { members = createMissingList(); @@ -37186,9 +37321,9 @@ var ts; function parseModuleBlock() { var pos = getNodePos(); var statements; - if (parseExpected(18 /* OpenBraceToken */)) { - statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(19 /* CloseBraceToken */); + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { + statements = parseList(1 /* ParsingContext.BlockStatements */, parseStatement); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } else { statements = createMissingList(); @@ -37198,10 +37333,10 @@ var ts; function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) { // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. - var namespaceFlag = flags & 16 /* Namespace */; + var namespaceFlag = flags & 16 /* NodeFlags.Namespace */; var name = parseIdentifier(); - var body = parseOptional(24 /* DotToken */) - ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) + var body = parseOptional(24 /* SyntaxKind.DotToken */) + ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NodeFlags.NestedNamespace */ | namespaceFlag) : parseModuleBlock(); var node = factory.createModuleDeclaration(modifiers, name, body, flags); node.decorators = decorators; @@ -37210,17 +37345,17 @@ var ts; function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; var name; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // parse 'global' as name of global scope augmentation name = parseIdentifier(); - flags |= 1024 /* GlobalAugmentation */; + flags |= 1024 /* NodeFlags.GlobalAugmentation */; } else { name = parseLiteralNode(); name.text = internIdentifier(name.text); } var body; - if (token() === 18 /* OpenBraceToken */) { + if (token() === 18 /* SyntaxKind.OpenBraceToken */) { body = parseModuleBlock(); } else { @@ -37232,37 +37367,37 @@ var ts; } function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) { var flags = 0; - if (token() === 157 /* GlobalKeyword */) { + if (token() === 157 /* SyntaxKind.GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } - else if (parseOptional(142 /* NamespaceKeyword */)) { - flags |= 16 /* Namespace */; + else if (parseOptional(142 /* SyntaxKind.NamespaceKeyword */)) { + flags |= 16 /* NodeFlags.Namespace */; } else { - parseExpected(141 /* ModuleKeyword */); - if (token() === 10 /* StringLiteral */) { + parseExpected(141 /* SyntaxKind.ModuleKeyword */); + if (token() === 10 /* SyntaxKind.StringLiteral */) { return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers); } } return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 146 /* RequireKeyword */ && + return token() === 146 /* SyntaxKind.RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 20 /* OpenParenToken */; + return nextToken() === 20 /* SyntaxKind.OpenParenToken */; } function nextTokenIsOpenBrace() { - return nextToken() === 18 /* OpenBraceToken */; + return nextToken() === 18 /* SyntaxKind.OpenBraceToken */; } function nextTokenIsSlash() { - return nextToken() === 43 /* SlashToken */; + return nextToken() === 43 /* SyntaxKind.SlashToken */; } function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(127 /* AsKeyword */); - parseExpected(142 /* NamespaceKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); + parseExpected(142 /* SyntaxKind.NamespaceKeyword */); var name = parseIdentifier(); parseSemicolon(); var node = factory.createNamespaceExportDeclaration(name); @@ -37272,7 +37407,7 @@ var ts; return withJSDoc(finishNode(node, pos), hasJSDoc); } function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) { - parseExpected(100 /* ImportKeyword */); + parseExpected(100 /* SyntaxKind.ImportKeyword */); var afterImportPos = scanner.getStartPos(); // We don't parse the identifier here in await context, instead we will report a grammar error in the checker. var identifier; @@ -37280,7 +37415,7 @@ var ts; identifier = parseIdentifier(); } var isTypeOnly = false; - if (token() !== 156 /* FromKeyword */ && + if (token() !== 156 /* SyntaxKind.FromKeyword */ && (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" && (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) { isTypeOnly = true; @@ -37294,15 +37429,15 @@ var ts; // import ModuleSpecifier; var importClause; if (identifier || // import id - token() === 41 /* AsteriskToken */ || // import * - token() === 18 /* OpenBraceToken */ // import { + token() === 41 /* SyntaxKind.AsteriskToken */ || // import * + token() === 18 /* SyntaxKind.OpenBraceToken */ // import { ) { importClause = parseImportClause(identifier, afterImportPos, isTypeOnly); - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); } var moduleSpecifier = parseModuleSpecifier(); var assertClause; - if (token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37312,21 +37447,21 @@ var ts; } function parseAssertEntry() { var pos = getNodePos(); - var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */); - parseExpected(58 /* ColonToken */); + var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* SyntaxKind.StringLiteral */); + parseExpected(58 /* SyntaxKind.ColonToken */); var value = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); return finishNode(factory.createAssertEntry(name, value), pos); } function parseAssertClause(skipAssertKeyword) { var pos = getNodePos(); if (!skipAssertKeyword) { - parseExpected(129 /* AssertKeyword */); + parseExpected(129 /* SyntaxKind.AssertKeyword */); } var openBracePosition = scanner.getTokenPos(); - if (parseExpected(18 /* OpenBraceToken */)) { + if (parseExpected(18 /* SyntaxKind.OpenBraceToken */)) { var multiLine = scanner.hasPrecedingLineBreak(); - var elements = parseDelimitedList(24 /* AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); - if (!parseExpected(19 /* CloseBraceToken */)) { + var elements = parseDelimitedList(24 /* ParsingContext.AssertEntries */, parseAssertEntry, /*considerSemicolonAsDelimiter*/ true); + if (!parseExpected(19 /* SyntaxKind.CloseBraceToken */)) { var lastError = ts.lastOrUndefined(parseDiagnostics); if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}")); @@ -37340,15 +37475,15 @@ var ts; } } function tokenAfterImportDefinitelyProducesImportDeclaration() { - return token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */; + return token() === 41 /* SyntaxKind.AsteriskToken */ || token() === 18 /* SyntaxKind.OpenBraceToken */; } function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() { // In `import id ___`, the current token decides whether to produce // an ImportDeclaration or ImportEqualsDeclaration. - return token() === 27 /* CommaToken */ || token() === 156 /* FromKeyword */; + return token() === 27 /* SyntaxKind.CommaToken */ || token() === 156 /* SyntaxKind.FromKeyword */; } function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) { - parseExpected(63 /* EqualsToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); var moduleReference = parseModuleReference(); parseSemicolon(); var node = factory.createImportEqualsDeclaration(modifiers, isTypeOnly, identifier, moduleReference); @@ -37367,8 +37502,8 @@ var ts; // parse namespace or named imports var namedBindings; if (!identifier || - parseOptional(27 /* CommaToken */)) { - namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* NamedImports */); + parseOptional(27 /* SyntaxKind.CommaToken */)) { + namedBindings = token() === 41 /* SyntaxKind.AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(269 /* SyntaxKind.NamedImports */); } return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos); } @@ -37379,14 +37514,14 @@ var ts; } function parseExternalModuleReference() { var pos = getNodePos(); - parseExpected(146 /* RequireKeyword */); - parseExpected(20 /* OpenParenToken */); + parseExpected(146 /* SyntaxKind.RequireKeyword */); + parseExpected(20 /* SyntaxKind.OpenParenToken */); var expression = parseModuleSpecifier(); - parseExpected(21 /* CloseParenToken */); + parseExpected(21 /* SyntaxKind.CloseParenToken */); return finishNode(factory.createExternalModuleReference(expression), pos); } function parseModuleSpecifier() { - if (token() === 10 /* StringLiteral */) { + if (token() === 10 /* SyntaxKind.StringLiteral */) { var result = parseLiteralNode(); result.text = internIdentifier(result.text); return result; @@ -37402,8 +37537,8 @@ var ts; // NameSpaceImport: // * as ImportedBinding var pos = getNodePos(); - parseExpected(41 /* AsteriskToken */); - parseExpected(127 /* AsKeyword */); + parseExpected(41 /* SyntaxKind.AsteriskToken */); + parseExpected(127 /* SyntaxKind.AsKeyword */); var name = parseIdentifier(); return finishNode(factory.createNamespaceImport(name), pos); } @@ -37416,17 +37551,17 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - var node = kind === 269 /* NamedImports */ - ? factory.createNamedImports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)) - : factory.createNamedExports(parseBracketedList(23 /* ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */)); + var node = kind === 269 /* SyntaxKind.NamedImports */ + ? factory.createNamedImports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseImportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)) + : factory.createNamedExports(parseBracketedList(23 /* ParsingContext.ImportOrExportSpecifiers */, parseExportSpecifier, 18 /* SyntaxKind.OpenBraceToken */, 19 /* SyntaxKind.CloseBraceToken */)); return finishNode(node, pos); } function parseExportSpecifier() { var hasJSDoc = hasPrecedingJSDocComment(); - return withJSDoc(parseImportOrExportSpecifier(275 /* ExportSpecifier */), hasJSDoc); + return withJSDoc(parseImportOrExportSpecifier(275 /* SyntaxKind.ExportSpecifier */), hasJSDoc); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(270 /* ImportSpecifier */); + return parseImportOrExportSpecifier(270 /* SyntaxKind.ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var pos = getNodePos(); @@ -37451,10 +37586,10 @@ var ts; // import { type as } from "mod"; - isTypeOnly: true, name: as // import { type as as } from "mod"; - isTypeOnly: false, name: as, propertyName: type // import { type as as as } from "mod"; - isTypeOnly: true, name: as, propertyName: as - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as ...? } var firstAs = parseIdentifierName(); - if (token() === 127 /* AsKeyword */) { + if (token() === 127 /* SyntaxKind.AsKeyword */) { // { type as as ...? } var secondAs = parseIdentifierName(); if (ts.tokenIsIdentifierOrKeyword(token())) { @@ -37489,15 +37624,15 @@ var ts; name = parseNameWithKeywordCheck(); } } - if (canParseAsKeyword && token() === 127 /* AsKeyword */) { + if (canParseAsKeyword && token() === 127 /* SyntaxKind.AsKeyword */) { propertyName = name; - parseExpected(127 /* AsKeyword */); + parseExpected(127 /* SyntaxKind.AsKeyword */); name = parseNameWithKeywordCheck(); } - if (kind === 270 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 270 /* SyntaxKind.ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } - var node = kind === 270 /* ImportSpecifier */ + var node = kind === 270 /* SyntaxKind.ImportSpecifier */ ? factory.createImportSpecifier(isTypeOnly, propertyName, name) : factory.createExportSpecifier(isTypeOnly, propertyName, name); return finishNode(node, pos); @@ -37517,26 +37652,26 @@ var ts; var exportClause; var moduleSpecifier; var assertClause; - var isTypeOnly = parseOptional(152 /* TypeKeyword */); + var isTypeOnly = parseOptional(152 /* SyntaxKind.TypeKeyword */); var namespaceExportPos = getNodePos(); - if (parseOptional(41 /* AsteriskToken */)) { - if (parseOptional(127 /* AsKeyword */)) { + if (parseOptional(41 /* SyntaxKind.AsteriskToken */)) { + if (parseOptional(127 /* SyntaxKind.AsKeyword */)) { exportClause = parseNamespaceExport(namespaceExportPos); } - parseExpected(156 /* FromKeyword */); + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } else { - exportClause = parseNamedImportsOrExports(273 /* NamedExports */); + exportClause = parseNamedImportsOrExports(273 /* SyntaxKind.NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 156 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(156 /* FromKeyword */); + if (token() === 156 /* SyntaxKind.FromKeyword */ || (token() === 10 /* SyntaxKind.StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(156 /* SyntaxKind.FromKeyword */); moduleSpecifier = parseModuleSpecifier(); } } - if (moduleSpecifier && token() === 129 /* AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (moduleSpecifier && token() === 129 /* SyntaxKind.AssertKeyword */ && !scanner.hasPrecedingLineBreak()) { assertClause = parseAssertClause(); } parseSemicolon(); @@ -37549,11 +37684,11 @@ var ts; var savedAwaitContext = inAwaitContext(); setAwaitContext(/*value*/ true); var isExportEquals; - if (parseOptional(63 /* EqualsToken */)) { + if (parseOptional(63 /* SyntaxKind.EqualsToken */)) { isExportEquals = true; } else { - parseExpected(88 /* DefaultKeyword */); + parseExpected(88 /* SyntaxKind.DefaultKeyword */); } var expression = parseAssignmentExpressionOrHigher(/*allowReturnTypeInArrowFunction*/ true); parseSemicolon(); @@ -37600,11 +37735,11 @@ var ts; var JSDocParser; (function (JSDocParser) { function parseJSDocTypeExpressionForTests(content, start, length) { - initializeState("file.js", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); + initializeState("file.js", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); scanner.setText(content, start, length); currentToken = scanner.scan(); var jsDocTypeExpression = parseJSDocTypeExpression(); - var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop); + var sourceFile = createSourceFile("file.js", 99 /* ScriptTarget.Latest */, 1 /* ScriptKind.JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* SyntaxKind.EndOfFileToken */), 0 /* NodeFlags.None */, ts.noop); var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); if (jsDocDiagnostics) { sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile); @@ -37616,10 +37751,10 @@ var ts; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { var pos = getNodePos(); - var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); + var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* SyntaxKind.OpenBraceToken */); + var type = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocTypeExpression(type); fixupParentReferences(result); @@ -37628,16 +37763,16 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocNameReference() { var pos = getNodePos(); - var hasBrace = parseOptional(18 /* OpenBraceToken */); + var hasBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var p2 = getNodePos(); var entityName = parseEntityName(/* allowReservedWords*/ false); - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # entityName = finishNode(factory.createJSDocMemberName(entityName, parseIdentifier()), p2); } if (hasBrace) { - parseExpectedJSDoc(19 /* CloseBraceToken */); + parseExpectedJSDoc(19 /* SyntaxKind.CloseBraceToken */); } var result = factory.createJSDocNameReference(entityName); fixupParentReferences(result); @@ -37645,9 +37780,9 @@ var ts; } JSDocParser.parseJSDocNameReference = parseJSDocNameReference; function parseIsolatedJSDocComment(content, start, length) { - initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); - var sourceFile = { languageVariant: 0 /* Standard */, text: content }; + initializeState("", content, 99 /* ScriptTarget.Latest */, /*_syntaxCursor:*/ undefined, 1 /* ScriptKind.JS */); + var jsDoc = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var sourceFile = { languageVariant: 0 /* LanguageVariant.Standard */, text: content }; var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile); clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -37657,9 +37792,9 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); ts.setParent(comment, parent); - if (contextFlags & 262144 /* JavaScriptFile */) { + if (contextFlags & 262144 /* NodeFlags.JavaScriptFile */) { if (!jsDocDiagnostics) { jsDocDiagnostics = []; } @@ -37707,7 +37842,7 @@ var ts; return scanner.scanRange(start + 3, length - 5, function () { // Initially we can parse out a tag. We also have seen a starting asterisk. // This is so that /** * @type */ doesn't parse. - var state = 1 /* SawAsterisk */; + var state = 1 /* JSDocState.SawAsterisk */; var margin; // + 4 for leading '/** ' // + 1 because the last index of \n is always one index before the first character in the line and coincidentally, if there is no \n before start, it is -1, which is also one index before the first character @@ -37720,16 +37855,16 @@ var ts; indent += text.length; } nextTokenJSDoc(); - while (parseOptionalJsdoc(5 /* WhitespaceTrivia */)) + while (parseOptionalJsdoc(5 /* SyntaxKind.WhitespaceTrivia */)) ; - if (parseOptionalJsdoc(4 /* NewLineTrivia */)) { - state = 0 /* BeginningOfLine */; + if (parseOptionalJsdoc(4 /* SyntaxKind.NewLineTrivia */)) { + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; } loop: while (true) { switch (token()) { - case 59 /* AtToken */: - if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { + case 59 /* SyntaxKind.AtToken */: + if (state === 0 /* JSDocState.BeginningOfLine */ || state === 1 /* JSDocState.SawAsterisk */) { removeTrailingWhitespace(comments); if (!commentsPos) commentsPos = getNodePos(); @@ -37737,35 +37872,35 @@ var ts; // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. // Real-world comments may break this rule, so "BeginningOfLine" will not be a real line beginning // for malformed examples like `/** @param {string} x @returns {number} the length */` - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; margin = undefined; } else { pushComment(scanner.getTokenText()); } break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: comments.push(scanner.getTokenText()); - state = 0 /* BeginningOfLine */; + state = 0 /* JSDocState.BeginningOfLine */; indent = 0; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: var asterisk = scanner.getTokenText(); - if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { + if (state === 1 /* JSDocState.SawAsterisk */ || state === 2 /* JSDocState.SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(asterisk); } else { // Ignore the first asterisk on a line - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += asterisk.length; } break; - case 5 /* WhitespaceTrivia */: + case 5 /* SyntaxKind.WhitespaceTrivia */: // only collect whitespace if we're already saving comments or have just crossed the comment indent margin var whitespace = scanner.getTokenText(); - if (state === 2 /* SavingComments */) { + if (state === 2 /* JSDocState.SavingComments */) { comments.push(whitespace); } else if (margin !== undefined && indent + whitespace.length > margin) { @@ -37773,10 +37908,10 @@ var ts; } indent += whitespace.length; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: break loop; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -37795,7 +37930,7 @@ var ts; // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. - state = 2 /* SavingComments */; + state = 2 /* JSDocState.SavingComments */; pushComment(scanner.getTokenText()); break; } @@ -37824,26 +37959,26 @@ var ts; // We must use infinite lookahead, as there could be any number of newlines :( while (true) { nextTokenJSDoc(); - if (token() === 1 /* EndOfFileToken */) { + if (token() === 1 /* SyntaxKind.EndOfFileToken */) { return true; } - if (!(token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */)) { + if (!(token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */)) { return false; } } } function skipWhitespace() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } } - while (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { nextTokenJSDoc(); } } function skipWhitespaceOrAsterisk() { - if (token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + if (token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) { return ""; // Don't skip whitespace prior to EoF (or end of comment) - that shouldn't be included in any node's range } @@ -37851,14 +37986,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* SyntaxKind.AsteriskToken */) || token() === 5 /* SyntaxKind.WhitespaceTrivia */ || token() === 4 /* SyntaxKind.NewLineTrivia */) { indentText += scanner.getTokenText(); - if (token() === 4 /* NewLineTrivia */) { + if (token() === 4 /* SyntaxKind.NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 41 /* AsteriskToken */) { + else if (token() === 41 /* SyntaxKind.AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -37866,7 +38001,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -37915,7 +38050,7 @@ var ts; case "arg": case "argument": case "param": - return parseParameterOrPropertyTag(start, tagName, 2 /* Parameter */, margin); + return parseParameterOrPropertyTag(start, tagName, 2 /* PropertyLikeParse.Parameter */, margin); case "return": case "returns": tag = parseReturnTag(start, tagName, margin, indentText); @@ -37953,7 +38088,7 @@ var ts; var comments = []; var parts = []; var linkEnd; - var state = 0 /* BeginningOfLine */; + var state = 0 /* JSDocState.BeginningOfLine */; var previousWhitespace = true; var margin; function pushComment(text) { @@ -37968,31 +38103,31 @@ var ts; if (initialMargin !== "") { pushComment(initialMargin); } - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; } var tok = token(); loop: while (true) { switch (tok) { - case 4 /* NewLineTrivia */: - state = 0 /* BeginningOfLine */; + case 4 /* SyntaxKind.NewLineTrivia */: + state = 0 /* JSDocState.BeginningOfLine */; // don't use pushComment here because we want to keep the margin unchanged comments.push(scanner.getTokenText()); indent = 0; break; - case 59 /* AtToken */: - if (state === 3 /* SavingBackticks */ - || state === 2 /* SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { + case 59 /* SyntaxKind.AtToken */: + if (state === 3 /* JSDocState.SavingBackticks */ + || state === 2 /* JSDocState.SavingComments */ && (!previousWhitespace || lookAhead(isNextJSDocTokenWhitespace))) { // @ doesn't start a new tag inside ``, and inside a comment, only after whitespace or not before whitespace comments.push(scanner.getTokenText()); break; } scanner.setTextPos(scanner.getTextPos() - 1); // falls through - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: // Done break loop; - case 5 /* WhitespaceTrivia */: - if (state === 2 /* SavingComments */ || state === 3 /* SavingBackticks */) { + case 5 /* SyntaxKind.WhitespaceTrivia */: + if (state === 2 /* JSDocState.SavingComments */ || state === 3 /* JSDocState.SavingBackticks */) { pushComment(scanner.getTokenText()); } else { @@ -38004,8 +38139,8 @@ var ts; indent += whitespace.length; } break; - case 18 /* OpenBraceToken */: - state = 2 /* SavingComments */; + case 18 /* SyntaxKind.OpenBraceToken */: + state = 2 /* JSDocState.SavingComments */; var commentEnd = scanner.getStartPos(); var linkStart = scanner.getTextPos() - 1; var link = parseJSDocLink(linkStart); @@ -38019,32 +38154,32 @@ var ts; pushComment(scanner.getTokenText()); } break; - case 61 /* BacktickToken */: - if (state === 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; + case 61 /* SyntaxKind.BacktickToken */: + if (state === 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; } else { - state = 3 /* SavingBackticks */; + state = 3 /* JSDocState.SavingBackticks */; } pushComment(scanner.getTokenText()); break; - case 41 /* AsteriskToken */: - if (state === 0 /* BeginningOfLine */) { + case 41 /* SyntaxKind.AsteriskToken */: + if (state === 0 /* JSDocState.BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token - state = 1 /* SawAsterisk */; + state = 1 /* JSDocState.SawAsterisk */; indent += 1; break; } // record the * as a comment // falls through default: - if (state !== 3 /* SavingBackticks */) { - state = 2 /* SavingComments */; // leading identifiers start recording as well + if (state !== 3 /* JSDocState.SavingBackticks */) { + state = 2 /* JSDocState.SavingComments */; // leading identifiers start recording as well } pushComment(scanner.getTokenText()); break; } - previousWhitespace = token() === 5 /* WhitespaceTrivia */; + previousWhitespace = token() === 5 /* SyntaxKind.WhitespaceTrivia */; tok = nextTokenJSDoc(); } removeLeadingNewlines(comments); @@ -38061,7 +38196,7 @@ var ts; } function isNextJSDocTokenWhitespace() { var next = nextTokenJSDoc(); - return next === 5 /* WhitespaceTrivia */ || next === 4 /* NewLineTrivia */; + return next === 5 /* SyntaxKind.WhitespaceTrivia */ || next === 4 /* SyntaxKind.NewLineTrivia */; } function parseJSDocLink(start) { var linkType = tryParse(parseJSDocLinkPrefix); @@ -38076,14 +38211,14 @@ var ts; ? parseEntityName(/*allowReservedWords*/ true) : undefined; if (name) { - while (token() === 80 /* PrivateIdentifier */) { + while (token() === 80 /* SyntaxKind.PrivateIdentifier */) { reScanHashToken(); // rescan #id as # id nextTokenJSDoc(); // then skip the # name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2); } } var text = []; - while (token() !== 19 /* CloseBraceToken */ && token() !== 4 /* NewLineTrivia */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 19 /* SyntaxKind.CloseBraceToken */ && token() !== 4 /* SyntaxKind.NewLineTrivia */ && token() !== 1 /* SyntaxKind.EndOfFileToken */) { text.push(scanner.getTokenText()); nextTokenJSDoc(); } @@ -38094,8 +38229,8 @@ var ts; } function parseJSDocLinkPrefix() { skipWhitespaceOrAsterisk(); - if (token() === 18 /* OpenBraceToken */ - && nextTokenJSDoc() === 59 /* AtToken */ + if (token() === 18 /* SyntaxKind.OpenBraceToken */ + && nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc())) { var kind = scanner.getTokenValue(); if (isJSDocLinkTag(kind)) @@ -38123,35 +38258,35 @@ var ts; } function tryParseTypeExpression() { skipWhitespaceOrAsterisk(); - return token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + return token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* SyntaxKind.BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(61 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* SyntaxKind.BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(63 /* EqualsToken */)) { + if (parseOptionalToken(63 /* SyntaxKind.EqualsToken */)) { parseExpression(); } - parseExpected(23 /* CloseBracketToken */); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } return { name: name, isBracketed: isBracketed }; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments; @@ -38167,12 +38302,12 @@ var ts; typeExpression = tryParseTypeExpression(); } var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText); - var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); + var nestedTypeLiteral = target !== 4 /* PropertyLikeParse.CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { typeExpression = nestedTypeLiteral; isNameFirst = true; } - var result = target === 1 /* Property */ + var result = target === 1 /* PropertyLikeParse.Property */ ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment); return finishNode(result, start); @@ -38183,12 +38318,12 @@ var ts; var child = void 0; var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) { + if (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* ArrayType */), pos); + var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */), pos); return finishNode(factory.createJSDocTypeExpression(literal), pos); } } @@ -38209,8 +38344,8 @@ var ts; return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start); } function parseSeeTag(start, tagName, indent, indentText) { - var isMarkdownOrJSDocLink = token() === 22 /* OpenBracketToken */ - || lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); + var isMarkdownOrJSDocLink = token() === 22 /* SyntaxKind.OpenBracketToken */ + || lookAhead(function () { return nextTokenJSDoc() === 59 /* SyntaxKind.AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && isJSDocLinkTag(scanner.getTokenValue()); }); var nameExpression = isMarkdownOrJSDocLink ? undefined : parseJSDocNameReference(); var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, getNodePos(), indent, indentText) : undefined; return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start); @@ -38232,14 +38367,14 @@ var ts; var comments = []; var inEmail = false; var token = scanner.getToken(); - while (token !== 1 /* EndOfFileToken */ && token !== 4 /* NewLineTrivia */) { - if (token === 29 /* LessThanToken */) { + while (token !== 1 /* SyntaxKind.EndOfFileToken */ && token !== 4 /* SyntaxKind.NewLineTrivia */) { + if (token === 29 /* SyntaxKind.LessThanToken */) { inEmail = true; } - else if (token === 59 /* AtToken */ && !inEmail) { + else if (token === 59 /* SyntaxKind.AtToken */ && !inEmail) { break; } - else if (token === 31 /* GreaterThanToken */ && inEmail) { + else if (token === 31 /* SyntaxKind.GreaterThanToken */ && inEmail) { comments.push(scanner.getTokenText()); scanner.setTextPos(scanner.getTokenPos() + 1); break; @@ -38258,21 +38393,21 @@ var ts; return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, getNodePos(), margin, indentText)), start); } function parseExpressionWithTypeArgumentsForAugments() { - var usedBrace = parseOptional(18 /* OpenBraceToken */); + var usedBrace = parseOptional(18 /* SyntaxKind.OpenBraceToken */); var pos = getNodePos(); var expression = parsePropertyAccessEntityNameExpression(); var typeArguments = tryParseTypeArguments(); var node = factory.createExpressionWithTypeArguments(expression, typeArguments); var res = finishNode(node, pos); if (usedBrace) { - parseExpected(19 /* CloseBraceToken */); + parseExpected(19 /* SyntaxKind.CloseBraceToken */); } return res; } function parsePropertyAccessEntityNameExpression() { var pos = getNodePos(); var node = parseJSDocIdentifierName(); - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); node = finishNode(factory.createPropertyAccessExpression(node, name), pos); } @@ -38306,7 +38441,7 @@ var ts; var hasChildren = false; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { hasChildren = true; - if (child.kind === 343 /* JSDocTypeTag */) { + if (child.kind === 343 /* SyntaxKind.JSDocTypeTag */) { if (childTypeTag) { var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags); if (lastError) { @@ -38323,7 +38458,7 @@ var ts; } } if (hasChildren) { - var isArrayType = typeExpression && typeExpression.type.kind === 183 /* ArrayType */; + var isArrayType = typeExpression && typeExpression.type.kind === 183 /* SyntaxKind.ArrayType */; var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType); typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? childTypeTag.typeExpression : @@ -38347,10 +38482,10 @@ var ts; return undefined; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (parseOptional(24 /* DotToken */)) { + if (parseOptional(24 /* SyntaxKind.DotToken */)) { var body = parseJSDocTypeNameWithNamespace(/*nested*/ true); var jsDocNamespaceNode = factory.createModuleDeclaration( - /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NestedNamespace */ : undefined); + /*modifiers*/ undefined, typeNameOrNamespaceName, body, nested ? 4 /* NodeFlags.NestedNamespace */ : undefined); return finishNode(jsDocNamespaceNode, pos); } if (nested) { @@ -38362,7 +38497,7 @@ var ts; var pos = getNodePos(); var child; var parameters; - while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { + while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* PropertyLikeParse.CallbackParameter */, indent); })) { parameters = ts.append(parameters, child); } return createNodeArray(parameters || [], pos); @@ -38373,9 +38508,9 @@ var ts; var comment = parseTagComments(indent); var parameters = parseCallbackTagParameters(indent); var returnTag = tryParse(function () { - if (parseOptionalJsdoc(59 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* SyntaxKind.AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 341 /* JSDocReturnTag */) { + if (tag && tag.kind === 341 /* SyntaxKind.JSDocReturnTag */) { return tag; } } @@ -38400,18 +38535,18 @@ var ts; return a.escapedText === b.escapedText; } function parseChildPropertyTag(indent) { - return parseChildParameterOrPropertyTag(1 /* Property */, indent); + return parseChildParameterOrPropertyTag(1 /* PropertyLikeParse.Property */, indent); } function parseChildParameterOrPropertyTag(target, indent, name) { var canParseTag = true; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 59 /* AtToken */: + case 59 /* SyntaxKind.AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 340 /* JSDocParameterTag */ || child.kind === 347 /* JSDocPropertyTag */) && - target !== 4 /* CallbackParameter */ && + if (child && (child.kind === 340 /* SyntaxKind.JSDocParameterTag */ || child.kind === 347 /* SyntaxKind.JSDocPropertyTag */) && + target !== 4 /* PropertyLikeParse.CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; } @@ -38419,26 +38554,26 @@ var ts; } seenAsterisk = false; break; - case 4 /* NewLineTrivia */: + case 4 /* SyntaxKind.NewLineTrivia */: canParseTag = true; seenAsterisk = false; break; - case 41 /* AsteriskToken */: + case 41 /* SyntaxKind.AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: canParseTag = false; break; - case 1 /* EndOfFileToken */: + case 1 /* SyntaxKind.EndOfFileToken */: return false; } } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 59 /* AtToken */); + ts.Debug.assert(token() === 59 /* SyntaxKind.AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -38446,15 +38581,15 @@ var ts; var t; switch (tagName.escapedText) { case "type": - return target === 1 /* Property */ && parseTypeTag(start, tagName); + return target === 1 /* PropertyLikeParse.Property */ && parseTypeTag(start, tagName); case "prop": case "property": - t = 1 /* Property */; + t = 1 /* PropertyLikeParse.Property */; break; case "arg": case "argument": case "param": - t = 2 /* Parameter */ | 4 /* CallbackParameter */; + t = 2 /* PropertyLikeParse.Parameter */ | 4 /* PropertyLikeParse.CallbackParameter */; break; default: return false; @@ -38466,7 +38601,7 @@ var ts; } function parseTemplateTagTypeParameter() { var typeParameterPos = getNodePos(); - var isBracketed = parseOptionalJsdoc(22 /* OpenBracketToken */); + var isBracketed = parseOptionalJsdoc(22 /* SyntaxKind.OpenBracketToken */); if (isBracketed) { skipWhitespace(); } @@ -38474,9 +38609,9 @@ var ts; var defaultType; if (isBracketed) { skipWhitespace(); - parseExpected(63 /* EqualsToken */); - defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType); - parseExpected(23 /* CloseBracketToken */); + parseExpected(63 /* SyntaxKind.EqualsToken */); + defaultType = doInsideOfContext(8388608 /* NodeFlags.JSDoc */, parseJSDocType); + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } if (ts.nodeIsMissing(name)) { return undefined; @@ -38493,7 +38628,7 @@ var ts; typeParameters.push(node); } skipWhitespaceOrAsterisk(); - } while (parseOptionalJsdoc(27 /* CommaToken */)); + } while (parseOptionalJsdoc(27 /* SyntaxKind.CommaToken */)); return createNodeArray(typeParameters, pos); } function parseTemplateTag(start, tagName, indent, indentText) { @@ -38508,7 +38643,7 @@ var ts; // TODO: Determine whether we should enforce this in the checker. // TODO: Consider moving the `constraint` to the first type parameter as we could then remove `getEffectiveConstraintOfTypeParameter`. // TODO: Consider only parsing a single type parameter if there is a constraint. - var constraint = token() === 18 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; + var constraint = token() === 18 /* SyntaxKind.OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; var typeParameters = parseTemplateTagTypeParameters(); return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, getNodePos(), indent, indentText)), start); } @@ -38521,16 +38656,16 @@ var ts; } function parseJSDocEntityName() { var entity = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); // Note that y[] is accepted as an entity name, but the postfix brackets are not saved for checking. // Technically usejsdoc.org requires them for specifying a property of a type equivalent to Array<{ x: ...}> // but it's not worth it to enforce that restriction. } - while (parseOptional(24 /* DotToken */)) { + while (parseOptional(24 /* SyntaxKind.DotToken */)) { var name = parseJSDocIdentifierName(); - if (parseOptional(22 /* OpenBracketToken */)) { - parseExpected(23 /* CloseBracketToken */); + if (parseOptional(22 /* SyntaxKind.OpenBracketToken */)) { + parseExpected(23 /* SyntaxKind.CloseBracketToken */); } entity = createQualifiedName(entity, name); } @@ -38538,7 +38673,7 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(79 /* SyntaxKind.Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); @@ -38555,7 +38690,7 @@ var ts; var IncrementalParser; (function (IncrementalParser) { function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { - aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* Aggressive */); + aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2 /* AssertionLevel.Aggressive */); checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks); if (ts.textChangeRangeIsUnchanged(textChangeRange)) { // if the text didn't change, then we can just return our current source file as-is. @@ -38710,9 +38845,9 @@ var ts; } function shouldCheckNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 79 /* Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 79 /* SyntaxKind.Identifier */: return true; } return false; @@ -38786,10 +38921,10 @@ var ts; } function checkNodePositions(node, aggressiveChecks) { if (aggressiveChecks) { - var pos_2 = node.pos; + var pos_3 = node.pos; var visitNode_1 = function (child) { - ts.Debug.assert(child.pos >= pos_2); - pos_2 = child.end; + ts.Debug.assert(child.pos >= pos_3); + pos_3 = child.end; }; if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -38798,7 +38933,7 @@ var ts; } } forEachChild(node, visitNode_1); - ts.Debug.assert(pos_2 <= node.end); + ts.Debug.assert(pos_3 <= node.end); } } function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) { @@ -38967,7 +39102,7 @@ var ts; var oldText = sourceFile.text; if (textChangeRange) { ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length); - if (aggressiveChecks || ts.Debug.shouldAssert(3 /* VeryAggressive */)) { + if (aggressiveChecks || ts.Debug.shouldAssert(3 /* AssertionLevel.VeryAggressive */)) { var oldTextPrefix = oldText.substr(0, textChangeRange.span.start); var newTextPrefix = newText.substr(0, textChangeRange.span.start); ts.Debug.assert(oldTextPrefix === newTextPrefix); @@ -38982,7 +39117,7 @@ var ts; var currentArrayIndex = 0; ts.Debug.assert(currentArrayIndex < currentArray.length); var current = currentArray[currentArrayIndex]; - var lastQueriedPosition = -1 /* Value */; + var lastQueriedPosition = -1 /* InvalidPosition.Value */; return { currentNode: function (position) { // Only compute the current node if the position is different than the last time @@ -39020,7 +39155,7 @@ var ts; function findHighestListElementThatStartsAtPosition(position) { // Clear out any cached state about the last node we found. currentArray = undefined; - currentArrayIndex = -1 /* Value */; + currentArrayIndex = -1 /* InvalidPosition.Value */; current = undefined; // Recurse into the source file to find the highest node at this position. forEachChild(sourceFile, visitNode, visitArray); @@ -39200,18 +39335,18 @@ var ts; if (namedArgRegExCache.has(name)) { return namedArgRegExCache.get(name); } - var result = new RegExp("(\\s" + name + "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))", "im"); + var result = new RegExp("(\\s".concat(name, "\\s*=\\s*)(?:(?:'([^']*)')|(?:\"([^\"]*)\"))"), "im"); namedArgRegExCache.set(name, result); return result; } var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im; var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im; function extractPragmas(pragmas, range, text) { - var tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); + var tripleSlash = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text); if (tripleSlash) { var name = tripleSlash[1].toLowerCase(); // Technically unsafe cast, but we do it so the below check to make it safe typechecks var pragma = ts.commentPragmas[name]; - if (!pragma || !(pragma.kind & 1 /* TripleSlashXML */)) { + if (!pragma || !(pragma.kind & 1 /* PragmaKindFlags.TripleSlashXML */)) { return; } if (pragma.args) { @@ -39245,15 +39380,15 @@ var ts; } return; } - var singleLine = range.kind === 2 /* SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); + var singleLine = range.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ && singleLinePragmaRegEx.exec(text); if (singleLine) { - return addPragmaForMatch(pragmas, range, 2 /* SingleLine */, singleLine); + return addPragmaForMatch(pragmas, range, 2 /* PragmaKindFlags.SingleLine */, singleLine); } - if (range.kind === 3 /* MultiLineCommentTrivia */) { + if (range.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { var multiLinePragmaRegEx = /@(\S+)(\s+.*)?$/gim; // Defined inline since it uses the "g" flag, which keeps a persistent index (for iterating) var multiLineMatch = void 0; while (multiLineMatch = multiLinePragmaRegEx.exec(text)) { - addPragmaForMatch(pragmas, range, 4 /* MultiLine */, multiLineMatch); + addPragmaForMatch(pragmas, range, 4 /* PragmaKindFlags.MultiLine */, multiLineMatch); } } } @@ -39296,10 +39431,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 79 /* Identifier */) { + if (lhs.kind === 79 /* SyntaxKind.Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 108 /* ThisKeyword */) { + if (lhs.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -39319,11 +39454,11 @@ var ts; defaultValueDescription: false, }; var jsxOptionMap = new ts.Map(ts.getEntries({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */, - "react-jsx": 4 /* ReactJSX */, - "react-jsxdev": 5 /* ReactJSXDev */, + "preserve": 1 /* JsxEmit.Preserve */, + "react-native": 3 /* JsxEmit.ReactNative */, + "react": 2 /* JsxEmit.React */, + "react-jsx": 4 /* JsxEmit.ReactJSX */, + "react-jsxdev": 5 /* JsxEmit.ReactJSXDev */, })); /* @internal */ ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) { @@ -39629,18 +39764,18 @@ var ts; name: "target", shortName: "t", type: new ts.Map(ts.getEntries({ - es3: 0 /* ES3 */, - es5: 1 /* ES5 */, - es6: 2 /* ES2015 */, - es2015: 2 /* ES2015 */, - es2016: 3 /* ES2016 */, - es2017: 4 /* ES2017 */, - es2018: 5 /* ES2018 */, - es2019: 6 /* ES2019 */, - es2020: 7 /* ES2020 */, - es2021: 8 /* ES2021 */, - es2022: 9 /* ES2022 */, - esnext: 99 /* ESNext */, + es3: 0 /* ScriptTarget.ES3 */, + es5: 1 /* ScriptTarget.ES5 */, + es6: 2 /* ScriptTarget.ES2015 */, + es2015: 2 /* ScriptTarget.ES2015 */, + es2016: 3 /* ScriptTarget.ES2016 */, + es2017: 4 /* ScriptTarget.ES2017 */, + es2018: 5 /* ScriptTarget.ES2018 */, + es2019: 6 /* ScriptTarget.ES2019 */, + es2020: 7 /* ScriptTarget.ES2020 */, + es2021: 8 /* ScriptTarget.ES2021 */, + es2022: 9 /* ScriptTarget.ES2022 */, + esnext: 99 /* ScriptTarget.ESNext */, })), affectsSourceFile: true, affectsModuleResolution: true, @@ -39650,7 +39785,7 @@ var ts; showInSimplifiedHelpView: true, category: ts.Diagnostics.Language_and_Environment, description: ts.Diagnostics.Set_the_JavaScript_language_version_for_emitted_JavaScript_and_include_compatible_library_declarations, - defaultValueDescription: 0 /* ES3 */, + defaultValueDescription: 0 /* ScriptTarget.ES3 */, }; /*@internal*/ ts.moduleOptionDeclaration = { @@ -39930,16 +40065,16 @@ var ts; { name: "importsNotUsedAsValues", type: new ts.Map(ts.getEntries({ - remove: 0 /* Remove */, - preserve: 1 /* Preserve */, - error: 2 /* Error */, + remove: 0 /* ImportsNotUsedAsValues.Remove */, + preserve: 1 /* ImportsNotUsedAsValues.Preserve */, + error: 2 /* ImportsNotUsedAsValues.Error */, })), affectsEmit: true, affectsSemanticDiagnostics: true, affectsMultiFileEmitBuildInfo: true, category: ts.Diagnostics.Emit, description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types, - defaultValueDescription: 0 /* Remove */, + defaultValueDescription: 0 /* ImportsNotUsedAsValues.Remove */, }, { name: "downlevelIteration", @@ -40394,8 +40529,8 @@ var ts; { name: "newLine", type: new ts.Map(ts.getEntries({ - crlf: 0 /* CarriageReturnLineFeed */, - lf: 1 /* LineFeed */ + crlf: 0 /* NewLineKind.CarriageReturnLineFeed */, + lf: 1 /* NewLineKind.LineFeed */ })), affectsEmit: true, affectsMultiFileEmitBuildInfo: true, @@ -40768,7 +40903,7 @@ var ts; /* @internal */ ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, - target: 3 /* ES2016 */, + target: 3 /* ScriptTarget.ES2016 */, strict: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, @@ -40793,8 +40928,8 @@ var ts; } ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType; function createDiagnosticForInvalidCustomType(opt, createDiagnostic) { - var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", "); - return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType); + var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'".concat(key, "'"); }).join(", "); + return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--".concat(opt.name), namesOfType); } /* @internal */ function parseCustomTypeOption(opt, value, errors) { @@ -40853,11 +40988,11 @@ var ts; while (i < args.length) { var s = args[i]; i++; - if (s.charCodeAt(0) === 64 /* at */) { + if (s.charCodeAt(0) === 64 /* CharacterCodes.at */) { parseResponseFile(s.slice(1)); } - else if (s.charCodeAt(0) === 45 /* minus */) { - var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* minus */ ? 2 : 1); + else if (s.charCodeAt(0) === 45 /* CharacterCodes.minus */) { + var inputOptionName = s.slice(s.charCodeAt(1) === 45 /* CharacterCodes.minus */ ? 2 : 1); var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, /*allowShort*/ true); if (opt) { i = parseOptionValue(args, i, diagnostics, opt, options, errors); @@ -40886,14 +41021,14 @@ var ts; var args = []; var pos = 0; while (true) { - while (pos < text.length && text.charCodeAt(pos) <= 32 /* space */) + while (pos < text.length && text.charCodeAt(pos) <= 32 /* CharacterCodes.space */) pos++; if (pos >= text.length) break; var start = pos; - if (text.charCodeAt(start) === 34 /* doubleQuote */) { + if (text.charCodeAt(start) === 34 /* CharacterCodes.doubleQuote */) { pos++; - while (pos < text.length && text.charCodeAt(pos) !== 34 /* doubleQuote */) + while (pos < text.length && text.charCodeAt(pos) !== 34 /* CharacterCodes.doubleQuote */) pos++; if (pos < text.length) { args.push(text.substring(start + 1, pos)); @@ -40904,7 +41039,7 @@ var ts; } } else { - while (text.charCodeAt(pos) > 32 /* space */) + while (text.charCodeAt(pos) > 32 /* CharacterCodes.space */) pos++; args.push(text.substring(start, pos)); } @@ -41239,7 +41374,7 @@ var ts; var _a; var rootExpression = (_a = sourceFile.statements[0]) === null || _a === void 0 ? void 0 : _a.expression; var knownRootOptions = reportOptionsErrors ? getTsconfigRootOptionsMap() : undefined; - if (rootExpression && rootExpression.kind !== 205 /* ObjectLiteralExpression */) { + if (rootExpression && rootExpression.kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, rootExpression, ts.Diagnostics.The_root_value_of_a_0_file_must_be_an_object, ts.getBaseFileName(sourceFile.fileName) === "jsconfig.json" ? "jsconfig.json" : "tsconfig.json")); // Last-ditch error recovery. Somewhat useful because the JSON parser will recover from some parse errors by // synthesizing a top-level array literal expression. There's a reasonable chance the first element of that @@ -41279,7 +41414,7 @@ var ts; function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) { var result = returnValue ? {} : undefined; var _loop_4 = function (element) { - if (element.kind !== 296 /* PropertyAssignment */) { + if (element.kind !== 296 /* SyntaxKind.PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); return "continue"; } @@ -41346,16 +41481,16 @@ var ts; function convertPropertyValueToJson(valueExpression, option) { var invalidReported; switch (valueExpression.kind) { - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ true); - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return validateValue(/*value*/ false); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return validateValue(/*value*/ null); // eslint-disable-line no-null/no-null - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); } @@ -41370,16 +41505,16 @@ var ts; } } return validateValue(text); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return validateValue(Number(valueExpression.text)); - case 219 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* SyntaxKind.MinusToken */ || valueExpression.operand.kind !== 8 /* SyntaxKind.NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return validateValue(-Number(valueExpression.operand.text)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -41396,7 +41531,7 @@ var ts; return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined)); } - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element)); } @@ -41590,10 +41725,10 @@ var ts; var newValue = compilerOptionsMap.get(cmd.name); var defaultValue = getDefaultValueForOption(cmd); if (newValue !== defaultValue) { - result.push("" + tab + cmd.name + ": " + newValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(newValue)); } else if (ts.hasProperty(ts.defaultInitCompilerOptions, cmd.name)) { - result.push("" + tab + cmd.name + ": " + defaultValue); + result.push("".concat(tab).concat(cmd.name, ": ").concat(defaultValue)); } }); return result.join(newLine) + newLine; @@ -41644,19 +41779,19 @@ var ts; if (entries.length !== 0) { entries.push({ value: "" }); } - entries.push({ value: "/* " + category + " */" }); + entries.push({ value: "/* ".concat(category, " */") }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; if (compilerOptionsMap.has(option.name)) { - optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); + optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ","); } else { - optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ","); } entries.push({ value: optionName, - description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */") }); marginLength = Math.max(optionName.length, marginLength); } @@ -41665,25 +41800,25 @@ var ts; var tab = makePadding(2); var result = []; result.push("{"); - result.push(tab + "\"compilerOptions\": {"); - result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file) + " */"); + result.push("".concat(tab, "\"compilerOptions\": {")); + result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */")); result.push(""); // Print out each row, aligning all the descriptions on the same column. for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) { var entry = entries_2[_a]; var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; - result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); + result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { - result.push(tab + "},"); - result.push(tab + "\"files\": ["); + result.push("".concat(tab, "},")); + result.push("".concat(tab, "\"files\": [")); for (var i = 0; i < fileNames.length; i++) { - result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ",")); + result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ",")); } - result.push(tab + "]"); + result.push("".concat(tab, "]")); } else { - result.push(tab + "}"); + result.push("".concat(tab, "}")); } result.push("}"); return result.join(newLine) + newLine; @@ -41738,7 +41873,7 @@ var ts; * file to. e.g. outDir */ function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* tracing.Phase.Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName }); var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -42088,8 +42223,8 @@ var ts; extendedConfig = ts.normalizeSlashes(extendedConfig); if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) { var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath); - if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Json */)) { - extendedConfigPath = extendedConfigPath + ".json"; + if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json" /* Extension.Json */)) { + extendedConfigPath = "".concat(extendedConfigPath, ".json"); if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig)); return undefined; @@ -42330,11 +42465,11 @@ var ts; var jsonOnlyIncludeRegexes; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { var _loop_6 = function (file) { - if (ts.fileExtensionIs(file, ".json" /* Json */)) { + if (ts.fileExtensionIs(file, ".json" /* Extension.Json */)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { - var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Json */); }); - var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; }); + var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json" /* Extension.Json */); }); + var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^".concat(pattern, "$"); }); jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray; } var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); }); @@ -42478,7 +42613,7 @@ var ts; var existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; - if (flags === 1 /* Recursive */) { + if (flags === 1 /* WatchDirectoryFlags.Recursive */) { recursiveKeys.push(key); } } @@ -42512,13 +42647,13 @@ var ts; key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]), flags: (questionWildcardIndex !== -1 && questionWildcardIndex < lastDirectorySeperatorIndex) || (starWildcardIndex !== -1 && starWildcardIndex < lastDirectorySeperatorIndex) - ? 1 /* Recursive */ : 0 /* None */ + ? 1 /* WatchDirectoryFlags.Recursive */ : 0 /* WatchDirectoryFlags.None */ }; } if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) { return { key: ts.removeTrailingDirectorySeparator(useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec)), - flags: 1 /* Recursive */ + flags: 1 /* WatchDirectoryFlags.Recursive */ }; } return undefined; @@ -42541,7 +42676,7 @@ var ts; } var higherPriorityPath = keyMapper(ts.changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { - if (ext === ".d.ts" /* Dts */ && (ts.fileExtensionIs(file, ".js" /* Js */) || ts.fileExtensionIs(file, ".jsx" /* Jsx */))) { + if (ext === ".d.ts" /* Extension.Dts */ && (ts.fileExtensionIs(file, ".js" /* Extension.Js */) || ts.fileExtensionIs(file, ".jsx" /* Extension.Jsx */))) { // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to // prevent breakage. @@ -42619,7 +42754,7 @@ var ts; return true; case "string": var defaultValue = option.defaultValueDescription; - return option.isFilePath ? "./" + (defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; + return option.isFilePath ? "./".concat(defaultValue && typeof defaultValue === "string" ? defaultValue : "") : ""; case "list": return []; case "object": @@ -42775,7 +42910,7 @@ var ts; var bestVersionKey = result.version, bestVersionPaths = result.paths; if (typeof bestVersionPaths !== "object") { if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths); + trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['".concat(bestVersionKey, "']"), "object", typeof bestVersionPaths); } return; } @@ -42838,7 +42973,7 @@ var ts; var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types"); function arePathsEqual(path1, path2, host) { var useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames; - return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */; + return ts.comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* Comparison.EqualTo */; } /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -43006,18 +43141,7 @@ var ts; * Does not try `@types/${packageName}` - use a second pass if needed. */ function resolvePackageNameToPackageJson(packageName, containingDirectory, options, host, cache) { - var moduleResolutionState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ts.emptyArray, - features: NodeResolutionFeatures.None, - requestContainingDirectory: containingDirectory, - reportDiagnostic: ts.noop - }; + var moduleResolutionState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) { if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") { var nodeModulesFolder = ts.combinePaths(ancestorDirectory, "node_modules"); @@ -43059,7 +43183,7 @@ var ts; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); // At this stage, skip results with leading dot. - if (baseFileName.charCodeAt(0) !== 46 /* dot */) { + if (baseFileName.charCodeAt(0) !== 46 /* CharacterCodes.dot */) { // Return just the type directive names result.push(baseFileName); } @@ -43114,7 +43238,7 @@ var ts; ts.createCacheWithRedirects = createCacheWithRedirects; function createPackageJsonInfoCache(currentDirectory, getCanonicalFileName) { var cache; - return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries }; + return { getPackageJsonInfo: getPackageJsonInfo, setPackageJsonInfo: setPackageJsonInfo, clear: clear, entries: entries, getInternalMap: getInternalMap }; function getPackageJsonInfo(packageJsonPath) { return cache === null || cache === void 0 ? void 0 : cache.get(ts.toPath(packageJsonPath, currentDirectory, getCanonicalFileName)); } @@ -43128,6 +43252,9 @@ var ts; var iter = cache === null || cache === void 0 ? void 0 : cache.entries(); return iter ? ts.arrayFrom(iter) : []; } + function getInternalMap() { + return cache; + } } function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) { var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference); @@ -43210,7 +43337,7 @@ var ts; }; return cache; function getUnderlyingCacheKey(specifier, mode) { - var result = mode === undefined ? specifier : mode + "|" + specifier; + var result = mode === undefined ? specifier : "".concat(mode, "|").concat(specifier); memoizedReverseKeys.set(result, [specifier, mode]); return result; } @@ -43231,21 +43358,24 @@ var ts; } ts.zipToModeAwareCache = zipToModeAwareCache; function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options, directoryToModuleNameMap, moduleNameToDirectoryMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); moduleNameToDirectoryMap || (moduleNameToDirectoryMap = createCacheWithRedirects(options)); var packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; } }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, clear: clear, update: update, getPackageJsonInfoCache: function () { return packageJsonInfoCache; }, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); - moduleNameToDirectoryMap.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + moduleNameToDirectoryMap.clear(); + } function update(options) { updateRedirectsMap(options, directoryToModuleNameMap, moduleNameToDirectoryMap); } function getOrCreateCacheForModuleName(nonRelativeModuleName, mode, redirectedReference) { ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName)); - return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : mode + "|" + nonRelativeModuleName, createPerModuleNameCache); + return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, mode === undefined ? nonRelativeModuleName : "".concat(mode, "|").concat(nonRelativeModuleName), createPerModuleNameCache); } function createPerModuleNameCache() { var directoryPathMap = new ts.Map(); @@ -43315,13 +43445,16 @@ var ts; } ts.createModuleResolutionCache = createModuleResolutionCache; function createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, options, packageJsonInfoCache, directoryToModuleNameMap) { - var preDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); + var perDirectoryResolutionCache = createPerDirectoryResolutionCache(currentDirectory, getCanonicalFileName, directoryToModuleNameMap || (directoryToModuleNameMap = createCacheWithRedirects(options))); packageJsonInfoCache || (packageJsonInfoCache = createPackageJsonInfoCache(currentDirectory, getCanonicalFileName)); - return __assign(__assign(__assign({}, packageJsonInfoCache), preDirectoryResolutionCache), { clear: clear }); + return __assign(__assign(__assign({}, packageJsonInfoCache), perDirectoryResolutionCache), { clear: clear, clearAllExceptPackageJsonInfoCache: clearAllExceptPackageJsonInfoCache }); function clear() { - preDirectoryResolutionCache.clear(); + clearAllExceptPackageJsonInfoCache(); packageJsonInfoCache.clear(); } + function clearAllExceptPackageJsonInfoCache() { + perDirectoryResolutionCache.clear(); + } } ts.createTypeReferenceDirectiveResolutionCache = createTypeReferenceDirectiveResolutionCache; function resolveModuleNameFromCache(moduleName, containingFile, cache, mode) { @@ -43392,10 +43525,10 @@ var ts; result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; default: - return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution); + return ts.Debug.fail("Unexpected moduleResolution: ".concat(moduleResolution)); } if (result && result.resolvedModule) - ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\""); + ts.perfLogger.logInfoEvent("Module \"".concat(moduleName, "\" resolved to \"").concat(result.resolvedModule.resolvedFileName, "\"")); ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null"); if (perFolderCache) { perFolderCache.set(moduleName, resolutionMode, result); @@ -43598,7 +43731,7 @@ var ts; function resolveJSModule(moduleName, initialDir, host) { var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; if (!resolvedModule) { - throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", ")); + throw new Error("Could not resolve JS module '".concat(moduleName, "' starting at '").concat(initialDir, "'. Looked in: ").concat(failedLookupLocations.join(", "))); } return resolvedModule.resolvedFileName; } @@ -43747,7 +43880,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); + ts.Debug.assert(host.fileExists(real), "".concat(path, " linked to nonexistent file ").concat(real)); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -43814,7 +43947,7 @@ var ts; } var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length; var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules); - if (path.charCodeAt(indexAfterNodeModules) === 64 /* at */) { + if (path.charCodeAt(indexAfterNodeModules) === 64 /* CharacterCodes.at */) { indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName); } return path.slice(0, indexAfterPackageName); @@ -43833,7 +43966,7 @@ var ts; */ function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { - var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Json */); + var extensionLess = ts.tryRemoveExtension(candidate, ".json" /* Extension.Json */); var extension = extensionLess ? candidate.substring(extensionLess.length) : ""; return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } @@ -43850,7 +43983,7 @@ var ts; function loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state) { // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" - if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Json */) && state.compilerOptions.resolveJsonModule)) { + if (ts.hasJSFileExtension(candidate) || (ts.fileExtensionIs(candidate, ".json" /* Extension.Json */) && state.compilerOptions.resolveJsonModule)) { var extensionless = ts.removeFileExtension(candidate); var extension = candidate.substring(extensionless.length); if (state.traceEnabled) { @@ -43878,55 +44011,55 @@ var ts; switch (extensions) { case Extensions.DtsOnly: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".d.mts" /* Dmts */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".d.cts" /* Dcts */); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return tryExtension(".d.ts" /* Dts */); - default: return tryExtension(".d.ts" /* Dts */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".d.mts" /* Extension.Dmts */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".d.cts" /* Extension.Dcts */); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return tryExtension(".d.ts" /* Extension.Dts */); + default: return tryExtension(".d.ts" /* Extension.Dts */); } case Extensions.TypeScript: case Extensions.TsOnly: var useDts = extensions === Extensions.TypeScript; switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mts" /* Mts */) || (useDts ? tryExtension(".d.mts" /* Dmts */) : undefined); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cts" /* Cts */) || (useDts ? tryExtension(".d.cts" /* Dcts */) : undefined); - case ".json" /* Json */: - candidate += ".json" /* Json */; - return useDts ? tryExtension(".d.ts" /* Dts */) : undefined; + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mts" /* Extension.Mts */) || (useDts ? tryExtension(".d.mts" /* Extension.Dmts */) : undefined); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cts" /* Extension.Cts */) || (useDts ? tryExtension(".d.cts" /* Extension.Dcts */) : undefined); + case ".json" /* Extension.Json */: + candidate += ".json" /* Extension.Json */; + return useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined; default: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || (useDts ? tryExtension(".d.ts" /* Dts */) : undefined); + return tryExtension(".ts" /* Extension.Ts */) || tryExtension(".tsx" /* Extension.Tsx */) || (useDts ? tryExtension(".d.ts" /* Extension.Dts */) : undefined); } case Extensions.JavaScript: switch (originalExtension) { - case ".mjs" /* Mjs */: - case ".mts" /* Mts */: - case ".d.mts" /* Dmts */: - return tryExtension(".mjs" /* Mjs */); - case ".cjs" /* Cjs */: - case ".cts" /* Cts */: - case ".d.cts" /* Dcts */: - return tryExtension(".cjs" /* Cjs */); - case ".json" /* Json */: - return tryExtension(".json" /* Json */); + case ".mjs" /* Extension.Mjs */: + case ".mts" /* Extension.Mts */: + case ".d.mts" /* Extension.Dmts */: + return tryExtension(".mjs" /* Extension.Mjs */); + case ".cjs" /* Extension.Cjs */: + case ".cts" /* Extension.Cts */: + case ".d.cts" /* Extension.Dcts */: + return tryExtension(".cjs" /* Extension.Cjs */); + case ".json" /* Extension.Json */: + return tryExtension(".json" /* Extension.Json */); default: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js" /* Extension.Js */) || tryExtension(".jsx" /* Extension.Jsx */); } case Extensions.TSConfig: case Extensions.Json: - return tryExtension(".json" /* Json */); + return tryExtension(".json" /* Extension.Json */); } function tryExtension(ext) { var path = tryFile(candidate + ext, onlyRecordFailures, state); @@ -43977,18 +44110,9 @@ var ts; var entrypoints; var extensions = resolveJs ? Extensions.JavaScript : Extensions.TypeScript; var features = getDefaultNodeResolutionFeatures(options); - var requireState = { - compilerOptions: options, - host: host, - traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], - packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), - conditions: ["node", "require", "types"], - features: features, - requestContainingDirectory: packageJsonInfo.packageDirectory, - reportDiagnostic: ts.noop - }; + var requireState = getTemporaryModuleResolutionState(cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(), host, options); + requireState.conditions = ["node", "require", "types"]; + requireState.requestContainingDirectory = packageJsonInfo.packageDirectory; var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory, /*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths); entrypoints = ts.append(entrypoints, requireResolution === null || requireResolution === void 0 ? void 0 : requireResolution.path); @@ -44061,23 +44185,27 @@ var ts; } } } - /** - * A function for locating the package.json scope for a given path - */ /*@internal*/ - function getPackageScopeForPath(fileName, packageJsonInfoCache, host, options) { - var state = { + function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options) { + return { host: host, compilerOptions: options, traceEnabled: isTraceEnabled(options, host), - failedLookupLocations: [], - affectingLocations: [], + failedLookupLocations: ts.noopPush, + affectingLocations: ts.noopPush, packageJsonInfoCache: packageJsonInfoCache, - features: 0, - conditions: [], + features: NodeResolutionFeatures.None, + conditions: ts.emptyArray, requestContainingDirectory: undefined, reportDiagnostic: ts.noop }; + } + ts.getTemporaryModuleResolutionState = getTemporaryModuleResolutionState; + /** + * A function for locating the package.json scope for a given path + */ + /*@internal*/ + function getPackageScopeForPath(fileName, state) { var parts = ts.getPathComponents(fileName); parts.pop(); while (parts.length > 0) { @@ -44215,16 +44343,16 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */ || extension === ".mjs" /* Mjs */ || extension === ".cjs" /* Cjs */; + return extension === ".js" /* Extension.Js */ || extension === ".jsx" /* Extension.Jsx */ || extension === ".mjs" /* Extension.Mjs */ || extension === ".cjs" /* Extension.Cjs */; case Extensions.TSConfig: case Extensions.Json: - return extension === ".json" /* Json */; + return extension === ".json" /* Extension.Json */; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */ || extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */ || extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; case Extensions.TsOnly: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".mts" /* Mts */ || extension === ".cts" /* Cts */; + return extension === ".ts" /* Extension.Ts */ || extension === ".tsx" /* Extension.Tsx */ || extension === ".mts" /* Extension.Mts */ || extension === ".cts" /* Extension.Cts */; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */ || extension === ".d.mts" /* Dmts */ || extension === ".d.cts" /* Dcts */; + return extension === ".d.ts" /* Extension.Dts */ || extension === ".d.mts" /* Extension.Dmts */ || extension === ".d.cts" /* Extension.Dcts */; } } /* @internal */ @@ -44248,7 +44376,7 @@ var ts; var _a, _b; var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope || !scope.packageJsonContent.exports) { return undefined; } @@ -44261,7 +44389,7 @@ var ts; return undefined; } var trailingParts = parts.slice(nameParts.length); - return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : "." + ts.directorySeparator + trailingParts.join(ts.directorySeparator), state, cache, redirectedReference); + return loadModuleFromExports(scope, extensions, !ts.length(trailingParts) ? "." : ".".concat(ts.directorySeparator).concat(trailingParts.join(ts.directorySeparator)), state, cache, redirectedReference); } function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) { if (!scope.packageJsonContent.exports) { @@ -44307,7 +44435,7 @@ var ts; } var useCaseSensitiveFileNames = typeof state.host.useCaseSensitiveFileNames === "function" ? state.host.useCaseSensitiveFileNames() : state.host.useCaseSensitiveFileNames; var directoryPath = ts.toPath(ts.combinePaths(directory, "dummy"), (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a), ts.createGetCanonicalFileName(useCaseSensitiveFileNames === undefined ? true : useCaseSensitiveFileNames)); - var scope = getPackageScopeForPath(directoryPath, state.packageJsonInfoCache, state.host, state.compilerOptions); + var scope = getPackageScopeForPath(directoryPath, state); if (!scope) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Directory_0_has_no_containing_package_json_scope_Imports_will_not_resolve, directoryPath); @@ -44330,6 +44458,7 @@ var ts; return toSearchResult(/*value*/ undefined); } /** + * @internal * From https://github.com/nodejs/node/blob/8f39f51cbbd3b2de14b9ee896e26421cc5b20121/lib/internal/modules/esm/resolve.js#L722 - * "longest" has some nuance as to what "longest" means in the presence of pattern trailers */ @@ -44352,6 +44481,7 @@ var ts; return 1; return 0; } + ts.comparePatternKeys = comparePatternKeys; function loadModuleFromImportsOrExports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) { var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports); if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) { @@ -44559,7 +44689,7 @@ var ts; // The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment); - var jsAndDtsExtensions = [".mjs" /* Mjs */, ".cjs" /* Cjs */, ".js" /* Js */, ".json" /* Json */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".d.ts" /* Dts */]; + var jsAndDtsExtensions = [".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */, ".js" /* Extension.Js */, ".json" /* Extension.Json */, ".d.mts" /* Extension.Dmts */, ".d.cts" /* Extension.Dcts */, ".d.ts" /* Extension.Dts */]; for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) { var ext = jsAndDtsExtensions_1[_f]; if (ts.fileExtensionIs(possibleInputBase, ext)) { @@ -44744,7 +44874,7 @@ var ts; } /* @internal */ function getTypesPackageName(packageName) { - return "@types/" + mangleScopedPackageName(packageName); + return "@types/".concat(mangleScopedPackageName(packageName)); } ts.getTypesPackageName = getTypesPackageName; /* @internal */ @@ -44890,14 +45020,14 @@ var ts; ts.setParent(node.body, node); ts.setParentRecursive(node.body, /*incremental*/ false); } - return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* ModuleInstanceState.Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; function getModuleInstanceStateCached(node, visited) { if (visited === void 0) { visited = new ts.Map(); } var nodeId = ts.getNodeId(node); if (visited.has(nodeId)) { - return visited.get(nodeId) || 0 /* NonInstantiated */; + return visited.get(nodeId) || 0 /* ModuleInstanceState.NonInstantiated */; } visited.set(nodeId, undefined); var result = getModuleInstanceStateWorker(node, visited); @@ -44908,34 +45038,34 @@ var ts; // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - return 0 /* NonInstantiated */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return 0 /* ModuleInstanceState.NonInstantiated */; // 2. const enum declarations - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: if (ts.isEnumConst(node)) { - return 2 /* ConstEnumOnly */; + return 2 /* ModuleInstanceState.ConstEnumOnly */; } break; // 3. non-exported import declarations - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - if (!(ts.hasSyntacticModifier(node, 1 /* Export */))) { - return 0 /* NonInstantiated */; + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (!(ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { + return 0 /* ModuleInstanceState.NonInstantiated */; } break; // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDeclaration = node; - if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* NamedExports */) { - var state = 0 /* NonInstantiated */; + if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 273 /* SyntaxKind.NamedExports */) { + var state = 0 /* ModuleInstanceState.NonInstantiated */; for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); if (specifierState > state) { state = specifierState; } - if (state === 1 /* Instantiated */) { + if (state === 1 /* ModuleInstanceState.Instantiated */) { return state; } } @@ -44943,21 +45073,21 @@ var ts; } break; // 5. other uninstantiated module declarations. - case 262 /* ModuleBlock */: { - var state_1 = 0 /* NonInstantiated */; + case 262 /* SyntaxKind.ModuleBlock */: { + var state_1 = 0 /* ModuleInstanceState.NonInstantiated */; ts.forEachChild(node, function (n) { var childState = getModuleInstanceStateCached(n, visited); switch (childState) { - case 0 /* NonInstantiated */: + case 0 /* ModuleInstanceState.NonInstantiated */: // child is non-instantiated - continue searching return; - case 2 /* ConstEnumOnly */: + case 2 /* ModuleInstanceState.ConstEnumOnly */: // child is const enum only - record state and continue searching - state_1 = 2 /* ConstEnumOnly */; + state_1 = 2 /* ModuleInstanceState.ConstEnumOnly */; return; - case 1 /* Instantiated */: + case 1 /* ModuleInstanceState.Instantiated */: // child is instantiated - record state and stop - state_1 = 1 /* Instantiated */; + state_1 = 1 /* ModuleInstanceState.Instantiated */; return true; default: ts.Debug.assertNever(childState); @@ -44965,16 +45095,16 @@ var ts; }); return state_1; } - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return getModuleInstanceState(node, visited); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { - return 0 /* NonInstantiated */; + return 0 /* ModuleInstanceState.NonInstantiated */; } } - return 1 /* Instantiated */; + return 1 /* ModuleInstanceState.Instantiated */; } function getModuleInstanceStateForAliasTarget(specifier, visited) { var name = specifier.propertyName || specifier.name; @@ -44994,7 +45124,7 @@ var ts; if (found === undefined || state > found) { found = state; } - if (found === 1 /* Instantiated */) { + if (found === 1 /* ModuleInstanceState.Instantiated */) { return found; } } @@ -45005,7 +45135,7 @@ var ts; } p = p.parent; } - return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + return 1 /* ModuleInstanceState.Instantiated */; // Couldn't locate, assume could refer to a value } var ContainerFlags; (function (ContainerFlags) { @@ -45079,8 +45209,8 @@ var ts; var symbolCount = 0; var Symbol; var classifiableNames; - var unreachableFlow = { flags: 1 /* Unreachable */ }; - var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; + var unreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; + var reportedUnreachableFlow = { flags: 1 /* FlowFlags.Unreachable */ }; var bindBinaryExpressionFlow = createBindBinaryExpressionFlow(); /** * Inside the binder, we may create a diagnostic for an as-yet unbound node (with potentially no parent pointers, implying no accessible source file) @@ -45102,7 +45232,7 @@ var ts; ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* tracing.Phase.Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true); bind(file); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); file.symbolCount = symbolCount; @@ -45129,7 +45259,7 @@ var ts; activeLabelList = undefined; hasExplicitReturn = false; inAssignmentPattern = false; - emitFlags = 0 /* None */; + emitFlags = 0 /* NodeFlags.None */; } return bindSourceFile; function bindInStrictMode(file, opts) { @@ -45149,33 +45279,33 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; symbol.declarations = ts.appendIfUnique(symbol.declarations, node); - if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } - if (symbolFlags & (32 /* Class */ | 64 /* Interface */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && !symbol.members) { + if (symbolFlags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && !symbol.members) { symbol.members = ts.createSymbolTable(); } // On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate) - if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) { + if (symbol.constEnumOnlyModule && (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) { symbol.constEnumOnlyModule = false; } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { ts.setValueDeclaration(symbol, node); } } // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 271 /* ExportAssignment */) { - return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; + if (node.kind === 271 /* SyntaxKind.ExportAssignment */) { + return node.isExportEquals ? "export=" /* InternalSymbolName.ExportEquals */ : "default" /* InternalSymbolName.Default */; } var name = ts.getNameOfDeclaration(node); if (name) { if (ts.isAmbientModule(node)) { var moduleName = ts.getTextOfIdentifierOrLiteral(name); - return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); + return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"".concat(moduleName, "\"")); } - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -45201,36 +45331,36 @@ var ts; return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 171 /* Constructor */: - return "__constructor" /* Constructor */; - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - return "__call" /* Call */; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: - return "__new" /* New */; - case 176 /* IndexSignature */: - return "__index" /* Index */; - case 272 /* ExportDeclaration */: - return "__export" /* ExportStar */; - case 305 /* SourceFile */: + case 171 /* SyntaxKind.Constructor */: + return "__constructor" /* InternalSymbolName.Constructor */; + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + return "__call" /* InternalSymbolName.Call */; + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + return "__new" /* InternalSymbolName.New */; + case 176 /* SyntaxKind.IndexSignature */: + return "__index" /* InternalSymbolName.Index */; + case 272 /* SyntaxKind.ExportDeclaration */: + return "__export" /* InternalSymbolName.ExportStar */; + case 305 /* SyntaxKind.SourceFile */: // json file should behave as // module.exports = ... - return "export=" /* ExportEquals */; - case 221 /* BinaryExpression */: - if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { + return "export=" /* InternalSymbolName.ExportEquals */; + case 221 /* SyntaxKind.BinaryExpression */: + if (ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */) { // module.exports = ... - return "export=" /* ExportEquals */; + return "export=" /* InternalSymbolName.ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 317 /* JSDocFunctionType */: - return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 164 /* Parameter */: + case 317 /* SyntaxKind.JSDocFunctionType */: + return (ts.isJSDocConstructSignature(node) ? "__new" /* InternalSymbolName.New */ : "__call" /* InternalSymbolName.Call */); + case 164 /* SyntaxKind.Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind), ", expected JSDocFunctionType"); }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -45249,14 +45379,14 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod, isComputedName) { ts.Debug.assert(isComputedName || !ts.hasDynamicName(node)); - var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; + var isDefaultExport = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" - var name = isComputedName ? "__computed" /* Computed */ - : isDefaultExport && parent ? "default" /* Default */ + var name = isComputedName ? "__computed" /* InternalSymbolName.Computed */ + : isDefaultExport && parent ? "default" /* InternalSymbolName.Default */ : getDeclarationName(node); var symbol; if (name === undefined) { - symbol = createSymbol(0 /* None */, "__missing" /* Missing */); + symbol = createSymbol(0 /* SymbolFlags.None */, "__missing" /* InternalSymbolName.Missing */); } else { // Check and see if the symbol table already has a symbol with this name. If not, @@ -45283,11 +45413,11 @@ var ts; // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. symbol = symbolTable.get(name); - if (includes & 2885600 /* Classifiable */) { + if (includes & 2885600 /* SymbolFlags.Classifiable */) { classifiableNames.add(name); } if (!symbol) { - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); if (isReplaceableByMethod) symbol.isReplaceableByMethod = true; } @@ -45299,20 +45429,20 @@ var ts; if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. - symbolTable.set(name, symbol = createSymbol(0 /* None */, name)); + symbolTable.set(name, symbol = createSymbol(0 /* SymbolFlags.None */, name)); } - else if (!(includes & 3 /* Variable */ && symbol.flags & 67108864 /* Assignment */)) { + else if (!(includes & 3 /* SymbolFlags.Variable */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { // Assignment declarations are allowed to merge with variables, no matter what other flags they have. if (ts.isNamedDeclaration(node)) { ts.setParent(node.name, node); } // Report errors every position with duplicate declaration // Report errors on previous encountered declarations - var message_1 = symbol.flags & 2 /* BlockScopedVariable */ + var message_1 = symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; var messageNeedsName_1 = true; - if (symbol.flags & 384 /* Enum */ || includes & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ || includes & 384 /* SymbolFlags.Enum */) { message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations; messageNeedsName_1 = false; } @@ -45332,7 +45462,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 271 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 271 /* SyntaxKind.ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -45340,9 +45470,9 @@ var ts; } } var relatedInformation_1 = []; - if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* Export */) && symbol.flags & (2097152 /* Alias */ | 788968 /* Type */ | 1920 /* Namespace */)) { + if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) && symbol.flags & (2097152 /* SymbolFlags.Alias */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { // export type T; - may have meant export type { T }? - relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }")); + relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { ".concat(ts.unescapeLeadingUnderscores(node.name.escapedText), " }"))); } var declarationName_1 = ts.getNameOfDeclaration(node) || node; ts.forEach(symbol.declarations, function (declaration, index) { @@ -45355,7 +45485,7 @@ var ts; }); var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined); file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1, false))); - symbol = createSymbol(0 /* None */, name); + symbol = createSymbol(0 /* SymbolFlags.None */, name); } } } @@ -45369,9 +45499,9 @@ var ts; return symbol; } function declareModuleMember(node, symbolFlags, symbolExcludes) { - var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* Export */) || jsdocTreatAsExported(node); - if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 275 /* ExportSpecifier */ || (node.kind === 265 /* ImportEqualsDeclaration */ && hasExportModifier)) { + var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) || jsdocTreatAsExported(node); + if (symbolFlags & 2097152 /* SymbolFlags.Alias */) { + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */ || (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -45395,11 +45525,11 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) { - if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* Default */) && !getDeclarationName(node))) { + if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* NodeFlags.ExportContext */)) { + if (!container.locals || (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } - var exportKind = symbolFlags & 111551 /* Value */ ? 1048576 /* ExportValue */ : 0; + var exportKind = symbolFlags & 111551 /* SymbolFlags.Value */ ? 1048576 /* SymbolFlags.ExportValue */ : 0; var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; @@ -45426,7 +45556,7 @@ var ts; return false; if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent)) return true; - if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* Export */) + if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1 /* ModifierFlags.Export */) return true; // This could potentially be simplified by having `delayedBindJSDocTypedefTag` pass in an override for `hasExportModifier`, since it should // already have calculated and branched on most of this. @@ -45459,21 +45589,21 @@ var ts; // reusing a node from a previous compilation, that node may have had 'locals' created // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. - if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 214 /* ArrowFunction */) { + if (containerFlags & 1 /* ContainerFlags.IsContainer */) { + if (node.kind !== 214 /* SyntaxKind.ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; - if (containerFlags & 32 /* HasLocals */) { + if (containerFlags & 32 /* ContainerFlags.HasLocals */) { container.locals = ts.createSymbolTable(); } addToContainerChain(container); } - else if (containerFlags & 2 /* IsBlockScopedContainer */) { + else if (containerFlags & 2 /* ContainerFlags.IsBlockScopedContainer */) { blockScopeContainer = node; blockScopeContainer.locals = undefined; } - if (containerFlags & 4 /* IsControlFlowContainer */) { + if (containerFlags & 4 /* ContainerFlags.IsControlFlowContainer */) { var saveCurrentFlow = currentFlow; var saveBreakTarget = currentBreakTarget; var saveContinueTarget = currentContinueTarget; @@ -45481,22 +45611,22 @@ var ts; var saveExceptionTarget = currentExceptionTarget; var saveActiveLabelList = activeLabelList; var saveHasExplicitReturn = hasExplicitReturn; - var isImmediatelyInvoked = (containerFlags & 16 /* IsFunctionExpression */ && - !ts.hasSyntacticModifier(node, 256 /* Async */) && + var isImmediatelyInvoked = (containerFlags & 16 /* ContainerFlags.IsFunctionExpression */ && + !ts.hasSyntacticModifier(node, 256 /* ModifierFlags.Async */) && !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node)) || - node.kind === 170 /* ClassStaticBlockDeclaration */; + node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isImmediatelyInvoked) { - currentFlow = initFlowNode({ flags: 2 /* Start */ }); - if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); + if (containerFlags & (16 /* ContainerFlags.IsFunctionExpression */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */)) { currentFlow.node = node; } } // 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 = isImmediatelyInvoked || node.kind === 171 /* Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) ? createBranchLabel() : undefined; + currentReturnTarget = isImmediatelyInvoked || node.kind === 171 /* SyntaxKind.Constructor */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) ? createBranchLabel() : undefined; currentExceptionTarget = undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; @@ -45504,21 +45634,21 @@ var ts; hasExplicitReturn = false; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~2816 /* ReachabilityAndEmitFlags */; - if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 256 /* HasImplicitReturn */; + node.flags &= ~2816 /* NodeFlags.ReachabilityAndEmitFlags */; + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && containerFlags & 8 /* ContainerFlags.IsFunctionLike */ && ts.nodeIsPresent(node.body)) { + node.flags |= 256 /* NodeFlags.HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 512 /* HasExplicitReturn */; + node.flags |= 512 /* NodeFlags.HasExplicitReturn */; node.endFlowNode = currentFlow; } - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { node.flags |= emitFlags; node.endFlowNode = currentFlow; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 171 /* Constructor */ || node.kind === 170 /* ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */))) { + if (node.kind === 171 /* SyntaxKind.Constructor */ || node.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */ || (ts.isInJSFile(node) && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */))) { node.returnFlowNode = currentFlow; } } @@ -45532,10 +45662,10 @@ var ts; activeLabelList = saveActiveLabelList; hasExplicitReturn = saveHasExplicitReturn; } - else if (containerFlags & 64 /* IsInterface */) { + else if (containerFlags & 64 /* ContainerFlags.IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* NodeFlags.ContainsThis */ : node.flags & ~128 /* NodeFlags.ContainsThis */; } else { bindChildren(node); @@ -45545,8 +45675,8 @@ var ts; blockScopeContainer = savedBlockScopeContainer; } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 256 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 256 /* SyntaxKind.FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -45569,59 +45699,59 @@ var ts; inAssignmentPattern = saveInAssignmentPattern; return; } - if (node.kind >= 237 /* FirstStatement */ && node.kind <= 253 /* LastStatement */ && !options.allowUnreachableCode) { + if (node.kind >= 237 /* SyntaxKind.FirstStatement */ && node.kind <= 253 /* SyntaxKind.LastStatement */ && !options.allowUnreachableCode) { node.flowNode = currentFlow; } switch (node.kind) { - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: bindWhileStatement(node); break; - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: bindDoStatement(node); break; - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: bindForStatement(node); break; - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: bindForInOrForOfStatement(node); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: bindIfStatement(node); break; - case 247 /* ReturnStatement */: - case 251 /* ThrowStatement */: + case 247 /* SyntaxKind.ReturnStatement */: + case 251 /* SyntaxKind.ThrowStatement */: bindReturnOrThrow(node); break; - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: bindTryStatement(node); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: bindSwitchStatement(node); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: bindCaseBlock(node); break; - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: bindCaseClause(node); break; - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: bindExpressionStatement(node); break; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: bindLabeledStatement(node); break; - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { // Carry over whether we are in an assignment pattern to // binary expressions that could actually be an initializer @@ -45631,47 +45761,47 @@ var ts; } bindBinaryExpressionFlow(node); break; - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bindAccessExpressionFlow(node); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bindCallExpressionFlow(node); break; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: bindNonNullExpressionFlow(node); break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 305 /* SourceFile */: { + case 305 /* SyntaxKind.SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: bindEachFunctionsFirst(node.statements); break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: bindBindingElementFlow(node); break; - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: - case 296 /* PropertyAssignment */: - case 225 /* SpreadElement */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 225 /* SyntaxKind.SpreadElement */: // Carry over whether we are in an assignment pattern of Object and Array literals // as well as their children that are valid assignment targets. inAssignmentPattern = saveInAssignmentPattern; @@ -45685,22 +45815,22 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 108 /* ThisKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 108 /* SyntaxKind.ThisKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return containsNarrowableReference(expr); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return hasNarrowableArgument(expr); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isNarrowingExpression(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 219 /* PrefixUnaryExpression */: - return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 216 /* TypeOfExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 53 /* SyntaxKind.ExclamationToken */ && isNarrowingExpression(expr.operand); + case 216 /* SyntaxKind.TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; @@ -45708,7 +45838,7 @@ var ts; function isNarrowableReference(expr) { return ts.isDottedName(expr) || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) - || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* CommaToken */ && isNarrowableReference(expr.right) + || ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isNarrowableReference(expr.right) || ts.isElementAccessExpression(expr) && (ts.isStringOrNumericLiteralLike(expr.argumentExpression) || ts.isEntityNameExpression(expr.argumentExpression)) && isNarrowableReference(expr.expression) || ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left); } @@ -45724,7 +45854,7 @@ var ts; } } } - if (expr.expression.kind === 206 /* PropertyAccessExpression */ && + if (expr.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && containsNarrowableReference(expr.expression.expression)) { return true; } @@ -45735,68 +45865,68 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return containsNarrowableReference(expr.left); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return isNarrowingExpression(expr.right); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: return isNarrowableOperand(expr.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return isNarrowableOperand(expr.right); } } return containsNarrowableReference(expr); } function createBranchLabel() { - return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); + return initFlowNode({ flags: 4 /* FlowFlags.BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); + return initFlowNode({ flags: 8 /* FlowFlags.LoopLabel */, antecedents: undefined }); } function createReduceLabel(target, antecedents, antecedent) { - return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); + return initFlowNode({ flags: 1024 /* FlowFlags.ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */; + flow.flags |= flow.flags & 2048 /* FlowFlags.Referenced */ ? 4096 /* FlowFlags.Shared */ : 2048 /* FlowFlags.Referenced */; } function addAntecedent(label, antecedent) { - if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { + if (!(antecedent.flags & 1 /* FlowFlags.Unreachable */) && !ts.contains(label.antecedents, antecedent)) { (label.antecedents || (label.antecedents = [])).push(antecedent); setFlowNodeReferenced(antecedent); } } function createFlowCondition(flags, antecedent, expression) { - if (antecedent.flags & 1 /* Unreachable */) { + if (antecedent.flags & 1 /* FlowFlags.Unreachable */) { return antecedent; } if (!expression) { - return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; + return flags & 32 /* FlowFlags.TrueCondition */ ? antecedent : unreachableFlow; } - if ((expression.kind === 110 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 95 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + if ((expression.kind === 110 /* SyntaxKind.TrueKeyword */ && flags & 64 /* FlowFlags.FalseCondition */ || + expression.kind === 95 /* SyntaxKind.FalseKeyword */ && flags & 32 /* FlowFlags.TrueCondition */) && !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } @@ -45808,7 +45938,7 @@ var ts; } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); + return initFlowNode({ flags: 128 /* FlowFlags.SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowMutation(flags, antecedent, node) { setFlowNodeReferenced(antecedent); @@ -45820,7 +45950,7 @@ var ts; } function createFlowCall(antecedent, node) { setFlowNodeReferenced(antecedent); - return initFlowNode({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + return initFlowNode({ flags: 512 /* FlowFlags.Call */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -45835,28 +45965,28 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 239 /* IfStatement */: - case 241 /* WhileStatement */: - case 240 /* DoStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: return parent.expression === node; - case 242 /* ForStatement */: - case 222 /* ConditionalExpression */: + case 242 /* SyntaxKind.ForStatement */: + case 222 /* SyntaxKind.ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 212 /* ParenthesizedExpression */) { + if (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 219 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { + else if (node.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && node.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.operand; } else { - return node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 56 /* BarBarToken */ || - node.operatorToken.kind === 60 /* QuestionQuestionToken */); + return node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || + node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */); } } } @@ -45866,7 +45996,7 @@ var ts; } function isTopLevelLogicalExpression(node) { while (ts.isParenthesizedExpression(node.parent) || - ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* SyntaxKind.ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && @@ -45885,8 +46015,8 @@ var ts; function bindCondition(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindIterativeStatement(node, breakTarget, continueTarget) { @@ -45900,7 +46030,7 @@ var ts; } function setContinueTarget(node, target) { var label = activeLabelList; - while (label && node.parent.kind === 250 /* LabeledStatement */) { + while (label && node.parent.kind === 250 /* SyntaxKind.LabeledStatement */) { label.continueTarget = target; label = label.next; node = node.parent; @@ -45951,12 +46081,12 @@ var ts; bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 244 /* ForOfStatement */) { + if (node.kind === 244 /* SyntaxKind.ForOfStatement */) { bind(node.awaitModifier); } addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 255 /* VariableDeclarationList */) { + if (node.initializer.kind !== 255 /* SyntaxKind.VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -45978,7 +46108,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 247 /* ReturnStatement */) { + if (node.kind === 247 /* SyntaxKind.ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -45995,7 +46125,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 246 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 246 /* SyntaxKind.BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -46066,7 +46196,7 @@ var ts; finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents); currentFlow = finallyLabel; bind(node.finallyBlock); - if (currentFlow.flags & 1 /* Unreachable */) { + if (currentFlow.flags & 1 /* FlowFlags.Unreachable */) { // If the end of the finally block is unreachable, the end of the entire try statement is unreachable. currentFlow = unreachableFlow; } @@ -46100,7 +46230,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 290 /* SyntaxKind.DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). Note, we no longer need // this property in control flow analysis, it's there only for backwards compatibility. @@ -46129,7 +46259,7 @@ var ts; var clause = clauses[i]; bind(clause); fallthroughFlow = currentFlow; - if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { clause.fallthroughFlowNode = currentFlow; } } @@ -46148,9 +46278,9 @@ var ts; function maybeBindExpressionFlowIfCall(node) { // A top level or comma expression call expression with a dotted function name and at least one argument // is potentially an assertion and is therefore included in the control flow. - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { var call = node; - if (call.expression.kind !== 106 /* SuperKeyword */ && ts.isDottedName(call.expression)) { + if (call.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && ts.isDottedName(call.expression)) { currentFlow = createFlowCall(currentFlow, call); } } @@ -46174,7 +46304,7 @@ var ts; currentFlow = finishFlowLabel(postStatementLabel); } function bindDestructuringTargetFlow(node) { - if (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -46183,12 +46313,12 @@ var ts; } function bindAssignmentTargetFlow(node) { if (isNarrowableReference(node)) { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } - else if (node.kind === 204 /* ArrayLiteralExpression */) { + else if (node.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 225 /* SpreadElement */) { + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -46196,16 +46326,16 @@ var ts; } } } - else if (node.kind === 205 /* ObjectLiteralExpression */) { + else if (node.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 296 /* PropertyAssignment */) { + if (p.kind === 296 /* SyntaxKind.PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 297 /* ShorthandPropertyAssignment */) { + else if (p.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 298 /* SpreadAssignment */) { + else if (p.kind === 298 /* SyntaxKind.SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -46213,7 +46343,7 @@ var ts; } function bindLogicalLikeExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* AmpersandAmpersandEqualsToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || node.operatorToken.kind === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -46224,15 +46354,15 @@ var ts; if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) { doWithConditionalBranches(bind, node.right, trueTarget, falseTarget); bindAssignmentTargetFlow(node.left); - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } else { bindCondition(node.right, trueTarget, falseTarget); } } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 53 /* ExclamationToken */) { + if (node.operator === 53 /* SyntaxKind.ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -46242,14 +46372,14 @@ var ts; } else { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } @@ -46298,9 +46428,9 @@ var ts; // we'll need to handle the `bindLogicalExpression` scenarios in this state machine, too // For now, though, since the common cases are chained `+`, leaving it recursive is fine var operator = node.operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || - operator === 56 /* BarBarToken */ || - operator === 60 /* QuestionQuestionToken */ || + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || + operator === 56 /* SyntaxKind.BarBarToken */ || + operator === 60 /* SyntaxKind.QuestionQuestionToken */ || ts.isLogicalOrCoalescingAssignmentOperator(operator)) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); @@ -46317,7 +46447,7 @@ var ts; function onLeft(left, state, node) { if (!state.skip) { var maybeBound = maybeBind(left); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(left); } return maybeBound; @@ -46331,7 +46461,7 @@ var ts; function onRight(right, state, node) { if (!state.skip) { var maybeBound = maybeBind(right); - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { maybeBindExpressionFlowIfCall(right); } return maybeBound; @@ -46342,10 +46472,10 @@ var ts; var operator = node.operatorToken.kind; if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 63 /* EqualsToken */ && node.left.kind === 207 /* ElementAccessExpression */) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && node.left.kind === 207 /* SyntaxKind.ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } @@ -46370,7 +46500,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -46398,7 +46528,7 @@ var ts; } } else { - currentFlow = createFlowMutation(16 /* Assignment */, currentFlow, node); + currentFlow = createFlowMutation(16 /* FlowFlags.Assignment */, currentFlow, node); } } function bindVariableDeclarationFlow(node) { @@ -46425,7 +46555,7 @@ var ts; } function bindJSDocTypeAlias(node) { bind(node.tagName); - if (node.kind !== 339 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 339 /* SyntaxKind.JSDocEnumTag */ && node.fullName) { // don't bind the type name yet; that's delayed until delayedBindJSDocTypedefTag ts.setParent(node.fullName, node); ts.setParentRecursive(node.fullName, /*incremental*/ false); @@ -46437,28 +46567,28 @@ var ts; function bindJSDocClassTag(node) { bindEachChild(node); var host = ts.getHostSignatureFromJSDoc(node); - if (host && host.kind !== 169 /* MethodDeclaration */) { - addDeclarationToSymbol(host.symbol, host, 32 /* Class */); + if (host && host.kind !== 169 /* SyntaxKind.MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* SymbolFlags.Class */); } } function bindOptionalExpression(node, trueTarget, falseTarget) { doWithConditionalBranches(bind, node, trueTarget, falseTarget); if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainRest(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: bind(node.questionDotToken); bind(node.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: bind(node.questionDotToken); bind(node.argumentExpression); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); @@ -46484,8 +46614,8 @@ var ts; } doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); if (ts.isOutermostOptionalChain(node)) { - addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); - addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + addAntecedent(trueTarget, createFlowCondition(32 /* FlowFlags.TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FlowFlags.FalseCondition */, currentFlow, node)); } } function bindOptionalChainFlow(node) { @@ -46523,76 +46653,76 @@ var ts; // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = ts.skipParentheses(node.expression); - if (expr.kind === 213 /* FunctionExpression */ || expr.kind === 214 /* ArrowFunction */) { + if (expr.kind === 213 /* SyntaxKind.FunctionExpression */ || expr.kind === 214 /* SyntaxKind.ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); } else { bindEachChild(node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { currentFlow = createFlowCall(currentFlow, node); } } } - if (node.expression.kind === 206 /* PropertyAccessExpression */) { + if (node.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { var propertyAccess = node.expression; if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { - currentFlow = createFlowMutation(256 /* ArrayMutation */, currentFlow, node); + currentFlow = createFlowMutation(256 /* FlowFlags.ArrayMutation */, currentFlow, node); } } } function getContainerFlags(node) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 205 /* ObjectLiteralExpression */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 286 /* JsxAttributes */: - return 1 /* IsContainer */; - case 258 /* InterfaceDeclaration */: - return 1 /* IsContainer */ | 64 /* IsInterface */; - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: - case 176 /* IndexSignature */: - return 1 /* IsContainer */ | 32 /* HasLocals */; - case 305 /* SourceFile */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 286 /* SyntaxKind.JsxAttributes */: + return 1 /* ContainerFlags.IsContainer */; + case 258 /* SyntaxKind.InterfaceDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 64 /* ContainerFlags.IsInterface */; + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: + case 176 /* SyntaxKind.IndexSignature */: + return 1 /* ContainerFlags.IsContainer */ | 32 /* ContainerFlags.HasLocals */; + case 305 /* SyntaxKind.SourceFile */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethodOrAccessor */; + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 128 /* ContainerFlags.IsObjectLiteralOrClassExpressionMethodOrAccessor */; } // falls through - case 171 /* Constructor */: - case 256 /* FunctionDeclaration */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 323 /* JSDocSignature */: - case 317 /* JSDocFunctionType */: - case 179 /* FunctionType */: - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: - case 170 /* ClassStaticBlockDeclaration */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 262 /* ModuleBlock */: - return 4 /* IsControlFlowContainer */; - case 167 /* PropertyDeclaration */: - return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 292 /* CatchClause */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: - case 263 /* CaseBlock */: - return 2 /* IsBlockScopedContainer */; - case 235 /* Block */: + case 171 /* SyntaxKind.Constructor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 179 /* SyntaxKind.FunctionType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */; + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + return 1 /* ContainerFlags.IsContainer */ | 4 /* ContainerFlags.IsControlFlowContainer */ | 32 /* ContainerFlags.HasLocals */ | 8 /* ContainerFlags.IsFunctionLike */ | 16 /* ContainerFlags.IsFunctionExpression */; + case 262 /* SyntaxKind.ModuleBlock */: + return 4 /* ContainerFlags.IsControlFlowContainer */; + case 167 /* SyntaxKind.PropertyDeclaration */: + return node.initializer ? 4 /* ContainerFlags.IsControlFlowContainer */ : 0; + case 292 /* SyntaxKind.CatchClause */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 263 /* SyntaxKind.CaseBlock */: + return 2 /* ContainerFlags.IsBlockScopedContainer */; + case 235 /* SyntaxKind.Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -46609,9 +46739,9 @@ var ts; // By not creating a new block-scoped-container here, we ensure that both 'var x' // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. - return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; + return ts.isFunctionLike(node.parent) || ts.isClassStaticBlockDeclaration(node.parent) ? 0 /* ContainerFlags.None */ : 2 /* ContainerFlags.IsBlockScopedContainer */; } - return 0 /* None */; + return 0 /* ContainerFlags.None */; } function addToContainerChain(next) { if (lastContainer) { @@ -46625,46 +46755,46 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 205 /* ObjectLiteralExpression */: - case 258 /* InterfaceDeclaration */: - case 286 /* JsxAttributes */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 286 /* SyntaxKind.JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 323 /* JSDocSignature */: - case 176 /* IndexSignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 317 /* JSDocFunctionType */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 170 /* ClassStaticBlockDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 195 /* MappedType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 323 /* SyntaxKind.JSDocSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 195 /* SyntaxKind.MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -46691,17 +46821,17 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 64 /* ExportContext */; + if (node.flags & 16777216 /* NodeFlags.Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* NodeFlags.ExportContext */; } else { - node.flags &= ~64 /* ExportContext */; + node.flags &= ~64 /* NodeFlags.ExportContext */; } } function bindModuleDeclaration(node) { setExportContextFlag(node); if (ts.isAmbientModule(node)) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible); } if (ts.isModuleAugmentationExternal(node)) { @@ -46709,25 +46839,25 @@ var ts; } else { var pattern = void 0; - if (node.name.kind === 10 /* StringLiteral */) { + if (node.name.kind === 10 /* SyntaxKind.StringLiteral */) { var text = node.name.text; pattern = ts.tryParsePattern(text); if (pattern === undefined) { errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text); } } - var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* ValueModule */, 110735 /* ValueModuleExcludes */); + var symbol = declareSymbolAndAddToSymbolTable(node, 512 /* SymbolFlags.ValueModule */, 110735 /* SymbolFlags.ValueModuleExcludes */); file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && !ts.isString(pattern) ? { pattern: pattern, symbol: symbol } : undefined); } } else { var state = declareModuleSymbol(node); - if (state !== 0 /* NonInstantiated */) { + if (state !== 0 /* ModuleInstanceState.NonInstantiated */) { var symbol = node.symbol; // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only - symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* Function */ | 32 /* Class */ | 256 /* RegularEnum */))) + symbol.constEnumOnlyModule = (!(symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 256 /* SymbolFlags.RegularEnum */))) // Current must be `const enum` only - && state === 2 /* ConstEnumOnly */ + && state === 2 /* ModuleInstanceState.ConstEnumOnly */ // Can't have been set to 'false' in a previous merged symbol. ('undefined' OK) && symbol.constEnumOnlyModule !== false; } @@ -46735,8 +46865,8 @@ var ts; } function declareModuleSymbol(node) { var state = getModuleInstanceState(node); - var instantiated = state !== 0 /* NonInstantiated */; - declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* ValueModule */ : 1024 /* NamespaceModule */, instantiated ? 110735 /* ValueModuleExcludes */ : 0 /* NamespaceModuleExcludes */); + var instantiated = state !== 0 /* ModuleInstanceState.NonInstantiated */; + declareSymbolAndAddToSymbolTable(node, instantiated ? 512 /* SymbolFlags.ValueModule */ : 1024 /* SymbolFlags.NamespaceModule */, instantiated ? 110735 /* SymbolFlags.ValueModuleExcludes */ : 0 /* SymbolFlags.NamespaceModuleExcludes */); return state; } function bindFunctionOrConstructorType(node) { @@ -46746,56 +46876,25 @@ var ts; // We do that by making an anonymous type literal symbol, and then setting the function // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. - var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); // TODO: GH#18217 - addDeclarationToSymbol(symbol, node, 131072 /* Signature */); - var typeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); - addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* TypeLiteral */); + var symbol = createSymbol(131072 /* SymbolFlags.Signature */, getDeclarationName(node)); // TODO: GH#18217 + addDeclarationToSymbol(symbol, node, 131072 /* SymbolFlags.Signature */); + var typeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); + addDeclarationToSymbol(typeLiteralSymbol, node, 2048 /* SymbolFlags.TypeLiteral */); typeLiteralSymbol.members = ts.createSymbolTable(); typeLiteralSymbol.members.set(symbol.escapedName, symbol); } function bindObjectLiteralExpression(node) { - var ElementKind; - (function (ElementKind) { - ElementKind[ElementKind["Property"] = 1] = "Property"; - ElementKind[ElementKind["Accessor"] = 2] = "Accessor"; - })(ElementKind || (ElementKind = {})); - if (inStrictMode && !ts.isAssignmentTarget(node)) { - var seen = new ts.Map(); - for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { - var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */ || prop.name.kind !== 79 /* Identifier */) { - continue; - } - var identifier = prop.name; - // ECMA-262 11.1.5 Object Initializer - // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true - // a.This production is contained in strict code and IsDataDescriptor(previous) is true and - // IsDataDescriptor(propId.descriptor) is true. - // b.IsDataDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true. - // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. - // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true - // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 296 /* PropertyAssignment */ || prop.kind === 297 /* ShorthandPropertyAssignment */ || prop.kind === 169 /* MethodDeclaration */ - ? 1 /* Property */ - : 2 /* Accessor */; - var existingKind = seen.get(identifier.escapedText); - if (!existingKind) { - seen.set(identifier.escapedText, currentKind); - continue; - } - } - } - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object" /* Object */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__object" /* InternalSymbolName.Object */); } function bindJsxAttributes(node) { - return bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__jsxAttributes" /* JSXAttributes */); + return bindAnonymousDeclaration(node, 4096 /* SymbolFlags.ObjectLiteral */, "__jsxAttributes" /* InternalSymbolName.JSXAttributes */); } function bindJsxAttribute(node, symbolFlags, symbolExcludes) { return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); - if (symbolFlags & (8 /* EnumMember */ | 106500 /* ClassMember */)) { + if (symbolFlags & (8 /* SymbolFlags.EnumMember */ | 106500 /* SymbolFlags.ClassMember */)) { symbol.parent = container.symbol; } addDeclarationToSymbol(symbol, node, symbolFlags); @@ -46803,10 +46902,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -46832,9 +46931,9 @@ var ts; for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) { var typeAlias = delayedTypeAliases_1[_i]; var host = typeAlias.parent.parent; - container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; + container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* ContainerFlags.IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = initFlowNode({ flags: 2 /* Start */ }); + currentFlow = initFlowNode({ flags: 2 /* FlowFlags.Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -46845,8 +46944,8 @@ var ts; bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { - case 1 /* ExportsProperty */: - case 2 /* ModuleExports */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: if (!ts.isExternalOrCommonJsModule(file)) { container = undefined; } @@ -46854,29 +46953,29 @@ var ts; container = file; } break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: container = declName.parent.expression; break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: container = declName.parent.expression.name; break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name : declName.parent.expression; break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } if (container) { - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + declareModuleMember(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 79 /* SyntaxKind.Identifier */) { parent = typeAlias.parent; - bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(typeAlias, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); } else { bind(typeAlias.fullName); @@ -46894,24 +46993,24 @@ var ts; function checkContextualIdentifier(node) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length && - !(node.flags & 16777216 /* Ambient */) && - !(node.flags & 8388608 /* JSDoc */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && + !(node.flags & 8388608 /* NodeFlags.JSDoc */) && !ts.isIdentifierName(node)) { // strict mode identifiers if (inStrictMode && - node.originalKeywordKind >= 117 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 125 /* LastFutureReservedWord */) { + node.originalKeywordKind >= 117 /* SyntaxKind.FirstFutureReservedWord */ && + node.originalKeywordKind <= 125 /* SyntaxKind.LastFutureReservedWord */) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } - else if (node.originalKeywordKind === 132 /* AwaitKeyword */) { + else if (node.originalKeywordKind === 132 /* SyntaxKind.AwaitKeyword */) { if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node))); } - else if (node.flags & 32768 /* AwaitContext */) { + else if (node.flags & 32768 /* NodeFlags.AwaitContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } - else if (node.originalKeywordKind === 125 /* YieldKeyword */ && node.flags & 8192 /* YieldContext */) { + else if (node.originalKeywordKind === 125 /* SyntaxKind.YieldKeyword */ && node.flags & 8192 /* NodeFlags.YieldContext */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node))); } } @@ -46953,7 +47052,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 79 /* Identifier */) { + if (inStrictMode && node.expression.kind === 79 /* SyntaxKind.Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -46964,7 +47063,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 79 /* Identifier */) { + if (name && name.kind === 79 /* SyntaxKind.Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -47003,10 +47102,10 @@ var ts; return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5; } function checkStrictModeFunctionDeclaration(node) { - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 305 /* SourceFile */ && - blockScopeContainer.kind !== 261 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 305 /* SyntaxKind.SourceFile */ && + blockScopeContainer.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isFunctionLikeOrClassStaticBlockDeclaration(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -47016,7 +47115,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (languageVersion < 1 /* ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* Octal */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */ && inStrictMode && node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -47032,7 +47131,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -47045,7 +47144,7 @@ var ts; } function checkStrictModeLabeledStatement(node) { // Grammar checking for labeledStatement - if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ES2015 */) { + if (inStrictMode && ts.getEmitScriptTarget(options) >= 2 /* ScriptTarget.ES2015 */) { if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) { errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here); } @@ -47103,11 +47202,11 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 160 /* LastToken */) { + if (node.kind > 160 /* SyntaxKind.LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); - if (containerFlags === 0 /* None */) { + if (containerFlags === 0 /* ContainerFlags.None */) { bindChildren(node); } else { @@ -47117,7 +47216,7 @@ var ts; } else { var saveParent = parent; - if (node.kind === 1 /* EndOfFileToken */) + if (node.kind === 1 /* SyntaxKind.EndOfFileToken */) parent = node; bindJSDoc(node); parent = saveParent; @@ -47165,7 +47264,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -47174,28 +47273,28 @@ var ts; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { parentNode = parentNode.parent; } - bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + bindBlockScopedDeclaration(parentNode, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); break; } // falls through - case 108 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* ShorthandPropertyAssignment */)) { + case 108 /* SyntaxKind.ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkContextualIdentifier(node); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: if (currentFlow && ts.isPartOfTypeQuery(node)) { node.flowNode = currentFlow; } break; - case 231 /* MetaProperty */: - case 106 /* SuperKeyword */: + case 231 /* SyntaxKind.MetaProperty */: + case 106 /* SyntaxKind.SuperKeyword */: node.flowNode = currentFlow; break; - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifier(node); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node; if (currentFlow && isNarrowableReference(expr)) { expr.flowNode = currentFlow; @@ -47207,28 +47306,28 @@ var ts; file.commonJsModuleIndicator && ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForName(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* SymbolFlags.FunctionScopedVariable */ | 134217728 /* SymbolFlags.ModuleExports */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { - case 1 /* ExportsProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: bindExportsPropertyAssignment(node); break; - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: bindModuleExportsAssignment(node); break; - case 3 /* PrototypeProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: bindPrototypePropertyAssignment(node.left, node); break; - case 6 /* Prototype */: + case 6 /* AssignmentDeclarationKind.Prototype */: bindPrototypeAssignment(node); break; - case 4 /* ThisProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: bindThisPropertyAssignment(node); break; - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: var expression = node.left.expression; if (ts.isInJSFile(node) && ts.isIdentifier(expression)) { var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText); @@ -47239,94 +47338,94 @@ var ts; } bindSpecialPropertyAssignment(node); break; - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: // Nothing to do break; default: ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return checkStrictModeCatchClause(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkStrictModeDeleteExpression(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkStrictModeWithStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: seenThisKeyword = true; return; - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: break; // Binding the children will handle everything - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return bindTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return bindParameter(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return bindPropertyWorker(node); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 299 /* EnumMember */: - return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: - return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); + case 299 /* SyntaxKind.EnumMember */: + return bindPropertyOrMethodOrAccessor(node, 8 /* SymbolFlags.EnumMember */, 900095 /* SymbolFlags.EnumMemberExcludes */); + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: + return declareSymbolAndAddToSymbolTable(node, 131072 /* SymbolFlags.Signature */, 0 /* SymbolFlags.None */); + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. - return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 256 /* FunctionDeclaration */: + return bindPropertyOrMethodOrAccessor(node, 8192 /* SymbolFlags.Method */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), ts.isObjectLiteralMethod(node) ? 0 /* SymbolFlags.PropertyExcludes */ : 103359 /* SymbolFlags.MethodExcludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: return bindFunctionDeclaration(node); - case 171 /* Constructor */: - return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 172 /* GetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 173 /* SetAccessor */: - return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 179 /* FunctionType */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: - case 180 /* ConstructorType */: + case 171 /* SyntaxKind.Constructor */: + return declareSymbolAndAddToSymbolTable(node, 16384 /* SymbolFlags.Constructor */, /*symbolExcludes:*/ 0 /* SymbolFlags.None */); + case 172 /* SyntaxKind.GetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 32768 /* SymbolFlags.GetAccessor */, 46015 /* SymbolFlags.GetAccessorExcludes */); + case 173 /* SyntaxKind.SetAccessor */: + return bindPropertyOrMethodOrAccessor(node, 65536 /* SymbolFlags.SetAccessor */, 78783 /* SymbolFlags.SetAccessorExcludes */); + case 179 /* SyntaxKind.FunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: + case 180 /* SyntaxKind.ConstructorType */: return bindFunctionOrConstructorType(node); - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 195 /* MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 195 /* SyntaxKind.MappedType */: return bindAnonymousTypeWorker(node); - case 332 /* JSDocClassTag */: + case 332 /* SyntaxKind.JSDocClassTag */: return bindJSDocClassTag(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return bindFunctionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { - case 7 /* ObjectDefinePropertyValue */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: return bindObjectDefinePropertyAssignment(node); - case 8 /* ObjectDefinePropertyExports */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: return bindObjectDefinePropertyExport(node); - case 9 /* ObjectDefinePrototypeProperty */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return bindObjectDefinePrototypeProperty(node); - case 0 /* None */: + case 0 /* AssignmentDeclarationKind.None */: break; // Nothing to do default: return ts.Debug.fail("Unknown call expression assignment declaration kind"); @@ -47336,73 +47435,73 @@ var ts; } break; // Members of classes, interfaces, and modules - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 258 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 259 /* TypeAliasDeclaration */: - return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 260 /* EnumDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* SymbolFlags.Interface */, 788872 /* SymbolFlags.InterfaceExcludes */); + case 259 /* SyntaxKind.TypeAliasDeclaration */: + return bindBlockScopedDeclaration(node, 524288 /* SymbolFlags.TypeAlias */, 788968 /* SymbolFlags.TypeAliasExcludes */); + case 260 /* SyntaxKind.EnumDeclaration */: return bindEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return bindJsxAttributes(node); - case 285 /* JsxAttribute */: - return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); + case 285 /* SyntaxKind.JsxAttribute */: + return bindJsxAttribute(node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.PropertyExcludes */); // Imports and exports - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: - return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 264 /* NamespaceExportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: + return declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return bindImportClause(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return bindExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return bindExportAssignment(node); - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: if (!ts.isFunctionLikeOrClassStaticBlockDeclaration(node.parent)) { return; } // falls through - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 340 /* JSDocParameterTag */: - if (node.parent.kind === 323 /* JSDocSignature */) { + case 340 /* SyntaxKind.JSDocParameterTag */: + if (node.parent.kind === 323 /* SyntaxKind.JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 322 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 322 /* SyntaxKind.JSDocTypeLiteral */) { break; } // falls through - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* JSDocOptionalType */ ? - 4 /* Property */ | 16777216 /* Optional */ : - 4 /* Property */; - return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ ? + 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */ : + 4 /* SymbolFlags.Property */; + return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* SymbolFlags.PropertyExcludes */); + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } function bindPropertyWorker(node) { - return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + return bindPropertyOrMethodOrAccessor(node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } function bindAnonymousTypeWorker(node) { - return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type" /* Type */); + return bindAnonymousDeclaration(node, 2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); } function bindSourceFileIfExternalModule() { setExportContextFlag(file); @@ -47413,27 +47512,27 @@ var ts; bindSourceFileAsExternalModule(); // Create symbol equivalent for the module.exports = {} var originalSymbol = file.symbol; - declareSymbol(file.symbol.exports, file.symbol, file, 4 /* Property */, 67108863 /* All */); + declareSymbol(file.symbol.exports, file.symbol, file, 4 /* SymbolFlags.Property */, 67108863 /* SymbolFlags.All */); file.symbol = originalSymbol; } } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, 512 /* ValueModule */, "\"" + ts.removeFileExtension(file.fileName) + "\""); + bindAnonymousDeclaration(file, 512 /* SymbolFlags.ValueModule */, "\"".concat(ts.removeFileExtension(file.fileName), "\"")); } function bindExportAssignment(node) { if (!container.symbol || !container.symbol.exports) { // Incorrect export assignment in some sort of block construct - bindAnonymousDeclaration(node, 111551 /* Value */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 111551 /* SymbolFlags.Value */, getDeclarationName(node)); } else { var flags = ts.exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression or a class expression exports all meanings of that identifier or expression; - ? 2097152 /* Alias */ + ? 2097152 /* SymbolFlags.Alias */ // An export default clause with any other expression exports a value - : 4 /* Property */; + : 4 /* SymbolFlags.Property */; // If there is an `export default x;` alias declaration, can't `export default` anything else. // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) - var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); + var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* SymbolFlags.All */); if (node.isExportEquals) { // Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set. ts.setValueDeclaration(symbol, node); @@ -47453,28 +47552,28 @@ var ts; } else { file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable(); - declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindExportDeclaration(node) { if (!container.symbol || !container.symbol.exports) { // Export * in some sort of block construct - bindAnonymousDeclaration(node, 8388608 /* ExportStar */, getDeclarationName(node)); + bindAnonymousDeclaration(node, 8388608 /* SymbolFlags.ExportStar */, getDeclarationName(node)); } else if (!node.exportClause) { // All export * declarations are collected in an __export symbol - declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* ExportStar */, 0 /* None */); + declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* SymbolFlags.ExportStar */, 0 /* SymbolFlags.None */); } else if (ts.isNamespaceExport(node.exportClause)) { // declareSymbol walks up parents to find name text, parent _must_ be set // but won't be set by the normal binder walk until `bindChildren` later on. ts.setParent(node.exportClause, node); - declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function bindImportClause(node) { if (node.name) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } } function setCommonJsModuleIndicator(node) { @@ -47495,13 +47594,13 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.arguments[0], /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { - var flags = 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, node, flags, 0 /* None */); + var flags = 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; + declareSymbol(symbol.exports, symbol, node, flags, 0 /* SymbolFlags.None */); } } function bindExportsPropertyAssignment(node) { @@ -47512,15 +47611,15 @@ var ts; } var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { - addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); + addDeclarationToSymbol(symbol, id, 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */); } return symbol; }); if (symbol) { var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression)); - var flags = isAlias ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */; + var flags = isAlias ? 2097152 /* SymbolFlags.Alias */ : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */; ts.setParent(node.left, node); - declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* SymbolFlags.None */); } } function bindModuleExportsAssignment(node) { @@ -47541,13 +47640,13 @@ var ts; } // 'module.exports = expr' assignment var flags = ts.exportAssignmentIsAlias(node) - ? 2097152 /* Alias */ - : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + ? 2097152 /* SymbolFlags.Alias */ + : 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */ | 512 /* SymbolFlags.ValueModule */; + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); ts.setValueDeclaration(symbol, node); } function bindExportAssignedObjectMemberAlias(node) { - declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* Alias */ | 67108864 /* Assignment */, 0 /* None */); + declareSymbol(file.symbol.exports, file.symbol, node, 2097152 /* SymbolFlags.Alias */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); @@ -47559,11 +47658,11 @@ var ts; } var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var l = thisContainer.parent.left; if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); @@ -47577,17 +47676,17 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol, constructorSymbol.members); } else { - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.PropertyExcludes */ & ~4 /* SymbolFlags.Property */); } - addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } break; - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; @@ -47596,19 +47695,19 @@ var ts; bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol, symbolTable); } else { - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true); } break; - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (ts.hasDynamicName(node)) { break; } else if (thisContainer.commonJsModuleIndicator) { - declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); + declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* SymbolFlags.Property */ | 1048576 /* SymbolFlags.ExportValue */, 0 /* SymbolFlags.None */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } break; default: @@ -47616,7 +47715,7 @@ var ts; } } function bindDynamicallyNamedThisPropertyAssignment(node, symbol, symbolTable) { - declareSymbol(symbolTable, symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); + declareSymbol(symbolTable, symbol, node, 4 /* SymbolFlags.Property */, 0 /* SymbolFlags.None */, /*isReplaceableByMethod*/ true, /*isComputedName*/ true); addLateBoundAssignmentDeclarationToSymbol(node, symbol); } function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { @@ -47625,10 +47724,10 @@ var ts; } } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 108 /* ThisKeyword */) { + if (node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -47647,7 +47746,7 @@ var ts; var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); if (namespaceSymbol && namespaceSymbol.valueDeclaration) { // Ensure the namespace symbol becomes class-like - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } @@ -47668,7 +47767,7 @@ var ts; } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 305 /* SourceFile */; + var isToplevel = node.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } @@ -47680,7 +47779,7 @@ var ts; return; } var rootExpr = ts.getLeftmostAccessExpression(node.left); - if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* Alias */) { + if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152 /* SymbolFlags.Alias */) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them @@ -47693,7 +47792,7 @@ var ts; bindExportsPropertyAssignment(node); } else if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + bindAnonymousDeclaration(node, 4 /* SymbolFlags.Property */ | 67108864 /* SymbolFlags.Assignment */, "__computed" /* InternalSymbolName.Computed */); var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); addLateBoundAssignmentDeclarationToSymbol(node, sym); } @@ -47711,13 +47810,13 @@ var ts; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { - if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* Alias */) { + if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152 /* SymbolFlags.Alias */) { return namespaceSymbol; } if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers - var flags_2 = 1536 /* Module */ | 67108864 /* Assignment */; - var excludeFlags_1 = 110735 /* ValueModuleExcludes */ & ~67108864 /* Assignment */; + var flags_2 = 1536 /* SymbolFlags.Module */ | 67108864 /* SymbolFlags.Assignment */; + var excludeFlags_1 = 110735 /* SymbolFlags.ValueModuleExcludes */ & ~67108864 /* SymbolFlags.Assignment */; namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) { if (symbol) { addDeclarationToSymbol(symbol, id, flags_2); @@ -47731,7 +47830,7 @@ var ts; }); } if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { - addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* SymbolFlags.Class */); } return namespaceSymbol; } @@ -47743,12 +47842,12 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var includes = 0 /* None */; - var excludes = 0 /* None */; + var includes = 0 /* SymbolFlags.None */; + var excludes = 0 /* SymbolFlags.None */; // Method-like if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { - includes = 8192 /* Method */; - excludes = 103359 /* MethodExcludes */; + includes = 8192 /* SymbolFlags.Method */; + excludes = 103359 /* SymbolFlags.MethodExcludes */; } // Maybe accessor-like else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { @@ -47758,27 +47857,27 @@ var ts; })) { // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) - includes |= 65536 /* SetAccessor */ | 4 /* Property */; - excludes |= 78783 /* SetAccessorExcludes */; + includes |= 65536 /* SymbolFlags.SetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 78783 /* SymbolFlags.SetAccessorExcludes */; } if (ts.some(declaration.arguments[2].properties, function (p) { var id = ts.getNameOfDeclaration(p); return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; })) { - includes |= 32768 /* GetAccessor */ | 4 /* Property */; - excludes |= 46015 /* GetAccessorExcludes */; + includes |= 32768 /* SymbolFlags.GetAccessor */ | 4 /* SymbolFlags.Property */; + excludes |= 46015 /* SymbolFlags.GetAccessorExcludes */; } } - if (includes === 0 /* None */) { - includes = 4 /* Property */; - excludes = 0 /* PropertyExcludes */; + if (includes === 0 /* SymbolFlags.None */) { + includes = 4 /* SymbolFlags.Property */; + excludes = 0 /* SymbolFlags.PropertyExcludes */; } - declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); + declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* SymbolFlags.Assignment */, excludes & ~67108864 /* SymbolFlags.Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SourceFile */ - : propertyAccess.parent.parent.kind === 305 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 305 /* SyntaxKind.SourceFile */ + : propertyAccess.parent.parent.kind === 305 /* SyntaxKind.SourceFile */; } function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer); @@ -47797,7 +47896,7 @@ var ts; * - with non-empty object literals if assigned to the prototype property */ function isExpandoSymbol(symbol) { - if (symbol.flags & (16 /* Function */ | 32 /* Class */ | 1024 /* NamespaceModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 32 /* SymbolFlags.Class */ | 1024 /* SymbolFlags.NamespaceModule */)) { return true; } var node = symbol.valueDeclaration; @@ -47812,7 +47911,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || init.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -47857,12 +47956,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 257 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); + if (node.kind === 257 /* SyntaxKind.ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* SymbolFlags.Class */, 899503 /* SymbolFlags.ClassExcludes */); } else { - var bindingName = node.name ? node.name.escapedText : "__class" /* Class */; - bindAnonymousDeclaration(node, 32 /* Class */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__class" /* InternalSymbolName.Class */; + bindAnonymousDeclaration(node, 32 /* SymbolFlags.Class */, bindingName); // Add name of class expression into the map for semantic classifier if (node.name) { classifiableNames.add(node.name.escapedText); @@ -47878,7 +47977,7 @@ var ts; // Note: we check for this here because this class may be merging into a module. The // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. - var prototypeSymbol = createSymbol(4 /* Property */ | 4194304 /* Prototype */, "prototype"); + var prototypeSymbol = createSymbol(4 /* SymbolFlags.Property */ | 4194304 /* SymbolFlags.Prototype */, "prototype"); var symbolExport = symbol.exports.get(prototypeSymbol.escapedName); if (symbolExport) { if (node.name) { @@ -47891,23 +47990,23 @@ var ts; } function bindEnumDeclaration(node) { return ts.isEnumConst(node) - ? bindBlockScopedDeclaration(node, 128 /* ConstEnum */, 899967 /* ConstEnumExcludes */) - : bindBlockScopedDeclaration(node, 256 /* RegularEnum */, 899327 /* RegularEnumExcludes */); + ? bindBlockScopedDeclaration(node, 128 /* SymbolFlags.ConstEnum */, 899967 /* SymbolFlags.ConstEnumExcludes */) + : bindBlockScopedDeclaration(node, 256 /* SymbolFlags.RegularEnum */, 899327 /* SymbolFlags.RegularEnumExcludes */); } function bindVariableDeclarationOrBindingElement(node) { if (inStrictMode) { checkStrictModeEvalOrArguments(node, node.name); } if (!ts.isBindingPattern(node.name)) { - var possibleVariableDecl = node.kind === 254 /* VariableDeclaration */ ? node : node.parent.parent; + var possibleVariableDecl = node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? node : node.parent.parent; if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !ts.getJSDocTypeTag(node) && - !(ts.getCombinedModifierFlags(node) & 1 /* Export */)) { - declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); + !(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */)) { + declareSymbolAndAddToSymbolTable(node, 2097152 /* SymbolFlags.Alias */, 2097152 /* SymbolFlags.AliasExcludes */); } else if (ts.isBlockOrCatchScoped(node)) { - bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */); + bindBlockScopedDeclaration(node, 2 /* SymbolFlags.BlockScopedVariable */, 111551 /* SymbolFlags.BlockScopedVariableExcludes */); } else if (ts.isParameterDeclaration(node)) { // It is safe to walk up parent chain to find whether the node is a destructuring parameter declaration @@ -47919,72 +48018,72 @@ var ts; // function foo([a,a]) {} // Duplicate Identifier error // function bar(a,a) {} // Duplicate Identifier error, parameter declaration in this case is handled in bindParameter // // which correctly set excluded symbols - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111550 /* SymbolFlags.FunctionScopedVariableExcludes */); } } } function bindParameter(node) { - if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) { + if (node.kind === 340 /* SyntaxKind.JSDocParameterTag */ && container.kind !== 323 /* SyntaxKind.JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) { + if (inStrictMode && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { - bindAnonymousDeclaration(node, 1 /* FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); + bindAnonymousDeclaration(node, 1 /* SymbolFlags.FunctionScopedVariable */, "__" + node.parent.parameters.indexOf(node)); } else { - declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 111551 /* ParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 1 /* SymbolFlags.FunctionScopedVariable */, 111551 /* SymbolFlags.ParameterExcludes */); } // If this is a property-parameter, then also declare the property symbol into the // containing class. if (ts.isParameterPropertyDeclaration(node, node.parent)) { var classDeclaration = node.parent.parent; - declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); + declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* SymbolFlags.Property */ | (node.questionToken ? 16777216 /* SymbolFlags.Optional */ : 0 /* SymbolFlags.None */), 0 /* SymbolFlags.PropertyExcludes */); } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } checkStrictModeFunctionName(node); if (inStrictMode) { checkStrictModeFunctionDeclaration(node); - bindBlockScopedDeclaration(node, 16 /* Function */, 110991 /* FunctionExcludes */); + bindBlockScopedDeclaration(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 110991 /* FunctionExcludes */); + declareSymbolAndAddToSymbolTable(node, 16 /* SymbolFlags.Function */, 110991 /* SymbolFlags.FunctionExcludes */); } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } } if (currentFlow) { node.flowNode = currentFlow; } checkStrictModeFunctionName(node); - var bindingName = node.name ? node.name.escapedText : "__function" /* Function */; - return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + var bindingName = node.name ? node.name.escapedText : "__function" /* InternalSymbolName.Function */; + return bindAnonymousDeclaration(node, 16 /* SymbolFlags.Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 2048 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* NodeFlags.HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) { node.flowNode = currentFlow; } return ts.hasDynamicName(node) - ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* Computed */) + ? bindAnonymousDeclaration(node, symbolFlags, "__computed" /* InternalSymbolName.Computed */) : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes); } function getInferTypeContainer(node) { @@ -47998,45 +48097,45 @@ var ts; if (!container_1.locals) { container_1.locals = ts.createSymbolTable(); } - declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_1.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } - else if (node.parent.kind === 190 /* InferType */) { + else if (node.parent.kind === 190 /* SyntaxKind.InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { container_2.locals = ts.createSymbolTable(); } - declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbol(container_2.locals, /*parent*/ undefined, node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } else { - bindAnonymousDeclaration(node, 262144 /* TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 + bindAnonymousDeclaration(node, 262144 /* SymbolFlags.TypeParameter */, getDeclarationName(node)); // TODO: GH#18217 } } else { - declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); + declareSymbolAndAddToSymbolTable(node, 262144 /* SymbolFlags.TypeParameter */, 526824 /* SymbolFlags.TypeParameterExcludes */); } } // reachability checks function shouldReportErrorOnModuleDeclaration(node) { var instanceState = getModuleInstanceState(node); - return instanceState === 1 /* Instantiated */ || (instanceState === 2 /* ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); + return instanceState === 1 /* ModuleInstanceState.Instantiated */ || (instanceState === 2 /* ModuleInstanceState.ConstEnumOnly */ && ts.shouldPreserveConstEnums(options)); } function checkUnreachable(node) { - if (!(currentFlow.flags & 1 /* Unreachable */)) { + if (!(currentFlow.flags & 1 /* FlowFlags.Unreachable */)) { return false; } if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 236 /* SyntaxKind.EmptyStatement */) || // report error on class declarations - node.kind === 257 /* ClassDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 261 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 261 /* SyntaxKind.ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -48050,9 +48149,9 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 16777216 /* Ambient */) && + !(node.flags & 16777216 /* NodeFlags.Ambient */) && (!ts.isVariableStatement(node) || - !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || + !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* NodeFlags.BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); }); } @@ -48076,27 +48175,28 @@ var ts; // Don't remove statements that can validly be used before they appear. return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) && // `var x;` may declare a variable used above - !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* Let */ | 2 /* Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); + !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 /* NodeFlags.Let */ | 2 /* NodeFlags.Const */)) && s.declarationList.declarations.some(function (d) { return !d.initializer; })); } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 261 /* ModuleDeclaration */: - return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 260 /* EnumDeclaration */: - return ts.hasSyntacticModifier(s, 2048 /* Const */); + case 261 /* SyntaxKind.ModuleDeclaration */: + return getModuleInstanceState(s) !== 1 /* ModuleInstanceState.Instantiated */; + case 260 /* SyntaxKind.EnumDeclaration */: + return ts.hasSyntacticModifier(s, 2048 /* ModifierFlags.Const */); default: return false; } } function isExportsOrModuleExportsOrAlias(sourceFile, node) { var i = 0; - var q = [node]; - while (q.length && i < 100) { + var q = ts.createQueue(); + q.enqueue(node); + while (!q.isEmpty() && i < 100) { i++; - node = q.shift(); + node = q.dequeue(); if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } @@ -48104,10 +48204,10 @@ var ts; var symbol = lookupSymbolForName(sourceFile, node.escapedText); if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) { var init = symbol.valueDeclaration.initializer; - q.push(init); + q.enqueue(init); if (ts.isAssignmentExpression(init, /*excludeCompoundAssignment*/ true)) { - q.push(init.left); - q.push(init.right); + q.enqueue(init.left); + q.enqueue(init.right); } } } @@ -48171,32 +48271,32 @@ var ts; if (shouldBail) return; // Visit the type's related types, if any - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var objectType = type; var objectFlags = objectType.objectFlags; - if (objectFlags & 4 /* Reference */) { + if (objectFlags & 4 /* ObjectFlags.Reference */) { visitTypeReference(type); } - if (objectFlags & 32 /* Mapped */) { + if (objectFlags & 32 /* ObjectFlags.Mapped */) { visitMappedType(type); } - if (objectFlags & (1 /* Class */ | 2 /* Interface */)) { + if (objectFlags & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { visitInterfaceType(type); } - if (objectFlags & (8 /* Tuple */ | 16 /* Anonymous */)) { + if (objectFlags & (8 /* ObjectFlags.Tuple */ | 16 /* ObjectFlags.Anonymous */)) { visitObjectType(objectType); } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { visitTypeParameter(type); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { visitUnionOrIntersectionType(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { visitIndexType(type); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { visitIndexedAccessType(type); } } @@ -48285,7 +48385,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 181 /* TypeQuery */) { + if (d.type && d.type.kind === 181 /* SyntaxKind.TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -48422,16 +48522,16 @@ var ts; // Masks TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask"; TypeFacts[TypeFacts["AndFactsMask"] = 134209471] = "AndFactsMask"; - })(TypeFacts || (TypeFacts = {})); + })(TypeFacts = ts.TypeFacts || (ts.TypeFacts = {})); var typeofNEFacts = new ts.Map(ts.getEntries({ - string: 256 /* TypeofNEString */, - number: 512 /* TypeofNENumber */, - bigint: 1024 /* TypeofNEBigInt */, - boolean: 2048 /* TypeofNEBoolean */, - symbol: 4096 /* TypeofNESymbol */, - undefined: 524288 /* NEUndefined */, - object: 8192 /* TypeofNEObject */, - function: 16384 /* TypeofNEFunction */ + string: 256 /* TypeFacts.TypeofNEString */, + number: 512 /* TypeFacts.TypeofNENumber */, + bigint: 1024 /* TypeFacts.TypeofNEBigInt */, + boolean: 2048 /* TypeFacts.TypeofNEBoolean */, + symbol: 4096 /* TypeFacts.TypeofNESymbol */, + undefined: 524288 /* TypeFacts.NEUndefined */, + object: 8192 /* TypeFacts.TypeofNEObject */, + function: 16384 /* TypeFacts.TypeofNEFunction */ })); var TypeSystemPropertyName; (function (TypeSystemPropertyName) { @@ -48457,7 +48557,7 @@ var ts; CheckMode[CheckMode["RestBindingElement"] = 64] = "RestBindingElement"; // e.g. in `const { a, ...rest } = foo`, when checking the type of `foo` to determine the type of `rest`, // we need to preserve generic types instead of substituting them for constraints - })(CheckMode || (CheckMode = {})); + })(CheckMode = ts.CheckMode || (ts.CheckMode = {})); var SignatureCheckMode; (function (SignatureCheckMode) { SignatureCheckMode[SignatureCheckMode["BivariantCallback"] = 1] = "BivariantCallback"; @@ -48465,7 +48565,7 @@ var ts; SignatureCheckMode[SignatureCheckMode["IgnoreReturnTypes"] = 4] = "IgnoreReturnTypes"; SignatureCheckMode[SignatureCheckMode["StrictArity"] = 8] = "StrictArity"; SignatureCheckMode[SignatureCheckMode["Callback"] = 3] = "Callback"; - })(SignatureCheckMode || (SignatureCheckMode = {})); + })(SignatureCheckMode = ts.SignatureCheckMode || (ts.SignatureCheckMode = {})); var IntersectionState; (function (IntersectionState) { IntersectionState[IntersectionState["None"] = 0] = "None"; @@ -48537,10 +48637,10 @@ var ts; IntrinsicTypeKind[IntrinsicTypeKind["Uncapitalize"] = 3] = "Uncapitalize"; })(IntrinsicTypeKind || (IntrinsicTypeKind = {})); var intrinsicTypeKinds = new ts.Map(ts.getEntries({ - Uppercase: 0 /* Uppercase */, - Lowercase: 1 /* Lowercase */, - Capitalize: 2 /* Capitalize */, - Uncapitalize: 3 /* Uncapitalize */ + Uppercase: 0 /* IntrinsicTypeKind.Uppercase */, + Lowercase: 1 /* IntrinsicTypeKind.Lowercase */, + Capitalize: 2 /* IntrinsicTypeKind.Capitalize */, + Uncapitalize: 3 /* IntrinsicTypeKind.Uncapitalize */ })); function SymbolLinks() { } @@ -48565,8 +48665,8 @@ var ts; ts.getSymbolId = getSymbolId; function isInstantiatedModule(node, preserveConstEnums) { var moduleState = ts.getModuleInstanceState(node); - return moduleState === 1 /* Instantiated */ || - (preserveConstEnums && moduleState === 2 /* ConstEnumOnly */); + return moduleState === 1 /* ModuleInstanceState.Instantiated */ || + (preserveConstEnums && moduleState === 2 /* ModuleInstanceState.ConstEnumOnly */); } ts.isInstantiatedModule = isInstantiatedModule; function createTypeChecker(host) { @@ -48581,7 +48681,7 @@ var ts; return; sf.resolvedModules.forEach(function (r) { if (r && r.packageId) - map.set(r.packageId.name, r.extension === ".d.ts" /* Dts */ || !!map.get(r.packageId.name)); + map.set(r.packageId.name, r.extension === ".d.ts" /* Extension.Dts */ || !!map.get(r.packageId.name)); }); }); return map; @@ -48615,7 +48715,7 @@ var ts; var currentNode; var varianceTypeParameter; var emptySymbols = ts.createSymbolTable(); - var arrayVariances = [1 /* Covariant */]; + var arrayVariances = [1 /* VarianceFlags.Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); @@ -48629,20 +48729,20 @@ var ts; var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis"); var useUnknownInCatchVariables = ts.getStrictOptionValue(compilerOptions, "useUnknownInCatchVariables"); var keyofStringsOnly = !!compilerOptions.keyofStringsOnly; - var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* FreshLiteral */; + var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 8192 /* ObjectFlags.FreshLiteral */; var exactOptionalPropertyTypes = compilerOptions.exactOptionalPropertyTypes; var checkBinaryExpression = createCheckBinaryExpression(); var emitResolver = createResolver(); var nodeBuilder = createNodeBuilder(); var globals = ts.createSymbolTable(); - var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); + var undefinedSymbol = createSymbol(4 /* SymbolFlags.Property */, "undefined"); undefinedSymbol.declarations = []; - var globalThisSymbol = createSymbol(1536 /* Module */, "globalThis", 8 /* Readonly */); + var globalThisSymbol = createSymbol(1536 /* SymbolFlags.Module */, "globalThis", 8 /* CheckFlags.Readonly */); globalThisSymbol.exports = globals; globalThisSymbol.declarations = []; globals.set(globalThisSymbol.escapedName, globalThisSymbol); - var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); - var requireSymbol = createSymbol(4 /* Property */, "require"); + var argumentsSymbol = createSymbol(4 /* SymbolFlags.Property */, "arguments"); + var requireSymbol = createSymbol(4 /* SymbolFlags.Property */, "require"); /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount; // for public members that accept a Node or one of its subtypes, we must guard against @@ -48694,10 +48794,10 @@ var ts; return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined; }, getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); }, - getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexInfoOfType: function (type, kind) { return getIndexInfoOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexInfosOfType: getIndexInfosOfType, getSignaturesOfType: getSignaturesOfType, - getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* String */ ? stringType : numberType); }, + getIndexTypeOfType: function (type, kind) { return getIndexTypeOfType(type, kind === 0 /* IndexKind.String */ ? stringType : numberType); }, getIndexType: function (type) { return getIndexType(type); }, getBaseTypes: getBaseTypes, getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, @@ -48792,14 +48892,14 @@ var ts; if (!node) { return undefined; } - if (contextFlags & 4 /* Completions */) { + if (contextFlags & 4 /* ContextFlags.Completions */) { return runWithInferenceBlockedFromSourceNode(node, function () { return getContextualType(node, contextFlags); }); } return getContextualType(node, contextFlags); }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); - return node ? getContextualTypeForObjectLiteralElement(node) : undefined; + return node ? getContextualTypeForObjectLiteralElement(node, /*contextFlags*/ undefined) : undefined; }, getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) { var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression); @@ -48807,19 +48907,19 @@ var ts; }, getContextualTypeForJsxAttribute: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike); - return node && getContextualTypeForJsxAttribute(node); + return node && getContextualTypeForJsxAttribute(node, /*contextFlags*/ undefined); }, isContextSensitive: isContextSensitive, getTypeOfPropertyOfContextualType: getTypeOfPropertyOfContextualType, getFullyQualifiedName: getFullyQualifiedName, getResolvedSignature: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* Normal */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0 /* CheckMode.Normal */); }, getResolvedSignatureForStringLiteralCompletions: function (call, editingArgument, candidatesOutArray) { - return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* IsForStringLiteralArgumentCompletions */, editingArgument); + return getResolvedSignatureWorker(call, candidatesOutArray, /*argumentCount*/ undefined, 32 /* CheckMode.IsForStringLiteralArgumentCompletions */, editingArgument); }, getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) { - return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* IsForSignatureHelp */); + return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16 /* CheckMode.IsForSignatureHelp */); }, getExpandedParameters: getExpandedParameters, hasEffectiveRestParameter: hasEffectiveRestParameter, @@ -48905,7 +49005,7 @@ var ts; getSuggestionForNonexistentExport: getSuggestionForNonexistentExport, getSuggestedSymbolForNonexistentClassMember: getSuggestedSymbolForNonexistentClassMember, getBaseConstraintOfType: getBaseConstraintOfType, - getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, + getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 /* TypeFlags.TypeParameter */ ? getDefaultFromTypeParameter(type) : undefined; }, resolveName: function (name, location, meaning, excludeGlobals) { return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false, excludeGlobals); }, @@ -48942,10 +49042,10 @@ var ts; cancellationToken = ct; // Ensure file is type checked, with _eager_ diagnostic production, so identifiers are registered as potentially unused checkSourceFileWithEagerDiagnostics(file); - ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */)); + ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* NodeCheckFlags.TypeChecked */)); diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName)); checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion })); } }); @@ -49013,35 +49113,35 @@ var ts; var stringMappingTypes = new ts.Map(); var substitutionTypes = new ts.Map(); var subtypeReductionCache = new ts.Map(); + var cachedTypes = new ts.Map(); var evolvingArrayTypes = []; var undefinedProperties = new ts.Map(); var markerTypes = new ts.Set(); - var unknownSymbol = createSymbol(4 /* Property */, "unknown"); - var resolvingSymbol = createSymbol(0, "__resolving__" /* Resolving */); + var unknownSymbol = createSymbol(4 /* SymbolFlags.Property */, "unknown"); + var resolvingSymbol = createSymbol(0, "__resolving__" /* InternalSymbolName.Resolving */); var unresolvedSymbols = new ts.Map(); var errorTypes = new ts.Map(); - var anyType = createIntrinsicType(1 /* Any */, "any"); - var autoType = createIntrinsicType(1 /* Any */, "any"); - var wildcardType = createIntrinsicType(1 /* Any */, "any"); - var errorType = createIntrinsicType(1 /* Any */, "error"); - var unresolvedType = createIntrinsicType(1 /* Any */, "unresolved"); - var nonInferrableAnyType = createIntrinsicType(1 /* Any */, "any", 65536 /* ContainsWideningType */); - var intrinsicMarkerType = createIntrinsicType(1 /* Any */, "intrinsic"); - var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var nonNullUnknownType = createIntrinsicType(2 /* Unknown */, "unknown"); - var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 65536 /* ContainsWideningType */); - var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); - var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* Undefined */, "undefined") : undefinedType; - var nullType = createIntrinsicType(65536 /* Null */, "null"); - var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 65536 /* ContainsWideningType */); - var stringType = createIntrinsicType(4 /* String */, "string"); - var numberType = createIntrinsicType(8 /* Number */, "number"); - var bigintType = createIntrinsicType(64 /* BigInt */, "bigint"); - var falseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var regularFalseType = createIntrinsicType(512 /* BooleanLiteral */, "false"); - var trueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); - var regularTrueType = createIntrinsicType(512 /* BooleanLiteral */, "true"); + var anyType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var autoType = createIntrinsicType(1 /* TypeFlags.Any */, "any", 262144 /* ObjectFlags.NonInferrableType */); + var wildcardType = createIntrinsicType(1 /* TypeFlags.Any */, "any"); + var errorType = createIntrinsicType(1 /* TypeFlags.Any */, "error"); + var unresolvedType = createIntrinsicType(1 /* TypeFlags.Any */, "unresolved"); + var intrinsicMarkerType = createIntrinsicType(1 /* TypeFlags.Any */, "intrinsic"); + var unknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var nonNullUnknownType = createIntrinsicType(2 /* TypeFlags.Unknown */, "unknown"); + var undefinedType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined", 65536 /* ObjectFlags.ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined"); + var missingType = exactOptionalPropertyTypes ? createIntrinsicType(32768 /* TypeFlags.Undefined */, "undefined") : undefinedType; + var nullType = createIntrinsicType(65536 /* TypeFlags.Null */, "null"); + var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* TypeFlags.Null */, "null", 65536 /* ObjectFlags.ContainsWideningType */); + var stringType = createIntrinsicType(4 /* TypeFlags.String */, "string"); + var numberType = createIntrinsicType(8 /* TypeFlags.Number */, "number"); + var bigintType = createIntrinsicType(64 /* TypeFlags.BigInt */, "bigint"); + var falseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var regularFalseType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "false"); + var trueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); + var regularTrueType = createIntrinsicType(512 /* TypeFlags.BooleanLiteral */, "true"); trueType.regularType = regularTrueType; trueType.freshType = trueType; regularTrueType.regularType = regularTrueType; @@ -49051,28 +49151,40 @@ var ts; regularFalseType.regularType = regularFalseType; regularFalseType.freshType = falseType; var booleanType = getUnionType([regularFalseType, regularTrueType]); - var esSymbolType = createIntrinsicType(4096 /* ESSymbol */, "symbol"); - var voidType = createIntrinsicType(16384 /* Void */, "void"); - var neverType = createIntrinsicType(131072 /* Never */, "never"); - var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 262144 /* NonInferrableType */); - var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); - var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); - var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); + var esSymbolType = createIntrinsicType(4096 /* TypeFlags.ESSymbol */, "symbol"); + var voidType = createIntrinsicType(16384 /* TypeFlags.Void */, "void"); + var neverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var silentNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never", 262144 /* ObjectFlags.NonInferrableType */); + var implicitNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); + var nonPrimitiveType = createIntrinsicType(67108864 /* TypeFlags.NonPrimitive */, "object"); var stringOrNumberType = getUnionType([stringType, numberType]); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]); var numericStringType = getTemplateLiteralType(["", ""], [numberType]); // The `${number}` type - var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); - var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); - var uniqueLiteralType = createIntrinsicType(131072 /* Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal - var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? uniqueLiteralType : t; }); // replace all type parameters with the unique literal type (disregarding constraints) + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }, function () { return "(restrictive mapper)"; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? wildcardType : t; }, function () { return "(permissive mapper)"; }); + var uniqueLiteralType = createIntrinsicType(131072 /* TypeFlags.Never */, "never"); // `uniqueLiteralType` is a special `never` flagged by union reduction to behave as a literal + var uniqueLiteralMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeFlags.TypeParameter */ ? uniqueLiteralType : t; }, function () { return "(unique literal mapper)"; }); // replace all type parameters with the unique literal type (disregarding constraints) + var outofbandVarianceMarkerHandler; + var reportUnreliableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true); + } + return t; + }, function () { return "(unmeasurable reporter)"; }); + var reportUnmeasurableMapper = makeFunctionTypeMapper(function (t) { + if (outofbandVarianceMarkerHandler && (t === markerSuperType || t === markerSubType || t === markerOtherType)) { + outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false); + } + return t; + }, function () { return "(unreliable reporter)"; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); - emptyJsxObjectType.objectFlags |= 2048 /* JsxAttributes */; - var emptyTypeLiteralSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + emptyJsxObjectType.objectFlags |= 2048 /* ObjectFlags.JsxAttributes */; + var emptyTypeLiteralSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); emptyTypeLiteralSymbol.members = ts.createSymbolTable(); var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var unknownUnionType = strictNullChecks ? getUnionType([undefinedType, nullType, createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray)]) : unknownType; @@ -49081,7 +49193,7 @@ var ts; var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.objectFlags |= 262144 /* NonInferrableType */; + anyFunctionType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); @@ -49089,11 +49201,14 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var markerSuperTypeForCheck = createTypeParameter(); + var markerSubTypeForCheck = createTypeParameter(); + markerSubTypeForCheck.constraint = markerSuperTypeForCheck; + var noTypePredicate = createTypePredicate(1 /* TypePredicateKind.Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var enumNumberIndexInfo = createIndexInfo(numberType, stringType, /*isReadonly*/ true); var iterationTypesCache = new ts.Map(); // cache for common IterationTypes instances var noIterationTypes = { @@ -49225,7 +49340,6 @@ var ts; var typeofType = createTypeofType(); var _jsxNamespace; var _jsxFactoryEntity; - var outofbandVarianceMarkerHandler; var subtypeRelation = new ts.Map(); var strictSubtypeRelation = new ts.Map(); var assignableRelation = new ts.Map(); @@ -49245,12 +49359,20 @@ var ts; [".mjs", ".mjs"], [".js", ".js"], [".cjs", ".cjs"], - [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"], + [".tsx", compilerOptions.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" : ".js"], [".jsx", ".jsx"], [".json", ".json"], ]; initializeTypeChecker(); return checker; + function getCachedType(key) { + return key ? cachedTypes.get(key) : undefined; + } + function setCachedType(key, type) { + if (key) + cachedTypes.set(key, type); + return type; + } function getJsxNamespace(location) { if (location) { var file = ts.getSourceFileOfNode(location); @@ -49391,7 +49513,7 @@ var ts; return diagnostic; } function isDeprecatedSymbol(symbol) { - return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */); + return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* NodeFlags.Deprecated */); } function addDeprecatedSuggestion(location, declarations, deprecatedEntity) { var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity); @@ -49405,44 +49527,44 @@ var ts; } function createSymbol(flags, name, checkFlags) { symbolCount++; - var symbol = new Symbol(flags | 33554432 /* Transient */, name); + var symbol = new Symbol(flags | 33554432 /* SymbolFlags.Transient */, name); symbol.checkFlags = checkFlags || 0; return symbol; } function getExcludedSymbolFlags(flags) { var result = 0; - if (flags & 2 /* BlockScopedVariable */) - result |= 111551 /* BlockScopedVariableExcludes */; - if (flags & 1 /* FunctionScopedVariable */) - result |= 111550 /* FunctionScopedVariableExcludes */; - if (flags & 4 /* Property */) - result |= 0 /* PropertyExcludes */; - if (flags & 8 /* EnumMember */) - result |= 900095 /* EnumMemberExcludes */; - if (flags & 16 /* Function */) - result |= 110991 /* FunctionExcludes */; - if (flags & 32 /* Class */) - result |= 899503 /* ClassExcludes */; - if (flags & 64 /* Interface */) - result |= 788872 /* InterfaceExcludes */; - if (flags & 256 /* RegularEnum */) - result |= 899327 /* RegularEnumExcludes */; - if (flags & 128 /* ConstEnum */) - result |= 899967 /* ConstEnumExcludes */; - if (flags & 512 /* ValueModule */) - result |= 110735 /* ValueModuleExcludes */; - if (flags & 8192 /* Method */) - result |= 103359 /* MethodExcludes */; - if (flags & 32768 /* GetAccessor */) - result |= 46015 /* GetAccessorExcludes */; - if (flags & 65536 /* SetAccessor */) - result |= 78783 /* SetAccessorExcludes */; - if (flags & 262144 /* TypeParameter */) - result |= 526824 /* TypeParameterExcludes */; - if (flags & 524288 /* TypeAlias */) - result |= 788968 /* TypeAliasExcludes */; - if (flags & 2097152 /* Alias */) - result |= 2097152 /* AliasExcludes */; + if (flags & 2 /* SymbolFlags.BlockScopedVariable */) + result |= 111551 /* SymbolFlags.BlockScopedVariableExcludes */; + if (flags & 1 /* SymbolFlags.FunctionScopedVariable */) + result |= 111550 /* SymbolFlags.FunctionScopedVariableExcludes */; + if (flags & 4 /* SymbolFlags.Property */) + result |= 0 /* SymbolFlags.PropertyExcludes */; + if (flags & 8 /* SymbolFlags.EnumMember */) + result |= 900095 /* SymbolFlags.EnumMemberExcludes */; + if (flags & 16 /* SymbolFlags.Function */) + result |= 110991 /* SymbolFlags.FunctionExcludes */; + if (flags & 32 /* SymbolFlags.Class */) + result |= 899503 /* SymbolFlags.ClassExcludes */; + if (flags & 64 /* SymbolFlags.Interface */) + result |= 788872 /* SymbolFlags.InterfaceExcludes */; + if (flags & 256 /* SymbolFlags.RegularEnum */) + result |= 899327 /* SymbolFlags.RegularEnumExcludes */; + if (flags & 128 /* SymbolFlags.ConstEnum */) + result |= 899967 /* SymbolFlags.ConstEnumExcludes */; + if (flags & 512 /* SymbolFlags.ValueModule */) + result |= 110735 /* SymbolFlags.ValueModuleExcludes */; + if (flags & 8192 /* SymbolFlags.Method */) + result |= 103359 /* SymbolFlags.MethodExcludes */; + if (flags & 32768 /* SymbolFlags.GetAccessor */) + result |= 46015 /* SymbolFlags.GetAccessorExcludes */; + if (flags & 65536 /* SymbolFlags.SetAccessor */) + result |= 78783 /* SymbolFlags.SetAccessorExcludes */; + if (flags & 262144 /* SymbolFlags.TypeParameter */) + result |= 526824 /* SymbolFlags.TypeParameterExcludes */; + if (flags & 524288 /* SymbolFlags.TypeAlias */) + result |= 788968 /* SymbolFlags.TypeAliasExcludes */; + if (flags & 2097152 /* SymbolFlags.Alias */) + result |= 2097152 /* SymbolFlags.AliasExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -49474,13 +49596,13 @@ var ts; function mergeSymbol(target, source, unidirectional) { if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || - (source.flags | target.flags) & 67108864 /* Assignment */) { + (source.flags | target.flags) & 67108864 /* SymbolFlags.Assignment */) { if (source === target) { // This can happen when an export assigned namespace exports something also erroneously exported at the top level // See `declarationFileNoCrashOnExtraExportModifier` for an example return target; } - if (!(target.flags & 33554432 /* Transient */)) { + if (!(target.flags & 33554432 /* SymbolFlags.Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { return source; @@ -49488,7 +49610,7 @@ var ts; target = cloneSymbol(resolvedTarget); } // Javascript static-property-assignment declarations always merge, even though they are also values - if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + if (source.flags & 512 /* SymbolFlags.ValueModule */ && target.flags & 512 /* SymbolFlags.ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { // reset flag when merging instantiated module into value module that has only const enums target.constEnumOnlyModule = false; } @@ -49511,7 +49633,7 @@ var ts; recordMergedSymbol(target, source); } } - else if (target.flags & 1024 /* NamespaceModule */) { + else if (target.flags & 1024 /* SymbolFlags.NamespaceModule */) { // Do not report an error when merging `var globalThis` with the built-in `globalThis`, // as we will already report a "Declaration name conflicts..." error, and this error // won't make much sense. @@ -49520,8 +49642,8 @@ var ts; } } else { // error - var isEitherEnum = !!(target.flags & 384 /* Enum */ || source.flags & 384 /* Enum */); - var isEitherBlockScoped_1 = !!(target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */); + var isEitherEnum = !!(target.flags & 384 /* SymbolFlags.Enum */ || source.flags & 384 /* SymbolFlags.Enum */); + var isEitherBlockScoped_1 = !!(target.flags & 2 /* SymbolFlags.BlockScopedVariable */ || source.flags & 2 /* SymbolFlags.BlockScopedVariable */); var message = isEitherEnum ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations : isEitherBlockScoped_1 ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0; @@ -49532,9 +49654,9 @@ var ts; var symbolName_1 = symbolToString(source); // Collect top-level duplicate identifier errors into one mapping, so we can then merge their diagnostics if there are a bunch if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) { - var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* LessThan */ ? sourceSymbolFile : targetSymbolFile; + var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 /* Comparison.LessThan */ ? sourceSymbolFile : targetSymbolFile; var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile; - var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () { + var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, "".concat(firstFile_1.path, "|").concat(secondFile_1.path), function () { return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() }); }); var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () { @@ -49577,7 +49699,7 @@ var ts; err.relatedInformation = err.relatedInformation || []; var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName); var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here); - if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; })) + if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* Comparison.EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* Comparison.EqualTo */; })) return "continue"; ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage); }; @@ -49619,7 +49741,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -49628,7 +49750,7 @@ var ts; } // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); - if (mainModule_1.flags & 1920 /* Namespace */) { + if (mainModule_1.flags & 1920 /* SymbolFlags.Namespace */) { // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you @@ -49643,9 +49765,9 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { - if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { + if (((_b = mainModule_1.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */)) && ((_c = moduleAugmentation.symbol.exports) === null || _c === void 0 ? void 0 : _c.size)) { // We may need to merge the module augmentation's exports into the target symbols of the resolved exports - var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); + var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */); for (var _i = 0, _d = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _d.length; _i++) { var _e = _d[_i], key = _e[0], value = _e[1]; if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { @@ -49678,7 +49800,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 33554432 /* Transient */) + if (symbol.flags & 33554432 /* SymbolFlags.Transient */) return symbol; var id = getSymbolId(symbol); return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks()); @@ -49688,17 +49810,17 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { - return node.kind === 305 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { var symbol = getMergedSymbol(symbols.get(name)); if (symbol) { - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = resolveAlias(symbol); // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors if (target === unknownSymbol || target.flags & meaning) { @@ -49718,8 +49840,8 @@ var ts; function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) { var constructorDeclaration = parameter.parent; var classDeclaration = parameter.parent.parent; - var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* Value */); - var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* Value */); + var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551 /* SymbolFlags.Value */); + var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551 /* SymbolFlags.Value */); if (parameterSymbol && propertySymbol) { return [parameterSymbol, propertySymbol]; } @@ -49733,7 +49855,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!ts.outFile(compilerOptions)) || isInTypeQuery(usage) || - declaration.flags & 16777216 /* Ambient */) { + declaration.flags & 16777216 /* NodeFlags.Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -49747,17 +49869,17 @@ var ts; } if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) { // declaration is before usage - if (declaration.kind === 203 /* BindingElement */) { + if (declaration.kind === 203 /* SyntaxKind.BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 203 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 203 /* SyntaxKind.BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 254 /* SyntaxKind.VariableDeclaration */), usage); } - else if (declaration.kind === 254 /* VariableDeclaration */) { + else if (declaration.kind === 254 /* SyntaxKind.VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -49771,7 +49893,7 @@ var ts; } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + return !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -49787,19 +49909,19 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 275 /* ExportSpecifier */ || (usage.parent.kind === 271 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 275 /* SyntaxKind.ExportSpecifier */ || (usage.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 271 /* SyntaxKind.ExportAssignment */ && usage.isExportEquals) { return true; } - if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { + if (!!(usage.flags & 8388608 /* NodeFlags.JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields + if (ts.getEmitScriptTarget(compilerOptions) === 99 /* ScriptTarget.ESNext */ && useDefineForClassFields && ts.getContainingClass(declaration) && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -49814,9 +49936,9 @@ var ts; } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { switch (declaration.parent.parent.kind) { - case 237 /* VariableStatement */: - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: + case 237 /* SyntaxKind.VariableStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, declContainer)) { @@ -49844,7 +49966,7 @@ var ts; var initializerOfProperty = propertyDeclaration.initializer === current; if (initializerOfProperty) { if (ts.isStatic(current.parent)) { - if (declaration.kind === 169 /* MethodDeclaration */) { + if (declaration.kind === 169 /* SyntaxKind.MethodDeclaration */) { return true; } if (ts.isPropertyDeclaration(declaration) && ts.getContainingClass(usage) === ts.getContainingClass(declaration)) { @@ -49859,7 +49981,7 @@ var ts; } } else { - var isDeclarationInstanceProperty = declaration.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(declaration); + var isDeclarationInstanceProperty = declaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(declaration); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -49882,19 +50004,19 @@ var ts; return "quit"; } switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // even when stopping at any property declaration, they need to come from the same class return stopAtAnyPropertyDeclaration && (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent) ? "quit" : true; - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: switch (node.parent.kind) { - case 172 /* GetAccessor */: - case 169 /* MethodDeclaration */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 173 /* SyntaxKind.SetAccessor */: return true; default: return false; @@ -49919,7 +50041,7 @@ var ts; // - optional chaining pre-es2020 // - nullish coalesce pre-es2020 // - spread assignment in binding pattern pre-es2017 - if (target >= 2 /* ES2015 */) { + if (target >= 2 /* ScriptTarget.ES2015 */) { var links = getNodeLinks(functionLocation); if (links.declarationRequiresScopeChange === undefined) { links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false; @@ -49934,30 +50056,30 @@ var ts; } function requiresScopeChangeWorker(node) { switch (node.kind) { - case 214 /* ArrowFunction */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: + case 214 /* SyntaxKind.ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: // do not descend into these return false; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 296 /* PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: return requiresScopeChangeWorker(node.name); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // static properties in classes introduce temporary variables if (ts.hasStaticModifier(node)) { - return target < 99 /* ESNext */ || !useDefineForClassFields; + return target < 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields; } return requiresScopeChangeWorker(node.name); default: // null coalesce and optional chain pre-es2020 produce temporary variables if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) { - return target < 7 /* ES2020 */; + return target < 7 /* ScriptTarget.ES2020 */; } if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) { - return target < 4 /* ES2017 */; + return target < 4 /* ScriptTarget.ES2017 */; } if (ts.isTypeNode(node)) return false; @@ -50010,35 +50132,35 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 320 /* JSDoc */) { - useResult = result.flags & 262144 /* TypeParameter */ + if (meaning & result.flags & 788968 /* SymbolFlags.Type */ && lastLocation.kind !== 320 /* SyntaxKind.JSDoc */) { + useResult = result.flags & 262144 /* SymbolFlags.TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 164 /* Parameter */ || - lastLocation.kind === 340 /* JSDocParameterTag */ || - lastLocation.kind === 341 /* JSDocReturnTag */ || - lastLocation.kind === 163 /* TypeParameter */ + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || + lastLocation.kind === 340 /* SyntaxKind.JSDocParameterTag */ || + lastLocation.kind === 341 /* SyntaxKind.JSDocReturnTag */ || + lastLocation.kind === 163 /* SyntaxKind.TypeParameter */ // local types not visible outside the function body : false; } - if (meaning & result.flags & 3 /* Variable */) { + if (meaning & result.flags & 3 /* SymbolFlags.Variable */) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } - else if (result.flags & 1 /* FunctionScopedVariable */) { + else if (result.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { // parameters are visible only inside function body, parameter list and return type // technically for parameter list case here we might mix parameters and variables declared in function, // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 164 /* Parameter */ || + lastLocation.kind === 164 /* SyntaxKind.Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 189 /* ConditionalType */) { + else if (location.kind === 189 /* SyntaxKind.ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -50053,17 +50175,17 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols; - if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { + if (location.kind === 305 /* SyntaxKind.SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. - if (result = moduleExports.get("default" /* Default */)) { + if (result = moduleExports.get("default" /* InternalSymbolName.Default */)) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { break loop; @@ -50083,13 +50205,13 @@ var ts; // which is not the desired behavior. var moduleExport = moduleExports.get(name); if (moduleExport && - moduleExport.flags === 2097152 /* Alias */ && - (ts.getDeclarationOfKind(moduleExport, 275 /* ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* NamespaceExport */))) { + moduleExport.flags === 2097152 /* SymbolFlags.Alias */ && + (ts.getDeclarationOfKind(moduleExport, 275 /* SyntaxKind.ExportSpecifier */) || ts.getDeclarationOfKind(moduleExport, 274 /* SyntaxKind.NamespaceExport */))) { break; } } // ES6 exports are also visible locally (except for 'default'), but commonjs exports are not (except typedefs) - if (name !== "default" /* Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* ModuleMember */))) { + if (name !== "default" /* InternalSymbolName.Default */ && (result = lookup(moduleExports, name, meaning & 2623475 /* SymbolFlags.ModuleMember */))) { if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !((_b = result.declarations) === null || _b === void 0 ? void 0 : _b.some(ts.isJSDocTypeAlias))) { result = undefined; } @@ -50098,12 +50220,12 @@ var ts; } } break; - case 260 /* EnumDeclaration */: - if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* EnumMember */)) { + case 260 /* SyntaxKind.EnumDeclaration */: + if (result = lookup(((_c = getSymbolOfNode(location)) === null || _c === void 0 ? void 0 : _c.exports) || emptySymbols, name, meaning & 8 /* SymbolFlags.EnumMember */)) { break loop; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -50113,20 +50235,21 @@ var ts; if (!ts.isStatic(location)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (lookup(ctor.locals, name, meaning & 111551 /* Value */)) { + if (lookup(ctor.locals, name, meaning & 111551 /* SymbolFlags.Value */)) { // Remember the property node, it will be used later to report appropriate error + ts.Debug.assertNode(location, ts.isPropertyDeclaration); propertyWithInvalidInitializer = location; } } } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! - if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968 /* SymbolFlags.Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -50141,7 +50264,7 @@ var ts; } break loop; } - if (location.kind === 226 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 226 /* SyntaxKind.ClassExpression */ && meaning & 32 /* SymbolFlags.Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -50149,11 +50272,11 @@ var ts; } } break; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 94 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 94 /* SyntaxKind.ExtendsKeyword */) { var container = location.parent.parent; - if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { + if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* SymbolFlags.Type */))) { if (nameNotFoundMessage) { error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters); } @@ -50169,39 +50292,39 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error - if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* SymbolFlags.Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error - if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */) { + if (ts.getEmitScriptTarget(compilerOptions) >= 2 /* ScriptTarget.ES2015 */) { break; } // falls through - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 256 /* FunctionDeclaration */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 213 /* FunctionExpression */: - if (meaning & 3 /* Variable */ && name === "arguments") { + case 213 /* SyntaxKind.FunctionExpression */: + if (meaning & 3 /* SymbolFlags.Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } - if (meaning & 16 /* Function */) { + if (meaning & 16 /* SymbolFlags.Function */) { var functionName = location.name; if (functionName && name === functionName.escapedText) { result = location.symbol; @@ -50209,7 +50332,7 @@ var ts; } } break; - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -50218,7 +50341,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 164 /* Parameter */) { + if (location.parent && location.parent.kind === 164 /* SyntaxKind.Parameter */) { location = location.parent; } // @@ -50233,20 +50356,20 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 257 /* SyntaxKind.ClassDeclaration */)) { location = location.parent; } break; - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it var root = ts.getJSDocRoot(location); if (root) { location = root.parent; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (!associatedDeclarationForContainingInitializerOrBindingName) { @@ -50254,7 +50377,7 @@ var ts; } } break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: if (lastLocation && (lastLocation === location.initializer || lastLocation === location.name && ts.isBindingPattern(lastLocation))) { if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) { @@ -50262,8 +50385,8 @@ var ts; } } break; - case 190 /* InferType */: - if (meaning & 262144 /* TypeParameter */) { + case 190 /* SyntaxKind.InferType */: + if (meaning & 262144 /* SymbolFlags.TypeParameter */) { var parameterName = location.typeParameter.name; if (parameterName && name === parameterName.escapedText) { result = location.typeParameter.symbol; @@ -50288,7 +50411,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 305 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 305 /* SyntaxKind.SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -50304,11 +50427,27 @@ var ts; } } } + // The invalid initializer error is needed in two situation: + // 1. When result is undefined, after checking for a missing "this." + // 2. When result is defined + function checkAndReportErrorForInvalidInitializer() { + if (propertyWithInvalidInitializer && !(useDefineForClassFields && ts.getEmitScriptTarget(compilerOptions) >= 9 /* ScriptTarget.ES2022 */)) { + // We have a match, but the reference occurred within a property initializer and the identifier also binds + // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed + // with ESNext+useDefineForClassFields because the scope semantics are different. + error(errorLocation, errorLocation && propertyWithInvalidInitializer.type && ts.textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos) + ? ts.Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor + : ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyWithInvalidInitializer.name), diagnosticName(nameArg)); + return true; + } + return false; + } if (!result) { if (nameNotFoundMessage) { addLazyDiagnostic(function () { if (!errorLocation || !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && // TODO: GH#18217 + !checkAndReportErrorForInvalidInitializer() && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) && @@ -50316,7 +50455,16 @@ var ts; !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { var suggestion = void 0; - if (getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { + var suggestedLib = void 0; + // Report missing lib first + if (nameArg) { + suggestedLib = getSuggestedLibForNonExistentName(nameArg); + if (suggestedLib) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), suggestedLib); + } + } + // then spelling suggestions + if (!suggestedLib && getSpellingSuggestions && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); var isGlobalScopeAugmentationDeclaration = (suggestion === null || suggestion === void 0 ? void 0 : suggestion.valueDeclaration) && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration); if (isGlobalScopeAugmentationDeclaration) { @@ -50325,7 +50473,7 @@ var ts; if (suggestion) { var suggestionName = symbolToString(suggestion); var isUncheckedJS = isUncheckedJSSuggestion(originalLocation, suggestion, /*excludeClasses*/ false); - var message = meaning === 1920 /* Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 + var message = meaning === 1920 /* SymbolFlags.Namespace */ || nameArg && typeof nameArg !== "string" && ts.nodeIsSynthesized(nameArg) ? ts.Diagnostics.Cannot_find_namespace_0_Did_you_mean_1 : isUncheckedJS ? ts.Diagnostics.Could_not_find_name_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1; var diagnostic = createError(errorLocation, message, diagnosticName(nameArg), suggestionName); @@ -50335,16 +50483,9 @@ var ts; } } } - if (!suggestion) { - if (nameArg) { - var lib = getSuggestedLibForNonExistentName(nameArg); - if (lib) { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib); - } - else { - error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); - } - } + // And then fall back to unspecified "not found" + if (!suggestion && !suggestedLib && nameArg) { + error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg)); } suggestionCount++; } @@ -50352,12 +50493,7 @@ var ts; } return undefined; } - if (propertyWithInvalidInitializer && !(ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields)) { - // We have a match, but the reference occurred within a property initializer and the identifier also binds - // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed - // with ESNext+useDefineForClassFields because the scope semantics are different. - var propertyName = propertyWithInvalidInitializer.name; - error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg)); + else if (checkAndReportErrorForInvalidInitializer()) { return undefined; } // Perform extra checks only if error reporting was requested @@ -50375,22 +50511,22 @@ var ts; // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped if (errorLocation && - (meaning & 2 /* BlockScopedVariable */ || - ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 111551 /* Value */) === 111551 /* Value */))) { + (meaning & 2 /* SymbolFlags.BlockScopedVariable */ || + ((meaning & 32 /* SymbolFlags.Class */ || meaning & 384 /* SymbolFlags.Enum */) && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */))) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { + if (exportOrLocalSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* SymbolFlags.Class */ || exportOrLocalSymbol.flags & 384 /* SymbolFlags.Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */ && !(originalLocation.flags & 8388608 /* NodeFlags.JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* SymbolFlags.Value */) === 111551 /* SymbolFlags.Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself @@ -50402,10 +50538,10 @@ var ts; error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation)); } } - if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { + if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result); if (typeOnlyDeclaration) { - var message = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ + var message = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type; var unescapedName = ts.unescapeLeadingUnderscores(name); @@ -50419,31 +50555,31 @@ var ts; function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) { if (!typeOnlyDeclaration) return diagnostic; - return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); + return ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(typeOnlyDeclaration, typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics._0_was_exported_here : ts.Diagnostics._0_was_imported_here, unescapedName)); } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 214 /* ArrowFunction */ && location.kind !== 213 /* FunctionExpression */) { + if (location.kind !== 214 /* SyntaxKind.ArrowFunction */ && location.kind !== 213 /* SyntaxKind.FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 167 /* PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(location))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; } // generator functions and async functions are not inlined in control flow when immediately invoked - if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* Async */)) { + if (location.asteriskToken || ts.hasSyntacticModifier(location, 256 /* ModifierFlags.Async */)) { return true; } return !ts.getImmediatelyInvokedFunctionExpression(location); } function isSelfReferenceLocation(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 261 /* ModuleDeclaration */: // For `namespace N { N; }` + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -50456,7 +50592,7 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 163 /* TypeParameter */) { + if (decl.kind === 163 /* SyntaxKind.TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); @@ -50500,7 +50636,7 @@ var ts; } function checkAndReportErrorForExtendingInterface(errorLocation) { var expression = getEntityNameForExtendingInterface(errorLocation); - if (expression && resolveEntityName(expression, 64 /* Interface */, /*ignoreErrors*/ true)) { + if (expression && resolveEntityName(expression, 64 /* SymbolFlags.Interface */, /*ignoreErrors*/ true)) { error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression)); return true; } @@ -50512,10 +50648,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 79 /* Identifier */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -50525,9 +50661,9 @@ var ts; } } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(errorLocation) ? 111551 /* SymbolFlags.Value */ : 0); if (meaning === namespaceMeaning) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~namespaceMeaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -50546,9 +50682,9 @@ var ts; return false; } function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) { - if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1920 /* Namespace */)) { + if (meaning & (788968 /* SymbolFlags.Type */ & ~1920 /* SymbolFlags.Namespace */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* SymbolFlags.Type */ & 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1920 /* SymbolFlags.Namespace */)) { error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name)); return true; } @@ -50559,14 +50695,14 @@ var ts; return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown"; } function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) { - if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* ExportSpecifier */) { + if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name); return true; } return false; } function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */)) { + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) { if (isPrimitiveTypeName(name)) { if (isExtendedByInterface(errorLocation)) { error(errorLocation, ts.Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, ts.unescapeLeadingUnderscores(name)); @@ -50576,8 +50712,8 @@ var ts; } return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* Type */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); - if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) { var rawName = ts.unescapeLeadingUnderscores(name); if (isES2015OrLaterConstructorName(name)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName); @@ -50597,7 +50733,7 @@ var ts; var grandparent = node.parent.parent; var parentOfGrandparent = grandparent.parent; if (grandparent && parentOfGrandparent) { - var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* ExtendsKeyword */; + var isExtending = ts.isHeritageClause(grandparent) && grandparent.token === 94 /* SyntaxKind.ExtendsKeyword */; var isInterface = ts.isInterfaceDeclaration(parentOfGrandparent); return isExtending && isInterface; } @@ -50609,7 +50745,7 @@ var ts; }); if (container && container.members.length === 1) { var type = getDeclaredTypeOfSymbol(symbol); - return !!(type.flags & 1048576 /* Union */) && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true); + return !!(type.flags & 1048576 /* TypeFlags.Union */) && allTypesAssignableToKind(type, 384 /* TypeFlags.StringOrNumberLiteral */, /*strict*/ true); } return false; } @@ -50626,15 +50762,15 @@ var ts; return false; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { - if (meaning & (111551 /* Value */ & ~1024 /* NamespaceModule */ & ~788968 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } - else if (meaning & (788968 /* Type */ & ~1024 /* NamespaceModule */ & ~111551 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* ValueModule */ | 1024 /* NamespaceModule */) & ~788968 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); + else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -50644,29 +50780,29 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { var _a; - ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); - if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + ts.Debug.assert(!!(result.flags & 2 /* SymbolFlags.BlockScopedVariable */ || result.flags & 32 /* SymbolFlags.Class */ || result.flags & 384 /* SymbolFlags.Enum */)); + if (result.flags & (16 /* SymbolFlags.Function */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 67108864 /* SymbolFlags.Assignment */) && result.flags & 32 /* SymbolFlags.Class */) { // constructor functions aren't block scoped return; } // Block-scoped variables cannot be used before their definition - var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); }); + var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* SyntaxKind.EnumDeclaration */); }); if (declaration === undefined) return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); - if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (!(declaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); - if (result.flags & 2 /* BlockScopedVariable */) { + if (result.flags & 2 /* SymbolFlags.BlockScopedVariable */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName); } - else if (result.flags & 32 /* Class */) { + else if (result.flags & 32 /* SymbolFlags.Class */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } - else if (result.flags & 256 /* RegularEnum */) { + else if (result.flags & 256 /* SymbolFlags.RegularEnum */) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } else { - ts.Debug.assert(!!(result.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(result.flags & 128 /* SymbolFlags.ConstEnum */)); if (ts.shouldPreserveConstEnums(compilerOptions)) { diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName); } @@ -50687,13 +50823,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return node; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.parent; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return node.parent.parent; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -50718,24 +50854,24 @@ var ts; * const { x } = require ... */ function isAliasSymbolDeclaration(node) { - return node.kind === 265 /* ImportEqualsDeclaration */ - || node.kind === 264 /* NamespaceExportDeclaration */ - || node.kind === 267 /* ImportClause */ && !!node.name - || node.kind === 268 /* NamespaceImport */ - || node.kind === 274 /* NamespaceExport */ - || node.kind === 270 /* ImportSpecifier */ - || node.kind === 275 /* ExportSpecifier */ - || node.kind === 271 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) - || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && ts.exportAssignmentIsAlias(node) + return node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ + || node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ + || node.kind === 267 /* SyntaxKind.ImportClause */ && !!node.name + || node.kind === 268 /* SyntaxKind.NamespaceImport */ + || node.kind === 274 /* SyntaxKind.NamespaceExport */ + || node.kind === 270 /* SyntaxKind.ImportSpecifier */ + || node.kind === 275 /* SyntaxKind.ExportSpecifier */ + || node.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.exportAssignmentIsAlias(node) + || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 /* AssignmentDeclarationKind.ModuleExports */ && ts.exportAssignmentIsAlias(node) || ts.isAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node - && node.parent.operatorToken.kind === 63 /* EqualsToken */ + && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && isAliasableOrJsExpression(node.parent.right) - || node.kind === 297 /* ShorthandPropertyAssignment */ - || node.kind === 296 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) - || node.kind === 254 /* VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) - || node.kind === 203 /* BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent); + || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ + || node.kind === 296 /* SyntaxKind.PropertyAssignment */ && isAliasableOrJsExpression(node.initializer) + || node.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) + || node.kind === 203 /* SyntaxKind.BindingElement */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.parent.parent); } function isAliasableOrJsExpression(e) { return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e); @@ -50748,7 +50884,7 @@ var ts; ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText)) : undefined; } - if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node)); var resolved_4 = resolveExternalModuleSymbol(immediate); markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, /*overwriteEmpty*/ false); @@ -50761,7 +50897,7 @@ var ts; function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) { if (markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false) && !node.isTypeOnly) { var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node)); - var isExport = typeOnlyDeclaration.kind === 275 /* ExportSpecifier */; + var isExport = typeOnlyDeclaration.kind === 275 /* SyntaxKind.ExportSpecifier */; var message = isExport ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type; @@ -50773,14 +50909,14 @@ var ts; } } function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) { - var exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportValue = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, /*overwriteEmpty*/ false); return resolved; } function isSyntacticDefault(node) { - return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* Default */) || ts.isExportSpecifier(node)); + return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) || ts.isExportSpecifier(node)); } function getUsageModeForExpression(usage) { return ts.isStringLiteralLike(usage) ? ts.getModeForUsageLocation(ts.getSourceFileOfNode(usage), usage) : undefined; @@ -50790,7 +50926,7 @@ var ts; } function isOnlyImportedAsDefault(usage) { var usageMode = getUsageModeForExpression(usage); - return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */); + return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Extension.Json */); } function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) { var usageMode = file && getUsageModeForExpression(usage); @@ -50807,7 +50943,7 @@ var ts; // Declaration files (and ambient modules) if (!file || file.isDeclarationFile) { // Definitely cannot have a synthetic default if they have a syntactic default member specified - var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration + var defaultExportSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, /*sourceNode*/ undefined, /*dontResolveAlias*/ true); // Dont resolve alias because we want the immediately exported symbol's declaration if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) { return false; } @@ -50839,7 +50975,7 @@ var ts; exportDefaultSymbol = moduleSymbol; } else { - exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias); + exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* InternalSymbolName.Default */, node, dontResolveAlias); } var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier); @@ -50847,7 +50983,7 @@ var ts; if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) { if (hasExportAssignmentSymbol(moduleSymbol)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; - var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */); + var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); var exportAssignment = exportEqualsSymbol.valueDeclaration; var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName); if (exportAssignment) { @@ -50875,12 +51011,12 @@ var ts; } else { var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); + var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* InternalSymbolName.ExportStar */); if (exportStar) { var defaultExport = (_c = exportStar.declarations) === null || _c === void 0 ? void 0 : _c.find(function (decl) { var _a, _b; return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && - ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); + ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */))); }); if (defaultExport) { ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default)); @@ -50924,7 +51060,7 @@ var ts; if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { return unknownSymbol; } - if (valueSymbol.flags & (788968 /* Type */ | 1920 /* Namespace */)) { + if (valueSymbol.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */)) { return valueSymbol; } var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName); @@ -50939,7 +51075,7 @@ var ts; return result; } function getExportOfModule(symbol, name, specifier, dontResolveAlias) { - if (symbol.flags & 1536 /* Module */) { + if (symbol.flags & 1536 /* SymbolFlags.Module */) { var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText); var resolved = resolveSymbol(exportSymbol, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false); @@ -50947,7 +51083,7 @@ var ts; } } function getPropertyOfVariable(symbol, name) { - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var typeAnnotation = symbol.valueDeclaration.type; if (typeAnnotation) { return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name)); @@ -50963,7 +51099,7 @@ var ts; if (!ts.isIdentifier(name)) { return undefined; } - var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); + var suppressInteropError = name.escapedText === "default" /* InternalSymbolName.Default */ && !!(compilerOptions.allowSyntheticDefaultImports || ts.getESModuleInterop(compilerOptions)); var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -50972,7 +51108,7 @@ var ts; } var symbolFromVariable = void 0; // First check if module was specified with "export=". If so, get the member from the resolved type - if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* ExportEquals */)) { + if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)) { symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, /*skipObjectFunctionPropertyAugment*/ true); } else { @@ -50981,7 +51117,7 @@ var ts; // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias); - if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) { + if (symbolFromModule === undefined && name.escapedText === "default" /* InternalSymbolName.Default */) { var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); @@ -51002,7 +51138,7 @@ var ts; } } else { - if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */)) { + if ((_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* InternalSymbolName.Default */)) { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { @@ -51019,7 +51155,7 @@ var ts; var localSymbol = (_b = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals) === null || _b === void 0 ? void 0 : _b.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { - var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); + var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportedEqualsSymbol) { getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); @@ -51099,19 +51235,15 @@ var ts; if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { return undefined; } - var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); + var aliasLike = resolveEntityName(expression, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } - function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { - var expression = node.initializer; - return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); - } function getTargetOfAccessExpression(node, dontRecursivelyResolve) { - if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* EqualsToken */)) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */)) { return undefined; } return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); @@ -51119,31 +51251,31 @@ var ts; function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: - case 254 /* VariableDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return getTargetOfNamespaceExport(node, dontRecursivelyResolve); - case 270 /* ImportSpecifier */: - case 203 /* BindingElement */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 203 /* SyntaxKind.BindingElement */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 275 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 275 /* SyntaxKind.ExportSpecifier */: + return getTargetOfExportSpecifier(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, dontRecursivelyResolve); + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); - case 297 /* ShorthandPropertyAssignment */: - return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); - case 296 /* PropertyAssignment */: - return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 296 /* SyntaxKind.PropertyAssignment */: + return getTargetOfAliasLikeExpression(node.initializer, dontRecursivelyResolve); + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return getTargetOfAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); @@ -51154,16 +51286,16 @@ var ts; * OR Is a JSContainer which may merge an alias with a local declaration */ function isNonLocalAlias(symbol, excludes) { - if (excludes === void 0) { excludes = 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */; } + if (excludes === void 0) { excludes = 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; } if (!symbol) return false; - return (symbol.flags & (2097152 /* Alias */ | excludes)) === 2097152 /* Alias */ || !!(symbol.flags & 2097152 /* Alias */ && symbol.flags & 67108864 /* Assignment */); + return (symbol.flags & (2097152 /* SymbolFlags.Alias */ | excludes)) === 2097152 /* SymbolFlags.Alias */ || !!(symbol.flags & 2097152 /* SymbolFlags.Alias */ && symbol.flags & 67108864 /* SymbolFlags.Assignment */); } function resolveSymbol(symbol, dontResolveAlias) { return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.aliasTarget) { links.aliasTarget = resolvingSymbol; @@ -51228,7 +51360,7 @@ var ts; function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) { var _a, _b, _c; if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) { - var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* ExportEquals */)) !== null && _b !== void 0 ? _b : target; + var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)) !== null && _b !== void 0 ? _b : target; var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration); aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false; } @@ -51236,7 +51368,7 @@ var ts; } /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */ function getTypeOnlyAliasDeclaration(symbol) { - if (!(symbol.flags & 2097152 /* Alias */)) { + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) { return undefined; } var links = getSymbolLinks(symbol); @@ -51247,7 +51379,7 @@ var ts; var target = resolveAlias(symbol); if (target) { var markAlias = target === unknownSymbol || - ((target.flags & 111551 /* Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); + ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol)); if (markAlias) { markAliasSymbolAsReferenced(symbol); } @@ -51268,7 +51400,7 @@ var ts; // position. if (ts.isInternalModuleImportEqualsDeclaration(node)) { var target = resolveSymbol(symbol); - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // import foo = checkExpressionCached(node.moduleReference); } @@ -51291,22 +51423,22 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 79 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 79 /* SyntaxKind.Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 79 /* Identifier */ || entityName.parent.kind === 161 /* QualifiedName */) { - return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + if (entityName.kind === 79 /* SyntaxKind.Identifier */ || entityName.parent.kind === 161 /* SyntaxKind.QualifiedName */) { + return resolveEntityName(entityName, 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 265 /* ImportEqualsDeclaration */); - return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); + ts.Debug.assert(entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */); + return resolveEntityName(entityName, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } function getFullyQualifiedName(symbol, containingLocation) { - return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* DoNotIncludeSymbolChain */ | 4 /* AllowAnyNodeKind */); + return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, /*meaning*/ undefined, 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */ | 4 /* SymbolFormatFlags.AllowAnyNodeKind */); } function getContainingQualifiedNameNode(node) { while (ts.isQualifiedName(node.parent)) { @@ -51316,7 +51448,7 @@ var ts; } function tryGetQualifiedNameAsValue(node) { var left = ts.getFirstIdentifier(node); - var symbol = resolveName(left, left.escapedText, 111551 /* Value */, undefined, left, /*isUse*/ true); + var symbol = resolveName(left, left.escapedText, 111551 /* SymbolFlags.Value */, undefined, left, /*isUse*/ true); if (!symbol) { return undefined; } @@ -51337,9 +51469,9 @@ var ts; if (ts.nodeIsMissing(name)) { return undefined; } - var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); + var namespaceMeaning = 1920 /* SymbolFlags.Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* SymbolFlags.Value */ : 0); var symbol; - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true, false)); @@ -51347,9 +51479,9 @@ var ts; return getMergedSymbol(symbolFromJSPrototype); } } - else if (name.kind === 161 /* QualifiedName */ || name.kind === 206 /* PropertyAccessExpression */) { - var left = name.kind === 161 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 161 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 161 /* SyntaxKind.QualifiedName */ || name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + var left = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.left : name.expression; + var right = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -51383,7 +51515,7 @@ var ts; } var containingQualifiedName = ts.isQualifiedName(name) && getContainingQualifiedNameNode(name); var canSuggestTypeof = globalObjectType // <-- can't pull on types if global types aren't initialized yet - && (meaning & 788968 /* Type */) + && (meaning & 788968 /* SymbolFlags.Type */) && containingQualifiedName && !ts.isTypeOfExpression(containingQualifiedName.parent) && tryGetQualifiedNameAsValue(containingQualifiedName); @@ -51391,8 +51523,8 @@ var ts; error(containingQualifiedName, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.entityNameToString(containingQualifiedName)); return undefined; } - if (meaning & 1920 /* Namespace */ && ts.isQualifiedName(name.parent)) { - var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* Type */)); + if (meaning & 1920 /* SymbolFlags.Namespace */ && ts.isQualifiedName(name.parent)) { + var exportedTypeSymbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, 788968 /* SymbolFlags.Type */)); if (exportedTypeSymbol) { error(name.parent.right, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, symbolToString(exportedTypeSymbol), ts.unescapeLeadingUnderscores(name.parent.right.escapedText)); return undefined; @@ -51406,8 +51538,8 @@ var ts; else { throw ts.Debug.assertNever(name, "Unknown entity name kind."); } - ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 271 /* ExportAssignment */)) { + ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) === 0, "Should never get an instantiated symbol here."); + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* SymbolFlags.Alias */ || name.parent.kind === 271 /* SyntaxKind.ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -51427,7 +51559,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* NodeFlags.JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -51448,7 +51580,7 @@ var ts; } if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) && ts.isBinaryExpression(host.parent.parent) && - ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(host.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { // X.prototype = { /** @param {K} p */m() { } } <-- look for K on X's declaration var symbol = getSymbolOfNode(host.parent.parent.left); if (symbol) { @@ -51479,7 +51611,7 @@ var ts; */ function getExpandoSymbol(symbol) { var decl = symbol.valueDeclaration; - if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* SymbolFlags.TypeAlias */ || ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false)) { return undefined; } var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); @@ -51546,7 +51678,40 @@ var ts; // An override clause will take effect for type-only imports and import types, and allows importing the types across formats, regardless of // normal mode restrictions if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext && !ts.getResolutionModeOverrideForClause(overrideClause)) { - error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); + if (ts.findAncestor(location, ts.isImportEqualsDeclaration)) { + // ImportEquals in a ESM file resolving to another ESM file + error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference); + } + else { + // CJS file resolving to an ESM file + var diagnosticDetails = void 0; + var ext = ts.tryGetExtensionFromPath(currentSourceFile.fileName); + if (ext === ".ts" /* Extension.Ts */ || ext === ".js" /* Extension.Js */ || ext === ".tsx" /* Extension.Tsx */ || ext === ".jsx" /* Extension.Jsx */) { + var scope = currentSourceFile.packageJsonScope; + var targetExt = ext === ".ts" /* Extension.Ts */ ? ".mts" /* Extension.Mts */ : ext === ".js" /* Extension.Js */ ? ".mjs" /* Extension.Mjs */ : undefined; + if (scope && !scope.packageJsonContent.type) { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_add_the_field_type_Colon_module_to_1, targetExt, ts.combinePaths(scope.packageDirectory, "package.json")); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_add_the_field_type_Colon_module_to_0, ts.combinePaths(scope.packageDirectory, "package.json")); + } + } + else { + if (targetExt) { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_change_its_file_extension_to_0_or_create_a_local_package_json_file_with_type_Colon_module, targetExt); + } + else { + diagnosticDetails = ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.To_convert_this_file_to_an_ECMAScript_module_create_a_local_package_json_file_with_type_Colon_module); + } + } + } + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, ts.chainDiagnosticMessages(diagnosticDetails, ts.Diagnostics.The_current_file_is_a_CommonJS_module_whose_imports_will_produce_require_calls_however_the_referenced_file_is_an_ECMAScript_module_and_cannot_be_imported_with_require_Consider_writing_a_dynamic_import_0_call_instead, moduleReference))); + } } } // merged symbol is module declaration symbol combined with all augmentations @@ -51611,12 +51776,12 @@ var ts; * @see https://github.com/microsoft/TypeScript/issues/42151 */ if (moduleKind >= ts.ModuleKind.ES2015) { - replacedImportSource += tsExtension === ".mts" /* Mts */ ? ".mjs" : tsExtension === ".cts" /* Cts */ ? ".cjs" : ".js"; + replacedImportSource += tsExtension === ".mts" /* Extension.Mts */ ? ".mjs" : tsExtension === ".cts" /* Extension.Cts */ ? ".cjs" : ".js"; } error(errorNode, diag, tsExtension, replacedImportSource); } else if (!compilerOptions.resolveJsonModule && - ts.fileExtensionIs(moduleReference, ".json" /* Json */) && + ts.fileExtensionIs(moduleReference, ".json" /* Extension.Json */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && ts.hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); @@ -51663,27 +51828,27 @@ var ts; } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { - var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); + var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */), dontResolveAlias); var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; } function getCommonJsExportEquals(exported, moduleSymbol) { - if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { + if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* SymbolFlags.Alias */) { return exported; } var links = getSymbolLinks(exported); if (links.cjsExportMerged) { return links.cjsExportMerged; } - var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); - merged.flags = merged.flags | 512 /* ValueModule */; + var merged = exported.flags & 33554432 /* SymbolFlags.Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* SymbolFlags.ValueModule */; if (merged.exports === undefined) { merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { - if (name === "export=" /* ExportEquals */) + if (name === "export=" /* InternalSymbolName.ExportEquals */) return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); @@ -51697,7 +51862,7 @@ var ts; var _a; var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* SymbolFlags.Module */ | 3 /* SymbolFlags.Variable */)) && !ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -51716,12 +51881,12 @@ var ts; var targetFile = (_a = moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getUsageModeForExpression(reference), targetFile.impliedNodeFormat); if (ts.getESModuleInterop(compilerOptions) || isEsmCjsRef) { - var sigs = getSignaturesOfStructuredType(type, 0 /* Call */); + var sigs = getSignaturesOfStructuredType(type, 0 /* SignatureKind.Call */); if (!sigs || !sigs.length) { - sigs = getSignaturesOfStructuredType(type, 1 /* Construct */); + sigs = getSignaturesOfStructuredType(type, 1 /* SignatureKind.Construct */); } if ((sigs && sigs.length) || - getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true) || + getPropertyOfType(type, "default" /* InternalSymbolName.Default */, /*skipObjectFunctionPropertyAugment*/ true) || isEsmCjsRef) { var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference); return cloneTypeAsModuleType(symbol, moduleType, referenceParent); @@ -51753,7 +51918,7 @@ var ts; return result; } function hasExportAssignmentSymbol(moduleSymbol) { - return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined; + return moduleSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */) !== undefined; } function getExportsOfModuleAsArray(moduleSymbol) { return symbolsToArray(getExportsOfModule(moduleSymbol)); @@ -51805,15 +51970,15 @@ var ts; return shouldTreatPropertiesOfExternalModuleAsExports(type) ? getPropertyOfType(type, memberName) : undefined; } function shouldTreatPropertiesOfExternalModuleAsExports(resolvedExternalModuleType) { - return !(resolvedExternalModuleType.flags & 131068 /* Primitive */ || - ts.getObjectFlags(resolvedExternalModuleType) & 1 /* Class */ || + return !(resolvedExternalModuleType.flags & 131068 /* TypeFlags.Primitive */ || + ts.getObjectFlags(resolvedExternalModuleType) & 1 /* ObjectFlags.Class */ || // `isArrayOrTupleLikeType` is too expensive to use in this auto-imports hot path isArrayType(resolvedExternalModuleType) || isTupleType(resolvedExternalModuleType)); } function getExportsOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : - symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } function getExportsOfModule(moduleSymbol) { @@ -51828,7 +51993,7 @@ var ts; if (!source) return; source.forEach(function (sourceSymbol, id) { - if (id === "default" /* Default */) + if (id === "default" /* InternalSymbolName.Default */) return; var targetSymbol = target.get(id); if (!targetSymbol) { @@ -51863,7 +52028,7 @@ var ts; } var symbols = new ts.Map(symbol.exports); // All export * declarations are collected in an __export symbol by the binder - var exportStars = symbol.exports.get("__export" /* ExportStar */); + var exportStars = symbol.exports.get("__export" /* InternalSymbolName.ExportStar */); if (exportStars) { var nestedSymbols = ts.createSymbolTable(); var lookupTable_1 = new ts.Map(); @@ -51952,21 +52117,21 @@ var ts; function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) { var container = getParentOfSymbol(symbol); // Type parameters end up in the `members` lists but are not externally visible - if (container && !(symbol.flags & 262144 /* TypeParameter */)) { + if (container && !(symbol.flags & 262144 /* SymbolFlags.TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning); if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && - getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { + getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */, /*externalOnly*/ false)) { return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer); // This order expresses a preference for the real container if it is in scope } // we potentially have a symbol which is a member of the instance side of something - look for a variable in scope with the container's type // which may be acting like a namespace (eg, `Symbol` acts like a namespace when looking up `Symbol.toStringTag`) var firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) - && container.flags & 788968 /* Type */ - && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ - && meaning === 111551 /* Value */ + && container.flags & 788968 /* SymbolFlags.Type */ + && getDeclaredTypeOfSymbol(container).flags & 524288 /* TypeFlags.Object */ + && meaning === 111551 /* SymbolFlags.Value */ ? forEachSymbolTableInScope(enclosingDeclaration, function (t) { return ts.forEachEntry(t, function (s) { if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) { @@ -51990,7 +52155,7 @@ var ts; return getSymbolOfNode(d.parent.parent); } } - if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { return getSymbolOfNode(ts.getSourceFileOfNode(d)); } @@ -52011,7 +52176,7 @@ var ts; // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations); - if (meaning & 111551 /* Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { + if (meaning & 111551 /* SymbolFlags.Value */ && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) { if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) { return getSymbolOfNode(firstDecl.parent); } @@ -52019,7 +52184,7 @@ var ts; } function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) { var fileSymbol = getExternalModuleContainer(d); - var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); + var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* InternalSymbolName.ExportEquals */); return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } function getAliasForSymbolInContainer(container, symbol) { @@ -52029,7 +52194,7 @@ var ts; } // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return // the container itself as the alias for the symbol - var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + var exportEquals = container.exports && container.exports.get("export=" /* InternalSymbolName.ExportEquals */); if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { return container; } @@ -52053,17 +52218,17 @@ var ts; } } function getExportSymbolOfValueSymbolIfExported(symbol) { - return getMergedSymbol(symbol && (symbol.flags & 1048576 /* ExportValue */) !== 0 && symbol.exportSymbol || symbol); + return getMergedSymbol(symbol && (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) !== 0 && symbol.exportSymbol || symbol); } function symbolIsValue(symbol, includeTypeOnlyMembers) { - return !!(symbol.flags & 111551 /* Value */ || - symbol.flags & 2097152 /* Alias */ && resolveAlias(symbol).flags & 111551 /* Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); + return !!(symbol.flags & 111551 /* SymbolFlags.Value */ || + symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol))); } function findConstructorDeclaration(node) { var members = node.members; for (var _i = 0, members_3 = members; _i < members_3.length; _i++) { var member = members_3[_i]; - if (member.kind === 171 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -52086,7 +52251,7 @@ var ts; return type; } function createObjectType(objectFlags, symbol) { - var type = createType(524288 /* Object */); + var type = createType(524288 /* TypeFlags.Object */); type.objectFlags = objectFlags; type.symbol = symbol; type.members = undefined; @@ -52100,7 +52265,7 @@ var ts; return getUnionType(ts.arrayFrom(typeofNEFacts.keys(), getStringLiteralType)); } function createTypeParameter(symbol) { - var type = createType(262144 /* TypeParameter */); + var type = createType(262144 /* TypeFlags.TypeParameter */); if (symbol) type.symbol = symbol; return type; @@ -52110,11 +52275,11 @@ var ts; // with at least two underscores. The @ character indicates that the name is denoted by a well known ES // Symbol instance and the # character indicates that the name is a PrivateIdentifier. function isReservedMemberName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) !== 95 /* _ */ && - name.charCodeAt(2) !== 64 /* at */ && - name.charCodeAt(2) !== 35 /* hash */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 95 /* CharacterCodes._ */ && + name.charCodeAt(2) !== 64 /* CharacterCodes.at */ && + name.charCodeAt(2) !== 35 /* CharacterCodes.hash */; } function getNamedMembers(members) { var result; @@ -52146,14 +52311,14 @@ var ts; return resolved; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, indexInfos) { - return setStructuredTypeMembers(createObjectType(16 /* Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); + return setStructuredTypeMembers(createObjectType(16 /* ObjectFlags.Anonymous */, symbol), members, callSignatures, constructSignatures, indexInfos); } function getResolvedTypeWithoutAbstractConstructSignatures(type) { if (type.constructSignatures.length === 0) return type; if (type.objectTypeWithoutAbstractConstructSignatures) return type.objectTypeWithoutAbstractConstructSignatures; - var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* Abstract */); }); + var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (type.constructSignatures === constructSignatures) return type; var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.indexInfos); @@ -52171,12 +52336,12 @@ var ts; } } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: var sym = getSymbolOfNode(location); // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred @@ -52185,9 +52350,9 @@ var ts; return { value: result }; } break; - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // Type parameters are bound into `members` lists so they can merge across declarations // This is troublesome, since in all other respects, they behave like locals :cries: // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol @@ -52198,7 +52363,7 @@ var ts; var table_1; // TODO: Should this filtered table be cached in some way? (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { - if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + if (memberSymbol.flags & (788968 /* SymbolFlags.Type */ & ~67108864 /* SymbolFlags.Assignment */)) { (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); } }); @@ -52217,7 +52382,7 @@ var ts; } function getQualifiedLeftMeaning(rightMeaning) { // If we are looking in value space, the parent meaning is value, other wise it is namespace - return rightMeaning === 111551 /* Value */ ? 111551 /* Value */ : 1920 /* Namespace */; + return rightMeaning === 111551 /* SymbolFlags.Value */ ? 111551 /* SymbolFlags.Value */ : 1920 /* SymbolFlags.Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) { if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); } @@ -52228,7 +52393,7 @@ var ts; var cache = (links.accessibleChainCache || (links.accessibleChainCache = new ts.Map())); // Go from enclosingDeclaration to the first scope we check, so the cache is keyed off the scope and thus shared more var firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, function (_, __, ___, node) { return node; }); - var key = (useOnlyExternalAliasing ? 0 : 1) + "|" + (firstRelevantLocation && getNodeId(firstRelevantLocation)) + "|" + meaning; + var key = "".concat(useOnlyExternalAliasing ? 0 : 1, "|").concat(firstRelevantLocation && getNodeId(firstRelevantLocation), "|").concat(meaning); if (cache.has(key)) { return cache.get(key); } @@ -52272,9 +52437,9 @@ var ts; } // Check if symbol is any of the aliases in scope var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" /* ExportEquals */ - && symbolFromSymbolTable.escapedName !== "default" /* Default */ + if (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ + && symbolFromSymbolTable.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && symbolFromSymbolTable.escapedName !== "default" /* InternalSymbolName.Default */ && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) @@ -52282,7 +52447,7 @@ var ts; && (isLocalNameLookup ? !ts.some(symbolFromSymbolTable.declarations, ts.isNamespaceReexportDeclaration) : true) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification); if (candidate) { @@ -52326,7 +52491,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 275 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -52341,10 +52506,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: continue; default: return false; @@ -52355,16 +52520,16 @@ var ts; return false; } function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968 /* SymbolFlags.Type */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) { - var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); - return access.accessibility === 0 /* Accessible */; + var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551 /* SymbolFlags.Value */, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ true); + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) { var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, /*shouldComputeAliasesToMakeVisible*/ false, /*allowModules*/ false); - return access.accessibility === 0 /* Accessible */; + return access.accessibility === 0 /* SymbolAccessibility.Accessible */; } function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) { if (!ts.length(symbols)) @@ -52394,7 +52559,7 @@ var ts; } // Any meaning of a module symbol is always accessible via an `import` type return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } } @@ -52418,14 +52583,14 @@ var ts; } if (earlyModuleBail) { return { - accessibility: 0 /* Accessible */ + accessibility: 0 /* SymbolAccessibility.Accessible */ }; } if (hadAccessibleChain) { return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* Namespace */) : undefined, + errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920 /* SymbolFlags.Namespace */) : undefined, }; } } @@ -52454,7 +52619,7 @@ var ts; if (symbolExternalModule !== enclosingExternalModule) { // name from different external module that is not visible return { - accessibility: 2 /* CannotBeNamed */, + accessibility: 2 /* SymbolAccessibility.CannotBeNamed */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), errorModuleName: symbolToString(symbolExternalModule), errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined, @@ -52463,28 +52628,28 @@ var ts; } // Just a local name that is not accessible return { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning), }; } - return { accessibility: 0 /* Accessible */ }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } function getExternalModuleContainer(declaration) { var node = ts.findAncestor(declaration, hasExternalModuleSymbol); return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 79 /* SyntaxKind.Identifier */; }), getIsDeclarationVisible)) { return undefined; } - return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; + return { accessibility: 0 /* SymbolAccessibility.Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { var _a, _b; if (!isDeclarationVisible(declaration)) { @@ -52492,27 +52657,39 @@ var ts; // because these kind of aliases can be used to name types in declaration file var anyImportSyntax = getAnyImportSyntax(declaration); if (anyImportSyntax && - !ts.hasSyntacticModifier(anyImportSyntax, 1 /* Export */) && // import clause without export + !ts.hasSyntacticModifier(anyImportSyntax, 1 /* ModifierFlags.Export */) && // import clause without export isDeclarationVisible(anyImportSyntax.parent)) { return addVisibleAlias(declaration, anyImportSyntax); } else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) && - !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* Export */) && // unexported variable statement + !ts.hasSyntacticModifier(declaration.parent.parent, 1 /* ModifierFlags.Export */) && // unexported variable statement isDeclarationVisible(declaration.parent.parent.parent)) { return addVisibleAlias(declaration, declaration.parent.parent); } else if (ts.isLateVisibilityPaintedStatement(declaration) // unexported top-level statement - && !ts.hasSyntacticModifier(declaration, 1 /* Export */) + && !ts.hasSyntacticModifier(declaration, 1 /* ModifierFlags.Export */) && isDeclarationVisible(declaration.parent)) { return addVisibleAlias(declaration, declaration); } - else if (symbol.flags & 2097152 /* Alias */ && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement - && ts.isVariableDeclaration(declaration.parent.parent) - && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) - && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* Export */) - && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) - && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { - return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + else if (ts.isBindingElement(declaration)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent) // exported import-like top-level JS require statement + && ts.isVariableDeclaration(declaration.parent.parent) + && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent) + && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1 /* ModifierFlags.Export */) + && declaration.parent.parent.parent.parent.parent // check if the thing containing the variable statement is visible (ie, the file) + && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) { + return addVisibleAlias(declaration, declaration.parent.parent.parent.parent); + } + else if (symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + var variableStatement = ts.findAncestor(declaration, ts.isVariableStatement); + if (ts.hasSyntacticModifier(variableStatement, 1 /* ModifierFlags.Export */)) { + return true; + } + if (!isDeclarationVisible(variableStatement.parent)) { + return false; + } + return addVisibleAlias(declaration, variableStatement); + } } // Declaration is not visible return false; @@ -52533,86 +52710,86 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 181 /* TypeQuery */ || - entityName.parent.kind === 228 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || - entityName.parent.kind === 162 /* ComputedPropertyName */) { + if (entityName.parent.kind === 181 /* SyntaxKind.TypeQuery */ || + entityName.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) || + entityName.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // Typeof value - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; } - else if (entityName.kind === 161 /* QualifiedName */ || entityName.kind === 206 /* PropertyAccessExpression */ || - entityName.parent.kind === 265 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 161 /* SyntaxKind.QualifiedName */ || entityName.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + entityName.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } else { // Type Reference or TypeAlias entity = Identifier - meaning = 788968 /* Type */; + meaning = 788968 /* SymbolFlags.Type */; } var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); - if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) { - return { accessibility: 0 /* Accessible */ }; + if (symbol && symbol.flags & 262144 /* SymbolFlags.TypeParameter */ && meaning & 788968 /* SymbolFlags.Type */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } - if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) { - return { accessibility: 0 /* Accessible */ }; + if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* SymbolAccessibility.Accessible */) { + return { accessibility: 0 /* SymbolAccessibility.Accessible */ }; } // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { - accessibility: 1 /* NotAccessible */, + accessibility: 1 /* SymbolAccessibility.NotAccessible */, errorSymbolName: ts.getTextOfNode(firstIdentifier), errorNode: firstIdentifier }; } function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) { - if (flags === void 0) { flags = 4 /* AllowAnyNodeKind */; } - var nodeFlags = 70221824 /* IgnoreErrors */; - if (flags & 2 /* UseOnlyExternalAliasing */) { - nodeFlags |= 128 /* UseOnlyExternalAliasing */; + if (flags === void 0) { flags = 4 /* SymbolFormatFlags.AllowAnyNodeKind */; } + var nodeFlags = 70221824 /* NodeBuilderFlags.IgnoreErrors */; + if (flags & 2 /* SymbolFormatFlags.UseOnlyExternalAliasing */) { + nodeFlags |= 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */; } - if (flags & 1 /* WriteTypeParametersOrArguments */) { - nodeFlags |= 512 /* WriteTypeParametersInQualifiedName */; + if (flags & 1 /* SymbolFormatFlags.WriteTypeParametersOrArguments */) { + nodeFlags |= 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; } - if (flags & 8 /* UseAliasDefinedOutsideCurrentScope */) { - nodeFlags |= 16384 /* UseAliasDefinedOutsideCurrentScope */; + if (flags & 8 /* SymbolFormatFlags.UseAliasDefinedOutsideCurrentScope */) { + nodeFlags |= 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */; } - if (flags & 16 /* DoNotIncludeSymbolChain */) { - nodeFlags |= 134217728 /* DoNotIncludeSymbolChain */; + if (flags & 16 /* SymbolFormatFlags.DoNotIncludeSymbolChain */) { + nodeFlags |= 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */; } - var builder = flags & 4 /* AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; + var builder = flags & 4 /* SymbolFormatFlags.AllowAnyNodeKind */ ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName; return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker); function symbolToStringWorker(writer) { var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags); // TODO: GH#18217 // add neverAsciiEscape for GH#39027 - var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); + var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 305 /* SyntaxKind.SourceFile */ ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, entity, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, entity, /*sourceFile*/ sourceFile, writer); return writer; } } function signatureToString(signature, enclosingDeclaration, flags, kind, writer) { - if (flags === void 0) { flags = 0 /* None */; } + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker); function signatureToStringWorker(writer) { var sigOutput; - if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 180 /* ConstructorType */ : 179 /* FunctionType */; + if (flags & 262144 /* TypeFormatFlags.WriteArrowStyleSignature */) { + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 180 /* SyntaxKind.ConstructorType */ : 179 /* SyntaxKind.FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 175 /* ConstructSignature */ : 174 /* CallSignature */; + sigOutput = kind === 1 /* SignatureKind.Construct */ ? 175 /* SyntaxKind.ConstructSignature */ : 174 /* SyntaxKind.CallSignature */; } - var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); + var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* EmitHint.Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } function typeToString(type, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 1048576 /* TypeFormatFlags.AllowUniqueESSymbolType */ | 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } if (writer === void 0) { writer = ts.createTextWriter(""); } - var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */; - var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0), writer); + var noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* TypeFormatFlags.NoTruncation */; + var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | (noTruncation ? 1 /* NodeBuilderFlags.NoTruncation */ : 0), writer); if (typeNode === undefined) return ts.Debug.fail("should always get typenode"); // The unresolved type gets a synthesized comment on `any` to hint to users that it's not a plain `any`. @@ -52620,7 +52797,7 @@ var ts; var options = { removeComments: type !== unresolvedType }; var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { @@ -52638,17 +52815,17 @@ var ts; return [leftStr, rightStr]; } function getTypeNameForErrorDisplay(type) { - return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); + return typeToString(type, /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */); } function symbolValueDeclarationIsContextSensitive(symbol) { return symbol && !!symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); } function toNodeBuilderFlags(flags) { - if (flags === void 0) { flags = 0 /* None */; } - return flags & 814775659 /* NodeBuilderFlagsMask */; + if (flags === void 0) { flags = 0 /* TypeFormatFlags.None */; } + return flags & 848330091 /* TypeFormatFlags.NodeBuilderFlagsMask */; } function isClassInstanceSide(type) { - return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 16777216 /* IsClassInstanceClone */))); + return !!type.symbol && !!(type.symbol.flags & 32 /* SymbolFlags.Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* TypeFlags.Object */) && !!(ts.getObjectFlags(type) & 16777216 /* ObjectFlags.IsClassInstanceClone */))); } function createNodeBuilder() { return { @@ -52682,12 +52859,12 @@ var ts; }; function withContext(enclosingDeclaration, flags, tracker, cb) { var _a, _b; - ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); + ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* NodeFlags.Synthesized */) === 0); var context = { enclosingDeclaration: enclosingDeclaration, - flags: flags || 0 /* None */, + flags: flags || 0 /* NodeBuilderFlags.None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost - tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { + tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: function () { return false; }, moduleResolverHost: flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache), @@ -52709,7 +52886,7 @@ var ts; }; context.tracker = wrapSymbolTrackerToReportForContext(context, context.tracker); var resultingNode = cb(context); - if (context.truncating && context.flags & 1 /* NoTruncation */) { + if (context.truncating && context.flags & 1 /* NodeBuilderFlags.NoTruncation */) { (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a); } return context.encounteredError ? undefined : resultingNode; @@ -52744,62 +52921,68 @@ var ts; function checkTruncationLength(context) { if (context.truncating) return context.truncating; - return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); + return context.truncating = context.approximateLength > ((context.flags & 1 /* NodeBuilderFlags.NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { + var savedFlags = context.flags; + var typeNode = typeToTypeNodeWorker(type, context); + context.flags = savedFlags; + return typeNode; + } + function typeToTypeNodeWorker(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { cancellationToken.throwIfCancellationRequested(); } - var inTypeAlias = context.flags & 8388608 /* InTypeAlias */; - context.flags &= ~8388608 /* InTypeAlias */; + var inTypeAlias = context.flags & 8388608 /* NodeBuilderFlags.InTypeAlias */; + context.flags &= ~8388608 /* NodeBuilderFlags.InTypeAlias */; if (!type) { - if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; return undefined; // TODO: GH#18217 } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (!(context.flags & 536870912 /* NoTypeReduction */)) { + if (!(context.flags & 536870912 /* NodeBuilderFlags.NoTypeReduction */)) { type = getReducedType(type); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { if (type.aliasSymbol) { return ts.factory.createTypeReferenceNode(symbolToEntityNameNode(type.aliasSymbol), mapToTypeNodes(type.aliasTypeArguments, context)); } if (type === unresolvedType) { - return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), 3 /* MultiLineCommentTrivia */, "unresolved"); + return ts.addSyntheticLeadingComment(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), 3 /* SyntaxKind.MultiLineCommentTrivia */, "unresolved"); } context.approximateLength += 3; - return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* IntrinsicKeyword */ : 130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 138 /* SyntaxKind.IntrinsicKeyword */ : 130 /* SyntaxKind.AnyKeyword */); } - if (type.flags & 2 /* Unknown */) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + if (type.flags & 2 /* TypeFlags.Unknown */) { + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } - if (type.flags & 4 /* String */) { + if (type.flags & 4 /* TypeFlags.String */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(150 /* StringKeyword */); + return ts.factory.createKeywordTypeNode(150 /* SyntaxKind.StringKeyword */); } - if (type.flags & 8 /* Number */) { + if (type.flags & 8 /* TypeFlags.Number */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(147 /* NumberKeyword */); + return ts.factory.createKeywordTypeNode(147 /* SyntaxKind.NumberKeyword */); } - if (type.flags & 64 /* BigInt */) { + if (type.flags & 64 /* TypeFlags.BigInt */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(158 /* BigIntKeyword */); + return ts.factory.createKeywordTypeNode(158 /* SyntaxKind.BigIntKeyword */); } - if (type.flags & 16 /* Boolean */ && !type.aliasSymbol) { + if (type.flags & 16 /* TypeFlags.Boolean */ && !type.aliasSymbol) { context.approximateLength += 7; - return ts.factory.createKeywordTypeNode(133 /* BooleanKeyword */); + return ts.factory.createKeywordTypeNode(133 /* SyntaxKind.BooleanKeyword */); } - if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { + if (type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); - var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* Type */); + var parentName = symbolToTypeNode(parentSymbol, context, 788968 /* SymbolFlags.Type */); if (getDeclaredTypeOfSymbol(parentSymbol) === type) { return parentName; } var memberName = ts.symbolName(type.symbol); - if (ts.isIdentifierText(memberName, 0 /* ES3 */)) { + if (ts.isIdentifierText(memberName, 0 /* ScriptTarget.ES3 */)) { return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, /*typeArguments*/ undefined)); } if (ts.isImportTypeNode(parentName)) { @@ -52813,66 +52996,66 @@ var ts; return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`."); } } - if (type.flags & 1056 /* EnumLike */) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + if (type.flags & 1056 /* TypeFlags.EnumLike */) { + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - if (type.flags & 128 /* StringLiteral */) { + if (type.flags & 128 /* TypeFlags.StringLiteral */) { context.approximateLength += (type.value.length + 2); - return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* UseSingleQuotesForStringLiteralType */)), 16777216 /* NoAsciiEscaping */)); + return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456 /* NodeBuilderFlags.UseSingleQuotesForStringLiteralType */)), 16777216 /* EmitFlags.NoAsciiEscaping */)); } - if (type.flags & 256 /* NumberLiteral */) { + if (type.flags & 256 /* TypeFlags.NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); + return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40 /* SyntaxKind.MinusToken */, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value)); } - if (type.flags & 2048 /* BigIntLiteral */) { + if (type.flags & 2048 /* TypeFlags.BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value))); } - if (type.flags & 512 /* BooleanLiteral */) { + if (type.flags & 512 /* TypeFlags.BooleanLiteral */) { context.approximateLength += type.intrinsicName.length; return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse()); } - if (type.flags & 8192 /* UniqueESSymbol */) { - if (!(context.flags & 1048576 /* AllowUniqueESSymbolType */)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + if (!(context.flags & 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */)) { if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { context.approximateLength += 6; - return symbolToTypeNode(type.symbol, context, 111551 /* Value */); + return symbolToTypeNode(type.symbol, context, 111551 /* SymbolFlags.Value */); } if (context.tracker.reportInaccessibleUniqueSymbolError) { context.tracker.reportInaccessibleUniqueSymbolError(); } } context.approximateLength += 13; - return ts.factory.createTypeOperatorNode(154 /* UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */)); + return ts.factory.createTypeOperatorNode(154 /* SyntaxKind.UniqueKeyword */, ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */)); } - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { context.approximateLength += 4; - return ts.factory.createKeywordTypeNode(114 /* VoidKeyword */); + return ts.factory.createKeywordTypeNode(114 /* SyntaxKind.VoidKeyword */); } - if (type.flags & 32768 /* Undefined */) { + if (type.flags & 32768 /* TypeFlags.Undefined */) { context.approximateLength += 9; - return ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */); + return ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */); } - if (type.flags & 65536 /* Null */) { + if (type.flags & 65536 /* TypeFlags.Null */) { context.approximateLength += 4; return ts.factory.createLiteralTypeNode(ts.factory.createNull()); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { context.approximateLength += 5; - return ts.factory.createKeywordTypeNode(143 /* NeverKeyword */); + return ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */); } - if (type.flags & 4096 /* ESSymbol */) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(151 /* SymbolKeyword */); + return ts.factory.createKeywordTypeNode(151 /* SyntaxKind.SymbolKeyword */); } - if (type.flags & 67108864 /* NonPrimitive */) { + if (type.flags & 67108864 /* TypeFlags.NonPrimitive */) { context.approximateLength += 6; - return ts.factory.createKeywordTypeNode(148 /* ObjectKeyword */); + return ts.factory.createKeywordTypeNode(148 /* SyntaxKind.ObjectKeyword */); } if (ts.isThisTypeParameter(type)) { - if (context.flags & 4194304 /* InObjectTypeLiteral */) { - if (!context.encounteredError && !(context.flags & 32768 /* AllowThisInObjectLiteral */)) { + if (context.flags & 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */) { + if (!context.encounteredError && !(context.flags & 32768 /* NodeBuilderFlags.AllowThisInObjectLiteral */)) { context.encounteredError = true; } if (context.tracker.reportInaccessibleThisError) { @@ -52882,22 +53065,22 @@ var ts; context.approximateLength += 4; return ts.factory.createThisTypeNode(); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* SymbolFlags.Class */)) return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes); if (ts.length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) { return ts.factory.createArrayTypeNode(typeArgumentNodes[0]); } - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); } var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 4 /* Reference */) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & 4 /* ObjectFlags.Reference */) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } - if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { - if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ || objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { context.approximateLength += (ts.symbolName(type.symbol).length + 6); var constraintNode = void 0; var constraint = getConstraintOfTypeParameter(type); @@ -52914,8 +53097,8 @@ var ts; } return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode)); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && - type.flags & 262144 /* TypeParameter */ && + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name_2 = typeParameterToName(type, context); context.approximateLength += ts.idText(name_2).length; @@ -52923,43 +53106,43 @@ var ts; } // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. if (type.symbol) { - return symbolToTypeNode(type.symbol, context, 788968 /* Type */); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */); } - var name = (type === markerSuperType || type === markerSubType) && varianceTypeParameter && varianceTypeParameter.symbol ? - (type === markerSubType ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; + var name = (type === markerSuperTypeForCheck || type === markerSubTypeForCheck) && varianceTypeParameter && varianceTypeParameter.symbol ? + (type === markerSubTypeForCheck ? "sub-" : "super-") + ts.symbolName(varianceTypeParameter.symbol) : "?"; return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(name), /*typeArguments*/ undefined); } - if (type.flags & 1048576 /* Union */ && type.origin) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.origin) { type = type.origin; } - if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { - var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; + if (type.flags & (1048576 /* TypeFlags.Union */ | 2097152 /* TypeFlags.Intersection */)) { + var types = type.flags & 1048576 /* TypeFlags.Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { return typeToTypeNodeHelper(types[0], context); } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - return type.flags & 1048576 /* Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes); } else { - if (!context.encounteredError && !(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + if (!context.encounteredError && !(context.flags & 262144 /* NodeBuilderFlags.AllowEmptyUnionOrIntersection */)) { context.encounteredError = true; } return undefined; // TODO: GH#18217 } } - if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + if (objectFlags & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var indexedType = type.type; context.approximateLength += 6; var indexTypeNode = typeToTypeNodeHelper(indexedType, context); - return ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, indexTypeNode); + return ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, indexTypeNode); } - if (type.flags & 134217728 /* TemplateLiteral */) { + if (type.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts_1 = type.texts; var types_1 = type.types; var templateHead = ts.factory.createTemplateHead(texts_1[0]); @@ -52967,32 +53150,32 @@ var ts; context.approximateLength += 2; return ts.factory.createTemplateLiteralType(templateHead, templateSpans); } - if (type.flags & 268435456 /* StringMapping */) { + if (type.flags & 268435456 /* TypeFlags.StringMapping */) { var typeNode = typeToTypeNodeHelper(type.type, context); - return symbolToTypeNode(type.symbol, context, 788968 /* Type */, [typeNode]); + return symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, [typeNode]); } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { var objectTypeNode = typeToTypeNodeHelper(type.objectType, context); var indexTypeNode = typeToTypeNodeHelper(type.indexType, context); context.approximateLength += 2; return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { return visitAndTransformType(type, function (type) { return conditionalTypeToTypeNode(type); }); } - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return typeToTypeNodeHelper(type.baseType, context); } return ts.Debug.fail("Should be unreachable."); function conditionalTypeToTypeNode(type) { var checkTypeNode = typeToTypeNodeHelper(type.checkType, context); context.approximateLength += 15; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeParameter */)) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && type.root.isDistributive && !(type.checkType.flags & 262144 /* TypeFlags.TypeParameter */)) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); var newTypeVariable = ts.factory.createTypeReferenceNode(name); context.approximateLength += 37; // 15 each for two added conditionals, 7 for an added infer type - var newMapper = prependTypeMapping(type.root.checkType, newParam, type.combinedMapper || type.mapper); + var newMapper = prependTypeMapping(type.root.checkType, newParam, type.mapper); var saveInferTypeParameters_1 = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; var extendsTypeNode_1 = typeToTypeNodeHelper(instantiateType(type.root.extendsType, newMapper), context); @@ -53009,7 +53192,7 @@ var ts; // On the other hand, // checkType extends infer T extends checkType ? T extends extendsType ? trueType : falseType : never; // may also work with `infer ... extends ...` in, but would produce declarations only compatible with the latest TS. - return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + return ts.factory.createConditionalTypeNode(checkTypeNode, ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), ts.factory.createConditionalTypeNode(ts.factory.createTypeReferenceNode(ts.factory.cloneNode(name)), typeToTypeNodeHelper(type.checkType, context), ts.factory.createConditionalTypeNode(newTypeVariable, extendsTypeNode_1, trueTypeNode_1, falseTypeNode_1), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)), ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } var saveInferTypeParameters = context.inferTypeParameters; context.inferTypeParameters = type.root.inferTypeParameters; @@ -53021,9 +53204,9 @@ var ts; } function typeToTypeNodeOrCircularityElision(type) { var _a, _b, _c; - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) { - if (!(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + if (!(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b); } @@ -53033,8 +53216,12 @@ var ts; } return typeToTypeNodeHelper(type, context); } + function isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) { + return isMappedTypeWithKeyofConstraintDeclaration(type) + && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeFlags.TypeParameter */); + } function createMappedTypeNodeFromType(type) { - ts.Debug.assert(!!(type.flags & 524288 /* Object */)); + ts.Debug.assert(!!(type.flags & 524288 /* TypeFlags.Object */)); var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined; var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined; var appropriateConstraintTypeNode; @@ -53042,27 +53229,28 @@ var ts; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } // We do this to ensure we retain the toplevel keyof-ness of the type which may be lost due to keyof distribution during `getConstraintTypeFromMappedType` - if (!(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { - var newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T")); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { + var newParam = createTypeParameter(createSymbol(262144 /* SymbolFlags.TypeParameter */, "T")); var name = typeParameterToName(newParam, context); newTypeVariable = ts.factory.createTypeReferenceNode(name); } - appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); + appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(140 /* SyntaxKind.KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context)); } else { appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context); } var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode); var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined; - var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), context); + var templateTypeNode = typeToTypeNodeHelper(removeMissingType(getTemplateTypeFromMappedType(type), !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), context); var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode, /*members*/ undefined); context.approximateLength += 10; - var result = ts.setEmitFlags(mappedTypeNode, 1 /* SingleLine */); - if (isMappedTypeWithKeyofConstraintDeclaration(type) && !(getModifiersTypeFromMappedType(type).flags & 262144 /* TypeParameter */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + var result = ts.setEmitFlags(mappedTypeNode, 1 /* EmitFlags.SingleLine */); + if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type) && context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { // homomorphic mapped type with a non-homomorphic naive inlining // wrap it with a conditional like `SomeModifiersType extends infer U ? {..the mapped type...} : never` to ensure the resulting // type stays homomorphic - return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName))), result, ts.factory.createKeywordTypeNode(143 /* NeverKeyword */)); + var originalConstraint = instantiateType(getConstraintOfTypeParameter(getTypeFromTypeNode(type.declaration.typeParameter.constraint.type)) || unknownType, type.mapper); + return ts.factory.createConditionalTypeNode(typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context), ts.factory.createInferTypeNode(ts.factory.createTypeParameterDeclaration(/*modifiers*/ undefined, ts.factory.cloneNode(newTypeVariable.typeName), originalConstraint.flags & 2 /* TypeFlags.Unknown */ ? undefined : typeToTypeNodeHelper(originalConstraint, context))), result, ts.factory.createKeywordTypeNode(143 /* SyntaxKind.NeverKeyword */)); } return result; } @@ -53071,16 +53259,16 @@ var ts; var typeId = type.id; var symbol = type.symbol; if (symbol) { - var isInstanceType = isClassInstanceSide(type) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = isClassInstanceSide(type) ? 788968 /* SymbolFlags.Type */ : 111551 /* SymbolFlags.Value */; if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ + else if (symbol.flags & 32 /* SymbolFlags.Class */ && !getBaseTypeVariableOfClass(symbol) - && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* Accessible */)) || - symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + && !(symbol.valueDeclaration && ts.isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && (!ts.isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(symbol, context.enclosingDeclaration, isInstanceType, /*computeAliases*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */)) || + symbol.flags & (384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, isInstanceType); } @@ -53089,7 +53277,7 @@ var ts; var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - return symbolToTypeNode(typeAlias, context, 788968 /* Type */); + return symbolToTypeNode(typeAlias, context, 788968 /* SymbolFlags.Type */); } else { return createElidedInformationPlaceholder(context); @@ -53105,26 +53293,26 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { var _a; - var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */) && // typeof static method + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* SymbolFlags.Method */) && // typeof static method ts.some(symbol.declarations, function (declaration) { return ts.isStatic(declaration); }); - var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* SymbolFlags.Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 305 /* SourceFile */ || declaration.parent.kind === 262 /* ModuleBlock */; + return declaration.parent.kind === 305 /* SyntaxKind.SourceFile */ || declaration.parent.kind === 262 /* SyntaxKind.ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions - return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed + return (!!(context.flags & 4096 /* NodeBuilderFlags.UseTypeOfFunction */) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) && // it is type of the symbol uses itself recursively + (!(context.flags & 8 /* NodeBuilderFlags.UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } function visitAndTransformType(type, transform) { var _a, _b; var typeId = type.id; - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : - type.flags & 16777216 /* Conditional */ ? "N" + getNodeId(type.root.node) : + var isConstructorObject = ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & 32 /* SymbolFlags.Class */; + var id = ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.node ? "N" + getNodeId(type.node) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? "N" + getNodeId(type.root.node) : type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : undefined; // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead @@ -53136,7 +53324,7 @@ var ts; context.symbolDepth = new ts.Map(); } var links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration); - var key = getTypeId(type) + "|" + context.flags; + var key = "".concat(getTypeId(type), "|").concat(context.flags); if (links) { links.serializedTypes || (links.serializedTypes = new ts.Map()); } @@ -53195,20 +53383,20 @@ var ts; if (!resolved.properties.length && !resolved.indexInfos.length) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { context.approximateLength += 2; - return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* SingleLine */); + return ts.setEmitFlags(ts.factory.createTypeLiteralNode(/*members*/ undefined), 1 /* EmitFlags.SingleLine */); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 179 /* SyntaxKind.FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 180 /* SyntaxKind.ConstructorType */, context); return signatureNode; } } - var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); }); + var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); }); if (ts.some(abstractSignatures)) { var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature); // count the number of type elements excluding abstract constructors @@ -53217,8 +53405,8 @@ var ts; resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per // the logic in `createTypeNodesFromResolvedType`. - (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? - ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* Prototype */); }) : + (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ ? + ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */); }) : ts.length(resolved.properties)); // don't include an empty object literal if there were no other static-side // properties to write, i.e. `abstract class C { }` becomes `abstract new () => {}` @@ -53230,27 +53418,27 @@ var ts; return typeToTypeNodeHelper(getIntersectionType(types), context); } var savedFlags = context.flags; - context.flags |= 4194304 /* InObjectTypeLiteral */; + context.flags |= 4194304 /* NodeBuilderFlags.InObjectTypeLiteral */; var members = createTypeNodesFromResolvedType(resolved); context.flags = savedFlags; var typeLiteralNode = ts.factory.createTypeLiteralNode(members); context.approximateLength += 2; - ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); + ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* NodeBuilderFlags.MultilineObjectLiterals */) ? 0 : 1 /* EmitFlags.SingleLine */); return typeLiteralNode; } function typeReferenceToTypeNode(type) { var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { - if (context.flags & 2 /* WriteArrayAsGenericType */) { + if (context.flags & 2 /* NodeBuilderFlags.WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]); } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.factory.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, arrayType); } - else if (type.target.objectFlags & 8 /* Tuple */) { - typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* Optional */)); }); + else if (type.target.objectFlags & 8 /* ObjectFlags.Tuple */) { + typeArguments = ts.sameMap(typeArguments, function (t, i) { return removeMissingType(t, !!(type.target.elementFlags[i] & 2 /* ElementFlags.Optional */)); }); if (typeArguments.length > 0) { var arity = getTypeReferenceArity(type); var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context); @@ -53258,7 +53446,7 @@ var ts; if (type.target.labeledElementDeclarations) { for (var i = 0; i < tupleConstituentNodes.length; i++) { var flags = type.target.elementFlags[i]; - tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* Variable */ ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : + tupleConstituentNodes[i] = ts.factory.createNamedTupleMember(flags & 12 /* ElementFlags.Variable */ ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined, ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(getTupleElementLabel(type.target.labeledElementDeclarations[i]))), flags & 2 /* ElementFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]); } } @@ -53266,23 +53454,23 @@ var ts; for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) { var flags = type.target.elementFlags[i]; tupleConstituentNodes[i] = - flags & 12 /* Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : - flags & 2 /* Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : + flags & 12 /* ElementFlags.Variable */ ? ts.factory.createRestTypeNode(flags & 4 /* ElementFlags.Rest */ ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) : + flags & 2 /* ElementFlags.Optional */ ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]; } } - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } - if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { - var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* SingleLine */); - return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + if (context.encounteredError || (context.flags & 524288 /* NodeBuilderFlags.AllowEmptyTuple */)) { + var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1 /* EmitFlags.SingleLine */); + return type.target.readonly ? ts.factory.createTypeOperatorNode(145 /* SyntaxKind.ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 } - else if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && + else if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ && type.symbol.valueDeclaration && ts.isClassLike(type.symbol.valueDeclaration) && !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) { @@ -53306,8 +53494,8 @@ var ts; if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var flags_3 = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var ref = symbolToTypeNode(parent, context, 788968 /* Type */, typeArgumentSlice); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var ref = symbolToTypeNode(parent, context, 788968 /* SymbolFlags.Type */, typeArgumentSlice); context.flags = flags_3; resultType = !resultType ? ref : appendReferenceToType(resultType, ref); } @@ -53319,8 +53507,8 @@ var ts; typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); } var flags = context.flags; - context.flags |= 16 /* ForbidIndexedAccessSymbolReferences */; - var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* Type */, typeArgumentNodes); + context.flags |= 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */; + var finalRef = symbolToTypeNode(type.symbol, context, 788968 /* SymbolFlags.Type */, typeArgumentNodes); context.flags = flags; return !resultType ? finalRef : appendReferenceToType(resultType, finalRef); } @@ -53384,17 +53572,17 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 174 /* SyntaxKind.CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - if (signature.flags & 4 /* Abstract */) + if (signature.flags & 4 /* SignatureFlags.Abstract */) continue; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 175 /* SyntaxKind.ConstructSignature */, context)); } for (var _d = 0, _e = resolvedType.indexInfos; _d < _e.length; _d++) { var info = _e[_d]; - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(info, context, resolvedType.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? createElidedInformationPlaceholder(context) : undefined)); } var properties = resolvedType.properties; if (!properties) { @@ -53404,16 +53592,16 @@ var ts; for (var _f = 0, properties_1 = properties; _f < properties_1.length; _f++) { var propertySymbol = properties_1[_f]; i++; - if (context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) { - if (propertySymbol.flags & 4194304 /* Prototype */) { + if (context.flags & 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */) { + if (propertySymbol.flags & 4194304 /* SymbolFlags.Prototype */) { continue; } - if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* Private */ | 16 /* Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { + if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */) && context.tracker.reportPrivateInBaseOfClassExpression) { context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName)); } } if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) { - typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... " + (properties.length - i) + " more ...", /*questionToken*/ undefined, /*type*/ undefined)); + typeElements.push(ts.factory.createPropertySignature(/*modifiers*/ undefined, "... ".concat(properties.length - i, " more ..."), /*questionToken*/ undefined, /*type*/ undefined)); addPropertyToElementList(properties[properties.length - 1], context, typeElements); break; } @@ -53424,10 +53612,10 @@ var ts; } function createElidedInformationPlaceholder(context) { context.approximateLength += 3; - if (!(context.flags & 1 /* NoTruncation */)) { + if (!(context.flags & 1 /* NodeBuilderFlags.NoTruncation */)) { return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } function shouldUsePlaceholderForProperty(propertySymbol, context) { var _a; @@ -53437,14 +53625,14 @@ var ts; // Since anonymous types usually come from expressions, this allows us to preserve the output // for deep mappings which likely come from expressions, while truncating those parts which // come from mappings over library functions. - return !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */) + return !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */) && (ts.contains(context.reverseMappedStack, propertySymbol) || (((_a = context.reverseMappedStack) === null || _a === void 0 ? void 0 : _a[0]) - && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* Anonymous */))); + && !(ts.getObjectFlags(ts.last(context.reverseMappedStack).propertyType) & 16 /* ObjectFlags.Anonymous */))); } function addPropertyToElementList(propertySymbol, context, typeElements) { var _a, _b; - var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); + var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* CheckFlags.ReverseMapped */); var propertyType = shouldUsePlaceholderForProperty(propertySymbol, context) ? anyType : getNonMissingTypeOfSymbol(propertySymbol); var saveEnclosingDeclaration = context.enclosingDeclaration; @@ -53472,12 +53660,12 @@ var ts; var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context); context.enclosingDeclaration = saveEnclosingDeclaration; context.approximateLength += (ts.symbolName(propertySymbol).length + 1); - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined; - if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { - var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); + var optionalToken = propertySymbol.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { + var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* TypeFlags.Undefined */); }), 0 /* SignatureKind.Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 168 /* SyntaxKind.MethodSignature */, context, { name: propertyName, questionToken: optionalToken }); typeElements.push(preserveCommentsOn(methodDeclaration)); } } @@ -53491,12 +53679,12 @@ var ts; context.reverseMappedStack || (context.reverseMappedStack = []); context.reverseMappedStack.push(propertySymbol); } - propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); if (propertyIsReverseMapped) { context.reverseMappedStack.pop(); } } - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } @@ -53505,11 +53693,11 @@ var ts; } function preserveCommentsOn(node) { var _a; - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* JSDocPropertyTag */; })) { - var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; })) { + var d = (_a = propertySymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.kind === 347 /* SyntaxKind.JSDocPropertyTag */; }); var commentText = ts.getTextOfJSDocComment(d.comment); if (commentText) { - ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); } } else if (propertySymbol.valueDeclaration) { @@ -53528,12 +53716,12 @@ var ts; else if (types.length > 2) { return [ typeToTypeNodeHelper(types[0], context), - ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", /*typeArguments*/ undefined), + ts.factory.createTypeReferenceNode("... ".concat(types.length - 2, " more ..."), /*typeArguments*/ undefined), typeToTypeNodeHelper(types[types.length - 1], context) ]; } } - var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); + var mayHaveNameCollisions = !(context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */); /** Map from type reference identifier text to [type, index in `result` where the type node is] */ var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; var result_5 = []; @@ -53542,7 +53730,7 @@ var ts; var type = types_2[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result_5.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_5.push(ts.factory.createTypeReferenceNode("... ".concat(types.length - i, " more ..."), /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { result_5.push(typeNode_1); @@ -53567,7 +53755,7 @@ var ts; // type node for each entry by that name with the // `UseFullyQualifiedType` flag enabled. var saveContextFlags = context.flags; - context.flags |= 64 /* UseFullyQualifiedType */; + context.flags |= 64 /* NodeBuilderFlags.UseFullyQualifiedType */; seenNames.forEach(function (types) { if (!ts.arrayIsHomogeneous(types, function (_a, _b) { var a = _a[0]; @@ -53601,21 +53789,21 @@ var ts; if (!typeNode) { typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); } - if (!indexInfo.type && !(context.flags & 2097152 /* AllowEmptyIndexInfoType */)) { + if (!indexInfo.type && !(context.flags & 2097152 /* NodeBuilderFlags.AllowEmptyIndexInfoType */)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); - return ts.factory.createIndexSignature(indexInfo.isReadonly ? [ts.factory.createToken(145 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + return ts.factory.createIndexSignature(indexInfo.isReadonly ? [ts.factory.createToken(145 /* SyntaxKind.ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context, options) { var _a, _b, _c, _d; - var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; + var suppressAny = context.flags & 256 /* NodeBuilderFlags.SuppressAnyReturnType */; if (suppressAny) - context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s + context.flags &= ~256 /* NodeBuilderFlags.SuppressAnyReturnType */; // suppress only toplevel `any`s context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum var typeParameters; var typeArguments; - if (context.flags & 32 /* WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { + if (context.flags & 32 /* NodeBuilderFlags.WriteTypeArgumentsOfSignature */ && signature.target && signature.mapper && signature.target.typeParameters) { typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); }); } else { @@ -53623,19 +53811,19 @@ var ts; } var expandedParams = getExpandedParameters(signature, /*skipUnionExpanding*/ true)[0]; // If the expanded parameter list had a variadic in a non-trailing position, don't expand it - var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); - var thisParameter = tryGetThisParameterDeclaration(signature, context); + var parameters = (ts.some(expandedParams, function (p) { return p !== expandedParams[expandedParams.length - 1] && !!(ts.getCheckFlags(p) & 32768 /* CheckFlags.RestParameter */); }) ? signature.parameters : expandedParams).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 171 /* SyntaxKind.Constructor */, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); }); + var thisParameter = context.flags & 33554432 /* NodeBuilderFlags.OmitThisParameter */ ? undefined : tryGetThisParameterDeclaration(signature, context); if (thisParameter) { parameters.unshift(thisParameter); } var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.factory.createToken(128 /* AssertsKeyword */) : + var assertsModifier = typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined; - var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? - ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : + var parameterName = typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? + ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216 /* EmitFlags.NoAsciiEscaping */) : ts.factory.createThisTypeNode(); var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode); @@ -53646,28 +53834,28 @@ var ts; returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports); } else if (!suppressAny) { - returnTypeNode = ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + returnTypeNode = ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } var modifiers = options === null || options === void 0 ? void 0 : options.modifiers; - if ((kind === 180 /* ConstructorType */) && signature.flags & 4 /* Abstract */) { + if ((kind === 180 /* SyntaxKind.ConstructorType */) && signature.flags & 4 /* SignatureFlags.Abstract */) { var flags = ts.modifiersToFlags(modifiers); - modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* Abstract */); - } - var node = kind === 174 /* CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : - kind === 175 /* ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : - kind === 168 /* MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : - kind === 169 /* MethodDeclaration */ ? ts.factory.createMethodDeclaration(modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 171 /* Constructor */ ? ts.factory.createConstructorDeclaration(modifiers, parameters, /*body*/ undefined) : - kind === 172 /* GetAccessor */ ? ts.factory.createGetAccessorDeclaration(modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === 173 /* SetAccessor */ ? ts.factory.createSetAccessorDeclaration(modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === 176 /* IndexSignature */ ? ts.factory.createIndexSignature(modifiers, parameters, returnTypeNode) : - kind === 317 /* JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : - kind === 179 /* FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 180 /* ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : - kind === 256 /* FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === 213 /* FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : - kind === 214 /* ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : + modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128 /* ModifierFlags.Abstract */); + } + var node = kind === 174 /* SyntaxKind.CallSignature */ ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) : + kind === 175 /* SyntaxKind.ConstructSignature */ ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : + kind === 168 /* SyntaxKind.MethodSignature */ ? ts.factory.createMethodSignature(modifiers, (_a = options === null || options === void 0 ? void 0 : options.name) !== null && _a !== void 0 ? _a : ts.factory.createIdentifier(""), options === null || options === void 0 ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : + kind === 169 /* SyntaxKind.MethodDeclaration */ ? ts.factory.createMethodDeclaration(modifiers, /*asteriskToken*/ undefined, (_b = options === null || options === void 0 ? void 0 : options.name) !== null && _b !== void 0 ? _b : ts.factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 171 /* SyntaxKind.Constructor */ ? ts.factory.createConstructorDeclaration(modifiers, parameters, /*body*/ undefined) : + kind === 172 /* SyntaxKind.GetAccessor */ ? ts.factory.createGetAccessorDeclaration(modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === 173 /* SyntaxKind.SetAccessor */ ? ts.factory.createSetAccessorDeclaration(modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === 176 /* SyntaxKind.IndexSignature */ ? ts.factory.createIndexSignature(modifiers, parameters, returnTypeNode) : + kind === 317 /* SyntaxKind.JSDocFunctionType */ ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) : + kind === 179 /* SyntaxKind.FunctionType */ ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 180 /* SyntaxKind.ConstructorType */ ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) : + kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.factory.createFunctionDeclaration(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === 213 /* SyntaxKind.FunctionExpression */ ? ts.factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, ts.factory.createBlock([])) : + kind === 214 /* SyntaxKind.ArrowFunction */ ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, ts.factory.createBlock([])) : ts.Debug.assertNever(kind); if (typeArguments) { node.typeArguments = ts.factory.createNodeArray(typeArguments); @@ -53690,7 +53878,7 @@ var ts; } function typeParameterToDeclarationWithConstraint(type, context, constraintNode) { var savedContextFlags = context.flags; - context.flags &= ~512 /* WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic + context.flags &= ~512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */; // Avoids potential infinite loop when building for a claimspace with a generic var modifiers = ts.factory.createModifiersFromModifierFlags(getVarianceModifiers(type)); var name = typeParameterToName(type, context); var defaultParameter = getDefaultFromTypeParameter(type); @@ -53704,26 +53892,26 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 164 /* SyntaxKind.Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 340 /* SyntaxKind.JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && ts.canHaveModifiers(parameterDeclaration) ? ts.map(ts.getModifiers(parameterDeclaration), ts.factory.cloneNode) : undefined; - var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; - var dotDotDotToken = isRest ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined; + var modifiers = !(context.flags & 8192 /* NodeBuilderFlags.OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && ts.canHaveModifiers(parameterDeclaration) ? ts.map(ts.getModifiers(parameterDeclaration), ts.factory.cloneNode) : undefined; + var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* CheckFlags.RestParameter */; + var dotDotDotToken = isRest ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined; var name = parameterDeclaration ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 79 /* Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 161 /* QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216 /* EmitFlags.NoAsciiEscaping */) : + parameterDeclaration.name.kind === 161 /* SyntaxKind.QualifiedName */ ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216 /* EmitFlags.NoAsciiEscaping */) : cloneBindingName(parameterDeclaration.name) : ts.symbolName(parameterSymbol) : ts.symbolName(parameterSymbol); - var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.factory.createToken(57 /* QuestionToken */) : undefined; + var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* CheckFlags.OptionalParameter */; + var questionToken = isOptional ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined; var parameterNode = ts.factory.createParameterDeclaration(modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); context.approximateLength += ts.symbolName(parameterSymbol).length + 3; @@ -53749,7 +53937,7 @@ var ts; if (!ts.nodeIsSynthesized(visited)) { visited = ts.factory.cloneNode(visited); } - return ts.setEmitFlags(visited, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); + return ts.setEmitFlags(visited, 1 /* EmitFlags.SingleLine */ | 16777216 /* EmitFlags.NoAsciiEscaping */); } } } @@ -53758,9 +53946,9 @@ var ts; return; // get symbol of the first identifier of the entityName var firstIdentifier = ts.getFirstIdentifier(accessExpression); - var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { - context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); + context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* SymbolFlags.Value */); } } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { @@ -53770,8 +53958,8 @@ var ts; function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; - var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; - if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) { + var isTypeParameter = symbol.flags & 262144 /* SymbolFlags.TypeParameter */; + if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* NodeBuilderFlags.UseFullyQualifiedType */) && !(context.flags & 134217728 /* NodeBuilderFlags.DoNotIncludeSymbolChain */)) { chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } @@ -53781,7 +53969,7 @@ var ts; return chain; /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ function getSymbolChain(symbol, meaning, endOfChain) { - var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* UseOnlyExternalAliasing */)); + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128 /* NodeBuilderFlags.UseOnlyExternalAliasing */)); var parentSpecifiers; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { @@ -53800,8 +53988,8 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { - if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && - getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + if (parent.exports && parent.exports.get("export=" /* InternalSymbolName.ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* InternalSymbolName.ExportEquals */), symbol)) { // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent // No need to lookup an alias for the symbol in itself accessibleSymbolChain = parentChain; @@ -53820,7 +54008,7 @@ var ts; // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. endOfChain || // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */))) { // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return; @@ -53850,7 +54038,7 @@ var ts; function typeParametersToTypeParameterDeclarations(symbol, context) { var typeParameterNodes; var targetSymbol = getTargetSymbol(symbol); - if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + if (targetSymbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */ | 524288 /* SymbolFlags.TypeAlias */)) { typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); })); } return typeParameterNodes; @@ -53865,11 +54053,11 @@ var ts; } (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId); var typeParameterNodes; - if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { + if (context.flags & 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { var parentSymbol = symbol; var nextSymbol_1 = chain[index + 1]; - if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) { - var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol); + if (ts.getCheckFlags(nextSymbol_1) & 1 /* CheckFlags.Instantiated */) { + var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(parentSymbol) : parentSymbol); typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context); } else { @@ -53889,11 +54077,11 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context, overrideImportMode) { var _a; - var file = ts.getDeclarationOfKind(symbol, 305 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 305 /* SyntaxKind.SourceFile */); if (!file) { var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); if (equivalentFileSymbol) { - file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SourceFile */); + file = ts.getDeclarationOfKind(equivalentFileSymbol, 305 /* SyntaxKind.SourceFile */); } } if (file && file.moduleName !== undefined) { @@ -53945,7 +54133,7 @@ var ts; } return specifier; function getSpecifierCacheKey(path, mode) { - return mode === undefined ? path : mode + "|" + path; + return mode === undefined ? path : "".concat(mode, "|").concat(path); } } function symbolToEntityNameNode(symbol) { @@ -53954,8 +54142,8 @@ var ts; } function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) { var _a, _b, _c, _d; - var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module - var isTypeOf = meaning === 111551 /* Value */; + var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */)); // If we're using aliases outside the current scope, dont bother with the module + var isTypeOf = meaning === 111551 /* SymbolFlags.Value */; if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { // module is root, must use `ImportTypeNode` var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; @@ -53977,7 +54165,7 @@ var ts; if (!specifier) { specifier = getSpecifierForModuleSymbol(chain[0], context); } - if (!(context.flags & 67108864 /* AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & 67108864 /* NodeBuilderFlags.AllowNodeModulesRelativePaths */) && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { var oldSpecifier = specifier; if (ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeNext) { // We might be able to write a portable import type using a mode override; try specifier generation again, but with a different mode set @@ -54039,16 +54227,16 @@ var ts; var parent = chain[index - 1]; var symbolName; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; symbolName = getNameOfSymbolAsWritten(symbol, context); context.approximateLength += (symbolName ? symbolName.length : 0) + 1; - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } else { if (parent && getExportsOfSymbol(parent)) { var exports_2 = getExportsOfSymbol(parent); ts.forEachEntry(exports_2, function (ex, name) { - if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* InternalSymbolName.ExportEquals */) { symbolName = ts.unescapeLeadingUnderscores(name); return true; } @@ -54067,7 +54255,7 @@ var ts; symbolName = getNameOfSymbolAsWritten(symbol, context); } context.approximateLength += symbolName.length + 1; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + if (!(context.flags & 16 /* NodeBuilderFlags.ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access @@ -54079,7 +54267,7 @@ var ts; return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName))); } } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; if (index > stopper) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); @@ -54092,9 +54280,9 @@ var ts; } } function typeParameterShadowsNameInScope(escapedName, context, type) { - var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* SymbolFlags.Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); if (result) { - if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) { + if (result.flags & 262144 /* SymbolFlags.TypeParameter */ && result === type.symbol) { return false; } return true; @@ -54103,23 +54291,23 @@ var ts; } function typeParameterToName(type, context) { var _a, _b; - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { var cached = context.typeParameterNames.get(getTypeId(type)); if (cached) { return cached; } } - var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); - if (!(result.kind & 79 /* Identifier */)) { + var result = symbolToName(type.symbol, context, 788968 /* SymbolFlags.Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 79 /* SyntaxKind.Identifier */)) { return ts.factory.createIdentifier("(Missing type parameter)"); } - if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { + if (context.flags & 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = ((_a = context.typeParameterNamesByTextNextNameCount) === null || _a === void 0 ? void 0 : _a.get(rawtext)) || 0; var text = rawtext; while (((_b = context.typeParameterNamesByText) === null || _b === void 0 ? void 0 : _b.has(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; - text = rawtext + "_" + i; + text = "".concat(rawtext, "_").concat(i); } if (text !== rawtext) { result = ts.factory.createIdentifier(text, result.typeArguments); @@ -54136,7 +54324,7 @@ var ts; var chain = lookupSymbolChain(symbol, context, meaning); if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & 65536 /* AllowQualifiedNameInPlaceOfIdentifier */)) { + && !(context.flags & 65536 /* NodeBuilderFlags.AllowQualifiedNameInPlaceOfIdentifier */)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); @@ -54144,13 +54332,13 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -54162,38 +54350,38 @@ var ts; var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; if (index === 0) { - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var symbolName = getNameOfSymbolAsWritten(symbol, context); if (index === 0) { - context.flags ^= 16777216 /* InInitialEntityName */; + context.flags ^= 16777216 /* NodeBuilderFlags.InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context)); } - var canUsePropertyAccess = firstChar === 35 /* hash */ ? + var canUsePropertyAccess = firstChar === 35 /* CharacterCodes.hash */ ? symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) : ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { - var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); identifier.symbol = symbol; return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier; } else { - if (firstChar === 91 /* openBracket */) { + if (firstChar === 91 /* CharacterCodes.openBracket */) { symbolName = symbolName.substring(1, symbolName.length - 1); firstChar = symbolName.charCodeAt(0); } var expression = void 0; - if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* EnumMember */)) { - expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* singleQuote */); + if (ts.isSingleOrDoubleQuote(firstChar) && !(symbol.flags & 8 /* SymbolFlags.EnumMember */)) { + expression = ts.factory.createStringLiteral(ts.stripQuotes(symbolName).replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39 /* CharacterCodes.singleQuote */); } else if (("" + +symbolName) === symbolName) { expression = ts.factory.createNumericLiteral(+symbolName); } if (!expression) { - expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); + expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216 /* EmitFlags.NoAsciiEscaping */); expression.symbol = symbol; } return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression); @@ -54222,7 +54410,7 @@ var ts; function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { return ts.factory.createStringLiteral(name, !!singleQuote); @@ -54232,8 +54420,8 @@ var ts; } return ts.createPropertyNameNodeForIdentifierOrLiteral(name, ts.getEmitScriptTarget(compilerOptions)); } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* SymbolFlags.Value */)); } } } @@ -54267,7 +54455,7 @@ var ts; 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); + return !(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag @@ -54288,9 +54476,9 @@ var ts; } } var oldFlags = context.flags; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) { - context.flags |= 1048576 /* AllowUniqueESSymbolType */; + context.flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } var result = typeToTypeNodeHelper(type, context); context.flags = oldFlags; @@ -54302,7 +54490,7 @@ var ts; return true; } if (ts.isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) { - return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode; + return getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */) === typeFromTypeNode; } return false; } @@ -54311,7 +54499,7 @@ var ts; var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation) { var annotated = getTypeFromTypeNode(annotation); - var thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; + var thisInstantiated = annotated.flags & 262144 /* TypeFlags.TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated; if (thisInstantiated === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { @@ -54330,20 +54518,20 @@ var ts; introducesError = true; return { introducesError: introducesError, node: node }; } - var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + var sym = resolveEntityName(leftmost, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); if (sym) { - if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) { + if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* SymbolAccessibility.Accessible */) { introducesError = true; } else { - (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */); + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* SymbolFlags.All */); includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym); } if (ts.isIdentifier(node)) { var type = getDeclaredTypeOfSymbol(sym); - var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); + var name = sym.flags & 262144 /* SymbolFlags.TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node); name.symbol = sym; // for quickinfo, which uses identifier symbol information - return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) }; + return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* EmitFlags.NoAsciiEscaping */) }; } } return { introducesError: introducesError, node: node }; @@ -54361,17 +54549,17 @@ var ts; return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed; function visitExistingNodeTreeSymbols(node) { // We don't _actually_ support jsdoc namepath types, emit `any` instead - if (ts.isJSDocAllType(node) || node.kind === 319 /* JSDocNamepathType */) { - return ts.factory.createKeywordTypeNode(130 /* AnyKeyword */); + if (ts.isJSDocAllType(node) || node.kind === 319 /* SyntaxKind.JSDocNamepathType */) { + return ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } if (ts.isJSDocUnknownType(node)) { - return ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */); + return ts.factory.createKeywordTypeNode(155 /* SyntaxKind.UnknownKeyword */); } if (ts.isJSDocNullableType(node)) { return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]); } if (ts.isJSDocOptionalType(node)) { - return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* UndefinedKeyword */)]); + return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(153 /* SyntaxKind.UndefinedKeyword */)]); } if (ts.isJSDocNonNullableType(node)) { return ts.visitNode(node.type, visitExistingNodeTreeSymbols); @@ -54385,11 +54573,11 @@ var ts; var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; return ts.factory.createPropertySignature( - /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*modifiers*/ undefined, name, t.isBracketed || t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); })); } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { - return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */), node); + return ts.setOriginalNode(ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */), node); } if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { return ts.factory.createTypeLiteralNode([ts.factory.createIndexSignature( @@ -54404,15 +54592,15 @@ var ts; return ts.factory.createConstructorTypeNode( /*modifiers*/ undefined, ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.factory.createParameterDeclaration( /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } else { return ts.factory.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.factory.createParameterDeclaration( /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols) || ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); } } - if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* Type */, /*ignoreErrors*/ true))) { + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); } if (ts.isLiteralImportTypeNode(node)) { @@ -54421,7 +54609,7 @@ var ts; nodeSymbol && ( // The import type resolved using jsdoc fallback logic - (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */)) || + (!node.isTypeOf && !(nodeSymbol.flags & 788968 /* SymbolFlags.Type */)) || // The import type had type arguments autofilled by js fallback logic !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) { return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); @@ -54436,17 +54624,17 @@ var ts; } } if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) { - ts.setEmitFlags(node, 1 /* SingleLine */); + ts.setEmitFlags(node, 1 /* EmitFlags.SingleLine */); } return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); function getEffectiveDotDotDotForParameter(p) { - return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* DotDotDotToken */) : undefined); + return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25 /* SyntaxKind.DotDotDotToken */) : undefined); } /** Note that `new:T` parameters are not handled, but should be before calling this function. */ function getNameForJSDocFunctionParameter(p, index) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? "args" - : "arg" + index; + : "arg".concat(index); } function rewriteModuleSpecifier(parent, lit) { if (bundled) { @@ -54477,8 +54665,8 @@ var ts; } } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { - var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* MethodDeclaration */, /*useAcessors*/ true); - var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* MethodSignature */, /*useAcessors*/ false); + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 169 /* SyntaxKind.MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 168 /* SyntaxKind.MethodSignature */, /*useAcessors*/ false); // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of // declaration mapping // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration @@ -54491,10 +54679,10 @@ var ts; var oldcontext = context; context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeAliases*/ false); - if (accessibleResult.accessibility === 0 /* Accessible */) { + if (accessibleResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Lookup the root symbol of the chain of refs we'll use to access it and serialize it var chain = lookupSymbolChainWorker(sym, context, meaning); - if (!(sym.flags & 4 /* Property */)) { + if (!(sym.flags & 4 /* SymbolFlags.Property */)) { includePrivateSymbol(chain[0]); } } @@ -54509,16 +54697,16 @@ var ts; void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` }); var addingDeclare = !bundled; - var exportEquals = symbolTable.get("export=" /* ExportEquals */); - if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + var exportEquals = symbolTable.get("export=" /* InternalSymbolName.ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* SymbolFlags.Alias */) { symbolTable = ts.createSymbolTable(); // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) - symbolTable.set("export=" /* ExportEquals */, exportEquals); + symbolTable.set("export=" /* InternalSymbolName.ExportEquals */, exportEquals); } visitSymbolTable(symbolTable); return mergeRedundantStatements(results); function isIdentifierAndNotUndefined(node) { - return !!node && node.kind === 79 /* Identifier */; + return !!node && node.kind === 79 /* SyntaxKind.Identifier */; } function getNamesOfDeclaration(statement) { if (ts.isVariableStatement(statement)) { @@ -54535,7 +54723,7 @@ var ts; ns.body && ts.isModuleBlock(ns.body)) { // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments - var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* Export */); }); + var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1 /* ModifierFlags.Export */); }); var name_3 = ns.name; var body = ns.body; if (ts.length(excessExports)) { @@ -54550,9 +54738,9 @@ var ts; results = []; // If the namespace contains no export assignments or declarations, and no declarations flagged with `export`, then _everything_ is exported - // to respect this as the top level, we need to add an `export` modifier to everything - var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); + var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1 /* ModifierFlags.Export */) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); }); ts.forEach(body.statements, function (s) { - addResult(s, mixinExportFlag_1 ? 1 /* Export */ : 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + addResult(s, mixinExportFlag_1 ? 1 /* ModifierFlags.Export */ : 0 /* ModifierFlags.None */); // Recalculates the ambient (and export, if applicable from above) flag }); statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), true), results, true); } @@ -54646,11 +54834,11 @@ var ts; isTypeDeclaration(node); } function addExportModifier(node) { - var flags = (ts.getEffectiveModifierFlags(node) | 1 /* Export */) & ~2 /* Ambient */; + var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */; return ts.factory.updateModifiers(node, flags); } function removeExportModifier(node) { - var flags = ts.getEffectiveModifierFlags(node) & ~1 /* Export */; + var flags = ts.getEffectiveModifierFlags(node) & ~1 /* ModifierFlags.Export */; return ts.factory.updateModifiers(node, flags); } function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { @@ -54683,12 +54871,11 @@ var ts; if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { var oldContext = context; context = cloneNodeBuilderContext(context); - var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); if (context.reportedDiagnostic) { oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context } context = oldContext; - return result; } } // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias @@ -54703,37 +54890,37 @@ var ts; function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { var _a, _b, _c, _d; var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isDefault = symbol.escapedName === "default" /* Default */; - if (isPrivate && !(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + var isDefault = symbol.escapedName === "default" /* InternalSymbolName.Default */; + if (isPrivate && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( context.encounteredError = true; // TODO: Issue error via symbol tracker? return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name } - var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ - || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* SymbolFlags.ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* SymbolFlags.Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* SymbolFlags.Alias */); // An alias symbol should preclude needing to make an alias ourselves var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault; // `serializeVariableOrProperty` will handle adding the export declaration if it is run (since `getInternalSymbolName` will create the name mapping), so we need to ensuer we unset `needsExportDeclaration` if it is if (needsPostExportDefault || needsExportDeclaration) { isPrivate = true; } - var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); - var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && - symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && - symbol.escapedName !== "export=" /* ExportEquals */; + var modifierFlags = (!isPrivate ? 1 /* ModifierFlags.Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* ModifierFlags.Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* SymbolFlags.Module */ && + symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) && + symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); - if (symbol.flags & (16 /* Function */ | 8192 /* Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { serializeTypeAlias(symbol, symbolName, modifierFlags); } // Need to skip over export= symbols below - json source files get a single `Property` flagged // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. - if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) - && symbol.escapedName !== "export=" /* ExportEquals */ - && !(symbol.flags & 4194304 /* Prototype */) - && !(symbol.flags & 32 /* Class */) + if (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 1 /* SymbolFlags.FunctionScopedVariable */ | 4 /* SymbolFlags.Property */) + && symbol.escapedName !== "export=" /* InternalSymbolName.ExportEquals */ + && !(symbol.flags & 4194304 /* SymbolFlags.Prototype */) + && !(symbol.flags & 32 /* SymbolFlags.Class */) && !isConstMergedWithNSPrintableAsSignatureMerge) { if (propertyAsAlias) { var createdExport = serializeMaybeAliasAssignment(symbol); @@ -54745,21 +54932,21 @@ var ts; else { var type = getTypeOfSymbol(symbol); var localName = getInternalSymbolName(symbol, symbolName); - if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + if (!(symbol.flags & 16 /* SymbolFlags.Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); } else { // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` - var flags = !(symbol.flags & 2 /* BlockScopedVariable */) + var flags = !(symbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) ? ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isSourceFile((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) - ? 2 /* Const */ + ? 2 /* NodeFlags.Const */ : undefined : isConstVariable(symbol) - ? 2 /* Const */ - : 1 /* Let */; - var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + ? 2 /* NodeFlags.Const */ + : 1 /* NodeFlags.Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* SymbolFlags.Property */)) ? localName : getUnusedName(localName, symbol); var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { textRange = textRange.parent.parent; @@ -54770,14 +54957,14 @@ var ts; var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* None */); - context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* Value */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)])), 0 /* ModifierFlags.None */); + context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551 /* SymbolFlags.Value */); } else { var statement = ts.setTextRange(ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], flags)), textRange); - addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + addResult(statement, name !== localName ? modifierFlags & ~1 /* ModifierFlags.Export */ : modifierFlags); if (name !== localName && !isPrivate) { // We rename the variable declaration we generate for Property symbols since they may have a name which // conflicts with a local declaration. For example, given input: @@ -54802,7 +54989,7 @@ var ts; // To create an export named `g` that does _not_ shadow the local `g` addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)])), 0 /* ModifierFlags.None */); needsExportDeclaration = false; needsPostExportDefault = false; } @@ -54810,11 +54997,11 @@ var ts; } } } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { serializeEnum(symbol, symbolName, modifierFlags); } - if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */ + if (symbol.flags & 32 /* SymbolFlags.Class */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { @@ -54827,20 +55014,20 @@ var ts; serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } } - if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + if ((symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { serializeModule(symbol, symbolName, modifierFlags); } // The class meaning serialization should handle serializing all interface members - if (symbol.flags & 64 /* Interface */ && !(symbol.flags & 32 /* Class */)) { + if (symbol.flags & 64 /* SymbolFlags.Interface */ && !(symbol.flags & 32 /* SymbolFlags.Class */)) { serializeInterface(symbol, symbolName, modifierFlags); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); } - if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.flags & 4 /* SymbolFlags.Property */ && symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } - if (symbol.flags & 8388608 /* ExportStar */) { + if (symbol.flags & 8388608 /* SymbolFlags.ExportStar */) { // synthesize export * from "moduleReference" // Straightforward - only one thing to do - make an export declaration if (symbol.declarations) { @@ -54849,17 +55036,17 @@ var ts; var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); if (!resolvedModule) continue; - addResult(ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + addResult(ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* ModifierFlags.None */); } } } if (needsPostExportDefault) { - addResult(ts.factory.createExportAssignment(/*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + addResult(ts.factory.createExportAssignment(/*modifiers*/ undefined, /*isExportAssignment*/ false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* ModifierFlags.None */); } else if (needsExportDeclaration) { addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)])), 0 /* ModifierFlags.None */); } } function includePrivateSymbol(symbol) { @@ -54872,7 +55059,7 @@ var ts; // will throw a wrench in this, since those may have been nested, but we'll need to synthesize them in the outer scope // anyway, as that's the only place the import they translate to is valid. In such a case, we might need to use a unique name // for the moved import; which hopefully the above `getUnusedName` call should produce. - var isExternalImportAlias = !!(symbol.flags & 2097152 /* Alias */) && !ts.some(symbol.declarations, function (d) { + var isExternalImportAlias = !!(symbol.flags & 2097152 /* SymbolFlags.Alias */) && !ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, ts.isExportDeclaration) || ts.isNamespaceExport(d) || (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference)); @@ -54886,23 +55073,23 @@ var ts; // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` function addResult(node, additionalModifierFlags) { if (ts.canHaveModifiers(node)) { - var newModifierFlags = 0 /* None */; + var newModifierFlags = 0 /* ModifierFlags.None */; var enclosingDeclaration_1 = context.enclosingDeclaration && (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration); - if (additionalModifierFlags & 1 /* Export */ && + if (additionalModifierFlags & 1 /* ModifierFlags.Export */ && enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) && canHaveExportModifier(node)) { // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private - newModifierFlags |= 1 /* Export */; + newModifierFlags |= 1 /* ModifierFlags.Export */; } - if (addingDeclare && !(newModifierFlags & 1 /* Export */) && - (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) && + if (addingDeclare && !(newModifierFlags & 1 /* ModifierFlags.Export */) && + (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* NodeFlags.Ambient */)) && (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope - newModifierFlags |= 2 /* Ambient */; + newModifierFlags |= 2 /* ModifierFlags.Ambient */; } - if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { - newModifierFlags |= 512 /* Default */; + if ((additionalModifierFlags & 512 /* ModifierFlags.Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* ModifierFlags.Default */; } if (newModifierFlags) { node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node)); @@ -54918,14 +55105,14 @@ var ts; var jsdocAliasDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isJSDocTypeAlias); var commentText = ts.getTextOfJSDocComment(jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined); var oldFlags = context.flags; - context.flags |= 8388608 /* InTypeAlias */; + context.flags |= 8388608 /* NodeBuilderFlags.InTypeAlias */; var oldEnclosingDecl = context.enclosingDeclaration; context.enclosingDeclaration = jsdocAliasDecl; var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); - addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(/*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3 /* SyntaxKind.MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); context.flags = oldFlags; context.enclosingDeclaration = oldEnclosingDecl; } @@ -54936,10 +55123,10 @@ var ts; var baseTypes = getBaseTypes(interfaceType); var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); - var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 174 /* CallSignature */); - var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 175 /* ConstructSignature */); + var callSignatures = serializeSignatures(0 /* SignatureKind.Call */, interfaceType, baseType, 174 /* SyntaxKind.CallSignature */); + var constructSignatures = serializeSignatures(1 /* SignatureKind.Construct */, interfaceType, baseType, 175 /* SyntaxKind.ConstructSignature */); var indexSignatures = serializeIndexSignatures(interfaceType, baseType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* Value */); }))]; + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551 /* SymbolFlags.Value */); }))]; addResult(ts.factory.createInterfaceDeclaration( /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures, true), constructSignatures, true), callSignatures, true), members, true)), modifierFlags); } @@ -54947,7 +55134,7 @@ var ts; return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); } function isTypeOnlyNamespace(symbol) { - return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); }); } function serializeModule(symbol, symbolName, modifierFlags) { var members = getNamespaceMembersForSerialization(symbol); @@ -54960,14 +55147,14 @@ var ts; // so we don't even have placeholders to fill in. if (ts.length(realMembers)) { var localName = getInternalSymbolName(symbol, symbolName); - serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* SymbolFlags.Function */ | 67108864 /* SymbolFlags.Assignment */))); } if (ts.length(mergedMembers)) { var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); var localName = getInternalSymbolName(symbol, symbolName); var nsBody = ts.factory.createModuleBlock([ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + /*isTypeOnly*/ false, ts.factory.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* InternalSymbolName.ExportEquals */; }), function (s) { var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); @@ -54982,11 +55169,11 @@ var ts; return ts.factory.createExportSpecifier(/*isTypeOnly*/ false, name === targetName ? undefined : targetName, name); })))]); addResult(ts.factory.createModuleDeclaration( - /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + /*modifiers*/ undefined, ts.factory.createIdentifier(localName), nsBody, 16 /* NodeFlags.Namespace */), 0 /* ModifierFlags.None */); } } function serializeEnum(symbol, symbolName, modifierFlags) { - addResult(ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + addResult(ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* ModifierFlags.Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* SymbolFlags.EnumMember */); }), function (p) { // TODO: Handle computed names // I hate that to get the initialized value we need to walk back to the declarations here; but there's no // other way to get the possible const value of an enum member that I'm aware of, as the value is cached @@ -54998,22 +55185,22 @@ var ts; })), modifierFlags); } function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 256 /* FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); + var decl = signatureToSignatureDeclarationHelper(sig, 256 /* SyntaxKind.FunctionDeclaration */, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled }); addResult(ts.setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports - if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + if (!(symbol.flags & (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } function getSignatureTextRangeLocation(signature) { if (signature.declaration && signature.declaration.parent) { - if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* Property */) { + if (ts.isBinaryExpression(signature.declaration.parent) && ts.getAssignmentDeclarationKind(signature.declaration.parent) === 5 /* AssignmentDeclarationKind.Property */) { return signature.declaration.parent; } // for expressions assigned to `var`s, use the `var` as the text range @@ -55047,7 +55234,7 @@ var ts; // emit akin to the above would be needed. // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace, enclosingDeclaration); fakespace.locals = ts.createSymbolTable(props); fakespace.symbol = props[0].parent; @@ -55067,15 +55254,15 @@ var ts; // replace namespace with synthetic version var defaultReplaced = ts.map(declarations, function (d) { return ts.isExportAssignment(d) && !d.isExportEquals && ts.isIdentifier(d.expression) ? ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* Default */))])) : d; }); - var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, ts.factory.createIdentifier("default" /* InternalSymbolName.Default */))])) : d; }); + var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1 /* ModifierFlags.Export */); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped)); addResult(fakespace, modifierFlags); // namespaces can never be default exported } } function isNamespaceMember(p) { - return !!(p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */)) || - !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); + return !!(p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */)) || + !(p.flags & 4194304 /* SymbolFlags.Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isStatic(p.valueDeclaration) && ts.isClassLike(p.valueDeclaration.parent)); } function sanitizeJSDocImplements(clauses) { var result = ts.mapDefined(clauses, function (e) { @@ -55124,7 +55311,7 @@ var ts; var staticBaseType = isClass ? getBaseConstructorTypeOfClass(staticType) : anyType; - var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* ImplementsKeyword */, implementsExpressions)], true); + var heritageClauses = __spreadArray(__spreadArray([], !ts.length(baseTypes) ? [] : [ts.factory.createHeritageClause(94 /* SyntaxKind.ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], true), !ts.length(implementsExpressions) ? [] : [ts.factory.createHeritageClause(117 /* SyntaxKind.ImplementsKeyword */, implementsExpressions)], true); var symbolProps = getNonInheritedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { // `valueDeclaration` could be undefined if inherited from @@ -55150,17 +55337,17 @@ var ts; ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* SymbolFlags.Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); // When we encounter an `X.prototype.y` assignment in a JS file, we bind `X` as a class regardless as to whether // the value is ever initialized with a class or function-like value. For cases where `X` could never be // created via `new`, we will inject a `private constructor()` declaration to indicate it is not createable. var isNonConstructableClassLikeInJsFile = !isClass && !!symbol.valueDeclaration && ts.isInJSFile(symbol.valueDeclaration) && - !ts.some(getSignaturesOfType(staticType, 1 /* Construct */)); + !ts.some(getSignaturesOfType(staticType, 1 /* SignatureKind.Construct */)); var constructors = isNonConstructableClassLikeInJsFile ? - [ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(8 /* Private */), [], /*body*/ undefined)] : - serializeSignatures(1 /* Construct */, staticType, staticBaseType, 171 /* Constructor */); + [ts.factory.createConstructorDeclaration(ts.factory.createModifiersFromModifierFlags(8 /* ModifierFlags.Private */), [], /*body*/ undefined)] : + serializeSignatures(1 /* SignatureKind.Construct */, staticType, staticBaseType, 171 /* SyntaxKind.Constructor */); var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(ts.setTextRange(ts.factory.createClassDeclaration( @@ -55202,34 +55389,34 @@ var ts; // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that var verbatimTargetName = ts.isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || ts.unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === "export=" /* ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === "export=" /* InternalSymbolName.ExportEquals */ && (ts.getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match - verbatimTargetName = "default" /* Default */; + verbatimTargetName = "default" /* InternalSymbolName.Default */; } var targetName = getInternalSymbolName(target, verbatimTargetName); includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first switch (node.kind) { - case 203 /* BindingElement */: - if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* VariableDeclaration */) { + case 203 /* SyntaxKind.BindingElement */: + if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 254 /* SyntaxKind.VariableDeclaration */) { // const { SomeClass } = require('./lib'); var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' var propertyName = node.propertyName; addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, ts.factory.createNamedImports([ts.factory.createImportSpecifier( /*isTypeOnly*/ false, propertyName && ts.isIdentifier(propertyName) ? ts.factory.createIdentifier(ts.idText(propertyName)) : undefined, ts.factory.createIdentifier(localName))])), ts.factory.createStringLiteral(specifier_1), - /*importClause*/ undefined), 0 /* None */); + /*importClause*/ undefined), 0 /* ModifierFlags.None */); break; } // We don't know how to serialize this (nested?) binding element ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization"); break; - case 297 /* ShorthandPropertyAssignment */: - if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* BinaryExpression */) { + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 221 /* SyntaxKind.BinaryExpression */) { // module.exports = { SomeClass } serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName); } break; - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: // commonjs require: const x = require('y') if (ts.isPropertyAccessExpression(node.initializer)) { // const x = require('y').z @@ -55239,7 +55426,7 @@ var ts; // import _x = require('y'); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* None */); + /*isTypeOnly*/ false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0 /* ModifierFlags.None */); // import x = _x.z addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, @@ -55247,48 +55434,48 @@ var ts; break; } // else fall through and treat commonjs require just like import= - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // This _specifically_ only exists to handle json declarations - where we make aliases, but since // we emit no declarations for the json document, must not refer to it in the declarations - if (target.escapedName === "export=" /* ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { + if (target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ && ts.some(target.declarations, ts.isJsonSourceFile)) { serializeMaybeAliasAssignment(symbol); break; } // Could be a local `import localName = ns.member` or // an external `import localName = require("whatever")` - var isLocalImport = !(target.flags & 512 /* ValueModule */) && !ts.isVariableDeclaration(node); + var isLocalImport = !(target.flags & 512 /* SymbolFlags.ValueModule */) && !ts.isVariableDeclaration(node); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createIdentifier(localName), isLocalImport - ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) - : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* None */); + ? symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false) + : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0 /* ModifierFlags.None */); break; - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // export as namespace foo // TODO: Not part of a file's local or export symbol tables // Is bound into file.symbol.globalExports instead, which we don't currently traverse - addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* ModifierFlags.None */); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, ts.factory.createIdentifier(localName), /*namedBindings*/ undefined), // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag // In such cases, the `target` refers to the module itself already ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, ts.factory.createNamespaceImport(ts.factory.createIdentifier(localName))), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* ModifierFlags.None */); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: addResult(ts.factory.createImportDeclaration( /*modifiers*/ undefined, ts.factory.createImportClause( /*isTypeOnly*/ false, @@ -55296,9 +55483,9 @@ var ts; ts.factory.createImportSpecifier( /*isTypeOnly*/ false, localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName)) ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context)), - /*assertClause*/ undefined), 0 /* None */); + /*assertClause*/ undefined), 0 /* ModifierFlags.None */); break; - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: // does not use localName because the symbol name in this case refers to the name in the exports table, // which we must exactly preserve var specifier = node.parent.parent.moduleSpecifier; @@ -55306,16 +55493,16 @@ var ts; // another file serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined); break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: serializeMaybeAliasAssignment(symbol); break; - case 221 /* BinaryExpression */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 221 /* SyntaxKind.BinaryExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // Could be best encoded as though an export specifier or as though an export assignment // If name is default or export=, do an export assignment // Otherwise do an export specifier - if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + if (symbol.escapedName === "default" /* InternalSymbolName.Default */ || symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { serializeMaybeAliasAssignment(symbol); } else { @@ -55329,18 +55516,18 @@ var ts; function serializeExportSpecifier(localName, targetName, specifier) { addResult(ts.factory.createExportDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* ModifierFlags.None */); } /** * Returns `true` if an export assignment or declaration was produced for the symbol */ function serializeMaybeAliasAssignment(symbol) { - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return false; } var name = ts.unescapeLeadingUnderscores(symbol.escapedName); - var isExportEquals = name === "export=" /* ExportEquals */; - var isDefault = name === "default" /* Default */; + var isExportEquals = name === "export=" /* InternalSymbolName.ExportEquals */; + var isDefault = name === "default" /* InternalSymbolName.Default */; var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault; // synthesize export = ref // ref should refer to either be a locally scoped symbol which we need to emit, or @@ -55355,7 +55542,7 @@ var ts; // Technically, this is all that's required in the case where the assignment is an entity name expression var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl)); var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; - var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); if (referenced || target) { includePrivateSymbol(referenced || target); } @@ -55368,7 +55555,7 @@ var ts; context.tracker.trackSymbol = function () { return false; }; if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( - /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* SymbolFlags.All */))); } else { if (first_1 === expr && first_1) { @@ -55383,7 +55570,7 @@ var ts; var varName = getUnusedName(name, symbol); addResult(ts.factory.createImportEqualsDeclaration( /*modifiers*/ undefined, - /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + /*isTypeOnly*/ false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863 /* SymbolFlags.All */, /*expectsIdentifier*/ false)), 0 /* ModifierFlags.None */); serializeExportSpecifier(name, varName); } } @@ -55398,17 +55585,17 @@ var ts; var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const - serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* None */ : 1 /* Export */); + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 /* ModifierFlags.None */ : 1 /* ModifierFlags.Export */); } else { var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(varName, /*exclamationToken*/ undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); // Inlined JSON types exported with [module.]exports= will already emit an export=, so should use `declare`. // Otherwise, the type itself should be exported. - addResult(statement, target && target.flags & 4 /* Property */ && target.escapedName === "export=" /* ExportEquals */ ? 2 /* Ambient */ - : name === varName ? 1 /* Export */ - : 0 /* None */); + addResult(statement, target && target.flags & 4 /* SymbolFlags.Property */ && target.escapedName === "export=" /* InternalSymbolName.ExportEquals */ ? 2 /* ModifierFlags.Ambient */ + : name === varName ? 1 /* ModifierFlags.Export */ + : 0 /* ModifierFlags.None */); } if (isExportAssignmentCompatibleSymbolName) { results.push(ts.factory.createExportAssignment( @@ -55427,11 +55614,11 @@ var ts; // context source file, and whose property names are all valid identifiers and not late-bound, _and_ // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); - return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + return ts.getObjectFlags(typeToSerialize) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */) && !ts.length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class - !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && - !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* SignatureKind.Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* SignatureKind.Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && @@ -55442,33 +55629,33 @@ var ts; return function serializePropertySymbol(p, isStatic, baseType) { var _a, _b, _c, _d, _e; var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p); - var isPrivate = !!(modifierFlags & 8 /* Private */); - if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + var isPrivate = !!(modifierFlags & 8 /* ModifierFlags.Private */); + if (isStatic && (p.flags & (788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */))) { // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols // need to be merged namespace members return []; } - if (p.flags & 4194304 /* Prototype */ || + if (p.flags & 4194304 /* SymbolFlags.Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) - && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && (p.flags & 16777216 /* SymbolFlags.Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* SymbolFlags.Optional */) && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } - var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); + var flag = (modifierFlags & ~256 /* ModifierFlags.Async */) | (isStatic ? 32 /* ModifierFlags.Static */ : 0); var name = getPropertyNameNodeForSymbol(p, context); var firstPropertyLikeDecl = (_a = p.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); - if (p.flags & 98304 /* Accessor */ && useAccessors) { + if (p.flags & 98304 /* SymbolFlags.Accessor */ && useAccessors) { var result = []; - if (p.flags & 65536 /* SetAccessor */) { + if (p.flags & 65536 /* SymbolFlags.SetAccessor */) { result.push(ts.setTextRange(ts.factory.createSetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [ts.factory.createParameterDeclaration( /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], /*body*/ undefined), ((_b = p.declarations) === null || _b === void 0 ? void 0 : _b.find(ts.isSetAccessor)) || firstPropertyLikeDecl)); } - if (p.flags & 32768 /* GetAccessor */) { - var isPrivate_1 = modifierFlags & 8 /* Private */; + if (p.flags & 32768 /* SymbolFlags.GetAccessor */) { + var isPrivate_1 = modifierFlags & 8 /* ModifierFlags.Private */; result.push(ts.setTextRange(ts.factory.createGetAccessorDeclaration(ts.factory.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), /*body*/ undefined), ((_c = p.declarations) === null || _c === void 0 ? void 0 : _c.find(ts.isGetAccessor)) || firstPropertyLikeDecl)); } @@ -55476,17 +55663,17 @@ var ts; } // This is an else/if as accessors and properties can't merge in TS, but might in JS // If this happens, we assume the accessor takes priority, as it imposes more constraints - else if (p.flags & (4 /* Property */ | 3 /* Variable */ | 98304 /* Accessor */)) { - return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), + else if (p.flags & (4 /* SymbolFlags.Property */ | 3 /* SymbolFlags.Variable */ | 98304 /* SymbolFlags.Accessor */)) { + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined), ((_d = p.declarations) === null || _d === void 0 ? void 0 : _d.find(ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration))) || firstPropertyLikeDecl); } - if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + if (p.flags & (8192 /* SymbolFlags.Method */ | 16 /* SymbolFlags.Function */)) { var type = getTypeOfSymbol(p); - var signatures = getSignaturesOfType(type, 0 /* Call */); - if (flag & 8 /* Private */) { - return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); + if (flag & 8 /* ModifierFlags.Private */) { + return ts.setTextRange(createProperty(ts.factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* ModifierFlags.Readonly */ : 0) | flag), name, p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, /*type*/ undefined, /*initializer*/ undefined), ((_e = p.declarations) === null || _e === void 0 ? void 0 : _e.find(ts.isFunctionLikeDeclaration)) || signatures[0] && signatures[0].declaration || p.declarations && p.declarations[0]); } @@ -55496,7 +55683,7 @@ var ts; // Each overload becomes a separate method declaration, in order var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, { name: name, - questionToken: p.flags & 16777216 /* Optional */ ? ts.factory.createToken(57 /* QuestionToken */) : undefined, + questionToken: p.flags & 16777216 /* SymbolFlags.Optional */ ? ts.factory.createToken(57 /* SyntaxKind.QuestionToken */) : undefined, modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined }); var location = sig.declaration && ts.isPrototypePropertyAssignment(sig.declaration.parent) ? sig.declaration.parent : sig.declaration; @@ -55505,7 +55692,7 @@ var ts; return results_1; } // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static - return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + return ts.Debug.fail("Unhandled class member kind! ".concat(p.__debugFlags || p.flags)); }; } function serializePropertySymbolForInterface(p, baseType) { @@ -55513,13 +55700,13 @@ var ts; } function serializeSignatures(kind, input, baseType, outputKind) { var signatures = getSignaturesOfType(input, kind); - if (kind === 1 /* Construct */) { + if (kind === 1 /* SignatureKind.Construct */) { if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // No base type, every constructor is empty - elide the extraneous `constructor()` } if (baseType) { // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations - var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + var baseSigs = getSignaturesOfType(baseType, 1 /* SignatureKind.Construct */); if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list } @@ -55540,7 +55727,7 @@ var ts; for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { var s = signatures_4[_i]; if (s.declaration) { - privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* Private */ | 16 /* Protected */); + privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */); } } if (privateProtected) { @@ -55575,15 +55762,15 @@ var ts; return results; } function serializeBaseType(t, staticType, rootName) { - var ref = trySerializeAsTypeReference(t, 111551 /* Value */); + var ref = trySerializeAsTypeReference(t, 111551 /* SymbolFlags.Value */); if (ref) { return ref; } - var tempName = getUnusedName(rootName + "_base"); + var tempName = getUnusedName("".concat(rootName, "_base")); var statement = ts.factory.createVariableStatement(/*modifiers*/ undefined, ts.factory.createVariableDeclarationList([ ts.factory.createVariableDeclaration(tempName, /*exclamationToken*/ undefined, typeToTypeNodeHelper(staticType, context)) - ], 2 /* Const */)); - addResult(statement, 0 /* None */); + ], 2 /* NodeFlags.Const */)); + addResult(statement, 0 /* ModifierFlags.None */); return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), /*typeArgs*/ undefined); } function trySerializeAsTypeReference(t, flags) { @@ -55593,22 +55780,22 @@ var ts; // which we can't write out in a syntactically valid way as an expression if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) { typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); - reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.target.symbol, context, 788968 /* SymbolFlags.Type */); } else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) { - reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + reference = symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */); } if (reference) { return ts.factory.createExpressionWithTypeArguments(reference, typeArgs); } } function serializeImplementedType(t) { - var ref = trySerializeAsTypeReference(t, 788968 /* Type */); + var ref = trySerializeAsTypeReference(t, 788968 /* SymbolFlags.Type */); if (ref) { return ref; } if (t.symbol) { - return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* Type */), /*typeArgs*/ undefined); + return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968 /* SymbolFlags.Type */), /*typeArgs*/ undefined); } } function getUnusedName(input, symbol) { @@ -55626,7 +55813,7 @@ var ts; var original = input; while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) { i++; - input = original + "_" + i; + input = "".concat(original, "_").concat(i); } (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input); if (id) { @@ -55635,17 +55822,17 @@ var ts; return input; } function getNameCandidateWorker(symbol, localName) { - if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + if (localName === "default" /* InternalSymbolName.Default */ || localName === "__class" /* InternalSymbolName.Class */ || localName === "__function" /* InternalSymbolName.Function */) { var flags = context.flags; - context.flags |= 16777216 /* InInitialEntityName */; + context.flags |= 16777216 /* NodeBuilderFlags.InInitialEntityName */; var nameCandidate = getNameOfSymbolAsWritten(symbol, context); context.flags = flags; localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; } - if (localName === "default" /* Default */) { + if (localName === "default" /* InternalSymbolName.Default */) { localName = "_default"; } - else if (localName === "export=" /* ExportEquals */) { + else if (localName === "export=" /* InternalSymbolName.ExportEquals */) { localName = "_exports"; } localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); @@ -55664,14 +55851,14 @@ var ts; } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { - if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } + if (flags === void 0) { flags = 16384 /* TypeFormatFlags.UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createToken(128 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + var predicate = ts.factory.createTypePredicateNode(typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createToken(128 /* SyntaxKind.AssertsKeyword */) : undefined, typePredicate.kind === 1 /* TypePredicateKind.Identifier */ || typePredicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ ? ts.factory.createIdentifier(typePredicate.parameterName) : ts.factory.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* NodeBuilderFlags.IgnoreErrors */ | 512 /* NodeBuilderFlags.WriteTypeParametersInQualifiedName */) // TODO: GH#18217 ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* EmitHint.Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); return writer; } } @@ -55681,10 +55868,10 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; flags |= t.flags; - if (!(t.flags & 98304 /* Nullable */)) { - if (t.flags & (512 /* BooleanLiteral */ | 1024 /* EnumLiteral */)) { - var baseType = t.flags & 512 /* BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); - if (baseType.flags & 1048576 /* Union */) { + if (!(t.flags & 98304 /* TypeFlags.Nullable */)) { + if (t.flags & (512 /* TypeFlags.BooleanLiteral */ | 1024 /* TypeFlags.EnumLiteral */)) { + var baseType = t.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : getBaseTypeOfEnumLiteralType(t); + if (baseType.flags & 1048576 /* TypeFlags.Union */) { var count = baseType.types.length; if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) { result.push(baseType); @@ -55696,25 +55883,25 @@ var ts; result.push(t); } } - if (flags & 65536 /* Null */) + if (flags & 65536 /* TypeFlags.Null */) result.push(nullType); - if (flags & 32768 /* Undefined */) + if (flags & 32768 /* TypeFlags.Undefined */) result.push(undefinedType); return result || types; } function visibilityToString(flags) { - if (flags === 8 /* Private */) { + if (flags === 8 /* ModifierFlags.Private */) { return "private"; } - if (flags === 16 /* Protected */) { + if (flags === 16 /* ModifierFlags.Protected */) { return "protected"; } return "public"; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && type.symbol.declarations) { + if (type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && type.symbol.declarations) { var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent); - if (node.kind === 259 /* TypeAliasDeclaration */) { + if (node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -55722,27 +55909,27 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 262 /* ModuleBlock */ && + node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 305 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 305 /* SyntaxKind.SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = getSymbolLinks(symbol).nameType; if (nameType) { - if (nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var name = "" + nameType.value; if (!ts.isIdentifierText(name, ts.getEmitScriptTarget(compilerOptions)) && !ts.isNumericLiteralName(name)) { - return "\"" + ts.escapeString(name, 34 /* doubleQuote */) + "\""; + return "\"".concat(ts.escapeString(name, 34 /* CharacterCodes.doubleQuote */), "\""); } if (ts.isNumericLiteralName(name) && ts.startsWith(name, "-")) { - return "[" + name + "]"; + return "[".concat(name, "]"); } return name; } - if (nameType.flags & 8192 /* UniqueESSymbol */) { - return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]"; + if (nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { + return "[".concat(getNameOfSymbolAsWritten(nameType.symbol, context), "]"); } } } @@ -55754,9 +55941,9 @@ var ts; * It will also use a representation of a number as written instead of a decimal form, e.g. `0o11` instead of `9`. */ function getNameOfSymbolAsWritten(symbol, context) { - if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && + if (context && symbol.escapedName === "default" /* InternalSymbolName.Default */ && !(context.flags & 16384 /* NodeBuilderFlags.UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default` - (!(context.flags & 16777216 /* InInitialEntityName */) || + (!(context.flags & 16777216 /* NodeBuilderFlags.InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default` !symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default` @@ -55770,9 +55957,9 @@ var ts; if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } - if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* Late */)) { + if (ts.isComputedPropertyName(name_4) && !(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */)) { var nameType = getSymbolLinks(symbol).nameType; - if (nameType && nameType.flags & 384 /* StringOrNumberLiteral */) { + if (nameType && nameType.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { // Computed property name isn't late bound, but has a well-known name type - use name type to generate a symbol name var result = getNameOfSymbolFromNameType(symbol, context); if (result !== undefined) { @@ -55785,17 +55972,17 @@ var ts; if (!declaration) { declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway } - if (declaration.parent && declaration.parent.kind === 254 /* VariableDeclaration */) { + if (declaration.parent && declaration.parent.kind === 254 /* SyntaxKind.VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + if (context && !context.encounteredError && !(context.flags & 131072 /* NodeBuilderFlags.AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 226 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 226 /* SyntaxKind.ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -55812,84 +55999,84 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 338 /* JSDocCallbackTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return isDeclarationVisible(node.parent.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 256 /* FunctionDeclaration */: - case 260 /* EnumDeclaration */: - case 265 /* ImportEqualsDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) { + if (!(ts.getCombinedModifierFlags(node) & 1 /* ModifierFlags.Export */) && + !(node.kind !== 265 /* SyntaxKind.ImportEqualsDeclaration */ && parent.kind !== 305 /* SyntaxKind.SourceFile */ && parent.flags & 16777216 /* NodeFlags.Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - if (ts.hasEffectiveModifier(node, 8 /* Private */ | 16 /* Protected */)) { + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 171 /* Constructor */: - case 175 /* ConstructSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 164 /* Parameter */: - case 262 /* ModuleBlock */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 178 /* TypeReference */: - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 171 /* SyntaxKind.Constructor */: + case 175 /* SyntaxKind.ConstructSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 164 /* SyntaxKind.Parameter */: + case 262 /* SyntaxKind.ModuleBlock */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 178 /* SyntaxKind.TypeReference */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: return false; // Type parameters are always visible - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: // Source file and namespace export are always visible // falls through - case 305 /* SourceFile */: - case 264 /* NamespaceExportDeclaration */: + case 305 /* SyntaxKind.SourceFile */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return false; default: return false; @@ -55898,11 +56085,11 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 271 /* ExportAssignment */) { - exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); + if (node.parent && node.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { + exportSymbol = resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 275 /* ExportSpecifier */) { - exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + else if (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) { + exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } var result; var visited; @@ -55926,7 +56113,7 @@ var ts; // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol && visited) { if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) { buildVisibleNodeList(importSymbol.declarations); @@ -55975,23 +56162,23 @@ var ts; } function hasType(target, propertyName) { switch (propertyName) { - case 0 /* Type */: + case 0 /* TypeSystemPropertyName.Type */: return !!getSymbolLinks(target).type; - case 5 /* EnumTagType */: + case 5 /* TypeSystemPropertyName.EnumTagType */: return !!(getNodeLinks(target).resolvedEnumType); - case 2 /* DeclaredType */: + case 2 /* TypeSystemPropertyName.DeclaredType */: return !!getSymbolLinks(target).declaredType; - case 1 /* ResolvedBaseConstructorType */: + case 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */: return !!target.resolvedBaseConstructorType; - case 3 /* ResolvedReturnType */: + case 3 /* TypeSystemPropertyName.ResolvedReturnType */: return !!target.resolvedReturnType; - case 4 /* ImmediateBaseConstraint */: + case 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */: return !!target.immediateBaseConstraint; - case 6 /* ResolvedTypeArguments */: + case 6 /* TypeSystemPropertyName.ResolvedTypeArguments */: return !!target.resolvedTypeArguments; - case 7 /* ResolvedBaseTypes */: + case 7 /* TypeSystemPropertyName.ResolvedBaseTypes */: return !!target.baseTypesResolved; - case 8 /* WriteType */: + case 8 /* TypeSystemPropertyName.WriteType */: return !!getSymbolLinks(target).writeType; } return ts.Debug.assertNever(propertyName); @@ -56008,12 +56195,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 254 /* VariableDeclaration */: - case 255 /* VariableDeclarationList */: - case 270 /* ImportSpecifier */: - case 269 /* NamedImports */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 255 /* SyntaxKind.VariableDeclarationList */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 269 /* SyntaxKind.NamedImports */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: return false; default: return true; @@ -56038,28 +56225,28 @@ var ts; return getTypeOfPropertyOfType(type, name) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || unknownType; } function isTypeAny(type) { - return type && (type.flags & 1 /* Any */) !== 0; + return type && (type.flags & 1 /* TypeFlags.Any */) !== 0; } function isErrorType(type) { // The only 'any' types that have alias symbols are those manufactured by getTypeFromTypeAliasReference for // a reference to an unresolved symbol. We want those to behave like the errorType. - return type === errorType || !!(type.flags & 1 /* Any */ && type.aliasSymbol); + return type === errorType || !!(type.flags & 1 /* TypeFlags.Any */ && type.aliasSymbol); } // Return the type of a binding element parent. We check SymbolLinks first to see if a type has been // assigned by contextual typing. function getTypeForBindingElementParent(node, checkMode) { - if (checkMode !== 0 /* Normal */) { + if (checkMode !== 0 /* CheckMode.Normal */) { return getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false, checkMode); } function getRestType(source, properties, symbol) { - source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (source.flags & 131072 /* Never */) { + source = filterType(source, function (t) { return !(t.flags & 98304 /* TypeFlags.Nullable */); }); + if (source.flags & 131072 /* TypeFlags.Never */) { return emptyObjectType; } - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return mapType(source, function (t) { return getRestType(t, properties, symbol); }); } var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName)); @@ -56067,9 +56254,9 @@ var ts; var unspreadableToRestKeys = []; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */); + var literalTypeFromProperty = getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); if (!isTypeAssignableTo(literalTypeFromProperty, omitKeyType) - && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) + && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) && isSpreadableProperty(prop)) { spreadableProperties.push(prop); } @@ -56084,7 +56271,7 @@ var ts; // they are explicitly omitted, as they would in the non-generic case. omitKeyType = getUnionType(__spreadArray([omitKeyType], unspreadableToRestKeys, true)); } - if (omitKeyType.flags & 131072 /* Never */) { + if (omitKeyType.flags & 131072 /* TypeFlags.Never */) { return source; } var omitTypeAlias = getGlobalOmitSymbol(); @@ -56099,15 +56286,15 @@ var ts; members.set(prop.escapedName, getSpreadSymbol(prop, /*readonly*/ false)); } var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(source)); - result.objectFlags |= 4194304 /* ObjectRestType */; + result.objectFlags |= 4194304 /* ObjectFlags.ObjectRestType */; return result; } function isGenericTypeWithUndefinedConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* Undefined */); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */) && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 32768 /* TypeFlags.Undefined */); } function getNonUndefinedType(type) { - var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; - return getTypeWithFacts(typeOrConstraint, 524288 /* NEUndefined */); + var typeOrConstraint = someType(type, isGenericTypeWithUndefinedConstraint) ? mapType(type, function (t) { return t.flags & 465829888 /* TypeFlags.Instantiable */ ? getBaseConstraintOrType(t) : t; }) : type; + return getTypeWithFacts(typeOrConstraint, 524288 /* TypeFacts.NEUndefined */); } // Determine the control flow type associated with a destructuring declaration or assignment. The following // forms of destructuring are possible: @@ -56143,34 +56330,34 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 203 /* BindingElement */: - case 296 /* PropertyAssignment */: + case 203 /* SyntaxKind.BindingElement */: + case 296 /* SyntaxKind.PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return ancestor.initializer; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 203 /* BindingElement */ && parent.kind === 201 /* ObjectBindingPattern */) { + if (node.kind === 203 /* SyntaxKind.BindingElement */ && parent.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 296 /* PropertyAssignment */ || node.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.kind === 296 /* SyntaxKind.PropertyAssignment */ || node.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); } function getLiteralPropertyNameText(name) { var type = getLiteralTypeFromPropertyName(name); - return type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */) ? "" + type.value : undefined; + return type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */) ? "" + type.value : undefined; } /** Return the inferred type for a binding element */ function getTypeForBindingElement(declaration) { - var checkMode = declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var checkMode = declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(declaration.parent.parent, checkMode); return parentType && getBindingElementTypeFromParentType(declaration, parentType); } @@ -56181,18 +56368,18 @@ var ts; } var pattern = declaration.parent; // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 16777216 /* NodeFlags.Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` - else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) { - parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* TypeFacts.EQUndefined */)) { + parentType = getTypeWithFacts(parentType, 524288 /* TypeFacts.NEUndefined */); } var type; - if (pattern.kind === 201 /* ObjectBindingPattern */) { + if (pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (declaration.dotDotDotToken) { parentType = getReducedType(parentType); - if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { + if (parentType.flags & 2 /* TypeFlags.Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return errorType; } @@ -56209,7 +56396,7 @@ var ts; // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) var name = declaration.propertyName || declaration.name; var indexType = getLiteralTypeFromPropertyName(name); - var declaredType = getIndexedAccessType(parentType, indexType, 32 /* ExpressionPosition */, name); + var declaredType = getIndexedAccessType(parentType, indexType, 32 /* AccessFlags.ExpressionPosition */, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -56217,7 +56404,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* PossiblyOutOfBounds */), parentType, undefinedType, pattern); + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | (declaration.dotDotDotToken ? 0 : 128 /* IterationUse.PossiblyOutOfBounds */), parentType, undefinedType, pattern); var index_2 = pattern.elements.indexOf(declaration); if (declaration.dotDotDotToken) { // If the parent is a tuple type, the rest element has a tuple type of the @@ -56229,7 +56416,7 @@ var ts; } else if (isArrayLikeType(parentType)) { var indexType = getNumberLiteralType(index_2); - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(declaration) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } @@ -56243,9 +56430,9 @@ var ts; if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. - return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* Normal */)) & 16777216 /* IsUndefined */) ? getNonUndefinedType(type) : type; + return strictNullChecks && !(getTypeFacts(checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)) & 16777216 /* TypeFacts.IsUndefined */) ? getNonUndefinedType(type) : type; } - return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* Normal */)], 2 /* Subtype */)); + return widenTypeInferredFromInitializer(declaration, getUnionType([getNonUndefinedType(type), checkDeclarationInitializer(declaration, 0 /* CheckMode.Normal */)], 2 /* UnionReduction.Subtype */)); } function getTypeForDeclarationFromJSDocComment(declaration) { var jsdocType = ts.getJSDocType(declaration); @@ -56256,11 +56443,11 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 104 /* NullKeyword */ || expr.kind === 79 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 104 /* SyntaxKind.NullKeyword */ || expr.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return expr.kind === 204 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, isProperty, isOptional) { if (isProperty === void 0) { isProperty = false; } @@ -56271,11 +56458,11 @@ var ts; function getTypeForVariableLikeDeclaration(declaration, includeOptionality, checkMode) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression, /*checkMode*/ checkMode))); - return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; + return indexType.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -56297,11 +56484,11 @@ var ts; } if ((noImplicitAny || ts.isInJSFile(declaration)) && ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) { + !(ts.getCombinedModifierFlags(declaration) & 1 /* ModifierFlags.Export */) && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. - if (!(ts.getCombinedNodeFlags(declaration) & 2 /* Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + if (!(ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array @@ -56313,8 +56500,8 @@ var ts; if (ts.isParameter(declaration)) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 173 /* SetAccessor */ && hasBindableName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* GetAccessor */); + if (func.kind === 173 /* SyntaxKind.SetAccessor */ && hasBindableName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 172 /* SyntaxKind.GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -56332,7 +56519,7 @@ var ts; return type_1; } // Use contextual parameter type if one is available - var type = declaration.symbol.escapedName === "this" /* This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); + var type = declaration.symbol.escapedName === "this" /* InternalSymbolName.This */ ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration); if (type) { return addOptionality(type, /*isProperty*/ false, isOptional); } @@ -56355,14 +56542,14 @@ var ts; if (!ts.hasStaticModifier(declaration)) { var constructor = findConstructorDeclaration(declaration.parent); var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } else { var staticBlocks = ts.filter(declaration.parent.members, ts.isClassStaticBlockDeclaration); var type = staticBlocks.length ? getFlowTypeInStaticBlocks(declaration.symbol, staticBlocks) : - ts.getEffectiveModifierFlags(declaration) & 2 /* Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : + ts.getEffectiveModifierFlags(declaration) & 2 /* ModifierFlags.Ambient */ ? getTypeOfPropertyInBaseClass(declaration.symbol) : undefined; return type && addOptionality(type, /*isProperty*/ true, isOptional); } @@ -56391,7 +56578,7 @@ var ts; links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) { return ts.isBinaryExpression(declaration) && isPossiblyAliasedThisProperty(declaration) && - (declaration.left.kind !== 207 /* ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && + (declaration.left.kind !== 207 /* SyntaxKind.ElementAccessExpression */ || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) && !getAnnotatedTypeForAssignmentDeclaration(/*declaredType*/ undefined, declaration, symbol, declaration); }); } @@ -56413,7 +56600,7 @@ var ts; 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 === 171 /* Constructor */ || isJSConstructor(container))) { + if (container && (container.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(container))) { return container; } } @@ -56473,7 +56660,7 @@ var ts; } function getFlowTypeOfProperty(reference, prop) { var initialType = (prop === null || prop === void 0 ? void 0 : prop.valueDeclaration) - && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* Ambient */) + && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2 /* ModifierFlags.Ambient */) && getTypeOfPropertyInBaseClass(prop) || undefinedType; return getFlowTypeOfReference(reference, autoType, initialType); @@ -56512,7 +56699,7 @@ var ts; var kind = ts.isAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); - if (kind === 4 /* ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */ || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; } @@ -56542,12 +56729,12 @@ var ts; definedInConstructor = true; } } - var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 + var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes); } } var widened = getWidenedType(addOptionality(type, /*isProperty*/ false, definedInMethod && !definedInConstructor)); - if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* Nullable */); }) === neverType) { + if (symbol.valueDeclaration && filterType(widened, function (t) { return !!(t.flags & ~98304 /* TypeFlags.Nullable */); }) === neverType) { reportImplicitAny(symbol.valueDeclaration, anyType); return anyType; } @@ -56571,7 +56758,7 @@ var ts; mergeSymbolTable(exports, s.exports); } var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - type.objectFlags |= 4096 /* JSLiteral */; + type.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return type; } function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) { @@ -56627,13 +56814,13 @@ var ts; if (containsSameNamedThisProperty(expression.left, expression.right)) { return anyType; } - var isDirectExport = kind === 1 /* ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); + var isDirectExport = kind === 1 /* AssignmentDeclarationKind.ExportsProperty */ && (ts.isPropertyAccessExpression(expression.left) || ts.isElementAccessExpression(expression.left)) && (ts.isModuleExportsAccessExpression(expression.left.expression) || (ts.isIdentifier(expression.left.expression) && ts.isExportsIdentifier(expression.left.expression))); var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : isDirectExport ? getRegularTypeOfLiteralType(checkExpressionCached(expression.right)) : getWidenedLiteralType(checkExpressionCached(expression.right)); - if (type.flags & 524288 /* Object */ && - kind === 2 /* ModuleExports */ && - symbol.escapedName === "export=" /* ExportEquals */) { + if (type.flags & 524288 /* TypeFlags.Object */ && + kind === 2 /* AssignmentDeclarationKind.ModuleExports */ && + symbol.escapedName === "export=" /* InternalSymbolName.ExportEquals */) { var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); ts.copyEntries(exportedType.members, members_4); @@ -56644,8 +56831,8 @@ var ts; (resolvedSymbol || symbol).exports.forEach(function (s, name) { var _a; var exportedMember = members_4.get(name); - if (exportedMember && exportedMember !== s) { - if (s.flags & 111551 /* Value */ && exportedMember.flags & 111551 /* Value */) { + if (exportedMember && exportedMember !== s && !(s.flags & 2097152 /* SymbolFlags.Alias */)) { + if (s.flags & 111551 /* SymbolFlags.Value */ && exportedMember.flags & 111551 /* SymbolFlags.Value */) { // If the member has an additional value-like declaration, union the types from the two declarations, // but issue an error if they occurred in two different files. The purpose is to support a JS file with // a pattern like: @@ -56683,15 +56870,15 @@ var ts; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = type.aliasTypeArguments; } - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { result.aliasSymbol = type.symbol; var args = getTypeArguments(type); result.aliasTypeArguments = ts.length(args) ? args : undefined; } } - result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* JSLiteral */); // Propagate JSLiteral flag - if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { - result.objectFlags |= 16777216 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type + result.objectFlags |= (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */); // Propagate JSLiteral flag + if (result.symbol && result.symbol.flags & 32 /* SymbolFlags.Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) { + result.objectFlags |= 16777216 /* ObjectFlags.IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type } return result; } @@ -56703,16 +56890,16 @@ var ts; } function containsSameNamedThisProperty(thisProperty, expression) { return ts.isPropertyAccessExpression(thisProperty) - && thisProperty.expression.kind === 108 /* ThisKeyword */ + && thisProperty.expression.kind === 108 /* SyntaxKind.ThisKeyword */ && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 171 /* Constructor */ || - thisContainer.kind === 256 /* FunctionDeclaration */ || - (thisContainer.kind === 213 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 171 /* SyntaxKind.Constructor */ || + thisContainer.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + (thisContainer.kind === 213 /* SyntaxKind.FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -56732,7 +56919,7 @@ var ts; // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* CheckMode.Normal */, contextualType))); } if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -56740,17 +56927,13 @@ var ts; if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAny(element, anyType); } - // When we're including the pattern in the type (an indication we're obtaining a contextual type), we - // use the non-inferrable any type. Inference will never directly infer this type, but it is possible - // to infer a type that contains it, e.g. for a binding pattern like [foo] or { foo }. In such cases, - // widening of the binding pattern type substitutes a regular any for the non-inferrable any. - return includePatternInType ? nonInferrableAnyType : anyType; + return anyType; } // Return the type implied by an object binding pattern function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) { var members = ts.createSymbolTable(); var stringIndexInfo; - var objectFlags = 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + var objectFlags = 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; ts.forEach(pattern.elements, function (e) { var name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -56760,11 +56943,11 @@ var ts; var exprType = getLiteralTypeFromPropertyName(name); if (!isTypeUsableAsPropertyName(exprType)) { // do not include computed properties in the implied type - objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; return; } var text = getPropertyNameFromType(exprType); - var flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0); + var flags = 4 /* SymbolFlags.Property */ | (e.initializer ? 16777216 /* SymbolFlags.Optional */ : 0); var symbol = createSymbol(flags, text); symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; @@ -56774,7 +56957,7 @@ var ts; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56782,18 +56965,18 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var restElement = lastElement && lastElement.kind === 203 /* BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; + var restElement = lastElement && lastElement.kind === 203 /* SyntaxKind.BindingElement */ && lastElement.dotDotDotToken ? lastElement : undefined; if (elements.length === 0 || elements.length === 1 && restElement) { - return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; + return languageVersion >= 2 /* ScriptTarget.ES2015 */ ? createIterableType(anyType) : anyArrayType; } var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); }); var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1; - var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* Rest */ : i >= minLength ? 2 /* Optional */ : 1 /* Required */; }); + var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 /* ElementFlags.Rest */ : i >= minLength ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */; }); var result = createTupleType(elementTypes, elementFlags); if (includePatternInType) { result = cloneTypeReference(result); result.pattern = pattern; - result.objectFlags |= 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return result; } @@ -56807,7 +56990,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 201 /* ObjectBindingPattern */ + return pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -56821,7 +57004,7 @@ var ts; // binding pattern [x, s = ""]. Because the contextual type is a tuple type, the resulting type of [1, "one"] is the // tuple type [number, string]. Thus, the type inferred for 'x' is number and the type inferred for 's' is string. function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) { - return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* Normal */), declaration, reportErrors); + return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ true, 0 /* CheckMode.Normal */), declaration, reportErrors); } function isGlobalSymbolConstructor(node) { var symbol = getSymbolOfNode(node); @@ -56831,14 +57014,14 @@ var ts; function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) { if (type) { // TODO: If back compat with pre-3.0/4.0 libs isn't required, remove the following SymbolConstructor special case transforming `symbol` into `unique symbol` - if (type.flags & 4096 /* ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { + if (type.flags & 4096 /* TypeFlags.ESSymbol */ && isGlobalSymbolConstructor(declaration.parent)) { type = getESSymbolLikeTypeForNode(declaration); } if (reportErrors) { reportErrorsFromWidening(declaration, type); } // always widen a 'unique symbol' type if the type was created for a different declaration. - if (type.flags & 8192 /* UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) { type = esSymbolType; } return getWidenedType(type); @@ -56855,7 +57038,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 164 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 164 /* SyntaxKind.Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(node) { @@ -56879,14 +57062,14 @@ var ts; } function getTypeOfVariableOrParameterOrPropertyWorker(symbol) { // Handle prototype property - if (symbol.flags & 4194304 /* Prototype */) { + if (symbol.flags & 4194304 /* SymbolFlags.Prototype */) { return getTypeOfPrototypeProperty(symbol); } // CommonsJS require and module both have type any. if (symbol === requireSymbol) { return anyType; } - if (symbol.flags & 134217728 /* ModuleExports */ && symbol.valueDeclaration) { + if (symbol.flags & 134217728 /* SymbolFlags.ModuleExports */ && symbol.valueDeclaration) { var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration)); var result = createSymbol(fileSymbol.flags, "exports"); result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : []; @@ -56927,15 +57110,15 @@ var ts; return getTypeOfAccessors(symbol); } // Handle variable, parameter or property - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 271 /* ExportAssignment */) { + if (declaration.kind === 271 /* SyntaxKind.ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionCached(declaration.expression), declaration); } else if (ts.isBinaryExpression(declaration) || @@ -56954,7 +57137,7 @@ var ts; || ts.isMethodSignature(declaration) || ts.isSourceFile(declaration)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } type = ts.isBinaryExpression(declaration.parent) ? @@ -56968,10 +57151,10 @@ var ts; type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration); } else if (ts.isShorthandPropertyAssignment(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0 /* CheckMode.Normal */); } else if (ts.isObjectLiteralMethod(declaration)) { - type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* Normal */); + type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0 /* CheckMode.Normal */); } else if (ts.isParameter(declaration) || ts.isPropertyDeclaration(declaration) @@ -56994,7 +57177,7 @@ var ts; } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -57003,7 +57186,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 172 /* GetAccessor */) { + if (accessor.kind === 172 /* SyntaxKind.GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -57028,11 +57211,11 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); // We try to resolve a getter type annotation, a setter type annotation, or a getter function // body return type inference, in that order. var type = getter && ts.isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || @@ -57067,10 +57250,10 @@ var ts; function getWriteTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.writeType) { - if (!pushTypeResolution(symbol, 8 /* WriteType */)) { + if (!pushTypeResolution(symbol, 8 /* TypeSystemPropertyName.WriteType */)) { return errorType; } - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); var writeType = getAnnotatedAccessorType(setter); if (!popTypeResolution()) { if (getAnnotatedAccessorTypeNode(setter)) { @@ -57085,8 +57268,8 @@ var ts; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : - baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + return baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeFlags.TypeVariable */); }) : undefined; } function getTypeOfFuncClassEnumModule(symbol) { @@ -57107,21 +57290,21 @@ var ts; } function getTypeOfFuncClassEnumModuleWorker(symbol) { var declaration = symbol.valueDeclaration; - if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { + if (symbol.flags & 1536 /* SymbolFlags.Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration && (declaration.kind === 221 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 221 /* BinaryExpression */)) { + declaration.parent.kind === 221 /* SyntaxKind.BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } - else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { + else if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { var resolvedModule = resolveExternalModuleSymbol(symbol); if (resolvedModule !== symbol) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { return errorType; } - var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* ExportEquals */)); + var exportEquals = getMergedSymbol(symbol.exports.get("export=" /* InternalSymbolName.ExportEquals */)); var type_3 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule); if (!popTypeResolution()) { return reportCircularityError(symbol); @@ -57129,13 +57312,13 @@ var ts; return type_3; } } - var type = createObjectType(16 /* Anonymous */, symbol); - if (symbol.flags & 32 /* Class */) { + var type = createObjectType(16 /* ObjectFlags.Anonymous */, symbol); + if (symbol.flags & 32 /* SymbolFlags.Class */) { var baseTypeVariable = getBaseTypeVariableOfClass(symbol); return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type; } else { - return strictNullChecks && symbol.flags & 16777216 /* Optional */ ? getOptionalType(type) : type; + return strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ ? getOptionalType(type) : type; } } function getTypeOfEnumMember(symbol) { @@ -57156,7 +57339,7 @@ var ts; links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol) : isDuplicatedCommonJSExport(symbol.declarations) ? autoType : declaredType ? declaredType - : targetSymbol.flags & 111551 /* Value */ ? getTypeOfSymbol(targetSymbol) + : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol) : errorType; } return links.type; @@ -57177,7 +57360,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 164 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 164 /* SyntaxKind.Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -57190,7 +57373,7 @@ var ts; if (!links.type) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); + links.type = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); } return links.type; } @@ -57199,7 +57382,7 @@ var ts; if (!links.writeType && links.deferralWriteConstituents) { ts.Debug.assertIsDefined(links.deferralParent); ts.Debug.assertIsDefined(links.deferralConstituents); - links.writeType = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); + links.writeType = links.deferralParent.flags & 1048576 /* TypeFlags.Union */ ? getUnionType(links.deferralWriteConstituents) : getIntersectionType(links.deferralWriteConstituents); } return links.writeType; } @@ -57210,15 +57393,15 @@ var ts; */ function getWriteTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (symbol.flags & 4 /* Property */) { - return checkFlags & 2 /* SyntheticProperty */ ? - checkFlags & 65536 /* DeferredType */ ? + if (symbol.flags & 4 /* SymbolFlags.Property */) { + return checkFlags & 2 /* CheckFlags.SyntheticProperty */ ? + checkFlags & 65536 /* CheckFlags.DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : symbol.writeType || symbol.type : getTypeOfSymbol(symbol); } - if (symbol.flags & 98304 /* Accessor */) { - return checkFlags & 1 /* Instantiated */ ? + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { + return checkFlags & 1 /* CheckFlags.Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol); } @@ -57226,56 +57409,56 @@ var ts; } function getTypeOfSymbol(symbol) { var checkFlags = ts.getCheckFlags(symbol); - if (checkFlags & 65536 /* DeferredType */) { + if (checkFlags & 65536 /* CheckFlags.DeferredType */) { return getTypeOfSymbolWithDeferredType(symbol); } - if (checkFlags & 1 /* Instantiated */) { + if (checkFlags & 1 /* CheckFlags.Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (checkFlags & 262144 /* Mapped */) { + if (checkFlags & 262144 /* CheckFlags.Mapped */) { return getTypeOfMappedSymbol(symbol); } - if (checkFlags & 8192 /* ReverseMapped */) { + if (checkFlags & 8192 /* CheckFlags.ReverseMapped */) { return getTypeOfReverseMappedSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & 98304 /* Accessor */) { + if (symbol.flags & 98304 /* SymbolFlags.Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getTypeOfAlias(symbol); } return errorType; } function getNonMissingTypeOfSymbol(symbol) { - return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* Optional */)); + return removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & 16777216 /* SymbolFlags.Optional */)); } function isReferenceToType(type, target) { return type !== undefined && target !== undefined - && (ts.getObjectFlags(type) & 4 /* Reference */) !== 0 + && (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) !== 0 && type.target === target; } function getTargetType(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ ? type.target : type; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target : type; } // TODO: GH#18217 If `checkBase` is undefined, we should not call this because this will always return false. function hasBaseType(type, checkBase) { return check(type); function check(type) { - if (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { var target = getTargetType(type); return target === checkBase || ts.some(getBaseTypes(target), check); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, check); } return false; @@ -57298,7 +57481,7 @@ var ts; if (node && ts.isBinaryExpression(node)) { // prototype assignments get the outer type parameters of their constructor function var assignmentKind = ts.getAssignmentDeclarationKind(node); - if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + if (assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */ || assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { var symbol = getSymbolOfNode(node.left); if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { node = symbol.parent.valueDeclaration; @@ -57309,46 +57492,46 @@ var ts; return undefined; } switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 168 /* MethodSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 317 /* JSDocFunctionType */: - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 259 /* TypeAliasDeclaration */: - case 344 /* JSDocTemplateTag */: - case 345 /* JSDocTypedefTag */: - case 339 /* JSDocEnumTag */: - case 338 /* JSDocCallbackTag */: - case 195 /* MappedType */: - case 189 /* ConditionalType */: { + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 344 /* SyntaxKind.JSDocTemplateTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 195 /* SyntaxKind.MappedType */: + case 189 /* SyntaxKind.ConditionalType */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 195 /* MappedType */) { + if (node.kind === 195 /* SyntaxKind.MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 189 /* ConditionalType */) { + else if (node.kind === 189 /* SyntaxKind.ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */ || node.kind === 258 /* InterfaceDeclaration */ || isJSConstructor(node)) && + (node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */ || node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: var paramSymbol = ts.getParameterSymbolFromJSDoc(node); if (paramSymbol) { node = paramSymbol.valueDeclaration; } break; - case 320 /* JSDoc */: { + case 320 /* SyntaxKind.JSDoc */: { var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); return node.tags ? appendTypeParameters(outerTypeParameters, ts.flatMap(node.tags, function (t) { return ts.isJSDocTemplateTag(t) ? t.typeParameters : undefined; })) @@ -57359,7 +57542,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* SymbolFlags.Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } @@ -57372,9 +57555,9 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 257 /* ClassDeclaration */ || - node.kind === 226 /* ClassExpression */ || + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 257 /* SyntaxKind.ClassDeclaration */ || + node.kind === 226 /* SyntaxKind.ClassExpression */ || isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; @@ -57391,7 +57574,7 @@ var ts; // A type is a mixin constructor if it has a single construct signature taking no type parameters and a single // rest parameter of type any[]. function isMixinConstructorType(type) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length === 1) { var s = signatures[0]; if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) { @@ -57402,10 +57585,10 @@ var ts; return false; } function isConstructorType(type) { - if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length > 0) { return true; } - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { var constraint = getBaseConstraintOfType(type); return !!constraint && isMixinConstructorType(constraint); } @@ -57418,7 +57601,7 @@ var ts; function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); var isJavascript = ts.isInJSFile(location); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); + return ts.filter(getSignaturesOfType(type, 1 /* SignatureKind.Construct */), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); @@ -57441,7 +57624,7 @@ var ts; if (!baseTypeNode) { return type.resolvedBaseConstructorType = undefinedType; } - if (!pushTypeResolution(type, 1 /* ResolvedBaseConstructorType */)) { + if (!pushTypeResolution(type, 1 /* TypeSystemPropertyName.ResolvedBaseConstructorType */)) { return errorType; } var baseConstructorType = checkExpression(baseTypeNode.expression); @@ -57449,7 +57632,7 @@ var ts; ts.Debug.assert(!extended.typeArguments); // Because this is in a JS file, and baseTypeNode is in an @extends tag checkExpression(extended.expression); } - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. resolveStructuredTypeMembers(baseConstructorType); @@ -57458,13 +57641,13 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = errorType; } - if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* TypeFlags.Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); - if (baseConstructorType.flags & 262144 /* TypeParameter */) { + if (baseConstructorType.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(baseConstructorType); var ctorReturn = unknownType; if (constraint) { - var ctorSig = getSignaturesOfType(constraint, 1 /* Construct */); + var ctorSig = getSignaturesOfType(constraint, 1 /* SignatureKind.Construct */); if (ctorSig[0]) { ctorReturn = getReturnTypeOfSignature(ctorSig[0]); } @@ -57504,19 +57687,19 @@ var ts; return resolvedImplementsTypes; } function reportCircularBaseType(node, type) { - error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); } function getBaseTypes(type) { if (!type.baseTypesResolved) { - if (pushTypeResolution(type, 7 /* ResolvedBaseTypes */)) { - if (type.objectFlags & 8 /* Tuple */) { + if (pushTypeResolution(type, 7 /* TypeSystemPropertyName.ResolvedBaseTypes */)) { + if (type.objectFlags & 8 /* ObjectFlags.Tuple */) { type.resolvedBaseTypes = [getTupleBaseType(type)]; } - else if (type.symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (type.symbol.flags & 32 /* Class */) { + else if (type.symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { + if (type.symbol.flags & 32 /* SymbolFlags.Class */) { resolveBaseTypesOfClass(type); } - if (type.symbol.flags & 64 /* Interface */) { + if (type.symbol.flags & 64 /* SymbolFlags.Interface */) { resolveBaseTypesOfInterface(type); } } @@ -57526,7 +57709,7 @@ var ts; if (!popTypeResolution() && type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 257 /* ClassDeclaration */ || declaration.kind === 258 /* InterfaceDeclaration */) { + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { reportCircularBaseType(declaration, type); } } @@ -57537,26 +57720,26 @@ var ts; return type.resolvedBaseTypes; } function getTupleBaseType(type) { - var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; }); + var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; }); return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly); } function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = ts.resolvingEmptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 1 /* Any */))) { + if (!(baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 1 /* TypeFlags.Any */))) { return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); var baseType; var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; - if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && + if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* SymbolFlags.Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } - else if (baseConstructorType.flags & 1 /* Any */) { + else if (baseConstructorType.flags & 1 /* TypeFlags.Any */) { baseType = baseConstructorType; } else { @@ -57581,7 +57764,7 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { - error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); + error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */)); return type.resolvedBaseTypes = ts.emptyArray; } if (type.resolvedBaseTypes === ts.resolvingEmptyArray) { @@ -57606,7 +57789,7 @@ var ts; } // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getBaseConstraintOfType(type); if (constraint) { return isValidBaseType(constraint); @@ -57614,15 +57797,15 @@ var ts; } // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? // There's no reason a `T` should be allowed while a `Readonly` should not. - return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType)); + return !!(type.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 1 /* TypeFlags.Any */) && !isGenericMappedType(type) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isValidBaseType)); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; if (type.symbol.declarations) { for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getReducedType(getTypeFromTypeNode(node)); @@ -57662,8 +57845,8 @@ var ts; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 258 /* InterfaceDeclaration */) { - if (declaration.flags & 128 /* ContainsThis */) { + if (declaration.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { + if (declaration.flags & 128 /* NodeFlags.ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -57671,8 +57854,8 @@ var ts; for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) { var node = baseTypeNodes_1[_b]; if (ts.isEntityNameExpression(node.expression)) { - var baseSymbol = resolveEntityName(node.expression, 788968 /* Type */, /*ignoreErrors*/ true); - if (!baseSymbol || !(baseSymbol.flags & 64 /* Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { + var baseSymbol = resolveEntityName(node.expression, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true); + if (!baseSymbol || !(baseSymbol.flags & 64 /* SymbolFlags.Interface */) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; } } @@ -57686,7 +57869,7 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.declaredType) { - var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; + var kind = symbol.flags & 32 /* SymbolFlags.Class */ ? 1 /* ObjectFlags.Class */ : 2 /* ObjectFlags.Interface */; var merged = mergeJSSymbols(symbol, symbol.valueDeclaration && getAssignedClassSymbol(symbol.valueDeclaration)); if (merged) { // note:we overwrite links because we just cloned the symbol @@ -57700,8 +57883,8 @@ var ts; // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === 1 /* Class */ || !isThislessInterface(symbol)) { - type.objectFlags |= 4 /* Reference */; + if (outerTypeParameters || localTypeParameters || kind === 1 /* ObjectFlags.Class */ || !isThislessInterface(symbol)) { + type.objectFlags |= 4 /* ObjectFlags.Reference */; type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; @@ -57722,7 +57905,7 @@ var ts; if (!links.declaredType) { // Note that we use the links object as the target here because the symbol object is used as the unique // identity for resolution of the 'type' property in SymbolLinks. - if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { + if (!pushTypeResolution(symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { return errorType; } var declaration = ts.Debug.checkDefined((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isTypeAlias), "Type alias symbol with no valid declaration found"); @@ -57741,11 +57924,11 @@ var ts; } else { type = errorType; - if (declaration.kind === 339 /* JSDocEnumTag */) { + if (declaration.kind === 339 /* SyntaxKind.JSDocEnumTag */) { error(declaration.typeExpression.type, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } else { - error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); + error(ts.isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } } links.declaredType = type; @@ -57756,7 +57939,7 @@ var ts; if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 221 /* BinaryExpression */) { + else if (expr.kind === 221 /* SyntaxKind.BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -57764,19 +57947,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 16777216 /* Ambient */); + return !(member.flags & 16777216 /* NodeFlags.Ambient */); } switch (expr.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return true; - case 219 /* PrefixUnaryExpression */: - return expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; - case 79 /* Identifier */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + return expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; + case 79 /* SyntaxKind.Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -57791,11 +57974,11 @@ var ts; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (member.initializer && ts.isStringLiteralLike(member.initializer)) { - return links.enumKind = 1 /* Literal */; + return links.enumKind = 1 /* EnumKind.Literal */; } if (!isLiteralEnumMember(member)) { hasNonLiteralMember = true; @@ -57804,23 +57987,23 @@ var ts; } } } - return links.enumKind = hasNonLiteralMember ? 0 /* Numeric */ : 1 /* Literal */; + return links.enumKind = hasNonLiteralMember ? 0 /* EnumKind.Numeric */ : 1 /* EnumKind.Literal */; } function getBaseTypeOfEnumLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && !(type.flags & 1048576 /* TypeFlags.Union */) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type; } function getDeclaredTypeOfEnum(symbol) { var links = getSymbolLinks(symbol); if (links.declaredType) { return links.declaredType; } - if (getEnumKind(symbol) === 1 /* Literal */) { + if (getEnumKind(symbol) === 1 /* EnumKind.Literal */) { enumCount++; var memberTypeList = []; if (symbol.declarations) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 260 /* EnumDeclaration */) { + if (declaration.kind === 260 /* SyntaxKind.EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -57832,15 +58015,15 @@ var ts; } } if (memberTypeList.length) { - var enumType_1 = getUnionType(memberTypeList, 1 /* Literal */, symbol, /*aliasTypeArguments*/ undefined); - if (enumType_1.flags & 1048576 /* Union */) { - enumType_1.flags |= 1024 /* EnumLiteral */; + var enumType_1 = getUnionType(memberTypeList, 1 /* UnionReduction.Literal */, symbol, /*aliasTypeArguments*/ undefined); + if (enumType_1.flags & 1048576 /* TypeFlags.Union */) { + enumType_1.flags |= 1024 /* TypeFlags.EnumLiteral */; enumType_1.symbol = symbol; } return links.declaredType = enumType_1; } } - var enumType = createType(32 /* Enum */); + var enumType = createType(32 /* TypeFlags.Enum */); enumType.symbol = symbol; return links.declaredType = enumType; } @@ -57866,22 +58049,22 @@ var ts; return tryGetDeclaredTypeOfSymbol(symbol) || errorType; } function tryGetDeclaredTypeOfSymbol(symbol) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getDeclaredTypeOfClassOrInterface(symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 384 /* Enum */) { + if (symbol.flags & 384 /* SymbolFlags.Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 8 /* EnumMember */) { + if (symbol.flags & 8 /* SymbolFlags.EnumMember */) { return getDeclaredTypeOfEnumMember(symbol); } - if (symbol.flags & 2097152 /* Alias */) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */) { return getDeclaredTypeOfAlias(symbol); } return undefined; @@ -57893,22 +58076,22 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 158 /* BigIntKeyword */: - case 133 /* BooleanKeyword */: - case 151 /* SymbolKeyword */: - case 148 /* ObjectKeyword */: - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: - case 196 /* LiteralType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 196 /* SyntaxKind.LiteralType */: return true; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return isThislessType(node.elementType); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -57934,7 +58117,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 171 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 171 /* SyntaxKind.Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -57950,14 +58133,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -57994,8 +58177,8 @@ var ts; type.declaredCallSignatures = ts.emptyArray; type.declaredConstructSignatures = ts.emptyArray; type.declaredIndexInfos = ts.emptyArray; - type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* Call */)); - type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* New */)); + type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call" /* InternalSymbolName.Call */)); + type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new" /* InternalSymbolName.New */)); type.declaredIndexInfos = getIndexInfosOfSymbol(symbol); } return type; @@ -58004,7 +58187,7 @@ var ts; * Indicates whether a type can be used as a property name. */ function isTypeUsableAsPropertyName(type) { - return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */); + return !!(type.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); } /** * Indicates whether a declaration name is definitely late-bindable. @@ -58023,9 +58206,9 @@ var ts; && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { - return name.charCodeAt(0) === 95 /* _ */ && - name.charCodeAt(1) === 95 /* _ */ && - name.charCodeAt(2) === 64 /* at */; + return name.charCodeAt(0) === 95 /* CharacterCodes._ */ && + name.charCodeAt(1) === 95 /* CharacterCodes._ */ && + name.charCodeAt(2) === 64 /* CharacterCodes.at */; } /** * Indicates whether a declaration has a late-bindable dynamic name. @@ -58050,10 +58233,10 @@ var ts; * Gets the symbolic name for a member from its type. */ function getPropertyNameFromType(type) { - if (type.flags & 8192 /* UniqueESSymbol */) { + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */) { return type.escapedName; } - if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (type.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { return ts.escapeLeadingUnderscores("" + type.value); } return ts.Debug.fail(); @@ -58064,7 +58247,7 @@ var ts; * members. */ function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) { - ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol."); + ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */), "Expected a late-bound symbol."); symbol.flags |= symbolFlags; getSymbolLinks(member.symbol).lateSymbol = symbol; if (!symbol.declarations) { @@ -58073,7 +58256,7 @@ var ts; else if (!member.symbol.isReplaceableByMethod) { symbol.declarations.push(member); } - if (symbolFlags & 111551 /* Value */) { + if (symbolFlags & 111551 /* SymbolFlags.Value */) { if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) { symbol.valueDeclaration = member; } @@ -58122,7 +58305,7 @@ var ts; // Get or add a late-bound symbol for the member. This allows us to merge late-bound accessor declarations. var lateSymbol = lateSymbols.get(memberName); if (!lateSymbol) - lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */)); + lateSymbols.set(memberName, lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */)); // Report an error if a late-bound member has the same name as an early-bound member, // or if we have another early-bound symbol declaration with the same name and // conflicting flags. @@ -58131,10 +58314,10 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_5 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); + var name_5 = !(type.flags & 8192 /* TypeFlags.UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_5); }); error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_5); - lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); + lateSymbol = createSymbol(0 /* SymbolFlags.None */, memberName, 4096 /* CheckFlags.Late */); } lateSymbol.nameType = type; addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags); @@ -58152,9 +58335,9 @@ var ts; function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) { var links = getSymbolLinks(symbol); if (!links[resolutionKind]) { - var isStatic_1 = resolutionKind === "resolvedExports" /* resolvedExports */; + var isStatic_1 = resolutionKind === "resolvedExports" /* MembersOrExportsResolutionKind.resolvedExports */; var earlySymbols = !isStatic_1 ? symbol.members : - symbol.flags & 1536 /* Module */ ? getExportsOfModuleWorker(symbol) : + symbol.flags & 1536 /* SymbolFlags.Module */ ? getExportsOfModuleWorker(symbol) : symbol.exports; // In the event we recursively resolve the members/exports of the symbol, we // set the initial value of resolvedMembers/resolvedExports to the early-bound @@ -58180,10 +58363,10 @@ var ts; for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { var member = decls_1[_c]; var assignmentKind = ts.getAssignmentDeclarationKind(member); - var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + var isInstanceMember = assignmentKind === 3 /* AssignmentDeclarationKind.PrototypeProperty */ || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind) - || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ - || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + || assignmentKind === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* AssignmentDeclarationKind.Prototype */; // A straight `Prototype` assignment probably can never have a computed name if (isStatic_1 === !isInstanceMember && hasLateBindableName(member)) { lateBindMember(symbol, earlySymbols, lateSymbols, member); } @@ -58199,8 +58382,8 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6256 /* LateBindingContainer */ - ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) + return symbol.flags & 6256 /* SymbolFlags.LateBindingContainer */ + ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* MembersOrExportsResolutionKind.resolvedMembers */) : symbol.members || emptySymbols; } /** @@ -58210,7 +58393,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getLateBoundSymbol(symbol) { - if (symbol.flags & 106500 /* ClassMember */ && symbol.escapedName === "__computed" /* Computed */) { + if (symbol.flags & 106500 /* SymbolFlags.ClassMember */ && symbol.escapedName === "__computed" /* InternalSymbolName.Computed */) { var links = getSymbolLinks(symbol); if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol @@ -58227,7 +58410,7 @@ var ts; return symbol; } function getTypeWithThisArgument(type, thisArgument, needApparentType) { - if (ts.getObjectFlags(type) & 4 /* Reference */) { + if (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) { var target = type.target; var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { @@ -58235,7 +58418,7 @@ var ts; return needApparentType ? getApparentType(ref) : ref; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); }); return types !== type.types ? getIntersectionType(types) : type; } @@ -58271,8 +58454,8 @@ var ts; var baseType = baseTypes_1[_i]; var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); - callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); - constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* SignatureKind.Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* SignatureKind.Construct */)); var inheritedIndexInfos = instantiatedBaseType !== anyType ? getIndexInfosOfType(instantiatedBaseType) : [createIndexInfo(stringType, anyType, /*isReadonly*/ false)]; indexInfos = ts.concatenate(indexInfos, ts.filter(inheritedIndexInfos, function (info) { return !findIndexInfo(indexInfos, info.keyType); })); } @@ -58307,7 +58490,7 @@ var ts; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; result.compositeSignatures = sig.compositeSignatures; @@ -58317,24 +58500,24 @@ var ts; function createUnionSignature(signature, unionSignatures) { var result = cloneSignature(signature); result.compositeSignatures = unionSignatures; - result.compositeKind = 1048576 /* Union */; + result.compositeKind = 1048576 /* TypeFlags.Union */; result.target = undefined; result.mapper = undefined; return result; } function getOptionalCallSignature(signature, callChainFlags) { - if ((signature.flags & 24 /* CallChainFlags */) === callChainFlags) { + if ((signature.flags & 24 /* SignatureFlags.CallChainFlags */) === callChainFlags) { return signature; } if (!signature.optionalCallSignatureCache) { signature.optionalCallSignatureCache = {}; } - var key = callChainFlags === 8 /* IsInnerCallChain */ ? "inner" : "outer"; + var key = callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ ? "inner" : "outer"; return signature.optionalCallSignatureCache[key] || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags)); } function createOptionalCallSignature(signature, callChainFlags) { - ts.Debug.assert(callChainFlags === 8 /* IsInnerCallChain */ || callChainFlags === 16 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); + ts.Debug.assert(callChainFlags === 8 /* SignatureFlags.IsInnerCallChain */ || callChainFlags === 16 /* SignatureFlags.IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both."); var result = cloneSignature(signature); result.flags |= callChainFlags; return result; @@ -58346,7 +58529,7 @@ var ts; if (isTupleType(restType)) { return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)]; } - else if (!skipUnionExpanding && restType.flags & 1048576 /* Union */ && ts.every(restType.types, isTupleType)) { + else if (!skipUnionExpanding && restType.flags & 1048576 /* TypeFlags.Union */ && ts.every(restType.types, isTupleType)) { return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); }); } } @@ -58359,10 +58542,10 @@ var ts; var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]); var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType); var flags = restType.target.elementFlags[i]; - var checkFlags = flags & 12 /* Variable */ ? 32768 /* RestParameter */ : - flags & 2 /* Optional */ ? 16384 /* OptionalParameter */ : 0; - var symbol = createSymbol(1 /* FunctionScopedVariable */, name, checkFlags); - symbol.type = flags & 4 /* Rest */ ? createArrayType(t) : t; + var checkFlags = flags & 12 /* ElementFlags.Variable */ ? 32768 /* CheckFlags.RestParameter */ : + flags & 2 /* ElementFlags.Optional */ ? 16384 /* CheckFlags.OptionalParameter */ : 0; + var symbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, name, checkFlags); + symbol.type = flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t; return symbol; }); return ts.concatenate(sig.parameters.slice(0, restIndex), restParams); @@ -58370,11 +58553,11 @@ var ts; } function getDefaultConstructSignatures(classType) { var baseConstructorType = getBaseConstructorTypeOfClass(classType); - var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); + var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol); - var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* Abstract */); + var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* Abstract */ : 0 /* None */)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, isAbstract ? 4 /* SignatureFlags.Abstract */ : 0 /* SignatureFlags.None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -58389,7 +58572,7 @@ var ts; var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; - sig.flags = isAbstract ? sig.flags | 4 /* Abstract */ : sig.flags & ~4 /* Abstract */; + sig.flags = isAbstract ? sig.flags | 4 /* SignatureFlags.Abstract */ : sig.flags & ~4 /* SignatureFlags.Abstract */; result.push(sig); } } @@ -58552,12 +58735,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -58579,11 +58762,11 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 1048576 /* Union */; - result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 1048576 /* TypeFlags.Union */; + result.compositeSignatures = ts.concatenate(left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind !== 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind !== 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } @@ -58608,8 +58791,8 @@ var ts; function resolveUnionTypeMembers(type) { // The members and properties collections are empty for union types. To get all properties of a union // type use getPropertiesOfType (only the language service uses this). - var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* Call */); })); - var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* Construct */); })); + var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0 /* SignatureKind.Call */); })); + var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */); })); var indexInfos = getUnionIndexInfos(type.types); setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, indexInfos); } @@ -58617,7 +58800,7 @@ var ts; return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); } function findMixins(types) { - var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* Construct */).length > 0; }); + var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1 /* SignatureKind.Construct */).length > 0; }); var mixinFlags = ts.map(types, isMixinConstructorType); if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) { var firstMixinIndex = mixinFlags.indexOf(/*searchElement*/ true); @@ -58632,7 +58815,7 @@ var ts; mixedTypes.push(type); } else if (mixinFlags[i]) { - mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* Construct */)[0])); + mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1 /* SignatureKind.Construct */)[0])); } } return getIntersectionType(mixedTypes); @@ -58654,7 +58837,7 @@ var ts; // '{ new(...args: any[]) => A } & { new(s: string) => B }' has a single construct signature // 'new(s: string) => A & B'. if (!mixinFlags[i]) { - var signatures = getSignaturesOfType(t, 1 /* Construct */); + var signatures = getSignaturesOfType(t, 1 /* SignatureKind.Construct */); if (signatures.length && mixinCount > 0) { signatures = ts.map(signatures, function (s) { var clone = cloneSignature(s); @@ -58664,7 +58847,7 @@ var ts; } constructSignatures = appendSignatures(constructSignatures, signatures); } - callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0 /* SignatureKind.Call */)); indexInfos = ts.reduceLeft(getIndexInfosOfType(t), function (infos, newInfo) { return appendIndexInfo(infos, newInfo, /*union*/ false); }, indexInfos); }; for (var i = 0; i < types.length; i++) { @@ -58703,18 +58886,18 @@ var ts; if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); - var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper); - var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper); + var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* SignatureKind.Call */), type.mapper); + var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* SignatureKind.Construct */), type.mapper); var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper); setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1); return; } var symbol = getMergedSymbol(type.symbol); - if (symbol.flags & 2048 /* TypeLiteral */) { + if (symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray); var members_7 = getMembersOfSymbol(symbol); - var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */)); - var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */)); + var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* InternalSymbolName.Call */)); + var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* InternalSymbolName.New */)); var indexInfos_2 = getIndexInfosOfSymbol(symbol); setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2); return; @@ -58728,7 +58911,7 @@ var ts; var varsOnly_1 = new ts.Map(); members.forEach(function (p) { var _a; - if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { + if (!(p.flags & 418 /* SymbolFlags.BlockScoped */) && !(p.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) { varsOnly_1.set(p.escapedName, p); } }); @@ -58737,10 +58920,10 @@ var ts; } var baseConstructorIndexInfo; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray); - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) { + if (baseConstructorType.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 8650752 /* TypeFlags.TypeVariable */)) { members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } @@ -58756,8 +58939,8 @@ var ts; if (baseConstructorIndexInfo) { indexInfos = ts.append(indexInfos, baseConstructorIndexInfo); } - if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ || - ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) { + if (symbol.flags & 384 /* SymbolFlags.Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* TypeFlags.Enum */ || + ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* TypeFlags.NumberLike */); }))) { indexInfos = ts.append(indexInfos, enumNumberIndexInfo); } } @@ -58766,16 +58949,16 @@ var ts; // typeof with a qualified name expression that circularly references the type we are // in the process of resolving (see issue #6072). The temporarily empty signature list // will never be observed because a qualified name can't reference signatures. - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); } // And likewise for construct signatures for classes - if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 32 /* SymbolFlags.Class */) { var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; - if (symbol.flags & 16 /* Function */) { + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* InternalSymbolName.Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* SymbolFlags.Function */) { constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? - createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) : + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* SignatureFlags.PropagatingFlags */) : undefined; })); } if (!constructSignatures.length) { @@ -58793,20 +58976,20 @@ var ts; function resolveReverseMappedTypeMembers(type) { var indexInfo = getIndexInfoOfType(type.source, stringType); var modifiers = getMappedTypeModifiers(type.mappedType); - var readonlyMask = modifiers & 1 /* IncludeReadonly */ ? false : true; - var optionalMask = modifiers & 4 /* IncludeOptional */ ? 0 : 16777216 /* Optional */; + var readonlyMask = modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? false : true; + var optionalMask = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 0 : 16777216 /* SymbolFlags.Optional */; var indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly)] : ts.emptyArray; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) { var prop = _a[_i]; - var checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0); - var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); + var checkFlags = 8192 /* CheckFlags.ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* CheckFlags.Readonly */ : 0); + var inferredProp = createSymbol(4 /* SymbolFlags.Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags); inferredProp.declarations = prop.declarations; inferredProp.nameType = getSymbolLinks(prop).nameType; inferredProp.propertyType = getTypeOfSymbol(prop); - if (type.constraintType.type.flags & 8388608 /* IndexedAccess */ - && type.constraintType.type.objectType.flags & 262144 /* TypeParameter */ - && type.constraintType.type.indexType.flags & 262144 /* TypeParameter */) { + if (type.constraintType.type.flags & 8388608 /* TypeFlags.IndexedAccess */ + && type.constraintType.type.objectType.flags & 262144 /* TypeFlags.TypeParameter */ + && type.constraintType.type.indexType.flags & 262144 /* TypeFlags.TypeParameter */) { // A reverse mapping of `{[K in keyof T[K_1]]: T[K_1]}` is the same as that of `{[K in keyof T]: T}`, since all we care about is // inferring to the "type parameter" (or indexed access) shared by the constraint and template. So, to reduce the number of // type identities produced, we simplify such indexed access occurences @@ -58827,11 +59010,11 @@ var ts; // bound includes those keys that are known to always be present, for example because // because of constraints on type parameters (e.g. 'keyof T' for a constrained T). function getLowerBoundOfKeyType(type) { - if (type.flags & 4194304 /* Index */) { + if (type.flags & 4194304 /* TypeFlags.Index */) { var t = getApparentType(type.type); return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t); } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { if (type.root.isDistributive) { var checkType = type.checkType; var constraint = getLowerBoundOfKeyType(checkType); @@ -58841,29 +59024,29 @@ var ts; } return type; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getLowerBoundOfKeyType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType)); } return type; } function getIsLateCheckFlag(s) { - return ts.getCheckFlags(s) & 4096 /* Late */; + return ts.getCheckFlags(s) & 4096 /* CheckFlags.Late */; } function forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(type, include, stringsOnly, cb) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; cb(getLiteralTypeFromProperty(prop, include)); } - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { cb(stringType); } else { for (var _b = 0, _c = getIndexInfosOfType(type); _b < _c.length; _b++) { var info = _c[_b]; - if (!stringsOnly || info.keyType.flags & (4 /* String */ | 134217728 /* TemplateLiteral */)) { + if (!stringsOnly || info.keyType.flags & (4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */)) { cb(info.keyType); } } @@ -58883,7 +59066,7 @@ var ts; var templateType = getTemplateTypeFromMappedType(type.target || type); var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateModifiers = getMappedTypeModifiers(type); - var include = keyofStringsOnly ? 128 /* StringLiteral */ : 8576 /* StringOrNumberLiteralOrUnique */; + var include = keyofStringsOnly ? 128 /* TypeFlags.StringLiteral */ : 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */; if (isMappedTypeWithKeyofConstraintDeclaration(type)) { // We have a { [P in keyof T]: X } forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, include, keyofStringsOnly, addMemberForKeyType); @@ -58911,13 +59094,13 @@ var ts; } else { var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined; - var isOptional = !!(templateModifiers & 4 /* IncludeOptional */ || - !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); - var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || - !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); - var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; + var isOptional = !!(templateModifiers & 4 /* MappedTypeModifiers.IncludeOptional */ || + !(templateModifiers & 8 /* MappedTypeModifiers.ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */); + var isReadonly = !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ || + !(templateModifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); + var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* SymbolFlags.Optional */; var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0; - var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, lateFlag | 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); + var prop = createSymbol(4 /* SymbolFlags.Property */ | (isOptional ? 16777216 /* SymbolFlags.Optional */ : 0), propName, lateFlag | 262144 /* CheckFlags.Mapped */ | (isReadonly ? 8 /* CheckFlags.Readonly */ : 0) | (stripOptional ? 524288 /* CheckFlags.StripOptional */ : 0)); prop.mappedType = type; prop.nameType = propNameType; prop.keyType = keyType; @@ -58930,12 +59113,12 @@ var ts; members.set(propName, prop); } } - else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* Any */ | 32 /* Enum */)) { - var indexKeyType = propNameType.flags & (1 /* Any */ | 4 /* String */) ? stringType : - propNameType.flags & (8 /* Number */ | 32 /* Enum */) ? numberType : + else if (isValidIndexKeyType(propNameType) || propNameType.flags & (1 /* TypeFlags.Any */ | 32 /* TypeFlags.Enum */)) { + var indexKeyType = propNameType.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */) ? stringType : + propNameType.flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */) ? numberType : propNameType; var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType)); - var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + var indexInfo = createIndexInfo(indexKeyType, propType, !!(templateModifiers & 1 /* MappedTypeModifiers.IncludeReadonly */)); indexInfos = appendIndexInfo(indexInfos, indexInfo, /*union*/ true); } } @@ -58943,7 +59126,7 @@ var ts; function getTypeOfMappedSymbol(symbol) { if (!symbol.type) { var mappedType = symbol.mappedType; - if (!pushTypeResolution(symbol, 0 /* Type */)) { + if (!pushTypeResolution(symbol, 0 /* TypeSystemPropertyName.Type */)) { mappedType.containsError = true; return errorType; } @@ -58953,8 +59136,8 @@ var ts; // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks // mode, if the underlying property is optional we remove 'undefined' from the type. - var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - symbol.checkFlags & 524288 /* StripOptional */ ? removeMissingOrUndefinedType(propType) : + var type = strictNullChecks && symbol.flags & 16777216 /* SymbolFlags.Optional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + symbol.checkFlags & 524288 /* CheckFlags.StripOptional */ ? removeMissingOrUndefinedType(propType) : propType; if (!popTypeResolution()) { error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType)); @@ -58980,7 +59163,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), /*isProperty*/ true, !!(getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -58988,8 +59171,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 193 /* TypeOperator */ && - constraintDeclaration.operator === 140 /* KeyOfKeyword */; + return constraintDeclaration.kind === 193 /* SyntaxKind.TypeOperator */ && + constraintDeclaration.operator === 140 /* SyntaxKind.KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -59005,20 +59188,20 @@ var ts; // the modifiers type is T. Otherwise, the modifiers type is unknown. var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); - var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; + var extendedConstraint = constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* TypeFlags.Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; } } return type.modifiersType; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* SyntaxKind.MinusToken */ ? 2 /* MappedTypeModifiers.ExcludeReadonly */ : 1 /* MappedTypeModifiers.IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* SyntaxKind.MinusToken */ ? 8 /* MappedTypeModifiers.ExcludeOptional */ : 4 /* MappedTypeModifiers.IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); - return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0; + return modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? -1 : modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? 1 : 0; } function getCombinedMappedTypeOptionality(type) { var optionality = getMappedTypeOptionality(type); @@ -59026,42 +59209,48 @@ var ts; return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0); } function isPartialMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */); } function isGenericMappedType(type) { - return !!(ts.getObjectFlags(type) & 32 /* Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); + return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) && isGenericIndexType(getConstraintTypeFromMappedType(type)); } function resolveStructuredTypeMembers(type) { if (!type.members) { - if (type.flags & 524288 /* Object */) { - if (type.objectFlags & 4 /* Reference */) { + if (type.flags & 524288 /* TypeFlags.Object */) { + if (type.objectFlags & 4 /* ObjectFlags.Reference */) { resolveTypeReferenceMembers(type); } - else if (type.objectFlags & 3 /* ClassOrInterface */) { + else if (type.objectFlags & 3 /* ObjectFlags.ClassOrInterface */) { resolveClassOrInterfaceMembers(type); } - else if (type.objectFlags & 1024 /* ReverseMapped */) { + else if (type.objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { resolveReverseMappedTypeMembers(type); } - else if (type.objectFlags & 16 /* Anonymous */) { + else if (type.objectFlags & 16 /* ObjectFlags.Anonymous */) { resolveAnonymousTypeMembers(type); } - else if (type.objectFlags & 32 /* Mapped */) { + else if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { resolveMappedTypeMembers(type); } + else { + ts.Debug.fail("Unhandled object type " + ts.Debug.formatObjectFlags(type.objectFlags)); + } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { resolveUnionTypeMembers(type); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { resolveIntersectionTypeMembers(type); } + else { + ts.Debug.fail("Unhandled type " + ts.Debug.formatTypeFlags(type.flags)); + } } return type; } /** Return properties of an object type or an empty array for other types */ function getPropertiesOfObjectType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { return resolveStructuredTypeMembers(type).properties; } return ts.emptyArray; @@ -59070,7 +59259,7 @@ var ts; * return the symbol for that property. Otherwise return undefined. */ function getPropertyOfObjectType(type, name) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol)) { @@ -59094,7 +59283,7 @@ var ts; } // The properties of a union type are those that are present in all constituent types, so // we only need to check the properties of the first type without index signature - if (type.flags & 1048576 /* Union */ && getIndexInfosOfType(current).length === 0) { + if (type.flags & 1048576 /* TypeFlags.Union */ && getIndexInfosOfType(current).length === 0) { break; } } @@ -59104,13 +59293,13 @@ var ts; } function getPropertiesOfType(type) { type = getReducedApparentType(type); - return type.flags & 3145728 /* UnionOrIntersection */ ? + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function forEachPropertyOfType(type, action) { type = getReducedApparentType(type); - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { resolveStructuredTypeMembers(type).members.forEach(function (symbol, escapedName) { if (isNamedMember(symbol, escapedName)) { action(symbol, escapedName); @@ -59129,7 +59318,7 @@ var ts; } function getAllPossiblePropertiesOfTypes(types) { var unionType = getUnionType(types); - if (!(unionType.flags & 1048576 /* Union */)) { + if (!(unionType.flags & 1048576 /* TypeFlags.Union */)) { return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); @@ -59148,9 +59337,9 @@ var ts; return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { - return type.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : - type.flags & 8388608 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : - type.flags & 16777216 /* Conditional */ ? getConstraintOfConditionalType(type) : + return type.flags & 262144 /* TypeFlags.TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getConstraintOfConditionalType(type) : getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { @@ -59211,7 +59400,7 @@ var ts; var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint && constraint !== type.checkType) { var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); - if (!(instantiated.flags & 131072 /* Never */)) { + if (!(instantiated.flags & 131072 /* TypeFlags.Never */)) { return instantiated; } } @@ -59229,11 +59418,11 @@ var ts; var hasDisjointDomainType = false; for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { var t = types_5[_i]; - if (t.flags & 465829888 /* Instantiable */) { + if (t.flags & 465829888 /* TypeFlags.Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). var constraint = getConstraintOfType(t); - while (constraint && constraint.flags & (262144 /* TypeParameter */ | 4194304 /* Index */ | 16777216 /* Conditional */)) { + while (constraint && constraint.flags & (262144 /* TypeFlags.TypeParameter */ | 4194304 /* TypeFlags.Index */ | 16777216 /* TypeFlags.Conditional */)) { constraint = getConstraintOfType(constraint); } if (constraint) { @@ -59243,7 +59432,7 @@ var ts; } } } - else if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) { + else if (t.flags & 469892092 /* TypeFlags.DisjointDomains */ || isEmptyAnonymousObjectType(t)) { hasDisjointDomainType = true; } } @@ -59255,21 +59444,22 @@ var ts; // intersection operation to reduce the union constraints. for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { var t = types_6[_a]; - if (t.flags & 469892092 /* DisjointDomains */ || isEmptyAnonymousObjectType(t)) { + if (t.flags & 469892092 /* TypeFlags.DisjointDomains */ || isEmptyAnonymousObjectType(t)) { constraints = ts.append(constraints, t); } } } - return getIntersectionType(constraints); + // The source types were normalized; ensure the result is normalized too. + return getNormalizedType(getIntersectionType(constraints), /*writing*/ false); } return undefined; } function getBaseConstraintOfType(type) { - if (type.flags & (58982400 /* InstantiableNonPrimitive */ | 3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) { + if (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */)) { var constraint = getResolvedBaseConstraint(type); return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; } - return type.flags & 4194304 /* Index */ ? keyofConstraintType : undefined; + return type.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : undefined; } /** * This is similar to `getBaseConstraintOfType` except it returns the input type if there's no base constraint, instead of `undefined` @@ -59294,7 +59484,7 @@ var ts; return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type); function getImmediateBaseConstraint(t) { if (!t.immediateBaseConstraint) { - if (!pushTypeResolution(t, 4 /* ImmediateBaseConstraint */)) { + if (!pushTypeResolution(t, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */)) { return circularConstraintType; } var result = void 0; @@ -59311,7 +59501,7 @@ var ts; stack.pop(); } if (!popTypeResolution()) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var errorNode = getConstraintDeclaration(t); if (errorNode) { var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t)); @@ -59331,13 +59521,13 @@ var ts; return c !== noConstraintType && c !== circularConstraintType ? c : undefined; } function computeBaseConstraint(t) { - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { var constraint = getConstraintFromTypeParameter(t); return t.isThisType || !constraint ? constraint : getBaseConstraint(constraint); } - if (t.flags & 3145728 /* UnionOrIntersection */) { + if (t.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = t.types; var baseTypes = []; var different = false; @@ -59357,23 +59547,23 @@ var ts; if (!different) { return t; } - return t.flags & 1048576 /* Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : - t.flags & 2097152 /* Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : + return t.flags & 1048576 /* TypeFlags.Union */ && baseTypes.length === types.length ? getUnionType(baseTypes) : + t.flags & 2097152 /* TypeFlags.Intersection */ && baseTypes.length ? getIntersectionType(baseTypes) : undefined; } - if (t.flags & 4194304 /* Index */) { + if (t.flags & 4194304 /* TypeFlags.Index */) { return keyofConstraintType; } - if (t.flags & 134217728 /* TemplateLiteral */) { + if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var types = t.types; var constraints = ts.mapDefined(types, getBaseConstraint); return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType; } - if (t.flags & 268435456 /* StringMapping */) { + if (t.flags & 268435456 /* TypeFlags.StringMapping */) { var constraint = getBaseConstraint(t.type); return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType; } - if (t.flags & 8388608 /* IndexedAccess */) { + if (t.flags & 8388608 /* TypeFlags.IndexedAccess */) { if (isMappedTypeGenericIndexedAccess(t)) { // For indexed access types of the form { [P in K]: E }[X], where K is non-generic and X is generic, // we substitute an instantiation of E where P is replaced with X. @@ -59384,11 +59574,11 @@ var ts; var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.accessFlags); return baseIndexedAccess && getBaseConstraint(baseIndexedAccess); } - if (t.flags & 16777216 /* Conditional */) { + if (t.flags & 16777216 /* TypeFlags.Conditional */) { var constraint = getConstraintFromConditionalType(t); return constraint && getBaseConstraint(constraint); } - if (t.flags & 33554432 /* Substitution */) { + if (t.flags & 33554432 /* TypeFlags.Substitution */) { return getBaseConstraint(t.substitute); } return t; @@ -59455,9 +59645,9 @@ var ts; } function isMappedTypeGenericIndexedAccess(type) { var objectType; - return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ && + return !!(type.flags & 8388608 /* TypeFlags.IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* ObjectFlags.Mapped */ && !isGenericMappedType(objectType) && isGenericIndexType(type.indexType) && - !(getMappedTypeModifiers(objectType) & 8 /* ExcludeOptional */) && !objectType.declaration.nameType); + !(getMappedTypeModifiers(objectType) & 8 /* MappedTypeModifiers.ExcludeOptional */) && !objectType.declaration.nameType); } /** * For a type parameter, return the base constraint of the type parameter. For the string, number, @@ -59465,17 +59655,17 @@ var ts; * type itself. */ function getApparentType(type) { - var t = !(type.flags & 465829888 /* Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; - return ts.getObjectFlags(t) & 32 /* Mapped */ ? getApparentTypeOfMappedType(t) : - t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : - t.flags & 402653316 /* StringLike */ ? globalStringType : - t.flags & 296 /* NumberLike */ ? globalNumberType : - t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType() : - t.flags & 528 /* BooleanLike */ ? globalBooleanType : - t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType() : - t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : - t.flags & 4194304 /* Index */ ? keyofConstraintType : - t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : + var t = !(type.flags & 465829888 /* TypeFlags.Instantiable */) ? type : getBaseConstraintOfType(type) || unknownType; + return ts.getObjectFlags(t) & 32 /* ObjectFlags.Mapped */ ? getApparentTypeOfMappedType(t) : + t.flags & 2097152 /* TypeFlags.Intersection */ ? getApparentTypeOfIntersectionType(t) : + t.flags & 402653316 /* TypeFlags.StringLike */ ? globalStringType : + t.flags & 296 /* TypeFlags.NumberLike */ ? globalNumberType : + t.flags & 2112 /* TypeFlags.BigIntLike */ ? getGlobalBigIntType() : + t.flags & 528 /* TypeFlags.BooleanLike */ ? globalBooleanType : + t.flags & 12288 /* TypeFlags.ESSymbolLike */ ? getGlobalESSymbolType() : + t.flags & 67108864 /* TypeFlags.NonPrimitive */ ? emptyObjectType : + t.flags & 4194304 /* TypeFlags.Index */ ? keyofConstraintType : + t.flags & 2 /* TypeFlags.Unknown */ && !strictNullChecks ? emptyObjectType : t; } function getReducedApparentType(type) { @@ -59490,21 +59680,21 @@ var ts; var singleProp; var propSet; var indexTypes; - var isUnion = containingType.flags & 1048576 /* Union */; + var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */; // Flags we want to propagate to the result if they exist in all source symbols - var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; - var syntheticFlag = 4 /* SyntheticMethod */; - var checkFlags = isUnion ? 0 : 8 /* Readonly */; + var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */; + var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */; + var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */; var mergedInstantiations = false; for (var _i = 0, _c = containingType.types; _i < _c.length; _i++) { var current = _c[_i]; var type = getApparentType(current); - if (!(isErrorType(type) || type.flags & 131072 /* Never */)) { + if (!(isErrorType(type) || type.flags & 131072 /* TypeFlags.Never */)) { var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop) { if (isUnion) { - optionalFlag |= (prop.flags & 16777216 /* Optional */); + optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */); } else { optionalFlag &= prop.flags; @@ -59517,7 +59707,7 @@ var ts; // If the symbols are instances of one another with identical types - consider the symbols // equivalent and just use the first one, which thus allows us to avoid eliding private // members when intersecting a (this-)instantiations of a class with it's raw base or another instance - if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* True */ : 0 /* False */; }) === -1 /* True */) { + if (isInstantiation && compareProperties(singleProp, prop, function (a, b) { return a === b ? -1 /* Ternary.True */ : 0 /* Ternary.False */; }) === -1 /* Ternary.True */) { // If we merged instantiations of a generic type, we replicate the symbol parent resetting behavior we used // to do when we recorded multiple distinct symbols so that we still get, eg, `Array.length` printed // back and not `Array.length` when we're looking at a `.length` access on a `string[] | number[]` @@ -59535,41 +59725,41 @@ var ts; } } if (isUnion && isReadonlySymbol(prop)) { - checkFlags |= 8 /* Readonly */; + checkFlags |= 8 /* CheckFlags.Readonly */; } else if (!isUnion && !isReadonlySymbol(prop)) { - checkFlags &= ~8 /* Readonly */; + checkFlags &= ~8 /* CheckFlags.Readonly */; } - checkFlags |= (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 512 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 1024 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 2048 /* ContainsStatic */ : 0); + checkFlags |= (!(modifiers & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) ? 256 /* CheckFlags.ContainsPublic */ : 0) | + (modifiers & 16 /* ModifierFlags.Protected */ ? 512 /* CheckFlags.ContainsProtected */ : 0) | + (modifiers & 8 /* ModifierFlags.Private */ ? 1024 /* CheckFlags.ContainsPrivate */ : 0) | + (modifiers & 32 /* ModifierFlags.Static */ ? 2048 /* CheckFlags.ContainsStatic */ : 0); if (!isPrototypeProperty(prop)) { - syntheticFlag = 2 /* SyntheticProperty */; + syntheticFlag = 2 /* CheckFlags.SyntheticProperty */; } } else if (isUnion) { var indexInfo = !isLateBoundName(name) && getApplicableIndexInfoForName(type, name); if (indexInfo) { - checkFlags |= 32 /* WritePartial */ | (indexInfo.isReadonly ? 8 /* Readonly */ : 0); + checkFlags |= 32 /* CheckFlags.WritePartial */ | (indexInfo.isReadonly ? 8 /* CheckFlags.Readonly */ : 0); indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type); } - else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ContainsSpread */)) { - checkFlags |= 32 /* WritePartial */; + else if (isObjectLiteralType(type) && !(ts.getObjectFlags(type) & 2097152 /* ObjectFlags.ContainsSpread */)) { + checkFlags |= 32 /* CheckFlags.WritePartial */; indexTypes = ts.append(indexTypes, undefinedType); } else { - checkFlags |= 16 /* ReadPartial */; + checkFlags |= 16 /* CheckFlags.ReadPartial */; } } } } - if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) { + if (!singleProp || isUnion && (propSet || checkFlags & 48 /* CheckFlags.Partial */) && checkFlags & (1024 /* CheckFlags.ContainsPrivate */ | 512 /* CheckFlags.ContainsProtected */)) { // No property was found, or, in a union, a property has a private or protected declaration in one // constituent, but is missing or has a different declaration in another constituent. return undefined; } - if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { + if (!propSet && !(checkFlags & 16 /* CheckFlags.ReadPartial */) && !indexTypes) { if (mergedInstantiations) { // No symbol from a union/intersection should have a `.parent` set (since unions/intersections don't act as symbol parents) // Unless that parent is "reconstituted" from the "first value declaration" on the symbol (which is likely different than its instantiated parent!) @@ -59611,18 +59801,18 @@ var ts; writeTypes = ts.append(!writeTypes ? propTypes.slice() : writeTypes, writeType); } else if (type !== firstType) { - checkFlags |= 64 /* HasNonUniformType */; + checkFlags |= 64 /* CheckFlags.HasNonUniformType */; } if (isLiteralType(type) || isPatternLiteralType(type) || type === uniqueLiteralType) { - checkFlags |= 128 /* HasLiteralType */; + checkFlags |= 128 /* CheckFlags.HasLiteralType */; } - if (type.flags & 131072 /* Never */ && type !== uniqueLiteralType) { - checkFlags |= 131072 /* HasNeverType */; + if (type.flags & 131072 /* TypeFlags.Never */ && type !== uniqueLiteralType) { + checkFlags |= 131072 /* CheckFlags.HasNeverType */; } propTypes.push(type); } ts.addRange(propTypes, indexTypes); - var result = createSymbol(4 /* Property */ | optionalFlag, name, syntheticFlag | checkFlags); + var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags); result.containingType = containingType; if (!hasNonUniformValueDeclaration && firstValueDeclaration) { result.valueDeclaration = firstValueDeclaration; @@ -59635,7 +59825,7 @@ var ts; result.nameType = nameType; if (propTypes.length > 2) { // When `propTypes` has the potential to explode in size when normalized, defer normalization until absolutely needed - result.checkFlags |= 65536 /* DeferredType */; + result.checkFlags |= 65536 /* CheckFlags.DeferredType */; result.deferralParent = containingType; result.deferralConstituents = propTypes; result.deferralWriteConstituents = writeTypes; @@ -59669,7 +59859,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) { var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment); // We need to filter out partial properties in union types - return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined; + return property && !(ts.getCheckFlags(property) & 16 /* CheckFlags.ReadPartial */) ? property : undefined; } /** * Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. @@ -59678,15 +59868,15 @@ var ts; * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. */ function getReducedType(type) { - if (type.flags & 1048576 /* Union */ && type.objectFlags & 16777216 /* ContainsIntersections */) { + if (type.flags & 1048576 /* TypeFlags.Union */ && type.objectFlags & 16777216 /* ObjectFlags.ContainsIntersections */) { return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); } - else if (type.flags & 2097152 /* Intersection */) { - if (!(type.objectFlags & 16777216 /* IsNeverIntersectionComputed */)) { - type.objectFlags |= 16777216 /* IsNeverIntersectionComputed */ | - (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* IsNeverIntersection */ : 0); + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { + if (!(type.objectFlags & 16777216 /* ObjectFlags.IsNeverIntersectionComputed */)) { + type.objectFlags |= 16777216 /* ObjectFlags.IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 33554432 /* ObjectFlags.IsNeverIntersection */ : 0); } - return type.objectFlags & 33554432 /* IsNeverIntersection */ ? neverType : type; + return type.objectFlags & 33554432 /* ObjectFlags.IsNeverIntersection */ ? neverType : type; } return type; } @@ -59696,7 +59886,7 @@ var ts; return unionType; } var reduced = getUnionType(reducedTypes); - if (reduced.flags & 1048576 /* Union */) { + if (reduced.flags & 1048576 /* TypeFlags.Union */) { reduced.resolvedReducedType = reduced; } return reduced; @@ -59707,23 +59897,23 @@ var ts; function isDiscriminantWithNeverType(prop) { // Return true for a synthetic non-optional property with non-uniform types, where at least one is // a literal type and none is never, that reduces to never. - return !(prop.flags & 16777216 /* Optional */) && - (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ && - !!(getTypeOfSymbol(prop).flags & 131072 /* Never */); + return !(prop.flags & 16777216 /* SymbolFlags.Optional */) && + (ts.getCheckFlags(prop) & (192 /* CheckFlags.Discriminant */ | 131072 /* CheckFlags.HasNeverType */)) === 192 /* CheckFlags.Discriminant */ && + !!(getTypeOfSymbol(prop).flags & 131072 /* TypeFlags.Never */); } function isConflictingPrivateProperty(prop) { // Return true for a synthetic property with multiple declarations, at least one of which is private. - return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); + return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* CheckFlags.ContainsPrivate */); } function elaborateNeverIntersection(errorInfo, type) { - if (type.flags & 2097152 /* Intersection */ && ts.getObjectFlags(type) & 33554432 /* IsNeverIntersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IsNeverIntersection */) { var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); if (neverProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(neverProp)); } var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty); if (privateProp) { - return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp)); + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* TypeFormatFlags.NoTypeReduction */), symbolToString(privateProp)); } } return errorInfo; @@ -59738,7 +59928,7 @@ var ts; */ function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment, includeTypeOnlyMembers) { type = getReducedApparentType(type); - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); if (symbol && symbolIsValue(symbol, includeTypeOnlyMembers)) { @@ -59758,15 +59948,15 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment); } return undefined; } function getSignaturesOfStructuredType(type, kind) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); - return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; + return kind === 0 /* SignatureKind.Call */ ? resolved.callSignatures : resolved.constructSignatures; } return ts.emptyArray; } @@ -59812,10 +60002,10 @@ var ts; // signature applies to types assignable to 'number', `${number}` and numeric string literal types. return isTypeAssignableTo(source, target) || target === stringType && isTypeAssignableTo(source, numberType) || - target === numberType && (source === numericStringType || !!(source.flags & 128 /* StringLiteral */) && ts.isNumericLiteralName(source.value)); + target === numberType && (source === numericStringType || !!(source.flags & 128 /* TypeFlags.StringLiteral */) && ts.isNumericLiteralName(source.value)); } function getIndexInfosOfStructuredType(type) { - if (type.flags & 3670016 /* StructuredType */) { + if (type.flags & 3670016 /* TypeFlags.StructuredType */) { var resolved = resolveStructuredTypeMembers(type); return resolved.indexInfos; } @@ -59847,12 +60037,15 @@ var ts; // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). function getTypeParametersFromDeclaration(declaration) { + var _a; var result; - for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) { - var node = _a[_i]; + for (var _i = 0, _b = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _b.length; _i++) { + var node = _b[_i]; result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol)); } - return result; + return (result === null || result === void 0 ? void 0 : result.length) ? result + : ts.isFunctionDeclaration(declaration) ? (_a = getSignatureOfTypeTag(declaration)) === null || _a === void 0 ? void 0 : _a.typeParameters + : undefined; } function symbolsToArray(symbols) { var result = []; @@ -59866,17 +60059,17 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 316 /* JSDocOptionalType */ + node.type && node.type.kind === 316 /* SyntaxKind.JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* SymbolFlags.ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -59891,7 +60084,7 @@ var ts; // Only consider syntactic or instantiated parameters as optional, not `void` parameters as this function is used // in grammar checks and checking for `void` too early results in parameter types widening too early // and causes some noImplicitAny errors to be lost. - return parameterIndex >= getMinArgumentCount(signature, 1 /* StrongArityForUntypedJS */ | 2 /* VoidIsNonOptional */); + return parameterIndex >= getMinArgumentCount(signature, 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */ | 2 /* MinArgumentCountFlags.VoidIsNonOptional */); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -59909,7 +60102,7 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 316 /* SyntaxKind.JSDocOptionalType */; } function createTypePredicate(kind, parameterName, parameterIndex, type) { return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; @@ -59958,7 +60151,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -59970,7 +60163,7 @@ var ts; !ts.hasJSDocParameterTags(declaration) && !ts.getJSDocType(declaration); if (isUntypedSignatureInJSFile) { - flags |= 32 /* IsUntypedSignatureInJSFile */; + flags |= 32 /* SignatureFlags.IsUntypedSignatureInJSFile */; } // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -59980,19 +60173,19 @@ var ts; var paramSymbol = param.symbol; var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type; // Include parameter symbol instead of property symbol in the signature - if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* Value */, undefined, undefined, /*isUse*/ false); + if (paramSymbol && !!(paramSymbol.flags & 4 /* SymbolFlags.Property */) && !ts.isBindingPattern(param.name)) { + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } - if (i === 0 && paramSymbol.escapedName === "this" /* This */) { + if (i === 0 && paramSymbol.escapedName === "this" /* InternalSymbolName.This */) { hasThisParameter = true; thisParameter = param.symbol; } else { parameters.push(paramSymbol); } - if (type && type.kind === 196 /* LiteralType */) { - flags |= 2 /* HasLiteralTypes */; + if (type && type.kind === 196 /* SyntaxKind.LiteralType */) { + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) || @@ -60004,25 +60197,25 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 172 /* GetAccessor */ || declaration.kind === 173 /* SetAccessor */) && + if ((declaration.kind === 172 /* SyntaxKind.GetAccessor */ || declaration.kind === 173 /* SyntaxKind.SetAccessor */) && hasBindableName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + var otherKind = declaration.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 171 /* Constructor */ ? + var classType = declaration.kind === 171 /* SyntaxKind.Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } - if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* Abstract */) || - ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* Abstract */)) { - flags |= 4 /* Abstract */; + if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128 /* ModifierFlags.Abstract */) || + ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128 /* ModifierFlags.Abstract */)) { + flags |= 4 /* SignatureFlags.Abstract */; } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); @@ -60044,7 +60237,7 @@ var ts; var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) { return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined; }); - var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */); + var syntheticArgsSymbol = createSymbol(3 /* SymbolFlags.Variable */, "args", 32768 /* CheckFlags.RestParameter */); if (lastParamVariadicType) { // Parameter has effective annotation, lock in type syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)); @@ -60053,7 +60246,7 @@ var ts; // Parameter has no annotation // By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been // cached by `getTypeOfSymbol` yet. - syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */; + syntheticArgsSymbol.checkFlags |= 65536 /* CheckFlags.DeferredType */; syntheticArgsSymbol.deferralParent = neverType; syntheticArgsSymbol.deferralConstituents = [anyArrayType]; syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType]; @@ -60086,7 +60279,7 @@ var ts; function containsArgumentsReference(declaration) { var links = getNodeLinks(declaration); if (links.containsArgumentsReference === undefined) { - if (links.flags & 8192 /* CaptureArguments */) { + if (links.flags & 8192 /* NodeCheckFlags.CaptureArguments */) { links.containsArgumentsReference = true; } else { @@ -60098,18 +60291,18 @@ var ts; if (!node) return false; switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node.escapedText === argumentsSymbol.escapedName && getReferencedValueSymbol(node) === argumentsSymbol; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - return node.name.kind === 162 /* ComputedPropertyName */ + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + return node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ && traverse(node.name); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return traverse(node.expression); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return traverse(node.initializer); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -60181,26 +60374,26 @@ var ts; function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; var type = node.type && getTypeFromTypeNode(node.type); - return parameterName.kind === 192 /* ThisType */ ? - createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : - createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); + return parameterName.kind === 192 /* SyntaxKind.ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* TypePredicateKind.AssertsThis */ : 0 /* TypePredicateKind.This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* TypePredicateKind.AssertsIdentifier */ : 1 /* TypePredicateKind.Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getUnionOrIntersectionType(types, kind, unionReduction) { - return kind !== 2097152 /* Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); + return kind !== 2097152 /* TypeFlags.Intersection */ ? getUnionType(types, unionReduction) : getIntersectionType(types); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { - if (!pushTypeResolution(signature, 3 /* ResolvedReturnType */)) { + if (!pushTypeResolution(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */)) { return errorType; } var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : - signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* Subtype */), signature.mapper) : + signature.compositeSignatures ? instantiateType(getUnionOrIntersectionType(ts.map(signature.compositeSignatures, getReturnTypeOfSignature), signature.compositeKind, 2 /* UnionReduction.Subtype */), signature.mapper) : getReturnTypeFromAnnotation(signature.declaration) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); - if (signature.flags & 8 /* IsInnerCallChain */) { + if (signature.flags & 8 /* SignatureFlags.IsInnerCallChain */) { type = addOptionalTypeMarker(type); } - else if (signature.flags & 16 /* IsOuterCallChain */) { + else if (signature.flags & 16 /* SignatureFlags.IsOuterCallChain */) { type = getOptionalType(type); } if (!popTypeResolution()) { @@ -60227,7 +60420,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 171 /* Constructor */) { + if (declaration.kind === 171 /* SyntaxKind.Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -60237,12 +60430,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 172 /* GetAccessor */ && hasBindableName(declaration)) { + if (declaration.kind === 172 /* SyntaxKind.GetAccessor */ && hasBindableName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 173 /* SyntaxKind.SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -60251,7 +60444,7 @@ var ts; return getReturnTypeOfTypeTag(declaration); } function isResolvingReturnTypeOfSignature(signature) { - return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* ResolvedReturnType */) >= 0; + return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3 /* TypeSystemPropertyName.ResolvedReturnType */) >= 0; } function getRestTypeOfSignature(signature) { return tryGetRestTypeOfSignature(signature) || anyType; @@ -60345,8 +60538,8 @@ var ts; if (!signature.isolatedSignatureType) { var kind = (_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind; // If declaration is undefined, it is likely to be the signature of the default constructor. - var isConstructor = kind === undefined || kind === 171 /* Constructor */ || kind === 175 /* ConstructSignature */ || kind === 180 /* ConstructorType */; - var type = createObjectType(16 /* Anonymous */); + var isConstructor = kind === undefined || kind === 171 /* SyntaxKind.Constructor */ || kind === 175 /* SyntaxKind.ConstructSignature */ || kind === 180 /* SyntaxKind.ConstructorType */; + var type = createObjectType(16 /* ObjectFlags.Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; type.callSignatures = !isConstructor ? [signature] : ts.emptyArray; @@ -60360,7 +60553,7 @@ var ts; return symbol.members ? getIndexSymbolFromSymbolTable(symbol.members) : undefined; } function getIndexSymbolFromSymbolTable(symbolTable) { - return symbolTable.get("__index" /* Index */); + return symbolTable.get("__index" /* InternalSymbolName.Index */); } function createIndexInfo(keyType, type, isReadonly, declaration) { return { keyType: keyType, type: type, isReadonly: isReadonly, declaration: declaration }; @@ -60378,7 +60571,7 @@ var ts; if (parameter.type) { forEachType(getTypeFromTypeNode(parameter.type), function (keyType) { if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) { - indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration)); + indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* ModifierFlags.Readonly */), declaration)); } }); } @@ -60393,8 +60586,8 @@ var ts; return ts.emptyArray; } function isValidIndexKeyType(type) { - return !!(type.flags & (4 /* String */ | 8 /* Number */ | 4096 /* ESSymbol */)) || isPatternLiteralType(type) || - !!(type.flags & 2097152 /* Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); + return !!(type.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 4096 /* TypeFlags.ESSymbol */)) || isPatternLiteralType(type) || + !!(type.flags & 2097152 /* TypeFlags.Intersection */) && !isGenericType(type) && ts.some(type.types, isValidIndexKeyType); } function getConstraintDeclaration(type) { return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0]; @@ -60403,21 +60596,20 @@ var ts; var _a; var inferences; if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) { - for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { - var declaration = _b[_i]; - if (declaration.parent.kind === 190 /* InferType */) { + var _loop_15 = function (declaration) { + if (declaration.parent.kind === 190 /* SyntaxKind.InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1]; - if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) { - var typeReference = grandParent; - var typeParameters = getTypeParametersForTypeReference(typeReference); - if (typeParameters) { - var index = typeReference.typeArguments.indexOf(childTypeParameter); - if (index < typeParameters.length) { - var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]); + if (grandParent.kind === 178 /* SyntaxKind.TypeReference */ && !omitTypeReferences) { + var typeReference_1 = grandParent; + var typeParameters_1 = getTypeParametersForTypeReference(typeReference_1); + if (typeParameters_1) { + var index = typeReference_1.typeArguments.indexOf(childTypeParameter); + if (index < typeParameters_1.length) { + var declaredConstraint = getConstraintOfTypeParameter(typeParameters_1[index]); if (declaredConstraint) { // Type parameter constraints can reference other type parameters so // constraints need to be instantiated. If instantiation produces the @@ -60425,7 +60617,9 @@ var ts; // type Foo = [T, U]; // type Bar = T extends Foo ? Foo : T; // the instantiated constraint for U is X, so we discard that inference. - var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters)); + var mapper = makeDeferredTypeMapper(typeParameters_1, typeParameters_1.map(function (_, index) { return function () { + return getEffectiveTypeArgumentAtIndex(typeReference_1, typeParameters_1, index); + }; })); var constraint = instantiateType(declaredConstraint, mapper); if (constraint !== typeParameter) { inferences = ts.append(inferences, constraint); @@ -60436,33 +60630,37 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter declaration, a rest type // or a named rest tuple element, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 164 /* Parameter */ && grandParent.dotDotDotToken || - grandParent.kind === 186 /* RestType */ || - grandParent.kind === 197 /* NamedTupleMember */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 164 /* SyntaxKind.Parameter */ && grandParent.dotDotDotToken || + grandParent.kind === 186 /* SyntaxKind.RestType */ || + grandParent.kind === 197 /* SyntaxKind.NamedTupleMember */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } // When an 'infer T' declaration is immediately contained in a string template type, we infer a 'string' // constraint. - else if (grandParent.kind === 199 /* TemplateLiteralTypeSpan */) { + else if (grandParent.kind === 199 /* SyntaxKind.TemplateLiteralTypeSpan */) { inferences = ts.append(inferences, stringType); } // When an 'infer T' declaration is in the constraint position of a mapped type, we infer a 'keyof any' // constraint. - else if (grandParent.kind === 163 /* TypeParameter */ && grandParent.parent.kind === 195 /* MappedType */) { + else if (grandParent.kind === 163 /* SyntaxKind.TypeParameter */ && grandParent.parent.kind === 195 /* SyntaxKind.MappedType */) { inferences = ts.append(inferences, keyofConstraintType); } // When an 'infer T' declaration is the template of a mapped type, and that mapped type is the extends // clause of a conditional whose check type is also a mapped type, give it a constraint equal to the template // of the check type's mapped type - else if (grandParent.kind === 195 /* MappedType */ && grandParent.type && - ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* ConditionalType */ && - grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* MappedType */ && + else if (grandParent.kind === 195 /* SyntaxKind.MappedType */ && grandParent.type && + ts.skipParentheses(grandParent.type) === declaration.parent && grandParent.parent.kind === 189 /* SyntaxKind.ConditionalType */ && + grandParent.parent.extendsType === grandParent && grandParent.parent.checkType.kind === 195 /* SyntaxKind.MappedType */ && grandParent.parent.checkType.type) { var checkMappedType_1 = grandParent.parent.checkType; var nodeType = getTypeFromTypeNode(checkMappedType_1.type); inferences = ts.append(inferences, instantiateType(nodeType, makeUnaryTypeMapper(getDeclaredTypeOfTypeParameter(getSymbolOfNode(checkMappedType_1.typeParameter)), checkMappedType_1.typeParameter.constraint ? getTypeFromTypeNode(checkMappedType_1.typeParameter.constraint) : keyofConstraintType))); } } + }; + for (var _i = 0, _b = typeParameter.symbol.declarations; _i < _b.length; _i++) { + var declaration = _b[_i]; + _loop_15(declaration); } } return inferences && getIntersectionType(inferences); @@ -60481,10 +60679,10 @@ var ts; } else { var type = getTypeFromTypeNode(constraintDeclaration); - if (type.flags & 1 /* Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed + if (type.flags & 1 /* TypeFlags.Any */ && !isErrorType(type)) { // Allow errorType to propegate to keep downstream errors suppressed // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), // use unknown otherwise - type = constraintDeclaration.parent.parent.kind === 195 /* MappedType */ ? keyofConstraintType : unknownType; + type = constraintDeclaration.parent.parent.kind === 195 /* SyntaxKind.MappedType */ ? keyofConstraintType : unknownType; } typeParameter.constraint = type; } @@ -60493,7 +60691,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 163 /* SyntaxKind.TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getEffectiveContainerForJSDocTemplateTag(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -60521,29 +60719,29 @@ var ts; return result; } function getAliasId(aliasSymbol, aliasTypeArguments) { - return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : ""; + return aliasSymbol ? "@".concat(getSymbolId(aliasSymbol)) + (aliasTypeArguments ? ":".concat(getTypeListId(aliasTypeArguments)) : "") : ""; } // This function is used to propagate certain flags when creating new object type references and union types. // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type - // of an object literal or the anyFunctionType. This is because there are operations in the type checker + // of an object literal or a non-inferrable type. This is because there are operations in the type checker // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { var type = types_8[_i]; - if (!(type.flags & excludeKinds)) { + if (excludeKinds === undefined || !(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } } - return result & 458752 /* PropagatingFlags */; + return result & 458752 /* ObjectFlags.PropagatingFlags */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); var type = target.instantiations.get(id); if (!type) { - type = createObjectType(4 /* Reference */, target.symbol); + type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); target.instantiations.set(id, type); - type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; + type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments) : 0; type.target = target; type.resolvedTypeArguments = typeArguments; } @@ -60563,7 +60761,7 @@ var ts; var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments; } - var type = createObjectType(4 /* Reference */, target.symbol); + var type = createObjectType(4 /* ObjectFlags.Reference */, target.symbol); type.target = target; type.node = node; type.mapper = mapper; @@ -60574,13 +60772,13 @@ var ts; function getTypeArguments(type) { var _a, _b; if (!type.resolvedTypeArguments) { - if (!pushTypeResolution(type, 6 /* ResolvedTypeArguments */)) { + if (!pushTypeResolution(type, 6 /* TypeSystemPropertyName.ResolvedTypeArguments */)) { return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; } var node = type.node; var typeArguments = !node ? ts.emptyArray : - node.kind === 178 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : - node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + node.kind === 178 /* SyntaxKind.TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); if (popTypeResolution()) { type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; @@ -60615,14 +60813,14 @@ var ts; missingAugmentsTag ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; - var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); + var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* TypeFormatFlags.WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { // TODO: Adopt same permissive behavior in TS as in JS to reduce follow-on editing experience failures (requires editing fillMissingTypeArguments) return errorType; } } - if (node.kind === 178 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -60653,12 +60851,12 @@ var ts; * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ function getTypeFromTypeAliasReference(node, symbol) { - if (ts.getCheckFlags(symbol) & 1048576 /* Unresolved */) { + if (ts.getCheckFlags(symbol) & 1048576 /* CheckFlags.Unresolved */) { var typeArguments = typeArgumentsFromTypeReferenceNode(node); var id = getAliasId(symbol, typeArguments); var errorType_1 = errorTypes.get(id); if (!errorType_1) { - errorType_1 = createIntrinsicType(1 /* Any */, "error"); + errorType_1 = createIntrinsicType(1 /* TypeFlags.Any */, "error"); errorType_1.aliasSymbol = symbol; errorType_1.aliasTypeArguments = typeArguments; errorTypes.set(id, errorType_1); @@ -60693,9 +60891,9 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -60707,21 +60905,21 @@ var ts; return undefined; } function getSymbolPath(symbol) { - return symbol.parent ? getSymbolPath(symbol.parent) + "." + symbol.escapedName : symbol.escapedName; + return symbol.parent ? "".concat(getSymbolPath(symbol.parent), ".").concat(symbol.escapedName) : symbol.escapedName; } function getUnresolvedSymbolForEntityName(name) { - var identifier = name.kind === 161 /* QualifiedName */ ? name.right : - name.kind === 206 /* PropertyAccessExpression */ ? name.name : + var identifier = name.kind === 161 /* SyntaxKind.QualifiedName */ ? name.right : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? name.name : name; var text = identifier.escapedText; if (text) { - var parentSymbol = name.kind === 161 /* QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : - name.kind === 206 /* PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : + var parentSymbol = name.kind === 161 /* SyntaxKind.QualifiedName */ ? getUnresolvedSymbolForEntityName(name.left) : + name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? getUnresolvedSymbolForEntityName(name.expression) : undefined; - var path = parentSymbol ? getSymbolPath(parentSymbol) + "." + text : text; + var path = parentSymbol ? "".concat(getSymbolPath(parentSymbol), ".").concat(text) : text; var result = unresolvedSymbols.get(path); if (!result) { - unresolvedSymbols.set(path, result = createSymbol(524288 /* TypeAlias */, text, 1048576 /* Unresolved */)); + unresolvedSymbols.set(path, result = createSymbol(524288 /* SymbolFlags.TypeAlias */, text, 1048576 /* CheckFlags.Unresolved */)); result.parent = parentSymbol; result.declaredType = unresolvedType; } @@ -60743,10 +60941,10 @@ var ts; return errorType; } symbol = getExpandoSymbol(symbol) || symbol; - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + if (symbol.flags & (32 /* SymbolFlags.Class */ | 64 /* SymbolFlags.Interface */)) { return getTypeFromClassOrInterfaceReference(node, symbol); } - if (symbol.flags & 524288 /* TypeAlias */) { + if (symbol.flags & 524288 /* SymbolFlags.TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) @@ -60754,14 +60952,14 @@ var ts; if (res) { return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType; } - if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + if (symbol.flags & 111551 /* SymbolFlags.Value */ && isJSDocTypeReference(node)) { var jsdocType = getTypeFromJSDocValueReference(node, symbol); if (jsdocType) { return jsdocType; } else { // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(node, 788968 /* Type */); + resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */); return getTypeOfSymbol(symbol); } } @@ -60777,7 +60975,7 @@ var ts; var valueType = getTypeOfSymbol(symbol); var typeType = valueType; if (symbol.valueDeclaration) { - var isImportTypeWithQualifier = node.kind === 200 /* ImportType */ && node.qualifier; + var isImportTypeWithQualifier = node.kind === 200 /* SyntaxKind.ImportType */ && node.qualifier; // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL} if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) { typeType = getTypeReferenceType(node, valueType.symbol); @@ -60788,22 +60986,22 @@ var ts; return links.resolvedJSDocType; } function getSubstitutionType(baseType, substitute) { - if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) { + if (substitute.flags & 3 /* TypeFlags.AnyOrUnknown */ || substitute === baseType) { return baseType; } - var id = getTypeId(baseType) + ">" + getTypeId(substitute); + var id = "".concat(getTypeId(baseType), ">").concat(getTypeId(substitute)); var cached = substitutionTypes.get(id); if (cached) { return cached; } - var result = createType(33554432 /* Substitution */); + var result = createType(33554432 /* TypeFlags.Substitution */); result.baseType = baseType; result.substitute = substitute; substitutionTypes.set(id, result); return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 184 /* TupleType */ && node.elements.length === 1; + return node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 1; } function getImpliedConstraint(type, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) : @@ -60813,16 +61011,16 @@ var ts; function getConditionalFlowTypeOfType(type, node) { var constraints; var covariant = true; - while (node && !ts.isStatement(node) && node.kind !== 320 /* JSDoc */) { + while (node && !ts.isStatement(node) && node.kind !== 320 /* SyntaxKind.JSDoc */) { var parent = node.parent; // only consider variance flipped by parameter locations - `keyof` types would usually be considered variance inverting, but // often get used in indexed accesses where they behave sortof invariantly, but our checking is lax - if (parent.kind === 164 /* Parameter */) { + if (parent.kind === 164 /* SyntaxKind.Parameter */) { covariant = !covariant; } // Always substitute on type parameters, regardless of variance, since even // in contravariant positions, they may rely on substituted constraints to be valid - if ((covariant || type.flags & 8650752 /* TypeVariable */) && parent.kind === 189 /* ConditionalType */ && node === parent.trueType) { + if ((covariant || type.flags & 8650752 /* TypeFlags.TypeVariable */) && parent.kind === 189 /* SyntaxKind.ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -60830,7 +61028,7 @@ var ts; } // Given a homomorphic mapped type { [K in keyof T]: XXX }, where T is constrained to an array or tuple type, in the // template type XXX, K has an added constraint of number | `${number}`. - else if (type.flags & 262144 /* TypeParameter */ && parent.kind === 195 /* MappedType */ && node === parent.type) { + else if (type.flags & 262144 /* TypeFlags.TypeParameter */ && parent.kind === 195 /* SyntaxKind.MappedType */ && node === parent.type) { var mappedType = getTypeFromTypeNode(parent); if (getTypeParameterFromMappedType(mappedType) === getActualTypeVariable(type)) { var typeParameter = getHomomorphicTypeVariable(mappedType); @@ -60847,7 +61045,7 @@ var ts; return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { - return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */); + return !!(node.flags & 8388608 /* NodeFlags.JSDoc */) && (node.kind === 178 /* SyntaxKind.TypeReference */ || node.kind === 200 /* SyntaxKind.ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -60903,7 +61101,7 @@ var ts; } function getTypeFromJSDocNullableTypeNode(node) { var type = getTypeFromTypeNode(node.type); - return strictNullChecks ? getNullableType(type, 65536 /* Null */) : type; + return strictNullChecks ? getNullableType(type, 65536 /* TypeFlags.Null */) : type; } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); @@ -60915,13 +61113,13 @@ var ts; } var symbol = void 0; var type = void 0; - var meaning = 788968 /* Type */; + var meaning = 788968 /* SymbolFlags.Type */; if (isJSDocTypeReference(node)) { type = getIntendedTypeFromJSDocTypeReference(node); if (!type) { symbol = resolveTypeReferenceName(node, meaning, /*ignoreErrors*/ true); if (symbol === unknownSymbol) { - symbol = resolveTypeReferenceName(node, meaning | 111551 /* Value */); + symbol = resolveTypeReferenceName(node, meaning | 111551 /* SymbolFlags.Value */); } else { resolveTypeReferenceName(node, meaning); // Resolve again to mark errors, if any @@ -60962,9 +61160,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 260 /* EnumDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return declaration; } } @@ -60974,7 +61172,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 524288 /* Object */)) { + if (!(type.flags & 524288 /* TypeFlags.Object */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol)); return arity ? emptyGenericType : emptyObjectType; } @@ -60985,13 +61183,13 @@ var ts; return type; } function getGlobalValueSymbol(name, reportErrors) { - return getGlobalSymbol(name, 111551 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); + return getGlobalSymbol(name, 111551 /* SymbolFlags.Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } function getGlobalTypeSymbol(name, reportErrors) { - return getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + return getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalTypeAliasSymbol(name, arity, reportErrors) { - var symbol = getGlobalSymbol(name, 788968 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); if (symbol) { // Resolve the declared type of the symbol. This resolves type parameters for the type // alias so that we can check arity. @@ -61027,9 +61225,9 @@ var ts; function getGlobalImportMetaExpressionType() { if (!deferredGlobalImportMetaExpressionType) { // Create a synthetic type `ImportMetaExpression { meta: MetaProperty }` - var symbol = createSymbol(0 /* None */, "ImportMetaExpression"); + var symbol = createSymbol(0 /* SymbolFlags.None */, "ImportMetaExpression"); var importMetaType = getGlobalImportMetaType(); - var metaPropertySymbol = createSymbol(4 /* Property */, "meta", 8 /* Readonly */); + var metaPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "meta", 8 /* CheckFlags.Readonly */); metaPropertySymbol.parent = symbol; metaPropertySymbol.type = importMetaType; var members = ts.createSymbolTable([metaPropertySymbol]); @@ -61094,7 +61292,7 @@ var ts; } function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - var symbol = getGlobalSymbol(name, 788968 /* Type */, /*diagnostic*/ undefined); + var symbol = getGlobalSymbol(name, 788968 /* SymbolFlags.Type */, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getGlobalExtractSymbol() { @@ -61132,20 +61330,20 @@ var ts; } function getTupleElementFlags(node) { switch (node.kind) { - case 185 /* OptionalType */: - return 2 /* Optional */; - case 186 /* RestType */: + case 185 /* SyntaxKind.OptionalType */: + return 2 /* ElementFlags.Optional */; + case 186 /* SyntaxKind.RestType */: return getRestTypeElementFlags(node); - case 197 /* NamedTupleMember */: - return node.questionToken ? 2 /* Optional */ : + case 197 /* SyntaxKind.NamedTupleMember */: + return node.questionToken ? 2 /* ElementFlags.Optional */ : node.dotDotDotToken ? getRestTypeElementFlags(node) : - 1 /* Required */; + 1 /* ElementFlags.Required */; default: - return 1 /* Required */; + return 1 /* ElementFlags.Required */; } } function getRestTypeElementFlags(node) { - return getArrayElementTypeNode(node.type) ? 4 /* Rest */ : 8 /* Variadic */; + return getArrayElementTypeNode(node.type) ? 4 /* ElementFlags.Rest */ : 8 /* ElementFlags.Variadic */; } function getArrayOrTupleTargetType(node) { var readonly = isReadonlyTypeOperator(node.parent); @@ -61154,14 +61352,14 @@ var ts; return readonly ? globalReadonlyArrayType : globalArrayType; } var elementFlags = ts.map(node.elements, getTupleElementFlags); - var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* NamedTupleMember */; }); + var missingName = ts.some(node.elements, function (e) { return e.kind !== 197 /* SyntaxKind.NamedTupleMember */; }); return getTupleTargetType(elementFlags, readonly, /*associatedNames*/ missingName ? undefined : node.elements); } // Return true if the given type reference node is directly aliased or if it needs to be deferred // because it is possibly contained in a circular chain of eagerly resolved types. function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { - return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : - node.kind === 184 /* TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 183 /* SyntaxKind.ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 184 /* SyntaxKind.TupleType */ ? ts.some(node.elements, mayResolveTypeAlias) : hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); } // Return true when the given node is transitively contained in type constructs that eagerly @@ -61170,18 +61368,18 @@ var ts; function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 194 /* IndexedAccessType */: - case 189 /* ConditionalType */: - case 193 /* TypeOperator */: - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 189 /* SyntaxKind.ConditionalType */: + case 193 /* SyntaxKind.TypeOperator */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return isResolvedByTypeAlias(parent); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; } return false; @@ -61190,28 +61388,28 @@ var ts; // of a type alias. function mayResolveTypeAlias(node) { switch (node.kind) { - case 178 /* TypeReference */: - return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* Type */).flags & 524288 /* TypeAlias */); - case 181 /* TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node, 788968 /* SymbolFlags.Type */).flags & 524288 /* SymbolFlags.TypeAlias */); + case 181 /* SyntaxKind.TypeQuery */: return true; - case 193 /* TypeOperator */: - return node.operator !== 154 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 197 /* NamedTupleMember */: - case 316 /* JSDocOptionalType */: - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 193 /* SyntaxKind.TypeOperator */: + return node.operator !== 154 /* SyntaxKind.UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 197 /* SyntaxKind.NamedTupleMember */: + case 316 /* SyntaxKind.JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return mayResolveTypeAlias(node.type); - case 186 /* RestType */: - return node.type.kind !== 183 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 186 /* SyntaxKind.RestType */: + return node.type.kind !== 183 /* SyntaxKind.ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return ts.some(node.types, mayResolveTypeAlias); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); } @@ -61224,33 +61422,33 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (!(node.kind === 184 /* TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* Variadic */); })) && isDeferredTypeReferenceNode(node)) { - links.resolvedType = node.kind === 184 /* TupleType */ && node.elements.length === 0 ? target : + else if (!(node.kind === 184 /* SyntaxKind.TupleType */ && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8 /* ElementFlags.Variadic */); })) && isDeferredTypeReferenceNode(node)) { + links.resolvedType = node.kind === 184 /* SyntaxKind.TupleType */ && node.elements.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } else { - var elementTypes = node.kind === 183 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); + var elementTypes = node.kind === 183 /* SyntaxKind.ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode); links.resolvedType = createNormalizedTypeReference(target, elementTypes); } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 145 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 145 /* SyntaxKind.ReadonlyKeyword */; } function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) { if (readonly === void 0) { readonly = false; } - var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* Required */; }), readonly, namedMemberDeclarations); + var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1 /* ElementFlags.Required */; }), readonly, namedMemberDeclarations); return tupleTarget === emptyGenericType ? emptyObjectType : elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) : tupleTarget; } function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { - if (elementFlags.length === 1 && elementFlags[0] & 4 /* Rest */) { + if (elementFlags.length === 1 && elementFlags[0] & 4 /* ElementFlags.Rest */) { // [...X[]] is equivalent to just X[] return readonly ? globalReadonlyArrayType : globalArrayType; } - var key = ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? "#" : f & 2 /* Optional */ ? "?" : f & 4 /* Rest */ ? "." : "*"; }).join() + + var key = ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? "#" : f & 2 /* ElementFlags.Optional */ ? "?" : f & 4 /* ElementFlags.Rest */ ? "." : "*"; }).join() + (readonly ? "R" : "") + (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : ""); var type = tupleTypes.get(key); @@ -61268,7 +61466,7 @@ var ts; // is true for each of the synthesized type parameters. function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) { var arity = elementFlags.length; - var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* Required */ | 8 /* Variadic */)); }); + var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 /* ElementFlags.Required */ | 8 /* ElementFlags.Variadic */)); }); var typeParameters; var properties = []; var combinedFlags = 0; @@ -61278,8 +61476,8 @@ var ts; var typeParameter = typeParameters[i] = createTypeParameter(); var flags = elementFlags[i]; combinedFlags |= flags; - if (!(combinedFlags & 12 /* Variable */)) { - var property = createSymbol(4 /* Property */ | (flags & 2 /* Optional */ ? 16777216 /* Optional */ : 0), "" + i, readonly ? 8 /* Readonly */ : 0); + if (!(combinedFlags & 12 /* ElementFlags.Variable */)) { + var property = createSymbol(4 /* SymbolFlags.Property */ | (flags & 2 /* ElementFlags.Optional */ ? 16777216 /* SymbolFlags.Optional */ : 0), "" + i, readonly ? 8 /* CheckFlags.Readonly */ : 0); property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i]; property.type = typeParameter; properties.push(property); @@ -61287,8 +61485,8 @@ var ts; } } var fixedLength = properties.length; - var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0); - if (combinedFlags & 12 /* Variable */) { + var lengthSymbol = createSymbol(4 /* SymbolFlags.Property */, "length", readonly ? 8 /* CheckFlags.Readonly */ : 0); + if (combinedFlags & 12 /* ElementFlags.Variable */) { lengthSymbol.type = numberType; } else { @@ -61298,7 +61496,7 @@ var ts; lengthSymbol.type = getUnionType(literalTypes); } properties.push(lengthSymbol); - var type = createObjectType(8 /* Tuple */ | 4 /* Reference */); + var type = createObjectType(8 /* ObjectFlags.Tuple */ | 4 /* ObjectFlags.Reference */); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -61316,26 +61514,26 @@ var ts; type.elementFlags = elementFlags; type.minLength = minLength; type.fixedLength = fixedLength; - type.hasRestElement = !!(combinedFlags & 12 /* Variable */); + type.hasRestElement = !!(combinedFlags & 12 /* ElementFlags.Variable */); type.combinedFlags = combinedFlags; type.readonly = readonly; type.labeledElementDeclarations = namedMemberDeclarations; return type; } function createNormalizedTypeReference(target, typeArguments) { - return target.objectFlags & 8 /* Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); + return target.objectFlags & 8 /* ObjectFlags.Tuple */ ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments); } function createNormalizedTupleType(target, elementTypes) { var _a, _b, _c; - if (!(target.combinedFlags & 14 /* NonRequired */)) { + if (!(target.combinedFlags & 14 /* ElementFlags.NonRequired */)) { // No need to normalize when we only have regular required elements return createTypeReference(target, elementTypes); } - if (target.combinedFlags & 8 /* Variadic */) { + if (target.combinedFlags & 8 /* ElementFlags.Variadic */) { // Transform [A, ...(X | Y | Z)] into [A, ...X] | [A, ...Y] | [A, ...Z] - var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* Variadic */ && t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 /* ElementFlags.Variadic */ && t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex_1 >= 0) { - return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* Variadic */ ? t : unknownType; })) ? + return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : unknownType; })) ? mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) : errorType; } @@ -61351,13 +61549,13 @@ var ts; var lastRequiredIndex = -1; var firstRestIndex = -1; var lastOptionalOrRestIndex = -1; - var _loop_15 = function (i) { + var _loop_16 = function (i) { var type = elementTypes[i]; var flags = target.elementFlags[i]; - if (flags & 8 /* Variadic */) { - if (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type)) { + if (flags & 8 /* ElementFlags.Variadic */) { + if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type)) { // Generic variadic elements stay as they are. - addElement(type, 8 /* Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + addElement(type, 8 /* ElementFlags.Variadic */, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); } else if (isTupleType(type)) { var elements = getTypeArguments(type); @@ -61372,7 +61570,7 @@ var ts; } else { // Treat everything else as an array type and create a rest element. - addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); + addElement(isArrayLikeType(type) && getIndexTypeOfType(type, numberType) || errorType, 4 /* ElementFlags.Rest */, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]); } } else { @@ -61381,18 +61579,18 @@ var ts; } }; for (var i = 0; i < elementTypes.length; i++) { - var state_4 = _loop_15(i); + var state_4 = _loop_16(i); if (typeof state_4 === "object") return state_4.value; } // Turn optional elements preceding the last required element into required elements for (var i = 0; i < lastRequiredIndex; i++) { - if (expandedFlags[i] & 2 /* Optional */) - expandedFlags[i] = 1 /* Required */; + if (expandedFlags[i] & 2 /* ElementFlags.Optional */) + expandedFlags[i] = 1 /* ElementFlags.Required */; } if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) { // Turn elements between first rest and last optional/rest into a single rest element - expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t; })); + expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t; })); expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex); @@ -61402,13 +61600,13 @@ var ts; expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) : tupleTarget; function addElement(type, flags, declaration) { - if (flags & 1 /* Required */) { + if (flags & 1 /* ElementFlags.Required */) { lastRequiredIndex = expandedFlags.length; } - if (flags & 4 /* Rest */ && firstRestIndex < 0) { + if (flags & 4 /* ElementFlags.Rest */ && firstRestIndex < 0) { firstRestIndex = expandedFlags.length; } - if (flags & (2 /* Optional */ | 4 /* Rest */)) { + if (flags & (2 /* ElementFlags.Optional */ | 4 /* ElementFlags.Rest */)) { lastOptionalOrRestIndex = expandedFlags.length; } expandedTypes.push(type); @@ -61460,19 +61658,19 @@ var ts; } function addTypeToUnion(typeSet, includes, type) { var flags = type.flags; - if (flags & 1048576 /* Union */) { - return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* Union */ : 0), type.types); + if (flags & 1048576 /* TypeFlags.Union */) { + return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 /* TypeFlags.Union */ : 0), type.types); } // We ignore 'never' types in unions - if (!(flags & 131072 /* Never */)) { - includes |= flags & 205258751 /* IncludesMask */; - if (flags & 465829888 /* Instantiable */) - includes |= 33554432 /* IncludesInstantiable */; + if (!(flags & 131072 /* TypeFlags.Never */)) { + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; + if (flags & 465829888 /* TypeFlags.Instantiable */) + includes |= 33554432 /* TypeFlags.IncludesInstantiable */; if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; - if (!strictNullChecks && flags & 98304 /* Nullable */) { - if (!(ts.getObjectFlags(type) & 65536 /* ContainsWideningType */)) - includes |= 4194304 /* IncludesNonWideningType */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; + if (!strictNullChecks && flags & 98304 /* TypeFlags.Nullable */) { + if (!(ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */)) + includes |= 4194304 /* TypeFlags.IncludesNonWideningType */; } else { var len = typeSet.length; @@ -61506,18 +61704,18 @@ var ts; // We assume that redundant primitive types have already been removed from the types array and that there // are no any and unknown types in the array. Thus, the only possible supertypes for primitive types are empty // object types, and if none of those are present we can exclude primitive types from the subtype check. - var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); + var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); }); var len = types.length; var i = len; var count = 0; while (i > 0) { i--; var source = types[i]; - if (hasEmptyObject || source.flags & 469499904 /* StructuredOrInstantiable */) { + if (hasEmptyObject || source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { // Find the first property with a unit type, if any. When constituents have a property by the same name // but of a different unit type, we can quickly disqualify them from subtype checks. This helps subtype // reduction of large discriminated union types. - var keyProperty = source.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */) ? + var keyProperty = source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.find(getPropertiesOfType(source), function (p) { return isUnitType(getTypeOfSymbol(p)); }) : undefined; var keyPropertyType = keyProperty && getRegularTypeOfLiteralType(getTypeOfSymbol(keyProperty)); @@ -61531,20 +61729,20 @@ var ts; // caps union types at 1000 unique object types. var estimatedCount = (count / (len - i)) * len; if (estimatedCount > 1000000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return undefined; } } count++; - if (keyProperty && target.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + if (keyProperty && target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var t = getTypeOfPropertyOfType(target, keyProperty.escapedName); if (t && isUnitType(t) && getRegularTypeOfLiteralType(t) !== keyPropertyType) { continue; } } - if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* Class */) || - !(ts.getObjectFlags(getTargetType(target)) & 1 /* Class */) || + if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1 /* ObjectFlags.Class */) || + !(ts.getObjectFlags(getTargetType(target)) & 1 /* ObjectFlags.Class */) || isTypeDerivedFrom(source, target))) { ts.orderedRemoveItemAt(types, i); break; @@ -61562,11 +61760,11 @@ var ts; i--; var t = types[i]; var flags = t.flags; - var remove = flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && includes & 4 /* String */ || - flags & 256 /* NumberLiteral */ && includes & 8 /* Number */ || - flags & 2048 /* BigIntLiteral */ && includes & 64 /* BigInt */ || - flags & 8192 /* UniqueESSymbol */ && includes & 4096 /* ESSymbol */ || - reduceVoidUndefined && flags & 32768 /* Undefined */ && includes & 16384 /* Void */ || + var remove = flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && includes & 4 /* TypeFlags.String */ || + flags & 256 /* TypeFlags.NumberLiteral */ && includes & 8 /* TypeFlags.Number */ || + flags & 2048 /* TypeFlags.BigIntLiteral */ && includes & 64 /* TypeFlags.BigInt */ || + flags & 8192 /* TypeFlags.UniqueESSymbol */ && includes & 4096 /* TypeFlags.ESSymbol */ || + reduceVoidUndefined && flags & 32768 /* TypeFlags.Undefined */ && includes & 16384 /* TypeFlags.Void */ || isFreshLiteralType(t) && containsType(types, t.regularType); if (remove) { ts.orderedRemoveItemAt(types, i); @@ -61577,30 +61775,30 @@ var ts; var templates = ts.filter(types, isPatternLiteralType); if (templates.length) { var i = types.length; - var _loop_16 = function () { + var _loop_17 = function () { i--; var t = types[i]; - if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { + if (t.flags & 128 /* TypeFlags.StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) { ts.orderedRemoveItemAt(types, i); } }; while (i > 0) { - _loop_16(); + _loop_17(); } } } function isNamedUnionType(type) { - return !!(type.flags & 1048576 /* Union */ && (type.aliasSymbol || type.origin)); + return !!(type.flags & 1048576 /* TypeFlags.Union */ && (type.aliasSymbol || type.origin)); } function addNamedUnions(namedUnions, types) { for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { var t = types_11[_i]; - if (t.flags & 1048576 /* Union */) { + if (t.flags & 1048576 /* TypeFlags.Union */) { var origin = t.origin; - if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* Union */)) { + if (t.aliasSymbol || origin && !(origin.flags & 1048576 /* TypeFlags.Union */)) { ts.pushIfUnique(namedUnions, t); } - else if (origin && origin.flags & 1048576 /* Union */) { + else if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { addNamedUnions(namedUnions, origin.types); } } @@ -61619,7 +61817,7 @@ var ts; // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) { - if (unionReduction === void 0) { unionReduction = 1 /* Literal */; } + if (unionReduction === void 0) { unionReduction = 1 /* UnionReduction.Literal */; } if (types.length === 0) { return neverType; } @@ -61628,48 +61826,48 @@ var ts; } var typeSet = []; var includes = addTypesToUnion(typeSet, 0, types); - if (unionReduction !== 0 /* None */) { - if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? - includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : - includes & 65536 /* Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; + if (unionReduction !== 0 /* UnionReduction.None */) { + if (includes & 3 /* TypeFlags.AnyOrUnknown */) { + return includes & 1 /* TypeFlags.Any */ ? + includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType : + includes & 65536 /* TypeFlags.Null */ || containsType(typeSet, unknownType) ? unknownType : nonNullUnknownType; } - if (exactOptionalPropertyTypes && includes & 32768 /* Undefined */) { + if (exactOptionalPropertyTypes && includes & 32768 /* TypeFlags.Undefined */) { var missingIndex = ts.binarySearch(typeSet, missingType, getTypeId, ts.compareValues); if (missingIndex >= 0 && containsType(typeSet, undefinedType)) { ts.orderedRemoveItemAt(typeSet, missingIndex); } } - if (includes & (2944 /* Literal */ | 8192 /* UniqueESSymbol */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || includes & 16384 /* Void */ && includes & 32768 /* Undefined */) { - removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* Subtype */)); + if (includes & (2944 /* TypeFlags.Literal */ | 8192 /* TypeFlags.UniqueESSymbol */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */) { + removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2 /* UnionReduction.Subtype */)); } - if (includes & 128 /* StringLiteral */ && includes & 134217728 /* TemplateLiteral */) { + if (includes & 128 /* TypeFlags.StringLiteral */ && includes & 134217728 /* TypeFlags.TemplateLiteral */) { removeStringLiteralsMatchedByTemplateLiterals(typeSet); } - if (unionReduction === 2 /* Subtype */) { - typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* Object */)); + if (unionReduction === 2 /* UnionReduction.Subtype */) { + typeSet = removeSubtypes(typeSet, !!(includes & 524288 /* TypeFlags.Object */)); if (!typeSet) { return errorType; } } if (typeSet.length === 0) { - return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : - includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 65536 /* TypeFlags.Null */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* TypeFlags.Undefined */ ? includes & 4194304 /* TypeFlags.IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType; } } - if (!origin && includes & 1048576 /* Union */) { + if (!origin && includes & 1048576 /* TypeFlags.Union */) { var namedUnions = []; addNamedUnions(namedUnions, types); var reducedTypes = []; - var _loop_17 = function (t) { + var _loop_18 = function (t) { if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) { reducedTypes.push(t); } }; for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) { var t = typeSet_1[_i]; - _loop_17(t); + _loop_18(t); } if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) { return namedUnions[0]; @@ -61682,11 +61880,11 @@ var ts; var t = namedUnions_1[_a]; insertType(reducedTypes, t); } - origin = createOriginUnionOrIntersectionType(1048576 /* Union */, reducedTypes); + origin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, reducedTypes); } } - var objectFlags = (includes & 36323363 /* NotPrimitiveUnion */ ? 0 : 32768 /* PrimitiveUnion */) | - (includes & 2097152 /* Intersection */ ? 16777216 /* ContainsIntersections */ : 0); + var objectFlags = (includes & 36323363 /* TypeFlags.NotPrimitiveUnion */ ? 0 : 32768 /* ObjectFlags.PrimitiveUnion */) | + (includes & 2097152 /* TypeFlags.Intersection */ ? 16777216 /* ObjectFlags.ContainsIntersections */ : 0); return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin); } function getUnionOrIntersectionTypePredicate(signatures, kind) { @@ -61695,8 +61893,8 @@ var ts; for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { var sig = signatures_6[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { - if (kind !== 2097152 /* Intersection */) { + if (!pred || pred.kind === 2 /* TypePredicateKind.AssertsThis */ || pred.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { + if (kind !== 2097152 /* TypeFlags.Intersection */) { continue; } else { @@ -61733,20 +61931,20 @@ var ts; return types[0]; } var typeKey = !origin ? getTypeListId(types) : - origin.flags & 1048576 /* Union */ ? "|" + getTypeListId(origin.types) : - origin.flags & 2097152 /* Intersection */ ? "&" + getTypeListId(origin.types) : - "#" + origin.type.id + "|" + getTypeListId(types); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving + origin.flags & 1048576 /* TypeFlags.Union */ ? "|".concat(getTypeListId(origin.types)) : + origin.flags & 2097152 /* TypeFlags.Intersection */ ? "&".concat(getTypeListId(origin.types)) : + "#".concat(origin.type.id, "|").concat(getTypeListId(types)); // origin type id alone is insufficient, as `keyof x` may resolve to multiple WIP values while `x` is still resolving var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments); var type = unionTypes.get(id); if (!type) { - type = createType(1048576 /* Union */); - type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + type = createType(1048576 /* TypeFlags.Union */); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); type.types = types; type.origin = origin; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; - if (types.length === 2 && types[0].flags & 512 /* BooleanLiteral */ && types[1].flags & 512 /* BooleanLiteral */) { - type.flags |= 16 /* Boolean */; + if (types.length === 2 && types[0].flags & 512 /* TypeFlags.BooleanLiteral */ && types[1].flags & 512 /* TypeFlags.BooleanLiteral */) { + type.flags |= 16 /* TypeFlags.Boolean */; type.intrinsicName = "boolean"; } unionTypes.set(id, type); @@ -61757,41 +61955,41 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); - links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); + links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1 /* UnionReduction.Literal */, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol)); } return links.resolvedType; } function addTypeToIntersection(typeSet, includes, type) { var flags = type.flags; - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return addTypesToIntersection(typeSet, includes, type.types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & 16777216 /* IncludesEmptyObject */)) { - includes |= 16777216 /* IncludesEmptyObject */; + if (!(includes & 16777216 /* TypeFlags.IncludesEmptyObject */)) { + includes |= 16777216 /* TypeFlags.IncludesEmptyObject */; typeSet.set(type.id.toString(), type); } } else { - if (flags & 3 /* AnyOrUnknown */) { + if (flags & 3 /* TypeFlags.AnyOrUnknown */) { if (type === wildcardType) - includes |= 8388608 /* IncludesWildcard */; + includes |= 8388608 /* TypeFlags.IncludesWildcard */; } - else if (strictNullChecks || !(flags & 98304 /* Nullable */)) { + else if (strictNullChecks || !(flags & 98304 /* TypeFlags.Nullable */)) { if (exactOptionalPropertyTypes && type === missingType) { - includes |= 262144 /* IncludesMissingType */; + includes |= 262144 /* TypeFlags.IncludesMissingType */; type = undefinedType; } if (!typeSet.has(type.id.toString())) { - if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { + if (type.flags & 109440 /* TypeFlags.Unit */ && includes & 109440 /* TypeFlags.Unit */) { // We have seen two distinct unit types which means we should reduce to an // empty intersection. Adding TypeFlags.NonPrimitive causes that to happen. - includes |= 67108864 /* NonPrimitive */; + includes |= 67108864 /* TypeFlags.NonPrimitive */; } typeSet.set(type.id.toString(), type); } } - includes |= flags & 205258751 /* IncludesMask */; + includes |= flags & 205258751 /* TypeFlags.IncludesMask */; } return includes; } @@ -61809,12 +62007,12 @@ var ts; while (i > 0) { i--; var t = types[i]; - var remove = t.flags & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || - t.flags & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - t.flags & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - t.flags & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || - t.flags & 16384 /* Void */ && includes & 32768 /* Undefined */ || - isEmptyAnonymousObjectType(t) && includes & 470302716 /* DefinitelyNonNullable */; + var remove = t.flags & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + t.flags & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + t.flags & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + t.flags & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */ || + t.flags & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */ || + isEmptyAnonymousObjectType(t) && includes & 470302716 /* TypeFlags.DefinitelyNonNullable */; if (remove) { ts.orderedRemoveItemAt(types, i); } @@ -61827,10 +62025,10 @@ var ts; for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) { var u = unionTypes_1[_i]; if (!containsType(u.types, type)) { - var primitive = type.flags & 128 /* StringLiteral */ ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : + var primitive = type.flags & 128 /* TypeFlags.StringLiteral */ ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : undefined; if (!primitive || !containsType(u.types, primitive)) { return false; @@ -61844,11 +62042,11 @@ var ts; */ function extractRedundantTemplateLiterals(types) { var i = types.length; - var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* StringLiteral */); }); + var literals = ts.filter(types, function (t) { return !!(t.flags & 128 /* TypeFlags.StringLiteral */); }); while (i > 0) { i--; var t = types[i]; - if (!(t.flags & 134217728 /* TemplateLiteral */)) + if (!(t.flags & 134217728 /* TypeFlags.TemplateLiteral */)) continue; for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) { var t2 = literals_1[_i]; @@ -61865,7 +62063,7 @@ var ts; return false; } function eachIsUnionContaining(types, flag) { - return ts.every(types, function (t) { return !!(t.flags & 1048576 /* Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); + return ts.every(types, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); }); } function removeFromEach(types, flag) { for (var i = 0; i < types.length; i++) { @@ -61877,7 +62075,7 @@ var ts; // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types) { var unionTypes; - var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */); }); + var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */); }); if (index < 0) { return false; } @@ -61886,7 +62084,7 @@ var ts; // the unionTypes array. while (i < types.length) { var t = types[i]; - if (ts.getObjectFlags(t) & 32768 /* PrimitiveUnion */) { + if (ts.getObjectFlags(t) & 32768 /* ObjectFlags.PrimitiveUnion */) { (unionTypes || (unionTypes = [types[index]])).push(t); ts.orderedRemoveItemAt(types, i); } @@ -61915,12 +62113,12 @@ var ts; } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, 32768 /* PrimitiveUnion */); + types[index] = getUnionTypeFromSortedList(result, 32768 /* ObjectFlags.PrimitiveUnion */); return true; } function createIntersectionType(types, aliasSymbol, aliasTypeArguments) { - var result = createType(2097152 /* Intersection */); - result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* Nullable */); + var result = createType(2097152 /* TypeFlags.Intersection */); + result.objectFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 98304 /* TypeFlags.Nullable */); result.types = types; result.aliasSymbol = aliasSymbol; result.aliasTypeArguments = aliasTypeArguments; @@ -61949,37 +62147,37 @@ var ts; // a symbol-like type and a type known to be non-symbol-like, or // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. - if (includes & 131072 /* Never */) { + if (includes & 131072 /* TypeFlags.Never */) { return ts.contains(typeSet, silentNeverType) ? silentNeverType : neverType; } - if (strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || - includes & 67108864 /* NonPrimitive */ && includes & (469892092 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || - includes & 402653316 /* StringLike */ && includes & (469892092 /* DisjointDomains */ & ~402653316 /* StringLike */) || - includes & 296 /* NumberLike */ && includes & (469892092 /* DisjointDomains */ & ~296 /* NumberLike */) || - includes & 2112 /* BigIntLike */ && includes & (469892092 /* DisjointDomains */ & ~2112 /* BigIntLike */) || - includes & 12288 /* ESSymbolLike */ && includes & (469892092 /* DisjointDomains */ & ~12288 /* ESSymbolLike */) || - includes & 49152 /* VoidLike */ && includes & (469892092 /* DisjointDomains */ & ~49152 /* VoidLike */)) { + if (strictNullChecks && includes & 98304 /* TypeFlags.Nullable */ && includes & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */ | 16777216 /* TypeFlags.IncludesEmptyObject */) || + includes & 67108864 /* TypeFlags.NonPrimitive */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~67108864 /* TypeFlags.NonPrimitive */) || + includes & 402653316 /* TypeFlags.StringLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~402653316 /* TypeFlags.StringLike */) || + includes & 296 /* TypeFlags.NumberLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~296 /* TypeFlags.NumberLike */) || + includes & 2112 /* TypeFlags.BigIntLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~2112 /* TypeFlags.BigIntLike */) || + includes & 12288 /* TypeFlags.ESSymbolLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~12288 /* TypeFlags.ESSymbolLike */) || + includes & 49152 /* TypeFlags.VoidLike */ && includes & (469892092 /* TypeFlags.DisjointDomains */ & ~49152 /* TypeFlags.VoidLike */)) { return neverType; } - if (includes & 134217728 /* TemplateLiteral */ && includes & 128 /* StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { + if (includes & 134217728 /* TypeFlags.TemplateLiteral */ && includes & 128 /* TypeFlags.StringLiteral */ && extractRedundantTemplateLiterals(typeSet)) { return neverType; } - if (includes & 1 /* Any */) { - return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType; + if (includes & 1 /* TypeFlags.Any */) { + return includes & 8388608 /* TypeFlags.IncludesWildcard */ ? wildcardType : anyType; } - if (!strictNullChecks && includes & 98304 /* Nullable */) { - return includes & 32768 /* Undefined */ ? undefinedType : nullType; + if (!strictNullChecks && includes & 98304 /* TypeFlags.Nullable */) { + return includes & 32768 /* TypeFlags.Undefined */ ? undefinedType : nullType; } - if (includes & 4 /* String */ && includes & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) || - includes & 8 /* Number */ && includes & 256 /* NumberLiteral */ || - includes & 64 /* BigInt */ && includes & 2048 /* BigIntLiteral */ || - includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */ || - includes & 16384 /* Void */ && includes & 32768 /* Undefined */ || - includes & 16777216 /* IncludesEmptyObject */ && includes & 470302716 /* DefinitelyNonNullable */) { + if (includes & 4 /* TypeFlags.String */ && includes & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) || + includes & 8 /* TypeFlags.Number */ && includes & 256 /* TypeFlags.NumberLiteral */ || + includes & 64 /* TypeFlags.BigInt */ && includes & 2048 /* TypeFlags.BigIntLiteral */ || + includes & 4096 /* TypeFlags.ESSymbol */ && includes & 8192 /* TypeFlags.UniqueESSymbol */ || + includes & 16384 /* TypeFlags.Void */ && includes & 32768 /* TypeFlags.Undefined */ || + includes & 16777216 /* TypeFlags.IncludesEmptyObject */ && includes & 470302716 /* TypeFlags.DefinitelyNonNullable */) { if (!noSupertypeReduction) removeRedundantSupertypes(typeSet, includes); } - if (includes & 262144 /* IncludesMissingType */) { + if (includes & 262144 /* TypeFlags.IncludesMissingType */) { typeSet[typeSet.indexOf(undefinedType)] = missingType; } if (typeSet.length === 0) { @@ -61991,21 +62189,21 @@ var ts; var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments); var result = intersectionTypes.get(id); if (!result) { - if (includes & 1048576 /* Union */) { + if (includes & 1048576 /* TypeFlags.Union */) { if (intersectUnionsOfPrimitiveTypes(typeSet)) { // When the intersection creates a reduced set (which might mean that *all* union types have // disappeared), we restart the operation to get a new set of combined flags. Once we have // reduced we'll never reduce again, so this occurs at most once. result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 32768 /* Undefined */)) { + else if (eachIsUnionContaining(typeSet, 32768 /* TypeFlags.Undefined */)) { var undefinedOrMissingType = exactOptionalPropertyTypes && ts.some(typeSet, function (t) { return containsType(t.types, missingType); }) ? missingType : undefinedType; - removeFromEach(typeSet, 32768 /* Undefined */); - result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + removeFromEach(typeSet, 32768 /* TypeFlags.Undefined */); + result = getUnionType([getIntersectionType(typeSet), undefinedOrMissingType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - else if (eachIsUnionContaining(typeSet, 65536 /* Null */)) { - removeFromEach(typeSet, 65536 /* Null */); - result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* Literal */, aliasSymbol, aliasTypeArguments); + else if (eachIsUnionContaining(typeSet, 65536 /* TypeFlags.Null */)) { + removeFromEach(typeSet, 65536 /* TypeFlags.Null */); + result = getUnionType([getIntersectionType(typeSet), nullType], 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } else { // We are attempting to construct a type of the form X & (A | B) & (C | D). Transform this into a type of @@ -62018,8 +62216,8 @@ var ts; // We attach a denormalized origin type when at least one constituent of the cross-product union is an // intersection (i.e. when the intersection didn't just reduce one or more unions to smaller unions) and // the denormalized origin has fewer constituents than the union itself. - var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* Intersection */, typeSet) : undefined; - result = getUnionType(constituents, 1 /* Literal */, aliasSymbol, aliasTypeArguments, origin); + var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152 /* TypeFlags.Intersection */); }) && getConstituentCountOfTypes(constituents) > getConstituentCountOfTypes(typeSet) ? createOriginUnionOrIntersectionType(2097152 /* TypeFlags.Intersection */, typeSet) : undefined; + result = getUnionType(constituents, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments, origin); } } else { @@ -62030,12 +62228,12 @@ var ts; return result; } function getCrossProductUnionSize(types) { - return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* Union */ ? n * t.types.length : t.flags & 131072 /* Never */ ? 0 : n; }, 1); + return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 /* TypeFlags.Union */ ? n * t.types.length : t.flags & 131072 /* TypeFlags.Never */ ? 0 : n; }, 1); } function checkCrossProductUnion(types) { var size = getCrossProductUnionSize(types); if (size >= 100000) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size }); error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent); return false; } @@ -62048,7 +62246,7 @@ var ts; var constituents = types.slice(); var n = i; for (var j = types.length - 1; j >= 0; j--) { - if (types[j].flags & 1048576 /* Union */) { + if (types[j].flags & 1048576 /* TypeFlags.Union */) { var sourceTypes = types[j].types; var length_5 = sourceTypes.length; constituents[j] = sourceTypes[n % length_5]; @@ -62056,14 +62254,14 @@ var ts; } } var t = getIntersectionType(constituents); - if (!(t.flags & 131072 /* Never */)) + if (!(t.flags & 131072 /* TypeFlags.Never */)) intersections.push(t); } return intersections; } function getConstituentCount(type) { - return !(type.flags & 3145728 /* UnionOrIntersection */) || type.aliasSymbol ? 1 : - type.flags & 1048576 /* Union */ && type.origin ? getConstituentCount(type.origin) : + return !(type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) || type.aliasSymbol ? 1 : + type.flags & 1048576 /* TypeFlags.Union */ && type.origin ? getConstituentCount(type.origin) : getConstituentCountOfTypes(type.types); } function getConstituentCountOfTypes(types) { @@ -62074,19 +62272,19 @@ var ts; if (!links.resolvedType) { var aliasSymbol = getAliasSymbolForTypeNode(node); var types = ts.map(node.types, getTypeFromTypeNode); - var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) && types[1] === emptyTypeLiteralType; + var noSupertypeReduction = types.length === 2 && !!(types[0].flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) && types[1] === emptyTypeLiteralType; links.resolvedType = getIntersectionType(types, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol), noSupertypeReduction); } return links.resolvedType; } function createIndexType(type, stringsOnly) { - var result = createType(4194304 /* Index */); + var result = createType(4194304 /* TypeFlags.Index */); result.type = type; result.stringsOnly = stringsOnly; return result; } function createOriginIndexType(type) { - var result = createOriginType(4194304 /* Index */); + var result = createOriginType(4194304 /* TypeFlags.Index */); result.type = type; return result; } @@ -62118,7 +62316,7 @@ var ts; // so we only eagerly manifest the keys if the constraint is nongeneric if (!isGenericIndexType(constraintType)) { var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, stringsOnly, addMemberForKeyType); } else { // we have a generic index and a homomorphic mapping (but a distributive key remapping) - we need to defer the whole `keyof whatever` for later @@ -62134,8 +62332,8 @@ var ts; } // we had to pick apart the constraintType to potentially map/filter it - compare the final resulting list with the original constraintType, // so we can return the union that preserves aliases/origin data if possible - var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* Any */ | 4 /* String */)); }) : getUnionType(keyTypes); - if (result.flags & 1048576 /* Union */ && constraintType.flags & 1048576 /* Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { + var result = noIndexSignatures ? filterType(getUnionType(keyTypes), function (t) { return !(t.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)); }) : getUnionType(keyTypes); + if (result.flags & 1048576 /* TypeFlags.Union */ && constraintType.flags & 1048576 /* TypeFlags.Union */ && getTypeListId(result.types) === getTypeListId(constraintType.types)) { return constraintType; } return result; @@ -62155,12 +62353,12 @@ var ts; var typeVariable = getTypeParameterFromMappedType(mappedType); return isDistributive(getNameTypeFromMappedType(mappedType) || typeVariable); function isDistributive(type) { - return type.flags & (3 /* AnyOrUnknown */ | 131068 /* Primitive */ | 131072 /* Never */ | 262144 /* TypeParameter */ | 524288 /* Object */ | 67108864 /* NonPrimitive */) ? true : - type.flags & 16777216 /* Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : - type.flags & (3145728 /* UnionOrIntersection */ | 134217728 /* TemplateLiteral */) ? ts.every(type.types, isDistributive) : - type.flags & 8388608 /* IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : - type.flags & 33554432 /* Substitution */ ? isDistributive(type.substitute) : - type.flags & 268435456 /* StringMapping */ ? isDistributive(type.type) : + return type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */ | 262144 /* TypeFlags.TypeParameter */ | 524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */) ? true : + type.flags & 16777216 /* TypeFlags.Conditional */ ? type.root.isDistributive && type.checkType === typeVariable : + type.flags & (3145728 /* TypeFlags.UnionOrIntersection */ | 134217728 /* TypeFlags.TemplateLiteral */) ? ts.every(type.types, isDistributive) : + type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? isDistributive(type.objectType) && isDistributive(type.indexType) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? isDistributive(type.substitute) : + type.flags & 268435456 /* TypeFlags.StringMapping */ ? isDistributive(type.type) : false; } } @@ -62172,11 +62370,11 @@ var ts; getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name)); } function getLiteralTypeFromProperty(prop, include, includeNonPublic) { - if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* NonPublicAccessibilityModifier */)) { + if (includeNonPublic || !(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType; if (!type) { var name = ts.getNameOfDeclaration(prop.valueDeclaration); - type = prop.escapedName === "default" /* Default */ ? getStringLiteralType("default") : + type = prop.escapedName === "default" /* InternalSymbolName.Default */ ? getStringLiteralType("default") : name && getLiteralTypeFromPropertyName(name) || (!ts.isKnownSymbol(prop) ? getStringLiteralType(ts.symbolName(prop)) : undefined); } if (type && type.flags & include) { @@ -62186,14 +62384,14 @@ var ts; return neverType; } function isKeyTypeIncluded(keyType, include) { - return !!(keyType.flags & include || keyType.flags & 2097152 /* Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); + return !!(keyType.flags & include || keyType.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(keyType.types, function (t) { return isKeyTypeIncluded(t, include); })); } function getLiteralTypeFromProperties(type, include, includeOrigin) { - var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ClassOrInterface */ | 4 /* Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; + var origin = includeOrigin && (ts.getObjectFlags(type) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */) || type.aliasSymbol) ? createOriginIndexType(type) : undefined; var propertyTypes = ts.map(getPropertiesOfType(type), function (prop) { return getLiteralTypeFromProperty(prop, include); }); var indexKeyTypes = ts.map(getIndexInfosOfType(type), function (info) { return info !== enumNumberIndexInfo && isKeyTypeIncluded(info.keyType, include) ? - info.keyType === stringType && include & 8 /* Number */ ? stringOrNumberType : info.keyType : neverType; }); - return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* Literal */, + info.keyType === stringType && include & 8 /* TypeFlags.Number */ ? stringOrNumberType : info.keyType : neverType; }); + return getUnionType(ts.concatenate(propertyTypes, indexKeyTypes), 1 /* UnionReduction.Literal */, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, origin); } /** @@ -62203,24 +62401,27 @@ var ts; * to reduce the resulting type if possible (since only intersections with conflicting literal-typed properties are reducible). */ function isPossiblyReducibleByInstantiation(type) { - return ts.some(type.types, function (t) { - var uniqueFilled = getUniqueLiteralFilledInstantiation(t); - return getReducedType(uniqueFilled) !== uniqueFilled; - }); + var uniqueFilled = getUniqueLiteralFilledInstantiation(type); + return getReducedType(uniqueFilled) !== uniqueFilled; + } + function shouldDeferIndexType(type) { + return !!(type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || + isGenericTupleType(type) || + isGenericMappedType(type) && !hasDistributiveNameType(type) || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isPossiblyReducibleByInstantiation) || + type.flags & 2097152 /* TypeFlags.Intersection */ && maybeTypeOfKind(type, 465829888 /* TypeFlags.Instantiable */) && ts.some(type.types, isEmptyAnonymousObjectType)); } function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } type = getReducedType(type); - return type.flags & 1048576 /* Union */ ? isPossiblyReducibleByInstantiation(type) - ? getIndexTypeForGenericType(type, stringsOnly) - : getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : - type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericTupleType(type) || isGenericMappedType(type) && !hasDistributiveNameType(type) ? getIndexTypeForGenericType(type, stringsOnly) : - ts.getObjectFlags(type) & 32 /* Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : + return shouldDeferIndexType(type) ? getIndexTypeForGenericType(type, stringsOnly) : + type.flags & 1048576 /* TypeFlags.Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : + ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ ? getIndexTypeForMappedType(type, stringsOnly, noIndexSignatures) : type === wildcardType ? wildcardType : - type.flags & 2 /* Unknown */ ? neverType : - type.flags & (1 /* Any */ | 131072 /* Never */) ? keyofConstraintType : - getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* StringLiteral */ : 402653316 /* StringLike */) | (stringsOnly ? 0 : 296 /* NumberLike */ | 12288 /* ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); + type.flags & 2 /* TypeFlags.Unknown */ ? neverType : + type.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */) ? keyofConstraintType : + getLiteralTypeFromProperties(type, (noIndexSignatures ? 128 /* TypeFlags.StringLiteral */ : 402653316 /* TypeFlags.StringLike */) | (stringsOnly ? 0 : 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */), stringsOnly === keyofStringsOnly && !noIndexSignatures); } function getExtractStringType(type) { if (keyofStringsOnly) { @@ -62231,21 +62432,21 @@ var ts; } function getIndexTypeOrString(type) { var indexType = getExtractStringType(getIndexType(type)); - return indexType.flags & 131072 /* Never */ ? stringType : indexType; + return indexType.flags & 131072 /* TypeFlags.Never */ ? stringType : indexType; } function getTypeFromTypeOperatorNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 140 /* KeyOfKeyword */: + case 140 /* SyntaxKind.KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 154 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 151 /* SymbolKeyword */ + case 154 /* SyntaxKind.UniqueKeyword */: + links.resolvedType = node.type.kind === 151 /* SyntaxKind.SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 145 /* ReadonlyKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; default: @@ -62262,7 +62463,7 @@ var ts; return links.resolvedType; } function getTemplateLiteralType(texts, types) { - var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* Never */ | 1048576 /* Union */)); }); + var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 /* TypeFlags.Never */ | 1048576 /* TypeFlags.Union */)); }); if (unionIndex >= 0) { return checkCrossProductUnion(types) ? mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) : @@ -62281,10 +62482,10 @@ var ts; return getStringLiteralType(text); } newTexts.push(text); - if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* String */); })) { + if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) { return stringType; } - var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join(""); + var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join("")); var type = templateLiteralTypes.get(id); if (!type) { templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes)); @@ -62295,13 +62496,13 @@ var ts; for (var i = 0; i < types.length; i++) { var t = types[i]; var addText = isTextsArray ? texts[i + 1] : texts; - if (t.flags & (2944 /* Literal */ | 65536 /* Null */ | 32768 /* Undefined */)) { + if (t.flags & (2944 /* TypeFlags.Literal */ | 65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */)) { text += getTemplateStringForType(t) || ""; text += addText; if (!isTextsArray) return true; } - else if (t.flags & 134217728 /* TemplateLiteral */) { + else if (t.flags & 134217728 /* TypeFlags.TemplateLiteral */) { text += t.texts[0]; if (!addSpans(t.texts, t.types)) return false; @@ -62314,7 +62515,7 @@ var ts; newTexts.push(text); text = addText; } - else if (t.flags & 2097152 /* Intersection */) { + else if (t.flags & 2097152 /* TypeFlags.Intersection */) { var added = addSpans(texts[i + 1], t.types); if (!added) return false; @@ -62327,47 +62528,47 @@ var ts; } } function getTemplateStringForType(type) { - return type.flags & 128 /* StringLiteral */ ? type.value : - type.flags & 256 /* NumberLiteral */ ? "" + type.value : - type.flags & 2048 /* BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : - type.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) ? type.intrinsicName : + return type.flags & 128 /* TypeFlags.StringLiteral */ ? type.value : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? "" + type.value : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? ts.pseudoBigIntToString(type.value) : + type.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) ? type.intrinsicName : undefined; } function createTemplateLiteralType(texts, types) { - var type = createType(134217728 /* TemplateLiteral */); + var type = createType(134217728 /* TypeFlags.TemplateLiteral */); type.texts = texts; type.types = types; return type; } function getStringMappingType(symbol, type) { - return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : + return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) : // Mapping> === Mapping - type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type : - isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) : - type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : - type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) : + type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type : + isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* TypeFlags.StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) : + type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) : + type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) : type; } function applyStringMapping(symbol, str) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return str.toUpperCase(); - case 1 /* Lowercase */: return str.toLowerCase(); - case 2 /* Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); - case 3 /* Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); + case 0 /* IntrinsicTypeKind.Uppercase */: return str.toUpperCase(); + case 1 /* IntrinsicTypeKind.Lowercase */: return str.toLowerCase(); + case 2 /* IntrinsicTypeKind.Capitalize */: return str.charAt(0).toUpperCase() + str.slice(1); + case 3 /* IntrinsicTypeKind.Uncapitalize */: return str.charAt(0).toLowerCase() + str.slice(1); } return str; } function applyTemplateStringMapping(symbol, texts, types) { switch (intrinsicTypeKinds.get(symbol.escapedName)) { - case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; - case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; - case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; - case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + case 0 /* IntrinsicTypeKind.Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 1 /* IntrinsicTypeKind.Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })]; + case 2 /* IntrinsicTypeKind.Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; + case 3 /* IntrinsicTypeKind.Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types]; } return [texts, types]; } function getStringMappingTypeForGenericType(symbol, type) { - var id = getSymbolId(symbol) + "," + getTypeId(type); + var id = "".concat(getSymbolId(symbol), ",").concat(getTypeId(type)); var result = stringMappingTypes.get(id); if (!result) { stringMappingTypes.set(id, result = createStringMappingType(symbol, type)); @@ -62375,13 +62576,13 @@ var ts; return result; } function createStringMappingType(symbol, type) { - var result = createType(268435456 /* StringMapping */); + var result = createType(268435456 /* TypeFlags.StringMapping */); result.symbol = symbol; result.type = type; return result; } function createIndexedAccessType(objectType, indexType, accessFlags, aliasSymbol, aliasTypeArguments) { - var type = createType(8388608 /* IndexedAccess */); + var type = createType(8388608 /* TypeFlags.IndexedAccess */); type.objectType = objectType; type.indexType = indexType; type.accessFlags = accessFlags; @@ -62402,16 +62603,16 @@ var ts; if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - if (ts.getObjectFlags(type) & 4096 /* JSLiteral */) { + if (ts.getObjectFlags(type) & 4096 /* ObjectFlags.JSLiteral */) { return true; } - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { return ts.every(type.types, isJSLiteralType); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.some(type.types, isJSLiteralType); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getResolvedBaseConstraint(type); return constraint !== type && isJSLiteralType(constraint); } @@ -62426,26 +62627,26 @@ var ts; undefined; } function isUncalledFunctionReference(node, symbol) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */)) { var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent; if (ts.isCallLikeExpression(parent)) { return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node); } - return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } return true; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, accessNode, accessFlags) { var _a; - var accessExpression = accessNode && accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode : undefined; var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { - if (accessFlags & 256 /* Contextual */) { + if (accessFlags & 256 /* AccessFlags.Contextual */) { return getTypeOfPropertyOfContextualType(objectType, propName) || anyType; } var prop = getPropertyOfType(objectType, propName); if (prop) { - if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { + if (accessFlags & 64 /* AccessFlags.ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) { var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode); addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName); } @@ -62455,7 +62656,7 @@ var ts; error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; } - if (accessFlags & 8 /* CacheSymbol */) { + if (accessFlags & 8 /* AccessFlags.CacheSymbol */) { getNodeLinks(accessNode).resolvedSymbol = prop; } if (isThisPropertyAccessInConstructor(accessExpression, prop)) { @@ -62463,50 +62664,57 @@ var ts; } } var propType = getTypeOfSymbol(prop); - return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? + return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 /* AssignmentKind.Definite */ ? getFlowTypeOfReference(accessExpression, propType) : propType; } - if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName) && +propName >= 0) { - if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* NoTupleBoundsCheck */)) { + if (everyType(objectType, isTupleType) && ts.isNumericLiteralName(propName)) { + var index = +propName; + if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 16 /* AccessFlags.NoTupleBoundsCheck */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { + if (index < 0) { + error(indexNode, ts.Diagnostics.A_tuple_type_cannot_be_indexed_with_a_negative_value); + return undefinedType; + } error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName)); } else { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } } - errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); - return mapType(objectType, function (t) { - var restType = getRestTypeOfTupleType(t) || undefinedType; - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; - }); + if (index >= 0) { + errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, numberType)); + return mapType(objectType, function (t) { + var restType = getRestTypeOfTupleType(t) || undefinedType; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([restType, undefinedType]) : restType; + }); + } } } - if (!(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */)) { - if (objectType.flags & (1 /* Any */ | 131072 /* Never */)) { + if (!(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */)) { + if (objectType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) { return objectType; } // If no index signature is applicable, we default to the string index signature. In effect, this means the string // index signature applies even when accessing with a symbol-like type. var indexInfo = getApplicableIndexInfo(objectType, indexType) || getIndexInfoOfType(objectType, stringType); if (indexInfo) { - if (accessFlags & 2 /* NoIndexSignatures */ && indexInfo.keyType !== numberType) { + if (accessFlags & 2 /* AccessFlags.NoIndexSignatures */ && indexInfo.keyType !== numberType) { if (accessExpression) { error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType)); } return undefined; } - if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (accessNode && indexInfo.keyType === stringType && !isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { var indexNode = getIndexNodeForAccessExpression(accessNode); error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } errorIfWritingToReadonlyIndex(indexInfo); - return accessFlags & 1 /* IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; + return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type; } - if (indexType.flags & 131072 /* Never */) { + if (indexType.flags & 131072 /* TypeFlags.Never */) { return neverType; } if (isJSLiteralType(objectType)) { @@ -62514,21 +62722,21 @@ var ts; } if (accessExpression && !isConstEnumObjectType(objectType)) { if (isObjectLiteralType(objectType)) { - if (noImplicitAny && indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (noImplicitAny && indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType))); return undefinedType; } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { var types = ts.map(objectType.properties, function (property) { return getTypeOfSymbol(property); }); return getUnionType(ts.append(types, undefinedType)); } } - if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* BlockScoped */)) { + if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418 /* SymbolFlags.BlockScoped */)) { error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType)); } - else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* SuppressNoImplicitAnyError */)) { + else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !(accessFlags & 128 /* AccessFlags.SuppressNoImplicitAnyError */)) { if (propName !== undefined && typeHasStaticProperty(propName, objectType)) { var typeName = typeToString(objectType); error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]"); @@ -62550,20 +62758,20 @@ var ts; } else { var errorInfo = void 0; - if (indexType.flags & 1024 /* EnumLiteral */) { + if (indexType.flags & 1024 /* TypeFlags.EnumLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType)); } - else if (indexType.flags & 8192 /* UniqueESSymbol */) { + else if (indexType.flags & 8192 /* TypeFlags.UniqueESSymbol */) { var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression); errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType)); } - else if (indexType.flags & 128 /* StringLiteral */) { + else if (indexType.flags & 128 /* TypeFlags.StringLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & 256 /* NumberLiteral */) { + else if (indexType.flags & 256 /* TypeFlags.NumberLiteral */) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)); } - else if (indexType.flags & (8 /* Number */ | 4 /* String */)) { + else if (indexType.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */)) { errorInfo = ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType)); } errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Element_implicitly_has_an_any_type_because_expression_of_type_0_can_t_be_used_to_index_type_1, typeToString(fullIndexType), typeToString(objectType)); @@ -62580,10 +62788,10 @@ var ts; } if (accessNode) { var indexNode = getIndexNodeForAccessExpression(accessNode); - if (indexType.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) { + if (indexType.flags & (128 /* TypeFlags.StringLiteral */ | 256 /* TypeFlags.NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType)); } - else if (indexType.flags & (4 /* String */ | 8 /* Number */)) { + else if (indexType.flags & (4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType)); } else { @@ -62601,62 +62809,62 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 207 /* ElementAccessExpression */ ? accessNode.argumentExpression : - accessNode.kind === 194 /* IndexedAccessType */ ? accessNode.indexType : - accessNode.kind === 162 /* ComputedPropertyName */ ? accessNode.expression : + return accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 194 /* SyntaxKind.IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? accessNode.expression : accessNode; } function isPatternLiteralPlaceholderType(type) { - return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type)); + return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */ && isPatternLiteralPlaceholderType(type.type)); } function isPatternLiteralType(type) { - return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); + return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType); } function isGenericType(type) { return !!getGenericObjectFlags(type); } function isGenericObjectType(type) { - return !!(getGenericObjectFlags(type) & 4194304 /* IsGenericObjectType */); + return !!(getGenericObjectFlags(type) & 4194304 /* ObjectFlags.IsGenericObjectType */); } function isGenericIndexType(type) { - return !!(getGenericObjectFlags(type) & 8388608 /* IsGenericIndexType */); + return !!(getGenericObjectFlags(type) & 8388608 /* ObjectFlags.IsGenericIndexType */); } function getGenericObjectFlags(type) { - if (type.flags & 3145728 /* UnionOrIntersection */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | ts.reduceLeft(type.types, function (flags, t) { return flags | getGenericObjectFlags(t); }, 0); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - if (type.flags & 33554432 /* Substitution */) { - if (!(type.objectFlags & 2097152 /* IsGenericTypeComputed */)) { - type.objectFlags |= 2097152 /* IsGenericTypeComputed */ | + if (type.flags & 33554432 /* TypeFlags.Substitution */) { + if (!(type.objectFlags & 2097152 /* ObjectFlags.IsGenericTypeComputed */)) { + type.objectFlags |= 2097152 /* ObjectFlags.IsGenericTypeComputed */ | getGenericObjectFlags(type.substitute) | getGenericObjectFlags(type.baseType); } - return type.objectFlags & 12582912 /* IsGenericType */; + return type.objectFlags & 12582912 /* ObjectFlags.IsGenericType */; } - return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | - (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* IsGenericIndexType */ : 0); + return (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* ObjectFlags.IsGenericObjectType */ : 0) | + (type.flags & (58982400 /* TypeFlags.InstantiableNonPrimitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && !isPatternLiteralType(type) ? 8388608 /* ObjectFlags.IsGenericIndexType */ : 0); } function getSimplifiedType(type, writing) { - return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : - type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : + return type.flags & 8388608 /* TypeFlags.IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : + type.flags & 16777216 /* TypeFlags.Conditional */ ? getSimplifiedConditionalType(type, writing) : type; } function distributeIndexOverObjectType(objectType, indexType, writing) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] - if (objectType.flags & 3145728 /* UnionOrIntersection */) { + if (objectType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); }); - return objectType.flags & 2097152 /* Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); + return objectType.flags & 2097152 /* TypeFlags.Intersection */ || writing ? getIntersectionType(types) : getUnionType(types); } } function distributeObjectOverIndexType(objectType, indexType, writing) { // T[A | B] -> T[A] | T[B] (reading) // T[A | B] -> T[A] & T[B] (writing) - if (indexType.flags & 1048576 /* Union */) { + if (indexType.flags & 1048576 /* TypeFlags.Union */) { var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); }); return writing ? getIntersectionType(types) : getUnionType(types); } @@ -62681,7 +62889,7 @@ var ts; return type[cache] = distributedOverIndex; } // Only do the inner distributions if the index can no longer be instantiated to cause index distribution again - if (!(indexType.flags & 465829888 /* Instantiable */)) { + if (!(indexType.flags & 465829888 /* TypeFlags.Instantiable */)) { // (T | U)[K] -> T[K] | U[K] (reading) // (T | U)[K] -> T[K] & U[K] (writing) // (T & U)[K] -> T[K] & U[K] @@ -62695,8 +62903,8 @@ var ts; // A generic tuple type indexed by a number exists only when the index type doesn't select a // fixed element. We simplify to either the combined type of all elements (when the index type // the actual number type) or to the combined type of all non-fixed elements. - if (isGenericTupleType(objectType) && indexType.flags & 296 /* NumberLike */) { - var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); + if (isGenericTupleType(objectType) && indexType.flags & 296 /* TypeFlags.NumberLike */) { + var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 /* TypeFlags.Number */ ? 0 : objectType.target.fixedLength, /*endSkipCount*/ 0, writing); if (elementType) { return type[cache] = elementType; } @@ -62718,19 +62926,19 @@ var ts; var trueType = getTrueTypeFromConditionalType(type); var falseType = getFalseTypeFromConditionalType(type); // Simplifications for types of the form `T extends U ? T : never` and `T extends U ? never : T`. - if (falseType.flags & 131072 /* Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { - if (checkType.flags & 1 /* Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + if (falseType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) { + if (checkType.flags & 1 /* TypeFlags.Any */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return getSimplifiedType(trueType, writing); } else if (isIntersectionEmpty(checkType, extendsType)) { // Always false return neverType; } } - else if (trueType.flags & 131072 /* Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { - if (!(checkType.flags & 1 /* Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true + else if (trueType.flags & 131072 /* TypeFlags.Never */ && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) { + if (!(checkType.flags & 1 /* TypeFlags.Any */) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) { // Always true return neverType; } - else if (checkType.flags & 1 /* Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false + else if (checkType.flags & 1 /* TypeFlags.Any */ || isIntersectionEmpty(checkType, extendsType)) { // Always false return getSimplifiedType(falseType, writing); } } @@ -62740,7 +62948,7 @@ var ts; * Invokes union simplification logic to determine if an intersection is considered empty as a union constituent */ function isIntersectionEmpty(type1, type2) { - return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* Never */); + return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072 /* TypeFlags.Never */); } function substituteIndexedMappedType(objectType, index) { var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]); @@ -62748,12 +62956,12 @@ var ts; return instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper); } function getIndexedAccessType(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType); } function indexTypeLessThan(indexType, limit) { return everyType(indexType, function (t) { - if (t.flags & 384 /* StringOrNumberLiteral */) { + if (t.flags & 384 /* TypeFlags.StringOrNumberLiteral */) { var propName = getPropertyNameFromType(t); if (ts.isNumericLiteralName(propName)) { var index = +propName; @@ -62764,33 +62972,33 @@ var ts; }); } function getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) { - if (accessFlags === void 0) { accessFlags = 0 /* None */; } + if (accessFlags === void 0) { accessFlags = 0 /* AccessFlags.None */; } if (objectType === wildcardType || indexType === wildcardType) { return wildcardType; } // If the object type has a string index signature and no other members we know that the result will // always be the type of that index signature and we can simplify accordingly. - if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* Nullable */) && isTypeAssignableToKind(indexType, 4 /* String */ | 8 /* Number */)) { + if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableToKind(indexType, 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */)) { indexType = stringType; } // In noUncheckedIndexedAccess mode, indexed access operations that occur in an expression in a read position and resolve to // an index signature have 'undefined' included in their type. - if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* ExpressionPosition */) - accessFlags |= 1 /* IncludeUndefined */; + if (compilerOptions.noUncheckedIndexedAccess && accessFlags & 32 /* AccessFlags.ExpressionPosition */) + accessFlags |= 1 /* AccessFlags.IncludeUndefined */; // If the index type is generic, or if the object type is generic and doesn't originate in an expression and // the operation isn't exclusively indexing the fixed (non-variadic) portion of a tuple type, we are performing // a higher-order index access where we cannot meaningfully access the properties of the object type. Note that // for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in an expression. This is to // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* IndexedAccessType */ ? + if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 194 /* SyntaxKind.IndexedAccessType */ ? isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) : isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) { - if (objectType.flags & 3 /* AnyOrUnknown */) { + if (objectType.flags & 3 /* TypeFlags.AnyOrUnknown */) { return objectType; } // Defer the operation by creating an indexed access type. - var persistentAccessFlags = accessFlags & 1 /* Persistent */; + var persistentAccessFlags = accessFlags & 1 /* AccessFlags.Persistent */; var id = objectType.id + "," + indexType.id + "," + persistentAccessFlags + getAliasId(aliasSymbol, aliasTypeArguments); var type = indexedAccessTypes.get(id); if (!type) { @@ -62802,12 +63010,12 @@ var ts; // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getReducedApparentType(objectType); - if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { + if (indexType.flags & 1048576 /* TypeFlags.Union */ && !(indexType.flags & 16 /* TypeFlags.Boolean */)) { var propTypes = []; var wasMissingProp = false; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; - var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* SuppressNoImplicitAnyError */ : 0)); + var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, accessNode, accessFlags | (wasMissingProp ? 128 /* AccessFlags.SuppressNoImplicitAnyError */ : 0)); if (propType) { propTypes.push(propType); } @@ -62823,11 +63031,11 @@ var ts; if (wasMissingProp) { return undefined; } - return accessFlags & 4 /* Writing */ + return accessFlags & 4 /* AccessFlags.Writing */ ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments) - : getUnionType(propTypes, 1 /* Literal */, aliasSymbol, aliasTypeArguments); + : getUnionType(propTypes, 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments); } - return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* CacheSymbol */ | 64 /* ReportDeprecated */); + return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, accessNode, accessFlags | 8 /* AccessFlags.CacheSymbol */ | 64 /* AccessFlags.ReportDeprecated */); } function getTypeFromIndexedAccessTypeNode(node) { var links = getNodeLinks(node); @@ -62835,8 +63043,8 @@ var ts; var objectType = getTypeFromTypeNode(node.objectType); var indexType = getTypeFromTypeNode(node.indexType); var potentialAlias = getAliasSymbolForTypeNode(node); - var resolved = getIndexedAccessType(objectType, indexType, 0 /* None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); - links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && + var resolved = getIndexedAccessType(objectType, indexType, 0 /* AccessFlags.None */, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias)); + links.resolvedType = resolved.flags & 8388608 /* TypeFlags.IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? getConditionalFlowTypeOfType(resolved, node) : resolved; @@ -62846,7 +63054,7 @@ var ts; function getTypeFromMappedTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var type = createObjectType(32 /* Mapped */, node.symbol); + var type = createObjectType(32 /* ObjectFlags.Mapped */, node.symbol); type.declaration = node; type.aliasSymbol = getAliasSymbolForTypeNode(node); type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol); @@ -62858,11 +63066,11 @@ var ts; return links.resolvedType; } function getActualTypeVariable(type) { - if (type.flags & 33554432 /* Substitution */) { + if (type.flags & 33554432 /* TypeFlags.Substitution */) { return type.baseType; } - if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ || - type.indexType.flags & 33554432 /* Substitution */)) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */ && (type.objectType.flags & 33554432 /* TypeFlags.Substitution */ || + type.indexType.flags & 33554432 /* TypeFlags.Substitution */)) { return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType)); } return type; @@ -62893,7 +63101,7 @@ var ts; var result; var extraTypes; var tailCount = 0; - var _loop_18 = function () { + var _loop_19 = function () { if (tailCount === 1000) { error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); result = errorType; @@ -62927,7 +63135,7 @@ var ts; // * The mapper that maps the clone to its inference result (`context.mapper`) var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter); var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined; - var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* None */); + var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */); if (freshMapper) { var freshCombinedMapper = combineTypeMappers(mapper, freshMapper); for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) { @@ -62945,7 +63153,7 @@ var ts; // We don't want inferences from constraints as they may cause us to eagerly resolve the // conditional type instead of deferring resolution. Also, we always want strict function // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); } var innerMapper = combineTypeMappers(freshMapper, context.mapper); // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the @@ -62961,15 +63169,15 @@ var ts; // types with type parameters mapped to the wildcard type, the most permissive instantiations // possible (the wildcard type is assignable to and from all types). If those are not related, // then no instantiations will be and we can just return the false branch type. - if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && ((checkType.flags & 1 /* Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */ && !isUnwrapped) { + if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) { (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper)); } // If falseType is an immediately nested conditional type that isn't distributive or has an // identical checkType, switch to that type and loop. var falseType_1 = getTypeFromTypeNode(root.node.falseType); - if (falseType_1.flags & 16777216 /* Conditional */) { + if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) { var newRoot = falseType_1.root; if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { root = newRoot; @@ -62987,7 +63195,7 @@ var ts; // that has no constraint. This ensures that, for example, the type // type Foo = T extends { x: string } ? string : number // doesn't immediately resolve to 'string' instead of being deferred. - if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { + if (inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { var trueType_1 = getTypeFromTypeNode(root.node.trueType); var trueMapper = combinedMapper || mapper; if (canTailRecurse(trueType_1, trueMapper)) { @@ -62998,7 +63206,7 @@ var ts; } } // Return a deferred type for a check that is neither definitely true nor definitely false - result = createType(16777216 /* Conditional */); + result = createType(16777216 /* TypeFlags.Conditional */); result.root = root; result.checkType = instantiateType(root.checkType, mapper); result.extendsType = instantiateType(root.extendsType, mapper); @@ -63014,7 +63222,7 @@ var ts; // another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive // cases we increment the tail recursion counter and stop after 1000 iterations. while (true) { - var state_5 = _loop_18(); + var state_5 = _loop_19(); if (typeof state_5 === "object") return state_5.value; if (state_5 === "break") @@ -63026,14 +63234,14 @@ var ts; // type. Note that recursion is possible only through aliased conditional types, so we only increment the tail // recursion counter for those. function canTailRecurse(newType, newMapper) { - if (newType.flags & 16777216 /* Conditional */ && newMapper) { + if (newType.flags & 16777216 /* TypeFlags.Conditional */ && newMapper) { var newRoot = newType.root; if (newRoot.outerTypeParameters) { var typeParamMapper_1 = combineTypeMappers(newType.mapper, newMapper); var typeArguments = ts.map(newRoot.outerTypeParameters, function (t) { return getMappedType(t, typeParamMapper_1); }); var newRootMapper = createTypeMapper(newRoot.outerTypeParameters, typeArguments); var newCheckType = newRoot.isDistributive ? getMappedType(newRoot.checkType, newRootMapper) : undefined; - if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* Union */ | 131072 /* Never */))) { + if (!newCheckType || newCheckType === newRoot.checkType || !(newCheckType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */))) { root = newRoot; mapper = newRootMapper; aliasSymbol = undefined; @@ -63061,7 +63269,7 @@ var ts; var result; if (node.locals) { node.locals.forEach(function (symbol) { - if (symbol.flags & 262144 /* TypeParameter */) { + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) { result = ts.append(result, getDeclaredTypeOfSymbol(symbol)); } }); @@ -63084,7 +63292,7 @@ var ts; node: node, checkType: checkType, extendsType: getTypeFromTypeNode(node.extendsType), - isDistributive: !!(checkType.flags & 262144 /* TypeParameter */), + isDistributive: !!(checkType.flags & 262144 /* TypeFlags.TypeParameter */), inferTypeParameters: getInferTypeParameters(node), outerTypeParameters: outerTypeParameters, instantiations: undefined, @@ -63115,6 +63323,7 @@ var ts; } } function getTypeFromImportTypeNode(node) { + var _a; var links = getNodeLinks(node); if (!links.resolvedType) { if (node.isTypeOf && node.typeArguments) { // Only the non-typeof form can make use of type arguments @@ -63127,27 +63336,30 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* SymbolFlags.Value */ : node.flags & 8388608 /* NodeFlags.JSDoc */ ? 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ : 788968 /* SymbolFlags.Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } + var isExportEquals = !!((_a = innerModuleSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("export=" /* InternalSymbolName.ExportEquals */)); var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, /*dontResolveAlias*/ false); if (!ts.nodeIsMissing(node.qualifier)) { var nameStack = getIdentifierChain(node.qualifier); var currentNamespace = moduleSymbol; var current = void 0; while (current = nameStack.shift()) { - var meaning = nameStack.length ? 1920 /* Namespace */ : targetMeaning; + var meaning = nameStack.length ? 1920 /* SymbolFlags.Namespace */ : targetMeaning; // typeof a.b.c is normally resolved using `checkExpression` which in turn defers to `checkQualifiedName` // That, in turn, ultimately uses `getPropertyOfType` on the type of the symbol, which differs slightly from // the `exports` lookup process that only looks up namespace members which is used for most type references var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace)); - var next = node.isTypeOf + var symbolFromVariable = node.isTypeOf || ts.isInJSFile(node) && isExportEquals ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ true) - : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + : undefined; + var symbolFromModule = node.isTypeOf ? undefined : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning); + var next = symbolFromModule !== null && symbolFromModule !== void 0 ? symbolFromModule : symbolFromVariable; if (!next) { error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current)); return links.resolvedType = errorType; @@ -63163,7 +63375,7 @@ var ts; links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { - var errorMessage = targetMeaning === 111551 /* Value */ + var errorMessage = targetMeaning === 111551 /* SymbolFlags.Value */ ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0; error(node, errorMessage, node.argument.literal.text); @@ -63177,7 +63389,7 @@ var ts; function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; - if (meaning === 111551 /* Value */) { + if (meaning === 111551 /* SymbolFlags.Value */) { return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { @@ -63193,7 +63405,7 @@ var ts; links.resolvedType = emptyTypeLiteralType; } else { - var type = createObjectType(16 /* Anonymous */, node.symbol); + var type = createObjectType(16 /* ObjectFlags.Anonymous */, node.symbol); type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); if (ts.isJSDocTypeLiteral(node) && node.isArrayType) { @@ -63206,7 +63418,7 @@ var ts; } function getAliasSymbolForTypeNode(node) { var host = node.parent; - while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* ReadonlyKeyword */) { + while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { host = host.parent; } return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; @@ -63215,13 +63427,13 @@ var ts; return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; } function isNonGenericObjectType(type) { - return !!(type.flags & 524288 /* Object */) && !isGenericMappedType(type); + return !!(type.flags & 524288 /* TypeFlags.Object */) && !isGenericMappedType(type); } function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) { - return isEmptyObjectType(type) || !!(type.flags & (65536 /* Null */ | 32768 /* Undefined */ | 528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)); + return isEmptyObjectType(type) || !!(type.flags & (65536 /* TypeFlags.Null */ | 32768 /* TypeFlags.Undefined */ | 528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)); } function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) { - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return type; } if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) { @@ -63241,13 +63453,13 @@ var ts; var members = ts.createSymbolTable(); for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { // do nothing, skip privates } else if (isSpreadableProperty(prop)) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - var flags = 4 /* Property */ | 16777216 /* Optional */; - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + var flags = 4 /* SymbolFlags.Property */ | 16777216 /* SymbolFlags.Optional */; + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : addOptionality(getTypeOfSymbol(prop), /*isProperty*/ true); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -63256,7 +63468,7 @@ var ts; } } var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfosOfType(type)); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return spread; } } @@ -63266,31 +63478,31 @@ var ts; * and right = the new element to be spread. */ function getSpreadType(left, right, symbol, objectFlags, readonly) { - if (left.flags & 1 /* Any */ || right.flags & 1 /* Any */) { + if (left.flags & 1 /* TypeFlags.Any */ || right.flags & 1 /* TypeFlags.Any */) { return anyType; } - if (left.flags & 2 /* Unknown */ || right.flags & 2 /* Unknown */) { + if (left.flags & 2 /* TypeFlags.Unknown */ || right.flags & 2 /* TypeFlags.Unknown */) { return unknownType; } - if (left.flags & 131072 /* Never */) { + if (left.flags & 131072 /* TypeFlags.Never */) { return right; } - if (right.flags & 131072 /* Never */) { + if (right.flags & 131072 /* TypeFlags.Never */) { return left; } left = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly); - if (left.flags & 1048576 /* Union */) { + if (left.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); }) : errorType; } right = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly); - if (right.flags & 1048576 /* Union */) { + if (right.flags & 1048576 /* TypeFlags.Union */) { return checkCrossProductUnion([left, right]) ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); }) : errorType; } - if (right.flags & (528 /* BooleanLike */ | 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 1056 /* EnumLike */ | 67108864 /* NonPrimitive */ | 4194304 /* Index */)) { + if (right.flags & (528 /* TypeFlags.BooleanLike */ | 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 1056 /* TypeFlags.EnumLike */ | 67108864 /* TypeFlags.NonPrimitive */ | 4194304 /* TypeFlags.Index */)) { return left; } if (isGenericObjectType(left) || isGenericObjectType(right)) { @@ -63300,7 +63512,7 @@ var ts; // When the left type is an intersection, we may need to merge the last constituent of the // intersection with the right type. For example when the left type is 'T & { a: string }' // and the right type is '{ b: string }' we produce 'T & { a: string, b: string }'. - if (left.flags & 2097152 /* Intersection */) { + if (left.flags & 2097152 /* TypeFlags.Intersection */) { var types = left.types; var lastLeft = types[types.length - 1]; if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { @@ -63314,7 +63526,7 @@ var ts; var indexInfos = left === emptyObjectType ? getIndexInfosOfType(right) : getUnionIndexInfos([left, right]); for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) { var rightProp = _a[_i]; - if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* Private */ | 16 /* Protected */)) { + if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { skippedPrivateMembers.add(rightProp.escapedName); } else if (isSpreadableProperty(rightProp)) { @@ -63329,11 +63541,11 @@ var ts; if (members.has(leftProp.escapedName)) { var rightProp = members.get(leftProp.escapedName); var rightType = getTypeOfSymbol(rightProp); - if (rightProp.flags & 16777216 /* Optional */) { + if (rightProp.flags & 16777216 /* SymbolFlags.Optional */) { var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); - var flags = 4 /* Property */ | (leftProp.flags & 16777216 /* Optional */); + var flags = 4 /* SymbolFlags.Property */ | (leftProp.flags & 16777216 /* SymbolFlags.Optional */); var result = createSymbol(flags, leftProp.escapedName); - result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* Subtype */); + result.type = getUnionType([getTypeOfSymbol(leftProp), removeMissingOrUndefinedType(rightType)], 2 /* UnionReduction.Subtype */); result.leftSpread = leftProp; result.rightSpread = rightProp; result.declarations = declarations; @@ -63346,23 +63558,23 @@ var ts; } } var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(indexInfos, function (info) { return getIndexInfoWithReadonly(info, readonly); })); - spread.objectFlags |= 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */ | 2097152 /* ContainsSpread */ | objectFlags; + spread.objectFlags |= 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */ | 2097152 /* ObjectFlags.ContainsSpread */ | objectFlags; return spread; } /** We approximate own properties as non-methods plus methods that are inside the object literal */ function isSpreadableProperty(prop) { var _a; return !ts.some(prop.declarations, ts.isPrivateIdentifierClassElementDeclaration) && - (!(prop.flags & (8192 /* Method */ | 32768 /* GetAccessor */ | 65536 /* SetAccessor */)) || + (!(prop.flags & (8192 /* SymbolFlags.Method */ | 32768 /* SymbolFlags.GetAccessor */ | 65536 /* SymbolFlags.SetAccessor */)) || !((_a = prop.declarations) === null || _a === void 0 ? void 0 : _a.some(function (decl) { return ts.isClassLike(decl.parent); }))); } function getSpreadSymbol(prop, readonly) { - var isSetonlyAccessor = prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); + var isSetonlyAccessor = prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) { return prop; } - var flags = 4 /* Property */ | (prop.flags & 16777216 /* Optional */); - var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* Readonly */ : 0)); + var flags = 4 /* SymbolFlags.Property */ | (prop.flags & 16777216 /* SymbolFlags.Optional */); + var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 /* CheckFlags.Readonly */ : 0)); result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop); result.declarations = prop.declarations; result.nameType = getSymbolLinks(prop).nameType; @@ -63380,7 +63592,7 @@ var ts; return type; } function getFreshTypeOfLiteralType(type) { - if (type.flags & 2944 /* Literal */) { + if (type.flags & 2944 /* TypeFlags.Literal */) { if (!type.freshType) { var freshType = createLiteralType(type.flags, type.value, type.symbol, type); freshType.freshType = freshType; @@ -63391,39 +63603,39 @@ var ts; return type; } function getRegularTypeOfLiteralType(type) { - return type.flags & 2944 /* Literal */ ? type.regularType : - type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : + return type.flags & 2944 /* TypeFlags.Literal */ ? type.regularType : + type.flags & 1048576 /* TypeFlags.Union */ ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) : type; } function isFreshLiteralType(type) { - return !!(type.flags & 2944 /* Literal */) && type.freshType === type; + return !!(type.flags & 2944 /* TypeFlags.Literal */) && type.freshType === type; } function getStringLiteralType(value) { var type; return stringLiteralTypes.get(value) || - (stringLiteralTypes.set(value, type = createLiteralType(128 /* StringLiteral */, value)), type); + (stringLiteralTypes.set(value, type = createLiteralType(128 /* TypeFlags.StringLiteral */, value)), type); } function getNumberLiteralType(value) { var type; return numberLiteralTypes.get(value) || - (numberLiteralTypes.set(value, type = createLiteralType(256 /* NumberLiteral */, value)), type); + (numberLiteralTypes.set(value, type = createLiteralType(256 /* TypeFlags.NumberLiteral */, value)), type); } function getBigIntLiteralType(value) { var type; var key = ts.pseudoBigIntToString(value); return bigIntLiteralTypes.get(key) || - (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* BigIntLiteral */, value)), type); + (bigIntLiteralTypes.set(key, type = createLiteralType(2048 /* TypeFlags.BigIntLiteral */, value)), type); } function getEnumLiteralType(value, enumId, symbol) { var type; var qualifier = typeof value === "string" ? "@" : "#"; var key = enumId + qualifier + value; - var flags = 1024 /* EnumLiteral */ | (typeof value === "string" ? 128 /* StringLiteral */ : 256 /* NumberLiteral */); + var flags = 1024 /* TypeFlags.EnumLiteral */ | (typeof value === "string" ? 128 /* TypeFlags.StringLiteral */ : 256 /* TypeFlags.NumberLiteral */); return enumLiteralTypes.get(key) || (enumLiteralTypes.set(key, type = createLiteralType(flags, value, symbol)), type); } function getTypeFromLiteralTypeNode(node) { - if (node.literal.kind === 104 /* NullKeyword */) { + if (node.literal.kind === 104 /* SyntaxKind.NullKeyword */) { return nullType; } var links = getNodeLinks(node); @@ -63433,9 +63645,9 @@ var ts; return links.resolvedType; } function createUniqueESSymbolType(symbol) { - var type = createType(8192 /* UniqueESSymbol */); + var type = createType(8192 /* TypeFlags.UniqueESSymbol */); type.symbol = symbol; - type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol); + type.escapedName = "__@".concat(type.symbol.escapedName, "@").concat(getSymbolId(type.symbol)); return type; } function getESSymbolLikeTypeForNode(node) { @@ -63451,20 +63663,20 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */)) { if (!ts.isStatic(container) && (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } // inside x.prototype = { ... } - if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; } // /** @return {this} */ // x.prototype.m = function() { ... } - var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; - if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + var host = node.flags & 8388608 /* NodeFlags.JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; } // inside constructor function C() { ... } @@ -63486,17 +63698,17 @@ var ts; } function getArrayElementTypeNode(node) { switch (node.kind) { - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return getArrayElementTypeNode(node.type); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: if (node.elements.length === 1) { node = node.elements[0]; - if (node.kind === 186 /* RestType */ || node.kind === 197 /* NamedTupleMember */ && node.dotDotDotToken) { + if (node.kind === 186 /* SyntaxKind.RestType */ || node.kind === 197 /* SyntaxKind.NamedTupleMember */ && node.dotDotDotToken) { return getArrayElementTypeNode(node.type); } } break; - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return node.elementType; } return undefined; @@ -63512,99 +63724,99 @@ var ts; } function getTypeFromTypeNodeWorker(node) { switch (node.kind) { - case 130 /* AnyKeyword */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: + case 130 /* SyntaxKind.AnyKeyword */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return anyType; - case 155 /* UnknownKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: return unknownType; - case 150 /* StringKeyword */: + case 150 /* SyntaxKind.StringKeyword */: return stringType; - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return numberType; - case 158 /* BigIntKeyword */: + case 158 /* SyntaxKind.BigIntKeyword */: return bigintType; - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return booleanType; - case 151 /* SymbolKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: return esSymbolType; - case 114 /* VoidKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: return voidType; - case 153 /* UndefinedKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: return undefinedType; - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: // TODO(rbuckton): `NullKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service. return nullType; - case 143 /* NeverKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return neverType; - case 148 /* ObjectKeyword */: - return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; - case 138 /* IntrinsicKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: + return node.flags & 262144 /* NodeFlags.JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType; + case 138 /* SyntaxKind.IntrinsicKeyword */: return intrinsicMarkerType; - case 192 /* ThisType */: - case 108 /* ThisKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 108 /* SyntaxKind.ThisKeyword */: // TODO(rbuckton): `ThisKeyword` is no longer a `TypeNode`, but we defensively allow it here because of incorrect casts in the Language Service and because of `isPartOfTypeNode`. return getTypeFromThisTypeNode(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return getTypeFromLiteralTypeNode(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return getTypeFromTypeReference(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? voidType : booleanType; - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return getTypeFromTypeQueryNode(node); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return getTypeFromArrayOrTupleTypeNode(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return getTypeFromOptionalTypeNode(node); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return getTypeFromUnionTypeNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return getTypeFromNamedTupleTypeNode(node); - case 191 /* ParenthesizedType */: - case 315 /* JSDocNonNullableType */: - case 309 /* JSDocTypeExpression */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: return getTypeFromRestTypeNode(node); - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 182 /* TypeLiteral */: - case 322 /* JSDocTypeLiteral */: - case 317 /* JSDocFunctionType */: - case 323 /* JSDocSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 323 /* SyntaxKind.JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return getTypeFromMappedTypeNode(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return getTypeFromInferTypeNode(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return getTypeFromTemplateTypeNode(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier, qualified name, or property access expression is a type expression // Callers should first ensure this by calling `isPartOfTypeNode` // TODO(rbuckton): These aren't valid TypeNodes, but we treat them as such because of `isPartOfTypeNode`, which returns `true` for things that aren't `TypeNode`s. - case 79 /* Identifier */: - case 161 /* QualifiedName */: - case 206 /* PropertyAccessExpression */: + case 79 /* SyntaxKind.Identifier */: + case 161 /* SyntaxKind.QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -63642,9 +63854,9 @@ var ts; } function getMappedType(type, mapper) { switch (mapper.kind) { - case 0 /* Simple */: + case 0 /* TypeMapKind.Simple */: return type === mapper.source ? mapper.target : type; - case 1 /* Array */: + case 1 /* TypeMapKind.Array */: { var sources = mapper.sources; var targets = mapper.targets; for (var i = 0; i < sources.length; i++) { @@ -63653,25 +63865,39 @@ var ts; } } return type; - case 2 /* Function */: + } + case 2 /* TypeMapKind.Deferred */: { + var sources = mapper.sources; + var targets = mapper.targets; + for (var i = 0; i < sources.length; i++) { + if (type === sources[i]) { + return targets[i](); + } + } + return type; + } + case 3 /* TypeMapKind.Function */: return mapper.func(type); - case 3 /* Composite */: - case 4 /* Merged */: + case 4 /* TypeMapKind.Composite */: + case 5 /* TypeMapKind.Merged */: var t1 = getMappedType(type, mapper.mapper1); - return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + return t1 !== type && mapper.kind === 4 /* TypeMapKind.Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); } } function makeUnaryTypeMapper(source, target) { - return { kind: 0 /* Simple */, source: source, target: target }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 0 /* TypeMapKind.Simple */, source: source, target: target }); } function makeArrayTypeMapper(sources, targets) { - return { kind: 1 /* Array */, sources: sources, targets: targets }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 1 /* TypeMapKind.Array */, sources: sources, targets: targets }); } - function makeFunctionTypeMapper(func) { - return { kind: 2 /* Function */, func: func }; + function makeFunctionTypeMapper(func, debugInfo) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 3 /* TypeMapKind.Function */, func: func, debugInfo: ts.Debug.isDebugging ? debugInfo : undefined }); + } + function makeDeferredTypeMapper(sources, targets) { + return ts.Debug.attachDebugPrototypeIfDebug({ kind: 2 /* TypeMapKind.Deferred */, sources: sources, targets: targets }); } function makeCompositeTypeMapper(kind, mapper1, mapper2) { - return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; + return ts.Debug.attachDebugPrototypeIfDebug({ kind: kind, mapper1: mapper1, mapper2: mapper2 }); } function createTypeEraser(sources) { return createTypeMapper(sources, /*targets*/ undefined); @@ -63681,19 +63907,20 @@ var ts; * This is used during inference when instantiating type parameter defaults. */ function createBackreferenceMapper(context, index) { - return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); + var forwardInferences = context.inferences.slice(index); + return createTypeMapper(ts.map(forwardInferences, function (i) { return i.typeParameter; }), ts.map(forwardInferences, function () { return unknownType; })); } function combineTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(4 /* TypeMapKind.Composite */, mapper1, mapper2) : mapper2; } function mergeTypeMappers(mapper1, mapper2) { - return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2; + return mapper1 ? makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, mapper1, mapper2) : mapper2; } function prependTypeMapping(source, target, mapper) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, makeUnaryTypeMapper(source, target), mapper); } function appendTypeMapping(mapper, source, target) { - return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target)); + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(5 /* TypeMapKind.Merged */, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), @@ -63726,7 +63953,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* PropagatingFlags */); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 39 /* SignatureFlags.PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -63738,7 +63965,7 @@ var ts; // be affected by instantiation, simply return the symbol itself. return symbol; } - if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + if (ts.getCheckFlags(symbol) & 1 /* CheckFlags.Instantiated */) { // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -63747,7 +63974,7 @@ var ts; } // Keep the flags from the symbol we're instantiating. Mark that is instantiated, and // also transient so that we can just store data on it directly. - var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* Instantiated */ | ts.getCheckFlags(symbol) & (8 /* Readonly */ | 4096 /* Late */ | 16384 /* OptionalParameter */ | 32768 /* RestParameter */)); + var result = createSymbol(symbol.flags, symbol.escapedName, 1 /* CheckFlags.Instantiated */ | ts.getCheckFlags(symbol) & (8 /* CheckFlags.Readonly */ | 4096 /* CheckFlags.Late */ | 16384 /* CheckFlags.OptionalParameter */ | 32768 /* CheckFlags.RestParameter */)); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -63761,12 +63988,12 @@ var ts; return result; } function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { - var declaration = type.objectFlags & 4 /* Reference */ ? type.node : - type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : + var declaration = type.objectFlags & 4 /* ObjectFlags.Reference */ ? type.node : + type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */ ? type.node : type.symbol.declarations[0]; var links = getNodeLinks(declaration); - var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : - type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var target = type.objectFlags & 4 /* ObjectFlags.Reference */ ? links.resolvedType : + type.objectFlags & 64 /* ObjectFlags.Instantiated */ ? type.target : type; var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type @@ -63779,8 +64006,8 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; - typeParameters = (target.objectFlags & (4 /* Reference */ | 8388608 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? + var allDeclarations_1 = type.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) ? [declaration] : type.symbol.declarations; + typeParameters = (target.objectFlags & (4 /* ObjectFlags.Reference */ | 8388608 /* ObjectFlags.InstantiationExpressionType */) || target.symbol.flags & 8192 /* SymbolFlags.Method */ || target.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -63801,8 +64028,8 @@ var ts; var result = target.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : - target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : + result = target.objectFlags & 4 /* ObjectFlags.Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) : + target.objectFlags & 32 /* ObjectFlags.Mapped */ ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) : instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments); target.instantiations.set(id, result); } @@ -63811,8 +64038,8 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.parent.kind === 178 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 200 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.parent.kind === 178 /* SyntaxKind.TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 200 /* SyntaxKind.ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -63821,7 +64048,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 235 /* Block */ || n.kind === 189 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 235 /* SyntaxKind.Block */ || n.kind === 189 /* SyntaxKind.ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -63830,15 +64057,15 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return !!tp.isThisType; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return true; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return !node.type && !!node.body || ts.some(node.typeParameters, containsReference) || ts.some(node.parameters, containsReference) || @@ -63849,9 +64076,9 @@ var ts; } function getHomomorphicTypeVariable(type) { var constraintType = getConstraintTypeFromMappedType(type); - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { var typeVariable = getActualTypeVariable(constraintType.type); - if (typeVariable.flags & 262144 /* TypeParameter */) { + if (typeVariable.flags & 262144 /* TypeFlags.TypeParameter */) { return typeVariable; } } @@ -63873,10 +64100,10 @@ var ts; var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) { - if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) { + if (t.flags & (3 /* TypeFlags.AnyOrUnknown */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && t !== wildcardType && !isErrorType(t)) { if (!type.declaration.nameType) { var constraint = void 0; - if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 && + if (isArrayType(t) || t.flags & 1 /* TypeFlags.Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* TypeSystemPropertyName.ImmediateBaseConstraint */) < 0 && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, isArrayOrTupleType)) { return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper)); } @@ -63897,7 +64124,7 @@ var ts; return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments); } function getModifiedReadonlyState(state, modifiers) { - return modifiers & 1 /* IncludeReadonly */ ? true : modifiers & 2 /* ExcludeReadonly */ ? false : state; + return modifiers & 1 /* MappedTypeModifiers.IncludeReadonly */ ? true : modifiers & 2 /* MappedTypeModifiers.ExcludeReadonly */ ? false : state; } function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) { // When a tuple type is generic (i.e. when it contains variadic elements), we want to eagerly map the @@ -63906,14 +64133,14 @@ var ts; // normalization to resolve the non-generic parts of the resulting tuple. var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) { - var singleton = elementFlags[i] & 8 /* Variadic */ ? t : - elementFlags[i] & 4 /* Rest */ ? createArrayType(t) : + var singleton = elementFlags[i] & 8 /* ElementFlags.Variadic */ ? t : + elementFlags[i] & 4 /* ElementFlags.Rest */ ? createArrayType(t) : createTupleType([t], [elementFlags[i]]); // The singleton is never a generic tuple type, so it is safe to recurse here. return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper)); }); var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType)); - return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* Variadic */; }), newReadonly); + return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8 /* ElementFlags.Variadic */; }), newReadonly); } function instantiateMappedArrayType(arrayType, mappedType, mapper) { var elementType = instantiateMappedTypeTemplate(mappedType, numberType, /*isOptional*/ true, mapper); @@ -63923,11 +64150,11 @@ var ts; function instantiateMappedTupleType(tupleType, mappedType, mapper) { var elementFlags = tupleType.target.elementFlags; var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { - return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* Optional */), mapper); + return instantiateMappedTypeTemplate(mappedType, getStringLiteralType("" + i), !!(elementFlags[i] & 2 /* ElementFlags.Optional */), mapper); }); var modifiers = getMappedTypeModifiers(mappedType); - var newTupleModifiers = modifiers & 4 /* IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* Required */ ? 2 /* Optional */ : f; }) : - modifiers & 8 /* ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var newTupleModifiers = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ ? ts.map(elementFlags, function (f) { return f & 1 /* ElementFlags.Required */ ? 2 /* ElementFlags.Optional */ : f; }) : + modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ ? ts.map(elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : elementFlags; var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers); return ts.contains(elementTypes, errorType) ? errorType : @@ -63937,13 +64164,13 @@ var ts; var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType, /*isProperty*/ true) : - strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + return strictNullChecks && modifiers & 4 /* MappedTypeModifiers.IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */) ? getOptionalType(propType, /*isProperty*/ true) : + strictNullChecks && modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */) : propType; } function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) { - var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); - if (type.objectFlags & 32 /* Mapped */) { + var result = createObjectType(type.objectFlags | 64 /* ObjectFlags.Instantiated */, type.symbol); + if (type.objectFlags & 32 /* ObjectFlags.Mapped */) { result.declaration = type.declaration; // C.f. instantiateSignature var origTypeParameter = getTypeParameterFromMappedType(type); @@ -63952,13 +64179,14 @@ var ts; mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper); freshTypeParameter.mapper = mapper; } - if (type.objectFlags & 8388608 /* InstantiationExpressionType */) { + if (type.objectFlags & 8388608 /* ObjectFlags.InstantiationExpressionType */) { result.node = type.node; } result.target = type; result.mapper = mapper; result.aliasSymbol = aliasSymbol || type.aliasSymbol; result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); + result.objectFlags |= result.aliasTypeArguments ? getPropagatingFlagsOfTypes(result.aliasTypeArguments) : 0; return result; } function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) { @@ -63977,7 +64205,7 @@ var ts; // Distributive conditional types are distributed over union types. For example, when the // distributive conditional type T extends U ? X : Y is instantiated with A | B for T, the // result is (A extends U ? X : Y) | (B extends U ? X : Y). - result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? + result = distributionType && checkType_1 !== distributionType && distributionType.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapTypeWithAlias(getReducedType(distributionType), function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, newMapper_1)); }, aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper_1, aliasSymbol, aliasTypeArguments); root.instantiations.set(id, result); @@ -63997,7 +64225,7 @@ var ts; // We have reached 100 recursive type instantiations, or 5M type instantiations caused by the same statement // or expression. There is a very high likelyhood we're dealing with a combination of infinite generic types // that perpetually generate new type identities, so we stop the recursion here by yielding the error type. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount }); error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } @@ -64010,62 +64238,62 @@ var ts; } function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) { var flags = type.flags; - if (flags & 262144 /* TypeParameter */) { + if (flags & 262144 /* TypeFlags.TypeParameter */) { return getMappedType(type, mapper); } - if (flags & 524288 /* Object */) { + if (flags & 524288 /* TypeFlags.Object */) { var objectFlags = type.objectFlags; - if (objectFlags & (4 /* Reference */ | 16 /* Anonymous */ | 32 /* Mapped */)) { - if (objectFlags & 4 /* Reference */ && !type.node) { + if (objectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */)) { + if (objectFlags & 4 /* ObjectFlags.Reference */ && !type.node) { var resolvedTypeArguments = type.resolvedTypeArguments; var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type; } - if (objectFlags & 1024 /* ReverseMapped */) { + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { return instantiateReverseMappedType(type, mapper); } return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments); } return type; } - if (flags & 3145728 /* UnionOrIntersection */) { - var origin = type.flags & 1048576 /* Union */ ? type.origin : undefined; - var types = origin && origin.flags & 3145728 /* UnionOrIntersection */ ? origin.types : type.types; + if (flags & 3145728 /* TypeFlags.UnionOrIntersection */) { + var origin = type.flags & 1048576 /* TypeFlags.Union */ ? type.origin : undefined; + var types = origin && origin.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? origin.types : type.types; var newTypes = instantiateTypes(types, mapper); if (newTypes === types && aliasSymbol === type.aliasSymbol) { return type; } var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); - return flags & 2097152 /* Intersection */ || origin && origin.flags & 2097152 /* Intersection */ ? + return flags & 2097152 /* TypeFlags.Intersection */ || origin && origin.flags & 2097152 /* TypeFlags.Intersection */ ? getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) : - getUnionType(newTypes, 1 /* Literal */, newAliasSymbol, newAliasTypeArguments); + getUnionType(newTypes, 1 /* UnionReduction.Literal */, newAliasSymbol, newAliasTypeArguments); } - if (flags & 4194304 /* Index */) { + if (flags & 4194304 /* TypeFlags.Index */) { return getIndexType(instantiateType(type.type, mapper)); } - if (flags & 134217728 /* TemplateLiteral */) { + if (flags & 134217728 /* TypeFlags.TemplateLiteral */) { return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper)); } - if (flags & 268435456 /* StringMapping */) { + if (flags & 268435456 /* TypeFlags.StringMapping */) { return getStringMappingType(type.symbol, instantiateType(type.type, mapper)); } - if (flags & 8388608 /* IndexedAccess */) { + if (flags & 8388608 /* TypeFlags.IndexedAccess */) { var newAliasSymbol = aliasSymbol || type.aliasSymbol; var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper); return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.accessFlags, /*accessNode*/ undefined, newAliasSymbol, newAliasTypeArguments); } - if (flags & 16777216 /* Conditional */) { + if (flags & 16777216 /* TypeFlags.Conditional */) { return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments); } - if (flags & 33554432 /* Substitution */) { + if (flags & 33554432 /* TypeFlags.Substitution */) { var maybeVariable = instantiateType(type.baseType, mapper); - if (maybeVariable.flags & 8650752 /* TypeVariable */) { + if (maybeVariable.flags & 8650752 /* TypeFlags.TypeVariable */) { return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper)); } else { var sub = instantiateType(type.substitute, mapper); - if (sub.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { + if (sub.flags & 3 /* TypeFlags.AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) { return maybeVariable; } return sub; @@ -64075,11 +64303,11 @@ var ts; } function instantiateReverseMappedType(type, mapper) { var innerMappedType = instantiateType(type.mappedType, mapper); - if (!(ts.getObjectFlags(innerMappedType) & 32 /* Mapped */)) { + if (!(ts.getObjectFlags(innerMappedType) & 32 /* ObjectFlags.Mapped */)) { return type; } var innerIndexType = instantiateType(type.constraintType, mapper); - if (!(innerIndexType.flags & 4194304 /* Index */)) { + if (!(innerIndexType.flags & 4194304 /* TypeFlags.Index */)) { return type; } var instantiated = inferTypeForHomomorphicMappedType(instantiateType(type.source, mapper), innerMappedType, innerIndexType); @@ -64089,15 +64317,15 @@ var ts; return type; // Nested invocation of `inferTypeForHomomorphicMappedType` or the `source` instantiated into something unmappable } function getUniqueLiteralFilledInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.uniqueLiteralFilledInstantiation || (type.uniqueLiteralFilledInstantiation = instantiateType(type, uniqueLiteralMapper)); } function getPermissiveInstantiation(type) { - return type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */) ? type : + return type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */) ? type : type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper)); } function getRestrictiveInstantiation(type) { - if (type.flags & (131068 /* Primitive */ | 3 /* AnyOrUnknown */ | 131072 /* Never */)) { + if (type.flags & (131068 /* TypeFlags.Primitive */ | 3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) { return type; } if (type.restrictiveInstantiation) { @@ -64118,35 +64346,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 221 /* BinaryExpression */: - return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && + case 221 /* SyntaxKind.BinaryExpression */: + return (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return isContextSensitive(node.initializer); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isContextSensitive(node.expression); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 285 /* JsxAttribute */: { + case 285 /* SyntaxKind.JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 288 /* JsxExpression */: { + case 288 /* SyntaxKind.JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -64160,17 +64388,17 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 235 /* SyntaxKind.Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && isContextSensitiveFunctionLikeDeclaration(func); } function getTypeWithoutSignatures(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length || resolved.callSignatures.length) { - var result = createObjectType(16 /* Anonymous */, type.symbol); + var result = createObjectType(16 /* ObjectFlags.Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = ts.emptyArray; @@ -64179,7 +64407,7 @@ var ts; return result; } } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures)); } return type; @@ -64189,13 +64417,13 @@ var ts; return isTypeRelatedTo(source, target, identityRelation); } function compareTypesIdentical(source, target) { - return isTypeRelatedTo(source, target, identityRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, identityRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesAssignable(source, target) { - return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, assignableRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function compareTypesSubtypeOf(source, target) { - return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* True */ : 0 /* False */; + return isTypeRelatedTo(source, target, subtypeRelation) ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } function isTypeSubtypeOf(source, target) { return isTypeRelatedTo(source, target, subtypeRelation); @@ -64212,11 +64440,11 @@ var ts; // Note that this check ignores type parameters and only considers the // inheritance hierarchy. function isTypeDerivedFrom(source, target) { - return source.flags & 1048576 /* Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : - target.flags & 1048576 /* Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : - source.flags & 58982400 /* InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : - target === globalObjectType ? !!(source.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */)) : - target === globalFunctionType ? !!(source.flags & 524288 /* Object */) && isFunctionObjectType(source) : + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) : + target.flags & 1048576 /* TypeFlags.Union */ ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) : + source.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) : + target === globalObjectType ? !!(source.flags & (524288 /* TypeFlags.Object */ | 67108864 /* TypeFlags.NonPrimitive */)) : + target === globalFunctionType ? !!(source.flags & 524288 /* TypeFlags.Object */) && isFunctionObjectType(source) : hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType)); } /** @@ -64254,7 +64482,7 @@ var ts; return false; } function isOrHasGenericConditional(type) { - return !!(type.flags & 16777216 /* Conditional */ || (type.flags & 2097152 /* Intersection */ && ts.some(type.types, isOrHasGenericConditional))); + return !!(type.flags & 16777216 /* TypeFlags.Conditional */ || (type.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(type.types, isOrHasGenericConditional))); } function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { if (!node || isOrHasGenericConditional(target)) @@ -64264,35 +64492,35 @@ var ts; return true; } switch (node.kind) { - case 288 /* JsxExpression */: - case 212 /* ParenthesizedExpression */: + case 288 /* SyntaxKind.JsxExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 27 /* CommaToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 27 /* SyntaxKind.CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; } function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) { - var callSignatures = getSignaturesOfType(source, 0 /* Call */); - var constructSignatures = getSignaturesOfType(source, 1 /* Construct */); + var callSignatures = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructSignatures = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) { var signatures = _a[_i]; if (ts.some(signatures, function (s) { var returnType = getReturnTypeOfSignature(s); - return !(returnType.flags & (1 /* Any */ | 131072 /* Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); + return !(returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */)) && checkTypeRelatedTo(returnType, target, relation, /*errorNode*/ undefined); })) { var resultObj = errorOutputContainer || {}; checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj); @@ -64316,7 +64544,7 @@ var ts; if (!sourceSig) { return false; } - var targetSignatures = getSignaturesOfType(target, 0 /* Call */); + var targetSignatures = getSignaturesOfType(target, 0 /* SignatureKind.Call */); if (!ts.length(targetSignatures)) { return false; } @@ -64334,7 +64562,7 @@ var ts; if (target.symbol && ts.length(target.symbol.declarations)) { ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); } - if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0 + if ((ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */) === 0 // exclude cases where source itself is promisy - this way we don't make a suggestion when relating // an IPromise and a Promise that are slightly different && !getTypeOfPropertyOfType(sourceReturn, "then") @@ -64351,7 +64579,7 @@ var ts; if (idx) { return idx; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { var best = getBestMatchingType(source, target); if (best) { return getIndexedAccessTypeOrUndefined(best, nameType); @@ -64361,7 +64589,7 @@ var ts; function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) { next.contextualType = sourcePropType; try { - return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType); + return checkExpressionForMutableLocation(next, 1 /* CheckMode.Contextual */, sourcePropType); } finally { next.contextualType = undefined; @@ -64378,7 +64606,7 @@ var ts; for (var status = iterator.next(); !status.done; status = iterator.next()) { var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage; var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType); - if (!targetPropType || targetPropType.flags & 8388608 /* IndexedAccess */) + if (!targetPropType || targetPropType.flags & 8388608 /* TypeFlags.IndexedAccess */) continue; // Don't elaborate on indexes on generic variables var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType); if (!sourcePropType) @@ -64398,8 +64626,8 @@ var ts; resultObj.errors = [diag]; } else { - var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* Optional */); - var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* Optional */); + var targetIsOptional = !!(propName && (getPropertyOfType(target, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); + var sourceIsOptional = !!(propName && (getPropertyOfType(source, propName) || unknownSymbol).flags & 16777216 /* SymbolFlags.Optional */); targetPropType = removeMissingType(targetPropType, targetIsOptional); sourcePropType = removeMissingType(sourcePropType, targetIsOptional && sourceIsOptional); var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); @@ -64423,7 +64651,7 @@ var ts; if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) { var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0]; if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) { - ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); + ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(targetNode, ts.Diagnostics.The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1, propertyName && !(nameType.flags & 8192 /* TypeFlags.UniqueESSymbol */) ? ts.unescapeLeadingUnderscores(propertyName) : typeToString(nameType), typeToString(target))); } } } @@ -64489,18 +64717,18 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: if (child.containsOnlyTriviaWhiteSpaces) { break; // Whitespace only jsx text isn't real jsx text } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 278 /* JsxElement */: - case 279 /* JsxSelfClosingElement */: - case 282 /* JsxFragment */: + case 278 /* SyntaxKind.JsxElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 282 /* SyntaxKind.JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -64525,7 +64753,7 @@ var ts; var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); }); if (moreThanOneRealChildren) { if (arrayLikeTargetParts !== neverType) { - var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* Normal */)); + var realSource = createTupleType(checkJsxChildren(containingElement, 0 /* CheckMode.Normal */)); var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic); result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result; } @@ -64607,7 +64835,7 @@ var ts; }); } function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & (131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) return false; if (isTupleLikeType(source)) { return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); @@ -64617,7 +64845,7 @@ var ts; var oldContext = node.contextualType; node.contextualType = target; try { - var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); + var tupleizedType = checkArrayLiteral(node, 1 /* CheckMode.Contextual */, /*forceTuple*/ true); node.contextualType = oldContext; if (isTupleLikeType(tupleizedType)) { return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); @@ -64642,17 +64870,17 @@ var ts; prop = _a[_i]; if (ts.isSpreadAssignment(prop)) return [3 /*break*/, 7]; - type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* StringOrNumberLiteralOrUnique */); - if (!type || (type.flags & 131072 /* Never */)) { + type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); + if (!type || (type.flags & 131072 /* TypeFlags.Never */)) { return [3 /*break*/, 7]; } _b = prop.kind; switch (_b) { - case 173 /* SetAccessor */: return [3 /*break*/, 2]; - case 172 /* GetAccessor */: return [3 /*break*/, 2]; - case 169 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 297 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 296 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 173 /* SyntaxKind.SetAccessor */: return [3 /*break*/, 2]; + case 172 /* SyntaxKind.GetAccessor */: return [3 /*break*/, 2]; + case 169 /* SyntaxKind.MethodDeclaration */: return [3 /*break*/, 2]; + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 296 /* SyntaxKind.PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -64674,7 +64902,7 @@ var ts; }); } function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) { - if (target.flags & 131068 /* Primitive */) + if (target.flags & (131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) return false; return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer); } @@ -64686,8 +64914,8 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* IgnoreReturnTypes */ : 0, /*reportErrors*/ false, - /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* False */; + return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 /* SignatureCheckMode.IgnoreReturnTypes */ : 0, /*reportErrors*/ false, + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable, /*reportUnreliableMarkers*/ undefined) !== 0 /* Ternary.False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` @@ -64703,16 +64931,16 @@ var ts; function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isAnySignature(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var targetCount = getParameterCount(target); var sourceHasMoreParameters = !hasEffectiveRestParameter(target) && - (checkMode & 8 /* StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); + (checkMode & 8 /* SignatureCheckMode.StrictArity */ ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount); if (sourceHasMoreParameters) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (source.typeParameters && source.typeParameters !== target.typeParameters) { target = getCanonicalSignature(target); @@ -64724,10 +64952,10 @@ var ts; if (sourceRestType || targetRestType) { void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers); } - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 169 /* MethodDeclaration */ && - kind !== 168 /* MethodSignature */ && kind !== 171 /* Constructor */; - var result = -1 /* True */; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + var strictVariance = !(checkMode & 3 /* SignatureCheckMode.Callback */) && strictFunctionTypes && kind !== 169 /* SyntaxKind.MethodDeclaration */ && + kind !== 168 /* SyntaxKind.MethodSignature */ && kind !== 171 /* SyntaxKind.Constructor */; + var result = -1 /* Ternary.True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { var targetThisType = getThisTypeOfSignature(target); @@ -64739,7 +64967,7 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -64758,27 +64986,27 @@ var ts; // similar to return values, callback parameters are output positions. This means that a Promise, // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) // with respect to T. - var sourceSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); - var targetSig = checkMode & 3 /* Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); + var sourceSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = checkMode & 3 /* SignatureCheckMode.Callback */ ? undefined : getSingleCallSignature(getNonNullableType(targetType)); var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && - (getTypeFacts(sourceType) & 50331648 /* IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* IsUndefinedOrNull */); + (getTypeFacts(sourceType) & 50331648 /* TypeFacts.IsUndefinedOrNull */) === (getTypeFacts(targetType) & 50331648 /* TypeFacts.IsUndefinedOrNull */); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* StrictArity */) | (strictVariance ? 2 /* StrictCallback */ : 1 /* BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : - !(checkMode & 3 /* Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8 /* SignatureCheckMode.StrictArity */) | (strictVariance ? 2 /* SignatureCheckMode.StrictCallback */ : 1 /* SignatureCheckMode.BivariantCallback */), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) : + !(checkMode & 3 /* SignatureCheckMode.Callback */) && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); // With strict arity, (x: number | undefined) => void is a subtype of (x?: number | undefined) => void - if (related && checkMode & 8 /* StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { - related = 0 /* False */; + if (related && checkMode & 8 /* SignatureCheckMode.StrictArity */ && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, /*reportErrors*/ false)) { + related = 0 /* Ternary.False */; } if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i))); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } } - if (!(checkMode & 4 /* IgnoreReturnTypes */)) { + if (!(checkMode & 4 /* SignatureCheckMode.IgnoreReturnTypes */)) { // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType @@ -64801,14 +65029,14 @@ var ts; if (reportErrors) { errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } else { // When relating callback signatures, we still need to relate return types bi-variantly as otherwise // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } // wouldn't be co-variant for T without this rule. - result &= checkMode & 1 /* BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + result &= checkMode & 1 /* SignatureCheckMode.BivariantCallback */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); if (!result && reportErrors && incompatibleErrorReporter) { incompatibleErrorReporter(sourceReturnType, targetReturnType); @@ -64823,21 +65051,21 @@ var ts; errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { + if (source.kind === 1 /* TypePredicateKind.Identifier */ || source.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var related = source.type === target.type ? -1 /* True */ : + var related = source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : - 0 /* False */; - if (related === 0 /* False */ && reportErrors) { + 0 /* Ternary.False */; + if (related === 0 /* Ternary.False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } return related; @@ -64863,33 +65091,33 @@ var ts; t.indexInfos.length === 0; } function isEmptyObjectType(type) { - return type.flags & 524288 /* Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : - type.flags & 67108864 /* NonPrimitive */ ? true : - type.flags & 1048576 /* Union */ ? ts.some(type.types, isEmptyObjectType) : - type.flags & 2097152 /* Intersection */ ? ts.every(type.types, isEmptyObjectType) : + return type.flags & 524288 /* TypeFlags.Object */ ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 67108864 /* TypeFlags.NonPrimitive */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, isEmptyObjectType) : + type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isEmptyObjectType) : false; } function isEmptyAnonymousObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */ && (type.members && isEmptyResolvedType(type) || - type.symbol && type.symbol.flags & 2048 /* TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && (type.members && isEmptyResolvedType(type) || + type.symbol && type.symbol.flags & 2048 /* SymbolFlags.TypeLiteral */ && getMembersOfSymbol(type.symbol).size === 0)); } function isUnknownLikeUnionType(type) { - if (strictNullChecks && type.flags & 1048576 /* Union */) { - if (!(type.objectFlags & 33554432 /* IsUnknownLikeUnionComputed */)) { + if (strictNullChecks && type.flags & 1048576 /* TypeFlags.Union */) { + if (!(type.objectFlags & 33554432 /* ObjectFlags.IsUnknownLikeUnionComputed */)) { var types = type.types; - type.objectFlags |= 33554432 /* IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* Undefined */ && - types[1].flags & 65536 /* Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* IsUnknownLikeUnion */ : 0); + type.objectFlags |= 33554432 /* ObjectFlags.IsUnknownLikeUnionComputed */ | (types.length >= 3 && types[0].flags & 32768 /* TypeFlags.Undefined */ && + types[1].flags & 65536 /* TypeFlags.Null */ && ts.some(types, isEmptyAnonymousObjectType) ? 67108864 /* ObjectFlags.IsUnknownLikeUnion */ : 0); } - return !!(type.objectFlags & 67108864 /* IsUnknownLikeUnion */); + return !!(type.objectFlags & 67108864 /* ObjectFlags.IsUnknownLikeUnion */); } return false; } function containsUndefinedType(type) { - return !!((type.flags & 1048576 /* Union */ ? type.types[0] : type).flags & 32768 /* Undefined */); + return !!((type.flags & 1048576 /* TypeFlags.Union */ ? type.types[0] : type).flags & 32768 /* TypeFlags.Undefined */); } function isStringIndexSignatureOnlyType(type) { - return type.flags & 524288 /* Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || - type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || + return type.flags & 524288 /* TypeFlags.Object */ && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfosOfType(type).length === 1 && !!getIndexInfoOfType(type, stringType) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(type.types, isStringIndexSignatureOnlyType) || false; } function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) { @@ -64898,83 +65126,83 @@ var ts; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); var entry = enumRelation.get(id); - if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { - return !!(entry & 1 /* Succeeded */); + if (entry !== undefined && !(!(entry & 4 /* RelationComparisonResult.Reported */) && entry & 2 /* RelationComparisonResult.Failed */ && errorReporter)) { + return !!(entry & 1 /* RelationComparisonResult.Succeeded */); } - if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* SymbolFlags.RegularEnum */) || !(targetSymbol.flags & 256 /* SymbolFlags.RegularEnum */)) { + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) { var property = _a[_i]; - if (property.flags & 8 /* EnumMember */) { + if (property.flags & 8 /* SymbolFlags.EnumMember */) { var targetProperty = getPropertyOfType(targetEnumType, property.escapedName); - if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { + if (!targetProperty || !(targetProperty.flags & 8 /* SymbolFlags.EnumMember */)) { if (errorReporter) { - errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); + errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* TypeFormatFlags.UseFullyQualifiedType */)); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */ | 4 /* RelationComparisonResult.Reported */); } else { - enumRelation.set(id, 2 /* Failed */); + enumRelation.set(id, 2 /* RelationComparisonResult.Failed */); } return false; } } } - enumRelation.set(id, 1 /* Succeeded */); + enumRelation.set(id, 1 /* RelationComparisonResult.Succeeded */); return true; } function isSimpleTypeRelatedTo(source, target, relation, errorReporter) { var s = source.flags; var t = target.flags; - if (t & 3 /* AnyOrUnknown */ || s & 131072 /* Never */ || source === wildcardType) + if (t & 3 /* TypeFlags.AnyOrUnknown */ || s & 131072 /* TypeFlags.Never */ || source === wildcardType) return true; - if (t & 131072 /* Never */) + if (t & 131072 /* TypeFlags.Never */) return false; - if (s & 402653316 /* StringLike */ && t & 4 /* String */) + if (s & 402653316 /* TypeFlags.StringLike */ && t & 4 /* TypeFlags.String */) return true; - if (s & 128 /* StringLiteral */ && s & 1024 /* EnumLiteral */ && - t & 128 /* StringLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 128 /* TypeFlags.StringLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 128 /* TypeFlags.StringLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 296 /* NumberLike */ && t & 8 /* Number */) + if (s & 296 /* TypeFlags.NumberLike */ && t & 8 /* TypeFlags.Number */) return true; - if (s & 256 /* NumberLiteral */ && s & 1024 /* EnumLiteral */ && - t & 256 /* NumberLiteral */ && !(t & 1024 /* EnumLiteral */) && + if (s & 256 /* TypeFlags.NumberLiteral */ && s & 1024 /* TypeFlags.EnumLiteral */ && + t & 256 /* TypeFlags.NumberLiteral */ && !(t & 1024 /* TypeFlags.EnumLiteral */) && source.value === target.value) return true; - if (s & 2112 /* BigIntLike */ && t & 64 /* BigInt */) + if (s & 2112 /* TypeFlags.BigIntLike */ && t & 64 /* TypeFlags.BigInt */) return true; - if (s & 528 /* BooleanLike */ && t & 16 /* Boolean */) + if (s & 528 /* TypeFlags.BooleanLike */ && t & 16 /* TypeFlags.Boolean */) return true; - if (s & 12288 /* ESSymbolLike */ && t & 4096 /* ESSymbol */) + if (s & 12288 /* TypeFlags.ESSymbolLike */ && t & 4096 /* TypeFlags.ESSymbol */) return true; - if (s & 32 /* Enum */ && t & 32 /* Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 32 /* TypeFlags.Enum */ && t & 32 /* TypeFlags.Enum */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 1024 /* EnumLiteral */ && t & 1024 /* EnumLiteral */) { - if (s & 1048576 /* Union */ && t & 1048576 /* Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) + if (s & 1024 /* TypeFlags.EnumLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */) { + if (s & 1048576 /* TypeFlags.Union */ && t & 1048576 /* TypeFlags.Union */ && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true; - if (s & 2944 /* Literal */ && t & 2944 /* Literal */ && + if (s & 2944 /* TypeFlags.Literal */ && t & 2944 /* TypeFlags.Literal */ && source.value === target.value && isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter)) return true; } // In non-strictNullChecks mode, `undefined` and `null` are assignable to anything except `never`. // Since unions and intersections may reduce to `never`, we exclude them here. - if (s & 32768 /* Undefined */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & (32768 /* Undefined */ | 16384 /* Void */))) + if (s & 32768 /* TypeFlags.Undefined */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & (32768 /* TypeFlags.Undefined */ | 16384 /* TypeFlags.Void */))) return true; - if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */)) + if (s & 65536 /* TypeFlags.Null */ && (!strictNullChecks && !(t & 3145728 /* TypeFlags.UnionOrIntersection */) || t & 65536 /* TypeFlags.Null */)) return true; - if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */))) + if (s & 524288 /* TypeFlags.Object */ && t & 67108864 /* TypeFlags.NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */))) return true; if (relation === assignableRelation || relation === comparableRelation) { - if (s & 1 /* Any */) + if (s & 1 /* TypeFlags.Any */) return true; // Type number or any numeric literal type is assignable to any numeric enum type or any // numeric enum literal type. This rule exists for backwards compatibility reasons because // bit-flag enum types sometimes look like literal enum types with numeric literal values. - if (s & (8 /* Number */ | 256 /* NumberLiteral */) && !(s & 1024 /* EnumLiteral */) && (t & 32 /* Enum */ || relation === assignableRelation && t & 256 /* NumberLiteral */ && t & 1024 /* EnumLiteral */)) + if (s & (8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) && !(s & 1024 /* TypeFlags.EnumLiteral */) && (t & 32 /* TypeFlags.Enum */ || relation === assignableRelation && t & 256 /* TypeFlags.NumberLiteral */ && t & 1024 /* TypeFlags.EnumLiteral */)) return true; // Anything is assignable to a union containing undefined, null, and {} if (isUnknownLikeUnionType(target)) @@ -64993,38 +65221,38 @@ var ts; return true; } if (relation !== identityRelation) { - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { return true; } } - else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) { + else if (!((source.flags | target.flags) & (3145728 /* TypeFlags.UnionOrIntersection */ | 8388608 /* TypeFlags.IndexedAccess */ | 16777216 /* TypeFlags.Conditional */ | 33554432 /* TypeFlags.Substitution */))) { // We have excluded types that may simplify to other forms, so types must have identical flags if (source.flags !== target.flags) return false; - if (source.flags & 67358815 /* Singleton */) + if (source.flags & 67358815 /* TypeFlags.Singleton */) return true; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, 0 /* None */, relation, /*ignoreConstraints*/ false)); + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { + var related = relation.get(getRelationKey(source, target, 0 /* IntersectionState.None */, relation, /*ignoreConstraints*/ false)); if (related !== undefined) { - return !!(related & 1 /* Succeeded */); + return !!(related & 1 /* RelationComparisonResult.Succeeded */); } } - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } function isIgnoredJsxProperty(source, sourceProp) { - return ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); + return ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && isHyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { while (true) { var t = isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 /* Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type : - type.flags & 3145728 /* UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) : - type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : - type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : + ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.node ? createTypeReference(type.target, getTypeArguments(type)) : getSingleBaseForNonAugmentingSubtype(type) || type : + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getNormalizedUnionOrIntersectionType(type, writing) : + type.flags & 33554432 /* TypeFlags.Substitution */ ? writing ? type.baseType : type.substitute : + type.flags & 25165824 /* TypeFlags.Simplifiable */ ? getSimplifiedType(type, writing) : type; if (t === type) return t; @@ -65036,7 +65264,7 @@ var ts; if (reduced !== type) { return reduced; } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { var normalizedTypes = ts.sameMap(type.types, function (t) { return getNormalizedType(t, writing); }); if (normalizedTypes !== type.types) { return getIntersectionType(normalizedTypes); @@ -65064,19 +65292,19 @@ var ts; var maybeCount = 0; var sourceDepth = 0; var targetDepth = 0; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; var overflow = false; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid var lastSkippedInfo; var incompatibleStack; var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedTo(source, target, 3 /* Both */, /*reportErrors*/ !!errorNode, headMessage); + var result = isRelatedTo(source, target, 3 /* RecursionFlags.Both */, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack) { reportIncompatibleStack(); } if (overflow) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: sourceDepth, targetDepth: targetDepth }); var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); @@ -65114,10 +65342,10 @@ var ts; diagnostics.add(diag); } } - if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* False */) { + if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0 /* Ternary.False */) { ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } - return result !== 0 /* False */; + return result !== 0 /* Ternary.False */; function resetErrorInfo(saved) { errorInfo = saved.errorInfo; lastSkippedInfo = saved.lastSkippedInfo; @@ -65162,24 +65390,24 @@ var ts; case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { // Parenthesize a `new` if there is one if (path.indexOf("new ") === 0) { - path = "(" + path + ")"; + path = "(".concat(path, ")"); } var str = "" + args[0]; // If leading, just print back the arg (irrespective of if it's a valid identifier) if (path.length === 0) { - path = "" + str; + path = "".concat(str); } // Otherwise write a dotted name if possible else if (ts.isIdentifierText(str, ts.getEmitScriptTarget(compilerOptions))) { - path = path + "." + str; + path = "".concat(path, ".").concat(str); } // Failing that, check if the name is already a computed name else if (str[0] === "[" && str[str.length - 1] === "]") { - path = "" + path + str; + path = "".concat(path).concat(str); } // And finally write out a computed name as a last resort else { - path = path + "[" + str + "]"; + path = "".concat(path, "[").concat(str, "]"); } break; } @@ -65208,7 +65436,7 @@ var ts; msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) ? "" : "..."; - path = "" + prefix + path + "(" + params + ")"; + path = "".concat(prefix).concat(path, "(").concat(params, ")"); } break; } @@ -65221,7 +65449,7 @@ var ts; break; } default: - return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + return ts.Debug.fail("Unhandled Diagnostic: ".concat(msg.code)); } } if (path) { @@ -65273,7 +65501,7 @@ var ts; ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable"); generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource); } - if (target.flags & 262144 /* TypeParameter */ && target !== markerSuperType && target !== markerSubType) { + if (target.flags & 262144 /* TypeFlags.TypeParameter */ && target !== markerSuperTypeForCheck && target !== markerSubTypeForCheck) { var constraint = getBaseConstraintOfType(target); var needsOriginalSource = void 0; if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) { @@ -65295,7 +65523,7 @@ var ts; message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties; } else { - if (source.flags & 128 /* StringLiteral */ && target.flags & 1048576 /* Union */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */ && target.flags & 1048576 /* TypeFlags.Union */) { var suggestedType = getSuggestedTypeForNonexistentStringLiteralType(source, target); if (suggestedType) { reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Did_you_mean_2, generalizedSourceType, targetType, typeToString(suggestedType)); @@ -65357,7 +65585,7 @@ var ts; return true; } function isRelatedToWorker(source, target, reportErrors) { - return isRelatedTo(source, target, 3 /* Both */, reportErrors); + return isRelatedTo(source, target, 3 /* RecursionFlags.Both */, reportErrors); } /** * Compare two types and return @@ -65366,19 +65594,19 @@ var ts; * * Ternary.False if they are not related. */ function isRelatedTo(originalSource, originalTarget, recursionFlags, reportErrors, headMessage, intersectionState) { - if (recursionFlags === void 0) { recursionFlags = 3 /* Both */; } + if (recursionFlags === void 0) { recursionFlags = 3 /* RecursionFlags.Both */; } if (reportErrors === void 0) { reportErrors = false; } - if (intersectionState === void 0) { intersectionState = 0 /* None */; } + if (intersectionState === void 0) { intersectionState = 0 /* IntersectionState.None */; } // Before normalization: if `source` is type an object type, and `target` is primitive, // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result - if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) { + if (originalSource.flags & 524288 /* TypeFlags.Object */ && originalTarget.flags & 131068 /* TypeFlags.Primitive */) { if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (reportErrors) { reportErrorResults(originalSource, originalTarget, originalSource, originalTarget, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and @@ -65387,73 +65615,73 @@ var ts; var source = getNormalizedType(originalSource, /*writing*/ false); var target = getNormalizedType(originalTarget, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; if (relation === identityRelation) { if (source.flags !== target.flags) - return 0 /* False */; - if (source.flags & 67358815 /* Singleton */) - return -1 /* True */; + return 0 /* Ternary.False */; + if (source.flags & 67358815 /* TypeFlags.Singleton */) + return -1 /* Ternary.True */; traceUnionsOrIntersectionsTooLarge(source, target); - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */, recursionFlags); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* IntersectionState.None */, recursionFlags); } // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, // as we break down the _target_ union first, _then_ get the source constraint - so for every // member of the target, we attempt to find a match in the source. This avoids that in cases where // the target is exactly the constraint. - if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) { - return -1 /* True */; + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && getConstraintOfType(source) === target) { + return -1 /* Ternary.True */; } // See if we're relating a definitely non-nullable type to a union that includes null and/or undefined // plus a single non-nullable type. If so, remove null and/or undefined from the target type. - if (source.flags & 470302716 /* DefinitelyNonNullable */ && target.flags & 1048576 /* Union */) { + if (source.flags & 470302716 /* TypeFlags.DefinitelyNonNullable */ && target.flags & 1048576 /* TypeFlags.Union */) { var types = target.types; - var candidate = types.length === 2 && types[0].flags & 98304 /* Nullable */ ? types[1] : - types.length === 3 && types[0].flags & 98304 /* Nullable */ && types[1].flags & 98304 /* Nullable */ ? types[2] : + var candidate = types.length === 2 && types[0].flags & 98304 /* TypeFlags.Nullable */ ? types[1] : + types.length === 3 && types[0].flags & 98304 /* TypeFlags.Nullable */ && types[1].flags & 98304 /* TypeFlags.Nullable */ ? types[2] : undefined; - if (candidate && !(candidate.flags & 98304 /* Nullable */)) { + if (candidate && !(candidate.flags & 98304 /* TypeFlags.Nullable */)) { target = getNormalizedType(candidate, /*writing*/ true); if (source === target) - return -1 /* True */; + return -1 /* Ternary.True */; } } - if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || + if (relation === comparableRelation && !(target.flags & 131072 /* TypeFlags.Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) - return -1 /* True */; - if (source.flags & 469499904 /* StructuredOrInstantiable */ || target.flags & 469499904 /* StructuredOrInstantiable */) { - var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* FreshLiteral */); + return -1 /* Ternary.True */; + if (source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */ || target.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */) { + var isPerformingExcessPropertyChecks = !(intersectionState & 2 /* IntersectionState.Target */) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 8192 /* ObjectFlags.FreshLiteral */); if (isPerformingExcessPropertyChecks) { if (hasExcessProperties(source, target, reportErrors)) { if (reportErrors) { reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* Target */) && - source.flags & (131068 /* Primitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && source !== globalObjectType && - target.flags & (524288 /* Object */ | 2097152 /* Intersection */) && isWeakType(target) && + var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2 /* IntersectionState.Target */) && + source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType && + target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) && (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source)); - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) { if (reportErrors) { var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source); var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target); - var calls = getSignaturesOfType(source, 0 /* Call */); - var constructs = getSignaturesOfType(source, 1 /* Construct */); - if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* Source */, /*reportErrors*/ false) || - constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* Source */, /*reportErrors*/ false)) { + var calls = getSignaturesOfType(source, 0 /* SignatureKind.Call */); + var constructs = getSignaturesOfType(source, 1 /* SignatureKind.Construct */); + if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false) || + constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString); } else { reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString); } } - return 0 /* False */; + return 0 /* Ternary.False */; } traceUnionsOrIntersectionsTooLarge(source, target); - var skipCaching = source.flags & 1048576 /* Union */ && source.types.length < 4 && !(target.flags & 1048576 /* Union */) || - target.flags & 1048576 /* Union */ && target.types.length < 4 && !(source.flags & 469499904 /* StructuredOrInstantiable */); + var skipCaching = source.flags & 1048576 /* TypeFlags.Union */ && source.types.length < 4 && !(target.flags & 1048576 /* TypeFlags.Union */) || + target.flags & 1048576 /* TypeFlags.Union */ && target.types.length < 4 && !(source.flags & 469499904 /* TypeFlags.StructuredOrInstantiable */); var result_7 = skipCaching ? unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) : recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags); @@ -65472,10 +65700,10 @@ 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_7 && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* NonInferrableType */); }))) { + if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || + isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) { inPropertyCheck = true; - result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */, recursionFlags); + result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags); inPropertyCheck = false; } if (result_7) { @@ -65485,7 +65713,7 @@ var ts; if (reportErrors) { reportErrorResults(originalSource, originalTarget, source, target, headMessage); } - return 0 /* False */; + return 0 /* Ternary.False */; } function reportErrorResults(originalSource, originalTarget, source, target, headMessage) { var _a, _b; @@ -65497,20 +65725,20 @@ var ts; if (maybeSuppress) { overrideNextErrorInfo--; } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ true); if (errorInfo !== currentError) { maybeSuppress = !!errorInfo; } } - if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { + if (source.flags & 524288 /* TypeFlags.Object */ && target.flags & 131068 /* TypeFlags.Primitive */) { tryElaborateErrorsForPrimitivesAndObjects(source, target); } - else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { + else if (source.symbol && source.flags & 524288 /* TypeFlags.Object */ && globalObjectType === source) { reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); } - else if (ts.getObjectFlags(source) & 2048 /* JsxAttributes */ && target.flags & 2097152 /* Intersection */) { + else if (ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */ && target.flags & 2097152 /* TypeFlags.Intersection */) { var targetTypes = target.types; var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); @@ -65529,7 +65757,7 @@ var ts; return; } reportRelationError(headMessage, source, target); - if (source.flags & 262144 /* TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) { + if (source.flags & 262144 /* TypeFlags.TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) { var syntheticParam = cloneTypeParameter(source); syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam)); if (hasNonCircularBaseConstraint(syntheticParam)) { @@ -65542,17 +65770,17 @@ var ts; if (!ts.tracing) { return; } - if ((source.flags & 3145728 /* UnionOrIntersection */) && (target.flags & 3145728 /* UnionOrIntersection */)) { + if ((source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) && (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */)) { var sourceUnionOrIntersection = source; var targetUnionOrIntersection = target; - if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* PrimitiveUnion */) { + if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 32768 /* ObjectFlags.PrimitiveUnion */) { // There's a fast path for comparing primitive unions return; } var sourceSize = sourceUnionOrIntersection.types.length; var targetSize = targetUnionOrIntersection.types.length; if (sourceSize * targetSize > 1E6) { - ts.tracing.instant("checkTypes" /* CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { + ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "traceUnionsOrIntersectionsTooLarge_DepthLimit", { sourceId: source.id, sourceSize: sourceSize, targetId: target.id, @@ -65567,7 +65795,7 @@ var ts; var appendPropType = function (propTypes, type) { var _a; type = getApparentType(type); - var prop = type.flags & 3145728 /* UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); + var prop = type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name); var propType = prop && getTypeOfSymbol(prop) || ((_a = getApplicableIndexInfoForName(type, name)) === null || _a === void 0 ? void 0 : _a.type) || undefinedType; return ts.append(propTypes, propType); }; @@ -65575,21 +65803,21 @@ var ts; } function hasExcessProperties(source, target, reportErrors) { var _a; - if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* JSLiteral */) { + if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 4096 /* ObjectFlags.JSLiteral */) { return false; // Disable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny } - var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* JsxAttributes */); + var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 2048 /* ObjectFlags.JsxAttributes */); if ((relation === assignableRelation || relation === comparableRelation) && (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { return false; } var reducedTarget = target; var checkTypes; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); - checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; + checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget]; } - var _loop_19 = function (prop) { + var _loop_20 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { @@ -65642,7 +65870,7 @@ var ts; } return { value: true }; } - if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* Both */, reportErrors)) { + if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), 3 /* RecursionFlags.Both */, reportErrors)) { if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop)); } @@ -65652,7 +65880,7 @@ var ts; }; for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) { var prop = _b[_i]; - var state_6 = _loop_19(prop); + var state_6 = _loop_20(prop); if (typeof state_6 === "object") return state_6.value; } @@ -65665,28 +65893,28 @@ var ts; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { return relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState); + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState) : + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */), intersectionState); } - if (target.flags & 1048576 /* Union */) { - return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */)); + if (target.flags & 1048576 /* TypeFlags.Union */) { + return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* TypeFlags.Primitive */) && !(target.flags & 131068 /* TypeFlags.Primitive */)); } - if (target.flags & 2097152 /* Intersection */) { - return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */); + if (target.flags & 2097152 /* TypeFlags.Intersection */) { + return typeRelatedToEachType(source, target, reportErrors, 2 /* IntersectionState.Target */); } // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the // constraints of all non-primitive types in the source into a new intersection. We do this because the // intersection may further constrain the constraints of the non-primitive types. For example, given a type // parameter 'T extends 1 | 2', the intersection 'T & 1' should be reduced to '1' such that it doesn't // appear to be comparable to '2'. - if (relation === comparableRelation && target.flags & 131068 /* Primitive */) { + if (relation === comparableRelation && target.flags & 131068 /* TypeFlags.Primitive */) { var constraints = ts.sameMap(source.types, getBaseConstraintOrType); if (constraints !== source.types) { source = getIntersectionType(constraints); - if (!(source.flags & 2097152 /* Intersection */)) { - return isRelatedTo(source, target, 1 /* Source */, /*reportErrors*/ false); + if (!(source.flags & 2097152 /* TypeFlags.Intersection */)) { + return isRelatedTo(source, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false); } } } @@ -65694,16 +65922,16 @@ var ts; // Don't report errors though. Elaborating on whether a source constituent is related to the target is // not actually useful and leads to some confusing error messages. Instead, we rely on the caller // checking whether the full intersection viewed as an object is related to the target. - return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* Source */); + return someTypeRelatedToType(source, target, /*reportErrors*/ false, 1 /* IntersectionState.Source */); } function eachTypeRelatedToSomeType(source, target) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) { var sourceType = sourceTypes_1[_i]; var related = typeRelatedToSomeType(sourceType, target, /*reportErrors*/ false); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65711,13 +65939,13 @@ var ts; } function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { if (containsType(targetTypes, source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } var match = getMatchingUnionConstituentForType(target, source); if (match) { - var related = isRelatedTo(source, match, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, match, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65725,7 +65953,7 @@ var ts; } for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) { var type = targetTypes_1[_i]; - var related = isRelatedTo(source, type, 2 /* Target */, /*reportErrors*/ false); + var related = isRelatedTo(source, type, 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (related) { return related; } @@ -65734,19 +65962,19 @@ var ts; // Elaborate only if we can find a best matching type in the target union var bestMatchingType = getBestMatchingType(source, target, isRelatedTo); if (bestMatchingType) { - isRelatedTo(source, bestMatchingType, 2 /* Target */, /*reportErrors*/ true); + isRelatedTo(source, bestMatchingType, 2 /* RecursionFlags.Target */, /*reportErrors*/ true); } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToEachType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var targetTypes = target.types; for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) { var targetType = targetTypes_2[_i]; - var related = isRelatedTo(source, targetType, 2 /* Target */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(source, targetType, 2 /* RecursionFlags.Target */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65754,50 +65982,50 @@ var ts; } function someTypeRelatedToType(source, target, reportErrors, intersectionState) { var sourceTypes = source.types; - if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { - return -1 /* True */; + if (source.flags & 1048576 /* TypeFlags.Union */ && containsType(sourceTypes, target)) { + return -1 /* Ternary.True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, 1 /* Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceTypes[i], target, 1 /* RecursionFlags.Source */, reportErrors && i === len - 1, /*headMessage*/ undefined, intersectionState); if (related) { return related; } } - return 0 /* False */; + return 0 /* Ternary.False */; } function getUndefinedStrippedTargetIfNeeded(source, target) { // As a builtin type, `undefined` is a very low type ID - making it almsot always first, making this a very fast check to see // if we need to strip `undefined` from the target - if (source.flags & 1048576 /* Union */ && target.flags & 1048576 /* Union */ && - !(source.types[0].flags & 32768 /* Undefined */) && target.types[0].flags & 32768 /* Undefined */) { - return extractTypesOfKind(target, ~32768 /* Undefined */); + if (source.flags & 1048576 /* TypeFlags.Union */ && target.flags & 1048576 /* TypeFlags.Union */ && + !(source.types[0].flags & 32768 /* TypeFlags.Undefined */) && target.types[0].flags & 32768 /* TypeFlags.Undefined */) { + return extractTypesOfKind(target, ~32768 /* TypeFlags.Undefined */); } return target; } function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var sourceTypes = source.types; // We strip `undefined` from the target if the `source` trivially doesn't contain it for our correspondence-checking fastpath // since `undefined` is frequently added by optionality and would otherwise spoil a potentially useful correspondence var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target); for (var i = 0; i < sourceTypes.length; i++) { var sourceType = sourceTypes[i]; - if (undefinedStrippedTarget.flags & 1048576 /* Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { + if (undefinedStrippedTarget.flags & 1048576 /* TypeFlags.Union */ && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) { // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison // such unions will have identical lengths, and their corresponding elements will match up. Another common scenario is where a large // union has a union of objects intersected with it. In such cases, if the input was, eg `("a" | "b" | "c") & (string | boolean | {} | {whatever})`, // the result will have the structure `"a" | "b" | "c" | "a" & {} | "b" & {} | "c" & {} | "a" & {whatever} | "b" & {whatever} | "c" & {whatever}` // - the resulting union has a length which is a multiple of the original union, and the elements correspond modulo the length of the original union - var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], 3 /* RecursionFlags.Both */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); if (related_1) { result &= related_1; continue; } } - var related = isRelatedTo(sourceType, target, 1 /* Source */, reportErrors, /*headMessage*/ undefined, intersectionState); + var related = isRelatedTo(sourceType, target, 1 /* RecursionFlags.Source */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65808,54 +66036,54 @@ var ts; if (targets === void 0) { targets = ts.emptyArray; } if (variances === void 0) { variances = ts.emptyArray; } if (sources.length !== targets.length && relation === identityRelation) { - return 0 /* False */; + return 0 /* Ternary.False */; } var length = sources.length <= targets.length ? sources.length : targets.length; - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < length; i++) { // When variance information isn't available we default to covariance. This happens // in the process of computing variance information for recursive types and when // comparing 'this' type arguments. - var varianceFlags = i < variances.length ? variances[i] : 1 /* Covariant */; - var variance = varianceFlags & 7 /* VarianceMask */; + var varianceFlags = i < variances.length ? variances[i] : 1 /* VarianceFlags.Covariant */; + var variance = varianceFlags & 7 /* VarianceFlags.VarianceMask */; // We ignore arguments for independent type parameters (because they're never witnessed). - if (variance !== 4 /* Independent */) { + if (variance !== 4 /* VarianceFlags.Independent */) { var s = sources[i]; var t = targets[i]; - var related = -1 /* True */; - if (varianceFlags & 8 /* Unmeasurable */) { + var related = -1 /* Ternary.True */; + if (varianceFlags & 8 /* VarianceFlags.Unmeasurable */) { // Even an `Unmeasurable` variance works out without a structural check if the source and target are _identical_. // We can't simply assume invariance, because `Unmeasurable` marks nonlinear relations, for example, a relation tained by // the `-?` modifier in a mapped type (where, no matter how the inputs are related, the outputs still might not be) - related = relation === identityRelation ? isRelatedTo(s, t, 3 /* Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); + related = relation === identityRelation ? isRelatedTo(s, t, 3 /* RecursionFlags.Both */, /*reportErrors*/ false) : compareTypesIdentical(s, t); } - else if (variance === 1 /* Covariant */) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 1 /* VarianceFlags.Covariant */) { + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 2 /* Contravariant */) { - related = isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + else if (variance === 2 /* VarianceFlags.Contravariant */) { + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } - else if (variance === 3 /* Bivariant */) { + else if (variance === 3 /* VarianceFlags.Bivariant */) { // In the bivariant case we first compare contravariantly without reporting // errors. Then, if that doesn't succeed, we compare covariantly with error // reporting. Thus, error elaboration will be based on the the covariant check, // which is generally easier to reason about. - related = isRelatedTo(t, s, 3 /* Both */, /*reportErrors*/ false); + related = isRelatedTo(t, s, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); if (!related) { - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } else { // In the invariant case we first compare covariantly, and only when that // succeeds do we proceed to compare contravariantly. Thus, error elaboration // will typically be based on the covariant check. - related = isRelatedTo(s, t, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related = isRelatedTo(s, t, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (related) { - related &= isRelatedTo(t, s, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + related &= isRelatedTo(t, s, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } } if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -65869,28 +66097,28 @@ var ts; // and issue an error. Otherwise, actually compare the structure of the two types. function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags) { if (overflow) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0); + var keyIntersectionState = intersectionState | (inPropertyCheck ? 8 /* IntersectionState.InPropertyCheck */ : 0); var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false); var entry = relation.get(id); if (entry !== undefined) { - if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { + if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - var saved = entry & 24 /* ReportsMask */; - if (saved & 8 /* ReportsUnmeasurable */) { - instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); + var saved = entry & 24 /* RelationComparisonResult.ReportsMask */; + if (saved & 8 /* RelationComparisonResult.ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMapper); } - if (saved & 16 /* ReportsUnreliable */) { - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + if (saved & 16 /* RelationComparisonResult.ReportsUnreliable */) { + instantiateType(source, reportUnreliableMapper); } } - return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* RelationComparisonResult.Succeeded */ ? -1 /* Ternary.True */ : 0 /* Ternary.False */; } } if (!maybeKeys) { @@ -65906,42 +66134,42 @@ var ts; for (var i = 0; i < maybeCount; i++) { // If source and target are already being compared, consider them related with assumptions if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) { - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } } if (sourceDepth === 100 || targetDepth === 100) { overflow = true; - return 0 /* False */; + return 0 /* Ternary.False */; } } var maybeStart = maybeCount; maybeKeys[maybeCount] = id; maybeCount++; var saveExpandingFlags = expandingFlags; - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceStack[sourceDepth] = source; sourceDepth++; - if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) - expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 1 /* ExpandingFlags.Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth)) + expandingFlags |= 1 /* ExpandingFlags.Source */; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetStack[targetDepth] = target; targetDepth++; - if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) - expandingFlags |= 2 /* Target */; + if (!(expandingFlags & 2 /* ExpandingFlags.Target */) && isDeeplyNestedType(target, targetStack, targetDepth)) + expandingFlags |= 2 /* ExpandingFlags.Target */; } var originalHandler; var propagatingVarianceFlags = 0; if (outofbandVarianceMarkerHandler) { originalHandler = outofbandVarianceMarkerHandler; outofbandVarianceMarkerHandler = function (onlyUnreliable) { - propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + propagatingVarianceFlags |= onlyUnreliable ? 16 /* RelationComparisonResult.ReportsUnreliable */ : 8 /* RelationComparisonResult.ReportsUnmeasurable */; return originalHandler(onlyUnreliable); }; } var result; - if (expandingFlags === 3 /* Both */) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { + if (expandingFlags === 3 /* ExpandingFlags.Both */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "recursiveTypeRelatedTo_DepthLimit", { sourceId: source.id, sourceIdStack: sourceStack.map(function (t) { return t.id; }), targetId: target.id, @@ -65949,30 +66177,30 @@ var ts; depth: sourceDepth, targetDepth: targetDepth }); - result = 3 /* Maybe */; + result = 3 /* Ternary.Maybe */; } else { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id }); result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } if (outofbandVarianceMarkerHandler) { outofbandVarianceMarkerHandler = originalHandler; } - if (recursionFlags & 1 /* Source */) { + if (recursionFlags & 1 /* RecursionFlags.Source */) { sourceDepth--; } - if (recursionFlags & 2 /* Target */) { + if (recursionFlags & 2 /* RecursionFlags.Target */) { targetDepth--; } expandingFlags = saveExpandingFlags; if (result) { - if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) { - if (result === -1 /* True */ || result === 3 /* Maybe */) { + if (result === -1 /* Ternary.True */ || (sourceDepth === 0 && targetDepth === 0)) { + if (result === -1 /* Ternary.True */ || result === 3 /* Ternary.Maybe */) { // If result is definitely true, record all maybe keys as having succeeded. Also, record Ternary.Maybe // results as having succeeded once we reach depth 0, but never record Ternary.Unknown results. for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); + relation.set(maybeKeys[i], 1 /* RelationComparisonResult.Succeeded */ | propagatingVarianceFlags); } } maybeCount = maybeStart; @@ -65981,46 +66209,73 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); + relation.set(id, (reportErrors ? 4 /* RelationComparisonResult.Reported */ : 0) | 2 /* RelationComparisonResult.Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { - if (intersectionState & 4 /* PropertyCheck */) { - return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); + var saveErrorInfo = captureErrorCalculationState(); + var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo); + if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) { + // The combined constraint of an intersection type is the intersection of the constraints of + // the constituents. When an intersection type contains instantiable types with union type + // constraints, there are situations where we need to examine the combined constraint. One is + // when the target is a union type. Another is when the intersection contains types belonging + // to one of the disjoint domains. For example, given type variables T and U, each with the + // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and + // we need to check this constraint against a union on the target side. Also, given a type + // variable V constrained to 'string | number', 'V & number' has a combined constraint of + // 'string & number | number & number' which reduces to just 'number'. + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */)); + if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + } + } + if (result) { + resetErrorInfo(saveErrorInfo); + } + return result; + } + function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) { + if (intersectionState & 4 /* IntersectionState.PropertyCheck */) { + return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */); } var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = captureErrorCalculationState(); var sourceFlags = source.flags; var targetFlags = target.flags; if (relation === identityRelation) { // We've already checked that source.flags and target.flags are identical - if (sourceFlags & 3145728 /* UnionOrIntersection */) { + if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { var result_8 = eachTypeRelatedToSomeType(source, target); if (result_8) { result_8 &= eachTypeRelatedToSomeType(target, source); } return result_8; } - if (sourceFlags & 4194304 /* Index */) { - return isRelatedTo(source.type, target.type, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + return isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (sourceFlags & 8388608 /* IndexedAccess */) { - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } } - if (sourceFlags & 16777216 /* Conditional */) { + if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result = isRelatedTo(source.checkType, target.checkType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { - if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, /*reportErrors*/ false)) { + if (result = isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(source.extendsType, target.extendsType, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { + if (result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } @@ -66028,60 +66283,37 @@ var ts; } } } - if (sourceFlags & 33554432 /* Substitution */) { - return isRelatedTo(source.substitute, target.substitute, 3 /* Both */, /*reportErrors*/ false); + if (sourceFlags & 33554432 /* TypeFlags.Substitution */) { + return isRelatedTo(source.substitute, target.substitute, 3 /* RecursionFlags.Both */, /*reportErrors*/ false); } - if (!(sourceFlags & 524288 /* Object */)) { - return 0 /* False */; + if (!(sourceFlags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } } - else if (sourceFlags & 3145728 /* UnionOrIntersection */ || targetFlags & 3145728 /* UnionOrIntersection */) { + else if (sourceFlags & 3145728 /* TypeFlags.UnionOrIntersection */ || targetFlags & 3145728 /* TypeFlags.UnionOrIntersection */) { if (result = unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState)) { return result; } - if (source.flags & 2097152 /* Intersection */ || source.flags & 262144 /* TypeParameter */ && target.flags & 1048576 /* Union */) { - // The combined constraint of an intersection type is the intersection of the constraints of - // the constituents. When an intersection type contains instantiable types with union type - // constraints, there are situations where we need to examine the combined constraint. One is - // when the target is a union type. Another is when the intersection contains types belonging - // to one of the disjoint domains. For example, given type variables T and U, each with the - // constraint 'string | number', the combined constraint of 'T & U' is 'string | number' and - // we need to check this constraint against a union on the target side. Also, given a type - // variable V constrained to 'string | number', 'V & number' has a combined constraint of - // 'string & number | number & number' which reduces to just 'number'. - // This also handles type parameters, as a type parameter with a union constraint compared against a union - // needs to have its constraint hoisted into an intersection with said type parameter, this way - // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) - // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` - var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); - if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself - // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); - return result; - } - } - } // The ordered decomposition above doesn't handle all cases. Specifically, we also need to handle: // Source is instantiable (e.g. source has union or intersection constraint). // Source is an object, target is a union (e.g. { a, b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target is an object (e.g. { a } & { b } <=> { a, b }). // Source is an intersection, target is a union (e.g. { a } & { b: boolean } <=> { a, b: true } | { a, b: false }). // Source is an intersection, target instantiable (e.g. string & { tag } <=> T["a"] constrained to string & { tag }). - if (!(sourceFlags & 465829888 /* Instantiable */ || - sourceFlags & 524288 /* Object */ && targetFlags & 1048576 /* Union */ || - sourceFlags & 2097152 /* Intersection */ && targetFlags & (524288 /* Object */ | 1048576 /* Union */ | 465829888 /* Instantiable */))) { - return 0 /* False */; + if (!(sourceFlags & 465829888 /* TypeFlags.Instantiable */ || + sourceFlags & 524288 /* TypeFlags.Object */ && targetFlags & 1048576 /* TypeFlags.Union */ || + sourceFlags & 2097152 /* TypeFlags.Intersection */ && targetFlags & (524288 /* TypeFlags.Object */ | 1048576 /* TypeFlags.Union */ | 465829888 /* TypeFlags.Instantiable */))) { + return 0 /* Ternary.False */; } } // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. - if (sourceFlags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && source.aliasTypeArguments && + if (sourceFlags & (524288 /* TypeFlags.Object */ | 16777216 /* TypeFlags.Conditional */) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(isMarkerType(source) || isMarkerType(target))) { var variances = getAliasVariances(source.aliasSymbol); if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState); if (varianceResult !== undefined) { @@ -66090,48 +66322,48 @@ var ts; } // For a generic type T and a type U that is assignable to T, [...U] is assignable to T, U is assignable to readonly [...T], // and U is assignable to [...T] when U is constrained to a mutable array or tuple type. - if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* Source */)) || - isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* Target */))) { + if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target, 1 /* RecursionFlags.Source */)) || + isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0], 2 /* RecursionFlags.Target */))) { return result; } - if (targetFlags & 262144 /* TypeParameter */) { + if (targetFlags & 262144 /* TypeFlags.TypeParameter */) { // A source type { [P in Q]: X } is related to a target type T if keyof T is related to Q and X is related to T[Q]. - if (ts.getObjectFlags(source) & 32 /* Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* Both */)) { - if (!(getMappedTypeModifiers(source) & 4 /* IncludeOptional */)) { + if (ts.getObjectFlags(source) & 32 /* ObjectFlags.Mapped */ && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source), 3 /* RecursionFlags.Both */)) { + if (!(getMappedTypeModifiers(source) & 4 /* MappedTypeModifiers.IncludeOptional */)) { var templateType = getTemplateTypeFromMappedType(source); var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(templateType, indexedAccessType, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } } - if (relation === comparableRelation && sourceFlags & 262144 /* TypeParameter */) { + if (relation === comparableRelation && sourceFlags & 262144 /* TypeFlags.TypeParameter */) { // This is a carve-out in comparability to essentially forbid comparing a type parameter // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!) var constraint = getConstraintOfTypeParameter(source); if (constraint && hasNonCircularBaseConstraint(source)) { - while (constraint && constraint.flags & 262144 /* TypeParameter */) { - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false)) { + while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) { + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) { return result; } constraint = getConstraintOfTypeParameter(constraint); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetFlags & 4194304 /* Index */) { + else if (targetFlags & 4194304 /* TypeFlags.Index */) { var targetType_1 = target.type; // A keyof S is related to a keyof T if T is related to S. - if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(targetType_1, source.type, 3 /* Both */, /*reportErrors*/ false)) { + if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(targetType_1, source.type, 3 /* RecursionFlags.Both */, /*reportErrors*/ false)) { return result; } } if (isTupleType(targetType_1)) { // An index type can have a tuple type target when the tuple type contains variadic elements. // Check if the source is related to the known keys of the tuple type. - if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType_1), 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -66144,8 +66376,8 @@ var ts; // false positives. For example, given 'T extends { [K in keyof T]: string }', // 'keyof T' has itself as its constraint and produces a Ternary.Maybe when // related to other types. - if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } else if (isGenericMappedType(targetType_1)) { @@ -66160,7 +66392,7 @@ var ts; // missing from the `constraintType` which will otherwise be mapped in the object var modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType_1)); var mappedKeys_1 = []; - forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* StringOrNumberLiteralOrUnique */, + forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(modifiersType, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*stringsOnly*/ false, function (t) { return void mappedKeys_1.push(instantiateType(nameType_1, appendTypeMapping(targetType_1.mapper, getTypeParameterFromMappedType(targetType_1), t))); }); // We still need to include the non-apparent (and thus still generic) keys in the target side of the comparison (in case they're in the source side) targetKeys = getUnionType(__spreadArray(__spreadArray([], mappedKeys_1, true), [nameType_1], false)); @@ -66168,21 +66400,20 @@ var ts; else { targetKeys = nameType_1 || constraintType; } - if (isRelatedTo(source, targetKeys, 2 /* Target */, reportErrors) === -1 /* True */) { - return -1 /* True */; + if (isRelatedTo(source, targetKeys, 2 /* RecursionFlags.Target */, reportErrors) === -1 /* Ternary.True */) { + return -1 /* Ternary.True */; } } } } - else if (targetFlags & 8388608 /* IndexedAccess */) { - if (sourceFlags & 8388608 /* IndexedAccess */) { + else if (targetFlags & 8388608 /* TypeFlags.IndexedAccess */) { + if (sourceFlags & 8388608 /* TypeFlags.IndexedAccess */) { // Relate components directly before falling back to constraint relationships // A type S[K] is related to a type T[J] if S is related to T and K is related to J. - if (result = isRelatedTo(source.objectType, target.objectType, 3 /* Both */, reportErrors)) { - result &= isRelatedTo(source.indexType, target.indexType, 3 /* Both */, reportErrors); + if (result = isRelatedTo(source.objectType, target.objectType, 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(source.indexType, target.indexType, 3 /* RecursionFlags.Both */, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } if (reportErrors) { @@ -66197,14 +66428,14 @@ var ts; var baseObjectType = getBaseConstraintOfType(objectType) || objectType; var baseIndexType = getBaseConstraintOfType(indexType) || indexType; if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) { - var accessFlags = 4 /* Writing */ | (baseObjectType !== objectType ? 2 /* NoIndexSignatures */ : 0); + var accessFlags = 4 /* AccessFlags.Writing */ | (baseObjectType !== objectType ? 2 /* AccessFlags.NoIndexSignatures */ : 0); var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, accessFlags); if (constraint) { if (reportErrors && originalErrorInfo) { // create a new chain for the constraint error resetErrorInfo(saveErrorInfo); } - if (result = isRelatedTo(source, constraint, 2 /* Target */, reportErrors)) { + if (result = isRelatedTo(source, constraint, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } // prefer the shorter chain of the constraint comparison chain, and the direct comparison chain @@ -66223,12 +66454,12 @@ var ts; var keysRemapped = !!target.declaration.nameType; var templateType = getTemplateTypeFromMappedType(target); var modifiers = getMappedTypeModifiers(target); - if (!(modifiers & 8 /* ExcludeOptional */)) { + if (!(modifiers & 8 /* MappedTypeModifiers.ExcludeOptional */)) { // If the mapped type has shape `{ [P in Q]: T[P] }`, // source `S` is related to target if `T` = `S`, i.e. `S` is related to `{ [P in Q]: S[P] }`. - if (!keysRemapped && templateType.flags & 8388608 /* IndexedAccess */ && templateType.objectType === source && + if (!keysRemapped && templateType.flags & 8388608 /* TypeFlags.IndexedAccess */ && templateType.objectType === source && templateType.indexType === getTypeParameterFromMappedType(target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!isGenericMappedType(source)) { // If target has shape `{ [P in Q as R]: T}`, then its keys have type `R`. @@ -66236,22 +66467,22 @@ var ts; var targetKeys = keysRemapped ? getNameTypeFromMappedType(target) : getConstraintTypeFromMappedType(target); // Type of the keys of source type `S`, i.e. `keyof S`. var sourceKeys = getIndexType(source, /*stringsOnly*/ undefined, /*noIndexSignatures*/ true); - var includeOptional = modifiers & 4 /* IncludeOptional */; + var includeOptional = modifiers & 4 /* MappedTypeModifiers.IncludeOptional */; var filteredByApplicability = includeOptional ? intersectTypes(targetKeys, sourceKeys) : undefined; // A source type `S` is related to a target type `{ [P in Q]: T }` if `Q` is related to `keyof S` and `S[Q]` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]: T }` if `R` is related to `keyof S` and `S[R]` is related to `T. // A source type `S` is related to a target type `{ [P in Q]?: T }` if some constituent `Q'` of `Q` is related to `keyof S` and `S[Q']` is related to `T`. // A source type `S` is related to a target type `{ [P in Q as R]?: T }` if some constituent `R'` of `R` is related to `keyof S` and `S[R']` is related to `T`. if (includeOptional - ? !(filteredByApplicability.flags & 131072 /* Never */) - : isRelatedTo(targetKeys, sourceKeys, 3 /* Both */)) { + ? !(filteredByApplicability.flags & 131072 /* TypeFlags.Never */) + : isRelatedTo(targetKeys, sourceKeys, 3 /* RecursionFlags.Both */)) { var templateType_1 = getTemplateTypeFromMappedType(target); var typeParameter = getTypeParameterFromMappedType(target); // Fastpath: When the template type has the form `Obj[P]` where `P` is the mapped type parameter, directly compare source `S` with `Obj` // to avoid creating the (potentially very large) number of new intermediate types made by manufacturing `S[P]`. - var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* Nullable */); - if (!keysRemapped && nonNullComponent.flags & 8388608 /* IndexedAccess */ && nonNullComponent.indexType === typeParameter) { - if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* Target */, reportErrors)) { + var nonNullComponent = extractTypesOfKind(templateType_1, ~98304 /* TypeFlags.Nullable */); + if (!keysRemapped && nonNullComponent.flags & 8388608 /* TypeFlags.IndexedAccess */ && nonNullComponent.indexType === typeParameter) { + if (result = isRelatedTo(source, nonNullComponent.objectType, 2 /* RecursionFlags.Target */, reportErrors)) { return result; } } @@ -66271,7 +66502,7 @@ var ts; : typeParameter; var indexedAccessType = getIndexedAccessType(source, indexingType); // Compare `S[indexingType]` to `T`, where `T` is the type of a property of the target type. - if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* Both */, reportErrors)) { + if (result = isRelatedTo(indexedAccessType, templateType_1, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } @@ -66281,12 +66512,11 @@ var ts; } } } - else if (targetFlags & 16777216 /* Conditional */) { + else if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(target, targetStack, targetDepth, 10)) { - resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } var c = target; // We check for a relationship to a conditional type target only when the conditional type has no @@ -66297,47 +66527,44 @@ var ts; var skipTrue = !isTypeAssignableTo(getPermissiveInstantiation(c.checkType), getPermissiveInstantiation(c.extendsType)); var skipFalse = !skipTrue && isTypeAssignableTo(getRestrictiveInstantiation(c.checkType), getRestrictiveInstantiation(c.extendsType)); // TODO: Find a nice way to include potential conditional type breakdowns in error output, if they seem good (they usually don't) - if (result = skipTrue ? -1 /* True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false)) { - result &= skipFalse ? -1 /* True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* Target */, /*reportErrors*/ false); + if (result = skipTrue ? -1 /* Ternary.True */ : isRelatedTo(source, getTrueTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false)) { + result &= skipFalse ? -1 /* Ternary.True */ : isRelatedTo(source, getFalseTypeFromConditionalType(c), 2 /* RecursionFlags.Target */, /*reportErrors*/ false); if (result) { - resetErrorInfo(saveErrorInfo); return result; } } } } - else if (targetFlags & 134217728 /* TemplateLiteral */) { - if (sourceFlags & 134217728 /* TemplateLiteral */) { + else if (targetFlags & 134217728 /* TypeFlags.TemplateLiteral */) { + if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */) { if (relation === comparableRelation) { - return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* False */ : -1 /* True */; + return templateLiteralTypesDefinitelyUnrelated(source, target) ? 0 /* Ternary.False */ : -1 /* Ternary.True */; } // Report unreliable variance for type variables referenced in template literal type placeholders. // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string. - instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); + instantiateType(source, reportUnreliableMapper); } if (isTypeMatchedByTemplateLiteralType(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } - else if (target.flags & 268435456 /* StringMapping */) { - if (!(source.flags & 268435456 /* StringMapping */)) { + else if (target.flags & 268435456 /* TypeFlags.StringMapping */) { + if (!(source.flags & 268435456 /* TypeFlags.StringMapping */)) { if (isMemberOfStringMapping(source, target)) { - return -1 /* True */; + return -1 /* Ternary.True */; } } } - if (sourceFlags & 8650752 /* TypeVariable */) { + if (sourceFlags & 8650752 /* TypeFlags.TypeVariable */) { // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch - if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) { + if (!(sourceFlags & 8388608 /* TypeFlags.IndexedAccess */ && targetFlags & 8388608 /* TypeFlags.IndexedAccess */)) { var constraint = getConstraintOfType(source) || unknownType; // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed - if (result = isRelatedTo(constraint, target, 1 /* Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState)) { return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example - else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeParameter */), /*headMessage*/ undefined, intersectionState)) { - resetErrorInfo(saveErrorInfo); + else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, 1 /* RecursionFlags.Source */, reportErrors && constraint !== unknownType && !(targetFlags & sourceFlags & 262144 /* TypeFlags.TypeParameter */), /*headMessage*/ undefined, intersectionState)) { return result; } if (isMappedTypeGenericIndexedAccess(source)) { @@ -66345,55 +66572,49 @@ var ts; // substituted for P. We also want to explore type { [P in K]: E }[C], where C is the constraint of X. var indexConstraint = getConstraintOfType(source.indexType); if (indexConstraint) { - if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(getIndexedAccessType(source.objectType, indexConstraint), target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } } } } - else if (sourceFlags & 4194304 /* Index */) { - if (result = isRelatedTo(keyofConstraintType, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + else if (sourceFlags & 4194304 /* TypeFlags.Index */) { + if (result = isRelatedTo(keyofConstraintType, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } - else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) { - if (!(targetFlags & 134217728 /* TemplateLiteral */)) { + else if (sourceFlags & 134217728 /* TypeFlags.TemplateLiteral */ && !(targetFlags & 524288 /* TypeFlags.Object */)) { + if (!(targetFlags & 134217728 /* TypeFlags.TemplateLiteral */)) { var constraint = getBaseConstraintOfType(source); - if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { - resetErrorInfo(saveErrorInfo); + if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { return result; } } } - else if (sourceFlags & 268435456 /* StringMapping */) { - if (targetFlags & 268435456 /* StringMapping */) { + else if (sourceFlags & 268435456 /* TypeFlags.StringMapping */) { + if (targetFlags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol !== target.symbol) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(source.type, target.type, 3 /* RecursionFlags.Both */, reportErrors)) { return result; } } else { var constraint = getBaseConstraintOfType(source); - if (constraint && (result = isRelatedTo(constraint, target, 1 /* Source */, reportErrors))) { - resetErrorInfo(saveErrorInfo); + if (constraint && (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, reportErrors))) { return result; } } } - else if (sourceFlags & 16777216 /* Conditional */) { + else if (sourceFlags & 16777216 /* TypeFlags.Conditional */) { // If we reach 10 levels of nesting for the same conditional type, assume it is an infinitely expanding recursive // conditional type and bail out with a Ternary.Maybe result. if (isDeeplyNestedType(source, sourceStack, sourceDepth, 10)) { - resetErrorInfo(saveErrorInfo); - return 3 /* Maybe */; + return 3 /* Ternary.Maybe */; } - if (targetFlags & 16777216 /* Conditional */) { + if (targetFlags & 16777216 /* TypeFlags.Conditional */) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. @@ -66402,18 +66623,17 @@ var ts; var mapper = void 0; if (sourceParams) { // If the source has infer type parameters, we instantiate them in the context of the target - var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedToWorker); - inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* NoConstraints */ | 1024 /* AlwaysStrict */); + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* InferenceFlags.None */, isRelatedToWorker); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */); sourceExtends = instantiateType(sourceExtends, ctx.mapper); mapper = ctx.mapper; } if (isTypeIdenticalTo(sourceExtends, target.extendsType) && - (isRelatedTo(source.checkType, target.checkType, 3 /* Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* Both */))) { - if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* Both */, reportErrors)) { - result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* Both */, reportErrors); + (isRelatedTo(source.checkType, target.checkType, 3 /* RecursionFlags.Both */) || isRelatedTo(target.checkType, source.checkType, 3 /* RecursionFlags.Both */))) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors)) { + result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), 3 /* RecursionFlags.Both */, reportErrors); } if (result) { - resetErrorInfo(saveErrorInfo); return result; } } @@ -66423,8 +66643,7 @@ var ts; // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = hasNonCircularBaseConstraint(source) ? getConstraintOfDistributiveConditionalType(source) : undefined; if (distributiveConstraint) { - if (result = isRelatedTo(distributiveConstraint, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(distributiveConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } @@ -66433,8 +66652,7 @@ var ts; // when `O` is a conditional (`never` is trivially assignable to `O`, as is `O`!). var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, 1 /* Source */, reportErrors)) { - resetErrorInfo(saveErrorInfo); + if (result = isRelatedTo(defaultConstraint, target, 1 /* RecursionFlags.Source */, reportErrors)) { return result; } } @@ -66442,31 +66660,30 @@ var ts; else { // An empty object type is related to any mapped type that includes a '?' modifier. if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - resetErrorInfo(saveErrorInfo); return result; } } - return 0 /* False */; + return 0 /* Ternary.False */; } - var sourceIsPrimitive = !!(sourceFlags & 131068 /* Primitive */); + var sourceIsPrimitive = !!(sourceFlags & 131068 /* TypeFlags.Primitive */); if (relation !== identityRelation) { source = getApparentType(source); sourceFlags = source.flags; } else if (isGenericMappedType(source)) { - return 0 /* False */; + return 0 /* Ternary.False */; } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && source.target === target.target && !isTupleType(source) && !(isMarkerType(source) || isMarkerType(target))) { // When strictNullChecks is disabled, the element type of the empty array literal is undefinedWideningType, // and an empty array literal wouldn't be assignable to a `never[]` without this check. if (isEmptyArrayLiteralType(source)) { - return -1 /* True */; + return -1 /* Ternary.True */; } // We have type references to the same generic type, and the type references are not marker // type references (which are intended by be compared structurally). Obtain the variance @@ -66476,7 +66693,7 @@ var ts; // effectively means we measure variance only from type parameter occurrences that aren't nested in // recursive instantiations of the generic type. if (variances === ts.emptyArray) { - return 1 /* Unknown */; + return 1 /* Ternary.Unknown */; } var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState); if (varianceResult !== undefined) { @@ -66485,32 +66702,32 @@ var ts; } else if (isReadonlyArrayType(target) ? isArrayOrTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { if (relation !== identityRelation) { - return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* Both */, reportErrors); + return isRelatedTo(getIndexTypeOfType(source, numberType) || anyType, getIndexTypeOfType(target, numberType) || anyType, 3 /* RecursionFlags.Both */, reportErrors); } else { // By flags alone, we know that the `target` is a readonly array while the source is a normal array or tuple // or `target` is an array and source is a tuple - in both cases the types cannot be identical, by construction - return 0 /* False */; + return 0 /* Ternary.False */; } } // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` // and not `{} <- fresh({}) <- {[idx: string]: any}` - else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* FreshLiteral */ && !isEmptyObjectType(source)) { - return 0 /* False */; + else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 8192 /* ObjectFlags.FreshLiteral */ && !isEmptyObjectType(source)) { + return 0 /* Ternary.False */; } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates // to X. Failing both of those we want to check if the aggregation of A and B's members structurally // relates to X. Thus, we include intersection types on the source side here. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 524288 /* Object */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 524288 /* TypeFlags.Object */) { // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, intersectionState); if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 0 /* SignatureKind.Call */, reportStructuralErrors); if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + result &= signaturesRelatedTo(source, target, 1 /* SignatureKind.Construct */, reportStructuralErrors); if (result) { result &= indexSignaturesRelatedTo(source, target, sourceIsPrimitive, reportStructuralErrors, intersectionState); } @@ -66527,9 +66744,9 @@ var ts; // there exists a constituent of T for every combination of the discriminants of S // with respect to T. We do not report errors here, as we will use the existing // error result from checking each constituent of the union. - if (sourceFlags & (524288 /* Object */ | 2097152 /* Intersection */) && targetFlags & 1048576 /* Union */) { - var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); - if (objectOnlyTarget.flags & 1048576 /* Union */) { + if (sourceFlags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && targetFlags & 1048576 /* TypeFlags.Union */) { + var objectOnlyTarget = extractTypesOfKind(target, 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 33554432 /* TypeFlags.Substitution */); + if (objectOnlyTarget.flags & 1048576 /* TypeFlags.Union */) { var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); if (result_9) { return result_9; @@ -66537,7 +66754,7 @@ var ts; } } } - return 0 /* False */; + return 0 /* Ternary.False */; function countMessageChainBreadth(info) { if (!info) return 0; @@ -66547,7 +66764,7 @@ var ts; if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) { return result; } - if (ts.some(variances, function (v) { return !!(v & 24 /* AllowsStructuralFallback */); })) { + if (ts.some(variances, function (v) { return !!(v & 24 /* VarianceFlags.AllowsStructuralFallback */); })) { // If some type parameter was `Unmeasurable` or `Unreliable`, and we couldn't pass by assuming it was identical, then we // have to allow a structural fallback check // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially @@ -66574,8 +66791,8 @@ var ts; // reveal the reason). // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, // we can return `False` early here to skip calculating the structural error message we don't need. - if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceMask */) === 0 /* Invariant */; }))) { - return 0 /* False */; + if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7 /* VarianceFlags.VarianceMask */) === 0 /* VarianceFlags.Invariant */; }))) { + return 0 /* Ternary.False */; } // We remember the original error information so we can restore it in case the structural // comparison unexpectedly succeeds. This can happen when the structural comparison result @@ -66585,18 +66802,6 @@ var ts; } } } - function reportUnmeasurableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(/*onlyUnreliable*/ false); - } - return p; - } - function reportUnreliableMarkers(p) { - if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) { - outofbandVarianceMarkerHandler(/*onlyUnreliable*/ true); - } - return p; - } // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice // that S and T are contra-variant whereas X and Y are co-variant. @@ -66606,15 +66811,15 @@ var ts; if (modifiersRelated) { var result_10; var targetConstraint = getConstraintTypeFromMappedType(target); - var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); - if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) { + var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMapper : reportUnreliableMapper); + if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* RecursionFlags.Both */, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) { - return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors); + return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* RecursionFlags.Both */, reportErrors); } } } - return 0 /* False */; + return 0 /* Ternary.False */; } function typeRelatedToDiscriminatedType(source, target) { // 1. Generate the combinations of discriminant properties & types 'source' can satisfy. @@ -66629,7 +66834,7 @@ var ts; var sourceProperties = getPropertiesOfType(source); var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); if (!sourcePropertiesFiltered) - return 0 /* False */; + return 0 /* Ternary.False */; // Though we could compute the number of combinations as we generate // the matrix, this would incur additional memory overhead due to // array allocations. To reduce this overhead, we first compute @@ -66641,8 +66846,8 @@ var ts; numCombinations *= countTypes(getNonMissingTypeOfSymbol(sourceProperty)); if (numCombinations > 25) { // We've reached the complexity limit. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); - return 0 /* False */; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations }); + return 0 /* Ternary.False */; } } // Compute the set of types for each discriminant property. @@ -66651,7 +66856,7 @@ var ts; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { var sourceProperty = sourcePropertiesFiltered[i]; var sourcePropertyType = getNonMissingTypeOfSymbol(sourceProperty); - sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* Union */ + sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576 /* TypeFlags.Union */ ? sourcePropertyType.types : [sourcePropertyType]; excludedProperties.add(sourceProperty.escapedName); @@ -66660,11 +66865,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_20 = function (combination) { + var _loop_21 = function (combination) { var hasMatch = false; outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) { var type = _d[_c]; - var _loop_21 = function (i) { + var _loop_22 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfType(type, sourceProperty.escapedName); if (!targetProperty) @@ -66672,7 +66877,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* IntersectionState.None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -66680,7 +66885,7 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_8 = _loop_21(i); + var state_8 = _loop_22(i); switch (state_8) { case "continue-outer": continue outer; } @@ -66689,30 +66894,30 @@ var ts; hasMatch = true; } if (!hasMatch) { - return { value: 0 /* False */ }; + return { value: 0 /* Ternary.False */ }; } }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_7 = _loop_20(combination); + var state_7 = _loop_21(combination); if (typeof state_7 === "object") return state_7.value; } // Compare the remaining non-discriminant properties of each match. - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { var type = matchingTypes_1[_b]; - result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* None */); + result &= propertiesRelatedTo(source, type, /*reportErrors*/ false, excludedProperties, 0 /* IntersectionState.None */); if (result) { - result &= signaturesRelatedTo(source, type, 0 /* Call */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 0 /* SignatureKind.Call */, /*reportStructuralErrors*/ false); if (result) { - result &= signaturesRelatedTo(source, type, 1 /* Construct */, /*reportStructuralErrors*/ false); + result &= signaturesRelatedTo(source, type, 1 /* SignatureKind.Construct */, /*reportStructuralErrors*/ false); if (result && !(isTupleType(source) && isTupleType(type))) { // Comparing numeric index types when both `source` and `type` are tuples is unnecessary as the // element types should be sufficiently covered by `propertiesRelatedTo`. It also causes problems // with index type assignability as the types for the excluded discriminants are still included // in the index type. - result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* None */); + result &= indexSignaturesRelatedTo(source, type, /*sourceIsPrimitive*/ false, /*reportStructuralErrors*/ false, 0 /* IntersectionState.None */); } } } @@ -66739,40 +66944,40 @@ var ts; return result || properties; } function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { - var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* Partial */); + var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */); var effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional); var effectiveSource = getTypeOfSourceProperty(sourceProp); - return isRelatedTo(effectiveSource, effectiveTarget, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + return isRelatedTo(effectiveSource, effectiveTarget, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); } function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); - if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ || targetPropFlags & 8 /* ModifierFlags.Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { + if (sourcePropFlags & 8 /* ModifierFlags.Private */ && targetPropFlags & 8 /* ModifierFlags.Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* Private */ ? source : target), typeToString(sourcePropFlags & 8 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? source : target), typeToString(sourcePropFlags & 8 /* ModifierFlags.Private */ ? target : source)); } } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (targetPropFlags & 16 /* Protected */) { + else if (targetPropFlags & 16 /* ModifierFlags.Protected */) { if (!isValidOverrideOf(sourceProp, targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(getDeclaringClass(sourceProp) || source), typeToString(getDeclaringClass(targetProp) || target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } - else if (sourcePropFlags & 16 /* Protected */) { + else if (sourcePropFlags & 16 /* ModifierFlags.Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // Ensure {readonly a: whatever} is not a subtype of {a: whatever}, // while {a: whatever} is a subtype of {readonly a: whatever}. @@ -66782,7 +66987,7 @@ var ts; // This is only applied during the strictSubtypeRelation -- currently used in subtype reduction if (relation === strictSubtypeRelation && isReadonlySymbol(sourceProp) && !isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // If the target comes from a partial union prop, allow `undefined` in the target type var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState); @@ -66790,10 +66995,10 @@ var ts; if (reportErrors) { reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return 0 /* False */; + return 0 /* Ternary.False */; } // When checking for comparability, be more lenient with optional properties. - if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { + if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -66804,7 +67009,7 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } return related; } @@ -66815,7 +67020,7 @@ var ts; && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration) && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name) && source.symbol - && source.symbol.flags & 32 /* Class */) { + && source.symbol.flags & 32 /* SymbolFlags.Class */) { var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText; var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription); if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) { @@ -66857,29 +67062,29 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target, excludedProperties); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (isTupleType(target)) { if (isArrayOrTupleType(source)) { if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) { - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceArity = getTypeReferenceArity(source); var targetArity = getTypeReferenceArity(target); - var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* Rest */ : 4 /* Rest */; - var targetRestFlag = target.target.combinedFlags & 4 /* Rest */; + var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 /* ElementFlags.Rest */ : 4 /* ElementFlags.Rest */; + var targetRestFlag = target.target.combinedFlags & 4 /* ElementFlags.Rest */; var sourceMinLength = isTupleType(source) ? source.target.minLength : 0; var targetMinLength = target.target.minLength; if (!sourceRestFlag && sourceArity < targetMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && targetArity < sourceMinLength) { if (reportErrors) { reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!targetRestFlag && (sourceRestFlag || targetArity < sourceArity)) { if (reportErrors) { @@ -66890,38 +67095,38 @@ var ts; reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity); } } - return 0 /* False */; + return 0 /* Ternary.False */; } var sourceTypeArguments = getTypeArguments(source); var targetTypeArguments = getTypeArguments(target); - var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* NonRest */) : 0, getStartElementCount(target.target, 11 /* NonRest */)); - var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* NonRest */) : 0); + var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, getStartElementCount(target.target, 11 /* ElementFlags.NonRest */)); + var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11 /* ElementFlags.NonRest */) : 0, targetRestFlag ? getEndElementCount(target.target, 11 /* ElementFlags.NonRest */) : 0); var canExcludeDiscriminants = !!excludedProperties; for (var i = 0; i < targetArity; i++) { var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity; - var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* Rest */; + var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4 /* ElementFlags.Rest */; var targetFlags = target.target.elementFlags[i]; - if (targetFlags & 8 /* Variadic */ && !(sourceFlags & 8 /* Variadic */)) { + if (targetFlags & 8 /* ElementFlags.Variadic */ && !(sourceFlags & 8 /* ElementFlags.Variadic */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (sourceFlags & 8 /* Variadic */ && !(targetFlags & 12 /* Variable */)) { + if (sourceFlags & 8 /* ElementFlags.Variadic */ && !(targetFlags & 12 /* ElementFlags.Variable */)) { if (reportErrors) { reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } - if (targetFlags & 1 /* Required */ && !(sourceFlags & 1 /* Required */)) { + if (targetFlags & 1 /* ElementFlags.Required */ && !(sourceFlags & 1 /* ElementFlags.Required */)) { if (reportErrors) { reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i); } - return 0 /* False */; + return 0 /* Ternary.False */; } // We can only exclude discriminant properties if we have not yet encountered a variable-length element. if (canExcludeDiscriminants) { - if (sourceFlags & 12 /* Variable */ || targetFlags & 12 /* Variable */) { + if (sourceFlags & 12 /* ElementFlags.Variable */ || targetFlags & 12 /* ElementFlags.Variable */) { canExcludeDiscriminants = false; } if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) { @@ -66929,12 +67134,12 @@ var ts; } } var sourceType = !isTupleType(source) ? sourceTypeArguments[0] : - i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* Optional */)) : + i < startCount || i >= targetArity - endCount ? removeMissingType(sourceTypeArguments[sourceIndex], !!(sourceFlags & targetFlags & 2 /* ElementFlags.Optional */)) : getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType; var targetType = targetTypeArguments[i]; - var targetCheckType = sourceFlags & 8 /* Variadic */ && targetFlags & 4 /* Rest */ ? createArrayType(targetType) : - removeMissingType(targetType, !!(targetFlags & 2 /* Optional */)); - var related = isRelatedTo(sourceType, targetCheckType, 3 /* Both */, reportErrors, /*headMessage*/ undefined, intersectionState); + var targetCheckType = sourceFlags & 8 /* ElementFlags.Variadic */ && targetFlags & 4 /* ElementFlags.Rest */ ? createArrayType(targetType) : + removeMissingType(targetType, !!(targetFlags & 2 /* ElementFlags.Optional */)); + var related = isRelatedTo(sourceType, targetCheckType, 3 /* RecursionFlags.Both */, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { if (reportErrors && (targetArity > 1 || sourceArity > 1)) { if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) { @@ -66944,14 +67149,14 @@ var ts; reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i); } } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } - if (target.target.combinedFlags & 12 /* Variable */) { - return 0 /* False */; + if (target.target.combinedFlags & 12 /* ElementFlags.Variable */) { + return 0 /* Ternary.False */; } } var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source); @@ -66960,18 +67165,18 @@ var ts; if (reportErrors && shouldReportUnmatchedPropertyError(source, target)) { reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (isObjectLiteralType(target)) { for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) { var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType.flags & 32768 /* Undefined */)) { + if (!(sourceType.flags & 32768 /* TypeFlags.Undefined */)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } } @@ -66983,12 +67188,12 @@ var ts; for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; var name = targetProp.escapedName; - if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { + if (!(targetProp.flags & 4194304 /* SymbolFlags.Prototype */) && (!numericNamesOnly || ts.isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -66997,24 +67202,24 @@ var ts; return result; } function propertiesIdenticalTo(source, target, excludedProperties) { - if (!(source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */)) { - return 0 /* False */; + if (!(source.flags & 524288 /* TypeFlags.Object */ && target.flags & 524288 /* TypeFlags.Object */)) { + return 0 /* Ternary.False */; } var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties); var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties); if (sourceProperties.length !== targetProperties.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) { var sourceProp = sourceProperties_1[_i]; var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName); if (!targetProp) { - return 0 /* False */; + return 0 /* Ternary.False */; } var related = compareProperties(sourceProp, targetProp, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67026,17 +67231,17 @@ var ts; return signaturesIdenticalTo(source, target, kind); } if (target === anyFunctionType || source === anyFunctionType) { - return -1 /* True */; + return -1 /* Ternary.True */; } var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration); var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration); - var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* Construct */) ? - 0 /* Call */ : kind); - if (kind === 1 /* Construct */ && sourceSignatures.length && targetSignatures.length) { - var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* Abstract */); - var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* Abstract */); + var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1 /* SignatureKind.Construct */) ? + 0 /* SignatureKind.Call */ : kind); + if (kind === 1 /* SignatureKind.Construct */ && sourceSignatures.length && targetSignatures.length) { + var sourceIsAbstract = !!(sourceSignatures[0].flags & 4 /* SignatureFlags.Abstract */); + var targetIsAbstract = !!(targetSignatures[0].flags & 4 /* SignatureFlags.Abstract */); if (sourceIsAbstract && !targetIsAbstract) { // An abstract constructor type is not assignable to a non-abstract constructor type // as it would otherwise be possible to new an abstract class. Note that the assignability @@ -67045,18 +67250,18 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); } - return 0 /* False */; + return 0 /* Ternary.False */; } if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } - var result = -1 /* True */; - var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; + var result = -1 /* Ternary.True */; + var incompatibleReporter = kind === 1 /* SignatureKind.Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; var sourceObjectFlags = ts.getObjectFlags(source); var targetObjectFlags = ts.getObjectFlags(target); - if (sourceObjectFlags & 64 /* Instantiated */ && targetObjectFlags & 64 /* Instantiated */ && source.symbol === target.symbol || - sourceObjectFlags & 4 /* Reference */ && targetObjectFlags & 4 /* Reference */ && source.target === target.target) { + if (sourceObjectFlags & 64 /* ObjectFlags.Instantiated */ && targetObjectFlags & 64 /* ObjectFlags.Instantiated */ && source.symbol === target.symbol || + sourceObjectFlags & 4 /* ObjectFlags.Reference */ && targetObjectFlags & 4 /* ObjectFlags.Reference */ && source.target === target.target) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters @@ -67064,7 +67269,7 @@ var ts; for (var i = 0; i < targetSignatures.length; i++) { var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67079,10 +67284,10 @@ var ts; var sourceSignature = ts.first(sourceSignatures); var targetSignature = ts.first(targetSignatures); result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature)); - if (!result && reportErrors && kind === 1 /* Construct */ && (sourceObjectFlags & targetObjectFlags) && - (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* Constructor */)) { + if (!result && reportErrors && kind === 1 /* SignatureKind.Construct */ && (sourceObjectFlags & targetObjectFlags) && + (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 171 /* SyntaxKind.Constructor */ || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 171 /* SyntaxKind.Constructor */)) { var constructSignatureToString = function (signature) { - return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* WriteArrowStyleSignature */, kind); + return signatureToString(signature, /*enclosingDeclaration*/ undefined, 262144 /* TypeFormatFlags.WriteArrowStyleSignature */, kind); }; reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature)); reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible); @@ -67108,18 +67313,18 @@ var ts; if (shouldElaborateErrors) { reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); } - return 0 /* False */; + return 0 /* Ternary.False */; } } return result; } function shouldReportUnmatchedPropertyError(source, target) { - var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* Call */); - var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* Construct */); + var typeCallSignatures = getSignaturesOfStructuredType(source, 0 /* SignatureKind.Call */); + var typeConstructSignatures = getSignaturesOfStructuredType(source, 1 /* SignatureKind.Construct */); var typeProperties = getPropertiesOfObjectType(source); if ((typeCallSignatures.length || typeConstructSignatures.length) && !typeProperties.length) { - if ((getSignaturesOfType(target, 0 /* Call */).length && typeCallSignatures.length) || - (getSignaturesOfType(target, 1 /* Construct */).length && typeConstructSignatures.length)) { + if ((getSignaturesOfType(target, 0 /* SignatureKind.Call */).length && typeCallSignatures.length) || + (getSignaturesOfType(target, 1 /* SignatureKind.Construct */).length && typeConstructSignatures.length)) { return true; // target has similar signature kinds to source, still focus on the unmatched property } return false; @@ -67142,45 +67347,45 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, makeFunctionTypeMapper(reportUnreliableMarkers)); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* SignatureCheckMode.StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedToWorker, reportUnreliableMapper); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var i = 0; i < sourceSignatures.length; i++) { var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, isRelatedTo); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } return result; } function membersRelatedToIndexInfo(source, targetInfo, reportErrors) { - var result = -1 /* True */; + var result = -1 /* Ternary.True */; var keyType = targetInfo.keyType; - var props = source.flags & 2097152 /* Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); + var props = source.flags & 2097152 /* TypeFlags.Intersection */ ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source); for (var _i = 0, props_2 = props; _i < props_2.length; _i++) { var prop = props_2[_i]; // Skip over ignored JSX and symbol-named members if (isIgnoredJsxProperty(source, prop)) { continue; } - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), keyType)) { var propType = getNonMissingTypeOfSymbol(prop); - var type = exactOptionalPropertyTypes || propType.flags & 32768 /* Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* Optional */) + var type = exactOptionalPropertyTypes || propType.flags & 32768 /* TypeFlags.Undefined */ || keyType === numberType || !(prop.flags & 16777216 /* SymbolFlags.Optional */) ? propType - : getTypeWithFacts(propType, 524288 /* NEUndefined */); - var related = isRelatedTo(type, targetInfo.type, 3 /* Both */, reportErrors); + : getTypeWithFacts(propType, 524288 /* TypeFacts.NEUndefined */); + var related = isRelatedTo(type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop)); } - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67190,7 +67395,7 @@ var ts; if (isApplicableIndexType(info.keyType, keyType)) { var related = indexInfoRelatedTo(info, targetInfo, reportErrors); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67198,7 +67403,7 @@ var ts; return result; } function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors) { - var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */, reportErrors); + var related = isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors); if (!related && reportErrors) { if (sourceInfo.keyType === targetInfo.keyType) { reportError(ts.Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType)); @@ -67215,14 +67420,14 @@ var ts; } var indexInfos = getIndexInfosOfType(target); var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; }); - var result = -1 /* True */; + var result = -1 /* Ternary.True */; for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) { var targetInfo = indexInfos_5[_i]; - var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ : - isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) : + var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* TypeFlags.Any */ ? -1 /* Ternary.True */ : + isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* RecursionFlags.Both */, reportErrors) : typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67233,46 +67438,46 @@ var ts; if (sourceInfo) { return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } - if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source)) { + if (!(intersectionState & 1 /* IntersectionState.Source */) && isObjectTypeWithInferableIndex(source)) { // Intersection constituents are never considered to have an inferred index signature return membersRelatedToIndexInfo(source, targetInfo, reportErrors); } if (reportErrors) { reportError(ts.Diagnostics.Index_signature_for_type_0_is_missing_in_type_1, typeToString(targetInfo.keyType), typeToString(source)); } - return 0 /* False */; + return 0 /* Ternary.False */; } function indexSignaturesIdenticalTo(source, target) { var sourceInfos = getIndexInfosOfType(source); var targetInfos = getIndexInfosOfType(target); if (sourceInfos.length !== targetInfos.length) { - return 0 /* False */; + return 0 /* Ternary.False */; } for (var _i = 0, targetInfos_1 = targetInfos; _i < targetInfos_1.length; _i++) { var targetInfo = targetInfos_1[_i]; var sourceInfo = getIndexInfoOfType(source, targetInfo.keyType); - if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { - return 0 /* False */; + if (!(sourceInfo && isRelatedTo(sourceInfo.type, targetInfo.type, 3 /* RecursionFlags.Both */) && sourceInfo.isReadonly === targetInfo.isReadonly)) { + return 0 /* Ternary.False */; } } - return -1 /* True */; + return -1 /* Ternary.True */; } function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) { if (!sourceSignature.declaration || !targetSignature.declaration) { return true; } - var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* NonPublicAccessibilityModifier */); - var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* NonPublicAccessibilityModifier */); + var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); + var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // A public, protected and private signature is assignable to a private signature. - if (targetAccessibility === 8 /* Private */) { + if (targetAccessibility === 8 /* ModifierFlags.Private */) { return true; } // A public and protected signature is assignable to a protected signature. - if (targetAccessibility === 16 /* Protected */ && sourceAccessibility !== 8 /* Private */) { + if (targetAccessibility === 16 /* ModifierFlags.Protected */ && sourceAccessibility !== 8 /* ModifierFlags.Private */) { return true; } // Only a public signature is assignable to public signature. - if (targetAccessibility !== 16 /* Protected */ && !sourceAccessibility) { + if (targetAccessibility !== 16 /* ModifierFlags.Protected */ && !sourceAccessibility) { return true; } if (reportErrors) { @@ -67285,19 +67490,19 @@ var ts; // Okay, yes, 'boolean' is a union of 'true | false', but that's not useful // in error reporting scenarios. If you need to use this function but that detail matters, // feel free to add a flag. - if (type.flags & 16 /* Boolean */) { + if (type.flags & 16 /* TypeFlags.Boolean */) { return false; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes); } - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { var constraint = getConstraintOfType(type); if (constraint && constraint !== type) { return typeCouldHaveTopLevelSingletonTypes(constraint); } } - return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */); + return isUnitType(type) || !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) || !!(type.flags & 268435456 /* TypeFlags.StringMapping */); } function getExactOptionalUnassignableProperties(source, target) { if (isTupleType(source) && isTupleType(target)) @@ -67306,7 +67511,7 @@ var ts; .filter(function (targetProp) { return isExactOptionalPropertyMismatch(getTypeOfPropertyOfType(source, targetProp.escapedName), getTypeOfSymbol(targetProp)); }); } function isExactOptionalPropertyMismatch(source, target) { - return !!source && !!target && maybeTypeOfKind(source, 32768 /* Undefined */) && !!containsMissingType(target); + return !!source && !!target && maybeTypeOfKind(source, 32768 /* TypeFlags.Undefined */) && !!containsMissingType(target); } function getExactOptionalProperties(type) { return getPropertiesOfType(type).filter(function (targetProp) { return containsMissingType(getTypeOfSymbol(targetProp)); }); @@ -67326,7 +67531,7 @@ var ts; for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; var targetProp = getUnionOrIntersectionProperty(target, propertyName); - if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) { + if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* CheckFlags.ReadPartial */) { continue; } var i = 0; @@ -67361,12 +67566,12 @@ var ts; * and no required properties, call/construct signatures or index signatures */ function isWeakType(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 && resolved.indexInfos.length === 0 && - resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* Optional */); }); + resolved.properties.length > 0 && ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216 /* SymbolFlags.Optional */); }); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return ts.every(type.types, isWeakType); } return false; @@ -67382,7 +67587,7 @@ var ts; } function getVariances(type) { // Arrays and tuples are known to be covariant, no need to spend time computing this. - return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* Tuple */ ? + return type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8 /* ObjectFlags.Tuple */ ? arrayVariances : getVariancesWorker(type.symbol, type.typeParameters); } @@ -67398,14 +67603,14 @@ var ts; if (typeParameters === void 0) { typeParameters = ts.emptyArray; } var links = getSymbolLinks(symbol); if (!links.variances) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) }); links.variances = ts.emptyArray; var variances = []; - var _loop_22 = function (tp) { + var _loop_23 = function (tp) { var modifiers = getVarianceModifiers(tp); - var variance = modifiers & 65536 /* Out */ ? - modifiers & 32768 /* In */ ? 0 /* Invariant */ : 1 /* Covariant */ : - modifiers & 32768 /* In */ ? 2 /* Contravariant */ : undefined; + var variance = modifiers & 65536 /* ModifierFlags.Out */ ? + modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ : + modifiers & 32768 /* ModifierFlags.In */ ? 2 /* VarianceFlags.Contravariant */ : undefined; if (variance === undefined) { var unmeasurable_1 = false; var unreliable_1 = false; @@ -67416,33 +67621,33 @@ var ts; // invariance, covariance, contravariance or bivariance. var typeWithSuper = createMarkerType(symbol, tp, markerSuperType); var typeWithSub = createMarkerType(symbol, tp, markerSubType); - variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* Covariant */ : 0) | - (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* Contravariant */ : 0); + variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 /* VarianceFlags.Covariant */ : 0) | + (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 /* VarianceFlags.Contravariant */ : 0); // If the instantiations appear to be related bivariantly it may be because the // type parameter is independent (i.e. it isn't witnessed anywhere in the generic // type). To determine this we compare instantiations where the type parameter is // replaced with marker types that are known to be unrelated. - if (variance === 3 /* Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { - variance = 4 /* Independent */; + if (variance === 3 /* VarianceFlags.Bivariant */ && isTypeAssignableTo(createMarkerType(symbol, tp, markerOtherType), typeWithSuper)) { + variance = 4 /* VarianceFlags.Independent */; } outofbandVarianceMarkerHandler = oldHandler; if (unmeasurable_1 || unreliable_1) { if (unmeasurable_1) { - variance |= 8 /* Unmeasurable */; + variance |= 8 /* VarianceFlags.Unmeasurable */; } if (unreliable_1) { - variance |= 16 /* Unreliable */; + variance |= 16 /* VarianceFlags.Unreliable */; } } } variances.push(variance); }; - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var tp = typeParameters_1[_i]; - _loop_22(tp); + for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { + var tp = typeParameters_2[_i]; + _loop_23(tp); } links.variances = variances; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) }); } return links.variances; } @@ -67452,7 +67657,7 @@ var ts; if (isErrorType(type)) { return type; } - var result = symbol.flags & 524288 /* TypeAlias */ ? + var result = symbol.flags & 524288 /* SymbolFlags.TypeAlias */ ? getTypeAliasInstantiation(symbol, instantiateTypes(getSymbolLinks(symbol).typeParameters, mapper)) : createTypeReference(type, instantiateTypes(type.typeParameters, mapper)); markerTypes.add(getTypeId(result)); @@ -67463,34 +67668,34 @@ var ts; } function getVarianceModifiers(tp) { var _a, _b; - return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* In */); }) ? 32768 /* In */ : 0) | - (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* Out */); }) ? 65536 /* Out */ : 0); + return (ts.some((_a = tp.symbol) === null || _a === void 0 ? void 0 : _a.declarations, function (d) { return ts.hasSyntacticModifier(d, 32768 /* ModifierFlags.In */); }) ? 32768 /* ModifierFlags.In */ : 0) | + (ts.some((_b = tp.symbol) === null || _b === void 0 ? void 0 : _b.declarations, function (d) { return ts.hasSyntacticModifier(d, 65536 /* ModifierFlags.Out */); }) ? 65536 /* ModifierFlags.Out */ : 0); } // Return true if the given type reference has a 'void' type argument for a covariant type parameter. // See comment at call in recursiveTypeRelatedTo for when this case matters. function hasCovariantVoidArgument(typeArguments, variances) { for (var i = 0; i < variances.length; i++) { - if ((variances[i] & 7 /* VarianceMask */) === 1 /* Covariant */ && typeArguments[i].flags & 16384 /* Void */) { + if ((variances[i] & 7 /* VarianceFlags.VarianceMask */) === 1 /* VarianceFlags.Covariant */ && typeArguments[i].flags & 16384 /* TypeFlags.Void */) { return true; } } return false; } function isUnconstrainedTypeParameter(type) { - return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); + return type.flags & 262144 /* TypeFlags.TypeParameter */ && !getConstraintOfTypeParameter(type); } function isNonDeferredTypeReference(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && !type.node; } function isTypeReferenceWithGenericArguments(type) { - return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return !!(t.flags & 262144 /* TypeFlags.TypeParameter */) || isTypeReferenceWithGenericArguments(t); }); } function getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) { var typeParameters = []; var constraintMarker = ""; var sourceId = getTypeReferenceId(source, 0); var targetId = getTypeReferenceId(target, 0); - return "" + constraintMarker + sourceId + "," + targetId + postFix; + return "".concat(constraintMarker).concat(sourceId, ",").concat(targetId).concat(postFix); // getTypeReferenceId(A) returns "111=0-12=1" // where A.id=111 and number.id=12 function getTypeReferenceId(type, depth) { @@ -67498,7 +67703,7 @@ var ts; var result = "" + type.target.id; for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; - if (t.flags & 262144 /* TypeParameter */) { + if (t.flags & 262144 /* TypeFlags.TypeParameter */) { if (ignoreConstraints || isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); if (index < 0) { @@ -67534,12 +67739,12 @@ var ts; var postFix = intersectionState ? ":" + intersectionState : ""; return isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target) ? getGenericTypeReferenceRelationKey(source, target, postFix, ignoreConstraints) : - source.id + "," + target.id + postFix; + "".concat(source.id, ",").concat(target.id).concat(postFix); } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (ts.getCheckFlags(prop) & 6 /* Synthetic */) { + if (ts.getCheckFlags(prop) & 6 /* CheckFlags.Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.escapedName); @@ -67554,7 +67759,7 @@ var ts; } // Return the declaring class type of a property or undefined if property not declared in class function getDeclaringClass(prop) { - return prop.parent && prop.parent.flags & 32 /* Class */ ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined; + return prop.parent && prop.parent.flags & 32 /* SymbolFlags.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) { @@ -67572,13 +67777,13 @@ var ts; } // Return true if source property is a valid override of protected parts of target property. function isValidOverrideOf(sourceProp, targetProp) { - return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* Protected */ ? + return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 /* ModifierFlags.Protected */ ? !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; }); } // Return true if the given class derives from each of the declaring classes of the protected // constituents of the given property. function isClassDerivedFromDeclaringClasses(checkClass, prop, writing) { - return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* Protected */ ? + return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p, writing) & 16 /* ModifierFlags.Protected */ ? !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass; } // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons @@ -67624,14 +67829,14 @@ var ts; // reference the type have a recursion identity that differs from the object identity. function getRecursionIdentity(type) { // Object and array literals are known not to contain recursive references and don't need a recursion identity. - if (type.flags & 524288 /* Object */ && !isObjectOrArrayLiteralType(type)) { - if (ts.getObjectFlags(type) && 4 /* Reference */ && type.node) { + if (type.flags & 524288 /* TypeFlags.Object */ && !isObjectOrArrayLiteralType(type)) { + if (ts.getObjectFlags(type) && 4 /* ObjectFlags.Reference */ && type.node) { // Deferred type references are tracked through their associated AST node. This gives us finer // granularity than using their associated target because each manifest type reference has a // unique AST node. return type.node; } - if (type.symbol && !(ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol.flags & 32 /* Class */)) { + if (type.symbol && !(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && type.symbol.flags & 32 /* SymbolFlags.Class */)) { // We track all object types that have an associated symbol (representing the origin of the type), but // exclude the static side of classes from this check since it shares its symbol with the instance side. return type.symbol; @@ -67641,49 +67846,49 @@ var ts; return type.target; } } - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { return type.symbol; } - if (type.flags & 8388608 /* IndexedAccess */) { + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { // Identity is the leftmost object type in a chain of indexed accesses, eg, in A[P][Q] it is A do { type = type.objectType; - } while (type.flags & 8388608 /* IndexedAccess */); + } while (type.flags & 8388608 /* TypeFlags.IndexedAccess */); return type; } - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { // The root object represents the origin of the conditional type return type.root; } return type; } function isPropertyIdenticalTo(sourceProp, targetProp) { - return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* False */; + return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0 /* Ternary.False */; } function compareProperties(sourceProp, targetProp, compareTypes) { // Two members are considered identical when // - they are public properties with identical names, optionality, and types, // - they are private or protected properties originating in the same declaration and having identical types if (sourceProp === targetProp) { - return -1 /* True */; + return -1 /* Ternary.True */; } - var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* NonPublicAccessibilityModifier */; - var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* NonPublicAccessibilityModifier */; + var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; + var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */; if (sourcePropAccessibility !== targetPropAccessibility) { - return 0 /* False */; + return 0 /* Ternary.False */; } if (sourcePropAccessibility) { if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } } else { - if ((sourceProp.flags & 16777216 /* Optional */) !== (targetProp.flags & 16777216 /* Optional */)) { - return 0 /* False */; + if ((sourceProp.flags & 16777216 /* SymbolFlags.Optional */) !== (targetProp.flags & 16777216 /* SymbolFlags.Optional */)) { + return 0 /* Ternary.False */; } } if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) { - return 0 /* False */; + return 0 /* Ternary.False */; } return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -67714,14 +67919,14 @@ var ts; function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { - return -1 /* True */; + return -1 /* Ternary.True */; } if (!(isMatchingSignature(source, target, partialMatch))) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that the two signatures have the same number of type parameters. if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) { - return 0 /* False */; + return 0 /* Ternary.False */; } // Check that type parameter constraints and defaults match. If they do, instantiate the source // signature with the type parameters of the target signature and continue the comparison. @@ -67732,12 +67937,12 @@ var ts; var t = target.typeParameters[i]; if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) && compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) { - return 0 /* False */; + return 0 /* Ternary.False */; } } source = instantiateSignature(source, mapper, /*eraseTypeParameters*/ true); } - var result = -1 /* True */; + var result = -1 /* Ternary.True */; if (!ignoreThisTypes) { var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType) { @@ -67745,7 +67950,7 @@ var ts; if (targetThisType) { var related = compareTypes(sourceThisType, targetThisType); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67757,7 +67962,7 @@ var ts; var t = getTypeAtPosition(target, i); var related = compareTypes(t, s); if (!related) { - return 0 /* False */; + return 0 /* Ternary.False */; } result &= related; } @@ -67771,56 +67976,52 @@ var ts; return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : - source.type === target.type ? -1 /* True */ : + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* Ternary.False */ : + source.type === target.type ? -1 /* Ternary.True */ : source.type && target.type ? compareTypes(source.type, target.type) : - 0 /* False */; + 0 /* Ternary.False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { var t = types_13[_i]; - var baseType = getBaseTypeOfLiteralType(t); - if (!commonBaseType) { - commonBaseType = baseType; - } - if (baseType === t || baseType !== commonBaseType) { - return false; + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + var baseType = getBaseTypeOfLiteralType(t); + commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType); + if (baseType === t || baseType !== commonBaseType) { + return false; + } } } return true; } - // When the candidate types are all literal types with the same base type, return a union - // of those literal types. Otherwise, return the leftmost type for which no type to the - // right is a supertype. - function getSupertypeOrUnion(types) { - if (types.length === 1) { - return types[0]; - } - return literalTypesWithSameBaseType(types) ? - getUnionType(types) : - ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + function getCombinedTypeFlags(types) { + return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 /* TypeFlags.Union */ ? getCombinedTypeFlags(t.types) : t.flags); }, 0); } function getCommonSupertype(types) { - if (!strictNullChecks) { - return getSupertypeOrUnion(types); - } - var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); }); - if (primaryTypes.length) { - var supertypeOrUnion = getSupertypeOrUnion(primaryTypes); - return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true)); + if (types.length === 1) { + return types[0]; } - return getUnionType(types, 2 /* Subtype */); + // Remove nullable types from each of the candidates. + var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304 /* TypeFlags.Nullable */); }); }) : types; + // When the candidate types are all literal types with the same base type, return a union + // of those literal types. Otherwise, return the leftmost type for which no type to the + // right is a supertype. + var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ? + getUnionType(primaryTypes) : + ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; }); + // Add any nullable types that occurred in the candidates back to the result. + return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* TypeFlags.Nullable */); } // Return the leftmost type for which no type to the right is a subtype. function getCommonSubtype(types) { return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; }); } function isArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && (type.target === globalArrayType || type.target === globalReadonlyArrayType); } function isReadonlyArrayType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) && type.target === globalReadonlyArrayType; } function isArrayOrTupleType(type) { return isArrayType(type) || isTupleType(type); @@ -67834,22 +68035,22 @@ var ts; function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, // or if it is not the undefined or null type and if it is assignable to ReadonlyArray - return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); + return isArrayType(type) || !(type.flags & 98304 /* TypeFlags.Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function getSingleBaseForNonAugmentingSubtype(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ObjectFlags.ClassOrInterface */)) { return undefined; } - if (ts.getObjectFlags(type) & 33554432 /* IdenticalBaseTypeCalculated */) { - return ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; + if (ts.getObjectFlags(type) & 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */) { + return ts.getObjectFlags(type) & 67108864 /* ObjectFlags.IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined; } - type.objectFlags |= 33554432 /* IdenticalBaseTypeCalculated */; + type.objectFlags |= 33554432 /* ObjectFlags.IdenticalBaseTypeCalculated */; var target = type.target; - if (ts.getObjectFlags(target) & 1 /* Class */) { + if (ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { var baseTypeNode = getBaseTypeNodeOfClass(target); // A base type expression may circularly reference the class itself (e.g. as an argument to function call), so we only // check for base types specified as simple qualified names. - if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* Identifier */ && baseTypeNode.expression.kind !== 206 /* PropertyAccessExpression */) { + if (baseTypeNode && baseTypeNode.expression.kind !== 79 /* SyntaxKind.Identifier */ && baseTypeNode.expression.kind !== 206 /* SyntaxKind.PropertyAccessExpression */) { return undefined; } } @@ -67864,7 +68065,7 @@ var ts; if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) { instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type))); } - type.objectFlags |= 67108864 /* IdenticalBaseTypeExists */; + type.objectFlags |= 67108864 /* ObjectFlags.IdenticalBaseTypeExists */; return type.cachedEquivalentBaseType = instantiatedBase; } function isEmptyLiteralType(type) { @@ -67891,44 +68092,49 @@ var ts; return undefined; } function isNeitherUnitTypeNorNever(type) { - return !(type.flags & (109440 /* Unit */ | 131072 /* Never */)); + return !(type.flags & (109440 /* TypeFlags.Unit */ | 131072 /* TypeFlags.Never */)); } function isUnitType(type) { - return !!(type.flags & 109440 /* Unit */); + return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.some(type.types, isUnitType) : - !!(type.flags & 109440 /* Unit */); + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isUnitType) : + !!(type.flags & 109440 /* TypeFlags.Unit */); } function extractUnitType(type) { - return type.flags & 2097152 /* Intersection */ ? ts.find(type.types, isUnitType) || type : type; + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; } function isLiteralType(type) { - return type.flags & 16 /* Boolean */ ? true : - type.flags & 1048576 /* Union */ ? type.flags & 1024 /* EnumLiteral */ ? true : ts.every(type.types, isUnitType) : + return type.flags & 16 /* TypeFlags.Boolean */ ? true : + type.flags & 1048576 /* TypeFlags.Union */ ? type.flags & 1024 /* TypeFlags.EnumLiteral */ ? true : ts.every(type.types, isUnitType) : isUnitType(type); } function getBaseTypeOfLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : - type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? stringType : - type.flags & 256 /* NumberLiteral */ ? numberType : - type.flags & 2048 /* BigIntLiteral */ ? bigintType : - type.flags & 512 /* BooleanLiteral */ ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getBaseTypeOfLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ ? getBaseTypeOfEnumLiteralType(type) : + type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? getBaseTypeOfLiteralTypeUnion(type) : type; } + function getBaseTypeOfLiteralTypeUnion(type) { + var _a; + var key = "B".concat(getTypeId(type)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, mapType(type, getBaseTypeOfLiteralType)); + } function getWidenedLiteralType(type) { - return type.flags & 1024 /* EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : - type.flags & 128 /* StringLiteral */ && isFreshLiteralType(type) ? stringType : - type.flags & 256 /* NumberLiteral */ && isFreshLiteralType(type) ? numberType : - type.flags & 2048 /* BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : - type.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedLiteralType) : + return type.flags & 1024 /* TypeFlags.EnumLiteral */ && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) : + type.flags & 128 /* TypeFlags.StringLiteral */ && isFreshLiteralType(type) ? stringType : + type.flags & 256 /* TypeFlags.NumberLiteral */ && isFreshLiteralType(type) ? numberType : + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isFreshLiteralType(type) ? bigintType : + type.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(type) ? booleanType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedLiteralType) : type; } function getWidenedUniqueESSymbolType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? esSymbolType : - type.flags & 1048576 /* Union */ ? mapType(type, getWidenedUniqueESSymbolType) : + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? esSymbolType : + type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getWidenedUniqueESSymbolType) : type; } function getWidenedLiteralLikeTypeForContextualType(type, contextualType) { @@ -67959,10 +68165,10 @@ var ts; * Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required. */ function isTupleType(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); + return !!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target.objectFlags & 8 /* ObjectFlags.Tuple */); } function isGenericTupleType(type) { - return isTupleType(type) && !!(type.target.combinedFlags & 8 /* Variadic */); + return isTupleType(type) && !!(type.target.combinedFlags & 8 /* ElementFlags.Variadic */); } function isSingleElementGenericTupleType(type) { return isGenericTupleType(type) && type.target.elementFlags.length === 1; @@ -67983,7 +68189,7 @@ var ts; var elementTypes = []; for (var i = index; i < length; i++) { var t = typeArguments[i]; - elementTypes.push(type.target.elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessType(t, numberType) : t); + elementTypes.push(type.target.elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessType(t, numberType) : t); } return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes); } @@ -67991,28 +68197,28 @@ var ts; } function isTupleTypeStructureMatching(t1, t2) { return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && - ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* Variable */) === (t2.target.elementFlags[i] & 12 /* Variable */); }); + ts.every(t1.target.elementFlags, function (f, i) { return (f & 12 /* ElementFlags.Variable */) === (t2.target.elementFlags[i] & 12 /* ElementFlags.Variable */); }); } function isZeroBigInt(_a) { var value = _a.value; return value.base10Value === "0"; } function removeDefinitelyFalsyTypes(type) { - return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* Truthy */); }); + return filterType(type, function (t) { return !!(getTypeFacts(t) & 4194304 /* TypeFacts.Truthy */); }); } function extractDefinitelyFalsyTypes(type) { return mapType(type, getDefinitelyFalsyPartOfType); } function getDefinitelyFalsyPartOfType(type) { - return type.flags & 4 /* String */ ? emptyStringType : - type.flags & 8 /* Number */ ? zeroType : - type.flags & 64 /* BigInt */ ? zeroBigIntType : + return type.flags & 4 /* TypeFlags.String */ ? emptyStringType : + type.flags & 8 /* TypeFlags.Number */ ? zeroType : + type.flags & 64 /* TypeFlags.BigInt */ ? zeroBigIntType : type === regularFalseType || type === falseType || - type.flags & (16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */ | 3 /* AnyOrUnknown */) || - type.flags & 128 /* StringLiteral */ && type.value === "" || - type.flags & 256 /* NumberLiteral */ && type.value === 0 || - type.flags & 2048 /* BigIntLiteral */ && isZeroBigInt(type) ? type : + type.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */ | 3 /* TypeFlags.AnyOrUnknown */) || + type.flags & 128 /* TypeFlags.StringLiteral */ && type.value === "" || + type.flags & 256 /* TypeFlags.NumberLiteral */ && type.value === 0 || + type.flags & 2048 /* TypeFlags.BigIntLiteral */ && isZeroBigInt(type) ? type : neverType; } /** @@ -68021,27 +68227,27 @@ var ts; * @param flags - Either TypeFlags.Undefined or TypeFlags.Null, or both */ function getNullableType(type, flags) { - var missing = (flags & ~type.flags) & (32768 /* Undefined */ | 65536 /* Null */); + var missing = (flags & ~type.flags) & (32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */); return missing === 0 ? type : - missing === 32768 /* Undefined */ ? getUnionType([type, undefinedType]) : - missing === 65536 /* Null */ ? getUnionType([type, nullType]) : + missing === 32768 /* TypeFlags.Undefined */ ? getUnionType([type, undefinedType]) : + missing === 65536 /* TypeFlags.Null */ ? getUnionType([type, nullType]) : getUnionType([type, undefinedType, nullType]); } function getOptionalType(type, isProperty) { if (isProperty === void 0) { isProperty = false; } ts.Debug.assert(strictNullChecks); - return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); + return type.flags & 32768 /* TypeFlags.Undefined */ ? type : getUnionType([type, isProperty ? missingType : undefinedType]); } function getGlobalNonNullableTypeInstantiation(type) { if (!deferredGlobalNonNullableTypeAlias) { - deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; + deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* SymbolFlags.TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol; } return deferredGlobalNonNullableTypeAlias !== unknownSymbol ? getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]) : getIntersectionType([type, emptyObjectType]); } function getNonNullableType(type) { - return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return strictNullChecks ? getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function addOptionalTypeMarker(type) { return strictNullChecks ? getUnionType([type, optionalType]) : type; @@ -68061,10 +68267,10 @@ var ts; return exactOptionalPropertyTypes && isOptional ? removeType(type, missingType) : type; } function containsMissingType(type) { - return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* Union */ && containsType(type.types, missingType)); + return exactOptionalPropertyTypes && (type === missingType || type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, missingType)); } function removeMissingOrUndefinedType(type) { - return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* NEUndefined */); + return exactOptionalPropertyTypes ? removeType(type, missingType) : getTypeWithFacts(type, 524288 /* TypeFacts.NEUndefined */); } /** * Is source potentially coercible to target type under `==`. @@ -68087,8 +68293,8 @@ var ts; * @param target */ function isCoercibleUnderDoubleEquals(source, target) { - return ((source.flags & (8 /* Number */ | 4 /* String */ | 512 /* BooleanLiteral */)) !== 0) - && ((target.flags & (8 /* Number */ | 4 /* String */ | 16 /* Boolean */)) !== 0); + return ((source.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 512 /* TypeFlags.BooleanLiteral */)) !== 0) + && ((target.flags & (8 /* TypeFlags.Number */ | 4 /* TypeFlags.String */ | 16 /* TypeFlags.Boolean */)) !== 0); } /** * Return true if type was inferred from an object literal, written as an object type literal, or is the shape of a module @@ -68096,15 +68302,15 @@ var ts; */ function isObjectTypeWithInferableIndex(type) { var objectFlags = ts.getObjectFlags(type); - return type.flags & 2097152 /* Intersection */ + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.every(type.types, isObjectTypeWithInferableIndex) : !!(type.symbol - && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 - && !(type.symbol.flags & 32 /* Class */) - && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); + && (type.symbol.flags & (4096 /* SymbolFlags.ObjectLiteral */ | 2048 /* SymbolFlags.TypeLiteral */ | 384 /* SymbolFlags.Enum */ | 512 /* SymbolFlags.ValueModule */)) !== 0 + && !(type.symbol.flags & 32 /* SymbolFlags.Class */) + && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectFlags.ObjectRestType */) || !!(objectFlags & 1024 /* ObjectFlags.ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { - var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); + var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* CheckFlags.Readonly */); symbol.declarations = source.declarations; symbol.parent = source.parent; symbol.type = type; @@ -68134,7 +68340,7 @@ var ts; * Leave signatures alone since they are not subject to the check. */ function getRegularTypeOfObjectLiteral(type) { - if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* FreshLiteral */)) { + if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 8192 /* ObjectFlags.FreshLiteral */)) { return type; } var regularType = type.regularType; @@ -68145,7 +68351,7 @@ var ts; var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral); var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.indexInfos); regularNew.flags = resolved.flags; - regularNew.objectFlags |= resolved.objectFlags & ~8192 /* FreshLiteral */; + regularNew.objectFlags |= resolved.objectFlags & ~8192 /* ObjectFlags.FreshLiteral */; type.regularType = regularNew; return regularNew; } @@ -68175,7 +68381,7 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) { var t = _a[_i]; - if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ContainsSpread */)) { + if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 2097152 /* ObjectFlags.ContainsSpread */)) { for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) { var prop = _c[_b]; names.set(prop.escapedName, prop); @@ -68187,7 +68393,7 @@ var ts; return context.resolvedProperties; } function getWidenedProperty(prop, context) { - if (!(prop.flags & 4 /* Property */)) { + if (!(prop.flags & 4 /* SymbolFlags.Property */)) { // Since get accessors already widen their return value there is no need to // widen accessor based properties here. return prop; @@ -68203,7 +68409,7 @@ var ts; return cached; } var result = createSymbolWithType(prop, missingType); - result.flags |= 16777216 /* Optional */; + result.flags |= 16777216 /* SymbolFlags.Optional */; undefinedProperties.set(prop.escapedName, result); return result; } @@ -68222,33 +68428,33 @@ var ts; } } var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, ts.sameMap(getIndexInfosOfType(type), function (info) { return createIndexInfo(info.keyType, getWidenedType(info.type), info.isReadonly); })); - result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* JSLiteral */ | 262144 /* NonInferrableType */)); // Retain js literal flag through widening + result.objectFlags |= (ts.getObjectFlags(type) & (4096 /* ObjectFlags.JSLiteral */ | 262144 /* ObjectFlags.NonInferrableType */)); // Retain js literal flag through widening return result; } function getWidenedType(type) { return getWidenedTypeWithContext(type, /*context*/ undefined); } function getWidenedTypeWithContext(type, context) { - if (ts.getObjectFlags(type) & 196608 /* RequiresWidening */) { + if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) { if (context === undefined && type.widened) { return type.widened; } var result = void 0; - if (type.flags & (1 /* Any */ | 98304 /* Nullable */)) { + if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) { result = anyType; } else if (isObjectLiteralType(type)) { result = getWidenedTypeOfObjectLiteral(type, context); } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); - var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); + var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); // Widening an empty object literal transitions from a highly restrictive type to // a highly inclusive one. For that reason we perform subtype reduction here if the // union includes empty object types (e.g. reducing {} | string to just {}). - result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* Subtype */ : 1 /* Literal */); + result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayOrTupleType(type)) { @@ -68274,8 +68480,8 @@ var ts; */ function reportWideningErrorsInType(type) { var errorReported = false; - if (ts.getObjectFlags(type) & 65536 /* ContainsWideningType */) { - if (type.flags & 1048576 /* Union */) { + if (ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { if (ts.some(type.types, isEmptyObjectType)) { errorReported = true; } @@ -68300,7 +68506,7 @@ var ts; for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) { var p = _e[_d]; var t = getTypeOfSymbol(p); - if (ts.getObjectFlags(t) & 65536 /* ContainsWideningType */) { + if (ts.getObjectFlags(t) & 65536 /* ObjectFlags.ContainsWideningType */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -68319,17 +68525,17 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 221 /* BinaryExpression */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: + case 221 /* SyntaxKind.BinaryExpression */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && param.parent.parameters.indexOf(param) > -1 && - (resolveName(param, param.name.escapedText, 788968 /* Type */, undefined, param.name.escapedText, /*isUse*/ true) || + (resolveName(param, param.name.escapedText, 788968 /* SymbolFlags.Type */, undefined, param.name.escapedText, /*isUse*/ true) || param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) { var newName = "arg" + param.parent.parameters.indexOf(param); var typeName = ts.declarationNameToString(param.name) + (param.dotDotDotToken ? "[]" : ""); @@ -68340,25 +68546,25 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 256 /* FunctionDeclaration */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: if (noImplicitAny && !declaration.name) { - if (wideningKind === 3 /* GeneratorYield */) { + if (wideningKind === 3 /* WideningKind.GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); } else { @@ -68367,10 +68573,10 @@ var ts; return; } diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage : - wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : + wideningKind === 3 /* WideningKind.GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -68382,7 +68588,7 @@ var ts; } function reportErrorsFromWidening(declaration, type, wideningKind) { addLazyDiagnostic(function () { - if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { + if (noImplicitAny && ts.getObjectFlags(type) & 65536 /* ObjectFlags.ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -68434,27 +68640,29 @@ var ts; signature: signature, flags: flags, compareTypes: compareTypes, - mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ true); }), - nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ false); }), + mapper: reportUnmeasurableMapper, + nonFixingMapper: reportUnmeasurableMapper, }; + context.mapper = makeFixingMapperForContext(context); + context.nonFixingMapper = makeNonFixingMapperForContext(context); return context; } - function mapToInferredType(context, t, fix) { - var inferences = context.inferences; - for (var i = 0; i < inferences.length; i++) { - var inference = inferences[i]; - if (t === inference.typeParameter) { - if (fix && !inference.isFixed) { - // Before we commit to a particular inference (and thus lock out any further inferences), - // we infer from any intra-expression inference sites we have collected. - inferFromIntraExpressionSites(context); - clearCachedInferences(inferences); - inference.isFixed = true; - } - return getInferredType(context, i); + function makeFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (inference, i) { return function () { + if (!inference.isFixed) { + // Before we commit to a particular inference (and thus lock out any further inferences), + // we infer from any intra-expression inference sites we have collected. + inferFromIntraExpressionSites(context); + clearCachedInferences(context.inferences); + inference.isFixed = true; } - } - return t; + return getInferredType(context, i); + }; })); + } + function makeNonFixingMapperForContext(context) { + return makeDeferredTypeMapper(ts.map(context.inferences, function (i) { return i.typeParameter; }), ts.map(context.inferences, function (_, i) { return function () { + return getInferredType(context, i); + }; })); } function clearCachedInferences(inferences) { for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { @@ -68485,9 +68693,9 @@ var ts; if (context.intraExpressionInferenceSites) { for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) { var _b = _a[_i], node = _b.node, type = _b.type; - var contextualType = node.kind === 169 /* MethodDeclaration */ ? - getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) : - getContextualType(node, 2 /* NoConstraints */); + var contextualType = node.kind === 169 /* SyntaxKind.MethodDeclaration */ ? + getContextualTypeForObjectLiteralMethod(node, 2 /* ContextFlags.NoConstraints */) : + getContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { inferTypes(context.inferences, type, contextualType); } @@ -68533,40 +68741,40 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) { - return !!(objectFlags & 1048576 /* CouldContainTypeVariables */); + if (objectFlags & 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 1048576 /* ObjectFlags.CouldContainTypeVariables */); } - var result = !!(type.flags & 465829888 /* Instantiable */ || - 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 */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); - if (type.flags & 3899393 /* ObjectFlagsType */) { - type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0); + var result = !!(type.flags & 465829888 /* TypeFlags.Instantiable */ || + type.flags & 524288 /* TypeFlags.Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* ObjectFlags.Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || + objectFlags & 16 /* ObjectFlags.Anonymous */ && type.symbol && type.symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 2048 /* SymbolFlags.TypeLiteral */ | 4096 /* SymbolFlags.ObjectLiteral */) && type.symbol.declarations || + objectFlags & (32 /* ObjectFlags.Mapped */ | 1024 /* ObjectFlags.ReverseMapped */ | 4194304 /* ObjectFlags.ObjectRestType */ | 8388608 /* ObjectFlags.InstantiationExpressionType */)) || + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && !(type.flags & 1024 /* TypeFlags.EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables)); + if (type.flags & 3899393 /* TypeFlags.ObjectFlagsType */) { + type.objectFlags |= 524288 /* ObjectFlags.CouldContainTypeVariablesComputed */ | (result ? 1048576 /* ObjectFlags.CouldContainTypeVariables */ : 0); } return result; } function isNonGenericTopLevelType(type) { if (type.aliasSymbol && !type.aliasTypeArguments) { - var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* TypeAliasDeclaration */); - return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SourceFile */ ? true : n.kind === 261 /* ModuleDeclaration */ ? false : "quit"; })); + var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 259 /* SyntaxKind.TypeAliasDeclaration */); + return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 305 /* SyntaxKind.SourceFile */ ? true : n.kind === 261 /* SyntaxKind.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); }) || - type.flags & 16777216 /* Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); + type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) || + type.flags & 16777216 /* TypeFlags.Conditional */ && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter)); } /** Create an object with properties named in the string literal type. Every property has type `any` */ function createEmptyObjectTypeFromStringLiteral(type) { var members = ts.createSymbolTable(); forEachType(type, function (t) { - if (!(t.flags & 128 /* StringLiteral */)) { + if (!(t.flags & 128 /* TypeFlags.StringLiteral */)) { return; } var name = ts.escapeLeadingUnderscores(t.value); - var literalProp = createSymbol(4 /* Property */, name); + var literalProp = createSymbol(4 /* SymbolFlags.Property */, name); literalProp.type = anyType; if (t.symbol) { literalProp.declarations = t.symbol.declarations; @@ -68574,7 +68782,7 @@ var ts; } members.set(name, literalProp); }); - var indexInfos = type.flags & 4 /* String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; + var indexInfos = type.flags & 4 /* TypeFlags.String */ ? [createIndexInfo(stringType, emptyObjectType, /*isReadonly*/ false)] : ts.emptyArray; return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfos); } /** @@ -68602,7 +68810,7 @@ var ts; // literal { a: 123, b: x => true } is marked non-inferable because it contains a context sensitive // arrow function, but is considered partially inferable because property 'a' has an inferable type. function isPartiallyInferableType(type) { - return !(ts.getObjectFlags(type) & 262144 /* NonInferrableType */) || + return !(ts.getObjectFlags(type) & 262144 /* ObjectFlags.NonInferrableType */) || isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) || isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType); } @@ -68619,14 +68827,14 @@ var ts; } if (isTupleType(source)) { var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); - var elementFlags = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? - ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* Optional */ ? 1 /* Required */ : f; }) : + var elementFlags = getMappedTypeModifiers(target) & 4 /* MappedTypeModifiers.IncludeOptional */ ? + ts.sameMap(source.target.elementFlags, function (f) { return f & 2 /* ElementFlags.Optional */ ? 1 /* ElementFlags.Required */ : f; }) : source.target.elementFlags; return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations); } // For all other object types we infer a new object type where the reverse mapping has been // applied to the type of each property. - var reversed = createObjectType(1024 /* ReverseMapped */ | 16 /* Anonymous */, /*symbol*/ undefined); + var reversed = createObjectType(1024 /* ObjectFlags.ReverseMapped */ | 16 /* ObjectFlags.Anonymous */, /*symbol*/ undefined); reversed.source = source; reversed.mappedType = target; reversed.constraintType = constraint; @@ -68661,7 +68869,7 @@ var ts; if (isStaticPrivateIdentifierProperty(targetProp)) { return [3 /*break*/, 5]; } - if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */ || ts.getCheckFlags(targetProp) & 48 /* Partial */))) return [3 /*break*/, 5]; + if (!(requireOptionalProperties || !(targetProp.flags & 16777216 /* SymbolFlags.Optional */ || ts.getCheckFlags(targetProp) & 48 /* CheckFlags.Partial */))) return [3 /*break*/, 5]; sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!!sourceProp) return [3 /*break*/, 3]; return [4 /*yield*/, targetProp]; @@ -68671,9 +68879,9 @@ var ts; case 3: if (!matchDiscriminantProperties) return [3 /*break*/, 5]; targetType = getTypeOfSymbol(targetProp); - if (!(targetType.flags & 109440 /* Unit */)) return [3 /*break*/, 5]; + if (!(targetType.flags & 109440 /* TypeFlags.Unit */)) return [3 /*break*/, 5]; sourceType = getTypeOfSymbol(sourceProp); - if (!!(sourceType.flags & 1 /* Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; + if (!!(sourceType.flags & 1 /* TypeFlags.Any */ || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3 /*break*/, 5]; return [4 /*yield*/, targetProp]; case 4: _a.sent(); @@ -68691,7 +68899,7 @@ var ts; return result.value; } function tupleTypesDefinitelyUnrelated(source, target) { - return !(target.target.combinedFlags & 8 /* Variadic */) && target.target.minLength > source.target.minLength || + return !(target.target.combinedFlags & 8 /* ElementFlags.Variadic */) && target.target.minLength > source.target.minLength || !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength); } function typesDefinitelyUnrelated(source, target) { @@ -68702,7 +68910,7 @@ var ts; !!getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false, /*matchDiscriminantProperties*/ false); } function getTypeFromInference(inference) { - return inference.candidates ? getUnionType(inference.candidates, 2 /* Subtype */) : + return inference.candidates ? getUnionType(inference.candidates, 2 /* UnionReduction.Subtype */) : inference.contraCandidates ? getIntersectionType(inference.contraCandidates) : undefined; } @@ -68739,7 +68947,7 @@ var ts; */ function parseBigIntLiteralType(text) { var negative = text.startsWith("-"); - var base10Value = ts.parsePseudoBigInt((negative ? text.slice(1) : text) + "n"); + var base10Value = ts.parsePseudoBigInt("".concat(negative ? text.slice(1) : text, "n")); return getBigIntLiteralType({ negative: negative, base10Value: base10Value }); } /** @@ -68750,12 +68958,12 @@ var ts; function isValidBigIntString(s, roundTripOnly) { if (s === "") return false; - var scanner = ts.createScanner(99 /* ESNext */, /*skipTrivia*/ false); + var scanner = ts.createScanner(99 /* ScriptTarget.ESNext */, /*skipTrivia*/ false); var success = true; scanner.setOnError(function () { return success = false; }); scanner.setText(s + "n"); var result = scanner.scan(); - var negative = result === 40 /* MinusToken */; + var negative = result === 40 /* SyntaxKind.MinusToken */; if (negative) { result = scanner.scan(); } @@ -68765,17 +68973,17 @@ var ts; // * a bigint can be scanned, and that when it is scanned, it is // * the full length of the input string (so the scanner is one character beyond the augmented input length) // * it does not contain a numeric seperator (the `BigInt` constructor does not accept a numeric seperator in its input) - return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */) + return success && result === 9 /* SyntaxKind.BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* TokenFlags.ContainsSeparator */) && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) })); } function isMemberOfStringMapping(source, target) { - if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) { + if (target.flags & (4 /* TypeFlags.String */ | 3 /* TypeFlags.AnyOrUnknown */)) { return true; } - if (target.flags & 134217728 /* TemplateLiteral */) { + if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { return isTypeAssignableTo(source, target); } - if (target.flags & 268435456 /* StringMapping */) { + if (target.flags & 268435456 /* TypeFlags.StringMapping */) { // We need to see whether applying the same mappings of the target // onto the source would produce an identical type *and* that // it's compatible with the inner-most non-string-mapped type. @@ -68784,7 +68992,7 @@ var ts; // and the source is compatible with the unmapped target, then they must // still reside in the same domain. var mappingStack = []; - while (target.flags & 268435456 /* StringMapping */) { + while (target.flags & 268435456 /* TypeFlags.StringMapping */) { mappingStack.unshift(target.symbol); target = target.type; } @@ -68794,25 +69002,25 @@ var ts; return false; } function isValidTypeForTemplateLiteralPlaceholder(source, target) { - if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) { + if (source === target || target.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */)) { return true; } - if (source.flags & 128 /* StringLiteral */) { + if (source.flags & 128 /* TypeFlags.StringLiteral */) { var value = source.value; - return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) || - target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) || - target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName || - target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target)); + return !!(target.flags & 8 /* TypeFlags.Number */ && isValidNumberString(value, /*roundTripOnly*/ false) || + target.flags & 64 /* TypeFlags.BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) || + target.flags & (512 /* TypeFlags.BooleanLiteral */ | 98304 /* TypeFlags.Nullable */) && value === target.intrinsicName || + target.flags & 268435456 /* TypeFlags.StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target)); } - if (source.flags & 134217728 /* TemplateLiteral */) { + if (source.flags & 134217728 /* TypeFlags.TemplateLiteral */) { var texts = source.texts; return texts.length === 2 && texts[0] === "" && texts[1] === "" && isTypeAssignableTo(source.types[0], target); } return isTypeAssignableTo(source, target); } function inferTypesFromTemplateLiteralType(source, target) { - return source.flags & 128 /* StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : - source.flags & 134217728 /* TemplateLiteral */ ? + return source.flags & 128 /* TypeFlags.StringLiteral */ ? inferFromLiteralPartsToTemplateLiteral([source.value], ts.emptyArray, target) : + source.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? ts.arraysEqual(source.texts, target.texts) ? ts.map(source.types, getStringLikeTypeForType) : inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) : undefined; @@ -68822,7 +69030,7 @@ var ts; return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); }); } function getStringLikeTypeForType(type) { - return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); + return type.flags & (1 /* TypeFlags.Any */ | 402653316 /* TypeFlags.StringLike */) ? type : getTemplateLiteralType(["", ""], [type]); } // This function infers from the text parts and type parts of a source literal to a target template literal. The number // of text parts is always one more than the number of type parts, and a source string literal is treated as a source @@ -68904,12 +69112,12 @@ var ts; if (contravariant === void 0) { contravariant = false; } var bivariant = false; var propagationType; - var inferencePriority = 2048 /* MaxValue */; + var inferencePriority = 2048 /* InferencePriority.MaxValue */; var allowComplexConstraintInference = true; var visited; var sourceStack; var targetStack; - var expandingFlags = 0 /* None */; + var expandingFlags = 0 /* ExpandingFlags.None */; inferFromTypes(originalSource, originalTarget); function inferFromTypes(source, target) { if (!couldContainTypeVariables(target)) { @@ -68925,13 +69133,16 @@ var ts; propagationType = savePropagationType; return; } - if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - // Source and target are types originating in the same generic type alias declaration. - // Simply infer from source type arguments to target type arguments. - inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) { + if (source.aliasTypeArguments) { + // Source and target are types originating in the same generic type alias declaration. + // Simply infer from source type arguments to target type arguments. + inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + } + // And if there weren't any type arguments, there's no reason to run inference as the types must be the same. return; } - if (source === target && source.flags & 3145728 /* UnionOrIntersection */) { + if (source === target && source.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { // When source and target are the same union or intersection type, just relate each constituent // type to itself. for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -68940,10 +69151,10 @@ var ts; } return; } - if (target.flags & 1048576 /* Union */) { + if (target.flags & 1048576 /* TypeFlags.Union */) { // First, infer between identically matching source and target constituents and remove the // matching types. - var _b = inferFromMatchingTypes(source.flags & 1048576 /* Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; + var _b = inferFromMatchingTypes(source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1]; // Next, infer between closely matching source and target constituents and remove // the matching types. Types closely match when they are instantiations of the same // object type or instantiations of the same type alias. @@ -68958,21 +69169,21 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - inferWithPriority(source, target, 1 /* NakedTypeVariable */); + inferWithPriority(source, target, 1 /* InferencePriority.NakedTypeVariable */); return; } source = getUnionType(sources); } - else if (target.flags & 2097152 /* Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { + else if (target.flags & 2097152 /* TypeFlags.Intersection */ && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) { // We reduce intersection types only when they contain naked type parameters. For example, when // inferring from 'string[] & { extra: any }' to 'string[] & T' we want to remove string[] and // infer { extra: any } for T. But when inferring to 'string[] & Iterable' we want to keep the // string[] on the source side and infer string for T. // Likewise, we consider a homomorphic mapped type constrainted to the target type parameter as similar to a "naked type variable" // in such scenarios. - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { // Infer between identically matching source and target constituents and remove the matching types. - var _d = inferFromMatchingTypes(source.flags & 2097152 /* Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; + var _d = inferFromMatchingTypes(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1]; if (sources.length === 0 || targets.length === 0) { return; } @@ -68980,23 +69191,31 @@ var ts; target = getIntersectionType(targets); } } - else if (target.flags & (8388608 /* IndexedAccess */ | 33554432 /* Substitution */)) { + else if (target.flags & (8388608 /* TypeFlags.IndexedAccess */ | 33554432 /* TypeFlags.Substitution */)) { target = getActualTypeVariable(target); } - if (target.flags & 8650752 /* TypeVariable */) { - // If target is a type parameter, make an inference, unless the source type contains - // the anyFunctionType (the wildcard type that's used to avoid contextually typing functions). - // Because the anyFunctionType is internal, it should not be exposed to the user by adding - // it as an inference candidate. Hopefully, a better candidate will come along that does - // not contain anyFunctionType when we come back to this argument for its second round - // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard - // when constructing types from type parameters that had no inference candidates). - if (source === nonInferrableAnyType || source === silentNeverType || (priority & 128 /* ReturnType */ && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) { + if (target.flags & 8650752 /* TypeFlags.TypeVariable */) { + // Skip inference if the source is "blocked", which is used by the language service to + // prevent inference on nodes currently being edited. + if (isFromInferenceBlockedSource(source)) { return; } var inference = getInferenceInfoForType(target); if (inference) { - if (ts.getObjectFlags(source) & 262144 /* NonInferrableType */) { + // If target is a type parameter, make an inference, unless the source type contains + // a "non-inferrable" type. Types with this flag set are markers used to prevent inference. + // + // For example: + // - anyFunctionType is a wildcard type that's used to avoid contextually typing functions; + // it's internal, so should not be exposed to the user by adding it as a candidate. + // - autoType (and autoArrayType) is a special "any" used in control flow; like anyFunctionType, + // it's internal and should not be observable. + // - silentNeverType is returned by getInferredType when instantiating a generic function for + // inference (and a type variable has no mapping). + // + // This flag is infectious; if we produce Box (where never is silentNeverType), Box is + // also non-inferrable. + if (ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */) { return; } if (!inference.isFixed) { @@ -69021,7 +69240,7 @@ var ts; clearCachedInferences(inferences); } } - if (!(priority & 128 /* ReturnType */) && target.flags & 262144 /* TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(priority & 128 /* InferencePriority.ReturnType */) && target.flags & 262144 /* TypeFlags.TypeParameter */ && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; clearCachedInferences(inferences); } @@ -69034,11 +69253,11 @@ var ts; if (simplified !== target) { inferFromTypes(source, simplified); } - else if (target.flags & 8388608 /* IndexedAccess */) { + else if (target.flags & 8388608 /* TypeFlags.IndexedAccess */) { var indexType = getSimplifiedType(target.indexType, /*writing*/ false); // Generally simplifications of instantiable indexes are avoided to keep relationship checking correct, however if our target is an access, we can consider // that key of that access to be "instantiated", since we're looking to find the infernce goal in any way we can. - if (indexType.flags & 465829888 /* Instantiable */) { + if (indexType.flags & 465829888 /* TypeFlags.Instantiable */) { var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, /*writing*/ false), indexType, /*writing*/ false); if (simplified_1 && simplified_1 !== target) { inferFromTypes(source, simplified_1); @@ -69046,45 +69265,38 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } - else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { - contravariant = !contravariant; - inferFromTypes(source.type, target.type); - contravariant = !contravariant; + else if (source.flags & 4194304 /* TypeFlags.Index */ && target.flags & 4194304 /* TypeFlags.Index */) { + inferFromContravariantTypes(source.type, target.type); } - else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { + else if ((isLiteralType(source) || source.flags & 4 /* TypeFlags.String */) && target.flags & 4194304 /* TypeFlags.Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); - contravariant = !contravariant; - inferWithPriority(empty, target.type, 256 /* LiteralKeyof */); - contravariant = !contravariant; + inferFromContravariantTypesWithPriority(empty, target.type, 256 /* InferencePriority.LiteralKeyof */); } - else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { + else if (source.flags & 8388608 /* TypeFlags.IndexedAccess */ && target.flags & 8388608 /* TypeFlags.IndexedAccess */) { inferFromTypes(source.objectType, target.objectType); inferFromTypes(source.indexType, target.indexType); } - else if (source.flags & 268435456 /* StringMapping */ && target.flags & 268435456 /* StringMapping */) { + else if (source.flags & 268435456 /* TypeFlags.StringMapping */ && target.flags & 268435456 /* TypeFlags.StringMapping */) { if (source.symbol === target.symbol) { inferFromTypes(source.type, target.type); } } - else if (source.flags & 33554432 /* Substitution */) { + else if (source.flags & 33554432 /* TypeFlags.Substitution */) { inferFromTypes(source.baseType, target); - var oldPriority = priority; - priority |= 4 /* SubstituteSource */; - inferFromTypes(source.substitute, target); // Make substitute inference at a lower priority - priority = oldPriority; + inferWithPriority(source.substitute, target, 4 /* InferencePriority.SubstituteSource */); // Make substitute inference at a lower priority } - else if (target.flags & 16777216 /* Conditional */) { + else if (target.flags & 16777216 /* TypeFlags.Conditional */) { invokeOnce(source, target, inferToConditionalType); } - else if (target.flags & 3145728 /* UnionOrIntersection */) { + else if (target.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { inferToMultipleTypes(source, target.types, target.flags); } - else if (source.flags & 1048576 /* Union */) { + else if (source.flags & 1048576 /* TypeFlags.Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) { @@ -69092,17 +69304,17 @@ var ts; inferFromTypes(sourceType, target); } } - else if (target.flags & 134217728 /* TemplateLiteral */) { + else if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) { inferToTemplateLiteralType(source, target); } else { source = getReducedType(source); - if (!(priority & 512 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */))) { + if (!(priority & 512 /* InferencePriority.NoConstraints */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. // If that occurs and it doesn't simplify to an object or intersection, we'll need to restart `inferFromTypes` // with the simplified source. - if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* Object */ | 2097152 /* Intersection */))) { + if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */))) { // TODO: The `allowComplexConstraintInference` flag is a hack! This forbids inference from complex constraints within constraints! // This isn't required algorithmically, but rather is used to lower the memory burden caused by performing inference // that is _too good_ in projects with complicated constraints (eg, fp-ts). In such cases, if we did not limit ourselves @@ -69115,7 +69327,7 @@ var ts; } source = apparentSource; } - if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */)) { + if (source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */)) { invokeOnce(source, target, inferFromObjectTypes); } } @@ -69126,6 +69338,18 @@ var ts; inferFromTypes(source, target); priority = savePriority; } + function inferFromContravariantTypesWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromContravariantTypes(source, target); + priority = savePriority; + } + function inferToMultipleTypesWithPriority(source, targets, targetFlags, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferToMultipleTypes(source, targets, targetFlags); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -69133,19 +69357,19 @@ var ts; inferencePriority = Math.min(inferencePriority, status); return; } - (visited || (visited = new ts.Map())).set(key, -1 /* Circularity */); + (visited || (visited = new ts.Map())).set(key, -1 /* InferencePriority.Circularity */); var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; // We stop inferring and report a circularity if we encounter duplicate recursion identities on both // the source side and the target side. var saveExpandingFlags = expandingFlags; var sourceIdentity = getRecursionIdentity(source); var targetIdentity = getRecursionIdentity(target); if (ts.contains(sourceStack, sourceIdentity)) - expandingFlags |= 1 /* Source */; + expandingFlags |= 1 /* ExpandingFlags.Source */; if (ts.contains(targetStack, targetIdentity)) - expandingFlags |= 2 /* Target */; - if (expandingFlags !== 3 /* Both */) { + expandingFlags |= 2 /* ExpandingFlags.Target */; + if (expandingFlags !== 3 /* ExpandingFlags.Both */) { (sourceStack || (sourceStack = [])).push(sourceIdentity); (targetStack || (targetStack = [])).push(targetIdentity); action(source, target); @@ -69153,7 +69377,7 @@ var ts; sourceStack.pop(); } else { - inferencePriority = -1 /* Circularity */; + inferencePriority = -1 /* InferencePriority.Circularity */; } expandingFlags = saveExpandingFlags; visited.set(key, inferencePriority); @@ -69181,7 +69405,7 @@ var ts; function inferFromTypeArguments(sourceTypes, targetTypes, variances) { var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length; for (var i = 0; i < count; i++) { - if (i < variances.length && (variances[i] & 7 /* VarianceMask */) === 2 /* Contravariant */) { + if (i < variances.length && (variances[i] & 7 /* VarianceFlags.VarianceMask */) === 2 /* VarianceFlags.Contravariant */) { inferFromContravariantTypes(sourceTypes[i], targetTypes[i]); } else { @@ -69190,17 +69414,20 @@ var ts; } } function inferFromContravariantTypes(source, target) { - if (strictFunctionTypes || priority & 1024 /* AlwaysStrict */) { - contravariant = !contravariant; - inferFromTypes(source, target); - contravariant = !contravariant; + contravariant = !contravariant; + inferFromTypes(source, target); + contravariant = !contravariant; + } + function inferFromContravariantTypesIfStrictFunctionTypes(source, target) { + if (strictFunctionTypes || priority & 1024 /* InferencePriority.AlwaysStrict */) { + inferFromContravariantTypes(source, target); } else { inferFromTypes(source, target); } } function getInferenceInfoForType(type) { - if (type.flags & 8650752 /* TypeVariable */) { + if (type.flags & 8650752 /* TypeFlags.TypeVariable */) { for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) { var inference = inferences_2[_i]; if (type === inference.typeParameter) { @@ -69214,7 +69441,7 @@ var ts; var typeVariable; for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { var type = types_14[_i]; - var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + var t = type.flags & 2097152 /* TypeFlags.Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; } @@ -69224,9 +69451,9 @@ var ts; } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; - if (targetFlags & 1048576 /* Union */) { + if (targetFlags & 1048576 /* TypeFlags.Union */) { var nakedTypeVariable = void 0; - var sources = source.flags & 1048576 /* Union */ ? source.types : [source]; + var sources = source.flags & 1048576 /* TypeFlags.Union */ ? source.types : [source]; var matched_1 = new Array(sources.length); var inferenceCircularity = false; // First infer to types that are not naked type variables. For each source type we @@ -69242,11 +69469,11 @@ var ts; else { for (var i = 0; i < sources.length; i++) { var saveInferencePriority = inferencePriority; - inferencePriority = 2048 /* MaxValue */; + inferencePriority = 2048 /* InferencePriority.MaxValue */; inferFromTypes(sources[i], t); if (inferencePriority === priority) matched_1[i] = true; - inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* Circularity */; + inferenceCircularity = inferenceCircularity || inferencePriority === -1 /* InferencePriority.Circularity */; inferencePriority = Math.min(inferencePriority, saveInferencePriority); } } @@ -69257,7 +69484,7 @@ var ts; // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); if (intersectionTypeVariable) { - inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + inferWithPriority(source, intersectionTypeVariable, 1 /* InferencePriority.NakedTypeVariable */); } return; } @@ -69291,17 +69518,17 @@ var ts; // less specific. For example, when inferring from Promise to T | Promise, // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. - if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { + if (targetFlags & 2097152 /* TypeFlags.Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferWithPriority(source, t, 1 /* NakedTypeVariable */); + inferWithPriority(source, t, 1 /* InferencePriority.NakedTypeVariable */); } } } } function inferToMappedType(source, target, constraintType) { - if (constraintType.flags & 1048576 /* Union */) { + if (constraintType.flags & 1048576 /* TypeFlags.Union */) { var result = false; for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) { var type = _a[_i]; @@ -69309,7 +69536,7 @@ var ts; } return result; } - if (constraintType.flags & 4194304 /* Index */) { + if (constraintType.flags & 4194304 /* TypeFlags.Index */) { // We're inferring from some source type S to a homomorphic mapped type { [P in keyof T]: X }, // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference @@ -69321,17 +69548,17 @@ var ts; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* NonInferrableType */ ? - 16 /* PartialHomomorphicMappedType */ : - 8 /* HomomorphicMappedType */); + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 262144 /* ObjectFlags.NonInferrableType */ ? + 16 /* InferencePriority.PartialHomomorphicMappedType */ : + 8 /* InferencePriority.HomomorphicMappedType */); } } return true; } - if (constraintType.flags & 262144 /* TypeParameter */) { + if (constraintType.flags & 262144 /* TypeFlags.TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - inferWithPriority(getIndexType(source), constraintType, 32 /* MappedTypeConstraint */); + inferWithPriority(getIndexType(source), constraintType, 32 /* InferencePriority.MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -69350,18 +69577,15 @@ var ts; return false; } function inferToConditionalType(source, target) { - if (source.flags & 16777216 /* Conditional */) { + if (source.flags & 16777216 /* TypeFlags.Conditional */) { inferFromTypes(source.checkType, target.checkType); inferFromTypes(source.extendsType, target.extendsType); inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target)); inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } else { - var savePriority = priority; - priority |= contravariant ? 64 /* ContravariantConditional */ : 0; var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)]; - inferToMultipleTypes(source, targetTypes, target.flags); - priority = savePriority; + inferToMultipleTypesWithPriority(source, targetTypes, target.flags, contravariant ? 64 /* InferencePriority.ContravariantConditional */ : 0); } } function inferToTemplateLiteralType(source, target) { @@ -69374,47 +69598,47 @@ var ts; // upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might // succeed. That would be a pointless and confusing outcome. if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) { - var _loop_23 = function (i) { + var _loop_24 = function (i) { var source_1 = matches ? matches[i] : neverType; var target_3 = types[i]; // If we are inferring from a string literal type to a type variable whose constraint includes one of the // allowed template literal placeholder types, infer from a literal type corresponding to the constraint. - if (source_1.flags & 128 /* StringLiteral */ && target_3.flags & 8650752 /* TypeVariable */) { + if (source_1.flags & 128 /* TypeFlags.StringLiteral */ && target_3.flags & 8650752 /* TypeFlags.TypeVariable */) { var inferenceContext = getInferenceInfoForType(target_3); var constraint = inferenceContext ? getBaseConstraintOfType(inferenceContext.typeParameter) : undefined; if (constraint && !isTypeAny(constraint)) { - var constraintTypes = constraint.flags & 1048576 /* Union */ ? constraint.types : [constraint]; + var constraintTypes = constraint.flags & 1048576 /* TypeFlags.Union */ ? constraint.types : [constraint]; var allTypeFlags_1 = ts.reduceLeft(constraintTypes, function (flags, t) { return flags | t.flags; }, 0); // If the constraint contains `string`, we don't need to look for a more preferred type - if (!(allTypeFlags_1 & 4 /* String */)) { + if (!(allTypeFlags_1 & 4 /* TypeFlags.String */)) { var str_1 = source_1.value; // If the type contains `number` or a number literal and the string isn't a valid number, exclude numbers - if (allTypeFlags_1 & 296 /* NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) { - allTypeFlags_1 &= ~296 /* NumberLike */; + if (allTypeFlags_1 & 296 /* TypeFlags.NumberLike */ && !isValidNumberString(str_1, /*roundTripOnly*/ true)) { + allTypeFlags_1 &= ~296 /* TypeFlags.NumberLike */; } // If the type contains `bigint` or a bigint literal and the string isn't a valid bigint, exclude bigints - if (allTypeFlags_1 & 2112 /* BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) { - allTypeFlags_1 &= ~2112 /* BigIntLike */; + if (allTypeFlags_1 & 2112 /* TypeFlags.BigIntLike */ && !isValidBigIntString(str_1, /*roundTripOnly*/ true)) { + allTypeFlags_1 &= ~2112 /* TypeFlags.BigIntLike */; } // for each type in the constraint, find the highest priority matching type var matchingType = ts.reduceLeft(constraintTypes, function (left, right) { return !(right.flags & allTypeFlags_1) ? left : - left.flags & 4 /* String */ ? left : right.flags & 4 /* String */ ? source_1 : - left.flags & 134217728 /* TemplateLiteral */ ? left : right.flags & 134217728 /* TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 : - left.flags & 268435456 /* StringMapping */ ? left : right.flags & 268435456 /* StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 : - left.flags & 128 /* StringLiteral */ ? left : right.flags & 128 /* StringLiteral */ && right.value === str_1 ? right : - left.flags & 8 /* Number */ ? left : right.flags & 8 /* Number */ ? getNumberLiteralType(+str_1) : - left.flags & 32 /* Enum */ ? left : right.flags & 32 /* Enum */ ? getNumberLiteralType(+str_1) : - left.flags & 256 /* NumberLiteral */ ? left : right.flags & 256 /* NumberLiteral */ && right.value === +str_1 ? right : - left.flags & 64 /* BigInt */ ? left : right.flags & 64 /* BigInt */ ? parseBigIntLiteralType(str_1) : - left.flags & 2048 /* BigIntLiteral */ ? left : right.flags & 2048 /* BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right : - left.flags & 16 /* Boolean */ ? left : right.flags & 16 /* Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType : - left.flags & 512 /* BooleanLiteral */ ? left : right.flags & 512 /* BooleanLiteral */ && right.intrinsicName === str_1 ? right : - left.flags & 32768 /* Undefined */ ? left : right.flags & 32768 /* Undefined */ && right.intrinsicName === str_1 ? right : - left.flags & 65536 /* Null */ ? left : right.flags & 65536 /* Null */ && right.intrinsicName === str_1 ? right : + left.flags & 4 /* TypeFlags.String */ ? left : right.flags & 4 /* TypeFlags.String */ ? source_1 : + left.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? left : right.flags & 134217728 /* TypeFlags.TemplateLiteral */ && isTypeMatchedByTemplateLiteralType(source_1, right) ? source_1 : + left.flags & 268435456 /* TypeFlags.StringMapping */ ? left : right.flags & 268435456 /* TypeFlags.StringMapping */ && str_1 === applyStringMapping(right.symbol, str_1) ? source_1 : + left.flags & 128 /* TypeFlags.StringLiteral */ ? left : right.flags & 128 /* TypeFlags.StringLiteral */ && right.value === str_1 ? right : + left.flags & 8 /* TypeFlags.Number */ ? left : right.flags & 8 /* TypeFlags.Number */ ? getNumberLiteralType(+str_1) : + left.flags & 32 /* TypeFlags.Enum */ ? left : right.flags & 32 /* TypeFlags.Enum */ ? getNumberLiteralType(+str_1) : + left.flags & 256 /* TypeFlags.NumberLiteral */ ? left : right.flags & 256 /* TypeFlags.NumberLiteral */ && right.value === +str_1 ? right : + left.flags & 64 /* TypeFlags.BigInt */ ? left : right.flags & 64 /* TypeFlags.BigInt */ ? parseBigIntLiteralType(str_1) : + left.flags & 2048 /* TypeFlags.BigIntLiteral */ ? left : right.flags & 2048 /* TypeFlags.BigIntLiteral */ && ts.pseudoBigIntToString(right.value) === str_1 ? right : + left.flags & 16 /* TypeFlags.Boolean */ ? left : right.flags & 16 /* TypeFlags.Boolean */ ? str_1 === "true" ? trueType : str_1 === "false" ? falseType : booleanType : + left.flags & 512 /* TypeFlags.BooleanLiteral */ ? left : right.flags & 512 /* TypeFlags.BooleanLiteral */ && right.intrinsicName === str_1 ? right : + left.flags & 32768 /* TypeFlags.Undefined */ ? left : right.flags & 32768 /* TypeFlags.Undefined */ && right.intrinsicName === str_1 ? right : + left.flags & 65536 /* TypeFlags.Null */ ? left : right.flags & 65536 /* TypeFlags.Null */ && right.intrinsicName === str_1 ? right : left; }, neverType); - if (!(matchingType.flags & 131072 /* Never */)) { + if (!(matchingType.flags & 131072 /* TypeFlags.Never */)) { inferFromTypes(matchingType, target_3); return "continue"; } @@ -69424,12 +69648,12 @@ var ts; inferFromTypes(source_1, target_3); }; for (var i = 0; i < types.length; i++) { - _loop_23(i); + _loop_24(i); } } } function inferFromObjectTypes(source, target) { - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* ObjectFlags.Reference */ && ts.getObjectFlags(target) & 4 /* ObjectFlags.Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { // If source and target are references to the same generic type, infer from type arguments inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); return; @@ -69444,7 +69668,7 @@ var ts; if (sourceNameType && targetNameType) inferFromTypes(sourceNameType, targetNameType); } - if (ts.getObjectFlags(target) & 32 /* Mapped */ && !target.declaration.nameType) { + if (ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */ && !target.declaration.nameType) { var constraintType = getConstraintTypeFromMappedType(target); if (inferToMappedType(source, target, constraintType)) { return; @@ -69467,21 +69691,21 @@ var ts; return; } var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0; - var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* Fixed */) : 0); + var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3 /* ElementFlags.Fixed */) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3 /* ElementFlags.Fixed */) : 0); // Infer between starting fixed elements. for (var i = 0; i < startLength; i++) { inferFromTypes(getTypeArguments(source)[i], elementTypes[i]); } - if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* Rest */) { + if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Single rest element remains in source, infer from that to every element in target var restType = getTypeArguments(source)[startLength]; for (var i = startLength; i < targetArity - endLength; i++) { - inferFromTypes(elementFlags[i] & 8 /* Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); + inferFromTypes(elementFlags[i] & 8 /* ElementFlags.Variadic */ ? createArrayType(restType) : restType, elementTypes[i]); } } else { var middleLength = targetArity - startLength - endLength; - if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* Variadic */ && isTupleType(source)) { + if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 /* ElementFlags.Variadic */ && isTupleType(source)) { // Middle of target is [...T, ...U] and source is tuple type var targetInfo = getInferenceInfoForType(elementTypes[startLength]); if (targetInfo && targetInfo.impliedArity !== undefined) { @@ -69490,14 +69714,14 @@ var ts; inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]); } } - else if (middleLength === 1 && elementFlags[startLength] & 8 /* Variadic */) { + else if (middleLength === 1 && elementFlags[startLength] & 8 /* ElementFlags.Variadic */) { // Middle of target is exactly one variadic element. Infer the slice between the fixed parts in the source. // If target ends in optional element(s), make a lower priority a speculative inference. - var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* Optional */; + var endsInOptional = target.target.elementFlags[targetArity - 1] & 2 /* ElementFlags.Optional */; var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]); - inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* SpeculativeTuple */ : 0); + inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 /* InferencePriority.SpeculativeTuple */ : 0); } - else if (middleLength === 1 && elementFlags[startLength] & 4 /* Rest */) { + else if (middleLength === 1 && elementFlags[startLength] & 4 /* ElementFlags.Rest */) { // Middle of target is exactly one rest element. If middle of source is not empty, infer union of middle element types. var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0]; if (restType) { @@ -69517,8 +69741,8 @@ var ts; } } inferFromProperties(source, target); - inferFromSignatures(source, target, 0 /* Call */); - inferFromSignatures(source, target, 1 /* Construct */); + inferFromSignatures(source, target, 0 /* SignatureKind.Call */); + inferFromSignatures(source, target, 1 /* SignatureKind.Construct */); inferFromIndexTypes(source, target); } } @@ -69538,25 +69762,22 @@ var ts; var sourceLen = sourceSignatures.length; var targetLen = targetSignatures.length; var len = sourceLen < targetLen ? sourceLen : targetLen; - var skipParameters = !!(ts.getObjectFlags(source) & 262144 /* NonInferrableType */); for (var i = 0; i < len; i++) { - inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); + inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i])); } } - function inferFromSignature(source, target, skipParameters) { - if (!skipParameters) { - var saveBivariant = bivariant; - var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 169 /* MethodDeclaration */ || kind === 168 /* MethodSignature */ || kind === 171 /* Constructor */; - applyToParameterTypes(source, target, inferFromContravariantTypes); - bivariant = saveBivariant; - } + function inferFromSignature(source, target) { + var saveBivariant = bivariant; + var kind = target.declaration ? target.declaration.kind : 0 /* SyntaxKind.Unknown */; + // Once we descend into a bivariant signature we remain bivariant for all nested inferences + bivariant = bivariant || kind === 169 /* SyntaxKind.MethodDeclaration */ || kind === 168 /* SyntaxKind.MethodSignature */ || kind === 171 /* SyntaxKind.Constructor */; + applyToParameterTypes(source, target, inferFromContravariantTypesIfStrictFunctionTypes); + bivariant = saveBivariant; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables - var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* ObjectFlags.Mapped */) ? 8 /* InferencePriority.HomomorphicMappedType */ : 0; var indexInfos = getIndexInfosOfType(target); if (isObjectTypeWithInferableIndex(source)) { for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) { @@ -69564,9 +69785,9 @@ var ts; var propTypes = []; for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { var prop = _b[_a]; - if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { + if (isApplicableIndexType(getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */), targetInfo.keyType)) { var propType = getTypeOfSymbol(prop); - propTypes.push(prop.flags & 16777216 /* Optional */ ? removeMissingOrUndefinedType(propType) : propType); + propTypes.push(prop.flags & 16777216 /* SymbolFlags.Optional */ ? removeMissingOrUndefinedType(propType) : propType); } } for (var _c = 0, _d = getIndexInfosOfType(source); _c < _d.length; _c++) { @@ -69591,34 +69812,34 @@ var ts; } function isTypeOrBaseIdenticalTo(s, t) { return exactOptionalPropertyTypes && t === missingType ? s === t : - (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */)); + (isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* TypeFlags.String */ && s.flags & 128 /* TypeFlags.StringLiteral */ || t.flags & 8 /* TypeFlags.Number */ && s.flags & 256 /* TypeFlags.NumberLiteral */)); } function isTypeCloselyMatchedBy(s, t) { - return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || + return !!(s.flags & 524288 /* TypeFlags.Object */ && t.flags & 524288 /* TypeFlags.Object */ && s.symbol && s.symbol === t.symbol || s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol); } function hasPrimitiveConstraint(type) { var constraint = getConstraintOfTypeParameter(type); - return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 /* TypeFlags.Conditional */ ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); } function isObjectLiteralType(type) { - return !!(ts.getObjectFlags(type) & 128 /* ObjectLiteral */); + return !!(ts.getObjectFlags(type) & 128 /* ObjectFlags.ObjectLiteral */); } function isObjectOrArrayLiteralType(type) { - return !!(ts.getObjectFlags(type) & (128 /* ObjectLiteral */ | 16384 /* ArrayLiteral */)); + return !!(ts.getObjectFlags(type) & (128 /* ObjectFlags.ObjectLiteral */ | 16384 /* ObjectFlags.ArrayLiteral */)); } function unionObjectAndArrayLiteralCandidates(candidates) { if (candidates.length > 1) { var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType); if (objectLiterals.length) { - var literalsType = getUnionType(objectLiterals, 2 /* Subtype */); + var literalsType = getUnionType(objectLiterals, 2 /* UnionReduction.Subtype */); return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]); } } return candidates; } function getContravariantInference(inference) { - return inference.priority & 416 /* PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); + return inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates); } function getCovariantInference(inference, signature) { // Extract all object and array literal types and replace them with a single widened and normalized type. @@ -69635,8 +69856,8 @@ var ts; candidates; // If all inferences were made from a position that implies a combined result, infer a union type. // Otherwise, infer a common supertype. - var unwidenedType = inference.priority & 416 /* PriorityImpliesCombination */ ? - getUnionType(baseCandidates, 2 /* Subtype */) : + var unwidenedType = inference.priority & 416 /* InferencePriority.PriorityImpliesCombination */ ? + getUnionType(baseCandidates, 2 /* UnionReduction.Subtype */) : getCommonSupertype(baseCandidates); return getWidenedType(unwidenedType); } @@ -69650,14 +69871,14 @@ var ts; if (inference.contraCandidates) { // If we have both co- and contra-variant inferences, we prefer the contra-variant inference // unless the co-variant inference is a subtype of some contra-variant inference and not 'never'. - inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* Never */) && + inferredType = inferredCovariantType_1 && !(inferredCovariantType_1.flags & 131072 /* TypeFlags.Never */) && ts.some(inference.contraCandidates, function (t) { return isTypeSubtypeOf(inferredCovariantType_1, t); }) ? inferredCovariantType_1 : getContravariantInference(inference); } else if (inferredCovariantType_1) { inferredType = inferredCovariantType_1; } - else if (context.flags & 1 /* NoDefault */) { + else if (context.flags & 1 /* InferenceFlags.NoDefault */) { // We use silentNeverType as the wildcard that signals no inferences. inferredType = silentNeverType; } @@ -69678,7 +69899,7 @@ var ts; else { inferredType = getTypeFromInference(inference); } - inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* AnyDefault */)); + inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2 /* InferenceFlags.AnyDefault */)); var constraint = getConstraintOfTypeParameter(inference.typeParameter); if (constraint) { var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper); @@ -69748,7 +69969,7 @@ var ts; } // falls through default: - if (node.parent.kind === 297 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -69760,7 +69981,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSymbol) { links.resolvedSymbol = !ts.nodeIsMissing(node) && - resolveName(node, node.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), + resolveName(node, node.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), /*excludeGlobals*/ false) || unknownSymbol; } return links.resolvedSymbol; @@ -69769,7 +69990,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* TypeQuery */ ? true : n.kind === 79 /* Identifier */ || n.kind === 161 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 181 /* SyntaxKind.TypeQuery */ ? true : n.kind === 79 /* SyntaxKind.Identifier */ || n.kind === 161 /* SyntaxKind.QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -69777,70 +69998,79 @@ var ts; // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: if (!ts.isThisInTypeQuery(node)) { var symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? "".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType), "|").concat(getSymbolId(symbol)) : undefined; } // falls through - case 108 /* ThisKeyword */: - return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType); - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return "0|".concat(flowContainer ? getNodeId(flowContainer) : "-1", "|").concat(getTypeId(declaredType), "|").concat(getTypeId(initialType)); + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: var left = getFlowCacheKey(node.left, declaredType, initialType, flowContainer); return left && left + "." + node.right.escapedText; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); return key && key + "." + propName; } + break; + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + // Handle pseudo-references originating in getNarrowedTypeOfSymbol. + return "".concat(getNodeId(node), "#").concat(getTypeId(declaredType)); } return undefined; } function isMatchingReference(source, target) { switch (target.kind) { - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return isMatchingReference(source, target.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) || - (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source, target.right)); + (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source, target.right)); } switch (source.kind) { - case 231 /* MetaProperty */: - return target.kind === 231 /* MetaProperty */ + case 231 /* SyntaxKind.MetaProperty */: + return target.kind === 231 /* SyntaxKind.MetaProperty */ && source.keywordToken === target.keywordToken && source.name.escapedText === target.name.escapedText; - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return ts.isThisInTypeQuery(source) ? - target.kind === 108 /* ThisKeyword */ : - target.kind === 79 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 254 /* VariableDeclaration */ || target.kind === 203 /* BindingElement */) && + target.kind === 108 /* SyntaxKind.ThisKeyword */ : + target.kind === 79 /* SyntaxKind.Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 254 /* SyntaxKind.VariableDeclaration */ || target.kind === 203 /* SyntaxKind.BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 108 /* ThisKeyword */: - return target.kind === 108 /* ThisKeyword */; - case 106 /* SuperKeyword */: - return target.kind === 106 /* SuperKeyword */; - case 230 /* NonNullExpression */: - case 212 /* ParenthesizedExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + return target.kind === 108 /* SyntaxKind.ThisKeyword */; + case 106 /* SyntaxKind.SuperKeyword */: + return target.kind === 106 /* SyntaxKind.SuperKeyword */; + case 230 /* SyntaxKind.NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var sourcePropertyName = getAccessedPropertyName(source); var targetPropertyName = ts.isAccessExpression(target) ? getAccessedPropertyName(target) : undefined; return sourcePropertyName !== undefined && targetPropertyName !== undefined && targetPropertyName === sourcePropertyName && isMatchingReference(source.expression, target.expression); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return ts.isAccessExpression(target) && source.right.escapedText === getAccessedPropertyName(target) && isMatchingReference(source.left, target.expression); - case 221 /* BinaryExpression */: - return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* CommaToken */ && isMatchingReference(source.right, target)); + case 221 /* SyntaxKind.BinaryExpression */: + return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && isMatchingReference(source.right, target)); } return false; } @@ -69861,15 +70091,15 @@ var ts; return undefined; } function tryGetNameFromType(type) { - return type.flags & 8192 /* UniqueESSymbol */ ? type.escapedName : - type.flags & 384 /* StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; + return type.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? type.escapedName : + type.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? ts.escapeLeadingUnderscores("" + type.value) : undefined; } function tryGetElementAccessExpressionName(node) { if (ts.isStringOrNumericLiteralLike(node.argumentExpression)) { return ts.escapeLeadingUnderscores(node.argumentExpression.text); } if (ts.isEntityNameExpression(node.argumentExpression)) { - var symbol = resolveEntityName(node.argumentExpression, 111551 /* Value */, /*ignoreErrors*/ true); + var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); if (!symbol || !isConstVariable(symbol)) return undefined; var declaration = symbol.valueDeclaration; @@ -69908,12 +70138,12 @@ var ts; return false; } function isDiscriminantProperty(type, name) { - if (type && type.flags & 1048576 /* Union */) { + if (type && type.flags & 1048576 /* TypeFlags.Union */) { var prop = getUnionOrIntersectionProperty(type, name); - if (prop && ts.getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (prop && ts.getCheckFlags(prop) & 2 /* CheckFlags.SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { prop.isDiscriminantProperty = - (prop.checkFlags & 192 /* Discriminant */) === 192 /* Discriminant */ && + (prop.checkFlags & 192 /* CheckFlags.Discriminant */) === 192 /* CheckFlags.Discriminant */ && !isGenericType(getTypeOfSymbol(prop)); } return !!prop.isDiscriminantProperty; @@ -69942,8 +70172,8 @@ var ts; function mapTypesByKeyProperty(types, name) { var map = new ts.Map(); var count = 0; - var _loop_24 = function (type) { - if (type.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 58982400 /* InstantiableNonPrimitive */)) { + var _loop_25 = function (type) { + if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { var discriminant = getTypeOfPropertyOfType(type, name); if (discriminant) { if (!isLiteralType(discriminant)) { @@ -69968,7 +70198,7 @@ var ts; }; for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { var type = types_15[_i]; - var state_9 = _loop_24(type); + var state_9 = _loop_25(type); if (typeof state_9 === "object") return state_9.value; } @@ -69979,15 +70209,15 @@ var ts; function getKeyPropertyName(unionType) { var types = unionType.types; // We only construct maps for unions with many non-primitive constituents. - if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* PrimitiveUnion */ || - ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */)); }) < 10) { + if (types.length < 10 || ts.getObjectFlags(unionType) & 32768 /* ObjectFlags.PrimitiveUnion */ || + ts.countWhere(types, function (t) { return !!(t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)); }) < 10) { return undefined; } if (unionType.keyPropertyName === undefined) { // The candidate key property name is the name of the first property with a unit type in one of the // constituent types. var keyPropertyName = ts.forEach(types, function (t) { - return t.flags & (524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) ? + return t.flags & (524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) ? ts.forEach(getPropertiesOfType(t), function (p) { return isUnitType(getTypeOfSymbol(p)) ? p.escapedName : undefined; }) : undefined; }); @@ -70011,7 +70241,7 @@ var ts; } function getMatchingUnionConstituentForObjectLiteral(unionType, node) { var keyPropertyName = getKeyPropertyName(unionType); - var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* PropertyAssignment */ && + var propNode = keyPropertyName && ts.find(node.properties, function (p) { return p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && p.symbol.escapedName === keyPropertyName && isPossiblyDiscriminantValue(p.initializer); }); var propType = propNode && getContextFreeTypeOfExpression(propNode.initializer); return propType && getConstituentTypeForKeyType(unionType, propType); @@ -70028,7 +70258,7 @@ var ts; } } } - if (expression.expression.kind === 206 /* PropertyAccessExpression */ && + if (expression.expression.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isOrContainsMatchingReference(reference, expression.expression.expression)) { return true; } @@ -70042,7 +70272,7 @@ var ts; return flow.id; } function typeMaybeAssignableTo(source, target) { - if (!(source.flags & 1048576 /* Union */)) { + if (!(source.flags & 1048576 /* TypeFlags.Union */)) { return isTypeAssignableTo(source, target); } for (var _i = 0, _a = source.types; _i < _a.length; _i++) { @@ -70057,23 +70287,25 @@ var ts; // For example, when a variable of type number | string | boolean is assigned a value of type number | boolean, // we remove type string. function getAssignmentReducedType(declaredType, assignedType) { - if (declaredType !== assignedType) { - if (assignedType.flags & 131072 /* Never */) { - return assignedType; - } - var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); - if (assignedType.flags & 512 /* BooleanLiteral */ && isFreshLiteralType(assignedType)) { - reducedType = mapType(reducedType, getFreshTypeOfLiteralType); // Ensure that if the assignment is a fresh type, that we narrow to fresh types - } - // Our crude heuristic produces an invalid result in some cases: see GH#26130. - // For now, when that happens, we give up and don't narrow at all. (This also - // means we'll never narrow for erroneous assignments where the assigned type - // is not assignable to the declared type.) - if (isTypeAssignableTo(assignedType, reducedType)) { - return reducedType; - } + var _a; + if (declaredType === assignedType) { + return declaredType; } - return declaredType; + if (assignedType.flags & 131072 /* TypeFlags.Never */) { + return assignedType; + } + var key = "A".concat(getTypeId(declaredType), ",").concat(getTypeId(assignedType)); + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getAssignmentReducedTypeWorker(declaredType, assignedType)); + } + function getAssignmentReducedTypeWorker(declaredType, assignedType) { + var filteredType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); }); + // Ensure that we narrow to fresh types if the assignment is a fresh boolean literal type. + var reducedType = assignedType.flags & 512 /* TypeFlags.BooleanLiteral */ && isFreshLiteralType(assignedType) ? mapType(filteredType, getFreshTypeOfLiteralType) : filteredType; + // Our crude heuristic produces an invalid result in some cases: see GH#26130. + // For now, when that happens, we give up and don't narrow at all. (This also + // means we'll never narrow for erroneous assignments where the assigned type + // is not assignable to the declared type.) + return isTypeAssignableTo(assignedType, reducedType) ? reducedType : declaredType; } function isFunctionObjectType(type) { // We do a quick check for a "bind" property before performing the more expensive subtype @@ -70083,95 +70315,95 @@ var ts; resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type) { - if (type.flags & (2097152 /* Intersection */ | 465829888 /* Instantiable */)) { + if (type.flags & (2097152 /* TypeFlags.Intersection */ | 465829888 /* TypeFlags.Instantiable */)) { type = getBaseConstraintOfType(type) || unknownType; } var flags = type.flags; - if (flags & (4 /* String */ | 268435456 /* StringMapping */)) { - return strictNullChecks ? 16317953 /* StringStrictFacts */ : 16776705 /* StringFacts */; + if (flags & (4 /* TypeFlags.String */ | 268435456 /* TypeFlags.StringMapping */)) { + return strictNullChecks ? 16317953 /* TypeFacts.StringStrictFacts */ : 16776705 /* TypeFacts.StringFacts */; } - if (flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */)) { - var isEmpty = flags & 128 /* StringLiteral */ && type.value === ""; + if (flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */)) { + var isEmpty = flags & 128 /* TypeFlags.StringLiteral */ && type.value === ""; return strictNullChecks ? - isEmpty ? 12123649 /* EmptyStringStrictFacts */ : 7929345 /* NonEmptyStringStrictFacts */ : - isEmpty ? 12582401 /* EmptyStringFacts */ : 16776705 /* NonEmptyStringFacts */; + isEmpty ? 12123649 /* TypeFacts.EmptyStringStrictFacts */ : 7929345 /* TypeFacts.NonEmptyStringStrictFacts */ : + isEmpty ? 12582401 /* TypeFacts.EmptyStringFacts */ : 16776705 /* TypeFacts.NonEmptyStringFacts */; } - if (flags & (8 /* Number */ | 32 /* Enum */)) { - return strictNullChecks ? 16317698 /* NumberStrictFacts */ : 16776450 /* NumberFacts */; + if (flags & (8 /* TypeFlags.Number */ | 32 /* TypeFlags.Enum */)) { + return strictNullChecks ? 16317698 /* TypeFacts.NumberStrictFacts */ : 16776450 /* TypeFacts.NumberFacts */; } - if (flags & 256 /* NumberLiteral */) { + if (flags & 256 /* TypeFlags.NumberLiteral */) { var isZero = type.value === 0; return strictNullChecks ? - isZero ? 12123394 /* ZeroNumberStrictFacts */ : 7929090 /* NonZeroNumberStrictFacts */ : - isZero ? 12582146 /* ZeroNumberFacts */ : 16776450 /* NonZeroNumberFacts */; + isZero ? 12123394 /* TypeFacts.ZeroNumberStrictFacts */ : 7929090 /* TypeFacts.NonZeroNumberStrictFacts */ : + isZero ? 12582146 /* TypeFacts.ZeroNumberFacts */ : 16776450 /* TypeFacts.NonZeroNumberFacts */; } - if (flags & 64 /* BigInt */) { - return strictNullChecks ? 16317188 /* BigIntStrictFacts */ : 16775940 /* BigIntFacts */; + if (flags & 64 /* TypeFlags.BigInt */) { + return strictNullChecks ? 16317188 /* TypeFacts.BigIntStrictFacts */ : 16775940 /* TypeFacts.BigIntFacts */; } - if (flags & 2048 /* BigIntLiteral */) { + if (flags & 2048 /* TypeFlags.BigIntLiteral */) { var isZero = isZeroBigInt(type); return strictNullChecks ? - isZero ? 12122884 /* ZeroBigIntStrictFacts */ : 7928580 /* NonZeroBigIntStrictFacts */ : - isZero ? 12581636 /* ZeroBigIntFacts */ : 16775940 /* NonZeroBigIntFacts */; + isZero ? 12122884 /* TypeFacts.ZeroBigIntStrictFacts */ : 7928580 /* TypeFacts.NonZeroBigIntStrictFacts */ : + isZero ? 12581636 /* TypeFacts.ZeroBigIntFacts */ : 16775940 /* TypeFacts.NonZeroBigIntFacts */; } - if (flags & 16 /* Boolean */) { - return strictNullChecks ? 16316168 /* BooleanStrictFacts */ : 16774920 /* BooleanFacts */; + if (flags & 16 /* TypeFlags.Boolean */) { + return strictNullChecks ? 16316168 /* TypeFacts.BooleanStrictFacts */ : 16774920 /* TypeFacts.BooleanFacts */; } - if (flags & 528 /* BooleanLike */) { + if (flags & 528 /* TypeFlags.BooleanLike */) { return strictNullChecks ? - (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ : - (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */; + (type === falseType || type === regularFalseType) ? 12121864 /* TypeFacts.FalseStrictFacts */ : 7927560 /* TypeFacts.TrueStrictFacts */ : + (type === falseType || type === regularFalseType) ? 12580616 /* TypeFacts.FalseFacts */ : 16774920 /* TypeFacts.TrueFacts */; } - if (flags & 524288 /* Object */) { - return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ? - strictNullChecks ? 83427327 /* EmptyObjectStrictFacts */ : 83886079 /* EmptyObjectFacts */ : + if (flags & 524288 /* TypeFlags.Object */) { + return ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */ && isEmptyObjectType(type) ? + strictNullChecks ? 83427327 /* TypeFacts.EmptyObjectStrictFacts */ : 83886079 /* TypeFacts.EmptyObjectFacts */ : isFunctionObjectType(type) ? - strictNullChecks ? 7880640 /* FunctionStrictFacts */ : 16728000 /* FunctionFacts */ : - strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + strictNullChecks ? 7880640 /* TypeFacts.FunctionStrictFacts */ : 16728000 /* TypeFacts.FunctionFacts */ : + strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 16384 /* Void */) { - return 9830144 /* VoidFacts */; + if (flags & 16384 /* TypeFlags.Void */) { + return 9830144 /* TypeFacts.VoidFacts */; } - if (flags & 32768 /* Undefined */) { - return 26607360 /* UndefinedFacts */; + if (flags & 32768 /* TypeFlags.Undefined */) { + return 26607360 /* TypeFacts.UndefinedFacts */; } - if (flags & 65536 /* Null */) { - return 42917664 /* NullFacts */; + if (flags & 65536 /* TypeFlags.Null */) { + return 42917664 /* TypeFacts.NullFacts */; } - if (flags & 12288 /* ESSymbolLike */) { - return strictNullChecks ? 7925520 /* SymbolStrictFacts */ : 16772880 /* SymbolFacts */; + if (flags & 12288 /* TypeFlags.ESSymbolLike */) { + return strictNullChecks ? 7925520 /* TypeFacts.SymbolStrictFacts */ : 16772880 /* TypeFacts.SymbolFacts */; } - if (flags & 67108864 /* NonPrimitive */) { - return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; + if (flags & 67108864 /* TypeFlags.NonPrimitive */) { + return strictNullChecks ? 7888800 /* TypeFacts.ObjectStrictFacts */ : 16736160 /* TypeFacts.ObjectFacts */; } - if (flags & 131072 /* Never */) { - return 0 /* None */; + if (flags & 131072 /* TypeFlags.Never */) { + return 0 /* TypeFacts.None */; } - if (flags & 1048576 /* Union */) { - return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* None */); + if (flags & 1048576 /* TypeFlags.Union */) { + return ts.reduceLeft(type.types, function (facts, t) { return facts | getTypeFacts(t); }, 0 /* TypeFacts.None */); } - if (flags & 2097152 /* Intersection */) { + if (flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionTypeFacts(type); } - return 83886079 /* UnknownFacts */; + return 83886079 /* TypeFacts.UnknownFacts */; } function getIntersectionTypeFacts(type) { // When an intersection contains a primitive type we ignore object type constituents as they are // presumably type tags. For example, in string & { __kind__: "name" } we ignore the object type. - var ignoreObjects = maybeTypeOfKind(type, 131068 /* Primitive */); + var ignoreObjects = maybeTypeOfKind(type, 131068 /* TypeFlags.Primitive */); // When computing the type facts of an intersection type, certain type facts are computed as `and` // and others are computed as `or`. - var oredFacts = 0 /* None */; - var andedFacts = 134217727 /* All */; + var oredFacts = 0 /* TypeFacts.None */; + var andedFacts = 134217727 /* TypeFacts.All */; for (var _i = 0, _a = type.types; _i < _a.length; _i++) { var t = _a[_i]; - if (!(ignoreObjects && t.flags & 524288 /* Object */)) { + if (!(ignoreObjects && t.flags & 524288 /* TypeFlags.Object */)) { var f = getTypeFacts(t); oredFacts |= f; andedFacts &= f; } } - return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 134209471 /* AndFactsMask */; + return oredFacts & 8256 /* TypeFacts.OrFactsMask */ | andedFacts & 134209471 /* TypeFacts.AndFactsMask */; } function getTypeWithFacts(type, include) { return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; }); @@ -70180,16 +70412,16 @@ var ts; // unknown with the union {} | null | undefined (and reduces that accordingly), and it intersects remaining // instantiable types with {}, {} | null, or {} | undefined in order to remove null and/or undefined. function getAdjustedTypeWithFacts(type, facts) { - var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* Unknown */ ? unknownUnionType : type, facts)); + var reduced = recombineUnknownType(getTypeWithFacts(strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */ ? unknownUnionType : type, facts)); if (strictNullChecks) { switch (facts) { - case 524288 /* NEUndefined */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* EQNull */ && !maybeTypeOfKind(reduced, 65536 /* Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; }); - case 1048576 /* NENull */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; }); - case 2097152 /* NEUndefinedOrNull */: - case 4194304 /* Truthy */: - return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; }); + case 524288 /* TypeFacts.NEUndefined */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 65536 /* TypeFacts.EQUndefined */ ? getIntersectionType([t, getTypeFacts(t) & 131072 /* TypeFacts.EQNull */ && !maybeTypeOfKind(reduced, 65536 /* TypeFlags.Null */) ? getUnionType([emptyObjectType, nullType]) : emptyObjectType]) : t; }); + case 1048576 /* TypeFacts.NENull */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 131072 /* TypeFacts.EQNull */ ? getIntersectionType([t, getTypeFacts(t) & 65536 /* TypeFacts.EQUndefined */ && !maybeTypeOfKind(reduced, 32768 /* TypeFlags.Undefined */) ? getUnionType([emptyObjectType, undefinedType]) : emptyObjectType]) : t; }); + case 2097152 /* TypeFacts.NEUndefinedOrNull */: + case 4194304 /* TypeFacts.Truthy */: + return mapType(reduced, function (t) { return getTypeFacts(t) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? getGlobalNonNullableTypeInstantiation(t) : t; }); } } return reduced; @@ -70212,7 +70444,7 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return everyType(type, isTupleLikeType) && getTupleElementType(type, index) || - includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || + includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined)) || errorType; } function includeUndefinedInIndexSignature(type) { @@ -70223,18 +70455,18 @@ var ts; type; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); + return createArrayType(checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 204 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 296 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 221 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 244 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -70251,21 +70483,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return stringType; - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkRightHandSideOfForOf(parent) || errorType; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return undefinedType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -70273,7 +70505,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 201 /* ObjectBindingPattern */ ? + var type = pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -70291,37 +70523,37 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 243 /* ForInStatement */) { + if (node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 244 /* ForOfStatement */) { + if (node.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 254 /* VariableDeclaration */ ? + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function isEmptyArrayAssignment(node) { - return node.kind === 254 /* VariableDeclaration */ && node.initializer && + return node.kind === 254 /* SyntaxKind.VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 203 /* BindingElement */ && node.parent.kind === 221 /* BinaryExpression */ && + node.kind !== 203 /* SyntaxKind.BindingElement */ && node.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: switch (node.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return getReferenceCandidate(node.left); - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return getReferenceCandidate(node.right); } } @@ -70329,13 +70561,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 212 /* ParenthesizedExpression */ || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */ && parent.left === node || - parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.left === node || + parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 27 /* SyntaxKind.CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -70354,25 +70586,25 @@ var ts; // Get the type names from all cases in a switch on `typeof`. The default clause and/or duplicate type names are // represented as undefined. Return undefined if one or more case clause expressions are not string literals. function getSwitchClauseTypeOfWitnesses(switchStatement) { - if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) { + if (ts.some(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 289 /* SyntaxKind.CaseClause */ && !ts.isStringLiteralLike(clause.expression); })) { return undefined; } var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - var text = clause.kind === 289 /* CaseClause */ ? clause.expression.text : undefined; + var text = clause.kind === 289 /* SyntaxKind.CaseClause */ ? clause.expression.text : undefined; witnesses.push(text && !ts.contains(witnesses, text) ? text : undefined); } return witnesses; } function eachTypeContainedIn(source, types) { - return source.flags & 1048576 /* Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); + return source.flags & 1048576 /* TypeFlags.Union */ ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source); } function isTypeSubsetOf(source, target) { - return source === target || target.flags & 1048576 /* Union */ && isTypeSubsetOfUnion(source, target); + return source === target || target.flags & 1048576 /* TypeFlags.Union */ && isTypeSubsetOfUnion(source, target); } function isTypeSubsetOfUnion(source, target) { - if (source.flags & 1048576 /* Union */) { + if (source.flags & 1048576 /* TypeFlags.Union */) { for (var _i = 0, _a = source.types; _i < _a.length; _i++) { var t = _a[_i]; if (!containsType(target.types, t)) { @@ -70381,25 +70613,25 @@ var ts; } return true; } - if (source.flags & 1024 /* EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { + if (source.flags & 1024 /* TypeFlags.EnumLiteral */ && getBaseTypeOfEnumLiteralType(source) === target) { return true; } return containsType(target.types, source); } function forEachType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.forEach(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.forEach(type.types, f) : f(type); } function someType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.some(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.some(type.types, f) : f(type); } function everyType(type, f) { - return type.flags & 1048576 /* Union */ ? ts.every(type.types, f) : f(type); + return type.flags & 1048576 /* TypeFlags.Union */ ? ts.every(type.types, f) : f(type); } function everyContainedType(type, f) { - return type.flags & 3145728 /* UnionOrIntersection */ ? ts.every(type.types, f) : f(type); + return type.flags & 3145728 /* TypeFlags.UnionOrIntersection */ ? ts.every(type.types, f) : f(type); } function filterType(type, f) { - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { var types = type.types; var filtered = ts.filter(types, f); if (filtered === types) { @@ -70407,45 +70639,45 @@ var ts; } var origin = type.origin; var newOrigin = void 0; - if (origin && origin.flags & 1048576 /* Union */) { + if (origin && origin.flags & 1048576 /* TypeFlags.Union */) { // If the origin type is a (denormalized) union type, filter its non-union constituents. If that ends // up removing a smaller number of types than in the normalized constituent set (meaning some of the // filtered types are within nested unions in the origin), then we can't construct a new origin type. // Otherwise, if we have exactly one type left in the origin set, return that as the filtered type. // Otherwise, construct a new filtered origin type. var originTypes = origin.types; - var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* Union */) || f(t); }); + var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576 /* TypeFlags.Union */) || f(t); }); if (originTypes.length - originFiltered.length === types.length - filtered.length) { if (originFiltered.length === 1) { return originFiltered[0]; } - newOrigin = createOriginUnionOrIntersectionType(1048576 /* Union */, originFiltered); + newOrigin = createOriginUnionOrIntersectionType(1048576 /* TypeFlags.Union */, originFiltered); } } return getUnionTypeFromSortedList(filtered, type.objectFlags, /*aliasSymbol*/ undefined, /*aliasTypeArguments*/ undefined, newOrigin); } - return type.flags & 131072 /* Never */ || f(type) ? type : neverType; + return type.flags & 131072 /* TypeFlags.Never */ || f(type) ? type : neverType; } function removeType(type, targetType) { return filterType(type, function (t) { return t !== targetType; }); } function countTypes(type) { - return type.flags & 1048576 /* Union */ ? type.types.length : 1; + return type.flags & 1048576 /* TypeFlags.Union */ ? type.types.length : 1; } function mapType(type, mapper, noReductions) { - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return type; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return mapper(type); } var origin = type.origin; - var types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types; + var types = origin && origin.flags & 1048576 /* TypeFlags.Union */ ? origin.types : type.types; var mappedTypes; var changed = false; for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { var t = types_16[_i]; - var mapped = t.flags & 1048576 /* Union */ ? mapType(t, mapper, noReductions) : mapper(t); + var mapped = t.flags & 1048576 /* TypeFlags.Union */ ? mapType(t, mapper, noReductions) : mapper(t); changed || (changed = t !== mapped); if (mapped) { if (!mappedTypes) { @@ -70456,11 +70688,11 @@ var ts; } } } - return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type; + return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* UnionReduction.None */ : 1 /* UnionReduction.Literal */) : type; } function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) { - return type.flags & 1048576 /* Union */ && aliasSymbol ? - getUnionType(ts.map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : + return type.flags & 1048576 /* TypeFlags.Union */ && aliasSymbol ? + getUnionType(ts.map(type.types, mapper), 1 /* UnionReduction.Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper); } function extractTypesOfKind(type, kind) { @@ -70472,13 +70704,13 @@ var ts; // true intersection because it is more costly and, when applied to union types, generates a large number of // types we don't actually care about. function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) { - if (maybeTypeOfKind(typeWithPrimitives, 4 /* String */ | 134217728 /* TemplateLiteral */ | 8 /* Number */ | 64 /* BigInt */) && - maybeTypeOfKind(typeWithLiterals, 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 256 /* NumberLiteral */ | 2048 /* BigIntLiteral */)) { + if (maybeTypeOfKind(typeWithPrimitives, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */) && + maybeTypeOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 256 /* TypeFlags.NumberLiteral */ | 2048 /* TypeFlags.BigIntLiteral */)) { return mapType(typeWithPrimitives, function (t) { - return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) : - isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* String */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* StringLiteral */) : - t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; + return t.flags & 4 /* TypeFlags.String */ ? extractTypesOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) : + isPatternLiteralType(t) && !maybeTypeOfKind(typeWithLiterals, 4 /* TypeFlags.String */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) ? extractTypesOfKind(typeWithLiterals, 128 /* TypeFlags.StringLiteral */) : + t.flags & 8 /* TypeFlags.Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* TypeFlags.Number */ | 256 /* TypeFlags.NumberLiteral */) : + t.flags & 64 /* TypeFlags.BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* TypeFlags.BigInt */ | 2048 /* TypeFlags.BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -70490,14 +70722,14 @@ var ts; return flowType.flags === 0 ? flowType.type : flowType; } function createFlowType(type, incomplete) { - return incomplete ? { flags: 0, type: type.flags & 131072 /* Never */ ? silentNeverType : type } : type; + return incomplete ? { flags: 0, type: type.flags & 131072 /* TypeFlags.Never */ ? silentNeverType : type } : type; } // An evolving array type tracks the element types that have so far been seen in an // 'x.push(value)' or 'x[n] = value' operation along the control flow graph. Evolving // array types are ultimately converted into manifest array types (using getFinalArrayType) // and never escape the getFlowTypeOfReference function. function createEvolvingArrayType(elementType) { - var result = createObjectType(256 /* EvolvingArray */); + var result = createObjectType(256 /* ObjectFlags.EvolvingArray */); result.elementType = elementType; return result; } @@ -70512,10 +70744,10 @@ var ts; return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { - return elementType.flags & 131072 /* Never */ ? + return elementType.flags & 131072 /* TypeFlags.Never */ ? autoArrayType : - createArrayType(elementType.flags & 1048576 /* Union */ ? - getUnionType(elementType.types, 2 /* Subtype */) : + createArrayType(elementType.flags & 1048576 /* TypeFlags.Union */ ? + getUnionType(elementType.types, 2 /* UnionReduction.Subtype */) : elementType); } // We perform subtype reduction upon obtaining the final array type from an evolving array type. @@ -70523,17 +70755,17 @@ var ts; return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType)); } function finalizeEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? getFinalArrayType(type) : type; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? getFinalArrayType(type) : type; } function getElementTypeOfEvolvingArrayType(type) { - return ts.getObjectFlags(type) & 256 /* EvolvingArray */ ? type.elementType : neverType; + return ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */ ? type.elementType : neverType; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { var t = types_17[_i]; - if (!(t.flags & 131072 /* Never */)) { - if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { + if (!(t.flags & 131072 /* TypeFlags.Never */)) { + if (!(ts.getObjectFlags(t) & 256 /* ObjectFlags.EvolvingArray */)) { return false; } hasEvolvingArrayType = true; @@ -70547,16 +70779,16 @@ var ts; var root = getReferenceRoot(node); var parent = root.parent; var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" || - parent.parent.kind === 208 /* CallExpression */ + parent.parent.kind === 208 /* SyntaxKind.CallExpression */ && ts.isIdentifier(parent.name) && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 207 /* ElementAccessExpression */ && + var isElementAssignment = parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 221 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 63 /* EqualsToken */ && + parent.parent.kind === 221 /* SyntaxKind.BinaryExpression */ && + parent.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && - isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); + isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* TypeFlags.NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(node) { @@ -70565,11 +70797,11 @@ var ts; ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer)); } function getExplicitTypeOfSymbol(symbol, diagnostic) { - if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) { return getTypeOfSymbol(symbol); } - if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - if (ts.getCheckFlags(symbol) & 262144 /* Mapped */) { + if (symbol.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */)) { + if (ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */) { var origin = symbol.syntheticOrigin; if (origin && getExplicitTypeOfSymbol(origin)) { return getTypeOfSymbol(symbol); @@ -70580,11 +70812,11 @@ var ts; if (isDeclarationWithExplicitTypeAnnotation(declaration)) { return getTypeOfSymbol(symbol); } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var statement = declaration.parent.parent; var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); if (expressionType) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); } } @@ -70599,16 +70831,16 @@ var ts; // parameter symbols with declarations that have explicit type annotations. Such references are // resolvable with no possibility of triggering circularities in control flow analysis. function getTypeOfDottedName(node, diagnostic) { - if (!(node.flags & 33554432 /* InWithStatement */)) { + if (!(node.flags & 33554432 /* NodeFlags.InWithStatement */)) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); - return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); - case 108 /* ThisKeyword */: + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 108 /* SyntaxKind.ThisKeyword */: return getExplicitThisType(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 206 /* PropertyAccessExpression */: { + case 206 /* SyntaxKind.PropertyAccessExpression */: { var type = getTypeOfDottedName(node.expression, diagnostic); if (type) { var name = node.name; @@ -70626,7 +70858,7 @@ var ts; } return undefined; } - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return getTypeOfDottedName(node.expression, diagnostic); } } @@ -70640,10 +70872,10 @@ var ts; // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call // target expression of an assertion. var funcType = void 0; - if (node.parent.kind === 238 /* ExpressionStatement */) { + if (node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */) { funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); } - else if (node.expression.kind !== 106 /* SuperKeyword */) { + else if (node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { if (ts.isOptionalChain(node)) { funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); } @@ -70651,7 +70883,7 @@ var ts; funcType = checkNonNullExpression(node.expression); } } - var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* SignatureKind.Call */); var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : undefined; @@ -70661,10 +70893,10 @@ var ts; } function hasTypePredicateOrNeverReturnType(signature) { return !!(getTypePredicateOfSignature(signature) || - signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* TypeFlags.Never */); } function getTypePredicateArgument(predicate, callExpression) { - if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + if (predicate.kind === 1 /* TypePredicateKind.Identifier */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */) { return callExpression.arguments[predicate.parameterIndex]; } var invokedExpression = ts.skipParentheses(callExpression.expression); @@ -70684,8 +70916,8 @@ var ts; } function isFalseExpression(expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 95 /* FalseKeyword */ || node.kind === 221 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || - node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + return node.kind === 95 /* SyntaxKind.FalseKeyword */ || node.kind === 221 /* SyntaxKind.BinaryExpression */ && (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); } function isReachableFlowNodeWorker(flow, noCacheCheck) { while (true) { @@ -70693,7 +70925,7 @@ var ts; return lastFlowNodeReachable; } var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var reachable = flowNodeReachable[id]; @@ -70701,30 +70933,30 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && predicate.kind === 3 /* AssertsIdentifier */ && !predicate.type) { + if (predicate && predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && !predicate.type) { var predicateArgument = flow.node.arguments[predicate.parameterIndex]; if (predicateArgument && isFalseExpression(predicateArgument)) { return false; } } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return false; } } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is reachable if any branch is reachable. return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { var antecedents = flow.antecedents; if (antecedents === undefined || antecedents.length === 0) { return false; @@ -70732,7 +70964,7 @@ var ts; // A loop is reachable if the control flow path that leads to the top is reachable. flow = antecedents[0]; } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { // The control flow path representing an unmatched value in a switch statement with // no default clause is unreachable if the switch statement is exhaustive. if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { @@ -70740,7 +70972,7 @@ var ts; } flow = flow.antecedent; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { // Cache is unreliable once we start adjusting labels lastFlowNode = undefined; var target = flow.target; @@ -70751,7 +70983,7 @@ var ts; return result; } else { - return !(flags & 1 /* Unreachable */); + return !(flags & 1 /* FlowFlags.Unreachable */); } } } @@ -70760,7 +70992,7 @@ var ts; function isPostSuperFlowNode(flow, noCacheCheck) { while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var postSuper = flowNodePostSuper[id]; @@ -70768,24 +71000,24 @@ var ts; } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 128 /* SwitchClause */)) { + if (flags & (16 /* FlowFlags.Assignment */ | 96 /* FlowFlags.Condition */ | 256 /* FlowFlags.ArrayMutation */ | 128 /* FlowFlags.SwitchClause */)) { flow = flow.antecedent; } - else if (flags & 512 /* Call */) { - if (flow.node.expression.kind === 106 /* SuperKeyword */) { + else if (flags & 512 /* FlowFlags.Call */) { + if (flow.node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return true; } flow = flow.antecedent; } - else if (flags & 4 /* BranchLabel */) { + else if (flags & 4 /* FlowFlags.BranchLabel */) { // A branching point is post-super if every branch is post-super. return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, /*noCacheCheck*/ false); }); } - else if (flags & 8 /* LoopLabel */) { + else if (flags & 8 /* FlowFlags.LoopLabel */) { // A loop is post-super if the control flow path that leads to the top is post-super. flow = flow.antecedents[0]; } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; @@ -70795,18 +71027,18 @@ var ts; } else { // Unreachable nodes are considered post-super to silence errors - return !!(flags & 1 /* Unreachable */); + return !!(flags & 1 /* FlowFlags.Unreachable */); } } } function isConstantReference(node) { switch (node.kind) { - case 79 /* Identifier */: { + case 79 /* SyntaxKind.Identifier */: { var symbol = getResolvedSymbol(node); return isConstVariable(symbol) || ts.isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // The resolvedSymbol property is initialized by checkPropertyAccess or checkElementAccess before we get here. return isConstantReference(node.expression) && isReadonlySymbol(getNodeLinks(node).resolvedSymbol || unknownSymbol); } @@ -70832,8 +71064,8 @@ var ts; // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. - var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* NonNullExpression */ && !(resultType.flags & 131072 /* Never */) && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + var resultType = ts.getObjectFlags(evolvedType) & 256 /* ObjectFlags.EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 230 /* SyntaxKind.NonNullExpression */ && !(resultType.flags & 131072 /* TypeFlags.Never */) && getTypeWithFacts(resultType, 2097152 /* TypeFacts.NEUndefinedOrNull */).flags & 131072 /* TypeFlags.Never */) { return declaredType; } // The non-null unknown type should never escape control flow analysis. @@ -70849,7 +71081,7 @@ var ts; if (flowDepth === 2000) { // We have made 2000 recursive invocations. To avoid overflowing the call stack we report an error // and disable further control flow analysis in the containing function or module body. - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes" /* tracing.Phase.CheckTypes */, "getTypeAtFlowNode_DepthLimit", { flowId: flow.id }); flowAnalysisDisabled = true; reportFlowControlError(reference); return errorType; @@ -70858,7 +71090,7 @@ var ts; var sharedFlow; while (true) { var flags = flow.flags; - if (flags & 4096 /* Shared */) { + if (flags & 4096 /* FlowFlags.Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -70871,56 +71103,56 @@ var ts; sharedFlow = flow; } var type = void 0; - if (flags & 16 /* Assignment */) { + if (flags & 16 /* FlowFlags.Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 512 /* Call */) { + else if (flags & 512 /* FlowFlags.Call */) { type = getTypeAtFlowCall(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 96 /* Condition */) { + else if (flags & 96 /* FlowFlags.Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flags & 128 /* SwitchClause */) { + else if (flags & 128 /* FlowFlags.SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flags & 12 /* Label */) { + else if (flags & 12 /* FlowFlags.Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flags & 4 /* BranchLabel */ ? + type = flags & 4 /* FlowFlags.BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* FlowFlags.ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flags & 1024 /* ReduceLabel */) { + else if (flags & 1024 /* FlowFlags.ReduceLabel */) { var target = flow.target; var saveAntecedents = target.antecedents; target.antecedents = flow.antecedents; type = getTypeAtFlowNode(flow.antecedent); target.antecedents = saveAntecedents; } - else if (flags & 2 /* Start */) { + else if (flags & 2 /* FlowFlags.Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 206 /* PropertyAccessExpression */ && - reference.kind !== 207 /* ElementAccessExpression */ && - reference.kind !== 108 /* ThisKeyword */) { + reference.kind !== 206 /* SyntaxKind.PropertyAccessExpression */ && + reference.kind !== 207 /* SyntaxKind.ElementAccessExpression */ && + reference.kind !== 108 /* SyntaxKind.ThisKeyword */) { flow = container.flowNode; continue; } @@ -70944,7 +71176,7 @@ var ts; } function getInitialOrAssignedType(flow) { var node = flow.node; - return getNarrowableTypeForReference(node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */ ? + return getNarrowableTypeForReference(node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */ ? getInitialType(node) : getAssignedType(node), reference); } @@ -70956,7 +71188,7 @@ var ts; if (!isReachableFlowNode(flow)) { return unreachableNeverType; } - if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { + if (ts.getAssignmentTargetKind(node) === 2 /* AssignmentKind.Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); } @@ -70967,7 +71199,7 @@ var ts; var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } - if (declaredType.flags & 1048576 /* Union */) { + if (declaredType.flags & 1048576 /* TypeFlags.Union */) { return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; @@ -70984,29 +71216,29 @@ var ts; // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 213 /* FunctionExpression */ || init.kind === 214 /* ArrowFunction */)) { + if (init && (init.kind === 213 /* SyntaxKind.FunctionExpression */ || init.kind === 214 /* SyntaxKind.ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { - return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 243 /* SyntaxKind.ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + return getNonNullableTypeIfNeeded(finalizeEvolvingArrayType(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)))); } // Assignment doesn't affect reference return undefined; } function narrowTypeByAssertion(type, expr) { var node = ts.skipParentheses(expr, /*excludeJSDocTypeAssertions*/ true); - if (node.kind === 95 /* FalseKeyword */) { + if (node.kind === 95 /* SyntaxKind.FalseKeyword */) { return unreachableNeverType; } - if (node.kind === 221 /* BinaryExpression */) { - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.kind === 221 /* SyntaxKind.BinaryExpression */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); } - if (node.operatorToken.kind === 56 /* BarBarToken */) { + if (node.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); } } @@ -71016,15 +71248,15 @@ var ts; var signature = getEffectsSignature(flow.node); if (signature) { var predicate = getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + if (predicate && (predicate.kind === 2 /* TypePredicateKind.AssertsThis */ || predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = finalizeEvolvingArrayType(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]) : + predicate.kind === 3 /* TypePredicateKind.AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); } - if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + if (getReturnTypeOfSignature(signature).flags & 131072 /* TypeFlags.Never */) { return unreachableNeverType; } } @@ -71033,15 +71265,15 @@ var ts; function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 208 /* CallExpression */ ? + var expr = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { + if (ts.getObjectFlags(type) & 256 /* ObjectFlags.EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 208 /* CallExpression */) { + if (node.kind === 208 /* SyntaxKind.CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -71050,7 +71282,7 @@ var ts; else { // We must get the context free expression type so as to not recur in an uncached fashion on the LHS (which causes exponential blowup in compile time) var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); } } @@ -71064,7 +71296,7 @@ var ts; function getTypeAtFlowCondition(flow) { var flowType = getTypeAtFlowNode(flow.antecedent); var type = getTypeFromFlowType(flowType); - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { return flowType; } // If we have an antecedent type (meaning we're reachable in some way), we first @@ -71074,7 +71306,7 @@ var ts; // have the complete type. We proceed by switching to the silent never type which // doesn't report errors when operators are applied to it. Note that this is the // *only* place a silent never type is ever generated. - var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; + var assumeTrue = (flow.flags & 32 /* FlowFlags.TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { @@ -71089,16 +71321,16 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (expr.kind === 216 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } else { if (strictNullChecks) { if (optionalChainContainsReference(expr, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* TypeFlags.Undefined */ | 131072 /* TypeFlags.Never */)); }); } - else if (expr.kind === 216 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { - type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + else if (expr.kind === 216 /* SyntaxKind.TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* TypeFlags.Never */ || t.flags & 128 /* TypeFlags.StringLiteral */ && t.value === "undefined"); }); } } var access = getDiscriminantPropertyAccess(expr, type); @@ -71115,7 +71347,7 @@ var ts; var bypassFlow; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { + if (!bypassFlow && antecedent.flags & 128 /* FlowFlags.SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { // The antecedent is the bypass branch of a potentially exhaustive switch statement. bypassFlow = antecedent; continue; @@ -71159,7 +71391,7 @@ var ts; } } } - return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */), seenIncomplete); + return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */), seenIncomplete); } function getTypeAtFlowLoopLabel(flow) { // If we have previously computed the control flow type for the reference at @@ -71185,7 +71417,7 @@ var ts; // path that leads to the top. for (var i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) { - return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* Literal */), /*incomplete*/ true); + return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1 /* UnionReduction.Literal */), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -71238,7 +71470,7 @@ var ts; } // The result is incomplete if the first antecedent (the non-looping control flow path) // is incomplete. - var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* Subtype */ : 1 /* Literal */); + var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); if (isIncomplete(firstAntecedentType)) { return createFlowType(result, /*incomplete*/ true); } @@ -71253,7 +71485,7 @@ var ts; return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType))); } var result = recombineUnknownType(getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction)); - if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* Union */ && ts.arraysEqual(result.types, declaredType.types)) { + if (result !== declaredType && result.flags & declaredType.flags & 1048576 /* TypeFlags.Union */ && ts.arraysEqual(result.types, declaredType.types)) { return declaredType; } return result; @@ -71299,8 +71531,8 @@ var ts; return undefined; } function getDiscriminantPropertyAccess(expr, computedType) { - var type = declaredType.flags & 1048576 /* Union */ ? declaredType : computedType; - if (type.flags & 1048576 /* Union */) { + var type = declaredType.flags & 1048576 /* TypeFlags.Union */ ? declaredType : computedType; + if (type.flags & 1048576 /* TypeFlags.Union */) { var access = getCandidateDiscriminantPropertyAccess(expr); if (access) { var name = getAccessedPropertyName(access); @@ -71316,8 +71548,8 @@ var ts; if (propName === undefined) { return type; } - var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* Nullable */); - var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName); + var removeNullable = strictNullChecks && ts.isOptionalChain(access) && maybeTypeOfKind(type, 98304 /* TypeFlags.Nullable */); + var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type, propName); if (!propType) { return type; } @@ -71325,16 +71557,16 @@ var ts; var narrowedPropType = narrowType(propType); return filterType(type, function (t) { var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName); - return !(narrowedPropType.flags & 131072 /* Never */) && isTypeComparableTo(narrowedPropType, discriminantType); + return !(narrowedPropType.flags & 131072 /* TypeFlags.Never */) && isTypeComparableTo(narrowedPropType, discriminantType); }); } function narrowTypeByDiscriminantProperty(type, access, operator, value, assumeTrue) { - if ((operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* Union */) { + if ((operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) && type.flags & 1048576 /* TypeFlags.Union */) { var keyPropertyName = getKeyPropertyName(type); if (keyPropertyName && keyPropertyName === getAccessedPropertyName(access)) { var candidate = getConstituentTypeForKeyType(type, getTypeOfExpression(value)); if (candidate) { - return operator === (assumeTrue ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */) ? candidate : + return operator === (assumeTrue ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) ? candidate : isUnitType(getTypeOfPropertyOfType(candidate, keyPropertyName) || unknownType) ? removeType(type, candidate) : type; } @@ -71343,7 +71575,7 @@ var ts; return narrowTypeByDiscriminant(type, access, function (t) { return narrowTypeByEquality(t, operator, value, assumeTrue); }); } function narrowTypeBySwitchOnDiscriminantProperty(type, access, switchStatement, clauseStart, clauseEnd) { - if (clauseStart < clauseEnd && type.flags & 1048576 /* Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { + if (clauseStart < clauseEnd && type.flags & 1048576 /* TypeFlags.Union */ && getKeyPropertyName(type) === getAccessedPropertyName(access)) { var clauseTypes = getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd); var candidate = getUnionType(ts.map(clauseTypes, function (t) { return getConstituentTypeForKeyType(type, t) || unknownType; })); if (candidate !== unknownType) { @@ -71354,51 +71586,51 @@ var ts; } function narrowTypeByTruthiness(type, expr, assumeTrue) { if (isMatchingReference(reference, expr)) { - return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); + return getAdjustedTypeWithFacts(type, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { - type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + type = getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* TypeFacts.Truthy */ : 8388608 /* TypeFacts.Falsy */); }); } return type; } function isTypePresencePossible(type, propName, assumeTrue) { var prop = getPropertyOfType(type, propName); if (prop) { - return prop.flags & 16777216 /* Optional */ ? true : assumeTrue; + return prop.flags & 16777216 /* SymbolFlags.Optional */ ? true : assumeTrue; } return getApplicableIndexInfoForName(type, propName) ? true : !assumeTrue; } function narrowByInKeyword(type, name, assumeTrue) { - if (type.flags & 1048576 /* Union */ - || type.flags & 524288 /* Object */ && declaredType !== type + if (type.flags & 1048576 /* TypeFlags.Union */ + || type.flags & 524288 /* TypeFlags.Object */ && declaredType !== type || ts.isThisTypeParameter(type) - || type.flags & 2097152 /* Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { + || type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) { return filterType(type, function (t) { return isTypePresencePossible(t, name, assumeTrue); }); } return type; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 63 /* EqualsToken */: - case 75 /* BarBarEqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: var operator = expr.operatorToken.kind; var left = getReferenceCandidate(expr.left); var right = getReferenceCandidate(expr.right); - if (left.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(right)) { + if (left.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(right)) { return narrowTypeByTypeof(type, left, operator, right, assumeTrue); } - if (right.kind === 216 /* TypeOfExpression */ && ts.isStringLiteralLike(left)) { + if (right.kind === 216 /* SyntaxKind.TypeOfExpression */ && ts.isStringLiteralLike(left)) { return narrowTypeByTypeof(type, right, operator, left, assumeTrue); } if (isMatchingReference(reference, left)) { @@ -71430,35 +71662,35 @@ var ts; return narrowTypeByConstructor(type, operator, left, assumeTrue); } break; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: if (ts.isPrivateIdentifier(expr.left)) { return narrowTypeByPrivateIdentifierInInExpression(type, expr, assumeTrue); } var target = getReferenceCandidate(expr.right); var leftType = getTypeOfNode(expr.left); - if (leftType.flags & 128 /* StringLiteral */) { + if (leftType.flags & 128 /* TypeFlags.StringLiteral */) { var name = ts.escapeLeadingUnderscores(leftType.value); if (containsMissingType(type) && ts.isAccessExpression(reference) && isMatchingReference(reference.expression, target) && getAccessedPropertyName(reference) === name) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } if (isMatchingReference(reference, target)) { return narrowByInKeyword(type, name, assumeTrue); } } break; - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: return narrowType(type, expr.right, assumeTrue); // Ordinarily we won't see && and || expressions in control flow analysis because the Binder breaks those // expressions down to individual conditional control flows. However, we may encounter them when analyzing // aliased conditional expressions. - case 55 /* AmpersandAmpersandToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: return assumeTrue ? narrowType(narrowType(type, expr.left, /*assumeTrue*/ true), expr.right, /*assumeTrue*/ true) : getUnionType([narrowType(type, expr.left, /*assumeTrue*/ false), narrowType(type, expr.right, /*assumeTrue*/ false)]); - case 56 /* BarBarToken */: + case 56 /* SyntaxKind.BarBarToken */: return assumeTrue ? getUnionType([narrowType(type, expr.left, /*assumeTrue*/ true), narrowType(type, expr.right, /*assumeTrue*/ true)]) : narrowType(narrowType(type, expr.left, /*assumeTrue*/ false), expr.right, /*assumeTrue*/ false); @@ -71479,7 +71711,7 @@ var ts; var targetType = ts.hasStaticModifier(ts.Debug.checkDefined(symbol.valueDeclaration, "should always have a declaration")) ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true); } function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { // We are in a branch of obj?.foo === value (or any one of the other equality operators). We narrow obj as follows: @@ -71491,45 +71723,45 @@ var ts; // When operator is !== and type of value is undefined, null and undefined is removed from type of obj in true branch. // When operator is == and type of value is null or undefined, null and undefined is removed from type of obj in false branch. // When operator is != and type of value is null or undefined, null and undefined is removed from type of obj in true branch. - var equalsOperator = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; - var nullableFlags = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */ ? 98304 /* Nullable */ : 32768 /* Undefined */; + var equalsOperator = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; + var nullableFlags = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */ ? 98304 /* TypeFlags.Nullable */ : 32768 /* TypeFlags.Undefined */; var valueType = getTypeOfExpression(value); // Note that we include any and unknown in the exclusion test because their domain includes null and undefined. var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) || - equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* AnyOrUnknown */ | nullableFlags)); }); - return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 /* TypeFlags.AnyOrUnknown */ | nullableFlags)); }); + return removeNullable ? getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeByEquality(type, operator, value, assumeTrue) { - if (type.flags & 1 /* Any */) { + if (type.flags & 1 /* TypeFlags.Any */) { return type; } - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { - if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && assumeTrue && (operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { + if (valueType.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { return valueType; } - if (valueType.flags & 524288 /* Object */) { + if (valueType.flags & 524288 /* TypeFlags.Object */) { return nonPrimitiveType; } return type; } - if (valueType.flags & 98304 /* Nullable */) { + if (valueType.flags & 98304 /* TypeFlags.Nullable */) { if (!strictNullChecks) { return type; } - var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 35 /* SyntaxKind.ExclamationEqualsToken */; var facts = doubleEquals ? - assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : - valueType.flags & 65536 /* Null */ ? - assumeTrue ? 131072 /* EQNull */ : 1048576 /* NENull */ : - assumeTrue ? 65536 /* EQUndefined */ : 524288 /* NEUndefined */; + assumeTrue ? 262144 /* TypeFacts.EQUndefinedOrNull */ : 2097152 /* TypeFacts.NEUndefinedOrNull */ : + valueType.flags & 65536 /* TypeFlags.Null */ ? + assumeTrue ? 131072 /* TypeFacts.EQNull */ : 1048576 /* TypeFacts.NENull */ : + assumeTrue ? 65536 /* TypeFacts.EQUndefined */ : 524288 /* TypeFacts.NEUndefined */; return getAdjustedTypeWithFacts(type, facts); } if (assumeTrue) { - var filterFn = operator === 34 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* SyntaxKind.EqualsEqualsToken */ ? function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); } : function (t) { return areTypesComparable(t, valueType); }; return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType); @@ -71541,23 +71773,23 @@ var ts; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands - if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* SyntaxKind.ExclamationEqualsToken */ || operator === 37 /* SyntaxKind.ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { - return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } return assumeTrue ? narrowTypeByTypeName(type, literal.text) : - getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */); + getTypeWithFacts(type, typeofNEFacts.get(literal.text) || 32768 /* TypeFacts.TypeofNEHostObject */); } function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); - return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */) : type; } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify @@ -71570,16 +71802,16 @@ var ts; } var clauseTypes = switchTypes.slice(clauseStart, clauseEnd); var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType); - if ((type.flags & 2 /* Unknown */) && !hasDefaultClause) { + if ((type.flags & 2 /* TypeFlags.Unknown */) && !hasDefaultClause) { var groundClauseTypes = void 0; for (var i = 0; i < clauseTypes.length; i += 1) { var t = clauseTypes[i]; - if (t.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { + if (t.flags & (131068 /* TypeFlags.Primitive */ | 67108864 /* TypeFlags.NonPrimitive */)) { if (groundClauseTypes !== undefined) { groundClauseTypes.push(t); } } - else if (t.flags & 524288 /* Object */) { + else if (t.flags & 524288 /* TypeFlags.Object */) { if (groundClauseTypes === undefined) { groundClauseTypes = clauseTypes.slice(0, i); } @@ -71592,26 +71824,26 @@ var ts; return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes); } var discriminantType = getUnionType(clauseTypes); - var caseType = discriminantType.flags & 131072 /* Never */ ? neverType : + var caseType = discriminantType.flags & 131072 /* TypeFlags.Never */ ? neverType : replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType); if (!hasDefaultClause) { return caseType; } var defaultType = filterType(type, function (t) { return !(isUnitLikeType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(extractUnitType(t)))); }); - return caseType.flags & 131072 /* Never */ ? defaultType : getUnionType([caseType, defaultType]); + return caseType.flags & 131072 /* TypeFlags.Never */ ? defaultType : getUnionType([caseType, defaultType]); } function narrowTypeByTypeName(type, typeName) { switch (typeName) { - case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeofEQString */); - case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeofEQNumber */); - case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeofEQBigInt */); - case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeofEQBoolean */); - case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeofEQSymbol */); - case "object": return type.flags & 1 /* Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* EQNull */)]); - case "function": return type.flags & 1 /* Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeofEQFunction */); - case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* EQUndefined */); + case "string": return narrowTypeByTypeFacts(type, stringType, 1 /* TypeFacts.TypeofEQString */); + case "number": return narrowTypeByTypeFacts(type, numberType, 2 /* TypeFacts.TypeofEQNumber */); + case "bigint": return narrowTypeByTypeFacts(type, bigintType, 4 /* TypeFacts.TypeofEQBigInt */); + case "boolean": return narrowTypeByTypeFacts(type, booleanType, 8 /* TypeFacts.TypeofEQBoolean */); + case "symbol": return narrowTypeByTypeFacts(type, esSymbolType, 16 /* TypeFacts.TypeofEQSymbol */); + case "object": return type.flags & 1 /* TypeFlags.Any */ ? type : getUnionType([narrowTypeByTypeFacts(type, nonPrimitiveType, 32 /* TypeFacts.TypeofEQObject */), narrowTypeByTypeFacts(type, nullType, 131072 /* TypeFacts.EQNull */)]); + case "function": return type.flags & 1 /* TypeFlags.Any */ ? type : narrowTypeByTypeFacts(type, globalFunctionType, 64 /* TypeFacts.TypeofEQFunction */); + case "undefined": return narrowTypeByTypeFacts(type, undefinedType, 65536 /* TypeFacts.EQUndefined */); } - return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */); + return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeFacts.TypeofEQHostObject */); } function narrowTypeByTypeFacts(type, impliedType, facts) { return mapType(type, function (t) { @@ -71636,7 +71868,7 @@ var ts; return type; } // Equal start and end denotes implicit fallthrough; undefined marks explicit default clause. - var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* DefaultClause */; }); + var defaultIndex = ts.findIndex(switchStatement.caseBlock.clauses, function (clause) { return clause.kind === 290 /* SyntaxKind.DefaultClause */; }); var hasDefaultClause = clauseStart === clauseEnd || (defaultIndex >= clauseStart && defaultIndex < clauseEnd); if (hasDefaultClause) { // In the default clause we filter constituents down to those that are not-equal to all handled cases. @@ -71654,7 +71886,7 @@ var ts; } function narrowTypeByConstructor(type, operator, identifier, assumeTrue) { // Do not narrow when checking inequality. - if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) { + if (assumeTrue ? (operator !== 34 /* SyntaxKind.EqualsEqualsToken */ && operator !== 36 /* SyntaxKind.EqualsEqualsEqualsToken */) : (operator !== 35 /* SyntaxKind.ExclamationEqualsToken */ && operator !== 37 /* SyntaxKind.ExclamationEqualsEqualsToken */)) { return type; } // Get the type of the constructor identifier expression, if it is not a function then do not narrow. @@ -71684,8 +71916,8 @@ var ts; // This is because you may have a class `A` that defines some set of properties, and another class `B` // that defines the same set of properties as class `A`, in that case they are structurally the same // type, but when you do something like `instanceOfA.constructor === B` it will return false. - if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ || - target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) { + if (source.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(source) & 1 /* ObjectFlags.Class */ || + target.flags & 524288 /* TypeFlags.Object */ && ts.getObjectFlags(target) & 1 /* ObjectFlags.Class */) { return source.symbol === target.symbol; } // For all other types just check that the `source` type is a subtype of the `target` type. @@ -71696,7 +71928,7 @@ var ts; var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { - return getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } return type; } @@ -71719,46 +71951,65 @@ var ts; return type; } if (!targetType) { - var constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(rightType, 1 /* SignatureKind.Construct */); targetType = constructSignatures.length ? getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) : emptyObjectType; } // We can't narrow a union based off instanceof without negated types see #31576 for more info - if (!assumeTrue && rightType.flags & 1048576 /* Union */) { + if (!assumeTrue && rightType.flags & 1048576 /* TypeFlags.Union */) { var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); }); if (!nonConstructorTypeInUnion) return type; } - return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom); + return getNarrowedType(type, targetType, assumeTrue, /*checkDerived*/ true); + } + function getNarrowedType(type, candidate, assumeTrue, checkDerived) { + var _a; + var key = type.flags & 1048576 /* TypeFlags.Union */ ? "N".concat(getTypeId(type), ",").concat(getTypeId(candidate), ",").concat((assumeTrue ? 1 : 0) | (checkDerived ? 2 : 0)) : undefined; + return (_a = getCachedType(key)) !== null && _a !== void 0 ? _a : setCachedType(key, getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived)); } - function getNarrowedType(type, candidate, assumeTrue, isRelated) { + function getNarrowedTypeWorker(type, candidate, assumeTrue, checkDerived) { + var isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf; if (!assumeTrue) { return filterType(type, function (t) { return !isRelated(t, candidate); }); } - // If the current type is a union type, remove all constituents that couldn't be instances of - // the candidate type. If one or more constituents remain, return a union of those. - if (type.flags & 1048576 /* Union */) { - var assignableType = filterType(type, function (t) { return isRelated(t, candidate); }); - if (!(assignableType.flags & 131072 /* Never */)) { - return assignableType; - } + if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { + return candidate; } - // If the candidate type is a subtype of the target type, narrow to the candidate type. - // Otherwise, if the target type is assignable to the candidate type, keep the target type. - // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate - // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the - // two types. - return isTypeSubtypeOf(candidate, type) ? candidate : - isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, type) ? candidate : - getIntersectionType([type, candidate]); + // We first attempt to filter the current type, narrowing constituents as appropriate and removing + // constituents that are unrelated to the candidate. + var keyPropertyName = type.flags & 1048576 /* TypeFlags.Union */ ? getKeyPropertyName(type) : undefined; + var narrowedType = mapType(candidate, function (c) { + // If a discriminant property is available, use that to reduce the type. + var discriminant = keyPropertyName && getTypeOfPropertyOfType(c, keyPropertyName); + var matching = discriminant && getConstituentTypeForKeyType(type, discriminant); + // For each constituent t in the current type, if t and and c are directly related, pick the most + // specific of the two. When t and c are related in both directions, we prefer c for type predicates + // because that is the asserted type, but t for `instanceof` because generics aren't reflected in + // prototype object types. + var directlyRelated = mapType(matching || type, checkDerived ? + function (t) { return isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType; } : + function (t) { return isTypeSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : neverType; }); + // If no constituents are directly related, create intersections for any generic constituents that + // are related by constraint. + return directlyRelated.flags & 131072 /* TypeFlags.Never */ ? + mapType(type, function (t) { return maybeTypeOfKind(t, 465829888 /* TypeFlags.Instantiable */) && isRelated(c, getBaseConstraintOfType(t) || unknownType) ? getIntersectionType([t, c]) : neverType; }) : + directlyRelated; + }); + // If filtering produced a non-empty type, return that. Otherwise, pick the most specific of the two + // based on assignability, or as a last resort produce an intersection. + return !(narrowedType.flags & 131072 /* TypeFlags.Never */) ? narrowedType : + isTypeSubtypeOf(candidate, type) ? candidate : + isTypeAssignableTo(type, candidate) ? type : + isTypeAssignableTo(candidate, type) ? candidate : + getIntersectionType([type, candidate]); } function narrowTypeByCallExpression(type, callExpression, assumeTrue) { if (hasMatchingArgument(callExpression, reference)) { var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; var predicate = signature && getTypePredicateOfSignature(signature); - if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + if (predicate && (predicate.kind === 0 /* TypePredicateKind.This */ || predicate.kind === 1 /* TypePredicateKind.Identifier */)) { return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); } } @@ -71768,7 +72019,7 @@ var ts; ts.isIdentifier(callAccess.name) && callAccess.name.escapedText === "hasOwnProperty" && callExpression.arguments.length === 1) { var argument = callExpression.arguments[0]; if (ts.isStringLiteralLike(argument) && getAccessedPropertyName(reference) === ts.escapeLeadingUnderscores(argument.text)) { - return getTypeWithFacts(type, assumeTrue ? 524288 /* NEUndefined */ : 65536 /* EQUndefined */); + return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */); } } } @@ -71780,15 +72031,15 @@ var ts; var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + return getNarrowedType(type, predicate.type, assumeTrue, /*checkDerived*/ false); } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && - !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { - type = getAdjustedTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + !(getTypeFacts(predicate.type) & 65536 /* TypeFacts.EQUndefined */)) { + type = getAdjustedTypeWithFacts(type, 2097152 /* TypeFacts.NEUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(predicateArgument, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, /*checkDerived*/ false); }); } } } @@ -71799,11 +72050,11 @@ var ts; function narrowType(type, expr, assumeTrue) { // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` if (ts.isExpressionOfOptionalChainRoot(expr) || - ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */ && expr.parent.left === expr) { return narrowTypeByOptionality(type, expr, assumeTrue); } switch (expr.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // When narrowing a reference to a const variable, non-assigned parameter, or readonly property, we inline // up to five levels of aliased conditional expressions that are themselves declared as const variables. if (!isMatchingReference(reference, expr) && inlineLevel < 5) { @@ -71819,20 +72070,20 @@ var ts; } } // falls through - case 108 /* ThisKeyword */: - case 106 /* SuperKeyword */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 108 /* SyntaxKind.ThisKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return narrowTypeByCallExpression(type, expr, assumeTrue); - case 212 /* ParenthesizedExpression */: - case 230 /* NonNullExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return narrowType(type, expr.expression, assumeTrue); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 219 /* PrefixUnaryExpression */: - if (expr.operator === 53 /* ExclamationToken */) { + case 219 /* SyntaxKind.PrefixUnaryExpression */: + if (expr.operator === 53 /* SyntaxKind.ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -71841,11 +72092,11 @@ var ts; } function narrowTypeByOptionality(type, expr, assumePresent) { if (isMatchingReference(reference, expr)) { - return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + return getAdjustedTypeWithFacts(type, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); } var access = getDiscriminantPropertyAccess(expr, type); if (access) { - return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + return narrowTypeByDiscriminant(type, access, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* TypeFacts.NEUndefinedOrNull */ : 262144 /* TypeFacts.EQUndefinedOrNull */); }); } return type; } @@ -71856,7 +72107,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 79 /* Identifier */ || location.kind === 80 /* PrivateIdentifier */) { + if (location.kind === 79 /* SyntaxKind.Identifier */ || location.kind === 80 /* SyntaxKind.PrivateIdentifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -71880,9 +72131,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 262 /* ModuleBlock */ || - node.kind === 305 /* SourceFile */ || - node.kind === 167 /* PropertyDeclaration */; + node.kind === 262 /* SyntaxKind.ModuleBlock */ || + node.kind === 305 /* SyntaxKind.SourceFile */ || + node.kind === 167 /* SyntaxKind.PropertyDeclaration */; }); } // Check if a parameter or catch variable is assigned anywhere @@ -71892,8 +72143,8 @@ var ts; } var parent = ts.getRootDeclaration(symbol.valueDeclaration).parent; var links = getNodeLinks(parent); - if (!(links.flags & 8388608 /* AssignmentsMarked */)) { - links.flags |= 8388608 /* AssignmentsMarked */; + if (!(links.flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */)) { + links.flags |= 8388608 /* NodeCheckFlags.AssignmentsMarked */; if (!hasParentWithAssignmentsMarked(parent)) { markNodeAssignments(parent); } @@ -71902,11 +72153,11 @@ var ts; } function hasParentWithAssignmentsMarked(node) { return !!ts.findAncestor(node.parent, function (node) { - return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); + return (ts.isFunctionLike(node) || ts.isCatchClause(node)) && !!(getNodeLinks(node).flags & 8388608 /* NodeCheckFlags.AssignmentsMarked */); }); } function markNodeAssignments(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); if (ts.isParameterOrCatchClauseVariable(symbol)) { @@ -71919,18 +72170,18 @@ var ts; } } function isConstVariable(symbol) { - return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0; + return symbol.flags & 3 /* SymbolFlags.Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */) !== 0; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { - if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { + if (pushTypeResolution(declaration.symbol, 2 /* TypeSystemPropertyName.DeclaredType */)) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 164 /* Parameter */ && + declaration.kind === 164 /* SyntaxKind.Parameter */ && declaration.initializer && - getTypeFacts(declaredType) & 16777216 /* IsUndefined */ && - !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* IsUndefined */); + getTypeFacts(declaredType) & 16777216 /* TypeFacts.IsUndefined */ && + !(getTypeFacts(checkExpression(declaration.initializer)) & 16777216 /* TypeFacts.IsUndefined */); popTypeResolution(); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* TypeFacts.NEUndefined */) : declaredType; } else { reportCircularityError(declaration.symbol); @@ -71942,19 +72193,19 @@ var ts; // In an element access obj[x], we consider obj to be in a constraint position, except when obj is of // a generic type without a nullable constraint and x is a generic type. This is because when both obj // and x are of generic types T and K, we want the resulting type to be T[K]. - return parent.kind === 206 /* PropertyAccessExpression */ || - parent.kind === 161 /* QualifiedName */ || - parent.kind === 208 /* CallExpression */ && parent.expression === node || - parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node && + return parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || + parent.kind === 161 /* SyntaxKind.QualifiedName */ || + parent.kind === 208 /* SyntaxKind.CallExpression */ && parent.expression === node || + parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && parent.expression === node && !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression))); } function isGenericTypeWithUnionConstraint(type) { - return type.flags & 2097152 /* Intersection */ ? + return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(type.types, isGenericTypeWithUnionConstraint) : - !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */)); + !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* TypeFlags.Nullable */ | 1048576 /* TypeFlags.Union */)); } function isGenericTypeWithoutNullableConstraint(type) { - return !!(type.flags & 465829888 /* Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* Nullable */)); + return !!(type.flags & 465829888 /* TypeFlags.Instantiable */ && !maybeTypeOfKind(getBaseConstraintOrType(type), 98304 /* TypeFlags.Nullable */)); } function hasContextualTypeWithNoGenericTypes(node, checkMode) { // Computing the contextual type for a child of a JSX element involves resolving the type of the @@ -71963,9 +72214,9 @@ var ts; // as we want the type of a rest element to be generic when possible. var contextualType = (ts.isIdentifier(node) || ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) && !((ts.isJsxOpeningElement(node.parent) || ts.isJsxSelfClosingElement(node.parent)) && node.parent.tagName === node) && - (checkMode && checkMode & 64 /* RestBindingElement */ ? - getContextualType(node, 8 /* SkipBindingPatterns */) - : getContextualType(node)); + (checkMode && checkMode & 64 /* CheckMode.RestBindingElement */ ? + getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) + : getContextualType(node, /*contextFlags*/ undefined)); return contextualType && !isGenericType(contextualType); } function getNarrowableTypeForReference(type, reference, checkMode) { @@ -71976,7 +72227,7 @@ var ts; // control flow analysis an opportunity to narrow it further. For example, for a reference of a type // parameter type 'T extends string | undefined' with a contextual type 'string', we substitute // 'string | undefined' to give control flow analysis the opportunity to narrow to type 'string'. - var substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && + var substituteConstraints = !(checkMode && checkMode & 2 /* CheckMode.Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode)); return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type; @@ -71997,9 +72248,9 @@ var ts; }); } function markAliasReferenced(symbol, location) { - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) { var target = resolveAlias(symbol); - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled // (because the const enum value will not be inlined), or if (2) the alias is an export // of a const enum declaration that will be preserved. @@ -72042,16 +72293,16 @@ var ts; // destructuring from the narrowed parent type. if (ts.isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { var parent = declaration.parent.parent; - if (parent.kind === 254 /* VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || parent.kind === 164 /* Parameter */) { + if (parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || parent.kind === 164 /* SyntaxKind.Parameter */) { var links = getNodeLinks(parent); - if (!(links.flags & 268435456 /* InCheckIdentifier */)) { - links.flags |= 268435456 /* InCheckIdentifier */; - var parentType = getTypeForBindingElementParent(parent, 0 /* Normal */); - links.flags &= ~268435456 /* InCheckIdentifier */; - if (parentType && parentType.flags & 1048576 /* Union */ && !(parent.kind === 164 /* Parameter */ && isSymbolAssigned(symbol))) { + if (!(links.flags & 268435456 /* NodeCheckFlags.InCheckIdentifier */)) { + links.flags |= 268435456 /* NodeCheckFlags.InCheckIdentifier */; + var parentType = getTypeForBindingElementParent(parent, 0 /* CheckMode.Normal */); + links.flags &= ~268435456 /* NodeCheckFlags.InCheckIdentifier */; + if (parentType && parentType.flags & 1048576 /* TypeFlags.Union */ && !(parent.kind === 164 /* SyntaxKind.Parameter */ && isSymbolAssigned(symbol))) { var pattern = declaration.parent; var narrowedType = getFlowTypeOfReference(pattern, parentType, parentType, /*flowContainer*/ undefined, location.flowNode); - if (narrowedType.flags & 131072 /* Never */) { + if (narrowedType.flags & 131072 /* TypeFlags.Never */) { return neverType; } return getBindingElementTypeFromParentType(declaration, narrowedType); @@ -72085,7 +72336,7 @@ var ts; var contextualSignature = getContextualSignature(func); if (contextualSignature && contextualSignature.parameters.length === 1 && signatureHasRestParameter(contextualSignature)) { var restType = getReducedApparentType(getTypeOfSymbol(contextualSignature.parameters[0])); - if (restType.flags & 1048576 /* Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { + if (restType.flags & 1048576 /* TypeFlags.Union */ && everyType(restType, isTupleType) && !isSymbolAssigned(symbol)) { var narrowedType = getFlowTypeOfReference(func, restType, restType, /*flowContainer*/ undefined, location.flowNode); var index = func.parameters.indexOf(declaration) - (ts.getThisParameter(func) ? 1 : 0); return getIndexedAccessType(narrowedType, getNumberLiteralType(index)); @@ -72116,20 +72367,18 @@ var ts; return errorType; } var container = ts.getContainingFunction(node); - if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 214 /* ArrowFunction */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } - else if (ts.hasSyntacticModifier(container, 256 /* Async */)) { + else if (ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; + getNodeLinks(container).flags |= 8192 /* NodeCheckFlags.CaptureArguments */; return getTypeOfSymbol(symbol); } - // We should only mark aliases as referenced if there isn't a local value declaration - // for the symbol. Also, don't mark any property access expression LHS - checkPropertyAccessExpression will handle that - if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) { + if (shouldMarkIdentifierAliasReferenced(node)) { markAliasReferenced(symbol, node); } var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); @@ -72138,32 +72387,32 @@ var ts; addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText); } var declaration = localOrExportSymbol.valueDeclaration; - if (declaration && localOrExportSymbol.flags & 32 /* Class */) { + if (declaration && localOrExportSymbol.flags & 32 /* SymbolFlags.Class */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 257 /* ClassDeclaration */ + if (declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { if (container === declaration && container.name !== node) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; break; } container = ts.getContainingClass(container); } } - else if (declaration.kind === 226 /* ClassExpression */) { + else if (declaration.kind === 226 /* SyntaxKind.ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 305 /* SourceFile */) { + while (container.kind !== 305 /* SyntaxKind.SourceFile */) { if (container.parent === declaration) { if (ts.isPropertyDeclaration(container) && ts.isStatic(container) || ts.isClassStaticBlockDeclaration(container)) { - getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; - getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; + getNodeLinks(declaration).flags |= 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + getNodeLinks(node).flags |= 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */; } break; } @@ -72175,19 +72424,19 @@ var ts; var type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); var assignmentKind = ts.getAssignmentTargetKind(node); if (assignmentKind) { - if (!(localOrExportSymbol.flags & 3 /* Variable */) && - !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) { - var assignmentError = localOrExportSymbol.flags & 384 /* Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum - : localOrExportSymbol.flags & 32 /* Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class - : localOrExportSymbol.flags & 1536 /* Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace - : localOrExportSymbol.flags & 16 /* Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function - : localOrExportSymbol.flags & 2097152 /* Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import + if (!(localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) && + !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512 /* SymbolFlags.ValueModule */)) { + var assignmentError = localOrExportSymbol.flags & 384 /* SymbolFlags.Enum */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_enum + : localOrExportSymbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_class + : localOrExportSymbol.flags & 1536 /* SymbolFlags.Module */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_namespace + : localOrExportSymbol.flags & 16 /* SymbolFlags.Function */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_function + : localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? ts.Diagnostics.Cannot_assign_to_0_because_it_is_an_import : ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable; error(node, assignmentError, symbolToString(symbol)); return errorType; } if (isReadonlySymbol(localOrExportSymbol)) { - if (localOrExportSymbol.flags & 3 /* Variable */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol)); } else { @@ -72196,11 +72445,11 @@ var ts; return errorType; } } - var isAlias = localOrExportSymbol.flags & 2097152 /* Alias */; + var isAlias = localOrExportSymbol.flags & 2097152 /* SymbolFlags.Alias */; // We only narrow variables and parameters occurring in a non-assignment position. For all other // entities we simply return the declared type. - if (localOrExportSymbol.flags & 3 /* Variable */) { - if (assignmentKind === 1 /* Definite */) { + if (localOrExportSymbol.flags & 3 /* SymbolFlags.Variable */) { + if (assignmentKind === 1 /* AssignmentKind.Definite */) { return type; } } @@ -72217,17 +72466,17 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 164 /* SyntaxKind.Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); - var isModuleExports = symbol.flags & 134217728 /* ModuleExports */; + var isModuleExports = symbol.flags & 134217728 /* SymbolFlags.ModuleExports */; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* FunctionExpression */ || - flowContainer.kind === 214 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 213 /* SyntaxKind.FunctionExpression */ || + flowContainer.kind === 214 /* SyntaxKind.ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -72235,11 +72484,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || - isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) || - node.parent.kind === 230 /* NonNullExpression */ || - declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 16777216 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */) || + node.parent.kind === 230 /* SyntaxKind.NonNullExpression */ || + declaration.kind === 254 /* SyntaxKind.VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 16777216 /* NodeFlags.Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -72263,6 +72512,25 @@ var ts; } return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function shouldMarkIdentifierAliasReferenced(node) { + var _a; + var parent = node.parent; + if (parent) { + // A property access expression LHS? checkPropertyAccessExpression will handle that. + if (ts.isPropertyAccessExpression(parent) && parent.expression === node) { + return false; + } + // Next two check for an identifier inside a type only export. + if (ts.isExportSpecifier(parent) && parent.isTypeOnly) { + return false; + } + var greatGrandparent = (_a = parent.parent) === null || _a === void 0 ? void 0 : _a.parent; + if (greatGrandparent && ts.isExportDeclaration(greatGrandparent) && greatGrandparent.isTypeOnly) { + return false; + } + } + return true; + } function isInsideFunctionOrInstancePropertyInitializer(node, threshold) { return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n) || (n.parent && ts.isPropertyDeclaration(n.parent) && !ts.hasStaticModifier(n.parent) && n.parent.initializer === n); }); } @@ -72273,11 +72541,11 @@ var ts; return ts.findAncestor(node, function (n) { return (!n || ts.nodeStartsNewLexicalEnvironment(n)) ? "quit" : ts.isIterationStatement(n, /*lookInLabeledStatements*/ false); }); } function checkNestedBlockScopedBinding(node, symbol) { - if (languageVersion >= 2 /* ES2015 */ || - (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || + (symbol.flags & (2 /* SymbolFlags.BlockScopedVariable */ | 32 /* SymbolFlags.Class */)) === 0 || !symbol.valueDeclaration || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 292 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 292 /* SyntaxKind.CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -72292,12 +72560,12 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); - links.flags |= 131072 /* ContainsCapturedBlockScopeBinding */; + links.flags |= 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */; var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []); ts.pushIfUnique(capturedBindings, symbol); if (part === container.initializer) { @@ -72307,22 +72575,22 @@ var ts; } } if (capturesBlockScopeBindingInLoopBody) { - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. if (ts.isForStatement(container)) { - var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* VariableDeclarationList */); + var varDeclList = ts.getAncestor(symbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) { - getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; + getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */; } } // set 'declared inside loop' bit on the block-scoped binding - getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } if (isCaptured) { - getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* CapturedBlockScopedBinding */; + getNodeLinks(symbol.valueDeclaration).flags |= 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; } } function isBindingCapturedByNode(node, decl) { @@ -72332,7 +72600,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 212 /* ParenthesizedExpression */) { + while (current.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -72340,9 +72608,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 219 /* PrefixUnaryExpression */ || current.parent.kind === 220 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ || current.parent.kind === 220 /* SyntaxKind.PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* SyntaxKind.PlusPlusToken */ || expr.operator === 46 /* SyntaxKind.MinusMinusToken */; } if (!isAssigned) { return false; @@ -72352,13 +72620,13 @@ var ts; return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { - getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 167 /* PropertyDeclaration */ || container.kind === 171 /* Constructor */) { + getNodeLinks(node).flags |= 2 /* NodeCheckFlags.LexicalThis */; + if (container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || container.kind === 171 /* SyntaxKind.Constructor */) { var classNode = container.parent; - getNodeLinks(classNode).flags |= 4 /* CaptureThis */; + getNodeLinks(classNode).flags |= 4 /* NodeCheckFlags.CaptureThis */; } else { - getNodeLinks(container).flags |= 4 /* CaptureThis */; + getNodeLinks(container).flags |= 4 /* NodeCheckFlags.CaptureThis */; } } function findFirstSuperCall(node) { @@ -72400,36 +72668,36 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 171 /* Constructor */) { + if (container.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 214 /* ArrowFunction */) { + if (container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } checkThisInStaticClassFieldInitializerInDecoratedClass(node, container); switch (container.kind) { - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } // When targeting es6, mark that we'll need to capture `this` in its lexically bound scope. - if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ES2015 */) { + if (!isNodeInTypeQuery && capturedByArrowFunction && languageVersion < 2 /* ScriptTarget.ES2015 */) { captureLexicalThis(node, container); } var type = tryGetThisTypeAt(node, /*includeGlobalThis*/ true, container); @@ -72464,7 +72732,7 @@ var ts; var className = getClassNameFromPrototypeMethod(container); if (isInJS && className) { var classSymbol = checkExpression(className).symbol; - if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { + if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* SymbolFlags.Function */)) { thisType = getDeclaredTypeOfSymbol(classSymbol).thisType; } } @@ -72512,9 +72780,9 @@ var ts; } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 213 /* FunctionExpression */ && + if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isBinaryExpression(container.parent) && - ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' return container.parent // x.prototype.y = container .left // x.prototype.y @@ -72522,31 +72790,31 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 169 /* MethodDeclaration */ && - container.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && + container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 213 /* FunctionExpression */ && - container.parent.kind === 296 /* PropertyAssignment */ && - container.parent.parent.kind === 205 /* ObjectLiteralExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && + container.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ && + container.parent.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* AssignmentDeclarationKind.Prototype */) { return container.parent.parent.parent.left.expression; } // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 213 /* FunctionExpression */ && + else if (container.kind === 213 /* SyntaxKind.FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && ts.isObjectLiteralExpression(container.parent.parent) && ts.isCallExpression(container.parent.parent.parent) && container.parent.parent.parent.arguments[2] === container.parent.parent && - ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.parent.arguments[0].expression; } // Object.defineProperty(x, "method", { value() { } }); @@ -72558,17 +72826,17 @@ var ts; ts.isObjectLiteralExpression(container.parent) && ts.isCallExpression(container.parent.parent) && container.parent.parent.arguments[2] === container.parent && - ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* ObjectDefinePrototypeProperty */) { + ts.getAssignmentDeclarationKind(container.parent.parent) === 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */) { return container.parent.parent.arguments[0].expression; } } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 317 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 317 /* SyntaxKind.JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && - jsDocFunctionType.parameters[0].name.escapedText === "this" /* This */) { + jsDocFunctionType.parameters[0].name.escapedText === "this" /* InternalSymbolName.This */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } @@ -72578,18 +72846,18 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 164 /* SyntaxKind.Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 208 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 208 /* SyntaxKind.CallExpression */ && node.parent.expression === node; var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var container = immediateContainer; var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 214 /* ArrowFunction */) { + while (container && container.kind === 214 /* SyntaxKind.ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); - needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; + needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */; } } var canUseSuperExpression = isLegalUsageOfSuperExpression(container); @@ -72600,14 +72868,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* ComputedPropertyName */; }); - if (current && current.kind === 162 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 162 /* SyntaxKind.ComputedPropertyName */; }); + if (current && current.kind === 162 /* SyntaxKind.ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -72615,26 +72883,26 @@ var ts; } return errorType; } - if (!isCallExpression && immediateContainer.kind === 171 /* Constructor */) { + if (!isCallExpression && immediateContainer.kind === 171 /* SyntaxKind.Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.isStatic(container) || isCallExpression) { - nodeCheckFlag = 512 /* SuperStatic */; + nodeCheckFlag = 512 /* NodeCheckFlags.SuperStatic */; if (!isCallExpression && - languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ && + languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && (ts.isPropertyDeclaration(container) || ts.isClassStaticBlockDeclaration(container))) { // for `super.x` or `super[x]` in a static initializer, mark all enclosing // block scope containers so that we can report potential collisions with // `Reflect`. ts.forEachEnclosingBlockScopeContainer(node.parent, function (current) { if (!ts.isSourceFile(current) || ts.isExternalOrCommonJsModule(current)) { - getNodeLinks(current).flags |= 134217728 /* ContainsSuperPropertyInStaticInitializer */; + getNodeLinks(current).flags |= 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */; } }); } } else { - nodeCheckFlag = 256 /* SuperInstance */; + nodeCheckFlag = 256 /* NodeCheckFlags.SuperInstance */; } getNodeLinks(node).flags |= nodeCheckFlag; // Due to how we emit async functions, we need to specialize the emit for an async method that contains a `super` reference. @@ -72696,12 +72964,12 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 169 /* MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* Async */)) { + if (container.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasSyntacticModifier(container, 256 /* ModifierFlags.Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { - getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; + getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */; } else { - getNodeLinks(container).flags |= 2048 /* AsyncMethodWithSuper */; + getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.AsyncMethodWithSuper */; } } if (needToCaptureLexicalThis) { @@ -72710,8 +72978,8 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 205 /* ObjectLiteralExpression */) { - if (languageVersion < 2 /* ES2015 */) { + if (container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; } @@ -72731,12 +72999,12 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 171 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 171 /* SyntaxKind.Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } - return nodeCheckFlag === 512 /* SuperStatic */ + return nodeCheckFlag === 512 /* NodeCheckFlags.SuperStatic */ ? getBaseConstructorTypeOfClass(classType) : getTypeWithThisArgument(baseClassType, classType.thisType); function isLegalUsageOfSuperExpression(container) { @@ -72746,7 +73014,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 171 /* Constructor */; + return container.kind === 171 /* SyntaxKind.Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -72754,23 +73022,23 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { if (ts.isStatic(container)) { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 170 /* ClassStaticBlockDeclaration */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 170 /* SyntaxKind.ClassStaticBlockDeclaration */; } else { - return container.kind === 169 /* MethodDeclaration */ || - container.kind === 168 /* MethodSignature */ || - container.kind === 172 /* GetAccessor */ || - container.kind === 173 /* SetAccessor */ || - container.kind === 167 /* PropertyDeclaration */ || - container.kind === 166 /* PropertySignature */ || - container.kind === 171 /* Constructor */; + return container.kind === 169 /* SyntaxKind.MethodDeclaration */ || + container.kind === 168 /* SyntaxKind.MethodSignature */ || + container.kind === 172 /* SyntaxKind.GetAccessor */ || + container.kind === 173 /* SyntaxKind.SetAccessor */ || + container.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + container.kind === 166 /* SyntaxKind.PropertySignature */ || + container.kind === 171 /* SyntaxKind.Constructor */; } } } @@ -72778,22 +73046,22 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 169 /* MethodDeclaration */ || - func.kind === 172 /* GetAccessor */ || - func.kind === 173 /* SetAccessor */) && func.parent.kind === 205 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 213 /* FunctionExpression */ && func.parent.kind === 296 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 169 /* SyntaxKind.MethodDeclaration */ || + func.kind === 172 /* SyntaxKind.GetAccessor */ || + func.kind === 173 /* SyntaxKind.SetAccessor */) && func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ ? func.parent : + func.kind === 213 /* SyntaxKind.FunctionExpression */ && func.parent.kind === 296 /* SyntaxKind.PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; + return ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { - return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); }); } function getContextualThisParameterType(func) { - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -72812,7 +73080,7 @@ var ts; // We have an object literal method. Check if the containing object literal has a contextual type // that includes a ThisType. If so, T is the contextual type for 'this'. We continue looking in // any directly enclosing object literals. - var contextualType = getApparentTypeOfContextualType(containingLiteral); + var contextualType = getApparentTypeOfContextualType(containingLiteral, /*contextFlags*/ undefined); var literal = containingLiteral; var type = contextualType; while (type) { @@ -72820,11 +73088,11 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 296 /* PropertyAssignment */) { + if (literal.parent.kind !== 296 /* SyntaxKind.PropertyAssignment */) { break; } literal = literal.parent.parent; - type = getApparentTypeOfContextualType(literal); + type = getApparentTypeOfContextualType(literal, /*contextFlags*/ undefined); } // There was no contextual ThisType for the containing object literal, so the contextual type // for 'this' is the non-null form of the contextual type for the containing object literal or @@ -72834,7 +73102,7 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = ts.walkUpParenthesizedExpressions(func.parent); - if (parent.kind === 221 /* BinaryExpression */ && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent.kind === 221 /* SyntaxKind.BinaryExpression */ && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var target = parent.left; if (ts.isAccessExpression(target)) { var expression = target.expression; @@ -72862,7 +73130,7 @@ var ts; var args = getEffectiveCallArguments(iife); var indexOfParameter = func.parameters.indexOf(parameter); if (parameter.dotDotDotToken) { - return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* Normal */); + return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, /*context*/ undefined, 0 /* CheckMode.Normal */); } var links = getNodeLinks(iife); var cached = links.resolvedSignature; @@ -72881,31 +73149,31 @@ var ts; tryGetTypeAtPosition(contextualSignature, index); } } - function getContextualTypeForVariableLikeDeclaration(declaration) { + function getContextualTypeForVariableLikeDeclaration(declaration, contextFlags) { var typeNode = ts.getEffectiveTypeAnnotationNode(declaration); if (typeNode) { return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return getContextuallyTypedParameterType(declaration); - case 203 /* BindingElement */: - return getContextualTypeForBindingElement(declaration); - case 167 /* PropertyDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + return getContextualTypeForBindingElement(declaration, contextFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isStatic(declaration)) { - return getContextualTypeForStaticPropertyDeclaration(declaration); + return getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags); } // By default, do nothing and return undefined - only the above cases have context implied by a parent } } - function getContextualTypeForBindingElement(declaration) { + function getContextualTypeForBindingElement(declaration, contextFlags) { var parent = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - var parentType = getContextualTypeForVariableLikeDeclaration(parent) || - parent.kind !== 203 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */); + var parentType = getContextualTypeForVariableLikeDeclaration(parent, contextFlags) || + parent.kind !== 203 /* SyntaxKind.BindingElement */ && parent.initializer && checkDeclarationInitializer(parent, declaration.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */); if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name)) return undefined; - if (parent.name.kind === 202 /* ArrayBindingPattern */) { + if (parent.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { var index = ts.indexOfNode(declaration.parent.elements, declaration); if (index < 0) return undefined; @@ -72917,8 +73185,8 @@ var ts; return getTypeOfPropertyOfType(parentType, text); } } - function getContextualTypeForStaticPropertyDeclaration(declaration) { - var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent); + function getContextualTypeForStaticPropertyDeclaration(declaration, contextFlags) { + var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent, contextFlags); if (!parentType) return undefined; return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName); @@ -72934,32 +73202,35 @@ var ts; function getContextualTypeForInitializerExpression(node, contextFlags) { var declaration = node.parent; if (ts.hasInitializer(declaration) && node === declaration.initializer) { - var result = getContextualTypeForVariableLikeDeclaration(declaration); + var result = getContextualTypeForVariableLikeDeclaration(declaration, contextFlags); if (result) { return result; } - if (!(contextFlags & 8 /* SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) { + if (!(contextFlags & 8 /* ContextFlags.SkipBindingPatterns */) && ts.isBindingPattern(declaration.name) && declaration.name.elements.length > 0) { return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } } return undefined; } - function getContextualTypeForReturnExpression(node) { + function getContextualTypeForReturnExpression(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { var functionFlags = ts.getFunctionFlags(func); - if (functionFlags & 1 /* Generator */) { // Generator or AsyncGenerator function - var use = functionFlags & 2 /* Async */ ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; - var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, /*errorNode*/ undefined); - if (!iterationTypes) { + if (functionFlags & 1 /* FunctionFlags.Generator */) { // Generator or AsyncGenerator function + var isAsyncGenerator_1 = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + if (contextualReturnType.flags & 1048576 /* TypeFlags.Union */) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, type, isAsyncGenerator_1); }); + } + var iterationReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, contextualReturnType, (functionFlags & 2 /* FunctionFlags.Async */) !== 0); + if (!iterationReturnType) { return undefined; } - contextualReturnType = iterationTypes.returnType; + contextualReturnType = iterationReturnType; // falls through to unwrap Promise for AsyncGenerators } - if (functionFlags & 2 /* Async */) { // Async function or AsyncGenerator function + if (functionFlags & 2 /* FunctionFlags.Async */) { // Async function or AsyncGenerator function // Get the awaited type without the `Awaited` alias var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeNoAlias); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); @@ -72977,15 +73248,19 @@ var ts; } return undefined; } - function getContextualTypeForYieldOperand(node) { + function getContextualTypeForYieldOperand(node, contextFlags) { var func = ts.getContainingFunction(node); if (func) { var functionFlags = ts.getFunctionFlags(func); - var contextualReturnType = getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func, contextFlags); if (contextualReturnType) { + var isAsyncGenerator_2 = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + if (!node.asteriskToken && contextualReturnType.flags & 1048576 /* TypeFlags.Union */) { + contextualReturnType = filterType(contextualReturnType, function (type) { return !!getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, type, isAsyncGenerator_2); }); + } return node.asteriskToken ? contextualReturnType - : getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, contextualReturnType, (functionFlags & 2 /* Async */) !== 0); + : getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, contextualReturnType, isAsyncGenerator_2); } } return undefined; @@ -73004,15 +73279,15 @@ var ts; return false; } function getContextualIterationType(kind, functionDecl) { - var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* Async */); - var contextualReturnType = getContextualReturnType(functionDecl); + var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2 /* FunctionFlags.Async */); + var contextualReturnType = getContextualReturnType(functionDecl, /*contextFlags*/ undefined); if (contextualReturnType) { return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync) || undefined; } return undefined; } - function getContextualReturnType(functionDecl) { + function getContextualReturnType(functionDecl, contextFlags) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed var returnType = getReturnTypeFromAnnotation(functionDecl); @@ -73027,7 +73302,7 @@ var ts; } var iife = ts.getImmediatelyInvokedFunctionExpression(functionDecl); if (iife) { - return getContextualType(iife); + return getContextualType(iife, contextFlags); } return undefined; } @@ -73051,11 +73326,11 @@ var ts; } var restIndex = signature.parameters.length - 1; return signatureHasRestParameter(signature) && argIndex >= restIndex ? - getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* Contextual */) : + getIndexedAccessType(getTypeOfSymbol(signature.parameters[restIndex]), getNumberLiteralType(argIndex - restIndex), 256 /* AccessFlags.Contextual */) : getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 210 /* TaggedTemplateExpression */) { + if (template.parent.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -73064,13 +73339,13 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 63 /* EqualsToken */: - case 76 /* AmpersandAmpersandEqualsToken */: - case 75 /* BarBarEqualsToken */: - case 77 /* QuestionQuestionEqualsToken */: + case 63 /* SyntaxKind.EqualsToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined; - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: + case 56 /* SyntaxKind.BarBarToken */: + case 60 /* SyntaxKind.QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -73079,8 +73354,8 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 27 /* SyntaxKind.CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: return undefined; @@ -73101,6 +73376,14 @@ var ts; var lhsType = getTypeOfExpression(e.expression); return ts.isPrivateIdentifier(e.name) ? tryGetPrivateIdentifierPropertyOfType(lhsType, e.name) : getPropertyOfType(lhsType, e.name.escapedText); } + if (ts.isElementAccessExpression(e)) { + var propType = checkExpressionCached(e.argumentExpression); + if (!isTypeUsableAsPropertyName(propType)) { + return undefined; + } + var lhsType = getTypeOfExpression(e.expression); + return getPropertyOfType(lhsType, getPropertyNameFromType(propType)); + } return undefined; function tryGetPrivateIdentifierPropertyOfType(type, id) { var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(id.escapedText, id); @@ -73113,8 +73396,8 @@ var ts; var _a, _b; var kind = ts.getAssignmentDeclarationKind(binaryExpression); switch (kind) { - case 0 /* None */: - case 4 /* ThisProperty */: + case 0 /* AssignmentDeclarationKind.None */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var lhsSymbol = getSymbolForExpression(binaryExpression.left); var decl = lhsSymbol && lhsSymbol.valueDeclaration; // Unannotated, uninitialized property declarations have a type implied by their usage in the constructor. @@ -73124,11 +73407,11 @@ var ts; return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || (ts.isPropertyDeclaration(decl) ? decl.initializer && getTypeOfExpression(binaryExpression.left) : undefined); } - if (kind === 0 /* None */) { + if (kind === 0 /* AssignmentDeclarationKind.None */) { return getTypeOfExpression(binaryExpression.left); } return getContextualTypeForThisPropertyAssignment(binaryExpression); - case 5 /* Property */: + case 5 /* AssignmentDeclarationKind.Property */: if (isPossiblyAliasedThisProperty(binaryExpression, kind)) { return getContextualTypeForThisPropertyAssignment(binaryExpression); } @@ -73149,7 +73432,7 @@ var ts; } else if (ts.isIdentifier(lhs.expression)) { var id = lhs.expression; - var parentSymbol = resolveName(id, id.escapedText, 111551 /* Value */, undefined, id.escapedText, /*isUse*/ true); + var parentSymbol = resolveName(id, id.escapedText, 111551 /* SymbolFlags.Value */, undefined, id.escapedText, /*isUse*/ true); if (parentSymbol) { var annotated_1 = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated_1) { @@ -73163,18 +73446,18 @@ var ts; } return ts.isInJSFile(decl_1) ? undefined : getTypeOfExpression(binaryExpression.left); } - case 1 /* ExportsProperty */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: var valueDeclaration = (_a = binaryExpression.left.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration; // falls through - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: valueDeclaration || (valueDeclaration = (_b = binaryExpression.symbol) === null || _b === void 0 ? void 0 : _b.valueDeclaration); var annotated = valueDeclaration && ts.getEffectiveTypeAnnotationNode(valueDeclaration); return annotated ? getTypeFromTypeNode(annotated) : undefined; - case 7 /* ObjectDefinePropertyValue */: - case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: + case 7 /* AssignmentDeclarationKind.ObjectDefinePropertyValue */: + case 8 /* AssignmentDeclarationKind.ObjectDefinePropertyExports */: + case 9 /* AssignmentDeclarationKind.ObjectDefinePrototypeProperty */: return ts.Debug.fail("Does not apply"); default: return ts.Debug.assertNever(kind); @@ -73182,14 +73465,14 @@ var ts; } function isPossiblyAliasedThisProperty(declaration, kind) { if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); } - if (kind === 4 /* ThisProperty */) { + if (kind === 4 /* AssignmentDeclarationKind.ThisProperty */) { return true; } - if (!ts.isInJSFile(declaration) || kind !== 5 /* Property */ || !ts.isIdentifier(declaration.left.expression)) { + if (!ts.isInJSFile(declaration) || kind !== 5 /* AssignmentDeclarationKind.Property */ || !ts.isIdentifier(declaration.left.expression)) { return false; } var name = declaration.left.expression.escapedText; - var symbol = resolveName(declaration.left, name, 111551 /* Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); + var symbol = resolveName(declaration.left, name, 111551 /* SymbolFlags.Value */, undefined, undefined, /*isUse*/ true, /*excludeGlobals*/ true); return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration); } function getContextualTypeForThisPropertyAssignment(binaryExpression) { @@ -73213,11 +73496,11 @@ var ts; return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined; } function isCircularMappedProperty(symbol) { - return !!(ts.getCheckFlags(symbol) & 262144 /* Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* Type */) >= 0); + return !!(ts.getCheckFlags(symbol) & 262144 /* CheckFlags.Mapped */ && !symbol.type && findResolutionCycleStartIndex(symbol, 0 /* TypeSystemPropertyName.Type */) >= 0); } function getTypeOfPropertyOfContextualType(type, name, nameType) { return mapType(type, function (t) { - if (t.flags & 2097152 /* Intersection */) { + if (t.flags & 2097152 /* TypeFlags.Intersection */) { var intersection = t; var newTypes = ts.mapDefined(intersection.types, getTypeOfConcretePropertyOfContextualType); if (newTypes.length > 0) { @@ -73245,7 +73528,7 @@ var ts; } return undefined; } - if (t.flags & 3670016 /* StructuredType */) { + if (t.flags & 3670016 /* TypeFlags.StructuredType */) { var prop = getPropertyOfType(t, name); if (prop) { return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop); @@ -73261,7 +73544,7 @@ var ts; } function getTypeOfApplicableIndexInfoOfContextualType(t) { var _a; - if (!(t.flags & 3670016 /* StructuredType */)) { + if (!(t.flags & 3670016 /* TypeFlags.StructuredType */)) { return undefined; } return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name)))) === null || _a === void 0 ? void 0 : _a.type; @@ -73272,7 +73555,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -73280,7 +73563,7 @@ var ts; } function getContextualTypeForObjectLiteralElement(element, contextFlags) { var objectLiteral = element.parent; - var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element); + var propertyAssignmentType = ts.isPropertyAssignment(element) && getContextualTypeForVariableLikeDeclaration(element, contextFlags); if (propertyAssignmentType) { return propertyAssignmentType; } @@ -73307,7 +73590,7 @@ var ts; // type of T. function getContextualTypeForElementExpression(arrayContextualType, index) { return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) - || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, + || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1 /* IterationUse.Element */, t, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); }, /*noReductions*/ true)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -73315,8 +73598,8 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined; } - function getContextualTypeForChildJsxExpression(node, child) { - var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName); + function getContextualTypeForChildJsxExpression(node, child, contextFlags) { + var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags); // JSX expression is in children of JSX Element, we will look for an "children" attribute (we get the name from JSX.ElementAttributesProperty) var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node)); if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) { @@ -73334,27 +73617,27 @@ var ts; } }, /*noReductions*/ true)); } - function getContextualTypeForJsxExpression(node) { + function getContextualTypeForJsxExpression(node, contextFlags) { var exprParent = node.parent; return ts.isJsxAttributeLike(exprParent) - ? getContextualType(node) + ? getContextualType(node, contextFlags) : ts.isJsxElement(exprParent) - ? getContextualTypeForChildJsxExpression(exprParent, node) + ? getContextualTypeForChildJsxExpression(exprParent, node, contextFlags) : undefined; } - function getContextualTypeForJsxAttribute(attribute) { + function getContextualTypeForJsxAttribute(attribute, contextFlags) { // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type // which is a type of the parameter of the signature we are trying out. // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName if (ts.isJsxAttribute(attribute)) { - var attributesType = getApparentTypeOfContextualType(attribute.parent); + var attributesType = getApparentTypeOfContextualType(attribute.parent, contextFlags); if (!attributesType || isTypeAny(attributesType)) { return undefined; } return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText); } else { - return getContextualType(attribute.parent); + return getContextualType(attribute.parent, contextFlags); } } // Return true if the given expression is possibly a discriminant value. We limit the kinds of @@ -73362,29 +73645,29 @@ var ts; // recursive (and possibly infinite) invocations of getContextualType. function isPossiblyDiscriminantValue(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 79 /* Identifier */: - case 153 /* UndefinedKeyword */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 79 /* SyntaxKind.Identifier */: + case 153 /* SyntaxKind.UndefinedKeyword */: return true; - case 206 /* PropertyAccessExpression */: - case 212 /* ParenthesizedExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return getMatchingUnionConstituentForObjectLiteral(contextualType, node) || discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 296 /* SyntaxKind.PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return getContextFreeTypeOfExpression(prop.initializer); }, prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.concatenate(ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 285 /* SyntaxKind.JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return getContextFreeTypeOfExpression(prop.initializer); }), prop.symbol.escapedName]; }), ts.map(ts.filter(getPropertiesOfType(contextualType), function (s) { var _a; return !!(s.flags & 16777216 /* SymbolFlags.Optional */) && !!((_a = node === null || node === void 0 ? void 0 : node.symbol) === null || _a === void 0 ? void 0 : _a.members) && !node.symbol.members.has(s.escapedName) && isDiscriminantProperty(contextualType, s.escapedName); }), function (s) { return [function () { return undefinedType; }, s.escapedName]; })), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -73393,21 +73676,21 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* ContextFlags.NoConstraints */ && instantiatedType.flags & 8650752 /* TypeFlags.TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); - return apparentType.flags & 1048576 /* Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : - apparentType.flags & 1048576 /* Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : + return apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType) : + apparentType.flags & 1048576 /* TypeFlags.Union */ && ts.isJsxAttributes(node) ? discriminateContextualTypeByJSXAttributes(node, apparentType) : apparentType; } } // If the given contextual type contains instantiable types and if a mapper representing // return type inferences is available, instantiate those types using that mapper. function instantiateContextualType(contextualType, node, contextFlags) { - if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* Instantiable */)) { + if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) { var inferenceContext = getInferenceContext(node); // If no inferences have been made, nothing is gained from instantiating as type parameters // would just be replaced with their defaults similar to the apparent type. - if (inferenceContext && contextFlags & 1 /* Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { + if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) { // For contextual signatures we incorporate all inferences made so far, e.g. from return // types as well as arguments to the left in a function call. return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper); @@ -73418,7 +73701,7 @@ var ts; // the 'boolean' type from the contextual type such that contextually typed boolean // literals actually end up widening to 'boolean' (see #48363). var type = instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper); - return type.flags & 1048576 /* Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? + return type.flags & 1048576 /* TypeFlags.Union */ && containsType(type.types, regularFalseType) && containsType(type.types, regularTrueType) ? filterType(type, function (t) { return t !== regularFalseType && t !== regularTrueType; }) : type; } @@ -73429,13 +73712,13 @@ var ts; // are classified as instantiable (i.e. it doesn't instantiate object types), and (b) it performs // no reductions on instantiated union types. function instantiateInstantiableTypes(type, mapper) { - if (type.flags & 465829888 /* Instantiable */) { + if (type.flags & 465829888 /* TypeFlags.Instantiable */) { return instantiateType(type, mapper); } - if (type.flags & 1048576 /* Union */) { - return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* None */); + if (type.flags & 1048576 /* TypeFlags.Union */) { + return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0 /* UnionReduction.None */); } - if (type.flags & 2097152 /* Intersection */) { + if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); })); } return type; @@ -73458,7 +73741,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -73467,65 +73750,65 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 203 /* BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 203 /* SyntaxKind.BindingElement */: return getContextualTypeForInitializerExpression(node, contextFlags); - case 214 /* ArrowFunction */: - case 247 /* ReturnStatement */: - return getContextualTypeForReturnExpression(node); - case 224 /* YieldExpression */: - return getContextualTypeForYieldOperand(parent); - case 218 /* AwaitExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 247 /* SyntaxKind.ReturnStatement */: + return getContextualTypeForReturnExpression(node, contextFlags); + case 224 /* SyntaxKind.YieldExpression */: + return getContextualTypeForYieldOperand(parent, contextFlags); + case 218 /* SyntaxKind.AwaitExpression */: return getContextualTypeForAwaitOperand(parent, contextFlags); - case 208 /* CallExpression */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: return getContextualTypeForArgument(parent, node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return getContextualType(parent.parent, contextFlags); - case 204 /* ArrayLiteralExpression */: { + case 204 /* SyntaxKind.ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 233 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 223 /* TemplateExpression */); + case 233 /* SyntaxKind.TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 223 /* SyntaxKind.TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 212 /* ParenthesizedExpression */: { + case 212 /* SyntaxKind.ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return !tag ? getContextualType(parent, contextFlags) : ts.isJSDocTypeTag(tag) && ts.isConstTypeReference(tag.typeExpression.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(tag.typeExpression.type); } - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return getContextualType(parent, contextFlags); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return tryGetTypeFromEffectiveTypeNode(parent); - case 288 /* JsxExpression */: - return getContextualTypeForJsxExpression(parent); - case 285 /* JsxAttribute */: - case 287 /* JsxSpreadAttribute */: - return getContextualTypeForJsxAttribute(parent); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 288 /* SyntaxKind.JsxExpression */: + return getContextualTypeForJsxExpression(parent, contextFlags); + case 285 /* SyntaxKind.JsxAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + return getContextualTypeForJsxAttribute(parent, contextFlags); + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent, contextFlags); } return undefined; function tryFindWhenConstTypeReference(node) { - return getContextualType(node); + return getContextualType(node, contextFlags); } } function getInferenceContext(node) { @@ -73533,7 +73816,7 @@ var ts; return ancestor && ancestor.inferenceContext; } function getContextualJsxElementAttributesType(node, contextFlags) { - if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* Completions */) { + if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4 /* ContextFlags.Completions */) { // Contextually applied type is moved from attributes up to the outer jsx attributes so when walking up from the children they get hit // _However_ to hit them from the _attributes_ we must look for them here; otherwise we'll used the declared type // (as below) instead! @@ -73542,7 +73825,7 @@ var ts; return getContextualTypeForArgumentAtIndex(node, 0); } function getEffectiveFirstArgumentForJsxSignature(signature, node) { - return getJsxReferenceKind(node) !== 0 /* Component */ + return getJsxReferenceKind(node) !== 0 /* JsxReferenceKind.Component */ ? getJsxPropsTypeFromCallSignature(signature, node) : getJsxPropsTypeFromClassType(signature, node); } @@ -73587,7 +73870,7 @@ var ts; return getOrCreateTypeFromSignature(fakeSignature); } var tagType = checkExpressionCached(context.tagName); - if (tagType.flags & 128 /* StringLiteral */) { + if (tagType.flags & 128 /* TypeFlags.StringLiteral */) { var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context); if (!result) { return errorType; @@ -73602,7 +73885,7 @@ var ts; if (managedSym) { var declaredManagedType = getDeclaredTypeOfSymbol(managedSym); // fetches interface type, or initializes symbol links type parmaeters var ctorType = getStaticTypeOfReferencedJsxConstructor(context); - if (managedSym.flags & 524288 /* TypeAlias */) { + if (managedSym.flags & 524288 /* SymbolFlags.TypeAlias */) { var params = getSymbolLinks(managedSym).typeParameters; if (ts.length(params) >= 2) { var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context)); @@ -73703,12 +73986,12 @@ var ts; !leftName ? rightName : !rightName ? leftName : undefined; - var paramSymbol = createSymbol(1 /* FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* Optional */ : 0), paramName || "arg" + i); + var paramSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */ | (isOptional && !isRestParam ? 16777216 /* SymbolFlags.Optional */ : 0), paramName || "arg".concat(i)); paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType; params[i] = paramSymbol; } if (needsExtraRestElement) { - var restParamSymbol = createSymbol(1 /* FunctionScopedVariable */, "args"); + var restParamSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "args"); restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount)); if (shorter === right) { restParamSymbol.type = instantiateType(restParamSymbol.type, mapper); @@ -73730,18 +74013,18 @@ var ts; var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); var result = createSignature(declaration, typeParams, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* PropagatingFlags */); - result.compositeKind = 2097152 /* Intersection */; - result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* Intersection */ && left.compositeSignatures || [left], [right]); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 39 /* SignatureFlags.PropagatingFlags */); + result.compositeKind = 2097152 /* TypeFlags.Intersection */; + result.compositeSignatures = ts.concatenate(left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.compositeSignatures || [left], [right]); if (paramMapper) { - result.mapper = left.compositeKind === 2097152 /* Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; + result.mapper = left.compositeKind === 2097152 /* TypeFlags.Intersection */ && left.mapper && left.compositeSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper; } return result; } // If the given type is an object or union type with a single signature, and if that signature has at // least as many parameters as the given function, return the signature. Otherwise return undefined. function getContextualCallSignature(type, node) { - var signatures = getSignaturesOfType(type, 0 /* Call */); + var signatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var applicableByArity = ts.filter(signatures, function (s) { return !isAritySmaller(s, node); }); return applicableByArity.length === 1 ? applicableByArity[0] : getIntersectedSignatures(applicableByArity); } @@ -73771,16 +74054,16 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; } - var type = getApparentTypeOfContextualType(node, 1 /* Signature */); + var type = getApparentTypeOfContextualType(node, 1 /* ContextFlags.Signature */); if (!type) { return undefined; } - if (!(type.flags & 1048576 /* Union */)) { + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { return getContextualCallSignature(type, node); } var signatureList; @@ -73809,38 +74092,38 @@ var ts; } } function checkSpreadExpression(node, checkMode) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var arrayOrIterableType = checkExpression(node.expression, checkMode); - return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); + return checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, arrayOrIterableType, undefinedType, node.expression); } function checkSyntheticExpression(node) { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } function hasDefaultValue(node) { - return (node.kind === 203 /* BindingElement */ && !!node.initializer) || - (node.kind === 221 /* BinaryExpression */ && node.operatorToken.kind === 63 /* EqualsToken */); + return (node.kind === 203 /* SyntaxKind.BindingElement */ && !!node.initializer) || + (node.kind === 221 /* SyntaxKind.BinaryExpression */ && node.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; var elementCount = elements.length; var elementTypes = []; var elementFlags = []; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined); var inDestructuringPattern = ts.isAssignmentTarget(node); var inConstContext = isConstContext(node); var hasOmittedExpression = false; for (var i = 0; i < elementCount; i++) { var e = elements[i]; - if (e.kind === 225 /* SpreadElement */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* SpreadIncludes */ : 1024 /* SpreadArray */); + if (e.kind === 225 /* SyntaxKind.SpreadElement */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 /* ExternalEmitHelpers.SpreadIncludes */ : 1024 /* ExternalEmitHelpers.SpreadArray */); } var spreadType = checkExpression(e.expression, checkMode, forceTuple); if (isArrayLikeType(spreadType)) { elementTypes.push(spreadType); - elementFlags.push(8 /* Variadic */); + elementFlags.push(8 /* ElementFlags.Variadic */); } else if (inDestructuringPattern) { // Given the following situation: @@ -73856,27 +74139,27 @@ var ts; // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. var restElementType = getIndexTypeOfType(spreadType, numberType) || - getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || + getIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false) || unknownType; elementTypes.push(restElementType); - elementFlags.push(4 /* Rest */); + elementFlags.push(4 /* ElementFlags.Rest */); } else { - elementTypes.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, e.expression)); - elementFlags.push(4 /* Rest */); + elementTypes.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, e.expression)); + elementFlags.push(4 /* ElementFlags.Rest */); } } - else if (exactOptionalPropertyTypes && e.kind === 227 /* OmittedExpression */) { + else if (exactOptionalPropertyTypes && e.kind === 227 /* SyntaxKind.OmittedExpression */) { hasOmittedExpression = true; elementTypes.push(missingType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); } else { var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression)); - elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */); - if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) { + elementFlags.push(hasOmittedExpression ? 2 /* ElementFlags.Optional */ : 1 /* ElementFlags.Required */); + if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && isContextSensitive(e)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context addIntraExpressionInferenceSite(inferenceContext, e, type); @@ -73890,28 +74173,28 @@ var ts; return createArrayLiteralType(createTupleType(elementTypes, elementFlags, /*readonly*/ inConstContext)); } return createArrayLiteralType(createArrayType(elementTypes.length ? - getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* Subtype */) : + getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 /* ElementFlags.Variadic */ ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2 /* UnionReduction.Subtype */) : strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext)); } function createArrayLiteralType(type) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */)) { + if (!(ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */)) { return type; } var literalType = type.literalType; if (!literalType) { literalType = type.literalType = cloneTypeReference(type); - literalType.objectFlags |= 16384 /* ArrayLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + literalType.objectFlags |= 16384 /* ObjectFlags.ArrayLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; } return literalType; } function isNumericName(name) { switch (name.kind) { - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return isNumericComputedName(name); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.isNumericLiteralName(name.escapedText); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return ts.isNumericLiteralName(name.text); default: return false; @@ -73920,14 +74203,14 @@ var ts; function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, // but this behavior is consistent with checkIndexedAccess - return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* NumberLike */); + return isTypeAssignableToKind(checkComputedPropertyName(name), 296 /* TypeFlags.NumberLike */); } function checkComputedPropertyName(node) { var links = getNodeLinks(node.expression); if (!links.resolvedType) { if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent)) - && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */ - && node.parent.kind !== 172 /* GetAccessor */ && node.parent.kind !== 173 /* SetAccessor */) { + && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ + && node.parent.kind !== 172 /* SyntaxKind.GetAccessor */ && node.parent.kind !== 173 /* SyntaxKind.SetAccessor */) { return links.resolvedType = errorType; } links.resolvedType = checkExpression(node.expression); @@ -73938,17 +74221,17 @@ var ts; var enclosingIterationStatement = getEnclosingIterationStatement(container); if (enclosingIterationStatement) { // The computed field name will use a block scoped binding which can be unique for each iteration of the loop. - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; // The generated variable which stores the computed field name must be block-scoped. - getNodeLinks(node).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; // The generated variable which stores the class must be block-scoped. - getNodeLinks(node.parent.parent).flags |= 524288 /* BlockScopedBindingInLoop */; + getNodeLinks(node.parent.parent).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; } } // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (links.resolvedType.flags & 98304 /* Nullable */ || - !isTypeAssignableToKind(links.resolvedType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) && + if (links.resolvedType.flags & 98304 /* TypeFlags.Nullable */ || + !isTypeAssignableToKind(links.resolvedType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) && !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } @@ -73964,7 +74247,7 @@ var ts; var _a; var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]; return ts.isKnownSymbol(symbol) || (firstDecl && ts.isNamedDeclaration(firstDecl) && ts.isComputedPropertyName(firstDecl.name) && - isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */)); + isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* TypeFlags.ESSymbol */)); } function getObjectLiteralIndexInfo(node, offset, properties, keyType) { var propTypes = []; @@ -73976,11 +74259,11 @@ var ts; propTypes.push(getTypeOfSymbol(properties[i])); } } - var unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType; + var unionType = propTypes.length ? getUnionType(propTypes, 2 /* UnionReduction.Subtype */) : undefinedType; return createIndexInfo(keyType, unionType, isConstContext(node)); } function getImmediateAliasedSymbol(symbol) { - ts.Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here."); + ts.Debug.assert((symbol.flags & 2097152 /* SymbolFlags.Alias */) !== 0, "Should only get Alias here."); var links = getSymbolLinks(symbol); if (!links.immediateTarget) { var node = getDeclarationOfAliasSymbol(symbol); @@ -73998,11 +74281,11 @@ var ts; var propertiesTable = ts.createSymbolTable(); var propertiesArray = []; var spread = emptyObjectType; - var contextualType = getApparentTypeOfContextualType(node); + var contextualType = getApparentTypeOfContextualType(node, /*contextFlags*/ undefined); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 201 /* ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 201 /* SyntaxKind.ObjectBindingPattern */ || contextualType.pattern.kind === 205 /* SyntaxKind.ObjectLiteralExpression */); var inConstContext = isConstContext(node); - var checkFlags = inConstContext ? 8 /* Readonly */ : 0; + var checkFlags = inConstContext ? 8 /* CheckFlags.Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); var enumTag = ts.getJSDocEnumTag(node); var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; @@ -74024,16 +74307,16 @@ var ts; for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var memberDecl = _c[_b]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* ComputedPropertyName */ ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 296 /* PropertyAssignment */ || - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 296 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + var type = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : // avoid resolving the left side of the ShorthandPropertyAssignment outside of the destructuring // for error recovery purposes. For example, if a user wrote `{ a = 100 }` instead of `{ a: 100 }`. // we don't want to say "could not find 'a'". - memberDecl.kind === 297 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : + memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -74045,29 +74328,29 @@ var ts; checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= ts.getObjectFlags(type) & 458752 /* PropagatingFlags */; + objectFlags |= ts.getObjectFlags(type) & 458752 /* ObjectFlags.PropagatingFlags */; var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; var prop = nameType ? - createSymbol(4 /* Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* Late */) : - createSymbol(4 /* Property */ | member.flags, member.escapedName, checkFlags); + createSymbol(4 /* SymbolFlags.Property */ | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096 /* CheckFlags.Late */) : + createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName, checkFlags); if (nameType) { prop.nameType = nameType; } if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 296 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 297 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { - prop.flags |= 16777216 /* Optional */; + prop.flags |= 16777216 /* SymbolFlags.Optional */; } } - else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { + else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the // binding pattern specifies a default value for the property, make the property optional. var impliedProp = getPropertyOfType(contextualType, member.escapedName); if (impliedProp) { - prop.flags |= impliedProp.flags & 16777216 /* Optional */; + prop.flags |= impliedProp.flags & 16777216 /* SymbolFlags.Optional */; } else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, stringType)) { error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType)); @@ -74082,17 +74365,17 @@ var ts; prop.target = member; member = prop; allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); - if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && - (memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) { + if (contextualType && checkMode && checkMode & 2 /* CheckMode.Inferential */ && !(checkMode & 4 /* CheckMode.SkipContextSensitive */) && + (memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ || memberDecl.kind === 169 /* SyntaxKind.MethodDeclaration */) && isContextSensitive(memberDecl)) { var inferenceContext = getInferenceContext(node); ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context - var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl; + var inferenceNode = memberDecl.kind === 296 /* SyntaxKind.PropertyAssignment */ ? memberDecl.initializer : memberDecl; addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type); } } - else if (memberDecl.kind === 298 /* SpreadAssignment */) { - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(memberDecl, 2 /* Assign */); + else if (memberDecl.kind === 298 /* SyntaxKind.SpreadAssignment */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(memberDecl, 2 /* ExternalEmitHelpers.Assign */); } if (propertiesArray.length > 0) { spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); @@ -74126,10 +74409,10 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 172 /* GetAccessor */ || memberDecl.kind === 173 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 172 /* SyntaxKind.GetAccessor */ || memberDecl.kind === 173 /* SyntaxKind.SetAccessor */); checkNodeDeferred(memberDecl); } - if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { + if (computedNameType && !(computedNameType.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */)) { if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) { if (isTypeAssignableTo(computedNameType, numberType)) { hasComputedNumberProperty = true; @@ -74154,11 +74437,11 @@ var ts; // type with those properties for which the binding pattern specifies a default value. // If the object literal is spread into another object literal, skip this step and let the top-level object // literal handle it instead. - if (contextualTypeHasPattern && node.parent.kind !== 298 /* SpreadAssignment */) { + if (contextualTypeHasPattern && node.parent.kind !== 298 /* SyntaxKind.SpreadAssignment */) { for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) { var prop = _e[_d]; if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { - if (!(prop.flags & 16777216 /* Optional */)) { + if (!(prop.flags & 16777216 /* SymbolFlags.Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } propertiesTable.set(prop.escapedName, prop); @@ -74190,12 +74473,12 @@ var ts; if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(node, offset, propertiesArray, esSymbolType)); var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, indexInfos); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; if (isJSObjectLiteral) { - result.objectFlags |= 4096 /* JSLiteral */; + result.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; } if (patternWithComputedProperties) { - result.objectFlags |= 512 /* ObjectLiteralPatternWithComputedProperties */; + result.objectFlags |= 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */; } if (inDestructuringPattern) { result.pattern = node; @@ -74205,8 +74488,8 @@ var ts; } function isValidSpreadType(type) { var t = removeDefinitelyFalsyTypes(mapType(type, getBaseConstraintOrType)); - return !!(t.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || - t.flags & 3145728 /* UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); + return !!(t.flags & (1 /* TypeFlags.Any */ | 67108864 /* TypeFlags.NonPrimitive */ | 524288 /* TypeFlags.Object */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + t.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && ts.every(t.types, isValidSpreadType)); } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); @@ -74252,7 +74535,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 79 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 79 /* SyntaxKind.Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -74276,15 +74559,15 @@ var ts; var hasSpreadAnyType = false; var typeToIntersect; var explicitlySpecifyChildrenAttribute = false; - var objectFlags = 2048 /* JsxAttributes */; + var objectFlags = 2048 /* ObjectFlags.JsxAttributes */; var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) { var attributeDecl = _a[_i]; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = checkJsxAttribute(attributeDecl, checkMode); - objectFlags |= ts.getObjectFlags(exprType) & 458752 /* PropagatingFlags */; - var attributeSymbol = createSymbol(4 /* Property */ | member.flags, member.escapedName); + objectFlags |= ts.getObjectFlags(exprType) & 458752 /* ObjectFlags.PropagatingFlags */; + var attributeSymbol = createSymbol(4 /* SymbolFlags.Property */ | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; if (member.valueDeclaration) { @@ -74299,7 +74582,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 287 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 287 /* SyntaxKind.JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -74326,7 +74609,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 278 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 278 /* SyntaxKind.JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -74337,10 +74620,10 @@ var ts; if (explicitlySpecifyChildrenAttribute) { error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName)); } - var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes); + var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes, /*contextFlags*/ undefined); var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName); // If there are children in the body of JSX element, create dummy attribute "children" with the union of children types so that it will pass the attribute checking process - var childrenPropSymbol = createSymbol(4 /* Property */, jsxChildrenPropertyName); + var childrenPropSymbol = createSymbol(4 /* SymbolFlags.Property */, jsxChildrenPropertyName); childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] : childrenContextualType && someType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) : createArrayType(getUnionType(childrenTypes)); @@ -74368,7 +74651,7 @@ var ts; function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); - result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */; + result.objectFlags |= objectFlags | 128 /* ObjectFlags.ObjectLiteral */ | 131072 /* ObjectFlags.ContainsObjectOrArrayLiteral */; return result; } } @@ -74378,12 +74661,12 @@ var ts; var child = _a[_i]; // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that // because then type of children property will have constituent of string type. - if (child.kind === 11 /* JsxText */) { + if (child.kind === 11 /* SyntaxKind.JsxText */) { if (!child.containsOnlyTriviaWhiteSpaces) { childrenTypes.push(stringType); } } - else if (child.kind === 288 /* JsxExpression */ && !child.expression) { + else if (child.kind === 288 /* SyntaxKind.JsxExpression */ && !child.expression) { continue; // empty jsx expressions don't *really* count as present children } else { @@ -74395,7 +74678,7 @@ var ts; function checkSpreadPropOverrides(type, props, spread) { for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { var right = _a[_i]; - if (!(right.flags & 16777216 /* Optional */)) { + if (!(right.flags & 16777216 /* SymbolFlags.Optional */)) { var left = props.get(right.escapedName); if (left) { var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); @@ -74415,7 +74698,7 @@ var ts; function getJsxType(name, location) { var namespace = getJsxNamespaceAt(location); var exports = namespace && getExportsOfSymbol(namespace); - var typeSymbol = exports && getSymbol(exports, name, 788968 /* Type */); + var typeSymbol = exports && getSymbol(exports, name, 788968 /* SymbolFlags.Type */); return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType; } /** @@ -74434,13 +74717,13 @@ var ts; return ts.Debug.fail(); var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText); if (intrinsicProp) { - links.jsxFlags |= 1 /* IntrinsicNamedElement */; + links.jsxFlags |= 1 /* JsxFlags.IntrinsicNamedElement */; return links.resolvedSymbol = intrinsicProp; } // Intrinsic string indexer case var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, stringType); if (indexSignatureType) { - links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + links.jsxFlags |= 2 /* JsxFlags.IntrinsicIndexedElement */; return links.resolvedSymbol = intrinsicElementsType.symbol; } // Wasn't found @@ -74489,10 +74772,10 @@ var ts; var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location); if (!resolvedNamespace || resolvedNamespace === unknownSymbol) { var namespaceName = getJsxNamespace(location); - resolvedNamespace = resolveName(location, namespaceName, 1920 /* Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); + resolvedNamespace = resolveName(location, namespaceName, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false); } if (resolvedNamespace) { - var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* Namespace */)); + var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920 /* SymbolFlags.Namespace */)); if (candidate && candidate !== unknownSymbol) { if (links) { links.jsxNamespace = candidate; @@ -74505,7 +74788,7 @@ var ts; } } // JSX global fallback - var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined)); + var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920 /* SymbolFlags.Namespace */, /*diagnosticMessage*/ undefined)); if (s === unknownSymbol) { return undefined; // TODO: GH#18217 } @@ -74520,7 +74803,7 @@ var ts; */ function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) { // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] - var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* Type */); + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968 /* SymbolFlags.Type */); // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute @@ -74544,7 +74827,7 @@ var ts; } function getJsxLibraryManagedAttributes(jsxNamespace) { // JSX.LibraryManagedAttributes [symbol] - return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* Type */); + return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968 /* SymbolFlags.Type */); } /// e.g. "props" for React.d.ts, /// or 'undefined' if ElementAttributesProperty doesn't exist (which means all @@ -74558,10 +74841,10 @@ var ts; return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace); } function getUninstantiatedJsxSignaturesOfType(elementType, caller) { - if (elementType.flags & 4 /* String */) { + if (elementType.flags & 4 /* TypeFlags.String */) { return [anySignature]; } - else if (elementType.flags & 128 /* StringLiteral */) { + else if (elementType.flags & 128 /* TypeFlags.StringLiteral */) { var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller); if (!intrinsicType) { error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements); @@ -74574,12 +74857,12 @@ var ts; } var apparentElemType = getApparentType(elementType); // Resolve the signatures, preferring constructor - var signatures = getSignaturesOfType(apparentElemType, 1 /* Construct */); + var signatures = getSignaturesOfType(apparentElemType, 1 /* SignatureKind.Construct */); if (signatures.length === 0) { // No construct signatures, try call signatures - signatures = getSignaturesOfType(apparentElemType, 0 /* Call */); + signatures = getSignaturesOfType(apparentElemType, 0 /* SignatureKind.Call */); } - if (signatures.length === 0 && apparentElemType.flags & 1048576 /* Union */) { + if (signatures.length === 0 && apparentElemType.flags & 1048576 /* TypeFlags.Union */) { // If each member has some combination of new/call signatures; make a union signature list for those signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); })); } @@ -74607,13 +74890,13 @@ var ts; return anyType; } function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) { - if (refKind === 1 /* Function */) { + if (refKind === 1 /* JsxReferenceKind.Function */) { var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); if (sfcReturnConstraint) { checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } - else if (refKind === 0 /* Component */) { + else if (refKind === 0 /* JsxReferenceKind.Component */) { var classConstraint = getJsxElementClassTypeAt(openingLikeElement); if (classConstraint) { // Issue an error if this return type isn't assignable to JSX.ElementClass, failing that @@ -74644,10 +74927,10 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var symbol = getIntrinsicTagSymbol(node); - if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + if (links.jsxFlags & 1 /* JsxFlags.IntrinsicNamedElement */) { return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol) || errorType; } - else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + else if (links.jsxFlags & 2 /* JsxFlags.IntrinsicIndexedElement */) { return links.resolvedJsxElementAttributesType = getIndexTypeOfType(getJsxType(JsxNames.IntrinsicElements, node), stringType) || errorType; } @@ -74681,7 +74964,7 @@ var ts; } function checkJsxPreconditions(errorNode) { // Preconditions for using JSX - if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + if ((compilerOptions.jsx || 0 /* JsxEmit.None */) === 0 /* JsxEmit.None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } if (getJsxElementTypeAt(errorNode) === undefined) { @@ -74699,20 +74982,20 @@ var ts; if (!getJsxNamespaceContainerForImplicitImport(node)) { // The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import. // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. - var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; + var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 /* JsxEmit.React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var jsxFactoryNamespace = getJsxNamespace(node); var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node; // allow null as jsxFragmentFactory var jsxFactorySym = void 0; if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) { - jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); + jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true); } if (jsxFactorySym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not jsxFactory as there wont be error being emitted - jsxFactorySym.isReferenced = 67108863 /* All */; + jsxFactorySym.isReferenced = 67108863 /* SymbolFlags.All */; // If react/jsxFactory symbol is alias, mark it as refereced - if (jsxFactorySym.flags & 2097152 /* Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { + if (jsxFactorySym.flags & 2097152 /* SymbolFlags.Alias */ && !getTypeOnlyAliasDeclaration(jsxFactorySym)) { markAliasSymbolAsReferenced(jsxFactorySym); } } @@ -74721,7 +75004,7 @@ var ts; var file = ts.getSourceFileOfNode(node); var localJsxNamespace = getLocalJsxNamespace(file); if (localJsxNamespace) { - resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); + resolveName(jsxFactoryLocation, localJsxNamespace, 111551 /* SymbolFlags.Value */, jsxFactoryRefErr, localJsxNamespace, /*isUse*/ true); } } } @@ -74746,7 +75029,7 @@ var ts; * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType */ function isKnownProperty(targetType, name, isComparingJsxAttributes) { - if (targetType.flags & 524288 /* Object */) { + if (targetType.flags & 524288 /* TypeFlags.Object */) { // For backwards compatibility a symbol-named property is satisfied by a string index signature. This // is incorrect and inconsistent with element access expressions, where it is an error, so eventually // we should remove this exception. @@ -74758,7 +75041,7 @@ var ts; return true; } } - else if (targetType.flags & 3145728 /* UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { + else if (targetType.flags & 3145728 /* TypeFlags.UnionOrIntersection */ && isExcessPropertyCheckTarget(targetType)) { for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) { var t = _a[_i]; if (isKnownProperty(t, name, isComparingJsxAttributes)) { @@ -74769,10 +75052,10 @@ var ts; return false; } function isExcessPropertyCheckTarget(type) { - return !!(type.flags & 524288 /* Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectLiteralPatternWithComputedProperties */) || - type.flags & 67108864 /* NonPrimitive */ || - type.flags & 1048576 /* Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || - type.flags & 2097152 /* Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); + return !!(type.flags & 524288 /* TypeFlags.Object */ && !(ts.getObjectFlags(type) & 512 /* ObjectFlags.ObjectLiteralPatternWithComputedProperties */) || + type.flags & 67108864 /* TypeFlags.NonPrimitive */ || + type.flags & 1048576 /* TypeFlags.Union */ && ts.some(type.types, isExcessPropertyCheckTarget) || + type.flags & 2097152 /* TypeFlags.Intersection */ && ts.every(type.types, isExcessPropertyCheckTarget)); } function checkJsxExpression(node, checkMode) { checkGrammarJsxExpression(node); @@ -74795,13 +75078,13 @@ var ts; * Note that this is not tracked well within the compiler, so the answer may be incorrect. */ function isPrototypeProperty(symbol) { - if (symbol.flags & 8192 /* Method */ || ts.getCheckFlags(symbol) & 4 /* SyntheticMethod */) { + if (symbol.flags & 8192 /* SymbolFlags.Method */ || ts.getCheckFlags(symbol) & 4 /* CheckFlags.SyntheticMethod */) { return true; } if (ts.isInJSFile(symbol.valueDeclaration)) { var parent = symbol.valueDeclaration.parent; return parent && ts.isBinaryExpression(parent) && - ts.getAssignmentDeclarationKind(parent) === 3 /* PrototypeProperty */; + ts.getAssignmentDeclarationKind(parent) === 3 /* AssignmentDeclarationKind.PrototypeProperty */; } } /** @@ -74815,9 +75098,9 @@ var ts; function checkPropertyAccessibility(node, isSuper, writing, type, prop, reportError) { if (reportError === void 0) { reportError = true; } var errorNode = !reportError ? undefined : - node.kind === 161 /* QualifiedName */ ? node.right : - node.kind === 200 /* ImportType */ ? node : - node.kind === 203 /* BindingElement */ && node.propertyName ? node.propertyName : node.name; + node.kind === 161 /* SyntaxKind.QualifiedName */ ? node.right : + node.kind === 200 /* SyntaxKind.ImportType */ ? node : + node.kind === 203 /* SyntaxKind.BindingElement */ && node.propertyName ? node.propertyName : node.name; return checkPropertyAccessibilityAtLocation(node, isSuper, writing, type, prop, errorNode); } /** @@ -74840,7 +75123,7 @@ var ts; // - In a static member function or static member accessor // where this references the constructor function object of a derived class, // a super property access is permitted and must specify a public static member function of the base class. - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { if (symbolHasNonMethodDeclaration(prop)) { if (errorNode) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); @@ -74848,7 +75131,7 @@ var ts; return false; } } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { // A method cannot be accessed in a super property access if the method is abstract. // This error could mask a private property access error. But, a member // cannot simultaneously be private and abstract, so this will trigger an @@ -74860,7 +75143,7 @@ var ts; } } // Referencing abstract properties within their own constructors is not allowed - if ((flags & 128 /* Abstract */) && symbolHasNonMethodDeclaration(prop) && + if ((flags & 128 /* ModifierFlags.Abstract */) && symbolHasNonMethodDeclaration(prop) && (ts.isThisProperty(location) || ts.isThisInitializedObjectBindingExpression(location) || ts.isObjectBindingPattern(location.parent) && ts.isThisInitializedDeclaration(location.parent.parent))) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(location)) { @@ -74871,12 +75154,12 @@ var ts; } } // Public properties are otherwise accessible. - if (!(flags & 24 /* NonPublicAccessibilityModifier */)) { + if (!(flags & 24 /* ModifierFlags.NonPublicAccessibilityModifier */)) { return true; } // Property is known to be private or protected at this point // Private property is accessible if the property is within the declaring class - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop)); if (!isNodeWithinClass(location, declaringClassDeclaration)) { if (errorNode) { @@ -74903,7 +75186,7 @@ var ts; // static member access is disallowed enclosingClass = getEnclosingClassFromThisParameter(location); enclosingClass = enclosingClass && isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing); - if (flags & 32 /* Static */ || !enclosingClass) { + if (flags & 32 /* ModifierFlags.Static */ || !enclosingClass) { if (errorNode) { error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || containingType)); } @@ -74911,10 +75194,10 @@ var ts; } } // No further restrictions for static properties - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return true; } - if (containingType.flags & 262144 /* TypeParameter */) { + if (containingType.flags & 262144 /* TypeFlags.TypeParameter */) { // get the original type -- represented as the type constraint of the 'this' type containingType = containingType.isThisType ? getConstraintOfTypeParameter(containingType) : getBaseConstraintOfType(containingType); // TODO: GH#18217 Use a different variable that's allowed to be undefined } @@ -74929,10 +75212,10 @@ var ts; function getEnclosingClassFromThisParameter(node) { var thisParameter = getThisParameterFromNodeContext(node); var thisType = (thisParameter === null || thisParameter === void 0 ? void 0 : thisParameter.type) && getTypeFromTypeNode(thisParameter.type); - if (thisType && thisType.flags & 262144 /* TypeParameter */) { + if (thisType && thisType.flags & 262144 /* TypeFlags.TypeParameter */) { thisType = getConstraintOfTypeParameter(thisType); } - if (thisType && ts.getObjectFlags(thisType) & (3 /* ClassOrInterface */ | 4 /* Reference */)) { + if (thisType && ts.getObjectFlags(thisType) & (3 /* ObjectFlags.ClassOrInterface */ | 4 /* ObjectFlags.Reference */)) { return getTargetType(thisType); } return undefined; @@ -74942,39 +75225,39 @@ var ts; return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined; } function symbolHasNonMethodDeclaration(symbol) { - return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); + return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* SymbolFlags.Method */); }); } function checkNonNullExpression(node) { return checkNonNullType(checkExpression(node), node); } function isNullableType(type) { - return !!(getTypeFacts(type) & 50331648 /* IsUndefinedOrNull */); + return !!(getTypeFacts(type) & 50331648 /* TypeFacts.IsUndefinedOrNull */); } function getNonNullableTypeIfNeeded(type) { return isNullableType(type) ? getNonNullableType(type) : type; } function reportObjectPossiblyNullOrUndefinedError(node, facts) { - error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? + error(node, facts & 16777216 /* TypeFacts.IsUndefined */ ? facts & 33554432 /* TypeFacts.IsNull */ ? ts.Diagnostics.Object_is_possibly_null_or_undefined : ts.Diagnostics.Object_is_possibly_undefined : ts.Diagnostics.Object_is_possibly_null); } function reportCannotInvokePossiblyNullOrUndefinedError(node, facts) { - error(node, facts & 16777216 /* IsUndefined */ ? facts & 33554432 /* IsNull */ ? + error(node, facts & 16777216 /* TypeFacts.IsUndefined */ ? facts & 33554432 /* TypeFacts.IsNull */ ? ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); } function checkNonNullTypeWithReporter(type, node, reportError) { - if (strictNullChecks && type.flags & 2 /* Unknown */) { + if (strictNullChecks && type.flags & 2 /* TypeFlags.Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } var facts = getTypeFacts(type); - if (facts & 50331648 /* IsUndefinedOrNull */) { + if (facts & 50331648 /* TypeFacts.IsUndefinedOrNull */) { reportError(node, facts); var t = getNonNullableType(type); - return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; + return t.flags & (98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */) ? errorType : t; } return type; } @@ -74983,13 +75266,13 @@ var ts; } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); - if (nonNullType.flags & 16384 /* Void */) { + if (nonNullType.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.Object_is_possibly_undefined); } return nonNullType; } function checkPropertyAccessExpression(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkPropertyAccessChain(node, checkMode) : checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name, checkMode); } function checkPropertyAccessChain(node, checkMode) { @@ -75002,7 +75285,7 @@ var ts; return checkPropertyAccessExpressionOrQualifiedName(node, node.left, leftType, node.right, checkMode); } function isMethodAccessForCall(node) { - while (node.parent.kind === 212 /* ParenthesizedExpression */) { + while (node.parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; @@ -75026,7 +75309,7 @@ var ts; if (!ts.isExpressionNode(privId)) { return grammarErrorOnNode(privId, ts.Diagnostics.Private_identifiers_are_only_allowed_in_class_bodies_and_may_only_be_used_as_part_of_a_class_member_declaration_property_access_or_on_the_left_hand_side_of_an_in_expression); } - var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* InKeyword */; + var isInOperation = ts.isBinaryExpression(privId.parent) && privId.parent.operatorToken.kind === 101 /* SyntaxKind.InKeyword */; if (!getSymbolForPrivateIdentifierExpression(privId) && !isInOperation) { return grammarErrorOnNode(privId, ts.Diagnostics.Cannot_find_name_0, ts.idText(privId)); } @@ -75098,16 +75381,16 @@ var ts; function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right, checkMode) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); - var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); + var apparentType = getApparentType(assignmentKind !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType; var prop; if (ts.isPrivateIdentifier(right)) { - if (languageVersion < 99 /* ESNext */) { - if (assignmentKind !== 0 /* None */) { - checkExternalEmitHelpers(node, 1048576 /* ClassPrivateFieldSet */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + if (assignmentKind !== 0 /* AssignmentKind.None */) { + checkExternalEmitHelpers(node, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } - if (assignmentKind !== 1 /* Definite */) { - checkExternalEmitHelpers(node, 524288 /* ClassPrivateFieldGet */); + if (assignmentKind !== 1 /* AssignmentKind.Definite */) { + checkExternalEmitHelpers(node, 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */); } } var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right); @@ -75129,8 +75412,8 @@ var ts; return errorType; } else { - var isSetonlyAccessor = prop && prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */); - if (isSetonlyAccessor && assignmentKind !== 1 /* Definite */) { + var isSetonlyAccessor = prop && prop.flags & 65536 /* SymbolFlags.SetAccessor */ && !(prop.flags & 32768 /* SymbolFlags.GetAccessor */); + if (isSetonlyAccessor && assignmentKind !== 1 /* AssignmentKind.Definite */) { error(node, ts.Diagnostics.Private_accessor_was_defined_without_a_getter); } } @@ -75142,7 +75425,7 @@ var ts; } return isErrorType(apparentType) ? errorType : apparentType; } - prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === 161 /* QualifiedName */); + prop = getPropertyOfType(apparentType, right.escapedText, /*skipObjectFunctionPropertyAugment*/ false, /*includeTypeOnlyMembers*/ node.kind === 161 /* SyntaxKind.QualifiedName */); } // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums. // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined @@ -75152,13 +75435,13 @@ var ts; // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`. if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || - !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && node.parent.kind === 299 /* EnumMember */)) || + !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* SymbolFlags.EnumMember */ && node.parent.kind === 299 /* SyntaxKind.EnumMember */)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) { markAliasReferenced(parentSymbol, node); } var propType; if (!prop) { - var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? + var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 /* AssignmentKind.None */ || !isGenericObjectType(leftType) || ts.isThisTypeParameter(leftType)) ? getApplicableIndexInfoForName(apparentType, right.escapedText) : undefined; if (!(indexInfo && indexInfo.type)) { var isUncheckedJS = isUncheckedJSSuggestion(node, leftType.symbol, /*excludeClasses*/ true); @@ -75166,7 +75449,7 @@ var ts; return anyType; } if (leftType.symbol === globalThisSymbol) { - if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* BlockScoped */)) { + if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418 /* SymbolFlags.BlockScoped */)) { error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType)); } else if (noImplicitAny) { @@ -75186,7 +75469,7 @@ var ts; if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) { error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText)); } - if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) { + if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* NodeFlags.Deprecated */) { addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText); } } @@ -75198,7 +75481,7 @@ var ts; markPropertyAsReferenced(prop, node, isSelfTypeAccess(left, parentSymbol)); getNodeLinks(node).resolvedSymbol = prop; var writing = ts.isWriteAccess(node); - checkPropertyAccessibility(node, left.kind === 106 /* SuperKeyword */, writing, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 106 /* SyntaxKind.SuperKeyword */, writing, apparentType, prop); if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); return errorType; @@ -75217,11 +75500,11 @@ var ts; function isUncheckedJSSuggestion(node, suggestion, excludeClasses) { var file = ts.getSourceFileOfNode(node); if (file) { - if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* JS */ || file.scriptKind === 2 /* JSX */)) { + if (compilerOptions.checkJs === undefined && file.checkJsDirective === undefined && (file.scriptKind === 1 /* ScriptKind.JS */ || file.scriptKind === 2 /* ScriptKind.JSX */)) { var declarationFile = ts.forEach(suggestion === null || suggestion === void 0 ? void 0 : suggestion.declarations, ts.getSourceFileOfNode); return !(file !== declarationFile && !!declarationFile && isGlobalSourceFile(declarationFile)) - && !(excludeClasses && suggestion && suggestion.flags & 32 /* Class */) - && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */); + && !(excludeClasses && suggestion && suggestion.flags & 32 /* SymbolFlags.Class */) + && !(!!node && excludeClasses && ts.isPropertyAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */); } } return false; @@ -75231,12 +75514,12 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (assignmentKind === 1 /* Definite */) { - return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* Optional */)); + if (assignmentKind === 1 /* AssignmentKind.Definite */) { + return removeMissingType(propType, !!(prop && prop.flags & 16777216 /* SymbolFlags.Optional */)); } if (prop && - !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) - && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */) + !(prop.flags & (3 /* SymbolFlags.Variable */ | 4 /* SymbolFlags.Property */ | 98304 /* SymbolFlags.Accessor */)) + && !(prop.flags & 8192 /* SymbolFlags.Method */ && propType.flags & 1048576 /* TypeFlags.Union */) && !isDuplicatedCommonJSExport(prop.declarations)) { return propType; } @@ -75249,12 +75532,12 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isPropertyWithoutInitializer(declaration)) { if (!ts.isStatic(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) { + if (flowContainer.kind === 171 /* SyntaxKind.Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { assumeUninitialized = true; } } @@ -75285,13 +75568,13 @@ var ts; && !isOptionalPropertyDeclaration(valueDeclaration) && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* Static */) + && !(ts.isMethodDeclaration(valueDeclaration) && ts.getCombinedModifierFlags(valueDeclaration) & 32 /* ModifierFlags.Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 257 /* ClassDeclaration */ && - node.parent.kind !== 178 /* TypeReference */ && - !(valueDeclaration.flags & 16777216 /* Ambient */) && + else if (valueDeclaration.kind === 257 /* SyntaxKind.ClassDeclaration */ && + node.parent.kind !== 178 /* SyntaxKind.TypeReference */ && + !(valueDeclaration.flags & 16777216 /* NodeFlags.Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -75302,25 +75585,25 @@ var ts; function isInPropertyInitializerOrClassStaticBlock(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return true; - case 296 /* PropertyAssignment */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 298 /* SpreadAssignment */: - case 162 /* ComputedPropertyName */: - case 233 /* TemplateSpan */: - case 288 /* JsxExpression */: - case 285 /* JsxAttribute */: - case 286 /* JsxAttributes */: - case 287 /* JsxSpreadAttribute */: - case 280 /* JsxOpeningElement */: - case 228 /* ExpressionWithTypeArguments */: - case 291 /* HeritageClause */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 298 /* SyntaxKind.SpreadAssignment */: + case 162 /* SyntaxKind.ComputedPropertyName */: + case 233 /* SyntaxKind.TemplateSpan */: + case 288 /* SyntaxKind.JsxExpression */: + case 285 /* SyntaxKind.JsxAttribute */: + case 286 /* SyntaxKind.JsxAttributes */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 291 /* SyntaxKind.HeritageClause */: return false; - case 214 /* ArrowFunction */: - case 238 /* ExpressionStatement */: + case 214 /* SyntaxKind.ArrowFunction */: + case 238 /* SyntaxKind.ExpressionStatement */: return ts.isBlock(node.parent) && ts.isClassStaticBlockDeclaration(node.parent.parent) ? true : "quit"; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -75332,7 +75615,7 @@ var ts; * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. */ function isPropertyDeclaredInAncestorClass(prop) { - if (!(prop.parent.flags & 32 /* Class */)) { + if (!(prop.parent.flags & 32 /* SymbolFlags.Class */)) { return false; } var classType = getTypeOfSymbol(prop.parent); @@ -75357,7 +75640,7 @@ var ts; function reportNonexistentProperty(propNode, containingType, isUncheckedJS) { var errorInfo; var relatedInfo; - if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { + if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 /* TypeFlags.Union */ && !(containingType.flags & 131068 /* TypeFlags.Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; if (!getPropertyOfType(subtype, propNode.escapedText) && !getApplicableIndexInfoForName(subtype, propNode.escapedText)) { @@ -75445,7 +75728,7 @@ var ts; } } function getSuggestedSymbolForNonexistentClassMember(name, baseType) { - return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* ClassMember */); + return getSpellingSuggestionForName(name, getPropertiesOfType(baseType), 106500 /* SymbolFlags.ClassMember */); } function getSuggestedSymbolForNonexistentProperty(name, containingType) { var props = getPropertiesOfType(containingType); @@ -75456,7 +75739,7 @@ var ts; } name = ts.idText(name); } - return getSpellingSuggestionForName(name, props, 111551 /* Value */); + return getSpellingSuggestionForName(name, props, 111551 /* SymbolFlags.Value */); } function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) { var strName = ts.isString(name) ? name : ts.idText(name); @@ -75464,7 +75747,7 @@ var ts; var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; }) : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; }) : undefined; - return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* Value */); + return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551 /* SymbolFlags.Value */); } function getSuggestionForNonexistentProperty(name, containingType) { var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType); @@ -75483,7 +75766,7 @@ var ts; var candidates; if (symbols === globals) { var primitives = ts.mapDefined(["string", "number", "boolean", "object", "bigint", "symbol"], function (s) { return symbols.has((s.charAt(0).toUpperCase() + s.slice(1))) - ? createSymbol(524288 /* TypeAlias */, s) + ? createSymbol(524288 /* SymbolFlags.TypeAlias */, s) : undefined; }); candidates = primitives.concat(ts.arrayFrom(symbols.values())); } @@ -75499,7 +75782,7 @@ var ts; return symbolResult && ts.symbolName(symbolResult); } function getSuggestedSymbolForNonexistentModule(name, targetModule) { - return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* ModuleMember */); + return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475 /* SymbolFlags.ModuleMember */); } function getSuggestionForNonexistentExport(name, targetModule) { var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule); @@ -75530,7 +75813,7 @@ var ts; return suggestion; } function getSuggestedTypeForNonexistentStringLiteralType(source, target) { - var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* StringLiteral */); }); + var candidates = target.types.filter(function (type) { return !!(type.flags & 128 /* TypeFlags.StringLiteral */); }); return ts.getSpellingSuggestion(source.value, candidates, function (type) { return type.value; }); } /** @@ -75558,7 +75841,7 @@ var ts; if (candidate.flags & meaning) { return candidateName; } - if (candidate.flags & 2097152 /* Alias */) { + if (candidate.flags & 2097152 /* SymbolFlags.Alias */) { var alias = tryResolveAlias(candidate); if (alias && alias.flags & meaning) { return candidateName; @@ -75568,16 +75851,16 @@ var ts; } } function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isSelfTypeAccess) { - var valueDeclaration = prop && (prop.flags & 106500 /* ClassMember */) && prop.valueDeclaration; + var valueDeclaration = prop && (prop.flags & 106500 /* SymbolFlags.ClassMember */) && prop.valueDeclaration; if (!valueDeclaration) { return; } - var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* Private */); + var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8 /* ModifierFlags.Private */); var hasPrivateIdentifier = prop.valueDeclaration && ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name); if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } - if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { + if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SymbolFlags.SetAccessor */)) { return; } if (isSelfTypeAccess) { @@ -75587,19 +75870,19 @@ var ts; return; } } - (ts.getCheckFlags(prop) & 1 /* Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* All */; + (ts.getCheckFlags(prop) & 1 /* CheckFlags.Instantiated */ ? getSymbolLinks(prop).target : prop).isReferenced = 67108863 /* SymbolFlags.All */; } function isSelfTypeAccess(name, parent) { - return name.kind === 108 /* ThisKeyword */ + return name.kind === 108 /* SyntaxKind.ThisKeyword */ || !!parent && ts.isEntityNameExpression(name) && parent === getResolvedSymbol(ts.getFirstIdentifier(name)); } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 161 /* QualifiedName */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 161 /* SyntaxKind.QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } @@ -75614,7 +75897,7 @@ var ts; * @param property the accessed property's symbol. */ function isValidPropertyAccessForCompletions(node, type, property) { - return isPropertyAccessible(node, node.kind === 206 /* PropertyAccessExpression */ && node.expression.kind === 106 /* SuperKeyword */, + return isPropertyAccessible(node, node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */, /* isWrite */ false, type, property); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } @@ -75654,13 +75937,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 79 /* Identifier */) { + else if (initializer.kind === 79 /* SyntaxKind.Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -75677,13 +75960,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 79 /* Identifier */) { + if (e.kind === 79 /* SyntaxKind.Identifier */) { var symbol = getResolvedSymbol(e); - if (symbol.flags & 3 /* Variable */) { + if (symbol.flags & 3 /* SymbolFlags.Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 243 /* ForInStatement */ && + if (node.kind === 243 /* SyntaxKind.ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -75697,7 +75980,7 @@ var ts; return false; } function checkIndexedAccess(node, checkMode) { - return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node, checkMode) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkElementAccessChain(node, checkMode) : checkElementAccessExpression(node, checkNonNullExpression(node.expression), checkMode); } function checkElementAccessChain(node, checkMode) { @@ -75706,7 +75989,7 @@ var ts; return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression), checkMode), node, nonOptionalType !== exprType); } function checkElementAccessExpression(node, exprType, checkMode) { - var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; + var objectType = ts.getAssignmentTargetKind(node) !== 0 /* AssignmentKind.None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; var indexType = checkExpression(indexExpression); if (isErrorType(objectType) || objectType === silentNeverType) { @@ -75718,8 +76001,8 @@ var ts; } var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType; var accessFlags = ts.isAssignmentTarget(node) ? - 4 /* Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* NoIndexSignatures */ : 0) : - 32 /* ExpressionPosition */; + 4 /* AccessFlags.Writing */ | (isGenericObjectType(objectType) && !ts.isThisTypeParameter(objectType) ? 2 /* AccessFlags.NoIndexSignatures */ : 0) : + 32 /* AccessFlags.ExpressionPosition */; var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, accessFlags, node) || errorType; return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, getNodeLinks(node).resolvedSymbol, indexedAccessType, indexExpression, checkMode), node); } @@ -75732,13 +76015,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 165 /* Decorator */) { + else if (node.kind !== 165 /* SyntaxKind.Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -75802,16 +76085,16 @@ var ts; } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 225 /* SpreadElement */ || arg.kind === 232 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); } function acceptsVoid(t) { - return !!(t.flags & 16384 /* Void */); + return !!(t.flags & 16384 /* TypeFlags.Void */); } function acceptsVoidUndefinedUnknownOrAny(t) { - return !!(t.flags & (16384 /* Void */ | 32768 /* Undefined */ | 2 /* Unknown */ | 1 /* Any */)); + return !!(t.flags & (16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 2 /* TypeFlags.Unknown */ | 1 /* TypeFlags.Any */)); } function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } @@ -75819,9 +76102,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 223 /* TemplateExpression */) { + if (node.template.kind === 223 /* SyntaxKind.TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -75832,11 +76115,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = node.template; - ts.Debug.assert(templateLiteral.kind === 14 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 165 /* Decorator */) { + else if (node.kind === 165 /* SyntaxKind.Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -75850,7 +76133,7 @@ var ts; } else if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 209 /* NewExpression */); + ts.Debug.assert(node.kind === 209 /* SyntaxKind.NewExpression */); return getMinArgumentCount(signature) === 0; } else { @@ -75874,7 +76157,7 @@ var ts; } for (var i = argCount; i < effectiveMinimumArguments; i++) { var type = getTypeAtPosition(signature, i); - if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072 /* TypeFlags.Never */) { return false; } } @@ -75890,20 +76173,20 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false); } function getSingleCallOrConstructSignature(type) { - return getSingleSignature(type, 0 /* Call */, /*allowMembers*/ false) || - getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ false); + return getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ false) || + getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ false); } function getSingleSignature(type, kind, allowMembers) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); if (allowMembers || resolved.properties.length === 0 && resolved.indexInfos.length === 0) { - if (kind === 0 /* Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { + if (kind === 0 /* SignatureKind.Call */ && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) { return resolved.callSignatures[0]; } - if (kind === 1 /* Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { + if (kind === 1 /* SignatureKind.Construct */ && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) { return resolved.constructSignatures[0]; } } @@ -75912,12 +76195,12 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) { - var context = createInferenceContext(signature.typeParameters, signature, 0 /* None */, compareTypes); + var context = createInferenceContext(signature.typeParameters, signature, 0 /* InferenceFlags.None */, compareTypes); // We clone the inferenceContext to avoid fixing. For example, when the source signature is (x: T) => T[] and // the contextual signature is (...args: A) => B, we want to infer the element type of A's constraint (say 'any') // for T but leave it possible to later infer '[any]' back to A. var restType = getEffectiveRestType(contextualSignature); - var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); + var mapper = inferenceContext && (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */ ? inferenceContext.nonFixingMapper : inferenceContext.mapper); var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature; applyToParameterTypes(sourceSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type @@ -75925,7 +76208,7 @@ var ts; }); if (!inferenceContext) { applyToReturnTypes(contextualSignature, signature, function (source, target) { - inferTypes(context.inferences, source, target, 128 /* ReturnType */); + inferTypes(context.inferences, source, target, 128 /* InferencePriority.ReturnType */); }); } return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration)); @@ -75953,14 +76236,14 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 165 /* Decorator */) { + if (node.kind !== 165 /* SyntaxKind.Decorator */) { var skipBindingPatterns = ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }); - var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* SkipBindingPatterns */ : 0 /* None */); + var contextualType = getContextualType(node, skipBindingPatterns ? 8 /* ContextFlags.SkipBindingPatterns */ : 0 /* ContextFlags.None */); if (contextualType) { var inferenceTargetType = getReturnTypeOfSignature(signature); if (couldContainTypeVariables(inferenceTargetType)) { var outerContext = getInferenceContext(node); - var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* SkipBindingPatterns */) !== contextualType; + var isFromBindingPattern = !skipBindingPatterns && getContextualType(node, 8 /* ContextFlags.SkipBindingPatterns */) !== contextualType; // A return type inference from a binding pattern can be used in instantiating the contextual // type of an argument later in inference, but cannot stand on its own as the final return type. // It is incorporated into `context.returnMapper` which is used in `instantiateContextualType`, @@ -75975,7 +76258,7 @@ var ts; // We clone the inference context to avoid disturbing a resolution in progress for an // outer call expression. Effectively we just want a snapshot of whatever has been // inferred for any outer call expression so far. - var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */)); + var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* InferenceFlags.NoDefault */)); var instantiatedType = instantiateType(contextualType, outerMapper); // If the contextual type is a generic function type with a single call signature, we // instantiate the type with its own type parameters and type arguments. This ensures that @@ -75989,7 +76272,7 @@ var ts; getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) : instantiatedType; // Inferences made from return types have lower priority than all other inferences. - inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */); + inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* InferencePriority.ReturnType */); } // Create a type mapper for instantiating generic contextual types using the inferences made // from the return type. We need a separate inference pass here because (a) instantiation of @@ -76004,7 +76287,7 @@ var ts; } var restType = getNonArrayRestType(signature); var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; - if (restType && restType.flags & 262144 /* TypeParameter */) { + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; }); if (info) { info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined; @@ -76017,7 +76300,7 @@ var ts; } for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */ && !(checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) { var paramType = getTypeAtPosition(signature, i); if (couldContainTypeVariables(paramType)) { var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); @@ -76032,10 +76315,10 @@ var ts; return getInferredTypes(context); } function getMutableArrayOrTupleType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, getMutableArrayOrTupleType) : - type.flags & 1 /* Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, getMutableArrayOrTupleType) : + type.flags & 1 /* TypeFlags.Any */ || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type : isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, /*readonly*/ false, type.target.labeledElementDeclarations) : - createTupleType([type], [8 /* Variadic */]); + createTupleType([type], [8 /* ElementFlags.Variadic */]); } function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) { if (index >= argCount - 1) { @@ -76043,7 +76326,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return getMutableArrayOrTupleType(arg.kind === 232 /* SyntheticExpression */ ? arg.type : + return getMutableArrayOrTupleType(arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpressionWithContextualType(arg.expression, restType, context, checkMode)); } } @@ -76053,24 +76336,24 @@ var ts; for (var i = index; i < argCount; i++) { var arg = args[i]; if (isSpreadArgument(arg)) { - var spreadType = arg.kind === 232 /* SyntheticExpression */ ? arg.type : checkExpression(arg.expression); + var spreadType = arg.kind === 232 /* SyntaxKind.SyntheticExpression */ ? arg.type : checkExpression(arg.expression); if (isArrayLikeType(spreadType)) { types.push(spreadType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } else { - types.push(checkIteratedTypeOrElementType(33 /* Spread */, spreadType, undefinedType, arg.kind === 225 /* SpreadElement */ ? arg.expression : arg)); - flags.push(4 /* Rest */); + types.push(checkIteratedTypeOrElementType(33 /* IterationUse.Spread */, spreadType, undefinedType, arg.kind === 225 /* SyntaxKind.SpreadElement */ ? arg.expression : arg)); + flags.push(4 /* ElementFlags.Rest */); } } else { - var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* Contextual */); + var contextualType = getIndexedAccessType(restType, getNumberLiteralType(i - index), 256 /* AccessFlags.Contextual */); var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode); - var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* Primitive */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */); + var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 /* TypeFlags.Primitive */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */); types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType)); - flags.push(1 /* Required */); + flags.push(1 /* ElementFlags.Required */); } - if (arg.kind === 232 /* SyntheticExpression */ && arg.tupleNameSource) { + if (arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.tupleNameSource) { names.push(arg.tupleNameSource); } } @@ -76100,16 +76383,16 @@ var ts; } function getJsxReferenceKind(node) { if (isJsxIntrinsicIdentifier(node.tagName)) { - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } var tagType = getApparentType(checkExpression(node.tagName)); - if (ts.length(getSignaturesOfType(tagType, 1 /* Construct */))) { - return 0 /* Component */; + if (ts.length(getSignaturesOfType(tagType, 1 /* SignatureKind.Construct */))) { + return 0 /* JsxReferenceKind.Component */; } - if (ts.length(getSignaturesOfType(tagType, 0 /* Call */))) { - return 1 /* Function */; + if (ts.length(getSignaturesOfType(tagType, 0 /* SignatureKind.Call */))) { + return 1 /* JsxReferenceKind.Function */; } - return 2 /* Mixed */; + return 2 /* JsxReferenceKind.Mixed */; } /** * Check if the given signature can possibly be a signature called by the JSX opening-like element. @@ -76134,7 +76417,7 @@ var ts; if (!tagType) { return true; } - var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */); + var tagCallSignatures = getSignaturesOfType(tagType, 0 /* SignatureKind.Call */); if (!ts.length(tagCallSignatures)) { return true; } @@ -76142,12 +76425,12 @@ var ts; if (!factory) { return true; } - var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); + var factorySymbol = resolveEntityName(factory, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); if (!factorySymbol) { return true; } var factoryType = getTypeOfSymbol(factorySymbol); - var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */); + var callSignatures = getSignaturesOfType(factoryType, 0 /* SignatureKind.Call */); if (!ts.length(callSignatures)) { return true; } @@ -76157,7 +76440,7 @@ var ts; for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) { var sig = callSignatures_1[_i]; var firstparam = getTypeAtPosition(sig, 0); - var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */); + var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* SignatureKind.Call */); if (!ts.length(signaturesOfParam)) continue; for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) { @@ -76214,7 +76497,7 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 209 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 209 /* SyntaxKind.NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -76232,13 +76515,13 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 227 /* OmittedExpression */) { + if (arg.kind !== 227 /* SyntaxKind.OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), // we obtain the regular type of any object literal arguments because we may not have inferred complete // parameter types yet and therefore excess property checks may yield false positives (see #17041). - var checkArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; + var checkArgType = checkMode & 4 /* CheckMode.SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType; if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) { ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors"); maybeAddMissingAwaitInfo(arg, checkArgType, paramType); @@ -76277,8 +76560,8 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - var expression = node.kind === 208 /* CallExpression */ ? node.expression : - node.kind === 210 /* TaggedTemplateExpression */ ? node.tag : undefined; + var expression = node.kind === 208 /* SyntaxKind.CallExpression */ ? node.expression : + node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */ ? node.tag : undefined; if (expression) { var callee = ts.skipOuterExpressions(expression); if (ts.isAccessExpression(callee)) { @@ -76296,17 +76579,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 210 /* TaggedTemplateExpression */) { + if (node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 223 /* TemplateExpression */) { + if (template.kind === 223 /* SyntaxKind.TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 165 /* Decorator */) { + if (node.kind === 165 /* SyntaxKind.Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -76317,15 +76600,15 @@ var ts; if (spreadIndex >= 0) { // Create synthetic arguments from spreads of tuple types. var effectiveArgs_1 = args.slice(0, spreadIndex); - var _loop_25 = function (i) { + var _loop_26 = function (i) { var arg = args[i]; // We can call checkExpressionCached because spread expressions never have a contextual type. - var spreadType = arg.kind === 225 /* SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); + var spreadType = arg.kind === 225 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression)); if (spreadType && isTupleType(spreadType)) { ts.forEach(getTypeArguments(spreadType), function (t, i) { var _a; var flags = spreadType.target.elementFlags[i]; - var syntheticArg = createSyntheticExpression(arg, flags & 4 /* Rest */ ? createArrayType(t) : t, !!(flags & 12 /* Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); + var syntheticArg = createSyntheticExpression(arg, flags & 4 /* ElementFlags.Rest */ ? createArrayType(t) : t, !!(flags & 12 /* ElementFlags.Variable */), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]); effectiveArgs_1.push(syntheticArg); }); } @@ -76334,7 +76617,7 @@ var ts; } }; for (var i = spreadIndex; i < args.length; i++) { - _loop_25(i); + _loop_26(i); } return effectiveArgs_1; } @@ -76347,30 +76630,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 171 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 171 /* SyntaxKind.Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 167 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && languageVersion !== 0 /* ScriptTarget.ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -76384,17 +76667,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return 1; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return 2; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments - return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 164 /* Parameter */: + return languageVersion === 0 /* ScriptTarget.ES3 */ || signature.parameters.length <= 2 ? 2 : 3; + case 164 /* SyntaxKind.Parameter */: return 3; default: return ts.Debug.fail(); @@ -76428,7 +76711,7 @@ var ts; function isPromiseResolveArityError(node) { if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression)) return false; - var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, undefined, undefined, false); + var symbol = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, undefined, undefined, false); var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration; if (!decl || !ts.isParameter(decl) || !ts.isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) { return false; @@ -76536,15 +76819,15 @@ var ts; return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) { - var isTaggedTemplate = node.kind === 210 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 165 /* Decorator */; + var isTaggedTemplate = node.kind === 210 /* SyntaxKind.TaggedTemplateExpression */; + var isDecorator = node.kind === 165 /* SyntaxKind.Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; - if (!isDecorator) { + if (!isDecorator && !ts.isSuperCall(node)) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 106 /* SyntaxKind.SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -76571,8 +76854,8 @@ var ts; // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters; - var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */; - argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */; + var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* CheckMode.SkipContextSensitive */ : 0 /* CheckMode.Normal */; + argCheckMode |= checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; // The following variables are captured and modified by calls to chooseOverload. // If overload resolution or type argument inference fails, we want to report the // best error possible. The best error is one which says that an argument was not @@ -76600,7 +76883,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 208 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* CheckMode.IsForSignatureHelp */) && node.kind === 208 /* SyntaxKind.CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -76620,6 +76903,15 @@ var ts; if (result) { return result; } + result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + // Preemptively cache the result; getResolvedSignature will do this after we return, but + // we need to ensure that the result is present for the error checks below so that if + // this signature is encountered again, we handle the circularity (rather than producing a + // different result which may produce no errors and assert). Callers of getResolvedSignature + // don't hit this issue because they only observe this result after it's had a chance to + // be cached, but the error reporting code below executes before getResolvedSignature sets + // resolvedSignature. + getNodeLinks(node).resolvedSignature = result; // No signatures were applicable. Now report errors based on the last applicable signature with // no arguments excluded from assignability checks. // If candidate is undefined, it means that no candidates had a suitable arity. In that case, @@ -76633,7 +76925,7 @@ var ts; chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error); chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call); } - var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, function () { return chain_1; }); + var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, function () { return chain_1; }); if (diags) { for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) { var d = diags_1[_i]; @@ -76654,9 +76946,9 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_26 = function (c) { + var _loop_27 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; - var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); + var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { if (diags_2.length <= min_3) { min_3 = diags_2.length; @@ -76672,7 +76964,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_26(c); + _loop_27(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -76711,7 +77003,7 @@ var ts; } } } - return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode); + return result; function addImplementationSuccessElaboration(failed, diagnostic) { var _a, _b; var oldCandidatesForArgumentError = candidatesForArgumentError; @@ -76741,7 +77033,7 @@ var ts; if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) { return undefined; } - if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { + if (getSignatureApplicabilityError(node, args, candidate, relation, 0 /* CheckMode.Normal */, /*reportErrors*/ false, /*containingMessageChain*/ undefined)) { candidatesForArgumentError = [candidate]; return undefined; } @@ -76764,9 +77056,9 @@ var ts; } } else { - inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext); - argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */; + inferenceContext = createInferenceContext(candidate.typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); + argCheckMode |= inferenceContext.flags & 4 /* InferenceFlags.SkippedGenericFunction */ ? 8 /* CheckMode.SkipGenericFunctions */ : 0 /* CheckMode.Normal */; } checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a @@ -76788,10 +77080,10 @@ var ts; // If one or more context sensitive arguments were excluded, we start including // them now (and keeping do so for any subsequent candidates) and perform a second // round of type inference and applicability checking for this particular candidate. - argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */; + argCheckMode = checkMode & 32 /* CheckMode.IsForStringLiteralArgumentCompletions */; if (inferenceContext) { var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext); - checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters); + checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters); // If the original signature has a generic rest type, instantiation may produce a // signature with different arity and we need to perform another arity check. if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) { @@ -76830,7 +77122,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_27 = function (i) { + var _loop_28 = function (i) { var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : i < s.parameters.length ? s.parameters[i] : undefined; }); @@ -76838,17 +77130,17 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_27(i); + _loop_28(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); - var flags = 0 /* None */; + var flags = 0 /* SignatureFlags.None */; if (restParameterSymbols.length !== 0) { - var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); + var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* UnionReduction.Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); - flags |= 1 /* HasRestParameter */; + flags |= 1 /* SignatureFlags.HasRestParameter */; } if (candidates.some(signatureHasLiteralTypes)) { - flags |= 2 /* HasLiteralTypes */; + flags |= 2 /* SignatureFlags.HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. @@ -76861,7 +77153,7 @@ var ts; return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { - return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); + return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* UnionReduction.Subtype */)); } function createCombinedSymbolForOverloadFailure(sources, type) { // This function is currently only used for erroneous overloads, so it's good enough to just use the first source. @@ -76898,8 +77190,8 @@ var ts; return typeArguments; } function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args, checkMode) { - var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */); - var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* SkipContextSensitive */ | 8 /* SkipGenericFunctions */, inferenceContext); + var inferenceContext = createInferenceContext(typeParameters, candidate, /*flags*/ ts.isInJSFile(node) ? 2 /* InferenceFlags.AnyDefault */ : 0 /* InferenceFlags.None */); + var typeArgumentTypes = inferTypeArguments(node, candidate, args, checkMode | 4 /* CheckMode.SkipContextSensitive */ | 8 /* CheckMode.SkipGenericFunctions */, inferenceContext); return createSignatureInstantiation(candidate, typeArgumentTypes); } function getLongestCandidateIndex(candidates, argsCount) { @@ -76919,7 +77211,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -76934,7 +77226,7 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } } return resolveUntypedCall(node); @@ -76943,13 +77235,13 @@ var ts; var funcType = checkExpression(node.expression); if (ts.isCallChain(node)) { var nonOptionalType = getOptionalExpressionType(funcType, node.expression); - callChainFlags = nonOptionalType === funcType ? 0 /* None */ : - ts.isOutermostOptionalChain(node) ? 16 /* IsOuterCallChain */ : - 8 /* IsInnerCallChain */; + callChainFlags = nonOptionalType === funcType ? 0 /* SignatureFlags.None */ : + ts.isOutermostOptionalChain(node) ? 16 /* SignatureFlags.IsOuterCallChain */ : + 8 /* SignatureFlags.IsInnerCallChain */; funcType = nonOptionalType; } else { - callChainFlags = 0 /* None */; + callChainFlags = 0 /* SignatureFlags.None */; } funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { @@ -76964,8 +77256,8 @@ var ts; // but we are not including call signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; // TS 1.0 Spec: 4.12 // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. @@ -76992,7 +77284,7 @@ var ts; relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon); } } - invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation); + invocationError(node.expression, apparentType, 0 /* SignatureKind.Call */, relatedInformation); } return resolveErrorCall(node); } @@ -77006,9 +77298,9 @@ var ts; // returns a function type, we choose to defer processing. This narrowly permits function composition // operators to flow inferences through return types, but otherwise processes calls right away. We // use the resolvingSignature singleton to indicate that we deferred processing. This result will be - // propagated out and eventually turned into nonInferrableType (a type that is assignable to anything and + // propagated out and eventually turned into silentNeverType (a type that is assignable to anything and // from which we never make inferences). - if (checkMode & 8 /* SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */ && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) { skippedGenericFunction(node, checkMode); return resolvingSignature; } @@ -77029,11 +77321,11 @@ var ts; */ function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) { // We exclude union types because we may have a union of function types that happen to have no common signatures. - return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeParameter */) || - !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* Never */) && isTypeAssignableTo(funcType, globalFunctionType); + return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144 /* TypeFlags.TypeParameter */) || + !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & 1048576 /* TypeFlags.Union */) && !(getReducedType(apparentFuncType).flags & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(funcType, globalFunctionType); } function resolveNewExpression(node, candidatesOutArray, checkMode) { - if (node.arguments && languageVersion < 1 /* ES5 */) { + if (node.arguments && languageVersion < 1 /* ScriptTarget.ES5 */) { var spreadIndex = getSpreadArgumentIndex(node.arguments); if (spreadIndex >= 0) { error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher); @@ -77066,7 +77358,7 @@ var ts; // but we are not including construct signatures that may have been added to the Object or // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. - var constructSignatures = getSignaturesOfType(expressionType, 1 /* Construct */); + var constructSignatures = getSignaturesOfType(expressionType, 1 /* SignatureKind.Construct */); if (constructSignatures.length) { if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); @@ -77075,24 +77367,24 @@ var ts; // then it cannot be instantiated. // In the case of a merged class-module or class-interface declaration, // only the class declaration node will have the Abstract flag set. - if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* Abstract */); })) { + if (someSignature(constructSignatures, function (signature) { return !!(signature.flags & 4 /* SignatureFlags.Abstract */); })) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* Abstract */)) { + if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128 /* ModifierFlags.Abstract */)) { error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. It is an error to have a Void this type. - var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); + var callSignatures = getSignaturesOfType(expressionType, 0 /* SignatureKind.Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -77103,14 +77395,14 @@ var ts; } return signature; } - invocationError(node.expression, expressionType, 1 /* Construct */); + invocationError(node.expression, expressionType, 1 /* SignatureKind.Construct */); return resolveErrorCall(node); } function someSignature(signatures, f) { if (ts.isArray(signatures)) { return ts.some(signatures, function (signature) { return someSignature(signature, f); }); } - return signatures.compositeKind === 1048576 /* Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); + return signatures.compositeKind === 1048576 /* TypeFlags.Union */ ? ts.some(signatures.compositeSignatures, f) : f(signatures); } function typeHasProtectedAccessibleBase(target, type) { var baseTypes = getBaseTypes(type); @@ -77118,7 +77410,7 @@ var ts; return false; } var firstBase = baseTypes[0]; - if (firstBase.flags & 2097152 /* Intersection */) { + if (firstBase.flags & 2097152 /* TypeFlags.Intersection */) { var types = firstBase.types; var mixinFlags = findMixins(types); var i = 0; @@ -77126,7 +77418,7 @@ var ts; var intersectionMember = _a[_i]; // We want to ignore mixin ctors if (!mixinFlags[i]) { - if (ts.getObjectFlags(intersectionMember) & (1 /* Class */ | 2 /* Interface */)) { + if (ts.getObjectFlags(intersectionMember) & (1 /* ObjectFlags.Class */ | 2 /* ObjectFlags.Interface */)) { if (intersectionMember.symbol === target) { return true; } @@ -77149,9 +77441,9 @@ var ts; return true; } var declaration = signature.declaration; - var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* NonPublicAccessibilityModifier */); + var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24 /* ModifierFlags.NonPublicAccessibilityModifier */); // (1) Public constructors and (2) constructor functions are always accessible. - if (!modifiers || declaration.kind !== 171 /* Constructor */) { + if (!modifiers || declaration.kind !== 171 /* SyntaxKind.Constructor */) { return true; } var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol); @@ -77159,16 +77451,16 @@ var ts; // A private or protected constructor can only be instantiated within its own class (or a subclass, for protected) if (!isNodeWithinClass(node, declaringClassDeclaration)) { var containingClass = ts.getContainingClass(node); - if (containingClass && modifiers & 16 /* Protected */) { + if (containingClass && modifiers & 16 /* ModifierFlags.Protected */) { var containingType = getTypeOfNode(containingClass); if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) { return true; } } - if (modifiers & 8 /* Private */) { + if (modifiers & 8 /* ModifierFlags.Private */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } - if (modifiers & 16 /* Protected */) { + if (modifiers & 16 /* ModifierFlags.Protected */) { error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass)); } return false; @@ -77177,10 +77469,10 @@ var ts; } function invocationErrorDetails(errorTarget, apparentType, kind) { var errorInfo; - var isCall = kind === 0 /* Call */; + var isCall = kind === 0 /* SignatureKind.Call */; var awaitedType = getAwaitedType(apparentType); var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0; - if (apparentType.flags & 1048576 /* Union */) { + if (apparentType.flags & 1048576 /* TypeFlags.Union */) { var types = apparentType.types; var hasSignatures = false; for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { @@ -77230,7 +77522,7 @@ var ts; // Diagnose get accessors incorrectly called as functions if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) { var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol; - if (resolvedSymbol && resolvedSymbol.flags & 32768 /* GetAccessor */) { + if (resolvedSymbol && resolvedSymbol.flags & 32768 /* SymbolFlags.GetAccessor */) { headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without; } } @@ -77274,8 +77566,8 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -77285,26 +77577,26 @@ var ts; diagnostics.add(diagnostic); return resolveErrorCall(node); } - invocationError(node.tag, apparentType, 0 /* Call */); + invocationError(node.tag, apparentType, 0 /* SignatureKind.Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -77319,8 +77611,8 @@ var ts; if (isErrorType(apparentType)) { return resolveErrorCall(node); } - var callSignatures = getSignaturesOfType(apparentType, 0 /* Call */); - var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* Construct */).length; + var callSignatures = getSignaturesOfType(apparentType, 0 /* SignatureKind.Call */); + var numConstructSignatures = getSignaturesOfType(apparentType, 1 /* SignatureKind.Construct */).length; if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) { return resolveUntypedCall(node); } @@ -77331,38 +77623,38 @@ var ts; } var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { - var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* Call */); + var errorDetails = invocationErrorDetails(node.expression, apparentType, 0 /* SignatureKind.Call */); var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage); var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain); if (errorDetails.relatedMessage) { ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage)); } diagnostics.add(diag); - invocationErrorRecovery(apparentType, 0 /* Call */, diag); + invocationErrorRecovery(apparentType, 0 /* SignatureKind.Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); // We fake up a SFC signature for each intrinsic, however a more specific per-element signature drawn from the JSX declaration // file would probably be preferable. - var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); - var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* AnyKeyword */)); - var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); + var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* SymbolFlags.Type */); + var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* SymbolFlags.Type */, node); + var declaration = ts.factory.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */)); + var parameterSymbol = createSymbol(1 /* SymbolFlags.FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, 0 /* None */); + /*returnTypePredicate*/ undefined, 1, 0 /* SignatureFlags.None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node); var fakeSignature = createSignatureForJSXIntrinsic(node, result); - checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* Normal */), result, node.tagName, node.attributes); + checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), /*mapper*/ undefined, 0 /* CheckMode.Normal */), result, node.tagName, node.attributes); if (ts.length(node.typeArguments)) { ts.forEach(node.typeArguments, checkSourceElement); diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments))); @@ -77383,7 +77675,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */); + return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* SignatureFlags.None */); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -77399,16 +77691,16 @@ var ts; } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -77431,7 +77723,7 @@ var ts; return cached; } links.resolvedSignature = resolvingSignature; - var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */); + var result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* CheckMode.Normal */); // When CheckMode.SkipGenericFunctions is set we use resolvingSignature to indicate that call // resolution should be deferred. if (result !== resolvingSignature) { @@ -77472,7 +77764,7 @@ var ts; var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target); inferred.exports = inferred.exports || ts.createSymbolTable(); inferred.members = inferred.members || ts.createSymbolTable(); - inferred.flags |= source.flags & 32 /* Class */; + inferred.flags |= source.flags & 32 /* SymbolFlags.Class */; if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) { mergeSymbolTable(inferred.exports, source.exports); } @@ -77508,16 +77800,16 @@ var ts; else if (ts.isBinaryExpression(node.parent)) { var parentNode = node.parent; var parentNodeOperator = node.parent.operatorToken.kind; - if (parentNodeOperator === 63 /* EqualsToken */ && (allowDeclaration || parentNode.right === node)) { + if (parentNodeOperator === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.right === node)) { name = parentNode.left; decl = name; } - else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + else if (parentNodeOperator === 56 /* SyntaxKind.BarBarToken */ || parentNodeOperator === 60 /* SyntaxKind.QuestionQuestionToken */) { if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { name = parentNode.parent.name; decl = parentNode.parent; } - else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */ && (allowDeclaration || parentNode.parent.right === parentNode)) { name = parentNode.parent.left; decl = name; } @@ -77540,10 +77832,10 @@ var ts; return false; } var parent = node.parent; - while (parent && parent.kind === 206 /* PropertyAccessExpression */) { + while (parent && parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } @@ -77559,19 +77851,19 @@ var ts; var signature = getResolvedSignature(node, /*candidatesOutArray*/ undefined, checkMode); if (signature === resolvingSignature) { // CheckMode.SkipGenericFunctions is enabled and this is a call to a generic function that - // returns a function type. We defer checking and return nonInferrableType. - return nonInferrableType; + // returns a function type. We defer checking and return silentNeverType. + return silentNeverType; } checkDeprecatedSignature(signature, node); - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return voidType; } - if (node.kind === 209 /* NewExpression */) { + if (node.kind === 209 /* SyntaxKind.NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 171 /* Constructor */ && - declaration.kind !== 175 /* ConstructSignature */ && - declaration.kind !== 180 /* ConstructorType */ && + declaration.kind !== 171 /* SyntaxKind.Constructor */ && + declaration.kind !== 175 /* SyntaxKind.ConstructSignature */ && + declaration.kind !== 180 /* SyntaxKind.ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -77588,11 +77880,11 @@ var ts; var returnType = getReturnTypeOfSignature(signature); // Treat any call to the global 'Symbol' function that is part of a const variable or readonly property // as a fresh unique symbol literal type. - if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { + if (returnType.flags & 12288 /* TypeFlags.ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - if (node.kind === 208 /* CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* ExpressionStatement */ && - returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (node.kind === 208 /* SyntaxKind.CallExpression */ && !node.questionDotToken && node.parent.kind === 238 /* SyntaxKind.ExpressionStatement */ && + returnType.flags & 16384 /* TypeFlags.Void */ && getTypePredicateOfSignature(signature)) { if (!ts.isDottedName(node.expression)) { error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); } @@ -77605,14 +77897,14 @@ var ts; var jsSymbol = getSymbolOfExpando(node, /*allowDeclaration*/ false); if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) { var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, ts.emptyArray); - jsAssignmentType.objectFlags |= 4096 /* JSLiteral */; + jsAssignmentType.objectFlags |= 4096 /* ObjectFlags.JSLiteral */; return getIntersectionType([returnType, jsAssignmentType]); } } return returnType; } function checkDeprecatedSignature(signature, node) { - if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) { + if (signature.declaration && signature.declaration.flags & 268435456 /* NodeFlags.Deprecated */) { var suggestionNode = getDeprecatedSuggestionNode(node); var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node)); addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature)); @@ -77621,20 +77913,20 @@ var ts; function getDeprecatedSuggestionNode(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 208 /* CallExpression */: - case 165 /* Decorator */: - case 209 /* NewExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 165 /* SyntaxKind.Decorator */: + case 209 /* SyntaxKind.NewExpression */: return getDeprecatedSuggestionNode(node.expression); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return getDeprecatedSuggestionNode(node.tag); - case 280 /* JsxOpeningElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return getDeprecatedSuggestionNode(node.tagName); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return node.argumentExpression; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: var typeReference = node; return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference; default: @@ -77656,7 +77948,7 @@ var ts; if (!globalESSymbol) { return false; } - return globalESSymbol === resolveName(left, "Symbol", 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + return globalESSymbol === resolveName(left, "Symbol", 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); } function checkImportCallExpression(node) { // Check grammar of dynamic import @@ -77671,13 +77963,13 @@ var ts; for (var i = 2; i < node.arguments.length; ++i) { checkExpressionCached(node.arguments[i]); } - if (specifierType.flags & 32768 /* Undefined */ || specifierType.flags & 65536 /* Null */ || !isTypeAssignableTo(specifierType, stringType)) { + if (specifierType.flags & 32768 /* TypeFlags.Undefined */ || specifierType.flags & 65536 /* TypeFlags.Null */ || !isTypeAssignableTo(specifierType, stringType)) { error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType)); } if (optionsType) { var importCallOptionsType = getGlobalImportCallOptionsType(/*reportErrors*/ true); if (importCallOptionsType !== emptyObjectType) { - checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* Undefined */), node.arguments[1]); + checkTypeAssignableTo(optionsType, getNullableType(importCallOptionsType, 32768 /* TypeFlags.Undefined */), node.arguments[1]); } } // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal @@ -77693,11 +77985,11 @@ var ts; } function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) { var memberTable = ts.createSymbolTable(); - var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */); + var newSymbol = createSymbol(2097152 /* SymbolFlags.Alias */, "default" /* InternalSymbolName.Default */); newSymbol.parent = originalSymbol; newSymbol.nameType = getStringLiteralType("default"); newSymbol.aliasTarget = resolveSymbol(symbol); - memberTable.set("default" /* Default */, newSymbol); + memberTable.set("default" /* InternalSymbolName.Default */, newSymbol); return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray); } function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) { @@ -77720,7 +78012,7 @@ var ts; var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile); var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier); if (hasSyntheticDefault) { - var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */); + var anonymousSymbol = createSymbol(2048 /* SymbolFlags.TypeLiteral */, "__type" /* InternalSymbolName.Type */); var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol); anonymousSymbol.type = defaultContainingObject; synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; @@ -77740,40 +78032,40 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) return ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); // TODO: GH#18217 if (resolvedRequire === requireSymbol) { return true; } // project includes symbol named 'require' - make sure that it is ambient and local non-alias - if (resolvedRequire.flags & 2097152 /* Alias */) { + if (resolvedRequire.flags & 2097152 /* SymbolFlags.Alias */) { return false; } - var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 256 /* FunctionDeclaration */ - : resolvedRequire.flags & 3 /* Variable */ - ? 254 /* VariableDeclaration */ - : 0 /* Unknown */; - if (targetDeclarationKind !== 0 /* Unknown */) { + var targetDeclarationKind = resolvedRequire.flags & 16 /* SymbolFlags.Function */ + ? 256 /* SyntaxKind.FunctionDeclaration */ + : resolvedRequire.flags & 3 /* SymbolFlags.Variable */ + ? 254 /* SyntaxKind.VariableDeclaration */ + : 0 /* SyntaxKind.Unknown */; + if (targetDeclarationKind !== 0 /* SyntaxKind.Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 16777216 /* Ambient */); + return !!decl && !!(decl.flags & 16777216 /* NodeFlags.Ambient */); } return false; } function checkTaggedTemplateExpression(node) { if (!checkGrammarTaggedTemplateChain(node)) checkGrammarTypeArguments(node, node.typeArguments); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 262144 /* MakeTemplateObject */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 262144 /* ExternalEmitHelpers.MakeTemplateObject */); } var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); return getReturnTypeOfSignature(signature); } function checkAssertion(node) { - if (node.kind === 211 /* TypeAssertionExpression */) { + if (node.kind === 211 /* SyntaxKind.TypeAssertionExpression */) { var file = ts.getSourceFileOfNode(node); - if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Cts */, ".mts" /* Mts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".cts" /* Extension.Cts */, ".mts" /* Extension.Mts */])) { grammarErrorOnNode(node, ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } @@ -77781,31 +78073,31 @@ var ts; } function isValidConstAssertionArgument(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 223 /* TemplateExpression */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return true; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + return op === 40 /* SyntaxKind.MinusToken */ && (arg.kind === 8 /* SyntaxKind.NumericLiteral */ || arg.kind === 9 /* SyntaxKind.BigIntLiteral */) || + op === 39 /* SyntaxKind.PlusToken */ && arg.kind === 8 /* SyntaxKind.NumericLiteral */; + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: var expr = node.expression; var symbol = getTypeOfNode(expr).symbol; - if (symbol && symbol.flags & 2097152 /* Alias */) { + if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) { symbol = resolveAlias(symbol); } - return !!(symbol && (symbol.flags & 384 /* Enum */) && getEnumKind(symbol) === 1 /* Literal */); + return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */); } return false; } @@ -77836,12 +78128,12 @@ var ts; return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType); } function checkNonNullAssertion(node) { - return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) : + return node.flags & 32 /* NodeFlags.OptionalChain */ ? checkNonNullChain(node) : getNonNullableType(checkExpression(node.expression)); } function checkExpressionWithTypeArguments(node) { checkGrammarExpressionWithTypeArguments(node); - var exprType = node.kind === 228 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) : + var exprType = node.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ ? checkExpression(node.expression) : ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) : checkExpression(node.exprName); var typeArguments = node.typeArguments; @@ -77866,7 +78158,7 @@ var ts; } return result; function getInstantiatedTypePart(type) { - if (type.flags & 524288 /* Object */) { + if (type.flags & 524288 /* TypeFlags.Object */) { var resolved = resolveStructuredTypeMembers(type); var callSignatures = getInstantiatedSignatures(resolved.callSignatures); var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures); @@ -77874,12 +78166,12 @@ var ts; hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0); if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) { var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos); - result_11.objectFlags |= 8388608 /* InstantiationExpressionType */; + result_11.objectFlags |= 8388608 /* ObjectFlags.InstantiationExpressionType */; result_11.node = node; return result_11; } } - else if (type.flags & 58982400 /* InstantiableNonPrimitive */) { + else if (type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { var constraint = getBaseConstraintOfType(type); if (constraint) { var instantiated = getInstantiatedTypePart(constraint); @@ -77888,10 +78180,10 @@ var ts; } } } - else if (type.flags & 1048576 /* Union */) { + else if (type.flags & 1048576 /* TypeFlags.Union */) { return mapType(type, getInstantiatedType); } - else if (type.flags & 2097152 /* Intersection */) { + else if (type.flags & 2097152 /* TypeFlags.Intersection */) { return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart)); } return type; @@ -77907,19 +78199,19 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 103 /* NewKeyword */) { + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 100 /* ImportKeyword */) { + if (node.keywordToken === 100 /* SyntaxKind.ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); } function checkMetaPropertyKeyword(node) { switch (node.keywordToken) { - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: return getGlobalImportMetaExpressionType(); - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: var type = checkNewTargetMetaProperty(node); return isErrorType(type) ? errorType : createNewTargetExpressionType(type); default: @@ -77932,7 +78224,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -77951,7 +78243,7 @@ var ts; error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node16_or_nodenext); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 4194304 /* NodeFlags.PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } function getTypeOfParameter(symbol) { @@ -77984,7 +78276,7 @@ var ts; } function getParameterIdentifierNameAtPosition(signature, pos) { var _a; - if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* JSDocFunctionType */) { + if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 317 /* SyntaxKind.JSDocFunctionType */) { return undefined; } var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -78016,7 +78308,7 @@ var ts; return symbol.valueDeclaration && ts.isParameter(symbol.valueDeclaration) && ts.isIdentifier(symbol.valueDeclaration.name); } function isValidDeclarationForTupleLabel(d) { - return d.kind === 197 /* NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); + return d.kind === 197 /* SyntaxKind.NamedTupleMember */ || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name)); } function getNameableDeclarationAtPosition(signature, pos) { var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); @@ -78066,11 +78358,11 @@ var ts; for (var i = pos; i < parameterCount; i++) { if (!restType || i < parameterCount - 1) { types.push(getTypeAtPosition(source, i)); - flags.push(i < minArgumentCount ? 1 /* Required */ : 2 /* Optional */); + flags.push(i < minArgumentCount ? 1 /* ElementFlags.Required */ : 2 /* ElementFlags.Optional */); } else { types.push(restType); - flags.push(8 /* Variadic */); + flags.push(8 /* ElementFlags.Variadic */); } var name = getNameableDeclarationAtPosition(source, i); if (name) { @@ -78094,14 +78386,14 @@ var ts; return length; } function getMinArgumentCount(signature, flags) { - var strongArityForUntypedJS = flags & 1 /* StrongArityForUntypedJS */; - var voidIsNonOptional = flags & 2 /* VoidIsNonOptional */; + var strongArityForUntypedJS = flags & 1 /* MinArgumentCountFlags.StrongArityForUntypedJS */; + var voidIsNonOptional = flags & 2 /* MinArgumentCountFlags.VoidIsNonOptional */; if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) { var minArgumentCount = void 0; if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { - var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* Required */); }); + var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1 /* ElementFlags.Required */); }); var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex; if (requiredCount > 0) { minArgumentCount = signature.parameters.length - 1 + requiredCount; @@ -78109,7 +78401,7 @@ var ts; } } if (minArgumentCount === undefined) { - if (!strongArityForUntypedJS && signature.flags & 32 /* IsUntypedSignatureInJSFile */) { + if (!strongArityForUntypedJS && signature.flags & 32 /* SignatureFlags.IsUntypedSignatureInJSFile */) { return 0; } minArgumentCount = signature.minArgumentCount; @@ -78119,7 +78411,7 @@ var ts; } for (var i = minArgumentCount - 1; i >= 0; i--) { var type = getTypeAtPosition(signature, i); - if (filterType(type, acceptsVoid).flags & 131072 /* Never */) { + if (filterType(type, acceptsVoid).flags & 131072 /* TypeFlags.Never */) { break; } minArgumentCount = i; @@ -78149,7 +78441,7 @@ var ts; } function getNonArrayRestType(signature) { var restType = getEffectiveRestType(signature); - return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined; + return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* TypeFlags.Never */) === 0 ? restType : undefined; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -78168,17 +78460,6 @@ var ts; } } } - var restType = getEffectiveRestType(context); - if (restType && restType.flags & 262144 /* TypeParameter */) { - // The contextual signature has a generic rest parameter. We first instantiate the contextual - // signature (without fixing type parameters) and assign types to contextually typed parameters. - var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper); - assignContextualParameterTypes(signature, instantiatedContext); - // We then infer from a tuple type representing the parameters that correspond to the contextual - // rest parameter. - var restPos = getParameterCount(context) - 1; - inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType); - } } function assignContextualParameterTypes(signature, context) { if (context.typeParameters) { @@ -78213,7 +78494,7 @@ var ts; ? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration) // a declarationless parameter may still have a `.type` already set by its construction logic // (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type - : !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) { + : !!(ts.getCheckFlags(parameter) & 65536 /* CheckFlags.DeferredType */)) { var contextualParameterType = getRestTypeAtPosition(context, len); assignParameterType(parameter, contextualParameterType); } @@ -78233,7 +78514,7 @@ var ts; if (!links.type) { var declaration = parameter.valueDeclaration; links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter)); - if (declaration && declaration.name.kind !== 79 /* Identifier */) { + if (declaration && declaration.name.kind !== 79 /* SyntaxKind.Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(declaration.name); @@ -78252,7 +78533,7 @@ var ts; var element = _a[_i]; if (!ts.isOmittedExpression(element)) { var type = getBindingElementTypeFromParentType(element, parentType); - if (element.name.kind === 79 /* Identifier */) { + if (element.name.kind === 79 /* SyntaxKind.Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = type; } else { @@ -78300,8 +78581,8 @@ var ts; } function createNewTargetExpressionType(targetType) { // Create a synthetic type `NewTargetExpression { target: TargetType; }` - var symbol = createSymbol(0 /* None */, "NewTargetExpression"); - var targetPropertySymbol = createSymbol(4 /* Property */, "target", 8 /* Readonly */); + var symbol = createSymbol(0 /* SymbolFlags.None */, "NewTargetExpression"); + var targetPropertySymbol = createSymbol(4 /* SymbolFlags.Property */, "target", 8 /* CheckFlags.Readonly */); targetPropertySymbol.parent = symbol; targetPropertySymbol.type = targetType; var members = ts.createSymbolTable([targetPropertySymbol]); @@ -78313,14 +78594,14 @@ var ts; return errorType; } var functionFlags = ts.getFunctionFlags(func); - var isAsync = (functionFlags & 2 /* Async */) !== 0; - var isGenerator = (functionFlags & 1 /* Generator */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; + var isGenerator = (functionFlags & 1 /* FunctionFlags.Generator */) !== 0; var returnType; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 235 /* Block */) { // Async or normal arrow function - returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); + if (func.body.kind !== 235 /* SyntaxKind.Block */) { // Async or normal arrow function + returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the @@ -78335,47 +78616,47 @@ var ts; fallbackReturnType = neverType; } else if (returnTypes.length > 0) { - returnType = getUnionType(returnTypes, 2 /* Subtype */); + returnType = getUnionType(returnTypes, 2 /* UnionReduction.Subtype */); } var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes; - yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* Subtype */) : undefined; + yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2 /* UnionReduction.Subtype */) : undefined; nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined; } else { // Async or normal function var types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, neverType) // Async function : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return functionFlags & 2 /* Async */ + return functionFlags & 2 /* FunctionFlags.Async */ ? createPromiseReturnType(func, voidType) // Async function : voidType; // Normal function } // Return a union of the return expression types. - returnType = getUnionType(types, 2 /* Subtype */); + returnType = getUnionType(types, 2 /* UnionReduction.Subtype */); } if (returnType || yieldType || nextType) { if (yieldType) - reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */); + reportErrorsFromWidening(func, yieldType, 3 /* WideningKind.GeneratorYield */); if (returnType) - reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */); + reportErrorsFromWidening(func, returnType, 1 /* WideningKind.FunctionReturn */); if (nextType) - reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */); + reportErrorsFromWidening(func, nextType, 2 /* WideningKind.GeneratorNext */); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); var contextualType = !contextualSignature ? undefined : contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : - instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); + instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func, /*contextFlags*/ undefined); if (isGenerator) { - yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* Yield */, isAsync); - returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* Return */, isAsync); - nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* Next */, isAsync); + yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0 /* IterationTypeKind.Yield */, isAsync); + returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1 /* IterationTypeKind.Return */, isAsync); + nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2 /* IterationTypeKind.Next */, isAsync); } else { returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync); @@ -78389,7 +78670,7 @@ var ts; nextType = getWidenedType(nextType); } if (isGenerator) { - return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* Next */, func) || unknownType, isAsync); + return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2 /* IterationTypeKind.Next */, func) || unknownType, isAsync); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -78432,17 +78713,17 @@ var ts; function checkAndAggregateYieldOperandTypes(func, checkMode) { var yieldTypes = []; var nextTypes = []; - var isAsync = (ts.getFunctionFlags(func) & 2 /* Async */) !== 0; + var isAsync = (ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) !== 0; ts.forEachYieldExpression(func.body, function (yieldExpression) { var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType; ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync)); var nextType; if (yieldExpression.asteriskToken) { - var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, yieldExpression.expression); + var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, yieldExpression.expression); nextType = iterationTypes && iterationTypes.nextType; } else { - nextType = getContextualType(yieldExpression); + nextType = getContextualType(yieldExpression, /*contextFlags*/ undefined); } if (nextType) ts.pushIfUnique(nextTypes, nextType); @@ -78452,17 +78733,17 @@ var ts; function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) { var errorNode = node.expression || node; // A `yield*` expression effectively yields everything that its operand yields - var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */, expressionType, sentType, errorNode) : expressionType; + var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */, expressionType, sentType, errorNode) : expressionType; return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } // Return the combined not-equal type facts for all cases except those between the start and end indices. function getNotEqualFactsFromTypeofSwitch(start, end, witnesses) { - var facts = 0 /* None */; + var facts = 0 /* TypeFacts.None */; for (var i = 0; i < witnesses.length; i++) { var witness = i < start || i >= end ? witnesses[i] : undefined; - facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeofNEHostObject */ : 0; + facts |= witness !== undefined ? typeofNEFacts.get(witness) || 32768 /* TypeFacts.TypeofNEHostObject */ : 0; } return facts; } @@ -78471,7 +78752,7 @@ var ts; return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); } function computeExhaustiveSwitchStatement(node) { - if (node.expression.kind === 216 /* TypeOfExpression */) { + if (node.expression.kind === 216 /* SyntaxKind.TypeOfExpression */) { var witnesses = getSwitchClauseTypeOfWitnesses(node); if (!witnesses) { return false; @@ -78479,9 +78760,9 @@ var ts; var operandConstraint = getBaseConstraintOrType(getTypeOfExpression(node.expression.expression)); // Get the not-equal flags for all handled cases. var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses); - if (operandConstraint.flags & 3 /* AnyOrUnknown */) { + if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) { // We special case the top types to be exhaustive when all cases are handled. - return (556800 /* AllTypeofNE */ & notEqualFacts_2) === 556800 /* AllTypeofNE */; + return (556800 /* TypeFacts.AllTypeofNE */ & notEqualFacts_2) === 556800 /* TypeFacts.AllTypeofNE */; } // A missing not-equal flag indicates that the type wasn't handled by some case. return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; }); @@ -78508,15 +78789,15 @@ var ts; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* SkipGenericFunctions */); - if (functionFlags & 2 /* Async */) { + var type = checkExpressionCached(expr, checkMode && checkMode & ~8 /* CheckMode.SkipGenericFunctions */); + if (functionFlags & 2 /* FunctionFlags.Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. type = unwrapAwaitedType(checkAwaitedType(type, /*withAlias*/ false, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member)); } - if (type.flags & 131072 /* Never */) { + if (type.flags & 131072 /* TypeFlags.Never */) { hasReturnOfTypeNever = true; } ts.pushIfUnique(aggregatedTypes, type); @@ -78537,11 +78818,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return true; - case 169 /* MethodDeclaration */: - return func.parent.kind === 205 /* ObjectLiteralExpression */; + case 169 /* SyntaxKind.MethodDeclaration */: + return func.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */; default: return false; } @@ -78562,17 +78843,17 @@ var ts; var functionFlags = ts.getFunctionFlags(func); var type = returnType && unwrapReturnType(returnType, functionFlags); // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. - if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) { + if (type && maybeTypeOfKind(type, 1 /* TypeFlags.Any */ | 16384 /* TypeFlags.Void */)) { return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 168 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 168 /* SyntaxKind.MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 235 /* SyntaxKind.Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* NodeFlags.HasExplicitReturn */; var errorNode = ts.getEffectiveReturnTypeNode(func) || func; - if (type && type.flags & 131072 /* Never */) { + if (type && type.flags & 131072 /* TypeFlags.Never */) { error(errorNode, ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } else if (type && !hasExplicitReturn) { @@ -78601,13 +78882,13 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (ts.isFunctionExpression(node)) { checkCollisionsForDeclarationName(node, node.name); } // The identityMapper object is used to indicate that function expressions are wildcards - if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { + if (checkMode && checkMode & 4 /* CheckMode.SkipContextSensitive */ && isContextSensitive(node)) { // Skip parameters, return signature with return type that retains noncontextual parts so inferences can still be drawn in an early stage if (!ts.getEffectiveReturnTypeNode(node) && !ts.hasContextSensitiveParameters(node)) { // Return plain anyFunctionType if there is no possibility we'll make inferences from the return type @@ -78618,9 +78899,9 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* SignatureFlags.None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, ts.emptyArray); - returnOnlyType.objectFlags |= 262144 /* NonInferrableType */; + returnOnlyType.objectFlags |= 262144 /* ObjectFlags.NonInferrableType */; return links.contextFreeType = returnOnlyType; } } @@ -78628,7 +78909,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 213 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 213 /* SyntaxKind.FunctionExpression */) { checkGrammarForGenerator(node); } contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -78637,25 +78918,30 @@ var ts; function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) { var links = getNodeLinks(node); // Check if function expression is contextually typed and assign parameter types if so. - if (!(links.flags & 1024 /* ContextChecked */)) { + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 1024 /* ContextChecked */)) { - links.flags |= 1024 /* ContextChecked */; - var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* Call */)); + if (!(links.flags & 1024 /* NodeCheckFlags.ContextChecked */)) { + links.flags |= 1024 /* NodeCheckFlags.ContextChecked */; + var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0 /* SignatureKind.Call */)); if (!signature) { return; } if (isContextSensitive(node)) { if (contextualSignature) { var inferenceContext = getInferenceContext(node); - if (checkMode && checkMode & 2 /* Inferential */) { + var instantiatedContextualSignature = void 0; + if (checkMode && checkMode & 2 /* CheckMode.Inferential */) { inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext); + var restType = getEffectiveRestType(contextualSignature); + if (restType && restType.flags & 262144 /* TypeFlags.TypeParameter */) { + instantiatedContextualSignature = instantiateSignature(contextualSignature, inferenceContext.nonFixingMapper); + } } - var instantiatedContextualSignature = inferenceContext ? - instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature; + instantiatedContextualSignature || (instantiatedContextualSignature = inferenceContext ? + instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature); assignContextualParameterTypes(signature, instantiatedContextualSignature); } else { @@ -78674,7 +78960,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 169 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 169 /* SyntaxKind.MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -78687,7 +78973,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 235 /* Block */) { + if (node.body.kind === 235 /* SyntaxKind.Block */) { checkSourceElement(node.body); } else { @@ -78699,7 +78985,7 @@ var ts; var exprType = checkExpression(node.body); var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { // Async function var awaitedType = checkAwaitedType(exprType, /*withAlias*/ false, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body); } @@ -78757,27 +79043,27 @@ var ts; // Enum members // Object.defineProperty assignments with writable false or no setter // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(ts.getCheckFlags(symbol) & 8 /* Readonly */ || - symbol.flags & 4 /* Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || - symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || - symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || - symbol.flags & 8 /* EnumMember */ || + return !!(ts.getCheckFlags(symbol) & 8 /* CheckFlags.Readonly */ || + symbol.flags & 4 /* SymbolFlags.Property */ && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* ModifierFlags.Readonly */ || + symbol.flags & 3 /* SymbolFlags.Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* NodeFlags.Const */ || + symbol.flags & 98304 /* SymbolFlags.Accessor */ && !(symbol.flags & 65536 /* SymbolFlags.SetAccessor */) || + symbol.flags & 8 /* SymbolFlags.EnumMember */ || ts.some(symbol.declarations, isReadonlyAssignmentDeclaration)); } function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) { var _a, _b; - if (assignmentKind === 0 /* None */) { + if (assignmentKind === 0 /* AssignmentKind.None */) { // no assigment means it doesn't matter whether the entity is readonly return false; } if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. - if (symbol.flags & 4 /* Property */ && + if (symbol.flags & 4 /* SymbolFlags.Property */ && ts.isAccessExpression(expr) && - expr.expression.kind === 108 /* ThisKeyword */) { + expr.expression.kind === 108 /* SyntaxKind.ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var ctor = ts.getContainingFunction(expr); - if (!(ctor && (ctor.kind === 171 /* Constructor */ || isJSConstructor(ctor)))) { + if (!(ctor && (ctor.kind === 171 /* SyntaxKind.Constructor */ || isJSConstructor(ctor)))) { return true; } if (symbol.valueDeclaration) { @@ -78798,11 +79084,11 @@ var ts; if (ts.isAccessExpression(expr)) { // references through namespace import should be readonly var node = ts.skipParentheses(expr.expression); - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { var symbol_2 = getNodeLinks(node).resolvedSymbol; - if (symbol_2.flags & 2097152 /* Alias */) { + if (symbol_2.flags & 2097152 /* SymbolFlags.Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol_2); - return !!declaration && declaration.kind === 268 /* NamespaceImport */; + return !!declaration && declaration.kind === 268 /* SyntaxKind.NamespaceImport */; } } } @@ -78810,12 +79096,12 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 79 /* Identifier */ && !ts.isAccessExpression(node)) { + var node = ts.skipOuterExpressions(expr, 6 /* OuterExpressionKinds.Assertions */ | 1 /* OuterExpressionKinds.Parentheses */); + if (node.kind !== 79 /* SyntaxKind.Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; } - if (node.flags & 32 /* OptionalChain */) { + if (node.flags & 32 /* NodeFlags.OptionalChain */) { error(expr, invalidOptionalChainMessage); return false; } @@ -78844,8 +79130,8 @@ var ts; function checkDeleteExpressionMustBeOptional(expr, symbol) { var type = getTypeOfSymbol(symbol); if (strictNullChecks && - !(type.flags & (3 /* AnyOrUnknown */ | 131072 /* Never */)) && - !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* Optional */ : getTypeFacts(type) & 16777216 /* IsUndefined */)) { + !(type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 131072 /* TypeFlags.Never */)) && + !(exactOptionalPropertyTypes ? symbol.flags & 16777216 /* SymbolFlags.Optional */ : getTypeFacts(type) & 16777216 /* TypeFacts.IsUndefined */)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional); } } @@ -78863,7 +79149,7 @@ var ts; if (container && ts.isClassStaticBlockDeclaration(container)) { error(node, ts.Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); } - else if (!(node.flags & 32768 /* AwaitContext */)) { + else if (!(node.flags & 32768 /* NodeFlags.AwaitContext */)) { if (ts.isInTopLevelContext(node)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { @@ -78885,7 +79171,7 @@ var ts; case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: case ts.ModuleKind.System: - if (languageVersion >= 4 /* ES2017 */) { + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { break; } // fallthrough @@ -78902,7 +79188,7 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); - if (container && container.kind !== 171 /* Constructor */ && (ts.getFunctionFlags(container) & 2 /* Async */) === 0) { + if (container && container.kind !== 171 /* SyntaxKind.Constructor */ && (ts.getFunctionFlags(container) & 2 /* FunctionFlags.Async */) === 0) { var relatedInfo = ts.createDiagnosticForNode(container, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -78918,7 +79204,7 @@ var ts; addLazyDiagnostic(function () { return checkAwaitExpressionGrammar(node); }); var operandType = checkExpression(node.expression); var awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); - if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* AnyOrUnknown */)) { + if (awaitedType === operandType && !isErrorType(awaitedType) && !(operandType.flags & 3 /* TypeFlags.AnyOrUnknown */)) { addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression)); } return awaitedType; @@ -78929,16 +79215,16 @@ var ts; return silentNeverType; } switch (node.operand.kind) { - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: switch (node.operator) { - case 40 /* MinusToken */: + case 40 /* SyntaxKind.MinusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(-node.operand.text)); - case 39 /* PlusToken */: + case 39 /* SyntaxKind.PlusToken */: return getFreshTypeOfLiteralType(getNumberLiteralType(+node.operand.text)); } break; - case 9 /* BigIntLiteral */: - if (node.operator === 40 /* MinusToken */) { + case 9 /* SyntaxKind.BigIntLiteral */: + if (node.operator === 40 /* SyntaxKind.MinusToken */) { return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -78946,28 +79232,28 @@ var ts; } } switch (node.operator) { - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: checkNonNullType(operandType, node.operand); - if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 12288 /* TypeFlags.ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 39 /* PlusToken */) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { + if (node.operator === 39 /* SyntaxKind.PlusToken */) { + if (maybeTypeOfKindConsideringBaseConstraint(operandType, 2112 /* TypeFlags.BigIntLike */)) { error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 53 /* ExclamationToken */: + case 53 /* SyntaxKind.ExclamationToken */: checkTruthinessExpression(node.operand); - var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); - return facts === 4194304 /* Truthy */ ? falseType : - facts === 8388608 /* Falsy */ ? trueType : + var facts = getTypeFacts(operandType) & (4194304 /* TypeFacts.Truthy */ | 8388608 /* TypeFacts.Falsy */); + return facts === 4194304 /* TypeFacts.Truthy */ ? falseType : + facts === 8388608 /* TypeFacts.Falsy */ ? trueType : booleanType; - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: + case 45 /* SyntaxKind.PlusPlusToken */: + case 46 /* SyntaxKind.MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -78990,8 +79276,8 @@ var ts; return getUnaryResultType(operandType); } function getUnaryResultType(operandType) { - if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - return isTypeAssignableToKind(operandType, 3 /* AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* NumberLike */) + if (maybeTypeOfKind(operandType, 2112 /* TypeFlags.BigIntLike */)) { + return isTypeAssignableToKind(operandType, 3 /* TypeFlags.AnyOrUnknown */) || maybeTypeOfKind(operandType, 296 /* TypeFlags.NumberLike */) ? numberOrBigIntType : bigintType; } @@ -79011,7 +79297,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 3145728 /* UnionOrIntersection */) { + if (type.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = type.types; for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { var t = types_20[_i]; @@ -79026,30 +79312,30 @@ var ts; if (source.flags & kind) { return true; } - if (strict && source.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */ | 32768 /* Undefined */ | 65536 /* Null */)) { + if (strict && source.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */ | 65536 /* TypeFlags.Null */)) { return false; } - return !!(kind & 296 /* NumberLike */) && isTypeAssignableTo(source, numberType) || - !!(kind & 2112 /* BigIntLike */) && isTypeAssignableTo(source, bigintType) || - !!(kind & 402653316 /* StringLike */) && isTypeAssignableTo(source, stringType) || - !!(kind & 528 /* BooleanLike */) && isTypeAssignableTo(source, booleanType) || - !!(kind & 16384 /* Void */) && isTypeAssignableTo(source, voidType) || - !!(kind & 131072 /* Never */) && isTypeAssignableTo(source, neverType) || - !!(kind & 65536 /* Null */) && isTypeAssignableTo(source, nullType) || - !!(kind & 32768 /* Undefined */) && isTypeAssignableTo(source, undefinedType) || - !!(kind & 4096 /* ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || - !!(kind & 67108864 /* NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); + return !!(kind & 296 /* TypeFlags.NumberLike */) && isTypeAssignableTo(source, numberType) || + !!(kind & 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableTo(source, bigintType) || + !!(kind & 402653316 /* TypeFlags.StringLike */) && isTypeAssignableTo(source, stringType) || + !!(kind & 528 /* TypeFlags.BooleanLike */) && isTypeAssignableTo(source, booleanType) || + !!(kind & 16384 /* TypeFlags.Void */) && isTypeAssignableTo(source, voidType) || + !!(kind & 131072 /* TypeFlags.Never */) && isTypeAssignableTo(source, neverType) || + !!(kind & 65536 /* TypeFlags.Null */) && isTypeAssignableTo(source, nullType) || + !!(kind & 32768 /* TypeFlags.Undefined */) && isTypeAssignableTo(source, undefinedType) || + !!(kind & 4096 /* TypeFlags.ESSymbol */) && isTypeAssignableTo(source, esSymbolType) || + !!(kind & 67108864 /* TypeFlags.NonPrimitive */) && isTypeAssignableTo(source, nonPrimitiveType); } function allTypesAssignableToKind(source, kind, strict) { - return source.flags & 1048576 /* Union */ ? + return source.flags & 1048576 /* TypeFlags.Union */ ? ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) : isTypeAssignableToKind(source, kind, strict); } function isConstEnumObjectType(type) { - return !!(ts.getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); + return !!(ts.getObjectFlags(type) & 16 /* ObjectFlags.Anonymous */) && !!type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { - return (symbol.flags & 128 /* ConstEnum */) !== 0; + return (symbol.flags & 128 /* SymbolFlags.ConstEnum */) !== 0; } function checkInstanceOfExpression(left, right, leftType, rightType) { if (leftType === silentNeverType || rightType === silentNeverType) { @@ -79061,7 +79347,7 @@ var ts; // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported if (!isTypeAny(leftType) && - allTypesAssignableToKind(leftType, 131068 /* Primitive */)) { + allTypesAssignableToKind(leftType, 131068 /* TypeFlags.Primitive */)) { error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -79075,8 +79361,8 @@ var ts; return silentNeverType; } if (ts.isPrivateIdentifier(left)) { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(left, 2097152 /* ClassPrivateFieldIn */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(left, 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */); } // Unlike in 'checkPrivateIdentifierExpression' we now have access to the RHS type // which provides us with the opportunity to emit more detailed errors @@ -79089,8 +79375,8 @@ var ts; leftType = checkNonNullType(leftType, left); // TypeScript 1.0 spec (April 2014): 4.15.5 // Require the left operand to be of type Any, the String primitive type, or the Number primitive type. - if (!(allTypesAssignableToKind(leftType, 402653316 /* StringLike */ | 296 /* NumberLike */ | 12288 /* ESSymbolLike */) || - isTypeAssignableToKind(leftType, 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */ | 262144 /* TypeParameter */))) { + if (!(allTypesAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */ | 296 /* TypeFlags.NumberLike */ | 12288 /* TypeFlags.ESSymbolLike */) || + isTypeAssignableToKind(leftType, 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */ | 262144 /* TypeFlags.TypeParameter */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_a_private_identifier_or_of_type_any_string_number_or_symbol); } } @@ -79115,9 +79401,9 @@ var ts; // // The result is always of the Boolean primitive type. var rightTypeConstraint = getConstraintOfType(rightType); - if (!allTypesAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */) || - !maybeTypeOfKind(rightTypeConstraint, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */))) { + if (!allTypesAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728 /* TypeFlags.UnionOrIntersection */) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */) || + !maybeTypeOfKind(rightTypeConstraint, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */ | 524288 /* TypeFlags.Object */))) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive); } return booleanType; @@ -79137,7 +79423,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 296 /* PropertyAssignment */ || property.kind === 297 /* ShorthandPropertyAssignment */) { + if (property.kind === 296 /* SyntaxKind.PropertyAssignment */ || property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -79148,17 +79434,17 @@ var ts; checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* ExpressionPosition */, name); + var elementType = getIndexedAccessType(objectLiteralType, exprType, 32 /* AccessFlags.ExpressionPosition */, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 297 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 298 /* SpreadAssignment */) { + else if (property.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } else { - if (languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(property, 4 /* Rest */); + if (languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(property, 4 /* ExternalEmitHelpers.Rest */); } var nonRestNames = []; if (allProperties) { @@ -79180,18 +79466,18 @@ var ts; } function checkArrayLiteralAssignment(node, sourceType, checkMode) { var elements = node.elements; - if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* Destructuring */ | 128 /* PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; + var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */ | 128 /* IterationUse.PossiblyOutOfBounds */, sourceType, undefinedType, node) || errorType; var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType; for (var i = 0; i < elements.length; i++) { var type = possiblyOutOfBoundsType; - if (node.elements[i].kind === 225 /* SpreadElement */) { - type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* Destructuring */, sourceType, undefinedType, node) || errorType); + if (node.elements[i].kind === 225 /* SyntaxKind.SpreadElement */) { + type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, sourceType, undefinedType, node) || errorType); } checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode); } @@ -79200,15 +79486,15 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 227 /* OmittedExpression */) { - if (element.kind !== 225 /* SpreadElement */) { + if (element.kind !== 227 /* SyntaxKind.OmittedExpression */) { + if (element.kind !== 225 /* SyntaxKind.SpreadElement */) { var indexType = getNumberLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - var accessFlags = 32 /* ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* NoTupleBoundsCheck */ : 0); + var accessFlags = 32 /* AccessFlags.ExpressionPosition */ | (hasDefaultValue(element) ? 16 /* AccessFlags.NoTupleBoundsCheck */ : 0); var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; - var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* NEUndefined */) : elementType_2; + var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288 /* TypeFacts.NEUndefined */) : elementType_2; var type = getFlowTypeOfDestructuring(element, assignedType); return checkDestructuringAssignment(element, type, checkMode); } @@ -79219,7 +79505,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 221 /* BinaryExpression */ && restExpression.operatorToken.kind === 63 /* EqualsToken */) { + if (restExpression.kind === 221 /* SyntaxKind.BinaryExpression */ && restExpression.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -79235,14 +79521,14 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 297 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove // undefined from the final type. if (strictNullChecks && - !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* IsUndefined */)) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + !(getTypeFacts(checkExpression(prop.objectAssignmentInitializer)) & 16777216 /* TypeFacts.IsUndefined */)) { + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } @@ -79251,35 +79537,35 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 221 /* BinaryExpression */ && target.operatorToken.kind === 63 /* EqualsToken */) { + if (target.kind === 221 /* SyntaxKind.BinaryExpression */ && target.operatorToken.kind === 63 /* SyntaxKind.EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; // A default value is specified, so remove undefined from the final type. if (strictNullChecks) { - sourceType = getTypeWithFacts(sourceType, 524288 /* NEUndefined */); + sourceType = getTypeWithFacts(sourceType, 524288 /* TypeFacts.NEUndefined */); } } - if (target.kind === 205 /* ObjectLiteralExpression */) { + if (target.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 204 /* ArrayLiteralExpression */) { + if (target.kind === 204 /* SyntaxKind.ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 298 /* SpreadAssignment */ ? + var error = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - var optionalError = target.parent.kind === 298 /* SpreadAssignment */ ? + var optionalError = target.parent.kind === 298 /* SyntaxKind.SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } if (ts.isPrivateIdentifierPropertyAccessExpression(target)) { - checkExternalEmitHelpers(target.parent, 1048576 /* ClassPrivateFieldSet */); + checkExternalEmitHelpers(target.parent, 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */); } return sourceType; } @@ -79294,59 +79580,59 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 79 /* Identifier */: - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 210 /* TaggedTemplateExpression */: - case 223 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: - case 104 /* NullKeyword */: - case 153 /* UndefinedKeyword */: - case 213 /* FunctionExpression */: - case 226 /* ClassExpression */: - case 214 /* ArrowFunction */: - case 204 /* ArrayLiteralExpression */: - case 205 /* ObjectLiteralExpression */: - case 216 /* TypeOfExpression */: - case 230 /* NonNullExpression */: - case 279 /* JsxSelfClosingElement */: - case 278 /* JsxElement */: + case 79 /* SyntaxKind.Identifier */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: + case 104 /* SyntaxKind.NullKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 213 /* SyntaxKind.FunctionExpression */: + case 226 /* SyntaxKind.ClassExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: + case 230 /* SyntaxKind.NonNullExpression */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 278 /* SyntaxKind.JsxElement */: return true; - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 53 /* ExclamationToken */: - case 39 /* PlusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: + case 53 /* SyntaxKind.ExclamationToken */: + case 39 /* SyntaxKind.PlusToken */: + case 40 /* SyntaxKind.MinusToken */: + case 54 /* SyntaxKind.TildeToken */: return true; } return false; // Some forms listed here for clarity - case 217 /* VoidExpression */: // Explicit opt-out - case 211 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 229 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 217 /* SyntaxKind.VoidExpression */: // Explicit opt-out + case 211 /* SyntaxKind.TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 229 /* SyntaxKind.AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } } function isTypeEqualityComparableTo(source, target) { - return (target.flags & 98304 /* Nullable */) !== 0 || isTypeComparableTo(source, target); + return (target.flags & 98304 /* TypeFlags.Nullable */) !== 0 || isTypeComparableTo(source, target); } function createCheckBinaryExpression() { var trampoline = ts.createBinaryExpressionTrampoline(onEnter, onLeft, onOperator, onRight, onExit, foldState); @@ -79377,9 +79663,9 @@ var ts; } checkGrammarNullishCoalesceWithLogicalExpression(node); var operator = node.operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (node.left.kind === 205 /* ObjectLiteralExpression */ || node.left.kind === 204 /* ArrayLiteralExpression */)) { + if (operator === 63 /* SyntaxKind.EqualsToken */ && (node.left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || node.left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { state.skip = true; - setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* ThisKeyword */)); + setLastResult(state, checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 108 /* SyntaxKind.ThisKeyword */)); return state; } return state; @@ -79396,9 +79682,13 @@ var ts; setLeftType(state, leftType); setLastResult(state, /*type*/ undefined); var operator = operatorToken.kind; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { - if (operator === 55 /* AmpersandAmpersandToken */) { - var parent = ts.walkUpParenthesizedExpressions(node.parent); + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */) { + var parent = node.parent; + while (parent.kind === 212 /* SyntaxKind.ParenthesizedExpression */ + || ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */)) { + parent = parent.parent; + } checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined); } checkTruthinessOfType(leftType, node.left); @@ -79457,11 +79747,11 @@ var ts; } function checkGrammarNullishCoalesceWithLogicalExpression(node) { var left = node.left, operatorToken = node.operatorToken, right = node.right; - if (operatorToken.kind === 60 /* QuestionQuestionToken */) { - if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || left.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } - if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || right.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */)) { grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); } } @@ -79470,11 +79760,11 @@ var ts; // expression-wide checks and does not use a work stack to fold nested binary expressions into the same callstack frame function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 63 /* EqualsToken */ && (left.kind === 205 /* ObjectLiteralExpression */ || left.kind === 204 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* ThisKeyword */); + if (operator === 63 /* SyntaxKind.EqualsToken */ && (left.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || left.kind === 204 /* SyntaxKind.ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 108 /* SyntaxKind.ThisKeyword */); } var leftType; - if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { + if (operator === 55 /* SyntaxKind.AmpersandAmpersandToken */ || operator === 56 /* SyntaxKind.BarBarToken */ || operator === 60 /* SyntaxKind.QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -79486,28 +79776,28 @@ var ts; function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) { var operator = operatorToken.kind; switch (operator) { - case 41 /* AsteriskToken */: - case 42 /* AsteriskAsteriskToken */: - case 66 /* AsteriskEqualsToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - case 43 /* SlashToken */: - case 68 /* SlashEqualsToken */: - case 44 /* PercentToken */: - case 69 /* PercentEqualsToken */: - case 40 /* MinusToken */: - case 65 /* MinusEqualsToken */: - case 47 /* LessThanLessThanToken */: - case 70 /* LessThanLessThanEqualsToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 71 /* GreaterThanGreaterThanEqualsToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: + case 41 /* SyntaxKind.AsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 66 /* SyntaxKind.AsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + case 43 /* SyntaxKind.SlashToken */: + case 68 /* SyntaxKind.SlashEqualsToken */: + case 44 /* SyntaxKind.PercentToken */: + case 69 /* SyntaxKind.PercentEqualsToken */: + case 40 /* SyntaxKind.MinusToken */: + case 65 /* SyntaxKind.MinusEqualsToken */: + case 47 /* SyntaxKind.LessThanLessThanToken */: + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -79516,8 +79806,8 @@ var ts; var suggestedOperator = void 0; // if a user tries to apply a bitwise operator to 2 boolean operands // try and return them a helpful suggestion - if ((leftType.flags & 528 /* BooleanLike */) && - (rightType.flags & 528 /* BooleanLike */) && + if ((leftType.flags & 528 /* TypeFlags.BooleanLike */) && + (rightType.flags & 528 /* TypeFlags.BooleanLike */) && (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) { error(errorNode || operatorToken, ts.Diagnostics.The_0_operator_is_not_allowed_for_boolean_types_Consider_using_1_instead, ts.tokenToString(operatorToken.kind), ts.tokenToString(suggestedOperator)); return numberType; @@ -79528,21 +79818,21 @@ var ts; var rightOk = checkArithmeticOperandType(right, rightType, ts.Diagnostics.The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type, /*isAwaitValid*/ true); var resultType_1; // If both are any or unknown, allow operation; assume it will resolve to number - if ((isTypeAssignableToKind(leftType, 3 /* AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* AnyOrUnknown */)) || + if ((isTypeAssignableToKind(leftType, 3 /* TypeFlags.AnyOrUnknown */) && isTypeAssignableToKind(rightType, 3 /* TypeFlags.AnyOrUnknown */)) || // Or, if neither could be bigint, implicit coercion results in a number result - !(maybeTypeOfKind(leftType, 2112 /* BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* BigIntLike */))) { + !(maybeTypeOfKind(leftType, 2112 /* TypeFlags.BigIntLike */) || maybeTypeOfKind(rightType, 2112 /* TypeFlags.BigIntLike */))) { resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); break; - case 42 /* AsteriskAsteriskToken */: - case 67 /* AsteriskAsteriskEqualsToken */: - if (languageVersion < 3 /* ES2016 */) { + case 42 /* SyntaxKind.AsteriskAsteriskToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later); } } @@ -79558,26 +79848,26 @@ var ts; } return resultType_1; } - case 39 /* PlusToken */: - case 64 /* PlusEqualsToken */: + case 39 /* SyntaxKind.PlusToken */: + case 64 /* SyntaxKind.PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } - if (!isTypeAssignableToKind(leftType, 402653316 /* StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* StringLike */)) { + if (!isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */) && !isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */)) { leftType = checkNonNullType(leftType, left); rightType = checkNonNullType(rightType, right); } var resultType = void 0; - if (isTypeAssignableToKind(leftType, 296 /* NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* NumberLike */, /*strict*/ true)) { + if (isTypeAssignableToKind(leftType, 296 /* TypeFlags.NumberLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 296 /* TypeFlags.NumberLike */, /*strict*/ true)) { // Operands of an enum type are treated as having the primitive type Number. // If both operands are of the Number primitive type, the result is of the Number primitive type. resultType = numberType; } - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true) && isTypeAssignableToKind(rightType, 2112 /* TypeFlags.BigIntLike */, /*strict*/ true)) { // If both operands are of the BigInt primitive type, the result is of the BigInt primitive type. resultType = bigintType; } - else if (isTypeAssignableToKind(leftType, 402653316 /* StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* StringLike */, /*strict*/ true)) { + else if (isTypeAssignableToKind(leftType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true) || isTypeAssignableToKind(rightType, 402653316 /* TypeFlags.StringLike */, /*strict*/ true)) { // If one or both operands are of the String primitive type, the result is of the String primitive type. resultType = stringType; } @@ -79595,21 +79885,21 @@ var ts; // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. - var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 402653316 /* StringLike */ | 3 /* AnyOrUnknown */; + var closeEnoughKind_1 = 296 /* TypeFlags.NumberLike */ | 2112 /* TypeFlags.BigIntLike */ | 402653316 /* TypeFlags.StringLike */ | 3 /* TypeFlags.AnyOrUnknown */; reportOperatorError(function (left, right) { return isTypeAssignableToKind(left, closeEnoughKind_1) && isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 64 /* PlusEqualsToken */) { + if (operator === 64 /* SyntaxKind.PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 29 /* LessThanToken */: - case 31 /* GreaterThanToken */: - case 32 /* LessThanEqualsToken */: - case 33 /* GreaterThanEqualsToken */: + case 29 /* SyntaxKind.LessThanToken */: + case 31 /* SyntaxKind.GreaterThanToken */: + case 32 /* SyntaxKind.LessThanEqualsToken */: + case 33 /* SyntaxKind.GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -79618,60 +79908,60 @@ var ts; }); } return booleanType; - case 34 /* EqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: if (ts.isLiteralExpressionOfObject(left) || ts.isLiteralExpressionOfObject(right)) { - var eqType = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */; + var eqType = operator === 34 /* SyntaxKind.EqualsEqualsToken */ || operator === 36 /* SyntaxKind.EqualsEqualsEqualsToken */; error(errorNode, ts.Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value, eqType ? "false" : "true"); } reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 102 /* InstanceOfKeyword */: + case 102 /* SyntaxKind.InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 101 /* InKeyword */: + case 101 /* SyntaxKind.InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 55 /* AmpersandAmpersandToken */: - case 76 /* AmpersandAmpersandEqualsToken */: { - var resultType_2 = getTypeFacts(leftType) & 4194304 /* Truthy */ ? + case 55 /* SyntaxKind.AmpersandAmpersandToken */: + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: { + var resultType_2 = getTypeFacts(leftType) & 4194304 /* TypeFacts.Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - if (operator === 76 /* AmpersandAmpersandEqualsToken */) { + if (operator === 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_2; } - case 56 /* BarBarToken */: - case 75 /* BarBarEqualsToken */: { - var resultType_3 = getTypeFacts(leftType) & 8388608 /* Falsy */ ? - getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* Subtype */) : + case 56 /* SyntaxKind.BarBarToken */: + case 75 /* SyntaxKind.BarBarEqualsToken */: { + var resultType_3 = getTypeFacts(leftType) & 8388608 /* TypeFacts.Falsy */ ? + getUnionType([getNonNullableType(removeDefinitelyFalsyTypes(leftType)), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 75 /* BarBarEqualsToken */) { + if (operator === 75 /* SyntaxKind.BarBarEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_3; } - case 60 /* QuestionQuestionToken */: - case 77 /* QuestionQuestionEqualsToken */: { - var resultType_4 = getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? - getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + case 60 /* SyntaxKind.QuestionQuestionToken */: + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: { + var resultType_4 = getTypeFacts(leftType) & 262144 /* TypeFacts.EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* UnionReduction.Subtype */) : leftType; - if (operator === 77 /* QuestionQuestionEqualsToken */) { + if (operator === 77 /* SyntaxKind.QuestionQuestionEqualsToken */) { checkAssignmentOperator(rightType); } return resultType_4; } - case 63 /* EqualsToken */: - var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; + case 63 /* SyntaxKind.EqualsToken */: + var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* AssignmentDeclarationKind.None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { - if (!(rightType.flags & 524288 /* Object */) || - declKind !== 2 /* ModuleExports */ && - declKind !== 6 /* Prototype */ && + if (!(rightType.flags & 524288 /* TypeFlags.Object */) || + declKind !== 2 /* AssignmentDeclarationKind.ModuleExports */ && + declKind !== 6 /* AssignmentDeclarationKind.Prototype */ && !isEmptyObjectType(rightType) && !isFunctionObjectType(rightType) && - !(ts.getObjectFlags(rightType) & 1 /* Class */)) { + !(ts.getObjectFlags(rightType) & 1 /* ObjectFlags.Class */)) { // don't check assignability of module.exports=, C.prototype=, or expando types because they will necessarily be incomplete checkAssignmentOperator(rightType); } @@ -79681,7 +79971,7 @@ var ts; checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); } - case 27 /* CommaToken */: + case 27 /* SyntaxKind.CommaToken */: if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { var sf = ts.getSourceFileOfNode(left); var sourceText = sf.text; @@ -79699,16 +79989,16 @@ var ts; return ts.Debug.fail(); } function bothAreBigIntLike(left, right) { - return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + return isTypeAssignableToKind(left, 2112 /* TypeFlags.BigIntLike */) && isTypeAssignableToKind(right, 2112 /* TypeFlags.BigIntLike */); } function checkAssignmentDeclaration(kind, rightType) { - if (kind === 2 /* ModuleExports */) { + if (kind === 2 /* AssignmentDeclarationKind.ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { var prop = _a[_i]; var propType = getTypeOfSymbol(prop); - if (propType.symbol && propType.symbol.flags & 32 /* Class */) { + if (propType.symbol && propType.symbol.flags & 32 /* SymbolFlags.Class */) { var name = prop.escapedName; - var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); + var symbol = resolveName(prop.valueDeclaration, name, 788968 /* SymbolFlags.Type */, undefined, name, /*isUse*/ false); if ((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) && symbol.declarations.some(ts.isJSDocTypedefTag)) { addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); @@ -79718,12 +80008,12 @@ var ts; } } function isEvalNode(node) { - return node.kind === 79 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 79 /* SyntaxKind.Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : - maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : + var offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* TypeFlags.ESSymbolLike */) ? left : + maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* TypeFlags.ESSymbolLike */) ? right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -79733,15 +80023,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 51 /* BarToken */: - case 74 /* BarEqualsToken */: - return 56 /* BarBarToken */; - case 52 /* CaretToken */: - case 78 /* CaretEqualsToken */: - return 37 /* ExclamationEqualsEqualsToken */; - case 50 /* AmpersandToken */: - case 73 /* AmpersandEqualsToken */: - return 55 /* AmpersandAmpersandToken */; + case 51 /* SyntaxKind.BarToken */: + case 74 /* SyntaxKind.BarEqualsToken */: + return 56 /* SyntaxKind.BarBarToken */; + case 52 /* SyntaxKind.CaretToken */: + case 78 /* SyntaxKind.CaretEqualsToken */: + return 37 /* SyntaxKind.ExclamationEqualsEqualsToken */; + case 50 /* SyntaxKind.AmpersandToken */: + case 73 /* SyntaxKind.AmpersandEqualsToken */: + return 55 /* SyntaxKind.AmpersandAmpersandToken */; default: return undefined; } @@ -79760,7 +80050,7 @@ var ts; if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { var headMessage = void 0; - if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* Undefined */)) { + if (exactOptionalPropertyTypes && ts.isPropertyAccessExpression(left) && maybeTypeOfKind(valueType, 32768 /* TypeFlags.Undefined */)) { var target = getTypeOfPropertyOfType(getTypeOfExpression(left.expression), left.name.escapedText); if (isExactOptionalPropertyMismatch(valueType, target)) { headMessage = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_type_of_the_target; @@ -79774,13 +80064,13 @@ var ts; function isAssignmentDeclaration(kind) { var _a; switch (kind) { - case 2 /* ModuleExports */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: return true; - case 1 /* ExportsProperty */: - case 5 /* Property */: - case 6 /* Prototype */: - case 3 /* PrototypeProperty */: - case 4 /* ThisProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 5 /* AssignmentDeclarationKind.Property */: + case 6 /* AssignmentDeclarationKind.Prototype */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: var symbol = getSymbolOfNode(left); var init = ts.getAssignedExpandoInitializer(right); return !!init && ts.isObjectLiteralExpression(init) && @@ -79823,12 +80113,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 36 /* EqualsEqualsEqualsToken */: - case 34 /* EqualsEqualsToken */: + case 36 /* SyntaxKind.EqualsEqualsEqualsToken */: + case 34 /* SyntaxKind.EqualsEqualsToken */: typeName = "false"; break; - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: + case 37 /* SyntaxKind.ExclamationEqualsEqualsToken */: + case 35 /* SyntaxKind.ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -79854,20 +80144,20 @@ var ts; if (!func) return anyType; var functionFlags = ts.getFunctionFlags(func); - if (!(functionFlags & 1 /* Generator */)) { + if (!(functionFlags & 1 /* FunctionFlags.Generator */)) { // If the user's code is syntactically correct, the func should always have a star. After all, we are in a yield context. return anyType; } - var isAsync = (functionFlags & 2 /* Async */) !== 0; + var isAsync = (functionFlags & 2 /* FunctionFlags.Async */) !== 0; if (node.asteriskToken) { // Async generator functions prior to ESNext require the __await, __asyncDelegator, // and __asyncValues helpers - if (isAsync && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 26624 /* AsyncDelegatorIncludes */); + if (isAsync && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 26624 /* ExternalEmitHelpers.AsyncDelegatorIncludes */); } // Generator functions prior to ES2015 require the __values helper - if (!isAsync && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 256 /* Values */); + if (!isAsync && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.Values */); } } // There is no point in doing an assignability check if the function @@ -79884,20 +80174,20 @@ var ts; checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression); } if (node.asteriskToken) { - var use = isAsync ? 19 /* AsyncYieldStar */ : 17 /* YieldStar */; - return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression) + var use = isAsync ? 19 /* IterationUse.AsyncYieldStar */ : 17 /* IterationUse.YieldStar */; + return getIterationTypeOfIterable(use, 1 /* IterationTypeKind.Return */, yieldExpressionType, node.expression) || anyType; } else if (returnType) { - return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync) + return getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, isAsync) || anyType; } - var type = getContextualIterationType(2 /* Next */, func); + var type = getContextualIterationType(2 /* IterationTypeKind.Next */, func); if (!type) { type = anyType; addLazyDiagnostic(function () { if (noImplicitAny && !ts.expressionResultIsUnused(node)) { - var contextualType = getContextualType(node); + var contextualType = getContextualType(node, /*contextFlags*/ undefined); if (!contextualType || isTypeAny(contextualType)) { error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation); } @@ -79906,7 +80196,7 @@ var ts; } return type; function checkYieldExpressionGrammar() { - if (!(node.flags & 8192 /* YieldContext */)) { + if (!(node.flags & 8192 /* NodeFlags.YieldContext */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -79919,7 +80209,7 @@ var ts; checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); - return getUnionType([type1, type2], 2 /* Subtype */); + return getUnionType([type1, type2], 2 /* UnionReduction.Subtype */); } function isTemplateLiteralContext(node) { var parent = node.parent; @@ -79932,20 +80222,20 @@ var ts; for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) { var span = _a[_i]; var type = checkExpression(span.expression); - if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* ESSymbolLike */)) { + if (maybeTypeOfKindConsideringBaseConstraint(type, 12288 /* TypeFlags.ESSymbolLike */)) { error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String); } texts.push(span.literal.text); types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType); } - return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; + return isConstContext(node) || isTemplateLiteralContext(node) || someType(getContextualType(node, /*contextFlags*/ undefined) || unknownType, isTemplateLiteralContextualType) ? getTemplateLiteralType(texts, types) : stringType; } function isTemplateLiteralContextualType(type) { - return !!(type.flags & (128 /* StringLiteral */ | 134217728 /* TemplateLiteral */) || - type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* StringLike */)); + return !!(type.flags & (128 /* TypeFlags.StringLiteral */ | 134217728 /* TypeFlags.TemplateLiteral */) || + type.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 402653316 /* TypeFlags.StringLike */)); } function getContextNode(node) { - if (node.kind === 286 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 286 /* SyntaxKind.JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -79957,7 +80247,7 @@ var ts; try { context.contextualType = contextualType; context.inferenceContext = inferenceContext; - var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0)); + var type = checkExpression(node, checkMode | 1 /* CheckMode.Contextual */ | (inferenceContext ? 2 /* CheckMode.Inferential */ : 0)); // In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type // parameters. This information is no longer needed after the call to checkExpression. if (inferenceContext && inferenceContext.intraExpressionInferenceSites) { @@ -79966,7 +80256,7 @@ var ts; // We strip literal freshness when an appropriate contextual type is present such that contextually typed // literals always preserve their literal types (otherwise they might widen during type inference). An alternative // here would be to not mark contextually typed literals as fresh in the first place. - var result = maybeTypeOfKind(type, 2944 /* Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ? + var result = maybeTypeOfKind(type, 2944 /* TypeFlags.Literal */) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node, /*contextFlags*/ undefined)) ? getRegularTypeOfLiteralType(type) : type; return result; } @@ -79979,7 +80269,7 @@ var ts; } } function checkExpressionCached(node, checkMode) { - if (checkMode && checkMode !== 0 /* Normal */) { + if (checkMode && checkMode !== 0 /* CheckMode.Normal */) { return checkExpression(node, checkMode); } var links = getNodeLinks(node); @@ -79999,17 +80289,17 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node, /*excludeJSDocTypeAssertions*/ true); - return node.kind === 211 /* TypeAssertionExpression */ || - node.kind === 229 /* AsExpression */ || + return node.kind === 211 /* SyntaxKind.TypeAssertionExpression */ || + node.kind === 229 /* SyntaxKind.AsExpression */ || ts.isJSDocTypeAssertion(node); } function checkDeclarationInitializer(declaration, checkMode, contextualType) { var initializer = ts.getEffectiveInitializer(declaration); var type = getQuickTypeOfExpression(initializer) || (contextualType ? - checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* Normal */) + checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || 0 /* CheckMode.Normal */) : checkExpressionCached(initializer, checkMode)); - return ts.isParameter(declaration) && declaration.name.kind === 202 /* ArrayBindingPattern */ && + return ts.isParameter(declaration) && declaration.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; } @@ -80019,9 +80309,9 @@ var ts; var elementFlags = type.target.elementFlags.slice(); for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 203 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 203 /* SyntaxKind.BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); - elementFlags.push(2 /* Optional */); + elementFlags.push(2 /* ElementFlags.Optional */); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); } @@ -80030,7 +80320,7 @@ var ts; return createTupleType(elementTypes, elementFlags, type.target.readonly); } function widenTypeInferredFromInitializer(declaration, type) { - var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); + var widened = ts.getCombinedNodeFlags(declaration) & 2 /* NodeFlags.Const */ || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (ts.isInJSFile(declaration)) { if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); @@ -80045,28 +80335,28 @@ var ts; } function isLiteralOfContextualType(candidateType, contextualType) { if (contextualType) { - if (contextualType.flags & 3145728 /* UnionOrIntersection */) { + if (contextualType.flags & 3145728 /* TypeFlags.UnionOrIntersection */) { var types = contextualType.types; return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); }); } - if (contextualType.flags & 58982400 /* InstantiableNonPrimitive */) { + if (contextualType.flags & 58982400 /* TypeFlags.InstantiableNonPrimitive */) { // If the contextual type is a type variable constrained to a primitive type, consider // this a literal context for literals of that primitive type. For example, given a // type parameter 'T extends string', infer string literal types for T. var constraint = getBaseConstraintOfType(contextualType) || unknownType; - return maybeTypeOfKind(constraint, 4 /* String */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - maybeTypeOfKind(constraint, 8 /* Number */) && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - maybeTypeOfKind(constraint, 64 /* BigInt */) && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - maybeTypeOfKind(constraint, 4096 /* ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */) || + return maybeTypeOfKind(constraint, 4 /* TypeFlags.String */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + maybeTypeOfKind(constraint, 8 /* TypeFlags.Number */) && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + maybeTypeOfKind(constraint, 64 /* TypeFlags.BigInt */) && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + maybeTypeOfKind(constraint, 4096 /* TypeFlags.ESSymbol */) && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */) || isLiteralOfContextualType(candidateType, constraint); } // If the contextual type is a literal of a particular primitive type, we consider this a // literal context for all literals of that primitive type. - return !!(contextualType.flags & (128 /* StringLiteral */ | 4194304 /* Index */ | 134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */) && maybeTypeOfKind(candidateType, 128 /* StringLiteral */) || - contextualType.flags & 256 /* NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* NumberLiteral */) || - contextualType.flags & 2048 /* BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* BigIntLiteral */) || - contextualType.flags & 512 /* BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* BooleanLiteral */) || - contextualType.flags & 8192 /* UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* UniqueESSymbol */)); + return !!(contextualType.flags & (128 /* TypeFlags.StringLiteral */ | 4194304 /* TypeFlags.Index */ | 134217728 /* TypeFlags.TemplateLiteral */ | 268435456 /* TypeFlags.StringMapping */) && maybeTypeOfKind(candidateType, 128 /* TypeFlags.StringLiteral */) || + contextualType.flags & 256 /* TypeFlags.NumberLiteral */ && maybeTypeOfKind(candidateType, 256 /* TypeFlags.NumberLiteral */) || + contextualType.flags & 2048 /* TypeFlags.BigIntLiteral */ && maybeTypeOfKind(candidateType, 2048 /* TypeFlags.BigIntLiteral */) || + contextualType.flags & 512 /* TypeFlags.BooleanLiteral */ && maybeTypeOfKind(candidateType, 512 /* TypeFlags.BooleanLiteral */) || + contextualType.flags & 8192 /* TypeFlags.UniqueESSymbol */ && maybeTypeOfKind(candidateType, 8192 /* TypeFlags.UniqueESSymbol */)); } return false; } @@ -80081,13 +80371,13 @@ var ts; var type = checkExpression(node, checkMode, forceTuple); return isConstContext(node) || ts.isCommonJsExportedExpression(node) ? getRegularTypeOfLiteralType(type) : isTypeAssertion(node) ? type : - getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node)); + getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node, /*contextFlags*/ undefined) : contextualType, node, /*contextFlags*/ undefined)); } function checkPropertyAssignment(node, checkMode) { // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -80098,23 +80388,23 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { - if (checkMode && checkMode & (2 /* Inferential */ | 8 /* SkipGenericFunctions */)) { - var callSignature = getSingleSignature(type, 0 /* Call */, /*allowMembers*/ true); - var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); + if (checkMode && checkMode & (2 /* CheckMode.Inferential */ | 8 /* CheckMode.SkipGenericFunctions */)) { + var callSignature = getSingleSignature(type, 0 /* SignatureKind.Call */, /*allowMembers*/ true); + var constructSignature = getSingleSignature(type, 1 /* SignatureKind.Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + var contextualType = getApparentTypeOfContextualType(node, 2 /* ContextFlags.NoConstraints */); if (contextualType) { - var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); + var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* SignatureKind.Call */ : 1 /* SignatureKind.Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { - if (checkMode & 8 /* SkipGenericFunctions */) { + if (checkMode & 8 /* CheckMode.SkipGenericFunctions */) { skippedGenericFunction(node, checkMode); return anyFunctionType; } @@ -80162,11 +80452,11 @@ var ts; return type; } function skippedGenericFunction(node, checkMode) { - if (checkMode & 2 /* Inferential */) { + if (checkMode & 2 /* CheckMode.Inferential */) { // We have skipped a generic function during inferential typing. Obtain the inference context and // indicate this has occurred such that we know a second pass of inference is be needed. var context = getInferenceContext(node); - context.flags |= 4 /* SkippedGenericFunction */; + context.flags |= 4 /* InferenceFlags.SkippedGenericFunction */; } } function hasInferenceCandidates(info) { @@ -80191,12 +80481,12 @@ var ts; var result = []; var oldTypeParameters; var newTypeParameters; - for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) { - var tp = typeParameters_2[_i]; + for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { + var tp = typeParameters_3[_i]; var name = tp.symbol.escapedName; if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) { var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name); - var symbol = createSymbol(262144 /* TypeParameter */, newName); + var symbol = createSymbol(262144 /* SymbolFlags.TypeParameter */, newName); var newTypeParameter = createTypeParameter(symbol); newTypeParameter.target = tp; oldTypeParameters = ts.append(oldTypeParameters, tp); @@ -80221,7 +80511,7 @@ var ts; } function getUniqueTypeParameterName(typeParameters, baseName) { var len = baseName.length; - while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* _0 */ && baseName.charCodeAt(len - 1) <= 57 /* _9 */) + while (len > 1 && baseName.charCodeAt(len - 1) >= 48 /* CharacterCodes._0 */ && baseName.charCodeAt(len - 1) <= 57 /* CharacterCodes._9 */) len--; var s = baseName.slice(0, len); for (var index = 1; true; index++) { @@ -80254,7 +80544,7 @@ var ts; return quickType; } // If a type has been cached for the node, return it. - if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) { + if (node.flags & 134217728 /* NodeFlags.TypeCached */ && flowTypeCache) { var cachedType = flowTypeCache[getNodeId(node)]; if (cachedType) { return cachedType; @@ -80266,7 +80556,7 @@ var ts; if (flowInvocationCount !== startInvocationCount) { var cache = flowTypeCache || (flowTypeCache = []); cache[getNodeId(node)] = type; - ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */); + ts.setNodeFlags(node, node.flags | 134217728 /* NodeFlags.TypeCached */); } return type; } @@ -80281,7 +80571,7 @@ var ts; expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + if (ts.isCallExpression(expr) && expr.expression.kind !== 106 /* SyntaxKind.SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) : getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression)); if (type) { @@ -80291,8 +80581,8 @@ var ts; else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { return getTypeFromTypeNode(expr.type); } - else if (node.kind === 8 /* NumericLiteral */ || node.kind === 10 /* StringLiteral */ || - node.kind === 110 /* TrueKeyword */ || node.kind === 95 /* FalseKeyword */) { + else if (node.kind === 8 /* SyntaxKind.NumericLiteral */ || node.kind === 10 /* SyntaxKind.StringLiteral */ || + node.kind === 110 /* SyntaxKind.TrueKeyword */ || node.kind === 95 /* SyntaxKind.FalseKeyword */) { return checkExpression(node); } return undefined; @@ -80312,7 +80602,7 @@ var ts; var saveContextualType = node.contextualType; node.contextualType = anyType; try { - var type = links.contextFreeType = checkExpression(node, 4 /* SkipContextSensitive */); + var type = links.contextFreeType = checkExpression(node, 4 /* CheckMode.SkipContextSensitive */); return type; } finally { @@ -80323,7 +80613,7 @@ var ts; } } function checkExpression(node, checkMode, forceTuple) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkExpression", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; @@ -80341,18 +80631,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 206 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 207 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 79 /* Identifier */ || node.kind === 161 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 181 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 275 /* ExportSpecifier */); // We allow reexporting const enums + var ok = (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 207 /* SyntaxKind.ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 79 /* SyntaxKind.Identifier */ || node.kind === 161 /* SyntaxKind.QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 181 /* SyntaxKind.TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 275 /* SyntaxKind.ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { - ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); + ts.Debug.assert(!!(type.symbol.flags & 128 /* SymbolFlags.ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 16777216 /* Ambient */) { + if (constEnumDeclaration.flags & 16777216 /* NodeFlags.Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -80370,113 +80660,113 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 226 /* ClassExpression */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 226 /* SyntaxKind.ClassExpression */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return checkIdentifier(node, checkMode); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return checkPrivateIdentifierExpression(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return checkThisExpression(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkSuperExpression(node); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return nullWideningType; - case 14 /* NoSubstitutionTemplateLiteral */: - case 10 /* StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getFreshTypeOfLiteralType(getStringLiteralType(node.text)); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(node); return getFreshTypeOfLiteralType(getNumberLiteralType(+node.text)); - case 9 /* BigIntLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType({ negative: false, base10Value: ts.parsePseudoBigInt(node.text) })); - case 110 /* TrueKeyword */: + case 110 /* SyntaxKind.TrueKeyword */: return trueType; - case 95 /* FalseKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return falseType; - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return checkTemplateExpression(node); - case 13 /* RegularExpressionLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: return globalRegExpType; - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return checkPropertyAccessExpression(node, checkMode); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return checkQualifiedName(node, checkMode); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return checkIndexedAccess(node, checkMode); - case 208 /* CallExpression */: - if (node.expression.kind === 100 /* ImportKeyword */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.expression.kind === 100 /* SyntaxKind.ImportKeyword */) { return checkImportCallExpression(node); } // falls through - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return checkCallExpression(node, checkMode); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return checkClassExpression(node); - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return checkTypeOfExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: return checkAssertion(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return checkNonNullAssertion(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return checkExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkMetaProperty(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return checkDeleteExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return checkVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return checkAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return checkSpreadExpression(node, checkMode); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return undefinedWideningType; - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return checkYieldExpression(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return checkSyntheticExpression(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return checkJsxExpression(node, checkMode); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return checkJsxElement(node, checkMode); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return checkJsxFragment(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -80510,16 +80800,18 @@ var ts; var modifiers = getVarianceModifiers(typeParameter); if (modifiers) { var symbol = getSymbolOfNode(node.parent); - if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* Anonymous */ | 32 /* Mapped */))) { + if (ts.isTypeAliasDeclaration(node.parent) && !(ts.getObjectFlags(getDeclaredTypeOfSymbol(symbol)) & (16 /* ObjectFlags.Anonymous */ | 32 /* ObjectFlags.Mapped */))) { error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types); } - else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) { - var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubType : markerSuperType); - var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperType : markerSubType); + else if (modifiers === 32768 /* ModifierFlags.In */ || modifiers === 65536 /* ModifierFlags.Out */) { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) }); + var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck); + var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* ModifierFlags.Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck); var saveVarianceTypeParameter = typeParameter; varianceTypeParameter = typeParameter; checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation); varianceTypeParameter = saveVarianceTypeParameter; + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } } } @@ -80532,28 +80824,28 @@ var ts; checkGrammarDecoratorsAndModifiers(node); checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); - if (ts.hasSyntacticModifier(node, 16476 /* ParameterPropertyModifier */)) { - if (!(func.kind === 171 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (ts.hasSyntacticModifier(node, 16476 /* ModifierFlags.ParameterPropertyModifier */)) { + if (!(func.kind === 171 /* SyntaxKind.Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } - if (func.kind === 171 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + if (func.kind === 171 /* SyntaxKind.Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); } } - if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { + if ((node.questionToken || isJSDocOptionalParameter(node)) && ts.isBindingPattern(node.name) && func.body) { error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); } if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) { if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 171 /* Constructor */ || func.kind === 175 /* ConstructSignature */ || func.kind === 180 /* ConstructorType */) { + if (func.kind === 171 /* SyntaxKind.Constructor */ || func.kind === 175 /* SyntaxKind.ConstructSignature */ || func.kind === 180 /* SyntaxKind.ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 214 /* ArrowFunction */) { + if (func.kind === 214 /* SyntaxKind.ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } - if (func.kind === 172 /* GetAccessor */ || func.kind === 173 /* SetAccessor */) { + if (func.kind === 172 /* SyntaxKind.GetAccessor */ || func.kind === 173 /* SyntaxKind.SetAccessor */) { error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); } } @@ -80577,7 +80869,7 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { + if (typePredicate.kind === 0 /* TypePredicateKind.This */ || typePredicate.kind === 2 /* TypePredicateKind.AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { @@ -80611,13 +80903,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 214 /* ArrowFunction */: - case 174 /* CallSignature */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 179 /* FunctionType */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 214 /* SyntaxKind.ArrowFunction */: + case 174 /* SyntaxKind.CallSignature */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 179 /* SyntaxKind.FunctionType */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -80631,11 +80923,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 79 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 79 /* SyntaxKind.Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 202 /* ArrayBindingPattern */ || name.kind === 201 /* ObjectBindingPattern */) { + else if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ || name.kind === 201 /* SyntaxKind.ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -80644,29 +80936,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 176 /* IndexSignature */) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 179 /* FunctionType */ || node.kind === 256 /* FunctionDeclaration */ || node.kind === 180 /* ConstructorType */ || - node.kind === 174 /* CallSignature */ || node.kind === 171 /* Constructor */ || - node.kind === 175 /* ConstructSignature */) { + else if (node.kind === 179 /* SyntaxKind.FunctionType */ || node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 180 /* SyntaxKind.ConstructorType */ || + node.kind === 174 /* SyntaxKind.CallSignature */ || node.kind === 171 /* SyntaxKind.Constructor */ || + node.kind === 175 /* SyntaxKind.ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); - if (!(functionFlags & 4 /* Invalid */)) { + if (!(functionFlags & 4 /* FunctionFlags.Invalid */)) { // Async generators prior to ESNext require the __await and __asyncGenerator helpers - if ((functionFlags & 3 /* AsyncGenerator */) === 3 /* AsyncGenerator */ && languageVersion < 99 /* ESNext */) { - checkExternalEmitHelpers(node, 6144 /* AsyncGeneratorIncludes */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 3 /* FunctionFlags.AsyncGenerator */ && languageVersion < 99 /* ScriptTarget.ESNext */) { + checkExternalEmitHelpers(node, 6144 /* ExternalEmitHelpers.AsyncGeneratorIncludes */); } // Async functions prior to ES2017 require the __awaiter helper - if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { - checkExternalEmitHelpers(node, 64 /* Awaiter */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */ && languageVersion < 4 /* ScriptTarget.ES2017 */) { + checkExternalEmitHelpers(node, 64 /* ExternalEmitHelpers.Awaiter */); } // Generator functions, Async functions, and Async Generator functions prior to // ES2015 require the __generator helper - if ((functionFlags & 3 /* AsyncGenerator */) !== 0 /* Normal */ && languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(node, 128 /* Generator */); + if ((functionFlags & 3 /* FunctionFlags.AsyncGenerator */) !== 0 /* FunctionFlags.Normal */ && languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(node, 128 /* ExternalEmitHelpers.Generator */); } } checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node)); @@ -80682,17 +80974,17 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (returnTypeNode) { var functionFlags_1 = ts.getFunctionFlags(node); - if ((functionFlags_1 & (4 /* Invalid */ | 1 /* Generator */)) === 1 /* Generator */) { + if ((functionFlags_1 & (4 /* FunctionFlags.Invalid */ | 1 /* FunctionFlags.Generator */)) === 1 /* FunctionFlags.Generator */) { var returnType = getTypeFromTypeNode(returnTypeNode); if (returnType === voidType) { error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -80704,18 +80996,18 @@ var ts; // interface BadGenerator extends Iterable, Iterator { } // function* g(): BadGenerator { } // Iterable and Iterator have different types! // - var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* Yield */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; - var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || generatorYieldType; - var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, (functionFlags_1 & 2 /* Async */) !== 0) || unknownType; - var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* Async */)); + var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0 /* IterationTypeKind.Yield */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || anyType; + var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || generatorYieldType; + var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2 /* IterationTypeKind.Next */, returnType, (functionFlags_1 & 2 /* FunctionFlags.Async */) !== 0) || unknownType; + var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2 /* FunctionFlags.Async */)); checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode); } } - else if ((functionFlags_1 & 3 /* AsyncGenerator */) === 2 /* Async */) { + else if ((functionFlags_1 & 3 /* FunctionFlags.AsyncGenerator */) === 2 /* FunctionFlags.Async */) { checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 176 /* IndexSignature */ && node.kind !== 317 /* JSDocFunctionType */) { + if (node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 317 /* SyntaxKind.JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -80727,11 +81019,11 @@ var ts; var privateIdentifiers = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 171 /* Constructor */) { + if (member.kind === 171 /* SyntaxKind.Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { - addName(instanceNames, param.name, param.name.escapedText, 3 /* GetOrSetAccessor */); + addName(instanceNames, param.name, param.name.escapedText, 3 /* DeclarationMeaning.GetOrSetAccessor */); } } } @@ -80742,24 +81034,24 @@ var ts; continue; } var isPrivate = ts.isPrivateIdentifier(name); - var privateStaticFlags = isPrivate && isStaticMember ? 16 /* PrivateStatic */ : 0; + var privateStaticFlags = isPrivate && isStaticMember ? 16 /* DeclarationMeaning.PrivateStatic */ : 0; var names = isPrivate ? privateIdentifiers : isStaticMember ? staticNames : instanceNames; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (memberName) { switch (member.kind) { - case 172 /* GetAccessor */: - addName(names, name, memberName, 1 /* GetAccessor */ | privateStaticFlags); + case 172 /* SyntaxKind.GetAccessor */: + addName(names, name, memberName, 1 /* DeclarationMeaning.GetAccessor */ | privateStaticFlags); break; - case 173 /* SetAccessor */: - addName(names, name, memberName, 2 /* SetAccessor */ | privateStaticFlags); + case 173 /* SyntaxKind.SetAccessor */: + addName(names, name, memberName, 2 /* DeclarationMeaning.SetAccessor */ | privateStaticFlags); break; - case 167 /* PropertyDeclaration */: - addName(names, name, memberName, 3 /* GetOrSetAccessor */ | privateStaticFlags); + case 167 /* SyntaxKind.PropertyDeclaration */: + addName(names, name, memberName, 3 /* DeclarationMeaning.GetOrSetAccessor */ | privateStaticFlags); break; - case 169 /* MethodDeclaration */: - addName(names, name, memberName, 8 /* Method */ | privateStaticFlags); + case 169 /* SyntaxKind.MethodDeclaration */: + addName(names, name, memberName, 8 /* DeclarationMeaning.Method */ | privateStaticFlags); break; } } @@ -80769,19 +81061,19 @@ var ts; var prev = names.get(name); if (prev) { // For private identifiers, do not allow mixing of static and instance members with the same name - if ((prev & 16 /* PrivateStatic */) !== (meaning & 16 /* PrivateStatic */)) { + if ((prev & 16 /* DeclarationMeaning.PrivateStatic */) !== (meaning & 16 /* DeclarationMeaning.PrivateStatic */)) { error(location, ts.Diagnostics.Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name, ts.getTextOfNode(location)); } else { - var prevIsMethod = !!(prev & 8 /* Method */); - var isMethod = !!(meaning & 8 /* Method */); + var prevIsMethod = !!(prev & 8 /* DeclarationMeaning.Method */); + var isMethod = !!(meaning & 8 /* DeclarationMeaning.Method */); if (prevIsMethod || isMethod) { if (prevIsMethod !== isMethod) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered } - else if (prev & meaning & ~16 /* PrivateStatic */) { + else if (prev & meaning & ~16 /* DeclarationMeaning.PrivateStatic */) { error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location)); } else { @@ -80830,15 +81122,15 @@ var ts; var names = new ts.Map(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 166 /* PropertySignature */) { + if (member.kind === 166 /* SyntaxKind.PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { - case 10 /* StringLiteral */: - case 8 /* NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: memberName = name.text; break; - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: memberName = ts.idText(name); break; default: @@ -80855,7 +81147,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -80869,7 +81161,7 @@ var ts; var indexSymbol = getIndexSymbol(getSymbolOfNode(node)); if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) { var indexSignatureMap_1 = new ts.Map(); - var _loop_28 = function (declaration) { + var _loop_29 = function (declaration) { if (declaration.parameters.length === 1 && declaration.parameters[0].type) { forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) { var entry = indexSignatureMap_1.get(getTypeId(type)); @@ -80884,7 +81176,7 @@ var ts; }; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - _loop_28(declaration); + _loop_29(declaration); } indexSignatureMap_1.forEach(function (entry) { if (entry.declarations.length > 1) { @@ -80903,7 +81195,7 @@ var ts; checkVariableLikeDeclaration(node); setNodeLinksForPrivateIdentifierScope(node); // property signatures already report "initializer not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 167 /* PropertyDeclaration */ && node.initializer) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && node.initializer) { error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -80923,7 +81215,7 @@ var ts; // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionOrMethodDeclaration(node); // method signatures already report "implementation not allowed in ambient context" elsewhere - if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 169 /* MethodDeclaration */ && node.body) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */) && node.kind === 169 /* SyntaxKind.MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } // Private named methods are only allowed in class declarations @@ -80933,9 +81225,9 @@ var ts; setNodeLinksForPrivateIdentifierScope(node); } function setNodeLinksForPrivateIdentifierScope(node) { - if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ESNext */) { + if (ts.isPrivateIdentifier(node.name) && languageVersion < 99 /* ScriptTarget.ESNext */) { for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) { - getNodeLinks(lexicalScope).flags |= 67108864 /* ContainsClassWithPrivateIdentifiers */; + getNodeLinks(lexicalScope).flags |= 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */; } // If this is a private element in a class expression inside the body of a loop, // then we must use a block-scoped binding to store the additional variables required @@ -80943,8 +81235,8 @@ var ts; if (ts.isClassExpression(node.parent)) { var enclosingIterationStatement = getEnclosingIterationStatement(node.parent); if (enclosingIterationStatement) { - getNodeLinks(node.name).flags |= 524288 /* BlockScopedBindingInLoop */; - getNodeLinks(enclosingIterationStatement).flags |= 65536 /* LoopWithCapturedBlockScopedBinding */; + getNodeLinks(node.name).flags |= 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + getNodeLinks(enclosingIterationStatement).flags |= 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */; } } } @@ -80976,7 +81268,7 @@ var ts; if (ts.isPrivateIdentifierClassElementDeclaration(n)) { return true; } - return n.kind === 167 /* PropertyDeclaration */ && + return n.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.isStatic(n) && !!n.initializer; } @@ -80997,9 +81289,9 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && + var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ScriptTarget.ESNext */ || !useDefineForClassFields) && (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); })); + ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ModifierFlags.ParameterPropertyModifier */); })); if (superCallShouldBeRootLevel) { // Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional // See GH #8277 @@ -81038,7 +81330,7 @@ var ts; return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body; } function nodeImmediatelyReferencesSuperOrThis(node) { - if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */ || node.kind === 108 /* SyntaxKind.ThisKeyword */) { return true; } if (ts.isThisContainerOrFunctionBlock(node)) { @@ -81059,9 +81351,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 172 /* GetAccessor */) { - if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { - if (!(node.flags & 512 /* HasExplicitReturn */)) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* NodeFlags.HasImplicitReturn */)) { + if (!(node.flags & 512 /* NodeFlags.HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -81069,25 +81361,25 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (hasBindableName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. var symbol = getSymbolOfNode(node); - var getter = ts.getDeclarationOfKind(symbol, 172 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 173 /* SetAccessor */); - if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* TypeChecked */)) { - getNodeLinks(getter).flags |= 1 /* TypeChecked */; + var getter = ts.getDeclarationOfKind(symbol, 172 /* SyntaxKind.GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 173 /* SyntaxKind.SetAccessor */); + if (getter && setter && !(getNodeCheckFlags(getter) & 1 /* NodeCheckFlags.TypeChecked */)) { + getNodeLinks(getter).flags |= 1 /* NodeCheckFlags.TypeChecked */; var getterFlags = ts.getEffectiveModifierFlags(getter); var setterFlags = ts.getEffectiveModifierFlags(setter); - if ((getterFlags & 128 /* Abstract */) !== (setterFlags & 128 /* Abstract */)) { + if ((getterFlags & 128 /* ModifierFlags.Abstract */) !== (setterFlags & 128 /* ModifierFlags.Abstract */)) { error(getter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); error(setter.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract); } - if (((getterFlags & 16 /* Protected */) && !(setterFlags & (16 /* Protected */ | 8 /* Private */))) || - ((getterFlags & 8 /* Private */) && !(setterFlags & 8 /* Private */))) { + if (((getterFlags & 16 /* ModifierFlags.Protected */) && !(setterFlags & (16 /* ModifierFlags.Protected */ | 8 /* ModifierFlags.Private */))) || + ((getterFlags & 8 /* ModifierFlags.Private */) && !(setterFlags & 8 /* ModifierFlags.Private */))) { error(getter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); error(setter.name, ts.Diagnostics.A_get_accessor_must_be_at_least_as_accessible_as_the_setter); } @@ -81099,7 +81391,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -81107,6 +81399,12 @@ var ts; function checkMissingDeclaration(node) { checkDecorators(node); } + function getEffectiveTypeArgumentAtIndex(node, typeParameters, index) { + if (index < typeParameters.length) { + return getTypeFromTypeNode(node.typeArguments[index]); + } + return getEffectiveTypeArguments(node, typeParameters)[index]; + } function getEffectiveTypeArguments(node, typeParameters) { return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node)); } @@ -81131,15 +81429,15 @@ var ts; if (!isErrorType(type)) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - return symbol.flags & 524288 /* TypeAlias */ && getSymbolLinks(symbol).typeParameters || - (ts.getObjectFlags(type) & 4 /* Reference */ ? type.target.localTypeParameters : undefined); + return symbol.flags & 524288 /* SymbolFlags.TypeAlias */ && getSymbolLinks(symbol).typeParameters || + (ts.getObjectFlags(type) & 4 /* ObjectFlags.Reference */ ? type.target.localTypeParameters : undefined); } } return undefined; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 178 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 178 /* SyntaxKind.TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } ts.forEach(node.typeArguments, checkSourceElement); @@ -81155,10 +81453,10 @@ var ts; } var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { - if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) { + if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) { addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName); } - if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) { + if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) { error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type)); } } @@ -81197,29 +81495,29 @@ var ts; var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember); for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) { var e = elementTypes_1[_i]; - if (e.kind !== 197 /* NamedTupleMember */ && hasNamedElement) { + if (e.kind !== 197 /* SyntaxKind.NamedTupleMember */ && hasNamedElement) { grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names); break; } var flags = getTupleElementFlags(e); - if (flags & 8 /* Variadic */) { + if (flags & 8 /* ElementFlags.Variadic */) { var type = getTypeFromTypeNode(e.type); if (!isArrayLikeType(type)) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); break; } - if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* Rest */) { + if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4 /* ElementFlags.Rest */) { seenRestElement = true; } } - else if (flags & 4 /* Rest */) { + else if (flags & 4 /* ElementFlags.Rest */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element); break; } seenRestElement = true; } - else if (flags & 2 /* Optional */) { + else if (flags & 2 /* ElementFlags.Optional */) { if (seenRestElement) { grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element); break; @@ -81239,15 +81537,15 @@ var ts; getTypeFromTypeNode(node); } function checkIndexedAccessIndexType(type, accessNode) { - if (!(type.flags & 8388608 /* IndexedAccess */)) { + if (!(type.flags & 8388608 /* TypeFlags.IndexedAccess */)) { return type; } // Check if the index type is assignable to 'keyof T' for the object type. var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 207 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && - ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { + if (accessNode.kind === 207 /* SyntaxKind.ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + ts.getObjectFlags(objectType) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(objectType) & 1 /* MappedTypeModifiers.IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } return type; @@ -81255,14 +81553,14 @@ var ts; // Check if we're indexing with a numeric type and if either object or index types // is a generic type with a constraint that has a numeric index signature. var apparentObjectType = getApparentType(objectType); - if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* NumberLike */)) { + if (getIndexInfoOfType(apparentObjectType, numberType) && isTypeAssignableToKind(indexType, 296 /* TypeFlags.NumberLike */)) { return type; } if (isGenericObjectType(objectType)) { var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode); if (propertyName_1) { var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); }); - if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* NonPublicAccessibilityModifier */) { + if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24 /* ModifierFlags.NonPublicAccessibilityModifier */) { error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1)); return errorType; } @@ -81311,7 +81609,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 189 /* SyntaxKind.ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -81321,7 +81619,7 @@ var ts; if (!links.typeParametersChecked) { links.typeParametersChecked = true; var typeParameter = getDeclaredTypeOfTypeParameter(symbol); - var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */); + var declarations = ts.getDeclarationsOfKind(symbol, 163 /* SyntaxKind.TypeParameter */); if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) { // Report an error on every conflicting declaration. var name = symbolToString(symbol); @@ -81362,31 +81660,31 @@ var ts; if (node.dotDotDotToken && node.questionToken) { grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest); } - if (node.type.kind === 185 /* OptionalType */) { + if (node.type.kind === 185 /* SyntaxKind.OptionalType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_optional_with_a_question_mark_after_the_name_and_before_the_colon_rather_than_after_the_type); } - if (node.type.kind === 186 /* RestType */) { + if (node.type.kind === 186 /* SyntaxKind.RestType */) { grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type); } checkSourceElement(node.type); getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */); + return (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* NodeFlags.Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 258 /* InterfaceDeclaration */ && - n.parent.kind !== 257 /* ClassDeclaration */ && - n.parent.kind !== 226 /* ClassExpression */ && - n.flags & 16777216 /* Ambient */) { - if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { + if (n.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */ && + n.parent.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + n.parent.kind !== 226 /* SyntaxKind.ClassExpression */ && + n.flags & 16777216 /* NodeFlags.Ambient */) { + if (!(flags & 2 /* ModifierFlags.Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; } return flags & flagsToCheck; } @@ -81411,16 +81709,16 @@ var ts; var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck); ts.forEach(overloads, function (o) { var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1; - if (deviation & 1 /* Export */) { + if (deviation & 1 /* ModifierFlags.Export */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } - else if (deviation & 2 /* Ambient */) { + else if (deviation & 2 /* ModifierFlags.Ambient */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & (8 /* Private */ | 16 /* Protected */)) { + else if (deviation & (8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */)) { error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } - else if (deviation & 128 /* Abstract */) { + else if (deviation & 128 /* ModifierFlags.Abstract */) { error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); @@ -81437,8 +81735,8 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 8 /* Private */ | 16 /* Protected */ | 128 /* Abstract */; - var someNodeFlags = 0 /* None */; + var flagsToCheck = 1 /* ModifierFlags.Export */ | 2 /* ModifierFlags.Ambient */ | 8 /* ModifierFlags.Private */ | 16 /* ModifierFlags.Protected */ | 128 /* ModifierFlags.Abstract */; + var someNodeFlags = 0 /* ModifierFlags.None */; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; var allHaveQuestionToken = true; @@ -81447,7 +81745,7 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* SymbolFlags.Constructor */) !== 0; function reportImplementationExpectedError(node) { if (node.name && ts.nodeIsMissing(node.name)) { return; @@ -81476,7 +81774,7 @@ var ts; // Both are literal property names that are the same. ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */) && + var reportError = (node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */) && ts.isStatic(node) !== ts.isStatic(subsequentNode); // we can get here in two cases // 1. mixed static and instance class members @@ -81501,7 +81799,7 @@ var ts; else { // Report different errors regarding non-consecutive blocks of declarations depending on whether // the node in question is abstract. - if (ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); } else { @@ -81517,8 +81815,8 @@ var ts; for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { var current = declarations_5[_i]; var node = current; - var inAmbientContext = node.flags & 16777216 /* Ambient */; - var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; + var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -81529,10 +81827,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 257 /* ClassDeclaration */ || node.kind === 226 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 226 /* SyntaxKind.ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 256 /* FunctionDeclaration */ || node.kind === 169 /* MethodDeclaration */ || node.kind === 168 /* MethodSignature */ || node.kind === 171 /* Constructor */) { + if (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 169 /* SyntaxKind.MethodDeclaration */ || node.kind === 168 /* SyntaxKind.MethodSignature */ || node.kind === 171 /* SyntaxKind.Constructor */) { functionDeclarations.push(node); var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; @@ -81576,13 +81874,13 @@ var ts; error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation); }); } - if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* Function */ && declarations) { - var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* ClassDeclaration */; }) + if (hasNonAmbientClass && !isConstructor && symbol.flags & 16 /* SymbolFlags.Function */ && declarations) { + var relatedDiagnostics_1 = ts.filter(declarations, function (d) { return d.kind === 257 /* SyntaxKind.ClassDeclaration */; }) .map(function (d) { return ts.createDiagnosticForNode(d, ts.Diagnostics.Consider_adding_a_declare_modifier_to_this_class); }); ts.forEach(declarations, function (declaration) { - var diagnostic = declaration.kind === 257 /* ClassDeclaration */ + var diagnostic = declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ ? ts.Diagnostics.Class_declaration_cannot_implement_overload_list_for_0 - : declaration.kind === 256 /* FunctionDeclaration */ + : declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ ? ts.Diagnostics.Function_with_bodies_can_only_merge_with_classes_that_are_ambient : undefined; if (diagnostic) { @@ -81592,7 +81890,7 @@ var ts; } // Abstract methods can't have an implementation -- in particular, they don't need one. if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && - !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { + !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128 /* ModifierFlags.Abstract */) && !lastSeenNonAmbientDeclaration.questionToken) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -81632,15 +81930,15 @@ var ts; if (ts.getDeclarationOfKind(symbol, node.kind) !== node) { return; } - var exportedDeclarationSpaces = 0 /* None */; - var nonExportedDeclarationSpaces = 0 /* None */; - var defaultExportedDeclarationSpaces = 0 /* None */; + var exportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var nonExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; + var defaultExportedDeclarationSpaces = 0 /* DeclarationSpaces.None */; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var d = _a[_i]; var declarationSpaces = getDeclarationSpaces(d); - var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* Export */ | 512 /* Default */); - if (effectiveDeclarationFlags & 1 /* Export */) { - if (effectiveDeclarationFlags & 512 /* Default */) { + var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */); + if (effectiveDeclarationFlags & 1 /* ModifierFlags.Export */) { + if (effectiveDeclarationFlags & 512 /* ModifierFlags.Default */) { defaultExportedDeclarationSpaces |= declarationSpaces; } else { @@ -81673,56 +81971,56 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: - return 2 /* ExportType */; - case 261 /* ModuleDeclaration */: - return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ - ? 4 /* ExportNamespace */ | 1 /* ExportValue */ - : 4 /* ExportNamespace */; - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 299 /* EnumMember */: - return 2 /* ExportType */ | 1 /* ExportValue */; - case 305 /* SourceFile */: - return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 271 /* ExportAssignment */: - case 221 /* BinaryExpression */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + return 2 /* DeclarationSpaces.ExportType */; + case 261 /* SyntaxKind.ModuleDeclaration */: + return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* ModuleInstanceState.NonInstantiated */ + ? 4 /* DeclarationSpaces.ExportNamespace */ | 1 /* DeclarationSpaces.ExportValue */ + : 4 /* DeclarationSpaces.ExportNamespace */; + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 299 /* SyntaxKind.EnumMember */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */; + case 305 /* SyntaxKind.SourceFile */: + return 2 /* DeclarationSpaces.ExportType */ | 1 /* DeclarationSpaces.ExportValue */ | 4 /* DeclarationSpaces.ExportNamespace */; + case 271 /* SyntaxKind.ExportAssignment */: + case 221 /* SyntaxKind.BinaryExpression */: var node_2 = d; var expression = ts.isExportAssignment(node_2) ? node_2.expression : node_2.right; // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(expression)) { - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; } d = expression; // The below options all declare an Alias, which is allowed to merge with other values within the importing module. // falls through - case 265 /* ImportEqualsDeclaration */: - case 268 /* NamespaceImport */: - case 267 /* ImportClause */: - var result_12 = 0 /* None */; + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 268 /* SyntaxKind.NamespaceImport */: + case 267 /* SyntaxKind.ImportClause */: + var result_12 = 0 /* DeclarationSpaces.None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); }); return result_12; - case 254 /* VariableDeclaration */: - case 203 /* BindingElement */: - case 256 /* FunctionDeclaration */: - case 270 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 - case 79 /* Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 + case 254 /* SyntaxKind.VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 270 /* SyntaxKind.ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 79 /* SyntaxKind.Identifier */: // https://github.com/microsoft/TypeScript/issues/36098 // Identifiers are used as declarations of assignment declarations whose parents may be // SyntaxKind.CallExpression - `Object.defineProperty(thing, "aField", {value: 42});` // SyntaxKind.ElementAccessExpression - `thing["aField"] = 42;` or `thing["aField"];` (with a doc comment on it) // or SyntaxKind.PropertyAccessExpression - `thing.aField = 42;` // all of which are pretty much always values, or at least imply a value meaning. // It may be apprpriate to treat these as aliases in the future. - return 1 /* ExportValue */; + return 1 /* DeclarationSpaces.ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); } @@ -81758,14 +82056,14 @@ var ts; return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } // primitives with a `{ then() }` won't be unwrapped/adopted. - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { return undefined; } var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : ts.emptyArray; + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* SignatureKind.Call */) : ts.emptyArray; if (thenSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); @@ -81794,18 +82092,18 @@ var ts; } return undefined; } - var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* NEUndefinedOrNull */); + var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(candidates, getTypeOfFirstParameterOfSignature)), 2097152 /* TypeFacts.NEUndefinedOrNull */); if (isTypeAny(onfulfilledParameterType)) { return undefined; } - var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* SignatureKind.Call */); if (onfulfilledParameterSignatures.length === 0) { if (errorNode) { error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); } return undefined; } - return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* Subtype */); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2 /* UnionReduction.Subtype */); } /** * Gets the "awaited type" of a type. @@ -81825,16 +82123,16 @@ var ts; * Determines whether a type is an object with a callable `then` member. */ function isThenableType(type) { - if (allTypesAssignableToKind(type, 131068 /* Primitive */ | 131072 /* Never */)) { + if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) { // primitive types cannot be considered "thenable" since they are not objects. return false; } var thenFunction = getTypeOfPropertyOfType(type, "then"); - return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; + return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* TypeFacts.NEUndefinedOrNull */), 0 /* SignatureKind.Call */).length > 0; } function isAwaitedTypeInstantiation(type) { var _a; - if (type.flags & 16777216 /* Conditional */) { + if (type.flags & 16777216 /* TypeFlags.Conditional */) { var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ false); return !!awaitedSymbol && type.aliasSymbol === awaitedSymbol && ((_a = type.aliasTypeArguments) === null || _a === void 0 ? void 0 : _a.length) === 1; } @@ -81844,10 +82142,38 @@ var ts; * For a generic `Awaited`, gets `T`. */ function unwrapAwaitedType(type) { - return type.flags & 1048576 /* Union */ ? mapType(type, unwrapAwaitedType) : + return type.flags & 1048576 /* TypeFlags.Union */ ? mapType(type, unwrapAwaitedType) : isAwaitedTypeInstantiation(type) ? type.aliasTypeArguments[0] : type; } + function isAwaitedTypeNeeded(type) { + // If this is already an `Awaited`, we shouldn't wrap it. This helps to avoid `Awaited>` in higher-order. + if (isTypeAny(type) || isAwaitedTypeInstantiation(type)) { + return false; + } + // We only need `Awaited` if `T` contains possibly non-primitive types. + if (isGenericObjectType(type)) { + var baseConstraint = getBaseConstraintOfType(type); + // We only need `Awaited` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, + // or is promise-like. + if (baseConstraint ? + baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint) : + maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) { + return true; + } + } + return false; + } + function tryCreateAwaitedType(type) { + // Nothing to do if `Awaited` doesn't exist + var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); + if (awaitedSymbol) { + // Unwrap unions that may contain `Awaited`, otherwise its possible to manufacture an `Awaited | U>` where + // an `Awaited` would suffice. + return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); + } + return undefined; + } function createAwaitedTypeIfNeeded(type) { // We wrap type `T` in `Awaited` based on the following conditions: // - `T` is not already an `Awaited`, and @@ -81856,26 +82182,10 @@ var ts; // - `T` has no base constraint, or // - The base constraint of `T` is `any`, `unknown`, `object`, or `{}`, or // - The base constraint of `T` is an object type with a callable `then` method. - if (isTypeAny(type)) { - return type; - } - // If this is already an `Awaited`, just return it. This helps to avoid `Awaited>` in higher-order. - if (isAwaitedTypeInstantiation(type)) { - return type; - } - // Only instantiate `Awaited` if `T` contains possibly non-primitive types. - if (isGenericObjectType(type)) { - var baseConstraint = getBaseConstraintOfType(type); - // Only instantiate `Awaited` if `T` has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`, - // or is promise-like. - if (!baseConstraint || (baseConstraint.flags & 3 /* AnyOrUnknown */) || isEmptyObjectType(baseConstraint) || isThenableType(baseConstraint)) { - // Nothing to do if `Awaited` doesn't exist - var awaitedSymbol = getGlobalAwaitedSymbol(/*reportErrors*/ true); - if (awaitedSymbol) { - // Unwrap unions that may contain `Awaited`, otherwise its possible to manufacture an `Awaited | U>` where - // an `Awaited` would suffice. - return getTypeAliasInstantiation(awaitedSymbol, [unwrapAwaitedType(type)]); - } + if (isAwaitedTypeNeeded(type)) { + var awaitedType = tryCreateAwaitedType(type); + if (awaitedType) { + return awaitedType; } } ts.Debug.assert(getPromisedTypeOfPromise(type) === undefined, "type provided should not be a non-generic 'promise'-like."); @@ -81914,9 +82224,22 @@ var ts; return typeAsAwaitable.awaitedTypeOfType; } // For a union, get a union of the awaited types of each constituent. - if (type.flags & 1048576 /* Union */) { + if (type.flags & 1048576 /* TypeFlags.Union */) { + if (awaitedTypeStack.lastIndexOf(type.id) >= 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias; - return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper); + awaitedTypeStack.push(type.id); + var mapped = mapType(type, mapper); + awaitedTypeStack.pop(); + return typeAsAwaitable.awaitedTypeOfType = mapped; + } + // If `type` is generic and should be wrapped in `Awaited`, return it. + if (isAwaitedTypeNeeded(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; } var thisTypeForErrorOut = { value: undefined }; var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut); @@ -82037,7 +82360,7 @@ var ts; // } // var returnType = getTypeFromTypeNode(returnTypeNode); - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { if (isErrorType(returnType)) { return; } @@ -82060,10 +82383,10 @@ var ts; error(returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, typeToString(returnType)); return; } - var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); + var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (isErrorType(promiseConstructorType)) { - if (promiseConstructorName.kind === 79 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 79 /* SyntaxKind.Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -82083,7 +82406,7 @@ var ts; } // Verify there is no local declaration that could collide with the promise constructor. var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); - var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); + var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* SymbolFlags.Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); return; @@ -82096,26 +82419,26 @@ var ts; var signature = getResolvedSignature(node); checkDeprecatedSignature(signature, node); var returnType = getReturnTypeOfSignature(signature); - if (returnType.flags & 1 /* Any */) { + if (returnType.flags & 1 /* TypeFlags.Any */) { return; } var headMessage; var expectedReturnType; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: headMessage = ts.Diagnostics.Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any; expectedReturnType = voidType; break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: headMessage = ts.Diagnostics.Decorator_function_return_type_0_is_not_assignable_to_type_1; var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); @@ -82137,9 +82460,9 @@ var ts; if (!typeName) return; var rootName = ts.getFirstIdentifier(typeName); - var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var meaning = (typeName.kind === 79 /* SyntaxKind.Identifier */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */) | 2097152 /* SymbolFlags.Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true); - if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) { + if (rootSymbol && rootSymbol.flags & 2097152 /* SymbolFlags.Alias */) { if (symbolIsValue(rootSymbol) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol)) && !getTypeOnlyAliasDeclaration(rootSymbol)) { @@ -82174,15 +82497,15 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 188 /* IntersectionType */: - case 187 /* UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 187 /* SyntaxKind.UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 191 /* ParenthesizedType */: - case 197 /* NamedTupleMember */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 197 /* SyntaxKind.NamedTupleMember */: return getEntityNameForDecoratorMetadata(node.type); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return node.typeName; } } @@ -82191,13 +82514,13 @@ var ts; var commonEntityName; for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { var typeNode = types_21[_i]; - while (typeNode.kind === 191 /* ParenthesizedType */ || typeNode.kind === 197 /* NamedTupleMember */) { + while (typeNode.kind === 191 /* SyntaxKind.ParenthesizedType */ || typeNode.kind === 197 /* SyntaxKind.NamedTupleMember */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 196 /* LiteralType */ && typeNode.literal.kind === 104 /* NullKeyword */ || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 196 /* SyntaxKind.LiteralType */ && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */ || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -82242,15 +82565,15 @@ var ts; if (!firstDecorator) { return; } - checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 164 /* Parameter */) { - checkExternalEmitHelpers(firstDecorator, 32 /* Param */); + checkExternalEmitHelpers(firstDecorator, 8 /* ExternalEmitHelpers.Decorate */); + if (node.kind === 164 /* SyntaxKind.Parameter */) { + checkExternalEmitHelpers(firstDecorator, 32 /* ExternalEmitHelpers.Param */); } if (compilerOptions.emitDecoratorMetadata) { - checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); + checkExternalEmitHelpers(firstDecorator, 16 /* ExternalEmitHelpers.Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -82259,23 +82582,23 @@ var ts; } } break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - var otherKind = node.kind === 172 /* GetAccessor */ ? 173 /* SetAccessor */ : 172 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + var otherKind = node.kind === 172 /* SyntaxKind.GetAccessor */ ? 173 /* SyntaxKind.SetAccessor */ : 172 /* SyntaxKind.GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -82375,9 +82698,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return node.name; default: return undefined; @@ -82391,7 +82714,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -82407,7 +82730,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find( // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* NodeFlags.JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -82417,7 +82740,7 @@ var ts; checkFunctionOrConstructorSymbol(symbol); } } - var body = node.kind === 168 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 168 /* SyntaxKind.MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); addLazyDiagnostic(checkFunctionOrMethodDeclarationDiagnostics); @@ -82435,7 +82758,7 @@ var ts; if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) { reportImplicitAny(node, anyType); } - if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(body)) { + if (functionFlags & 1 /* FunctionFlags.Generator */ && ts.nodeIsPresent(body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -82463,42 +82786,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 305 /* SourceFile */: - case 261 /* ModuleDeclaration */: - case 235 /* Block */: - case 263 /* CaseBlock */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 305 /* SyntaxKind.SourceFile */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 235 /* SyntaxKind.Block */: + case 263 /* SyntaxKind.CaseBlock */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 171 /* Constructor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 259 /* TypeAliasDeclaration */: - case 258 /* InterfaceDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -82509,41 +82832,41 @@ var ts; function errorUnusedLocal(declaration, name, addDiagnostic) { var node = ts.getNameOfDeclaration(declaration) || declaration; var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read; - addDiagnostic(declaration, 0 /* Local */, ts.createDiagnosticForNode(node, message, name)); + addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name)); } function isIdentifierThatStartsWithUnderscore(node) { - return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* _ */; + return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95 /* CharacterCodes._ */; } function checkUnusedClassMembers(node, addDiagnostic) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - if (member.kind === 173 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + if (member.kind === 173 /* SyntaxKind.SetAccessor */ && member.symbol.flags & 32768 /* SymbolFlags.GetAccessor */) { // Already would have reported an error on the getter. break; } var symbol = getSymbolOfNode(member); if (!symbol.isReferenced - && (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) - && !(member.flags & 16777216 /* Ambient */)) { - addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); + && (ts.hasEffectiveModifier(member, 8 /* ModifierFlags.Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) + && !(member.flags & 16777216 /* NodeFlags.Ambient */)) { + addDiagnostic(member, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; - if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* Private */)) { - addDiagnostic(parameter, 0 /* Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); + if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8 /* ModifierFlags.Private */)) { + addDiagnostic(parameter, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol))); } } break; - case 176 /* IndexSignature */: - case 234 /* SemicolonClassElement */: - case 170 /* ClassStaticBlockDeclaration */: + case 176 /* SyntaxKind.IndexSignature */: + case 234 /* SyntaxKind.SemicolonClassElement */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Can't be private break; default: @@ -82554,7 +82877,7 @@ var ts; function checkUnusedInferTypeParameter(node, addDiagnostic) { var typeParameter = node.typeParameter; if (isTypeParameterUnused(typeParameter)) { - addDiagnostic(node, 1 /* Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); + addDiagnostic(node, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name))); } } function checkUnusedTypeParameters(node, addDiagnostic) { @@ -82565,13 +82888,13 @@ var ts; return; var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); var seenParentsWithEveryUnused = new ts.Set(); - for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) { - var typeParameter = typeParameters_3[_i]; + for (var _i = 0, typeParameters_4 = typeParameters; _i < typeParameters_4.length; _i++) { + var typeParameter = typeParameters_4[_i]; if (!isTypeParameterUnused(typeParameter)) continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 190 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 190 /* SyntaxKind.InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) { var sourceFile = ts.getSourceFileOfNode(parent); var range = ts.isJSDocTemplateTag(parent) @@ -82583,17 +82906,17 @@ var ts; //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0)); } } else { //TODO: following line is possible reason for bug #41974, unusedTypeParameters_TemplateTag - addDiagnostic(typeParameter, 1 /* Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); + addDiagnostic(typeParameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name)); } } } function isTypeParameterUnused(typeParameter) { - return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); + return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144 /* SymbolFlags.TypeParameter */) && !isIdentifierThatStartsWithUnderscore(typeParameter.name); } function addToGroup(map, key, value, getKey) { var keyString = String(getKey(key)); @@ -82630,7 +82953,7 @@ var ts; nodeWithLocals.locals.forEach(function (local) { // If it's purely a type parameter, ignore, will be checked in `checkUnusedTypeParameters`. // If it's a type parameter merged with a parameter, check if the parameter-side is used. - if (local.flags & 262144 /* TypeParameter */ ? !(local.flags & 3 /* Variable */ && !(local.isReferenced & 3 /* Variable */)) : local.isReferenced || local.exportSymbol) { + if (local.flags & 262144 /* SymbolFlags.TypeParameter */ ? !(local.flags & 3 /* SymbolFlags.Variable */ && !(local.isReferenced & 3 /* SymbolFlags.Variable */)) : local.isReferenced || local.exportSymbol) { return; } if (local.declarations) { @@ -82661,7 +82984,7 @@ var ts; addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId); } else { - addDiagnostic(parameter, 1 /* Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); + addDiagnostic(parameter, 1 /* UnusedKind.Parameter */, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local))); } } } @@ -82677,10 +83000,10 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 268 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { - addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 + addDiagnostic(importDecl, 0 /* UnusedKind.Local */, unuseds.length === 1 ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name)) : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused)); } @@ -82693,9 +83016,9 @@ var ts; }); unusedDestructures.forEach(function (_a) { var bindingPattern = _a[0], bindingElements = _a[1]; - var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; + var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* UnusedKind.Parameter */ : 0 /* UnusedKind.Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 254 /* SyntaxKind.VariableDeclaration */ && bindingPattern.parent.parent.kind === 255 /* SyntaxKind.VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -82714,14 +83037,14 @@ var ts; unusedVariables.forEach(function (_a) { var declarationList = _a[0], declarations = _a[1]; if (declarationList.declarations.length === declarations.length) { - addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 + addDiagnostic(declarationList, 0 /* UnusedKind.Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* SyntaxKind.VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) { var decl = declarations_6[_i]; - addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); + addDiagnostic(decl, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name))); } } }); @@ -82744,24 +83067,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return ts.idText(name); - case 202 /* ArrayBindingPattern */: - case 201 /* ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 267 /* ImportClause */ || node.kind === 270 /* ImportSpecifier */ || node.kind === 268 /* NamespaceImport */; + return node.kind === 267 /* SyntaxKind.ImportClause */ || node.kind === 270 /* SyntaxKind.ImportSpecifier */ || node.kind === 268 /* SyntaxKind.NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 267 /* ImportClause */ ? decl : decl.kind === 268 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 267 /* SyntaxKind.ImportClause */ ? decl : decl.kind === 268 /* SyntaxKind.NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 235 /* Block */) { + if (node.kind === 235 /* SyntaxKind.Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -82778,7 +83101,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* NodeFlags.Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -82796,17 +83119,17 @@ var ts; if ((identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) !== name) { return false; } - if (node.kind === 167 /* PropertyDeclaration */ || - node.kind === 166 /* PropertySignature */ || - node.kind === 169 /* MethodDeclaration */ || - node.kind === 168 /* MethodSignature */ || - node.kind === 172 /* GetAccessor */ || - node.kind === 173 /* SetAccessor */ || - node.kind === 296 /* PropertyAssignment */) { + if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || + node.kind === 166 /* SyntaxKind.PropertySignature */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */ || + node.kind === 168 /* SyntaxKind.MethodSignature */ || + node.kind === 172 /* SyntaxKind.GetAccessor */ || + node.kind === 173 /* SyntaxKind.SetAccessor */ || + node.kind === 296 /* SyntaxKind.PropertyAssignment */) { // it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified return false; } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // ambient context - no codegen impact return false; } @@ -82826,8 +83149,8 @@ var ts; // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 4 /* NodeCheckFlags.CaptureThis */) { + var isDeclaration_1 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -82841,8 +83164,8 @@ var ts; } function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { - if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 79 /* Identifier */; + if (getNodeCheckFlags(current) & 8 /* NodeCheckFlags.CaptureNewTarget */) { + var isDeclaration_2 = node.kind !== 79 /* SyntaxKind.Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -82863,46 +83186,46 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) { - if (!name || languageVersion >= 4 /* ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { + if (!name || languageVersion >= 4 /* ScriptTarget.ES2017 */ || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } // Uninstantiated modules shouldnt do this check - if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1 /* ModuleInstanceState.Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 305 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { + if (parent.kind === 305 /* SyntaxKind.SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* NodeFlags.HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. errorSkippedOn("noEmit", name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } function recordPotentialCollisionWithWeakMapSetInGeneratedCode(node, name) { - if (languageVersion <= 8 /* ES2021 */ + if (languageVersion <= 8 /* ScriptTarget.ES2021 */ && (needCollisionCheckForIdentifier(node, name, "WeakMap") || needCollisionCheckForIdentifier(node, name, "WeakSet"))) { potentialWeakMapSetCollisions.push(node); } } function checkWeakMapSetCollision(node) { var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node); - if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* ContainsClassWithPrivateIdentifiers */) { + if (getNodeCheckFlags(enclosingBlockScope) & 67108864 /* NodeCheckFlags.ContainsClassWithPrivateIdentifiers */) { ts.Debug.assert(ts.isNamedDeclaration(node) && ts.isIdentifier(node.name) && typeof node.name.escapedText === "string", "The target of a WeakMap/WeakSet collision check should be an identifier"); errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, node.name.escapedText); } } function recordPotentialCollisionWithReflectInGeneratedCode(node, name) { - if (name && languageVersion >= 2 /* ES2015 */ && languageVersion <= 8 /* ES2021 */ + if (name && languageVersion >= 2 /* ScriptTarget.ES2015 */ && languageVersion <= 8 /* ScriptTarget.ES2021 */ && needCollisionCheckForIdentifier(node, name, "Reflect")) { potentialReflectCollisions.push(node); } @@ -82913,7 +83236,7 @@ var ts; // ClassExpression names don't contribute to their containers, but do matter for any of their block-scoped members. for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (getNodeCheckFlags(member) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(member) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; break; } @@ -82921,13 +83244,13 @@ var ts; } else if (ts.isFunctionExpression(node)) { // FunctionExpression names don't contribute to their containers, but do matter for their contents - if (getNodeCheckFlags(node) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (getNodeCheckFlags(node) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } else { var container = ts.getEnclosingBlockScopeContainer(node); - if (container && getNodeCheckFlags(container) & 134217728 /* ContainsSuperPropertyInStaticInitializer */) { + if (container && getNodeCheckFlags(container) & 134217728 /* NodeCheckFlags.ContainsSuperPropertyInStaticInitializer */) { hasCollision = true; } } @@ -82945,7 +83268,7 @@ var ts; recordPotentialCollisionWithReflectInGeneratedCode(node, name); if (ts.isClassLike(node)) { checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0); - if (!(node.flags & 16777216 /* Ambient */)) { + if (!(node.flags & 16777216 /* NodeFlags.Ambient */)) { checkClassNameCollisionWithObject(name); } } @@ -82977,35 +83300,35 @@ var ts; // const x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 3 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 3 /* NodeFlags.BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 254 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); - if (symbol.flags & 1 /* FunctionScopedVariable */) { + if (symbol.flags & 1 /* SymbolFlags.FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) return ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* SymbolFlags.Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && - localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 237 /* VariableStatement */ && varDeclList.parent.parent + localDeclarationSymbol.flags & 2 /* SymbolFlags.BlockScopedVariable */) { + if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* NodeFlags.BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 255 /* SyntaxKind.VariableDeclarationList */); + var container = varDeclList.parent.kind === 237 /* SyntaxKind.VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 235 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 262 /* ModuleBlock */ || - container.kind === 261 /* ModuleDeclaration */ || - container.kind === 305 /* SourceFile */); + (container.kind === 235 /* SyntaxKind.Block */ && ts.isFunctionLike(container.parent) || + container.kind === 262 /* SyntaxKind.ModuleBlock */ || + container.kind === 261 /* SyntaxKind.ModuleDeclaration */ || + container.kind === 305 /* SyntaxKind.SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -83036,7 +83359,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 162 /* ComputedPropertyName */) { + if (node.name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.name); if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { checkExpressionCached(node.initializer); @@ -83054,16 +83377,16 @@ var ts; potentialUnusedRenamedBindingElementsInTypes.push(node); return; } - if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) { - checkExternalEmitHelpers(node, 4 /* Rest */); + if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ScriptTarget.ES2018 */) { + checkExternalEmitHelpers(node, 4 /* ExternalEmitHelpers.Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 162 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 162 /* SyntaxKind.ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access var parent = node.parent.parent; - var parentCheckMode = node.dotDotDotToken ? 64 /* RestBindingElement */ : 0 /* Normal */; + var parentCheckMode = node.dotDotDotToken ? 64 /* CheckMode.RestBindingElement */ : 0 /* CheckMode.Normal */; var parentType = getTypeForBindingElementParent(parent, parentCheckMode); var name = node.propertyName || node.name; if (parentType && !ts.isBindingPattern(name)) { @@ -83073,15 +83396,15 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isSelfTypeAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SuperKeyword */, /*writing*/ false, parentType, property); + checkPropertyAccessibility(node, !!parent.initializer && parent.initializer.kind === 106 /* SyntaxKind.SuperKeyword */, /*writing*/ false, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 202 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { - checkExternalEmitHelpers(node, 512 /* Read */); + if (node.name.kind === 202 /* SyntaxKind.ArrayBindingPattern */ && languageVersion < 2 /* ScriptTarget.ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* ExternalEmitHelpers.Read */); } ts.forEach(node.name.elements, checkSourceElement); } @@ -83092,7 +83415,7 @@ var ts; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = ts.hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 243 /* ForInStatement */; + var needCheckInitializer = ts.hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */; var needCheckWidenedType = !ts.some(node.name.elements, ts.not(ts.isOmittedExpression)); if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -83109,7 +83432,7 @@ var ts; // check the binding pattern with empty elements if (needCheckWidenedType) { if (ts.isArrayBindingPattern(node.name)) { - checkIteratedTypeOrElementType(65 /* Destructuring */, widenedType, undefinedType, node); + checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, widenedType, undefinedType, node); } else if (strictNullChecks) { checkNonNullNonVoidType(widenedType, node); @@ -83120,7 +83443,7 @@ var ts; } // For a commonjs `const x = require`, validate the alias and exit var symbol = getSymbolOfNode(node); - if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* BindingElement */ ? node.parent.parent : node)) { + if (symbol.flags & 2097152 /* SymbolFlags.Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node.kind === 203 /* SyntaxKind.BindingElement */ ? node.parent.parent : node)) { checkAliasSymbol(node); return; } @@ -83134,7 +83457,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -83150,7 +83473,7 @@ var ts; var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node)); if (!isErrorType(type) && !isErrorType(declarationType) && !isTypeIdenticalTo(type, declarationType) && - !(symbol.flags & 67108864 /* Assignment */)) { + !(symbol.flags & 67108864 /* SymbolFlags.Assignment */)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } if (ts.hasOnlyExpressionInitializer(node) && node.initializer) { @@ -83160,10 +83483,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */) { + if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionsForDeclarationName(node, node.name); @@ -83171,7 +83494,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 167 /* PropertyDeclaration */ || nextDeclaration.kind === 166 /* PropertySignature */ + var message = nextDeclaration.kind === 167 /* SyntaxKind.PropertyDeclaration */ || nextDeclaration.kind === 166 /* SyntaxKind.PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -83181,24 +83504,24 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 164 /* Parameter */ && right.kind === 254 /* VariableDeclaration */) || - (left.kind === 254 /* VariableDeclaration */ && right.kind === 164 /* Parameter */)) { + if ((left.kind === 164 /* SyntaxKind.Parameter */ && right.kind === 254 /* SyntaxKind.VariableDeclaration */) || + (left.kind === 254 /* SyntaxKind.VariableDeclaration */ && right.kind === 164 /* SyntaxKind.Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { return false; } - var interestingFlags = 8 /* Private */ | - 16 /* Protected */ | - 256 /* Async */ | - 128 /* Abstract */ | - 64 /* Readonly */ | - 32 /* Static */; + var interestingFlags = 8 /* ModifierFlags.Private */ | + 16 /* ModifierFlags.Protected */ | + 256 /* ModifierFlags.Async */ | + 128 /* ModifierFlags.Abstract */ | + 64 /* ModifierFlags.Readonly */ | + 32 /* ModifierFlags.Static */; return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags); } function checkVariableDeclaration(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); checkGrammarVariableDeclaration(node); checkVariableLikeDeclaration(node); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); @@ -83224,7 +83547,7 @@ var ts; checkTruthinessExpression(node.expression); checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 236 /* EmptyStatement */) { + if (node.thenStatement.kind === 236 /* SyntaxKind.EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -83233,27 +83556,27 @@ var ts; if (!strictNullChecks) return; helper(condExpr, body); - while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) { + while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */) { condExpr = condExpr.left; helper(condExpr, body); } function helper(condExpr, body) { var location = ts.isBinaryExpression(condExpr) && - (condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */) + (condExpr.operatorToken.kind === 56 /* SyntaxKind.BarBarToken */ || condExpr.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) ? condExpr.right : condExpr; if (ts.isModuleExportsAccessExpression(location)) return; var type = checkTruthinessExpression(location); var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression); - if (!(getTypeFacts(type) & 4194304 /* Truthy */) || isPropertyExpressionCast) + if (!(getTypeFacts(type) & 4194304 /* TypeFacts.Truthy */) || isPropertyExpressionCast) return; // While it technically should be invalid for any known-truthy value // to be tested, we de-scope to functions and Promises unreferenced in // the block as a heuristic to identify the most common bugs. There // are too many false positives for values sourced from type // definitions without strictNullChecks otherwise. - var callSignatures = getSignaturesOfType(type, 0 /* Call */); + var callSignatures = getSignaturesOfType(type, 0 /* SignatureKind.Call */); var isPromise = !!getAwaitedTypeOfPromise(type); if (callSignatures.length === 0 && !isPromise) { return; @@ -83293,7 +83616,7 @@ var ts; var childExpression = childNode.parent; while (testedExpression && childExpression) { if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || - testedExpression.kind === 108 /* ThisKeyword */ && childExpression.kind === 108 /* ThisKeyword */) { + testedExpression.kind === 108 /* SyntaxKind.ThisKeyword */ && childExpression.kind === 108 /* SyntaxKind.ThisKeyword */) { return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); } else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { @@ -83317,7 +83640,7 @@ var ts; }); } function isSymbolUsedInBinaryExpressionChain(node, testedSymbol) { - while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { var isUsed = ts.forEachChild(node.right, function visit(child) { if (ts.isIdentifier(child)) { var symbol = getSymbolAtLocation(child); @@ -83347,7 +83670,7 @@ var ts; checkSourceElement(node.statement); } function checkTruthinessOfType(type, node) { - if (type.flags & 16384 /* Void */) { + if (type.flags & 16384 /* TypeFlags.Void */) { error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness); } return type; @@ -83358,12 +83681,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -83388,29 +83711,29 @@ var ts; } else { var functionFlags = ts.getFunctionFlags(container); - if ((functionFlags & (4 /* Invalid */ | 2 /* Async */)) === 2 /* Async */ && languageVersion < 99 /* ESNext */) { + if ((functionFlags & (4 /* FunctionFlags.Invalid */ | 2 /* FunctionFlags.Async */)) === 2 /* FunctionFlags.Async */ && languageVersion < 99 /* ScriptTarget.ESNext */) { // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper - checkExternalEmitHelpers(node, 16384 /* ForAwaitOfIncludes */); + checkExternalEmitHelpers(node, 16384 /* ExternalEmitHelpers.ForAwaitOfIncludes */); } } } - else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ES2015 */) { + else if (compilerOptions.downlevelIteration && languageVersion < 2 /* ScriptTarget.ES2015 */) { // for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled - checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + checkExternalEmitHelpers(node, 256 /* ExternalEmitHelpers.ForOfIncludes */); } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -83442,7 +83765,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 255 /* VariableDeclarationList */) { + if (node.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -83456,7 +83779,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 204 /* ArrayLiteralExpression */ || varExpr.kind === 205 /* ObjectLiteralExpression */) { + if (varExpr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */ || varExpr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -83469,7 +83792,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* NonPrimitive */ | 58982400 /* InstantiableNonPrimitive */)) { + if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 /* TypeFlags.NonPrimitive */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0, typeToString(rightType)); } checkSourceElement(node.statement); @@ -83486,7 +83809,7 @@ var ts; } } function checkRightHandSideOfForOf(statement) { - var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + var use = statement.awaitModifier ? 15 /* IterationUse.ForAwaitOf */ : 13 /* IterationUse.ForOf */; return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) { @@ -83501,14 +83824,14 @@ var ts; * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) { - var allowAsyncIterables = (use & 2 /* AllowsAsyncIterablesFlag */) !== 0; + var allowAsyncIterables = (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) !== 0; if (inputType === neverType) { reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables); // TODO: GH#18217 return undefined; } - var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var uplevelIteration = languageVersion >= 2 /* ScriptTarget.ES2015 */; var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; - var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* PossiblyOutOfBounds */); + var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128 /* IterationUse.PossiblyOutOfBounds */); // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 // or higher, when inside of an async generator or for-await-if, or when // downlevelIteration is requested. @@ -83517,10 +83840,10 @@ var ts; var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined); if (checkAssignability) { if (iterationTypes) { - var diagnostic = use & 8 /* ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : - use & 32 /* SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : - use & 64 /* DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : - use & 16 /* YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : + var diagnostic = use & 8 /* IterationUse.ForOfFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_for_of_will_always_send_0 : + use & 32 /* IterationUse.SpreadFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 : + use & 64 /* IterationUse.DestructuringFlag */ ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 : + use & 16 /* IterationUse.YieldStarFlag */ ? ts.Diagnostics.Cannot_delegate_iteration_to_value_because_the_next_method_of_its_iterator_expects_type_1_but_the_containing_generator_will_always_send_0 : undefined; if (diagnostic) { checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic); @@ -83537,22 +83860,22 @@ var ts; // If strings are permitted, remove any string-like constituents from the array type. // This allows us to find other non-string element types from an array unioned with // a string. - if (use & 4 /* AllowsStringInputFlag */) { - if (arrayType.flags & 1048576 /* Union */) { + if (use & 4 /* IterationUse.AllowsStringInputFlag */) { + if (arrayType.flags & 1048576 /* TypeFlags.Union */) { // After we remove all types that are StringLike, we will know if there was a string constituent // based on whether the result of filter is a new array. var arrayTypes = inputType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* StringLike */); }); + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316 /* TypeFlags.StringLike */); }); if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, 2 /* Subtype */); + arrayType = getUnionType(filteredTypes, 2 /* UnionReduction.Subtype */); } } - else if (arrayType.flags & 402653316 /* StringLike */) { + else if (arrayType.flags & 402653316 /* TypeFlags.StringLike */) { arrayType = neverType; } hasStringConstituent = arrayType !== inputType; if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { if (errorNode) { error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); reportedError = true; @@ -83560,7 +83883,7 @@ var ts; } // Now that we've removed all the StringLike types, if no constituents remain, then the entire // arrayOrStringType was a string. - if (arrayType.flags & 131072 /* Never */) { + if (arrayType.flags & 131072 /* TypeFlags.Never */) { return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType; } } @@ -83572,7 +83895,7 @@ var ts; // want to say that number is not an array type. But if the input was just // number and string input is allowed, we want to say that number is not an // array type or a string type. - var allowsStrings = !!(use & 4 /* AllowsStringInputFlag */) && !hasStringConstituent; + var allowsStrings = !!(use & 4 /* IterationUse.AllowsStringInputFlag */) && !hasStringConstituent; var _a = getIterationDiagnosticDetails(allowsStrings, downlevelIteration), defaultDiagnostic = _a[0], maybeMissingAwait = _a[1]; errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType)); } @@ -83581,12 +83904,12 @@ var ts; var arrayElementType = getIndexTypeOfType(arrayType, numberType); if (hasStringConstituent && arrayElementType) { // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 402653316 /* StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { + if (arrayElementType.flags & 402653316 /* TypeFlags.StringLike */ && !compilerOptions.noUncheckedIndexedAccess) { return stringType; } - return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* Subtype */); + return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2 /* UnionReduction.Subtype */); } - return (use & 128 /* PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; + return (use & 128 /* IterationUse.PossiblyOutOfBounds */) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType; function getIterationDiagnosticDetails(allowsStrings, downlevelIteration) { var _a; if (downlevelIteration) { @@ -83594,7 +83917,7 @@ var ts; ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true] : [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]; } - var yieldType = getIterationTypeOfIterable(use, 0 /* Yield */, inputType, /*errorNode*/ undefined); + var yieldType = getIterationTypeOfIterable(use, 0 /* IterationTypeKind.Yield */, inputType, /*errorNode*/ undefined); if (yieldType) { return [ts.Diagnostics.Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher, false]; } @@ -83643,9 +83966,9 @@ var ts; // more frequently created (i.e. `Iterator`). Iteration types // are also cached on the type they are requested for, so we shouldn't need to maintain // the cache for less-frequently used types. - if (yieldType.flags & 67359327 /* Intrinsic */ && - returnType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */) && - nextType.flags & (1 /* Any */ | 131072 /* Never */ | 2 /* Unknown */ | 16384 /* Void */ | 32768 /* Undefined */)) { + if (yieldType.flags & 67359327 /* TypeFlags.Intrinsic */ && + returnType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */) && + nextType.flags & (1 /* TypeFlags.Any */ | 131072 /* TypeFlags.Never */ | 2 /* TypeFlags.Unknown */ | 16384 /* TypeFlags.Void */ | 32768 /* TypeFlags.Undefined */)) { var id = getTypeListId([yieldType, returnType, nextType]); var iterationTypes = iterationTypesCache.get(id); if (!iterationTypes) { @@ -83712,37 +84035,56 @@ var ts; * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method. */ function getIterationTypesOfIterable(type, use, errorNode) { + var _a, _b; if (isTypeAny(type)) { return anyIterationTypes; } - if (!(type.flags & 1048576 /* Union */)) { - var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode); + if (!(type.flags & 1048576 /* TypeFlags.Union */)) { + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer); if (iterationTypes_1 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } return undefined; } + else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) { + for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) { + var diag = _c[_i]; + diagnostics.add(diag); + } + } return iterationTypes_1; } - var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; + var cacheKey = use & 2 /* IterationUse.AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable"; var cachedTypes = getCachedIterationTypes(type, cacheKey); if (cachedTypes) return cachedTypes === noIterationTypes ? undefined : cachedTypes; var allIterationTypes; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituent = _a[_i]; - var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode); + for (var _d = 0, _e = type.types; _d < _e.length; _d++) { + var constituent = _e[_d]; + var errorOutputContainer = errorNode ? { errors: undefined } : undefined; + var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer); if (iterationTypes_2 === noIterationTypes) { if (errorNode) { - reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */)); + var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* IterationUse.AllowsAsyncIterablesFlag */)); + if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) { + ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false)); + } } setCachedIterationTypes(type, cacheKey, noIterationTypes); return undefined; } - else { - allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); + else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) { + for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) { + var diag = _g[_f]; + diagnostics.add(diag); + } } + allIterationTypes = ts.append(allIterationTypes, iterationTypes_2); } var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes; setCachedIterationTypes(type, cacheKey, iterationTypes); @@ -83770,47 +84112,62 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterable` instead. */ - function getIterationTypesOfIterableWorker(type, use, errorNode) { + function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) { if (isTypeAny(type)) { return anyIterationTypes; } - if (use & 2 /* AllowsAsyncIterablesFlag */) { + // If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached. + // In addition, we should not cache any new results for this call. + var noCache = false; + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) || getIterationTypesOfIterableFast(type, asyncIterationTypesResolver); if (iterationTypes) { - return use & 8 /* ForOfFlag */ ? - getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : - iterationTypes; + if (iterationTypes === noIterationTypes && errorNode) { + // ignore the cached value + noCache = true; + } + else { + return use & 8 /* IterationUse.ForOfFlag */ ? + getAsyncFromSyncIterationTypes(iterationTypes, errorNode) : + iterationTypes; + } } } - if (use & 1 /* AllowsSyncIterablesFlag */) { + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) || getIterationTypesOfIterableFast(type, syncIterationTypesResolver); if (iterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { - // for a sync iterable in an async context, only use the cached types if they are valid. - if (iterationTypes !== noIterationTypes) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode)); - } + if (iterationTypes === noIterationTypes && errorNode) { + // ignore the cached value + noCache = true; } else { - return iterationTypes; + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + // for a sync iterable in an async context, only use the cached types if they are valid. + if (iterationTypes !== noIterationTypes) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); + } + } + else { + return iterationTypes; + } } } } - if (use & 2 /* AllowsAsyncIterablesFlag */) { - var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode); + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { return iterationTypes; } } - if (use & 1 /* AllowsSyncIterablesFlag */) { - var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode); + if (use & 1 /* IterationUse.AllowsSyncIterablesFlag */) { + var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache); if (iterationTypes !== noIterationTypes) { - if (use & 2 /* AllowsAsyncIterablesFlag */) { - return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes - ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode) - : noIterationTypes); + if (use & 2 /* IterationUse.AllowsAsyncIterablesFlag */) { + iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode); + return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes); } else { return iterationTypes; @@ -83831,7 +84188,7 @@ var ts; } function getIterationTypesOfGlobalIterableType(globalType, resolver) { var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) || - getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined); + getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false); return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes; } /** @@ -83873,7 +84230,7 @@ var ts; function getPropertyNameForKnownSymbolName(symbolName) { var ctorType = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ false); var uniqueType = ctorType && getTypeOfPropertyOfType(getTypeOfSymbol(ctorType), ts.escapeLeadingUnderscores(symbolName)); - return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@" + symbolName; + return uniqueType && isTypeUsableAsPropertyName(uniqueType) ? getPropertyNameFromType(uniqueType) : "__@".concat(symbolName); } /** * Gets the *yield*, *return*, and *next* types of an `Iterable`-like or `AsyncIterable`-like @@ -83885,26 +84242,26 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterable` instead. */ - function getIterationTypesOfIterableSlow(type, resolver, errorNode) { + function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var _a; var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName)); - var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined; + var methodType = method && !(method.flags & 16777216 /* SymbolFlags.Optional */) ? getTypeOfSymbol(method) : undefined; if (isTypeAny(methodType)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); + return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes); } - var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined; + var signatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : undefined; if (!ts.some(signatures)) { - return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); + return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes); } var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature)); - var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes; - return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); + var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes; + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes); } function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) { var message = allowAsyncIterables ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator; - errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); + return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type)); } /** * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type. @@ -83912,13 +84269,29 @@ var ts; * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` * record is returned. Otherwise, `undefined` is returned. */ - function getIterationTypesOfIterator(type, resolver, errorNode) { + function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) { + return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false); + } + /** + * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type. + * + * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` + * record is returned. Otherwise, `undefined` is returned. + * + * NOTE: You probably don't want to call this directly and should be calling + * `getIterationTypesOfIterator` instead. + */ + function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) { if (isTypeAny(type)) { return anyIterationTypes; } var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) || - getIterationTypesOfIteratorFast(type, resolver) || - getIterationTypesOfIteratorSlow(type, resolver, errorNode); + getIterationTypesOfIteratorFast(type, resolver); + if (iterationTypes === noIterationTypes && errorNode) { + iterationTypes = undefined; + noCache = true; + } + iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache)); return iterationTypes === noIterationTypes ? undefined : iterationTypes; } /** @@ -83956,7 +84329,7 @@ var ts; // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || - getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined); + getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false); var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType; return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType)); } @@ -83972,13 +84345,13 @@ var ts; // > If the end was not reached `done` is `false` and a value is available. // > If a `done` property (either own or inherited) does not exist, it is consider to have the value `false`. var doneType = getTypeOfPropertyOfType(type, "done") || falseType; - return isTypeAssignableTo(kind === 0 /* Yield */ ? falseType : trueType, doneType); + return isTypeAssignableTo(kind === 0 /* IterationTypeKind.Yield */ ? falseType : trueType, doneType); } function isYieldIteratorResult(type) { - return isIteratorResult(type, 0 /* Yield */); + return isIteratorResult(type, 0 /* IterationTypeKind.Yield */); } function isReturnIteratorResult(type) { - return isIteratorResult(type, 1 /* Return */); + return isIteratorResult(type, 1 /* IterationTypeKind.Return */); } /** * Gets the *yield* and *return* types of an `IteratorResult`-like type. @@ -84026,30 +84399,36 @@ var ts; * If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes` * record is returned. Otherwise, we return `undefined`. */ - function getIterationTypesOfMethod(type, resolver, methodName, errorNode) { - var _a, _b, _c, _d; + function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) { + var _a, _b, _c, _d, _e, _f; var method = getPropertyOfType(type, methodName); // Ignore 'return' or 'throw' if they are missing. if (!method && methodName !== "next") { return undefined; } - var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* Optional */)) - ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* NEUndefinedOrNull */) + var methodType = method && !(methodName === "next" && (method.flags & 16777216 /* SymbolFlags.Optional */)) + ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152 /* TypeFacts.NEUndefinedOrNull */) : undefined; if (isTypeAny(methodType)) { // `return()` and `throw()` don't provide a *next* type. return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext; } // Both async and non-async iterators *must* have a `next` method. - var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : ts.emptyArray; + var methodSignatures = methodType ? getSignaturesOfType(methodType, 0 /* SignatureKind.Call */) : ts.emptyArray; if (methodSignatures.length === 0) { if (errorNode) { var diagnostic = methodName === "next" ? resolver.mustHaveANextMethodDiagnostic : resolver.mustBeAMethodDiagnostic; - error(errorNode, diagnostic, methodName); + if (errorOutputContainer) { + (_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName)); + } + else { + error(errorNode, diagnostic, methodName); + } } - return methodName === "next" ? anyIterationTypes : undefined; + return methodName === "next" ? noIterationTypes : undefined; } // If the method signature comes exclusively from the global iterator or generator type, // create iteration types from its type arguments like `getIterationTypesOfIteratorFast` @@ -84061,8 +84440,8 @@ var ts; if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) { var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false); var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false); - var isGeneratorMethod = ((_b = (_a = globalGeneratorType.symbol) === null || _a === void 0 ? void 0 : _a.members) === null || _b === void 0 ? void 0 : _b.get(methodName)) === methodType.symbol; - var isIteratorMethod = !isGeneratorMethod && ((_d = (_c = globalIteratorType.symbol) === null || _c === void 0 ? void 0 : _c.members) === null || _d === void 0 ? void 0 : _d.get(methodName)) === methodType.symbol; + var isGeneratorMethod = ((_c = (_b = globalGeneratorType.symbol) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.get(methodName)) === methodType.symbol; + var isIteratorMethod = !isGeneratorMethod && ((_e = (_d = globalIteratorType.symbol) === null || _d === void 0 ? void 0 : _d.members) === null || _e === void 0 ? void 0 : _e.get(methodName)) === methodType.symbol; if (isGeneratorMethod || isIteratorMethod) { var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType; var mapper = methodType.mapper; @@ -84102,7 +84481,13 @@ var ts; var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType); if (iterationTypes === noIterationTypes) { if (errorNode) { - error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + if (errorOutputContainer) { + (_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []); + errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName)); + } + else { + error(errorNode, resolver.mustHaveAValueDiagnostic, methodName); + } } yieldType = anyType; returnTypes = ts.append(returnTypes, anyType); @@ -84123,13 +84508,13 @@ var ts; * NOTE: You probably don't want to call this directly and should be calling * `getIterationTypesOfIterator` instead. */ - function getIterationTypesOfIteratorSlow(type, resolver, errorNode) { + function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) { var iterationTypes = combineIterationTypes([ - getIterationTypesOfMethod(type, resolver, "next", errorNode), - getIterationTypesOfMethod(type, resolver, "return", errorNode), - getIterationTypesOfMethod(type, resolver, "throw", errorNode), + getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer), + getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer), ]); - return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); + return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes); } /** * Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like, @@ -84147,10 +84532,10 @@ var ts; if (isTypeAny(type)) { return anyIterationTypes; } - var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */; + var use = isAsyncGenerator ? 2 /* IterationUse.AsyncGeneratorReturnType */ : 1 /* IterationUse.GeneratorReturnType */; var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver; return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) || - getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined); + getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined); } function checkBreakOrContinueStatement(node) { // Grammar checking @@ -84159,15 +84544,20 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { - var isGenerator = !!(functionFlags & 1 /* Generator */); - var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : - isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : - returnType; + var isGenerator = !!(functionFlags & 1 /* FunctionFlags.Generator */); + var isAsync = !!(functionFlags & 2 /* FunctionFlags.Async */); + if (isGenerator) { + var returnIterationType = getIterationTypeOfGeneratorFunctionReturnType(1 /* IterationTypeKind.Return */, returnType, isAsync); + if (!returnIterationType) { + return errorType; + } + return isAsync ? getAwaitedTypeNoAlias(unwrapAwaitedType(returnIterationType)) : returnIterationType; + } + return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func)); - return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); + return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* TypeFlags.Void */ | 3 /* TypeFlags.AnyOrUnknown */); } function checkReturnStatement(node) { var _a; @@ -84187,21 +84577,21 @@ var ts; var signature = getSignatureFromDeclaration(container); var returnType = getReturnTypeOfSignature(signature); var functionFlags = ts.getFunctionFlags(container); - if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { + if (strictNullChecks || node.expression || returnType.flags & 131072 /* TypeFlags.Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (container.kind === 173 /* SetAccessor */) { + if (container.kind === 173 /* SyntaxKind.SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (container.kind === 171 /* Constructor */) { + else if (container.kind === 171 /* SyntaxKind.Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (getReturnTypeFromAnnotation(container)) { var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; - var unwrappedExprType = functionFlags & 2 /* Async */ + var unwrappedExprType = functionFlags & 2 /* FunctionFlags.Async */ ? checkAwaitedType(exprType, /*withAlias*/ false, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; if (unwrappedReturnType) { @@ -84212,7 +84602,7 @@ var ts; } } } - else if (container.kind !== 171 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { + else if (container.kind !== 171 /* SyntaxKind.Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(container, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -84220,7 +84610,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 32768 /* AwaitContext */) { + if (node.flags & 32768 /* NodeFlags.AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -84241,7 +84631,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 290 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -84250,7 +84640,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { addLazyDiagnostic(createLazyCaseClauseDiagnostics(clause)); } ts.forEach(clause.statements, checkSourceElement); @@ -84287,7 +84677,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 250 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 250 /* SyntaxKind.LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -84319,8 +84709,8 @@ var ts; var declaration = catchClause.variableDeclaration; var typeNode = ts.getEffectiveTypeAnnotationNode(ts.getRootDeclaration(declaration)); if (typeNode) { - var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* Normal */); - if (type && !(type.flags & 3 /* AnyOrUnknown */)) { + var type = getTypeForVariableLikeDeclaration(declaration, /*includeOptionality*/ false, 0 /* CheckMode.Normal */); + if (type && !(type.flags & 3 /* TypeFlags.AnyOrUnknown */)) { grammarErrorOnFirstToken(typeNode, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified); } } @@ -84332,7 +84722,7 @@ var ts; if (blockLocals_1) { ts.forEachKey(catchClause.locals, function (caughtName) { var blockLocal = blockLocals_1.get(caughtName); - if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* BlockScopedVariable */) !== 0) { + if ((blockLocal === null || blockLocal === void 0 ? void 0 : blockLocal.valueDeclaration) && (blockLocal.flags & 2 /* SymbolFlags.BlockScopedVariable */) !== 0) { grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName); } }); @@ -84352,8 +84742,8 @@ var ts; } for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { var prop = _a[_i]; - if (!(isStaticIndex && prop.flags & 4194304 /* Prototype */)) { - checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); + if (!(isStaticIndex && prop.flags & 4194304 /* SymbolFlags.Prototype */)) { + checkIndexConstraintForProperty(type, prop, getLiteralTypeFromProperty(prop, 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */, /*includeNonPublic*/ true), getNonMissingTypeOfSymbol(prop)); } } var typeDeclaration = symbol.valueDeclaration; @@ -84382,10 +84772,11 @@ var ts; return; } var indexInfos = getApplicableIndexInfos(type, propNameType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; - var localPropDeclaration = declaration && declaration.kind === 221 /* BinaryExpression */ || - name && name.kind === 162 /* ComputedPropertyName */ || getParentOfSymbol(prop) === type.symbol ? declaration : undefined; - var _loop_29 = function (info) { + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; + var propDeclaration = declaration && declaration.kind === 221 /* SyntaxKind.BinaryExpression */ || + name && name.kind === 162 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined; + var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined; + var _loop_30 = function (info) { var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; // We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared // in the containing type, or (c) the containing type is an interface and no base interface contains both the property and @@ -84393,20 +84784,24 @@ var ts; var errorNode = localPropDeclaration || localIndexDeclaration || (interfaceDeclaration && !ts.some(getBaseTypes(type), function (base) { return !!getPropertyOfObjectType(base, prop.escapedName) && !!getIndexTypeOfType(base, info.keyType); }) ? interfaceDeclaration : undefined); if (errorNode && !isTypeAssignableTo(propType, info.type)) { - error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + var diagnostic = createError(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type)); + if (propDeclaration && errorNode !== propDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(propDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(prop))); + } + diagnostics.add(diagnostic); } }; for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) { var info = indexInfos_9[_i]; - _loop_29(info); + _loop_30(info); } } function checkIndexConstraintForIndexSignature(type, checkInfo) { var declaration = checkInfo.declaration; var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType); - var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* InterfaceDeclaration */) : undefined; + var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 258 /* SyntaxKind.InterfaceDeclaration */) : undefined; var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined; - var _loop_30 = function (info) { + var _loop_31 = function (info) { if (info === checkInfo) return "continue"; var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined; @@ -84421,7 +84816,7 @@ var ts; }; for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) { var info = indexInfos_10[_i]; - _loop_30(info); + _loop_31(info); } } function checkTypeNameIsReserved(name, message) { @@ -84445,7 +84840,7 @@ var ts; * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name) { - if (languageVersion >= 1 /* ES5 */ && name.escapedText === "Object" + if (languageVersion >= 1 /* ScriptTarget.ES5 */ && name.escapedText === "Object" && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(name).impliedNodeFormat === ts.ModuleKind.CommonJS)) { error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } @@ -84524,9 +84919,9 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 178 /* TypeReference */) { + if (node.kind === 178 /* SyntaxKind.TypeReference */) { var type = getTypeFromTypeReference(node); - if (type.flags & 262144 /* TypeParameter */) { + if (type.flags & 262144 /* TypeFlags.TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { if (type.symbol === getSymbolOfNode(typeParameters[i])) { error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters); @@ -84614,7 +85009,7 @@ var ts; if (firstDecorator && ts.some(node.members, function (p) { return ts.hasStaticModifier(p) && ts.isPrivateIdentifierClassElementDeclaration(p); })) { grammarErrorOnNode(firstDecorator, ts.Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } - if (!node.name && !ts.hasSyntacticModifier(node, 512 /* Default */)) { + if (!node.name && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); @@ -84635,15 +85030,15 @@ var ts; checkFunctionOrConstructorSymbol(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (!nodeInAmbientContext) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - if (languageVersion < 2 /* ES2015 */) { - checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { + checkExternalEmitHelpers(baseTypeNode.parent, 1 /* ExternalEmitHelpers.Extends */); } // check both @extends and extends if both are specified. var extendsNode = ts.getClassExtendsHeritageElement(node); @@ -84675,18 +85070,18 @@ var ts; // Report static side error only when instance type is assignable checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); } - if (baseConstructorType.flags & 8650752 /* TypeVariable */) { + if (baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */) { if (!isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } else { - var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); - if (constructSignatures.some(function (signature) { return signature.flags & 4 /* Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* Abstract */)) { + var constructSignatures = getSignaturesOfType(baseConstructorType, 1 /* SignatureKind.Construct */); + if (constructSignatures.some(function (signature) { return signature.flags & 4 /* SignatureFlags.Abstract */; }) && !ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)) { error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract); } } } - if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* SymbolFlags.Class */) && !(baseConstructorType.flags & 8650752 /* TypeFlags.TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); @@ -84721,7 +85116,7 @@ var ts; var t = getReducedType(getTypeFromTypeNode(typeRefNode)); if (!isErrorType(t)) { if (isValidBaseType(t)) { - var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? + var genericDiag = t.symbol && t.symbol.flags & 32 /* SymbolFlags.Class */ ? ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass : ts.Diagnostics.Class_0_incorrectly_implements_interface_1; var baseWithThis = getTypeWithThisArgument(t, type.thisType); @@ -84741,7 +85136,7 @@ var ts; var baseTypes = baseTypeNode && getBaseTypes(type); var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined; var baseStaticType = getBaseConstructorTypeOfClass(type); - var _loop_31 = function (member) { + var _loop_32 = function (member) { if (ts.hasAmbientModifier(member)) { return "continue"; } @@ -84758,7 +85153,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_31(member); + _loop_32(member); } } /** @@ -84771,7 +85166,7 @@ var ts; && getSymbolAtLocation(member.name) || getSymbolAtLocation(member); if (!declaredProp) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined); } @@ -84785,7 +85180,7 @@ var ts; */ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) { var isJs = ts.isInJSFile(node); - var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */); + var nodeInAmbientContext = !!(node.flags & 16777216 /* NodeFlags.Ambient */); if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) { var memberEscapedName = ts.escapeLeadingUnderscores(memberName); var thisType = memberIsStatic ? staticType : typeWithThis; @@ -84804,12 +85199,12 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) { var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier); if (memberHasOverrideModifier) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } if (!baseHasAbstract) { if (errorNode) { @@ -84822,13 +85217,13 @@ var ts; ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0; error(errorNode, diag, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } else if (memberHasAbstractModifier && baseHasAbstract) { if (errorNode) { error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName); } - return 1 /* NeedsOverride */; + return 1 /* MemberOverrideStatus.NeedsOverride */; } } } @@ -84839,14 +85234,14 @@ var ts; ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class : ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className); } - return 2 /* HasInvalidOverride */; + return 2 /* MemberOverrideStatus.HasInvalidOverride */; } - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_32 = function (member) { + var _loop_33 = function (member) { if (ts.isStatic(member)) { return "continue"; } @@ -84865,7 +85260,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_32(member); + _loop_33(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -84873,10 +85268,10 @@ var ts; } } function checkBaseTypeAccessibility(type, node) { - var signatures = getSignaturesOfType(type, 1 /* Construct */); + var signatures = getSignaturesOfType(type, 1 /* SignatureKind.Construct */); if (signatures.length) { var declaration = signatures[0].declaration; - if (declaration && ts.hasEffectiveModifier(declaration, 8 /* Private */)) { + if (declaration && ts.hasEffectiveModifier(declaration, 8 /* ModifierFlags.Private */)) { var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol); if (!isNodeWithinClass(node, typeClassDeclaration)) { error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol)); @@ -84892,7 +85287,7 @@ var ts; */ function getMemberOverrideModifierStatus(node, member) { if (!member.name) { - return 0 /* Ok */; + return 0 /* MemberOverrideStatus.Ok */; } var symbol = getSymbolOfNode(node); var type = getDeclaredTypeOfSymbol(symbol); @@ -84904,7 +85299,7 @@ var ts; var baseStaticType = getBaseConstructorTypeOfClass(type); var memberHasOverrideModifier = member.parent ? ts.hasOverrideModifier(member) - : ts.hasSyntacticModifier(member, 16384 /* Override */); + : ts.hasSyntacticModifier(member, 16384 /* ModifierFlags.Override */); var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name)); return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member), /* memberIsParameterProperty */ false, memberName); @@ -84912,11 +85307,11 @@ var ts; function getTargetSymbol(s) { // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags - return ts.getCheckFlags(s) & 1 /* Instantiated */ ? s.target : s; + return ts.getCheckFlags(s) & 1 /* CheckFlags.Instantiated */ ? s.target : s; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 257 /* ClassDeclaration */ || d.kind === 258 /* InterfaceDeclaration */; + return d.kind === 257 /* SyntaxKind.ClassDeclaration */ || d.kind === 258 /* SyntaxKind.InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -84936,9 +85331,9 @@ var ts; var _a, _b, _c, _d; // NOTE: assignability is checked in checkClassDeclaration var baseProperties = getPropertiesOfType(baseType); - var _loop_33 = function (baseProperty) { + var _loop_34 = function (baseProperty) { var base = getTargetSymbol(baseProperty); - if (base.flags & 4194304 /* Prototype */) { + if (base.flags & 4194304 /* SymbolFlags.Prototype */) { return "continue"; } var baseSymbol = getPropertyOfObjectType(type, base.escapedName); @@ -84957,7 +85352,7 @@ var ts; // It is an error to inherit an abstract member without implementing it or being declared abstract. // If there is no declaration for the derived class (as in the case of class expressions), // then the class cannot be declared abstract. - if (baseDeclarationFlags & 128 /* Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* Abstract */))) { + if (baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128 /* ModifierFlags.Abstract */))) { // Searches other base types for a declaration that would satisfy the inherited abstract member. // (The class may have more than one base type via declaration merging with an interface with the // same name.) @@ -84971,7 +85366,7 @@ var ts; return "continue-basePropertyCheck"; } } - if (derivedClassDecl.kind === 226 /* ClassExpression */) { + if (derivedClassDecl.kind === 226 /* SyntaxKind.ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -84982,23 +85377,23 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived); - if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { + if (baseDeclarationFlags & 8 /* ModifierFlags.Private */ || derivedDeclarationFlags & 8 /* ModifierFlags.Private */) { return "continue"; } var errorMessage = void 0; - var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; - var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + var basePropertyFlags = base.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* SymbolFlags.PropertyOrAccessor */; if (basePropertyFlags && derivedPropertyFlags) { // property/accessor is overridden with property/accessor - if ((ts.getCheckFlags(base) & 6 /* Synthetic */ + if ((ts.getCheckFlags(base) & 6 /* CheckFlags.Synthetic */ ? (_a = base.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); }) : (_b = base.declarations) === null || _b === void 0 ? void 0 : _b.every(function (d) { return isPropertyAbstractOrInterface(d, baseDeclarationFlags); })) - || ts.getCheckFlags(base) & 262144 /* Mapped */ + || ts.getCheckFlags(base) & 262144 /* CheckFlags.Mapped */ || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { return "continue"; } - var overriddenInstanceProperty = basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */; - var overriddenInstanceAccessor = basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */; + var overriddenInstanceProperty = basePropertyFlags !== 4 /* SymbolFlags.Property */ && derivedPropertyFlags === 4 /* SymbolFlags.Property */; + var overriddenInstanceAccessor = basePropertyFlags === 4 /* SymbolFlags.Property */ && derivedPropertyFlags !== 4 /* SymbolFlags.Property */; if (overriddenInstanceProperty || overriddenInstanceAccessor) { var errorMessage_1 = overriddenInstanceProperty ? ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property : @@ -85006,12 +85401,12 @@ var ts; error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type)); } else if (useDefineForClassFields) { - var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* PropertyDeclaration */ && !d.initializer; }); + var uninitialized = (_c = derived.declarations) === null || _c === void 0 ? void 0 : _c.find(function (d) { return d.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !d.initializer; }); if (uninitialized - && !(derived.flags & 33554432 /* Transient */) - && !(baseDeclarationFlags & 128 /* Abstract */) - && !(derivedDeclarationFlags & 128 /* Abstract */) - && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) { + && !(derived.flags & 33554432 /* SymbolFlags.Transient */) + && !(baseDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !(derivedDeclarationFlags & 128 /* ModifierFlags.Abstract */) + && !((_d = derived.declarations) === null || _d === void 0 ? void 0 : _d.some(function (d) { return !!(d.flags & 16777216 /* NodeFlags.Ambient */); }))) { var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); var propName = uninitialized.name; if (uninitialized.exclamationToken @@ -85027,15 +85422,15 @@ var ts; return "continue"; } else if (isPrototypeProperty(base)) { - if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* SymbolFlags.Property */) { return "continue"; } else { - ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + ts.Debug.assert(!!(derived.flags & 98304 /* SymbolFlags.Accessor */)); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } - else if (base.flags & 98304 /* Accessor */) { + else if (base.flags & 98304 /* SymbolFlags.Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } else { @@ -85046,14 +85441,14 @@ var ts; }; basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) { var baseProperty = baseProperties_1[_i]; - var state_10 = _loop_33(baseProperty); + var state_10 = _loop_34(baseProperty); switch (state_10) { case "continue-basePropertyCheck": continue basePropertyCheck; } } } function isPropertyAbstractOrInterface(declaration, baseDeclarationFlags) { - return baseDeclarationFlags & 128 /* Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer) + return baseDeclarationFlags & 128 /* ModifierFlags.Abstract */ && (!ts.isPropertyDeclaration(declaration) || !declaration.initializer) || ts.isInterfaceDeclaration(declaration.parent); } function getNonInheritedProperties(type, baseTypes, properties) { @@ -85112,20 +85507,20 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* NodeFlags.Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (ts.getEffectiveModifierFlags(member) & 2 /* Ambient */) { + if (ts.getEffectiveModifierFlags(member) & 2 /* ModifierFlags.Ambient */) { continue; } if (!ts.isStatic(member) && isPropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName) || ts.isComputedPropertyName(propName)) { var type = getTypeOfSymbol(getSymbolOfNode(member)); - if (!(type.flags & 3 /* AnyOrUnknown */ || containsUndefinedType(type))) { + if (!(type.flags & 3 /* TypeFlags.AnyOrUnknown */ || containsUndefinedType(type))) { if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) { error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName)); } @@ -85135,7 +85530,7 @@ var ts; } } function isPropertyWithoutInitializer(node) { - return node.kind === 167 /* PropertyDeclaration */ && + return node.kind === 167 /* SyntaxKind.PropertyDeclaration */ && !ts.hasAbstractModifier(node) && !node.exclamationToken && !node.initializer; @@ -85178,7 +85573,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 258 /* SyntaxKind.InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -85211,7 +85606,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkExportsOnMergedDeclarations(node); checkTypeParameters(node.typeParameters); - if (node.type.kind === 138 /* IntrinsicKeyword */) { + if (node.type.kind === 138 /* SyntaxKind.IntrinsicKeyword */) { if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) { error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types); } @@ -85223,8 +85618,8 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 16384 /* EnumValuesComputed */)) { - nodeLinks.flags |= 16384 /* EnumValuesComputed */; + if (!(nodeLinks.flags & 16384 /* NodeCheckFlags.EnumValuesComputed */)) { + nodeLinks.flags |= 16384 /* NodeCheckFlags.EnumValuesComputed */; var autoValue = 0; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; @@ -85249,7 +85644,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 16777216 /* NodeFlags.Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* EnumKind.Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -85266,7 +85661,7 @@ var ts; var enumKind = getEnumKind(getSymbolOfNode(member.parent)); var isConstEnum = ts.isEnumConst(member.parent); var initializer = member.initializer; - var value = enumKind === 1 /* Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); + var value = enumKind === 1 /* EnumKind.Literal */ && !isLiteralEnumMember(member) ? undefined : evaluate(initializer); if (value !== undefined) { if (isConstEnum && typeof value === "number" && !isFinite(value)) { error(initializer, isNaN(value) ? @@ -85274,20 +85669,20 @@ var ts; ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); } } - else if (enumKind === 1 /* Literal */) { + else if (enumKind === 1 /* EnumKind.Literal */) { error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members); return 0; } else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 16777216 /* Ambient */) { + else if (member.parent.flags & 16777216 /* NodeFlags.Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { // Only here do we need to check that the initializer is assignable to the enum type. var source = checkExpression(initializer); - if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) { + if (!isTypeAssignableToKind(source, 296 /* TypeFlags.NumberLike */)) { error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); } else { @@ -85297,60 +85692,60 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 39 /* PlusToken */: return value_2; - case 40 /* MinusToken */: return -value_2; - case 54 /* TildeToken */: return ~value_2; + case 39 /* SyntaxKind.PlusToken */: return value_2; + case 40 /* SyntaxKind.MinusToken */: return -value_2; + case 54 /* SyntaxKind.TildeToken */: return ~value_2; } } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 51 /* BarToken */: return left | right; - case 50 /* AmpersandToken */: return left & right; - case 48 /* GreaterThanGreaterThanToken */: return left >> right; - case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 47 /* LessThanLessThanToken */: return left << right; - case 52 /* CaretToken */: return left ^ right; - case 41 /* AsteriskToken */: return left * right; - case 43 /* SlashToken */: return left / right; - case 39 /* PlusToken */: return left + right; - case 40 /* MinusToken */: return left - right; - case 44 /* PercentToken */: return left % right; - case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); + case 51 /* SyntaxKind.BarToken */: return left | right; + case 50 /* SyntaxKind.AmpersandToken */: return left & right; + case 48 /* SyntaxKind.GreaterThanGreaterThanToken */: return left >> right; + case 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* SyntaxKind.LessThanLessThanToken */: return left << right; + case 52 /* SyntaxKind.CaretToken */: return left ^ right; + case 41 /* SyntaxKind.AsteriskToken */: return left * right; + case 43 /* SyntaxKind.SlashToken */: return left / right; + case 39 /* SyntaxKind.PlusToken */: return left + right; + case 40 /* SyntaxKind.MinusToken */: return left - right; + case 44 /* SyntaxKind.PercentToken */: return left % right; + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* SyntaxKind.PlusToken */) { return left + right; } break; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return expr.text; - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return evaluate(expr.expression); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: var identifier = expr; if (ts.isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 207 /* ElementAccessExpression */: - case 206 /* PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: if (isConstantMemberAccess(expr)) { var type = getTypeOfExpression(expr.expression); - if (type.symbol && type.symbol.flags & 384 /* Enum */) { + if (type.symbol && type.symbol.flags & 384 /* SymbolFlags.Enum */) { var name = void 0; - if (expr.kind === 206 /* PropertyAccessExpression */) { + if (expr.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { name = expr.name.escapedText; } else { @@ -85386,9 +85781,9 @@ var ts; if (type === errorType) { return false; } - return node.kind === 79 /* Identifier */ || - node.kind === 206 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 207 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + return node.kind === 79 /* SyntaxKind.Identifier */ || + node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 207 /* SyntaxKind.ElementAccessExpression */ && isConstantMemberAccess(node.expression) && ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { @@ -85422,7 +85817,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 260 /* EnumDeclaration */) { + if (declaration.kind !== 260 /* SyntaxKind.EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -85451,9 +85846,9 @@ var ts; if (declarations) { for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) { var declaration = declarations_9[_i]; - if ((declaration.kind === 257 /* ClassDeclaration */ || - (declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 16777216 /* Ambient */)) { + if ((declaration.kind === 257 /* SyntaxKind.ClassDeclaration */ || + (declaration.kind === 256 /* SyntaxKind.FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 16777216 /* NodeFlags.Ambient */)) { return declaration; } } @@ -85484,7 +85879,7 @@ var ts; function checkModuleDeclarationDiagnostics() { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 16777216 /* Ambient */; + var inAmbientContext = node.flags & 16777216 /* NodeFlags.Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -85497,7 +85892,7 @@ var ts; return; } if (!checkGrammarDecoratorsAndModifiers(node)) { - if (!inAmbientContext && node.name.kind === 10 /* StringLiteral */) { + if (!inAmbientContext && node.name.kind === 10 /* SyntaxKind.StringLiteral */) { grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names); } } @@ -85507,7 +85902,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); // The following checks only apply on a non-ambient instantiated module declaration. - if (symbol.flags & 512 /* ValueModule */ + if (symbol.flags & 512 /* SymbolFlags.ValueModule */ && !inAmbientContext && symbol.declarations && symbol.declarations.length > 1 @@ -85523,10 +85918,10 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 257 /* SyntaxKind.ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* NodeCheckFlags.LexicalModuleMergesWithClass */; } } if (isAmbientExternalModule) { @@ -85536,7 +85931,7 @@ var ts; // We can detect if augmentation was applied using following rules: // - augmentation for a global scope is always applied // - augmentation for some external module is applied if symbol for augmentation is merged (it was combined with target module). - var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* Transient */); + var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432 /* SymbolFlags.Transient */); if (checkBody && node.body) { for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -85568,23 +85963,23 @@ var ts; function checkModuleAugmentationElement(node, isGlobalAugmentation) { var _a; switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _b = node.declarationList.declarations; _i < _b.length; _i++) { var decl = _b[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 203 /* BindingElement */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 254 /* SyntaxKind.VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _c = 0, _d = name.elements; _c < _d.length; _c++) { @@ -85595,12 +85990,12 @@ var ts; break; } // falls through - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 256 /* FunctionDeclaration */: - case 258 /* InterfaceDeclaration */: - case 261 /* ModuleDeclaration */: - case 259 /* TypeAliasDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -85610,7 +86005,7 @@ var ts; // this is done it two steps // 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error // 2. main check - report error if value declaration of the parent symbol is module augmentation) - var reportError = !(symbol.flags & 33554432 /* Transient */); + var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */); if (!reportError) { // symbol should not originate in augmentation reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]); @@ -85621,20 +86016,20 @@ var ts; } function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return node; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: do { node = node.left; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: do { if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) { return node.name; } node = node.expression; - } while (node.kind !== 79 /* Identifier */); + } while (node.kind !== 79 /* SyntaxKind.Identifier */); return node; } } @@ -85648,9 +86043,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 272 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 272 /* SyntaxKind.ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -85693,12 +86088,12 @@ var ts; // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). symbol = getMergedSymbol(symbol.exportSymbol || symbol); // A type-only import/export will already have a grammar error in a JS file, so no need to issue more errors within - if (ts.isInJSFile(node) && !(target.flags & 111551 /* Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) { + if (ts.isInJSFile(node) && !(target.flags & 111551 /* SymbolFlags.Value */) && !ts.isTypeOnlyImportOrExportDeclaration(node)) { var errorNode = ts.isImportOrExportSpecifier(node) ? node.propertyName || node.name : ts.isNamedDeclaration(node) ? node.name : node; - ts.Debug.assert(node.kind !== 274 /* NamespaceExport */); - if (node.kind === 275 /* ExportSpecifier */) { + ts.Debug.assert(node.kind !== 274 /* SyntaxKind.NamespaceExport */); + if (node.kind === 275 /* SyntaxKind.ExportSpecifier */) { var diag = error(errorNode, ts.Diagnostics.Types_cannot_appear_in_export_declarations_in_JavaScript_files); var alreadyExportedSymbol = (_b = (_a = ts.getSourceFileOfNode(node).symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.get((node.propertyName || node.name).escapedText); if (alreadyExportedSymbol === target) { @@ -85709,47 +86104,47 @@ var ts; } } else { - ts.Debug.assert(node.kind !== 254 /* VariableDeclaration */); + ts.Debug.assert(node.kind !== 254 /* SyntaxKind.VariableDeclaration */); var importDeclaration = ts.findAncestor(node, ts.or(ts.isImportDeclaration, ts.isImportEqualsDeclaration)); var moduleSpecifier = (_e = (importDeclaration && ((_d = ts.tryGetModuleSpecifierFromDeclaration(importDeclaration)) === null || _d === void 0 ? void 0 : _d.text))) !== null && _e !== void 0 ? _e : "..."; var importedIdentifier = ts.unescapeLeadingUnderscores(ts.isIdentifier(errorNode) ? errorNode.escapedText : symbol.escapedName); - error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"" + moduleSpecifier + "\")." + importedIdentifier); + error(errorNode, ts.Diagnostics._0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation, importedIdentifier, "import(\"".concat(moduleSpecifier, "\").").concat(importedIdentifier)); } return; } - var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | - (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | - (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); + var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) | + (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) | + (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 275 /* ExportSpecifier */ ? + var message = node.kind === 275 /* SyntaxKind.ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } if (compilerOptions.isolatedModules && !ts.isTypeOnlyImportOrExportDeclaration(node) - && !(node.flags & 16777216 /* Ambient */)) { + && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol); - var isType = !(target.flags & 111551 /* Value */); + var isType = !(target.flags & 111551 /* SymbolFlags.Value */); if (isType || typeOnlyAlias) { switch (node.kind) { - case 267 /* ImportClause */: - case 270 /* ImportSpecifier */: - case 265 /* ImportEqualsDeclaration */: { + case 267 /* SyntaxKind.ImportClause */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { if (compilerOptions.preserveValueImports) { ts.Debug.assertIsDefined(node.name, "An ImportClause with a symbol should have a name"); var message = isType ? ts.Diagnostics._0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled : ts.Diagnostics._0_resolves_to_a_type_only_declaration_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedModules_are_both_enabled; - var name = ts.idText(node.kind === 270 /* ImportSpecifier */ ? node.propertyName || node.name : node.name); + var name = ts.idText(node.kind === 270 /* SyntaxKind.ImportSpecifier */ ? node.propertyName || node.name : node.name); addTypeOnlyDeclarationRelatedInfo(error(node, message, name), isType ? undefined : typeOnlyAlias, name); } - if (isType && node.kind === 265 /* ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* Export */)) { + if (isType && node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && ts.hasEffectiveModifier(node, 1 /* ModifierFlags.Export */)) { error(node, ts.Diagnostics.Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided); } break; } - case 275 /* ExportSpecifier */: { + case 275 /* SyntaxKind.ExportSpecifier */: { // Don't allow re-exporting an export that will be elided when `--isolatedModules` is set. // The exception is that `import type { A } from './a'; export { A }` is allowed // because single-file analysis can determine that the export should be dropped. @@ -85774,15 +86169,15 @@ var ts; } } function isDeprecatedAliasedSymbol(symbol) { - return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); }); + return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* NodeFlags.Deprecated */); }); } function checkDeprecatedAliasedSymbol(symbol, location) { - if (!(symbol.flags & 2097152 /* Alias */)) + if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) return symbol; var targetSymbol = resolveAlias(symbol); if (targetSymbol === unknownSymbol) return targetSymbol; - while (symbol.flags & 2097152 /* Alias */) { + while (symbol.flags & 2097152 /* SymbolFlags.Alias */) { var target = getImmediateAliasedSymbol(symbol); if (target) { if (target === targetSymbol) @@ -85808,11 +86203,11 @@ var ts; function checkImportBinding(node) { checkCollisionsForDeclarationName(node, node.name); checkAliasSymbol(node); - if (node.kind === 270 /* ImportSpecifier */ && + if (node.kind === 270 /* SyntaxKind.ImportSpecifier */ && ts.idText(node.propertyName || node.name) === "default" && ts.getESModuleInterop(compilerOptions) && moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS)) { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } function checkAssertClause(declaration) { @@ -85858,11 +86253,11 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { checkImportBinding(importClause.namedBindings); if (moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { @@ -85884,20 +86279,20 @@ var ts; checkGrammarDecoratorsAndModifiers(node); if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) { checkImportBinding(node); - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 277 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 277 /* SyntaxKind.ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { - if (target.flags & 111551 /* Value */) { + if (target.flags & 111551 /* SymbolFlags.Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name var moduleName = ts.getFirstIdentifier(node.moduleReference); - if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { + if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } } - if (target.flags & 788968 /* Type */) { + if (target.flags & 788968 /* SymbolFlags.Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } @@ -85906,7 +86301,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -85921,8 +86316,8 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } - if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { - checkExternalEmitHelpers(node, 4194304 /* CreateBinding */); + if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ScriptTarget.ES3 */) { + checkExternalEmitHelpers(node, 4194304 /* ExternalEmitHelpers.CreateBinding */); } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -85930,10 +86325,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 16777216 /* Ambient */; - if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ && + !node.moduleSpecifier && node.flags & 16777216 /* NodeFlags.Ambient */; + if (node.parent.kind !== 305 /* SyntaxKind.SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -85953,12 +86348,12 @@ var ts; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop if (ts.getESModuleInterop(compilerOptions)) { - checkExternalEmitHelpers(node, 65536 /* ImportStar */); + checkExternalEmitHelpers(node, 65536 /* ExternalEmitHelpers.ImportStar */); } } else { // export * from "foo" - checkExternalEmitHelpers(node, 32768 /* ExportStar */); + checkExternalEmitHelpers(node, 32768 /* ExternalEmitHelpers.ExportStar */); } } } @@ -85968,7 +86363,7 @@ var ts; function checkGrammarExportDeclaration(node) { var _a; if (node.isTypeOnly) { - if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* NamedExports */) { + if (((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) === 273 /* SyntaxKind.NamedExports */) { return checkGrammarNamedImportsOrExports(node.exportClause); } else { @@ -85978,7 +86373,7 @@ var ts; return false; } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 305 /* SourceFile */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 261 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 305 /* SyntaxKind.SourceFile */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 261 /* SyntaxKind.ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -86026,15 +86421,17 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) - var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, + var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || symbol.declarations && isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { - markExportAsReferenced(node); - var target = symbol && (symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol); - if (!target || target === unknownSymbol || target.flags & 111551 /* Value */) { + if (!node.isTypeOnly && !node.parent.parent.isTypeOnly) { + markExportAsReferenced(node); + } + var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol); + if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { checkExpressionCached(node.propertyName || node.name); } } @@ -86044,7 +86441,7 @@ var ts; moduleKind !== ts.ModuleKind.System && (moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && ts.idText(node.propertyName || node.name) === "default") { - checkExternalEmitHelpers(node, 131072 /* ImportDefault */); + checkExternalEmitHelpers(node, 131072 /* ExternalEmitHelpers.ImportDefault */); } } } @@ -86056,8 +86453,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -86074,14 +86471,14 @@ var ts; if (typeAnnotationNode) { checkTypeAssignableTo(checkExpressionCached(node.expression), getTypeFromTypeNode(typeAnnotationNode), node.expression); } - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { var id = node.expression; - var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); + var sym = resolveEntityName(id, 67108863 /* SymbolFlags.All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { markAliasReferenced(sym, id); // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`) - var target = sym.flags & 2097152 /* Alias */ ? resolveAlias(sym) : sym; - if (target === unknownSymbol || target.flags & 111551 /* Value */) { + var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym; + if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) { // However if it is a value, we need to check it's being used correctly checkExpressionCached(node.expression); } @@ -86097,10 +86494,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 16777216 /* NodeFlags.Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 16777216 /* NodeFlags.Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -86135,11 +86532,11 @@ var ts; } // ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries. // (TS Exceptions: namespaces, function overloads, enums, and interfaces) - if (flags & (1920 /* Namespace */ | 384 /* Enum */)) { + if (flags & (1920 /* SymbolFlags.Namespace */ | 384 /* SymbolFlags.Enum */)) { return; } var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration))); - if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { + if (flags & 524288 /* SymbolFlags.TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) return; @@ -86189,181 +86586,181 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 261 /* ModuleDeclaration */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 256 /* FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } - if (kind >= 237 /* FirstStatement */ && kind <= 253 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + if (kind >= 237 /* SyntaxKind.FirstStatement */ && kind <= 253 /* SyntaxKind.LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); } switch (kind) { - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return checkTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return checkParameter(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return checkPropertyDeclaration(node); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return checkPropertySignature(node); - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 174 /* CallSignature */: - case 175 /* ConstructSignature */: - case 176 /* IndexSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 174 /* SyntaxKind.CallSignature */: + case 175 /* SyntaxKind.ConstructSignature */: + case 176 /* SyntaxKind.IndexSignature */: return checkSignatureDeclaration(node); - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: return checkMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return checkClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return checkConstructorDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return checkAccessorDeclaration(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return checkTypeReferenceNode(node); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return checkTypePredicate(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return checkTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return checkTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return checkArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return checkTupleType(node); - case 187 /* UnionType */: - case 188 /* IntersectionType */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: return checkUnionOrIntersectionType(node); - case 191 /* ParenthesizedType */: - case 185 /* OptionalType */: - case 186 /* RestType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: return checkSourceElement(node.type); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return checkThisType(node); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return checkTypeOperator(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return checkConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return checkInferType(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return checkTemplateLiteralType(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return checkImportType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return checkNamedTupleMember(node); - case 328 /* JSDocAugmentsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 329 /* JSDocImplementsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return checkJSDocImplementsTag(node); - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 343 /* JSDocTypeTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return checkJSDocTypeTag(node); - case 324 /* JSDocLink */: - case 325 /* JSDocLinkCode */: - case 326 /* JSDocLinkPlain */: + case 324 /* SyntaxKind.JSDocLink */: + case 325 /* SyntaxKind.JSDocLinkCode */: + case 326 /* SyntaxKind.JSDocLinkPlain */: return checkJSDocLinkLikeTag(node); - case 340 /* JSDocParameterTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: return checkJSDocParameterTag(node); - case 347 /* JSDocPropertyTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return checkJSDocPropertyTag(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 315 /* JSDocNonNullableType */: - case 314 /* JSDocNullableType */: - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 322 /* JSDocTypeLiteral */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 318 /* JSDocVariadicType */: + case 318 /* SyntaxKind.JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return checkSourceElement(node.type); - case 333 /* JSDocPublicTag */: - case 335 /* JSDocProtectedTag */: - case 334 /* JSDocPrivateTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: return checkJSDocAccessibilityModifiers(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return checkIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return checkMappedType(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return checkFunctionDeclaration(node); - case 235 /* Block */: - case 262 /* ModuleBlock */: + case 235 /* SyntaxKind.Block */: + case 262 /* SyntaxKind.ModuleBlock */: return checkBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return checkVariableStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return checkExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return checkIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return checkDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return checkWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return checkForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return checkForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return checkForOfStatement(node); - case 245 /* ContinueStatement */: - case 246 /* BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: return checkBreakOrContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return checkReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return checkWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return checkSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return checkLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return checkThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return checkTryStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return checkVariableDeclaration(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return checkBindingElement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return checkClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return checkEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return checkModuleDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return checkImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return checkExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return checkExportAssignment(node); - case 236 /* EmptyStatement */: - case 253 /* DebuggerStatement */: + case 236 /* SyntaxKind.EmptyStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -86453,7 +86850,7 @@ var ts; function checkNodeDeferred(node) { var enclosingFile = ts.getSourceFileOfNode(node); var links = getNodeLinks(enclosingFile); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { links.deferredNodes || (links.deferredNodes = new ts.Set()); links.deferredNodes.add(node); } @@ -86465,41 +86862,41 @@ var ts; } } function checkDeferredNode(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end, path: node.tracingPath }); var saveCurrentNode = currentNode; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 210 /* TaggedTemplateExpression */: - case 165 /* Decorator */: - case 280 /* JsxOpeningElement */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: + case 165 /* SyntaxKind.Decorator */: + case 280 /* SyntaxKind.JsxOpeningElement */: // These node kinds are deferred checked when overload resolution fails // To save on work, we ensure the arguments are checked just once, in // a deferred way resolveUntypedCall(node); break; - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: checkAccessorDeclaration(node); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: checkClassExpressionDeferred(node); break; - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: checkTypeParameterDeferred(node); break; - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: checkJsxElementDeferred(node); break; } @@ -86507,7 +86904,7 @@ var ts; ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } function checkSourceFile(node) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check" /* tracing.Phase.Check */, "checkSourceFile", { path: node.path }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeCheck"); checkSourceFileWorker(node); ts.performance.mark("afterCheck"); @@ -86519,9 +86916,9 @@ var ts; return false; } switch (kind) { - case 0 /* Local */: + case 0 /* UnusedKind.Local */: return !!compilerOptions.noUnusedLocals; - case 1 /* Parameter */: + case 1 /* UnusedKind.Parameter */: return !!compilerOptions.noUnusedParameters; default: return ts.Debug.assertNever(kind); @@ -86533,7 +86930,7 @@ var ts; // Fully type check a source file and collect the relevant diagnostics. function checkSourceFileWorker(node) { var links = getNodeLinks(node); - if (!(links.flags & 1 /* TypeChecked */)) { + if (!(links.flags & 1 /* NodeCheckFlags.TypeChecked */)) { if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } @@ -86554,7 +86951,7 @@ var ts; // This relies on the results of other lazy diagnostics, so must be computed after them if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) { checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) { - if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) { + if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* NodeFlags.Ambient */))) { diagnostics.add(diag); } }); @@ -86563,7 +86960,7 @@ var ts; checkPotentialUncheckedRenamedBindingElementsInTypes(); } }); - if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ && + if (compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ && !node.isDeclarationFile && ts.isExternalModule(node)) { checkImportsForTypeOnlyConversion(node); @@ -86587,7 +86984,7 @@ var ts; ts.forEach(potentialReflectCollisions, checkReflectCollision); ts.clear(potentialReflectCollisions); } - links.flags |= 1 /* TypeChecked */; + links.flags |= 1 /* NodeCheckFlags.TypeChecked */; } } function getDiagnostics(sourceFile, ct) { @@ -86657,14 +87054,14 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 33554432 /* InWithStatement */) { + if (location.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } var symbols = ts.createSymbolTable(); var isStaticSymbol = false; populateSymbols(); - symbols.delete("this" /* This */); // Not a symbol, a keyword + symbols.delete("this" /* InternalSymbolName.This */); // Not a symbol, a keyword return symbolsToArray(symbols); function populateSymbols() { while (location) { @@ -86672,17 +87069,17 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: if (!ts.isExternalModule(location)) break; // falls through - case 261 /* ModuleDeclaration */: - copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); + case 261 /* SyntaxKind.ModuleDeclaration */: + copyLocallyVisibleExportSymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* SymbolFlags.ModuleMember */); break; - case 260 /* EnumDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); + case 260 /* SyntaxKind.EnumDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* SymbolFlags.EnumMember */); break; - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); @@ -86690,17 +87087,17 @@ var ts; // this fall-through is necessary because we would like to handle // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. // falls through - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. // Note: that the memberFlags come from previous iteration. if (!isStaticSymbol) { - copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); + copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* SymbolFlags.Type */); } break; - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -86744,7 +87141,7 @@ var ts; if (meaning) { source.forEach(function (symbol) { // Similar condition as in `resolveNameHelper` - if (!ts.getDeclarationOfKind(symbol, 275 /* ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* NamespaceExport */)) { + if (!ts.getDeclarationOfKind(symbol, 275 /* SyntaxKind.ExportSpecifier */) && !ts.getDeclarationOfKind(symbol, 274 /* SyntaxKind.NamespaceExport */)) { copySymbol(symbol, meaning); } }); @@ -86752,25 +87149,25 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 79 /* Identifier */ && + return name.kind === 79 /* SyntaxKind.Identifier */ && isTypeDeclaration(name.parent) && ts.getNameOfDeclaration(name.parent) === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 163 /* TypeParameter */: - case 257 /* ClassDeclaration */: - case 258 /* InterfaceDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 345 /* JSDocTypedefTag */: - case 338 /* JSDocCallbackTag */: - case 339 /* JSDocEnumTag */: + case 163 /* SyntaxKind.TypeParameter */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 345 /* SyntaxKind.JSDocTypedefTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: return true; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return node.isTypeOnly; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return node.parent.parent.isTypeOnly; default: return false; @@ -86778,16 +87175,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 161 /* QualifiedName */) { + while (node.parent.kind === 161 /* SyntaxKind.QualifiedName */) { node = node.parent; } - return node.parent.kind === 178 /* TypeReference */; + return node.parent.kind === 178 /* SyntaxKind.TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 206 /* PropertyAccessExpression */) { + while (node.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 228 /* ExpressionWithTypeArguments */; + return node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -86815,13 +87212,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 161 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 161 /* SyntaxKind.QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 265 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 271 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 271 /* SyntaxKind.ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -86832,12 +87229,12 @@ var ts; function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent); switch (specialPropertyAssignmentKind) { - case 1 /* ExportsProperty */: - case 3 /* PrototypeProperty */: + case 1 /* AssignmentDeclarationKind.ExportsProperty */: + case 3 /* AssignmentDeclarationKind.PrototypeProperty */: return getSymbolOfNode(entityName.parent); - case 4 /* ThisProperty */: - case 2 /* ModuleExports */: - case 5 /* Property */: + case 4 /* AssignmentDeclarationKind.ThisProperty */: + case 2 /* AssignmentDeclarationKind.ModuleExports */: + case 5 /* AssignmentDeclarationKind.Property */: return getSymbolOfNode(entityName.parent.parent); } } @@ -86847,7 +87244,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 200 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 200 /* SyntaxKind.ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -86857,7 +87254,7 @@ var ts; return getSymbolOfNode(name.parent); } if (ts.isInJSFile(name) && - name.parent.kind === 206 /* PropertyAccessExpression */ && + name.parent.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && name.parent === name.parent.parent.left) { // Check if this is a special property assignment if (!ts.isPrivateIdentifier(name) && !ts.isJSDocMemberName(name)) { @@ -86867,17 +87264,17 @@ var ts; } } } - if (name.parent.kind === 271 /* ExportAssignment */ && ts.isEntityNameExpression(name)) { + if (name.parent.kind === 271 /* SyntaxKind.ExportAssignment */ && ts.isEntityNameExpression(name)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(name, - /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); + /*all meanings*/ 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */, /*ignoreErrors*/ true); if (success && success !== unknownSymbol) { return success; } } else if (ts.isEntityName(name) && isInRightSideOfImportOrExportAssignment(name)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(name, 265 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(name, 265 /* SyntaxKind.ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(name, /*dontResolveAlias*/ true); } @@ -86893,28 +87290,28 @@ var ts; name = name.parent; } if (isHeritageClauseElementIdentifier(name)) { - var meaning = 0 /* None */; + var meaning = 0 /* SymbolFlags.None */; // In an interface or class, we're definitely interested in a type. - if (name.parent.kind === 228 /* ExpressionWithTypeArguments */) { - meaning = 788968 /* Type */; + if (name.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */) { + meaning = 788968 /* SymbolFlags.Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) { - meaning |= 111551 /* Value */; + meaning |= 111551 /* SymbolFlags.Value */; } } else { - meaning = 1920 /* Namespace */; + meaning = 1920 /* SymbolFlags.Namespace */; } - meaning |= 2097152 /* Alias */; + meaning |= 2097152 /* SymbolFlags.Alias */; var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined; if (entityNameSymbol) { return entityNameSymbol; } } - if (name.parent.kind === 340 /* JSDocParameterTag */) { + if (name.parent.kind === 340 /* SyntaxKind.JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 163 /* TypeParameter */ && name.parent.parent.kind === 344 /* JSDocTemplateTag */) { + if (name.parent.kind === 163 /* SyntaxKind.TypeParameter */ && name.parent.parent.kind === 344 /* SyntaxKind.JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -86925,8 +87322,8 @@ var ts; return undefined; } var isJSDoc_1 = ts.findAncestor(name, ts.or(ts.isJSDocLinkLike, ts.isJSDocNameReference, ts.isJSDocMemberName)); - var meaning = isJSDoc_1 ? 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */ : 111551 /* Value */; - if (name.kind === 79 /* Identifier */) { + var meaning = isJSDoc_1 ? 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */ : 111551 /* SymbolFlags.Value */; + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) { var symbol = getIntrinsicTagSymbol(name.parent); return symbol === unknownSymbol ? undefined : symbol; @@ -86943,16 +87340,16 @@ var ts; else if (ts.isPrivateIdentifier(name)) { return getSymbolForPrivateIdentifierExpression(name); } - else if (name.kind === 206 /* PropertyAccessExpression */ || name.kind === 161 /* QualifiedName */) { + else if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || name.kind === 161 /* SyntaxKind.QualifiedName */) { var links = getNodeLinks(name); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (name.kind === 206 /* PropertyAccessExpression */) { - checkPropertyAccessExpression(name, 0 /* Normal */); + if (name.kind === 206 /* SyntaxKind.PropertyAccessExpression */) { + checkPropertyAccessExpression(name, 0 /* CheckMode.Normal */); } else { - checkQualifiedName(name, 0 /* Normal */); + checkQualifiedName(name, 0 /* CheckMode.Normal */); } if (!links.resolvedSymbol && isJSDoc_1 && ts.isQualifiedName(name)) { return resolveJSDocMemberName(name); @@ -86964,12 +87361,12 @@ var ts; } } else if (isTypeReferenceIdentifier(name)) { - var meaning = name.parent.kind === 178 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = name.parent.kind === 178 /* SyntaxKind.TypeReference */ ? 788968 /* SymbolFlags.Type */ : 1920 /* SymbolFlags.Namespace */; var symbol = resolveEntityName(name, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); return symbol && symbol !== unknownSymbol ? symbol : getUnresolvedSymbolForEntityName(name); } - if (name.parent.kind === 177 /* TypePredicate */) { - return resolveEntityName(name, /*meaning*/ 1 /* FunctionScopedVariable */); + if (name.parent.kind === 177 /* SyntaxKind.TypePredicate */) { + return resolveEntityName(name, /*meaning*/ 1 /* SymbolFlags.FunctionScopedVariable */); } return undefined; } @@ -86984,7 +87381,7 @@ var ts; function resolveJSDocMemberName(name, ignoreErrors, container) { if (ts.isEntityName(name)) { // resolve static values first - var meaning = 788968 /* Type */ | 1920 /* Namespace */ | 111551 /* Value */; + var meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 111551 /* SymbolFlags.Value */; var symbol = resolveEntityName(name, meaning, ignoreErrors, /*dontResolveAlias*/ true, ts.getHostSignatureFromJSDoc(name)); if (!symbol && ts.isIdentifier(name) && container) { symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(container), name.escapedText, meaning)); @@ -86996,18 +87393,18 @@ var ts; var left = ts.isIdentifier(name) ? container : resolveJSDocMemberName(name.left, ignoreErrors, container); var right = ts.isIdentifier(name) ? name.escapedText : name.right.escapedText; if (left) { - var proto = left.flags & 111551 /* Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); + var proto = left.flags & 111551 /* SymbolFlags.Value */ && getPropertyOfType(getTypeOfSymbol(left), "prototype"); var t = proto ? getTypeOfSymbol(proto) : getDeclaredTypeOfSymbol(left); return getPropertyOfType(t, right); } } function getSymbolAtLocation(node, ignoreErrors) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -87021,12 +87418,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } - else if (parent.kind === 203 /* BindingElement */ && - grandParent.kind === 201 /* ObjectBindingPattern */ && + else if (parent.kind === 203 /* SyntaxKind.BindingElement */ && + grandParent.kind === 201 /* SyntaxKind.ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -87035,7 +87432,7 @@ var ts; } } else if (ts.isMetaProperty(parent) && parent.name === node) { - if (parent.keywordToken === 103 /* NewKeyword */ && ts.idText(node) === "target") { + if (parent.keywordToken === 103 /* SyntaxKind.NewKeyword */ && ts.idText(node) === "target") { // `target` in `new.target` return checkNewTargetMetaProperty(parent).symbol; } @@ -87043,7 +87440,7 @@ var ts; // we have a fake expression type made for other reasons already, whose transient `meta` // member should more exactly be the kind of (declarationless) symbol we want. // (See #44364 and #45031 for relevant implementation PRs) - if (parent.keywordToken === 100 /* ImportKeyword */ && ts.idText(node) === "meta") { + if (parent.keywordToken === 100 /* SyntaxKind.ImportKeyword */ && ts.idText(node) === "meta") { return getGlobalImportMetaExpressionType().members.get("meta"); } // no other meta properties are valid syntax, thus no others should have symbols @@ -87051,15 +87448,15 @@ var ts; } } switch (node.kind) { - case 79 /* Identifier */: - case 80 /* PrivateIdentifier */: - case 206 /* PropertyAccessExpression */: - case 161 /* QualifiedName */: + case 79 /* SyntaxKind.Identifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 161 /* SyntaxKind.QualifiedName */: if (!ts.isThisInTypeQuery(node)) { return getSymbolOfNameOrPropertyAccessExpression(node); } // falls through - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -87071,25 +87468,25 @@ var ts; return checkExpression(node).symbol; } // falls through - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return checkExpression(node).symbol; - case 134 /* ConstructorKeyword */: + case 134 /* SyntaxKind.ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 171 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 171 /* SyntaxKind.Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: // 1). import x = require("./mo/*gotToDefinitionHere*/d") // 2). External module name in an import declaration // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 266 /* ImportDeclaration */ || node.parent.kind === 272 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.parent.kind === 272 /* SyntaxKind.ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node, ignoreErrors); @@ -87098,7 +87495,7 @@ var ts; return getSymbolOfNode(parent); } // falls through - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: // index access var objectType = ts.isElementAccessExpression(parent) ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined @@ -87106,19 +87503,19 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 88 /* DefaultKeyword */: - case 98 /* FunctionKeyword */: - case 38 /* EqualsGreaterThanToken */: - case 84 /* ClassKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: + case 98 /* SyntaxKind.FunctionKeyword */: + case 38 /* SyntaxKind.EqualsGreaterThanToken */: + case 84 /* SyntaxKind.ClassKeyword */: return getSymbolOfNode(node.parent); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; - case 93 /* ExportKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; - case 100 /* ImportKeyword */: - case 103 /* NewKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: + case 103 /* SyntaxKind.NewKeyword */: return ts.isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined; - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return checkExpression(node).symbol; default: return undefined; @@ -87128,14 +87525,14 @@ var ts; if (ts.isIdentifier(node) && ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { var keyType_1 = getLiteralTypeFromPropertyName(node); var objectType = getTypeOfExpression(node.parent.expression); - var objectTypes = objectType.flags & 1048576 /* Union */ ? objectType.types : [objectType]; + var objectTypes = objectType.flags & 1048576 /* TypeFlags.Union */ ? objectType.types : [objectType]; return ts.flatMap(objectTypes, function (t) { return ts.filter(getIndexInfosOfType(t), function (info) { return isApplicableIndexType(keyType_1, info.keyType); }); }); } return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 297 /* ShorthandPropertyAssignment */) { - return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); + if (location && location.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */) { + return resolveEntityName(location.name, 111551 /* SymbolFlags.Value */ | 2097152 /* SymbolFlags.Alias */); } return undefined; } @@ -87144,17 +87541,17 @@ var ts; if (ts.isExportSpecifier(node)) { return node.parent.parent.moduleSpecifier ? getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + resolveEntityName(node.propertyName || node.name, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } else { - return resolveEntityName(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); + return resolveEntityName(node, 111551 /* SymbolFlags.Value */ | 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */ | 2097152 /* SymbolFlags.Alias */); } } function getTypeOfNode(node) { if (ts.isSourceFile(node) && !ts.isExternalModule(node)) { return errorType; } - if (node.flags & 33554432 /* InWithStatement */) { + if (node.flags & 33554432 /* NodeFlags.InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -87195,7 +87592,7 @@ var ts; return errorType; } if (ts.isBindingPattern(node)) { - return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* Normal */) || errorType; + return getTypeForVariableLikeDeclaration(node.parent, /*includeOptionality*/ true, 0 /* CheckMode.Normal */) || errorType; } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolAtLocation(node); @@ -87216,23 +87613,23 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 205 /* ObjectLiteralExpression */ || expr.kind === 204 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 205 /* SyntaxKind.ObjectLiteralExpression */ || expr.kind === 204 /* SyntaxKind.ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 244 /* ForOfStatement */) { + if (expr.parent.kind === 244 /* SyntaxKind.ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 221 /* BinaryExpression */) { + if (expr.parent.kind === 221 /* SyntaxKind.BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 296 /* PropertyAssignment */) { + if (expr.parent.kind === 296 /* SyntaxKind.PropertyAssignment */) { var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); @@ -87242,7 +87639,7 @@ var ts; var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; - var elementType = checkIteratedTypeOrElementType(65 /* Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; + var elementType = checkIteratedTypeOrElementType(65 /* IterationUse.Destructuring */, typeOfArrayLiteral, undefinedType, expr.parent) || errorType; return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -87275,14 +87672,14 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return getStringLiteralType(ts.idText(name)); - case 8 /* NumericLiteral */: - case 10 /* StringLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return getStringLiteralType(name.text); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: var nameType = checkComputedPropertyName(name); - return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; + return isTypeAssignableToKind(nameType, 12288 /* TypeFlags.ESSymbolLike */) ? nameType : stringType; default: return ts.Debug.fail("Unsupported property name."); } @@ -87292,8 +87689,8 @@ var ts; function getAugmentedPropertiesOfType(type) { type = getApparentType(type); var propsByName = ts.createSymbolTable(getPropertiesOfType(type)); - var functionType = getSignaturesOfType(type, 0 /* Call */).length ? globalCallableFunctionType : - getSignaturesOfType(type, 1 /* Construct */).length ? globalNewableFunctionType : + var functionType = getSignaturesOfType(type, 0 /* SignatureKind.Call */).length ? globalCallableFunctionType : + getSignaturesOfType(type, 1 /* SignatureKind.Construct */).length ? globalNewableFunctionType : undefined; if (functionType) { ts.forEach(getPropertiesOfType(functionType), function (p) { @@ -87312,10 +87709,10 @@ var ts; return roots ? ts.flatMap(roots, getRootSymbols) : [symbol]; } function getImmediateRootSymbols(symbol) { - if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { + if (ts.getCheckFlags(symbol) & 6 /* CheckFlags.Synthetic */) { return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); }); } - else if (symbol.flags & 33554432 /* Transient */) { + else if (symbol.flags & 33554432 /* SymbolFlags.Transient */) { var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin; return leftSpread ? [leftSpread, rightSpread] : syntheticOrigin ? [syntheticOrigin] @@ -87362,13 +87759,13 @@ var ts; // for export assignments - check if resolved symbol for RHS is itself a value // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment - ? !!(moduleSymbol.flags & 111551 /* Value */) + ? !!(moduleSymbol.flags & 111551 /* SymbolFlags.Value */) : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; function isValue(s) { s = resolveSymbol(s); - return s && !!(s.flags & 111551 /* Value */); + return s && !!(s.flags & 111551 /* SymbolFlags.Value */); } } function isNameOfModuleOrEnumDeclaration(node) { @@ -87386,19 +87783,19 @@ var ts; // declaration if it contains an exported member with the same name. var symbol = getReferencedValueSymbol(node, /*startInDeclarationContainer*/ isNameOfModuleOrEnumDeclaration(node)); if (symbol) { - if (symbol.flags & 1048576 /* ExportValue */) { + if (symbol.flags & 1048576 /* SymbolFlags.ExportValue */) { // If we reference an exported entity within the same module declaration, then whether // we prefix depends on the kind of entity. SymbolFlags.ExportHasLocal encompasses all the // kinds that we do NOT prefix. var exportSymbol = getMergedSymbol(symbol.exportSymbol); - if (!prefixLocals && exportSymbol.flags & 944 /* ExportHasLocal */ && !(exportSymbol.flags & 3 /* Variable */)) { + if (!prefixLocals && exportSymbol.flags & 944 /* SymbolFlags.ExportHasLocal */ && !(exportSymbol.flags & 3 /* SymbolFlags.Variable */)) { return undefined; } symbol = exportSymbol; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* SymbolFlags.ValueModule */ && ((_a = parentSymbol_1.valueDeclaration) === null || _a === void 0 ? void 0 : _a.kind) === 305 /* SyntaxKind.SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -87421,7 +87818,7 @@ var ts; var symbol = getReferencedValueSymbol(node); // We should only get the declaration of an alias if there isn't a local value // declaration for the symbol - if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* Value */) && !getTypeOnlyAliasDeclaration(symbol)) { + if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) { return getDeclarationOfAliasSymbol(symbol); } } @@ -87430,20 +87827,20 @@ var ts; function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 292 /* SyntaxKind.CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { - if (symbol.flags & 418 /* BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { + if (symbol.flags & 418 /* SymbolFlags.BlockScoped */ && symbol.valueDeclaration && !ts.isSourceFile(symbol.valueDeclaration)) { var links = getSymbolLinks(symbol); if (links.isDeclarationWithCollidingName === undefined) { var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (resolveName(container.parent, symbol.escapedName, 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { + if (resolveName(container.parent, symbol.escapedName, 111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } - else if (nodeLinks_1.flags & 262144 /* CapturedBlockScopedBinding */) { + else if (nodeLinks_1.flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */) { // binding is captured in the function // should be renamed if: // - binding is not top level - top level bindings never collide with anything @@ -87459,9 +87856,9 @@ var ts; // * variables from initializer are passed to rewritten loop body as parameters so they are not captured directly // * variables that are declared immediately in loop body will become top level variable after loop is rewritten and thus // they will not collide with anything - var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; + var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 235 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 235 /* SyntaxKind.Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -87502,20 +87899,20 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 267 /* ImportClause */: - case 268 /* NamespaceImport */: - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 267 /* SyntaxKind.ImportClause */: + case 268 /* SyntaxKind.NamespaceImport */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: var symbol = getSymbolOfNode(node); return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && (ts.isNamespaceExport(exportClause) || ts.some(exportClause.elements, isValueAliasDeclaration)); - case 271 /* ExportAssignment */: - return node.expression && node.expression.kind === 79 /* Identifier */ ? + case 271 /* SyntaxKind.ExportAssignment */: + return node.expression && node.expression.kind === 79 /* SyntaxKind.Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } @@ -87523,7 +87920,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 305 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -87540,7 +87937,7 @@ var ts; } // const enums and modules that contain only const enums are not considered values from the emit perspective // unless 'preserveConstEnums' option is set to true - return !!(target.flags & 111551 /* Value */) && + return !!(target.flags & 111551 /* SymbolFlags.Value */) && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target)); } function isConstEnumOrConstEnumOnlyModule(s) { @@ -87554,8 +87951,8 @@ var ts; return true; } var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217 - if (target && ts.getEffectiveModifierFlags(node) & 1 /* Export */ && - target.flags & 111551 /* Value */ && + if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ && + target.flags & 111551 /* SymbolFlags.Value */ && (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) { // An `export import ... =` of a value symbol is always considered referenced return true; @@ -87593,13 +87990,13 @@ var ts; !isOptionalParameter(parameter) && !ts.isJSDocParameterTag(parameter) && !!parameter.initializer && - !ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + !ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isOptionalUninitializedParameterProperty(parameter) { return strictNullChecks && isOptionalParameter(parameter) && !parameter.initializer && - ts.hasSyntacticModifier(parameter, 16476 /* ParameterPropertyModifier */); + ts.hasSyntacticModifier(parameter, 16476 /* ModifierFlags.ParameterPropertyModifier */); } function isExpandoFunctionDeclaration(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -87607,10 +88004,10 @@ var ts; return false; } var symbol = getSymbolOfNode(declaration); - if (!symbol || !(symbol.flags & 16 /* Function */)) { + if (!symbol || !(symbol.flags & 16 /* SymbolFlags.Function */)) { return false; } - return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); + return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 /* SymbolFlags.Value */ && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); }); } function getPropertiesOfContainerFunction(node) { var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration); @@ -87633,19 +88030,19 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 299 /* EnumMember */: - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 299 /* SyntaxKind.EnumMember */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 299 /* EnumMember */) { + if (node.kind === 299 /* SyntaxKind.EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; - if (symbol && (symbol.flags & 8 /* EnumMember */)) { + if (symbol && (symbol.flags & 8 /* SymbolFlags.EnumMember */)) { // inline property\index accesses only for const enums var member = symbol.valueDeclaration; if (ts.isEnumConst(member.parent)) { @@ -87655,7 +88052,7 @@ var ts; return undefined; } function isFunctionType(type) { - return !!(type.flags & 524288 /* Object */) && getSignaturesOfType(type, 0 /* Call */).length > 0; + return !!(type.flags & 524288 /* TypeFlags.Object */) && getSignaturesOfType(type, 0 /* SignatureKind.Call */).length > 0; } function getTypeReferenceSerializationKind(typeNameIn, location) { var _a, _b; @@ -87671,14 +88068,14 @@ var ts; // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var isTypeOnly = false; if (ts.isQualifiedName(typeName)) { - var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var rootValueSymbol = resolveEntityName(ts.getFirstIdentifier(typeName), 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); isTypeOnly = !!((_a = rootValueSymbol === null || rootValueSymbol === void 0 ? void 0 : rootValueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)); } - var valueSymbol = resolveEntityName(typeName, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); - var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* Alias */ ? resolveAlias(valueSymbol) : valueSymbol; + var valueSymbol = resolveEntityName(typeName, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location); + var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(valueSymbol) : valueSymbol; isTypeOnly || (isTypeOnly = !!((_b = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _b === void 0 ? void 0 : _b.every(ts.isTypeOnlyImportOrExportDeclaration))); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. - var typeSymbol = resolveEntityName(typeName, 788968 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + var typeSymbol = resolveEntityName(typeName, 788968 /* SymbolFlags.Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (resolvedSymbol && resolvedSymbol === typeSymbol) { var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) { @@ -87697,28 +88094,28 @@ var ts; if (isErrorType(type)) { return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown; } - else if (type.flags & 3 /* AnyOrUnknown */) { + else if (type.flags & 3 /* TypeFlags.AnyOrUnknown */) { return ts.TypeReferenceSerializationKind.ObjectType; } - else if (isTypeAssignableToKind(type, 16384 /* Void */ | 98304 /* Nullable */ | 131072 /* Never */)) { + else if (isTypeAssignableToKind(type, 16384 /* TypeFlags.Void */ | 98304 /* TypeFlags.Nullable */ | 131072 /* TypeFlags.Never */)) { return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType; } - else if (isTypeAssignableToKind(type, 528 /* BooleanLike */)) { + else if (isTypeAssignableToKind(type, 528 /* TypeFlags.BooleanLike */)) { return ts.TypeReferenceSerializationKind.BooleanType; } - else if (isTypeAssignableToKind(type, 296 /* NumberLike */)) { + else if (isTypeAssignableToKind(type, 296 /* TypeFlags.NumberLike */)) { return ts.TypeReferenceSerializationKind.NumberLikeType; } - else if (isTypeAssignableToKind(type, 2112 /* BigIntLike */)) { + else if (isTypeAssignableToKind(type, 2112 /* TypeFlags.BigIntLike */)) { return ts.TypeReferenceSerializationKind.BigIntLikeType; } - else if (isTypeAssignableToKind(type, 402653316 /* StringLike */)) { + else if (isTypeAssignableToKind(type, 402653316 /* TypeFlags.StringLike */)) { return ts.TypeReferenceSerializationKind.StringLikeType; } else if (isTupleType(type)) { return ts.TypeReferenceSerializationKind.ArrayLikeType; } - else if (isTypeAssignableToKind(type, 12288 /* ESSymbolLike */)) { + else if (isTypeAssignableToKind(type, 12288 /* TypeFlags.ESSymbolLike */)) { return ts.TypeReferenceSerializationKind.ESSymbolType; } else if (isFunctionType(type)) { @@ -87734,37 +88131,37 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); - var type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) + var type = symbol && !(symbol.flags & (2048 /* SymbolFlags.TypeLiteral */ | 131072 /* SymbolFlags.Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType; - if (type.flags & 8192 /* UniqueESSymbol */ && + if (type.flags & 8192 /* TypeFlags.UniqueESSymbol */ && type.symbol === symbol) { - flags |= 1048576 /* AllowUniqueESSymbolType */; + flags |= 1048576 /* NodeBuilderFlags.AllowUniqueESSymbolType */; } if (addUndefined) { type = getOptionalType(type); } - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); - return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.factory.createToken(130 /* AnyKeyword */); + return ts.factory.createToken(130 /* SyntaxKind.AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); - return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); + return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* NodeBuilderFlags.MultilineObjectLiterals */, tracker); } function hasGlobalName(name) { return globals.has(ts.escapeLeadingUnderscores(name)); @@ -87783,7 +88180,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); + return resolveName(location, reference.escapedText, 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(referenceIn) { if (!ts.isGeneratedIdentifier(referenceIn)) { @@ -87804,7 +88201,7 @@ var ts; return false; } function literalTypeToNode(type, enclosing, tracker) { - var enumResult = type.flags & 1024 /* EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* Value */, enclosing, /*flags*/ undefined, tracker) + var enumResult = type.flags & 1024 /* TypeFlags.EnumLiteral */ ? nodeBuilder.symbolToExpression(type.symbol, 111551 /* SymbolFlags.Value */, enclosing, /*flags*/ undefined, tracker) : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse(); if (enumResult) return enumResult; @@ -87912,18 +88309,18 @@ var ts; isLateBound: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration); var symbol = node && getSymbolOfNode(node); - return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */); + return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* CheckFlags.Late */); }, getJsxFactoryEntity: getJsxFactoryEntity, getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 173 /* SetAccessor */ ? 172 /* GetAccessor */ : 173 /* SetAccessor */; + var otherKind = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? 172 /* SyntaxKind.GetAccessor */ : 173 /* SyntaxKind.SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 173 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 172 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 173 /* SyntaxKind.SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -87939,7 +88336,7 @@ var ts; }, getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { var n = ts.getParseTreeNode(node); - ts.Debug.assert(n && n.kind === 305 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + ts.Debug.assert(n && n.kind === 305 /* SyntaxKind.SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); var sym = getSymbolOfNode(node); if (!sym) { return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); @@ -87976,7 +88373,7 @@ var ts; return false; } function isInHeritageClause(node) { - return node.parent && node.parent.kind === 228 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* HeritageClause */; + return node.parent && node.parent.kind === 228 /* SyntaxKind.ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 291 /* SyntaxKind.HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -87984,12 +88381,19 @@ var ts; if (!fileToDirective) { return undefined; } + // computed property name should use node as value // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { - meaning = 111551 /* Value */ | 1048576 /* ExportValue */; + var meaning; + if (node.parent.kind === 162 /* SyntaxKind.ComputedPropertyName */) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; + } + else { + meaning = 788968 /* SymbolFlags.Type */ | 1920 /* SymbolFlags.Namespace */; + if ((node.kind === 79 /* SyntaxKind.Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ && !isInHeritageClause(node))) { + meaning = 111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */; + } } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined; @@ -88036,7 +88440,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 305 /* SyntaxKind.SourceFile */ && current.flags & 512 /* SymbolFlags.ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -88064,12 +88468,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 261 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 261 /* SyntaxKind.ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 305 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 305 /* SyntaxKind.SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -88140,7 +88544,7 @@ var ts; getSymbolLinks(undefinedSymbol).type = undefinedWideningType; getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = errorType; - getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* Anonymous */, globalThisSymbol); + getSymbolLinks(globalThisSymbol).type = createObjectType(16 /* ObjectFlags.Anonymous */, globalThisSymbol); // Initialize special types globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); @@ -88202,28 +88606,28 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* NodeFlags.Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 4194304 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* ExternalEmitHelpers.FirstEmitHelper */; helper <= 4194304 /* ExternalEmitHelpers.LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); - var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); + var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* SymbolFlags.Value */); if (!symbol) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } - else if (helper & 524288 /* ClassPrivateFieldGet */) { + else if (helper & 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 3; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 4); } } - else if (helper & 1048576 /* ClassPrivateFieldSet */) { + else if (helper & 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 4; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 5); } } - else if (helper & 1024 /* SpreadArray */) { + else if (helper & 1024 /* ExternalEmitHelpers.SpreadArray */) { if (!ts.some(getSignaturesOfSymbol(symbol), function (signature) { return getParameterCount(signature) > 2; })) { error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name, 3); } @@ -88237,29 +88641,29 @@ var ts; } function getHelperName(helper) { switch (helper) { - case 1 /* Extends */: return "__extends"; - case 2 /* Assign */: return "__assign"; - case 4 /* Rest */: return "__rest"; - case 8 /* Decorate */: return "__decorate"; - case 16 /* Metadata */: return "__metadata"; - case 32 /* Param */: return "__param"; - case 64 /* Awaiter */: return "__awaiter"; - case 128 /* Generator */: return "__generator"; - case 256 /* Values */: return "__values"; - case 512 /* Read */: return "__read"; - case 1024 /* SpreadArray */: return "__spreadArray"; - case 2048 /* Await */: return "__await"; - case 4096 /* AsyncGenerator */: return "__asyncGenerator"; - case 8192 /* AsyncDelegator */: return "__asyncDelegator"; - case 16384 /* AsyncValues */: return "__asyncValues"; - case 32768 /* ExportStar */: return "__exportStar"; - case 65536 /* ImportStar */: return "__importStar"; - case 131072 /* ImportDefault */: return "__importDefault"; - case 262144 /* MakeTemplateObject */: return "__makeTemplateObject"; - case 524288 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; - case 1048576 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; - case 2097152 /* ClassPrivateFieldIn */: return "__classPrivateFieldIn"; - case 4194304 /* CreateBinding */: return "__createBinding"; + case 1 /* ExternalEmitHelpers.Extends */: return "__extends"; + case 2 /* ExternalEmitHelpers.Assign */: return "__assign"; + case 4 /* ExternalEmitHelpers.Rest */: return "__rest"; + case 8 /* ExternalEmitHelpers.Decorate */: return "__decorate"; + case 16 /* ExternalEmitHelpers.Metadata */: return "__metadata"; + case 32 /* ExternalEmitHelpers.Param */: return "__param"; + case 64 /* ExternalEmitHelpers.Awaiter */: return "__awaiter"; + case 128 /* ExternalEmitHelpers.Generator */: return "__generator"; + case 256 /* ExternalEmitHelpers.Values */: return "__values"; + case 512 /* ExternalEmitHelpers.Read */: return "__read"; + case 1024 /* ExternalEmitHelpers.SpreadArray */: return "__spreadArray"; + case 2048 /* ExternalEmitHelpers.Await */: return "__await"; + case 4096 /* ExternalEmitHelpers.AsyncGenerator */: return "__asyncGenerator"; + case 8192 /* ExternalEmitHelpers.AsyncDelegator */: return "__asyncDelegator"; + case 16384 /* ExternalEmitHelpers.AsyncValues */: return "__asyncValues"; + case 32768 /* ExternalEmitHelpers.ExportStar */: return "__exportStar"; + case 65536 /* ExternalEmitHelpers.ImportStar */: return "__importStar"; + case 131072 /* ExternalEmitHelpers.ImportDefault */: return "__importDefault"; + case 262144 /* ExternalEmitHelpers.MakeTemplateObject */: return "__makeTemplateObject"; + case 524288 /* ExternalEmitHelpers.ClassPrivateFieldGet */: return "__classPrivateFieldGet"; + case 1048576 /* ExternalEmitHelpers.ClassPrivateFieldSet */: return "__classPrivateFieldSet"; + case 2097152 /* ExternalEmitHelpers.ClassPrivateFieldIn */: return "__classPrivateFieldIn"; + case 4194304 /* ExternalEmitHelpers.CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -88281,14 +88685,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 169 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 172 /* GetAccessor */ || node.kind === 173 /* SetAccessor */) { + else if (node.kind === 172 /* SyntaxKind.GetAccessor */ || node.kind === 173 /* SyntaxKind.SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (ts.hasDecorators(accessors.firstAccessor) && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -88302,71 +88706,71 @@ var ts; return quickResult; } var lastStatic, lastDeclare, lastAsync, lastOverride; - var flags = 0 /* None */; + var flags = 0 /* ModifierFlags.None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; if (ts.isDecorator(modifier)) continue; - if (modifier.kind !== 145 /* ReadonlyKeyword */) { - if (node.kind === 166 /* PropertySignature */ || node.kind === 168 /* MethodSignature */) { + if (modifier.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.kind === 166 /* SyntaxKind.PropertySignature */ || node.kind === 168 /* SyntaxKind.MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 176 /* IndexSignature */ && (modifier.kind !== 124 /* StaticKeyword */ || !ts.isClassLike(node.parent))) { + if (node.kind === 176 /* SyntaxKind.IndexSignature */ && (modifier.kind !== 124 /* SyntaxKind.StaticKeyword */ || !ts.isClassLike(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } - if (modifier.kind !== 101 /* InKeyword */ && modifier.kind !== 144 /* OutKeyword */) { - if (node.kind === 163 /* TypeParameter */) { + if (modifier.kind !== 101 /* SyntaxKind.InKeyword */ && modifier.kind !== 144 /* SyntaxKind.OutKeyword */) { + if (node.kind === 163 /* SyntaxKind.TypeParameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_parameter, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 85 /* ConstKeyword */: - if (node.kind !== 260 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* ConstKeyword */)); + case 85 /* SyntaxKind.ConstKeyword */: + if (node.kind !== 260 /* SyntaxKind.EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(85 /* SyntaxKind.ConstKeyword */)); } break; - case 159 /* OverrideKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "override"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "override", "declare"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "override", "async"); } - flags |= 16384 /* Override */; + flags |= 16384 /* ModifierFlags.Override */; lastOverride = modifier; break; - case 123 /* PublicKeyword */: - case 122 /* ProtectedKeyword */: - case 121 /* PrivateKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (flags & 28 /* AccessibilityModifier */) { + if (flags & 28 /* ModifierFlags.AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "override"); } - else if (flags & 32 /* Static */) { + else if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } - else if (flags & 128 /* Abstract */) { - if (modifier.kind === 121 /* PrivateKeyword */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { + if (modifier.kind === 121 /* SyntaxKind.PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -88378,185 +88782,185 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 124 /* StaticKeyword */: - if (flags & 32 /* Static */) { + case 124 /* SyntaxKind.StaticKeyword */: + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (flags & 64 /* Readonly */) { + else if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + else if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "override"); } - flags |= 32 /* Static */; + flags |= 32 /* ModifierFlags.Static */; lastStatic = modifier; break; - case 145 /* ReadonlyKeyword */: - if (flags & 64 /* Readonly */) { + case 145 /* SyntaxKind.ReadonlyKeyword */: + if (flags & 64 /* ModifierFlags.Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 167 /* PropertyDeclaration */ && node.kind !== 166 /* PropertySignature */ && node.kind !== 176 /* IndexSignature */ && node.kind !== 164 /* Parameter */) { + else if (node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && node.kind !== 166 /* SyntaxKind.PropertySignature */ && node.kind !== 176 /* SyntaxKind.IndexSignature */ && node.kind !== 164 /* SyntaxKind.Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter reports an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } - flags |= 64 /* Readonly */; + flags |= 64 /* ModifierFlags.Readonly */; break; - case 93 /* ExportKeyword */: - if (flags & 1 /* Export */) { + case 93 /* SyntaxKind.ExportKeyword */: + if (flags & 1 /* ModifierFlags.Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } - else if (flags & 2 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (flags & 128 /* Abstract */) { + else if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } - flags |= 1 /* Export */; + flags |= 1 /* ModifierFlags.Export */; break; - case 88 /* DefaultKeyword */: - var container = node.parent.kind === 305 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 261 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 88 /* SyntaxKind.DefaultKeyword */: + var container = node.parent.kind === 305 /* SyntaxKind.SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 261 /* SyntaxKind.ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } - else if (!(flags & 1 /* Export */)) { + else if (!(flags & 1 /* ModifierFlags.Export */)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } - flags |= 512 /* Default */; + flags |= 512 /* ModifierFlags.Default */; break; - case 135 /* DeclareKeyword */: - if (flags & 2 /* Ambient */) { + case 135 /* SyntaxKind.DeclareKeyword */: + if (flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (flags & 256 /* Async */) { + else if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (flags & 16384 /* Override */) { + else if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "override"); } else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) { + else if ((node.parent.flags & 16777216 /* NodeFlags.Ambient */) && node.parent.kind === 262 /* SyntaxKind.ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } else if (ts.isPrivateIdentifierClassElementDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare"); } - flags |= 2 /* Ambient */; + flags |= 2 /* ModifierFlags.Ambient */; lastDeclare = modifier; break; - case 126 /* AbstractKeyword */: - if (flags & 128 /* Abstract */) { + case 126 /* SyntaxKind.AbstractKeyword */: + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 257 /* ClassDeclaration */ && - node.kind !== 180 /* ConstructorType */) { - if (node.kind !== 169 /* MethodDeclaration */ && - node.kind !== 167 /* PropertyDeclaration */ && - node.kind !== 172 /* GetAccessor */ && - node.kind !== 173 /* SetAccessor */) { + if (node.kind !== 257 /* SyntaxKind.ClassDeclaration */ && + node.kind !== 180 /* SyntaxKind.ConstructorType */) { + if (node.kind !== 169 /* SyntaxKind.MethodDeclaration */ && + node.kind !== 167 /* SyntaxKind.PropertyDeclaration */ && + node.kind !== 172 /* SyntaxKind.GetAccessor */ && + node.kind !== 173 /* SyntaxKind.SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 257 /* ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ && ts.hasSyntacticModifier(node.parent, 128 /* ModifierFlags.Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } - if (flags & 32 /* Static */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); } - if (flags & 8 /* Private */) { + if (flags & 8 /* ModifierFlags.Private */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); } - if (flags & 256 /* Async */ && lastAsync) { + if (flags & 256 /* ModifierFlags.Async */ && lastAsync) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "abstract", "override"); } } - if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* PrivateIdentifier */) { + if (ts.isNamedDeclaration(node) && node.name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract"); } - flags |= 128 /* Abstract */; + flags |= 128 /* ModifierFlags.Abstract */; break; - case 131 /* AsyncKeyword */: - if (flags & 256 /* Async */) { + case 131 /* SyntaxKind.AsyncKeyword */: + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) { + else if (flags & 2 /* ModifierFlags.Ambient */ || node.parent.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 164 /* Parameter */) { + else if (node.kind === 164 /* SyntaxKind.Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } - if (flags & 128 /* Abstract */) { + if (flags & 128 /* ModifierFlags.Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract"); } - flags |= 256 /* Async */; + flags |= 256 /* ModifierFlags.Async */; lastAsync = modifier; break; - case 101 /* InKeyword */: - case 144 /* OutKeyword */: - var inOutFlag = modifier.kind === 101 /* InKeyword */ ? 32768 /* In */ : 65536 /* Out */; - var inOutText = modifier.kind === 101 /* InKeyword */ ? "in" : "out"; - if (node.kind !== 163 /* TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: + var inOutFlag = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? 32768 /* ModifierFlags.In */ : 65536 /* ModifierFlags.Out */; + var inOutText = modifier.kind === 101 /* SyntaxKind.InKeyword */ ? "in" : "out"; + if (node.kind !== 163 /* SyntaxKind.TypeParameter */ || !(ts.isInterfaceDeclaration(node.parent) || ts.isClassLike(node.parent) || ts.isTypeAliasDeclaration(node.parent))) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_can_only_appear_on_a_type_parameter_of_a_class_interface_or_type_alias, inOutText); } if (flags & inOutFlag) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, inOutText); } - if (inOutFlag & 32768 /* In */ && flags & 65536 /* Out */) { + if (inOutFlag & 32768 /* ModifierFlags.In */ && flags & 65536 /* ModifierFlags.Out */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "in", "out"); } flags |= inOutFlag; break; } } - if (node.kind === 171 /* Constructor */) { - if (flags & 32 /* Static */) { + if (node.kind === 171 /* SyntaxKind.Constructor */) { + if (flags & 32 /* ModifierFlags.Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - if (flags & 16384 /* Override */) { + if (flags & 16384 /* ModifierFlags.Override */) { return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217 } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); } return false; } - else if ((node.kind === 266 /* ImportDeclaration */ || node.kind === 265 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 266 /* SyntaxKind.ImportDeclaration */ || node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */) && flags & 2 /* ModifierFlags.Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 164 /* Parameter */ && (flags & 16476 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 164 /* SyntaxKind.Parameter */ && (flags & 16476 /* ModifierFlags.ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } - if (flags & 256 /* Async */) { + if (flags & 256 /* ModifierFlags.Async */) { return checkGrammarAsyncModifier(node, lastAsync); } return false; @@ -88574,48 +88978,48 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: - case 176 /* IndexSignature */: - case 261 /* ModuleDeclaration */: - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: - case 164 /* Parameter */: - case 163 /* TypeParameter */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: + case 164 /* SyntaxKind.Parameter */: + case 163 /* SyntaxKind.TypeParameter */: return false; - case 170 /* ClassStaticBlockDeclaration */: - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 264 /* NamespaceExportDeclaration */: - case 179 /* FunctionType */: - case 276 /* MissingDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 276 /* SyntaxKind.MissingDeclaration */: return true; default: - if (node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { return false; } switch (node.kind) { - case 256 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 131 /* AsyncKeyword */); - case 257 /* ClassDeclaration */: - case 180 /* ConstructorType */: - return nodeHasAnyModifiersExcept(node, 126 /* AbstractKeyword */); - case 226 /* ClassExpression */: - case 258 /* InterfaceDeclaration */: - case 237 /* VariableStatement */: - case 259 /* TypeAliasDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 131 /* SyntaxKind.AsyncKeyword */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 180 /* SyntaxKind.ConstructorType */: + return nodeHasAnyModifiersExcept(node, 126 /* SyntaxKind.AbstractKeyword */); + case 226 /* SyntaxKind.ClassExpression */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return true; - case 260 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 85 /* ConstKeyword */); + case 260 /* SyntaxKind.EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 85 /* SyntaxKind.ConstKeyword */); default: ts.Debug.assertNever(node); } @@ -88632,10 +89036,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 169 /* MethodDeclaration */: - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 214 /* ArrowFunction */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 214 /* SyntaxKind.ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -88664,7 +89068,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 16777216 /* NodeFlags.Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -88689,7 +89093,7 @@ var ts; return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); }); } function checkGrammarForUseStrictSimpleParameterList(node) { - if (languageVersion >= 3 /* ES2016 */) { + if (languageVersion >= 3 /* ScriptTarget.ES2016 */) { var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements); if (useStrictDirective_1) { var nonSimpleParameters = getNonSimpleParameters(node.parameters); @@ -88724,7 +89128,7 @@ var ts; return false; } if (node.typeParameters && !(ts.length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { - if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Mts */, ".cts" /* Cts */])) { + if (file && ts.fileExtensionIsOneOf(file.fileName, [".mts" /* Extension.Mts */, ".cts" /* Extension.Cts */])) { grammarErrorOnNode(node.typeParameters[0], ts.Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } @@ -88760,7 +89164,7 @@ var ts; return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } var type = getTypeFromTypeNode(parameter.type); - if (someType(type, function (t) { return !!(t.flags & 8576 /* StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { + if (someType(type, function (t) { return !!(t.flags & 8576 /* TypeFlags.StringOrNumberLiteralOrUnique */); }) || isGenericType(type)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_object_type_instead); } if (!everyType(type, isValidIndexKeyType)) { @@ -88789,7 +89193,7 @@ var ts; checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } function checkGrammarTaggedTemplateChain(node) { - if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + if (node.questionDotToken || node.flags & 32 /* NodeFlags.OptionalChain */) { return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); } return false; @@ -88817,7 +89221,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -88830,7 +89234,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -88846,14 +89250,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 94 /* ExtendsKeyword */) { + if (heritageClause.token === 94 /* SyntaxKind.ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 117 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -88864,21 +89268,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 162 /* ComputedPropertyName */) { + if (node.kind !== 162 /* SyntaxKind.ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 221 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 221 /* SyntaxKind.BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ || - node.kind === 213 /* FunctionExpression */ || - node.kind === 169 /* MethodDeclaration */); - if (node.flags & 16777216 /* Ambient */) { + ts.Debug.assert(node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || + node.kind === 213 /* SyntaxKind.FunctionExpression */ || + node.kind === 169 /* SyntaxKind.MethodDeclaration */); + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -88896,7 +89300,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 298 /* SpreadAssignment */) { + if (prop.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -88907,23 +89311,23 @@ var ts; continue; } var name = prop.name; - if (name.kind === 162 /* ComputedPropertyName */) { + if (name.kind === 162 /* SyntaxKind.ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 297 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 297 /* SyntaxKind.ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern); } - if (name.kind === 80 /* PrivateIdentifier */) { + if (name.kind === 80 /* SyntaxKind.PrivateIdentifier */) { grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (ts.canHaveModifiers(prop) && prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (ts.isModifier(mod) && (mod.kind !== 131 /* AsyncKeyword */ || prop.kind !== 169 /* MethodDeclaration */)) { + if (ts.isModifier(mod) && (mod.kind !== 131 /* SyntaxKind.AsyncKeyword */ || prop.kind !== 169 /* SyntaxKind.MethodDeclaration */)) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -88944,24 +89348,24 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 297 /* ShorthandPropertyAssignment */: - case 296 /* PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name.kind === 8 /* NumericLiteral */) { + if (name.kind === 8 /* SyntaxKind.NumericLiteral */) { checkGrammarNumericLiteral(name); } - currentKind = 4 /* PropertyAssignment */; + currentKind = 4 /* DeclarationMeaning.PropertyAssignment */; break; - case 169 /* MethodDeclaration */: - currentKind = 8 /* Method */; + case 169 /* SyntaxKind.MethodDeclaration */: + currentKind = 8 /* DeclarationMeaning.Method */; break; - case 172 /* GetAccessor */: - currentKind = 1 /* GetAccessor */; + case 172 /* SyntaxKind.GetAccessor */: + currentKind = 1 /* DeclarationMeaning.GetAccessor */; break; - case 173 /* SetAccessor */: - currentKind = 2 /* SetAccessor */; + case 173 /* SyntaxKind.SetAccessor */: + currentKind = 2 /* DeclarationMeaning.SetAccessor */; break; default: throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); @@ -88976,14 +89380,14 @@ var ts; seen.set(effectiveName, currentKind); } else { - if ((currentKind & 8 /* Method */) && (existingKind & 8 /* Method */)) { + if ((currentKind & 8 /* DeclarationMeaning.Method */) && (existingKind & 8 /* DeclarationMeaning.Method */)) { grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name)); } - else if ((currentKind & 4 /* PropertyAssignment */) && (existingKind & 4 /* PropertyAssignment */)) { + else if ((currentKind & 4 /* DeclarationMeaning.PropertyAssignment */) && (existingKind & 4 /* DeclarationMeaning.PropertyAssignment */)) { grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name, ts.getTextOfNode(name)); } - else if ((currentKind & 3 /* GetOrSetAccessor */) && (existingKind & 3 /* GetOrSetAccessor */)) { - if (existingKind !== 3 /* GetOrSetAccessor */ && currentKind !== existingKind) { + else if ((currentKind & 3 /* DeclarationMeaning.GetOrSetAccessor */) && (existingKind & 3 /* DeclarationMeaning.GetOrSetAccessor */)) { + if (existingKind !== 3 /* DeclarationMeaning.GetOrSetAccessor */ && currentKind !== existingKind) { seen.set(effectiveName, currentKind | existingKind); } else { @@ -89003,7 +89407,7 @@ var ts; var seen = new ts.Map(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 287 /* JsxSpreadAttribute */) { + if (attr.kind === 287 /* SyntaxKind.JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -89013,7 +89417,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 288 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 288 /* SyntaxKind.JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -89048,8 +89452,8 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 244 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if (!(forInOrOfStatement.flags & 32768 /* AwaitContext */)) { + if (forInOrOfStatement.kind === 244 /* SyntaxKind.ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if (!(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */)) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (ts.isInTopLevelContext(forInOrOfStatement)) { if (!hasParseDiagnostics(sourceFile)) { @@ -89067,7 +89471,7 @@ var ts; case ts.ModuleKind.ES2022: case ts.ModuleKind.ESNext: case ts.ModuleKind.System: - if (languageVersion >= 4 /* ES2017 */) { + if (languageVersion >= 4 /* ScriptTarget.ES2017 */) { break; } // fallthrough @@ -89082,8 +89486,8 @@ var ts; if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 171 /* Constructor */) { - ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); + if (func && func.kind !== 171 /* SyntaxKind.Constructor */) { + ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* FunctionFlags.Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); } @@ -89094,12 +89498,12 @@ var ts; return false; } } - if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* AwaitContext */) && + if (ts.isForOfStatement(forInOrOfStatement) && !(forInOrOfStatement.flags & 32768 /* NodeFlags.AwaitContext */) && ts.isIdentifier(forInOrOfStatement.initializer) && forInOrOfStatement.initializer.escapedText === "async") { grammarErrorOnNode(forInOrOfStatement.initializer, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_async); return false; } - if (forInOrOfStatement.initializer.kind === 255 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -89114,20 +89518,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 243 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 243 /* SyntaxKind.ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -89137,22 +89541,22 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) { - if (languageVersion < 1 /* ES5 */) { + if (!(accessor.flags & 16777216 /* NodeFlags.Ambient */) && (accessor.parent.kind !== 182 /* SyntaxKind.TypeLiteral */) && (accessor.parent.kind !== 258 /* SyntaxKind.InterfaceDeclaration */)) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(accessor.name)) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } - if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{"); } } if (accessor.body) { - if (ts.hasSyntacticModifier(accessor, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(accessor, 128 /* ModifierFlags.Abstract */)) { return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation); } - if (accessor.parent.kind === 182 /* TypeLiteral */ || accessor.parent.kind === 258 /* InterfaceDeclaration */) { + if (accessor.parent.kind === 182 /* SyntaxKind.TypeLiteral */ || accessor.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return grammarErrorOnNode(accessor.body, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } @@ -89160,11 +89564,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 173 /* SetAccessor */) { + if (accessor.kind === 173 /* SyntaxKind.SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -89186,17 +89590,17 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 172 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 154 /* UniqueKeyword */) { - if (node.type.kind !== 151 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SymbolKeyword */)); + if (node.operator === 154 /* SyntaxKind.UniqueKeyword */) { + if (node.type.kind !== 151 /* SyntaxKind.SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) { @@ -89206,26 +89610,26 @@ var ts; } } switch (parent.kind) { - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 79 /* Identifier */) { + if (decl.name.kind !== 79 /* SyntaxKind.Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement); } - if (!(decl.parent.flags & 2 /* Const */)) { + if (!(decl.parent.flags & 2 /* NodeFlags.Const */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (!ts.isStatic(parent) || !ts.hasEffectiveReadonlyModifier(parent)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 166 /* PropertySignature */: - if (!ts.hasSyntacticModifier(parent, 64 /* Readonly */)) { + case 166 /* SyntaxKind.PropertySignature */: + if (!ts.hasSyntacticModifier(parent, 64 /* ModifierFlags.Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } break; @@ -89233,9 +89637,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 145 /* ReadonlyKeyword */) { - if (node.type.kind !== 183 /* ArrayType */ && node.type.kind !== 184 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SymbolKeyword */)); + else if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { + if (node.type.kind !== 183 /* SyntaxKind.ArrayType */ && node.type.kind !== 184 /* SyntaxKind.TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(151 /* SyntaxKind.SymbolKeyword */)); } } } @@ -89248,10 +89652,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 169 /* MethodDeclaration */) { - if (node.parent.kind === 205 /* ObjectLiteralExpression */) { + if (node.kind === 169 /* SyntaxKind.MethodDeclaration */) { + if (node.parent.kind === 205 /* SyntaxKind.ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 131 /* SyntaxKind.AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -89269,7 +89673,7 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } // Technically, computed properties in ambient contexts is disallowed @@ -89277,17 +89681,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 169 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 169 /* SyntaxKind.MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 182 /* TypeLiteral */) { + else if (node.parent.kind === 182 /* SyntaxKind.TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -89298,11 +89702,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 245 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 245 /* SyntaxKind.ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -89310,8 +89714,8 @@ var ts; return false; } break; - case 249 /* SwitchStatement */: - if (node.kind === 246 /* BreakStatement */ && !node.label) { + case 249 /* SyntaxKind.SwitchStatement */: + if (node.kind === 246 /* SyntaxKind.BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -89326,13 +89730,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 246 /* BreakStatement */ + var message = node.kind === 246 /* SyntaxKind.BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -89356,18 +89760,18 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return ts.isStringOrNumericLiteralLike(expr) || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 8 /* NumericLiteral */; + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 8 /* SyntaxKind.NumericLiteral */; } function isBigIntLiteralExpression(expr) { - return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 219 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && - expr.operand.kind === 9 /* BigIntLiteral */; + return expr.kind === 9 /* SyntaxKind.BigIntLiteral */ || + expr.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ && expr.operator === 40 /* SyntaxKind.MinusToken */ && + expr.operand.kind === 9 /* SyntaxKind.BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) && ts.isEntityNameExpression(expr.expression)) { - return !!(checkExpressionCached(expr).flags & 1024 /* EnumLiteral */); + return !!(checkExpressionCached(expr).flags & 1024 /* TypeFlags.EnumLiteral */); } } function checkAmbientInitializer(node) { @@ -89375,7 +89779,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 110 /* TrueKeyword */ || initializer.kind === 95 /* FalseKeyword */ || + initializer.kind === 110 /* SyntaxKind.TrueKeyword */ || initializer.kind === 95 /* SyntaxKind.FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -89386,14 +89790,11 @@ var ts; else { return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); } - if (!isConstOrReadonly || isInvalidInitializer) { - return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts); - } } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) { - if (node.flags & 16777216 /* Ambient */) { + if (node.parent.parent.kind !== 243 /* SyntaxKind.ForInStatement */ && node.parent.parent.kind !== 244 /* SyntaxKind.ForOfStatement */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -89405,7 +89806,7 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 237 /* SyntaxKind.VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* NodeFlags.Ambient */)) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -89414,7 +89815,7 @@ var ts; return grammarErrorOnNode(node.exclamationToken, message); } if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System && - !(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 16777216 /* NodeFlags.Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* ModifierFlags.Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -89427,7 +89828,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -89444,8 +89845,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 79 /* Identifier */) { - if (name.originalKeywordKind === 119 /* LetKeyword */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { + if (name.originalKeywordKind === 119 /* SyntaxKind.LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -89472,15 +89873,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 239 /* IfStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 248 /* WithStatement */: - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return false; - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -89498,12 +89899,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 103 /* NewKeyword */: + case 103 /* SyntaxKind.NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 100 /* ImportKeyword */: + case 100 /* SyntaxKind.ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -89561,7 +89962,7 @@ var ts; } } function checkGrammarProperty(node) { - if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* InKeyword */) { + if (ts.isComputedPropertyName(node.name) && ts.isBinaryExpression(node.name.expression) && node.name.expression.operatorToken.kind === 101 /* SyntaxKind.InKeyword */) { return grammarErrorOnNode(node.parent.members[0], ts.Diagnostics.A_mapped_type_may_not_declare_properties_or_methods); } if (ts.isClassLike(node.parent)) { @@ -89571,11 +89972,11 @@ var ts; if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_class_property_declaration_must_have_a_simple_literal_type_or_a_unique_symbol_type)) { return true; } - if (languageVersion < 2 /* ES2015 */ && ts.isPrivateIdentifier(node.name)) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */ && ts.isPrivateIdentifier(node.name)) { return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher); } } - else if (node.parent.kind === 258 /* InterfaceDeclaration */) { + else if (node.parent.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -89595,11 +89996,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { + node.flags & 16777216 /* NodeFlags.Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) { var message = node.initializer ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -89621,14 +90022,14 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 258 /* InterfaceDeclaration */ || - node.kind === 259 /* TypeAliasDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 265 /* ImportEqualsDeclaration */ || - node.kind === 272 /* ExportDeclaration */ || - node.kind === 271 /* ExportAssignment */ || - node.kind === 264 /* NamespaceExportDeclaration */ || - ts.hasSyntacticModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */ || + node.kind === 259 /* SyntaxKind.TypeAliasDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ || + node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 271 /* SyntaxKind.ExportAssignment */ || + node.kind === 264 /* SyntaxKind.NamespaceExportDeclaration */ || + ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */ | 1 /* ModifierFlags.Export */ | 512 /* ModifierFlags.Default */)) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier); @@ -89636,7 +90037,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 237 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 237 /* SyntaxKind.VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -89645,10 +90046,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 16777216 /* NodeFlags.Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 16777216 /* Ambient */) { + if (node.flags & 16777216 /* NodeFlags.Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -89659,7 +90060,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 235 /* Block */ || node.parent.kind === 262 /* ModuleBlock */ || node.parent.kind === 305 /* SourceFile */) { + if (node.parent.kind === 235 /* SyntaxKind.Block */ || node.parent.kind === 262 /* SyntaxKind.ModuleBlock */ || node.parent.kind === 305 /* SyntaxKind.SourceFile */) { var links_2 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_2.hasReportedStatementInAmbientContext) { @@ -89676,19 +90077,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.numericLiteralFlags & 32 /* Octal */) { + if (node.numericLiteralFlags & 32 /* TokenFlags.Octal */) { var diagnosticMessage = void 0; - if (languageVersion >= 1 /* ES5 */) { + if (languageVersion >= 1 /* ScriptTarget.ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 196 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 196 /* SyntaxKind.LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 299 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 299 /* SyntaxKind.EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* SyntaxKind.MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -89701,7 +90102,7 @@ var ts; // We should test against `getTextOfNode(node)` rather than `node.text`, because `node.text` for large numeric literals can contain "." // e.g. `node.text` for numeric literal `1100000000000000000000` is `1.1e21`. var isFractional = ts.getTextOfNode(node).indexOf(".") !== -1; - var isScientific = node.numericLiteralFlags & 16 /* Scientific */; + var isScientific = node.numericLiteralFlags & 16 /* TokenFlags.Scientific */; // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway if (isFractional || isScientific) { @@ -89722,7 +90123,7 @@ var ts; var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); if (!literalType) { - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) { return true; } @@ -89756,7 +90157,7 @@ var ts; if (node.isTypeOnly && node.name && node.namedBindings) { return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both); } - if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* NamedImports */) { + if (node.isTypeOnly && ((_a = node.namedBindings) === null || _a === void 0 ? void 0 : _a.kind) === 269 /* SyntaxKind.NamedImports */) { return checkGrammarNamedImportsOrExports(node.namedBindings); } return false; @@ -89764,7 +90165,7 @@ var ts; function checkGrammarNamedImportsOrExports(namedBindings) { return !!ts.forEach(namedBindings.elements, function (specifier) { if (specifier.isTypeOnly) { - return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* ImportSpecifier */ + return grammarErrorOnFirstToken(specifier, specifier.kind === 270 /* SyntaxKind.ImportSpecifier */ ? ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement : ts.Diagnostics.The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement); } @@ -89799,14 +90200,14 @@ var ts; } function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) { var sourceObjectFlags = ts.getObjectFlags(source); - if (sourceObjectFlags & (4 /* Reference */ | 16 /* Anonymous */) && unionTarget.flags & 1048576 /* Union */) { + if (sourceObjectFlags & (4 /* ObjectFlags.Reference */ | 16 /* ObjectFlags.Anonymous */) && unionTarget.flags & 1048576 /* TypeFlags.Union */) { return ts.find(unionTarget.types, function (target) { - if (target.flags & 524288 /* Object */) { + if (target.flags & 524288 /* TypeFlags.Object */) { var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target); - if (overlapObjFlags & 4 /* Reference */) { + if (overlapObjFlags & 4 /* ObjectFlags.Reference */) { return source.target === target.target; } - if (overlapObjFlags & 16 /* Anonymous */) { + if (overlapObjFlags & 16 /* ObjectFlags.Anonymous */) { return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol; } } @@ -89815,35 +90216,35 @@ var ts; } } function findBestTypeForObjectLiteral(source, unionTarget) { - if (ts.getObjectFlags(source) & 128 /* ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { + if (ts.getObjectFlags(source) & 128 /* ObjectFlags.ObjectLiteral */ && someType(unionTarget, isArrayLikeType)) { return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); }); } } function findBestTypeForInvokable(source, unionTarget) { - var signatureKind = 0 /* Call */; + var signatureKind = 0 /* SignatureKind.Call */; var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 || - (signatureKind = 1 /* Construct */, getSignaturesOfType(source, signatureKind).length > 0); + (signatureKind = 1 /* SignatureKind.Construct */, getSignaturesOfType(source, signatureKind).length > 0); if (hasSignatures) { return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; }); } } function findMostOverlappyType(source, unionTarget) { var bestMatch; - if (!(source.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(source.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var matchingCount = 0; for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) { var target = _a[_i]; - if (!(target.flags & (131068 /* Primitive */ | 406847488 /* InstantiablePrimitive */))) { + if (!(target.flags & (131068 /* TypeFlags.Primitive */ | 406847488 /* TypeFlags.InstantiablePrimitive */))) { var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]); - if (overlap.flags & 4194304 /* Index */) { + if (overlap.flags & 4194304 /* TypeFlags.Index */) { // perfect overlap of keys return target; } - else if (isUnitType(overlap) || overlap.flags & 1048576 /* Union */) { + else if (isUnitType(overlap) || overlap.flags & 1048576 /* TypeFlags.Union */) { // We only want to account for literal types otherwise. // If we have a union of index types, it seems likely that we // needed to elaborate between two generic mapped types anyway. - var len = overlap.flags & 1048576 /* Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; + var len = overlap.flags & 1048576 /* TypeFlags.Union */ ? ts.countWhere(overlap.types, isUnitType) : 1; if (len >= matchingCount) { bestMatch = target; matchingCount = len; @@ -89855,9 +90256,9 @@ var ts; return bestMatch; } function filterPrimitivesIfContainsNonPrimitive(type) { - if (maybeTypeOfKind(type, 67108864 /* NonPrimitive */)) { - var result = filterType(type, function (t) { return !(t.flags & 131068 /* Primitive */); }); - if (!(result.flags & 131072 /* Never */)) { + if (maybeTypeOfKind(type, 67108864 /* TypeFlags.NonPrimitive */)) { + var result = filterType(type, function (t) { return !(t.flags & 131068 /* TypeFlags.Primitive */); }); + if (!(result.flags & 131072 /* TypeFlags.Never */)) { return result; } } @@ -89865,7 +90266,7 @@ var ts; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { - if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { + if (target.flags & 1048576 /* TypeFlags.Union */ && source.flags & (2097152 /* TypeFlags.Intersection */ | 524288 /* TypeFlags.Object */)) { var match = getMatchingUnionConstituentForType(target, source); if (match) { return match; @@ -89887,14 +90288,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 256 /* FunctionDeclaration */ && declaration.kind !== 169 /* MethodDeclaration */) || + return (declaration.kind !== 256 /* SyntaxKind.FunctionDeclaration */ && declaration.kind !== 169 /* SyntaxKind.MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -89914,17 +90315,17 @@ var ts; })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { - case 0 /* Yield */: return "yieldType"; - case 1 /* Return */: return "returnType"; - case 2 /* Next */: return "nextType"; + case 0 /* IterationTypeKind.Yield */: return "yieldType"; + case 1 /* IterationTypeKind.Return */: return "returnType"; + case 2 /* IterationTypeKind.Next */: return "nextType"; } } function signatureHasRestParameter(s) { - return !!(s.flags & 1 /* HasRestParameter */); + return !!(s.flags & 1 /* SignatureFlags.HasRestParameter */); } ts.signatureHasRestParameter = signatureHasRestParameter; function signatureHasLiteralTypes(s) { - return !!(s.flags & 2 /* HasLiteralTypes */); + return !!(s.flags & 2 /* SignatureFlags.HasLiteralTypes */); } ts.signatureHasLiteralTypes = signatureHasLiteralTypes; })(ts || (ts = {})); @@ -90064,7 +90465,7 @@ var ts; var updated; context.startLexicalEnvironment(); if (nodes) { - context.setLexicalEnvironmentFlags(1 /* InParameters */, true); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, true); updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression @@ -90072,11 +90473,11 @@ var ts; // exists in a different lexical scope. To address this, we move any binding patterns and initializers // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list // when the emit target is greater than ES2015. - if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ && - ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + if (context.getLexicalEnvironmentFlags() & 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */ && + ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ScriptTarget.ES2015 */) { updated = addDefaultValueAssignmentsIfNeeded(updated, context); } - context.setLexicalEnvironmentFlags(1 /* InParameters */, false); + context.setLexicalEnvironmentFlags(1 /* LexicalEnvironmentFlags.InParameters */, false); } context.suspendLexicalEnvironment(); return updated; @@ -90123,8 +90524,8 @@ var ts; function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { var factory = context.factory; context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ - factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */))); + factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */))); return factory.updateParameterDeclaration(parameter, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, /*initializer*/ undefined); } @@ -90170,446 +90571,446 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 160 /* LastToken */) || kind === 192 /* ThisType */) { + if ((kind > 0 /* SyntaxKind.FirstToken */ && kind <= 160 /* SyntaxKind.LastToken */) || kind === 192 /* SyntaxKind.ThisType */) { return node; } var factory = context.factory; switch (kind) { // Names - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: ts.Debug.type(node); return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNodeOrTypeParameterDeclaration)); - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: ts.Debug.type(node); return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier)); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: ts.Debug.type(node); return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: ts.Debug.type(node); return factory.updateTypeParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode)); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: ts.Debug.type(node); return factory.updateParameterDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: ts.Debug.type(node); return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Type elements - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: ts.Debug.type(node); return factory.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: ts.Debug.type(node); return factory.updatePropertyDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, ts.isQuestionOrExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: ts.Debug.type(node); return factory.updateMethodSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: ts.Debug.type(node); return factory.updateMethodDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: ts.Debug.type(node); return factory.updateConstructorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: ts.Debug.type(node); return factory.updateGetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: ts.Debug.type(node); return factory.updateSetAccessorDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: ts.Debug.type(node); context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); return factory.updateClassStaticBlockDeclaration(node, visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: ts.Debug.type(node); return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: ts.Debug.type(node); return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: ts.Debug.type(node); return factory.updateIndexSignature(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: ts.Debug.type(node); return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor, ts.isAssertsKeyword), nodeVisitor(node.parameterName, visitor, ts.isIdentifierOrThisTypeNode), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: ts.Debug.type(node); return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: ts.Debug.type(node); return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: ts.Debug.type(node); return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: ts.Debug.type(node); return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: ts.Debug.type(node); return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: ts.Debug.type(node); return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode)); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: ts.Debug.type(node); return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode)); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: ts.Debug.type(node); return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 186 /* RestType */: + case 186 /* SyntaxKind.RestType */: ts.Debug.type(node); return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: ts.Debug.type(node); return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: ts.Debug.type(node); return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: ts.Debug.type(node); return factory.updateConditionalTypeNode(node, nodeVisitor(node.checkType, visitor, ts.isTypeNode), nodeVisitor(node.extendsType, visitor, ts.isTypeNode), nodeVisitor(node.trueType, visitor, ts.isTypeNode), nodeVisitor(node.falseType, visitor, ts.isTypeNode)); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: ts.Debug.type(node); return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: ts.Debug.type(node); - return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 295 /* ImportTypeAssertionContainer */: + return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); + case 295 /* SyntaxKind.ImportTypeAssertionContainer */: ts.Debug.type(node); return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: ts.Debug.type(node); - return factory.updateNamedTupleMember(node, visitNode(node.dotDotDotToken, visitor, ts.isDotDotDotToken), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.questionToken, visitor, ts.isQuestionToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 191 /* ParenthesizedType */: + return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode)); + case 191 /* SyntaxKind.ParenthesizedType */: ts.Debug.type(node); return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: ts.Debug.type(node); return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: ts.Debug.type(node); return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode)); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: ts.Debug.type(node); return factory.updateMappedTypeNode(node, nodeVisitor(node.readonlyToken, tokenVisitor, ts.isReadonlyKeywordOrPlusOrMinusToken), nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.nameType, visitor, ts.isTypeNode), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionOrPlusOrMinusToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: ts.Debug.type(node); return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression)); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: ts.Debug.type(node); return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan)); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: ts.Debug.type(node); return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: ts.Debug.type(node); return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.Debug.type(node); return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: ts.Debug.type(node); return factory.updateBindingElement(node, nodeVisitor(node.dotDotDotToken, tokenVisitor, ts.isDotDotDotToken), nodeVisitor(node.propertyName, visitor, ts.isPropertyName), nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Expression - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: ts.Debug.type(node); return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: ts.Debug.type(node); return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 206 /* PropertyAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.name, visitor, ts.isMemberName)); } ts.Debug.type(node); return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isMemberName)); - case 207 /* ElementAccessExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression)); - case 208 /* CallExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 208 /* SyntaxKind.CallExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateCallChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isQuestionDotToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: ts.Debug.type(node); return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: ts.Debug.type(node); - return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); - case 211 /* TypeAssertionExpression */: + return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral)); + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.type(node); return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: ts.Debug.type(node); return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: ts.Debug.type(node); return factory.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: ts.Debug.type(node); return factory.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, ts.isEqualsGreaterThanToken), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: ts.Debug.type(node); return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: ts.Debug.type(node); return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: ts.Debug.type(node); return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: ts.Debug.type(node); return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: ts.Debug.type(node); return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: ts.Debug.type(node); return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression)); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: ts.Debug.type(node); return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isBinaryOperatorToken), nodeVisitor(node.right, visitor, ts.isExpression)); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: ts.Debug.type(node); return factory.updateConditionalExpression(node, nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.questionToken, tokenVisitor, ts.isQuestionToken), nodeVisitor(node.whenTrue, visitor, ts.isExpression), nodeVisitor(node.colonToken, tokenVisitor, ts.isColonToken), nodeVisitor(node.whenFalse, visitor, ts.isExpression)); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: ts.Debug.type(node); return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: ts.Debug.type(node); return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: ts.Debug.type(node); return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: ts.Debug.type(node); return factory.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: ts.Debug.type(node); return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: ts.Debug.type(node); return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 230 /* NonNullExpression */: - if (node.flags & 32 /* OptionalChain */) { + case 230 /* SyntaxKind.NonNullExpression */: + if (node.flags & 32 /* NodeFlags.OptionalChain */) { ts.Debug.type(node); return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression)); } ts.Debug.type(node); return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: ts.Debug.type(node); return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: ts.Debug.type(node); return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.Debug.type(node); return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: ts.Debug.type(node); return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: ts.Debug.type(node); return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: ts.Debug.type(node); return factory.updateIfStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.thenStatement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.elseStatement, visitor, ts.isStatement, factory.liftToBlock)); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: ts.Debug.type(node); return factory.updateDoStatement(node, visitIterationBody(node.statement, visitor, context), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: ts.Debug.type(node); return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: ts.Debug.type(node); return factory.updateForStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.condition, visitor, ts.isExpression), nodeVisitor(node.incrementor, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: ts.Debug.type(node); return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: ts.Debug.type(node); return factory.updateForOfStatement(node, nodeVisitor(node.awaitModifier, tokenVisitor, ts.isAwaitKeyword), nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), visitIterationBody(node.statement, visitor, context)); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: ts.Debug.type(node); return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: ts.Debug.type(node); return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier)); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: ts.Debug.type(node); return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: ts.Debug.type(node); return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: ts.Debug.type(node); return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock)); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: ts.Debug.type(node); return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock)); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: ts.Debug.type(node); return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: ts.Debug.type(node); return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock)); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: ts.Debug.type(node); return factory.updateVariableDeclaration(node, nodeVisitor(node.name, visitor, ts.isBindingName), nodeVisitor(node.exclamationToken, tokenVisitor, ts.isExclamationToken), nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.Debug.type(node); return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: ts.Debug.type(node); return factory.updateFunctionDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, ts.isAsteriskToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context, nodeVisitor)); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: ts.Debug.type(node); return factory.updateClassDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifierLike), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: ts.Debug.type(node); return factory.updateInterfaceDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: ts.Debug.type(node); return factory.updateTypeAliasDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode)); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: ts.Debug.type(node); return factory.updateEnumDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: ts.Debug.type(node); return factory.updateModuleDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.name, visitor, ts.isModuleName), nodeVisitor(node.body, visitor, ts.isModuleBody)); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: ts.Debug.type(node); return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.Debug.type(node); return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: ts.Debug.type(node); return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.type(node); return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference)); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: ts.Debug.type(node); return factory.updateImportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.importClause, visitor, ts.isImportClause), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: ts.Debug.type(node); return factory.updateAssertClause(node, nodesVisitor(node.elements, visitor, ts.isAssertEntry), node.multiLine); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: ts.Debug.type(node); return factory.updateAssertEntry(node, nodeVisitor(node.name, visitor, ts.isAssertionKey), nodeVisitor(node.value, visitor, ts.isExpressionNode)); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: ts.Debug.type(node); return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: ts.Debug.type(node); return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: ts.Debug.type(node); return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.Debug.type(node); return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: ts.Debug.type(node); return factory.updateImportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: ts.Debug.type(node); return factory.updateExportAssignment(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression)); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.type(node); return factory.updateExportDeclaration(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, ts.isNamedExportBindings), nodeVisitor(node.moduleSpecifier, visitor, ts.isExpression), nodeVisitor(node.assertClause, visitor, ts.isAssertClause)); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: ts.Debug.type(node); return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: ts.Debug.type(node); return factory.updateExportSpecifier(node, node.isTypeOnly, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier)); // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: ts.Debug.type(node); return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: ts.Debug.type(node); return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement)); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: ts.Debug.type(node); return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: ts.Debug.type(node); return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes)); - case 281 /* JsxClosingElement */: + case 281 /* SyntaxKind.JsxClosingElement */: ts.Debug.type(node); return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: ts.Debug.type(node); return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: ts.Debug.type(node); return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: ts.Debug.type(node); return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: ts.Debug.type(node); return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: ts.Debug.type(node); return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: ts.Debug.type(node); return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.Debug.type(node); return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: ts.Debug.type(node); return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: ts.Debug.type(node); return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock)); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: ts.Debug.type(node); return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: ts.Debug.type(node); return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: ts.Debug.type(node); return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression)); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: ts.Debug.type(node); return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: ts.Debug.type(node); return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: ts.Debug.type(node); return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: ts.Debug.type(node); return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: @@ -90834,7 +91235,7 @@ var ts; if (lastGeneratedLine < pendingGeneratedLine) { // Emit line delimiters do { - appendMappingCharCode(59 /* semicolon */); + appendMappingCharCode(59 /* CharacterCodes.semicolon */); lastGeneratedLine++; } while (lastGeneratedLine < pendingGeneratedLine); // Only need to set this once @@ -90844,7 +91245,7 @@ var ts; ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack"); // Emit comma to separate the entry if (hasLast) { - appendMappingCharCode(44 /* comma */); + appendMappingCharCode(44 /* CharacterCodes.comma */); } } // 1. Relative generated character @@ -90987,14 +91388,14 @@ var ts; next: function () { while (!done && pos < mappings.length) { var ch = mappings.charCodeAt(pos); - if (ch === 59 /* semicolon */) { + if (ch === 59 /* CharacterCodes.semicolon */) { // new line generatedLine++; generatedCharacter = 0; pos++; continue; } - if (ch === 44 /* comma */) { + if (ch === 44 /* CharacterCodes.comma */) { // Next entry is on same line - no action needed pos++; continue; @@ -91071,8 +91472,8 @@ var ts; } function isSourceMappingSegmentEnd() { return (pos === mappings.length || - mappings.charCodeAt(pos) === 44 /* comma */ || - mappings.charCodeAt(pos) === 59 /* semicolon */); + mappings.charCodeAt(pos) === 44 /* CharacterCodes.comma */ || + mappings.charCodeAt(pos) === 59 /* CharacterCodes.semicolon */); } function base64VLQFormatDecode() { var moreDigits = true; @@ -91122,19 +91523,19 @@ var ts; } ts.isSourceMapping = isSourceMapping; function base64FormatEncode(value) { - return value >= 0 && value < 26 ? 65 /* A */ + value : - value >= 26 && value < 52 ? 97 /* a */ + value - 26 : - value >= 52 && value < 62 ? 48 /* _0 */ + value - 52 : - value === 62 ? 43 /* plus */ : - value === 63 ? 47 /* slash */ : - ts.Debug.fail(value + ": not a base64 value"); + return value >= 0 && value < 26 ? 65 /* CharacterCodes.A */ + value : + value >= 26 && value < 52 ? 97 /* CharacterCodes.a */ + value - 26 : + value >= 52 && value < 62 ? 48 /* CharacterCodes._0 */ + value - 52 : + value === 62 ? 43 /* CharacterCodes.plus */ : + value === 63 ? 47 /* CharacterCodes.slash */ : + ts.Debug.fail("".concat(value, ": not a base64 value")); } function base64FormatDecode(ch) { - return ch >= 65 /* A */ && ch <= 90 /* Z */ ? ch - 65 /* A */ : - ch >= 97 /* a */ && ch <= 122 /* z */ ? ch - 97 /* a */ + 26 : - ch >= 48 /* _0 */ && ch <= 57 /* _9 */ ? ch - 48 /* _0 */ + 52 : - ch === 43 /* plus */ ? 62 : - ch === 47 /* slash */ ? 63 : + return ch >= 65 /* CharacterCodes.A */ && ch <= 90 /* CharacterCodes.Z */ ? ch - 65 /* CharacterCodes.A */ : + ch >= 97 /* CharacterCodes.a */ && ch <= 122 /* CharacterCodes.z */ ? ch - 97 /* CharacterCodes.a */ + 26 : + ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */ ? ch - 48 /* CharacterCodes._0 */ + 52 : + ch === 43 /* CharacterCodes.plus */ ? 62 : + ch === 47 /* CharacterCodes.slash */ ? 63 : -1; } function isSourceMappedPosition(value) { @@ -91202,7 +91603,7 @@ var ts; var mappings = ts.arrayFrom(decoder, processMapping); if (decoder.error !== undefined) { if (host.log) { - host.log("Encountered error while decoding sourcemap: " + decoder.error); + host.log("Encountered error while decoding sourcemap: ".concat(decoder.error)); } decodedMappings = ts.emptyArray; } @@ -91295,12 +91696,12 @@ var ts; return ts.some(node.elements, isNamedDefaultReference); } function isNamedDefaultReference(e) { - return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* Default */; + return e.propertyName !== undefined && e.propertyName.escapedText === "default" /* InternalSymbolName.Default */; } function chainBundle(context, transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -91351,7 +91752,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -91364,13 +91765,13 @@ var ts; hasImportDefault = true; } break; - case 265 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 277 /* ExternalModuleReference */) { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + if (node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -91401,23 +91802,23 @@ var ts; addExportedNamesForExportDeclaration(node); } break; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 237 /* VariableStatement */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + case 237 /* SyntaxKind.VariableStatement */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) { var decl = _c[_b]; exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames); } } break; - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default function() { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -91435,9 +91836,9 @@ var ts; } } break; - case 257 /* ClassDeclaration */: - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - if (ts.hasSyntacticModifier(node, 512 /* Default */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + if (ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)) { // export default class { } if (!hasExportDefault) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node)); @@ -91518,7 +91919,7 @@ var ts; */ function isSimpleCopiableExpression(expression) { return ts.isStringLiteralLike(expression) || - expression.kind === 8 /* NumericLiteral */ || + expression.kind === 8 /* SyntaxKind.NumericLiteral */ || ts.isKeyword(expression.kind) || ts.isIdentifier(expression); } @@ -91533,27 +91934,27 @@ var ts; } ts.isSimpleInlineableExpression = isSimpleInlineableExpression; function isCompoundAssignment(kind) { - return kind >= 64 /* FirstCompoundAssignment */ - && kind <= 78 /* LastCompoundAssignment */; + return kind >= 64 /* SyntaxKind.FirstCompoundAssignment */ + && kind <= 78 /* SyntaxKind.LastCompoundAssignment */; } ts.isCompoundAssignment = isCompoundAssignment; function getNonAssignmentOperatorForCompoundAssignment(kind) { switch (kind) { - case 64 /* PlusEqualsToken */: return 39 /* PlusToken */; - case 65 /* MinusEqualsToken */: return 40 /* MinusToken */; - case 66 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; - case 67 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; - case 68 /* SlashEqualsToken */: return 43 /* SlashToken */; - case 69 /* PercentEqualsToken */: return 44 /* PercentToken */; - case 70 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; - case 71 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; - case 72 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; - case 73 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; - case 74 /* BarEqualsToken */: return 51 /* BarToken */; - case 78 /* CaretEqualsToken */: return 52 /* CaretToken */; - case 75 /* BarBarEqualsToken */: return 56 /* BarBarToken */; - case 76 /* AmpersandAmpersandEqualsToken */: return 55 /* AmpersandAmpersandToken */; - case 77 /* QuestionQuestionEqualsToken */: return 60 /* QuestionQuestionToken */; + case 64 /* SyntaxKind.PlusEqualsToken */: return 39 /* SyntaxKind.PlusToken */; + case 65 /* SyntaxKind.MinusEqualsToken */: return 40 /* SyntaxKind.MinusToken */; + case 66 /* SyntaxKind.AsteriskEqualsToken */: return 41 /* SyntaxKind.AsteriskToken */; + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return 42 /* SyntaxKind.AsteriskAsteriskToken */; + case 68 /* SyntaxKind.SlashEqualsToken */: return 43 /* SyntaxKind.SlashToken */; + case 69 /* SyntaxKind.PercentEqualsToken */: return 44 /* SyntaxKind.PercentToken */; + case 70 /* SyntaxKind.LessThanLessThanEqualsToken */: return 47 /* SyntaxKind.LessThanLessThanToken */; + case 71 /* SyntaxKind.GreaterThanGreaterThanEqualsToken */: return 48 /* SyntaxKind.GreaterThanGreaterThanToken */; + case 72 /* SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* SyntaxKind.GreaterThanGreaterThanGreaterThanToken */; + case 73 /* SyntaxKind.AmpersandEqualsToken */: return 50 /* SyntaxKind.AmpersandToken */; + case 74 /* SyntaxKind.BarEqualsToken */: return 51 /* SyntaxKind.BarToken */; + case 78 /* SyntaxKind.CaretEqualsToken */: return 52 /* SyntaxKind.CaretToken */; + case 75 /* SyntaxKind.BarBarEqualsToken */: return 56 /* SyntaxKind.BarBarToken */; + case 76 /* SyntaxKind.AmpersandAmpersandEqualsToken */: return 55 /* SyntaxKind.AmpersandAmpersandToken */; + case 77 /* SyntaxKind.QuestionQuestionEqualsToken */: return 60 /* SyntaxKind.QuestionQuestionToken */; } } ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment; @@ -91615,7 +92016,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member) { - return member.kind === 167 /* PropertyDeclaration */ + return member.kind === 167 /* SyntaxKind.PropertyDeclaration */ && member.initializer !== undefined; } ts.isInitializedProperty = isInitializedProperty; @@ -91679,12 +92080,12 @@ var ts; */ function getAllDecoratorsOfClassElement(member, parent) { switch (member.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return getAllDecoratorsOfAccessors(member, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -92020,9 +92421,9 @@ var ts; var element = elements[i]; if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) { var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element); - if (flattenContext.level >= 1 /* ObjectRest */ - && !(element.transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */)) - && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* ContainsRestOrSpread */ | 65536 /* ContainsObjectRestOrSpread */)) + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */ + && !(element.transformFlags & (32768 /* TransformFlags.ContainsRestOrSpread */ | 65536 /* TransformFlags.ContainsObjectRestOrSpread */)) + && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (32768 /* TransformFlags.ContainsRestOrSpread */ | 65536 /* TransformFlags.ContainsObjectRestOrSpread */)) && !ts.isComputedPropertyName(propertyName)) { bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor)); } @@ -92063,14 +92464,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + if (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ && flattenContext.downlevelIteration) { // Read the elements of the iterable into an array value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) ? undefined : numElements), location), /*reuseIdentifierExpressions*/ false, location); } - else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0) + else if (numElements !== 1 && (flattenContext.level < 1 /* FlattenLevel.ObjectRest */ || numElements === 0) || ts.every(elements, ts.isOmittedExpression)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements @@ -92085,10 +92486,10 @@ var ts; var restContainingElements; for (var i = 0; i < numElements; i++) { var element = elements[i]; - if (flattenContext.level >= 1 /* ObjectRest */) { + if (flattenContext.level >= 1 /* FlattenLevel.ObjectRest */) { // If an array pattern contains an ObjectRest, we must cache the result so that we // can perform the ObjectRest destructuring in a different declaration - if (element.transformFlags & 65536 /* ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { + if (element.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */ || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) { flattenContext.hasTransformedPriorElement = true; var temp = flattenContext.context.factory.createTempVariable(/*recordTempVariable*/ undefined); if (flattenContext.hoistTempVariables) { @@ -92291,7 +92692,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + var isLast = node.kind === 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */ || node.kind === 17 /* SyntaxKind.TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); } // Newline normalization: @@ -92345,8 +92746,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -92366,14 +92767,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -92422,16 +92823,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 305 /* SourceFile */: - case 263 /* CaseBlock */: - case 262 /* ModuleBlock */: - case 235 /* Block */: + case 305 /* SyntaxKind.SourceFile */: + case 263 /* SyntaxKind.CaseBlock */: + case 262 /* SyntaxKind.ModuleBlock */: + case 235 /* SyntaxKind.Block */: currentLexicalScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 257 /* ClassDeclaration */: - case 256 /* FunctionDeclaration */: - if (ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + case 257 /* SyntaxKind.ClassDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + if (ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { break; } // Record these declarations provided that they have a name. @@ -92442,7 +92843,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 257 /* ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 257 /* SyntaxKind.ClassDeclaration */ || ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */)); } break; } @@ -92461,7 +92862,7 @@ var ts; * @param node The node to visit. */ function visitorWorker(node) { - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { return visitTypeScript(node); } return node; @@ -92481,10 +92882,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 271 /* ExportAssignment */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitElidableStatement(node); default: return visitorWorker(node); @@ -92497,7 +92898,7 @@ var ts; // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes // We do not reuse `visitorWorker`, as the ellidable statement syntax kinds are technically unrecognized by the switch-case in `visitTypeScript`, // and will trigger debug failures when debug verbosity is turned up - if (node.transformFlags & 1 /* ContainsTypeScript */) { + if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */) { // This node contains TypeScript, so we should visit its children. return ts.visitEachChild(node, visitor, context); } @@ -92505,13 +92906,13 @@ var ts; return node; } switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -92531,15 +92932,15 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 272 /* ExportDeclaration */ || - node.kind === 266 /* ImportDeclaration */ || - node.kind === 267 /* ImportClause */ || - (node.kind === 265 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 277 /* ExternalModuleReference */)) { + if (node.kind === 272 /* SyntaxKind.ExportDeclaration */ || + node.kind === 266 /* SyntaxKind.ImportDeclaration */ || + node.kind === 267 /* SyntaxKind.ImportClause */ || + (node.kind === 265 /* SyntaxKind.ImportEqualsDeclaration */ && + node.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } - else if (node.transformFlags & 1 /* ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* Export */)) { + else if (node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */ || ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { return visitTypeScript(node); } return node; @@ -92559,27 +92960,27 @@ var ts; */ function classElementVisitorWorker(node, parent) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructor(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node, parent); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node, parent); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node, parent); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return ts.visitEachChild(node, visitor, context); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Index signatures are elided return; default: @@ -92591,17 +92992,17 @@ var ts; } function objectLiteralElementVisitorWorker(node, parent) { switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 298 /* SpreadAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return visitor(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node, parent); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node, parent); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node, parent); @@ -92612,10 +93013,10 @@ var ts; function modifierVisitor(node) { if (ts.isDecorator(node)) return undefined; - if (ts.modifierToFlag(node.kind) & 116958 /* TypeScriptModifier */) { + if (ts.modifierToFlag(node.kind) & 116958 /* ModifierFlags.TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 93 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 93 /* SyntaxKind.ExportKeyword */) { return undefined; } return node; @@ -92626,72 +93027,72 @@ var ts; * @param node The node to visit. */ function visitTypeScript(node) { - if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { // TypeScript ambient declarations are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); } switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 85 /* ConstKeyword */: - case 135 /* DeclareKeyword */: - case 145 /* ReadonlyKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: // TypeScript accessibility and readonly modifiers are elided // falls through - case 183 /* ArrayType */: - case 184 /* TupleType */: - case 185 /* OptionalType */: - case 186 /* RestType */: - case 182 /* TypeLiteral */: - case 177 /* TypePredicate */: - case 163 /* TypeParameter */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 133 /* BooleanKeyword */: - case 150 /* StringKeyword */: - case 147 /* NumberKeyword */: - case 143 /* NeverKeyword */: - case 114 /* VoidKeyword */: - case 151 /* SymbolKeyword */: - case 180 /* ConstructorType */: - case 179 /* FunctionType */: - case 181 /* TypeQuery */: - case 178 /* TypeReference */: - case 187 /* UnionType */: - case 188 /* IntersectionType */: - case 189 /* ConditionalType */: - case 191 /* ParenthesizedType */: - case 192 /* ThisType */: - case 193 /* TypeOperator */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 196 /* LiteralType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: + case 185 /* SyntaxKind.OptionalType */: + case 186 /* SyntaxKind.RestType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 177 /* SyntaxKind.TypePredicate */: + case 163 /* SyntaxKind.TypeParameter */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: + case 150 /* SyntaxKind.StringKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 151 /* SyntaxKind.SymbolKeyword */: + case 180 /* SyntaxKind.ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 181 /* SyntaxKind.TypeQuery */: + case 178 /* SyntaxKind.TypeReference */: + case 187 /* SyntaxKind.UnionType */: + case 188 /* SyntaxKind.IntersectionType */: + case 189 /* SyntaxKind.ConditionalType */: + case 191 /* SyntaxKind.ParenthesizedType */: + case 192 /* SyntaxKind.ThisType */: + case 193 /* SyntaxKind.TypeOperator */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 196 /* SyntaxKind.LiteralType */: // TypeScript type nodes are elided. // falls through - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // TypeScript index signatures are elided. return undefined; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return factory.createNotEmittedStatement(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return factory.createNotEmittedStatement(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -92701,7 +93102,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -92711,34 +93112,34 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 171 /* Constructor */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return ts.Debug.fail("Class and object literal elements must be visited with their respective visitors"); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -92748,40 +93149,40 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 211 /* TypeAssertionExpression */: - case 229 /* AsExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: + case 229 /* SyntaxKind.AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node); - case 280 /* JsxOpeningElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax @@ -92798,28 +93199,28 @@ var ts; return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, getObjectLiteralElementVisitor(node), ts.isObjectLiteralElement)); } function getClassFacts(node, staticProperties) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; if (ts.some(staticProperties)) - facts |= 1 /* HasStaticInitializedProperties */; + facts |= 1 /* ClassFacts.HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */) - facts |= 64 /* IsDerivedClass */; + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */) + facts |= 64 /* ClassFacts.IsDerivedClass */; if (ts.classOrConstructorParameterIsDecorated(node)) - facts |= 2 /* HasConstructorDecorators */; + facts |= 2 /* ClassFacts.HasConstructorDecorators */; if (ts.childIsDecorated(node)) - facts |= 4 /* HasMemberDecorators */; + facts |= 4 /* ClassFacts.HasMemberDecorators */; if (isExportOfNamespace(node)) - facts |= 8 /* IsExportOfNamespace */; + facts |= 8 /* ClassFacts.IsExportOfNamespace */; else if (isDefaultExternalModuleExport(node)) - facts |= 32 /* IsDefaultExternalExport */; + facts |= 32 /* ClassFacts.IsDefaultExternalExport */; else if (isNamedExternalModuleExport(node)) - facts |= 16 /* IsNamedExternalExport */; - if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */)) - facts |= 128 /* UseImmediatelyInvokedFunctionExpression */; + facts |= 16 /* ClassFacts.IsNamedExternalExport */; + if (languageVersion <= 1 /* ScriptTarget.ES5 */ && (facts & 7 /* ClassFacts.MayNeedImmediatelyInvokedFunctionExpression */)) + facts |= 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */; return facts; } function hasTypeScriptClassSyntax(node) { - return !!(node.transformFlags & 8192 /* ContainsTypeScriptClassSyntax */); + return !!(node.transformFlags & 8192 /* TransformFlags.ContainsTypeScriptClassSyntax */); } function isClassLikeDeclarationWithTypeScriptSyntax(node) { return ts.hasDecorators(node) @@ -92828,20 +93229,20 @@ var ts; || ts.some(node.members, hasTypeScriptClassSyntax); } function visitClassDeclaration(node) { - if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* Export */))) { + if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */))) { return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, getClassElementVisitor(node), ts.isClassElement)); } var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); } - var name = node.name || (facts & 5 /* NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); + var name = node.name || (facts & 5 /* ClassFacts.NeedsName */ ? factory.getGeneratedNameForNode(node) : undefined); var allDecorators = ts.getAllDecoratorsOfClass(node); var decorators = transformAllDecoratorsOfDeclaration(node, node, allDecorators); // we do not emit modifiers on the declaration if we are emitting an IIFE - var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */) + var modifiers = !(facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) : ts.elideNodes(factory, node.modifiers); // preserve positions, if available // ${modifiers} class ${name} ${heritageClauses} { @@ -92852,12 +93253,12 @@ var ts; // To better align with the old emitter, we should not emit a trailing source map // entry if the class has static properties. var emitFlags = ts.getEmitFlags(node); - if (facts & 1 /* HasStaticInitializedProperties */) { - emitFlags |= 32 /* NoTrailingSourceMap */; + if (facts & 1 /* ClassFacts.HasStaticInitializedProperties */) { + emitFlags |= 32 /* EmitFlags.NoTrailingSourceMap */; } ts.setEmitFlags(classStatement, emitFlags); var statements = [classStatement]; - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */) { // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the // 'es2015' transformer can properly nest static initializers and decorators. The result // looks something like: @@ -92869,20 +93270,20 @@ var ts; // return C; // }(); // - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); var localName = factory.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(localName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment()); var iife = factory.createImmediatelyInvokedArrowFunction(statements); - ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); + ts.setEmitFlags(iife, 33554432 /* EmitFlags.TypeScriptClassWrapper */); var varStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), @@ -92898,21 +93299,21 @@ var ts; // If the class is exported as part of a TypeScript namespace, emit the namespace export. // Otherwise, if the class was exported at the top level and was decorated, emit an export // declaration or export default for the class. - if (facts & 8 /* IsExportOfNamespace */) { + if (facts & 8 /* ClassFacts.IsExportOfNamespace */) { addExportMemberAssignment(statements, node); } - else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { - if (facts & 32 /* IsDefaultExternalExport */) { + else if (facts & 128 /* ClassFacts.UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* ClassFacts.HasConstructorDecorators */) { + if (facts & 32 /* ClassFacts.IsDefaultExternalExport */) { statements.push(factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } - else if (facts & 16 /* IsNamedExternalExport */) { + else if (facts & 16 /* ClassFacts.IsNamedExternalExport */) { statements.push(factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } } if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -92983,11 +93384,11 @@ var ts; var expression = ts.visitNode(parameterDecorator.expression, visitor, ts.isExpression); var helper = emitHelpers().createParamHelper(expression, parameterOffset); ts.setTextRange(helper, parameterDecorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); var decorator = factory.createDecorator(helper); ts.setSourceMapRange(decorator, parameterDecorator.expression); ts.setCommentRange(decorator, parameterDecorator.expression); - ts.setEmitFlags(decorator, 1536 /* NoComments */); + ts.setEmitFlags(decorator, 1536 /* EmitFlags.NoComments */); decorators.push(decorator); } return decorators; @@ -93025,15 +93426,15 @@ var ts; if (typeSerializer) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + var typeProperty = factory.createPropertyAssignment("type", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); properties = ts.append(properties, typeProperty); } if (shouldAddParamTypesMetadata(node)) { - var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container))); + var paramTypeProperty = factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeParameterTypesOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node, container))); properties = ts.append(properties, paramTypeProperty); } if (shouldAddReturnTypeMetadata(node)) { - var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); + var returnTypeProperty = factory.createPropertyAssignment("returnType", factory.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, factory.createToken(38 /* SyntaxKind.EqualsGreaterThanToken */), typeSerializer.serializeReturnTypeOfNode({ currentLexicalScope: currentLexicalScope, currentNameScope: container }, node))); properties = ts.append(properties, returnTypeProperty); } if (properties) { @@ -93051,10 +93452,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */ - || kind === 167 /* PropertyDeclaration */; + return kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */ + || kind === 167 /* SyntaxKind.PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -93064,7 +93465,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 169 /* MethodDeclaration */; + return node.kind === 169 /* SyntaxKind.MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -93075,12 +93476,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return true; } return false; @@ -93142,7 +93543,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 117 /* ImplementsKeyword */) { + if (node.token === 117 /* SyntaxKind.ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -93170,7 +93571,7 @@ var ts; return !ts.nodeIsMissing(node.body); } function visitPropertyDeclaration(node, parent) { - var isAmbient = node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */); + var isAmbient = node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */); if (isAmbient && !ts.hasDecorators(node)) { return undefined; } @@ -93178,7 +93579,7 @@ var ts; var decorators = transformAllDecoratorsOfDeclaration(node, parent, allDecorators); // Preserve a `declare x` property with decorators to be handled by the decorators transform if (isAmbient) { - return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, factory.createModifiersFromModifierFlags(2 /* Ambient */)), ts.visitNode(node.name, visitor, ts.isPropertyName), + return factory.updatePropertyDeclaration(node, ts.concatenate(decorators, factory.createModifiersFromModifierFlags(2 /* ModifierFlags.Ambient */)), ts.visitNode(node.name, visitor, ts.isPropertyName), /*questionOrExclamationToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined); @@ -93230,7 +93631,8 @@ var ts; statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), parameterPropertyAssignments, true), statements.slice(prologueStatementCount), true); } // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements - ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1 + prologueStatementCount)); + var start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount; + ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, start)); // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); @@ -93250,14 +93652,14 @@ var ts; } // TODO(rbuckton): Does this need to be parented? var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 48 /* NoSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 48 /* EmitFlags.NoSourceMap */); // TODO(rbuckton): Does this need to be parented? var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent); - ts.setEmitFlags(localName, 1536 /* NoComments */); + ts.setEmitFlags(localName, 1536 /* EmitFlags.NoComments */); return ts.startOnNewLine(ts.removeAllComments(ts.setTextRange(ts.setOriginalNode(factory.createExpressionStatement(factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createThis(), propertyName), node.name), localName)), node), ts.moveRangePos(node, -1)))); } function visitMethodDeclaration(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitFunctionLikeDeclaration(node)) { @@ -93277,10 +93679,10 @@ var ts; * @param node The declaration node. */ function shouldEmitAccessorDeclaration(node) { - return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* Abstract */)); + return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128 /* ModifierFlags.Abstract */)); } function visitGetAccessor(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitAccessorDeclaration(node)) { @@ -93293,7 +93695,7 @@ var ts; /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || factory.createBlock([])); } function visitSetAccessor(node, parent) { - if (!(node.transformFlags & 1 /* ContainsTypeScript */)) { + if (!(node.transformFlags & 1 /* TransformFlags.ContainsTypeScript */)) { return node; } if (!shouldEmitAccessorDeclaration(node)) { @@ -93347,7 +93749,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -93367,7 +93769,7 @@ var ts; function transformInitializedVariable(node) { var name = node.name; if (ts.isBindingPattern(name)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createNamespaceExportExpression); } else { @@ -93385,7 +93787,7 @@ var ts; return updated; } function visitParenthesizedExpression(node) { - var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */); + var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* OuterExpressionKinds.Assertions */); if (ts.isAssertionExpression(innerExpression)) { // Make sure we consider all nested cast expressions, e.g.: // (-A).x; @@ -93462,7 +93864,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the enum. If we emit // a leading variable declaration, we should not emit leading comments for the // enum body. @@ -93470,7 +93872,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the enum. @@ -93478,7 +93880,7 @@ var ts; // `containerName` is the expression used inside of the enum for assignments. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93544,7 +93946,7 @@ var ts; var name = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ false); var valueExpression = transformEnumMemberDeclarationValue(member); var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression); - var outerAssignment = valueExpression.kind === 10 /* StringLiteral */ ? + var outerAssignment = valueExpression.kind === 10 /* SyntaxKind.StringLiteral */ ? innerAssignment : factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name); return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member); @@ -93632,12 +94034,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([ factory.createVariableDeclaration(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 305 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 305 /* SyntaxKind.SourceFile */ ? 0 /* NodeFlags.None */ : 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 260 /* EnumDeclaration */) { + if (node.kind === 260 /* SyntaxKind.EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -93662,7 +94064,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.addEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.addEmitFlags(statement, 1024 /* EmitFlags.NoTrailingComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -93672,7 +94074,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = factory.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* EmitFlags.NoComments */ | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -93693,7 +94095,7 @@ var ts; var statements = []; // We request to be advised when the printer is about to print this node. This allows // us to set up the correct state for later substitutions. - var emitFlags = 2 /* AdviseOnEmitNode */; + var emitFlags = 2 /* EmitFlags.AdviseOnEmitNode */; // If needed, we should emit a variable declaration for the module. If we emit // a leading variable declaration, we should not emit leading comments for the // module body. @@ -93701,7 +94103,7 @@ var ts; if (varAdded) { // We should still emit the comments if we are emitting a system module. if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) { - emitFlags |= 512 /* NoLeadingComments */; + emitFlags |= 512 /* EmitFlags.NoLeadingComments */; } } // `parameterName` is the declaration name used inside of the namespace. @@ -93709,7 +94111,7 @@ var ts; // `containerName` is the expression used inside of the namespace for exports. var containerName = getNamespaceContainerName(node); // `exportName` is the expression used within this node's container for any exported references. - var exportName = ts.hasSyntacticModifier(node, 1 /* Export */) + var exportName = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // x || (x = {}) @@ -93762,7 +94164,7 @@ var ts; var statementsLocation; var blockLocation; if (node.body) { - if (node.body.kind === 262 /* ModuleBlock */) { + if (node.body.kind === 262 /* SyntaxKind.ModuleBlock */) { saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = node.body.statements; blockLocation = node.body; @@ -93809,13 +94211,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (!node.body || node.body.kind !== 262 /* ModuleBlock */) { - ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); + if (!node.body || node.body.kind !== 262 /* SyntaxKind.ModuleBlock */) { + ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* EmitFlags.NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 261 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 261 /* SyntaxKind.ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -93838,8 +94240,8 @@ var ts; // Elide the declaration if the import clause was elided. var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause || - compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */ + compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */ ? factory.updateImportDeclaration(node, /*modifiers*/ undefined, importClause, node.moduleSpecifier, node.assertClause) : undefined; @@ -93862,14 +94264,14 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 268 /* NamespaceImport */) { + if (node.kind === 268 /* SyntaxKind.NamespaceImport */) { // Elide a namespace import if it is not referenced. return shouldEmitAliasDeclaration(node) ? node : undefined; } else { // Elide named imports if all of its import specifiers are elided and settings allow. - var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = compilerOptions.preserveValueImports && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier); return allowEmpty || ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined; } @@ -93910,8 +94312,8 @@ var ts; return node; } // Elide the export declaration if all of its named exports are elided. - var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* Preserve */ || - compilerOptions.importsNotUsedAsValues === 2 /* Error */); + var allowEmpty = !!node.moduleSpecifier && (compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */ || + compilerOptions.importsNotUsedAsValues === 2 /* ImportsNotUsedAsValues.Error */); var exportClause = ts.visitNode(node.exportClause, function (bindings) { return visitNamedExportBindings(bindings, allowEmpty); }, ts.isNamedExportBindings); return exportClause ? factory.updateExportDeclaration(node, @@ -93970,7 +94372,7 @@ var ts; if (ts.isExternalModuleImportEqualsDeclaration(node)) { var isReferenced = shouldEmitAliasDeclaration(node); // If the alias is unreferenced but we want to keep the import, replace with 'import "mod"'. - if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* Preserve */) { + if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1 /* ImportsNotUsedAsValues.Preserve */) { return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration( /*modifiers*/ undefined, /*importClause*/ undefined, node.moduleReference.expression, @@ -93982,7 +94384,7 @@ var ts; return undefined; } var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference); - ts.setEmitFlags(moduleReference, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + ts.setEmitFlags(moduleReference, 1536 /* EmitFlags.NoComments */ | 2048 /* EmitFlags.NoNestedComments */); if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) { // export var ${name} = ${moduleReference}; // var ${name} = ${moduleReference}; @@ -94003,7 +94405,7 @@ var ts; * @param node The node to test. */ function isExportOfNamespace(node) { - return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is exported from an external module. @@ -94011,7 +94413,7 @@ var ts; * @param node The node to test. */ function isExternalModuleExport(node) { - return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* Export */); + return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); } /** * Gets a value indicating whether the node is a named export from an external module. @@ -94020,7 +94422,7 @@ var ts; */ function isNamedExternalModuleExport(node) { return isExternalModuleExport(node) - && !ts.hasSyntacticModifier(node, 512 /* Default */); + && !ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } /** * Gets a value indicating whether the node is the default export of an external module. @@ -94029,7 +94431,7 @@ var ts; */ function isDefaultExternalModuleExport(node) { return isExternalModuleExport(node) - && ts.hasSyntacticModifier(node, 512 /* Default */); + && ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */); } function addExportMemberAssignment(statements, node) { var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, /*allowComments*/ false, /*allowSourceMaps*/ true), factory.getLocalName(node)); @@ -94063,27 +94465,27 @@ var ts; return factory.getGeneratedNameForNode(node); } function enableSubstitutionForNonQualifiedEnumMembers() { - if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { - enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */) === 0) { + enabledSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } function enableSubstitutionForNamespaceExports() { - if ((enabledSubstitutions & 2 /* NamespaceExports */) === 0) { - enabledSubstitutions |= 2 /* NamespaceExports */; + if ((enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) === 0) { + enabledSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(79 /* Identifier */); - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(261 /* ModuleDeclaration */); + context.enableEmitNotification(261 /* SyntaxKind.ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 261 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 261 /* SyntaxKind.ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 260 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 260 /* SyntaxKind.EnumDeclaration */; } /** * Hook for node emit. @@ -94098,11 +94500,11 @@ var ts; if (ts.isSourceFile(node)) { currentSourceFile = node; } - if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { - applicableSubstitutions |= 2 /* NamespaceExports */; + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && isTransformedModuleDeclaration(node)) { + applicableSubstitutions |= 2 /* TypeScriptSubstitutionFlags.NamespaceExports */; } - if (enabledSubstitutions & 8 /* NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { - applicableSubstitutions |= 8 /* NonQualifiedEnumMembers */; + if (enabledSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && isTransformedEnumDeclaration(node)) { + applicableSubstitutions |= 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; @@ -94116,7 +94518,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -94125,7 +94527,7 @@ var ts; return node; } function substituteShorthandPropertyAssignment(node) { - if (enabledSubstitutions & 2 /* NamespaceExports */) { + if (enabledSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */) { var name = node.name; var exportedName = trySubstituteNamespaceExportedName(name); if (exportedName) { @@ -94142,11 +94544,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -94161,9 +94563,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 305 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 261 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 260 /* EnumDeclaration */); + if (container && container.kind !== 305 /* SyntaxKind.SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* TypeScriptSubstitutionFlags.NamespaceExports */ && container.kind === 261 /* SyntaxKind.ModuleDeclaration */) || + (applicableSubstitutions & 8 /* TypeScriptSubstitutionFlags.NonQualifiedEnumMembers */ && container.kind === 260 /* SyntaxKind.EnumDeclaration */); if (substitute) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), /*location*/ node); @@ -94189,7 +94591,7 @@ var ts; var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue); if (!compilerOptions.removeComments) { var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); - ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + safeMultiLineComment(ts.getTextOfNode(originalNode)) + " "); + ts.addSyntheticTrailingComment(substitute, 3 /* SyntaxKind.MultiLineCommentTrivia */, " ".concat(safeMultiLineComment(ts.getTextOfNode(originalNode)), " ")); } return substitute; } @@ -94252,13 +94654,13 @@ var ts; var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions); - var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */; + var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ScriptTarget.ES2022 */; // We need to transform `this` in a static initializer into a reference to the class // when targeting < ES2022 since the assignment will be moved outside of the class body. - var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */; + var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ScriptTarget.ES2022 */; // We don't need to transform `super` property access when targeting ES5, ES3 because // the es2015 transformation handles those. - var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */; + var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ScriptTarget.ES2015 */; var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -94284,7 +94686,7 @@ var ts; function transformSourceFile(node) { var options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ES2022 */) { + || useDefineForClassFields && ts.getEmitScriptTarget(options) >= 9 /* ScriptTarget.ES2022 */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -94292,50 +94694,50 @@ var ts; return visited; } function visitorWorker(node, valueIsDiscarded) { - if (node.transformFlags & 16777216 /* ContainsClassFields */) { + if (node.transformFlags & 16777216 /* TransformFlags.ContainsClassFields */) { switch (node.kind) { - case 226 /* ClassExpression */: - case 257 /* ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassLike(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return visitPrivateIdentifier(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return visitClassStaticBlockDeclaration(node); } } - if (node.transformFlags & 16777216 /* ContainsClassFields */ || - node.transformFlags & 134217728 /* ContainsLexicalSuper */ && + if (node.transformFlags & 16777216 /* TransformFlags.ContainsClassFields */ || + node.transformFlags & 134217728 /* TransformFlags.ContainsLexicalSuper */ && shouldTransformSuperInStaticInitializers && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { switch (node.kind) { - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return visitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: { var savedCurrentStaticPropertyDeclarationOrStaticBlock = currentStaticPropertyDeclarationOrStaticBlock; currentStaticPropertyDeclarationOrStaticBlock = undefined; var result = ts.visitEachChild(node, visitor, context); @@ -94354,17 +94756,17 @@ var ts; } function heritageClauseVisitor(node) { switch (node.kind) { - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return ts.visitEachChild(node, heritageClauseVisitor, context); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return visitExpressionWithTypeArguments(node); } return visitor(node); } function visitorDestructuringTarget(node) { switch (node.kind) { - case 205 /* ObjectLiteralExpression */: - case 204 /* ArrayLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitAssignmentPattern(node); default: return visitor(node); @@ -94394,7 +94796,7 @@ var ts; } var privId = node.left; ts.Debug.assertNode(privId, ts.isPrivateIdentifier); - ts.Debug.assert(node.operatorToken.kind === 101 /* InKeyword */); + ts.Debug.assert(node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */); var info = accessPrivateIdentifier(privId); if (info) { var receiver = ts.visitNode(node.right, visitor, ts.isExpression); @@ -94410,19 +94812,19 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodOrAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return node; default: return visitor(node); @@ -94471,10 +94873,10 @@ var ts; ts.Debug.assert(ts.isPrivateIdentifier(node.name)); var info = accessPrivateIdentifier(node.name); ts.Debug.assert(info, "Undeclared private name for property declaration."); - if (info.kind === "m" /* Method */) { + if (info.kind === "m" /* PrivateIdentifierKind.Method */) { return info.methodName; } - if (info.kind === "a" /* Accessor */) { + if (info.kind === "a" /* PrivateIdentifierKind.Accessor */) { if (ts.isGetAccessor(node)) { return info.getterName; } @@ -94533,11 +94935,11 @@ var ts; function createPrivateIdentifierAccessHelper(info, receiver) { ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.getterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.methodName); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(receiver, info.brandCheckIdentifier, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94556,7 +94958,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94575,7 +94977,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return visitInvalidSuperProperty(node); } if (classConstructor && superClassReference) { @@ -94589,16 +94991,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitPreOrPostfixUnaryExpression(node, valueIsDiscarded) { - if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { - if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) { + if (node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) { + var operand = ts.skipParentheses(node.operand); + if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierPropertyAccessExpression(operand)) { var info = void 0; - if (info = accessPrivateIdentifier(node.operand.name)) { - var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression); + if (info = accessPrivateIdentifier(operand.name)) { + var receiver = ts.visitNode(operand.expression, visitor, ts.isExpression); var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression; var expression = createPrivateIdentifierAccess(info, readExpression); var temp = ts.isPrefixUnaryExpression(node) || valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); - expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* EqualsToken */); + expression = createPrivateIdentifierAssignment(info, initializeExpression || readExpression, expression, 63 /* SyntaxKind.EqualsToken */); ts.setOriginalNode(expression, node); ts.setTextRange(expression, node); if (temp) { @@ -94609,7 +95012,7 @@ var ts; } } else if (shouldTransformSuperInStaticInitializers && - ts.isSuperProperty(node.operand) && + ts.isSuperProperty(operand) && currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { // converts `++super.a` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = ++_a), _classTemp), _b)` @@ -94621,32 +95024,32 @@ var ts; // converts `super.a--` into `(Reflect.set(_baseTemp, "a", (_a = Reflect.get(_baseTemp, "a", _classTemp), _b = _a--), _classTemp), _b)` // converts `super[f()]--` into `(Reflect.set(_baseTemp, _a = f(), (_b = Reflect.get(_baseTemp, _a, _classTemp), _c = _b--), _classTemp), _c)` var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { - var operand = visitInvalidSuperProperty(node.operand); + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { + var expression = visitInvalidSuperProperty(operand); return ts.isPrefixUnaryExpression(node) ? - factory.updatePrefixUnaryExpression(node, operand) : - factory.updatePostfixUnaryExpression(node, operand); + factory.updatePrefixUnaryExpression(node, expression) : + factory.updatePostfixUnaryExpression(node, expression); } if (classConstructor && superClassReference) { var setterName = void 0; var getterName = void 0; - if (ts.isPropertyAccessExpression(node.operand)) { - if (ts.isIdentifier(node.operand.name)) { - getterName = setterName = factory.createStringLiteralFromNode(node.operand.name); + if (ts.isPropertyAccessExpression(operand)) { + if (ts.isIdentifier(operand.name)) { + getterName = setterName = factory.createStringLiteralFromNode(operand.name); } } else { - if (ts.isSimpleInlineableExpression(node.operand.argumentExpression)) { - getterName = setterName = node.operand.argumentExpression; + if (ts.isSimpleInlineableExpression(operand.argumentExpression)) { + getterName = setterName = operand.argumentExpression; } else { getterName = factory.createTempVariable(hoistVariableDeclaration); - setterName = factory.createAssignment(getterName, ts.visitNode(node.operand.argumentExpression, visitor, ts.isExpression)); + setterName = factory.createAssignment(getterName, ts.visitNode(operand.argumentExpression, visitor, ts.isExpression)); } } if (setterName && getterName) { var expression = factory.createReflectGetCall(superClassReference, getterName, classConstructor); - ts.setTextRange(expression, node.operand); + ts.setTextRange(expression, operand); var temp = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration); expression = ts.expandPreOrPostfixIncrementOrDecrementExpression(factory, node, expression, hoistVariableDeclaration, temp); expression = factory.createReflectSetCall(superClassReference, setterName, expression, classConstructor); @@ -94737,7 +95140,7 @@ var ts; var iife = factory.createImmediatelyInvokedArrowFunction(statements); ts.setOriginalNode(iife, node); ts.setTextRange(iife, node); - ts.addEmitFlags(iife, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(iife, 2 /* EmitFlags.AdviseOnEmitNode */); return iife; } } @@ -94764,7 +95167,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.updateBinaryExpression(node, visitInvalidSuperProperty(node.left), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression)); } if (classConstructor && superClassReference) { @@ -94806,7 +95209,7 @@ var ts; } } } - if (node.operatorToken.kind === 101 /* InKeyword */ && ts.isPrivateIdentifier(node.left)) { + if (node.operatorToken.kind === 101 /* SyntaxKind.InKeyword */ && ts.isPrivateIdentifier(node.left)) { return visitPrivateIdentifierInInExpression(node); } return ts.visitEachChild(node, visitor, context); @@ -94821,12 +95224,12 @@ var ts; } ts.setCommentRange(receiver, ts.moveRangePos(receiver, -1)); switch (info.kind) { - case "a" /* Accessor */: + case "a" /* PrivateIdentifierKind.Accessor */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.setterName); - case "m" /* Method */: + case "m" /* PrivateIdentifierKind.Method */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, /* f */ undefined); - case "f" /* Field */: + case "f" /* PrivateIdentifierKind.Field */: return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.brandCheckIdentifier, right, info.kind, info.variableName); default: ts.Debug.assertNever(info, "Unknown private element type"); @@ -94866,28 +95269,28 @@ var ts; return ts.filter(node.members, ts.isNonStaticMethodOrAccessorWithPrivateName); } function getClassFacts(node) { - var facts = 0 /* None */; + var facts = 0 /* ClassFacts.None */; var original = ts.getOriginalNode(node); if (ts.isClassDeclaration(original) && ts.classOrConstructorParameterIsDecorated(original)) { - facts |= 1 /* ClassWasDecorated */; + facts |= 1 /* ClassFacts.ClassWasDecorated */; } for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; if (!ts.isStatic(member)) continue; if (member.name && ts.isPrivateIdentifier(member.name) && shouldTransformPrivateElementsOrClassStaticBlocks) { - facts |= 2 /* NeedsClassConstructorReference */; + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } if (ts.isPropertyDeclaration(member) || ts.isClassStaticBlockDeclaration(member)) { - if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* ContainsLexicalThis */) { - facts |= 8 /* NeedsSubstitutionForThisInClassStaticField */; - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */; + if (shouldTransformThisInStaticInitializers && member.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */) { + facts |= 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */; + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */; } } - if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* ContainsLexicalSuper */) { - if (!(facts & 1 /* ClassWasDecorated */)) { - facts |= 2 /* NeedsClassConstructorReference */ | 4 /* NeedsClassSuperReference */; + if (shouldTransformSuperInStaticInitializers && member.transformFlags & 134217728 /* TransformFlags.ContainsLexicalSuper */) { + if (!(facts & 1 /* ClassFacts.ClassWasDecorated */)) { + facts |= 2 /* ClassFacts.NeedsClassConstructorReference */ | 4 /* ClassFacts.NeedsClassSuperReference */; } } } @@ -94895,8 +95298,8 @@ var ts; return facts; } function visitExpressionWithTypeArguments(node) { - var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* None */; - if (facts & 4 /* NeedsClassSuperReference */) { + var facts = (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts) || 0 /* ClassFacts.None */; + if (facts & 4 /* ClassFacts.NeedsClassSuperReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reserveInNestedScopes*/ true); getClassLexicalEnvironment().superClassReference = temp; return factory.updateExpressionWithTypeArguments(node, factory.createAssignment(temp, ts.visitNode(node.expression, visitor, ts.isExpression)), @@ -94909,19 +95312,19 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If a class has private static fields, or a static field has a `this` or `super` reference, // then we need to allocate a temp variable to hold on to that reference. var pendingClassReferenceAssignment; - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { var temp = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); pendingClassReferenceAssignment = factory.createAssignment(temp, factory.getInternalName(node)); } var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); var statements = [ factory.updateClassDeclaration(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) @@ -94949,7 +95352,7 @@ var ts; if (facts) { getClassLexicalEnvironment().facts = facts; } - if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) { + if (facts & 8 /* ClassFacts.NeedsSubstitutionForThisInClassStaticField */) { enableSubstitutionForClassStaticThisOrSuperReference(); } // If this class expression is a transformation of a decorated class declaration, @@ -94959,19 +95362,19 @@ var ts; // In this case, we use pendingStatements to produce the same output as the // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. - var isDecoratedClassDeclaration = !!(facts & 1 /* ClassWasDecorated */); + var isDecoratedClassDeclaration = !!(facts & 1 /* ClassFacts.ClassWasDecorated */); var staticPropertiesOrClassStaticBlocks = ts.getStaticPropertiesAndClassStaticBlock(node); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */); - var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */; + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */); + var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; var temp; function createClassTempVar() { var classCheckFlags = resolver.getNodeCheckFlags(node); - var isClassWithConstructorReference = classCheckFlags & 16777216 /* ClassWithConstructorReference */; - var requiresBlockScopedVar = classCheckFlags & 524288 /* BlockScopedBindingInLoop */; + var isClassWithConstructorReference = classCheckFlags & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */; + var requiresBlockScopedVar = classCheckFlags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; return factory.createTempVariable(requiresBlockScopedVar ? addBlockScopedVariable : hoistVariableDeclaration, !!isClassWithConstructorReference); } - if (facts & 2 /* NeedsClassConstructorReference */) { + if (facts & 2 /* ClassFacts.NeedsClassConstructorReference */) { temp = createClassTempVar(); getClassLexicalEnvironment().classConstructor = factory.cloneNode(temp); } @@ -95000,12 +95403,12 @@ var ts; // record an alias as the class name is not in scope for statics. enableSubstitutionForClassAliases(); var alias = factory.cloneNode(temp); - alias.autoGenerateFlags &= ~8 /* ReservedInNestedScopes */; + alias.autoGenerateFlags &= ~8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */; classAliases[ts.getOriginalNodeId(node)] = alias; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* EmitFlags.Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression))); // Add any pending expressions leftover from elided or relocated computed property names ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine)); @@ -95058,13 +95461,13 @@ var ts; /*typeArguments*/ undefined, []))); } function isClassElementThatRequiresConstructorStatement(member) { - if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* Abstract */)) { + if (ts.isStatic(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128 /* ModifierFlags.Abstract */)) { return false; } if (useDefineForClassFields) { // If we are using define semantics and targeting ESNext or higher, // then we don't need to transform any class properties. - return languageVersion < 9 /* ES2022 */; + return languageVersion < 9 /* ScriptTarget.ES2022 */; } return ts.isInitializedProperty(member) || shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifierClassElementDeclaration(member); } @@ -95253,7 +95656,7 @@ var ts; if (transformed && ts.hasStaticModifier(property) && (currentClassLexicalEnvironment === null || currentClassLexicalEnvironment === void 0 ? void 0 : currentClassLexicalEnvironment.facts)) { // capture the lexical environment for the member ts.setOriginalNode(transformed, property); - ts.addEmitFlags(transformed, 2 /* AdviseOnEmitNode */); + ts.addEmitFlags(transformed, 2 /* EmitFlags.AdviseOnEmitNode */); classLexicalEnvironmentMap.set(ts.getOriginalNodeId(transformed), currentClassLexicalEnvironment); } currentStaticPropertyDeclarationOrStaticBlock = savedCurrentStaticPropertyDeclarationOrStaticBlock; @@ -95272,7 +95675,7 @@ var ts; if (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(propertyName)) { var privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { - if (privateIdentifierInfo.kind === "f" /* Field */) { + if (privateIdentifierInfo.kind === "f" /* PrivateIdentifierKind.Field */) { if (!privateIdentifierInfo.isStatic) { return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.brandCheckIdentifier); } @@ -95292,7 +95695,7 @@ var ts; return undefined; } var propertyOriginalNode = ts.getOriginalNode(property); - if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* Abstract */)) { + if (ts.hasSyntacticModifier(propertyOriginalNode, 128 /* ModifierFlags.Abstract */)) { return undefined; } var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero() @@ -95311,32 +95714,32 @@ var ts; } } function enableSubstitutionForClassAliases() { - if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { - enabledSubstitutions |= 1 /* ClassAliases */; + if ((enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) === 0) { + enabledSubstitutions |= 1 /* ClassPropertySubstitutionFlags.ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } } function enableSubstitutionForClassStaticThisOrSuperReference() { - if ((enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */) === 0) { - enabledSubstitutions |= 2 /* ClassStaticThisOrSuperReference */; + if ((enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */) === 0) { + enabledSubstitutions |= 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */; // substitute `this` in a static field initializer - context.enableSubstitution(108 /* ThisKeyword */); + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); // these push a new lexical environment that is not the class lexical environment - context.enableEmitNotification(256 /* FunctionDeclaration */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // these push a new lexical environment that is not the class lexical environment, except // when they have a computed property name - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(167 /* PropertyDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(167 /* SyntaxKind.PropertyDeclaration */); // class lexical environments are restored when entering a computed property name - context.enableEmitNotification(162 /* ComputedPropertyName */); + context.enableEmitNotification(162 /* SyntaxKind.ComputedPropertyName */); } } /** @@ -95375,13 +95778,13 @@ var ts; } } switch (node.kind) { - case 213 /* FunctionExpression */: - if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */) { + case 213 /* SyntaxKind.FunctionExpression */: + if (ts.isArrowFunction(original) || ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */) { break; } // falls through - case 256 /* FunctionDeclaration */: - case 171 /* Constructor */: { + case 256 /* SyntaxKind.FunctionDeclaration */: + case 171 /* SyntaxKind.Constructor */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = undefined; @@ -95391,10 +95794,10 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 169 /* MethodDeclaration */: - case 167 /* PropertyDeclaration */: { + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentComputedPropertyNameClassLexicalEnvironment = currentClassLexicalEnvironment; @@ -95404,7 +95807,7 @@ var ts; currentComputedPropertyNameClassLexicalEnvironment = savedCurrentComputedPropertyNameClassLexicalEnvironment; return; } - case 162 /* ComputedPropertyName */: { + case 162 /* SyntaxKind.ComputedPropertyName */: { var savedClassLexicalEnvironment = currentClassLexicalEnvironment; var savedCurrentComputedPropertyNameClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; currentClassLexicalEnvironment = currentComputedPropertyNameClassLexicalEnvironment; @@ -95425,24 +95828,24 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisExpression(node); } return node; } function substituteThisExpression(node) { - if (enabledSubstitutions & 2 /* ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { + if (enabledSubstitutions & 2 /* ClassPropertySubstitutionFlags.ClassStaticThisOrSuperReference */ && currentClassLexicalEnvironment) { var facts = currentClassLexicalEnvironment.facts, classConstructor = currentClassLexicalEnvironment.classConstructor; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { return factory.createParenthesizedExpression(factory.createVoidZero()); } if (classConstructor) { @@ -95455,8 +95858,8 @@ var ts; return trySubstituteClassAlias(node) || node; } function trySubstituteClassAlias(node) { - if (enabledSubstitutions & 1 /* ClassAliases */) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (enabledSubstitutions & 1 /* ClassPropertySubstitutionFlags.ClassAliases */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -95489,7 +95892,7 @@ var ts; var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left); if (!alreadyTransformed && !inlinable && shouldHoist) { var generatedName = factory.getGeneratedNameForNode(name); - if (resolver.getNodeCheckFlags(name) & 524288 /* BlockScopedBindingInLoop */) { + if (resolver.getNodeCheckFlags(name) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(generatedName); } else { @@ -95509,7 +95912,7 @@ var ts; } function getClassLexicalEnvironment() { return currentClassLexicalEnvironment || (currentClassLexicalEnvironment = { - facts: 0 /* None */, + facts: 0 /* ClassFacts.None */, classConstructor: undefined, superClassReference: undefined, privateIdentifierEnvironment: undefined, @@ -95542,7 +95945,7 @@ var ts; if (ts.isPropertyDeclaration(node)) { var variableName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, variableName: variableName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95552,7 +95955,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { var functionName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: functionName, brandCheckIdentifier: classConstructor, isStatic: true, @@ -95561,12 +95964,12 @@ var ts; } else if (ts.isGetAccessorDeclaration(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: classConstructor, @@ -95577,12 +95980,12 @@ var ts; } else if (ts.isSetAccessorDeclaration(node)) { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: classConstructor, @@ -95598,7 +96001,7 @@ var ts; else if (ts.isPropertyDeclaration(node)) { var weakMapName = createHoistedVariableForPrivateName(text, node); privateEnv.identifiers.set(privateName, { - kind: "f" /* Field */, + kind: "f" /* PrivateIdentifierKind.Field */, brandCheckIdentifier: weakMapName, isStatic: false, variableName: undefined, @@ -95610,7 +96013,7 @@ var ts; else if (ts.isMethodDeclaration(node)) { ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); privateEnv.identifiers.set(privateName, { - kind: "m" /* Method */, + kind: "m" /* PrivateIdentifierKind.Method */, methodName: createHoistedVariableForPrivateName(text, node), brandCheckIdentifier: weakSetName, isStatic: false, @@ -95621,12 +96024,12 @@ var ts; ts.Debug.assert(weakSetName, "weakSetName should be set in private identifier environment"); if (ts.isGetAccessor(node)) { var getterName = createHoistedVariableForPrivateName(text + "_get", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.getterName) { previousInfo.getterName = getterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: getterName, setterName: undefined, brandCheckIdentifier: weakSetName, @@ -95637,12 +96040,12 @@ var ts; } else { var setterName = createHoistedVariableForPrivateName(text + "_set", node); - if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { + if ((previousInfo === null || previousInfo === void 0 ? void 0 : previousInfo.kind) === "a" /* PrivateIdentifierKind.Accessor */ && !previousInfo.isStatic && !previousInfo.setterName) { previousInfo.setterName = setterName; } else { privateEnv.identifiers.set(privateName, { - kind: "a" /* Accessor */, + kind: "a" /* PrivateIdentifierKind.Accessor */, getterName: undefined, setterName: setterName, brandCheckIdentifier: weakSetName, @@ -95659,9 +96062,9 @@ var ts; } function createHoistedVariableForClass(name, node) { var className = getPrivateIdentifierEnvironment().className; - var prefix = className ? "_" + className : ""; - var identifier = factory.createUniqueName(prefix + "_" + name, 16 /* Optimistic */); - if (resolver.getNodeCheckFlags(node) & 524288 /* BlockScopedBindingInLoop */) { + var prefix = className ? "_".concat(className) : ""; + var identifier = factory.createUniqueName("".concat(prefix, "_").concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */); + if (resolver.getNodeCheckFlags(node) & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */) { addBlockScopedVariable(identifier); } else { @@ -95703,9 +96106,9 @@ var ts; // differently inside the function. if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) { receiver = factory.createTempVariable(hoistVariableDeclaration, /*reservedInNestedScopes*/ true); - getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); + getPendingExpressions().push(factory.createBinaryExpression(receiver, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(node.expression, visitor, ts.isExpression))); } - return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* EqualsToken */)); + return factory.createAssignmentTargetWrapper(parameter, createPrivateIdentifierAssignment(info, receiver, parameter, 63 /* SyntaxKind.EqualsToken */)); } function visitArrayAssignmentTarget(node) { var target = ts.getTargetOfBindingOrAssignmentElement(node); @@ -95719,7 +96122,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95759,7 +96162,7 @@ var ts; currentStaticPropertyDeclarationOrStaticBlock && currentClassLexicalEnvironment) { var classConstructor = currentClassLexicalEnvironment.classConstructor, superClassReference = currentClassLexicalEnvironment.superClassReference, facts = currentClassLexicalEnvironment.facts; - if (facts & 1 /* ClassWasDecorated */) { + if (facts & 1 /* ClassFacts.ClassWasDecorated */) { wrapped = visitInvalidSuperProperty(target); } else if (classConstructor && superClassReference) { @@ -95867,15 +96270,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 164 /* Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 164 /* SyntaxKind.Parameter */: return serializeTypeNode(node.type); - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: return ts.factory.createIdentifier("Function"); default: return ts.factory.createVoidZero(); @@ -95911,7 +96314,7 @@ var ts; return ts.factory.createArrayLiteralExpression(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 172 /* GetAccessor */) { + if (container && node.kind === 172 /* SyntaxKind.GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -95956,67 +96359,67 @@ var ts; } node = ts.skipTypeParentheses(node); switch (node.kind) { - case 114 /* VoidKeyword */: - case 153 /* UndefinedKeyword */: - case 143 /* NeverKeyword */: + case 114 /* SyntaxKind.VoidKeyword */: + case 153 /* SyntaxKind.UndefinedKeyword */: + case 143 /* SyntaxKind.NeverKeyword */: return ts.factory.createVoidZero(); - case 179 /* FunctionType */: - case 180 /* ConstructorType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: return ts.factory.createIdentifier("Function"); - case 183 /* ArrayType */: - case 184 /* TupleType */: + case 183 /* SyntaxKind.ArrayType */: + case 184 /* SyntaxKind.TupleType */: return ts.factory.createIdentifier("Array"); - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return node.assertsModifier ? ts.factory.createVoidZero() : ts.factory.createIdentifier("Boolean"); - case 133 /* BooleanKeyword */: + case 133 /* SyntaxKind.BooleanKeyword */: return ts.factory.createIdentifier("Boolean"); - case 198 /* TemplateLiteralType */: - case 150 /* StringKeyword */: + case 198 /* SyntaxKind.TemplateLiteralType */: + case 150 /* SyntaxKind.StringKeyword */: return ts.factory.createIdentifier("String"); - case 148 /* ObjectKeyword */: + case 148 /* SyntaxKind.ObjectKeyword */: return ts.factory.createIdentifier("Object"); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return serializeLiteralOfLiteralTypeNode(node.literal); - case 147 /* NumberKeyword */: + case 147 /* SyntaxKind.NumberKeyword */: return ts.factory.createIdentifier("Number"); - case 158 /* BigIntKeyword */: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); - case 151 /* SymbolKeyword */: - return getGlobalConstructor("Symbol", 2 /* ES2015 */); - case 178 /* TypeReference */: + case 158 /* SyntaxKind.BigIntKeyword */: + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); + case 151 /* SyntaxKind.SymbolKeyword */: + return getGlobalConstructor("Symbol", 2 /* ScriptTarget.ES2015 */); + case 178 /* SyntaxKind.TypeReference */: return serializeTypeReferenceNode(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ true); - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return serializeUnionOrIntersectionConstituents(node.types, /*isIntersection*/ false); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return serializeUnionOrIntersectionConstituents([node.trueType, node.falseType], /*isIntersection*/ false); - case 193 /* TypeOperator */: - if (node.operator === 145 /* ReadonlyKeyword */) { + case 193 /* SyntaxKind.TypeOperator */: + if (node.operator === 145 /* SyntaxKind.ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 181 /* TypeQuery */: - case 194 /* IndexedAccessType */: - case 195 /* MappedType */: - case 182 /* TypeLiteral */: - case 130 /* AnyKeyword */: - case 155 /* UnknownKeyword */: - case 192 /* ThisType */: - case 200 /* ImportType */: + case 181 /* SyntaxKind.TypeQuery */: + case 194 /* SyntaxKind.IndexedAccessType */: + case 195 /* SyntaxKind.MappedType */: + case 182 /* SyntaxKind.TypeLiteral */: + case 130 /* SyntaxKind.AnyKeyword */: + case 155 /* SyntaxKind.UnknownKeyword */: + case 192 /* SyntaxKind.ThisType */: + case 200 /* SyntaxKind.ImportType */: break; // handle JSDoc types from an invalid parse - case 312 /* JSDocAllType */: - case 313 /* JSDocUnknownType */: - case 317 /* JSDocFunctionType */: - case 318 /* JSDocVariadicType */: - case 319 /* JSDocNamepathType */: + case 312 /* SyntaxKind.JSDocAllType */: + case 313 /* SyntaxKind.JSDocUnknownType */: + case 317 /* SyntaxKind.JSDocFunctionType */: + case 318 /* SyntaxKind.JSDocVariadicType */: + case 319 /* SyntaxKind.JSDocNamepathType */: break; - case 314 /* JSDocNullableType */: - case 315 /* JSDocNonNullableType */: - case 316 /* JSDocOptionalType */: + case 314 /* SyntaxKind.JSDocNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); @@ -96025,27 +96428,27 @@ var ts; } function serializeLiteralOfLiteralTypeNode(node) { switch (node.kind) { - case 10 /* StringLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return ts.factory.createIdentifier("String"); - case 219 /* PrefixUnaryExpression */: { + case 219 /* SyntaxKind.PrefixUnaryExpression */: { var operand = node.operand; switch (operand.kind) { - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return serializeLiteralOfLiteralTypeNode(operand); default: return ts.Debug.failBadSyntaxKind(operand); } } - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return ts.factory.createIdentifier("Number"); - case 9 /* BigIntLiteral */: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); - case 110 /* TrueKeyword */: - case 95 /* FalseKeyword */: + case 9 /* SyntaxKind.BigIntLiteral */: + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); + case 110 /* SyntaxKind.TrueKeyword */: + case 95 /* SyntaxKind.FalseKeyword */: return ts.factory.createIdentifier("Boolean"); - case 104 /* NullKeyword */: + case 104 /* SyntaxKind.NullKeyword */: return ts.factory.createVoidZero(); default: return ts.Debug.failBadSyntaxKind(node); @@ -96057,20 +96460,20 @@ var ts; for (var _i = 0, types_22 = types; _i < types_22.length; _i++) { var typeNode = types_22[_i]; typeNode = ts.skipTypeParentheses(typeNode); - if (typeNode.kind === 143 /* NeverKeyword */) { + if (typeNode.kind === 143 /* SyntaxKind.NeverKeyword */) { if (isIntersection) return ts.factory.createVoidZero(); // Reduce to `never` in an intersection continue; // Elide `never` in a union } - if (typeNode.kind === 155 /* UnknownKeyword */) { + if (typeNode.kind === 155 /* SyntaxKind.UnknownKeyword */) { if (!isIntersection) return ts.factory.createIdentifier("Object"); // Reduce to `unknown` in a union continue; // Elide `unknown` in an intersection } - if (typeNode.kind === 130 /* AnyKeyword */) { + if (typeNode.kind === 130 /* SyntaxKind.AnyKeyword */) { return ts.factory.createIdentifier("Object"); // Reduce to `any` in a union or intersection } - if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* NullKeyword */) || typeNode.kind === 153 /* UndefinedKeyword */)) { + if (!strictNullChecks && ((ts.isLiteralTypeNode(typeNode) && typeNode.literal.kind === 104 /* SyntaxKind.NullKeyword */) || typeNode.kind === 153 /* SyntaxKind.UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedConstituent = serializeTypeNode(typeNode); @@ -96151,7 +96554,7 @@ var ts; case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType: return ts.factory.createVoidZero(); case ts.TypeReferenceSerializationKind.BigIntLikeType: - return getGlobalConstructor("BigInt", 7 /* ES2020 */); + return getGlobalConstructor("BigInt", 7 /* ScriptTarget.ES2020 */); case ts.TypeReferenceSerializationKind.BooleanType: return ts.factory.createIdentifier("Boolean"); case ts.TypeReferenceSerializationKind.NumberLikeType: @@ -96161,7 +96564,7 @@ var ts; case ts.TypeReferenceSerializationKind.ArrayLikeType: return ts.factory.createIdentifier("Array"); case ts.TypeReferenceSerializationKind.ESSymbolType: - return getGlobalConstructor("Symbol", 2 /* ES2015 */); + return getGlobalConstructor("Symbol", 2 /* ScriptTarget.ES2015 */); case ts.TypeReferenceSerializationKind.TypeWithCallSignature: return ts.factory.createIdentifier("Function"); case ts.TypeReferenceSerializationKind.Promise: @@ -96191,12 +96594,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { // A -> typeof A !== "undefined" && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 79 /* Identifier */) { + if (node.left.kind === 79 /* SyntaxKind.Identifier */) { // A.B -> typeof A !== "undefined" && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -96211,14 +96614,14 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent); name.original = undefined; ts.setParent(name, ts.getParseTreeNode(currentLexicalScope)); // ensure the parent is set to a parse tree node. return name; - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -96269,28 +96672,28 @@ var ts; return ts.isDecorator(node) ? undefined : node; } function visitor(node) { - if (!(node.transformFlags & 33554432 /* ContainsDecorators */)) { + if (!(node.transformFlags & 33554432 /* TransformFlags.ContainsDecorators */)) { return node; } switch (node.kind) { - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: // Decorators are elided. They will be emitted as part of `visitClassDeclaration`. return undefined; - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return visitConstructorDeclaration(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 173 /* SetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitSetAccessorDeclaration(node); - case 172 /* GetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return visitGetAccessorDeclaration(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return visitPropertyDeclaration(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameterDeclaration(node); default: return ts.visitEachChild(node, visitor, context); @@ -96299,39 +96702,72 @@ var ts; function visitClassDeclaration(node) { if (!(ts.classOrConstructorParameterIsDecorated(node) || ts.childIsDecorated(node))) return ts.visitEachChild(node, visitor, context); - var classStatement = ts.hasDecorators(node) ? - createClassDeclarationHeadWithDecorators(node, node.name) : - createClassDeclarationHeadWithoutDecorators(node, node.name); - var statements = [classStatement]; - // Write any decorators of the node. - addClassElementDecorationStatements(statements, node, /*isStatic*/ false); - addClassElementDecorationStatements(statements, node, /*isStatic*/ true); - addConstructorDecorationStatement(statements, node); + var statements = ts.hasDecorators(node) ? + transformClassDeclarationWithClassDecorators(node, node.name) : + transformClassDeclarationWithoutClassDecorators(node, node.name); if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statements[0], ts.getEmitFlags(statements[0]) | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } + function decoratorContainsPrivateIdentifierInExpression(decorator) { + return !!(decorator.transformFlags & 536870912 /* TransformFlags.ContainsPrivateIdentifierInExpression */); + } + function parameterDecoratorsContainPrivateIdentifierInExpression(parameterDecorators) { + return ts.some(parameterDecorators, decoratorContainsPrivateIdentifierInExpression); + } + function hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node) { + for (var _i = 0, _a = node.members; _i < _a.length; _i++) { + var member = _a[_i]; + if (!ts.canHaveDecorators(member)) + continue; + var allDecorators = ts.getAllDecoratorsOfClassElement(member, node); + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.decorators, decoratorContainsPrivateIdentifierInExpression)) + return true; + if (ts.some(allDecorators === null || allDecorators === void 0 ? void 0 : allDecorators.parameters, parameterDecoratorsContainPrivateIdentifierInExpression)) + return true; + } + return false; + } + function transformDecoratorsOfClassElements(node, members) { + var decorationStatements = []; + addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ false); + addClassElementDecorationStatements(decorationStatements, node, /*isStatic*/ true); + if (hasClassElementWithDecoratorContainingPrivateIdentifierInExpression(node)) { + members = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], members, true), [ + factory.createClassStaticBlockDeclaration(factory.createBlock(decorationStatements, /*multiLine*/ true)) + ], false)), members); + decorationStatements = undefined; + } + return { decorationStatements: decorationStatements, members: members }; + } /** * Transforms a non-decorated class declaration. * * @param node A ClassDeclaration node. * @param name The name of the class. */ - function createClassDeclarationHeadWithoutDecorators(node, name) { + function transformClassDeclarationWithoutClassDecorators(node, name) { // ${modifiers} class ${name} ${heritageClauses} { // ${members} // } - return factory.updateClassDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), name, - /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), ts.visitNodes(node.members, visitor, ts.isClassElement)); + var _a; + var modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier); + var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); + var members = ts.visitNodes(node.members, visitor, ts.isClassElement); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var updated = factory.updateClassDeclaration(node, modifiers, name, + /*typeParameters*/ undefined, heritageClauses, members); + return ts.addRange([updated], decorationStatements); } /** * Transforms a decorated class declaration and appends the resulting statements. If * the class requires an alias to avoid issues with double-binding, the alias is returned. */ - function createClassDeclarationHeadWithDecorators(node, name) { + function transformClassDeclarationWithClassDecorators(node, name) { // When we emit an ES6 class that has a class decorator, we must tailor the // emit to certain specific cases. // @@ -96417,11 +96853,12 @@ var ts; // | var C_1; // --------------------------------------------------------------------- // + var _a; var location = ts.moveRangePastModifiers(node); var classAlias = getClassAliasIfNeeded(node); // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var declName = languageVersion <= 2 /* ES2015 */ ? + var declName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); // ... = class ${name} ${heritageClauses} { @@ -96429,7 +96866,11 @@ var ts; // } var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); var members = ts.visitNodes(node.members, visitor, ts.isClassElement); - var classExpression = factory.createClassExpression(/*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); + var decorationStatements = []; + (_a = transformDecoratorsOfClassElements(node, members), members = _a.members, decorationStatements = _a.decorationStatements); + var classExpression = factory.createClassExpression( + /*modifiers*/ undefined, name, + /*typeParameters*/ undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); ts.setTextRange(classExpression, location); // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference @@ -96439,11 +96880,14 @@ var ts; factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression) - ], 1 /* Let */)); + ], 1 /* NodeFlags.Let */)); ts.setOriginalNode(statement, node); ts.setTextRange(statement, location); ts.setCommentRange(statement, node); - return statement; + var statements = [statement]; + ts.addRange(statements, decorationStatements); + addConstructorDecorationStatement(statements, node); + return statements; } function visitClassExpression(node) { // Legacy decorators were not supported on class expressions @@ -96476,7 +96920,7 @@ var ts; return finishClassElement(factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), ts.visitNode(node.body, visitor, ts.isBlock)), node); } function visitPropertyDeclaration(node) { - if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 2 /* Ambient */)) { + if (node.flags & 16777216 /* NodeFlags.Ambient */ || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */)) { return undefined; } return finishClassElement(factory.updatePropertyDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.visitNode(node.name, visitor, ts.isPropertyName), @@ -96493,7 +96937,7 @@ var ts; ts.setCommentRange(updated, node); ts.setTextRange(updated, ts.moveRangePastModifiers(node)); ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node)); - ts.setEmitFlags(updated.name, 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(updated.name, 32 /* EmitFlags.NoTrailingSourceMap */); } return updated; } @@ -96603,9 +97047,9 @@ var ts; // ], C.prototype, "prop"); // var prefix = getClassMemberPrefix(node, member); - var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* Ambient */)); - var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 167 /* PropertyDeclaration */ + var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ !ts.hasSyntacticModifier(member, 2 /* ModifierFlags.Ambient */)); + var descriptor = languageVersion > 0 /* ScriptTarget.ES3 */ + ? member.kind === 167 /* SyntaxKind.PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? factory.createVoidZero() @@ -96614,7 +97058,7 @@ var ts; : factory.createNull() : undefined; var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(helper, ts.moveRangePastModifiers(member)); return helper; } @@ -96643,12 +97087,12 @@ var ts; var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)]; // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name // without any block-scoped variable collision handling - var localName = languageVersion <= 2 /* ES2015 */ ? + var localName = languageVersion <= 2 /* ScriptTarget.ES2015 */ ? factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName); var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate); - ts.setEmitFlags(expression, 1536 /* NoComments */); + ts.setEmitFlags(expression, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(expression, ts.moveRangePastModifiers(node)); return expression; } @@ -96674,7 +97118,7 @@ var ts; var decorator = decorators_1[_i]; var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset); ts.setTextRange(helper, decorator.expression); - ts.setEmitFlags(helper, 1536 /* NoComments */); + ts.setEmitFlags(helper, 1536 /* EmitFlags.NoComments */); expressions.push(helper); } } @@ -96707,7 +97151,7 @@ var ts; if (!classAliases) { // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Keep track of class aliases. classAliases = []; } @@ -96718,7 +97162,7 @@ var ts; * double-binding semantics for the class name. */ function getClassAliasIfNeeded(node) { - if (resolver.getNodeCheckFlags(node) & 16777216 /* ClassWithConstructorReference */) { + if (resolver.getNodeCheckFlags(node) & 16777216 /* NodeCheckFlags.ClassWithConstructorReference */) { enableSubstitutionForClassAliases(); var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default"); classAliases[ts.getOriginalNodeId(node)] = classAlias; @@ -96742,14 +97186,14 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -96760,7 +97204,7 @@ var ts; } function trySubstituteClassAlias(node) { if (classAliases) { - if (resolver.getNodeCheckFlags(node) & 33554432 /* ConstructorReferenceInClass */) { + if (resolver.getNodeCheckFlags(node) & 33554432 /* NodeCheckFlags.ConstructorReferenceInClass */) { // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. @@ -96832,8 +97276,8 @@ var ts; if (node.isDeclarationFile) { return node; } - setContextFlag(1 /* NonTopLevel */, false); - setContextFlag(2 /* HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); + setContextFlag(1 /* ContextFlags.NonTopLevel */, false); + setContextFlag(2 /* ContextFlags.HasLexicalThis */, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions)); var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); return visited; @@ -96845,10 +97289,10 @@ var ts; return (contextFlags & flags) !== 0; } function inTopLevelContext() { - return !inContext(1 /* NonTopLevel */); + return !inContext(1 /* ContextFlags.NonTopLevel */); } function inHasLexicalThisContext() { - return inContext(2 /* HasLexicalThis */); + return inContext(2 /* ContextFlags.HasLexicalThis */); } function doWithContext(flags, cb, value) { var contextFlagsToSet = flags & ~contextFlags; @@ -96864,39 +97308,39 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 256 /* ContainsES2017 */) === 0) { + if ((node.transformFlags & 256 /* TransformFlags.ContainsES2017 */) === 0) { return node; } switch (node.kind) { - case 131 /* AsyncKeyword */: + case 131 /* SyntaxKind.AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 169 /* MethodDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitMethodDeclaration, node); - case 256 /* FunctionDeclaration */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionDeclaration, node); - case 213 /* FunctionExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitFunctionExpression, node); - case 214 /* ArrowFunction */: - return doWithContext(1 /* NonTopLevel */, visitArrowFunction, node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitMethodDeclaration, node); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionDeclaration, node); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitFunctionExpression, node); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithContext(1 /* ContextFlags.NonTopLevel */, visitArrowFunction, node); + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 171 /* Constructor */: - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithContext(1 /* NonTopLevel */ | 2 /* HasLexicalThis */, visitDefault, node); + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 171 /* SyntaxKind.Constructor */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node); default: return ts.visitEachChild(node, visitor, context); } @@ -96904,27 +97348,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatementInAsyncBody(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatementInAsyncBody(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClauseInAsyncBody(node); - case 235 /* Block */: - case 249 /* SwitchStatement */: - case 263 /* CaseBlock */: - case 289 /* CaseClause */: - case 290 /* DefaultClause */: - case 252 /* TryStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 239 /* IfStatement */: - case 248 /* WithStatement */: - case 250 /* LabeledStatement */: + case 235 /* SyntaxKind.Block */: + case 249 /* SyntaxKind.SwitchStatement */: + case 263 /* SyntaxKind.CaseBlock */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: + case 252 /* SyntaxKind.TryStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 239 /* SyntaxKind.IfStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -97006,7 +97450,7 @@ var ts; return factory.updateMethodDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97021,7 +97465,7 @@ var ts; function visitFunctionDeclaration(node) { return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97036,7 +97480,7 @@ var ts; function visitFunctionExpression(node) { return factory.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97051,7 +97495,7 @@ var ts; function visitArrowFunction(node) { return factory.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -97072,7 +97516,7 @@ var ts; function isVariableDeclarationListWithCollidingName(node) { return !!node && ts.isVariableDeclarationList(node) - && !(node.flags & 3 /* BlockScoped */) + && !(node.flags & 3 /* NodeFlags.BlockScoped */) && node.declarations.some(collidesWithParameterName); } function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) { @@ -97126,9 +97570,9 @@ var ts; resumeLexicalEnvironment(); var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 214 /* ArrowFunction */; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; + var promiseConstructor = languageVersion < 2 /* ScriptTarget.ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 214 /* SyntaxKind.ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* NodeCheckFlags.CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current // `this` and `arguments` objects to `__awaiter`. The generator function @@ -97154,7 +97598,7 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); if (capturedSuperProperties.size) { @@ -97167,10 +97611,10 @@ var ts; ts.setTextRange(block, node.body); if (emitSuperHelpers && hasSuperElementAccess) { // Emit helpers for super element access expressions (`super[x]`). - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -97214,21 +97658,21 @@ var ts; return undefined; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -97241,8 +97685,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -97269,30 +97713,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -97312,19 +97756,19 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } else { - return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* Optimistic */ | 32 /* FileLevel */), + return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*typeArguments*/ undefined, [argumentExpression]), location); } } @@ -97334,7 +97778,7 @@ var ts; function createSuperAccessVariableStatement(factory, resolver, node, names) { // Create a variable declaration with a getter/setter (if binding) definition for each name: // const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... }); - var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) !== 0; + var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) !== 0; var accessors = []; names.forEach(function (_, key) { var name = ts.unescapeLeadingUnderscores(key); @@ -97344,7 +97788,7 @@ var ts; /* typeParameters */ undefined, /* parameters */ [], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */)))); + /* equalsGreaterThanToken */ undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */)))); if (hasBinding) { getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction( /* modifiers */ undefined, @@ -97358,20 +97802,20 @@ var ts; /* initializer */ undefined) ], /* type */ undefined, - /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* NoSubstitution */), name), 4 /* NoSubstitution */), factory.createIdentifier("v"))))); + /* equalsGreaterThanToken */ undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4 /* EmitFlags.NoSubstitution */), name), 4 /* EmitFlags.NoSubstitution */), factory.createIdentifier("v"))))); } accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter))); }); return factory.createVariableStatement( /* modifiers */ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /* type */ undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), /* typeArguments */ undefined, [ factory.createNull(), factory.createObjectLiteralExpression(accessors, /* multiline */ true) ])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); } ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement; })(ts || (ts = {})); @@ -97441,7 +97885,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -97473,7 +97917,7 @@ var ts; return visitorWorker(node, /*expressionResultIsUnused*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 131 /* AsyncKeyword */) { + if (node.kind === 131 /* SyntaxKind.AsyncKeyword */) { return undefined; } return node; @@ -97495,88 +97939,88 @@ var ts; * expression of an `ExpressionStatement`). */ function visitorWorker(node, expressionResultIsUnused) { - if ((node.transformFlags & 128 /* ContainsES2018 */) === 0) { + if ((node.transformFlags & 128 /* TransformFlags.ContainsES2018 */) === 0) { return node; } switch (node.kind) { - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return visitAwaitExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: - case 243 /* ForInStatement */: - return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 244 /* ForOfStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: + case 243 /* SyntaxKind.ForInStatement */: + return doWithHierarchyFacts(visitDefault, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: - return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - case 217 /* VoidExpression */: + case 242 /* SyntaxKind.ForStatement */: + return doWithHierarchyFacts(visitForStatement, node, 0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); - case 171 /* Constructor */: - return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 169 /* MethodDeclaration */: - return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 172 /* GetAccessor */: - return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 173 /* SetAccessor */: - return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 256 /* FunctionDeclaration */: - return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 213 /* FunctionExpression */: - return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); - case 214 /* ArrowFunction */: - return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); - case 164 /* Parameter */: + case 171 /* SyntaxKind.Constructor */: + return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 169 /* SyntaxKind.MethodDeclaration */: + return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 172 /* SyntaxKind.GetAccessor */: + return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 173 /* SyntaxKind.SetAccessor */: + return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 256 /* SyntaxKind.FunctionDeclaration */: + return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 213 /* SyntaxKind.FunctionExpression */: + return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); + case 214 /* SyntaxKind.ArrowFunction */: + return doWithHierarchyFacts(visitArrowFunction, node, 2 /* HierarchyFacts.ArrowFunctionExcludes */, 0 /* HierarchyFacts.ArrowFunctionIncludes */); + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 206 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SuperKeyword */) { + case 206 /* SyntaxKind.PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { capturedSuperProperties.add(node.name.escapedText); } return ts.visitEachChild(node, visitor, context); - case 207 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 106 /* SuperKeyword */) { + case 207 /* SyntaxKind.ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + return doWithHierarchyFacts(visitDefault, node, 2 /* HierarchyFacts.ClassOrFunctionExcludes */, 1 /* HierarchyFacts.ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); } } function visitAwaitExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), /*location*/ node), node); } return ts.visitEachChild(node, visitor, context); } function visitYieldExpression(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { if (node.asteriskToken) { var expression = ts.visitNode(ts.Debug.checkDefined(node.expression), visitor, ts.isExpression); return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression( @@ -97590,15 +98034,15 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitReturnStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */) { return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero())); } return ts.visitEachChild(node, visitor, context); } function visitLabeledStatement(node) { - if (enclosingFunctionFlags & 2 /* Async */) { + if (enclosingFunctionFlags & 2 /* FunctionFlags.Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 244 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 244 /* SyntaxKind.ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node); @@ -97610,7 +98054,7 @@ var ts; var objects = []; for (var _i = 0, elements_5 = elements; _i < elements_5.length; _i++) { var e = elements_5[_i]; - if (e.kind === 298 /* SpreadAssignment */) { + if (e.kind === 298 /* SyntaxKind.SpreadAssignment */) { if (chunkObject) { objects.push(factory.createObjectLiteralExpression(chunkObject)); chunkObject = undefined; @@ -97619,7 +98063,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 296 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 296 /* SyntaxKind.PropertyAssignment */ ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -97630,7 +98074,7 @@ var ts; return objects; } function visitObjectLiteralExpression(node) { - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { // spread elements emit like so: // non-spread elements are chunked together into object literals, and then all are passed to __assign: // { a, ...o, b } => __assign(__assign({a}, o), {b}); @@ -97653,7 +98097,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 205 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 205 /* SyntaxKind.ObjectLiteralExpression */) { objects.unshift(factory.createObjectLiteralExpression()); } var expression = objects[0]; @@ -97680,9 +98124,9 @@ var ts; return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context); } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? - 0 /* StrictModeSourceFileIncludes */ : - 1 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(2 /* HierarchyFacts.SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? + 0 /* HierarchyFacts.StrictModeSourceFileIncludes */ : + 1 /* HierarchyFacts.SourceFileIncludes */); exportedVariableStatement = false; var visited = ts.visitEachChild(node, visitor, context); var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ @@ -97703,10 +98147,10 @@ var ts; * expression of an `ExpressionStatement`). */ function visitBinaryExpression(node, expressionResultIsUnused) { - if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !expressionResultIsUnused); + if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -97734,10 +98178,10 @@ var ts; function visitCatchClause(node) { if (node.variableDeclaration && ts.isBindingPattern(node.variableDeclaration.name) && - node.variableDeclaration.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + node.variableDeclaration.name.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { var name = factory.getGeneratedNameForNode(node.variableDeclaration.name); var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, /*exclamationToken*/ undefined, /*type*/ undefined, name); - var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* ObjectRest */); + var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1 /* FlattenLevel.ObjectRest */); var block = ts.visitNode(node.block, visitor, ts.isBlock); if (ts.some(visitedBindings)) { block = factory.updateBlock(block, __spreadArray([ @@ -97749,7 +98193,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitVariableStatement(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var savedExportedVariableStatement = exportedVariableStatement; exportedVariableStatement = true; var visited = ts.visitEachChild(node, visitor, context); @@ -97775,8 +98219,8 @@ var ts; } function visitVariableDeclarationWorker(node, exportedVariableStatement) { // If we are here it is because the name contains a binding pattern with a rest somewhere in it. - if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { - return ts.flattenDestructuringBinding(node, visitor, context, 1 /* ObjectRest */, + if (ts.isBindingPattern(node.name) && node.name.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { + return ts.flattenDestructuringBinding(node, visitor, context, 1 /* FlattenLevel.ObjectRest */, /*rval*/ undefined, exportedVariableStatement); } return ts.visitEachChild(node, visitor, context); @@ -97793,8 +98237,8 @@ var ts; * @param node A ForOfStatement. */ function visitForOfStatement(node, outermostLabeledStatement) { - var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); - if (node.initializer.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.IterationStatementExcludes */, 2 /* HierarchyFacts.IterationStatementIncludes */); + if (node.initializer.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } var result = node.awaitModifier ? @@ -97822,7 +98266,7 @@ var ts; } return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), + ], 1 /* NodeFlags.Let */), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), /*multiLine*/ true), bodyLocation)); } return node; @@ -97842,10 +98286,10 @@ var ts; statements.push(statement); } return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), - /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function createDownlevelAwait(expression) { - return enclosingFunctionFlags & 1 /* Generator */ + return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? factory.createYieldExpression(/*asteriskToken*/ undefined, emitHelpers().createAwaitHelper(expression)) : factory.createAwaitExpression(expression); } @@ -97864,18 +98308,18 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 2 /* IterationContainer */ ? + var initializer = ancestorFacts & 2 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) : callValues; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), /*incrementor*/ undefined, /*statement*/ convertForOfStatementHead(node, getValue)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setOriginalNode(forStatement, node); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement) @@ -97883,15 +98327,15 @@ var ts; factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */) ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } function parameterVisitor(node) { @@ -97906,7 +98350,7 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } - if (node.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + if (node.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { // Binding patterns are converted into a generated name and are // evaluated inside the function body. return factory.updateParameterDeclaration(node, @@ -97923,7 +98367,7 @@ var ts; if (parameters) { parameters.add(parameter); } - else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { parameters = new ts.Set(); } } @@ -97965,13 +98409,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateMethodDeclaration(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateMethodDeclaration(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifierLike) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -97983,13 +98427,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionDeclaration(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionDeclaration(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98013,13 +98457,13 @@ var ts; var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread; enclosingFunctionFlags = ts.getFunctionFlags(node); parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); - var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) - : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + : node.modifiers, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ ? undefined : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context), - /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + /*type*/ undefined, enclosingFunctionFlags & 2 /* FunctionFlags.Async */ && enclosingFunctionFlags & 1 /* FunctionFlags.Generator */ ? transformAsyncGeneratorFunctionBody(node) : transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; @@ -98036,13 +98480,13 @@ var ts; capturedSuperProperties = new ts.Set(); hasSuperElementAccess = false; var returnStatement = factory.createReturnStatement(emitHelpers().createAsyncGeneratorHelper(factory.createFunctionExpression( - /*modifiers*/ undefined, factory.createToken(41 /* AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, factory.createToken(41 /* SyntaxKind.AsteriskToken */), node.name && factory.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */))); + /*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */))); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. - var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); + var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */ | 2048 /* NodeCheckFlags.AsyncMethodWithSuper */); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties); @@ -98053,10 +98497,10 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.updateBlock(node.body, statements); if (emitSuperHelpers && hasSuperElementAccess) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.AsyncMethodWithSuper */) { ts.addEmitHelper(block, ts.asyncSuperHelper); } } @@ -98095,11 +98539,11 @@ var ts; // // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts if (parameter.name.elements.length > 0) { - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)); + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98108,7 +98552,7 @@ var ts; var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); var assignment = factory.createAssignment(name, initializer); var statement = factory.createExpressionStatement(assignment); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98124,32 +98568,32 @@ var ts; // } var name = factory.cloneNode(parameter.name); ts.setTextRange(name, parameter.name); - ts.setEmitFlags(name, 48 /* NoSourceMap */); + ts.setEmitFlags(name, 48 /* EmitFlags.NoSourceMap */); var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression); - ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */); + ts.addEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | 1536 /* EmitFlags.NoComments */); var assignment = factory.createAssignment(name, initializer); ts.setTextRange(assignment, parameter); - ts.setEmitFlags(assignment, 1536 /* NoComments */); + ts.setEmitFlags(assignment, 1536 /* EmitFlags.NoComments */); var block = factory.createBlock([factory.createExpressionStatement(assignment)]); ts.setTextRange(block, parameter); - ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined"); var statement = factory.createIfStatement(typeCheck, block); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); statements = ts.append(statements, statement); } } - else if (parameter.transformFlags & 65536 /* ContainsObjectRestOrSpread */) { + else if (parameter.transformFlags & 65536 /* TransformFlags.ContainsObjectRestOrSpread */) { containsPrecedingObjectRestOrSpread = true; - var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter), + var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* FlattenLevel.ObjectRest */, factory.getGeneratedNameForNode(parameter), /*doNotRecordTempVariablesInLine*/ false, /*skipInitializer*/ true); if (ts.some(declarations)) { var declarationList = factory.createVariableDeclarationList(declarations); var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); statements = ts.append(statements, statement); } } @@ -98157,21 +98601,21 @@ var ts; return statements; } function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + if ((enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(208 /* CallExpression */); - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(207 /* ElementAccessExpression */); + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(207 /* SyntaxKind.ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(257 /* ClassDeclaration */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(171 /* Constructor */); + context.enableEmitNotification(257 /* SyntaxKind.ClassDeclaration */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(237 /* VariableStatement */); + context.enableEmitNotification(237 /* SyntaxKind.VariableStatement */); } } /** @@ -98184,8 +98628,8 @@ var ts; function onEmitNode(hint, node, emitCallback) { // If we need to support substitutions for `super` in an async method, // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.AsyncMethodWithSuper */ | 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */); if (superContainerFlags !== enclosingSuperContainerFlags) { var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; enclosingSuperContainerFlags = superContainerFlags; @@ -98212,30 +98656,30 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + if (hint === 1 /* EmitHint.Expression */ && enclosingSuperContainerFlags) { return substituteExpression(node); } return node; } function substituteExpression(node) { switch (node.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return substituteElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { - return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), node.name), node); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -98255,14 +98699,14 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 257 /* ClassDeclaration */ - || kind === 171 /* Constructor */ - || kind === 169 /* MethodDeclaration */ - || kind === 172 /* GetAccessor */ - || kind === 173 /* SetAccessor */; + return kind === 257 /* SyntaxKind.ClassDeclaration */ + || kind === 171 /* SyntaxKind.Constructor */ + || kind === 169 /* SyntaxKind.MethodDeclaration */ + || kind === 172 /* SyntaxKind.GetAccessor */ + || kind === 173 /* SyntaxKind.SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { - if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.AsyncMethodWithSuperBinding */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), /*typeArguments*/ undefined, [argumentExpression]), "value"), location); } @@ -98287,11 +98731,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 64 /* ContainsES2019 */) === 0) { + if ((node.transformFlags & 64 /* TransformFlags.ContainsES2019 */) === 0) { return node; } switch (node.kind) { - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -98319,29 +98763,29 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 32 /* ContainsES2020 */) === 0) { + if ((node.transformFlags & 32 /* TransformFlags.ContainsES2020 */) === 0) { return node; } switch (node.kind) { - case 208 /* CallExpression */: { + case 208 /* SyntaxKind.CallExpression */: { var updated = visitNonOptionalCallExpression(node, /*captureThisArg*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (ts.isOptionalChain(node)) { var updated = visitOptionalExpression(node, /*captureThisArg*/ false, /*isDelete*/ false); ts.Debug.assertNotNode(updated, ts.isSyntheticReference); return updated; } return ts.visitEachChild(node, visitor, context); - case 221 /* BinaryExpression */: - if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + case 221 /* SyntaxKind.BinaryExpression */: + if (node.operatorToken.kind === 60 /* SyntaxKind.QuestionQuestionToken */) { return transformNullishCoalescingExpression(node); } return ts.visitEachChild(node, visitor, context); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return visitDeleteExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98383,7 +98827,7 @@ var ts; thisArg = expression; } } - expression = node.kind === 206 /* PropertyAccessExpression */ + expression = node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)) : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression; @@ -98406,10 +98850,10 @@ var ts; } function visitNonOptionalExpression(node, captureThisArg, isDelete) { switch (node.kind) { - case 212 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); - case 208 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete); + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete); + case 208 /* SyntaxKind.CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); default: return ts.visitNode(node, visitor, ts.isExpression); } } @@ -98418,7 +98862,7 @@ var ts; var left = visitNonOptionalExpression(ts.skipPartiallyEmittedExpressions(expression), ts.isCallChain(chain[0]), /*isDelete*/ false); var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; var capturedLeft = ts.isSyntheticReference(left) ? left.expression : left; - var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* PartiallyEmittedExpressions */); + var leftExpression = factory.restoreOuterExpressions(expression, capturedLeft, 8 /* OuterExpressionKinds.PartiallyEmittedExpressions */); if (!ts.isSimpleCopiableExpression(capturedLeft)) { capturedLeft = factory.createTempVariable(hoistVariableDeclaration); leftExpression = factory.createAssignment(capturedLeft, leftExpression); @@ -98428,8 +98872,8 @@ var ts; for (var i = 0; i < chain.length; i++) { var segment = chain[i]; switch (segment.kind) { - case 206 /* PropertyAccessExpression */: - case 207 /* ElementAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: if (i === chain.length - 1 && captureThisArg) { if (!ts.isSimpleCopiableExpression(rightExpression)) { thisArg = factory.createTempVariable(hoistVariableDeclaration); @@ -98439,17 +98883,17 @@ var ts; thisArg = rightExpression; } } - rightExpression = segment.kind === 206 /* PropertyAccessExpression */ + rightExpression = segment.kind === 206 /* SyntaxKind.PropertyAccessExpression */ ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)) : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (i === 0 && leftThisArg) { if (!ts.isGeneratedIdentifier(leftThisArg)) { leftThisArg = factory.cloneNode(leftThisArg); - ts.addEmitFlags(leftThisArg, 1536 /* NoComments */); + ts.addEmitFlags(leftThisArg, 1536 /* EmitFlags.NoComments */); } - rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 106 /* SyntaxKind.SuperKeyword */ ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); } else { rightExpression = factory.createCallExpression(rightExpression, @@ -98466,7 +98910,7 @@ var ts; return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target; } function createNotNullCondition(left, right, invert) { - return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* BarBarToken */ : 55 /* AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* EqualsEqualsEqualsToken */ : 37 /* ExclamationEqualsEqualsToken */), factory.createVoidZero())); + return factory.createBinaryExpression(factory.createBinaryExpression(left, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createNull()), factory.createToken(invert ? 56 /* SyntaxKind.BarBarToken */ : 55 /* SyntaxKind.AmpersandAmpersandToken */), factory.createBinaryExpression(right, factory.createToken(invert ? 36 /* SyntaxKind.EqualsEqualsEqualsToken */ : 37 /* SyntaxKind.ExclamationEqualsEqualsToken */), factory.createVoidZero())); } function transformNullishCoalescingExpression(node) { var left = ts.visitNode(node.left, visitor, ts.isExpression); @@ -98500,11 +98944,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2021 */) === 0) { + if ((node.transformFlags & 16 /* TransformFlags.ContainsES2021 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: var binaryExpression = node; if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) { return transformLogicalAssignment(binaryExpression); @@ -98554,7 +98998,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 4 /* ContainsESNext */) === 0) { + if ((node.transformFlags & 4 /* TransformFlags.ContainsESNext */) === 0) { return node; } switch (node.kind) { @@ -98578,12 +99022,12 @@ var ts; if (currentFileState.filenameDeclaration) { return currentFileState.filenameDeclaration.name; } - var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* Optimistic */ | 32 /* FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); + var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral(currentSourceFile.fileName)); currentFileState.filenameDeclaration = declaration; return currentFileState.filenameDeclaration.name; } function getJsxFactoryCalleePrimitive(isStaticChildren) { - return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; + return compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx"; } function getJsxFactoryCallee(isStaticChildren) { var type = getJsxFactoryCalleePrimitive(isStaticChildren); @@ -98609,7 +99053,7 @@ var ts; specifierSourceImports = new ts.Map(); currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports); } - var generatedName = factory.createUniqueName("_" + name, 16 /* Optimistic */ | 32 /* FileLevel */ | 64 /* AllowNameSubstitution */); + var generatedName = factory.createUniqueName("_".concat(name), 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */ | 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */); var specifier = factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier(name), generatedName); generatedName.generatedImportReference = specifier; specifierSourceImports.set(name, specifier); @@ -98631,7 +99075,7 @@ var ts; ts.addEmitHelpers(visited, context.readEmitHelpers()); var statements = visited.statements; if (currentFileState.filenameDeclaration) { - statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* Const */))); + statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(/*modifiers*/ undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2 /* NodeFlags.Const */))); } if (currentFileState.utilizedImplicitRuntimeImports) { for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) { @@ -98648,7 +99092,7 @@ var ts; factory.createVariableDeclaration(factory.createObjectBindingPattern(ts.map(ts.arrayFrom(importSpecifiersMap.values()), function (s) { return factory.createBindingElement(/*dotdotdot*/ undefined, s.propertyName, s.name); })), /*exclaimationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, [factory.createStringLiteral(importSource)])) - ], 2 /* Const */)); + ], 2 /* NodeFlags.Const */)); ts.setParentRecursive(requireStatement, /*incremental*/ false); statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement); } @@ -98664,7 +99108,7 @@ var ts; return visited; } function visitor(node) { - if (node.transformFlags & 2 /* ContainsJsx */) { + if (node.transformFlags & 2 /* TransformFlags.ContainsJsx */) { return visitorWorker(node); } else { @@ -98673,13 +99117,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -98687,15 +99131,15 @@ var ts; } function transformJsxChildToExpression(node) { switch (node.kind) { - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return visitJsxText(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return visitJsxExpression(node); - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -98764,7 +99208,7 @@ var ts; if (keyAttr) { args.push(transformJsxAttributeInitializer(keyAttr.initializer)); } - if (compilerOptions.jsx === 5 /* ReactJSXDev */) { + if (compilerOptions.jsx === 5 /* JsxEmit.ReactJSXDev */) { var originalFile = ts.getOriginalNode(currentSourceFile); if (originalFile && ts.isSourceFile(originalFile)) { // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature @@ -98829,7 +99273,7 @@ var ts; } function transformJsxAttributesToObjectProps(attrs, children) { var target = ts.getEmitScriptTarget(compilerOptions); - return target && target >= 5 /* ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : + return target && target >= 5 /* ScriptTarget.ES2018 */ ? factory.createObjectLiteralExpression(transformJsxAttributesToProps(attrs, children)) : transformJsxAttributesToExpression(attrs, children); } function transformJsxAttributesToProps(attrs, children) { @@ -98869,14 +99313,14 @@ var ts; if (node === undefined) { return factory.createTrue(); } - if (node.kind === 10 /* StringLiteral */) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */) { // Always recreate the literal to escape any escape sequences or newlines which may be in the original jsx string and which // Need to be escaped to be handled correctly in a normal string var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote); return ts.setTextRange(literal, node); } - if (node.kind === 288 /* JsxExpression */) { + if (node.kind === 288 /* SyntaxKind.JsxExpression */) { if (node.expression === undefined) { return factory.createTrue(); } @@ -98977,7 +99421,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 278 /* JsxElement */) { + if (node.kind === 278 /* SyntaxKind.JsxElement */) { return getTagName(node.openingElement); } else { @@ -99280,11 +99724,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitor(node) { - if ((node.transformFlags & 512 /* ContainsES2016 */) === 0) { + if ((node.transformFlags & 512 /* TransformFlags.ContainsES2016 */) === 0) { return node; } switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -99292,9 +99736,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 67 /* AsteriskAsteriskEqualsToken */: + case 67 /* SyntaxKind.AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 42 /* AsteriskAsteriskToken */: + case 42 /* SyntaxKind.AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -99484,7 +99928,7 @@ var ts; currentSourceFile = undefined; currentText = undefined; taggedTemplateStringDeclarations = undefined; - hierarchyFacts = 0 /* None */; + hierarchyFacts = 0 /* HierarchyFacts.None */; return visited; } /** @@ -99494,7 +99938,7 @@ var ts; */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* AncestorFactsMask */; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 32767 /* HierarchyFacts.AncestorFactsMask */; return ancestorFacts; } /** @@ -99505,15 +99949,15 @@ var ts; * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { - hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* SubtreeFactsMask */ | ancestorFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -32768 /* HierarchyFacts.SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { - return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 247 /* ReturnStatement */ + return (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */) !== 0 + && node.kind === 247 /* SyntaxKind.ReturnStatement */ && !node.expression; } function isOrMayContainReturnCompletion(node) { - return node.transformFlags & 4194304 /* ContainsHoistedDeclarationOrCompletion */ + return node.transformFlags & 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */ && (ts.isReturnStatement(node) || ts.isIfStatement(node) || ts.isWithStatement(node) @@ -99528,11 +99972,11 @@ var ts; || ts.isBlock(node)); } function shouldVisitNode(node) { - return (node.transformFlags & 1024 /* ContainsES2015 */) !== 0 + return (node.transformFlags & 1024 /* TransformFlags.ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) + || (hierarchyFacts & 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */ && isOrMayContainReturnCompletion(node)) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) - || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; + || (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) !== 0; } function visitor(node) { return shouldVisitNode(node) ? visitorWorker(node, /*expressionResultIsUnused*/ false) : node; @@ -99544,9 +99988,9 @@ var ts; if (shouldVisitNode(node)) { var original = ts.getOriginalNode(node); if (ts.isPropertyDeclaration(original) && ts.hasStaticModifier(original)) { - var ancestorFacts = enterSubtree(32670 /* StaticInitializerExcludes */, 16449 /* StaticInitializerIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.StaticInitializerExcludes */, 16449 /* HierarchyFacts.StaticInitializerIncludes */); var result = visitorWorker(node, /*expressionResultIsUnused*/ false); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); return result; } return visitorWorker(node, /*expressionResultIsUnused*/ false); @@ -99554,115 +99998,115 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 106 /* SuperKeyword */) { + if (node.kind === 106 /* SyntaxKind.SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitorWorker(node, expressionResultIsUnused) { switch (node.kind) { - case 124 /* StaticKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: return undefined; // elide static keyword - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return visitClassExpression(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return visitParameter(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return visitArrowFunction(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return visitVariableDeclaration(node); - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return visitIdentifier(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return visitVariableDeclarationList(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 246 /* BreakStatement */: - case 245 /* ContinueStatement */: + case 246 /* SyntaxKind.BreakStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitBreakOrContinueStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return visitComputedPropertyName(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, expressionResultIsUnused); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node, expressionResultIsUnused); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node, expressionResultIsUnused); - case 14 /* NoSubstitutionTemplateLiteral */: - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return visitTemplateLiteral(node); - case 10 /* StringLiteral */: + case 10 /* SyntaxKind.StringLiteral */: return visitStringLiteral(node); - case 8 /* NumericLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: return visitNumericLiteral(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return visitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return visitSpreadElement(node); - case 106 /* SuperKeyword */: + case 106 /* SyntaxKind.SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return visitThisKeyword(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return visitMetaProperty(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return visitMethodDeclaration(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return visitVoidExpression(node); default: return ts.visitEachChild(node, visitor, context); } } function visitSourceFile(node) { - var ancestorFacts = enterSubtree(8064 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); + var ancestorFacts = enterSubtree(8064 /* HierarchyFacts.SourceFileExcludes */, 64 /* HierarchyFacts.SourceFileIncludes */); var prologue = []; var statements = []; startLexicalEnvironment(); @@ -99673,14 +100117,14 @@ var ts; } factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureThisForNodeIfNeeded(prologue, node); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements)); } function visitSwitchStatement(node) { if (convertedLoopState !== undefined) { var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; // for switch statement allow only non-labeled break - convertedLoopState.allowedNonLabeledJumps |= 2 /* Break */; + convertedLoopState.allowedNonLabeledJumps |= 2 /* Jump.Break */; var result = ts.visitEachChild(node, visitor, context); convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps; return result; @@ -99688,17 +100132,17 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCaseBlock(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function returnCapturedThis(node) { - return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)), node); + return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)), node); } function visitReturnStatement(node) { if (convertedLoopState) { - convertedLoopState.nonLocalJumps |= 8 /* Return */; + convertedLoopState.nonLocalJumps |= 8 /* Jump.Return */; if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) { node = returnCapturedThis(node); } @@ -99714,11 +100158,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitThisKeyword(node) { - if (hierarchyFacts & 2 /* ArrowFunction */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } if (convertedLoopState) { - if (hierarchyFacts & 2 /* ArrowFunction */) { + if (hierarchyFacts & 2 /* HierarchyFacts.ArrowFunction */) { // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword. convertedLoopState.containsLexicalThis = true; return node; @@ -99745,30 +100189,30 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 246 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 246 /* SyntaxKind.BreakStatement */ ? 2 /* Jump.Break */ : 4 /* Jump.Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 246 /* BreakStatement */) { - convertedLoopState.nonLocalJumps |= 2 /* Break */; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + convertedLoopState.nonLocalJumps |= 2 /* Jump.Break */; labelMarker = "break"; } else { - convertedLoopState.nonLocalJumps |= 4 /* Continue */; + convertedLoopState.nonLocalJumps |= 4 /* Jump.Continue */; // note: return value is emitted only to simplify debugging, call to converted loop body does not do any dispatching on it. labelMarker = "continue"; } } else { - if (node.kind === 246 /* BreakStatement */) { - labelMarker = "break-" + label.escapedText; + if (node.kind === 246 /* SyntaxKind.BreakStatement */) { + labelMarker = "break-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } else { - labelMarker = "continue-" + label.escapedText; + labelMarker = "continue-".concat(label.escapedText); setLabeledJump(convertedLoopState, /*isBreak*/ false, ts.idText(label), labelMarker); } } @@ -99777,15 +100221,15 @@ var ts; var outParams = convertedLoopState.loopOutParameters; var expr = void 0; for (var i = 0; i < outParams.length; i++) { - var copyExpr = copyOutParameter(outParams[i], 1 /* ToOutParameter */); + var copyExpr = copyOutParameter(outParams[i], 1 /* CopyDirection.ToOutParameter */); if (i === 0) { expr = copyExpr; } else { - expr = factory.createBinaryExpression(expr, 27 /* CommaToken */, copyExpr); + expr = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, copyExpr); } } - returnExpression = factory.createBinaryExpression(expr, 27 /* CommaToken */, returnExpression); + returnExpression = factory.createBinaryExpression(expr, 27 /* SyntaxKind.CommaToken */, returnExpression); } return factory.createReturnStatement(returnExpression); } @@ -99818,18 +100262,18 @@ var ts; ts.startOnNewLine(statement); statements.push(statement); // Add an `export default` statement for default exports (for `--target es5 --module es6`) - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { - var exportStatement = ts.hasSyntacticModifier(node, 512 /* Default */) + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { + var exportStatement = ts.hasSyntacticModifier(node, 512 /* ModifierFlags.Default */) ? factory.createExportDefault(factory.getLocalName(node)) : factory.createExternalModuleExport(factory.getLocalName(node)); ts.setOriginalNode(exportStatement, statement); statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(factory.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* EmitFlags.HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -99886,25 +100330,25 @@ var ts; /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ undefined, - /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */))] : [], + /*typeParameters*/ undefined, extendsClauseElement ? [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement)); // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* Indented */) | 524288 /* ReuseTempVariableScope */); + ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */) | 524288 /* EmitFlags.ReuseTempVariableScope */); // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter var inner = factory.createPartiallyEmittedExpression(classFunction); ts.setTextRangeEnd(inner, node.end); - ts.setEmitFlags(inner, 1536 /* NoComments */); + ts.setEmitFlags(inner, 1536 /* EmitFlags.NoComments */); var outer = factory.createPartiallyEmittedExpression(inner); ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos)); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, /*typeArguments*/ undefined, extendsClauseElement ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)] : [])); - ts.addSyntheticLeadingComment(result, 3 /* MultiLineCommentTrivia */, "* @class "); + ts.addSyntheticLeadingComment(result, 3 /* SyntaxKind.MultiLineCommentTrivia */, "* @class "); return result; } /** @@ -99922,19 +100366,19 @@ var ts; addConstructor(statements, node, constructorLikeName, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* CloseBraceToken */); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19 /* SyntaxKind.CloseBraceToken */); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = factory.createPartiallyEmittedExpression(constructorLikeName); ts.setTextRangeEnd(outer, closingBraceLocation.end); - ts.setEmitFlags(outer, 1536 /* NoComments */); + ts.setEmitFlags(outer, 1536 /* EmitFlags.NoComments */); var statement = factory.createReturnStatement(outer); ts.setTextRangePos(statement, closingBraceLocation.pos); - ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */ | 384 /* EmitFlags.NoTokenSourceMaps */); statements.push(statement); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), /*location*/ node.members), /*multiLine*/ true); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -99960,7 +100404,7 @@ var ts; function addConstructor(statements, node, name, extendsClauseElement) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32662 /* ConstructorExcludes */, 73 /* ConstructorIncludes */); + var ancestorFacts = enterSubtree(32662 /* HierarchyFacts.ConstructorExcludes */, 73 /* HierarchyFacts.ConstructorIncludes */); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); var constructorFunction = factory.createFunctionDeclaration( @@ -99970,10 +100414,10 @@ var ts; /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { - ts.setEmitFlags(constructorFunction, 8 /* CapturesThis */); + ts.setEmitFlags(constructorFunction, 8 /* EmitFlags.CapturesThis */); } statements.push(constructorFunction); - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; } /** @@ -100007,7 +100451,7 @@ var ts; ts.setTextRange(statementsArray, node.members); var block = factory.createBlock(statementsArray, /*multiLine*/ true); ts.setTextRange(block, node); - ts.setEmitFlags(block, 1536 /* NoComments */); + ts.setEmitFlags(block, 1536 /* EmitFlags.NoComments */); return block; } /** @@ -100022,7 +100466,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 104 /* SyntaxKind.NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -100066,7 +100510,7 @@ var ts; superCallExpression = visitSuperCallInBody(superCall); } if (superCallExpression) { - hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */; + hierarchyFacts |= 8192 /* HierarchyFacts.ConstructorWithCapturedSuper */; } // Add parameter defaults at the beginning of the output, with prologue statements addDefaultValueAssignmentsIfNeeded(prologue, constructor); @@ -100076,7 +100520,7 @@ var ts; factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* ContainsLexicalThis */)) { + if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */)) { // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the // following representation: // @@ -100099,7 +100543,7 @@ var ts; var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression); var returnStatement = factory.createReturnStatement(superCallExpression); ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1)); - ts.setEmitFlags(superCall_1, 1536 /* NoComments */); + ts.setEmitFlags(superCall_1, 1536 /* EmitFlags.NoComments */); statements.push(returnStatement); } else { @@ -100138,7 +100582,7 @@ var ts; } } if (!isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */))); + statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */))); } } } @@ -100188,11 +100632,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 247 /* ReturnStatement */) { + if (statement.kind === 247 /* SyntaxKind.ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 239 /* IfStatement */) { + else if (statement.kind === 239 /* SyntaxKind.IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -100200,7 +100644,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 235 /* Block */) { + else if (statement.kind === 235 /* SyntaxKind.Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -100209,10 +100653,10 @@ var ts; return false; } function createActualThis() { - return ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */); + return ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */); } function createDefaultSuperCallOrThis() { - return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); + return factory.createLogicalOr(factory.createLogicalAnd(factory.createStrictInequality(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), factory.createNull()), factory.createFunctionApplyCall(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), createActualThis(), factory.createIdentifier("arguments"))), createActualThis()); } /** * Visits a parameter declaration. @@ -100299,11 +100743,11 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, factory.getGeneratedNameForNode(parameter)))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } else if (initializer) { - ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); + ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* EmitFlags.CustomPrologue */)); return true; } return false; @@ -100321,11 +100765,11 @@ var ts; var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([ factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment( // TODO(rbuckton): Does this need to be parented? - ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) - ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */)); + ts.setEmitFlags(ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent), 48 /* EmitFlags.NoSourceMap */), ts.setEmitFlags(initializer, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* EmitFlags.NoComments */)), parameter), 1536 /* EmitFlags.NoComments */)) + ]), parameter), 1 /* EmitFlags.SingleLine */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */)); ts.startOnNewLine(statement); ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1048576 /* EmitFlags.CustomPrologue */ | 1536 /* EmitFlags.NoComments */); ts.insertStatementAfterCustomPrologue(statements, statement); } /** @@ -100356,10 +100800,10 @@ var ts; } // `declarationName` is the name of the local declaration for the parameter. // TODO(rbuckton): Does this need to be parented? - var declarationName = parameter.name.kind === 79 /* Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); - ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); + var declarationName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(/*recordTempVariable*/ undefined); + ts.setEmitFlags(declarationName, 48 /* EmitFlags.NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 79 /* Identifier */ ? factory.cloneNode(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 79 /* SyntaxKind.Identifier */ ? factory.cloneNode(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = factory.createLoopVariable(); // var param = []; @@ -100369,7 +100813,7 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, factory.createArrayLiteralExpression([])) ])), - /*location*/ parameter), 1048576 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* EmitFlags.CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -100381,13 +100825,13 @@ var ts; : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* EmitFlags.CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 79 /* Identifier */) { + if (parameter.name.kind !== 79 /* SyntaxKind.Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); + /*modifiers*/ undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* FlattenLevel.All */, expressionName))), parameter), 1048576 /* EmitFlags.CustomPrologue */)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; @@ -100400,7 +100844,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 65536 /* CapturedLexicalThis */ && node.kind !== 214 /* ArrowFunction */) { + if (hierarchyFacts & 65536 /* HierarchyFacts.CapturedLexicalThis */ && node.kind !== 214 /* SyntaxKind.ArrowFunction */) { insertCaptureThisForNode(statements, node, factory.createThis()); return true; } @@ -100414,7 +100858,7 @@ var ts; */ function insertSuperThisCaptureThisForNode(statements, superExpression) { enableSubstitutionsForCapturedThis(); - var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression)); + var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* SyntaxKind.EqualsToken */, superExpression)); ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression); ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent); } @@ -100422,38 +100866,38 @@ var ts; enableSubstitutionsForCapturedThis(); var captureThisStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); ts.setSourceMapRange(captureThisStatement, node); ts.insertStatementAfterCustomPrologue(statements, captureThisStatement); } function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) { - if (hierarchyFacts & 32768 /* NewTarget */) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return statements; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = factory.createVoidZero(); break; - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. - newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"); + newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"); break; - case 256 /* FunctionDeclaration */: - case 213 /* FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 213 /* SyntaxKind.FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), 102 /* InstanceOfKeyword */, factory.getLocalName(node))), - /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* NoSubstitution */), "constructor"), + newTarget = factory.createConditionalExpression(factory.createLogicalAnd(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), factory.createBinaryExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), 102 /* SyntaxKind.InstanceOfKeyword */, factory.getLocalName(node))), + /*questionToken*/ undefined, factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4 /* EmitFlags.NoSubstitution */), "constructor"), /*colonToken*/ undefined, factory.createVoidZero()); break; default: @@ -100461,11 +100905,11 @@ var ts; } var captureNewTargetStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ - factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */), + factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), /*exclamationToken*/ undefined, /*type*/ undefined, newTarget) ])); - ts.setEmitFlags(captureNewTargetStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); + ts.setEmitFlags(captureNewTargetStatement, 1536 /* EmitFlags.NoComments */ | 1048576 /* EmitFlags.CustomPrologue */); if (copyOnWrite) { statements = statements.slice(); } @@ -100484,21 +100928,21 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 171 /* Constructor */: - case 170 /* ClassStaticBlockDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -100537,7 +100981,7 @@ var ts; var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, /*location*/ member.name); e = factory.createAssignment(memberName, memberFunction); } - ts.setEmitFlags(memberFunction, 1536 /* NoComments */); + ts.setEmitFlags(memberFunction, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); var statement = ts.setTextRange(factory.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); @@ -100545,7 +100989,7 @@ var ts; // The location for the statement is used to emit comments only. // No source map should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 48 /* NoSourceMap */); + ts.setEmitFlags(statement, 48 /* EmitFlags.NoSourceMap */); return statement; } /** @@ -100559,7 +101003,7 @@ var ts; // The location for the statement is used to emit source maps only. // No comments should be emitted for this statement to align with the // old emitter. - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor)); return statement; } @@ -100575,20 +101019,20 @@ var ts; // arguments are both mapped contiguously to the accessor name. // TODO(rbuckton): Does this need to be parented? var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent); - ts.setEmitFlags(target, 1536 /* NoComments */ | 32 /* NoTrailingSourceMap */); + ts.setEmitFlags(target, 1536 /* EmitFlags.NoComments */ | 32 /* EmitFlags.NoTrailingSourceMap */); ts.setSourceMapRange(target, firstAccessor.name); var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName); if (ts.isPrivateIdentifier(visitedAccessorName)) { return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015."); } var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName); - ts.setEmitFlags(propertyName, 1536 /* NoComments */ | 16 /* NoLeadingSourceMap */); + ts.setEmitFlags(propertyName, 1536 /* EmitFlags.NoComments */ | 16 /* EmitFlags.NoLeadingSourceMap */); ts.setSourceMapRange(propertyName, firstAccessor.name); var properties = []; if (getAccessor) { var getterFunction = transformFunctionLikeToExpression(getAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor)); - ts.setEmitFlags(getterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(getterFunction, 512 /* EmitFlags.NoLeadingComments */); var getter = factory.createPropertyAssignment("get", getterFunction); ts.setCommentRange(getter, ts.getCommentRange(getAccessor)); properties.push(getter); @@ -100596,7 +101040,7 @@ var ts; if (setAccessor) { var setterFunction = transformFunctionLikeToExpression(setAccessor, /*location*/ undefined, /*name*/ undefined, container); ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor)); - ts.setEmitFlags(setterFunction, 512 /* NoLeadingComments */); + ts.setEmitFlags(setterFunction, 512 /* EmitFlags.NoLeadingComments */); var setter = factory.createPropertyAssignment("set", setterFunction); ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); @@ -100619,12 +101063,12 @@ var ts; * @param node An ArrowFunction node. */ function visitArrowFunction(node) { - if (node.transformFlags & 16384 /* ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* StaticInitializer */)) { - hierarchyFacts |= 65536 /* CapturedLexicalThis */; + if (node.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */ && !(hierarchyFacts & 16384 /* HierarchyFacts.StaticInitializer */)) { + hierarchyFacts |= 65536 /* HierarchyFacts.CapturedLexicalThis */; } var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(15232 /* ArrowFunctionExcludes */, 66 /* ArrowFunctionIncludes */); + var ancestorFacts = enterSubtree(15232 /* HierarchyFacts.ArrowFunctionExcludes */, 66 /* HierarchyFacts.ArrowFunctionIncludes */); var func = factory.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -100633,9 +101077,9 @@ var ts; /*type*/ undefined, transformFunctionBody(node)); ts.setTextRange(func, node); ts.setOriginalNode(func, node); - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); // If an arrow function contains - exitSubtree(ancestorFacts, 0 /* ArrowFunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.ArrowFunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return func; } @@ -100645,17 +101089,17 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ - ? enterSubtree(32662 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* EmitFlags.AsyncFunctionBody */ + ? enterSubtree(32662 /* HierarchyFacts.AsyncFunctionBodyExcludes */, 69 /* HierarchyFacts.AsyncFunctionBodyIncludes */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionExpression(node, /*modifiers*/ undefined, node.asteriskToken, name, @@ -100670,13 +101114,13 @@ var ts; function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - var name = hierarchyFacts & 32768 /* NewTarget */ + var name = hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ ? factory.getLocalName(node) : node.name; - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, /*typeParameters*/ undefined, parameters, @@ -100693,14 +101137,14 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = container && ts.isClassLike(container) && !ts.isStatic(node) - ? enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */ | 8 /* NonStaticClassElement */) - : enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + ? enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */ | 8 /* HierarchyFacts.NonStaticClassElement */) + : enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 32768 /* NewTarget */ && !name && (node.kind === 256 /* FunctionDeclaration */ || node.kind === 213 /* FunctionExpression */)) { + if (hierarchyFacts & 32768 /* HierarchyFacts.NewTarget */ && !name && (node.kind === 256 /* SyntaxKind.FunctionDeclaration */ || node.kind === 213 /* SyntaxKind.FunctionExpression */)) { name = factory.getGeneratedNameForNode(node); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression( /*modifiers*/ undefined, node.asteriskToken, name, @@ -100743,7 +101187,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 214 /* ArrowFunction */); + ts.Debug.assert(node.kind === 214 /* SyntaxKind.ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -100762,7 +101206,7 @@ var ts; var returnStatement = factory.createReturnStatement(expression); ts.setTextRange(returnStatement, body); ts.moveSyntheticComments(returnStatement, body); - ts.setEmitFlags(returnStatement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1024 /* NoTrailingComments */); + ts.setEmitFlags(returnStatement, 384 /* EmitFlags.NoTokenSourceMaps */ | 32 /* EmitFlags.NoTrailingSourceMap */ | 1024 /* EmitFlags.NoTrailingComments */); statements.push(returnStatement); // To align with the source map emit for the old emitter, we set a custom // source map location for the close brace. @@ -100783,10 +101227,10 @@ var ts; var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine); ts.setTextRange(block, node.body); if (!multiLine && singleLine) { - ts.setEmitFlags(block, 1 /* SingleLine */); + ts.setEmitFlags(block, 1 /* EmitFlags.SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 19 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 19 /* SyntaxKind.CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -100796,11 +101240,11 @@ var ts; // A function body is not a block scope. return ts.visitEachChild(node, visitor, context); } - var ancestorFacts = hierarchyFacts & 256 /* IterationStatement */ - ? enterSubtree(7104 /* IterationStatementBlockExcludes */, 512 /* IterationStatementBlockIncludes */) - : enterSubtree(6976 /* BlockExcludes */, 128 /* BlockIncludes */); + var ancestorFacts = hierarchyFacts & 256 /* HierarchyFacts.IterationStatement */ + ? enterSubtree(7104 /* HierarchyFacts.IterationStatementBlockExcludes */, 512 /* HierarchyFacts.IterationStatementBlockIncludes */) + : enterSubtree(6976 /* HierarchyFacts.BlockExcludes */, 128 /* HierarchyFacts.BlockIncludes */); var updated = ts.visitEachChild(node, visitor, context); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -100831,9 +101275,9 @@ var ts; function visitBinaryExpression(node, expressionResultIsUnused) { // If we are here it is because this is a destructuring assignment. if (ts.isDestructuringAssignment(node)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !expressionResultIsUnused); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !expressionResultIsUnused); } - if (node.operatorToken.kind === 27 /* CommaToken */) { + if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -100861,12 +101305,12 @@ var ts; function isVariableStatementOfTypeScriptClassWrapper(node) { return node.declarationList.declarations.length === 1 && !!node.declarationList.declarations[0].initializer - && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */); + && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* EmitFlags.TypeScriptClassWrapper */); } function visitVariableStatement(node) { - var ancestorFacts = enterSubtree(0 /* None */, ts.hasSyntacticModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); + var ancestorFacts = enterSubtree(0 /* HierarchyFacts.None */, ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */) ? 32 /* HierarchyFacts.ExportedVariableStatement */ : 0 /* HierarchyFacts.None */); var updated; - if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { + if (convertedLoopState && (node.declarationList.flags & 3 /* NodeFlags.BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -100875,10 +101319,10 @@ var ts; if (decl.initializer) { var assignment = void 0; if (ts.isBindingPattern(decl.name)) { - assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); + assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* FlattenLevel.All */); } else { - assignment = factory.createBinaryExpression(decl.name, 63 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = factory.createBinaryExpression(decl.name, 63 /* SyntaxKind.EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -100895,7 +101339,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } /** @@ -100904,11 +101348,11 @@ var ts; * @param node A VariableDeclarationList node. */ function visitVariableDeclarationList(node) { - if (node.flags & 3 /* BlockScoped */ || node.transformFlags & 524288 /* ContainsBindingPattern */) { - if (node.flags & 3 /* BlockScoped */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */ || node.transformFlags & 524288 /* TransformFlags.ContainsBindingPattern */) { + if (node.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } - var declarations = ts.flatMap(node.declarations, node.flags & 1 /* Let */ + var declarations = ts.flatMap(node.declarations, node.flags & 1 /* NodeFlags.Let */ ? visitVariableDeclarationInLetDeclarationList : visitVariableDeclaration); var declarationList = factory.createVariableDeclarationList(declarations); @@ -100917,7 +101361,7 @@ var ts; ts.setCommentRange(declarationList, node); // If the first or last declaration is a binding pattern, we need to modify // the source map range for the declaration list. - if (node.transformFlags & 524288 /* ContainsBindingPattern */ + if (node.transformFlags & 524288 /* TransformFlags.ContainsBindingPattern */ && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) { ts.setSourceMapRange(declarationList, getRangeUnion(declarations)); } @@ -100983,18 +101427,18 @@ var ts; // * Why loop initializer is excluded? // - Since we've introduced a fresh name it already will be undefined. var flags = resolver.getNodeCheckFlags(node); - var isCapturedInFunction = flags & 262144 /* CapturedBlockScopedBinding */; - var isDeclaredInLoop = flags & 524288 /* BlockScopedBindingInLoop */; - var emittedAsTopLevel = (hierarchyFacts & 64 /* TopLevel */) !== 0 + var isCapturedInFunction = flags & 262144 /* NodeCheckFlags.CapturedBlockScopedBinding */; + var isDeclaredInLoop = flags & 524288 /* NodeCheckFlags.BlockScopedBindingInLoop */; + var emittedAsTopLevel = (hierarchyFacts & 64 /* HierarchyFacts.TopLevel */) !== 0 || (isCapturedInFunction && isDeclaredInLoop - && (hierarchyFacts & 512 /* IterationStatementBlock */) !== 0); + && (hierarchyFacts & 512 /* HierarchyFacts.IterationStatementBlock */) !== 0); var emitExplicitInitializer = !emittedAsTopLevel - && (hierarchyFacts & 4096 /* ForInOrForOfStatement */) === 0 + && (hierarchyFacts & 4096 /* HierarchyFacts.ForInOrForOfStatement */) === 0 && (!resolver.isDeclarationWithCollidingName(node) || (isDeclaredInLoop && !isCapturedInFunction - && (hierarchyFacts & (2048 /* ForStatement */ | 4096 /* ForInOrForOfStatement */)) === 0)); + && (hierarchyFacts & (2048 /* HierarchyFacts.ForStatement */ | 4096 /* HierarchyFacts.ForInOrForOfStatement */)) === 0)); return emitExplicitInitializer; } /** @@ -101021,16 +101465,16 @@ var ts; * @param node A VariableDeclaration node. */ function visitVariableDeclaration(node) { - var ancestorFacts = enterSubtree(32 /* ExportedVariableStatement */, 0 /* None */); + var ancestorFacts = enterSubtree(32 /* HierarchyFacts.ExportedVariableStatement */, 0 /* HierarchyFacts.None */); var updated; if (ts.isBindingPattern(node.name)) { - updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* All */, - /*value*/ undefined, (ancestorFacts & 32 /* ExportedVariableStatement */) !== 0); + updated = ts.flattenDestructuringBinding(node, visitor, context, 0 /* FlattenLevel.All */, + /*value*/ undefined, (ancestorFacts & 32 /* HierarchyFacts.ExportedVariableStatement */) !== 0); } else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function recordLabel(node) { @@ -101050,50 +101494,50 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function visitDoOrWhileStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(0 /* DoOrWhileStatementExcludes */, 1280 /* DoOrWhileStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(0 /* HierarchyFacts.DoOrWhileStatementExcludes */, 1280 /* HierarchyFacts.DoOrWhileStatementIncludes */, node, outermostLabeledStatement); } function visitForStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(5056 /* ForStatementExcludes */, 3328 /* ForStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(5056 /* HierarchyFacts.ForStatementExcludes */, 3328 /* HierarchyFacts.ForStatementIncludes */, node, outermostLabeledStatement); } function visitEachChildOfForStatement(node) { return factory.updateForStatement(node, ts.visitNode(node.initializer, visitorWithUnusedExpressionResult, ts.isForInitializer), ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitorWithUnusedExpressionResult, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock)); } function visitForInStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(3008 /* ForInOrForOfStatementExcludes */, 5376 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); + return visitIterationStatementWithFacts(3008 /* HierarchyFacts.ForInOrForOfStatementExcludes */, 5376 /* HierarchyFacts.ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; var initializer = node.initializer; if (ts.isVariableDeclarationList(initializer)) { - if (node.initializer.flags & 3 /* BlockScoped */) { + if (node.initializer.flags & 3 /* NodeFlags.BlockScoped */) { enableSubstitutionsForBlockScopedBindings(); } var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { // This works whether the declaration is a var, let, or const. // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* FlattenLevel.All */, boundValue); var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer); ts.setOriginalNode(declarationList, node.initializer); // Adjust the source map range for the first declaration to align with the old @@ -101141,7 +101585,7 @@ var ts; } function createSyntheticBlockForConvertedStatements(statements) { return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), - /*multiLine*/ true), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + /*multiLine*/ true), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */); } function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: @@ -101173,18 +101617,18 @@ var ts; var counter = factory.createLoopVariable(); var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression - ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); + ts.setEmitFlags(expression, 48 /* EmitFlags.NoSourceMap */ | ts.getEmitFlags(expression)); var forStatement = ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(counter, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(factory.createVariableDeclaration(rhsReference, /*exclamationToken*/ undefined, /*type*/ undefined, expression), node.expression) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ ts.setTextRange(factory.createLessThan(counter, factory.createPropertyAccessExpression(rhsReference, "length")), node.expression), /*incrementor*/ ts.setTextRange(factory.createPostfixIncrement(counter), node.expression), /*statement*/ convertForOfStatementHead(node, factory.createElementAccessExpression(rhsReference, counter), convertedLoopBodyStatements)), /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. - ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); + ts.setEmitFlags(forStatement, 256 /* EmitFlags.NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } @@ -101200,33 +101644,33 @@ var ts; hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration - var initializer = ancestorFacts & 1024 /* IterationContainer */ + var initializer = ancestorFacts & 1024 /* HierarchyFacts.IterationContainer */ ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values]) : values; var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement( /*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([ ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression), factory.createVariableDeclaration(result, /*exclamationToken*/ undefined, /*type*/ undefined, next) - ]), node.expression), 2097152 /* NoHoisting */), + ]), node.expression), 2097152 /* EmitFlags.NoHoisting */), /*condition*/ factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), /*incrementor*/ factory.createAssignment(result, next), /*statement*/ convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), - /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + /*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */); return factory.createTryStatement(factory.createBlock([ factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([ factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([ factory.createPropertyAssignment("error", catchVariable) ]))) - ]), 1 /* SingleLine */)), factory.createBlock([ + ]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([ factory.createTryStatement( /*tryBlock*/ factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done"))), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(factory.createFunctionCallCall(returnMethod, iterator, []))), 1 /* EmitFlags.SingleLine */), ]), /*catchClause*/ undefined, /*finallyBlock*/ ts.setEmitFlags(factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* SingleLine */) - ]), 1 /* SingleLine */)) + ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1 /* EmitFlags.SingleLine */) + ]), 1 /* EmitFlags.SingleLine */)) ])); } /** @@ -101241,9 +101685,9 @@ var ts; var numInitialProperties = -1, hasComputed = false; for (var i = 0; i < properties.length; i++) { var property = properties[i]; - if ((property.transformFlags & 1048576 /* ContainsYield */ && - hierarchyFacts & 4 /* AsyncFunctionBody */) - || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* ComputedPropertyName */)) { + if ((property.transformFlags & 1048576 /* TransformFlags.ContainsYield */ && + hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + || (hasComputed = ts.Debug.checkDefined(property.name).kind === 162 /* SyntaxKind.ComputedPropertyName */)) { numInitialProperties = i; break; } @@ -101256,7 +101700,7 @@ var ts; var temp = factory.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* Indented */ : 0)); + var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 /* EmitFlags.Indented */ : 0)); if (node.multiLine) { ts.startOnNewLine(assignment); } @@ -101268,7 +101712,7 @@ var ts; return factory.inlineExpressions(expressions); } function shouldConvertPartOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 131072 /* ContainsCapturedBlockScopeBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 131072 /* NodeCheckFlags.ContainsCapturedBlockScopeBinding */) !== 0; } function shouldConvertInitializerOfForStatement(node) { return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer); @@ -101284,7 +101728,7 @@ var ts; || shouldConvertInitializerOfForStatement(node); } function shouldConvertBodyOfIterationStatement(node) { - return (resolver.getNodeCheckFlags(node) & 65536 /* LoopWithCapturedBlockScopedBinding */) !== 0; + return (resolver.getNodeCheckFlags(node) & 65536 /* NodeCheckFlags.LoopWithCapturedBlockScopedBinding */) !== 0; } /** * Records constituents of name for the given variable to be hoisted in the outer scope. @@ -101295,7 +101739,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -101315,7 +101759,7 @@ var ts; // we get here if we are trying to emit normal loop loop inside converted loop // set allowedNonLabeledJumps to Break | Continue to mark that break\continue inside the loop should be emitted as is saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps; - convertedLoopState.allowedNonLabeledJumps = 2 /* Break */ | 4 /* Continue */; + convertedLoopState.allowedNonLabeledJumps = 2 /* Jump.Break */ | 4 /* Jump.Continue */; } var result = convert ? convert(node, outermostLabeledStatement, /*convertedLoopBodyStatements*/ undefined, ancestorFacts) @@ -101359,11 +101803,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 242 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 243 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 244 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 240 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 241 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 242 /* SyntaxKind.ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 243 /* SyntaxKind.ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 244 /* SyntaxKind.ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 240 /* SyntaxKind.DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 241 /* SyntaxKind.WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -101388,11 +101832,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 242 /* ForStatement */: - case 243 /* ForInStatement */: - case 244 /* ForOfStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 243 /* SyntaxKind.ForInStatement */: + case 244 /* SyntaxKind.ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 255 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 255 /* SyntaxKind.VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -101401,7 +101845,7 @@ var ts; var loopParameters = []; // variables declared in the loop initializer that will be changed inside the loop var loopOutParameters = []; - if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) { + if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* NodeFlags.BlockScoped */)) { var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) || shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node); @@ -101514,15 +101958,15 @@ var ts; */ function createFunctionForInitializerOfForStatement(node, currentState) { var functionName = factory.createUniqueName("_loop_init"); - var containsYield = (node.initializer.transformFlags & 1048576 /* ContainsYield */) !== 0; - var emitFlags = 0 /* None */; + var containsYield = (node.initializer.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 0 /* EmitFlags.None */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && hierarchyFacts & 4 /* AsyncFunctionBody */) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; var statements = []; statements.push(factory.createVariableStatement(/*modifiers*/ undefined, node.initializer)); - copyOutParameters(currentState.loopOutParameters, 2 /* Initializer */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 2 /* LoopOutParameterFlags.Initializer */, 1 /* CopyDirection.ToOutParameter */, statements); // This transforms the following ES2015 syntax: // // for (let i = (setImmediate(() => console.log(i)), 0); i < 2; i++) { @@ -101548,12 +101992,12 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, /*type*/ undefined, ts.visitNode(factory.createBlock(statements, /*multiLine*/ true), visitor, ts.isBlock)), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } @@ -101615,7 +102059,7 @@ var ts; statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue())))); } if (shouldConvertConditionOfForStatement(node)) { - statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); + statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53 /* SyntaxKind.ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -101624,17 +102068,17 @@ var ts; else { statements.push(statement); } - copyOutParameters(currentState.loopOutParameters, 1 /* Body */, 1 /* ToOutParameter */, statements); + copyOutParameters(currentState.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 1 /* CopyDirection.ToOutParameter */, statements); ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment); var loopBody = factory.createBlock(statements, /*multiLine*/ true); if (ts.isBlock(statement)) ts.setOriginalNode(loopBody, statement); - var containsYield = (node.statement.transformFlags & 1048576 /* ContainsYield */) !== 0; - var emitFlags = 524288 /* ReuseTempVariableScope */; + var containsYield = (node.statement.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; + var emitFlags = 524288 /* EmitFlags.ReuseTempVariableScope */; if (currentState.containsLexicalThis) - emitFlags |= 8 /* CapturesThis */; - if (containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0) - emitFlags |= 262144 /* AsyncFunctionBody */; + emitFlags |= 8 /* EmitFlags.CapturesThis */; + if (containsYield && (hierarchyFacts & 4 /* HierarchyFacts.AsyncFunctionBody */) !== 0) + emitFlags |= 262144 /* EmitFlags.AsyncFunctionBody */; // This transforms the following ES2015 syntax (in addition to other variations): // // for (let i = 0; i < 2; i++) { @@ -101654,18 +102098,18 @@ var ts; factory.createVariableDeclaration(functionName, /*exclamationToken*/ undefined, /*type*/ undefined, ts.setEmitFlags(factory.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? factory.createToken(41 /* SyntaxKind.AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) - ]), 2097152 /* NoHoisting */)); + ]), 2097152 /* EmitFlags.NoHoisting */)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; } function copyOutParameter(outParam, copyDirection) { - var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; - var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return factory.createBinaryExpression(target, 63 /* EqualsToken */, source); + var source = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.outParamName : outParam.originalName; + var target = copyDirection === 0 /* CopyDirection.ToOriginal */ ? outParam.originalName : outParam.outParamName; + return factory.createBinaryExpression(target, 63 /* SyntaxKind.EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -101678,7 +102122,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = factory.createCallExpression(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; return factory.createExpressionStatement(callResult); } @@ -101687,27 +102131,27 @@ var ts; // loop is considered simple if it does not have any return statements or break\continue that transfer control outside of the loop // simple loops are emitted as just 'loop()'; // NOTE: if loop uses only 'continue' it still will be emitted as simple loop - var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Continue */) && + var isSimpleLoop = !(state.nonLocalJumps & ~4 /* Jump.Continue */) && !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = factory.createCallExpression(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? factory.createYieldExpression(factory.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? factory.createYieldExpression(factory.createToken(41 /* SyntaxKind.AsteriskToken */), ts.setEmitFlags(call, 8388608 /* EmitFlags.Iterator */)) : call; if (isSimpleLoop) { statements.push(factory.createExpressionStatement(callResult)); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); } else { var loopResultName = factory.createUniqueName("state"); var stateVariable = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, /*exclamationToken*/ undefined, /*type*/ undefined, callResult)])); statements.push(stateVariable); - copyOutParameters(state.loopOutParameters, 1 /* Body */, 0 /* ToOriginal */, statements); - if (state.nonLocalJumps & 8 /* Return */) { + copyOutParameters(state.loopOutParameters, 1 /* LoopOutParameterFlags.Body */, 0 /* CopyDirection.ToOriginal */, statements); + if (state.nonLocalJumps & 8 /* Jump.Return */) { var returnStatement = void 0; if (outerState) { - outerState.nonLocalJumps |= 8 /* Return */; + outerState.nonLocalJumps |= 8 /* Jump.Return */; returnStatement = factory.createReturnStatement(loopResultName); } else { @@ -101715,7 +102159,7 @@ var ts; } statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement)); } - if (state.nonLocalJumps & 2 /* Break */) { + if (state.nonLocalJumps & 2 /* Jump.Break */) { statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { @@ -101774,19 +102218,19 @@ var ts; else { loopParameters.push(factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); var checkFlags = resolver.getNodeCheckFlags(decl); - if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) { var outParamName = factory.createUniqueName("out_" + ts.idText(name)); var flags = 0; - if (checkFlags & 4194304 /* NeedsLoopOutParameter */) { - flags |= 1 /* Body */; + if (checkFlags & 4194304 /* NodeCheckFlags.NeedsLoopOutParameter */) { + flags |= 1 /* LoopOutParameterFlags.Body */; } if (ts.isForStatement(container)) { if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) { - flags |= 2 /* Initializer */; + flags |= 2 /* LoopOutParameterFlags.Initializer */; } if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) || container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) { - flags |= 1 /* Body */; + flags |= 1 /* LoopOutParameterFlags.Body */; } } loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName }); @@ -101808,20 +102252,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -101876,14 +102320,14 @@ var ts; return expression; } function visitCatchClause(node) { - var ancestorFacts = enterSubtree(7104 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); + var ancestorFacts = enterSubtree(7104 /* HierarchyFacts.BlockScopeExcludes */, 0 /* HierarchyFacts.BlockScopeIncludes */); var updated; ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015."); if (ts.isBindingPattern(node.variableDeclaration.name)) { var temp = factory.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = factory.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); - var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); + var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* FlattenLevel.All */, temp); var list = factory.createVariableDeclarationList(vars); ts.setTextRange(list, node.variableDeclaration); var destructure = factory.createVariableStatement(/*modifiers*/ undefined, list); @@ -101892,7 +102336,7 @@ var ts; else { updated = ts.visitEachChild(node, visitor, context); } - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return updated; } function addStatementToStartOfBlock(block, statement) { @@ -101911,7 +102355,7 @@ var ts; // Methods with computed property names are handled in visitObjectLiteralExpression. ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var functionExpression = transformFunctionLikeToExpression(node, /*location*/ ts.moveRangePos(node, -1), /*name*/ undefined, /*container*/ undefined); - ts.setEmitFlags(functionExpression, 512 /* NoLeadingComments */ | ts.getEmitFlags(functionExpression)); + ts.setEmitFlags(functionExpression, 512 /* EmitFlags.NoLeadingComments */ | ts.getEmitFlags(functionExpression)); return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), /*location*/ node); } @@ -101924,17 +102368,17 @@ var ts; ts.Debug.assert(!ts.isComputedPropertyName(node.name)); var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, 65 /* HierarchyFacts.FunctionIncludes */); var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 172 /* GetAccessor */) { + if (node.kind === 172 /* SyntaxKind.GetAccessor */) { updated = factory.updateGetAccessorDeclaration(node, node.modifiers, node.name, parameters, node.type, body); } else { updated = factory.updateSetAccessorDeclaration(node, node.modifiers, node.name, parameters, body); } - exitSubtree(ancestorFacts, 98304 /* FunctionSubtreeExcludes */, 0 /* None */); + exitSubtree(ancestorFacts, 98304 /* HierarchyFacts.FunctionSubtreeExcludes */, 0 /* HierarchyFacts.None */); convertedLoopState = savedConvertedLoopState; return updated; } @@ -101977,11 +102421,11 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { + if (ts.getEmitFlags(node) & 33554432 /* EmitFlags.TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 106 /* SuperKeyword */ || + if (expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -102054,7 +102498,7 @@ var ts; // }()) // var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression); - if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* CommaToken */) { + if (!aliasAssignment && ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { aliasAssignment = ts.tryCast(initializer.left, ts.isAssignmentExpression); } // The underlying call (3) is another IIFE that may contain a '_super' argument. @@ -102111,15 +102555,15 @@ var ts; function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. - if (node.transformFlags & 32768 /* ContainsRestOrSpread */ || - node.expression.kind === 106 /* SuperKeyword */ || + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */ || + node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 106 /* SuperKeyword */) { - ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { + ts.setEmitFlags(thisArg, 4 /* EmitFlags.NoSubstitution */); } var resultingCall = void 0; - if (node.transformFlags & 32768 /* ContainsRestOrSpread */) { + if (node.transformFlags & 32768 /* TransformFlags.ContainsRestOrSpread */) { // [source] // f(...a, b) // x.m(...a, b) @@ -102133,7 +102577,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = factory.createFunctionApplyCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*isArgumentList*/ true, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -102145,12 +102589,12 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); + resultingCall = ts.setTextRange(factory.createFunctionCallCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 106 /* SyntaxKind.SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression)), node); } - if (node.expression.kind === 106 /* SuperKeyword */) { + if (node.expression.kind === 106 /* SyntaxKind.SuperKeyword */) { var initializer = factory.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis - ? factory.createAssignment(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), initializer) + ? factory.createAssignment(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), initializer) : initializer; } return ts.setOriginalNode(resultingCall, node); @@ -102239,13 +102683,13 @@ var ts; } } var helpers = emitHelpers(); - var startsWithSpread = segments[0].kind !== 0 /* None */; + var startsWithSpread = segments[0].kind !== 0 /* SpreadSegmentKind.None */; var expression = startsWithSpread ? factory.createArrayLiteralExpression() : segments[0].expression; for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) { var segment = segments[i]; // If this is for an argument list, it doesn't matter if the array is packed or sparse - expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* UnpackedSpread */ && !isArgumentList); + expression = helpers.createSpreadArrayHelper(expression, segment.expression, segment.kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !isArgumentList); } return expression; } @@ -102261,12 +102705,12 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); // We don't need to pack already packed array literals, or existing calls to the `__read` helper. var isCallToReadHelper = ts.isCallToHelper(expression, "___read"); - var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* PackedSpread */ : 1 /* UnpackedSpread */; + var kind = isCallToReadHelper || ts.isPackedArrayLiteral(expression) ? 2 /* SpreadSegmentKind.PackedSpread */ : 1 /* SpreadSegmentKind.UnpackedSpread */; // We don't need the `__read` helper for array literals. Array packing will be performed by `__spreadArray`. - if (compilerOptions.downlevelIteration && kind === 1 /* UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { + if (compilerOptions.downlevelIteration && kind === 1 /* SpreadSegmentKind.UnpackedSpread */ && !ts.isArrayLiteralExpression(expression) && !isCallToReadHelper) { expression = emitHelpers().createReadHelper(expression, /*count*/ undefined); // the `__read` helper returns a packed array, so we don't need to ensure a packed array - kind = 2 /* PackedSpread */; + kind = 2 /* SpreadSegmentKind.PackedSpread */; } return createSpreadSegment(kind, expression); } @@ -102274,7 +102718,7 @@ var ts; var expression = factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine); // We do not pack non-spread segments, this is so that `[1, , ...[2, , 3], , 4]` is properly downleveled to // `[1, , 2, undefined, 3, , 4]`. See the NOTE in `transformAndSpreadElements` - return createSpreadSegment(0 /* None */, expression); + return createSpreadSegment(0 /* SpreadSegmentKind.None */, expression); } function visitSpreadElement(node) { return ts.visitNode(node.expression, visitor, ts.isExpression); @@ -102304,7 +102748,7 @@ var ts; * @param node A string literal. */ function visitNumericLiteral(node) { - if (node.numericLiteralFlags & 384 /* BinaryOrOctalSpecifier */) { + if (node.numericLiteralFlags & 384 /* TokenFlags.BinaryOrOctalSpecifier */) { return ts.setTextRange(factory.createNumericLiteral(node.text), node); } return node; @@ -102339,15 +102783,15 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ + return hierarchyFacts & 8 /* HierarchyFacts.NonStaticClassElement */ && !isExpressionOfCall - ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */), "prototype") - : factory.createUniqueName("_super", 16 /* Optimistic */ | 32 /* FileLevel */); + ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), "prototype") + : factory.createUniqueName("_super", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } function visitMetaProperty(node) { - if (node.keywordToken === 103 /* NewKeyword */ && node.name.escapedText === "target") { - hierarchyFacts |= 32768 /* NewTarget */; - return factory.createUniqueName("_newTarget", 16 /* Optimistic */ | 32 /* FileLevel */); + if (node.keywordToken === 103 /* SyntaxKind.NewKeyword */ && node.name.escapedText === "target") { + hierarchyFacts |= 32768 /* HierarchyFacts.NewTarget */; + return factory.createUniqueName("_newTarget", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); } return node; } @@ -102359,13 +102803,13 @@ var ts; * @param emitCallback The callback used to emit the node. */ function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 /* CapturedThis */ && ts.isFunctionLike(node)) { + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ && ts.isFunctionLike(node)) { // If we are tracking a captured `this`, keep track of the enclosing function. - var ancestorFacts = enterSubtree(32670 /* FunctionExcludes */, ts.getEmitFlags(node) & 8 /* CapturesThis */ - ? 65 /* FunctionIncludes */ | 16 /* CapturesThis */ - : 65 /* FunctionIncludes */); + var ancestorFacts = enterSubtree(32670 /* HierarchyFacts.FunctionExcludes */, ts.getEmitFlags(node) & 8 /* EmitFlags.CapturesThis */ + ? 65 /* HierarchyFacts.FunctionIncludes */ | 16 /* HierarchyFacts.CapturesThis */ + : 65 /* HierarchyFacts.FunctionIncludes */); previousOnEmitNode(hint, node, emitCallback); - exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); + exitSubtree(ancestorFacts, 0 /* HierarchyFacts.None */, 0 /* HierarchyFacts.None */); return; } previousOnEmitNode(hint, node, emitCallback); @@ -102375,9 +102819,9 @@ var ts; * contains block-scoped bindings (e.g. `let` or `const`). */ function enableSubstitutionsForBlockScopedBindings() { - if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { - enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(79 /* Identifier */); + if ((enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */) === 0) { + enabledSubstitutions |= 2 /* ES2015SubstitutionFlags.BlockScopedBindings */; + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } } /** @@ -102385,16 +102829,16 @@ var ts; * contains a captured `this`. */ function enableSubstitutionsForCapturedThis() { - if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { - enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(108 /* ThisKeyword */); - context.enableEmitNotification(171 /* Constructor */); - context.enableEmitNotification(169 /* MethodDeclaration */); - context.enableEmitNotification(172 /* GetAccessor */); - context.enableEmitNotification(173 /* SetAccessor */); - context.enableEmitNotification(214 /* ArrowFunction */); - context.enableEmitNotification(213 /* FunctionExpression */); - context.enableEmitNotification(256 /* FunctionDeclaration */); + if ((enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */) === 0) { + enabledSubstitutions |= 1 /* ES2015SubstitutionFlags.CapturedThis */; + context.enableSubstitution(108 /* SyntaxKind.ThisKeyword */); + context.enableEmitNotification(171 /* SyntaxKind.Constructor */); + context.enableEmitNotification(169 /* SyntaxKind.MethodDeclaration */); + context.enableEmitNotification(172 /* SyntaxKind.GetAccessor */); + context.enableEmitNotification(173 /* SyntaxKind.SetAccessor */); + context.enableEmitNotification(214 /* SyntaxKind.ArrowFunction */); + context.enableEmitNotification(213 /* SyntaxKind.FunctionExpression */); + context.enableEmitNotification(256 /* SyntaxKind.FunctionDeclaration */); } } /** @@ -102405,7 +102849,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } if (ts.isIdentifier(node)) { @@ -102419,7 +102863,7 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return ts.setTextRange(factory.getGeneratedNameForNode(original), node); @@ -102435,10 +102879,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: - case 260 /* EnumDeclaration */: - case 254 /* VariableDeclaration */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -102451,9 +102895,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 108 /* ThisKeyword */: + case 108 /* SyntaxKind.ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -102464,7 +102908,7 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { + if (enabledSubstitutions & 2 /* ES2015SubstitutionFlags.BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node); @@ -102501,9 +102945,9 @@ var ts; * @param node The ThisKeyword node. */ function substituteThisKeyword(node) { - if (enabledSubstitutions & 1 /* CapturedThis */ - && hierarchyFacts & 16 /* CapturesThis */) { - return ts.setTextRange(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */), node); + if (enabledSubstitutions & 1 /* ES2015SubstitutionFlags.CapturedThis */ + && hierarchyFacts & 16 /* HierarchyFacts.CapturesThis */) { + return ts.setTextRange(factory.createUniqueName("_this", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */), node); } return node; } @@ -102520,19 +102964,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 238 /* SyntaxKind.ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 208 /* SyntaxKind.CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 106 /* SyntaxKind.SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 225 /* SyntaxKind.SpreadElement */) { return false; } var expression = callArgument.expression; @@ -102555,18 +102999,18 @@ var ts; // enable emit notification only if using --jsx preserve or react-native var previousOnEmitNode; var noSubstitution; - if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { + if (compilerOptions.jsx === 1 /* JsxEmit.Preserve */ || compilerOptions.jsx === 3 /* JsxEmit.ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(280 /* JsxOpeningElement */); - context.enableEmitNotification(281 /* JsxClosingElement */); - context.enableEmitNotification(279 /* JsxSelfClosingElement */); + context.enableEmitNotification(280 /* SyntaxKind.JsxOpeningElement */); + context.enableEmitNotification(281 /* SyntaxKind.JsxClosingElement */); + context.enableEmitNotification(279 /* SyntaxKind.JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(206 /* PropertyAccessExpression */); - context.enableSubstitution(296 /* PropertyAssignment */); + context.enableSubstitution(206 /* SyntaxKind.PropertyAccessExpression */); + context.enableSubstitution(296 /* SyntaxKind.PropertyAssignment */); return ts.chainBundle(context, transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -102585,9 +103029,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 280 /* JsxOpeningElement */: - case 281 /* JsxClosingElement */: - case 279 /* JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -102647,7 +103091,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 81 /* FirstReservedWord */ && token <= 116 /* LastReservedWord */) { + if (token !== undefined && token >= 81 /* SyntaxKind.FirstReservedWord */ && token <= 116 /* SyntaxKind.LastReservedWord */) { return ts.setTextRange(factory.createStringLiteralFromNode(name), name); } return undefined; @@ -102827,11 +103271,11 @@ var ts; })(Instruction || (Instruction = {})); function getInstructionName(instruction) { switch (instruction) { - case 2 /* Return */: return "return"; - case 3 /* Break */: return "break"; - case 4 /* Yield */: return "yield"; - case 5 /* YieldStar */: return "yield*"; - case 7 /* Endfinally */: return "endfinally"; + case 2 /* Instruction.Return */: return "return"; + case 3 /* Instruction.Break */: return "break"; + case 4 /* Instruction.Yield */: return "yield"; + case 5 /* Instruction.YieldStar */: return "yield*"; + case 7 /* Instruction.Endfinally */: return "endfinally"; default: return undefined; // TODO: GH#18217 } } @@ -102885,7 +103329,7 @@ var ts; var withBlockStack; // A stack containing `with` blocks. return ts.chainBundle(context, transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile || (node.transformFlags & 2048 /* ContainsGenerator */) === 0) { + if (node.isDeclarationFile || (node.transformFlags & 2048 /* TransformFlags.ContainsGenerator */) === 0) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -102908,7 +103352,7 @@ var ts; else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) { return visitGenerator(node); } - else if (transformFlags & 2048 /* ContainsGenerator */) { + else if (transformFlags & 2048 /* TransformFlags.ContainsGenerator */) { return ts.visitEachChild(node, visitor, context); } else { @@ -102922,13 +103366,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -102941,30 +103385,30 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return visitAccessorDeclaration(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return visitBreakStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return visitContinueStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return visitReturnStatement(node); default: - if (node.transformFlags & 1048576 /* ContainsYield */) { + if (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) { return visitJavaScriptContainingYield(node); } - else if (node.transformFlags & (2048 /* ContainsGenerator */ | 4194304 /* ContainsHoistedDeclarationOrCompletion */)) { + else if (node.transformFlags & (2048 /* TransformFlags.ContainsGenerator */ | 4194304 /* TransformFlags.ContainsHoistedDeclarationOrCompletion */)) { return ts.visitEachChild(node, visitor, context); } else { @@ -102979,23 +103423,23 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return visitBinaryExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return visitCommaListExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return visitConditionalExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return visitYieldExpression(node); - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return visitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return visitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -103008,9 +103452,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -103168,13 +103612,13 @@ var ts; * @param node The node to visit. */ function visitVariableStatement(node) { - if (node.transformFlags & 1048576 /* ContainsYield */) { + if (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) { transformAndEmitVariableDeclarationList(node.declarationList); return undefined; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* EmitFlags.CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -103199,9 +103643,9 @@ var ts; function visitBinaryExpression(node) { var assoc = ts.getExpressionAssociativity(node); switch (assoc) { - case 0 /* Left */: + case 0 /* Associativity.Left */: return visitLeftAssociativeBinaryExpression(node); - case 1 /* Right */: + case 1 /* Associativity.Right */: return visitRightAssociativeBinaryExpression(node); default: return ts.Debug.assertNever(assoc); @@ -103217,7 +103661,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: // [source] // a.b = yield; // @@ -103229,7 +103673,7 @@ var ts; // _a.b = %sent%; target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: // [source] // a[b] = yield; // @@ -103261,7 +103705,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 27 /* CommaToken */) { + else if (node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { return visitCommaExpression(node); } // [source] @@ -103295,13 +103739,13 @@ var ts; visit(node.right); return factory.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { visit(node.left); visit(node.right); } else { if (containsYield(node) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression)); @@ -103318,12 +103762,12 @@ var ts; var pendingExpressions = []; for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var elem = _a[_i]; - if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* CommaToken */) { + if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27 /* SyntaxKind.CommaToken */) { pendingExpressions.push(visitCommaExpression(elem)); } else { if (containsYield(elem) && pendingExpressions.length > 0) { - emitWorker(1 /* Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); + emitWorker(1 /* OpCode.Statement */, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]); pendingExpressions = []; } pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression)); @@ -103368,7 +103812,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* SyntaxKind.AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -103434,7 +103878,7 @@ var ts; var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { // NOTE: `expression` must be defined for `yield*`. - var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* EmitFlags.Iterator */) === 0 ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node) : expression; emitYieldStar(iterator, /*location*/ node); @@ -103623,35 +104067,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return transformAndEmitBlock(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return transformAndEmitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return transformAndEmitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return transformAndEmitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return transformAndEmitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return transformAndEmitForInStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return transformAndEmitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return transformAndEmitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return transformAndEmitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return transformAndEmitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return transformAndEmitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -104081,7 +104525,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 290 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 290 /* SyntaxKind.DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -104094,7 +104538,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 289 /* CaseClause */) { + if (clause.kind === 289 /* SyntaxKind.CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -104226,7 +104670,7 @@ var ts; } } function containsYield(node) { - return !!node && (node.transformFlags & 1048576 /* ContainsYield */) !== 0; + return !!node && (node.transformFlags & 1048576 /* TransformFlags.ContainsYield */) !== 0; } function countInitialNodesWithoutYield(nodes) { var numNodes = nodes.length; @@ -104239,7 +104683,7 @@ var ts; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } return node; @@ -104270,7 +104714,7 @@ var ts; return node; } function cacheExpression(node) { - if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return node; } var temp = factory.createTempVariable(hoistVariableDeclaration); @@ -104316,7 +104760,7 @@ var ts; blockStack = []; } var index = blockActions.length; - blockActions[index] = 0 /* Open */; + blockActions[index] = 0 /* BlockAction.Open */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.push(block); @@ -104330,7 +104774,7 @@ var ts; if (block === undefined) return ts.Debug.fail("beginBlock was never called."); var index = blockActions.length; - blockActions[index] = 1 /* Close */; + blockActions[index] = 1 /* BlockAction.Close */; blockOffsets[index] = operations ? operations.length : 0; blocks[index] = block; blockStack.pop(); @@ -104359,7 +104803,7 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 1 /* With */, + kind: 1 /* CodeBlockKind.With */, expression: expression, startLabel: startLabel, endLabel: endLabel @@ -104369,7 +104813,7 @@ var ts; * Ends a code block for a generated `with` statement. */ function endWithBlock() { - ts.Debug.assert(peekBlockKind() === 1 /* With */); + ts.Debug.assert(peekBlockKind() === 1 /* CodeBlockKind.With */); var block = endBlock(); markLabel(block.endLabel); } @@ -104381,8 +104825,8 @@ var ts; var endLabel = defineLabel(); markLabel(startLabel); beginBlock({ - kind: 0 /* Exception */, - state: 0 /* Try */, + kind: 0 /* CodeBlockKind.Exception */, + state: 0 /* ExceptionBlockState.Try */, startLabel: startLabel, endLabel: endLabel }); @@ -104395,7 +104839,7 @@ var ts; * @param variable The catch variable. */ function beginCatchBlock(variable) { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); // generated identifiers should already be unique within a file var name; if (ts.isGeneratedIdentifier(variable.name)) { @@ -104408,18 +104852,18 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = new ts.Map(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(79 /* Identifier */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } var exception = peekBlock(); - ts.Debug.assert(exception.state < 1 /* Catch */); + ts.Debug.assert(exception.state < 1 /* ExceptionBlockState.Catch */); var endLabel = exception.endLabel; emitBreak(endLabel); var catchLabel = defineLabel(); markLabel(catchLabel); - exception.state = 1 /* Catch */; + exception.state = 1 /* ExceptionBlockState.Catch */; exception.catchVariable = name; exception.catchLabel = catchLabel; emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), /*typeArguments*/ undefined, [])); @@ -104429,24 +104873,24 @@ var ts; * Enters the `finally` block of a generated `try` statement. */ function beginFinallyBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = peekBlock(); - ts.Debug.assert(exception.state < 2 /* Finally */); + ts.Debug.assert(exception.state < 2 /* ExceptionBlockState.Finally */); var endLabel = exception.endLabel; emitBreak(endLabel); var finallyLabel = defineLabel(); markLabel(finallyLabel); - exception.state = 2 /* Finally */; + exception.state = 2 /* ExceptionBlockState.Finally */; exception.finallyLabel = finallyLabel; } /** * Ends the code block for a generated `try` statement. */ function endExceptionBlock() { - ts.Debug.assert(peekBlockKind() === 0 /* Exception */); + ts.Debug.assert(peekBlockKind() === 0 /* CodeBlockKind.Exception */); var exception = endBlock(); var state = exception.state; - if (state < 2 /* Finally */) { + if (state < 2 /* ExceptionBlockState.Finally */) { emitBreak(exception.endLabel); } else { @@ -104454,7 +104898,7 @@ var ts; } markLabel(exception.endLabel); emitNop(); - exception.state = 3 /* Done */; + exception.state = 3 /* ExceptionBlockState.Done */; } /** * Begins a code block that supports `break` or `continue` statements that are defined in @@ -104464,7 +104908,7 @@ var ts; */ function beginScriptLoopBlock() { beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: true, breakLabel: -1, continueLabel: -1 @@ -104481,7 +104925,7 @@ var ts; function beginLoopBlock(continueLabel) { var breakLabel = defineLabel(); beginBlock({ - kind: 3 /* Loop */, + kind: 3 /* CodeBlockKind.Loop */, isScript: false, breakLabel: breakLabel, continueLabel: continueLabel, @@ -104493,7 +104937,7 @@ var ts; * generated code or in the source tree. */ function endLoopBlock() { - ts.Debug.assert(peekBlockKind() === 3 /* Loop */); + ts.Debug.assert(peekBlockKind() === 3 /* CodeBlockKind.Loop */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -104507,7 +104951,7 @@ var ts; */ function beginScriptSwitchBlock() { beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: true, breakLabel: -1 }); @@ -104520,7 +104964,7 @@ var ts; function beginSwitchBlock() { var breakLabel = defineLabel(); beginBlock({ - kind: 2 /* Switch */, + kind: 2 /* CodeBlockKind.Switch */, isScript: false, breakLabel: breakLabel, }); @@ -104530,7 +104974,7 @@ var ts; * Ends a code block that supports `break` statements that are defined in generated code. */ function endSwitchBlock() { - ts.Debug.assert(peekBlockKind() === 2 /* Switch */); + ts.Debug.assert(peekBlockKind() === 2 /* CodeBlockKind.Switch */); var block = endBlock(); var breakLabel = block.breakLabel; if (!block.isScript) { @@ -104539,7 +104983,7 @@ var ts; } function beginScriptLabeledBlock(labelText) { beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: true, labelText: labelText, breakLabel: -1 @@ -104548,14 +104992,14 @@ var ts; function beginLabeledBlock(labelText) { var breakLabel = defineLabel(); beginBlock({ - kind: 4 /* Labeled */, + kind: 4 /* CodeBlockKind.Labeled */, isScript: false, labelText: labelText, breakLabel: breakLabel }); } function endLabeledBlock() { - ts.Debug.assert(peekBlockKind() === 4 /* Labeled */); + ts.Debug.assert(peekBlockKind() === 4 /* CodeBlockKind.Labeled */); var block = endBlock(); if (!block.isScript) { markLabel(block.breakLabel); @@ -104567,8 +105011,8 @@ var ts; * @param block A code block. */ function supportsUnlabeledBreak(block) { - return block.kind === 2 /* Switch */ - || block.kind === 3 /* Loop */; + return block.kind === 2 /* CodeBlockKind.Switch */ + || block.kind === 3 /* CodeBlockKind.Loop */; } /** * Indicates whether the provided block supports `break` statements with labels. @@ -104576,7 +105020,7 @@ var ts; * @param block A code block. */ function supportsLabeledBreakOrContinue(block) { - return block.kind === 4 /* Labeled */; + return block.kind === 4 /* CodeBlockKind.Labeled */; } /** * Indicates whether the provided block supports `continue` statements. @@ -104584,7 +105028,7 @@ var ts; * @param block A code block. */ function supportsUnlabeledContinue(block) { - return block.kind === 3 /* Loop */; + return block.kind === 3 /* CodeBlockKind.Loop */; } function hasImmediateContainingLabeledBlock(labelText, start) { for (var j = start; j >= 0; j--) { @@ -104681,7 +105125,7 @@ var ts; */ function createInstruction(instruction) { var literal = factory.createNumericLiteral(instruction); - ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); + ts.addSyntheticTrailingComment(literal, 3 /* SyntaxKind.MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -104693,7 +105137,7 @@ var ts; function createInlineBreak(label, location) { ts.Debug.assertLessThan(0, label, "Invalid label"); return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) ])), location); } @@ -104705,8 +105149,8 @@ var ts; */ function createInlineReturn(expression, location) { return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), location); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), location); } /** * Creates an expression that can be used to resume from a Yield operation. @@ -104719,7 +105163,7 @@ var ts; * Emits an empty instruction. */ function emitNop() { - emitWorker(0 /* Nop */); + emitWorker(0 /* OpCode.Nop */); } /** * Emits a Statement. @@ -104728,7 +105172,7 @@ var ts; */ function emitStatement(node) { if (node) { - emitWorker(1 /* Statement */, [node]); + emitWorker(1 /* OpCode.Statement */, [node]); } else { emitNop(); @@ -104742,7 +105186,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitAssignment(left, right, location) { - emitWorker(2 /* Assign */, [left, right], location); + emitWorker(2 /* OpCode.Assign */, [left, right], location); } /** * Emits a Break operation to the specified label. @@ -104751,7 +105195,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreak(label, location) { - emitWorker(3 /* Break */, [label], location); + emitWorker(3 /* OpCode.Break */, [label], location); } /** * Emits a Break operation to the specified label when a condition evaluates to a truthy @@ -104762,7 +105206,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenTrue(label, condition, location) { - emitWorker(4 /* BreakWhenTrue */, [label, condition], location); + emitWorker(4 /* OpCode.BreakWhenTrue */, [label, condition], location); } /** * Emits a Break to the specified label when a condition evaluates to a falsey value at @@ -104773,7 +105217,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitBreakWhenFalse(label, condition, location) { - emitWorker(5 /* BreakWhenFalse */, [label, condition], location); + emitWorker(5 /* OpCode.BreakWhenFalse */, [label, condition], location); } /** * Emits a YieldStar operation for the provided expression. @@ -104782,7 +105226,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYieldStar(expression, location) { - emitWorker(7 /* YieldStar */, [expression], location); + emitWorker(7 /* OpCode.YieldStar */, [expression], location); } /** * Emits a Yield operation for the provided expression. @@ -104791,7 +105235,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitYield(expression, location) { - emitWorker(6 /* Yield */, [expression], location); + emitWorker(6 /* OpCode.Yield */, [expression], location); } /** * Emits a Return operation for the provided expression. @@ -104800,7 +105244,7 @@ var ts; * @param location An optional source map location for the assignment. */ function emitReturn(expression, location) { - emitWorker(8 /* Return */, [expression], location); + emitWorker(8 /* OpCode.Return */, [expression], location); } /** * Emits a Throw operation for the provided expression. @@ -104809,13 +105253,13 @@ var ts; * @param location An optional source map location for the assignment. */ function emitThrow(expression, location) { - emitWorker(9 /* Throw */, [expression], location); + emitWorker(9 /* OpCode.Throw */, [expression], location); } /** * Emits an Endfinally operation. This is used to handle `finally` block semantics. */ function emitEndfinally() { - emitWorker(10 /* Endfinally */); + emitWorker(10 /* OpCode.Endfinally */); } /** * Emits an operation. @@ -104859,7 +105303,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, factory.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* EmitFlags.ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -105032,8 +105476,8 @@ var ts; var block = blocks[blockIndex]; var blockAction = blockActions[blockIndex]; switch (block.kind) { - case 0 /* Exception */: - if (blockAction === 0 /* Open */) { + case 0 /* CodeBlockKind.Exception */: + if (blockAction === 0 /* BlockAction.Open */) { if (!exceptionBlockStack) { exceptionBlockStack = []; } @@ -105043,18 +105487,18 @@ var ts; exceptionBlockStack.push(currentExceptionBlock); currentExceptionBlock = block; } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { currentExceptionBlock = exceptionBlockStack.pop(); } break; - case 1 /* With */: - if (blockAction === 0 /* Open */) { + case 1 /* CodeBlockKind.With */: + if (blockAction === 0 /* BlockAction.Open */) { if (!withBlockStack) { withBlockStack = []; } withBlockStack.push(block); } - else if (blockAction === 1 /* Close */) { + else if (blockAction === 1 /* BlockAction.Close */) { withBlockStack.pop(); } break; @@ -105078,33 +105522,33 @@ var ts; lastOperationWasAbrupt = false; lastOperationWasCompletion = false; var opcode = operations[operationIndex]; - if (opcode === 0 /* Nop */) { + if (opcode === 0 /* OpCode.Nop */) { return; } - else if (opcode === 10 /* Endfinally */) { + else if (opcode === 10 /* OpCode.Endfinally */) { return writeEndfinally(); } var args = operationArguments[operationIndex]; - if (opcode === 1 /* Statement */) { + if (opcode === 1 /* OpCode.Statement */) { return writeStatement(args[0]); } var location = operationLocations[operationIndex]; switch (opcode) { - case 2 /* Assign */: + case 2 /* OpCode.Assign */: return writeAssign(args[0], args[1], location); - case 3 /* Break */: + case 3 /* OpCode.Break */: return writeBreak(args[0], location); - case 4 /* BreakWhenTrue */: + case 4 /* OpCode.BreakWhenTrue */: return writeBreakWhenTrue(args[0], args[1], location); - case 5 /* BreakWhenFalse */: + case 5 /* OpCode.BreakWhenFalse */: return writeBreakWhenFalse(args[0], args[1], location); - case 6 /* Yield */: + case 6 /* OpCode.Yield */: return writeYield(args[0], location); - case 7 /* YieldStar */: + case 7 /* OpCode.YieldStar */: return writeYieldStar(args[0], location); - case 8 /* Return */: + case 8 /* OpCode.Return */: return writeReturn(args[0], location); - case 9 /* Throw */: + case 9 /* OpCode.Throw */: return writeThrow(args[0], location); } } @@ -105154,8 +105598,8 @@ var ts; lastOperationWasAbrupt = true; lastOperationWasCompletion = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(2 /* Return */), expression] - : [createInstruction(2 /* Return */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(2 /* Instruction.Return */), expression] + : [createInstruction(2 /* Instruction.Return */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a Break operation to the current label's statement list. @@ -105166,9 +105610,9 @@ var ts; function writeBreak(label, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a BreakWhenTrue operation to the current label's statement list. @@ -105179,9 +105623,9 @@ var ts; */ function writeBreakWhenTrue(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a BreakWhenFalse operation to the current label's statement list. @@ -105192,9 +105636,9 @@ var ts; */ function writeBreakWhenFalse(label, condition, operationLocation) { writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(3 /* Break */), + createInstruction(3 /* Instruction.Break */), createLabel(label) - ])), operationLocation), 384 /* NoTokenSourceMaps */)), 1 /* SingleLine */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)), 1 /* EmitFlags.SingleLine */)); } /** * Writes a Yield operation to the current label's statement list. @@ -105205,8 +105649,8 @@ var ts; function writeYield(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression - ? [createInstruction(4 /* Yield */), expression] - : [createInstruction(4 /* Yield */)])), operationLocation), 384 /* NoTokenSourceMaps */)); + ? [createInstruction(4 /* Instruction.Yield */), expression] + : [createInstruction(4 /* Instruction.Yield */)])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes a YieldStar instruction to the current label's statement list. @@ -105217,9 +105661,9 @@ var ts; function writeYieldStar(expression, operationLocation) { lastOperationWasAbrupt = true; writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(5 /* YieldStar */), + createInstruction(5 /* Instruction.YieldStar */), expression - ])), operationLocation), 384 /* NoTokenSourceMaps */)); + ])), operationLocation), 384 /* EmitFlags.NoTokenSourceMaps */)); } /** * Writes an Endfinally instruction to the current label's statement list. @@ -105227,7 +105671,7 @@ var ts; function writeEndfinally() { lastOperationWasAbrupt = true; writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([ - createInstruction(7 /* Endfinally */) + createInstruction(7 /* Instruction.Endfinally */) ]))); } } @@ -105254,12 +105698,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(208 /* CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(210 /* TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(208 /* SyntaxKind.CallExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(210 /* SyntaxKind.TaggedTemplateExpression */); // Substitute calls to imported/exported symbols to avoid incorrect `this`. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -105275,7 +105719,7 @@ var ts; function transformSourceFile(node) { if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || - node.transformFlags & 8388608 /* ContainsDynamicImport */ || + node.transformFlags & 8388608 /* TransformFlags.ContainsDynamicImport */ || (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) { return node; } @@ -105411,7 +105855,7 @@ var ts; factory.createIdentifier("exports") ])) ]), - ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(factory.createStrictInequality(factory.createIdentifier("v"), factory.createIdentifier("undefined")), factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), factory.createIdentifier("v")))), 1 /* EmitFlags.SingleLine */) ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([ factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), /*typeArguments*/ undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : []), true), [ @@ -105496,7 +105940,7 @@ var ts; if (includeNonAmdDependencies && importAliasName) { // Set emitFlags on the name of the classDeclaration // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + ts.setEmitFlags(importAliasName, 4 /* EmitFlags.NoSubstitution */); aliasedModuleNames.push(externalModuleName); importAliasNames.push(factory.createParameterDeclaration(/*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } @@ -105565,13 +106009,13 @@ var ts; if (emitAsReturn) { var statement = factory.createReturnStatement(expressionResult); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + ts.setEmitFlags(statement, 384 /* EmitFlags.NoTokenSourceMaps */ | 1536 /* EmitFlags.NoComments */); statements.push(statement); } else { var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult)); ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); statements.push(statement); } } @@ -105587,23 +106031,23 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -105612,30 +106056,30 @@ var ts; function visitorWorker(node, valueIsDiscarded) { // This visitor does not need to descend into the tree if there is no dynamic import, destructuring assignment, or update expression // as export/import statements are only transformed at the top level of a file. - if (!(node.transformFlags & (8388608 /* ContainsDynamicImport */ | 4096 /* ContainsDestructuringAssignment */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (8388608 /* TransformFlags.ContainsDynamicImport */ | 4096 /* TransformFlags.ContainsDestructuringAssignment */ | 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } break; - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPreOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -105651,24 +106095,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -105694,7 +106138,7 @@ var ts; } function visitDestructuringAssignment(node, valueIsDiscarded) { if (destructuringNeedsFlattening(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded, createAllExportExpressions); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded, createAllExportExpressions); } return ts.visitEachChild(node, visitor, context); } @@ -105720,7 +106164,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -105763,7 +106207,7 @@ var ts; var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), visitor); // Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output. var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument; - var containsLexicalThis = !!(node.transformFlags & 16384 /* ContainsLexicalThis */); + var containsLexicalThis = !!(node.transformFlags & 16384 /* TransformFlags.ContainsLexicalThis */); switch (compilerOptions.module) { case ts.ModuleKind.AMD: return createImportCallExpressionAMD(argument, containsLexicalThis); @@ -105790,7 +106234,7 @@ var ts; // }); needUMDDynamicImportHelper = true; if (ts.isSimpleCopiableExpression(arg)) { - var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* NoComments */); + var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536 /* EmitFlags.NoComments */); return factory.createConditionalExpression( /*condition*/ factory.createIdentifier("__syncRequire"), /*questionToken*/ undefined, @@ -105826,7 +106270,7 @@ var ts; /*typeArguments*/ undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject])) ]); var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, parameters, @@ -105844,7 +106288,7 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } var promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); @@ -105865,7 +106309,7 @@ var ts; requireCall = emitHelpers().createImportStarHelper(requireCall); } var func; - if (languageVersion >= 2 /* ES2015 */) { + if (languageVersion >= 2 /* ScriptTarget.ES2015 */) { func = factory.createArrowFunction( /*modifiers*/ undefined, /*typeParameters*/ undefined, @@ -105885,13 +106329,13 @@ var ts; // that this new function expression indicates it captures 'this' so that the // es2015 transformer will properly substitute 'this' with '_this'. if (containsLexicalThis) { - ts.setEmitFlags(func, 8 /* CapturesThis */); + ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */); } } return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]); } function getHelperExpressionForExport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getExportNeedsImportStarHelper(node)) { @@ -105900,7 +106344,7 @@ var ts; return innerExpr; } function getHelperExpressionForImport(node, innerExpr) { - if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) { + if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) { return innerExpr; } if (ts.getImportNeedsImportStarHelper(node)) { @@ -105947,7 +106391,7 @@ var ts; } } statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), + /*modifiers*/ undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), /*location*/ node), /*original*/ node)); } @@ -105961,7 +106405,7 @@ var ts; /*type*/ undefined, factory.getGeneratedNameForNode(node)), /*location*/ node), /*original*/ node) - ], languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */))); + ], languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */))); } if (hasAssociatedEndOfDeclarationMarker(node)) { // Defer exports until we encounter an EndOfDeclarationMarker node @@ -105995,7 +106439,7 @@ var ts; ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); var statements; if (moduleKind !== ts.ModuleKind.AMD) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node)); } else { @@ -106005,11 +106449,11 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); } } else { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node)); } } @@ -106050,12 +106494,12 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createCreateBindingHelper(generatedName, factory.createStringLiteralFromNode(specifier.propertyName || specifier.name), specifier.propertyName ? factory.createStringLiteralFromNode(specifier.name) : undefined)), specifier), specifier)); } else { var exportNeedsImportDefault = !!ts.getESModuleInterop(compilerOptions) && - !(ts.getEmitFlags(node) & 67108864 /* NeverApplyImportHelper */) && + !(ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) && ts.idText(specifier.propertyName || specifier.name) === "default"; var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name); statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); @@ -106106,7 +106550,7 @@ var ts; */ function visitFunctionDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createFunctionDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor), /*type*/ undefined, ts.visitEachChild(node.body, visitor, context)), @@ -106133,7 +106577,7 @@ var ts; */ function visitClassDeclaration(node) { var statements; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createClassDeclaration(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor), ts.visitNodes(node.members, visitor)), node), node)); } @@ -106159,7 +106603,7 @@ var ts; var statements; var variables; var expressions; - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { var modifiers = void 0; var removeCommentsOnExpressions = false; // If we're exporting these variables, then these just become assignments to 'exports.x'. @@ -106217,7 +106661,7 @@ var ts; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; // Mark the node to prevent triggering substitution. - ts.setEmitFlags(expression, 4 /* NoSubstitution */); + ts.setEmitFlags(expression, 4 /* EmitFlags.NoSubstitution */); expression = createExportExpression(exportName, expression, /*location*/ location); } return expression; @@ -106232,7 +106676,7 @@ var ts; function transformInitializedVariable(node) { if (ts.isBindingPattern(node.name)) { return ts.flattenDestructuringAssignment(ts.visitNode(node, visitor), - /*visitor*/ undefined, context, 0 /* All */, + /*visitor*/ undefined, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAllExportExpressions); } else { @@ -106254,7 +106698,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -106266,7 +106710,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -106309,10 +106753,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); @@ -106395,8 +106839,8 @@ var ts; if (currentModuleInfo.exportEquals) { return statements; } - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -106441,7 +106885,7 @@ var ts; } function createUnderscoreUnderscoreESModule() { var statement; - if (languageVersion === 0 /* ES3 */) { + if (languageVersion === 0 /* ScriptTarget.ES3 */) { statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue())); } else { @@ -106454,7 +106898,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); return statement; } /** @@ -106469,7 +106913,7 @@ var ts; var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -106481,7 +106925,7 @@ var ts; * @param location The location to use for source maps and comments for the export. */ function createExportExpression(name, value, location, liveBinding) { - return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), + return ts.setTextRange(liveBinding && languageVersion !== 0 /* ScriptTarget.ES3 */ ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ factory.createIdentifier("exports"), factory.createStringLiteralFromNode(name), @@ -106508,8 +106952,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -106525,7 +106969,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; previousOnEmitNode(hint, node, emitCallback); @@ -106550,7 +106994,7 @@ var ts; if (node.id && noSubstitution[node.id]) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } else if (ts.isShorthandPropertyAssignment(node)) { @@ -106585,13 +107029,13 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return substituteCallExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return substituteTaggedTemplateExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); } return node; @@ -106600,9 +107044,9 @@ var ts; if (ts.isIdentifier(node.expression)) { var expression = substituteExpressionIdentifier(node.expression); noSubstitution[ts.getNodeId(expression)] = true; - if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(expression) && !(ts.getEmitFlags(node.expression) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateCallExpression(node, expression, - /*typeArguments*/ undefined, node.arguments), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.arguments), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -106611,9 +107055,9 @@ var ts; if (ts.isIdentifier(node.tag)) { var tag = substituteExpressionIdentifier(node.tag); noSubstitution[ts.getNodeId(tag)] = true; - if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* HelperName */)) { + if (!ts.isIdentifier(tag) && !(ts.getEmitFlags(node.tag) & 4096 /* EmitFlags.HelperName */)) { return ts.addEmitFlags(factory.updateTaggedTemplateExpression(node, tag, - /*typeArguments*/ undefined, node.template), 536870912 /* IndirectCall */); + /*typeArguments*/ undefined, node.template), 536870912 /* EmitFlags.IndirectCall */); } } return node; @@ -106626,16 +107070,16 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); } return node; } - else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* AllowNameSubstitution */)) && !ts.isLocalName(node)) { + else if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64 /* GeneratedIdentifierFlags.AllowNameSubstitution */)) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), /*location*/ node); } @@ -106724,11 +107168,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(79 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(297 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(221 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(231 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(305 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(79 /* SyntaxKind.Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(297 /* SyntaxKind.ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(221 /* SyntaxKind.BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(231 /* SyntaxKind.MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -106748,7 +107192,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* ContainsDynamicImport */)) { + if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 8388608 /* TransformFlags.ContainsDynamicImport */)) { return node; } var id = ts.getOriginalNodeId(node); @@ -106795,7 +107239,7 @@ var ts; /*typeArguments*/ undefined, moduleName ? [moduleName, dependencies, moduleBodyFunction] : [dependencies, moduleBodyFunction])) - ]), node.statements)), 1024 /* NoTrailingComments */); + ]), node.statements)), 1024 /* EmitFlags.NoTrailingComments */); if (!ts.outFile(compilerOptions)) { ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; }); } @@ -106917,8 +107361,8 @@ var ts; // - Temporary variables will appear at the top rather than at the bottom of the file ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var exportStarFunction = addExportStarIfNeeded(statements); // TODO: GH#18217 - var modifiers = node.transformFlags & 2097152 /* ContainsAwait */ ? - factory.createModifiersFromModifierFlags(256 /* Async */) : + var modifiers = node.transformFlags & 2097152 /* TransformFlags.ContainsAwait */ ? + factory.createModifiersFromModifierFlags(256 /* ModifierFlags.Async */) : undefined; var moduleObject = factory.createObjectLiteralExpression([ factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)), @@ -106952,7 +107396,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 272 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 272 /* SyntaxKind.ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -107017,7 +107461,7 @@ var ts; factory.createForInStatement(factory.createVariableDeclarationList([ factory.createVariableDeclaration(n) ]), m, factory.createBlock([ - ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* SingleLine */) + ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1 /* EmitFlags.SingleLine */) ])), factory.createExpressionStatement(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exports])) @@ -107041,19 +107485,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName))); break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { if (ts.isNamedExports(entry.exportClause)) { @@ -107112,13 +107556,13 @@ var ts; */ function topLevelVisitor(node) { switch (node.kind) { - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return visitImportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return visitExportDeclaration(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); default: return topLevelNestedVisitor(node); @@ -107194,7 +107638,7 @@ var ts; * @param node The node to visit. */ function visitFunctionDeclaration(node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { hoistedStatements = ts.append(hoistedStatements, factory.updateFunctionDeclaration(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifierLike), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, visitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, visitor, ts.isBlock))); @@ -107246,7 +107690,7 @@ var ts; return ts.visitNode(node, visitor, ts.isStatement); } var expressions; - var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */); var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node); for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; @@ -107296,9 +107740,9 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 305 /* SourceFile */ - || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); + return (ts.getEmitFlags(node) & 2097152 /* EmitFlags.NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 305 /* SyntaxKind.SourceFile */ + || (ts.getOriginalNode(node).flags & 3 /* NodeFlags.BlockScoped */) === 0); } /** * Transform an initialized variable declaration into an expression. @@ -107309,7 +107753,7 @@ var ts; function transformInitializedVariable(node, isExportedDeclaration) { var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment; return ts.isBindingPattern(node.name) - ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, + ? ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, /*needsValue*/ false, createAssignment) : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, visitor, ts.isExpression)) : node.name; } @@ -107361,9 +107805,9 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 237 /* SyntaxKind.VariableStatement */) { var id = ts.getOriginalNodeId(node); - var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* Export */); + var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1 /* ModifierFlags.Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); } return node; @@ -107374,7 +107818,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* EmitFlags.HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -107423,10 +107867,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -107520,8 +107964,8 @@ var ts; return statements; } var excludeName; - if (ts.hasSyntacticModifier(decl, 1 /* Export */)) { - var exportName = ts.hasSyntacticModifier(decl, 512 /* Default */) ? factory.createStringLiteral("default") : decl.name; + if (ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */)) { + var exportName = ts.hasSyntacticModifier(decl, 512 /* ModifierFlags.Default */) ? factory.createStringLiteral("default") : decl.name; statements = appendExportStatement(statements, exportName, factory.getLocalName(decl)); excludeName = ts.getTextOfIdentifierOrLiteral(exportName); } @@ -107581,7 +108025,7 @@ var ts; var statement = factory.createExpressionStatement(createExportExpression(name, value)); ts.startOnNewLine(statement); if (!allowComments) { - ts.setEmitFlags(statement, 1536 /* NoComments */); + ts.setEmitFlags(statement, 1536 /* EmitFlags.NoComments */); } return statement; } @@ -107593,7 +108037,7 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name; - ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* EmitFlags.NoComments */); return ts.setCommentRange(factory.createCallExpression(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // @@ -107606,43 +108050,43 @@ var ts; */ function topLevelNestedVisitor(node) { switch (node.kind) { - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return visitVariableStatement(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return visitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return visitClassDeclaration(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ true); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return visitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return visitForOfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return visitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return visitWhileStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return visitLabeledStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return visitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return visitSwitchStatement(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return visitCaseBlock(node); - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return visitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return visitDefaultClause(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return visitTryStatement(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return visitCatchClause(node); - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return visitBlock(node); - case 352 /* MergeDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 353 /* EndOfDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return visitor(node); @@ -107824,30 +108268,30 @@ var ts; * @param node The node to visit. */ function visitorWorker(node, valueIsDiscarded) { - if (!(node.transformFlags & (4096 /* ContainsDestructuringAssignment */ | 8388608 /* ContainsDynamicImport */ | 268435456 /* ContainsUpdateExpressionForIdentifier */))) { + if (!(node.transformFlags & (4096 /* TransformFlags.ContainsDestructuringAssignment */ | 8388608 /* TransformFlags.ContainsDynamicImport */ | 268435456 /* TransformFlags.ContainsUpdateExpressionForIdentifier */))) { return node; } switch (node.kind) { - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return visitForStatement(node, /*isTopLevel*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return visitExpressionStatement(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return visitParenthesizedExpression(node, valueIsDiscarded); - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return visitPartiallyEmittedExpression(node, valueIsDiscarded); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: if (ts.isDestructuringAssignment(node)) { return visitDestructuringAssignment(node, valueIsDiscarded); } break; - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: if (ts.isImportCall(node)) { return visitImportCallExpression(node); } break; - case 219 /* PrefixUnaryExpression */: - case 220 /* PostfixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return visitPrefixOrPostfixUnaryExpression(node, valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); @@ -107897,7 +108341,7 @@ var ts; */ function visitDestructuringAssignment(node, valueIsDiscarded) { if (hasExportedReferenceInDestructuringTarget(node.left)) { - return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* All */, !valueIsDiscarded); + return ts.flattenDestructuringAssignment(node, visitor, context, 0 /* FlattenLevel.All */, !valueIsDiscarded); } return ts.visitEachChild(node, visitor, context); } @@ -107927,7 +108371,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 305 /* SourceFile */; + return container !== undefined && container.kind === 305 /* SyntaxKind.SourceFile */; } else { return false; @@ -107943,7 +108387,7 @@ var ts; // - We do not transform identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only transform identifiers that are exported at the top level. - if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) + if ((node.operator === 45 /* SyntaxKind.PlusPlusToken */ || node.operator === 46 /* SyntaxKind.MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) @@ -107988,8 +108432,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: return undefined; } return node; @@ -108005,7 +108449,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 305 /* SourceFile */) { + if (node.kind === 305 /* SyntaxKind.SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -108040,10 +108484,10 @@ var ts; if (isSubstitutionPrevented(node)) { return node; } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { return substituteExpression(node); } - else if (hint === 4 /* Unspecified */) { + else if (hint === 4 /* EmitHint.Unspecified */) { return substituteUnspecified(node); } return node; @@ -108055,7 +108499,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -108090,11 +108534,11 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return substituteExpressionIdentifier(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return substituteBinaryExpression(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return substituteMetaProperty(node); } return node; @@ -108106,7 +108550,7 @@ var ts; */ function substituteExpressionIdentifier(node) { var _a, _b; - if (ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile); if (externalHelpersModuleName) { return factory.createPropertyAccessExpression(externalHelpersModuleName, node); @@ -108184,7 +108628,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 305 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 305 /* SyntaxKind.SourceFile */) { exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -108227,8 +108671,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(305 /* SourceFile */); - context.enableSubstitution(79 /* Identifier */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); + context.enableSubstitution(79 /* SyntaxKind.Identifier */); var helperNameSubstitutions; var currentSourceFile; var importRequireStatements; @@ -108267,14 +108711,14 @@ var ts; } function visitor(node) { switch (node.kind) { - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` // is available, just because the output is reasonable for a node-like runtime. return ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.Node16 ? visitImportEqualsDeclaration(node) : undefined; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return visitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: var exportDecl = node; return visitExportDeclaration(exportDecl); } @@ -108292,23 +108736,23 @@ var ts; args.push(moduleName); } if (!importRequireStatements) { - var createRequireName = factory.createUniqueName("_createRequire", 16 /* Optimistic */ | 32 /* FileLevel */); + var createRequireName = factory.createUniqueName("_createRequire", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var importStatement = factory.createImportDeclaration( /*modifiers*/ undefined, factory.createImportClause( /*isTypeOnly*/ false, /*name*/ undefined, factory.createNamedImports([ factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName) ])), factory.createStringLiteral("module")); - var requireHelperName = factory.createUniqueName("__require", 16 /* Optimistic */ | 32 /* FileLevel */); + var requireHelperName = factory.createUniqueName("__require", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */); var requireStatement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList([ factory.createVariableDeclaration(requireHelperName, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ - factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) + factory.createPropertyAccessExpression(factory.createMetaProperty(100 /* SyntaxKind.ImportKeyword */, factory.createIdentifier("meta")), factory.createIdentifier("url")) ])) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)); importRequireStatements = [importStatement, requireStatement]; } var name = importRequireStatements[1].declarationList.declarations[0].name; @@ -108329,12 +108773,12 @@ var ts; /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(node)) ], - /*flags*/ languageVersion >= 2 /* ES2015 */ ? 2 /* Const */ : 0 /* None */)), node), node)); + /*flags*/ languageVersion >= 2 /* ScriptTarget.ES2015 */ ? 2 /* NodeFlags.Const */ : 0 /* NodeFlags.None */)), node), node)); statements = appendExportsOfImportEqualsDeclaration(statements, node); return ts.singleOrMany(statements); } function appendExportsOfImportEqualsDeclaration(statements, node) { - if (ts.hasSyntacticModifier(node, 1 /* Export */)) { + if (ts.hasSyntacticModifier(node, 1 /* ModifierFlags.Export */)) { statements = ts.append(statements, factory.createExportDeclaration( /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, ts.idText(node.name))]))); } @@ -108399,7 +108843,7 @@ var ts; */ function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); - if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* HelperName */) { + if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096 /* EmitFlags.HelperName */) { return substituteHelperName(node); } return node; @@ -108408,7 +108852,7 @@ var ts; var name = ts.idText(node); var substitution = helperNameSubstitutions.get(name); if (!substitution) { - helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* Optimistic */ | 32 /* FileLevel */)); + helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */)); } return substitution; } @@ -108431,8 +108875,8 @@ var ts; var cjsOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(305 /* SourceFile */); - context.enableEmitNotification(305 /* SourceFile */); + context.enableSubstitution(305 /* SyntaxKind.SourceFile */); + context.enableEmitNotification(305 /* SyntaxKind.SourceFile */); var currentSourceFile; return transformSourceFileOrBundle; function onSubstituteNode(hint, node) { @@ -108479,7 +108923,7 @@ var ts; return result; } function transformSourceFileOrBundle(node) { - return node.kind === 305 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 305 /* SyntaxKind.SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -108534,14 +108978,14 @@ var ts; function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -108563,14 +109007,14 @@ var ts; function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) { if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1; @@ -108594,7 +109038,7 @@ var ts; return getReturnTypeVisibilityError; } else if (ts.isParameter(node)) { - if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* Private */)) { + if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */)) { return getVariableDeclarationTypeVisibilityError; } return getParameterDeclarationTypeVisibilityError; @@ -108612,31 +109056,31 @@ var ts; return getTypeAliasDeclarationVisibilityError; } else { - return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind)); + return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(node.kind))); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 167 /* PropertyDeclaration */ || node.kind === 206 /* PropertyAccessExpression */ || node.kind === 166 /* PropertySignature */ || - (node.kind === 164 /* Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 167 /* SyntaxKind.PropertyDeclaration */ || node.kind === 206 /* SyntaxKind.PropertyAccessExpression */ || node.kind === 166 /* SyntaxKind.PropertySignature */ || + (node.kind === 164 /* SyntaxKind.Parameter */ && ts.hasSyntacticModifier(node.parent, 8 /* ModifierFlags.Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.isStatic(node)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 257 /* ClassDeclaration */ || node.kind === 164 /* Parameter */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */ || node.kind === 164 /* SyntaxKind.Parameter */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; @@ -108659,7 +109103,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.isStatic(node)) { @@ -108676,14 +109120,14 @@ var ts; else { if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1; @@ -108698,36 +109142,36 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; @@ -108739,9 +109183,9 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; @@ -108764,40 +109208,40 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 175 /* ConstructSignature */: - case 180 /* ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; @@ -108808,61 +109252,61 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 256 /* FunctionDeclaration */: - case 179 /* FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; - case 173 /* SetAccessor */: - case 172 /* GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: return symbolAccessibilityResult.errorModuleName ? - symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + symbolAccessibilityResult.accessibility === 2 /* SymbolAccessibility.CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: - return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind)); + return ts.Debug.fail("Unknown parent for parameter: ".concat(ts.Debug.formatSyntaxKind(node.parent.kind))); } } function getTypeParameterConstraintVisibilityError() { // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 180 /* ConstructorType */: - case 175 /* ConstructSignature */: + case 180 /* SyntaxKind.ConstructorType */: + case 175 /* SyntaxKind.ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 169 /* MethodDeclaration */: - case 168 /* MethodSignature */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: if (ts.isStatic(node.parent)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 257 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 257 /* SyntaxKind.ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 179 /* FunctionType */: - case 256 /* FunctionDeclaration */: + case 179 /* SyntaxKind.FunctionType */: + case 256 /* SyntaxKind.FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -108879,7 +109323,7 @@ var ts; // Heritage clause is written by user so it can always be named if (ts.isClassDeclaration(node.parent.parent)) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 117 /* SyntaxKind.ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0; @@ -108928,7 +109372,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 164 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 164 /* SyntaxKind.Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -108947,13 +109391,13 @@ var ts; }); } ts.isInternalDeclaration = isInternalDeclaration; - var declarationEmitNodeBuilderFlags = 1024 /* MultilineObjectLiterals */ | - 2048 /* WriteClassExpressionAsTypeLiteral */ | - 4096 /* UseTypeOfFunction */ | - 8 /* UseStructuralFallback */ | - 524288 /* AllowEmptyTuple */ | - 4 /* GenerateNamesForShadowedTypeParams */ | - 1 /* NoTruncation */; + var declarationEmitNodeBuilderFlags = 1024 /* NodeBuilderFlags.MultilineObjectLiterals */ | + 2048 /* NodeBuilderFlags.WriteClassExpressionAsTypeLiteral */ | + 4096 /* NodeBuilderFlags.UseTypeOfFunction */ | + 8 /* NodeBuilderFlags.UseStructuralFallback */ | + 524288 /* NodeBuilderFlags.AllowEmptyTuple */ | + 4 /* NodeBuilderFlags.GenerateNamesForShadowedTypeParams */ | + 1 /* NodeBuilderFlags.NoTruncation */; /** * Transforms a ts file into a .d.ts file * This process requires type information, which is retrieved through the emit resolver. Because of this, @@ -109013,7 +109457,7 @@ var ts; } function trackReferencedAmbientModule(node, symbol) { // If it is visible via `// `, then we should just use that - var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* All */); + var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863 /* SymbolFlags.All */); if (ts.length(directives)) { return recordTypeReferenceDirectivesIfNecessary(directives); } @@ -109022,7 +109466,7 @@ var ts; refs.set(ts.getOriginalNodeId(container), container); } function handleSymbolAccessibilityError(symbolAccessibilityResult) { - if (symbolAccessibilityResult.accessibility === 0 /* Accessible */) { + if (symbolAccessibilityResult.accessibility === 0 /* SymbolAccessibility.Accessible */) { // Add aliases back onto the possible imports list if they're not there so we can try them again with updated visibility info if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) { if (!lateMarkedStatements) { @@ -109058,7 +109502,7 @@ var ts; } } function trackSymbol(symbol, enclosingDeclaration, meaning) { - if (symbol.flags & 262144 /* TypeParameter */) + if (symbol.flags & 262144 /* SymbolFlags.TypeParameter */) return false; var issuedDiagnostic = handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, /*shouldComputeAliasesToMakeVisible*/ true)); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning)); @@ -109134,10 +109578,10 @@ var ts; return result; } function transformRoot(node) { - if (node.kind === 305 /* SourceFile */ && node.isDeclarationFile) { + if (node.kind === 305 /* SyntaxKind.SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 306 /* Bundle */) { + if (node.kind === 306 /* SyntaxKind.Bundle */) { isBundledEmit = true; refs = new ts.Map(); libs = new ts.Map(); @@ -109160,14 +109604,14 @@ var ts; resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([factory.createModifier(135 /* DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration([factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)], factory.createStringLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 308 /* InputFiles */) { + if (prepend.kind === 308 /* SyntaxKind.InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -109304,11 +109748,11 @@ var ts; return ret; } function filterBindingPatternInitializersAndRenamings(name) { - if (name.kind === 79 /* Identifier */) { + if (name.kind === 79 /* SyntaxKind.Identifier */) { return name; } else { - if (name.kind === 202 /* ArrayBindingPattern */) { + if (name.kind === 202 /* SyntaxKind.ArrayBindingPattern */) { return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -109316,7 +109760,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 227 /* OmittedExpression */) { + if (elem.kind === 227 /* SyntaxKind.OmittedExpression */) { return elem; } if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) { @@ -109333,7 +109777,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } - var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* SyntaxKind.QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -109350,7 +109794,7 @@ var ts; return undefined; } function ensureType(node, type, ignorePrivate) { - if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (!ignorePrivate && ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { // Private nodes emit no types (except private parameter properties, whose parameter types are actually visible) return; } @@ -109358,19 +109802,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 164 /* Parameter */ && + var shouldUseResolverType = node.kind === 164 /* SyntaxKind.Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } - if (node.kind === 173 /* SetAccessor */) { + if (node.kind === 173 /* SyntaxKind.SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return factory.createKeywordTypeNode(130 /* AnyKeyword */); + return factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -109378,12 +109822,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) { + if (node.kind === 254 /* SyntaxKind.VariableDeclaration */ || node.kind === 203 /* SyntaxKind.BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 164 /* Parameter */ - || node.kind === 167 /* PropertyDeclaration */ - || node.kind === 166 /* PropertySignature */) { + if (node.kind === 164 /* SyntaxKind.Parameter */ + || node.kind === 167 /* SyntaxKind.PropertyDeclaration */ + || node.kind === 166 /* SyntaxKind.PropertySignature */) { if (ts.isPropertySignature(node) || !node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -109394,28 +109838,28 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || factory.createKeywordTypeNode(130 /* AnyKeyword */); + return returnValue || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return !getBindingNameVisible(node); - case 265 /* ImportEqualsDeclaration */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return false; - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return true; } return false; @@ -109442,7 +109886,7 @@ var ts; } } function updateParamsList(node, params, modifierMask) { - if (ts.hasEffectiveModifier(node, 8 /* Private */)) { + if (ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */)) { return undefined; // TODO: GH#18217 } var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); }); @@ -109478,7 +109922,7 @@ var ts; return factory.createNodeArray(newParams || ts.emptyArray); } function ensureTypeParams(node, params) { - return ts.hasEffectiveModifier(node, 8 /* Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); + return ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */) ? undefined : ts.visitNodes(params, visitDeclarationSubtree); } function isEnclosingDeclaration(node) { return ts.isSourceFile(node) @@ -109504,7 +109948,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* ModuleDeclaration */ && parent.kind !== 200 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 261 /* SyntaxKind.ModuleDeclaration */ && parent.kind !== 200 /* SyntaxKind.ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -109524,7 +109968,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 277 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 277 /* SyntaxKind.ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration(decl, decl.modifiers, decl.isTypeOnly, decl.name, factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); @@ -109549,7 +109993,7 @@ var ts; return visibleDefaultBinding && factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)); } - if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 268 /* SyntaxKind.NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined; @@ -109594,7 +110038,7 @@ var ts; while (ts.length(lateMarkedStatements)) { var i = lateMarkedStatements.shift(); if (!ts.isLateVisibilityPaintedStatement(i)) { - return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind)); + return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: ".concat(ts.Debug.formatSyntaxKind(i.kind))); } var priorNeedsDeclare = needsDeclare; needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit); @@ -109652,10 +110096,10 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* TypeLiteral */ || input.kind === 195 /* MappedType */) && input.parent.kind !== 259 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 182 /* SyntaxKind.TypeLiteral */ || input.kind === 195 /* SyntaxKind.MappedType */) && input.parent.kind !== 259 /* SyntaxKind.TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { - if (ts.hasEffectiveModifier(input, 8 /* Private */)) { + if (ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload return cleanup(factory.createPropertyDeclaration(ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); @@ -109673,28 +110117,28 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 228 /* ExpressionWithTypeArguments */: { + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments)); } - case 178 /* TypeReference */: { + case 178 /* SyntaxKind.TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments)); } - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 171 /* Constructor */: { + case 171 /* SyntaxKind.Constructor */: { // A constructor declaration may not have a type annotation var ctor = factory.createConstructorDeclaration( - /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* None */), + /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, 0 /* ModifierFlags.None */), /*body*/ undefined); return cleanup(ctor); } - case 169 /* MethodDeclaration */: { + case 169 /* SyntaxKind.MethodDeclaration */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } @@ -109703,44 +110147,44 @@ var ts; /*body*/ undefined); return cleanup(sig); } - case 172 /* GetAccessor */: { + case 172 /* SyntaxKind.GetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(factory.updateGetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), ensureType(input, accessorType), + return cleanup(factory.updateGetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), ensureType(input, accessorType), /*body*/ undefined)); } - case 173 /* SetAccessor */: { + case 173 /* SyntaxKind.SetAccessor */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } - return cleanup(factory.updateSetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* Private */)), + return cleanup(factory.updateSetAccessorDeclaration(input, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8 /* ModifierFlags.Private */)), /*body*/ undefined)); } - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertyDeclaration(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input))); - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type))); - case 168 /* MethodSignature */: { + case 168 /* SyntaxKind.MethodSignature */: { if (ts.isPrivateIdentifier(input.name)) { return cleanup(/*returnValue*/ undefined); } return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 174 /* CallSignature */: { + case 174 /* SyntaxKind.CallSignature */: { return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 176 /* IndexSignature */: { - return cleanup(factory.updateIndexSignature(input, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* AnyKeyword */))); + case 176 /* SyntaxKind.IndexSignature */: { + return cleanup(factory.updateIndexSignature(input, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(130 /* SyntaxKind.AnyKeyword */))); } - case 254 /* VariableDeclaration */: { + case 254 /* SyntaxKind.VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -109748,13 +110192,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(factory.updateVariableDeclaration(input, input.name, /*exclamationToken*/ undefined, ensureType(input, input.type), ensureNoInitializer(input))); } - case 163 /* TypeParameter */: { + case 163 /* SyntaxKind.TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(factory.updateTypeParameterDeclaration(input, input.modifiers, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 189 /* ConditionalType */: { + case 189 /* SyntaxKind.ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -109766,22 +110210,22 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 179 /* FunctionType */: { + case 179 /* SyntaxKind.FunctionType */: { return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 180 /* ConstructorType */: { + case 180 /* SyntaxKind.ConstructorType */: { return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 200 /* ImportType */: { + case 200 /* SyntaxKind.ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); } - default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind)); + default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: ".concat(ts.Debug.formatSyntaxKind(input.kind))); } } if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) { - ts.setEmitFlags(input, 1 /* SingleLine */); + ts.setEmitFlags(input, 1 /* EmitFlags.SingleLine */); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); function cleanup(returnValue) { @@ -109804,7 +110248,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 169 /* MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* Private */); + return node.parent.kind === 169 /* SyntaxKind.MethodDeclaration */ && ts.hasEffectiveModifier(node.parent, 8 /* ModifierFlags.Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -109814,7 +110258,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 272 /* ExportDeclaration */: { + case 272 /* SyntaxKind.ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -109823,17 +110267,17 @@ var ts; // Rewrite external module names if necessary return factory.updateExportDeclaration(input, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier), ts.getResolutionModeOverrideForClause(input.assertClause) ? input.assertClause : undefined); } - case 271 /* ExportAssignment */: { + case 271 /* SyntaxKind.ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 79 /* Identifier */) { + if (input.expression.kind === 79 /* SyntaxKind.Identifier */) { return input; } else { - var newId = factory.createUniqueName("_default", 16 /* Optimistic */); + var newId = factory.createUniqueName("_default", 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, errorNode: input @@ -109841,7 +110285,7 @@ var ts; errorFallbackNode = input; var varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); preserveJsDoc(statement, input); ts.removeAllComments(input); return [statement, factory.updateExportAssignment(input, input.modifiers, newId)]; @@ -109854,12 +110298,12 @@ var ts; return input; } function stripExportModifiers(statement) { - if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* Default */) || !ts.canHaveModifiers(statement)) { + if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512 /* ModifierFlags.Default */) || !ts.canHaveModifiers(statement)) { // `export import` statements should remain as-is, as imports are _not_ implicitly exported in an ambient namespace // Likewise, `export default` classes and the like and just be `default`, so we preserve their `export` modifiers, too return statement; } - var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (257023 /* All */ ^ 1 /* Export */)); + var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (257023 /* ModifierFlags.All */ ^ 1 /* ModifierFlags.Export */)); return factory.updateModifiers(statement, modifiers); } function transformTopLevelDeclaration(input) { @@ -109870,10 +110314,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 265 /* ImportEqualsDeclaration */: { + case 265 /* SyntaxKind.ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 266 /* ImportDeclaration */: { + case 266 /* SyntaxKind.ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -109894,12 +110338,12 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 259 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 259 /* SyntaxKind.TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration(input, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 258 /* InterfaceDeclaration */: { + case 258 /* SyntaxKind.InterfaceDeclaration */: { return cleanup(factory.updateInterfaceDeclaration(input, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 256 /* FunctionDeclaration */: { + case 256 /* SyntaxKind.FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(factory.updateFunctionDeclaration(input, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), @@ -109907,7 +110351,7 @@ var ts; if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { var props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration - var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* Namespace */); + var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(/*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16 /* NodeFlags.Namespace */); ts.setParent(fakespace_1, enclosingDeclaration); fakespace_1.locals = ts.createSymbolTable(props); fakespace_1.symbol = props[0].parent; @@ -109926,10 +110370,10 @@ var ts; exportMappings_1.push([name, nameStr]); } var varDecl = factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, type, /*initializer*/ undefined); - return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); + return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(93 /* SyntaxKind.ExportKeyword */)], factory.createVariableDeclarationList([varDecl])); }); if (!exportMappings_1.length) { - declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* None */); }); + declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0 /* ModifierFlags.None */); }); } else { declarations.push(factory.createExportDeclaration( @@ -109939,11 +110383,11 @@ var ts; return factory.createExportSpecifier(/*isTypeOnly*/ false, gen, exp); })))); } - var namespaceDecl = factory.createModuleDeclaration(ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* Namespace */); - if (!ts.hasEffectiveModifier(clean, 512 /* Default */)) { + var namespaceDecl = factory.createModuleDeclaration(ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16 /* NodeFlags.Namespace */); + if (!ts.hasEffectiveModifier(clean, 512 /* ModifierFlags.Default */)) { return [clean, namespaceDecl]; } - var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ExportDefault */) | 2 /* Ambient */); + var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513 /* ModifierFlags.ExportDefault */) | 2 /* ModifierFlags.Ambient */); var cleanDeclaration = factory.updateFunctionDeclaration(clean, modifiers, /*asteriskToken*/ undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, /*body*/ undefined); @@ -109961,17 +110405,17 @@ var ts; return clean; } } - case 261 /* ModuleDeclaration */: { + case 261 /* SyntaxKind.ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 262 /* ModuleBlock */) { + if (inner && inner.kind === 262 /* SyntaxKind.ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 16777216 /* Ambient */) { + if (input.flags & 16777216 /* NodeFlags.Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -110005,7 +110449,7 @@ var ts; return cleanup(factory.updateModuleDeclaration(input, mods, input.name, body)); } } - case 257 /* ClassDeclaration */: { + case 257 /* SyntaxKind.ClassDeclaration */: { errorNameNode = input.name; errorFallbackNode = input; var modifiers = factory.createNodeArray(ensureModifiers(input)); @@ -110015,10 +110459,10 @@ var ts; if (ctor) { var oldDiag_1 = getSymbolAccessibilityDiagnostic; parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) { - if (!ts.hasSyntacticModifier(param, 16476 /* ParameterPropertyModifier */) || shouldStripInternal(param)) + if (!ts.hasSyntacticModifier(param, 16476 /* ModifierFlags.ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 79 /* Identifier */) { + if (param.name.kind === 79 /* SyntaxKind.Identifier */) { return preserveJsDoc(factory.createPropertyDeclaration(ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } else { @@ -110057,26 +110501,26 @@ var ts; var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree)); var members = factory.createNodeArray(memberNodes); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 104 /* SyntaxKind.NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; - var newId_1 = factory.createUniqueName(oldId + "_base", 16 /* Optimistic */); + var newId_1 = factory.createUniqueName("".concat(oldId, "_base"), 16 /* GeneratedIdentifierFlags.Optimistic */); getSymbolAccessibilityDiagnostic = function () { return ({ diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, errorNode: extendsClause_1, typeName: input.name }); }; var varDecl = factory.createVariableDeclaration(newId_1, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(135 /* SyntaxKind.DeclareKeyword */)] : [], factory.createVariableDeclarationList([varDecl], 2 /* NodeFlags.Const */)); var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 94 /* ExtendsKeyword */) { + if (clause.token === 94 /* SyntaxKind.ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* NullKeyword */; })), visitDeclarationSubtree)); + return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 104 /* SyntaxKind.NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 } @@ -110085,10 +110529,10 @@ var ts; return cleanup(factory.updateClassDeclaration(input, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 237 /* VariableStatement */: { + case 237 /* SyntaxKind.VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 260 /* EnumDeclaration */: { + case 260 /* SyntaxKind.EnumDeclaration */: { return cleanup(factory.updateEnumDeclaration(input, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -110099,7 +110543,7 @@ var ts; } } // Anything left unhandled is an error, so this should be unreachable - return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind)); + return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: ".concat(ts.Debug.formatSyntaxKind(input.kind))); function cleanup(node) { if (isEnclosingDeclaration(input)) { enclosingDeclaration = previousEnclosingDeclaration; @@ -110107,7 +110551,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 261 /* ModuleDeclaration */) { + if (input.kind === 261 /* SyntaxKind.ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -110130,7 +110574,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 227 /* OmittedExpression */) { + if (e.kind === 227 /* SyntaxKind.OmittedExpression */) { return; } if (e.name) { @@ -110178,12 +110622,12 @@ var ts; return factory.createModifiersFromModifierFlags(newFlags); } function ensureModifierFlags(node) { - var mask = 257023 /* All */ ^ (4 /* Public */ | 256 /* Async */ | 16384 /* Override */); // No async and override modifiers in declaration files - var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 305 /* SourceFile */; + var mask = 257023 /* ModifierFlags.All */ ^ (4 /* ModifierFlags.Public */ | 256 /* ModifierFlags.Async */ | 16384 /* ModifierFlags.Override */); // No async and override modifiers in declaration files + var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* ModifierFlags.Ambient */ : 0 /* ModifierFlags.None */; + var parentIsFile = node.parent.kind === 305 /* SyntaxKind.SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { - mask ^= 2 /* Ambient */; - additions = 0 /* None */; + mask ^= 2 /* ModifierFlags.Ambient */; + additions = 0 /* ModifierFlags.None */; } return maskModifierFlags(node, mask, additions); } @@ -110203,13 +110647,13 @@ var ts; } function transformHeritageClauses(nodes) { return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* ExtendsKeyword */ && t.expression.kind === 104 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 94 /* SyntaxKind.ExtendsKeyword */ && t.expression.kind === 104 /* SyntaxKind.NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 258 /* InterfaceDeclaration */) { + if (node.kind === 258 /* SyntaxKind.InterfaceDeclaration */) { return true; } return false; @@ -110219,22 +110663,22 @@ var ts; return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions)); } function maskModifierFlags(node, modifierMask, modifierAdditions) { - if (modifierMask === void 0) { modifierMask = 257023 /* All */ ^ 4 /* Public */; } - if (modifierAdditions === void 0) { modifierAdditions = 0 /* None */; } + if (modifierMask === void 0) { modifierMask = 257023 /* ModifierFlags.All */ ^ 4 /* ModifierFlags.Public */; } + if (modifierAdditions === void 0) { modifierAdditions = 0 /* ModifierFlags.None */; } var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions; - if (flags & 512 /* Default */ && !(flags & 1 /* Export */)) { + if (flags & 512 /* ModifierFlags.Default */ && !(flags & 1 /* ModifierFlags.Export */)) { // A non-exported default is a nonsequitor - we usually try to remove all export modifiers // from statements in ambient declarations; but a default export must retain its export modifier to be syntactically valid - flags ^= 1 /* Export */; + flags ^= 1 /* ModifierFlags.Export */; } - if (flags & 512 /* Default */ && flags & 2 /* Ambient */) { - flags ^= 2 /* Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) + if (flags & 512 /* ModifierFlags.Default */ && flags & 2 /* ModifierFlags.Ambient */) { + flags ^= 2 /* ModifierFlags.Ambient */; // `declare` is never required alongside `default` (and would be an error if printed) } return flags; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 172 /* GetAccessor */ + return accessor.kind === 172 /* SyntaxKind.GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -110243,52 +110687,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - return !ts.hasEffectiveModifier(node, 8 /* Private */); - case 164 /* Parameter */: - case 254 /* VariableDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + return !ts.hasEffectiveModifier(node, 8 /* ModifierFlags.Private */); + case 164 /* SyntaxKind.Parameter */: + case 254 /* SyntaxKind.VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 256 /* FunctionDeclaration */: - case 261 /* ModuleDeclaration */: - case 265 /* ImportEqualsDeclaration */: - case 258 /* InterfaceDeclaration */: - case 257 /* ClassDeclaration */: - case 259 /* TypeAliasDeclaration */: - case 260 /* EnumDeclaration */: - case 237 /* VariableStatement */: - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: + case 237 /* SyntaxKind.VariableStatement */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 175 /* ConstructSignature */: - case 171 /* Constructor */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 167 /* PropertyDeclaration */: - case 166 /* PropertySignature */: - case 168 /* MethodSignature */: - case 174 /* CallSignature */: - case 176 /* IndexSignature */: - case 254 /* VariableDeclaration */: - case 163 /* TypeParameter */: - case 228 /* ExpressionWithTypeArguments */: - case 178 /* TypeReference */: - case 189 /* ConditionalType */: - case 179 /* FunctionType */: - case 180 /* ConstructorType */: - case 200 /* ImportType */: + case 175 /* SyntaxKind.ConstructSignature */: + case 171 /* SyntaxKind.Constructor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 166 /* SyntaxKind.PropertySignature */: + case 168 /* SyntaxKind.MethodSignature */: + case 174 /* SyntaxKind.CallSignature */: + case 176 /* SyntaxKind.IndexSignature */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 163 /* SyntaxKind.TypeParameter */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 178 /* SyntaxKind.TypeReference */: + case 189 /* SyntaxKind.ConditionalType */: + case 179 /* SyntaxKind.FunctionType */: + case 180 /* SyntaxKind.ConstructorType */: + case 200 /* SyntaxKind.ImportType */: return true; } return false; @@ -110346,35 +110790,35 @@ var ts; if (ts.getJSXTransformEnabled(compilerOptions)) { transformers.push(ts.transformJsx); } - if (languageVersion < 99 /* ESNext */) { + if (languageVersion < 99 /* ScriptTarget.ESNext */) { transformers.push(ts.transformESNext); } - if (languageVersion < 8 /* ES2021 */) { + if (languageVersion < 8 /* ScriptTarget.ES2021 */) { transformers.push(ts.transformES2021); } - if (languageVersion < 7 /* ES2020 */) { + if (languageVersion < 7 /* ScriptTarget.ES2020 */) { transformers.push(ts.transformES2020); } - if (languageVersion < 6 /* ES2019 */) { + if (languageVersion < 6 /* ScriptTarget.ES2019 */) { transformers.push(ts.transformES2019); } - if (languageVersion < 5 /* ES2018 */) { + if (languageVersion < 5 /* ScriptTarget.ES2018 */) { transformers.push(ts.transformES2018); } - if (languageVersion < 4 /* ES2017 */) { + if (languageVersion < 4 /* ScriptTarget.ES2017 */) { transformers.push(ts.transformES2017); } - if (languageVersion < 3 /* ES2016 */) { + if (languageVersion < 3 /* ScriptTarget.ES2016 */) { transformers.push(ts.transformES2016); } - if (languageVersion < 2 /* ES2015 */) { + if (languageVersion < 2 /* ScriptTarget.ES2015 */) { transformers.push(ts.transformES2015); transformers.push(ts.transformGenerators); } transformers.push(getModuleTransformer(moduleKind)); // The ES5 transformer is last so that it can substitute expressions like `exports.default` // for ES3. - if (languageVersion < 1 /* ES5 */) { + if (languageVersion < 1 /* ScriptTarget.ES5 */) { transformers.push(ts.transformES5); } ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory)); @@ -110428,11 +110872,11 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(355 /* Count */); + var enabledSyntaxKindFeatures = new Array(355 /* SyntaxKind.Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentStatements; - var lexicalEnvironmentFlags = 0 /* None */; + var lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; var lexicalEnvironmentStatementsStack = []; @@ -110445,7 +110889,7 @@ var ts; var emitHelpers; var onSubstituteNode = noEmitSubstitution; var onEmitNode = noEmitNotification; - var state = 0 /* Uninitialized */; + var state = 0 /* TransformationState.Uninitialized */; var diagnostics = []; // The transformation context is provided to each transformer as part of transformer // initialization. @@ -110475,13 +110919,13 @@ var ts; isEmitNotificationEnabled: isEmitNotificationEnabled, get onSubstituteNode() { return onSubstituteNode; }, set onSubstituteNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onSubstituteNode = value; }, get onEmitNode() { return onEmitNode; }, set onEmitNode(value) { - ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(state < 1 /* TransformationState.Initialized */, "Cannot modify transformation hooks after initialization has completed."); ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); onEmitNode = value; }, @@ -110505,17 +110949,17 @@ var ts; return node; }; // prevent modification of transformation hooks. - state = 1 /* Initialized */; + state = 1 /* TransformationState.Initialized */; // Transform each node. var transformed = []; for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) { var node = nodes_3[_a]; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "transformNodes", node.kind === 305 /* SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "transformNodes", node.kind === 305 /* SyntaxKind.SourceFile */ ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end }); transformed.push((allowDtsFiles ? transformation : transformRoot)(node)); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } // prevent modification of the lexical environment. - state = 2 /* Completed */; + state = 2 /* TransformationState.Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { @@ -110533,15 +110977,15 @@ var ts; * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 1 /* SyntaxKindFeatureFlags.Substitution */; } /** * Determines whether expression substitutions are enabled for the provided node. */ function isSubstitutionEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 1 /* Substitution */) !== 0 - && (ts.getEmitFlags(node) & 4 /* NoSubstitution */) === 0; + return (enabledSyntaxKindFeatures[node.kind] & 1 /* SyntaxKindFeatureFlags.Substitution */) !== 0 + && (ts.getEmitFlags(node) & 4 /* EmitFlags.NoSubstitution */) === 0; } /** * Emits a node with possible substitution. @@ -110551,23 +110995,23 @@ var ts; * @param emitCallback The callback used to emit the node or its substitute. */ function substituteNode(hint, node) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot substitute a node after the result is disposed."); return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); - enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); + enabledSyntaxKindFeatures[kind] |= 2 /* SyntaxKindFeatureFlags.EmitNotifications */; } /** * Determines whether before/after emit notifications should be raised in the pretty * printer when it emits a node. */ function isEmitNotificationEnabled(node) { - return (enabledSyntaxKindFeatures[node.kind] & 2 /* EmitNotifications */) !== 0 - || (ts.getEmitFlags(node) & 2 /* AdviseOnEmitNode */) !== 0; + return (enabledSyntaxKindFeatures[node.kind] & 2 /* SyntaxKindFeatureFlags.EmitNotifications */) !== 0 + || (ts.getEmitFlags(node) & 2 /* EmitFlags.AdviseOnEmitNode */) !== 0; } /** * Emits a node with possible emit notification. @@ -110577,7 +111021,7 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { - ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); + ts.Debug.assert(state < 3 /* TransformationState.Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { // TODO: Remove check and unconditionally use onEmitNode when API is breakingly changed // (see https://github.com/microsoft/TypeScript/pull/36248/files/5062623f39120171b98870c71344b3242eb03d23#r369766739) @@ -110593,26 +111037,26 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* NoNestedSourceMaps */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64 /* EmitFlags.NoNestedSourceMaps */); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; } else { lexicalEnvironmentVariableDeclarations.push(decl); } - if (lexicalEnvironmentFlags & 1 /* InParameters */) { - lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */; + if (lexicalEnvironmentFlags & 1 /* LexicalEnvironmentFlags.InParameters */) { + lexicalEnvironmentFlags |= 2 /* LexicalEnvironmentFlags.VariablesHoistedInParameters */; } } /** * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(func, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(func, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -110624,9 +111068,9 @@ var ts; * Adds an initialization statement to the top of the lexical environment. */ function addInitializationStatement(node) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); - ts.setEmitFlags(node, 1048576 /* CustomPrologue */); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(node, 1048576 /* EmitFlags.CustomPrologue */); if (!lexicalEnvironmentStatements) { lexicalEnvironmentStatements = [node]; } @@ -110639,8 +111083,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -110654,19 +111098,19 @@ var ts; lexicalEnvironmentVariableDeclarations = undefined; lexicalEnvironmentFunctionDeclarations = undefined; lexicalEnvironmentStatements = undefined; - lexicalEnvironmentFlags = 0 /* None */; + lexicalEnvironmentFlags = 0 /* LexicalEnvironmentFlags.None */; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -110675,8 +111119,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || @@ -110688,7 +111132,7 @@ var ts; if (lexicalEnvironmentVariableDeclarations) { var statement = factory.createVariableStatement( /*modifiers*/ undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations)); - ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* EmitFlags.CustomPrologue */); if (!statements) { statements = [statement]; } @@ -110731,8 +111175,8 @@ var ts; * Starts a block scope. Any existing block hoisted variables are pushed onto the stack and the related storage variables are reset. */ function startBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot start a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot start a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot start a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot start a block scope after transformation has completed."); blockScopedVariableDeclarationsStack[blockScopeStackOffset] = blockScopedVariableDeclarations; blockScopeStackOffset++; blockScopedVariableDeclarations = undefined; @@ -110741,12 +111185,12 @@ var ts; * Ends a block scope. The previous set of block hoisted variables are restored. Any hoisted declarations are returned. */ function endBlockScope() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot end a block scope during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot end a block scope after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot end a block scope during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot end a block scope after transformation has completed."); var statements = ts.some(blockScopedVariableDeclarations) ? [ factory.createVariableStatement( - /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* Let */)) + /*modifiers*/ undefined, factory.createVariableDeclarationList(blockScopedVariableDeclarations.map(function (identifier) { return factory.createVariableDeclaration(identifier); }), 1 /* NodeFlags.Let */)) ] : undefined; blockScopeStackOffset--; blockScopedVariableDeclarations = blockScopedVariableDeclarationsStack[blockScopeStackOffset]; @@ -110760,8 +111204,8 @@ var ts; (blockScopedVariableDeclarations || (blockScopedVariableDeclarations = [])).push(name); } function requestEmitHelper(helper) { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); if (helper.dependencies) { for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) { @@ -110772,14 +111216,14 @@ var ts; emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); - ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); + ts.Debug.assert(state > 0 /* TransformationState.Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* TransformationState.Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } function dispose() { - if (state < 3 /* Disposed */) { + if (state < 3 /* TransformationState.Disposed */) { // Clean up emit nodes on parse tree for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { var node = nodes_4[_i]; @@ -110794,7 +111238,7 @@ var ts; onEmitNode = undefined; emitHelpers = undefined; // Prevent further use of the transformation result. - state = 3 /* Disposed */; + state = 3 /* TransformationState.Disposed */; } } } @@ -110833,7 +111277,7 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ function isBuildInfoFile(file) { - return ts.fileExtensionIs(file, ".tsbuildinfo" /* TsBuildInfo */); + return ts.fileExtensionIs(file, ".tsbuildinfo" /* Extension.TsBuildInfo */); } ts.isBuildInfoFile = isBuildInfoFile; /*@internal*/ @@ -110899,7 +111343,7 @@ var ts; ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) : configFileExtensionLess; } - return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; + return buildInfoExtensionLess + ".tsbuildinfo" /* Extension.TsBuildInfo */; } ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ @@ -110907,7 +111351,7 @@ var ts; var outPath = ts.outFile(options); var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Extension.Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; @@ -110916,7 +111360,7 @@ var ts; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 306 /* Bundle */) { + if (sourceFile.kind === 306 /* SyntaxKind.Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -110924,7 +111368,7 @@ var ts; var isJsonFile = ts.isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it var isJsonEmittedToSameLocation = isJsonFile && - ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; @@ -110938,11 +111382,11 @@ var ts; } /* @internal */ function getOutputExtension(fileName, options) { - return ts.fileExtensionIs(fileName, ".json" /* Json */) ? ".json" /* Json */ : - options.jsx === 1 /* Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Jsx */, ".tsx" /* Tsx */]) ? ".jsx" /* Jsx */ : - ts.fileExtensionIsOneOf(fileName, [".mts" /* Mts */, ".mjs" /* Mjs */]) ? ".mjs" /* Mjs */ : - ts.fileExtensionIsOneOf(fileName, [".cts" /* Cts */, ".cjs" /* Cjs */]) ? ".cjs" /* Cjs */ : - ".js" /* Js */; + return ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) ? ".json" /* Extension.Json */ : + options.jsx === 1 /* JsxEmit.Preserve */ && ts.fileExtensionIsOneOf(fileName, [".jsx" /* Extension.Jsx */, ".tsx" /* Extension.Tsx */]) ? ".jsx" /* Extension.Jsx */ : + ts.fileExtensionIsOneOf(fileName, [".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ".mjs" /* Extension.Mjs */ : + ts.fileExtensionIsOneOf(fileName, [".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ".cjs" /* Extension.Cjs */ : + ".js" /* Extension.Js */; } ts.getOutputExtension = getOutputExtension; function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) { @@ -110958,9 +111402,9 @@ var ts; function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) { if (configFile.options.emitDeclarationOnly) return undefined; - var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */); var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), getOutputExtension(inputFileName, configFile.options)); - return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? + return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* Comparison.EqualTo */ ? outputFileName : undefined; } @@ -110989,16 +111433,16 @@ var ts; return; var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) return; if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); + addOutput("".concat(js, ".map")); } if (ts.getEmitDeclarations(configFile.options)) { var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); addOutput(dts); if (configFile.options.declarationMap) { - addOutput(dts + ".map"); + addOutput("".concat(dts, ".map")); } } } @@ -111067,7 +111511,7 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (ts.outFile(configFile.options)) { var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath; - return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); }); for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { @@ -111077,7 +111521,7 @@ var ts; var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); if (jsFilePath) return jsFilePath; - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + if (ts.fileExtensionIs(inputFileName, ".json" /* Extension.Json */)) continue; if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory); @@ -111086,7 +111530,7 @@ var ts; var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; - return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.fail("project ".concat(configFile.options.configFilePath, " expected to have at least one output")); } ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ @@ -111102,7 +111546,6 @@ var ts; var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit; var bundleBuildInfo; var emitSkipped = false; - var exportedModulesFromDeclarationEmit; // Emit each output file enter(); forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile); @@ -111112,7 +111555,6 @@ var ts; diagnostics: emitterDiagnostics.getDiagnostics(), emittedFiles: emittedFilesList, sourceMaps: sourceMapDataList, - exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function emitSourceFileOrBundle(_a, sourceFileOrBundle) { var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; @@ -111124,13 +111566,13 @@ var ts; sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); }) }; } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitJsFileOrBundle", { jsFilePath: jsFilePath }); emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath }); emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", { buildInfoPath: buildInfoPath }); emitBuildInfo(bundleBuildInfo, buildInfoPath); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); if (!emitSkipped && emittedFilesList) { @@ -111175,7 +111617,7 @@ var ts; return; } // Make sure not to write js file and source map file if any of them cannot be written - if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) { + if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) { emitSkipped = true; return; } @@ -111204,7 +111646,7 @@ var ts; substituteNode: transform.substituteNode, }); ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform"); - printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions); + printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions); // Clean up emit nodes on parse tree transform.dispose(); if (bundleBuildInfo) @@ -111240,7 +111682,7 @@ var ts; noEmitHelpers: true, module: compilerOptions.module, target: compilerOptions.target, - sourceMap: compilerOptions.sourceMap, + sourceMap: !forceDtsEmit && compilerOptions.declarationMap, inlineSourceMap: compilerOptions.inlineSourceMap, extendedDiagnostics: compilerOptions.extendedDiagnostics, onlyPrintJsDocStyle: true, @@ -111260,17 +111702,13 @@ var ts; emitSkipped = emitSkipped || declBlocked; if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); - printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { - sourceMap: !forceDtsEmit && compilerOptions.declarationMap, + printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, { + sourceMap: printerOptions.sourceMap, sourceRoot: compilerOptions.sourceRoot, mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, // Explicitly do not passthru either `inline` option }); - if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) { - var sourceFile = declarationTransform.transformed[0]; - exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; - } } declarationTransform.dispose(); if (bundleBuildInfo) @@ -111278,7 +111716,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 79 /* Identifier */) { + if (node.expression.kind === 79 /* SyntaxKind.Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -111289,9 +111727,10 @@ var ts; } ts.forEachChild(node, collectLinkedAliases); } - function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined; + function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) { + var sourceFileOrBundle = transform.transformed[0]; + var bundle = sourceFileOrBundle.kind === 306 /* SyntaxKind.Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 305 /* SyntaxKind.SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -111316,14 +111755,14 @@ var ts; if (!writer.isAtStartOfLine()) writer.rawWrite(newLine); sourceMapUrlPos = writer.getTextPos(); - writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment + writer.writeComment("//# ".concat("sourceMappingURL", "=").concat(sourceMappingURL)); // Tools can sometimes see this line as a source mapping url comment } // Write the source map if (sourceMapFilePath) { var sourceMap = sourceMapGenerator.toString(); ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles); if (printer.bundleFileInfo) - printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash)); } } else { @@ -111331,17 +111770,17 @@ var ts; } // Write the output file var text = writer.getText(); - ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos }); + ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics }); // We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo // This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode if (printer.bundleFileInfo) - printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash)); + printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash)); // Reset state writer.clear(); } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 305 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 305 /* SyntaxKind.SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Extension.Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -111372,7 +111811,7 @@ var ts; // Encode the sourceMap into the sourceMap url var sourceMapText = sourceMapGenerator.toString(); var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); - return "data:application/json;base64," + base64SourceMapText; + return "data:application/json;base64,".concat(base64SourceMapText); } var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { @@ -111465,8 +111904,8 @@ var ts; ts.setParent(literal, statement); return statement; }); - var eofToken = ts.factory.createToken(1 /* EndOfFileToken */); - var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* None */); + var eofToken = ts.factory.createToken(1 /* SyntaxKind.EndOfFileToken */); + var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0 /* NodeFlags.None */); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : ""; ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0); @@ -111500,25 +111939,25 @@ var ts; if (!jsFileText) return jsFilePath; // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it - if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) + if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash) return jsFilePath; var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); // error if no source map or for now if inline sourcemap if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap) return sourceMapFilePath || "inline sourcemap decoding"; - if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) + if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash) return sourceMapFilePath; // read declaration text var declarationText = declarationFilePath && host.readFile(declarationFilePath); if (declarationFilePath && !declarationText) return declarationFilePath; - if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) + if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash) return declarationFilePath; var declarationMapText = declarationMapPath && host.readFile(declarationMapPath); // error if no source map or for now if inline sourcemap if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap) return declarationMapPath || "inline sourcemap decoding"; - if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) + if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash) return declarationMapPath; var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory())); var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, @@ -111558,8 +111997,7 @@ var ts; newBuildInfo.program = buildInfo.program; if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) { // Update the output signature - newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash); - newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime(); + newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData); } // Update sourceFileInfo var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles; @@ -111581,7 +112019,7 @@ var ts; return; break; default: - ts.Debug.fail("Unexpected path: " + name); + ts.Debug.fail("Unexpected path: ".concat(name)); } outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark }); }, @@ -111634,7 +112072,7 @@ var ts; var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined; var recordInternalSection = printerOptions.recordInternalSection; var sourceFileTextPos = 0; - var sourceFileTextKind = "text" /* Text */; + var sourceFileTextKind = "text" /* BundleFileSectionKind.Text */; // Source Maps var sourceMapsDisabled = true; var sourceMapGenerator; @@ -111674,20 +112112,20 @@ var ts; }; function printNode(hint, node, sourceFile) { switch (hint) { - case 0 /* SourceFile */: + case 0 /* EmitHint.SourceFile */: ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node."); break; - case 2 /* IdentifierName */: + case 2 /* EmitHint.IdentifierName */: ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node."); break; - case 1 /* Expression */: + case 1 /* EmitHint.Expression */: ts.Debug.assert(ts.isExpression(node), "Expected an Expression node."); break; } switch (node.kind) { - case 305 /* SourceFile */: return printFile(node); - case 306 /* Bundle */: return printBundle(node); - case 307 /* UnparsedSource */: return printUnparsedSource(node); + case 305 /* SyntaxKind.SourceFile */: return printFile(node); + case 306 /* SyntaxKind.Bundle */: return printBundle(node); + case 307 /* SyntaxKind.UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -111743,11 +112181,11 @@ var ts; currentSourceFile && (ts.isDeclaration(node) || ts.isVariableStatement(node)) && ts.isInternalDeclaration(node, currentSourceFile) && - sourceFileTextKind !== "internal" /* Internal */) { + sourceFileTextKind !== "internal" /* BundleFileSectionKind.Internal */) { var prevSourceFileTextKind = sourceFileTextKind; recordBundleFileTextLikeSection(writer.getTextPos()); sourceFileTextPos = getTextPosWithWriteLine(); - sourceFileTextKind = "internal" /* Internal */; + sourceFileTextKind = "internal" /* BundleFileSectionKind.Internal */; return prevSourceFileTextKind; } return undefined; @@ -111782,7 +112220,7 @@ var ts; var savedSections = bundleFileInfo && bundleFileInfo.sections; if (savedSections) bundleFileInfo.sections = []; - print(4 /* Unspecified */, prepend, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, prepend, /*sourceFile*/ undefined); if (bundleFileInfo) { var newSections = bundleFileInfo.sections; bundleFileInfo.sections = savedSections; @@ -111793,7 +112231,7 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), - kind: "prepend" /* Prepend */, + kind: "prepend" /* BundleFileSectionKind.Prepend */, data: relativeToBuildInfo(prepend.fileName), texts: newSections }); @@ -111803,7 +112241,7 @@ var ts; sourceFileTextPos = getTextPosWithWriteLine(); for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) { var sourceFile = _e[_d]; - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); } if (bundleFileInfo && bundle.sourceFiles.length) { var end = writer.getTextPos(); @@ -111830,7 +112268,7 @@ var ts; function writeUnparsedSource(unparsed, output) { var previousWriter = writer; setWriter(output, /*_sourceMapGenerator*/ undefined); - print(4 /* Unspecified */, unparsed, /*sourceFile*/ undefined); + print(4 /* EmitHint.Unspecified */, unparsed, /*sourceFile*/ undefined); reset(); writer = previousWriter; } @@ -111840,7 +112278,7 @@ var ts; setWriter(output, sourceMapGenerator); emitShebangIfNeeded(sourceFile); emitPrologueDirectivesIfNeeded(sourceFile); - print(0 /* SourceFile */, sourceFile, sourceFile); + print(0 /* EmitHint.SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; } @@ -111879,7 +112317,7 @@ var ts; autoGeneratedIdToGeneratedName = []; generatedNames = new ts.Set(); tempFlagsStack = []; - tempFlags = 0 /* Auto */; + tempFlags = 0 /* TempFlags.Auto */; reservedNamesStack = []; currentSourceFile = undefined; currentLineMap = undefined; @@ -111893,24 +112331,24 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - pipelineEmit(4 /* Unspecified */, node, parenthesizerRule); + pipelineEmit(4 /* EmitHint.Unspecified */, node, parenthesizerRule); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); } function emitIdentifierName(node) { if (node === undefined) return; - pipelineEmit(2 /* IdentifierName */, node, /*parenthesizerRule*/ undefined); + pipelineEmit(2 /* EmitHint.IdentifierName */, node, /*parenthesizerRule*/ undefined); } function emitExpression(node, parenthesizerRule) { if (node === undefined) return; - pipelineEmit(1 /* Expression */, node, parenthesizerRule); + pipelineEmit(1 /* EmitHint.Expression */, node, parenthesizerRule); } function emitJsxAttributeValue(node) { - pipelineEmit(ts.isStringLiteral(node) ? 6 /* JsxAttributeValue */ : 4 /* Unspecified */, node); + pipelineEmit(ts.isStringLiteral(node) ? 6 /* EmitHint.JsxAttributeValue */ : 4 /* EmitHint.Unspecified */, node); } function beforeEmitNode(node) { - if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + if (preserveSourceNewlines && (ts.getEmitFlags(node) & 134217728 /* EmitFlags.IgnoreSourceNewlines */)) { preserveSourceNewlines = false; } } @@ -111919,7 +112357,7 @@ var ts; } function pipelineEmit(emitHint, node, parenthesizerRule) { currentParenthesizerRule = parenthesizerRule; - var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, emitHint, node); pipelinePhase(emitHint, node); currentParenthesizerRule = undefined; } @@ -111935,12 +112373,12 @@ var ts; } function getPipelinePhase(phase, emitHint, node) { switch (phase) { - case 0 /* Notification */: + case 0 /* PipelinePhase.Notification */: if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) { return pipelineEmitWithNotification; } // falls through - case 1 /* Substitution */: + case 1 /* PipelinePhase.Substitution */: if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) { if (currentParenthesizerRule) { lastSubstitution = currentParenthesizerRule(lastSubstitution); @@ -111948,17 +112386,17 @@ var ts; return pipelineEmitWithSubstitution; } // falls through - case 2 /* Comments */: + case 2 /* PipelinePhase.Comments */: if (shouldEmitComments(node)) { return pipelineEmitWithComments; } // falls through - case 3 /* SourceMaps */: + case 3 /* PipelinePhase.SourceMaps */: if (shouldEmitSourceMaps(node)) { return pipelineEmitWithSourceMaps; } // falls through - case 4 /* Emit */: + case 4 /* PipelinePhase.Emit */: return pipelineEmitWithHint; default: return ts.Debug.assertNever(phase); @@ -111968,7 +112406,7 @@ var ts; return getPipelinePhase(currentPhase + 1, emitHint, node); } function pipelineEmitWithNotification(hint, node) { - var pipelinePhase = getNextPipelinePhase(0 /* Notification */, hint, node); + var pipelinePhase = getNextPipelinePhase(0 /* PipelinePhase.Notification */, hint, node); onEmitNode(hint, node, pipelinePhase); } function pipelineEmitWithHint(hint, node) { @@ -111994,346 +112432,346 @@ var ts; return emitSnippetNode(hint, node, snippet); } } - if (hint === 0 /* SourceFile */) + if (hint === 0 /* EmitHint.SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); - if (hint === 2 /* IdentifierName */) + if (hint === 2 /* EmitHint.IdentifierName */) return emitIdentifier(ts.cast(node, ts.isIdentifier)); - if (hint === 6 /* JsxAttributeValue */) + if (hint === 6 /* EmitHint.JsxAttributeValue */) return emitLiteral(ts.cast(node, ts.isStringLiteral), /*jsxAttributeEscape*/ true); - if (hint === 3 /* MappedTypeParameter */) + if (hint === 3 /* EmitHint.MappedTypeParameter */) return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); - if (hint === 5 /* EmbeddedStatement */) { + if (hint === 5 /* EmitHint.EmbeddedStatement */) { ts.Debug.assertNode(node, ts.isEmptyStatement); return emitEmptyStatement(/*isEmbeddedStatement*/ true); } - if (hint === 4 /* Unspecified */) { + if (hint === 4 /* EmitHint.Unspecified */) { switch (node.kind) { // Pseudo-literals - case 15 /* TemplateHead */: - case 16 /* TemplateMiddle */: - case 17 /* TemplateTail */: + case 15 /* SyntaxKind.TemplateHead */: + case 16 /* SyntaxKind.TemplateMiddle */: + case 17 /* SyntaxKind.TemplateTail */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); // PrivateIdentifiers - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Parse tree nodes // Names - case 161 /* QualifiedName */: + case 161 /* SyntaxKind.QualifiedName */: return emitQualifiedName(node); - case 162 /* ComputedPropertyName */: + case 162 /* SyntaxKind.ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 163 /* TypeParameter */: + case 163 /* SyntaxKind.TypeParameter */: return emitTypeParameter(node); - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: return emitParameter(node); - case 165 /* Decorator */: + case 165 /* SyntaxKind.Decorator */: return emitDecorator(node); // Type members - case 166 /* PropertySignature */: + case 166 /* SyntaxKind.PropertySignature */: return emitPropertySignature(node); - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: return emitPropertyDeclaration(node); - case 168 /* MethodSignature */: + case 168 /* SyntaxKind.MethodSignature */: return emitMethodSignature(node); - case 169 /* MethodDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: return emitMethodDeclaration(node); - case 170 /* ClassStaticBlockDeclaration */: + case 170 /* SyntaxKind.ClassStaticBlockDeclaration */: return emitClassStaticBlockDeclaration(node); - case 171 /* Constructor */: + case 171 /* SyntaxKind.Constructor */: return emitConstructor(node); - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return emitAccessorDeclaration(node); - case 174 /* CallSignature */: + case 174 /* SyntaxKind.CallSignature */: return emitCallSignature(node); - case 175 /* ConstructSignature */: + case 175 /* SyntaxKind.ConstructSignature */: return emitConstructSignature(node); - case 176 /* IndexSignature */: + case 176 /* SyntaxKind.IndexSignature */: return emitIndexSignature(node); // Types - case 177 /* TypePredicate */: + case 177 /* SyntaxKind.TypePredicate */: return emitTypePredicate(node); - case 178 /* TypeReference */: + case 178 /* SyntaxKind.TypeReference */: return emitTypeReference(node); - case 179 /* FunctionType */: + case 179 /* SyntaxKind.FunctionType */: return emitFunctionType(node); - case 180 /* ConstructorType */: + case 180 /* SyntaxKind.ConstructorType */: return emitConstructorType(node); - case 181 /* TypeQuery */: + case 181 /* SyntaxKind.TypeQuery */: return emitTypeQuery(node); - case 182 /* TypeLiteral */: + case 182 /* SyntaxKind.TypeLiteral */: return emitTypeLiteral(node); - case 183 /* ArrayType */: + case 183 /* SyntaxKind.ArrayType */: return emitArrayType(node); - case 184 /* TupleType */: + case 184 /* SyntaxKind.TupleType */: return emitTupleType(node); - case 185 /* OptionalType */: + case 185 /* SyntaxKind.OptionalType */: return emitOptionalType(node); // SyntaxKind.RestType is handled below - case 187 /* UnionType */: + case 187 /* SyntaxKind.UnionType */: return emitUnionType(node); - case 188 /* IntersectionType */: + case 188 /* SyntaxKind.IntersectionType */: return emitIntersectionType(node); - case 189 /* ConditionalType */: + case 189 /* SyntaxKind.ConditionalType */: return emitConditionalType(node); - case 190 /* InferType */: + case 190 /* SyntaxKind.InferType */: return emitInferType(node); - case 191 /* ParenthesizedType */: + case 191 /* SyntaxKind.ParenthesizedType */: return emitParenthesizedType(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 192 /* ThisType */: + case 192 /* SyntaxKind.ThisType */: return emitThisType(); - case 193 /* TypeOperator */: + case 193 /* SyntaxKind.TypeOperator */: return emitTypeOperator(node); - case 194 /* IndexedAccessType */: + case 194 /* SyntaxKind.IndexedAccessType */: return emitIndexedAccessType(node); - case 195 /* MappedType */: + case 195 /* SyntaxKind.MappedType */: return emitMappedType(node); - case 196 /* LiteralType */: + case 196 /* SyntaxKind.LiteralType */: return emitLiteralType(node); - case 197 /* NamedTupleMember */: + case 197 /* SyntaxKind.NamedTupleMember */: return emitNamedTupleMember(node); - case 198 /* TemplateLiteralType */: + case 198 /* SyntaxKind.TemplateLiteralType */: return emitTemplateType(node); - case 199 /* TemplateLiteralTypeSpan */: + case 199 /* SyntaxKind.TemplateLiteralTypeSpan */: return emitTemplateTypeSpan(node); - case 200 /* ImportType */: + case 200 /* SyntaxKind.ImportType */: return emitImportTypeNode(node); // Binding patterns - case 201 /* ObjectBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 202 /* ArrayBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 203 /* BindingElement */: + case 203 /* SyntaxKind.BindingElement */: return emitBindingElement(node); // Misc - case 233 /* TemplateSpan */: + case 233 /* SyntaxKind.TemplateSpan */: return emitTemplateSpan(node); - case 234 /* SemicolonClassElement */: + case 234 /* SyntaxKind.SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: return emitBlock(node); - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: return emitVariableStatement(node); - case 236 /* EmptyStatement */: + case 236 /* SyntaxKind.EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 238 /* ExpressionStatement */: + case 238 /* SyntaxKind.ExpressionStatement */: return emitExpressionStatement(node); - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: return emitIfStatement(node); - case 240 /* DoStatement */: + case 240 /* SyntaxKind.DoStatement */: return emitDoStatement(node); - case 241 /* WhileStatement */: + case 241 /* SyntaxKind.WhileStatement */: return emitWhileStatement(node); - case 242 /* ForStatement */: + case 242 /* SyntaxKind.ForStatement */: return emitForStatement(node); - case 243 /* ForInStatement */: + case 243 /* SyntaxKind.ForInStatement */: return emitForInStatement(node); - case 244 /* ForOfStatement */: + case 244 /* SyntaxKind.ForOfStatement */: return emitForOfStatement(node); - case 245 /* ContinueStatement */: + case 245 /* SyntaxKind.ContinueStatement */: return emitContinueStatement(node); - case 246 /* BreakStatement */: + case 246 /* SyntaxKind.BreakStatement */: return emitBreakStatement(node); - case 247 /* ReturnStatement */: + case 247 /* SyntaxKind.ReturnStatement */: return emitReturnStatement(node); - case 248 /* WithStatement */: + case 248 /* SyntaxKind.WithStatement */: return emitWithStatement(node); - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: return emitSwitchStatement(node); - case 250 /* LabeledStatement */: + case 250 /* SyntaxKind.LabeledStatement */: return emitLabeledStatement(node); - case 251 /* ThrowStatement */: + case 251 /* SyntaxKind.ThrowStatement */: return emitThrowStatement(node); - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: return emitTryStatement(node); - case 253 /* DebuggerStatement */: + case 253 /* SyntaxKind.DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 254 /* VariableDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: return emitVariableDeclaration(node); - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: return emitVariableDeclarationList(node); - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: return emitFunctionDeclaration(node); - case 257 /* ClassDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: return emitClassDeclaration(node); - case 258 /* InterfaceDeclaration */: + case 258 /* SyntaxKind.InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 260 /* EnumDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return emitEnumDeclaration(node); - case 261 /* ModuleDeclaration */: + case 261 /* SyntaxKind.ModuleDeclaration */: return emitModuleDeclaration(node); - case 262 /* ModuleBlock */: + case 262 /* SyntaxKind.ModuleBlock */: return emitModuleBlock(node); - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: return emitCaseBlock(node); - case 264 /* NamespaceExportDeclaration */: + case 264 /* SyntaxKind.NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: return emitImportDeclaration(node); - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: return emitImportClause(node); - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: return emitNamespaceImport(node); - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: return emitNamespaceExport(node); - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: return emitNamedImports(node); - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: return emitImportSpecifier(node); - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: return emitExportAssignment(node); - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return emitExportDeclaration(node); - case 273 /* NamedExports */: + case 273 /* SyntaxKind.NamedExports */: return emitNamedExports(node); - case 275 /* ExportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: return emitExportSpecifier(node); - case 293 /* AssertClause */: + case 293 /* SyntaxKind.AssertClause */: return emitAssertClause(node); - case 294 /* AssertEntry */: + case 294 /* SyntaxKind.AssertEntry */: return emitAssertEntry(node); - case 276 /* MissingDeclaration */: + case 276 /* SyntaxKind.MissingDeclaration */: return; // Module references - case 277 /* ExternalModuleReference */: + case 277 /* SyntaxKind.ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) - case 11 /* JsxText */: + case 11 /* SyntaxKind.JsxText */: return emitJsxText(node); - case 280 /* JsxOpeningElement */: - case 283 /* JsxOpeningFragment */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 283 /* SyntaxKind.JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 281 /* JsxClosingElement */: - case 284 /* JsxClosingFragment */: + case 281 /* SyntaxKind.JsxClosingElement */: + case 284 /* SyntaxKind.JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 285 /* JsxAttribute */: + case 285 /* SyntaxKind.JsxAttribute */: return emitJsxAttribute(node); - case 286 /* JsxAttributes */: + case 286 /* SyntaxKind.JsxAttributes */: return emitJsxAttributes(node); - case 287 /* JsxSpreadAttribute */: + case 287 /* SyntaxKind.JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 288 /* JsxExpression */: + case 288 /* SyntaxKind.JsxExpression */: return emitJsxExpression(node); // Clauses - case 289 /* CaseClause */: + case 289 /* SyntaxKind.CaseClause */: return emitCaseClause(node); - case 290 /* DefaultClause */: + case 290 /* SyntaxKind.DefaultClause */: return emitDefaultClause(node); - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: return emitHeritageClause(node); - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: return emitCatchClause(node); // Property assignments - case 296 /* PropertyAssignment */: + case 296 /* SyntaxKind.PropertyAssignment */: return emitPropertyAssignment(node); - case 297 /* ShorthandPropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 298 /* SpreadAssignment */: + case 298 /* SyntaxKind.SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 299 /* EnumMember */: + case 299 /* SyntaxKind.EnumMember */: return emitEnumMember(node); // Unparsed - case 300 /* UnparsedPrologue */: + case 300 /* SyntaxKind.UnparsedPrologue */: return writeUnparsedNode(node); - case 307 /* UnparsedSource */: - case 301 /* UnparsedPrepend */: + case 307 /* SyntaxKind.UnparsedSource */: + case 301 /* SyntaxKind.UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 302 /* UnparsedText */: - case 303 /* UnparsedInternalText */: + case 302 /* SyntaxKind.UnparsedText */: + case 303 /* SyntaxKind.UnparsedInternalText */: return emitUnparsedTextLike(node); - case 304 /* UnparsedSyntheticReference */: + case 304 /* SyntaxKind.UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Top-level nodes - case 305 /* SourceFile */: + case 305 /* SyntaxKind.SourceFile */: return emitSourceFile(node); - case 306 /* Bundle */: + case 306 /* SyntaxKind.Bundle */: return ts.Debug.fail("Bundles should be printed using printBundle"); // SyntaxKind.UnparsedSource (handled above) - case 308 /* InputFiles */: + case 308 /* SyntaxKind.InputFiles */: return ts.Debug.fail("InputFiles should not be printed"); // JSDoc nodes (only used in codefixes currently) - case 309 /* JSDocTypeExpression */: + case 309 /* SyntaxKind.JSDocTypeExpression */: return emitJSDocTypeExpression(node); - case 310 /* JSDocNameReference */: + case 310 /* SyntaxKind.JSDocNameReference */: return emitJSDocNameReference(node); - case 312 /* JSDocAllType */: + case 312 /* SyntaxKind.JSDocAllType */: return writePunctuation("*"); - case 313 /* JSDocUnknownType */: + case 313 /* SyntaxKind.JSDocUnknownType */: return writePunctuation("?"); - case 314 /* JSDocNullableType */: + case 314 /* SyntaxKind.JSDocNullableType */: return emitJSDocNullableType(node); - case 315 /* JSDocNonNullableType */: + case 315 /* SyntaxKind.JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 316 /* JSDocOptionalType */: + case 316 /* SyntaxKind.JSDocOptionalType */: return emitJSDocOptionalType(node); - case 317 /* JSDocFunctionType */: + case 317 /* SyntaxKind.JSDocFunctionType */: return emitJSDocFunctionType(node); - case 186 /* RestType */: - case 318 /* JSDocVariadicType */: + case 186 /* SyntaxKind.RestType */: + case 318 /* SyntaxKind.JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); - case 319 /* JSDocNamepathType */: + case 319 /* SyntaxKind.JSDocNamepathType */: return; - case 320 /* JSDoc */: + case 320 /* SyntaxKind.JSDoc */: return emitJSDoc(node); - case 322 /* JSDocTypeLiteral */: + case 322 /* SyntaxKind.JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 323 /* JSDocSignature */: + case 323 /* SyntaxKind.JSDocSignature */: return emitJSDocSignature(node); - case 327 /* JSDocTag */: - case 332 /* JSDocClassTag */: - case 337 /* JSDocOverrideTag */: + case 327 /* SyntaxKind.JSDocTag */: + case 332 /* SyntaxKind.JSDocClassTag */: + case 337 /* SyntaxKind.JSDocOverrideTag */: return emitJSDocSimpleTag(node); - case 328 /* JSDocAugmentsTag */: - case 329 /* JSDocImplementsTag */: + case 328 /* SyntaxKind.JSDocAugmentsTag */: + case 329 /* SyntaxKind.JSDocImplementsTag */: return emitJSDocHeritageTag(node); - case 330 /* JSDocAuthorTag */: - case 331 /* JSDocDeprecatedTag */: + case 330 /* SyntaxKind.JSDocAuthorTag */: + case 331 /* SyntaxKind.JSDocDeprecatedTag */: return; // SyntaxKind.JSDocClassTag (see JSDocTag, above) - case 333 /* JSDocPublicTag */: - case 334 /* JSDocPrivateTag */: - case 335 /* JSDocProtectedTag */: - case 336 /* JSDocReadonlyTag */: + case 333 /* SyntaxKind.JSDocPublicTag */: + case 334 /* SyntaxKind.JSDocPrivateTag */: + case 335 /* SyntaxKind.JSDocProtectedTag */: + case 336 /* SyntaxKind.JSDocReadonlyTag */: return; - case 338 /* JSDocCallbackTag */: + case 338 /* SyntaxKind.JSDocCallbackTag */: return emitJSDocCallbackTag(node); // SyntaxKind.JSDocEnumTag (see below) - case 340 /* JSDocParameterTag */: - case 347 /* JSDocPropertyTag */: + case 340 /* SyntaxKind.JSDocParameterTag */: + case 347 /* SyntaxKind.JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 339 /* JSDocEnumTag */: - case 341 /* JSDocReturnTag */: - case 342 /* JSDocThisTag */: - case 343 /* JSDocTypeTag */: + case 339 /* SyntaxKind.JSDocEnumTag */: + case 341 /* SyntaxKind.JSDocReturnTag */: + case 342 /* SyntaxKind.JSDocThisTag */: + case 343 /* SyntaxKind.JSDocTypeTag */: return emitJSDocSimpleTypedTag(node); - case 344 /* JSDocTemplateTag */: + case 344 /* SyntaxKind.JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 345 /* JSDocTypedefTag */: + case 345 /* SyntaxKind.JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 346 /* JSDocSeeTag */: + case 346 /* SyntaxKind.JSDocSeeTag */: return emitJSDocSeeTag(node); // SyntaxKind.JSDocPropertyTag (see JSDocParameterTag, above) // Transformation nodes - case 349 /* NotEmittedStatement */: - case 353 /* EndOfDeclarationMarker */: - case 352 /* MergeDeclarationMarker */: + case 349 /* SyntaxKind.NotEmittedStatement */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: return; } if (ts.isExpression(node)) { - hint = 1 /* Expression */; + hint = 1 /* EmitHint.Expression */; if (substituteNode !== ts.noEmitSubstitution) { var substitute = substituteNode(hint, node) || node; if (substitute !== node) { @@ -112345,101 +112783,101 @@ var ts; } } } - if (hint === 1 /* Expression */) { + if (hint === 1 /* EmitHint.Expression */) { switch (node.kind) { // Literals - case 8 /* NumericLiteral */: - case 9 /* BigIntLiteral */: + case 8 /* SyntaxKind.NumericLiteral */: + case 9 /* SyntaxKind.BigIntLiteral */: return emitNumericOrBigIntLiteral(node); - case 10 /* StringLiteral */: - case 13 /* RegularExpressionLiteral */: - case 14 /* NoSubstitutionTemplateLiteral */: + case 10 /* SyntaxKind.StringLiteral */: + case 13 /* SyntaxKind.RegularExpressionLiteral */: + case 14 /* SyntaxKind.NoSubstitutionTemplateLiteral */: return emitLiteral(node, /*jsxAttributeEscape*/ false); // Identifiers - case 79 /* Identifier */: + case 79 /* SyntaxKind.Identifier */: return emitIdentifier(node); - case 80 /* PrivateIdentifier */: + case 80 /* SyntaxKind.PrivateIdentifier */: return emitPrivateIdentifier(node); // Expressions - case 204 /* ArrayLiteralExpression */: + case 204 /* SyntaxKind.ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 205 /* ObjectLiteralExpression */: + case 205 /* SyntaxKind.ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 206 /* PropertyAccessExpression */: + case 206 /* SyntaxKind.PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 207 /* ElementAccessExpression */: + case 207 /* SyntaxKind.ElementAccessExpression */: return emitElementAccessExpression(node); - case 208 /* CallExpression */: + case 208 /* SyntaxKind.CallExpression */: return emitCallExpression(node); - case 209 /* NewExpression */: + case 209 /* SyntaxKind.NewExpression */: return emitNewExpression(node); - case 210 /* TaggedTemplateExpression */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 212 /* ParenthesizedExpression */: + case 212 /* SyntaxKind.ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 213 /* FunctionExpression */: + case 213 /* SyntaxKind.FunctionExpression */: return emitFunctionExpression(node); - case 214 /* ArrowFunction */: + case 214 /* SyntaxKind.ArrowFunction */: return emitArrowFunction(node); - case 215 /* DeleteExpression */: + case 215 /* SyntaxKind.DeleteExpression */: return emitDeleteExpression(node); - case 216 /* TypeOfExpression */: + case 216 /* SyntaxKind.TypeOfExpression */: return emitTypeOfExpression(node); - case 217 /* VoidExpression */: + case 217 /* SyntaxKind.VoidExpression */: return emitVoidExpression(node); - case 218 /* AwaitExpression */: + case 218 /* SyntaxKind.AwaitExpression */: return emitAwaitExpression(node); - case 219 /* PrefixUnaryExpression */: + case 219 /* SyntaxKind.PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 220 /* PostfixUnaryExpression */: + case 220 /* SyntaxKind.PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 221 /* BinaryExpression */: + case 221 /* SyntaxKind.BinaryExpression */: return emitBinaryExpression(node); - case 222 /* ConditionalExpression */: + case 222 /* SyntaxKind.ConditionalExpression */: return emitConditionalExpression(node); - case 223 /* TemplateExpression */: + case 223 /* SyntaxKind.TemplateExpression */: return emitTemplateExpression(node); - case 224 /* YieldExpression */: + case 224 /* SyntaxKind.YieldExpression */: return emitYieldExpression(node); - case 225 /* SpreadElement */: + case 225 /* SyntaxKind.SpreadElement */: return emitSpreadElement(node); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return emitClassExpression(node); - case 227 /* OmittedExpression */: + case 227 /* SyntaxKind.OmittedExpression */: return; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: return emitAsExpression(node); - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: return emitNonNullExpression(node); - case 228 /* ExpressionWithTypeArguments */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 231 /* MetaProperty */: + case 231 /* SyntaxKind.MetaProperty */: return emitMetaProperty(node); - case 232 /* SyntheticExpression */: + case 232 /* SyntaxKind.SyntheticExpression */: return ts.Debug.fail("SyntheticExpression should never be printed."); // JSX - case 278 /* JsxElement */: + case 278 /* SyntaxKind.JsxElement */: return emitJsxElement(node); - case 279 /* JsxSelfClosingElement */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 282 /* JsxFragment */: + case 282 /* SyntaxKind.JsxFragment */: return emitJsxFragment(node); // Synthesized list - case 348 /* SyntaxList */: + case 348 /* SyntaxKind.SyntaxList */: return ts.Debug.fail("SyntaxList should not be printed"); // Transformation nodes - case 349 /* NotEmittedStatement */: + case 349 /* SyntaxKind.NotEmittedStatement */: return; - case 350 /* PartiallyEmittedExpression */: + case 350 /* SyntaxKind.PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 351 /* CommaListExpression */: + case 351 /* SyntaxKind.CommaListExpression */: return emitCommaList(node); - case 352 /* MergeDeclarationMarker */: - case 353 /* EndOfDeclarationMarker */: + case 352 /* SyntaxKind.MergeDeclarationMarker */: + case 353 /* SyntaxKind.EndOfDeclarationMarker */: return; - case 354 /* SyntheticReferenceExpression */: + case 354 /* SyntaxKind.SyntheticReferenceExpression */: return ts.Debug.fail("SyntheticReferenceExpression should not be printed"); } } @@ -112447,7 +112885,7 @@ var ts; return writeTokenNode(node, writeKeyword); if (ts.isTokenKind(node.kind)) return writeTokenNode(node, writePunctuation); - ts.Debug.fail("Unhandled SyntaxKind: " + ts.Debug.formatSyntaxKind(node.kind) + "."); + ts.Debug.fail("Unhandled SyntaxKind: ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); } function emitMappedTypeParameter(node) { emit(node.name); @@ -112457,7 +112895,7 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { - var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, hint, node); + var pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, hint, node); ts.Debug.assertIsDefined(lastSubstitution); node = lastSubstitution; lastSubstitution = undefined; @@ -112487,7 +112925,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 306 /* Bundle */ ? node : undefined; + var bundle = node.kind === 306 /* SyntaxKind.Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -112529,7 +112967,7 @@ var ts; writeLines(helper.text(makeFileLevelOptimisticUniqueName)); } if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* EmitHelpers */, data: helper.name }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers" /* BundleFileSectionKind.EmitHelpers */, data: helper.name }); helpersEmitted = true; } } @@ -112557,7 +112995,7 @@ var ts; function emitLiteral(node, jsxAttributeEscape) { var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape); if ((printerOptions.sourceMap || printerOptions.inlineSourceMap) - && (node.kind === 10 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { + && (node.kind === 10 /* SyntaxKind.StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writeLiteral(text); } else { @@ -112587,9 +113025,9 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* UnparsedText */ ? - "text" /* Text */ : - "internal" /* Internal */); + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 302 /* SyntaxKind.UnparsedText */ ? + "text" /* BundleFileSectionKind.Text */ : + "internal" /* BundleFileSectionKind.Internal */); } } // SyntaxKind.UnparsedSyntheticReference @@ -112608,25 +113046,25 @@ var ts; // function emitSnippetNode(hint, node, snippet) { switch (snippet.kind) { - case 1 /* Placeholder */: + case 1 /* SnippetKind.Placeholder */: emitPlaceholder(hint, node, snippet); break; - case 0 /* TabStop */: + case 0 /* SnippetKind.TabStop */: emitTabStop(hint, node, snippet); break; } } function emitPlaceholder(hint, node, snippet) { - nonEscapingWrite("${" + snippet.order + ":"); // `${2:` + nonEscapingWrite("${".concat(snippet.order, ":")); // `${2:` pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...` nonEscapingWrite("}"); // `}` // `${2:...}` } function emitTabStop(hint, node, snippet) { // A tab stop should only be attached to an empty node, i.e. a node that doesn't emit any text. - ts.Debug.assert(node.kind === 236 /* EmptyStatement */, "A tab stop cannot be attached to a node of kind " + ts.Debug.formatSyntaxKind(node.kind) + "."); - ts.Debug.assert(hint !== 5 /* EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); - nonEscapingWrite("$" + snippet.order); + ts.Debug.assert(node.kind === 236 /* SyntaxKind.EmptyStatement */, "A tab stop cannot be attached to a node of kind ".concat(ts.Debug.formatSyntaxKind(node.kind), ".")); + ts.Debug.assert(hint !== 5 /* EmitHint.EmbeddedStatement */, "A tab stop cannot be attached to an embedded statement."); + nonEscapingWrite("$".concat(snippet.order)); } // // Identifiers @@ -112634,7 +113072,7 @@ var ts; function emitIdentifier(node) { var writeText = node.symbol ? writeSymbol : write; writeText(getTextOfNode(node, /*includeTrivia*/ false), node.symbol); - emitList(node, node.typeArguments, 53776 /* TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments + emitList(node, node.typeArguments, 53776 /* ListFormat.TypeParameters */); // Call emitList directly since it could be an array of TypeParameterDeclarations _or_ type arguments } // // Names @@ -112649,7 +113087,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -112685,7 +113123,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 317 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 317 /* SyntaxKind.JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -112746,7 +113184,7 @@ var ts; } function emitAccessorDeclaration(node) { emitDecoratorsAndModifiers(node, node.modifiers); - writeKeyword(node.kind === 172 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 172 /* SyntaxKind.GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -112851,8 +113289,8 @@ var ts; } function emitTypeLiteral(node) { writePunctuation("{"); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineTypeLiteralMembers */ : 32897 /* MultiLineTypeLiteralMembers */; - emitList(node, node.members, flags | 524288 /* NoSpaceIfEmpty */); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineTypeLiteralMembers */ : 32897 /* ListFormat.MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 524288 /* ListFormat.NoSpaceIfEmpty */); writePunctuation("}"); } function emitArrayType(node) { @@ -112865,16 +113303,16 @@ var ts; emit(node.type); } function emitTupleType(node) { - emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node); - var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */; - emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); - emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.pos, writePunctuation, node); + var flags = ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 528 /* ListFormat.SingleLineTupleTypeElements */ : 657 /* ListFormat.MultiLineTupleTypeElements */; + emitList(node, node.elements, flags | 524288 /* ListFormat.NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.elements.end, writePunctuation, node); } function emitNamedTupleMember(node) { emit(node.dotDotDotToken); emit(node.name); emit(node.questionToken); - emitTokenWithComment(58 /* ColonToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.name.end, writePunctuation, node); writeSpace(); emit(node.type); } @@ -112883,10 +113321,10 @@ var ts; writePunctuation("?"); } function emitUnionType(node) { - emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); + emitList(node, node.types, 516 /* ListFormat.UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType); } function emitIntersectionType(node) { - emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); + emitList(node, node.types, 520 /* ListFormat.IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType); } function emitConditionalType(node) { emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType); @@ -112919,7 +113357,7 @@ var ts; function emitTypeOperator(node) { writeTokenText(node.operator, writeKeyword); writeSpace(); - var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ? + var parenthesizerRule = node.operator === 145 /* SyntaxKind.ReadonlyKeyword */ ? parenthesizer.parenthesizeOperandOfReadonlyTypeOperator : parenthesizer.parenthesizeOperandOfTypeOperator; emit(node.type, parenthesizerRule); @@ -112933,7 +113371,7 @@ var ts; function emitMappedType(node) { var emitFlags = ts.getEmitFlags(node); writePunctuation("{"); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { @@ -112942,13 +113380,13 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 145 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 145 /* SyntaxKind.ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* EmitHint.MappedTypeParameter */, node.typeParameter); if (node.nameType) { writeSpace(); writeKeyword("as"); @@ -112958,7 +113396,7 @@ var ts; writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 57 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* SyntaxKind.QuestionToken */) { writePunctuation("?"); } } @@ -112966,14 +113404,14 @@ var ts; writeSpace(); emit(node.type); writeTrailingSemicolon(); - if (emitFlags & 1 /* SingleLine */) { + if (emitFlags & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else { writeLine(); decreaseIndent(); } - emitList(node, node.members, 2 /* PreserveLines */); + emitList(node, node.members, 2 /* ListFormat.PreserveLines */); writePunctuation("}"); } function emitLiteralType(node) { @@ -112981,7 +113419,7 @@ var ts; } function emitTemplateType(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitImportTypeNode(node) { if (node.isTypeOf) { @@ -113000,7 +113438,7 @@ var ts; writePunctuation(":"); writeSpace(); var elements = node.assertions.assertClause.elements; - emitList(node.assertions.assertClause, elements, 526226 /* ImportClauseEntries */); + emitList(node.assertions.assertClause, elements, 526226 /* ListFormat.ImportClauseEntries */); writeSpace(); writePunctuation("}"); } @@ -113016,12 +113454,12 @@ var ts; // function emitObjectBindingPattern(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* ObjectBindingPatternElements */); + emitList(node, node.elements, 525136 /* ListFormat.ObjectBindingPatternElements */); writePunctuation("}"); } function emitArrayBindingPattern(node) { writePunctuation("["); - emitList(node, node.elements, 524880 /* ArrayBindingPatternElements */); + emitList(node, node.elements, 524880 /* ListFormat.ArrayBindingPatternElements */); writePunctuation("]"); } function emitBindingElement(node) { @@ -113039,29 +113477,29 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 8914 /* ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + emitExpressionList(node, elements, 8914 /* ListFormat.ArrayLiteralExpressionElements */ | preferNewLine, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitObjectLiteralExpression(node) { ts.forEach(node.properties, generateMemberNames); - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } - var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + var preferNewLine = node.multiLine ? 65536 /* ListFormat.PreferNewLine */ : 0 /* ListFormat.None */; + var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ScriptTarget.ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* ListFormat.AllowTrailingComma */ : 0 /* ListFormat.None */; + emitList(node, node.properties, 526226 /* ListFormat.ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); } } function emitPropertyAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); - var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* DotToken */), node.expression.end, node.name.pos); + var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24 /* SyntaxKind.DotToken */), node.expression.end, node.name.pos); var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); var linesAfterDot = getLinesBetweenNodes(node, token, node.name); writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + var shouldEmitDotDot = token.kind !== 28 /* SyntaxKind.QuestionDotToken */ && mayNeedDotDotForPropertyAccess(node.expression) && !writer.hasTrailingComment() && !writer.hasTrailingWhitespace(); @@ -113087,7 +113525,7 @@ var ts; var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true, /*jsxAttributeEscape*/ false); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* SyntaxKind.DotToken */)); } else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer @@ -113100,12 +113538,12 @@ var ts; function emitElementAccessExpression(node) { emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess); emit(node.questionDotToken); - emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(22 /* SyntaxKind.OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); - emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); + emitTokenWithComment(23 /* SyntaxKind.CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -113118,17 +113556,17 @@ var ts; } emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 2576 /* ListFormat.CallExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitNewExpression(node) { - emitTokenWithComment(103 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(103 /* SyntaxKind.NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfNew); emitTypeArguments(node, node.typeArguments); - emitExpressionList(node, node.arguments, 18960 /* NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitExpressionList(node, node.arguments, 18960 /* ListFormat.NewExpressionArguments */, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitTaggedTemplateExpression(node) { - var indirectCall = ts.getEmitFlags(node) & 536870912 /* IndirectCall */; + var indirectCall = ts.getEmitFlags(node) & 536870912 /* EmitFlags.IndirectCall */; if (indirectCall) { writePunctuation("("); writeLiteral("0"); @@ -113150,12 +113588,12 @@ var ts; emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitParenthesizedExpression(node) { - var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); + var openParenPos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, node.pos, writePunctuation, node); var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression, /*parenthesizerRules*/ undefined); writeLineSeparatorsAfter(node.expression, node); decreaseIndentIf(indented); - emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { generateNameIfNeeded(node.name); @@ -113173,22 +113611,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(89 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(89 /* SyntaxKind.DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitTypeOfExpression(node) { - emitTokenWithComment(112 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(112 /* SyntaxKind.TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitVoidExpression(node) { - emitTokenWithComment(114 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(114 /* SyntaxKind.VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } function emitAwaitExpression(node) { - emitTokenWithComment(132 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(132 /* SyntaxKind.AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeOperandOfPrefixUnary); } @@ -113213,9 +113651,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 219 /* PrefixUnaryExpression */ - && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) - || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); + return operand.kind === 219 /* SyntaxKind.PrefixUnaryExpression */ + && ((node.operator === 39 /* SyntaxKind.PlusToken */ && (operand.operator === 39 /* SyntaxKind.PlusToken */ || operand.operator === 45 /* SyntaxKind.PlusPlusToken */)) + || (node.operator === 40 /* SyntaxKind.MinusToken */ && (operand.operator === 40 /* SyntaxKind.MinusToken */ || operand.operator === 46 /* SyntaxKind.MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand, parenthesizer.parenthesizeOperandOfPostfixUnary); @@ -113256,12 +113694,12 @@ var ts; return maybeEmitExpression(next, parent, "left"); } function onOperator(operatorToken, _state, node) { - var isCommaOperator = operatorToken.kind !== 27 /* CommaToken */; + var isCommaOperator = operatorToken.kind !== 27 /* SyntaxKind.CommaToken */; var linesBeforeOperator = getLinesBetweenNodes(node, node.left, operatorToken); var linesAfterOperator = getLinesBetweenNodes(node, operatorToken, node.right); writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(operatorToken.pos); - writeTokenNode(operatorToken, operatorToken.kind === 101 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(operatorToken, operatorToken.kind === 101 /* SyntaxKind.InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); } @@ -113292,11 +113730,11 @@ var ts; var parenthesizerRule = side === "left" ? parenthesizer.getParenthesizeLeftSideOfBinaryForOperator(parent.operatorToken.kind) : parenthesizer.getParenthesizeRightSideOfBinaryForOperator(parent.operatorToken.kind); - var pipelinePhase = getPipelinePhase(0 /* Notification */, 1 /* Expression */, next); + var pipelinePhase = getPipelinePhase(0 /* PipelinePhase.Notification */, 1 /* EmitHint.Expression */, next); if (pipelinePhase === pipelineEmitWithSubstitution) { ts.Debug.assertIsDefined(lastSubstitution); next = parenthesizerRule(ts.cast(lastSubstitution, ts.isExpression)); - pipelinePhase = getNextPipelinePhase(1 /* Substitution */, 1 /* Expression */, next); + pipelinePhase = getNextPipelinePhase(1 /* PipelinePhase.Substitution */, 1 /* EmitHint.Expression */, next); lastSubstitution = undefined; } if (pipelinePhase === pipelineEmitWithComments || @@ -113307,7 +113745,7 @@ var ts; } } currentParenthesizerRule = parenthesizerRule; - pipelinePhase(1 /* Expression */, next); + pipelinePhase(1 /* EmitHint.Expression */, next); } } function emitConditionalExpression(node) { @@ -113329,15 +113767,15 @@ var ts; } function emitTemplateExpression(node) { emit(node.head); - emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); + emitList(node, node.templateSpans, 262144 /* ListFormat.TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(125 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(125 /* SyntaxKind.YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsiAndDisallowedComma); } function emitSpreadElement(node) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitClassExpression(node) { @@ -113380,10 +113818,10 @@ var ts; emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); } function emitBlockStatements(node, forceSingleLine) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); - var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 768 /* SingleLineBlockStatements */ : 129 /* MultiLineBlockStatements */; + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, /*contextNode*/ node); + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* EmitFlags.SingleLine */ ? 768 /* ListFormat.SingleLineBlockStatements */ : 129 /* ListFormat.MultiLineBlockStatements */; emitList(node, node.statements, format); - emitTokenWithComment(19 /* CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* MultiLine */)); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.statements.end, writePunctuation, /*contextNode*/ node, /*indentLeading*/ !!(format & 1 /* ListFormat.MultiLine */)); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -113409,16 +113847,16 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(99 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(99 /* SyntaxKind.IfKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node, node.thenStatement, node.elseStatement); - emitTokenWithComment(91 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 239 /* IfStatement */) { + emitTokenWithComment(91 /* SyntaxKind.ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 239 /* SyntaxKind.IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -113428,14 +113866,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(115 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(115 /* SyntaxKind.WhileKeyword */, startPos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(90 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(90 /* SyntaxKind.DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement) && !preserveSourceNewlines) { writeSpace(); @@ -113451,45 +113889,45 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); + var pos = emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.initializer ? node.initializer.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.condition); - pos = emitTokenWithComment(26 /* SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); + pos = emitTokenWithComment(26 /* SyntaxKind.SemicolonToken */, node.condition ? node.condition.end : pos, writePunctuation, node); emitExpressionWithLeadingSpace(node.incrementor); - emitTokenWithComment(21 /* CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.incrementor ? node.incrementor.end : pos, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(101 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(101 /* SyntaxKind.InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(97 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(97 /* SyntaxKind.ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(160 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(160 /* SyntaxKind.OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { emit(node); } else { @@ -113498,12 +113936,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(86 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(86 /* SyntaxKind.ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(81 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* SyntaxKind.BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -113526,13 +113964,13 @@ var ts; } pos = writeTokenText(token, writer, pos); if (isSimilarNode && contextNode.end !== pos) { - var isJsxExprContext = contextNode.kind === 288 /* JsxExpression */; + var isJsxExprContext = contextNode.kind === 288 /* SyntaxKind.JsxExpression */; emitTrailingCommentsOfPosition(pos, /*prefixSpace*/ !isJsxExprContext, /*forceNoNewline*/ isJsxExprContext); } return pos; } function commentWillEmitNewLine(node) { - return node.kind === 2 /* SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; + return node.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */ || !!node.hasTrailingNewLine; } function willEmitLeadingNewLine(node) { if (!currentSourceFile) @@ -113572,40 +114010,40 @@ var ts; return parenthesizeExpressionForNoAsi(parenthesizer.parenthesizeExpressionForDisallowedComma(node)); } function emitReturnStatement(node) { - emitTokenWithComment(105 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(105 /* SyntaxKind.ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression && parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(116 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(116 /* SyntaxKind.WithKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(107 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(107 /* SyntaxKind.SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); - emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.expression.end, writePunctuation, node); writeSpace(); emit(node.caseBlock); } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(109 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* SyntaxKind.ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(parenthesizeExpressionForNoAsi(node.expression), parenthesizeExpressionForNoAsi); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(111 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(111 /* SyntaxKind.TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -113614,13 +114052,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock); - emitTokenWithComment(96 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(96 /* SyntaxKind.FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(87 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(87 /* SyntaxKind.DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -113636,7 +114074,7 @@ var ts; function emitVariableDeclarationList(node) { writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var"); writeSpace(); - emitList(node, node.declarations, 528 /* VariableDeclarationList */); + emitList(node, node.declarations, 528 /* ListFormat.VariableDeclarationList */); } function emitFunctionDeclaration(node) { emitFunctionDeclarationOrExpression(node); @@ -113653,7 +114091,7 @@ var ts; var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } @@ -113690,7 +114128,7 @@ var ts; // * The body is explicitly marked as multi-line. // * A non-synthesized body's start and end position are on different lines. // * Any statement in the body starts on a new line. - if (ts.getEmitFlags(body) & 1 /* SingleLine */) { + if (ts.getEmitFlags(body) & 1 /* EmitFlags.SingleLine */) { return true; } if (body.multiLine) { @@ -113699,14 +114137,14 @@ var ts; if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (getLeadingLineTerminatorCount(body, ts.firstOrUndefined(body.statements), 2 /* PreserveLines */) - || getClosingLineTerminatorCount(body, ts.lastOrUndefined(body.statements), 2 /* PreserveLines */, body.statements)) { + if (getLeadingLineTerminatorCount(body, ts.firstOrUndefined(body.statements), 2 /* ListFormat.PreserveLines */) + || getClosingLineTerminatorCount(body, ts.lastOrUndefined(body.statements), 2 /* ListFormat.PreserveLines */, body.statements)) { return false; } var previousStatement; for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { var statement = _b[_a]; - if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) { + if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* ListFormat.PreserveLines */) > 0) { return false; } previousStatement = statement; @@ -113723,7 +114161,7 @@ var ts; : emitBlockFunctionBodyWorker; emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); decreaseIndent(); - writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body); + writeToken(19 /* SyntaxKind.CloseBraceToken */, body.statements.end, writePunctuation, body); onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body); } function emitBlockFunctionBodyOnSingleLine(body) { @@ -113736,11 +114174,11 @@ var ts; emitHelpers(body); if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) { decreaseIndent(); - emitList(body, body.statements, 768 /* SingleLineFunctionBodyStatements */); + emitList(body, body.statements, 768 /* ListFormat.SingleLineFunctionBodyStatements */); increaseIndent(); } else { - emitList(body, body.statements, 1 /* MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); + emitList(body, body.statements, 1 /* ListFormat.MultiLineFunctionBodyStatements */, /*parenthesizerRule*/ undefined, statementOffset); } } function emitClassDeclaration(node) { @@ -113754,15 +114192,15 @@ var ts; writeSpace(); emitIdentifierName(node.name); } - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* EmitFlags.Indented */; if (indentedFlag) { increaseIndent(); } emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 0 /* ClassHeritageClauses */); + emitList(node, node.heritageClauses, 0 /* ListFormat.ClassHeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* ClassMembers */); + emitList(node, node.members, 129 /* ListFormat.ClassMembers */); writePunctuation("}"); if (indentedFlag) { decreaseIndent(); @@ -113774,10 +114212,10 @@ var ts; writeSpace(); emit(node.name); emitTypeParameters(node, node.typeParameters); - emitList(node, node.heritageClauses, 512 /* HeritageClauses */); + emitList(node, node.heritageClauses, 512 /* ListFormat.HeritageClauses */); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 129 /* InterfaceMembers */); + emitList(node, node.members, 129 /* ListFormat.InterfaceMembers */); writePunctuation("}"); } function emitTypeAliasDeclaration(node) { @@ -113799,13 +114237,13 @@ var ts; emit(node.name); writeSpace(); writePunctuation("{"); - emitList(node, node.members, 145 /* EnumMembers */); + emitList(node, node.members, 145 /* ListFormat.EnumMembers */); writePunctuation("}"); } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 1024 /* GlobalAugmentation */) { - writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); + if (~node.flags & 1024 /* NodeFlags.GlobalAugmentation */) { + writeKeyword(node.flags & 16 /* NodeFlags.Namespace */ ? "namespace" : "module"); writeSpace(); } emit(node.name); @@ -113827,27 +114265,27 @@ var ts; popNameGenerationScope(node); } function emitCaseBlock(node) { - emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); - emitList(node, node.clauses, 129 /* CaseBlockClauses */); - emitTokenWithComment(19 /* CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); + emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); + emitList(node, node.clauses, 129 /* ListFormat.CaseBlockClauses */); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, node.clauses.end, writePunctuation, node, /*indentLeading*/ true); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -113856,12 +114294,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(100 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(100 /* SyntaxKind.ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(156 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -113872,20 +114310,20 @@ var ts; } function emitImportClause(node) { if (node.isTypeOnly) { - emitTokenWithComment(152 /* TypeKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, node.pos, writeKeyword, node); writeSpace(); } emit(node.name); if (node.name && node.namedBindings) { - emitTokenWithComment(27 /* CommaToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, node.name.end, writePunctuation, node); writeSpace(); } emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -113896,37 +114334,37 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(63 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(88 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression, node.isExportEquals ? - parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* EqualsToken */) : + parenthesizer.getParenthesizeRightSideOfBinaryForOperator(63 /* SyntaxKind.EqualsToken */) : parenthesizer.parenthesizeExpressionOfExportDefault); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isTypeOnly) { - nextPos = emitTokenWithComment(152 /* TypeKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(152 /* SyntaxKind.TypeKeyword */, nextPos, writeKeyword, node); writeSpace(); } if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(156 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(156 /* SyntaxKind.FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } @@ -113936,10 +114374,10 @@ var ts; writeTrailingSemicolon(); } function emitAssertClause(node) { - emitTokenWithComment(129 /* AssertKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(129 /* SyntaxKind.AssertKeyword */, node.pos, writeKeyword, node); writeSpace(); var elements = node.elements; - emitList(node, elements, 526226 /* ImportClauseEntries */); + emitList(node, elements, 526226 /* ListFormat.ImportClauseEntries */); } function emitAssertEntry(node) { emit(node.name); @@ -113947,26 +114385,26 @@ var ts; writeSpace(); var value = node.value; /** @see {emitPropertyAssignment} */ - if ((ts.getEmitFlags(value) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(value) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(value); emitTrailingCommentsOfPosition(commentRange.pos); } emit(value); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(93 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(93 /* SyntaxKind.ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(127 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(142 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(142 /* SyntaxKind.NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); } function emitNamespaceExport(node) { - var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* SyntaxKind.AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -113978,7 +114416,7 @@ var ts; } function emitNamedImportsOrExports(node) { writePunctuation("{"); - emitList(node, node.elements, 525136 /* NamedImportsOrExportsElements */); + emitList(node, node.elements, 525136 /* ListFormat.NamedImportsOrExportsElements */); writePunctuation("}"); } function emitImportOrExportSpecifier(node) { @@ -113989,7 +114427,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(127 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(127 /* SyntaxKind.AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -114008,7 +114446,7 @@ var ts; // function emitJsxElement(node) { emit(node.openingElement); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingElement); } function emitJsxSelfClosingElement(node) { @@ -114021,7 +114459,7 @@ var ts; } function emitJsxFragment(node) { emit(node.openingFragment); - emitList(node, node.children, 262144 /* JsxElementOrFragmentChildren */); + emitList(node, node.children, 262144 /* ListFormat.JsxElementOrFragmentChildren */); emit(node.closingFragment); } function emitJsxOpeningElementOrFragment(node) { @@ -114050,7 +114488,7 @@ var ts; writePunctuation(">"); } function emitJsxAttributes(node) { - emitList(node, node.properties, 262656 /* JsxElementAttributes */); + emitList(node, node.properties, 262656 /* ListFormat.JsxElementAttributes */); } function emitJsxAttribute(node) { emit(node.name); @@ -114081,17 +114519,17 @@ var ts; if (isMultiline) { writer.increaseIndent(); } - var end = emitTokenWithComment(18 /* OpenBraceToken */, node.pos, writePunctuation, node); + var end = emitTokenWithComment(18 /* SyntaxKind.OpenBraceToken */, node.pos, writePunctuation, node); emit(node.dotDotDotToken); emitExpression(node.expression); - emitTokenWithComment(19 /* CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); + emitTokenWithComment(19 /* SyntaxKind.CloseBraceToken */, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node); if (isMultiline) { writer.decreaseIndent(); } } } function emitJsxTagName(node) { - if (node.kind === 79 /* Identifier */) { + if (node.kind === 79 /* SyntaxKind.Identifier */) { emitExpression(node); } else { @@ -114102,13 +114540,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(82 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(82 /* SyntaxKind.CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(88 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(88 /* SyntaxKind.DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -114119,14 +114557,14 @@ var ts; ts.nodeIsSynthesized(parentNode) || ts.nodeIsSynthesized(statements[0]) || ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); - var format = 163969 /* CaseOrDefaultClauseStatements */; + var format = 163969 /* ListFormat.CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); - format &= ~(1 /* MultiLine */ | 128 /* Indented */); + format &= ~(1 /* ListFormat.MultiLine */ | 128 /* ListFormat.Indented */); } else { - emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* SyntaxKind.ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -114134,15 +114572,15 @@ var ts; writeSpace(); writeTokenText(node.token, writeKeyword); writeSpace(); - emitList(node, node.types, 528 /* HeritageClauseTypes */); + emitList(node, node.types, 528 /* ListFormat.HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(83 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(83 /* SyntaxKind.CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { - emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); + emitTokenWithComment(20 /* SyntaxKind.OpenParenToken */, openParenPos, writePunctuation, node); emit(node.variableDeclaration); - emitTokenWithComment(21 /* CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); + emitTokenWithComment(21 /* SyntaxKind.CloseParenToken */, node.variableDeclaration.end, writePunctuation, node); writeSpace(); } emit(node.block); @@ -114162,7 +114600,7 @@ var ts; // "comment1" is not considered to be leading comment for node.initializer // but rather a trailing comment on the previous node. var initializer = node.initializer; - if ((ts.getEmitFlags(initializer) & 512 /* NoLeadingComments */) === 0) { + if ((ts.getEmitFlags(initializer) & 512 /* EmitFlags.NoLeadingComments */) === 0) { var commentRange = ts.getCommentRange(initializer); emitTrailingCommentsOfPosition(commentRange.pos); } @@ -114179,7 +114617,7 @@ var ts; } function emitSpreadAssignment(node) { if (node.expression) { - emitTokenWithComment(25 /* DotDotDotToken */, node.pos, writePunctuation, node); + emitTokenWithComment(25 /* SyntaxKind.DotDotDotToken */, node.pos, writePunctuation, node); emitExpression(node.expression, parenthesizer.parenthesizeExpressionForDisallowedComma); } } @@ -114210,12 +114648,12 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 343 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 343 /* SyntaxKind.JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } else { - emitList(node, node.tags, 33 /* JSDocComment */); + emitList(node, node.tags, 33 /* ListFormat.JSDocComment */); } } writeSpace(); @@ -114249,13 +114687,13 @@ var ts; emitJSDocTagName(tag.tagName); emitJSDocTypeExpression(tag.constraint); writeSpace(); - emitList(tag, tag.typeParameters, 528 /* CommaListElements */); + emitList(tag, tag.typeParameters, 528 /* ListFormat.CommaListElements */); emitJSDocComment(tag.comment); } function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 309 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 309 /* SyntaxKind.JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -114274,7 +114712,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 322 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 322 /* SyntaxKind.JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -114292,14 +114730,14 @@ var ts; emitJSDocComment(tag.comment); } function emitJSDocTypeLiteral(lit) { - emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* JSDocComment */); + emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33 /* ListFormat.JSDocComment */); } function emitJSDocSignature(sig) { if (sig.typeParameters) { - emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33 /* ListFormat.JSDocComment */); } if (sig.parameters) { - emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* JSDocComment */); + emitList(sig, ts.factory.createNodeArray(sig.parameters), 33 /* ListFormat.JSDocComment */); } if (sig.type) { writeLine(); @@ -114380,21 +114818,21 @@ var ts; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* NoDefaultLib */ }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" /* BundleFileSectionKind.NoDefaultLib */ }); writeLine(); } if (currentSourceFile && currentSourceFile.moduleName) { - writeComment("/// "); + writeComment("/// ")); writeLine(); } if (currentSourceFile && currentSourceFile.amdDependencies) { for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) { var dep = _b[_a]; if (dep.name) { - writeComment("/// "); + writeComment("/// ")); } else { - writeComment("/// "); + writeComment("/// ")); } writeLine(); } @@ -114402,28 +114840,28 @@ var ts; for (var _c = 0, files_2 = files; _c < files_2.length; _c++) { var directive = files_2[_c]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* BundleFileSectionKind.Reference */, data: directive.fileName }); writeLine(); } for (var _d = 0, types_23 = types; _d < types_23.length; _d++) { var directive = types_23[_d]; var pos = writer.getTextPos(); var resolutionMode = directive.resolutionMode && directive.resolutionMode !== (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.impliedNodeFormat) - ? "resolution-mode=\"" + (directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require") + "\"" + ? "resolution-mode=\"".concat(directive.resolutionMode === ts.ModuleKind.ESNext ? "import" : "require", "\"") : ""; - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* TypeResolutionModeImport */ : "type-require" /* TypeResolutionModeRequire */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: !directive.resolutionMode ? "type" /* BundleFileSectionKind.Type */ : directive.resolutionMode === ts.ModuleKind.ESNext ? "type-import" /* BundleFileSectionKind.TypeResolutionModeImport */ : "type-require" /* BundleFileSectionKind.TypeResolutionModeRequire */, data: directive.fileName }); writeLine(); } for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) { var directive = libs_1[_e]; var pos = writer.getTextPos(); - writeComment("/// "); + writeComment("/// ")); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* Lib */, data: directive.fileName }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib" /* BundleFileSectionKind.Lib */, data: directive.fileName }); writeLine(); } } @@ -114434,22 +114872,22 @@ var ts; emitHelpers(node); var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); emitTripleSlashDirectivesIfNeeded(node); - emitList(node, statements, 1 /* MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); + emitList(node, statements, 1 /* ListFormat.MultiLine */, /*parenthesizerRule*/ undefined, index === -1 ? statements.length : index); popNameGenerationScope(node); } // Transformation nodes function emitPartiallyEmittedExpression(node) { var emitFlags = ts.getEmitFlags(node); - if (!(emitFlags & 512 /* NoLeadingComments */) && node.pos !== node.expression.pos) { + if (!(emitFlags & 512 /* EmitFlags.NoLeadingComments */) && node.pos !== node.expression.pos) { emitTrailingCommentsOfPosition(node.expression.pos); } emitExpression(node.expression); - if (!(emitFlags & 1024 /* NoTrailingComments */) && node.end !== node.expression.end) { + if (!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */) && node.end !== node.expression.end) { emitLeadingCommentsOfPosition(node.expression.end); } } function emitCommaList(node) { - emitExpressionList(node, node.elements, 528 /* CommaListElements */, /*parenthesizerRule*/ undefined); + emitExpressionList(node, node.elements, 528 /* ListFormat.CommaListElements */, /*parenthesizerRule*/ undefined); } /** * Emits any prologue directives at the start of a Statement list, returning the @@ -114470,7 +114908,7 @@ var ts; var pos = writer.getTextPos(); emit(statement); if (recordBundleFileSection && bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: statement.expression.text }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: statement.expression.text }); if (seenPrologueDirectives) { seenPrologueDirectives.add(statement.expression.text); } @@ -114491,7 +114929,7 @@ var ts; var pos = writer.getTextPos(); emit(prologue); if (bundleFileInfo) - bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* Prologue */, data: prologue.data }); + bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue" /* BundleFileSectionKind.Prologue */, data: prologue.data }); if (seenPrologueDirectives) { seenPrologueDirectives.add(prologue.data); } @@ -114615,7 +115053,7 @@ var ts; textRange.pos = modifiers.pos; if (pos === modifiers.length - 1) textRange.end = modifiers.end; - emitNodeListItems(emit, node, modifiers, lastMode === "modifiers" ? 2359808 /* Modifiers */ : 2146305 /* Decorators */, + emitNodeListItems(emit, node, modifiers, lastMode === "modifiers" ? 2359808 /* ListFormat.Modifiers */ : 2146305 /* ListFormat.Decorators */, /*parenthesizerRule*/ undefined, start, pos - start, /*hasTrailingComma*/ false, textRange); start = pos; @@ -114626,7 +115064,7 @@ var ts; } } function emitModifiers(node, modifiers) { - emitList(node, modifiers, 2359808 /* Modifiers */); + emitList(node, modifiers, 2359808 /* ListFormat.Modifiers */); } function emitTypeAnnotation(node) { if (node) { @@ -114638,7 +115076,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container, parenthesizerRule) { if (node) { writeSpace(); - emitTokenWithComment(63 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(63 /* SyntaxKind.EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node, parenthesizerRule); } @@ -114668,7 +115106,7 @@ var ts; } } function emitEmbeddedStatement(parent, node) { - if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* SingleLine */) { + if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1 /* EmitFlags.SingleLine */) { writeSpace(); emit(node); } @@ -114676,7 +115114,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - pipelineEmit(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmitHint.EmbeddedStatement */, node); } else { emit(node); @@ -114685,19 +115123,19 @@ var ts; } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 2146305 /* Decorators */); + emitList(parentNode, decorators, 2146305 /* ListFormat.Decorators */); } function emitTypeArguments(parentNode, typeArguments) { - emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector); + emitList(parentNode, typeArguments, 53776 /* ListFormat.TypeArguments */, typeArgumentParenthesizerRuleSelector); } function emitTypeParameters(parentNode, typeParameters) { if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures return emitTypeArguments(parentNode, parentNode.typeArguments); } - emitList(parentNode, typeParameters, 53776 /* TypeParameters */); + emitList(parentNode, typeParameters, 53776 /* ListFormat.TypeParameters */); } function emitParameters(parentNode, parameters) { - emitList(parentNode, parameters, 2576 /* Parameters */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */); } function canEmitSimpleArrowHead(parentNode, parameters) { var parameter = ts.singleOrUndefined(parameters); @@ -114716,32 +115154,32 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emitList(parentNode, parameters, 2576 /* Parameters */ & ~2048 /* Parenthesis */); + emitList(parentNode, parameters, 2576 /* ListFormat.Parameters */ & ~2048 /* ListFormat.Parenthesis */); } else { emitParameters(parentNode, parameters); } } function emitParametersForIndexSignature(parentNode, parameters) { - emitList(parentNode, parameters, 8848 /* IndexSignatureParameters */); + emitList(parentNode, parameters, 8848 /* ListFormat.IndexSignatureParameters */); } function writeDelimiter(format) { - switch (format & 60 /* DelimitersMask */) { - case 0 /* None */: + switch (format & 60 /* ListFormat.DelimitersMask */) { + case 0 /* ListFormat.None */: break; - case 16 /* CommaDelimited */: + case 16 /* ListFormat.CommaDelimited */: writePunctuation(","); break; - case 4 /* BarDelimited */: + case 4 /* ListFormat.BarDelimited */: writeSpace(); writePunctuation("|"); break; - case 32 /* AsteriskDelimited */: + case 32 /* ListFormat.AsteriskDelimited */: writeSpace(); writePunctuation("*"); writeSpace(); break; - case 8 /* AmpersandDelimited */: + case 8 /* ListFormat.AmpersandDelimited */: writeSpace(); writePunctuation("&"); break; @@ -114757,16 +115195,16 @@ var ts; if (start === void 0) { start = 0; } if (count === void 0) { count = children ? children.length - start : 0; } var isUndefined = children === undefined; - if (isUndefined && format & 16384 /* OptionalIfUndefined */) { + if (isUndefined && format & 16384 /* ListFormat.OptionalIfUndefined */) { return; } var isEmpty = children === undefined || start >= children.length || count === 0; - if (isEmpty && format & 32768 /* OptionalIfEmpty */) { + if (isEmpty && format & 32768 /* ListFormat.OptionalIfEmpty */) { onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); return; } - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { writePunctuation(getOpeningBracket(format)); if (isEmpty && children) { emitTrailingCommentsOfPosition(children.pos, /*prefixSpace*/ true); // Emit comments within empty bracketed lists @@ -114775,10 +115213,10 @@ var ts; onBeforeEmitNodeArray === null || onBeforeEmitNodeArray === void 0 ? void 0 : onBeforeEmitNodeArray(children); if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { + if (format & 1 /* ListFormat.MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) { writeLine(); } - else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */ && !(format & 524288 /* ListFormat.NoSpaceIfEmpty */)) { writeSpace(); } } @@ -114786,7 +115224,7 @@ var ts; emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, children.hasTrailingComma, children); } onAfterEmitNodeArray === null || onAfterEmitNodeArray === void 0 ? void 0 : onAfterEmitNodeArray(children); - if (format & 15360 /* BracketsMask */) { + if (format & 15360 /* ListFormat.BracketsMask */) { if (isEmpty && children) { emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists } @@ -114800,18 +115238,18 @@ var ts; */ function emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, hasTrailingComma, childrenTextRange) { // Write the opening line terminator or leading whitespace. - var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; + var mayEmitInterveningComments = (format & 262144 /* ListFormat.NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format); if (leadingLineTerminatorCount) { writeLine(leadingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (format & 256 /* SpaceBetweenBraces */) { + else if (format & 256 /* ListFormat.SpaceBetweenBraces */) { writeSpace(); } // Increase the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { increaseIndent(); } var emitListItem = getEmitListItem(emit, parenthesizerRule); @@ -114822,7 +115260,7 @@ var ts; for (var i = 0; i < count; i++) { var child = children[start + i]; // Write the delimiter if this is not the first node. - if (format & 32 /* AsteriskDelimited */) { + if (format & 32 /* ListFormat.AsteriskDelimited */) { // always write JSDoc in the format "\n *" writeLine(); writeDelimiter(format); @@ -114834,7 +115272,7 @@ var ts; // a // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline // , - if (format & 60 /* DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + if (format & 60 /* ListFormat.DelimitersMask */ && previousSibling.end !== (parentNode ? parentNode.end : -1)) { emitLeadingCommentsOfPosition(previousSibling.end); } writeDelimiter(format); @@ -114844,14 +115282,14 @@ var ts; if (separatingLineTerminatorCount > 0) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. - if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { + if ((format & (3 /* ListFormat.LinesMask */ | 128 /* ListFormat.Indented */)) === 0 /* ListFormat.SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } writeLine(separatingLineTerminatorCount); shouldEmitInterveningComments = false; } - else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { + else if (previousSibling && format & 512 /* ListFormat.SpaceBetweenSiblings */) { writeSpace(); } } @@ -114874,11 +115312,11 @@ var ts; } // Write a trailing comma, if requested. var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0; - var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* NoTrailingComments */); - var emitTrailingComma = hasTrailingComma && (format & 64 /* AllowTrailingComma */) && (format & 16 /* CommaDelimited */); + var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024 /* EmitFlags.NoTrailingComments */); + var emitTrailingComma = hasTrailingComma && (format & 64 /* ListFormat.AllowTrailingComma */) && (format & 16 /* ListFormat.CommaDelimited */); if (emitTrailingComma) { if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(27 /* CommaToken */, previousSibling.end, writePunctuation, previousSibling); + emitTokenWithComment(27 /* SyntaxKind.CommaToken */, previousSibling.end, writePunctuation, previousSibling); } else { writePunctuation(","); @@ -114890,11 +115328,11 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* DelimitersMask */) && !skipTrailingComments) { + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & 60 /* ListFormat.DelimitersMask */) && !skipTrailingComments) { emitLeadingCommentsOfPosition(emitTrailingComma && (childrenTextRange === null || childrenTextRange === void 0 ? void 0 : childrenTextRange.end) ? childrenTextRange.end : previousSibling.end); } // Decrease the indent, if requested. - if (format & 128 /* Indented */) { + if (format & 128 /* ListFormat.Indented */) { decreaseIndent(); } recordBundleFileInternalSectionEnd(previousSourceFileTextKind); @@ -114903,7 +115341,7 @@ var ts; if (closingLineTerminatorCount) { writeLine(closingLineTerminatorCount); } - else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) { + else if (format & (2097152 /* ListFormat.SpaceAfterList */ | 256 /* ListFormat.SpaceBetweenBraces */)) { writeSpace(); } } @@ -114985,7 +115423,7 @@ var ts; return pos < 0 ? pos : pos + tokenString.length; } function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) { - if (ts.getEmitFlags(parentNode) & 1 /* SingleLine */) { + if (ts.getEmitFlags(parentNode) & 1 /* EmitFlags.SingleLine */) { writeSpace(); } else if (preserveSourceNewlines) { @@ -115035,8 +115473,8 @@ var ts; } } function getLeadingLineTerminatorCount(parentNode, firstChild, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } if (firstChild === undefined) { @@ -115060,7 +115498,7 @@ var ts; // leading newline to start the modifiers. return 0; } - if (firstChild.kind === 11 /* JsxText */) { + if (firstChild.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } @@ -115077,14 +115515,14 @@ var ts; return 1; } } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { if (previousNode === undefined || nextNode === undefined) { return 0; } - if (nextNode.kind === 11 /* JsxText */) { + if (nextNode.kind === 11 /* SyntaxKind.JsxText */) { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } @@ -115102,7 +115540,7 @@ var ts; } // If the two nodes are not comparable, add a line terminator based on the format that can indicate // whether new lines are preferred or not. - return format & 65536 /* PreferNewLine */ ? 1 : 0; + return format & 65536 /* ListFormat.PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -115111,11 +115549,11 @@ var ts; else if (ts.getStartsOnNewLine(nextNode)) { return 1; } - return format & 1 /* MultiLine */ ? 1 : 0; + return format & 1 /* ListFormat.MultiLine */ ? 1 : 0; } function getClosingLineTerminatorCount(parentNode, lastChild, format, childrenTextRange) { - if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { - if (format & 65536 /* PreferNewLine */) { + if (format & 2 /* ListFormat.PreserveLines */ || preserveSourceNewlines) { + if (format & 65536 /* ListFormat.PreferNewLine */) { return 1; } if (lastChild === undefined) { @@ -115132,7 +115570,7 @@ var ts; return 1; } } - if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) { + if (format & 1 /* ListFormat.MultiLine */ && !(format & 131072 /* ListFormat.NoTrailingNewLine */)) { return 1; } return 0; @@ -115161,14 +115599,14 @@ var ts; return lines; } function writeLineSeparatorsAndIndentBefore(node, parent) { - var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, 0 /* None */); + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, 0 /* ListFormat.None */); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false); } return !!leadingNewlines; } function writeLineSeparatorsAfter(node, parent) { - var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, 0 /* None */, /*childrenTextRange*/ undefined); + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, 0 /* ListFormat.None */, /*childrenTextRange*/ undefined); if (trailingNewlines) { writeLine(trailingNewlines); } @@ -115177,14 +115615,14 @@ var ts; if (ts.nodeIsSynthesized(node)) { var startsOnNewLine = ts.getStartsOnNewLine(node); if (startsOnNewLine === undefined) { - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } return startsOnNewLine; } - return (format & 65536 /* PreferNewLine */) !== 0; + return (format & 65536 /* ListFormat.PreferNewLine */) !== 0; } function getLinesBetweenNodes(parent, node1, node2) { - if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + if (ts.getEmitFlags(parent) & 131072 /* EmitFlags.NoIndentation */) { return 0; } parent = skipSynthesizedParentheses(parent); @@ -115207,7 +115645,7 @@ var ts; && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile)); } function skipSynthesizedParentheses(node) { - while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 212 /* SyntaxKind.ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -115235,29 +115673,29 @@ var ts; return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia); } function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) { - if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) { + if (node.kind === 10 /* SyntaxKind.StringLiteral */ && node.textSourceNode) { var textSourceNode = node.textSourceNode; if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) { var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode); - return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" : - neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* NoAsciiEscaping */) ? "\"" + ts.escapeString(text) + "\"" : - "\"" + ts.escapeNonAsciiString(text) + "\""; + return jsxAttributeEscape ? "\"".concat(ts.escapeJsxAttributeString(text), "\"") : + neverAsciiEscape || (ts.getEmitFlags(node) & 16777216 /* EmitFlags.NoAsciiEscaping */) ? "\"".concat(ts.escapeString(text), "\"") : + "\"".concat(ts.escapeNonAsciiString(text), "\""); } else { return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape); } } - var flags = (neverAsciiEscape ? 1 /* NeverAsciiEscape */ : 0) - | (jsxAttributeEscape ? 2 /* JsxAttributeEscape */ : 0) - | (printerOptions.terminateUnterminatedLiterals ? 4 /* TerminateUnterminatedLiterals */ : 0) - | (printerOptions.target && printerOptions.target === 99 /* ESNext */ ? 8 /* AllowNumericSeparator */ : 0); + var flags = (neverAsciiEscape ? 1 /* GetLiteralTextFlags.NeverAsciiEscape */ : 0) + | (jsxAttributeEscape ? 2 /* GetLiteralTextFlags.JsxAttributeEscape */ : 0) + | (printerOptions.terminateUnterminatedLiterals ? 4 /* GetLiteralTextFlags.TerminateUnterminatedLiterals */ : 0) + | (printerOptions.target && printerOptions.target === 99 /* ScriptTarget.ESNext */ ? 8 /* GetLiteralTextFlags.AllowNumericSeparator */ : 0); return ts.getLiteralText(node, currentSourceFile, flags); } /** * Push a new name generation scope. */ function pushNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlagsStack.push(tempFlags); @@ -115268,7 +115706,7 @@ var ts; * Pop the current name generation scope. */ function popNameGenerationScope(node) { - if (node && ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (node && ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { return; } tempFlags = tempFlagsStack.pop(); @@ -115284,84 +115722,84 @@ var ts; if (!node) return; switch (node.kind) { - case 235 /* Block */: + case 235 /* SyntaxKind.Block */: ts.forEach(node.statements, generateNames); break; - case 250 /* LabeledStatement */: - case 248 /* WithStatement */: - case 240 /* DoStatement */: - case 241 /* WhileStatement */: + case 250 /* SyntaxKind.LabeledStatement */: + case 248 /* SyntaxKind.WithStatement */: + case 240 /* SyntaxKind.DoStatement */: + case 241 /* SyntaxKind.WhileStatement */: generateNames(node.statement); break; - case 239 /* IfStatement */: + case 239 /* SyntaxKind.IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 242 /* ForStatement */: - case 244 /* ForOfStatement */: - case 243 /* ForInStatement */: + case 242 /* SyntaxKind.ForStatement */: + case 244 /* SyntaxKind.ForOfStatement */: + case 243 /* SyntaxKind.ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 249 /* SwitchStatement */: + case 249 /* SyntaxKind.SwitchStatement */: generateNames(node.caseBlock); break; - case 263 /* CaseBlock */: + case 263 /* SyntaxKind.CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 289 /* CaseClause */: - case 290 /* DefaultClause */: + case 289 /* SyntaxKind.CaseClause */: + case 290 /* SyntaxKind.DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 252 /* TryStatement */: + case 252 /* SyntaxKind.TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 292 /* CatchClause */: + case 292 /* SyntaxKind.CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: generateNames(node.declarationList); break; - case 255 /* VariableDeclarationList */: + case 255 /* SyntaxKind.VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 254 /* VariableDeclaration */: - case 164 /* Parameter */: - case 203 /* BindingElement */: - case 257 /* ClassDeclaration */: + case 254 /* SyntaxKind.VariableDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 203 /* SyntaxKind.BindingElement */: + case 257 /* SyntaxKind.ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 256 /* FunctionDeclaration */: + case 256 /* SyntaxKind.FunctionDeclaration */: generateNameIfNeeded(node.name); - if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* EmitFlags.ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 201 /* ObjectBindingPattern */: - case 202 /* ArrayBindingPattern */: + case 201 /* SyntaxKind.ObjectBindingPattern */: + case 202 /* SyntaxKind.ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 266 /* ImportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: generateNames(node.importClause); break; - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 268 /* NamespaceImport */: + case 268 /* SyntaxKind.NamespaceImport */: generateNameIfNeeded(node.name); break; - case 274 /* NamespaceExport */: + case 274 /* SyntaxKind.NamespaceExport */: generateNameIfNeeded(node.name); break; - case 269 /* NamedImports */: + case 269 /* SyntaxKind.NamedImports */: ts.forEach(node.elements, generateNames); break; - case 270 /* ImportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -115370,12 +115808,12 @@ var ts; if (!node) return; switch (node.kind) { - case 296 /* PropertyAssignment */: - case 297 /* ShorthandPropertyAssignment */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 296 /* SyntaxKind.PropertyAssignment */: + case 297 /* SyntaxKind.ShorthandPropertyAssignment */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -115394,7 +115832,7 @@ var ts; * Generate the text for a generated identifier. */ function generateName(name) { - if ((name.autoGenerateFlags & 7 /* KindMask */) === 4 /* Node */) { + if ((name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) === 4 /* GeneratedIdentifierFlags.Node */) { // Node names generate unique names based on their original node // and are cached based on that node's id. return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags); @@ -115433,7 +115871,7 @@ var ts; if (node.locals) { var local = node.locals.get(ts.escapeLeadingUnderscores(name)); // We conservatively include alias symbols to cover cases where they're emitted as locals - if (local && local.flags & (111551 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */)) { + if (local && local.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */ | 2097152 /* SymbolFlags.Alias */)) { return false; } } @@ -115447,7 +115885,7 @@ var ts; */ function makeTempVariableName(flags, reservedInNestedScopes) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; + var name = flags === 268435456 /* TempFlags._i */ ? "_i" : "_n"; if (isUniqueName(name)) { tempFlags |= flags; if (reservedInNestedScopes) { @@ -115457,12 +115895,12 @@ var ts; } } while (true) { - var count = tempFlags & 268435455 /* CountMask */; + var count = tempFlags & 268435455 /* TempFlags.CountMask */; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { var name = count < 26 - ? "_" + String.fromCharCode(97 /* a */ + count) + ? "_" + String.fromCharCode(97 /* CharacterCodes.a */ + count) : "_" + (count - 26); if (isUniqueName(name)) { if (reservedInNestedScopes) { @@ -115494,7 +115932,7 @@ var ts; } } // Find the first unique 'name_n', where n is a positive number - if (baseName.charCodeAt(baseName.length - 1) !== 95 /* _ */) { + if (baseName.charCodeAt(baseName.length - 1) !== 95 /* CharacterCodes._ */) { baseName += "_"; } var i = 1; @@ -115548,48 +115986,48 @@ var ts; if (ts.isIdentifier(node.name)) { return generateNameCached(node.name); } - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } /** * Generates a unique name from a node. */ function generateNameForNode(node, flags) { switch (node.kind) { - case 79 /* Identifier */: - return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 261 /* ModuleDeclaration */: - case 260 /* EnumDeclaration */: + case 79 /* SyntaxKind.Identifier */: + return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(flags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 261 /* SyntaxKind.ModuleDeclaration */: + case 260 /* SyntaxKind.EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 266 /* ImportDeclaration */: - case 272 /* ExportDeclaration */: + case 266 /* SyntaxKind.ImportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 256 /* FunctionDeclaration */: - case 257 /* ClassDeclaration */: - case 271 /* ExportAssignment */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 271 /* SyntaxKind.ExportAssignment */: return generateNameForExportDefault(); - case 226 /* ClassExpression */: + case 226 /* SyntaxKind.ClassExpression */: return generateNameForClassExpression(); - case 169 /* MethodDeclaration */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: return generateNameForMethodOrAccessor(node); - case 162 /* ComputedPropertyName */: - return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); + case 162 /* SyntaxKind.ComputedPropertyName */: + return makeTempVariableName(0 /* TempFlags.Auto */, /*reserveInNestedScopes*/ true); default: - return makeTempVariableName(0 /* Auto */); + return makeTempVariableName(0 /* TempFlags.Auto */); } } /** * Generates a unique identifier for a node. */ function makeName(name) { - switch (name.autoGenerateFlags & 7 /* KindMask */) { - case 1 /* Auto */: - return makeTempVariableName(0 /* Auto */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 2 /* Loop */: - return makeTempVariableName(268435456 /* _i */, !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); - case 3 /* Unique */: - return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* Optimistic */), !!(name.autoGenerateFlags & 8 /* ReservedInNestedScopes */)); + switch (name.autoGenerateFlags & 7 /* GeneratedIdentifierFlags.KindMask */) { + case 1 /* GeneratedIdentifierFlags.Auto */: + return makeTempVariableName(0 /* TempFlags.Auto */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 2 /* GeneratedIdentifierFlags.Loop */: + return makeTempVariableName(268435456 /* TempFlags._i */, !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); + case 3 /* GeneratedIdentifierFlags.Unique */: + return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32 /* GeneratedIdentifierFlags.FileLevel */) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16 /* GeneratedIdentifierFlags.Optimistic */), !!(name.autoGenerateFlags & 8 /* GeneratedIdentifierFlags.ReservedInNestedScopes */)); } return ts.Debug.fail("Unsupported GeneratedIdentifierKind."); } @@ -115605,7 +116043,7 @@ var ts; // if "node" is a different generated name (having a different // "autoGenerateId"), use it and stop traversing. if (ts.isIdentifier(node) - && !!(node.autoGenerateFlags & 4 /* Node */) + && !!(node.autoGenerateFlags & 4 /* GeneratedIdentifierFlags.Node */) && node.autoGenerateId !== autoGenerateId) { break; } @@ -115616,7 +116054,7 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { - var pipelinePhase = getNextPipelinePhase(2 /* Comments */, hint, node); + var pipelinePhase = getNextPipelinePhase(2 /* PipelinePhase.Comments */, hint, node); var savedContainerPos = containerPos; var savedContainerEnd = containerEnd; var savedDeclarationListContainerEnd = declarationListContainerEnd; @@ -115629,7 +116067,7 @@ var ts; var commentRange = ts.getCommentRange(node); // Emit leading comments emitLeadingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end); - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = true; } } @@ -115637,7 +116075,7 @@ var ts; var emitFlags = ts.getEmitFlags(node); var commentRange = ts.getCommentRange(node); // Emit trailing comments - if (emitFlags & 2048 /* NoNestedComments */) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */) { commentsDisabled = false; } emitTrailingCommentsOfNode(node, emitFlags, commentRange.pos, commentRange.end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd); @@ -115651,25 +116089,25 @@ var ts; hasWrittenComment = false; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; // Save current container state on the stack. if ((pos > 0 || end > 0) && pos !== end) { // Emit leading comments if the position is not synthesized and the node // has not opted out from emitting leading comments. if (!skipLeadingComments) { - emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* NotEmittedStatement */); + emitLeadingComments(pos, /*isEmittedNode*/ node.kind !== 349 /* SyntaxKind.NotEmittedStatement */); } - if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* NoLeadingComments */) !== 0)) { + if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0)) { // Advance the container position if comments get emitted or if they've been disabled explicitly using NoLeadingComments. containerPos = pos; } - if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* NoTrailingComments */) !== 0)) { + if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0)) { // As above. containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 255 /* VariableDeclarationList */) { + if (node.kind === 255 /* SyntaxKind.VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -115679,7 +116117,7 @@ var ts; } function emitTrailingCommentsOfNode(node, emitFlags, pos, end, savedContainerPos, savedContainerEnd, savedDeclarationListContainerEnd) { enterComment(); - var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0 || node.kind === 11 /* JsxText */; + var skipTrailingComments = end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0 || node.kind === 11 /* SyntaxKind.JsxText */; ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment); if ((pos > 0 || end > 0) && pos !== end) { // Restore previous container state. @@ -115688,18 +116126,18 @@ var ts; declarationListContainerEnd = savedDeclarationListContainerEnd; // Emit trailing comments if the position is not synthesized and the node // has not opted out from emitting leading comments and is an emitted node. - if (!skipTrailingComments && node.kind !== 349 /* NotEmittedStatement */) { + if (!skipTrailingComments && node.kind !== 349 /* SyntaxKind.NotEmittedStatement */) { emitTrailingComments(end); } } exitComment(); } function emitLeadingSynthesizedComment(comment) { - if (comment.hasLeadingNewline || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasLeadingNewline || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } writeSynthesizedComment(comment); - if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + if (comment.hasTrailingNewLine || comment.kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); } else { @@ -115717,25 +116155,25 @@ var ts; } function writeSynthesizedComment(comment) { var text = formatSynthesizedComment(comment); - var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + var lineMap = comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); } function formatSynthesizedComment(comment) { - return comment.kind === 3 /* MultiLineCommentTrivia */ - ? "/*" + comment.text + "*/" - : "//" + comment.text; + return comment.kind === 3 /* SyntaxKind.MultiLineCommentTrivia */ + ? "/*".concat(comment.text, "*/") + : "//".concat(comment.text); } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { enterComment(); var pos = detachedRange.pos, end = detachedRange.end; var emitFlags = ts.getEmitFlags(node); - var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; - var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; + var skipLeadingComments = pos < 0 || (emitFlags & 512 /* EmitFlags.NoLeadingComments */) !== 0; + var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024 /* EmitFlags.NoTrailingComments */) !== 0; if (!skipLeadingComments) { emitDetachedCommentsAndUpdateCommentsInfo(detachedRange); } exitComment(); - if (emitFlags & 2048 /* NoNestedComments */ && !commentsDisabled) { + if (emitFlags & 2048 /* EmitFlags.NoNestedComments */ && !commentsDisabled) { commentsDisabled = true; emitCallback(node); commentsDisabled = false; @@ -115824,7 +116262,7 @@ var ts; if (hasTrailingNewLine) { writer.writeLine(); } - else if (kind === 3 /* MultiLineCommentTrivia */) { + else if (kind === 3 /* SyntaxKind.MultiLineCommentTrivia */) { writer.writeSpace(" "); } } @@ -115866,7 +116304,7 @@ var ts; emitPos(commentPos); ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine); emitPos(commentEnd); - if (kind === 2 /* SingleLineCommentTrivia */) { + if (kind === 2 /* SyntaxKind.SingleLineCommentTrivia */) { writer.writeLine(); // still write a newline for single-line comments, so closing tokens aren't written on the same line } } @@ -115951,7 +116389,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMaps(hint, node) { - var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, hint, node); + var pipelinePhase = getNextPipelinePhase(3 /* PipelinePhase.SourceMaps */, hint, node); emitSourceMapsBeforeNode(node); pipelinePhase(hint, node); emitSourceMapsAfterNode(node); @@ -115969,12 +116407,12 @@ var ts; } else { var source = sourceMapRange.source || sourceMapSource; - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 16 /* EmitFlags.NoLeadingSourceMap */) === 0 && sourceMapRange.pos >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, sourceMapRange.pos)); } - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = true; } } @@ -115984,11 +116422,11 @@ var ts; var sourceMapRange = ts.getSourceMapRange(node); // Emit trailing sourcemap if (!ts.isUnparsedNode(node)) { - if (emitFlags & 64 /* NoNestedSourceMaps */) { + if (emitFlags & 64 /* EmitFlags.NoNestedSourceMaps */) { sourceMapsDisabled = false; } - if (node.kind !== 349 /* NotEmittedStatement */ - && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 + if (node.kind !== 349 /* SyntaxKind.NotEmittedStatement */ + && (emitFlags & 32 /* EmitFlags.NoTrailingSourceMap */) === 0 && sourceMapRange.end >= 0) { emitSourcePos(sourceMapRange.source || sourceMapSource, sourceMapRange.end); } @@ -116041,17 +116479,17 @@ var ts; return emitCallback(token, writer, tokenPos); } var emitNode = node && node.emitNode; - var emitFlags = emitNode && emitNode.flags || 0 /* None */; + var emitFlags = emitNode && emitNode.flags || 0 /* EmitFlags.None */; var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token]; var source = range && range.source || sourceMapSource; tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos); - if ((emitFlags & 128 /* NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 128 /* EmitFlags.NoTokenLeadingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } tokenPos = emitCallback(token, writer, tokenPos); if (range) tokenPos = range.end; - if ((emitFlags & 256 /* NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { + if ((emitFlags & 256 /* EmitFlags.NoTokenTrailingSourceMaps */) === 0 && tokenPos >= 0) { emitSourcePos(source, tokenPos); } return tokenPos; @@ -116082,23 +116520,23 @@ var ts; sourceMapSourceIndex = sourceIndex; } function isJsonSourceMapSource(sourceFile) { - return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Json */); + return ts.fileExtensionIs(sourceFile.fileName, ".json" /* Extension.Json */); } } ts.createPrinter = createPrinter; function createBracketsMap() { var brackets = []; - brackets[1024 /* Braces */] = ["{", "}"]; - brackets[2048 /* Parenthesis */] = ["(", ")"]; - brackets[4096 /* AngleBrackets */] = ["<", ">"]; - brackets[8192 /* SquareBrackets */] = ["[", "]"]; + brackets[1024 /* ListFormat.Braces */] = ["{", "}"]; + brackets[2048 /* ListFormat.Parenthesis */] = ["(", ")"]; + brackets[4096 /* ListFormat.AngleBrackets */] = ["<", ">"]; + brackets[8192 /* ListFormat.SquareBrackets */] = ["[", "]"]; return brackets; } function getOpeningBracket(format) { - return brackets[format & 15360 /* BracketsMask */][0]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][0]; } function getClosingBracket(format) { - return brackets[format & 15360 /* BracketsMask */][1]; + return brackets[format & 15360 /* ListFormat.BracketsMask */][1]; } // Flags enum to track count of temp variables and a few dedicated names var TempFlags; @@ -116464,7 +116902,7 @@ var ts; var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog, toPath = _a.toPath; var newPath = ts.removeIgnoredPath(fileOrDirectoryPath); if (!newPath) { - writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected ignored path: ").concat(fileOrDirectory)); return true; } fileOrDirectoryPath = newPath; @@ -116473,11 +116911,11 @@ var ts; // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) { - writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected file add/remove of non supported extension: ").concat(fileOrDirectory)); return true; } if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) { - writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory); + writeLog("Project: ".concat(configFileName, " Detected excluded file: ").concat(fileOrDirectory)); return true; } if (!program) @@ -116499,9 +116937,9 @@ var ts; var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath); var realProgram = ts.isArray(program) ? undefined : isBuilderProgram(program) ? program.getProgramOrUndefined() : program; var builderProgram = !realProgram && !ts.isArray(program) ? program : undefined; - if (hasSourceFile((filePathWithoutExtension + ".ts" /* Ts */)) || - hasSourceFile((filePathWithoutExtension + ".tsx" /* Tsx */))) { - writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory); + if (hasSourceFile((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + hasSourceFile((filePathWithoutExtension + ".tsx" /* Extension.Tsx */))) { + writeLog("Project: ".concat(configFileName, " Detected output file: ").concat(fileOrDirectory)); return true; } return false; @@ -116534,7 +116972,7 @@ var ts; ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop); var plainInvokeFactory = { watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); }, - watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* Recursive */) !== 0, options); }, + watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1 /* WatchDirectoryFlags.Recursive */) !== 0, options); }, }; var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ? { @@ -116569,36 +117007,36 @@ var ts; host.useCaseSensitiveFileNames(); } function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) { - log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("ExcludeWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); return { - close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); } + close: function () { return log("ExcludeWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); } }; } function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2); return { close: function () { - log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); + log("FileWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo))); watcher.close(); } }; } function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) { - var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Added:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); return { close: function () { - var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var watchInfo = "DirectoryWatcher:: Close:: ".concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(watchInfo); var start = ts.timestamp(); watcher.close(); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + watchInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(watchInfo)); } }; } @@ -116608,16 +117046,16 @@ var ts; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo); + var triggerredInfo = "".concat(key === "watchFile" ? "FileWatcher" : "DirectoryWatcher", ":: Triggered with ").concat(args[0], " ").concat(args[1] !== undefined ? args[1] : "", ":: ").concat(getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); log(triggerredInfo); var start = ts.timestamp(); cb.call.apply(cb, __spreadArray([/*thisArg*/ undefined], args, false)); var elapsed = ts.timestamp() - start; - log("Elapsed:: " + elapsed + "ms " + triggerredInfo); + log("Elapsed:: ".concat(elapsed, "ms ").concat(triggerredInfo)); }, flags, options, detailInfo1, detailInfo2); }; } function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) { - return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2); + return "WatchInfo: ".concat(file, " ").concat(flags, " ").concat(JSON.stringify(options), " ").concat(getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : "".concat(detailInfo1, " ").concat(detailInfo2)); } } ts.getWatchFactory = getWatchFactory; @@ -116798,7 +117236,7 @@ var ts; if (value !== undefined) return value !== false ? value : undefined; // could be .d.ts from output // Cache json or buildInfo - if (!ts.fileExtensionIs(fileName, ".json" /* Json */) && !ts.isBuildInfoFile(fileName)) { + if (!ts.fileExtensionIs(fileName, ".json" /* Extension.Json */) && !ts.isBuildInfoFile(fileName)) { return originalReadFile.call(host, fileName); } return setReadFileCache(key, fileName); @@ -116809,7 +117247,7 @@ var ts; if (value) return value; var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile); - if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */))) { + if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) { sourceFileCache.set(key, sourceFile); } return sourceFile; @@ -116899,12 +117337,12 @@ var ts; } ts.formatDiagnostics = formatDiagnostics; function formatDiagnostic(diagnostic, host) { - var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine(); + var errorMessage = "".concat(ts.diagnosticCategoryName(diagnostic), " TS").concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine())).concat(host.getNewLine()); if (diagnostic.file) { var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character; // TODO: GH#18217 var fileName = diagnostic.file.fileName; var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }); - return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage; + return "".concat(relativeFileName, "(").concat(line + 1, ",").concat(character + 1, "): ") + errorMessage; } return errorMessage; } @@ -116992,9 +117430,9 @@ var ts; var output = ""; output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan); output += ":"; - output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLine + 1), ForegroundColorEscapeSequences.Yellow); output += ":"; - output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); + output += color("".concat(firstLineChar + 1), ForegroundColorEscapeSequences.Yellow); return output; } ts.formatLocation = formatLocation; @@ -117008,7 +117446,7 @@ var ts; output += " - "; } output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category)); - output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey); + output += formatColorAndReset(" TS".concat(diagnostic.code, ": "), ForegroundColorEscapeSequences.Grey); output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); if (diagnostic.file) { output += host.getNewLine(); @@ -117071,7 +117509,7 @@ var ts; var mode = getModeForFileReference(name, containingFileMode); // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var strName = ts.isString(name) ? name : name.fileName.toLowerCase(); - var cacheKey = mode !== undefined ? mode + "|" + strName : strName; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(strName) : strName; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -117187,7 +117625,7 @@ var ts; var result = void 0; var mode = getModeForResolutionAtIndex(containingFile, i); i++; - var cacheKey = mode !== undefined ? mode + "|" + name : name; + var cacheKey = mode !== undefined ? "".concat(mode, "|").concat(name) : name; if (cache.has(cacheKey)) { result = cache.get(cacheKey); } @@ -117366,22 +117804,33 @@ var ts; * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format */ function getImpliedNodeFormatForFile(fileName, packageJsonInfoCache, host, options) { + var result = getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options); + return typeof result === "object" ? result.impliedNodeFormat : result; + } + ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + /*@internal*/ + function getImpliedNodeFormatForFileWorker(fileName, packageJsonInfoCache, host, options) { switch (ts.getEmitModuleResolutionKind(options)) { case ts.ModuleResolutionKind.Node16: case ts.ModuleResolutionKind.NodeNext: - return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".mjs" /* Mjs */]) ? ts.ModuleKind.ESNext : - ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Dcts */, ".cts" /* Cts */, ".cjs" /* Cjs */]) ? ts.ModuleKind.CommonJS : - ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */]) ? lookupFromPackageJson() : + return ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".mjs" /* Extension.Mjs */]) ? ts.ModuleKind.ESNext : + ts.fileExtensionIsOneOf(fileName, [".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */, ".cjs" /* Extension.Cjs */]) ? ts.ModuleKind.CommonJS : + ts.fileExtensionIsOneOf(fileName, [".d.ts" /* Extension.Dts */, ".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */]) ? lookupFromPackageJson() : undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline default: return undefined; } function lookupFromPackageJson() { - var scope = ts.getPackageScopeForPath(fileName, packageJsonInfoCache, host, options); - return (scope === null || scope === void 0 ? void 0 : scope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + var state = ts.getTemporaryModuleResolutionState(packageJsonInfoCache, host, options); + var packageJsonLocations = []; + state.failedLookupLocations = packageJsonLocations; + state.affectingLocations = packageJsonLocations; + var packageJsonScope = ts.getPackageScopeForPath(fileName, state); + var impliedNodeFormat = (packageJsonScope === null || packageJsonScope === void 0 ? void 0 : packageJsonScope.packageJsonContent.type) === "module" ? ts.ModuleKind.ESNext : ts.ModuleKind.CommonJS; + return { impliedNodeFormat: impliedNodeFormat, packageJsonLocations: packageJsonLocations, packageJsonScope: packageJsonScope }; } } - ts.getImpliedNodeFormatForFile = getImpliedNodeFormatForFile; + ts.getImpliedNodeFormatForFileWorker = getImpliedNodeFormatForFileWorker; /** @internal */ ts.plainJSErrors = new ts.Set([ // binder errors @@ -117529,7 +117978,7 @@ var ts; var modulesWithElidedImports = new ts.Map(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. var sourceFilesFoundSearchingNodeModules = new ts.Map(); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeProgram"); var host = createProgramOptions.host || createCompilerHost(options); var configParsingHost = parseConfigHostFromCompilerHostLike(host); @@ -117610,16 +118059,16 @@ var ts; forEachResolvedProjectReference: forEachResolvedProjectReference }), onProgramCreateComplete = _e.onProgramCreateComplete, fileExists = _e.fileExists, directoryExists = _e.directoryExists; var readFile = host.readFile.bind(host); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram }); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structureIsReused; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "tryReuseStructureFromOldProgram", {}); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "tryReuseStructureFromOldProgram", {}); structureIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; if (projectReferences) { @@ -117647,7 +118096,7 @@ var ts; var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); }); for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) { var fileName = _c[_b]; - if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index }); } } @@ -117656,13 +118105,13 @@ var ts; }); } } - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processRootFiles", { count: rootNames.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processRootFiles", { count: rootNames.length }); ts.forEach(rootNames, function (name, index) { return processRootFile(name, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, { kind: ts.FileIncludeKind.RootFile, index: index }); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferences", { count: typeReferences.length }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferences", { count: typeReferences.length }); // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); @@ -117706,7 +118155,7 @@ var ts; for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) { var oldSourceFile = oldSourceFiles_1[_i]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); - if (shouldCreateNewSourceFile || !newFile || + if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || // old file wasn't redirect but new file is (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path)); @@ -117796,9 +118245,9 @@ var ts; // Add file processingDiagnostics fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) { switch (diagnostic.kind) { - case 1 /* FilePreprocessingFileExplainingDiagnostic */: + case 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */: return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray)); - case 0 /* FilePreprocessingReferencedDiagnostic */: + case 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */: var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end; return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray, false))); default: @@ -117849,7 +118298,7 @@ var ts; return ts.emptyArray; var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory); var redirectedReference = getRedirectReferenceForResolution(containingFile); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveModuleNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveModule"); var result = actualResolveModuleNamesWorker(moduleNames, containingFile, containingFileName, reusedNames, redirectedReference); ts.performance.mark("afterResolveModule"); @@ -117864,7 +118313,7 @@ var ts; var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile; var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined; var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined; - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName }); ts.performance.mark("beforeResolveTypeReference"); var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference, containingFileMode); ts.performance.mark("afterResolveTypeReference"); @@ -117946,7 +118395,7 @@ var ts; return classifiableNames; } function resolveModuleNamesReusingOldState(moduleNames, file) { - if (structureIsReused === 0 /* Not */ && !file.ambientModuleNames.length) { + if (structureIsReused === 0 /* StructureIsReused.Not */ && !file.ambientModuleNames.length) { // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, // the best we can do is fallback to the default logic. return resolveModuleNamesWorker(moduleNames, file, /*reusedNames*/ undefined); @@ -118043,7 +118492,7 @@ var ts; // `result[i]` is either a `ResolvedModuleFull` or a marker. // If it is the former, we can leave it as is. if (result[i] === predictedToResolveToAmbientModuleMarker) { - result[i] = undefined; // TODO: GH#18217 + result[i] = undefined; } } else { @@ -118099,24 +118548,24 @@ var ts; }); } function tryReuseStructureFromOldProgram() { - var _a; + var _a, _b; if (!oldProgram) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused var oldOptions = oldProgram.getCompilerOptions(); if (ts.changesAffectModuleResolution(oldOptions, options)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // there is an old program, check if we can reuse its structure var oldRootNames = oldProgram.getRootFileNames(); if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } // Check if any referenced project tsconfig files are different if (!canReuseProjectReferences()) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); @@ -118124,12 +118573,12 @@ var ts; // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; var modifiedSourceFiles = []; - structureIsReused = 2 /* Completely */; + structureIsReused = 2 /* StructureIsReused.Completely */; // If the missing file paths are now present, it can change the progam structure, // and hence cant reuse the structure. // This is same as how we dont reuse the structure if one of the file from old program is now missing if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } var oldSourceFiles = oldProgram.getSourceFiles(); var SeenPackageName; @@ -118140,12 +118589,15 @@ var ts; var seenPackageNames = new ts.Map(); for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) { var oldSourceFile = oldSourceFiles_2[_i]; + var sourceFileOptions = getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options); var newSourceFile = host.getSourceFileByPath - ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 + ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat) + : host.getSourceFile(oldSourceFile.fileName, sourceFileOptions, /*onError*/ undefined, shouldCreateNewSourceFile || sourceFileOptions.impliedNodeFormat !== oldSourceFile.impliedNodeFormat); // TODO: GH#18217 if (!newSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } + newSourceFile.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + newSourceFile.packageJsonScope = sourceFileOptions.packageJsonScope; ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`"); var fileChanged = void 0; if (oldSourceFile.redirectInfo) { @@ -118153,7 +118605,7 @@ var ts; // This lets us know if the unredirected file has changed. If it has we should break the redirect. if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) { // Underlying file has changed. Might not redirect anymore. Must rebuild program. - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; newSourceFile = oldSourceFile; // Use the redirect. @@ -118161,7 +118613,7 @@ var ts; else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) { // If a redirected-to source file changes, the redirect may be broken. if (newSourceFile !== oldSourceFile) { - return 0 /* Not */; + return 0 /* StructureIsReused.Not */; } fileChanged = false; } @@ -118178,80 +118630,85 @@ var ts; // If there are 2 different source files for the same package name and at least one of them changes, // they might become redirects. So we must rebuild the program. var prevKind = seenPackageNames.get(packageName); - var newKind = fileChanged ? 1 /* Modified */ : 0 /* Exists */; - if ((prevKind !== undefined && newKind === 1 /* Modified */) || prevKind === 1 /* Modified */) { - return 0 /* Not */; + var newKind = fileChanged ? 1 /* SeenPackageName.Modified */ : 0 /* SeenPackageName.Exists */; + if ((prevKind !== undefined && newKind === 1 /* SeenPackageName.Modified */) || prevKind === 1 /* SeenPackageName.Modified */) { + return 0 /* StructureIsReused.Not */; } seenPackageNames.set(packageName, newKind); } if (fileChanged) { + if (oldSourceFile.impliedNodeFormat !== newSourceFile.impliedNodeFormat) { + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } // The `newSourceFile` object was created for the new program. - if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) { // 'lib' references has changed. Matches behavior in changesAffectModuleResolution - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { + else if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } // check tripleslash references - if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { + else if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - structureIsReused = 1 /* SafeModules */; - } - // check imports and module augmentations - collectExternalModuleReferences(newSourceFile); - if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { - // imports has changed - structureIsReused = 1 /* SafeModules */; - } - if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { - // moduleAugmentations has changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; } - if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) { - // dynamicImport has changed - structureIsReused = 1 /* SafeModules */; - } - if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { - // 'types' references has changed - structureIsReused = 1 /* SafeModules */; + else { + // check imports and module augmentations + collectExternalModuleReferences(newSourceFile); + if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { + // imports has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { + // moduleAugmentations has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if ((oldSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* NodeFlags.PermanentlySetIncrementalFlags */)) { + // dynamicImport has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } + else if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { + // 'types' references has changed + structureIsReused = 1 /* StructureIsReused.SafeModules */; + } } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } else if (hasInvalidatedResolution(oldSourceFile.path)) { // 'module/types' references could have changed - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; // add file to the modified list so that we will resolve it later modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; }); - for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) { - var oldFile = oldSourceFiles_3[_b]; + for (var _c = 0, oldSourceFiles_3 = oldSourceFiles; _c < oldSourceFiles_3.length; _c++) { + var oldFile = oldSourceFiles_3[_c]; if (!ts.contains(modifiedFiles, oldFile)) { - for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) { - var moduleName = _d[_c]; + for (var _d = 0, _e = oldFile.ambientModuleNames; _d < _e.length; _d++) { + var moduleName = _e[_d]; ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName); } } } // try to verify results of module resolution - for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) { - var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile; + for (var _f = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _f < modifiedSourceFiles_1.length; _f++) { + var _g = modifiedSourceFiles_1[_f], oldSourceFile = _g.oldFile, newSourceFile = _g.newFile; var moduleNames = getModuleNames(newSourceFile); var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile); // ensure that module resolution results are still correct var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, oldSourceFile, ts.moduleResolutionIsEqualTo); if (resolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedModules = ts.zipToModeAwareCache(newSourceFile, moduleNames, resolutions); } else { @@ -118262,24 +118719,24 @@ var ts; // ensure that types resolutions are still correct var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo); if (typeReferenceResolutionsChanged) { - structureIsReused = 1 /* SafeModules */; + structureIsReused = 1 /* StructureIsReused.SafeModules */; newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - if (structureIsReused !== 2 /* Completely */) { + if (structureIsReused !== 2 /* StructureIsReused.Completely */) { return structureIsReused; } - if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host))) { - return 1 /* SafeModules */; + if (ts.changesAffectingProgramStructure(oldOptions, options) || ((_b = host.hasChangedAutomaticTypeDirectiveNames) === null || _b === void 0 ? void 0 : _b.call(host))) { + return 1 /* StructureIsReused.SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); // update fileName -> file mapping ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length); - for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) { - var newSourceFile = newSourceFiles_1[_g]; + for (var _h = 0, newSourceFiles_1 = newSourceFiles; _h < newSourceFiles_1.length; _h++) { + var newSourceFile = newSourceFiles_1[_h]; filesByName.set(newSourceFile.path, newSourceFile); } var oldFilesByNameMap = oldProgram.getFilesByNameMap(); @@ -118304,7 +118761,7 @@ var ts; sourceFileToPackageName = oldProgram.sourceFileToPackageName; redirectTargetsMap = oldProgram.redirectTargetsMap; usesUriStyleNodeCoreModules = oldProgram.usesUriStyleNodeCoreModules; - return 2 /* Completely */; + return 2 /* StructureIsReused.Completely */; } function getEmitHost(writeFileCallback) { return { @@ -118349,7 +118806,7 @@ var ts; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!ts.outFile(options)); - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true); ts.performance.mark("beforeEmit"); var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), /*targetSourceFile*/ undefined, @@ -118401,7 +118858,7 @@ var ts; return typeChecker || (typeChecker = ts.createTypeChecker(program)); } function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* tracing.Phase.Emit */, "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, /*separateBeginAndEnd*/ true); var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); return result; @@ -118521,7 +118978,7 @@ var ts; } var typeChecker = getTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); - var isJs = sourceFile.scriptKind === 1 /* JS */ || sourceFile.scriptKind === 2 /* JSX */; + var isJs = sourceFile.scriptKind === 1 /* ScriptKind.JS */ || sourceFile.scriptKind === 2 /* ScriptKind.JSX */; var isCheckJs = isJs && ts.isCheckJsEnabledForFile(sourceFile, options); var isPlainJs = ts.isPlainJsFile(sourceFile, options.checkJs); var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; @@ -118529,8 +118986,8 @@ var ts; // - plain JS: .js files with no // ts-check and checkJs: undefined // - check JS: .js files with either // ts-check or checkJs: true // - external: files that are added by plugins - var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ - || sourceFile.scriptKind === 5 /* External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* ScriptKind.TS */ || sourceFile.scriptKind === 4 /* ScriptKind.TSX */ + || sourceFile.scriptKind === 5 /* ScriptKind.External */ || isPlainJs || isCheckJs || sourceFile.scriptKind === 7 /* ScriptKind.Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; if (isPlainJs) { @@ -118609,22 +119066,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 164 /* Parameter */: - case 167 /* PropertyDeclaration */: - case 169 /* MethodDeclaration */: + case 164 /* SyntaxKind.Parameter */: + case 167 /* SyntaxKind.PropertyDeclaration */: + case 169 /* SyntaxKind.MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); return "skip"; } // falls through - case 168 /* MethodSignature */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: - case 254 /* VariableDeclaration */: + case 168 /* SyntaxKind.MethodSignature */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: + case 254 /* SyntaxKind.VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); @@ -118632,65 +119089,65 @@ var ts; } } switch (node.kind) { - case 267 /* ImportClause */: + case 267 /* SyntaxKind.ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); return "skip"; } break; - case 272 /* ExportDeclaration */: + case 272 /* SyntaxKind.ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); return "skip"; } break; - case 270 /* ImportSpecifier */: - case 275 /* ExportSpecifier */: + case 270 /* SyntaxKind.ImportSpecifier */: + case 275 /* SyntaxKind.ExportSpecifier */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, ts.isImportSpecifier(node) ? "import...type" : "export...type")); return "skip"; } break; - case 265 /* ImportEqualsDeclaration */: + case 265 /* SyntaxKind.ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); return "skip"; - case 271 /* ExportAssignment */: + case 271 /* SyntaxKind.ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 291 /* HeritageClause */: + case 291 /* SyntaxKind.HeritageClause */: var heritageClause = node; - if (heritageClause.token === 117 /* ImplementsKeyword */) { + if (heritageClause.token === 117 /* SyntaxKind.ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 258 /* InterfaceDeclaration */: - var interfaceKeyword = ts.tokenToString(118 /* InterfaceKeyword */); + case 258 /* SyntaxKind.InterfaceDeclaration */: + var interfaceKeyword = ts.tokenToString(118 /* SyntaxKind.InterfaceKeyword */); ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); return "skip"; - case 261 /* ModuleDeclaration */: - var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(142 /* NamespaceKeyword */) : ts.tokenToString(141 /* ModuleKeyword */); + case 261 /* SyntaxKind.ModuleDeclaration */: + var moduleKeyword = node.flags & 16 /* NodeFlags.Namespace */ ? ts.tokenToString(142 /* SyntaxKind.NamespaceKeyword */) : ts.tokenToString(141 /* SyntaxKind.ModuleKeyword */); ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); return "skip"; - case 259 /* TypeAliasDeclaration */: + case 259 /* SyntaxKind.TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); return "skip"; - case 260 /* EnumDeclaration */: - var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* EnumKeyword */)); + case 260 /* SyntaxKind.EnumDeclaration */: + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(92 /* SyntaxKind.EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); return "skip"; - case 230 /* NonNullExpression */: + case 230 /* SyntaxKind.NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 229 /* AsExpression */: + case 229 /* SyntaxKind.AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); return "skip"; - case 211 /* TypeAssertionExpression */: + case 211 /* SyntaxKind.TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } } @@ -118699,53 +119156,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 257 /* ClassDeclaration */: - case 226 /* ClassExpression */: - case 169 /* MethodDeclaration */: - case 171 /* Constructor */: - case 172 /* GetAccessor */: - case 173 /* SetAccessor */: - case 213 /* FunctionExpression */: - case 256 /* FunctionDeclaration */: - case 214 /* ArrowFunction */: + case 257 /* SyntaxKind.ClassDeclaration */: + case 226 /* SyntaxKind.ClassExpression */: + case 169 /* SyntaxKind.MethodDeclaration */: + case 171 /* SyntaxKind.Constructor */: + case 172 /* SyntaxKind.GetAccessor */: + case 173 /* SyntaxKind.SetAccessor */: + case 213 /* SyntaxKind.FunctionExpression */: + case 256 /* SyntaxKind.FunctionDeclaration */: + case 214 /* SyntaxKind.ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); return "skip"; } // falls through - case 237 /* VariableStatement */: + case 237 /* SyntaxKind.VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === 237 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 237 /* SyntaxKind.VariableStatement */); return "skip"; } break; - case 167 /* PropertyDeclaration */: + case 167 /* SyntaxKind.PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (ts.isModifier(modifier) && modifier.kind !== 124 /* StaticKeyword */) { + if (ts.isModifier(modifier) && modifier.kind !== 124 /* SyntaxKind.StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } return "skip"; } break; - case 164 /* Parameter */: + case 164 /* SyntaxKind.Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers && ts.some(nodes, ts.isModifier)) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } break; - case 208 /* CallExpression */: - case 209 /* NewExpression */: - case 228 /* ExpressionWithTypeArguments */: - case 279 /* JsxSelfClosingElement */: - case 280 /* JsxOpeningElement */: - case 210 /* TaggedTemplateExpression */: + case 208 /* SyntaxKind.CallExpression */: + case 209 /* SyntaxKind.NewExpression */: + case 228 /* SyntaxKind.ExpressionWithTypeArguments */: + case 279 /* SyntaxKind.JsxSelfClosingElement */: + case 280 /* SyntaxKind.JsxOpeningElement */: + case 210 /* SyntaxKind.TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); @@ -118758,27 +119215,27 @@ var ts; for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) { var modifier = modifiers_2[_i]; switch (modifier.kind) { - case 85 /* ConstKeyword */: + case 85 /* SyntaxKind.ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 123 /* PublicKeyword */: - case 121 /* PrivateKeyword */: - case 122 /* ProtectedKeyword */: - case 145 /* ReadonlyKeyword */: - case 135 /* DeclareKeyword */: - case 126 /* AbstractKeyword */: - case 159 /* OverrideKeyword */: - case 101 /* InKeyword */: - case 144 /* OutKeyword */: + case 123 /* SyntaxKind.PublicKeyword */: + case 121 /* SyntaxKind.PrivateKeyword */: + case 122 /* SyntaxKind.ProtectedKeyword */: + case 145 /* SyntaxKind.ReadonlyKeyword */: + case 135 /* SyntaxKind.DeclareKeyword */: + case 126 /* SyntaxKind.AbstractKeyword */: + case 159 /* SyntaxKind.OverrideKeyword */: + case 101 /* SyntaxKind.InKeyword */: + case 144 /* SyntaxKind.OutKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 124 /* StaticKeyword */: - case 93 /* ExportKeyword */: - case 88 /* DefaultKeyword */: + case 124 /* SyntaxKind.StaticKeyword */: + case 93 /* SyntaxKind.ExportKeyword */: + case 88 /* SyntaxKind.DefaultKeyword */: } } } @@ -118848,20 +119305,20 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 79 /* Identifier */ - ? b.kind === 79 /* Identifier */ && a.escapedText === b.escapedText - : b.kind === 10 /* StringLiteral */ && a.text === b.text; + return a.kind === 79 /* SyntaxKind.Identifier */ + ? b.kind === 79 /* SyntaxKind.Identifier */ && a.escapedText === b.escapedText + : b.kind === 10 /* SyntaxKind.StringLiteral */ && a.text === b.text; } function createSyntheticImport(text, file) { var externalHelpersModuleReference = ts.factory.createStringLiteral(text); var importDecl = ts.factory.createImportDeclaration(/*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); - ts.addEmitFlags(importDecl, 67108864 /* NeverApplyImportHelper */); + ts.addEmitFlags(importDecl, 67108864 /* EmitFlags.NeverApplyImportHelper */); ts.setParent(externalHelpersModuleReference, importDecl); ts.setParent(importDecl, file); // explicitly unset the synthesized flag on these declarations so the checker API will answer questions about them // (which is required to build the dependency graph for incremental emit) - externalHelpersModuleReference.flags &= ~8 /* Synthesized */; - importDecl.flags &= ~8 /* Synthesized */; + externalHelpersModuleReference.flags &= ~8 /* NodeFlags.Synthesized */; + importDecl.flags &= ~8 /* NodeFlags.Synthesized */; return externalHelpersModuleReference; } function collectExternalModuleReferences(file) { @@ -118892,7 +119349,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 2097152 /* NodeFlags.PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -118914,7 +119371,7 @@ var ts; } } else if (ts.isModuleDeclaration(node)) { - if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { + if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2 /* ModifierFlags.Ambient */) || file.isDeclarationFile)) { node.name.parent = node; var nameText = ts.getTextOfIdentifierOrLiteral(node.name); // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -118969,7 +119426,7 @@ var ts; function getNodeAtPosition(sourceFile, position) { var current = sourceFile; var getContainingChild = function (child) { - if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* EndOfFileToken */)))) { + if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1 /* SyntaxKind.EndOfFileToken */)))) { return child; } }; @@ -119062,13 +119519,16 @@ var ts; addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]); } } - function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { + function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName, sourceFileOptions) { + var _a; var redirect = Object.create(redirectTarget); redirect.fileName = fileName; redirect.path = path; redirect.resolvedPath = resolvedPath; redirect.originalFileName = originalFileName; redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected }; + redirect.packageJsonLocations = ((_a = sourceFileOptions.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) ? sourceFileOptions.packageJsonLocations : undefined; + redirect.packageJsonScope = sourceFileOptions.packageJsonScope; sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0); Object.defineProperties(redirect, { id: { @@ -119084,7 +119544,7 @@ var ts; } // Get source file from normalized fileName function findSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "findSourceFile", { + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "findSourceFile", { fileName: fileName, isDefaultLib: isDefaultLib || undefined, fileIncludeKind: ts.FileIncludeKind[reason.kind], @@ -119097,14 +119557,14 @@ var ts; // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront. - var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); - return { - languageVersion: ts.getEmitScriptTarget(options), - impliedNodeFormat: impliedNodeFormat, - setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options) - }; + var result = getImpliedNodeFormatForFileWorker(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options); + var languageVersion = ts.getEmitScriptTarget(options); + var setExternalModuleIndicator = ts.getSetExternalModuleIndicator(options); + return typeof result === "object" ? __assign(__assign({}, result), { languageVersion: languageVersion, setExternalModuleIndicator: setExternalModuleIndicator }) : + { languageVersion: languageVersion, impliedNodeFormat: result, setExternalModuleIndicator: setExternalModuleIndicator }; } function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) { + var _a, _b; var path = toPath(fileName); if (useSourceOfProjectReferenceRedirect) { var source = getSourceOfProjectReferenceRedirect(path); @@ -119191,14 +119651,15 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile); + var sourceFileOptions = getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options); + var file = host.getSourceFile(fileName, sourceFileOptions, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile || (((_a = oldProgram === null || oldProgram === void 0 ? void 0 : oldProgram.getSourceFileByPath(toPath(fileName))) === null || _a === void 0 ? void 0 : _a.impliedNodeFormat) !== sourceFileOptions.impliedNodeFormat)); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. // Instead of creating a duplicate, just redirect to the existing one. - var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName); // TODO: GH#18217 + var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName, sourceFileOptions); redirectTargetsMap.add(fileFromPackageId.path, fileName); addFileToFilesByName(dupFile, path, redirectedPath); addFileIncludeReason(dupFile, reason); @@ -119219,6 +119680,8 @@ var ts; file.path = path; file.resolvedPath = toPath(fileName); file.originalFileName = originalFileName; + file.packageJsonLocations = ((_b = sourceFileOptions.packageJsonLocations) === null || _b === void 0 ? void 0 : _b.length) ? sourceFileOptions.packageJsonLocations : undefined; + file.packageJsonScope = sourceFileOptions.packageJsonScope; addFileIncludeReason(file, reason); if (host.useCaseSensitiveFileNames()) { var pathLowerCase = ts.toFileNameLowerCase(path); @@ -119269,7 +119732,7 @@ var ts; } function getProjectReferenceRedirectProject(fileName) { // Ignore dts or any json files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -119279,7 +119742,7 @@ var ts; function getProjectReferenceOutputName(referencedProject, fileName) { var out = ts.outFile(referencedProject.commandLine.options); return out ? - ts.changeExtension(out, ".d.ts" /* Dts */) : + ts.changeExtension(out, ".d.ts" /* Extension.Dts */) : ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames()); } /** @@ -119312,13 +119775,13 @@ var ts; var out = ts.outFile(resolvedRef.commandLine.options); if (out) { // Dont know which source file it means so return true? - var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + var outputDts = ts.changeExtension(out, ".d.ts" /* Extension.Dts */); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); } else { var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); }); ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { - if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { + if (!ts.isDeclarationFileName(fileName) && !ts.fileExtensionIs(fileName, ".json" /* Extension.Json */)) { var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3); mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); } @@ -119364,7 +119827,7 @@ var ts; } } function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) { - ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); + ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* tracing.Phase.Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined }); processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason); ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop(); } @@ -119423,7 +119886,7 @@ var ts; path += (i === 2 ? "/" : "-") + components[i]; i++; } - var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_" + libFileName + "__.ts"); + var resolveFrom = ts.combinePaths(currentDirectory, "__lib_node_modules_lookup_".concat(libFileName, "__.ts")); var localOverrideModuleResult = ts.resolveModuleName("@typescript/lib-" + path, resolveFrom, { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, moduleResolutionCache); if (localOverrideModuleResult === null || localOverrideModuleResult === void 0 ? void 0 : localOverrideModuleResult.resolvedModule) { return localOverrideModuleResult.resolvedModule.resolvedFileName; @@ -119443,7 +119906,7 @@ var ts; var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 0 /* FilePreprocessingReferencedDiagnostic */, + kind: 0 /* FilePreprocessingDiagnosticsKind.FilePreprocessingReferencedDiagnostic */, reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, }, diagnostic: diagnostic, args: [libName, suggestion] @@ -119490,7 +119953,7 @@ var ts; && index < file.imports.length && !elideImport && !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile)) - && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */)); + && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* NodeFlags.JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -119551,7 +120014,7 @@ var ts; else { // An absolute path pointing to the containing directory of the config file var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory()); - sourceFile = host.getSourceFile(refPath, 100 /* JSON */); + sourceFile = host.getSourceFile(refPath, 100 /* ScriptTarget.JSON */); addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); if (sourceFile === undefined) { projectReferenceRedirects.set(sourceFilePath, false); @@ -119691,19 +120154,19 @@ var ts; var languageVersion = ts.getEmitScriptTarget(options); var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; }); if (options.isolatedModules) { - if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ES2015 */) { + if (options.module === ts.ModuleKind.None && languageVersion < 2 /* ScriptTarget.ES2015 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target"); } if (options.preserveConstEnums === false) { createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules"); } - var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* JSON */; }); + var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6 /* ScriptKind.JSON */; }); if (firstNonExternalModuleSourceFile) { var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(ts.createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, ts.Diagnostics._0_cannot_be_compiled_under_isolatedModules_because_it_is_considered_a_global_script_file_Add_an_import_export_or_an_empty_export_statement_to_make_it_a_module, ts.getBaseFileName(firstNonExternalModuleSourceFile.fileName))); } } - else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) { + else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ScriptTarget.ES2015 */ && options.module === ts.ModuleKind.None) { // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator); programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none)); @@ -119742,7 +120205,7 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + if (options.useDefineForClassFields && languageVersion === 0 /* ScriptTarget.ES3 */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !ts.getAllowJSCompilerOption(options)) { @@ -119764,7 +120227,7 @@ var ts; if (options.reactNamespace) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) { @@ -119778,7 +120241,7 @@ var ts; if (!options.jsxFactory) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory"); } - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx)); } if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) { @@ -119786,12 +120249,12 @@ var ts; } } if (options.reactNamespace) { - if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) { + if (options.jsx === 4 /* JsxEmit.ReactJSX */ || options.jsx === 5 /* JsxEmit.ReactJSXDev */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx)); } } if (options.jsxImportSource) { - if (options.jsx === 2 /* React */) { + if (options.jsx === 2 /* JsxEmit.React */) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx)); } } @@ -119849,7 +120312,7 @@ var ts; fileIncludeReasons = undefined; var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason); var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon); - var redirectInfo = file && ts.explainIfFileIsRedirect(file); + var redirectInfo = file && ts.explainIfFileIsRedirectAndImpliedFormat(file); var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo, true) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray, false)); return location && isReferenceFileLocation(location) ? ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) : @@ -119870,7 +120333,7 @@ var ts; } function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) { (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({ - kind: 1 /* FilePreprocessingFileExplainingDiagnostic */, + kind: 1 /* FilePreprocessingDiagnosticsKind.FilePreprocessingFileExplainingDiagnostic */, file: file && file.path, fileProcessingReason: fileProcessingReason, diagnostic: diagnostic, @@ -120109,7 +120572,7 @@ var ts; // If options have --outFile or --out just check that var out = ts.outFile(options); if (out) { - return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Dts */); + return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts" /* Extension.Dts */); } // If declarationDir is specified, return if its a file in that directory if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) { @@ -120122,13 +120585,13 @@ var ts; if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensionsFlat) || ts.isDeclarationFileName(filePath)) { // Otherwise just check if sourceFile with the name exists var filePathWithoutExtension = ts.removeFileExtension(filePath); - return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Ts */)) || - !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Tsx */)); + return !!getSourceFileByPath((filePathWithoutExtension + ".ts" /* Extension.Ts */)) || + !!getSourceFileByPath((filePathWithoutExtension + ".tsx" /* Extension.Tsx */)); } return false; } function isSameFile(file1, file2) { - return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* Comparison.EqualTo */; } function getSymlinkCache() { if (host.getSymlinkCache) { @@ -120229,12 +120692,12 @@ var ts; } function directoryExistsIfProjectReferenceDeclDir(dir) { var dirPath = host.toPath(dir); - var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + var dirPathWithTrailingDirectorySeparator = "".concat(dirPath).concat(ts.directorySeparator); return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || // Any parent directory of declaration dir ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || // Any directory inside declaration dir - ts.startsWith(dirPath, declDirPath + "/"); }); + ts.startsWith(dirPath, "".concat(declDirPath, "/")); }); } function handleDirectoryCouldBeSymlink(directory) { var _a; @@ -120287,7 +120750,7 @@ var ts; if (isFile && result) { // Store the real path for the file' var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); - symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "".concat(symlinkedDirectory.real).concat(absolutePath.replace(new RegExp(directoryPath, "i"), ""))); } return result; }) || false; @@ -120383,17 +120846,17 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ".tsx" /* Extension.Tsx */: return needJsx(); - case ".jsx" /* Jsx */: + case ".jsx" /* Extension.Jsx */: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ".js" /* Extension.Js */: return needAllowJs(); - case ".json" /* Json */: + case ".json" /* Extension.Json */: return needResolveJsonModule(); } function needJsx() { @@ -120412,7 +120875,7 @@ var ts; var res = imports.map(function (i) { return i.text; }); for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { var aug = moduleAugmentations_1[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { res.push(aug.text); } // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. @@ -120427,7 +120890,7 @@ var ts; var augIndex = imports.length; for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) { var aug = moduleAugmentations_2[_i]; - if (aug.kind === 10 /* StringLiteral */) { + if (aug.kind === 10 /* SyntaxKind.StringLiteral */) { if (index === augIndex) return aug; augIndex++; @@ -120443,8 +120906,8 @@ var ts; (function (ts) { function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit; - return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; + var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics; + return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); } @@ -120668,23 +121131,23 @@ var ts; /** * Gets the files affected by the path from the program */ - function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var _a, _b; - var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash); + var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName); (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear(); (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); return result; } BuilderState.getFilesAffectedBy = getFilesAffectedBy; - function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) { + function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) { var sourceFile = programOfThisState.getSourceFileByPath(path); if (!sourceFile) { return ts.emptyArray; } - if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) { + if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) { return [sourceFile]; } - return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash); + return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName); } BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState; function updateSignatureOfFile(state, signature, path) { @@ -120695,7 +121158,7 @@ var ts; /** * Returns if the shape of the signature has changed since last emit */ - function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) { + function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) { var _a; if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; } // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate @@ -120705,18 +121168,16 @@ var ts; var prevSignature = info.signature; var latestSignature; if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) { - var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, - /*emitOnlyDtsFiles*/ true, cancellationToken, - /*customTransformers*/ undefined, - /*forceDtsEmit*/ true); - var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles); - if (firstDts_1) { - ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); }); - latestSignature = computeSignature(firstDts_1.text, computeHash); + programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) { + ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: ".concat(fileName)); + latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data); if (latestSignature !== prevSignature) { - updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit); + updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit); } - } + }, cancellationToken, + /*emitOnlyDtsFiles*/ true, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); } // Default is to use file version as signature if (latestSignature === undefined) { @@ -120739,10 +121200,6 @@ var ts; return latestSignature !== prevSignature; } BuilderState.updateShapeSignature = updateShapeSignature; - function computeSignature(text, computeHash) { - return (computeHash || ts.generateDjb2Hash)(text); - } - BuilderState.computeSignature = computeSignature; /** * Coverts the declaration emit result into exported modules map */ @@ -120892,7 +121349,7 @@ var ts; /** * When program emits modular code, gets the files affected by the sourceFile whose shape has changed */ - function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) { + function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) { if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) { return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape); } @@ -120912,7 +121369,7 @@ var ts; if (!seenFileNamesMap.has(currentPath)) { var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath); seenFileNamesMap.set(currentPath, currentSourceFile); - if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) { + if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) { queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath)); } } @@ -120952,7 +121409,7 @@ var ts; state.outSignature = oldState === null || oldState === void 0 ? void 0 : oldState.outSignature; } state.changedFilesSet = new ts.Set(); - state.dtsChangeTime = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.dtsChangeTime : undefined; + state.latestChangedDtsFile = compilerOptions.composite ? oldState === null || oldState === void 0 ? void 0 : oldState.latestChangedDtsFile : undefined; var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState); var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined; var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile && @@ -121023,7 +121480,7 @@ var ts; } else if (oldCompilerOptions && !outFilePath && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); }); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* BuilderFileEmit.Full */); }); ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set(); } @@ -121076,7 +121533,7 @@ var ts; programEmitComplete: state.programEmitComplete, emitSignatures: state.emitSignatures && new ts.Map(state.emitSignatures), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: state.latestChangedDtsFile, hasChangedEmitSignature: state.hasChangedEmitSignature, changedFilesSet: outFilePath ? new ts.Set(state.changedFilesSet) : undefined, }; @@ -121089,7 +121546,7 @@ var ts; state.programEmitComplete = savedEmitState.programEmitComplete; state.emitSignatures = savedEmitState.emitSignatures; state.outSignature = savedEmitState.outSignature; - state.dtsChangeTime = savedEmitState.dtsChangeTime; + state.latestChangedDtsFile = savedEmitState.latestChangedDtsFile; state.hasChangedEmitSignature = savedEmitState.hasChangedEmitSignature; if (savedEmitState.changedFilesSet) state.changedFilesSet = savedEmitState.changedFilesSet; @@ -121106,7 +121563,7 @@ var ts; * This is to allow the callers to be able to actually remove affected file only when the operation is complete * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained */ - function getNextAffectedFile(state, cancellationToken, computeHash, host) { + function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; while (true) { var affectedFiles = state.affectedFiles; @@ -121118,7 +121575,7 @@ var ts; if (!seenAffectedFiles.has(affectedFile.resolvedPath)) { // Set the next affected file as seen and remove the cached semantic diagnostics state.affectedFilesIndex = affectedFilesIndex; - handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); return affectedFile; } affectedFilesIndex++; @@ -121146,7 +121603,7 @@ var ts; return program; } // Get next batch of affected files - state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash); + state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName); state.currentChangedFilePath = nextKey.value; state.affectedFilesIndex = 0; if (!state.seenAffectedFiles) @@ -121197,7 +121654,7 @@ var ts; * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change */ - function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath); // If affected files is everything except default library, then nothing more to do if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { @@ -121205,18 +121662,18 @@ var ts; // When a change affects the global scope, all files are considered to be affected without updating their signature // That means when affected file is handled, its signature can be out of date // To avoid this, ensure that we update the signature for any affected file in this scenario. - ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash); + ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName); return; } if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) return; - handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host); + handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host); } /** * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled, * Also we need to make sure signature is updated for these files */ - function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) { + function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { var program = ts.Debug.checkDefined(state.program); @@ -121227,10 +121684,10 @@ var ts; // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build // But we avoid expensive full shape computation, as using file version as shape is enough for correctness. - ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); + addToAffectedFilesPendingEmit(state, path, 0 /* BuilderFileEmit.DtsOnly */); } } } @@ -121252,20 +121709,20 @@ var ts; var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignature; } - function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope)) return false; // Every file needs to be handled ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined) - .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); }); + .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); }); removeDiagnosticsOfLibraryFiles(state); return true; } /** * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit */ - function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a; // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit @@ -121283,9 +121740,9 @@ var ts; var currentPath = queue.pop(); if (!seenFileNamesMap.has(currentPath)) { seenFileNamesMap.set(currentPath, true); - if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host)) return; - handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host); if (isChangedSignature(state, currentPath)) { var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); @@ -121297,11 +121754,11 @@ var ts; // Go through exported modules from cache first // If exported modules has path, all files referencing file exported from are affected (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; var references = state.referencedMap.getKeys(exportedFromPath); return references && ts.forEachKey(references, function (filePath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); }); } @@ -121309,22 +121766,22 @@ var ts; * handle dts and semantic diagnostics on file and iterate on anything that exports this file * return true when all work is done and we can exit handling dts emit and semantic diagnostics */ - function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) { + function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) { var _a, _b; if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) return undefined; - if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host)) + if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host)) return true; - handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host); + handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host); // If exported modules has path, all files referencing file exported from are affected (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) { - return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host); + return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host); }); // Remove diagnostics of files that import this file (without going to exports of referencing files) (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) { return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal - state, referencingFilePath, cancellationToken, computeHash, host); + state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host); }); return undefined; } @@ -121403,14 +121860,14 @@ var ts; /** * Gets the program information to be emitted in buildInfo so that we can use it to create new program */ - function getProgramBuildInfo(state, getCanonicalFileName, host) { + function getProgramBuildInfo(state, getCanonicalFileName) { var outFilePath = ts.outFile(state.compilerOptions); if (outFilePath && !state.compilerOptions.composite) return; var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); - // Update the dtsChange time in buildInfo - state.dtsChangeTime = state.hasChangedEmitSignature ? ts.getCurrentTime(host).getTime() : state.dtsChangeTime; + // Convert the file name to Path here if we set the fileName instead to optimize multiple d.ts file emits and having to compute Canonical path + var latestChangedDtsFile = state.latestChangedDtsFile ? relativeToBuildInfoEnsuringAbsolutePath(state.latestChangedDtsFile) : undefined; if (outFilePath) { var fileNames_1 = []; var fileInfos_1 = []; @@ -121426,7 +121883,7 @@ var ts; fileInfos: fileInfos_1, options: convertToProgramBuildInfoCompilerOptions(state.compilerOptions, "affectsBundleEmitBuildInfo"), outSignature: state.outSignature, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result_15; } @@ -121528,7 +121985,7 @@ var ts; affectedFilesPendingEmit: affectedFilesPendingEmit, changeFileSet: changeFileSet, emitSignatures: emitSignatures, - dtsChangeTime: state.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, }; return result; function relativeToBuildInfoEnsuringAbsolutePath(path) { @@ -121643,8 +122100,39 @@ var ts; return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray }; } ts.getBuilderCreationParameters = getBuilderCreationParameters; - function computeSignature(text, data, computeHash) { - return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash); + function getTextHandlingSourceMapForSignature(text, data) { + return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text; + } + function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) { + var _a; + text = getTextHandlingSourceMapForSignature(text, data); + var sourceFileDirectory; + if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) { + text += data.diagnostics.map(function (diagnostic) { + return "".concat(locationInfo(diagnostic)).concat(ts.DiagnosticCategory[diagnostic.category]).concat(diagnostic.code, ": ").concat(flattenDiagnosticMessageText(diagnostic.messageText)); + }).join("\n"); + } + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text); + function flattenDiagnosticMessageText(diagnostic) { + return ts.isString(diagnostic) ? + diagnostic : + diagnostic === undefined ? + "" : + !diagnostic.next ? + diagnostic.messageText : + diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n"); + } + function locationInfo(diagnostic) { + if (diagnostic.file.resolvedPath === sourceFile.resolvedPath) + return "(".concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + if (sourceFileDirectory === undefined) + sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath); + return "".concat(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)), "(").concat(diagnostic.start, ",").concat(diagnostic.length, ")"); + } + } + ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics; + function computeSignature(text, computeHash, data) { + return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data)); } ts.computeSignature = computeSignature; function createBuilderProgram(kind, _a) { @@ -121665,7 +122153,7 @@ var ts; */ var computeHash = ts.maybeBind(host, host.createHash); var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState, host.disableUseFileVersionAsSignature); - newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName, host); }; + newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); }; // To ensure that we arent storing any references to old program or new program without state newProgram = undefined; // TODO: GH#18217 oldProgram = undefined; @@ -121675,6 +122163,7 @@ var ts; builderProgram.getState = getState; builderProgram.saveEmitState = function () { return backupBuilderProgramEmitState(state); }; builderProgram.restoreEmitState = function (saved) { return restoreBuilderProgramEmitState(state, saved); }; + builderProgram.hasChangedEmitSignature = function () { return !!state.hasChangedEmitSignature; }; builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); }; builderProgram.getSemanticDiagnostics = getSemanticDiagnostics; builderProgram.emit = emit; @@ -121705,8 +122194,8 @@ var ts; * in that order would be used to write the files */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); - var emitKind = 1 /* Full */; + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); + var emitKind = 1 /* BuilderFileEmit.Full */; var isPendingEmitFile = false; if (!affected) { if (!ts.outFile(state.compilerOptions)) { @@ -121719,7 +122208,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* BuilderFileEmit.Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } @@ -121738,36 +122227,39 @@ var ts; // Otherwise just affected file ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, ts.getEmitDeclarations(state.compilerOptions) ? getWriteFileCallback(writeFile, customTransformers) : - writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* BuilderFileEmit.DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } function getWriteFileCallback(writeFile, customTransformers) { return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) { - var _a, _b, _c; + var _a, _b, _c, _d, _e, _f, _g; if (ts.isDeclarationFileName(fileName)) { if (!ts.outFile(state.compilerOptions)) { ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1); - var newSignature = void 0; + var emitSignature = void 0; if (!customTransformers) { var file = sourceFiles[0]; var info = state.fileInfos.get(file.resolvedPath); if (info.signature === file.version) { - newSignature = computeSignature(text, data, computeHash); - if (newSignature !== file.version) { // Update it + var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data); + // With d.ts diagnostics they are also part of the signature so emitSignature will be different from it since its just hash of d.ts + if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length)) + emitSignature = signature; + if (signature !== file.version) { // Update it if (host.storeFilesChangingSignatureDuringEmit) - (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); + ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath); if (state.exportedModulesMap) ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit); if (state.affectedFiles) { // Keep old signature so we know what to undo if cancellation happens - var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath); + var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath); if (existing === undefined) - (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); - info.signature = newSignature; + ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false); + info.signature = signature; } else { // These are directly commited - info.signature = newSignature; - (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear(); + info.signature = signature; + (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear(); } } } @@ -121777,20 +122269,24 @@ var ts; // and would need their d.ts change time in --build mode if (state.compilerOptions.composite) { var filePath = sourceFiles[0].resolvedPath; - var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath); - newSignature || (newSignature = computeSignature(text, data, computeHash)); - if (newSignature !== oldSignature) { - (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature); - state.hasChangedEmitSignature = true; - } + var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath); + emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data)); + // Dont write dts files if they didn't change + if (emitSignature === oldSignature) + return; + ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature); + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } else if (state.compilerOptions.composite) { - var newSignature = computeSignature(text, data, computeHash); - if (newSignature !== state.outSignature) { - state.outSignature = newSignature; - state.hasChangedEmitSignature = true; - } + var newSignature = computeSignature(text, computeHash, data); + // Dont write dts files if they didn't change + if (newSignature === state.outSignature) + return; + state.outSignature = newSignature; + state.hasChangedEmitSignature = true; + state.latestChangedDtsFile = fileName; } } if (writeFile) @@ -121850,7 +122346,7 @@ var ts; // If every file pending emit is pending on only dts emit || ts.every(state.affectedFilesPendingEmit, function (path, index) { return index < state.affectedFilesPendingEmitIndex || - state.affectedFilesPendingEmitKind.get(path) === 0 /* DtsOnly */; + state.affectedFilesPendingEmitKind.get(path) === 0 /* BuilderFileEmit.DtsOnly */; })) { clearAffectedFilesPendingEmit(state); } @@ -121866,7 +122362,7 @@ var ts; */ function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) { while (true) { - var affected = getNextAffectedFile(state, cancellationToken, computeHash, host); + var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host); if (!affected) { // Done return undefined; @@ -121878,7 +122374,7 @@ var ts; // Add file to affected file pending emit to handle for later emit time // Apart for emit builder do this for tsbuildinfo, do this for non emit builder when noEmit is set as tsbuildinfo is written and reused between emitters if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) { - addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* Full */); + addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1 /* BuilderFileEmit.Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -121953,11 +122449,12 @@ var ts; var state; var filePaths; var filePathsSetList; + var latestChangedDtsFile = program.latestChangedDtsFile ? toAbsolutePath(program.latestChangedDtsFile) : undefined; if (isProgramBundleEmitBuildInfo(program)) { state = { fileInfos: new ts.Map(), compilerOptions: program.options ? ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath) : {}, - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, outSignature: program.outSignature, }; } @@ -121990,7 +122487,7 @@ var ts; affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toFilePath(value[0]); }, function (value) { return value[1]; }), affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0, changedFilesSet: new ts.Set(ts.map(program.changeFileSet, toFilePath)), - dtsChangeTime: program.dtsChangeTime, + latestChangedDtsFile: latestChangedDtsFile, emitSignatures: (emitSignatures_1 === null || emitSignatures_1 === void 0 ? void 0 : emitSignatures_1.size) ? emitSignatures_1 : undefined, }; } @@ -122017,6 +122514,7 @@ var ts; getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented, emitBuildInfo: ts.notImplemented, close: ts.noop, + hasChangedEmitSignature: ts.returnFalse, }; function toPath(path) { return ts.toPath(path, buildInfoDirectory, getCanonicalFileName); @@ -122119,7 +122617,7 @@ var ts; * "c:/", "c:/users", "c:/users/username", "c:/users/username/folderAtRoot", "c:/folderAtRoot" * @param dirPath */ - function canWatchDirectory(dirPath) { + function canWatchDirectoryOrFile(dirPath) { var rootLength = ts.getRootLength(dirPath); if (dirPath.length === rootLength) { // Ignore "/", "c:/" @@ -122131,7 +122629,7 @@ var ts; return false; } var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); - var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */; if (isNonDirectorySeparatorRoot && dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart @@ -122156,7 +122654,7 @@ var ts; } return true; } - ts.canWatchDirectory = canWatchDirectory; + ts.canWatchDirectoryOrFile = canWatchDirectoryOrFile; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; var filesWithInvalidatedResolutions; @@ -122165,7 +122663,9 @@ var ts; var resolutionsWithFailedLookups = []; var resolutionsWithOnlyAffectingLocations = []; var resolvedFileToResolution = ts.createMultiMap(); + var impliedFormatPackageJsons = new ts.Map(); var hasChangedAutomaticTypeDirectiveNames = false; + var affectingPathChecksForFile; var affectingPathChecks; var failedLookupChecks; var startsWithPathChecks; @@ -122190,7 +122690,7 @@ var ts; * This helps in not having to comb through all resolutions when files are added/removed * Note that .d.ts file also has .d.ts extension hence will be part of default extensions */ - var failedLookupDefaultExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".js" /* Js */, ".jsx" /* Jsx */, ".json" /* Json */]; + var failedLookupDefaultExtensions = [".ts" /* Extension.Ts */, ".tsx" /* Extension.Tsx */, ".js" /* Extension.Js */, ".jsx" /* Extension.Jsx */, ".json" /* Extension.Json */]; var customFailedLookupPaths = new ts.Map(); var directoryWatchesOfFailedLookups = new ts.Map(); var fileWatchesOfAffectingLocations = new ts.Map(); @@ -122205,7 +122705,7 @@ var ts; finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions, // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) - startCachingPerDirectoryResolution: clearPerDirectoryResolutions, + startCachingPerDirectoryResolution: startCachingPerDirectoryResolution, finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution, resolveModuleNames: resolveModuleNames, getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache, @@ -122249,9 +122749,10 @@ var ts; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; affectingPathChecks = undefined; - // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update - // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) - clearPerDirectoryResolutions(); + affectingPathChecksForFile = undefined; + moduleResolutionCache.clear(); + typeReferenceDirectiveResolutionCache.clear(); + impliedFormatPackageJsons.clear(); hasChangedAutomaticTypeDirectiveNames = false; } function startRecordingFilesWithChangedResolutions() { @@ -122283,15 +122784,44 @@ var ts; return function (path) { return (!!collected && collected.has(path)) || isFileWithInvalidatedNonRelativeUnresolvedImports(path); }; } - function clearPerDirectoryResolutions() { - moduleResolutionCache.clear(); - typeReferenceDirectiveResolutionCache.clear(); + function startCachingPerDirectoryResolution() { + moduleResolutionCache.clearAllExceptPackageJsonInfoCache(); + typeReferenceDirectiveResolutionCache.clearAllExceptPackageJsonInfoCache(); + // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update + // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); nonRelativeExternalModuleResolutions.clear(); } - function finishCachingPerDirectoryResolution() { + function finishCachingPerDirectoryResolution(newProgram, oldProgram) { filesWithInvalidatedNonRelativeUnresolvedImports = undefined; - clearPerDirectoryResolutions(); + nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions); + nonRelativeExternalModuleResolutions.clear(); + // Update file watches + if (newProgram !== oldProgram) { + newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFiles().forEach(function (newFile) { + var _a, _b, _c; + var expected = ts.isExternalOrCommonJsModule(newFile) ? (_b = (_a = newFile.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0 : 0; + var existing = (_c = impliedFormatPackageJsons.get(newFile.path)) !== null && _c !== void 0 ? _c : ts.emptyArray; + for (var i = existing.length; i < expected; i++) { + createFileWatcherOfAffectingLocation(newFile.packageJsonLocations[i], /*forResolution*/ false); + } + if (existing.length > expected) { + for (var i = expected; i < existing.length; i++) { + fileWatchesOfAffectingLocations.get(existing[i]).files--; + } + } + if (expected) + impliedFormatPackageJsons.set(newFile.path, newFile.packageJsonLocations); + else + impliedFormatPackageJsons.delete(newFile.path); + }); + impliedFormatPackageJsons.forEach(function (existing, path) { + if (!(newProgram === null || newProgram === void 0 ? void 0 : newProgram.getSourceFileByPath(path))) { + existing.forEach(function (location) { return fileWatchesOfAffectingLocations.get(location).files--; }); + impliedFormatPackageJsons.delete(path); + } + }); + } directoryWatchesOfFailedLookups.forEach(function (watcher, path) { if (watcher.refCount === 0) { directoryWatchesOfFailedLookups.delete(path); @@ -122299,11 +122829,9 @@ var ts; } }); fileWatchesOfAffectingLocations.forEach(function (watcher, path) { - if (watcher.refCount === 0) { + if (watcher.files === 0 && watcher.resolutions === 0) { fileWatchesOfAffectingLocations.delete(path); watcher.watcher.close(); - // Ensure when watching symlinked package.json, we can close the actual file watcher only once - watcher.watcher = ts.noopFileWatcher; } }); hasChangedAutomaticTypeDirectiveNames = false; @@ -122503,7 +123031,7 @@ var ts; failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator); var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator); - ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); + ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: ".concat(failedLookupLocation, " failedLookupLocationPath: ").concat(failedLookupLocationPath)); if (failedLookupPathSplit.length > rootSplitLength + 1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution return { @@ -122530,7 +123058,7 @@ var ts; } // If the directory is node_modules use it to watch, always watch it recursively if (ts.isNodeModulesDirectory(dirPath)) { - return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; + return canWatchDirectoryOrFile(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; // Use some ancestor of the root directory @@ -122548,7 +123076,7 @@ var ts; dir = ts.getDirectoryPath(dir); } } - return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; + return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined; } function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); @@ -122619,46 +123147,65 @@ var ts; // Watch package json for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) { var affectingLocation = affectingLocations_1[_i]; - createFileWatcherOfAffectingLocation(affectingLocation); + createFileWatcherOfAffectingLocation(affectingLocation, /*forResolution*/ true); } } - function createFileWatcherOfAffectingLocation(affectingLocation) { - var path = resolutionHost.toPath(affectingLocation); - var fileWatcher = fileWatchesOfAffectingLocations.get(path); + function createFileWatcherOfAffectingLocation(affectingLocation, forResolution) { + var fileWatcher = fileWatchesOfAffectingLocations.get(affectingLocation); if (fileWatcher) { - fileWatcher.refCount++; + if (forResolution) + fileWatcher.resolutions++; + else + fileWatcher.files++; return; } var locationToWatch = affectingLocation; - var locationToWatchPath = path; if (resolutionHost.realpath) { locationToWatch = resolutionHost.realpath(affectingLocation); - locationToWatchPath = resolutionHost.toPath(locationToWatch); - if (path !== locationToWatchPath) { - var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatchPath); + if (affectingLocation !== locationToWatch) { + var fileWatcher_1 = fileWatchesOfAffectingLocations.get(locationToWatch); if (fileWatcher_1) { - fileWatcher_1.refCount++; - fileWatcher_1.paths.add(path); - fileWatchesOfAffectingLocations.set(path, fileWatcher_1); + if (forResolution) + fileWatcher_1.resolutions++; + else + fileWatcher_1.files++; + fileWatcher_1.paths.add(affectingLocation); + fileWatchesOfAffectingLocations.set(affectingLocation, fileWatcher_1); return; } } } var paths = new ts.Set(); - paths.add(locationToWatchPath); - var watcher = { - watcher: resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { - cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind); - paths.forEach(function (path) { return (affectingPathChecks || (affectingPathChecks = new ts.Set())).add(path); }); + paths.add(locationToWatch); + var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ? + resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) { + cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind); + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + paths.forEach(function (path) { + if (watcher.resolutions) + (affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path); + if (watcher.files) + (affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path); + packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path)); + }); resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); - }), - refCount: 1, + }) : ts.noopFileWatcher; + var watcher = { + watcher: actualWatcher !== ts.noopFileWatcher ? { + close: function () { + actualWatcher.close(); + // Ensure when watching symlinked package.json, we can close the actual file watcher only once + actualWatcher = ts.noopFileWatcher; + } + } : actualWatcher, + resolutions: forResolution ? 1 : 0, + files: forResolution ? 0 : 1, paths: paths, }; - fileWatchesOfAffectingLocations.set(locationToWatchPath, watcher); - if (path !== locationToWatchPath) { - fileWatchesOfAffectingLocations.set(path, watcher); - paths.add(path); + fileWatchesOfAffectingLocations.set(locationToWatch, watcher); + if (affectingLocation !== locationToWatch) { + fileWatchesOfAffectingLocations.set(affectingLocation, watcher); + paths.add(affectingLocation); } } function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) { @@ -122726,8 +123273,8 @@ var ts; } for (var _a = 0, affectingLocations_2 = affectingLocations; _a < affectingLocations_2.length; _a++) { var affectingLocation = affectingLocations_2[_a]; - var watcher = fileWatchesOfAffectingLocations.get(resolutionHost.toPath(affectingLocation)); - watcher.refCount--; + var watcher = fileWatchesOfAffectingLocations.get(affectingLocation); + watcher.resolutions--; } } function removeDirectoryWatcher(dirPath) { @@ -122743,7 +123290,7 @@ var ts; cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); - }, nonRecursive ? 0 /* None */ : 1 /* Recursive */); + }, nonRecursive ? 0 /* WatchDirectoryFlags.None */ : 1 /* WatchDirectoryFlags.Recursive */); } function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) { // Deleted file, stop watching failed lookups for all the resolutions in the file @@ -122754,7 +123301,7 @@ var ts; } } function removeResolutionsFromProjectReferenceRedirects(filePath) { - if (!ts.fileExtensionIs(filePath, ".json" /* Json */)) + if (!ts.fileExtensionIs(filePath, ".json" /* Extension.Json */)) return; var program = resolutionHost.getCurrentProgram(); if (!program) @@ -122781,7 +123328,7 @@ var ts; resolution.isInvalidated = invalidated = true; for (var _a = 0, _b = ts.Debug.checkDefined(resolution.files); _a < _b.length; _a++) { var containingFilePath = _b[_a]; - (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath); // When its a file with inferred types resolution, invalidate type reference directive resolution hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile); } @@ -122848,10 +123395,25 @@ var ts; resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations(); } function invalidateResolutionsOfFailedLookupLocations() { + var _a; + var invalidated = false; + if (affectingPathChecksForFile) { + (_a = resolutionHost.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFiles().forEach(function (f) { + if (ts.some(f.packageJsonLocations, function (location) { return affectingPathChecksForFile.has(location); })) { + (filesWithInvalidatedResolutions !== null && filesWithInvalidatedResolutions !== void 0 ? filesWithInvalidatedResolutions : (filesWithInvalidatedResolutions = new ts.Set())).add(f.path); + invalidated = true; + } + }); + affectingPathChecksForFile = undefined; + } if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks && !affectingPathChecks) { - return false; + return invalidated; + } + invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution) || invalidated; + var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap(); + if (packageJsonMap && (failedLookupChecks || startsWithPathChecks || isInDirectoryChecks)) { + packageJsonMap.forEach(function (_value, path) { return isInvalidatedFailedLookup(path) ? packageJsonMap.delete(path) : undefined; }); } - var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution); failedLookupChecks = undefined; startsWithPathChecks = undefined; isInDirectoryChecks = undefined; @@ -122864,17 +123426,15 @@ var ts; return true; if (!failedLookupChecks && !startsWithPathChecks && !isInDirectoryChecks) return false; - return resolution.failedLookupLocations.some(function (location) { - var locationPath = resolutionHost.toPath(location); - return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || - ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || - ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); - }); + return resolution.failedLookupLocations.some(function (location) { return isInvalidatedFailedLookup(resolutionHost.toPath(location)); }); + } + function isInvalidatedFailedLookup(locationPath) { + return (failedLookupChecks === null || failedLookupChecks === void 0 ? void 0 : failedLookupChecks.has(locationPath)) || + ts.firstDefinedIterator((startsWithPathChecks === null || startsWithPathChecks === void 0 ? void 0 : startsWithPathChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath) ? true : undefined; }) || + ts.firstDefinedIterator((isInDirectoryChecks === null || isInDirectoryChecks === void 0 ? void 0 : isInDirectoryChecks.keys()) || ts.emptyIterator, function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath) ? true : undefined; }); } function canInvalidatedFailedLookupResolutionWithAffectingLocation(resolution) { - return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { - return affectingPathChecks.has(resolutionHost.toPath(location)); - }); + return !!affectingPathChecks && resolution.affectingLocations.some(function (location) { return affectingPathChecks.has(location); }); } function closeTypeRootsWatch() { ts.clearMap(typeRootsWatches, ts.closeFileWatcher); @@ -122905,7 +123465,7 @@ var ts; if (dirPath) { scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath); } - }, 1 /* Recursive */); + }, 1 /* WatchDirectoryFlags.Recursive */); } /** * Watches the types that would get added as part of getAutomaticTypeDirectiveNames @@ -122940,7 +123500,7 @@ var ts; function directoryExistsForTypeRootWatch(nodeTypesDirectory) { var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory)); var dirPath = resolutionHost.toPath(dir); - return dirPath === rootPath || canWatchDirectory(dirPath); + return dirPath === rootPath || canWatchDirectoryOrFile(dirPath); } } ts.createResolutionCache = createResolutionCache; @@ -122973,28 +123533,28 @@ var ts; function getPreferences(host, _a, compilerOptions, importingSourceFile) { var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding; return { - relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* Relative */ : - importModuleSpecifierPreference === "non-relative" ? 1 /* NonRelative */ : - importModuleSpecifierPreference === "project-relative" ? 3 /* ExternalNonRelative */ : - 2 /* Shortest */, + relativePreference: importModuleSpecifierPreference === "relative" ? 0 /* RelativePreference.Relative */ : + importModuleSpecifierPreference === "non-relative" ? 1 /* RelativePreference.NonRelative */ : + importModuleSpecifierPreference === "project-relative" ? 3 /* RelativePreference.ExternalNonRelative */ : + 2 /* RelativePreference.Shortest */, ending: getEnding(), }; function getEnding() { switch (importModuleSpecifierEnding) { - case "minimal": return 0 /* Minimal */; - case "index": return 1 /* Index */; - case "js": return 2 /* JsExtension */; - default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Index */ : 0 /* Minimal */; + case "minimal": return 0 /* Ending.Minimal */; + case "index": return 1 /* Ending.Index */; + case "js": return 2 /* Ending.JsExtension */; + default: return usesJsExtensionOnImports(importingSourceFile) || isFormatRequiringExtensions(compilerOptions, importingSourceFile.path, host) ? 2 /* Ending.JsExtension */ + : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */; } } } function getPreferencesForUpdate(compilerOptions, oldImportSpecifier, importingSourceFileName, host) { return { - relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, + relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* RelativePreference.Relative */ : 1 /* RelativePreference.NonRelative */, ending: ts.hasJSFileExtension(oldImportSpecifier) || isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) ? - 2 /* JsExtension */ : - ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + 2 /* Ending.JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Ending.Index */ : 0 /* Ending.Minimal */, }; } function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) { @@ -123051,7 +123611,7 @@ var ts; var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options); return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) || - getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences); + getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); } function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) { if (options === void 0) { options = {}; } @@ -123107,7 +123667,7 @@ var ts; return undefined; var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text; // If the preference is for non relative and the module specifier is relative, ignore it - return preferences.relativePreference !== 1 /* NonRelative */ || !ts.pathIsRelative(specifier) ? + return preferences.relativePreference !== 1 /* RelativePreference.NonRelative */ || !ts.pathIsRelative(specifier) ? specifier : undefined; }); }); @@ -123134,7 +123694,7 @@ var ts; return nodeModulesSpecifiers; } if (!specifier && !modulePath.isRedirect) { - var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences); + var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences); if (ts.pathIsBareSpecifier(local)) { pathsSpecifiers = ts.append(pathsSpecifiers, local); } @@ -123162,13 +123722,13 @@ var ts; var sourceDirectory = ts.getDirectoryPath(importingSourceFileName); return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory }; } - function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) { + function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) { var ending = _a.ending, relativePreference = _a.relativePreference; var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs; var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName; var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) || removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions); - if (!baseUrl && !paths || relativePreference === 0 /* Relative */) { + if (!baseUrl && !paths || relativePreference === 0 /* RelativePreference.Relative */) { return relativePath; } var baseDirectory = ts.getNormalizedAbsolutePath(ts.getPathsBasePath(compilerOptions, host) || baseUrl, host.getCurrentDirectory()); @@ -123176,16 +123736,15 @@ var ts; if (!relativeToBaseUrl) { return relativePath; } - var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions); - var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths); - var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths; + var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions); + var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths; if (!nonRelative) { return relativePath; } - if (relativePreference === 1 /* NonRelative */) { + if (relativePreference === 1 /* RelativePreference.NonRelative */) { return nonRelative; } - if (relativePreference === 3 /* ExternalNonRelative */) { + if (relativePreference === 3 /* RelativePreference.ExternalNonRelative */) { var projectDirectory = compilerOptions.configFilePath ? ts.toPath(ts.getDirectoryPath(compilerOptions.configFilePath), host.getCurrentDirectory(), info.getCanonicalFileName) : info.getCanonicalFileName(host.getCurrentDirectory()); @@ -123219,7 +123778,7 @@ var ts; } return relativePath; } - if (relativePreference !== 2 /* Shortest */) + if (relativePreference !== 2 /* RelativePreference.Shortest */) ts.Debug.assertNever(relativePreference); // Prefer a relative import over a baseUrl import if it has fewer components. return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative; @@ -123227,7 +123786,7 @@ var ts; function countPathComponents(path) { var count = 0; for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) { - if (path.charCodeAt(i) === 47 /* slash */) + if (path.charCodeAt(i) === 47 /* CharacterCodes.slash */) count++; } return count; @@ -123331,7 +123890,7 @@ var ts; }); // Sort by paths closest to importing file Name directory var sortedPaths = []; - var _loop_34 = function (directory) { + var _loop_35 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (_a, fileName) { @@ -123355,7 +123914,7 @@ var ts; }; var out_directory_1; for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) { - var state_11 = _loop_34(directory); + var state_11 = _loop_35(directory); directory = out_directory_1; if (state_11 === "break") break; @@ -123398,11 +123957,11 @@ var ts; var exportSymbol = checker.getSymbolAtLocation(exportAssignment); if (!exportSymbol) return; - var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; + var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 /* SymbolFlags.Alias */ ? checker.getAliasedSymbol(exportSymbol) : exportSymbol; if (originalExportSymbol === d.symbol) return topNamespace.parent.parent; function getTopNamespace(namespaceDeclaration) { - while (namespaceDeclaration.flags & 4 /* NestedNamespace */) { + while (namespaceDeclaration.flags & 4 /* NodeFlags.NestedNamespace */) { namespaceDeclaration = namespaceDeclaration.parent; } return namespaceDeclaration; @@ -123413,28 +123972,102 @@ var ts; return ambientModuleDeclare.name.text; } } - function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) { + function getAllowedEndings(preferredEnding, compilerOptions, importMode) { + if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) { + return [2 /* Ending.JsExtension */]; + } + switch (preferredEnding) { + case 2 /* Ending.JsExtension */: return [2 /* Ending.JsExtension */, 0 /* Ending.Minimal */, 1 /* Ending.Index */]; + case 1 /* Ending.Index */: return [1 /* Ending.Index */, 0 /* Ending.Minimal */, 2 /* Ending.JsExtension */]; + case 0 /* Ending.Minimal */: return [0 /* Ending.Minimal */, 1 /* Ending.Index */, 2 /* Ending.JsExtension */]; + default: ts.Debug.assertNever(preferredEnding); + } + } + function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) { for (var key in paths) { - for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { - var patternText_1 = _a[_i]; - var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1)); + var _loop_36 = function (patternText_1) { + var pattern = ts.normalizePath(patternText_1); var indexOfStar = pattern.indexOf("*"); + // In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly, + // meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution + // causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file + // and matches the '*'. For example: + // + // Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action + // ---------------------->------------------------------->--------------------->--------------------------------------------------------------- + // import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm] + // import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm] + // + // (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516) + // + // The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in + // the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result. + // (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid + // extension for a module specifier.) + // + // Here, this means we need to be careful about whether we generate a match from the target filename (typically with a + // .ts extension) or the possible relative module specifiers representing that file: + // + // Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results + // --------------------<----------------------------------------------<------------------------------<-------------------||---------------------------- + // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none) + // dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js + // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none) + // dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*"] <- (none) || @app/foo, @app/foo/index, @app/foo/index.js + // dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js + // + // The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of + // relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes + // into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js' + // exists) and (c) that they are ordered by preference. The last row shows that the filename result and module + // specifier results are not mutually exclusive. Note that the filename result is a higher priority in module + // resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result + // in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be + // sorted among the others for a particular value of `importModuleSpecifierEnding`. + var candidates = allowedEndings.map(function (ending) { return ({ + ending: ending, + value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) + }); }); + if (ts.tryGetExtensionFromPath(pattern)) { + candidates.push({ ending: undefined, value: relativeToBaseUrl }); + } if (indexOfStar !== -1) { - var prefix = pattern.substr(0, indexOfStar); - var suffix = pattern.substr(indexOfStar + 1); - if (relativeToBaseUrl.length >= prefix.length + suffix.length && - ts.startsWith(relativeToBaseUrl, prefix) && - ts.endsWith(relativeToBaseUrl, suffix) || - !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) { - var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length - prefix.length); - return key.replace("*", matchedStar); + var prefix = pattern.substring(0, indexOfStar); + var suffix = pattern.substring(indexOfStar + 1); + for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) { + var _c = candidates_3[_b], ending = _c.ending, value = _c.value; + if (value.length >= prefix.length + suffix.length && + ts.startsWith(value, prefix) && + ts.endsWith(value, suffix) && + validateEnding({ ending: ending, value: value })) { + var matchedStar = value.substring(prefix.length, value.length - suffix.length); + return { value: key.replace("*", matchedStar) }; + } } } - else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) { - return key; + else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Ending.Minimal */ && pattern === c.value; }) || + ts.some(candidates, function (c) { return c.ending === 0 /* Ending.Minimal */ && pattern === c.value && validateEnding(c); })) { + return { value: key }; } + }; + for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) { + var patternText_1 = _a[_i]; + var state_12 = _loop_36(patternText_1); + if (typeof state_12 === "object") + return state_12.value; } } + function validateEnding(_a) { + var ending = _a.ending, value = _a.value; + // Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename + // is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only + // here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls), + // do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the + // `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is + // that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally + // everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.) + return ending !== 0 /* Ending.Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host); + } } var MatchingMode; (function (MatchingMode) { @@ -123443,23 +124076,23 @@ var ts; MatchingMode[MatchingMode["Pattern"] = 2] = "Pattern"; })(MatchingMode || (MatchingMode = {})); function tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, packageName, exports, conditions, mode) { - if (mode === void 0) { mode = 0 /* Exact */; } + if (mode === void 0) { mode = 0 /* MatchingMode.Exact */; } if (typeof exports === "string") { var pathOrPattern = ts.getNormalizedAbsolutePath(ts.combinePaths(packageDirectory, exports), /*currentDirectory*/ undefined); var extensionSwappedTarget = ts.hasTSFileExtension(targetFilePath) ? ts.removeFileExtension(targetFilePath) + tryGetJSExtensionForFile(targetFilePath, options) : undefined; switch (mode) { - case 0 /* Exact */: - if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* EqualTo */)) { + case 0 /* MatchingMode.Exact */: + if (ts.comparePaths(targetFilePath, pathOrPattern) === 0 /* Comparison.EqualTo */ || (extensionSwappedTarget && ts.comparePaths(extensionSwappedTarget, pathOrPattern) === 0 /* Comparison.EqualTo */)) { return { moduleFileToTry: packageName }; } break; - case 1 /* Directory */: + case 1 /* MatchingMode.Directory */: if (ts.containsPath(pathOrPattern, targetFilePath)) { var fragment = ts.getRelativePathFromDirectory(pathOrPattern, targetFilePath, /*ignoreCase*/ false); return { moduleFileToTry: ts.getNormalizedAbsolutePath(ts.combinePaths(ts.combinePaths(packageName, exports), fragment), /*currentDirectory*/ undefined) }; } break; - case 2 /* Pattern */: + case 2 /* MatchingMode.Pattern */: var starPos = pathOrPattern.indexOf("*"); var leadingSlice = pathOrPattern.slice(0, starPos); var trailingSlice = pathOrPattern.slice(starPos + 1); @@ -123486,9 +124119,9 @@ var ts; // * exact mappings (no *, does not end with /) return ts.forEach(ts.getOwnKeys(exports), function (k) { var subPackageName = ts.getNormalizedAbsolutePath(ts.combinePaths(packageName, k), /*currentDirectory*/ undefined); - var mode = ts.endsWith(k, "/") ? 1 /* Directory */ - : ts.stringContains(k, "*") ? 2 /* Pattern */ - : 0 /* Exact */; + var mode = ts.endsWith(k, "/") ? 1 /* MatchingMode.Directory */ + : ts.stringContains(k, "*") ? 2 /* MatchingMode.Pattern */ + : 0 /* MatchingMode.Exact */; return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, exports[k], conditions, mode); }); } @@ -123530,10 +124163,10 @@ var ts; return undefined; } // Simplify the full file path to something that can be resolved by Node. + var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var moduleSpecifier = path; var isPackageRootPath = false; if (!packageNameOnly) { - var preferences = getPreferences(host, userPreferences, options, importingSourceFile); var packageRootIndex = parts.packageRootIndex; var moduleFileName = void 0; while (true) { @@ -123582,15 +124215,13 @@ var ts; var packageRootPath = path.substring(0, packageRootIndex); var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); var moduleFileToTry = path; + var maybeBlockedByTypesVersions = false; var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath); if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) { var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath)); + var importMode = overrideMode || importingSourceFile.impliedNodeFormat; if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) { - // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate - // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is - // usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex` - // with, so for now we just stick with the mode of the file. - var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"]; + var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"]; var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string" ? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions) : undefined; @@ -123609,16 +124240,26 @@ var ts; : undefined; if (versionPaths) { var subModuleName = path.slice(packageRootPath.length + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { + var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options); + if (fromPaths === undefined) { + maybeBlockedByTypesVersions = true; + } + else { moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); } } // If the file is the main module, it can be imported by the package name var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js"; - if (ts.isString(mainFileRelative)) { + if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) { + // The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path + // explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable. + // (The only way this can happen is if some file in a package that's not resolvable from outside the + // package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It + // happens very easily in fourslash tests though, since every test file listed gets included. See + // importNameCodeFix_typesVersions.ts for an example.) var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { + // ^ An arbitrary removal of file extension for this comparison is almost certainly wrong return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry }; } } @@ -123637,7 +124278,7 @@ var ts; if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* JSON */ }])); + var extensions = ts.flatten(ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 /* ScriptKind.JSON */ }])); for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) { var e = extensions_3[_i]; var fullPath = path + e; @@ -123653,15 +124294,15 @@ var ts; }); } function removeExtensionAndIndexPostFix(fileName, ending, options, host) { - if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */])) + if (ts.fileExtensionIsOneOf(fileName, [".json" /* Extension.Json */, ".mjs" /* Extension.Mjs */, ".cjs" /* Extension.Cjs */])) return fileName; var noExtension = ts.removeFileExtension(fileName); if (fileName === noExtension) return fileName; - if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Dmts */, ".mts" /* Mts */, ".d.cts" /* Dcts */, ".cts" /* Cts */])) + if (ts.fileExtensionIsOneOf(fileName, [".d.mts" /* Extension.Dmts */, ".mts" /* Extension.Mts */, ".d.cts" /* Extension.Dcts */, ".cts" /* Extension.Cts */])) return noExtension + getJSExtensionForFile(fileName, options); switch (ending) { - case 0 /* Minimal */: + case 0 /* Ending.Minimal */: var withoutIndex = ts.removeSuffix(noExtension, "/index"); if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) { // Can't remove index if there's a file by the same name as the directory. @@ -123669,9 +124310,9 @@ var ts; return noExtension; } return withoutIndex; - case 1 /* Index */: + case 1 /* Ending.Index */: return noExtension; - case 2 /* JsExtension */: + case 2 /* Ending.JsExtension */: return noExtension + getJSExtensionForFile(fileName, options); default: return ts.Debug.assertNever(ending); @@ -123679,28 +124320,28 @@ var ts; } function getJSExtensionForFile(fileName, options) { var _a; - return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension " + ts.extensionFromPath(fileName) + " is unsupported:: FileName:: " + fileName); + return (_a = tryGetJSExtensionForFile(fileName, options)) !== null && _a !== void 0 ? _a : ts.Debug.fail("Extension ".concat(ts.extensionFromPath(fileName), " is unsupported:: FileName:: ").concat(fileName)); } function tryGetJSExtensionForFile(fileName, options) { var ext = ts.tryGetExtensionFromPath(fileName); switch (ext) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: - return ".js" /* Js */; - case ".tsx" /* Tsx */: - return options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */; - case ".js" /* Js */: - case ".jsx" /* Jsx */: - case ".json" /* Json */: + case ".ts" /* Extension.Ts */: + case ".d.ts" /* Extension.Dts */: + return ".js" /* Extension.Js */; + case ".tsx" /* Extension.Tsx */: + return options.jsx === 1 /* JsxEmit.Preserve */ ? ".jsx" /* Extension.Jsx */ : ".js" /* Extension.Js */; + case ".js" /* Extension.Js */: + case ".jsx" /* Extension.Jsx */: + case ".json" /* Extension.Json */: return ext; - case ".d.mts" /* Dmts */: - case ".mts" /* Mts */: - case ".mjs" /* Mjs */: - return ".mjs" /* Mjs */; - case ".d.cts" /* Dcts */: - case ".cts" /* Cts */: - case ".cjs" /* Cjs */: - return ".cjs" /* Cjs */; + case ".d.mts" /* Extension.Dmts */: + case ".mts" /* Extension.Mts */: + case ".mjs" /* Extension.Mjs */: + return ".mjs" /* Extension.Mjs */; + case ".d.cts" /* Extension.Dcts */: + case ".cts" /* Extension.Cts */: + case ".cjs" /* Extension.Cjs */: + return ".cjs" /* Extension.Cjs */; default: return undefined; } @@ -123782,8 +124423,8 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); + var output = "[".concat(ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(newLine + newLine); system.write(output); } : function (diagnostic, newLine, options) { @@ -123791,8 +124432,8 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); + output += "".concat(getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(getPlainDiagnosticFollowingNewLines(diagnostic, newLine)); system.write(output); }; } @@ -123815,7 +124456,7 @@ var ts; .map(function (errorDiagnostic) { if (errorDiagnostic.file === undefined) return; - return "" + errorDiagnostic.file.fileName; + return "".concat(errorDiagnostic.file.fileName); }); return filesInError.map(function (fileName) { var diagnosticForFileName = ts.find(diagnostics, function (diagnostic) { @@ -123848,7 +124489,7 @@ var ts; if (errorCount === 0) return ""; var nonNilFiles = filesInError.filter(function (fileInError) { return fileInError !== undefined; }); - var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return fileInError.fileName + ":" + fileInError.line; }) + var distinctFileNamesWithLines = nonNilFiles.map(function (fileInError) { return "".concat(fileInError.fileName, ":").concat(fileInError.line); }) .filter(function (value, index, self) { return self.indexOf(value) === index; }); var firstFileReference = nonNilFiles[0] && prettyPathForFileError(nonNilFiles[0], host.getCurrentDirectory()); var d = errorCount === 1 ? @@ -123861,7 +124502,7 @@ var ts; ts.Diagnostics.Found_0_errors_in_the_same_file_starting_at_Colon_1 : ts.Diagnostics.Found_0_errors_in_1_files, errorCount, distinctFileNamesWithLines.length === 1 ? firstFileReference : distinctFileNamesWithLines.length); var suffix = distinctFileNamesWithLines.length > 1 ? createTabularErrorsDisplay(nonNilFiles, host) : ""; - return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine + suffix; + return "".concat(newLine).concat(ts.flattenDiagnosticMessageText(d.messageText, newLine)).concat(newLine).concat(newLine).concat(suffix); } ts.getErrorSummaryText = getErrorSummaryText; function createTabularErrorsDisplay(filesInError, host) { @@ -123884,7 +124525,7 @@ var ts; " ".repeat(leftPaddingGoal - errorCountDigitsLength) : ""; var fileRef = prettyPathForFileError(file, host.getCurrentDirectory()); - tabularData += "" + leftPadding + errorCount + " " + fileRef + "\n"; + tabularData += "".concat(leftPadding).concat(errorCount, " ").concat(fileRef, "\n"); }); return tabularData; } @@ -123911,25 +124552,48 @@ var ts; var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); }; for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) { var file = _c[_i]; - write("" + toFileName(file, relativeFileName)); - (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); }); - (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" " + d.messageText); }); + write("".concat(toFileName(file, relativeFileName))); + (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write(" ".concat(fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText)); }); + (_b = explainIfFileIsRedirectAndImpliedFormat(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write(" ".concat(d.messageText)); }); } } ts.explainFiles = explainFiles; - function explainIfFileIsRedirect(file, fileNameConvertor) { + function explainIfFileIsRedirectAndImpliedFormat(file, fileNameConvertor) { + var _a; var result; if (file.path !== file.resolvedPath) { - (result || (result = [])).push(ts.chainDiagnosticMessages( + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor))); } if (file.redirectInfo) { - (result || (result = [])).push(ts.chainDiagnosticMessages( + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor))); } + if (ts.isExternalOrCommonJsModule(file)) { + switch (file.impliedNodeFormat) { + case ts.ModuleKind.ESNext: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.File_is_ECMAScript_module_because_0_has_field_type_with_value_module, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + break; + case ts.ModuleKind.CommonJS: + if (file.packageJsonScope) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, file.packageJsonScope.packageJsonContent.type ? + ts.Diagnostics.File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module : + ts.Diagnostics.File_is_CommonJS_module_because_0_does_not_have_field_type, toFileName(ts.last(file.packageJsonLocations), fileNameConvertor))); + } + else if ((_a = file.packageJsonLocations) === null || _a === void 0 ? void 0 : _a.length) { + (result !== null && result !== void 0 ? result : (result = [])).push(ts.chainDiagnosticMessages( + /*details*/ undefined, ts.Diagnostics.File_is_CommonJS_module_because_package_json_was_not_found)); + } + break; + } + } return result; } - ts.explainIfFileIsRedirect = explainIfFileIsRedirect; + ts.explainIfFileIsRedirectAndImpliedFormat = explainIfFileIsRedirectAndImpliedFormat; function getMatchedFileSpec(program, fileName) { var _a; var configFile = program.getCompilerOptions().configFile; @@ -123949,14 +124613,14 @@ var ts; // Return true if its default include spec if (configFile.configFileSpecs.isDefaultIncludeSpec) return true; - var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Json */); + var isJsonFile = ts.fileExtensionIs(fileName, ".json" /* Extension.Json */); var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory())); var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames(); return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) { - if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Json */)) + if (isJsonFile && !ts.endsWith(includeSpec, ".json" /* Extension.Json */)) return false; var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files"); - return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName); + return !!pattern && ts.getRegexFromPattern("(".concat(pattern, ")$"), useCaseSensitiveFileNames).test(fileName); }); } ts.getMatchedIncludeSpec = getMatchedIncludeSpec; @@ -123965,7 +124629,7 @@ var ts; var options = program.getCompilerOptions(); if (ts.isReferencedFile(reason)) { var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason); - var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\""; + var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"".concat(referenceLocation.text, "\""); var message = void 0; ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports"); switch (reason.kind) { @@ -124091,7 +124755,7 @@ var ts; var currentDir_1 = program.getCurrentDirectory(); ts.forEach(emittedFiles, function (file) { var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1); - write("TSFILE: " + filepath); + write("TSFILE: ".concat(filepath)); }); listFiles(program, write); } @@ -124139,6 +124803,7 @@ var ts; MissingFile: "Missing file", WildcardDirectory: "Wild card directory", FailedLookupLocations: "Failed Lookup Locations", + AffectingFileLocation: "File location affecting resolution", TypeRoots: "Type roots", ConfigFileOfReferencedProject: "Config file of referened project", ExtendedConfigOfReferencedProject: "Extended config file of referenced project", @@ -124199,7 +124864,6 @@ var ts; readDirectory: ts.maybeBind(host, host.readDirectory), disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, - now: ts.maybeBind(host, host.now), }; function writeFile(fileName, text, writeByteOrderMark, onError) { try { @@ -124357,7 +125021,6 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - host.now = ts.maybeBind(system, system.now); ts.setGetSourceFileAsHashVersioned(host, system); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; @@ -124408,7 +125071,6 @@ var ts; var parsedConfigs; // Parsed commandline and watching cached for referenced projects var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation - var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files @@ -124439,7 +125101,7 @@ var ts; } var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog; var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); - writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames); + writeLog("Current directory: ".concat(currentDirectory, " CaseSensitiveFileNames: ").concat(useCaseSensitiveFileNames)); var configFileWatcher; if (configFileName) { configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); @@ -124465,7 +125127,7 @@ var ts; compilerHost.getCompilationSettings = function () { return compilerOptions; }; compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect); compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); }; - compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.PackageJson); }; + compilerHost.watchAffectingFileLocation = function (file, cb) { return watchFile(file, cb, ts.PollingInterval.High, watchOptions, ts.WatchType.AffectingFileLocation); }; compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); }; compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; }; compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations; @@ -124499,6 +125161,9 @@ var ts; return host.resolveTypeReferenceDirectives.apply(host, args); }) : (function (typeDirectiveNames, containingFile, redirectedReference, _options, containingFileMode) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference, containingFileMode); }); + compilerHost.getModuleResolutionCache = host.resolveModuleNames ? + ts.maybeBind(host, host.getModuleResolutionCache) : + (function () { return resolutionCache.getModuleResolutionCache(); }); var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives; builderProgram = readBuilderProgram(compilerOptions, compilerHost); synchronizeProgram(); @@ -124561,12 +125226,12 @@ var ts; var program = getCurrentBuilderProgram(); if (hasChangedCompilerOptions) { newLine = updateNewLine(); - if (program && (changesAffectResolution || ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) { + if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) { resolutionCache.clear(); } } // All resolutions are invalid if user provided resolutions - var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution); + var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution); if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { @@ -124582,7 +125247,6 @@ var ts; } createNewProgram(hasInvalidatedResolution); } - changesAffectResolution = false; // reset for next sync reportFileChangeDetectedOnCreateProgram = false; if (host.afterProgramCreate && program !== builderProgram) { host.afterProgramCreate(builderProgram); @@ -124592,18 +125256,19 @@ var ts; function createNewProgram(hasInvalidatedResolution) { // Compile the program writeLog("CreatingProgramWith::"); - writeLog(" roots: " + JSON.stringify(rootFileNames)); - writeLog(" options: " + JSON.stringify(compilerOptions)); + writeLog(" roots: ".concat(JSON.stringify(rootFileNames))); + writeLog(" options: ".concat(JSON.stringify(compilerOptions))); if (projectReferences) - writeLog(" projectReferences: " + JSON.stringify(projectReferences)); + writeLog(" projectReferences: ".concat(JSON.stringify(projectReferences))); var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram(); hasChangedCompilerOptions = false; hasChangedConfigFileParsingErrors = false; resolutionCache.startCachingPerDirectoryResolution(); compilerHost.hasInvalidatedResolution = hasInvalidatedResolution; compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames; + var oldProgram = getCurrentProgram(); builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); - resolutionCache.finishCachingPerDirectoryResolution(); + resolutionCache.finishCachingPerDirectoryResolution(builderProgram.getProgram(), oldProgram); // Update watches ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath); if (needsUpdateInTypeRootWatch) { @@ -124685,9 +125350,6 @@ var ts; sourceFilesCache.set(path, false); } } - if (sourceFile) { - sourceFile.impliedNodeFormat = ts.getImpliedNodeFormatForFile(path, resolutionCache.getModuleResolutionCache().getPackageJsonInfoCache(), compilerHost, compilerHost.getCompilationSettings()); - } return sourceFile; } return hostSourceFile.sourceFile; @@ -124750,7 +125412,7 @@ var ts; return resolutionCache.invalidateResolutionsOfFailedLookupLocations(); } var pending = clearInvalidateResolutionsOfFailedLookupLocations(); - writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : "")); + writeLog("Scheduling invalidateFailedLookup".concat(pending ? ", Cancelled earlier one" : "")); timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250); } function invalidateResolutionsOfFailedLookup() { @@ -124811,7 +125473,7 @@ var ts; synchronizeProgram(); } function reloadConfigFile() { - writeLog("Reloading config file: " + configFileName); + writeLog("Reloading config file: ".concat(configFileName)); reloadLevel = ts.ConfigFileProgramReloadLevel.None; if (cachedDirectoryStructureHost) { cachedDirectoryStructureHost.clearCache(); @@ -124852,7 +125514,7 @@ var ts; return config.parsedCommandLine; } } - writeLog("Loading config file: " + configFileName); + writeLog("Loading config file: ".concat(configFileName)); var parsedCommandLine = host.getParsedCommandLine ? host.getParsedCommandLine(configFileName) : getParsedCommandLineFromConfigFileHost(configFileName); @@ -125081,7 +125743,7 @@ var ts; UpToDateStatusType[UpToDateStatusType["ForceBuild"] = 14] = "ForceBuild"; })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {})); function resolveConfigFileProjectName(project) { - if (ts.fileExtensionIs(project, ".json" /* Json */)) { + if (ts.fileExtensionIs(project, ".json" /* Extension.Json */)) { return project; } return ts.combinePaths(project, "tsconfig.json"); @@ -125144,8 +125806,8 @@ var ts; */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; - output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); + var output = pretty ? "[".concat(ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey), "] ") : "".concat(ts.getLocaleTimeString(system), " - "); + output += "".concat(ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine)).concat(system.newLine + system.newLine); system.write(output); }; } @@ -125203,6 +125865,7 @@ var ts; compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); + compilerHost.getModuleResolutionCache = ts.maybeBind(host, host.getModuleResolutionCache); var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined; var typeReferenceDirectiveResolutionCache = !compilerHost.resolveTypeReferenceDirectives ? ts.createTypeReferenceDirectiveResolutionCache(currentDirectory, getCanonicalFileName, /*options*/ undefined, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache()) : undefined; if (!compilerHost.resolveModuleNames) { @@ -125685,8 +126348,7 @@ var ts; } // Actual Emit var host = state.host, compilerHost = state.compilerHost; - var resultFlags = BuildResultFlags.DeclarationOutputUnchanged; - var existingBuildInfo = ((_d = state.buildInfoCache.get(projectPath)) === null || _d === void 0 ? void 0 : _d.buildInfo) || undefined; + var resultFlags = ((_d = program.hasChangedEmitSignature) === null || _d === void 0 ? void 0 : _d.call(program)) ? BuildResultFlags.None : BuildResultFlags.DeclarationOutputUnchanged; var emitterDiagnostics = ts.createDiagnosticCollection(); var emittedOutputs = new ts.Map(); var options = program.getCompilerOptions(); @@ -125694,17 +126356,11 @@ var ts; var outputTimeStampMap; var now; outputFiles.forEach(function (_a) { - var _b, _c; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; var path = toPath(state, name); emittedOutputs.set(toPath(state, name), name); - if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, options); - // Buildinfo has information on when last dts change time - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo === null || existingBuildInfo === void 0 ? void 0 : existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { - resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; - } - } + if (buildInfo) + setBuildInfo(state, buildInfo, projectPath, options, resultFlags); ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); if (!isIncremental && state.watch) { (outputTimeStampMap || (outputTimeStampMap = getOutputTimeStampMap(state, projectPath))).set(path, now || (now = getCurrentTime(state.host))); @@ -125718,7 +126374,7 @@ var ts; ts.Debug.assert(step === BuildStep.EmitBuildInfo); var emitResult = program.emitBuildInfo(function (name, text, writeByteOrderMark, onError, sourceFiles, data) { if (data === null || data === void 0 ? void 0 : data.buildInfo) - setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions()); + setBuildInfo(state, data.buildInfo, projectPath, program.getCompilerOptions(), BuildResultFlags.DeclarationOutputUnchanged); if (writeFileCallback) writeFileCallback(name, text, writeByteOrderMark, onError, sourceFiles, data); else @@ -125751,7 +126407,6 @@ var ts; state.diagnostics.delete(projectPath); state.projectStatus.set(projectPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, config.options, projectPath), oldestOutputFileName: oldestOutputFileName }); afterProgramDone(state, program, config); @@ -125793,10 +126448,10 @@ var ts; var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark, buildInfo = _a.buildInfo; emittedOutputs.set(toPath(state, name), name); if (buildInfo) { - setBuildInfo(state, buildInfo, projectPath, config.options); - if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.dtsChangeTime) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime)) { + if (((_b = buildInfo.program) === null || _b === void 0 ? void 0 : _b.outSignature) !== ((_c = existingBuildInfo.program) === null || _c === void 0 ? void 0 : _c.outSignature)) { resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged; } + setBuildInfo(state, buildInfo, projectPath, config.options, resultFlags); } ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark); }); @@ -125957,7 +126612,7 @@ var ts; function listEmittedFile(_a, proj, file) { var write = _a.write; if (write && proj.options.listEmittedFiles) { - write("TSFILE: " + file); + write("TSFILE: ".concat(file)); } } function getOldProgram(_a, proj, parsed) { @@ -125971,7 +126626,7 @@ var ts; } function afterProgramDone(state, program, config) { if (program) { - if (program && state.write) + if (state.write) ts.listFiles(program, state.write); if (state.host.afterProgramEmitAndDiagnostics) { state.host.afterProgramEmitAndDiagnostics(program); @@ -125987,7 +126642,7 @@ var ts; // Since buildinfo has changeset and diagnostics when doing multi file emit, only --out cannot emit buildinfo if it has errors var canEmitBuildInfo = program && !ts.outFile(program.getCompilerOptions()); reportAndStoreErrors(state, resolvedPath, diagnostics); - state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" }); + state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: "".concat(errorType, " errors") }); if (canEmitBuildInfo) return { buildResult: buildResult, step: BuildStep.EmitBuildInfo }; afterProgramDone(state, program, config); @@ -126055,15 +126710,23 @@ var ts; state.outputTimeStamps.set(resolvedConfigFilePath, result = new ts.Map()); return result; } - function setBuildInfo(state, buildInfo, resolvedConfigPath, options) { + function setBuildInfo(state, buildInfo, resolvedConfigPath, options, resultFlags) { var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); var existing = getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath); + var modifiedTime = getCurrentTime(state.host); if (existing) { existing.buildInfo = buildInfo; - existing.modifiedTime = getCurrentTime(state.host); + existing.modifiedTime = modifiedTime; + if (!(resultFlags & BuildResultFlags.DeclarationOutputUnchanged)) + existing.latestChangedDtsTime = modifiedTime; } else { - state.buildInfoCache.set(resolvedConfigPath, { path: toPath(state, buildInfoPath), buildInfo: buildInfo, modifiedTime: getCurrentTime(state.host) }); + state.buildInfoCache.set(resolvedConfigPath, { + path: toPath(state, buildInfoPath), + buildInfo: buildInfo, + modifiedTime: modifiedTime, + latestChangedDtsTime: resultFlags & BuildResultFlags.DeclarationOutputUnchanged ? undefined : modifiedTime, + }); } } function getBuildInfoCacheEntry(state, buildInfoPath, resolvedConfigPath) { @@ -126095,7 +126758,7 @@ var ts; } } function getUpToDateStatusWorker(state, project, resolvedPath) { - var _a, _b, _c; + var _a, _b; // Container if no files are specified in the project if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) { return { @@ -126107,8 +126770,8 @@ var ts; var force = !!state.options.force; if (project.projectReferences) { state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream }); - for (var _i = 0, _d = project.projectReferences; _i < _d.length; _i++) { - var ref = _d[_i]; + for (var _i = 0, _c = project.projectReferences; _i < _c.length; _i++) { + var ref = _c[_i]; var resolvedRef = ts.resolveProjectReferencePath(ref); var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef); var resolvedConfig = parseConfigFile(state, resolvedRef, resolvedRefPath); @@ -126148,7 +126811,6 @@ var ts; var buildInfoTime; var buildInfoProgram; var buildInfoVersionMap; - var newestDeclarationFileContentChangedTime; if (buildInfoPath) { var buildInfoCacheEntry_1 = getBuildInfoCacheEntry(state, buildInfoPath, resolvedPath); buildInfoTime = (buildInfoCacheEntry_1 === null || buildInfoCacheEntry_1 === void 0 ? void 0 : buildInfoCacheEntry_1.modifiedTime) || ts.getModifiedTime(host, buildInfoPath); @@ -126185,8 +126847,6 @@ var ts; } oldestOutputFileTime = buildInfoTime; oldestOutputFileName = buildInfoPath; - // Get the last dtsChange time from build info - newestDeclarationFileContentChangedTime = ((_c = buildInfo.program) === null || _c === void 0 ? void 0 : _c.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; } // Check input files var newestInputFileName = undefined; @@ -126194,13 +126854,13 @@ var ts; /** True if input file has changed timestamp but text is not changed, we can then do only timestamp updates on output to make it look up-to-date later */ var pseudoInputUpToDate = false; // Get timestamps of input files - for (var _e = 0, _f = project.fileNames; _e < _f.length; _e++) { - var inputFile = _f[_e]; + for (var _d = 0, _e = project.fileNames; _d < _e.length; _d++) { + var inputFile = _e[_d]; var inputTime = getModifiedTime(state, inputFile); if (inputTime === ts.missingFileModifiedTime) { return { type: ts.UpToDateStatusType.Unbuildable, - reason: inputFile + " does not exist" + reason: "".concat(inputFile, " does not exist") }; } // If an buildInfo is older than the newest input, we can stop checking @@ -126236,8 +126896,8 @@ var ts; // Collect the expected outputs of this project var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames()); var outputTimeStampMap = getOutputTimeStampMap(state, resolvedPath); - for (var _g = 0, outputs_1 = outputs; _g < outputs_1.length; _g++) { - var output = outputs_1[_g]; + for (var _f = 0, outputs_1 = outputs; _f < outputs_1.length; _f++) { + var output = outputs_1[_f]; var path = toPath(state, output); // Output is missing; can stop checking var outputTime = outputTimeStampMap === null || outputTimeStampMap === void 0 ? void 0 : outputTimeStampMap.get(path); @@ -126275,8 +126935,8 @@ var ts; var usesPrepend = false; var upstreamChangedProject; if (referenceStatuses) { - for (var _h = 0, referenceStatuses_1 = referenceStatuses; _h < referenceStatuses_1.length; _h++) { - var _j = referenceStatuses_1[_h], ref = _j.ref, refStatus = _j.refStatus, resolvedConfig = _j.resolvedConfig, resolvedRefPath = _j.resolvedRefPath; + for (var _g = 0, referenceStatuses_1 = referenceStatuses; _g < referenceStatuses_1.length; _g++) { + var _h = referenceStatuses_1[_g], ref = _h.ref, refStatus = _h.refStatus, resolvedConfig = _h.resolvedConfig, resolvedRefPath = _h.resolvedRefPath; usesPrepend = usesPrepend || !!(ref.prepend); // If the upstream project's newest file is older than our oldest output, we // can't be out of date because of it @@ -126293,7 +126953,8 @@ var ts; } // If the upstream project has only change .d.ts files, and we've built // *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild - if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { + var newestDeclarationFileContentChangedTime = getLatestChangedDtsTime(state, resolvedConfig.options, resolvedRefPath); + if (newestDeclarationFileContentChangedTime && newestDeclarationFileContentChangedTime <= oldestOutputFileTime) { pseudoUpToDate = true; upstreamChangedProject = ref.path; continue; @@ -126336,7 +126997,6 @@ var ts; pseudoInputUpToDate ? ts.UpToDateStatusType.UpToDateWithInputFileText : ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime, newestInputFileTime: newestInputFileTime, newestInputFileName: newestInputFileName, oldestOutputFileName: oldestOutputFileName @@ -126420,13 +127080,17 @@ var ts; outputTimeStampMap.delete(key); }); } - function getDtsChangeTime(state, options, resolvedConfigPath) { - var _a; + function getLatestChangedDtsTime(state, options, resolvedConfigPath) { if (!options.composite) return undefined; - var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(options); - var buildInfo = getBuildInfo(state, buildInfoPath, resolvedConfigPath, /*modifiedTime*/ undefined); - return ((_a = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.program) === null || _a === void 0 ? void 0 : _a.dtsChangeTime) ? new Date(buildInfo.program.dtsChangeTime) : undefined; + var entry = ts.Debug.checkDefined(state.buildInfoCache.get(resolvedConfigPath)); + if (entry.latestChangedDtsTime !== undefined) + return entry.latestChangedDtsTime || undefined; + var latestChangedDtsTime = entry.buildInfo && entry.buildInfo.program && entry.buildInfo.program.latestChangedDtsFile ? + state.host.getModifiedTime(ts.getNormalizedAbsolutePath(entry.buildInfo.program.latestChangedDtsFile, ts.getDirectoryPath(entry.path))) : + undefined; + entry.latestChangedDtsTime = latestChangedDtsTime || false; + return latestChangedDtsTime; } function updateOutputTimestamps(state, proj, resolvedPath) { if (state.options.dry) { @@ -126435,7 +127099,6 @@ var ts; updateOutputTimestampsWorker(state, proj, resolvedPath, ts.Diagnostics.Updating_output_timestamps_of_project_0); state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.UpToDate, - newestDeclarationFileContentChangedTime: getDtsChangeTime(state, proj.options, resolvedPath), oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames()) }); } @@ -126571,7 +127234,7 @@ var ts; } } if (filesToDelete) { - reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join("")); + reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * ".concat(f); }).join("")); } return ts.ExitStatus.Success; } @@ -126921,7 +127584,7 @@ var ts; function nowString() { // E.g. "12:34:56.789" var d = new Date(); - return ts.padLeft(d.getHours().toString(), 2, "0") + ":" + ts.padLeft(d.getMinutes().toString(), 2, "0") + ":" + ts.padLeft(d.getSeconds().toString(), 2, "0") + "." + ts.padLeft(d.getMilliseconds().toString(), 3, "0"); + return "".concat(ts.padLeft(d.getHours().toString(), 2, "0"), ":").concat(ts.padLeft(d.getMinutes().toString(), 2, "0"), ":").concat(ts.padLeft(d.getSeconds().toString(), 2, "0"), ".").concat(ts.padLeft(d.getMilliseconds().toString(), 3, "0")); } server.nowString = nowString; })(server = ts.server || (ts.server = {})); @@ -126932,7 +127595,7 @@ var ts; var JsTyping; (function (JsTyping) { function isTypingUpToDate(cachedTyping, availableTypingVersions) { - var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts" + ts.versionMajorMinor) || ts.getProperty(availableTypingVersions, "latest")); + var availableVersion = new ts.Version(ts.getProperty(availableTypingVersions, "ts".concat(ts.versionMajorMinor)) || ts.getProperty(availableTypingVersions, "latest")); return availableVersion.compareTo(cachedTyping.version) <= 0; } JsTyping.isTypingUpToDate = isTypingUpToDate; @@ -126985,7 +127648,7 @@ var ts; "worker_threads", "zlib" ]; - JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:" + name; }); + JsTyping.prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(function (name) { return "node:".concat(name); }); JsTyping.nodeCoreModuleList = __spreadArray(__spreadArray([], unprefixedNodeCoreModuleList, true), JsTyping.prefixedNodeCoreModuleList, true); JsTyping.nodeCoreModules = new ts.Set(JsTyping.nodeCoreModuleList); function nonRelativeModuleNameForTypingCache(moduleName) { @@ -127060,7 +127723,7 @@ var ts; var excludeTypingName = exclude_1[_i]; var didDelete = inferredTypings.delete(excludeTypingName); if (didDelete && log) - log("Typing for " + excludeTypingName + " is in exclude list, will be ignored."); + log("Typing for ".concat(excludeTypingName, " is in exclude list, will be ignored.")); } var newTypingNames = []; var cachedTypingPaths = []; @@ -127074,7 +127737,7 @@ var ts; }); var result = { cachedTypingPaths: cachedTypingPaths, newTypingNames: newTypingNames, filesToWatch: filesToWatch }; if (log) - log("Result: " + JSON.stringify(result)); + log("Result: ".concat(JSON.stringify(result))); return result; function addInferredTyping(typingName) { if (!inferredTypings.has(typingName)) { @@ -127083,7 +127746,7 @@ var ts; } function addInferredTypings(typingNames, message) { if (log) - log(message + ": " + JSON.stringify(typingNames)); + log("".concat(message, ": ").concat(JSON.stringify(typingNames))); ts.forEach(typingNames, addInferredTyping); } /** @@ -127105,7 +127768,7 @@ var ts; filesToWatch.push(manifestPath); manifest = ts.readConfigFile(manifestPath, function (path) { return host.readFile(path); }).config; manifestTypingNames = ts.flatMap([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies], ts.getOwnKeys); - addInferredTypings(manifestTypingNames, "Typing names in '" + manifestPath + "' dependencies"); + addInferredTypings(manifestTypingNames, "Typing names in '".concat(manifestPath, "' dependencies")); } // Now we scan the directories for typing information in // already-installed dependencies (if present). Note that this @@ -127133,7 +127796,7 @@ var ts; // This is #1 described above. ? manifestTypingNames.map(function (typingName) { return ts.combinePaths(packagesFolderPath, typingName, manifestName); }) // And #2. Depth = 3 because scoped packages look like `node_modules/@foo/bar/package.json` - : host.readDirectory(packagesFolderPath, [".json" /* Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) + : host.readDirectory(packagesFolderPath, [".json" /* Extension.Json */], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 3) .filter(function (manifestPath) { if (ts.getBaseFileName(manifestPath) !== manifestName) { return false; @@ -127149,7 +127812,7 @@ var ts; !isScoped && pathComponents[pathComponents.length - 3].toLowerCase() === modulesDirName; // `node_modules/foo` }); if (log) - log("Searching for typing names in " + packagesFolderPath + "; all files: " + JSON.stringify(dependencyManifestNames)); + log("Searching for typing names in ".concat(packagesFolderPath, "; all files: ").concat(JSON.stringify(dependencyManifestNames))); // Once we have the names of things to look up, we iterate over // and either collect their included typings, or add them to the // list of typings we need to look up separately. @@ -127168,12 +127831,12 @@ var ts; var absolutePath = ts.getNormalizedAbsolutePath(ownTypes, ts.getDirectoryPath(normalizedFileName)); if (host.fileExists(absolutePath)) { if (log) - log(" Package '" + manifest_1.name + "' provides its own types."); + log(" Package '".concat(manifest_1.name, "' provides its own types.")); inferredTypings.set(manifest_1.name, absolutePath); } else { if (log) - log(" Package '" + manifest_1.name + "' provides its own types but they are missing."); + log(" Package '".concat(manifest_1.name, "' provides its own types but they are missing.")); } } else { @@ -127199,7 +127862,7 @@ var ts; if (fromFileNames.length) { addInferredTypings(fromFileNames, "Inferred typings from file names"); } - var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Jsx */); }); + var hasJsxFile = ts.some(fileNames, function (f) { return ts.fileExtensionIs(f, ".jsx" /* Extension.Jsx */); }); if (hasJsxFile) { if (log) log("Inferred 'react' typings due to presence of '.jsx' extension"); @@ -127227,16 +127890,16 @@ var ts; JsTyping.validatePackageName = validatePackageName; function validatePackageNameWorker(packageName, supportScopedPackage) { if (!packageName) { - return 1 /* EmptyName */; + return 1 /* NameValidationResult.EmptyName */; } if (packageName.length > maxPackageNameLength) { - return 2 /* NameTooLong */; + return 2 /* NameValidationResult.NameTooLong */; } - if (packageName.charCodeAt(0) === 46 /* dot */) { - return 3 /* NameStartsWithDot */; + if (packageName.charCodeAt(0) === 46 /* CharacterCodes.dot */) { + return 3 /* NameValidationResult.NameStartsWithDot */; } - if (packageName.charCodeAt(0) === 95 /* _ */) { - return 4 /* NameStartsWithUnderscore */; + if (packageName.charCodeAt(0) === 95 /* CharacterCodes._ */) { + return 4 /* NameValidationResult.NameStartsWithUnderscore */; } // check if name is scope package like: starts with @ and has one '/' in the middle // scoped packages are not currently supported @@ -127244,20 +127907,20 @@ var ts; var matches = /^@([^/]+)\/([^/]+)$/.exec(packageName); if (matches) { var scopeResult = validatePackageNameWorker(matches[1], /*supportScopedPackage*/ false); - if (scopeResult !== 0 /* Ok */) { + if (scopeResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[1], isScopeName: true, result: scopeResult }; } var packageResult = validatePackageNameWorker(matches[2], /*supportScopedPackage*/ false); - if (packageResult !== 0 /* Ok */) { + if (packageResult !== 0 /* NameValidationResult.Ok */) { return { name: matches[2], isScopeName: false, result: packageResult }; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } } if (encodeURIComponent(packageName) !== packageName) { - return 5 /* NameContainsNonURISafeCharacters */; + return 5 /* NameValidationResult.NameContainsNonURISafeCharacters */; } - return 0 /* Ok */; + return 0 /* NameValidationResult.Ok */; } function renderPackageNameValidationFailure(result, typing) { return typeof result === "object" ? @@ -127268,17 +127931,17 @@ var ts; function renderPackageNameValidationFailureWorker(typing, result, name, isScopeName) { var kind = isScopeName ? "Scope" : "Package"; switch (result) { - case 1 /* EmptyName */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot be empty"; - case 2 /* NameTooLong */: - return "'" + typing + "':: " + kind + " name '" + name + "' should be less than " + maxPackageNameLength + " characters"; - case 3 /* NameStartsWithDot */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '.'"; - case 4 /* NameStartsWithUnderscore */: - return "'" + typing + "':: " + kind + " name '" + name + "' cannot start with '_'"; - case 5 /* NameContainsNonURISafeCharacters */: - return "'" + typing + "':: " + kind + " name '" + name + "' contains non URI safe characters"; - case 0 /* Ok */: + case 1 /* NameValidationResult.EmptyName */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot be empty"); + case 2 /* NameValidationResult.NameTooLong */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' should be less than ").concat(maxPackageNameLength, " characters"); + case 3 /* NameValidationResult.NameStartsWithDot */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '.'"); + case 4 /* NameValidationResult.NameStartsWithUnderscore */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' cannot start with '_'"); + case 5 /* NameValidationResult.NameContainsNonURISafeCharacters */: + return "'".concat(typing, "':: ").concat(kind, " name '").concat(name, "' contains non URI safe characters"); + case 0 /* NameValidationResult.Ok */: return ts.Debug.fail(); // Shouldn't have called this. default: throw ts.Debug.assertNever(result); @@ -127303,7 +127966,7 @@ var ts; } catch (e) { if (log.isEnabled()) { - log.writeLine("Failed to resolve " + packageName + " in folder '" + cachePath + "': " + e.message); + log.writeLine("Failed to resolve ".concat(packageName, " in folder '").concat(cachePath, "': ").concat(e.message)); } return undefined; } @@ -127324,7 +127987,7 @@ var ts; var sliceStart = packageNames.length - remaining; var command, toSlice = remaining; while (true) { - command = npmPath + " install --ignore-scripts " + (toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice)).join(" ") + " --save-dev --user-agent=\"typesInstaller/" + tsVersion + "\""; + command = "".concat(npmPath, " install --ignore-scripts ").concat((toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice)).join(" "), " --save-dev --user-agent=\"typesInstaller/").concat(tsVersion, "\""); if (command.length < 8000) { break; } @@ -127337,13 +128000,13 @@ var ts; var expectedPos = str.length - suffix.length; return expectedPos >= 0 && (str.indexOf(suffix, expectedPos) === expectedPos || - (!caseSensitive && ts.compareStringsCaseInsensitive(str.substr(expectedPos), suffix) === 0 /* EqualTo */)); + (!caseSensitive && ts.compareStringsCaseInsensitive(str.substr(expectedPos), suffix) === 0 /* Comparison.EqualTo */)); } function isPackageOrBowerJson(fileName, caseSensitive) { return endsWith(fileName, "/package.json", caseSensitive) || endsWith(fileName, "/bower.json", caseSensitive); } function sameFiles(a, b, caseSensitive) { - return a === b || (!caseSensitive && ts.compareStringsCaseInsensitive(a, b) === 0 /* EqualTo */); + return a === b || (!caseSensitive && ts.compareStringsCaseInsensitive(a, b) === 0 /* Comparison.EqualTo */); } var ProjectWatcherType; (function (ProjectWatcherType) { @@ -127351,12 +128014,12 @@ var ts; ProjectWatcherType["DirectoryWatcher"] = "DirectoryWatcher"; })(ProjectWatcherType || (ProjectWatcherType = {})); function getDetailWatchInfo(projectName, watchers) { - return "Project: " + projectName + " watcher already invoked: " + watchers.isInvoked; + return "Project: ".concat(projectName, " watcher already invoked: ").concat(watchers.isInvoked); } var TypingsInstaller = /** @class */ (function () { function TypingsInstaller(installTypingHost, globalCachePath, safeListPath, typesMapLocation, throttleLimit, log) { - var _this = this; if (log === void 0) { log = nullLog; } + var _this = this; this.installTypingHost = installTypingHost; this.globalCachePath = globalCachePath; this.safeListPath = safeListPath; @@ -127375,7 +128038,7 @@ var ts; this.globalCachePackageJsonPath = ts.combinePaths(globalCachePath, "package.json"); var isLoggingEnabled = this.log.isEnabled(); if (isLoggingEnabled) { - this.log.writeLine("Global cache location '" + globalCachePath + "', safe file path '" + safeListPath + "', types map path " + typesMapLocation); + this.log.writeLine("Global cache location '".concat(globalCachePath, "', safe file path '").concat(safeListPath, "', types map path ").concat(typesMapLocation)); } this.watchFactory = ts.getWatchFactory(this.installTypingHost, isLoggingEnabled ? ts.WatchLogLevel.Verbose : ts.WatchLogLevel.None, function (s) { return _this.log.writeLine(s); }, getDetailWatchInfo); this.processCacheLocation(this.globalCachePath); @@ -127385,30 +128048,30 @@ var ts; }; TypingsInstaller.prototype.closeWatchers = function (projectName) { if (this.log.isEnabled()) { - this.log.writeLine("Closing file watchers for project '" + projectName + "'"); + this.log.writeLine("Closing file watchers for project '".concat(projectName, "'")); } var watchers = this.projectWatchers.get(projectName); if (!watchers) { if (this.log.isEnabled()) { - this.log.writeLine("No watchers are registered for project '" + projectName + "'"); + this.log.writeLine("No watchers are registered for project '".concat(projectName, "'")); } return; } ts.clearMap(watchers, ts.closeFileWatcher); this.projectWatchers.delete(projectName); if (this.log.isEnabled()) { - this.log.writeLine("Closing file watchers for project '" + projectName + "' - done."); + this.log.writeLine("Closing file watchers for project '".concat(projectName, "' - done.")); } }; TypingsInstaller.prototype.install = function (req) { var _this = this; if (this.log.isEnabled()) { - this.log.writeLine("Got install request " + JSON.stringify(req)); + this.log.writeLine("Got install request ".concat(JSON.stringify(req))); } // load existing typing information from the cache if (req.cachePath) { if (this.log.isEnabled()) { - this.log.writeLine("Request specifies cache path '" + req.cachePath + "', loading cached information..."); + this.log.writeLine("Request specifies cache path '".concat(req.cachePath, "', loading cached information...")); } this.processCacheLocation(req.cachePath); } @@ -127417,7 +128080,7 @@ var ts; } var discoverTypingsResult = ts.JsTyping.discoverTypings(this.installTypingHost, this.log.isEnabled() ? (function (s) { return _this.log.writeLine(s); }) : undefined, req.fileNames, req.projectRootPath, this.safeList, this.packageNameToTypingLocation, req.typeAcquisition, req.unresolvedImports, this.typesRegistry, req.compilerOptions); if (this.log.isEnabled()) { - this.log.writeLine("Finished typings discovery: " + JSON.stringify(discoverTypingsResult)); + this.log.writeLine("Finished typings discovery: ".concat(JSON.stringify(discoverTypingsResult))); } // start watching files this.watchFiles(req.projectName, discoverTypingsResult.filesToWatch, req.projectRootPath, req.watchOptions); @@ -127437,17 +128100,17 @@ var ts; if (this.typesMapLocation) { var safeListFromMap = ts.JsTyping.loadTypesMap(this.installTypingHost, this.typesMapLocation); if (safeListFromMap) { - this.log.writeLine("Loaded safelist from types map file '" + this.typesMapLocation + "'"); + this.log.writeLine("Loaded safelist from types map file '".concat(this.typesMapLocation, "'")); this.safeList = safeListFromMap; return; } - this.log.writeLine("Failed to load safelist from types map file '" + this.typesMapLocation + "'"); + this.log.writeLine("Failed to load safelist from types map file '".concat(this.typesMapLocation, "'")); } this.safeList = ts.JsTyping.loadSafeList(this.installTypingHost, this.safeListPath); }; TypingsInstaller.prototype.processCacheLocation = function (cacheLocation) { if (this.log.isEnabled()) { - this.log.writeLine("Processing cache location '" + cacheLocation + "'"); + this.log.writeLine("Processing cache location '".concat(cacheLocation, "'")); } if (this.knownCachesSet.has(cacheLocation)) { if (this.log.isEnabled()) { @@ -127458,14 +128121,14 @@ var ts; var packageJson = ts.combinePaths(cacheLocation, "package.json"); var packageLockJson = ts.combinePaths(cacheLocation, "package-lock.json"); if (this.log.isEnabled()) { - this.log.writeLine("Trying to find '" + packageJson + "'..."); + this.log.writeLine("Trying to find '".concat(packageJson, "'...")); } if (this.installTypingHost.fileExists(packageJson) && this.installTypingHost.fileExists(packageLockJson)) { var npmConfig = JSON.parse(this.installTypingHost.readFile(packageJson)); // TODO: GH#18217 var npmLock = JSON.parse(this.installTypingHost.readFile(packageLockJson)); // TODO: GH#18217 if (this.log.isEnabled()) { - this.log.writeLine("Loaded content of '" + packageJson + "': " + JSON.stringify(npmConfig)); - this.log.writeLine("Loaded content of '" + packageLockJson + "'"); + this.log.writeLine("Loaded content of '".concat(packageJson, "': ").concat(JSON.stringify(npmConfig))); + this.log.writeLine("Loaded content of '".concat(packageLockJson, "'")); } if (npmConfig.devDependencies && npmLock.dependencies) { for (var key in npmConfig.devDependencies) { @@ -127489,11 +128152,11 @@ var ts; continue; } if (this.log.isEnabled()) { - this.log.writeLine("New typing for package " + packageName + " from '" + typingFile + "' conflicts with existing typing file '" + existingTypingFile + "'"); + this.log.writeLine("New typing for package ".concat(packageName, " from '").concat(typingFile, "' conflicts with existing typing file '").concat(existingTypingFile, "'")); } } if (this.log.isEnabled()) { - this.log.writeLine("Adding entry into typings cache: '" + packageName + "' => '" + typingFile + "'"); + this.log.writeLine("Adding entry into typings cache: '".concat(packageName, "' => '").concat(typingFile, "'")); } var info = ts.getProperty(npmLock.dependencies, key); var version_1 = info && info.version; @@ -127506,7 +128169,7 @@ var ts; } } if (this.log.isEnabled()) { - this.log.writeLine("Finished processing cache location '" + cacheLocation + "'"); + this.log.writeLine("Finished processing cache location '".concat(cacheLocation, "'")); } this.knownCachesSet.add(cacheLocation); }; @@ -127516,11 +128179,11 @@ var ts; var typingKey = ts.mangleScopedPackageName(typing); if (_this.missingTypingsSet.has(typingKey)) { if (_this.log.isEnabled()) - _this.log.writeLine("'" + typing + "':: '" + typingKey + "' is in missingTypingsSet - skipping..."); + _this.log.writeLine("'".concat(typing, "':: '").concat(typingKey, "' is in missingTypingsSet - skipping...")); return undefined; } var validationResult = ts.JsTyping.validatePackageName(typing); - if (validationResult !== 0 /* Ok */) { + if (validationResult !== 0 /* JsTyping.NameValidationResult.Ok */) { // add typing name to missing set so we won't process it again _this.missingTypingsSet.add(typingKey); if (_this.log.isEnabled()) @@ -127529,12 +128192,12 @@ var ts; } if (!_this.typesRegistry.has(typingKey)) { if (_this.log.isEnabled()) - _this.log.writeLine("'" + typing + "':: Entry for package '" + typingKey + "' does not exist in local types registry - skipping..."); + _this.log.writeLine("'".concat(typing, "':: Entry for package '").concat(typingKey, "' does not exist in local types registry - skipping...")); return undefined; } if (_this.packageNameToTypingLocation.get(typingKey) && ts.JsTyping.isTypingUpToDate(_this.packageNameToTypingLocation.get(typingKey), _this.typesRegistry.get(typingKey))) { if (_this.log.isEnabled()) - _this.log.writeLine("'" + typing + "':: '" + typingKey + "' already has an up-to-date typing - skipping..."); + _this.log.writeLine("'".concat(typing, "':: '").concat(typingKey, "' already has an up-to-date typing - skipping...")); return undefined; } return typingKey; @@ -127543,11 +128206,11 @@ var ts; TypingsInstaller.prototype.ensurePackageDirectoryExists = function (directory) { var npmConfigPath = ts.combinePaths(directory, "package.json"); if (this.log.isEnabled()) { - this.log.writeLine("Npm config file: " + npmConfigPath); + this.log.writeLine("Npm config file: ".concat(npmConfigPath)); } if (!this.installTypingHost.fileExists(npmConfigPath)) { if (this.log.isEnabled()) { - this.log.writeLine("Npm config file: '" + npmConfigPath + "' is missing, creating new one..."); + this.log.writeLine("Npm config file: '".concat(npmConfigPath, "' is missing, creating new one...")); } this.ensureDirectoryExists(directory, this.installTypingHost); this.installTypingHost.writeFile(npmConfigPath, '{ "private": true }'); @@ -127556,7 +128219,7 @@ var ts; TypingsInstaller.prototype.installTypings = function (req, cachePath, currentlyCachedTypings, typingsToInstall) { var _this = this; if (this.log.isEnabled()) { - this.log.writeLine("Installing typings " + JSON.stringify(typingsToInstall)); + this.log.writeLine("Installing typings ".concat(JSON.stringify(typingsToInstall))); } var filteredTypings = this.filterTypings(typingsToInstall); if (filteredTypings.length === 0) { @@ -127583,7 +128246,7 @@ var ts; try { if (!ok) { if (_this.log.isEnabled()) { - _this.log.writeLine("install request failed, marking packages as missing to prevent repeated requests: " + JSON.stringify(filteredTypings)); + _this.log.writeLine("install request failed, marking packages as missing to prevent repeated requests: ".concat(JSON.stringify(filteredTypings))); } for (var _i = 0, filteredTypings_1 = filteredTypings; _i < filteredTypings_1.length; _i++) { var typing = filteredTypings_1[_i]; @@ -127593,7 +128256,7 @@ var ts; } // TODO: watch project directory if (_this.log.isEnabled()) { - _this.log.writeLine("Installed typings " + JSON.stringify(scopedTypings)); + _this.log.writeLine("Installed typings ".concat(JSON.stringify(scopedTypings))); } var installedTypingFiles = []; for (var _a = 0, filteredTypings_2 = filteredTypings; _a < filteredTypings_2.length; _a++) { @@ -127605,13 +128268,13 @@ var ts; } // packageName is guaranteed to exist in typesRegistry by filterTypings var distTags = _this.typesRegistry.get(packageName); - var newVersion = new ts.Version(distTags["ts" + ts.versionMajorMinor] || distTags[_this.latestDistTag]); + var newVersion = new ts.Version(distTags["ts".concat(ts.versionMajorMinor)] || distTags[_this.latestDistTag]); var newTyping = { typingLocation: typingFile, version: newVersion }; _this.packageNameToTypingLocation.set(packageName, newTyping); installedTypingFiles.push(typingFile); } if (_this.log.isEnabled()) { - _this.log.writeLine("Installed typing files " + JSON.stringify(installedTypingFiles)); + _this.log.writeLine("Installed typing files ".concat(JSON.stringify(installedTypingFiles))); } _this.sendResponse(_this.createSetTypings(req, currentlyCachedTypings.concat(installedTypingFiles))); } @@ -127665,9 +128328,9 @@ var ts; return; } if (isLoggingEnabled) { - _this.log.writeLine(projectWatcherType + ":: Added:: WatchInfo: " + path); + _this.log.writeLine("".concat(projectWatcherType, ":: Added:: WatchInfo: ").concat(path)); } - var watcher = projectWatcherType === "FileWatcher" /* FileWatcher */ ? + var watcher = projectWatcherType === "FileWatcher" /* ProjectWatcherType.FileWatcher */ ? _this.watchFactory.watchFile(path, function () { if (!watchers.isInvoked) { watchers.isInvoked = true; @@ -127675,7 +128338,7 @@ var ts; } }, ts.PollingInterval.High, options, projectName, watchers) : _this.watchFactory.watchDirectory(path, function (f) { - if (watchers.isInvoked || !ts.fileExtensionIs(f, ".json" /* Json */)) { + if (watchers.isInvoked || !ts.fileExtensionIs(f, ".json" /* Extension.Json */)) { return; } if (isPackageOrBowerJson(f, _this.installTypingHost.useCaseSensitiveFileNames) && @@ -127683,10 +128346,10 @@ var ts; watchers.isInvoked = true; _this.sendResponse({ projectName: projectName, kind: server.ActionInvalidate }); } - }, 1 /* Recursive */, options, projectName, watchers); + }, 1 /* WatchDirectoryFlags.Recursive */, options, projectName, watchers); watchers.set(canonicalPath, isLoggingEnabled ? { close: function () { - _this.log.writeLine(projectWatcherType + ":: Closed:: WatchInfo: " + path); + _this.log.writeLine("".concat(projectWatcherType, ":: Closed:: WatchInfo: ").concat(path)); watcher.close(); } } : watcher); @@ -127696,7 +128359,7 @@ var ts; var file = files_1[_i]; if (file.endsWith("/package.json") || file.endsWith("/bower.json")) { // package.json or bower.json exists, watch the file to detect changes and update typings - createProjectWatcher(file, "FileWatcher" /* FileWatcher */); + createProjectWatcher(file, "FileWatcher" /* ProjectWatcherType.FileWatcher */); continue; } // path in projectRoot, watch project root @@ -127704,21 +128367,21 @@ var ts; var subDirectory = file.indexOf(ts.directorySeparator, projectRootPath.length + 1); if (subDirectory !== -1) { // Watch subDirectory - createProjectWatcher(file.substr(0, subDirectory), "DirectoryWatcher" /* DirectoryWatcher */); + createProjectWatcher(file.substr(0, subDirectory), "DirectoryWatcher" /* ProjectWatcherType.DirectoryWatcher */); } else { // Watch the directory itself - createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */); + createProjectWatcher(file, "DirectoryWatcher" /* ProjectWatcherType.DirectoryWatcher */); } continue; } // path in global cache, watch global cache if (ts.containsPath(this.globalCachePath, file, projectRootPath, !this.installTypingHost.useCaseSensitiveFileNames)) { - createProjectWatcher(this.globalCachePath, "DirectoryWatcher" /* DirectoryWatcher */); + createProjectWatcher(this.globalCachePath, "DirectoryWatcher" /* ProjectWatcherType.DirectoryWatcher */); continue; } // watch node_modules or bower_components - createProjectWatcher(file, "DirectoryWatcher" /* DirectoryWatcher */); + createProjectWatcher(file, "DirectoryWatcher" /* ProjectWatcherType.DirectoryWatcher */); } // Remove unused watches toRemove.forEach(function (watch, path) { @@ -127761,7 +128424,7 @@ var ts; typingsInstaller.TypingsInstaller = TypingsInstaller; /* @internal */ function typingsName(packageName) { - return "@types/" + packageName + "@ts" + ts.versionMajorMinor; + return "@types/".concat(packageName, "@ts").concat(ts.versionMajorMinor); } typingsInstaller.typingsName = typingsName; })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); @@ -127786,7 +128449,7 @@ var ts; if (typeof _this.logFile !== "string") return; try { - fs.appendFileSync(_this.logFile, "[" + server.nowString() + "] " + text + ts.sys.newLine); + fs.appendFileSync(_this.logFile, "[".concat(server.nowString(), "] ").concat(text).concat(ts.sys.newLine)); } catch (e) { _this.logFile = undefined; @@ -127802,7 +128465,7 @@ var ts; return npmPath; } if (host.fileExists(npmPath)) { - return "\"" + npmPath + "\""; + return "\"".concat(npmPath, "\""); } } return "npm"; @@ -127810,7 +128473,7 @@ var ts; function loadTypesRegistryFile(typesRegistryFilePath, host, log) { if (!host.fileExists(typesRegistryFilePath)) { if (log.isEnabled()) { - log.writeLine("Types registry file '" + typesRegistryFilePath + "' does not exist"); + log.writeLine("Types registry file '".concat(typesRegistryFilePath, "' does not exist")); } return new ts.Map(); } @@ -127820,14 +128483,14 @@ var ts; } catch (e) { if (log.isEnabled()) { - log.writeLine("Error when loading types registry file '" + typesRegistryFilePath + "': " + e.message + ", " + e.stack); + log.writeLine("Error when loading types registry file '".concat(typesRegistryFilePath, "': ").concat(e.message, ", ").concat(e.stack)); } return new ts.Map(); } } var typesRegistryPackageName = "types-registry"; function getTypesRegistryFileLocation(globalTypingsCacheLocation) { - return ts.combinePaths(ts.normalizeSlashes(globalTypingsCacheLocation), "node_modules/" + typesRegistryPackageName + "/index.json"); + return ts.combinePaths(ts.normalizeSlashes(globalTypingsCacheLocation), "node_modules/".concat(typesRegistryPackageName, "/index.json")); } var NodeTypingsInstaller = (function (_super) { __extends(NodeTypingsInstaller, _super); @@ -127835,27 +128498,27 @@ var ts; var _this = _super.call(this, ts.sys, globalTypingsCacheLocation, typingSafeListLocation ? ts.toPath(typingSafeListLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), typesMapLocation ? ts.toPath(typesMapLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typesMap.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; _this.npmPath = npmLocation !== undefined ? npmLocation : getDefaultNPMLocation(process.argv[0], validateDefaultNpmLocation, _this.installTypingHost); if (ts.stringContains(_this.npmPath, " ") && _this.npmPath[0] !== "\"") { - _this.npmPath = "\"" + _this.npmPath + "\""; + _this.npmPath = "\"".concat(_this.npmPath, "\""); } if (_this.log.isEnabled()) { - _this.log.writeLine("Process id: " + process.pid); - _this.log.writeLine("NPM location: " + _this.npmPath + " (explicit '" + server.Arguments.NpmLocation + "' " + (npmLocation === undefined ? "not " : "") + " provided)"); - _this.log.writeLine("validateDefaultNpmLocation: " + validateDefaultNpmLocation); + _this.log.writeLine("Process id: ".concat(process.pid)); + _this.log.writeLine("NPM location: ".concat(_this.npmPath, " (explicit '").concat(server.Arguments.NpmLocation, "' ").concat(npmLocation === undefined ? "not " : "", " provided)")); + _this.log.writeLine("validateDefaultNpmLocation: ".concat(validateDefaultNpmLocation)); } (_this.nodeExecSync = require("child_process").execSync); _this.ensurePackageDirectoryExists(globalTypingsCacheLocation); try { if (_this.log.isEnabled()) { - _this.log.writeLine("Updating " + typesRegistryPackageName + " npm package..."); + _this.log.writeLine("Updating ".concat(typesRegistryPackageName, " npm package...")); } - _this.execSyncAndLog(_this.npmPath + " install --ignore-scripts " + typesRegistryPackageName + "@" + _this.latestDistTag, { cwd: globalTypingsCacheLocation }); + _this.execSyncAndLog("".concat(_this.npmPath, " install --ignore-scripts ").concat(typesRegistryPackageName, "@").concat(_this.latestDistTag), { cwd: globalTypingsCacheLocation }); if (_this.log.isEnabled()) { - _this.log.writeLine("Updated " + typesRegistryPackageName + " npm package"); + _this.log.writeLine("Updated ".concat(typesRegistryPackageName, " npm package")); } } catch (e) { if (_this.log.isEnabled()) { - _this.log.writeLine("Error updating " + typesRegistryPackageName + " package: " + e.message); + _this.log.writeLine("Error updating ".concat(typesRegistryPackageName, " package: ").concat(e.message)); } _this.delayedInitializationError = { kind: "event::initializationFailed", @@ -127894,7 +128557,7 @@ var ts; var cwd = getDirectoryOfPackageJson(fileName, _this.installTypingHost) || projectRootPath; if (cwd) { _this.installWorker(-1, [packageName_1], cwd, function (success) { - var message = success ? "Package " + packageName_1 + " installed." : "There was an error installing " + packageName_1 + "."; + var message = success ? "Package ".concat(packageName_1, " installed.") : "There was an error installing ".concat(packageName_1, "."); var response = { kind: server.ActionPackageInstalled, projectName: projectName_1, success: success, message: message }; _this.sendResponse(response); }); @@ -127912,7 +128575,7 @@ var ts; }; NodeTypingsInstaller.prototype.sendResponse = function (response) { if (this.log.isEnabled()) { - this.log.writeLine("Sending response:\n " + JSON.stringify(response)); + this.log.writeLine("Sending response:\n ".concat(JSON.stringify(response))); } process.send(response); if (this.log.isEnabled()) { @@ -127922,29 +128585,29 @@ var ts; NodeTypingsInstaller.prototype.installWorker = function (requestId, packageNames, cwd, onRequestCompleted) { var _this = this; if (this.log.isEnabled()) { - this.log.writeLine("#" + requestId + " with arguments'" + JSON.stringify(packageNames) + "'."); + this.log.writeLine("#".concat(requestId, " with arguments'").concat(JSON.stringify(packageNames), "'.")); } var start = Date.now(); var hasError = typingsInstaller.installNpmPackages(this.npmPath, ts.version, packageNames, function (command) { return _this.execSyncAndLog(command, { cwd: cwd }); }); if (this.log.isEnabled()) { - this.log.writeLine("npm install #" + requestId + " took: " + (Date.now() - start) + " ms"); + this.log.writeLine("npm install #".concat(requestId, " took: ").concat(Date.now() - start, " ms")); } onRequestCompleted(!hasError); }; NodeTypingsInstaller.prototype.execSyncAndLog = function (command, options) { if (this.log.isEnabled()) { - this.log.writeLine("Exec: " + command); + this.log.writeLine("Exec: ".concat(command)); } try { var stdout = this.nodeExecSync(command, __assign(__assign({}, options), { encoding: "utf-8" })); if (this.log.isEnabled()) { - this.log.writeLine(" Succeeded. stdout:" + indent(ts.sys.newLine, stdout)); + this.log.writeLine(" Succeeded. stdout:".concat(indent(ts.sys.newLine, stdout))); } return false; } catch (error) { var stdout = error.stdout, stderr = error.stderr; - this.log.writeLine(" Failed. stdout:" + indent(ts.sys.newLine, stdout) + ts.sys.newLine + " stderr:" + indent(ts.sys.newLine, stderr)); + this.log.writeLine(" Failed. stdout:".concat(indent(ts.sys.newLine, stdout)).concat(ts.sys.newLine, " stderr:").concat(indent(ts.sys.newLine, stderr))); return true; } }; @@ -127967,7 +128630,7 @@ var ts; var log = new FileLog(logFilePath); if (log.isEnabled()) { process.on("uncaughtException", function (e) { - log.writeLine("Unhandled exception: " + e + " at " + e.stack); + log.writeLine("Unhandled exception: ".concat(e, " at ").concat(e.stack)); }); } process.on("disconnect", function () { @@ -127980,7 +128643,7 @@ var ts; installer.listen(); function indent(newline, str) { return str && str.length - ? newline + " " + str.replace(/\r?\n/, newline + " ") + ? "".concat(newline, " ") + str.replace(/\r?\n/, "".concat(newline, " ")) : ""; } })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); diff --git a/lib/zh-cn/diagnosticMessages.generated.json b/lib/zh-cn/diagnosticMessages.generated.json index e6966a598071c..bc09e0e369a4a 100644 --- a/lib/zh-cn/diagnosticMessages.generated.json +++ b/lib/zh-cn/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "\"this\" 类型仅在类或接口的非静态成员中可用。", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "已在“{0}”中定义了 \"tsconfig.json\" 文件。", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "元组成员不能既是可选的又是 rest。", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "不能使用负值为元组类型编制索引。", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "乘方表达式的左侧不允许出现类型断言表达式。请考虑用括号将表达式括起。", "A_type_literal_property_cannot_have_an_initializer_1247": "类型文字数据不可具有初始化表达式。", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "仅类型导入可以指定默认导入或命名绑定,但不能同时指定这两者。", @@ -226,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "索引签名参数必须具有类型批注。", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "索引签名参数类型不能为文本类型或泛型类型。请考虑改用映射的对象类型。", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "索引签名参数类型必须是 “string”、“number”、“symbol”或模板文本类型。", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "实例化表达式不能后跟属性访问。", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "接口只能扩展具有可选类型参数的标识符/限定名称。", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "接口只能扩展使用静态已知成员的对象类型或对象类型的交集。", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "接口无法扩展基元类型,如“{0}”;接口只能扩展命名类型和类", @@ -700,6 +702,10 @@ "File_0_not_found_6053": "找不到文件“{0}”。", "File_Management_6245": "文件管理", "File_change_detected_Starting_incremental_compilation_6032": "检测到文件更改。正在启动增量编译...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "文件是 CommonJS 模块,因为“{0}”没有字段 “type”", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "文件是 CommonJS 模块,因为“{0}”具有值不是 “module” 的字段 “type”", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "文件是 CommonJS 模块,因为找不到 “package.json”", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "文件是 ECMAScript 模块,因为“{0}”具有值为 “module” 的字段 “type”", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "文件是 CommonJS 模块; 它可能会转换为 ES 模块。", "File_is_default_library_for_target_specified_here_1426": "文件是此处指定的目标的默认库。", "File_is_entry_point_of_type_library_specified_here_1419": "文件是此处指定的类型库的入口点。", @@ -774,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "应为标识符。\"{0}\" 是保留字,不能在此处使用。", "Identifier_expected_1003": "应为标识符。", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "应为标识符。转换 ECMAScript 模块时,\"__esModule\" 保留为导出标记。", + "Identifier_or_string_literal_expected_1478": "应为标识符或字符串字面量。", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "如果“{0}”包实际上公开此模块,请考虑发送拉取请求以修正“https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}”", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "如果“{0}”包实际公开了此模块,请尝试添加包含 `declare module‘{1}';` 的新声明(.d.ts)文件", "Ignore_this_error_message_90019": "忽略此错误信息", @@ -1561,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "通过 \"{0}\" 从具有 packageId \"{2}\" 的文件 \"{1}\" 引用了库类型", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "\"await\" 操作数的类型必须是有效承诺,或不得包含可调用的 \"then\" 成员。", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "计算属性类型的值为 \"{0}\",该值不能赋给 \"{1}\" 类型。", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "实例成员变量“{0}”的类型不能引用构造函数中声明的标识符“{1}”。", "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\" 成员。", @@ -1588,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== 未解析类型引用指令“{0}”。========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== 类型引用指令“{0}”已成功解析为“{1}”,主要: {2}。========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== 类型引用指令 \"{0}\" 已成功解析为 \"{1}\" ,包 ID 为 \"{2}\",主要: {3}。========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "类型不能出现在 JavaScript 文件的导出声明中。", "Types_have_separate_declarations_of_a_private_property_0_2442": "类型具有私有属性“{0}”的单独声明。", "Types_of_construct_signatures_are_incompatible_2419": "构造签名的类型不兼容。", "Types_of_parameters_0_and_1_are_incompatible_2328": "参数“{0}”和“{1}” 的类型不兼容。", @@ -1665,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "用括号将以下应为对象文字的正文括起来", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "你可以在 {0} 了解编译器选项的所有内容", "You_cannot_rename_a_module_via_a_global_import_8031": "不能通过全局导入对模块进行重命名。", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "不能重命名已在 “node_modules” 文件夹中定义的元素。", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "不能重命名已在另一个 “node_modules” 文件夹中定义的元素。", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "不能重命名标准 TypeScript 库中定义的元素。", "You_cannot_rename_this_element_8000": "无法重命名此元素。", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "“{0}”收到的参数过少,无法在此处充当修饰器。你是要先调用它,然后再写入 \"@{0}()\" 吗?", @@ -1692,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "“{0}”索引签名不兼容。", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "“{0}”索引类型“{1}”不能分配给“{2}”索引类型“{3}”。", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "“{0}”是基元,但“{1}”是包装器对象。如可能首选使用“{0}”。", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "“{0}”是一种类型,无法在 JavaScript 文件中导入。请在 JSDoc 类型批注中使用“{1}”。", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "\"{0}\" 是一种类型,在同时启用了 \"preserveValueImports\" 和 \"isolatedModules\" 时,必须使用仅类型导入进行导入。", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "“{0}”是“{1}”的未使用重命名。是否打算将其用作类型批注?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "\"{0}\" 可赋给 \"{1}\" 类型的约束,但可以使用约束 \"{2}\" 的其他子类型实例化 \"{1}\"。", + "_0_is_automatically_exported_here_18044": "“{0}”自动导出到此处。", "_0_is_declared_but_its_value_is_never_read_6133": "已声明“{0}”,但从未读取其值。", "_0_is_declared_but_never_used_6196": "“{0}”已声明,但从未使用过。", "_0_is_declared_here_2728": "在此处声明了 \"{0}\"。", diff --git a/lib/zh-tw/diagnosticMessages.generated.json b/lib/zh-tw/diagnosticMessages.generated.json index 92454df118cf1..eed2d3e67f638 100644 --- a/lib/zh-tw/diagnosticMessages.generated.json +++ b/lib/zh-tw/diagnosticMessages.generated.json @@ -94,6 +94,7 @@ "A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface_2526": "'this' 類型只適用於類別或介面的非靜態成員。", "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054": "'tsconfig.json' 檔案已定義於: '{0}'。", "A_tuple_member_cannot_be_both_optional_and_rest_5085": "元組成員不能同時為選用及待用。", + "A_tuple_type_cannot_be_indexed_with_a_negative_value_2514": "元組類型無法以負值編製索引。", "A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Con_17007": "乘冪運算式左邊不允許類型宣告運算式。請考慮以括弧括住運算式。", "A_type_literal_property_cannot_have_an_initializer_1247": "類型常值屬性不得有初始設定式。", "A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both_1363": "僅限類型的匯入可以指定預設匯入或具名繫結,但不能同時指定兩者。", @@ -226,6 +227,7 @@ "An_index_signature_parameter_must_have_a_type_annotation_1022": "索引簽章參數必須有類型註釋。", "An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "索引簽章參數類型不能是常值型別或泛型型別。請考慮改用對應的物件類型。", "An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "索引簽章參數類型必須是 'string'、'number'、'symbol' 或範本文字類型。", + "An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "具現化運算式後面不能接著屬性存取。", "An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "介面只能擴充具有選擇性型別引數的識別碼/限定名稱。", "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "介面只能延伸物件類型或具有靜態已知成員的物件類型交集。", "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "介面無法延伸基本類型,例如 '{0}';介面只能延伸命名類型和類別", @@ -700,6 +702,10 @@ "File_0_not_found_6053": "找不到檔案 '{0}'。", "File_Management_6245": "檔案管理", "File_change_detected_Starting_incremental_compilation_6032": "偵測到檔案變更。正在啟動累加編譯...", + "File_is_CommonJS_module_because_0_does_not_have_field_type_1460": "檔案是 CommonJS 模組,因為 '{0}' 沒有 \"type\" 欄位", + "File_is_CommonJS_module_because_0_has_field_type_whose_value_is_not_module_1459": "檔案是 CommonJS 模組,因為 '{0}' 具有值不是 \"module\" 的 \"type\" 欄位", + "File_is_CommonJS_module_because_package_json_was_not_found_1461": "檔案是 CommonJS 模組,因為找不到 'package.json'", + "File_is_ECMAScript_module_because_0_has_field_type_with_value_module_1458": "檔案是 ECMAScript 模組,因為 '{0}' 具有值不是 \"module\" 的 \"type\" 欄位", "File_is_a_CommonJS_module_it_may_be_converted_to_an_ES_module_80001": "檔案為 CommonJS 模組; 其可轉換為 ES 模組。", "File_is_default_library_for_target_specified_here_1426": "檔案是此處指定目標的預設程式庫。", "File_is_entry_point_of_type_library_specified_here_1419": "檔案是此處指定型別程式庫的進入點。", @@ -774,6 +780,7 @@ "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359": "必須為識別碼。'{0}' 為保留字,此處不可使用。", "Identifier_expected_1003": "必須是識別碼。", "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216": "必須有識別碼。'__esModule' 已保留為轉換 ECMAScript 模組時匯出的標記。", + "Identifier_or_string_literal_expected_1478": "需要識別碼或字串常值。", "If_the_0_package_actually_exposes_this_module_consider_sending_a_pull_request_to_amend_https_Colon_S_7040": "如果「{0}」套件實際上公開了此模組,請考慮傳送提取要求以修改 「https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/{1}」", "If_the_0_package_actually_exposes_this_module_try_adding_a_new_declaration_d_ts_file_containing_decl_7058": "如果 '{0}' 套件的確公開了此模組,請嘗試新增包含 `declare module '{1}';` 的宣告 (.d.ts) 檔案。", "Ignore_this_error_message_90019": "略過此錯誤訊息", @@ -1561,6 +1568,7 @@ "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "透過 '{0}' 從檔案 '{1}' (packageId 為 '{2}') 參考的型別程式庫", "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "'await' 運算元類型必須是有效的 Promise,或不得包含可呼叫的 'then' 成員。", "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "已計算屬性值的類型為 '{0}',其無法指派給類型 '{1}'。", + "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "執行個體成員變數 '{0}' 的類型不得參考建構函式中所宣告的識別碼 '{1}'。", "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "'yield*' 運算元的反覆項目類型必須是有效的 Promise,或不得包含可呼叫的 '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' 運算元類型必須是有效的 Promise,或不得包含可呼叫的 'then' 成員。", @@ -1588,6 +1596,7 @@ "Type_reference_directive_0_was_not_resolved_6120": "======== 類型參考指示詞 '{0}' 未解析。========", "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119": "======== 類型參考指示詞 '{0}' 已成功解析為 '{1}',主要: {2}。========", "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219": "======== 類型參考指示詞 '{0}' 已成功解析為 '{1}',套件識別碼為 '{2}',主要: {3}。========", + "Types_cannot_appear_in_export_declarations_in_JavaScript_files_18043": "類型不能出現在 JavaScript 檔案的匯出宣告中。", "Types_have_separate_declarations_of_a_private_property_0_2442": "類型具有私用屬性 '{0}' 的個別宣告。", "Types_of_construct_signatures_are_incompatible_2419": "建構簽章的類型不相容。", "Types_of_parameters_0_and_1_are_incompatible_2328": "參數 '{0}' 和 '{1}' 的類型不相容。", @@ -1665,6 +1674,8 @@ "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113": "使用括弧括住下列必須是物件常值的主體", "You_can_learn_about_all_of_the_compiler_options_at_0_6913": "您可以在以下位置了解所有編譯器選項: {0}", "You_cannot_rename_a_module_via_a_global_import_8031": "您無法透過全域匯入重新命名模組。", + "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035": "您無法重新命名 'node_modules' 資料夾中定義的元素。", + "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036": "您無法重新命名其他 'node_modules' 資料夾中定義的元素。", "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001": "您無法重新命名標準 TypeScript 程式庫中所定義的項目。", "You_cannot_rename_this_element_8000": "您無法重新命名這個項目。", "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329": "'{0}' 在此只接受極少數的引數用為裝飾項目。要先呼叫此項目,然後再寫入 '@{0}()' 嗎?", @@ -1692,9 +1703,11 @@ "_0_index_signatures_are_incompatible_2634": "'{0}' 索引簽章不相容。", "_0_index_type_1_is_not_assignable_to_2_index_type_3_2413": "'{0}' 索引類型 '{1}' 無法指派給 '{2}' 索引類型 '{3}'。", "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692": "'{0}' 為基元,但 '{1}' 為包裝函式物件。建議盡可能使用 '{0}'。", + "_0_is_a_type_and_cannot_be_imported_in_JavaScript_files_Use_1_in_a_JSDoc_type_annotation_18042": "'{0}' 為類型,無法匯入 JavaScript 檔案。在 JSDoc 類型註釋中使用 '{1}'。", "_0_is_a_type_and_must_be_imported_using_a_type_only_import_when_preserveValueImports_and_isolatedMod_1444": "'{0}' 是類型,而且當 'preserveValueImports' 和 'isolatedModules' 都啟用時,必須使用僅類型匯入來匯入。", "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842": "'{0}' 是未使用的 '{1}' 重新命名。您是否想要使用它作為類型註釋?", "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075": "'{0}' 可指派給 '{1}' 類型的條件約束,但可能會將 '{1}' 以不同的條件約束 '{2}' 子類型來具現化。", + "_0_is_automatically_exported_here_18044": "'{0}' 會自動匯出到此處。", "_0_is_declared_but_its_value_is_never_read_6133": "'{0}' 已宣告但從未讀取其值。", "_0_is_declared_but_never_used_6196": "宣告了 '{0}',但從未使用過。", "_0_is_declared_here_2728": "'{0}' 宣告於此處。", diff --git a/package.json b/package.json index 0edd1f3898aa6..40fb797e8c8bc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "4.8.0-beta", + "version": "4.8.1-rc", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index 1a9a082796323..71291f59f6ee4 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -5,7 +5,7 @@ namespace ts { // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - export const version = `${versionMajorMinor}.0-beta`; + export const version = "4.8.1-rc" as string; /** * Type of objects whose values are all of the same type.